mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 16:27:13 +02:00
Compare commits
154 Commits
2020.09.09
...
2020.09.24
Author | SHA1 | Date | |
---|---|---|---|
aa3af2f0ce | |||
e4615a11bb | |||
c01ce3d514 | |||
99642dad69 | |||
2c1fddee84 | |||
c862f1df81 | |||
671a2724ac | |||
9c5d8cfcd7 | |||
8483e05f4c | |||
d96352f2ae | |||
0f65633ea3 | |||
18d5c5e26d | |||
3f19f29c9e | |||
101f029eef | |||
97fea10ee2 | |||
d3fbfebeb7 | |||
50fd9276ce | |||
1f31dd667b | |||
18cd363f8f | |||
0b0f5c94d5 | |||
23720e3c63 | |||
3432343adb | |||
d06e0d1e7f | |||
750adffe6a | |||
0b02fabaf8 | |||
4aa33b5d7f | |||
40a1d27e3a | |||
b23410bc5e | |||
b6d5efd441 | |||
79a03c6c92 | |||
330df3463a | |||
11754fbb5e | |||
e786b9f037 | |||
bd4299fd15 | |||
a4bdffd0b9 | |||
bb575c6017 | |||
65da9e701b | |||
804ad0997c | |||
2fc0768ad1 | |||
ca0192e27e | |||
4ad486fda0 | |||
cf8581caaa | |||
a8cc47d25c | |||
d50c40e2ad | |||
f6a442fd10 | |||
f5b8681811 | |||
54ca9f7ebb | |||
9920987b4d | |||
569c014d3c | |||
608b71d5ea | |||
c83daab56d | |||
d65030f5ca | |||
c3366a6748 | |||
7c21aa96a9 | |||
d028a120bb | |||
f6dd02acc2 | |||
0906efaf31 | |||
8ef79ce173 | |||
539c0c295b | |||
e91420bd16 | |||
515a0c05b9 | |||
46b75c1429 | |||
092b3fa8b9 | |||
a7e24717a9 | |||
e01e41926c | |||
44a8ce864b | |||
e18f10051e | |||
d9bb028da2 | |||
6d01348bf4 | |||
e8cd75a6ac | |||
d945f39142 | |||
ac1e9569b5 | |||
ea1b41c84a | |||
b0dd82c667 | |||
bf69951456 | |||
2d2e80469c | |||
5d648443fa | |||
1fb7352378 | |||
511c206787 | |||
74edb6a1c1 | |||
3376f7fa37 | |||
bfe36085f2 | |||
f061d2273a | |||
b12ae5d929 | |||
2285061623 | |||
e10ebe33d7 | |||
01921bc016 | |||
aa10c4665f | |||
f644cba244 | |||
884da7197e | |||
8ae0659478 | |||
ad95f729dc | |||
3b071cc43f | |||
2805359cd0 | |||
1515b79c97 | |||
2ab4bb1c04 | |||
5214c0f1a4 | |||
60bc3a8fa7 | |||
00f780665f | |||
ab738790e0 | |||
d4cff5b99c | |||
84f49a9b27 | |||
a4926e6ae1 | |||
cf8785ad2e | |||
be8284f5c2 | |||
3fd32b2c9c | |||
d70090967d | |||
88fe306902 | |||
d931416def | |||
6cfaa92b61 | |||
c94dfde17c | |||
b879a377ba | |||
d420451751 | |||
2bc33ad34a | |||
cb23e827bf | |||
a0f915316e | |||
2733bc5320 | |||
3b82e9fcc1 | |||
a95d8f664a | |||
11e7d89da3 | |||
34043c358f | |||
da9c7c354e | |||
4d499e231d | |||
0a7809286b | |||
00abb5e14b | |||
22c2bb0258 | |||
9d1cd09fd4 | |||
80b053eb10 | |||
3cd4f3897b | |||
d011186b9a | |||
669c14d6d5 | |||
ecabc94ade | |||
c58a2d957d | |||
1b214778a5 | |||
d5f6cbc075 | |||
52303daffd | |||
02d4769f6a | |||
a9d1a78662 | |||
3cf2160a2d | |||
4917812bb0 | |||
a0f9c6fe8c | |||
82e978e901 | |||
04bf2aca6d | |||
97687f0f6d | |||
bfbfe204f4 | |||
67d57eb5cd | |||
f940c09290 | |||
30293b1d36 | |||
87bad38f80 | |||
67f1f9924a | |||
e1e04ee755 | |||
6e06d4307d | |||
20a959bf61 | |||
8e49a114db |
@ -38,6 +38,7 @@ set(SPHINX_SOURCE_FILES
|
|||||||
src/pydetector.rst
|
src/pydetector.rst
|
||||||
src/pyenums.rst
|
src/pyenums.rst
|
||||||
src/pyexamples.rst
|
src/pyexamples.rst
|
||||||
|
src/servers.rst
|
||||||
src/receiver.rst
|
src/receiver.rst
|
||||||
src/result.rst
|
src/result.rst
|
||||||
src/type_traits.rst
|
src/type_traits.rst
|
||||||
@ -57,8 +58,21 @@ configure_file(
|
|||||||
"${SPHINX_BUILD}/conf.py"
|
"${SPHINX_BUILD}/conf.py"
|
||||||
@ONLY)
|
@ONLY)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/gen_server_doc.py.in"
|
||||||
|
"${SPHINX_BUILD}/gen_server_doc.py"
|
||||||
|
@ONLY)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/static/extra.css"
|
||||||
|
"${SPHINX_BUILD}/static/css/extra.css"
|
||||||
|
@ONLY)
|
||||||
|
|
||||||
|
add_custom_target(server_rst python gen_server_doc.py)
|
||||||
|
|
||||||
add_custom_target(docs
|
add_custom_target(docs
|
||||||
gendoc
|
gendoc
|
||||||
|
COMMAND python gen_server_doc.py
|
||||||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
|
||||||
COMMAND ${SPHINX_EXECUTABLE} -a -b html
|
COMMAND ${SPHINX_EXECUTABLE} -a -b html
|
||||||
-Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml
|
-Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml
|
||||||
@ -74,3 +88,4 @@ add_custom_target(rst
|
|||||||
${SPHINX_BUILD}/src
|
${SPHINX_BUILD}/src
|
||||||
${SPHINX_BUILD}/html
|
${SPHINX_BUILD}/html
|
||||||
COMMENT "Generating documentation with Sphinx")
|
COMMENT "Generating documentation with Sphinx")
|
||||||
|
|
||||||
|
@ -59,4 +59,8 @@ html_theme = "sphinx_rtd_theme"
|
|||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# 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,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
#html_static_path = ['_static']
|
html_static_path = ['static']
|
||||||
|
|
||||||
|
|
||||||
|
def setup(app):
|
||||||
|
app.add_stylesheet('css/extra.css') # may also be an URL
|
86
docs/gen_server_doc.py.in
Normal file
86
docs/gen_server_doc.py.in
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
import os
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
def remove_comments(text):
|
||||||
|
def replacer(match):
|
||||||
|
s = match.group(0)
|
||||||
|
if s.startswith('/'):
|
||||||
|
return " " # note: a space and not an empty string
|
||||||
|
else:
|
||||||
|
return s
|
||||||
|
pattern = re.compile(
|
||||||
|
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
|
||||||
|
re.DOTALL | re.MULTILINE
|
||||||
|
)
|
||||||
|
return re.sub(pattern, replacer, text)
|
||||||
|
|
||||||
|
|
||||||
|
# @CMAKE_CURRENT_BINARY_DIR@
|
||||||
|
|
||||||
|
print('\n\n\n\n SERVER CSV')
|
||||||
|
|
||||||
|
src = Path('@CMAKE_SOURCE_DIR@')/'slsDetectorServers/'
|
||||||
|
detectors = ['Mythen3', 'Gotthard2', 'Eiger',
|
||||||
|
'Jungfrau', 'Moench', 'Gotthard', 'Ctb']
|
||||||
|
|
||||||
|
|
||||||
|
for det in detectors:
|
||||||
|
print(det)
|
||||||
|
in_fname = src/f'{det.lower()}DetectorServer/slsDetectorServer_defs.h'
|
||||||
|
#print(f'Reading: {in_fname}')
|
||||||
|
with open(in_fname) as f:
|
||||||
|
lines = f.read().replace('\\\n', '')
|
||||||
|
lines = lines.splitlines(keepends = True)
|
||||||
|
|
||||||
|
lines = [l.strip('#define').strip(' ') for l in lines if l.startswith('#define')]
|
||||||
|
output = []
|
||||||
|
signals = []
|
||||||
|
fields = ['Name,', 'Value', 'Comment']
|
||||||
|
excluded = ['DAC_NAMES', 'DEFAULT_DAC_VALS', 'CLK_NAMES', 'ONCHIP_DAC_NAMES']
|
||||||
|
header = f'{fields[0]:35}{fields[1]:35}\n'
|
||||||
|
output.append(header)
|
||||||
|
signals.append(header)
|
||||||
|
dac_names = []
|
||||||
|
dac_values = []
|
||||||
|
for line in lines:
|
||||||
|
name, *parts = line.split()
|
||||||
|
arg = ' '.join(parts)
|
||||||
|
value, *comments = arg.split('//')
|
||||||
|
value = value.strip('() ')
|
||||||
|
# value = value.replace(', ', ' ')
|
||||||
|
value = value.replace('\"', '')
|
||||||
|
if name not in excluded:
|
||||||
|
name += ','
|
||||||
|
if name.startswith('SIGNAL_'):
|
||||||
|
signals.append(f'{name:35}{value}\n')
|
||||||
|
else:
|
||||||
|
output.append(f'{name:35}\"{value}\"\n')
|
||||||
|
elif name == 'DAC_NAMES':
|
||||||
|
dac_names = [v.strip(', ') for v in value.split()]
|
||||||
|
dac_names = [n+',' for n in dac_names]
|
||||||
|
elif name == 'DEFAULT_DAC_VALS':
|
||||||
|
dac_values = remove_comments(value).strip('{}; ')
|
||||||
|
dac_values = dac_values.replace(',', '').split()
|
||||||
|
dac_values = [v.strip('') for v in dac_values]
|
||||||
|
|
||||||
|
print(f"dac_names: {len(dac_names)}, dac_values={len(dac_values)}")
|
||||||
|
if len(dac_values) == 0:
|
||||||
|
dac_values = ['N/A']*len(dac_names)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rstpath = Path('@CMAKE_SOURCE_DIR@')/'docs/src/'
|
||||||
|
|
||||||
|
out_fname = Path.cwd()/f'src/{det.lower()}.csv'
|
||||||
|
out_dac_fname = Path.cwd()/f'src/{det.lower()}-dacs.csv'
|
||||||
|
#print(f'Writing: {out_fname}')
|
||||||
|
with open(out_fname, 'w') as f:
|
||||||
|
f.writelines(output)
|
||||||
|
|
||||||
|
output = [f'{n:35}{v}\n' for n,v in zip(dac_names, dac_values)]
|
||||||
|
output.insert(0, header)
|
||||||
|
|
||||||
|
with open(out_dac_fname, 'w') as f:
|
||||||
|
f.writelines(output)
|
||||||
|
|
||||||
|
print('END\n\n\n\n')
|
@ -50,6 +50,11 @@ Welcome to slsDetectorPackage's documentation!
|
|||||||
type_traits
|
type_traits
|
||||||
ToString
|
ToString
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:caption: Servers
|
||||||
|
|
||||||
|
servers
|
||||||
|
|
||||||
.. Indices and tables
|
.. Indices and tables
|
||||||
.. ==================
|
.. ==================
|
||||||
|
|
||||||
|
108
docs/src/servers.rst
Normal file
108
docs/src/servers.rst
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
Default values
|
||||||
|
==============================================
|
||||||
|
|
||||||
|
Some general intro
|
||||||
|
|
||||||
|
Mythen3
|
||||||
|
-------------
|
||||||
|
|
||||||
|
.. csv-table:: Default values
|
||||||
|
:file: mythen3.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
DACS
|
||||||
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. csv-table:: Mythen3 DACS
|
||||||
|
:file: mythen3-dacs.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
Gotthard2
|
||||||
|
-------------
|
||||||
|
|
||||||
|
.. csv-table:: Default values
|
||||||
|
:file: gotthard2.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
DACS
|
||||||
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. csv-table:: Gotthard 2 DACS
|
||||||
|
:file: gotthard2-dacs.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
Moench
|
||||||
|
-------------
|
||||||
|
|
||||||
|
.. csv-table:: Default values
|
||||||
|
:file: moench.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
DACS
|
||||||
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. csv-table:: Moench DACS
|
||||||
|
:file: moench-dacs.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
Ctb
|
||||||
|
-------------
|
||||||
|
|
||||||
|
.. csv-table:: Default values
|
||||||
|
:file: ctb.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
Eiger
|
||||||
|
-------------
|
||||||
|
|
||||||
|
.. csv-table:: Default values
|
||||||
|
:file: eiger.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
DACS
|
||||||
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. csv-table:: Eiger DACS
|
||||||
|
:file: eiger-dacs.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
Jungfrau
|
||||||
|
-------------
|
||||||
|
|
||||||
|
.. csv-table:: Default values
|
||||||
|
:file: jungfrau.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
DACS
|
||||||
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. csv-table:: Jungfrau DACS
|
||||||
|
:file: jungfrau-dacs.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
Gotthard
|
||||||
|
-------------
|
||||||
|
|
||||||
|
.. csv-table:: Default values
|
||||||
|
:file: gotthard.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
DACS
|
||||||
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. csv-table:: Gotthard DACS
|
||||||
|
:file: gotthard-dacs.csv
|
||||||
|
:widths: 35, 35
|
||||||
|
:header-rows: 1
|
4
docs/static/extra.css
vendored
Normal file
4
docs/static/extra.css
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/* override table no-wrap */
|
||||||
|
.wy-table-responsive table td, .wy-table-responsive table th {
|
||||||
|
white-space: normal;
|
||||||
|
}
|
@ -41,11 +41,11 @@ hostname bchip074+bchip075+
|
|||||||
|
|
||||||
|
|
||||||
r_readfreq 1
|
r_readfreq 1
|
||||||
rx_datastream 1
|
rx_zmqstream 1
|
||||||
|
|
||||||
#replace my_receiver_hostname with the hostname of 1Gb IP of the machine where the receiver runs
|
#replace my_receiver_hostname with the hostname of 1Gb IP of the machine where the receiver runs
|
||||||
rx_hostname my_receiver_hostname
|
rx_hostname my_receiver_hostname
|
||||||
rx_datastream 1
|
rx_zmqstream 1
|
||||||
outdir /tmp/
|
outdir /tmp/
|
||||||
|
|
||||||
|
|
||||||
|
@ -459,8 +459,8 @@ rx_hostname mpc2011
|
|||||||
|
|
||||||
tengiga 1
|
tengiga 1
|
||||||
|
|
||||||
rx_datastream 1
|
rx_zmqstream 1
|
||||||
rx_readfreq 1
|
rx_zmqfreq 1
|
||||||
|
|
||||||
|
|
||||||
dac 6 800
|
dac 6 800
|
||||||
|
@ -35,7 +35,7 @@ zmqport 50001
|
|||||||
|
|
||||||
|
|
||||||
tengiga 1
|
tengiga 1
|
||||||
rx_datastream 1
|
rx_zmqstream 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ period 0.0006
|
|||||||
############################################
|
############################################
|
||||||
fpath /mnt/moench_data/scratch/
|
fpath /mnt/moench_data/scratch/
|
||||||
fwrite 0
|
fwrite 0
|
||||||
rx_datastream 1
|
rx_zmqstream 1
|
||||||
|
|
||||||
rx_jsonpara frameMode frame
|
rx_jsonpara frameMode frame
|
||||||
rx_jsonpara detectorMode counting
|
rx_jsonpara detectorMode counting
|
||||||
|
@ -35,7 +35,7 @@ set( PYTHON_FILES
|
|||||||
gotthard.py
|
gotthard.py
|
||||||
gotthard2.py
|
gotthard2.py
|
||||||
moench.py
|
moench.py
|
||||||
jsonproxy.py
|
proxy.py
|
||||||
ctb.py
|
ctb.py
|
||||||
jungfrau.py
|
jungfrau.py
|
||||||
mythen3.py
|
mythen3.py
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
import pytest
|
|
||||||
import datetime as dt
|
|
||||||
from slsdet import Detector, timingMode, detectorType
|
|
||||||
|
|
||||||
not_eiger = pytest.mark.skipif(
|
|
||||||
Detector().type == detectorType.EIGER, reason="Does not work for eiger"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def det():
|
|
||||||
from slsdet import Detector
|
|
||||||
|
|
||||||
return Detector()
|
|
||||||
|
|
||||||
|
|
||||||
def test_frames(det):
|
|
||||||
for n in [1, 100, 3245, 10000]:
|
|
||||||
det.frames = n
|
|
||||||
assert det.frames == n
|
|
||||||
det.frames = 1
|
|
||||||
|
|
||||||
|
|
||||||
def test_triggers(det):
|
|
||||||
for n in [1, 100, 3245, 10000]:
|
|
||||||
det.triggers = n
|
|
||||||
assert det.triggers == n
|
|
||||||
det.triggers = 1
|
|
||||||
|
|
||||||
|
|
||||||
def test_exptime(det):
|
|
||||||
det.exptime = 1
|
|
||||||
assert det.exptime == 1
|
|
||||||
det.exptime = dt.timedelta(milliseconds=10)
|
|
||||||
assert det.exptime == 0.01
|
|
||||||
det.exptime = 1
|
|
||||||
|
|
||||||
|
|
||||||
def test_period(det):
|
|
||||||
det.period = 3.2
|
|
||||||
assert det.period == 3.2
|
|
||||||
|
|
||||||
p = dt.timedelta(microseconds=1020)
|
|
||||||
det.period = p
|
|
||||||
assert det.period == 0.001020
|
|
||||||
r = det.getPeriod()
|
|
||||||
assert r[0] == p
|
|
||||||
det.period = 0
|
|
||||||
assert det.period == 0
|
|
||||||
|
|
||||||
|
|
||||||
def test_lock(det):
|
|
||||||
for l in [True, False]:
|
|
||||||
det.lock = l
|
|
||||||
assert det.lock == l
|
|
||||||
|
|
||||||
|
|
||||||
def test_timing(det):
|
|
||||||
# auto and trigger is available for all det
|
|
||||||
for m in [timingMode.TRIGGER_EXPOSURE, timingMode.AUTO_TIMING]:
|
|
||||||
det.timing = m
|
|
||||||
assert det.timing == m
|
|
||||||
|
|
||||||
@not_eiger
|
|
||||||
def test_delay(det):
|
|
||||||
det.delay = 1
|
|
||||||
assert det.delay == 1
|
|
||||||
|
|
||||||
t = dt.timedelta(microseconds=1)
|
|
||||||
det.delay = t
|
|
||||||
assert det.delay == t.total_seconds()
|
|
||||||
|
|
||||||
r = det.getDelayAfterTrigger()[0]
|
|
||||||
assert r == t
|
|
||||||
|
|
||||||
det.delay = 0
|
|
||||||
assert det.delay == 0
|
|
||||||
|
|
||||||
|
|
||||||
@not_eiger
|
|
||||||
def test_delayl(det):
|
|
||||||
assert det.delayl == 0
|
|
@ -1,89 +0,0 @@
|
|||||||
import pytest
|
|
||||||
import datetime as dt
|
|
||||||
from slsdet import Detector, detectorType
|
|
||||||
|
|
||||||
"""
|
|
||||||
These tests are designed to work the API and catch
|
|
||||||
any changes in behavior or naming. Tests are expected
|
|
||||||
to pass with a virtual detector or a real one
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def jf():
|
|
||||||
from slsdet import Jungfrau
|
|
||||||
return Jungfrau()
|
|
||||||
|
|
||||||
|
|
||||||
jungfrautest = pytest.mark.skipif(
|
|
||||||
Detector().type != detectorType.JUNGFRAU, reason="Only valid for Jungfrau"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_storagecells(jf):
|
|
||||||
for i in range(16):
|
|
||||||
jf.storagecells = i
|
|
||||||
assert jf.storagecells == i
|
|
||||||
jf.storagecells = 0 # default
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_storagecell_start(jf):
|
|
||||||
for i in range(16):
|
|
||||||
jf.storagecell_start = i
|
|
||||||
assert jf.storagecell_start == i
|
|
||||||
jf.storagecells = 15 # default
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_storagecell_delay(jf):
|
|
||||||
for t in [0.001, 0.0002, 0.0013]:
|
|
||||||
jf.storagecell_delay = t
|
|
||||||
assert jf.storagecell_delay == t
|
|
||||||
jf.storagecell_delay = 0 # default
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_temp_event(jf):
|
|
||||||
# hard to test with virtual server
|
|
||||||
assert jf.temp_event == 0
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_temp_threshold(jf):
|
|
||||||
for th in [0, 10, 43, 72]:
|
|
||||||
jf.temp_threshold = th
|
|
||||||
assert jf.temp_threshold == th
|
|
||||||
jf.temp_threshold = 0
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_auto_comp_disable(jf):
|
|
||||||
for v in [True, False]:
|
|
||||||
jf.auto_comp_disable = v
|
|
||||||
assert jf.auto_comp_disable == v
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_numinterfaces(jf):
|
|
||||||
for n in [2, 1]:
|
|
||||||
jf.numinterfaces = n
|
|
||||||
assert jf.numinterfaces == n
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_dr(jf):
|
|
||||||
assert jf.dr == 16
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_temp_control(jf):
|
|
||||||
for v in [True, False]:
|
|
||||||
jf.temp_control = v
|
|
||||||
assert jf.temp_control == v
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_startingfnum(jf):
|
|
||||||
for n in [10, 127, 43321, 1]:
|
|
||||||
jf.startingfnum = n
|
|
||||||
assert jf.startingfnum == n
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_selinterface(jf):
|
|
||||||
for i in [1, 0]:
|
|
||||||
jf.selinterface = i
|
|
||||||
assert jf.selinterface == i
|
|
@ -1,11 +1,14 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from pathlib import Path
|
||||||
sys.path.append(os.path.join(os.getcwd(), 'bin'))
|
sys.path.append(os.path.join(os.getcwd(), 'bin'))
|
||||||
|
|
||||||
from slsdet import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb, Gotthard2, Moench
|
from slsdet import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb, Gotthard2, Moench
|
||||||
from slsdet import dacIndex, readoutMode
|
from slsdet import dacIndex, readoutMode
|
||||||
from slsdet.lookup import view, find
|
from slsdet.lookup import view, find
|
||||||
|
import slsdet
|
||||||
|
|
||||||
|
|
||||||
d = Detector()
|
d = Detector()
|
||||||
e = Eiger()
|
e = Eiger()
|
||||||
|
@ -1,98 +0,0 @@
|
|||||||
import subprocess
|
|
||||||
import locale
|
|
||||||
out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
|
|
||||||
cmd = out.stdout.splitlines()
|
|
||||||
cmd.pop(0)
|
|
||||||
|
|
||||||
from slsdet import Detector, Eiger, Ctb
|
|
||||||
|
|
||||||
pycmd = dir(Detector)+dir(Eiger)+dir(Ctb)
|
|
||||||
|
|
||||||
#Add commands that we should not expect as direct commands in python
|
|
||||||
pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim',
|
|
||||||
'vsvp', 'vth1', 'vth2', 'vth3', 'vshaper', 'vshaperneg', 'rxb_rb',
|
|
||||||
'rxb_lb', 'vref_prech', 'vref_rstore', 'vref_cds',
|
|
||||||
'vpreamp', 'vref_comp', 'vref_comp_fe vref_ds', 'vref_h_adc',
|
|
||||||
'vref_l_adc', 'iodelay', 'list', 'vref_ds', 'vis', 'vpl',
|
|
||||||
'vref_comp_fe', 'vph', 'vout_cm', 'vcp', 'vcn', 'vcmp_ll', 'vcmp_lr'
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# dacs are in general not included in the python commands and we expect to
|
|
||||||
# set them from the specialized class or using an enum
|
|
||||||
dacs = [
|
|
||||||
'vicin',
|
|
||||||
'vcassh',
|
|
||||||
'vcal_n',
|
|
||||||
'vcal_p'
|
|
||||||
'vipre_out',
|
|
||||||
'vipre_cds',
|
|
||||||
'vdd_prot',
|
|
||||||
'vcmp_rl',
|
|
||||||
'vcmp_rr',
|
|
||||||
'vcal', 'vcas',
|
|
||||||
'vipre',
|
|
||||||
'vin_com',
|
|
||||||
'vin_cm',
|
|
||||||
'vrshaper',
|
|
||||||
'vrshaper_n',
|
|
||||||
'vrpreamp',
|
|
||||||
'vishaper',
|
|
||||||
'vipre_out',
|
|
||||||
'vcom_adc1',
|
|
||||||
'vcom_adc2',
|
|
||||||
'vcom_cds',
|
|
||||||
'vdcsh',
|
|
||||||
'v_chip',
|
|
||||||
'vb_comp',
|
|
||||||
'vb_comp_adc',
|
|
||||||
'vb_comp_fe',
|
|
||||||
'vb_cs',
|
|
||||||
'vb_ds',
|
|
||||||
'vb_opa_1st',
|
|
||||||
'vb_opa_fd',
|
|
||||||
'vb_pixbuf',
|
|
||||||
'vb_sda',
|
|
||||||
'vbp_colbuf',
|
|
||||||
'vcal_p',
|
|
||||||
'vcasc_out',
|
|
||||||
'vcasc_sfp',
|
|
||||||
'vcascn_pb',
|
|
||||||
'vcascp_pb',
|
|
||||||
'vchip_comp_adc',
|
|
||||||
'vchip_comp_fe',
|
|
||||||
'vchip_cs',
|
|
||||||
'vchip_opa_1st',
|
|
||||||
'vchip_opa_fd',
|
|
||||||
'vchip_ref_comp_fe',
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
intentionally_missing = [
|
|
||||||
'temp_10ge', #temperatures already available from enum or specialized class
|
|
||||||
'temp_adc',
|
|
||||||
'temp_dcdc',
|
|
||||||
'temp_fpga',
|
|
||||||
'temp_fpgaext',
|
|
||||||
'temp_fpgafl',
|
|
||||||
'temp_fpgafr',
|
|
||||||
'temp_slowadc',
|
|
||||||
'temp_sodl',
|
|
||||||
'temp_sodr',
|
|
||||||
'trigger', #use sendSoftwareTrigger
|
|
||||||
'update', #use updateServerAndFirmare
|
|
||||||
'udp_validate', #use validateUdpConfiguration
|
|
||||||
'udp_reconfigure', #use reconfigureUdpDestination
|
|
||||||
'emin', #use rx_jsonpara
|
|
||||||
]
|
|
||||||
|
|
||||||
pycmd += intentionally_missing
|
|
||||||
pycmd += dacs
|
|
||||||
missing = []
|
|
||||||
for c in cmd:
|
|
||||||
if c not in pycmd:
|
|
||||||
print(c)
|
|
||||||
missing.append(c)
|
|
||||||
|
|
||||||
print(f'Missing: {len(missing)} commands')
|
|
143
python/scripts/compare_with_commandline.py
Normal file
143
python/scripts/compare_with_commandline.py
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
import subprocess
|
||||||
|
import locale
|
||||||
|
out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
|
||||||
|
cmd = out.stdout.splitlines()
|
||||||
|
cmd.pop(0)
|
||||||
|
|
||||||
|
from slsdet import Detector
|
||||||
|
|
||||||
|
pycmd = dir(Detector)
|
||||||
|
|
||||||
|
|
||||||
|
# dacs are in general not included in the python commands and we expect to
|
||||||
|
# set them from the specialized class or using an enum
|
||||||
|
dacs = [
|
||||||
|
'adcvpp',
|
||||||
|
'iodelay',
|
||||||
|
'list',
|
||||||
|
'rxb_lb',
|
||||||
|
'rxb_rb',
|
||||||
|
'v_chip',
|
||||||
|
'vb_comp',
|
||||||
|
'vb_comp_adc',
|
||||||
|
'vb_comp_fe',
|
||||||
|
'vb_cs',
|
||||||
|
'vb_ds',
|
||||||
|
'vb_opa_1st',
|
||||||
|
'vb_opa_fd',
|
||||||
|
'vb_pixbuf',
|
||||||
|
'vb_sda',
|
||||||
|
'vbp_colbuf',
|
||||||
|
'vcal',
|
||||||
|
'vcal_n',
|
||||||
|
'vcal_p',
|
||||||
|
'vipre_out',
|
||||||
|
'vcas',
|
||||||
|
'vcasc_out',
|
||||||
|
'vcasc_sfp',
|
||||||
|
'vcascn_pb',
|
||||||
|
'vcascp_pb',
|
||||||
|
'vcassh',
|
||||||
|
'vchip_comp_adc',
|
||||||
|
'vchip_comp_fe',
|
||||||
|
'vchip_cs',
|
||||||
|
'vchip_opa_1st',
|
||||||
|
'vchip_opa_fd',
|
||||||
|
'vchip_ref_comp_fe',
|
||||||
|
'vcmp_ll',
|
||||||
|
'vcmp_lr',
|
||||||
|
'vcmp_rl',
|
||||||
|
'vcmp_rr',
|
||||||
|
'vcn',
|
||||||
|
'vcom_adc1',
|
||||||
|
'vcom_adc2',
|
||||||
|
'vcom_cds',
|
||||||
|
'vcp',
|
||||||
|
'vdcsh',
|
||||||
|
'vdd_prot',
|
||||||
|
'vicin',
|
||||||
|
'vin_cm',
|
||||||
|
'vin_com',
|
||||||
|
'vipre',
|
||||||
|
'vipre_cds',
|
||||||
|
'vipre_out',
|
||||||
|
'vishaper',
|
||||||
|
'vout_cm',
|
||||||
|
'vref_cds',
|
||||||
|
'vref_comp',
|
||||||
|
'vref_comp_fe',
|
||||||
|
'vref_ds',
|
||||||
|
'vref_h_adc',
|
||||||
|
'vref_l_adc',
|
||||||
|
'vref_prech',
|
||||||
|
'vref_rstore',
|
||||||
|
'vrpreamp',
|
||||||
|
'vrshaper',
|
||||||
|
'vrshaper_n',
|
||||||
|
'vsvn',
|
||||||
|
'vsvp',
|
||||||
|
'vtgstv',
|
||||||
|
'vth1',
|
||||||
|
'vth2',
|
||||||
|
'vth3',
|
||||||
|
'vtrim',
|
||||||
|
'ib_test_c',
|
||||||
|
'ibias_sfp',
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
intentionally_missing = [
|
||||||
|
'activate', #use getActive and getRxPadDeactivatedMode syntax is not a good fit for python
|
||||||
|
'temp_10ge', #temperatures already available from enum or specialized class
|
||||||
|
'temp_adc',
|
||||||
|
'temp_dcdc',
|
||||||
|
'temp_fpga',
|
||||||
|
'temp_fpgaext',
|
||||||
|
'temp_fpgafl',
|
||||||
|
'temp_fpgafr',
|
||||||
|
'temp_slowadc',
|
||||||
|
'temp_sodl',
|
||||||
|
'temp_sodr',
|
||||||
|
'trigger', #use sendSoftwareTrigger
|
||||||
|
'update', #use updateServerAndFirmare
|
||||||
|
'udp_validate', #use validateUdpConfiguration
|
||||||
|
'udp_reconfigure', #use reconfigureUdpDestination
|
||||||
|
'pulse', # use pulseChip pulsePixel pulsePixelNmove
|
||||||
|
'pulsechip',
|
||||||
|
'pulsenmove',
|
||||||
|
'savepattern', #use savePattern()
|
||||||
|
'resetfpga', #use resetFPGA()
|
||||||
|
'rebootcontroller', #use rebootController()
|
||||||
|
'firmwaretest', #use executeFirmwareTest
|
||||||
|
'bustest', # executeBusTest
|
||||||
|
'programfpga', #programFPGA
|
||||||
|
'dac', #use setDAC or detector specific class
|
||||||
|
'clearroi', #clearROI
|
||||||
|
]
|
||||||
|
|
||||||
|
pycmd += intentionally_missing
|
||||||
|
pycmd += dacs
|
||||||
|
missing = []
|
||||||
|
for c in cmd:
|
||||||
|
if c not in pycmd:
|
||||||
|
print(c)
|
||||||
|
missing.append(c)
|
||||||
|
|
||||||
|
print(f'\nMissing: {len(missing)} commands')
|
||||||
|
print(f'Excluded: {len(dacs)} dacs')
|
||||||
|
print(f'Excluded: {len(intentionally_missing)} other commands')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
not_in_cmd = []
|
||||||
|
for c in pycmd:
|
||||||
|
if c.islower() and not c.startswith('_'):
|
||||||
|
if c not in cmd:
|
||||||
|
not_in_cmd.append(c)
|
||||||
|
print(f'\nCommands in Python and NOT in command line: {len(not_in_cmd)}')
|
||||||
|
for c in not_in_cmd:
|
||||||
|
print(c)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# print(',\n'.join([f'\'{d}\'' for d in sorted(dacs)]))
|
@ -60,6 +60,23 @@ def get_arguments(node):
|
|||||||
args = f", {args}"
|
args = f", {args}"
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
def get_arguments_with_default(node):
|
||||||
|
args = []
|
||||||
|
for arg in node.get_arguments():
|
||||||
|
tokens = [t.spelling for t in arg.get_tokens()]
|
||||||
|
print(tokens)
|
||||||
|
if '=' in tokens:
|
||||||
|
if arg.type.spelling == "sls::Positions": #TODO! automate
|
||||||
|
args.append("py::arg() = Positions{}")
|
||||||
|
else:
|
||||||
|
args.append('py::arg()' + ''.join(tokens[tokens.index('='):]))
|
||||||
|
else:
|
||||||
|
args.append('py::arg()')
|
||||||
|
args = ", ".join(args)
|
||||||
|
if args:
|
||||||
|
args = f", {args}"
|
||||||
|
return args
|
||||||
|
|
||||||
|
|
||||||
def get_fdec(node):
|
def get_fdec(node):
|
||||||
args = [a.type.spelling for a in node.get_arguments()]
|
args = [a.type.spelling for a in node.get_arguments()]
|
||||||
@ -86,7 +103,8 @@ def visit(node):
|
|||||||
and child.access_specifier == cindex.AccessSpecifier.PUBLIC
|
and child.access_specifier == cindex.AccessSpecifier.PUBLIC
|
||||||
):
|
):
|
||||||
m.append(child)
|
m.append(child)
|
||||||
args = get_arguments(child)
|
# args = get_arguments(child)
|
||||||
|
args = get_arguments_with_default(child)
|
||||||
fs = get_fdec(child)
|
fs = get_fdec(child)
|
||||||
lines.append(
|
lines.append(
|
||||||
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
|
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Created on Tue Nov 14 16:49:07 2017
|
|
||||||
|
|
||||||
@author: l_frojdh
|
|
||||||
"""
|
|
||||||
|
|
||||||
fw_version = 23
|
|
||||||
detector_type = 'Eiger'
|
|
||||||
known_hostnames = ['beb083', 'beb098']
|
|
||||||
image_size = (512,1024) #rows, cols
|
|
||||||
module_geometry = (1,2) #horizontal, vertical
|
|
||||||
|
|
||||||
#Remember to change these in the settings file as well!
|
|
||||||
settings_path = '/home/l_frojdh/slsDetectorPackage/settingsdir/eiger'
|
|
||||||
file_path = '/home/l_frojdh/out'
|
|
@ -1,27 +0,0 @@
|
|||||||
import pytest
|
|
||||||
|
|
||||||
from sls_detector import Detector
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def detector():
|
|
||||||
from sls_detector import Detector
|
|
||||||
return Detector()
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def eiger():
|
|
||||||
from sls_detector import Eiger
|
|
||||||
d = Eiger()
|
|
||||||
d.n_frames = 1
|
|
||||||
d.exposure_time = 1
|
|
||||||
d.file_write = False
|
|
||||||
return d
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def jungfrau():
|
|
||||||
from sls_detector import Jungfrau
|
|
||||||
return Jungfrau()
|
|
||||||
|
|
||||||
detector_type = Detector().detector_type
|
|
||||||
eigertest = pytest.mark.skipif(detector_type != 'Eiger', reason = 'Only valid for Eiger')
|
|
||||||
jungfrautest = pytest.mark.skipif(detector_type != 'Jungfrau', reason = 'Only valid for Jungfrau')
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,33 +0,0 @@
|
|||||||
detsizechan 1024 512
|
|
||||||
|
|
||||||
#hostname for top+bottom+
|
|
||||||
hostname beb083+beb098+
|
|
||||||
|
|
||||||
#top
|
|
||||||
0:rx_tcpport 1954
|
|
||||||
0:lock 0
|
|
||||||
0:rx_udpport 50010
|
|
||||||
0:rx_udpport2 50011
|
|
||||||
0:rx_hostname mpc2048
|
|
||||||
0:flippeddatax 0
|
|
||||||
|
|
||||||
#bottom
|
|
||||||
1:rx_tcpport 1955
|
|
||||||
1:lock 0
|
|
||||||
1:rx_udpport 50004
|
|
||||||
1:rx_udpport2 50005
|
|
||||||
1:rx_hostname mpc2048
|
|
||||||
1:flippeddatax 1
|
|
||||||
|
|
||||||
settingsdir /home/l_frojdh/slsDetectorPackage/settingsdir/eiger
|
|
||||||
outdir /home/l_frojdh/out
|
|
||||||
vthreshold 1500
|
|
||||||
vtr 4000
|
|
||||||
dr 32
|
|
||||||
|
|
||||||
threaded 1
|
|
||||||
tengiga 0
|
|
||||||
highvoltage 150
|
|
||||||
iodelay 660
|
|
||||||
|
|
||||||
#gappixels 1
|
|
@ -1,2 +0,0 @@
|
|||||||
vrf 3000
|
|
||||||
vthreshold 1800
|
|
@ -1,44 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Testing setting dynamic range for Eiger.
|
|
||||||
If the detector is not Eiger the tests are skipped
|
|
||||||
"""
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
|
|
||||||
from sls_detector.errors import DetectorValueError
|
|
||||||
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_dynamic_range_and_make_acq(eiger):
|
|
||||||
eiger.exposure_time = 0.5
|
|
||||||
eiger.n_frames = 2
|
|
||||||
for dr in [4, 8, 16, 32]:
|
|
||||||
eiger.dynamic_range = dr
|
|
||||||
assert eiger.dynamic_range == dr
|
|
||||||
eiger.acq()
|
|
||||||
assert eiger.frames_caught == 2
|
|
||||||
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_dynamic_range_raises(eiger):
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
eiger.dynamic_range = 1
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
eiger.dynamic_range = 75
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
eiger.dynamic_range = -3
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
eiger.dynamic_range = 12
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_dynamic_range_reduces_speed(eiger):
|
|
||||||
eiger.readout_clock = 'Full Speed'
|
|
||||||
eiger.dynamic_range = 32
|
|
||||||
assert eiger.dynamic_range == 32
|
|
||||||
assert eiger.readout_clock == 'Quarter Speed'
|
|
||||||
|
|
||||||
eiger.dynamic_range = 16
|
|
||||||
assert eiger.dynamic_range == 16
|
|
||||||
assert eiger.readout_clock == 'Half Speed'
|
|
@ -1,119 +0,0 @@
|
|||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
import time
|
|
||||||
from sls_detector.errors import DetectorValueError
|
|
||||||
|
|
||||||
from fixtures import eiger, eigertest
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_matrix_reset(eiger):
|
|
||||||
eiger.eiger_matrix_reset = False
|
|
||||||
assert eiger.eiger_matrix_reset == False
|
|
||||||
eiger.eiger_matrix_reset = True
|
|
||||||
assert eiger.eiger_matrix_reset == True
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_tx_delay_left_single(eiger):
|
|
||||||
eiger.tx_delay.left[0] = 130
|
|
||||||
assert eiger.tx_delay.left[0] == 130
|
|
||||||
eiger.tx_delay.left[1] = 150
|
|
||||||
assert eiger.tx_delay.left[1] == 150
|
|
||||||
eiger.tx_delay.left[0] = 0
|
|
||||||
eiger.tx_delay.left[1] = 0
|
|
||||||
assert eiger.tx_delay.left[0] == 0
|
|
||||||
assert eiger.tx_delay.left[1] == 0
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_tx_delay_right_single(eiger):
|
|
||||||
eiger.tx_delay.right[0] = 130
|
|
||||||
assert eiger.tx_delay.right[0] == 130
|
|
||||||
eiger.tx_delay.right[1] = 150
|
|
||||||
assert eiger.tx_delay.right[1] == 150
|
|
||||||
eiger.tx_delay.right[0] = 0
|
|
||||||
eiger.tx_delay.right[1] = 0
|
|
||||||
assert eiger.tx_delay.right[0] == 0
|
|
||||||
assert eiger.tx_delay.right[1] == 0
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_tx_delay_frame_single(eiger):
|
|
||||||
eiger.tx_delay.frame[0] = 500
|
|
||||||
eiger.tx_delay.frame[1] = 600
|
|
||||||
assert eiger.tx_delay.frame[0] == 500
|
|
||||||
assert eiger.tx_delay.frame[1] == 600
|
|
||||||
|
|
||||||
eiger.tx_delay.frame[0] = 0
|
|
||||||
eiger.tx_delay.frame[1] = 0
|
|
||||||
assert eiger.tx_delay.frame[0] == 0
|
|
||||||
assert eiger.tx_delay.frame[1] == 0
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_tx_delay_from_list(eiger):
|
|
||||||
eiger.tx_delay.left = [123,456]
|
|
||||||
assert eiger.tx_delay.left[:] == [123,456]
|
|
||||||
eiger.tx_delay.right = [789,100]
|
|
||||||
assert eiger.tx_delay.right[:] == [789,100]
|
|
||||||
eiger.tx_delay.frame = [1000,90000]
|
|
||||||
assert eiger.tx_delay.frame[:] == [1000,90000]
|
|
||||||
|
|
||||||
eiger.tx_delay.left = [0, 0]
|
|
||||||
eiger.tx_delay.right = [0, 0]
|
|
||||||
eiger.tx_delay.frame = [0, 0]
|
|
||||||
assert eiger.tx_delay.left[:] == [0, 0]
|
|
||||||
assert eiger.tx_delay.right[:] == [0, 0]
|
|
||||||
assert eiger.tx_delay.frame[:] == [0, 0]
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_acitve(eiger):
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.reset_frames_caught()
|
|
||||||
eiger.active[1] = False
|
|
||||||
eiger.acq()
|
|
||||||
assert eiger._api.getFramesCaughtByReceiver(1) == 0
|
|
||||||
assert eiger._api.getFramesCaughtByReceiver(0) == 1
|
|
||||||
eiger.active = True
|
|
||||||
time.sleep(0.5)
|
|
||||||
eiger.acq()
|
|
||||||
assert eiger.frames_caught == 1
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_default_settings(eiger):
|
|
||||||
eiger.default_settings()
|
|
||||||
assert eiger.n_frames == 1
|
|
||||||
assert eiger.exposure_time == 1
|
|
||||||
assert eiger.period == 0
|
|
||||||
assert eiger.n_cycles == 1
|
|
||||||
assert eiger.dynamic_range == 16
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_flowcontrol10g(eiger):
|
|
||||||
eiger.flowcontrol_10g = True
|
|
||||||
assert eiger.flowcontrol_10g == True
|
|
||||||
eiger.flowcontrol_10g = False
|
|
||||||
assert eiger.flowcontrol_10g == False
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_read_vcmp(eiger):
|
|
||||||
eiger.vthreshold = 1500
|
|
||||||
assert eiger.vcmp[:] == [1500]*4*eiger.n_modules
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_vcmp(eiger):
|
|
||||||
eiger.vcmp = [1000,1100,1200,1300,1400,1500,1600,1700]
|
|
||||||
assert eiger.vcmp[:] == [1000,1100,1200,1300,1400,1500,1600,1700]
|
|
||||||
eiger.vthreshold = 1500
|
|
||||||
|
|
||||||
#Disabled only works with receiver on the same pc
|
|
||||||
# @eigertest
|
|
||||||
# def test_setup500k():
|
|
||||||
# from sls_detector import Eiger, free_shared_memory
|
|
||||||
# free_shared_memory()
|
|
||||||
# d = Eiger()
|
|
||||||
# d.setup500k(config_test.known_hostnames)
|
|
||||||
# d.acq()
|
|
||||||
# assert d.rx_tcpport == [1954,1955]
|
|
||||||
# assert d.frames_caught == 1
|
|
||||||
# #could assert more setting but if the frame is caught it worked...
|
|
@ -1,129 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Tests specific for the firmware.
|
|
||||||
|
|
||||||
Check that register values are correct after starting an exposure
|
|
||||||
|
|
||||||
0x4 exposure time
|
|
||||||
0x5 period
|
|
||||||
0x6 sub exposure time
|
|
||||||
|
|
||||||
"""
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
|
|
||||||
from sls_detector.errors import DetectorValueError
|
|
||||||
from sls_detector.utils import eiger_register_to_time
|
|
||||||
|
|
||||||
# testdata_exptimes = [0.001, 0.002, 0.0236]
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_short_exposure_time(eiger):
|
|
||||||
t = 1.23
|
|
||||||
eiger.exposure_time = t
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.start_detector()
|
|
||||||
eiger.stop_detector()
|
|
||||||
|
|
||||||
#Register 0x4 holds exposure time
|
|
||||||
reg = eiger.register[0x4]
|
|
||||||
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_short_minimal_exposure_time(eiger):
|
|
||||||
t = 1e-8
|
|
||||||
eiger.exposure_time = t
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.start_detector()
|
|
||||||
eiger.stop_detector()
|
|
||||||
|
|
||||||
#Register 0x4 holds exposure time
|
|
||||||
reg = eiger.register[0x4]
|
|
||||||
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
|
|
||||||
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_long_exposure_time(eiger):
|
|
||||||
t = 623
|
|
||||||
eiger.exposure_time = t
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.start_detector()
|
|
||||||
eiger.stop_detector()
|
|
||||||
|
|
||||||
# Register 0x4 holds exposure time
|
|
||||||
reg = eiger.register[0x4]
|
|
||||||
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
|
|
||||||
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_short_period(eiger):
|
|
||||||
t = 0.1
|
|
||||||
eiger.exposure_time = 0.001
|
|
||||||
eiger.period = t
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.start_detector()
|
|
||||||
eiger.stop_detector()
|
|
||||||
|
|
||||||
# Register 0x5 holds period
|
|
||||||
reg = eiger.register[0x5]
|
|
||||||
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
|
|
||||||
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_long_period(eiger):
|
|
||||||
t = 8900
|
|
||||||
eiger.exposure_time = 0.001
|
|
||||||
eiger.period = t
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.start_detector()
|
|
||||||
eiger.stop_detector()
|
|
||||||
|
|
||||||
# Register 0x5 holds period
|
|
||||||
reg = eiger.register[0x5]
|
|
||||||
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_zero_period_with_acq(eiger):
|
|
||||||
t = 0
|
|
||||||
eiger.exposure_time = 0.001
|
|
||||||
eiger.period = t
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.start_detector()
|
|
||||||
eiger.stop_detector()
|
|
||||||
|
|
||||||
# Register 0x5 holds period
|
|
||||||
reg = eiger.register[0x5]
|
|
||||||
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
|
|
||||||
|
|
||||||
|
|
||||||
testdata_times = [0.001, 0.002, 0.0236]
|
|
||||||
@eigertest
|
|
||||||
@pytest.mark.parametrize("t", testdata_times)
|
|
||||||
def test_subexptime(eiger,t):
|
|
||||||
eiger.sub_exposure_time = t
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.start_detector()
|
|
||||||
eiger.stop_detector()
|
|
||||||
|
|
||||||
# Register 0x6 holds sub exposure time
|
|
||||||
# time is stored straight as n clocks
|
|
||||||
reg = eiger.register[0x6]
|
|
||||||
assert pytest.approx(t, 1e-9) == reg/100e6
|
|
||||||
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
@pytest.mark.parametrize("t", testdata_times)
|
|
||||||
def test_subdeadtime(eiger, t):
|
|
||||||
eiger.sub_deadtime = t
|
|
||||||
eiger.sub_exposure_time = 1
|
|
||||||
eiger.sub_exposure_time = 0.001
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.start_detector()
|
|
||||||
eiger.stop_detector()
|
|
||||||
|
|
||||||
# Register 0x7 holds sub period
|
|
||||||
# time is stored straight as n clocks
|
|
||||||
# exptime+deadtime
|
|
||||||
reg = eiger.register[0x7]
|
|
||||||
assert pytest.approx(t, 1e-7) == (reg/100e6-0.001)
|
|
@ -1,187 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
General tests for the Detector class. Should not depend on the connected detector. Aim is to have tests working
|
|
||||||
for both Jungfrau and Eiger.
|
|
||||||
|
|
||||||
NOTE! Uses hostnames from config_test
|
|
||||||
"""
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
from fixtures import detector
|
|
||||||
from sls_detector.errors import DetectorValueError, DetectorError
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_error_handling(detector):
|
|
||||||
with pytest.raises(DetectorError):
|
|
||||||
detector._provoke_error()
|
|
||||||
|
|
||||||
def test_not_busy(detector):
|
|
||||||
"""Test that the detector is not busy from the start"""
|
|
||||||
assert detector.busy == False
|
|
||||||
|
|
||||||
def test_reset_frames_caught(detector):
|
|
||||||
detector.file_write = False
|
|
||||||
detector.acq()
|
|
||||||
assert detector.frames_caught == 1
|
|
||||||
detector.reset_frames_caught()
|
|
||||||
assert detector.frames_caught == 0
|
|
||||||
|
|
||||||
def test_set_busy_true_then_false(detector):
|
|
||||||
"""Test both cases of assignment"""
|
|
||||||
detector.busy = True
|
|
||||||
assert detector.busy == True
|
|
||||||
detector.busy = False
|
|
||||||
assert detector.busy == False
|
|
||||||
|
|
||||||
def test_set_readout_speed(detector):
|
|
||||||
for s in ['Full Speed', 'Half Speed', 'Quarter Speed', 'Super Slow Speed']:
|
|
||||||
detector.readout_clock = s
|
|
||||||
assert detector.readout_clock == s
|
|
||||||
|
|
||||||
def test_wrong_speed_raises_error(detector):
|
|
||||||
with pytest.raises(KeyError):
|
|
||||||
detector.readout_clock = 'Something strange'
|
|
||||||
|
|
||||||
def test_readout_clock_remains(detector):
|
|
||||||
s = detector.readout_clock
|
|
||||||
try:
|
|
||||||
detector.readout_clock = 'This does not exists'
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
assert detector.readout_clock == s
|
|
||||||
|
|
||||||
def test_len_method(detector):
|
|
||||||
"""to test this we need to know the length, this we get from the configuration of hostnames"""
|
|
||||||
assert len(detector) == len(config_test.known_hostnames)
|
|
||||||
|
|
||||||
def test_setting_n_cycles_to_zero_gives_error(detector):
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
detector.n_cycles = 0
|
|
||||||
|
|
||||||
def test_setting_n_cycles_to_negative_gives_error(detector):
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
detector.n_cycles = -50
|
|
||||||
|
|
||||||
def test_set_cycles_frome_one_to_ten(detector):
|
|
||||||
for i in range(1,11):
|
|
||||||
detector.n_cycles = i
|
|
||||||
assert detector.n_cycles == i
|
|
||||||
detector.n_cycles = 1
|
|
||||||
assert detector.n_cycles == 1
|
|
||||||
|
|
||||||
def test_get_detector_type(detector):
|
|
||||||
assert detector.detector_type == config_test.detector_type
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_file_index(detector):
|
|
||||||
detector.file_index = 5
|
|
||||||
assert detector.file_index == 5
|
|
||||||
|
|
||||||
def test_negative_file_index_raises(detector):
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
detector.file_index = -8
|
|
||||||
|
|
||||||
def test_setting_file_name(detector):
|
|
||||||
fname = 'hej'
|
|
||||||
detector.file_name = fname
|
|
||||||
assert detector.file_name == fname
|
|
||||||
|
|
||||||
def test_set_file_write(detector):
|
|
||||||
detector.file_write = True
|
|
||||||
assert detector.file_write == True
|
|
||||||
|
|
||||||
detector.file_write = False
|
|
||||||
assert detector.file_write == False
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_high_voltage(detector):
|
|
||||||
detector.high_voltage = 55
|
|
||||||
assert detector.high_voltage == 55
|
|
||||||
|
|
||||||
def test_negative_voltage_raises(detector):
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
detector.high_voltage = -5
|
|
||||||
|
|
||||||
def test_high_voltage_raises_on_to_high(detector):
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
detector.high_voltage = 500
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_image_size(detector):
|
|
||||||
"""Compares with the size in the config file"""
|
|
||||||
assert detector.image_size.rows == config_test.image_size[0]
|
|
||||||
assert detector.image_size.cols == config_test.image_size[1]
|
|
||||||
|
|
||||||
def test_get_module_geometry(detector):
|
|
||||||
"""Compares with the size in the config file"""
|
|
||||||
assert detector.module_geometry.horizontal == config_test.module_geometry[0]
|
|
||||||
assert detector.module_geometry.vertical == config_test.module_geometry[1]
|
|
||||||
|
|
||||||
def test_set_nframes(detector):
|
|
||||||
detector.n_frames = 5
|
|
||||||
assert detector.n_frames == 5
|
|
||||||
detector.n_frames = 1
|
|
||||||
assert detector.n_frames == 1
|
|
||||||
|
|
||||||
def test_set_n_measurements(detector):
|
|
||||||
detector.n_measurements = 7
|
|
||||||
assert detector.n_measurements == 7
|
|
||||||
detector.n_measurements = 1
|
|
||||||
assert detector.n_measurements == 1
|
|
||||||
|
|
||||||
def test_negative_nframes_raises(detector):
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
detector.n_frames = -2
|
|
||||||
|
|
||||||
def test_nmodules(detector):
|
|
||||||
"""Assume that the number of modules should be the same as the number of hostnames"""
|
|
||||||
assert detector.n_modules == len(config_test.known_hostnames)
|
|
||||||
|
|
||||||
def test_is_detector_online(detector):
|
|
||||||
assert detector.online == True
|
|
||||||
|
|
||||||
def test_set_online(detector):
|
|
||||||
detector.online = False
|
|
||||||
assert detector.online == False
|
|
||||||
detector.online = True
|
|
||||||
assert detector.online == True
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_receiver_is_online(detector):
|
|
||||||
assert detector.receiver_online == True
|
|
||||||
|
|
||||||
def test_set_receiver_online(detector):
|
|
||||||
detector.receiver_online = False
|
|
||||||
assert detector.receiver_online == False
|
|
||||||
detector.receiver_online = True
|
|
||||||
assert detector.receiver_online == True
|
|
||||||
|
|
||||||
def test_set_receiver_online_raises_on_non_bool(detector):
|
|
||||||
with pytest.raises(TypeError):
|
|
||||||
detector.receiver_online = 'probably not this'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_period(detector):
|
|
||||||
detector.period = 5.123
|
|
||||||
assert detector.period == 5.123
|
|
||||||
detector.period = 0
|
|
||||||
assert detector.period == 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_timing_mode(detector):
|
|
||||||
detector.timing_mode = 'trigger'
|
|
||||||
assert detector.timing_mode == 'trigger'
|
|
||||||
detector.timing_mode = 'auto'
|
|
||||||
assert detector.timing_mode == 'auto'
|
|
||||||
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
|||||||
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
import os
|
|
||||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
from sls_detector.detector import element_if_equal
|
|
||||||
from sls_detector.errors import DetectorValueError
|
|
||||||
|
|
||||||
|
|
||||||
from fixtures import eiger, eigertest
|
|
||||||
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_load_config_file_eiger(eiger):
|
|
||||||
"""Load a settings file and assert all settings"""
|
|
||||||
eiger.load_config(os.path.join(dir_path, 'test.config'))
|
|
||||||
|
|
||||||
|
|
||||||
assert eiger.rx_tcpport == [1954, 1955]
|
|
||||||
assert eiger.lock == False
|
|
||||||
assert eiger.rx_udpport == [50010, 50011, 50004, 50005]
|
|
||||||
assert eiger.rx_hostname == 'mpc2048'
|
|
||||||
assert eiger.flipped_data_x[:] == [False, True]
|
|
||||||
assert eiger.settings_path == config_test.settings_path
|
|
||||||
assert eiger.file_path == config_test.file_path
|
|
||||||
assert eiger.vthreshold == 1500
|
|
||||||
assert element_if_equal(eiger.dacs.vtr[:]) == 4000
|
|
||||||
assert eiger.dynamic_range == 32
|
|
||||||
assert eiger.tengiga == False
|
|
||||||
assert eiger.high_voltage == 150
|
|
||||||
assert element_if_equal(eiger.dacs.iodelay[:]) == 660
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_load_parameters_file_eiger(eiger):
|
|
||||||
"""Load a parametes file and assert the settings in the file"""
|
|
||||||
eiger.load_parameters(os.path.join(dir_path, 'test.par'))
|
|
||||||
assert element_if_equal(eiger.dacs.vrf[:]) == 3000
|
|
||||||
assert eiger.vthreshold == 1800
|
|
@ -1,81 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Tests for network related functions of the detector
|
|
||||||
"""
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
from fixtures import eiger, eigertest, detector
|
|
||||||
|
|
||||||
|
|
||||||
# def test_last_client(detector):
|
|
||||||
# import socket
|
|
||||||
# # We probably should check for multiple ip's
|
|
||||||
# myip = socket.gethostbyname_ex(socket.gethostname())[-1][0]
|
|
||||||
# assert detector.last_client_ip == myip
|
|
||||||
|
|
||||||
def test_get_hostname(detector):
|
|
||||||
for detector_host, config_host in zip(detector.hostname, config_test.known_hostnames):
|
|
||||||
assert detector_host == config_host
|
|
||||||
|
|
||||||
def test_hostname_has_same_length_as_n_modules(detector):
|
|
||||||
assert len(detector.hostname) == detector.n_modules
|
|
||||||
|
|
||||||
|
|
||||||
# # def test_get_receiver_hostname(detector):
|
|
||||||
# # """Assume that the receiver are on the local computer"""
|
|
||||||
# # import socket
|
|
||||||
# # host = socket.gethostname().split('.')[0]
|
|
||||||
# # assert detector.rx_hostname == host
|
|
||||||
|
|
||||||
# def test_set_receiver_hostname(detector):
|
|
||||||
# import socket
|
|
||||||
# host = socket.gethostname().split('.')[0]
|
|
||||||
# phony_host = 'madeup'
|
|
||||||
# detector.rx_hostname = phony_host
|
|
||||||
# assert detector.rx_hostname == phony_host
|
|
||||||
# detector.rx_hostname = host
|
|
||||||
# assert detector.rx_hostname == host
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_rx_zmqport_single_value(eiger):
|
|
||||||
eiger.rx_zmqport = 35000
|
|
||||||
assert eiger.rx_zmqport == [35000, 35001, 35002, 35003]
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_rx_zmqport_list(eiger):
|
|
||||||
eiger.rx_zmqport = [37000, 38000]
|
|
||||||
assert eiger.rx_zmqport == [37000, 37001, 38000, 38001]
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_rx_updport(eiger):
|
|
||||||
ports = [60010,60011,60012,60013]
|
|
||||||
eiger.rx_udpport = ports
|
|
||||||
assert eiger.rx_udpport == ports
|
|
||||||
eiger.acq()
|
|
||||||
assert eiger.frames_caught == 1
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_rx_tcpport(eiger):
|
|
||||||
ports = eiger.rx_tcpport
|
|
||||||
eiger.rx_tcpport = [2000,2001]
|
|
||||||
assert eiger.rx_tcpport == [2000,2001]
|
|
||||||
eiger.rx_tcpport = ports
|
|
||||||
assert eiger.rx_tcpport == ports
|
|
||||||
eiger.acq()
|
|
||||||
assert eiger.frames_caught == 1
|
|
||||||
|
|
||||||
# @eigertest
|
|
||||||
# @pytest.mark.new
|
|
||||||
# def test_enable_disable_tengiga(eiger):
|
|
||||||
# """
|
|
||||||
# This test does not check for dat on the 10Gbit link, only the set and get functions
|
|
||||||
# """
|
|
||||||
# eiger.tengiga = True
|
|
||||||
# assert eiger.tengiga == True
|
|
||||||
# eiger.tengiga = False
|
|
||||||
# assert eiger.tengiga == False
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#TODO! Add test for Jungfrau
|
|
@ -1,54 +0,0 @@
|
|||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
|
|
||||||
from sls_detector.errors import DetectorValueError
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
@pytest.mark.local
|
|
||||||
def test_set_path(eiger, tmpdir):
|
|
||||||
import os
|
|
||||||
path = os.path.join(tmpdir.dirname, tmpdir.basename)
|
|
||||||
eiger.file_path = path
|
|
||||||
assert eiger.file_path == path
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
@pytest.mark.local
|
|
||||||
def test_set_path_and_write_files(eiger, tmpdir):
|
|
||||||
import os
|
|
||||||
prefix = 'testprefix'
|
|
||||||
path = os.path.join(tmpdir.dirname, tmpdir.basename)
|
|
||||||
eiger.file_path = path
|
|
||||||
eiger.file_write = True
|
|
||||||
eiger.exposure_time = 0.1
|
|
||||||
eiger.n_frames = 1
|
|
||||||
eiger.timing_mode = 'auto'
|
|
||||||
eiger.file_name = prefix
|
|
||||||
eiger.file_index = 0
|
|
||||||
eiger.acq()
|
|
||||||
|
|
||||||
files = [f.basename for f in tmpdir.listdir()]
|
|
||||||
|
|
||||||
assert len(files) == 5
|
|
||||||
assert (prefix+'_d0_0.raw' in files) == True
|
|
||||||
assert (prefix+'_d1_0.raw' in files) == True
|
|
||||||
assert (prefix+'_d2_0.raw' in files) == True
|
|
||||||
assert (prefix+'_d3_0.raw' in files) == True
|
|
||||||
|
|
||||||
def test_set_discard_policy(detector):
|
|
||||||
detector.frame_discard_policy = 'nodiscard'
|
|
||||||
assert detector.frame_discard_policy == 'nodiscard'
|
|
||||||
detector.frame_discard_policy = 'discardpartial'
|
|
||||||
assert detector.frame_discard_policy == 'discardpartial'
|
|
||||||
detector.frame_discard_policy = 'discardempty'
|
|
||||||
assert detector.frame_discard_policy == 'discardempty'
|
|
||||||
|
|
||||||
def test_set_discard_policy_raises(detector):
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
detector.frame_discard_policy = 'adjfvadksvsj'
|
|
||||||
|
|
||||||
def test_set_frames_perfile(detector):
|
|
||||||
detector.frames_per_file = 5000
|
|
||||||
assert detector.frames_per_file == 5000
|
|
@ -1,47 +0,0 @@
|
|||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
import time
|
|
||||||
from sls_detector.errors import DetectorValueError
|
|
||||||
import os
|
|
||||||
from fixtures import eiger, eigertest
|
|
||||||
|
|
||||||
|
|
||||||
testdata_th = [0,333,500,1750,2000]
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
@pytest.mark.parametrize("th", testdata_th)
|
|
||||||
def test_set_vthreshold(eiger, th):
|
|
||||||
eiger.vthreshold = th
|
|
||||||
assert eiger.vthreshold == th
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_vthreshold_with_different_vcmp(eiger):
|
|
||||||
#When vcmp is different for the chip vthreshold should return -1
|
|
||||||
eiger.vthreshold = 1500
|
|
||||||
eiger.dacs.vcmp_ll = 1400
|
|
||||||
assert eiger.vthreshold == -1
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_settingsdir(eiger):
|
|
||||||
path = os.path.dirname( os.path.realpath(__file__) )
|
|
||||||
path = os.path.join(path, 'settingsdir')
|
|
||||||
eiger.settings_path = path
|
|
||||||
assert eiger.settings_path == path
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_trimmed_energies(eiger):
|
|
||||||
en = [5000,6000,7000]
|
|
||||||
eiger.trimmed_energies = en
|
|
||||||
assert eiger.trimmed_energies == en
|
|
||||||
|
|
||||||
|
|
||||||
#TODO! add checks for vcmp as well and improve naming
|
|
||||||
#TODO! remove dependency on beb number
|
|
||||||
testdata_en = [(5000, 500),(5500,750),(6000,1000),(6200,1100),(7000,1500)]
|
|
||||||
@eigertest
|
|
||||||
@pytest.mark.parametrize('val', testdata_en)
|
|
||||||
def test_set_energy_threshold(eiger, val):
|
|
||||||
eiger.settings = 'standard'
|
|
||||||
eiger.threshold = val[0]
|
|
||||||
assert eiger.threshold == val[0]
|
|
||||||
assert eiger.dacs.vrf[0] == val[1]
|
|
@ -1,136 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Tests regarding exposure time and period of the detector
|
|
||||||
Set and get test as well as test for duration and on detector
|
|
||||||
measurement of the time.
|
|
||||||
"""
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
|
|
||||||
from sls_detector.errors import DetectorValueError, DetectorError
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
testdata_times = [1e-8, 0.001, 0.5, 3.125, 5.0, 600, 784]
|
|
||||||
@pytest.mark.parametrize("t", testdata_times)
|
|
||||||
def test_set_and_get_exposure_time(eiger, t):
|
|
||||||
"""
|
|
||||||
Test that the exposure time we set in the detector
|
|
||||||
is the same as the one read back
|
|
||||||
"""
|
|
||||||
eiger.exposure_time = t
|
|
||||||
assert eiger.exposure_time == t
|
|
||||||
|
|
||||||
|
|
||||||
def test_negative_exposure_time_raises_error(eiger):
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
eiger.exposure_time = -15
|
|
||||||
|
|
||||||
|
|
||||||
testdata_times = [0.001, 0.0025, 0.005, 5]
|
|
||||||
@pytest.mark.parametrize("t", testdata_times)
|
|
||||||
def test_set_subexptime(eiger, t):
|
|
||||||
eiger.sub_exposure_time = t
|
|
||||||
assert eiger.sub_exposure_time == t
|
|
||||||
|
|
||||||
|
|
||||||
testdata_times = [-5,6,7,50]
|
|
||||||
@pytest.mark.parametrize("t", testdata_times)
|
|
||||||
def test_set_subextime_too_large_or_neg(eiger, t):
|
|
||||||
with pytest.raises((DetectorError, DetectorValueError)):
|
|
||||||
eiger.sub_exposure_time = t
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
testdata_times = [0.2, 0.5, 1, 2, 5, 7]
|
|
||||||
@pytest.mark.slow
|
|
||||||
@pytest.mark.parametrize("t", testdata_times)
|
|
||||||
def test_measure_exposure_time_from_python(eiger, t):
|
|
||||||
"""
|
|
||||||
The main idea with this test is to make sure the overhead of a
|
|
||||||
single acq is less than tol[s]. This test also catches stupid bugs
|
|
||||||
that would for example not change the exposure time or make acquire
|
|
||||||
not blocking.
|
|
||||||
"""
|
|
||||||
tol = 0.5
|
|
||||||
eiger.dynamic_range = 16
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.n_frames = 1
|
|
||||||
eiger.exposure_time = t
|
|
||||||
assert eiger.exposure_time == t
|
|
||||||
t0 = time.time()
|
|
||||||
eiger.acq()
|
|
||||||
duration = time.time()-t0
|
|
||||||
assert duration < (t+tol)
|
|
||||||
|
|
||||||
|
|
||||||
testdata_times = [0.5, 1, 3, 5]
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slow
|
|
||||||
@pytest.mark.parametrize("t", testdata_times)
|
|
||||||
def test_measure_period_from_python_and_detector(eiger, t):
|
|
||||||
tol = 0.5
|
|
||||||
nframes = 5
|
|
||||||
eiger.dynamic_range = 16
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.n_frames = nframes
|
|
||||||
eiger.exposure_time = 0.001
|
|
||||||
eiger.period = t
|
|
||||||
t0 = time.time()
|
|
||||||
eiger.acq()
|
|
||||||
duration = time.time()-t0
|
|
||||||
assert duration < t*(nframes-1)+tol
|
|
||||||
for mp in eiger.measured_period:
|
|
||||||
assert pytest.approx(mp, 1e-5) == t
|
|
||||||
|
|
||||||
|
|
||||||
testdata_times = [0.001, 0.002, 0.003, 0.005, 0.01]
|
|
||||||
@pytest.mark.parametrize("t", testdata_times)
|
|
||||||
def test_measure_subperiod_nonparallel(eiger, t):
|
|
||||||
readout_time = 500e-6
|
|
||||||
eiger.dynamic_range = 32
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.flags = 'nonparallel'
|
|
||||||
eiger.n_frames = 1
|
|
||||||
eiger.period = 0
|
|
||||||
eiger.exposure_time = 0.5
|
|
||||||
eiger.sub_exposure_time = t
|
|
||||||
eiger.sub_deadtime = 0
|
|
||||||
eiger.acq()
|
|
||||||
for mp in eiger.measured_subperiod:
|
|
||||||
assert pytest.approx(mp, abs=1e-5) == t+readout_time
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("t", testdata_times)
|
|
||||||
def test_measure_subperiod_parallel(eiger, t):
|
|
||||||
readout_time = 12e-6
|
|
||||||
eiger.dynamic_range = 32
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.flags = 'parallel'
|
|
||||||
eiger.n_frames = 1
|
|
||||||
eiger.period = 0
|
|
||||||
eiger.exposure_time = 0.5
|
|
||||||
eiger.sub_exposure_time = t
|
|
||||||
eiger.sub_deadtime = 0
|
|
||||||
eiger.acq()
|
|
||||||
for mp in eiger.measured_subperiod:
|
|
||||||
assert pytest.approx(mp, abs=1e-5) == t+readout_time
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("t", testdata_times)
|
|
||||||
def test_measure_subperiod_parallel_when_changing_deadtime(eiger, t):
|
|
||||||
readout_time = 12e-6
|
|
||||||
exposure_time = 0.001
|
|
||||||
eiger.dynamic_range = 32
|
|
||||||
eiger.file_write = False
|
|
||||||
eiger.flags = 'parallel'
|
|
||||||
eiger.n_frames = 1
|
|
||||||
eiger.period = 0
|
|
||||||
eiger.exposure_time = 0.5
|
|
||||||
eiger.sub_exposure_time = exposure_time
|
|
||||||
eiger.sub_deadtime = t
|
|
||||||
eiger.acq()
|
|
||||||
for mp in eiger.measured_subperiod:
|
|
||||||
assert pytest.approx(mp, abs=1e-5) == t+exposure_time
|
|
@ -1,34 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Tests for trimbit and dac related functions
|
|
||||||
"""
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
|
|
||||||
from sls_detector.errors import DetectorValueError
|
|
||||||
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_trimbits(eiger):
|
|
||||||
"""Limited values due to time"""
|
|
||||||
for i in [17, 32, 60]:
|
|
||||||
print(i)
|
|
||||||
eiger.trimbits = i
|
|
||||||
assert eiger.trimbits == i
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_trimbits_raises_on_too_big(eiger):
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
eiger.trimbits = 75
|
|
||||||
|
|
||||||
@eigertest
|
|
||||||
def test_set_trimbits_raises_on_negative(eiger):
|
|
||||||
with pytest.raises(DetectorValueError):
|
|
||||||
eiger.trimbits = -5
|
|
||||||
|
|
||||||
|
|
||||||
# @jungfrautest
|
|
||||||
# def test_jungfrau(jungfrau):
|
|
||||||
# """Example of a test that is not run with Eiger connected"""
|
|
||||||
# pass
|
|
@ -1,16 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Tests for hostname related functions of the detector
|
|
||||||
"""
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
|
|
||||||
from sls_detector.errors import DetectorValueError
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_firmware_version(detector):
|
|
||||||
assert detector.firmware_version == config_test.fw_version
|
|
||||||
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Created on Tue May 22 14:13:48 2018
|
|
||||||
|
|
||||||
@author: l_frojdh
|
|
||||||
"""
|
|
||||||
import os
|
|
||||||
from sls_detector_tools.io import write_trimbit_file
|
|
||||||
from sls_detector_tools import mask
|
|
||||||
|
|
||||||
energy = [5000, 6000, 7000]
|
|
||||||
vrf = [500, 1000, 1500]
|
|
||||||
|
|
||||||
for i,e in enumerate(energy):
|
|
||||||
dacs = np.array( [[ 0., 0.], #vsvp
|
|
||||||
[4000., 4000.], #vtr
|
|
||||||
[vrf[i], vrf[i]], #vrf
|
|
||||||
[1400., 1400.], #vrs
|
|
||||||
[4000., 4000.], #vsvn
|
|
||||||
[2556., 2556.], #vtgstv
|
|
||||||
[1400., 1400.], #vcmp_ll
|
|
||||||
[1500., 1500.], #vcmp_lr
|
|
||||||
[4000., 4000.], #vcall
|
|
||||||
[1500., 1500.], #vcmp_rl
|
|
||||||
[1100., 1100.], #rxb_rb
|
|
||||||
[1100., 1100.], #rxb_lb
|
|
||||||
[1500., 1500.], #vcmp_rr
|
|
||||||
[1500., 1500.], #vcp
|
|
||||||
[2000., 2000.], #vcn
|
|
||||||
[1550., 1550.], #vis
|
|
||||||
[ 660., 660.], #iodelay
|
|
||||||
[ 0., 0.], #tau
|
|
||||||
])
|
|
||||||
|
|
||||||
tb = np.zeros((256,1024))
|
|
||||||
|
|
||||||
for beb in [83,98]:
|
|
||||||
write_trimbit_file(f'settingsdir/standard/{e}eV/noise.sn{beb:03d}', tb, dacs[:,0])
|
|
||||||
#print(os.getcwd())
|
|
||||||
|
|
||||||
#print( os.path.realpath(__file__))
|
|
@ -1,17 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Created on Tue Nov 14 16:49:07 2017
|
|
||||||
|
|
||||||
@author: l_frojdh
|
|
||||||
"""
|
|
||||||
|
|
||||||
fw_version = 0x180220
|
|
||||||
detector_type = 'Jungfrau'
|
|
||||||
known_hostnames = ['bchip038']
|
|
||||||
image_size = (512,1024) #rows, cols
|
|
||||||
module_geometry = (1,1) #horizontal, vertical
|
|
||||||
|
|
||||||
#Remember to change these in the settings file as well!
|
|
||||||
settings_path = '/home/l_lopez/projects/slsDetectorPackage/settingsdir/jungfrau'
|
|
||||||
file_path = '/home/l_lopez/out'
|
|
@ -1,23 +0,0 @@
|
|||||||
import pytest
|
|
||||||
|
|
||||||
from sls_detector import Detector
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def detector():
|
|
||||||
from sls_detector import Detector
|
|
||||||
return Detector()
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def eiger():
|
|
||||||
from sls_detector import Eiger
|
|
||||||
return Eiger()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def jungfrau():
|
|
||||||
from sls_detector import Jungfrau
|
|
||||||
return Jungfrau()
|
|
||||||
|
|
||||||
detector_type = Detector().detector_type
|
|
||||||
eigertest = pytest.mark.skipif(detector_type != 'Eiger', reason = 'Only valid for Eiger')
|
|
||||||
jungfrautest = pytest.mark.skipif(detector_type != 'Jungfrau', reason = 'Only valid for Jungfrau')
|
|
@ -1,17 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
General tests for the Jungfrau detector.
|
|
||||||
|
|
||||||
NOTE! Uses hostnames from config_test
|
|
||||||
"""
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
import tests
|
|
||||||
|
|
||||||
import os
|
|
||||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
|
|
||||||
pytest.main(['-x', '-s', os.path.join(dir_path, 'tests/test_load_config.py')]) #Test 1
|
|
||||||
pytest.main(['-x', '-s', os.path.join(dir_path, 'tests/test_overtemperature.py')]) #Test 2
|
|
@ -1,21 +0,0 @@
|
|||||||
detsizechan 1024 512
|
|
||||||
|
|
||||||
settingsdir /home/l_lopez/projects/slsDetectorPackage/settingsdir/jungfrau
|
|
||||||
caldir /home/l_lopez/projects/slsDetectorPackage/settingsdir/jungfrau
|
|
||||||
lock 0
|
|
||||||
|
|
||||||
hostname bchip094+
|
|
||||||
|
|
||||||
rx_udpport 1754
|
|
||||||
rx_udpip 10.1.1.107
|
|
||||||
rx_udpmac 90:E2:BA:9A:4F:D4
|
|
||||||
detectorip 10.1.1.9
|
|
||||||
detectormac 00:aa:bb:cc:dd:ee
|
|
||||||
configuremac 0
|
|
||||||
|
|
||||||
powerchip 1
|
|
||||||
timing auto
|
|
||||||
|
|
||||||
outdir /home/l_lopez/out
|
|
||||||
threaded 1
|
|
||||||
high
|
|
@ -1 +0,0 @@
|
|||||||
highvoltage 200
|
|
@ -1,43 +0,0 @@
|
|||||||
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
import os
|
|
||||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
|
|
||||||
from fixtures import jungfrau, jungfrautest
|
|
||||||
|
|
||||||
|
|
||||||
def load_config_file_jungfrau_test(jungfrau):
|
|
||||||
"""Load a settings file and assert all settings"""
|
|
||||||
|
|
||||||
print('\tStarting load_config_file_jungfrau_test test case')
|
|
||||||
|
|
||||||
jungfrau.free_shared_memory
|
|
||||||
jungfrau.load_config(os.path.join(dir_path, 'test.config'))
|
|
||||||
|
|
||||||
assert jungfrau.lock == False
|
|
||||||
assert jungfrau.rx_udpport == ['1754']
|
|
||||||
assert jungfrau.hostname == ['bchip094']
|
|
||||||
assert jungfrau.firmware_version == config_test.fw_version
|
|
||||||
|
|
||||||
print('\tFinished load_config_file_jungfrau_test test case')
|
|
||||||
|
|
||||||
def load_parameters_file_jungfrau_test(jungfrau):
|
|
||||||
"""Load a parametes file and assert the settings in the file"""
|
|
||||||
|
|
||||||
print('\tStarting load_parameters_file_jungfrau_test test case')
|
|
||||||
|
|
||||||
jungfrau.load_parameters(os.path.join(dir_path, 'test.par'))
|
|
||||||
assert jungfrau.high_voltage == 200
|
|
||||||
|
|
||||||
print('\tFinished load_parameters_file_jungfrau_test test case')
|
|
||||||
|
|
||||||
@jungfrautest
|
|
||||||
def test_main(jungfrau):
|
|
||||||
print('\nTesting configuration file loading')
|
|
||||||
|
|
||||||
load_config_file_jungfrau_test(jungfrau)
|
|
||||||
load_parameters_file_jungfrau_test(jungfrau)
|
|
||||||
|
|
||||||
print('Tested configuration file loading')
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
|||||||
|
|
||||||
import pytest
|
|
||||||
import config_test
|
|
||||||
import time
|
|
||||||
from fixtures import jungfrau, jungfrautest
|
|
||||||
|
|
||||||
def powerchip_test(jungfrau, control):
|
|
||||||
"""
|
|
||||||
|
|
||||||
Test the main overtemperature protection control
|
|
||||||
|
|
||||||
"""
|
|
||||||
#Set test initial conditions
|
|
||||||
print('\tStarting powerchip_test test case')
|
|
||||||
|
|
||||||
jungfrau.power_chip = False
|
|
||||||
jungfrau.temperature_control = control
|
|
||||||
assert jungfrau.power_chip == False
|
|
||||||
jungfrau.temperature_threshold = 35
|
|
||||||
jungfrau.power_chip = True
|
|
||||||
|
|
||||||
|
|
||||||
if jungfrau.temperature_control is True:
|
|
||||||
if jungfrau.temperature_event is True:
|
|
||||||
assert jungfrau.power_chip == False
|
|
||||||
jungfrau.power_chip = True
|
|
||||||
assert jungfrau.power_chip == False
|
|
||||||
jungfrau.temperature_control = False
|
|
||||||
assert jungfrau.power_chip == True
|
|
||||||
jungfrau.temperature_control = True
|
|
||||||
jungfrau.temperature_threshold = 50
|
|
||||||
assert jungfrau.power_chip == False
|
|
||||||
|
|
||||||
print('\t\tWaiting to cool down the board. This may take a while...')
|
|
||||||
while jungfrau.temperature_threshold < jungfrau.temp.fpga[0]:
|
|
||||||
time.sleep(5)
|
|
||||||
print('\t\tJungfrau MCB temperature: {0:.2f} °C'.format(jungfrau.temp.fpga[0]))
|
|
||||||
|
|
||||||
#Leave enough time to let the board cool down a bit more
|
|
||||||
time.sleep(30)
|
|
||||||
jungfrau.reset_temperature_event()
|
|
||||||
|
|
||||||
assert jungfrau.temperature_event == False
|
|
||||||
assert jungfrau.power_chip == True
|
|
||||||
|
|
||||||
else:
|
|
||||||
assert jungfrau.power_chip == True
|
|
||||||
else:
|
|
||||||
print('\t\tWaiting to warm up the board. This may take a while...')
|
|
||||||
while jungfrau.temperature_threshold > jungfrau.temp.fpga[0]:
|
|
||||||
time.sleep(5)
|
|
||||||
print('\t\tJungfrau MCB temperature: {0:.2f} °C'.format(jungfrau.temp.fpga[0]))
|
|
||||||
|
|
||||||
assert jungfrau.temperature_event == False
|
|
||||||
assert jungfrau.power_chip == True
|
|
||||||
|
|
||||||
print('\tFinished powerchip_test test case')
|
|
||||||
|
|
||||||
|
|
||||||
#@jungfrautest
|
|
||||||
def test_main(jungfrau):
|
|
||||||
|
|
||||||
print('\nTesting overtemperature protection control')
|
|
||||||
|
|
||||||
powerchip_test(jungfrau, False)
|
|
||||||
powerchip_test(jungfrau, True)
|
|
||||||
|
|
||||||
print('Tested overtemperature protection control')
|
|
@ -8,31 +8,12 @@ from .mythen3 import Mythen3
|
|||||||
from .gotthard2 import Gotthard2
|
from .gotthard2 import Gotthard2
|
||||||
from .gotthard import Gotthard
|
from .gotthard import Gotthard
|
||||||
from .moench import Moench
|
from .moench import Moench
|
||||||
# from .jungfrau_ctb import JungfrauCTB
|
|
||||||
# from _slsdet import DetectorApi
|
|
||||||
|
|
||||||
import _slsdet
|
import _slsdet
|
||||||
|
xy = _slsdet.xy
|
||||||
defs = _slsdet.slsDetectorDefs
|
defs = _slsdet.slsDetectorDefs
|
||||||
|
|
||||||
from .enums import *
|
from .enums import *
|
||||||
# runStatus = _slsdet.slsDetectorDefs.runStatus
|
|
||||||
# speedLevel = _slsdet.slsDetectorDefs.speedLevel
|
|
||||||
# detectorType = _slsdet.slsDetectorDefs.detectorType
|
|
||||||
# frameDiscardPolicy = _slsdet.slsDetectorDefs.frameDiscardPolicy
|
|
||||||
# fileFormat = _slsdet.slsDetectorDefs.fileFormat
|
|
||||||
# dimension = _slsdet.slsDetectorDefs.dimension
|
|
||||||
# externalSignalFlag = _slsdet.slsDetectorDefs.externalSignalFlag
|
|
||||||
# timingMode = _slsdet.slsDetectorDefs.timingMode
|
|
||||||
# dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
|
||||||
# detectorSettings = _slsdet.slsDetectorDefs.detectorSettings
|
|
||||||
# clockIndex = _slsdet.slsDetectorDefs.clockIndex
|
|
||||||
# readoutMode = _slsdet.slsDetectorDefs.readoutMode
|
|
||||||
# masterFlags = _slsdet.slsDetectorDefs.masterFlags
|
|
||||||
# frameModeType = _slsdet.slsDetectorDefs.frameModeType
|
|
||||||
# detectorModeType = _slsdet.slsDetectorDefs.detectorModeType
|
|
||||||
# burstMode = _slsdet.slsDetectorDefs.burstMode
|
|
||||||
# timingSourceType = _slsdet.slsDetectorDefs.timingSourceType
|
|
||||||
|
|
||||||
|
|
||||||
IpAddr = _slsdet.IpAddr
|
IpAddr = _slsdet.IpAddr
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,5 @@ detectorSettings = _slsdet.slsDetectorDefs.detectorSettings
|
|||||||
clockIndex = _slsdet.slsDetectorDefs.clockIndex
|
clockIndex = _slsdet.slsDetectorDefs.clockIndex
|
||||||
readoutMode = _slsdet.slsDetectorDefs.readoutMode
|
readoutMode = _slsdet.slsDetectorDefs.readoutMode
|
||||||
masterFlags = _slsdet.slsDetectorDefs.masterFlags
|
masterFlags = _slsdet.slsDetectorDefs.masterFlags
|
||||||
frameModeType = _slsdet.slsDetectorDefs.frameModeType
|
|
||||||
detectorModeType = _slsdet.slsDetectorDefs.detectorModeType
|
|
||||||
burstMode = _slsdet.slsDetectorDefs.burstMode
|
burstMode = _slsdet.slsDetectorDefs.burstMode
|
||||||
timingSourceType = _slsdet.slsDetectorDefs.timingSourceType
|
timingSourceType = _slsdet.slsDetectorDefs.timingSourceType
|
@ -1,30 +0,0 @@
|
|||||||
from .utils import element_if_equal
|
|
||||||
|
|
||||||
class JsonProxy:
|
|
||||||
"""
|
|
||||||
Proxy class to allow for intuitive setting and getting of rx_jsonpara
|
|
||||||
This class is returned by Detectr.rx_jsonpara
|
|
||||||
"""
|
|
||||||
def __init__(self, det):
|
|
||||||
self.det = det
|
|
||||||
|
|
||||||
def __getitem__(self, key):
|
|
||||||
return element_if_equal(self.det.getAdditionalJsonParameter(key))
|
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
|
||||||
self.det.setAdditionalJsonParameter(key, str(value))
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
r = element_if_equal(self.det.getAdditionalJsonHeader())
|
|
||||||
if isinstance(r, list):
|
|
||||||
rstr = ''
|
|
||||||
for i, list_item in enumerate(r):
|
|
||||||
list_item = dict(list_item)
|
|
||||||
rstr += ''.join([f'{i}:{key}: {value}\n' for key, value in list_item.items()])
|
|
||||||
|
|
||||||
return rstr.strip('\n')
|
|
||||||
else:
|
|
||||||
r = dict(r)
|
|
||||||
return '\n'.join([f'{key}: {value}' for key, value in r.items()])
|
|
||||||
|
|
||||||
|
|
128
python/slsdet/proxy.py
Normal file
128
python/slsdet/proxy.py
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
from .utils import element_if_equal
|
||||||
|
from .enums import dacIndex
|
||||||
|
|
||||||
|
|
||||||
|
def set_proxy_using_dict(func, key, value):
|
||||||
|
if isinstance(value, dict) and all(isinstance(k, int) for k in value.keys()):
|
||||||
|
for dkey, dvalue in value.items():
|
||||||
|
func(key, dvalue, [dkey])
|
||||||
|
else:
|
||||||
|
func(key, value)
|
||||||
|
|
||||||
|
class JsonProxy:
|
||||||
|
"""
|
||||||
|
Proxy class to allow for intuitive setting and getting of rx_jsonpara
|
||||||
|
This class is returned by Detectr.rx_jsonpara
|
||||||
|
"""
|
||||||
|
def __init__(self, det):
|
||||||
|
self.det = det
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
return element_if_equal(self.det.getAdditionalJsonParameter(key))
|
||||||
|
|
||||||
|
def __setitem__(self, key, value):
|
||||||
|
self.det.setAdditionalJsonParameter(key, str(value))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
r = element_if_equal(self.det.getAdditionalJsonHeader())
|
||||||
|
if isinstance(r, list):
|
||||||
|
rstr = ''
|
||||||
|
for i, list_item in enumerate(r):
|
||||||
|
list_item = dict(list_item)
|
||||||
|
rstr += ''.join([f'{i}:{key}: {value}\n' for key, value in list_item.items()])
|
||||||
|
|
||||||
|
return rstr.strip('\n')
|
||||||
|
else:
|
||||||
|
r = dict(r)
|
||||||
|
return '\n'.join([f'{key}: {value}' for key, value in r.items()])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class SlowAdcProxy:
|
||||||
|
"""
|
||||||
|
Proxy class to allow for more intuitive reading the slow ADCs
|
||||||
|
"""
|
||||||
|
def __init__(self, det):
|
||||||
|
self.det = det
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
dac_index = dacIndex(int(dacIndex.SLOW_ADC0)+key)
|
||||||
|
return element_if_equal(self.det.getSlowADC(dac_index))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
rstr = ''
|
||||||
|
for i in range(8):
|
||||||
|
r = element_if_equal(self.__getitem__(i))
|
||||||
|
if isinstance(r, list):
|
||||||
|
rstr += ' '.join(f'{item} uV' for item in r)
|
||||||
|
else:
|
||||||
|
rstr += f'{i}: {r} uV\n'
|
||||||
|
|
||||||
|
return rstr.strip('\n')
|
||||||
|
|
||||||
|
class ClkDivProxy:
|
||||||
|
"""
|
||||||
|
Proxy class to allow for more intuitive reading clockdivider
|
||||||
|
"""
|
||||||
|
def __init__(self, det):
|
||||||
|
self.det = det
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
return element_if_equal(self.det.getClockDivider(key))
|
||||||
|
|
||||||
|
def __setitem__(self, key, value):
|
||||||
|
set_proxy_using_dict(self.det.setClockDivider, key, value)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
rstr = ''
|
||||||
|
for i in range(6):
|
||||||
|
r = element_if_equal(self.__getitem__(i))
|
||||||
|
if isinstance(r, list):
|
||||||
|
rstr += ' '.join(f'{item}' for item in r)
|
||||||
|
else:
|
||||||
|
rstr += f'{i}: {r}\n'
|
||||||
|
|
||||||
|
return rstr.strip('\n')
|
||||||
|
|
||||||
|
|
||||||
|
class MaxPhaseProxy:
|
||||||
|
"""
|
||||||
|
Proxy class to allow for more intuitive reading clockdivider
|
||||||
|
"""
|
||||||
|
def __init__(self, det):
|
||||||
|
self.det = det
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
return element_if_equal(self.det.getMaxClockPhaseShift(key))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
rstr = ''
|
||||||
|
for i in range(5):
|
||||||
|
r = element_if_equal(self.__getitem__(i))
|
||||||
|
if isinstance(r, list):
|
||||||
|
rstr += ' '.join(f'{item}' for item in r)
|
||||||
|
else:
|
||||||
|
rstr += f'{i}: {r}\n'
|
||||||
|
|
||||||
|
return rstr.strip('\n')
|
||||||
|
|
||||||
|
class ClkFreqProxy:
|
||||||
|
"""
|
||||||
|
Proxy class to allow for more intuitive reading clockdivider
|
||||||
|
"""
|
||||||
|
def __init__(self, det):
|
||||||
|
self.det = det
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
return element_if_equal(self.det.getClockFrequency(key))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
rstr = ''
|
||||||
|
for i in range(5):
|
||||||
|
r = element_if_equal(self.__getitem__(i))
|
||||||
|
if isinstance(r, list):
|
||||||
|
rstr += ' '.join(f'{item}' for item in r)
|
||||||
|
else:
|
||||||
|
rstr += f'{i}: {r}\n'
|
||||||
|
|
||||||
|
return rstr.strip('\n')
|
@ -3,28 +3,31 @@ Utility functions that are useful for testing and troubleshooting
|
|||||||
but not directly used in controlling the detector
|
but not directly used in controlling the detector
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import _slsdet #C++ lib
|
import _slsdet #C++ lib
|
||||||
import functools
|
import functools
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
import pathlib
|
import pathlib
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
Geometry = namedtuple('Geometry', ['x', 'y'])
|
Geometry = namedtuple('Geometry', ['x', 'y'])
|
||||||
|
|
||||||
|
|
||||||
def is_iterable(item):
|
def is_iterable(item):
|
||||||
try:
|
try:
|
||||||
iter(item)
|
iter(item)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_set_bits(mask):
|
def get_set_bits(mask):
|
||||||
"""
|
"""
|
||||||
Return a list of the set bits in a python integer
|
Return a list of the set bits in a python integer
|
||||||
"""
|
"""
|
||||||
return [i for i in range(mask.bit_length()) if (mask>>i)&1]
|
return [i for i in range(mask.bit_length()) if (mask >> i) & 1]
|
||||||
|
|
||||||
|
|
||||||
def list_to_bitmask(values):
|
def list_to_bitmask(values):
|
||||||
"""
|
"""
|
||||||
@ -32,16 +35,26 @@ def list_to_bitmask(values):
|
|||||||
where the list indicates
|
where the list indicates
|
||||||
"""
|
"""
|
||||||
mask = int(0)
|
mask = int(0)
|
||||||
values = list(set(values)) #Remove duplicates
|
values = list(set(values)) #Remove duplicates
|
||||||
for v in values:
|
for v in values:
|
||||||
mask += 1 << v
|
mask += 1 << v
|
||||||
return mask
|
return mask
|
||||||
|
|
||||||
|
def make_bitmask(args):
|
||||||
|
if isinstance(args, list):
|
||||||
|
return list_to_bitmask(args)
|
||||||
|
elif isinstance(args, dict):
|
||||||
|
return {key: list_to_bitmask(value) for key, value in args.items()}
|
||||||
|
else:
|
||||||
|
raise ValueError("Cannot convert arg to bitmask")
|
||||||
|
|
||||||
|
|
||||||
def to_geo(value):
|
def to_geo(value):
|
||||||
if isinstance(value, _slsdet.xy):
|
if isinstance(value, _slsdet.xy):
|
||||||
return Geometry(x = value.x, y = value.y)
|
return Geometry(x=value.x, y=value.y)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Can only convert sls_detector.xy")
|
raise ValueError("Can only convert slsdet.xy")
|
||||||
|
|
||||||
|
|
||||||
def all_equal(mylist):
|
def all_equal(mylist):
|
||||||
"""If all elements are equal return true otherwise false"""
|
"""If all elements are equal return true otherwise false"""
|
||||||
@ -52,7 +65,7 @@ def element_if_equal(mylist):
|
|||||||
"""If all elements are equal return only one element"""
|
"""If all elements are equal return only one element"""
|
||||||
if not is_iterable(mylist):
|
if not is_iterable(mylist):
|
||||||
return mylist
|
return mylist
|
||||||
|
|
||||||
if all_equal(mylist):
|
if all_equal(mylist):
|
||||||
if len(mylist) == 0:
|
if len(mylist) == 0:
|
||||||
return None
|
return None
|
||||||
@ -61,6 +74,7 @@ def element_if_equal(mylist):
|
|||||||
else:
|
else:
|
||||||
return mylist
|
return mylist
|
||||||
|
|
||||||
|
|
||||||
def reduce_time(mylist):
|
def reduce_time(mylist):
|
||||||
res = element_if_equal(element_if_equal(mylist))
|
res = element_if_equal(element_if_equal(mylist))
|
||||||
if isinstance(res, dt.timedelta):
|
if isinstance(res, dt.timedelta):
|
||||||
@ -70,6 +84,7 @@ def reduce_time(mylist):
|
|||||||
else:
|
else:
|
||||||
return [r.total_seconds() for r in res]
|
return [r.total_seconds() for r in res]
|
||||||
|
|
||||||
|
|
||||||
def element(func):
|
def element(func):
|
||||||
"""
|
"""
|
||||||
Wrapper to return either list or element
|
Wrapper to return either list or element
|
||||||
@ -77,6 +92,7 @@ def element(func):
|
|||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(self, *args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
return element_if_equal(func(self, *args, **kwargs))
|
return element_if_equal(func(self, *args, **kwargs))
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
@ -89,15 +105,17 @@ def eiger_register_to_time(register):
|
|||||||
"""
|
"""
|
||||||
clocks = register >> 3
|
clocks = register >> 3
|
||||||
exponent = register & 0b111
|
exponent = register & 0b111
|
||||||
return clocks*10**exponent / 100e6
|
return clocks * 10**exponent / 100e6
|
||||||
|
|
||||||
|
|
||||||
def make_timedelta(t):
|
def make_timedelta(t):
|
||||||
if isinstance(t, dt.timedelta):
|
if isinstance(t, dt.timedelta):
|
||||||
return t
|
return t
|
||||||
else:
|
else:
|
||||||
return dt.timedelta(seconds=t)
|
return dt.timedelta(seconds=t)
|
||||||
|
|
||||||
def make_string_path(path):
|
|
||||||
|
def _make_string_path(path):
|
||||||
"""
|
"""
|
||||||
Accepts either a pathlib.Path or a string, expands ~ to user and convert
|
Accepts either a pathlib.Path or a string, expands ~ to user and convert
|
||||||
Path to str
|
Path to str
|
||||||
@ -110,20 +128,83 @@ def make_string_path(path):
|
|||||||
raise ValueError("Cannot convert argument to posix path")
|
raise ValueError("Cannot convert argument to posix path")
|
||||||
|
|
||||||
|
|
||||||
def set_using_dict(func, args):
|
def make_string_path(path):
|
||||||
if isinstance(args, dict):
|
return _make(path, _make_string_path)
|
||||||
for key, value in args.items():
|
|
||||||
func(value, [key])
|
|
||||||
|
def make_ip(arg):
|
||||||
|
return _make(arg, _slsdet.IpAddr)
|
||||||
|
|
||||||
|
|
||||||
|
def make_mac(arg):
|
||||||
|
return _make(arg, _slsdet.MacAddr)
|
||||||
|
|
||||||
|
|
||||||
|
def make_path(arg):
|
||||||
|
return _make(arg, Path)
|
||||||
|
|
||||||
|
|
||||||
|
def _make(arg, transform):
|
||||||
|
"""Helper function for make_mac and make_ip special cases for
|
||||||
|
dict, list and tuple. Otherwise just calls transform"""
|
||||||
|
if isinstance(arg, dict):
|
||||||
|
return {key: transform(value) for key, value in arg.items()}
|
||||||
|
elif isinstance(arg, list):
|
||||||
|
return [transform(a) for a in arg]
|
||||||
|
elif isinstance(arg, tuple):
|
||||||
|
return tuple(transform(a) for a in arg)
|
||||||
else:
|
else:
|
||||||
func(args)
|
return transform(arg)
|
||||||
|
|
||||||
|
|
||||||
|
def set_using_dict(func, *args):
|
||||||
|
|
||||||
|
if len(args) == 1 and isinstance(args[0], dict) and all(
|
||||||
|
isinstance(k, int) for k in args[0].keys()):
|
||||||
|
for key, value in args[0].items():
|
||||||
|
if not isinstance(value, tuple):
|
||||||
|
value = (value,)
|
||||||
|
try:
|
||||||
|
func(*value, [key])
|
||||||
|
except TypeError:
|
||||||
|
func(*value, key)
|
||||||
|
else:
|
||||||
|
func(*args)
|
||||||
|
|
||||||
|
|
||||||
def set_time_using_dict(func, args):
|
def set_time_using_dict(func, args):
|
||||||
if isinstance(args, dict):
|
if isinstance(args, dict) and all(isinstance(k, int) for k in args.keys()):
|
||||||
for key, value in args.items():
|
for key, value in args.items():
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
value = float(value)
|
value = float(value)
|
||||||
func(value, [key])
|
func(value, [key])
|
||||||
else:
|
else:
|
||||||
if isinstance(args, int):
|
if isinstance(args, int):
|
||||||
args = float(args)
|
args = float(args)
|
||||||
func(args)
|
func(args)
|
||||||
|
|
||||||
|
|
||||||
|
def lhex(iterable):
|
||||||
|
return [hex(item) for item in iterable]
|
||||||
|
|
||||||
|
|
||||||
|
def lpath(iterable):
|
||||||
|
return [Path(item) for item in iterable]
|
||||||
|
|
||||||
|
def add_argument_before(a, args):
|
||||||
|
"""Add a before the other arguments. Also works with
|
||||||
|
dict that holds args to several modules. Always puts the
|
||||||
|
args in a dict to be compatible with set_using_dict"""
|
||||||
|
print(f'{args=}')
|
||||||
|
if isinstance(args, tuple):
|
||||||
|
return (a, *args)
|
||||||
|
elif isinstance(args, dict):
|
||||||
|
ret = {}
|
||||||
|
for key, value in args.items():
|
||||||
|
if isinstance(value, tuple):
|
||||||
|
ret[key] = (a, *value)
|
||||||
|
else:
|
||||||
|
ret[key] = (a, value)
|
||||||
|
return (ret,)
|
||||||
|
return a, args
|
||||||
|
|
@ -253,10 +253,6 @@ void init_det(py::module &m) {
|
|||||||
(Result<int>(Detector::*)(int, sls::Positions)) &
|
(Result<int>(Detector::*)(int, sls::Positions)) &
|
||||||
Detector::getClockFrequency,
|
Detector::getClockFrequency,
|
||||||
py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("setClockFrequency",
|
|
||||||
(void (Detector::*)(int, int, sls::Positions)) &
|
|
||||||
Detector::setClockFrequency,
|
|
||||||
py::arg(), py::arg(), py::arg() = Positions{})
|
|
||||||
.def("getClockPhase",
|
.def("getClockPhase",
|
||||||
(Result<int>(Detector::*)(int, sls::Positions)) &
|
(Result<int>(Detector::*)(int, sls::Positions)) &
|
||||||
Detector::getClockPhase,
|
Detector::getClockPhase,
|
||||||
@ -322,11 +318,11 @@ void init_det(py::module &m) {
|
|||||||
(Result<int>(Detector::*)(defs::dacIndex, bool, sls::Positions)
|
(Result<int>(Detector::*)(defs::dacIndex, bool, sls::Positions)
|
||||||
const) &
|
const) &
|
||||||
Detector::getDAC,
|
Detector::getDAC,
|
||||||
py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = false, py::arg() = Positions{})
|
||||||
.def("setDAC",
|
.def("setDAC",
|
||||||
(void (Detector::*)(defs::dacIndex, int, bool, sls::Positions)) &
|
(void (Detector::*)(defs::dacIndex, int, bool, sls::Positions)) &
|
||||||
Detector::setDAC,
|
Detector::setDAC,
|
||||||
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg(), py::arg() = false, py::arg() = Positions{})
|
||||||
.def("getOnChipDAC",
|
.def("getOnChipDAC",
|
||||||
(Result<int>(Detector::*)(defs::dacIndex, int, sls::Positions)
|
(Result<int>(Detector::*)(defs::dacIndex, int, sls::Positions)
|
||||||
const) &
|
const) &
|
||||||
@ -346,6 +342,14 @@ void init_det(py::module &m) {
|
|||||||
sls::Positions)) &
|
sls::Positions)) &
|
||||||
Detector::setExternalSignalFlags,
|
Detector::setExternalSignalFlags,
|
||||||
py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getParallelMode",
|
||||||
|
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getParallelMode,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setParallelMode",
|
||||||
|
(void (Detector::*)(bool, sls::Positions)) &
|
||||||
|
Detector::setParallelMode,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("acquire", (void (Detector::*)()) & Detector::acquire)
|
.def("acquire", (void (Detector::*)()) & Detector::acquire)
|
||||||
.def("clearAcquiringFlag",
|
.def("clearAcquiringFlag",
|
||||||
(void (Detector::*)()) & Detector::clearAcquiringFlag)
|
(void (Detector::*)()) & Detector::clearAcquiringFlag)
|
||||||
@ -480,14 +484,14 @@ void init_det(py::module &m) {
|
|||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setDestinationUDPPort",
|
.def("setDestinationUDPPort",
|
||||||
(void (Detector::*)(int, int)) & Detector::setDestinationUDPPort,
|
(void (Detector::*)(int, int)) & Detector::setDestinationUDPPort,
|
||||||
py::arg(), py::arg())
|
py::arg(), py::arg() = -1)
|
||||||
.def("getDestinationUDPPort2",
|
.def("getDestinationUDPPort2",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getDestinationUDPPort2,
|
Detector::getDestinationUDPPort2,
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setDestinationUDPPort2",
|
.def("setDestinationUDPPort2",
|
||||||
(void (Detector::*)(int, int)) & Detector::setDestinationUDPPort2,
|
(void (Detector::*)(int, int)) & Detector::setDestinationUDPPort2,
|
||||||
py::arg(), py::arg())
|
py::arg(), py::arg() = -1)
|
||||||
.def("reconfigureUDPDestination",
|
.def("reconfigureUDPDestination",
|
||||||
(void (Detector::*)(sls::Positions)) &
|
(void (Detector::*)(sls::Positions)) &
|
||||||
Detector::reconfigureUDPDestination,
|
Detector::reconfigureUDPDestination,
|
||||||
@ -560,7 +564,7 @@ void init_det(py::module &m) {
|
|||||||
Detector::getRxPort,
|
Detector::getRxPort,
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setRxPort", (void (Detector::*)(int, int)) & Detector::setRxPort,
|
.def("setRxPort", (void (Detector::*)(int, int)) & Detector::setRxPort,
|
||||||
py::arg(), py::arg())
|
py::arg(), py::arg() = -1)
|
||||||
.def("getRxFifoDepth",
|
.def("getRxFifoDepth",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getRxFifoDepth,
|
Detector::getRxFifoDepth,
|
||||||
@ -661,13 +665,10 @@ void init_det(py::module &m) {
|
|||||||
Detector::setFileWrite,
|
Detector::setFileWrite,
|
||||||
py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("getMasterFileWrite",
|
.def("getMasterFileWrite",
|
||||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
(bool (Detector::*)() const) & Detector::getMasterFileWrite)
|
||||||
Detector::getMasterFileWrite,
|
|
||||||
py::arg() = Positions{})
|
|
||||||
.def("setMasterFileWrite",
|
.def("setMasterFileWrite",
|
||||||
(void (Detector::*)(bool, sls::Positions)) &
|
(void (Detector::*)(bool)) & Detector::setMasterFileWrite,
|
||||||
Detector::setMasterFileWrite,
|
py::arg())
|
||||||
py::arg(), py::arg() = Positions{})
|
|
||||||
.def("getFileOverWrite",
|
.def("getFileOverWrite",
|
||||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getFileOverWrite,
|
Detector::getFileOverWrite,
|
||||||
@ -722,7 +723,7 @@ void init_det(py::module &m) {
|
|||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setRxZmqPort",
|
.def("setRxZmqPort",
|
||||||
(void (Detector::*)(int, int)) & Detector::setRxZmqPort, py::arg(),
|
(void (Detector::*)(int, int)) & Detector::setRxZmqPort, py::arg(),
|
||||||
py::arg())
|
py::arg() = -1)
|
||||||
.def("getRxZmqIP",
|
.def("getRxZmqIP",
|
||||||
(Result<sls::IpAddr>(Detector::*)(sls::Positions) const) &
|
(Result<sls::IpAddr>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getRxZmqIP,
|
Detector::getRxZmqIP,
|
||||||
@ -737,7 +738,7 @@ void init_det(py::module &m) {
|
|||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setClientZmqPort",
|
.def("setClientZmqPort",
|
||||||
(void (Detector::*)(int, int)) & Detector::setClientZmqPort,
|
(void (Detector::*)(int, int)) & Detector::setClientZmqPort,
|
||||||
py::arg(), py::arg())
|
py::arg(), py::arg() = -1)
|
||||||
.def("getClientZmqIp",
|
.def("getClientZmqIp",
|
||||||
(Result<sls::IpAddr>(Detector::*)(sls::Positions) const) &
|
(Result<sls::IpAddr>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getClientZmqIp,
|
Detector::getClientZmqIp,
|
||||||
@ -770,7 +771,8 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(int, defs::detectorSettings, bool,
|
(void (Detector::*)(int, defs::detectorSettings, bool,
|
||||||
sls::Positions)) &
|
sls::Positions)) &
|
||||||
Detector::setThresholdEnergy,
|
Detector::setThresholdEnergy,
|
||||||
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = defs::STANDARD, py::arg() = true,
|
||||||
|
py::arg() = Positions{})
|
||||||
.def("getSettingsPath",
|
.def("getSettingsPath",
|
||||||
(Result<std::string>(Detector::*)(sls::Positions) const) &
|
(Result<std::string>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getSettingsPath,
|
Detector::getSettingsPath,
|
||||||
@ -779,14 +781,6 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||||
Detector::setSettingsPath,
|
Detector::setSettingsPath,
|
||||||
py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("getParallelMode",
|
|
||||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
|
||||||
Detector::getParallelMode,
|
|
||||||
py::arg() = Positions{})
|
|
||||||
.def("setParallelMode",
|
|
||||||
(void (Detector::*)(bool, sls::Positions)) &
|
|
||||||
Detector::setParallelMode,
|
|
||||||
py::arg(), py::arg() = Positions{})
|
|
||||||
.def("getOverFlowMode",
|
.def("getOverFlowMode",
|
||||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getOverFlowMode,
|
Detector::getOverFlowMode,
|
||||||
@ -971,6 +965,10 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(sls::ns, sls::Positions)) &
|
(void (Detector::*)(sls::ns, sls::Positions)) &
|
||||||
Detector::setBurstPeriod,
|
Detector::setBurstPeriod,
|
||||||
py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getNumberOfBurstsLeft",
|
||||||
|
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getNumberOfBurstsLeft,
|
||||||
|
py::arg() = Positions{})
|
||||||
.def("getInjectChannel",
|
.def("getInjectChannel",
|
||||||
(Result<std::array<int, 2>>(Detector::*)(sls::Positions)) &
|
(Result<std::array<int, 2>>(Detector::*)(sls::Positions)) &
|
||||||
Detector::getInjectChannel,
|
Detector::getInjectChannel,
|
||||||
@ -1344,31 +1342,6 @@ void init_det(py::module &m) {
|
|||||||
sls::Positions)) &
|
sls::Positions)) &
|
||||||
Detector::setAdditionalJsonParameter,
|
Detector::setAdditionalJsonParameter,
|
||||||
py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg(), py::arg() = Positions{})
|
||||||
.def("getDetectorMinMaxEnergyThreshold",
|
|
||||||
(Result<int>(Detector::*)(const bool, sls::Positions) const) &
|
|
||||||
Detector::getDetectorMinMaxEnergyThreshold,
|
|
||||||
py::arg(), py::arg() = Positions{})
|
|
||||||
.def("setDetectorMinMaxEnergyThreshold",
|
|
||||||
(void (Detector::*)(const bool, const int, sls::Positions)) &
|
|
||||||
Detector::setDetectorMinMaxEnergyThreshold,
|
|
||||||
py::arg(), py::arg(), py::arg() = Positions{})
|
|
||||||
.def("getFrameMode",
|
|
||||||
(Result<defs::frameModeType>(Detector::*)(sls::Positions) const) &
|
|
||||||
Detector::getFrameMode,
|
|
||||||
py::arg() = Positions{})
|
|
||||||
.def("setFrameMode",
|
|
||||||
(void (Detector::*)(defs::frameModeType, sls::Positions)) &
|
|
||||||
Detector::setFrameMode,
|
|
||||||
py::arg(), py::arg() = Positions{})
|
|
||||||
.def("getDetectorMode",
|
|
||||||
(Result<defs::detectorModeType>(Detector::*)(sls::Positions)
|
|
||||||
const) &
|
|
||||||
Detector::getDetectorMode,
|
|
||||||
py::arg() = Positions{})
|
|
||||||
.def("setDetectorMode",
|
|
||||||
(void (Detector::*)(defs::detectorModeType, sls::Positions)) &
|
|
||||||
Detector::setDetectorMode,
|
|
||||||
py::arg(), py::arg() = Positions{})
|
|
||||||
.def("programFPGA",
|
.def("programFPGA",
|
||||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||||
Detector::programFPGA,
|
Detector::programFPGA,
|
||||||
@ -1405,6 +1378,10 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(uint32_t, int, sls::Positions)) &
|
(void (Detector::*)(uint32_t, int, sls::Positions)) &
|
||||||
Detector::clearBit,
|
Detector::clearBit,
|
||||||
py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getBit",
|
||||||
|
(Result<int>(Detector::*)(uint32_t, int, sls::Positions)) &
|
||||||
|
Detector::getBit,
|
||||||
|
py::arg(), py::arg(), py::arg() = Positions{})
|
||||||
.def("executeFirmwareTest",
|
.def("executeFirmwareTest",
|
||||||
(void (Detector::*)(sls::Positions)) &
|
(void (Detector::*)(sls::Positions)) &
|
||||||
Detector::executeFirmwareTest,
|
Detector::executeFirmwareTest,
|
||||||
|
@ -259,20 +259,6 @@ void init_enums(py::module &m) {
|
|||||||
.value("IS_SLAVE", slsDetectorDefs::masterFlags::IS_SLAVE)
|
.value("IS_SLAVE", slsDetectorDefs::masterFlags::IS_SLAVE)
|
||||||
.export_values();
|
.export_values();
|
||||||
|
|
||||||
py::enum_<slsDetectorDefs::frameModeType>(Defs, "frameModeType")
|
|
||||||
.value("PEDESTAL", slsDetectorDefs::frameModeType::PEDESTAL)
|
|
||||||
.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("COUNTING", slsDetectorDefs::detectorModeType::COUNTING)
|
|
||||||
.value("INTERPOLATING",
|
|
||||||
slsDetectorDefs::detectorModeType::INTERPOLATING)
|
|
||||||
.value("ANALOG", slsDetectorDefs::detectorModeType::ANALOG)
|
|
||||||
.export_values();
|
|
||||||
|
|
||||||
py::enum_<slsDetectorDefs::burstMode>(Defs, "burstMode")
|
py::enum_<slsDetectorDefs::burstMode>(Defs, "burstMode")
|
||||||
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
|
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
|
||||||
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)
|
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)
|
||||||
|
@ -1,173 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Testing setting and getting dacs from the detector
|
|
||||||
"""
|
|
||||||
from unittest.mock import Mock, call
|
|
||||||
import pytest
|
|
||||||
from pytest_mock import mocker
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
from sls_detector import Eiger
|
|
||||||
from sls_detector import DetectorApi
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_vrf_for_three_mod(mocker):
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 3
|
|
||||||
m = mocker.patch.object(DetectorApi, 'getDac', autospec=True)
|
|
||||||
m.return_value = 1560
|
|
||||||
d = Eiger()
|
|
||||||
vrf = d.dacs.vrf[:]
|
|
||||||
assert vrf == [1560, 1560, 1560]
|
|
||||||
|
|
||||||
def test_set_vrf_for_three_mod_same_value(mocker):
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 3
|
|
||||||
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
|
|
||||||
# m.return_value = 1560
|
|
||||||
d = Eiger()
|
|
||||||
d.dacs.vrf[:] = 1500
|
|
||||||
calls = [call('vrf', 0, 1500), call('vrf', 1, 1500), call('vrf', 2, 1500)]
|
|
||||||
m.assert_has_calls(calls)
|
|
||||||
assert m.call_count == 3
|
|
||||||
|
|
||||||
def test_set_vrf_for_four_mod_different_value(mocker):
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 4
|
|
||||||
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
|
|
||||||
# m.return_value = 1560
|
|
||||||
d = Eiger()
|
|
||||||
d.dacs.vrf = [1500, 1600, 1800, 1502]
|
|
||||||
calls = [call('vrf', 0, 1500),
|
|
||||||
call('vrf', 1, 1600),
|
|
||||||
call('vrf', 2, 1800),
|
|
||||||
call('vrf', 3, 1502)]
|
|
||||||
m.assert_has_calls(calls)
|
|
||||||
assert m.call_count == 4
|
|
||||||
|
|
||||||
def test_set_vrf_for_four_mod_different_value_slice(mocker):
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 4
|
|
||||||
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
|
|
||||||
# m.return_value = 1560
|
|
||||||
d = Eiger()
|
|
||||||
d.dacs.vrf[:] = [1500, 1600, 1800, 1502]
|
|
||||||
calls = [call('vrf', 0, 1500),
|
|
||||||
call('vrf', 1, 1600),
|
|
||||||
call('vrf', 2, 1800),
|
|
||||||
call('vrf', 3, 1502)]
|
|
||||||
m.assert_has_calls(calls)
|
|
||||||
assert m.call_count == 4
|
|
||||||
|
|
||||||
def test_set_vcp_single_call(mocker):
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 2
|
|
||||||
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
|
|
||||||
# m.return_value = 1560
|
|
||||||
d = Eiger()
|
|
||||||
d.dacs.vcp[1] = 1637
|
|
||||||
m.assert_called_once_with('vcp', 1, 1637)
|
|
||||||
|
|
||||||
def test_iterate_on_index_call_vcn(mocker):
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 10
|
|
||||||
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
|
|
||||||
# m.return_value = 1560
|
|
||||||
d = Eiger()
|
|
||||||
d.dacs.vcn[0,3,8] = 1532
|
|
||||||
calls = [call('vcn', 0, 1532),
|
|
||||||
call('vcn', 3, 1532),
|
|
||||||
call('vcn', 8, 1532)]
|
|
||||||
m.assert_has_calls(calls)
|
|
||||||
assert m.call_count == 3
|
|
||||||
|
|
||||||
def test_set_dac_from_element_in_numpy_array(mocker):
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 2
|
|
||||||
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
|
|
||||||
d = Eiger()
|
|
||||||
|
|
||||||
vrf = np.array((1600,1700,1800))
|
|
||||||
d.dacs.vrf = vrf[0]
|
|
||||||
calls = [call('vrf', 0, 1600),
|
|
||||||
call('vrf', 1, 1600),]
|
|
||||||
m.assert_has_calls(calls)
|
|
||||||
assert m.call_count == 2
|
|
||||||
|
|
||||||
def test_set_dac_from_element_in_numpy_array_using_slice(mocker):
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 2
|
|
||||||
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
|
|
||||||
d = Eiger()
|
|
||||||
|
|
||||||
vrf = np.array((1600,1700,1800))
|
|
||||||
d.dacs.vrf[:] = vrf[0]
|
|
||||||
calls = [call('vrf', 0, 1600),
|
|
||||||
call('vrf', 1, 1600),]
|
|
||||||
m.assert_has_calls(calls)
|
|
||||||
assert m.call_count == 2
|
|
||||||
|
|
||||||
def test_set_eiger_default(mocker):
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 2
|
|
||||||
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
|
|
||||||
# m.return_value = 1560
|
|
||||||
d = Eiger()
|
|
||||||
d.dacs.set_default()
|
|
||||||
calls = [call('vsvp', 0, 0),
|
|
||||||
call('vsvp', 1, 0),
|
|
||||||
call('vtr', 0, 2500),
|
|
||||||
call('vtr', 1, 2500),
|
|
||||||
call('vrf', 0, 3300),
|
|
||||||
call('vrf', 1, 3300),
|
|
||||||
call('vrs', 0, 1400),
|
|
||||||
call('vrs', 1, 1400),
|
|
||||||
call('vsvn', 0, 4000),
|
|
||||||
call('vsvn', 1, 4000),
|
|
||||||
call('vtgstv', 0, 2556),
|
|
||||||
call('vtgstv', 1, 2556),
|
|
||||||
call('vcmp_ll', 0, 1500),
|
|
||||||
call('vcmp_ll', 1, 1500),
|
|
||||||
call('vcmp_lr', 0, 1500),
|
|
||||||
call('vcmp_lr', 1, 1500),
|
|
||||||
call('vcall', 0, 4000),
|
|
||||||
call('vcall', 1, 4000),
|
|
||||||
call('vcmp_rl', 0, 1500),
|
|
||||||
call('vcmp_rl', 1, 1500),
|
|
||||||
call('rxb_rb', 0, 1100),
|
|
||||||
call('rxb_rb', 1, 1100),
|
|
||||||
call('rxb_lb', 0, 1100),
|
|
||||||
call('rxb_lb', 1, 1100),
|
|
||||||
call('vcmp_rr', 0, 1500),
|
|
||||||
call('vcmp_rr', 1, 1500),
|
|
||||||
call('vcp', 0, 200),
|
|
||||||
call('vcp', 1, 200),
|
|
||||||
call('vcn', 0, 2000),
|
|
||||||
call('vcn', 1, 2000),
|
|
||||||
call('vis', 0, 1550),
|
|
||||||
call('vis', 1, 1550),
|
|
||||||
call('iodelay', 0, 660),
|
|
||||||
call('iodelay', 1, 660)]
|
|
||||||
|
|
||||||
m.assert_has_calls(calls)
|
|
||||||
assert m.call_count == 17*2
|
|
||||||
|
|
||||||
def test_set_eiger_set_from_array_call_count(mocker):
|
|
||||||
import numpy as np
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 3
|
|
||||||
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
|
|
||||||
# m.return_value = 1560
|
|
||||||
d = Eiger()
|
|
||||||
d.dacs.set_from_array( np.zeros((17,3)))
|
|
||||||
assert m.call_count == 17*3
|
|
||||||
|
|
||||||
def test_get_fpga_temp(mocker):
|
|
||||||
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
|
|
||||||
m2.return_value = 2
|
|
||||||
m = mocker.patch.object(DetectorApi, 'getAdc', autospec=True)
|
|
||||||
m.return_value = 34253
|
|
||||||
d = Eiger()
|
|
||||||
t = d.temp.fpga[:]
|
|
||||||
assert t == [34.253, 34.253]
|
|
@ -1,489 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Testing parameters and methods of the Detector class using mocks
|
|
||||||
"""
|
|
||||||
from unittest.mock import Mock
|
|
||||||
import pytest
|
|
||||||
from pytest_mock import mocker
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def d():
|
|
||||||
from sls_detector import Eiger
|
|
||||||
return Eiger()
|
|
||||||
|
|
||||||
|
|
||||||
def test_acq_call(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.acq')
|
|
||||||
d.acq()
|
|
||||||
m.assert_called_once_with()
|
|
||||||
|
|
||||||
def test_busy_call(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getAcquiringFlag')
|
|
||||||
m.return_value = False
|
|
||||||
assert d.busy == False
|
|
||||||
|
|
||||||
|
|
||||||
def test_assign_to_detector_type(d):
|
|
||||||
with pytest.raises(AttributeError):
|
|
||||||
d.detector_type = 'Eiger'
|
|
||||||
|
|
||||||
def test_det_type(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getDetectorType')
|
|
||||||
m.return_value = 'Eiger'
|
|
||||||
assert d.detector_type == 'Eiger'
|
|
||||||
|
|
||||||
def test_set_dynamic_range_4(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
|
|
||||||
d.dynamic_range = 4
|
|
||||||
m.assert_called_with(4)
|
|
||||||
|
|
||||||
def test_set_dynamic_range_8(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
|
|
||||||
d.dynamic_range = 8
|
|
||||||
m.assert_called_with(8)
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_dynamic_range_16(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
|
|
||||||
d.dynamic_range = 16
|
|
||||||
m.assert_called_with(16)
|
|
||||||
|
|
||||||
def test_set_dynamic_range_32(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
|
|
||||||
d.dynamic_range = 32
|
|
||||||
m.assert_called_with(32)
|
|
||||||
|
|
||||||
def test_set_dynamic_range_raises_exception(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setDynamicRange')
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.dynamic_range = 17
|
|
||||||
|
|
||||||
def test_get_dynamic_range_32(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getDynamicRange')
|
|
||||||
m.return_value = 32
|
|
||||||
dr = d.dynamic_range
|
|
||||||
assert dr == 32
|
|
||||||
|
|
||||||
def test_eiger_matrix_reset(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getCounterBit')
|
|
||||||
m.return_value = True
|
|
||||||
assert d.eiger_matrix_reset == True
|
|
||||||
|
|
||||||
def test_set_eiger_matrix_reset(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setCounterBit')
|
|
||||||
d.eiger_matrix_reset = True
|
|
||||||
m.assert_called_once_with(True)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_exposure_time(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getExposureTime')
|
|
||||||
m.return_value = 100000000
|
|
||||||
assert d.exposure_time == 0.1
|
|
||||||
|
|
||||||
def test_set_exposure_time(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setExposureTime')
|
|
||||||
d.exposure_time = 1.5
|
|
||||||
m.assert_called_once_with(1500000000)
|
|
||||||
|
|
||||||
def test_set_exposure_time_less_than_zero(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setExposureTime')
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.exposure_time = -7
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_file_index(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getFileIndex')
|
|
||||||
m.return_value = 8
|
|
||||||
assert d.file_index == 8
|
|
||||||
|
|
||||||
def test_set_file_index(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setFileIndex')
|
|
||||||
d.file_index = 9
|
|
||||||
m.assert_called_with(9)
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_file_index_raises_on_neg(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setFileIndex')
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.file_index = -9
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_file_name(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getFileName')
|
|
||||||
d.file_name
|
|
||||||
m.assert_called_once_with()
|
|
||||||
|
|
||||||
def test_set_file_name(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setFileName')
|
|
||||||
d.file_name = 'hej'
|
|
||||||
m.assert_called_once_with('hej')
|
|
||||||
|
|
||||||
def test_get_file_path(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getFilePath')
|
|
||||||
d.file_path
|
|
||||||
m.assert_called_once_with()
|
|
||||||
|
|
||||||
def test_set_file_path_when_path_exists(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setFilePath')
|
|
||||||
#To avoid raising an exception because path is not there
|
|
||||||
mock_os = mocker.patch('os.path.exists')
|
|
||||||
mock_os.return_value = True
|
|
||||||
d.file_path = '/path/to/something/'
|
|
||||||
m.assert_called_once_with('/path/to/something/')
|
|
||||||
|
|
||||||
def test_set_file_path_raises_when_not_exists(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setFilePath')
|
|
||||||
mock_os = mocker.patch('os.path.exists')
|
|
||||||
mock_os.return_value = False
|
|
||||||
with pytest.raises(FileNotFoundError):
|
|
||||||
d.file_path = '/path/to/something/'
|
|
||||||
|
|
||||||
def test_get_file_write(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getFileWrite')
|
|
||||||
m.return_value = False
|
|
||||||
assert d.file_write == False
|
|
||||||
|
|
||||||
def test_set_file_write(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setFileWrite')
|
|
||||||
d.file_write = True
|
|
||||||
m.assert_called_once_with(True)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_firmware_version(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getFirmwareVersion')
|
|
||||||
m.return_value = 20
|
|
||||||
assert d.firmware_version == 20
|
|
||||||
|
|
||||||
def test_cannot_set_fw_version(d):
|
|
||||||
with pytest.raises(AttributeError):
|
|
||||||
d.firmware_version = 20
|
|
||||||
|
|
||||||
def test_get_high_voltage_call_signature(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getDac')
|
|
||||||
d.high_voltage
|
|
||||||
m.assert_called_once_with('highvoltage', -1)
|
|
||||||
|
|
||||||
def test_get_high_voltage(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getDac')
|
|
||||||
m.return_value = 80
|
|
||||||
assert d.high_voltage == 80
|
|
||||||
|
|
||||||
#self._api.setDac('highvoltage', -1, voltage)
|
|
||||||
def test_set_high_voltage(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setDac')
|
|
||||||
d.high_voltage = 80
|
|
||||||
m.assert_called_once_with('highvoltage', -1, 80)
|
|
||||||
|
|
||||||
def test_decode_hostname_two_names(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getHostname')
|
|
||||||
m.return_value = 'beb059+beb048+'
|
|
||||||
assert d.hostname == ['beb059', 'beb048']
|
|
||||||
|
|
||||||
def test_decode_hostname_four_names(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getHostname')
|
|
||||||
m.return_value = 'beb059+beb048+beb120+beb153+'
|
|
||||||
assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
|
|
||||||
|
|
||||||
def test_decode_hostname_blank(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getHostname')
|
|
||||||
m.return_value = ''
|
|
||||||
assert d.hostname == []
|
|
||||||
|
|
||||||
def test_get_image_size_gives_correct_size(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getImageSize')
|
|
||||||
m.return_value = (512,1024)
|
|
||||||
im_size = d.image_size
|
|
||||||
assert im_size.rows == 512
|
|
||||||
assert im_size.cols == 1024
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_load_config(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
|
|
||||||
#To avoid raising an exception because path is not there
|
|
||||||
mock_os = mocker.patch('os.path.isfile')
|
|
||||||
mock_os.return_value = True
|
|
||||||
d.load_config('/path/to/my/file.config')
|
|
||||||
m.assert_called_once_with('/path/to/my/file.config')
|
|
||||||
|
|
||||||
def test_load_config_raises_when_file_is_not_found(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
|
|
||||||
mock_os = mocker.patch('os.path.isfile')
|
|
||||||
mock_os.return_value = False
|
|
||||||
with pytest.raises(FileNotFoundError):
|
|
||||||
d.load_config('/path/to/my/file.config')
|
|
||||||
|
|
||||||
def test_load_parameters(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.readParametersFile')
|
|
||||||
#To avoid raising an exception because path is not there
|
|
||||||
mock_os = mocker.patch('os.path.isfile')
|
|
||||||
mock_os.return_value = True
|
|
||||||
d.load_parameters('/path/to/my/file.par')
|
|
||||||
m.assert_called_once_with('/path/to/my/file.par')
|
|
||||||
|
|
||||||
def test_load_parameters_raises_when_file_is_not_found(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.readParametersFile')
|
|
||||||
mock_os = mocker.patch('os.path.isfile')
|
|
||||||
mock_os.return_value = False
|
|
||||||
with pytest.raises(FileNotFoundError):
|
|
||||||
d.load_parameters('/path/to/my/file.par')
|
|
||||||
|
|
||||||
#getDetectorGeometry
|
|
||||||
def test_get_module_geometry_gives_correct_size(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
|
|
||||||
m.return_value = (13,7)
|
|
||||||
g = d.module_geometry
|
|
||||||
assert g.vertical == 7
|
|
||||||
assert g.horizontal == 13
|
|
||||||
|
|
||||||
def test_get_module_geometry_access(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
|
|
||||||
m.return_value = (12,3)
|
|
||||||
assert d.module_geometry[0] == 12
|
|
||||||
assert d.module_geometry[1] == 3
|
|
||||||
assert d.module_geometry.vertical == 3
|
|
||||||
assert d.module_geometry.horizontal == 12
|
|
||||||
|
|
||||||
def test_get_n_frames(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getNumberOfFrames')
|
|
||||||
m.return_value = 3
|
|
||||||
assert d.n_frames == 3
|
|
||||||
|
|
||||||
def test_set_n_frames(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
|
|
||||||
d.n_frames = 9
|
|
||||||
m.assert_called_once_with(9)
|
|
||||||
|
|
||||||
def test_set_n_frames_raises_on_neg(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.n_frames = -1
|
|
||||||
|
|
||||||
def test_set_n_frames_raises_on_zero(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.n_frames = 0
|
|
||||||
|
|
||||||
def test_get_n_modules(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
|
|
||||||
m.return_value = 12
|
|
||||||
assert d.n_modules == 12
|
|
||||||
|
|
||||||
def test_get_period_time(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getPeriod')
|
|
||||||
m.return_value = 130000000
|
|
||||||
assert d.period == 0.13
|
|
||||||
|
|
||||||
def test_set_period_time(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setPeriod')
|
|
||||||
d.period = 1.953
|
|
||||||
m.assert_called_once_with(1953000000)
|
|
||||||
|
|
||||||
def test_set_period_time_less_than_zero(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setPeriod')
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.period = -7
|
|
||||||
|
|
||||||
def test_pulse_chip_call(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.pulseChip')
|
|
||||||
d.pulse_chip(15)
|
|
||||||
m.assert_called_once_with(15)
|
|
||||||
|
|
||||||
def test_pulse_chip_call_minus_one(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.pulseChip')
|
|
||||||
d.pulse_chip(-1)
|
|
||||||
m.assert_called_once_with(-1)
|
|
||||||
|
|
||||||
def test_pulse_chip_asserts_on_smaller_than_minus_one(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.pulseChip')
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.pulse_chip(-3)
|
|
||||||
#--------------------------------------------------------------------subexptime
|
|
||||||
def test_get_sub_exposure_time(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getSubExposureTime')
|
|
||||||
m.return_value = 2370000
|
|
||||||
assert d.sub_exposure_time == 0.00237
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_sub_exposure_time(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
|
|
||||||
d.sub_exposure_time = 0.002
|
|
||||||
m.assert_called_once_with(2000000)
|
|
||||||
|
|
||||||
def test_set_sub_exposure_time_raises_on_zero(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.sub_exposure_time = 0
|
|
||||||
|
|
||||||
#-------------------------------------------------------------Rate correction
|
|
||||||
def test_get_rate_correction(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getRateCorrection')
|
|
||||||
m.return_value = [132,129]
|
|
||||||
assert d.rate_correction == [132,129]
|
|
||||||
|
|
||||||
def test_set_rate_correction(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setRateCorrection')
|
|
||||||
mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
|
|
||||||
mock_n.return_value = 3
|
|
||||||
d.rate_correction = [123,90,50]
|
|
||||||
m.assert_called_once_with([123,90,50])
|
|
||||||
|
|
||||||
def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setRateCorrection')
|
|
||||||
mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
|
|
||||||
mock_n.return_value = 4
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.rate_correction = [123,90,50]
|
|
||||||
|
|
||||||
#----------------------------------------------------------------Readout clock
|
|
||||||
def test_get_readout_clock_0(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
|
|
||||||
m.return_value = 0
|
|
||||||
assert d.readout_clock == 'Full Speed'
|
|
||||||
|
|
||||||
def test_get_readout_clock_1(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
|
|
||||||
m.return_value = 1
|
|
||||||
assert d.readout_clock == 'Half Speed'
|
|
||||||
|
|
||||||
def test_get_readout_clock_2(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
|
|
||||||
m.return_value = 2
|
|
||||||
assert d.readout_clock == 'Quarter Speed'
|
|
||||||
|
|
||||||
def test_get_readout_clock_3(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
|
|
||||||
m.return_value = 3
|
|
||||||
assert d.readout_clock == 'Super Slow Speed'
|
|
||||||
|
|
||||||
def test_set_readout_clock_0(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
|
|
||||||
d.readout_clock = 'Full Speed'
|
|
||||||
m.assert_called_once_with(0)
|
|
||||||
|
|
||||||
def test_set_readout_clock_1(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
|
|
||||||
d.readout_clock = 'Half Speed'
|
|
||||||
m.assert_called_once_with(1)
|
|
||||||
|
|
||||||
def test_set_readout_clock_2(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
|
|
||||||
d.readout_clock = 'Quarter Speed'
|
|
||||||
m.assert_called_once_with(2)
|
|
||||||
|
|
||||||
def test_set_readout_clock_3(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
|
|
||||||
d.readout_clock = 'Super Slow Speed'
|
|
||||||
m.assert_called_once_with(3)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------rx_datastream
|
|
||||||
def test_get_rx_datastream(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getRxDataStreamStatus')
|
|
||||||
m.return_value = False
|
|
||||||
assert d.rx_datastream == False
|
|
||||||
|
|
||||||
def test_set_rx_datastream(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setRxDataStreamStatus')
|
|
||||||
d.rx_datastream = True
|
|
||||||
m.assert_called_once_with(True)
|
|
||||||
|
|
||||||
def test_get_rx_zmqip(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
|
|
||||||
d.rx_zmqip
|
|
||||||
m.assert_called_once_with('rx_zmqip')
|
|
||||||
|
|
||||||
def test_get_rx_zmqport_call(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
|
|
||||||
d.rx_zmqport
|
|
||||||
m.assert_called_once_with('rx_zmqport')
|
|
||||||
|
|
||||||
def test_get_rx_zmqport_decode(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
|
|
||||||
m.return_value = '30001+30003+'
|
|
||||||
assert d.rx_zmqport == [30001, 30002, 30003, 30004]
|
|
||||||
|
|
||||||
def test_get_rx_zmqport_empty(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
|
|
||||||
m.return_value = ''
|
|
||||||
assert d.rx_zmqport == []
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------status
|
|
||||||
def test_status_call(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getRunStatus')
|
|
||||||
d.status
|
|
||||||
m.assert_called_once_with()
|
|
||||||
|
|
||||||
def test_start_acq_call(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
|
|
||||||
d.start_acq()
|
|
||||||
m.assert_called_once_with()
|
|
||||||
|
|
||||||
def test_stop_acq_call(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.stopAcquisition')
|
|
||||||
d.stop_acq()
|
|
||||||
m.assert_called_once_with()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------subexptime
|
|
||||||
def test_get_sub_exposure_time(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getSubExposureTime')
|
|
||||||
m.return_value = 2370000
|
|
||||||
assert d.sub_exposure_time == 0.00237
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_sub_exposure_time(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
|
|
||||||
d.sub_exposure_time = 0.002
|
|
||||||
m.assert_called_once_with(2000000)
|
|
||||||
|
|
||||||
def test_set_sub_exposure_time_raises_on_zero(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.sub_exposure_time = 0
|
|
||||||
|
|
||||||
#------------------------------------------------------------------timing mode
|
|
||||||
def test_get_timing_mode(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getTimingMode')
|
|
||||||
d.timing_mode
|
|
||||||
m.assert_called_once_with()
|
|
||||||
|
|
||||||
def test_set_timing_mode(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setTimingMode')
|
|
||||||
d.timing_mode = 'auto'
|
|
||||||
m.assert_called_once_with('auto')
|
|
||||||
|
|
||||||
#----------------------------------------------------------------vthreshold
|
|
||||||
def test_get_vthreshold(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getDac')
|
|
||||||
d.vthreshold
|
|
||||||
m.assert_called_once_with('vthreshold', -1)
|
|
||||||
|
|
||||||
def test_set_vthreshold(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setDac')
|
|
||||||
d.vthreshold = 1675
|
|
||||||
m.assert_called_once_with('vthreshold', -1, 1675)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------trimbits
|
|
||||||
def test_get_trimbits(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.getAllTrimbits')
|
|
||||||
d.trimbits
|
|
||||||
m.assert_called_once_with()
|
|
||||||
|
|
||||||
def test_set_trimbits(d, mocker):
|
|
||||||
m = mocker.patch('_slsdet.DetectorApi.setAllTrimbits')
|
|
||||||
d.trimbits = 15
|
|
||||||
m.assert_called_once_with(15)
|
|
||||||
|
|
||||||
def test_set_trimbits_raises_outside_range(d, mocker):
|
|
||||||
mocker.patch('_slsdet.DetectorApi.setAllTrimbits')
|
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.trimbits = 69
|
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d.trimbits = -5
|
|
||||||
|
|
||||||
|
|
@ -1,489 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Testing the Detector python class by mocking calls.
|
|
||||||
Should only be used when there is functionality in
|
|
||||||
the detector.py file.
|
|
||||||
|
|
||||||
An example is converting a mask to a list of set bits.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from unittest.mock import Mock
|
|
||||||
import pytest
|
|
||||||
from pytest_mock import mocker
|
|
||||||
|
|
||||||
import sys
|
|
||||||
sys.path.append('/home/l_frojdh/slsdetectorgrup/sls_detector')
|
|
||||||
|
|
||||||
import _slsdet
|
|
||||||
from sls_detector.errors import DetectorValueError, DetectorError
|
|
||||||
from sls_detector.utils import all_equal, element_if_equal
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def d():
|
|
||||||
from sls_detector import Detector
|
|
||||||
return Detector()
|
|
||||||
|
|
||||||
def test_length(d, mocker):
|
|
||||||
m = mocker.patch('sls_detector.Detector.size')
|
|
||||||
m.return_value = 5
|
|
||||||
assert(len(d) == 5)
|
|
||||||
|
|
||||||
def test_counters_single(d, mocker):
|
|
||||||
m = mocker.patch('sls_detector.Detector.getCounterMask')
|
|
||||||
m.return_value = [7]
|
|
||||||
assert(d.counters == [0,1,2])
|
|
||||||
|
|
||||||
def test_counters_multi(d, mocker):
|
|
||||||
m = mocker.patch('sls_detector.Detector.getCounterMask')
|
|
||||||
m.return_value = [7, 9]
|
|
||||||
assert(d.counters == [[0,1,2],[0,3]])
|
|
||||||
|
|
||||||
def test_set_counters_single(d, mocker):
|
|
||||||
m = mocker.patch('sls_detector.Detector.setCounterMask')
|
|
||||||
d.counters = [0,2]
|
|
||||||
m.assert_called_once_with(5)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# def test_busy_call(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getAcquiringFlag')
|
|
||||||
# m.return_value = False
|
|
||||||
# assert d.busy == False
|
|
||||||
|
|
||||||
# def test_set_busy(d):
|
|
||||||
# d.busy = True
|
|
||||||
# assert d.busy == True
|
|
||||||
# assert d._api.getAcquiringFlag() == True
|
|
||||||
# d.busy = False
|
|
||||||
# assert d.busy == False
|
|
||||||
# assert d._api.getAcquiringFlag() == False
|
|
||||||
|
|
||||||
# def test_error_mask(d):
|
|
||||||
# d._api.setErrorMask(1)
|
|
||||||
# assert d.error_mask == 1
|
|
||||||
# d.clear_errors()
|
|
||||||
|
|
||||||
# def test_error_handling(d):
|
|
||||||
# with pytest.raises(DetectorError):
|
|
||||||
# d._provoke_error()
|
|
||||||
|
|
||||||
# def test_assign_to_detector_type(d):
|
|
||||||
# with pytest.raises(AttributeError):
|
|
||||||
# d.detector_type = 'Eiger'
|
|
||||||
|
|
||||||
# def test_det_type(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getDetectorType')
|
|
||||||
# m.return_value = 'Eiger'
|
|
||||||
# assert d.detector_type == 'Eiger'
|
|
||||||
|
|
||||||
|
|
||||||
# def test_get_exposure_time(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getExposureTime')
|
|
||||||
# m.return_value = 100000000
|
|
||||||
# assert d.exposure_time == 0.1
|
|
||||||
|
|
||||||
# def test_set_exposure_time(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setExposureTime')
|
|
||||||
# d.exposure_time = 1.5
|
|
||||||
# m.assert_called_once_with(1500000000)
|
|
||||||
|
|
||||||
# def test_set_exposure_time_less_than_zero(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.setExposureTime')
|
|
||||||
# with pytest.raises(DetectorValueError):
|
|
||||||
# d.exposure_time = -7
|
|
||||||
|
|
||||||
|
|
||||||
# def test_get_file_index(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getFileIndex')
|
|
||||||
# m.return_value = 8
|
|
||||||
# assert d.file_index == 8
|
|
||||||
|
|
||||||
# def test_set_file_index(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setFileIndex')
|
|
||||||
# d.file_index = 9
|
|
||||||
# m.assert_called_with(9)
|
|
||||||
|
|
||||||
|
|
||||||
# def file_index_with_no_detector(d):
|
|
||||||
# assert d.file_index == -100
|
|
||||||
|
|
||||||
# def dr_with_no_detector(d):
|
|
||||||
# assert d.dynamic_range == -100
|
|
||||||
|
|
||||||
# def test_set_file_index_raises_on_neg(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.setFileIndex')
|
|
||||||
# with pytest.raises(ValueError):
|
|
||||||
# d.file_index = -9
|
|
||||||
|
|
||||||
|
|
||||||
# def test_get_file_name(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getFileName')
|
|
||||||
# d.file_name
|
|
||||||
# m.assert_called_once_with()
|
|
||||||
|
|
||||||
# def test_set_file_name(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setFileName')
|
|
||||||
# d.file_name = 'hej'
|
|
||||||
# m.assert_called_once_with('hej')
|
|
||||||
|
|
||||||
# def test_get_file_path(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getFilePath')
|
|
||||||
# d.file_path
|
|
||||||
# m.assert_called_once_with()
|
|
||||||
|
|
||||||
# def test_set_file_path_when_path_exists(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setFilePath')
|
|
||||||
# #To avoid raising an exception because path is not there
|
|
||||||
# mock_os = mocker.patch('os.path.exists')
|
|
||||||
# mock_os.return_value = True
|
|
||||||
# d.file_path = '/path/to/something/'
|
|
||||||
# m.assert_called_once_with('/path/to/something/')
|
|
||||||
|
|
||||||
# def test_set_file_path_raises_when_not_exists(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.setFilePath')
|
|
||||||
# mock_os = mocker.patch('os.path.exists')
|
|
||||||
# mock_os.return_value = False
|
|
||||||
# with pytest.raises(FileNotFoundError):
|
|
||||||
# d.file_path = '/path/to/something/'
|
|
||||||
|
|
||||||
# def test_get_file_write(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getFileWrite')
|
|
||||||
# m.return_value = False
|
|
||||||
# assert d.file_write == False
|
|
||||||
|
|
||||||
# def test_set_file_write(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setFileWrite')
|
|
||||||
# d.file_write = True
|
|
||||||
# m.assert_called_once_with(True)
|
|
||||||
|
|
||||||
|
|
||||||
# def test_get_firmware_version(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getFirmwareVersion')
|
|
||||||
# m.return_value = 20
|
|
||||||
# assert d.firmware_version == 20
|
|
||||||
|
|
||||||
# def test_cannot_set_fw_version(d):
|
|
||||||
# with pytest.raises(AttributeError):
|
|
||||||
# d.firmware_version = 20
|
|
||||||
|
|
||||||
# def test_get_high_voltage_call_signature(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getDac')
|
|
||||||
# d.high_voltage
|
|
||||||
# m.assert_called_once_with('highvoltage', -1)
|
|
||||||
|
|
||||||
# def test_get_high_voltage(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getDac')
|
|
||||||
# m.return_value = 80
|
|
||||||
# assert d.high_voltage == 80
|
|
||||||
|
|
||||||
# #self._api.setDac('highvoltage', -1, voltage)
|
|
||||||
# def test_set_high_voltage(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setDac')
|
|
||||||
# d.high_voltage = 80
|
|
||||||
# m.assert_called_once_with('highvoltage', -1, 80)
|
|
||||||
|
|
||||||
# def test_decode_hostname_two_names(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getHostname')
|
|
||||||
# m.return_value = 'beb059+beb048+'
|
|
||||||
# assert d.hostname == ['beb059', 'beb048']
|
|
||||||
|
|
||||||
# def test_decode_hostname_four_names(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getHostname')
|
|
||||||
# m.return_value = 'beb059+beb048+beb120+beb153+'
|
|
||||||
# assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
|
|
||||||
|
|
||||||
# def test_decode_hostname_blank(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getHostname')
|
|
||||||
# m.return_value = ''
|
|
||||||
# assert d.hostname == []
|
|
||||||
|
|
||||||
# def test_get_image_size_gives_correct_size(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getImageSize')
|
|
||||||
# m.return_value = (512,1024)
|
|
||||||
# im_size = d.image_size
|
|
||||||
# assert im_size.rows == 512
|
|
||||||
# assert im_size.cols == 1024
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# def test_load_config(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
|
|
||||||
# #To avoid raising an exception because path is not there
|
|
||||||
# mock_os = mocker.patch('os.path.isfile')
|
|
||||||
# mock_os.return_value = True
|
|
||||||
# d.load_config('/path/to/my/file.config')
|
|
||||||
# m.assert_called_once_with('/path/to/my/file.config')
|
|
||||||
|
|
||||||
# def test_load_config_raises_when_file_is_not_found(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
|
|
||||||
# mock_os = mocker.patch('os.path.isfile')
|
|
||||||
# mock_os.return_value = False
|
|
||||||
# with pytest.raises(FileNotFoundError):
|
|
||||||
# d.load_config('/path/to/my/file.config')
|
|
||||||
|
|
||||||
# def test_load_parameters(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.readParametersFile')
|
|
||||||
# #To avoid raising an exception because path is not there
|
|
||||||
# mock_os = mocker.patch('os.path.isfile')
|
|
||||||
# mock_os.return_value = True
|
|
||||||
# d.load_parameters('/path/to/my/file.par')
|
|
||||||
# m.assert_called_once_with('/path/to/my/file.par')
|
|
||||||
|
|
||||||
# def test_load_parameters_raises_when_file_is_not_found(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.readParametersFile')
|
|
||||||
# mock_os = mocker.patch('os.path.isfile')
|
|
||||||
# mock_os.return_value = False
|
|
||||||
# with pytest.raises(FileNotFoundError):
|
|
||||||
# d.load_parameters('/path/to/my/file.par')
|
|
||||||
|
|
||||||
# #getDetectorGeometry
|
|
||||||
# def test_get_module_geometry_gives_correct_size(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
|
|
||||||
# m.return_value = (13,7)
|
|
||||||
# g = d.module_geometry
|
|
||||||
# assert g.vertical == 7
|
|
||||||
# assert g.horizontal == 13
|
|
||||||
|
|
||||||
# def test_get_module_geometry_access(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
|
|
||||||
# m.return_value = (12,3)
|
|
||||||
# assert d.module_geometry[0] == 12
|
|
||||||
# assert d.module_geometry[1] == 3
|
|
||||||
# assert d.module_geometry.vertical == 3
|
|
||||||
# assert d.module_geometry.horizontal == 12
|
|
||||||
|
|
||||||
# def test_module_geometry_without_detectors(d):
|
|
||||||
# t = d.module_geometry
|
|
||||||
# assert t.horizontal == 0
|
|
||||||
# assert t.vertical == 0
|
|
||||||
|
|
||||||
# def test_get_n_frames(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getNumberOfFrames')
|
|
||||||
# m.return_value = 3
|
|
||||||
# assert d.n_frames == 3
|
|
||||||
|
|
||||||
# def test_set_n_frames(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
|
|
||||||
# d.n_frames = 9
|
|
||||||
# m.assert_called_once_with(9)
|
|
||||||
|
|
||||||
# def test_nframes_without_detector(d):
|
|
||||||
# assert d.n_frames == -100
|
|
||||||
|
|
||||||
# def test_set_n_frames_raises_on_neg(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
|
|
||||||
# with pytest.raises(DetectorValueError):
|
|
||||||
# d.n_frames = -1
|
|
||||||
|
|
||||||
# def test_set_n_frames_raises_on_zero(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
|
|
||||||
# with pytest.raises(DetectorValueError):
|
|
||||||
# d.n_frames = 0
|
|
||||||
|
|
||||||
# def test_n_cycles_without_detector(d):
|
|
||||||
# assert d.n_cycles == -100
|
|
||||||
|
|
||||||
# def test_set_n_cycles_raises_on_zero(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.setCycles')
|
|
||||||
# with pytest.raises(DetectorValueError):
|
|
||||||
# d.n_cycles = 0
|
|
||||||
|
|
||||||
# def test_set_n_cycles(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setCycles')
|
|
||||||
# d.n_cycles = 56
|
|
||||||
# m.assert_called_once_with(56)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# def test_n_measurements_without_detector(d):
|
|
||||||
# assert d.n_measurements == -100
|
|
||||||
|
|
||||||
# def test_set_n_measurements_raises_on_zero(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
|
|
||||||
# with pytest.raises(DetectorValueError):
|
|
||||||
# d.n_measurements = 0
|
|
||||||
|
|
||||||
# def test_set_n_measurements(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
|
|
||||||
# d.n_measurements = 560
|
|
||||||
# m.assert_called_once_with(560)
|
|
||||||
|
|
||||||
# def test_get_n_modules_no_detector(d):
|
|
||||||
# assert d.n_modules == 0
|
|
||||||
|
|
||||||
# def test_get_n_modules(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
|
|
||||||
# m.return_value = 12
|
|
||||||
# assert d.n_modules == 12
|
|
||||||
|
|
||||||
# def test_get_period_time(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getPeriod')
|
|
||||||
# m.return_value = 130000000
|
|
||||||
# assert d.period == 0.13
|
|
||||||
|
|
||||||
# def test_set_period_time(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setPeriod')
|
|
||||||
# d.period = 1.953
|
|
||||||
# m.assert_called_once_with(1953000000)
|
|
||||||
|
|
||||||
# def test_set_period_time_less_than_zero(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.setPeriod')
|
|
||||||
# with pytest.raises(ValueError):
|
|
||||||
# d.period = -7
|
|
||||||
|
|
||||||
|
|
||||||
# def test_get_online(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getOnline')
|
|
||||||
# d.online
|
|
||||||
# m.assert_called_once_with()
|
|
||||||
|
|
||||||
# def test_set_online(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setOnline')
|
|
||||||
# d.online = True
|
|
||||||
# m.assert_called_once_with(True)
|
|
||||||
|
|
||||||
# def test_last_client_ip_no_detector(d):
|
|
||||||
# assert d.last_client_ip == ''
|
|
||||||
|
|
||||||
# def test_last_cliten_ip_call(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getLastClientIP')
|
|
||||||
# d.last_client_ip
|
|
||||||
# m.assert_called_once_with()
|
|
||||||
|
|
||||||
# #-------------------------------------------------------------Rate correction
|
|
||||||
# def test_get_rate_correction(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getRateCorrection')
|
|
||||||
# m.return_value = [132,129]
|
|
||||||
# assert d.rate_correction == [132,129]
|
|
||||||
|
|
||||||
# def test_set_rate_correction(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setRateCorrection')
|
|
||||||
# mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
|
|
||||||
# mock_n.return_value = 3
|
|
||||||
# d.rate_correction = [123,90,50]
|
|
||||||
# m.assert_called_once_with([123,90,50])
|
|
||||||
|
|
||||||
# def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
|
|
||||||
# mocker.patch('_slsdet.DetectorApi.setRateCorrection')
|
|
||||||
# mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
|
|
||||||
# mock_n.return_value = 4
|
|
||||||
# with pytest.raises(ValueError):
|
|
||||||
# d.rate_correction = [123,90,50]
|
|
||||||
|
|
||||||
# #----------------------------------------------------------------Readout clock
|
|
||||||
# def test_get_readout_clock_0(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
|
|
||||||
# m.return_value = 0
|
|
||||||
# assert d.readout_clock == 'Full Speed'
|
|
||||||
|
|
||||||
# def test_get_readout_clock_1(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
|
|
||||||
# m.return_value = 1
|
|
||||||
# assert d.readout_clock == 'Half Speed'
|
|
||||||
|
|
||||||
# def test_get_readout_clock_2(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
|
|
||||||
# m.return_value = 2
|
|
||||||
# assert d.readout_clock == 'Quarter Speed'
|
|
||||||
|
|
||||||
# def test_get_readout_clock_3(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
|
|
||||||
# m.return_value = 3
|
|
||||||
# assert d.readout_clock == 'Super Slow Speed'
|
|
||||||
|
|
||||||
# def test_set_readout_clock_0(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
|
|
||||||
# d.readout_clock = 'Full Speed'
|
|
||||||
# m.assert_called_once_with(0)
|
|
||||||
|
|
||||||
# def test_set_readout_clock_1(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
|
|
||||||
# d.readout_clock = 'Half Speed'
|
|
||||||
# m.assert_called_once_with(1)
|
|
||||||
|
|
||||||
# def test_set_readout_clock_2(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
|
|
||||||
# d.readout_clock = 'Quarter Speed'
|
|
||||||
# m.assert_called_once_with(2)
|
|
||||||
|
|
||||||
# def test_set_readout_clock_3(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
|
|
||||||
# d.readout_clock = 'Super Slow Speed'
|
|
||||||
# m.assert_called_once_with(3)
|
|
||||||
|
|
||||||
# #----------------------------------------------------------------rx_datastream
|
|
||||||
# def test_get_rx_datastream(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getRxDataStreamStatus')
|
|
||||||
# m.return_value = False
|
|
||||||
# assert d.rx_datastream == False
|
|
||||||
|
|
||||||
# def test_set_rx_datastream(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setRxDataStreamStatus')
|
|
||||||
# d.rx_datastream = True
|
|
||||||
# m.assert_called_once_with(True)
|
|
||||||
|
|
||||||
# def test_get_rx_zmqip(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
|
|
||||||
# d.rx_zmqip
|
|
||||||
# m.assert_called_once_with('rx_zmqip')
|
|
||||||
|
|
||||||
# def test_get_rx_zmqport_call(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
|
|
||||||
# d.rx_zmqport
|
|
||||||
# m.assert_called_once_with('rx_zmqport')
|
|
||||||
|
|
||||||
# def test_get_rx_zmqport_decode(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
|
|
||||||
# m.return_value = ['30001', '30003']
|
|
||||||
# assert d.rx_zmqport == [30001, 30003]
|
|
||||||
|
|
||||||
# def test_get_rx_zmqport_empty(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
|
|
||||||
# m.return_value = ''
|
|
||||||
# assert d.rx_zmqport == []
|
|
||||||
|
|
||||||
|
|
||||||
# #--------------------------------------------------------------------status
|
|
||||||
# def test_status_call(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getRunStatus')
|
|
||||||
# d.status
|
|
||||||
# m.assert_called_once_with()
|
|
||||||
|
|
||||||
# def test_start_detecor(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
|
|
||||||
# d.start_detector()
|
|
||||||
# m.assert_called_once_with()
|
|
||||||
|
|
||||||
# def test_stop_acq_call(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.stopAcquisition')
|
|
||||||
# d.stop_detector()
|
|
||||||
# m.assert_called_once_with()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# #------------------------------------------------------------------timing mode
|
|
||||||
# def test_get_timing_mode(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getTimingMode')
|
|
||||||
# d.timing_mode
|
|
||||||
# m.assert_called_once_with()
|
|
||||||
|
|
||||||
# def test_set_timing_mode(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setTimingMode')
|
|
||||||
# d.timing_mode = 'auto'
|
|
||||||
# m.assert_called_once_with('auto')
|
|
||||||
|
|
||||||
# #----------------------------------------------------------------vthreshold
|
|
||||||
# def test_get_vthreshold(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.getDac')
|
|
||||||
# d.vthreshold
|
|
||||||
# m.assert_called_once_with('vthreshold', -1)
|
|
||||||
|
|
||||||
# def test_set_vthreshold(d, mocker):
|
|
||||||
# m = mocker.patch('_slsdet.DetectorApi.setDac')
|
|
||||||
# d.vthreshold = 1675
|
|
||||||
# m.assert_called_once_with('vthreshold', -1, 1675)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
|||||||
import pytest
|
|
||||||
from sls_detector.detector_property import DetectorProperty
|
|
||||||
|
|
||||||
class Holder:
|
|
||||||
"""
|
|
||||||
This class does nothing except hold values
|
|
||||||
for testing of the DetectorProperty class
|
|
||||||
"""
|
|
||||||
def __init__(self, N):
|
|
||||||
self.values = [i for i in range(N)]
|
|
||||||
def get(self, i):
|
|
||||||
return self.values[i]
|
|
||||||
def set(self, i,v):
|
|
||||||
self.values[i] = v
|
|
||||||
def nmod(self):
|
|
||||||
return len(self.values)
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def p():
|
|
||||||
h = Holder(5)
|
|
||||||
return DetectorProperty(h.get, h.set, h.nmod, 'prop')
|
|
||||||
|
|
||||||
def test_initialization():
|
|
||||||
def getf(i):
|
|
||||||
return 5
|
|
||||||
def setf():
|
|
||||||
return
|
|
||||||
def nmod():
|
|
||||||
return 3
|
|
||||||
name = 'a property'
|
|
||||||
p = DetectorProperty(getf, setf, nmod, name)
|
|
||||||
assert p.get == getf
|
|
||||||
assert p.set == setf
|
|
||||||
assert p.get_nmod == nmod
|
|
||||||
assert p.__name__ == name
|
|
||||||
|
|
||||||
def test_get_single_value(p):
|
|
||||||
assert p[2] == 2
|
|
||||||
|
|
||||||
def test_get_all_values(p):
|
|
||||||
assert p[:] == [0, 1, 2, 3, 4]
|
|
||||||
|
|
||||||
def test_get_values_by_iterable(p):
|
|
||||||
vals = p[1,3]
|
|
||||||
assert vals == [1,3]
|
|
||||||
|
|
||||||
def test_set_single_value(p):
|
|
||||||
p[2] = 7
|
|
||||||
assert p[:] == [0,1,7,3,4]
|
|
||||||
|
|
||||||
def test_set_all(p):
|
|
||||||
p[:] = 10
|
|
||||||
assert p[:] == [10,10,10,10,10]
|
|
||||||
|
|
||||||
def test_set_all_by_list(p):
|
|
||||||
p[:] = [7,8,9,10,11]
|
|
||||||
assert p[:] == [7,8,9,10,11]
|
|
||||||
|
|
||||||
def test_set_all_bool(p):
|
|
||||||
p[:] = True
|
|
||||||
assert p[:] == [True]*5
|
|
||||||
|
|
||||||
def test_set_by_iter(p):
|
|
||||||
keys = [2,4]
|
|
||||||
vals = [18,23]
|
|
||||||
p[keys] = vals
|
|
||||||
assert p[:] == [0,1,18,3,23]
|
|
||||||
|
|
||||||
def test_set_by_iter_single_val(p):
|
|
||||||
keys = [2,4]
|
|
||||||
val = 9
|
|
||||||
p[keys] = val
|
|
||||||
assert p[:] == [0,1,9,3,9]
|
|
||||||
|
|
||||||
def test_print_values(p):
|
|
||||||
assert repr(p) == 'prop: [0, 1, 2, 3, 4]'
|
|
@ -6,8 +6,11 @@ Testing functions from utils.py
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from slsdet.utils import *
|
from slsdet.utils import *
|
||||||
|
from slsdet import IpAddr, MacAddr
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
import pathlib
|
import pathlib
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def test_iterable():
|
def test_iterable():
|
||||||
assert is_iterable(5) == False
|
assert is_iterable(5) == False
|
||||||
@ -15,74 +18,80 @@ def test_iterable():
|
|||||||
assert is_iterable([]) == True
|
assert is_iterable([]) == True
|
||||||
assert is_iterable(5.9) == False
|
assert is_iterable(5.9) == False
|
||||||
|
|
||||||
|
|
||||||
def test_reduce_time_to_single_value_from_list():
|
def test_reduce_time_to_single_value_from_list():
|
||||||
t = 3*[dt.timedelta(seconds = 1)]
|
t = 3 * [dt.timedelta(seconds=1)]
|
||||||
assert reduce_time(t) == 1
|
assert reduce_time(t) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_reduce_time_to_single_value_from_list_of_lists():
|
def test_reduce_time_to_single_value_from_list_of_lists():
|
||||||
t = 3*[dt.timedelta(seconds = 3.3)]
|
t = 3 * [dt.timedelta(seconds=3.3)]
|
||||||
tt = 5*t
|
tt = 5 * t
|
||||||
assert reduce_time(tt) == 3.3
|
assert reduce_time(tt) == 3.3
|
||||||
|
|
||||||
|
|
||||||
def test_reduce_time_when_sublist_is_different():
|
def test_reduce_time_when_sublist_is_different():
|
||||||
t = [dt.timedelta(seconds = 1), dt.timedelta(seconds = 2), dt.timedelta(seconds = 1)]
|
t = [
|
||||||
|
dt.timedelta(seconds=1),
|
||||||
|
dt.timedelta(seconds=2),
|
||||||
|
dt.timedelta(seconds=1)
|
||||||
|
]
|
||||||
tt = [t for i in range(4)]
|
tt = [t for i in range(4)]
|
||||||
assert reduce_time(tt) == [1,2,1]
|
assert reduce_time(tt) == [1, 2, 1]
|
||||||
|
|
||||||
|
|
||||||
def test_convert_zero():
|
def test_convert_zero():
|
||||||
assert eiger_register_to_time(0) == 0
|
assert eiger_register_to_time(0) == 0
|
||||||
|
|
||||||
|
|
||||||
def test_convert_smallest_unit():
|
def test_convert_smallest_unit():
|
||||||
assert pytest.approx(eiger_register_to_time(0b1000), 1e-9) == 1e-8
|
assert pytest.approx(eiger_register_to_time(0b1000), 1e-9) == 1e-8
|
||||||
|
|
||||||
|
|
||||||
def test_convert_second_smallest_unit():
|
def test_convert_second_smallest_unit():
|
||||||
assert pytest.approx(eiger_register_to_time(0b10000), 1e-9) == 2e-8
|
assert pytest.approx(eiger_register_to_time(0b10000), 1e-9) == 2e-8
|
||||||
|
|
||||||
|
|
||||||
def test_convert_one_ms_using_exponent():
|
def test_convert_one_ms_using_exponent():
|
||||||
assert pytest.approx(eiger_register_to_time(0b1101), 1e-9) == 1e-3
|
assert pytest.approx(eiger_register_to_time(0b1101), 1e-9) == 1e-3
|
||||||
|
|
||||||
|
|
||||||
def test_convert_five_seconds():
|
def test_convert_five_seconds():
|
||||||
assert pytest.approx(eiger_register_to_time(0b1001110001000101), 1e-9) == 5.0
|
assert pytest.approx(eiger_register_to_time(0b1001110001000101),
|
||||||
|
1e-9) == 5.0
|
||||||
|
|
||||||
|
|
||||||
def test_all_equal_int():
|
def test_all_equal_int():
|
||||||
assert all_equal([5,5]) == True
|
assert all_equal([5, 5]) == True
|
||||||
|
|
||||||
|
|
||||||
def test_all_equal_fails():
|
def test_all_equal_fails():
|
||||||
assert all_equal([5,6]) == False
|
assert all_equal([5, 6]) == False
|
||||||
|
|
||||||
|
|
||||||
def test_all_equal_tuple():
|
def test_all_equal_tuple():
|
||||||
assert all_equal(('a', 'a', 'a')) == True
|
assert all_equal(('a', 'a', 'a')) == True
|
||||||
|
|
||||||
|
|
||||||
def test_all_equal_str():
|
def test_all_equal_str():
|
||||||
assert all_equal('aaa') == True
|
assert all_equal('aaa') == True
|
||||||
|
|
||||||
|
|
||||||
def test_all_equal_str_fails():
|
def test_all_equal_str_fails():
|
||||||
assert all_equal('aaab') == False
|
assert all_equal('aaab') == False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_element_if_equal_int():
|
def test_element_if_equal_int():
|
||||||
assert element_if_equal([5,5]) == 5
|
assert element_if_equal([5, 5]) == 5
|
||||||
|
|
||||||
|
|
||||||
def test_element_if_equal_str():
|
def test_element_if_equal_str():
|
||||||
assert element_if_equal('hhh') == 'h'
|
assert element_if_equal('hhh') == 'h'
|
||||||
|
|
||||||
|
|
||||||
def test_element_if_equal_int_fails():
|
def test_element_if_equal_int_fails():
|
||||||
assert element_if_equal([5, 6, 7]) == [5, 6, 7]
|
assert element_if_equal([5, 6, 7]) == [5, 6, 7]
|
||||||
|
|
||||||
def test_get_set_bits():
|
|
||||||
assert(get_set_bits(0) == [])
|
|
||||||
assert get_set_bits(7) == [0, 1, 2]
|
|
||||||
|
|
||||||
def test_list_to_mask():
|
|
||||||
assert(list_to_bitmask([0,1,2]) == 7)
|
|
||||||
assert(list_to_bitmask([]) == 0)
|
|
||||||
assert(list_to_bitmask([0]) == 1)
|
|
||||||
assert(list_to_bitmask([1]) == 2)
|
|
||||||
assert(list_to_bitmask([3]) == 8)
|
|
||||||
assert(list_to_bitmask([1,1,1]) == 2)
|
|
||||||
|
|
||||||
|
|
||||||
def test_make_timedelta_from_double():
|
def test_make_timedelta_from_double():
|
||||||
t = 1.7
|
t = 1.7
|
||||||
@ -90,6 +99,7 @@ def test_make_timedelta_from_double():
|
|||||||
assert t == r.total_seconds()
|
assert t == r.total_seconds()
|
||||||
assert r == dt.timedelta(seconds=t)
|
assert r == dt.timedelta(seconds=t)
|
||||||
|
|
||||||
|
|
||||||
def test_make_timedelta_from_timedelta():
|
def test_make_timedelta_from_timedelta():
|
||||||
t = dt.timedelta(minutes=1)
|
t = dt.timedelta(minutes=1)
|
||||||
r = make_timedelta(t)
|
r = make_timedelta(t)
|
||||||
@ -105,6 +115,7 @@ def test_make_string_path_from_Path():
|
|||||||
assert r == p.as_posix()
|
assert r == p.as_posix()
|
||||||
assert r == pathstr
|
assert r == pathstr
|
||||||
|
|
||||||
|
|
||||||
def test_make_string_path_expand_user():
|
def test_make_string_path_expand_user():
|
||||||
pathstr = "~/tmp/virtual.config"
|
pathstr = "~/tmp/virtual.config"
|
||||||
home = pathlib.Path.home()
|
home = pathlib.Path.home()
|
||||||
@ -113,4 +124,200 @@ def test_make_string_path_expand_user():
|
|||||||
rp = make_string_path(p)
|
rp = make_string_path(p)
|
||||||
rs = make_string_path(pathstr)
|
rs = make_string_path(pathstr)
|
||||||
assert rp == expanded_str
|
assert rp == expanded_str
|
||||||
assert rs == expanded_str
|
assert rs == expanded_str
|
||||||
|
|
||||||
|
|
||||||
|
def test_lhex_passing_list():
|
||||||
|
values = [0, 1, 2, 3, 4]
|
||||||
|
assert lhex(values) == ["0x0", "0x1", "0x2", "0x3", "0x4"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_lhex_emty_list():
|
||||||
|
assert lhex([]) == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_ip_from_dict():
|
||||||
|
arg = {0: 0, 1: "192.168.1.1"}
|
||||||
|
res = make_ip(arg)
|
||||||
|
assert res == {0: IpAddr("0.0.0.0"), 1: IpAddr("192.168.1.1")}
|
||||||
|
assert res[0].str() == "0.0.0.0"
|
||||||
|
assert res[1].str() == "192.168.1.1"
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_ip_from_str():
|
||||||
|
ip = "192.168.1.1"
|
||||||
|
assert make_ip(ip).str() == ip
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_ip_from_list():
|
||||||
|
arg = ["192.168.1.1", "192.168.1.2", "127.0.0.1"]
|
||||||
|
assert make_ip(arg) == [IpAddr(a) for a in arg]
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_ip_from_tuple():
|
||||||
|
arg = ("127.0.0.1")
|
||||||
|
assert make_ip(arg) == (IpAddr(arg))
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_mac_from_dict():
|
||||||
|
arg = {6: "84:a9:aa:24:32:88", 12: "84:a9:3e:24:32:aa"}
|
||||||
|
res = make_mac(arg)
|
||||||
|
assert res == {
|
||||||
|
6: MacAddr("84:a9:aa:24:32:88"),
|
||||||
|
12: MacAddr("84:a9:3e:24:32:aa")
|
||||||
|
}
|
||||||
|
assert res[6].str() == "84:a9:aa:24:32:88"
|
||||||
|
assert res[12].str() == "84:a9:3e:24:32:aa"
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_mac_from_str():
|
||||||
|
mac = "84:a9:aa:24:32:88"
|
||||||
|
assert make_mac(mac) == MacAddr(mac)
|
||||||
|
assert make_mac(mac).str() == mac
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_mac_from_list():
|
||||||
|
arg = ["84:a9:aa:24:32:88", "84:a9:3e:24:32:aa"]
|
||||||
|
assert make_mac(arg) == [MacAddr(a) for a in arg]
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_mac_from_tuple():
|
||||||
|
arg = ("84:a9:aa:24:32:88", "84:a9:3e:24:32:aa")
|
||||||
|
assert make_mac(arg) == (MacAddr("84:a9:aa:24:32:88"),
|
||||||
|
MacAddr("84:a9:3e:24:32:aa"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_path_from_str():
|
||||||
|
assert make_path("/") == Path("/")
|
||||||
|
assert make_path("/home") == Path("/home")
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_path_from_list():
|
||||||
|
arg = ["/", "/home", "/another/path"]
|
||||||
|
assert make_path(arg) == [Path(p) for p in arg]
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_string_path_from_str():
|
||||||
|
arg = "/path/to/something"
|
||||||
|
assert make_string_path(arg) == arg
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_string_path_from_Path():
|
||||||
|
s = "/path/to/something"
|
||||||
|
arg = Path(s)
|
||||||
|
assert make_string_path(arg) == s
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_string_path_from_list_of_Path_and_string():
|
||||||
|
args = ["/path/to", Path("/something/something"), "else/"]
|
||||||
|
assert make_string_path(args) == [
|
||||||
|
"/path/to", "/something/something", "else/"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_string_path_from_Path_list():
|
||||||
|
s = "/path/to/something"
|
||||||
|
arg = [Path(s)]
|
||||||
|
assert make_string_path(arg) == [s]
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_string_path_from_dict():
|
||||||
|
args = {0: "/path/to/something", 1: Path("/something/else")}
|
||||||
|
assert make_string_path(args) == {
|
||||||
|
0: "/path/to/something",
|
||||||
|
1: "/something/else"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DummyClass:
|
||||||
|
def __init__(self):
|
||||||
|
self.args = []
|
||||||
|
|
||||||
|
def call(self, *args):
|
||||||
|
"""Normal type call in slsdet where list of detectors is passed"""
|
||||||
|
self.args.append(args)
|
||||||
|
|
||||||
|
def call_int_id(self, *args):
|
||||||
|
"""call where det_is is an int"""
|
||||||
|
*args, i = args
|
||||||
|
if isinstance(i, list):
|
||||||
|
raise TypeError
|
||||||
|
self.args.append((*args, i))
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_using_dict_single_int():
|
||||||
|
c = DummyClass()
|
||||||
|
set_using_dict(c.call, 5)
|
||||||
|
assert c.args == [(5, )]
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_using_dict_two_ints():
|
||||||
|
c = DummyClass()
|
||||||
|
set_using_dict(c.call, 1, 2)
|
||||||
|
assert c.args == [(1, 2)]
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_using_dict_passing_dict():
|
||||||
|
c = DummyClass()
|
||||||
|
set_using_dict(c.call, {0: 5, 8: 3, 9: 7})
|
||||||
|
assert len(c.args) == 3
|
||||||
|
assert c.args == [(5, [0]), (3, [8]), (7, [9])]
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_using_dict_calling_int_id():
|
||||||
|
c = DummyClass()
|
||||||
|
set_using_dict(c.call_int_id, {0: "hej", 8: 3, 9: 7})
|
||||||
|
assert len(c.args) == 3
|
||||||
|
assert c.args == [("hej", 0), (3, 8), (7, 9)]
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_using_dict_pass_multiple_args():
|
||||||
|
c = DummyClass()
|
||||||
|
set_using_dict(c.call, "a", "b", "c")
|
||||||
|
assert len(c.args) == 1
|
||||||
|
assert c.args == [("a", "b", "c")]
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_using_dict_passing_dict_with_multiple_args():
|
||||||
|
c = DummyClass()
|
||||||
|
set_using_dict(c.call, {0: ("a", "b"), 1: ("c", "d")})
|
||||||
|
assert c.args == [("a", "b", [0]), ("c", "d", [1])]
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_set_bits():
|
||||||
|
assert (get_set_bits(0) == [])
|
||||||
|
assert get_set_bits(7) == [0, 1, 2]
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_to_mask():
|
||||||
|
assert (list_to_bitmask([0, 1, 2]) == 7)
|
||||||
|
assert (list_to_bitmask([]) == 0)
|
||||||
|
assert (list_to_bitmask([0]) == 1)
|
||||||
|
assert (list_to_bitmask([1]) == 2)
|
||||||
|
assert (list_to_bitmask([3]) == 8)
|
||||||
|
assert (list_to_bitmask([1, 1, 1]) == 2)
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_bitmask_from_list_of_int():
|
||||||
|
assert make_bitmask([0, 1, 2]) == 0b111
|
||||||
|
assert make_bitmask([0, 1, 7]) == 0b10000011
|
||||||
|
assert make_bitmask([1, 1, 1]) == 0b10
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_bitmask_from_dict():
|
||||||
|
assert make_bitmask({0: [0, 1], 1: [0, 1, 7]}) == {0: 0b11, 1: 0b10000011}
|
||||||
|
|
||||||
|
|
||||||
|
def test_add_argument_before():
|
||||||
|
assert add_argument_before("a", 5) == ("a", 5)
|
||||||
|
assert add_argument_before(3, ("a", "b")) == (3, "a", "b")
|
||||||
|
|
||||||
|
|
||||||
|
def test_add_argument_before_dict():
|
||||||
|
assert add_argument_before(5, {0: "a"}) == ({0: (5, "a")},)
|
||||||
|
assert add_argument_before(0, {0: 1}) == ({0: (0, 1)},)
|
||||||
|
assert add_argument_before(5, {0: ("a", "b")}) == ({0: (5, "a", "b")}, )
|
||||||
|
assert add_argument_before(6, "hej") == (6, "hej")
|
||||||
|
assert add_argument_before("another", {9: "string"}) == ({
|
||||||
|
9: ("another", "string")
|
||||||
|
}, )
|
||||||
|
@ -161,6 +161,21 @@ void qTabMeasurement::ShowTriggerDelay() {
|
|||||||
// show burst, burstperiod, not trigger or delay
|
// show burst, burstperiod, not trigger or delay
|
||||||
showTrigger = false;
|
showTrigger = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// frame and period are disabled for cont trigger in g2
|
||||||
|
bool enableFramePeriod = true;
|
||||||
|
if ((comboBurstMode->currentIndex() ==
|
||||||
|
slsDetectorDefs::CONTINUOUS_INTERNAL ||
|
||||||
|
comboBurstMode->currentIndex() ==
|
||||||
|
slsDetectorDefs::CONTINUOUS_EXTERNAL) &&
|
||||||
|
(comboTimingMode->currentIndex() == TRIGGER)) {
|
||||||
|
enableFramePeriod = false;
|
||||||
|
}
|
||||||
|
lblNumFrames->setEnabled(enableFramePeriod);
|
||||||
|
spinNumFrames->setEnabled(enableFramePeriod);
|
||||||
|
lblPeriod->setEnabled(enableFramePeriod);
|
||||||
|
spinPeriod->setEnabled(enableFramePeriod);
|
||||||
|
comboPeriodUnit->setEnabled(enableFramePeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTrigger) {
|
if (showTrigger) {
|
||||||
|
Binary file not shown.
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
|
extern int updateFlag;
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
@ -105,8 +106,9 @@ void basictests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// does check only if flag is 0 (by default), set by command line
|
// does check only if flag is 0 (by default), set by command line
|
||||||
if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) ||
|
if ((!debugflag) && (!updateFlag) &&
|
||||||
(testBus() == FAIL))) {
|
((checkType() == FAIL) || (testFpga() == FAIL) ||
|
||||||
|
(testBus() == FAIL))) {
|
||||||
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
||||||
"Dangerous to continue.\n");
|
"Dangerous to continue.\n");
|
||||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
@ -145,7 +147,7 @@ void basictests() {
|
|||||||
(long long int)client_sw_apiversion));
|
(long long int)client_sw_apiversion));
|
||||||
|
|
||||||
// return if flag is not zero, debug mode
|
// return if flag is not zero, debug mode
|
||||||
if (debugflag) {
|
if (debugflag || updateFlag) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +419,7 @@ uint32_t getDetectorIP() {
|
|||||||
/* initialization */
|
/* initialization */
|
||||||
|
|
||||||
void initControlServer() {
|
void initControlServer() {
|
||||||
if (initError == OK) {
|
if (!updateFlag && initError == OK) {
|
||||||
setupDetector();
|
setupDetector();
|
||||||
}
|
}
|
||||||
initCheckDone = 1;
|
initCheckDone = 1;
|
||||||
|
@ -95,7 +95,7 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
|
|||||||
#define NDAC_ONLY (NDAC - NPWR)
|
#define NDAC_ONLY (NDAC - NPWR)
|
||||||
#define DYNAMIC_RANGE (16)
|
#define DYNAMIC_RANGE (16)
|
||||||
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
|
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
|
||||||
#define CLK_FREQ (156.25) /* MHz */
|
#define CLK_FREQ (156.25) // MHz
|
||||||
#define I2C_POWER_VIO_DEVICE_ID (0x40)
|
#define I2C_POWER_VIO_DEVICE_ID (0x40)
|
||||||
#define I2C_POWER_VA_DEVICE_ID (0x41)
|
#define I2C_POWER_VA_DEVICE_ID (0x41)
|
||||||
#define I2C_POWER_VB_DEVICE_ID (0x42)
|
#define I2C_POWER_VB_DEVICE_ID (0x42)
|
||||||
|
@ -151,7 +151,7 @@ void Beb_Beb(int id) {
|
|||||||
Beb_bit_mode = 4;
|
Beb_bit_mode = 4;
|
||||||
|
|
||||||
// ll_beb = &ll_beb_local;
|
// ll_beb = &ll_beb_local;
|
||||||
// Local_LocalLinkInterface1(ll_beb,XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR);
|
// Local_LocalLinkInterface(ll_beb,XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR);
|
||||||
|
|
||||||
// Beb_SetByteOrder();
|
// Beb_SetByteOrder();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "Beb.h"
|
#include "Beb.h"
|
||||||
#include "FebRegisterDefs.h"
|
#include "FebRegisterDefs.h"
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
|
#include "sharedMemory.h"
|
||||||
#include "slsDetectorServer_defs.h"
|
#include "slsDetectorServer_defs.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -752,16 +753,24 @@ int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Feb_Control_WaitForFinishedFlag(int sleep_time_us) {
|
int Feb_Control_WaitForFinishedFlag(int sleep_time_us, int tempLock) {
|
||||||
int is_running = Feb_Control_AcquisitionInProgress();
|
int is_running = Feb_Control_AcquisitionInProgress();
|
||||||
|
// unlock for stop server
|
||||||
|
if (tempLock) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
}
|
||||||
int check_error = 0;
|
int check_error = 0;
|
||||||
|
|
||||||
// it will break out if it is idle or if check_error is more than 5 times
|
// it will break out if it is idle or if check_error is more than 5 times
|
||||||
while (is_running != STATUS_IDLE) {
|
while (is_running != STATUS_IDLE) {
|
||||||
usleep(sleep_time_us);
|
usleep(sleep_time_us);
|
||||||
|
if (tempLock) {
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
|
}
|
||||||
is_running = Feb_Control_AcquisitionInProgress();
|
is_running = Feb_Control_AcquisitionInProgress();
|
||||||
|
if (tempLock) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
}
|
||||||
// check error only 5 times (ensuring it is not something that happens
|
// check error only 5 times (ensuring it is not something that happens
|
||||||
// sometimes)
|
// sometimes)
|
||||||
if (is_running == STATUS_ERROR) {
|
if (is_running == STATUS_ERROR) {
|
||||||
@ -772,6 +781,10 @@ int Feb_Control_WaitForFinishedFlag(int sleep_time_us) {
|
|||||||
else
|
else
|
||||||
check_error = 0;
|
check_error = 0;
|
||||||
}
|
}
|
||||||
|
// lock it again to be unlocked later
|
||||||
|
if (tempLock) {
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
|
}
|
||||||
return is_running;
|
return is_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,7 +813,7 @@ int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Feb_Control_WaitForFinishedFlag(sleep_time_us);
|
return Feb_Control_WaitForFinishedFlag(sleep_time_us, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Feb_Control_Reset() {
|
int Feb_Control_Reset() {
|
||||||
@ -816,7 +829,7 @@ int Feb_Control_Reset() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Feb_Control_WaitForFinishedFlag(5000);
|
return Feb_Control_WaitForFinishedFlag(5000, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Feb_Control_ResetChipCompletely() {
|
int Feb_Control_ResetChipCompletely() {
|
||||||
|
@ -42,7 +42,7 @@ unsigned int *Feb_Control_GetTrimbits();
|
|||||||
int Feb_Control_AcquisitionInProgress();
|
int Feb_Control_AcquisitionInProgress();
|
||||||
int Feb_Control_AcquisitionStartedBit();
|
int Feb_Control_AcquisitionStartedBit();
|
||||||
int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag);
|
int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag);
|
||||||
int Feb_Control_WaitForFinishedFlag(int sleep_time_us);
|
int Feb_Control_WaitForFinishedFlag(int sleep_time_us, int tempLock);
|
||||||
int Feb_Control_GetDAQStatusRegister(unsigned int dst_address,
|
int Feb_Control_GetDAQStatusRegister(unsigned int dst_address,
|
||||||
unsigned int *ret_status);
|
unsigned int *ret_status);
|
||||||
int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us);
|
int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us);
|
||||||
|
@ -37,7 +37,7 @@ void Feb_Interface_FebInterface() {
|
|||||||
malloc((Feb_Interface_recv_buffer_size + 1) * sizeof(unsigned int));
|
malloc((Feb_Interface_recv_buffer_size + 1) * sizeof(unsigned int));
|
||||||
Feb_Interface_recv_data = &Feb_Interface_recv_data_raw[1];
|
Feb_Interface_recv_data = &Feb_Interface_recv_data_raw[1];
|
||||||
|
|
||||||
Local_LocalLinkInterface1(
|
Local_LocalLinkInterface(
|
||||||
ll, XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
|
ll, XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void Local_LocalLinkInterface1(struct LocalLinkInterface *ll,
|
void Local_LocalLinkInterface(struct LocalLinkInterface *ll,
|
||||||
unsigned int ll_fifo_badr) {
|
unsigned int ll_fifo_badr) {
|
||||||
LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n"));
|
LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n"));
|
||||||
ll->ll_fifo_base = 0;
|
ll->ll_fifo_base = 0;
|
||||||
ll->ll_fifo_ctrl_reg = 0;
|
ll->ll_fifo_ctrl_reg = 0;
|
||||||
@ -20,16 +20,12 @@ void Local_LocalLinkInterface1(struct LocalLinkInterface *ll,
|
|||||||
("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr));
|
("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Local_LocalLinkInterface(struct LocalLinkInterface *ll) {
|
|
||||||
LOG(logDEBUG1, ("Initializing new memory\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
int Local_Init(struct LocalLinkInterface *ll, unsigned int ll_fifo_badr) {
|
int Local_Init(struct LocalLinkInterface *ll, unsigned int ll_fifo_badr) {
|
||||||
int fd;
|
int fd;
|
||||||
void *plb_ll_fifo_ptr;
|
void *plb_ll_fifo_ptr;
|
||||||
|
|
||||||
if ((fd = open("/dev/mem", O_RDWR)) < 0) {
|
if ((fd = open("/dev/mem", O_RDWR)) < 0) {
|
||||||
fprintf(stderr, "Could not open /dev/mem\n");
|
LOG(logERROR, ("Could not open /dev/mem for local link\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +34,7 @@ int Local_Init(struct LocalLinkInterface *ll, unsigned int ll_fifo_badr) {
|
|||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
if (plb_ll_fifo_ptr == MAP_FAILED) {
|
if (plb_ll_fifo_ptr == MAP_FAILED) {
|
||||||
perror("mmap");
|
LOG(logERROR, ("mmap error for local link\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +74,7 @@ unsigned int Local_StatusVector(struct LocalLinkInterface *ll) {
|
|||||||
|
|
||||||
int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
||||||
void *buffer) {
|
void *buffer) {
|
||||||
|
|
||||||
// note: buffer must be word (4 byte) aligned
|
// note: buffer must be word (4 byte) aligned
|
||||||
// frame_len in byte
|
// frame_len in byte
|
||||||
int vacancy = 0;
|
int vacancy = 0;
|
||||||
@ -87,8 +84,9 @@ int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
|||||||
unsigned int fifo_ctrl;
|
unsigned int fifo_ctrl;
|
||||||
xfs_u32 status;
|
xfs_u32 status;
|
||||||
|
|
||||||
if (buffer_len < 1)
|
if (buffer_len < 1) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
last_word = (buffer_len - 1) / 4;
|
last_word = (buffer_len - 1) / 4;
|
||||||
word_ptr = (unsigned int *)buffer;
|
word_ptr = (unsigned int *)buffer;
|
||||||
@ -131,11 +129,13 @@ int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
|||||||
word_ptr[words_send++]);
|
word_ptr[words_send++]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer_len;
|
return buffer_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Local_Read(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
int Local_Read(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
||||||
void *buffer) {
|
void *buffer) {
|
||||||
|
|
||||||
static unsigned int buffer_ptr = 0;
|
static unsigned int buffer_ptr = 0;
|
||||||
// note: buffer must be word (4 byte) aligned
|
// note: buffer must be word (4 byte) aligned
|
||||||
// frame_len in byte
|
// frame_len in byte
|
||||||
@ -184,7 +184,6 @@ int Local_Read(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!(status & PLB_LL_FIFO_STATUS_EMPTY));
|
} while (!(status & PLB_LL_FIFO_STATUS_EMPTY));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ int Local_Init(struct LocalLinkInterface *ll, unsigned int ll_fifo_badr);
|
|||||||
int Local_Reset1(struct LocalLinkInterface *ll, unsigned int rst_mask);
|
int Local_Reset1(struct LocalLinkInterface *ll, unsigned int rst_mask);
|
||||||
int Local_ctrl_reg_write_mask(struct LocalLinkInterface *ll, unsigned int mask,
|
int Local_ctrl_reg_write_mask(struct LocalLinkInterface *ll, unsigned int mask,
|
||||||
unsigned int val);
|
unsigned int val);
|
||||||
void Local_LocalLinkInterface1(struct LocalLinkInterface *ll,
|
void Local_LocalLinkInterface(struct LocalLinkInterface *ll,
|
||||||
unsigned int ll_fifo_badr);
|
unsigned int ll_fifo_badr);
|
||||||
unsigned int Local_StatusVector(struct LocalLinkInterface *ll);
|
unsigned int Local_StatusVector(struct LocalLinkInterface *ll);
|
||||||
int Local_Reset(struct LocalLinkInterface *ll);
|
int Local_Reset(struct LocalLinkInterface *ll);
|
||||||
int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
||||||
@ -21,4 +21,3 @@ int Local_Read(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
|||||||
void *buffer);
|
void *buffer);
|
||||||
int Local_Test(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
int Local_Test(struct LocalLinkInterface *ll, unsigned int buffer_len,
|
||||||
void *buffer);
|
void *buffer);
|
||||||
void Local_LocalLinkInterface(struct LocalLinkInterface *ll);
|
|
||||||
|
Binary file not shown.
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
|
extern int updateFlag;
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
@ -140,7 +141,7 @@ void basictests() {
|
|||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
// return if debugflag is not zero, debug mode
|
// return if debugflag is not zero, debug mode
|
||||||
if (debugflag) {
|
if (debugflag || updateFlag) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,10 +320,11 @@ u_int32_t getDetectorIP() {
|
|||||||
|
|
||||||
void initControlServer() {
|
void initControlServer() {
|
||||||
LOG(logINFOBLUE, ("Configuring Control server\n"));
|
LOG(logINFOBLUE, ("Configuring Control server\n"));
|
||||||
if (initError == OK) {
|
if (!updateFlag && initError == OK) {
|
||||||
readDetectorNumber();
|
readDetectorNumber();
|
||||||
getModuleConfiguration();
|
getModuleConfiguration();
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_SetMasterVariable(master);
|
Feb_Control_SetMasterVariable(master);
|
||||||
Feb_Interface_FebInterface();
|
Feb_Interface_FebInterface();
|
||||||
Feb_Control_FebControl();
|
Feb_Control_FebControl();
|
||||||
@ -332,6 +334,7 @@ void initControlServer() {
|
|||||||
sprintf(initErrorMessage, "Could not intitalize feb control\n");
|
sprintf(initErrorMessage, "Could not intitalize feb control\n");
|
||||||
LOG(logERROR, (initErrorMessage));
|
LOG(logERROR, (initErrorMessage));
|
||||||
initCheckDone = 1;
|
initCheckDone = 1;
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// master of 9M, check high voltage serial communication to blackfin
|
// master of 9M, check high voltage serial communication to blackfin
|
||||||
@ -343,9 +346,11 @@ void initControlServer() {
|
|||||||
"Could not intitalize feb control serial communication\n");
|
"Could not intitalize feb control serial communication\n");
|
||||||
LOG(logERROR, (initErrorMessage));
|
LOG(logERROR, (initErrorMessage));
|
||||||
initCheckDone = 1;
|
initCheckDone = 1;
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
|
LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
|
||||||
Beb_SetTopVariable(top);
|
Beb_SetTopVariable(top);
|
||||||
Beb_Beb(detid);
|
Beb_Beb(detid);
|
||||||
@ -372,11 +377,13 @@ void initStopServer() {
|
|||||||
// exit(-1);
|
// exit(-1);
|
||||||
readDetectorNumber();
|
readDetectorNumber();
|
||||||
getModuleConfiguration();
|
getModuleConfiguration();
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_SetMasterVariable(master);
|
Feb_Control_SetMasterVariable(master);
|
||||||
Feb_Interface_FebInterface();
|
Feb_Interface_FebInterface();
|
||||||
Feb_Control_FebControl();
|
Feb_Control_FebControl();
|
||||||
// same addresses for top and bottom
|
// same addresses for top and bottom
|
||||||
Feb_Control_Init(master, normal, getDetectorNumber());
|
Feb_Control_Init(master, normal, getDetectorNumber());
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||||
#endif
|
#endif
|
||||||
// client first connect (from shm) will activate
|
// client first connect (from shm) will activate
|
||||||
@ -492,14 +499,17 @@ int readConfigFile() {
|
|||||||
top, line);
|
top, line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_SetTop(ind, 1, 1)) {
|
if (!Feb_Control_SetTop(ind, 1, 1)) {
|
||||||
sprintf(
|
sprintf(
|
||||||
initErrorMessage,
|
initErrorMessage,
|
||||||
"Could not overwrite top to %d in Feb from on-board server "
|
"Could not overwrite top to %d in Feb from on-board server "
|
||||||
"config file. Line:[%s].\n",
|
"config file. Line:[%s].\n",
|
||||||
top, line);
|
top, line);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
// validate change
|
// validate change
|
||||||
int actual_top = -1, temp = -1, temp2 = -1;
|
int actual_top = -1, temp = -1, temp2 = -1;
|
||||||
Beb_GetModuleConfiguration(&temp, &actual_top, &temp2);
|
Beb_GetModuleConfiguration(&temp, &actual_top, &temp2);
|
||||||
@ -532,14 +542,17 @@ int readConfigFile() {
|
|||||||
master, line);
|
master, line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_SetMaster(ind)) {
|
if (!Feb_Control_SetMaster(ind)) {
|
||||||
sprintf(initErrorMessage,
|
sprintf(initErrorMessage,
|
||||||
"Could not overwrite master to %d in Feb from on-board "
|
"Could not overwrite master to %d in Feb from on-board "
|
||||||
"server "
|
"server "
|
||||||
"config file. Line:[%s].\n",
|
"config file. Line:[%s].\n",
|
||||||
master, line);
|
master, line);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
// validate change
|
// validate change
|
||||||
int actual_master = -1, temp = -1, temp2 = -1;
|
int actual_master = -1, temp = -1, temp2 = -1;
|
||||||
Beb_GetModuleConfiguration(&actual_master, &temp, &temp2);
|
Beb_GetModuleConfiguration(&actual_master, &temp, &temp2);
|
||||||
@ -549,7 +562,9 @@ int readConfigFile() {
|
|||||||
actual_master);
|
actual_master);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_SetMasterVariable(master);
|
Feb_Control_SetMasterVariable(master);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,13 +606,16 @@ void resetToHardwareSettings() {
|
|||||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_SetTop(TOP_HARDWARE, 1, 1)) {
|
if (!Feb_Control_SetTop(TOP_HARDWARE, 1, 1)) {
|
||||||
initError = FAIL;
|
initError = FAIL;
|
||||||
strcpy(initErrorMessage,
|
strcpy(initErrorMessage,
|
||||||
"Could not reset Top flag to Feb hardware settings.\n");
|
"Could not reset Top flag to Feb hardware settings.\n");
|
||||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
int temp = -1, temp2 = -1;
|
int temp = -1, temp2 = -1;
|
||||||
Beb_GetModuleConfiguration(&temp, &top, &temp2);
|
Beb_GetModuleConfiguration(&temp, &top, &temp2);
|
||||||
Beb_SetTopVariable(top);
|
Beb_SetTopVariable(top);
|
||||||
@ -611,16 +629,21 @@ void resetToHardwareSettings() {
|
|||||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_SetMaster(TOP_HARDWARE)) {
|
if (!Feb_Control_SetMaster(TOP_HARDWARE)) {
|
||||||
initError = FAIL;
|
initError = FAIL;
|
||||||
strcpy(initErrorMessage,
|
strcpy(initErrorMessage,
|
||||||
"Could not reset Master flag to Feb hardware settings.\n");
|
"Could not reset Master flag to Feb hardware settings.\n");
|
||||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
int temp = -1, temp2 = -1;
|
int temp = -1, temp2 = -1;
|
||||||
Beb_GetModuleConfiguration(&master, &temp, &temp2);
|
Beb_GetModuleConfiguration(&master, &temp, &temp2);
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_SetMasterVariable(master);
|
Feb_Control_SetMasterVariable(master);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -698,16 +721,21 @@ void setupDetector() {
|
|||||||
int enable[2] = {DEFAULT_EXT_GATING_ENABLE, DEFAULT_EXT_GATING_POLARITY};
|
int enable[2] = {DEFAULT_EXT_GATING_ENABLE, DEFAULT_EXT_GATING_POLARITY};
|
||||||
setExternalGating(enable); // disable external gating
|
setExternalGating(enable); // disable external gating
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_SetInTestModeVariable(DEFAULT_TEST_MODE);
|
Feb_Control_SetInTestModeVariable(DEFAULT_TEST_MODE);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
|
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_CheckSetup()) {
|
if (!Feb_Control_CheckSetup()) {
|
||||||
initError = FAIL;
|
initError = FAIL;
|
||||||
sprintf(initErrorMessage, "Could not pass feb control setup checks\n");
|
sprintf(initErrorMessage, "Could not pass feb control setup checks\n");
|
||||||
LOG(logERROR, (initErrorMessage));
|
LOG(logERROR, (initErrorMessage));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
// force top or master if in config file
|
// force top or master if in config file
|
||||||
if (readConfigFile() == FAIL) {
|
if (readConfigFile() == FAIL) {
|
||||||
@ -731,9 +759,12 @@ int writeRegister(uint32_t offset, uint32_t data) {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return OK;
|
return OK;
|
||||||
#else
|
#else
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_WriteRegister(offset, data)) {
|
if (!Feb_Control_WriteRegister(offset, data)) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -742,9 +773,12 @@ int readRegister(uint32_t offset, uint32_t *retval) {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return OK;
|
return OK;
|
||||||
#else
|
#else
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_ReadRegister(offset, retval)) {
|
if (!Feb_Control_ReadRegister(offset, retval)) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -756,21 +790,26 @@ int setDynamicRange(int dr) {
|
|||||||
if (dr > 0) {
|
if (dr > 0) {
|
||||||
LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
|
LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (Feb_Control_SetDynamicRange(dr)) {
|
if (Feb_Control_SetDynamicRange(dr)) {
|
||||||
on_dst = 0;
|
on_dst = 0;
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0; i < 32; ++i)
|
||||||
dst_requested[i] = 0; // clear dst requested
|
dst_requested[i] = 0; // clear dst requested
|
||||||
if (!Beb_SetUpTransferParameters(dr)) {
|
if (!Beb_SetUpTransferParameters(dr)) {
|
||||||
LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return eiger_dynamicrange;
|
return eiger_dynamicrange;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
eiger_dynamicrange = dr;
|
eiger_dynamicrange = dr;
|
||||||
}
|
}
|
||||||
// getting dr
|
// getting dr
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
eiger_dynamicrange = Feb_Control_GetDynamicRange();
|
eiger_dynamicrange = Feb_Control_GetDynamicRange();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
return eiger_dynamicrange;
|
return eiger_dynamicrange;
|
||||||
}
|
}
|
||||||
@ -780,9 +819,12 @@ int setDynamicRange(int dr) {
|
|||||||
int setParallelMode(int mode) {
|
int setParallelMode(int mode) {
|
||||||
mode = (mode == 0 ? E_NON_PARALLEL : E_PARALLEL);
|
mode = (mode == 0 ? E_NON_PARALLEL : E_PARALLEL);
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_SetReadoutMode(mode)) {
|
if (!Feb_Control_SetReadoutMode(mode)) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
eiger_parallelmode = mode;
|
eiger_parallelmode = mode;
|
||||||
return OK;
|
return OK;
|
||||||
@ -827,6 +869,7 @@ void setNumFrames(int64_t val) {
|
|||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
|
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (Feb_Control_SetNExposures((unsigned int)val * eiger_ntriggers)) {
|
if (Feb_Control_SetNExposures((unsigned int)val * eiger_ntriggers)) {
|
||||||
eiger_nexposures = val;
|
eiger_nexposures = val;
|
||||||
on_dst = 0;
|
on_dst = 0;
|
||||||
@ -835,6 +878,7 @@ void setNumFrames(int64_t val) {
|
|||||||
ndsts_in_use = 1;
|
ndsts_in_use = 1;
|
||||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
eiger_nexposures = val;
|
eiger_nexposures = val;
|
||||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||||
@ -848,6 +892,7 @@ void setNumTriggers(int64_t val) {
|
|||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
|
LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (Feb_Control_SetNExposures((unsigned int)val * eiger_nexposures)) {
|
if (Feb_Control_SetNExposures((unsigned int)val * eiger_nexposures)) {
|
||||||
eiger_ntriggers = val;
|
eiger_ntriggers = val;
|
||||||
on_dst = 0;
|
on_dst = 0;
|
||||||
@ -855,6 +900,7 @@ void setNumTriggers(int64_t val) {
|
|||||||
dst_requested[i] = 0; // clear dst requested
|
dst_requested[i] = 0; // clear dst requested
|
||||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
eiger_ntriggers = val;
|
eiger_ntriggers = val;
|
||||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||||
@ -867,7 +913,9 @@ int64_t getNumTriggers() { return eiger_ntriggers; }
|
|||||||
int setExpTime(int64_t val) {
|
int setExpTime(int64_t val) {
|
||||||
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_SetExposureTime(val / (1E9));
|
Feb_Control_SetExposureTime(val / (1E9));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
eiger_virtual_exptime = val;
|
eiger_virtual_exptime = val;
|
||||||
#endif
|
#endif
|
||||||
@ -876,7 +924,10 @@ int setExpTime(int64_t val) {
|
|||||||
|
|
||||||
int64_t getExpTime() {
|
int64_t getExpTime() {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
return (Feb_Control_GetExposureTime() * (1E9));
|
sharedMemory_lockLocalLink();
|
||||||
|
int64_t retval = (Feb_Control_GetExposureTime() * (1E9));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
return retval;
|
||||||
#else
|
#else
|
||||||
return eiger_virtual_exptime;
|
return eiger_virtual_exptime;
|
||||||
#endif
|
#endif
|
||||||
@ -885,7 +936,9 @@ int64_t getExpTime() {
|
|||||||
int setPeriod(int64_t val) {
|
int setPeriod(int64_t val) {
|
||||||
LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
|
LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_SetExposurePeriod(val / (1E9));
|
Feb_Control_SetExposurePeriod(val / (1E9));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
eiger_virtual_period = val;
|
eiger_virtual_period = val;
|
||||||
#endif
|
#endif
|
||||||
@ -894,7 +947,10 @@ int setPeriod(int64_t val) {
|
|||||||
|
|
||||||
int64_t getPeriod() {
|
int64_t getPeriod() {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
return (Feb_Control_GetExposurePeriod() * (1E9));
|
sharedMemory_lockLocalLink();
|
||||||
|
int64_t retval = (Feb_Control_GetExposurePeriod() * (1E9));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
return retval;
|
||||||
#else
|
#else
|
||||||
return eiger_virtual_period;
|
return eiger_virtual_period;
|
||||||
#endif
|
#endif
|
||||||
@ -903,12 +959,14 @@ int64_t getPeriod() {
|
|||||||
int setSubExpTime(int64_t val) {
|
int setSubExpTime(int64_t val) {
|
||||||
LOG(logINFO, ("Setting subexptime %lld ns\n", (long long int)val));
|
LOG(logINFO, ("Setting subexptime %lld ns\n", (long long int)val));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
// calculate subdeadtime before settings subexptime
|
// calculate subdeadtime before settings subexptime
|
||||||
int64_t subdeadtime =
|
int64_t subdeadtime =
|
||||||
Feb_Control_GetSubFramePeriod() - Feb_Control_GetSubFrameExposureTime();
|
Feb_Control_GetSubFramePeriod() - Feb_Control_GetSubFrameExposureTime();
|
||||||
Feb_Control_SetSubFrameExposureTime(val / 10);
|
Feb_Control_SetSubFrameExposureTime(val / 10);
|
||||||
// set subperiod
|
// set subperiod
|
||||||
Feb_Control_SetSubFramePeriod((val + subdeadtime) / 10);
|
Feb_Control_SetSubFramePeriod((val + subdeadtime) / 10);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
int64_t subdeadtime =
|
int64_t subdeadtime =
|
||||||
eiger_virtual_subperiod * 10 - eiger_virtual_subexptime * 10;
|
eiger_virtual_subperiod * 10 - eiger_virtual_subexptime * 10;
|
||||||
@ -920,7 +978,10 @@ int setSubExpTime(int64_t val) {
|
|||||||
|
|
||||||
int64_t getSubExpTime() {
|
int64_t getSubExpTime() {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
return (Feb_Control_GetSubFrameExposureTime());
|
sharedMemory_lockLocalLink();
|
||||||
|
int64_t retval = (Feb_Control_GetSubFrameExposureTime());
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
return retval;
|
||||||
#else
|
#else
|
||||||
return eiger_virtual_subexptime * 10;
|
return eiger_virtual_subexptime * 10;
|
||||||
#endif
|
#endif
|
||||||
@ -929,8 +990,10 @@ int64_t getSubExpTime() {
|
|||||||
int setSubDeadTime(int64_t val) {
|
int setSubDeadTime(int64_t val) {
|
||||||
LOG(logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val));
|
LOG(logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
// get subexptime
|
// get subexptime
|
||||||
int64_t subexptime = Feb_Control_GetSubFrameExposureTime();
|
int64_t subexptime = Feb_Control_GetSubFrameExposureTime();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
int64_t subexptime = eiger_virtual_subexptime * 10;
|
int64_t subexptime = eiger_virtual_subexptime * 10;
|
||||||
#endif
|
#endif
|
||||||
@ -941,7 +1004,9 @@ int setSubDeadTime(int64_t val) {
|
|||||||
// calculate subperiod
|
// calculate subperiod
|
||||||
val += subexptime;
|
val += subexptime;
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_SetSubFramePeriod(val / 10);
|
Feb_Control_SetSubFramePeriod(val / 10);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
eiger_virtual_subperiod = (val / 10);
|
eiger_virtual_subperiod = (val / 10);
|
||||||
#endif
|
#endif
|
||||||
@ -950,13 +1015,18 @@ int setSubDeadTime(int64_t val) {
|
|||||||
|
|
||||||
int64_t getSubDeadTime() {
|
int64_t getSubDeadTime() {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
// get subexptime
|
// get subexptime
|
||||||
int64_t subexptime = Feb_Control_GetSubFrameExposureTime();
|
int64_t subexptime = Feb_Control_GetSubFrameExposureTime();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
int64_t subexptime = eiger_virtual_subexptime * 10;
|
int64_t subexptime = eiger_virtual_subexptime * 10;
|
||||||
#endif
|
#endif
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
return (Feb_Control_GetSubFramePeriod() - subexptime);
|
sharedMemory_lockLocalLink();
|
||||||
|
int64_t retval = (Feb_Control_GetSubFramePeriod() - subexptime);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
return retval;
|
||||||
#else
|
#else
|
||||||
return (eiger_virtual_subperiod * 10 - subexptime);
|
return (eiger_virtual_subperiod * 10 - subexptime);
|
||||||
#endif
|
#endif
|
||||||
@ -966,7 +1036,10 @@ int64_t getMeasuredPeriod() {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
return Feb_Control_GetMeasuredPeriod();
|
sharedMemory_lockLocalLink();
|
||||||
|
int64_t retval = Feb_Control_GetMeasuredPeriod();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
return retval;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -974,7 +1047,10 @@ int64_t getMeasuredSubPeriod() {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
return Feb_Control_GetSubMeasuredPeriod();
|
sharedMemory_lockLocalLink();
|
||||||
|
int64_t retval = Feb_Control_GetSubMeasuredPeriod();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
return retval;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1053,14 +1129,17 @@ int setModule(sls_detector_module myMod, char *mess) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set trimbits
|
// set trimbits
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_SetTrimbits(tt, top)) {
|
if (!Feb_Control_SetTrimbits(tt, top)) {
|
||||||
sprintf(mess, "Could not set module. Could not set trimbits\n");
|
sprintf(mess, "Could not set module. Could not set trimbits\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
setSettings(UNDEFINED);
|
setSettings(UNDEFINED);
|
||||||
LOG(logERROR, ("Settings has been changed to undefined (random "
|
LOG(logERROR, ("Settings has been changed to undefined (random "
|
||||||
"trim file)\n"));
|
"trim file)\n"));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1184,9 +1263,11 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (Feb_Control_SetDAC(ind, dacval)) {
|
if (Feb_Control_SetDAC(ind, dacval)) {
|
||||||
(detectorModules)->dacs[ind] = dacval;
|
(detectorModules)->dacs[ind] = dacval;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1232,19 +1313,23 @@ int getADC(enum ADCINDEX ind) {
|
|||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
char tempnames[6][20] = {"FPGA EXT", "10GE", "DCDC",
|
char *adc_names[] = {ADC_NAMES};
|
||||||
"SODL", "SODR", "FPGA"};
|
|
||||||
char cstore[255];
|
char cstore[255];
|
||||||
|
memset(cstore, 0, 255);
|
||||||
|
|
||||||
switch (ind) {
|
switch (ind) {
|
||||||
case TEMP_FPGA:
|
case TEMP_FPGA:
|
||||||
retval = getBebFPGATemp();
|
retval = getBebFPGATemp();
|
||||||
break;
|
break;
|
||||||
case TEMP_FPGAFEBL:
|
case TEMP_FPGAFEBL:
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
retval = Feb_Control_GetLeftFPGATemp();
|
retval = Feb_Control_GetLeftFPGATemp();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
break;
|
break;
|
||||||
case TEMP_FPGAFEBR:
|
case TEMP_FPGAFEBR:
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
retval = Feb_Control_GetRightFPGATemp();
|
retval = Feb_Control_GetRightFPGATemp();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
break;
|
break;
|
||||||
case TEMP_FPGAEXT:
|
case TEMP_FPGAEXT:
|
||||||
case TEMP_10GE:
|
case TEMP_10GE:
|
||||||
@ -1263,7 +1348,7 @@ int getADC(enum ADCINDEX ind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
("Temperature %s: %f°C\n", tempnames[ind], (double)retval / 1000.00));
|
("Temperature %s: %f°C\n", adc_names[ind], (double)retval / 1000.00));
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
#endif
|
#endif
|
||||||
@ -1288,7 +1373,9 @@ int setHighVoltage(int val) {
|
|||||||
// set
|
// set
|
||||||
if (val != -1) {
|
if (val != -1) {
|
||||||
eiger_theo_highvoltage = val;
|
eiger_theo_highvoltage = val;
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
int ret = Feb_Control_SetHighVoltage(val);
|
int ret = Feb_Control_SetHighVoltage(val);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
if (!ret) // could not set
|
if (!ret) // could not set
|
||||||
return -2;
|
return -2;
|
||||||
else if (ret == -1) // outside range
|
else if (ret == -1) // outside range
|
||||||
@ -1296,10 +1383,13 @@ int setHighVoltage(int val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get
|
// get
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_GetHighVoltage(&eiger_highvoltage)) {
|
if (!Feb_Control_GetHighVoltage(&eiger_highvoltage)) {
|
||||||
LOG(logERROR, ("Could not read high voltage\n"));
|
LOG(logERROR, ("Could not read high voltage\n"));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
|
||||||
// tolerance of 5
|
// tolerance of 5
|
||||||
if (abs(eiger_theo_highvoltage - eiger_highvoltage) >
|
if (abs(eiger_theo_highvoltage - eiger_highvoltage) >
|
||||||
@ -1338,9 +1428,14 @@ void setTiming(enum timingMode arg) {
|
|||||||
}
|
}
|
||||||
LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
|
LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
if (Feb_Control_SetTriggerMode(ret))
|
sharedMemory_lockLocalLink();
|
||||||
#endif
|
if (Feb_Control_SetTriggerMode(ret)) {
|
||||||
eiger_triggermode = ret;
|
eiger_triggermode = ret;
|
||||||
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
#else
|
||||||
|
eiger_triggermode = ret;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
enum timingMode getTiming() {
|
enum timingMode getTiming() {
|
||||||
@ -1468,9 +1563,12 @@ int setQuad(int value) {
|
|||||||
if (Beb_SetQuad(value) == FAIL) {
|
if (Beb_SetQuad(value) == FAIL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_SetQuad(value)) {
|
if (!Feb_Control_SetQuad(value)) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
eiger_virtual_quad_mode = value;
|
eiger_virtual_quad_mode = value;
|
||||||
#endif
|
#endif
|
||||||
@ -1489,9 +1587,12 @@ int setInterruptSubframe(int value) {
|
|||||||
if (value < 0)
|
if (value < 0)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_SetInterruptSubframe(value)) {
|
if (!Feb_Control_SetInterruptSubframe(value)) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
eiger_virtual_interrupt_subframe = value;
|
eiger_virtual_interrupt_subframe = value;
|
||||||
#endif
|
#endif
|
||||||
@ -1502,7 +1603,10 @@ int getInterruptSubframe() {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return eiger_virtual_interrupt_subframe;
|
return eiger_virtual_interrupt_subframe;
|
||||||
#else
|
#else
|
||||||
return Feb_Control_GetInterruptSubframe();
|
sharedMemory_lockLocalLink();
|
||||||
|
int retval = Feb_Control_GetInterruptSubframe();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
return retval;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1510,9 +1614,12 @@ int setReadNLines(int value) {
|
|||||||
if (value < 0)
|
if (value < 0)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_SetReadNLines(value)) {
|
if (!Feb_Control_SetReadNLines(value)) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
Beb_SetReadNLines(value);
|
Beb_SetReadNLines(value);
|
||||||
#else
|
#else
|
||||||
eiger_virtual_read_nlines = value;
|
eiger_virtual_read_nlines = value;
|
||||||
@ -1524,7 +1631,10 @@ int getReadNLines() {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return eiger_virtual_read_nlines;
|
return eiger_virtual_read_nlines;
|
||||||
#else
|
#else
|
||||||
return Feb_Control_GetReadNLines();
|
sharedMemory_lockLocalLink();
|
||||||
|
int retval = Feb_Control_GetReadNLines();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
return retval;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1548,9 +1658,14 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
|||||||
if (val >= 0) {
|
if (val >= 0) {
|
||||||
LOG(logINFO, ("Setting Read out Speed: %d\n", val));
|
LOG(logINFO, ("Setting Read out Speed: %d\n", val));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
if (Feb_Control_SetReadoutSpeed(val))
|
sharedMemory_lockLocalLink();
|
||||||
#endif
|
if (Feb_Control_SetReadoutSpeed(val)) {
|
||||||
eiger_readoutspeed = val;
|
eiger_readoutspeed = val;
|
||||||
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
#else
|
||||||
|
eiger_readoutspeed = val;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -1567,9 +1682,14 @@ int setIODelay(int val) {
|
|||||||
if (val != -1) {
|
if (val != -1) {
|
||||||
LOG(logDEBUG1, ("Setting IO Delay: %d\n", val));
|
LOG(logDEBUG1, ("Setting IO Delay: %d\n", val));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
if (Feb_Control_SetIDelays(val))
|
sharedMemory_lockLocalLink();
|
||||||
#endif
|
if (Feb_Control_SetIDelays(val)) {
|
||||||
eiger_iodelay = val;
|
eiger_iodelay = val;
|
||||||
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
#else
|
||||||
|
eiger_iodelay = val;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return eiger_iodelay;
|
return eiger_iodelay;
|
||||||
}
|
}
|
||||||
@ -1580,36 +1700,53 @@ int setCounterBit(int val) {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
eiger_virtual_counter_bit = val;
|
eiger_virtual_counter_bit = val;
|
||||||
#else
|
#else
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_Set_Counter_Bit(val);
|
Feb_Control_Set_Counter_Bit(val);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return eiger_virtual_counter_bit;
|
return eiger_virtual_counter_bit;
|
||||||
#else
|
#else
|
||||||
return Feb_Control_Get_Counter_Bit();
|
sharedMemory_lockLocalLink();
|
||||||
|
int retval = Feb_Control_Get_Counter_Bit();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
return retval;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int pulsePixel(int n, int x, int y) {
|
int pulsePixel(int n, int x, int y) {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
if (!Feb_Control_Pulse_Pixel(n, x, y))
|
sharedMemory_lockLocalLink();
|
||||||
|
if (!Feb_Control_Pulse_Pixel(n, x, y)) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pulsePixelNMove(int n, int x, int y) {
|
int pulsePixelNMove(int n, int x, int y) {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
if (!Feb_Control_PulsePixelNMove(n, x, y))
|
sharedMemory_lockLocalLink();
|
||||||
|
if (!Feb_Control_PulsePixelNMove(n, x, y)) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pulseChip(int n) {
|
int pulseChip(int n) {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
if (!Feb_Control_PulseChip(n))
|
sharedMemory_lockLocalLink();
|
||||||
|
if (!Feb_Control_PulseChip(n)) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -1715,10 +1852,12 @@ int setRateCorrection(
|
|||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
#else
|
#else
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
|
|
||||||
// deactivating rate correction
|
// deactivating rate correction
|
||||||
if (custom_tau_in_nsec == 0) {
|
if (custom_tau_in_nsec == 0) {
|
||||||
Feb_Control_SetRateCorrectionVariable(0);
|
Feb_Control_SetRateCorrectionVariable(0);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1757,6 +1896,7 @@ int setRateCorrection(
|
|||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
("Rate correction failed. Deactivating rate correction\n"));
|
("Rate correction failed. Deactivating rate correction\n"));
|
||||||
Feb_Control_SetRateCorrectionVariable(0);
|
Feb_Control_SetRateCorrectionVariable(0);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1765,6 +1905,7 @@ int setRateCorrection(
|
|||||||
LOG(logINFO, ("Rate Correction Value set to %lld ns\n",
|
LOG(logINFO, ("Rate Correction Value set to %lld ns\n",
|
||||||
(long long int)Feb_Control_Get_RateTable_Tau_in_nsec()));
|
(long long int)Feb_Control_Get_RateTable_Tau_in_nsec()));
|
||||||
Feb_Control_PrintCorrectedValues();
|
Feb_Control_PrintCorrectedValues();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
@ -1774,7 +1915,10 @@ int getRateCorrectionEnable() {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return eiger_virtual_ratecorrection_variable;
|
return eiger_virtual_ratecorrection_variable;
|
||||||
#else
|
#else
|
||||||
return Feb_Control_GetRateCorrectionVariable();
|
sharedMemory_lockLocalLink();
|
||||||
|
int retval = Feb_Control_GetRateCorrectionVariable();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
return retval;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1791,7 +1935,9 @@ int64_t getCurrentTau() {
|
|||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
eiger_tau_ns = Feb_Control_Get_RateTable_Tau_in_nsec();
|
eiger_tau_ns = Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#else
|
#else
|
||||||
eiger_tau_ns = eiger_virtual_ratetable_tau_in_ns;
|
eiger_tau_ns = eiger_virtual_ratetable_tau_in_ns;
|
||||||
#endif
|
#endif
|
||||||
@ -1804,9 +1950,11 @@ void setExternalGating(int enable[]) {
|
|||||||
// default: disable gating with positive polarity
|
// default: disable gating with positive polarity
|
||||||
if (enable[0] >= 0 && enable[1] >= 0) {
|
if (enable[0] >= 0 && enable[1] >= 0) {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_SetExternalEnableMode(
|
Feb_Control_SetExternalEnableMode(
|
||||||
enable[0], enable[1]); // enable = 0 or 1, polarity = 0 or 1 , where
|
enable[0], enable[1]); // enable = 0 or 1, polarity = 0 or 1 , where
|
||||||
// 1 is positive
|
// 1 is positive
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
eiger_extgating = enable[0];
|
eiger_extgating = enable[0];
|
||||||
eiger_extgatingpolarity = enable[1];
|
eiger_extgatingpolarity = enable[1];
|
||||||
@ -1818,10 +1966,13 @@ void setExternalGating(int enable[]) {
|
|||||||
int setAllTrimbits(int val) {
|
int setAllTrimbits(int val) {
|
||||||
LOG(logINFO, ("Setting all trimbits to %d\n", val));
|
LOG(logINFO, ("Setting all trimbits to %d\n", val));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if (!Feb_Control_SaveAllTrimbitsTo(val, top)) {
|
if (!Feb_Control_SaveAllTrimbitsTo(val, top)) {
|
||||||
LOG(logERROR, ("Could not set all trimbits\n"));
|
LOG(logERROR, ("Could not set all trimbits\n"));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
if (detectorModules) {
|
if (detectorModules) {
|
||||||
for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
|
for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
|
||||||
@ -1866,7 +2017,9 @@ int setActivate(int enable) {
|
|||||||
if (!Beb_SetActivate(enable)) {
|
if (!Beb_SetActivate(enable)) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
Feb_Control_activate(enable);
|
Feb_Control_activate(enable);
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
if (enable) {
|
if (enable) {
|
||||||
LOG(logINFOGREEN, ("Activated in %s Server!\n",
|
LOG(logINFOGREEN, ("Activated in %s Server!\n",
|
||||||
@ -1969,9 +2122,11 @@ int setTransmissionDelayRight(int value) {
|
|||||||
|
|
||||||
int prepareAcquisition() {
|
int prepareAcquisition() {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",
|
LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",
|
||||||
Feb_Control_Get_Counter_Bit()));
|
Feb_Control_Get_Counter_Bit()));
|
||||||
Feb_Control_PrepareForAcquisition();
|
Feb_Control_PrepareForAcquisition();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
#endif
|
#endif
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -2000,6 +2155,7 @@ int startStateMachine() {
|
|||||||
LOG(logINFO, ("Virtual Acquisition started\n"));
|
LOG(logINFO, ("Virtual Acquisition started\n"));
|
||||||
return OK;
|
return OK;
|
||||||
#else
|
#else
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
LOG(logINFO, ("Acquisition started bit toggled\n"));
|
LOG(logINFO, ("Acquisition started bit toggled\n"));
|
||||||
int ret = OK, prev_flag;
|
int ret = OK, prev_flag;
|
||||||
// get the DAQ toggle bit
|
// get the DAQ toggle bit
|
||||||
@ -2016,10 +2172,12 @@ int startStateMachine() {
|
|||||||
if (!Feb_Control_WaitForStartedFlag(5000, prev_flag)) {
|
if (!Feb_Control_WaitForStartedFlag(5000, prev_flag)) {
|
||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
("Acquisition did not LOG(logERROR ouble reading register\n"));
|
("Acquisition did not LOG(logERROR ouble reading register\n"));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("Acquisition started\n"));
|
LOG(logINFOGREEN, ("Acquisition started\n"));
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
@ -2222,11 +2380,14 @@ int stopStateMachine() {
|
|||||||
LOG(logINFO, ("Stopped State Machine\n"));
|
LOG(logINFO, ("Stopped State Machine\n"));
|
||||||
return OK;
|
return OK;
|
||||||
#else
|
#else
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
if ((Feb_Control_StopAcquisition() != STATUS_IDLE) ||
|
if ((Feb_Control_StopAcquisition() != STATUS_IDLE) ||
|
||||||
(!Beb_StopAcquisition())) {
|
(!Beb_StopAcquisition())) {
|
||||||
LOG(logERROR, ("failed to stop acquisition\n"));
|
LOG(logERROR, ("failed to stop acquisition\n"));
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
|
|
||||||
// ensure all have same starting frame numbers
|
// ensure all have same starting frame numbers
|
||||||
uint64_t retval = 0;
|
uint64_t retval = 0;
|
||||||
@ -2241,8 +2402,12 @@ int softwareTrigger() {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return OK;
|
return OK;
|
||||||
#else
|
#else
|
||||||
if (!Feb_Control_SoftwareTrigger())
|
sharedMemory_lockLocalLink();
|
||||||
|
if (!Feb_Control_SoftwareTrigger()) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -2293,7 +2458,9 @@ enum runStatus getRunStatus() {
|
|||||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||||
return IDLE;
|
return IDLE;
|
||||||
#else
|
#else
|
||||||
|
sharedMemory_lockLocalLink();
|
||||||
int i = Feb_Control_AcquisitionInProgress();
|
int i = Feb_Control_AcquisitionInProgress();
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
if (i == STATUS_ERROR) {
|
if (i == STATUS_ERROR) {
|
||||||
LOG(logERROR, ("Status: ERROR reading status register\n"));
|
LOG(logERROR, ("Status: ERROR reading status register\n"));
|
||||||
return ERROR;
|
return ERROR;
|
||||||
@ -2324,11 +2491,14 @@ void readFrame(int *ret, char *mess) {
|
|||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if (Feb_Control_WaitForFinishedFlag(5000) == STATUS_ERROR) {
|
sharedMemory_lockLocalLink();
|
||||||
|
if (Feb_Control_WaitForFinishedFlag(5000, 1) == STATUS_ERROR) {
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
LOG(logERROR, ("Waiting for finished flag\n"));
|
LOG(logERROR, ("Waiting for finished flag\n"));
|
||||||
*ret = FAIL;
|
*ret = FAIL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sharedMemory_unlockLocalLink();
|
||||||
LOG(logINFOGREEN, ("Acquisition finished\n"));
|
LOG(logINFOGREEN, ("Acquisition finished\n"));
|
||||||
|
|
||||||
// wait for detector to send
|
// wait for detector to send
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
|
||||||
#define REQUIRED_FIRMWARE_VERSION (26)
|
#define REQUIRED_FIRMWARE_VERSION (27)
|
||||||
#define IDFILECOMMAND "more /home/root/executables/detid.txt"
|
#define IDFILECOMMAND "more /home/root/executables/detid.txt"
|
||||||
#define CONFIG_FILE ("config_eiger.txt")
|
#define CONFIG_FILE ("config_eiger.txt")
|
||||||
#define WAIT_STOP_SERVER_START (1 * 1000 * 1000)
|
#define WAIT_STOP_SERVER_START (1 * 1000 * 1000)
|
||||||
@ -63,6 +63,10 @@ enum ADCINDEX {
|
|||||||
TEMP_FPGAFEBL,
|
TEMP_FPGAFEBL,
|
||||||
TEMP_FPGAFEBR
|
TEMP_FPGAFEBR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define ADC_NAMES \
|
||||||
|
"FPGA EXT", "10GE", "DCDC", "SODL", "SODR", "FPGA", "FPGA_FL", "FPGA_FR"
|
||||||
|
|
||||||
enum NETWORKINDEX { TXN_LEFT, TXN_RIGHT, TXN_FRAME, FLOWCTRL_10G };
|
enum NETWORKINDEX { TXN_LEFT, TXN_RIGHT, TXN_FRAME, FLOWCTRL_10G };
|
||||||
enum ROINDEX { E_PARALLEL, E_NON_PARALLEL };
|
enum ROINDEX { E_PARALLEL, E_NON_PARALLEL };
|
||||||
enum CLKINDEX { RUN_CLK, NUM_CLOCKS };
|
enum CLKINDEX { RUN_CLK, NUM_CLOCKS };
|
||||||
@ -130,7 +134,7 @@ enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
|
|||||||
#define DAC_MAX_STEPS (4096)
|
#define DAC_MAX_STEPS (4096)
|
||||||
|
|
||||||
#define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS \
|
#define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS \
|
||||||
(0x1FFFFFFF) /** 29 bit register for max subframe exposure value */
|
(0x1FFFFFFF) // 29 bit register for max subframe exposure value
|
||||||
|
|
||||||
#define SLAVE_HIGH_VOLTAGE_READ_VAL (-999)
|
#define SLAVE_HIGH_VOLTAGE_READ_VAL (-999)
|
||||||
#define HIGH_VOLTAGE_TOLERANCE (5)
|
#define HIGH_VOLTAGE_TOLERANCE (5)
|
||||||
|
@ -152,6 +152,10 @@
|
|||||||
#define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC)
|
#define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC)
|
||||||
#define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC)
|
#define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC)
|
||||||
|
|
||||||
|
/* ASIC Exptime 64bit Register */
|
||||||
|
#define ASIC_CONT_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_ASIC)
|
||||||
|
#define ASIC_CONT_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_ASIC)
|
||||||
|
|
||||||
/* Packetizer -------------------------------------------------------------*/
|
/* Packetizer -------------------------------------------------------------*/
|
||||||
|
|
||||||
/* Packetizer Config Register */
|
/* Packetizer Config Register */
|
||||||
|
Binary file not shown.
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
|
extern int updateFlag;
|
||||||
extern int checkModuleFlag;
|
extern int checkModuleFlag;
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
@ -53,6 +54,8 @@ int vetoReference[NCHIP][NCHAN];
|
|||||||
int vetoGainIndices[NCHIP][NCHAN];
|
int vetoGainIndices[NCHIP][NCHAN];
|
||||||
uint8_t adcConfiguration[NCHIP][NADC];
|
uint8_t adcConfiguration[NCHIP][NADC];
|
||||||
int burstMode = BURST_INTERNAL;
|
int burstMode = BURST_INTERNAL;
|
||||||
|
int64_t numFramesReg = 1;
|
||||||
|
int64_t periodReg = 0;
|
||||||
int64_t numTriggersReg = 1;
|
int64_t numTriggersReg = 1;
|
||||||
int64_t delayReg = 0;
|
int64_t delayReg = 0;
|
||||||
int64_t numBurstsReg = 1;
|
int64_t numBurstsReg = 1;
|
||||||
@ -92,8 +95,9 @@ void basictests() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// does check only if flag is 0 (by default), set by command line
|
// does check only if flag is 0 (by default), set by command line
|
||||||
if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) ||
|
if ((!debugflag) && (!updateFlag) &&
|
||||||
(testBus() == FAIL))) {
|
((checkKernelVersion() == FAIL) || (checkType() == FAIL) ||
|
||||||
|
(testFpga() == FAIL) || (testBus() == FAIL))) {
|
||||||
sprintf(initErrorMessage,
|
sprintf(initErrorMessage,
|
||||||
"Could not pass basic tests of FPGA and bus. Dangerous to "
|
"Could not pass basic tests of FPGA and bus. Dangerous to "
|
||||||
"continue. (Firmware version:0x%llx) \n",
|
"continue. (Firmware version:0x%llx) \n",
|
||||||
@ -131,7 +135,7 @@ void basictests() {
|
|||||||
(long long int)client_sw_apiversion));
|
(long long int)client_sw_apiversion));
|
||||||
|
|
||||||
// return if flag is not zero, debug mode
|
// return if flag is not zero, debug mode
|
||||||
if (debugflag) {
|
if (debugflag || updateFlag) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +179,13 @@ void basictests() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int checkKernelVersion() {
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return OK;
|
||||||
|
#endif
|
||||||
|
return Nios_checkKernelVersion(KERNEL_DATE_VRSN);
|
||||||
|
}
|
||||||
|
|
||||||
int checkType() {
|
int checkType() {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return OK;
|
return OK;
|
||||||
@ -326,7 +337,7 @@ u_int32_t getDetectorIP() {
|
|||||||
/* initialization */
|
/* initialization */
|
||||||
|
|
||||||
void initControlServer() {
|
void initControlServer() {
|
||||||
if (initError == OK) {
|
if (!updateFlag && initError == OK) {
|
||||||
setupDetector();
|
setupDetector();
|
||||||
}
|
}
|
||||||
initCheckDone = 1;
|
initCheckDone = 1;
|
||||||
@ -368,6 +379,8 @@ void setupDetector() {
|
|||||||
injectedChannelsOffset = 0;
|
injectedChannelsOffset = 0;
|
||||||
injectedChannelsIncrement = 0;
|
injectedChannelsIncrement = 0;
|
||||||
burstMode = BURST_INTERNAL;
|
burstMode = BURST_INTERNAL;
|
||||||
|
numFramesReg = 1;
|
||||||
|
periodReg = 0;
|
||||||
numTriggersReg = 1;
|
numTriggersReg = 1;
|
||||||
delayReg = 0;
|
delayReg = 0;
|
||||||
numBurstsReg = 1;
|
numBurstsReg = 1;
|
||||||
@ -809,12 +822,24 @@ int setDynamicRange(int dr) { return DYNAMIC_RANGE; }
|
|||||||
/* parameters - timer */
|
/* parameters - timer */
|
||||||
void setNumFrames(int64_t val) {
|
void setNumFrames(int64_t val) {
|
||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
|
numFramesReg = val;
|
||||||
// continuous
|
// continuous
|
||||||
if (burstMode == CONTINUOUS_INTERNAL ||
|
if (burstMode == CONTINUOUS_INTERNAL ||
|
||||||
burstMode == CONTINUOUS_EXTERNAL) {
|
burstMode == CONTINUOUS_EXTERNAL) {
|
||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
("Setting number of frames %lld [Continuous mode]\n", val));
|
("Setting number of frames %lld [Continuous mode]\n", val));
|
||||||
set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
// trigger
|
||||||
|
if (getTiming() == TRIGGER_EXPOSURE) {
|
||||||
|
LOG(logINFO,
|
||||||
|
("\tCont. Trigger mode (not writing to register)\n", val));
|
||||||
|
// #frames limited in cont trigger mode
|
||||||
|
}
|
||||||
|
// auto
|
||||||
|
else {
|
||||||
|
set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
||||||
|
set64BitReg(val, ASIC_CONT_FRAMES_LSB_REG,
|
||||||
|
ASIC_CONT_FRAMES_MSB_REG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// burst
|
// burst
|
||||||
else {
|
else {
|
||||||
@ -832,6 +857,12 @@ void setNumFrames(int64_t val) {
|
|||||||
int64_t getNumFrames() {
|
int64_t getNumFrames() {
|
||||||
// continuous
|
// continuous
|
||||||
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
|
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
|
||||||
|
// trigger
|
||||||
|
if (getTiming() == TRIGGER_EXPOSURE) {
|
||||||
|
// #frames limited in cont trigger mode
|
||||||
|
return numFramesReg;
|
||||||
|
}
|
||||||
|
// auto
|
||||||
return get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
return get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
||||||
}
|
}
|
||||||
// burst
|
// burst
|
||||||
@ -843,25 +874,37 @@ int64_t getNumFrames() {
|
|||||||
|
|
||||||
void setNumTriggers(int64_t val) {
|
void setNumTriggers(int64_t val) {
|
||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
|
numTriggersReg = val;
|
||||||
LOG(logINFO, ("Setting number of triggers %lld\n", val));
|
LOG(logINFO, ("Setting number of triggers %lld\n", val));
|
||||||
|
// auto
|
||||||
if (getTiming() == AUTO_TIMING) {
|
if (getTiming() == AUTO_TIMING) {
|
||||||
LOG(logINFO, ("\tNot trigger mode: not writing to register\n"));
|
LOG(logINFO, ("\tAuto mode (not writing to register)\n"));
|
||||||
numTriggersReg = val;
|
}
|
||||||
} else {
|
// trigger
|
||||||
|
else {
|
||||||
set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||||
|
// continuous
|
||||||
|
if (burstMode == CONTINUOUS_INTERNAL ||
|
||||||
|
burstMode == CONTINUOUS_EXTERNAL) {
|
||||||
|
set64BitReg(val, ASIC_CONT_FRAMES_LSB_REG,
|
||||||
|
ASIC_CONT_FRAMES_MSB_REG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t getNumTriggers() {
|
int64_t getNumTriggers() {
|
||||||
|
// auto
|
||||||
if (getTiming() == AUTO_TIMING) {
|
if (getTiming() == AUTO_TIMING) {
|
||||||
return numTriggersReg;
|
return numTriggersReg;
|
||||||
}
|
}
|
||||||
|
// trigger
|
||||||
return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNumBursts(int64_t val) {
|
void setNumBursts(int64_t val) {
|
||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
|
numBurstsReg = val;
|
||||||
LOG(logINFO, ("Setting number of bursts %lld\n", val));
|
LOG(logINFO, ("Setting number of bursts %lld\n", val));
|
||||||
// burst and auto
|
// burst and auto
|
||||||
if ((burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) &&
|
if ((burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) &&
|
||||||
@ -872,7 +915,6 @@ void setNumBursts(int64_t val) {
|
|||||||
else {
|
else {
|
||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
("\tNot (Burst and Auto mode): not writing to register\n"));
|
("\tNot (Burst and Auto mode): not writing to register\n"));
|
||||||
numBurstsReg = val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -919,7 +961,16 @@ int setPeriod(int64_t val) {
|
|||||||
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
|
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
|
||||||
LOG(logINFO, ("Setting period %lld ns [Continuous mode]\n", val));
|
LOG(logINFO, ("Setting period %lld ns [Continuous mode]\n", val));
|
||||||
val *= (1E-9 * systemFrequency);
|
val *= (1E-9 * systemFrequency);
|
||||||
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
// trigger
|
||||||
|
if (getTiming() == TRIGGER_EXPOSURE) {
|
||||||
|
LOG(logINFO,
|
||||||
|
("\tCont. Trigger mode (not writing to register)\n", val));
|
||||||
|
// #frames limited in cont trigger mode
|
||||||
|
}
|
||||||
|
// auto
|
||||||
|
else {
|
||||||
|
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// burst
|
// burst
|
||||||
else {
|
else {
|
||||||
@ -927,6 +978,7 @@ int setPeriod(int64_t val) {
|
|||||||
val *= (1E-9 * systemFrequency);
|
val *= (1E-9 * systemFrequency);
|
||||||
set64BitReg(val, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
|
set64BitReg(val, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
|
||||||
}
|
}
|
||||||
|
periodReg = val;
|
||||||
// validate for tolerance
|
// validate for tolerance
|
||||||
int64_t retval = getPeriod();
|
int64_t retval = getPeriod();
|
||||||
val /= (1E-9 * systemFrequency);
|
val /= (1E-9 * systemFrequency);
|
||||||
@ -939,6 +991,12 @@ int setPeriod(int64_t val) {
|
|||||||
int64_t getPeriod() {
|
int64_t getPeriod() {
|
||||||
// continuous
|
// continuous
|
||||||
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
|
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
|
||||||
|
// trigger
|
||||||
|
if (getTiming() == TRIGGER_EXPOSURE) {
|
||||||
|
// #frames limited in cont trigger mode
|
||||||
|
return periodReg / (1E-9 * systemFrequency);
|
||||||
|
}
|
||||||
|
// auto
|
||||||
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG) /
|
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG) /
|
||||||
(1E-9 * systemFrequency);
|
(1E-9 * systemFrequency);
|
||||||
}
|
}
|
||||||
@ -956,9 +1014,9 @@ int setDelayAfterTrigger(int64_t val) {
|
|||||||
}
|
}
|
||||||
LOG(logINFO, ("Setting delay after trigger %lld ns\n", val));
|
LOG(logINFO, ("Setting delay after trigger %lld ns\n", val));
|
||||||
val *= (1E-9 * systemFrequency);
|
val *= (1E-9 * systemFrequency);
|
||||||
|
delayReg = val;
|
||||||
if (getTiming() == AUTO_TIMING) {
|
if (getTiming() == AUTO_TIMING) {
|
||||||
LOG(logINFO, ("\tNot trigger mode: not writing to register\n"));
|
LOG(logINFO, ("\tAuto mode (not writing to register)\n"));
|
||||||
delayReg = val;
|
|
||||||
} else {
|
} else {
|
||||||
set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
|
set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
|
||||||
}
|
}
|
||||||
@ -986,6 +1044,8 @@ int setBurstPeriod(int64_t val) {
|
|||||||
}
|
}
|
||||||
LOG(logINFO, ("Setting burst period %lld ns\n", val));
|
LOG(logINFO, ("Setting burst period %lld ns\n", val));
|
||||||
val *= (1E-9 * systemFrequency);
|
val *= (1E-9 * systemFrequency);
|
||||||
|
burstPeriodReg = val;
|
||||||
|
|
||||||
// burst and auto
|
// burst and auto
|
||||||
if ((burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) &&
|
if ((burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) &&
|
||||||
getTiming() == AUTO_TIMING) {
|
getTiming() == AUTO_TIMING) {
|
||||||
@ -993,9 +1053,7 @@ int setBurstPeriod(int64_t val) {
|
|||||||
}
|
}
|
||||||
// burst-trigger, continuous
|
// burst-trigger, continuous
|
||||||
else {
|
else {
|
||||||
LOG(logINFO,
|
LOG(logINFO, ("\tNot Burst and Auto mode (not writing to register)\n"));
|
||||||
("\tNot (Burst and Auto mode): not writing to register\n"));
|
|
||||||
burstPeriodReg = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate for tolerance
|
// validate for tolerance
|
||||||
@ -1019,11 +1077,21 @@ int64_t getBurstPeriod() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int64_t getNumFramesLeft() {
|
int64_t getNumFramesLeft() {
|
||||||
return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG);
|
// continuous and auto
|
||||||
|
if ((burstMode == CONTINUOUS_INTERNAL ||
|
||||||
|
burstMode == CONTINUOUS_EXTERNAL) &&
|
||||||
|
getTiming() == AUTO_TIMING) {
|
||||||
|
return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t getNumTriggersLeft() {
|
int64_t getNumTriggersLeft() {
|
||||||
return get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG);
|
// trigger
|
||||||
|
if (getTiming() == TRIGGER_EXPOSURE) {
|
||||||
|
return get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t getDelayAfterTriggerLeft() {
|
int64_t getDelayAfterTriggerLeft() {
|
||||||
@ -1036,6 +1104,15 @@ int64_t getPeriodLeft() {
|
|||||||
(1E-9 * systemFrequency);
|
(1E-9 * systemFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t getNumBurstsLeft() {
|
||||||
|
// burst and auto
|
||||||
|
if ((burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) &&
|
||||||
|
getTiming() == AUTO_TIMING) {
|
||||||
|
return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t getFramesFromStart() {
|
int64_t getFramesFromStart() {
|
||||||
return get64BitReg(FRAMES_FROM_START_LSB_REG, FRAMES_FROM_START_MSB_REG);
|
return get64BitReg(FRAMES_FROM_START_LSB_REG, FRAMES_FROM_START_MSB_REG);
|
||||||
}
|
}
|
||||||
@ -1229,20 +1306,201 @@ int setHighVoltage(int val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* parameters - timing */
|
/* parameters - timing */
|
||||||
void setTiming(enum timingMode arg) {
|
|
||||||
// update
|
|
||||||
// trigger
|
|
||||||
if (getTiming() == TRIGGER_EXPOSURE) {
|
|
||||||
numTriggersReg = get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
|
||||||
delayReg =
|
|
||||||
get64BitReg(SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
|
|
||||||
}
|
|
||||||
// auto and burst
|
|
||||||
else if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
|
|
||||||
numBurstsReg = get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
|
||||||
burstPeriodReg = get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void updatingRegisters() {
|
||||||
|
LOG(logINFO, ("\tUpdating registers\n"));
|
||||||
|
// burst
|
||||||
|
if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
|
||||||
|
// auto
|
||||||
|
if (getTiming() == AUTO_TIMING) {
|
||||||
|
LOG(logINFO, ("\t[Burst, Auto mode]\n"))
|
||||||
|
// trigger reg
|
||||||
|
set64BitReg(1, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tTrigger reg: %lld\n",
|
||||||
|
get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG)));
|
||||||
|
// delay reg
|
||||||
|
set64BitReg(0, SET_TRIGGER_DELAY_LSB_REG,
|
||||||
|
SET_TRIGGER_DELAY_MSB_REG);
|
||||||
|
LOG(logINFO,
|
||||||
|
("\tDelay reg: %lldns\n",
|
||||||
|
(long long int)(get64BitReg(SET_TRIGGER_DELAY_LSB_REG,
|
||||||
|
SET_TRIGGER_DELAY_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// frame reg
|
||||||
|
set64BitReg(numBurstsReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tFrame reg (bursts): %lld\n",
|
||||||
|
get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG)));
|
||||||
|
// period reg
|
||||||
|
set64BitReg(burstPeriodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tPeriod reg (burst period): %lldns\n",
|
||||||
|
(long long int)(get64BitReg(SET_PERIOD_LSB_REG,
|
||||||
|
SET_PERIOD_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// int. frame reg
|
||||||
|
bus_w(ASIC_INT_FRAMES_REG,
|
||||||
|
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
|
||||||
|
bus_w(ASIC_INT_FRAMES_REG,
|
||||||
|
bus_r(ASIC_INT_FRAMES_REG) |
|
||||||
|
(((int)numFramesReg << ASIC_INT_FRAMES_OFST) &
|
||||||
|
ASIC_INT_FRAMES_MSK));
|
||||||
|
LOG(logINFO, ("\tInt. Frame reg (frames): %d\n",
|
||||||
|
((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >>
|
||||||
|
ASIC_INT_FRAMES_OFST)));
|
||||||
|
// int. period reg
|
||||||
|
set64BitReg(periodReg, ASIC_INT_PERIOD_LSB_REG,
|
||||||
|
ASIC_INT_PERIOD_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tInt. Period reg (period): %lldns\n",
|
||||||
|
(long long int)(get64BitReg(ASIC_INT_PERIOD_LSB_REG,
|
||||||
|
ASIC_INT_PERIOD_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// extra frame reg (N.A)
|
||||||
|
}
|
||||||
|
// trigger
|
||||||
|
else {
|
||||||
|
LOG(logINFO, ("\t[Burst, Trigger mode]\n"))
|
||||||
|
// trigger reg
|
||||||
|
set64BitReg(numTriggersReg, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tTrigger reg (triggers): %lld\n",
|
||||||
|
get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG)));
|
||||||
|
// delay reg
|
||||||
|
set64BitReg(delayReg, SET_TRIGGER_DELAY_LSB_REG,
|
||||||
|
SET_TRIGGER_DELAY_MSB_REG);
|
||||||
|
LOG(logINFO,
|
||||||
|
("\tDelay reg (delay): %lldns\n",
|
||||||
|
(long long int)(get64BitReg(SET_TRIGGER_DELAY_LSB_REG,
|
||||||
|
SET_TRIGGER_DELAY_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// frame reg
|
||||||
|
set64BitReg(1, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tFrame reg: %lld\n",
|
||||||
|
get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG)));
|
||||||
|
// period reg
|
||||||
|
set64BitReg(0, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tPeriod reg: %lldns\n",
|
||||||
|
(long long int)(get64BitReg(SET_PERIOD_LSB_REG,
|
||||||
|
SET_PERIOD_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// int. frame reg
|
||||||
|
bus_w(ASIC_INT_FRAMES_REG,
|
||||||
|
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
|
||||||
|
bus_w(ASIC_INT_FRAMES_REG,
|
||||||
|
bus_r(ASIC_INT_FRAMES_REG) |
|
||||||
|
(((int)numFramesReg << ASIC_INT_FRAMES_OFST) &
|
||||||
|
ASIC_INT_FRAMES_MSK));
|
||||||
|
LOG(logINFO, ("\tInt. Frame reg (frames): %d\n",
|
||||||
|
((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >>
|
||||||
|
ASIC_INT_FRAMES_OFST)));
|
||||||
|
// int. period reg
|
||||||
|
set64BitReg(periodReg, ASIC_INT_PERIOD_LSB_REG,
|
||||||
|
ASIC_INT_PERIOD_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tInt. Period reg (period): %lldns\n",
|
||||||
|
(long long int)(get64BitReg(ASIC_INT_PERIOD_LSB_REG,
|
||||||
|
ASIC_INT_PERIOD_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// extra frame reg (N.A)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// continuous
|
||||||
|
else {
|
||||||
|
// auto
|
||||||
|
if (getTiming() == AUTO_TIMING) {
|
||||||
|
LOG(logINFO, ("\t[Continuous, Auto mode]\n"))
|
||||||
|
// trigger reg
|
||||||
|
set64BitReg(1, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tTrigger reg: %lld\n",
|
||||||
|
get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG)));
|
||||||
|
// delay reg
|
||||||
|
set64BitReg(0, SET_TRIGGER_DELAY_LSB_REG,
|
||||||
|
SET_TRIGGER_DELAY_MSB_REG);
|
||||||
|
LOG(logINFO,
|
||||||
|
("\tDelay reg: %lldns\n",
|
||||||
|
(long long int)(get64BitReg(SET_TRIGGER_DELAY_LSB_REG,
|
||||||
|
SET_TRIGGER_DELAY_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// frame reg
|
||||||
|
set64BitReg(numFramesReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tFrame reg (frames): %lld\n",
|
||||||
|
get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG)));
|
||||||
|
// period reg
|
||||||
|
set64BitReg(periodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tPeriod reg (period): %lldns\n",
|
||||||
|
(long long int)(get64BitReg(SET_PERIOD_LSB_REG,
|
||||||
|
SET_PERIOD_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// int. frame reg
|
||||||
|
bus_w(ASIC_INT_FRAMES_REG,
|
||||||
|
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
|
||||||
|
bus_w(ASIC_INT_FRAMES_REG,
|
||||||
|
bus_r(ASIC_INT_FRAMES_REG) |
|
||||||
|
((1 << ASIC_INT_FRAMES_OFST) & ASIC_INT_FRAMES_MSK));
|
||||||
|
LOG(logINFO, ("\tInt. Frame reg: %d\n",
|
||||||
|
((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >>
|
||||||
|
ASIC_INT_FRAMES_OFST)));
|
||||||
|
// int. period reg
|
||||||
|
set64BitReg(0, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tInt. Period reg: %lldns\n",
|
||||||
|
(long long int)(get64BitReg(ASIC_INT_PERIOD_LSB_REG,
|
||||||
|
ASIC_INT_PERIOD_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// extra frame reg
|
||||||
|
set64BitReg(numFramesReg, ASIC_CONT_FRAMES_LSB_REG,
|
||||||
|
ASIC_CONT_FRAMES_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tExtra Frame reg (frames): %lld\n",
|
||||||
|
get64BitReg(ASIC_CONT_FRAMES_LSB_REG,
|
||||||
|
ASIC_CONT_FRAMES_MSB_REG)));
|
||||||
|
}
|
||||||
|
// trigger
|
||||||
|
else {
|
||||||
|
LOG(logINFO, ("\t[Continuous, Trigger mode]\n"))
|
||||||
|
// trigger reg
|
||||||
|
set64BitReg(numTriggersReg, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tTrigger reg (triggers): %lld\n",
|
||||||
|
get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG)));
|
||||||
|
// delay reg
|
||||||
|
set64BitReg(delayReg, SET_TRIGGER_DELAY_LSB_REG,
|
||||||
|
SET_TRIGGER_DELAY_MSB_REG);
|
||||||
|
LOG(logINFO,
|
||||||
|
("\tDelay reg (delay): %lldns\n",
|
||||||
|
(long long int)(get64BitReg(SET_TRIGGER_DELAY_LSB_REG,
|
||||||
|
SET_TRIGGER_DELAY_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// frame reg
|
||||||
|
set64BitReg(1, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tFrame reg: %lld\n",
|
||||||
|
get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG)));
|
||||||
|
// period reg
|
||||||
|
set64BitReg(0, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tPeriod reg: %lld\n",
|
||||||
|
(long long int)(get64BitReg(SET_PERIOD_LSB_REG,
|
||||||
|
SET_PERIOD_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// int. frame reg
|
||||||
|
bus_w(ASIC_INT_FRAMES_REG,
|
||||||
|
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
|
||||||
|
bus_w(ASIC_INT_FRAMES_REG,
|
||||||
|
bus_r(ASIC_INT_FRAMES_REG) |
|
||||||
|
((1 << ASIC_INT_FRAMES_OFST) & ASIC_INT_FRAMES_MSK));
|
||||||
|
LOG(logINFO, ("\tInt. Frame reg: %d\n",
|
||||||
|
((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >>
|
||||||
|
ASIC_INT_FRAMES_OFST)));
|
||||||
|
// int. period reg
|
||||||
|
set64BitReg(0, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tInt. Period reg: %lldns\n",
|
||||||
|
(long long int)(get64BitReg(ASIC_INT_PERIOD_LSB_REG,
|
||||||
|
ASIC_INT_PERIOD_MSB_REG) /
|
||||||
|
(1E-9 * systemFrequency))));
|
||||||
|
// extra frame reg
|
||||||
|
set64BitReg(numTriggersReg, ASIC_CONT_FRAMES_LSB_REG,
|
||||||
|
ASIC_CONT_FRAMES_MSB_REG);
|
||||||
|
LOG(logINFO, ("\tExtra Frame reg (triggers): %lld\n",
|
||||||
|
get64BitReg(ASIC_CONT_FRAMES_LSB_REG,
|
||||||
|
ASIC_CONT_FRAMES_MSB_REG)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("\tDone Updating registers\n\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTiming(enum timingMode arg) {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case AUTO_TIMING:
|
case AUTO_TIMING:
|
||||||
LOG(logINFO, ("Set Timing: Auto\n"));
|
LOG(logINFO, ("Set Timing: Auto\n"));
|
||||||
@ -1256,36 +1514,7 @@ void setTiming(enum timingMode arg) {
|
|||||||
LOG(logERROR, ("Unknown timing mode %d\n", arg));
|
LOG(logERROR, ("Unknown timing mode %d\n", arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO, ("\tUpdating registers\n"))
|
updatingRegisters();
|
||||||
// trigger
|
|
||||||
if (getTiming() == TRIGGER_EXPOSURE) {
|
|
||||||
set64BitReg(numTriggersReg, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
|
||||||
set64BitReg(delayReg, SET_TRIGGER_DELAY_LSB_REG,
|
|
||||||
SET_TRIGGER_DELAY_MSB_REG);
|
|
||||||
LOG(logINFO, ("\tTriggers reg: %lld, Delay reg: %lldns\n",
|
|
||||||
getNumTriggers(), getDelayAfterTrigger()));
|
|
||||||
// burst
|
|
||||||
if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
|
|
||||||
LOG(logINFO, ("\tFrame reg: 1, Period reg: 0\n"))
|
|
||||||
set64BitReg(1, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
|
||||||
set64BitReg(0, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// auto
|
|
||||||
else {
|
|
||||||
LOG(logINFO, ("\tTrigger reg: 1, Delay reg: 0\n"))
|
|
||||||
set64BitReg(1, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
|
||||||
set64BitReg(0, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
|
|
||||||
// burst
|
|
||||||
if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
|
|
||||||
set64BitReg(numBurstsReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
|
||||||
set64BitReg(burstPeriodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
|
||||||
LOG(logINFO, ("\tFrames reg (bursts): %lld, Period reg(burst "
|
|
||||||
"period): %lldns\n",
|
|
||||||
getNumBursts(), getBurstPeriod()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LOG(logINFO, ("\tDone Updating registers\n"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum timingMode getTiming() {
|
enum timingMode getTiming() {
|
||||||
@ -1457,8 +1686,8 @@ int configureMAC() {
|
|||||||
}
|
}
|
||||||
if (vetoEnabled && numInterfaces == 2 &&
|
if (vetoEnabled && numInterfaces == 2 &&
|
||||||
setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) {
|
setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) {
|
||||||
LOG(logERROR,
|
LOG(logERROR, ("could not set udp destination IP and port for "
|
||||||
("could not set udp destination IP and port for interface 2\n"));
|
"interface 2\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
@ -1869,8 +2098,8 @@ int configureASICVetoReference(int chipIndex, int *gainIndices, int *values) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create command for 4 padding + 1792 bits + 4 bits address = 1800 bits =
|
// create command for 4 padding + 1792 bits + 4 bits address = 1800
|
||||||
// 225 bytes
|
// bits = 225 bytes
|
||||||
char buffer[len];
|
char buffer[len];
|
||||||
memset(buffer, 0, len);
|
memset(buffer, 0, len);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
@ -1911,7 +2140,8 @@ int configureASICVetoReference(int chipIndex, int *gainIndices, int *values) {
|
|||||||
|
|
||||||
int getVetoPhoton(int chipIndex, int *retvals, int *gainRetvals) {
|
int getVetoPhoton(int chipIndex, int *retvals, int *gainRetvals) {
|
||||||
if (chipIndex == -1) {
|
if (chipIndex == -1) {
|
||||||
// if chipindex is -1, check that all values and gain indices are same
|
// if chipindex is -1, check that all values and gain indices are
|
||||||
|
// same
|
||||||
for (int i = 0; i < NCHAN; ++i) {
|
for (int i = 0; i < NCHAN; ++i) {
|
||||||
int val = vetoReference[0][i];
|
int val = vetoReference[0][i];
|
||||||
int gval = vetoGainIndices[0][i];
|
int gval = vetoGainIndices[0][i];
|
||||||
@ -1919,7 +2149,8 @@ int getVetoPhoton(int chipIndex, int *retvals, int *gainRetvals) {
|
|||||||
if (vetoReference[j][i] != val) {
|
if (vetoReference[j][i] != val) {
|
||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
("Get vet photon fail for chipIndex:%d. Different "
|
("Get vet photon fail for chipIndex:%d. Different "
|
||||||
"values between [nchip:%d, nchan:%d, value:%d] and "
|
"values between [nchip:%d, nchan:%d, value:%d] "
|
||||||
|
"and "
|
||||||
"[nchip:0, nchan:%d, value:%d]\n",
|
"[nchip:0, nchan:%d, value:%d]\n",
|
||||||
chipIndex, j, i, vetoReference[j][i], i, val));
|
chipIndex, j, i, vetoReference[j][i], i, val));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -1928,7 +2159,8 @@ int getVetoPhoton(int chipIndex, int *retvals, int *gainRetvals) {
|
|||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
("Get vet photon fail for chipIndex:%d. Different "
|
("Get vet photon fail for chipIndex:%d. Different "
|
||||||
"gain indices between [nchip:%d, nchan:%d, gain "
|
"gain indices between [nchip:%d, nchan:%d, gain "
|
||||||
"index:%d] and [nchip:0, nchan:%d, gain index:%d]\n",
|
"index:%d] and [nchip:0, nchan:%d, gain "
|
||||||
|
"index:%d]\n",
|
||||||
chipIndex, j, i, vetoGainIndices[j][i], i, gval));
|
chipIndex, j, i, vetoGainIndices[j][i], i, gval));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -2011,8 +2243,8 @@ int setADCConfiguration(int chipIndex, int adcIndex, int value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create command for 4 padding + 224 bits + 4 bits address = 232 bits = 29
|
// create command for 4 padding + 224 bits + 4 bits address = 232 bits =
|
||||||
// bytes
|
// 29 bytes
|
||||||
char buffer[len];
|
char buffer[len];
|
||||||
memset(buffer, 0, len);
|
memset(buffer, 0, len);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
@ -2065,7 +2297,8 @@ int getADCConfiguration(int chipIndex, int adcIndex) {
|
|||||||
for (int j = adcmin; j < adcmax; ++j) {
|
for (int j = adcmin; j < adcmax; ++j) {
|
||||||
if (adcConfiguration[i][j] != val) {
|
if (adcConfiguration[i][j] != val) {
|
||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
("\tADC configuration 0x%x at [%d][%d] differs from 0x%x "
|
("\tADC configuration 0x%x at [%d][%d] differs from "
|
||||||
|
"0x%x "
|
||||||
"at "
|
"at "
|
||||||
"[%d][%d], returning -1\n",
|
"[%d][%d], returning -1\n",
|
||||||
adcConfiguration[i][j], i, j, val, chipmin, adcmin));
|
adcConfiguration[i][j], i, j, val, chipmin, adcmin));
|
||||||
@ -2114,77 +2347,11 @@ int setBurstMode(enum burstMode burst) {
|
|||||||
? "continuous internal"
|
? "continuous internal"
|
||||||
: "continuous external")))));
|
: "continuous external")))));
|
||||||
|
|
||||||
// update
|
|
||||||
int64_t framesReg = 0;
|
|
||||||
int64_t periodReg = 0;
|
|
||||||
// burst
|
|
||||||
if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
|
|
||||||
framesReg = ((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >>
|
|
||||||
ASIC_INT_FRAMES_OFST);
|
|
||||||
periodReg =
|
|
||||||
get64BitReg(ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
|
|
||||||
// auto
|
|
||||||
if (getTiming() == AUTO_TIMING) {
|
|
||||||
numBurstsReg = get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
|
||||||
burstPeriodReg =
|
|
||||||
get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// continuous
|
|
||||||
else {
|
|
||||||
framesReg = get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
|
||||||
periodReg = get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setBurstModeinFPGA(burst) == FAIL) {
|
if (setBurstModeinFPGA(burst) == FAIL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO, ("\tUpdating registers\n"));
|
updatingRegisters();
|
||||||
// continuous
|
|
||||||
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
|
|
||||||
set64BitReg(framesReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
|
||||||
set64BitReg(periodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
|
||||||
LOG(logINFO, ("\tFrames reg: %lld, Period reg: %lldns\n",
|
|
||||||
getNumFrames(), getPeriod()));
|
|
||||||
|
|
||||||
LOG(logINFO, ("\tInt. Frame reg: 1, Int. Period reg: 0\n"))
|
|
||||||
bus_w(ASIC_INT_FRAMES_REG,
|
|
||||||
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
|
|
||||||
bus_w(ASIC_INT_FRAMES_REG,
|
|
||||||
bus_r(ASIC_INT_FRAMES_REG) |
|
|
||||||
((1 << ASIC_INT_FRAMES_OFST) & ASIC_INT_FRAMES_MSK));
|
|
||||||
set64BitReg(0, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
|
|
||||||
}
|
|
||||||
// burst
|
|
||||||
else {
|
|
||||||
bus_w(ASIC_INT_FRAMES_REG,
|
|
||||||
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
|
|
||||||
bus_w(ASIC_INT_FRAMES_REG,
|
|
||||||
bus_r(ASIC_INT_FRAMES_REG) |
|
|
||||||
(((int)framesReg << ASIC_INT_FRAMES_OFST) &
|
|
||||||
ASIC_INT_FRAMES_MSK));
|
|
||||||
set64BitReg(periodReg, ASIC_INT_PERIOD_LSB_REG,
|
|
||||||
ASIC_INT_PERIOD_MSB_REG);
|
|
||||||
LOG(logINFO, ("\tInt. Frames reg: %lld, Int. Period reg: %lldns\n",
|
|
||||||
getNumFrames(), getPeriod()));
|
|
||||||
|
|
||||||
// trigger
|
|
||||||
if (getTiming() == TRIGGER_EXPOSURE) {
|
|
||||||
LOG(logINFO, ("\tFrame reg: 1, Period reg: 0\n"))
|
|
||||||
set64BitReg(1, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
|
||||||
set64BitReg(0, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
|
||||||
}
|
|
||||||
// auto
|
|
||||||
else {
|
|
||||||
set64BitReg(numBurstsReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
|
||||||
set64BitReg(burstPeriodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
|
||||||
LOG(logINFO, ("\tFrames reg (bursts): %lld, Period reg(burst "
|
|
||||||
"period): %lldns\n",
|
|
||||||
getNumBursts(), getBurstPeriod()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LOG(logINFO, ("\tDone Updating registers\n"))
|
|
||||||
return configureASICGlobalSettings();
|
return configureASICGlobalSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2223,8 +2390,8 @@ int configureASICGlobalSettings() {
|
|||||||
((value >> (ASIC_GLOBAL_SETT_MAX_BITS - 1 - iBit)) & 0x1);
|
((value >> (ASIC_GLOBAL_SETT_MAX_BITS - 1 - iBit)) & 0x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create command for 4 padding + 224 bits + 4 bits address = 232 bits = 29
|
// create command for 4 padding + 224 bits + 4 bits address = 232 bits =
|
||||||
// bytes
|
// 29 bytes
|
||||||
char buffer[len];
|
char buffer[len];
|
||||||
memset(buffer, 0, len);
|
memset(buffer, 0, len);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
@ -2483,7 +2650,13 @@ void *start_timer(void *arg) {
|
|||||||
}
|
}
|
||||||
int repeatPeriodNs = getBurstPeriod();
|
int repeatPeriodNs = getBurstPeriod();
|
||||||
int numFrames = getNumFrames();
|
int numFrames = getNumFrames();
|
||||||
|
// continuous trigger mode, #frames = 1
|
||||||
int64_t periodNs = getPeriod();
|
int64_t periodNs = getPeriod();
|
||||||
|
if (getTiming() == TRIGGER_EXPOSURE && (burstMode == CONTINUOUS_INTERNAL ||
|
||||||
|
burstMode == CONTINUOUS_EXTERNAL)) {
|
||||||
|
numFrames = 1;
|
||||||
|
periodNs = 0;
|
||||||
|
}
|
||||||
int64_t expUs = getExpTime() / 1000;
|
int64_t expUs = getExpTime() / 1000;
|
||||||
int imagesize = NCHAN * NCHIP * 2;
|
int imagesize = NCHAN * NCHIP * 2;
|
||||||
int datasize = imagesize;
|
int datasize = imagesize;
|
||||||
@ -2684,15 +2857,7 @@ void readFrame(int *ret, char *mess) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
*ret = (int)OK;
|
*ret = (int)OK;
|
||||||
// frames left to give status
|
LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
|
||||||
int64_t retval = getNumFramesLeft() + 1;
|
|
||||||
|
|
||||||
if (retval > 0) {
|
|
||||||
LOG(logERROR, ("No data and run stopped: %lld frames left\n",
|
|
||||||
(long long int)retval));
|
|
||||||
} else {
|
|
||||||
LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int32_t runBusy() {
|
u_int32_t runBusy() {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
|
||||||
#define REQRD_FRMWRE_VRSN (0x200707)
|
#define REQRD_FRMWRE_VRSN (0x200707)
|
||||||
|
#define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020"
|
||||||
|
|
||||||
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -18,6 +18,9 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Global variable from slsDetectorServer_funcs
|
||||||
|
extern int debugflag;
|
||||||
|
extern int updateFlag;
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
@ -91,7 +94,8 @@ void basictests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// does check only if flag is 0 (by default), set by command line
|
// does check only if flag is 0 (by default), set by command line
|
||||||
if (((checkType() == FAIL) || (testFpga() == FAIL) ||
|
if ((!debugflag) && (!updateFlag) &&
|
||||||
|
((checkType() == FAIL) || (testFpga() == FAIL) ||
|
||||||
(testBus() == FAIL))) {
|
(testBus() == FAIL))) {
|
||||||
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
||||||
"Dangerous to continue.\n");
|
"Dangerous to continue.\n");
|
||||||
@ -125,7 +129,9 @@ void basictests() {
|
|||||||
(long long int)fwversion, (long long int)swversion,
|
(long long int)fwversion, (long long int)swversion,
|
||||||
(long long int)client_sw_apiversion));
|
(long long int)client_sw_apiversion));
|
||||||
|
|
||||||
LOG(logINFO, ("Basic Tests - success\n"));
|
if (!debugflag || updateFlag) {
|
||||||
|
LOG(logINFO, ("Basic Tests - success\n"));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +349,7 @@ u_int32_t getBoardRevision() {
|
|||||||
/* initialization */
|
/* initialization */
|
||||||
|
|
||||||
void initControlServer() {
|
void initControlServer() {
|
||||||
if (initError == OK) {
|
if (!updateFlag && initError == OK) {
|
||||||
setupDetector();
|
setupDetector();
|
||||||
}
|
}
|
||||||
initCheckDone = 1;
|
initCheckDone = 1;
|
||||||
@ -1029,8 +1035,10 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
|||||||
if (val < 0)
|
if (val < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val,
|
char *dac_names[] = {DAC_NAMES};
|
||||||
(mV ? "mV" : "dac units")));
|
LOG(logINFO, ("Setting DAC %s\n", dac_names[ind]));
|
||||||
|
LOG(logDEBUG1, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind],
|
||||||
|
val, (mV ? "mV" : "dac units")));
|
||||||
int dacval = val;
|
int dacval = val;
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (!mV) {
|
if (!mV) {
|
||||||
|
@ -17,6 +17,10 @@ enum DACINDEX {
|
|||||||
enum CLKINDEX { ADC_CLK, NUM_CLOCKS };
|
enum CLKINDEX { ADC_CLK, NUM_CLOCKS };
|
||||||
#define CLK_NAMES "adc"
|
#define CLK_NAMES "adc"
|
||||||
|
|
||||||
|
#define DAC_NAMES \
|
||||||
|
"vref_ds", "vcascn_pb", "vcascp_pb", "vout_cm", "vcasc_out", "vin_cm", \
|
||||||
|
"vref_comp", "ib_testc"
|
||||||
|
|
||||||
#define DEFAULT_DAC_VALS \
|
#define DEFAULT_DAC_VALS \
|
||||||
{ \
|
{ \
|
||||||
660, /* G_VREF_DS */ \
|
660, /* G_VREF_DS */ \
|
||||||
@ -41,7 +45,7 @@ enum CLKINDEX { ADC_CLK, NUM_CLOCKS };
|
|||||||
#define DYNAMIC_RANGE (16)
|
#define DYNAMIC_RANGE (16)
|
||||||
#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8)
|
#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8)
|
||||||
#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
|
#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
|
||||||
#define CLK_FREQ (32007729) /* Hz */
|
#define CLK_FREQ (32007729) // Hz
|
||||||
#define MAX_EXT_SIGNALS (1)
|
#define MAX_EXT_SIGNALS (1)
|
||||||
|
|
||||||
/** Firmware Definitions */
|
/** Firmware Definitions */
|
||||||
|
Binary file not shown.
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
|
extern int updateFlag;
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
@ -77,8 +78,9 @@ void basictests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// does check only if flag is 0 (by default), set by command line
|
// does check only if flag is 0 (by default), set by command line
|
||||||
if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) ||
|
if ((!debugflag) && (!updateFlag) &&
|
||||||
(testBus() == FAIL))) {
|
((checkType() == FAIL) || (testFpga() == FAIL) ||
|
||||||
|
(testBus() == FAIL))) {
|
||||||
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
||||||
"Dangerous to continue.\n");
|
"Dangerous to continue.\n");
|
||||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
@ -119,7 +121,7 @@ void basictests() {
|
|||||||
(long long int)client_sw_apiversion));
|
(long long int)client_sw_apiversion));
|
||||||
|
|
||||||
// return if flag is not zero, debug mode
|
// return if flag is not zero, debug mode
|
||||||
if (debugflag) {
|
if (debugflag || updateFlag) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +349,7 @@ u_int32_t getDetectorIP() {
|
|||||||
/* initialization */
|
/* initialization */
|
||||||
|
|
||||||
void initControlServer() {
|
void initControlServer() {
|
||||||
if (initError == OK) {
|
if (!updateFlag && initError == OK) {
|
||||||
setupDetector();
|
setupDetector();
|
||||||
}
|
}
|
||||||
initCheckDone = 1;
|
initCheckDone = 1;
|
||||||
@ -841,8 +843,10 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
|||||||
if (val < 0)
|
if (val < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val,
|
char *dac_names[] = {DAC_NAMES};
|
||||||
(mV ? "mV" : "dac units")));
|
LOG(logINFO, ("Setting DAC %s\n", dac_names[ind]));
|
||||||
|
LOG(logDEBUG1, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind],
|
||||||
|
val, (mV ? "mV" : "dac units")));
|
||||||
int dacval = val;
|
int dacval = val;
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (!mV) {
|
if (!mV) {
|
||||||
|
@ -47,6 +47,10 @@ enum DACINDEX {
|
|||||||
J_VREF_DS,
|
J_VREF_DS,
|
||||||
J_VREF_COMP
|
J_VREF_COMP
|
||||||
};
|
};
|
||||||
|
#define DAC_NAMES \
|
||||||
|
"vb_comp", "vdd_prot", "vin_com", "vref_prech", "vb_pixbuf", "vb_ds", \
|
||||||
|
"vref_ds", "vref_comp"
|
||||||
|
|
||||||
#define DEFAULT_DAC_VALS \
|
#define DEFAULT_DAC_VALS \
|
||||||
{ \
|
{ \
|
||||||
1220, /* J_VB_COMP */ \
|
1220, /* J_VB_COMP */ \
|
||||||
@ -69,8 +73,8 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
|
|||||||
#define DYNAMIC_RANGE (16)
|
#define DYNAMIC_RANGE (16)
|
||||||
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
|
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
|
||||||
#define DATA_BYTES (NCHIP * NCHAN * NUM_BYTES_PER_PIXEL)
|
#define DATA_BYTES (NCHIP * NCHAN * NUM_BYTES_PER_PIXEL)
|
||||||
#define CLK_RUN (40) /* MHz */
|
#define CLK_RUN (40) // MHz
|
||||||
#define CLK_SYNC (20) /* MHz */
|
#define CLK_SYNC (20) // MHz
|
||||||
#define ADC_CLK_INDEX (1)
|
#define ADC_CLK_INDEX (1)
|
||||||
#define DBIT_CLK_INDEX (0)
|
#define DBIT_CLK_INDEX (0)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
|
extern int updateFlag;
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
@ -101,8 +102,9 @@ void basictests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// does check only if flag is 0 (by default), set by command line
|
// does check only if flag is 0 (by default), set by command line
|
||||||
if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) ||
|
if ((!debugflag) && (!updateFlag) &&
|
||||||
(testBus() == FAIL))) {
|
((checkType() == FAIL) || (testFpga() == FAIL) ||
|
||||||
|
(testBus() == FAIL))) {
|
||||||
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
||||||
"Dangerous to continue.\n");
|
"Dangerous to continue.\n");
|
||||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
@ -141,7 +143,7 @@ void basictests() {
|
|||||||
(long long int)client_sw_apiversion));
|
(long long int)client_sw_apiversion));
|
||||||
|
|
||||||
// return if flag is not zero, debug mode
|
// return if flag is not zero, debug mode
|
||||||
if (debugflag) {
|
if (debugflag || updateFlag) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +415,7 @@ uint32_t getDetectorIP() {
|
|||||||
/* initialization */
|
/* initialization */
|
||||||
|
|
||||||
void initControlServer() {
|
void initControlServer() {
|
||||||
if (initError == OK) {
|
if (!updateFlag && initError == OK) {
|
||||||
setupDetector();
|
setupDetector();
|
||||||
}
|
}
|
||||||
initCheckDone = 1;
|
initCheckDone = 1;
|
||||||
|
@ -129,6 +129,10 @@
|
|||||||
#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST)
|
#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST)
|
||||||
#define CONTROL_STRT_PATTERN_OFST (2)
|
#define CONTROL_STRT_PATTERN_OFST (2)
|
||||||
#define CONTROL_STRT_PATTERN_MSK (0x00000001 << CONTROL_STRT_PATTERN_OFST)
|
#define CONTROL_STRT_PATTERN_MSK (0x00000001 << CONTROL_STRT_PATTERN_OFST)
|
||||||
|
#define CONTROL_STRT_READOUT_OFST (3) // not connected in software yet
|
||||||
|
#define CONTROL_STRT_READOUT_MSK (0x00000001 << CONTROL_STRT_READOUT_OFST)
|
||||||
|
#define CONTROL_STRT_SW_TRIGGER_OFST (4)
|
||||||
|
#define CONTROL_STRT_SW_TRIGGER_MSK (0x00000001 << CONTROL_STRT_SW_TRIGGER_OFST)
|
||||||
#define CONTROL_CRE_RST_OFST (10)
|
#define CONTROL_CRE_RST_OFST (10)
|
||||||
#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST)
|
#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST)
|
||||||
#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10?
|
#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10?
|
||||||
|
Binary file not shown.
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
|
extern int updateFlag;
|
||||||
extern int checkModuleFlag;
|
extern int checkModuleFlag;
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
@ -80,8 +81,9 @@ void basictests() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// does check only if flag is 0 (by default), set by command line
|
// does check only if flag is 0 (by default), set by command line
|
||||||
if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) ||
|
if ((!debugflag) && (!updateFlag) &&
|
||||||
(testBus() == FAIL))) {
|
((checkKernelVersion() == FAIL) || (checkType() == FAIL) ||
|
||||||
|
(testFpga() == FAIL) || (testBus() == FAIL))) {
|
||||||
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
||||||
"Dangerous to continue.\n");
|
"Dangerous to continue.\n");
|
||||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
@ -117,7 +119,7 @@ void basictests() {
|
|||||||
(long long int)client_sw_apiversion));
|
(long long int)client_sw_apiversion));
|
||||||
|
|
||||||
// return if flag is not zero, debug mode
|
// return if flag is not zero, debug mode
|
||||||
if (debugflag) {
|
if (debugflag || updateFlag) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,6 +163,13 @@ void basictests() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int checkKernelVersion() {
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return OK;
|
||||||
|
#endif
|
||||||
|
return Nios_checkKernelVersion(KERNEL_DATE_VRSN);
|
||||||
|
}
|
||||||
|
|
||||||
int checkType() {
|
int checkType() {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return OK;
|
return OK;
|
||||||
@ -313,7 +322,7 @@ u_int32_t getDetectorIP() {
|
|||||||
/* initialization */
|
/* initialization */
|
||||||
|
|
||||||
void initControlServer() {
|
void initControlServer() {
|
||||||
if (initError == OK) {
|
if (!updateFlag && initError == OK) {
|
||||||
setupDetector();
|
setupDetector();
|
||||||
}
|
}
|
||||||
initCheckDone = 1;
|
initCheckDone = 1;
|
||||||
@ -2297,6 +2306,12 @@ int stopStateMachine() {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int softwareTrigger() {
|
||||||
|
LOG(logINFO, ("Sending Software Trigger\n"));
|
||||||
|
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STRT_SW_TRIGGER_MSK);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
enum runStatus getRunStatus() {
|
enum runStatus getRunStatus() {
|
||||||
LOG(logDEBUG1, ("Getting status\n"));
|
LOG(logDEBUG1, ("Getting status\n"));
|
||||||
// scan error or running
|
// scan error or running
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
|
||||||
#define REQRD_FRMWRE_VRSN 0x190000
|
#define REQRD_FRMWRE_VRSN 0x190000
|
||||||
|
#define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020"
|
||||||
|
|
||||||
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
||||||
|
|
||||||
@ -24,24 +25,26 @@
|
|||||||
#define MAX_EXT_SIGNALS (8)
|
#define MAX_EXT_SIGNALS (8)
|
||||||
|
|
||||||
/** Default Parameters */
|
/** Default Parameters */
|
||||||
#define DEFAULT_PATTERN_FILE ("DefaultPattern_mythen3.txt")
|
#define DEFAULT_PATTERN_FILE ("DefaultPattern_mythen3.txt")
|
||||||
#define DEFAULT_INTERNAL_GATES (1)
|
#define DEFAULT_INTERNAL_GATES (1)
|
||||||
#define DEFAULT_EXTERNAL_GATES (1)
|
#define DEFAULT_EXTERNAL_GATES (1)
|
||||||
#define DEFAULT_DYNAMIC_RANGE (32)
|
#define DEFAULT_DYNAMIC_RANGE (32)
|
||||||
#define DEFAULT_NUM_FRAMES (1)
|
#define DEFAULT_NUM_FRAMES (1)
|
||||||
#define DEFAULT_NUM_CYCLES (1)
|
#define DEFAULT_NUM_CYCLES (1)
|
||||||
#define DEFAULT_GATE_WIDTH (100 * 1000 * 1000) // ns
|
#define DEFAULT_GATE_WIDTH (100 * 1000 * 1000) // ns
|
||||||
#define DEFAULT_GATE_DELAY (0)
|
#define DEFAULT_GATE_DELAY (0)
|
||||||
#define DEFAULT_PERIOD (2 * 1000 * 1000) // ns
|
#define DEFAULT_PERIOD (2 * 1000 * 1000) // ns
|
||||||
#define DEFAULT_DELAY_AFTER_TRIGGER (0)
|
#define DEFAULT_DELAY_AFTER_TRIGGER (0)
|
||||||
#define DEFAULT_HIGH_VOLTAGE (0)
|
#define DEFAULT_HIGH_VOLTAGE (0)
|
||||||
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
|
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
|
||||||
#define DEFAULT_READOUT_C0 (8) //(125000000) // rdo_clk, 125 MHz
|
#define DEFAULT_READOUT_C0 (10) //(100000000) // rdo_clk, 100 MHz
|
||||||
#define DEFAULT_READOUT_C1 (8) //(125000000) // rdo_x2_clk, 125 MHz
|
#define DEFAULT_READOUT_C1 (10) //(100000000) // smp sample clk (x2), 100 MHz
|
||||||
#define DEFAULT_SYSTEM_C0 (4) //(250000000) // run_clk, 250 MHz
|
#define DEFAULT_SYSTEM_C0 (20) // (50000000) // run_clk, 50 MHz
|
||||||
#define DEFAULT_SYSTEM_C1 (8) //(125000000) // sync_clk, 125 MHz
|
#define DEFAULT_SYSTEM_C1 (10) //(100000000) // sync_clk, 100 MHz
|
||||||
#define DEFAULT_SYSTEM_C2 (8) //(125000000) // str_clk, 125 MHz
|
#define DEFAULT_SYSTEM_C2 (10) //(100000000) // str_clk, 100 MHz
|
||||||
#define DEFAULT_SYSTEM_C3 (5) //(200000000) // smp_clk, 200 MHz (only for timing receiver)
|
#define DEFAULT_SYSTEM_C3 (5) //(200000000) // smp_clk, 200 MHz
|
||||||
|
// (DEFAULT_SYSTEM_C3 only for timing receiver) should not be changed
|
||||||
|
|
||||||
#define DEFAULT_ASIC_LATCHING_NUM_PULSES (10)
|
#define DEFAULT_ASIC_LATCHING_NUM_PULSES (10)
|
||||||
#define DEFAULT_MSTR_OTPT_P1_NUM_PULSES (20)
|
#define DEFAULT_MSTR_OTPT_P1_NUM_PULSES (20)
|
||||||
|
|
||||||
@ -110,7 +113,8 @@ enum CLKINDEX {
|
|||||||
NUM_CLOCKS
|
NUM_CLOCKS
|
||||||
};
|
};
|
||||||
#define CLK_NAMES \
|
#define CLK_NAMES \
|
||||||
"READOUT_C0", "READOUT_C1", "SYSTEM_C0", "SYSTEM_C1", "SYSTEM_C2", "SYSTEM_C3"
|
"READOUT_C0", "READOUT_C1", "SYSTEM_C0", "SYSTEM_C1", "SYSTEM_C2", \
|
||||||
|
"SYSTEM_C3"
|
||||||
enum PLLINDEX { READOUT_PLL, SYSTEM_PLL };
|
enum PLLINDEX { READOUT_PLL, SYSTEM_PLL };
|
||||||
|
|
||||||
/* Struct Definitions */
|
/* Struct Definitions */
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a value from a range to a different range (eg voltage to dac or vice
|
* Convert a value from a range to a different range (eg voltage to dac or vice
|
||||||
@ -16,4 +17,6 @@
|
|||||||
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
||||||
int outputMax, int inputValue, int *outputValue);
|
int outputMax, int inputValue, int *outputValue);
|
||||||
|
|
||||||
int getAbsPath(char *buf, size_t bufSize, char *fname);
|
int getAbsPath(char *buf, size_t bufSize, char *fname);
|
||||||
|
|
||||||
|
int GetTimeFromString(char *buf, time_t *result);
|
@ -87,3 +87,7 @@ int mapCSP0(void);
|
|||||||
* Get Nios base address
|
* Get Nios base address
|
||||||
*/
|
*/
|
||||||
u_int32_t *Nios_getBaseAddress();
|
u_int32_t *Nios_getBaseAddress();
|
||||||
|
|
||||||
|
/** check kernel version against expected version string (complain if too old)
|
||||||
|
* @returns OK or FAIL */
|
||||||
|
int Nios_checkKernelVersion(char *expectedVersion);
|
@ -8,8 +8,8 @@ int sharedMemory_open(int port);
|
|||||||
int sharedMemory_attach();
|
int sharedMemory_attach();
|
||||||
int sharedMemory_detach();
|
int sharedMemory_detach();
|
||||||
int sharedMemory_remove();
|
int sharedMemory_remove();
|
||||||
void sharedMemory_lock();
|
void sharedMemory_lockStatus();
|
||||||
void sharedMemory_unlock();
|
void sharedMemory_unlockStatus();
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
void sharedMemory_setStatus(enum runStatus s);
|
void sharedMemory_setStatus(enum runStatus s);
|
||||||
enum runStatus sharedMemory_getStatus();
|
enum runStatus sharedMemory_getStatus();
|
||||||
@ -19,4 +19,8 @@ int sharedMemory_getStop();
|
|||||||
void sharedMemory_setScanStatus(enum runStatus s);
|
void sharedMemory_setScanStatus(enum runStatus s);
|
||||||
enum runStatus sharedMemory_getScanStatus();
|
enum runStatus sharedMemory_getScanStatus();
|
||||||
void sharedMemory_setScanStop(int s);
|
void sharedMemory_setScanStop(int s);
|
||||||
int sharedMemory_getScanStop();
|
int sharedMemory_getScanStop();
|
||||||
|
#ifdef EIGERD
|
||||||
|
void sharedMemory_lockLocalLink();
|
||||||
|
void sharedMemory_unlockLocalLink();
|
||||||
|
#endif
|
@ -56,6 +56,9 @@ typedef struct udpStruct_s {
|
|||||||
int isInitCheckDone();
|
int isInitCheckDone();
|
||||||
int getInitResult(char **mess);
|
int getInitResult(char **mess);
|
||||||
void basictests();
|
void basictests();
|
||||||
|
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||||
|
int checkKernelVersion();
|
||||||
|
#endif
|
||||||
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || \
|
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || \
|
||||||
defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||||
int checkType();
|
int checkType();
|
||||||
@ -264,6 +267,9 @@ int64_t getNumTriggersLeft();
|
|||||||
int64_t getDelayAfterTriggerLeft();
|
int64_t getDelayAfterTriggerLeft();
|
||||||
int64_t getPeriodLeft();
|
int64_t getPeriodLeft();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef GOTTHARD2D
|
||||||
|
int64_t getNumBurstsLeft();
|
||||||
|
#endif
|
||||||
#ifdef GOTTHARDD
|
#ifdef GOTTHARDD
|
||||||
int64_t getExpTimeLeft();
|
int64_t getExpTimeLeft();
|
||||||
#endif
|
#endif
|
||||||
@ -335,6 +341,9 @@ int getADC(enum ADCINDEX ind);
|
|||||||
int setHighVoltage(int val);
|
int setHighVoltage(int val);
|
||||||
|
|
||||||
// parameters - timing, extsig
|
// parameters - timing, extsig
|
||||||
|
#ifdef GOTTHARD2D
|
||||||
|
void updatingRegisters();
|
||||||
|
#endif
|
||||||
void setTiming(enum timingMode arg);
|
void setTiming(enum timingMode arg);
|
||||||
enum timingMode getTiming();
|
enum timingMode getTiming();
|
||||||
#ifdef MYTHEN3D
|
#ifdef MYTHEN3D
|
||||||
@ -554,7 +563,7 @@ int startStateMachine();
|
|||||||
void *start_timer(void *arg);
|
void *start_timer(void *arg);
|
||||||
#endif
|
#endif
|
||||||
int stopStateMachine();
|
int stopStateMachine();
|
||||||
#ifdef EIGERD
|
#if defined(EIGERD) || defined(MYTHEN3D)
|
||||||
int softwareTrigger();
|
int softwareTrigger();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -238,4 +238,5 @@ int set_adc_config(int);
|
|||||||
int get_bad_channels(int);
|
int get_bad_channels(int);
|
||||||
int set_bad_channels(int);
|
int set_bad_channels(int);
|
||||||
int reconfigure_udp(int);
|
int reconfigure_udp(int);
|
||||||
int validate_udp_configuration(int);
|
int validate_udp_configuration(int);
|
||||||
|
int get_bursts_left(int);
|
@ -1,3 +1,4 @@
|
|||||||
|
#define _GNU_SOURCE // needed for strptime to be at the top
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
@ -59,4 +60,13 @@ int getAbsPath(char *buf, size_t bufSize, char *fname) {
|
|||||||
sprintf(buf, "%s/%s", dir, fname);
|
sprintf(buf, "%s/%s", dir, fname);
|
||||||
LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf));
|
LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf));
|
||||||
return OK;
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetTimeFromString(char *buf, time_t *result) {
|
||||||
|
struct tm t;
|
||||||
|
if (NULL == strptime(buf, "%a %b %d %H:%M:%S %Z %Y", &t)) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
*result = mktime(&t);
|
||||||
|
return OK;
|
||||||
}
|
}
|
@ -2,10 +2,13 @@
|
|||||||
#include "RegisterDefs.h"
|
#include "RegisterDefs.h"
|
||||||
#include "ansi.h"
|
#include "ansi.h"
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
|
#include "common.h"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
|
||||||
#include <fcntl.h> // open
|
#include <fcntl.h> // open
|
||||||
#include <sys/mman.h> // mmap
|
#include <string.h>
|
||||||
|
#include <sys/mman.h> // mmap
|
||||||
|
#include <sys/utsname.h> // uname
|
||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
u_int32_t *csp0base = 0;
|
u_int32_t *csp0base = 0;
|
||||||
@ -126,4 +129,50 @@ int mapCSP0(void) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int32_t *Nios_getBaseAddress() { return csp0base; }
|
u_int32_t *Nios_getBaseAddress() { return csp0base; }
|
||||||
|
|
||||||
|
int Nios_checkKernelVersion(char *expectedVersion) {
|
||||||
|
// extract kernel date string
|
||||||
|
struct utsname buf;
|
||||||
|
if (uname(&buf) == -1) {
|
||||||
|
LOG(logERROR, ("Could not get kernel version\n"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove first word (#version number)
|
||||||
|
const char *ptr = strchr(buf.version, ' ');
|
||||||
|
if (ptr == NULL) {
|
||||||
|
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
char output[256];
|
||||||
|
memset(output, 0, 256);
|
||||||
|
strcpy(output, buf.version + (ptr - buf.version + 1));
|
||||||
|
|
||||||
|
// convert kernel date string into time
|
||||||
|
time_t kernelDate;
|
||||||
|
if (GetTimeFromString(output, &kernelDate) == FAIL) {
|
||||||
|
LOG(logERROR, ("Could not parse retrieved kernel date, %s\n", output));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert expected date into time
|
||||||
|
time_t expDate;
|
||||||
|
if (GetTimeFromString(expectedVersion, &expDate) == FAIL) {
|
||||||
|
LOG(logERROR,
|
||||||
|
("Could not parse expected kernel date, %s\n", expectedVersion));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// compare if kernel time is older than expected time
|
||||||
|
if (kernelDate < expDate) {
|
||||||
|
LOG(logERROR, ("Kernel Version Incompatible (too old)! Expected: [%s], "
|
||||||
|
"Got [%s]\n",
|
||||||
|
expectedVersion, output));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(logINFOBLUE, ("Kernel Version Compatible: %s [min.: %s]\n", output,
|
||||||
|
expectedVersion));
|
||||||
|
return OK;
|
||||||
|
}
|
@ -2,20 +2,27 @@
|
|||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <semaphore.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define SHM_NAME "sls_server_shared_memory"
|
#define SHM_NAME "sls_server_shared_memory"
|
||||||
|
#ifdef EIGERD
|
||||||
|
#define SHM_VERSION 0x200915
|
||||||
|
#else
|
||||||
#define SHM_VERSION 0x200625
|
#define SHM_VERSION 0x200625
|
||||||
#define SHM_KEY 5678
|
#endif
|
||||||
#define MEM_SIZE 128
|
#define SHM_KEY 5678
|
||||||
|
#define MEM_SIZE 128
|
||||||
|
|
||||||
typedef struct Memory {
|
typedef struct Memory {
|
||||||
int version;
|
int version;
|
||||||
pthread_mutex_t lock;
|
sem_t semStatus;
|
||||||
|
#ifdef EIGERD
|
||||||
|
sem_t semLocalLink;
|
||||||
|
#endif
|
||||||
enum runStatus scanStatus; // idle, running or error
|
enum runStatus scanStatus; // idle, running or error
|
||||||
int scanStop;
|
int scanStop;
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
@ -80,11 +87,18 @@ int sharedMemory_create(int port) {
|
|||||||
|
|
||||||
int sharedMemory_initialize() {
|
int sharedMemory_initialize() {
|
||||||
shm->version = SHM_VERSION;
|
shm->version = SHM_VERSION;
|
||||||
if (pthread_mutex_init(&(shm->lock), NULL) != 0) {
|
if (sem_init(&(shm->semStatus), 1, 1) != 0) {
|
||||||
LOG(logERROR,
|
LOG(logERROR, ("Failed to initialize semaphore semStatus for "
|
||||||
("Failed to initialize pthread lock for shared memory\n"));
|
"shared memory\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
#ifdef EIGERD
|
||||||
|
if (sem_init(&(shm->semLocalLink), 1, 1) != 0) {
|
||||||
|
LOG(logERROR, ("Failed to initialize semaphore semLocalLink for "
|
||||||
|
"shared memory\n"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
shm->scanStatus = IDLE;
|
shm->scanStatus = IDLE;
|
||||||
shm->scanStop = 0;
|
shm->scanStop = 0;
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
@ -141,64 +155,70 @@ int sharedMemory_remove() {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sharedMemory_lock() { pthread_mutex_lock(&(shm->lock)); }
|
void sharedMemory_lockStatus() { sem_wait(&(shm->semStatus)); }
|
||||||
|
|
||||||
void sharedMemory_unlock() { pthread_mutex_unlock(&(shm->lock)); }
|
void sharedMemory_unlockStatus() { sem_post(&(shm->semStatus)); }
|
||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
void sharedMemory_setStatus(enum runStatus s) {
|
void sharedMemory_setStatus(enum runStatus s) {
|
||||||
sharedMemory_lock();
|
sharedMemory_lockStatus();
|
||||||
shm->status = s;
|
shm->status = s;
|
||||||
sharedMemory_unlock();
|
sharedMemory_unlockStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum runStatus sharedMemory_getStatus() {
|
enum runStatus sharedMemory_getStatus() {
|
||||||
enum runStatus s = 0;
|
enum runStatus s = 0;
|
||||||
sharedMemory_lock();
|
sharedMemory_lockStatus();
|
||||||
s = shm->status;
|
s = shm->status;
|
||||||
sharedMemory_unlock();
|
sharedMemory_unlockStatus();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sharedMemory_setStop(int s) {
|
void sharedMemory_setStop(int s) {
|
||||||
sharedMemory_lock();
|
sharedMemory_lockStatus();
|
||||||
shm->stop = s;
|
shm->stop = s;
|
||||||
sharedMemory_unlock();
|
sharedMemory_unlockStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
int sharedMemory_getStop() {
|
int sharedMemory_getStop() {
|
||||||
int s = 0;
|
int s = 0;
|
||||||
sharedMemory_lock();
|
sharedMemory_lockStatus();
|
||||||
s = shm->stop;
|
s = shm->stop;
|
||||||
sharedMemory_unlock();
|
sharedMemory_unlockStatus();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void sharedMemory_setScanStatus(enum runStatus s) {
|
void sharedMemory_setScanStatus(enum runStatus s) {
|
||||||
sharedMemory_lock();
|
sharedMemory_lockStatus();
|
||||||
shm->scanStatus = s;
|
shm->scanStatus = s;
|
||||||
sharedMemory_unlock();
|
sharedMemory_unlockStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum runStatus sharedMemory_getScanStatus() {
|
enum runStatus sharedMemory_getScanStatus() {
|
||||||
enum runStatus s = IDLE;
|
enum runStatus s = IDLE;
|
||||||
sharedMemory_lock();
|
sharedMemory_lockStatus();
|
||||||
s = shm->scanStatus;
|
s = shm->scanStatus;
|
||||||
sharedMemory_unlock();
|
sharedMemory_unlockStatus();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sharedMemory_setScanStop(int s) {
|
void sharedMemory_setScanStop(int s) {
|
||||||
sharedMemory_lock();
|
sharedMemory_lockStatus();
|
||||||
shm->scanStop = s;
|
shm->scanStop = s;
|
||||||
sharedMemory_unlock();
|
sharedMemory_unlockStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
int sharedMemory_getScanStop() {
|
int sharedMemory_getScanStop() {
|
||||||
int s = 0;
|
int s = 0;
|
||||||
sharedMemory_lock();
|
sharedMemory_lockStatus();
|
||||||
s = shm->scanStop;
|
s = shm->scanStop;
|
||||||
sharedMemory_unlock();
|
sharedMemory_unlockStatus();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EIGERD
|
||||||
|
void sharedMemory_lockLocalLink() { sem_wait(&(shm->semLocalLink)); }
|
||||||
|
|
||||||
|
void sharedMemory_unlockLocalLink() { sem_post(&(shm->semLocalLink)); }
|
||||||
|
#endif
|
@ -21,6 +21,7 @@ extern int ret;
|
|||||||
// Global variables from slsDetectorServer_funcs
|
// Global variables from slsDetectorServer_funcs
|
||||||
extern int sockfd;
|
extern int sockfd;
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
|
extern int updateFlag;
|
||||||
extern int checkModuleFlag;
|
extern int checkModuleFlag;
|
||||||
|
|
||||||
// Global variables from slsDetectorFunctionList
|
// Global variables from slsDetectorFunctionList
|
||||||
@ -41,6 +42,7 @@ int main(int argc, char *argv[]) {
|
|||||||
int portno = DEFAULT_PORTNO;
|
int portno = DEFAULT_PORTNO;
|
||||||
isControlServer = 1;
|
isControlServer = 1;
|
||||||
debugflag = 0;
|
debugflag = 0;
|
||||||
|
updateFlag = 0;
|
||||||
checkModuleFlag = 1;
|
checkModuleFlag = 1;
|
||||||
int version = 0;
|
int version = 0;
|
||||||
|
|
||||||
@ -53,10 +55,12 @@ int main(int argc, char *argv[]) {
|
|||||||
"Possible arguments are:\n"
|
"Possible arguments are:\n"
|
||||||
"\t-v, --version : Software version\n"
|
"\t-v, --version : Software version\n"
|
||||||
"\t-p, --port <port> : TCP communication port with client. \n"
|
"\t-p, --port <port> : TCP communication port with client. \n"
|
||||||
"\t-d, --devel : Developer mode. Skips firmware checks. \n"
|
|
||||||
"\t-g, --nomodule : [Mythen3][Gotthard2] Generic or No "
|
"\t-g, --nomodule : [Mythen3][Gotthard2] Generic or No "
|
||||||
"Module mode. Skips detector type checks. \n"
|
"Module mode. Skips detector type checks. \n"
|
||||||
"\t-f, --phaseshift <value> : [Gotthard] only. Sets phase shift. \n"
|
"\t-f, --phaseshift <value> : [Gotthard] only. Sets phase shift. \n"
|
||||||
|
"\t-d, --devel : Developer mode. Skips firmware checks. \n"
|
||||||
|
"\t-u, --update : Update mode. Skips firmware checks and "
|
||||||
|
"initial detector setup. \n"
|
||||||
"\t-s, --stopserver : Stop server. Do not use as created by "
|
"\t-s, --stopserver : Stop server. Do not use as created by "
|
||||||
"control server \n\n",
|
"control server \n\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
@ -68,9 +72,10 @@ int main(int argc, char *argv[]) {
|
|||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{"port", required_argument, NULL, 'p'},
|
{"port", required_argument, NULL, 'p'},
|
||||||
{"devel", no_argument, NULL, 'd'},
|
|
||||||
{"phaseshift", required_argument, NULL, 'f'},
|
{"phaseshift", required_argument, NULL, 'f'},
|
||||||
{"nomodule", no_argument, NULL, 'g'}, // generic
|
{"nomodule", no_argument, NULL, 'g'}, // generic
|
||||||
|
{"devel", no_argument, NULL, 'd'},
|
||||||
|
{"update", no_argument, NULL, 'u'},
|
||||||
{"stopserver", no_argument, NULL, 's'},
|
{"stopserver", no_argument, NULL, 's'},
|
||||||
{NULL, 0, NULL, 0}};
|
{NULL, 0, NULL, 0}};
|
||||||
|
|
||||||
@ -80,7 +85,7 @@ int main(int argc, char *argv[]) {
|
|||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
while (c != -1) {
|
while (c != -1) {
|
||||||
c = getopt_long(argc, argv, "hvp:df:gs", long_options, &option_index);
|
c = getopt_long(argc, argv, "hvp:f:gdus", long_options, &option_index);
|
||||||
|
|
||||||
// Detect the end of the options
|
// Detect the end of the options
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
@ -116,11 +121,6 @@ int main(int argc, char *argv[]) {
|
|||||||
LOG(logINFO, ("Detected port: %d\n", portno));
|
LOG(logINFO, ("Detected port: %d\n", portno));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
|
||||||
LOG(logINFO, ("Detected developer mode\n"));
|
|
||||||
debugflag = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
#ifndef GOTTHARDD
|
#ifndef GOTTHARDD
|
||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
@ -141,6 +141,16 @@ int main(int argc, char *argv[]) {
|
|||||||
checkModuleFlag = 0;
|
checkModuleFlag = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
LOG(logINFO, ("Detected developer mode\n"));
|
||||||
|
debugflag = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'u':
|
||||||
|
LOG(logINFO, ("Detected update mode\n"));
|
||||||
|
updateFlag = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
LOG(logINFO, ("Detected stop server\n"));
|
LOG(logINFO, ("Detected stop server\n"));
|
||||||
isControlServer = 0;
|
isControlServer = 0;
|
||||||
|
@ -42,6 +42,7 @@ extern char mess[MAX_STR_LENGTH];
|
|||||||
// Variables that will be exported
|
// Variables that will be exported
|
||||||
int sockfd = 0;
|
int sockfd = 0;
|
||||||
int debugflag = 0;
|
int debugflag = 0;
|
||||||
|
int updateFlag = 0;
|
||||||
int checkModuleFlag = 1;
|
int checkModuleFlag = 1;
|
||||||
udpStruct udpDetails = {32410, 32411, 50001, 50002, 0, 0, 0, 0, 0, 0, 0, 0};
|
udpStruct udpDetails = {32410, 32411, 50001, 50002, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
int configured = FAIL;
|
int configured = FAIL;
|
||||||
@ -356,6 +357,7 @@ void function_table() {
|
|||||||
flist[F_SET_BAD_CHANNELS] = &set_bad_channels;
|
flist[F_SET_BAD_CHANNELS] = &set_bad_channels;
|
||||||
flist[F_RECONFIGURE_UDP] = &reconfigure_udp;
|
flist[F_RECONFIGURE_UDP] = &reconfigure_udp;
|
||||||
flist[F_VALIDATE_UDP_CONFIG] = &validate_udp_configuration;
|
flist[F_VALIDATE_UDP_CONFIG] = &validate_udp_configuration;
|
||||||
|
flist[F_GET_BURSTS_LEFT] = &get_bursts_left;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||||
@ -4106,7 +4108,7 @@ int software_trigger(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
LOG(logDEBUG1, ("Software Trigger\n"));
|
LOG(logDEBUG1, ("Software Trigger\n"));
|
||||||
#ifndef EIGERD
|
#if !defined(EIGERD) && !defined(MYTHEN3D)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
// only set
|
// only set
|
||||||
@ -4222,6 +4224,7 @@ int copy_detector_server(int file_des) {
|
|||||||
strcat(cmd, sname);
|
strcat(cmd, sname);
|
||||||
executeCommand(cmd, retvals, logDEBUG1);
|
executeCommand(cmd, retvals, logDEBUG1);
|
||||||
|
|
||||||
|
#if !defined(GOTTHAR2D) && !defined(MYTHEN3D)
|
||||||
// edit /etc/inittab
|
// edit /etc/inittab
|
||||||
// find line numbers in /etc/inittab where DetectorServer
|
// find line numbers in /etc/inittab where DetectorServer
|
||||||
strcpy(cmd, "sed -n '/DetectorServer/=' /etc/inittab");
|
strcpy(cmd, "sed -n '/DetectorServer/=' /etc/inittab");
|
||||||
@ -4246,6 +4249,7 @@ int copy_detector_server(int file_des) {
|
|||||||
executeCommand(cmd, retvals, logDEBUG1);
|
executeCommand(cmd, retvals, logDEBUG1);
|
||||||
|
|
||||||
LOG(logINFO, ("/etc/inittab modified to have %s\n", sname));
|
LOG(logINFO, ("/etc/inittab modified to have %s\n", sname));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -8064,4 +8068,19 @@ int validate_udp_configuration(int file_des) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_bursts_left(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int64_t retval = -1;
|
||||||
|
|
||||||
|
#ifndef GOTTHARD2D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// get only
|
||||||
|
retval = getNumBurstsLeft();
|
||||||
|
LOG(logDEBUG1, ("retval num bursts left %lld\n", (long long int)retval));
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user