mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-02 01:11:19 +01:00
Compare commits
194 Commits
2020.06.08
...
2020.07.23
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fb19aeae2 | ||
|
|
ad297e9c51 | ||
|
|
beb6afe101 | ||
|
|
78a6896ae9 | ||
|
|
9ea8882c05 | ||
|
|
4cf5e81971 | ||
|
|
2fa5e7d00c | ||
|
|
af17fb9f61 | ||
|
|
07869134d6 | ||
|
|
8b9a69e1f1 | ||
| 023924c4cc | |||
|
|
01d00164e5 | ||
|
|
e6c8ba0e88 | ||
| 37fc69b297 | |||
| e1e265bd49 | |||
| b46809e1c0 | |||
| 396d82bd62 | |||
| e7ff96fe8d | |||
| 07a292af95 | |||
| e4433a99a5 | |||
| 28fb1023fa | |||
|
|
c4374e623e | ||
| da2f12072f | |||
| 918da2402f | |||
| 94e9591974 | |||
| a76ed6d8db | |||
| b7cb341ee3 | |||
| 546bef5e5a | |||
|
|
97ddfed819 | ||
| 2d68b61f00 | |||
| 3bdf02a23c | |||
| f70d28b175 | |||
|
|
d076fda59a | ||
| a3062a5e00 | |||
| c6921bf954 | |||
| ae9499047b | |||
| 8dd9bb6ea3 | |||
| 9a284f75c3 | |||
| 3e87cfa5c1 | |||
| 6136eabee2 | |||
| 67bb0dff1a | |||
| ca298580f3 | |||
| d7f490701b | |||
| 7752b86d97 | |||
| 35dbc3813d | |||
| a096434864 | |||
| ab4d89aa70 | |||
| c67b7aab4d | |||
| 293fda0c7a | |||
|
|
bef35eb3d6 | ||
| eea013d492 | |||
| 890a641304 | |||
| 1e0160d655 | |||
| 42b7f6fa7c | |||
| 4a1943216b | |||
| a23504c9c4 | |||
|
|
4db3473e32 | ||
|
|
8c1c696f64 | ||
|
|
39bbc5c688 | ||
| 28b3fb4101 | |||
| 05059c1176 | |||
| 95089b5faa | |||
| 7c48ef8931 | |||
| 0dc062e6d3 | |||
| 9b1b878f95 | |||
| e23a8e7da2 | |||
| a228ae0773 | |||
| 9787c6a385 | |||
| 4d1fad04c3 | |||
| c5a9ff3024 | |||
| 25ec47dfff | |||
| 93c5505285 | |||
| a656668d73 | |||
| 3156e6f50e | |||
| f224b7dadf | |||
| ccf54f29b6 | |||
| ef564e382c | |||
| e571f7bb3e | |||
| aacc61b058 | |||
| 7d128585e1 | |||
| 279986d77c | |||
| ff729fb43f | |||
| 488e0230ba | |||
|
|
c04793a9d7 | ||
| f1cbf49449 | |||
| 285ef30439 | |||
| 75e9d63341 | |||
|
|
21a79752e2 | ||
|
|
5780cabe8d | ||
|
|
cec26f81e1 | ||
| 0c045f0faa | |||
|
|
19e40cf0e6 | ||
| 902366fede | |||
| ee67c28711 | |||
| cfe9a431f9 | |||
| 524c86de49 | |||
|
|
05ef55b258 | ||
|
|
bcd217b6fe | ||
|
|
4ca46e4123 | ||
| 7333909f6b | |||
| ba7f54744b | |||
|
|
cd677e4d97 | ||
| 4240ea57d4 | |||
| 692ade6c17 | |||
| 4cbe354396 | |||
| 39d5a7db26 | |||
| ae88af2a72 | |||
|
|
f592d21570 | ||
|
|
35f95e603e | ||
| 5c42792580 | |||
| 301073e60b | |||
| 159b0a0367 | |||
| f6911c4238 | |||
| 1d53dc65cd | |||
| 9d3bbc0a68 | |||
| 801f2c4559 | |||
|
|
da2ce03e1d | ||
|
|
f366e9ae6f | ||
|
|
5bf6b7a338 | ||
| 991acc7c07 | |||
| b40e481da9 | |||
|
|
12b40a44a2 | ||
| f14c2d06a5 | |||
| 0cc547c2de | |||
| 489fccb25c | |||
|
|
7c23f1e42c | ||
|
|
f66345d128 | ||
| e7da4ae862 | |||
| 8adddfb083 | |||
| 7cc05ead89 | |||
| ebc164aaa6 | |||
| a57f7943ee | |||
| db8616fcb3 | |||
| 55af974c4e | |||
| 1f3fd010a7 | |||
|
|
cf9ec3de0d | ||
| b5781e1f9b | |||
| e09fc8cd2b | |||
| 48b8116849 | |||
|
|
f5759921d2 | ||
| b5b50a2061 | |||
| a7d2a89c50 | |||
| e80bc905d6 | |||
|
|
c6b664b25b | ||
|
|
f078e6147d | ||
| 7609a2bda4 | |||
| d5ae9a22f4 | |||
| ffb1a59df0 | |||
| 889e926479 | |||
| 19bd39eece | |||
| f28b41b130 | |||
| 9a80975929 | |||
| efc247f46f | |||
| c0e8e44b41 | |||
| 82a6383466 | |||
| 0289f22a0d | |||
| 6a919ece02 | |||
| d0baa4c7b9 | |||
| 6dccf48759 | |||
| b128837538 | |||
| 3c46204b14 | |||
| 807a588c4b | |||
| fb5b2133f5 | |||
| 6f2413fd5d | |||
| 5412569e77 | |||
| 0375e80b42 | |||
| 569d0464e7 | |||
| cc8549e6cb | |||
| bcb5b8047b | |||
| 8c9341836b | |||
|
|
ad36ee2ba2 | ||
|
|
afa71895e7 | ||
| 62449b81ad | |||
| 6794d58db1 | |||
| 3775ff302e | |||
| e76da84c9f | |||
| 24af0ee578 | |||
| e0b86799ae | |||
|
|
5a7451e29e | ||
| e0c056be09 | |||
| cf0681a23c | |||
| 24168d5e32 | |||
| 7c2949f372 | |||
| 5a7eeb3d76 | |||
| 64a94b962a | |||
| ab72d342c9 | |||
| 200186ddde | |||
|
|
7388bb4aa7 | ||
|
|
9c26cd5552 | ||
|
|
5f91198328 | ||
|
|
265e96d675 | ||
|
|
f5160b0978 | ||
| 2a2bb5f63a | |||
| e306c39e1d |
@@ -46,6 +46,7 @@ option(SLS_BUILD_DOCS "docs" OFF)
|
||||
option(SLS_BUILD_EXAMPLES "examples" OFF)
|
||||
option(SLS_TUNE_LOCAL "tune to local machine" OFF)
|
||||
option(SLS_DEVEL_HEADERS "install headers for devel" OFF)
|
||||
option(SLS_USE_MOENCH "compile zmq and post processing for Moench" OFF)
|
||||
|
||||
# set(ClangFormat_BIN_NAME clang-format)
|
||||
set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
||||
@@ -229,6 +230,11 @@ if(SLS_BUILD_DOCS)
|
||||
add_subdirectory(docs)
|
||||
endif(SLS_BUILD_DOCS)
|
||||
|
||||
|
||||
if(SLS_USE_MOENCH)
|
||||
add_subdirectory(slsDetectorCalibration/moenchExecutables)
|
||||
endif(SLS_USE_MOENCH)
|
||||
|
||||
if(SLS_MASTER_PROJECT)
|
||||
# Set install dir CMake packages
|
||||
set(CMAKE_INSTALL_DIR "share/cmake/${PROJECT_NAME}")
|
||||
|
||||
29
cmk.sh
29
cmk.sh
@@ -12,6 +12,7 @@ TESTS=0
|
||||
SIMULATOR=0
|
||||
CTBGUI=0
|
||||
MANUALS=0
|
||||
MOENCHZMQ=0
|
||||
|
||||
|
||||
CLEAN=0
|
||||
@@ -20,7 +21,7 @@ CMAKE_PRE=""
|
||||
CMAKE_POST=""
|
||||
|
||||
usage() { echo -e "
|
||||
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [m] [-h] [-d <HDF5 directory>] [-j] <Number of threads>
|
||||
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [m] [-h] [z] [-d <HDF5 directory>] [-j] <Number of threads>
|
||||
-[no option]: only make
|
||||
-c: Clean
|
||||
-b: Builds/Rebuilds CMake files normal mode
|
||||
@@ -36,6 +37,7 @@ Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [m] [-h] [-d <HDF5 director
|
||||
-e: Debug mode
|
||||
-i: Builds tests
|
||||
-m: Manuals
|
||||
-z: Moench zmq processor
|
||||
|
||||
Rebuild when you switch to a new build and compile in parallel:
|
||||
./cmk.sh -bj5
|
||||
@@ -71,7 +73,7 @@ For rebuilding only certain sections
|
||||
|
||||
" ; exit 1; }
|
||||
|
||||
while getopts ":bpchd:j:trgeisum" opt ; do
|
||||
while getopts ":bpchd:j:trgeisumz" opt ; do
|
||||
case $opt in
|
||||
b)
|
||||
echo "Building of CMake files Required"
|
||||
@@ -130,6 +132,10 @@ while getopts ":bpchd:j:trgeisum" opt ; do
|
||||
echo "Compiling Manuals"
|
||||
MANUALS=1
|
||||
;;
|
||||
z)
|
||||
echo "Compiling Moench Zmq Processor"
|
||||
MOENCHZMQ=1
|
||||
;;
|
||||
u)
|
||||
echo "Compiling Options: Chip Test Gui"
|
||||
CTBGUI=1
|
||||
@@ -210,6 +216,12 @@ if [ $MANUALS -eq 1 ]; then
|
||||
echo "Manuals Option enabled"
|
||||
fi
|
||||
|
||||
#Moench zmq processor
|
||||
if [ $MOENCHZMQ -eq 1 ]; then
|
||||
CMAKE_POST+=" -DSLS_USE_MOENCH=ON "
|
||||
echo "Moench Zmq Processor Option enabled"
|
||||
fi
|
||||
|
||||
#Chip Test Gui
|
||||
if [ $CTBGUI -eq 1 ]; then
|
||||
CMAKE_POST+=" -DSLS_USE_CTBGUI=ON "
|
||||
@@ -259,13 +271,20 @@ if [ $COMPILERTHREADS -gt 0 ]; then
|
||||
BUILDCOMMAND="make -j$COMPILERTHREADS"
|
||||
echo $BUILDCOMMAND
|
||||
eval $BUILDCOMMAND
|
||||
if [ $MANUALS -eq 1 ]; then
|
||||
BUILDCOMMAND="make docs -j$COMPILERTHREADS"
|
||||
echo $BUILDCOMMAND
|
||||
eval $BUILDCOMMAND
|
||||
fi
|
||||
else
|
||||
echo "make"
|
||||
make
|
||||
if [ $MANUALS -eq 1 ]; then
|
||||
echo "make docs"
|
||||
make docs
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $MANUALS -eq 1 ]; then
|
||||
make docs
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -66,4 +66,10 @@ add_custom_target(docs
|
||||
${SPHINX_BUILD}/html
|
||||
COMMENT "Generating documentation with Sphinx")
|
||||
|
||||
|
||||
add_custom_target(rst
|
||||
COMMAND ${SPHINX_EXECUTABLE} -a -b html
|
||||
-Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml
|
||||
-c "${SPHINX_BUILD}"
|
||||
${SPHINX_BUILD}/src
|
||||
${SPHINX_BUILD}/html
|
||||
COMMENT "Generating documentation with Sphinx")
|
||||
|
||||
@@ -21,7 +21,7 @@ print(sys.path)
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'slsDetectorPackage'
|
||||
copyright = '2019, PSD Detector Group'
|
||||
copyright = '2020, PSD Detector Group'
|
||||
author = 'PSD Detector Group'
|
||||
version = '@PROJECT_VERSION@'
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Enums
|
||||
These enums are defined in slsDetectorDefs in the C++ package and
|
||||
exposed to Python through pybind11.
|
||||
|
||||
.. py:currentmodule:: sls_detector
|
||||
.. py:currentmodule:: slsdet
|
||||
|
||||
.. autoclass:: runStatus
|
||||
:members:
|
||||
|
||||
@@ -74,7 +74,7 @@ But lets start looking at the at the manual way:
|
||||
::
|
||||
|
||||
import time
|
||||
from sls_detector import Eiger
|
||||
from slsdet import Eiger
|
||||
d = Eiger()
|
||||
|
||||
n = 10
|
||||
@@ -114,7 +114,7 @@ hang around until the main process exits.
|
||||
|
||||
import time
|
||||
from multiprocessing import Process
|
||||
from sls_detector import Eiger
|
||||
from slsdet import Eiger
|
||||
|
||||
def acquire():
|
||||
"""
|
||||
|
||||
@@ -360,16 +360,16 @@ In the case of REAL CONTINUOUS readout, i.e. continuous acquire and readout from
|
||||
\hline
|
||||
1 & 32 & \textbf{128} & 7820 & \\
|
||||
\hline
|
||||
10 & 4 & \textbf{10240} & 98 & 105/128\\
|
||||
10 & 4 & \textbf{7813} & 98 & 105/128\\
|
||||
\hline
|
||||
10 & 8 & \textbf{5120} & 196 & 210/250\\
|
||||
10 & 8 & \textbf{4000} & 196 & 210/250\\
|
||||
\hline
|
||||
10 & 16 & \textbf{2560} & 391 & 420/490\\
|
||||
10 & 16 & \textbf{2000} & 391 & 420/490\\
|
||||
\hline
|
||||
10 & 32 & \textbf{1280} & 782 & 840/977\\
|
||||
10 & 32 & \textbf{1023} & 782 & 840/977\\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\caption{Frame rate limits for the CONTINUOS streaming out of images, i.e. the data rate out is just below 1Gb/s or 10Gb/s. 1280~Hz for 32-bit, 10GbE is obtained from the 10GbE limitation. The maximum achievable frame rate is 977~Hz.}
|
||||
\caption{Frame rate limits for the CONTINUOS streaming out of images, i.e. the data rate out is just below 1Gb/s or 10Gb/s. 1023~Hz for 32-bit, 10GbE is obtained from the 10GbE limitation. The maximum achievable frame rate is 977~Hz.}
|
||||
\label{tcont}\end{table}
|
||||
Note that in the {\tt{continuous}} flag mode, some buffering is still done on the memories, so a higher frame rate than the proper real continuous one can be achieved. Still, this extra buffering is possible till the memories are not saturated. The number of images that can be stored on the DDR2 on board memories are listed in table~\ref{timgs}.
|
||||
\begin{table}
|
||||
|
||||
@@ -12,6 +12,7 @@ target_link_libraries(_slsdet PUBLIC
|
||||
slsDetectorShared
|
||||
slsReceiverShared
|
||||
slsSupportLib
|
||||
${ZeroMQ_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Setup file for sls_detector
|
||||
Setup file for slsdet
|
||||
Build upon the pybind11 example found here: https://github.com/pybind/python_example
|
||||
"""
|
||||
from setuptools import setup, Extension, find_packages
|
||||
|
||||
@@ -178,7 +178,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@exptime.setter
|
||||
def exptime(self, t):
|
||||
self.setExptime(ut.make_timedelta(t))
|
||||
self.setExptime(t)
|
||||
|
||||
@property
|
||||
def period(self):
|
||||
@@ -187,7 +187,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@period.setter
|
||||
def period(self, t):
|
||||
self.setPeriod(ut.make_timedelta(t))
|
||||
self.setPeriod(t)
|
||||
|
||||
@property
|
||||
@element
|
||||
@@ -196,7 +196,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@delay.setter
|
||||
def delay(self, t):
|
||||
self.setDelayAfterTrigger(ut.make_timedelta(t))
|
||||
self.setDelayAfterTrigger(t)
|
||||
|
||||
@property
|
||||
@element
|
||||
@@ -639,7 +639,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@property
|
||||
def vthreshold(self):
|
||||
return element_if_equal(self.getDAC(dacIndex.THRESHOLD))
|
||||
return element_if_equal(self.getDAC(dacIndex.VTHRESHOLD, False))
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
@@ -663,7 +663,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@subexptime.setter
|
||||
def subexptime(self, t):
|
||||
self.setSubExptime(ut.make_timedelta(t))
|
||||
self.setSubExptime(t)
|
||||
|
||||
@property
|
||||
def subdeadtime(self):
|
||||
@@ -672,7 +672,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@subdeadtime.setter
|
||||
def subdeadtime(self, t):
|
||||
self.setSubDeadTime(ut.make_timedelta(t))
|
||||
self.setSubDeadTime(t)
|
||||
|
||||
@property
|
||||
def partialreset(self):
|
||||
@@ -732,13 +732,6 @@ class Detector(CppDetectorApi):
|
||||
res = self.getMeasuredSubFramePeriod()
|
||||
return element_if_equal([it.total_seconds() for it in res])
|
||||
|
||||
@property
|
||||
def storeinram(self):
|
||||
return element_if_equal(self.getStoreInRamMode())
|
||||
|
||||
@storeinram.setter
|
||||
def storeinram(self, value):
|
||||
self.setStoreInRamMode(value)
|
||||
|
||||
"""
|
||||
Jungfrau specific
|
||||
@@ -778,7 +771,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@storagecell_delay.setter
|
||||
def storagecell_delay(self, t):
|
||||
self.setStorageCellDelay(ut.make_timedelta(t))
|
||||
self.setStorageCellDelay(t)
|
||||
|
||||
@property
|
||||
@element
|
||||
@@ -846,9 +839,9 @@ class Detector(CppDetectorApi):
|
||||
if is_iterable(value):
|
||||
if len(value) == 3:
|
||||
for i, v in enumerate(value):
|
||||
self.setGateDelay(i, ut.make_timedelta(v))
|
||||
self.setGateDelay(i, v)
|
||||
else:
|
||||
self.setGateDelay(-1, ut.make_timedelta(value))
|
||||
self.setGateDelay(-1, value)
|
||||
|
||||
@property
|
||||
def counters(self):
|
||||
@@ -981,14 +974,6 @@ class Detector(CppDetectorApi):
|
||||
print("Set only")
|
||||
return 0
|
||||
|
||||
@property
|
||||
def patclkctrl(self):
|
||||
return element_if_equal(self.getPatternClockControl())
|
||||
|
||||
@patclkctrl.setter
|
||||
def patclkctrl(self, mask):
|
||||
self.setPatternClockControl(mask)
|
||||
|
||||
# patioctrl
|
||||
@property
|
||||
def patioctrl(self):
|
||||
|
||||
@@ -60,23 +60,23 @@ class EigerDacs(DetectorDacs):
|
||||
"""
|
||||
Eiger specific dacs
|
||||
"""
|
||||
_dacs = [('vsvp', dacIndex.SVP,0, 4000, 0),
|
||||
('vtr', dacIndex.VTR,0, 4000, 2500),
|
||||
('vrf', dacIndex.VRF,0, 4000, 3300),
|
||||
('vrs', dacIndex.VRS,0, 4000, 1400),
|
||||
('vsvn', dacIndex.SVN,0, 4000, 4000),
|
||||
('vtgstv', dacIndex.VTGSTV,0, 4000, 2556),
|
||||
('vcmp_ll', dacIndex.VCMP_LL,0, 4000, 1500),
|
||||
('vcmp_lr', dacIndex.VCMP_LR,0, 4000, 1500),
|
||||
('vcall', dacIndex.CAL,0, 4000, 4000),
|
||||
('vcmp_rl', dacIndex.VCMP_RL,0, 4000, 1500),
|
||||
('rxb_rb', dacIndex.RXB_RB,0, 4000, 1100),
|
||||
('rxb_lb', dacIndex.RXB_LB,0, 4000, 1100),
|
||||
('vcmp_rr', dacIndex.VCMP_RR,0, 4000, 1500),
|
||||
('vcp', dacIndex.VCP,0, 4000, 200),
|
||||
('vcn', dacIndex.VCN,0, 4000, 2000),
|
||||
('vis', dacIndex.VIS,0, 4000, 1550),
|
||||
('iodelay', dacIndex.IO_DELAY,0, 4000, 660)]
|
||||
_dacs = [('vsvp', dacIndex.VSVP,0, 4000, 0),
|
||||
('vtrim', dacIndex.VTRIM,0, 4000, 2500),
|
||||
('vrpreamp', dacIndex.VRPREAMP,0, 4000, 3300),
|
||||
('vrshaper', dacIndex.VRSHAPER,0, 4000, 1400),
|
||||
('vsvn', dacIndex.VSVN,0, 4000, 4000),
|
||||
('vtgstv', dacIndex.VTGSTV,0, 4000, 2556),
|
||||
('vcmp_ll', dacIndex.VCMP_LL,0, 4000, 1500),
|
||||
('vcmp_lr', dacIndex.VCMP_LR,0, 4000, 1500),
|
||||
('vcal', dacIndex.VCAL,0, 4000, 4000),
|
||||
('vcmp_rl', dacIndex.VCMP_RL,0, 4000, 1500),
|
||||
('rxb_rb', dacIndex.RXB_RB,0, 4000, 1100),
|
||||
('rxb_lb', dacIndex.RXB_LB,0, 4000, 1100),
|
||||
('vcmp_rr', dacIndex.VCMP_RR,0, 4000, 1500),
|
||||
('vcp', dacIndex.VCP,0, 4000, 200),
|
||||
('vcn', dacIndex.VCN,0, 4000, 2000),
|
||||
('vishaper', dacIndex.VISHAPER,0, 4000, 1550),
|
||||
('iodelay', dacIndex.IO_DELAY,0, 4000, 660)]
|
||||
_dacnames = [_d[0] for _d in _dacs]
|
||||
|
||||
# # noinspection PyProtectedMember
|
||||
|
||||
@@ -13,49 +13,32 @@ import _slsdet
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
from .detector_property import DetectorProperty
|
||||
|
||||
# vcassh 1200,
|
||||
# vth2 2800,
|
||||
# vshaper 1280,
|
||||
# vshaperneg 2800,
|
||||
# vipre_out 1220,
|
||||
# vth3 2800,
|
||||
# vth1 2800,
|
||||
# vicin 1708,
|
||||
# vcas 1800,
|
||||
# vpreamp 1100,
|
||||
# vpl 1100,
|
||||
# vipre 2624,
|
||||
# viinsh 1708,
|
||||
# vph 1712,
|
||||
# vtrim 2800,
|
||||
# vdcsh 800
|
||||
|
||||
|
||||
# @freeze
|
||||
class Mythen3Dacs(DetectorDacs):
|
||||
"""
|
||||
Jungfrau specific DACs
|
||||
"""
|
||||
_dacs = [('vcassh', dacIndex.CASSH, 0, 4000, 1220),
|
||||
_dacs = [('vcassh', dacIndex.VCASSH, 0, 4000, 1220),
|
||||
('vth2', dacIndex.VTH2, 0, 4000, 2800),
|
||||
('vshaper', dacIndex.SHAPER1, 0, 4000, 1280),
|
||||
('vshaperneg', dacIndex.SHAPER2, 0, 4000, 2800),
|
||||
('vrshaper', dacIndex.VRSHAPER, 0, 4000, 1280),
|
||||
('vrshaper_n', dacIndex.VRSHAPER_N, 0, 4000, 2800),
|
||||
('vipre_out', dacIndex.VIPRE_OUT, 0, 4000, 1220),
|
||||
('vth3', dacIndex.VTH3, 0, 4000, 2800),
|
||||
('vth1', dacIndex.THRESHOLD, 0, 4000, 2800),
|
||||
('vth1', dacIndex.VTH1, 0, 4000, 2800),
|
||||
('vicin', dacIndex.VICIN, 0, 4000, 1708),
|
||||
('vcas', dacIndex.CAS, 0, 4000, 1800),
|
||||
('vpreamp', dacIndex.PREAMP, 0, 4000, 1100),
|
||||
('vpl', dacIndex.VPL, 0, 4000, 1100),
|
||||
('vcas', dacIndex.VCAS, 0, 4000, 1800),
|
||||
('vrpreamp', dacIndex.VRPREAMP, 0, 4000, 1100),
|
||||
('vcal_n', dacIndex.VCAL_N, 0, 4000, 1100),
|
||||
('vipre', dacIndex.VIPRE, 0, 4000, 2624),
|
||||
('viinsh', dacIndex.VIINSH, 0, 4000, 1708),
|
||||
('vph', dacIndex.CALIBRATION_PULSE, 0, 4000, 1712),
|
||||
('vtrim', dacIndex.TRIMBIT_SIZE, 0, 4000, 2800),
|
||||
('vdcsh', dacIndex.VDCSH, 0, 4000, 800),
|
||||
('vishaper', dacIndex.VISHAPER, 0, 4000, 1708),
|
||||
('vcal_p', dacIndex.VCAL_P, 0, 4000, 1712),
|
||||
('vtrim', dacIndex.VTRIM, 0, 4000, 2800),
|
||||
('vdcsh', dacIndex.VDCSH, 0, 4000, 800),
|
||||
]
|
||||
_dacnames = [_d[0] for _d in _dacs]
|
||||
|
||||
|
||||
#vthreshold??
|
||||
|
||||
|
||||
@freeze
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = python -msphinx
|
||||
SPHINXPROJ = sls_detector_tools
|
||||
SOURCEDIR = .
|
||||
BUILDDIR = _build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 44 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 MiB |
@@ -1,134 +0,0 @@
|
||||
Code quality
|
||||
=============================
|
||||
|
||||
For usability and reliability of the software the code needs to be high quality. For this
|
||||
project it means meeting the four criteria described below. Any addition should pass all of
|
||||
them.
|
||||
|
||||
|
||||
--------------------------------
|
||||
Look, read and feel like Python
|
||||
--------------------------------
|
||||
|
||||
When using classes and functions from the
|
||||
package it should feel like you are using Python tools and be forces
|
||||
to write C++ style code with Python syntax.
|
||||
|
||||
::
|
||||
|
||||
with xray_box.shutter_open():
|
||||
for th in threshold:
|
||||
d.vthreshold = th
|
||||
d.acq()
|
||||
|
||||
should be preferred over
|
||||
|
||||
::
|
||||
|
||||
N = len(threshold)
|
||||
xray_box.open_shutter()
|
||||
for i in range(N):
|
||||
d.dacs.set_dac('vthreshold', threshold[i])
|
||||
d.acq()
|
||||
xray_box.close_shutter()
|
||||
|
||||
even if the difference might seem small.
|
||||
|
||||
--------------------
|
||||
Have documentation
|
||||
--------------------
|
||||
|
||||
Classes and functions should be documented with doc-strings
|
||||
in the source code. Preferably with examples. The syntax to be used
|
||||
is numpy-sphinx.
|
||||
|
||||
::
|
||||
|
||||
def function(arg):
|
||||
"""
|
||||
This is a function that does something
|
||||
|
||||
Parameters
|
||||
----------
|
||||
arg: int
|
||||
An argument
|
||||
|
||||
Returns
|
||||
--------
|
||||
value: double
|
||||
Returns a value
|
||||
|
||||
"""
|
||||
return np.sin(arg+np.pi)
|
||||
|
||||
---------------------------------
|
||||
Pass static analysis with pylint
|
||||
---------------------------------
|
||||
|
||||
Yes, anything less than 9/10 just means that you are lazy. If
|
||||
there is a good reason why to diverge, then we can always
|
||||
add an exception.
|
||||
|
||||
Currently the following additions are made:
|
||||
|
||||
* good-names: x, y, ax, im etc.
|
||||
* function arguments 10
|
||||
* Whitelist: numpy, _sls
|
||||
|
||||
|
||||
|
||||
-----------------------
|
||||
Tested code
|
||||
-----------------------
|
||||
|
||||
Last but not least... *actually last just because of the long list included.*
|
||||
All code that goes in should have adequate tests. If a new function does not
|
||||
have a minimum of one test it does not get added.
|
||||
|
||||
**Unit-tests with pytest and mocker**
|
||||
|
||||
::
|
||||
|
||||
----------- coverage: platform linux, python 3.6.4-final-0 -----------
|
||||
Name Stmts Miss Cover
|
||||
------------------------------------------------
|
||||
sls_detector/__init__.py 4 0 100%
|
||||
sls_detector/decorators.py 14 3 79%
|
||||
sls_detector/detector.py 461 115 75%
|
||||
sls_detector/eiger.py 150 64 57%
|
||||
sls_detector/errors.py 7 0 100%
|
||||
sls_detector/jungfrau.py 59 26 56%
|
||||
------------------------------------------------
|
||||
TOTAL 695 208 70%
|
||||
|
||||
|
||||
========= 78 passed in 0.60 seconds =========
|
||||
|
||||
|
||||
|
||||
**Simple integration tests**
|
||||
|
||||
These tests require a detector connected. Performs simple tasks like setting
|
||||
exposure time and reading back to double check the value
|
||||
|
||||
::
|
||||
|
||||
----------- coverage: platform linux, python 3.6.4-final-0 -----------
|
||||
Name Stmts Miss Cover
|
||||
------------------------------------------------
|
||||
sls_detector/__init__.py 4 0 100%
|
||||
sls_detector/decorators.py 14 0 100%
|
||||
sls_detector/detector.py 461 103 78%
|
||||
sls_detector/eiger.py 150 20 87%
|
||||
sls_detector/errors.py 7 0 100%
|
||||
sls_detector/jungfrau.py 59 26 56%
|
||||
------------------------------------------------
|
||||
TOTAL 695 149 79%
|
||||
|
||||
|
||||
========= 67 passed, 1 skipped in 16.66 seconds =========
|
||||
|
||||
**Complex integration test**
|
||||
|
||||
Typical measurements. Might require X-rays. Tests are usually evaluated from
|
||||
plots
|
||||
@@ -1,370 +0,0 @@
|
||||
Command line to Python
|
||||
=========================
|
||||
|
||||
If you are already familiar with the command line interface to the
|
||||
slsDetectorSoftware here is a quick reference translating to Python commands
|
||||
|
||||
|
||||
.. note ::
|
||||
|
||||
Commands labeled Mythen only or Gotthard only are currently not implemented in the
|
||||
Python class. If you need this functionallity please contact the SLS Detector Group
|
||||
|
||||
.. py:currentmodule:: sls_detector
|
||||
|
||||
.. |ro| replace:: *(read only)*
|
||||
.. |free| replace:: :py:func:`Detector.free_shared_memory`
|
||||
.. |sub| replace:: :py:attr:`Detector.sub_exposure_time`
|
||||
.. |mg| replace:: Mythen and Gotthard only
|
||||
.. |g| replace:: Gotthard only
|
||||
.. |m| replace:: Mythen only
|
||||
.. |msp| replace:: :py:attr:`Detector.measured_subperiod`
|
||||
.. |new_chiptest| replace:: New chip test board only
|
||||
.. |chiptest| replace:: Chip test board only
|
||||
.. |dr| replace:: :py:attr:`Detector.dynamic_range`
|
||||
.. |j| replace:: Jungfrau only
|
||||
.. |te| replace:: :py:attr:`Detector.trimmed_energies`
|
||||
.. |temp_fpgaext| replace:: :py:attr:`Detector.temp`.fpgaext
|
||||
.. |epa| replace:: :py:func:`Eiger.pulse_all_pixels`
|
||||
.. |rfc| replace:: :py:func:`Detector.reset_frames_caught`
|
||||
.. |rfi| replace:: :py:attr:`Detector.receiver_frame_index`
|
||||
.. |ron| replace:: :py:attr:`Detector.receiver_online`
|
||||
.. |flipy| replace:: :py:attr:`Detector.flipped_data_y`
|
||||
.. |flipx| replace:: :py:attr:`Detector.flipped_data_x`
|
||||
.. |adcr| replace:: :py:func:`DetectorApi.writeAdcRegister`
|
||||
.. |sb| replace:: :py:func:`DetectorApi.setBitInRegister`
|
||||
.. |cb| replace:: :py:func:`DetectorApi.clearBitInRegister`
|
||||
.. |tempth| replace:: :py:attr:`Jungfrau.temperature_threshold`
|
||||
.. |tempev| replace:: :py:attr:`Jungfrau.temperature_event`
|
||||
.. |tempco| replace:: :py:attr:`Jungfrau.temperature_control`
|
||||
.. |depr| replace:: *Deprecated/Internal*
|
||||
.. |nimp| replace:: *Not implemented*
|
||||
.. |rudp| replace:: :py:attr:`Detector.rx_realudpsocksize`
|
||||
.. |lci| replace:: :py:attr:`Detector.last_client_ip`
|
||||
.. |rlci| replace:: :py:attr:`Detector.receiver_last_client_ip`
|
||||
.. |fdp| replace:: :py:attr:`Detector.frame_discard_policy`
|
||||
.. |apic| replace:: :py:attr:`Detector.api_compatibility`
|
||||
|
||||
|
||||
------------------------
|
||||
Commands
|
||||
------------------------
|
||||
|
||||
===================== ===================================== ================== =========
|
||||
Command Python Implementation Tests
|
||||
===================== ===================================== ================== =========
|
||||
sls_detector_acquire :py:func:`Detector.acq` OK OK
|
||||
test |depr| \- \-
|
||||
help help(Detector.acq) \- \-
|
||||
exitserver |depr| \- \-
|
||||
exitreceiver |depr| \- \-
|
||||
flippeddatay |flipy| OK \-
|
||||
digitest |depr| \- \-
|
||||
bustest |depr| \- \-
|
||||
digibittest Which detector? \- \-
|
||||
reg :py:attr:`Detector.register` OK \-
|
||||
adcreg |adcr| OK \-
|
||||
setbit |sb| OK \-
|
||||
clearbit |cb| OK \-
|
||||
getbit |nimp| \- \-
|
||||
r_compression Not implemented in receiver \- \-
|
||||
acquire :py:func:`Detector.acq` OK \-
|
||||
busy :py:attr:`Detector.busy` OK Partial
|
||||
status :py:attr:`Detector.status` OK |ro| \-
|
||||
status start :py:func:`Detector.start_detector` OK \-
|
||||
status stop :py:func:`Detector.stop_detector` OK \-
|
||||
data |depr| \- \-
|
||||
frame |depr| \- \-
|
||||
readctr |g| \- \-
|
||||
resetctr |g| \- \-
|
||||
resmat :py:attr:`Eiger.eiger_matrix_reset` OK OK
|
||||
free |free| OK \-
|
||||
hostname :py:attr:`Detector.hostname` OK OK
|
||||
add |nimp| \- \-
|
||||
replace |nimp| \- \-
|
||||
user |nimp| \- \-
|
||||
master |nimp| \- \-
|
||||
sync Which detector? \- \-
|
||||
online :py:attr:`Detector.online` OK \-
|
||||
checkonline |nimp| \- \-
|
||||
activate :py:attr:`Eiger.active` \- \-
|
||||
nmod :py:attr:`Detector.n_modules` OK \-
|
||||
maxmod |depr| \- \-
|
||||
dr |dr| OK OK
|
||||
roi |g| \- \-
|
||||
detsizechan :py:attr:`Detector.image_size` OK \-
|
||||
roimask |nimp| \- \-
|
||||
flippeddatax |flipx| OK \-
|
||||
tengiga :py:attr:`Eiger.tengiga` OK \-
|
||||
gappixels :py:attr:`Eiger.add_gappixels` OK \-
|
||||
flags :py:attr:`Detector.flags` OK \-
|
||||
extsig |mg| \- \-
|
||||
programfpga |j| \- \-
|
||||
resetfpga |j| \- \-
|
||||
powerchip :py:attr:`Jungfrau.powerchip` \- \-
|
||||
led |nimp| \- \-
|
||||
auto_comp_disable |j| \- \-
|
||||
pulse Used in |epa| OK \-
|
||||
pulsenmove Used in |epa| OK \-
|
||||
pulsechip :py:func:`Eiger.pulse_chip` OK \-
|
||||
checkdetversion |apic| \- \-
|
||||
checkrecversion |apic| \- \-
|
||||
moduleversion |m| \- \-
|
||||
detectornumber :py:attr:`Detector.detector_number` OK \-
|
||||
modulenumber |m| \- \-
|
||||
detectorversion :py:attr:`Detector.firmware_version` OK OK
|
||||
softwareversion :py:attr:`Detector.server_version` \- \-
|
||||
thisversion :py:attr:`Detector.client_version` Reads date \-
|
||||
receiverversion :py:attr:`Detector.receiver_version` Reads date \-
|
||||
timing :py:attr:`Detector.timing_mode` OK \-
|
||||
exptime :py:attr:`Detector.exposure_time` OK OK
|
||||
subexptime |sub| OK OK
|
||||
period :py:attr:`Detector.period` OK OK
|
||||
subdeadtime :py:attr:`Eiger.sub_deadtime` OK OK
|
||||
delay :py:attr:`Jungfrau.delay` OK \-
|
||||
gates :py:attr:`Jungfrau.n_gates` OK \-
|
||||
frames :py:attr:`Detector.n_frames` OK OK
|
||||
cycles :py:attr:`Detector.n_cycles` OK \-
|
||||
probes :py:attr:`Jungfrau.n_probes` OK \-
|
||||
measurements :py:attr:`Detector.n_measurements` OK \-
|
||||
samples Chip test board only (new?) \- \-
|
||||
storagecells :py:attr:`Jungfrau.n_storagecells` OK \-
|
||||
storagecell_start :py:attr:`Jungfrau.storagecell_start` OK \-
|
||||
exptimel |mg| \- \-
|
||||
periodl |mg| \- \-
|
||||
delayl |mg| \- \-
|
||||
gatesl |mg| \- \-
|
||||
framesl |mg| \- \-
|
||||
cyclesl |mg| \- \-
|
||||
probesl |mg| \- \-
|
||||
now |nimp| \- \-
|
||||
timestamp |m| \- \-
|
||||
nframes |nimp| \- \-
|
||||
measuredperiod :py:attr:`Detector.measured_period` OK \-
|
||||
measuredsubperiod |msp| \- \-
|
||||
clkdivider :py:attr:`Detector.readout_clock` OK OK
|
||||
setlength |m| \- \-
|
||||
waitstates |m| \- \-
|
||||
totdivider |m| \- \-
|
||||
totdutycycle |m| \- \-
|
||||
phasestep |g| \- \-
|
||||
oversampling |new_chiptest| \- \-
|
||||
adcclk |new_chiptest| \- \-
|
||||
adcphase |new_chiptest| \- \-
|
||||
adcpipeline |new_chiptest| \- \-
|
||||
dbitclk |new_chiptest| \- \-
|
||||
dbitphase |new_chiptest| \- \-
|
||||
dbitpipeline |new_chiptest| \- \-
|
||||
config :py:func:`Detector.load_config` OK \-
|
||||
rx_printconfig |nimp| \- \-
|
||||
parameters :py:func:`Detector.load_parameters` OK \-
|
||||
setup |nimp| \- \-
|
||||
flatfield |nimp| \- \-
|
||||
ffdir |nimp| \- \-
|
||||
ratecorr :py:attr:`Detector.rate_correction` OK \-
|
||||
badchannels |nimp| \- \-
|
||||
angconv |m| \- \-
|
||||
globaloff |nimp| \- \-
|
||||
fineoff |nimp| \- \-
|
||||
binsize |nimp| \- \-
|
||||
angdir |nimp| \- \-
|
||||
moveflag |nimp| \- \-
|
||||
samplex |nimp| \- \-
|
||||
sampley |nimp| \- \-
|
||||
threaded :py:attr:`Detector.threaded` OK \-
|
||||
darkimage |nimp| \- \-
|
||||
gainimage |nimp| \- \-
|
||||
settingsdir :py:attr:`Detector.settings_path` OK \-
|
||||
trimdir |nimp| \- \-
|
||||
caldir |nimp| \- \-
|
||||
trimen :py:attr:`Detector.trimmed_energies` OK \-
|
||||
settings :py:attr:`Detector.settings` OK \-
|
||||
threshold :py:attr:`Detector.threshold` OK \-
|
||||
thresholdnotb |nimp| \- \-
|
||||
trimbits :py:func:`Detector.load_trimbits` OK \-
|
||||
trim |nimp| \- \-
|
||||
trimval :py:attr:`Detector.trimbits` OK OK
|
||||
pedestal |nimp| \- \-
|
||||
vthreshold :py:attr:`Detector.vthreshold` OK \-
|
||||
vcalibration |nimp| \- \-
|
||||
vtrimbit |nimp| \- \-
|
||||
vpreamp |nimp| \- \-
|
||||
vshaper1 |nimp| \- \-
|
||||
vshaper2 |nimp| \- \-
|
||||
vhighvoltage :py:attr:`Detector.high_voltage` OK \-
|
||||
vapower |nimp| \- \-
|
||||
vddpower |nimp| \- \-
|
||||
vshpower |nimp| \- \-
|
||||
viopower |nimp| \- \-
|
||||
vref_ds :py:attr:`Jungfrau.dacs.vref_ds` OK \-
|
||||
vcascn_pb |nimp| \- \-
|
||||
vcascp_pb |nimp| \- \-
|
||||
vout_cm |nimp| \- \-
|
||||
vcasc_out |nimp| \- \-
|
||||
vin_cm |nimp| \- \-
|
||||
vref_comp |nimp| \- \-
|
||||
ib_test_c |nimp| \- \-
|
||||
dac0 |nimp| \- \-
|
||||
dac1 |nimp| \- \-
|
||||
dac2 |nimp| \- \-
|
||||
dac3 |nimp| \- \-
|
||||
dac4 |nimp| \- \-
|
||||
dac5 |nimp| \- \-
|
||||
dac6 |nimp| \- \-
|
||||
dac7 |nimp| \- \-
|
||||
vsvp :py:attr:`Eiger.dacs.vsvp` OK \-
|
||||
vsvn :py:attr:`Eiger.dacs.vsvn` OK \-
|
||||
vtr :py:attr:`Eiger.dacs.vtr` OK \-
|
||||
vrf :py:attr:`Eiger.dacs.vrf` OK \-
|
||||
vrs :py:attr:`Eiger.dacs.vrs` OK \-
|
||||
vtgstv :py:attr:`Eiger.dacs.vtgstv` OK \-
|
||||
vcmp_ll :py:attr:`Eiger.dacs.vcmp_ll` OK \-
|
||||
vcmp_ll :py:attr:`Eiger.dacs.vcmp_ll` OK \-
|
||||
vcall :py:attr:`Eiger.dacs.vcall` OK \-
|
||||
vcmp_rl :py:attr:`Eiger.dacs.vcmp_rl` OK \-
|
||||
vcmp_rr :py:attr:`Eiger.dacs.vcmp_rr` OK \-
|
||||
rxb_rb :py:attr:`Eiger.dacs.rxb_rb` OK \-
|
||||
rxb_lb :py:attr:`Eiger.dacs.rxb_lb` OK \-
|
||||
vcp :py:attr:`Eiger.dacs.vcp` OK \-
|
||||
vcn :py:attr:`Eiger.dacs.vcn` OK \-
|
||||
vis :py:attr:`Eiger.dacs.vis` OK \-
|
||||
iodelay :py:attr:`Eiger.dacs.iodelay` OK \-
|
||||
dac |nimp| \- \-
|
||||
adcvpp |nimp| \- \-
|
||||
v_a |nimp| \- \-
|
||||
v_b |nimp| \- \-
|
||||
v_c |nimp| \- \-
|
||||
v_d |nimp| \- \-
|
||||
v_io |nimp| \- \-
|
||||
v_chip |nimp| \- \-
|
||||
v_limit |nimp| \- \-
|
||||
vIpre |nimp| \- \-
|
||||
VcdSh |nimp| \- \-
|
||||
Vth1 |nimp| \- \-
|
||||
Vth2 |nimp| \- \-
|
||||
Vth3 |nimp| \- \-
|
||||
VPL |nimp| \- \-
|
||||
Vtrim |nimp| \- \-
|
||||
vIbias |nimp| \- \-
|
||||
vIinSh |nimp| \- \-
|
||||
cas |nimp| \- \-
|
||||
casSh |nimp| \- \-
|
||||
vIbiasSh |nimp| \- \-
|
||||
vIcin |nimp| \- \-
|
||||
vIpreOut |nimp| \- \-
|
||||
temp_adc |nimp| \- \-
|
||||
temp_fpga :py:attr:`Detector.temp`.fpga OK \-
|
||||
temp_fpgaext |temp_fpgaext| OK \-
|
||||
temp_10ge :py:attr:`Detector.temp`.t10ge OK \-
|
||||
temp_dcdc :py:attr:`Detector.temp`.dcdc OK \-
|
||||
temp_sodl :py:attr:`Detector.temp`.sodl OK \-
|
||||
temp_sodr :py:attr:`Detector.temp`.sodr OK \-
|
||||
adc |nimp| \- \-
|
||||
temp_fpgafl :py:attr:`Detector.temp`.fpgafl OK \-
|
||||
temp_fpgafr :py:attr:`Detector.temp`.fpgafr OK \-
|
||||
i_a |nimp| \- \-
|
||||
i_b |nimp| \- \-
|
||||
i_c |nimp| \- \-
|
||||
i_d |nimp| \- \-
|
||||
i_io |nimp| \- \-
|
||||
vm_a |nimp| \- \-
|
||||
vm_b |nimp| \- \-
|
||||
vm_c |nimp| \- \-
|
||||
vm_d |nimp| \- \-
|
||||
vm_io |nimp| \- \-
|
||||
temp_threshold |tempth| \- \-
|
||||
temp_control |tempco| \- \-
|
||||
temp_event |tempev| \- \-
|
||||
outdir :py:attr:`Detector.file_path` OK OK
|
||||
fname :py:attr:`Detector.file_name` OK OK
|
||||
index :py:attr:`Detector.file_index` OK OK
|
||||
enablefwrite :py:attr:`Detector.file_write` OK OK
|
||||
overwrite :py:attr:`Detector.file_overwrite` OK \-
|
||||
currentfname |nimp| \- \-
|
||||
fileformat :py:attr:`Detector.file_format` OK \-
|
||||
positions |depr| \- \-
|
||||
startscript |depr| \- \-
|
||||
startscriptpar |depr| \- \-
|
||||
stopscript |depr| \- \-
|
||||
stopscriptpar |depr| \- \-
|
||||
scriptbefore |depr| \- \-
|
||||
scriptbeforepar |depr| \- \-
|
||||
scriptafter |depr| \- \-
|
||||
scriptafterpar |depr| \- \-
|
||||
headerafter |depr| \- \-
|
||||
headerbefore |depr| \- \-
|
||||
headerbeforepar |depr| \- \-
|
||||
headerafterpar |depr| \- \-
|
||||
encallog |depr| \- \-
|
||||
angcallog |depr| \- \-
|
||||
scan0script |depr| \- \-
|
||||
scan0par |depr| \- \-
|
||||
scan0prec |depr| \- \-
|
||||
scan0steps |depr| \- \-
|
||||
scan0range |depr| \- \-
|
||||
scan1script |depr| \- \-
|
||||
scan1par |depr| \- \-
|
||||
scan1prec |depr| \- \-
|
||||
scan1steps |depr| \- \-
|
||||
scan1range |depr| \- \-
|
||||
rx_hostname :py:attr:`Detector.rx_hostname` OK \-
|
||||
rx_udpip :py:attr:`Detector.rx_udpip` OK \-
|
||||
rx_udpmac :py:attr:`Detector.rx_udpmac` OK \-
|
||||
rx_udpport :py:attr:`Detector.rx_udpport` OK \-
|
||||
rx_udpport2 :py:attr:`Detector.rx_udpport` OK \-
|
||||
rx_udpsocksize :py:attr:`Detector.rx_udpsocksize` OK \-
|
||||
rx_realudpsocksize |rudp| OK
|
||||
detectormac :py:attr:`Detector.detector_mac` OK \-
|
||||
detectorip :py:attr:`Detector.detector_ip` OK \-
|
||||
txndelay_left :py:attr:`Eiger.delay`.left OK \-
|
||||
txndelay_right :py:attr:`Eiger.delay`.right OK \-
|
||||
txndelay_frame :py:attr:`Eiger.delay`.frame OK \-
|
||||
flowcontrol_10g :py:attr:`Eiger.flowcontrol_10g` OK \-
|
||||
zmqport :py:attr:`Detector.client_zmqport` Read \-
|
||||
rx_zmqport :py:attr:`Detector.rx_zmqport` Read \-
|
||||
rx_datastream :py:attr:`Detector.rx_datastream` OK \-
|
||||
zmqip :py:attr:`Detector.client_zmqip` OK \-
|
||||
rx_zmqip :py:attr:`Detector.rx_zmqip` Read \-
|
||||
rx_jsonaddheader :py:attr:`Detector.rx_jsonaddheader` OK \-
|
||||
configuremac :py:attr:`Detector.config_network` OK \-
|
||||
rx_tcpport :py:attr:`Detector.rx_tcpport`
|
||||
port |nimp| \- \-
|
||||
stopport |nimp| \- \-
|
||||
lock :py:attr:`Detector.lock` OK \-
|
||||
lastclient :py:attr:`Detector.last_client_ip` OK \-
|
||||
receiver start :py:func:`Detector.start_receiver` OK \-
|
||||
receiver stop :py:func:`Detector.stop_receiver` \- \-
|
||||
r_online |ron| OK \-
|
||||
r_checkonline |nimp| \- \-
|
||||
framescaught :py:attr:`Detector.frames_caught` OK \-
|
||||
resetframescaught |rfc| OK \-
|
||||
frameindex |rfi| OK \-
|
||||
r_lock :py:attr:`Detector.lock_receiver` OK \-
|
||||
r_lastclient |rlci| OK \-
|
||||
r_readfreq |nimp| \- \-
|
||||
rx_fifodepth :py:attr:`Detector.rx_fifodepth` OK \-
|
||||
r_silent |nimp| \- \-
|
||||
r_framesperfile :py:attr:`Detector.n_frames_per_file` OK \-
|
||||
r_discardpolicy |fdp| OK \-
|
||||
r_padding :py:attr:`Detector.file_padding` OK \-
|
||||
adcinvert |chiptest| \- \-
|
||||
adcdisable |chiptest| \- \-
|
||||
pattern |chiptest| \- \-
|
||||
patword |chiptest| \- \-
|
||||
patioctrl |chiptest| \- \-
|
||||
patclkctrl |chiptest| \- \-
|
||||
patlimits |chiptest| \- \-
|
||||
patloop0 |chiptest| \- \-
|
||||
patnloop0 |chiptest| \- \-
|
||||
patwait0 |chiptest| \- \-
|
||||
patwaittime0 |chiptest| \- \-
|
||||
patloop1 |chiptest| \- \-
|
||||
patnloop1 |chiptest| \- \-
|
||||
patwait1 |chiptest| \- \-
|
||||
patwaittime1 |chiptest| \- \-
|
||||
patloop2 |chiptest| \- \-
|
||||
patnloop2 |chiptest| \- \-
|
||||
patwait2 |chiptest| \- \-
|
||||
patwaittime2 |chiptest| \- \-
|
||||
dut_clk |chiptest| \- \-
|
||||
===================== ===================================== ================== =========
|
||||
@@ -1,178 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# sls_detector_tools documentation build configuration file, created by
|
||||
# sphinx-quickstart on Wed Nov 1 10:17:29 2017.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = ['sphinx.ext.autodoc',
|
||||
'sphinx.ext.doctest',
|
||||
'sphinx.ext.coverage',
|
||||
'sphinx.ext.mathjax',
|
||||
'sphinx.ext.viewcode',
|
||||
'sphinx.ext.napoleon',
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.autosummary']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = 'sls_detector'
|
||||
copyright = '2019, Sls Detector Group'
|
||||
author = 'Erik Frojdh'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '4.0.1'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '4.0.1'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This patterns also effect to html_static_path and html_extra_path
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = "sphinx_rtd_theme"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
#
|
||||
# This is required for the alabaster theme
|
||||
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
|
||||
html_sidebars = {
|
||||
'**': [
|
||||
'about.html',
|
||||
'navigation.html',
|
||||
'relations.html', # needs 'show_related': True theme option to display
|
||||
'searchbox.html',
|
||||
'donate.html',
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
# -- Options for HTMLHelp output ------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'sls_detector_doc'
|
||||
napoleon_use_ivar = True
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'sls_detector.tex', 'sls_detector Documentation',
|
||||
'Erik Frojdh', 'manual'),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'sls_detector_tools', 'sls_detector_tools Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'py_sls', 'py_sls Documentation',
|
||||
author, 'py_sls', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
C++ API
|
||||
=====================================================
|
||||
|
||||
|
||||
.. py:currentmodule:: _slsdet
|
||||
|
||||
.. autoclass:: DetectorApi
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
Error handling
|
||||
=========================
|
||||
|
||||
|
||||
Check input in Python
|
||||
----------------------
|
||||
|
||||
As far as possible we try to check the input on the Python side
|
||||
before calling the slsDeteectorsSoftware. Errors should not pass
|
||||
silently but raise an exception
|
||||
|
||||
::
|
||||
|
||||
#Trimbit range for Eiger is 0-63
|
||||
detector.trimbits = 98
|
||||
(...)
|
||||
ValueError: Trimbit setting 98 is outside of range:0-63
|
||||
|
||||
Errors in slsDetectorsSoftware
|
||||
-------------------------------
|
||||
|
||||
The slsDetectorsSoftware uses a mask to record errors from the different
|
||||
detectors. If an error is found we raise a RuntimeError at the end of the
|
||||
call using the error message from slsDetectorsSoftware
|
||||
|
||||
.. todo ::
|
||||
|
||||
Implement this for all functions
|
||||
|
||||
::
|
||||
|
||||
detector.settings = 'bananas'
|
||||
(...)
|
||||
RuntimeError: Detector 0:
|
||||
Could not set settings.
|
||||
Detector 1:
|
||||
Could not set settings.
|
||||
Detector 2:
|
||||
Could not set settings.
|
||||
|
||||
|
||||
Using decorators
|
||||
-------------------
|
||||
|
||||
Using decorators we can reset the error mask before the command and then
|
||||
check it after the command
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
#add decorator to check the error mask
|
||||
@error_handling
|
||||
def some_function():
|
||||
a = 1+1
|
||||
return a
|
||||
|
||||
Communication with the detector is usually the biggest overhead so
|
||||
this does not impact performance.
|
||||
|
||||
::
|
||||
|
||||
%timeit d.exposure_time
|
||||
>> 1.52 ms ± 5.42 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
|
||||
|
||||
%timeit d.decorated_exposure_time
|
||||
>> 1.53 ms ± 3.18 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
|
||||
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
Getting started
|
||||
================
|
||||
|
||||
|
||||
------------------------
|
||||
Setting up the detector
|
||||
------------------------
|
||||
|
||||
All configuration of the detector can either be done from the Python
|
||||
API (including loading config file) or externally. The detector setup is
|
||||
discovered from the shared memory when launching a new script. Because the
|
||||
detector usually should remain online longer than a specific script it is
|
||||
recommended to run the receivers seperate.
|
||||
|
||||
---------------------------------
|
||||
Setting and getting attributes
|
||||
---------------------------------
|
||||
|
||||
Most of the detector and software setting are implemented as attributes
|
||||
in the Detector class. When something is assigned it is also set
|
||||
in the detector and when the attribute is called using dot notation it
|
||||
it looked up from the detector.
|
||||
|
||||
::
|
||||
|
||||
#Currently Eiger and Jungfrau but Detector should work for all
|
||||
from sls_detector import Eiger()
|
||||
d = Eiger()
|
||||
|
||||
d.file_write = True
|
||||
d.vthreshold = 1500
|
||||
|
||||
d.frame_index
|
||||
>> 12
|
||||
|
||||
d.file_name
|
||||
>> 'run'
|
||||
|
||||
---------------------------------
|
||||
Working with DACs
|
||||
---------------------------------
|
||||
|
||||
The following examples assumes an Eiger500k detector. But the same syntax
|
||||
works for other detector sizes and models.
|
||||
|
||||
::
|
||||
|
||||
d.dacs
|
||||
>>
|
||||
========== DACS =========
|
||||
vsvp : 0, 0
|
||||
vtr : 4000, 4000
|
||||
vrf : 2000, 2300
|
||||
vrs : 1400, 1400
|
||||
vsvn : 4000, 4000
|
||||
vtgstv : 2556, 2556
|
||||
vcmp_ll : 1500, 1500
|
||||
vcmp_lr : 1500, 1500
|
||||
vcall : 3500, 3600
|
||||
vcmp_rl : 1500, 1500
|
||||
rxb_rb : 1100, 1100
|
||||
rxb_lb : 1100, 1100
|
||||
vcmp_rr : 1500, 1500
|
||||
vcp : 1500, 1500
|
||||
vcn : 2000, 2000
|
||||
vis : 1550, 1550
|
||||
iodelay : 660, 660
|
||||
|
||||
#Read dac values to a variable
|
||||
vrf = d.dacs.vrf[:]
|
||||
|
||||
#Set a dac in a module
|
||||
d.dacs.vrf[0] = 1500
|
||||
d.dacs.vrf[0]
|
||||
>> 1500
|
||||
|
||||
#Set vrf to the same value in all moduels
|
||||
d.dacs.vrf = 1500
|
||||
|
||||
#Set a dac using an iterable
|
||||
d.dacs.vrf = [1500, 1600]
|
||||
d.dacs.vrf
|
||||
>> vrf : 1500, 1600
|
||||
|
||||
#Set dacs iterating on index and values
|
||||
d.dacs.vrf[0,1] = 1300,1400
|
||||
|
||||
|
||||
---------------------------------
|
||||
Operating multiple detectors
|
||||
---------------------------------
|
||||
|
||||
Operating multiple detectors is supported by assigning an id when creating the object. If no id is
|
||||
set it defaults to 0.
|
||||
|
||||
::
|
||||
|
||||
d0 = Eiger() #id is now 0
|
||||
d1 = Jungfrau(1)
|
||||
|
||||
#Or explicitly
|
||||
d1 = Jungfrau(id = 0)
|
||||
|
||||
The detectors now operate independently of each other but can be synchronized using a hardware trigger.
|
||||
|
||||
::
|
||||
|
||||
from sls_detector import Eiger
|
||||
|
||||
d0 = Eiger(0)
|
||||
d1 = Eiger(1)
|
||||
|
||||
d0.load_config('/some/path/T45.config')
|
||||
d1.load_config('/some/path/T62.config')
|
||||
|
||||
d0.n_frames = 1
|
||||
d0.exposure_time = 1
|
||||
d0.timing_mode = 'trigger'
|
||||
|
||||
d1.n_frames = 5
|
||||
d1.exposure_time = 0.2
|
||||
d1.timing_mode = 'trigger'
|
||||
@@ -1,30 +0,0 @@
|
||||
sls_detector - Python interface for the slsDetectorsPackage
|
||||
==============================================================
|
||||
|
||||
sls_detector provide Python bindings to the slsDetectorsPackage using mainly the
|
||||
DetectorImpl API. This module contains two parts, a compiled C module to
|
||||
expose the API and a Python class to offer a more Pythonic interface.
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
:caption: Contents:
|
||||
|
||||
installation
|
||||
getting_started
|
||||
code_quality
|
||||
command_line
|
||||
examples
|
||||
error-handling
|
||||
|
||||
sls_detector
|
||||
cpp_api
|
||||
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
@@ -1,90 +0,0 @@
|
||||
Installation
|
||||
=========================
|
||||
|
||||
The easiest way to install the Python API and the slsDetectorPackage is using conda. But other
|
||||
methods are also available.
|
||||
|
||||
---------------------
|
||||
Install using conda
|
||||
---------------------
|
||||
If you don't have it installed get the latest version of `Miniconda`_
|
||||
|
||||
.. _Miniconda: https://conda.io/miniconda.html
|
||||
|
||||
::
|
||||
|
||||
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
|
||||
sh Miniconda3-latest-Linux-x86_64.sh
|
||||
|
||||
|
||||
Install sls_detector and sls_detector_lib using:
|
||||
|
||||
::
|
||||
|
||||
#Add conda channels
|
||||
conda config --add channels conda-forge
|
||||
conda config --add channels slsdetectorgroup
|
||||
|
||||
#Install latest version
|
||||
conda install sls_detector
|
||||
|
||||
#Install specific version
|
||||
conda install sls_detector=3.0.1
|
||||
|
||||
------------------------------
|
||||
Local build using conda-build
|
||||
------------------------------
|
||||
|
||||
Needs the `sls_detector_lib`_ installed in order to automatically find headers
|
||||
and shared libraries. Make sure that the branch of sls_detector matches the lib
|
||||
version installed.
|
||||
|
||||
.. _sls_detector_lib: https://github.com/slsdetectorgroup/sls_detector_lib
|
||||
|
||||
::
|
||||
|
||||
#Clone source code
|
||||
git clone https://github.com/slsdetectorgroup/sls_detector.git
|
||||
|
||||
#Checkout the branch needed
|
||||
git checkout 3.0.1
|
||||
|
||||
#Build and install the local version
|
||||
conda-build sls_detector
|
||||
conda install --use-local sls_detector
|
||||
|
||||
|
||||
-----------------------
|
||||
Developer build
|
||||
-----------------------
|
||||
|
||||
IF you if you are developing and are making constant changes to the code it's a bit cumbersome
|
||||
to build with conda and install. Then an easier way is to build the C/C++ parts in the package
|
||||
directory and temporary add this to the path
|
||||
|
||||
::
|
||||
|
||||
#in path/to/sls_detector
|
||||
python setup.py build_ext --inplace
|
||||
|
||||
Then in your Python script
|
||||
|
||||
::
|
||||
|
||||
import sys
|
||||
sys.path.append('/path/to/sls_detector')
|
||||
from sls_detector import Detector
|
||||
|
||||
|
||||
|
||||
--------------
|
||||
Prerequisites
|
||||
--------------
|
||||
|
||||
All dependencies are manged trough conda but for a stand alone build you would need
|
||||
|
||||
* gcc 4.8+
|
||||
* Qwt 6
|
||||
* Qt 4.8
|
||||
* numpy
|
||||
* slsDetectorPackage
|
||||
@@ -1,6 +0,0 @@
|
||||
make clean
|
||||
make html
|
||||
rm -rf ../docs/
|
||||
mv _build/html/ ../docs/
|
||||
touch ../docs/.nojekyll
|
||||
rm -rf _build
|
||||
@@ -1,8 +0,0 @@
|
||||
sls_detector
|
||||
==================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
sls_detector
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
Python classes
|
||||
=====================================================
|
||||
|
||||
|
||||
.. py:currentmodule:: sls_detector
|
||||
|
||||
Detector
|
||||
----------
|
||||
|
||||
.. autoclass:: Detector
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
|
||||
Eiger
|
||||
-------
|
||||
|
||||
.. autoclass:: Eiger
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
|
||||
Jungfrau
|
||||
----------
|
||||
|
||||
.. autoclass:: Jungfrau
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
@@ -86,6 +86,9 @@ void init_det(py::module &m) {
|
||||
.def("setDetectorSize",
|
||||
(void (Detector::*)(const defs::xy)) & Detector::setDetectorSize,
|
||||
py::arg())
|
||||
.def("getSettingsList",
|
||||
(std::vector<defs::detectorSettings>(Detector::*)() const) &
|
||||
Detector::getSettingsList)
|
||||
.def("getSettings",
|
||||
(Result<defs::detectorSettings>(Detector::*)(sls::Positions)
|
||||
const) &
|
||||
@@ -107,6 +110,12 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)(int, sls::Positions)) &
|
||||
Detector::setAllTrimbits,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getGapPixelsinCallback",
|
||||
(bool (Detector::*)() const) & Detector::getGapPixelsinCallback)
|
||||
.def("setGapPixelsinCallback",
|
||||
(void (Detector::*)(const bool)) &
|
||||
Detector::setGapPixelsinCallback,
|
||||
py::arg())
|
||||
.def("registerAcquisitionFinishedCallback",
|
||||
(void (Detector::*)(void (*)(double, int, void *), void *)) &
|
||||
Detector::registerAcquisitionFinishedCallback,
|
||||
@@ -117,12 +126,6 @@ void init_det(py::module &m) {
|
||||
void (*)(detectorData *, uint64_t, uint32_t, void *), void *)) &
|
||||
Detector::registerDataCallback,
|
||||
py::arg(), py::arg())
|
||||
.def("getGapPixelsinCallback",
|
||||
(bool (Detector::*)() const) & Detector::getGapPixelsinCallback)
|
||||
.def("setGapPixelsinCallback",
|
||||
(void (Detector::*)(const bool)) &
|
||||
Detector::setGapPixelsinCallback,
|
||||
py::arg())
|
||||
.def("getNumberOfFrames",
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNumberOfFrames,
|
||||
@@ -295,6 +298,8 @@ void init_det(py::module &m) {
|
||||
(Result<int>(Detector::*)(defs::dacIndex, sls::Positions) const) &
|
||||
Detector::getTemperature,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getDacList", (std::vector<defs::dacIndex>(Detector::*)() const) &
|
||||
Detector::getDacList)
|
||||
.def("getDAC",
|
||||
(Result<int>(Detector::*)(defs::dacIndex, bool, sls::Positions)
|
||||
const) &
|
||||
@@ -313,6 +318,16 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)(defs::dacIndex, int, int, sls::Positions)) &
|
||||
Detector::setOnChipDAC,
|
||||
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("getExternalSignalFlags",
|
||||
(Result<defs::externalSignalFlag>(Detector::*)(int, sls::Positions)
|
||||
const) &
|
||||
Detector::getExternalSignalFlags,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("setExternalSignalFlags",
|
||||
(void (Detector::*)(int, defs::externalSignalFlag,
|
||||
sls::Positions)) &
|
||||
Detector::setExternalSignalFlags,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("acquire", (void (Detector::*)()) & Detector::acquire)
|
||||
.def("clearAcquiringFlag",
|
||||
(void (Detector::*)()) & Detector::clearAcquiringFlag)
|
||||
@@ -563,6 +578,10 @@ void init_det(py::module &m) {
|
||||
(Result<sls::IpAddr>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxLastClientIP,
|
||||
py::arg() = Positions{})
|
||||
.def("getRxThreadIds",
|
||||
(Result<std::array<pid_t, 8>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxThreadIds,
|
||||
py::arg() = Positions{})
|
||||
.def("getFileFormat",
|
||||
(Result<defs::fileFormat>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getFileFormat,
|
||||
@@ -736,14 +755,6 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
Detector::setOverFlowMode,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getStoreInRamMode",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getStoreInRamMode,
|
||||
py::arg() = Positions{})
|
||||
.def("setStoreInRamMode",
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
Detector::setStoreInRamMode,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getBottom",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getBottom,
|
||||
@@ -905,16 +916,6 @@ void init_det(py::module &m) {
|
||||
(Result<sls::ns>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getExptimeLeft,
|
||||
py::arg() = Positions{})
|
||||
.def("getExternalSignalFlags",
|
||||
(Result<defs::externalSignalFlag>(Detector::*)(int, sls::Positions)
|
||||
const) &
|
||||
Detector::getExternalSignalFlags,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("setExternalSignalFlags",
|
||||
(void (Detector::*)(int, defs::externalSignalFlag,
|
||||
sls::Positions)) &
|
||||
Detector::setExternalSignalFlags,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("getNumberOfBursts",
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNumberOfBursts,
|
||||
@@ -1136,7 +1137,7 @@ void init_det(py::module &m) {
|
||||
Detector::setExternalSamplingSource,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getExternalSampling",
|
||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getExternalSampling,
|
||||
py::arg() = Positions{})
|
||||
.def("setExternalSampling",
|
||||
@@ -1186,14 +1187,6 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)(uint64_t, sls::Positions)) &
|
||||
Detector::setPatternIOControl,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getPatternClockControl",
|
||||
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getPatternClockControl,
|
||||
py::arg() = Positions{})
|
||||
.def("setPatternClockControl",
|
||||
(void (Detector::*)(uint64_t, sls::Positions)) &
|
||||
Detector::setPatternClockControl,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getPatternWord",
|
||||
(Result<uint64_t>(Detector::*)(int, sls::Positions)) &
|
||||
Detector::getPatternWord,
|
||||
@@ -1387,7 +1380,8 @@ void init_det(py::module &m) {
|
||||
Detector::getLastClientIP,
|
||||
py::arg() = Positions{})
|
||||
.def("executeCommand",
|
||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||
(Result<std::string>(Detector::*)(const std::string &,
|
||||
sls::Positions)) &
|
||||
Detector::executeCommand,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getNumberOfFramesFromStart",
|
||||
|
||||
@@ -17,8 +17,6 @@ void init_enums(py::module &m) {
|
||||
xy.def_readwrite("y", &slsDetectorDefs::xy::y);
|
||||
|
||||
py::enum_<slsDetectorDefs::detectorType>(Defs, "detectorType")
|
||||
.value("GET_DETECTOR_TYPE",
|
||||
slsDetectorDefs::detectorType::GET_DETECTOR_TYPE)
|
||||
.value("GENERIC", slsDetectorDefs::detectorType::GENERIC)
|
||||
.value("EIGER", slsDetectorDefs::detectorType::EIGER)
|
||||
.value("GOTTHARD", slsDetectorDefs::detectorType::GOTTHARD)
|
||||
@@ -40,8 +38,6 @@ void init_enums(py::module &m) {
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::frameDiscardPolicy>(Defs, "frameDiscardPolicy")
|
||||
.value("GET_FRAME_DISCARD_POLICY",
|
||||
slsDetectorDefs::frameDiscardPolicy::GET_FRAME_DISCARD_POLICY)
|
||||
.value("NO_DISCARD", slsDetectorDefs::frameDiscardPolicy::NO_DISCARD)
|
||||
.value("DISCARD_EMPTY_FRAMES",
|
||||
slsDetectorDefs::frameDiscardPolicy::DISCARD_EMPTY_FRAMES)
|
||||
@@ -52,16 +48,15 @@ void init_enums(py::module &m) {
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::fileFormat>(Defs, "fileFormat")
|
||||
.value("GET_FILE_FORMAT", slsDetectorDefs::fileFormat::GET_FILE_FORMAT)
|
||||
.value("BINARY", slsDetectorDefs::fileFormat::BINARY)
|
||||
.value("HDF5", slsDetectorDefs::fileFormat::HDF5)
|
||||
.value("NUM_FILE_FORMATS",
|
||||
.value(" HDF5", slsDetectorDefs::fileFormat::HDF5)
|
||||
.value(" NUM_FILE_FORMATS",
|
||||
slsDetectorDefs::fileFormat::NUM_FILE_FORMATS)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::dimension>(Defs, "dimension")
|
||||
.value("X", slsDetectorDefs::dimension::X)
|
||||
.value("Y", slsDetectorDefs::dimension::Y)
|
||||
.value(" Y", slsDetectorDefs::dimension::Y)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::externalSignalFlag>(Defs, "externalSignalFlag")
|
||||
@@ -76,7 +71,6 @@ void init_enums(py::module &m) {
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::timingMode>(Defs, "timingMode")
|
||||
.value("GET_TIMING_MODE", slsDetectorDefs::timingMode::GET_TIMING_MODE)
|
||||
.value("AUTO_TIMING", slsDetectorDefs::timingMode::AUTO_TIMING)
|
||||
.value("TRIGGER_EXPOSURE",
|
||||
slsDetectorDefs::timingMode::TRIGGER_EXPOSURE)
|
||||
@@ -88,15 +82,42 @@ void init_enums(py::module &m) {
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::dacIndex>(Defs, "dacIndex")
|
||||
.value("THRESHOLD", slsDetectorDefs::dacIndex::THRESHOLD)
|
||||
.value("CALIBRATION_PULSE",
|
||||
slsDetectorDefs::dacIndex::CALIBRATION_PULSE)
|
||||
.value("TRIMBIT_SIZE", slsDetectorDefs::dacIndex::TRIMBIT_SIZE)
|
||||
.value("PREAMP", slsDetectorDefs::dacIndex::PREAMP)
|
||||
.value("SHAPER1", slsDetectorDefs::dacIndex::SHAPER1)
|
||||
.value("SHAPER2", slsDetectorDefs::dacIndex::SHAPER2)
|
||||
.value("TEMPERATURE_ADC", slsDetectorDefs::dacIndex::TEMPERATURE_ADC)
|
||||
.value("TEMPERATURE_FPGA", slsDetectorDefs::dacIndex::TEMPERATURE_FPGA)
|
||||
.value("DAC_0", slsDetectorDefs::dacIndex::DAC_0)
|
||||
.value("DAC_1", slsDetectorDefs::dacIndex::DAC_1)
|
||||
.value("DAC_2", slsDetectorDefs::dacIndex::DAC_2)
|
||||
.value("DAC_3", slsDetectorDefs::dacIndex::DAC_3)
|
||||
.value("DAC_4", slsDetectorDefs::dacIndex::DAC_4)
|
||||
.value("DAC_5", slsDetectorDefs::dacIndex::DAC_5)
|
||||
.value("DAC_6", slsDetectorDefs::dacIndex::DAC_6)
|
||||
.value("DAC_7", slsDetectorDefs::dacIndex::DAC_7)
|
||||
.value("DAC_8", slsDetectorDefs::dacIndex::DAC_8)
|
||||
.value("DAC_9", slsDetectorDefs::dacIndex::DAC_9)
|
||||
.value("DAC_10", slsDetectorDefs::dacIndex::DAC_10)
|
||||
.value("DAC_11", slsDetectorDefs::dacIndex::DAC_11)
|
||||
.value("DAC_12", slsDetectorDefs::dacIndex::DAC_12)
|
||||
.value("DAC_13", slsDetectorDefs::dacIndex::DAC_13)
|
||||
.value("DAC_14", slsDetectorDefs::dacIndex::DAC_14)
|
||||
.value("DAC_15", slsDetectorDefs::dacIndex::DAC_15)
|
||||
.value("DAC_16", slsDetectorDefs::dacIndex::DAC_16)
|
||||
.value("DAC_17", slsDetectorDefs::dacIndex::DAC_17)
|
||||
.value("VSVP", slsDetectorDefs::dacIndex::VSVP)
|
||||
.value("VTRIM", slsDetectorDefs::dacIndex::VTRIM)
|
||||
.value("VRPREAMP", slsDetectorDefs::dacIndex::VRPREAMP)
|
||||
.value("VRSHAPER", slsDetectorDefs::dacIndex::VRSHAPER)
|
||||
.value("VSVN", slsDetectorDefs::dacIndex::VSVN)
|
||||
.value("VTGSTV", slsDetectorDefs::dacIndex::VTGSTV)
|
||||
.value("VCMP_LL", slsDetectorDefs::dacIndex::VCMP_LL)
|
||||
.value("VCMP_LR", slsDetectorDefs::dacIndex::VCMP_LR)
|
||||
.value("VCAL", slsDetectorDefs::dacIndex::VCAL)
|
||||
.value("VCMP_RL", slsDetectorDefs::dacIndex::VCMP_RL)
|
||||
.value("RXB_RB", slsDetectorDefs::dacIndex::RXB_RB)
|
||||
.value("RXB_LB", slsDetectorDefs::dacIndex::RXB_LB)
|
||||
.value("VCMP_RR", slsDetectorDefs::dacIndex::VCMP_RR)
|
||||
.value("VCP", slsDetectorDefs::dacIndex::VCP)
|
||||
.value("VCN", slsDetectorDefs::dacIndex::VCN)
|
||||
.value("VISHAPER", slsDetectorDefs::dacIndex::VISHAPER)
|
||||
.value("VTHRESHOLD", slsDetectorDefs::dacIndex::VTHRESHOLD)
|
||||
.value("IO_DELAY", slsDetectorDefs::dacIndex::IO_DELAY)
|
||||
.value("VREF_DS", slsDetectorDefs::dacIndex::VREF_DS)
|
||||
.value("VCASCN_PB", slsDetectorDefs::dacIndex::VCASCN_PB)
|
||||
.value("VCASCP_PB", slsDetectorDefs::dacIndex::VCASCP_PB)
|
||||
@@ -105,25 +126,46 @@ void init_enums(py::module &m) {
|
||||
.value("VIN_CM", slsDetectorDefs::dacIndex::VIN_CM)
|
||||
.value("VREF_COMP", slsDetectorDefs::dacIndex::VREF_COMP)
|
||||
.value("IB_TESTC", slsDetectorDefs::dacIndex::IB_TESTC)
|
||||
.value("SVP", slsDetectorDefs::dacIndex::SVP)
|
||||
.value("SVN", slsDetectorDefs::dacIndex::SVN)
|
||||
.value("VTR", slsDetectorDefs::dacIndex::VTR)
|
||||
.value("VRF", slsDetectorDefs::dacIndex::VRF)
|
||||
.value("VRS", slsDetectorDefs::dacIndex::VRS)
|
||||
.value("VTGSTV", slsDetectorDefs::dacIndex::VTGSTV)
|
||||
.value("VCMP_LL", slsDetectorDefs::dacIndex::VCMP_LL)
|
||||
.value("VCMP_LR", slsDetectorDefs::dacIndex::VCMP_LR)
|
||||
.value("CAL", slsDetectorDefs::dacIndex::CAL)
|
||||
.value("VCMP_RL", slsDetectorDefs::dacIndex::VCMP_RL)
|
||||
.value("VCMP_RR", slsDetectorDefs::dacIndex::VCMP_RR)
|
||||
.value("RXB_RB", slsDetectorDefs::dacIndex::RXB_RB)
|
||||
.value("RXB_LB", slsDetectorDefs::dacIndex::RXB_LB)
|
||||
.value("VCP", slsDetectorDefs::dacIndex::VCP)
|
||||
.value("VCN", slsDetectorDefs::dacIndex::VCN)
|
||||
.value("VIS", slsDetectorDefs::dacIndex::VIS)
|
||||
.value("IO_DELAY", slsDetectorDefs::dacIndex::IO_DELAY)
|
||||
.value("VB_COMP", slsDetectorDefs::dacIndex::VB_COMP)
|
||||
.value("VDD_PROT", slsDetectorDefs::dacIndex::VDD_PROT)
|
||||
.value("VIN_COM", slsDetectorDefs::dacIndex::VIN_COM)
|
||||
.value("VREF_PRECH", slsDetectorDefs::dacIndex::VREF_PRECH)
|
||||
.value("VB_PIXBUF", slsDetectorDefs::dacIndex::VB_PIXBUF)
|
||||
.value("VB_DS", slsDetectorDefs::dacIndex::VB_DS)
|
||||
.value("VREF_H_ADC", slsDetectorDefs::dacIndex::VREF_H_ADC)
|
||||
.value("VB_COMP_FE", slsDetectorDefs::dacIndex::VB_COMP_FE)
|
||||
.value("VB_COMP_ADC", slsDetectorDefs::dacIndex::VB_COMP_ADC)
|
||||
.value("VCOM_CDS", slsDetectorDefs::dacIndex::VCOM_CDS)
|
||||
.value("VREF_RSTORE", slsDetectorDefs::dacIndex::VREF_RSTORE)
|
||||
.value("VB_OPA_1ST", slsDetectorDefs::dacIndex::VB_OPA_1ST)
|
||||
.value("VREF_COMP_FE", slsDetectorDefs::dacIndex::VREF_COMP_FE)
|
||||
.value("VCOM_ADC1", slsDetectorDefs::dacIndex::VCOM_ADC1)
|
||||
.value("VREF_L_ADC", slsDetectorDefs::dacIndex::VREF_L_ADC)
|
||||
.value("VREF_CDS", slsDetectorDefs::dacIndex::VREF_CDS)
|
||||
.value("VB_CS", slsDetectorDefs::dacIndex::VB_CS)
|
||||
.value("VB_OPA_FD", slsDetectorDefs::dacIndex::VB_OPA_FD)
|
||||
.value("VCOM_ADC2", slsDetectorDefs::dacIndex::VCOM_ADC2)
|
||||
.value("VCASSH", slsDetectorDefs::dacIndex::VCASSH)
|
||||
.value("VTH2", slsDetectorDefs::dacIndex::VTH2)
|
||||
.value("VRSHAPER_N", slsDetectorDefs::dacIndex::VRSHAPER_N)
|
||||
.value("VIPRE_OUT", slsDetectorDefs::dacIndex::VIPRE_OUT)
|
||||
.value("VTH3", slsDetectorDefs::dacIndex::VTH3)
|
||||
.value("VTH1", slsDetectorDefs::dacIndex::VTH1)
|
||||
.value("VICIN", slsDetectorDefs::dacIndex::VICIN)
|
||||
.value("VCAS", slsDetectorDefs::dacIndex::VCAS)
|
||||
.value("VCAL_N", slsDetectorDefs::dacIndex::VCAL_N)
|
||||
.value("VIPRE", slsDetectorDefs::dacIndex::VIPRE)
|
||||
.value("VCAL_P", slsDetectorDefs::dacIndex::VCAL_P)
|
||||
.value("VDCSH", slsDetectorDefs::dacIndex::VDCSH)
|
||||
.value("VBP_COLBUF", slsDetectorDefs::dacIndex::VBP_COLBUF)
|
||||
.value("VB_SDA", slsDetectorDefs::dacIndex::VB_SDA)
|
||||
.value("VCASC_SFP", slsDetectorDefs::dacIndex::VCASC_SFP)
|
||||
.value("VIPRE_CDS", slsDetectorDefs::dacIndex::VIPRE_CDS)
|
||||
.value("IBIAS_SFP", slsDetectorDefs::dacIndex::IBIAS_SFP)
|
||||
.value("ADC_VPP", slsDetectorDefs::dacIndex::ADC_VPP)
|
||||
.value("HIGH_VOLTAGE", slsDetectorDefs::dacIndex::HIGH_VOLTAGE)
|
||||
.value("TEMPERATURE_ADC", slsDetectorDefs::dacIndex::TEMPERATURE_ADC)
|
||||
.value("TEMPERATURE_FPGA", slsDetectorDefs::dacIndex::TEMPERATURE_FPGA)
|
||||
.value("TEMPERATURE_FPGAEXT",
|
||||
slsDetectorDefs::dacIndex::TEMPERATURE_FPGAEXT)
|
||||
.value("TEMPERATURE_10GE", slsDetectorDefs::dacIndex::TEMPERATURE_10GE)
|
||||
@@ -134,40 +176,6 @@ void init_enums(py::module &m) {
|
||||
slsDetectorDefs::dacIndex::TEMPERATURE_FPGA2)
|
||||
.value("TEMPERATURE_FPGA3",
|
||||
slsDetectorDefs::dacIndex::TEMPERATURE_FPGA3)
|
||||
.value("VIPRE", slsDetectorDefs::dacIndex::VIPRE)
|
||||
.value("VIINSH", slsDetectorDefs::dacIndex::VIINSH)
|
||||
.value("VDCSH", slsDetectorDefs::dacIndex::VDCSH)
|
||||
.value("VTH2", slsDetectorDefs::dacIndex::VTH2)
|
||||
.value("VPL", slsDetectorDefs::dacIndex::VPL)
|
||||
.value("VTH3", slsDetectorDefs::dacIndex::VTH3)
|
||||
.value("CASSH", slsDetectorDefs::dacIndex::CASSH)
|
||||
.value("CAS", slsDetectorDefs::dacIndex::CAS)
|
||||
.value("VICIN", slsDetectorDefs::dacIndex::VICIN)
|
||||
.value("VIPRE_OUT", slsDetectorDefs::dacIndex::VIPRE_OUT)
|
||||
.value("VREF_H_ADC", slsDetectorDefs::dacIndex::VREF_H_ADC)
|
||||
.value("VB_COMP_FE", slsDetectorDefs::dacIndex::VB_COMP_FE)
|
||||
.value("VB_COMP_ADC", slsDetectorDefs::dacIndex::VB_COMP_ADC)
|
||||
.value("VCOM_CDS", slsDetectorDefs::dacIndex::VCOM_CDS)
|
||||
.value("VREF_RSTORE", slsDetectorDefs::dacIndex::VREF_RSTORE)
|
||||
.value("VB_OPA_1ST", slsDetectorDefs::dacIndex::VB_OPA_1ST)
|
||||
.value("VREF_COMP_FE", slsDetectorDefs::dacIndex::VREF_COMP_FE)
|
||||
.value("VCOM_ADC1", slsDetectorDefs::dacIndex::VCOM_ADC1)
|
||||
.value("VREF_PRECH", slsDetectorDefs::dacIndex::VREF_PRECH)
|
||||
.value("VREF_L_ADC", slsDetectorDefs::dacIndex::VREF_L_ADC)
|
||||
.value("VREF_CDS", slsDetectorDefs::dacIndex::VREF_CDS)
|
||||
.value("VB_CS", slsDetectorDefs::dacIndex::VB_CS)
|
||||
.value("VB_OPA_FD", slsDetectorDefs::dacIndex::VB_OPA_FD)
|
||||
.value("VCOM_ADC2", slsDetectorDefs::dacIndex::VCOM_ADC2)
|
||||
.value("VB_DS", slsDetectorDefs::dacIndex::VB_DS)
|
||||
.value("VB_COMP", slsDetectorDefs::dacIndex::VB_COMP)
|
||||
.value("VB_PIXBUF", slsDetectorDefs::dacIndex::VB_PIXBUF)
|
||||
.value("VIN_COM", slsDetectorDefs::dacIndex::VIN_COM)
|
||||
.value("VDD_PROT", slsDetectorDefs::dacIndex::VDD_PROT)
|
||||
.value("VBP_COLBUF", slsDetectorDefs::dacIndex::VBP_COLBUF)
|
||||
.value("VB_SDA", slsDetectorDefs::dacIndex::VB_SDA)
|
||||
.value("VCASC_SFP", slsDetectorDefs::dacIndex::VCASC_SFP)
|
||||
.value("VIPRE_CDS", slsDetectorDefs::dacIndex::VIPRE_CDS)
|
||||
.value("IBIAS_SFP", slsDetectorDefs::dacIndex::IBIAS_SFP)
|
||||
.value("V_POWER_A", slsDetectorDefs::dacIndex::V_POWER_A)
|
||||
.value("V_POWER_B", slsDetectorDefs::dacIndex::V_POWER_B)
|
||||
.value("V_POWER_C", slsDetectorDefs::dacIndex::V_POWER_C)
|
||||
@@ -192,7 +200,6 @@ void init_enums(py::module &m) {
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::detectorSettings>(Defs, "detectorSettings")
|
||||
.value("GET_SETTINGS", slsDetectorDefs::detectorSettings::GET_SETTINGS)
|
||||
.value("STANDARD", slsDetectorDefs::detectorSettings::STANDARD)
|
||||
.value("FAST", slsDetectorDefs::detectorSettings::FAST)
|
||||
.value("HIGHGAIN", slsDetectorDefs::detectorSettings::HIGHGAIN)
|
||||
@@ -245,34 +252,24 @@ void init_enums(py::module &m) {
|
||||
.value(" QUARTER_SPEED", slsDetectorDefs::speedLevel::QUARTER_SPEED)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::portType>(Defs, "portType")
|
||||
.value("CONTROL_PORT", slsDetectorDefs::portType::CONTROL_PORT)
|
||||
.value("STOP_PORT", slsDetectorDefs::portType::STOP_PORT)
|
||||
.value("DATA_PORT", slsDetectorDefs::portType::DATA_PORT)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::masterFlags>(Defs, "masterFlags")
|
||||
.value("GET_MASTER", slsDetectorDefs::masterFlags::GET_MASTER)
|
||||
.value("NO_MASTER", slsDetectorDefs::masterFlags::NO_MASTER)
|
||||
.value("IS_MASTER", slsDetectorDefs::masterFlags::IS_MASTER)
|
||||
.value("IS_SLAVE", slsDetectorDefs::masterFlags::IS_SLAVE)
|
||||
.value(" IS_MASTER", slsDetectorDefs::masterFlags::IS_MASTER)
|
||||
.value(" IS_SLAVE", slsDetectorDefs::masterFlags::IS_SLAVE)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::frameModeType>(Defs, "frameModeType")
|
||||
.value("GET_FRAME_MODE", slsDetectorDefs::frameModeType::GET_FRAME_MODE)
|
||||
.value("PEDESTAL", slsDetectorDefs::frameModeType::PEDESTAL)
|
||||
.value("NEW_PEDESTAL", slsDetectorDefs::frameModeType::NEW_PEDESTAL)
|
||||
.value("FLATFIELD", slsDetectorDefs::frameModeType::FLATFIELD)
|
||||
.value("NEW_FLATFIELD", slsDetectorDefs::frameModeType::NEW_FLATFIELD)
|
||||
.value(" NEW_PEDESTAL", slsDetectorDefs::frameModeType::NEW_PEDESTAL)
|
||||
.value(" FLATFIELD", slsDetectorDefs::frameModeType::FLATFIELD)
|
||||
.value(" NEW_FLATFIELD", slsDetectorDefs::frameModeType::NEW_FLATFIELD)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::detectorModeType>(Defs, "detectorModeType")
|
||||
.value("GET_DETECTOR_MODE",
|
||||
slsDetectorDefs::detectorModeType::GET_DETECTOR_MODE)
|
||||
.value("COUNTING", slsDetectorDefs::detectorModeType::COUNTING)
|
||||
.value("INTERPOLATING",
|
||||
.value(" INTERPOLATING",
|
||||
slsDetectorDefs::detectorModeType::INTERPOLATING)
|
||||
.value("ANALOG", slsDetectorDefs::detectorModeType::ANALOG)
|
||||
.value(" ANALOG", slsDetectorDefs::detectorModeType::ANALOG)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::burstMode>(Defs, "burstMode")
|
||||
|
||||
39
slsDetectorCalibration/moenchExecutables/CMakeLists.txt
Normal file
39
slsDetectorCalibration/moenchExecutables/CMakeLists.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
|
||||
#Moench ZMQ
|
||||
add_executable(moenchZmqProcess moenchZmqProcess.cpp ../tiffIO.cpp)
|
||||
add_compile_definitions(moenchZmqProcess NEWZMQ INTERP)
|
||||
|
||||
#Moench04 ZMQ
|
||||
add_executable(moench04ZmqProcess moenchZmqProcess.cpp ../tiffIO.cpp)
|
||||
add_compile_definitions(moenchZmqProcess NEWZMQ INTERP MOENCH04)
|
||||
|
||||
|
||||
#Both executables should have the same includes and output dirs
|
||||
set(MOENCH_EXECUTABLES "moenchZmqProcess" "moench04ZmqProcess")
|
||||
|
||||
foreach(exe ${MOENCH_EXECUTABLES})
|
||||
#TODO! At a later stage clean up include dirs and have a proper lib
|
||||
target_include_directories(${exe} PRIVATE
|
||||
../
|
||||
../dataStructures
|
||||
../interpolations
|
||||
../../slsReceiverSoftware/include/
|
||||
)
|
||||
|
||||
target_link_libraries(${exe}
|
||||
PUBLIC
|
||||
slsSupportLib
|
||||
${ZeroMQ_LIBRARIES}
|
||||
pthread
|
||||
tiff
|
||||
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
)
|
||||
|
||||
|
||||
set_target_properties(${exe} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
endforeach(exe ${MOENCH_EXECUTABLES})
|
||||
@@ -245,7 +245,7 @@ int main(int argc, char *argv[]) {
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress().c_str());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
|
||||
@@ -45,7 +45,9 @@ void qDacWidget::GetDac() {
|
||||
spinDac->setValue(retval);
|
||||
// mv
|
||||
retval = det->getDAC(index, 1, {detectorIndex}).squash(-1);
|
||||
lblDacmV->setText(QString("%1mV").arg(retval - 10));
|
||||
// -6 is the minimum amt of space it occupies, if more needed, its
|
||||
// padded with ' ', negative value for left aligned text
|
||||
lblDacmV->setText(QString("%1mV").arg(retval, -6));
|
||||
}
|
||||
CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index),
|
||||
"qDacWidget::GetDac")
|
||||
|
||||
@@ -25,44 +25,40 @@ void qTabDeveloper::SetupWidgetWindow() {
|
||||
switch (detType) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v SvP: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vsvp: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v SvN ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vsvn ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v Vrf: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vrpreamp: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v Vrs: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vrshaper: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v Vtr: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vtrim: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v Vtgstv: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vtgstv: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v cal: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vcal: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v Vcp ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vcp ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v Vcn: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vcn: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v Vis: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vishaper: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v rxb_lb: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "rxb_lb: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "v rxb_rb: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "rxb_rb: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vcmp_ll: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vcmp_lr: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vcmp_rl: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vcmp_rr: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(
|
||||
new qDacWidget(this, det, true,
|
||||
"v Vcmp_ll: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(
|
||||
new qDacWidget(this, det, true,
|
||||
"v Vcmp_lr: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(
|
||||
new qDacWidget(this, det, true,
|
||||
"v Vcmp_rl: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(
|
||||
new qDacWidget(this, det, true,
|
||||
"v Vcmp_rr: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true,
|
||||
"v threshold: ", getSLSIndex(detType, tempid++)));
|
||||
"vthreshold: ", getSLSIndex(detType, tempid++)));
|
||||
adcWidgets.push_back(new qDacWidget(
|
||||
this, det, false,
|
||||
"Temperature FPGA Ext: ", getSLSIndex(detType, tempid++)));
|
||||
@@ -183,10 +179,10 @@ void qTabDeveloper::SetupWidgetWindow() {
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vth2: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vshaper: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vrshaper: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(
|
||||
new qDacWidget(this, det, true,
|
||||
"vshaperneg: ", getSLSIndex(detType, tempid++)));
|
||||
"vrshaper_n: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(
|
||||
new qDacWidget(this, det, true,
|
||||
"vipre_out: ", getSLSIndex(detType, tempid++)));
|
||||
@@ -199,19 +195,22 @@ void qTabDeveloper::SetupWidgetWindow() {
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vcas: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vpreamp: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vrpreamp: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vph: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vcal_p: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vipre: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "viinsh: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vishaper: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vpl: ", getSLSIndex(detType, tempid++)));
|
||||
this, det, true, "vcal_n: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vtrim: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(new qDacWidget(
|
||||
this, det, true, "vdcsh: ", getSLSIndex(detType, tempid++)));
|
||||
dacWidgets.push_back(
|
||||
new qDacWidget(this, det, true,
|
||||
"vthreshold: ", getSLSIndex(detType, tempid++)));
|
||||
break;
|
||||
|
||||
case slsDetectorDefs::GOTTHARD2:
|
||||
@@ -384,25 +383,25 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
switch (index) {
|
||||
case 0:
|
||||
return slsDetectorDefs::SVP;
|
||||
return slsDetectorDefs::VSVP;
|
||||
case 1:
|
||||
return slsDetectorDefs::SVN;
|
||||
return slsDetectorDefs::VSVN;
|
||||
case 2:
|
||||
return slsDetectorDefs::VRF;
|
||||
return slsDetectorDefs::VRPREAMP;
|
||||
case 3:
|
||||
return slsDetectorDefs::VRS;
|
||||
return slsDetectorDefs::VRSHAPER;
|
||||
case 4:
|
||||
return slsDetectorDefs::VTR;
|
||||
return slsDetectorDefs::VTRIM;
|
||||
case 5:
|
||||
return slsDetectorDefs::VTGSTV;
|
||||
case 6:
|
||||
return slsDetectorDefs::CAL;
|
||||
return slsDetectorDefs::VCAL;
|
||||
case 7:
|
||||
return slsDetectorDefs::VCP;
|
||||
case 8:
|
||||
return slsDetectorDefs::VCN;
|
||||
case 9:
|
||||
return slsDetectorDefs::VIS;
|
||||
return slsDetectorDefs::VISHAPER;
|
||||
case 10:
|
||||
return slsDetectorDefs::RXB_LB;
|
||||
case 11:
|
||||
@@ -416,7 +415,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
||||
case 15:
|
||||
return slsDetectorDefs::VCMP_RR;
|
||||
case 16:
|
||||
return slsDetectorDefs::THRESHOLD;
|
||||
return slsDetectorDefs::VTHRESHOLD;
|
||||
case 17:
|
||||
return slsDetectorDefs::TEMPERATURE_FPGAEXT;
|
||||
case 18:
|
||||
@@ -515,37 +514,39 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
||||
case slsDetectorDefs::MYTHEN3:
|
||||
switch (index) {
|
||||
case 0:
|
||||
return slsDetectorDefs::CASSH;
|
||||
return slsDetectorDefs::VCASSH;
|
||||
case 1:
|
||||
return slsDetectorDefs::VTH2;
|
||||
case 2:
|
||||
return slsDetectorDefs::SHAPER1;
|
||||
return slsDetectorDefs::VRSHAPER;
|
||||
case 3:
|
||||
return slsDetectorDefs::SHAPER2;
|
||||
return slsDetectorDefs::VRSHAPER_N;
|
||||
case 4:
|
||||
return slsDetectorDefs::VIPRE_OUT;
|
||||
case 5:
|
||||
return slsDetectorDefs::VTH3;
|
||||
case 6:
|
||||
return slsDetectorDefs::THRESHOLD;
|
||||
return slsDetectorDefs::VTH1;
|
||||
case 7:
|
||||
return slsDetectorDefs::VICIN;
|
||||
case 8:
|
||||
return slsDetectorDefs::CAS;
|
||||
return slsDetectorDefs::VCAS;
|
||||
case 9:
|
||||
return slsDetectorDefs::PREAMP;
|
||||
return slsDetectorDefs::VRPREAMP;
|
||||
case 10:
|
||||
return slsDetectorDefs::CALIBRATION_PULSE;
|
||||
return slsDetectorDefs::VCAL_P;
|
||||
case 11:
|
||||
return slsDetectorDefs::VIPRE;
|
||||
case 12:
|
||||
return slsDetectorDefs::VIINSH;
|
||||
return slsDetectorDefs::VISHAPER;
|
||||
case 13:
|
||||
return slsDetectorDefs::VPL;
|
||||
return slsDetectorDefs::VCAL_N;
|
||||
case 14:
|
||||
return slsDetectorDefs::TRIMBIT_SIZE;
|
||||
return slsDetectorDefs::VTRIM;
|
||||
case 15:
|
||||
return slsDetectorDefs::VDCSH;
|
||||
case 16:
|
||||
return slsDetectorDefs::VTHRESHOLD;
|
||||
default:
|
||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
|
||||
std::to_string(index));
|
||||
|
||||
@@ -15,19 +15,31 @@ qTabSettings::~qTabSettings() {}
|
||||
void qTabSettings::SetupWidgetWindow() {
|
||||
|
||||
// enabling according to det type
|
||||
switch (det->getDetectorType().squash()) {
|
||||
case slsDetectorDefs::MYTHEN3:
|
||||
slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
|
||||
if (detType == slsDetectorDefs::MYTHEN3) {
|
||||
lblSettings->setEnabled(false);
|
||||
comboSettings->setEnabled(false);
|
||||
break;
|
||||
case slsDetectorDefs::EIGER:
|
||||
|
||||
lblDynamicRange->setEnabled(true);
|
||||
comboDynamicRange->setEnabled(true);
|
||||
// disable dr
|
||||
QStandardItemModel *model =
|
||||
qobject_cast<QStandardItemModel *>(comboDynamicRange->model());
|
||||
if (model) {
|
||||
QModelIndex index;
|
||||
QStandardItem *item;
|
||||
index =
|
||||
model->index(DYNAMICRANGE_4, comboDynamicRange->modelColumn(),
|
||||
comboDynamicRange->rootModelIndex());
|
||||
item = model->itemFromIndex(index);
|
||||
item->setEnabled(false);
|
||||
}
|
||||
|
||||
} else if (detType == slsDetectorDefs::EIGER) {
|
||||
lblDynamicRange->setEnabled(true);
|
||||
comboDynamicRange->setEnabled(true);
|
||||
lblThreshold->setEnabled(true);
|
||||
spinThreshold->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// default settings for the disabled
|
||||
|
||||
@@ -8,7 +8,6 @@ if [ $# -eq 0 ]; then
|
||||
)
|
||||
else
|
||||
declare -a det=("${1}")
|
||||
echo "got something"
|
||||
fi
|
||||
|
||||
declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK")
|
||||
|
||||
@@ -16,7 +16,7 @@ add_executable(ctbDetectorServer_virtual
|
||||
../slsDetectorServer/src/LTC2620.c
|
||||
../slsDetectorServer/src/MAX1932.c
|
||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
||||
@@ -5,14 +5,14 @@ support_lib = ../../slsSupportLib/include/
|
||||
|
||||
CROSS = bfin-uclinux-
|
||||
CC = $(CROSS)gcc
|
||||
CFLAGS += -Wall -DCHIPTESTBOARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm
|
||||
CFLAGS += -Wall -std=gnu99 -DCHIPTESTBOARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lrt -pthread
|
||||
PROGS = ctbDetectorServer
|
||||
DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD7689.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)I2C.c $(main_src)INA226.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD7689.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)I2C.c $(main_src)INA226.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)/sharedMemory.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "clogger.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
#include "AD7689.h" // slow adcs
|
||||
@@ -10,9 +11,6 @@
|
||||
#include "UDPPacketHeaderGenerator.h"
|
||||
#include "common.h"
|
||||
#include "communication_funcs_UDP.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
@@ -43,8 +41,8 @@ char initErrorMessage[MAX_STR_LENGTH];
|
||||
|
||||
#ifdef VIRTUAL
|
||||
pthread_t pthread_virtual_tid;
|
||||
int virtual_status = 0;
|
||||
int virtual_stop = 0;
|
||||
uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
|
||||
int64_t virtual_currentFrameNumber = 2;
|
||||
#endif
|
||||
|
||||
// 1g readout
|
||||
@@ -237,8 +235,7 @@ int testFpga() {
|
||||
|
||||
volatile uint32_t val = 0, readval = 0;
|
||||
int times = 1000 * 1000;
|
||||
int i = 0;
|
||||
for (i = 0; i < times; ++i) {
|
||||
for (int i = 0; i < times; ++i) {
|
||||
val = 0x5A5A5A5A - i;
|
||||
bus_w(addr, val);
|
||||
readval = bus_r(addr);
|
||||
@@ -302,9 +299,8 @@ int testBus() {
|
||||
|
||||
volatile uint32_t val = 0, readval = 0;
|
||||
int times = 1000 * 1000;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < times; ++i) {
|
||||
for (int i = 0; i < times; ++i) {
|
||||
val += 0xbbbbb;
|
||||
bus_w(addr, val);
|
||||
readval = bus_r(addr);
|
||||
@@ -436,10 +432,7 @@ void initStopServer() {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
sharedMemory_setStop(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -463,15 +456,14 @@ void setupDetector() {
|
||||
analogDataPtr = 0;
|
||||
digitalDataPtr = 0;
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < NUM_CLOCKS; ++i) {
|
||||
for (int i = 0; i < NUM_CLOCKS; ++i) {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
clkFrequency[RUN_CLK] = DEFAULT_RUN_CLK;
|
||||
clkFrequency[ADC_CLK] = DEFAULT_ADC_CLK;
|
||||
clkFrequency[SYNC_CLK] = DEFAULT_SYNC_CLK;
|
||||
clkFrequency[DBIT_CLK] = DEFAULT_DBIT_CLK;
|
||||
for (i = 0; i < NDAC; ++i)
|
||||
for (int i = 0; i < NDAC; ++i)
|
||||
dacValues[i] = -1;
|
||||
}
|
||||
vLimit = DEFAULT_VLIMIT;
|
||||
@@ -483,10 +475,8 @@ void setupDetector() {
|
||||
naSamples = 1;
|
||||
ndSamples = 1;
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
memset(virtual_pattern, 0, sizeof(virtual_pattern));
|
||||
#endif
|
||||
|
||||
ALTERA_PLL_ResetPLLAndReconfiguration();
|
||||
@@ -528,12 +518,9 @@ void setupDetector() {
|
||||
// switch off dacs (power regulators most likely only sets to minimum (if
|
||||
// power enable on))
|
||||
LOG(logINFOBLUE, ("Powering down all dacs\n"));
|
||||
{
|
||||
int idac = 0;
|
||||
for (idac = 0; idac < NDAC; ++idac) {
|
||||
setDAC(idac, LTC2620_GetPowerDownValue(),
|
||||
0); // has to be before setvchip
|
||||
}
|
||||
for (int idac = 0; idac < NDAC; ++idac) {
|
||||
setDAC(idac, LTC2620_GetPowerDownValue(),
|
||||
0); // has to be before setvchip
|
||||
}
|
||||
|
||||
// power regulators
|
||||
@@ -649,8 +636,7 @@ void updateDataBytes() {
|
||||
if (adcEnableMask_1g == BIT32_MSK)
|
||||
nachans = 32;
|
||||
else {
|
||||
int ichan = 0;
|
||||
for (ichan = 0; ichan < NCHAN_ANALOG; ++ichan) {
|
||||
for (int ichan = 0; ichan < NCHAN_ANALOG; ++ichan) {
|
||||
if (adcEnableMask_1g & (1 << ichan))
|
||||
++nachans;
|
||||
}
|
||||
@@ -735,8 +721,7 @@ void setADCEnableMask_10G(uint32_t mask) {
|
||||
uint8_t actualMask = 0;
|
||||
if (mask != 0) {
|
||||
int ival = 0;
|
||||
int ich = 0;
|
||||
for (ich = 0; ich < NCHAN_ANALOG; ich = ich + 4) {
|
||||
for (int ich = 0; ich < NCHAN_ANALOG; ich = ich + 4) {
|
||||
if ((1 << ich) & mask) {
|
||||
actualMask |= (1 << ival);
|
||||
}
|
||||
@@ -766,13 +751,11 @@ uint32_t getADCEnableMask_10G() {
|
||||
// convert 8 bit mask to 32 bit mask
|
||||
uint32_t retval = 0;
|
||||
if (adcEnableMask_10g) {
|
||||
int ival = 0;
|
||||
int iloop = 0;
|
||||
for (ival = 0; ival < 8; ++ival) {
|
||||
for (int ival = 0; ival < 8; ++ival) {
|
||||
// if bit in 8 bit mask set
|
||||
if ((1 << ival) & adcEnableMask_10g) {
|
||||
// set it for 4 bits in 32 bit mask
|
||||
for (iloop = 0; iloop < 4; ++iloop) {
|
||||
for (int iloop = 0; iloop < 4; ++iloop) {
|
||||
retval |= (1 << (ival * 4 + iloop));
|
||||
}
|
||||
}
|
||||
@@ -1196,9 +1179,8 @@ int getVChipToSet(enum DACINDEX ind, int val) {
|
||||
// get maximum value of the adc values (minimum is 0)
|
||||
int max = 0;
|
||||
|
||||
int ipwr = 0;
|
||||
// loop through the adcs
|
||||
for (ipwr = 0; ipwr < NPWR - 1; ++ipwr) {
|
||||
for (int ipwr = 0; ipwr < NPWR - 1; ++ipwr) {
|
||||
|
||||
// get the dac values for each adc
|
||||
int dacmV = getPower(getDACIndexFromADCIndex(ipwr));
|
||||
@@ -1632,7 +1614,6 @@ int enableTenGigabitEthernet(int val) {
|
||||
} else {
|
||||
bus_w(addr, bus_r(addr) & (~CONFIG_GB10_SND_UDP_MSK));
|
||||
}
|
||||
// configuremac called from client
|
||||
}
|
||||
return ((bus_r(addr) & CONFIG_GB10_SND_UDP_MSK) >>
|
||||
CONFIG_GB10_SND_UDP_OFST);
|
||||
@@ -1911,19 +1892,6 @@ uint64_t writePatternIOControl(uint64_t word) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
uint64_t writePatternClkControl(uint64_t word) {
|
||||
if ((int64_t)word != -1) {
|
||||
LOG(logINFO,
|
||||
("Setting Pattern Clock Control: 0x%llx\n", (long long int)word));
|
||||
set64BitReg(word, PATTERN_IO_CLK_CNTRL_LSB_REG,
|
||||
PATTERN_IO_CLK_CNTRL_MSB_REG);
|
||||
}
|
||||
uint64_t retval =
|
||||
get64BitReg(PATTERN_IO_CLK_CNTRL_LSB_REG, PATTERN_IO_CLK_CNTRL_MSB_REG);
|
||||
LOG(logDEBUG1, (" Clock Control retval: 0x%llx\n", (long long int)retval));
|
||||
return retval;
|
||||
}
|
||||
|
||||
uint64_t readPatternWord(int addr) {
|
||||
// error (handled in tcp)
|
||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||
@@ -1950,7 +1918,9 @@ uint64_t readPatternWord(int addr) {
|
||||
uint64_t retval = get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG);
|
||||
LOG(logDEBUG1,
|
||||
(" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int)retval));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
retval = virtual_pattern[addr];
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1967,8 +1937,8 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
||||
(long long int)word));
|
||||
LOG(logDEBUG1, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
||||
(long long int)word));
|
||||
uint32_t reg = PATTERN_CNTRL_REG;
|
||||
|
||||
// write word
|
||||
@@ -1984,6 +1954,9 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
|
||||
// unset write strobe
|
||||
bus_w(reg, bus_r(reg) & (~PATTERN_CNTRL_WR_MSK));
|
||||
#ifdef VIRTUAL
|
||||
virtual_pattern[addr] = word;
|
||||
#endif
|
||||
|
||||
return word;
|
||||
// return readPatternWord(addr); // will start executing the pattern
|
||||
@@ -2161,18 +2134,15 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
|
||||
}
|
||||
|
||||
// get
|
||||
else {
|
||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
||||
"startAddr:0x%x)\n",
|
||||
level, *startAddr));
|
||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
||||
"startAddr:0x%x)\n",
|
||||
level, *startAddr));
|
||||
|
||||
*stopAddr = ((bus_r(addr) & stopMask) >> stopOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read "
|
||||
"stopAddr:0x%x)\n",
|
||||
level, *stopAddr));
|
||||
}
|
||||
*stopAddr = ((bus_r(addr) & stopMask) >> stopOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read "
|
||||
"stopAddr:0x%x)\n",
|
||||
level, *stopAddr));
|
||||
}
|
||||
|
||||
int setLEDEnable(int enable) {
|
||||
@@ -2242,22 +2212,15 @@ int startStateMachine() {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (sharedMemory_getStop() != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_setStatus(RUNNING);
|
||||
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@@ -2310,78 +2273,65 @@ void *start_timer(void *arg) {
|
||||
// Generate Data
|
||||
char imageData[imageSize];
|
||||
memset(imageData, 0, imageSize);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t *)(imageData + i)) = i;
|
||||
}
|
||||
for (int i = 0; i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t *)(imageData + i)) = i;
|
||||
}
|
||||
|
||||
// Send data
|
||||
{
|
||||
int frameNr = 0;
|
||||
// loop over number of frames
|
||||
for (frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
// loop over number of frames
|
||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
// check if virtual_stop is high
|
||||
if (virtual_stop == 1) {
|
||||
break;
|
||||
}
|
||||
// check if manual stop
|
||||
if (sharedMemory_getStop() == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i != packetsPerFrame; ++i) {
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
for (int i = 0; i != packetsPerFrame; ++i) {
|
||||
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
// set header
|
||||
sls_detector_header *header =
|
||||
(sls_detector_header *)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
// set header
|
||||
sls_detector_header *header = (sls_detector_header *)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = virtual_currentFrameNumber;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header),
|
||||
imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header),
|
||||
imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d [%lld]\n", frameNr,
|
||||
(long long unsigned int)virtual_currentFrameNumber));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs =
|
||||
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs) / 1000);
|
||||
}
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs) / 1000);
|
||||
}
|
||||
}
|
||||
++virtual_currentFrameNumber;
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@@ -2389,46 +2339,47 @@ void *start_timer(void *arg) {
|
||||
|
||||
int stopStateMachine() {
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while (tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
// if scan active, stop scan first
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
sharedMemory_setScanStop(1);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(1);
|
||||
// read till status is idle
|
||||
while (sharedMemory_getStatus() == RUNNING)
|
||||
;
|
||||
sharedMemory_setStop(0);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
return OK;
|
||||
#endif
|
||||
// stop state machine
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STP_ACQSTN_MSK);
|
||||
usleep(WAIT_TIME_US_STP_ACQ);
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STP_ACQSTN_MSK);
|
||||
|
||||
LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
// scan error or running
|
||||
if (sharedMemory_getScanStatus() == ERROR) {
|
||||
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||
return ERROR;
|
||||
}
|
||||
if (virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
} else {
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (sharedMemory_getStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
|
||||
uint32_t retval = bus_r(STATUS_REG);
|
||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||
|
||||
@@ -2555,11 +2506,8 @@ void readSample(int ns) {
|
||||
bus_w(addr, bus_r(addr) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK));
|
||||
|
||||
// wait for 1 us to latch different clocks of read and read strobe
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
|
||||
;
|
||||
}
|
||||
for (int i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
|
||||
;
|
||||
|
||||
if (!(ns % 1000)) {
|
||||
LOG(logDEBUG1, ("Reading sample ns:%d of %d AEmtpy:0x%x AFull:0x%x "
|
||||
@@ -2569,8 +2517,7 @@ void readSample(int ns) {
|
||||
}
|
||||
|
||||
// loop through all channels
|
||||
int ich = 0;
|
||||
for (ich = 0; ich < NCHAN_ANALOG; ++ich) {
|
||||
for (int ich = 0; ich < NCHAN_ANALOG; ++ich) {
|
||||
|
||||
// if channel is in enable mask
|
||||
if ((1 << ich) & (adcEnableMask_1g)) {
|
||||
@@ -2604,11 +2551,8 @@ void readSample(int ns) {
|
||||
bus_w(addr, bus_r(addr) & (~DUMMY_DGTL_FIFO_RD_STRBE_MSK));
|
||||
|
||||
// wait for 1 us to latch different clocks of read and read strobe
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
|
||||
;
|
||||
}
|
||||
for (int i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
|
||||
;
|
||||
|
||||
// wait as it is connected directly to fifo running on a different clock
|
||||
if (!(ns % 1000)) {
|
||||
@@ -2706,10 +2650,7 @@ int readFrameFromFifo() {
|
||||
|
||||
uint32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||
#endif
|
||||
uint32_t s = (bus_r(STATUS_REG) & STATUS_RN_BSY_MSK);
|
||||
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||
@@ -2735,8 +2676,7 @@ void getNumberOfChannels(int *nchanx, int *nchany) {
|
||||
if (mask == BIT32_MASK) {
|
||||
nachans = NCHAN_ANALOG;
|
||||
} else {
|
||||
int ich = 0;
|
||||
for (ich = 0; ich < NCHAN_ANALOG; ++ich) {
|
||||
for (int ich = 0; ich < NCHAN_ANALOG; ++ich) {
|
||||
if ((mask & (1 << ich)) != 0U)
|
||||
++nachans;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,6 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
|
||||
#define VIO_MIN_MV (1200) // for fpga to function
|
||||
|
||||
/* Defines in the Firmware */
|
||||
#define MAX_PATTERN_LENGTH (0x2000)
|
||||
#define DIGITAL_IO_DELAY_MAXIMUM_PS \
|
||||
((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
|
||||
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
|
||||
|
||||
@@ -141,8 +141,7 @@ void Beb_Beb(int id) {
|
||||
exit(1);
|
||||
|
||||
LOG(logDEBUG1, ("Printing Beb infos:\n"));
|
||||
unsigned int i;
|
||||
for (i = 1; i < bebInfoSize; i++)
|
||||
for (unsigned int i = 1; i < bebInfoSize; i++)
|
||||
BebInfo_Print(&beb_infos[i]);
|
||||
|
||||
Beb_bit_mode = 4;
|
||||
@@ -749,11 +748,7 @@ void Beb_ResetFrameNumber() {
|
||||
}
|
||||
}
|
||||
|
||||
void Beb_ClearBebInfos() {
|
||||
// unsigned int i;
|
||||
// for(i=0;i<bebInfoSize;i++) free(beb_infos[i]);
|
||||
bebInfoSize = 0;
|
||||
}
|
||||
void Beb_ClearBebInfos() { bebInfoSize = 0; }
|
||||
|
||||
int Beb_InitBebInfos() { // file name at some point
|
||||
Beb_ClearBebInfos();
|
||||
@@ -817,8 +812,8 @@ int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig,
|
||||
}
|
||||
|
||||
int Beb_CheckSourceStuffBebInfo() {
|
||||
unsigned int i;
|
||||
for (i = 1; i < bebInfoSize; i++) { // header stuff always starts from 1
|
||||
for (unsigned int i = 1; i < bebInfoSize;
|
||||
i++) { // header stuff always starts from 1
|
||||
if (!Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]), 0,
|
||||
"00:00:00:00:00:00", "10.0.0.1", 20000) ||
|
||||
!Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]), 1,
|
||||
@@ -833,10 +828,7 @@ int Beb_CheckSourceStuffBebInfo() {
|
||||
}
|
||||
|
||||
unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb) {
|
||||
/******************** if (!beb_numb) return
|
||||
* 0;******************************/
|
||||
unsigned int i;
|
||||
for (i = 1; i < bebInfoSize; i++)
|
||||
for (unsigned int i = 1; i < bebInfoSize; i++)
|
||||
if (beb_numb == BebInfo_GetBebNumber(&beb_infos[i])) {
|
||||
LOG(logDEBUG1,
|
||||
("*****found beb index:%d, for beb number:%d\n", i, beb_numb));
|
||||
@@ -870,14 +862,13 @@ int Beb_WriteTo(unsigned int index) {
|
||||
}
|
||||
|
||||
void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d) {
|
||||
unsigned int i;
|
||||
if (little_endian)
|
||||
for (i = 0; i < n; i++)
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
d[i] = (((d[i] & 0xff) << 24) | ((d[i] & 0xff00) << 8) |
|
||||
((d[i] & 0xff0000) >> 8) |
|
||||
((d[i] & 0xff000000) >> 24)); // little_endian
|
||||
else
|
||||
for (i = 0; i < n; i++)
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
d[i] = (((d[i] & 0xffff) << 16) | ((d[i] & 0xffff0000) >> 16));
|
||||
}
|
||||
|
||||
@@ -976,13 +967,9 @@ udp_header_type udp_header = {
|
||||
|
||||
unsigned int *base_ptr = (unsigned int *)&udp_header;
|
||||
unsigned int num_words = (sizeof(struct udp_header_type) + 3) / 4;
|
||||
// for(unsigned int i=0; i<num_words; i++) word_ptr[i] = base_ptr[i];
|
||||
// for(unsigned int i=num_words; i<16; i++) word_ptr[i] = 0;
|
||||
// return word_ptr;
|
||||
unsigned int i;
|
||||
for (i = 0; i < num_words; i++)
|
||||
for (unsigned int i = 0; i < num_words; i++)
|
||||
Beb_send_data[i + 2] = base_ptr[i];
|
||||
for (i = num_words; i < 16; i++)
|
||||
for (unsigned int i = num_words; i < 16; i++)
|
||||
Beb_send_data[i + 2] = 0;
|
||||
|
||||
return 1;
|
||||
@@ -1046,8 +1033,7 @@ void Beb_AdjustIPChecksum(struct udp_header_type *ip) {
|
||||
|
||||
// calc ip checksum
|
||||
unsigned int ip_checksum = 0;
|
||||
unsigned int i;
|
||||
for (i = 0; i < 10; i++) {
|
||||
for (unsigned int i = 0; i < 10; i++) {
|
||||
ip_checksum += ((cptr[2 * i] << 8) + (cptr[2 * i + 1]));
|
||||
if (ip_checksum & 0x00010000)
|
||||
ip_checksum = (ip_checksum + 1) & 0x0000ffff;
|
||||
@@ -1190,11 +1176,9 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
|
||||
LOG(logERROR, ("Beb Request N Images FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 10; i++)
|
||||
LOG(logDEBUG1,
|
||||
("%X\n", Beb_Read32(csp0base, (LEFT_OFFSET + i * 4))));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
LOG(logDEBUG1,
|
||||
("%X\n", Beb_Read32(csp0base, (LEFT_OFFSET + i * 4))));
|
||||
}
|
||||
// Generating commands
|
||||
u_int32_t send_header_command =
|
||||
@@ -1203,13 +1187,11 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
|
||||
u_int32_t send_frame_command =
|
||||
0x62000000 | (!test_just_send_out_packets_no_wait) << 27 |
|
||||
(ten_gig == 1) << 24 | packet_size << 14 | (npackets - 1);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 10; i++)
|
||||
LOG(logDEBUG1,
|
||||
("%X\n", Beb_Read32(csp0base, (LEFT_OFFSET + i * 4))));
|
||||
LOG(logDEBUG1, ("%d\n", in_two_requests));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
LOG(logDEBUG1,
|
||||
("%X\n", Beb_Read32(csp0base, (LEFT_OFFSET + i * 4))));
|
||||
}
|
||||
LOG(logDEBUG1, ("%d\n", in_two_requests));
|
||||
//"0x20 << 8" is dst_number (0x00 for left, 0x20 for right)
|
||||
// Left
|
||||
Beb_Write32(csp0base, (LEFT_OFFSET + FIRST_CMD_PART1_OFFSET), 0);
|
||||
@@ -1246,14 +1228,12 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
|
||||
nimages * (2 + in_two_requests));
|
||||
Beb_Write32(csp0base, (RIGHT_OFFSET + COMMAND_COUNTER_OFFSET),
|
||||
nimages * (2 + in_two_requests));
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 10; i++)
|
||||
LOG(logDEBUG1,
|
||||
("%X\n", Beb_Read32(csp0base,
|
||||
(LEFT_OFFSET + i * 4)))); //*(ptrl+i));
|
||||
LOG(logDEBUG1, ("%d\n", in_two_requests));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
LOG(logDEBUG1,
|
||||
("%X\n", Beb_Read32(csp0base,
|
||||
(LEFT_OFFSET + i * 4)))); //*(ptrl+i));
|
||||
}
|
||||
LOG(logDEBUG1, ("%d\n", in_two_requests));
|
||||
Beb_close(fd, csp0base);
|
||||
|
||||
LOG(logDEBUG1, ("----Beb_RequestNImages----\n"));
|
||||
@@ -1275,8 +1255,7 @@ int Beb_Test(unsigned int beb_number) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int i;
|
||||
for (i = 0; i < 64; i++) {
|
||||
for (unsigned int i = 0; i < 64; i++) {
|
||||
if (!Beb_SetUpUDPHeader(beb_number, 0, i, "60:fb:42:f4:e3:d2",
|
||||
"129.129.205.186", 22000 + i)) {
|
||||
LOG(logERROR, ("Error setting up header table....\n"));
|
||||
@@ -1288,7 +1267,7 @@ int Beb_Test(unsigned int beb_number) {
|
||||
// left_right, int ten_gig, unsigned int dst_number, unsigned int
|
||||
// npackets, unsigned int packet_size, int
|
||||
// stop_read_when_fifo_empty=1);
|
||||
for (i = 0; i < 64; i++) {
|
||||
for (unsigned int i = 0; i < 64; i++) {
|
||||
if (!Beb_SendMultiReadRequest(beb_number, i % 3 + 1, 0, i, 1, 0, 1)) {
|
||||
LOG(logERROR, ("Error requesting data....\n"));
|
||||
return 0;
|
||||
|
||||
@@ -5,7 +5,7 @@ set(src
|
||||
../slsDetectorServer/src/communication_funcs.c
|
||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||
../slsDetectorServer/src/common.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@@ -58,7 +58,7 @@ target_compile_definitions(eigerDetectorServerSlaveTop_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerSlaveTop_virtual
|
||||
PUBLIC pthread rt
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerSlaveTop_virtual PROPERTIES
|
||||
@@ -86,7 +86,7 @@ target_compile_definitions(eigerDetectorServerSlaveBottom_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerSlaveBottom_virtual
|
||||
PUBLIC pthread rt
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerSlaveBottom_virtual PROPERTIES
|
||||
@@ -96,3 +96,7 @@ set_target_properties(eigerDetectorServerSlaveBottom_virtual PROPERTIES
|
||||
install(TARGETS eigerDetectorServerSlaveBottom_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
|
||||
configure_file(config_eiger.txt ${CMAKE_BINARY_DIR}/bin/config_eiger.txt COPYONLY)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,123 +3,67 @@
|
||||
#include "slsDetectorServer_defs.h"
|
||||
#include <netinet/in.h>
|
||||
|
||||
struct Module {
|
||||
unsigned int module_number;
|
||||
int top_address_valid;
|
||||
unsigned int top_left_address;
|
||||
unsigned int top_right_address;
|
||||
int bottom_address_valid;
|
||||
unsigned int bottom_left_address;
|
||||
unsigned int bottom_right_address;
|
||||
|
||||
unsigned int idelay_top[4]; // ll,lr,rl,ll
|
||||
unsigned int idelay_bottom[4]; // ll,lr,rl,ll
|
||||
float high_voltage;
|
||||
int *top_dac;
|
||||
int *bottom_dac;
|
||||
};
|
||||
|
||||
void Module_Module(struct Module *mod, unsigned int number,
|
||||
unsigned int address_top);
|
||||
void Module_ModuleBottom(struct Module *mod, unsigned int number,
|
||||
unsigned int address_bottom);
|
||||
void Module_Module1(struct Module *mod, unsigned int number,
|
||||
unsigned int address_top, unsigned int address_bottom);
|
||||
unsigned int Module_GetModuleNumber(struct Module *mod);
|
||||
int Module_TopAddressIsValid(struct Module *mod);
|
||||
unsigned int Module_GetTopBaseAddress(struct Module *mod);
|
||||
unsigned int Module_GetTopLeftAddress(struct Module *mod);
|
||||
unsigned int Module_GetTopRightAddress(struct Module *mod);
|
||||
unsigned int Module_GetBottomBaseAddress(struct Module *mod);
|
||||
int Module_BottomAddressIsValid(struct Module *mod);
|
||||
unsigned int Module_GetBottomLeftAddress(struct Module *mod);
|
||||
unsigned int Module_GetBottomRightAddress(struct Module *mod);
|
||||
unsigned int Module_SetTopIDelay(struct Module *mod, unsigned int chip,
|
||||
unsigned int value);
|
||||
unsigned int Module_GetTopIDelay(struct Module *mod, unsigned int chip);
|
||||
unsigned int Module_SetBottomIDelay(struct Module *mod, unsigned int chip,
|
||||
unsigned int value);
|
||||
unsigned int Module_GetBottomIDelay(struct Module *mod, unsigned int chip);
|
||||
|
||||
float Module_SetHighVoltage(struct Module *mod, float value);
|
||||
float Module_GetHighVoltage(struct Module *mod);
|
||||
|
||||
int Module_SetTopDACValue(struct Module *mod, unsigned int i, int value);
|
||||
int Module_GetTopDACValue(struct Module *mod, unsigned int i);
|
||||
int Module_SetBottomDACValue(struct Module *mod, unsigned int i, int value);
|
||||
int Module_GetBottomDACValue(struct Module *mod, unsigned int i);
|
||||
|
||||
// setup
|
||||
void Feb_Control_activate(int activate);
|
||||
|
||||
int Feb_Control_IsBottomModule();
|
||||
int Feb_Control_GetModuleNumber();
|
||||
|
||||
void Feb_Control_PrintModuleList();
|
||||
int Feb_Control_GetModuleIndex(unsigned int module_number,
|
||||
unsigned int *module_index);
|
||||
int Feb_Control_CheckModuleAddresses(struct Module *m);
|
||||
int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address);
|
||||
int Feb_Control_AddModule1(unsigned int module_number, int top_enable,
|
||||
unsigned int top_address,
|
||||
unsigned int bottom_address, int half_module);
|
||||
int Feb_Control_GetDACNumber(char *s, unsigned int *n);
|
||||
int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch,
|
||||
unsigned int *value);
|
||||
void Feb_Control_FebControl();
|
||||
int Feb_Control_Init(int master, int normal, int module_num);
|
||||
int Feb_Control_OpenSerialCommunication();
|
||||
void Feb_Control_CloseSerialCommunication();
|
||||
int Feb_Control_CheckSetup();
|
||||
unsigned int Feb_Control_AddressToAll();
|
||||
int Feb_Control_SetCommandRegister(unsigned int cmd);
|
||||
int Feb_Control_SetStaticBits();
|
||||
int Feb_Control_SetStaticBits1(unsigned int the_static_bits);
|
||||
int Feb_Control_SetInTestModeVariable(int on);
|
||||
int Feb_Control_GetTestModeVariable();
|
||||
// idelays
|
||||
int Feb_Control_SetIDelays(unsigned int ndelay_units);
|
||||
int Feb_Control_SetIDelays1(unsigned int chip_pos, unsigned int ndelay_units);
|
||||
int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr,
|
||||
unsigned int channels, unsigned int ndelay_units);
|
||||
// high voltage
|
||||
int Feb_Control_SetHighVoltage(int value);
|
||||
int Feb_Control_GetHighVoltage(int *value);
|
||||
int Feb_Control_SendHighVoltage(int dacvalue);
|
||||
int Feb_Control_ReceiveHighVoltage(unsigned int *value);
|
||||
// dacs
|
||||
int Feb_Control_VoltageToDAC(float value, unsigned int *digital,
|
||||
unsigned int nsteps, float vmin, float vmax);
|
||||
float Feb_Control_DACToVoltage(unsigned int digital, unsigned int nsteps,
|
||||
float vmin, float vmax);
|
||||
int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr,
|
||||
unsigned int channels, unsigned int ndelay_units);
|
||||
int Feb_Control_SetStaticBits();
|
||||
int Feb_Control_SetStaticBits1(unsigned int the_static_bits);
|
||||
int Feb_Control_SendBitModeToBebServer();
|
||||
unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec);
|
||||
unsigned int Feb_Control_AddressToAll();
|
||||
int Feb_Control_SetCommandRegister(unsigned int cmd);
|
||||
int Feb_Control_SetDAC(unsigned int ch, int value);
|
||||
|
||||
// trimbits
|
||||
int Feb_Control_SetTrimbits(unsigned int *trimbits, int top);
|
||||
int Feb_Control_SaveAllTrimbitsTo(int value, int top);
|
||||
unsigned int *Feb_Control_GetTrimbits();
|
||||
|
||||
// acquisition
|
||||
int Feb_Control_AcquisitionInProgress();
|
||||
int Feb_Control_AcquisitionStartedBit();
|
||||
int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag);
|
||||
int Feb_Control_WaitForFinishedFlag(int sleep_time_us);
|
||||
int Feb_Control_GetDAQStatusRegister(unsigned int dst_address,
|
||||
unsigned int *ret_status);
|
||||
int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us);
|
||||
int Feb_Control_Reset();
|
||||
int Feb_Control_ResetChipCompletely();
|
||||
int Feb_Control_ResetChipPartially();
|
||||
void Feb_Control_FebControl();
|
||||
int Feb_Control_Init(int master, int top, int normal, int module_num);
|
||||
int Feb_Control_OpenSerialCommunication();
|
||||
void Feb_Control_CloseSerialCommunication();
|
||||
int Feb_Control_CheckSetup();
|
||||
unsigned int Feb_Control_GetNModules();
|
||||
unsigned int Feb_Control_GetNHalfModules();
|
||||
|
||||
int Feb_Control_SetHighVoltage(int value);
|
||||
int Feb_Control_GetHighVoltage(int *value);
|
||||
|
||||
int Feb_Control_SendHighVoltage(int dacvalue);
|
||||
int Feb_Control_ReceiveHighVoltage(unsigned int *value);
|
||||
|
||||
int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units);
|
||||
int Feb_Control_SetIDelays1(unsigned int module_num, unsigned int chip_pos,
|
||||
unsigned int ndelay_units);
|
||||
|
||||
int Feb_Control_DecodeDACString(char *dac_str, unsigned int *module_index,
|
||||
int *top, int *bottom, unsigned int *dac_ch);
|
||||
int Feb_Control_SetDAC(char *s, int value, int is_a_voltage_mv);
|
||||
int Feb_Control_GetDAC(char *s, int *ret_value, int voltage_mv);
|
||||
int Feb_Control_GetDACName(unsigned int dac_num, char *s);
|
||||
|
||||
int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits,
|
||||
int top);
|
||||
unsigned int *Feb_Control_GetTrimbits();
|
||||
int Feb_Control_SaveAllTrimbitsTo(int value, int top);
|
||||
int Feb_Control_Reset();
|
||||
int Feb_Control_SendBitModeToBebServer();
|
||||
unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec);
|
||||
int Feb_Control_PrepareForAcquisition();
|
||||
|
||||
void Feb_Control_PrintAcquisitionSetup();
|
||||
int Feb_Control_StartAcquisition();
|
||||
int Feb_Control_StopAcquisition();
|
||||
int Feb_Control_AcquisitionInProgress();
|
||||
int Feb_Control_AcquisitionStartedBit();
|
||||
int Feb_Control_WaitForFinishedFlag(int sleep_time_us);
|
||||
int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag);
|
||||
void Feb_Control_PrintAcquisitionSetup();
|
||||
int Feb_Control_SoftwareTrigger();
|
||||
|
||||
// parameters
|
||||
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo);
|
||||
unsigned int Feb_Control_GetDynamicRange();
|
||||
int Feb_Control_SetReadoutSpeed(unsigned int readout_speed);
|
||||
int Feb_Control_SetReadoutMode(unsigned int readout_mode);
|
||||
int Feb_Control_SetTriggerMode(unsigned int trigger_mode);
|
||||
int Feb_Control_SetExternalEnableMode(int use_external_enable, int polarity);
|
||||
int Feb_Control_SetNExposures(unsigned int n_images);
|
||||
unsigned int Feb_Control_GetNExposures();
|
||||
int Feb_Control_SetExposureTime(double the_exposure_time_in_sec);
|
||||
@@ -132,25 +76,20 @@ int Feb_Control_SetSubFramePeriod(int64_t the_subframe_period_in_10nsec);
|
||||
int64_t Feb_Control_GetSubFramePeriod();
|
||||
int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec);
|
||||
double Feb_Control_GetExposurePeriod();
|
||||
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo);
|
||||
unsigned int Feb_Control_GetDynamicRange();
|
||||
int Feb_Control_SetReadoutSpeed(
|
||||
unsigned int readout_speed); // 0 was default, 0->full,1->half,2->quarter or
|
||||
// 3->super_slow
|
||||
int Feb_Control_SetReadoutMode(
|
||||
unsigned int readout_mode); /// 0 was
|
||||
/// default,0->parallel,1->non-parallel,2->
|
||||
/// safe_mode
|
||||
int Feb_Control_SetTriggerMode(unsigned int trigger_mode,
|
||||
int polarity); // 0 and 1 was default,
|
||||
int Feb_Control_SetExternalEnableMode(int use_external_enable,
|
||||
int polarity); // 0 and 1 was default,
|
||||
|
||||
int Feb_Control_SetInTestModeVariable(int on);
|
||||
int Feb_Control_GetTestModeVariable();
|
||||
|
||||
void Feb_Control_Set_Counter_Bit(int value);
|
||||
int Feb_Control_Get_Counter_Bit();
|
||||
int Feb_Control_SetInterruptSubframe(int val);
|
||||
int Feb_Control_GetInterruptSubframe();
|
||||
int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right);
|
||||
void Feb_Control_SetMasterVariable(int val);
|
||||
int Feb_Control_SetMaster(enum MASTERINDEX ind);
|
||||
int Feb_Control_SetQuad(int val);
|
||||
int Feb_Control_SetReadNLines(int value);
|
||||
int Feb_Control_GetReadNLines();
|
||||
int Feb_Control_WriteRegister(uint32_t offset, uint32_t data);
|
||||
int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval);
|
||||
|
||||
// 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);
|
||||
int Feb_Control_Shift32InSerialIn(unsigned int value_to_shift_in);
|
||||
@@ -158,6 +97,7 @@ int Feb_Control_SendTokenIn();
|
||||
int Feb_Control_ClockRowClock(unsigned int ntimes);
|
||||
int Feb_Control_PulseChip(int npulses);
|
||||
|
||||
// rate correction
|
||||
int64_t Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
int64_t Feb_Control_Get_RateTable_Period_in_nsec();
|
||||
int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec);
|
||||
@@ -166,22 +106,8 @@ int Feb_Control_GetRateCorrectionVariable();
|
||||
void Feb_Control_SetRateCorrectionVariable(int activate_rate_correction);
|
||||
int Feb_Control_PrintCorrectedValues();
|
||||
|
||||
// adcs
|
||||
int Feb_Control_GetLeftFPGATemp();
|
||||
int Feb_Control_GetRightFPGATemp();
|
||||
|
||||
int64_t Feb_Control_GetMeasuredPeriod();
|
||||
int64_t Feb_Control_GetSubMeasuredPeriod();
|
||||
|
||||
int Feb_Control_SoftwareTrigger();
|
||||
int Feb_Control_SetInterruptSubframe(int val);
|
||||
int Feb_Control_GetInterruptSubframe();
|
||||
|
||||
int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right);
|
||||
void Feb_Control_SetMasterVariable(int val);
|
||||
int Feb_Control_SetMaster(enum MASTERINDEX ind);
|
||||
int Feb_Control_SetQuad(int val);
|
||||
int Feb_Control_SetReadNLines(int value);
|
||||
int Feb_Control_GetReadNLines();
|
||||
|
||||
int Feb_Control_WriteRegister(uint32_t offset, uint32_t data);
|
||||
int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval);
|
||||
|
||||
@@ -41,14 +41,13 @@ void Feb_Interface_FebInterface() {
|
||||
ll, XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
|
||||
}
|
||||
|
||||
void Feb_Interface_SendCompleteList(unsigned int n, unsigned int *list) {
|
||||
unsigned int i;
|
||||
void Feb_Interface_SetAddress(unsigned int leftAddr, unsigned int rightAddr) {
|
||||
if (Feb_Interface_feb_numb)
|
||||
free(Feb_Interface_feb_numb);
|
||||
Feb_Interface_nfebs = n;
|
||||
Feb_Interface_feb_numb = malloc(n * sizeof(unsigned int));
|
||||
for (i = 0; i < n; i++)
|
||||
Feb_Interface_feb_numb[i] = list[i];
|
||||
Feb_Interface_nfebs = 2;
|
||||
Feb_Interface_feb_numb = malloc(2 * sizeof(unsigned int));
|
||||
Feb_Interface_feb_numb[0] = leftAddr;
|
||||
Feb_Interface_feb_numb[1] = rightAddr;
|
||||
}
|
||||
|
||||
int Feb_Interface_WriteTo(unsigned int ch) {
|
||||
@@ -72,7 +71,6 @@ int Feb_Interface_WriteTo(unsigned int ch) {
|
||||
}
|
||||
|
||||
int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys) {
|
||||
unsigned int t;
|
||||
if (ch >= 0xfff)
|
||||
return 0;
|
||||
|
||||
@@ -81,7 +79,7 @@ int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys) {
|
||||
usleep(20);
|
||||
|
||||
Feb_Interface_recv_ndata = -1;
|
||||
for (t = 0; t < ntrys; t++) {
|
||||
for (unsigned int t = 0; t < ntrys; t++) {
|
||||
if ((Feb_Interface_recv_ndata =
|
||||
Local_Read(ll, Feb_Interface_recv_buffer_size * 4,
|
||||
Feb_Interface_recv_data_raw) /
|
||||
@@ -102,12 +100,13 @@ int Feb_Interface_SetByteOrder() {
|
||||
Feb_Interface_send_ndata = 2;
|
||||
Feb_Interface_send_data[0] = 0;
|
||||
Feb_Interface_send_data[1] = 0;
|
||||
unsigned int i;
|
||||
unsigned int dst = 0xff;
|
||||
for (i = 0; i < Feb_Interface_nfebs; i++)
|
||||
for (unsigned int i = 0; i < Feb_Interface_nfebs; i++)
|
||||
dst = (dst | Feb_Interface_feb_numb[i]);
|
||||
int passed = Feb_Interface_WriteTo(dst);
|
||||
|
||||
if (!passed) {
|
||||
LOG(logERROR, ("Could not set byte order in Feb Interface\n"));
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
@@ -119,8 +118,6 @@ int Feb_Interface_ReadRegister(unsigned int sub_num, unsigned int reg_num,
|
||||
int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads,
|
||||
unsigned int *reg_nums,
|
||||
unsigned int *values_read) {
|
||||
// here cout<<"Reading Register ...."<<endl;
|
||||
unsigned int i;
|
||||
nreads &= 0x3ff;
|
||||
if (!nreads || nreads > Feb_Interface_send_buffer_size - 2)
|
||||
return 0;
|
||||
@@ -128,7 +125,7 @@ int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads,
|
||||
Feb_Interface_send_ndata = nreads + 2;
|
||||
Feb_Interface_send_data[0] = 0x20000000 | nreads << 14;
|
||||
|
||||
for (i = 0; i < nreads; i++)
|
||||
for (unsigned int i = 0; i < nreads; i++)
|
||||
Feb_Interface_send_data[i + 1] = reg_nums[i];
|
||||
Feb_Interface_send_data[nreads + 1] = 0;
|
||||
|
||||
@@ -137,7 +134,7 @@ int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads,
|
||||
Feb_Interface_recv_ndata != (int)(nreads + 2))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < nreads; i++)
|
||||
for (unsigned int i = 0; i < nreads; i++)
|
||||
values_read[i] = Feb_Interface_recv_data[i + 1];
|
||||
|
||||
return 1;
|
||||
@@ -154,7 +151,6 @@ int Feb_Interface_WriteRegisters(unsigned int sub_num, unsigned int nwrites,
|
||||
unsigned int *reg_nums, unsigned int *values,
|
||||
int *wait_ons,
|
||||
unsigned int *wait_on_addresses) {
|
||||
unsigned int i;
|
||||
nwrites &= 0x3ff; // 10 bits
|
||||
if (!nwrites || 2 * nwrites > Feb_Interface_send_buffer_size - 2)
|
||||
return 0;
|
||||
@@ -165,13 +161,13 @@ int Feb_Interface_WriteRegisters(unsigned int sub_num, unsigned int nwrites,
|
||||
Feb_Interface_send_data[0] = 0x80000000 | nwrites << 14;
|
||||
Feb_Interface_send_data[2 * nwrites + 1] = 0;
|
||||
|
||||
for (i = 0; i < nwrites; i++)
|
||||
for (unsigned int i = 0; i < nwrites; i++)
|
||||
Feb_Interface_send_data[2 * i + 1] = 0x3fff & reg_nums[i];
|
||||
for (i = 0; i < nwrites; i++)
|
||||
for (unsigned int i = 0; i < nwrites; i++)
|
||||
Feb_Interface_send_data[2 * i + 2] = values[i];
|
||||
// wait on busy data(28), address of busy flag data(27 downto 14)
|
||||
if (wait_ons && wait_on_addresses)
|
||||
for (i = 0; i < nwrites; i++)
|
||||
for (unsigned int i = 0; i < nwrites; i++)
|
||||
Feb_Interface_send_data[2 * i + 1] |=
|
||||
(wait_ons[i] << 28 | (0x3fff & wait_on_addresses[i]) << 14);
|
||||
|
||||
@@ -211,7 +207,6 @@ int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num,
|
||||
unsigned int start_address, unsigned int nwrites,
|
||||
unsigned int *values) {
|
||||
// -1 means write to all
|
||||
unsigned int i;
|
||||
mem_num &= 0x3f;
|
||||
start_address &= 0x3fff;
|
||||
nwrites &= 0x3ff;
|
||||
@@ -226,7 +221,7 @@ int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num,
|
||||
start_address; // cmd -> write to memory, nwrites, mem number, start
|
||||
// address
|
||||
Feb_Interface_send_data[nwrites + 1] = 0;
|
||||
for (i = 0; i < nwrites; i++)
|
||||
for (unsigned int i = 0; i < nwrites; i++)
|
||||
Feb_Interface_send_data[i + 1] = values[i];
|
||||
|
||||
if (!Feb_Interface_WriteTo(sub_num))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
int Feb_Interface_WriteTo(unsigned int ch);
|
||||
int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys);
|
||||
void Feb_Interface_FebInterface();
|
||||
void Feb_Interface_SendCompleteList(unsigned int n, unsigned int *list);
|
||||
void Feb_Interface_SetAddress(unsigned int leftAddr, unsigned int rightAddr);
|
||||
int Feb_Interface_SetByteOrder();
|
||||
int Feb_Interface_ReadRegister(unsigned int sub_num, unsigned int reg_num,
|
||||
unsigned int *value_read);
|
||||
|
||||
@@ -81,7 +81,6 @@ int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
||||
// note: buffer must be word (4 byte) aligned
|
||||
// frame_len in byte
|
||||
int vacancy = 0;
|
||||
int i;
|
||||
int words_send = 0;
|
||||
int last_word;
|
||||
unsigned int *word_ptr;
|
||||
@@ -96,7 +95,7 @@ int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
||||
|
||||
LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ", buffer_len,
|
||||
ll->ll_fifo_base));
|
||||
for (i = 0; i < buffer_len / 4; i++)
|
||||
for (int i = 0; i < buffer_len / 4; i++)
|
||||
LOG(logDEBUG1, ("%.8X ", *(((unsigned *)buffer) + i)));
|
||||
|
||||
while (words_send <= last_word) {
|
||||
@@ -112,8 +111,8 @@ int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
||||
}
|
||||
|
||||
// Just to know: #define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100
|
||||
for (i = 0; ((i < PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS) &&
|
||||
(words_send <= last_word));
|
||||
for (int i = 0; ((i < PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS) &&
|
||||
(words_send <= last_word));
|
||||
i++) {
|
||||
fifo_ctrl = 0;
|
||||
if (words_send == 0) {
|
||||
|
||||
@@ -6,14 +6,14 @@ support_lib = ../../slsSupportLib/include/
|
||||
BLACKFIN_CC = bfin-uclinux-gcc
|
||||
CROSS = powerpc-4xx-softfloat-
|
||||
CC = $(CROSS)gcc
|
||||
CFLAGS += -Wall -DEIGERD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm
|
||||
CFLAGS += -Wall -std=gnu99 -DEIGERD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lrt -pthread
|
||||
PROGS = eigerDetectorServer
|
||||
DESTDIR = bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c HardwareIO.c LocalLinkInterface.c FebInterface.c FebControl.c Beb.c
|
||||
SRCS += $(main_src)communication_funcs.c $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs_UDP.c $(main_src)common.c
|
||||
SRCS += $(main_src)communication_funcs.c $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs_UDP.c $(main_src)common.c $(main_src)/sharedMemory.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
@@ -33,6 +33,7 @@ $(PROGS): $(OBJS)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
cp config_eiger.txt $(DESTDIR)
|
||||
|
||||
|
||||
hv9m_blackfin_server:9mhvserial_bf.c
|
||||
|
||||
Binary file not shown.
0
slsDetectorServers/eigerDetectorServer/config.txt → slsDetectorServers/eigerDetectorServer/config_eiger.txt
Normal file → Executable file
0
slsDetectorServers/eigerDetectorServer/config.txt → slsDetectorServers/eigerDetectorServer/config_eiger.txt
Normal file → Executable file
@@ -1,13 +1,12 @@
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
#ifndef VIRTUAL
|
||||
#include "Beb.h"
|
||||
#include "FebControl.h"
|
||||
#else
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
@@ -33,10 +32,6 @@ int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
|
||||
const char *dac_names[16] = {"SvP", "Vtr", "Vrf", "Vrs",
|
||||
"SvN", "Vtgstv", "Vcmp_ll", "Vcmp_lr",
|
||||
"cal", "Vcmp_rl", "rxb_rb", "rxb_lb",
|
||||
"Vcmp_rr", "Vcp", "Vcn", "Vis"};
|
||||
int default_tau_from_file = -1;
|
||||
enum detectorSettings thisSettings;
|
||||
sls_detector_module *detectorModules = NULL;
|
||||
@@ -64,7 +59,6 @@ int eiger_iodelay = 0;
|
||||
int eiger_photonenergy = 0;
|
||||
int eiger_dynamicrange = 0;
|
||||
int eiger_parallelmode = 0;
|
||||
int eiger_storeinmem = 0;
|
||||
int eiger_overflow32 = 0;
|
||||
int eiger_readoutspeed = 0;
|
||||
int eiger_triggermode = 0;
|
||||
@@ -76,8 +70,6 @@ int eiger_tau_ns = 0;
|
||||
|
||||
#ifdef VIRTUAL
|
||||
pthread_t virtual_tid;
|
||||
int virtual_status = 0;
|
||||
int virtual_stop = 0;
|
||||
// values for virtual server
|
||||
int64_t eiger_virtual_exptime = 0;
|
||||
int64_t eiger_virtual_subexptime = 0;
|
||||
@@ -256,9 +248,10 @@ u_int64_t getDetectorMAC() {
|
||||
// execute and get address
|
||||
char output[255];
|
||||
#ifdef VIRTUAL
|
||||
FILE *sysFile = popen("cat /sys/class/net/$(ip route show default | awk "
|
||||
"'/default/ {print $5}')/address",
|
||||
"r");
|
||||
FILE *sysFile =
|
||||
popen("cat /sys/class/net/$(ip route show default | grep -v vpn | awk "
|
||||
"'/default/ {print $5}')/address",
|
||||
"r");
|
||||
#else
|
||||
FILE *sysFile = popen("more /sys/class/net/eth0/address", "r");
|
||||
#endif
|
||||
@@ -293,9 +286,10 @@ u_int32_t getDetectorIP() {
|
||||
// execute and get address
|
||||
char output[255];
|
||||
#ifdef VIRTUAL
|
||||
FILE *sysFile = popen("ifconfig $(ip route show default | awk '/default/ "
|
||||
"{print $5}') | grep 'inet ' | cut -d ' ' -f10",
|
||||
"r");
|
||||
FILE *sysFile =
|
||||
popen("ifconfig $(ip route show default | grep -v vpn | awk '/default/ "
|
||||
"{print $5}') | grep 'inet ' | cut -d ' ' -f10",
|
||||
"r");
|
||||
#else
|
||||
FILE *sysFile = popen(
|
||||
"ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2",
|
||||
@@ -333,11 +327,24 @@ void initControlServer() {
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
// same addresses for top and bottom
|
||||
Feb_Control_Init(master, 1, normal, getDetectorNumber());
|
||||
if (!Feb_Control_Init(master, normal, getDetectorNumber())) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not intitalize feb control\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
// master of 9M, check high voltage serial communication to blackfin
|
||||
if (master && !normal) {
|
||||
if (Feb_Control_OpenSerialCommunication())
|
||||
; // Feb_Control_CloseSerialCommunication();
|
||||
if (!Feb_Control_OpenSerialCommunication()) {
|
||||
initError = FAIL;
|
||||
sprintf(
|
||||
initErrorMessage,
|
||||
"Could not intitalize feb control serial communication\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
|
||||
Beb_SetTopVariable(top);
|
||||
@@ -355,10 +362,7 @@ void initStopServer() {
|
||||
#ifdef VIRTUAL
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
getModuleConfiguration();
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
sharedMemory_setStop(0);
|
||||
// get top/master in virtual
|
||||
readConfigFile();
|
||||
#else
|
||||
@@ -372,7 +376,7 @@ void initStopServer() {
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
// same addresses for top and bottom
|
||||
Feb_Control_Init(master, 1, normal, getDetectorNumber());
|
||||
Feb_Control_Init(master, normal, getDetectorNumber());
|
||||
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||
#endif
|
||||
// client first connect (from shm) will activate
|
||||
@@ -421,7 +425,14 @@ int readConfigFile() {
|
||||
}
|
||||
master = -1;
|
||||
top = -1;
|
||||
FILE *fd = fopen(CONFIG_FILE, "r");
|
||||
|
||||
char fname[128];
|
||||
if (getAbsPath(fname, 128, CONFIG_FILE) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// open config file
|
||||
FILE *fd = fopen(fname, "r");
|
||||
if (fd == NULL) {
|
||||
LOG(logINFO, ("No config file found. Resetting to hardware settings "
|
||||
"(Top/Master)\n"));
|
||||
@@ -639,8 +650,7 @@ void allocateDetectorStructureMemory() {
|
||||
thisSettings = UNINITIALIZED;
|
||||
|
||||
// if trimval requested, should return -1 to acknowledge unknown
|
||||
int ichan = 0;
|
||||
for (ichan = 0; ichan < (detectorModules->nchan); ichan++) {
|
||||
for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
|
||||
*((detectorModules->chanregs) + ichan) = -1;
|
||||
}
|
||||
}
|
||||
@@ -651,9 +661,8 @@ void setupDetector() {
|
||||
// set dacs
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
{
|
||||
int i = 0;
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (i = 0; i < NDAC; ++i) {
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if ((detectorModules)->dacs[i] != defaultvals[i]) {
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
@@ -662,10 +671,7 @@ void setupDetector() {
|
||||
}
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
#endif
|
||||
|
||||
LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||
@@ -680,8 +686,7 @@ void setupDetector() {
|
||||
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
|
||||
eiger_photonenergy = DEFAULT_PHOTON_ENERGY;
|
||||
setParallelMode(DEFAULT_PARALLEL_MODE);
|
||||
setOverFlowMode(DEFAULT_READOUT_STOREINRAM_MODE);
|
||||
setStoreInRamMode(DEFAULT_READOUT_OVERFLOW32_MODE);
|
||||
setOverFlowMode(DEFAULT_READOUT_OVERFLOW32_MODE);
|
||||
setClockDivider(RUN_CLK, DEFAULT_CLK_SPEED); // clk_devider,half speed
|
||||
setIODelay(DEFAULT_IO_DELAY);
|
||||
setTiming(DEFAULT_TIMING_MODE);
|
||||
@@ -697,7 +702,12 @@ void setupDetector() {
|
||||
#endif
|
||||
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
|
||||
#ifndef VIRTUAL
|
||||
Feb_Control_CheckSetup();
|
||||
if (!Feb_Control_CheckSetup()) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not pass feb control setup checks\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// force top or master if in config file
|
||||
if (readConfigFile() == FAIL) {
|
||||
@@ -748,8 +758,7 @@ int setDynamicRange(int dr) {
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetDynamicRange(dr)) {
|
||||
on_dst = 0;
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
for (int i = 0; i < 32; ++i)
|
||||
dst_requested[i] = 0; // clear dst requested
|
||||
if (!Beb_SetUpTransferParameters(dr)) {
|
||||
LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
@@ -794,14 +803,6 @@ int setOverFlowMode(int mode) {
|
||||
|
||||
int getOverFlowMode() { return eiger_overflow32; }
|
||||
|
||||
void setStoreInRamMode(int mode) {
|
||||
mode = (mode == 0 ? 0 : 1);
|
||||
LOG(logINFO, ("Setting Store in Ram mode to %d\n", mode));
|
||||
eiger_storeinmem = mode;
|
||||
}
|
||||
|
||||
int getStoreInRamMode() { return eiger_storeinmem; }
|
||||
|
||||
/* parameters - timer */
|
||||
|
||||
int setStartingFrameNumber(uint64_t value) {
|
||||
@@ -829,8 +830,7 @@ void setNumFrames(int64_t val) {
|
||||
if (Feb_Control_SetNExposures((unsigned int)val * eiger_ntriggers)) {
|
||||
eiger_nexposures = val;
|
||||
on_dst = 0;
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
for (int i = 0; i < 32; ++i)
|
||||
dst_requested[i] = 0; // clear dst requested
|
||||
ndsts_in_use = 1;
|
||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||
@@ -851,8 +851,7 @@ void setNumTriggers(int64_t val) {
|
||||
if (Feb_Control_SetNExposures((unsigned int)val * eiger_nexposures)) {
|
||||
eiger_ntriggers = val;
|
||||
on_dst = 0;
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
for (int i = 0; i < 32; ++i)
|
||||
dst_requested[i] = 0; // clear dst requested
|
||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||
}
|
||||
@@ -1021,18 +1020,14 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
}
|
||||
|
||||
// dacs
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
|
||||
if (myMod.dacs[i] != (detectorModules)->dacs[i]) {
|
||||
sprintf(mess, "Could not set module. Could not set dac %d\n",
|
||||
i);
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
return FAIL;
|
||||
}
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
|
||||
if (myMod.dacs[i] != (detectorModules)->dacs[i]) {
|
||||
sprintf(mess, "Could not set module. Could not set dac %d\n", i);
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1044,10 +1039,10 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
LOG(logINFO, ("Setting module with trimbits\n"));
|
||||
// includ gap pixels
|
||||
unsigned int tt[263680];
|
||||
int iy, ichip, ix, ip = 0, ich = 0;
|
||||
for (iy = 0; iy < 256; ++iy) {
|
||||
for (ichip = 0; ichip < 4; ++ichip) {
|
||||
for (ix = 0; ix < 256; ++ix) {
|
||||
int ip = 0, ich = 0;
|
||||
for (int iy = 0; iy < 256; ++iy) {
|
||||
for (int ichip = 0; ichip < 4; ++ichip) {
|
||||
for (int ix = 0; ix < 256; ++ix) {
|
||||
tt[ip++] = myMod.chanregs[ich++];
|
||||
}
|
||||
if (ichip < 3) {
|
||||
@@ -1058,7 +1053,7 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
}
|
||||
|
||||
// set trimbits
|
||||
if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(), tt, top)) {
|
||||
if (!Feb_Control_SetTrimbits(tt, top)) {
|
||||
sprintf(mess, "Could not set module. Could not set trimbits\n");
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
@@ -1113,43 +1108,11 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModule(sls_detector_module *myMod) {
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// trimbits
|
||||
unsigned int *tt;
|
||||
tt = Feb_Control_GetTrimbits();
|
||||
|
||||
// exclude gap pixels
|
||||
int iy, ichip, ix, ip = 0, ich = 0;
|
||||
for (iy = 0; iy < 256; ++iy) {
|
||||
for (ichip = 0; ichip < 4; ++ichip) {
|
||||
for (ix = 0; ix < 256; ++iy) {
|
||||
myMod->chanregs[ich++] = tt[ip++];
|
||||
}
|
||||
if (ichip < 3) {
|
||||
ip++;
|
||||
ip++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// copy local module to myMod
|
||||
if (detectorModules) {
|
||||
if (copyModule(myMod, detectorModules) == FAIL)
|
||||
return FAIL;
|
||||
} else
|
||||
return FAIL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
if (sett == UNINITIALIZED) {
|
||||
return thisSettings;
|
||||
}
|
||||
if (sett != GET_SETTINGS)
|
||||
thisSettings = sett;
|
||||
thisSettings = sett;
|
||||
LOG(logINFO, ("Settings: %d\n", thisSettings));
|
||||
return thisSettings;
|
||||
}
|
||||
@@ -1196,6 +1159,10 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *dac_names[] = {DAC_NAMES};
|
||||
LOG(logINFO, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind],
|
||||
val, (mV ? "mV" : "dac units")));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
int dacval = 0;
|
||||
if (!mV) {
|
||||
@@ -1207,11 +1174,17 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
(detectorModules)->dacs[ind] = dacval;
|
||||
}
|
||||
#else
|
||||
char iname[10];
|
||||
strcpy(iname, dac_names[(int)ind]);
|
||||
if (Feb_Control_SetDAC(iname, val, mV)) {
|
||||
int dacval = 0;
|
||||
Feb_Control_GetDAC(iname, &dacval, 0);
|
||||
int dacval = val;
|
||||
if (mV) {
|
||||
// convert to dac units
|
||||
if (ConvertToDifferentRange(DAC_MIN_MV, DAC_MAX_MV, LTC2620_MIN_VAL,
|
||||
LTC2620_MAX_VAL, val, &dacval) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not convert %d mV for dac to dac units\n", val));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Feb_Control_SetDAC(ind, dacval)) {
|
||||
(detectorModules)->dacs[ind] = dacval;
|
||||
}
|
||||
#endif
|
||||
@@ -1301,6 +1274,7 @@ int setHighVoltage(int val) {
|
||||
if (master) {
|
||||
// set
|
||||
if (val != -1) {
|
||||
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
||||
eiger_theo_highvoltage = val;
|
||||
}
|
||||
return eiger_theo_highvoltage;
|
||||
@@ -1364,7 +1338,7 @@ void setTiming(enum timingMode arg) {
|
||||
}
|
||||
LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetTriggerMode(ret, 1))
|
||||
if (Feb_Control_SetTriggerMode(ret))
|
||||
#endif
|
||||
eiger_triggermode = ret;
|
||||
}
|
||||
@@ -1381,7 +1355,7 @@ enum timingMode getTiming() {
|
||||
return GATED;
|
||||
default:
|
||||
LOG(logERROR, ("Unknown trigger mode found %d\n", eiger_triggermode));
|
||||
return GET_TIMING_MODE;
|
||||
return GET_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1432,37 +1406,32 @@ int configureMAC() {
|
||||
if (!top)
|
||||
dst_port = dstport2;
|
||||
|
||||
int i = 0;
|
||||
/* for(i=0;i<32;i++) { modified for Aldo*/
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num, send_to_ten_gig, src_mac, src_ip,
|
||||
srcport) &&
|
||||
Beb_SetUpUDPHeader(beb_num, send_to_ten_gig, header_number + i, dst_mac,
|
||||
Beb_SetUpUDPHeader(beb_num, send_to_ten_gig, header_number, dst_mac,
|
||||
dst_ip, dst_port)) {
|
||||
LOG(logDEBUG1, ("\tset up left ok\n"));
|
||||
} else {
|
||||
return FAIL;
|
||||
}
|
||||
/*}*/
|
||||
|
||||
header_number = 32;
|
||||
dst_port = dstport2;
|
||||
if (!top)
|
||||
dst_port = dstport;
|
||||
|
||||
/*for(i=0;i<32;i++) {*/ /** modified for Aldo*/
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num, send_to_ten_gig, src_mac, src_ip,
|
||||
srcport) &&
|
||||
Beb_SetUpUDPHeader(beb_num, send_to_ten_gig, header_number + i, dst_mac,
|
||||
Beb_SetUpUDPHeader(beb_num, send_to_ten_gig, header_number, dst_mac,
|
||||
dst_ip, dst_port)) {
|
||||
LOG(logDEBUG1, (" set up right ok\n"));
|
||||
} else {
|
||||
return FAIL;
|
||||
}
|
||||
/*}*/
|
||||
|
||||
on_dst = 0;
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
for (int i = 0; i < 32; ++i)
|
||||
dst_requested[i] = 0; // clear dst requested
|
||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||
#endif
|
||||
@@ -1490,6 +1459,11 @@ int setQuad(int value) {
|
||||
if (value < 0) {
|
||||
return OK;
|
||||
}
|
||||
// only top can be set to quad
|
||||
if (!top && value > 0) {
|
||||
LOG(logERROR, ("Only a top can be set to quad\n"));
|
||||
return FAIL;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
if (Beb_SetQuad(value) == FAIL) {
|
||||
return FAIL;
|
||||
@@ -1561,7 +1535,6 @@ int enableTenGigabitEthernet(int val) {
|
||||
send_to_ten_gig = 1;
|
||||
else
|
||||
send_to_ten_gig = 0;
|
||||
// configuremac called from client
|
||||
}
|
||||
return send_to_ten_gig;
|
||||
}
|
||||
@@ -1594,7 +1567,7 @@ int setIODelay(int val) {
|
||||
if (val != -1) {
|
||||
LOG(logDEBUG1, ("Setting IO Delay: %d\n", val));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetIDelays(Feb_Control_GetModuleNumber(), val))
|
||||
if (Feb_Control_SetIDelays(val))
|
||||
#endif
|
||||
eiger_iodelay = val;
|
||||
}
|
||||
@@ -1827,6 +1800,8 @@ int64_t getCurrentTau() {
|
||||
}
|
||||
|
||||
void setExternalGating(int enable[]) {
|
||||
// not configured from client
|
||||
// default: disable gating with positive polarity
|
||||
if (enable[0] >= 0 && enable[1] >= 0) {
|
||||
#ifndef VIRTUAL
|
||||
Feb_Control_SetExternalEnableMode(
|
||||
@@ -1849,8 +1824,7 @@ int setAllTrimbits(int val) {
|
||||
}
|
||||
#endif
|
||||
if (detectorModules) {
|
||||
int ichan;
|
||||
for (ichan = 0; ichan < (detectorModules->nchan); ichan++) {
|
||||
for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
|
||||
*((detectorModules->chanregs) + ichan) = val;
|
||||
}
|
||||
}
|
||||
@@ -1860,10 +1834,9 @@ int setAllTrimbits(int val) {
|
||||
}
|
||||
|
||||
int getAllTrimbits() {
|
||||
int ichan = 0;
|
||||
int value = *((detectorModules->chanregs));
|
||||
if (detectorModules) {
|
||||
for (ichan = 0; ichan < (detectorModules->nchan); ichan++) {
|
||||
for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
|
||||
if (*((detectorModules->chanregs) + ichan) != value) {
|
||||
value = -1;
|
||||
break;
|
||||
@@ -2013,39 +1986,30 @@ int startStateMachine() {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (sharedMemory_getStop() != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_setStatus(RUNNING);
|
||||
if (pthread_create(&virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("Virtual Acquisition started\n"));
|
||||
return OK;
|
||||
#else
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
LOG(logINFO, ("Acquisition started bit toggled\n"));
|
||||
int ret = OK, prev_flag;
|
||||
// get the DAQ toggle bit
|
||||
prev_flag = Feb_Control_AcquisitionStartedBit();
|
||||
|
||||
LOG(logINFO, ("Going to start acquisition\n"));
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
Feb_Control_StartAcquisition();
|
||||
|
||||
if (!eiger_storeinmem) {
|
||||
LOG(logINFO, ("requesting images right after start\n"));
|
||||
ret = startReadOut();
|
||||
}
|
||||
LOG(logINFO, ("requesting images right after start\n"));
|
||||
ret = startReadOut();
|
||||
|
||||
// wait for acquisition start
|
||||
if (ret == OK) {
|
||||
@@ -2094,10 +2058,9 @@ void *start_timer(void *arg) {
|
||||
char imageData[databytes * 2];
|
||||
memset(imageData, 0, databytes * 2);
|
||||
{
|
||||
int i = 0;
|
||||
switch (dr) {
|
||||
case 4:
|
||||
for (i = 0; i < ntotpixels / 2; ++i) {
|
||||
for (int i = 0; i < ntotpixels / 2; ++i) {
|
||||
*((uint8_t *)(imageData + i)) =
|
||||
eiger_virtual_test_mode
|
||||
? 0xEE
|
||||
@@ -2105,19 +2068,19 @@ void *start_timer(void *arg) {
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (i = 0; i < ntotpixels; ++i) {
|
||||
for (int i = 0; i < ntotpixels; ++i) {
|
||||
*((uint8_t *)(imageData + i)) =
|
||||
eiger_virtual_test_mode ? 0xFE : (uint8_t)i;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
for (i = 0; i < ntotpixels; ++i) {
|
||||
for (int i = 0; i < ntotpixels; ++i) {
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||
eiger_virtual_test_mode ? 0xFFE : (uint16_t)i;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
for (i = 0; i < ntotpixels; ++i) {
|
||||
for (int i = 0; i < ntotpixels; ++i) {
|
||||
*((uint32_t *)(imageData + i * sizeof(uint32_t))) =
|
||||
eiger_virtual_test_mode ? 0xFFFFFE : (uint32_t)i;
|
||||
}
|
||||
@@ -2132,15 +2095,12 @@ void *start_timer(void *arg) {
|
||||
uint64_t frameNr = 0;
|
||||
getStartingFrameNumber(&frameNr);
|
||||
// loop over number of frames
|
||||
int iframes = 0;
|
||||
for (iframes = 0; iframes != numFrames; ++iframes) {
|
||||
for (int iframes = 0; iframes != numFrames; ++iframes) {
|
||||
|
||||
usleep(eiger_virtual_transmission_delay_frame);
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
// check if virtual_stop is high
|
||||
if (virtual_stop == 1) {
|
||||
// check if manual stop
|
||||
if (sharedMemory_getStop() == 1) {
|
||||
setStartingFrameNumber(frameNr + iframes + 1);
|
||||
break;
|
||||
}
|
||||
@@ -2154,76 +2114,72 @@ void *start_timer(void *arg) {
|
||||
int srcOffset2 = npixelsx;
|
||||
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i != numPacketsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
sls_detector_header *header =
|
||||
(sls_detector_header *)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION;
|
||||
header->frameNumber = frameNr + iframes;
|
||||
header->packetNumber = i;
|
||||
header->row = row;
|
||||
header->column = colLeft;
|
||||
for (int i = 0; i != numPacketsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
sls_detector_header *header =
|
||||
(sls_detector_header *)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION;
|
||||
header->frameNumber = frameNr + iframes;
|
||||
header->packetNumber = i;
|
||||
header->row = row;
|
||||
header->column = colLeft;
|
||||
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
header = (sls_detector_header *)(packetData2);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION;
|
||||
header->frameNumber = frameNr + iframes;
|
||||
header->packetNumber = i;
|
||||
header->row = row;
|
||||
header->column = colRight;
|
||||
if (eiger_virtual_quad_mode) {
|
||||
header->row = 1; // right is next row
|
||||
header->column = 0; // right same first column
|
||||
}
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
header = (sls_detector_header *)(packetData2);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION;
|
||||
header->frameNumber = frameNr + iframes;
|
||||
header->packetNumber = i;
|
||||
header->row = row;
|
||||
header->column = colRight;
|
||||
if (eiger_virtual_quad_mode) {
|
||||
header->row = 1; // right is next row
|
||||
header->column = 0; // right same first column
|
||||
}
|
||||
|
||||
// fill data
|
||||
int dstOffset = sizeof(sls_detector_header);
|
||||
int dstOffset2 = sizeof(sls_detector_header);
|
||||
{
|
||||
int psize = 0;
|
||||
for (psize = 0; psize < datasize; psize += npixelsx) {
|
||||
// fill data
|
||||
int dstOffset = sizeof(sls_detector_header);
|
||||
int dstOffset2 = sizeof(sls_detector_header);
|
||||
{
|
||||
for (int psize = 0; psize < datasize; psize += npixelsx) {
|
||||
|
||||
if (dr == 32 && tgEnable == 0) {
|
||||
memcpy(packetData + dstOffset,
|
||||
imageData + srcOffset, npixelsx / 2);
|
||||
memcpy(packetData2 + dstOffset2,
|
||||
imageData + srcOffset2, npixelsx / 2);
|
||||
if (srcOffset % npixelsx == 0) {
|
||||
srcOffset += npixelsx / 2;
|
||||
srcOffset2 += npixelsx / 2;
|
||||
}
|
||||
// skip the other half (2 packets in 1 line for
|
||||
// 32 bit)
|
||||
else {
|
||||
srcOffset += npixelsx;
|
||||
srcOffset2 += npixelsx;
|
||||
}
|
||||
dstOffset += npixelsx / 2;
|
||||
dstOffset2 += npixelsx / 2;
|
||||
} else {
|
||||
memcpy(packetData + dstOffset,
|
||||
imageData + srcOffset, npixelsx);
|
||||
memcpy(packetData2 + dstOffset2,
|
||||
imageData + srcOffset2, npixelsx);
|
||||
srcOffset += 2 * npixelsx;
|
||||
srcOffset2 += 2 * npixelsx;
|
||||
dstOffset += npixelsx;
|
||||
dstOffset2 += npixelsx;
|
||||
if (dr == 32 && tgEnable == 0) {
|
||||
memcpy(packetData + dstOffset,
|
||||
imageData + srcOffset, npixelsx / 2);
|
||||
memcpy(packetData2 + dstOffset2,
|
||||
imageData + srcOffset2, npixelsx / 2);
|
||||
if (srcOffset % npixelsx == 0) {
|
||||
srcOffset += npixelsx / 2;
|
||||
srcOffset2 += npixelsx / 2;
|
||||
}
|
||||
// skip the other half (2 packets in 1 line for
|
||||
// 32 bit)
|
||||
else {
|
||||
srcOffset += npixelsx;
|
||||
srcOffset2 += npixelsx;
|
||||
}
|
||||
dstOffset += npixelsx / 2;
|
||||
dstOffset2 += npixelsx / 2;
|
||||
} else {
|
||||
memcpy(packetData + dstOffset,
|
||||
imageData + srcOffset, npixelsx);
|
||||
memcpy(packetData2 + dstOffset2,
|
||||
imageData + srcOffset2, npixelsx);
|
||||
srcOffset += 2 * npixelsx;
|
||||
srcOffset2 += 2 * npixelsx;
|
||||
dstOffset += npixelsx;
|
||||
dstOffset2 += npixelsx;
|
||||
}
|
||||
}
|
||||
usleep(eiger_virtual_transmission_delay_left);
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
usleep(eiger_virtual_transmission_delay_right);
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
usleep(eiger_virtual_transmission_delay_left);
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
usleep(eiger_virtual_transmission_delay_right);
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", iframes));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
@@ -2243,30 +2199,25 @@ void *start_timer(void *arg) {
|
||||
closeUDPSocket(0);
|
||||
closeUDPSocket(1);
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int stopStateMachine() {
|
||||
LOG(logINFORED, ("Going to stop acquisition\n"));
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while (tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
LOG(logINFORED, ("Stopping state machine\n"));
|
||||
// if scan active, stop scan
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
sharedMemory_setScanStop(1);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(1);
|
||||
// read till status is idle
|
||||
while (sharedMemory_getStatus() == RUNNING)
|
||||
;
|
||||
sharedMemory_setStop(0);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
return OK;
|
||||
#else
|
||||
if ((Feb_Control_StopAcquisition() != STATUS_IDLE) ||
|
||||
@@ -2309,10 +2260,6 @@ int startReadOut() {
|
||||
if ((ret_val = (!Beb_RequestNImages(beb_num, send_to_ten_gig, on_dst,
|
||||
nimages_per_request, 0))))
|
||||
break;
|
||||
// for(i=0;i<nimages_per_request;i++)
|
||||
// if ((ret_val =
|
||||
//(!Beb_RequestNImages(beb_num,send_to_ten_gig,on_dst,1,0))))
|
||||
// break;
|
||||
|
||||
dst_requested[on_dst++] = 0;
|
||||
on_dst %= ndsts_in_use;
|
||||
@@ -2326,19 +2273,24 @@ int startReadOut() {
|
||||
}
|
||||
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
// scan error or running
|
||||
if (sharedMemory_getScanStatus() == ERROR) {
|
||||
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||
return ERROR;
|
||||
}
|
||||
if (virtual_status == 0) {
|
||||
LOG(logINFO, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
} else {
|
||||
LOG(logINFO, ("Status: RUNNING...\n"));
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (sharedMemory_getStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
#else
|
||||
|
||||
int i = Feb_Control_AcquisitionInProgress();
|
||||
if (i == STATUS_ERROR) {
|
||||
LOG(logERROR, ("Status: ERROR reading status register\n"));
|
||||
@@ -2363,7 +2315,7 @@ enum runStatus getRunStatus() {
|
||||
void readFrame(int *ret, char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
// wait for status to be done
|
||||
while (virtual_status == 1) {
|
||||
while (sharedMemory_getStatus() == RUNNING) {
|
||||
usleep(500);
|
||||
}
|
||||
LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||
@@ -2377,16 +2329,6 @@ void readFrame(int *ret, char *mess) {
|
||||
}
|
||||
LOG(logINFOGREEN, ("Acquisition finished\n"));
|
||||
|
||||
if (eiger_storeinmem) {
|
||||
LOG(logINFO, ("requesting images after storing in memory\n"));
|
||||
if (startReadOut() == FAIL) {
|
||||
strcpy(mess, "Could not execute read image requests\n");
|
||||
LOG(logERROR, (mess));
|
||||
*ret = (int)FAIL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// wait for detector to send
|
||||
int isTransmitting = 1;
|
||||
while (isTransmitting) {
|
||||
@@ -2407,10 +2349,6 @@ void readFrame(int *ret, char *mess) {
|
||||
/* common */
|
||||
|
||||
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
|
||||
int idac, ichan;
|
||||
int ret = OK;
|
||||
|
||||
LOG(logDEBUG1, ("Copying module\n"));
|
||||
|
||||
if (srcMod->serialnumber >= 0) {
|
||||
@@ -2445,19 +2383,19 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
LOG(logDEBUG1, ("Copying register %x (%x)\n", destMod->reg, srcMod->reg));
|
||||
|
||||
if (destMod->nchan != 0) {
|
||||
for (ichan = 0; ichan < (srcMod->nchan); ichan++) {
|
||||
for (int ichan = 0; ichan < (srcMod->nchan); ichan++) {
|
||||
if (*((srcMod->chanregs) + ichan) >= 0)
|
||||
*((destMod->chanregs) + ichan) = *((srcMod->chanregs) + ichan);
|
||||
}
|
||||
} else
|
||||
LOG(logINFO, ("Not Copying trimbits\n"));
|
||||
|
||||
for (idac = 0; idac < (srcMod->ndac); idac++) {
|
||||
for (int idac = 0; idac < (srcMod->ndac); idac++) {
|
||||
if (*((srcMod->dacs) + idac) >= 0) {
|
||||
*((destMod->dacs) + idac) = *((srcMod->dacs) + idac);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int calculateDataBytes() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION (26)
|
||||
#define IDFILECOMMAND "more /home/root/executables/detid.txt"
|
||||
#define CONFIG_FILE ("config.txt")
|
||||
#define CONFIG_FILE ("config_eiger.txt")
|
||||
#define WAIT_STOP_SERVER_START (1 * 1000 * 1000)
|
||||
|
||||
#define STATUS_IDLE 0
|
||||
@@ -12,42 +12,46 @@
|
||||
|
||||
/* Enums */
|
||||
enum DACINDEX {
|
||||
E_SVP,
|
||||
E_VTR,
|
||||
E_VRF,
|
||||
E_VRS,
|
||||
E_SVN,
|
||||
E_VSVP,
|
||||
E_VTRIM,
|
||||
E_VRPREAMP,
|
||||
E_VRSHAPER,
|
||||
E_VSVN,
|
||||
E_VTGSTV,
|
||||
E_VCMP_LL,
|
||||
E_VCMP_LR,
|
||||
E_CAL,
|
||||
E_VCAL,
|
||||
E_VCMP_RL,
|
||||
E_RXB_RB,
|
||||
E_RXB_LB,
|
||||
E_VCMP_RR,
|
||||
E_VCP,
|
||||
E_VCN,
|
||||
E_VIS,
|
||||
E_VISHAPER,
|
||||
E_VTHRESHOLD
|
||||
};
|
||||
#define DAC_NAMES \
|
||||
"VSvP", "Vtrim", "Vrpreamp", "Vrshaper", "VSvN", "Vtgstv", "Vcmp_ll", \
|
||||
"Vcmp_lr", "Vcal", "Vcmp_rl", "rxb_rb", "rxb_lb", "Vcmp_rr", "Vcp", \
|
||||
"Vcn", "Vishaper"
|
||||
#define DEFAULT_DAC_VALS \
|
||||
{ \
|
||||
0, /* SvP */ \
|
||||
2480, /* Vtr */ \
|
||||
3300, /* Vrf */ \
|
||||
1400, /* Vrs */ \
|
||||
4000, /* SvN */ \
|
||||
0, /* VSvP */ \
|
||||
2480, /* Vtrim */ \
|
||||
3300, /* Vrpreamp */ \
|
||||
1400, /* Vrshaper */ \
|
||||
4000, /* VSvN */ \
|
||||
2556, /* Vtgstv */ \
|
||||
1000, /* Vcmp_ll */ \
|
||||
1000, /* Vcmp_lr */ \
|
||||
0, /* cal */ \
|
||||
0, /* Vcal */ \
|
||||
1000, /* Vcmp_rl */ \
|
||||
1100, /* rxb_rb */ \
|
||||
1100, /* rxb_lb */ \
|
||||
1000, /* Vcmp_rr */ \
|
||||
1000, /* Vcp */ \
|
||||
2000, /* Vcn */ \
|
||||
1550 /* Vis */ \
|
||||
1550 /* Vishaper */ \
|
||||
};
|
||||
enum ADCINDEX {
|
||||
TEMP_FPGAEXT,
|
||||
@@ -99,7 +103,6 @@ enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
|
||||
#define DEFAULT_DYNAMIC_RANGE (16)
|
||||
|
||||
#define DEFAULT_PARALLEL_MODE (1)
|
||||
#define DEFAULT_READOUT_STOREINRAM_MODE (0)
|
||||
#define DEFAULT_READOUT_OVERFLOW32_MODE (0)
|
||||
#define DEFAULT_CLK_SPEED (FULL_SPEED)
|
||||
#define DEFAULT_IO_DELAY (650)
|
||||
|
||||
@@ -11,7 +11,7 @@ add_executable(gotthard2DetectorServer_virtual
|
||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||
../slsDetectorServer/src/ASIC_Driver.c
|
||||
../slsDetectorServer/src/programFpgaNios.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@@ -38,3 +38,5 @@ set_target_properties(gotthard2DetectorServer_virtual PROPERTIES
|
||||
install(TARGETS gotthard2DetectorServer_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
configure_file(config_gotthard2.txt ${CMAKE_BINARY_DIR}/bin/config_gotthard2.txt COPYONLY)
|
||||
|
||||
@@ -5,14 +5,14 @@ support_lib = ../../slsSupportLib/include/
|
||||
|
||||
CROSS = nios2-buildroot-linux-gnu-
|
||||
CC = $(CROSS)gcc
|
||||
CFLAGS += -Wall -DGOTTHARD2D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm
|
||||
CFLAGS += -Wall -std=gnu99 -DGOTTHARD2D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lrt -pthread
|
||||
PROGS = gotthard2DetectorServer
|
||||
DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)ASIC_Driver.c $(main_src)/programFpgaNios.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)ASIC_Driver.c $(main_src)/programFpgaNios.c $(main_src)/sharedMemory.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
@@ -32,6 +32,7 @@ $(PROGS): $(OBJS)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
cp config_gotthard2.txt $(DESTDIR)
|
||||
rm $(main_src)*.o
|
||||
|
||||
clean:
|
||||
|
||||
@@ -78,14 +78,11 @@
|
||||
/* Status register */
|
||||
#define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL)
|
||||
|
||||
/* Look at me read only register */
|
||||
#define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL)
|
||||
|
||||
/* System status register */
|
||||
#define SYSTEM_STATUS_REG (0x06 * REG_OFFSET + BASE_CONTROL)
|
||||
#define SYSTEM_STATUS_REG (0x05 * REG_OFFSET + BASE_CONTROL)
|
||||
|
||||
/* Config RW regiseter */
|
||||
#define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL)
|
||||
#define CONFIG_REG (0x08 * REG_OFFSET + BASE_CONTROL)
|
||||
|
||||
#define CONFIG_VETO_ENBL_OFST (0)
|
||||
#define CONFIG_VETO_ENBL_MSK (0x00000001 << CONFIG_VETO_ENBL_OFST)
|
||||
@@ -93,7 +90,7 @@
|
||||
#define CONFIG_VETO_CH_10GB_ENBL_MSK (0x00000001 << CONFIG_VETO_CH_10GB_ENBL_OFST)
|
||||
|
||||
/* Control RW register */
|
||||
#define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL)
|
||||
#define CONTROL_REG (0x09 * REG_OFFSET + BASE_CONTROL)
|
||||
|
||||
#define CONTROL_STRT_ACQSTN_OFST (0)
|
||||
#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST)
|
||||
@@ -111,12 +108,16 @@
|
||||
#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST)
|
||||
|
||||
/** DTA Offset Register */
|
||||
#define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL)
|
||||
#define DTA_OFFSET_REG (0x0A * REG_OFFSET + BASE_CONTROL)
|
||||
|
||||
/** Mask Strip Registers (40) */
|
||||
#define MASK_STRIP_START_REG (0x18 * REG_OFFSET + BASE_CONTROL)
|
||||
#define MASK_STRIP_NUM_REGS (40)
|
||||
|
||||
/* ASIC registers --------------------------------------------------*/
|
||||
|
||||
/* ASIC Config register */
|
||||
#define ASIC_CONFIG_REG (0x00 * REG_OFFSET + BASE_ASIC)
|
||||
#define ASIC_CONFIG_REG (0x00 * REG_OFFSET + BASE_ASIC)
|
||||
|
||||
#define ASIC_CONFIG_RUN_MODE_OFST (0)
|
||||
#define ASIC_CONFIG_RUN_MODE_MSK (0x00000003 << ASIC_CONFIG_RUN_MODE_OFST)
|
||||
|
||||
Binary file not shown.
@@ -7,20 +7,20 @@ vchip_ref_comp_fe -1 0x100
|
||||
vchip_cs -1 0x0D0
|
||||
|
||||
#dacs value (max 4096)
|
||||
vref_h_adc 2099
|
||||
vref_h_adc 2116
|
||||
vb_comp_fe 0
|
||||
vb_comp_adc 0
|
||||
vcom_cds 1400
|
||||
vref_rstore 640
|
||||
vcom_cds 705
|
||||
vref_rstore 205
|
||||
vb_opa_1st 0
|
||||
vref_comp_fe 0
|
||||
vcom_adc1 1400
|
||||
vref_prech 1720
|
||||
vcom_adc1 705
|
||||
vref_prech 900
|
||||
vref_l_adc 700
|
||||
vref_cds 1200
|
||||
vref_cds 600
|
||||
vb_cs 2799
|
||||
vb_opa_fd 0
|
||||
vcom_adc2 1400
|
||||
vcom_adc2 704
|
||||
|
||||
#configure adc chip index adc index value(max 0x7F)
|
||||
confadc -1 -1 0x22
|
||||
@@ -6,10 +6,10 @@
|
||||
#include "RegisterDefs.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "versionAPI.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
@@ -37,8 +37,7 @@ char initErrorMessage[MAX_STR_LENGTH];
|
||||
|
||||
#ifdef VIRTUAL
|
||||
pthread_t pthread_virtual_tid;
|
||||
int virtual_status = 0;
|
||||
int virtual_stop = 0;
|
||||
int64_t virtual_currentFrameNumber = 2;
|
||||
#endif
|
||||
|
||||
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||
@@ -57,6 +56,8 @@ int64_t numTriggersReg = 1;
|
||||
int64_t delayReg = 0;
|
||||
int64_t numBurstsReg = 1;
|
||||
int64_t burstPeriodReg = 0;
|
||||
int filter = 0;
|
||||
int cdsGain = 0;
|
||||
int detPos[2] = {};
|
||||
|
||||
int isInitCheckDone() { return initCheckDone; }
|
||||
@@ -342,10 +343,7 @@ void initStopServer() {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
sharedMemory_setStop(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -373,6 +371,8 @@ void setupDetector() {
|
||||
delayReg = 0;
|
||||
numBurstsReg = 1;
|
||||
burstPeriodReg = 0;
|
||||
filter = 0;
|
||||
cdsGain = 0;
|
||||
for (int i = 0; i < NUM_CLOCKS; ++i) {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
@@ -393,10 +393,7 @@ void setupDetector() {
|
||||
}
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
#endif
|
||||
|
||||
// pll defines
|
||||
@@ -457,6 +454,8 @@ void setupDetector() {
|
||||
return;
|
||||
}
|
||||
setBurstMode(DEFAULT_BURST_MODE);
|
||||
setFilter(DEFAULT_FILTER);
|
||||
setCDSGain(DEFAILT_CDS_GAIN);
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
|
||||
// Initialization of acquistion parameters
|
||||
@@ -486,7 +485,13 @@ int readConfigFile() {
|
||||
|
||||
usleep(INITIAL_STARTUP_WAIT);
|
||||
|
||||
FILE *fd = fopen(CONFIG_FILE, "r");
|
||||
char fname[128];
|
||||
if (getAbsPath(fname, 128, CONFIG_FILE) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// open config file
|
||||
FILE *fd = fopen(fname, "r");
|
||||
if (fd == NULL) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not open on-board detector server config file [%s].\n",
|
||||
@@ -504,7 +509,7 @@ int readConfigFile() {
|
||||
memset(line, 0, LZ);
|
||||
char command[LZ];
|
||||
|
||||
int nadcRead = 0;
|
||||
int nAdcTotal = 0;
|
||||
|
||||
// keep reading a line
|
||||
while (fgets(line, LZ, fd)) {
|
||||
@@ -618,7 +623,7 @@ int readConfigFile() {
|
||||
break;
|
||||
}
|
||||
// validations
|
||||
if (value > ASIC_ADC_MAX_VAL) {
|
||||
if (value < 0 || value > ASIC_ADC_MAX_VAL) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not configure adc from on-board server config "
|
||||
"file. Invalid value (max 0x%x). Line:[%s].\n",
|
||||
@@ -626,28 +631,23 @@ int readConfigFile() {
|
||||
break;
|
||||
}
|
||||
|
||||
int chipmin = 0;
|
||||
int chipmax = NCHIP;
|
||||
int adcmin = 0;
|
||||
int adcmax = NADC;
|
||||
|
||||
// specific chip
|
||||
if (ichip != -1) {
|
||||
chipmin = ichip;
|
||||
chipmax = ichip + 1;
|
||||
}
|
||||
// specific adc
|
||||
if (iadc != -1) {
|
||||
adcmin = iadc;
|
||||
adcmax = iadc + 1;
|
||||
if (setADCConfiguration(ichip, iadc, value) == FAIL) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not configure adc from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = chipmin; i < chipmax; ++i) {
|
||||
for (int j = adcmin; j < adcmax; ++j) {
|
||||
adcConfiguration[i][j] = (uint8_t)value;
|
||||
++nadcRead;
|
||||
}
|
||||
// to ensure all adcs are configured at start up
|
||||
int nadc = 1;
|
||||
if (iadc == -1) {
|
||||
nadc = NADC;
|
||||
}
|
||||
if (ichip == -1) {
|
||||
nadc *= NCHIP;
|
||||
}
|
||||
nAdcTotal += nadc;
|
||||
}
|
||||
|
||||
// vchip command
|
||||
@@ -763,17 +763,11 @@ int readConfigFile() {
|
||||
fclose(fd);
|
||||
|
||||
if (!strlen(initErrorMessage)) {
|
||||
if (nadcRead != NADC * NCHIP) {
|
||||
if (nAdcTotal != NADC * NCHIP) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not configure adc from on-board server config file. "
|
||||
"Insufficient adcconf commands. Read %d, expected %d\n",
|
||||
nadcRead, NADC * NCHIP);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < NCHIP; ++i) {
|
||||
for (int j = 0; j < NADC; ++j) {
|
||||
LOG(logDEBUG2,
|
||||
("adc read %d %d: 0x%02hhx\n", i, j, adcConfiguration[i][j]));
|
||||
nAdcTotal, NADC * NCHIP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1044,34 +1038,31 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
// set settings
|
||||
uint32_t addr = ASIC_CONFIG_REG;
|
||||
uint32_t mask = ASIC_CONFIG_GAIN_MSK;
|
||||
if (sett != GET_SETTINGS) {
|
||||
switch (sett) {
|
||||
case DYNAMICGAIN:
|
||||
bus_w(addr, bus_r(addr) & ~mask);
|
||||
bus_w(addr, bus_r(addr) | ASIC_CONFIG_DYNAMIC_GAIN_VAL);
|
||||
LOG(logINFO, ("Set settings - Dyanmic Gain, val: 0x%x\n",
|
||||
bus_r(addr) & mask));
|
||||
break;
|
||||
case FIXGAIN1:
|
||||
bus_w(addr, bus_r(addr) & ~mask);
|
||||
bus_w(addr, bus_r(addr) | ASIC_CONFIG_FIX_GAIN_1_VAL);
|
||||
LOG(logINFO,
|
||||
("Set settings - Fix Gain 1, val: 0x%x\n", bus_r(addr) & mask));
|
||||
break;
|
||||
case FIXGAIN2:
|
||||
bus_w(addr, bus_r(addr) & ~mask);
|
||||
bus_w(addr, bus_r(addr) | ASIC_CONFIG_FIX_GAIN_2_VAL);
|
||||
LOG(logINFO,
|
||||
("Set settings - Fix Gain 2, val: 0x%x\n", bus_r(addr) & mask));
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("This settings is not defined for this detector %d\n",
|
||||
(int)sett));
|
||||
return -1;
|
||||
}
|
||||
thisSettings = sett;
|
||||
switch (sett) {
|
||||
case DYNAMICGAIN:
|
||||
bus_w(addr, bus_r(addr) & ~mask);
|
||||
bus_w(addr, bus_r(addr) | ASIC_CONFIG_DYNAMIC_GAIN_VAL);
|
||||
LOG(logINFO,
|
||||
("Set settings - Dyanmic Gain, val: 0x%x\n", bus_r(addr) & mask));
|
||||
break;
|
||||
case FIXGAIN1:
|
||||
bus_w(addr, bus_r(addr) & ~mask);
|
||||
bus_w(addr, bus_r(addr) | ASIC_CONFIG_FIX_GAIN_1_VAL);
|
||||
LOG(logINFO,
|
||||
("Set settings - Fix Gain 1, val: 0x%x\n", bus_r(addr) & mask));
|
||||
break;
|
||||
case FIXGAIN2:
|
||||
bus_w(addr, bus_r(addr) & ~mask);
|
||||
bus_w(addr, bus_r(addr) | ASIC_CONFIG_FIX_GAIN_2_VAL);
|
||||
LOG(logINFO,
|
||||
("Set settings - Fix Gain 2, val: 0x%x\n", bus_r(addr) & mask));
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("This settings is not defined for this detector %d\n", (int)sett));
|
||||
return -1;
|
||||
}
|
||||
thisSettings = sett;
|
||||
|
||||
return getSettings();
|
||||
}
|
||||
@@ -1208,17 +1199,11 @@ int setHighVoltage(int val) {
|
||||
val = HV_SOFT_MAX_VOLTAGE;
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
if (val >= 0)
|
||||
highvoltage = val;
|
||||
return highvoltage;
|
||||
#endif
|
||||
|
||||
// setting hv
|
||||
if (val >= 0) {
|
||||
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
||||
DAC6571_Set(val);
|
||||
highvoltage = val;
|
||||
if (DAC6571_Set(val) == OK)
|
||||
highvoltage = val;
|
||||
}
|
||||
return highvoltage;
|
||||
}
|
||||
@@ -1726,7 +1711,7 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
}
|
||||
|
||||
// phase is reset by pll (when setting output frequency)
|
||||
if (ind >= READOUT_C0) {
|
||||
if (ind < SYSTEM_C0) {
|
||||
clkPhase[READOUT_C0] = 0;
|
||||
clkPhase[READOUT_C1] = 0;
|
||||
} else {
|
||||
@@ -1813,29 +1798,31 @@ int setVetoPhoton(int chipIndex, int gainIndex, int *values) {
|
||||
("Setting veto photon [chip:%d, G%d]\n", chipIndex, gainIndex));
|
||||
|
||||
// add gain bits
|
||||
{
|
||||
int gainValue = 0;
|
||||
switch (gainIndex) {
|
||||
case 0:
|
||||
gainValue = ASIC_G0_VAL;
|
||||
break;
|
||||
case 1:
|
||||
gainValue = ASIC_G1_VAL;
|
||||
break;
|
||||
case 2:
|
||||
gainValue = ASIC_G2_VAL;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Unknown gain index %d\n", gainIndex));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG2, ("Adding gain bits\n"));
|
||||
for (int i = 0; i < NCHAN; ++i) {
|
||||
values[i] |= gainValue;
|
||||
LOG(logDEBUG2, ("Value %d: 0x%x\n", i, values[i]));
|
||||
}
|
||||
int gainValue = 0;
|
||||
switch (gainIndex) {
|
||||
case 0:
|
||||
gainValue = ASIC_G0_VAL;
|
||||
break;
|
||||
case 1:
|
||||
gainValue = ASIC_G1_VAL;
|
||||
break;
|
||||
case 2:
|
||||
gainValue = ASIC_G2_VAL;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Unknown gain index %d\n", gainIndex));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG2, ("Adding gain bits\n"));
|
||||
for (int i = 0; i < NCHAN; ++i) {
|
||||
values[i] |= gainValue;
|
||||
LOG(logDEBUG2, ("Value %d: 0x%x\n", i, values[i]));
|
||||
}
|
||||
|
||||
return configureASICVetoReference(chipIndex, values);
|
||||
}
|
||||
|
||||
int configureASICVetoReference(int chipIndex, int *values) {
|
||||
const int lenDataBitsPerchannel = ASIC_GAIN_MAX_BITS + ADU_MAX_BITS; // 14
|
||||
const int lenBits = lenDataBitsPerchannel * NCHAN; // 1792
|
||||
const int padding = 4; // due to address (4) to make it byte aligned
|
||||
@@ -1848,8 +1835,7 @@ int setVetoPhoton(int chipIndex, int gainIndex, int *values) {
|
||||
int offset = padding; // bit offset for commandbytes
|
||||
for (int ich = 0; ich < NCHAN; ++ich) {
|
||||
// loop through all bits in a value
|
||||
int iBit = 0;
|
||||
for (iBit = 0; iBit < lenDataBitsPerchannel; ++iBit) {
|
||||
for (int iBit = 0; iBit < lenDataBitsPerchannel; ++iBit) {
|
||||
commandBytes[offset++] =
|
||||
((values[ich] >> (lenDataBitsPerchannel - 1 - iBit)) & 0x1);
|
||||
}
|
||||
@@ -1917,24 +1903,78 @@ int getVetoPhoton(int chipIndex, int *retvals) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int configureSingleADCDriver(int chipIndex) {
|
||||
LOG(logINFO, ("Configuring ADC for %s chips [chipIndex:%d Burst Mode:%d]\n",
|
||||
chipIndex == -1 ? "All" : "Single", chipIndex, burstMode));
|
||||
int setVetoFile(int chipIndex, int *gainIndices, int *values) {
|
||||
LOG(logINFO, ("Setting veto file [chip:%d]\n", chipIndex));
|
||||
|
||||
// correct gain bits and integrate into values
|
||||
for (int i = 0; i < NCHAN; ++i) {
|
||||
switch (gainIndices[i]) {
|
||||
case 0:
|
||||
gainIndices[i] = ASIC_G0_VAL;
|
||||
break;
|
||||
case 1:
|
||||
gainIndices[i] = ASIC_G1_VAL;
|
||||
break;
|
||||
case 2:
|
||||
gainIndices[i] = ASIC_G2_VAL;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("Unknown gain index %d for channel %d\n", gainIndices[i], i));
|
||||
return FAIL;
|
||||
}
|
||||
values[i] |= gainIndices[i];
|
||||
LOG(logDEBUG2, ("Values[%d]: 0x%x\n", i, values[i]));
|
||||
}
|
||||
return configureASICVetoReference(chipIndex, values);
|
||||
}
|
||||
|
||||
int setADCConfiguration(int chipIndex, int adcIndex, int value) {
|
||||
LOG(logINFO, ("Configuring ADC [chipIndex:%d, adcIndex:%d, value:0x%x]\n",
|
||||
chipIndex, adcIndex, value));
|
||||
|
||||
// validations
|
||||
if (chipIndex < -1 || chipIndex >= NCHIP) {
|
||||
LOG(logERROR, ("Invalid chip index %d\n", chipIndex));
|
||||
return FAIL;
|
||||
}
|
||||
if (adcIndex < -1 || adcIndex >= NADC) {
|
||||
LOG(logERROR, ("Invalid adc index %d\n", adcIndex));
|
||||
return FAIL;
|
||||
}
|
||||
// validations
|
||||
if (value < 0 || value > ASIC_ADC_MAX_VAL) {
|
||||
LOG(logERROR, ("Invalid value 0x%x\n", value));
|
||||
return FAIL;
|
||||
}
|
||||
int chipmin = 0;
|
||||
int chipmax = NCHIP;
|
||||
int adcmin = 0;
|
||||
int adcmax = NADC;
|
||||
// specific chip
|
||||
if (chipIndex != -1) {
|
||||
chipmin = chipIndex;
|
||||
chipmax = chipIndex + 1;
|
||||
}
|
||||
// specific adc
|
||||
if (adcIndex != -1) {
|
||||
adcmin = adcIndex;
|
||||
adcmax = adcIndex + 1;
|
||||
}
|
||||
// update values
|
||||
for (int i = chipmin; i < chipmax; ++i) {
|
||||
for (int j = adcmin; j < adcmax; ++j) {
|
||||
adcConfiguration[i][j] = (uint8_t)value;
|
||||
LOG(logDEBUG1,
|
||||
("Value [%d][%d]: 0x%02hhx\n", i, j, adcConfiguration[i][j]));
|
||||
}
|
||||
}
|
||||
// single chip configuration
|
||||
int ind = chipIndex;
|
||||
// all chips, take the first one as all equal
|
||||
if (ind == -1) {
|
||||
ind = 0;
|
||||
}
|
||||
uint8_t values[NADC];
|
||||
memcpy(values, adcConfiguration + ind * NADC, NADC);
|
||||
|
||||
// change adc values if continuous mode
|
||||
for (int i = 0; i < NADC; ++i) {
|
||||
if (burstMode == BURST_OFF) {
|
||||
values[i] |= ASIC_CONTINUOUS_MODE_MSK;
|
||||
}
|
||||
LOG(logDEBUG2, ("Value %d: 0x%02hhx\n", i, values[i]));
|
||||
}
|
||||
|
||||
const int lenDataBitsPerADC = ASIC_ADC_MAX_BITS; // 7
|
||||
const int lenBits = lenDataBitsPerADC * NADC; // 224
|
||||
@@ -1949,8 +1989,9 @@ int configureSingleADCDriver(int chipIndex) {
|
||||
for (int ich = 0; ich < NADC; ++ich) {
|
||||
// loop through all bits in a value
|
||||
for (int iBit = 0; iBit < lenDataBitsPerADC; ++iBit) {
|
||||
commandBytes[offset++] =
|
||||
((values[ich] >> (lenDataBitsPerADC - 1 - iBit)) & 0x1);
|
||||
commandBytes[offset++] = ((adcConfiguration[ind][ich] >>
|
||||
(lenDataBitsPerADC - 1 - iBit)) &
|
||||
0x1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1977,29 +2018,46 @@ int configureSingleADCDriver(int chipIndex) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int configureADC() {
|
||||
LOG(logINFO, ("Configuring ADC \n"));
|
||||
int getADCConfiguration(int chipIndex, int adcIndex) {
|
||||
// already validated at tcp interface
|
||||
if (chipIndex < -1 || chipIndex >= NCHIP) {
|
||||
LOG(logERROR, ("Invalid chip index %d\n", chipIndex));
|
||||
return -1;
|
||||
}
|
||||
if (adcIndex < -1 || adcIndex >= NADC) {
|
||||
LOG(logERROR, ("Invalid adc index %d\n", adcIndex));
|
||||
return -1;
|
||||
}
|
||||
int chipmin = 0;
|
||||
int chipmax = NCHIP;
|
||||
int adcmin = 0;
|
||||
int adcmax = NADC;
|
||||
// specific chip
|
||||
if (chipIndex != -1) {
|
||||
chipmin = chipIndex;
|
||||
chipmax = chipIndex + 1;
|
||||
}
|
||||
// specific adc
|
||||
if (adcIndex != -1) {
|
||||
adcmin = adcIndex;
|
||||
adcmax = adcIndex + 1;
|
||||
}
|
||||
int val = adcConfiguration[chipmin][adcmin];
|
||||
|
||||
int equal = 1;
|
||||
for (int i = 0; i < NADC; ++i) {
|
||||
int val = adcConfiguration[0][i];
|
||||
for (int j = 1; j < NCHIP; ++j) {
|
||||
if (adcConfiguration[j][i] != val) {
|
||||
equal = 0;
|
||||
break;
|
||||
// ensure same values for chip and adc in question
|
||||
for (int i = chipmin; i < chipmax; ++i) {
|
||||
for (int j = adcmin; j < adcmax; ++j) {
|
||||
if (adcConfiguration[i][j] != val) {
|
||||
LOG(logINFO,
|
||||
("\tADC configuration 0x%x at [%d][%d] differs from 0x%x "
|
||||
"at "
|
||||
"[%d][%d], returning -1\n",
|
||||
adcConfiguration[i][j], i, j, val, chipmin, adcmin));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (equal) {
|
||||
return configureSingleADCDriver(-1);
|
||||
} else {
|
||||
for (int i = 0; i < NCHIP; ++i) {
|
||||
if (configureSingleADCDriver(i) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
return val;
|
||||
}
|
||||
|
||||
int setBurstModeinFPGA(enum burstMode value) {
|
||||
@@ -2104,10 +2162,20 @@ int setBurstMode(enum burstMode burst) {
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("\tDone Updating registers\n"))
|
||||
return configureASICGlobalSettings();
|
||||
}
|
||||
|
||||
LOG(logINFO, ("\tSetting %s Mode in Chip\n",
|
||||
burstMode == BURST_OFF ? "Continuous" : "Burst"));
|
||||
int value = burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
|
||||
int configureASICGlobalSettings() {
|
||||
int modeValue =
|
||||
burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
|
||||
int value = ((modeValue << ASIC_GLOBAL_MODE_OFST) & ASIC_GLOBAL_MODE_MSK) |
|
||||
((filter << ASIC_FILTER_OFST) & ASIC_FILTER_MSK) |
|
||||
((cdsGain << ASIC_CDS_GAIN_OFST) & ASIC_CDS_GAIN_MSK);
|
||||
LOG(logINFO,
|
||||
("\tSending Global Chip settings:0x%x (mode:%d(%s), filter:%d, "
|
||||
"cdsgain:%d)\n",
|
||||
value, modeValue, (burstMode == BURST_OFF ? "Continuous" : "Burst"),
|
||||
filter, cdsGain));
|
||||
|
||||
const int padding = 6; // due to address (4) to make it byte aligned
|
||||
const int lenTotalBits = padding + ASIC_GLOBAL_SETT_MAX_BITS +
|
||||
@@ -2145,7 +2213,7 @@ int setBurstMode(enum burstMode burst) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
return configureADC();
|
||||
return OK;
|
||||
}
|
||||
|
||||
enum burstMode getBurstMode() {
|
||||
@@ -2168,6 +2236,30 @@ enum burstMode getBurstMode() {
|
||||
return burstMode;
|
||||
}
|
||||
|
||||
int setCDSGain(int enable) {
|
||||
if (enable >= 0) {
|
||||
cdsGain = (enable == 0 ? 0 : 1);
|
||||
LOG(logINFO,
|
||||
("%s CDS Gain\n", (cdsGain == 0 ? "Disabling" : "Enabling")));
|
||||
return configureASICGlobalSettings();
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int getCDSGain() { return cdsGain; }
|
||||
|
||||
int setFilter(int value) {
|
||||
if (value < 0 || value > ASIC_FILTER_MAX_VALUE) {
|
||||
LOG(logERROR, ("Invalid filter value %d\n", value));
|
||||
return FAIL;
|
||||
}
|
||||
filter = value;
|
||||
LOG(logINFO, ("Setting Filter to %d\n", filter));
|
||||
return configureASICGlobalSettings();
|
||||
}
|
||||
|
||||
int getFilter() { return filter; }
|
||||
|
||||
void setCurrentSource(int value) {
|
||||
uint32_t addr = ASIC_CONFIG_REG;
|
||||
if (value > 0) {
|
||||
@@ -2230,6 +2322,72 @@ int getVeto() {
|
||||
CONFIG_VETO_ENBL_OFST);
|
||||
}
|
||||
|
||||
void setBadChannels(int nch, int *channels) {
|
||||
LOG(logINFO, ("Setting %d bad channels\n", nch));
|
||||
|
||||
int numAddr = MASK_STRIP_NUM_REGS;
|
||||
int startAddr = MASK_STRIP_START_REG;
|
||||
|
||||
// resetting all mask registers first
|
||||
for (int iaddr = 0; iaddr < numAddr; ++iaddr) {
|
||||
uint32_t addr = startAddr + iaddr * REG_OFFSET;
|
||||
bus_w(addr, 0);
|
||||
}
|
||||
|
||||
// setting badchannels, loop through list
|
||||
for (int i = 0; i < nch; ++i) {
|
||||
LOG(logINFO, ("\t[%d]: %d\n", i, channels[i]));
|
||||
int iaddr = channels[i] / 32;
|
||||
int iBit = channels[i] % 32;
|
||||
uint32_t addr = startAddr + iaddr * REG_OFFSET;
|
||||
LOG(logDEBUG1,
|
||||
("val:%d iaddr:%d iBit:%d, addr:0x%x old:0x%x val:0x%x\n",
|
||||
channels[i], iaddr, iBit, addr, bus_r(addr), (1 << iBit)));
|
||||
bus_w(addr, bus_r(addr) | (1 << iBit));
|
||||
}
|
||||
}
|
||||
|
||||
int *getBadChannels(int *nch) {
|
||||
int *retvals = NULL;
|
||||
// count number of bad channels
|
||||
*nch = 0;
|
||||
for (int i = 0; i < MASK_STRIP_NUM_REGS; ++i) {
|
||||
uint32_t addr = MASK_STRIP_START_REG + i * REG_OFFSET;
|
||||
*nch += __builtin_popcount(bus_r(addr));
|
||||
}
|
||||
if (*nch > 0) {
|
||||
// get list of bad channels
|
||||
retvals = malloc(*nch * sizeof(int));
|
||||
if (retvals == NULL) {
|
||||
*nch = -1;
|
||||
return NULL;
|
||||
}
|
||||
int chIndex = 0;
|
||||
int numAddr = MASK_STRIP_NUM_REGS;
|
||||
// loop through registers
|
||||
for (int iaddr = 0; iaddr < numAddr; ++iaddr) {
|
||||
// calculate address and get value
|
||||
uint32_t addr = MASK_STRIP_START_REG + iaddr * REG_OFFSET;
|
||||
uint32_t val = bus_r(addr);
|
||||
// loop through 32 bits
|
||||
for (int iBit = 0; iBit < 32; ++iBit) {
|
||||
// masked, add to list
|
||||
if ((val >> iBit) & 0x1) {
|
||||
LOG(logDEBUG1, ("iaddr:%d iBit:%d val:0x%x, ch:%d\n", iaddr,
|
||||
iBit, val, iaddr * 32 + iBit));
|
||||
retvals[chIndex++] = iaddr * 32 + iBit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// debugging
|
||||
LOG(logDEBUG1, ("Reading Bad channel list\n"));
|
||||
for (int i = 0; i < (*nch); ++i) {
|
||||
LOG(logDEBUG1, ("[%d]: %d\n", i, retvals[i]));
|
||||
}
|
||||
return retvals;
|
||||
}
|
||||
|
||||
/* aquisition */
|
||||
|
||||
int startStateMachine() {
|
||||
@@ -2244,22 +2402,15 @@ int startStateMachine() {
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
// set status to running
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (sharedMemory_getStop() != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_setStatus(RUNNING);
|
||||
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@@ -2314,86 +2465,80 @@ void *start_timer(void *arg) {
|
||||
*((uint16_t *)(vetoData + i)) = i;
|
||||
}
|
||||
|
||||
{
|
||||
int frameHeaderNr = 0;
|
||||
// loop over number of repeats
|
||||
for (int repeatNr = 0; repeatNr != numRepeats; ++repeatNr) {
|
||||
// loop over number of repeats
|
||||
for (int repeatNr = 0; repeatNr != numRepeats; ++repeatNr) {
|
||||
|
||||
struct timespec rbegin, rend;
|
||||
clock_gettime(CLOCK_REALTIME, &rbegin);
|
||||
struct timespec rbegin, rend;
|
||||
clock_gettime(CLOCK_REALTIME, &rbegin);
|
||||
|
||||
// loop over number of frames
|
||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
// loop over number of frames
|
||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
// check if virtual_stop is high
|
||||
if (virtual_stop == 1) {
|
||||
break;
|
||||
}
|
||||
// check if manual stop
|
||||
if (sharedMemory_getStop() == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
// first interface
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
// first interface
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
// set header
|
||||
sls_detector_header *header = (sls_detector_header *)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = virtual_currentFrameNumber;
|
||||
header->packetNumber = 0;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData,
|
||||
datasize);
|
||||
// send 1 packet = 1 frame
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
|
||||
// second interface (veto)
|
||||
char packetData2[vetopacketsize];
|
||||
memset(packetData2, 0, vetopacketsize);
|
||||
if (vetoEnabled && numInterfaces == 2) {
|
||||
// set header
|
||||
sls_detector_header *header =
|
||||
(sls_detector_header *)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameHeaderNr;
|
||||
header->packetNumber = 0;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
veto_header *header = (veto_header *)(packetData2);
|
||||
header->frameNumber = virtual_currentFrameNumber;
|
||||
header->bunchId = 0;
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData,
|
||||
datasize);
|
||||
memcpy(packetData2 + sizeof(veto_header), vetoData,
|
||||
vetodatasize);
|
||||
// send 1 packet = 1 frame
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
sendUDPPacket(1, packetData2, vetopacketsize);
|
||||
}
|
||||
LOG(logINFO,
|
||||
("Sent frame: %d (bursts: %d) [%lld]\n", frameNr, repeatNr,
|
||||
(long long unsigned int)virtual_currentFrameNumber));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// second interface (veto)
|
||||
char packetData2[vetopacketsize];
|
||||
memset(packetData2, 0, vetopacketsize);
|
||||
if (vetoEnabled && numInterfaces == 2) {
|
||||
// set header
|
||||
veto_header *header = (veto_header *)(packetData2);
|
||||
header->frameNumber = frameHeaderNr;
|
||||
header->bunchId = 0;
|
||||
// fill data
|
||||
memcpy(packetData2 + sizeof(veto_header), vetoData,
|
||||
vetodatasize);
|
||||
// send 1 packet = 1 frame
|
||||
sendUDPPacket(1, packetData2, vetopacketsize);
|
||||
}
|
||||
++frameHeaderNr;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
LOG(logINFO,
|
||||
("Sent frame: %d (bursts: %d)\n", frameNr, repeatNr));
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs) / 1000);
|
||||
}
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs) / 1000);
|
||||
}
|
||||
}
|
||||
clock_gettime(CLOCK_REALTIME, &rend);
|
||||
int64_t timeNs = ((rend.tv_sec - rbegin.tv_sec) * 1E9 +
|
||||
(rend.tv_nsec - rbegin.tv_nsec));
|
||||
++virtual_currentFrameNumber;
|
||||
}
|
||||
clock_gettime(CLOCK_REALTIME, &rend);
|
||||
int64_t timeNs = ((rend.tv_sec - rbegin.tv_sec) * 1E9 +
|
||||
(rend.tv_nsec - rbegin.tv_nsec));
|
||||
|
||||
// sleep for (repeatPeriodNs - time remaining)
|
||||
if (repeatNr < numRepeats) { // if there is a next repeat
|
||||
if (repeatPeriodNs > timeNs) {
|
||||
usleep((repeatPeriodNs - timeNs) / 1000);
|
||||
}
|
||||
// sleep for (repeatPeriodNs - time remaining)
|
||||
if (repeatNr < numRepeats) { // if there is a next repeat
|
||||
if (repeatPeriodNs > timeNs) {
|
||||
usleep((repeatPeriodNs - timeNs) / 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2403,10 +2548,7 @@ void *start_timer(void *arg) {
|
||||
closeUDPSocket(1);
|
||||
}
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@@ -2414,19 +2556,16 @@ void *start_timer(void *arg) {
|
||||
|
||||
int stopStateMachine() {
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while (tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
// if scan active, stop scan
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
sharedMemory_setScanStop(1);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(1);
|
||||
while (sharedMemory_getStatus() == RUNNING)
|
||||
;
|
||||
sharedMemory_setStop(0);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
return OK;
|
||||
#endif
|
||||
// stop state machine
|
||||
@@ -2436,19 +2575,24 @@ int stopStateMachine() {
|
||||
}
|
||||
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
// scan error or running
|
||||
if (sharedMemory_getScanStatus() == ERROR) {
|
||||
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||
return ERROR;
|
||||
}
|
||||
if (virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
} else {
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (sharedMemory_getStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
uint32_t retval = bus_r(FLOW_STATUS_REG);
|
||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||
|
||||
@@ -2515,10 +2659,7 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||
#endif
|
||||
u_int32_t s = (bus_r(FLOW_STATUS_REG) & FLOW_STATUS_RUN_BUSY_MSK);
|
||||
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||
@@ -2534,4 +2675,4 @@ int getTotalNumberOfChannels() {
|
||||
}
|
||||
int getNumberOfChips() { return NCHIP; }
|
||||
int getNumberOfDACs() { return NDAC; }
|
||||
int getNumberOfChannelsPerChip() { return NCHAN; }
|
||||
int getNumberOfChannelsPerChip() { return NCHAN; }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#define REQRD_FRMWRE_VRSN (0x190000)
|
||||
#define REQRD_FRMWRE_VRSN (0x200707)
|
||||
|
||||
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
||||
|
||||
@@ -18,19 +18,21 @@
|
||||
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
|
||||
#define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac")
|
||||
#define TYPE_FILE_NAME ("/etc/devlinks/type")
|
||||
#define CONFIG_FILE ("config.txt")
|
||||
#define CONFIG_FILE ("config_gotthard2.txt")
|
||||
#define DAC_MAX_MV (2048)
|
||||
#define ONCHIP_DAC_MAX_VAL (0x3FF)
|
||||
#define ADU_MAX_VAL (0xFFF)
|
||||
#define ADU_MAX_BITS (12)
|
||||
#define MAX_FRAMES_IN_BURST_MODE (2720)
|
||||
#define TYPE_GOTTHARD2_MODULE_VAL (512)
|
||||
#define TYPE_GOTTHARD2_MODULE_VAL (536)
|
||||
#define TYPE_TOLERANCE (10)
|
||||
#define TYPE_NO_MODULE_STARTING_VAL (800)
|
||||
#define INITIAL_STARTUP_WAIT (1 * 1000 * 1000)
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_BURST_MODE (BURST_INTERNAL)
|
||||
#define DEFAULT_FILTER (0)
|
||||
#define DEFAILT_CDS_GAIN (0)
|
||||
#define DEFAULT_NUM_FRAMES (1)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
#define DEFAULT_NUM_BURSTS (1)
|
||||
@@ -135,7 +137,14 @@ enum PLLINDEX { READOUT_PLL, SYSTEM_PLL };
|
||||
#define ASIC_ADC_MAX_VAL (0x7F)
|
||||
#define ASIC_GLOBAL_SETT_MAX_BITS (6)
|
||||
#define ASIC_GLOBAL_BURST_VALUE (0x0)
|
||||
#define ASIC_GLOBAL_CONT_VALUE (0x1E)
|
||||
#define ASIC_GLOBAL_CONT_VALUE (0x6)
|
||||
#define ASIC_GLOBAL_MODE_OFST (0)
|
||||
#define ASIC_GLOBAL_MODE_MSK (0x7 << ASIC_GLOBAL_MODE_OFST)
|
||||
#define ASIC_FILTER_OFST (3)
|
||||
#define ASIC_FILTER_MSK (0x3 << ASIC_FILTER_OFST)
|
||||
#define ASIC_FILTER_MAX_VALUE (3)
|
||||
#define ASIC_CDS_GAIN_OFST (5)
|
||||
#define ASIC_CDS_GAIN_MSK (0x1 << ASIC_CDS_GAIN_OFST)
|
||||
|
||||
/* Struct Definitions */
|
||||
typedef struct udp_header_struct {
|
||||
@@ -161,4 +170,4 @@ typedef struct udp_header_struct {
|
||||
uint16_t udp_destport;
|
||||
} udp_header;
|
||||
#define IP_HEADER_SIZE (20)
|
||||
#define UDP_IP_HEADER_LENGTH_BYTES (28)
|
||||
#define UDP_IP_HEADER_LENGTH_BYTES (28)
|
||||
|
||||
@@ -10,7 +10,7 @@ add_executable(gotthardDetectorServer_virtual
|
||||
../slsDetectorServer/src/common.c
|
||||
../slsDetectorServer/src/commonServerFunctions.c
|
||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@@ -37,3 +37,5 @@ set_target_properties(gotthardDetectorServer_virtual PROPERTIES
|
||||
install(TARGETS gotthardDetectorServer_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
configure_file(config_gotthard.txt ${CMAKE_BINARY_DIR}/bin/config_gotthard.txt COPYONLY)
|
||||
@@ -5,14 +5,14 @@ support_lib = ../../slsSupportLib/include/
|
||||
|
||||
CROSS = bfin-uclinux-
|
||||
CC = $(CROSS)gcc
|
||||
CFLAGS += -Wall -DGOTTHARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm
|
||||
CFLAGS += -Wall -std=gnu99 -DGOTTHARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lrt -pthread
|
||||
PROGS = gotthardDetectorServer
|
||||
DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)AD9252.c $(main_src)AD9257.c $(main_src)LTC2620.c $(main_src)common.c $(main_src)commonServerFunctions.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)AD9252.c $(main_src)AD9257.c $(main_src)LTC2620.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)/sharedMemory.c
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
all: clean $(PROGS)
|
||||
@@ -31,6 +31,7 @@ $(PROGS): $(OBJS)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
cp config_gotthard.txt $(DESTDIR)
|
||||
rm *.gdb
|
||||
rm $(main_src)*.o
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,12 +1,13 @@
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "RegisterDefs.h"
|
||||
#include "clogger.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "versionAPI.h"
|
||||
#include "common.h"
|
||||
|
||||
#include "LTC2620.h" // dacs
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include "string.h"
|
||||
@@ -34,9 +35,8 @@ char initErrorMessage[MAX_STR_LENGTH];
|
||||
|
||||
#ifdef VIRTUAL
|
||||
pthread_t pthread_virtual_tid;
|
||||
int virtual_status = 0;
|
||||
int virtual_stop = 0;
|
||||
int highvoltage = 0;
|
||||
int64_t virtual_currentFrameNumber = 2;
|
||||
#endif
|
||||
int detPos[2] = {};
|
||||
|
||||
@@ -167,8 +167,7 @@ int testFpga() {
|
||||
u_int32_t addr = DUMMY_REG;
|
||||
volatile u_int32_t val = 0, readval = 0;
|
||||
int times = 1000 * 1000;
|
||||
int i = 0;
|
||||
for (i = 0; i < times; ++i) {
|
||||
for (int i = 0; i < times; ++i) {
|
||||
val = 0x5A5A5A5A - i;
|
||||
bus_w(addr, val);
|
||||
readval = bus_r(addr);
|
||||
@@ -226,9 +225,8 @@ int testBus() {
|
||||
u_int32_t addr = DUMMY_REG;
|
||||
volatile u_int32_t val = 0, readval = 0;
|
||||
int times = 1000 * 1000;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < times; ++i) {
|
||||
for (int i = 0; i < times; ++i) {
|
||||
val += 0xbbbbb;
|
||||
bus_w(addr, val);
|
||||
readval = bus_r(addr);
|
||||
@@ -358,10 +356,7 @@ void initStopServer() {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
sharedMemory_setStop(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -371,10 +366,7 @@ void setupDetector() {
|
||||
LOG(logINFO, ("This Server is for 1 Gotthard module (1280 channels)\n"));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
#endif
|
||||
|
||||
// Initialization
|
||||
@@ -436,14 +428,11 @@ void setupDetector() {
|
||||
int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
{
|
||||
int i = 0;
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (i = 0; i < NDAC; ++i) {
|
||||
// if not already default, set it to default
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
}
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
// if not already default, set it to default
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -477,8 +466,7 @@ void setPhaseShiftOnce() {
|
||||
detectorFirstServer = 1;
|
||||
LOG(logINFO,
|
||||
("Implementing the first phase shift of %d\n", phaseShift));
|
||||
int times = 0;
|
||||
for (times = 1; times < phaseShift; ++times) {
|
||||
for (int times = 1; times < phaseShift; ++times) {
|
||||
bus_w(addr, (INT_RSTN_MSK | ENT_RSTN_MSK | SW1_MSK |
|
||||
PHS_STP_MSK)); // 0x1821
|
||||
bus_w(addr, (INT_RSTN_MSK | ENT_RSTN_MSK |
|
||||
@@ -495,8 +483,7 @@ void setPhaseShift(int numphaseshift) {
|
||||
|
||||
volatile u_int32_t val = bus_r(addr);
|
||||
LOG(logDEBUG1, ("Multipurpose reg: 0x%x\n", val));
|
||||
int times = 0;
|
||||
for (times = 1; times < numphaseshift; ++times) {
|
||||
for (int times = 1; times < numphaseshift; ++times) {
|
||||
bus_w(addr, val | PHS_STP_MSK);
|
||||
bus_w(addr, val & (~PHS_STP_MSK));
|
||||
}
|
||||
@@ -591,10 +578,15 @@ void setGbitReadout() {
|
||||
}
|
||||
|
||||
int readConfigFile() {
|
||||
char fname[128];
|
||||
if (getAbsPath(fname, 128, CONFIG_FILE) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// open config file
|
||||
FILE *fd = fopen(CONFIG_FILE, "r");
|
||||
FILE *fd = fopen(fname, "r");
|
||||
if (fd == NULL) {
|
||||
LOG(logWARNING, ("\tCould not find config file %s\n", CONFIG_FILE));
|
||||
LOG(logWARNING, ("Could not find config file %s\n", CONFIG_FILE));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tConfig file %s opened\n", CONFIG_FILE));
|
||||
@@ -947,75 +939,51 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
setSettings((enum detectorSettings)myMod.reg);
|
||||
|
||||
// set dac values
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < NDAC; ++i)
|
||||
setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
|
||||
}
|
||||
for (int i = 0; i < NDAC; ++i)
|
||||
setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModule(sls_detector_module *myMod) {
|
||||
int idac = 0;
|
||||
for (idac = 0; idac < NDAC; ++idac) {
|
||||
if (dacValues[idac] >= 0)
|
||||
*((myMod->dacs) + idac) = dacValues[idac];
|
||||
}
|
||||
// check if all of them are not initialized
|
||||
int initialized = 0;
|
||||
for (idac = 0; idac < NDAC; ++idac) {
|
||||
if (dacValues[idac] >= 0)
|
||||
initialized = 1;
|
||||
}
|
||||
if (initialized) {
|
||||
return OK;
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
if (sett == UNINITIALIZED)
|
||||
return thisSettings;
|
||||
|
||||
// set settings
|
||||
if (sett != GET_SETTINGS) {
|
||||
u_int32_t addr = GAIN_REG;
|
||||
u_int32_t addr = GAIN_REG;
|
||||
|
||||
// find conf gain value
|
||||
uint32_t confgain = 0x0;
|
||||
switch (sett) {
|
||||
case DYNAMICGAIN:
|
||||
LOG(logINFO, ("Set settings - Dyanmic Gain\n"));
|
||||
confgain = GAIN_CONFGAIN_DYNMC_GAIN_VAL;
|
||||
break;
|
||||
case HIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - High Gain\n"));
|
||||
confgain = GAIN_CONFGAIN_HGH_GAIN_VAL;
|
||||
break;
|
||||
case LOWGAIN:
|
||||
LOG(logINFO, ("Set settings - Low Gain\n"));
|
||||
confgain = GAIN_CONFGAIN_LW_GAIN_VAL;
|
||||
break;
|
||||
case MEDIUMGAIN:
|
||||
LOG(logINFO, ("Set settings - Medium Gain\n"));
|
||||
confgain = GAIN_CONFGAIN_MDM_GAIN_VAL;
|
||||
break;
|
||||
case VERYHIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - Very High Gain\n"));
|
||||
confgain = GAIN_CONFGAIN_VRY_HGH_GAIN_VAL;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("This settings is not defined for this detector %d\n",
|
||||
(int)sett));
|
||||
return -1;
|
||||
}
|
||||
// set conf gain
|
||||
bus_w(addr, bus_r(addr) & ~GAIN_CONFGAIN_MSK);
|
||||
bus_w(addr, bus_r(addr) | confgain);
|
||||
LOG(logINFO, ("\tGain Reg: 0x%x\n", bus_r(addr)));
|
||||
thisSettings = sett;
|
||||
// find conf gain value
|
||||
uint32_t confgain = 0x0;
|
||||
switch (sett) {
|
||||
case DYNAMICGAIN:
|
||||
LOG(logINFO, ("Set settings - Dyanmic Gain\n"));
|
||||
confgain = GAIN_CONFGAIN_DYNMC_GAIN_VAL;
|
||||
break;
|
||||
case HIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - High Gain\n"));
|
||||
confgain = GAIN_CONFGAIN_HGH_GAIN_VAL;
|
||||
break;
|
||||
case LOWGAIN:
|
||||
LOG(logINFO, ("Set settings - Low Gain\n"));
|
||||
confgain = GAIN_CONFGAIN_LW_GAIN_VAL;
|
||||
break;
|
||||
case MEDIUMGAIN:
|
||||
LOG(logINFO, ("Set settings - Medium Gain\n"));
|
||||
confgain = GAIN_CONFGAIN_MDM_GAIN_VAL;
|
||||
break;
|
||||
case VERYHIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - Very High Gain\n"));
|
||||
confgain = GAIN_CONFGAIN_VRY_HGH_GAIN_VAL;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("This settings is not defined for this detector %d\n", (int)sett));
|
||||
return -1;
|
||||
}
|
||||
// set conf gain
|
||||
bus_w(addr, bus_r(addr) & ~GAIN_CONFGAIN_MSK);
|
||||
bus_w(addr, bus_r(addr) | confgain);
|
||||
LOG(logINFO, ("\tGain Reg: 0x%x\n", bus_r(addr)));
|
||||
thisSettings = sett;
|
||||
|
||||
return getSettings();
|
||||
}
|
||||
@@ -1112,27 +1080,23 @@ int getADC(enum ADCINDEX ind) {
|
||||
// high clk low cs
|
||||
bus_w(addr, (TEMP_SPI_IN_T1_CLK_MSK | TEMP_SPI_IN_T2_CLK_MSK));
|
||||
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < reads; ++i) {
|
||||
for (int i = 0; i < reads; ++i) {
|
||||
|
||||
int j = 0;
|
||||
// low clk low cs
|
||||
for (j = 0; j < repeats; ++j)
|
||||
bus_w(addr, 0x0);
|
||||
// high clk low cs
|
||||
for (j = 0; j < repeats; ++j)
|
||||
bus_w(addr, (TEMP_SPI_IN_T1_CLK_MSK | TEMP_SPI_IN_T2_CLK_MSK));
|
||||
// low clk low cs
|
||||
for (int j = 0; j < repeats; ++j)
|
||||
bus_w(addr, 0x0);
|
||||
// high clk low cs
|
||||
for (int j = 0; j < repeats; ++j)
|
||||
bus_w(addr, (TEMP_SPI_IN_T1_CLK_MSK | TEMP_SPI_IN_T2_CLK_MSK));
|
||||
|
||||
// only the first time
|
||||
if (i <= 10) {
|
||||
if (ind == TEMP_ADC)
|
||||
value = (value << 1) +
|
||||
(bus_r(addrout) & TEMP_SPI_OUT_T1_DT_MSK);
|
||||
else
|
||||
value = (value << 1) +
|
||||
(bus_r(addrout) & TEMP_SPI_OUT_T2_DT_MSK);
|
||||
}
|
||||
// only the first time
|
||||
if (i <= 10) {
|
||||
if (ind == TEMP_ADC)
|
||||
value =
|
||||
(value << 1) + (bus_r(addrout) & TEMP_SPI_OUT_T1_DT_MSK);
|
||||
else
|
||||
value =
|
||||
(value << 1) + (bus_r(addrout) & TEMP_SPI_OUT_T2_DT_MSK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1551,22 +1515,15 @@ int startStateMachine() {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (sharedMemory_getStop() != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_setStatus(RUNNING);
|
||||
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@@ -1603,74 +1560,60 @@ void *start_timer(void *arg) {
|
||||
// Generate Data
|
||||
char imageData[imageSize];
|
||||
memset(imageData, 0, imageSize);
|
||||
{
|
||||
int i = 0;
|
||||
if (adcConfigured == -1) {
|
||||
*((uint32_t *)(imageData)) = 0xCACACACA;
|
||||
}
|
||||
for (i = sizeof(uint32_t); i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t *)(imageData + i)) = (uint16_t)i;
|
||||
}
|
||||
if (adcConfigured == -1) {
|
||||
*((uint32_t *)(imageData)) = 0xCACACACA;
|
||||
}
|
||||
for (int i = sizeof(uint32_t); i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t *)(imageData + i)) = (uint16_t)i;
|
||||
}
|
||||
|
||||
// Send data
|
||||
{
|
||||
int frameNr = 0;
|
||||
uint16_t frameHeaderNr = 2;
|
||||
// loop over number of frames
|
||||
for (frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
// loop over number of frames
|
||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
// check if virtual_stop is high
|
||||
if (virtual_stop == 1) {
|
||||
break;
|
||||
}
|
||||
// check if manual stop
|
||||
if (sharedMemory_getStop() == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i != packetsPerFrame; ++i) {
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
for (int i = 0; i != packetsPerFrame; ++i) {
|
||||
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
// set header
|
||||
*((uint16_t *)(packetData)) = frameHeaderNr;
|
||||
++frameHeaderNr;
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
// set header
|
||||
*((uint16_t *)(packetData)) = virtual_currentFrameNumber;
|
||||
++virtual_currentFrameNumber;
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + 4, imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
// fill data
|
||||
memcpy(packetData + 4, imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
LOG(logINFO,
|
||||
("Sent frame: %d [%d]\n", frameNr, virtual_currentFrameNumber));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs =
|
||||
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs) / 1000);
|
||||
}
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs) / 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@@ -1678,17 +1621,17 @@ void *start_timer(void *arg) {
|
||||
|
||||
int stopStateMachine() {
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
// if scan active, stop scan
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
sharedMemory_setScanStop(1);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
sharedMemory_setStop(1);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while (tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
while (sharedMemory_getStatus() == RUNNING)
|
||||
;
|
||||
sharedMemory_setStop(0);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
@@ -1711,19 +1654,24 @@ int stopStateMachine() {
|
||||
}
|
||||
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
// scan error or running
|
||||
if (sharedMemory_getScanStatus() == ERROR) {
|
||||
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||
return ERROR;
|
||||
}
|
||||
if (virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
} else {
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (sharedMemory_getStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
|
||||
enum runStatus s = IDLE;
|
||||
u_int32_t retval = runState(logINFO);
|
||||
@@ -1768,8 +1716,7 @@ enum runStatus getRunStatus() {
|
||||
} else {
|
||||
LOG(logINFORED,
|
||||
("Status: Unknown Status: 0x%x. Trying again.\n", retval));
|
||||
int iloop = 0;
|
||||
for (iloop = 0; iloop < 10; ++iloop) {
|
||||
for (int iloop = 0; iloop < 10; ++iloop) {
|
||||
usleep(1000 * 1000);
|
||||
if (runState(logDEBUG1) != retval)
|
||||
return getRunStatus();
|
||||
@@ -1794,7 +1741,7 @@ enum runStatus getRunStatus() {
|
||||
|
||||
void readFrame(int *ret, char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
while (virtual_status) {
|
||||
while (sharedMemory_getStatus() == RUNNING) {
|
||||
// LOG(logERROR, ("Waiting for finished flag\n");
|
||||
usleep(5000);
|
||||
}
|
||||
@@ -1818,17 +1765,14 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||
#endif
|
||||
return runState(logDEBUG1) & STATUS_RN_BSY_MSK;
|
||||
}
|
||||
|
||||
u_int32_t runState(enum TLogLevel lev) {
|
||||
#ifdef VIRTUAL
|
||||
return virtual_status;
|
||||
return (int)sharedMemory_getStatus();
|
||||
#endif
|
||||
u_int32_t s = bus_r(STATUS_REG);
|
||||
LOG(lev, ("Status Register: 0x%08x\n", s));
|
||||
|
||||
@@ -30,7 +30,7 @@ enum CLKINDEX { ADC_CLK, NUM_CLOCKS };
|
||||
};
|
||||
|
||||
/* for 25 um */
|
||||
#define CONFIG_FILE "config.txt"
|
||||
#define CONFIG_FILE "config_gotthard.txt"
|
||||
|
||||
/* Hardware Definitions */
|
||||
#define NCHAN (128)
|
||||
|
||||
@@ -12,7 +12,7 @@ add_executable(jungfrauDetectorServer_virtual
|
||||
../slsDetectorServer/src/MAX1932.c
|
||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
)
|
||||
|
||||
target_include_directories(jungfrauDetectorServer_virtual
|
||||
|
||||
@@ -5,14 +5,14 @@ support_lib = ../../slsSupportLib/include/
|
||||
|
||||
CROSS = bfin-uclinux-
|
||||
CC = $(CROSS)gcc
|
||||
CFLAGS += -Wall -DJUNGFRAUD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm
|
||||
CFLAGS += -Wall -std=gnu99 -DJUNGFRAUD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lrt -pthread
|
||||
PROGS = jungfrauDetectorServer
|
||||
DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)/sharedMemory.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "clogger.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
#include "ALTERA_PLL.h" // pll
|
||||
@@ -8,7 +9,6 @@
|
||||
#include "common.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
@@ -36,8 +36,6 @@ char initErrorMessage[MAX_STR_LENGTH];
|
||||
|
||||
#ifdef VIRTUAL
|
||||
pthread_t pthread_virtual_tid;
|
||||
int virtual_status = 0;
|
||||
int virtual_stop = 0;
|
||||
int virtual_image_test_mode = 0;
|
||||
#endif
|
||||
|
||||
@@ -210,9 +208,8 @@ int testBus() {
|
||||
int ret = OK;
|
||||
u_int32_t addr = SET_TRIGGER_DELAY_LSB_REG;
|
||||
u_int32_t times = 1000 * 1000;
|
||||
u_int32_t i = 0;
|
||||
|
||||
for (i = 0; i < times; ++i) {
|
||||
for (u_int32_t i = 0; i < times; ++i) {
|
||||
bus_w(addr, i * 100);
|
||||
if (i * 100 != bus_r(addr)) {
|
||||
LOG(logERROR,
|
||||
@@ -364,10 +361,10 @@ void initStopServer() {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
sharedMemory_setStop(0);
|
||||
// temp threshold and reset event (read by stop server)
|
||||
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
|
||||
setTemperatureEvent(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -376,17 +373,11 @@ void initStopServer() {
|
||||
void setupDetector() {
|
||||
LOG(logINFO, ("This Server is for 1 Jungfrau module (500k)\n"));
|
||||
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < NUM_CLOCKS; ++i) {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
for (int i = 0; i < NUM_CLOCKS; ++i) {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
#endif
|
||||
|
||||
ALTERA_PLL_ResetPLL();
|
||||
@@ -462,14 +453,11 @@ void setupDetector() {
|
||||
int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
{
|
||||
int i = 0;
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (i = 0; i < NDAC; ++i) {
|
||||
// if not already default, set it to default
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
}
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
// if not already default, set it to default
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -747,84 +735,60 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
setSettings((enum detectorSettings)myMod.reg);
|
||||
|
||||
// set dac values
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < NDAC; ++i)
|
||||
setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
|
||||
}
|
||||
for (int i = 0; i < NDAC; ++i)
|
||||
setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModule(sls_detector_module *myMod) {
|
||||
int idac = 0;
|
||||
for (idac = 0; idac < NDAC; ++idac) {
|
||||
if (dacValues[idac] >= 0)
|
||||
*((myMod->dacs) + idac) = dacValues[idac];
|
||||
}
|
||||
// check if all of them are not initialized
|
||||
int initialized = 0;
|
||||
for (idac = 0; idac < NDAC; ++idac) {
|
||||
if (dacValues[idac] >= 0)
|
||||
initialized = 1;
|
||||
}
|
||||
if (initialized) {
|
||||
return OK;
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
if (sett == UNINITIALIZED)
|
||||
return thisSettings;
|
||||
|
||||
// set settings
|
||||
if (sett != GET_SETTINGS) {
|
||||
switch (sett) {
|
||||
case DYNAMICGAIN:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
LOG(logINFO, ("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n",
|
||||
bus_r(DAQ_REG)));
|
||||
break;
|
||||
case DYNAMICHG0:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL);
|
||||
LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n",
|
||||
bus_r(DAQ_REG)));
|
||||
break;
|
||||
case FIXGAIN1:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_STG_1_VAL);
|
||||
LOG(logINFO,
|
||||
("Set settings - Fix Gain 1, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
|
||||
break;
|
||||
case FIXGAIN2:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_STG_2_VAL);
|
||||
LOG(logINFO,
|
||||
("Set settings - Fix Gain 2, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
|
||||
break;
|
||||
case FORCESWITCHG1:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FRCE_GAIN_STG_1_VAL);
|
||||
LOG(logINFO, ("Set settings - Force Switch Gain 1, DAQ Reg: 0x%x\n",
|
||||
bus_r(DAQ_REG)));
|
||||
break;
|
||||
case FORCESWITCHG2:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FRCE_GAIN_STG_2_VAL);
|
||||
LOG(logINFO, ("Set settings - Force Switch Gain 2, DAQ Reg: 0x%x\n",
|
||||
bus_r(DAQ_REG)));
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("This settings is not defined for this detector %d\n",
|
||||
(int)sett));
|
||||
return -1;
|
||||
}
|
||||
|
||||
thisSettings = sett;
|
||||
switch (sett) {
|
||||
case DYNAMICGAIN:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
LOG(logINFO,
|
||||
("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
|
||||
break;
|
||||
case DYNAMICHG0:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL);
|
||||
LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n",
|
||||
bus_r(DAQ_REG)));
|
||||
break;
|
||||
case FIXGAIN1:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_STG_1_VAL);
|
||||
LOG(logINFO,
|
||||
("Set settings - Fix Gain 1, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
|
||||
break;
|
||||
case FIXGAIN2:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_STG_2_VAL);
|
||||
LOG(logINFO,
|
||||
("Set settings - Fix Gain 2, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
|
||||
break;
|
||||
case FORCESWITCHG1:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FRCE_GAIN_STG_1_VAL);
|
||||
LOG(logINFO, ("Set settings - Force Switch Gain 1, DAQ Reg: 0x%x\n",
|
||||
bus_r(DAQ_REG)));
|
||||
break;
|
||||
case FORCESWITCHG2:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FRCE_GAIN_STG_2_VAL);
|
||||
LOG(logINFO, ("Set settings - Force Switch Gain 2, DAQ Reg: 0x%x\n",
|
||||
bus_r(DAQ_REG)));
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("This settings is not defined for this detector %d\n", (int)sett));
|
||||
return -1;
|
||||
}
|
||||
|
||||
thisSettings = sett;
|
||||
|
||||
return getSettings();
|
||||
}
|
||||
|
||||
@@ -1700,22 +1664,15 @@ int startStateMachine() {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (sharedMemory_getStop() != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_setStatus(RUNNING);
|
||||
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@@ -1753,29 +1710,23 @@ void *start_timer(void *arg) {
|
||||
// Generate data
|
||||
char imageData[DATA_BYTES];
|
||||
memset(imageData, 0, DATA_BYTES);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < npixels; ++i) {
|
||||
// avoiding gain also being divided when gappixels enabled in call
|
||||
// back
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||
virtual_image_test_mode ? 0x0FFE : (uint16_t)i;
|
||||
}
|
||||
for (int i = 0; i < npixels; ++i) {
|
||||
// avoiding gain also being divided when gappixels enabled in call
|
||||
// back
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||
virtual_image_test_mode ? 0x0FFE : (uint16_t)i;
|
||||
}
|
||||
|
||||
// Send data
|
||||
{
|
||||
uint64_t frameNr = 0;
|
||||
getStartingFrameNumber(&frameNr);
|
||||
int iframes = 0;
|
||||
for (iframes = 0; iframes != numFrames; ++iframes) {
|
||||
for (int iframes = 0; iframes != numFrames; ++iframes) {
|
||||
|
||||
usleep(transmissionDelayUs);
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
// check if virtual_stop is high
|
||||
if (virtual_stop == 1) {
|
||||
// check if manual stop
|
||||
if (sharedMemory_getStop() == 1) {
|
||||
setStartingFrameNumber(frameNr + iframes + 1);
|
||||
break;
|
||||
}
|
||||
@@ -1788,49 +1739,46 @@ void *start_timer(void *arg) {
|
||||
int srcOffset = 0;
|
||||
int srcOffset2 = DATA_BYTES / 2;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i != packetsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
sls_detector_header *header =
|
||||
(sls_detector_header *)(packetData);
|
||||
for (int i = 0; i != packetsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
sls_detector_header *header =
|
||||
(sls_detector_header *)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr + iframes;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[2];
|
||||
header->column = detPos[3];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header),
|
||||
imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
|
||||
// second interface
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
if (numInterfaces == 2) {
|
||||
header = (sls_detector_header *)(packetData2);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr + iframes;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[2];
|
||||
header->column = detPos[3];
|
||||
header->row = detPos[0];
|
||||
header->column = detPos[1];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header),
|
||||
imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
memcpy(packetData2 + sizeof(sls_detector_header),
|
||||
imageData + srcOffset2, dataSize);
|
||||
srcOffset2 += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
|
||||
// second interface
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
if (numInterfaces == 2) {
|
||||
header = (sls_detector_header *)(packetData2);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr + iframes;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[0];
|
||||
header->column = detPos[1];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData2 + sizeof(sls_detector_header),
|
||||
imageData + srcOffset2, dataSize);
|
||||
srcOffset2 += dataSize;
|
||||
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", iframes));
|
||||
@@ -1853,10 +1801,7 @@ void *start_timer(void *arg) {
|
||||
closeUDPSocket(1);
|
||||
}
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@@ -1864,19 +1809,17 @@ void *start_timer(void *arg) {
|
||||
|
||||
int stopStateMachine() {
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while (tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
// if scan active, stop scan
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
sharedMemory_setScanStop(1);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(1);
|
||||
// read till status is idle
|
||||
while (sharedMemory_getStatus() == RUNNING)
|
||||
;
|
||||
sharedMemory_setStop(0);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
return OK;
|
||||
#endif
|
||||
// stop state machine
|
||||
@@ -1889,19 +1832,24 @@ int stopStateMachine() {
|
||||
}
|
||||
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
// scan error or running
|
||||
if (sharedMemory_getScanStatus() == ERROR) {
|
||||
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||
return ERROR;
|
||||
}
|
||||
if (virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
} else {
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (sharedMemory_getStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
|
||||
enum runStatus s;
|
||||
u_int32_t retval = bus_r(STATUS_REG);
|
||||
@@ -1963,10 +1911,7 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||
#endif
|
||||
u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK);
|
||||
LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||
|
||||
@@ -14,7 +14,7 @@ add_executable(moenchDetectorServer_virtual
|
||||
../slsDetectorServer/src/MAX1932.c
|
||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||
../slsDetectorServer/src/readDefaultPattern.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@@ -42,3 +42,5 @@ set_target_properties(moenchDetectorServer_virtual PROPERTIES
|
||||
install(TARGETS moenchDetectorServer_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
configure_file(DefaultPattern_moench.txt ${CMAKE_BINARY_DIR}/bin/DefaultPattern_moench.txt COPYONLY)
|
||||
@@ -273,7 +273,6 @@ patword 0x010f 0x0008599f0008503a
|
||||
patword 0x0110 0x0008599f0008503a
|
||||
patword 0x0111 0x0008599f0008503a
|
||||
patioctrl 0x8f0effff6dbffdbf
|
||||
patclkctrl 0x0000000000000000
|
||||
patlimits 0x0000 0x0110
|
||||
patloop0 0x00be 0x00ef
|
||||
patnloop0 199
|
||||
@@ -5,14 +5,14 @@ support_lib = ../../slsSupportLib/include/
|
||||
|
||||
CROSS = bfin-uclinux-
|
||||
CC = $(CROSS)gcc
|
||||
CFLAGS += -Wall -DMOENCHD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm
|
||||
CFLAGS += -Wall -std=gnu99 -DMOENCHD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lrt -pthread
|
||||
PROGS = moenchDetectorServer
|
||||
DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)readDefaultPattern.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)readDefaultPattern.c $(main_src)/sharedMemory.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
@@ -32,6 +32,7 @@ $(PROGS): $(OBJS)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
cp DefaultPattern_moench.txt $(DESTDIR)
|
||||
rm *.gdb
|
||||
rm $(main_src)*.o
|
||||
rm *.o
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "clogger.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
#include "ALTERA_PLL.h" // pll
|
||||
@@ -8,9 +9,6 @@
|
||||
#include "UDPPacketHeaderGenerator.h"
|
||||
#include "common.h"
|
||||
#include "communication_funcs_UDP.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
@@ -41,8 +39,8 @@ char initErrorMessage[MAX_STR_LENGTH];
|
||||
|
||||
#ifdef VIRTUAL
|
||||
pthread_t pthread_virtual_tid;
|
||||
int virtual_status = 0;
|
||||
int virtual_stop = 0;
|
||||
uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
|
||||
int64_t virtual_currentFrameNumber = 2;
|
||||
#endif
|
||||
|
||||
// 1g readout
|
||||
@@ -233,8 +231,7 @@ int testFpga() {
|
||||
|
||||
volatile uint32_t val = 0, readval = 0;
|
||||
int times = 1000 * 1000;
|
||||
int i = 0;
|
||||
for (i = 0; i < times; ++i) {
|
||||
for (int i = 0; i < times; ++i) {
|
||||
val = 0x5A5A5A5A - i;
|
||||
bus_w(addr, val);
|
||||
readval = bus_r(addr);
|
||||
@@ -298,9 +295,8 @@ int testBus() {
|
||||
|
||||
volatile uint32_t val = 0, readval = 0;
|
||||
int times = 1000 * 1000;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < times; ++i) {
|
||||
for (int i = 0; i < times; ++i) {
|
||||
val += 0xbbbbb;
|
||||
bus_w(addr, val);
|
||||
readval = bus_r(addr);
|
||||
@@ -432,10 +428,7 @@ void initStopServer() {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
sharedMemory_setStop(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -458,43 +451,38 @@ void setupDetector() {
|
||||
}
|
||||
analogDataPtr = 0;
|
||||
digitalDataPtr = 0;
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < NUM_CLOCKS; ++i) {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
clkFrequency[RUN_CLK] = DEFAULT_RUN_CLK_AT_STARTUP;
|
||||
clkFrequency[ADC_CLK] = DEFAULT_ADC_CLK_AT_STARTUP;
|
||||
clkFrequency[SYNC_CLK] = DEFAULT_SYNC_CLK_AT_STARTUP;
|
||||
clkFrequency[DBIT_CLK] = DEFAULT_DBIT_CLK_AT_STARTUP;
|
||||
// default adc phase in deg
|
||||
/*
|
||||
{
|
||||
int phase_shifts = 0;
|
||||
ConvertToDifferentRange(0, 359, 0, getMaxPhase(ADC_CLK) - 1,
|
||||
DEFAULT_ADC_PHASE_DEG, &phase_shifts); clkPhase[ADC_CLK] =
|
||||
phase_shifts;
|
||||
}
|
||||
LOG(logINFO, ("Default Run clk: %d MHz\n",
|
||||
clkFrequency[RUN_CLK])); LOG(logINFO, ("Default Adc clk: %d MHz\n",
|
||||
clkFrequency[ADC_CLK])); LOG(logINFO, ("Default Sync clk: %d MHz\n",
|
||||
clkFrequency[SYNC_CLK])); LOG(logINFO, ("Default Dbit clk: %d MHz\n",
|
||||
clkFrequency[DBIT_CLK])); LOG(logINFO, ("Default Adc Phase: %d (%d
|
||||
deg)\n", clkPhase[ADC_CLK], getPhase(ADC_CLK, 1)));
|
||||
*/
|
||||
for (i = 0; i < NDAC; ++i)
|
||||
dacValues[i] = -1;
|
||||
for (int i = 0; i < NUM_CLOCKS; ++i) {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
clkFrequency[RUN_CLK] = DEFAULT_RUN_CLK_AT_STARTUP;
|
||||
clkFrequency[ADC_CLK] = DEFAULT_ADC_CLK_AT_STARTUP;
|
||||
clkFrequency[SYNC_CLK] = DEFAULT_SYNC_CLK_AT_STARTUP;
|
||||
clkFrequency[DBIT_CLK] = DEFAULT_DBIT_CLK_AT_STARTUP;
|
||||
// default adc phase in deg
|
||||
/*
|
||||
{
|
||||
int phase_shifts = 0;
|
||||
ConvertToDifferentRange(0, 359, 0, getMaxPhase(ADC_CLK) - 1,
|
||||
DEFAULT_ADC_PHASE_DEG, &phase_shifts); clkPhase[ADC_CLK] =
|
||||
phase_shifts;
|
||||
}
|
||||
LOG(logINFO, ("Default Run clk: %d MHz\n",
|
||||
clkFrequency[RUN_CLK])); LOG(logINFO, ("Default Adc clk: %d MHz\n",
|
||||
clkFrequency[ADC_CLK])); LOG(logINFO, ("Default Sync clk: %d MHz\n",
|
||||
clkFrequency[SYNC_CLK])); LOG(logINFO, ("Default Dbit clk: %d MHz\n",
|
||||
clkFrequency[DBIT_CLK])); LOG(logINFO, ("Default Adc Phase: %d (%d
|
||||
deg)\n", clkPhase[ADC_CLK], getPhase(ADC_CLK, 1)));
|
||||
*/
|
||||
for (int i = 0; i < NDAC; ++i)
|
||||
dacValues[i] = -1;
|
||||
vLimit = DEFAULT_VLIMIT;
|
||||
highvoltage = 0;
|
||||
adcEnableMask_1g = 0;
|
||||
adcEnableMask_10g = 0;
|
||||
nSamples = 1;
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
memset(virtual_pattern, 0, sizeof(virtual_pattern));
|
||||
#endif
|
||||
|
||||
ALTERA_PLL_ResetPLLAndReconfiguration();
|
||||
@@ -610,8 +598,7 @@ void updateDataBytes() {
|
||||
if (adcEnableMask_1g == BIT32_MSK)
|
||||
nchans = 32;
|
||||
else {
|
||||
int ichan = 0;
|
||||
for (ichan = 0; ichan < NCHAN; ++ichan) {
|
||||
for (int ichan = 0; ichan < NCHAN; ++ichan) {
|
||||
if (adcEnableMask_1g & (1 << ichan))
|
||||
++nchans;
|
||||
}
|
||||
@@ -625,14 +612,11 @@ void updateDataBytes() {
|
||||
int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
{
|
||||
int i = 0;
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (i = 0; i < NDAC; ++i) {
|
||||
// if not already default, set it to default
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
}
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
// if not already default, set it to default
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -712,8 +696,7 @@ void setADCEnableMask_10G(uint32_t mask) {
|
||||
uint8_t actualMask = 0;
|
||||
if (mask != 0) {
|
||||
int ival = 0;
|
||||
int ich = 0;
|
||||
for (ich = 0; ich < NCHAN; ich = ich + 4) {
|
||||
for (int ich = 0; ich < NCHAN; ich = ich + 4) {
|
||||
if ((1 << ich) & mask) {
|
||||
actualMask |= (1 << ival);
|
||||
}
|
||||
@@ -739,13 +722,11 @@ uint32_t getADCEnableMask_10G() {
|
||||
// convert 8 bit mask to 32 bit mask
|
||||
uint32_t retval = 0;
|
||||
if (adcEnableMask_10g) {
|
||||
int ival = 0;
|
||||
int iloop = 0;
|
||||
for (ival = 0; ival < 8; ++ival) {
|
||||
for (int ival = 0; ival < 8; ++ival) {
|
||||
// if bit in 8 bit mask set
|
||||
if ((1 << ival) & adcEnableMask_10g) {
|
||||
// set it for 4 bits in 32 bit mask
|
||||
for (iloop = 0; iloop < 4; ++iloop) {
|
||||
for (int iloop = 0; iloop < 4; ++iloop) {
|
||||
retval |= (1 << (ival * 4 + iloop));
|
||||
}
|
||||
}
|
||||
@@ -921,49 +902,46 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
return thisSettings;
|
||||
|
||||
// set settings
|
||||
if (sett != GET_SETTINGS) {
|
||||
switch (sett) {
|
||||
case G1_HIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - G1_HIGHGAIN\n"));
|
||||
setPatternMask(G1_HIGHGAIN_PATMASK);
|
||||
break;
|
||||
case G1_LOWGAIN:
|
||||
LOG(logINFO, ("Set settings - G1_LOWGAIN\n"));
|
||||
setPatternMask(G1_LOWGAIN_PATMASK);
|
||||
break;
|
||||
case G2_HIGHCAP_HIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - G2_HIGHCAP_HIGHGAIN\n"));
|
||||
setPatternMask(G2_HIGHCAP_HIGHGAIN_PATMASK);
|
||||
break;
|
||||
case G2_HIGHCAP_LOWGAIN:
|
||||
LOG(logINFO, ("Set settings - G2_HIGHCAP_LOWGAIN\n"));
|
||||
setPatternMask(G2_HIGHCAP_LOWGAIN_PATMASK);
|
||||
break;
|
||||
case G2_LOWCAP_HIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - G2_LOWCAP_HIGHGAIN\n"));
|
||||
setPatternMask(G2_LOWCAP_HIGHGAIN_PATMASK);
|
||||
break;
|
||||
case G2_LOWCAP_LOWGAIN:
|
||||
LOG(logINFO, ("Set settings - G2_LOWCAP_LOWGAIN\n"));
|
||||
setPatternMask(G2_LOWCAP_LOWGAIN_PATMASK);
|
||||
break;
|
||||
case G4_HIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - G4_HIGHGAIN\n"));
|
||||
setPatternMask(G4_HIGHGAIN_PATMASK);
|
||||
break;
|
||||
case G4_LOWGAIN:
|
||||
LOG(logINFO, ("Set settings - G4_LOWGAIN\n"));
|
||||
setPatternMask(G4_LOWGAIN_PATMASK);
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("This settings is not defined for this detector %d\n",
|
||||
(int)sett));
|
||||
return -1;
|
||||
}
|
||||
setPatternBitMask(DEFAULT_PATSETBIT);
|
||||
thisSettings = sett;
|
||||
switch (sett) {
|
||||
case G1_HIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - G1_HIGHGAIN\n"));
|
||||
setPatternMask(G1_HIGHGAIN_PATMASK);
|
||||
break;
|
||||
case G1_LOWGAIN:
|
||||
LOG(logINFO, ("Set settings - G1_LOWGAIN\n"));
|
||||
setPatternMask(G1_LOWGAIN_PATMASK);
|
||||
break;
|
||||
case G2_HIGHCAP_HIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - G2_HIGHCAP_HIGHGAIN\n"));
|
||||
setPatternMask(G2_HIGHCAP_HIGHGAIN_PATMASK);
|
||||
break;
|
||||
case G2_HIGHCAP_LOWGAIN:
|
||||
LOG(logINFO, ("Set settings - G2_HIGHCAP_LOWGAIN\n"));
|
||||
setPatternMask(G2_HIGHCAP_LOWGAIN_PATMASK);
|
||||
break;
|
||||
case G2_LOWCAP_HIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - G2_LOWCAP_HIGHGAIN\n"));
|
||||
setPatternMask(G2_LOWCAP_HIGHGAIN_PATMASK);
|
||||
break;
|
||||
case G2_LOWCAP_LOWGAIN:
|
||||
LOG(logINFO, ("Set settings - G2_LOWCAP_LOWGAIN\n"));
|
||||
setPatternMask(G2_LOWCAP_LOWGAIN_PATMASK);
|
||||
break;
|
||||
case G4_HIGHGAIN:
|
||||
LOG(logINFO, ("Set settings - G4_HIGHGAIN\n"));
|
||||
setPatternMask(G4_HIGHGAIN_PATMASK);
|
||||
break;
|
||||
case G4_LOWGAIN:
|
||||
LOG(logINFO, ("Set settings - G4_LOWGAIN\n"));
|
||||
setPatternMask(G4_LOWGAIN_PATMASK);
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("This settings is not defined for this detector %d\n", (int)sett));
|
||||
return -1;
|
||||
}
|
||||
setPatternBitMask(DEFAULT_PATSETBIT);
|
||||
thisSettings = sett;
|
||||
|
||||
return getSettings();
|
||||
}
|
||||
@@ -1589,19 +1567,6 @@ uint64_t writePatternIOControl(uint64_t word) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
uint64_t writePatternClkControl(uint64_t word) {
|
||||
if ((int64_t)word != -1) {
|
||||
LOG(logINFO,
|
||||
("Setting Pattern Clock Control: 0x%llx\n", (long long int)word));
|
||||
set64BitReg(word, PATTERN_IO_CLK_CNTRL_LSB_REG,
|
||||
PATTERN_IO_CLK_CNTRL_MSB_REG);
|
||||
}
|
||||
uint64_t retval =
|
||||
get64BitReg(PATTERN_IO_CLK_CNTRL_LSB_REG, PATTERN_IO_CLK_CNTRL_MSB_REG);
|
||||
LOG(logDEBUG1, (" Clock Control retval: 0x%llx\n", (long long int)retval));
|
||||
return retval;
|
||||
}
|
||||
|
||||
uint64_t readPatternWord(int addr) {
|
||||
// error (handled in tcp)
|
||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||
@@ -1628,7 +1593,9 @@ uint64_t readPatternWord(int addr) {
|
||||
uint64_t retval = get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG);
|
||||
LOG(logDEBUG1,
|
||||
(" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int)retval));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
retval = virtual_pattern[addr];
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1645,8 +1612,8 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
||||
(long long int)word));
|
||||
LOG(logDEBUG1, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
||||
(long long int)word));
|
||||
uint32_t reg = PATTERN_CNTRL_REG;
|
||||
|
||||
// write word
|
||||
@@ -1662,7 +1629,9 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
|
||||
// unset write strobe
|
||||
bus_w(reg, bus_r(reg) & (~PATTERN_CNTRL_WR_MSK));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
virtual_pattern[addr] = word;
|
||||
#endif
|
||||
return word;
|
||||
// return readPatternWord(addr); // will start executing the pattern
|
||||
}
|
||||
@@ -1839,18 +1808,15 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
|
||||
}
|
||||
|
||||
// get
|
||||
else {
|
||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
||||
"startAddr:0x%x)\n",
|
||||
level, *startAddr));
|
||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
||||
"startAddr:0x%x)\n",
|
||||
level, *startAddr));
|
||||
|
||||
*stopAddr = ((bus_r(addr) & stopMask) >> stopOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read "
|
||||
"stopAddr:0x%x)\n",
|
||||
level, *stopAddr));
|
||||
}
|
||||
*stopAddr = ((bus_r(addr) & stopMask) >> stopOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read "
|
||||
"stopAddr:0x%x)\n",
|
||||
level, *stopAddr));
|
||||
}
|
||||
|
||||
void setPatternMask(uint64_t mask) {
|
||||
@@ -1880,22 +1846,15 @@ int startStateMachine() {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (sharedMemory_getStop() != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_setStatus(RUNNING);
|
||||
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@@ -1948,77 +1907,64 @@ void *start_timer(void *arg) {
|
||||
// Generate Data
|
||||
char imageData[imageSize];
|
||||
memset(imageData, 0, imageSize);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t *)(imageData + i)) = i;
|
||||
}
|
||||
for (int i = 0; i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t *)(imageData + i)) = i;
|
||||
}
|
||||
|
||||
// Send data
|
||||
{
|
||||
int frameNr = 0;
|
||||
// loop over number of frames
|
||||
for (frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
// loop over number of frames
|
||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
// check if virtual_stop is high
|
||||
if (virtual_stop == 1) {
|
||||
break;
|
||||
}
|
||||
// check if manual stop
|
||||
if (sharedMemory_getStop() == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expNs / 1000);
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expNs / 1000);
|
||||
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i != packetsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
sls_detector_header *header =
|
||||
(sls_detector_header *)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
for (int i = 0; i != packetsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
sls_detector_header *header = (sls_detector_header *)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = virtual_currentFrameNumber;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header),
|
||||
imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header),
|
||||
imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d [%lld]\n", frameNr,
|
||||
(long long unsigned int)virtual_currentFrameNumber));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs =
|
||||
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs) / 1000);
|
||||
}
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs) / 1000);
|
||||
}
|
||||
}
|
||||
++virtual_currentFrameNumber;
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@@ -2026,19 +1972,17 @@ void *start_timer(void *arg) {
|
||||
|
||||
int stopStateMachine() {
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while (tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
// if scan active, stop scan
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
sharedMemory_setScanStop(1);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(1);
|
||||
// read till status is idle
|
||||
while (sharedMemory_getStatus() == RUNNING)
|
||||
;
|
||||
sharedMemory_setStop(0);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
return OK;
|
||||
#endif
|
||||
// stop state machine
|
||||
@@ -2052,19 +1996,24 @@ int stopStateMachine() {
|
||||
}
|
||||
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
// scan error or running
|
||||
if (sharedMemory_getScanStatus() == ERROR) {
|
||||
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||
return ERROR;
|
||||
}
|
||||
if (virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
} else {
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (sharedMemory_getStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
|
||||
uint32_t retval = bus_r(STATUS_REG);
|
||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||
@@ -2192,11 +2141,8 @@ void readSample(int ns) {
|
||||
bus_w(addr, bus_r(addr) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK));
|
||||
|
||||
// wait for 1 us to latch different clocks of read and read strobe
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
|
||||
;
|
||||
}
|
||||
for (int i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
|
||||
;
|
||||
|
||||
if (!(ns % 1000)) {
|
||||
LOG(logDEBUG1, ("Reading sample ns:%d of %d AEmtpy:0x%x AFull:0x%x "
|
||||
@@ -2206,8 +2152,7 @@ void readSample(int ns) {
|
||||
}
|
||||
|
||||
// loop through all channels
|
||||
int ich = 0;
|
||||
for (ich = 0; ich < NCHAN; ++ich) {
|
||||
for (int ich = 0; ich < NCHAN; ++ich) {
|
||||
|
||||
// if channel is in enable mask
|
||||
if ((1 << ich) & (adcEnableMask_1g)) {
|
||||
@@ -2297,10 +2242,7 @@ int readFrameFromFifo() {
|
||||
|
||||
uint32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||
#endif
|
||||
uint32_t s = (bus_r(STATUS_REG) & STATUS_RN_BSY_MSK);
|
||||
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||
|
||||
@@ -74,7 +74,7 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
|
||||
#define NCHANS_PER_ADC (25)
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_PATTERN_FILE ("DefaultPattern.txt")
|
||||
#define DEFAULT_PATTERN_FILE ("DefaultPattern_moench.txt")
|
||||
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
|
||||
#define DEFAULT_NUM_SAMPLES (5000)
|
||||
#define DEFAULT_EXPTIME (0)
|
||||
@@ -117,7 +117,6 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
|
||||
#define DAC_MAX_MV (2500)
|
||||
|
||||
/* Defines in the Firmware */
|
||||
#define MAX_PATTERN_LENGTH (0x2000)
|
||||
#define DIGITAL_IO_DELAY_MAXIMUM_PS \
|
||||
((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
|
||||
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
|
||||
|
||||
@@ -10,7 +10,8 @@ add_executable(mythen3DetectorServer_virtual
|
||||
../slsDetectorServer/src/LTC2620_Driver.c
|
||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||
../slsDetectorServer/src/programFpgaNios.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
../slsDetectorServer/src/readDefaultPattern.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@@ -37,3 +38,5 @@ set_target_properties(mythen3DetectorServer_virtual PROPERTIES
|
||||
install(TARGETS mythen3DetectorServer_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
configure_file(DefaultPattern_mythen3.txt ${CMAKE_BINARY_DIR}/bin/DefaultPattern_mythen3.txt COPYONLY)
|
||||
256
slsDetectorServers/mythen3DetectorServer/DefaultPattern_mythen3.txt
Executable file
256
slsDetectorServers/mythen3DetectorServer/DefaultPattern_mythen3.txt
Executable file
@@ -0,0 +1,256 @@
|
||||
patword 0x0000 0x0000000000000000
|
||||
patword 0x0001 0x0000000000000000
|
||||
patword 0x0002 0x0000000000000000
|
||||
patword 0x0003 0x0000000000000000
|
||||
patword 0x0004 0x0000000000000000
|
||||
patword 0x0005 0x0000000000000000
|
||||
patword 0x0006 0x0000000000c00000
|
||||
patword 0x0007 0x0000000000c00000
|
||||
patword 0x0008 0x0000000000c00000
|
||||
patword 0x0009 0x0000000000c00000
|
||||
patword 0x000a 0x0000000000c00000
|
||||
patword 0x000b 0x0000000000c00000
|
||||
patword 0x000c 0x0000000000000000
|
||||
patword 0x000d 0x0000000000000000
|
||||
patword 0x000e 0x0000000000000000
|
||||
patword 0x000f 0x0000000000000000
|
||||
patword 0x0010 0x0000000000000000
|
||||
patword 0x0011 0x0000000000000000
|
||||
patword 0x0012 0x0000000000200000
|
||||
patword 0x0013 0x0000000000200000
|
||||
patword 0x0014 0x0000000000e00000
|
||||
patword 0x0015 0x0000000000e00000
|
||||
patword 0x0016 0x0000000000e00000
|
||||
patword 0x0017 0x0000000000e00000
|
||||
patword 0x0018 0x0000000000e00000
|
||||
patword 0x0019 0x0000000000e00000
|
||||
patword 0x001a 0x0000000000e00000
|
||||
patword 0x001b 0x0000000000e00000
|
||||
patword 0x001c 0x0000000000200000
|
||||
patword 0x001d 0x0000000000200000
|
||||
patword 0x001e 0x0000000000200000
|
||||
patword 0x001f 0x0000000000200000
|
||||
patword 0x0020 0x0000000000200000
|
||||
patword 0x0021 0x0000000000200000
|
||||
patword 0x0022 0x0000000000200000
|
||||
patword 0x0023 0x0000000000200000
|
||||
patword 0x0024 0x0000000000200000
|
||||
patword 0x0025 0x0000000000200000
|
||||
patword 0x0026 0x0000000000200000
|
||||
patword 0x0027 0x0000000000200000
|
||||
patword 0x0028 0x0000000000200000
|
||||
patword 0x0029 0x0000000001200000
|
||||
patword 0x002a 0x0000000000200000
|
||||
patword 0x002b 0x0000000000200000
|
||||
patword 0x002c 0x0000000000200000
|
||||
patword 0x002d 0x0000000000200000
|
||||
patword 0x002e 0x0000000000200000
|
||||
patword 0x002f 0x0000000000200000
|
||||
patword 0x0030 0x0000000000200000
|
||||
patword 0x0031 0x0000000000200000
|
||||
patword 0x0032 0x0000000001200000
|
||||
patword 0x0033 0x0000000000200000
|
||||
patword 0x0034 0x0000000000200000
|
||||
patword 0x0035 0x0000000000200000
|
||||
patword 0x0036 0x0000000000200000
|
||||
patword 0x0037 0x0000000000200000
|
||||
patword 0x0038 0x0000000000200000
|
||||
patword 0x0039 0x0000000000200000
|
||||
patword 0x003a 0x0000000000200000
|
||||
patword 0x003b 0x0000000001200000
|
||||
patword 0x003c 0x0000000000200000
|
||||
patword 0x003d 0x0000000000200000
|
||||
patword 0x003e 0x0000000000200000
|
||||
patword 0x003f 0x0000000000200000
|
||||
patword 0x0040 0x0000000000200000
|
||||
patword 0x0041 0x0000000000200000
|
||||
patword 0x0042 0x0000000000200000
|
||||
patword 0x0043 0x0000000000200000
|
||||
patword 0x0044 0x0000000001200000
|
||||
patword 0x0045 0x0000000000200000
|
||||
patword 0x0046 0x0000000000200000
|
||||
patword 0x0047 0x0000000000200000
|
||||
patword 0x0048 0x0000000000200000
|
||||
patword 0x0049 0x0000000000200000
|
||||
patword 0x004a 0x0000000000200000
|
||||
patword 0x004b 0x0000000000200000
|
||||
patword 0x004c 0x0000000000200000
|
||||
patword 0x004d 0x0000000001200000
|
||||
patword 0x004e 0x0000000000200000
|
||||
patword 0x004f 0x0000000000200000
|
||||
patword 0x0050 0x0000000000200000
|
||||
patword 0x0051 0x0000000000200000
|
||||
patword 0x0052 0x0000000000200000
|
||||
patword 0x0053 0x0000000000200000
|
||||
patword 0x0054 0x0000000000200000
|
||||
patword 0x0055 0x0000000000200000
|
||||
patword 0x0056 0x0000000001200000
|
||||
patword 0x0057 0x0000000000200000
|
||||
patword 0x0058 0x0000000000200000
|
||||
patword 0x0059 0x0000000000200000
|
||||
patword 0x005a 0x0000000000280000
|
||||
patword 0x005b 0x0000000000280000
|
||||
patword 0x005c 0x0000000000280000
|
||||
patword 0x005d 0x0000000000280000
|
||||
patword 0x005e 0x0000000000280000
|
||||
patword 0x005f 0x0000000001280000
|
||||
patword 0x0060 0x0000000000280000
|
||||
patword 0x0061 0x0000000000200000
|
||||
patword 0x0062 0x0000000000200000
|
||||
patword 0x0063 0x0000000000200000
|
||||
patword 0x0064 0x0000000000200000
|
||||
patword 0x0065 0x0000000000200000
|
||||
patword 0x0066 0x0000000000200000
|
||||
patword 0x0067 0x0000000000200000
|
||||
patword 0x0068 0x0000000001200000
|
||||
patword 0x0069 0x0000000000200000
|
||||
patword 0x006a 0x0000000000200000
|
||||
patword 0x006b 0x0000000000200000
|
||||
patword 0x006c 0x0000000000200000
|
||||
patword 0x006d 0x0000000000200000
|
||||
patword 0x006e 0x0000000000200000
|
||||
patword 0x006f 0x0000000000200000
|
||||
patword 0x0070 0x0000000000200000
|
||||
patword 0x0071 0x0000000001200000
|
||||
patword 0x0072 0x0000000000200000
|
||||
patword 0x0073 0x0000000000200000
|
||||
patword 0x0074 0x0000000000200000
|
||||
patword 0x0075 0x0000000000200000
|
||||
patword 0x0076 0x0000000000200000
|
||||
patword 0x0077 0x0000000000200000
|
||||
patword 0x0078 0x0000000000200000
|
||||
patword 0x0079 0x0000000000200000
|
||||
patword 0x007a 0x0000000001200000
|
||||
patword 0x007b 0x0000000000200000
|
||||
patword 0x007c 0x0000000000200000
|
||||
patword 0x007d 0x0000000000200000
|
||||
patword 0x007e 0x0000000000280000
|
||||
patword 0x007f 0x0000000000280000
|
||||
patword 0x0080 0x0000000000280000
|
||||
patword 0x0081 0x0000000000280000
|
||||
patword 0x0082 0x0000000000280000
|
||||
patword 0x0083 0x0000000001280000
|
||||
patword 0x0084 0x0000000000280000
|
||||
patword 0x0085 0x0000000000200000
|
||||
patword 0x0086 0x0000000000200000
|
||||
patword 0x0087 0x0000000000200000
|
||||
patword 0x0088 0x0000000000200000
|
||||
patword 0x0089 0x0000000000200000
|
||||
patword 0x008a 0x0000000000200000
|
||||
patword 0x008b 0x0000000000200000
|
||||
patword 0x008c 0x0000000001200000
|
||||
patword 0x008d 0x0000000000200000
|
||||
patword 0x008e 0x0000000000200000
|
||||
patword 0x008f 0x0000000000200000
|
||||
patword 0x0090 0x0000000000200000
|
||||
patword 0x0091 0x0000000000200000
|
||||
patword 0x0092 0x0000000000200000
|
||||
patword 0x0093 0x0000000000200000
|
||||
patword 0x0094 0x0000000000200000
|
||||
patword 0x0095 0x0000000001200000
|
||||
patword 0x0096 0x0000000000200000
|
||||
patword 0x0097 0x0000000000200000
|
||||
patword 0x0098 0x0000000000200000
|
||||
patword 0x0099 0x0000000000200000
|
||||
patword 0x009a 0x0000000000200000
|
||||
patword 0x009b 0x0000000000200000
|
||||
patword 0x009c 0x0000000000200000
|
||||
patword 0x009d 0x0000000000200000
|
||||
patword 0x009e 0x0000000001200000
|
||||
patword 0x009f 0x0000000000200000
|
||||
patword 0x00a0 0x0000000000200000
|
||||
patword 0x00a1 0x0000000000200000
|
||||
patword 0x00a2 0x0000000000200000
|
||||
patword 0x00a3 0x0000000000200000
|
||||
patword 0x00a4 0x0000000000200000
|
||||
patword 0x00a5 0x0000000000200000
|
||||
patword 0x00a6 0x0000000000200000
|
||||
patword 0x00a7 0x0000000001200000
|
||||
patword 0x00a8 0x0000000000200000
|
||||
patword 0x00a9 0x0000000000200000
|
||||
patword 0x00aa 0x0000000000200000
|
||||
patword 0x00ab 0x0000000000200000
|
||||
patword 0x00ac 0x0000000000200000
|
||||
patword 0x00ad 0x0000000000200000
|
||||
patword 0x00ae 0x0000000000200000
|
||||
patword 0x00af 0x0000000000200000
|
||||
patword 0x00b0 0x0000000001200000
|
||||
patword 0x00b1 0x0000000000200000
|
||||
patword 0x00b2 0x0000000000200000
|
||||
patword 0x00b3 0x0000000000200000
|
||||
patword 0x00b4 0x0000000000200000
|
||||
patword 0x00b5 0x0000000000200000
|
||||
patword 0x00b6 0x0000000000200000
|
||||
patword 0x00b7 0x0000000000200000
|
||||
patword 0x00b8 0x0000000000200000
|
||||
patword 0x00b9 0x0000000001200000
|
||||
patword 0x00ba 0x0000000000200000
|
||||
patword 0x00bb 0x0000000000200000
|
||||
patword 0x00bc 0x0000000000200000
|
||||
patword 0x00bd 0x0000000000200000
|
||||
patword 0x00be 0x0000000000200000
|
||||
patword 0x00bf 0x0000000000200000
|
||||
patword 0x00c0 0x0000000000200000
|
||||
patword 0x00c1 0x0000000000200000
|
||||
patword 0x00c2 0x0000000001200000
|
||||
patword 0x00c3 0x0000000000200000
|
||||
patword 0x00c4 0x0000000000200000
|
||||
patword 0x00c5 0x0000000000200000
|
||||
patword 0x00c6 0x0000000000300000
|
||||
patword 0x00c7 0x0000000000300000
|
||||
patword 0x00c8 0x0000000000300000
|
||||
patword 0x00c9 0x0000000000300000
|
||||
patword 0x00ca 0x0000000000300000
|
||||
patword 0x00cb 0x0000000000200000
|
||||
patword 0x00cc 0x0000000000200000
|
||||
patword 0x00cd 0x0000000000200000
|
||||
patword 0x00ce 0x0000000000200000
|
||||
patword 0x00cf 0x0000000000200000
|
||||
patword 0x00d0 0x0000000000200000
|
||||
patword 0x00d1 0x0000000000200000
|
||||
patword 0x00d2 0x0000000000000000
|
||||
patword 0x00d3 0x0000000000000000
|
||||
patword 0x00d4 0x0000000000000000
|
||||
patword 0x00d5 0x0000000000000000
|
||||
patword 0x00d6 0x0000000000000000
|
||||
patword 0x00d7 0x0000000000000000
|
||||
patword 0x00d8 0x0000000000000000
|
||||
patword 0x00d9 0x0000000000000000
|
||||
patword 0x00da 0x0000000000c00000
|
||||
patword 0x00db 0x0000000000c00000
|
||||
patword 0x00dc 0x0000000000c00000
|
||||
patword 0x00dd 0x0000000000c00000
|
||||
patword 0x00de 0x0000000000c00000
|
||||
patword 0x00df 0x0000000000c00000
|
||||
patword 0x00e0 0x0000000000c00000
|
||||
patword 0x00e1 0x0000000000c00000
|
||||
patword 0x00e2 0x0000000000c00000
|
||||
patword 0x00e3 0x0000000000c00000
|
||||
patword 0x00e4 0x0000000000000000
|
||||
patword 0x00e5 0x0000000000000000
|
||||
patword 0x00e6 0x0000000000000000
|
||||
patword 0x00e7 0x0000000000000000
|
||||
patword 0x00e8 0x0000000000000000
|
||||
patword 0x00e9 0x0000000000000000
|
||||
patword 0x00ea 0x0000000000000000
|
||||
patword 0x00eb 0x0000000000000000
|
||||
patword 0x00ec 0x0000000000000000
|
||||
patword 0x00ed 0x0000000000000000
|
||||
patword 0x00ee 0x0000000000000000
|
||||
patword 0x00ef 0x0000000000000000
|
||||
patword 0x00f0 0x0000000000000000
|
||||
patword 0x00f1 0x0000000000000000
|
||||
patword 0x00f2 0x0000000000000000
|
||||
patlimits 0x0000 0x00f2
|
||||
patloop0 0x0400 0x0400
|
||||
patnloop0 0
|
||||
patloop1 0x0400 0x0400
|
||||
patnloop1 0
|
||||
patloop2 0x0400 0x0400
|
||||
patnloop2 0
|
||||
patwait0 0x0400
|
||||
patwaittime0 0
|
||||
patwait1 0x0400
|
||||
patwaittime1 0
|
||||
patwait2 0x0400
|
||||
patwaittime2 0
|
||||
@@ -5,14 +5,14 @@ support_lib = ../../slsSupportLib/include/
|
||||
|
||||
CROSS = nios2-buildroot-linux-gnu-
|
||||
CC = $(CROSS)gcc
|
||||
CFLAGS += -Wall -DMYTHEN3D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm
|
||||
CFLAGS += -Wall -std=gnu99 -DMYTHEN3D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lrt -pthread
|
||||
PROGS = mythen3DetectorServer
|
||||
DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)DAC6571.c $(main_src)common.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)/programFpgaNios.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)DAC6571.c $(main_src)common.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)/programFpgaNios.c $(main_src)readDefaultPattern.c $(main_src)/sharedMemory.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
@@ -32,6 +32,7 @@ $(PROGS): $(OBJS)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
cp DefaultPattern_mythen3.txt $(DESTDIR)
|
||||
rm $(main_src)*.o
|
||||
|
||||
clean:
|
||||
|
||||
@@ -104,16 +104,15 @@
|
||||
/* Config RW regiseter */
|
||||
#define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL)
|
||||
|
||||
#define CONFIG_COUNTER_ENA_OFST (0)
|
||||
#define CONFIG_COUNTER_ENA_MSK (0x00000003 << CONFIG_COUNTER_ENA_OFST)
|
||||
#define CONFIG_COUNTER_ENA_DEFAULT_VAL ((0x0 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
|
||||
#define CONFIG_COUNTER_ENA_1_VAL ((0x1 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
|
||||
#define CONFIG_COUNTER_ENA_2_VAL ((0x2 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
|
||||
#define CONFIG_COUNTER_ENA_ALL_VAL ((0x3 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
|
||||
#define CONFIG_COUNTERS_ENA_OFST (0)
|
||||
#define CONFIG_COUNTERS_ENA_MSK (0x00000007 << CONFIG_COUNTERS_ENA_OFST)
|
||||
#define CONFIG_COUNTER_1_ENA_VAL ((0x1 << CONFIG_COUNTERS_ENA_OFST) & CONFIG_COUNTERS_ENA_MSK)
|
||||
#define CONFIG_COUNTER_2_ENA_VAL ((0x2 << CONFIG_COUNTERS_ENA_OFST) & CONFIG_COUNTERS_ENA_MSK)
|
||||
#define CONFIG_COUNTER_3_ENA_VAL ((0x4 << CONFIG_COUNTERS_ENA_OFST) & CONFIG_COUNTERS_ENA_MSK)
|
||||
#define CONFIG_DYNAMIC_RANGE_OFST (4)
|
||||
#define CONFIG_DYNAMIC_RANGE_MSK (0x00000003 << CONFIG_DYNAMIC_RANGE_OFST)
|
||||
#define CONFIG_DYNAMIC_RANGE_1_VAL ((0x0 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
|
||||
#define CONFIG_DYNAMIC_RANGE_4_VAL ((0x1 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
|
||||
#define CONFIG_DYNAMIC_RANGE_8_VAL ((0x1 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
|
||||
#define CONFIG_DYNAMIC_RANGE_16_VAL ((0x2 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
|
||||
#define CONFIG_DYNAMIC_RANGE_24_VAL ((0x3 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
|
||||
|
||||
@@ -150,6 +149,8 @@
|
||||
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
|
||||
#define PKT_CONFIG_RXR_START_ID_OFST (8)
|
||||
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
|
||||
#define PKT_CONFIG_1G_INTERFACE_OFST (16)
|
||||
#define PKT_CONFIG_1G_INTERFACE_MSK (0x00000001 << PKT_CONFIG_1G_INTERFACE_OFST)
|
||||
|
||||
/* Module Coordinates Register */
|
||||
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)
|
||||
|
||||
Binary file not shown.
@@ -5,10 +5,10 @@
|
||||
#include "RegisterDefs.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "versionAPI.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
// Global variable from slsDetectorServer_funcs
|
||||
extern int debugflag;
|
||||
extern int checkModuleFlag;
|
||||
extern udpStruct udpDetails;
|
||||
extern const enum detectorType myDetectorType;
|
||||
|
||||
@@ -35,8 +36,7 @@ char initErrorMessage[MAX_STR_LENGTH];
|
||||
|
||||
#ifdef VIRTUAL
|
||||
pthread_t pthread_virtual_tid;
|
||||
int virtual_status = 0;
|
||||
int virtual_stop = 0;
|
||||
int64_t virtual_currentFrameNumber = 2;
|
||||
#endif
|
||||
|
||||
sls_detector_module *detectorModules = NULL;
|
||||
@@ -49,8 +49,6 @@ uint32_t clkDivider[NUM_CLOCKS] = {};
|
||||
|
||||
int highvoltage = 0;
|
||||
int detPos[2] = {};
|
||||
uint32_t countermask =
|
||||
0; // will be removed later when in firmware converted to mask
|
||||
|
||||
int isInitCheckDone() { return initCheckDone; }
|
||||
|
||||
@@ -333,10 +331,7 @@ void initStopServer() {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
sharedMemory_setStop(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -390,10 +385,7 @@ void setupDetector() {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
#endif
|
||||
|
||||
// pll defines
|
||||
@@ -435,6 +427,43 @@ void setupDetector() {
|
||||
setGateDelay(i, DEFAULT_GATE_DELAY);
|
||||
}
|
||||
setInitialExtSignals();
|
||||
// 10G UDP
|
||||
enableTenGigabitEthernet(1);
|
||||
|
||||
// check module type attached if not in debug mode
|
||||
{
|
||||
int ret = checkDetectorType();
|
||||
if (checkModuleFlag) {
|
||||
switch (ret) {
|
||||
case -1:
|
||||
sprintf(initErrorMessage,
|
||||
"Could not get the module type attached.\n");
|
||||
initError = FAIL;
|
||||
LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage));
|
||||
return;
|
||||
case -2:
|
||||
sprintf(initErrorMessage,
|
||||
"No Module attached! Run server with -nomodule.\n");
|
||||
initError = FAIL;
|
||||
LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage));
|
||||
return;
|
||||
case FAIL:
|
||||
sprintf(initErrorMessage,
|
||||
"Wrong Module (Not Mythen3) attached!\n");
|
||||
initError = FAIL;
|
||||
LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage));
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
LOG(logINFOBLUE,
|
||||
("In No-Module mode: Ignoring module type. Continuing.\n"));
|
||||
}
|
||||
}
|
||||
|
||||
powerChip(1);
|
||||
loadDefaultPattern(DEFAULT_PATTERN_FILE);
|
||||
}
|
||||
|
||||
int setDefaultDacs() {
|
||||
@@ -504,16 +533,15 @@ int setDynamicRange(int dr) {
|
||||
if (dr > 0) {
|
||||
uint32_t regval = 0;
|
||||
switch (dr) {
|
||||
case 1:
|
||||
/*case 1: TODO:Not implemented in firmware yet
|
||||
regval = CONFIG_DYNAMIC_RANGE_1_VAL;
|
||||
break;
|
||||
case 4:
|
||||
regval = CONFIG_DYNAMIC_RANGE_4_VAL;
|
||||
break;*/
|
||||
case 8:
|
||||
regval = CONFIG_DYNAMIC_RANGE_8_VAL;
|
||||
break;
|
||||
case 16:
|
||||
regval = CONFIG_DYNAMIC_RANGE_16_VAL;
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
regval = CONFIG_DYNAMIC_RANGE_24_VAL;
|
||||
break;
|
||||
@@ -528,10 +556,10 @@ int setDynamicRange(int dr) {
|
||||
|
||||
uint32_t regval = bus_r(CONFIG_REG) & CONFIG_DYNAMIC_RANGE_MSK;
|
||||
switch (regval) {
|
||||
case CONFIG_DYNAMIC_RANGE_1_VAL:
|
||||
return 1;
|
||||
case CONFIG_DYNAMIC_RANGE_4_VAL:
|
||||
return 4;
|
||||
/*case CONFIG_DYNAMIC_RANGE_1_VAL: TODO:Not implemented in firmware yet
|
||||
return 1;*/
|
||||
case CONFIG_DYNAMIC_RANGE_8_VAL:
|
||||
return 8;
|
||||
case CONFIG_DYNAMIC_RANGE_16_VAL:
|
||||
return 16;
|
||||
case CONFIG_DYNAMIC_RANGE_24_VAL:
|
||||
@@ -602,16 +630,6 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModule(sls_detector_module *myMod) {
|
||||
// copy local module to myMod
|
||||
if (detectorModules) {
|
||||
if (copyModule(myMod, detectorModules) == FAIL)
|
||||
return FAIL;
|
||||
} else
|
||||
return FAIL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setBit(int ibit, int patword) { return patword |= (1 << ibit); }
|
||||
|
||||
int clearBit(int ibit, int patword) { return patword &= ~(1 << ibit); }
|
||||
@@ -815,12 +833,12 @@ int setPeriod(int64_t val) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
|
||||
val *= (1E-9 * getFrequency(SYSTEM_C2));
|
||||
val *= (1E-9 * getFrequency(SYSTEM_C0));
|
||||
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
||||
|
||||
// validate for tolerance
|
||||
int64_t retval = getPeriod();
|
||||
val /= (1E-9 * getFrequency(SYSTEM_C2));
|
||||
val /= (1E-9 * getFrequency(SYSTEM_C0));
|
||||
if (val != retval) {
|
||||
return FAIL;
|
||||
}
|
||||
@@ -829,7 +847,7 @@ int setPeriod(int64_t val) {
|
||||
|
||||
int64_t getPeriod() {
|
||||
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG) /
|
||||
(1E-9 * getFrequency(SYSTEM_C2));
|
||||
(1E-9 * getFrequency(SYSTEM_C0));
|
||||
}
|
||||
|
||||
void setNumIntGates(int val) {
|
||||
@@ -851,15 +869,18 @@ int getNumGates() { return bus_r(ASIC_EXP_EXT_GATE_NUMBER_REG); }
|
||||
|
||||
void updateGatePeriod() {
|
||||
uint64_t max = 0;
|
||||
uint32_t countermask = getCounterMask();
|
||||
for (int i = 0; i != 3; ++i) {
|
||||
// TODO: only those counters enabled (when updated to mask in firmware)
|
||||
uint64_t sum = getExpTime(i) + getGateDelay(i);
|
||||
if (sum > max) {
|
||||
max = sum;
|
||||
// only if counter enabled
|
||||
if (countermask & (1 << i)) {
|
||||
uint64_t sum = getExpTime(i) + getGateDelay(i);
|
||||
if (sum > max) {
|
||||
max = sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("\tSetting Gate Period to %lld ns\n", (long long int)max));
|
||||
max *= (1E-9 * getFrequency(SYSTEM_C2));
|
||||
max *= (1E-9 * getFrequency(SYSTEM_C0));
|
||||
set64BitReg(max, ASIC_EXP_GATE_PERIOD_LSB_REG,
|
||||
ASIC_EXP_GATE_PERIOD_MSB_REG);
|
||||
}
|
||||
@@ -867,7 +888,7 @@ void updateGatePeriod() {
|
||||
int64_t getGatePeriod() {
|
||||
return get64BitReg(ASIC_EXP_GATE_PERIOD_LSB_REG,
|
||||
ASIC_EXP_GATE_PERIOD_MSB_REG) /
|
||||
(1E-9 * getFrequency(SYSTEM_C2));
|
||||
(1E-9 * getFrequency(SYSTEM_C0));
|
||||
}
|
||||
|
||||
int setExpTime(int gateIndex, int64_t val) {
|
||||
@@ -897,12 +918,12 @@ int setExpTime(int gateIndex, int64_t val) {
|
||||
}
|
||||
LOG(logINFO, ("Setting exptime %lld ns (index:%d)\n", (long long int)val,
|
||||
gateIndex));
|
||||
val *= (1E-9 * getFrequency(SYSTEM_C2));
|
||||
val *= (1E-9 * getFrequency(SYSTEM_C0));
|
||||
set64BitReg(val, alsb, amsb);
|
||||
|
||||
// validate for tolerance
|
||||
int64_t retval = getExpTime(gateIndex);
|
||||
val /= (1E-9 * getFrequency(SYSTEM_C2));
|
||||
val /= (1E-9 * getFrequency(SYSTEM_C0));
|
||||
if (val != retval) {
|
||||
return FAIL;
|
||||
}
|
||||
@@ -932,7 +953,7 @@ int64_t getExpTime(int gateIndex) {
|
||||
LOG(logERROR, ("Invalid gate index: %d\n", gateIndex));
|
||||
return -1;
|
||||
}
|
||||
return get64BitReg(alsb, amsb) / (1E-9 * getFrequency(SYSTEM_C2));
|
||||
return get64BitReg(alsb, amsb) / (1E-9 * getFrequency(SYSTEM_C0));
|
||||
}
|
||||
|
||||
int setGateDelay(int gateIndex, int64_t val) {
|
||||
@@ -962,12 +983,12 @@ int setGateDelay(int gateIndex, int64_t val) {
|
||||
}
|
||||
LOG(logINFO, ("Setting gate delay %lld ns (index:%d)\n", (long long int)val,
|
||||
gateIndex));
|
||||
val *= (1E-9 * getFrequency(SYSTEM_C2));
|
||||
val *= (1E-9 * getFrequency(SYSTEM_C0));
|
||||
set64BitReg(val, alsb, amsb);
|
||||
|
||||
// validate for tolerance
|
||||
int64_t retval = getGateDelay(gateIndex);
|
||||
val /= (1E-9 * getFrequency(SYSTEM_C2));
|
||||
val /= (1E-9 * getFrequency(SYSTEM_C0));
|
||||
if (val != retval) {
|
||||
return FAIL;
|
||||
}
|
||||
@@ -997,71 +1018,26 @@ int64_t getGateDelay(int gateIndex) {
|
||||
LOG(logERROR, ("Invalid gate index: %d\n", gateIndex));
|
||||
return -1;
|
||||
}
|
||||
return get64BitReg(alsb, amsb) / (1E-9 * getFrequency(SYSTEM_C2));
|
||||
return get64BitReg(alsb, amsb) / (1E-9 * getFrequency(SYSTEM_C0));
|
||||
}
|
||||
|
||||
void setCounterMask(uint32_t arg) {
|
||||
if (arg == 0 || arg > MAX_COUNTER_MSK) {
|
||||
return;
|
||||
}
|
||||
countermask = arg;
|
||||
// convert mask into number of counters (until firmware converts to mask)
|
||||
int ncounters = __builtin_popcount(countermask);
|
||||
LOG(logINFO, ("Setting number of counters to %d\n", ncounters));
|
||||
uint32_t val = 0;
|
||||
switch (ncounters) {
|
||||
case 1:
|
||||
val = CONFIG_COUNTER_ENA_1_VAL;
|
||||
break;
|
||||
case 2:
|
||||
val = CONFIG_COUNTER_ENA_2_VAL;
|
||||
break;
|
||||
default:
|
||||
val = CONFIG_COUNTER_ENA_ALL_VAL;
|
||||
break;
|
||||
}
|
||||
LOG(logINFO, ("Setting counter mask to 0x%x\n", arg));
|
||||
uint32_t addr = CONFIG_REG;
|
||||
bus_w(addr, bus_r(addr) & ~CONFIG_COUNTER_ENA_MSK);
|
||||
bus_w(addr, bus_r(addr) | val);
|
||||
bus_w(addr, bus_r(addr) & ~CONFIG_COUNTERS_ENA_MSK);
|
||||
bus_w(addr, bus_r(addr) | ((arg << CONFIG_COUNTERS_ENA_OFST) &
|
||||
CONFIG_COUNTERS_ENA_MSK));
|
||||
LOG(logDEBUG, ("Config Reg: 0x%x\n", bus_r(addr)));
|
||||
|
||||
updateGatePeriod();
|
||||
}
|
||||
|
||||
uint32_t getCounterMask() {
|
||||
uint32_t addr = CONFIG_REG;
|
||||
uint32_t regval = (bus_r(addr) & CONFIG_COUNTER_ENA_MSK);
|
||||
int ncounters = 0;
|
||||
switch (regval) {
|
||||
case CONFIG_COUNTER_ENA_1_VAL:
|
||||
ncounters = 1;
|
||||
break;
|
||||
case CONFIG_COUNTER_ENA_2_VAL:
|
||||
ncounters = 2;
|
||||
break;
|
||||
default:
|
||||
ncounters = 3;
|
||||
break;
|
||||
}
|
||||
// confirm ncounters work with mask saved in server (until firmware converts
|
||||
// to mask)
|
||||
int nc = __builtin_popcount(countermask);
|
||||
// if not equal, make a mask of what is in register (will change once
|
||||
// firmware changes)
|
||||
if (nc != ncounters) {
|
||||
switch (ncounters) {
|
||||
case 1:
|
||||
countermask = 0x1;
|
||||
break;
|
||||
case 2:
|
||||
countermask = 0x3;
|
||||
break;
|
||||
default:
|
||||
countermask = 0x7;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return countermask;
|
||||
return ((bus_r(CONFIG_REG) & CONFIG_COUNTERS_ENA_MSK) >>
|
||||
CONFIG_COUNTERS_ENA_OFST);
|
||||
}
|
||||
|
||||
int setDelayAfterTrigger(int64_t val) {
|
||||
@@ -1071,12 +1047,12 @@ int setDelayAfterTrigger(int64_t val) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("Setting delay after trigger %lld ns\n", (long long int)val));
|
||||
val *= (1E-9 * getFrequency(SYSTEM_C2));
|
||||
val *= (1E-9 * getFrequency(SYSTEM_C0));
|
||||
set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
|
||||
|
||||
// validate for tolerance
|
||||
int64_t retval = getDelayAfterTrigger();
|
||||
val /= (1E-9 * getFrequency(SYSTEM_C2));
|
||||
val /= (1E-9 * getFrequency(SYSTEM_C0));
|
||||
if (val != retval) {
|
||||
return FAIL;
|
||||
}
|
||||
@@ -1085,7 +1061,7 @@ int setDelayAfterTrigger(int64_t val) {
|
||||
|
||||
int64_t getDelayAfterTrigger() {
|
||||
return get64BitReg(SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG) /
|
||||
(1E-9 * getFrequency(SYSTEM_C2));
|
||||
(1E-9 * getFrequency(SYSTEM_C0));
|
||||
}
|
||||
|
||||
int64_t getNumFramesLeft() {
|
||||
@@ -1098,12 +1074,12 @@ int64_t getNumTriggersLeft() {
|
||||
|
||||
int64_t getDelayAfterTriggerLeft() {
|
||||
return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) /
|
||||
(1E-9 * getFrequency(SYSTEM_C2));
|
||||
(1E-9 * getFrequency(SYSTEM_C0));
|
||||
}
|
||||
|
||||
int64_t getPeriodLeft() {
|
||||
return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG) /
|
||||
(1E-9 * getFrequency(SYSTEM_C2));
|
||||
(1E-9 * getFrequency(SYSTEM_C0));
|
||||
}
|
||||
|
||||
int64_t getFramesFromStart() {
|
||||
@@ -1126,6 +1102,15 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ind == M_VTHRESHOLD) {
|
||||
LOG(logINFO,
|
||||
("Setting Threshold voltages to %d %s\n", val, (mV ? "mv" : "")));
|
||||
setDAC(M_VTH1, val, mV);
|
||||
setDAC(M_VTH2, val, mV);
|
||||
setDAC(M_VTH3, val, mV);
|
||||
return;
|
||||
}
|
||||
|
||||
char *dac_names[] = {DAC_NAMES};
|
||||
LOG(logDEBUG1, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind],
|
||||
val, (mV ? "mV" : "dac units")));
|
||||
@@ -1150,6 +1135,23 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
}
|
||||
|
||||
int getDAC(enum DACINDEX ind, int mV) {
|
||||
if (ind == M_VTHRESHOLD) {
|
||||
int ret[3] = {0};
|
||||
ret[0] = getDAC(M_VTH1, mV);
|
||||
ret[1] = getDAC(M_VTH2, mV);
|
||||
ret[2] = getDAC(M_VTH3, mV);
|
||||
|
||||
if ((ret[0] == ret[1]) && (ret[1] == ret[2])) {
|
||||
LOG(logINFO, ("\tvthreshold match\n"));
|
||||
return ret[0];
|
||||
} else {
|
||||
LOG(logERROR, ("\tvthreshold mismatch vth1:%d vth2:%d "
|
||||
"vth3:%d\n",
|
||||
ret[0], ret[1], ret[2]));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mV) {
|
||||
LOG(logDEBUG1, ("Getting DAC %d : %d dac\n", ind, detectorDacs[ind]));
|
||||
return detectorDacs[ind];
|
||||
@@ -1168,54 +1170,47 @@ int setHighVoltage(int val) {
|
||||
if (val > HV_SOFT_MAX_VOLTAGE) {
|
||||
val = HV_SOFT_MAX_VOLTAGE;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (val >= 0)
|
||||
highvoltage = val;
|
||||
return highvoltage;
|
||||
#endif
|
||||
|
||||
// setting hv
|
||||
if (val >= 0) {
|
||||
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
||||
DAC6571_Set(val);
|
||||
highvoltage = val;
|
||||
if (DAC6571_Set(val) == OK)
|
||||
highvoltage = val;
|
||||
}
|
||||
return highvoltage;
|
||||
}
|
||||
|
||||
/* parameters - timing */
|
||||
void setTiming(enum timingMode arg) {
|
||||
if (arg != GET_TIMING_MODE) {
|
||||
switch (arg) {
|
||||
case AUTO_TIMING:
|
||||
LOG(logINFO, ("Set Timing: Auto (Int. Trigger, Int. Gating)\n"));
|
||||
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
|
||||
bus_w(ASIC_EXP_STATUS_REG,
|
||||
bus_r(ASIC_EXP_STATUS_REG) & ~ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
|
||||
break;
|
||||
case TRIGGER_EXPOSURE:
|
||||
LOG(logINFO, ("Set Timing: Trigger (Ext. Trigger, Int. Gating)\n"));
|
||||
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
|
||||
bus_w(ASIC_EXP_STATUS_REG,
|
||||
bus_r(ASIC_EXP_STATUS_REG) & ~ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
|
||||
break;
|
||||
case GATED:
|
||||
LOG(logINFO, ("Set Timing: Gating (Int. Trigger, Ext. Gating)\n"));
|
||||
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
|
||||
bus_w(ASIC_EXP_STATUS_REG,
|
||||
bus_r(ASIC_EXP_STATUS_REG) | ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
|
||||
break;
|
||||
case TRIGGER_GATED:
|
||||
LOG(logINFO,
|
||||
("Set Timing: Trigger_Gating (Ext. Trigger, Ext. Gating)\n"));
|
||||
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
|
||||
bus_w(ASIC_EXP_STATUS_REG,
|
||||
bus_r(ASIC_EXP_STATUS_REG) | ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Unknown timing mode %d\n", arg));
|
||||
return;
|
||||
}
|
||||
switch (arg) {
|
||||
case AUTO_TIMING:
|
||||
LOG(logINFO, ("Set Timing: Auto (Int. Trigger, Int. Gating)\n"));
|
||||
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
|
||||
bus_w(ASIC_EXP_STATUS_REG,
|
||||
bus_r(ASIC_EXP_STATUS_REG) & ~ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
|
||||
break;
|
||||
case TRIGGER_EXPOSURE:
|
||||
LOG(logINFO, ("Set Timing: Trigger (Ext. Trigger, Int. Gating)\n"));
|
||||
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
|
||||
bus_w(ASIC_EXP_STATUS_REG,
|
||||
bus_r(ASIC_EXP_STATUS_REG) & ~ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
|
||||
break;
|
||||
case GATED:
|
||||
LOG(logINFO, ("Set Timing: Gating (Int. Trigger, Ext. Gating)\n"));
|
||||
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
|
||||
bus_w(ASIC_EXP_STATUS_REG,
|
||||
bus_r(ASIC_EXP_STATUS_REG) | ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
|
||||
break;
|
||||
case TRIGGER_GATED:
|
||||
LOG(logINFO,
|
||||
("Set Timing: Trigger_Gating (Ext. Trigger, Ext. Gating)\n"));
|
||||
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
|
||||
bus_w(ASIC_EXP_STATUS_REG,
|
||||
bus_r(ASIC_EXP_STATUS_REG) | ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Unknown timing mode %d\n", arg));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1500,6 +1495,26 @@ int setDetectorPosition(int pos[]) {
|
||||
|
||||
int *getDetectorPosition() { return detPos; }
|
||||
|
||||
int enableTenGigabitEthernet(int val) {
|
||||
uint32_t addr = PKT_CONFIG_REG;
|
||||
|
||||
// set
|
||||
if (val != -1) {
|
||||
LOG(logINFO, ("Setting 10Gbe: %d\n", (val > 0) ? 1 : 0));
|
||||
// 1g
|
||||
if (val == 0) {
|
||||
bus_w(addr, bus_r(addr) | PKT_CONFIG_1G_INTERFACE_MSK);
|
||||
}
|
||||
// 10g
|
||||
else {
|
||||
bus_w(addr, bus_r(addr) & (~PKT_CONFIG_1G_INTERFACE_MSK));
|
||||
}
|
||||
}
|
||||
int oneG = ((bus_r(addr) & PKT_CONFIG_1G_INTERFACE_MSK) >>
|
||||
PKT_CONFIG_1G_INTERFACE_OFST);
|
||||
return oneG ? 0 : 1;
|
||||
}
|
||||
|
||||
/* pattern */
|
||||
|
||||
void startPattern() {
|
||||
@@ -1521,7 +1536,7 @@ uint64_t readPatternWord(int addr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG(trimmingPrint, (" Reading Pattern Word (addr:0x%x)\n", addr));
|
||||
LOG(logDEBUG1, (" Reading Pattern Word (addr:0x%x)\n", addr));
|
||||
uint32_t reg_lsb =
|
||||
PATTERN_STEP0_LSB_REG +
|
||||
addr * REG_OFFSET * 2; // the first word in RAM as base plus the offset
|
||||
@@ -1549,8 +1564,8 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
addr, MAX_PATTERN_LENGTH));
|
||||
return -1;
|
||||
}
|
||||
LOG(trimmingPrint, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
||||
(long long int)word));
|
||||
LOG(logDEBUG1, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
||||
(long long int)word));
|
||||
|
||||
// write word
|
||||
uint32_t reg_lsb =
|
||||
@@ -1740,18 +1755,15 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
((*stopAddr << stopOffset) & stopMask));
|
||||
}
|
||||
|
||||
// get
|
||||
else {
|
||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
||||
"startAddr:0x%x)\n",
|
||||
level, *startAddr));
|
||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
||||
"startAddr:0x%x)\n",
|
||||
level, *startAddr));
|
||||
|
||||
*stopAddr = ((bus_r(addr) & stopMask) >> stopOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read "
|
||||
"stopAddr:0x%x)\n",
|
||||
level, *stopAddr));
|
||||
}
|
||||
*stopAddr = ((bus_r(addr) & stopMask) >> stopOffset);
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read "
|
||||
"stopAddr:0x%x)\n",
|
||||
level, *stopAddr));
|
||||
}
|
||||
|
||||
void setPatternMask(uint64_t mask) {
|
||||
@@ -1973,7 +1985,7 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
clkDivider[ind]));
|
||||
|
||||
// phase is reset by pll (when setting output frequency)
|
||||
if (ind >= READOUT_C0) {
|
||||
if (ind < SYSTEM_C0) {
|
||||
clkPhase[READOUT_C0] = 0;
|
||||
clkPhase[READOUT_C1] = 0;
|
||||
} else {
|
||||
@@ -2013,22 +2025,15 @@ int startStateMachine() {
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
// set status to running
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (sharedMemory_getStop() != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_setStatus(RUNNING);
|
||||
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@@ -2054,7 +2059,6 @@ void *start_timer(void *arg) {
|
||||
int numFrames = (getNumFrames() * getNumTriggers());
|
||||
int64_t expUs = getGatePeriod() / 1000;
|
||||
|
||||
// int dr = setDynamicRange(-1);
|
||||
int imagesize = calculateDataBytes();
|
||||
int dataSize = imagesize / PACKETS_PER_FRAME;
|
||||
int packetSize = dataSize + sizeof(sls_detector_header);
|
||||
@@ -2062,18 +2066,41 @@ void *start_timer(void *arg) {
|
||||
// Generate data
|
||||
char imageData[imagesize];
|
||||
memset(imageData, 0, imagesize);
|
||||
for (int i = 0; i < imagesize; i += sizeof(uint8_t)) {
|
||||
*((uint8_t *)(imageData + i)) = i;
|
||||
{
|
||||
int dr = setDynamicRange(-1);
|
||||
int numCounters = __builtin_popcount(getCounterMask());
|
||||
int nchannels = NCHAN_1_COUNTER * NCHIP * numCounters;
|
||||
|
||||
switch (dr) {
|
||||
/*case 1: // TODO: Not implemented in firmware yet
|
||||
break;*/
|
||||
case 8:
|
||||
for (int i = 0; i < nchannels; ++i) {
|
||||
*((uint8_t *)(imageData + i)) = (uint8_t)i;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
for (int i = 0; i < nchannels; ++i) {
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) = (uint16_t)i;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
for (int i = 0; i < nchannels; ++i) {
|
||||
*((uint32_t *)(imageData + i * sizeof(uint32_t))) =
|
||||
((uint32_t)i & 0xFFFFFF); // 24 bit
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Send data
|
||||
// loop over number of frames
|
||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
// check if virtual_stop is high
|
||||
if (virtual_stop == 1) {
|
||||
// check if manual stop
|
||||
if (sharedMemory_getStop() == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2092,7 +2119,7 @@ void *start_timer(void *arg) {
|
||||
sls_detector_header *header = (sls_detector_header *)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr + 1;
|
||||
header->frameNumber = virtual_currentFrameNumber;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
@@ -2105,7 +2132,8 @@ void *start_timer(void *arg) {
|
||||
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
LOG(logINFO, ("Sent frame: %d [%lld]\n", frameNr,
|
||||
(long long unsigned int)virtual_currentFrameNumber));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs =
|
||||
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
|
||||
@@ -2116,14 +2144,12 @@ void *start_timer(void *arg) {
|
||||
usleep((periodNs - timeNs) / 1000);
|
||||
}
|
||||
}
|
||||
++virtual_currentFrameNumber;
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@@ -2131,17 +2157,17 @@ void *start_timer(void *arg) {
|
||||
|
||||
int stopStateMachine() {
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
// if scan active, stop scan
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
sharedMemory_setScanStop(1);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
sharedMemory_setStop(1);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while (tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
while (sharedMemory_getStatus() == RUNNING)
|
||||
;
|
||||
sharedMemory_setStop(0);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
@@ -2153,19 +2179,25 @@ int stopStateMachine() {
|
||||
}
|
||||
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
// scan error or running
|
||||
if (sharedMemory_getScanStatus() == ERROR) {
|
||||
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||
return ERROR;
|
||||
}
|
||||
if (virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
} else {
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (sharedMemory_getStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
|
||||
uint32_t retval = bus_r(FLOW_STATUS_REG);
|
||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||
|
||||
@@ -2233,10 +2265,7 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||
#endif
|
||||
u_int32_t s = (bus_r(FLOW_STATUS_REG) & FLOW_STATUS_RUN_BUSY_MSK);
|
||||
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||
@@ -2298,13 +2327,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
int calculateDataBytes() {
|
||||
int numCounters = __builtin_popcount(getCounterMask());
|
||||
int dr = setDynamicRange(-1);
|
||||
int databytes = NCHAN_1_COUNTER * NCHIP * numCounters *
|
||||
((dr > 16) ? 4 : // 32 bit
|
||||
((dr > 8) ? 2 : // 16 bit
|
||||
((dr > 4) ? 0.5 : // 4 bit
|
||||
0.125))); // 1 bit
|
||||
|
||||
return databytes;
|
||||
return (NCHAN_1_COUNTER * NCHIP * numCounters * ((double)dr / 8.00));
|
||||
}
|
||||
|
||||
int getTotalNumberOfChannels() {
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
#define MAX_EXT_SIGNALS (8)
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_PATTERN_FILE ("DefaultPattern_mythen3.txt")
|
||||
#define DEFAULT_INTERNAL_GATES (1)
|
||||
#define DEFAULT_EXTERNAL_GATES (1)
|
||||
#define DEFAULT_DYNAMIC_RANGE (24)
|
||||
#define DEFAULT_DYNAMIC_RANGE (32)
|
||||
#define DEFAULT_NUM_FRAMES (1)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
#define DEFAULT_GATE_WIDTH (100 * 1000 * 1000) // ns
|
||||
@@ -37,9 +38,9 @@
|
||||
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
|
||||
#define DEFAULT_READOUT_C0 (10) //(125000000) // rdo_clk, 125 MHz
|
||||
#define DEFAULT_READOUT_C1 (10) //(125000000) // rdo_x2_clk, 125 MHz
|
||||
#define DEFAULT_SYSTEM_C0 (5) //(250000000) // run_clk, 250 MHz
|
||||
#define DEFAULT_SYSTEM_C1 (10) //(125000000) // chip_clk, 125 MHz
|
||||
#define DEFAULT_SYSTEM_C2 (10) //(125000000) // sync_clk, 125 MHz
|
||||
#define DEFAULT_SYSTEM_C0 (4) //(250000000) // run_clk, 250 MHz
|
||||
#define DEFAULT_SYSTEM_C1 (8) //(125000000) // chip_clk, 125 MHz
|
||||
#define DEFAULT_SYSTEM_C2 (8) //(125000000) // sync_clk, 125 MHz
|
||||
#define DEFAULT_ASIC_LATCHING_NUM_PULSES (10)
|
||||
#define DEFAULT_MSTR_OTPT_P1_NUM_PULSES (20)
|
||||
|
||||
@@ -47,8 +48,7 @@
|
||||
#define IP_HEADER_SIZE (20)
|
||||
#define FIXED_PLL_FREQUENCY (020000000) // 20MHz
|
||||
#define READOUT_PLL_VCO_FREQ_HZ (1250000000) // 1.25GHz
|
||||
#define SYSTEM_PLL_VCO_FREQ_HZ (1250000000) // 1.25GHz
|
||||
#define MAX_PATTERN_LENGTH (0x2000) // maximum number of words (64bit)
|
||||
#define SYSTEM_PLL_VCO_FREQ_HZ (1000000000) // 1GHz
|
||||
|
||||
/** Other Definitions */
|
||||
#define BIT16_MASK (0xFFFF)
|
||||
@@ -56,43 +56,44 @@
|
||||
|
||||
/* Enums */
|
||||
enum DACINDEX {
|
||||
M_CASSH,
|
||||
M_VCASSH,
|
||||
M_VTH2,
|
||||
M_VRFSH,
|
||||
M_VRFSHNPOL,
|
||||
M_VRSHAPER,
|
||||
M_VRSHAPER_N,
|
||||
M_VIPRE_OUT,
|
||||
M_VTH3,
|
||||
M_VTH1,
|
||||
M_VICIN,
|
||||
M_CAS,
|
||||
M_VRF,
|
||||
M_VPL,
|
||||
M_VCAS,
|
||||
M_VRPREAMP,
|
||||
M_VCAL_N,
|
||||
M_VIPRE,
|
||||
M_VIINSH,
|
||||
M_VPH,
|
||||
M_VISHAPER,
|
||||
M_VCAL_P,
|
||||
M_VTRIM,
|
||||
M_VDCSH
|
||||
M_VDCSH,
|
||||
M_VTHRESHOLD
|
||||
};
|
||||
#define DAC_NAMES \
|
||||
"vcassh", "vth2", "vshaper", "vshaperneg", "vipre_out", "vth3", "vth1", \
|
||||
"vicin", "vcas", "vpreamp", "vpl", "vipre", "viinsh", "vph", "vtrim", \
|
||||
"vdcsh"
|
||||
"vcassh", "vth2", "vrshaper", "vrshaper_n", "vipre_out", "vth3", "vth1", \
|
||||
"vicin", "vcas", "vrpreamp", "vcal_n", "vipre", "vishaper", "vcal_p", \
|
||||
"vtrim", "vdcsh"
|
||||
#define DEFAULT_DAC_VALS \
|
||||
{ \
|
||||
1200, /* casSh */ \
|
||||
2800, /* Vth2 */ \
|
||||
1280, /* VrfSh */ \
|
||||
2800, /* VrfShNpol */ \
|
||||
1280, /* Vrshaper */ \
|
||||
2800, /* Vrshaper_n */ \
|
||||
1220, /* vIpreOut */ \
|
||||
2800, /* Vth3 */ \
|
||||
2800, /* Vth1 */ \
|
||||
1708, /* vIcin */ \
|
||||
1800, /* cas */ \
|
||||
1100, /* Vrf */ \
|
||||
1100, /* VPL */ \
|
||||
1100, /* Vrpreamp */ \
|
||||
1100, /* Vcal_n */ \
|
||||
2624, /* vIpre */ \
|
||||
1708, /* vIinSh */ \
|
||||
1712, /* VPH */ \
|
||||
1708, /* vishaper */ \
|
||||
1712, /* Vcal_p */ \
|
||||
2800, /* vTrim */ \
|
||||
800 /* VdcSh */ \
|
||||
};
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/**
|
||||
* Convert a value from a range to a different range (eg voltage to dac or vice
|
||||
* versa)
|
||||
@@ -13,3 +16,7 @@
|
||||
*/
|
||||
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
||||
int outputMax, int inputValue, int *outputValue);
|
||||
|
||||
|
||||
|
||||
int getAbsPath(char* buf, size_t bufSize, char* fname);
|
||||
@@ -24,7 +24,6 @@ int receiveData(int file_des, void *buf, int length, intType itype);
|
||||
int sendDataOnly(int file_des, void *buf, int length);
|
||||
int receiveDataOnly(int file_des, void *buf, int length);
|
||||
|
||||
int sendModule(int file_des, sls_detector_module *myMod);
|
||||
int receiveModule(int file_des, sls_detector_module *myMod);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
#ifdef VIRTUAL
|
||||
// communciate between control and stop server
|
||||
|
||||
int ComVirtual_createFiles(const int port);
|
||||
void ComVirtual_setFileNames(const int port);
|
||||
void ComVirtual_setStatus(int value);
|
||||
int ComVirtual_getStatus();
|
||||
void ComVirtual_setStop(int value);
|
||||
int ComVirtual_getStop();
|
||||
int ComVirtual_writeToFile(int value, const char *fname,
|
||||
const char *serverName);
|
||||
int ComVirtual_readFromFile(int *value, const char *fname,
|
||||
const char *serverName);
|
||||
|
||||
#endif
|
||||
@@ -3,13 +3,13 @@
|
||||
#include <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int loadDefaultPattern(char *fname);
|
||||
int loadDefaultPattern(char *patFname);
|
||||
|
||||
int default_writePatternWord(char *line, uint32_t addr, uint64_t word);
|
||||
|
||||
#ifndef MYTHEN3D
|
||||
int default_writePatternIOControl(char *line, uint64_t arg);
|
||||
|
||||
int default_writePatternClkControl(char *line, uint64_t arg);
|
||||
#endif
|
||||
|
||||
int default_setPatternLoopLimits(char *line, uint32_t startAddr,
|
||||
uint32_t stopAddr);
|
||||
|
||||
22
slsDetectorServers/slsDetectorServer/include/sharedMemory.h
Normal file
22
slsDetectorServers/slsDetectorServer/include/sharedMemory.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
void sharedMemory_print();
|
||||
int sharedMemory_create(int port);
|
||||
int sharedMemory_initialize();
|
||||
int sharedMemory_open(int port);
|
||||
int sharedMemory_attach();
|
||||
int sharedMemory_detach();
|
||||
int sharedMemory_remove();
|
||||
void sharedMemory_lock();
|
||||
void sharedMemory_unlock();
|
||||
#ifdef VIRTUAL
|
||||
void sharedMemory_setStatus(enum runStatus s);
|
||||
enum runStatus sharedMemory_getStatus();
|
||||
void sharedMemory_setStop(int s);
|
||||
int sharedMemory_getStop();
|
||||
#endif
|
||||
void sharedMemory_setScanStatus(enum runStatus s);
|
||||
enum runStatus sharedMemory_getScanStatus();
|
||||
void sharedMemory_setScanStop(int s);
|
||||
int sharedMemory_getScanStop();
|
||||
@@ -8,7 +8,7 @@
|
||||
defined(MOENCHD)
|
||||
#include "AD9257.h" // commonServerFunctions.h, blackfin.h, ansi.h
|
||||
#endif
|
||||
#ifdef MOENCHD
|
||||
#if defined(MOENCHD) || defined(MYTHEN3D)
|
||||
#include "readDefaultPattern.h"
|
||||
#endif
|
||||
|
||||
@@ -184,8 +184,6 @@ int setParallelMode(int mode);
|
||||
int getParallelMode();
|
||||
int setOverFlowMode(int mode);
|
||||
int getOverFlowMode();
|
||||
void setStoreInRamMode(int mode);
|
||||
int getStoreInRamMode();
|
||||
#endif
|
||||
#ifdef CHIPTESTBOARDD
|
||||
int setReadoutMode(enum readoutMode mode);
|
||||
@@ -276,7 +274,6 @@ int64_t getMeasurementTime();
|
||||
// parameters - module, settings
|
||||
#if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(GOTTHARD2D))
|
||||
int setModule(sls_detector_module myMod, char *mess);
|
||||
int getModule(sls_detector_module *myMod);
|
||||
#endif
|
||||
#ifdef MYTHEN3D
|
||||
int setTrimbits(int *trimbits);
|
||||
@@ -380,7 +377,8 @@ int getInterruptSubframe();
|
||||
int setReadNLines(int value);
|
||||
int getReadNLines();
|
||||
#endif
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD)
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD) || \
|
||||
defined(MYTHEN3D)
|
||||
int enableTenGigabitEthernet(int val);
|
||||
#endif
|
||||
|
||||
@@ -406,7 +404,6 @@ void setPipeline(enum CLKINDEX ind, int val);
|
||||
int getPipeline(enum CLKINDEX ind);
|
||||
// patterns
|
||||
uint64_t writePatternIOControl(uint64_t word);
|
||||
uint64_t writePatternClkControl(uint64_t word);
|
||||
uint64_t readPatternWord(int addr);
|
||||
uint64_t writePatternWord(int addr, uint64_t word);
|
||||
int setPatternWaitAddress(int level, int addr);
|
||||
@@ -508,18 +505,27 @@ int setInjectChannel(int offset, int increment);
|
||||
void getInjectedChannels(int *offset, int *increment);
|
||||
int setVetoReference(int gainIndex, int value);
|
||||
int setVetoPhoton(int chipIndex, int gainIndex, int *values);
|
||||
int configureASICVetoReference(int chipIndex, int *values);
|
||||
int getVetoPhoton(int chipIndex, int *retvals);
|
||||
int configureSingleADCDriver(int chipIndex);
|
||||
int configureADC();
|
||||
int setVetoFile(int chipIndex, int *gainIndices, int *values);
|
||||
int setADCConfiguration(int chipIndex, int adcIndex, int value);
|
||||
int getADCConfiguration(int chipIndex, int adcIndex);
|
||||
int setBurstModeinFPGA(enum burstMode value);
|
||||
int setBurstMode(enum burstMode burst);
|
||||
int configureASICGlobalSettings();
|
||||
enum burstMode getBurstMode();
|
||||
int setCDSGain(int enable);
|
||||
int getCDSGain();
|
||||
int setFilter(int value);
|
||||
int getFilter();
|
||||
void setCurrentSource(int value);
|
||||
int getCurrentSource();
|
||||
void setTimingSource(enum timingSourceType value);
|
||||
enum timingSourceType getTimingSource();
|
||||
void setVeto(int enable);
|
||||
int getVeto();
|
||||
void setBadChannels(int nch, int *channels);
|
||||
int *getBadChannels(int *nch);
|
||||
#endif
|
||||
|
||||
#if defined(JUNGFRAUD) || defined(EIGERD)
|
||||
|
||||
@@ -36,17 +36,19 @@ int set_firmware_test(int);
|
||||
int set_bus_test(int);
|
||||
int set_image_test_mode(int);
|
||||
int get_image_test_mode(int);
|
||||
enum DACINDEX getDACIndex(enum dacIndex ind);
|
||||
int validateAndSetDac(enum dacIndex ind, int val, int mV);
|
||||
int set_dac(int);
|
||||
int get_adc(int);
|
||||
int write_register(int);
|
||||
int read_register(int);
|
||||
int set_module(int);
|
||||
int get_module(int);
|
||||
int set_settings(int);
|
||||
int get_threshold_energy(int);
|
||||
int acquire(int blocking, int file_des);
|
||||
void *start_state_machine(void *arg);
|
||||
int start_acquisition(int);
|
||||
int stop_acquisition(int);
|
||||
int start_readout(int);
|
||||
int get_run_status(int);
|
||||
int start_and_read_all(int);
|
||||
int read_all(int);
|
||||
@@ -85,15 +87,14 @@ int get_measurement_time(int);
|
||||
int set_dynamic_range(int);
|
||||
int set_roi(int);
|
||||
int get_roi(int);
|
||||
int exit_server(int);
|
||||
int lock_server(int);
|
||||
int get_last_client_ip(int);
|
||||
int set_port(int);
|
||||
int calibrate_pedestal(int);
|
||||
int enable_ten_giga(int);
|
||||
int validateAndSetAllTrimbits(int arg);
|
||||
int set_all_trimbits(int);
|
||||
int set_pattern_io_control(int);
|
||||
int set_pattern_clock_control(int);
|
||||
int set_pattern_word(int);
|
||||
int set_pattern_loop_addresses(int);
|
||||
int set_pattern_loop_cycles(int);
|
||||
@@ -122,7 +123,6 @@ int program_fpga(int);
|
||||
int reset_fpga(int);
|
||||
int power_chip(int);
|
||||
int set_activate(int);
|
||||
int prepare_acquisition(int);
|
||||
int threshold_temp(int);
|
||||
int temp_control(int);
|
||||
int temp_event(int);
|
||||
@@ -181,8 +181,6 @@ int set_parallel_mode(int);
|
||||
int get_parallel_mode(int);
|
||||
int set_overflow_mode(int);
|
||||
int get_overflow_mode(int);
|
||||
int set_storeinram(int);
|
||||
int get_storeinram(int);
|
||||
int set_readout_mode(int);
|
||||
int get_readout_mode(int);
|
||||
int set_clock_frequency(int);
|
||||
@@ -226,4 +224,17 @@ int get_gate_delay(int);
|
||||
int get_exptime_all_gates(int);
|
||||
int get_gate_delay_all_gates(int);
|
||||
int get_veto(int);
|
||||
int set_veto(int);
|
||||
int set_veto(int);
|
||||
int set_pattern(int);
|
||||
int get_scan(int);
|
||||
int set_scan(int);
|
||||
int get_scan_error_message(int);
|
||||
int get_cds_gain(int);
|
||||
int set_cds_gain(int);
|
||||
int get_filter(int);
|
||||
int set_filter(int);
|
||||
int set_veto_file(int);
|
||||
int get_adc_config(int);
|
||||
int set_adc_config(int);
|
||||
int get_bad_channels(int);
|
||||
int set_bad_channels(int);
|
||||
@@ -219,8 +219,7 @@ void AD7689_Configure() {
|
||||
LOG(logINFO,
|
||||
("\tConfiguring %d x due to invalid conversions from power up\n",
|
||||
AD7689_NUM_INVALID_CONVERSIONS));
|
||||
int i = 0;
|
||||
for (i = 0; i < AD7689_NUM_INVALID_CONVERSIONS; ++i) {
|
||||
for (int i = 0; i < AD7689_NUM_INVALID_CONVERSIONS; ++i) {
|
||||
AD7689_Set(
|
||||
// read back
|
||||
AD7689_CFG_RB_MSK |
|
||||
|
||||
@@ -35,8 +35,7 @@ int ASIC_Driver_Set(int index, int length, char *buffer) {
|
||||
("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname));
|
||||
{
|
||||
LOG(logDEBUG2, ("\t[values: \n"));
|
||||
int i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
LOG(logDEBUG2, ("\t%d: 0x%02hhx\n", i, buffer[i]));
|
||||
}
|
||||
LOG(logDEBUG2, ("\t]\n"));
|
||||
|
||||
@@ -234,10 +234,8 @@ uint32_t I2C_Read(uint32_t devId, uint32_t addr) {
|
||||
int level = bus_r(I2C_Rx_Data_Fifo_Level_Reg);
|
||||
LOG(logDEBUG2, (" level:%d\n", level));
|
||||
|
||||
int iloop = level - 1;
|
||||
|
||||
// level bytes to read, read 1 byte at a time
|
||||
for (iloop = level - 1; iloop >= 0; --iloop) {
|
||||
for (int iloop = level - 1; iloop >= 0; --iloop) {
|
||||
u_int16_t byte =
|
||||
bus_r(I2C_Rx_Data_Fifo_Reg) & I2C_RX_DATA_FIFO_RXDATA_MSK;
|
||||
LOG(logDEBUG2, (" byte nr %d:0x%x\n", iloop, byte));
|
||||
|
||||
@@ -116,7 +116,6 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
|
||||
int nchip = LTC2620_Ndac / LTC2620_NUMCHANNELS;
|
||||
uint32_t valw = 0;
|
||||
int ichip = 0;
|
||||
|
||||
LOG(logDEBUG2, ("(Daisy) desired chip index:%d, nchip:%d, dac ch:%d, "
|
||||
"val:%d, cmd:0x%x \n",
|
||||
@@ -136,7 +135,7 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
// send same data to all
|
||||
if (chipIndex < 0) {
|
||||
LOG(logDEBUG2, ("Send same data to all\n"));
|
||||
for (ichip = 0; ichip < nchip; ++ichip) {
|
||||
for (int ichip = 0; ichip < nchip; ++ichip) {
|
||||
LOG(logDEBUG2, ("Send data (0x%x) to ichip %d\n", codata, ichip));
|
||||
LTC2620_SendDaisyData(&valw, codata);
|
||||
}
|
||||
@@ -146,7 +145,7 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
else {
|
||||
// send nothing to subsequent ichips (daisy chain) (if any chips after
|
||||
// desired chip)
|
||||
for (ichip = chipIndex + 1; ichip < nchip; ++ichip) {
|
||||
for (int ichip = chipIndex + 1; ichip < nchip; ++ichip) {
|
||||
LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip));
|
||||
LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL);
|
||||
}
|
||||
@@ -157,7 +156,7 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
|
||||
// send nothing to preceding ichips (daisy chain) (if any chips in front
|
||||
// of desired chip)
|
||||
for (ichip = 0; ichip < chipIndex; ++ichip) {
|
||||
for (int ichip = 0; ichip < chipIndex; ++ichip) {
|
||||
LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip));
|
||||
LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
#include "clogger.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <libgen.h> // dirname
|
||||
#include <unistd.h> // readlink
|
||||
|
||||
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
||||
int outputMax, int inputValue, int *outputValue) {
|
||||
LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n",
|
||||
@@ -37,3 +41,23 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
||||
LOG(logDEBUG1, (" Converted Output Value: %d\n", *outputValue));
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int getAbsPath(char* buf, size_t bufSize, char* fname) {
|
||||
// get path of current binary
|
||||
char path[bufSize];
|
||||
memset(path, 0, bufSize);
|
||||
ssize_t len = readlink("/proc/self/exe", path, bufSize - 1);
|
||||
if (len < 0) {
|
||||
LOG(logWARNING, ("Could not readlink current binary for %s\n", fname));
|
||||
return FAIL;
|
||||
}
|
||||
path[len] = '\0';
|
||||
|
||||
// get dir path and attach config file name
|
||||
char *dir = dirname(path);
|
||||
memset(buf, 0, bufSize);
|
||||
sprintf(buf, "%s/%s", dir, fname);
|
||||
LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf));
|
||||
return OK;
|
||||
}
|
||||
@@ -83,8 +83,7 @@ void sendDataToSPI(uint32_t *valw, uint32_t addr, uint32_t val,
|
||||
"clkmask:0x%x digmask:0x%x digofst:%d\n",
|
||||
*valw, addr, val, numbitstosend, clkmask, digoutmask, digofset));
|
||||
|
||||
int i = 0;
|
||||
for (i = 0; i < numbitstosend; ++i) {
|
||||
for (int i = 0; i < numbitstosend; ++i) {
|
||||
|
||||
// clk down
|
||||
(*valw) &= ~clkmask;
|
||||
@@ -112,9 +111,7 @@ uint32_t receiveDataFromSPI(uint32_t *valw, uint32_t addr, int numbitstoreceive,
|
||||
*valw, addr, numbitstoreceive, clkmask, readaddr));
|
||||
|
||||
uint32_t retval = 0;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < numbitstoreceive; ++i) {
|
||||
for (int i = 0; i < numbitstoreceive; ++i) {
|
||||
|
||||
// clk down
|
||||
(*valw) &= ~clkmask;
|
||||
|
||||
@@ -121,7 +121,6 @@ int bindSocket(unsigned short int port_number) {
|
||||
}
|
||||
|
||||
int acceptConnection(int socketDescriptor) {
|
||||
int j;
|
||||
struct sockaddr_in addressC;
|
||||
int file_des = -1;
|
||||
struct timeval tv;
|
||||
@@ -159,7 +158,7 @@ int acceptConnection(int socketDescriptor) {
|
||||
("%s select returned!\n", (isControlServer ? "control" : "stop")));
|
||||
|
||||
// loop through the file descriptor set
|
||||
for (j = 0; j < maxfd + 1; ++j) {
|
||||
for (int j = 0; j < maxfd + 1; ++j) {
|
||||
|
||||
// checks if file descriptor part of set
|
||||
if (FD_ISSET(j, &tempset)) {
|
||||
@@ -264,11 +263,10 @@ void exitServer(int socketDescriptor) {
|
||||
}
|
||||
|
||||
void swapData(void *val, int length, intType itype) {
|
||||
int i;
|
||||
int16_t *c = (int16_t *)val;
|
||||
int32_t *a = (int32_t *)val;
|
||||
int64_t *b = (int64_t *)val;
|
||||
for (i = 0; length > 0; i++) {
|
||||
for (int i = 0; length > 0; i++) {
|
||||
switch (itype) {
|
||||
case INT16:
|
||||
c[i] = ((c[i] & 0x00FF) << 8) | ((c[i] & 0xFF00) >> 8);
|
||||
@@ -406,68 +404,6 @@ int receiveDataOnly(int file_des, void *buf, int length) {
|
||||
return total_received;
|
||||
}
|
||||
|
||||
int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
int ts = 0, n = 0;
|
||||
n = sendData(file_des, &(myMod->serialnumber), sizeof(myMod->serialnumber),
|
||||
INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->nchip), sizeof(myMod->nchip), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->ndac), sizeof(myMod->ndac), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->reg), sizeof(myMod->reg), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->iodelay), sizeof(myMod->iodelay), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
n = sendData(file_des, &(myMod->eV), sizeof(myMod->eV), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
// dacs
|
||||
n = sendData(file_des, myMod->dacs, sizeof(int) * (myMod->ndac), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
// channels
|
||||
#if defined(EIGERD) || defined(MYTHEN3D)
|
||||
n = sendData(file_des, myMod->chanregs, sizeof(int) * (myMod->nchan),
|
||||
INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("module of size %d sent register %x\n", ts, myMod->reg));
|
||||
return ts;
|
||||
}
|
||||
|
||||
int receiveModule(int file_des, sls_detector_module *myMod) {
|
||||
enum TLogLevel level = logDEBUG1;
|
||||
LOG(level, ("Receiving Module\n"));
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_virtual.h"
|
||||
#include "clogger.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
|
||||
#define FILE_STATUS "/tmp/sls_virtual_server_status_"
|
||||
#define FILE_STOP "/tmp/sls_virtual_server_stop_"
|
||||
#define FD_STATUS 0
|
||||
#define FD_STOP 1
|
||||
#define FILE_NAME_LENGTH 1000
|
||||
|
||||
FILE *fd[2] = {NULL, NULL};
|
||||
char fnameStatus[FILE_NAME_LENGTH];
|
||||
char fnameStop[FILE_NAME_LENGTH];
|
||||
int portNumber = 0;
|
||||
|
||||
int ComVirtual_createFiles(const int port) {
|
||||
portNumber = port;
|
||||
// control server writign status file
|
||||
memset(fnameStatus, 0, FILE_NAME_LENGTH);
|
||||
sprintf(fnameStatus, "%s%d", FILE_STATUS, port);
|
||||
FILE *fd = NULL;
|
||||
if (NULL == (fd = fopen(fnameStatus, "w"))) {
|
||||
LOG(logERROR, ("Could not open the file %s for virtual communication\n",
|
||||
fnameStatus));
|
||||
return 0;
|
||||
}
|
||||
fclose(fd);
|
||||
LOG(logINFOBLUE, ("Created status file %s\n", fnameStatus));
|
||||
|
||||
// stop server writing stop file
|
||||
memset(fnameStop, 0, FILE_NAME_LENGTH);
|
||||
sprintf(fnameStop, "%s%d", FILE_STOP, port);
|
||||
if (NULL == (fd = fopen(fnameStop, "w"))) {
|
||||
LOG(logERROR, ("Could not open the file %s for virtual communication\n",
|
||||
fnameStop));
|
||||
return 0;
|
||||
}
|
||||
fclose(fd);
|
||||
LOG(logINFOBLUE, ("Created stop file %s\n", fnameStop));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ComVirtual_setFileNames(const int port) {
|
||||
portNumber = port;
|
||||
memset(fnameStatus, 0, FILE_NAME_LENGTH);
|
||||
memset(fnameStop, 0, FILE_NAME_LENGTH);
|
||||
sprintf(fnameStatus, "%s%d", FILE_STATUS, port);
|
||||
sprintf(fnameStop, "%s%d", FILE_STOP, port);
|
||||
}
|
||||
|
||||
void ComVirtual_setStatus(int value) {
|
||||
while (!ComVirtual_writeToFile(value, fnameStatus, "Control")) {
|
||||
usleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
int ComVirtual_getStatus() {
|
||||
int retval = 0;
|
||||
while (!ComVirtual_readFromFile(&retval, fnameStatus, "Stop")) {
|
||||
usleep(100);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void ComVirtual_setStop(int value) {
|
||||
while (!ComVirtual_writeToFile(value, fnameStop, "Stop")) {
|
||||
usleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
int ComVirtual_getStop() {
|
||||
int retval = 0;
|
||||
while (!ComVirtual_readFromFile(&retval, fnameStop, "Control")) {
|
||||
usleep(100);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int ComVirtual_writeToFile(int value, const char *fname,
|
||||
const char *serverName) {
|
||||
FILE *fd = NULL;
|
||||
if (NULL == (fd = fopen(fname, "w"))) {
|
||||
LOG(logERROR, ("Vritual %s Server [%d] could not open "
|
||||
"the file %s for writing\n",
|
||||
serverName, portNumber, fname));
|
||||
return 0;
|
||||
}
|
||||
while (fwrite(&value, sizeof(value), 1, fd) < 1) {
|
||||
LOG(logERROR, ("Vritual %s Server [%d] could not write "
|
||||
"to file %s\n",
|
||||
serverName, portNumber, fname));
|
||||
return 0;
|
||||
}
|
||||
fclose(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ComVirtual_readFromFile(int *value, const char *fname,
|
||||
const char *serverName) {
|
||||
FILE *fd = NULL;
|
||||
if (NULL == (fd = fopen(fname, "r"))) {
|
||||
LOG(logERROR, ("Vritual %s Server [%d] could not open "
|
||||
"the file %s for reading\n",
|
||||
serverName, portNumber, fname));
|
||||
return 0;
|
||||
}
|
||||
while (fread(value, sizeof(int), 1, fd) < 1) {
|
||||
LOG(logERROR, ("Vritual %s Server [%d] could not read "
|
||||
"from file %s\n",
|
||||
serverName, portNumber, fname));
|
||||
return 0;
|
||||
}
|
||||
fclose(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -89,8 +89,7 @@ int mapCSP0(void) {
|
||||
u_int32_t **cspbases[2] = {&csp0base, &csp1base};
|
||||
char names[2][10] = {"csp0base", "csp1base"};
|
||||
|
||||
int i = 0;
|
||||
for (i = 0; i < 2; ++i) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
// if not mapped
|
||||
if (*cspbases[i] == 0) {
|
||||
LOG(logINFO, ("Mapping memory for %s\n", names[i]));
|
||||
|
||||
@@ -3,33 +3,42 @@
|
||||
#include "clogger.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
extern char initErrorMessage[MAX_STR_LENGTH];
|
||||
extern int initError;
|
||||
|
||||
#ifndef MYTHEN3D
|
||||
extern uint64_t writePatternIOControl(uint64_t word);
|
||||
extern uint64_t writePatternClkControl(uint64_t word);
|
||||
#endif
|
||||
extern uint64_t writePatternWord(int addr, uint64_t word);
|
||||
extern int setPatternWaitAddress(int level, int addr);
|
||||
extern uint64_t setPatternWaitTime(int level, uint64_t t);
|
||||
extern void setPatternLoop(int level, int *startAddr, int *stopAddr,
|
||||
int *nLoop);
|
||||
|
||||
int loadDefaultPattern(char *fname) {
|
||||
int loadDefaultPattern(char *patFname) {
|
||||
if (initError == FAIL) {
|
||||
return initError;
|
||||
}
|
||||
|
||||
char fname[128];
|
||||
if (getAbsPath(fname, 128, patFname) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// open config file
|
||||
FILE *fd = fopen(fname, "r");
|
||||
if (fd == NULL) {
|
||||
sprintf(initErrorMessage, "Could not open pattern file [%s].\n", fname);
|
||||
sprintf(initErrorMessage, "Could not open pattern file [%s].\n",
|
||||
patFname);
|
||||
initError = FAIL;
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Reading default pattern file %s\n", fname));
|
||||
LOG(logINFOBLUE, ("Reading default pattern file %s\n", patFname));
|
||||
|
||||
// Initialization
|
||||
const size_t LZ = 256;
|
||||
@@ -104,6 +113,7 @@ int loadDefaultPattern(char *fname) {
|
||||
}
|
||||
|
||||
// patioctrl
|
||||
#ifndef MYTHEN3D
|
||||
if (!strncmp(line, "patioctrl", strlen("patioctrl"))) {
|
||||
uint64_t arg = 0;
|
||||
|
||||
@@ -124,28 +134,7 @@ int loadDefaultPattern(char *fname) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// patclkctrl
|
||||
if (!strncmp(line, "patclkctrl", strlen("patclkctrl"))) {
|
||||
uint64_t arg = 0;
|
||||
|
||||
// cannot scan values
|
||||
#ifdef VIRTUAL
|
||||
if (sscanf(line, "%s 0x%lx", command, &arg) != 2) {
|
||||
#else
|
||||
if (sscanf(line, "%s 0x%llx", command, &arg) != 2) {
|
||||
#endif
|
||||
sprintf(initErrorMessage,
|
||||
"Could not scan patclkctrl arguments from default "
|
||||
"pattern file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
|
||||
if (default_writePatternClkControl(line, arg) == FAIL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// patlimits
|
||||
if (!strncmp(line, "patlimits", strlen("patlimits"))) {
|
||||
@@ -323,6 +312,7 @@ int default_writePatternWord(char *line, uint32_t addr, uint64_t word) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifndef MYTHEN3D
|
||||
int default_writePatternIOControl(char *line, uint64_t arg) {
|
||||
uint64_t retval = writePatternIOControl(arg);
|
||||
if (retval != arg) {
|
||||
@@ -341,25 +331,7 @@ int default_writePatternIOControl(char *line, uint64_t arg) {
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int default_writePatternClkControl(char *line, uint64_t arg) {
|
||||
uint64_t retval = writePatternClkControl(arg);
|
||||
if (retval != arg) {
|
||||
#ifdef VIRTUAL
|
||||
sprintf(initErrorMessage,
|
||||
"Could not set patclkctrl from default pattern "
|
||||
"file. Set 0x%lx, read 0x%lx. Line:[%s]\n",
|
||||
arg, retval, line);
|
||||
#else
|
||||
sprintf(initErrorMessage,
|
||||
"Could not set patclkctrl from default pattern "
|
||||
"file. Set 0x%llx, read 0x%llx. Line:[%s]\n",
|
||||
arg, retval, line);
|
||||
#endif
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int default_setPatternLoopLimits(char *line, uint32_t startAddr,
|
||||
uint32_t stopAddr) {
|
||||
|
||||
204
slsDetectorServers/slsDetectorServer/src/sharedMemory.c
Normal file
204
slsDetectorServers/slsDetectorServer/src/sharedMemory.c
Normal file
@@ -0,0 +1,204 @@
|
||||
#include "sharedMemory.h"
|
||||
#include "clogger.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define SHM_NAME "sls_server_shared_memory"
|
||||
#define SHM_VERSION 0x200625
|
||||
#define SHM_KEY 5678
|
||||
#define MEM_SIZE 128
|
||||
|
||||
typedef struct Memory {
|
||||
int version;
|
||||
pthread_mutex_t lock;
|
||||
enum runStatus scanStatus; // idle, running or error
|
||||
int scanStop;
|
||||
#ifdef VIRTUAL
|
||||
enum runStatus status;
|
||||
int stop;
|
||||
#endif
|
||||
} sharedMem;
|
||||
|
||||
sharedMem *shm = NULL;
|
||||
int shmFd = -1;
|
||||
|
||||
extern int isControlServer;
|
||||
|
||||
void sharedMemory_print() {
|
||||
LOG(logINFO, ("%s Shared Memory:\n", isControlServer ? "c" : "s"));
|
||||
LOG(logINFO,
|
||||
("%s version:0x%x\n", isControlServer ? "c" : "s", shm->version));
|
||||
LOG(logINFO, ("%s scan status: %d\n", isControlServer ? "c" : "s",
|
||||
(int)shm->scanStatus));
|
||||
LOG(logINFO,
|
||||
("%s scan stop: %d\n", isControlServer ? "c" : "s", shm->scanStop));
|
||||
#ifdef VIRTUAL
|
||||
LOG(logINFO,
|
||||
("%s status: %d\n", isControlServer ? "c" : "s", (int)shm->status));
|
||||
LOG(logINFO, ("%s stop: %d\n", isControlServer ? "c" : "s", shm->stop));
|
||||
#endif
|
||||
}
|
||||
|
||||
int sharedMemory_create(int port) {
|
||||
// if shm existed, delete old shm and create again
|
||||
shmFd = shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | IPC_EXCL | 0666);
|
||||
if (shmFd == -1 && errno == EEXIST) {
|
||||
// open existing one
|
||||
shmFd = shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | 0666);
|
||||
if (shmFd == -1) {
|
||||
LOG(logERROR,
|
||||
("c: open existing shared memory (to delete) failed: %s\n",
|
||||
strerror(errno)));
|
||||
return FAIL;
|
||||
}
|
||||
// delete existing one
|
||||
sharedMemory_remove();
|
||||
LOG(logWARNING, ("Removed old shared memory with id 0x%x (%d)\n",
|
||||
SHM_KEY + port, SHM_KEY + port));
|
||||
|
||||
// create it again with current structure
|
||||
shmFd = shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | IPC_EXCL | 0666);
|
||||
}
|
||||
if (shmFd == -1) {
|
||||
LOG(logERROR, ("Create shared memory failed: %s\n", strerror(errno)));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("Shared memory created with key 0x%x\n", SHM_KEY + port));
|
||||
if (sharedMemory_attach() == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
if (sharedMemory_initialize() == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int sharedMemory_initialize() {
|
||||
shm->version = SHM_VERSION;
|
||||
if (pthread_mutex_init(&(shm->lock), NULL) != 0) {
|
||||
LOG(logERROR,
|
||||
("Failed to initialize pthread lock for shared memory\n"));
|
||||
return FAIL;
|
||||
}
|
||||
shm->scanStatus = IDLE;
|
||||
shm->scanStop = 0;
|
||||
#ifdef VIRTUAL
|
||||
shm->status = IDLE;
|
||||
shm->stop = 0;
|
||||
#endif
|
||||
LOG(logINFO, ("Shared memory initialized\n"))
|
||||
return OK;
|
||||
}
|
||||
|
||||
int sharedMemory_open(int port) {
|
||||
shmFd = shmget(SHM_KEY + port, MEM_SIZE, 0666);
|
||||
if (shmFd == -1) {
|
||||
LOG(logERROR, ("Open shared memory failed: %s\n", strerror(errno)));
|
||||
return FAIL;
|
||||
}
|
||||
if (sharedMemory_attach() == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
if (shm->version != SHM_VERSION) {
|
||||
LOG(logERROR,
|
||||
("Shared memory version 0x%x does not match! (expected: 0x%x)\n",
|
||||
shm->version, SHM_VERSION));
|
||||
}
|
||||
LOG(logINFO, ("Shared memory opened\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int sharedMemory_attach() {
|
||||
shm = (sharedMem *)shmat(shmFd, NULL, 0);
|
||||
if (shm == (void *)-1) {
|
||||
LOG(logERROR, ("could not attach: %s\n", strerror(errno)));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("Shared memory attached\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int sharedMemory_detach() {
|
||||
if (shmdt(shm) == -1) {
|
||||
LOG(logERROR, ("could not detach: %s\n", strerror(errno)));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("Shared memory detached\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int sharedMemory_remove() {
|
||||
if (shmctl(shmFd, IPC_RMID, NULL) == -1) {
|
||||
LOG(logERROR, ("could not remove: %s\n", strerror(errno)));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("Shared memory removed\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
void sharedMemory_lock() { pthread_mutex_lock(&(shm->lock)); }
|
||||
|
||||
void sharedMemory_unlock() { pthread_mutex_unlock(&(shm->lock)); }
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void sharedMemory_setStatus(enum runStatus s) {
|
||||
sharedMemory_lock();
|
||||
shm->status = s;
|
||||
sharedMemory_unlock();
|
||||
}
|
||||
|
||||
enum runStatus sharedMemory_getStatus() {
|
||||
enum runStatus s = 0;
|
||||
sharedMemory_lock();
|
||||
s = shm->status;
|
||||
sharedMemory_unlock();
|
||||
return s;
|
||||
}
|
||||
|
||||
void sharedMemory_setStop(int s) {
|
||||
sharedMemory_lock();
|
||||
shm->stop = s;
|
||||
sharedMemory_unlock();
|
||||
}
|
||||
|
||||
int sharedMemory_getStop() {
|
||||
int s = 0;
|
||||
sharedMemory_lock();
|
||||
s = shm->stop;
|
||||
sharedMemory_unlock();
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
void sharedMemory_setScanStatus(enum runStatus s) {
|
||||
sharedMemory_lock();
|
||||
shm->scanStatus = s;
|
||||
sharedMemory_unlock();
|
||||
}
|
||||
|
||||
enum runStatus sharedMemory_getScanStatus() {
|
||||
enum runStatus s = IDLE;
|
||||
sharedMemory_lock();
|
||||
s = shm->scanStatus;
|
||||
sharedMemory_unlock();
|
||||
return s;
|
||||
}
|
||||
|
||||
void sharedMemory_setScanStop(int s) {
|
||||
sharedMemory_lock();
|
||||
shm->scanStop = s;
|
||||
sharedMemory_unlock();
|
||||
}
|
||||
|
||||
int sharedMemory_getScanStop() {
|
||||
int s = 0;
|
||||
sharedMemory_lock();
|
||||
s = shm->scanStop;
|
||||
sharedMemory_unlock();
|
||||
return s;
|
||||
}
|
||||
@@ -3,13 +3,11 @@
|
||||
|
||||
#include "clogger.h"
|
||||
#include "communication_funcs.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
#include "slsDetectorServer_funcs.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "versionAPI.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
@@ -31,6 +29,11 @@ extern int phaseShift;
|
||||
|
||||
void error(char *msg) { perror(msg); }
|
||||
|
||||
void sigInterruptHandler(int p) {
|
||||
sharedMemory_remove();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// print version
|
||||
@@ -60,89 +63,90 @@ int main(int argc, char *argv[]) {
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
// circumvent the basic tests
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (!strcasecmp(argv[i], "-stopserver")) {
|
||||
LOG(logINFO, ("Detected stop server\n"));
|
||||
isControlServer = 0;
|
||||
} else if (!strcasecmp(argv[i], "-devel")) {
|
||||
LOG(logINFO, ("Detected developer mode\n"));
|
||||
debugflag = 1;
|
||||
} else if (!strcasecmp(argv[i], "-nomodule")) {
|
||||
LOG(logINFO, ("Detected No Module mode\n"));
|
||||
checkModuleFlag = 0;
|
||||
} else if (!strcasecmp(argv[i], "-port")) {
|
||||
if ((i + 1) >= argc) {
|
||||
LOG(logERROR, ("no port value given. Exiting.\n"));
|
||||
return -1;
|
||||
}
|
||||
if (sscanf(argv[i + 1], "%d", &portno) == 0) {
|
||||
LOG(logERROR, ("cannot decode port value %s. Exiting.\n",
|
||||
argv[i + 1]));
|
||||
return -1;
|
||||
}
|
||||
LOG(logINFO, ("Detected port: %d\n", portno));
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (!strcasecmp(argv[i], "-stopserver")) {
|
||||
LOG(logINFO, ("Detected stop server\n"));
|
||||
isControlServer = 0;
|
||||
} else if (!strcasecmp(argv[i], "-devel")) {
|
||||
LOG(logINFO, ("Detected developer mode\n"));
|
||||
debugflag = 1;
|
||||
} else if (!strcasecmp(argv[i], "-nomodule")) {
|
||||
LOG(logINFO, ("Detected No Module mode\n"));
|
||||
checkModuleFlag = 0;
|
||||
} else if (!strcasecmp(argv[i], "-port")) {
|
||||
if ((i + 1) >= argc) {
|
||||
LOG(logERROR, ("no port value given. Exiting.\n"));
|
||||
return -1;
|
||||
}
|
||||
#ifdef GOTTHARDD
|
||||
else if (!strcasecmp(argv[i], "-phaseshift")) {
|
||||
if ((i + 1) >= argc) {
|
||||
LOG(logERROR, ("no phase shift value given. Exiting.\n"));
|
||||
return -1;
|
||||
}
|
||||
if (sscanf(argv[i + 1], "%d", &phaseShift) == 0) {
|
||||
LOG(logERROR,
|
||||
("cannot decode phase shift value %s. Exiting.\n",
|
||||
argv[i + 1]));
|
||||
return -1;
|
||||
}
|
||||
LOG(logINFO, ("Detected phase shift of %d\n", phaseShift));
|
||||
if (sscanf(argv[i + 1], "%d", &portno) == 0) {
|
||||
LOG(logERROR,
|
||||
("cannot decode port value %s. Exiting.\n", argv[i + 1]));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
LOG(logINFO, ("Detected port: %d\n", portno));
|
||||
}
|
||||
#ifdef GOTTHARDD
|
||||
else if (!strcasecmp(argv[i], "-phaseshift")) {
|
||||
if ((i + 1) >= argc) {
|
||||
LOG(logERROR, ("no phase shift value given. Exiting.\n"));
|
||||
return -1;
|
||||
}
|
||||
if (sscanf(argv[i + 1], "%d", &phaseShift) == 0) {
|
||||
LOG(logERROR, ("cannot decode phase shift value %s. Exiting.\n",
|
||||
argv[i + 1]));
|
||||
return -1;
|
||||
}
|
||||
LOG(logINFO, ("Detected phase shift of %d\n", phaseShift));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// control server
|
||||
if (isControlServer) {
|
||||
LOG(logINFOBLUE, ("Control Server [%d]\n", portno));
|
||||
|
||||
// Catch signal SIGINT to destroy shm properly
|
||||
struct sigaction sa;
|
||||
sa.sa_flags = 0; // no flags
|
||||
sa.sa_handler = sigInterruptHandler; // handler function
|
||||
sigemptyset(&sa.sa_mask); // dont block additional signals during
|
||||
// invocation of handler
|
||||
if (sigaction(SIGINT, &sa, NULL) == -1) {
|
||||
LOG(logERROR, ("Could not set handler function for SIGINT"));
|
||||
}
|
||||
|
||||
if (sharedMemory_create(portno) == FAIL) {
|
||||
return -1;
|
||||
}
|
||||
#ifdef STOP_SERVER
|
||||
// start stop server process
|
||||
char cmd[MAX_STR_LENGTH];
|
||||
memset(cmd, 0, MAX_STR_LENGTH);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < argc; ++i) {
|
||||
if (!strcasecmp(argv[i], "-port")) {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
if (i > 0) {
|
||||
strcat(cmd, " ");
|
||||
}
|
||||
strcat(cmd, argv[i]);
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
if (!strcasecmp(argv[i], "-port")) {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
char temp[50];
|
||||
memset(temp, 0, sizeof(temp));
|
||||
sprintf(temp, " -stopserver -port %d &", portno + 1);
|
||||
strcat(cmd, temp);
|
||||
if (i > 0) {
|
||||
strcat(cmd, " ");
|
||||
}
|
||||
strcat(cmd, argv[i]);
|
||||
}
|
||||
char temp[50];
|
||||
memset(temp, 0, sizeof(temp));
|
||||
sprintf(temp, " -stopserver -port %d &", portno + 1);
|
||||
strcat(cmd, temp);
|
||||
|
||||
LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
|
||||
system(cmd);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Control Server [%d]\n", portno));
|
||||
#ifdef VIRTUAL
|
||||
// creating files for virtual servers to communicate with each other
|
||||
if (!ComVirtual_createFiles(portno)) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
|
||||
system(cmd);
|
||||
#endif
|
||||
}
|
||||
// stop server
|
||||
else {
|
||||
LOG(logINFOBLUE, ("Stop Server [%d]\n", portno));
|
||||
#ifdef VIRTUAL
|
||||
ComVirtual_setFileNames(portno - 1);
|
||||
#endif
|
||||
if (sharedMemory_open(portno - 1) == FAIL) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
init_detector();
|
||||
@@ -171,6 +175,17 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
exitServer(sockfd);
|
||||
|
||||
// detach shared memory
|
||||
if (sharedMemory_detach() == FAIL) {
|
||||
return -1;
|
||||
}
|
||||
// remove shared memory (control server)
|
||||
if (isControlServer) {
|
||||
if (sharedMemory_remove() == FAIL) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (retval == REBOOT) {
|
||||
LOG(logINFORED, ("Rebooting!\n"));
|
||||
fflush(stdout);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user