Compare commits

...

70 Commits

Author SHA1 Message Date
aa3af2f0ce Merge pull request #190 from slsdetectorgroup/g2cont
G2cont
2020-09-24 17:20:05 +02:00
e4615a11bb binary in 2020-09-24 17:19:21 +02:00
c01ce3d514 Merge branch 'developer' into g2cont 2020-09-24 17:18:04 +02:00
99642dad69 g2 fix: cont trigger frames in rxr should be 1 2020-09-24 17:16:46 +02:00
2c1fddee84 Cmddacs (#189)
Moved dacs to it's own command for command line. 
Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com>
2020-09-24 17:16:34 +02:00
c862f1df81 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-09-24 16:55:50 +02:00
671a2724ac more set_using_dict 2020-09-24 16:55:41 +02:00
9c5d8cfcd7 gui fix g2 disabling frame period in con ext 2020-09-24 16:05:43 +02:00
8483e05f4c binary in 2020-09-24 15:44:07 +02:00
d96352f2ae g2:fix for period in trigger cont 2020-09-24 15:43:14 +02:00
0f65633ea3 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-09-24 14:07:15 +02:00
18d5c5e26d more element 2020-09-24 14:06:58 +02:00
3f19f29c9e G2ContTrigger (#188)
* g2: setting #frames  to 1 and period to 0 for cont trigger, extra frame reg is set to #frames for cont auto and #trigger for cont trigger
2020-09-24 11:59:11 +02:00
101f029eef generalized set_using_dict 2020-09-24 11:01:51 +02:00
97fea10ee2 more of @element 2020-09-24 08:39:12 +02:00
d3fbfebeb7 generalized make_ for python 2020-09-23 17:44:19 +02:00
50fd9276ce removed unused tests 2020-09-23 17:14:38 +02:00
1f31dd667b more element and dict 2020-09-23 17:06:30 +02:00
18cd363f8f tests in 2020-09-23 16:34:18 +02:00
0b0f5c94d5 master file no index 2020-09-23 16:28:50 +02:00
23720e3c63 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-09-23 15:09:25 +02:00
3432343adb element 2020-09-23 15:09:16 +02:00
d06e0d1e7f wip, doc 2020-09-23 15:07:12 +02:00
750adffe6a wip, doc 2020-09-23 15:07:03 +02:00
0b02fabaf8 wip, doc 2020-09-23 14:59:27 +02:00
4aa33b5d7f Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-09-23 14:58:33 +02:00
40a1d27e3a wip, doc 2020-09-23 14:58:30 +02:00
b23410bc5e wip, doc 2020-09-23 14:58:25 +02:00
b6d5efd441 fix for clientversion 2020-09-23 14:54:16 +02:00
79a03c6c92 WIP 2020-09-23 14:25:51 +02:00
330df3463a version prints hex 2020-09-23 14:08:41 +02:00
11754fbb5e tempvalues gives int in case of single value or same values 2020-09-23 13:54:18 +02:00
e786b9f037 wip, doc 2020-09-23 13:15:53 +02:00
bd4299fd15 Wip, doc 2020-09-23 12:32:51 +02:00
a4bdffd0b9 Merge branch 'eigerserverlock' into developer 2020-09-22 18:48:35 +02:00
bb575c6017 wip, doc 2020-09-22 18:39:46 +02:00
65da9e701b wip, doc 2020-09-21 18:30:33 +02:00
804ad0997c wip, doc 2020-09-21 18:20:59 +02:00
2fc0768ad1 minor warning fix 2020-09-21 17:57:31 +02:00
ca0192e27e Merge pull request #184 from slsdetectorgroup/eigerserverlock
Eigerserverlock
2020-09-21 17:29:03 +02:00
4ad486fda0 Merge branch 'developer' into eigerserverlock 2020-09-21 17:28:38 +02:00
cf8581caaa Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-09-21 17:28:03 +02:00
a8cc47d25c wip, doc 2020-09-21 17:27:49 +02:00
d50c40e2ad Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-09-21 17:18:43 +02:00
f6a442fd10 detsize in python 2020-09-21 17:18:31 +02:00
f5b8681811 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-09-21 17:09:49 +02:00
54ca9f7ebb wip, doc 2020-09-21 17:09:39 +02:00
9920987b4d dacvalues return int if same 2020-09-21 14:41:30 +02:00
569c014d3c WIP, doc 2020-09-21 11:23:46 +02:00
608b71d5ea Merge branch 'eigerserverlock' of github.com:slsdetectorgroup/slsDetectorPackage into eigerserverlock 2020-09-18 18:16:09 +02:00
c83daab56d merge solved 2020-09-18 18:15:54 +02:00
d65030f5ca Merge pull request #186 from slsdetectorgroup/g2cwframes
G2cwframes
2020-09-18 18:01:45 +02:00
c3366a6748 g2 binary in 2020-09-18 17:59:48 +02:00
7c21aa96a9 g2: setting continuous mode frames in naother reg, and when changing from burst to continous 2020-09-18 17:58:39 +02:00
d028a120bb binaries in 2020-09-18 14:20:05 +02:00
f6dd02acc2 minor print in temp_Fpgafl in eiger 2020-09-18 14:18:19 +02:00
0906efaf31 moving temp_fpgafl and temp_fpgafr back to the stop server 2020-09-18 14:09:23 +02:00
8ef79ce173 binaries in 2020-09-18 11:37:25 +02:00
539c0c295b replaced pthread_mutex_t with sem_t 2020-09-18 11:30:04 +02:00
e91420bd16 locking in list 2020-09-18 11:23:57 +02:00
515a0c05b9 removed locking in locallink 2020-09-18 11:23:46 +02:00
46b75c1429 minor 2020-09-18 11:23:33 +02:00
092b3fa8b9 eiger: locking for local link access in shared memory 2020-09-18 11:23:21 +02:00
a7e24717a9 dacs 2020-09-17 17:29:57 +02:00
e01e41926c Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-09-17 17:13:30 +02:00
44a8ce864b dacs for docs 2020-09-17 17:13:22 +02:00
e18f10051e jungfrau and gotthard binaries in 2020-09-17 17:11:57 +02:00
d9bb028da2 added dacnames in server defs for g1 and jungfrau 2020-09-17 17:11:09 +02:00
6d01348bf4 removed setClockFrequency and added some python commands 2020-09-17 16:03:58 +02:00
e8cd75a6ac more python commands 2020-09-17 15:10:02 +02:00
91 changed files with 2807 additions and 3858 deletions

View File

@ -1,7 +1,18 @@
import os import os
import re import re
from pathlib import Path from pathlib import Path
def remove_comments(text):
def replacer(match):
s = match.group(0)
if s.startswith('/'):
return " " # note: a space and not an empty string
else:
return s
pattern = re.compile(
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
re.DOTALL | re.MULTILINE
)
return re.sub(pattern, replacer, text)
# @CMAKE_CURRENT_BINARY_DIR@ # @CMAKE_CURRENT_BINARY_DIR@
@ -14,8 +25,9 @@ detectors = ['Mythen3', 'Gotthard2', 'Eiger',
for det in detectors: for det in detectors:
print(det)
in_fname = src/f'{det.lower()}DetectorServer/slsDetectorServer_defs.h' in_fname = src/f'{det.lower()}DetectorServer/slsDetectorServer_defs.h'
print(f'Reading: {in_fname}') #print(f'Reading: {in_fname}')
with open(in_fname) as f: with open(in_fname) as f:
lines = f.read().replace('\\\n', '') lines = f.read().replace('\\\n', '')
lines = lines.splitlines(keepends = True) lines = lines.splitlines(keepends = True)
@ -28,6 +40,8 @@ for det in detectors:
header = f'{fields[0]:35}{fields[1]:35}\n' header = f'{fields[0]:35}{fields[1]:35}\n'
output.append(header) output.append(header)
signals.append(header) signals.append(header)
dac_names = []
dac_values = []
for line in lines: for line in lines:
name, *parts = line.split() name, *parts = line.split()
arg = ' '.join(parts) arg = ' '.join(parts)
@ -41,13 +55,32 @@ for det in detectors:
signals.append(f'{name:35}{value}\n') signals.append(f'{name:35}{value}\n')
else: else:
output.append(f'{name:35}\"{value}\"\n') output.append(f'{name:35}\"{value}\"\n')
elif name == 'DAC_NAMES':
dac_names = [v.strip(', ') for v in value.split()]
dac_names = [n+',' for n in dac_names]
elif name == 'DEFAULT_DAC_VALS':
dac_values = remove_comments(value).strip('{}; ')
dac_values = dac_values.replace(',', '').split()
dac_values = [v.strip('') for v in dac_values]
print(f"dac_names: {len(dac_names)}, dac_values={len(dac_values)}")
if len(dac_values) == 0:
dac_values = ['N/A']*len(dac_names)
rstpath = Path('@CMAKE_SOURCE_DIR@')/'docs/src/' rstpath = Path('@CMAKE_SOURCE_DIR@')/'docs/src/'
out_fname = Path.cwd()/f'src/{det.lower()}.csv' out_fname = Path.cwd()/f'src/{det.lower()}.csv'
print(f'Writing: {out_fname}') out_dac_fname = Path.cwd()/f'src/{det.lower()}-dacs.csv'
#print(f'Writing: {out_fname}')
with open(out_fname, 'w') as f: with open(out_fname, 'w') as f:
f.writelines(output) f.writelines(output)
output = [f'{n:35}{v}\n' for n,v in zip(dac_names, dac_values)]
output.insert(0, header)
with open(out_dac_fname, 'w') as f:
f.writelines(output)
print('END\n\n\n\n') print('END\n\n\n\n')

View File

@ -11,6 +11,14 @@ Mythen3
:widths: 35, 35 :widths: 35, 35
:header-rows: 1 :header-rows: 1
DACS
^^^^^^^^^^^^^
.. csv-table:: Mythen3 DACS
:file: mythen3-dacs.csv
:widths: 35, 35
:header-rows: 1
Gotthard2 Gotthard2
------------- -------------
@ -19,6 +27,14 @@ Gotthard2
:widths: 35, 35 :widths: 35, 35
:header-rows: 1 :header-rows: 1
DACS
^^^^^^^^^^^^^
.. csv-table:: Gotthard 2 DACS
:file: gotthard2-dacs.csv
:widths: 35, 35
:header-rows: 1
Moench Moench
------------- -------------
@ -27,6 +43,14 @@ Moench
:widths: 35, 35 :widths: 35, 35
:header-rows: 1 :header-rows: 1
DACS
^^^^^^^^^^^^^
.. csv-table:: Moench DACS
:file: moench-dacs.csv
:widths: 35, 35
:header-rows: 1
Ctb Ctb
------------- -------------
@ -43,6 +67,14 @@ Eiger
:widths: 35, 35 :widths: 35, 35
:header-rows: 1 :header-rows: 1
DACS
^^^^^^^^^^^^^
.. csv-table:: Eiger DACS
:file: eiger-dacs.csv
:widths: 35, 35
:header-rows: 1
Jungfrau Jungfrau
------------- -------------
@ -51,6 +83,14 @@ Jungfrau
:widths: 35, 35 :widths: 35, 35
:header-rows: 1 :header-rows: 1
DACS
^^^^^^^^^^^^^
.. csv-table:: Jungfrau DACS
:file: jungfrau-dacs.csv
:widths: 35, 35
:header-rows: 1
Gotthard Gotthard
------------- -------------
@ -58,3 +98,11 @@ Gotthard
:file: gotthard.csv :file: gotthard.csv
:widths: 35, 35 :widths: 35, 35
:header-rows: 1 :header-rows: 1
DACS
^^^^^^^^^^^^^
.. csv-table:: Gotthard DACS
:file: gotthard-dacs.csv
:widths: 35, 35
:header-rows: 1

View File

@ -1,82 +0,0 @@
import pytest
import datetime as dt
from slsdet import Detector, timingMode, detectorType
not_eiger = pytest.mark.skipif(
Detector().type == detectorType.EIGER, reason="Does not work for eiger"
)
@pytest.fixture
def det():
from slsdet import Detector
return Detector()
def test_frames(det):
for n in [1, 100, 3245, 10000]:
det.frames = n
assert det.frames == n
det.frames = 1
def test_triggers(det):
for n in [1, 100, 3245, 10000]:
det.triggers = n
assert det.triggers == n
det.triggers = 1
def test_exptime(det):
det.exptime = 1
assert det.exptime == 1
det.exptime = dt.timedelta(milliseconds=10)
assert det.exptime == 0.01
det.exptime = 1
def test_period(det):
det.period = 3.2
assert det.period == 3.2
p = dt.timedelta(microseconds=1020)
det.period = p
assert det.period == 0.001020
r = det.getPeriod()
assert r[0] == p
det.period = 0
assert det.period == 0
def test_lock(det):
for l in [True, False]:
det.lock = l
assert det.lock == l
def test_timing(det):
# auto and trigger is available for all det
for m in [timingMode.TRIGGER_EXPOSURE, timingMode.AUTO_TIMING]:
det.timing = m
assert det.timing == m
@not_eiger
def test_delay(det):
det.delay = 1
assert det.delay == 1
t = dt.timedelta(microseconds=1)
det.delay = t
assert det.delay == t.total_seconds()
r = det.getDelayAfterTrigger()[0]
assert r == t
det.delay = 0
assert det.delay == 0
@not_eiger
def test_delayl(det):
assert det.delayl == 0

View File

@ -1,89 +0,0 @@
import pytest
import datetime as dt
from slsdet import Detector, detectorType
"""
These tests are designed to work the API and catch
any changes in behavior or naming. Tests are expected
to pass with a virtual detector or a real one
"""
@pytest.fixture
def jf():
from slsdet import Jungfrau
return Jungfrau()
jungfrautest = pytest.mark.skipif(
Detector().type != detectorType.JUNGFRAU, reason="Only valid for Jungfrau"
)
@jungfrautest
def test_storagecells(jf):
for i in range(16):
jf.storagecells = i
assert jf.storagecells == i
jf.storagecells = 0 # default
@jungfrautest
def test_storagecell_start(jf):
for i in range(16):
jf.storagecell_start = i
assert jf.storagecell_start == i
jf.storagecells = 15 # default
@jungfrautest
def test_storagecell_delay(jf):
for t in [0.001, 0.0002, 0.0013]:
jf.storagecell_delay = t
assert jf.storagecell_delay == t
jf.storagecell_delay = 0 # default
@jungfrautest
def test_temp_event(jf):
# hard to test with virtual server
assert jf.temp_event == 0
@jungfrautest
def test_temp_threshold(jf):
for th in [0, 10, 43, 72]:
jf.temp_threshold = th
assert jf.temp_threshold == th
jf.temp_threshold = 0
@jungfrautest
def test_auto_comp_disable(jf):
for v in [True, False]:
jf.auto_comp_disable = v
assert jf.auto_comp_disable == v
@jungfrautest
def test_numinterfaces(jf):
for n in [2, 1]:
jf.numinterfaces = n
assert jf.numinterfaces == n
@jungfrautest
def test_dr(jf):
assert jf.dr == 16
@jungfrautest
def test_temp_control(jf):
for v in [True, False]:
jf.temp_control = v
assert jf.temp_control == v
@jungfrautest
def test_startingfnum(jf):
for n in [10, 127, 43321, 1]:
jf.startingfnum = n
assert jf.startingfnum == n
@jungfrautest
def test_selinterface(jf):
for i in [1, 0]:
jf.selinterface = i
assert jf.selinterface == i

View File

@ -1,11 +1,14 @@
import os import os
import sys import sys
import numpy as np import numpy as np
from pathlib import Path
sys.path.append(os.path.join(os.getcwd(), 'bin')) sys.path.append(os.path.join(os.getcwd(), 'bin'))
from slsdet import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb, Gotthard2, Moench from slsdet import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb, Gotthard2, Moench
from slsdet import dacIndex, readoutMode from slsdet import dacIndex, readoutMode
from slsdet.lookup import view, find from slsdet.lookup import view, find
import slsdet
d = Detector() d = Detector()
e = Eiger() e = Eiger()

View File

@ -80,7 +80,10 @@ dacs = [
'vth1', 'vth1',
'vth2', 'vth2',
'vth3', 'vth3',
'vtrim' 'vtrim',
'ib_test_c',
'ibias_sfp',
] ]
intentionally_missing = [ intentionally_missing = [
@ -102,6 +105,14 @@ intentionally_missing = [
'pulse', # use pulseChip pulsePixel pulsePixelNmove 'pulse', # use pulseChip pulsePixel pulsePixelNmove
'pulsechip', 'pulsechip',
'pulsenmove', 'pulsenmove',
'savepattern', #use savePattern()
'resetfpga', #use resetFPGA()
'rebootcontroller', #use rebootController()
'firmwaretest', #use executeFirmwareTest
'bustest', # executeBusTest
'programfpga', #programFPGA
'dac', #use setDAC or detector specific class
'clearroi', #clearROI
] ]
pycmd += intentionally_missing pycmd += intentionally_missing

View File

@ -1,17 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 14 16:49:07 2017
@author: l_frojdh
"""
fw_version = 23
detector_type = 'Eiger'
known_hostnames = ['beb083', 'beb098']
image_size = (512,1024) #rows, cols
module_geometry = (1,2) #horizontal, vertical
#Remember to change these in the settings file as well!
settings_path = '/home/l_frojdh/slsDetectorPackage/settingsdir/eiger'
file_path = '/home/l_frojdh/out'

View File

@ -1,27 +0,0 @@
import pytest
from sls_detector import Detector
@pytest.fixture
def detector():
from sls_detector import Detector
return Detector()
@pytest.fixture
def eiger():
from sls_detector import Eiger
d = Eiger()
d.n_frames = 1
d.exposure_time = 1
d.file_write = False
return d
@pytest.fixture
def jungfrau():
from sls_detector import Jungfrau
return Jungfrau()
detector_type = Detector().detector_type
eigertest = pytest.mark.skipif(detector_type != 'Eiger', reason = 'Only valid for Eiger')
jungfrautest = pytest.mark.skipif(detector_type != 'Jungfrau', reason = 'Only valid for Jungfrau')

View File

@ -1,33 +0,0 @@
detsizechan 1024 512
#hostname for top+bottom+
hostname beb083+beb098+
#top
0:rx_tcpport 1954
0:lock 0
0:rx_udpport 50010
0:rx_udpport2 50011
0:rx_hostname mpc2048
0:flippeddatax 0
#bottom
1:rx_tcpport 1955
1:lock 0
1:rx_udpport 50004
1:rx_udpport2 50005
1:rx_hostname mpc2048
1:flippeddatax 1
settingsdir /home/l_frojdh/slsDetectorPackage/settingsdir/eiger
outdir /home/l_frojdh/out
vthreshold 1500
vtr 4000
dr 32
threaded 1
tengiga 0
highvoltage 150
iodelay 660
#gappixels 1

View File

@ -1,2 +0,0 @@
vrf 3000
vthreshold 1800

View File

@ -1,44 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Testing setting dynamic range for Eiger.
If the detector is not Eiger the tests are skipped
"""
import pytest
import config_test
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
from sls_detector.errors import DetectorValueError
@eigertest
def test_set_dynamic_range_and_make_acq(eiger):
eiger.exposure_time = 0.5
eiger.n_frames = 2
for dr in [4, 8, 16, 32]:
eiger.dynamic_range = dr
assert eiger.dynamic_range == dr
eiger.acq()
assert eiger.frames_caught == 2
@eigertest
def test_set_dynamic_range_raises(eiger):
with pytest.raises(DetectorValueError):
eiger.dynamic_range = 1
with pytest.raises(DetectorValueError):
eiger.dynamic_range = 75
with pytest.raises(DetectorValueError):
eiger.dynamic_range = -3
with pytest.raises(DetectorValueError):
eiger.dynamic_range = 12
@eigertest
def test_set_dynamic_range_reduces_speed(eiger):
eiger.readout_clock = 'Full Speed'
eiger.dynamic_range = 32
assert eiger.dynamic_range == 32
assert eiger.readout_clock == 'Quarter Speed'
eiger.dynamic_range = 16
assert eiger.dynamic_range == 16
assert eiger.readout_clock == 'Half Speed'

View File

@ -1,119 +0,0 @@
import pytest
import config_test
import time
from sls_detector.errors import DetectorValueError
from fixtures import eiger, eigertest
@eigertest
def test_set_matrix_reset(eiger):
eiger.eiger_matrix_reset = False
assert eiger.eiger_matrix_reset == False
eiger.eiger_matrix_reset = True
assert eiger.eiger_matrix_reset == True
@eigertest
def test_set_tx_delay_left_single(eiger):
eiger.tx_delay.left[0] = 130
assert eiger.tx_delay.left[0] == 130
eiger.tx_delay.left[1] = 150
assert eiger.tx_delay.left[1] == 150
eiger.tx_delay.left[0] = 0
eiger.tx_delay.left[1] = 0
assert eiger.tx_delay.left[0] == 0
assert eiger.tx_delay.left[1] == 0
@eigertest
def test_set_tx_delay_right_single(eiger):
eiger.tx_delay.right[0] = 130
assert eiger.tx_delay.right[0] == 130
eiger.tx_delay.right[1] = 150
assert eiger.tx_delay.right[1] == 150
eiger.tx_delay.right[0] = 0
eiger.tx_delay.right[1] = 0
assert eiger.tx_delay.right[0] == 0
assert eiger.tx_delay.right[1] == 0
@eigertest
def test_set_tx_delay_frame_single(eiger):
eiger.tx_delay.frame[0] = 500
eiger.tx_delay.frame[1] = 600
assert eiger.tx_delay.frame[0] == 500
assert eiger.tx_delay.frame[1] == 600
eiger.tx_delay.frame[0] = 0
eiger.tx_delay.frame[1] = 0
assert eiger.tx_delay.frame[0] == 0
assert eiger.tx_delay.frame[1] == 0
@eigertest
def test_tx_delay_from_list(eiger):
eiger.tx_delay.left = [123,456]
assert eiger.tx_delay.left[:] == [123,456]
eiger.tx_delay.right = [789,100]
assert eiger.tx_delay.right[:] == [789,100]
eiger.tx_delay.frame = [1000,90000]
assert eiger.tx_delay.frame[:] == [1000,90000]
eiger.tx_delay.left = [0, 0]
eiger.tx_delay.right = [0, 0]
eiger.tx_delay.frame = [0, 0]
assert eiger.tx_delay.left[:] == [0, 0]
assert eiger.tx_delay.right[:] == [0, 0]
assert eiger.tx_delay.frame[:] == [0, 0]
@eigertest
def test_acitve(eiger):
eiger.file_write = False
eiger.reset_frames_caught()
eiger.active[1] = False
eiger.acq()
assert eiger._api.getFramesCaughtByReceiver(1) == 0
assert eiger._api.getFramesCaughtByReceiver(0) == 1
eiger.active = True
time.sleep(0.5)
eiger.acq()
assert eiger.frames_caught == 1
@eigertest
def test_set_default_settings(eiger):
eiger.default_settings()
assert eiger.n_frames == 1
assert eiger.exposure_time == 1
assert eiger.period == 0
assert eiger.n_cycles == 1
assert eiger.dynamic_range == 16
@eigertest
def test_flowcontrol10g(eiger):
eiger.flowcontrol_10g = True
assert eiger.flowcontrol_10g == True
eiger.flowcontrol_10g = False
assert eiger.flowcontrol_10g == False
@eigertest
def test_read_vcmp(eiger):
eiger.vthreshold = 1500
assert eiger.vcmp[:] == [1500]*4*eiger.n_modules
@eigertest
def test_set_vcmp(eiger):
eiger.vcmp = [1000,1100,1200,1300,1400,1500,1600,1700]
assert eiger.vcmp[:] == [1000,1100,1200,1300,1400,1500,1600,1700]
eiger.vthreshold = 1500
#Disabled only works with receiver on the same pc
# @eigertest
# def test_setup500k():
# from sls_detector import Eiger, free_shared_memory
# free_shared_memory()
# d = Eiger()
# d.setup500k(config_test.known_hostnames)
# d.acq()
# assert d.rx_tcpport == [1954,1955]
# assert d.frames_caught == 1
# #could assert more setting but if the frame is caught it worked...

View File

@ -1,129 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Tests specific for the firmware.
Check that register values are correct after starting an exposure
0x4 exposure time
0x5 period
0x6 sub exposure time
"""
import pytest
import config_test
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
from sls_detector.errors import DetectorValueError
from sls_detector.utils import eiger_register_to_time
# testdata_exptimes = [0.001, 0.002, 0.0236]
@eigertest
def test_short_exposure_time(eiger):
t = 1.23
eiger.exposure_time = t
eiger.file_write = False
eiger.start_detector()
eiger.stop_detector()
#Register 0x4 holds exposure time
reg = eiger.register[0x4]
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
@eigertest
def test_short_minimal_exposure_time(eiger):
t = 1e-8
eiger.exposure_time = t
eiger.file_write = False
eiger.start_detector()
eiger.stop_detector()
#Register 0x4 holds exposure time
reg = eiger.register[0x4]
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
@eigertest
def test_long_exposure_time(eiger):
t = 623
eiger.exposure_time = t
eiger.file_write = False
eiger.start_detector()
eiger.stop_detector()
# Register 0x4 holds exposure time
reg = eiger.register[0x4]
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
@eigertest
def test_short_period(eiger):
t = 0.1
eiger.exposure_time = 0.001
eiger.period = t
eiger.file_write = False
eiger.start_detector()
eiger.stop_detector()
# Register 0x5 holds period
reg = eiger.register[0x5]
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
@eigertest
def test_long_period(eiger):
t = 8900
eiger.exposure_time = 0.001
eiger.period = t
eiger.file_write = False
eiger.start_detector()
eiger.stop_detector()
# Register 0x5 holds period
reg = eiger.register[0x5]
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
@eigertest
def test_zero_period_with_acq(eiger):
t = 0
eiger.exposure_time = 0.001
eiger.period = t
eiger.file_write = False
eiger.start_detector()
eiger.stop_detector()
# Register 0x5 holds period
reg = eiger.register[0x5]
assert pytest.approx(t, 1e-9) == eiger_register_to_time(reg)
testdata_times = [0.001, 0.002, 0.0236]
@eigertest
@pytest.mark.parametrize("t", testdata_times)
def test_subexptime(eiger,t):
eiger.sub_exposure_time = t
eiger.file_write = False
eiger.start_detector()
eiger.stop_detector()
# Register 0x6 holds sub exposure time
# time is stored straight as n clocks
reg = eiger.register[0x6]
assert pytest.approx(t, 1e-9) == reg/100e6
@eigertest
@pytest.mark.parametrize("t", testdata_times)
def test_subdeadtime(eiger, t):
eiger.sub_deadtime = t
eiger.sub_exposure_time = 1
eiger.sub_exposure_time = 0.001
eiger.file_write = False
eiger.start_detector()
eiger.stop_detector()
# Register 0x7 holds sub period
# time is stored straight as n clocks
# exptime+deadtime
reg = eiger.register[0x7]
assert pytest.approx(t, 1e-7) == (reg/100e6-0.001)

View File

@ -1,187 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
General tests for the Detector class. Should not depend on the connected detector. Aim is to have tests working
for both Jungfrau and Eiger.
NOTE! Uses hostnames from config_test
"""
import pytest
import config_test
from fixtures import detector
from sls_detector.errors import DetectorValueError, DetectorError
def test_error_handling(detector):
with pytest.raises(DetectorError):
detector._provoke_error()
def test_not_busy(detector):
"""Test that the detector is not busy from the start"""
assert detector.busy == False
def test_reset_frames_caught(detector):
detector.file_write = False
detector.acq()
assert detector.frames_caught == 1
detector.reset_frames_caught()
assert detector.frames_caught == 0
def test_set_busy_true_then_false(detector):
"""Test both cases of assignment"""
detector.busy = True
assert detector.busy == True
detector.busy = False
assert detector.busy == False
def test_set_readout_speed(detector):
for s in ['Full Speed', 'Half Speed', 'Quarter Speed', 'Super Slow Speed']:
detector.readout_clock = s
assert detector.readout_clock == s
def test_wrong_speed_raises_error(detector):
with pytest.raises(KeyError):
detector.readout_clock = 'Something strange'
def test_readout_clock_remains(detector):
s = detector.readout_clock
try:
detector.readout_clock = 'This does not exists'
except KeyError:
pass
assert detector.readout_clock == s
def test_len_method(detector):
"""to test this we need to know the length, this we get from the configuration of hostnames"""
assert len(detector) == len(config_test.known_hostnames)
def test_setting_n_cycles_to_zero_gives_error(detector):
with pytest.raises(DetectorValueError):
detector.n_cycles = 0
def test_setting_n_cycles_to_negative_gives_error(detector):
with pytest.raises(DetectorValueError):
detector.n_cycles = -50
def test_set_cycles_frome_one_to_ten(detector):
for i in range(1,11):
detector.n_cycles = i
assert detector.n_cycles == i
detector.n_cycles = 1
assert detector.n_cycles == 1
def test_get_detector_type(detector):
assert detector.detector_type == config_test.detector_type
def test_set_file_index(detector):
detector.file_index = 5
assert detector.file_index == 5
def test_negative_file_index_raises(detector):
with pytest.raises(ValueError):
detector.file_index = -8
def test_setting_file_name(detector):
fname = 'hej'
detector.file_name = fname
assert detector.file_name == fname
def test_set_file_write(detector):
detector.file_write = True
assert detector.file_write == True
detector.file_write = False
assert detector.file_write == False
def test_set_high_voltage(detector):
detector.high_voltage = 55
assert detector.high_voltage == 55
def test_negative_voltage_raises(detector):
with pytest.raises(DetectorValueError):
detector.high_voltage = -5
def test_high_voltage_raises_on_to_high(detector):
with pytest.raises(DetectorValueError):
detector.high_voltage = 500
def test_get_image_size(detector):
"""Compares with the size in the config file"""
assert detector.image_size.rows == config_test.image_size[0]
assert detector.image_size.cols == config_test.image_size[1]
def test_get_module_geometry(detector):
"""Compares with the size in the config file"""
assert detector.module_geometry.horizontal == config_test.module_geometry[0]
assert detector.module_geometry.vertical == config_test.module_geometry[1]
def test_set_nframes(detector):
detector.n_frames = 5
assert detector.n_frames == 5
detector.n_frames = 1
assert detector.n_frames == 1
def test_set_n_measurements(detector):
detector.n_measurements = 7
assert detector.n_measurements == 7
detector.n_measurements = 1
assert detector.n_measurements == 1
def test_negative_nframes_raises(detector):
with pytest.raises(DetectorValueError):
detector.n_frames = -2
def test_nmodules(detector):
"""Assume that the number of modules should be the same as the number of hostnames"""
assert detector.n_modules == len(config_test.known_hostnames)
def test_is_detector_online(detector):
assert detector.online == True
def test_set_online(detector):
detector.online = False
assert detector.online == False
detector.online = True
assert detector.online == True
def test_receiver_is_online(detector):
assert detector.receiver_online == True
def test_set_receiver_online(detector):
detector.receiver_online = False
assert detector.receiver_online == False
detector.receiver_online = True
assert detector.receiver_online == True
def test_set_receiver_online_raises_on_non_bool(detector):
with pytest.raises(TypeError):
detector.receiver_online = 'probably not this'
def test_set_period(detector):
detector.period = 5.123
assert detector.period == 5.123
detector.period = 0
assert detector.period == 0
def test_set_timing_mode(detector):
detector.timing_mode = 'trigger'
assert detector.timing_mode == 'trigger'
detector.timing_mode = 'auto'
assert detector.timing_mode == 'auto'

View File

@ -1,38 +0,0 @@
import pytest
import config_test
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
from sls_detector.detector import element_if_equal
from sls_detector.errors import DetectorValueError
from fixtures import eiger, eigertest
@eigertest
def test_load_config_file_eiger(eiger):
"""Load a settings file and assert all settings"""
eiger.load_config(os.path.join(dir_path, 'test.config'))
assert eiger.rx_tcpport == [1954, 1955]
assert eiger.lock == False
assert eiger.rx_udpport == [50010, 50011, 50004, 50005]
assert eiger.rx_hostname == 'mpc2048'
assert eiger.flipped_data_x[:] == [False, True]
assert eiger.settings_path == config_test.settings_path
assert eiger.file_path == config_test.file_path
assert eiger.vthreshold == 1500
assert element_if_equal(eiger.dacs.vtr[:]) == 4000
assert eiger.dynamic_range == 32
assert eiger.tengiga == False
assert eiger.high_voltage == 150
assert element_if_equal(eiger.dacs.iodelay[:]) == 660
@eigertest
def test_load_parameters_file_eiger(eiger):
"""Load a parametes file and assert the settings in the file"""
eiger.load_parameters(os.path.join(dir_path, 'test.par'))
assert element_if_equal(eiger.dacs.vrf[:]) == 3000
assert eiger.vthreshold == 1800

View File

@ -1,81 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Tests for network related functions of the detector
"""
import pytest
import config_test
from fixtures import eiger, eigertest, detector
# def test_last_client(detector):
# import socket
# # We probably should check for multiple ip's
# myip = socket.gethostbyname_ex(socket.gethostname())[-1][0]
# assert detector.last_client_ip == myip
def test_get_hostname(detector):
for detector_host, config_host in zip(detector.hostname, config_test.known_hostnames):
assert detector_host == config_host
def test_hostname_has_same_length_as_n_modules(detector):
assert len(detector.hostname) == detector.n_modules
# # def test_get_receiver_hostname(detector):
# # """Assume that the receiver are on the local computer"""
# # import socket
# # host = socket.gethostname().split('.')[0]
# # assert detector.rx_hostname == host
# def test_set_receiver_hostname(detector):
# import socket
# host = socket.gethostname().split('.')[0]
# phony_host = 'madeup'
# detector.rx_hostname = phony_host
# assert detector.rx_hostname == phony_host
# detector.rx_hostname = host
# assert detector.rx_hostname == host
@eigertest
def test_set_rx_zmqport_single_value(eiger):
eiger.rx_zmqport = 35000
assert eiger.rx_zmqport == [35000, 35001, 35002, 35003]
@eigertest
def test_set_rx_zmqport_list(eiger):
eiger.rx_zmqport = [37000, 38000]
assert eiger.rx_zmqport == [37000, 37001, 38000, 38001]
@eigertest
def test_set_rx_updport(eiger):
ports = [60010,60011,60012,60013]
eiger.rx_udpport = ports
assert eiger.rx_udpport == ports
eiger.acq()
assert eiger.frames_caught == 1
@eigertest
def test_rx_tcpport(eiger):
ports = eiger.rx_tcpport
eiger.rx_tcpport = [2000,2001]
assert eiger.rx_tcpport == [2000,2001]
eiger.rx_tcpport = ports
assert eiger.rx_tcpport == ports
eiger.acq()
assert eiger.frames_caught == 1
# @eigertest
# @pytest.mark.new
# def test_enable_disable_tengiga(eiger):
# """
# This test does not check for dat on the 10Gbit link, only the set and get functions
# """
# eiger.tengiga = True
# assert eiger.tengiga == True
# eiger.tengiga = False
# assert eiger.tengiga == False
#TODO! Add test for Jungfrau

View File

@ -1,54 +0,0 @@
import pytest
import config_test
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
from sls_detector.errors import DetectorValueError
@eigertest
@pytest.mark.local
def test_set_path(eiger, tmpdir):
import os
path = os.path.join(tmpdir.dirname, tmpdir.basename)
eiger.file_path = path
assert eiger.file_path == path
@eigertest
@pytest.mark.local
def test_set_path_and_write_files(eiger, tmpdir):
import os
prefix = 'testprefix'
path = os.path.join(tmpdir.dirname, tmpdir.basename)
eiger.file_path = path
eiger.file_write = True
eiger.exposure_time = 0.1
eiger.n_frames = 1
eiger.timing_mode = 'auto'
eiger.file_name = prefix
eiger.file_index = 0
eiger.acq()
files = [f.basename for f in tmpdir.listdir()]
assert len(files) == 5
assert (prefix+'_d0_0.raw' in files) == True
assert (prefix+'_d1_0.raw' in files) == True
assert (prefix+'_d2_0.raw' in files) == True
assert (prefix+'_d3_0.raw' in files) == True
def test_set_discard_policy(detector):
detector.frame_discard_policy = 'nodiscard'
assert detector.frame_discard_policy == 'nodiscard'
detector.frame_discard_policy = 'discardpartial'
assert detector.frame_discard_policy == 'discardpartial'
detector.frame_discard_policy = 'discardempty'
assert detector.frame_discard_policy == 'discardempty'
def test_set_discard_policy_raises(detector):
with pytest.raises(ValueError):
detector.frame_discard_policy = 'adjfvadksvsj'
def test_set_frames_perfile(detector):
detector.frames_per_file = 5000
assert detector.frames_per_file == 5000

View File

@ -1,47 +0,0 @@
import pytest
import config_test
import time
from sls_detector.errors import DetectorValueError
import os
from fixtures import eiger, eigertest
testdata_th = [0,333,500,1750,2000]
@eigertest
@pytest.mark.parametrize("th", testdata_th)
def test_set_vthreshold(eiger, th):
eiger.vthreshold = th
assert eiger.vthreshold == th
@eigertest
def test_vthreshold_with_different_vcmp(eiger):
#When vcmp is different for the chip vthreshold should return -1
eiger.vthreshold = 1500
eiger.dacs.vcmp_ll = 1400
assert eiger.vthreshold == -1
@eigertest
def test_set_settingsdir(eiger):
path = os.path.dirname( os.path.realpath(__file__) )
path = os.path.join(path, 'settingsdir')
eiger.settings_path = path
assert eiger.settings_path == path
@eigertest
def test_set_trimmed_energies(eiger):
en = [5000,6000,7000]
eiger.trimmed_energies = en
assert eiger.trimmed_energies == en
#TODO! add checks for vcmp as well and improve naming
#TODO! remove dependency on beb number
testdata_en = [(5000, 500),(5500,750),(6000,1000),(6200,1100),(7000,1500)]
@eigertest
@pytest.mark.parametrize('val', testdata_en)
def test_set_energy_threshold(eiger, val):
eiger.settings = 'standard'
eiger.threshold = val[0]
assert eiger.threshold == val[0]
assert eiger.dacs.vrf[0] == val[1]

View File

@ -1,136 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Tests regarding exposure time and period of the detector
Set and get test as well as test for duration and on detector
measurement of the time.
"""
import pytest
import config_test
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
from sls_detector.errors import DetectorValueError, DetectorError
import time
testdata_times = [1e-8, 0.001, 0.5, 3.125, 5.0, 600, 784]
@pytest.mark.parametrize("t", testdata_times)
def test_set_and_get_exposure_time(eiger, t):
"""
Test that the exposure time we set in the detector
is the same as the one read back
"""
eiger.exposure_time = t
assert eiger.exposure_time == t
def test_negative_exposure_time_raises_error(eiger):
with pytest.raises(DetectorValueError):
eiger.exposure_time = -15
testdata_times = [0.001, 0.0025, 0.005, 5]
@pytest.mark.parametrize("t", testdata_times)
def test_set_subexptime(eiger, t):
eiger.sub_exposure_time = t
assert eiger.sub_exposure_time == t
testdata_times = [-5,6,7,50]
@pytest.mark.parametrize("t", testdata_times)
def test_set_subextime_too_large_or_neg(eiger, t):
with pytest.raises((DetectorError, DetectorValueError)):
eiger.sub_exposure_time = t
testdata_times = [0.2, 0.5, 1, 2, 5, 7]
@pytest.mark.slow
@pytest.mark.parametrize("t", testdata_times)
def test_measure_exposure_time_from_python(eiger, t):
"""
The main idea with this test is to make sure the overhead of a
single acq is less than tol[s]. This test also catches stupid bugs
that would for example not change the exposure time or make acquire
not blocking.
"""
tol = 0.5
eiger.dynamic_range = 16
eiger.file_write = False
eiger.n_frames = 1
eiger.exposure_time = t
assert eiger.exposure_time == t
t0 = time.time()
eiger.acq()
duration = time.time()-t0
assert duration < (t+tol)
testdata_times = [0.5, 1, 3, 5]
@pytest.mark.slow
@pytest.mark.parametrize("t", testdata_times)
def test_measure_period_from_python_and_detector(eiger, t):
tol = 0.5
nframes = 5
eiger.dynamic_range = 16
eiger.file_write = False
eiger.n_frames = nframes
eiger.exposure_time = 0.001
eiger.period = t
t0 = time.time()
eiger.acq()
duration = time.time()-t0
assert duration < t*(nframes-1)+tol
for mp in eiger.measured_period:
assert pytest.approx(mp, 1e-5) == t
testdata_times = [0.001, 0.002, 0.003, 0.005, 0.01]
@pytest.mark.parametrize("t", testdata_times)
def test_measure_subperiod_nonparallel(eiger, t):
readout_time = 500e-6
eiger.dynamic_range = 32
eiger.file_write = False
eiger.flags = 'nonparallel'
eiger.n_frames = 1
eiger.period = 0
eiger.exposure_time = 0.5
eiger.sub_exposure_time = t
eiger.sub_deadtime = 0
eiger.acq()
for mp in eiger.measured_subperiod:
assert pytest.approx(mp, abs=1e-5) == t+readout_time
@pytest.mark.parametrize("t", testdata_times)
def test_measure_subperiod_parallel(eiger, t):
readout_time = 12e-6
eiger.dynamic_range = 32
eiger.file_write = False
eiger.flags = 'parallel'
eiger.n_frames = 1
eiger.period = 0
eiger.exposure_time = 0.5
eiger.sub_exposure_time = t
eiger.sub_deadtime = 0
eiger.acq()
for mp in eiger.measured_subperiod:
assert pytest.approx(mp, abs=1e-5) == t+readout_time
@pytest.mark.parametrize("t", testdata_times)
def test_measure_subperiod_parallel_when_changing_deadtime(eiger, t):
readout_time = 12e-6
exposure_time = 0.001
eiger.dynamic_range = 32
eiger.file_write = False
eiger.flags = 'parallel'
eiger.n_frames = 1
eiger.period = 0
eiger.exposure_time = 0.5
eiger.sub_exposure_time = exposure_time
eiger.sub_deadtime = t
eiger.acq()
for mp in eiger.measured_subperiod:
assert pytest.approx(mp, abs=1e-5) == t+exposure_time

View File

@ -1,34 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Tests for trimbit and dac related functions
"""
import pytest
import config_test
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
from sls_detector.errors import DetectorValueError
@eigertest
def test_set_trimbits(eiger):
"""Limited values due to time"""
for i in [17, 32, 60]:
print(i)
eiger.trimbits = i
assert eiger.trimbits == i
@eigertest
def test_set_trimbits_raises_on_too_big(eiger):
with pytest.raises(DetectorValueError):
eiger.trimbits = 75
@eigertest
def test_set_trimbits_raises_on_negative(eiger):
with pytest.raises(DetectorValueError):
eiger.trimbits = -5
# @jungfrautest
# def test_jungfrau(jungfrau):
# """Example of a test that is not run with Eiger connected"""
# pass

View File

@ -1,16 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Tests for hostname related functions of the detector
"""
import pytest
import config_test
from fixtures import detector, eiger, jungfrau, eigertest, jungfrautest
from sls_detector.errors import DetectorValueError
def test_firmware_version(detector):
assert detector.firmware_version == config_test.fw_version

View File

@ -1,42 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May 22 14:13:48 2018
@author: l_frojdh
"""
import os
from sls_detector_tools.io import write_trimbit_file
from sls_detector_tools import mask
energy = [5000, 6000, 7000]
vrf = [500, 1000, 1500]
for i,e in enumerate(energy):
dacs = np.array( [[ 0., 0.], #vsvp
[4000., 4000.], #vtr
[vrf[i], vrf[i]], #vrf
[1400., 1400.], #vrs
[4000., 4000.], #vsvn
[2556., 2556.], #vtgstv
[1400., 1400.], #vcmp_ll
[1500., 1500.], #vcmp_lr
[4000., 4000.], #vcall
[1500., 1500.], #vcmp_rl
[1100., 1100.], #rxb_rb
[1100., 1100.], #rxb_lb
[1500., 1500.], #vcmp_rr
[1500., 1500.], #vcp
[2000., 2000.], #vcn
[1550., 1550.], #vis
[ 660., 660.], #iodelay
[ 0., 0.], #tau
])
tb = np.zeros((256,1024))
for beb in [83,98]:
write_trimbit_file(f'settingsdir/standard/{e}eV/noise.sn{beb:03d}', tb, dacs[:,0])
#print(os.getcwd())
#print( os.path.realpath(__file__))

View File

@ -1,17 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 14 16:49:07 2017
@author: l_frojdh
"""
fw_version = 0x180220
detector_type = 'Jungfrau'
known_hostnames = ['bchip038']
image_size = (512,1024) #rows, cols
module_geometry = (1,1) #horizontal, vertical
#Remember to change these in the settings file as well!
settings_path = '/home/l_lopez/projects/slsDetectorPackage/settingsdir/jungfrau'
file_path = '/home/l_lopez/out'

View File

@ -1,23 +0,0 @@
import pytest
from sls_detector import Detector
@pytest.fixture
def detector():
from sls_detector import Detector
return Detector()
@pytest.fixture
def eiger():
from sls_detector import Eiger
return Eiger()
@pytest.fixture
def jungfrau():
from sls_detector import Jungfrau
return Jungfrau()
detector_type = Detector().detector_type
eigertest = pytest.mark.skipif(detector_type != 'Eiger', reason = 'Only valid for Eiger')
jungfrautest = pytest.mark.skipif(detector_type != 'Jungfrau', reason = 'Only valid for Jungfrau')

View File

@ -1,17 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
General tests for the Jungfrau detector.
NOTE! Uses hostnames from config_test
"""
import pytest
import config_test
import tests
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
pytest.main(['-x', '-s', os.path.join(dir_path, 'tests/test_load_config.py')]) #Test 1
pytest.main(['-x', '-s', os.path.join(dir_path, 'tests/test_overtemperature.py')]) #Test 2

View File

@ -1,21 +0,0 @@
detsizechan 1024 512
settingsdir /home/l_lopez/projects/slsDetectorPackage/settingsdir/jungfrau
caldir /home/l_lopez/projects/slsDetectorPackage/settingsdir/jungfrau
lock 0
hostname bchip094+
rx_udpport 1754
rx_udpip 10.1.1.107
rx_udpmac 90:E2:BA:9A:4F:D4
detectorip 10.1.1.9
detectormac 00:aa:bb:cc:dd:ee
configuremac 0
powerchip 1
timing auto
outdir /home/l_lopez/out
threaded 1
high

View File

@ -1 +0,0 @@
highvoltage 200

View File

@ -1,43 +0,0 @@
import pytest
import config_test
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
from fixtures import jungfrau, jungfrautest
def load_config_file_jungfrau_test(jungfrau):
"""Load a settings file and assert all settings"""
print('\tStarting load_config_file_jungfrau_test test case')
jungfrau.free_shared_memory
jungfrau.load_config(os.path.join(dir_path, 'test.config'))
assert jungfrau.lock == False
assert jungfrau.rx_udpport == ['1754']
assert jungfrau.hostname == ['bchip094']
assert jungfrau.firmware_version == config_test.fw_version
print('\tFinished load_config_file_jungfrau_test test case')
def load_parameters_file_jungfrau_test(jungfrau):
"""Load a parametes file and assert the settings in the file"""
print('\tStarting load_parameters_file_jungfrau_test test case')
jungfrau.load_parameters(os.path.join(dir_path, 'test.par'))
assert jungfrau.high_voltage == 200
print('\tFinished load_parameters_file_jungfrau_test test case')
@jungfrautest
def test_main(jungfrau):
print('\nTesting configuration file loading')
load_config_file_jungfrau_test(jungfrau)
load_parameters_file_jungfrau_test(jungfrau)
print('Tested configuration file loading')

View File

@ -1,68 +0,0 @@
import pytest
import config_test
import time
from fixtures import jungfrau, jungfrautest
def powerchip_test(jungfrau, control):
"""
Test the main overtemperature protection control
"""
#Set test initial conditions
print('\tStarting powerchip_test test case')
jungfrau.power_chip = False
jungfrau.temperature_control = control
assert jungfrau.power_chip == False
jungfrau.temperature_threshold = 35
jungfrau.power_chip = True
if jungfrau.temperature_control is True:
if jungfrau.temperature_event is True:
assert jungfrau.power_chip == False
jungfrau.power_chip = True
assert jungfrau.power_chip == False
jungfrau.temperature_control = False
assert jungfrau.power_chip == True
jungfrau.temperature_control = True
jungfrau.temperature_threshold = 50
assert jungfrau.power_chip == False
print('\t\tWaiting to cool down the board. This may take a while...')
while jungfrau.temperature_threshold < jungfrau.temp.fpga[0]:
time.sleep(5)
print('\t\tJungfrau MCB temperature: {0:.2f} °C'.format(jungfrau.temp.fpga[0]))
#Leave enough time to let the board cool down a bit more
time.sleep(30)
jungfrau.reset_temperature_event()
assert jungfrau.temperature_event == False
assert jungfrau.power_chip == True
else:
assert jungfrau.power_chip == True
else:
print('\t\tWaiting to warm up the board. This may take a while...')
while jungfrau.temperature_threshold > jungfrau.temp.fpga[0]:
time.sleep(5)
print('\t\tJungfrau MCB temperature: {0:.2f} °C'.format(jungfrau.temp.fpga[0]))
assert jungfrau.temperature_event == False
assert jungfrau.power_chip == True
print('\tFinished powerchip_test test case')
#@jungfrautest
def test_main(jungfrau):
print('\nTesting overtemperature protection control')
powerchip_test(jungfrau, False)
powerchip_test(jungfrau, True)
print('Tested overtemperature protection control')

View File

@ -10,7 +10,7 @@ from .gotthard import Gotthard
from .moench import Moench from .moench import Moench
import _slsdet import _slsdet
xy = _slsdet.xy
defs = _slsdet.slsDetectorDefs defs = _slsdet.slsDetectorDefs
from .enums import * from .enums import *

File diff suppressed because it is too large Load Diff

View File

@ -51,12 +51,12 @@ class SlowAdcProxy:
def __repr__(self): def __repr__(self):
rstr = '' rstr = ''
for i in range(7): for i in range(8):
r = element_if_equal(self.__getitem__(i)) r = element_if_equal(self.__getitem__(i))
if isinstance(r, list): if isinstance(r, list):
rstr += ' '.join(f'{item} mV' for item in r) rstr += ' '.join(f'{item} uV' for item in r)
else: else:
rstr += f'{i}: {r} mV\n' rstr += f'{i}: {r} uV\n'
return rstr.strip('\n') return rstr.strip('\n')
@ -83,3 +83,46 @@ class ClkDivProxy:
rstr += f'{i}: {r}\n' rstr += f'{i}: {r}\n'
return rstr.strip('\n') return rstr.strip('\n')
class MaxPhaseProxy:
"""
Proxy class to allow for more intuitive reading clockdivider
"""
def __init__(self, det):
self.det = det
def __getitem__(self, key):
return element_if_equal(self.det.getMaxClockPhaseShift(key))
def __repr__(self):
rstr = ''
for i in range(5):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
rstr += ' '.join(f'{item}' for item in r)
else:
rstr += f'{i}: {r}\n'
return rstr.strip('\n')
class ClkFreqProxy:
"""
Proxy class to allow for more intuitive reading clockdivider
"""
def __init__(self, det):
self.det = det
def __getitem__(self, key):
return element_if_equal(self.det.getClockFrequency(key))
def __repr__(self):
rstr = ''
for i in range(5):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
rstr += ' '.join(f'{item}' for item in r)
else:
rstr += f'{i}: {r}\n'
return rstr.strip('\n')

View File

@ -3,16 +3,17 @@ Utility functions that are useful for testing and troubleshooting
but not directly used in controlling the detector but not directly used in controlling the detector
""" """
from collections import namedtuple from collections import namedtuple
import _slsdet #C++ lib import _slsdet #C++ lib
import functools import functools
import datetime as dt import datetime as dt
import pathlib import pathlib
import os import os
from pathlib import Path
Geometry = namedtuple('Geometry', ['x', 'y']) Geometry = namedtuple('Geometry', ['x', 'y'])
def is_iterable(item): def is_iterable(item):
try: try:
iter(item) iter(item)
@ -20,11 +21,13 @@ def is_iterable(item):
return False return False
return True return True
def get_set_bits(mask): def get_set_bits(mask):
""" """
Return a list of the set bits in a python integer Return a list of the set bits in a python integer
""" """
return [i for i in range(mask.bit_length()) if (mask>>i)&1] return [i for i in range(mask.bit_length()) if (mask >> i) & 1]
def list_to_bitmask(values): def list_to_bitmask(values):
""" """
@ -37,11 +40,21 @@ def list_to_bitmask(values):
mask += 1 << v mask += 1 << v
return mask return mask
def make_bitmask(args):
if isinstance(args, list):
return list_to_bitmask(args)
elif isinstance(args, dict):
return {key: list_to_bitmask(value) for key, value in args.items()}
else:
raise ValueError("Cannot convert arg to bitmask")
def to_geo(value): def to_geo(value):
if isinstance(value, _slsdet.xy): if isinstance(value, _slsdet.xy):
return Geometry(x = value.x, y = value.y) return Geometry(x=value.x, y=value.y)
else: else:
raise ValueError("Can only convert sls_detector.xy") raise ValueError("Can only convert slsdet.xy")
def all_equal(mylist): def all_equal(mylist):
"""If all elements are equal return true otherwise false""" """If all elements are equal return true otherwise false"""
@ -61,6 +74,7 @@ def element_if_equal(mylist):
else: else:
return mylist return mylist
def reduce_time(mylist): def reduce_time(mylist):
res = element_if_equal(element_if_equal(mylist)) res = element_if_equal(element_if_equal(mylist))
if isinstance(res, dt.timedelta): if isinstance(res, dt.timedelta):
@ -70,6 +84,7 @@ def reduce_time(mylist):
else: else:
return [r.total_seconds() for r in res] return [r.total_seconds() for r in res]
def element(func): def element(func):
""" """
Wrapper to return either list or element Wrapper to return either list or element
@ -77,6 +92,7 @@ def element(func):
@functools.wraps(func) @functools.wraps(func)
def wrapper(self, *args, **kwargs): def wrapper(self, *args, **kwargs):
return element_if_equal(func(self, *args, **kwargs)) return element_if_equal(func(self, *args, **kwargs))
return wrapper return wrapper
@ -89,7 +105,8 @@ def eiger_register_to_time(register):
""" """
clocks = register >> 3 clocks = register >> 3
exponent = register & 0b111 exponent = register & 0b111
return clocks*10**exponent / 100e6 return clocks * 10**exponent / 100e6
def make_timedelta(t): def make_timedelta(t):
if isinstance(t, dt.timedelta): if isinstance(t, dt.timedelta):
@ -97,7 +114,8 @@ def make_timedelta(t):
else: else:
return dt.timedelta(seconds=t) return dt.timedelta(seconds=t)
def make_string_path(path):
def _make_string_path(path):
""" """
Accepts either a pathlib.Path or a string, expands ~ to user and convert Accepts either a pathlib.Path or a string, expands ~ to user and convert
Path to str Path to str
@ -110,12 +128,49 @@ def make_string_path(path):
raise ValueError("Cannot convert argument to posix path") raise ValueError("Cannot convert argument to posix path")
def set_using_dict(func, args): def make_string_path(path):
if isinstance(args, dict) and all(isinstance(k, int) for k in args.keys()): return _make(path, _make_string_path)
for key, value in args.items():
func(value, [key])
def make_ip(arg):
return _make(arg, _slsdet.IpAddr)
def make_mac(arg):
return _make(arg, _slsdet.MacAddr)
def make_path(arg):
return _make(arg, Path)
def _make(arg, transform):
"""Helper function for make_mac and make_ip special cases for
dict, list and tuple. Otherwise just calls transform"""
if isinstance(arg, dict):
return {key: transform(value) for key, value in arg.items()}
elif isinstance(arg, list):
return [transform(a) for a in arg]
elif isinstance(arg, tuple):
return tuple(transform(a) for a in arg)
else: else:
func(args) return transform(arg)
def set_using_dict(func, *args):
if len(args) == 1 and isinstance(args[0], dict) and all(
isinstance(k, int) for k in args[0].keys()):
for key, value in args[0].items():
if not isinstance(value, tuple):
value = (value,)
try:
func(*value, [key])
except TypeError:
func(*value, key)
else:
func(*args)
def set_time_using_dict(func, args): def set_time_using_dict(func, args):
if isinstance(args, dict) and all(isinstance(k, int) for k in args.keys()): if isinstance(args, dict) and all(isinstance(k, int) for k in args.keys()):
@ -127,3 +182,29 @@ def set_time_using_dict(func, args):
if isinstance(args, int): if isinstance(args, int):
args = float(args) args = float(args)
func(args) func(args)
def lhex(iterable):
return [hex(item) for item in iterable]
def lpath(iterable):
return [Path(item) for item in iterable]
def add_argument_before(a, args):
"""Add a before the other arguments. Also works with
dict that holds args to several modules. Always puts the
args in a dict to be compatible with set_using_dict"""
print(f'{args=}')
if isinstance(args, tuple):
return (a, *args)
elif isinstance(args, dict):
ret = {}
for key, value in args.items():
if isinstance(value, tuple):
ret[key] = (a, *value)
else:
ret[key] = (a, value)
return (ret,)
return a, args

View File

@ -253,10 +253,6 @@ void init_det(py::module &m) {
(Result<int>(Detector::*)(int, sls::Positions)) & (Result<int>(Detector::*)(int, sls::Positions)) &
Detector::getClockFrequency, Detector::getClockFrequency,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("setClockFrequency",
(void (Detector::*)(int, int, sls::Positions)) &
Detector::setClockFrequency,
py::arg(), py::arg(), py::arg() = Positions{})
.def("getClockPhase", .def("getClockPhase",
(Result<int>(Detector::*)(int, sls::Positions)) & (Result<int>(Detector::*)(int, sls::Positions)) &
Detector::getClockPhase, Detector::getClockPhase,
@ -669,13 +665,10 @@ void init_det(py::module &m) {
Detector::setFileWrite, Detector::setFileWrite,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("getMasterFileWrite", .def("getMasterFileWrite",
(Result<bool>(Detector::*)(sls::Positions) const) & (bool (Detector::*)() const) & Detector::getMasterFileWrite)
Detector::getMasterFileWrite,
py::arg() = Positions{})
.def("setMasterFileWrite", .def("setMasterFileWrite",
(void (Detector::*)(bool, sls::Positions)) & (void (Detector::*)(bool)) & Detector::setMasterFileWrite,
Detector::setMasterFileWrite, py::arg())
py::arg(), py::arg() = Positions{})
.def("getFileOverWrite", .def("getFileOverWrite",
(Result<bool>(Detector::*)(sls::Positions) const) & (Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getFileOverWrite, Detector::getFileOverWrite,
@ -972,6 +965,10 @@ void init_det(py::module &m) {
(void (Detector::*)(sls::ns, sls::Positions)) & (void (Detector::*)(sls::ns, sls::Positions)) &
Detector::setBurstPeriod, Detector::setBurstPeriod,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("getNumberOfBurstsLeft",
(Result<int64_t>(Detector::*)(sls::Positions) const) &
Detector::getNumberOfBurstsLeft,
py::arg() = Positions{})
.def("getInjectChannel", .def("getInjectChannel",
(Result<std::array<int, 2>>(Detector::*)(sls::Positions)) & (Result<std::array<int, 2>>(Detector::*)(sls::Positions)) &
Detector::getInjectChannel, Detector::getInjectChannel,
@ -1381,6 +1378,10 @@ void init_det(py::module &m) {
(void (Detector::*)(uint32_t, int, sls::Positions)) & (void (Detector::*)(uint32_t, int, sls::Positions)) &
Detector::clearBit, Detector::clearBit,
py::arg(), py::arg(), py::arg() = Positions{}) py::arg(), py::arg(), py::arg() = Positions{})
.def("getBit",
(Result<int>(Detector::*)(uint32_t, int, sls::Positions)) &
Detector::getBit,
py::arg(), py::arg(), py::arg() = Positions{})
.def("executeFirmwareTest", .def("executeFirmwareTest",
(void (Detector::*)(sls::Positions)) & (void (Detector::*)(sls::Positions)) &
Detector::executeFirmwareTest, Detector::executeFirmwareTest,

View File

@ -1,173 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Testing setting and getting dacs from the detector
"""
from unittest.mock import Mock, call
import pytest
from pytest_mock import mocker
import numpy as np
from sls_detector import Eiger
from sls_detector import DetectorApi
def test_get_vrf_for_three_mod(mocker):
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 3
m = mocker.patch.object(DetectorApi, 'getDac', autospec=True)
m.return_value = 1560
d = Eiger()
vrf = d.dacs.vrf[:]
assert vrf == [1560, 1560, 1560]
def test_set_vrf_for_three_mod_same_value(mocker):
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 3
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
# m.return_value = 1560
d = Eiger()
d.dacs.vrf[:] = 1500
calls = [call('vrf', 0, 1500), call('vrf', 1, 1500), call('vrf', 2, 1500)]
m.assert_has_calls(calls)
assert m.call_count == 3
def test_set_vrf_for_four_mod_different_value(mocker):
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 4
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
# m.return_value = 1560
d = Eiger()
d.dacs.vrf = [1500, 1600, 1800, 1502]
calls = [call('vrf', 0, 1500),
call('vrf', 1, 1600),
call('vrf', 2, 1800),
call('vrf', 3, 1502)]
m.assert_has_calls(calls)
assert m.call_count == 4
def test_set_vrf_for_four_mod_different_value_slice(mocker):
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 4
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
# m.return_value = 1560
d = Eiger()
d.dacs.vrf[:] = [1500, 1600, 1800, 1502]
calls = [call('vrf', 0, 1500),
call('vrf', 1, 1600),
call('vrf', 2, 1800),
call('vrf', 3, 1502)]
m.assert_has_calls(calls)
assert m.call_count == 4
def test_set_vcp_single_call(mocker):
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 2
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
# m.return_value = 1560
d = Eiger()
d.dacs.vcp[1] = 1637
m.assert_called_once_with('vcp', 1, 1637)
def test_iterate_on_index_call_vcn(mocker):
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 10
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
# m.return_value = 1560
d = Eiger()
d.dacs.vcn[0,3,8] = 1532
calls = [call('vcn', 0, 1532),
call('vcn', 3, 1532),
call('vcn', 8, 1532)]
m.assert_has_calls(calls)
assert m.call_count == 3
def test_set_dac_from_element_in_numpy_array(mocker):
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 2
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
d = Eiger()
vrf = np.array((1600,1700,1800))
d.dacs.vrf = vrf[0]
calls = [call('vrf', 0, 1600),
call('vrf', 1, 1600),]
m.assert_has_calls(calls)
assert m.call_count == 2
def test_set_dac_from_element_in_numpy_array_using_slice(mocker):
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 2
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
d = Eiger()
vrf = np.array((1600,1700,1800))
d.dacs.vrf[:] = vrf[0]
calls = [call('vrf', 0, 1600),
call('vrf', 1, 1600),]
m.assert_has_calls(calls)
assert m.call_count == 2
def test_set_eiger_default(mocker):
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 2
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
# m.return_value = 1560
d = Eiger()
d.dacs.set_default()
calls = [call('vsvp', 0, 0),
call('vsvp', 1, 0),
call('vtr', 0, 2500),
call('vtr', 1, 2500),
call('vrf', 0, 3300),
call('vrf', 1, 3300),
call('vrs', 0, 1400),
call('vrs', 1, 1400),
call('vsvn', 0, 4000),
call('vsvn', 1, 4000),
call('vtgstv', 0, 2556),
call('vtgstv', 1, 2556),
call('vcmp_ll', 0, 1500),
call('vcmp_ll', 1, 1500),
call('vcmp_lr', 0, 1500),
call('vcmp_lr', 1, 1500),
call('vcall', 0, 4000),
call('vcall', 1, 4000),
call('vcmp_rl', 0, 1500),
call('vcmp_rl', 1, 1500),
call('rxb_rb', 0, 1100),
call('rxb_rb', 1, 1100),
call('rxb_lb', 0, 1100),
call('rxb_lb', 1, 1100),
call('vcmp_rr', 0, 1500),
call('vcmp_rr', 1, 1500),
call('vcp', 0, 200),
call('vcp', 1, 200),
call('vcn', 0, 2000),
call('vcn', 1, 2000),
call('vis', 0, 1550),
call('vis', 1, 1550),
call('iodelay', 0, 660),
call('iodelay', 1, 660)]
m.assert_has_calls(calls)
assert m.call_count == 17*2
def test_set_eiger_set_from_array_call_count(mocker):
import numpy as np
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 3
m = mocker.patch.object(DetectorApi, 'setDac', autospec=True)
# m.return_value = 1560
d = Eiger()
d.dacs.set_from_array( np.zeros((17,3)))
assert m.call_count == 17*3
def test_get_fpga_temp(mocker):
m2= mocker.patch.object(DetectorApi, 'getNumberOfDetectors', autospec=True)
m2.return_value = 2
m = mocker.patch.object(DetectorApi, 'getAdc', autospec=True)
m.return_value = 34253
d = Eiger()
t = d.temp.fpga[:]
assert t == [34.253, 34.253]

View File

@ -1,489 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Testing parameters and methods of the Detector class using mocks
"""
from unittest.mock import Mock
import pytest
from pytest_mock import mocker
@pytest.fixture
def d():
from sls_detector import Eiger
return Eiger()
def test_acq_call(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.acq')
d.acq()
m.assert_called_once_with()
def test_busy_call(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getAcquiringFlag')
m.return_value = False
assert d.busy == False
def test_assign_to_detector_type(d):
with pytest.raises(AttributeError):
d.detector_type = 'Eiger'
def test_det_type(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getDetectorType')
m.return_value = 'Eiger'
assert d.detector_type == 'Eiger'
def test_set_dynamic_range_4(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 4
m.assert_called_with(4)
def test_set_dynamic_range_8(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 8
m.assert_called_with(8)
def test_set_dynamic_range_16(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 16
m.assert_called_with(16)
def test_set_dynamic_range_32(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 32
m.assert_called_with(32)
def test_set_dynamic_range_raises_exception(d, mocker):
mocker.patch('_slsdet.DetectorApi.setDynamicRange')
with pytest.raises(ValueError):
d.dynamic_range = 17
def test_get_dynamic_range_32(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getDynamicRange')
m.return_value = 32
dr = d.dynamic_range
assert dr == 32
def test_eiger_matrix_reset(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getCounterBit')
m.return_value = True
assert d.eiger_matrix_reset == True
def test_set_eiger_matrix_reset(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setCounterBit')
d.eiger_matrix_reset = True
m.assert_called_once_with(True)
def test_get_exposure_time(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getExposureTime')
m.return_value = 100000000
assert d.exposure_time == 0.1
def test_set_exposure_time(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setExposureTime')
d.exposure_time = 1.5
m.assert_called_once_with(1500000000)
def test_set_exposure_time_less_than_zero(d, mocker):
mocker.patch('_slsdet.DetectorApi.setExposureTime')
with pytest.raises(ValueError):
d.exposure_time = -7
def test_get_file_index(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getFileIndex')
m.return_value = 8
assert d.file_index == 8
def test_set_file_index(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setFileIndex')
d.file_index = 9
m.assert_called_with(9)
def test_set_file_index_raises_on_neg(d, mocker):
mocker.patch('_slsdet.DetectorApi.setFileIndex')
with pytest.raises(ValueError):
d.file_index = -9
def test_get_file_name(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getFileName')
d.file_name
m.assert_called_once_with()
def test_set_file_name(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setFileName')
d.file_name = 'hej'
m.assert_called_once_with('hej')
def test_get_file_path(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getFilePath')
d.file_path
m.assert_called_once_with()
def test_set_file_path_when_path_exists(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setFilePath')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.exists')
mock_os.return_value = True
d.file_path = '/path/to/something/'
m.assert_called_once_with('/path/to/something/')
def test_set_file_path_raises_when_not_exists(d, mocker):
mocker.patch('_slsdet.DetectorApi.setFilePath')
mock_os = mocker.patch('os.path.exists')
mock_os.return_value = False
with pytest.raises(FileNotFoundError):
d.file_path = '/path/to/something/'
def test_get_file_write(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getFileWrite')
m.return_value = False
assert d.file_write == False
def test_set_file_write(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setFileWrite')
d.file_write = True
m.assert_called_once_with(True)
def test_get_firmware_version(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getFirmwareVersion')
m.return_value = 20
assert d.firmware_version == 20
def test_cannot_set_fw_version(d):
with pytest.raises(AttributeError):
d.firmware_version = 20
def test_get_high_voltage_call_signature(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getDac')
d.high_voltage
m.assert_called_once_with('highvoltage', -1)
def test_get_high_voltage(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getDac')
m.return_value = 80
assert d.high_voltage == 80
#self._api.setDac('highvoltage', -1, voltage)
def test_set_high_voltage(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setDac')
d.high_voltage = 80
m.assert_called_once_with('highvoltage', -1, 80)
def test_decode_hostname_two_names(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getHostname')
m.return_value = 'beb059+beb048+'
assert d.hostname == ['beb059', 'beb048']
def test_decode_hostname_four_names(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getHostname')
m.return_value = 'beb059+beb048+beb120+beb153+'
assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
def test_decode_hostname_blank(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getHostname')
m.return_value = ''
assert d.hostname == []
def test_get_image_size_gives_correct_size(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getImageSize')
m.return_value = (512,1024)
im_size = d.image_size
assert im_size.rows == 512
assert im_size.cols == 1024
def test_load_config(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = True
d.load_config('/path/to/my/file.config')
m.assert_called_once_with('/path/to/my/file.config')
def test_load_config_raises_when_file_is_not_found(d, mocker):
mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = False
with pytest.raises(FileNotFoundError):
d.load_config('/path/to/my/file.config')
def test_load_parameters(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.readParametersFile')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = True
d.load_parameters('/path/to/my/file.par')
m.assert_called_once_with('/path/to/my/file.par')
def test_load_parameters_raises_when_file_is_not_found(d, mocker):
mocker.patch('_slsdet.DetectorApi.readParametersFile')
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = False
with pytest.raises(FileNotFoundError):
d.load_parameters('/path/to/my/file.par')
#getDetectorGeometry
def test_get_module_geometry_gives_correct_size(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
m.return_value = (13,7)
g = d.module_geometry
assert g.vertical == 7
assert g.horizontal == 13
def test_get_module_geometry_access(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
m.return_value = (12,3)
assert d.module_geometry[0] == 12
assert d.module_geometry[1] == 3
assert d.module_geometry.vertical == 3
assert d.module_geometry.horizontal == 12
def test_get_n_frames(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getNumberOfFrames')
m.return_value = 3
assert d.n_frames == 3
def test_set_n_frames(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
d.n_frames = 9
m.assert_called_once_with(9)
def test_set_n_frames_raises_on_neg(d, mocker):
mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
with pytest.raises(ValueError):
d.n_frames = -1
def test_set_n_frames_raises_on_zero(d, mocker):
mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
with pytest.raises(ValueError):
d.n_frames = 0
def test_get_n_modules(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
m.return_value = 12
assert d.n_modules == 12
def test_get_period_time(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getPeriod')
m.return_value = 130000000
assert d.period == 0.13
def test_set_period_time(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setPeriod')
d.period = 1.953
m.assert_called_once_with(1953000000)
def test_set_period_time_less_than_zero(d, mocker):
mocker.patch('_slsdet.DetectorApi.setPeriod')
with pytest.raises(ValueError):
d.period = -7
def test_pulse_chip_call(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.pulseChip')
d.pulse_chip(15)
m.assert_called_once_with(15)
def test_pulse_chip_call_minus_one(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.pulseChip')
d.pulse_chip(-1)
m.assert_called_once_with(-1)
def test_pulse_chip_asserts_on_smaller_than_minus_one(d, mocker):
mocker.patch('_slsdet.DetectorApi.pulseChip')
with pytest.raises(ValueError):
d.pulse_chip(-3)
#--------------------------------------------------------------------subexptime
def test_get_sub_exposure_time(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getSubExposureTime')
m.return_value = 2370000
assert d.sub_exposure_time == 0.00237
def test_set_sub_exposure_time(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
d.sub_exposure_time = 0.002
m.assert_called_once_with(2000000)
def test_set_sub_exposure_time_raises_on_zero(d, mocker):
mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
with pytest.raises(ValueError):
d.sub_exposure_time = 0
#-------------------------------------------------------------Rate correction
def test_get_rate_correction(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getRateCorrection')
m.return_value = [132,129]
assert d.rate_correction == [132,129]
def test_set_rate_correction(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
mock_n.return_value = 3
d.rate_correction = [123,90,50]
m.assert_called_once_with([123,90,50])
def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
mocker.patch('_slsdet.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
mock_n.return_value = 4
with pytest.raises(ValueError):
d.rate_correction = [123,90,50]
#----------------------------------------------------------------Readout clock
def test_get_readout_clock_0(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 0
assert d.readout_clock == 'Full Speed'
def test_get_readout_clock_1(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 1
assert d.readout_clock == 'Half Speed'
def test_get_readout_clock_2(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 2
assert d.readout_clock == 'Quarter Speed'
def test_get_readout_clock_3(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 3
assert d.readout_clock == 'Super Slow Speed'
def test_set_readout_clock_0(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Full Speed'
m.assert_called_once_with(0)
def test_set_readout_clock_1(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Half Speed'
m.assert_called_once_with(1)
def test_set_readout_clock_2(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Quarter Speed'
m.assert_called_once_with(2)
def test_set_readout_clock_3(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Super Slow Speed'
m.assert_called_once_with(3)
#----------------------------------------------------------------rx_zmqstream
def test_get_rx_zmqstream(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getRxDataStreamStatus')
m.return_value = False
assert d.rx_zmqstream == False
def test_set_rx_zmqstream(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setRxDataStreamStatus')
d.rx_zmqstream = True
m.assert_called_once_with(True)
def test_get_rx_zmqip(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
d.rx_zmqip
m.assert_called_once_with('rx_zmqip')
def test_get_rx_zmqport_call(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
d.rx_zmqport
m.assert_called_once_with('rx_zmqport')
def test_get_rx_zmqport_decode(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
m.return_value = '30001+30003+'
assert d.rx_zmqport == [30001, 30002, 30003, 30004]
def test_get_rx_zmqport_empty(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
m.return_value = ''
assert d.rx_zmqport == []
#--------------------------------------------------------------------status
def test_status_call(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getRunStatus')
d.status
m.assert_called_once_with()
def test_start_acq_call(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
d.start_acq()
m.assert_called_once_with()
def test_stop_acq_call(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.stopAcquisition')
d.stop_acq()
m.assert_called_once_with()
#--------------------------------------------------------------------subexptime
def test_get_sub_exposure_time(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getSubExposureTime')
m.return_value = 2370000
assert d.sub_exposure_time == 0.00237
def test_set_sub_exposure_time(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
d.sub_exposure_time = 0.002
m.assert_called_once_with(2000000)
def test_set_sub_exposure_time_raises_on_zero(d, mocker):
mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
with pytest.raises(ValueError):
d.sub_exposure_time = 0
#------------------------------------------------------------------timing mode
def test_get_timing_mode(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getTimingMode')
d.timing_mode
m.assert_called_once_with()
def test_set_timing_mode(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setTimingMode')
d.timing_mode = 'auto'
m.assert_called_once_with('auto')
#----------------------------------------------------------------vthreshold
def test_get_vthreshold(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getDac')
d.vthreshold
m.assert_called_once_with('vthreshold', -1)
def test_set_vthreshold(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setDac')
d.vthreshold = 1675
m.assert_called_once_with('vthreshold', -1, 1675)
#----------------------------------------------------------------trimbits
def test_get_trimbits(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.getAllTrimbits')
d.trimbits
m.assert_called_once_with()
def test_set_trimbits(d, mocker):
m = mocker.patch('_slsdet.DetectorApi.setAllTrimbits')
d.trimbits = 15
m.assert_called_once_with(15)
def test_set_trimbits_raises_outside_range(d, mocker):
mocker.patch('_slsdet.DetectorApi.setAllTrimbits')
with pytest.raises(ValueError):
d.trimbits = 69
with pytest.raises(ValueError):
d.trimbits = -5

View File

@ -1,489 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Testing the Detector python class by mocking calls.
Should only be used when there is functionality in
the detector.py file.
An example is converting a mask to a list of set bits.
"""
from unittest.mock import Mock
import pytest
from pytest_mock import mocker
import sys
sys.path.append('/home/l_frojdh/slsdetectorgrup/sls_detector')
import _slsdet
from sls_detector.errors import DetectorValueError, DetectorError
from sls_detector.utils import all_equal, element_if_equal
@pytest.fixture
def d():
from sls_detector import Detector
return Detector()
def test_length(d, mocker):
m = mocker.patch('sls_detector.Detector.size')
m.return_value = 5
assert(len(d) == 5)
def test_counters_single(d, mocker):
m = mocker.patch('sls_detector.Detector.getCounterMask')
m.return_value = [7]
assert(d.counters == [0,1,2])
def test_counters_multi(d, mocker):
m = mocker.patch('sls_detector.Detector.getCounterMask')
m.return_value = [7, 9]
assert(d.counters == [[0,1,2],[0,3]])
def test_set_counters_single(d, mocker):
m = mocker.patch('sls_detector.Detector.setCounterMask')
d.counters = [0,2]
m.assert_called_once_with(5)
# def test_busy_call(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getAcquiringFlag')
# m.return_value = False
# assert d.busy == False
# def test_set_busy(d):
# d.busy = True
# assert d.busy == True
# assert d._api.getAcquiringFlag() == True
# d.busy = False
# assert d.busy == False
# assert d._api.getAcquiringFlag() == False
# def test_error_mask(d):
# d._api.setErrorMask(1)
# assert d.error_mask == 1
# d.clear_errors()
# def test_error_handling(d):
# with pytest.raises(DetectorError):
# d._provoke_error()
# def test_assign_to_detector_type(d):
# with pytest.raises(AttributeError):
# d.detector_type = 'Eiger'
# def test_det_type(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDetectorType')
# m.return_value = 'Eiger'
# assert d.detector_type == 'Eiger'
# def test_get_exposure_time(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getExposureTime')
# m.return_value = 100000000
# assert d.exposure_time == 0.1
# def test_set_exposure_time(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setExposureTime')
# d.exposure_time = 1.5
# m.assert_called_once_with(1500000000)
# def test_set_exposure_time_less_than_zero(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setExposureTime')
# with pytest.raises(DetectorValueError):
# d.exposure_time = -7
# def test_get_file_index(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getFileIndex')
# m.return_value = 8
# assert d.file_index == 8
# def test_set_file_index(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setFileIndex')
# d.file_index = 9
# m.assert_called_with(9)
# def file_index_with_no_detector(d):
# assert d.file_index == -100
# def dr_with_no_detector(d):
# assert d.dynamic_range == -100
# def test_set_file_index_raises_on_neg(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setFileIndex')
# with pytest.raises(ValueError):
# d.file_index = -9
# def test_get_file_name(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getFileName')
# d.file_name
# m.assert_called_once_with()
# def test_set_file_name(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setFileName')
# d.file_name = 'hej'
# m.assert_called_once_with('hej')
# def test_get_file_path(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getFilePath')
# d.file_path
# m.assert_called_once_with()
# def test_set_file_path_when_path_exists(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setFilePath')
# #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.exists')
# mock_os.return_value = True
# d.file_path = '/path/to/something/'
# m.assert_called_once_with('/path/to/something/')
# def test_set_file_path_raises_when_not_exists(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setFilePath')
# mock_os = mocker.patch('os.path.exists')
# mock_os.return_value = False
# with pytest.raises(FileNotFoundError):
# d.file_path = '/path/to/something/'
# def test_get_file_write(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getFileWrite')
# m.return_value = False
# assert d.file_write == False
# def test_set_file_write(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setFileWrite')
# d.file_write = True
# m.assert_called_once_with(True)
# def test_get_firmware_version(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getFirmwareVersion')
# m.return_value = 20
# assert d.firmware_version == 20
# def test_cannot_set_fw_version(d):
# with pytest.raises(AttributeError):
# d.firmware_version = 20
# def test_get_high_voltage_call_signature(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDac')
# d.high_voltage
# m.assert_called_once_with('highvoltage', -1)
# def test_get_high_voltage(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDac')
# m.return_value = 80
# assert d.high_voltage == 80
# #self._api.setDac('highvoltage', -1, voltage)
# def test_set_high_voltage(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setDac')
# d.high_voltage = 80
# m.assert_called_once_with('highvoltage', -1, 80)
# def test_decode_hostname_two_names(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getHostname')
# m.return_value = 'beb059+beb048+'
# assert d.hostname == ['beb059', 'beb048']
# def test_decode_hostname_four_names(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getHostname')
# m.return_value = 'beb059+beb048+beb120+beb153+'
# assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
# def test_decode_hostname_blank(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getHostname')
# m.return_value = ''
# assert d.hostname == []
# def test_get_image_size_gives_correct_size(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getImageSize')
# m.return_value = (512,1024)
# im_size = d.image_size
# assert im_size.rows == 512
# assert im_size.cols == 1024
# def test_load_config(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
# #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = True
# d.load_config('/path/to/my/file.config')
# m.assert_called_once_with('/path/to/my/file.config')
# def test_load_config_raises_when_file_is_not_found(d, mocker):
# mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
# mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = False
# with pytest.raises(FileNotFoundError):
# d.load_config('/path/to/my/file.config')
# def test_load_parameters(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.readParametersFile')
# #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = True
# d.load_parameters('/path/to/my/file.par')
# m.assert_called_once_with('/path/to/my/file.par')
# def test_load_parameters_raises_when_file_is_not_found(d, mocker):
# mocker.patch('_slsdet.DetectorApi.readParametersFile')
# mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = False
# with pytest.raises(FileNotFoundError):
# d.load_parameters('/path/to/my/file.par')
# #getDetectorGeometry
# def test_get_module_geometry_gives_correct_size(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
# m.return_value = (13,7)
# g = d.module_geometry
# assert g.vertical == 7
# assert g.horizontal == 13
# def test_get_module_geometry_access(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
# m.return_value = (12,3)
# assert d.module_geometry[0] == 12
# assert d.module_geometry[1] == 3
# assert d.module_geometry.vertical == 3
# assert d.module_geometry.horizontal == 12
# def test_module_geometry_without_detectors(d):
# t = d.module_geometry
# assert t.horizontal == 0
# assert t.vertical == 0
# def test_get_n_frames(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNumberOfFrames')
# m.return_value = 3
# assert d.n_frames == 3
# def test_set_n_frames(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# d.n_frames = 9
# m.assert_called_once_with(9)
# def test_nframes_without_detector(d):
# assert d.n_frames == -100
# def test_set_n_frames_raises_on_neg(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# with pytest.raises(DetectorValueError):
# d.n_frames = -1
# def test_set_n_frames_raises_on_zero(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# with pytest.raises(DetectorValueError):
# d.n_frames = 0
# def test_n_cycles_without_detector(d):
# assert d.n_cycles == -100
# def test_set_n_cycles_raises_on_zero(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setCycles')
# with pytest.raises(DetectorValueError):
# d.n_cycles = 0
# def test_set_n_cycles(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setCycles')
# d.n_cycles = 56
# m.assert_called_once_with(56)
# def test_n_measurements_without_detector(d):
# assert d.n_measurements == -100
# def test_set_n_measurements_raises_on_zero(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
# with pytest.raises(DetectorValueError):
# d.n_measurements = 0
# def test_set_n_measurements(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
# d.n_measurements = 560
# m.assert_called_once_with(560)
# def test_get_n_modules_no_detector(d):
# assert d.n_modules == 0
# def test_get_n_modules(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# m.return_value = 12
# assert d.n_modules == 12
# def test_get_period_time(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getPeriod')
# m.return_value = 130000000
# assert d.period == 0.13
# def test_set_period_time(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setPeriod')
# d.period = 1.953
# m.assert_called_once_with(1953000000)
# def test_set_period_time_less_than_zero(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setPeriod')
# with pytest.raises(ValueError):
# d.period = -7
# def test_get_online(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getOnline')
# d.online
# m.assert_called_once_with()
# def test_set_online(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setOnline')
# d.online = True
# m.assert_called_once_with(True)
# def test_last_client_ip_no_detector(d):
# assert d.last_client_ip == ''
# def test_last_cliten_ip_call(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getLastClientIP')
# d.last_client_ip
# m.assert_called_once_with()
# #-------------------------------------------------------------Rate correction
# def test_get_rate_correction(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getRateCorrection')
# m.return_value = [132,129]
# assert d.rate_correction == [132,129]
# def test_set_rate_correction(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# mock_n.return_value = 3
# d.rate_correction = [123,90,50]
# m.assert_called_once_with([123,90,50])
# def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
# mocker.patch('_slsdet.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# mock_n.return_value = 4
# with pytest.raises(ValueError):
# d.rate_correction = [123,90,50]
# #----------------------------------------------------------------Readout clock
# def test_get_readout_clock_0(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 0
# assert d.readout_clock == 'Full Speed'
# def test_get_readout_clock_1(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 1
# assert d.readout_clock == 'Half Speed'
# def test_get_readout_clock_2(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 2
# assert d.readout_clock == 'Quarter Speed'
# def test_get_readout_clock_3(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 3
# assert d.readout_clock == 'Super Slow Speed'
# def test_set_readout_clock_0(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Full Speed'
# m.assert_called_once_with(0)
# def test_set_readout_clock_1(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Half Speed'
# m.assert_called_once_with(1)
# def test_set_readout_clock_2(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Quarter Speed'
# m.assert_called_once_with(2)
# def test_set_readout_clock_3(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Super Slow Speed'
# m.assert_called_once_with(3)
# #----------------------------------------------------------------rx_zmqstream
# def test_get_rx_zmqstream(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getRxDataStreamStatus')
# m.return_value = False
# assert d.rx_zmqstream == False
# def test_set_rx_zmqstream(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setRxDataStreamStatus')
# d.rx_zmqstream = True
# m.assert_called_once_with(True)
# def test_get_rx_zmqip(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# d.rx_zmqip
# m.assert_called_once_with('rx_zmqip')
# def test_get_rx_zmqport_call(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# d.rx_zmqport
# m.assert_called_once_with('rx_zmqport')
# def test_get_rx_zmqport_decode(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# m.return_value = ['30001', '30003']
# assert d.rx_zmqport == [30001, 30003]
# def test_get_rx_zmqport_empty(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# m.return_value = ''
# assert d.rx_zmqport == []
# #--------------------------------------------------------------------status
# def test_status_call(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getRunStatus')
# d.status
# m.assert_called_once_with()
# def test_start_detecor(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
# d.start_detector()
# m.assert_called_once_with()
# def test_stop_acq_call(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.stopAcquisition')
# d.stop_detector()
# m.assert_called_once_with()
# #------------------------------------------------------------------timing mode
# def test_get_timing_mode(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getTimingMode')
# d.timing_mode
# m.assert_called_once_with()
# def test_set_timing_mode(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setTimingMode')
# d.timing_mode = 'auto'
# m.assert_called_once_with('auto')
# #----------------------------------------------------------------vthreshold
# def test_get_vthreshold(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.getDac')
# d.vthreshold
# m.assert_called_once_with('vthreshold', -1)
# def test_set_vthreshold(d, mocker):
# m = mocker.patch('_slsdet.DetectorApi.setDac')
# d.vthreshold = 1675
# m.assert_called_once_with('vthreshold', -1, 1675)

View File

@ -1,76 +0,0 @@
import pytest
from sls_detector.detector_property import DetectorProperty
class Holder:
"""
This class does nothing except hold values
for testing of the DetectorProperty class
"""
def __init__(self, N):
self.values = [i for i in range(N)]
def get(self, i):
return self.values[i]
def set(self, i,v):
self.values[i] = v
def nmod(self):
return len(self.values)
@pytest.fixture
def p():
h = Holder(5)
return DetectorProperty(h.get, h.set, h.nmod, 'prop')
def test_initialization():
def getf(i):
return 5
def setf():
return
def nmod():
return 3
name = 'a property'
p = DetectorProperty(getf, setf, nmod, name)
assert p.get == getf
assert p.set == setf
assert p.get_nmod == nmod
assert p.__name__ == name
def test_get_single_value(p):
assert p[2] == 2
def test_get_all_values(p):
assert p[:] == [0, 1, 2, 3, 4]
def test_get_values_by_iterable(p):
vals = p[1,3]
assert vals == [1,3]
def test_set_single_value(p):
p[2] = 7
assert p[:] == [0,1,7,3,4]
def test_set_all(p):
p[:] = 10
assert p[:] == [10,10,10,10,10]
def test_set_all_by_list(p):
p[:] = [7,8,9,10,11]
assert p[:] == [7,8,9,10,11]
def test_set_all_bool(p):
p[:] = True
assert p[:] == [True]*5
def test_set_by_iter(p):
keys = [2,4]
vals = [18,23]
p[keys] = vals
assert p[:] == [0,1,18,3,23]
def test_set_by_iter_single_val(p):
keys = [2,4]
val = 9
p[keys] = val
assert p[:] == [0,1,9,3,9]
def test_print_values(p):
assert repr(p) == 'prop: [0, 1, 2, 3, 4]'

View File

@ -6,8 +6,11 @@ Testing functions from utils.py
import pytest import pytest
from slsdet.utils import * from slsdet.utils import *
from slsdet import IpAddr, MacAddr
import datetime as dt import datetime as dt
import pathlib import pathlib
from pathlib import Path
def test_iterable(): def test_iterable():
assert is_iterable(5) == False assert is_iterable(5) == False
@ -15,74 +18,80 @@ def test_iterable():
assert is_iterable([]) == True assert is_iterable([]) == True
assert is_iterable(5.9) == False assert is_iterable(5.9) == False
def test_reduce_time_to_single_value_from_list(): def test_reduce_time_to_single_value_from_list():
t = 3*[dt.timedelta(seconds = 1)] t = 3 * [dt.timedelta(seconds=1)]
assert reduce_time(t) == 1 assert reduce_time(t) == 1
def test_reduce_time_to_single_value_from_list_of_lists(): def test_reduce_time_to_single_value_from_list_of_lists():
t = 3*[dt.timedelta(seconds = 3.3)] t = 3 * [dt.timedelta(seconds=3.3)]
tt = 5*t tt = 5 * t
assert reduce_time(tt) == 3.3 assert reduce_time(tt) == 3.3
def test_reduce_time_when_sublist_is_different(): def test_reduce_time_when_sublist_is_different():
t = [dt.timedelta(seconds = 1), dt.timedelta(seconds = 2), dt.timedelta(seconds = 1)] t = [
dt.timedelta(seconds=1),
dt.timedelta(seconds=2),
dt.timedelta(seconds=1)
]
tt = [t for i in range(4)] tt = [t for i in range(4)]
assert reduce_time(tt) == [1,2,1] assert reduce_time(tt) == [1, 2, 1]
def test_convert_zero(): def test_convert_zero():
assert eiger_register_to_time(0) == 0 assert eiger_register_to_time(0) == 0
def test_convert_smallest_unit(): def test_convert_smallest_unit():
assert pytest.approx(eiger_register_to_time(0b1000), 1e-9) == 1e-8 assert pytest.approx(eiger_register_to_time(0b1000), 1e-9) == 1e-8
def test_convert_second_smallest_unit(): def test_convert_second_smallest_unit():
assert pytest.approx(eiger_register_to_time(0b10000), 1e-9) == 2e-8 assert pytest.approx(eiger_register_to_time(0b10000), 1e-9) == 2e-8
def test_convert_one_ms_using_exponent(): def test_convert_one_ms_using_exponent():
assert pytest.approx(eiger_register_to_time(0b1101), 1e-9) == 1e-3 assert pytest.approx(eiger_register_to_time(0b1101), 1e-9) == 1e-3
def test_convert_five_seconds(): def test_convert_five_seconds():
assert pytest.approx(eiger_register_to_time(0b1001110001000101), 1e-9) == 5.0 assert pytest.approx(eiger_register_to_time(0b1001110001000101),
1e-9) == 5.0
def test_all_equal_int(): def test_all_equal_int():
assert all_equal([5,5]) == True assert all_equal([5, 5]) == True
def test_all_equal_fails(): def test_all_equal_fails():
assert all_equal([5,6]) == False assert all_equal([5, 6]) == False
def test_all_equal_tuple(): def test_all_equal_tuple():
assert all_equal(('a', 'a', 'a')) == True assert all_equal(('a', 'a', 'a')) == True
def test_all_equal_str(): def test_all_equal_str():
assert all_equal('aaa') == True assert all_equal('aaa') == True
def test_all_equal_str_fails(): def test_all_equal_str_fails():
assert all_equal('aaab') == False assert all_equal('aaab') == False
def test_element_if_equal_int(): def test_element_if_equal_int():
assert element_if_equal([5,5]) == 5 assert element_if_equal([5, 5]) == 5
def test_element_if_equal_str(): def test_element_if_equal_str():
assert element_if_equal('hhh') == 'h' assert element_if_equal('hhh') == 'h'
def test_element_if_equal_int_fails(): def test_element_if_equal_int_fails():
assert element_if_equal([5, 6, 7]) == [5, 6, 7] assert element_if_equal([5, 6, 7]) == [5, 6, 7]
def test_get_set_bits():
assert(get_set_bits(0) == [])
assert get_set_bits(7) == [0, 1, 2]
def test_list_to_mask():
assert(list_to_bitmask([0,1,2]) == 7)
assert(list_to_bitmask([]) == 0)
assert(list_to_bitmask([0]) == 1)
assert(list_to_bitmask([1]) == 2)
assert(list_to_bitmask([3]) == 8)
assert(list_to_bitmask([1,1,1]) == 2)
def test_make_timedelta_from_double(): def test_make_timedelta_from_double():
t = 1.7 t = 1.7
@ -90,6 +99,7 @@ def test_make_timedelta_from_double():
assert t == r.total_seconds() assert t == r.total_seconds()
assert r == dt.timedelta(seconds=t) assert r == dt.timedelta(seconds=t)
def test_make_timedelta_from_timedelta(): def test_make_timedelta_from_timedelta():
t = dt.timedelta(minutes=1) t = dt.timedelta(minutes=1)
r = make_timedelta(t) r = make_timedelta(t)
@ -105,6 +115,7 @@ def test_make_string_path_from_Path():
assert r == p.as_posix() assert r == p.as_posix()
assert r == pathstr assert r == pathstr
def test_make_string_path_expand_user(): def test_make_string_path_expand_user():
pathstr = "~/tmp/virtual.config" pathstr = "~/tmp/virtual.config"
home = pathlib.Path.home() home = pathlib.Path.home()
@ -114,3 +125,199 @@ def test_make_string_path_expand_user():
rs = make_string_path(pathstr) rs = make_string_path(pathstr)
assert rp == expanded_str assert rp == expanded_str
assert rs == expanded_str assert rs == expanded_str
def test_lhex_passing_list():
values = [0, 1, 2, 3, 4]
assert lhex(values) == ["0x0", "0x1", "0x2", "0x3", "0x4"]
def test_lhex_emty_list():
assert lhex([]) == []
def test_make_ip_from_dict():
arg = {0: 0, 1: "192.168.1.1"}
res = make_ip(arg)
assert res == {0: IpAddr("0.0.0.0"), 1: IpAddr("192.168.1.1")}
assert res[0].str() == "0.0.0.0"
assert res[1].str() == "192.168.1.1"
def test_make_ip_from_str():
ip = "192.168.1.1"
assert make_ip(ip).str() == ip
def test_make_ip_from_list():
arg = ["192.168.1.1", "192.168.1.2", "127.0.0.1"]
assert make_ip(arg) == [IpAddr(a) for a in arg]
def test_make_ip_from_tuple():
arg = ("127.0.0.1")
assert make_ip(arg) == (IpAddr(arg))
def test_make_mac_from_dict():
arg = {6: "84:a9:aa:24:32:88", 12: "84:a9:3e:24:32:aa"}
res = make_mac(arg)
assert res == {
6: MacAddr("84:a9:aa:24:32:88"),
12: MacAddr("84:a9:3e:24:32:aa")
}
assert res[6].str() == "84:a9:aa:24:32:88"
assert res[12].str() == "84:a9:3e:24:32:aa"
def test_make_mac_from_str():
mac = "84:a9:aa:24:32:88"
assert make_mac(mac) == MacAddr(mac)
assert make_mac(mac).str() == mac
def test_make_mac_from_list():
arg = ["84:a9:aa:24:32:88", "84:a9:3e:24:32:aa"]
assert make_mac(arg) == [MacAddr(a) for a in arg]
def test_make_mac_from_tuple():
arg = ("84:a9:aa:24:32:88", "84:a9:3e:24:32:aa")
assert make_mac(arg) == (MacAddr("84:a9:aa:24:32:88"),
MacAddr("84:a9:3e:24:32:aa"))
def test_make_path_from_str():
assert make_path("/") == Path("/")
assert make_path("/home") == Path("/home")
def test_make_path_from_list():
arg = ["/", "/home", "/another/path"]
assert make_path(arg) == [Path(p) for p in arg]
def test_make_string_path_from_str():
arg = "/path/to/something"
assert make_string_path(arg) == arg
def test_make_string_path_from_Path():
s = "/path/to/something"
arg = Path(s)
assert make_string_path(arg) == s
def test_make_string_path_from_list_of_Path_and_string():
args = ["/path/to", Path("/something/something"), "else/"]
assert make_string_path(args) == [
"/path/to", "/something/something", "else/"
]
def test_make_string_path_from_Path_list():
s = "/path/to/something"
arg = [Path(s)]
assert make_string_path(arg) == [s]
def test_make_string_path_from_dict():
args = {0: "/path/to/something", 1: Path("/something/else")}
assert make_string_path(args) == {
0: "/path/to/something",
1: "/something/else"
}
class DummyClass:
def __init__(self):
self.args = []
def call(self, *args):
"""Normal type call in slsdet where list of detectors is passed"""
self.args.append(args)
def call_int_id(self, *args):
"""call where det_is is an int"""
*args, i = args
if isinstance(i, list):
raise TypeError
self.args.append((*args, i))
def test_set_using_dict_single_int():
c = DummyClass()
set_using_dict(c.call, 5)
assert c.args == [(5, )]
def test_set_using_dict_two_ints():
c = DummyClass()
set_using_dict(c.call, 1, 2)
assert c.args == [(1, 2)]
def test_set_using_dict_passing_dict():
c = DummyClass()
set_using_dict(c.call, {0: 5, 8: 3, 9: 7})
assert len(c.args) == 3
assert c.args == [(5, [0]), (3, [8]), (7, [9])]
def test_set_using_dict_calling_int_id():
c = DummyClass()
set_using_dict(c.call_int_id, {0: "hej", 8: 3, 9: 7})
assert len(c.args) == 3
assert c.args == [("hej", 0), (3, 8), (7, 9)]
def test_set_using_dict_pass_multiple_args():
c = DummyClass()
set_using_dict(c.call, "a", "b", "c")
assert len(c.args) == 1
assert c.args == [("a", "b", "c")]
def test_set_using_dict_passing_dict_with_multiple_args():
c = DummyClass()
set_using_dict(c.call, {0: ("a", "b"), 1: ("c", "d")})
assert c.args == [("a", "b", [0]), ("c", "d", [1])]
def test_get_set_bits():
assert (get_set_bits(0) == [])
assert get_set_bits(7) == [0, 1, 2]
def test_list_to_mask():
assert (list_to_bitmask([0, 1, 2]) == 7)
assert (list_to_bitmask([]) == 0)
assert (list_to_bitmask([0]) == 1)
assert (list_to_bitmask([1]) == 2)
assert (list_to_bitmask([3]) == 8)
assert (list_to_bitmask([1, 1, 1]) == 2)
def test_make_bitmask_from_list_of_int():
assert make_bitmask([0, 1, 2]) == 0b111
assert make_bitmask([0, 1, 7]) == 0b10000011
assert make_bitmask([1, 1, 1]) == 0b10
def test_make_bitmask_from_dict():
assert make_bitmask({0: [0, 1], 1: [0, 1, 7]}) == {0: 0b11, 1: 0b10000011}
def test_add_argument_before():
assert add_argument_before("a", 5) == ("a", 5)
assert add_argument_before(3, ("a", "b")) == (3, "a", "b")
def test_add_argument_before_dict():
assert add_argument_before(5, {0: "a"}) == ({0: (5, "a")},)
assert add_argument_before(0, {0: 1}) == ({0: (0, 1)},)
assert add_argument_before(5, {0: ("a", "b")}) == ({0: (5, "a", "b")}, )
assert add_argument_before(6, "hej") == (6, "hej")
assert add_argument_before("another", {9: "string"}) == ({
9: ("another", "string")
}, )

View File

@ -161,6 +161,21 @@ void qTabMeasurement::ShowTriggerDelay() {
// show burst, burstperiod, not trigger or delay // show burst, burstperiod, not trigger or delay
showTrigger = false; showTrigger = false;
} }
// frame and period are disabled for cont trigger in g2
bool enableFramePeriod = true;
if ((comboBurstMode->currentIndex() ==
slsDetectorDefs::CONTINUOUS_INTERNAL ||
comboBurstMode->currentIndex() ==
slsDetectorDefs::CONTINUOUS_EXTERNAL) &&
(comboTimingMode->currentIndex() == TRIGGER)) {
enableFramePeriod = false;
}
lblNumFrames->setEnabled(enableFramePeriod);
spinNumFrames->setEnabled(enableFramePeriod);
lblPeriod->setEnabled(enableFramePeriod);
spinPeriod->setEnabled(enableFramePeriod);
comboPeriodUnit->setEnabled(enableFramePeriod);
} }
if (showTrigger) { if (showTrigger) {

View File

@ -151,7 +151,7 @@ void Beb_Beb(int id) {
Beb_bit_mode = 4; Beb_bit_mode = 4;
// ll_beb = &ll_beb_local; // ll_beb = &ll_beb_local;
// Local_LocalLinkInterface1(ll_beb,XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR); // Local_LocalLinkInterface(ll_beb,XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR);
// Beb_SetByteOrder(); // Beb_SetByteOrder();
} }

View File

@ -2,6 +2,7 @@
#include "Beb.h" #include "Beb.h"
#include "FebRegisterDefs.h" #include "FebRegisterDefs.h"
#include "clogger.h" #include "clogger.h"
#include "sharedMemory.h"
#include "slsDetectorServer_defs.h" #include "slsDetectorServer_defs.h"
#include <errno.h> #include <errno.h>
@ -752,16 +753,24 @@ int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag) {
return 1; return 1;
} }
int Feb_Control_WaitForFinishedFlag(int sleep_time_us) { int Feb_Control_WaitForFinishedFlag(int sleep_time_us, int tempLock) {
int is_running = Feb_Control_AcquisitionInProgress(); int is_running = Feb_Control_AcquisitionInProgress();
// unlock for stop server
if (tempLock) {
sharedMemory_unlockLocalLink();
}
int check_error = 0; int check_error = 0;
// it will break out if it is idle or if check_error is more than 5 times // it will break out if it is idle or if check_error is more than 5 times
while (is_running != STATUS_IDLE) { while (is_running != STATUS_IDLE) {
usleep(sleep_time_us); usleep(sleep_time_us);
if (tempLock) {
sharedMemory_lockLocalLink();
}
is_running = Feb_Control_AcquisitionInProgress(); is_running = Feb_Control_AcquisitionInProgress();
if (tempLock) {
sharedMemory_unlockLocalLink();
}
// check error only 5 times (ensuring it is not something that happens // check error only 5 times (ensuring it is not something that happens
// sometimes) // sometimes)
if (is_running == STATUS_ERROR) { if (is_running == STATUS_ERROR) {
@ -772,6 +781,10 @@ int Feb_Control_WaitForFinishedFlag(int sleep_time_us) {
else else
check_error = 0; check_error = 0;
} }
// lock it again to be unlocked later
if (tempLock) {
sharedMemory_lockLocalLink();
}
return is_running; return is_running;
} }
@ -800,7 +813,7 @@ int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us) {
return 0; return 0;
} }
} }
return Feb_Control_WaitForFinishedFlag(sleep_time_us); return Feb_Control_WaitForFinishedFlag(sleep_time_us, 0);
} }
int Feb_Control_Reset() { int Feb_Control_Reset() {
@ -816,7 +829,7 @@ int Feb_Control_Reset() {
return 0; return 0;
} }
} }
return Feb_Control_WaitForFinishedFlag(5000); return Feb_Control_WaitForFinishedFlag(5000, 0);
} }
int Feb_Control_ResetChipCompletely() { int Feb_Control_ResetChipCompletely() {

View File

@ -42,7 +42,7 @@ unsigned int *Feb_Control_GetTrimbits();
int Feb_Control_AcquisitionInProgress(); int Feb_Control_AcquisitionInProgress();
int Feb_Control_AcquisitionStartedBit(); int Feb_Control_AcquisitionStartedBit();
int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag); int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag);
int Feb_Control_WaitForFinishedFlag(int sleep_time_us); int Feb_Control_WaitForFinishedFlag(int sleep_time_us, int tempLock);
int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, int Feb_Control_GetDAQStatusRegister(unsigned int dst_address,
unsigned int *ret_status); unsigned int *ret_status);
int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us); int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us);

View File

@ -37,7 +37,7 @@ void Feb_Interface_FebInterface() {
malloc((Feb_Interface_recv_buffer_size + 1) * sizeof(unsigned int)); malloc((Feb_Interface_recv_buffer_size + 1) * sizeof(unsigned int));
Feb_Interface_recv_data = &Feb_Interface_recv_data_raw[1]; Feb_Interface_recv_data = &Feb_Interface_recv_data_raw[1];
Local_LocalLinkInterface1( Local_LocalLinkInterface(
ll, XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR); ll, XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
} }

View File

@ -6,7 +6,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <unistd.h> #include <unistd.h>
void Local_LocalLinkInterface1(struct LocalLinkInterface *ll, void Local_LocalLinkInterface(struct LocalLinkInterface *ll,
unsigned int ll_fifo_badr) { unsigned int ll_fifo_badr) {
LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n")); LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n"));
ll->ll_fifo_base = 0; ll->ll_fifo_base = 0;
@ -20,16 +20,12 @@ void Local_LocalLinkInterface1(struct LocalLinkInterface *ll,
("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr)); ("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr));
} }
void Local_LocalLinkInterface(struct LocalLinkInterface *ll) {
LOG(logDEBUG1, ("Initializing new memory\n"));
}
int Local_Init(struct LocalLinkInterface *ll, unsigned int ll_fifo_badr) { int Local_Init(struct LocalLinkInterface *ll, unsigned int ll_fifo_badr) {
int fd; int fd;
void *plb_ll_fifo_ptr; void *plb_ll_fifo_ptr;
if ((fd = open("/dev/mem", O_RDWR)) < 0) { if ((fd = open("/dev/mem", O_RDWR)) < 0) {
fprintf(stderr, "Could not open /dev/mem\n"); LOG(logERROR, ("Could not open /dev/mem for local link\n"));
return 0; return 0;
} }
@ -38,7 +34,7 @@ int Local_Init(struct LocalLinkInterface *ll, unsigned int ll_fifo_badr) {
close(fd); close(fd);
if (plb_ll_fifo_ptr == MAP_FAILED) { if (plb_ll_fifo_ptr == MAP_FAILED) {
perror("mmap"); LOG(logERROR, ("mmap error for local link\n"));
return 0; return 0;
} }
@ -78,6 +74,7 @@ unsigned int Local_StatusVector(struct LocalLinkInterface *ll) {
int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len, int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
void *buffer) { void *buffer) {
// note: buffer must be word (4 byte) aligned // note: buffer must be word (4 byte) aligned
// frame_len in byte // frame_len in byte
int vacancy = 0; int vacancy = 0;
@ -87,8 +84,9 @@ int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
unsigned int fifo_ctrl; unsigned int fifo_ctrl;
xfs_u32 status; xfs_u32 status;
if (buffer_len < 1) if (buffer_len < 1) {
return -1; return -1;
}
last_word = (buffer_len - 1) / 4; last_word = (buffer_len - 1) / 4;
word_ptr = (unsigned int *)buffer; word_ptr = (unsigned int *)buffer;
@ -131,11 +129,13 @@ int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
word_ptr[words_send++]); word_ptr[words_send++]);
} }
} }
return buffer_len; return buffer_len;
} }
int Local_Read(struct LocalLinkInterface *ll, unsigned int buffer_len, int Local_Read(struct LocalLinkInterface *ll, unsigned int buffer_len,
void *buffer) { void *buffer) {
static unsigned int buffer_ptr = 0; static unsigned int buffer_ptr = 0;
// note: buffer must be word (4 byte) aligned // note: buffer must be word (4 byte) aligned
// frame_len in byte // frame_len in byte
@ -184,7 +184,6 @@ int Local_Read(struct LocalLinkInterface *ll, unsigned int buffer_len,
} }
} }
} while (!(status & PLB_LL_FIFO_STATUS_EMPTY)); } while (!(status & PLB_LL_FIFO_STATUS_EMPTY));
return 0; return 0;
} }

View File

@ -11,7 +11,7 @@ int Local_Init(struct LocalLinkInterface *ll, unsigned int ll_fifo_badr);
int Local_Reset1(struct LocalLinkInterface *ll, unsigned int rst_mask); int Local_Reset1(struct LocalLinkInterface *ll, unsigned int rst_mask);
int Local_ctrl_reg_write_mask(struct LocalLinkInterface *ll, unsigned int mask, int Local_ctrl_reg_write_mask(struct LocalLinkInterface *ll, unsigned int mask,
unsigned int val); unsigned int val);
void Local_LocalLinkInterface1(struct LocalLinkInterface *ll, void Local_LocalLinkInterface(struct LocalLinkInterface *ll,
unsigned int ll_fifo_badr); unsigned int ll_fifo_badr);
unsigned int Local_StatusVector(struct LocalLinkInterface *ll); unsigned int Local_StatusVector(struct LocalLinkInterface *ll);
int Local_Reset(struct LocalLinkInterface *ll); int Local_Reset(struct LocalLinkInterface *ll);
@ -21,4 +21,3 @@ int Local_Read(struct LocalLinkInterface *ll, unsigned int buffer_len,
void *buffer); void *buffer);
int Local_Test(struct LocalLinkInterface *ll, unsigned int buffer_len, int Local_Test(struct LocalLinkInterface *ll, unsigned int buffer_len,
void *buffer); void *buffer);
void Local_LocalLinkInterface(struct LocalLinkInterface *ll);

View File

@ -324,6 +324,7 @@ void initControlServer() {
readDetectorNumber(); readDetectorNumber();
getModuleConfiguration(); getModuleConfiguration();
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
Feb_Control_SetMasterVariable(master); Feb_Control_SetMasterVariable(master);
Feb_Interface_FebInterface(); Feb_Interface_FebInterface();
Feb_Control_FebControl(); Feb_Control_FebControl();
@ -333,6 +334,7 @@ void initControlServer() {
sprintf(initErrorMessage, "Could not intitalize feb control\n"); sprintf(initErrorMessage, "Could not intitalize feb control\n");
LOG(logERROR, (initErrorMessage)); LOG(logERROR, (initErrorMessage));
initCheckDone = 1; initCheckDone = 1;
sharedMemory_unlockLocalLink();
return; return;
} }
// master of 9M, check high voltage serial communication to blackfin // master of 9M, check high voltage serial communication to blackfin
@ -344,9 +346,11 @@ void initControlServer() {
"Could not intitalize feb control serial communication\n"); "Could not intitalize feb control serial communication\n");
LOG(logERROR, (initErrorMessage)); LOG(logERROR, (initErrorMessage));
initCheckDone = 1; initCheckDone = 1;
sharedMemory_unlockLocalLink();
return; return;
} }
} }
sharedMemory_unlockLocalLink();
LOG(logDEBUG1, ("Control server: FEB Initialization done\n")); LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
Beb_SetTopVariable(top); Beb_SetTopVariable(top);
Beb_Beb(detid); Beb_Beb(detid);
@ -373,11 +377,13 @@ void initStopServer() {
// exit(-1); // exit(-1);
readDetectorNumber(); readDetectorNumber();
getModuleConfiguration(); getModuleConfiguration();
sharedMemory_lockLocalLink();
Feb_Control_SetMasterVariable(master); Feb_Control_SetMasterVariable(master);
Feb_Interface_FebInterface(); Feb_Interface_FebInterface();
Feb_Control_FebControl(); Feb_Control_FebControl();
// same addresses for top and bottom // same addresses for top and bottom
Feb_Control_Init(master, normal, getDetectorNumber()); Feb_Control_Init(master, normal, getDetectorNumber());
sharedMemory_unlockLocalLink();
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n")); LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
#endif #endif
// client first connect (from shm) will activate // client first connect (from shm) will activate
@ -493,14 +499,17 @@ int readConfigFile() {
top, line); top, line);
break; break;
} }
sharedMemory_lockLocalLink();
if (!Feb_Control_SetTop(ind, 1, 1)) { if (!Feb_Control_SetTop(ind, 1, 1)) {
sprintf( sprintf(
initErrorMessage, initErrorMessage,
"Could not overwrite top to %d in Feb from on-board server " "Could not overwrite top to %d in Feb from on-board server "
"config file. Line:[%s].\n", "config file. Line:[%s].\n",
top, line); top, line);
sharedMemory_unlockLocalLink();
break; break;
} }
sharedMemory_unlockLocalLink();
// validate change // validate change
int actual_top = -1, temp = -1, temp2 = -1; int actual_top = -1, temp = -1, temp2 = -1;
Beb_GetModuleConfiguration(&temp, &actual_top, &temp2); Beb_GetModuleConfiguration(&temp, &actual_top, &temp2);
@ -533,14 +542,17 @@ int readConfigFile() {
master, line); master, line);
break; break;
} }
sharedMemory_lockLocalLink();
if (!Feb_Control_SetMaster(ind)) { if (!Feb_Control_SetMaster(ind)) {
sprintf(initErrorMessage, sprintf(initErrorMessage,
"Could not overwrite master to %d in Feb from on-board " "Could not overwrite master to %d in Feb from on-board "
"server " "server "
"config file. Line:[%s].\n", "config file. Line:[%s].\n",
master, line); master, line);
sharedMemory_unlockLocalLink();
break; break;
} }
sharedMemory_unlockLocalLink();
// validate change // validate change
int actual_master = -1, temp = -1, temp2 = -1; int actual_master = -1, temp = -1, temp2 = -1;
Beb_GetModuleConfiguration(&actual_master, &temp, &temp2); Beb_GetModuleConfiguration(&actual_master, &temp, &temp2);
@ -550,7 +562,9 @@ int readConfigFile() {
actual_master); actual_master);
break; break;
} }
sharedMemory_lockLocalLink();
Feb_Control_SetMasterVariable(master); Feb_Control_SetMasterVariable(master);
sharedMemory_unlockLocalLink();
#endif #endif
} }
@ -592,13 +606,16 @@ void resetToHardwareSettings() {
LOG(logERROR, ("%s\n\n", initErrorMessage)); LOG(logERROR, ("%s\n\n", initErrorMessage));
return; return;
} }
sharedMemory_lockLocalLink();
if (!Feb_Control_SetTop(TOP_HARDWARE, 1, 1)) { if (!Feb_Control_SetTop(TOP_HARDWARE, 1, 1)) {
initError = FAIL; initError = FAIL;
strcpy(initErrorMessage, strcpy(initErrorMessage,
"Could not reset Top flag to Feb hardware settings.\n"); "Could not reset Top flag to Feb hardware settings.\n");
LOG(logERROR, ("%s\n\n", initErrorMessage)); LOG(logERROR, ("%s\n\n", initErrorMessage));
sharedMemory_unlockLocalLink();
return; return;
} }
sharedMemory_unlockLocalLink();
int temp = -1, temp2 = -1; int temp = -1, temp2 = -1;
Beb_GetModuleConfiguration(&temp, &top, &temp2); Beb_GetModuleConfiguration(&temp, &top, &temp2);
Beb_SetTopVariable(top); Beb_SetTopVariable(top);
@ -612,16 +629,21 @@ void resetToHardwareSettings() {
LOG(logERROR, ("%s\n\n", initErrorMessage)); LOG(logERROR, ("%s\n\n", initErrorMessage));
return; return;
} }
sharedMemory_lockLocalLink();
if (!Feb_Control_SetMaster(TOP_HARDWARE)) { if (!Feb_Control_SetMaster(TOP_HARDWARE)) {
initError = FAIL; initError = FAIL;
strcpy(initErrorMessage, strcpy(initErrorMessage,
"Could not reset Master flag to Feb hardware settings.\n"); "Could not reset Master flag to Feb hardware settings.\n");
LOG(logERROR, ("%s\n\n", initErrorMessage)); LOG(logERROR, ("%s\n\n", initErrorMessage));
sharedMemory_unlockLocalLink();
return; return;
} }
sharedMemory_unlockLocalLink();
int temp = -1, temp2 = -1; int temp = -1, temp2 = -1;
Beb_GetModuleConfiguration(&master, &temp, &temp2); Beb_GetModuleConfiguration(&master, &temp, &temp2);
sharedMemory_lockLocalLink();
Feb_Control_SetMasterVariable(master); Feb_Control_SetMasterVariable(master);
sharedMemory_unlockLocalLink();
} }
#endif #endif
} }
@ -699,16 +721,21 @@ void setupDetector() {
int enable[2] = {DEFAULT_EXT_GATING_ENABLE, DEFAULT_EXT_GATING_POLARITY}; int enable[2] = {DEFAULT_EXT_GATING_ENABLE, DEFAULT_EXT_GATING_POLARITY};
setExternalGating(enable); // disable external gating setExternalGating(enable); // disable external gating
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
Feb_Control_SetInTestModeVariable(DEFAULT_TEST_MODE); Feb_Control_SetInTestModeVariable(DEFAULT_TEST_MODE);
sharedMemory_unlockLocalLink();
#endif #endif
setHighVoltage(DEFAULT_HIGH_VOLTAGE); setHighVoltage(DEFAULT_HIGH_VOLTAGE);
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (!Feb_Control_CheckSetup()) { if (!Feb_Control_CheckSetup()) {
initError = FAIL; initError = FAIL;
sprintf(initErrorMessage, "Could not pass feb control setup checks\n"); sprintf(initErrorMessage, "Could not pass feb control setup checks\n");
LOG(logERROR, (initErrorMessage)); LOG(logERROR, (initErrorMessage));
sharedMemory_unlockLocalLink();
return; return;
} }
sharedMemory_unlockLocalLink();
#endif #endif
// force top or master if in config file // force top or master if in config file
if (readConfigFile() == FAIL) { if (readConfigFile() == FAIL) {
@ -732,9 +759,12 @@ int writeRegister(uint32_t offset, uint32_t data) {
#ifdef VIRTUAL #ifdef VIRTUAL
return OK; return OK;
#else #else
sharedMemory_lockLocalLink();
if (!Feb_Control_WriteRegister(offset, data)) { if (!Feb_Control_WriteRegister(offset, data)) {
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
sharedMemory_unlockLocalLink();
return OK; return OK;
#endif #endif
} }
@ -743,9 +773,12 @@ int readRegister(uint32_t offset, uint32_t *retval) {
#ifdef VIRTUAL #ifdef VIRTUAL
return OK; return OK;
#else #else
sharedMemory_lockLocalLink();
if (!Feb_Control_ReadRegister(offset, retval)) { if (!Feb_Control_ReadRegister(offset, retval)) {
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
sharedMemory_unlockLocalLink();
return OK; return OK;
#endif #endif
} }
@ -757,21 +790,26 @@ int setDynamicRange(int dr) {
if (dr > 0) { if (dr > 0) {
LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr)); LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (Feb_Control_SetDynamicRange(dr)) { if (Feb_Control_SetDynamicRange(dr)) {
on_dst = 0; on_dst = 0;
for (int i = 0; i < 32; ++i) for (int i = 0; i < 32; ++i)
dst_requested[i] = 0; // clear dst requested dst_requested[i] = 0; // clear dst requested
if (!Beb_SetUpTransferParameters(dr)) { if (!Beb_SetUpTransferParameters(dr)) {
LOG(logERROR, ("Could not set bit mode in the back end\n")); LOG(logERROR, ("Could not set bit mode in the back end\n"));
sharedMemory_unlockLocalLink();
return eiger_dynamicrange; return eiger_dynamicrange;
} }
} }
sharedMemory_unlockLocalLink();
#endif #endif
eiger_dynamicrange = dr; eiger_dynamicrange = dr;
} }
// getting dr // getting dr
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
eiger_dynamicrange = Feb_Control_GetDynamicRange(); eiger_dynamicrange = Feb_Control_GetDynamicRange();
sharedMemory_unlockLocalLink();
#endif #endif
return eiger_dynamicrange; return eiger_dynamicrange;
} }
@ -781,9 +819,12 @@ int setDynamicRange(int dr) {
int setParallelMode(int mode) { int setParallelMode(int mode) {
mode = (mode == 0 ? E_NON_PARALLEL : E_PARALLEL); mode = (mode == 0 ? E_NON_PARALLEL : E_PARALLEL);
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (!Feb_Control_SetReadoutMode(mode)) { if (!Feb_Control_SetReadoutMode(mode)) {
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
sharedMemory_unlockLocalLink();
#endif #endif
eiger_parallelmode = mode; eiger_parallelmode = mode;
return OK; return OK;
@ -828,6 +869,7 @@ void setNumFrames(int64_t val) {
if (val > 0) { if (val > 0) {
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val)); LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (Feb_Control_SetNExposures((unsigned int)val * eiger_ntriggers)) { if (Feb_Control_SetNExposures((unsigned int)val * eiger_ntriggers)) {
eiger_nexposures = val; eiger_nexposures = val;
on_dst = 0; on_dst = 0;
@ -836,6 +878,7 @@ void setNumFrames(int64_t val) {
ndsts_in_use = 1; ndsts_in_use = 1;
nimages_per_request = eiger_nexposures * eiger_ntriggers; nimages_per_request = eiger_nexposures * eiger_ntriggers;
} }
sharedMemory_unlockLocalLink();
#else #else
eiger_nexposures = val; eiger_nexposures = val;
nimages_per_request = eiger_nexposures * eiger_ntriggers; nimages_per_request = eiger_nexposures * eiger_ntriggers;
@ -849,6 +892,7 @@ void setNumTriggers(int64_t val) {
if (val > 0) { if (val > 0) {
LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val)); LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (Feb_Control_SetNExposures((unsigned int)val * eiger_nexposures)) { if (Feb_Control_SetNExposures((unsigned int)val * eiger_nexposures)) {
eiger_ntriggers = val; eiger_ntriggers = val;
on_dst = 0; on_dst = 0;
@ -856,6 +900,7 @@ void setNumTriggers(int64_t val) {
dst_requested[i] = 0; // clear dst requested dst_requested[i] = 0; // clear dst requested
nimages_per_request = eiger_nexposures * eiger_ntriggers; nimages_per_request = eiger_nexposures * eiger_ntriggers;
} }
sharedMemory_unlockLocalLink();
#else #else
eiger_ntriggers = val; eiger_ntriggers = val;
nimages_per_request = eiger_nexposures * eiger_ntriggers; nimages_per_request = eiger_nexposures * eiger_ntriggers;
@ -868,7 +913,9 @@ int64_t getNumTriggers() { return eiger_ntriggers; }
int setExpTime(int64_t val) { int setExpTime(int64_t val) {
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val)); LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
Feb_Control_SetExposureTime(val / (1E9)); Feb_Control_SetExposureTime(val / (1E9));
sharedMemory_unlockLocalLink();
#else #else
eiger_virtual_exptime = val; eiger_virtual_exptime = val;
#endif #endif
@ -877,7 +924,10 @@ int setExpTime(int64_t val) {
int64_t getExpTime() { int64_t getExpTime() {
#ifndef VIRTUAL #ifndef VIRTUAL
return (Feb_Control_GetExposureTime() * (1E9)); sharedMemory_lockLocalLink();
int64_t retval = (Feb_Control_GetExposureTime() * (1E9));
sharedMemory_unlockLocalLink();
return retval;
#else #else
return eiger_virtual_exptime; return eiger_virtual_exptime;
#endif #endif
@ -886,7 +936,9 @@ int64_t getExpTime() {
int setPeriod(int64_t val) { int setPeriod(int64_t val) {
LOG(logINFO, ("Setting period %lld ns\n", (long long int)val)); LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
Feb_Control_SetExposurePeriod(val / (1E9)); Feb_Control_SetExposurePeriod(val / (1E9));
sharedMemory_unlockLocalLink();
#else #else
eiger_virtual_period = val; eiger_virtual_period = val;
#endif #endif
@ -895,7 +947,10 @@ int setPeriod(int64_t val) {
int64_t getPeriod() { int64_t getPeriod() {
#ifndef VIRTUAL #ifndef VIRTUAL
return (Feb_Control_GetExposurePeriod() * (1E9)); sharedMemory_lockLocalLink();
int64_t retval = (Feb_Control_GetExposurePeriod() * (1E9));
sharedMemory_unlockLocalLink();
return retval;
#else #else
return eiger_virtual_period; return eiger_virtual_period;
#endif #endif
@ -904,12 +959,14 @@ int64_t getPeriod() {
int setSubExpTime(int64_t val) { int setSubExpTime(int64_t val) {
LOG(logINFO, ("Setting subexptime %lld ns\n", (long long int)val)); LOG(logINFO, ("Setting subexptime %lld ns\n", (long long int)val));
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
// calculate subdeadtime before settings subexptime // calculate subdeadtime before settings subexptime
int64_t subdeadtime = int64_t subdeadtime =
Feb_Control_GetSubFramePeriod() - Feb_Control_GetSubFrameExposureTime(); Feb_Control_GetSubFramePeriod() - Feb_Control_GetSubFrameExposureTime();
Feb_Control_SetSubFrameExposureTime(val / 10); Feb_Control_SetSubFrameExposureTime(val / 10);
// set subperiod // set subperiod
Feb_Control_SetSubFramePeriod((val + subdeadtime) / 10); Feb_Control_SetSubFramePeriod((val + subdeadtime) / 10);
sharedMemory_unlockLocalLink();
#else #else
int64_t subdeadtime = int64_t subdeadtime =
eiger_virtual_subperiod * 10 - eiger_virtual_subexptime * 10; eiger_virtual_subperiod * 10 - eiger_virtual_subexptime * 10;
@ -921,7 +978,10 @@ int setSubExpTime(int64_t val) {
int64_t getSubExpTime() { int64_t getSubExpTime() {
#ifndef VIRTUAL #ifndef VIRTUAL
return (Feb_Control_GetSubFrameExposureTime()); sharedMemory_lockLocalLink();
int64_t retval = (Feb_Control_GetSubFrameExposureTime());
sharedMemory_unlockLocalLink();
return retval;
#else #else
return eiger_virtual_subexptime * 10; return eiger_virtual_subexptime * 10;
#endif #endif
@ -930,8 +990,10 @@ int64_t getSubExpTime() {
int setSubDeadTime(int64_t val) { int setSubDeadTime(int64_t val) {
LOG(logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val)); LOG(logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val));
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
// get subexptime // get subexptime
int64_t subexptime = Feb_Control_GetSubFrameExposureTime(); int64_t subexptime = Feb_Control_GetSubFrameExposureTime();
sharedMemory_unlockLocalLink();
#else #else
int64_t subexptime = eiger_virtual_subexptime * 10; int64_t subexptime = eiger_virtual_subexptime * 10;
#endif #endif
@ -942,7 +1004,9 @@ int setSubDeadTime(int64_t val) {
// calculate subperiod // calculate subperiod
val += subexptime; val += subexptime;
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
Feb_Control_SetSubFramePeriod(val / 10); Feb_Control_SetSubFramePeriod(val / 10);
sharedMemory_unlockLocalLink();
#else #else
eiger_virtual_subperiod = (val / 10); eiger_virtual_subperiod = (val / 10);
#endif #endif
@ -951,13 +1015,18 @@ int setSubDeadTime(int64_t val) {
int64_t getSubDeadTime() { int64_t getSubDeadTime() {
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
// get subexptime // get subexptime
int64_t subexptime = Feb_Control_GetSubFrameExposureTime(); int64_t subexptime = Feb_Control_GetSubFrameExposureTime();
sharedMemory_unlockLocalLink();
#else #else
int64_t subexptime = eiger_virtual_subexptime * 10; int64_t subexptime = eiger_virtual_subexptime * 10;
#endif #endif
#ifndef VIRTUAL #ifndef VIRTUAL
return (Feb_Control_GetSubFramePeriod() - subexptime); sharedMemory_lockLocalLink();
int64_t retval = (Feb_Control_GetSubFramePeriod() - subexptime);
sharedMemory_unlockLocalLink();
return retval;
#else #else
return (eiger_virtual_subperiod * 10 - subexptime); return (eiger_virtual_subperiod * 10 - subexptime);
#endif #endif
@ -967,7 +1036,10 @@ int64_t getMeasuredPeriod() {
#ifdef VIRTUAL #ifdef VIRTUAL
return 0; return 0;
#else #else
return Feb_Control_GetMeasuredPeriod(); sharedMemory_lockLocalLink();
int64_t retval = Feb_Control_GetMeasuredPeriod();
sharedMemory_unlockLocalLink();
return retval;
#endif #endif
} }
@ -975,7 +1047,10 @@ int64_t getMeasuredSubPeriod() {
#ifdef VIRTUAL #ifdef VIRTUAL
return 0; return 0;
#else #else
return Feb_Control_GetSubMeasuredPeriod(); sharedMemory_lockLocalLink();
int64_t retval = Feb_Control_GetSubMeasuredPeriod();
sharedMemory_unlockLocalLink();
return retval;
#endif #endif
} }
@ -1054,14 +1129,17 @@ int setModule(sls_detector_module myMod, char *mess) {
} }
// set trimbits // set trimbits
sharedMemory_lockLocalLink();
if (!Feb_Control_SetTrimbits(tt, top)) { if (!Feb_Control_SetTrimbits(tt, top)) {
sprintf(mess, "Could not set module. Could not set trimbits\n"); sprintf(mess, "Could not set module. Could not set trimbits\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
setSettings(UNDEFINED); setSettings(UNDEFINED);
LOG(logERROR, ("Settings has been changed to undefined (random " LOG(logERROR, ("Settings has been changed to undefined (random "
"trim file)\n")); "trim file)\n"));
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
sharedMemory_unlockLocalLink();
} }
#endif #endif
@ -1185,9 +1263,11 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
return; return;
} }
} }
sharedMemory_lockLocalLink();
if (Feb_Control_SetDAC(ind, dacval)) { if (Feb_Control_SetDAC(ind, dacval)) {
(detectorModules)->dacs[ind] = dacval; (detectorModules)->dacs[ind] = dacval;
} }
sharedMemory_unlockLocalLink();
#endif #endif
} }
@ -1233,19 +1313,23 @@ int getADC(enum ADCINDEX ind) {
return 0; return 0;
#else #else
int retval = -1; int retval = -1;
char tempnames[6][20] = {"FPGA EXT", "10GE", "DCDC", char *adc_names[] = {ADC_NAMES};
"SODL", "SODR", "FPGA"};
char cstore[255]; char cstore[255];
memset(cstore, 0, 255);
switch (ind) { switch (ind) {
case TEMP_FPGA: case TEMP_FPGA:
retval = getBebFPGATemp(); retval = getBebFPGATemp();
break; break;
case TEMP_FPGAFEBL: case TEMP_FPGAFEBL:
sharedMemory_lockLocalLink();
retval = Feb_Control_GetLeftFPGATemp(); retval = Feb_Control_GetLeftFPGATemp();
sharedMemory_unlockLocalLink();
break; break;
case TEMP_FPGAFEBR: case TEMP_FPGAFEBR:
sharedMemory_lockLocalLink();
retval = Feb_Control_GetRightFPGATemp(); retval = Feb_Control_GetRightFPGATemp();
sharedMemory_unlockLocalLink();
break; break;
case TEMP_FPGAEXT: case TEMP_FPGAEXT:
case TEMP_10GE: case TEMP_10GE:
@ -1264,7 +1348,7 @@ int getADC(enum ADCINDEX ind) {
} }
LOG(logINFO, LOG(logINFO,
("Temperature %s: %f°C\n", tempnames[ind], (double)retval / 1000.00)); ("Temperature %s: %f°C\n", adc_names[ind], (double)retval / 1000.00));
return retval; return retval;
#endif #endif
@ -1289,7 +1373,9 @@ int setHighVoltage(int val) {
// set // set
if (val != -1) { if (val != -1) {
eiger_theo_highvoltage = val; eiger_theo_highvoltage = val;
sharedMemory_lockLocalLink();
int ret = Feb_Control_SetHighVoltage(val); int ret = Feb_Control_SetHighVoltage(val);
sharedMemory_unlockLocalLink();
if (!ret) // could not set if (!ret) // could not set
return -2; return -2;
else if (ret == -1) // outside range else if (ret == -1) // outside range
@ -1297,10 +1383,13 @@ int setHighVoltage(int val) {
} }
// get // get
sharedMemory_lockLocalLink();
if (!Feb_Control_GetHighVoltage(&eiger_highvoltage)) { if (!Feb_Control_GetHighVoltage(&eiger_highvoltage)) {
LOG(logERROR, ("Could not read high voltage\n")); LOG(logERROR, ("Could not read high voltage\n"));
sharedMemory_unlockLocalLink();
return -3; return -3;
} }
sharedMemory_unlockLocalLink();
// tolerance of 5 // tolerance of 5
if (abs(eiger_theo_highvoltage - eiger_highvoltage) > if (abs(eiger_theo_highvoltage - eiger_highvoltage) >
@ -1339,9 +1428,14 @@ void setTiming(enum timingMode arg) {
} }
LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret)); LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
#ifndef VIRTUAL #ifndef VIRTUAL
if (Feb_Control_SetTriggerMode(ret)) sharedMemory_lockLocalLink();
#endif if (Feb_Control_SetTriggerMode(ret)) {
eiger_triggermode = ret; eiger_triggermode = ret;
}
sharedMemory_unlockLocalLink();
#else
eiger_triggermode = ret;
#endif
} }
enum timingMode getTiming() { enum timingMode getTiming() {
@ -1469,9 +1563,12 @@ int setQuad(int value) {
if (Beb_SetQuad(value) == FAIL) { if (Beb_SetQuad(value) == FAIL) {
return FAIL; return FAIL;
} }
sharedMemory_lockLocalLink();
if (!Feb_Control_SetQuad(value)) { if (!Feb_Control_SetQuad(value)) {
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
sharedMemory_unlockLocalLink();
#else #else
eiger_virtual_quad_mode = value; eiger_virtual_quad_mode = value;
#endif #endif
@ -1490,9 +1587,12 @@ int setInterruptSubframe(int value) {
if (value < 0) if (value < 0)
return FAIL; return FAIL;
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (!Feb_Control_SetInterruptSubframe(value)) { if (!Feb_Control_SetInterruptSubframe(value)) {
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
sharedMemory_unlockLocalLink();
#else #else
eiger_virtual_interrupt_subframe = value; eiger_virtual_interrupt_subframe = value;
#endif #endif
@ -1503,7 +1603,10 @@ int getInterruptSubframe() {
#ifdef VIRTUAL #ifdef VIRTUAL
return eiger_virtual_interrupt_subframe; return eiger_virtual_interrupt_subframe;
#else #else
return Feb_Control_GetInterruptSubframe(); sharedMemory_lockLocalLink();
int retval = Feb_Control_GetInterruptSubframe();
sharedMemory_unlockLocalLink();
return retval;
#endif #endif
} }
@ -1511,9 +1614,12 @@ int setReadNLines(int value) {
if (value < 0) if (value < 0)
return FAIL; return FAIL;
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (!Feb_Control_SetReadNLines(value)) { if (!Feb_Control_SetReadNLines(value)) {
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
sharedMemory_unlockLocalLink();
Beb_SetReadNLines(value); Beb_SetReadNLines(value);
#else #else
eiger_virtual_read_nlines = value; eiger_virtual_read_nlines = value;
@ -1525,7 +1631,10 @@ int getReadNLines() {
#ifdef VIRTUAL #ifdef VIRTUAL
return eiger_virtual_read_nlines; return eiger_virtual_read_nlines;
#else #else
return Feb_Control_GetReadNLines(); sharedMemory_lockLocalLink();
int retval = Feb_Control_GetReadNLines();
sharedMemory_unlockLocalLink();
return retval;
#endif #endif
} }
@ -1549,10 +1658,15 @@ int setClockDivider(enum CLKINDEX ind, int val) {
if (val >= 0) { if (val >= 0) {
LOG(logINFO, ("Setting Read out Speed: %d\n", val)); LOG(logINFO, ("Setting Read out Speed: %d\n", val));
#ifndef VIRTUAL #ifndef VIRTUAL
if (Feb_Control_SetReadoutSpeed(val)) sharedMemory_lockLocalLink();
#endif if (Feb_Control_SetReadoutSpeed(val)) {
eiger_readoutspeed = val; eiger_readoutspeed = val;
} }
sharedMemory_unlockLocalLink();
#else
eiger_readoutspeed = val;
#endif
}
return OK; return OK;
} }
@ -1568,10 +1682,15 @@ int setIODelay(int val) {
if (val != -1) { if (val != -1) {
LOG(logDEBUG1, ("Setting IO Delay: %d\n", val)); LOG(logDEBUG1, ("Setting IO Delay: %d\n", val));
#ifndef VIRTUAL #ifndef VIRTUAL
if (Feb_Control_SetIDelays(val)) sharedMemory_lockLocalLink();
#endif if (Feb_Control_SetIDelays(val)) {
eiger_iodelay = val; eiger_iodelay = val;
} }
sharedMemory_unlockLocalLink();
#else
eiger_iodelay = val;
#endif
}
return eiger_iodelay; return eiger_iodelay;
} }
@ -1581,36 +1700,53 @@ int setCounterBit(int val) {
#ifdef VIRTUAL #ifdef VIRTUAL
eiger_virtual_counter_bit = val; eiger_virtual_counter_bit = val;
#else #else
sharedMemory_lockLocalLink();
Feb_Control_Set_Counter_Bit(val); Feb_Control_Set_Counter_Bit(val);
sharedMemory_unlockLocalLink();
#endif #endif
} }
#ifdef VIRTUAL #ifdef VIRTUAL
return eiger_virtual_counter_bit; return eiger_virtual_counter_bit;
#else #else
return Feb_Control_Get_Counter_Bit(); sharedMemory_lockLocalLink();
int retval = Feb_Control_Get_Counter_Bit();
sharedMemory_unlockLocalLink();
return retval;
#endif #endif
} }
int pulsePixel(int n, int x, int y) { int pulsePixel(int n, int x, int y) {
#ifndef VIRTUAL #ifndef VIRTUAL
if (!Feb_Control_Pulse_Pixel(n, x, y)) sharedMemory_lockLocalLink();
if (!Feb_Control_Pulse_Pixel(n, x, y)) {
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
}
sharedMemory_unlockLocalLink();
#endif #endif
return OK; return OK;
} }
int pulsePixelNMove(int n, int x, int y) { int pulsePixelNMove(int n, int x, int y) {
#ifndef VIRTUAL #ifndef VIRTUAL
if (!Feb_Control_PulsePixelNMove(n, x, y)) sharedMemory_lockLocalLink();
if (!Feb_Control_PulsePixelNMove(n, x, y)) {
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
}
sharedMemory_unlockLocalLink();
#endif #endif
return OK; return OK;
} }
int pulseChip(int n) { int pulseChip(int n) {
#ifndef VIRTUAL #ifndef VIRTUAL
if (!Feb_Control_PulseChip(n)) sharedMemory_lockLocalLink();
if (!Feb_Control_PulseChip(n)) {
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
}
sharedMemory_unlockLocalLink();
#endif #endif
return OK; return OK;
} }
@ -1716,10 +1852,12 @@ int setRateCorrection(
return OK; return OK;
#else #else
sharedMemory_lockLocalLink();
// deactivating rate correction // deactivating rate correction
if (custom_tau_in_nsec == 0) { if (custom_tau_in_nsec == 0) {
Feb_Control_SetRateCorrectionVariable(0); Feb_Control_SetRateCorrectionVariable(0);
sharedMemory_unlockLocalLink();
return OK; return OK;
} }
@ -1758,6 +1896,7 @@ int setRateCorrection(
LOG(logERROR, LOG(logERROR,
("Rate correction failed. Deactivating rate correction\n")); ("Rate correction failed. Deactivating rate correction\n"));
Feb_Control_SetRateCorrectionVariable(0); Feb_Control_SetRateCorrectionVariable(0);
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
} }
@ -1766,6 +1905,7 @@ int setRateCorrection(
LOG(logINFO, ("Rate Correction Value set to %lld ns\n", LOG(logINFO, ("Rate Correction Value set to %lld ns\n",
(long long int)Feb_Control_Get_RateTable_Tau_in_nsec())); (long long int)Feb_Control_Get_RateTable_Tau_in_nsec()));
Feb_Control_PrintCorrectedValues(); Feb_Control_PrintCorrectedValues();
sharedMemory_unlockLocalLink();
return OK; return OK;
#endif #endif
@ -1775,7 +1915,10 @@ int getRateCorrectionEnable() {
#ifdef VIRTUAL #ifdef VIRTUAL
return eiger_virtual_ratecorrection_variable; return eiger_virtual_ratecorrection_variable;
#else #else
return Feb_Control_GetRateCorrectionVariable(); sharedMemory_lockLocalLink();
int retval = Feb_Control_GetRateCorrectionVariable();
sharedMemory_unlockLocalLink();
return retval;
#endif #endif
} }
@ -1792,7 +1935,9 @@ int64_t getCurrentTau() {
return 0; return 0;
} else { } else {
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
eiger_tau_ns = Feb_Control_Get_RateTable_Tau_in_nsec(); eiger_tau_ns = Feb_Control_Get_RateTable_Tau_in_nsec();
sharedMemory_unlockLocalLink();
#else #else
eiger_tau_ns = eiger_virtual_ratetable_tau_in_ns; eiger_tau_ns = eiger_virtual_ratetable_tau_in_ns;
#endif #endif
@ -1805,9 +1950,11 @@ void setExternalGating(int enable[]) {
// default: disable gating with positive polarity // default: disable gating with positive polarity
if (enable[0] >= 0 && enable[1] >= 0) { if (enable[0] >= 0 && enable[1] >= 0) {
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
Feb_Control_SetExternalEnableMode( Feb_Control_SetExternalEnableMode(
enable[0], enable[1]); // enable = 0 or 1, polarity = 0 or 1 , where enable[0], enable[1]); // enable = 0 or 1, polarity = 0 or 1 , where
// 1 is positive // 1 is positive
sharedMemory_unlockLocalLink();
#endif #endif
eiger_extgating = enable[0]; eiger_extgating = enable[0];
eiger_extgatingpolarity = enable[1]; eiger_extgatingpolarity = enable[1];
@ -1819,10 +1966,13 @@ void setExternalGating(int enable[]) {
int setAllTrimbits(int val) { int setAllTrimbits(int val) {
LOG(logINFO, ("Setting all trimbits to %d\n", val)); LOG(logINFO, ("Setting all trimbits to %d\n", val));
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (!Feb_Control_SaveAllTrimbitsTo(val, top)) { if (!Feb_Control_SaveAllTrimbitsTo(val, top)) {
LOG(logERROR, ("Could not set all trimbits\n")); LOG(logERROR, ("Could not set all trimbits\n"));
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
sharedMemory_unlockLocalLink();
#endif #endif
if (detectorModules) { if (detectorModules) {
for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) { for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
@ -1867,7 +2017,9 @@ int setActivate(int enable) {
if (!Beb_SetActivate(enable)) { if (!Beb_SetActivate(enable)) {
return FAIL; return FAIL;
} }
sharedMemory_lockLocalLink();
Feb_Control_activate(enable); Feb_Control_activate(enable);
sharedMemory_unlockLocalLink();
#endif #endif
if (enable) { if (enable) {
LOG(logINFOGREEN, ("Activated in %s Server!\n", LOG(logINFOGREEN, ("Activated in %s Server!\n",
@ -1970,9 +2122,11 @@ int setTransmissionDelayRight(int value) {
int prepareAcquisition() { int prepareAcquisition() {
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink();
LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n", LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",
Feb_Control_Get_Counter_Bit())); Feb_Control_Get_Counter_Bit()));
Feb_Control_PrepareForAcquisition(); Feb_Control_PrepareForAcquisition();
sharedMemory_unlockLocalLink();
#endif #endif
return OK; return OK;
} }
@ -2001,6 +2155,7 @@ int startStateMachine() {
LOG(logINFO, ("Virtual Acquisition started\n")); LOG(logINFO, ("Virtual Acquisition started\n"));
return OK; return OK;
#else #else
sharedMemory_lockLocalLink();
LOG(logINFO, ("Acquisition started bit toggled\n")); LOG(logINFO, ("Acquisition started bit toggled\n"));
int ret = OK, prev_flag; int ret = OK, prev_flag;
// get the DAQ toggle bit // get the DAQ toggle bit
@ -2017,10 +2172,12 @@ int startStateMachine() {
if (!Feb_Control_WaitForStartedFlag(5000, prev_flag)) { if (!Feb_Control_WaitForStartedFlag(5000, prev_flag)) {
LOG(logERROR, LOG(logERROR,
("Acquisition did not LOG(logERROR ouble reading register\n")); ("Acquisition did not LOG(logERROR ouble reading register\n"));
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
LOG(logINFOGREEN, ("Acquisition started\n")); LOG(logINFOGREEN, ("Acquisition started\n"));
} }
sharedMemory_unlockLocalLink();
return ret; return ret;
#endif #endif
@ -2223,11 +2380,14 @@ int stopStateMachine() {
LOG(logINFO, ("Stopped State Machine\n")); LOG(logINFO, ("Stopped State Machine\n"));
return OK; return OK;
#else #else
sharedMemory_lockLocalLink();
if ((Feb_Control_StopAcquisition() != STATUS_IDLE) || if ((Feb_Control_StopAcquisition() != STATUS_IDLE) ||
(!Beb_StopAcquisition())) { (!Beb_StopAcquisition())) {
LOG(logERROR, ("failed to stop acquisition\n")); LOG(logERROR, ("failed to stop acquisition\n"));
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
} }
sharedMemory_unlockLocalLink();
// ensure all have same starting frame numbers // ensure all have same starting frame numbers
uint64_t retval = 0; uint64_t retval = 0;
@ -2242,8 +2402,12 @@ int softwareTrigger() {
#ifdef VIRTUAL #ifdef VIRTUAL
return OK; return OK;
#else #else
if (!Feb_Control_SoftwareTrigger()) sharedMemory_lockLocalLink();
if (!Feb_Control_SoftwareTrigger()) {
sharedMemory_unlockLocalLink();
return FAIL; return FAIL;
}
sharedMemory_unlockLocalLink();
return OK; return OK;
#endif #endif
} }
@ -2294,7 +2458,9 @@ enum runStatus getRunStatus() {
LOG(logINFOBLUE, ("Status: IDLE\n")); LOG(logINFOBLUE, ("Status: IDLE\n"));
return IDLE; return IDLE;
#else #else
sharedMemory_lockLocalLink();
int i = Feb_Control_AcquisitionInProgress(); int i = Feb_Control_AcquisitionInProgress();
sharedMemory_unlockLocalLink();
if (i == STATUS_ERROR) { if (i == STATUS_ERROR) {
LOG(logERROR, ("Status: ERROR reading status register\n")); LOG(logERROR, ("Status: ERROR reading status register\n"));
return ERROR; return ERROR;
@ -2325,11 +2491,14 @@ void readFrame(int *ret, char *mess) {
return; return;
#else #else
if (Feb_Control_WaitForFinishedFlag(5000) == STATUS_ERROR) { sharedMemory_lockLocalLink();
if (Feb_Control_WaitForFinishedFlag(5000, 1) == STATUS_ERROR) {
sharedMemory_unlockLocalLink();
LOG(logERROR, ("Waiting for finished flag\n")); LOG(logERROR, ("Waiting for finished flag\n"));
*ret = FAIL; *ret = FAIL;
return; return;
} }
sharedMemory_unlockLocalLink();
LOG(logINFOGREEN, ("Acquisition finished\n")); LOG(logINFOGREEN, ("Acquisition finished\n"));
// wait for detector to send // wait for detector to send

View File

@ -63,6 +63,10 @@ enum ADCINDEX {
TEMP_FPGAFEBL, TEMP_FPGAFEBL,
TEMP_FPGAFEBR TEMP_FPGAFEBR
}; };
#define ADC_NAMES \
"FPGA EXT", "10GE", "DCDC", "SODL", "SODR", "FPGA", "FPGA_FL", "FPGA_FR"
enum NETWORKINDEX { TXN_LEFT, TXN_RIGHT, TXN_FRAME, FLOWCTRL_10G }; enum NETWORKINDEX { TXN_LEFT, TXN_RIGHT, TXN_FRAME, FLOWCTRL_10G };
enum ROINDEX { E_PARALLEL, E_NON_PARALLEL }; enum ROINDEX { E_PARALLEL, E_NON_PARALLEL };
enum CLKINDEX { RUN_CLK, NUM_CLOCKS }; enum CLKINDEX { RUN_CLK, NUM_CLOCKS };
@ -130,7 +134,7 @@ enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define DAC_MAX_STEPS (4096) #define DAC_MAX_STEPS (4096)
#define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS \ #define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS \
(0x1FFFFFFF) // 29 bit register for max subframe exposure value (0x1FFFFFFF) // 29 bit register for max subframe exposure value
#define SLAVE_HIGH_VOLTAGE_READ_VAL (-999) #define SLAVE_HIGH_VOLTAGE_READ_VAL (-999)
#define HIGH_VOLTAGE_TOLERANCE (5) #define HIGH_VOLTAGE_TOLERANCE (5)

View File

@ -152,6 +152,10 @@
#define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC) #define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC) #define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC)
/* ASIC Exptime 64bit Register */
#define ASIC_CONT_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_ASIC)
#define ASIC_CONT_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_ASIC)
/* Packetizer -------------------------------------------------------------*/ /* Packetizer -------------------------------------------------------------*/
/* Packetizer Config Register */ /* Packetizer Config Register */

View File

@ -54,6 +54,8 @@ int vetoReference[NCHIP][NCHAN];
int vetoGainIndices[NCHIP][NCHAN]; int vetoGainIndices[NCHIP][NCHAN];
uint8_t adcConfiguration[NCHIP][NADC]; uint8_t adcConfiguration[NCHIP][NADC];
int burstMode = BURST_INTERNAL; int burstMode = BURST_INTERNAL;
int64_t numFramesReg = 1;
int64_t periodReg = 0;
int64_t numTriggersReg = 1; int64_t numTriggersReg = 1;
int64_t delayReg = 0; int64_t delayReg = 0;
int64_t numBurstsReg = 1; int64_t numBurstsReg = 1;
@ -377,6 +379,8 @@ void setupDetector() {
injectedChannelsOffset = 0; injectedChannelsOffset = 0;
injectedChannelsIncrement = 0; injectedChannelsIncrement = 0;
burstMode = BURST_INTERNAL; burstMode = BURST_INTERNAL;
numFramesReg = 1;
periodReg = 0;
numTriggersReg = 1; numTriggersReg = 1;
delayReg = 0; delayReg = 0;
numBurstsReg = 1; numBurstsReg = 1;
@ -818,12 +822,24 @@ int setDynamicRange(int dr) { return DYNAMIC_RANGE; }
/* parameters - timer */ /* parameters - timer */
void setNumFrames(int64_t val) { void setNumFrames(int64_t val) {
if (val > 0) { if (val > 0) {
numFramesReg = val;
// continuous // continuous
if (burstMode == CONTINUOUS_INTERNAL || if (burstMode == CONTINUOUS_INTERNAL ||
burstMode == CONTINUOUS_EXTERNAL) { burstMode == CONTINUOUS_EXTERNAL) {
LOG(logINFO, LOG(logINFO,
("Setting number of frames %lld [Continuous mode]\n", val)); ("Setting number of frames %lld [Continuous mode]\n", val));
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
LOG(logINFO,
("\tCont. Trigger mode (not writing to register)\n", val));
// #frames limited in cont trigger mode
}
// auto
else {
set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG); set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(val, ASIC_CONT_FRAMES_LSB_REG,
ASIC_CONT_FRAMES_MSB_REG);
}
} }
// burst // burst
else { else {
@ -841,6 +857,12 @@ void setNumFrames(int64_t val) {
int64_t getNumFrames() { int64_t getNumFrames() {
// continuous // continuous
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) { if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
// #frames limited in cont trigger mode
return numFramesReg;
}
// auto
return get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG); return get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
} }
// burst // burst
@ -852,25 +874,37 @@ int64_t getNumFrames() {
void setNumTriggers(int64_t val) { void setNumTriggers(int64_t val) {
if (val > 0) { if (val > 0) {
LOG(logINFO, ("Setting number of triggers %lld\n", val));
if (getTiming() == AUTO_TIMING) {
LOG(logINFO, ("\tNot trigger mode: not writing to register\n"));
numTriggersReg = val; numTriggersReg = val;
} else { LOG(logINFO, ("Setting number of triggers %lld\n", val));
// auto
if (getTiming() == AUTO_TIMING) {
LOG(logINFO, ("\tAuto mode (not writing to register)\n"));
}
// trigger
else {
set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG); set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
// continuous
if (burstMode == CONTINUOUS_INTERNAL ||
burstMode == CONTINUOUS_EXTERNAL) {
set64BitReg(val, ASIC_CONT_FRAMES_LSB_REG,
ASIC_CONT_FRAMES_MSB_REG);
}
} }
} }
} }
int64_t getNumTriggers() { int64_t getNumTriggers() {
// auto
if (getTiming() == AUTO_TIMING) { if (getTiming() == AUTO_TIMING) {
return numTriggersReg; return numTriggersReg;
} }
// trigger
return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG); return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
} }
void setNumBursts(int64_t val) { void setNumBursts(int64_t val) {
if (val > 0) { if (val > 0) {
numBurstsReg = val;
LOG(logINFO, ("Setting number of bursts %lld\n", val)); LOG(logINFO, ("Setting number of bursts %lld\n", val));
// burst and auto // burst and auto
if ((burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) && if ((burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) &&
@ -881,7 +915,6 @@ void setNumBursts(int64_t val) {
else { else {
LOG(logINFO, LOG(logINFO,
("\tNot (Burst and Auto mode): not writing to register\n")); ("\tNot (Burst and Auto mode): not writing to register\n"));
numBurstsReg = val;
} }
} }
} }
@ -928,14 +961,24 @@ int setPeriod(int64_t val) {
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) { if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
LOG(logINFO, ("Setting period %lld ns [Continuous mode]\n", val)); LOG(logINFO, ("Setting period %lld ns [Continuous mode]\n", val));
val *= (1E-9 * systemFrequency); val *= (1E-9 * systemFrequency);
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
LOG(logINFO,
("\tCont. Trigger mode (not writing to register)\n", val));
// #frames limited in cont trigger mode
}
// auto
else {
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG); set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
} }
}
// burst // burst
else { else {
LOG(logINFO, ("Setting period %lld ns [Burst mode]\n", val)); LOG(logINFO, ("Setting period %lld ns [Burst mode]\n", val));
val *= (1E-9 * systemFrequency); val *= (1E-9 * systemFrequency);
set64BitReg(val, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG); set64BitReg(val, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
} }
periodReg = val;
// validate for tolerance // validate for tolerance
int64_t retval = getPeriod(); int64_t retval = getPeriod();
val /= (1E-9 * systemFrequency); val /= (1E-9 * systemFrequency);
@ -948,6 +991,12 @@ int setPeriod(int64_t val) {
int64_t getPeriod() { int64_t getPeriod() {
// continuous // continuous
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) { if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
// #frames limited in cont trigger mode
return periodReg / (1E-9 * systemFrequency);
}
// auto
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG) / return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG) /
(1E-9 * systemFrequency); (1E-9 * systemFrequency);
} }
@ -965,9 +1014,9 @@ int setDelayAfterTrigger(int64_t val) {
} }
LOG(logINFO, ("Setting delay after trigger %lld ns\n", val)); LOG(logINFO, ("Setting delay after trigger %lld ns\n", val));
val *= (1E-9 * systemFrequency); val *= (1E-9 * systemFrequency);
if (getTiming() == AUTO_TIMING) {
LOG(logINFO, ("\tNot trigger mode: not writing to register\n"));
delayReg = val; delayReg = val;
if (getTiming() == AUTO_TIMING) {
LOG(logINFO, ("\tAuto mode (not writing to register)\n"));
} else { } else {
set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG); set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
} }
@ -995,6 +1044,8 @@ int setBurstPeriod(int64_t val) {
} }
LOG(logINFO, ("Setting burst period %lld ns\n", val)); LOG(logINFO, ("Setting burst period %lld ns\n", val));
val *= (1E-9 * systemFrequency); val *= (1E-9 * systemFrequency);
burstPeriodReg = val;
// burst and auto // burst and auto
if ((burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) && if ((burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) &&
getTiming() == AUTO_TIMING) { getTiming() == AUTO_TIMING) {
@ -1002,9 +1053,7 @@ int setBurstPeriod(int64_t val) {
} }
// burst-trigger, continuous // burst-trigger, continuous
else { else {
LOG(logINFO, LOG(logINFO, ("\tNot Burst and Auto mode (not writing to register)\n"));
("\tNot (Burst and Auto mode): not writing to register\n"));
burstPeriodReg = val;
} }
// validate for tolerance // validate for tolerance
@ -1028,11 +1077,21 @@ int64_t getBurstPeriod() {
} }
int64_t getNumFramesLeft() { int64_t getNumFramesLeft() {
// continuous and auto
if ((burstMode == CONTINUOUS_INTERNAL ||
burstMode == CONTINUOUS_EXTERNAL) &&
getTiming() == AUTO_TIMING) {
return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG); return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG);
}
return -1;
} }
int64_t getNumTriggersLeft() { int64_t getNumTriggersLeft() {
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
return get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG); return get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG);
}
return -1;
} }
int64_t getDelayAfterTriggerLeft() { int64_t getDelayAfterTriggerLeft() {
@ -1045,6 +1104,15 @@ int64_t getPeriodLeft() {
(1E-9 * systemFrequency); (1E-9 * systemFrequency);
} }
int64_t getNumBurstsLeft() {
// burst and auto
if ((burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) &&
getTiming() == AUTO_TIMING) {
return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG);
}
return -1;
}
int64_t getFramesFromStart() { int64_t getFramesFromStart() {
return get64BitReg(FRAMES_FROM_START_LSB_REG, FRAMES_FROM_START_MSB_REG); return get64BitReg(FRAMES_FROM_START_LSB_REG, FRAMES_FROM_START_MSB_REG);
} }
@ -1238,20 +1306,201 @@ int setHighVoltage(int val) {
} }
/* parameters - timing */ /* parameters - timing */
void setTiming(enum timingMode arg) {
// update
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
numTriggersReg = get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
delayReg =
get64BitReg(SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
}
// auto and burst
else if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
numBurstsReg = get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
burstPeriodReg = get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
}
void updatingRegisters() {
LOG(logINFO, ("\tUpdating registers\n"));
// burst
if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
// auto
if (getTiming() == AUTO_TIMING) {
LOG(logINFO, ("\t[Burst, Auto mode]\n"))
// trigger reg
set64BitReg(1, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
LOG(logINFO, ("\tTrigger reg: %lld\n",
get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG)));
// delay reg
set64BitReg(0, SET_TRIGGER_DELAY_LSB_REG,
SET_TRIGGER_DELAY_MSB_REG);
LOG(logINFO,
("\tDelay reg: %lldns\n",
(long long int)(get64BitReg(SET_TRIGGER_DELAY_LSB_REG,
SET_TRIGGER_DELAY_MSB_REG) /
(1E-9 * systemFrequency))));
// frame reg
set64BitReg(numBurstsReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
LOG(logINFO, ("\tFrame reg (bursts): %lld\n",
get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG)));
// period reg
set64BitReg(burstPeriodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
LOG(logINFO, ("\tPeriod reg (burst period): %lldns\n",
(long long int)(get64BitReg(SET_PERIOD_LSB_REG,
SET_PERIOD_MSB_REG) /
(1E-9 * systemFrequency))));
// int. frame reg
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) |
(((int)numFramesReg << ASIC_INT_FRAMES_OFST) &
ASIC_INT_FRAMES_MSK));
LOG(logINFO, ("\tInt. Frame reg (frames): %d\n",
((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >>
ASIC_INT_FRAMES_OFST)));
// int. period reg
set64BitReg(periodReg, ASIC_INT_PERIOD_LSB_REG,
ASIC_INT_PERIOD_MSB_REG);
LOG(logINFO, ("\tInt. Period reg (period): %lldns\n",
(long long int)(get64BitReg(ASIC_INT_PERIOD_LSB_REG,
ASIC_INT_PERIOD_MSB_REG) /
(1E-9 * systemFrequency))));
// extra frame reg (N.A)
}
// trigger
else {
LOG(logINFO, ("\t[Burst, Trigger mode]\n"))
// trigger reg
set64BitReg(numTriggersReg, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
LOG(logINFO, ("\tTrigger reg (triggers): %lld\n",
get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG)));
// delay reg
set64BitReg(delayReg, SET_TRIGGER_DELAY_LSB_REG,
SET_TRIGGER_DELAY_MSB_REG);
LOG(logINFO,
("\tDelay reg (delay): %lldns\n",
(long long int)(get64BitReg(SET_TRIGGER_DELAY_LSB_REG,
SET_TRIGGER_DELAY_MSB_REG) /
(1E-9 * systemFrequency))));
// frame reg
set64BitReg(1, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
LOG(logINFO, ("\tFrame reg: %lld\n",
get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG)));
// period reg
set64BitReg(0, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
LOG(logINFO, ("\tPeriod reg: %lldns\n",
(long long int)(get64BitReg(SET_PERIOD_LSB_REG,
SET_PERIOD_MSB_REG) /
(1E-9 * systemFrequency))));
// int. frame reg
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) |
(((int)numFramesReg << ASIC_INT_FRAMES_OFST) &
ASIC_INT_FRAMES_MSK));
LOG(logINFO, ("\tInt. Frame reg (frames): %d\n",
((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >>
ASIC_INT_FRAMES_OFST)));
// int. period reg
set64BitReg(periodReg, ASIC_INT_PERIOD_LSB_REG,
ASIC_INT_PERIOD_MSB_REG);
LOG(logINFO, ("\tInt. Period reg (period): %lldns\n",
(long long int)(get64BitReg(ASIC_INT_PERIOD_LSB_REG,
ASIC_INT_PERIOD_MSB_REG) /
(1E-9 * systemFrequency))));
// extra frame reg (N.A)
}
}
// continuous
else {
// auto
if (getTiming() == AUTO_TIMING) {
LOG(logINFO, ("\t[Continuous, Auto mode]\n"))
// trigger reg
set64BitReg(1, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
LOG(logINFO, ("\tTrigger reg: %lld\n",
get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG)));
// delay reg
set64BitReg(0, SET_TRIGGER_DELAY_LSB_REG,
SET_TRIGGER_DELAY_MSB_REG);
LOG(logINFO,
("\tDelay reg: %lldns\n",
(long long int)(get64BitReg(SET_TRIGGER_DELAY_LSB_REG,
SET_TRIGGER_DELAY_MSB_REG) /
(1E-9 * systemFrequency))));
// frame reg
set64BitReg(numFramesReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
LOG(logINFO, ("\tFrame reg (frames): %lld\n",
get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG)));
// period reg
set64BitReg(periodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
LOG(logINFO, ("\tPeriod reg (period): %lldns\n",
(long long int)(get64BitReg(SET_PERIOD_LSB_REG,
SET_PERIOD_MSB_REG) /
(1E-9 * systemFrequency))));
// int. frame reg
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) |
((1 << ASIC_INT_FRAMES_OFST) & ASIC_INT_FRAMES_MSK));
LOG(logINFO, ("\tInt. Frame reg: %d\n",
((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >>
ASIC_INT_FRAMES_OFST)));
// int. period reg
set64BitReg(0, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
LOG(logINFO, ("\tInt. Period reg: %lldns\n",
(long long int)(get64BitReg(ASIC_INT_PERIOD_LSB_REG,
ASIC_INT_PERIOD_MSB_REG) /
(1E-9 * systemFrequency))));
// extra frame reg
set64BitReg(numFramesReg, ASIC_CONT_FRAMES_LSB_REG,
ASIC_CONT_FRAMES_MSB_REG);
LOG(logINFO, ("\tExtra Frame reg (frames): %lld\n",
get64BitReg(ASIC_CONT_FRAMES_LSB_REG,
ASIC_CONT_FRAMES_MSB_REG)));
}
// trigger
else {
LOG(logINFO, ("\t[Continuous, Trigger mode]\n"))
// trigger reg
set64BitReg(numTriggersReg, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
LOG(logINFO, ("\tTrigger reg (triggers): %lld\n",
get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG)));
// delay reg
set64BitReg(delayReg, SET_TRIGGER_DELAY_LSB_REG,
SET_TRIGGER_DELAY_MSB_REG);
LOG(logINFO,
("\tDelay reg (delay): %lldns\n",
(long long int)(get64BitReg(SET_TRIGGER_DELAY_LSB_REG,
SET_TRIGGER_DELAY_MSB_REG) /
(1E-9 * systemFrequency))));
// frame reg
set64BitReg(1, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
LOG(logINFO, ("\tFrame reg: %lld\n",
get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG)));
// period reg
set64BitReg(0, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
LOG(logINFO, ("\tPeriod reg: %lld\n",
(long long int)(get64BitReg(SET_PERIOD_LSB_REG,
SET_PERIOD_MSB_REG) /
(1E-9 * systemFrequency))));
// int. frame reg
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) |
((1 << ASIC_INT_FRAMES_OFST) & ASIC_INT_FRAMES_MSK));
LOG(logINFO, ("\tInt. Frame reg: %d\n",
((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >>
ASIC_INT_FRAMES_OFST)));
// int. period reg
set64BitReg(0, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
LOG(logINFO, ("\tInt. Period reg: %lldns\n",
(long long int)(get64BitReg(ASIC_INT_PERIOD_LSB_REG,
ASIC_INT_PERIOD_MSB_REG) /
(1E-9 * systemFrequency))));
// extra frame reg
set64BitReg(numTriggersReg, ASIC_CONT_FRAMES_LSB_REG,
ASIC_CONT_FRAMES_MSB_REG);
LOG(logINFO, ("\tExtra Frame reg (triggers): %lld\n",
get64BitReg(ASIC_CONT_FRAMES_LSB_REG,
ASIC_CONT_FRAMES_MSB_REG)));
}
}
LOG(logINFO, ("\tDone Updating registers\n\n"));
}
void setTiming(enum timingMode arg) {
switch (arg) { switch (arg) {
case AUTO_TIMING: case AUTO_TIMING:
LOG(logINFO, ("Set Timing: Auto\n")); LOG(logINFO, ("Set Timing: Auto\n"));
@ -1265,36 +1514,7 @@ void setTiming(enum timingMode arg) {
LOG(logERROR, ("Unknown timing mode %d\n", arg)); LOG(logERROR, ("Unknown timing mode %d\n", arg));
} }
LOG(logINFO, ("\tUpdating registers\n")) updatingRegisters();
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
set64BitReg(numTriggersReg, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
set64BitReg(delayReg, SET_TRIGGER_DELAY_LSB_REG,
SET_TRIGGER_DELAY_MSB_REG);
LOG(logINFO, ("\tTriggers reg: %lld, Delay reg: %lldns\n",
getNumTriggers(), getDelayAfterTrigger()));
// burst
if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
LOG(logINFO, ("\tFrame reg: 1, Period reg: 0\n"))
set64BitReg(1, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(0, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
}
}
// auto
else {
LOG(logINFO, ("\tTrigger reg: 1, Delay reg: 0\n"))
set64BitReg(1, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
set64BitReg(0, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
// burst
if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
set64BitReg(numBurstsReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(burstPeriodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
LOG(logINFO, ("\tFrames reg (bursts): %lld, Period reg(burst "
"period): %lldns\n",
getNumBursts(), getBurstPeriod()));
}
}
LOG(logINFO, ("\tDone Updating registers\n"))
} }
enum timingMode getTiming() { enum timingMode getTiming() {
@ -1466,8 +1686,8 @@ int configureMAC() {
} }
if (vetoEnabled && numInterfaces == 2 && if (vetoEnabled && numInterfaces == 2 &&
setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) { setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) {
LOG(logERROR, LOG(logERROR, ("could not set udp destination IP and port for "
("could not set udp destination IP and port for interface 2\n")); "interface 2\n"));
return FAIL; return FAIL;
} }
return OK; return OK;
@ -1878,8 +2098,8 @@ int configureASICVetoReference(int chipIndex, int *gainIndices, int *values) {
} }
} }
// create command for 4 padding + 1792 bits + 4 bits address = 1800 bits = // create command for 4 padding + 1792 bits + 4 bits address = 1800
// 225 bytes // bits = 225 bytes
char buffer[len]; char buffer[len];
memset(buffer, 0, len); memset(buffer, 0, len);
offset = 0; offset = 0;
@ -1920,7 +2140,8 @@ int configureASICVetoReference(int chipIndex, int *gainIndices, int *values) {
int getVetoPhoton(int chipIndex, int *retvals, int *gainRetvals) { int getVetoPhoton(int chipIndex, int *retvals, int *gainRetvals) {
if (chipIndex == -1) { if (chipIndex == -1) {
// if chipindex is -1, check that all values and gain indices are same // if chipindex is -1, check that all values and gain indices are
// same
for (int i = 0; i < NCHAN; ++i) { for (int i = 0; i < NCHAN; ++i) {
int val = vetoReference[0][i]; int val = vetoReference[0][i];
int gval = vetoGainIndices[0][i]; int gval = vetoGainIndices[0][i];
@ -1928,7 +2149,8 @@ int getVetoPhoton(int chipIndex, int *retvals, int *gainRetvals) {
if (vetoReference[j][i] != val) { if (vetoReference[j][i] != val) {
LOG(logERROR, LOG(logERROR,
("Get vet photon fail for chipIndex:%d. Different " ("Get vet photon fail for chipIndex:%d. Different "
"values between [nchip:%d, nchan:%d, value:%d] and " "values between [nchip:%d, nchan:%d, value:%d] "
"and "
"[nchip:0, nchan:%d, value:%d]\n", "[nchip:0, nchan:%d, value:%d]\n",
chipIndex, j, i, vetoReference[j][i], i, val)); chipIndex, j, i, vetoReference[j][i], i, val));
return FAIL; return FAIL;
@ -1937,7 +2159,8 @@ int getVetoPhoton(int chipIndex, int *retvals, int *gainRetvals) {
LOG(logERROR, LOG(logERROR,
("Get vet photon fail for chipIndex:%d. Different " ("Get vet photon fail for chipIndex:%d. Different "
"gain indices between [nchip:%d, nchan:%d, gain " "gain indices between [nchip:%d, nchan:%d, gain "
"index:%d] and [nchip:0, nchan:%d, gain index:%d]\n", "index:%d] and [nchip:0, nchan:%d, gain "
"index:%d]\n",
chipIndex, j, i, vetoGainIndices[j][i], i, gval)); chipIndex, j, i, vetoGainIndices[j][i], i, gval));
return FAIL; return FAIL;
} }
@ -2020,8 +2243,8 @@ int setADCConfiguration(int chipIndex, int adcIndex, int value) {
} }
} }
// create command for 4 padding + 224 bits + 4 bits address = 232 bits = 29 // create command for 4 padding + 224 bits + 4 bits address = 232 bits =
// bytes // 29 bytes
char buffer[len]; char buffer[len];
memset(buffer, 0, len); memset(buffer, 0, len);
offset = 0; offset = 0;
@ -2074,7 +2297,8 @@ int getADCConfiguration(int chipIndex, int adcIndex) {
for (int j = adcmin; j < adcmax; ++j) { for (int j = adcmin; j < adcmax; ++j) {
if (adcConfiguration[i][j] != val) { if (adcConfiguration[i][j] != val) {
LOG(logINFO, LOG(logINFO,
("\tADC configuration 0x%x at [%d][%d] differs from 0x%x " ("\tADC configuration 0x%x at [%d][%d] differs from "
"0x%x "
"at " "at "
"[%d][%d], returning -1\n", "[%d][%d], returning -1\n",
adcConfiguration[i][j], i, j, val, chipmin, adcmin)); adcConfiguration[i][j], i, j, val, chipmin, adcmin));
@ -2123,77 +2347,11 @@ int setBurstMode(enum burstMode burst) {
? "continuous internal" ? "continuous internal"
: "continuous external"))))); : "continuous external")))));
// update
int64_t framesReg = 0;
int64_t periodReg = 0;
// burst
if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
framesReg = ((bus_r(ASIC_INT_FRAMES_REG) & ASIC_INT_FRAMES_MSK) >>
ASIC_INT_FRAMES_OFST);
periodReg =
get64BitReg(ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
// auto
if (getTiming() == AUTO_TIMING) {
numBurstsReg = get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
burstPeriodReg =
get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
}
}
// continuous
else {
framesReg = get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
periodReg = get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
}
if (setBurstModeinFPGA(burst) == FAIL) { if (setBurstModeinFPGA(burst) == FAIL) {
return FAIL; return FAIL;
} }
LOG(logINFO, ("\tUpdating registers\n")); updatingRegisters();
// continuous
if (burstMode == CONTINUOUS_INTERNAL || burstMode == CONTINUOUS_EXTERNAL) {
set64BitReg(framesReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(periodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
LOG(logINFO, ("\tFrames reg: %lld, Period reg: %lldns\n",
getNumFrames(), getPeriod()));
LOG(logINFO, ("\tInt. Frame reg: 1, Int. Period reg: 0\n"))
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) |
((1 << ASIC_INT_FRAMES_OFST) & ASIC_INT_FRAMES_MSK));
set64BitReg(0, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
}
// burst
else {
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) & ~ASIC_INT_FRAMES_MSK);
bus_w(ASIC_INT_FRAMES_REG,
bus_r(ASIC_INT_FRAMES_REG) |
(((int)framesReg << ASIC_INT_FRAMES_OFST) &
ASIC_INT_FRAMES_MSK));
set64BitReg(periodReg, ASIC_INT_PERIOD_LSB_REG,
ASIC_INT_PERIOD_MSB_REG);
LOG(logINFO, ("\tInt. Frames reg: %lld, Int. Period reg: %lldns\n",
getNumFrames(), getPeriod()));
// trigger
if (getTiming() == TRIGGER_EXPOSURE) {
LOG(logINFO, ("\tFrame reg: 1, Period reg: 0\n"))
set64BitReg(1, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(0, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
}
// auto
else {
set64BitReg(numBurstsReg, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
set64BitReg(burstPeriodReg, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
LOG(logINFO, ("\tFrames reg (bursts): %lld, Period reg(burst "
"period): %lldns\n",
getNumBursts(), getBurstPeriod()));
}
}
LOG(logINFO, ("\tDone Updating registers\n"))
return configureASICGlobalSettings(); return configureASICGlobalSettings();
} }
@ -2232,8 +2390,8 @@ int configureASICGlobalSettings() {
((value >> (ASIC_GLOBAL_SETT_MAX_BITS - 1 - iBit)) & 0x1); ((value >> (ASIC_GLOBAL_SETT_MAX_BITS - 1 - iBit)) & 0x1);
} }
// create command for 4 padding + 224 bits + 4 bits address = 232 bits = 29 // create command for 4 padding + 224 bits + 4 bits address = 232 bits =
// bytes // 29 bytes
char buffer[len]; char buffer[len];
memset(buffer, 0, len); memset(buffer, 0, len);
offset = 0; offset = 0;
@ -2492,7 +2650,13 @@ void *start_timer(void *arg) {
} }
int repeatPeriodNs = getBurstPeriod(); int repeatPeriodNs = getBurstPeriod();
int numFrames = getNumFrames(); int numFrames = getNumFrames();
// continuous trigger mode, #frames = 1
int64_t periodNs = getPeriod(); int64_t periodNs = getPeriod();
if (getTiming() == TRIGGER_EXPOSURE && (burstMode == CONTINUOUS_INTERNAL ||
burstMode == CONTINUOUS_EXTERNAL)) {
numFrames = 1;
periodNs = 0;
}
int64_t expUs = getExpTime() / 1000; int64_t expUs = getExpTime() / 1000;
int imagesize = NCHAN * NCHIP * 2; int imagesize = NCHAN * NCHIP * 2;
int datasize = imagesize; int datasize = imagesize;
@ -2693,15 +2857,7 @@ void readFrame(int *ret, char *mess) {
#endif #endif
*ret = (int)OK; *ret = (int)OK;
// frames left to give status
int64_t retval = getNumFramesLeft() + 1;
if (retval > 0) {
LOG(logERROR, ("No data and run stopped: %lld frames left\n",
(long long int)retval));
} else {
LOG(logINFOGREEN, ("Acquisition successfully finished\n")); LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
}
} }
u_int32_t runBusy() { u_int32_t runBusy() {

View File

@ -1035,8 +1035,10 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
if (val < 0) if (val < 0)
return; return;
LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, char *dac_names[] = {DAC_NAMES};
(mV ? "mV" : "dac units"))); LOG(logINFO, ("Setting DAC %s\n", dac_names[ind]));
LOG(logDEBUG1, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind],
val, (mV ? "mV" : "dac units")));
int dacval = val; int dacval = val;
#ifdef VIRTUAL #ifdef VIRTUAL
if (!mV) { if (!mV) {

View File

@ -17,6 +17,10 @@ enum DACINDEX {
enum CLKINDEX { ADC_CLK, NUM_CLOCKS }; enum CLKINDEX { ADC_CLK, NUM_CLOCKS };
#define CLK_NAMES "adc" #define CLK_NAMES "adc"
#define DAC_NAMES \
"vref_ds", "vcascn_pb", "vcascp_pb", "vout_cm", "vcasc_out", "vin_cm", \
"vref_comp", "ib_testc"
#define DEFAULT_DAC_VALS \ #define DEFAULT_DAC_VALS \
{ \ { \
660, /* G_VREF_DS */ \ 660, /* G_VREF_DS */ \

View File

@ -843,8 +843,10 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
if (val < 0) if (val < 0)
return; return;
LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, char *dac_names[] = {DAC_NAMES};
(mV ? "mV" : "dac units"))); LOG(logINFO, ("Setting DAC %s\n", dac_names[ind]));
LOG(logDEBUG1, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind],
val, (mV ? "mV" : "dac units")));
int dacval = val; int dacval = val;
#ifdef VIRTUAL #ifdef VIRTUAL
if (!mV) { if (!mV) {

View File

@ -47,6 +47,10 @@ enum DACINDEX {
J_VREF_DS, J_VREF_DS,
J_VREF_COMP J_VREF_COMP
}; };
#define DAC_NAMES \
"vb_comp", "vdd_prot", "vin_com", "vref_prech", "vb_pixbuf", "vb_ds", \
"vref_ds", "vref_comp"
#define DEFAULT_DAC_VALS \ #define DEFAULT_DAC_VALS \
{ \ { \
1220, /* J_VB_COMP */ \ 1220, /* J_VB_COMP */ \

View File

@ -8,8 +8,8 @@ int sharedMemory_open(int port);
int sharedMemory_attach(); int sharedMemory_attach();
int sharedMemory_detach(); int sharedMemory_detach();
int sharedMemory_remove(); int sharedMemory_remove();
void sharedMemory_lock(); void sharedMemory_lockStatus();
void sharedMemory_unlock(); void sharedMemory_unlockStatus();
#ifdef VIRTUAL #ifdef VIRTUAL
void sharedMemory_setStatus(enum runStatus s); void sharedMemory_setStatus(enum runStatus s);
enum runStatus sharedMemory_getStatus(); enum runStatus sharedMemory_getStatus();
@ -20,3 +20,7 @@ void sharedMemory_setScanStatus(enum runStatus s);
enum runStatus sharedMemory_getScanStatus(); enum runStatus sharedMemory_getScanStatus();
void sharedMemory_setScanStop(int s); void sharedMemory_setScanStop(int s);
int sharedMemory_getScanStop(); int sharedMemory_getScanStop();
#ifdef EIGERD
void sharedMemory_lockLocalLink();
void sharedMemory_unlockLocalLink();
#endif

View File

@ -267,6 +267,9 @@ int64_t getNumTriggersLeft();
int64_t getDelayAfterTriggerLeft(); int64_t getDelayAfterTriggerLeft();
int64_t getPeriodLeft(); int64_t getPeriodLeft();
#endif #endif
#ifdef GOTTHARD2D
int64_t getNumBurstsLeft();
#endif
#ifdef GOTTHARDD #ifdef GOTTHARDD
int64_t getExpTimeLeft(); int64_t getExpTimeLeft();
#endif #endif
@ -338,6 +341,9 @@ int getADC(enum ADCINDEX ind);
int setHighVoltage(int val); int setHighVoltage(int val);
// parameters - timing, extsig // parameters - timing, extsig
#ifdef GOTTHARD2D
void updatingRegisters();
#endif
void setTiming(enum timingMode arg); void setTiming(enum timingMode arg);
enum timingMode getTiming(); enum timingMode getTiming();
#ifdef MYTHEN3D #ifdef MYTHEN3D

View File

@ -239,3 +239,4 @@ int get_bad_channels(int);
int set_bad_channels(int); int set_bad_channels(int);
int reconfigure_udp(int); int reconfigure_udp(int);
int validate_udp_configuration(int); int validate_udp_configuration(int);
int get_bursts_left(int);

View File

@ -2,20 +2,27 @@
#include "clogger.h" #include "clogger.h"
#include <errno.h> #include <errno.h>
#include <pthread.h> #include <semaphore.h>
#include <string.h> #include <string.h>
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
#include <unistd.h> #include <unistd.h>
#define SHM_NAME "sls_server_shared_memory" #define SHM_NAME "sls_server_shared_memory"
#ifdef EIGERD
#define SHM_VERSION 0x200915
#else
#define SHM_VERSION 0x200625 #define SHM_VERSION 0x200625
#endif
#define SHM_KEY 5678 #define SHM_KEY 5678
#define MEM_SIZE 128 #define MEM_SIZE 128
typedef struct Memory { typedef struct Memory {
int version; int version;
pthread_mutex_t lock; sem_t semStatus;
#ifdef EIGERD
sem_t semLocalLink;
#endif
enum runStatus scanStatus; // idle, running or error enum runStatus scanStatus; // idle, running or error
int scanStop; int scanStop;
#ifdef VIRTUAL #ifdef VIRTUAL
@ -80,11 +87,18 @@ int sharedMemory_create(int port) {
int sharedMemory_initialize() { int sharedMemory_initialize() {
shm->version = SHM_VERSION; shm->version = SHM_VERSION;
if (pthread_mutex_init(&(shm->lock), NULL) != 0) { if (sem_init(&(shm->semStatus), 1, 1) != 0) {
LOG(logERROR, LOG(logERROR, ("Failed to initialize semaphore semStatus for "
("Failed to initialize pthread lock for shared memory\n")); "shared memory\n"));
return FAIL; return FAIL;
} }
#ifdef EIGERD
if (sem_init(&(shm->semLocalLink), 1, 1) != 0) {
LOG(logERROR, ("Failed to initialize semaphore semLocalLink for "
"shared memory\n"));
return FAIL;
}
#endif
shm->scanStatus = IDLE; shm->scanStatus = IDLE;
shm->scanStop = 0; shm->scanStop = 0;
#ifdef VIRTUAL #ifdef VIRTUAL
@ -141,64 +155,70 @@ int sharedMemory_remove() {
return OK; return OK;
} }
void sharedMemory_lock() { pthread_mutex_lock(&(shm->lock)); } void sharedMemory_lockStatus() { sem_wait(&(shm->semStatus)); }
void sharedMemory_unlock() { pthread_mutex_unlock(&(shm->lock)); } void sharedMemory_unlockStatus() { sem_post(&(shm->semStatus)); }
#ifdef VIRTUAL #ifdef VIRTUAL
void sharedMemory_setStatus(enum runStatus s) { void sharedMemory_setStatus(enum runStatus s) {
sharedMemory_lock(); sharedMemory_lockStatus();
shm->status = s; shm->status = s;
sharedMemory_unlock(); sharedMemory_unlockStatus();
} }
enum runStatus sharedMemory_getStatus() { enum runStatus sharedMemory_getStatus() {
enum runStatus s = 0; enum runStatus s = 0;
sharedMemory_lock(); sharedMemory_lockStatus();
s = shm->status; s = shm->status;
sharedMemory_unlock(); sharedMemory_unlockStatus();
return s; return s;
} }
void sharedMemory_setStop(int s) { void sharedMemory_setStop(int s) {
sharedMemory_lock(); sharedMemory_lockStatus();
shm->stop = s; shm->stop = s;
sharedMemory_unlock(); sharedMemory_unlockStatus();
} }
int sharedMemory_getStop() { int sharedMemory_getStop() {
int s = 0; int s = 0;
sharedMemory_lock(); sharedMemory_lockStatus();
s = shm->stop; s = shm->stop;
sharedMemory_unlock(); sharedMemory_unlockStatus();
return s; return s;
} }
#endif #endif
void sharedMemory_setScanStatus(enum runStatus s) { void sharedMemory_setScanStatus(enum runStatus s) {
sharedMemory_lock(); sharedMemory_lockStatus();
shm->scanStatus = s; shm->scanStatus = s;
sharedMemory_unlock(); sharedMemory_unlockStatus();
} }
enum runStatus sharedMemory_getScanStatus() { enum runStatus sharedMemory_getScanStatus() {
enum runStatus s = IDLE; enum runStatus s = IDLE;
sharedMemory_lock(); sharedMemory_lockStatus();
s = shm->scanStatus; s = shm->scanStatus;
sharedMemory_unlock(); sharedMemory_unlockStatus();
return s; return s;
} }
void sharedMemory_setScanStop(int s) { void sharedMemory_setScanStop(int s) {
sharedMemory_lock(); sharedMemory_lockStatus();
shm->scanStop = s; shm->scanStop = s;
sharedMemory_unlock(); sharedMemory_unlockStatus();
} }
int sharedMemory_getScanStop() { int sharedMemory_getScanStop() {
int s = 0; int s = 0;
sharedMemory_lock(); sharedMemory_lockStatus();
s = shm->scanStop; s = shm->scanStop;
sharedMemory_unlock(); sharedMemory_unlockStatus();
return s; return s;
} }
#ifdef EIGERD
void sharedMemory_lockLocalLink() { sem_wait(&(shm->semLocalLink)); }
void sharedMemory_unlockLocalLink() { sem_post(&(shm->semLocalLink)); }
#endif

View File

@ -357,6 +357,7 @@ void function_table() {
flist[F_SET_BAD_CHANNELS] = &set_bad_channels; flist[F_SET_BAD_CHANNELS] = &set_bad_channels;
flist[F_RECONFIGURE_UDP] = &reconfigure_udp; flist[F_RECONFIGURE_UDP] = &reconfigure_udp;
flist[F_VALIDATE_UDP_CONFIG] = &validate_udp_configuration; flist[F_VALIDATE_UDP_CONFIG] = &validate_udp_configuration;
flist[F_GET_BURSTS_LEFT] = &get_bursts_left;
// check // check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -4223,6 +4224,7 @@ int copy_detector_server(int file_des) {
strcat(cmd, sname); strcat(cmd, sname);
executeCommand(cmd, retvals, logDEBUG1); executeCommand(cmd, retvals, logDEBUG1);
#if !defined(GOTTHAR2D) && !defined(MYTHEN3D)
// edit /etc/inittab // edit /etc/inittab
// find line numbers in /etc/inittab where DetectorServer // find line numbers in /etc/inittab where DetectorServer
strcpy(cmd, "sed -n '/DetectorServer/=' /etc/inittab"); strcpy(cmd, "sed -n '/DetectorServer/=' /etc/inittab");
@ -4247,6 +4249,7 @@ int copy_detector_server(int file_des) {
executeCommand(cmd, retvals, logDEBUG1); executeCommand(cmd, retvals, logDEBUG1);
LOG(logINFO, ("/etc/inittab modified to have %s\n", sname)); LOG(logINFO, ("/etc/inittab modified to have %s\n", sname));
#endif
} }
} }
#endif #endif
@ -8066,3 +8069,18 @@ int validate_udp_configuration(int file_des) {
return Server_SendResult(file_des, INT32, NULL, 0); return Server_SendResult(file_des, INT32, NULL, 0);
} }
int get_bursts_left(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// get only
retval = getNumBurstsLeft();
LOG(logDEBUG1, ("retval num bursts left %lld\n", (long long int)retval));
#endif
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
}

View File

@ -58,10 +58,11 @@ class Detector {
Result<std::string> getHostname(Positions pos = {}) const; Result<std::string> getHostname(Positions pos = {}) const;
/**Frees shared memory, adds detectors to the list */ /**Frees shared memory, adds detectors to the list. */
void setHostname(const std::vector<std::string> &hostname); void setHostname(const std::vector<std::string> &hostname);
/** connects to n servers at local host starting at specific control port */ /** connects to n servers at local host starting at specific control port.
* Every virtual server will have a stop port (control port + 1) */
void setVirtualDetectorServers(int numServers, int startingPort); void setVirtualDetectorServers(int numServers, int startingPort);
/** Gets shared memory ID */ /** Gets shared memory ID */
@ -84,7 +85,7 @@ class Detector {
* CHIPTESTBOARD */ * CHIPTESTBOARD */
Result<defs::detectorType> getDetectorType(Positions pos = {}) const; Result<defs::detectorType> getDetectorType(Positions pos = {}) const;
/** Gets the total number of detectors */ /** Gets the total number of modules in shared memory */
int size() const; int size() const;
bool empty() const; bool empty() const;
@ -98,8 +99,10 @@ class Detector {
defs::xy getDetectorSize() const; defs::xy getDetectorSize() const;
/** /**
* Sets the detector size in both dimensions. \n * Sets the detector size in both dimensions (number of channels). \n
* This value is used to calculate row and column positions for each module. * This value is used to calculate row and column positions for each module
* and included into udp data packet header. \n By default, it adds modules
* in y dimension for 2d detectors and in x dimension for 1d detectors.
*/ */
void setDetectorSize(const defs::xy value); void setDetectorSize(const defs::xy value);
@ -183,7 +186,8 @@ class Detector {
Result<int64_t> getNumberOfFrames(Positions pos = {}) const; Result<int64_t> getNumberOfFrames(Positions pos = {}) const;
/** In trigger mode, number of frames per trigger. In scan mode, number of /** In trigger mode, number of frames per trigger. In scan mode, number of
* frames is set to number of steps */ * frames is set to number of steps \n [Gotthard2] Burst mode has a maximum
* of 2720 frames. */
void setNumberOfFrames(int64_t value); void setNumberOfFrames(int64_t value);
Result<int64_t> getNumberOfTriggers(Positions pos = {}) const; Result<int64_t> getNumberOfTriggers(Positions pos = {}) const;
@ -210,14 +214,14 @@ class Detector {
void setDelayAfterTrigger(ns value, Positions pos = {}); void setDelayAfterTrigger(ns value, Positions pos = {});
/** [Gotthard][Jungfrau][CTB][Moench][Mythen3] /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
* [Gotthard2] only in continuous mode */ * [Gotthard2] only in continuous auto mode */
Result<int64_t> getNumberOfFramesLeft(Positions pos = {}) const; Result<int64_t> getNumberOfFramesLeft(Positions pos = {}) const;
/** [Gotthard][Jungfrau][CTB][Moench][Mythen3] /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
* [Gotthard2] only in continuous mode */ * Only when external trigger used */
Result<int64_t> getNumberOfTriggersLeft(Positions pos = {}) const; Result<int64_t> getNumberOfTriggersLeft(Positions pos = {}) const;
/** [Gotthard][Jungfrau][CTB][Moench][Mythen3] /** [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2]
* [Gotthard2] only in continuous mode */ * [Gotthard2] only in continuous mode */
Result<ns> getPeriodLeft(Positions pos = {}) const; Result<ns> getPeriodLeft(Positions pos = {}) const;
@ -228,8 +232,8 @@ class Detector {
Result<int> getDynamicRange(Positions pos = {}) const; Result<int> getDynamicRange(Positions pos = {}) const;
/** /**
* [Eiger] Options: 4, 8, 16, 32. If i is 32, also sets clkdivider to 2, if * [Eiger] Options: 4, 8, 16, 32. If i is 32, also sets clkdivider to 2,
* 16, sets clkdivider to 1 \n [Mythen3] Options: 8, 16, 32 \n * else sets clkdivider to 1 \n [Mythen3] Options: 8, 16, 32 \n
* [Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16 * [Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16
*/ */
void setDynamicRange(int value); void setDynamicRange(int value);
@ -310,13 +314,10 @@ class Detector {
/** [Mythen3][Gotthard2] Hz */ /** [Mythen3][Gotthard2] Hz */
Result<int> getClockFrequency(int clkIndex, Positions pos = {}); Result<int> getClockFrequency(int clkIndex, Positions pos = {});
/** [not implemented] Hz */
void setClockFrequency(int clkIndex, int value, Positions pos = {});
/** [Mythen3][Gotthard2] */ /** [Mythen3][Gotthard2] */
Result<int> getClockPhase(int clkIndex, Positions pos = {}); Result<int> getClockPhase(int clkIndex, Positions pos = {});
/** [Mythen3][Gotthard2] */ /** [Mythen3][Gotthard2] absolute phase shift */
void setClockPhase(int clkIndex, int value, Positions pos = {}); void setClockPhase(int clkIndex, int value, Positions pos = {});
/** [Mythen3][Gotthard2] */ /** [Mythen3][Gotthard2] */
@ -331,7 +332,7 @@ class Detector {
/** [Mythen3][Gotthard2] */ /** [Mythen3][Gotthard2] */
Result<int> getClockDivider(int clkIndex, Positions pos = {}); Result<int> getClockDivider(int clkIndex, Positions pos = {});
/** [Mythen3][Gotthard2] */ /** [Mythen3][Gotthard2] Must be greater than 1. */
void setClockDivider(int clkIndex, int value, Positions pos = {}); void setClockDivider(int clkIndex, int value, Positions pos = {});
Result<int> getHighVoltage(Positions pos = {}) const; Result<int> getHighVoltage(Positions pos = {}) const;
@ -346,16 +347,22 @@ class Detector {
/** [Jungfrau][Mythen3][Gotthard2][Moench] */ /** [Jungfrau][Mythen3][Gotthard2][Moench] */
Result<bool> getPowerChip(Positions pos = {}) const; Result<bool> getPowerChip(Positions pos = {}) const;
/** [Jungfrau][Mythen3][Gotthard2][Moench] */ /** [Jungfrau][Mythen3][Gotthard2][Moench] Power the chip. \n
* [Moench] Default is disabled. \n
* [Jungfrau] Default is disabled. Get will return power status. Can be off
* if temperature event occured (temperature over temp_threshold with
* temp_control enabled. \n [Mythen3][Gotthard2] Default is 1. If module not
* connected or wrong module, powerchip will fail.
*/
void setPowerChip(bool on, Positions pos = {}); void setPowerChip(bool on, Positions pos = {});
/** [Gotthard][Eiger virtual] */ /** [Gotthard][Eiger virtual] */
Result<int> getImageTestMode(Positions pos = {}); Result<int> getImageTestMode(Positions pos = {});
/** [Gotthard] If 1, adds channel intensity with precalculated values. /** [Gotthard] If 1, adds channel intensity with precalculated values.
* Default is 0 * Default is 0 \n
* [Eiger virtual] If 1, pixels are saturated. If 0, increasing intensity * [Eiger][Jungfrau] Only for virtual servers, if 1, pixels are saturated.
* Only for virtual servers */ * If 0, increasing intensity */
void setImageTestMode(const int value, Positions pos = {}); void setImageTestMode(const int value, Positions pos = {});
/** gets list of temperature indices for this detector */ /** gets list of temperature indices for this detector */
@ -367,9 +374,7 @@ class Detector {
* [Jungfrau] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA \n * [Jungfrau] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA \n
* [Eiger] Options: TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE, * [Eiger] Options: TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE,
* TEMPERATURE_DCDC, TEMPERATURE_SODL, TEMPERATURE_SODR, TEMPERATURE_FPGA2, * TEMPERATURE_DCDC, TEMPERATURE_SODL, TEMPERATURE_SODR, TEMPERATURE_FPGA2,
* TEMPERATURE_FPGA3 \n * TEMPERATURE_FPGA3 \n [CTB] Options: SLOW_ADC_TEMP
* Cannot call TEMPERATURE_FPGA2 and TEMPERATURE_FPGA3 when blocking acquire
* in progress \n [CTB] Options: SLOW_ADC_TEMP
*/ */
Result<int> getTemperature(defs::dacIndex index, Positions pos = {}) const; Result<int> getTemperature(defs::dacIndex index, Positions pos = {}) const;
@ -435,8 +440,8 @@ class Detector {
*/ */
void acquire(); void acquire();
/** If acquisition aborted, use this to clear before starting next /** If acquisition aborted during blocking acquire, use this to clear
* acquisition */ * acquiring flag in shared memory before starting next acquisition */
void clearAcquiringFlag(); void clearAcquiringFlag();
/** Non Blocking: Start receiver listener and create data file if file write /** Non Blocking: Start receiver listener and create data file if file write
@ -452,10 +457,11 @@ class Detector {
void startDetector(); void startDetector();
/** Non blocking: Abort detector acquisition. Status changes to IDLE or /** Non blocking: Abort detector acquisition. Status changes to IDLE or
* STOPPED */ * STOPPED. Goes to stop server. */
void stopDetector(); void stopDetector();
/** IDLE, ERROR, WAITING, RUN_FINISHED, TRANSMITTING, RUNNING, STOPPED */ /** IDLE, ERROR, WAITING, RUN_FINISHED, TRANSMITTING, RUNNING, STOPPED \n
* Goes to stop server */
Result<defs::runStatus> getDetectorStatus(Positions pos = {}) const; Result<defs::runStatus> getDetectorStatus(Positions pos = {}) const;
/** Options: IDLE, TRANSMITTING, RUNNING */ /** Options: IDLE, TRANSMITTING, RUNNING */
@ -470,7 +476,7 @@ class Detector {
/** [Eiger][Jungfrau] */ /** [Eiger][Jungfrau] */
Result<uint64_t> getStartingFrameNumber(Positions pos = {}) const; Result<uint64_t> getStartingFrameNumber(Positions pos = {}) const;
/** [Eiger][Jungfrau] Stopping acquiistion might result in different frame /** [Eiger][Jungfrau] Stopping acquisition might result in different frame
* numbers for different modules.*/ * numbers for different modules.*/
void setStartingFrameNumber(uint64_t value, Positions pos = {}); void setStartingFrameNumber(uint64_t value, Positions pos = {});
@ -479,13 +485,15 @@ class Detector {
Result<defs::scanParameters> getScan(Positions pos = {}) const; Result<defs::scanParameters> getScan(Positions pos = {}) const;
/** enables/ disables scans for dac, trimbits [Eiger/ Mythen3] /** enables/ disables scans for dac and trimbits \n
* TRIMBIT_SCAN. Enabling scan sets number of frames to number of steps in * Enabling scan sets number of frames to number of steps in
* receiver. Disabling scan sets number of frames to 1 */ * receiver. \n To cancel scan configuration, set dac to '0', which also
* sets number of frames to 1 \n [Eiger/ Mythen3] Trimbits using
* TRIMBIT_SCAN*/
void setScan(const defs::scanParameters t); void setScan(const defs::scanParameters t);
/** gets scan error message in case of error during scan in case of non /** Gets Scan error message if scan ended in error for non blocking
* blocking acquisition (startDetector, not acquire) */ * acquisitions.*/
Result<std::string> getScanErrorMessage(Positions pos = {}) const; Result<std::string> getScanErrorMessage(Positions pos = {}) const;
///@{ ///@{
@ -513,7 +521,7 @@ class Detector {
Result<int> getSelectedUDPInterface(Positions pos = {}) const; Result<int> getSelectedUDPInterface(Positions pos = {}) const;
/** /**
* [Jungfrau: * [Jungfrau]
* Effective only when number of interfaces is 1. * Effective only when number of interfaces is 1.
* Options: 0 (outer, default), 1(inner)] //TODO: enum? * Options: 0 (outer, default), 1(inner)] //TODO: enum?
*/ */
@ -591,8 +599,14 @@ class Detector {
* calculated (incremented by 1 if no 2nd interface)*/ * calculated (incremented by 1 if no 2nd interface)*/
void setDestinationUDPPort2(int port, int module_id = -1); void setDestinationUDPPort2(int port, int module_id = -1);
/** Reconfigures Detector with UDP destination. More for debugging as the
* configuration is done automatically when the detector has sufficient UDP
* details. */
void reconfigureUDPDestination(Positions pos = {}); void reconfigureUDPDestination(Positions pos = {});
/** Validates that UDP configuration in the detector is valid. If not
* configured, it will throw with error message requesting missing udp
* information */
void validateUDPConfiguration(Positions pos = {}); void validateUDPConfiguration(Positions pos = {});
Result<std::string> printRxConfiguration(Positions pos = {}) const; Result<std::string> printRxConfiguration(Positions pos = {}) const;
@ -613,26 +627,26 @@ class Detector {
Result<int> getTransmissionDelayFrame(Positions pos = {}) const; Result<int> getTransmissionDelayFrame(Positions pos = {}) const;
/** /**
* [Jungfrau]: Sets the transmission delay of the first UDP packet being * Eiger][Jungfrau][Mythen3] Transmission delay of first udp packet being
* streamed out of the module. Options: 0 - 31, each value represenets 1 ms * streamed out of the module.\n[Jungfrau] [0-31] Each value represents 1
* [Eiger]: Sets the transmission delay of entire frame streamed out for * ms\n[Eiger] Additional delay to txndelay_left and txndelay_right. Each
* both left and right UDP ports. Options: //TODO possible values * value represents 10ns. Typical value is 50000.\n[Mythen3] [0-16777215]
* [Mythen3] Options: [0-16777215] Each value represents 8 ns (125 MHz * Each value represents 8 ns (125 MHz clock), max is 134 ms.
* clock), max is 134 ms.
*/ */
void setTransmissionDelayFrame(int value, Positions pos = {}); void setTransmissionDelayFrame(int value, Positions pos = {});
/** [Eiger] */ /** [Eiger] */
Result<int> getTransmissionDelayLeft(Positions pos = {}) const; Result<int> getTransmissionDelayLeft(Positions pos = {}) const;
/** /**[Eiger] Transmission delay of first packet in an image being streamed out
* [Eiger] * of the module's left UDP port. Each value represents 10ns. Typical value
* Sets the transmission delay of first packet streamed out of the left UDP * is 50000.
* port
*/ */
void setTransmissionDelayLeft(int value, Positions pos = {}); void setTransmissionDelayLeft(int value, Positions pos = {});
/** [Eiger] */ /** [Eiger] Transmission delay of first packet in an image being streamed
* out of the module's right UDP port. Each value represents 10ns. Typical
* value is 50000. */
Result<int> getTransmissionDelayRight(Positions pos = {}) const; Result<int> getTransmissionDelayRight(Positions pos = {}) const;
/** /**
@ -679,7 +693,7 @@ class Detector {
Result<int> getRxFifoDepth(Positions pos = {}) const; Result<int> getRxFifoDepth(Positions pos = {}) const;
/** fifo between udp listening and processing threads */ /** Number of frames in fifo between udp listening and processing threads */
void setRxFifoDepth(int nframes, Positions pos = {}); void setRxFifoDepth(int nframes, Positions pos = {});
Result<bool> getRxSilentMode(Positions pos = {}) const; Result<bool> getRxSilentMode(Positions pos = {}) const;
@ -724,6 +738,9 @@ class Detector {
/** Client IP Address that last communicated with the receiver */ /** Client IP Address that last communicated with the receiver */
Result<sls::IpAddr> getRxLastClientIP(Positions pos = {}) const; Result<sls::IpAddr> getRxLastClientIP(Positions pos = {}) const;
/** Get thread ids from the receiver in order of [parent, tcp, listener 0,
* processor 0, streamer 0, listener 1, processor 1, streamer 1]. If no
* streamer yet or there is no second interface, it gives 0 in its place. */
Result<std::array<pid_t, NUM_RX_THREAD_IDS>> Result<std::array<pid_t, NUM_RX_THREAD_IDS>>
getRxThreadIds(Positions pos = {}) const; getRxThreadIds(Positions pos = {}) const;
///@{ ///@{
@ -743,7 +760,7 @@ class Detector {
Result<std::string> getFilePath(Positions pos = {}) const; Result<std::string> getFilePath(Positions pos = {}) const;
/** If path does not exist, it will try to create it */ /** Default is "/"If path does not exist, it will try to create it */
void setFilePath(const std::string &fpath, Positions pos = {}); void setFilePath(const std::string &fpath, Positions pos = {});
Result<std::string> getFileNamePrefix(Positions pos = {}) const; Result<std::string> getFileNamePrefix(Positions pos = {}) const;
@ -756,7 +773,10 @@ class Detector {
Result<int64_t> getAcquisitionIndex(Positions pos = {}) const; Result<int64_t> getAcquisitionIndex(Positions pos = {}) const;
/** file or Acquisition index in receiver */ /** file or Acquisition index in receiver \n
* File name: [file name prefix]_d[detector index]_f[sub file
* index]_[acquisition/file index].[raw/h5].
*/
void setAcquisitionIndex(int64_t i, Positions pos = {}); void setAcquisitionIndex(int64_t i, Positions pos = {});
Result<bool> getFileWrite(Positions pos = {}) const; Result<bool> getFileWrite(Positions pos = {}) const;
@ -764,10 +784,10 @@ class Detector {
/** default enabled */ /** default enabled */
void setFileWrite(bool value, Positions pos = {}); void setFileWrite(bool value, Positions pos = {});
Result<bool> getMasterFileWrite(Positions pos = {}) const; bool getMasterFileWrite() const;
/**default enabled */ /**default enabled */
void setMasterFileWrite(bool value, Positions pos = {}); void setMasterFileWrite(bool value);
Result<bool> getFileOverWrite(Positions pos = {}) const; Result<bool> getFileOverWrite(Positions pos = {}) const;
@ -776,8 +796,8 @@ class Detector {
Result<int> getFramesPerFile(Positions pos = {}) const; Result<int> getFramesPerFile(Positions pos = {}) const;
/** Default depends on detector type. \n 0 will set frames per file to /** Default depends on detector type. \n 0 will set frames per file in an
* unlimited */ * acquisition to unlimited */
void setFramesPerFile(int n, Positions pos = {}); void setFramesPerFile(int n, Positions pos = {});
///@{ ///@{
@ -861,9 +881,10 @@ class Detector {
Result<IpAddr> getClientZmqIp(Positions pos = {}) const; Result<IpAddr> getClientZmqIp(Positions pos = {}) const;
/** Ip Address to listen to zmq data streamed out from receiver or /** Ip Address to listen to zmq data streamed out from receiver or
* intermediate process. Default connects to receiver zmq Ip Address (from * intermediate process. \n Default connects to receiver zmq Ip Address
* rx_hostname). Modified only when using an intermediate process between * (from rx_hostname). \n Modified only when using an intermediate process
* receiver and client(gui). Also restarts client zmq streaming if enabled. * between receiver and client(gui). \n Also restarts client zmq streaming
* if enabled.
*/ */
void setClientZmqIp(const IpAddr ip, Positions pos = {}); void setClientZmqIp(const IpAddr ip, Positions pos = {});
///@{ ///@{
@ -911,7 +932,7 @@ class Detector {
/** [Eiger] */ /** [Eiger] */
Result<bool> getBottom(Positions pos = {}) const; Result<bool> getBottom(Positions pos = {}) const;
/** [Eiger] for client call back (gui) purposes */ /** [Eiger] for client call back (gui) purposes to flip bottom image */
void setBottom(bool value, Positions pos = {}); void setBottom(bool value, Positions pos = {});
/**[Eiger] Returns energies in eV where the module is trimmed */ /**[Eiger] Returns energies in eV where the module is trimmed */
@ -937,8 +958,8 @@ class Detector {
Result<int> getPartialReadout(Positions pos = {}) const; Result<int> getPartialReadout(Positions pos = {}) const;
/** [Eiger] Number of lines to read out per half module /** [Eiger] Number of lines to read out per half module
* Options: 0 - 256. Depending on dynamic range and * Options: 0 - 256. 256 is default. The permissible values depend on
* 10 GbE enabled, only specific values are accepted. * dynamic range and 10Gbe enabled.
*/ */
void setPartialReadout(const int lines, Positions pos = {}); void setPartialReadout(const int lines, Positions pos = {});
@ -959,13 +980,14 @@ class Detector {
/** [Eiger] */ /** [Eiger] */
Result<bool> getActive(Positions pos = {}) const; Result<bool> getActive(Positions pos = {}) const;
/** [Eiger] */ /** [Eiger] activated by default at hostname command. Deactivated does not
* send data or communicated with FEB or BEB */
void setActive(const bool active, Positions pos = {}); void setActive(const bool active, Positions pos = {});
/** [Eiger] */ /** [Eiger] */
Result<bool> getRxPadDeactivatedMode(Positions pos = {}) const; Result<bool> getRxPadDeactivatedMode(Positions pos = {}) const;
/** [Eiger] Pad deactivated modules in receiver */ /** [Eiger] Pad deactivated modules in receiver. Enabled by default */
void setRxPadDeactivatedMode(bool pad, Positions pos = {}); void setRxPadDeactivatedMode(bool pad, Positions pos = {});
/** [Eiger] Advanced */ /** [Eiger] Advanced */
@ -984,13 +1006,16 @@ class Detector {
void pulsePixelNMove(int n, defs::xy pixel, Positions pos = {}); void pulsePixelNMove(int n, defs::xy pixel, Positions pos = {});
/** [Eiger] Advanced /** [Eiger] Advanced
* Pulse chip n times */ * Pulse chip n times. \n
* If n is -1, resets to normal mode (reset chip completely at start of
* acquisition, where partialreset = 0). */
void pulseChip(int n, Positions pos = {}); void pulseChip(int n, Positions pos = {});
/** [Eiger] with specific quad hardware */ /** [Eiger] with specific quad hardware */
Result<bool> getQuad(Positions pos = {}) const; Result<bool> getQuad(Positions pos = {}) const;
/** [Eiger] with specific quad hardware */ /** [Eiger] Sets detector size to a quad. 0 (disabled) is default. (Specific
* hardware required). */
void setQuad(const bool enable); void setQuad(const bool enable);
///@{ ///@{
@ -1006,12 +1031,12 @@ class Detector {
Result<int> getThresholdTemperature(Positions pos = {}) const; Result<int> getThresholdTemperature(Positions pos = {}) const;
/** /**
* [Jungfrau]Set threshold temperature * [Jungfrau]Set threshold temperature in degrees.
* If temperature crosses threshold temperature * If temperature crosses threshold temperature
* and temperature control is enabled (default is disabled), power to chip * and temperature control is enabled (default is disabled), power to chip
* will be switched off and temperature event will be set. \n To power on * will be switched off and temperature event will be set. \n To power on
* chip again, temperature has to be less than threshold temperature and * chip again, temperature has to be less than threshold temperature and
* temperature event has to be cleared. val is value in degrees * temperature event has to be cleared.
*/ */
void setThresholdTemperature(int temp, Positions pos = {}); void setThresholdTemperature(int temp, Positions pos = {});
@ -1038,7 +1063,7 @@ class Detector {
* automatically after 93.75% of exposure time (only for longer than * automatically after 93.75% of exposure time (only for longer than
* 100us).\n * 100us).\n
* Default is false or this mode disabled(comparator enabled throughout). * Default is false or this mode disabled(comparator enabled throughout).
* true enables " "mode. 0 disables mode. * true enables mode. 0 disables mode.
*/ */
void setAutoCompDisable(bool value, Positions pos = {}); void setAutoCompDisable(bool value, Positions pos = {});
@ -1061,8 +1086,9 @@ class Detector {
/** [Jungfrau] Advanced*/ /** [Jungfrau] Advanced*/
Result<ns> getStorageCellDelay(Positions pos = {}) const; Result<ns> getStorageCellDelay(Positions pos = {}) const;
/** [Jungfrau] Advanced \n /** [Jungfrau] Advanced \n Additional time delay between 2 consecutive
* Options: (0-1638375 ns (resolution of 25ns) */ * exposures in burst mode. \n Options: (0-1638375 ns (resolution of 25ns)
*/
void setStorageCellDelay(ns value, Positions pos = {}); void setStorageCellDelay(ns value, Positions pos = {});
///@{ ///@{
@ -1078,14 +1104,15 @@ class Detector {
Result<defs::ROI> getROI(Positions pos = {}) const; Result<defs::ROI> getROI(Positions pos = {}) const;
/** /**
* [Gotthard] * [Gotthard] Region of interest in detector \n
* Options: Only a single ROI per module * Options: Only a single ROI per module \n
* Can set only a single ROI at a time * Either all channels or a single adc or 2 chips (256 channels). Default is
* module_id is position index * all channels enabled (-1 -1). \n module_id is position index
*/ */
void setROI(defs::ROI value, int module_id); void setROI(defs::ROI value, int module_id);
/** [Gotthard] Clear ROI */ /** [Gotthard] Clear ROI to all channels enabled. Default is all channels
* enabled. */
void clearROI(Positions pos = {}); void clearROI(Positions pos = {});
/** [Gotthard] */ /** [Gotthard] */
@ -1109,13 +1136,18 @@ class Detector {
/** [Gotthard2] only in burst mode and auto timing mode */ /** [Gotthard2] only in burst mode and auto timing mode */
Result<ns> getBurstPeriod(Positions pos = {}) const; Result<ns> getBurstPeriod(Positions pos = {}) const;
/** [Gotthard2] only in burst mode and auto timing mode */ /** [Gotthard2] Period between 2 bursts. Only in burst mode and auto timing
* mode */
void setBurstPeriod(ns value, Positions pos = {}); void setBurstPeriod(ns value, Positions pos = {});
/** [Gotthard2] only in burst auto mode */
Result<int64_t> getNumberOfBurstsLeft(Positions pos = {}) const;
/** [Gotthard2] offset channel, increment channel */ /** [Gotthard2] offset channel, increment channel */
Result<std::array<int, 2>> getInjectChannel(Positions pos = {}); Result<std::array<int, 2>> getInjectChannel(Positions pos = {});
/** [Gotthard2] /** [Gotthard2]
* Inject channels with current source for calibration.
* offsetChannel is starting channel to be injected * offsetChannel is starting channel to be injected
* incrementChannel is determines succeeding channels to be injected */ * incrementChannel is determines succeeding channels to be injected */
void setInjectChannel(const int offsetChannel, const int incrementChannel, void setInjectChannel(const int offsetChannel, const int incrementChannel,
@ -1130,11 +1162,12 @@ class Detector {
const int energy, const std::string &fname, const int energy, const std::string &fname,
Positions pos = {}); Positions pos = {});
/** [Gotthard2] */ /** [Gotthard2] for all chips */
void setVetoReference(const int gainIndex, const int value, void setVetoReference(const int gainIndex, const int value,
Positions pos = {}); Positions pos = {});
/** [Gotthard2] gain indices and adu values for each channel */ /** [Gotthard2] Set veto reference for each 128 channels for specific chip.
* The file should have 128 rows of gain index and 12 bit value in dec"*/
void setVetoFile(const int chipIndex, const std::string &fname, void setVetoFile(const int chipIndex, const std::string &fname,
Positions pos = {}); Positions pos = {});
@ -1154,7 +1187,7 @@ class Detector {
/** [Gotthard2] */ /** [Gotthard2] */
Result<int> getFilter(Positions pos = {}) const; Result<int> getFilter(Positions pos = {}) const;
/** default 0 */ /** [Gotthard2] Set filter resister. Options: 0-3. Default: 0 */
void setFilter(int value, Positions pos = {}); void setFilter(int value, Positions pos = {});
/** [Gotthard2] */ /** [Gotthard2] */
@ -1166,7 +1199,7 @@ class Detector {
/** [Gotthard2] */ /** [Gotthard2] */
Result<defs::timingSourceType> getTimingSource(Positions pos = {}) const; Result<defs::timingSourceType> getTimingSource(Positions pos = {}) const;
/** [Gotthard2] Options: TIMING_INTERNAL, TIMING_EXTERNAL */ /** [Gotthard2] Options: TIMING_INTERNAL (default), TIMING_EXTERNAL */
void setTimingSource(defs::timingSourceType value, Positions pos = {}); void setTimingSource(defs::timingSourceType value, Positions pos = {});
/** [Gotthard2] */ /** [Gotthard2] */
@ -1179,7 +1212,8 @@ class Detector {
Result<int> getADCConfiguration(const int chipIndex, const int adcIndex, Result<int> getADCConfiguration(const int chipIndex, const int adcIndex,
Positions pos = {}) const; Positions pos = {}) const;
/** [Gotthard2] */ /** [Gotthard2] configures one chip at a time for specific adc, chipIndex
* and adcIndex is -1 for all */
void setADCConfiguration(const int chipIndex, const int adcIndex, void setADCConfiguration(const int chipIndex, const int adcIndex,
const int value, Positions pos = {}); const int value, Positions pos = {});
@ -1288,7 +1322,8 @@ class Detector {
/** [CTB][Moench] */ /** [CTB][Moench] */
Result<uint32_t> getTenGigaADCEnableMask(Positions pos = {}) const; Result<uint32_t> getTenGigaADCEnableMask(Positions pos = {}) const;
/** [CTB][Moench] */ /** [CTB][Moench] If any of a consecutive 4 bits are enabled, the "
"complete 4 bits are enabled */
void setTenGigaADCEnableMask(uint32_t mask, Positions pos = {}); void setTenGigaADCEnableMask(uint32_t mask, Positions pos = {});
///@{ ///@{
@ -1309,7 +1344,8 @@ class Detector {
/** [CTB] */ /** [CTB] */
Result<defs::readoutMode> getReadoutMode(Positions pos = {}) const; Result<defs::readoutMode> getReadoutMode(Positions pos = {}) const;
/** [CTB] Options: ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL */ /** [CTB] Options: ANALOG_ONLY (default), DIGITAL_ONLY, ANALOG_AND_DIGITAL
*/
void setReadoutMode(defs::readoutMode value, Positions pos = {}); void setReadoutMode(defs::readoutMode value, Positions pos = {});
/** [CTB] */ /** [CTB] */
@ -1342,13 +1378,13 @@ class Detector {
/** [CTB] */ /** [CTB] */
Result<int> getExternalSamplingSource(Positions pos = {}) const; Result<int> getExternalSamplingSource(Positions pos = {}) const;
/** [CTB] Value between 0-63 */ /** [CTB] Value between 0-63 \n For advanced users only.*/
void setExternalSamplingSource(int value, Positions pos = {}); void setExternalSamplingSource(int value, Positions pos = {});
/** [CTB] */ /** [CTB] */
Result<bool> getExternalSampling(Positions pos = {}) const; Result<bool> getExternalSampling(Positions pos = {}) const;
/** [CTB] */ /** [CTB] For advanced users only. */
void setExternalSampling(bool value, Positions pos = {}); void setExternalSampling(bool value, Positions pos = {});
/** [CTB] */ /** [CTB] */
@ -1387,10 +1423,12 @@ class Detector {
* * * *
* ************************************************/ * ************************************************/
/** [CTB][Moench][Mythen3] */ /** [CTB][Moench][Mythen3] Loads ASCII pattern file directly to server
* (instead of executing line by line)*/
void setPattern(const std::string &fname, Positions pos = {}); void setPattern(const std::string &fname, Positions pos = {});
/** [CTB][Moench][Mythen3] */ /** [CTB][Moench][Mythen3] [Ctb][Moench][Mythen3] Saves pattern to file
* (ascii). \n [Ctb][Moench] Also executes pattern.*/
void savePattern(const std::string &fname); void savePattern(const std::string &fname);
/** [CTB][Moench] */ /** [CTB][Moench] */
@ -1402,9 +1440,9 @@ class Detector {
/** [CTB][Moench][Mythen3] same as executing for ctb and moench */ /** [CTB][Moench][Mythen3] same as executing for ctb and moench */
Result<uint64_t> getPatternWord(int addr, Positions pos = {}); Result<uint64_t> getPatternWord(int addr, Positions pos = {});
/** [CTB] Caution: If word is -1 reads the addr (same as /** [CTB][Moench] Caution: If word is -1 reads the addr (same as
* executing the pattern) * executing the pattern)
* [Mythen3][Moench] */ * [Mythen3] */
void setPatternWord(int addr, uint64_t word, Positions pos = {}); void setPatternWord(int addr, uint64_t word, Positions pos = {});
/**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2 /**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2
@ -1420,9 +1458,7 @@ class Detector {
Positions pos = {}); Positions pos = {});
/**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2 /**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2
* levels * levels */
* @returns number of loops
*/
Result<int> getPatternLoopCycles(int level, Positions pos = {}) const; Result<int> getPatternLoopCycles(int level, Positions pos = {}) const;
/** [CTB][Moench][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2 /** [CTB][Moench][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2
@ -1471,8 +1507,10 @@ class Detector {
Result<std::map<std::string, std::string>> Result<std::map<std::string, std::string>>
getAdditionalJsonHeader(Positions pos = {}) const; getAdditionalJsonHeader(Positions pos = {}) const;
/** [Moench] If empty, reset additional json header. Max 20 characters for /** [Moench] If empty, reset additional json header. Default is empty. Max
* each key/value */ * 20 characters for each key/value. Empty value deletes header. Use only if
* to be processed by an intermediate user process listening to receiver zmq
* packets such as in Moench */
void setAdditionalJsonHeader( void setAdditionalJsonHeader(
const std::map<std::string, std::string> &jsonHeader, const std::map<std::string, std::string> &jsonHeader,
Positions pos = {}); Positions pos = {});
@ -1482,9 +1520,9 @@ class Detector {
Positions pos = {}) const; Positions pos = {}) const;
/** /**
* [Moench] * [Moench]
* Sets the value for additional json header parameters if found, * Sets the value for additional json header parameters. If not found,
* else appends the parameter key and value * the pair is appended. Empty value deletes parameter. Max 20 characters
* If empty, deletes parameter. Max 20 characters for each key/value * for each key/value.
*/ */
void setAdditionalJsonParameter(const std::string &key, void setAdditionalJsonParameter(const std::string &key,
const std::string &value, const std::string &value,
@ -1500,8 +1538,9 @@ class Detector {
* ************************************************/ * ************************************************/
/** Advanced user Function! /** Advanced user Function!
* [Jungfrau][CTB][Moench] fname is a pof file * [Jungfrau][CTB][Moench] fname is a pof file, rebooting the controller is
* [Mythen3][Gotthard2] fname is an rbf file * recommended \n [Mythen3][Gotthard2] fname is an rbf file, power cycling
* the detector is recommended
*/ */
void programFPGA(const std::string &fname, Positions pos = {}); void programFPGA(const std::string &fname, Positions pos = {});
@ -1509,9 +1548,10 @@ class Detector {
void resetFPGA(Positions pos = {}); void resetFPGA(Positions pos = {});
/** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2] /** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2]
* Advanced user Function! * Advanced user Function! \n
* Copy detector server fname from tftp folder of hostname to detector * Copy detector server fname from tftp folder of hostname to detector \n
* Also changes respawn server, which is effective after a reboot. * [Jungfrau][Gotthard][CTB][Moench] Also changes respawn server, which is
* effective after a reboot.
*/ */
void copyDetectorServer(const std::string &fname, void copyDetectorServer(const std::string &fname,
const std::string &hostname, Positions pos = {}); const std::string &hostname, Positions pos = {});
@ -1521,25 +1561,27 @@ class Detector {
void rebootController(Positions pos = {}); void rebootController(Positions pos = {});
/** /**
* [Jungfrau][Gotthard][CTB][Moench] * Advanced user Function!\n [Jungfrau][Gotthard][CTB][Moench] Updates the
* Advanced user Function! * firmware, detector server and then reboots detector controller blackfin.
* Updates the firmware, detector server and then reboots detector * \n [Mythen3][Gotthard2] Will still have old server starting up as the new
* controller blackfin. * server is not respawned \n sname is name of detector server binary found
* sname is name of detector server binary found on tftp folder of host * on tftp folder of host pc \n hostname is name of pc to tftp from \n fname
* pc * is programming file name
* hostname is name of pc to tftp from
* fname is programming file name
*/ */
void updateFirmwareAndServer(const std::string &sname, void updateFirmwareAndServer(const std::string &sname,
const std::string &hostname, const std::string &hostname,
const std::string &fname, Positions pos = {}); const std::string &fname, Positions pos = {});
/** Advanced user Function! \n /** Advanced user Function! \n
* [Eiger] Address is +0x100 for only left, +0x200 for only right. */ * Goes to stop server. Hence, can be called while calling blocking
* acquire(). \n [Eiger] Address is +0x100 for only left, +0x200 for only
* right. */
Result<uint32_t> readRegister(uint32_t addr, Positions pos = {}) const; Result<uint32_t> readRegister(uint32_t addr, Positions pos = {}) const;
/** Advanced user Function! \n /** Advanced user Function! \n
* [Eiger] Address is +0x100 for only left, +0x200 for only right. */ * Goes to stop server. Hence, can be called while calling blocking
* acquire(). \n [Eiger] Address is +0x100 for only left, +0x200 for only
* right. */
void writeRegister(uint32_t addr, uint32_t val, Positions pos = {}); void writeRegister(uint32_t addr, uint32_t val, Positions pos = {});
/** Advanced user Function! */ /** Advanced user Function! */
@ -1548,12 +1590,16 @@ class Detector {
/** Advanced user Function! */ /** Advanced user Function! */
void clearBit(uint32_t addr, int bitnr, Positions pos = {}); void clearBit(uint32_t addr, int bitnr, Positions pos = {});
/** Advanced user Function! */
Result<int> getBit(uint32_t addr, int bitnr, Positions pos = {});
/** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Advanced user /** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Advanced user
* Function! */ * Function! */
void executeFirmwareTest(Positions pos = {}); void executeFirmwareTest(Positions pos = {});
/** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Advanced user /** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Advanced user
* Function! */ * Function! Writes different values in a R/W register and confirms the
* writes to check bus */
void executeBusTest(Positions pos = {}); void executeBusTest(Positions pos = {});
/** [Gotthard][Jungfrau][CTB][Moench] Advanced user Function! not possible /** [Gotthard][Jungfrau][CTB][Moench] Advanced user Function! not possible
@ -1563,14 +1609,17 @@ class Detector {
/** Advanced user Function! */ /** Advanced user Function! */
bool getInitialChecks() const; bool getInitialChecks() const;
/** initial compaibility and other server start up checks /** Enables/disabled initial compaibility and other server start up checks.
* default enabled Advanced user Function! */ * \n Default is enabled. Must come before 'hostname' command to take
* effect. \n Can be used to reprogram fpga when current firmware is
* incompatible. \n Advanced user Function! */
void setInitialChecks(const bool value); void setInitialChecks(const bool value);
/** [CTB][Moench][Jungfrau] Advanced user Function! */ /** [CTB][Moench][Jungfrau] Advanced user Function! */
Result<uint32_t> getADCInvert(Positions pos = {}) const; Result<uint32_t> getADCInvert(Positions pos = {}) const;
/** [CTB][Moench][Jungfrau] Advanced user Function! */ /** [CTB][Moench][Jungfrau] Advanced user Function! \n
[Jungfrau] Inversions on top of default mask */
void setADCInvert(uint32_t value, Positions pos = {}); void setADCInvert(uint32_t value, Positions pos = {});
///@{ ///@{
@ -1585,13 +1634,14 @@ class Detector {
Result<int> getControlPort(Positions pos = {}) const; Result<int> getControlPort(Positions pos = {}) const;
/** Detector Control TCP port (for client communication with Detector /** Detector Control TCP port (for client communication with Detector
* control server) */ * control server) Default is 1952. Normally unchanged. Set different ports
* for virtual servers on same pc */
void setControlPort(int value, Positions pos = {}); void setControlPort(int value, Positions pos = {});
Result<int> getStopPort(Positions pos = {}) const; Result<int> getStopPort(Positions pos = {}) const;
/** Detector Stop TCP port (for client communication with Detector Stop /** Port number of the stop server on detector for detector-client tcp
* server) */ * interface. Default is 1953. Normally unchanged. */
void setStopPort(int value, Positions pos = {}); void setStopPort(int value, Positions pos = {});
Result<bool> getDetectorLock(Positions pos = {}) const; Result<bool> getDetectorLock(Positions pos = {}) const;
@ -1599,7 +1649,7 @@ class Detector {
/** lock detector to one client IP. default is unlocked */ /** lock detector to one client IP. default is unlocked */
void setDetectorLock(bool lock, Positions pos = {}); void setDetectorLock(bool lock, Positions pos = {});
/** Get last client IP saved on detector server */ /** Client IP Address that last communicated with the detector */
Result<sls::IpAddr> getLastClientIP(Positions pos = {}) const; Result<sls::IpAddr> getLastClientIP(Positions pos = {}) const;
/** Execute a command on the detector server console */ /** Execute a command on the detector server console */
@ -1611,11 +1661,11 @@ class Detector {
Result<int64_t> getNumberOfFramesFromStart(Positions pos = {}) const; Result<int64_t> getNumberOfFramesFromStart(Positions pos = {}) const;
/** [Jungfrau][Mythen3][CTB][Moench] Get time from detector start /** [Jungfrau][Mythen3][CTB][Moench] Get time from detector start
* [Gotthard2] only in continuous mode */ * [Gotthard2] not in burst and auto mode */
Result<ns> getActualTime(Positions pos = {}) const; Result<ns> getActualTime(Positions pos = {}) const;
/** [Jungfrau][Mythen3][CTB][Moench] Get timestamp at a frame start /** [Jungfrau][Mythen3][CTB][Moench] Get timestamp at a frame start
* [Gotthard2] only in continuous mode */ * [Gotthard2] not in burst and auto mode */
Result<ns> getMeasurementTime(Positions pos = {}) const; Result<ns> getMeasurementTime(Positions pos = {}) const;
/** get user details from shared memory (hostname, type, PID, User, Date) /** get user details from shared memory (hostname, type, PID, User, Date)

View File

@ -1,4 +1,5 @@
#include "CmdProxy.h" #include "CmdProxy.h"
#include "HelpDacs.h"
#include "TimeHelper.h" #include "TimeHelper.h"
#include "ToString.h" #include "ToString.h"
#include "bit_utils.h" #include "bit_utils.h"
@ -33,7 +34,11 @@ void CmdProxy::Call(const std::string &command,
args = arguments; args = arguments;
det_id = detector_id; det_id = detector_id;
std::string temp;
while (temp != cmd) {
temp = cmd;
ReplaceIfDepreciated(cmd); ReplaceIfDepreciated(cmd);
}
auto it = functions.find(cmd); auto it = functions.find(cmd);
if (it != functions.end()) { if (it != functions.end()) {
@ -51,6 +56,10 @@ bool CmdProxy::ReplaceIfDepreciated(std::string &command) {
<< command << command
<< " is depreciated and will be removed. Please migrate to: " << " is depreciated and will be removed. Please migrate to: "
<< d_it->second; << d_it->second;
// insert old command into arguments (for dacs)
if (d_it->second == "dac") {
args.insert(args.begin(), command);
}
command = d_it->second; command = d_it->second;
return true; return true;
} }
@ -122,7 +131,9 @@ std::string CmdProxy::Hostname(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "\n\tFrees shared memory and sets hostname (or IP address) of " os << "\n\tFrees shared memory and sets hostname (or IP address) of "
"all modules concatenated by +." "all modules concatenated by +.\n\t Virtual servers can already "
"use the port in hostname separated by ':' and ports incremented "
"by 2 to accomodate the stop server as well."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (!args.empty()) { if (!args.empty()) {
@ -159,7 +170,8 @@ std::string CmdProxy::VirtualServer(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[n_servers] [starting_port_number]\n\tConnecs to n virtual " os << "[n_servers] [starting_port_number]\n\tConnecs to n virtual "
"server at local host starting at specific control port." "server at local host starting at specific control port. Every "
"virtual server will have a stop port (control port + 1)"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("cannot get"); throw sls::RuntimeError("cannot get");
@ -220,8 +232,8 @@ std::string CmdProxy::FirmwareVersion(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "\n\tFimware version of detector in format [0xYYMMDD] or integer " os << "\n\tFimware version of detector in format [0xYYMMDD] or an "
"for Eiger." "increasing 2 digit number for Eiger."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (!args.empty()) { if (!args.empty()) {
@ -315,9 +327,9 @@ std::string CmdProxy::DetectorSize(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[nx] [ny]\n\tDetector size, ie. Number of channels in x and y " os << "[nx] [ny]\n\tDetector size, ie. Number of channels in x and y "
"dim. If 0, then hostname adds all modules in y dim. This is " "dim. This is used to calculate module coordinates included in "
"used to calculate module coordinates included in UDP data " "UDP data. \n\tBy default, it adds module in y dimension for 2d "
"packet header." "detectors and in x dimension for 1d detectors packet header."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (!args.empty()) { if (!args.empty()) {
@ -480,7 +492,8 @@ std::string CmdProxy::DynamicRange(int action) {
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[value]\n\tDynamic Range or number of bits per " os << "[value]\n\tDynamic Range or number of bits per "
"pixel in detector.\n\t" "pixel in detector.\n\t"
"[Eiger] Options: 4, 8, 16, 32\n\t" "[Eiger] Options: 4, 8, 16, 32. If set to 32, also sets "
"clkdivider to 2, else to 0.\n\t"
"[Mythen3] Options: 8, 16, 32\n\t" "[Mythen3] Options: 8, 16, 32\n\t"
"[Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16" "[Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16"
<< '\n'; << '\n';
@ -699,13 +712,7 @@ std::string CmdProxy::ClockFrequency(int action) {
std::vector<int>{det_id}); std::vector<int>{det_id});
os << OutString(t) << '\n'; os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (args.size() != 2) { throw sls::RuntimeError("cannot put");
WrongNumberOfParameters(2);
}
det->setClockFrequency(StringTo<int>(args[0]),
StringTo<int>(args[1]),
std::vector<int>{det_id});
os << StringTo<int>(args[1]) << '\n';
} else { } else {
throw sls::RuntimeError("Unknown action"); throw sls::RuntimeError("Unknown action");
} }
@ -844,7 +851,7 @@ std::string CmdProxy::ExternalSignal(int action) {
"[trigger_in_rising_edge|trigger_in_falling_edge|inversion_on|" "[trigger_in_rising_edge|trigger_in_falling_edge|inversion_on|"
"inversion_off]\n\t where 0 is master input trigger signal, 1-3 " "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 " "is master input gate signals, 4 is busy out signal and 5-7 is "
"master output gate signals" "master output gate signals."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 1) { if (args.size() != 1) {
@ -907,45 +914,59 @@ std::string CmdProxy::TemperatureValues(int action) {
std::string CmdProxy::Dac(int action) { std::string CmdProxy::Dac(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[dac index] [dac or mV value] [(optional unit) mV] " // dac indices only for ctb
"\n\t[Ctb] Dac." if (args.size() > 0 && action != defs::HELP_ACTION) {
<< '\n'; if (is_int(args[0]) &&
} else if (det->getDetectorType().squash(defs::GENERIC) != det->getDetectorType().squash() != defs::CHIPTESTBOARD) {
defs::CHIPTESTBOARD) {
throw sls::RuntimeError( throw sls::RuntimeError(
"Dac command can only be used for chip test board. Use daclist to " "Dac indices can only be used for chip test board. Use daclist "
"get list of dac commands for current detector."); "to get list of dac names for current detector.");
}
}
if (action == defs::HELP_ACTION) {
if (args.size() == 0) {
os << GetHelpDac(std::to_string(0)) << '\n';
} else {
os << args[0] << ' ' << GetHelpDac(args[0]) << '\n';
}
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
bool mv = false; if (args.empty())
WrongNumberOfParameters(1); // This prints slightly wrong
defs::dacIndex dacIndex = StringTo<defs::dacIndex>(args[0]);
bool mV = false;
if (args.size() == 2) { if (args.size() == 2) {
if ((args[1] != "mv") && (args[1] != "mV")) { if ((args[1] != "mv") && (args[1] != "mV")) {
throw sls::RuntimeError("Unknown argument " + args[1] + throw sls::RuntimeError("Unknown argument " + args[1] +
". Did you mean mV?"); ". Did you mean mV?");
} }
mv = true; mV = true;
} else if (args.size() > 2) { } else if (args.size() > 2) {
WrongNumberOfParameters(1); WrongNumberOfParameters(1);
} }
auto t = auto t = det->getDAC(dacIndex, mV, std::vector<int>{det_id});
det->getDAC(static_cast<defs::dacIndex>(StringTo<int>(args[0])), mv, os << args[0] << ' ' << OutString(t) << (mV ? " mV\n" : "\n");
std::vector<int>{det_id});
os << args[0] << ' ' << OutString(t)
<< (args.size() > 1 ? " mV\n" : "\n");
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
bool mv = false; if (args.empty())
WrongNumberOfParameters(1); // This prints slightly wrong
defs::dacIndex dacIndex = StringTo<defs::dacIndex>(args[0]);
bool mV = false;
if (args.size() == 3) { if (args.size() == 3) {
if ((args[2] != "mv") && (args[2] != "mV")) { if ((args[2] != "mv") && (args[2] != "mV")) {
throw sls::RuntimeError("Unknown argument " + args[2] + throw sls::RuntimeError("Unknown argument " + args[2] +
". Did you mean mV?"); ". Did you mean mV?");
} }
mv = true; mV = true;
} else if (args.size() > 3 || args.size() < 2) { } else if (args.size() > 3 || args.size() < 2) {
WrongNumberOfParameters(2); WrongNumberOfParameters(2);
} }
det->setDAC(static_cast<defs::dacIndex>(StringTo<int>(args[0])), det->setDAC(dacIndex, StringTo<int>(args[1]), mV,
StringTo<int>(args[1]), mv, std::vector<int>{det_id}); std::vector<int>{det_id});
os << args[0] << ' ' << args[1] << (args.size() > 2 ? " mV\n" : "\n"); os << args[0] << ' ' << args[1] << (mV ? " mV\n" : "\n");
} else { } else {
throw sls::RuntimeError("Unknown action"); throw sls::RuntimeError("Unknown action");
} }
@ -1018,7 +1039,7 @@ std::string CmdProxy::DetectorStatus(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[running, error, transmitting, finished, waiting, " os << "[running, error, transmitting, finished, waiting, "
"idle]\n\tDetector status." "idle]\n\tDetector status. Goes to stop server. "
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (!args.empty()) { if (!args.empty()) {
@ -1040,14 +1061,12 @@ std::string CmdProxy::Scan(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[dac_name|0|trimbit_scan] [start_val] [stop_val] " os << "[dac_name|0|trimbit_scan] [start_val] [stop_val] "
"[step_size] [dac settling time ns|us|ms|s]\n\tConfigures to " "[step_size] [dac settling time ns|us|ms|s]\n\tEnables/ disables "
"scan dac and sets number of frames to number of steps. Must " "scans for dac and trimbits \n\tEnabling scan sets number of "
"acquire after this. \n\tTo cancel the scan configuration " "frames to number of steps in receiver. \n\tTo cancel scan "
"set dac to '0' without further arguments, which also sets " "configuration, set dac to '0', which also sets number of frames "
"number " "to 1. \n\t[Eiger][Mythen3] Use trimbit_scan as dac name for a "
"of frames back to 1." "trimbit scan."
"\n\t[Eiger][Mythen3] Use trimbit_scan as dac name for a trimbit "
"scan."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 0) { if (args.size() != 0) {
@ -1421,7 +1440,7 @@ std::string CmdProxy::PulsePixel(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[n_times] [x] [y]\n\t[Eiger] Pulse pixel n number of times at " os << "[n_times] [x] [y]\n\t[Eiger] Pulse pixel n number of times at "
"coordinates (x, y)." "coordinates (x, y). Advanced User!"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("cannot get"); throw sls::RuntimeError("cannot get");
@ -1446,7 +1465,7 @@ std::string CmdProxy::PulsePixelAndMove(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[n_times] [x] [y]\n\t[Eiger] Pulse pixel n number of times and " os << "[n_times] [x] [y]\n\t[Eiger] Pulse pixel n number of times and "
"moves relatively by (x, y)." "moves relatively by (x, y). Advanced User!"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("cannot get"); throw sls::RuntimeError("cannot get");
@ -1472,7 +1491,7 @@ std::string CmdProxy::PulseChip(int action) {
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[n_times] \n\t[Eiger] Pulse chip n times. If n is -1, resets to " os << "[n_times] \n\t[Eiger] Pulse chip n times. If n is -1, resets to "
"normal mode (reset chip completely at start of acquisition, " "normal mode (reset chip completely at start of acquisition, "
"where partialreset = 0)." "where partialreset = 0). Advanced User!"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("cannot get"); throw sls::RuntimeError("cannot get");
@ -1492,8 +1511,8 @@ std::string CmdProxy::Quad(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[0, 1]\n\t[Eiger] 0 is default. 1 sets detector size to a quad " os << "[0, 1]\n\t[Eiger] Sets detector size to a quad. 0 (disabled) is "
"(Specific hardware required)." "default. (Specific hardware required)."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (!args.empty()) { if (!args.empty()) {
@ -1557,9 +1576,10 @@ std::string CmdProxy::ROI(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[xmin] [xmax] \n\t[Gotthard] Region of interest in detector. " os << "[xmin] [xmax] \n\t[Gotthard] Region of interest in detector.\n\t"
"Either all channels or a single adc or 2 chips (256 channels). " "Options: Only a single ROI per module. \n\tEither all channels "
"Default is all channels enabled (-1 -1). " "or a single adc or 2 chips (256 channels). Default is all "
"channels enabled (-1 -1). "
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (!args.empty()) { if (!args.empty()) {
@ -1590,7 +1610,7 @@ std::string CmdProxy::ClearROI(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "\n\t[Gotthard] Resets Region of interest in detector. All " os << "\n\t[Gotthard] Resets Region of interest in detector. All "
"channels enabled. Default is all channels." "channels enabled. Default is all channels enabled."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get"); throw sls::RuntimeError("Cannot get");
@ -1643,9 +1663,8 @@ std::string CmdProxy::VetoPhoton(int action) {
os << "[ichip] [#photons] [energy in keV] [reference " os << "[ichip] [#photons] [energy in keV] [reference "
"file]\n\t[Gotthard2] Set veto reference for 128 channels for " "file]\n\t[Gotthard2] Set veto reference for 128 channels for "
"chip ichip according to reference file and #photons and energy " "chip ichip according to reference file and #photons and energy "
"in keV.\n\t" "in keV.\n[ichip] [output file]\n\t Get gain indices and veto "
<< "[ichip] [output file]\n\t Get gain indices and veto reference " "reference for 128 channels for chip ichip, saved to file."
"for 128 channels for chip ichip, saved to file."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 2) { if (args.size() != 2) {
@ -1992,7 +2011,7 @@ std::string CmdProxy::SlowAdc(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[n_channel (0-7 for channel]\n\t[Ctb] Slow " os << "[n_channel (0-7 for channel]\n\t[Ctb] Slow "
"ADC channel in mV" "ADC channel in uV"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 1) { if (args.size() != 1) {
@ -2111,8 +2130,8 @@ std::string CmdProxy::PatternWord(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[step or address] [64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 " os << "[step or address] [64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 "
"bit pattern at " "bit pattern at address of pattern memory.\n\t[Ctb][Moench] read "
"address of pattern memory." "is same as executing pattern"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 1) { if (args.size() != 1) {
@ -2357,9 +2376,8 @@ std::string CmdProxy::AdditionalJsonHeader(int action) {
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[key1] [value1] [key2] [value2]...[keyn] [valuen]" os << "[key1] [value1] [key2] [value2]...[keyn] [valuen]"
"\n\tAdditional json header to be streamed out from receiver via " "\n\tAdditional json header to be streamed out from receiver via "
"zmq. " "zmq. Default is empty. Max 20 characters for each key/value. "
"Default is empty. Use only if to be processed by an " "Use only if to be processed by an intermediate user process "
"intermediate user process "
"listening to receiver zmq packets. Empty value deletes header. " "listening to receiver zmq packets. Empty value deletes header. "
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
@ -2393,8 +2411,8 @@ std::string CmdProxy::JsonParameter(int action) {
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[key1] [value1]\n\tAdditional json header parameter streamed " os << "[key1] [value1]\n\tAdditional json header parameter streamed "
"out from receiver. If not found in header, the pair is " "out from receiver. If not found in header, the pair is "
"appended. " "appended. An empty values deletes parameter. Max 20 characters "
"An empty values deletes parameter." "for each key/value."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 1) { if (args.size() != 1) {
@ -2434,8 +2452,10 @@ std::string CmdProxy::ProgramFpga(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[fname.pof | fname.rbf]\n\t[Jungfrau][Ctb][Moench] Programs " os << "[fname.pof | fname.rbf]\n\t[Jungfrau][Ctb][Moench] Programs "
"FPGA from pof file." "FPGA from pof file. Rebooting controller is recommended. "
<< "\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file." << '\n'; "\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file. Power "
"cycling the detector is recommended. "
<< '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get"); throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
@ -2456,10 +2476,9 @@ std::string CmdProxy::CopyDetectorServer(int action) {
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[server_name] " os << "[server_name] "
"[pc_host_name]\n\t[Jungfrau][Ctb][Moench][Mythen3][Gotthard2] " "[pc_host_name]\n\t[Jungfrau][Ctb][Moench][Mythen3][Gotthard2] "
"Copies " "Copies detector server via tftp from pc. "
"detector " "\n\t[Jungfrau][Ctb][Moench]Also changes respawn server, which "
"server via tftp from pc and changes respawn server name in " "is effective after a reboot."
"/etc/inittab of detector."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get"); throw sls::RuntimeError("Cannot get");
@ -2480,9 +2499,13 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[server_name] [pc_host_name] " os << "[server_name] [pc_host_name] "
"[fname.pof]\n\t[Jungfrau][Ctb][Moench] " "[fname.pof]\n\t[Jungfrau][Gotthard][CTB][Moench] Updates the "
"Updates detector server via tftp from pc, updates firmware to " "firmware, detector server and then reboots detector controller "
"pof file and then reboots controller (blackfin)." "blackfin. \n\t[Mythen3][Gotthard2] Will still have old server "
"starting up as the new server is not respawned \n\tsname is "
"name of detector server binary found on tftp folder of host pc "
"\n\thostname is name of pc to tftp from \n\tfname is "
"programming file name"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get"); throw sls::RuntimeError("Cannot get");
@ -2507,8 +2530,9 @@ std::string CmdProxy::Register(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[address] [32 bit value]\n\tReads/writes to a 32 bit register " os << "[address] [32 bit value]\n\tReads/writes to a 32 bit register "
"in hex. Advanced Function!\n\t[Eiger] +0x100 for only left, " "in hex. Advanced Function!\n\tGoes to stop server. Hence, can "
"+0x200 for only right." "be called while calling blocking acquire(). \n\t[Eiger] +0x100 "
"for only left, +0x200 for only right."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 1) { if (args.size() != 1) {
@ -2560,16 +2584,13 @@ std::string CmdProxy::BitOperations(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
if (cmd == "setbit") { if (cmd == "setbit") {
os << "[address] [value\n\t[Moench] Minimum energy threshold (soft " os << "[reg address in hex] [bit index]\n\tSets bit in address."
"setting) for processor."
<< '\n'; << '\n';
} else if (cmd == "clearbit") { } else if (cmd == "clearbit") {
os << "[n_value]\n\t[Moench] Maximum energy threshold (soft " os << "[reg address in hex] [bit index]\n\tClears bit in address."
"setting) for processor."
<< '\n'; << '\n';
} else if (cmd == "getbit") { } else if (cmd == "getbit") {
os << "[n_value]\n\t[Moench] Maximum energy threshold (soft " os << "[reg address in hex] [bit index]\n\tGets bit in address."
"setting) for processor."
<< '\n'; << '\n';
} else { } else {
throw sls::RuntimeError( throw sls::RuntimeError(
@ -2593,12 +2614,8 @@ std::string CmdProxy::BitOperations(int action) {
if (cmd == "setbit" || cmd == "clearbit") { if (cmd == "setbit" || cmd == "clearbit") {
throw sls::RuntimeError("Cannot get"); throw sls::RuntimeError("Cannot get");
} }
auto t = det->readRegister(addr, std::vector<int>{det_id}); auto t = det->getBit(addr, bitnr, std::vector<int>{det_id});
Result<int> result(t.size()); os << OutString(t) << '\n';
for (unsigned int i = 0; i < t.size(); ++i) {
result[i] = ((t[i] >> bitnr) & 0x1);
}
os << OutString(result) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (cmd == "getbit") { if (cmd == "getbit") {
throw sls::RuntimeError("Cannot put"); throw sls::RuntimeError("Cannot put");
@ -2623,7 +2640,8 @@ std::string CmdProxy::InitialChecks(int action) {
os << "[0, 1]\n\tEnable or disable intial compatibility and other " os << "[0, 1]\n\tEnable or disable intial compatibility and other "
"checks at detector start up. It is enabled by default. Must " "checks at detector start up. It is enabled by default. Must "
"come before 'hostname' command to take effect. Can be used to " "come before 'hostname' command to take effect. Can be used to "
"reprogram fpga when current firmware is incompatible." "reprogram fpga when current firmware is "
"incompatible.\n\tAdvanced User function!"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (det_id != -1) { if (det_id != -1) {
@ -2657,7 +2675,8 @@ std::string CmdProxy::ExecuteCommand(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[command]\n\tExecutes command on detector server." << '\n'; os << "[command]\n\tExecutes command on detector server console."
<< '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get."); throw sls::RuntimeError("Cannot get.");
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {

View File

@ -318,46 +318,6 @@
return os.str(); \ return os.str(); \
} }
/** dac */
#define DAC_COMMAND(CMDNAME, GETFCN, SETFCN, DAC_INDEX, HLPSTR) \
std::string CMDNAME(const int action) { \
std::ostringstream os; \
os << cmd << ' '; \
if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \
else if (action == slsDetectorDefs::GET_ACTION) { \
bool mv = false; \
if (args.size() == 1) { \
if ((args[0] != "mv") && (args[0] != "mV")) { \
throw sls::RuntimeError("Unknown argument " + args[0] + \
". Did you mean mV?"); \
} \
mv = true; \
} else if (args.size() > 1) { \
WrongNumberOfParameters(0); \
} \
auto t = det->GETFCN(DAC_INDEX, mv, std::vector<int>{det_id}); \
os << OutString(t) << (!args.empty() ? " mV\n" : "\n"); \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
bool mv = false; \
if (args.size() == 2) { \
if ((args[1] != "mv") && (args[1] != "mV")) { \
throw sls::RuntimeError("Unknown argument " + args[1] + \
". Did you mean mV?"); \
} \
mv = true; \
} else if (args.size() > 2 || args.empty()) { \
WrongNumberOfParameters(1); \
} \
det->SETFCN(DAC_INDEX, StringTo<int>(args[0]), mv, \
std::vector<int>{det_id}); \
os << args.front() << (args.size() > 1 ? " mV\n" : "\n"); \
} else { \
throw sls::RuntimeError("Unknown action"); \
} \
return os.str(); \
}
/** set only, no arguments, no id */ /** set only, no arguments, no id */
#define EXECUTE_SET_COMMAND_NOID(CMDNAME, SETFCN, HLPSTR) \ #define EXECUTE_SET_COMMAND_NOID(CMDNAME, SETFCN, HLPSTR) \
std::string CMDNAME(const int action) { \ std::string CMDNAME(const int action) { \
@ -563,11 +523,16 @@ class CmdProxy {
return ToStringHex(value, width); return ToStringHex(value, width);
} }
template <typename V> std::string OutString(const V &value) { template <typename V> std::string OutString(const sls::Result<V> &value) {
if (value.equal()) if (value.equal())
return ToString(value.front()); return ToString(value.front());
return ToString(value); return ToString(value);
} }
template <typename V> std::string OutString(const V &value) {
return ToString(value);
}
template <typename V> template <typename V>
std::string OutString(const V &value, const std::string &unit) { std::string OutString(const V &value, const std::string &unit) {
if (value.equal()) if (value.equal())
@ -597,6 +562,7 @@ class CmdProxy {
{"detectorversion", "firmwareversion"}, {"detectorversion", "firmwareversion"},
{"softwareversion", "detectorserverversion"}, {"softwareversion", "detectorserverversion"},
{"receiverversion", "rx_version"}, {"receiverversion", "rx_version"},
{"detectornumber", "serialnumber"},
{"thisversion", "clientversion"}, {"thisversion", "clientversion"},
{"detsizechan", "detsize"}, {"detsizechan", "detsize"},
@ -609,7 +575,7 @@ class CmdProxy {
/** temperature */ /** temperature */
/** dacs */ /** super old dacs */
{"vtr", "vtrim"}, {"vtr", "vtrim"},
{"vrf", "vrpreamp"}, {"vrf", "vrpreamp"},
{"vrs", "vrshaper"}, {"vrs", "vrshaper"},
@ -621,6 +587,70 @@ class CmdProxy {
{"viinsh", "vishaper"}, {"viinsh", "vishaper"},
{"vpl", "vcal_n"}, {"vpl", "vcal_n"},
{"vph", "vcal_p"}, {"vph", "vcal_p"},
/** dacs */
{"vthreshold", "dac"},
{"vsvp", "dac"},
{"vsvn", "dac"},
{"vtrim", "dac"},
{"vrpreamp", "dac"},
{"vrshaper", "dac"},
{"vtgstv", "dac"},
{"vcmp_ll", "dac"},
{"vcmp_lr", "dac"},
{"vcal", "dac"},
{"vcmp_rl", "dac"},
{"vcmp_rr", "dac"},
{"rxb_rb", "dac"},
{"rxb_lb", "dac"},
{"vcp", "dac"},
{"vcn", "dac"},
{"vishaper", "dac"},
{"iodelay", "dac"},
{"vref_ds", "dac"},
{"vcascn_pb", "dac"},
{"vcascp_pb", "dac"},
{"vout_cm", "dac"},
{"vcasc_out", "dac"},
{"vin_cm", "dac"},
{"vref_comp", "dac"},
{"ib_test_c", "dac"},
{"vrshaper_n", "dac"},
{"vipre", "dac"},
{"vdcsh", "dac"},
{"vth1", "dac"},
{"vth2", "dac"},
{"vth3", "dac"},
{"vcal_n", "dac"},
{"vcal_p", "dac"},
{"vcassh", "dac"},
{"vcas", "dac"},
{"vicin", "dac"},
{"vipre_out", "dac"},
{"vref_h_adc", "dac"},
{"vb_comp_fe", "dac"},
{"vb_comp_adc", "dac"},
{"vcom_cds", "dac"},
{"vref_rstore", "dac"},
{"vb_opa_1st", "dac"},
{"vref_comp_fe", "dac"},
{"vcom_adc1", "dac"},
{"vref_prech", "dac"},
{"vref_l_adc", "dac"},
{"vref_cds", "dac"},
{"vb_cs", "dac"},
{"vb_opa_fd", "dac"},
{"vcom_adc2", "dac"},
{"adcvpp", "dac"},
{"vb_ds", "dac"},
{"vb_comp", "dac"},
{"vb_pixbuf", "dac"},
{"vin_com", "dac"},
{"vdd_prot", "dac"},
{"vbp_colbuf", "dac"},
{"vb_sda", "dac"},
{"vcasc_sfp", "dac"},
{"vipre_cds", "dac"},
{"ibias_sfp", "dac"},
/* acquisition */ /* acquisition */
{"busy", "clearbusy"}, {"busy", "clearbusy"},
@ -703,7 +733,7 @@ class CmdProxy {
{"firmwareversion", &CmdProxy::FirmwareVersion}, {"firmwareversion", &CmdProxy::FirmwareVersion},
{"detectorserverversion", &CmdProxy::detectorserverversion}, {"detectorserverversion", &CmdProxy::detectorserverversion},
{"rx_version", &CmdProxy::rx_version}, {"rx_version", &CmdProxy::rx_version},
{"detectornumber", &CmdProxy::detectornumber}, {"serialnumber", &CmdProxy::serialnumber},
{"type", &CmdProxy::type}, {"type", &CmdProxy::type},
{"nmod", &CmdProxy::nmod}, {"nmod", &CmdProxy::nmod},
{"detsize", &CmdProxy::DetectorSize}, {"detsize", &CmdProxy::DetectorSize},
@ -758,70 +788,6 @@ class CmdProxy {
{"temp_slowadc", &CmdProxy::temp_slowadc}, {"temp_slowadc", &CmdProxy::temp_slowadc},
/* dacs */ /* dacs */
{"vthreshold", &CmdProxy::vthreshold},
{"vsvp", &CmdProxy::vsvp},
{"vsvn", &CmdProxy::vsvn},
{"vtrim", &CmdProxy::vtrim},
{"vrpreamp", &CmdProxy::vrpreamp},
{"vrshaper", &CmdProxy::vrshaper},
{"vtgstv", &CmdProxy::vtgstv},
{"vcmp_ll", &CmdProxy::vcmp_ll},
{"vcmp_lr", &CmdProxy::vcmp_lr},
{"vcal", &CmdProxy::vcal},
{"vcmp_rl", &CmdProxy::vcmp_rl},
{"vcmp_rr", &CmdProxy::vcmp_rr},
{"rxb_rb", &CmdProxy::rxb_rb},
{"rxb_lb", &CmdProxy::rxb_lb},
{"vcp", &CmdProxy::vcp},
{"vcn", &CmdProxy::vcn},
{"vishaper", &CmdProxy::vishaper},
{"iodelay", &CmdProxy::iodelay},
{"vref_ds", &CmdProxy::vref_ds},
{"vcascn_pb", &CmdProxy::vcascn_pb},
{"vcascp_pb", &CmdProxy::vcascp_pb},
{"vout_cm", &CmdProxy::vout_cm},
{"vcasc_out", &CmdProxy::vcasc_out},
{"vin_cm", &CmdProxy::vin_cm},
{"vref_comp", &CmdProxy::vref_comp},
{"ib_test_c", &CmdProxy::ib_test_c},
{"vrshaper_n", &CmdProxy::vrshaper_n},
{"vipre", &CmdProxy::vipre},
{"vdcsh", &CmdProxy::vdcsh},
{"vth1", &CmdProxy::vth1},
{"vth2", &CmdProxy::vth2},
{"vth3", &CmdProxy::vth3},
{"vcal_n", &CmdProxy::vcal_n},
{"vcal_p", &CmdProxy::vcal_p},
{"vcassh", &CmdProxy::vcassh},
{"vcas", &CmdProxy::vcas},
{"vicin", &CmdProxy::vicin},
{"vipre_out", &CmdProxy::vipre_out},
{"vref_h_adc", &CmdProxy::vref_h_adc},
{"vb_comp_fe", &CmdProxy::vb_comp_fe},
{"vb_comp_adc", &CmdProxy::vb_comp_adc},
{"vcom_cds", &CmdProxy::vcom_cds},
{"vref_rstore", &CmdProxy::vref_rstore},
{"vb_opa_1st", &CmdProxy::vb_opa_1st},
{"vref_comp_fe", &CmdProxy::vref_comp_fe},
{"vcom_adc1", &CmdProxy::vcom_adc1},
{"vref_prech", &CmdProxy::vref_prech},
{"vref_l_adc", &CmdProxy::vref_l_adc},
{"vref_cds", &CmdProxy::vref_cds},
{"vb_cs", &CmdProxy::vb_cs},
{"vb_opa_fd", &CmdProxy::vb_opa_fd},
{"vcom_adc2", &CmdProxy::vcom_adc2},
{"adcvpp", &CmdProxy::adcvpp},
{"vb_ds", &CmdProxy::vb_ds},
{"vb_comp", &CmdProxy::vb_comp},
{"vb_pixbuf", &CmdProxy::vb_pixbuf},
{"vin_com", &CmdProxy::vin_com},
{"vdd_prot", &CmdProxy::vdd_prot},
{"vbp_colbuf", &CmdProxy::vbp_colbuf},
{"vb_sda", &CmdProxy::vb_sda},
{"vcasc_sfp", &CmdProxy::vcasc_sfp},
{"vipre_cds", &CmdProxy::vipre_cds},
{"ibias_sfp", &CmdProxy::ibias_sfp},
{"dac", &CmdProxy::Dac}, {"dac", &CmdProxy::Dac},
{"daclist", &CmdProxy::daclist}, {"daclist", &CmdProxy::daclist},
{"dacvalues", &CmdProxy::DacValues}, {"dacvalues", &CmdProxy::DacValues},
@ -941,6 +907,7 @@ class CmdProxy {
/* Gotthard2 Specific */ /* Gotthard2 Specific */
{"bursts", &CmdProxy::bursts}, {"bursts", &CmdProxy::bursts},
{"burstperiod", &CmdProxy::burstperiod}, {"burstperiod", &CmdProxy::burstperiod},
{"burstsl", &CmdProxy::burstsl},
{"inj_ch", &CmdProxy::InjectChannel}, {"inj_ch", &CmdProxy::InjectChannel},
{"vetophoton", &CmdProxy::VetoPhoton}, {"vetophoton", &CmdProxy::VetoPhoton},
{"vetoref", &CmdProxy::VetoReference}, {"vetoref", &CmdProxy::VetoReference},
@ -1176,8 +1143,8 @@ class CmdProxy {
GET_COMMAND_HEX(rx_version, getReceiverVersion, GET_COMMAND_HEX(rx_version, getReceiverVersion,
"\n\tReceiver version in format [0xYYMMDD]."); "\n\tReceiver version in format [0xYYMMDD].");
GET_COMMAND_HEX(detectornumber, getSerialNumber, GET_COMMAND_HEX(serialnumber, getSerialNumber,
"\n\tReceiver version in format [0xYYMMDD]."); "\n\tSerial number of detector.");
GET_COMMAND(type, getDetectorType, GET_COMMAND(type, getDetectorType,
"\n\tReturns detector type. Can be Eiger, Jungfrau, Gotthard, " "\n\tReturns detector type. Can be Eiger, Jungfrau, Gotthard, "
@ -1222,8 +1189,8 @@ class CmdProxy {
INTEGER_COMMAND_NOID( INTEGER_COMMAND_NOID(
frames, getNumberOfFrames, setNumberOfFrames, StringTo<int64_t>, frames, getNumberOfFrames, setNumberOfFrames, StringTo<int64_t>,
"[n_frames]\n\tNumber of frames per acquisition. In " "[n_frames]\n\tNumber of frames per acquisition. In "
"trigger mode, number of frames per trigger. Cannot be set in modular " "trigger mode, number of frames per trigger. \n\tCannot be set in "
"level. In scan mode, number of frames is set to number of " "modular level. \n\tIn scan mode, number of frames is set to number of "
"steps.\n\t[Gotthard2] Burst mode has a maximum of 2720 frames."); "steps.\n\t[Gotthard2] Burst mode has a maximum of 2720 frames.");
INTEGER_COMMAND_NOID(triggers, getNumberOfTriggers, setNumberOfTriggers, INTEGER_COMMAND_NOID(triggers, getNumberOfTriggers, setNumberOfTriggers,
@ -1243,12 +1210,12 @@ class CmdProxy {
GET_COMMAND(framesl, getNumberOfFramesLeft, GET_COMMAND(framesl, getNumberOfFramesLeft,
"\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] " "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] "
"Number of frames left in acquisition." "Number of frames left in acquisition."
"\n\t[Gotthard2] only in continuous mode."); "\n\t[Gotthard2] only in continuous auto mode.");
GET_COMMAND(triggersl, getNumberOfTriggersLeft, GET_COMMAND(triggersl, getNumberOfTriggersLeft,
"\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] " "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] "
"Number of triggers left in acquisition." "Number of triggers left in acquisition. Only when external "
"\n\t[Gotthard2] only in continuous mode."); "trigger used.");
TIME_GET_COMMAND(delayl, getDelayAfterTriggerLeft, TIME_GET_COMMAND(delayl, getDelayAfterTriggerLeft,
"\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench]" "\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench]"
@ -1256,7 +1223,7 @@ class CmdProxy {
"\n\t[Gotthard2] only in continuous mode."); "\n\t[Gotthard2] only in continuous mode.");
TIME_GET_COMMAND(periodl, getPeriodLeft, TIME_GET_COMMAND(periodl, getPeriodLeft,
"\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench]" "\n\t[Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2]"
" Period left for current frame." " Period left for current frame."
"\n\t[Gotthard2] only in continuous mode."); "\n\t[Gotthard2] only in continuous mode.");
@ -1293,14 +1260,11 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
powerchip, getPowerChip, setPowerChip, StringTo<int>, powerchip, getPowerChip, setPowerChip, StringTo<int>,
"[0, 1]\n\t[Jungfrau][Mythen3][Gotthard2][Moench] Power " "[0, 1]\n\t[Jungfrau][Mythen3][Gotthard2][Moench] Power "
"the chip. Default 0." "the chip. \n\t[Moench] Default is 0. \n\t[Jungfrau] Default is 0. Get "
"\n\t[Jungfrau] Get will return power status." "will return power status. Can be off if temperature event occured "
"Can be off if temperature event occured (temperature over " "(temperature over temp_threshold with temp_control "
"temp_threshold with temp_control enabled." "enabled.\n\t[Mythen3][Gotthard2] Default is 1. If module not "
"\n\t[Mythen3] If module not connected or wrong module, 1 " "connected or wrong module, powerchip will fail.");
"will fail. By default, not powered on"
"\n\t[Gotthard2] If module not connected or wrong module, "
"1 will fail. By default, powered on at server start up.");
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
imagetest, getImageTestMode, setImageTestMode, StringTo<int>, imagetest, getImageTestMode, setImageTestMode, StringTo<int>,
@ -1350,13 +1314,11 @@ class CmdProxy {
GET_IND_COMMAND( GET_IND_COMMAND(
temp_fpgafl, getTemperature, slsDetectorDefs::TEMPERATURE_FPGA2, " °C", temp_fpgafl, getTemperature, slsDetectorDefs::TEMPERATURE_FPGA2, " °C",
"[n_value]\n\t[Eiger]Temperature of the left front end board fpga. " "[n_value]\n\t[Eiger]Temperature of the left front end board fpga.");
"Cannot call this while blocking acquire is going on.");
GET_IND_COMMAND( GET_IND_COMMAND(
temp_fpgafr, getTemperature, slsDetectorDefs::TEMPERATURE_FPGA3, " °C", temp_fpgafr, getTemperature, slsDetectorDefs::TEMPERATURE_FPGA3, " °C",
"[n_value]\n\t[Eiger]Temperature of the left front end board fpga. " "[n_value]\n\t[Eiger]Temperature of the left front end board fpga.");
"Cannot call this while blocking acquire is going on.");
GET_IND_COMMAND(temp_slowadc, getTemperature, GET_IND_COMMAND(temp_slowadc, getTemperature,
slsDetectorDefs::SLOW_ADC_TEMP, " °C", slsDetectorDefs::SLOW_ADC_TEMP, " °C",
@ -1364,268 +1326,6 @@ class CmdProxy {
/* dacs */ /* dacs */
DAC_COMMAND(
vthreshold, getDAC, setDAC, defs::VTHRESHOLD,
"[dac or mV value][(optional unit) mV] \n\t[Eiger][Mythen3] "
"Detector threshold voltage for single photon counters.\n\t[Eiger] "
"Sets vcmp_ll, vcmp_lr, vcmp_rl, vcmp_rr and vcp to the same value. "
"\n\t[Mythen3] Sets vth1, vth2 and vth3 to the same value.");
DAC_COMMAND(vsvp, getDAC, setDAC, defs::VSVP,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(vsvn, getDAC, setDAC, defs::VSVN,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? \n\t[Mythen3] voltage "
"to define feedback resistance of the first shaper"); // TODO
DAC_COMMAND(vtrim, getDAC, setDAC, defs::VTRIM,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? \n\t[Mythen3] Dac for "
"the voltage defining the trim bit size."); // TODO
DAC_COMMAND(vrpreamp, getDAC, setDAC, defs::VRPREAMP,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? \n\t[Mythen3] voltage "
"to define the preamplifier feedback resistance."); // TODO
DAC_COMMAND(vrshaper, getDAC, setDAC, defs::VRSHAPER,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? \n\t[Mythen3] voltage to define feedback resistance of "
"the first shaper"); // TODO
DAC_COMMAND(vtgstv, getDAC, setDAC, defs::VTGSTV,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(vcmp_ll, getDAC, setDAC, defs::VCMP_LL,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(vcmp_lr, getDAC, setDAC, defs::VCMP_LR,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(vcal, getDAC, setDAC, defs::VCAL,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(vcmp_rl, getDAC, setDAC, defs::VCMP_RL,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(vcmp_rr, getDAC, setDAC, defs::VCMP_RR,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(rxb_rb, getDAC, setDAC, defs::RXB_RB,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(rxb_lb, getDAC, setDAC, defs::RXB_LB,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(vcp, getDAC, setDAC, defs::VCP,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(vcn, getDAC, setDAC, defs::VCN,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(vishaper, getDAC, setDAC, defs::VISHAPER,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? \n\t[Mythen3] Dac for "
"the bias current for the shaper."); // TODO
DAC_COMMAND(iodelay, getDAC, setDAC, defs::IO_DELAY,
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for "
"?? "); // TODO
DAC_COMMAND(vref_ds, getDAC, setDAC, defs::VREF_DS,
"[dac or mV value][(optional unit) mV] "
"\n\t[Gotthard][Jungfrau] Dac for ?? "); // TODO
DAC_COMMAND(vcascn_pb, getDAC, setDAC, defs::VCASCN_PB,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard] Dac for "
"?? "); // TODO
DAC_COMMAND(vcascp_pb, getDAC, setDAC, defs::VCASCP_PB,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard] Dac for "
"?? "); // TODO
DAC_COMMAND(vout_cm, getDAC, setDAC, defs::VOUT_CM,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard] Dac for "
"?? \n\t[Moench] Dac for 5"); // TODO
DAC_COMMAND(vcasc_out, getDAC, setDAC, defs::VCASC_OUT,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard] Dac for "
"?? "); // TODO
DAC_COMMAND(vin_cm, getDAC, setDAC, defs::VIN_CM,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard] Dac for "
"?? \n\t[Moench] Dac for 2"); // TODO
DAC_COMMAND(vref_comp, getDAC, setDAC, defs::VREF_COMP,
"[dac or mV value][(optional unit) mV] "
"\n\t[Gotthard][Jungfrau] Dac for ?? "); // TODO
DAC_COMMAND(ib_test_c, getDAC, setDAC, defs::IB_TESTC,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard] Dac for "
"?? "); // TODO
DAC_COMMAND(vrshaper_n, getDAC, setDAC, defs::VRSHAPER_N,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] voltage "
"to define feedback resistance of the second shaper.");
DAC_COMMAND(
vipre, getDAC, setDAC, defs::VIPRE,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for the "
"preamplifier's input transistor current.\n\t[Moench] Dac for 1");
DAC_COMMAND(vdcsh, getDAC, setDAC, defs::VDCSH,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"the reference (DC) voltage for the shaper.");
DAC_COMMAND(vth1, getDAC, setDAC, defs::VTH1,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"first detector threshold voltage.");
DAC_COMMAND(vth2, getDAC, setDAC, defs::VTH2,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"second detector threshold voltage.");
DAC_COMMAND(vth3, getDAC, setDAC, defs::VTH3,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"third detector threshold voltage.");
DAC_COMMAND(vcal_n, getDAC, setDAC, defs::VCAL_N,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"the low voltage for analog pulsing.");
DAC_COMMAND(vcal_p, getDAC, setDAC, defs::VCAL_P,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"the high voltage for analog pulsing.");
DAC_COMMAND(vcassh, getDAC, setDAC, defs::VCASSH,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"the shaper's cascode voltage.");
DAC_COMMAND(vcas, getDAC, setDAC, defs::VCAS,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"the preamplifier's cascode voltage.");
DAC_COMMAND(vicin, getDAC, setDAC, defs::VICIN,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"the bias current for the comparator.");
DAC_COMMAND(vipre_out, getDAC, setDAC, defs::VIPRE_OUT,
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"preamplifier's output transistor current."); // TODO
DAC_COMMAND(vref_h_adc, getDAC, setDAC, defs::VREF_H_ADC,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"reference voltage high of ADC.");
DAC_COMMAND(vb_comp_fe, getDAC, setDAC, defs::VB_COMP_FE,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"comparator current of analogue front end.");
DAC_COMMAND(vb_comp_adc, getDAC, setDAC, defs::VB_COMP_ADC,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"comparator current of ADC.");
DAC_COMMAND(vcom_cds, getDAC, setDAC, defs::VCOM_CDS,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"common mode voltage of CDS stage.");
DAC_COMMAND(
vref_rstore, getDAC, setDAC, defs::VREF_RSTORE,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"reference charging voltage of temparory storage cell in high gain.");
DAC_COMMAND(vb_opa_1st, getDAC, setDAC, defs::VB_OPA_1ST,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] dac dac "
"for opa current for driving the other DACs in chip.");
DAC_COMMAND(vref_comp_fe, getDAC, setDAC, defs::VREF_COMP_FE,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"reference voltage of the comparator of analogue front end.");
DAC_COMMAND(vcom_adc1, getDAC, setDAC, defs::VCOM_ADC1,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"common mode voltage of ADC DAC bank 1.");
DAC_COMMAND(
vref_prech, getDAC, setDAC, defs::VREF_PRECH,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2][Jungfrau] Dac "
"for reference votlage for precharing the preamplifier."); // TODO also
// for
// jungfrau?
DAC_COMMAND(vref_l_adc, getDAC, setDAC, defs::VREF_L_ADC,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"reference voltage low for ADC.");
DAC_COMMAND(vref_cds, getDAC, setDAC, defs::VREF_CDS,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"reference voltage of CDS applied to the temporary storage "
"cell in medium and low gain.");
DAC_COMMAND(vb_cs, getDAC, setDAC, defs::VB_CS,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"current injection into preamplifier.");
DAC_COMMAND(vb_opa_fd, getDAC, setDAC, defs::VB_OPA_FD,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"current for CDS opa stage.");
DAC_COMMAND(vcom_adc2, getDAC, setDAC, defs::VCOM_ADC2,
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"common mode voltage of ADC DAC bank 2.");
DAC_COMMAND(
adcvpp, getDAC, setDAC, defs::ADC_VPP,
"[dac or mV value][(optional unit) mV] \n\t[Ctb][Moench] Vpp of "
"ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V.");
DAC_COMMAND(vb_ds, getDAC, setDAC, defs::VB_DS,
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for "
"??"); // TODO
DAC_COMMAND(vb_comp, getDAC, setDAC, defs::VB_COMP,
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for "
"??"); // TODO
DAC_COMMAND(vb_pixbuf, getDAC, setDAC, defs::VB_PIXBUF,
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for "
"??"); // TODO
DAC_COMMAND(vin_com, getDAC, setDAC, defs::VIN_COM,
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for "
"??"); // TODO
DAC_COMMAND(vdd_prot, getDAC, setDAC, defs::VDD_PROT,
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for "
"??"); // TODO
DAC_COMMAND(vbp_colbuf, getDAC, setDAC, defs::VBP_COLBUF,
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 0");
DAC_COMMAND(vb_sda, getDAC, setDAC, defs::VB_SDA,
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 3");
DAC_COMMAND(vcasc_sfp, getDAC, setDAC, defs::VCASC_SFP,
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 4");
DAC_COMMAND(vipre_cds, getDAC, setDAC, defs::VIPRE_CDS,
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 6");
DAC_COMMAND(ibias_sfp, getDAC, setDAC, defs::IBIAS_SFP,
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 7");
GET_COMMAND_NOID( GET_COMMAND_NOID(
daclist, getDacList, daclist, getDacList,
"\n\tGets the list of commands for every dac for this detector."); "\n\tGets the list of commands for every dac for this detector.");
@ -1669,9 +1369,10 @@ class CmdProxy {
/* acquisition */ /* acquisition */
EXECUTE_SET_COMMAND_NOID(clearbusy, clearAcquiringFlag, EXECUTE_SET_COMMAND_NOID(
"\n\tClears Acquiring Flag for unexpected acquire " clearbusy, clearAcquiringFlag,
"command terminations."); "\n\tIf acquisition aborted during acquire command, use this to clear "
"acquiring flag in shared memory before starting next acquisition");
EXECUTE_SET_COMMAND_NOID( EXECUTE_SET_COMMAND_NOID(
rx_start, startReceiver, rx_start, startReceiver,
@ -1688,9 +1389,9 @@ class CmdProxy {
"\n\tStarts detector acquisition. Status changes to RUNNING or WAITING " "\n\tStarts detector acquisition. Status changes to RUNNING or WAITING "
"and automatically returns to idle at the end of acquisition."); "and automatically returns to idle at the end of acquisition.");
EXECUTE_SET_COMMAND_NOID( EXECUTE_SET_COMMAND_NOID(stop, stopDetector,
stop, stopDetector, "\n\tAbort detector acquisition. Status changes "
"\n\tAbort detector acquisition. Status changes to IDLE or STOPPED."); "to IDLE or STOPPED. Goes to stop server.");
GET_COMMAND(rx_framescaught, getFramesCaught, GET_COMMAND(rx_framescaught, getFramesCaught,
"\n\tNumber of frames caught by receiver."); "\n\tNumber of frames caught by receiver.");
@ -1702,7 +1403,7 @@ class CmdProxy {
startingfnum, getStartingFrameNumber, setStartingFrameNumber, startingfnum, getStartingFrameNumber, setStartingFrameNumber,
StringTo<uint64_t>, StringTo<uint64_t>,
"[n_value]\n\t[Eiger][Jungfrau] Starting frame number for " "[n_value]\n\t[Eiger][Jungfrau] Starting frame number for "
"next acquisition. Stopping acquiistion might result in " "next acquisition. Stopping acquisition might result in "
"different frame numbers for different modules."); "different frame numbers for different modules.");
EXECUTE_SET_COMMAND( EXECUTE_SET_COMMAND(
@ -1813,13 +1514,12 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
txndelay_frame, getTransmissionDelayFrame, setTransmissionDelayFrame, txndelay_frame, getTransmissionDelayFrame, setTransmissionDelayFrame,
StringTo<int>, StringTo<int>,
"[n_delay]\n\t[Eiger][Jungfrau][Mythen3] Transmission delay of each " "[n_delay]\n\t[Eiger][Jungfrau][Mythen3] Transmission delay of first "
"image being " "udp packet being streamed out of the module.\n\t[Jungfrau] [0-31] "
"streamed out of the module.\n\t[Jungfrau] [0-31] Each value " "Each value represents 1 ms\n\t[Eiger] Additional delay to "
"represents 1 ms\n\t[Eiger] Additional delay to txndelay_left and " "txndelay_left and txndelay_right. Each value represents 10ns. Typical "
"txndelay_right. Each value represents 10ns. Typical value is " "value is 50000.\n\t[Mythen3] [0-16777215] Each value represents 8 ns "
"50000.\n\t[Mythen3] [0-16777215] Each value represents 8 ns (125 MHz " "(125 MHz clock), max is 134 ms.");
"clock), max is 134 ms.");
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
txndelay_left, getTransmissionDelayLeft, setTransmissionDelayLeft, txndelay_left, getTransmissionDelayLeft, setTransmissionDelayLeft,
@ -1879,7 +1579,7 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
rx_lock, getRxLock, setRxLock, StringTo<int>, rx_lock, getRxLock, setRxLock, StringTo<int>,
"[0, 1]\n\tLock receiver to one client IP, 1 locks, 0 " "[0, 1]\n\tLock receiver to one client IP, 1 locks, 0 "
"unlocks. Default is unlocked. 1: locks"); "unlocks. Default is unlocked.");
GET_COMMAND( GET_COMMAND(
rx_lastclient, getRxLastClientIP, rx_lastclient, getRxLastClientIP,
@ -1901,10 +1601,10 @@ class CmdProxy {
"[binary|hdf5]\n\tFile format of data file. For HDF5, package must be " "[binary|hdf5]\n\tFile format of data file. For HDF5, package must be "
"compiled with HDF5 flags. Default is binary."); "compiled with HDF5 flags. Default is binary.");
STRING_COMMAND( STRING_COMMAND(fpath, getFilePath, setFilePath,
fpath, getFilePath, setFilePath, "[path]\n\tDirectory where output data files are written in "
"[path]\n\tDirectory where output data files are written in receiver. " "receiver. Default is '/'. \n\tIf path does not exist, it "
"If path does not exist, it will try to create it."); "will try to create it.");
STRING_COMMAND(fname, getFileNamePrefix, setFileNamePrefix, STRING_COMMAND(fname, getFileNamePrefix, setFileNamePrefix,
"[name]\n\tFile name prefix for output data file. Default " "[name]\n\tFile name prefix for output data file. Default "
@ -1929,8 +1629,9 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
rx_framesperfile, getFramesPerFile, setFramesPerFile, StringTo<int>, rx_framesperfile, getFramesPerFile, setFramesPerFile, StringTo<int>,
"[n_frames]\n\tNumber of frames per file in receiver. 0 is " "[n_frames]\n\tNumber of frames per file in receiver in an "
"infinite or all frames in single file."); "acquisition. Default depends on detector type. 0 is infinite or all "
"frames in single file.");
/* ZMQ Streaming Parameters (Receiver<->Client) */ /* ZMQ Streaming Parameters (Receiver<->Client) */
@ -2014,14 +1715,15 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
flippeddatax, getBottom, setBottom, StringTo<int>, flippeddatax, getBottom, setBottom, StringTo<int>,
"[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 " "[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 "
"is top. Used to let Receivers and Gui know to flip the bottom image " "is top. Used to let Gui (via zmq from receiver) know to flip the "
"over the x axis. Files are not written without the flip however."); "bottom image over the x axis. Files are not written without the flip "
"however.");
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
readnlines, getPartialReadout, setPartialReadout, StringTo<int>, readnlines, getPartialReadout, setPartialReadout, StringTo<int>,
"[1 - 256]\n\t[Eiger] Number of rows to readout per half module " "[1 - 256]\n\t[Eiger] Number of rows to readout per half module "
"starting from the centre. 256 is default. The permissible values " "starting from the centre. Options: 0 - 256. 256 is default. The "
"depend on dynamic range and 10Gbe enabled."); "permissible values depend on dynamic range and 10Gbe enabled.");
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
interruptsubframe, getInterruptSubframe, setInterruptSubframe, interruptsubframe, getInterruptSubframe, setInterruptSubframe,
@ -2107,9 +1809,14 @@ class CmdProxy {
"timing mode and burst mode. Use timing command to set timing mode and " "timing mode and burst mode. Use timing command to set timing mode and "
"burstmode command to set burst mode."); "burstmode command to set burst mode.");
TIME_COMMAND(burstperiod, getBurstPeriod, setBurstPeriod, TIME_COMMAND(
"[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] Burst " burstperiod, getBurstPeriod, setBurstPeriod,
"period. Only in burst mode and auto timing mode."); "[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] "
"Period between 2 bursts. Only in burst mode and auto timing mode.");
GET_COMMAND(burstsl, getNumberOfBurstsLeft,
"\n\t[Gotthard2] Number of bursts left in acquisition. Only in "
"burst auto mode.");
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
cdsgain, getCDSGain, setCDSGain, StringTo<bool>, cdsgain, getCDSGain, setCDSGain, StringTo<bool>,
@ -2171,13 +1878,13 @@ class CmdProxy {
INTEGER_COMMAND_HEX(adcenable, getADCEnableMask, setADCEnableMask, INTEGER_COMMAND_HEX(adcenable, getADCEnableMask, setADCEnableMask,
StringTo<uint32_t>, StringTo<uint32_t>,
"[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 1Gb " "[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 1Gb "
"Mode for each 32 ADC channel."); "Enable for each 32 ADC channel.");
INTEGER_COMMAND_HEX( INTEGER_COMMAND_HEX(
adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask, adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask,
StringTo<uint32_t>, StringTo<uint32_t>,
"[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 10Gb mode for each 32 " "[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 10Gb mode for each 32 "
"ADC channel. However, if any of consecutive 4 bits are enabled, the " "ADC channel. However, if any of a consecutive 4 bits are enabled, the "
"complete 4 bits are enabled."); "complete 4 bits are enabled.");
/* CTB Specific */ /* CTB Specific */
@ -2260,8 +1967,8 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
extsampling, getExternalSampling, setExternalSampling, StringTo<int>, extsampling, getExternalSampling, setExternalSampling, StringTo<int>,
"[0, 1]\n\t[Ctb] Enable for external sampling signal to extsamplingsrc " "[0, 1]\n\t[Ctb] Enable for external sampling signal for digital data "
"signal for digital data. For advanced users only."); "to signal by extsampling src command. For advanced users only.");
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
extsamplingsrc, getExternalSamplingSource, setExternalSamplingSource, extsamplingsrc, getExternalSamplingSource, setExternalSamplingSource,
@ -2281,8 +1988,8 @@ class CmdProxy {
EXECUTE_SET_COMMAND_NOID_1ARG( EXECUTE_SET_COMMAND_NOID_1ARG(
savepattern, savePattern, savepattern, savePattern,
"[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). Also " "[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). "
"executes pattern."); "\n\t[Ctb][Moench] Also executes pattern.");
INTEGER_COMMAND_HEX_WIDTH16(patioctrl, getPatternIOControl, INTEGER_COMMAND_HEX_WIDTH16(patioctrl, getPatternIOControl,
setPatternIOControl, StringTo<uint64_t>, setPatternIOControl, StringTo<uint64_t>,
@ -2311,7 +2018,7 @@ class CmdProxy {
EXECUTE_SET_COMMAND(rebootcontroller, rebootController, EXECUTE_SET_COMMAND(rebootcontroller, rebootController,
"\n\t[Jungfrau][Ctb][Moench][Gotthard][Mythen3][" "\n\t[Jungfrau][Ctb][Moench][Gotthard][Mythen3]["
"Gotthard2] Reboot controler (blackfin) of detector."); "Gotthard2] Reboot controller of detector.");
EXECUTE_SET_COMMAND( EXECUTE_SET_COMMAND(
firmwaretest, executeFirmwareTest, firmwaretest, executeFirmwareTest,
@ -2321,7 +2028,8 @@ class CmdProxy {
EXECUTE_SET_COMMAND( EXECUTE_SET_COMMAND(
bustest, executeBusTest, bustest, executeBusTest,
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Bus test, " "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Bus test, "
"ie. keeps writing and reading back different values in R/W register."); "ie. Writes different values in a R/W register and confirms the "
"writes to check bus.\n\tAdvanced User function!");
INTEGER_COMMAND_HEX( INTEGER_COMMAND_HEX(
adcinvert, getADCInvert, setADCInvert, StringTo<uint32_t>, adcinvert, getADCInvert, setADCInvert, StringTo<uint32_t>,
@ -2333,16 +2041,17 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
port, getControlPort, setControlPort, StringTo<int>, port, getControlPort, setControlPort, StringTo<int>,
"[n]\n\tPort number of the control server on detector for " "[n]\n\tPort number of the control server on detector for "
"detector-client tcp interface. Default is 1952. Normally unchanged."); "detector-client tcp interface. Default is 1952. Normally unchanged. "
"Set different ports for virtual servers on same pc.");
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
stopport, getStopPort, setStopPort, StringTo<int>, stopport, getStopPort, setStopPort, StringTo<int>,
"[n]\n\tPort number of the stop server on detector for detector-client " "[n]\n\tPort number of the stop server on detector for detector-client "
"tcp interface. Default is 1953. Normally unchanged."); "tcp interface. Default is 1953. Normally unchanged.");
INTEGER_COMMAND_VEC_ID(lock, getDetectorLock, setDetectorLock, INTEGER_COMMAND_VEC_ID(
StringTo<int>, lock, getDetectorLock, setDetectorLock, StringTo<int>,
"[0, 1]\n\tLock detector to one IP, 1: locks"); "[0, 1]\n\tLock detector to one IP, 1: locks. Default is unlocked");
GET_COMMAND( GET_COMMAND(
lastclient, getLastClientIP, lastclient, getLastClientIP,
@ -2357,13 +2066,13 @@ class CmdProxy {
"[(optional unit) " "[(optional unit) "
"ns|us|ms|s]\n\t[Jungfrau][Mythen3][Gotthard2][Moench][" "ns|us|ms|s]\n\t[Jungfrau][Mythen3][Gotthard2][Moench]["
"CTB] Time from detector start up." "CTB] Time from detector start up."
"\n\t[Gotthard2] only in continuous mode."); "\n\t[Gotthard2] not in burst and auto mode.");
TIME_GET_COMMAND(timestamp, getMeasurementTime, TIME_GET_COMMAND(timestamp, getMeasurementTime,
"[(optional unit) " "[(optional unit) "
"ns|us|ms|s]\n\t[Jungfrau][Mythen3][Gotthard2][Moench][" "ns|us|ms|s]\n\t[Jungfrau][Mythen3][Gotthard2][Moench]["
"CTB] Timestamp at a frame start." "CTB] Timestamp at a frame start."
"\n\t[Gotthard2] only in continuous mode."); "\n\t[Gotthard2] not in burst and auto mode.");
GET_COMMAND( GET_COMMAND(
rx_frameindex, getRxCurrentFrameIndex, rx_frameindex, getRxCurrentFrameIndex,

View File

@ -384,10 +384,6 @@ Result<int> Detector::getClockFrequency(int clkIndex, Positions pos) {
return pimpl->Parallel(&Module::getClockFrequency, pos, clkIndex); return pimpl->Parallel(&Module::getClockFrequency, pos, clkIndex);
} }
void Detector::setClockFrequency(int clkIndex, int value, Positions pos) {
pimpl->Parallel(&Module::setClockFrequency, pos, clkIndex, value);
}
Result<int> Detector::getClockPhase(int clkIndex, Positions pos) { Result<int> Detector::getClockPhase(int clkIndex, Positions pos) {
return pimpl->Parallel(&Module::getClockPhase, pos, clkIndex, false); return pimpl->Parallel(&Module::getClockPhase, pos, clkIndex, false);
} }
@ -983,12 +979,12 @@ void Detector::setFileWrite(bool value, Positions pos) {
pimpl->Parallel(&Module::setFileWrite, pos, value); pimpl->Parallel(&Module::setFileWrite, pos, value);
} }
void Detector::setMasterFileWrite(bool value, Positions pos) { void Detector::setMasterFileWrite(bool value) {
pimpl->Parallel(&Module::setMasterFileWrite, pos, value); pimpl->Parallel(&Module::setMasterFileWrite, {0}, value);
} }
Result<bool> Detector::getMasterFileWrite(Positions pos) const { bool Detector::getMasterFileWrite() const {
return pimpl->Parallel(&Module::getMasterFileWrite, pos); return pimpl->Parallel(&Module::getMasterFileWrite, {0})[0];
} }
Result<bool> Detector::getFileOverWrite(Positions pos) const { Result<bool> Detector::getFileOverWrite(Positions pos) const {
@ -1357,6 +1353,10 @@ void Detector::setBurstPeriod(ns value, Positions pos) {
pimpl->Parallel(&Module::setBurstPeriod, pos, value.count()); pimpl->Parallel(&Module::setBurstPeriod, pos, value.count());
} }
Result<int64_t> Detector::getNumberOfBurstsLeft(Positions pos) const {
return pimpl->Parallel(&Module::getNumberOfBurstsLeft, pos);
}
Result<std::array<int, 2>> Detector::getInjectChannel(Positions pos) { Result<std::array<int, 2>> Detector::getInjectChannel(Positions pos) {
return pimpl->Parallel(&Module::getInjectChannel, pos); return pimpl->Parallel(&Module::getInjectChannel, pos);
} }
@ -1886,6 +1886,10 @@ void Detector::clearBit(uint32_t addr, int bitnr, Positions pos) {
pimpl->Parallel(&Module::clearBit, pos, addr, bitnr); pimpl->Parallel(&Module::clearBit, pos, addr, bitnr);
} }
Result<int> Detector::getBit(uint32_t addr, int bitnr, Positions pos) {
return pimpl->Parallel(&Module::getBit, pos, addr, bitnr);
}
void Detector::executeFirmwareTest(Positions pos) { void Detector::executeFirmwareTest(Positions pos) {
pimpl->Parallel(&Module::executeFirmwareTest, pos); pimpl->Parallel(&Module::executeFirmwareTest, pos);
} }

View File

@ -623,13 +623,13 @@ void DetectorImpl::readFrameFromReceiver() {
// send data to callback // send data to callback
if (data) { if (data) {
char *image = multiframe; char *callbackImage = multiframe;
int imagesize = multisize; int imagesize = multisize;
if (gapPixels) { if (gapPixels) {
int n = InsertGapPixels(multiframe, multigappixels, quadEnable, int n = InsertGapPixels(multiframe, multigappixels, quadEnable,
dynamicRange, nDetPixelsX, nDetPixelsY); dynamicRange, nDetPixelsX, nDetPixelsY);
image = multigappixels; callbackImage = multigappixels;
imagesize = n; imagesize = n;
} }
LOG(logDEBUG) << "Image Info:" LOG(logDEBUG) << "Image Info:"
@ -640,8 +640,8 @@ void DetectorImpl::readFrameFromReceiver() {
thisData = thisData =
new detectorData(currentProgress, currentFileName, nDetPixelsX, new detectorData(currentProgress, currentFileName, nDetPixelsX,
nDetPixelsY, image, imagesize, dynamicRange, nDetPixelsY, callbackImage, imagesize,
currentFileIndex, completeImage); dynamicRange, currentFileIndex, completeImage);
dataReady( dataReady(
thisData, currentFrameIndex, thisData, currentFrameIndex,

View File

@ -0,0 +1,302 @@
#include "string_utils.h"
std::string GetHelpDac(std::string dac) {
if (sls::is_int(dac)) {
return std::string("[dac name] [dac or mV value] [(optional unit) mV] "
"\n\t[Ctb] Use dac index for dac name.");
}
if (dac == "vthreshold") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger][Mythen3] "
"Detector threshold voltage for single photon counters.\n\t[Eiger] "
"Sets vcmp_ll, vcmp_lr, vcmp_rl, vcmp_rr and vcp to the same "
"value. \n\t[Mythen3] Sets vth1, vth2 and vth3 to the same value.");
}
if (dac == "vsvp") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ?? ");
}
if (dac == "vsvn") {
return std::string("[dac or mV value][(optional unit) mV] \n\t[Eiger] "
"Dac for ?? \n\t[Mythen3] voltage to define "
"feedback resistance of the first shaper");
}
if (dac == "vtrim") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ?? "
"\n\t[Mythen3] Dac for the voltage defining the trim bit size.");
}
if (dac == "vrpreamp") {
return std::string("[dac or mV value][(optional unit) mV] \n\t[Eiger] "
"Dac for ?? \n\t[Mythen3] voltage to define the "
"preamplifier feedback resistance.");
}
if (dac == "vrshaper") {
return std::string("[dac or mV value][(optional unit) mV] \n\t[Eiger] "
"Dac for ?? \n\t[Mythen3] voltage to define "
"feedback resistance of the first shaper");
}
if (dac == "vtgstv") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "vcmp_ll") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "vcmp_lr") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "vcal") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "vcmp_rl") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "vcmp_rr") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "rxb_rb") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "rxb_lb") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "vcp") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "vcn") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "vishaper") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "iodelay") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Eiger] Dac for ??");
}
if (dac == "vref_ds") {
return std::string("[dac or mV value][(optional unit) mV] "
"\n\t[Gotthard][Jungfrau] Dac for ??");
}
if (dac == "vcascn_pb") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard] Dac for ??");
}
if (dac == "vcascp_pb") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard] Dac for ??");
}
if (dac == "vout_cm") {
return std::string("[dac or mV value][(optional unit) mV] "
"\n\t[Gotthard] Dac for ??\n\t[Moench] Dac for 5");
}
if (dac == "vcasc_out") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard] Dac for ??");
}
if (dac == "vin_cm") {
return std::string("[dac or mV value][(optional unit) mV] "
"\n\t[Gotthard] Dac for ??\n\t[Moench] Dac for 2");
}
if (dac == "vref_comp") {
return std::string("[dac or mV value][(optional unit) mV] "
"\n\t[Gotthard][Jungfrau] Dac for ??");
}
if (dac == "ib_test_c") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard] Dac for ??");
}
if (dac == "vrshaper_n") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] voltage to "
"define feedback resistance of the second shaper.");
}
if (dac == "vipre") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for the "
"preamplifier's input transistor current.\n\t[Moench] Dac for 1");
}
if (dac == "vdcsh") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for the "
"reference (DC) voltage for the shaper.");
}
if (dac == "vth1") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for first "
"detector threshold voltage.");
}
if (dac == "vth2") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"second detector threshold voltage.");
}
if (dac == "vth3") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for third "
"detector threshold voltage.");
}
if (dac == "vcal_n") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for the "
"low voltage for analog pulsing.");
}
if (dac == "vcal_p") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for the "
"high voltage for analog pulsing.");
}
if (dac == "vcassh") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for the "
"shaper's cascode voltage.");
}
if (dac == "vcas") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for the "
"preamplifier's cascode voltage.");
}
if (dac == "vicin") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for the "
"bias current for the comparator.");
}
if (dac == "vipre_out") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Mythen3] Dac for "
"preamplifier's output transistor current.");
}
if (dac == "vref_h_adc") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"reference voltage high of ADC.");
}
if (dac == "vb_comp_fe") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"comparator current of analogue front end.");
}
if (dac == "vb_comp_adc") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"comparator current of ADC.");
}
if (dac == "vcom_cds") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"common mode voltage of CDS stage.");
}
if (dac == "vref_rstore") {
return std::string("[dac or mV value][(optional unit) mV] "
"\n\t[Gotthard2] Dac for reference charging voltage "
"of temparory storage cell in high gain.");
}
if (dac == "vb_opa_1st") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] dac dac for "
"opa current for driving the other DACs in chip.");
}
if (dac == "vref_comp_fe") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"reference voltage of the comparator of analogue front end.");
}
if (dac == "vcom_adc1") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"common mode voltage of ADC DAC bank 1.");
}
if (dac == "vref_prech") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2][Jungfrau] "
"Dac for reference votlage for precharing the preamplifier.");
}
if (dac == "vref_l_adc") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"reference voltage low for ADC.");
}
if (dac == "vref_cds") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"reference voltage of CDS applied to the temporary storage cell in "
"medium and low gain.");
}
if (dac == "vb_cs") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"current injection into preamplifier.");
}
if (dac == "vb_opa_fd") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"current for CDS opa stage.");
}
if (dac == "vcom_adc2") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for "
"common mode voltage of ADC DAC bank 2.");
}
if (dac == "adcvpp") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Ctb][Moench] Vpp of "
"ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V. "
"\n\tAdvanced User function! ");
}
if (dac == "vb_ds") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for ??");
}
if (dac == "vb_comp") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for ??");
}
if (dac == "vb_pixbuf") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for ??");
}
if (dac == "vin_com") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for ??");
}
if (dac == "vdd_prot") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for ??");
}
if (dac == "vbp_colbuf") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 0");
}
if (dac == "vb_sda") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 3");
}
if (dac == "vcasc_sfp") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 4");
}
if (dac == "vipre_cds") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 6");
}
if (dac == "ibias_sfp") {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 7");
}
// clang-format off
if (dac == "vtgstv") { return std::string(""); }
// clang-format on
throw sls::RuntimeError("Unknown dac command");
}

View File

@ -357,10 +357,6 @@ void Module::setImageTestMode(const int value) {
} }
int Module::getADC(dacIndex index) const { int Module::getADC(dacIndex index) const {
// cannot access fpga links simultaneously (eiger) temp fix
if (index == TEMPERATURE_FPGA2 || index == TEMPERATURE_FPGA3) {
return sendToDetector<int>(F_GET_ADC, index);
}
return sendToDetectorStop<int>(F_GET_ADC, index); return sendToDetectorStop<int>(F_GET_ADC, index);
} }
@ -1359,6 +1355,10 @@ void Module::setBurstPeriod(int64_t value) {
sendToDetector(F_SET_BURST_PERIOD, value, nullptr); sendToDetector(F_SET_BURST_PERIOD, value, nullptr);
} }
int64_t Module::getNumberOfBurstsLeft() const {
return sendToDetectorStop<int64_t>(F_GET_BURSTS_LEFT);
}
std::array<int, 2> Module::getInjectChannel() const { std::array<int, 2> Module::getInjectChannel() const {
return sendToDetector<std::array<int, 2>>(F_GET_INJECT_CHANNEL); return sendToDetector<std::array<int, 2>>(F_GET_INJECT_CHANNEL);
} }
@ -2199,21 +2199,29 @@ uint32_t Module::writeRegister(uint32_t addr, uint32_t val) {
return sendToDetectorStop<uint32_t>(F_WRITE_REGISTER, args); return sendToDetectorStop<uint32_t>(F_WRITE_REGISTER, args);
} }
uint32_t Module::setBit(uint32_t addr, int n) { void Module::setBit(uint32_t addr, int n) {
if (n < 0 || n > 31) { if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range"); throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else { } else {
uint32_t val = readRegister(addr); uint32_t val = readRegister(addr);
return writeRegister(addr, val | 1 << n); writeRegister(addr, val | 1 << n);
} }
} }
uint32_t Module::clearBit(uint32_t addr, int n) { void Module::clearBit(uint32_t addr, int n) {
if (n < 0 || n > 31) { if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range"); throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else { } else {
uint32_t val = readRegister(addr); uint32_t val = readRegister(addr);
return writeRegister(addr, val & ~(1 << n)); writeRegister(addr, val & ~(1 << n));
}
}
int Module::getBit(uint32_t addr, int n) {
if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else {
return ((readRegister(addr) >> n) & 0x1);
} }
} }

View File

@ -372,6 +372,7 @@ class Module : public virtual slsDetectorDefs {
void setNumberOfBursts(int64_t value); void setNumberOfBursts(int64_t value);
int64_t getBurstPeriod() const; int64_t getBurstPeriod() const;
void setBurstPeriod(int64_t value); void setBurstPeriod(int64_t value);
int64_t getNumberOfBurstsLeft() const;
std::array<int, 2> getInjectChannel() const; std::array<int, 2> getInjectChannel() const;
void setInjectChannel(const int offsetChannel, const int incrementChannel); void setInjectChannel(const int offsetChannel, const int incrementChannel);
void sendVetoPhoton(const int chipIndex, void sendVetoPhoton(const int chipIndex,
@ -497,8 +498,9 @@ class Module : public virtual slsDetectorDefs {
void rebootController(); void rebootController();
uint32_t readRegister(uint32_t addr) const; uint32_t readRegister(uint32_t addr) const;
uint32_t writeRegister(uint32_t addr, uint32_t val); uint32_t writeRegister(uint32_t addr, uint32_t val);
uint32_t setBit(uint32_t addr, int n); void setBit(uint32_t addr, int n);
uint32_t clearBit(uint32_t addr, int n); void clearBit(uint32_t addr, int n);
int getBit(uint32_t addr, int n);
void executeFirmwareTest(); void executeFirmwareTest();
void executeBusTest(); void executeBusTest();
void writeAdcRegister(uint32_t addr, uint32_t val); void writeAdcRegister(uint32_t addr, uint32_t val);

View File

@ -284,6 +284,17 @@ TEST_CASE("burstperiod", "[.cmd][.new]") {
} }
} }
TEST_CASE("burstsl", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
REQUIRE_NOTHROW(proxy.Call("burstsl", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("burstsl", {}, -1, GET));
}
}
TEST_CASE("inj_ch", "[.cmd][.new]") { TEST_CASE("inj_ch", "[.cmd][.new]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);

View File

@ -495,7 +495,7 @@ TEST_CASE("fwrite", "[.cmd][.new]") {
} }
} }
TEST_CASE("fmaster", "[.cmd][.new]") { TEST_CASE("fmaster", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto prev_val = det.getMasterFileWrite(); auto prev_val = det.getMasterFileWrite();
@ -514,9 +514,7 @@ TEST_CASE("fmaster", "[.cmd][.new]") {
proxy.Call("fmaster", {"1"}, -1, PUT, oss); proxy.Call("fmaster", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "fmaster 1\n"); REQUIRE(oss.str() == "fmaster 1\n");
} }
for (int i = 0; i != det.size(); ++i) { det.setMasterFileWrite(prev_val);
det.setMasterFileWrite(prev_val[i], {i});
}
} }
TEST_CASE("foverwrite", "[.cmd][.new]") { TEST_CASE("foverwrite", "[.cmd][.new]") {

View File

@ -101,11 +101,11 @@ TEST_CASE("detectorserverversion", "[.cmd][.new]") {
REQUIRE_THROWS(proxy.Call("detectorserverversion", {"0"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("detectorserverversion", {"0"}, -1, PUT));
} }
TEST_CASE("detectornumber", "[.cmd][.new]") { TEST_CASE("serialnumber", "[.cmd][.new]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
REQUIRE_NOTHROW(proxy.Call("detectornumber", {}, -1, GET)); REQUIRE_NOTHROW(proxy.Call("serialnumber", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("detectornumber", {"0"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("serialnumber", {"0"}, -1, PUT));
} }
TEST_CASE("type", "[.cmd][.new]") { TEST_CASE("type", "[.cmd][.new]") {
@ -334,7 +334,7 @@ TEST_CASE("exptime", "[.cmd][.time]") {
REQUIRE(oss.str() == "exptime 0\n"); REQUIRE(oss.str() == "exptime 0\n");
} }
{ {
//Get exptime of single module // Get exptime of single module
std::ostringstream oss; std::ostringstream oss;
proxy.Call("exptime", {}, 0, GET, oss); proxy.Call("exptime", {}, 0, GET, oss);
REQUIRE(oss.str() == "exptime 0ns\n"); REQUIRE(oss.str() == "exptime 0ns\n");

View File

@ -167,11 +167,10 @@ void Implementation::setDetectorType(const detectorType d) {
&activated, &deactivatedPaddingEnable, &silentMode)); &activated, &deactivatedPaddingEnable, &silentMode));
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, &fileFormatType, fileWriteEnable, i, myDetectorType, fifo_ptr, &fileFormatType, fileWriteEnable,
&masterFileWriteEnable, &dataStreamEnable, &masterFileWriteEnable, &dataStreamEnable, &streamingFrequency,
&streamingFrequency, &streamingTimerInMs, &streamingStartFnum, &streamingTimerInMs, &streamingStartFnum, &framePadding,
&framePadding, &activated, &deactivatedPaddingEnable, &activated, &deactivatedPaddingEnable, &silentMode,
&silentMode, &ctbDbitList, &ctbDbitOffset, &ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
&ctbAnalogDataBytes));
} catch (...) { } catch (...) {
listener.clear(); listener.clear();
dataProcessor.clear(); dataProcessor.clear();
@ -841,10 +840,10 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
auto fifo_ptr = fifo[i].get(); auto fifo_ptr = fifo[i].get();
listener.push_back(sls::make_unique<Listener>( listener.push_back(sls::make_unique<Listener>(
i, myDetectorType, fifo_ptr, &status, &udpPortNum[i], i, myDetectorType, fifo_ptr, &status, &udpPortNum[i],
&eth[i], &numberOfTotalFrames, &eth[i], &numberOfTotalFrames, &udpSocketBufferSize,
&udpSocketBufferSize, &actualUDPSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile,
&framesPerFile, &frameDiscardMode, &activated, &frameDiscardMode, &activated, &deactivatedPaddingEnable,
&deactivatedPaddingEnable, &silentMode)); &silentMode));
listener[i]->SetGeneralData(generalData); listener[i]->SetGeneralData(generalData);
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
@ -852,8 +851,8 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable, fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable,
&streamingFrequency, &streamingTimerInMs, &streamingFrequency, &streamingTimerInMs,
&streamingStartFnum, &framePadding, &activated, &streamingStartFnum, &framePadding, &activated,
&deactivatedPaddingEnable, &silentMode, &deactivatedPaddingEnable, &silentMode, &ctbDbitList,
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes)); &ctbDbitOffset, &ctbAnalogDataBytes));
dataProcessor[i]->SetGeneralData(generalData); dataProcessor[i]->SetGeneralData(generalData);
} catch (...) { } catch (...) {
listener.clear(); listener.clear();
@ -1123,18 +1122,31 @@ void Implementation::setAdditionalJsonParameter(const std::string &key,
* ************************************************/ * ************************************************/
void Implementation::updateTotalNumberOfFrames() { void Implementation::updateTotalNumberOfFrames() {
int64_t repeats = numberOfTriggers; int64_t repeats = numberOfTriggers;
// gotthard2: auto mode int64_t numFrames = numberOfFrames;
// burst mode: (bursts instead of triggers) // gotthard2
// continuous mode: no bursts or triggers if (myDetectorType == GOTTHARD2) {
if (myDetectorType == GOTTHARD2 && timingMode == AUTO_TIMING) { // auto
if (timingMode == AUTO_TIMING) {
// burst mode, repeats = #bursts
if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) { if (burstMode == BURST_INTERNAL || burstMode == BURST_EXTERNAL) {
repeats = numberOfBursts; repeats = numberOfBursts;
} else { }
// continuous, repeats = 1 (no trigger as well)
else {
repeats = 1; repeats = 1;
} }
} }
numberOfTotalFrames = numberOfFrames * repeats * // trigger
(int64_t)(numberOfAdditionalStorageCells + 1); else {
// continuous, numFrames is limited
if (burstMode == CONTINUOUS_INTERNAL ||
burstMode == CONTINUOUS_EXTERNAL) {
numFrames = 1;
}
}
}
numberOfTotalFrames =
numFrames * repeats * (int64_t)(numberOfAdditionalStorageCells + 1);
if (numberOfTotalFrames == 0) { if (numberOfTotalFrames == 0) {
throw sls::RuntimeError("Invalid total number of frames to receive: 0"); throw sls::RuntimeError("Invalid total number of frames to receive: 0");
} }

View File

@ -213,6 +213,7 @@ enum detFuncs {
F_SET_BAD_CHANNELS, F_SET_BAD_CHANNELS,
F_RECONFIGURE_UDP, F_RECONFIGURE_UDP,
F_VALIDATE_UDP_CONFIG, F_VALIDATE_UDP_CONFIG,
F_GET_BURSTS_LEFT,
NUM_DET_FUNCTIONS, NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
@ -529,6 +530,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_BAD_CHANNELS: return "F_SET_BAD_CHANNELS"; case F_SET_BAD_CHANNELS: return "F_SET_BAD_CHANNELS";
case F_RECONFIGURE_UDP: return "F_RECONFIGURE_UDP"; case F_RECONFIGURE_UDP: return "F_RECONFIGURE_UDP";
case F_VALIDATE_UDP_CONFIG: return "F_VALIDATE_UDP_CONFIG"; case F_VALIDATE_UDP_CONFIG: return "F_VALIDATE_UDP_CONFIG";
case F_GET_BURSTS_LEFT: return "F_GET_BURSTS_LEFT";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -51,4 +51,7 @@ implementation should not be used in a performance critical place.
std::vector<std::string> split(const std::string &strToSplit, char delimeter); std::vector<std::string> split(const std::string &strToSplit, char delimeter);
std::string RemoveUnit(std::string &str); std::string RemoveUnit(std::string &str);
bool is_int(const std::string& s);
} // namespace sls } // namespace sls

View File

@ -3,11 +3,10 @@
#define APILIB 0x200810 #define APILIB 0x200810
#define APIRECEIVER 0x200810 #define APIRECEIVER 0x200810
#define APIGUI 0x200804 #define APIGUI 0x200804
#define APICTB 0x200910 #define APICTB 0x200910
#define APIGOTTHARD 0x200910
#define APIJUNGFRAU 0x200910
#define APIMOENCH 0x200910 #define APIMOENCH 0x200910
#define APIEIGER 0x200910 #define APIMYTHEN3 0x200923
#define APIGOTTHARD2 0x200910 #define APIGOTTHARD 0x200917
#define APIMYTHEN3 0x200910 #define APIJUNGFRAU 0x200917
#define APIEIGER 0x200918
#define APIGOTTHARD2 0x200924

View File

@ -686,41 +686,41 @@ template <> defs::readoutMode StringTo(const std::string &s) {
} }
template <> defs::dacIndex StringTo(const std::string &s) { template <> defs::dacIndex StringTo(const std::string &s) {
if (s == "dac 0") if (s == "dac 0" || s == "0")
return defs::DAC_0; return defs::DAC_0;
if (s == "dac 1") if (s == "dac 1" || s == "1")
return defs::DAC_1; return defs::DAC_1;
if (s == "dac 2") if (s == "dac 2" || s == "2")
return defs::DAC_2; return defs::DAC_2;
if (s == "dac 3") if (s == "dac 3" || s == "3")
return defs::DAC_3; return defs::DAC_3;
if (s == "dac 4") if (s == "dac 4" || s == "4")
return defs::DAC_4; return defs::DAC_4;
if (s == "dac 5") if (s == "dac 5"|| s == "5")
return defs::DAC_5; return defs::DAC_5;
if (s == "dac 6") if (s == "dac 6"|| s == "6")
return defs::DAC_6; return defs::DAC_6;
if (s == "dac 7") if (s == "dac 7"|| s == "7")
return defs::DAC_7; return defs::DAC_7;
if (s == "dac 8") if (s == "dac 8"|| s == "8")
return defs::DAC_8; return defs::DAC_8;
if (s == "dac 9") if (s == "dac 9"|| s == "9")
return defs::DAC_9; return defs::DAC_9;
if (s == "dac 10") if (s == "dac 10"|| s == "10")
return defs::DAC_10; return defs::DAC_10;
if (s == "dac 11") if (s == "dac 11"|| s == "11")
return defs::DAC_11; return defs::DAC_11;
if (s == "dac 12") if (s == "dac 12"|| s == "12")
return defs::DAC_12; return defs::DAC_12;
if (s == "dac 13") if (s == "dac 13"|| s == "13")
return defs::DAC_13; return defs::DAC_13;
if (s == "dac 14") if (s == "dac 14"|| s == "14")
return defs::DAC_14; return defs::DAC_14;
if (s == "dac 15") if (s == "dac 15"|| s == "15")
return defs::DAC_15; return defs::DAC_15;
if (s == "dac 16") if (s == "dac 16"|| s == "16")
return defs::DAC_16; return defs::DAC_16;
if (s == "dac 17") if (s == "dac 17"|| s == "17")
return defs::DAC_17; return defs::DAC_17;
if (s == "vsvp") if (s == "vsvp")
return defs::VSVP; return defs::VSVP;

View File

@ -30,4 +30,10 @@ std::string RemoveUnit(std::string &str) {
return unit; return unit;
} }
bool is_int(const std::string &s) {
return !s.empty() && std::find_if(s.begin(), s.end(), [](unsigned char c) {
return !std::isdigit(c);
}) == s.end();
}
}; // namespace sls }; // namespace sls

View File

@ -66,4 +66,14 @@ TEST_CASE("Many characters in a row") {
REQUIRE(std::string(str) == "someeequite::ongstring"); REQUIRE(std::string(str) == "someeequite::ongstring");
} }
TEST_CASE("Check is string is integer"){
REQUIRE(sls::is_int("75"));
REQUIRE(sls::is_int("11675"));
REQUIRE_FALSE(sls::is_int("7.5"));
REQUIRE_FALSE(sls::is_int("hej"));
REQUIRE_FALSE(sls::is_int("7a"));
REQUIRE_FALSE(sls::is_int(""));
}
// TEST_CASE("concat things not being strings") // TEST_CASE("concat things not being strings")