mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 14:38:14 +02:00
merge vetoheader
This commit is contained in:
commit
c6ff50d753
82
python/api-tests/test_detector.py
Normal file
82
python/api-tests/test_detector.py
Normal 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
|
89
python/api-tests/test_jungfrau.py
Normal file
89
python/api-tests/test_jungfrau.py
Normal 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
|
@ -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:
|
||||
|
@ -3,12 +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, reduce_time, is_iterable
|
||||
from . import utils as ut
|
||||
from .registers import Register, Adc_register
|
||||
import datetime as dt
|
||||
|
||||
@ -16,6 +18,7 @@ from functools import wraps
|
||||
from collections import namedtuple
|
||||
import socket
|
||||
|
||||
|
||||
def freeze(cls):
|
||||
cls._frozen = False
|
||||
|
||||
@ -60,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()
|
||||
@ -91,7 +91,6 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@property
|
||||
def hostname(self):
|
||||
print('getting host!')
|
||||
return self.getHostname()
|
||||
|
||||
@hostname.setter
|
||||
@ -109,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
|
||||
@ -130,7 +129,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@dr.setter
|
||||
def dr(self, dr):
|
||||
self.setDynamicRange(dr)
|
||||
self.setDynamicRange(dr)
|
||||
|
||||
@property
|
||||
def module_geometry(self):
|
||||
@ -173,83 +172,42 @@ class Detector(CppDetectorApi):
|
||||
def exptime(self):
|
||||
if self.type == detectorType.MYTHEN3:
|
||||
res = self.getExptimeForAllGates()
|
||||
return reduce_time(res)
|
||||
res = self.getExptime()
|
||||
return element_if_equal([it.total_seconds() for it in res])
|
||||
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 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):
|
||||
if isinstance(v, dt.timedelta):
|
||||
self.setGateDelay(i, v)
|
||||
else:
|
||||
self.setGateDelay(i, dt.timedelta(seconds = v))
|
||||
else:
|
||||
if isinstance(value, dt.timedelta):
|
||||
self.setGateDelay(-1, value)
|
||||
else:
|
||||
self.setGateDelay(-1, dt.timedelta(seconds=value))
|
||||
|
||||
|
||||
@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):
|
||||
@ -258,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):
|
||||
@ -327,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)
|
||||
@ -445,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))
|
||||
|
||||
@ -462,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))
|
||||
|
||||
@ -482,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())
|
||||
@ -539,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())
|
||||
@ -576,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())
|
||||
@ -592,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):
|
||||
@ -626,7 +583,6 @@ class Detector(CppDetectorApi):
|
||||
def adcreg(self):
|
||||
return self._adc_register
|
||||
|
||||
|
||||
@property
|
||||
def led(self):
|
||||
return element_if_equal(self.getLEDEnable())
|
||||
@ -667,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):
|
||||
@ -685,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())
|
||||
@ -699,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())
|
||||
@ -714,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)
|
||||
@ -761,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())
|
||||
@ -770,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()
|
||||
@ -784,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
|
||||
"""
|
||||
@ -836,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)
|
||||
@ -876,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)
|
||||
@ -900,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
|
||||
|
||||
@ -992,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))
|
||||
@ -1041,7 +1114,6 @@ class Detector(CppDetectorApi):
|
||||
def patnloop2(self, n):
|
||||
self.setPatternLoopCycles(2, n)
|
||||
|
||||
|
||||
@property
|
||||
@element
|
||||
def v_a(self):
|
||||
@ -1119,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)
|
||||
|
@ -88,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)
|
||||
|
@ -880,9 +880,9 @@ void init_det(py::module &m) {
|
||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getStorageCellStart,
|
||||
py::arg() = Positions{})
|
||||
.def("setStoragecellStart",
|
||||
.def("setStorageCellStart",
|
||||
(void (Detector::*)(int, sls::Positions)) &
|
||||
Detector::setStoragecellStart,
|
||||
Detector::setStorageCellStart,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getStorageCellDelay",
|
||||
(Result<sls::ns>(Detector::*)(sls::Positions) const) &
|
||||
@ -978,6 +978,14 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)(defs::timingSourceType, sls::Positions)) &
|
||||
Detector::setTimingSource,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getVeto",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getVeto,
|
||||
py::arg() = Positions{})
|
||||
.def("setVeto",
|
||||
(void (Detector::*)(const bool, sls::Positions)) &
|
||||
Detector::setVeto,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getCounterMask",
|
||||
(Result<uint32_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getCounterMask,
|
||||
|
@ -9,10 +9,10 @@ from slsdet.utils import *
|
||||
import datetime as dt
|
||||
|
||||
def test_iterable():
|
||||
assert iterable(5) == False
|
||||
assert iterable('abc') == True
|
||||
assert iterable([]) == True
|
||||
assert iterable(5.9) == False
|
||||
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)]
|
||||
@ -25,7 +25,7 @@ def test_reduce_time_to_single_value_from_list_of_lists():
|
||||
|
||||
def test_reduce_time_when_sublist_is_different():
|
||||
t = [dt.timedelta(seconds = 1), dt.timedelta(seconds = 2), dt.timedelta(seconds = 1)]
|
||||
tt = 4*t
|
||||
tt = [t for i in range(4)]
|
||||
assert reduce_time(tt) == [1,2,1]
|
||||
|
||||
|
||||
@ -80,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)
|
@ -89,6 +89,8 @@
|
||||
|
||||
#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)
|
||||
@ -248,6 +250,6 @@
|
||||
|
||||
/* UDP datagram registers --------------------------------------------------*/
|
||||
#define RXR_ENDPOINTS_MAX (32)
|
||||
#define RXR_ENDPOINT_OFST (0x10)
|
||||
#define RXR_ENDPOINT_OFST (16 * REG_OFFSET)
|
||||
|
||||
// clang-format on
|
Binary file not shown.
@ -1295,23 +1295,21 @@ void setNumberofUDPInterfaces(int val) {
|
||||
|
||||
// 2 interfaces (enable veto)
|
||||
if (val > 1) {
|
||||
LOG(logINFOBLUE,
|
||||
("Setting #Interfaces: 2 (enabling veto streaming)\n"));
|
||||
bus_w(addr, bus_r(addr) | CONFIG_VETO_ENBL_MSK);
|
||||
LOG(logINFOBLUE, ("Setting #Interfaces: 2 (10gbps veto streaming)\n"));
|
||||
bus_w(addr, bus_r(addr) | CONFIG_VETO_CH_10GB_ENBL_MSK);
|
||||
}
|
||||
// 1 interface (disable veto)
|
||||
else {
|
||||
LOG(logINFOBLUE,
|
||||
("Setting #Interfaces: 1 (disabling veto streaming)\n"));
|
||||
bus_w(addr, bus_r(addr) & ~CONFIG_VETO_ENBL_MSK);
|
||||
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 veto enabled, else 1
|
||||
return ((bus_r(CONFIG_REG) & CONFIG_VETO_ENBL_MSK) ? 2 : 1);
|
||||
// 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,
|
||||
@ -1422,7 +1420,10 @@ int configureMAC() {
|
||||
getIpAddressinString(dst_ip2, dstip2);
|
||||
|
||||
int numInterfaces = getNumberofUDPInterfaces();
|
||||
LOG(logINFO, ("\t#Interfaces : %d\n", numInterfaces));
|
||||
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"
|
||||
@ -1433,8 +1434,9 @@ int configureMAC() {
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
||||
|
||||
LOG(logINFO, ("\tVeto Interface (%s)\n",
|
||||
(numInterfaces == 2 ? "enabled" : "disabled")));
|
||||
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"
|
||||
@ -1448,7 +1450,7 @@ int configureMAC() {
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (numInterfaces == 2 &&
|
||||
if (vetoEnabled && numInterfaces == 2 &&
|
||||
setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("could not set udp destination IP and port for interface 2\n"));
|
||||
@ -1463,7 +1465,7 @@ int configureMAC() {
|
||||
setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip, srcport);
|
||||
|
||||
// veto
|
||||
if (numInterfaces == 2) {
|
||||
if (vetoEnabled && numInterfaces == 2) {
|
||||
setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, srcip2,
|
||||
srcport2);
|
||||
}
|
||||
@ -2207,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() {
|
||||
@ -2215,7 +2238,8 @@ int startStateMachine() {
|
||||
if (createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
if (getNumberofUDPInterfaces() == 2 && createUDPSocket(1) != OK) {
|
||||
if (getVeto() && getNumberofUDPInterfaces() == 2 &&
|
||||
createUDPSocket(1) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
@ -2258,6 +2282,8 @@ void *start_timer(void *arg) {
|
||||
}
|
||||
|
||||
int numInterfaces = getNumberofUDPInterfaces();
|
||||
int vetoEnabled = getVeto();
|
||||
|
||||
int numRepeats = getNumTriggers();
|
||||
if (getTiming() == AUTO_TIMING) {
|
||||
if (burstMode == BURST_OFF) {
|
||||
@ -2274,7 +2300,7 @@ void *start_timer(void *arg) {
|
||||
int datasize = imagesize;
|
||||
int packetsize = datasize + sizeof(sls_detector_header);
|
||||
int vetodatasize = VETO_DATA_SIZE;
|
||||
int vetopacketsize = vetodatasize + sizeof(sls_detector_header);
|
||||
int vetopacketsize = vetodatasize + sizeof(veto_header);
|
||||
|
||||
// Generate data
|
||||
char imageData[imagesize];
|
||||
@ -2331,21 +2357,15 @@ void *start_timer(void *arg) {
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
|
||||
// second interface (veto)
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
if (numInterfaces == 2) {
|
||||
char packetData2[vetopacketsize];
|
||||
memset(packetData2, 0, vetopacketsize);
|
||||
if (vetoEnabled && numInterfaces == 2) {
|
||||
// set header
|
||||
sls_detector_header *header =
|
||||
(sls_detector_header *)(packetData2);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
veto_header *header = (veto_header *)(packetData2);
|
||||
header->frameNumber = frameHeaderNr;
|
||||
header->packetNumber = 0;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
header->bunchId = 0;
|
||||
// fill data
|
||||
memcpy(packetData2 + sizeof(sls_detector_header), vetoData,
|
||||
memcpy(packetData2 + sizeof(veto_header), vetoData,
|
||||
vetodatasize);
|
||||
// send 1 packet = 1 frame
|
||||
sendUDPPacket(1, packetData2, vetopacketsize);
|
||||
@ -2379,7 +2399,7 @@ void *start_timer(void *arg) {
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
if (numInterfaces == 2) {
|
||||
if (vetoEnabled && numInterfaces == 2) {
|
||||
closeUDPSocket(1);
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
@ -57,6 +57,11 @@
|
||||
#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)
|
||||
|
||||
|
@ -518,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)
|
||||
|
@ -224,4 +224,6 @@ 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_gate_delay_all_gates(int);
|
||||
int get_veto(int);
|
||||
int set_veto(int);
|
@ -336,6 +336,8 @@ void function_table() {
|
||||
flist[F_GET_GATE_DELAY] = &get_gate_delay;
|
||||
flist[F_GET_EXPTIME_ALL_GATES] = &get_exptime_all_gates;
|
||||
flist[F_GET_GATE_DELAY_ALL_GATES] = &get_gate_delay_all_gates;
|
||||
flist[F_GET_VETO] = &get_veto;
|
||||
flist[F_SET_VETO] = &set_veto;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -7429,3 +7431,62 @@ int get_gate_delay_all_gates(int file_des) {
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, retvals, sizeof(retvals));
|
||||
}
|
||||
|
||||
int get_veto(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
|
||||
LOG(logDEBUG1, ("Getting veto\n"));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getVeto();
|
||||
LOG(logDEBUG1, ("veto mode retval: %u\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_veto(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting veto mode: %u\n", arg));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
setVeto(arg);
|
||||
// if numinterfaces is 2 and veto is 1 now, then configuremac
|
||||
if (arg > 0 && getNumberofUDPInterfaces() == 2 &&
|
||||
is_configurable() == OK) {
|
||||
ret = configureMAC();
|
||||
if (ret != OK) {
|
||||
sprintf(mess, "Configure Mac failed after enabling veto\n");
|
||||
strcpy(configureMessage, mess);
|
||||
LOG(logERROR, (mess));
|
||||
configured = FAIL;
|
||||
LOG(logWARNING, ("Configure FAIL, not all parameters "
|
||||
"configured yet\n"));
|
||||
|
||||
} else {
|
||||
LOG(logINFOGREEN, ("\tConfigure MAC successful\n"));
|
||||
configured = OK;
|
||||
}
|
||||
}
|
||||
if (ret == OK) {
|
||||
int retval = getVeto();
|
||||
LOG(logDEBUG1, ("veto mode retval: %u\n", retval));
|
||||
validate(arg, retval, "set veto mode", DEC);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
@ -385,8 +385,8 @@ class Detector {
|
||||
Result<int> getNumberofUDPInterfaces(Positions pos = {}) const;
|
||||
|
||||
/** [Jungfrau][Gotthard2] Also restarts client and receiver zmq sockets
|
||||
* [Gotthard2] second interface enabled to send veto information for
|
||||
* debugging
|
||||
* [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 = {});
|
||||
|
||||
@ -884,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;
|
||||
@ -989,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 *
|
||||
|
@ -795,6 +795,7 @@ class CmdProxy {
|
||||
{"burstmode", &CmdProxy::BurstMode},
|
||||
{"currentsource", &CmdProxy::currentsource},
|
||||
{"timingsource", &CmdProxy::timingsource},
|
||||
{"veto", &CmdProxy::veto},
|
||||
|
||||
/* Mythen3 Specific */
|
||||
{"counters", &CmdProxy::Counters},
|
||||
@ -1530,8 +1531,10 @@ class CmdProxy {
|
||||
StringTo<int>,
|
||||
"[1, 2]\n\t[Jungfrau][Gotthard2] Number of udp interfaces to stream "
|
||||
"data from detector. Default: 1.\n\t"
|
||||
"[Gotthard2] Second interface enabled to send veto information for "
|
||||
"debugging.");
|
||||
"[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,
|
||||
@ -1841,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.");
|
||||
@ -1875,6 +1878,10 @@ 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>,
|
||||
|
@ -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 {
|
||||
@ -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 {
|
||||
|
@ -2094,6 +2094,12 @@ void Module::setTimingSource(slsDetectorDefs::timingSourceType value) {
|
||||
sendToDetector(F_SET_TIMING_SOURCE, static_cast<int>(value), nullptr);
|
||||
}
|
||||
|
||||
bool Module::getVeto() { return sendToDetector<int>(F_GET_VETO); }
|
||||
|
||||
void Module::setVeto(bool enable) {
|
||||
sendToDetector(F_SET_VETO, static_cast<int>(enable), nullptr);
|
||||
}
|
||||
|
||||
int Module::setCounterBit(int cb) {
|
||||
return sendToDetector<int>(F_SET_COUNTER_BIT, cb);
|
||||
}
|
||||
@ -2349,7 +2355,7 @@ int Module::setTemperatureEvent(int val) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
int Module::setStoragecellStart(int pos) {
|
||||
int Module::setStorageCellStart(int pos) {
|
||||
return sendToDetector<int>(F_STORAGE_CELL_START, pos);
|
||||
}
|
||||
|
||||
|
@ -993,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
|
||||
@ -1194,7 +1200,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
|
||||
|
@ -426,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) {
|
||||
@ -521,7 +521,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
||||
impl()->setGateDelay3(arg.gateDelay3Ns);
|
||||
impl()->setNumberOfGates(arg.gates);
|
||||
}
|
||||
if (myDetectorType == GOTTHARD) {
|
||||
if (myDetectorType == GOTTHARD2) {
|
||||
impl()->setBurstMode(arg.burstType);
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ class GeneralData {
|
||||
uint32_t vetoDataSize{0};
|
||||
uint32_t vetoPacketSize{0};
|
||||
uint32_t vetoImageSize{0};
|
||||
uint32_t vetoHsize{0};
|
||||
|
||||
GeneralData(){};
|
||||
virtual ~GeneralData(){};
|
||||
@ -61,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,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)
|
||||
@ -207,6 +213,7 @@ class GotthardData : public GeneralData {
|
||||
frameNumber = *reinterpret_cast<uint32_t *>(packetData);
|
||||
packetNumber = 0;
|
||||
}
|
||||
bunchId = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -488,8 +495,9 @@ class Gotthard2Data : public GeneralData {
|
||||
standardheader = true;
|
||||
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
|
||||
vetoDataSize = 160;
|
||||
vetoPacketSize = headerSizeinPacket + vetoDataSize;
|
||||
vetoImageSize = vetoDataSize * packetsPerFrame;
|
||||
vetoHsize = 16;
|
||||
vetoPacketSize = vetoHsize + vetoDataSize;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -506,6 +514,23 @@ class Gotthard2Data : public GeneralData {
|
||||
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 {
|
||||
|
@ -102,7 +102,7 @@ void Implementation::InitializeMembers() {
|
||||
numberOfAdditionalStorageCells = 0;
|
||||
numberOfGates = 0;
|
||||
timingMode = AUTO_TIMING;
|
||||
burstMode = BURST_OFF;
|
||||
burstMode = BURST_INTERNAL;
|
||||
acquisitionPeriod = SAMPLE_TIME_IN_NS;
|
||||
acquisitionTime = 0;
|
||||
acquisitionTime1 = 0;
|
||||
@ -1294,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;
|
||||
|
@ -270,22 +270,25 @@ 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 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 hsize = generalData->headerSizeinPacket;
|
||||
uint32_t fifohsize = generalData->fifoBufferHeaderSize;
|
||||
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) - imageSize);
|
||||
|
||||
// reset to -1
|
||||
@ -329,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) {
|
||||
@ -403,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 =
|
||||
@ -470,7 +474,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
||||
}
|
||||
|
||||
generalData->GetHeaderInfo(index, &listeningPacket[0],
|
||||
oddStartingPacket, fnum, pnum);
|
||||
oddStartingPacket, fnum, pnum, bnum);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -569,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 =
|
||||
|
@ -205,6 +205,8 @@ enum detFuncs {
|
||||
F_GET_GATE_DELAY,
|
||||
F_GET_EXPTIME_ALL_GATES,
|
||||
F_GET_GATE_DELAY_ALL_GATES,
|
||||
F_GET_VETO,
|
||||
F_SET_VETO,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||
@ -508,7 +510,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_GET_GATE_DELAY: return "F_GET_GATE_DELAY";
|
||||
case F_GET_EXPTIME_ALL_GATES: return "F_GET_EXPTIME_ALL_GATES";
|
||||
case F_GET_GATE_DELAY_ALL_GATES: return "F_GET_GATE_DELAY_ALL_GATES";
|
||||
|
||||
case F_GET_VETO: return "F_GET_VETO";
|
||||
case F_SET_VETO: return "F_SET_VETO";
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
@ -1,13 +1,12 @@
|
||||
/** API versions */
|
||||
#define GITBRANCH "setrxhostname"
|
||||
#define APILIB 0x200409
|
||||
#define APIRECEIVER 0x200409
|
||||
#define APIGUI 0x200409
|
||||
|
||||
#define APICTB 0x200520
|
||||
#define APIGOTTHARD 0x200520
|
||||
#define APIGOTTHARD2 0x200520
|
||||
#define APIJUNGFRAU 0x200520
|
||||
#define APIMOENCH 0x200515
|
||||
#define APIEIGER 0x200520
|
||||
#define GITBRANCH "developer"
|
||||
#define APILIB 0x200409
|
||||
#define APIRECEIVER 0x200409
|
||||
#define APIGUI 0x200409
|
||||
#define APICTB 0x200520
|
||||
#define APIGOTTHARD 0x200520
|
||||
#define APIJUNGFRAU 0x200520
|
||||
#define APIMOENCH 0x200515
|
||||
#define APIEIGER 0x200520
|
||||
#define APIGOTTHARD2 0x200528
|
||||
#define APIMYTHEN3 0x200528
|
||||
|
Loading…
x
Reference in New Issue
Block a user