Compare commits

..

122 Commits

Author SHA1 Message Date
6c95bf171b Merge branch 'test' into developer 2020-06-05 09:07:42 +02:00
fd948f1a00 updated binaries 2020-06-05 09:06:49 +02:00
ff9811895f WIP 2020-06-05 09:04:32 +02:00
7f6d57d6ba WIP 2020-06-04 17:42:24 +02:00
099805ba8b WIP 2020-06-04 17:02:56 +02:00
1e2a3f2767 WIP 2020-06-04 15:21:53 +02:00
9a8300ca08 WIP 2020-06-04 12:12:40 +02:00
40257fc82d Adds the stripDetector daemon 2020-06-04 11:50:33 +02:00
3bdc8e95ce WIP 2020-06-03 16:10:47 +02:00
223e24f924 WIP 2020-06-03 14:56:24 +02:00
4053594c4d WIP 2020-06-03 14:40:51 +02:00
f07e722d26 read/write reg moved to stop server, tests 2020-06-02 11:56:50 +02:00
2ef8f2f046 WIP 2020-05-29 19:36:41 +02:00
0e514a470d gotthard2 config example 2020-05-29 17:04:54 +02:00
294612b03c WIP 2020-05-29 17:04:10 +02:00
f223415f94 fix for testing 2020-05-29 16:26:57 +02:00
c6ff50d753 merge vetoheader 2020-05-29 10:50:33 +02:00
f0a318777c mythen3 bnaries in 2020-05-28 13:11:32 +02:00
8aa7144252 mythen3: fix of external signals to not allow master output inversion, but can edge detect not configurable, and default dout pulse length 2020-05-28 13:09:09 +02:00
15eea51f12 gotthard2 new firmware veto header reduced to 16 (frames, bunchid) 2020-05-28 12:44:03 +02:00
e884836f5c Merge branch 'vetoheader' of github.com:slsdetectorgroup/slsDetectorPackage into vetoheader 2020-05-28 11:33:59 +02:00
104d91e8c6 more jf stuff 2020-05-28 11:33:52 +02:00
9ddebc4c09 binaries in 2020-05-28 10:36:17 +02:00
0525e374b2 settign veto also configures mac, sending veto data for 10gb only if veto and numinterfaces==2, changed veto entry offset 2020-05-28 10:35:48 +02:00
e727b97d75 gottahrd2 binary in 2020-05-28 09:46:12 +02:00
5ca987ecbb Merge branch 'vetoheader' of github.com:slsdetectorgroup/slsDetectorPackage into vetoheader 2020-05-28 09:44:32 +02:00
2a64a9f6e0 gotthard2: removed check for module attached when setting veto, for later 2020-05-28 09:44:25 +02:00
a708da5455 Merge branch 'vetoheader' of github.com:slsdetectorgroup/slsDetectorPackage into vetoheader 2020-05-28 09:29:02 +02:00
e2eb1598d3 jf stuff 2020-05-28 09:28:53 +02:00
d175ba0936 check for module attached only when enabling veto streaming, not disabling 2020-05-28 09:21:19 +02:00
6189fd157a gotthard2: cehck if module attached when setting veto to 1 2020-05-28 09:19:55 +02:00
6c753f3b50 veto 2020-05-28 08:48:11 +02:00
098d3e6d98 gotthard2: binaries in 2020-05-27 14:39:28 +02:00
4300e95a8e virtual, adding veto command 2020-05-27 14:37:52 +02:00
46daa7e2de merge from developer (mythen3 branch) 2020-05-27 14:19:33 +02:00
754536898a Merge pull request #100 from slsdetectorgroup/mythen3
Mythen3
2020-05-27 14:12:52 +02:00
20bfe92573 gatedelay 2020-05-27 14:02:33 +02:00
9493ae3da9 WIP 2020-05-27 11:30:47 +02:00
0fca9fba79 Merge branch 'mythen3' of github.com:slsdetectorgroup/slsDetectorPackage into mythen3 2020-05-27 11:30:23 +02:00
b543708d9d exptime 2020-05-27 11:30:11 +02:00
e0ea08332f gotthard2: fix in rxr for gotthard2 2020-05-26 17:44:31 +02:00
e229fee6ba gotthard2: hv soft max uptdated to 500v 2020-05-26 14:59:48 +02:00
44a88893ba mythen3: hv soft max uptdated to 500v 2020-05-26 14:58:41 +02:00
f4ba46c19b update function and enum generation 2020-05-26 11:26:24 +02:00
37cb0bb1c0 minor PR fixes 2020-05-26 08:57:48 +02:00
f293ba8c56 gui cmake fix 2020-05-26 08:50:09 +02:00
e9ca17f860 Merge branch 'vetoheader' of github.com:slsdetectorgroup/slsDetectorPackage into vetoheader 2020-05-25 14:23:45 +02:00
30391a2faf veto header size in server using sizeof 2020-05-25 14:23:10 +02:00
7ba877446c gotthard2 binary 2020-05-25 12:21:44 +02:00
6bdc506a34 veto header smaller size 2020-05-25 12:20:40 +02:00
9592d1760f gui fix 2020-05-25 11:09:26 +02:00
8ffb27c300 WIP 2020-05-25 11:05:51 +02:00
0a66605111 tests mainly and minor print 2020-05-22 15:23:56 +02:00
02d8b1fb5f mythen3 binary 2020-05-20 17:30:40 +02:00
457f31ed61 mythen3 server minor print fix 2020-05-20 17:30:07 +02:00
be3f095b56 gui minor fix 2020-05-20 17:27:22 +02:00
174bb32744 gui minor fix 2020-05-20 17:26:57 +02:00
07d90d127f gui fix 2020-05-20 17:25:39 +02:00
0debd6a457 mythen3: auto mode does not ignore #triggers 2020-05-20 17:12:45 +02:00
8f0ef68029 binaries in 2020-05-20 17:07:41 +02:00
d71e40729a external signals 2020-05-20 17:05:42 +02:00
9475e01062 gui done 2020-05-20 12:41:14 +02:00
dc8f67cd7b gui fix 2020-05-20 12:04:48 +02:00
3ebb1fca02 gui WIP 2020-05-20 11:51:18 +02:00
8973ef1aaa from timetest merge 2020-05-20 10:18:51 +02:00
5690914048 Merge branch 'mythen3' of github.com:slsdetectorgroup/slsDetectorPackage into mythen3 2020-05-20 10:15:04 +02:00
fa768e584e rxr 2020-05-20 10:14:57 +02:00
62e69b900b Merge pull request #99 from slsdetectorgroup/timetest
directly writing exptime
2020-05-20 09:56:34 +02:00
30fc346e22 directly writing exptime 2020-05-20 09:47:41 +02:00
761f93d753 exptime of gates 2020-05-20 09:36:43 +02:00
6d71d6cf9f fix with virtual server 2020-05-19 19:11:05 +02:00
e208d3ebe8 WIP 2020-05-19 18:59:07 +02:00
cd90f09a30 WIP 2020-05-19 18:24:32 +02:00
4570ffc8ad Merge branch 'mythen3' of github.com:slsdetectorgroup/slsDetectorPackage into mythen3 2020-05-18 14:36:17 +02:00
a7ce30391c register defs from pattern control to flow control 2020-05-18 14:35:59 +02:00
c33c479ada removed funcs from install 2020-05-18 14:18:12 +02:00
c8eda1a458 mythen binary up 2020-05-15 17:07:27 +02:00
ecc692ad9a start pattern without binaries 2020-05-15 17:06:08 +02:00
00c1211c56 unformatting regdefs 2020-05-15 16:14:57 +02:00
599625e6ed server binaries up 2020-05-15 15:49:59 +02:00
3514b14bc9 servers: removing notification file as this will be done by daemon 2020-05-15 15:48:52 +02:00
395b9f1b72 reordering one function, minor 2020-05-15 13:08:59 +02:00
26dfccf77e binaries compiling, removed inline for c 2020-05-15 13:03:50 +02:00
50d2d21018 fix for virtual servers for rhel7 2020-05-15 12:44:44 +02:00
2c83abcac7 merged detFuncs for c and c++ 2020-05-15 12:24:06 +02:00
ea7cc9db8c less public headers 2020-05-15 10:52:23 +02:00
0dd5a099c8 renamed FixedCap.. to StaticVector 2020-05-15 09:03:23 +02:00
e6deccc2c6 Merge pull request #98 from slsdetectorgroup/gotthard2
Gotthard2
2020-05-14 11:54:09 +02:00
ad42a61bae Merge branch 'developer' into gotthard2 2020-05-14 11:53:59 +02:00
cbc2856c1c rxr should print ip, mac, when set from structure 2020-05-13 18:35:46 +02:00
e34fbb4350 binaries in 2020-05-13 17:55:08 +02:00
eea67014b7 gotthard2 with veto data on second interface 2020-05-13 17:50:18 +02:00
3962714b48 format + exception.cpp 2020-05-13 14:48:52 +02:00
f0f97f265a removed non used slsDetectorUsers 2020-05-13 14:05:05 +02:00
e730c124e3 Merge pull request #97 from slsdetectorgroup/eiger26
Eiger26
2020-05-13 10:47:53 +02:00
f51c4e1d7c c99 2020-05-13 09:41:41 +02:00
a62b650e24 eiger binary in 2020-05-13 09:25:58 +02:00
af4b5bbf50 Pr fix 2020-05-13 09:22:40 +02:00
d8ca9bb6b5 eiger virtual server fix 2020-05-12 13:49:08 +02:00
9a1fdc4104 Merge branch 'developer' into eiger26 2020-05-12 13:43:36 +02:00
b3ebce378d Merge pull request #96 from slsdetectorgroup/rxthrow
More receiver functions throws
2020-05-12 13:42:43 +02:00
46afcfe694 removed logging 2020-05-12 11:49:49 +02:00
d7563fdd1a Merge branch 'developer' into eiger26 2020-05-12 11:39:29 +02:00
ccf1889113 formatting 2020-05-11 20:09:45 +02:00
88f801061f fix for reset 2020-05-11 20:09:09 +02:00
e3d3c88d74 update format 2020-05-11 19:53:50 +02:00
80f4f115f9 updated bianries 2020-05-11 19:53:00 +02:00
9a7d15bbf6 WIP 2020-05-11 19:36:12 +02:00
e148a584df formatting 2020-05-11 19:27:49 +02:00
5aaefc8e00 fix using real detectors, moving readconfig to end (due to initialization) 2020-05-11 19:26:22 +02:00
ed8d606eb2 WIP 2020-05-11 19:19:49 +02:00
eff664e790 cleanup 2020-05-11 18:28:06 +02:00
1ed1b5da86 migrate to return values 2020-05-11 12:15:16 +02:00
353b8d0057 migrate to return values 2020-05-11 11:48:18 +02:00
bbe9108fb9 migrate to return values 2020-05-11 11:39:11 +02:00
1998f9541e reorder read settings func 2020-05-11 10:30:55 +02:00
6620027439 reset to hardware evn if no file 2020-05-08 18:14:59 +02:00
30078d6c1f eiger: deactivate at startup, hostname activates, config file for top or master, if none, reset to hardware, no binaries 2020-05-08 18:11:15 +02:00
13c1f7c2d6 WIP 2020-05-08 16:31:26 +02:00
28bafb012a fixed test for new default values 2020-05-08 15:09:12 +02:00
9c7ff84b73 compiled all servers again 2020-05-08 13:57:23 +02:00
ab5cad4fde formatted servers 2020-05-08 13:56:47 +02:00
122 changed files with 9554 additions and 7143 deletions

View File

@ -45,6 +45,7 @@ option(SLS_USE_CTBGUI "ctb GUI" OFF)
option(SLS_BUILD_DOCS "docs" OFF)
option(SLS_BUILD_EXAMPLES "examples" OFF)
option(SLS_TUNE_LOCAL "tune to local machine" OFF)
option(SLS_DEVEL_HEADERS "install headers for devel" OFF)
# set(ClangFormat_BIN_NAME clang-format)
set(ClangFormat_EXCLUDE_PATTERNS "build/"

View File

@ -0,0 +1,29 @@
hostname strip3
udp_srcip 10.1.1.184
udp_dstip 10.1.1.107
udp_dstport2 50084
udp_srcip2 10.1.1.185
udp_dstip2 10.1.1.107
rx_hostname pc12365:1954
#udp_dstmac 3c:fd:fe:d2:a4:25
fpath /tmp
fname run
fwrite 0
bursts 10
frames 2700
burstperiod 100ms
numinterfaces 2
veto 1
#fixing data looks
# Sampling pipeline 1 clk
reg 0x120 0x00000010
clkphase 1 135 deg

View File

@ -0,0 +1,82 @@
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

View File

@ -0,0 +1,89 @@
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

View File

@ -15,7 +15,7 @@ pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim',
'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'
, 'vcmp_rl', 'vcmp_rr']
, 'vcmp_rl', 'vcmp_rr', 'daclist', 'dacvalues', 'vcal', 'vcas']
missing = []
for c in cmd:

View File

@ -11,6 +11,10 @@ import subprocess
from parse import remove_comments
def single_line_enum(line):
sub = line[line.find('{')+1:line.find('}')]
return sub.strip().split(',')
def extract_enums(lines):
line_iter = iter(lines)
enums = {}
@ -18,19 +22,26 @@ def extract_enums(lines):
m = re.search("(?<=enum )\w+(?= {)", line)
if m:
enum_name = m.group()
# print(enum_name)
print(enum_name)
# print(line)
fields = []
while True:
l = next(line_iter)
if '};' in l:
break
m = re.search("\w+", l)
try:
# print('\t', m.group())
fields.append(m.group())
except:
pass
#deal with single line enums
if '};' in line:
fields = single_line_enum(line)
else:
#deal with multi line enums
while True:
l = next(line_iter)
if '};' in l:
break
m = re.search("\w+", l)
try:
# print('\t', m.group())
fields.append(m.group())
except:
pass
enums[enum_name] = fields
return enums

View File

@ -47,6 +47,8 @@ lines = []
ag2 = []
cn = []
def get_arguments(node):
args = [a.type.spelling for a in node.get_arguments()]
args = [
@ -66,8 +68,12 @@ def get_fdec(node):
else:
return_type = 'void'
if node.is_const_method():
const = 'const'
else:
const = ''
args = ", ".join(args)
args = f'({return_type}(Detector::*)({args}))'
args = f'({return_type}(Detector::*)({args}){const})'
return args
@ -85,6 +91,7 @@ def visit(node):
lines.append(
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
)
cn.append(child)
for child in node.get_children():
visit(child)

View File

@ -3,11 +3,14 @@ from _slsdet import slsDetectorDefs
from _slsdet import IpAddr, MacAddr
runStatus = slsDetectorDefs.runStatus
timingMode = slsDetectorDefs.timingMode
speedLevel = slsDetectorDefs.speedLevel
dacIndex = slsDetectorDefs.dacIndex
detectorType = slsDetectorDefs.detectorType
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
from .utils import Geometry, to_geo, element
from .utils import Geometry, to_geo, element, reduce_time, is_iterable
from . import utils as ut
from .registers import Register, Adc_register
import datetime as dt
@ -15,6 +18,7 @@ from functools import wraps
from collections import namedtuple
import socket
def freeze(cls):
cls._frozen = False
@ -59,15 +63,12 @@ class Detector(CppDetectorApi):
self._register = Register(self)
self._adc_register = Adc_register(self)
# CONFIGURATION
def __len__(self):
return self.size()
def __repr__(self):
return '{}(id = {})'.format(self.__class__.__name__,
self.getShmId())
return "{}(id = {})".format(self.__class__.__name__, self.getShmId())
def free(self):
self.freeSharedMemory()
@ -90,7 +91,6 @@ class Detector(CppDetectorApi):
@property
def hostname(self):
print('getting host!')
return self.getHostname()
@hostname.setter
@ -108,7 +108,7 @@ class Detector(CppDetectorApi):
@property
def server_version(self):
#TODO! handle hex print
# TODO! handle hex print
return element_if_equal(self.getDetectorServerVersion())
@property
@ -129,7 +129,7 @@ class Detector(CppDetectorApi):
@dr.setter
def dr(self, dr):
self.setDynamicRange(dr)
self.setDynamicRange(dr)
@property
def module_geometry(self):
@ -170,62 +170,44 @@ class Detector(CppDetectorApi):
@property
def exptime(self):
res = self.getExptime()
return element_if_equal([it.total_seconds() for it in res])
if self.type == detectorType.MYTHEN3:
res = self.getExptimeForAllGates()
else:
res = self.getExptime()
return reduce_time(res)
@exptime.setter
def exptime(self, t):
if isinstance(t, dt.timedelta):
self.setExptime(t)
else:
self.setExptime(dt.timedelta(seconds=t))
@property
def subexptime(self):
res = self.getSubExptime()
return element_if_equal([it.total_seconds() for it in res])
@subexptime.setter
def subexptime(self, t):
if isinstance(t, dt.timedelta):
self.setSubExptime(t)
else:
self.setSubExptime(dt.timedelta(seconds=t))
@property
def subdeadtime(self):
res = self.getSubDeadTime()
return element_if_equal([it.total_seconds() for it in res])
@subdeadtime.setter
def subdeadtime(self, t):
if isinstance(t, dt.timedelta):
self.setSubDeadTime(t)
else:
self.setSubDeadTime(dt.timedelta(seconds=t))
self.setExptime(ut.make_timedelta(t))
@property
def period(self):
res = self.getPeriod()
return element_if_equal([it.total_seconds() for it in res])
return reduce_time(res)
@period.setter
def period(self, t):
if isinstance(t, dt.timedelta):
self.setPeriod(t)
else:
self.setPeriod(dt.timedelta(seconds=t))
self.setPeriod(ut.make_timedelta(t))
@property
@element
def delay(self):
return ut.reduce_time(self.getDelayAfterTrigger())
@delay.setter
def delay(self, t):
self.setDelayAfterTrigger(ut.make_timedelta(t))
@property
@element
def delayl(self):
return ut.reduce_time(self.getDelayAfterTriggerLeft())
# Time
@property
def rx_framescaught(self):
return element_if_equal(self.getFramesCaught())
@property
def startingfnum(self):
@ -234,10 +216,7 @@ class Detector(CppDetectorApi):
@startingfnum.setter
def startingfnum(self, value):
self.setStartingFrameNumber(value)
#TODO! add txdelay
# TODO! add txdelay
@property
def use_receiver(self):
@ -303,14 +282,21 @@ class Detector(CppDetectorApi):
@property
def rx_lastclient(self):
return element_if_equal(self.getRxLastClientIP())
# FILE
@property
@element
def numinterfaces(self):
return self.getNumberofUDPInterfaces()
#FILE
@numinterfaces.setter
def numinterfaces(self, value):
self.setNumberofUDPInterfaces(value)
@property
def fformat(self):
return element_if_equal(self.getFileFormat())
@fformat.setter
def fformat(self, format):
self.setFileFormat(format)
@ -421,14 +407,13 @@ class Detector(CppDetectorApi):
def zmqip(self, ip):
self.setClientZmqIp(ip)
@property
def udp_dstip(self):
return element_if_equal(self.getDestinationUDPIP())
@udp_dstip.setter
def udp_dstip(self, ip):
if ip == 'auto':
if ip == "auto":
ip = socket.gethostbyname(self.rx_hostname)
self.setDestinationUDPIP(IpAddr(ip))
@ -438,7 +423,7 @@ class Detector(CppDetectorApi):
@udp_dstip2.setter
def udp_dstip2(self, ip):
if ip == 'auto':
if ip == "auto":
ip = socket.gethostbyname(self.rx_hostname)
self.setDestinationUDPIP2(IpAddr(ip))
@ -458,7 +443,6 @@ class Detector(CppDetectorApi):
def udp_dstmac2(self, mac):
self.setDestinationUDPMAC2(MacAddr(mac))
@property
def udp_srcip(self):
return element_if_equal(self.getSourceUDPIP())
@ -515,7 +499,6 @@ class Detector(CppDetectorApi):
def src_udpip(self, ip):
self.setSourceUDPIP(IpAddr(ip))
@property
def src_udpmac2(self):
return element_if_equal(self.getSourceUDPMAC2())
@ -552,8 +535,6 @@ class Detector(CppDetectorApi):
def rx_status(self):
return element_if_equal(self.getReceiverStatus())
@property
def rx_udpsocksize(self):
return element_if_equal(self.getRxUDPSocketBufferSize())
@ -568,7 +549,7 @@ class Detector(CppDetectorApi):
@property
def trimbits(self):
return NotImplementedError('trimbits are set only')
return NotImplementedError("trimbits are set only")
@trimbits.setter
def trimbits(self, fname):
@ -602,7 +583,6 @@ class Detector(CppDetectorApi):
def adcreg(self):
return self._adc_register
@property
def led(self):
return element_if_equal(self.getLEDEnable())
@ -643,11 +623,11 @@ class Detector(CppDetectorApi):
@property
def timing(self):
return element_if_equal(self.getTimingMode())
return element_if_equal(self.getTimingMode())
@timing.setter
def timing(self, mode):
self.setTimingMode(mode)
self.setTimingMode(mode)
@property
def trimen(self):
@ -661,8 +641,6 @@ class Detector(CppDetectorApi):
def vthreshold(self):
return element_if_equal(self.getDAC(dacIndex.THRESHOLD))
@property
def type(self):
return element_if_equal(self.getDetectorType())
@ -675,10 +653,27 @@ class Detector(CppDetectorApi):
def rx_missingpackets(self):
return element_if_equal(self.getNumMissingPackets())
"""
Some Eiger stuff, does this have to be here or can we move it to subclass?
"""
@property
def subexptime(self):
res = self.getSubExptime()
return reduce_time(res)
@subexptime.setter
def subexptime(self, t):
self.setSubExptime(ut.make_timedelta(t))
@property
def subdeadtime(self):
res = self.getSubDeadTime()
reduce_time(res)
@subdeadtime.setter
def subdeadtime(self, t):
self.setSubDeadTime(ut.make_timedelta(t))
@property
def partialreset(self):
return element_if_equal(self.getPartialReset())
@ -690,7 +685,7 @@ class Detector(CppDetectorApi):
@property
def tengiga(self):
return element_if_equal(self.getTenGiga())
@tengiga.setter
def tengiga(self, value):
self.setTenGiga(value)
@ -737,7 +732,6 @@ class Detector(CppDetectorApi):
res = self.getMeasuredSubFramePeriod()
return element_if_equal([it.total_seconds() for it in res])
@property
def storeinram(self):
return element_if_equal(self.getStoreInRamMode())
@ -746,11 +740,116 @@ class Detector(CppDetectorApi):
def storeinram(self, value):
self.setStoreInRamMode(value)
"""
Jungfrau specific
"""
@property
@element
def auto_comp_disable(self):
return self.getAutoCompDisable()
@auto_comp_disable.setter
def auto_comp_disable(self, value):
self.setAutoCompDisable(value)
@property
@element
def storagecells(self):
return self.getNumberOfAdditionalStorageCells()
@storagecells.setter
def storagecells(self, n_cells):
self.setNumberOfAdditionalStorageCells(n_cells)
@property
@element
def storagecell_start(self):
return self.getStorageCellStart()
@storagecell_start.setter
def storagecell_start(self, value):
self.setStorageCellStart(value)
@property
@element
def storagecell_delay(self):
return ut.reduce_time(self.getStorageCellDelay())
@storagecell_delay.setter
def storagecell_delay(self, t):
self.setStorageCellDelay(ut.make_timedelta(t))
@property
@element
def temp_threshold(self):
return self.getThresholdTemperature()
@temp_threshold.setter
def temp_threshold(self, value):
self.setThresholdTemperature(value)
@property
@element
def temp_event(self):
return self.getTemperatureEvent()
@temp_event.setter
def temp_event(self, value):
if value != 0:
raise ValueError("Value needs to be 0 for reset. Setting not allowed")
self.resetTemperatureEvent()
@property
@element
def temp_control(self):
return self.getTemperatureControl()
@temp_control.setter
def temp_control(self, value):
self.setTemperatureControl(value)
@property
@element
def selinterface(self):
return self.getSelectedUDPInterface()
@selinterface.setter
def selinterface(self, i):
self.selectUDPInterface(i)
"""
Gotthard2
"""
@property
@element
def veto(self):
return self.getVeto()
@veto.setter
def veto(self, value):
self.setVeto(value)
"""
Mythen3 specific
"""
@property
def gatedelay(self):
return reduce_time(self.getGateDelayForAllGates())
@gatedelay.setter
def gatedelay(self, value):
if is_iterable(value):
if len(value) == 3:
for i, v in enumerate(value):
self.setGateDelay(i, ut.make_timedelta(v))
else:
self.setGateDelay(-1, ut.make_timedelta(value))
@property
def counters(self):
mask = self.getCounterMask()
@ -760,11 +859,10 @@ class Detector(CppDetectorApi):
else:
return [get_set_bits(m) for m in mask]
@counters.setter
def counters(self, values):
self.setCounterMask(list_to_bitmask(values))
"""
CTB stuff
"""
@ -812,7 +910,7 @@ class Detector(CppDetectorApi):
@property
def dbitclk(self):
return element_if_equal(self.getDBITClock())
@dbitclk.setter
def dbitclk(self, value):
self.setDBITClock(value)
@ -852,7 +950,7 @@ class Detector(CppDetectorApi):
@property
def adcphase(self):
return element_if_equal(self.getADCPhase())
@adcphase.setter
def adcphase(self, value):
self.setADCPhase(value)
@ -876,10 +974,10 @@ class Detector(CppDetectorApi):
@property
def syncclk(self):
return element_if_equal(self.getSYNCClock())
@property
def pattern(self):
#TODO! Clean fix
# TODO! Clean fix
print("Set only")
return 0
@ -968,7 +1066,6 @@ class Detector(CppDetectorApi):
def patwaittime2(self, nclk):
self.setPatternWaitTime(2, nclk)
@property
def patloop0(self):
return element_if_equal(self.getPatternLoopAddresses(0))
@ -1017,7 +1114,6 @@ class Detector(CppDetectorApi):
def patnloop2(self, n):
self.setPatternLoopCycles(2, n)
@property
@element
def v_a(self):
@ -1095,4 +1191,4 @@ class Detector(CppDetectorApi):
@property
@element
def im_io(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)

View File

@ -7,10 +7,17 @@ but not directly used in controlling the detector
from collections import namedtuple
import _slsdet #C++ lib
import functools
import datetime as dt
Geometry = namedtuple('Geometry', ['x', 'y'])
def is_iterable(item):
try:
iter(item)
except TypeError:
return False
return True
def get_set_bits(mask):
"""
Return a list of the set bits in a python integer
@ -41,6 +48,9 @@ def all_equal(mylist):
def element_if_equal(mylist):
"""If all elements are equal return only one element"""
if not is_iterable(mylist):
return mylist
if all_equal(mylist):
if len(mylist) == 0:
return None
@ -49,6 +59,15 @@ def element_if_equal(mylist):
else:
return mylist
def reduce_time(mylist):
res = element_if_equal(element_if_equal(mylist))
if isinstance(res, dt.timedelta):
return res.total_seconds()
elif isinstance(res[0], list):
return [[item.total_seconds() for item in subl] for subl in res]
else:
return [r.total_seconds() for r in res]
def element(func):
"""
Wrapper to return either list or element
@ -69,3 +88,8 @@ def eiger_register_to_time(register):
exponent = register & 0b111
return clocks*10**exponent / 100e6
def make_timedelta(t):
if isinstance(t, dt.timedelta):
return t
else:
return dt.timedelta(seconds=t)

File diff suppressed because it is too large Load Diff

View File

@ -8,12 +8,17 @@
#include "network_utils.h"
#include "sls_detector_defs.h"
#include "typecaster.h"
#include "TimeHelper.h"
#include <array>
#include <chrono>
namespace py = pybind11;
void init_det(py::module &m) {
using sls::Detector;
using sls::Positions;
using sls::Result;
using sls::defs;
using sls::ns;
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
CppDetectorApi

View File

@ -65,38 +65,14 @@ void init_enums(py::module &m) {
.export_values();
py::enum_<slsDetectorDefs::externalSignalFlag>(Defs, "externalSignalFlag")
.value("GET_EXTERNAL_SIGNAL_FLAG",
slsDetectorDefs::externalSignalFlag::GET_EXTERNAL_SIGNAL_FLAG)
.value("SIGNAL_OFF", slsDetectorDefs::externalSignalFlag::SIGNAL_OFF)
.value("GATE_IN_ACTIVE_HIGH",
slsDetectorDefs::externalSignalFlag::GATE_IN_ACTIVE_HIGH)
.value("GATE_IN_ACTIVE_LOW",
slsDetectorDefs::externalSignalFlag::GATE_IN_ACTIVE_LOW)
.value("TRIGGER_IN_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_IN_RISING_EDGE)
.value("TRIGGER_IN_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_IN_FALLING_EDGE)
.value("RO_TRIGGER_IN_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_IN_RISING_EDGE)
.value("RO_TRIGGER_IN_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_IN_FALLING_EDGE)
.value("GATE_OUT_ACTIVE_HIGH",
slsDetectorDefs::externalSignalFlag::GATE_OUT_ACTIVE_HIGH)
.value("GATE_OUT_ACTIVE_LOW",
slsDetectorDefs::externalSignalFlag::GATE_OUT_ACTIVE_LOW)
.value("TRIGGER_OUT_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_OUT_RISING_EDGE)
.value("TRIGGER_OUT_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_OUT_FALLING_EDGE)
.value("RO_TRIGGER_OUT_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_OUT_RISING_EDGE)
.value("RO_TRIGGER_OUT_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_OUT_FALLING_EDGE)
.value("OUTPUT_LOW", slsDetectorDefs::externalSignalFlag::OUTPUT_LOW)
.value("OUTPUT_HIGH", slsDetectorDefs::externalSignalFlag::OUTPUT_HIGH)
.value(
"MASTER_SLAVE_SYNCHRONIZATION",
slsDetectorDefs::externalSignalFlag::MASTER_SLAVE_SYNCHRONIZATION)
.value("INVERSION_ON",
slsDetectorDefs::externalSignalFlag::INVERSION_ON)
.value("INVERSION_OFF",
slsDetectorDefs::externalSignalFlag::INVERSION_OFF)
.export_values();
py::enum_<slsDetectorDefs::timingMode>(Defs, "timingMode")
@ -106,6 +82,9 @@ void init_enums(py::module &m) {
slsDetectorDefs::timingMode::TRIGGER_EXPOSURE)
.value("GATED", slsDetectorDefs::timingMode::GATED)
.value("BURST_TRIGGER", slsDetectorDefs::timingMode::BURST_TRIGGER)
.value("TRIGGER_GATED", slsDetectorDefs::timingMode::TRIGGER_GATED)
.value("NUM_TIMING_MODES",
slsDetectorDefs::timingMode::NUM_TIMING_MODES)
.export_values();
py::enum_<slsDetectorDefs::dacIndex>(Defs, "dacIndex")
@ -248,22 +227,22 @@ void init_enums(py::module &m) {
py::enum_<slsDetectorDefs::clockIndex>(Defs, "clockIndex")
.value("ADC_CLOCK", slsDetectorDefs::clockIndex::ADC_CLOCK)
.value("DBIT_CLOCK", slsDetectorDefs::clockIndex::DBIT_CLOCK)
.value("RUN_CLOCK", slsDetectorDefs::clockIndex::RUN_CLOCK)
.value("SYNC_CLOCK", slsDetectorDefs::clockIndex::SYNC_CLOCK)
.value(" DBIT_CLOCK", slsDetectorDefs::clockIndex::DBIT_CLOCK)
.value(" RUN_CLOCK", slsDetectorDefs::clockIndex::RUN_CLOCK)
.value(" SYNC_CLOCK", slsDetectorDefs::clockIndex::SYNC_CLOCK)
.export_values();
py::enum_<slsDetectorDefs::readoutMode>(Defs, "readoutMode")
.value("ANALOG_ONLY", slsDetectorDefs::readoutMode::ANALOG_ONLY)
.value("DIGITAL_ONLY", slsDetectorDefs::readoutMode::DIGITAL_ONLY)
.value("ANALOG_AND_DIGITAL",
.value(" DIGITAL_ONLY", slsDetectorDefs::readoutMode::DIGITAL_ONLY)
.value(" ANALOG_AND_DIGITAL",
slsDetectorDefs::readoutMode::ANALOG_AND_DIGITAL)
.export_values();
py::enum_<slsDetectorDefs::speedLevel>(Defs, "speedLevel")
.value("FULL_SPEED", slsDetectorDefs::speedLevel::FULL_SPEED)
.value("HALF_SPEED", slsDetectorDefs::speedLevel::HALF_SPEED)
.value("QUARTER_SPEED", slsDetectorDefs::speedLevel::QUARTER_SPEED)
.value(" HALF_SPEED", slsDetectorDefs::speedLevel::HALF_SPEED)
.value(" QUARTER_SPEED", slsDetectorDefs::speedLevel::QUARTER_SPEED)
.export_values();
py::enum_<slsDetectorDefs::portType>(Defs, "portType")
@ -300,12 +279,13 @@ void init_enums(py::module &m) {
.value("BURST_OFF", slsDetectorDefs::burstMode::BURST_OFF)
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)
.value("NUM_BURST_MODES", slsDetectorDefs::burstMode::NUM_BURST_MODES)
.export_values();
py::enum_<slsDetectorDefs::timingSourceType>(Defs, "timingSourceType")
.value("TIMING_INTERNAL",
slsDetectorDefs::timingSourceType::TIMING_INTERNAL)
.value("TIMING_EXTERNAL",
.value(" TIMING_EXTERNAL",
slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
.export_values();
}

View File

@ -5,7 +5,28 @@ Testing functions from utils.py
"""
import pytest
from sls_detector.utils import *
from slsdet.utils import *
import datetime as dt
def test_iterable():
assert is_iterable(5) == False
assert is_iterable('abc') == True
assert is_iterable([]) == True
assert is_iterable(5.9) == False
def test_reduce_time_to_single_value_from_list():
t = 3*[dt.timedelta(seconds = 1)]
assert reduce_time(t) == 1
def test_reduce_time_to_single_value_from_list_of_lists():
t = 3*[dt.timedelta(seconds = 3.3)]
tt = 5*t
assert reduce_time(tt) == 3.3
def test_reduce_time_when_sublist_is_different():
t = [dt.timedelta(seconds = 1), dt.timedelta(seconds = 2), dt.timedelta(seconds = 1)]
tt = [t for i in range(4)]
assert reduce_time(tt) == [1,2,1]
def test_convert_zero():
@ -59,4 +80,17 @@ def test_list_to_mask():
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)
assert(list_to_bitmask([1,1,1]) == 2)
def test_make_timedelta_from_double():
t = 1.7
r = make_timedelta(t)
assert t == r.total_seconds()
assert r == dt.timedelta(seconds=t)
def test_make_timedelta_from_timedelta():
t = dt.timedelta(minutes=1)
r = make_timedelta(t)
assert 60 == r.total_seconds()
assert r == dt.timedelta(minutes=1)

Binary file not shown.

View File

@ -88,6 +88,7 @@ target_include_directories(slsDetectorGui PUBLIC
)
target_link_libraries(slsDetectorGui PUBLIC
slsProjectWarnings
slsDetectorShared
${QT_QTCORE_LIBRARIES}
${QT_QTGUI_LIBRARIES}

View File

@ -1066,239 +1066,6 @@
<string>Acquisition</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="1" column="4">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblNumStoragecells">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of additional storage cells. For Jungfrau only. &lt;/p&gt;&lt;p&gt;Default: 0. &lt;/p&gt;&lt;p&gt;Number of Images received: #frames * #triggers * (#storagecells+1) &lt;/p&gt;&lt;p&gt; #storagecells#&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Storage cells:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2" colspan="2">
<widget class="QSpinBox" name="spinNumStoragecells">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of additional storage cells. For Jungfrau only. &lt;/p&gt;&lt;p&gt;Default: 0. &lt;/p&gt;&lt;p&gt;Number of Images received: #frames * #triggers * (#storagecells+1) &lt;/p&gt;&lt;p&gt; #storagecells#&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>15</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="spinSubExpTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Exposure Time of a sub frame. Only for Eiger in 32 bit mode
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
#subexptime#
&lt;/nobr&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblSubDeadTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Dead time between sub frames. Only for Eiger in 32 bit mode.
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
Default value is 0. A value less than the required minimum is ignored.
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
#subdeadtime#
&lt;/nobr&gt;</string>
</property>
<property name="text">
<string>Sub Frame Dead Time:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="spinSubDeadTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Period between sub frames. Only for Eiger in 32 bit mode.
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
Default value is 0. A value less than the required minimum is ignored.
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
#subperiod#
&lt;/nobr&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblSubExpTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Exposure Time of a sub frame. Only for Eiger in 32 bit mode
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
#subexptime#
&lt;/nobr&gt;</string>
</property>
<property name="text">
<string>Sub Frame Exposure Time:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QComboBox" name="comboSubDeadTimeUnit">
<property name="enabled">
@ -1425,6 +1192,98 @@ Exposure Time of a sub frame. Only for Eiger in 32 bit mode
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblNumStoragecells">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of additional storage cells. For Jungfrau only. &lt;/p&gt;&lt;p&gt;Default: 0. &lt;/p&gt;&lt;p&gt;Number of Images received: #frames * #triggers * (#storagecells+1) &lt;/p&gt;&lt;p&gt; #storagecells#&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Storage cells:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="spinSubDeadTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Period between sub frames. Only for Eiger in 32 bit mode.
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
Default value is 0. A value less than the required minimum is ignored.
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
#subperiod#
&lt;/nobr&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblSubExpTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Exposure Time of a sub frame. Only for Eiger in 32 bit mode
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
#subexptime#
&lt;/nobr&gt;</string>
</property>
<property name="text">
<string>Sub Frame Exposure Time:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblDiscardBits">
<property name="enabled">
@ -1490,6 +1349,428 @@ Default value is 0. A value less than the required minimum is ignored.
</property>
</widget>
</item>
<item row="1" column="4">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2" colspan="2">
<widget class="QSpinBox" name="spinNumStoragecells">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of additional storage cells. For Jungfrau only. &lt;/p&gt;&lt;p&gt;Default: 0. &lt;/p&gt;&lt;p&gt;Number of Images received: #frames * #triggers * (#storagecells+1) &lt;/p&gt;&lt;p&gt; #storagecells#&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>15</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="spinSubExpTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Exposure Time of a sub frame. Only for Eiger in 32 bit mode
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
#subexptime#
&lt;/nobr&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblSubDeadTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Dead time between sub frames. Only for Eiger in 32 bit mode.
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
Default value is 0. A value less than the required minimum is ignored.
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
#subdeadtime#
&lt;/nobr&gt;</string>
</property>
<property name="text">
<string>Sub Frame Dead Time:</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QComboBox" name="comboExpTimeUnit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Exposure Time of a corresonding gate signal index. &lt;br/&gt;#exptime1# &lt;/p&gt;&lt;p&gt;#exptime2#&lt;/p&gt;&lt;p&gt;#exptime3#  &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>hr</string>
</property>
</item>
<item>
<property name="text">
<string>min</string>
</property>
</item>
<item>
<property name="text">
<string>s</string>
</property>
</item>
<item>
<property name="text">
<string>ms</string>
</property>
</item>
<item>
<property name="text">
<string>us</string>
</property>
</item>
<item>
<property name="text">
<string>ns</string>
</property>
</item>
</widget>
</item>
<item row="5" column="2">
<widget class="QDoubleSpinBox" name="spinExpTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Exposure Time of a corresonding gate signal index. &lt;br/&gt;#exptime1# &lt;/p&gt;&lt;p&gt;#exptime2#&lt;/p&gt;&lt;p&gt;#exptime3# &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QSpinBox" name="spinGateIndex">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Gate index. It will get exposure time and gate delay for corresponding gate signal.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>3</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lblGateDelay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of additional storage cells. For Jungfrau only. &lt;/p&gt;&lt;p&gt;Default: 0. &lt;/p&gt;&lt;p&gt;Number of Images received: #frames * #triggers * (#storagecells+1) &lt;/p&gt;&lt;p&gt; #storagecells#&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Gate Delay:</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QDoubleSpinBox" name="spinGateDelay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Gate Delay of a corresonding gate signal index. &lt;br/&gt;#gatedelay1# &lt;/p&gt;&lt;p&gt;#gatedelay2#&lt;/p&gt;&lt;p&gt;#gatedelay3#  &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QComboBox" name="comboGateDelayUnit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Gate Delay of a corresonding gate signal index. &lt;br/&gt;#gatedelay1# &lt;/p&gt;&lt;p&gt;#gatedelay2#&lt;/p&gt;&lt;p&gt;#gatedelay3#  &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>hr</string>
</property>
</item>
<item>
<property name="text">
<string>min</string>
</property>
</item>
<item>
<property name="text">
<string>s</string>
</property>
</item>
<item>
<property name="text">
<string>ms</string>
</property>
</item>
<item>
<property name="text">
<string>us</string>
</property>
</item>
<item>
<property name="text">
<string>ns</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lblExpTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of additional storage cells. For Jungfrau only. &lt;/p&gt;&lt;p&gt;Default: 0. &lt;/p&gt;&lt;p&gt;Number of Images received: #frames * #triggers * (#storagecells+1) &lt;/p&gt;&lt;p&gt; #storagecells#&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Expososure Time:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lblGateIndex">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of additional storage cells. For Jungfrau only. &lt;/p&gt;&lt;p&gt;Default: 0. &lt;/p&gt;&lt;p&gt;Number of Images received: #frames * #triggers * (#storagecells+1) &lt;/p&gt;&lt;p&gt; #storagecells#&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Gate Index:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>

View File

@ -409,7 +409,7 @@
<widget class="QFrame" name="frameTimeResolved">
<property name="minimumSize">
<size>
<width>400</width>
<width>410</width>
<height>0</height>
</size>
</property>
@ -432,6 +432,77 @@
<property name="verticalSpacing">
<number>4</number>
</property>
<item row="5" column="0">
<widget class="QStackedWidget" name="stackedLblTriggerBurst">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageLblTrigger">
<layout class="QGridLayout" name="gridLblTrigger">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblNumTriggers">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Triggers:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageLblBurst">
<layout class="QGridLayout" name="gridLblBurst">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblNumBursts">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Bursts:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="4" column="3">
<widget class="QComboBox" name="comboPeriodUnit">
<property name="enabled">
@ -501,53 +572,6 @@ Frame period between exposures.
</property>
</widget>
</item>
<item row="7" column="2" colspan="2">
<widget class="QSpinBox" name="spinNumSamples">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>Number of Triggers to be expected.
#triggers#</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QSpinBox" name="spinNumMeasurements">
<property name="sizePolicy">
@ -594,25 +618,17 @@ Frame period between exposures.
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="minimumSize">
<size>
<width>175</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Number of Measurements:</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="lblNumSamples">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Number of Triggers to be expected.
#triggers#</string>
</property>
<property name="text">
<string>Number of Samples:</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QComboBox" name="comboTimingMode">
<property name="sizePolicy">
@ -651,6 +667,11 @@ Frame period between exposures.
<string>Burst Trigger</string>
</property>
</item>
<item>
<property name="text">
<string>Trigger Gated</string>
</property>
</item>
</widget>
</item>
<item row="3" column="2">
@ -910,77 +931,6 @@ Frame period between exposures.
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QStackedWidget" name="stackedLblTriggerBurst">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageLblTrigger">
<layout class="QGridLayout" name="gridLblTrigger">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblNumTriggers">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Triggers:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageLblBurst">
<layout class="QGridLayout" name="gridLblBurst">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblNumBursts">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Bursts:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="5" column="2">
<widget class="QStackedWidget" name="stackedSpinTriggerBurst">
<property name="sizePolicy">
@ -1481,6 +1431,214 @@ Frame period between exposures.
</widget>
</widget>
</item>
<item row="7" column="0">
<widget class="QStackedWidget" name="stackedLblSamplesGates">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageLblSamples">
<layout class="QGridLayout" name="gridLblTrigger_2">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblNumSamples">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of analog samples.&lt;/p&gt;&lt;p&gt;#asamples#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Samples:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageLblGates">
<layout class="QGridLayout" name="gridLblBurst_2">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblNumGates">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of external gates.&lt;/p&gt;&lt;p&gt;#gates#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Gates:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="7" column="2">
<widget class="QStackedWidget" name="stackedSpinSamplesGates">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>208</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>208</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageSpinSamples">
<layout class="QGridLayout" name="gridSpinTrigger_2">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QSpinBox" name="spinNumSamples">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of analog samples.&lt;/p&gt;&lt;p&gt;#asamples#&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageSpinGates">
<layout class="QGridLayout" name="gridSpinBurst_2">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QSpinBox" name="spinNumGates">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of external gates.&lt;/p&gt;&lt;p&gt;#gates#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
@ -1513,7 +1671,6 @@ Frame period between exposures.
<tabstop>comboExpUnit</tabstop>
<tabstop>spinPeriod</tabstop>
<tabstop>comboPeriodUnit</tabstop>
<tabstop>spinNumSamples</tabstop>
</tabstops>
<resources>
<include location="../include/icons.qrc"/>

View File

@ -1,5 +1,6 @@
#pragma once
#include "logger.h"
#include "sls_detector_defs.h"
#include <QAbstractButton>

View File

@ -36,6 +36,9 @@ class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject {
void SetNumStoragecells(int value);
void SetSubExposureTime();
void SetSubDeadTime();
void SetGateIndex(int value);
void SetExposureTime();
void SetGateDelay();
private:
void SetupWidgetWindow();
@ -59,6 +62,8 @@ class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject {
void GetNumStoragecells();
void GetSubExposureTime();
void GetSubDeadTime();
void GetExposureTime();
void GetGateDelay();
sls::Detector *det;
qDrawPlot *plot;

View File

@ -25,6 +25,7 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
void SetNumTriggers(int val);
void SetNumBursts(int val);
void SetNumSamples(int val);
void SetNumGates(int val);
void SetExposureTime();
void SetAcquisitionPeriod();
void SetDelay();
@ -45,6 +46,7 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
* show bursts and burst period
*/
void ShowTriggerDelay();
void ShowGates();
void SetupTimingMode();
void EnableWidgetsforTimingMode();
@ -53,6 +55,7 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
void GetNumTriggers();
void GetNumBursts();
void GetNumSamples();
void GetNumGates();
void GetExposureTime();
void GetAcquisitionPeriod();
void CheckAcqPeriodGreaterThanExp();
@ -76,7 +79,7 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
sls::Detector *det;
qDrawPlot *plot;
// enum for the timing mode
enum { AUTO, TRIGGER, GATED, BURST_TRIGGER, NUMTIMINGMODES };
enum { AUTO, TRIGGER, GATED, BURST_TRIGGER, TRIGGER_GATED, NUMTIMINGMODES };
QTimer *progressTimer;
// tool tip variables
QString acqPeriodTip;
@ -84,6 +87,7 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
QPalette red;
bool delayImplemented;
bool sampleImplemented;
bool gateImplemented;
bool startingFnumImplemented;
bool isAcquisitionStopped{false};
int numMeasurements{1};

View File

@ -29,9 +29,21 @@ void qTabAdvanced::SetupWidgetWindow() {
tab_roi->setEnabled(true);
break;
case slsDetectorDefs::MYTHEN3:
lblDiscardBits->setEnabled(true);
spinDiscardBits->setEnabled(true);
lblGateIndex->setEnabled(true);
spinGateIndex->setEnabled(true);
lblExpTime->setEnabled(true);
spinExpTime->setEnabled(true);
comboExpTimeUnit->setEnabled(true);
lblGateDelay->setEnabled(true);
spinGateDelay->setEnabled(true);
comboGateDelayUnit->setEnabled(true);
break;
case slsDetectorDefs::GOTTHARD2:
lblDiscardBits->setEnabled(true);
spinDiscardBits->setEnabled(true);
break;
default:
break;
}
@ -116,6 +128,28 @@ void qTabAdvanced::Initialization() {
connect(spinDiscardBits, SIGNAL(valueChanged(int)), plot,
SLOT(SetNumDiscardBits(int)));
}
// gate index
if (lblGateIndex->isEnabled()) {
connect(spinGateIndex, SIGNAL(valueChanged(int)), this,
SLOT(SetGateIndex(int)));
}
// exptime1, exptime2, exptme3
if (lblExpTime->isEnabled()) {
connect(spinExpTime, SIGNAL(valueChanged(double)), this,
SLOT(SetExposureTime()));
connect(comboExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetExposureTime()));
}
// gatedelay1, gatedelay2, gatedelay3
if (lblGateDelay->isEnabled()) {
connect(spinGateDelay, SIGNAL(valueChanged(double)), this,
SLOT(SetGateDelay()));
connect(comboGateDelayUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetGateDelay()));
}
}
void qTabAdvanced::PopulateDetectors() {
@ -671,6 +705,92 @@ void qTabAdvanced::SetSubDeadTime() {
GetSubDeadTime();
}
void qTabAdvanced::SetGateIndex(int value) {
LOG(logINFO) << "Getting exptime and gate delay for gate index: " << value;
GetExposureTime();
GetGateDelay();
}
void qTabAdvanced::GetExposureTime() {
int gateIndex = spinGateIndex->value();
LOG(logDEBUG) << "Getting exposure time" << gateIndex;
disconnect(spinExpTime, SIGNAL(valueChanged(double)), this,
SLOT(SetExposureTime()));
disconnect(comboExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetExposureTime()));
try {
auto retval = det->getExptime(gateIndex).tsquash(
"Exptime is inconsistent for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval);
spinExpTime->setValue(time.first);
comboExpTimeUnit->setCurrentIndex(static_cast<int>(time.second));
}
CATCH_DISPLAY("Could not get exposure time.",
"qTabSettings::GetExposureTime")
connect(spinExpTime, SIGNAL(valueChanged(double)), this,
SLOT(SetExposureTime()));
connect(comboExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetExposureTime()));
}
void qTabAdvanced::SetExposureTime() {
int gateIndex = spinGateIndex->value();
auto timeNS = qDefs::getNSTime(std::make_pair(
spinExpTime->value(),
static_cast<qDefs::timeUnit>(comboExpTimeUnit->currentIndex())));
LOG(logINFO) << "Setting exptime" << gateIndex << " to " << timeNS.count()
<< " ns"
<< "/" << spinExpTime->value()
<< qDefs::getUnitString(
(qDefs::timeUnit)comboExpTimeUnit->currentIndex());
try {
det->setExptime(gateIndex, timeNS);
}
CATCH_DISPLAY("Could not set exposure time.",
"qTabAdvanced::SetExposureTime")
GetExposureTime();
}
void qTabAdvanced::GetGateDelay() {
int gateIndex = spinGateIndex->value();
LOG(logDEBUG) << "Getting gate delay" << gateIndex;
disconnect(spinGateDelay, SIGNAL(valueChanged(double)), this,
SLOT(SetGateDelay()));
disconnect(comboGateDelayUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetGateDelay()));
try {
auto retval = det->getGateDelay(gateIndex).tsquash(
"GateDelay is inconsistent for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval);
spinGateDelay->setValue(time.first);
comboGateDelayUnit->setCurrentIndex(static_cast<int>(time.second));
}
CATCH_DISPLAY("Could not get gate delay.", "qTabSettings::GetGateDelay")
connect(spinGateDelay, SIGNAL(valueChanged(double)), this,
SLOT(SetGateDelay()));
connect(comboGateDelayUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetGateDelay()));
}
void qTabAdvanced::SetGateDelay() {
int gateIndex = spinGateIndex->value();
auto timeNS = qDefs::getNSTime(std::make_pair(
spinGateDelay->value(),
static_cast<qDefs::timeUnit>(comboGateDelayUnit->currentIndex())));
LOG(logINFO) << "Setting gatedelay" << gateIndex << " to " << timeNS.count()
<< " ns"
<< "/" << spinGateDelay->value()
<< qDefs::getUnitString(
(qDefs::timeUnit)comboGateDelayUnit->currentIndex());
try {
det->setGateDelay(gateIndex, timeNS);
}
CATCH_DISPLAY("Could not set gate delay.", "qTabAdvanced::SetGateDelay")
GetGateDelay();
}
void qTabAdvanced::Refresh() {
LOG(logDEBUG) << "**Updating Advanced Tab";
@ -698,5 +818,14 @@ void qTabAdvanced::Refresh() {
GetSubDeadTime();
}
// exptime1, exptime2, exptme3
if (lblExpTime->isEnabled()) {
GetExposureTime();
}
// gatedelay1, gatedelay2, gatedelay3
if (lblGateDelay->isEnabled()) {
GetGateDelay();
}
LOG(logDEBUG) << "**Updated Advanced Tab";
}

View File

@ -31,6 +31,7 @@ void qTabMeasurement::SetupWidgetWindow() {
progressTimer = new QTimer(this);
sampleImplemented = false;
gateImplemented = false;
delayImplemented = true;
startingFnumImplemented = false;
// by default, delay and starting fnum is disabled in form
@ -41,6 +42,8 @@ void qTabMeasurement::SetupWidgetWindow() {
// default is triggers and delay (not #bursts and burst period for gotthard2
// in auto mode)
ShowTriggerDelay();
// default is to show samples, mythen3, show gates
ShowGates();
// enabling according to det type
switch (det->getDetectorType().squash()) {
@ -67,6 +70,9 @@ void qTabMeasurement::SetupWidgetWindow() {
spinBurstPeriod->setEnabled(true);
comboBurstPeriodUnit->setEnabled(true);
break;
case slsDetectorDefs::MYTHEN3:
gateImplemented = true;
break;
default:
break;
}
@ -97,6 +103,10 @@ void qTabMeasurement::Initialization() {
connect(spinNumSamples, SIGNAL(valueChanged(int)), this,
SLOT(SetNumSamples(int)));
}
if (gateImplemented) {
connect(spinNumGates, SIGNAL(valueChanged(int)), this,
SLOT(SetNumGates(int)));
}
connect(spinExpTime, SIGNAL(valueChanged(double)), this,
SLOT(SetExposureTime()));
connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this,
@ -161,6 +171,16 @@ void qTabMeasurement::ShowTriggerDelay() {
}
}
void qTabMeasurement::ShowGates() {
if (det->getDetectorType().squash() == slsDetectorDefs::MYTHEN3) {
stackedLblSamplesGates->setCurrentWidget(pageLblGates);
stackedSpinSamplesGates->setCurrentWidget(pageSpinGates);
} else {
stackedLblSamplesGates->setCurrentWidget(pageLblSamples);
stackedSpinSamplesGates->setCurrentWidget(pageSpinSamples);
}
}
void qTabMeasurement::SetupTimingMode() {
QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboTimingMode->model());
@ -173,9 +193,20 @@ void qTabMeasurement::SetupTimingMode() {
item[i] = model->itemFromIndex(index[i]);
}
if (det->getDetectorType().squash() != slsDetectorDefs::EIGER) {
item[(int)GATED]->setEnabled(false);
item[(int)BURST_TRIGGER]->setEnabled(false);
item[(int)GATED]->setEnabled(false);
item[(int)BURST_TRIGGER]->setEnabled(false);
item[(int)TRIGGER_GATED]->setEnabled(false);
switch (det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER:
item[(int)GATED]->setEnabled(true);
item[(int)BURST_TRIGGER]->setEnabled(true);
break;
case slsDetectorDefs::MYTHEN3:
item[(int)GATED]->setEnabled(true);
item[(int)TRIGGER_GATED]->setEnabled(true);
break;
default:
break;
}
}
}
@ -197,6 +228,8 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
lblDelay->setEnabled(false);
spinDelay->setEnabled(false);
comboDelayUnit->setEnabled(false);
lblNumGates->setEnabled(false);
spinNumGates->setEnabled(false);
switch (comboTimingMode->currentIndex()) {
case AUTO:
@ -223,6 +256,7 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
lblExpTime->setEnabled(true);
spinExpTime->setEnabled(true);
comboExpUnit->setEnabled(true);
// not implemented in FW to have multiple frames for eiger
if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
spinNumFrames->setValue(1);
} else {
@ -241,8 +275,12 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
}
break;
case GATED:
// #frames
// #frames, #gates(mythen3)
spinNumTriggers->setValue(1);
if (det->getDetectorType().squash() == slsDetectorDefs::MYTHEN3) {
lblNumGates->setEnabled(true);
spinNumGates->setEnabled(true);
}
lblNumFrames->setEnabled(true);
spinNumFrames->setEnabled(true);
break;
@ -258,6 +296,18 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
spinPeriod->setEnabled(true);
comboPeriodUnit->setEnabled(true);
break;
case TRIGGER_GATED:
// #triggers, delay, #frames, #gates
lblNumTriggers->setEnabled(true);
spinNumTriggers->setEnabled(true);
lblDelay->setEnabled(true);
spinDelay->setEnabled(true);
comboDelayUnit->setEnabled(true);
lblNumFrames->setEnabled(true);
spinNumFrames->setEnabled(true);
lblNumGates->setEnabled(true);
spinNumGates->setEnabled(true);
break;
default:
break;
}
@ -278,6 +328,7 @@ void qTabMeasurement::GetTimingMode() {
case slsDetectorDefs::TRIGGER_EXPOSURE:
case slsDetectorDefs::GATED:
case slsDetectorDefs::BURST_TRIGGER:
case slsDetectorDefs::TRIGGER_GATED:
comboTimingMode->setCurrentIndex((int)retval);
// update widget enable only if different
if (oldMode != comboTimingMode->currentIndex()) {
@ -411,6 +462,31 @@ void qTabMeasurement::SetNumSamples(int val) {
&qTabMeasurement::GetNumSamples)
}
void qTabMeasurement::GetNumGates() {
LOG(logDEBUG) << "Getting number of gates";
disconnect(spinNumGates, SIGNAL(valueChanged(int)), this,
SLOT(SetNumGates(int)));
try {
auto retval = det->getNumberOfGates().tsquash(
"Inconsistent number of gates for all detectors.");
spinNumGates->setValue(retval);
}
CATCH_DISPLAY("Could not get number of gates.",
"qTabMeasurement::GetNumGates")
connect(spinNumGates, SIGNAL(valueChanged(int)), this,
SLOT(SetNumGates(int)));
}
void qTabMeasurement::SetNumGates(int val) {
LOG(logINFO) << "Setting number of external gates to " << val;
try {
det->setNumberOfGates(val);
}
CATCH_HANDLE("Could not set number of gates.",
"qTabMeasurement::SetNumGates", this,
&qTabMeasurement::GetNumGates)
}
void qTabMeasurement::GetExposureTime() {
LOG(logDEBUG) << "Getting exposure time";
disconnect(spinExpTime, SIGNAL(valueChanged(double)), this,
@ -419,12 +495,30 @@ void qTabMeasurement::GetExposureTime() {
SLOT(SetExposureTime()));
try {
spinExpTime->setValue(-1);
auto retval = det->getExptime().tsquash(
"Inconsistent exposure time for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval);
spinExpTime->setValue(time.first);
comboExpUnit->setCurrentIndex(static_cast<int>(time.second));
CheckAcqPeriodGreaterThanExp();
bool inconsistentGateValues = false;
std::chrono::nanoseconds retval;
if (det->getDetectorType().squash() == slsDetectorDefs::MYTHEN3) {
auto retvals = det->getExptimeForAllGates().tsquash(
"Inconsistent exposure time for all detectors.");
// all gates have same value
if (retvals[0] == retvals[1] && retvals[1] == retvals[2]) {
retval = retvals[0];
} else {
// dont throw, just leave it as -1
inconsistentGateValues = true;
}
} else {
retval = det->getExptime().tsquash(
"Inconsistent exposure time for all detectors.");
}
if (!inconsistentGateValues) {
auto time = qDefs::getUserFriendlyTime(retval);
spinExpTime->setValue(time.first);
comboExpUnit->setCurrentIndex(static_cast<int>(time.second));
CheckAcqPeriodGreaterThanExp();
}
}
CATCH_DISPLAY("Could not get exposure time.",
"qTabMeasurement::GetExposureTime")
@ -826,6 +920,9 @@ void qTabMeasurement::Refresh() {
if (sampleImplemented) {
GetNumSamples();
}
if (gateImplemented) {
GetNumGates();
}
GetFileWrite();
GetFileName();
GetRunIndex();

View File

@ -1,6 +1,7 @@
add_library(slsProjectCWarnings INTERFACE)
target_compile_options(slsProjectCWarnings INTERFACE
add_library(slsProjectCSettings INTERFACE)
target_compile_features(slsProjectCSettings INTERFACE c_std_99)
target_compile_options(slsProjectCSettings INTERFACE
-Wall
-Wextra
-Wno-unused-parameter #Needs to be slowly mitigated
@ -13,7 +14,7 @@ target_compile_options(slsProjectCWarnings INTERFACE
)
# Install fake the library
install(TARGETS slsProjectCWarnings
install(TARGETS slsProjectCSettings
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@ -33,7 +33,7 @@ target_compile_definitions(ctbDetectorServer_virtual
)
target_link_libraries(ctbDetectorServer_virtual
PUBLIC pthread rt slsProjectCWarnings
PUBLIC pthread rt slsProjectCSettings
m
)

View File

@ -1622,9 +1622,6 @@ int setDetectorPosition(int pos[]) {
int *getDetectorPosition() { return detPos; }
int enableTenGigabitEthernet(int val) {
#ifdef VIRTUAL
return 0;
#endif
uint32_t addr = CONFIG_REG;
// set

View File

@ -165,16 +165,15 @@ void Beb_GetModuleConfiguration(int *master, int *top, int *normal) {
LOG(logERROR, ("Module Configuration FAIL\n"));
} else {
// read data
ret = Beb_Read32(csp0base, MODULE_CONFIGURATION_MASK);
ret = Beb_Read32(csp0base, BEB_CONFIG_RD_OFST);
LOG(logDEBUG1, ("Module Configuration OK\n"));
LOG(logDEBUG1, ("Beb: value =0x%x\n", ret));
if (ret & TOP_BIT_MASK) {
if (ret & BEB_CONFIG_TOP_RD_MSK) {
*top = 1;
Beb_top = 1;
}
if (ret & MASTER_BIT_MASK)
if (ret & BEB_CONFIG_MASTER_RD_MSK)
*master = 1;
if (ret & NORMAL_MODULE_BIT_MASK)
if (ret & BEB_CONFIG_NORMAL_RD_MSK)
*normal = 1;
// close file pointer
Beb_close(fd, csp0base);
@ -298,125 +297,149 @@ int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay) {
return OK;
}
/* do not work at the moment */
int Beb_SetMasterViaSoftware() {
void Beb_SetTopVariable(int val) { Beb_top = val; }
int Beb_SetTop(enum TOPINDEX ind) {
if (!Beb_activated)
return 0;
// mapping new memory
u_int32_t *csp0base = 0;
u_int32_t value = 0, ret = 1;
// open file pointer
u_int32_t value = 0;
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
if (fd < 0) {
LOG(logERROR, ("Set Master FAIL\n"));
} else {
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
value |= MASTER_BIT;
value |= OVERWRITE_HARDWARE_BIT;
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET, value);
if (newval != value) {
LOG(logERROR, ("Could not set Master via Software\n"));
} else {
ret = 0;
}
LOG(logERROR, ("Set Top FAIL, could not open fd in Beb\n"));
return 0;
}
value = Beb_Read32(csp0base, BEB_CONFIG_WR_OFST);
switch (ind) {
case TOP_HARDWARE:
value &= ~BEB_CONFIG_OW_TOP_MSK;
break;
case OW_TOP:
value |= BEB_CONFIG_OW_TOP_MSK;
value |= BEB_CONFIG_TOP_MSK;
break;
case OW_BOTTOM:
value |= BEB_CONFIG_OW_TOP_MSK;
value &= ~BEB_CONFIG_TOP_MSK;
break;
default:
LOG(logERROR, ("Unknown top index in Beb: %d\n", ind));
Beb_close(fd, csp0base);
return 0;
}
// close file pointer
if (fd > 0)
char *top_names[] = {TOP_NAMES};
int newval = Beb_Write32(csp0base, BEB_CONFIG_WR_OFST, value);
if (newval != value) {
LOG(logERROR,
("Could not set Top flag to %s in Beb\n", top_names[ind]));
Beb_close(fd, csp0base);
return ret;
return 0;
}
LOG(logINFOBLUE,
("%s Top flag to %s in Beb\n",
(ind == TOP_HARDWARE ? "Resetting" : "Overwriting"), top_names[ind]));
Beb_close(fd, csp0base);
return 1;
}
/* do not work at the moment */
int Beb_SetSlaveViaSoftware() {
int Beb_SetMaster(enum MASTERINDEX ind) {
if (!Beb_activated)
return 0;
// mapping new memory
u_int32_t *csp0base = 0;
u_int32_t value = 0, ret = 1;
// open file pointer
u_int32_t value = 0;
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
if (fd < 0) {
LOG(logERROR, ("Set Slave FAIL\n"));
} else {
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
value &= ~MASTER_BIT;
value |= OVERWRITE_HARDWARE_BIT;
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET, value);
if (newval != value) {
LOG(logERROR, ("Could not set Slave via Software\n"));
} else {
ret = 0;
}
LOG(logERROR, ("Set Master FAIL, could not open fd in Beb\n"));
return 0;
}
value = Beb_Read32(csp0base, BEB_CONFIG_WR_OFST);
switch (ind) {
case MASTER_HARDWARE:
value &= ~BEB_CONFIG_OW_MASTER_MSK;
break;
case OW_MASTER:
value |= BEB_CONFIG_OW_MASTER_MSK;
value |= BEB_CONFIG_MASTER_MSK;
break;
case OW_SLAVE:
value |= BEB_CONFIG_OW_MASTER_MSK;
value &= ~BEB_CONFIG_MASTER_MSK;
break;
default:
LOG(logERROR, ("Unknown master index in Beb: %d\n", ind));
Beb_close(fd, csp0base);
return 0;
}
// close file pointer
if (fd > 0)
char *master_names[] = {MASTER_NAMES};
int newval = Beb_Write32(csp0base, BEB_CONFIG_WR_OFST, value);
if (newval != value) {
LOG(logERROR,
("Could not set Master flag to %s in Beb\n", master_names[ind]));
Beb_close(fd, csp0base);
return 0;
}
LOG(logINFOBLUE, ("%s Master flag to %s in Beb\n",
(ind == MASTER_HARDWARE ? "Resetting" : "Overwriting"),
master_names[ind]));
return ret;
Beb_close(fd, csp0base);
return 1;
}
int Beb_Activate(int enable) {
// mapping new memory
int Beb_SetActivate(int enable) {
if (enable < 0) {
LOG(logERROR, ("Invalid enable value\n"));
return 0;
}
u_int32_t *csp0base = 0;
u_int32_t value = 0, ret = -1;
// open file pointer
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
if (fd < 0) {
LOG(logERROR, ("Deactivate FAIL\n"));
LOG(logERROR, ("Activate FAIL, could not open fd\n"));
return 0;
} else {
if (enable > -1) {
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
LOG(logINFO, ("Deactivate register value before:%d\n", value));
if (enable)
value &= ~DEACTIVATE_BIT;
else
value |= DEACTIVATE_BIT;
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET, value);
if (newval != value) {
if (enable) {
LOG(logERROR, ("Could not activate via Software\n"));
} else {
LOG(logERROR, ("Could not deactivate via Software\n"));
}
}
}
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
if (value & DEACTIVATE_BIT)
ret = 0;
u_int32_t value = Beb_Read32(csp0base, BEB_CONFIG_WR_OFST);
LOG(logDEBUG, ("Activate register value before:%d\n", value));
if (enable)
value |= BEB_CONFIG_ACTIVATE_MSK;
else
ret = 1;
if (enable == -1) {
if (ret) {
LOG(logINFOBLUE,
("Detector is active. Register value:%d\n", value));
} else {
LOG(logERROR,
("Detector is deactivated! Register value:%d\n", value));
}
value &= ~BEB_CONFIG_ACTIVATE_MSK;
u_int32_t retval = Beb_Write32(csp0base, BEB_CONFIG_WR_OFST, value);
if (retval != value) {
LOG(logERROR,
("Could not %s. WRote 0x%x, read 0x%x\n",
(enable ? "activate" : "deactivate"), value, retval));
Beb_close(fd, csp0base);
}
}
// close file pointer
if (fd > 0)
Beb_close(fd, csp0base);
Beb_activated = ret;
return ret;
Beb_activated = enable;
Beb_close(fd, csp0base);
return 1;
}
int Beb_GetActivate() { return Beb_activated; }
int Beb_GetActivate(int *retval) {
u_int32_t *csp0base = 0;
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
if (fd < 0) {
LOG(logERROR, ("Activate FAIL, could not open fd\n"));
return 0;
} else {
u_int32_t value = Beb_Read32(csp0base, BEB_CONFIG_WR_OFST);
Beb_activated = (value & BEB_CONFIG_ACTIVATE_MSK) ? 1 : 0;
if (Beb_activated) {
LOG(logINFOBLUE, ("Detector is active\n"));
} else {
LOG(logINFORED, ("Detector is deactivated!\n"));
}
}
Beb_close(fd, csp0base);
*retval = Beb_activated;
return 1;
}
int Beb_Set32bitOverflow(int val) {
if (!Beb_activated)
@ -454,8 +477,7 @@ int Beb_Set32bitOverflow(int val) {
FLOW_REG_OVERFLOW_32_BIT_OFST;
}
// close file pointer
if (fd > 0)
Beb_close(fd, csp0base);
Beb_close(fd, csp0base);
return valueread;
}
@ -465,8 +487,8 @@ int Beb_GetTenGigaFlowControl() {
u_int32_t *csp0base = 0;
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
if (fd <= 0) {
LOG(logERROR,
("Could not read register to get ten giga flow control. FAIL\n"));
LOG(logERROR, ("Could not read register to get ten giga flow "
"control. FAIL\n"));
return -1;
} else {
u_int32_t retval = Beb_Read32(csp0base, offset);
@ -485,8 +507,8 @@ int Beb_SetTenGigaFlowControl(int value) {
u_int32_t *csp0base = 0;
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
if (fd <= 0) {
LOG(logERROR,
("Could not read register to set ten giga flow control. FAIL\n"));
LOG(logERROR, ("Could not read register to set ten giga flow "
"control. FAIL\n"));
return 0;
} else {
// reset bit
@ -545,8 +567,8 @@ int Beb_GetTransmissionDelayLeft() {
u_int32_t *csp0base = 0;
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
if (fd <= 0) {
LOG(logERROR,
("Could not read register to get transmission delay left. FAIL\n"));
LOG(logERROR, ("Could not read register to get transmission delay "
"left. FAIL\n"));
return -1;
} else {
u_int32_t retval = Beb_Read32(csp0base, offset);
@ -565,8 +587,8 @@ int Beb_SetTransmissionDelayLeft(int value) {
u_int32_t *csp0base = 0;
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
if (fd <= 0) {
LOG(logERROR,
("Could not read register to set transmission delay left. FAIL\n"));
LOG(logERROR, ("Could not read register to set transmission delay "
"left. FAIL\n"));
return 0;
} else {
Beb_Write32(csp0base, offset, value);
@ -656,35 +678,6 @@ int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val) {
return valueread;
}
int Beb_ResetToHardwareSettings() {
if (!Beb_activated)
return 1;
// mapping new memory
u_int32_t *csp0base = 0;
u_int32_t value = 0, ret = 1;
// open file pointer
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
if (fd < 0) {
LOG(logERROR, ("Reset to Hardware Settings FAIL\n"));
} else {
value = Beb_Write32(csp0base, MASTERCONFIG_OFFSET, 0);
if (value) {
LOG(logERROR, ("Could not reset to hardware settings\n"));
} else {
ret = 0;
}
}
// close file pointer
if (fd > 0)
Beb_close(fd, csp0base);
return ret;
}
u_int32_t Beb_GetFirmwareRevision() {
// mapping new memory
u_int32_t *csp0base = 0;
@ -697,8 +690,8 @@ u_int32_t Beb_GetFirmwareRevision() {
} else {
value = Beb_Read32(csp0base, FIRMWARE_VERSION_OFFSET);
if (!value) {
LOG(logERROR,
("Firmware Revision Number does not exist in this version\n"));
LOG(logERROR, ("Firmware Revision Number does not exist in "
"this version\n"));
}
}
@ -768,7 +761,8 @@ int Beb_InitBebInfos() { // file name at some point
struct BebInfo b0;
BebInfo_BebInfo(&b0, 0);
if (BebInfo_SetSerialAddress(
&b0, 0xff)) { // all bebs for reset and possibly get request data?
&b0,
0xff)) { // all bebs for reset and possibly get request data?
beb_infos[bebInfoSize] = b0;
bebInfoSize++;
}
@ -794,11 +788,11 @@ int Beb_InitBebInfos() { // file name at some point
//loop through file to fill vector.
BebInfo* b = new BebInfo(26);
b->SetSerialAddress(0); //0xc4000000
b->SetHeaderInfo(0,"00:50:c2:46:d9:34","129.129.205.78",42000 + 26); // 1 GbE,
ip address can be acquire from the network "arp"
b->SetHeaderInfo(0,"00:50:c2:46:d9:34","129.129.205.78",42000 + 26); // 1
GbE, ip address can be acquire from the network "arp"
b->SetHeaderInfo(1,"00:50:c2:46:d9:35","10.0.26.1",52000 + 26); //10 GbE,
everything calculable/setable beb_infos.push_back(b);
*/
*/
return Beb_CheckSourceStuffBebInfo();
}
@ -809,9 +803,11 @@ int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig,
// so that the values can be reset externally for now....
unsigned int i = 1; /*Beb_GetBebInfoIndex(beb_number);*/
/******* if (!i) return 0;****************************/ // i must be greater
// than 0, zero is
// the global send
/******* if (!i) return 0;****************************/ // i must be
// greater than
// 0, zero is
// the global
// send
BebInfo_SetHeaderInfo(&beb_infos[i], ten_gig, src_mac, src_ip, src_port);
LOG(logINFO, ("Printing Beb info number (%d) :\n", i));
@ -954,7 +950,7 @@ udp_header_type udp_header = {
{0x00, 0x00}, //{0x00, 0x11},
{0x00, 0x00}
};
*/
*/
if (!Beb_SetMAC(src_mac, &(udp_header.src_mac[0])))
return 0;
@ -1167,8 +1163,8 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
unsigned int nl = Beb_readNLines;
unsigned int npackets = (nl * maxnp) / maxnl;
if ((nl * maxnp) % maxnl) {
LOG(logERROR,
("Read N Lines is incorrect. Switching to Full Image Readout\n"));
LOG(logERROR, ("Read N Lines is incorrect. Switching to Full Image "
"Readout\n"));
npackets = maxnp;
}
int in_two_requests = (npackets > MAX_PACKETS_PER_REQUEST) ? 1 : 0;
@ -1270,8 +1266,8 @@ int Beb_Test(unsigned int beb_number) {
LOG(logINFO, ("Testing module number: %d\n", beb_number));
// int SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int
// header_number, string dst_mac, string dst_ip, unsigned int dst_port) {
// SetUpUDPHeader(26,0,0,"60:fb:42:f4:e3:d2","129.129.205.186",22000);
// header_number, string dst_mac, string dst_ip, unsigned int dst_port)
// { SetUpUDPHeader(26,0,0,"60:fb:42:f4:e3:d2","129.129.205.186",22000);
unsigned int index = Beb_GetBebInfoIndex(beb_number);
if (!index) {
@ -1288,9 +1284,10 @@ int Beb_Test(unsigned int beb_number) {
}
}
// SendMultiReadRequest(unsigned int beb_number, unsigned int left_right,
// int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned
// int packet_size, int stop_read_when_fifo_empty=1);
// SendMultiReadRequest(unsigned int beb_number, unsigned int
// left_right, int ten_gig, unsigned int dst_number, unsigned int
// npackets, unsigned int packet_size, int
// stop_read_when_fifo_empty=1);
for (i = 0; i < 64; i++) {
if (!Beb_SendMultiReadRequest(beb_number, i % 3 + 1, 0, i, 1, 0, 1)) {
LOG(logERROR, ("Error requesting data....\n"));
@ -1532,8 +1529,8 @@ int Beb_GetStartingFrameNumber(uint64_t *retval, int tengigaEnable) {
(long long int)left1g, (long long int)right1g));
*retval = (left1g > right1g)
? left1g
: right1g; // give max to set it to when stopping acq
// & different value
: right1g; // give max to set it to when stopping
// acq & different value
return -2; // to differentiate between failed address mapping
}
*retval = left1g;
@ -1559,8 +1556,8 @@ int Beb_GetStartingFrameNumber(uint64_t *retval, int tengigaEnable) {
(long long int)left10g, (long long int)right10g));
*retval = (left10g > right10g)
? left10g
: right10g; // give max to set it to when stopping acq
// & different value
: right10g; // give max to set it to when stopping
// acq & different value
return -2; // to differentiate between failed address mapping
}
*retval = left10g;

View File

@ -1,8 +1,8 @@
#pragma once
#include <stdlib.h>
#include "LocalLinkInterface.h"
#include "slsDetectorServer_defs.h"
#include <stdlib.h>
struct BebInfo {
unsigned int beb_number;
@ -36,10 +36,11 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb);
void Beb_GetModuleConfiguration(int *master, int *top, int *normal);
int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay);
int Beb_SetMasterViaSoftware();
int Beb_SetSlaveViaSoftware();
int Beb_Activate(int enable);
int Beb_GetActivate();
void Beb_SetTopVariable(int val);
int Beb_SetTop(enum TOPINDEX ind);
int Beb_SetMaster(enum MASTERINDEX ind);
int Beb_SetActivate(int enable);
int Beb_GetActivate(int *retval);
int Beb_Set32bitOverflow(int val);
int Beb_GetTenGigaFlowControl();
@ -51,7 +52,6 @@ int Beb_SetTransmissionDelayLeft(int value);
int Beb_GetTransmissionDelayRight();
int Beb_SetTransmissionDelayRight(int value);
int Beb_ResetToHardwareSettings();
u_int32_t Beb_GetFirmwareRevision();
u_int32_t Beb_GetFirmwareSoftwareAPIVersion();
void Beb_ResetFrameNumber();

View File

@ -28,7 +28,7 @@ target_compile_definitions(eigerDetectorServerMaster_virtual
)
target_link_libraries(eigerDetectorServerMaster_virtual
PUBLIC pthread rt slsProjectCWarnings
PUBLIC pthread rt slsProjectCSettings
)
set_target_properties(eigerDetectorServerMaster_virtual PROPERTIES

View File

@ -1841,10 +1841,10 @@ int Feb_Control_PrepareForAcquisition() { // return 1;
reg_nums[5] = DAQ_REG_SUBFRAME_EXPOSURES;
reg_vals[5] =
Feb_Control_subframe_exposure_time_in_10nsec; //(1 means 10ns, 100 means
//1000ns)
// 1000ns)
reg_nums[6] = DAQ_REG_SUBFRAME_PERIOD;
reg_vals[6] = Feb_Control_subframe_period_in_10nsec; //(1 means 10ns, 100
//means 1000ns)
// means 1000ns)
// if
// (!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),20,reg_nums,reg_vals,0,0))
// {
@ -2459,29 +2459,110 @@ int Feb_Control_GetInterruptSubframe() {
return value[0];
}
int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right) {
uint32_t offset = DAQ_REG_HRDWRE;
unsigned int addr[2] = {0, 0};
if (left) {
addr[0] = Module_GetTopLeftAddress(&modules[1]);
}
if (right) {
addr[1] = Module_GetTopRightAddress(&modules[1]);
}
char *top_names[] = {TOP_NAMES};
int i = 0;
for (i = 0; i < 2; ++i) {
if (addr[i] == 0) {
continue;
}
uint32_t value = 0;
if (!Feb_Interface_ReadRegister(addr[i], offset, &value)) {
LOG(logERROR, ("Could not read %s Feb reg to set Top flag\n",
(i == 0 ? "left" : "right")));
return 0;
}
switch (ind) {
case TOP_HARDWARE:
value &= ~DAQ_REG_HRDWRE_OW_TOP_MSK;
break;
case OW_TOP:
value |= DAQ_REG_HRDWRE_OW_TOP_MSK;
value |= DAQ_REG_HRDWRE_TOP_MSK;
break;
case OW_BOTTOM:
value |= DAQ_REG_HRDWRE_OW_TOP_MSK;
value &= ~DAQ_REG_HRDWRE_TOP_MSK;
break;
default:
LOG(logERROR, ("Unknown top index in Feb: %d\n", ind));
return 0;
}
if (!Feb_Interface_WriteRegister(addr[i], offset, value, 0, 0)) {
LOG(logERROR, ("Could not set Top flag to %s in %s Feb\n",
top_names[ind], (i == 0 ? "left" : "right")));
return 0;
}
}
if (left && right) {
LOG(logINFOBLUE, ("%s Top flag to %s Feb\n",
(ind == TOP_HARDWARE ? "Resetting" : "Overwriting"),
top_names[ind]));
}
return 1;
}
void Feb_Control_SetMasterVariable(int val) { Feb_control_master = val; }
int Feb_Control_SetMaster(enum MASTERINDEX ind) {
uint32_t offset = DAQ_REG_HRDWRE;
unsigned int addr[2] = {0, 0};
addr[0] = Module_GetTopLeftAddress(&modules[1]);
addr[1] = Module_GetTopRightAddress(&modules[1]);
char *master_names[] = {MASTER_NAMES};
int i = 0;
for (i = 0; i < 2; ++i) {
uint32_t value = 0;
if (!Feb_Interface_ReadRegister(addr[i], offset, &value)) {
LOG(logERROR, ("Could not read %s Feb reg to set Master flag\n",
(i == 0 ? "left" : "right")));
return 0;
}
switch (ind) {
case MASTER_HARDWARE:
value &= ~DAQ_REG_HRDWRE_OW_MASTER_MSK;
break;
case OW_MASTER:
value |= DAQ_REG_HRDWRE_OW_MASTER_MSK;
value |= DAQ_REG_HRDWRE_MASTER_MSK;
break;
case OW_SLAVE:
value |= DAQ_REG_HRDWRE_OW_MASTER_MSK;
value &= ~DAQ_REG_HRDWRE_MASTER_MSK;
break;
default:
LOG(logERROR, ("Unknown master index in Feb: %d\n", ind));
return 0;
}
if (!Feb_Interface_WriteRegister(addr[i], offset, value, 0, 0)) {
LOG(logERROR, ("Could not set Master flag to %s in %s Feb\n",
master_names[ind], (i == 0 ? "left" : "right")));
return 0;
}
}
LOG(logINFOBLUE, ("%s Master flag to %s Feb\n",
(ind == MASTER_HARDWARE ? "Resetting" : "Overwriting"),
master_names[ind]));
return 1;
}
int Feb_Control_SetQuad(int val) {
// no bottom for quad
if (!Module_TopAddressIsValid(&modules[1])) {
return 1;
}
uint32_t offset = DAQ_REG_HRDWRE;
LOG(logINFO, ("Setting Quad to %d in Feb\n", val));
unsigned int addr = Module_GetTopRightAddress(&modules[1]);
uint32_t regVal = 0;
if (!Feb_Interface_ReadRegister(addr, offset, &regVal)) {
LOG(logERROR, ("Could not read top right quad reg\n"));
return 0;
}
uint32_t data =
((val == 0)
? (regVal & ~DAQ_REG_HRDWRE_OW_MSK)
: ((regVal | DAQ_REG_HRDWRE_OW_MSK) & ~DAQ_REG_HRDWRE_TOP_MSK));
if (!Feb_Interface_WriteRegister(addr, offset, data, 0, 0)) {
LOG(logERROR, ("Could not write 0x%x to top right quad addr 0x%x\n",
data, offset));
return 0;
}
return 1;
// only setting on the right feb if quad
return Feb_Control_SetTop(val == 0 ? TOP_HARDWARE : OW_TOP, 0, 1);
}
int Feb_Control_SetReadNLines(int value) {
@ -2565,6 +2646,7 @@ int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
addr[1] = Module_TopAddressIsValid(&modules[1])
? Module_GetTopLeftAddress(&modules[1])
: Module_GetBottomLeftAddress(&modules[1]);
uint32_t value[2] = {0, 0};
int run[2] = {0, 0};

View File

@ -1,5 +1,6 @@
#pragma once
#include "FebInterface.h"
#include "slsDetectorServer_defs.h"
#include <netinet/in.h>
struct Module {
@ -174,6 +175,10 @@ int64_t Feb_Control_GetSubMeasuredPeriod();
int Feb_Control_SoftwareTrigger();
int Feb_Control_SetInterruptSubframe(int val);
int Feb_Control_GetInterruptSubframe();
int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right);
void Feb_Control_SetMasterVariable(int val);
int Feb_Control_SetMaster(enum MASTERINDEX ind);
int Feb_Control_SetQuad(int val);
int Feb_Control_SetReadNLines(int value);
int Feb_Control_GetReadNLines();

View File

@ -16,21 +16,24 @@
#define DAQ_REG_PARTIAL_READOUT 8
#define DAQ_REG_HRDWRE 12
#define DAQ_REG_HRDWRE_OW_OFST (0)
#define DAQ_REG_HRDWRE_OW_MSK (0x00000001 << DAQ_REG_HRDWRE_OW_OFST)
// clang-format off
#define DAQ_REG_HRDWRE_OW_TOP_OFST (0)
#define DAQ_REG_HRDWRE_OW_TOP_MSK (0x00000001 << DAQ_REG_HRDWRE_OW_TOP_OFST)
#define DAQ_REG_HRDWRE_TOP_OFST (1)
#define DAQ_REG_HRDWRE_TOP_MSK (0x00000001 << DAQ_REG_HRDWRE_TOP_OFST)
#define DAQ_REG_HRDWRE_INTRRPT_SF_OFST (2)
#define DAQ_REG_HRDWRE_INTRRPT_SF_MSK \
(0x00000001 << DAQ_REG_HRDWRE_INTRRPT_SF_OFST)
#define DAQ_REG_HRDWRE_INTRRPT_SF_MSK (0x00000001 << DAQ_REG_HRDWRE_INTRRPT_SF_OFST)
#define DAQ_REG_HRDWRE_OW_MASTER_OFST (3)
#define DAQ_REG_HRDWRE_OW_MASTER_MSK (0x00000001 << DAQ_REG_HRDWRE_OW_MASTER_OFST)
#define DAQ_REG_HRDWRE_MASTER_OFST (4)
#define DAQ_REG_HRDWRE_MASTER_MSK (0x00000001 << DAQ_REG_HRDWRE_MASTER_OFST)
#define DAQ_REG_RO_OFFSET 20
#define DAQ_REG_STATUS \
(DAQ_REG_RO_OFFSET + 0) // also pg and fifo status register
#define DAQ_REG_RO_OFFSET 20
#define DAQ_REG_STATUS (DAQ_REG_RO_OFFSET + 0) // also pg and fifo status register
#define FEB_REG_STATUS (DAQ_REG_RO_OFFSET + 3)
#define MEAS_SUBPERIOD_REG (DAQ_REG_RO_OFFSET + 4)
#define MEAS_PERIOD_REG (DAQ_REG_RO_OFFSET + 5)
// clang-format on
#define DAQ_CTRL_RESET 0x80000000
#define DAQ_CTRL_START 0x40000000
@ -52,10 +55,11 @@
#define DAQ_SERIALIN_SHIFT_IN_32 0x00000100
#define DAQ_LOAD_16ROWS_OF_TRIMBITS 0x00000200
#define DAQ_IGNORE_INITIAL_CRAP 0x00000400 // crap before readout
// crap before readout
#define DAQ_IGNORE_INITIAL_CRAP 0x00000400
#define DAQ_READOUT_NROWS 0x00000800
#define DAQ_CLKOUT_LAST_4_BITS_AND_RETURN_TO_START \
0x00001000 // last 4 bit of data in the last frame
// last 4 bit of data in the last frame
#define DAQ_CLKOUT_LAST_4_BITS_AND_RETURN_TO_START 0x00001000
#define DAQ_RELEASE_IMAGE_STORE_AFTER_READOUT 0x00002000
#define DAQ_RESET_PIXEL_COUNTERS_AFTER_READOUT 0x00004000
@ -64,23 +68,24 @@
#define DAQ_CLK_MAIN_CLK_TO_SELECT_NEXT_PIXEL 0x00010000
#define DAQ_SEND_N_TEST_PULSES 0x00020000
#define DAQ_CHIP_CONTROLLER_HALF_SPEED \
0x00040000 // everything at 100 MHz (50MHz ddr readout)
#define DAQ_CHIP_CONTROLLER_QUARTER_SPEED \
0x00080000 // everything at 50 MHz (25MHz ddr readout)
#define DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED \
0x000c0000 // everything at ~200 kHz (200 kHz MHz ddr readout)
// everything at 100 MHz (50MHz ddr readout)
#define DAQ_CHIP_CONTROLLER_HALF_SPEED 0x00040000
// everything at 50 MHz (25MHz ddr readout)
#define DAQ_CHIP_CONTROLLER_QUARTER_SPEED 0x00080000
// everything at ~200 kHz (200 kHz MHz ddr readout)
#define DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED 0x000c0000
//#define DAQ_FIFO_ENABLE 0x00100000 commented out as it
//#define DAQ_FIFO_ENABLE 0x00100000 commented out as it
// is not used anywhere
#define DAQ_REG_CHIP_CMDS_INT_TRIGGER 0x00100000
// direct chip commands to the DAQ_REG_CHIP_CMDS register
#define DAQ_NEXPOSURERS_SAFEST_MODE_ROW_CLK_BEFORE_MODE \
0x00200000 // row clk is before main clk readout sequence
#define DAQ_NEXPOSURERS_NORMAL_NONPARALLEL_MODE \
0x00400000 // expose ->readout ->expose -> ..., with store is always closed
#define DAQ_NEXPOSURERS_PARALLEL_MODE 0x00600000 // parallel acquire/read mode
// row clk is before main clk readout sequence
#define DAQ_NEXPOSURERS_SAFEST_MODE_ROW_CLK_BEFORE_MODE 0x00200000
// expose ->readout ->expose -> ..., with store is always closed
#define DAQ_NEXPOSURERS_NORMAL_NONPARALLEL_MODE 0x00400000
// parallel acquire/read mode
#define DAQ_NEXPOSURERS_PARALLEL_MODE 0x00600000
// DAQ_NEXPOSURERS_READOUT_COMPLETE_IMAGES is old now hard-wired in the firmware
// that every image comes with a header #define
@ -91,12 +96,14 @@
#define DAQ_NEXPOSURERS_EXTERNAL_ENABLING_POLARITY 0x02000000
#define DAQ_NEXPOSURERS_EXTERNAL_TRIGGER_POLARITY 0x04000000
#define DAQ_NEXPOSURERS_INTERNAL_ACQUISITION 0x00000000 // internally controlled
#define DAQ_NEXPOSURERS_EXTERNAL_ACQUISITION_START \
0x08000000 // external acquisition start
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START 0x10000000 // external image start
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START_AND_STOP \
0x18000000 // externally controlly, external image start and stop
// internally controlled
#define DAQ_NEXPOSURERS_INTERNAL_ACQUISITION 0x00000000
// external acquisition start
#define DAQ_NEXPOSURERS_EXTERNAL_ACQUISITION_START 0x08000000
// external image start
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START 0x10000000
// externally controlly, external image start and stop
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START_AND_STOP 0x18000000
#define DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING 0x20000000
#define DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION 0x40000000
@ -106,11 +113,12 @@
// chips static bits
#define DAQ_STATIC_BIT_PROGRAM 0x00000001
#define DAQ_STATIC_BIT_M4 0x00000002 // these are the status bits, not bit mode
#define DAQ_STATIC_BIT_M8 0x00000004 // these are the status bits, not bit mode
#define DAQ_STATIC_BIT_M12 \
0x00000000 // these are the status bits, not bit mode, ie. "00" is 12 bit
// mode
// these are the status bits, not bit mode
#define DAQ_STATIC_BIT_M4 0x00000002
#define DAQ_STATIC_BIT_M8 0x00000004
// these are the status bits, not bit mode, ie. "00" is 12 bit mode
#define DAQ_STATIC_BIT_M12 0x00000000
#define DAQ_STATIC_BIT_CHIP_TEST 0x00000008
#define DAQ_STATIC_BIT_ROTEST 0x00000010
#define DAQ_CS_BAR_LEFT 0x00000020
@ -136,18 +144,28 @@
#define CHIP_DATA_OUT_DELAY_REG4 4
#define CHIP_DATA_OUT_DELAY_SET 0x20000000
// module configuration
#define TOP_BIT_MASK 0x00f
#define MASTER_BIT_MASK 0x200
#define NORMAL_MODULE_BIT_MASK 0x400
/** BEB Registers */
// Master Slave Top Bottom Definition
#define MODULE_CONFIGURATION_MASK 0x84
// Software Configuration
#define MASTERCONFIG_OFFSET 0x160 // 0x20 * 11 (P11)
#define MASTER_BIT 0x1
#define OVERWRITE_HARDWARE_BIT 0x2
#define DEACTIVATE_BIT 0x4
// module configuration - XPAR_PLB_GPIO_SYS_BASEADDR
#define BEB_CONFIG_WR_OFST (0x160) // 0x20 * 11 (P11)
#define BEB_CONFIG_MASTER_OFST (0)
#define BEB_CONFIG_MASTER_MSK (0x00000001 << BEB_CONFIG_MASTER_OFST)
#define BEB_CONFIG_OW_MASTER_OFST (1)
#define BEB_CONFIG_OW_MASTER_MSK (0x00000001 << BEB_CONFIG_OW_MASTER_OFST)
#define BEB_CONFIG_ACTIVATE_OFST (2)
#define BEB_CONFIG_ACTIVATE_MSK (0x00000001 << BEB_CONFIG_ACTIVATE_OFST)
#define BEB_CONFIG_TOP_OFST (3)
#define BEB_CONFIG_TOP_MSK (0x00000001 << BEB_CONFIG_TOP_OFST)
#define BEB_CONFIG_OW_TOP_OFST (4)
#define BEB_CONFIG_OW_TOP_MSK (0x00000001 << BEB_CONFIG_OW_TOP_OFST)
#define BEB_CONFIG_RD_OFST (0x84)
#define BEB_CONFIG_TOP_RD_OFST (0)
#define BEB_CONFIG_TOP_RD_MSK (0x00000001 << BEB_CONFIG_TOP_RD_OFST)
#define BEB_CONFIG_MASTER_RD_OFST (9)
#define BEB_CONFIG_MASTER_RD_MSK (0x00000001 << BEB_CONFIG_MASTER_RD_OFST)
#define BEB_CONFIG_NORMAL_RD_OFST (10)
#define BEB_CONFIG_NORMAL_RD_MSK (0x00000001 << BEB_CONFIG_NORMAL_RD_OFST)
#define FPGA_TEMP_OFFSET 0x200

View File

@ -0,0 +1,2 @@
top 1
master 1

View File

@ -96,6 +96,8 @@ uint64_t eiger_virtual_startingframenumber = 1;
int eiger_virtual_detPos[2] = {0, 0};
int eiger_virtual_test_mode = 0;
int eiger_virtual_quad_mode = 0;
int eiger_virtual_read_nlines = 256;
int eiger_virtual_interrupt_subframe = 0;
#endif
int isInitCheckDone() { return initCheckDone; }
@ -226,6 +228,19 @@ u_int64_t getFirmwareAPIVersion() {
#endif
}
void readDetectorNumber() {
#ifndef VIRTUAL
char output[255];
FILE *sysFile = popen(IDFILECOMMAND, "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
sscanf(output, "%u", &detid);
if (isControlServer) {
LOG(logINFOBLUE, ("Detector ID: %u\n", detid));
}
#endif
}
u_int32_t getDetectorNumber() {
#ifdef VIRTUAL
return 0;
@ -309,85 +324,67 @@ u_int32_t getDetectorIP() {
/* initialization */
void initControlServer() {
#ifdef VIRTUAL
LOG(logINFOBLUE, ("Configuring Control server\n"));
if (initError == OK) {
readDetectorNumber();
getModuleConfiguration();
setupDetector();
}
initCheckDone = 1;
return;
#else
if (initError == OK) {
// Feb and Beb Initializations
getModuleConfiguration();
#ifndef VIRTUAL
Feb_Control_SetMasterVariable(master);
Feb_Interface_FebInterface();
Feb_Control_FebControl();
// different addresses for top and bottom
if (getFirmwareVersion() < FIRMWARE_VERSION_SAME_TOP_BOT_ADDR) {
Feb_Control_Init(master, top, normal, getDetectorNumber());
}
// same addresses for top and bottom
else {
Feb_Control_Init(master, 1, normal, getDetectorNumber());
}
Feb_Control_Init(master, 1, normal, getDetectorNumber());
// master of 9M, check high voltage serial communication to blackfin
if (master && !normal) {
if (Feb_Control_OpenSerialCommunication())
; // Feb_Control_CloseSerialCommunication();
}
LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
Beb_SetTopVariable(top);
Beb_Beb(detid);
Beb_SetDetectorNumber(getDetectorNumber());
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
#endif
// also reads config file and deactivates
setupDetector();
// activate (if it gets ip) (later FW will deactivate at startup)
if (getDetectorIP() != 0) {
Beb_Activate(1);
Feb_Control_activate(1);
} else {
Beb_Activate(0);
Feb_Control_activate(0);
}
}
initCheckDone = 1;
#endif
}
void initStopServer() {
#ifdef VIRTUAL
LOG(logINFOBLUE, ("Configuring Stop server\n"));
getModuleConfiguration();
virtual_stop = 0;
if (!isControlServer) {
ComVirtual_setStop(virtual_stop);
}
return;
// get top/master in virtual
readConfigFile();
#else
// wait a few s (control server is setting top/master from config file)
usleep(WAIT_STOP_SERVER_START);
LOG(logINFOBLUE, ("Configuring Stop server\n"));
// exit(-1);
readDetectorNumber();
getModuleConfiguration();
Feb_Control_SetMasterVariable(master);
Feb_Interface_FebInterface();
Feb_Control_FebControl();
// different addresses for top and bottom
if (getFirmwareVersion() < FIRMWARE_VERSION_SAME_TOP_BOT_ADDR) {
Feb_Control_Init(master, top, normal, getDetectorNumber());
}
// same addresses for top and bottom
else {
Feb_Control_Init(master, 1, normal, getDetectorNumber());
}
Feb_Control_Init(master, 1, normal, getDetectorNumber());
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
// activate (if it gets ip) (later FW will deactivate at startup)
// also needed for stop server for status
if (getDetectorIP() != 0) {
Beb_Activate(1);
Feb_Control_activate(1);
} else {
Beb_Activate(0);
Feb_Control_activate(0);
}
#endif
// client first connect (from shm) will activate
if (setActivate(0) == FAIL) {
LOG(logERROR, ("Could not deactivate in stop server\n"));
}
}
void getModuleConfiguration() {
if (initError == FAIL) {
return;
}
#ifdef VIRTUAL
#ifdef VIRTUAL_MASTER
master = 1;
@ -400,34 +397,219 @@ void getModuleConfiguration() {
top = 0;
#endif
#endif
#ifdef VIRTUAL_9M
normal = 0;
#else
normal = 1;
#endif
LOG(logINFOBLUE,
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
(master ? "MASTER" : "SLAVE"), (normal ? "NORMAL" : "SPECIAL")));
return;
#else
int *m = &master;
int *t = &top;
int *n = &normal;
Beb_GetModuleConfiguration(m, t, n);
Beb_GetModuleConfiguration(&master, &top, &normal);
#endif
if (isControlServer) {
LOG(logINFOBLUE,
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
(master ? "MASTER" : "SLAVE"), (normal ? "NORMAL" : "SPECIAL")));
}
}
// read detector id
char output[255];
FILE *sysFile = popen(IDFILECOMMAND, "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
sscanf(output, "%u", &detid);
if (isControlServer) {
LOG(logINFOBLUE, ("Detector ID: %u\n\n", detid));
int readConfigFile() {
if (initError == FAIL) {
return initError;
}
master = -1;
top = -1;
FILE *fd = fopen(CONFIG_FILE, "r");
if (fd == NULL) {
LOG(logINFO, ("No config file found. Resetting to hardware settings "
"(Top/Master)\n"));
// reset to hardware settings if not in config file (if overwritten)
resetToHardwareSettings();
return initError;
}
LOG(logINFO, ("Reading config file %s\n", CONFIG_FILE));
// Initialization
const size_t LZ = 256;
char line[LZ];
memset(line, 0, LZ);
char command[LZ];
// keep reading a line
while (fgets(line, LZ, fd)) {
// ignore comments
if (line[0] == '#') {
LOG(logDEBUG1, ("Ignoring Comment\n"));
continue;
}
// ignore empty lines
if (strlen(line) <= 1) {
LOG(logDEBUG1, ("Ignoring Empty line\n"));
continue;
}
// ignoring lines beginning with space or tab
if (line[0] == ' ' || line[0] == '\t') {
LOG(logDEBUG1, ("Ignoring Lines starting with space or tabs\n"));
continue;
}
LOG(logDEBUG1, ("Command to process: (size:%d) %.*s\n", strlen(line),
strlen(line) - 1, line));
memset(command, 0, LZ);
// top command
if (!strncmp(line, "top", strlen("top"))) {
// cannot scan values
if (sscanf(line, "%s %d", command, &top) != 2) {
sprintf(initErrorMessage,
"Could not scan top commands from on-board server "
"config file. Line:[%s].\n",
line);
break;
}
#ifndef VIRTUAL
enum TOPINDEX ind = (top == 1 ? OW_TOP : OW_BOTTOM);
if (!Beb_SetTop(ind)) {
sprintf(
initErrorMessage,
"Could not overwrite top to %d in Beb from on-board server "
"config file. Line:[%s].\n",
top, line);
break;
}
if (!Feb_Control_SetTop(ind, 1, 1)) {
sprintf(
initErrorMessage,
"Could not overwrite top to %d in Feb from on-board server "
"config file. Line:[%s].\n",
top, line);
break;
}
// validate change
int actual_top = -1, temp = -1, temp2 = -1;
Beb_GetModuleConfiguration(&temp, &actual_top, &temp2);
if (actual_top != top) {
sprintf(initErrorMessage, "Could not set top to %d. Read %d\n",
top, actual_top);
break;
}
Beb_SetTopVariable(top);
#endif
}
// master command
else if (!strncmp(line, "master", strlen("master"))) {
// cannot scan values
if (sscanf(line, "%s %d", command, &master) != 2) {
sprintf(initErrorMessage,
"Could not scan master commands from on-board server "
"config file. Line:[%s].\n",
line);
break;
}
#ifndef VIRTUAL
enum MASTERINDEX ind = (master == 1 ? OW_MASTER : OW_SLAVE);
if (!Beb_SetMaster(ind)) {
sprintf(initErrorMessage,
"Could not overwrite master to %d in Beb from on-board "
"server "
"config file. Line:[%s].\n",
master, line);
break;
}
if (!Feb_Control_SetMaster(ind)) {
sprintf(initErrorMessage,
"Could not overwrite master to %d in Feb from on-board "
"server "
"config file. Line:[%s].\n",
master, line);
break;
}
// validate change
int actual_master = -1, temp = -1, temp2 = -1;
Beb_GetModuleConfiguration(&actual_master, &temp, &temp2);
if (actual_master != master) {
sprintf(initErrorMessage,
"Could not set master to %d. Read %d\n", master,
actual_master);
break;
}
Feb_Control_SetMasterVariable(master);
#endif
}
// other commands
else {
sprintf(initErrorMessage,
"Could not scan command from on-board server "
"config file. Line:[%s].\n",
line);
break;
}
}
fclose(fd);
if (strlen(initErrorMessage)) {
initError = FAIL;
LOG(logERROR, ("%s\n\n", initErrorMessage));
} else {
LOG(logINFO, ("Successfully read config file\n"));
}
// reset to hardware settings if not in config file (if overwritten)
resetToHardwareSettings();
return initError;
}
void resetToHardwareSettings() {
#ifndef VIRTUAL
if (initError == FAIL) {
return;
}
// top not set in config file
if (top == -1) {
if (!Beb_SetTop(TOP_HARDWARE)) {
initError = FAIL;
strcpy(initErrorMessage,
"Could not reset Top flag to Beb hardware settings.\n");
LOG(logERROR, ("%s\n\n", initErrorMessage));
return;
}
if (!Feb_Control_SetTop(TOP_HARDWARE, 1, 1)) {
initError = FAIL;
strcpy(initErrorMessage,
"Could not reset Top flag to Feb hardware settings.\n");
LOG(logERROR, ("%s\n\n", initErrorMessage));
return;
}
int temp = -1, temp2 = -1;
Beb_GetModuleConfiguration(&temp, &top, &temp2);
Beb_SetTopVariable(top);
}
// master not set in config file
if (master == -1) {
if (!Beb_SetMaster(TOP_HARDWARE)) {
initError = FAIL;
strcpy(initErrorMessage,
"Could not reset Master flag to Beb hardware settings.\n");
LOG(logERROR, ("%s\n\n", initErrorMessage));
return;
}
if (!Feb_Control_SetMaster(TOP_HARDWARE)) {
initError = FAIL;
strcpy(initErrorMessage,
"Could not reset Master flag to Feb hardware settings.\n");
LOG(logERROR, ("%s\n\n", initErrorMessage));
return;
}
int temp = -1, temp2 = -1;
Beb_GetModuleConfiguration(&master, &temp, &temp2);
Feb_Control_SetMasterVariable(master);
}
#endif
}
@ -517,6 +699,20 @@ void setupDetector() {
#ifndef VIRTUAL
Feb_Control_CheckSetup();
#endif
// force top or master if in config file
if (readConfigFile() == FAIL) {
return;
}
LOG(logINFOBLUE,
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
(master ? "MASTER" : "SLAVE"), (normal ? "NORMAL" : "SPECIAL")));
// client first connect (from shm) will activate
if (setActivate(0) == FAIL) {
initError = FAIL;
sprintf(initErrorMessage, "Could not deactivate\n");
LOG(logERROR, (initErrorMessage));
}
LOG(logDEBUG1, ("Setup detector done\n\n"));
}
@ -1322,13 +1518,15 @@ int setInterruptSubframe(int value) {
if (!Feb_Control_SetInterruptSubframe(value)) {
return FAIL;
}
#else
eiger_virtual_interrupt_subframe = value;
#endif
return OK;
}
int getInterruptSubframe() {
#ifdef VIRTUAL
return 0;
return eiger_virtual_interrupt_subframe;
#else
return Feb_Control_GetInterruptSubframe();
#endif
@ -1342,13 +1540,15 @@ int setReadNLines(int value) {
return FAIL;
}
Beb_SetReadNLines(value);
#else
eiger_virtual_read_nlines = value;
#endif
return OK;
}
int getReadNLines() {
#ifdef VIRTUAL
return 0;
return eiger_virtual_read_nlines;
#else
return Feb_Control_GetReadNLines();
#endif
@ -1641,6 +1841,7 @@ void setExternalGating(int enable[]) {
}
int setAllTrimbits(int val) {
LOG(logINFO, ("Setting all trimbits to %d\n", val));
#ifndef VIRTUAL
if (!Feb_Control_SaveAllTrimbitsTo(val, top)) {
LOG(logERROR, ("Could not set all trimbits\n"));
@ -1681,16 +1882,38 @@ int getBebFPGATemp() {
#endif
}
int activate(int enable) {
int setActivate(int enable) {
if (enable < 0) {
LOG(logERROR, ("Invalid activate argument: %d\n", enable));
return FAIL;
}
#ifdef VIRTUAL
if (enable >= 0)
eiger_virtual_activate = enable;
return eiger_virtual_activate;
eiger_virtual_activate = enable;
#else
int ret = Beb_Activate(enable);
Feb_Control_activate(ret);
return ret;
if (!Beb_SetActivate(enable)) {
return FAIL;
}
Feb_Control_activate(enable);
#endif
if (enable) {
LOG(logINFOGREEN, ("Activated in %s Server!\n",
isControlServer ? " Control" : "Stop"));
} else {
LOG(logINFORED, ("Deactivated in %s Server!\n",
isControlServer ? " Control" : "Stop"));
}
return OK;
}
int getActivate(int *retval) {
#ifdef VIRTUAL
*retval = eiger_virtual_activate;
#else
if (!Beb_GetActivate(retval)) {
return FAIL;
}
#endif
return OK;
}
int getTenGigaFlowControl() {
@ -1939,9 +2162,8 @@ void *start_timer(void *arg) {
memset(packetData, 0, packetsize);
sls_detector_header *header =
(sls_detector_header *)(packetData);
header->detType = 3; //(uint16_t)myDetectorType; updated
//when firmware updates
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
header->row = row;
@ -1950,9 +2172,8 @@ void *start_timer(void *arg) {
char packetData2[packetsize];
memset(packetData2, 0, packetsize);
header = (sls_detector_header *)(packetData2);
header->detType = 3; //(uint16_t)myDetectorType; updated
//when firmware updates
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
header->row = row;
@ -2090,7 +2311,8 @@ int startReadOut() {
break;
// for(i=0;i<nimages_per_request;i++)
// if ((ret_val =
//(!Beb_RequestNImages(beb_num,send_to_ten_gig,on_dst,1,0)))) break;
//(!Beb_RequestNImages(beb_num,send_to_ten_gig,on_dst,1,0))))
// break;
dst_requested[on_dst++] = 0;
on_dst %= ndsts_in_use;
@ -2127,7 +2349,7 @@ enum runStatus getRunStatus() {
return ERROR;
}
if (isTransmitting) {
printf("Status: TRANSMITTING\n");
LOG(logINFOBLUE, ("Status: TRANSMITTING\n"));
return TRANSMITTING;
}
LOG(logINFOBLUE, ("Status: IDLE\n"));
@ -2177,7 +2399,7 @@ void readFrame(int *ret, char *mess) {
printf("Transmitting...\n");
}
}
printf("Detector has sent all data\n");
LOG(logINFO, ("Detector has sent all data\n"));
LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
#endif
}

View File

@ -1,9 +1,10 @@
#pragma once
#include "sls_detector_defs.h"
#define REQUIRED_FIRMWARE_VERSION (24)
#define IDFILECOMMAND "more /home/root/executables/detid.txt"
#define FIRMWARE_VERSION_SAME_TOP_BOT_ADDR (26)
#define REQUIRED_FIRMWARE_VERSION (26)
#define IDFILECOMMAND "more /home/root/executables/detid.txt"
#define CONFIG_FILE ("config.txt")
#define WAIT_STOP_SERVER_START (1 * 1000 * 1000)
#define STATUS_IDLE 0
#define STATUS_RUNNING 1
@ -61,6 +62,11 @@ enum ADCINDEX {
enum NETWORKINDEX { TXN_LEFT, TXN_RIGHT, TXN_FRAME, FLOWCTRL_10G };
enum ROINDEX { E_PARALLEL, E_NON_PARALLEL };
enum CLKINDEX { RUN_CLK, NUM_CLOCKS };
enum TOPINDEX { TOP_HARDWARE, OW_TOP, OW_BOTTOM };
#define TOP_NAMES "hardware", "top", "bottom"
enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define MASTER_NAMES "hardware", "master", "slave"
#define CLK_NAMES "run"
/* Hardware Definitions */

View File

@ -28,7 +28,7 @@ target_compile_definitions(gotthard2DetectorServer_virtual
)
target_link_libraries(gotthard2DetectorServer_virtual
PUBLIC pthread rt slsProjectCWarnings
PUBLIC pthread rt slsProjectCSettings
)
set_target_properties(gotthard2DetectorServer_virtual PROPERTIES

View File

@ -1,110 +1,114 @@
#pragma once
// clang-format off
#define REG_OFFSET (4)
/* Base addresses 0x1804 0000 ---------------------------------------------*/
/* Reconfiguration core for readout pll */
#define BASE_READOUT_PLL (0x0000) // 0x1804_0000 - 0x1804_07FF
#define BASE_READOUT_PLL (0x0000) // 0x1804_0000 - 0x1804_07FF
/* Reconfiguration core for system pll */
#define BASE_SYSTEM_PLL (0x0800) // 0x1804_0800 - 0x1804_0FFF
#define BASE_SYSTEM_PLL (0x0800) // 0x1804_0800 - 0x1804_0FFF
/* Clock Generation */
#define BASE_CLK_GENERATION (0x1000) // 0x1804_1000 - 0x1804_XXXX //TODO
/* Base addresses 0x1806 0000 ---------------------------------------------*/
/* General purpose control and status registers */
#define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF
#define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/ctrl/ctrl.vhd
/* ASIC Control */
#define BASE_ASIC (0x0100) // 0x1806_0100 - 0x1806_011F
#define BASE_ASIC (0x0100) // 0x1806_0100 - 0x1806_011F
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/asic/asic_ctrl.vhd
/* ASIC Digital Interface. Data recovery core */
#define BASE_ADIF (0x0120) // 0x1806_0120 - 0x1806_012F
#define BASE_ADIF (0x0120) // 0x1806_0120 - 0x1806_012F
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/adif/adif_ctrl.vhd
/* Formatting of data core */
#define BASE_FMT (0x0130) // 0x1806_0130 - 0x1806_013F
#define BASE_FMT (0x0130) // 0x1806_0130 - 0x1806_013F
/* Packetizer */
#define BASE_PKT (0x0140) // 0x1806_0140 - 0x1806_014F
#define BASE_PKT (0x0140) // 0x1806_0140 - 0x1806_014F
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/pkt/pkt_ctrl.vhd
/* Flow control and status registers */
#define BASE_FLOW_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF
#define BASE_FLOW_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/f37608230b4721661f29aacc20124555705ee705/flow/flow_ctrl.vhd
/* UDP datagram generator */
#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF
#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF
/* Clock Generation registers
* ------------------------------------------------------*/
#define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION)
#define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION)
#define PLL_RESET_READOUT_OFST (0)
#define PLL_RESET_READOUT_MSK (0x00000001 << PLL_RESET_READOUT_OFST)
#define PLL_RESET_SYSTEM_OFST (1)
#define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST)
#define PLL_RESET_READOUT_OFST (0)
#define PLL_RESET_READOUT_MSK (0x00000001 << PLL_RESET_READOUT_OFST)
#define PLL_RESET_SYSTEM_OFST (1)
#define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST)
/* Control registers --------------------------------------------------*/
/* Module Control Board Serial Number register */
#define MCB_SERIAL_NO_REG (0x00 * REG_OFFSET + BASE_CONTROL)
#define MCB_SERIAL_NO_REG (0x00 * REG_OFFSET + BASE_CONTROL)
#define MCB_SERIAL_NO_VRSN_OFST (16)
#define MCB_SERIAL_NO_VRSN_MSK (0x0000001F << MCB_SERIAL_NO_VRSN_OFST)
#define MCB_SERIAL_NO_VRSN_OFST (16)
#define MCB_SERIAL_NO_VRSN_MSK (0x0000001F << MCB_SERIAL_NO_VRSN_OFST)
/* FPGA Version register */
#define FPGA_VERSION_REG (0x01 * REG_OFFSET + BASE_CONTROL)
#define FPGA_VERSION_REG (0x01 * REG_OFFSET + BASE_CONTROL)
#define FPGA_COMPILATION_DATE_OFST (0)
#define FPGA_COMPILATION_DATE_MSK (0x00FFFFFF << FPGA_COMPILATION_DATE_OFST)
#define DETECTOR_TYPE_OFST (24)
#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST)
#define FPGA_COMPILATION_DATE_OFST (0)
#define FPGA_COMPILATION_DATE_MSK (0x00FFFFFF << FPGA_COMPILATION_DATE_OFST)
#define DETECTOR_TYPE_OFST (24)
#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST)
/* API Version register */
#define API_VERSION_REG (0x02 * REG_OFFSET + BASE_CONTROL)
#define API_VERSION_REG (0x02 * REG_OFFSET + BASE_CONTROL)
#define API_VERSION_OFST (0)
#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
#define API_VERSION_DETECTOR_TYPE_OFST (24) // Not used in software
#define API_VERSION_DETECTOR_TYPE_MSK \
(0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) // Not used in software
#define API_VERSION_OFST (0)
#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
#define API_VERSION_DETECTOR_TYPE_OFST (24) // Not used in software
#define API_VERSION_DETECTOR_TYPE_MSK (0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) // Not used in software
/* Fix pattern register */
#define FIX_PATT_REG (0x03 * REG_OFFSET + BASE_CONTROL)
#define FIX_PATT_VAL (0xACDC2019)
#define FIX_PATT_REG (0x03 * REG_OFFSET + BASE_CONTROL)
#define FIX_PATT_VAL (0xACDC2019)
/* Status register */
#define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL)
#define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL)
/* Look at me read only register */
#define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL)
#define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL)
/* System status register */
#define SYSTEM_STATUS_REG (0x06 * REG_OFFSET + BASE_CONTROL)
#define SYSTEM_STATUS_REG (0x06 * REG_OFFSET + BASE_CONTROL)
/* Config RW regiseter */
#define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL)
#define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL)
#define CONFIG_VETO_ENBL_OFST (0)
#define CONFIG_VETO_ENBL_MSK (0x00000001 << CONFIG_VETO_ENBL_OFST)
#define CONFIG_VETO_CH_10GB_ENBL_OFST (1)
#define CONFIG_VETO_CH_10GB_ENBL_MSK (0x00000001 << CONFIG_VETO_CH_10GB_ENBL_OFST)
/* Control RW register */
#define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL)
#define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL)
#define CONTROL_STRT_ACQSTN_OFST (0)
#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST)
#define CONTROL_STP_ACQSTN_OFST (1)
#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST)
#define CONTROL_CRE_RST_OFST (10)
#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST)
#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10?
#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST)
#define CONTROL_CLR_ACQSTN_FIFO_OFST (15)
#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST)
#define CONTROL_TIMING_SOURCE_EXT_OFST (17)
#define CONTROL_TIMING_SOURCE_EXT_MSK \
(0x00000001 << CONTROL_TIMING_SOURCE_EXT_OFST)
#define CONTROL_PWR_CHIP_OFST (31)
#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST)
#define CONTROL_STRT_ACQSTN_OFST (0)
#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST)
#define CONTROL_STP_ACQSTN_OFST (1)
#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST)
#define CONTROL_CRE_RST_OFST (10)
#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST)
#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10?
#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST)
#define CONTROL_CLR_ACQSTN_FIFO_OFST (15)
#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST)
#define CONTROL_TIMING_SOURCE_EXT_OFST (17)
#define CONTROL_TIMING_SOURCE_EXT_MSK (0x00000001 << CONTROL_TIMING_SOURCE_EXT_OFST)
#define CONTROL_PWR_CHIP_OFST (31)
#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST)
/** DTA Offset Register */
#define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL)
@ -114,143 +118,138 @@
/* ASIC Config register */
#define ASIC_CONFIG_REG (0x00 * REG_OFFSET + BASE_ASIC)
#define ASIC_CONFIG_RUN_MODE_OFST (0)
#define ASIC_CONFIG_RUN_MODE_MSK (0x00000003 << ASIC_CONFIG_RUN_MODE_OFST)
#define ASIC_CONFIG_RUN_MODE_INT_BURST_VAL \
((0x1 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_RUN_MODE_CONT_VAL \
((0x2 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL \
((0x3 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_GAIN_OFST (4)
#define ASIC_CONFIG_GAIN_MSK (0x00000003 << ASIC_CONFIG_GAIN_OFST)
#define ASIC_CONFIG_DYNAMIC_GAIN_VAL \
((0x0 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_FIX_GAIN_1_VAL \
((0x1 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_FIX_GAIN_2_VAL \
((0x2 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_RESERVED_VAL \
((0x3 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_CURRENT_SRC_EN_OFST (7)
#define ASIC_CONFIG_CURRENT_SRC_EN_MSK \
(0x00000001 << ASIC_CONFIG_CURRENT_SRC_EN_OFST)
#define ASIC_CONFIG_RST_DAC_OFST (15)
#define ASIC_CONFIG_RST_DAC_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST)
#define ASIC_CONFIG_DONE_OFST (31)
#define ASIC_CONFIG_DONE_MSK (0x00000001 << ASIC_CONFIG_DONE_OFST)
#define ASIC_CONFIG_RUN_MODE_OFST (0)
#define ASIC_CONFIG_RUN_MODE_MSK (0x00000003 << ASIC_CONFIG_RUN_MODE_OFST)
#define ASIC_CONFIG_RUN_MODE_INT_BURST_VAL ((0x1 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_RUN_MODE_CONT_VAL ((0x2 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL ((0x3 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_GAIN_OFST (4)
#define ASIC_CONFIG_GAIN_MSK (0x00000003 << ASIC_CONFIG_GAIN_OFST)
#define ASIC_CONFIG_DYNAMIC_GAIN_VAL ((0x0 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_FIX_GAIN_1_VAL ((0x1 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_FIX_GAIN_2_VAL ((0x2 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_RESERVED_VAL ((0x3 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_CURRENT_SRC_EN_OFST (7)
#define ASIC_CONFIG_CURRENT_SRC_EN_MSK (0x00000001 << ASIC_CONFIG_CURRENT_SRC_EN_OFST)
#define ASIC_CONFIG_RST_DAC_OFST (15)
#define ASIC_CONFIG_RST_DAC_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST)
#define ASIC_CONFIG_DONE_OFST (31)
#define ASIC_CONFIG_DONE_MSK (0x00000001 << ASIC_CONFIG_DONE_OFST)
/* ASIC Internal Frames Register */
#define ASIC_INT_FRAMES_REG (0x01 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_FRAMES_REG (0x01 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_FRAMES_OFST (0)
#define ASIC_INT_FRAMES_MSK (0x00000FFF << ASIC_INT_FRAMES_OFST)
#define ASIC_INT_FRAMES_OFST (0)
#define ASIC_INT_FRAMES_MSK (0x00000FFF << ASIC_INT_FRAMES_OFST)
/* ASIC Period 64bit Register */
#define ASIC_INT_PERIOD_LSB_REG (0x02 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_PERIOD_MSB_REG (0x03 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_PERIOD_LSB_REG (0x02 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_PERIOD_MSB_REG (0x03 * REG_OFFSET + BASE_ASIC)
/* ASIC Exptime 64bit Register */
#define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC)
/* Packetizer -------------------------------------------------------------*/
/* Packetizer Config Register */
#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT)
#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT)
#define PKT_CONFIG_NRXR_MAX_OFST (0)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_RXR_START_ID_OFST (8)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
#define PKT_CONFIG_NRXR_MAX_OFST (0)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_RXR_START_ID_OFST (8)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
/* Module Coordinates Register */
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)
#define COORD_ROW_OFST (0)
#define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST)
#define COORD_COL_OFST (16)
#define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST)
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)
#define COORD_ROW_OFST (0)
#define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST)
#define COORD_COL_OFST (16)
#define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST)
/* Module ID Register */
#define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT)
#define COORD_RESERVED_OFST (0)
#define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST)
#define COORD_ID_OFST (16) // Not connected in firmware TODO
#define COORD_ID_MSK \
(0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO
#define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT)
#define COORD_RESERVED_OFST (0)
#define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST)
#define COORD_ID_OFST (16) // Not connected in firmware TODO
#define COORD_ID_MSK (0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO
/* Flow control registers --------------------------------------------------*/
/* Flow status Register*/
#define FLOW_STATUS_REG (0x00 * REG_OFFSET + BASE_FLOW_CONTROL)
#define FLOW_STATUS_REG (0x00 * REG_OFFSET + BASE_FLOW_CONTROL)
#define FLOW_STATUS_RUN_BUSY_OFST (0)
#define FLOW_STATUS_RUN_BUSY_MSK (0x00000001 << FLOW_STATUS_RUN_BUSY_OFST)
#define FLOW_STATUS_WAIT_FOR_TRGGR_OFST (3)
#define FLOW_STATUS_WAIT_FOR_TRGGR_MSK \
(0x00000001 << FLOW_STATUS_WAIT_FOR_TRGGR_OFST)
#define FLOW_STATUS_DLY_BFRE_TRGGR_OFST (4)
#define FLOW_STATUS_DLY_BFRE_TRGGR_MSK \
(0x00000001 << FLOW_STATUS_DLY_BFRE_TRGGR_OFST)
#define FLOW_STATUS_FIFO_FULL_OFST (5)
#define FLOW_STATUS_FIFO_FULL_MSK (0x00000001 << FLOW_STATUS_FIFO_FULL_OFST)
#define FLOW_STATUS_DLY_AFTR_TRGGR_OFST (15)
#define FLOW_STATUS_DLY_AFTR_TRGGR_MSK \
(0x00000001 << FLOW_STATUS_DLY_AFTR_TRGGR_OFST)
#define FLOW_STATUS_CSM_BUSY_OFST (17)
#define FLOW_STATUS_CSM_BUSY_MSK (0x00000001 << FLOW_STATUS_CSM_BUSY_OFST)
#define FLOW_STATUS_RUN_BUSY_OFST (0)
#define FLOW_STATUS_RUN_BUSY_MSK (0x00000001 << FLOW_STATUS_RUN_BUSY_OFST)
#define FLOW_STATUS_WAIT_FOR_TRGGR_OFST (3)
#define FLOW_STATUS_WAIT_FOR_TRGGR_MSK (0x00000001 << FLOW_STATUS_WAIT_FOR_TRGGR_OFST)
#define FLOW_STATUS_DLY_BFRE_TRGGR_OFST (4)
#define FLOW_STATUS_DLY_BFRE_TRGGR_MSK (0x00000001 << FLOW_STATUS_DLY_BFRE_TRGGR_OFST)
#define FLOW_STATUS_FIFO_FULL_OFST (5)
#define FLOW_STATUS_FIFO_FULL_MSK (0x00000001 << FLOW_STATUS_FIFO_FULL_OFST)
#define FLOW_STATUS_DLY_AFTR_TRGGR_OFST (15)
#define FLOW_STATUS_DLY_AFTR_TRGGR_MSK (0x00000001 << FLOW_STATUS_DLY_AFTR_TRGGR_OFST)
#define FLOW_STATUS_CSM_BUSY_OFST (17)
#define FLOW_STATUS_CSM_BUSY_MSK (0x00000001 << FLOW_STATUS_CSM_BUSY_OFST)
/* Delay left 64bit Register */
#define GET_DELAY_LSB_REG (0x02 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_DELAY_MSB_REG (0x03 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_DELAY_LSB_REG (0x02 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_DELAY_MSB_REG (0x03 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Triggers left 64bit Register */
#define GET_CYCLES_LSB_REG (0x04 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_CYCLES_MSB_REG (0x05 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_CYCLES_LSB_REG (0x04 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_CYCLES_MSB_REG (0x05 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Frames left 64bit Register */
#define GET_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Period left 64bit Register */
#define GET_PERIOD_LSB_REG (0x08 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_PERIOD_MSB_REG (0x09 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_PERIOD_LSB_REG (0x08 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_PERIOD_MSB_REG (0x09 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Time from Start 64 bit register */
#define TIME_FROM_START_LSB_REG (0x0A * REG_OFFSET + BASE_FLOW_CONTROL)
#define TIME_FROM_START_MSB_REG (0x0B * REG_OFFSET + BASE_FLOW_CONTROL)
#define TIME_FROM_START_LSB_REG (0x0A * REG_OFFSET + BASE_FLOW_CONTROL)
#define TIME_FROM_START_MSB_REG (0x0B * REG_OFFSET + BASE_FLOW_CONTROL)
/* Get Frames from Start 64 bit register (frames from last reset using
* CONTROL_CRST) */
#define FRAMES_FROM_START_LSB_REG (0x0C * REG_OFFSET + BASE_FLOW_CONTROL)
#define FRAMES_FROM_START_MSB_REG (0x0D * REG_OFFSET + BASE_FLOW_CONTROL)
#define FRAMES_FROM_START_LSB_REG (0x0C * REG_OFFSET + BASE_FLOW_CONTROL)
#define FRAMES_FROM_START_MSB_REG (0x0D * REG_OFFSET + BASE_FLOW_CONTROL)
/* Measurement Time 64 bit register (timestamp at a frame start until reset)*/
#define START_FRAME_TIME_LSB_REG (0x0E * REG_OFFSET + BASE_FLOW_CONTROL)
#define START_FRAME_TIME_MSB_REG (0x0F * REG_OFFSET + BASE_FLOW_CONTROL)
#define START_FRAME_TIME_LSB_REG (0x0E * REG_OFFSET + BASE_FLOW_CONTROL)
#define START_FRAME_TIME_MSB_REG (0x0F * REG_OFFSET + BASE_FLOW_CONTROL)
/* Delay 64bit Write-register */
#define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Cylces (also #bursts) 64bit Write-register */
#define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Frames 64bit Write-register */
#define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Period (also burst period) 64bit Write-register */
#define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL)
/* External Signal register */
#define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_FLOW_CONTROL)
#define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_FLOW_CONTROL)
#define EXT_SIGNAL_OFST (0)
#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST)
#define EXT_SIGNAL_OFST (0)
#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST)
/* Trigger Delay 64 bit register */
#define SET_TRIGGER_DELAY_LSB_REG (0x32 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_TRIGGER_DELAY_MSB_REG (0x33 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_TRIGGER_DELAY_LSB_REG (0x32 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_TRIGGER_DELAY_MSB_REG (0x33 * REG_OFFSET + BASE_FLOW_CONTROL)
/* UDP datagram registers --------------------------------------------------*/
#define RXR_ENDPOINTS_MAX (32)
#define RXR_ENDPOINT_OFST (16 * REG_OFFSET)
// clang-format on

View File

@ -324,7 +324,6 @@ u_int32_t getDetectorIP() {
/* initialization */
void initControlServer() {
CreateNotificationForCriticalTasks();
if (initError == OK) {
setupDetector();
}
@ -1290,44 +1289,40 @@ enum timingMode getTiming() {
return AUTO_TIMING;
}
int configureMAC() {
/* configure mac */
void setNumberofUDPInterfaces(int val) {
uint32_t addr = CONFIG_REG;
uint32_t srcip = udpDetails.srcip;
uint32_t dstip = udpDetails.dstip;
uint64_t srcmac = udpDetails.srcmac;
uint64_t dstmac = udpDetails.dstmac;
int srcport = udpDetails.srcport;
int dstport = udpDetails.dstport;
LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50],
dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac);
getMacAddressinString(dst_mac, 50, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);
LOG(logINFO, ("\tSource IP : %s\n"
"\tSource MAC : %s\n"
"\tSource Port : %d\n"
"\tDest IP : %s\n"
"\tDest MAC : %s\n"
"\tDest Port : %d\n",
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
#ifdef VIRTUAL
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port\n"));
return FAIL;
// 2 interfaces (enable veto)
if (val > 1) {
LOG(logINFOBLUE, ("Setting #Interfaces: 2 (10gbps veto streaming)\n"));
bus_w(addr, bus_r(addr) | CONFIG_VETO_CH_10GB_ENBL_MSK);
}
return OK;
#endif
// 1 interface (disable veto)
else {
LOG(logINFOBLUE, ("Setting #Interfaces: 1 (2.5gbps veto streaming)\n"));
bus_w(addr, bus_r(addr) & ~CONFIG_VETO_CH_10GB_ENBL_MSK);
}
LOG(logDEBUG, ("config reg:0x%x\n", bus_r(addr)));
}
int getNumberofUDPInterfaces() {
LOG(logDEBUG, ("config reg:0x%x\n", bus_r(CONFIG_REG)));
// return 2 if 10gbps veto streaming enabled, else 1
return ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_10GB_ENBL_MSK) ? 2 : 1);
}
void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip,
uint64_t destmac, uint32_t destport, uint64_t sourcemac,
uint32_t sourceip, uint32_t sourceport) {
// start addr
uint32_t addr = BASE_UDP_RAM;
// calculate rxr endpoint offset
// addr += (iRxEntry * RXR_ENDPOINT_OFST);//TODO: is there round robin
// already implemented?
if (vetoInterface == 1) {
iRxEntry += RXR_ENDPOINTS_MAX;
}
addr += (iRxEntry * RXR_ENDPOINT_OFST);
// get struct memory
udp_header *udp =
(udp_header *)(Nios_getBaseAddress() + addr / (sizeof(u_int32_t)));
@ -1335,21 +1330,21 @@ int configureMAC() {
// mac addresses
// msb (32) + lsb (16)
udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK);
udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK);
udp->udp_destmac_msb = ((destmac >> 16) & BIT32_MASK);
udp->udp_destmac_lsb = ((destmac >> 0) & BIT16_MASK);
// msb (16) + lsb (32)
udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK);
udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK);
udp->udp_srcmac_msb = ((sourcemac >> 32) & BIT16_MASK);
udp->udp_srcmac_lsb = ((sourcemac >> 0) & BIT32_MASK);
// ip addresses
udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK);
udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK);
udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK);
udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK);
udp->ip_srcip_msb = ((sourceip >> 16) & BIT16_MASK);
udp->ip_srcip_lsb = ((sourceip >> 0) & BIT16_MASK);
udp->ip_destip_msb = ((destip >> 16) & BIT16_MASK);
udp->ip_destip_lsb = ((destip >> 0) & BIT16_MASK);
// source port
udp->udp_srcport = srcport;
udp->udp_destport = dstport;
udp->udp_srcport = sourceport;
udp->udp_destport = destport;
// other defines
udp->udp_ethertype = 0x800;
@ -1361,12 +1356,6 @@ int configureMAC() {
// total length is redefined in firmware
calcChecksum(udp);
// TODO?
cleanFifos();
resetCore();
// alignDeserializer();
return OK;
}
void calcChecksum(udp_header *udp) {
@ -1401,6 +1390,92 @@ void calcChecksum(udp_header *udp) {
udp->ip_checksum = checksum;
}
int configureMAC() {
uint32_t srcip = udpDetails.srcip;
uint32_t srcip2 = udpDetails.srcip2;
uint32_t dstip = udpDetails.dstip;
uint32_t dstip2 = udpDetails.dstip2;
uint64_t srcmac = udpDetails.srcmac;
uint64_t srcmac2 = udpDetails.srcmac2;
uint64_t dstmac = udpDetails.dstmac;
uint64_t dstmac2 = udpDetails.dstmac2;
int srcport = udpDetails.srcport;
int srcport2 = udpDetails.srcport2;
int dstport = udpDetails.dstport;
int dstport2 = udpDetails.dstport2;
LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50],
dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac);
getMacAddressinString(dst_mac, 50, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);
char src_mac2[50], src_ip2[INET_ADDRSTRLEN], dst_mac2[50],
dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, 50, srcmac2);
getMacAddressinString(dst_mac2, 50, dstmac2);
getIpAddressinString(src_ip2, srcip2);
getIpAddressinString(dst_ip2, dstip2);
int numInterfaces = getNumberofUDPInterfaces();
int vetoEnabled = getVeto();
LOG(logINFO, ("\t#Veto : %d\n", vetoEnabled));
LOG(logINFO, ("\t#10Gb Interfaces : %d\n", numInterfaces));
LOG(logINFO, ("\tData Interface \n"));
LOG(logINFO, ("\tSource IP : %s\n"
"\tSource MAC : %s\n"
"\tSource Port : %d\n"
"\tDest IP : %s\n"
"\tDest MAC : %s\n"
"\tDest Port : %d\n",
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
LOG(logINFO,
("\tVeto Interface (%s)\n",
(vetoEnabled && numInterfaces == 2 ? "enabled" : "disabled")));
LOG(logINFO, ("\tSource IP2 : %s\n"
"\tSource MAC2 : %s\n"
"\tSource Port2: %d\n"
"\tDest IP2 : %s\n"
"\tDest MAC2 : %s\n"
"\tDest Port2 : %d\n",
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
#ifdef VIRTUAL
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port\n"));
return FAIL;
}
if (vetoEnabled && numInterfaces == 2 &&
setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) {
LOG(logERROR,
("could not set udp destination IP and port for interface 2\n"));
return FAIL;
}
return OK;
#endif
// default one rxr entry (others not yet implemented in client yet)
int iRxEntry = 0;
// data
setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip, srcport);
// veto
if (vetoEnabled && numInterfaces == 2) {
setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, srcip2,
srcport2);
}
cleanFifos();
resetCore();
// alignDeserializer();
return OK;
}
int setDetectorPosition(int pos[]) {
memcpy(detPos, pos, sizeof(detPos));
@ -2134,6 +2209,27 @@ enum timingSourceType getTimingSource() {
return TIMING_INTERNAL;
}
void setVeto(int enable) {
if (enable >= 0) {
uint32_t addr = CONFIG_REG;
if (enable) {
LOG(logINFOBLUE, ("Enabling veto streaming\n"));
bus_w(addr, bus_r(addr) | CONFIG_VETO_ENBL_MSK);
} else {
LOG(logINFOBLUE, ("Disabling veto streaming\n"));
bus_w(addr, bus_r(addr) & ~CONFIG_VETO_ENBL_MSK);
}
LOG(logDEBUG, ("config reg:0x%x\n", bus_r(addr)));
}
}
int getVeto() {
LOG(logDEBUG, ("config reg:0x%x\n", bus_r(CONFIG_REG)));
return ((bus_r(CONFIG_REG) & CONFIG_VETO_ENBL_MSK) >>
CONFIG_VETO_ENBL_OFST);
}
/* aquisition */
int startStateMachine() {
@ -2142,6 +2238,10 @@ int startStateMachine() {
if (createUDPSocket(0) != OK) {
return FAIL;
}
if (getVeto() && getNumberofUDPInterfaces() == 2 &&
createUDPSocket(1) != OK) {
return FAIL;
}
LOG(logINFOBLUE, ("Starting State Machine\n"));
// set status to running
virtual_status = 1;
@ -2181,6 +2281,9 @@ void *start_timer(void *arg) {
return NULL;
}
int numInterfaces = getNumberofUDPInterfaces();
int vetoEnabled = getVeto();
int numRepeats = getNumTriggers();
if (getTiming() == AUTO_TIMING) {
if (burstMode == BURST_OFF) {
@ -2196,6 +2299,8 @@ void *start_timer(void *arg) {
int imagesize = NCHAN * NCHIP * 2;
int datasize = imagesize;
int packetsize = datasize + sizeof(sls_detector_header);
int vetodatasize = VETO_DATA_SIZE;
int vetopacketsize = vetodatasize + sizeof(veto_header);
// Generate data
char imageData[imagesize];
@ -2203,6 +2308,11 @@ void *start_timer(void *arg) {
for (int i = 0; i < imagesize; i += sizeof(uint16_t)) {
*((uint16_t *)(imageData + i)) = i;
}
char vetoData[vetodatasize];
memset(vetoData, 0, sizeof(vetodatasize));
for (int i = 0; i < vetodatasize; i += sizeof(uint8_t)) {
*((uint16_t *)(vetoData + i)) = i;
}
{
int frameHeaderNr = 0;
@ -2227,6 +2337,7 @@ void *start_timer(void *arg) {
clock_gettime(CLOCK_REALTIME, &begin);
usleep(expUs);
// first interface
char packetData[packetsize];
memset(packetData, 0, packetsize);
// set header
@ -2235,19 +2346,32 @@ void *start_timer(void *arg) {
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameHeaderNr;
++frameHeaderNr;
header->packetNumber = 0;
header->modId = 0;
header->row = detPos[X];
header->column = detPos[Y];
// fill data
memcpy(packetData + sizeof(sls_detector_header), imageData,
datasize);
// send 1 packet = 1 frame
sendUDPPacket(0, packetData, packetsize);
// second interface (veto)
char packetData2[vetopacketsize];
memset(packetData2, 0, vetopacketsize);
if (vetoEnabled && numInterfaces == 2) {
// set header
veto_header *header = (veto_header *)(packetData2);
header->frameNumber = frameHeaderNr;
header->bunchId = 0;
// fill data
memcpy(packetData2 + sizeof(veto_header), vetoData,
vetodatasize);
// send 1 packet = 1 frame
sendUDPPacket(1, packetData2, vetopacketsize);
}
++frameHeaderNr;
clock_gettime(CLOCK_REALTIME, &end);
LOG(logINFO,
("Sent frame: %d (bursts: %d)\n", frameNr, repeatNr));
@ -2275,6 +2399,9 @@ void *start_timer(void *arg) {
}
closeUDPSocket(0);
if (vetoEnabled && numInterfaces == 2) {
closeUDPSocket(1);
}
virtual_status = 0;
if (isControlServer) {

View File

@ -12,7 +12,7 @@
#define NADC (32)
#define ONCHIP_NDAC (7)
#define DYNAMIC_RANGE (16)
#define HV_SOFT_MAX_VOLTAGE (200)
#define HV_SOFT_MAX_VOLTAGE (500)
#define HV_HARD_MAX_VOLTAGE (530)
#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac")
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
@ -52,11 +52,15 @@
#define DEFAULT_SYSTEM_C3 (5) //(144444448) // str_clk, 144 MHz
/* Firmware Definitions */
#define IP_HEADER_SIZE (20)
#define FIXED_PLL_FREQUENCY (20000000) // 20MHz
#define INT_SYSTEM_C0_FREQUENCY (144000000) // 144 MHz
#define READOUT_PLL_VCO_FREQ_HZ (866666688) // 866 MHz
#define SYSTEM_PLL_VCO_FREQ_HZ (722222224) // 722 MHz
#define VETO_DATA_SIZE (160)
typedef struct {
uint64_t frameNumber;
uint64_t bunchId;
} veto_header;
/** Other Definitions */
#define BIT16_MASK (0xFFFF)
@ -156,4 +160,5 @@ typedef struct udp_header_struct {
uint16_t udp_checksum;
uint16_t udp_destport;
} udp_header;
#define IP_HEADER_SIZE (20)
#define UDP_IP_HEADER_LENGTH_BYTES (28)

View File

@ -27,7 +27,7 @@ target_compile_definitions(gotthardDetectorServer_virtual
)
target_link_libraries(gotthardDetectorServer_virtual
PUBLIC pthread rt slsProjectCWarnings
PUBLIC pthread rt slsProjectCSettings
)
set_target_properties(gotthardDetectorServer_virtual PROPERTIES

View File

@ -424,7 +424,7 @@ void setupDetector() {
LOG(logINFOBLUE, ("Setting Default parameters\n"));
setSettings(DEFAULT_SETTINGS);
setExtSignal(DEFAULT_TRIGGER_MODE);
setExtSignal(0, DEFAULT_TRIGGER_MODE);
setTiming(DEFAULT_TIMING_MODE);
setNumFrames(DEFAULT_NUM_FRAMES);
setNumTriggers(DEFAULT_NUM_CYCLES);
@ -880,10 +880,11 @@ int setDelayAfterTrigger(int64_t val) {
val += masterdefaultdelay;
LOG(logINFO, ("\tActual Delay (master): %lld\n", (long long int)val));
}
val = (val * 1E-9 * CLK_FREQ) +
0.5; // because of the master delay of 62 ns (not really double of
// clkfreq), losing precision and 0 delay becomes -31ns, so adding
// +0.5. Also adding +0.5 for more tolerance for gotthard1.
val =
(val * 1E-9 * CLK_FREQ) +
0.5; // because of the master delay of 62 ns (not really double of
// clkfreq), losing precision and 0 delay becomes -31ns, so adding
// +0.5. Also adding +0.5 for more tolerance for gotthard1.
set64BitReg(val, SET_DELAY_LSB_REG, SET_DELAY_MSB_REG);
// validate for tolerance
@ -1258,7 +1259,8 @@ enum timingMode getTiming() {
}
}
void setExtSignal(enum externalSignalFlag mode) {
void setExtSignal(int signalIndex, enum externalSignalFlag mode) {
LOG(logDEBUG1, ("Setting signal flag[%d] to %d\n", signalIndex, mode));
switch (mode) {
case TRIGGER_IN_RISING_EDGE:
LOG(logINFO,
@ -1277,7 +1279,10 @@ void setExtSignal(enum externalSignalFlag mode) {
setTiming(getTiming());
}
int getExtSignal() { return signalMode; }
int getExtSignal(int signalIndex) {
LOG(logDEBUG1, ("Getting signal flag[%d]\n", signalIndex));
return signalMode;
}
/* configure mac */

View File

@ -42,6 +42,7 @@ enum CLKINDEX { ADC_CLK, NUM_CLOCKS };
#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8)
#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define CLK_FREQ (32007729) /* Hz */
#define MAX_EXT_SIGNALS (1)
/** Firmware Definitions */
#define IP_PACKET_SIZE_NO_ROI \

View File

@ -26,7 +26,7 @@ target_compile_definitions(jungfrauDetectorServer_virtual
)
target_link_libraries(jungfrauDetectorServer_virtual
PUBLIC pthread rt slsProjectCWarnings
PUBLIC pthread rt slsProjectCSettings
)
set_target_properties(jungfrauDetectorServer_virtual PROPERTIES

View File

@ -46,7 +46,6 @@ int highvoltage = 0;
int dacValues[NDAC] = {};
int32_t clkPhase[NUM_CLOCKS] = {};
int detPos[4] = {};
int numUDPInterfaces = 1;
int isInitCheckDone() { return initCheckDone; }

View File

@ -31,7 +31,7 @@ target_compile_definitions(moenchDetectorServer_virtual
)
target_link_libraries(moenchDetectorServer_virtual
PUBLIC pthread rt slsProjectCWarnings
PUBLIC pthread rt slsProjectCSettings
m
)

View File

@ -1255,9 +1255,6 @@ int setDetectorPosition(int pos[]) {
int *getDetectorPosition() { return detPos; }
int enableTenGigabitEthernet(int val) {
#ifdef VIRTUAL
return 0;
#endif
uint32_t addr = CONFIG_REG;
// set

View File

@ -27,7 +27,7 @@ target_compile_definitions(mythen3DetectorServer_virtual
)
target_link_libraries(mythen3DetectorServer_virtual
PUBLIC pthread rt slsProjectCWarnings
PUBLIC pthread rt slsProjectCSettings
)
set_target_properties(mythen3DetectorServer_virtual PROPERTIES

View File

@ -1,326 +1,451 @@
#pragma once
// clang-format off
#define REG_OFFSET (4)
/* Base addresses 0x1804 0000 ---------------------------------------------*/
/* Reconfiguration core for readout pll */
#define BASE_READOUT_PLL (0x0000) // 0x1804_0000 - 0x1804_07FF
#define BASE_READOUT_PLL (0x0000) // 0x1804_0000 - 0x1804_07FF
/* Reconfiguration core for system pll */
#define BASE_SYSTEM_PLL (0x0800) // 0x1804_0800 - 0x1804_0FFF
#define BASE_SYSTEM_PLL (0x0800) // 0x1804_0800 - 0x1804_0FFF
/* Clock Generation */
#define BASE_CLK_GENERATION (0x1000) // 0x1804_1000 - 0x1804_XXXX //TODO
#define BASE_CLK_GENERATION (0x1000) // 0x1804_1000 - 0x1804_XXXX //TODO
/* Base addresses 0x1806 0000 ---------------------------------------------*/
/* General purpose control and status registers */
#define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF
#define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF
// https://git.psi.ch/sls_detectors_firmware/mythen_III_mcb/blob/master/code/hdl/ctrl/ctrl.vhd
/* ASIC Control */
#define BASE_ASIC (0x0100) // 0x1806_0100 - 0x1806_010F
/* ASIC Digital Interface. Data recovery core */
#define BASE_ADIF (0x0110) // 0x1806_0110 - 0x1806_011F
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/2e81ccbdbc5cb81813ba190fbdba43e8d6884eb9/adif/adif_ctrl.vhd
#define BASE_ADIF (0x0110) // 0x1806_0110 - 0x1806_011F
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/xxx/adif/adif_ctrl.vhd
/* Formatting of data core */
#define BASE_FMT (0x0120) // 0x1806_0120 - 0x1806_012F
#define BASE_FMT (0x0120) // 0x1806_0120 - 0x1806_012F
/* Packetizer */
#define BASE_PKT (0x0140) // 0x1806_0140 - 0x1806_014F
#define BASE_PKT (0x0130) // 0x1806_0130 - 0x1806_013F
// https://git.psi.ch/sls_detectors_firmware/mythen_III_mcb/blob/master/code/hdl/pkt/pkt_ctrl.vhd
/* Pattern control and status registers */
#define BASE_PATTERN_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/2e81ccbdbc5cb81813ba190fbdba43e8d6884eb9/pattern_flow/pattern_flow_ctrl.vhd
/** Pipeline (Timing Rec) */
#define BASE_PIPELINE (0x0140) // 0x1806_0140 - 0x1806_014F
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/xxx/MythenIIITriggerBoard/timingReceier.vhd
/* ASIC Exposure Control */
#define BASE_ASIC_EXP (0x0180) // 0x1806_0180 - 0x1806_01BF
/* Pattern control and status */
#define BASE_PATTERN_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/xxx/pattern_flow/pattern_flow_ctrl.vhd
/* Flow control and status */
#define BASE_FLOW_CONTROL (0x00400) // 0x1806_0400 - 0x1806_04FF
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/qsys/flow/flow_ctrl.vhd
/** ASIC Readout Control */
#define BASE_ASIC_RDO (0x00500) // 0x1806_0500 - 0x1806_050F
// https://git.psi.ch/sls_detectors_firmware/mythen_III_mcb/blob/master/code/hdl/asic_rdo/asic_rdo.vhd
/* UDP datagram generator */
#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF
#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF
/* Pattern RAM. Pattern table */
#define BASE_PATTERN_RAM (0x10000) // 0x1807_0000 - 0x1807_FFFF
#define BASE_PATTERN_RAM (0x10000) // 0x1807_0000 - 0x1807_FFFF
/* Clock Generation registers
* ------------------------------------------------------*/
#define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION)
#define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION)
#define PLL_RESET_READOUT_OFST (0)
#define PLL_RESET_READOUT_MSK (0x00000001 << PLL_RESET_READOUT_OFST)
#define PLL_RESET_SYSTEM_OFST (1)
#define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST)
#define PLL_RESET_READOUT_OFST (0)
#define PLL_RESET_READOUT_MSK (0x00000001 << PLL_RESET_READOUT_OFST)
#define PLL_RESET_SYSTEM_OFST (1)
#define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST)
/* Control registers --------------------------------------------------*/
/* Module Control Board Serial Number Register */
#define MCB_SERIAL_NO_REG (0x00 * REG_OFFSET + BASE_CONTROL)
#define MCB_SERIAL_NO_REG (0x00 * REG_OFFSET + BASE_CONTROL)
#define MCB_SERIAL_NO_VRSN_OFST (16)
#define MCB_SERIAL_NO_VRSN_MSK (0x0000001F << MCB_SERIAL_NO_VRSN_OFST)
#define MCB_SERIAL_NO_VRSN_OFST (16)
#define MCB_SERIAL_NO_VRSN_MSK (0x0000001F << MCB_SERIAL_NO_VRSN_OFST)
/* FPGA Version register */
#define FPGA_VERSION_REG (0x01 * REG_OFFSET + BASE_CONTROL)
#define FPGA_VERSION_REG (0x01 * REG_OFFSET + BASE_CONTROL)
#define FPGA_COMPILATION_DATE_OFST (0)
#define FPGA_COMPILATION_DATE_MSK (0x00FFFFFF << FPGA_COMPILATION_DATE_OFST)
#define DETECTOR_TYPE_OFST (24)
#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST)
#define FPGA_COMPILATION_DATE_OFST (0)
#define FPGA_COMPILATION_DATE_MSK (0x00FFFFFF << FPGA_COMPILATION_DATE_OFST)
#define DETECTOR_TYPE_OFST (24)
#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST)
/* API Version Register */
#define API_VERSION_REG (0x02 * REG_OFFSET + BASE_CONTROL)
#define API_VERSION_REG (0x02 * REG_OFFSET + BASE_CONTROL)
#define API_VERSION_OFST (0)
#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
#define API_VERSION_DETECTOR_TYPE_OFST (24) // Not used in software
#define API_VERSION_DETECTOR_TYPE_MSK \
(0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) // Not used in software
#define API_VERSION_OFST (0)
#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
#define API_VERSION_DETECTOR_TYPE_OFST (24) // Not used in software
#define API_VERSION_DETECTOR_TYPE_MSK (0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) // Not used in software
/* Fix pattern register */
#define FIX_PATT_REG (0x03 * REG_OFFSET + BASE_CONTROL)
#define FIX_PATT_VAL (0xACDC2019)
#define FIX_PATT_REG (0x03 * REG_OFFSET + BASE_CONTROL)
#define FIX_PATT_VAL (0xACDC2019)
/* Status register */
#define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL)
#define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL)
/* Look at me register, read only */
#define LOOK_AT_ME_REG \
(0x05 * REG_OFFSET + \
BASE_CONTROL) // Not used in firmware or software, good to play with
#define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL) // Not used in firmware or software, good to play with
#define SYSTEM_STATUS_REG \
(0x06 * REG_OFFSET + BASE_CONTROL) // Not used in software
#define SYSTEM_STATUS_REG (0x06 * REG_OFFSET + BASE_CONTROL) // Not used in software
/* Config RW regiseter */
#define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL)
#define CONFIG_COUNTER_ENA_OFST (0)
#define CONFIG_COUNTER_ENA_MSK (0x00000003 << CONFIG_COUNTER_ENA_OFST)
#define CONFIG_COUNTER_ENA_DEFAULT_VAL \
((0x0 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
#define CONFIG_COUNTER_ENA_1_VAL \
((0x1 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
#define CONFIG_COUNTER_ENA_2_VAL \
((0x2 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
#define CONFIG_COUNTER_ENA_ALL_VAL \
((0x3 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
#define CONFIG_DYNAMIC_RANGE_OFST (4)
#define CONFIG_DYNAMIC_RANGE_MSK (0x00000003 << CONFIG_DYNAMIC_RANGE_OFST)
#define CONFIG_DYNAMIC_RANGE_1_VAL \
((0x0 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_DYNAMIC_RANGE_4_VAL \
((0x1 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_DYNAMIC_RANGE_16_VAL \
((0x2 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_DYNAMIC_RANGE_24_VAL \
((0x3 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL)
#define CONFIG_COUNTER_ENA_OFST (0)
#define CONFIG_COUNTER_ENA_MSK (0x00000003 << CONFIG_COUNTER_ENA_OFST)
#define CONFIG_COUNTER_ENA_DEFAULT_VAL ((0x0 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
#define CONFIG_COUNTER_ENA_1_VAL ((0x1 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
#define CONFIG_COUNTER_ENA_2_VAL ((0x2 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
#define CONFIG_COUNTER_ENA_ALL_VAL ((0x3 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK)
#define CONFIG_DYNAMIC_RANGE_OFST (4)
#define CONFIG_DYNAMIC_RANGE_MSK (0x00000003 << CONFIG_DYNAMIC_RANGE_OFST)
#define CONFIG_DYNAMIC_RANGE_1_VAL ((0x0 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_DYNAMIC_RANGE_4_VAL ((0x1 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_DYNAMIC_RANGE_16_VAL ((0x2 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_DYNAMIC_RANGE_24_VAL ((0x3 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
/* Control RW register */
#define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL)
#define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL)
#define CONTROL_STRT_ACQSTN_OFST (0)
#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST)
#define CONTROL_STP_ACQSTN_OFST (1)
#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST)
#define CONTROL_CRE_RST_OFST (10)
#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST)
#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10?
#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST)
#define CONTROL_CLR_ACQSTN_FIFO_OFST (15)
#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST)
#define CONTROL_PWR_CHIP_OFST (31)
#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST)
#define CONTROL_STRT_ACQSTN_OFST (0)
#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST)
#define CONTROL_STP_ACQSTN_OFST (1)
#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST)
#define CONTROL_STRT_PATTERN_OFST (2)
#define CONTROL_STRT_PATTERN_MSK (0x00000001 << CONTROL_STRT_PATTERN_OFST)
#define CONTROL_CRE_RST_OFST (10)
#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST)
#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10?
#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST)
#define CONTROL_CLR_ACQSTN_FIFO_OFST (15)
#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST)
#define CONTROL_PWR_CHIP_OFST (31)
#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST)
/* Pattern IO Control 64 bit register */
#define PATTERN_IO_CTRL_LSB_REG (0x22 * REG_OFFSET + BASE_CONTROL)
#define PATTERN_IO_CTRL_MSB_REG (0x23 * REG_OFFSET + BASE_CONTROL)
#define PATTERN_IO_CTRL_LSB_REG (0x22 * REG_OFFSET + BASE_CONTROL)
#define PATTERN_IO_CTRL_MSB_REG (0x23 * REG_OFFSET + BASE_CONTROL)
#define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL)
#define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL)
/* Packetizer -------------------------------------------------------------*/
/* Packetizer Config Register */
#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT)
#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT)
#define PKT_CONFIG_NRXR_MAX_OFST (0)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_RXR_START_ID_OFST (8)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
#define PKT_CONFIG_NRXR_MAX_OFST (0)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_RXR_START_ID_OFST (8)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
/* Module Coordinates Register */
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)
#define COORD_ROW_OFST (0)
#define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST)
#define COORD_COL_OFST (16)
#define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST)
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)
#define COORD_ROW_OFST (0)
#define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST)
#define COORD_COL_OFST (16)
#define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST)
/* Module ID Register */
#define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT)
#define COORD_RESERVED_OFST (0)
#define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST)
#define COORD_ID_OFST (16) // Not connected in firmware TODO
#define COORD_ID_MSK \
(0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO
#define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT)
#define COORD_RESERVED_OFST (0)
#define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST)
#define COORD_ID_OFST (16) // Not connected in firmware TODO
#define COORD_ID_MSK (0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO
/* Pipeline -------------------------------------------------------------*/
/** DINF1 Master Input Register */
#define DINF1_REG (0x00 * REG_OFFSET + BASE_PIPELINE)
#define DINF1_TRIGGER_BYPASS_OFST (0)
#define DINF1_TRIGGER_BYPASS_MSK (0x00000001 << DINF1_TRIGGER_BYPASS_OFST)
#define DINF1_BYPASS_GATE_OFST (1)
#define DINF1_BYPASS_GATE_MSK (0x00000007 << DINF1_BYPASS_GATE_OFST)
#define DINF1_INVERSION_OFST (4)
#define DINF1_INVERSION_MSK (0x0000000F << DINF1_INVERSION_OFST)
#define DINF1_RISING_TRIGGER_OFST (8)
#define DINF1_RISING_TRIGGER_MSK (0x00000001 << DINF1_RISING_TRIGGER_OFST)
#define DINF1_RISING_GATE_OFST (9)
#define DINF1_RISING_GATE_MSK (0x00000007 << DINF1_RISING_GATE_OFST)
#define DINF1_FALLING_OFST (12)
#define DINF1_FALLING_MSK (0x0000000F << DINF1_FALLING_OFST)
/** DOUTIF1 Master Ouput Register */
#define DOUTIF1_REG (0x01 * REG_OFFSET + BASE_PIPELINE)
#define DOUTIF1_TRIGGER_BYPASS_OFST (0)
#define DOUTIF1_TRIGGER_BYPASS_MSK (0x00000001 << DOUTIF1_TRIGGER_BYPASS_OFST)
#define DOUTIF1_BYPASS_GATE_OFST (1)
#define DOUTIF1_BYPASS_GATE_MSK (0x00000007 << DOUTIF1_BYPASS_GATE_OFST)
#define DOUTIF1_INVERSION_OFST (4)
#define DOUTIF1_INVERSION_MSK (0x0000000F << DOUTIF1_INVERSION_OFST)
#define DOUTIF1_RISING_TRIGGER_OFST (8)
#define DOUTIF1_RISING_TRIGGER_MSK (0x00000001 << DOUTIF1_RISING_TRIGGER_OFST)
#define DOUTIF1_RISING_GATE_OFST (9)
#define DOUTIF1_RISING_GATE_MSK (0x00000007 << DOUTIF1_RISING_GATE_OFST)
#define DOUTIF1_FALLING_OFST (12)
#define DOUTIF1_FALLING_MSK (0x0000000F << DOUTIF1_FALLING_OFST)
/** DINF2 Slave Input Register */
#define DINF2_REG (0x02 * REG_OFFSET + BASE_PIPELINE)
#define DINF2_BYPASS_OFST (0)
#define DINF2_BYPASS_MSK (0x0000000F << DINF2_BYPASS_OFST)
#define DINF2_INVERSION_OFST (4)
#define DINF2_INVERSION_MSK (0x0000000F << DINF2_INVERSION_OFST)
#define DINF2_RISING_OFST (8)
#define DINF2_RISING_MSK (0x0000000F << DINF2_RISING_OFST)
#define DINF2_FALLING_OFST (12)
#define DINF2_FALLING_MSK (0x0000000F << DINF2_FALLING_OFST)
/* Pulse length after rising edge TODO (maybe fix a value for port 1 later )*/
#define DOUTIF_RISING_LNGTH_REG (0x03 * REG_OFFSET + BASE_PIPELINE)
#define DOUTIF_RISING_LNGTH_PORT_1_OFST (0)
#define DOUTIF_RISING_LNGTH_PORT_1_MSK (0x000000FF << DOUTIF_RISING_LNGTH_PORT_1_OFST)
#define DOUTIF_RISING_LNGTH_PORT_2_OFST (8)
#define DOUTIF_RISING_LNGTH_PORT_2_MSK (0x000000FF << DOUTIF_RISING_LNGTH_PORT_2_OFST)
#define DOUTIF_RISING_LNGTH_PORT_3_OFST (16)
#define DOUTIF_RISING_LNGTH_PORT_3_MSK (0x000000FF << DOUTIF_RISING_LNGTH_PORT_3_OFST)
#define DOUTIF_RISING_LNGTH_PORT_4_OFST (24)
#define DOUTIF_RISING_LNGTH_PORT_4_MSK (0x000000FF << DOUTIF_RISING_LNGTH_PORT_4_OFST)
/* ASIC Exposure Control registers
* --------------------------------------------------*/
/** ASIC Exposure Status register */
#define ASIC_EXP_STATUS_REG (0x00 * REG_OFFSET + BASE_ASIC_EXP)
#define ASIC_EXP_STAT_GATE_SRC_EXT_OFST (0)
#define ASIC_EXP_STAT_GATE_SRC_EXT_MSK (0x00000001 << ASIC_EXP_STAT_GATE_SRC_EXT_OFST)
#define ASIC_EXP_STAT_STO_LNGTH_OFST (16)
#define ASIC_EXP_STAT_STO_LNGTH_MSK (0x000000FF << ASIC_EXP_STAT_STO_LNGTH_OFST)
#define ASIC_EXP_STAT_RSCNTR_LNGTH_OFST (24)
#define ASIC_EXP_STAT_RSCNTR_LNGTH_MSK (0x000000FF << ASIC_EXP_STAT_RSCNTR_LNGTH_OFST)
/** Gate 0 width register */
#define ASIC_EXP_GATE_0_WIDTH_LSB_REG (0x01 * REG_OFFSET + BASE_ASIC_EXP)
#define ASIC_EXP_GATE_0_WIDTH_MSB_REG (0x02 * REG_OFFSET + BASE_ASIC_EXP)
/** Gate 1 width register */
#define ASIC_EXP_GATE_1_WIDTH_LSB_REG (0x03 * REG_OFFSET + BASE_ASIC_EXP)
#define ASIC_EXP_GATE_1_WIDTH_MSB_REG (0x04 * REG_OFFSET + BASE_ASIC_EXP)
/** Gate 2 width register */
#define ASIC_EXP_GATE_2_WIDTH_LSB_REG (0x05 * REG_OFFSET + BASE_ASIC_EXP)
#define ASIC_EXP_GATE_2_WIDTH_MSB_REG (0x06 * REG_OFFSET + BASE_ASIC_EXP)
/** Gate 0 delay register */
#define ASIC_EXP_GATE_0_DELAY_LSB_REG (0x07 * REG_OFFSET + BASE_ASIC_EXP)
#define ASIC_EXP_GATE_0_DELAY_MSB_REG (0x08 * REG_OFFSET + BASE_ASIC_EXP)
/** Gate 1 delay register */
#define ASIC_EXP_GATE_1_DELAY_LSB_REG (0x09 * REG_OFFSET + BASE_ASIC_EXP)
#define ASIC_EXP_GATE_1_DELAY_MSB_REG (0x0A * REG_OFFSET + BASE_ASIC_EXP)
/** Gate 2 delay register */
#define ASIC_EXP_GATE_2_DELAY_LSB_REG (0x0B * REG_OFFSET + BASE_ASIC_EXP)
#define ASIC_EXP_GATE_2_DELAY_MSB_REG (0x0C * REG_OFFSET + BASE_ASIC_EXP)
/** Gate period register */
#define ASIC_EXP_GATE_PERIOD_LSB_REG (0x0D * REG_OFFSET + BASE_ASIC_EXP)
#define ASIC_EXP_GATE_PERIOD_MSB_REG (0x0E * REG_OFFSET + BASE_ASIC_EXP)
/** Number of Internal Gates register */
#define ASIC_EXP_INT_GATE_NUMBER_REG (0x0F * REG_OFFSET + BASE_ASIC_EXP)
/** Number of Internal Gates register */
#define ASIC_EXP_EXT_GATE_NUMBER_REG (0x10 * REG_OFFSET + BASE_ASIC_EXP)
/* Pattern Control registers
* --------------------------------------------------*/
/* Pattern status Register*/
#define PAT_STATUS_REG (0x00 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PAT_STATUS_RUN_BUSY_OFST (0)
#define PAT_STATUS_RUN_BUSY_MSK (0x00000001 << PAT_STATUS_RUN_BUSY_OFST)
#define PAT_STATUS_WAIT_FOR_TRGGR_OFST (3)
#define PAT_STATUS_WAIT_FOR_TRGGR_MSK \
(0x00000001 << PAT_STATUS_WAIT_FOR_TRGGR_OFST)
#define PAT_STATUS_DLY_BFRE_TRGGR_OFST (4)
#define PAT_STATUS_DLY_BFRE_TRGGR_MSK \
(0x00000001 << PAT_STATUS_DLY_BFRE_TRGGR_OFST)
#define PAT_STATUS_FIFO_FULL_OFST (5)
#define PAT_STATUS_FIFO_FULL_MSK (0x00000001 << PAT_STATUS_FIFO_FULL_OFST)
#define PAT_STATUS_DLY_AFTR_TRGGR_OFST (15)
#define PAT_STATUS_DLY_AFTR_TRGGR_MSK \
(0x00000001 << PAT_STATUS_DLY_AFTR_TRGGR_OFST)
#define PAT_STATUS_CSM_BUSY_OFST (17)
#define PAT_STATUS_CSM_BUSY_MSK (0x00000001 << PAT_STATUS_CSM_BUSY_OFST)
/* Delay left 64bit Register */
#define GET_DELAY_LSB_REG (0x02 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define GET_DELAY_MSB_REG (0x03 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Triggers left 64bit Register */
#define GET_CYCLES_LSB_REG (0x04 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define GET_CYCLES_MSB_REG (0x05 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Frames left 64bit Register */
#define GET_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define GET_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Period left 64bit Register */
#define GET_PERIOD_LSB_REG (0x08 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define GET_PERIOD_MSB_REG (0x09 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Time from Start 64 bit register */
#define TIME_FROM_START_LSB_REG (0x0A * REG_OFFSET + BASE_PATTERN_CONTROL)
#define TIME_FROM_START_MSB_REG (0x0B * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Get Frames from Start 64 bit register (frames from last reset using
* CONTROL_CRST) */
#define FRAMES_FROM_START_LSB_REG (0x0C * REG_OFFSET + BASE_PATTERN_CONTROL)
#define FRAMES_FROM_START_MSB_REG (0x0D * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Measurement Time 64 bit register (timestamp at a frame start until reset)*/
#define START_FRAME_TIME_LSB_REG (0x0E * REG_OFFSET + BASE_PATTERN_CONTROL)
#define START_FRAME_TIME_MSB_REG (0x0F * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Delay 64bit Write-register */
#define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Cylces 64bit Write-register */
#define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Frames 64bit Write-register */
#define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Period 64bit Write-register */
#define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* External Signal register */
#define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define EXT_SIGNAL_OFST (0)
#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST)
/* Trigger Delay 64 bit register */
#define SET_TRIGGER_DELAY_LSB_REG (0x32 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define SET_TRIGGER_DELAY_MSB_REG (0x33 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PAT_STATUS_REG (0x00 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PAT_STATUS_RUN_BUSY_OFST (0)
#define PAT_STATUS_RUN_BUSY_MSK (0x00000001 << PAT_STATUS_RUN_BUSY_OFST)
/* Pattern Limit RW Register */
#define PATTERN_LIMIT_REG (0x40 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LIMIT_REG (0x40 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LIMIT_STRT_OFST (0)
#define PATTERN_LIMIT_STRT_MSK (0x00001FFF << PATTERN_LIMIT_STRT_OFST)
#define PATTERN_LIMIT_STP_OFST (16)
#define PATTERN_LIMIT_STP_MSK (0x00001FFF << PATTERN_LIMIT_STP_OFST)
#define PATTERN_LIMIT_STRT_OFST (0)
#define PATTERN_LIMIT_STRT_MSK (0x00001FFF << PATTERN_LIMIT_STRT_OFST)
#define PATTERN_LIMIT_STP_OFST (16)
#define PATTERN_LIMIT_STP_MSK (0x00001FFF << PATTERN_LIMIT_STP_OFST)
/** Pattern Mask 64 bit RW regiser */
#define PATTERN_MASK_LSB_REG (0x42 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_MASK_MSB_REG (0x43 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_MASK_LSB_REG (0x42 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_MASK_MSB_REG (0x43 * REG_OFFSET + BASE_PATTERN_CONTROL)
/** Pattern Set 64 bit RW regiser */
#define PATTERN_SET_LSB_REG (0x44 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_SET_MSB_REG (0x45 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_SET_LSB_REG (0x44 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_SET_MSB_REG (0x45 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Pattern Wait Timer 0 64bit RW Register */
#define PATTERN_WAIT_TIMER_0_LSB_REG (0x60 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_TIMER_0_MSB_REG (0x61 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_TIMER_0_LSB_REG (0x60 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_TIMER_0_MSB_REG (0x61 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Pattern Wait 0 RW Register*/
#define PATTERN_WAIT_0_ADDR_REG (0x62 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_0_ADDR_REG (0x62 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_0_ADDR_OFST (0)
#define PATTERN_WAIT_0_ADDR_MSK (0x00001FFF << PATTERN_WAIT_0_ADDR_OFST)
#define PATTERN_WAIT_0_ADDR_OFST (0)
#define PATTERN_WAIT_0_ADDR_MSK (0x00001FFF << PATTERN_WAIT_0_ADDR_OFST)
/* Pattern Loop 0 Iteration RW Register */
#define PATTERN_LOOP_0_ITERATION_REG (0x63 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LOOP_0_ITERATION_REG (0x63 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Pattern Loop 0 Address RW Register */
#define PATTERN_LOOP_0_ADDR_REG (0x64 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LOOP_0_ADDR_REG (0x64 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LOOP_0_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_0_ADDR_STRT_MSK \
(0x00001FFF << PATTERN_LOOP_0_ADDR_STRT_OFST)
#define PATTERN_LOOP_0_ADDR_STP_OFST (16)
#define PATTERN_LOOP_0_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_0_ADDR_STP_OFST)
#define PATTERN_LOOP_0_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_0_ADDR_STRT_MSK (0x00001FFF << PATTERN_LOOP_0_ADDR_STRT_OFST)
#define PATTERN_LOOP_0_ADDR_STP_OFST (16)
#define PATTERN_LOOP_0_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_0_ADDR_STP_OFST)
/* Pattern Wait Timer 1 64bit RW Register */
#define PATTERN_WAIT_TIMER_1_LSB_REG (0x65 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_TIMER_1_MSB_REG (0x66 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_TIMER_1_LSB_REG (0x65 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_TIMER_1_MSB_REG (0x66 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Pattern Wait 1 RW Register*/
#define PATTERN_WAIT_1_ADDR_REG (0x67 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_1_ADDR_REG (0x67 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_1_ADDR_OFST (0)
#define PATTERN_WAIT_1_ADDR_MSK (0x00001FFF << PATTERN_WAIT_1_ADDR_OFST)
#define PATTERN_WAIT_1_ADDR_OFST (0)
#define PATTERN_WAIT_1_ADDR_MSK (0x00001FFF << PATTERN_WAIT_1_ADDR_OFST)
/* Pattern Loop 1 Iteration RW Register */
#define PATTERN_LOOP_1_ITERATION_REG (0x68 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LOOP_1_ITERATION_REG (0x68 * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Pattern Loop 1 Address RW Register */
#define PATTERN_LOOP_1_ADDR_REG (0x69 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LOOP_1_ADDR_REG (0x69 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LOOP_1_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_1_ADDR_STRT_MSK \
(0x00001FFF << PATTERN_LOOP_1_ADDR_STRT_OFST)
#define PATTERN_LOOP_1_ADDR_STP_OFST (16)
#define PATTERN_LOOP_1_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_1_ADDR_STP_OFST)
#define PATTERN_LOOP_1_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_1_ADDR_STRT_MSK (0x00001FFF << PATTERN_LOOP_1_ADDR_STRT_OFST)
#define PATTERN_LOOP_1_ADDR_STP_OFST (16)
#define PATTERN_LOOP_1_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_1_ADDR_STP_OFST)
/* Pattern Wait Timer 2 64bit RW Register */
#define PATTERN_WAIT_TIMER_2_LSB_REG (0x6A * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_TIMER_2_MSB_REG (0x6B * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_TIMER_2_LSB_REG (0x6A * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_TIMER_2_MSB_REG (0x6B * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Pattern Wait 2 RW Register*/
#define PATTERN_WAIT_2_ADDR_REG (0x6C * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_2_ADDR_REG (0x6C * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_WAIT_2_ADDR_OFST (0)
#define PATTERN_WAIT_2_ADDR_MSK (0x00001FFF << PATTERN_WAIT_2_ADDR_OFST)
#define PATTERN_WAIT_2_ADDR_OFST (0)
#define PATTERN_WAIT_2_ADDR_MSK (0x00001FFF << PATTERN_WAIT_2_ADDR_OFST)
/* Pattern Loop 2 Iteration RW Register */
#define PATTERN_LOOP_2_ITERATION_REG (0x6D * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LOOP_2_ITERATION_REG (0x6D * REG_OFFSET + BASE_PATTERN_CONTROL)
/* Pattern Loop 0 Address RW Register */
#define PATTERN_LOOP_2_ADDR_REG (0x6E * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LOOP_2_ADDR_REG (0x6E * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PATTERN_LOOP_2_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_2_ADDR_STRT_MSK \
(0x00001FFF << PATTERN_LOOP_2_ADDR_STRT_OFST)
#define PATTERN_LOOP_2_ADDR_STP_OFST (16)
#define PATTERN_LOOP_2_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_2_ADDR_STP_OFST)
#define PATTERN_LOOP_2_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_2_ADDR_STRT_MSK (0x00001FFF << PATTERN_LOOP_2_ADDR_STRT_OFST)
#define PATTERN_LOOP_2_ADDR_STP_OFST (16)
#define PATTERN_LOOP_2_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_2_ADDR_STP_OFST)
/* Pattern RAM registers --------------------------------------------------*/
/* Register of first word */
#define PATTERN_STEP0_LSB_REG (0x0 * REG_OFFSET + BASE_PATTERN_RAM)
#define PATTERN_STEP0_MSB_REG (0x1 * REG_OFFSET + BASE_PATTERN_RAM)
#define PATTERN_STEP0_LSB_REG (0x0 * REG_OFFSET + BASE_PATTERN_RAM)
#define PATTERN_STEP0_MSB_REG (0x1 * REG_OFFSET + BASE_PATTERN_RAM)
/* Flow Control registers
* --------------------------------------------------*/
/* Flow status Register*/
#define FLOW_STATUS_REG (0x00 * REG_OFFSET + BASE_FLOW_CONTROL)
#define FLOW_STATUS_RUN_BUSY_OFST (0)
#define FLOW_STATUS_RUN_BUSY_MSK (0x00000001 << FLOW_STATUS_RUN_BUSY_OFST)
#define FLOW_STATUS_WAIT_FOR_TRGGR_OFST (3)
#define FLOW_STATUS_WAIT_FOR_TRGGR_MSK (0x00000001 << FLOW_STATUS_WAIT_FOR_TRGGR_OFST)
#define FLOW_STATUS_DLY_BFRE_TRGGR_OFST (4)
#define FLOW_STATUS_DLY_BFRE_TRGGR_MSK (0x00000001 << FLOW_STATUS_DLY_BFRE_TRGGR_OFST)
#define FLOW_STATUS_FIFO_FULL_OFST (5)
#define FLOW_STATUS_FIFO_FULL_MSK (0x00000001 << FLOW_STATUS_FIFO_FULL_OFST)
#define FLOW_STATUS_DLY_AFTR_TRGGR_OFST (15)
#define FLOW_STATUS_DLY_AFTR_TRGGR_MSK (0x00000001 << FLOW_STATUS_DLY_AFTR_TRGGR_OFST)
#define FLOW_STATUS_CSM_BUSY_OFST (17)
#define FLOW_STATUS_CSM_BUSY_MSK (0x00000001 << FLOW_STATUS_CSM_BUSY_OFST)
/* Delay left 64bit Register */
#define GET_DELAY_LSB_REG (0x02 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_DELAY_MSB_REG (0x03 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Triggers left 64bit Register */
#define GET_CYCLES_LSB_REG (0x04 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_CYCLES_MSB_REG (0x05 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Frames left 64bit Register */
#define GET_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Period left 64bit Register */
#define GET_PERIOD_LSB_REG (0x08 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_PERIOD_MSB_REG (0x09 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Time from Start 64 bit register */
#define TIME_FROM_START_LSB_REG (0x0A * REG_OFFSET + BASE_FLOW_CONTROL)
#define TIME_FROM_START_MSB_REG (0x0B * REG_OFFSET + BASE_FLOW_CONTROL)
/* Get Frames from Start 64 bit register (frames from last reset using
* CONTROL_CRST) */
#define FRAMES_FROM_START_LSB_REG (0x0C * REG_OFFSET + BASE_FLOW_CONTROL)
#define FRAMES_FROM_START_MSB_REG (0x0D * REG_OFFSET + BASE_FLOW_CONTROL)
/* Measurement Time 64 bit register (timestamp at a frame start until reset)*/
#define START_FRAME_TIME_LSB_REG (0x0E * REG_OFFSET + BASE_FLOW_CONTROL)
#define START_FRAME_TIME_MSB_REG (0x0F * REG_OFFSET + BASE_FLOW_CONTROL)
/* Delay 64bit Write-register */
#define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Cylces 64bit Write-register */
#define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Frames 64bit Write-register */
#define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Period 64bit Write-register */
#define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL)
/* External Signal register */
#define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_FLOW_CONTROL)
#define EXT_SIGNAL_OFST (0)
#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST)
/* Trigger Delay 64 bit register */
#define SET_TRIGGER_DELAY_LSB_REG (0x32 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_TRIGGER_DELAY_MSB_REG (0x33 * REG_OFFSET + BASE_FLOW_CONTROL)
/* ASIC Readout Control registers
* --------------------------------------------------*/
#define ASIC_RDO_CONFIG_REG (0x01 * REG_OFFSET + BASE_ASIC_RDO)
#define ASICRDO_CNFG_RESSTRG_LNGTH_OFST (0)
#define ASICRDO_CNFG_RESSTRG_LNGTH_MSK (0x000000FF << ASICRDO_CNFG_RESSTRG_LNGTH_OFST)
// clang-format on

View File

@ -315,7 +315,6 @@ u_int32_t getDetectorIP() {
/* initialization */
void initControlServer() {
CreateNotificationForCriticalTasks();
if (initError == OK) {
setupDetector();
}
@ -416,6 +415,7 @@ void setupDetector() {
// defaults
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
setDefaultDacs();
setASICDefaults();
// dynamic range
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
@ -425,10 +425,16 @@ void setupDetector() {
// Initialization of acquistion parameters
setNumFrames(DEFAULT_NUM_FRAMES);
setNumTriggers(DEFAULT_NUM_CYCLES);
setExpTime(DEFAULT_EXPTIME);
setPeriod(DEFAULT_PERIOD);
setDelayAfterTrigger(DEFAULT_DELAY_AFTER_TRIGGER);
setTiming(DEFAULT_TIMING_MODE);
setNumIntGates(DEFAULT_INTERNAL_GATES);
setNumGates(DEFAULT_EXTERNAL_GATES);
for (int i = 0; i != 3; ++i) {
setExpTime(i, DEFAULT_GATE_WIDTH);
setGateDelay(i, DEFAULT_GATE_DELAY);
}
setInitialExtSignals();
}
int setDefaultDacs() {
@ -447,6 +453,25 @@ int setDefaultDacs() {
return ret;
}
void setASICDefaults() {
uint32_t val = bus_r(ASIC_EXP_STATUS_REG);
val &= (~ASIC_EXP_STAT_STO_LNGTH_MSK);
val |= ((DEFAULT_ASIC_LATCHING_NUM_PULSES << ASIC_EXP_STAT_STO_LNGTH_OFST) &
ASIC_EXP_STAT_STO_LNGTH_MSK);
val &= (~ASIC_EXP_STAT_RSCNTR_LNGTH_MSK);
val |=
((DEFAULT_ASIC_LATCHING_NUM_PULSES << ASIC_EXP_STAT_RSCNTR_LNGTH_OFST) &
ASIC_EXP_STAT_RSCNTR_LNGTH_MSK);
bus_w(ASIC_EXP_STATUS_REG, val);
val = bus_r(ASIC_RDO_CONFIG_REG);
val &= (~ASICRDO_CNFG_RESSTRG_LNGTH_MSK);
val |=
((DEFAULT_ASIC_LATCHING_NUM_PULSES << ASICRDO_CNFG_RESSTRG_LNGTH_OFST) &
ASICRDO_CNFG_RESSTRG_LNGTH_MSK);
bus_w(ASIC_RDO_CONFIG_REG, val);
}
/* firmware functions (resets) */
void cleanFifos() {
@ -717,10 +742,8 @@ int setTrimbits(int *trimbits) {
int start = 0, nloop = 0;
setPatternLoop(-1, &start, &iaddr, &nloop);
}
// load the trimbits
#ifndef VIRTUAL
startStateMachine();
#endif
// send pattern to the chips
startPattern();
}
// copy trimbits locally
@ -786,40 +809,18 @@ int64_t getNumTriggers() {
return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
}
int setExpTime(int64_t val) {
if (val < 0) {
LOG(logERROR, ("Invalid exptime: %lld ns\n", (long long int)val));
return FAIL;
}
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
val *= (1E-9 * getFrequency(SYSTEM_C0));
setPatternWaitTime(0, val);
// validate for tolerance
int64_t retval = getExpTime();
val /= (1E-9 * getFrequency(SYSTEM_C0));
if (val != retval) {
return FAIL;
}
return OK;
}
int64_t getExpTime() {
return setPatternWaitTime(0, -1) / (1E-9 * getFrequency(SYSTEM_C0));
}
int setPeriod(int64_t val) {
if (val < 0) {
LOG(logERROR, ("Invalid period: %lld ns\n", (long long int)val));
return FAIL;
}
LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
val *= (1E-9 * FIXED_PLL_FREQUENCY);
val *= (1E-9 * getFrequency(SYSTEM_C2));
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
// validate for tolerance
int64_t retval = getPeriod();
val /= (1E-9 * FIXED_PLL_FREQUENCY);
val /= (1E-9 * getFrequency(SYSTEM_C2));
if (val != retval) {
return FAIL;
}
@ -828,7 +829,175 @@ int setPeriod(int64_t val) {
int64_t getPeriod() {
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG) /
(1E-9 * FIXED_PLL_FREQUENCY);
(1E-9 * getFrequency(SYSTEM_C2));
}
void setNumIntGates(int val) {
if (val > 0) {
LOG(logINFO,
("Setting number of Internal Gates %lld\n", (long long int)val));
bus_w(ASIC_EXP_INT_GATE_NUMBER_REG, val);
}
}
void setNumGates(int val) {
if (val > 0) {
LOG(logINFO, ("Setting number of Gates %lld\n", (long long int)val));
bus_w(ASIC_EXP_EXT_GATE_NUMBER_REG, val);
}
}
int getNumGates() { return bus_r(ASIC_EXP_EXT_GATE_NUMBER_REG); }
void updateGatePeriod() {
uint64_t max = 0;
for (int i = 0; i != 3; ++i) {
// TODO: only those counters enabled (when updated to mask in firmware)
uint64_t sum = getExpTime(i) + getGateDelay(i);
if (sum > max) {
max = sum;
}
}
LOG(logINFO, ("\tSetting Gate Period to %lld ns\n", (long long int)max));
max *= (1E-9 * getFrequency(SYSTEM_C2));
set64BitReg(max, ASIC_EXP_GATE_PERIOD_LSB_REG,
ASIC_EXP_GATE_PERIOD_MSB_REG);
}
int64_t getGatePeriod() {
return get64BitReg(ASIC_EXP_GATE_PERIOD_LSB_REG,
ASIC_EXP_GATE_PERIOD_MSB_REG) /
(1E-9 * getFrequency(SYSTEM_C2));
}
int setExpTime(int gateIndex, int64_t val) {
uint32_t alsb = 0;
uint32_t amsb = 0;
switch (gateIndex) {
case 0:
alsb = ASIC_EXP_GATE_0_WIDTH_LSB_REG;
amsb = ASIC_EXP_GATE_0_WIDTH_MSB_REG;
break;
case 1:
alsb = ASIC_EXP_GATE_1_WIDTH_LSB_REG;
amsb = ASIC_EXP_GATE_1_WIDTH_MSB_REG;
break;
case 2:
alsb = ASIC_EXP_GATE_2_WIDTH_LSB_REG;
amsb = ASIC_EXP_GATE_2_WIDTH_MSB_REG;
break;
default:
LOG(logERROR, ("Invalid gate index: %d\n", gateIndex));
return FAIL;
}
if (val < 0) {
LOG(logERROR, ("Invalid exptime (index:%d): %lld ns\n", gateIndex,
(long long int)val));
return FAIL;
}
LOG(logINFO, ("Setting exptime %lld ns (index:%d)\n", (long long int)val,
gateIndex));
val *= (1E-9 * getFrequency(SYSTEM_C2));
set64BitReg(val, alsb, amsb);
// validate for tolerance
int64_t retval = getExpTime(gateIndex);
val /= (1E-9 * getFrequency(SYSTEM_C2));
if (val != retval) {
return FAIL;
}
updateGatePeriod();
return OK;
}
int64_t getExpTime(int gateIndex) {
uint32_t alsb = 0;
uint32_t amsb = 0;
switch (gateIndex) {
case 0:
alsb = ASIC_EXP_GATE_0_WIDTH_LSB_REG;
amsb = ASIC_EXP_GATE_0_WIDTH_MSB_REG;
break;
case 1:
alsb = ASIC_EXP_GATE_1_WIDTH_LSB_REG;
amsb = ASIC_EXP_GATE_1_WIDTH_MSB_REG;
break;
case 2:
alsb = ASIC_EXP_GATE_2_WIDTH_LSB_REG;
amsb = ASIC_EXP_GATE_2_WIDTH_MSB_REG;
break;
default:
LOG(logERROR, ("Invalid gate index: %d\n", gateIndex));
return -1;
}
return get64BitReg(alsb, amsb) / (1E-9 * getFrequency(SYSTEM_C2));
}
int setGateDelay(int gateIndex, int64_t val) {
uint32_t alsb = 0;
uint32_t amsb = 0;
switch (gateIndex) {
case 0:
alsb = ASIC_EXP_GATE_0_DELAY_LSB_REG;
amsb = ASIC_EXP_GATE_0_DELAY_MSB_REG;
break;
case 1:
alsb = ASIC_EXP_GATE_1_DELAY_LSB_REG;
amsb = ASIC_EXP_GATE_1_DELAY_MSB_REG;
break;
case 2:
alsb = ASIC_EXP_GATE_2_DELAY_LSB_REG;
amsb = ASIC_EXP_GATE_2_DELAY_MSB_REG;
break;
default:
LOG(logERROR, ("Invalid gate index: %d\n", gateIndex));
return FAIL;
}
if (val < 0) {
LOG(logERROR, ("Invalid gate delay (index:%d): %lld ns\n", gateIndex,
(long long int)val));
return FAIL;
}
LOG(logINFO, ("Setting gate delay %lld ns (index:%d)\n", (long long int)val,
gateIndex));
val *= (1E-9 * getFrequency(SYSTEM_C2));
set64BitReg(val, alsb, amsb);
// validate for tolerance
int64_t retval = getGateDelay(gateIndex);
val /= (1E-9 * getFrequency(SYSTEM_C2));
if (val != retval) {
return FAIL;
}
updateGatePeriod();
return OK;
}
int64_t getGateDelay(int gateIndex) {
uint32_t alsb = 0;
uint32_t amsb = 0;
switch (gateIndex) {
case 0:
alsb = ASIC_EXP_GATE_0_DELAY_LSB_REG;
amsb = ASIC_EXP_GATE_0_DELAY_MSB_REG;
break;
case 1:
alsb = ASIC_EXP_GATE_1_DELAY_LSB_REG;
amsb = ASIC_EXP_GATE_1_DELAY_MSB_REG;
break;
case 2:
alsb = ASIC_EXP_GATE_2_DELAY_LSB_REG;
amsb = ASIC_EXP_GATE_2_DELAY_MSB_REG;
break;
default:
LOG(logERROR, ("Invalid gate index: %d\n", gateIndex));
return -1;
}
return get64BitReg(alsb, amsb) / (1E-9 * getFrequency(SYSTEM_C2));
}
void setCounterMask(uint32_t arg) {
@ -855,6 +1024,8 @@ void setCounterMask(uint32_t arg) {
bus_w(addr, bus_r(addr) & ~CONFIG_COUNTER_ENA_MSK);
bus_w(addr, bus_r(addr) | val);
LOG(logDEBUG, ("Config Reg: 0x%x\n", bus_r(addr)));
updateGatePeriod();
}
uint32_t getCounterMask() {
@ -900,12 +1071,12 @@ int setDelayAfterTrigger(int64_t val) {
return FAIL;
}
LOG(logINFO, ("Setting delay after trigger %lld ns\n", (long long int)val));
val *= (1E-9 * FIXED_PLL_FREQUENCY);
val *= (1E-9 * getFrequency(SYSTEM_C2));
set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
// validate for tolerance
int64_t retval = getDelayAfterTrigger();
val /= (1E-9 * FIXED_PLL_FREQUENCY);
val /= (1E-9 * getFrequency(SYSTEM_C2));
if (val != retval) {
return FAIL;
}
@ -914,7 +1085,7 @@ int setDelayAfterTrigger(int64_t val) {
int64_t getDelayAfterTrigger() {
return get64BitReg(SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG) /
(1E-9 * FIXED_PLL_FREQUENCY);
(1E-9 * getFrequency(SYSTEM_C2));
}
int64_t getNumFramesLeft() {
@ -927,12 +1098,12 @@ int64_t getNumTriggersLeft() {
int64_t getDelayAfterTriggerLeft() {
return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) /
(1E-9 * FIXED_PLL_FREQUENCY);
(1E-9 * getFrequency(SYSTEM_C2));
}
int64_t getPeriodLeft() {
return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG) /
(1E-9 * FIXED_PLL_FREQUENCY);
(1E-9 * getFrequency(SYSTEM_C2));
}
int64_t getFramesFromStart() {
@ -1017,23 +1188,167 @@ void setTiming(enum timingMode arg) {
if (arg != GET_TIMING_MODE) {
switch (arg) {
case AUTO_TIMING:
LOG(logINFO, ("Set Timing: Auto\n"));
LOG(logINFO, ("Set Timing: Auto (Int. Trigger, Int. Gating)\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
bus_w(ASIC_EXP_STATUS_REG,
bus_r(ASIC_EXP_STATUS_REG) & ~ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
break;
case TRIGGER_EXPOSURE:
LOG(logINFO, ("Set Timing: Trigger\n"));
LOG(logINFO, ("Set Timing: Trigger (Ext. Trigger, Int. Gating)\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
bus_w(ASIC_EXP_STATUS_REG,
bus_r(ASIC_EXP_STATUS_REG) & ~ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
break;
case GATED:
LOG(logINFO, ("Set Timing: Gating (Int. Trigger, Ext. Gating)\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
bus_w(ASIC_EXP_STATUS_REG,
bus_r(ASIC_EXP_STATUS_REG) | ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
break;
case TRIGGER_GATED:
LOG(logINFO,
("Set Timing: Trigger_Gating (Ext. Trigger, Ext. Gating)\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
bus_w(ASIC_EXP_STATUS_REG,
bus_r(ASIC_EXP_STATUS_REG) | ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
break;
default:
LOG(logERROR, ("Unknown timing mode %d\n", arg));
return;
}
}
}
enum timingMode getTiming() {
if (bus_r(EXT_SIGNAL_REG) == EXT_SIGNAL_MSK)
return TRIGGER_EXPOSURE;
return AUTO_TIMING;
uint32_t extTrigger = (bus_r(EXT_SIGNAL_REG) & EXT_SIGNAL_MSK);
uint32_t extGate =
(bus_r(ASIC_EXP_STATUS_REG) & ASIC_EXP_STAT_GATE_SRC_EXT_MSK);
if (extTrigger) {
if (extGate) {
// external trigger, external gating
return TRIGGER_GATED;
} else {
// external trigger, internal gating
return TRIGGER_EXPOSURE;
}
} else {
if (extGate) {
// internal trigger, external gating
return GATED;
} else {
// internal trigger, internal gating
return AUTO_TIMING;
}
}
}
void setInitialExtSignals() {
LOG(logINFOBLUE, ("Setting Initial External Signals\n"));
// default, everything is 0
bus_w(DINF1_REG, 0);
bus_w(DOUTIF1_REG, 0);
bus_w(DINF2_REG, 0);
bus_w(DOUTIF_RISING_LNGTH_REG, 0);
// bypass everything
// (except master triggers can edge detect)
bus_w(DINF1_REG, DINF1_BYPASS_GATE_MSK);
bus_w(DOUTIF1_REG, DOUTIF1_BYPASS_GATE_MSK);
bus_w(DINF2_REG, DINF2_BYPASS_MSK);
// master input/output can edge detect, so rising is 1
bus_w(DINF1_REG, bus_r(DINF1_REG) | DINF1_RISING_TRIGGER_MSK);
bus_w(DOUTIF1_REG, bus_r(DOUTIF1_REG) | DOUTIF1_RISING_TRIGGER_MSK);
// set default value for master output rising pulse length for port1
bus_w(DOUTIF_RISING_LNGTH_REG,
bus_r(DOUTIF_RISING_LNGTH_REG) & ~DOUTIF_RISING_LNGTH_PORT_1_MSK);
bus_w(DOUTIF_RISING_LNGTH_REG, bus_r(DOUTIF_RISING_LNGTH_REG) |
((DEFAULT_MSTR_OTPT_P1_NUM_PULSES
<< DOUTIF_RISING_LNGTH_PORT_1_OFST) &
DOUTIF_RISING_LNGTH_PORT_1_MSK));
}
void setExtSignal(int signalIndex, enum externalSignalFlag mode) {
LOG(logDEBUG1, ("Setting signal flag[%d] to %d\n", signalIndex, mode));
if (signalIndex == 0 && mode != TRIGGER_IN_RISING_EDGE &&
mode != TRIGGER_IN_FALLING_EDGE) {
return;
}
// getting addr and mask for each signal
uint32_t addr = 0;
uint32_t mask = 0;
if (signalIndex <= 3) {
addr = DINF1_REG;
int offset = DINF1_INVERSION_OFST + signalIndex;
mask = (1 << offset);
} else {
addr = DOUTIF1_REG;
int offset = DOUTIF1_INVERSION_OFST + signalIndex - 4;
mask = (1 << offset);
}
LOG(logDEBUG, ("addr: 0x%x mask:0x%x\n", addr, mask));
switch (mode) {
case TRIGGER_IN_RISING_EDGE:
LOG(logINFO, ("Setting External Master Input Signal flag: Trigger in "
"Rising Edge\n"));
bus_w(addr, bus_r(addr) & ~mask);
break;
case TRIGGER_IN_FALLING_EDGE:
LOG(logINFO, ("Setting External Master Input Signal flag: Trigger in "
"Falling Edge\n"));
bus_w(addr, bus_r(addr) | mask);
break;
case INVERSION_ON:
LOG(logINFO, ("Setting External Master %s Signal flag: Inversion on\n",
(signalIndex <= 3 ? "Input" : "Output")));
bus_w(addr, bus_r(addr) | mask);
break;
case INVERSION_OFF:
LOG(logINFO, ("Setting External Master %s Signal flag: Inversion offn",
(signalIndex <= 3 ? "Input" : "Output")));
bus_w(addr, bus_r(addr) & ~mask);
break;
default:
LOG(logERROR,
("Extsig (signal mode) %d not defined for this detector\n", mode));
return;
}
}
int getExtSignal(int signalIndex) {
// getting addr and mask for each signal
uint32_t addr = 0;
uint32_t mask = 0;
if (signalIndex <= 3) {
addr = DINF1_REG;
int offset = DINF1_INVERSION_OFST + signalIndex;
mask = (1 << offset);
} else {
addr = DOUTIF1_REG;
int offset = DOUTIF1_INVERSION_OFST + signalIndex - 4;
mask = (1 << offset);
}
LOG(logDEBUG, ("addr: 0x%x mask:0x%x\n", addr, mask));
int val = bus_r(addr) & mask;
// master input trigger signal
if (signalIndex == 0) {
if (val) {
return TRIGGER_IN_FALLING_EDGE;
} else {
return TRIGGER_IN_RISING_EDGE;
}
} else {
if (val) {
return INVERSION_ON;
} else {
return INVERSION_OFF;
}
}
}
int configureMAC() {
@ -1187,6 +1502,16 @@ int *getDetectorPosition() { return detPos; }
/* pattern */
void startPattern() {
LOG(logINFOBLUE, ("Starting Pattern\n"));
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STRT_PATTERN_MSK);
usleep(1);
while (bus_r(PAT_STATUS_REG) & PAT_STATUS_RUN_BUSY_MSK) {
usleep(1);
}
LOG(logINFOBLUE, ("Pattern done\n"));
}
uint64_t readPatternWord(int addr) {
// error (handled in tcp)
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
@ -1727,7 +2052,7 @@ void *start_timer(void *arg) {
int64_t periodNs = getPeriod();
int numFrames = (getNumFrames() * getNumTriggers());
int64_t expUs = getExpTime() / 1000;
int64_t expUs = getGatePeriod() / 1000;
// int dr = setDynamicRange(-1);
int imagesize = calculateDataBytes();
@ -1841,20 +2166,20 @@ enum runStatus getRunStatus() {
}
#endif
LOG(logDEBUG1, ("Getting status\n"));
uint32_t retval = bus_r(PAT_STATUS_REG);
uint32_t retval = bus_r(FLOW_STATUS_REG);
LOG(logINFO, ("Status Register: %08x\n", retval));
enum runStatus s;
// running
if (retval & PAT_STATUS_RUN_BUSY_MSK) {
if (retval & PAT_STATUS_WAIT_FOR_TRGGR_MSK) {
if (retval & FLOW_STATUS_RUN_BUSY_MSK) {
if (retval & FLOW_STATUS_WAIT_FOR_TRGGR_MSK) {
LOG(logINFOBLUE, ("Status: WAITING\n"));
s = WAITING;
} else {
if (retval & PAT_STATUS_DLY_BFRE_TRGGR_MSK) {
if (retval & FLOW_STATUS_DLY_BFRE_TRGGR_MSK) {
LOG(logINFO, ("Status: Delay before Trigger\n"));
} else if (retval & PAT_STATUS_DLY_AFTR_TRGGR_MSK) {
} else if (retval & FLOW_STATUS_DLY_AFTR_TRGGR_MSK) {
LOG(logINFO, ("Status: Delay after Trigger\n"));
}
LOG(logINFOBLUE, ("Status: RUNNING\n"));
@ -1865,10 +2190,10 @@ enum runStatus getRunStatus() {
// not running
else {
// stopped or error
if (retval & PAT_STATUS_FIFO_FULL_MSK) {
if (retval & FLOW_STATUS_FIFO_FULL_MSK) {
LOG(logINFOBLUE, ("Status: STOPPED\n")); // FIFO FULL??
s = STOPPED;
} else if (retval & PAT_STATUS_CSM_BUSY_MSK) {
} else if (retval & FLOW_STATUS_CSM_BUSY_MSK) {
LOG(logINFOBLUE, ("Status: READ MACHINE BUSY\n"));
s = TRANSMITTING;
} else if (!retval) {
@ -1913,7 +2238,7 @@ u_int32_t runBusy() {
}
return virtual_status;
#endif
u_int32_t s = (bus_r(PAT_STATUS_REG) & PAT_STATUS_RUN_BUSY_MSK);
u_int32_t s = (bus_r(FLOW_STATUS_REG) & FLOW_STATUS_RUN_BUSY_MSK);
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
return s;
}

View File

@ -12,7 +12,7 @@
#define NCHAN (128 * NCOUNTERS)
#define NCHIP (10)
#define NDAC (16)
#define HV_SOFT_MAX_VOLTAGE (200)
#define HV_SOFT_MAX_VOLTAGE (500)
#define HV_HARD_MAX_VOLTAGE (530)
#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac")
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
@ -21,21 +21,27 @@
#define TYPE_MYTHEN3_MODULE_VAL (93)
#define TYPE_TOLERANCE (10)
#define TYPE_NO_MODULE_STARTING_VAL (800)
#define MAX_EXT_SIGNALS (8)
/** Default Parameters */
#define DEFAULT_DYNAMIC_RANGE (24)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (100 * 1000 * 1000) // ns
#define DEFAULT_PERIOD (2 * 1000 * 1000) // ns
#define DEFAULT_DELAY_AFTER_TRIGGER (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_READOUT_C0 (10) //(125000000) // rdo_clk, 125 MHz
#define DEFAULT_READOUT_C1 (10) //(125000000) // rdo_x2_clk, 125 MHz
#define DEFAULT_SYSTEM_C0 (5) //(250000000) // run_clk, 250 MHz
#define DEFAULT_SYSTEM_C1 (10) //(125000000) // chip_clk, 125 MHz
#define DEFAULT_SYSTEM_C2 (10) //(125000000) // sync_clk, 125 MHz
#define DEFAULT_INTERNAL_GATES (1)
#define DEFAULT_EXTERNAL_GATES (1)
#define DEFAULT_DYNAMIC_RANGE (24)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_GATE_WIDTH (100 * 1000 * 1000) // ns
#define DEFAULT_GATE_DELAY (0)
#define DEFAULT_PERIOD (2 * 1000 * 1000) // ns
#define DEFAULT_DELAY_AFTER_TRIGGER (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_READOUT_C0 (10) //(125000000) // rdo_clk, 125 MHz
#define DEFAULT_READOUT_C1 (10) //(125000000) // rdo_x2_clk, 125 MHz
#define DEFAULT_SYSTEM_C0 (5) //(250000000) // run_clk, 250 MHz
#define DEFAULT_SYSTEM_C1 (10) //(125000000) // chip_clk, 125 MHz
#define DEFAULT_SYSTEM_C2 (10) //(125000000) // sync_clk, 125 MHz
#define DEFAULT_ASIC_LATCHING_NUM_PULSES (10)
#define DEFAULT_MSTR_OTPT_P1_NUM_PULSES (20)
/* Firmware Definitions */
#define IP_HEADER_SIZE (20)

View File

@ -8,16 +8,6 @@
/** Notify microcontroller of successful server start up */
void NotifyServerStartSuccess();
/** create notification file to notify watchdog of critical tasks (to not
* shutdown) */
void CreateNotificationForCriticalTasks();
/** write 1 to notification file to postpone shut down process if requested*/
void NotifyCriticalTask();
/** write 0 to notification file to allow shut down process if requested */
void NotifyCriticalTaskDone();
/** reset fpga and controller(only implemented for >= v1.1 boards) */
void rebootControllerAndFPGA();

View File

@ -84,6 +84,9 @@ u_int16_t getHardwareSerialNumber();
#ifdef JUNGFRAUD
int isHardwareVersion2();
#endif
#ifdef EIGERD
void readDetectorNumber();
#endif
u_int32_t getDetectorNumber();
u_int64_t getDetectorMAC();
u_int32_t getDetectorIP();
@ -112,9 +115,15 @@ void updateDataBytes();
defined(MOENCHD)
int setDefaultDacs();
#endif
#ifdef GOTTHARD2D
#ifdef MYTHEN3D
void setASICDefaults();
#endif
#if defined(GOTTHARD2D) || defined(EIGERD)
int readConfigFile();
#endif
#ifdef EIGERD
void resetToHardwareSettings();
#endif
// advanced read/write reg
#ifdef EIGERD
@ -195,10 +204,23 @@ void setNumFrames(int64_t val);
int64_t getNumFrames();
void setNumTriggers(int64_t val);
int64_t getNumTriggers();
#ifndef MYTHEN3D
int setExpTime(int64_t val);
int64_t getExpTime();
#endif
int setPeriod(int64_t val);
int64_t getPeriod();
#ifdef MYTHEN3D
void setNumIntGates(int val);
void setNumGates(int val);
int getNumGates();
void updateGatePeriod();
int64_t getGatePeriod();
int setExpTime(int gateIndex, int64_t val);
int64_t getExpTime(int gateIndex);
int setGateDelay(int gateIndex, int64_t val);
int64_t getGateDelay(int gateIndex);
#endif
#ifdef GOTTHARD2D
void setNumBursts(int64_t val);
int64_t getNumBursts();
@ -315,17 +337,23 @@ int setHighVoltage(int val);
// parameters - timing, extsig
void setTiming(enum timingMode arg);
enum timingMode getTiming();
#ifdef GOTTHARDD
void setExtSignal(enum externalSignalFlag mode);
int getExtSignal();
#ifdef MYTHEN3D
void setInitialExtSignals();
#endif
#if defined(GOTTHARDD) || defined(MYTHEN3D)
void setExtSignal(int signalIndex, enum externalSignalFlag mode);
int getExtSignal(int signalIndex);
#endif
// configure mac
#ifdef GOTTHARDD
void calcChecksum(mac_conf *mac, int sourceip, int destip);
#elif JUNGFRAUD
#endif
#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
void setNumberofUDPInterfaces(int val);
int getNumberofUDPInterfaces();
#endif
#ifdef JUNGFRAUD
void selectPrimaryInterface(int val);
int getPrimaryInterface();
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
@ -432,13 +460,15 @@ void setExternalGating(int enable[]);
int setAllTrimbits(int val);
int getAllTrimbits();
int getBebFPGATemp();
int activate(int enable);
int setActivate(int enable);
int getActivate(int *retval);
// gotthard specific - adc phase
#elif GOTTHARDD
int setPhase(enum CLKINDEX ind, int val, int degrees);
#elif MYTHEN3D
void startPattern();
uint64_t readPatternWord(int addr);
uint64_t writePatternWord(int addr, uint64_t word);
int setPatternWaitAddress(int level, int addr);
@ -488,6 +518,8 @@ void setCurrentSource(int value);
int getCurrentSource();
void setTimingSource(enum timingSourceType value);
enum timingSourceType getTimingSource();
void setVeto(int enable);
int getVeto();
#endif
#if defined(JUNGFRAUD) || defined(EIGERD)

View File

@ -11,7 +11,6 @@ int printSocketReadError();
void init_detector();
int decode_function(int);
const char *getRetName();
const char *getFunctionName(enum detFuncs func);
void function_table();
void functionNotImplemented();
void modeNotImplemented(char *modename, int mode);
@ -27,6 +26,7 @@ void rebootNiosControllerAndFPGA();
// functions called by client
int exec_command(int);
int get_detector_type(int);
int get_external_signal_flag(int);
int set_external_signal_flag(int);
int set_timing_mode(int);
int get_firmware_version(int);
@ -218,3 +218,12 @@ int set_timing_source(int);
int get_num_channels(int);
int update_rate_correction(int);
int get_receiver_parameters(int);
int start_pattern(int);
int set_num_gates(int);
int get_num_gates(int);
int set_gate_delay(int);
int get_gate_delay(int);
int get_exptime_all_gates(int);
int get_gate_delay_all_gates(int);
int get_veto(int);
int set_veto(int);

View File

@ -106,7 +106,7 @@
/** Receive Data Fifo Level register */
//#define I2C_RX_DATA_FIFO_LVL_OFST (0)
//#define I2C_RX_DATA_FIFO_LVL_MSK (0x000000FF <<
//I2C_RX_DATA_FIFO_LVL_OFST)
// I2C_RX_DATA_FIFO_LVL_OFST)
// defines in the fpga
uint32_t I2C_Control_Reg = 0x0;

View File

@ -247,7 +247,7 @@ int LTC2620_SetDACValue(int dacnum, int val, int mV, int *dacval) {
} else if (val >= 0 && dacnum <= ndacsonly) {
// do not convert power down dac val
//(if not ndacsonly (pwr/vchip): dont need to print mV value as it will
//be wrong (wrong limits))
// be wrong (wrong limits))
ret = LTC2620_DacToVoltage(val, &dacmV);
}

View File

@ -9,7 +9,6 @@
/* global variables */
#define MTDSIZE 10
char mtdvalue[MTDSIZE] = {0};
#define NOTIFICATION_FILE "/tmp/block_shutdown"
#define MICROCONTROLLER_FILE "/dev/ttyAL0"
void NotifyServerStartSuccess() {
@ -20,38 +19,6 @@ void NotifyServerStartSuccess() {
system(command);
}
void CreateNotificationForCriticalTasks() {
FILE *fd = fopen(NOTIFICATION_FILE, "r");
if (fd == NULL) {
fd = fopen(NOTIFICATION_FILE, "w");
if (fd == NULL) {
LOG(logERROR,
("Could not create notication file: %s\n", NOTIFICATION_FILE));
return;
}
LOG(logINFOBLUE,
("Created notification file: %s\n", NOTIFICATION_FILE));
}
fclose(fd);
NotifyCriticalTaskDone();
}
void NotifyCriticalTask() {
LOG(logINFO, ("\tNotifying Critical Task Ongoing\n"));
char command[255];
memset(command, 0, 255);
sprintf(command, "echo 1 > %s", NOTIFICATION_FILE);
system(command);
}
void NotifyCriticalTaskDone() {
LOG(logINFO, ("\tNotifying Critical Task Done\n"));
char command[255];
memset(command, 0, 255);
sprintf(command, "echo 0 > %s", NOTIFICATION_FILE);
system(command);
}
void rebootControllerAndFPGA() {
LOG(logDEBUG1, ("Reseting FPGA...\n"));
char command[255];
@ -77,7 +44,7 @@ int findFlash(char *mess) {
if (fp == NULL) {
strcpy(mess, "popen returned NULL. Need that to get mtd drive.\n");
LOG(logERROR, (mess));
return RO_TRIGGER_IN_FALLING_EDGE;
return FAIL;
}
if (fgets(output, sizeof(output), fp) == NULL) {
strcpy(mess, "fgets returned NULL. Need that to get mtd drive.\n");
@ -111,13 +78,11 @@ int eraseAndWriteToFlash(char *mess, char *fpgasrc, uint64_t fsize) {
if (findFlash(mess) == FAIL) {
return FAIL;
}
NotifyCriticalTask();
eraseFlash();
// open file pointer to flash
FILE *filefp = fopen(mtdvalue, "w");
if (filefp == NULL) {
NotifyCriticalTaskDone();
sprintf(mess, "Unable to open %s in write mode\n", mtdvalue);
LOG(logERROR, (mess));
return FAIL;
@ -126,13 +91,11 @@ int eraseAndWriteToFlash(char *mess, char *fpgasrc, uint64_t fsize) {
// write to flash
if (writeFPGAProgram(mess, fpgasrc, fsize, filefp) == FAIL) {
NotifyCriticalTaskDone();
fclose(filefp);
return FAIL;
}
fclose(filefp);
NotifyCriticalTaskDone();
return OK;
}

View File

@ -177,7 +177,9 @@ int main(int argc, char *argv[]) {
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
rebootNiosControllerAndFPGA();
#else
#ifndef VIRTUAL
system("reboot");
#endif
#endif
}
LOG(logINFO, ("Goodbye!\n"));

View File

@ -0,0 +1,29 @@
current_dir = $(shell pwd)
CROSS = nios2-buildroot-linux-gnu-
CC = $(CROSS)gcc
CFLAGS += -Wall #-DDEBUG
PROGS = stripd
DESTDIR ?= bin
INSTMODE = 0777
SRCS = stripd.c
OBJS = $(SRCS:.c=.o)
all: clean $(PROGS)
version: clean versioning $(PROGS)
boot: $(OBJS)
$(PROGS): $(OBJS)
mkdir -p $(DESTDIR)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR)
rm $(main_src)*.o
clean:
rm -rf $(DESTDIR)/$(PROGS) *.o *.gdb $(main_src)*.o

View File

@ -0,0 +1,197 @@
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <signal.h>
#include <errno.h>
#define UART_DEVICE "/dev/ttyAL0"
#ifdef DEBUG
#define DEBUG_PRINT(fmt, args...) fprintf(stderr, "DEBUG: %s:%d:%s(): " fmt, \
__FILE__, __LINE__, __func__, ##args)
#else
#define DEBUG_PRINT(fmt, args...) /* Don't do anything in release builds */
#endif
struct termios oldtio;
int uart;
int update_files = 1;
void intHandler(int signo)
{
DEBUG_PRINT("signo %d received\n", signo);
if (signo == SIGINT)
{
DEBUG_PRINT("SIGINT handling\n");
tcsetattr(uart,TCSANOW,&oldtio);
close(uart);
exit(0);
}
if (signo == SIGUSR1)
{
DEBUG_PRINT("SIGUSR1 handling\n");
update_files = 1;
}
}
void kill_servers()
{
system("killall gotthard2DetectorServer mythen3DetectorServer gotthard2DetectorServer_developer mythen3DetectorServer_developer");
}
void set_hv_zero()
{
FILE* hv;
hv = fopen("/etc/devlinks/hvdac", "w");
if (hv == NULL)
fprintf(stderr, "Could not open hvdac file.\n");
else
{
fputc('0', hv);
fclose(hv);
}
}
void disable_chip_power()
{
unsigned* mem_ptr;
unsigned mem_val;
unsigned mem_address = 0x18040000;
int mem_desc;
mem_desc = open("/dev/mem", O_RDWR | O_SYNC, 0);
if (mem_desc == -1)
fprintf(stderr, "Cannot open /dev/mem\n");
else
{
mem_ptr = (unsigned *) mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, mem_desc, mem_address);
if (mem_ptr == MAP_FAILED)
fprintf(stderr, "Cannot map memory area\n");
else
{
mem_val = mem_ptr[0x84/4];
mem_val = mem_val & 0x7FFFFFFF; // Removes top bit
mem_ptr[0x84/4] = mem_val;
munmap((unsigned*) mem_address, 0x1000);
}
close(mem_desc);
}
}
void prepare_for_shutdown()
{
kill_servers();
set_hv_zero();
disable_chip_power();
system("sync");
return;
}
int uart_setup(struct termios* old_settings)
{
int desc;
struct termios newtio;
desc = open(UART_DEVICE, O_RDWR | O_NOCTTY);
if (desc < 0) { perror(UART_DEVICE); exit(-1); }
tcgetattr(desc, old_settings);
newtio.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR | IGNCR | IXANY;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
tcflush(desc, TCIFLUSH);
tcsetattr(desc,TCSANOW,&newtio);
return desc;
}
int get_boot_condition()
{
FILE* ru_trig_cond;
char ru_trig_cond_content[10];
int bytes_read;
ru_trig_cond = fopen("/sys/devices/platform/sopc@0/18000000.bridge/180000c0.remoteupdate/remote_update/trig_cond","r");
if (ru_trig_cond == NULL)
fprintf(stderr, "Cannot read remote update status\n");
bytes_read = fread(ru_trig_cond_content, 1, 10, ru_trig_cond);
if (bytes_read < 4)
fprintf(stderr, "Invalid file content\n");
return strtoul(ru_trig_cond_content, NULL, 0);
}
void write_cmd_in_file(char* cmd, char* filename, int lines)
{
int res,i;
char buf[255];
FILE* cmd_file;
cmd_file = fopen(filename, "w");
write(uart, cmd, 1);
for (i=0; i < lines; i++)
{
res = read(uart, buf, 255);
fwrite(buf, 1, res, cmd_file);
}
fclose(cmd_file);
}
int main(int argc, char* argv[])
{
char buf[255];
fd_set readfs;
int maxfd;
int res;
char factory_image_detected_cmd = 'f';
char get_voltage_cmd = 'u';
char get_versions_cmd = 'v';
char get_eventlog_cmd = 'e';
uart = uart_setup(&oldtio);
signal(SIGINT, intHandler);
signal(SIGUSR1, intHandler);
maxfd = uart+1;
if (get_boot_condition() != 4)
write(uart, &factory_image_detected_cmd, 1);
while (1)
{
if (update_files == 1)
{
DEBUG_PRINT("Updating files...\n");
write_cmd_in_file(&get_voltage_cmd, "/tmp/uc_voltage", 1);
write_cmd_in_file(&get_versions_cmd, "/tmp/uc_versions", 2);
write_cmd_in_file(&get_eventlog_cmd, "/tmp/uc_eventlog", 16);
update_files = 0;
}
FD_SET(uart, &readfs);
res = select(maxfd, &readfs, NULL, NULL, NULL);
if ((res == -1) && (errno == EINTR)) // If SIGUSR1 occured
continue;
if (FD_ISSET(uart,&readfs))
{
res = read(uart, buf, 255);
buf[res] = 0;
DEBUG_PRINT("-->%s:%d<--", buf, res);
if ((buf[0] == 'S') && (res < 5))
{
prepare_for_shutdown();
exit(0);
}
}
usleep(1000);
}
// Should never get here
tcsetattr(uart,TCSANOW,&oldtio);
return 0;
}

View File

@ -1,6 +1,5 @@
set(SOURCES
src/DetectorImpl.cpp
src/slsDetectorUsers.cpp
src/Module.cpp
src/Detector.cpp
src/CmdProxy.cpp
@ -39,7 +38,6 @@ target_link_libraries(slsDetectorShared
set(PUBLICHEADERS
include/slsDetectorUsers.h
include/detectorData.h
include/Detector.h
include/Result.h

View File

@ -117,6 +117,16 @@ class Detector {
/**[Eiger][Mythen3] */
void setAllTrimbits(int value, Positions pos = {});
/**[Eiger][Jungfrau] */
bool getGapPixelsinCallback() const;
/**
* [Eiger][Jungfrau]
* Only in client data call back
* Fills in gap pixels in data
*/
void setGapPixelsinCallback(const bool enable);
/**************************************************
* *
* Callbacks *
@ -146,16 +156,6 @@ class Detector {
void *),
void *pArg);
/**[Eiger][Jungfrau] */
bool getGapPixelsinCallback() const;
/**
* [Eiger][Jungfrau]
* Only in client data call back
* Fills in gap pixels in data
*/
void setGapPixelsinCallback(const bool enable);
/**************************************************
* *
* Acquisition Parameters *
@ -203,7 +203,9 @@ class Detector {
Result<defs::timingMode> getTimingMode(Positions pos = {}) const;
/**
* [Gotthard][Jungfrau][CTB][Moench] Options: AUTO_TIMING, TRIGGER_EXPOSURE
* [Gotthard][Jungfrau][CTB][Moench][Mythen3] Options:
* AUTO_TIMING, TRIGGER_EXPOSURE
* [Gotthard2] Options: AUTO_TIMING, TRIGGER_EXPOSURE, GATED, TRIGGER_GATED
* [Eiger] Options: AUTO_TIMING, TRIGGER_EXPOSURE, GATED, BURST_TRIGGER
*/
void setTimingMode(defs::timingMode value, Positions pos = {});
@ -379,10 +381,13 @@ class Detector {
* *
* ************************************************/
/** [Jungfrau] */
/** [Jungfrau][Gotthard2] */
Result<int> getNumberofUDPInterfaces(Positions pos = {}) const;
/** [Jungfrau] Also restarts client and receiver sockets */
/** [Jungfrau][Gotthard2] Also restarts client and receiver zmq sockets
* [Gotthard2] second interface enabled to send veto information via 10gbps
* for debugging. By default it is sent via 2.5gbps if veto enabled
* n can be 1 or 2 */
void setNumberofUDPInterfaces(int n, Positions pos = {});
/** [Jungfrau] */
@ -791,7 +796,7 @@ class Detector {
Result<bool> getActive(Positions pos = {}) const;
/** [Eiger] */
void setActive(bool active, Positions pos = {});
void setActive(const bool active, Positions pos = {});
/** [Eiger] */
Result<bool> getRxPadDeactivatedMode(Positions pos = {}) const;
@ -879,7 +884,7 @@ class Detector {
/** [Jungfrau] Advanced. Sets the storage cell storing the first acquisition
* of the series. Options: 0-15
*/
void setStoragecellStart(int cell, Positions pos = {});
void setStorageCellStart(int cell, Positions pos = {});
/** [Jungfrau] Advanced*/
Result<ns> getStorageCellDelay(Positions pos = {}) const;
@ -911,12 +916,19 @@ class Detector {
/** [Gotthard] */
Result<ns> getExptimeLeft(Positions pos = {}) const;
/** [Gotthard] */
/** [Gotthard] signal index is 0
* [Mythen3] signal index 0-3 for master input, 4-7 master output signals */
Result<defs::externalSignalFlag>
getExternalSignalFlags(Positions pos = {}) const;
getExternalSignalFlags(int signalIndex, Positions pos = {}) const;
/** [Gotthard] Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE */
void setExternalSignalFlags(defs::externalSignalFlag value,
/** [Gotthard] signal index is 0
* Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE
* [Mythen3] signal index 0 is master input trigger signal, 1-3 for master
* input gate signals, 4 is busy out signal, 5-7 is master output gate
* signals.
* Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE (for
* master input trigger only), INVERSION_ON, INVERSION_OFF */
void setExternalSignalFlags(int signalIndex, defs::externalSignalFlag value,
Positions pos = {});
/**************************************************
@ -977,6 +989,12 @@ class Detector {
/** [Gotthard2] Options: TIMING_INTERNAL, TIMING_EXTERNAL */
void setTimingSource(defs::timingSourceType value, Positions pos = {});
/** [Gotthard2] */
Result<bool> getVeto(Positions pos = {}) const;
/** [Gotthard2] */
void setVeto(const bool enable, Positions pos = {});
/**************************************************
* *
* Mythen3 Specific *
@ -988,6 +1006,36 @@ class Detector {
/** [Mythen3] countermask bit set for each counter enabled */
void setCounterMask(uint32_t countermask, Positions pos = {});
Result<int> getNumberOfGates(Positions pos = {}) const;
/** [Mythen3] external gates in gating or trigger_gating mode (external
* gating) */
void setNumberOfGates(int value, Positions pos = {});
/** [Mythen3] exptime for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2 */
Result<ns> getExptime(int gateIndex, Positions pos = {}) const;
/** [Mythen3] exptime for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2, -1 for all */
void setExptime(int gateIndex, ns t, Positions pos = {});
/** [Mythen3] exptime for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2, -1 for all */
Result<std::array<ns, 3>> getExptimeForAllGates(Positions pos = {}) const;
/** [Mythen3] gate delay for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2 */
Result<ns> getGateDelay(int gateIndex, Positions pos = {}) const;
/** [Mythen3] gate delay for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2, -1 for all */
void setGateDelay(int gateIndex, ns t, Positions pos = {});
/** [Mythen3] gate delay for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2, -1 for all */
Result<std::array<ns, 3>> getGateDelayForAllGates(Positions pos = {}) const;
/**************************************************
* *
* CTB / Moench Specific *
@ -1095,7 +1143,7 @@ class Detector {
void setExternalSamplingSource(int value, Positions pos = {});
/** [CTB] */
Result<int> getExternalSampling(Positions pos = {}) const;
Result<bool> getExternalSampling(Positions pos = {}) const;
/** [CTB] */
void setExternalSampling(bool value, Positions pos = {});
@ -1138,16 +1186,16 @@ class Detector {
/** [CTB][Moench][Mythen3] */
void savePattern(const std::string &fname);
/** [CTB][Moench][Mythen3] */
/** [CTB][Moench] */
Result<uint64_t> getPatternIOControl(Positions pos = {}) const;
/** [CTB][Moench][Mythen3] */
/** [CTB][Moench] */
void setPatternIOControl(uint64_t word, Positions pos = {});
/** [CTB][Moench][Mythen3] */
/** [CTB][Moench] */
Result<uint64_t> getPatternClockControl(Positions pos = {}) const;
/** [CTB][Moench][Mythen3] */
/** [CTB][Moench] */
void setPatternClockControl(uint64_t word, Positions pos = {});
/** [CTB][Moench][Mythen3] same as executing for ctb and moench */
@ -1207,6 +1255,9 @@ class Detector {
*/
void setPatternBitMask(uint64_t mask, Positions pos = {});
/** [Mythen3] */
void startPattern(Positions pos = {});
/**************************************************
* *
* Moench *
@ -1273,7 +1324,7 @@ class Detector {
/** [Jungfrau][CTB][Moench] */
void resetFPGA(Positions pos = {});
/** [Jungfrau][Gotthard][CTB][Moench]
/** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2]
* Copy detector server fname from tftp folder of hostname to detector
* Also changes respawn server, which is effective after a reboot.
*/

View File

@ -13,7 +13,6 @@
#include <iostream>
#include <vector>
#include "TimeHelper.h"
#include "ToString.h"
#include "container_utils.h"

View File

@ -1,6 +1,7 @@
#include <cstring>
#include <unistd.h>
#pragma once
#include <cstdint>
#include <string>
/**
@short data structure to hold the detector data after postprocessing
*/

View File

@ -1,910 +0,0 @@
#pragma once
// class detectorData;
namespace sls {
class Detector;
}
#include <memory>
class slsDetectorUsers {
public:
/**
* @param shm_id detector shared memory id
* Default value is 0. Can be set to more values for
* multiple detectors.It is important only if you
* are controlling multiple detectors from the same pc.
*/
slsDetectorUsers(int shm_id = 0);
~slsDetectorUsers();
/**************************************************
* *
* CONFIGURATION *
* *
* ************************************************/
void readConfigurationFile(const std::string &fname);
/** Gets the total number of detectors */
int size() const;
// /**
// * Returns the size of detector/multi detector
// * @param nx number of channels in horiziontal
// * @param ny number of channels in vertical
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns the total number of channels of all sls detectors
// */
// int getDetectorSize(int &nx, int &ny, int detPos);
// /**
// * Gets detector type
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns detector type (EIGER, JUNGFRAU, GOTTHARD) slsDetectorDefs
// */
// std::string getDetectorType(int detPos = -1);
// /**
// * Write current configuration to a file (for one time detector setup)
// * @param fname configuration file name
// */
// void writeConfigurationFile(const std::string& fname);
// /**
// * Loads the detector setup from file (current measurement setup)
// * @param fname file to read from
// * @returns OK or FAIL
// */
// int retrieveDetectorSetup(const std::string& fname);
// /**
// * Saves the detector setup to file (currentmeasurement setup)
// * @param fname file to write to
// * @returns OK or FAIL
// */
// int dumpDetectorSetup(const std::string& fname);
// /**
// * Get detector firmware version
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns detector firmware version
// */
// int64_t getDetectorFirmwareVersion(int detPos = -1);
// /**
// * Get detector serial number or MAC
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns detector serial number or MAC
// */
// int64_t getDetectorSerialNumber(int detPos = -1);
// /**
// * Get on-board detector server software version
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns on-board detector server software version
// */
// int64_t getDetectorSoftwareVersion(int detPos = -1);
// /**
// * (previously getThisSoftwareVersion)
// * Get client software version
// * @returns client software version
// */
// int64_t getClientSoftwareVersion();
// /**
// * Get receiver software version
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns receiver software version
// */
// int64_t getReceiverSoftwareVersion(int detPos = -1);
// /**
// * Check Detector Version Compatibility
// * @param detPos -1 for all detectors in list or specific detector
// position
// */
// void isDetectorVersionCompatible(int detPos = -1);
// /**
// * Check Receiver Version Compatibility
// * @param detPos -1 for all detectors in list or specific detector
// position
// */
// void isReceiverVersionCompatible(int detPos = -1);
// /**
// * Performs a complete acquisition
// * resets frames caught in receiver, starts receiver, starts detector,
// * blocks till detector finished acquisition, stop receiver, increments
// file index,
// * loops for measurements, calls required call backs.
// * @returns OK or FAIL depending on if it already started
// */
// int startMeasurement();
// /**
// * Stop detector acquisition
// * @param detPos -1 for all detectors in list or specific detector
// position
// */
// void stopMeasurement(int detPos = -1);
// /**
// * Get Detector run status
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns status
// */
// int getDetectorStatus(int detPos = -1);
// /**
// * (Advanced user, included in startMeasurement)
// * Start detector acquisition (Non blocking)
// * @param detPos -1 for all detectors in list or specific detector
// position
// */
// void startAcquisition(int detPos = -1);
// /**
// * Stop detector acquisition (Same as stopMeasurement)
// * @param detPos -1 for all detectors in list or specific detector
// position
// */
// void stopAcquisition(int detPos = -1);
// /**
// * (Only in non blocking acquire mode)
// * Give an internal software trigger to the detector (Eiger)
// * @param detPos -1 for all detectors in list or specific detector
// position
// */
// void sendSoftwareTrigger(int detPos = -1);
// /**
// * Set Rate correction ( Eiger)
// * @param t (1) enable rate correction to default dead time,
// * (0) disable rate correction, (-1) gets
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns rate correction tau
// */
// int enableCountRateCorrection(int i = -1, int detPos = -1);
// /**
// * Set/get dynamic range
// * @param i dynamic range (-1 get)
// * Options: Eiger(4, 8, 16, 32), Jungfrau(16), Gotthard(16)
// * Background operation:
// * (Eiger: If i is 32, also sets clkdivider to 2, if 16, sets clkdivider
// to 1)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns current dynamic range
// */
// int setBitDepth(int i = -1, int detPos = -1);
// /**
// * Set detector settings
// * (Eiger only stores in shared memory. A get will overwrite this. One
// must use set threshold energy)
// * @param isettings settings (-1 gets)
// * Options: (slsDetectorDefs::detectorSettings)
// * Eiger (STANDARD, HIGHGAIN, LOWGAIN, VERYHIGHGAIN, VERYLOWGAIN)
// * Jungfrau (DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1,
// FORCESWITCHG2)
// * Gotthard (DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns current settings (can also return UNDEFINED, UNINITIALIZED)
// */
// int setSettings(int isettings = -1, int detPos = -1);
// /**
// * Get threshold energy (Eiger)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns current threshold value
// */
// int getThresholdEnergy(int detPos = -1);
// /**
// * Set threshold energy (Eiger)
// * @param e_eV threshold in eV
// * @param tb 1 to load trimbits, 0 to exclude trimbits
// * @param isettings settings (-1 current settings)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns current threshold value
// */
// int setThresholdEnergy(int e_ev, int tb = 1, int isettings = -1, int
// detPos = -1);
// /**
// * Set/get exposure time
// * @param t time (-1 gets)
// * @param inseconds true if the value is in s, else ns
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns exposure time in ns, or s if specified
// */
// double setExposureTime(double t = -1, bool inseconds = false, int detPos
// = -1);
// /**
// * Set/get exposure period
// * @param t time (-1 gets)
// * @param inseconds true if the value is in s, else ns
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns exposure period in ns, or s if specified
// */
// double setExposurePeriod(double t = -1, bool inseconds = false, int
// detPos = -1);
// /**
// * Set/get delay after trigger (Gotthard, Jungfrau(not for this release))
// * @param t time (-1 gets)
// * @param inseconds true if the value is in s, else ns
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns delay after trigger in ns, or s if specified
// */
// double setDelayAfterTrigger(double t = -1, bool inseconds = false, int
// detPos = -1);
// /**
// * (Advanced users)
// * Set/get sub frame exposure time (Eiger in 32 bit mode)
// * @param t time (-1 gets)
// * @param inseconds true if the value is in s, else ns
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns sub frame exposure time in ns, or s if specified
// */
// double setSubFrameExposureTime(double t = -1, bool inseconds = false, int
// detPos = -1);
// /**
// * (Advanced users)
// * Set/get sub frame dead time (Eiger in 32 bit mode)
// * @param t time (-1 gets)
// * @param inseconds true if the value is in s, else ns
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns sub frame dead time in ns, or s if specified
// */
// double setSubFrameExposureDeadTime(double t = -1, bool inseconds = false,
// int detPos = -1);
// /**
// * Set/get number of frames
// * @param t number of frames (-1 gets)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns number of frames
// */
// int64_t setNumberOfFrames(int64_t t = -1, int detPos = -1);
// /**
// * Set/get number of triggers
// * @param t number of triggers (-1 gets)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns number of triggers
// */
// int64_t setNumberOfTriggers(int64_t t = -1, int detPos = -1);
// /**
// * Set/get number of additional storage cells (Jungfrau)
// * @param t number of additional storage cells. Default is 0. (-1 gets)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns number of additional storage cells
// */
// int64_t setNumberOfStorageCells(int64_t t = -1, int detPos = -1);
// /**
// * Get measured period between previous two frames (EIGER)
// * @param t time (-1 gets)
// * @param inseconds true if the value is in s, else ns
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns sub frame dead time in ns, or s if specified
// */
// double getMeasuredPeriod(bool inseconds = false, int detPos = -1);
// /**
// * Get sub period between previous two sub frames in 32 bit mode (EIGER)
// * @param t time (-1 gets)
// * @param inseconds true if the value is in s, else ns
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns sub frame dead time in ns, or s if specified
// */
// double getMeasuredSubFramePeriod(bool inseconds = false, int detPos =
// -1);
// /**
// * Set/get timing mode
// * @param pol timing mode (-1 gets)
// * Options (slsDetectorDefs::timingMode)
// * (Eiger: AUTO_TIMING, TRIGGER_EXPOSURE, BURST_TRIGGER, GATED)
// * (Jungfrau: AUTO_TIMING, TRIGGER_EXPOSURE)
// * (Gotthard: AUTO_TIMING, TRIGGER_EXPOSURE)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns current timing mode
// */
// int setTimingMode(int pol = -1, int detPos = -1);
// /**
// * Sets clock speed of the detector (Eiger, Jungfrau)
// * (Jungfrau also writes adcphase to recommended default)
// * (Eiger: 0(full speed not for 32 bit mode), 1 (half speed), 2(quarter
// speed))
// * (Jungfrau: 0(full speed not implemented), 1(half speed), 2(quarter
// speed))
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns clock speed
// */
// int setClockDivider(int value, int detPos = -1);
// /**
// * Set parallel readout mode (Eiger)
// * @param value readout mode (-1 gets)
// * false for NonParallel (Default), true for Parallel
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns 1 for parallel, 0 for non parallel, -1 if different
// */
// int setParallelMode(bool value, int detPos = -1);
// /**
// * Set overflow readout mode (Eiger in 32 bit)
// * @param value readout mode (-1 gets)
// * Options: true to Show overflow, false to not show overflow
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns 1 for overflow, 0 for no overflow, -1 if different
// */
// int setOverflowMode(bool value, int detPos = -1);
// /**
// * (Advanced user)
// * Sets all the trimbits to a particular value (Eiger)
// * @param val trimbit value
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns OK or FAIL
// */
// int setAllTrimbits(int val, int detPos = -1);
// /**
// * (Advanced user)
// * Set/get dacs value
// * @param val value (in V) (-1 gets)
// * @param index DAC index
// * Options: slsDetectorDefs::dacIndex
// * (Eiger: SVP up to IO_DELAY, THRESHOLD, HIGH_VOLTAGE)
// * (Jungfrau: 0-7)
// * (Gotthard: VREF_DS up to IB_TESTC, HIGH_VOLTAGE)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns current DAC value
// */
// int setDAC(int val, int index , int detPos = -1);
// /**
// * Get adc value
// * @param index adc(DAC) index
// * Options: slsDetectorDefs::dacIndex
// * (Eiger: TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT upto TEMPERATURE_FPGA3)
// * (Jungfrau: TEMPERATURE_FPGA)
// * (Gotthard: TEMPERATURE_ADC, TEMPERATURE_FPGA)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns current adc value (temperature for eiger and jungfrau in
// millidegrees)
// */
// int getADC(int index, int detPos = -1);
// /**
// * Enable/disable or 10Gbe (Eiger)
// * @param i is -1 to get, 0 to disable and 1 to enable
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns if 10Gbe is enabled
// */
// int setTenGigabitEthernet(int i = -1, int detPos = -1);
// /**
// * Set storage cell that stores first acquisition of the series
// (Jungfrau)
// * @param value storage cell index. Value can be 0 to 15. (-1 gets)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns the storage cell that stores the first acquisition of the
// series
// */
// int setStoragecellStart(int pos=-1, int detPos = -1);
// /**
// * set high voltage (Gotthard, Jungfrau, Eiger)
// * @param i > 0 sets, 0 unsets, (-1 gets)
// * (Eiger: )
// * (Jungfrau: )
// * (Gotthard: )
// * @returns high voltage
// */
// int setHighVoltage(int i = -1, int detPos = -1);
// /**
// * Set 10GbE Flow Control (Eiger and Jungfrau)
// * @param enable 1 to set, 0 to unset, -1 gets
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns 10GbE flow Control
// */
// int setFlowControl10G(int enable = -1, int detPos = -1);
// /**
// * Set ROI (Gotthard)
// * At the moment only one set allowed per module
// * Only allowed to set one ROI per module
// * @param arg roi
// * @param detPos specific detector position
// */
// void setROI(slsDetectorDefs::ROI arg, int detPos = -1);
// /**
// * Get ROI (Gotthard)
// * Only allowed to set one ROI per module
// * @param detPos specific detector position
// * @returns roi
// */
// slsDetectorDefs::ROI getROI(int detPos = -1);
// /************************************************************************
// RECEIVER FUNCTIONS
// *********************************************************************/
// /**
// * (Advanced user, included in startMeasurement)
// * Receiver starts listening to packets
// * @param detPos -1 for all detectors in list or specific detector
// position
// */
// void startReceiver(int detPos = -1);
// /**
// * (Advanced user, included in startMeasurement)
// * Stops the listening mode of receiver
// * @param detPos -1 for all detectors in list or specific detector
// position
// */
// void stopReceiver(int detPos = -1);
// /**
// * Set/get receiver silent mode
// * @param i is -1 to get, 0 unsets silent mode, 1 sets silent mode
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns the receiver silent mode enable
// */
// int setReceiverSilentMode(int i = -1, int detPos = -1);
// /**
// * (Advanced user, included in startMeasurement)
// * Resets framescaught in receiver
// * Use this when using startAcquisition instead of acquire
// * @param detPos -1 for all detectors in list or specific detector
// position
// */
// void resetFramesCaughtInReceiver(int detPos = -1);
// /**
// * (Advanced user)
// * Set/get receiver fifo depth
// * @param i is -1 to get, any other value to set the fifo deph
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns the receiver fifo depth
// */
// int setReceiverFifoDepth(int i = -1, int detPos = -1);
// /**
// * Returns output file directory
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns output file directory
// */
// std::string getFilePath(int detPos = -1);
// /**
// * Sets up the file directory
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @param s file directory
// * @returns file dir
// */
// std::string setFilePath(const std::string& s, int detPos = -1);
// /**
// * Returns file name prefix
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns file name prefix
// */
// std::string getFileName(int detPos = -1);
// /**
// * Sets up the file name prefix
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @param s file name prefix
// * @returns file name prefix
// */
// std::string setFileName(const std::string& s, int detPos = -1);
// /**
// * Returns file index
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns file index
// */
// int getFileIndex(int detPos = -1);
// /**
// * Sets up the file index
// * @param i file index
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns file index
// */
// int setFileIndex(int i, int detPos = -1);
// /**
// * Sets/Gets receiver file write enable
// * @param enable 1 or 0 to set/reset file write enable
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns file write enable
// */
// int enableWriteToFile(int enable = -1, int detPos = -1);
// /**
// * Sets/Gets file overwrite enable
// * @param enable 1 or 0 to set/reset file overwrite enable
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns file overwrite enable
// */
// int enableOverwriteFile(int enable = -1, int detPos = -1);
// /**
// * (previously setReceiverMode)
// * Sets the receiver streaming frequency
// * @param freq nth frame streamed out, if 0, streamed out at a timer of
// 200 ms
// * frames in between are not streamed
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns receiver streaming frequency
// */
// int setReceiverStreamingFrequency(int freq = -1, int detPos = -1);
// /**
// * Sets the receiver streaming timer
// * If receiver streaming frequency is 0, then this timer between each
// * data stream is set. Default is 200 ms.
// * @param time_in_ms timer between frames
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns receiver streaming timer in ms
// */
// int setReceiverStreamingTimer(int time_in_ms=500, int detPos = -1);
// /**
// * Enable data streaming to client (data call back in client processing
// thread)
// * @param enable 0 to disable, 1 to enable, -1 to get the value
// * @returns data streaming to client enable
// */
// int enableDataStreamingToClient(int enable=-1);
// /**
// * Enable or disable streaming data from receiver (starts streaming
// threads)
// * @param enable 0 to disable 1 to enable -1 to only get the value
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns data streaming from receiver enable
// */
// int enableDataStreamingFromReceiver(int enable=-1, int detPos = -1);
// /**
// * (advanced users)
// * Set/Get receiver streaming out ZMQ port and restarts receiver sockets
// * @param i sets, -1 gets
// * If detPos is -1(multi module), port calculated (increments) for all
// the individual detectors using i
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns receiver streaming out ZMQ port (if multiple, of first
// receiver socket)
// */
// int setReceiverDataStreamingOutPort(int i = -1, int detPos = -1);
// /**
// * (advanced users)
// * Set/Get client streaming in ZMQ port and restarts client sockets
// * @param i sets, -1 gets
// * If detPos is -1(multi module), port calculated (increments) for all
// the individual detectors using i
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns receiver streaming out ZMQ port (if multiple, of first
// receiver socket)
// */
// int setClientDataStreamingInPort(int i = -1, int detPos = -1);
// /**
// * (advanced users)
// * Set/Get receiver streaming out ZMQ IP and restarts receiver sockets
// * @param i sets, empty string gets
// * By default, it is the IP of receiver hostname
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns receiver streaming out ZMQ IP
// */
// std::string setReceiverDataStreamingOutIP(const std::string& ip="", int
// detPos = -1);
// /**
// * (advanced users)
// * Set/Get client streaming in ZMQ IP and restarts client sockets
// * @param i sets, empty string gets
// * By default, it is the IP of receiver hostname
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns client streaming in ZMQ IP
// */
// std::string setClientDataStreamingInIP(const std::string& ip = "", int
// detPos = -1);
// /**
// * Enable gap pixels in receiver (Eiger for 8,16 and 32 bit mode)
// * 4 bit mode gap pixels only in data call back in client
// * @param val 1 sets, 0 unsets, -1 gets
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns gap pixel enable
// */
// int enableGapPixels(int val=-1, int detPos = -1);
// /**
// * Sets the frame discard policy in receiver
// * @param f frame discard policy (-1 gets)
// * Options: (slsDetectorDefs::frameDiscardPolicy)
// * (NO_DISCARD (default), DISCARD_EMPTY_FRAMES, DISCARD_PARTIAL_FRAMES
// (fastest))
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns current frame discard policy
// */
// int setReceiverFramesDiscardPolicy(int f = -1, int detPos = -1);
// /**
// * Sets the frame padding in receiver
// * @param f 0 does not partial frames, 1 pads partial frames (-1 gets)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns partial frames padding enable
// */
// int setReceiverPartialFramesPadding(int f = -1, int detPos = -1);
// /**
// * Sets the frames per file in receiver
// * @param f frames per file, 0 is infinite ie. every frame in same file
// (-1 gets)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns frames per file
// */
// int setReceiverFramesPerFile(int f = -1, int detPos = -1);
// /**
// * Sets the detector minimum/maximum energy threshold in processor (for
// Moench only)
// * @param index 0 for emin, antyhing else for emax
// * @param v value to set (-1 gets)
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns detector minimum/maximum energy threshold
// */
// int setDetectorMinMaxEnergyThreshold(const int index, int v, int detPos =
// -1);
// /**
// * Sets the frame mode in processor (Moench only)
// * @param value frame mode value (-1 gets)
// * Options (slsDetectorDefs::frameModeType)
// * PEDESTAL, NEW_PEDESTAL, FLATFIELD, NEW_FLATFIELD
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns frame mode (-1 for not found or error in computing json
// parameter value)
// */
// int setFrameMode(int value, int detPos = -1);
// /**
// * Sets the detector mode in processor (Moench only)
// * @param value detector mode value (-1 gets)
// * Options (slsDetectorDefs::detectorModeType)
// * COUNTING, INTERPOLATING, ANALOG
// * @param detPos -1 for all detectors in list or specific detector
// position
// * @returns detector mode (-1 for not found or error in computing json
// parameter value)
// */
// int setDetectorMode(int value, int detPos = -1);
// /************************************************************************
// CALLBACKS & COMMAND LINE PARSING
// *********************************************************************/
// /**
// * register callback for accessing detector final data in client,
// * also enables data streaming in client and receiver
// * @param userCallback function for plotting/analyzing the data.
// * Its arguments are
// * the data structure d and the frame number f,
// * s is for subframe number for eiger for 32 bit mode
// * @param pArg argument
// */
// void registerDataCallback(void( *userCallback)(detectorData* d, uint64_t
// f, uint32_t s, void*), void *pArg);
// /**
// * register callback for accessing acquisition final data in client,
// * @param func function to be called at the end of the acquisition.
// * gets detector status and progress index as arguments
// * @param pArg argument
// */
// void registerAcquisitionFinishedCallback(void( *func)(double,int, void*),
// void *pArg);
// /**
// @short [usage strongly discouraged] sets parameters trough command line
// interface
// http://www.psi.ch/detectors/UsersSupportEN/slsDetectorClientHowTo.pdf
// \param command string as it would be written on the command line
// \returns void
// */
// void putCommand(const std::string& command);
// /************************************************************************
// STATIC FUNCTIONS
// *********************************************************************/
/** @short returns std::string from run status index
\param s run status index
\returns std::string error, waiting, running, data, finished or unknown when
wrong index
*/
/* static std::string runStatusType(int s){
\
switch (s) {
\
case 0: return std::string("idle");
\
case 1: return std::string("error");
\
case 2: return std::string("waiting");
\
case 3: return std::string("finished");
\
case 4: return std::string("data");
\
case 5: return std::string("running");
\
case 6: return std::string("stopped"); \
default: return std::string("unknown");
\
}};
*/
/** @short returns detector settings std::string from index
\param s can be standard, fast, highgain, dynamicgain, lowgain, mediumgain,
veryhighgain \returns setting index (-1 unknown std::string)
*/
/*
static int getDetectorSettings(std::string s){ \
if (s=="standard") return 0; \
if (s=="fast") return 1; \
if (s=="highgain") return 2; \
if (s=="dynamicgain") return 3; \
if (s=="lowgain") return 4; \
if (s=="mediumgain") return 5; \
if (s=="veryhighgain") return 6; \
return -1; }; */
/** @short returns detector settings std::string from index
\param s settings index
\returns standard, fast, highgain, dynamicgain, lowgain, mediumgain,
veryhighgain, undefined when wrong index
*/
/* static std::string getDetectorSettings(int s){\
switch(s) { \
case 0: return std::string("standard");\
case 1: return std::string("fast");\
case 2: return std::string("highgain");\
case 3: return std::string("dynamicgain"); \
case 4: return std::string("lowgain"); \
case 5: return std::string("mediumgain"); \
case 6: return std::string("veryhighgain");
\
default: return std::string("undefined");
\
}};
*/
/**
@short returns external communication mode std::string from index
\param f index for communication mode
\returns auto, trigger, ro_trigger, gating, triggered_gating, unknown when
wrong mode
*/
/* static std::string getTimingMode(int f){ \
switch(f) { \
case 0: return std::string( "auto"); \
case 1: return std::string("trigger"); \
case 2: return std::string("ro_trigger");
\
case 3: return std::string("gating"); \
case 4: return std::string("triggered_gating"); \
case 5: return std::string("burst_trigger"); \
default: return std::string( "unknown");
\ } };
*/
/**
@short returns external communication mode std::string from index
\param s index for communication mode
\returns auto, trigger, ro_trigger, gating, triggered_gating, burst_trigger,
unknown when wrong mode
*/
/* static int getTimingMode(std::string s){ \
if (s== "auto") return 0;
\
if (s== "trigger") return 1;
\
if (s== "ro_trigger") return 2;
\
if (s== "gating") return 3;
\
if (s== "triggered_gating") return 4; \
if (s== "burst_trigger") return 5; \ return -1;
};
*/
private:
std::unique_ptr<sls::Detector> detector;
};

View File

@ -331,8 +331,143 @@ std::string CmdProxy::DetectorSize(int action) {
return os.str();
}
std::string CmdProxy::GapPixels(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[0, 1]\n\t[Eiger][Jungfrau] Include Gap pixels only in data "
"call back."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError("Cannot get gap pixels at module level");
}
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getGapPixelsinCallback();
os << t << '\n';
} else if (action == defs::PUT_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError("Cannot add gap pixels at module level");
}
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setGapPixelsinCallback(StringTo<int>(args[0]));
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* acquisition parameters */
std::string CmdProxy::Exptime(int action) {
int gateIndex = -1;
if (cmd == "exptime") {
gateIndex = -1;
} else if (cmd == "exptime1") {
gateIndex = 0;
} else if (cmd == "exptime2") {
gateIndex = 1;
} else if (cmd == "exptime3") {
gateIndex = 2;
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "exptime") {
os << "[duration] [(optional unit) "
"ns|us|ms|s]\n\t[Eiger][Jungfrau][Gotthard][Gotthard2]["
"Moench][Ctb] Exposure time"
"\n\t[Gotthard2] Uploaded to detector just before "
"acquisition starts"
"\n\t[Mythen3] Exposure time of all gate signals in auto and "
"trigger mode (internal gating)."
<< '\n';
} else if (cmd == "exptime1") {
os << "[n_value]\n\t[Mythen3] Exposure time of gate signal 1 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
} else if (cmd == "exptime2") {
os << "[n_value]\n\t[Mythen3] Exposure time of gate signal 2 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
} else {
os << "[n_value]\n\t[Mythen3] Exposure time of gate signal 3 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
}
} else if (action == defs::GET_ACTION) {
if (args.size() > 1) {
WrongNumberOfParameters(1);
}
// vector of exptimes
if (gateIndex == -1 &&
det->getDetectorType().squash() == defs::MYTHEN3) {
auto t = det->getExptimeForAllGates({det_id});
if (args.size() == 0) {
os << OutString(t) << '\n';
} else if (args.size() == 1) {
os << OutString(t, args[0]) << '\n';
}
}
// single exptime
else {
Result<ns> t;
if (gateIndex == -1) {
t = det->getExptime({det_id});
} else {
t = det->getExptime(gateIndex, {det_id});
}
if (args.size() == 0) {
os << OutString(t) << '\n';
} else if (args.size() == 1) {
os << OutString(t, args[0]) << '\n';
}
}
} else if (action == defs::PUT_ACTION) {
defs::detectorType type = det->getDetectorType().squash();
if (args.size() == 1) {
std::string time_str(args[0]);
std::string unit = RemoveUnit(time_str);
auto t = StringTo<time::ns>(time_str, unit);
if (type == defs::MYTHEN3) {
det->setExptime(gateIndex, t, {det_id});
} else {
det->setExptime(t, {det_id});
}
} else if (args.size() == 2) {
auto t = StringTo<time::ns>(args[0], args[1]);
if (type == defs::MYTHEN3) {
det->setExptime(gateIndex, t, {det_id});
} else {
det->setExptime(t, {det_id});
}
} else {
WrongNumberOfParameters(2);
}
/* TODO: os << args << '\n'; (doesnt work for vectors in .h)*/
if (args.size() > 1) {
os << args[0] << args[1] << '\n';
} else {
os << args[0] << '\n';
}
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::Speed(int action) {
std::ostringstream os;
os << cmd << ' ';
@ -652,6 +787,40 @@ std::string CmdProxy::ClockDivider(int action) {
return os.str();
}
std::string CmdProxy::ExternalSignal(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[n_signal] [signal_type] External signal mode for trigger "
"timing mode."
"\n\t[Gotthard] [0] "
"[trigger_in_rising_edge|trigger_in_falling_edge]"
"\n\t[Mythen3] [0-7] "
"[trigger_in_rising_edge|trigger_in_falling_edge|inversion_on|"
"inversion_off]\n\t where 0 is master input trigger signal, 1-3 "
"is master input gate signals, 4 is busy out signal and 5-7 is "
"master output gate signals"
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
auto t = det->getExternalSignalFlags(StringTo<int>(args[0]), {det_id});
os << args[0] << " " << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
det->setExternalSignalFlags(
StringTo<int>(args[0]),
StringTo<slsDetectorDefs::externalSignalFlag>(args[1]), {det_id});
os << args[0] << " " << args[1] << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/** temperature */
/* dacs */
std::string CmdProxy::Dac(int action) {
@ -1086,37 +1255,6 @@ std::string CmdProxy::ThresholdNoTb(int action) {
return os.str();
}
std::string CmdProxy::GapPixels(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[0, 1]\n\t[Eiger][Jungfrau] Include Gap pixels only in data "
"call back."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError("Cannot get gap pixels at module level");
}
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getGapPixelsinCallback();
os << t << '\n';
} else if (action == defs::PUT_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError("Cannot add gap pixels at module level");
}
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setGapPixelsinCallback(StringTo<int>(args[0]));
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::TrimEnergies(int action) {
std::ostringstream os;
os << cmd << ' ';
@ -1133,13 +1271,11 @@ std::string CmdProxy::TrimEnergies(int action) {
auto t = det->getTrimEnergies({det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.empty()) {
WrongNumberOfParameters(1);
}
std::vector<int> t(args.size());
for (size_t i = 0; i < t.size(); ++i) {
t[i] = StringTo<int>(args[i]);
if (!args.empty()) {
for (size_t i = 0; i < t.size(); ++i) {
t[i] = StringTo<int>(args[i]);
}
}
det->setTrimEnergies(t, {det_id});
os << sls::ToString(args) << '\n';
@ -1391,7 +1527,7 @@ std::string CmdProxy::ROI(int action) {
t.xmin = StringTo<int>(args[0]);
t.xmax = StringTo<int>(args[1]);
det->setROI(t, det_id);
os << '[' << t.xmin << ", " << t.xmax << "] \n";
os << '[' << t.xmin << ", " << t.xmax << "]\n";
} else {
throw sls::RuntimeError("Unknown action");
}
@ -1412,7 +1548,7 @@ std::string CmdProxy::ClearROI(int action) {
WrongNumberOfParameters(0);
}
det->clearROI({det_id});
os << "[-1, -1] \n";
os << "[-1, -1]\n";
} else {
throw sls::RuntimeError("Unknown action");
}
@ -1591,6 +1727,92 @@ std::string CmdProxy::Counters(int action) {
return os.str();
}
std::string CmdProxy::GateDelay(int action) {
int gateIndex = -1;
if (cmd == "gatedelay") {
gateIndex = -1;
} else if (cmd == "gatedelay1") {
gateIndex = 0;
} else if (cmd == "gatedelay2") {
gateIndex = 1;
} else if (cmd == "gatedelay3") {
gateIndex = 2;
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "gatedelay") {
os << "[duration] [(optional unit) "
"ns|us|ms|s]\n\t[Mythen3] Gate Delay of all gate signals in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
} else if (cmd == "gatedelay1") {
os << "[n_value]\n\t[Mythen3] Gate Delay of gate signal 1 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
} else if (cmd == "gatedelay2") {
os << "[n_value]\n\t[Mythen3] Gate Delay of gate signal 2 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
} else {
os << "[n_value]\n\t[Mythen3] Gate Delay of gate signal 3 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
}
} else if (action == defs::GET_ACTION) {
if (args.size() > 1) {
WrongNumberOfParameters(1);
}
// vector of gate delays
if (gateIndex == -1) {
auto t = det->getGateDelayForAllGates({det_id});
if (args.size() == 0) {
os << OutString(t) << '\n';
} else if (args.size() == 1) {
os << OutString(t, args[0]) << '\n';
}
}
// single gate delay
else {
auto t = det->getGateDelay(gateIndex, {det_id});
if (args.size() == 0) {
os << OutString(t) << '\n';
} else if (args.size() == 1) {
os << OutString(t, args[0]) << '\n';
}
}
} else if (action == defs::PUT_ACTION) {
if (args.size() == 1) {
std::string time_str(args[0]);
std::string unit = RemoveUnit(time_str);
auto t = StringTo<time::ns>(time_str, unit);
det->setGateDelay(gateIndex, t, {det_id});
} else if (args.size() == 2) {
auto t = StringTo<time::ns>(args[0], args[1]);
det->setGateDelay(gateIndex, t, {det_id});
} else {
WrongNumberOfParameters(2);
}
/* TODO: os << args << '\n'; (doesnt work for vectors in .h)*/
if (args.size() > 1) {
os << args[0] << args[1] << '\n';
} else {
os << args[0] << '\n';
}
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* CTB / Moench Specific */
std::string CmdProxy::Samples(int action) {
@ -1739,7 +1961,7 @@ std::string CmdProxy::Pattern(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[fname]\n\t[Mythen3][Moench][Ctb][Moench] Loads binary pattern "
os << "[fname]\n\t[Mythen3][Moench][Ctb] Loads binary pattern "
"file with only pattern "
"words"
<< '\n';
@ -2139,7 +2361,9 @@ std::string CmdProxy::CopyDetectorServer(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[server_name] [pc_host_name]\n\t[Jungfrau][Ctb][Moench] Copies "
os << "[server_name] "
"[pc_host_name]\n\t[Jungfrau][Ctb][Moench][Mythen3][Gotthard2] "
"Copies "
"detector "
"server via tftp from pc and changes respawn server name in "
"/etc/inittab of detector."

View File

@ -565,12 +565,13 @@ class CmdProxy {
{"settings", &CmdProxy::settings},
{"trimbits", &CmdProxy::trimbits},
{"trimval", &CmdProxy::trimval},
{"gappixels", &CmdProxy::GapPixels},
/* acquisition parameters */
{"acquire", &CmdProxy::acquire},
{"frames", &CmdProxy::frames},
{"triggers", &CmdProxy::triggers},
{"exptime", &CmdProxy::exptime},
{"exptime", &CmdProxy::Exptime},
{"period", &CmdProxy::period},
{"delay", &CmdProxy::delay},
{"framesl", &CmdProxy::framesl},
@ -590,6 +591,7 @@ class CmdProxy {
{"vhighvoltage", &CmdProxy::vhighvoltage},
{"powerchip", &CmdProxy::powerchip},
{"imagetest", &CmdProxy::imagetest},
{"extsig", &CmdProxy::ExternalSignal},
/** temperature */
{"temp_adc", &CmdProxy::temp_adc},
@ -753,7 +755,6 @@ class CmdProxy {
{"threshold", &CmdProxy::Threshold},
{"thresholdnotb", &CmdProxy::ThresholdNoTb},
{"settingspath", &CmdProxy::settingspath},
{"gappixels", &CmdProxy::GapPixels},
{"parallel", &CmdProxy::parallel},
{"overflow", &CmdProxy::overflow},
{"storeinram", &CmdProxy::storeinram},
@ -784,7 +785,6 @@ class CmdProxy {
{"roi", &CmdProxy::ROI},
{"clearroi", &CmdProxy::ClearROI},
{"exptimel", &CmdProxy::exptimel},
{"extsig", &CmdProxy::extsig},
/* Gotthard2 Specific */
{"bursts", &CmdProxy::bursts},
@ -795,9 +795,18 @@ class CmdProxy {
{"burstmode", &CmdProxy::BurstMode},
{"currentsource", &CmdProxy::currentsource},
{"timingsource", &CmdProxy::timingsource},
{"veto", &CmdProxy::veto},
/* Mythen3 Specific */
{"counters", &CmdProxy::Counters},
{"gates", &CmdProxy::gates},
{"exptime1", &CmdProxy::Exptime},
{"exptime2", &CmdProxy::Exptime},
{"exptime3", &CmdProxy::Exptime},
{"gatedelay", &CmdProxy::GateDelay},
{"gatedelay1", &CmdProxy::GateDelay},
{"gatedelay2", &CmdProxy::GateDelay},
{"gatedelay3", &CmdProxy::GateDelay},
/* CTB/ Moench Specific */
{"samples", &CmdProxy::Samples},
@ -860,6 +869,7 @@ class CmdProxy {
{"patwaittime2", &CmdProxy::PatternWaitTime},
{"patmask", &CmdProxy::patmask},
{"patsetbit", &CmdProxy::patsetbit},
{"patternstart", &CmdProxy::patternstart},
/* Moench */
{"rx_jsonaddheader", &CmdProxy::AdditionalJsonHeader},
@ -913,8 +923,10 @@ class CmdProxy {
std::string PackageVersion(int action);
std::string ClientVersion(int action);
std::string DetectorSize(int action);
std::string GapPixels(int action);
/* acquisition parameters */
std::string acquire(int action);
std::string Exptime(int action);
std::string Speed(int action);
std::string Adcphase(int action);
std::string Dbitphase(int action);
@ -922,6 +934,7 @@ class CmdProxy {
std::string ClockPhase(int action);
std::string MaxClockPhaseShift(int action);
std::string ClockDivider(int action);
std::string ExternalSignal(int action);
/** temperature */
/* dacs */
std::string Dac(int action);
@ -942,7 +955,6 @@ class CmdProxy {
std::string DynamicRange(int action);
std::string Threshold(int action);
std::string ThresholdNoTb(int action);
std::string GapPixels(int action);
std::string TrimEnergies(int action);
std::string RateCorrection(int action);
std::string Activate(int action);
@ -962,6 +974,7 @@ class CmdProxy {
std::string BurstMode(int action);
/* Mythen3 Specific */
std::string Counters(int action);
std::string GateDelay(int action);
/* CTB/ Moench Specific */
std::string Samples(int action);
/* CTB Specific */
@ -1054,11 +1067,6 @@ class CmdProxy {
"[n_triggers]\n\tNumber of triggers per aquire. Use "
"timing command to set timing mode.");
TIME_COMMAND(
exptime, getExptime, setExptime,
"[duration] [(optional unit) ns|us|ms|s]\n\tExposure time"
"\n\t[Gotthard2] Uploaded to detector just before acquisition starts");
TIME_COMMAND(
period, getPeriod, setPeriod,
"[duration] [(optional unit) ns|us|ms|s]\n\tPeriod between frames"
@ -1093,12 +1101,13 @@ class CmdProxy {
" Period left for current frame."
"\n\t[Gotthard2] only in continuous mode.");
INTEGER_COMMAND(
timing, getTimingMode, setTimingMode,
sls::StringTo<slsDetectorDefs::timingMode>,
"[auto|trigger|gating|burst_trigger]\n\tTiming Mode of "
"detector.\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] "
"[auto|trigger]\n\t[Eiger] [auto|trigger|gating|burst_trigger]");
INTEGER_COMMAND(timing, getTimingMode, setTimingMode,
sls::StringTo<slsDetectorDefs::timingMode>,
"[auto|trigger|gating|burst_trigger]\n\tTiming Mode of "
"detector.\n\t[Jungfrau][Gotthard][Mythen3][Ctb][Moench] "
"[auto|trigger]\n\t[Gotthard2] "
"[auto|trigger|gating|trigger_gating]\n\t[Eiger] "
"[auto|trigger|gating|burst_trigger]");
GET_COMMAND(maxadcphaseshift, getMaxADCPhaseShift,
"\n\t[Jungfrau][CTB][Moench] Absolute maximum Phase shift of "
@ -1517,10 +1526,15 @@ class CmdProxy {
/* Network Configuration (Detector<->Receiver) */
INTEGER_COMMAND(numinterfaces, getNumberofUDPInterfaces,
setNumberofUDPInterfaces, StringTo<int>,
"[1, 2]\n\t[Jungfrau] Number of udp interfaces to stream "
"data from detector. Default: 1.");
INTEGER_COMMAND(
numinterfaces, getNumberofUDPInterfaces, setNumberofUDPInterfaces,
StringTo<int>,
"[1, 2]\n\t[Jungfrau][Gotthard2] Number of udp interfaces to stream "
"data from detector. Default: 1.\n\t"
"[Gotthard2] 2 will select 10gbps as channel for veto data streaming "
"in detector and also enable second interface in receiver to listen to "
"it. This is mainly for debugging purposes. By default, numinterfaces "
"is 1 and if veto enabled, it is sent via 2.5 gbps interface");
INTEGER_COMMAND(
selinterface, getSelectedUDPInterface, selectUDPInterface,
@ -1830,7 +1844,7 @@ class CmdProxy {
"(#storagecells + 1).");
INTEGER_COMMAND(
storagecell_start, getStorageCellStart, setStoragecellStart,
storagecell_start, getStorageCellStart, setStorageCellStart,
StringTo<int>,
"[0-15]\n\t[Jungfrau] Storage cell that stores the first acquisition "
"of the series. Default is 15. For advanced users only.");
@ -1846,11 +1860,6 @@ class CmdProxy {
"[(optional unit) ns|us|ms|s]\n\t[Gotthard] Exposure time "
"left for current frame. ");
INTEGER_COMMAND(extsig, getExternalSignalFlags, setExternalSignalFlags,
sls::StringTo<slsDetectorDefs::externalSignalFlag>,
"[trigger_in_rising_edge|trigger_in_falling_edge]\n\t["
"Gotthard] External signal mode for trigger timing mode.");
/* Gotthard2 Specific */
INTEGER_COMMAND_NOID(
bursts, getNumberOfBursts, setNumberOfBursts, StringTo<int64_t>,
@ -1869,8 +1878,16 @@ class CmdProxy {
"[internal|external]\n\t[Gotthard2] Timing source. Internal is crystal "
"and external is system timing. Default is internal.");
INTEGER_COMMAND(veto, getVeto, setVeto, StringTo<int>,
"[0, 1]\n\t[Gotthard2] Enable or disable veto data "
"streaming from detector. Default is 0.");
/* Mythen3 Specific */
INTEGER_COMMAND(gates, getNumberOfGates, setNumberOfGates, StringTo<int>,
"[n_gates]\n\t[Mythen3] Number of external gates in gating "
"or trigger_gating mode (external gating).");
/* CTB/ Moench Specific */
INTEGER_COMMAND(
@ -2010,12 +2027,12 @@ class CmdProxy {
INTEGER_COMMAND_HEX(patioctrl, getPatternIOControl, setPatternIOControl,
StringTo<uint64_t>,
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask "
"[64 bit mask]\n\t[Ctb][Moench] 64 bit mask "
"defining input (0) and output (1) signals.");
INTEGER_COMMAND_HEX(patclkctrl, getPatternClockControl,
setPatternClockControl, StringTo<uint64_t>,
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask "
"[64 bit mask]\n\t[Ctb][Moench] 64 bit mask "
"defining output clock enable.");
INTEGER_COMMAND_HEX(
@ -2028,6 +2045,9 @@ class CmdProxy {
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit values "
"applied to the selected patmask for every pattern.");
EXECUTE_SET_COMMAND(patternstart, startPattern,
"\n\t[Mythen3] Starts Pattern");
/* Moench */
INTEGER_COMMAND(framemode, getFrameMode, setFrameMode,
@ -2061,7 +2081,7 @@ class CmdProxy {
INTEGER_COMMAND_HEX(
adcinvert, getADCInvert, setADCInvert, StringTo<uint32_t>,
"[bitmask]\n\t[Ctb][Moench][Jungfrau][Moench] ADC Inversion "
"[bitmask]\n\t[Ctb][Moench][Jungfrau] ADC Inversion "
"Mask.\n\t[Jungfrau][Moench] Inversions on top of the default mask.");
/* Insignificant */
@ -2084,7 +2104,7 @@ class CmdProxy {
"\n\tClient IP Address that last communicated with the detector.");
GET_COMMAND(nframes, getNumberOfFramesFromStart,
"\n\t[Jungfrau][Mythen3][Gotthard2][Moench][CTB][Moench] "
"\n\t[Jungfrau][Mythen3][Gotthard2][Moench][CTB] "
"Number of frames from start run control."
"\n\t[Gotthard2] only in continuous mode.");

View File

@ -161,6 +161,14 @@ void Detector::setAllTrimbits(int value, Positions pos) {
pimpl->Parallel(&Module::setAllTrimbits, pos, value);
}
bool Detector::getGapPixelsinCallback() const {
return pimpl->getGapPixelsinCallback();
}
void Detector::setGapPixelsinCallback(bool enable) {
pimpl->setGapPixelsinCallback(enable);
}
// Callback
void Detector::registerAcquisitionFinishedCallback(void (*func)(double, int,
@ -175,14 +183,6 @@ void Detector::registerDataCallback(void (*func)(detectorData *, uint64_t,
pimpl->registerDataCallback(func, pArg);
}
bool Detector::getGapPixelsinCallback() const {
return pimpl->getGapPixelsinCallback();
}
void Detector::setGapPixelsinCallback(bool enable) {
pimpl->setGapPixelsinCallback(enable);
}
// Acquisition Parameters
Result<int64_t> Detector::getNumberOfFrames(Positions pos) const {
@ -202,11 +202,11 @@ void Detector::setNumberOfTriggers(int64_t value) {
}
Result<ns> Detector::getExptime(Positions pos) const {
return pimpl->Parallel(&Module::getExptime, pos);
return pimpl->Parallel(&Module::getExptime, pos, -1);
}
void Detector::setExptime(ns t, Positions pos) {
pimpl->Parallel(&Module::setExptime, pos, t.count());
pimpl->Parallel(&Module::setExptime, pos, -1, t.count());
}
Result<ns> Detector::getPeriod(Positions pos) const {
@ -1031,11 +1031,11 @@ Result<ns> Detector::getMeasuredSubFramePeriod(Positions pos) const {
}
Result<bool> Detector::getActive(Positions pos) const {
return pimpl->Parallel(&Module::activate, pos, -1);
return pimpl->Parallel(&Module::getActivate, pos);
}
void Detector::setActive(bool active, Positions pos) {
pimpl->Parallel(&Module::activate, pos, static_cast<int>(active));
void Detector::setActive(const bool active, Positions pos) {
pimpl->Parallel(&Module::setActivate, pos, active);
}
Result<bool> Detector::getRxPadDeactivatedMode(Positions pos) const {
@ -1132,11 +1132,11 @@ void Detector::setNumberOfAdditionalStorageCells(int value) {
}
Result<int> Detector::getStorageCellStart(Positions pos) const {
return pimpl->Parallel(&Module::setStoragecellStart, pos, -1);
return pimpl->Parallel(&Module::setStorageCellStart, pos, -1);
}
void Detector::setStoragecellStart(int cell, Positions pos) {
pimpl->Parallel(&Module::setStoragecellStart, pos, cell);
void Detector::setStorageCellStart(int cell, Positions pos) {
pimpl->Parallel(&Module::setStorageCellStart, pos, cell);
}
Result<ns> Detector::getStorageCellDelay(Positions pos) const {
@ -1169,14 +1169,14 @@ Result<ns> Detector::getExptimeLeft(Positions pos) const {
}
Result<defs::externalSignalFlag>
Detector::getExternalSignalFlags(Positions pos) const {
return pimpl->Parallel(&Module::setExternalSignalFlags, pos,
defs::GET_EXTERNAL_SIGNAL_FLAG);
Detector::getExternalSignalFlags(int signalIndex, Positions pos) const {
return pimpl->Parallel(&Module::getExternalSignalFlags, pos, signalIndex);
}
void Detector::setExternalSignalFlags(defs::externalSignalFlag value,
void Detector::setExternalSignalFlags(int signalIndex,
defs::externalSignalFlag value,
Positions pos) {
pimpl->Parallel(&Module::setExternalSignalFlags, pos, value);
pimpl->Parallel(&Module::setExternalSignalFlags, pos, signalIndex, value);
}
// Gotthard2 Specific
@ -1248,6 +1248,14 @@ void Detector::setTimingSource(defs::timingSourceType value, Positions pos) {
pimpl->Parallel(&Module::setTimingSource, pos, value);
}
Result<bool> Detector::getVeto(Positions pos) const {
return pimpl->Parallel(&Module::getVeto, pos);
}
void Detector::setVeto(bool enable, Positions pos) {
pimpl->Parallel(&Module::setVeto, pos, enable);
}
// Mythen3 Specific
Result<uint32_t> Detector::getCounterMask(Positions pos) const {
@ -1258,6 +1266,39 @@ void Detector::setCounterMask(uint32_t countermask, Positions pos) {
pimpl->Parallel(&Module::setCounterMask, pos, countermask);
}
Result<int> Detector::getNumberOfGates(Positions pos) const {
return pimpl->Parallel(&Module::getNumberOfGates, pos);
}
void Detector::setNumberOfGates(int value, Positions pos) {
pimpl->Parallel(&Module::setNumberOfGates, pos, value);
}
Result<ns> Detector::getExptime(int gateIndex, Positions pos) const {
return pimpl->Parallel(&Module::getExptime, pos, gateIndex);
}
void Detector::setExptime(int gateIndex, ns t, Positions pos) {
pimpl->Parallel(&Module::setExptime, pos, gateIndex, t.count());
}
Result<std::array<ns, 3>> Detector::getExptimeForAllGates(Positions pos) const {
return pimpl->Parallel(&Module::getExptimeForAllGates, pos);
}
Result<ns> Detector::getGateDelay(int gateIndex, Positions pos) const {
return pimpl->Parallel(&Module::getGateDelay, pos, gateIndex);
}
void Detector::setGateDelay(int gateIndex, ns t, Positions pos) {
pimpl->Parallel(&Module::setGateDelay, pos, gateIndex, t.count());
}
Result<std::array<ns, 3>>
Detector::getGateDelayForAllGates(Positions pos) const {
return pimpl->Parallel(&Module::getGateDelayForAllGates, pos);
}
// CTB/ Moench Specific
Result<int> Detector::getNumberOfAnalogSamples(Positions pos) const {
@ -1427,7 +1468,7 @@ void Detector::setExternalSamplingSource(int value, Positions pos) {
pimpl->Parallel(&Module::setExternalSamplingSource, pos, value);
}
Result<int> Detector::getExternalSampling(Positions pos) const {
Result<bool> Detector::getExternalSampling(Positions pos) const {
return pimpl->Parallel(&Module::getExternalSampling, pos);
}
@ -1484,13 +1525,17 @@ void Detector::savePattern(const std::string &fname) {
proxy.Call("patword", {addr}, -1, defs::GET_ACTION, outfile);
}
// rest of pattern file
const std::vector<std::string> commands{
std::vector<std::string> commands{
"patioctrl", "patclkctrl", "patlimits", "patloop0",
"patnloop0", "patloop1", "patnloop1", "patloop2",
"patnloop2", "patwait0", "patwaittime0", "patwait1",
"patwaittime1", "patwait2", "patwaittime2", "patmask",
"patsetbit",
};
auto det_type = getDetectorType().squash();
if (det_type == defs::MYTHEN3) {
commands.erase(commands.begin(), commands.begin() + 2);
}
for (const auto &cmd : commands)
proxy.Call(cmd, {}, -1, defs::GET_ACTION, outfile);
}
@ -1574,6 +1619,10 @@ void Detector::setPatternBitMask(uint64_t mask, Positions pos) {
pimpl->Parallel(&Module::setPatternBitMask, pos, mask);
}
void Detector::startPattern(Positions pos) {
pimpl->Parallel(&Module::startPattern, pos);
}
// Moench
Result<std::map<std::string, std::string>>

View File

@ -357,7 +357,7 @@ void DetectorImpl::setGapPixelsinCallback(const bool enable) {
break;
default:
throw RuntimeError("Gap Pixels is not implemented for " +
multi_shm()->multiDetectorType);
ToString(multi_shm()->multiDetectorType));
}
}
multi_shm()->gapPixels = enable;
@ -383,8 +383,12 @@ int DetectorImpl::createReceivingDataSockets(const bool destroy) {
if (multi_shm()->multiDetectorType == EIGER) {
numSocketsPerDetector = 2;
}
if (Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash() == 2) {
numSocketsPerDetector = 2;
// gotthard2 second interface is only for veto debugging
else if (multi_shm()->multiDetectorType != GOTTHARD2) {
if (Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash() ==
2) {
numSocketsPerDetector = 2;
}
}
numSockets *= numSocketsPerDetector;
@ -424,9 +428,12 @@ void DetectorImpl::readFrameFromReceiver() {
int nDetPixelsY = 0;
bool quadEnable = false;
bool eiger = false;
bool numInterfaces = Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
.squash(); // cannot pick up from zmq
bool numInterfaces = 1;
// gotthard2 second interface is veto debugging
if (multi_shm()->multiDetectorType != GOTTHARD2) {
numInterfaces = Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
.squash(); // cannot pick up from zmq
}
bool runningList[zmqSocket.size()], connectList[zmqSocket.size()];
int numRunning = 0;
for (size_t i = 0; i < zmqSocket.size(); ++i) {
@ -515,7 +522,7 @@ void DetectorImpl::readFrameFromReceiver() {
nDetPixelsX = nX * nPixelsX;
nDetPixelsY = nY * nPixelsY;
// det type
eiger = (zHeader.detType == static_cast<int>(3))
eiger = (zHeader.detType == EIGER)
? true
: false; // to be changed to EIGER when
// firmware updates its header data
@ -1048,7 +1055,8 @@ int DetectorImpl::acquire() {
}
Parallel(&Module::startAndReadAll, {});
} catch (...) {
Parallel(&Module::stopReceiver, {});
if (receiver)
Parallel(&Module::stopReceiver, {});
throw;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
#pragma once
#include "ClientSocket.h"
#include "FixedCapacityContainer.h"
#include "SharedMemory.h"
#include "StaticVector.h"
#include "logger.h"
#include "network_utils.h"
#include "sls_detector_defs.h"
@ -51,7 +51,7 @@ struct sharedSlsDetector {
char settingsDir[MAX_STR_LENGTH];
/** list of the energies at which the detector has been trimmed */
sls::FixedCapacityContainer<int, MAX_TRIMEN> trimEnergies;
sls::StaticVector<int, MAX_TRIMEN> trimEnergies;
/** number of channels per chip in one direction */
slsDetectorDefs::xy nChan;
@ -419,9 +419,29 @@ class Module : public virtual slsDetectorDefs {
/** [CTB] */
void setNumberOfDigitalSamples(int value);
int64_t getExptime();
/** [Mythen3] */
int getNumberOfGates();
void setExptime(int64_t value);
/** [Mythen3] */
void setNumberOfGates(int value);
/** [Mythen3] gatIndex: 0-2, [Others]: -1 always */
int64_t getExptime(int gateIndex);
/** [Mythen3] gatIndex: -1 for all, 0-2, [Others]: -1 always */
void setExptime(int gateIndex, int64_t value);
/** [Mythen3] for all gates */
std::array<time::ns, 3> getExptimeForAllGates();
/** [Mythen3] gatIndex: 0-2 */
int64_t getGateDelay(int gateIndex);
/** [Mythen3] gatIndex: -1 for all, 0-2 */
void setGateDelay(int gateIndex, int64_t value);
/** [Mythen3] for all gates */
std::array<time::ns, 3> getGateDelayForAllGates();
int64_t getPeriod();
@ -529,14 +549,8 @@ class Module : public virtual slsDetectorDefs {
*/
int getADC(dacIndex index);
/**
* Set/get external signal flags (to specify triggerinrising edge etc)
* (Gotthard, Mythen)
* @param pol external signal flag (-1 gets)
* @returns current timing mode
*/
externalSignalFlag
setExternalSignalFlags(externalSignalFlag pol = GET_EXTERNAL_SIGNAL_FLAG);
externalSignalFlag getExternalSignalFlags(int signalIndex);
void setExternalSignalFlags(int signalIndex, externalSignalFlag type);
/**
* Set Parallel readout mode (Only for Eiger)
@ -780,12 +794,7 @@ class Module : public virtual slsDetectorDefs {
*/
int getDestinationUDPPort2();
/**
* Sets the number of UDP interfaces to stream data from detector (Jungfrau
* only)
* @param n number of interfaces. Options 1 or 2.
* @returns the number of interface
*/
/** [Jungfrau][Gotthard2] */
void setNumberofUDPInterfaces(int n);
/** Returns the number of udp interfaces from shared memory */
@ -984,6 +993,12 @@ class Module : public virtual slsDetectorDefs {
/** [Gotthard2] Options: TIMING_INTERNAL, TIMING_EXTERNAL */
void setTimingSource(slsDetectorDefs::timingSourceType value);
/** [Gotthard2] */
bool getVeto();
/** default disabled */
void setVeto(bool enable);
/**
* Set/get counter bit in detector (Gotthard)
* @param i is -1 to get, 0 to reset and any other value to set the counter
@ -1064,20 +1079,9 @@ class Module : public virtual slsDetectorDefs {
*/
int getExternalSamplingSource();
/**
* Set external sampling enable (CTB only)
* @param value external sampling source (Option: 0-63)
* @param detPos -1 for all detectors in list or specific detector position
* @returns external sampling enable
*/
int setExternalSampling(int value);
void setExternalSampling(bool value);
/**
* Get external sampling source (CTB only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns external sampling enable
*/
int getExternalSampling();
bool getExternalSampling();
/** digital data bits enable (CTB only) */
void setReceiverDbitList(const std::vector<int> &list);
@ -1095,12 +1099,8 @@ class Module : public virtual slsDetectorDefs {
*/
void writeAdcRegister(uint32_t addr, uint32_t val);
/**
* Activates/Deactivates the detector (Eiger only)
* @param enable active (1) or inactive (0), -1 gets
* @returns 0 (inactive) or 1 (active)for activate mode
*/
int activate(int const enable = -1);
bool getActivate();
void setActivate(const bool enable);
bool getDeactivatedRxrPaddingMode();
@ -1189,7 +1189,7 @@ class Module : public virtual slsDetectorDefs {
* @param value storage cell index. Value can be 0 to 15. (-1 gets)
* @returns the storage cell that stores the first acquisition of the series
*/
int setStoragecellStart(int pos = -1);
int setStorageCellStart(int pos = -1);
/**
* [Jungfau][Ctb] Programs FPGA with raw file from pof file
@ -1314,13 +1314,6 @@ class Module : public virtual slsDetectorDefs {
*/
void exitReceiver();
/**
* Executes a system command on the receiver server
* e.g. mount an nfs disk, reboot and returns answer etc.
* @param cmd command to be executed
*/
void execReceiverCommand(const std::string &cmd);
std::string getFilePath();
void setFilePath(const std::string &path);
std::string getFileName();
@ -1516,6 +1509,9 @@ class Module : public virtual slsDetectorDefs {
*/
uint64_t getPatternBitMask();
/** [Mythen3] */
void startPattern();
/**
* Set LED Enable (Moench, CTB only)
* @param enable 1 to switch on, 0 to switch off, -1 gets

View File

@ -1,396 +0,0 @@
#include "slsDetectorUsers.h"
//#include "detectorData.h"
//#include "multiSlsDetectorClient.h" TODO: do we need this put and get in users
// api
#include "Detector.h"
slsDetectorUsers::slsDetectorUsers(int shm_id)
: detector(sls::make_unique<sls::Detector>(shm_id)) {}
slsDetectorUsers::~slsDetectorUsers() = default;
void slsDetectorUsers::readConfigurationFile(const std::string &fname) {
detector->loadConfig(fname);
}
int slsDetectorUsers::size() const { return detector->size(); }
// int slsDetectorUsers::getDetectorSize(int &nx, int &ny, int detPos){
// slsDetectorDefs::xy res = detector.getNumberOfChannels();
// nx=res.x;
// ny=res.y;
// return nx*ny;
// }
// std::string slsDetectorUsers::getDetectorType(int detPos){
// return detector.getDetectorTypeAsString(detPos);
// }
// void slsDetectorUsers::writeConfigurationFile(const std::string& fname){
// detector.writeConfigurationFile(fname);
// }
// int slsDetectorUsers::retrieveDetectorSetup(const std::string& fname){
// return detector.retrieveDetectorSetup(fname);
// }
// int slsDetectorUsers::dumpDetectorSetup(const std::string& fname){
// return detector.dumpDetectorSetup(fname);
// }
// int64_t slsDetectorUsers::getDetectorFirmwareVersion(int detPos){
// return detector.getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION,
// detPos);
// }
// int64_t slsDetectorUsers::getDetectorSerialNumber(int detPos){
// return detector.getId(slsDetectorDefs::DETECTOR_SERIAL_NUMBER, detPos);
// }
// int64_t slsDetectorUsers::getDetectorSoftwareVersion(int detPos){
// return detector.getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION,
// detPos);
// }
// int64_t slsDetectorUsers::getClientSoftwareVersion(){
// return detector.getClientSoftwareVersion();
// }
// int64_t slsDetectorUsers::getReceiverSoftwareVersion(int detPos){
// return detector.getId(slsDetectorDefs::RECEIVER_VERSION, detPos);
// }
// void slsDetectorUsers::isDetectorVersionCompatible(int detPos) {
// detector.checkDetectorVersionCompatibility(detPos);
// }
// void slsDetectorUsers::isReceiverVersionCompatible(int detPos) {
// detector.checkReceiverVersionCompatibility(detPos);
// }
// int slsDetectorUsers::startMeasurement(){
// return detector.acquire();
// }
// void slsDetectorUsers::stopMeasurement(int detPos){
// detector.stopAcquisition(detPos);
// }
// int slsDetectorUsers::getDetectorStatus(int detPos){
// return (int)detector.getRunStatus(detPos);
// }
// void slsDetectorUsers::startAcquisition(int detPos) {
// detector.startAcquisition(detPos);
// }
// void slsDetectorUsers::stopAcquisition(int detPos) {
// detector.stopAcquisition(detPos);
// }
// void slsDetectorUsers::sendSoftwareTrigger(int detPos) {
// detector.sendSoftwareTrigger(detPos);
// }
// int slsDetectorUsers::enableCountRateCorrection(int i, int detPos){
// if (i == 0)
// detector.setRateCorrection(0, detPos);
// else
// detector.setRateCorrection(-1, detPos);
// return detector.getRateCorrection(detPos);
// }
// int slsDetectorUsers::setBitDepth(int i, int detPos){
// return detector.setDynamicRange(i, detPos);
// }
// int slsDetectorUsers::setSettings(int isettings, int detPos){
// return
// detector.setSettings((slsDetectorDefs::detectorSettings)isettings, detPos);
// }
// int slsDetectorUsers::getThresholdEnergy(int detPos){
// return detector.getThresholdEnergy(detPos);
// }
// int slsDetectorUsers::setThresholdEnergy(int e_ev, int tb, int isettings, int
// detPos) { return detector.setThresholdEnergy(e_ev,
// (isettings == -1) ? slsDetectorDefs::GET_SETTINGS :
// (slsDetectorDefs::detectorSettings)isettings,
// tb, detPos);
// }
// double slsDetectorUsers::setExposureTime(double t, bool inseconds, int
// detPos){ return detector.setExposureTime(t, inseconds, detPos);
// }
// double slsDetectorUsers::setExposurePeriod(double t, bool inseconds, int
// detPos){ return detector.setExposurePeriod(t, inseconds, detPos);
// }
// double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds, int
// detPos){ return detector.setDelayAfterTrigger(t, inseconds, detPos);
// }
// double slsDetectorUsers::setSubFrameExposureTime(double t, bool inseconds,
// int detPos){ return detector.setSubFrameExposureTime(t, inseconds,
// detPos);
// }
// double slsDetectorUsers::setSubFrameExposureDeadTime(double t, bool
// inseconds, int detPos){ return detector.setSubFrameExposureDeadTime(t,
// inseconds, detPos);
// }
// int64_t slsDetectorUsers::setNumberOfFrames(int64_t t, int detPos){
// return detector.setNumberOfFrames(t, detPos);
// }
// int64_t slsDetectorUsers::setNumberOfTriggers(int64_t t, int detPos){
// return detector.setNumberOfTriggers(t, detPos);
// }
// int64_t slsDetectorUsers::setNumberOfStorageCells(int64_t t, int detPos) {
// return detector.setNumberOfStorageCells(t, detPos);
// }
// double slsDetectorUsers::getMeasuredPeriod(bool inseconds, int detPos) {
// return detector.getMeasuredPeriod(inseconds, detPos);
// }
// double slsDetectorUsers::getMeasuredSubFramePeriod(bool inseconds, int
// detPos) { return detector.getMeasuredSubFramePeriod(inseconds, detPos);
// }
// int slsDetectorUsers::setTimingMode(int pol, int detPos){
// return detector.setTimingMode(slsDetectorDefs::timingMode(pol), detPos);
// }
// int slsDetectorUsers::setClockDivider(int value, int detPos) {
// return detector.setSpeed(slsDetectorDefs::CLOCK_DIVIDER, value, detPos);
// }
// int slsDetectorUsers::setParallelMode(bool value, int detPos) {
// /* to be uncommented when moving to Detector.h
// detector.setParallelMode(value, {detPos});
// auto res = detector.getParallelMode({detPos});
// if (res.equal())
// return res.front();*/
// return -1;
// }
// int slsDetectorUsers::setOverflowMode(bool value, int detPos) {
// /* to be uncommented when moving to Detector.h
// detector.setOverFlowMode(value, {detPos});
// auto res = detector.getOverFlowMode({detPos});
// if (res.equal())
// return res.front();*/
// return -1;
// }
// int slsDetectorUsers::setAllTrimbits(int val, int detPos) {
// return detector.setAllTrimbits(val, detPos);
// }
// int slsDetectorUsers::setDAC(int val, int index , int detPos) {
// return detector.setDAC(val, slsDetectorDefs::dacIndex(index), 0,
// detPos);
// }
// int slsDetectorUsers::getADC(int index, int detPos) {
// return detector.getADC(slsDetectorDefs::dacIndex(index),detPos);
// }
// int slsDetectorUsers::setTenGigabitEthernet(int i, int detPos) {
// return detector.enableTenGigabitEthernet(i, detPos);
// }
// int slsDetectorUsers::setStoragecellStart(int pos, int detPos) {
// return detector.setStoragecellStart(pos, detPos);
// }
// int slsDetectorUsers::setHighVoltage(int i, int detPos) {
// return detector.setDAC(i, slsDetectorDefs::HIGH_VOLTAGE, 0, detPos);
// }
// int slsDetectorUsers::setFlowControl10G(int i, int detPos) {
// return detector.setFlowControl10G(i, detPos);
// }
// void slsDetectorUsers::setROI(slsDetectorDefs::ROI arg, int detPos) {
// detector.setROI(arg, detPos);
// }
// slsDetectorDefs::ROI slsDetectorUsers::getROI(int detPos) {
// return detector.getROI(detPos);
// }
// /************************************************************************
// RECEIVER FUNCTIONS
// *********************************************************************/
// void slsDetectorUsers::startReceiver(int detPos) {
// detector.startReceiver(detPos);
// }
// void slsDetectorUsers::stopReceiver(int detPos) {
// detector.stopReceiver(detPos);
// }
// int slsDetectorUsers::setReceiverSilentMode(int i, int detPos) {
// return detector.setReceiverSilentMode(i, detPos);
// }
// void slsDetectorUsers::resetFramesCaughtInReceiver(int detPos) {
// detector.resetFramesCaught(detPos);
// }
// int slsDetectorUsers::setReceiverFifoDepth(int i, int detPos) {
// return detector.setReceiverFifoDepth(i, detPos);
// }
// std::string slsDetectorUsers::getFilePath(int detPos){
// return detector.getFilePath(detPos);
// }
// std::string slsDetectorUsers::setFilePath(const std::string& s, int detPos){
// return detector.setFilePath(s, detPos);
// }
// std::string slsDetectorUsers::getFileName(int detPos){
// return detector.getFileName(detPos);
// }
// std::string slsDetectorUsers::setFileName(const std::string& s, int detPos){
// return detector.setFileName(s, detPos);
// }
// int slsDetectorUsers::getFileIndex(int detPos){
// return detector.getFileIndex(detPos);
// }
// int slsDetectorUsers::setFileIndex(int i, int detPos){
// return detector.setFileIndex(i, detPos);
// }
// int slsDetectorUsers::enableWriteToFile(int enable, int detPos){
// if (enable >0)
// return detector.setFileWrite(enable, detPos);
// else
// return detector.getFileWrite(detPos);
// }
// int slsDetectorUsers::enableOverwriteFile(int enable, int detPos) {
// if (enable > 0)
// return detector.setFileOverWrite(enable, detPos);
// else
// return detector.getFileOverWrite(detPos);
// }
// int slsDetectorUsers::setReceiverStreamingFrequency(int freq, int detPos){
// return detector.setReceiverStreamingFrequency(freq, detPos);
// }
// int slsDetectorUsers::setReceiverStreamingTimer(int time_in_ms, int detPos){
// return detector.setReceiverStreamingTimer(time_in_ms, detPos);
// }
// int slsDetectorUsers::enableDataStreamingToClient(int i){
// return detector.enableDataStreamingToClient(i);
// }
// int slsDetectorUsers::enableDataStreamingFromReceiver(int i, int detPos){
// return detector.enableDataStreamingFromReceiver(i, detPos);
// }
// int slsDetectorUsers::setReceiverDataStreamingOutPort(int i, int detPos){
// if (i >= 0) {
// detector.setReceiverDataStreamingOutPort(i, detPos);
// }
// return detector.getReceiverStreamingPort(detPos);
// }
// int slsDetectorUsers::setClientDataStreamingInPort(int i, int detPos){
// if (i >= 0) {
// detector.setClientDataStreamingInPort(i, detPos);
// }
// return detector.getClientStreamingPort(detPos);
// }
// std::string slsDetectorUsers::setReceiverDataStreamingOutIP(const
// std::string& ip, int detPos){ if (ip.length()) {
// detector.setReceiverDataStreamingOutIP(ip, detPos);
// }
// return detector.getReceiverStreamingIP(detPos);
// }
// std::string slsDetectorUsers::setClientDataStreamingInIP(const std::string&
// ip, int detPos){ if (ip.length()) {
// detector.setClientDataStreamingInIP(ip, detPos);
// }
// return detector.getClientStreamingIP(detPos);
// }
// int slsDetectorUsers::enableGapPixels(int enable, int detPos) {
// return detector.enableGapPixels(enable, detPos);
// }
// int slsDetectorUsers::setReceiverFramesDiscardPolicy(int f, int detPos) {
// return
// detector.setReceiverFramesDiscardPolicy(slsDetectorDefs::frameDiscardPolicy(f),
// detPos);
// }
// int slsDetectorUsers::setReceiverPartialFramesPadding(int f, int detPos) {
// if (f>=0)
// return detector.setPartialFramesPadding(f, detPos);
// else
// return detector.getPartialFramesPadding(detPos);
// }
// int slsDetectorUsers::setReceiverFramesPerFile(int f, int detPos) {
// if (f > 0) {
// return detector.setFramesPerFile(f, detPos);
// }
// else {
// return detector.getFramesPerFile(detPos);
// }
// }
// int slsDetectorUsers::setDetectorMinMaxEnergyThreshold(const int index, int
// v, int detPos) {
// return detector.setDetectorMinMaxEnergyThreshold(index, v, detPos);
// }
// int slsDetectorUsers::setFrameMode(int value, int detPos) {
// return detector.setFrameMode(slsDetectorDefs::frameModeType(value),
// detPos);
// }
// int slsDetectorUsers::setDetectorMode(int value, int detPos) {
// return detector.setDetectorMode(slsDetectorDefs::detectorModeType(value),
// detPos);
// }
// /************************************************************************
// CALLBACKS & COMMAND LINE PARSING
// *********************************************************************/
// void slsDetectorUsers::registerDataCallback(void(
// *userCallback)(detectorData*, uint64_t, uint32_t, void*), void *pArg) {
// detector.registerDataCallback(userCallback,pArg);
// }
// void slsDetectorUsers::registerAcquisitionFinishedCallback(void(
// *func)(double,int, void*), void *pArg) {
// detector.registerAcquisitionFinishedCallback(func,pArg);
// }
// void slsDetectorUsers::putCommand(const std::string& command){
// multiSlsDetectorClient(command, slsDetectorDefs::PUT_ACTION, &detector);
// }

View File

@ -3,6 +3,7 @@ target_sources(tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test-slsDetector.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-rx.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-pattern.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-eiger.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-jungfrau.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-mythen3.cpp
@ -13,6 +14,7 @@ target_sources(tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-global.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-Result.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdParser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-Module.cpp
)
target_include_directories(tests PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>")

View File

@ -17,8 +17,7 @@ using test::PUT;
/* dacs */
TEST_CASE("Setting and reading back Chip test board dacs",
"[.cmd][.dacs][.new]") {
TEST_CASE("dac", "[.cmd][.dacs][.new]") {
// dac 0 to dac 17
Detector det;
@ -100,3 +99,803 @@ TEST_CASE("Setting and reading back Chip test board dacs",
REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET));
}
}
TEST_CASE("adcvpp", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_val = det.getDAC(defs::ADC_VPP, false);
{
std::ostringstream oss;
proxy.Call("adcvpp", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcvpp 1\n");
}
{
std::ostringstream oss;
proxy.Call("adcvpp", {"1140", "mv"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcvpp 1140 mv\n");
}
{
std::ostringstream oss;
proxy.Call("adcvpp", {"mv"}, -1, GET, oss);
REQUIRE(oss.str() == "adcvpp 1140 mv\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setDAC(defs::ADC_VPP, prev_val[i], false, {i});
}
} else {
REQUIRE_THROWS(proxy.Call("adcvpp", {}, -1, GET));
}
}
/* CTB/ Moench Specific */
TEST_CASE("samples", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_asamples = det.getNumberOfAnalogSamples();
sls::Result<int> prev_dsamples = 0;
if (det_type == defs::CHIPTESTBOARD) {
prev_dsamples = det.getNumberOfDigitalSamples();
}
{
std::ostringstream oss;
proxy.Call("samples", {"25"}, -1, PUT, oss);
REQUIRE(oss.str() == "samples 25\n");
}
{
std::ostringstream oss;
proxy.Call("samples", {"450"}, -1, PUT, oss);
REQUIRE(oss.str() == "samples 450\n");
}
{
std::ostringstream oss;
proxy.Call("samples", {}, -1, GET, oss);
REQUIRE(oss.str() == "samples 450\n");
}
{
std::ostringstream oss;
proxy.Call("asamples", {}, -1, GET, oss);
REQUIRE(oss.str() == "asamples 450\n");
}
if (det_type == defs::CHIPTESTBOARD) {
std::ostringstream oss;
proxy.Call("dsamples", {}, -1, GET, oss);
REQUIRE(oss.str() == "dsamples 450\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setNumberOfAnalogSamples(prev_asamples[i], {i});
if (det_type == defs::CHIPTESTBOARD) {
det.setNumberOfDigitalSamples(prev_dsamples[i], {i});
}
}
} else {
REQUIRE_THROWS(proxy.Call("samples", {}, -1, GET));
}
}
TEST_CASE("asamples", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_val = det.getNumberOfAnalogSamples();
{
std::ostringstream oss;
proxy.Call("asamples", {"25"}, -1, PUT, oss);
REQUIRE(oss.str() == "asamples 25\n");
}
{
std::ostringstream oss;
proxy.Call("asamples", {"450"}, -1, PUT, oss);
REQUIRE(oss.str() == "asamples 450\n");
}
{
std::ostringstream oss;
proxy.Call("asamples", {}, -1, GET, oss);
REQUIRE(oss.str() == "asamples 450\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setNumberOfAnalogSamples(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("asamples", {}, -1, GET));
}
}
TEST_CASE("adcclk", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_val = det.getADCClock();
{
std::ostringstream oss;
proxy.Call("adcclk", {"20"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcclk 20\n");
}
{
std::ostringstream oss;
proxy.Call("adcclk", {"10"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcclk 10\n");
}
{
std::ostringstream oss;
proxy.Call("adcclk", {}, -1, GET, oss);
REQUIRE(oss.str() == "adcclk 10\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setADCClock(prev_val[i], {i});
}
} else {
// clock index might work
// REQUIRE_THROWS(proxy.Call("adcclk", {}, -1, GET));
}
}
TEST_CASE("runclk", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_val = det.getRUNClock();
{
std::ostringstream oss;
proxy.Call("runclk", {"20"}, -1, PUT, oss);
REQUIRE(oss.str() == "runclk 20\n");
}
{
std::ostringstream oss;
proxy.Call("runclk", {"10"}, -1, PUT, oss);
REQUIRE(oss.str() == "runclk 10\n");
}
{
std::ostringstream oss;
proxy.Call("runclk", {}, -1, GET, oss);
REQUIRE(oss.str() == "runclk 10\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setRUNClock(prev_val[i], {i});
}
} else {
// clock index might work
// REQUIRE_THROWS(proxy.Call("runclk", {}, -1, GET));
}
}
TEST_CASE("syncclk", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
REQUIRE_NOTHROW(proxy.Call("syncclk", {}, -1, GET));
} else {
// clock index might work
// REQUIRE_THROWS(proxy.Call("syncclk", {}, -1, GET));
}
}
TEST_CASE("adcpipeline", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_val = det.getADCPipeline();
{
std::ostringstream oss;
proxy.Call("adcpipeline", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcpipeline 1\n");
}
{
std::ostringstream oss;
proxy.Call("adcpipeline", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcpipeline 0\n");
}
{
std::ostringstream oss;
proxy.Call("adcpipeline", {"15"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcpipeline 15\n");
}
{
std::ostringstream oss;
proxy.Call("adcpipeline", {}, -1, GET, oss);
REQUIRE(oss.str() == "adcpipeline 15\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setADCPipeline(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("adcpipeline", {}, -1, GET));
}
}
TEST_CASE("v_limit", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_val = det.getVoltage(defs::V_LIMIT);
{
std::ostringstream oss;
proxy.Call("v_limit", {"1500"}, -1, PUT, oss);
REQUIRE(oss.str() == "v_limit 1500\n");
}
{
std::ostringstream oss;
proxy.Call("v_limit", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "v_limit 0\n");
}
{
std::ostringstream oss;
proxy.Call("v_limit", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "v_limit 0\n");
}
{
std::ostringstream oss;
proxy.Call("v_limit", {}, -1, GET, oss);
REQUIRE(oss.str() == "v_limit 0\n");
}
for (int i = 0; i != det.size(); ++i) {
if (prev_val[i] == -100) {
prev_val[i] = 0;
}
det.setVoltage(defs::V_LIMIT, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("v_limit", {}, -1, GET));
}
}
TEST_CASE("adcenable", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_val = det.getADCEnableMask();
{
std::ostringstream oss;
proxy.Call("adcenable", {"0x8d0aa0d8"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcenable 0x8d0aa0d8\n");
}
{
std::ostringstream oss;
proxy.Call("adcenable", {"0xffffffff"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcenable 0xffffffff\n");
}
{
std::ostringstream oss;
proxy.Call("adcenable", {}, -1, GET, oss);
REQUIRE(oss.str() == "adcenable 0xffffffff\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setADCEnableMask(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("adcenable", {}, -1, GET));
}
}
TEST_CASE("adcenable10g", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_val = det.getTenGigaADCEnableMask();
{
std::ostringstream oss;
proxy.Call("adcenable10g", {"0xff0000ff"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcenable10g 0xff0000ff\n");
}
{
std::ostringstream oss;
proxy.Call("adcenable10g", {"0xffffffff"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcenable10g 0xffffffff\n");
}
{
std::ostringstream oss;
proxy.Call("adcenable10g", {}, -1, GET, oss);
REQUIRE(oss.str() == "adcenable10g 0xffffffff\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setTenGigaADCEnableMask(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("adcenable10g", {}, -1, GET));
}
}
/* CTB Specific */
TEST_CASE("dsamples", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getNumberOfDigitalSamples();
{
std::ostringstream oss;
proxy.Call("dsamples", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "dsamples 1\n");
}
{
std::ostringstream oss;
proxy.Call("dsamples", {"450"}, -1, PUT, oss);
REQUIRE(oss.str() == "dsamples 450\n");
}
{
std::ostringstream oss;
proxy.Call("dsamples", {}, -1, GET, oss);
REQUIRE(oss.str() == "dsamples 450\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setNumberOfDigitalSamples(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("dsamples", {}, -1, GET));
}
}
TEST_CASE("romode", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_romode = det.getReadoutMode();
auto prev_asamples = det.getNumberOfAnalogSamples();
auto prev_dsamples = det.getNumberOfDigitalSamples();
det.setNumberOfAnalogSamples(5000);
det.setNumberOfDigitalSamples(5000);
{
std::ostringstream oss;
proxy.Call("romode", {"digital"}, -1, PUT, oss);
REQUIRE(oss.str() == "romode digital\n");
}
{
std::ostringstream oss;
proxy.Call("romode", {"analog_digital"}, -1, PUT, oss);
REQUIRE(oss.str() == "romode analog_digital\n");
}
{
std::ostringstream oss;
proxy.Call("romode", {"analog"}, -1, PUT, oss);
REQUIRE(oss.str() == "romode analog\n");
}
{
std::ostringstream oss;
proxy.Call("romode", {}, -1, GET, oss);
REQUIRE(oss.str() == "romode analog\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setReadoutMode(prev_romode[i], {i});
det.setNumberOfAnalogSamples(prev_asamples[i], {i});
det.setNumberOfDigitalSamples(prev_dsamples[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("romode", {}, -1, GET));
}
}
TEST_CASE("dbitclk", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getRUNClock();
{
std::ostringstream oss;
proxy.Call("dbitclk", {"20"}, -1, PUT, oss);
REQUIRE(oss.str() == "dbitclk 20\n");
}
{
std::ostringstream oss;
proxy.Call("dbitclk", {"10"}, -1, PUT, oss);
REQUIRE(oss.str() == "dbitclk 10\n");
}
{
std::ostringstream oss;
proxy.Call("dbitclk", {}, -1, GET, oss);
REQUIRE(oss.str() == "dbitclk 10\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setRUNClock(prev_val[i], {i});
}
} else {
// clock index might work
// REQUIRE_THROWS(proxy.Call("dbitclk", {}, -1, GET));
}
}
TEST_CASE("dbitpipeline", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getDBITPipeline();
{
std::ostringstream oss;
proxy.Call("dbitpipeline", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "dbitpipeline 1\n");
}
{
std::ostringstream oss;
proxy.Call("dbitpipeline", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "dbitpipeline 0\n");
}
{
std::ostringstream oss;
proxy.Call("dbitpipeline", {"15"}, -1, PUT, oss);
REQUIRE(oss.str() == "dbitpipeline 15\n");
}
{
std::ostringstream oss;
proxy.Call("dbitpipeline", {}, -1, GET, oss);
REQUIRE(oss.str() == "dbitpipeline 15\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setDBITPipeline(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("dbitpipeline", {}, -1, GET));
}
}
TEST_CASE("v_a", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getVoltage(defs::V_POWER_A);
{
std::ostringstream oss1, oss2;
proxy.Call("v_a", {"700"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "v_a 700\n");
proxy.Call("v_a", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "v_a 700\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setVoltage(defs::V_POWER_A, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("v_a", {}, -1, GET));
}
}
TEST_CASE("v_b", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getVoltage(defs::V_POWER_B);
{
std::ostringstream oss1, oss2;
proxy.Call("v_b", {"700"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "v_b 700\n");
proxy.Call("v_b", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "v_b 700\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setVoltage(defs::V_POWER_B, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("v_b", {}, -1, GET));
}
}
TEST_CASE("v_c", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getVoltage(defs::V_POWER_C);
{
std::ostringstream oss1, oss2;
proxy.Call("v_c", {"700"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "v_c 700\n");
proxy.Call("v_c", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "v_c 700\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setVoltage(defs::V_POWER_C, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("v_c", {}, -1, GET));
}
}
TEST_CASE("v_d", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getVoltage(defs::V_POWER_D);
{
std::ostringstream oss1, oss2;
proxy.Call("v_d", {"700"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "v_d 700\n");
proxy.Call("v_d", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "v_d 700\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setVoltage(defs::V_POWER_D, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("v_d", {}, -1, GET));
}
}
TEST_CASE("v_io", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
// better not to play with setting it
REQUIRE_NOTHROW(proxy.Call("v_io", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("v_io", {}, -1, GET));
}
}
TEST_CASE("v_chip", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
// better not to play with setting it
REQUIRE_NOTHROW(proxy.Call("v_chip", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("v_chip", {}, -1, GET));
}
}
TEST_CASE("vm_a", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("vm_a", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("vm_a", {}, -1, GET));
}
}
TEST_CASE("vm_b", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("vm_b", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("vm_b", {}, -1, GET));
}
}
TEST_CASE("vm_c", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("vm_c", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("vm_c", {}, -1, GET));
}
}
TEST_CASE("vm_d", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("vm_d", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("vm_d", {}, -1, GET));
}
}
TEST_CASE("vm_io", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("vm_io", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("vm_io", {}, -1, GET));
}
}
TEST_CASE("im_a", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("im_a", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("im_a", {}, -1, GET));
}
}
TEST_CASE("im_b", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("im_b", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("im_b", {}, -1, GET));
}
}
TEST_CASE("im_c", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("im_c", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("im_c", {}, -1, GET));
}
}
TEST_CASE("im_d", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("im_d", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("im_d", {}, -1, GET));
}
}
TEST_CASE("im_io", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("im_io", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("im_io", {}, -1, GET));
}
}
TEST_CASE("adc", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
for (int i = 0; i <= 8; ++i) {
REQUIRE_NOTHROW(proxy.Call("adc", {std::to_string(i)}, -1, GET));
REQUIRE_THROWS(proxy.Call("adc", {"0"}, -1, PUT));
}
} else {
REQUIRE_THROWS(proxy.Call("adc", {"0"}, -1, GET));
}
}
TEST_CASE("extsampling", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getExternalSampling();
{
std::ostringstream oss;
proxy.Call("extsampling", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "extsampling 1\n");
}
{
std::ostringstream oss;
proxy.Call("extsampling", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "extsampling 0\n");
}
{
std::ostringstream oss;
proxy.Call("extsampling", {}, -1, GET, oss);
REQUIRE(oss.str() == "extsampling 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setExternalSampling(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("extsampling", {}, -1, GET));
}
}
TEST_CASE("extsamplingsrc", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getExternalSamplingSource();
{
std::ostringstream oss;
proxy.Call("extsamplingsrc", {"63"}, -1, PUT, oss);
REQUIRE(oss.str() == "extsamplingsrc 63\n");
}
{
std::ostringstream oss;
proxy.Call("extsamplingsrc", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "extsamplingsrc 0\n");
}
{
std::ostringstream oss;
proxy.Call("extsamplingsrc", {}, -1, GET, oss);
REQUIRE(oss.str() == "extsamplingsrc 0\n");
}
REQUIRE_THROWS(proxy.Call("extsamplingsrc", {"64"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setExternalSamplingSource(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("extsamplingsrc", {}, -1, GET));
}
}
TEST_CASE("diodelay", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
{
std::ostringstream oss;
proxy.Call("diodelay", {"0x01010", "0"}, -1, PUT, oss);
REQUIRE(oss.str() == "diodelay [0x01010, 0]\n");
}
{
std::ostringstream oss;
proxy.Call("diodelay", {"0x01010", "775"}, -1, PUT, oss);
REQUIRE(oss.str() == "diodelay [0x01010, 775]\n");
}
REQUIRE_THROWS(proxy.Call("diodelay", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("diodelay", {"0x01010", "776"}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("diodelay", {"0x01010", "775"}, -1, PUT));
}
}
TEST_CASE("led", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getLEDEnable();
{
std::ostringstream oss;
proxy.Call("led", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "led 1\n");
}
{
std::ostringstream oss;
proxy.Call("led", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "led 0\n");
}
{
std::ostringstream oss;
proxy.Call("led", {}, -1, GET, oss);
REQUIRE(oss.str() == "led 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setLEDEnable(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("led", {}, -1, GET));
}
}

View File

@ -4,6 +4,7 @@
#include "sls_detector_defs.h"
#include <array>
#include <sstream>
#include <thread>
#include "test-CmdProxy-global.h"
#include "tests/globals.h"
@ -228,52 +229,97 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd][.dacs][.new]") {
}
}
TEST_CASE("Eiger transmission delay", "[.cmd]") {
/* acquisition */
TEST_CASE("trigger", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_THROWS(proxy.Call("trigger", {}, -1, GET));
auto det_type = det.getDetectorType().squash();
if (det_type != defs::EIGER) {
REQUIRE_THROWS(proxy.Call("trigger", {}, -1, PUT));
} else {
auto prev_timing =
det.getTimingMode().tsquash("inconsistent timing mode in test");
auto prev_frames =
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
auto prev_exptime =
det.getExptime().tsquash("inconsistent exptime in test");
auto prev_period =
det.getPeriod().tsquash("inconsistent period in test");
det.setTimingMode(defs::TRIGGER_EXPOSURE);
det.setNumberOfFrames(1);
det.setExptime(std::chrono::milliseconds(1));
det.setPeriod(std::chrono::milliseconds(1));
auto startingfnum = det.getStartingFrameNumber().tsquash(
"inconsistent frame nr in test");
det.startDetector();
{
std::ostringstream oss;
proxy.Call("trigger", {}, -1, PUT, oss);
REQUIRE(oss.str() == "trigger successful\n");
}
std::this_thread::sleep_for(std::chrono::seconds(2));
auto currentfnum = det.getStartingFrameNumber().tsquash(
"inconsistent frame nr in test");
REQUIRE(startingfnum + 1 == currentfnum);
det.stopDetector();
det.setTimingMode(prev_timing);
det.setNumberOfFrames(prev_frames);
}
}
/* Network Configuration (Detector<->Receiver) */
TEST_CASE("txndelay_left", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
auto frame = det.getTransmissionDelayFrame();
auto left = det.getTransmissionDelayLeft();
auto right = det.getTransmissionDelayRight();
if (det_type == defs::EIGER) {
SECTION("txndelay_frame") {
std::ostringstream oss1, oss2;
proxy.Call("txndelay_frame", {"5000"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "txndelay_frame 5000\n");
proxy.Call("txndelay_frame", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "txndelay_frame 5000\n");
}
SECTION("txndelay_left") {
auto prev_val = det.getTransmissionDelayLeft();
{
std::ostringstream oss1, oss2;
proxy.Call("txndelay_left", {"5000"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "txndelay_left 5000\n");
proxy.Call("txndelay_left", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "txndelay_left 5000\n");
}
SECTION("txndelay_right") {
for (int i = 0; i != det.size(); ++i) {
det.setTransmissionDelayLeft(prev_val[i]);
}
} else {
REQUIRE_THROWS(proxy.Call("txndelay_left", {}, -1, GET));
}
}
TEST_CASE("txndelay_right", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_val = det.getTransmissionDelayRight();
{
std::ostringstream oss1, oss2;
proxy.Call("txndelay_right", {"5000"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "txndelay_right 5000\n");
proxy.Call("txndelay_right", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "txndelay_right 5000\n");
}
// Reset to previous values
for (int i = 0; i != det.size(); ++i) {
det.setTransmissionDelayFrame(frame[i]);
det.setTransmissionDelayLeft(left[i]);
det.setTransmissionDelayRight(right[i]);
det.setTransmissionDelayRight(prev_val[i]);
}
} else {
REQUIRE_THROWS(proxy.Call("txndelay_right", {}, -1, GET));
}
}
TEST_CASE("dr", "[.cmd]") {
/* Eiger Specific */
TEST_CASE("dr", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
// The only detector currently supporting setting dr
// is EIGER?
auto dr = det.getDynamicRange().squash();
std::array<int, 4> vals{4, 8, 16, 32};
for (const auto val : vals) {
@ -284,6 +330,17 @@ TEST_CASE("dr", "[.cmd]") {
REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n');
}
det.setDynamicRange(dr);
} else if (det_type == defs::MYTHEN3) {
// not updated in firmware to support anything other than 32 at the
// moment
std::ostringstream oss1, oss2;
proxy.Call("dr", {"32"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "dr 32\n");
proxy.Call("dr", {"32"}, -1, PUT, oss2);
REQUIRE(oss2.str() == "dr 32\n");
REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("dr", {"16"}, -1, PUT));
} else {
// For the other detectors we should get an error message
// except for dr 16
@ -299,124 +356,7 @@ TEST_CASE("dr", "[.cmd]") {
}
}
TEST_CASE("interruptsubframe", "[.cmd][!mayfail]") {
// TODO! Fix this for virtual server
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto previous = det.getInterruptSubframe();
std::ostringstream oss1, oss2, oss3;
proxy.Call("interruptsubframe", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "interruptsubframe 1\n");
proxy.Call("interruptsubframe", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "interruptsubframe 1\n");
proxy.Call("interruptsubframe", {"0"}, -1, PUT, oss3);
REQUIRE(oss3.str() == "interruptsubframe 0\n");
for (int i = 0; i != det.size(); ++i) {
det.setInterruptSubframe(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("interruptsubframe", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("interruptsubframe", {"1"}, -1, PUT));
}
}
TEST_CASE("overflow", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto previous = det.getOverFlowMode();
std::ostringstream oss1, oss2, oss3;
proxy.Call("overflow", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "overflow 1\n");
proxy.Call("overflow", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "overflow 1\n");
proxy.Call("overflow", {"0"}, -1, PUT, oss3);
REQUIRE(oss3.str() == "overflow 0\n");
for (int i = 0; i != det.size(); ++i) {
det.setOverFlowMode(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("overflow", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("overflow", {"1"}, -1, PUT));
}
}
TEST_CASE("trimen", "[.cmd][.this]") {
// TODO! Also Mythen?
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto previous = det.getTrimEnergies();
std::ostringstream oss1, oss2;
proxy.Call("trimen", {"4500", "5400", "6400"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "trimen [4500, 5400, 6400]\n");
proxy.Call("trimen", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "trimen [4500, 5400, 6400]\n");
for (int i = 0; i != det.size(); ++i) {
det.setTrimEnergies(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("trimen", {"4500", "5400", "6400"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("trimen", {}, -1, GET));
}
}
// TEST_CASE("threshold"{
// })
// TEST_CASE("activate", "[.cmd][.eiger]") {
// if (test::type == slsDetectorDefs::EIGER) {
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate 1", PUT,
// nullptr, oss)); REQUIRE(oss.str() == "activate 1\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate 1 nopadding",
// PUT, nullptr, oss)); REQUIRE(oss.str() == "activate 1
// nopadding\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate 0 padding",
// PUT, nullptr, oss)); REQUIRE(oss.str() == "activate 0
// padding\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate 0 nopadding",
// PUT, nullptr, oss)); REQUIRE(oss.str() == "activate 0
// nopadding\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate 1 padding",
// PUT, nullptr, oss)); REQUIRE(oss.str() == "activate 1
// padding\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate", GET,
// nullptr, oss)); REQUIRE(oss.str() == "activate 1 padding\n");
// }
// } else {
// REQUIRE_THROWS(multiSlsDetectorClient("activate", GET));
// }
// }
TEST_CASE("subexptime", "[.cmd]") {
TEST_CASE("subexptime", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
@ -437,7 +377,7 @@ TEST_CASE("subexptime", "[.cmd]") {
}
}
TEST_CASE("subdeadtime", "[.cmd]") {
TEST_CASE("subdeadtime", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
@ -458,119 +398,469 @@ TEST_CASE("subdeadtime", "[.cmd]") {
}
}
TEST_CASE("tengiga", "[.cmd]") {
TEST_CASE("threshold", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::CHIPTESTBOARD) {
auto tengiga = det.getTenGiga();
det.setTenGiga(false);
std::ostringstream oss1, oss2;
proxy.Call("tengiga", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "tengiga 1\n");
proxy.Call("tengiga", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "tengiga 1\n");
for (int i = 0; i != det.size(); ++i) {
det.setTenGiga(tengiga[i], {i});
if (det_type == defs::EIGER) {
auto prev_threshold = det.getThresholdEnergy();
auto prev_energies =
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
if (prev_energies.size() != 0) {
std::ostringstream oss1, oss2;
proxy.Call("threshold", {"4500", "standard"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "threshold [4500, standard]\n");
proxy.Call("threshold", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "threshold 4500\n");
det.setTrimEnergies(prev_energies);
for (int i = 0; i != det.size(); ++i) {
if (prev_threshold[i] >= 0) {
det.setThresholdEnergy(prev_threshold[i], defs::STANDARD,
true, {i});
}
}
}
REQUIRE_NOTHROW(proxy.Call("threshold", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("threshold", {}, -1, GET));
}
}
TEST_CASE("quad", "[.cmd]") {
// TODO! set and get once available in virtual detector
TEST_CASE("thresholdnotb", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_threshold = det.getThresholdEnergy();
auto prev_energies =
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
if (prev_energies.size() != 0) {
std::ostringstream oss1, oss2;
proxy.Call("thresholdnotb", {"4500 standard"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "thresholdnotb [4500 standard]\n");
proxy.Call("threshold", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "threshold 4500\n");
det.setTrimEnergies(prev_energies);
for (int i = 0; i != det.size(); ++i) {
if (prev_threshold[i] >= 0) {
det.setThresholdEnergy(prev_threshold[i], defs::STANDARD,
false, {i});
}
}
}
REQUIRE_NOTHROW(proxy.Call("threshold", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("thresholdnotb", {}, -1, GET));
}
}
TEST_CASE("settingspath", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val = det.getSettingsPath();
{
std::ostringstream oss1, oss2;
proxy.Call("settingspath", {"/tmp"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "settingspath /tmp\n");
proxy.Call("settingspath", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "settingspath /tmp\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setSettingsPath(prev_val[i], {i});
}
}
TEST_CASE("parallel", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_val = det.getParallelMode();
{
std::ostringstream oss;
proxy.Call("parallel", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "parallel 1\n");
}
{
std::ostringstream oss;
proxy.Call("parallel", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "parallel 0\n");
}
{
std::ostringstream oss;
proxy.Call("parallel", {}, -1, GET, oss);
REQUIRE(oss.str() == "parallel 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setParallelMode(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("parallel", {}, -1, GET));
}
}
TEST_CASE("overflow", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto previous = det.getOverFlowMode();
std::ostringstream oss1, oss2, oss3;
proxy.Call("overflow", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "overflow 1\n");
proxy.Call("overflow", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "overflow 1\n");
proxy.Call("overflow", {"0"}, -1, PUT, oss3);
REQUIRE(oss3.str() == "overflow 0\n");
for (int i = 0; i != det.size(); ++i) {
det.setOverFlowMode(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("overflow", {}, -1, GET));
}
}
TEST_CASE("storeinram", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto previous = det.getStoreInRamMode();
std::ostringstream oss1, oss2, oss3;
proxy.Call("storeinram", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "storeinram 1\n");
proxy.Call("storeinram", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "storeinram 1\n");
proxy.Call("storeinram", {"0"}, -1, PUT, oss3);
REQUIRE(oss3.str() == "storeinram 0\n");
for (int i = 0; i != det.size(); ++i) {
det.setStoreInRamMode(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("storeinram", {}, -1, GET));
}
}
TEST_CASE("flippeddatax", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto previous = det.getBottom();
std::ostringstream oss1, oss2, oss3;
proxy.Call("flippeddatax", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "flippeddatax 1\n");
proxy.Call("flippeddatax", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "flippeddatax 1\n");
proxy.Call("flippeddatax", {"0"}, -1, PUT, oss3);
REQUIRE(oss3.str() == "flippeddatax 0\n");
for (int i = 0; i != det.size(); ++i) {
det.setBottom(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("flippeddatax", {}, -1, GET));
}
}
TEST_CASE("trimen", "[.cmd][.this][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto previous = det.getTrimEnergies();
std::ostringstream oss1, oss2;
proxy.Call("trimen", {"4500", "5400", "6400"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "trimen [4500, 5400, 6400]\n");
proxy.Call("trimen", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "trimen [4500, 5400, 6400]\n");
for (int i = 0; i != det.size(); ++i) {
det.setTrimEnergies(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("trimen", {"4500", "5400", "6400"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("trimen", {}, -1, GET));
}
}
TEST_CASE("ratecorr", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_dr = det.getDynamicRange().tsquash("inconsistent dr to test");
auto prev_tau = det.getRateCorrection();
det.setDynamicRange(16);
{
std::ostringstream oss;
proxy.Call("ratecorr", {"120"}, -1, PUT, oss);
REQUIRE(oss.str() == "ratecorr 120ns\n");
}
{
std::ostringstream oss;
proxy.Call("ratecorr", {}, -1, GET, oss);
REQUIRE(oss.str() == "ratecorr 120ns\n");
}
// may fail if default settings not loaded
// REQUIRE_NOTHROW(proxy.Call("ratecorr", {"-1"}, -1, PUT));
{
std::ostringstream oss;
proxy.Call("ratecorr", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "ratecorr 0ns\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setRateCorrection(prev_tau[i], {i});
}
det.setDynamicRange(prev_dr);
} else {
REQUIRE_THROWS(proxy.Call("ratecorr", {}, -1, GET));
}
}
TEST_CASE("readnlines", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_val = det.getPartialReadout();
{
std::ostringstream oss;
proxy.Call("readnlines", {"256"}, -1, PUT, oss);
REQUIRE(oss.str() == "readnlines 256\n");
}
{
std::ostringstream oss;
proxy.Call("readnlines", {}, -1, GET, oss);
REQUIRE(oss.str() == "readnlines 256\n");
}
{
std::ostringstream oss;
proxy.Call("readnlines", {"16"}, -1, PUT, oss);
REQUIRE(oss.str() == "readnlines 16\n");
}
REQUIRE_THROWS(proxy.Call("readnlines", {"0"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setPartialReadout(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("readnlines", {}, -1, GET));
}
}
TEST_CASE("interruptsubframe", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_val = det.getInterruptSubframe();
std::ostringstream oss1, oss2, oss3;
proxy.Call("interruptsubframe", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "interruptsubframe 1\n");
proxy.Call("interruptsubframe", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "interruptsubframe 1\n");
proxy.Call("interruptsubframe", {"0"}, -1, PUT, oss3);
REQUIRE(oss3.str() == "interruptsubframe 0\n");
for (int i = 0; i != det.size(); ++i) {
det.setInterruptSubframe(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("interruptsubframe", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("interruptsubframe", {"1"}, -1, PUT));
}
}
TEST_CASE("measuredperiod", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_frames = det.getNumberOfFrames().tsquash(
"inconsistent number of frames to test");
auto prev_timing =
det.getTimingMode().tsquash("inconsistent timing mode to test");
auto prev_period = det.getPeriod();
det.setNumberOfFrames(2);
det.setPeriod(std::chrono::seconds(1));
det.setTimingMode(defs::AUTO_TIMING);
det.startDetector();
std::this_thread::sleep_for(std::chrono::seconds(3));
std::ostringstream oss;
proxy.Call("measuredperiod", {}, -1, GET, oss);
std::string st = oss.str();
std::string s = st.erase(0, strlen("measuredperiod "));
double val = std::stod(s);
// REQUIRE(val >= 1.0);
REQUIRE(val < 2.0);
for (int i = 0; i != det.size(); ++i) {
det.setPeriod(prev_period[i], {i});
}
det.setNumberOfFrames(prev_frames);
det.setTimingMode(prev_timing);
} else {
REQUIRE_THROWS(proxy.Call("measuredperiod", {}, -1, GET));
}
}
TEST_CASE("measuredsubperiod", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_frames = det.getNumberOfFrames().tsquash(
"inconsistent number of frames to test");
auto prev_timing =
det.getTimingMode().tsquash("inconsistent timing mode to test");
auto prev_period = det.getPeriod();
auto prev_dr = det.getDynamicRange().tsquash("inconsistent dr to test");
det.setNumberOfFrames(1);
det.setPeriod(std::chrono::seconds(1));
det.setTimingMode(defs::AUTO_TIMING);
det.setDynamicRange(32);
det.startDetector();
std::this_thread::sleep_for(std::chrono::seconds(3));
std::ostringstream oss;
proxy.Call("measuredsubperiod", {}, -1, GET, oss);
std::string st = oss.str();
std::string s = st.erase(0, strlen("measuredsubperiod "));
double val = std::stod(s);
REQUIRE(val >= 0);
REQUIRE(val < 1000);
for (int i = 0; i != det.size(); ++i) {
det.setPeriod(prev_period[i], {i});
}
det.setNumberOfFrames(prev_frames);
det.setTimingMode(prev_timing);
det.setDynamicRange(prev_dr);
} else {
REQUIRE_THROWS(proxy.Call("measuredsubperiod", {}, -1, GET));
}
}
TEST_CASE("activate", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_val = det.getActive();
{
std::ostringstream oss;
proxy.Call("activate", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "activate 1\n");
}
{
std::ostringstream oss;
proxy.Call("activate", {"1", "nopadding"}, -1, PUT, oss);
REQUIRE(oss.str() == "activate 1 nopadding\n");
}
{
std::ostringstream oss;
proxy.Call("activate", {"0", "padding"}, -1, PUT, oss);
REQUIRE(oss.str() == "activate 0 padding\n");
}
{
std::ostringstream oss;
proxy.Call("activate", {"0", "nopadding"}, -1, PUT, oss);
REQUIRE(oss.str() == "activate 0 nopadding\n");
}
{
std::ostringstream oss;
proxy.Call("activate", {"1", "padding"}, -1, PUT, oss);
REQUIRE(oss.str() == "activate 1 padding\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setActive(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("activate", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("activate", {"1"}, -1, PUT));
}
}
TEST_CASE("partialreset", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_val = det.getPartialReset();
std::ostringstream oss1, oss2, oss3;
proxy.Call("partialreset", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "partialreset 1\n");
proxy.Call("partialreset", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "partialreset 1\n");
proxy.Call("partialreset", {"0"}, -1, PUT, oss3);
REQUIRE(oss3.str() == "partialreset 0\n");
for (int i = 0; i != det.size(); ++i) {
det.setPartialReset(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("partialreset", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("partialreset", {"1"}, -1, PUT));
}
}
TEST_CASE("pulse", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
REQUIRE_THROWS(proxy.Call("pulse", {}, -1, GET));
std::ostringstream oss;
proxy.Call("pulse", {"1", "1", "5"}, -1, PUT, oss);
REQUIRE(oss.str() == "pulse [1, 1, 5]\n");
} else {
REQUIRE_THROWS(proxy.Call("pulse", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("pulse", {"1", "1", "5"}, -1, PUT));
}
}
TEST_CASE("pulsenmove", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
REQUIRE_THROWS(proxy.Call("pulsenmove", {}, -1, GET));
std::ostringstream oss;
proxy.Call("pulsenmove", {"1", "1", "5"}, -1, PUT, oss);
REQUIRE(oss.str() == "pulsenmove [1, 1, 5]\n");
} else {
REQUIRE_THROWS(proxy.Call("pulsenmove", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("pulsenmove", {"1", "1", "5"}, -1, PUT));
}
}
TEST_CASE("pulsechip", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
REQUIRE_THROWS(proxy.Call("pulsechip", {}, -1, GET));
std::ostringstream oss;
proxy.Call("pulsechip", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "pulsechip 1\n");
} else {
REQUIRE_THROWS(proxy.Call("pulsechip", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("pulsechip", {"1"}, -1, PUT));
}
}
TEST_CASE("quad", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_val = det.getQuad().tsquash("inconsistent quad to test");
// Quad only works with a single half module EIGER
std::ostringstream oss;
proxy.Call("quad", {}, -1, GET, oss);
REQUIRE(oss.str() == "quad 0\n");
det.setQuad(prev_val);
} else {
REQUIRE_THROWS(proxy.Call("quad", {}, -1, GET));
}
}
// TEST_CASE("trigger", "[.cmd]") {
// Detector det;
// CmdProxy proxy(&det);
// auto det_type = det.getDetectorType().squash();
// if (det_type != defs::EIGER) {
// proxy.Call("trigger", {}, -1, PUT);
// } else {
// {
// std::ostringstream oss;
// proxy.Call("timing", {"trigger"}, -1, PUT, oss);
// REQUIRE(oss.str() == "timing trigger\n");
// }
// auto startingfnum = det.getStartingFrameNumber().tsquash(
// "inconsistent frame nr in test");
// det.startDetector();
// {
// std::ostringstream oss;
// proxy.Call("trigger", {}, -1, PUT, oss);
// REQUIRE(oss.str() == "trigger successful\n");
// }
// auto currentfnum = det.getStartingFrameNumber().tsquash(
// "inconsistent frame nr in test");
// REQUIRE(startingfnum +1 == currentfnum);
// det.stopDetector();
// {
// std::ostringstream oss;
// proxy.Call("timing", {"auto"}, -1, PUT, oss);
// REQUIRE(oss.str() == "timing auto\n");
// }
// }
// if(test::type != slsDetectorDefs::EIGER) {
// REQUIRE_THROWS(multiSlsDetectorClient("trigger", PUT));
// } else {
// // trigger
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing trigger", PUT,
// nullptr, oss)); REQUIRE(oss.str() == "timing trigger\n");
// }
// int startingfnum = 0;
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
// nullptr, oss)); std::string s = (oss.str()).erase (0,
// strlen("startingfnum ")); startingfnum = std::stoi(s);
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT, nullptr,
// oss)); REQUIRE(oss.str() == "start successful\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("status", GET,
// nullptr, oss)); REQUIRE(oss.str() != "status idle\n");
// REQUIRE(oss.str()
// != "status stopped\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("trigger", PUT,
// nullptr, oss)); REQUIRE(oss.str() == "trigger successful\n");
// }
// REQUIRE_NOTHROW(multiSlsDetectorClient("stop", PUT));
// int currentfnum = 0;
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
// nullptr, oss)); std::string s = (oss.str()).erase (0,
// strlen("startingfnum ")); currentfnum = std::stoi(s);
// }
// REQUIRE((startingfnum + 1) == currentfnum);
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing auto", PUT));
// }
// }

View File

@ -94,3 +94,62 @@ TEST_CASE("Setting and reading back GOTTHARD dacs", "[.cmd][.dacs][.new]") {
REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET));
}
}
/* Gotthard Specific */
TEST_CASE("roi", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD) {
auto prev_val = det.getROI();
{
std::ostringstream oss;
proxy.Call("roi", {"0", "255"}, -1, PUT, oss);
REQUIRE(oss.str() == "roi [0, 255]\n");
}
{
std::ostringstream oss;
proxy.Call("roi", {"256", "511"}, -1, PUT, oss);
REQUIRE(oss.str() == "roi [256, 511]\n");
}
REQUIRE_THROWS(proxy.Call("roi", {"0", "256"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setROI(prev_val[i], i);
}
} else {
REQUIRE_THROWS(proxy.Call("roi", {}, -1, GET));
}
}
TEST_CASE("clearroi", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD) {
auto prev_val = det.getROI();
{
std::ostringstream oss;
proxy.Call("clearroi", {}, -1, PUT, oss);
REQUIRE(oss.str() == "clearroi [-1, -1]\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setROI(prev_val[i], i);
}
} else {
REQUIRE_THROWS(proxy.Call("clearroi", {}, -1, PUT));
}
}
TEST_CASE("exptimel", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD) {
REQUIRE_NOTHROW(proxy.Call("exptimel", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("exptimel", {}, -1, GET));
}
}

View File

@ -15,82 +15,6 @@ using sls::Detector;
using test::GET;
using test::PUT;
/* acquisition parameters */
TEST_CASE("bursts", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto prev_burst =
det.getNumberOfBursts().tsquash("#bursts should be same to test");
auto prev_trigger =
det.getNumberOfFrames().tsquash("#frames should be same to test");
auto prev_frames = det.getNumberOfTriggers().tsquash(
"#triggers should be same to test");
auto prev_timingMode = det.getTimingMode();
auto prev_burstMode = det.getBurstMode();
// changing continuous mode frames and bursts
det.setBurstMode(defs::BURST_INTERNAL);
det.setTimingMode(defs::AUTO_TIMING);
{
std::ostringstream oss;
proxy.Call("bursts", {"3"}, -1, PUT, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
REQUIRE_THROWS(proxy.Call("bursts", {"0"}, -1, PUT));
// trigger mode: reg set to 1, but bursts must be same
det.setTimingMode(defs::TRIGGER_EXPOSURE);
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
det.setTimingMode(defs::AUTO_TIMING);
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
// continuous mode: reg set to #frames,
// but bursts should return same value
det.setBurstMode(defs::BURST_OFF);
det.setNumberOfFrames(2);
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
det.setTimingMode(defs::TRIGGER_EXPOSURE);
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
det.setBurstMode(defs::BURST_INTERNAL);
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
// set to previous values
det.setNumberOfBursts(prev_burst);
det.setNumberOfFrames(prev_frames);
det.setNumberOfTriggers(prev_trigger);
for (int i = 0; i != det.size(); ++i) {
det.setTimingMode(prev_timingMode[i], {i});
det.setBurstMode(prev_burstMode[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("bursts", {}, -1, GET));
}
}
/* dacs */
TEST_CASE("Setting and reading back GOTTHARD2 dacs", "[.cmd][.dacs][.new]") {
@ -262,7 +186,164 @@ TEST_CASE("vchip_cs", "[.cmd][.onchipdacs][.new]") {
}
}
TEST_CASE("burstmode", "[.cmd]") {
/* Gotthard2 Specific */
TEST_CASE("bursts", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto prev_burst =
det.getNumberOfBursts().tsquash("#bursts should be same to test");
auto prev_trigger =
det.getNumberOfFrames().tsquash("#frames should be same to test");
auto prev_frames = det.getNumberOfTriggers().tsquash(
"#triggers should be same to test");
auto prev_timingMode = det.getTimingMode();
auto prev_burstMode = det.getBurstMode();
// changing continuous mode frames and bursts
det.setBurstMode(defs::BURST_INTERNAL);
det.setTimingMode(defs::AUTO_TIMING);
{
std::ostringstream oss;
proxy.Call("bursts", {"3"}, -1, PUT, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
REQUIRE_THROWS(proxy.Call("bursts", {"0"}, -1, PUT));
// trigger mode: reg set to 1, but bursts must be same
det.setTimingMode(defs::TRIGGER_EXPOSURE);
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
det.setTimingMode(defs::AUTO_TIMING);
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
// continuous mode: reg set to #frames,
// but bursts should return same value
det.setBurstMode(defs::BURST_OFF);
det.setNumberOfFrames(2);
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
det.setTimingMode(defs::TRIGGER_EXPOSURE);
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
det.setBurstMode(defs::BURST_INTERNAL);
{
std::ostringstream oss;
proxy.Call("bursts", {}, -1, GET, oss);
REQUIRE(oss.str() == "bursts 3\n");
}
// set to previous values
det.setNumberOfBursts(prev_burst);
det.setNumberOfFrames(prev_frames);
det.setNumberOfTriggers(prev_trigger);
for (int i = 0; i != det.size(); ++i) {
det.setTimingMode(prev_timingMode[i], {i});
det.setBurstMode(prev_burstMode[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("bursts", {}, -1, GET));
}
}
TEST_CASE("burstperiod", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto previous = det.getBurstPeriod();
std::ostringstream oss_set, oss_get;
proxy.Call("burstperiod", {"30ms"}, -1, PUT, oss_set);
REQUIRE(oss_set.str() == "burstperiod 30ms\n");
proxy.Call("burstperiod", {}, -1, GET, oss_get);
REQUIRE(oss_get.str() == "burstperiod 30ms\n");
// Reset to previous value
for (int i = 0; i != det.size(); ++i) {
det.setBurstPeriod(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("burstperiod", {}, -1, GET));
}
}
TEST_CASE("inj_ch", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
REQUIRE_THROWS(
proxy.Call("inj_ch", {"-1", "1"}, -1, PUT)); // invalid offset
REQUIRE_THROWS(
proxy.Call("inj_ch", {"0", "0"}, -1, PUT)); // invalid increment
{
std::ostringstream oss;
proxy.Call("inj_ch", {"0", "1"}, -1, PUT, oss);
REQUIRE(oss.str() == "inj_ch [0, 1]\n");
}
{
std::ostringstream oss;
proxy.Call("inj_ch", {}, -1, GET, oss);
REQUIRE(oss.str() == "inj_ch [0, 1]\n");
}
} else {
REQUIRE_THROWS(proxy.Call("inj_ch", {}, -1, GET));
}
}
TEST_CASE("vetophoton", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
REQUIRE_THROWS(proxy.Call("vetophoton", {}, -1, GET));
REQUIRE_NOTHROW(proxy.Call("vetophoton", {"-1"}, -1, GET));
REQUIRE_THROWS(proxy.Call("vetophoton", {"12", "1", "39950"}, -1,
PUT)); // invalid chip index
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "0"}, -1,
PUT)); // invalid photon number
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "1", "39950"}, -1,
PUT)); // invald file
} else {
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1"}, -1, GET));
}
}
TEST_CASE("vetoref", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
REQUIRE_THROWS(proxy.Call("vetoref", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x3ff"}, -1,
PUT)); // invalid chip index
REQUIRE_NOTHROW(proxy.Call("vetoref", {"1", "0x010"}, -1, PUT));
} else {
REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x0"}, -1, PUT));
}
}
TEST_CASE("burstmode", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
@ -293,92 +374,7 @@ TEST_CASE("burstmode", "[.cmd]") {
}
}
TEST_CASE("vetoref", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
REQUIRE_THROWS(proxy.Call("vetoref", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x3ff"}, -1,
PUT)); // invalid chip index
REQUIRE_NOTHROW(proxy.Call("vetoref", {"1", "0x010"}, -1, PUT));
} else {
REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x0"}, -1, PUT));
}
}
TEST_CASE("vetophoton", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
REQUIRE_THROWS(proxy.Call("vetophoton", {}, -1, GET));
REQUIRE_NOTHROW(proxy.Call("vetophoton", {"-1"}, -1, GET));
REQUIRE_THROWS(proxy.Call("vetophoton", {"12", "1", "39950"}, -1,
PUT)); // invalid chip index
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "0"}, -1,
PUT)); // invalid photon number
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "1", "39950"}, -1,
PUT)); // invald file
} else {
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1"}, -1, GET));
}
}
TEST_CASE("inj_ch", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto inj = det.getInjectChannel();
REQUIRE_THROWS(
proxy.Call("inj_ch", {"-1", "1"}, -1, PUT)); // invalid offset
REQUIRE_THROWS(
proxy.Call("inj_ch", {"0", "0"}, -1, PUT)); // invalid increment
{
std::ostringstream oss;
proxy.Call("inj_ch", {"0", "1"}, -1, PUT, oss);
REQUIRE(oss.str() == "inj_ch [0, 1]\n");
}
{
std::ostringstream oss;
proxy.Call("inj_ch", {}, -1, GET, oss);
REQUIRE(oss.str() == "inj_ch [0, 1]\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setInjectChannel(inj[i][0], inj[i][1], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("inj_ch", {}, -1, GET));
}
}
TEST_CASE("burstperiod", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto previous = det.getBurstPeriod();
std::ostringstream oss_set, oss_get;
proxy.Call("burstperiod", {"30ms"}, -1, PUT, oss_set);
REQUIRE(oss_set.str() == "burstperiod 30ms\n");
proxy.Call("burstperiod", {}, -1, GET, oss_get);
REQUIRE(oss_get.str() == "burstperiod 30ms\n");
// Reset to previous value
for (int i = 0; i != det.size(); ++i) {
det.setBurstPeriod(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("burstperiod", {}, -1, GET));
}
}
TEST_CASE("currentsource", "[.cmd]") {
TEST_CASE("currentsource", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
@ -408,7 +404,7 @@ TEST_CASE("currentsource", "[.cmd]") {
}
}
TEST_CASE("timingsource", "[.cmd]") {
TEST_CASE("timingsource", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
@ -437,3 +433,33 @@ TEST_CASE("timingsource", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("timingsource", {}, -1, GET));
}
}
TEST_CASE("veto", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto prev_val = det.getVeto();
{
std::ostringstream oss;
proxy.Call("veto", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "veto 1\n");
}
{
std::ostringstream oss;
proxy.Call("veto", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "veto 0\n");
}
{
std::ostringstream oss;
proxy.Call("veto", {}, -1, GET, oss);
REQUIRE(oss.str() == "veto 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setVeto(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("veto", {}, -1, GET));
}
}

View File

@ -94,114 +94,248 @@ TEST_CASE("Setting and reading back Jungfrau dacs", "[.cmd][.dacs][.new]") {
}
}
TEST_CASE("nframes", "[.cmd]") {
/* Network Configuration (Detector<->Receiver) */
TEST_CASE("selinterface", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) {
auto nframes = det.getNumberOfFramesFromStart().squash();
std::ostringstream oss;
proxy.Call("nframes", {}, -1, GET, oss);
REQUIRE(oss.str() == "nframes " + std::to_string(nframes) + "\n");
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getSelectedUDPInterface().tsquash(
"inconsistent selected interface to test");
{
std::ostringstream oss;
proxy.Call("selinterface", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "selinterface 1\n");
}
{
std::ostringstream oss;
proxy.Call("selinterface", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "selinterface 0\n");
}
{
std::ostringstream oss;
proxy.Call("selinterface", {}, -1, GET, oss);
REQUIRE(oss.str() == "selinterface 0\n");
}
det.selectUDPInterface(prev_val);
REQUIRE_THROWS(proxy.Call("selinterface", {"2"}, -1, PUT));
} else {
REQUIRE_THROWS(proxy.Call("nframes", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("selinterface", {}, -1, GET));
}
}
TEST_CASE("now", "[.cmd]") {
// TODO! can we test this?
/* Jungfrau Specific */
TEST_CASE("temp_threshold", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) {
std::ostringstream oss;
proxy.Call("now", {}, -1, GET, oss);
// Get only
REQUIRE_THROWS(proxy.Call("now", {"2019"}, -1, PUT));
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getThresholdTemperature();
{
std::ostringstream oss;
proxy.Call("temp_threshold", {"65"}, -1, PUT, oss);
REQUIRE(oss.str() == "temp_threshold 65\n");
}
{
std::ostringstream oss;
proxy.Call("temp_threshold", {"70"}, -1, PUT, oss);
REQUIRE(oss.str() == "temp_threshold 70\n");
}
{
std::ostringstream oss;
proxy.Call("temp_threshold", {}, -1, GET, oss);
REQUIRE(oss.str() == "temp_threshold 70\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setThresholdTemperature(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("now", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("temp_threshold", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("temp_threshold", {"70"}, -1, PUT));
}
}
TEST_CASE("timestamp", "[.cmd]") {
// TODO! can we test this?
TEST_CASE("temp_control", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) {
std::ostringstream oss;
proxy.Call("timestamp", {}, -1, GET, oss);
// Get only
REQUIRE_THROWS(proxy.Call("timestamp", {"2019"}, -1, PUT));
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getTemperatureControl();
{
std::ostringstream oss;
proxy.Call("temp_control", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "temp_control 0\n");
}
{
std::ostringstream oss;
proxy.Call("temp_control", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "temp_control 1\n");
}
{
std::ostringstream oss;
proxy.Call("temp_control", {}, -1, GET, oss);
REQUIRE(oss.str() == "temp_control 1\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setTemperatureControl(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("timestamp", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("temp_control", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("temp_control", {"0"}, -1, PUT));
}
}
TEST_CASE("adcreg", "[.cmd]") {
// TODO! what is a safe value to use?
TEST_CASE("temp_event", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
det_type == defs::GOTTHARD) {
std::ostringstream oss;
proxy.Call("adcreg", {"0x0", "0"}, -1, PUT, oss);
REQUIRE(oss.str() == "adcreg [0x0, 0]\n");
// This is a put only command
REQUIRE_THROWS(proxy.Call("adcreg", {}, -1, GET));
if (det_type == defs::JUNGFRAU) {
{
std::ostringstream oss;
proxy.Call("temp_event", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "temp_event cleared\n");
}
{
std::ostringstream oss;
proxy.Call("temp_event", {}, -1, GET, oss);
REQUIRE(oss.str() == "temp_event 0\n");
}
} else {
REQUIRE_THROWS(proxy.Call("adcreg", {"0x0", "0"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("adcreg", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("temp_event", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("temp_event", {"0"}, -1, PUT));
}
}
TEST_CASE("bustest", "[.cmd]") {
TEST_CASE("auto_comp_disable", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
det_type == defs::GOTTHARD) {
std::ostringstream oss;
proxy.Call("bustest", {}, -1, PUT, oss);
REQUIRE(oss.str() == "bustest successful\n");
REQUIRE_THROWS(proxy.Call("bustest", {}, -1, GET));
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getAutoCompDisable();
{
std::ostringstream oss;
proxy.Call("auto_comp_disable", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "auto_comp_disable 0\n");
}
{
std::ostringstream oss;
proxy.Call("auto_comp_disable", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "auto_comp_disable 1\n");
}
{
std::ostringstream oss;
proxy.Call("auto_comp_disable", {}, -1, GET, oss);
REQUIRE(oss.str() == "auto_comp_disable 1\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setAutoCompDisable(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("bustest", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("bustest", {}, -1, PUT));
REQUIRE_THROWS(proxy.Call("auto_comp_disable", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("auto_comp_disable", {"0"}, -1, PUT));
}
}
TEST_CASE("firmwaretest", "[.cmd]") {
TEST_CASE("storagecells", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
det_type == defs::GOTTHARD) {
std::ostringstream oss;
proxy.Call("firmwaretest", {}, -1, PUT, oss);
REQUIRE(oss.str() == "firmwaretest successful\n");
REQUIRE_THROWS(proxy.Call("firmwaretest", {}, -1, GET));
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getNumberOfAdditionalStorageCells().tsquash(
"inconsistent #additional storage cells to test");
{
std::ostringstream oss;
proxy.Call("storagecells", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecells 1\n");
}
{
std::ostringstream oss;
proxy.Call("storagecells", {"15"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecells 15\n");
}
{
std::ostringstream oss;
proxy.Call("storagecells", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecells 0\n");
}
{
std::ostringstream oss;
proxy.Call("storagecells", {}, -1, GET, oss);
REQUIRE(oss.str() == "storagecells 0\n");
}
REQUIRE_THROWS(proxy.Call("storagecells", {"16"}, -1, PUT));
det.setNumberOfAdditionalStorageCells(prev_val);
} else {
REQUIRE_THROWS(proxy.Call("firmwaretest", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("firmwaretest", {}, -1, PUT));
REQUIRE_THROWS(proxy.Call("storagecells", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("storagecells", {"0"}, -1, PUT));
}
}
TEST_CASE("resetfpga", "[.cmd]") {
TEST_CASE("storagecell_start", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) {
std::ostringstream oss;
proxy.Call("resetfpga", {}, -1, PUT, oss);
REQUIRE(oss.str() == "resetfpga successful\n");
REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, GET));
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getStorageCellStart();
{
std::ostringstream oss;
proxy.Call("storagecell_start", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecell_start 1\n");
}
{
std::ostringstream oss;
proxy.Call("storagecell_start", {"15"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecell_start 15\n");
}
{
std::ostringstream oss;
proxy.Call("storagecell_start", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecell_start 0\n");
}
{
std::ostringstream oss;
proxy.Call("storagecell_start", {}, -1, GET, oss);
REQUIRE(oss.str() == "storagecell_start 0\n");
}
REQUIRE_THROWS(proxy.Call("storagecell_start", {"16"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setStorageCellStart(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, PUT));
REQUIRE_THROWS(proxy.Call("storagecell_start", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("storagecell_start", {"0"}, -1, PUT));
}
}
TEST_CASE("storagecell_delay", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getStorageCellDelay();
{
std::ostringstream oss;
proxy.Call("storagecell_delay", {"1.62ms"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecell_delay 1.62ms\n");
}
{
std::ostringstream oss;
proxy.Call("storagecell_delay", {}, -1, GET, oss);
REQUIRE(oss.str() == "storagecell_delay 1.62ms\n");
}
{
std::ostringstream oss;
proxy.Call("storagecell_delay", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "storagecell_delay 0\n");
}
REQUIRE_THROWS(proxy.Call("storagecell_delay", {"1638376ns"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setStorageCellDelay(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("storagecell_delay", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("storagecell_delay", {"0"}, -1, PUT));
}
}

View File

@ -106,3 +106,121 @@ TEST_CASE("Setting and reading back MOENCH dacs", "[.cmd][.dacs][.new]") {
REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET));
}
}
/* Moench */
TEST_CASE("emin", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MOENCH) {
{
std::ostringstream oss;
proxy.Call("emin", {"100"}, -1, PUT, oss);
REQUIRE(oss.str() == "emin 100\n");
}
{
std::ostringstream oss;
proxy.Call("emin", {"200"}, -1, PUT, oss);
REQUIRE(oss.str() == "emin 200\n");
}
{
std::ostringstream oss;
proxy.Call("emin", {}, -1, GET, oss);
REQUIRE(oss.str() == "emin 200\n");
}
} else {
REQUIRE_THROWS(proxy.Call("emin", {}, -1, GET));
}
}
TEST_CASE("emax", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MOENCH) {
{
std::ostringstream oss;
proxy.Call("emax", {"100"}, -1, PUT, oss);
REQUIRE(oss.str() == "emax 100\n");
}
{
std::ostringstream oss;
proxy.Call("emax", {"200"}, -1, PUT, oss);
REQUIRE(oss.str() == "emax 200\n");
}
{
std::ostringstream oss;
proxy.Call("emax", {}, -1, GET, oss);
REQUIRE(oss.str() == "emax 200\n");
}
} else {
REQUIRE_THROWS(proxy.Call("emax", {}, -1, GET));
}
}
TEST_CASE("framemode", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MOENCH) {
{
std::ostringstream oss;
proxy.Call("framemode", {"pedestal"}, -1, PUT, oss);
REQUIRE(oss.str() == "framemode pedestal\n");
}
{
std::ostringstream oss;
proxy.Call("framemode", {"newpedestal"}, -1, PUT, oss);
REQUIRE(oss.str() == "framemode newpedestal\n");
}
{
std::ostringstream oss;
proxy.Call("framemode", {"flatfield"}, -1, PUT, oss);
REQUIRE(oss.str() == "framemode flatfield\n");
}
{
std::ostringstream oss;
proxy.Call("framemode", {"newflatfield"}, -1, PUT, oss);
REQUIRE(oss.str() == "framemode newflatfield\n");
}
{
std::ostringstream oss;
proxy.Call("framemode", {}, -1, GET, oss);
REQUIRE(oss.str() == "framemode newflatfield\n");
}
REQUIRE_THROWS(proxy.Call("framemode", {"counting"}, -1, PUT));
} else {
REQUIRE_THROWS(proxy.Call("framemode", {}, -1, GET));
}
}
TEST_CASE("detectormode", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MOENCH) {
{
std::ostringstream oss;
proxy.Call("detectormode", {"counting"}, -1, PUT, oss);
REQUIRE(oss.str() == "detectormode counting\n");
}
{
std::ostringstream oss;
proxy.Call("detectormode", {"interpolating"}, -1, PUT, oss);
REQUIRE(oss.str() == "detectormode interpolating\n");
}
{
std::ostringstream oss;
proxy.Call("detectormode", {"analog"}, -1, PUT, oss);
REQUIRE(oss.str() == "detectormode analog\n");
}
std::ostringstream oss;
proxy.Call("detectormode", {}, -1, GET, oss);
REQUIRE(oss.str() == "detectormode analog\n");
REQUIRE_THROWS(proxy.Call("detectormode", {"pedestal"}, -1, PUT));
} else {
REQUIRE_THROWS(proxy.Call("detectormode", {}, -1, GET));
}
}

View File

@ -89,7 +89,9 @@ TEST_CASE("Setting and reading back MYTHEN3 dacs", "[.cmd][.dacs][.new]") {
}
}
TEST_CASE("counters", "[.cmd]") {
/* Mythen3 Specific */
TEST_CASE("counters", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
@ -120,3 +122,243 @@ TEST_CASE("counters", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("counters", {}, -1, GET));
}
}
TEST_CASE("gates", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3) {
auto prev_val = det.getNumberOfGates();
{
std::ostringstream oss;
proxy.Call("gates", {"1000"}, -1, PUT, oss);
REQUIRE(oss.str() == "gates 1000\n");
}
{
std::ostringstream oss;
proxy.Call("gates", {}, -1, GET, oss);
REQUIRE(oss.str() == "gates 1000\n");
}
{
std::ostringstream oss;
proxy.Call("gates", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "gates 1\n");
}
REQUIRE_THROWS(proxy.Call("gates", {"0"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setNumberOfGates(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("gates", {}, -1, GET));
}
}
TEST_CASE("exptime1", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3) {
auto prev_val = det.getExptime(0);
{
std::ostringstream oss;
proxy.Call("exptime1", {"1.25s"}, -1, PUT, oss);
REQUIRE(oss.str() == "exptime1 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("exptime1", {}, -1, GET, oss);
REQUIRE(oss.str() == "exptime1 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("exptime1", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "exptime1 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setExptime(0, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("exptime1", {}, -1, GET));
}
}
TEST_CASE("exptime2", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3) {
auto prev_val = det.getExptime(1);
{
std::ostringstream oss;
proxy.Call("exptime2", {"1.25s"}, -1, PUT, oss);
REQUIRE(oss.str() == "exptime2 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("exptime2", {}, -1, GET, oss);
REQUIRE(oss.str() == "exptime2 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("exptime2", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "exptime2 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setExptime(1, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("exptime2", {}, -1, GET));
}
}
TEST_CASE("exptime3", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3) {
auto prev_val = det.getExptime(2);
{
std::ostringstream oss;
proxy.Call("exptime3", {"1.25s"}, -1, PUT, oss);
REQUIRE(oss.str() == "exptime3 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("exptime3", {}, -1, GET, oss);
REQUIRE(oss.str() == "exptime3 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("exptime3", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "exptime3 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setExptime(2, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("exptime3", {}, -1, GET));
}
}
TEST_CASE("gatedelay", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3) {
auto prev_val = det.getExptimeForAllGates().tsquash(
"inconsistent gatedelay to test");
if (prev_val[0] != prev_val[1] || prev_val[1] != prev_val[2]) {
throw sls::RuntimeError("inconsistent gatedelay for all gates");
}
{
std::ostringstream oss;
proxy.Call("gatedelay", {"0.05"}, -1, PUT, oss);
REQUIRE(oss.str() == "gatedelay 0.05\n");
}
if (det_type != defs::MYTHEN3) {
std::ostringstream oss;
proxy.Call("gatedelay", {}, -1, GET, oss);
REQUIRE(oss.str() == "gatedelay 50ms\n");
}
{
std::ostringstream oss;
proxy.Call("gatedelay", {"1s"}, -1, PUT, oss);
REQUIRE(oss.str() == "gatedelay 1s\n");
}
{
std::ostringstream oss;
proxy.Call("gatedelay", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "gatedelay 0\n");
}
det.setGateDelay(-1, prev_val[0]);
} else {
REQUIRE_THROWS(proxy.Call("gatedelay", {}, -1, GET));
}
}
TEST_CASE("gatedelay1", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3) {
auto prev_val = det.getGateDelay(0);
{
std::ostringstream oss;
proxy.Call("gatedelay1", {"1.25s"}, -1, PUT, oss);
REQUIRE(oss.str() == "gatedelay1 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("gatedelay1", {}, -1, GET, oss);
REQUIRE(oss.str() == "gatedelay1 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("gatedelay1", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "gatedelay1 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setGateDelay(0, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("gatedelay1", {}, -1, GET));
}
}
TEST_CASE("gatedelay2", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3) {
auto prev_val = det.getGateDelay(1);
{
std::ostringstream oss;
proxy.Call("gatedelay2", {"1.25s"}, -1, PUT, oss);
REQUIRE(oss.str() == "gatedelay2 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("gatedelay2", {}, -1, GET, oss);
REQUIRE(oss.str() == "gatedelay2 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("gatedelay2", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "gatedelay2 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setGateDelay(1, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("gatedelay2", {}, -1, GET));
}
}
TEST_CASE("gatedelay3", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3) {
auto prev_val = det.getGateDelay(2);
{
std::ostringstream oss;
proxy.Call("gatedelay3", {"1.25s"}, -1, PUT, oss);
REQUIRE(oss.str() == "gatedelay3 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("gatedelay3", {}, -1, GET, oss);
REQUIRE(oss.str() == "gatedelay3 1.25s\n");
}
{
std::ostringstream oss;
proxy.Call("gatedelay3", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "gatedelay3 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setGateDelay(2, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("gatedelay3", {}, -1, GET));
}
}

View File

@ -0,0 +1,544 @@
#include "CmdProxy.h"
#include "Detector.h"
#include "catch.hpp"
#include "sls_detector_defs.h"
#include <sstream>
#include "Result.h"
#include "ToString.h"
#include "test-CmdProxy-global.h"
#include "tests/globals.h"
#include "versionAPI.h"
using sls::CmdProxy;
using sls::Detector;
using test::GET;
using test::PUT;
/* Pattern */
TEST_CASE("pattern", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
// no proper test for put
REQUIRE_THROWS(proxy.Call("pattern", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("pattern", {}, -1, GET));
}
}
TEST_CASE("savepattern", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
REQUIRE_THROWS(
proxy.Call("savepattern", {"/tmp/pattern.txt"}, -1, GET));
REQUIRE_NOTHROW(
proxy.Call("savepattern", {"/tmp/pattern.txt"}, -1, PUT));
} else {
REQUIRE_THROWS(
proxy.Call("savepattern", {"/tmp/pattern.txt"}, -1, PUT));
}
}
TEST_CASE("patioctrl", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_val = det.getPatternIOControl();
{
std::ostringstream oss;
proxy.Call("patioctrl", {"0xc15004808d0a21a4"}, -1, PUT, oss);
REQUIRE(oss.str() == "patioctrl 0xc15004808d0a21a4\n");
}
{
std::ostringstream oss;
proxy.Call("patioctrl", {"0x0"}, -1, PUT, oss);
REQUIRE(oss.str() == "patioctrl 0x0\n");
}
{
std::ostringstream oss;
proxy.Call("patioctrl", {}, -1, GET, oss);
REQUIRE(oss.str() == "patioctrl 0x0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternIOControl(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patioctrl", {}, -1, GET));
}
}
TEST_CASE("patclkctrl", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
auto prev_val = det.getPatternClockControl();
{
std::ostringstream oss;
proxy.Call("patclkctrl", {"0xc15004808d0a21a4"}, -1, PUT, oss);
REQUIRE(oss.str() == "patclkctrl 0xc15004808d0a21a4\n");
}
{
std::ostringstream oss;
proxy.Call("patclkctrl", {"0x0"}, -1, PUT, oss);
REQUIRE(oss.str() == "patclkctrl 0x0\n");
}
{
std::ostringstream oss;
proxy.Call("patclkctrl", {}, -1, GET, oss);
REQUIRE(oss.str() == "patclkctrl 0x0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternClockControl(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patclkctrl", {}, -1, GET));
}
}
TEST_CASE("patword", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
int addr = 0x23;
std::string saddr = sls::ToStringHex(addr);
auto prev_val = det.getPatternWord(addr);
{
std::ostringstream oss;
proxy.Call("patword", {saddr, "0xc15004808d0a21a4"}, -1, PUT, oss);
REQUIRE(oss.str() ==
"patword [" + saddr + ", 0xc15004808d0a21a4]\n");
}
{
std::ostringstream oss;
proxy.Call("patword", {saddr, "0x0"}, -1, PUT, oss);
REQUIRE(oss.str() == "patword [" + saddr + ", 0x0]\n");
}
{
std::ostringstream oss;
proxy.Call("patword", {saddr}, -1, GET, oss);
REQUIRE(oss.str() == "patword 0x0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWord(addr, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patword", {"0x23"}, -1, GET));
}
}
TEST_CASE("patlimits", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopAddresses(-1);
{
std::ostringstream oss;
proxy.Call("patlimits", {"0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patlimits [0x20, 0x5c]\n");
}
{
std::ostringstream oss;
proxy.Call("patlimits", {}, -1, GET, oss);
REQUIRE(oss.str() == "patlimits [0x20, 0x5c]\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopAddresses(-1, prev_val[i][0], prev_val[i][1],
{i});
}
} else {
REQUIRE_THROWS(proxy.Call("patlimits", {}, -1, GET));
}
}
TEST_CASE("patloop0", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopAddresses(0);
{
std::ostringstream oss;
proxy.Call("patloop0", {"0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patloop0 [0x20, 0x5c]\n");
}
{
std::ostringstream oss;
proxy.Call("patloop0", {}, -1, GET, oss);
REQUIRE(oss.str() == "patloop0 [0x20, 0x5c]\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopAddresses(0, prev_val[i][0], prev_val[i][1], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patloop0", {}, -1, GET));
}
}
TEST_CASE("patloop1", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopAddresses(1);
{
std::ostringstream oss;
proxy.Call("patloop1", {"0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patloop1 [0x20, 0x5c]\n");
}
{
std::ostringstream oss;
proxy.Call("patloop1", {}, -1, GET, oss);
REQUIRE(oss.str() == "patloop1 [0x20, 0x5c]\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopAddresses(1, prev_val[i][0], prev_val[i][1], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patloop1", {}, -1, GET));
}
}
TEST_CASE("patloop2", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopAddresses(2);
{
std::ostringstream oss;
proxy.Call("patloop2", {"0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patloop2 [0x20, 0x5c]\n");
}
{
std::ostringstream oss;
proxy.Call("patloop2", {}, -1, GET, oss);
REQUIRE(oss.str() == "patloop2 [0x20, 0x5c]\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopAddresses(2, prev_val[i][0], prev_val[i][1], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patloop2", {}, -1, GET));
}
}
TEST_CASE("patnloop0", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopCycles(0);
{
std::ostringstream oss;
proxy.Call("patnloop0", {"5"}, -1, PUT, oss);
REQUIRE(oss.str() == "patnloop0 5\n");
}
{
std::ostringstream oss;
proxy.Call("patnloop0", {}, -1, GET, oss);
REQUIRE(oss.str() == "patnloop0 5\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopCycles(0, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patnloop0", {}, -1, GET));
}
}
TEST_CASE("patnloop1", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopCycles(1);
{
std::ostringstream oss;
proxy.Call("patnloop1", {"5"}, -1, PUT, oss);
REQUIRE(oss.str() == "patnloop1 5\n");
}
{
std::ostringstream oss;
proxy.Call("patnloop1", {}, -1, GET, oss);
REQUIRE(oss.str() == "patnloop1 5\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopCycles(1, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patnloop1", {}, -1, GET));
}
}
TEST_CASE("patnloop2", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopCycles(2);
{
std::ostringstream oss;
proxy.Call("patnloop2", {"5"}, -1, PUT, oss);
REQUIRE(oss.str() == "patnloop2 5\n");
}
{
std::ostringstream oss;
proxy.Call("patnloop2", {}, -1, GET, oss);
REQUIRE(oss.str() == "patnloop2 5\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopCycles(2, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patnloop2", {}, -1, GET));
}
}
TEST_CASE("patwait0", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitAddr(0);
{
std::ostringstream oss;
proxy.Call("patwait0", {"0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwait0 0x5c\n");
}
{
std::ostringstream oss;
proxy.Call("patwait0", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwait0 0x5c\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitAddr(0, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwait0", {}, -1, GET));
}
}
TEST_CASE("patwait1", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitAddr(1);
{
std::ostringstream oss;
proxy.Call("patwait1", {"0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwait1 0x5c\n");
}
{
std::ostringstream oss;
proxy.Call("patwait1", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwait1 0x5c\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitAddr(1, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwait1", {}, -1, GET));
}
}
TEST_CASE("patwait2", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitAddr(2);
{
std::ostringstream oss;
proxy.Call("patwait2", {"0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwait2 0x5c\n");
}
{
std::ostringstream oss;
proxy.Call("patwait2", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwait2 0x5c\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitAddr(2, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwait2", {}, -1, GET));
}
}
TEST_CASE("patwaittime0", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitTime(0);
{
std::ostringstream oss;
proxy.Call("patwaittime0", {"8589936640"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwaittime0 8589936640\n");
}
{
std::ostringstream oss;
proxy.Call("patwaittime0", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwaittime0 8589936640\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitTime(0, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwaittime0", {}, -1, GET));
}
}
TEST_CASE("patwaittime1", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitTime(1);
{
std::ostringstream oss;
proxy.Call("patwaittime1", {"8589936640"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwaittime1 8589936640\n");
}
{
std::ostringstream oss;
proxy.Call("patwaittime1", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwaittime1 8589936640\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitTime(1, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwaittime1", {}, -1, GET));
}
}
TEST_CASE("patwaittime2", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitTime(2);
{
std::ostringstream oss;
proxy.Call("patwaittime2", {"8589936640"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwaittime2 8589936640\n");
}
{
std::ostringstream oss;
proxy.Call("patwaittime2", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwaittime2 8589936640\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitTime(2, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwaittime2", {}, -1, GET));
}
}
TEST_CASE("patmask", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternMask();
{
std::ostringstream oss;
proxy.Call("patmask", {"0x842f020204200dc0"}, -1, PUT, oss);
REQUIRE(oss.str() == "patmask 0x842f020204200dc0\n");
}
{
std::ostringstream oss;
proxy.Call("patmask", {}, -1, GET, oss);
REQUIRE(oss.str() == "patmask 0x842f020204200dc0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternMask(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patmask", {}, -1, GET));
}
}
TEST_CASE("patsetbit", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternBitMask();
{
std::ostringstream oss;
proxy.Call("patsetbit", {"0x842f020204200dc0"}, -1, PUT, oss);
REQUIRE(oss.str() == "patsetbit 0x842f020204200dc0\n");
}
{
std::ostringstream oss;
proxy.Call("patsetbit", {}, -1, GET, oss);
REQUIRE(oss.str() == "patsetbit 0x842f020204200dc0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternBitMask(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patsetbit", {}, -1, GET));
}
}
TEST_CASE("patternstart", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_THROWS(proxy.Call("patternstart", {}, -1, GET));
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3) {
REQUIRE_NOTHROW(proxy.Call("patternstart", {}, -1, PUT));
} else {
REQUIRE_THROWS(proxy.Call("patternstart", {}, -1, PUT));
}
}

View File

@ -374,7 +374,7 @@ TEST_CASE("rx_lastclient", "[.cmd][.rx][.new]") {
/* File */
TEST_CASE("fformat", "[.cmd]") {
TEST_CASE("fformat", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val = det.getFileFormat();
@ -393,7 +393,7 @@ TEST_CASE("fformat", "[.cmd]") {
}
}
TEST_CASE("fpath", "[.cmd]") {
TEST_CASE("fpath", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val = det.getFilePath();
@ -412,7 +412,7 @@ TEST_CASE("fpath", "[.cmd]") {
}
}
TEST_CASE("fname", "[.cmd]") {
TEST_CASE("fname", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val = det.getFileNamePrefix();
@ -436,7 +436,7 @@ TEST_CASE("fname", "[.cmd]") {
}
}
TEST_CASE("findex", "[.cmd]") {
TEST_CASE("findex", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val = det.getAcquisitionIndex();
@ -460,7 +460,7 @@ TEST_CASE("findex", "[.cmd]") {
}
}
TEST_CASE("fwrite", "[.cmd]") {
TEST_CASE("fwrite", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val = det.getFileWrite();
@ -484,7 +484,7 @@ TEST_CASE("fwrite", "[.cmd]") {
}
}
TEST_CASE("fmaster", "[.cmd]") {
TEST_CASE("fmaster", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val = det.getMasterFileWrite();
@ -508,7 +508,7 @@ TEST_CASE("fmaster", "[.cmd]") {
}
}
TEST_CASE("foverwrite", "[.cmd]") {
TEST_CASE("foverwrite", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val = det.getFileOverWrite();

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
#include "Module.h"
#include "catch.hpp"
using dt = slsDetectorDefs::detectorType;
TEST_CASE("Construction with a defined detector type") {
sls::Module m(dt::EIGER);
REQUIRE(m.getDetectorType() == dt::EIGER);
}

View File

@ -191,6 +191,13 @@ void BinaryFile::CreateMasterFile(bool masterFileWriteEnable,
"Dbit Offset : %d\n"
"Dbit Bitset : %lld\n"
"Roi (xmin, xmax) : %d %d\n"
"Exptime1 (ns) : %lld\n"
"Exptime2 (ns) : %lld\n"
"Exptime3 (ns) : %lld\n"
"GateDelay1 (ns) : %lld\n"
"GateDelay2 (ns) : %lld\n"
"GateDelay3 (ns) : %lld\n"
"Gates : %d\n"
"Timestamp : %s\n\n"
"#Frame Header\n"
@ -224,7 +231,13 @@ void BinaryFile::CreateMasterFile(bool masterFileWriteEnable,
masterFileAttributes.dbitoffset,
(long long int)masterFileAttributes.dbitlist,
masterFileAttributes.roiXmin, masterFileAttributes.roiXmax,
ctime(&t));
(long long int)masterFileAttributes.exptime1Ns,
(long long int)masterFileAttributes.exptime2Ns,
(long long int)masterFileAttributes.exptime3Ns,
(long long int)masterFileAttributes.gateDelay1Ns,
(long long int)masterFileAttributes.gateDelay2Ns,
(long long int)masterFileAttributes.gateDelay3Ns,
masterFileAttributes.gates, ctime(&t));
if (strlen(message) > maxMasterFileSize) {
throw sls::RuntimeError("Master File Size " +
std::to_string(strlen(message)) +

View File

@ -1,7 +1,8 @@
#include "ClientInterface.h"
#include "FixedCapacityContainer.h"
#include "ServerSocket.h"
#include "StaticVector.h"
#include "ToString.h"
#include "sls_detector_exceptions.h"
#include "string_utils.h"
#include "versionAPI.h"
@ -196,7 +197,9 @@ int ClientInterface::functionTable(){
flist[F_SET_ADDITIONAL_JSON_PARAMETER] = &ClientInterface::set_additional_json_parameter;
flist[F_GET_ADDITIONAL_JSON_PARAMETER] = &ClientInterface::get_additional_json_parameter;
flist[F_GET_RECEIVER_PROGRESS] = &ClientInterface::get_progress;
flist[F_SET_RECEIVER_NUM_GATES] = &ClientInterface::set_num_gates;
flist[F_SET_RECEIVER_GATE_DELAY] = &ClientInterface::set_gate_delay;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
LOG(logDEBUG1) << "function fnum: " << i << " (" <<
getFunctionNameFromEnum((enum detFuncs)i) << ") located at " << flist[i];
@ -334,40 +337,47 @@ int ClientInterface::get_version(Interface &socket) {
int ClientInterface::setup_receiver(Interface &socket) {
auto arg = socket.Receive<rxParameters>();
LOG(logDEBUG1) << "detType:" << arg.detType << std::endl
<< "multiSize.x:" << arg.multiSize.x << std::endl
<< "multiSize.y:" << arg.multiSize.y << std::endl
<< "detId:" << arg.detId << std::endl
<< "hostname:" << arg.hostname << std::endl
<< "udpInterfaces:" << arg.udpInterfaces << std::endl
<< "udp_dstport:" << arg.udp_dstport << std::endl
<< "udp_dstip:" << sls::IpAddr(arg.udp_dstip) << std::endl
<< "udp_dstmac:" << sls::MacAddr(arg.udp_dstmac) << std::endl
<< "udp_dstport2:" << arg.udp_dstport2 << std::endl
<< "udp_dstip2:" << sls::IpAddr(arg.udp_dstip2) << std::endl
<< "udp_dstmac2:" << sls::MacAddr(arg.udp_dstmac2)
<< std::endl
<< "frames:" << arg.frames << std::endl
<< "triggers:" << arg.triggers << std::endl
<< "bursts:" << arg.bursts << std::endl
<< "analogSamples:" << arg.analogSamples << std::endl
<< "digitalSamples:" << arg.digitalSamples << std::endl
<< "expTimeNs:" << arg.expTimeNs << std::endl
<< "periodNs:" << arg.periodNs << std::endl
<< "subExpTimeNs:" << arg.subExpTimeNs << std::endl
<< "subDeadTimeNs:" << arg.subDeadTimeNs << std::endl
<< "activate:" << arg.activate << std::endl
<< "quad:" << arg.quad << std::endl
<< "dynamicRange:" << arg.dynamicRange << std::endl
<< "timMode:" << arg.timMode << std::endl
<< "tenGiga:" << arg.tenGiga << std::endl
<< "roMode:" << arg.roMode << std::endl
<< "adcMask:" << arg.adcMask << std::endl
<< "adc10gMask:" << arg.adc10gMask << std::endl
<< "roi.xmin:" << arg.roi.xmin << std::endl
<< "roi.xmax:" << arg.roi.xmax << std::endl
<< "countermask:" << arg.countermask << std::endl
<< "burstType:" << arg.burstType << std::endl;
LOG(logDEBUG) << "detType:" << arg.detType << std::endl
<< "multiSize.x:" << arg.multiSize.x << std::endl
<< "multiSize.y:" << arg.multiSize.y << std::endl
<< "detId:" << arg.detId << std::endl
<< "hostname:" << arg.hostname << std::endl
<< "udpInterfaces:" << arg.udpInterfaces << std::endl
<< "udp_dstport:" << arg.udp_dstport << std::endl
<< "udp_dstip:" << sls::IpAddr(arg.udp_dstip) << std::endl
<< "udp_dstmac:" << sls::MacAddr(arg.udp_dstmac) << std::endl
<< "udp_dstport2:" << arg.udp_dstport2 << std::endl
<< "udp_dstip2:" << sls::IpAddr(arg.udp_dstip2) << std::endl
<< "udp_dstmac2:" << sls::MacAddr(arg.udp_dstmac2)
<< std::endl
<< "frames:" << arg.frames << std::endl
<< "triggers:" << arg.triggers << std::endl
<< "bursts:" << arg.bursts << std::endl
<< "analogSamples:" << arg.analogSamples << std::endl
<< "digitalSamples:" << arg.digitalSamples << std::endl
<< "expTimeNs:" << arg.expTimeNs << std::endl
<< "periodNs:" << arg.periodNs << std::endl
<< "subExpTimeNs:" << arg.subExpTimeNs << std::endl
<< "subDeadTimeNs:" << arg.subDeadTimeNs << std::endl
<< "activate:" << arg.activate << std::endl
<< "quad:" << arg.quad << std::endl
<< "dynamicRange:" << arg.dynamicRange << std::endl
<< "timMode:" << arg.timMode << std::endl
<< "tenGiga:" << arg.tenGiga << std::endl
<< "roMode:" << arg.roMode << std::endl
<< "adcMask:" << arg.adcMask << std::endl
<< "adc10gMask:" << arg.adc10gMask << std::endl
<< "roi.xmin:" << arg.roi.xmin << std::endl
<< "roi.xmax:" << arg.roi.xmax << std::endl
<< "countermask:" << arg.countermask << std::endl
<< "burstType:" << arg.burstType << std::endl
<< "exptime1:" << arg.expTime1Ns << std::endl
<< "exptime2:" << arg.expTime2Ns << std::endl
<< "exptime3:" << arg.expTime3Ns << std::endl
<< "gateDelay1:" << arg.gateDelay1Ns << std::endl
<< "gateDelay2:" << arg.gateDelay2Ns << std::endl
<< "gateDelay3:" << arg.gateDelay3Ns << std::endl
<< "gates:" << arg.gates << std::endl;
// if object exists, verify unlocked and idle, else only verify lock
// (connecting first time)
@ -385,16 +395,25 @@ int ClientInterface::setup_receiver(Interface &socket) {
impl()->setDetectorHostname(arg.hostname);
// udp setup
// update retvals only if detmac is not the same as in detector
sls::MacAddr retvals[2];
if (arg.udp_dstmac == 0 && arg.udp_dstip != 0) {
retvals[0] = setUdpIp(sls::IpAddr(arg.udp_dstip));
if (arg.udp_dstip != 0) {
sls::MacAddr r = setUdpIp(sls::IpAddr(arg.udp_dstip));
sls::MacAddr detMac{arg.udp_dstmac};
if (detMac != r) {
retvals[0] = r;
}
}
if (arg.udp_dstmac2 == 0 && arg.udp_dstip2 != 0) {
retvals[1] = setUdpIp2(sls::IpAddr(arg.udp_dstip2));
if (arg.udp_dstip2 != 0) {
sls::MacAddr r = setUdpIp2(sls::IpAddr(arg.udp_dstip2));
sls::MacAddr detMac{arg.udp_dstmac2};
if (detMac != r) {
retvals[1] = r;
}
}
impl()->setUDPPortNumber(arg.udp_dstport);
impl()->setUDPPortNumber2(arg.udp_dstport2);
if (myDetectorType == JUNGFRAU) {
if (myDetectorType == JUNGFRAU || myDetectorType == GOTTHARD2) {
try {
impl()->setNumberofUDPInterfaces(arg.udpInterfaces);
} catch (const RuntimeError &e) {
@ -407,7 +426,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
// acquisition parameters
impl()->setNumberOfFrames(arg.frames);
impl()->setNumberOfTriggers(arg.triggers);
if (myDetectorType == GOTTHARD) {
if (myDetectorType == GOTTHARD2) {
impl()->setNumberOfBursts(arg.bursts);
}
if (myDetectorType == MOENCH || myDetectorType == CHIPTESTBOARD) {
@ -428,7 +447,9 @@ int ClientInterface::setup_receiver(Interface &socket) {
" due to fifo structure memory allocation.");
}
}
impl()->setAcquisitionTime(arg.expTimeNs);
if (myDetectorType != MYTHEN3) {
impl()->setAcquisitionTime(arg.expTimeNs);
}
impl()->setAcquisitionPeriod(arg.periodNs);
if (myDetectorType == EIGER) {
impl()->setSubExpTime(arg.subExpTimeNs);
@ -492,8 +513,15 @@ int ClientInterface::setup_receiver(Interface &socket) {
if (myDetectorType == MYTHEN3) {
int ncounters = __builtin_popcount(arg.countermask);
impl()->setNumberofCounters(ncounters);
impl()->setAcquisitionTime1(arg.expTime1Ns);
impl()->setAcquisitionTime2(arg.expTime2Ns);
impl()->setAcquisitionTime3(arg.expTime3Ns);
impl()->setGateDelay1(arg.gateDelay1Ns);
impl()->setGateDelay2(arg.gateDelay2Ns);
impl()->setGateDelay3(arg.gateDelay3Ns);
impl()->setNumberOfGates(arg.gates);
}
if (myDetectorType == GOTTHARD) {
if (myDetectorType == GOTTHARD2) {
impl()->setBurstMode(arg.burstType);
}
@ -669,9 +697,44 @@ int ClientInterface::set_num_digital_samples(Interface &socket) {
}
int ClientInterface::set_exptime(Interface &socket) {
auto value = socket.Receive<int64_t>();
LOG(logDEBUG1) << "Setting exptime to " << value << "ns";
impl()->setAcquisitionTime(value);
int64_t args[2]{-1, -1};
socket.Receive(args);
int gateIndex = static_cast<int>(args[0]);
int64_t value = args[1];
LOG(logDEBUG1) << "Setting exptime to " << value
<< "ns (gateIndex: " << gateIndex << ")";
switch (gateIndex) {
case -1:
if (myDetectorType == MYTHEN3) {
impl()->setAcquisitionTime1(value);
impl()->setAcquisitionTime2(value);
impl()->setAcquisitionTime3(value);
} else {
impl()->setAcquisitionTime(value);
}
break;
case 0:
if (myDetectorType != MYTHEN3) {
functionNotImplemented();
}
impl()->setAcquisitionTime1(value);
break;
case 1:
if (myDetectorType != MYTHEN3) {
functionNotImplemented();
}
impl()->setAcquisitionTime2(value);
break;
case 2:
if (myDetectorType != MYTHEN3) {
functionNotImplemented();
}
impl()->setAcquisitionTime3(value);
break;
default:
throw RuntimeError("Unknown gate index for exptime " +
std::to_string(gateIndex));
}
return socket.Send(OK);
}
@ -1390,7 +1453,7 @@ int ClientInterface::set_adc_mask(Interface &socket) {
}
int ClientInterface::set_dbit_list(Interface &socket) {
sls::FixedCapacityContainer<int, MAX_RX_DBIT> args;
sls::StaticVector<int, MAX_RX_DBIT> args;
socket.Receive(args);
if (myDetectorType != CHIPTESTBOARD)
functionNotImplemented();
@ -1407,7 +1470,7 @@ int ClientInterface::set_dbit_list(Interface &socket) {
int ClientInterface::get_dbit_list(Interface &socket) {
if (myDetectorType != CHIPTESTBOARD)
functionNotImplemented();
sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval;
sls::StaticVector<int, MAX_RX_DBIT> retval;
retval = impl()->getDbitList();
LOG(logDEBUG1) << "Dbit list size retval:" << retval.size();
return socket.sendResult(retval);
@ -1471,6 +1534,7 @@ int ClientInterface::set_read_n_lines(Interface &socket) {
}
sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) {
LOG(logINFO) << "Received UDP IP: " << arg;
// getting eth
std::string eth = sls::IpToInterfaceName(arg.str());
if (eth == "none") {
@ -1492,19 +1556,19 @@ sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) {
throw RuntimeError("Failed to get udp mac adddress to listen to (eth:" +
eth + ", ip:" + arg.str() + ")\n");
}
LOG(logINFO) << "Receiver MAC Address: " << retval;
return retval;
}
int ClientInterface::set_udp_ip(Interface &socket) {
auto arg = socket.Receive<sls::IpAddr>();
verifyIdle(socket);
LOG(logINFO) << "Received UDP IP: " << arg;
auto retval = setUdpIp(arg);
LOG(logINFO) << "Receiver MAC Address: " << retval;
return socket.sendResult(retval);
}
sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) {
LOG(logINFO) << "Received UDP IP2: " << arg;
// getting eth
std::string eth = sls::IpToInterfaceName(arg.str());
if (eth == "none") {
@ -1525,19 +1589,18 @@ sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) {
"Failed to get udp mac adddress2 to listen to (eth:" + eth +
", ip:" + arg.str() + ")\n");
}
LOG(logINFO) << "Receiver MAC Address2: " << retval;
return retval;
}
int ClientInterface::set_udp_ip2(Interface &socket) {
auto arg = socket.Receive<sls::IpAddr>();
verifyIdle(socket);
if (myDetectorType != JUNGFRAU) {
if (myDetectorType != JUNGFRAU && myDetectorType != GOTTHARD2) {
throw RuntimeError(
"UDP Destination IP2 not implemented for this detector");
}
LOG(logINFO) << "Received UDP IP2: " << arg;
auto retval = setUdpIp2(arg);
LOG(logINFO) << "Receiver MAC Address2: " << retval;
return socket.sendResult(retval);
}
@ -1552,7 +1615,8 @@ int ClientInterface::set_udp_port(Interface &socket) {
int ClientInterface::set_udp_port2(Interface &socket) {
auto arg = socket.Receive<int>();
verifyIdle(socket);
if (myDetectorType != JUNGFRAU && myDetectorType != EIGER) {
if (myDetectorType != JUNGFRAU && myDetectorType != EIGER &&
myDetectorType != GOTTHARD2) {
throw RuntimeError(
"UDP Destination Port2 not implemented for this detector");
}
@ -1565,7 +1629,7 @@ int ClientInterface::set_num_interfaces(Interface &socket) {
auto arg = socket.Receive<int>();
arg = (arg > 1 ? 2 : 1);
verifyIdle(socket);
if (myDetectorType != JUNGFRAU) {
if (myDetectorType != JUNGFRAU && myDetectorType != GOTTHARD2) {
throw RuntimeError(
"Number of interfaces not implemented for this detector");
}
@ -1640,4 +1704,46 @@ int ClientInterface::get_progress(Interface &socket) {
int retval = impl()->getProgress();
LOG(logDEBUG1) << "progress retval: " << retval;
return socket.sendResult(retval);
}
int ClientInterface::set_num_gates(Interface &socket) {
auto value = socket.Receive<int>();
LOG(logDEBUG1) << "Setting num gates to " << value;
if (myDetectorType != MYTHEN3) {
functionNotImplemented();
}
impl()->setNumberOfGates(value);
return socket.Send(OK);
}
int ClientInterface::set_gate_delay(Interface &socket) {
int64_t args[2]{-1, -1};
socket.Receive(args);
int gateIndex = static_cast<int>(args[0]);
int64_t value = args[1];
LOG(logDEBUG1) << "Setting gate delay to " << value
<< "ns (gateIndex: " << gateIndex << ")";
if (myDetectorType != MYTHEN3) {
functionNotImplemented();
}
switch (gateIndex) {
case -1:
impl()->setGateDelay1(value);
impl()->setGateDelay2(value);
impl()->setGateDelay3(value);
break;
case 0:
impl()->setGateDelay1(value);
break;
case 1:
impl()->setGateDelay2(value);
break;
case 2:
impl()->setGateDelay3(value);
break;
default:
throw RuntimeError("Unknown gate index for gate delay " +
std::to_string(gateIndex));
}
return socket.Send(OK);
}

View File

@ -3,6 +3,7 @@
#include "ServerSocket.h"
#include "receiver_defs.h"
#include "sls_detector_defs.h"
#include "sls_detector_funcs.h"
class ServerInterface;
#include <atomic>
@ -152,6 +153,8 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_additional_json_parameter(sls::ServerInterface &socket);
int get_additional_json_parameter(sls::ServerInterface &socket);
int get_progress(sls::ServerInterface &socket);
int set_num_gates(sls::ServerInterface &socket);
int set_gate_delay(sls::ServerInterface &socket);
Implementation *impl() {
if (receiver != nullptr) {

View File

@ -74,7 +74,6 @@ void DataProcessor::RecordFirstIndex(uint64_t fnum) {
void DataProcessor::SetGeneralData(GeneralData *g) {
generalData = g;
generalData->Print();
if (file != nullptr) {
if (file->GetFileType() == HDF5) {
file->SetNumberofPixels(generalData->nPixelsX,
@ -352,6 +351,9 @@ void DataProcessor::PadMissingPackets(char *buf) {
sls_bitset pmask = header->packetsMask;
uint32_t dsize = generalData->dataSize;
if (myDetectorType == GOTTHARD2 && index != 0) {
dsize = generalData->vetoDataSize;
}
uint32_t fifohsize = generalData->fifoBufferHeaderSize;
uint32_t corrected_dsize =
dsize - ((pperFrame * dsize) - generalData->imageSize);

View File

@ -41,10 +41,8 @@ void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) {
delete[] completeBuffer;
completeBuffer = nullptr;
}
if (roi->xmin != -1) {
if (generalData->myDetectorType == GOTTHARD) {
adcConfigured = generalData->GetAdcConfigured(index, *roi);
}
if (generalData->myDetectorType == GOTTHARD && roi->xmin != -1) {
adcConfigured = generalData->GetAdcConfigured(index, *roi);
completeBuffer = new char[generalData->imageSizeComplete];
memset(completeBuffer, 0, generalData->imageSizeComplete);
}
@ -57,10 +55,7 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum) {
LOG(logDEBUG1) << index << " First Index: " << firstIndex;
}
void DataStreamer::SetGeneralData(GeneralData *g) {
generalData = g;
generalData->Print();
}
void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; }
void DataStreamer::SetNumberofDetectors(int *nd) {
numDet[0] = nd[0];
@ -147,7 +142,6 @@ void DataStreamer::ProcessAnImage(char *buf) {
// shortframe gotthard
if (completeBuffer) {
// disregarding the size modified from callback (always using
// imageSizeComplete
// instead of buf (32 bit) because gui needs imagesizecomplete and

View File

@ -17,86 +17,42 @@
class GeneralData {
public:
/** DetectorType */
slsDetectorDefs::detectorType myDetectorType;
/** Number of Pixels in x axis */
uint32_t nPixelsX;
/** Number of Pixels in y axis */
uint32_t nPixelsY;
/** Size of header in Packet */
uint32_t headerSizeinPacket;
slsDetectorDefs::detectorType myDetectorType{slsDetectorDefs::GENERIC};
uint32_t nPixelsX{0};
uint32_t nPixelsY{0};
uint32_t headerSizeinPacket{0};
/** Size of just data in 1 packet (in bytes) */
uint32_t dataSize;
/** Size of 1 packet (in bytes) */
uint32_t packetSize;
uint32_t dataSize{0};
uint32_t packetSize{0};
/** Number of packets in an image (for each listening UDP port) */
uint32_t packetsPerFrame;
uint32_t packetsPerFrame{0};
/** Image size (in bytes, for each listening UDP port) */
uint32_t imageSize;
/** Frame Number Mask */
uint64_t frameIndexMask;
/** Frame Index Offset */
uint32_t frameIndexOffset;
/** Packet Index Mask */
uint32_t packetIndexMask;
/** Packet Index Offset */
uint32_t packetIndexOffset;
/** Max Frames per binary file */
uint32_t maxFramesPerFile;
uint32_t imageSize{0};
uint64_t frameIndexMask{0};
uint32_t frameIndexOffset{0};
uint32_t packetIndexMask{0};
uint32_t packetIndexOffset{0};
uint32_t maxFramesPerFile{0};
/** Header size of data saved into fifo buffer at a time*/
uint32_t fifoBufferHeaderSize;
/** Default Fifo depth */
uint32_t defaultFifoDepth;
/** Threads per receiver */
uint32_t threadsPerReceiver;
/** Size of a header packet */
uint32_t headerPacketSize;
/** Streaming (for ROI - mainly short Gotthard) - Number of Pixels in x axis
*/
uint32_t nPixelsXComplete;
/** Streaming (for ROI - mainly short Gotthard) - Number of Pixels in y axis
*/
uint32_t nPixelsYComplete;
uint32_t fifoBufferHeaderSize{0};
uint32_t defaultFifoDepth{0};
uint32_t threadsPerReceiver{1};
uint32_t headerPacketSize{0};
/** Streaming (for ROI - mainly short Gotthard) */
uint32_t nPixelsXComplete{0};
/** Streaming (for ROI - mainly short Gotthard) */
uint32_t nPixelsYComplete{0};
/** Streaming (for ROI - mainly short Gotthard) - Image size (in bytes) */
uint32_t imageSizeComplete;
uint32_t imageSizeComplete{0};
/** if standard header implemented in firmware */
bool standardheader;
bool standardheader{false};
uint32_t defaultUdpSocketBufferSize{RECEIVE_SOCKET_BUFFER_SIZE};
uint32_t vetoDataSize{0};
uint32_t vetoPacketSize{0};
uint32_t vetoImageSize{0};
uint32_t vetoHsize{0};
/** default udp socket buffer size */
uint32_t defaultUdpSocketBufferSize;
/** Cosntructor */
GeneralData()
: myDetectorType(slsDetectorDefs::GENERIC), nPixelsX(0), nPixelsY(0),
headerSizeinPacket(0), dataSize(0), packetSize(0), packetsPerFrame(0),
imageSize(0), frameIndexMask(0), frameIndexOffset(0),
packetIndexMask(0), packetIndexOffset(0), maxFramesPerFile(0),
fifoBufferHeaderSize(0), defaultFifoDepth(0), threadsPerReceiver(1),
headerPacketSize(0), nPixelsXComplete(0), nPixelsYComplete(0),
imageSizeComplete(0), standardheader(false),
defaultUdpSocketBufferSize(RECEIVE_SOCKET_BUFFER_SIZE){};
/** Destructor */
GeneralData(){};
virtual ~GeneralData(){};
/**
@ -106,14 +62,17 @@ class GeneralData {
* @param oddStartingPacket odd starting packet (gotthard)
* @param frameNumber frame number
* @param packetNumber packet number
* @param bunchId bunch Id
*/
virtual void GetHeaderInfo(int index, char *packetData,
bool oddStartingPacket, uint64_t &frameNumber,
uint32_t &packetNumber) const {
uint32_t &packetNumber,
uint64_t &bunchId) const {
frameNumber = ((uint32_t)(*((uint32_t *)(packetData))));
frameNumber++;
packetNumber = frameNumber & packetIndexMask;
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
bunchId = -1;
}
/**
@ -203,35 +162,6 @@ class GeneralData {
LOG(logERROR) << "SetNumberofCounters is a generic function that "
"should be overloaded by a derived class";
}
/**
* Print all variables
*/
virtual void Print(TLogLevel level = logDEBUG1) const {
LOG(level) << "\n\nDetector Data Variables:";
LOG(level) << "myDetectorType: " << sls::ToString(myDetectorType);
LOG(level) << "Pixels X: " << nPixelsX;
LOG(level) << "Pixels Y: " << nPixelsY;
LOG(level) << "Header Size in Packet: " << headerSizeinPacket;
LOG(level) << "Data Size: " << dataSize;
LOG(level) << "Packet Size: " << packetSize;
LOG(level) << "Packets per Frame: " << packetsPerFrame;
LOG(level) << "Image Size: " << imageSize;
LOG(level) << "Frame Index Mask: " << frameIndexMask;
LOG(level) << "Frame Index Offset: " << frameIndexOffset;
LOG(level) << "Packet Index Mask: " << packetIndexMask;
LOG(level) << "Packet Index Offset: " << packetIndexOffset;
LOG(level) << "Max Frames Per File: " << maxFramesPerFile;
LOG(level) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize;
LOG(level) << "Default Fifo Depth: " << defaultFifoDepth;
LOG(level) << "Threads Per Receiver: " << threadsPerReceiver;
LOG(level) << "Header Packet Size: " << headerPacketSize;
LOG(level) << "Complete Pixels X: " << nPixelsXComplete;
LOG(level) << "Complete Pixels Y: " << nPixelsYComplete;
LOG(level) << "Complete Image Size: " << imageSizeComplete;
LOG(level) << "Standard Header: " << standardheader;
LOG(level) << "UDP Socket Buffer Size: " << defaultUdpSocketBufferSize;
};
};
class GotthardData : public GeneralData {
@ -268,9 +198,11 @@ class GotthardData : public GeneralData {
* @param oddStartingPacket odd starting packet (gotthard)
* @param frameNumber frame number
* @param packetNumber packet number
* @param bunchId bunch Id
*/
void GetHeaderInfo(int index, char *packetData, bool oddStartingPacket,
uint64_t &frameNumber, uint32_t &packetNumber) const {
uint64_t &frameNumber, uint32_t &packetNumber,
uint64_t &bunchId) const {
if (nPixelsX == 1280) {
frameNumber = *reinterpret_cast<uint32_t *>(packetData);
if (oddStartingPacket)
@ -281,6 +213,7 @@ class GotthardData : public GeneralData {
frameNumber = *reinterpret_cast<uint32_t *>(packetData);
packetNumber = 0;
}
bunchId = -1;
}
/**
@ -475,7 +408,7 @@ class JungfrauData : public GeneralData {
threadsPerReceiver = 1;
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
}
}
};
};
class Mythen3Data : public GeneralData {
@ -561,7 +494,43 @@ class Gotthard2Data : public GeneralData {
defaultFifoDepth = 50000;
standardheader = true;
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
vetoDataSize = 160;
vetoImageSize = vetoDataSize * packetsPerFrame;
vetoHsize = 16;
vetoPacketSize = vetoHsize + vetoDataSize;
};
/**
* set number of interfaces
* @param number of interfaces
*/
void SetNumberofInterfaces(const int n) {
// 2 interfaces (+veto)
if (n == 2) {
threadsPerReceiver = 2;
}
// 1 interface (data only)
else {
threadsPerReceiver = 1;
}
};
/**
* Get Header Infomation (frame number, packet number) for veto packets
* @param index thread index for debugging purposes
* @param packetData pointer to data
* @param oddStartingPacket odd starting packet (gotthard)
* @param frameNumber frame number
* @param packetNumber packet number
* @param bunchId bunch Id
*/
void GetHeaderInfo(int index, char *packetData, bool oddStartingPacket,
uint64_t &frameNumber, uint32_t &packetNumber,
uint64_t &bunchId) const {
frameNumber = *reinterpret_cast<uint64_t *>(packetData);
bunchId = *reinterpret_cast<uint64_t *>(packetData + 8);
packetNumber = 0;
}
};
class ChipTestBoardData : public GeneralData {

View File

@ -725,6 +725,98 @@ void HDF5File::CreateMasterDataFile(masterAttributes &masterFileAttributes) {
PredType::NATIVE_INT);
}
// Exptime1
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group5.createDataSet(
"exposure time1", PredType::STD_U64LE, dataspace);
dataset.write(&(masterFileAttributes.exptime1Ns),
PredType::STD_U64LE);
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
Attribute attribute =
dataset.createAttribute("unit", strdatatype, dataspaceAttr);
attribute.write(strdatatype, std::string("ns"));
}
// Exptime2
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group5.createDataSet(
"exposure time2", PredType::STD_U64LE, dataspace);
dataset.write(&(masterFileAttributes.exptime2Ns),
PredType::STD_U64LE);
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
Attribute attribute =
dataset.createAttribute("unit", strdatatype, dataspaceAttr);
attribute.write(strdatatype, std::string("ns"));
}
// Exptime3
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group5.createDataSet(
"exposure time3", PredType::STD_U64LE, dataspace);
dataset.write(&(masterFileAttributes.exptime3Ns),
PredType::STD_U64LE);
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
Attribute attribute =
dataset.createAttribute("unit", strdatatype, dataspaceAttr);
attribute.write(strdatatype, std::string("ns"));
}
// GateDelay1
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group5.createDataSet(
"gate delay1", PredType::STD_U64LE, dataspace);
dataset.write(&(masterFileAttributes.gateDelay1Ns),
PredType::STD_U64LE);
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
Attribute attribute =
dataset.createAttribute("unit", strdatatype, dataspaceAttr);
attribute.write(strdatatype, std::string("ns"));
}
// GateDelay2
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group5.createDataSet(
"gate delay2", PredType::STD_U64LE, dataspace);
dataset.write(&(masterFileAttributes.gateDelay2Ns),
PredType::STD_U64LE);
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
Attribute attribute =
dataset.createAttribute("unit", strdatatype, dataspaceAttr);
attribute.write(strdatatype, std::string("ns"));
}
// GateDelay3
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group5.createDataSet(
"gate delay3", PredType::STD_U64LE, dataspace);
dataset.write(&(masterFileAttributes.gateDelay3Ns),
PredType::STD_U64LE);
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
Attribute attribute =
dataset.createAttribute("unit", strdatatype, dataspaceAttr);
attribute.write(strdatatype, std::string("ns"));
}
// Dbit Offset
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group5.createDataSet("gates", PredType::NATIVE_INT, dataspace);
dataset.write(&(masterFileAttributes.gates), PredType::NATIVE_INT);
}
// Timestamp
{
time_t t = time(0);

View File

@ -100,10 +100,17 @@ void Implementation::InitializeMembers() {
numberOfTriggers = 1;
numberOfBursts = 1;
numberOfAdditionalStorageCells = 0;
numberOfGates = 0;
timingMode = AUTO_TIMING;
burstMode = BURST_OFF;
burstMode = BURST_INTERNAL;
acquisitionPeriod = SAMPLE_TIME_IN_NS;
acquisitionTime = 0;
acquisitionTime1 = 0;
acquisitionTime2 = 0;
acquisitionTime3 = 0;
gateDelay1 = 0;
gateDelay2 = 0;
gateDelay3 = 0;
subExpTime = 0;
subPeriod = 0;
numberOfAnalogSamples = 0;
@ -178,13 +185,16 @@ void Implementation::SetupFifoStructure() {
fifo.clear();
for (int i = 0; i < numThreads; ++i) {
uint32_t datasize = generalData->imageSize;
// veto data size
if (myDetectorType == GOTTHARD2 && i != 0) {
datasize = generalData->vetoImageSize;
}
// create fifo structure
try {
fifo.push_back(sls::make_unique<Fifo>(
i,
(generalData->imageSize) + (generalData->fifoBufferHeaderSize),
fifoDepth));
i, datasize + (generalData->fifoBufferHeaderSize), fifoDepth));
} catch (...) {
fifo.clear();
fifoDepth = 0;
@ -199,14 +209,15 @@ void Implementation::SetupFifoStructure() {
dataProcessor[i]->SetFifo(fifo[i].get());
if (dataStreamer.size())
dataStreamer[i]->SetFifo(fifo[i].get());
LOG(logINFO) << "Memory Allocated for Fifo " << i << ": "
<< (double)(((size_t)(datasize) +
(size_t)(generalData->fifoBufferHeaderSize)) *
(size_t)fifoDepth) /
(double)(1024 * 1024)
<< " MB";
}
LOG(logINFO) << "Memory Allocated Per Fifo: "
<< (double)(((size_t)(generalData->imageSize) +
(size_t)(generalData->fifoBufferHeaderSize)) *
(size_t)fifoDepth) /
(double)(1024 * 1024)
<< " MB";
LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed";
}
@ -885,6 +896,13 @@ void Implementation::SetupWriter() {
for (auto &i : ctbDbitList) {
attr.dbitlist |= (1 << i);
}
attr.exptime1Ns = acquisitionTime1;
attr.exptime2Ns = acquisitionTime2;
attr.exptime3Ns = acquisitionTime3;
attr.gateDelay1Ns = gateDelay1;
attr.gateDelay2Ns = gateDelay2;
attr.gateDelay3Ns = gateDelay3;
attr.gates = numberOfGates;
try {
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
@ -1276,7 +1294,7 @@ void Implementation::updateTotalNumberOfFrames() {
// burst mode: (bursts instead of triggers)
// non burst mode: no bursts or triggers
if (myDetectorType == GOTTHARD2 && timingMode == AUTO_TIMING) {
if (burstMode == BURST_OFF) {
if (burstMode != BURST_OFF) {
repeats = numberOfBursts;
} else {
repeats = 1;
@ -1339,6 +1357,12 @@ void Implementation::setNumberOfAdditionalStorageCells(const int i) {
updateTotalNumberOfFrames();
}
void Implementation::setNumberOfGates(const int i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
numberOfGates = i;
LOG(logINFO) << "Number of Gates: " << numberOfGates;
}
slsDetectorDefs::timingMode Implementation::getTimingMode() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return timingMode;
@ -1381,6 +1405,15 @@ uint64_t Implementation::getAcquisitionTime() const {
return acquisitionTime;
}
void Implementation::updateAcquisitionTime() {
if (acquisitionTime1 == acquisitionTime2 &&
acquisitionTime2 == acquisitionTime3) {
acquisitionTime = acquisitionTime1;
} else {
acquisitionTime = -1;
}
}
void Implementation::setAcquisitionTime(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
@ -1389,6 +1422,54 @@ void Implementation::setAcquisitionTime(const uint64_t i) {
<< "s";
}
void Implementation::setAcquisitionTime1(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
acquisitionTime1 = i;
LOG(logINFO) << "Acquisition Time1: " << (double)acquisitionTime1 / (1E9)
<< "s";
updateAcquisitionTime();
}
void Implementation::setAcquisitionTime2(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
acquisitionTime2 = i;
LOG(logINFO) << "Acquisition Time2: " << (double)acquisitionTime2 / (1E9)
<< "s";
updateAcquisitionTime();
}
void Implementation::setAcquisitionTime3(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
acquisitionTime3 = i;
LOG(logINFO) << "Acquisition Time3: " << (double)acquisitionTime3 / (1E9)
<< "s";
updateAcquisitionTime();
}
void Implementation::setGateDelay1(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
gateDelay1 = i;
LOG(logINFO) << "Gate Delay1: " << (double)gateDelay1 / (1E9) << "s";
}
void Implementation::setGateDelay2(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
gateDelay2 = i;
LOG(logINFO) << "Gate Delay2: " << (double)gateDelay2 / (1E9) << "s";
}
void Implementation::setGateDelay3(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
gateDelay3 = i;
LOG(logINFO) << "Gate Delay3: " << (double)gateDelay3 / (1E9) << "s";
}
uint64_t Implementation::getSubExpTime() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return subExpTime;

View File

@ -140,15 +140,34 @@ class Implementation : private virtual slsDetectorDefs {
uint64_t getNumberOfTriggers() const;
void setNumberOfTriggers(const uint64_t i);
uint64_t getNumberOfBursts() const;
/** [Gottthard2] */
void setNumberOfBursts(const uint64_t i);
int getNumberOfAdditionalStorageCells() const;
/** [Jungfrau] */
void setNumberOfAdditionalStorageCells(const int i);
/** [Mythen3] */
void setNumberOfGates(const int i);
timingMode getTimingMode() const;
void setTimingMode(const timingMode i);
burstMode getBurstMode() const;
/** [Gottthard2] */
void setBurstMode(const burstMode i);
uint64_t getAcquisitionTime() const;
void setAcquisitionTime(const uint64_t i);
/** [Mythen3] */
void updateAcquisitionTime();
/** [Mythen3] */
void setAcquisitionTime1(const uint64_t i);
/** [Mythen3] */
void setAcquisitionTime2(const uint64_t i);
/** [Mythen3] */
void setAcquisitionTime3(const uint64_t i);
/** [Mythen3] */
void setGateDelay1(const uint64_t i);
/** [Mythen3] */
void setGateDelay2(const uint64_t i);
/** [Mythen3] */
void setGateDelay3(const uint64_t i);
uint64_t getAcquisitionPeriod() const;
void setAcquisitionPeriod(const uint64_t i);
uint64_t getSubExpTime() const;
@ -286,10 +305,17 @@ class Implementation : private virtual slsDetectorDefs {
uint64_t numberOfTriggers;
uint64_t numberOfBursts;
int numberOfAdditionalStorageCells;
int numberOfGates;
timingMode timingMode;
burstMode burstMode;
uint64_t acquisitionPeriod;
uint64_t acquisitionTime;
uint64_t acquisitionTime1;
uint64_t acquisitionTime2;
uint64_t acquisitionTime3;
uint64_t gateDelay1;
uint64_t gateDelay2;
uint64_t gateDelay3;
uint64_t subExpTime;
uint64_t subPeriod;
uint64_t numberOfAnalogSamples;

View File

@ -63,10 +63,14 @@ void Listener::ResetParametersforNewAcquisition() {
currentFrameIndex = 0;
lastCaughtFrameIndex = 0;
carryOverFlag = false;
carryOverPacket = sls::make_unique<char[]>(generalData->packetSize);
memset(carryOverPacket.get(), 0, generalData->packetSize);
listeningPacket = sls::make_unique<char[]>(generalData->packetSize);
memset(carryOverPacket.get(), 0, generalData->packetSize);
uint32_t packetSize = generalData->packetSize;
if (myDetectorType == GOTTHARD2 && index != 0) {
packetSize = generalData->vetoPacketSize;
}
carryOverPacket = sls::make_unique<char[]>(packetSize);
memset(carryOverPacket.get(), 0, packetSize);
listeningPacket = sls::make_unique<char[]>(packetSize);
memset(carryOverPacket.get(), 0, packetSize);
numPacketsStatistic = 0;
numFramesStatistic = 0;
@ -89,10 +93,7 @@ void Listener::RecordFirstIndex(uint64_t fnum) {
}
}
void Listener::SetGeneralData(GeneralData *g) {
generalData = g;
generalData->Print();
}
void Listener::SetGeneralData(GeneralData *g) { generalData = g; }
void Listener::CreateUDPSockets() {
if (!(*activated)) {
@ -108,10 +109,16 @@ void Listener::CreateUDPSockets() {
}
ShutDownUDPSocket();
uint32_t packetSize = generalData->packetSize;
if (myDetectorType == GOTTHARD2 && index != 0) {
packetSize = generalData->vetoPacketSize;
}
// InterfaceNameToIp(eth).str().c_str()
try {
udpSocket = sls::make_unique<sls::UdpRxSocket>(
*udpPortNumber, generalData->packetSize,
*udpPortNumber, packetSize,
((*eth).length() ? sls::InterfaceNameToIp(*eth).str().c_str()
: nullptr),
*udpSocketBufferSize);
@ -152,9 +159,14 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) {
(*eth) = "";
}
uint32_t packetSize = generalData->packetSize;
if (myDetectorType == GOTTHARD2 && index != 0) {
packetSize = generalData->vetoPacketSize;
}
// create dummy socket
try {
sls::UdpRxSocket g(*udpPortNumber, generalData->packetSize,
sls::UdpRxSocket g(*udpPortNumber, packetSize,
((*eth).length()
? sls::InterfaceNameToIp(*eth).str().c_str()
: nullptr),
@ -258,21 +270,29 @@ uint32_t Listener::ListenToAnImage(char *buf) {
int rc = 0;
uint64_t fnum = 0;
uint32_t pnum = 0;
uint64_t bnum = 0;
uint32_t numpackets = 0;
uint32_t dsize = generalData->dataSize;
uint32_t hsize = generalData->headerSizeinPacket; //(includes empty header)
uint32_t imageSize = generalData->imageSize;
uint32_t packetSize = generalData->packetSize;
uint32_t hsize = generalData->headerSizeinPacket;
uint32_t fifohsize = generalData->fifoBufferHeaderSize;
bool standardheader = generalData->standardheader;
if (myDetectorType == GOTTHARD2 && index != 0) {
dsize = generalData->vetoDataSize;
imageSize = generalData->vetoImageSize;
packetSize = generalData->vetoPacketSize;
hsize = generalData->vetoHsize;
standardheader = false;
}
uint32_t pperFrame = generalData->packetsPerFrame;
bool isHeaderEmpty = true;
sls_detector_header *old_header = nullptr;
sls_receiver_header *new_header = nullptr;
bool standardheader = generalData->standardheader;
uint32_t corrected_dsize =
dsize - ((pperFrame * dsize) - generalData->imageSize);
uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - imageSize);
// reset to -1
memset(buf, 0, fifohsize);
/*memset(buf + fifohsize, 0xFF, generalData->imageSize);*/
new_header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
// deactivated (eiger)
@ -294,7 +314,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
new_header->detHeader.column = column;
new_header->detHeader.detType = (uint8_t)generalData->myDetectorType;
new_header->detHeader.version = (uint8_t)SLS_DETECTOR_HEADER_VERSION;
return generalData->imageSize;
return imageSize;
}
// look for carry over
@ -312,7 +332,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
// -----------------------------------------------------------------------------
else {
generalData->GetHeaderInfo(index, &carryOverPacket[0],
oddStartingPacket, fnum, pnum);
oddStartingPacket, fnum, pnum, bnum);
}
//------------------------------------------------------------------------------------------------------------
if (fnum != currentFrameIndex) {
@ -338,7 +358,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
new_header->detHeader.row = row;
new_header->detHeader.column = column;
}
return generalData->imageSize;
return imageSize;
}
// copy packet
@ -386,6 +406,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
// ------------------------------------------------------------------------------
else {
new_header->detHeader.frameNumber = fnum;
new_header->detHeader.bunchId = bnum;
new_header->detHeader.row = row;
new_header->detHeader.column = column;
new_header->detHeader.detType =
@ -427,8 +448,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
new_header->detHeader.row = row;
new_header->detHeader.column = column;
}
return generalData
->imageSize; // empty packet now, but not empty image
return imageSize; // empty packet now, but not empty image
}
// update parameters
@ -454,7 +474,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
}
generalData->GetHeaderInfo(index, &listeningPacket[0],
oddStartingPacket, fnum, pnum);
oddStartingPacket, fnum, pnum, bnum);
}
//------------------------------------------------------------------------------------------------------------
@ -489,8 +509,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
// detectors)
if (fnum != currentFrameIndex) {
carryOverFlag = true;
memcpy(carryOverPacket.get(), &listeningPacket[0],
generalData->packetSize);
memcpy(carryOverPacket.get(), &listeningPacket[0], packetSize);
switch (*frameDiscardMode) {
case DISCARD_EMPTY_FRAMES:
@ -508,7 +527,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
new_header->detHeader.row = row;
new_header->detHeader.column = column;
}
return generalData->imageSize;
return imageSize;
}
// copy packet
@ -554,6 +573,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
// ------------------------------------------------------------------------------
else {
new_header->detHeader.frameNumber = fnum;
new_header->detHeader.bunchId = bnum;
new_header->detHeader.row = row;
new_header->detHeader.column = column;
new_header->detHeader.detType =
@ -568,7 +588,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
// complete image
new_header->detHeader.packetNumber = numpackets; // number of packets caught
return generalData->imageSize;
return imageSize;
}
void Listener::PrintFifoStatistics() {

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