Compare commits

...

17 Commits

Author SHA1 Message Date
dbb1e1de56 generate data every time 2022-07-18 14:49:29 +02:00
ac6433a59b random data from M3 2022-07-18 11:33:11 +02:00
8fcec81a67 Pattern 6 levels (#493)
* separating pattern levels from command name: command line done

* separated patten level from command in examples and default pattern files in servers

* command line and server works

* python: patnloop not verified, wip

* works except for patloop (set, and get does not list properly)

* minor

* fixed tests

* added 3 more levels for ctb and moench

* wip

* minor err msg

* minor

* binaries in

* separating pattern levels from command name: command line done

* separated patten level from command in examples and default pattern files in servers

* command line and server works

* python: patnloop not verified, wip

* works except for patloop (set, and get does not list properly)

* minor

* fixed tests

* added 3 more levels for ctb and moench

* wip

* minor err msg

* minor

* binaries in

* python working

* import fix

* changed fw version for ctb and moench. binaries in

Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com>
2022-07-14 12:00:07 +02:00
5be50785fb rx noRoi should not create files for port (#499) 2022-07-14 10:09:48 +02:00
3d3e70c718 added defines for python (#498) 2022-07-14 10:07:26 +02:00
f1051246ad Configfree (#492)
* prevent mem size check before Detector constructed (for loading config files), allowing freeing shm for submodules

* back to not allowing free submodules - consistency issues
2022-07-12 11:01:44 +02:00
0fc76a81b0 Zmqhint (#495)
* sorted the arguments of cmk.sh

* sorted arguments

* sorting arguments

* added q for zmq hint
2022-07-12 11:01:00 +02:00
b6db097800 udp_cleardst in fpga (#490)
* set number of destination in fpga as well when using udp_cleardst

* ensures fpga destinations are also cleared up

* binaries in
2022-07-05 16:09:41 +02:00
c414d92b86 help script to update submodule 2022-07-05 14:52:23 +02:00
0358838dfb fixed ctb gui for namespace fix 2022-07-05 11:29:23 +02:00
aa93aed4ed updated client versioning 2022-06-09 13:50:41 +02:00
5490daa0a1 storagecells not updated in rx and allowing it in idle mode (#485) 2022-06-09 13:42:18 +02:00
8ca8185d41 H5 one dataset name (#484)
* rename all datasets in hdf5 files to just 'data'

* removing the global qualifier H5

* update release notes
2022-06-09 12:35:33 +02:00
89aa0760c6 Hdf5fix (#483)
* hdf5 fix for string reference

* fix hdf5 compilation after namespace change
2022-06-09 11:42:32 +02:00
3cee36a3db gui hv moved to settings tab from developer tab, allowed also for eiger (#482) 2022-06-08 17:06:08 +02:00
364e0c6268 Udp srcip auto (#480)
* able to set udp_srcip and udp_srcip2 to auto

* minor

* minor
2022-06-08 12:26:49 +02:00
728cb35c37 rxMemsize (#479)
* changing fifo header size to 16 to fix the rxr header (112) to be a power of 2 to make it more efficient and reduce packet loss

* release notes
2022-06-08 12:03:13 +02:00
67 changed files with 1992 additions and 1469 deletions

View File

@ -79,6 +79,10 @@ This document describes the differences between v7.0.0 and v6.x.x
- g2 and m3 clkdiv 2 (system clock) change should affect time settings (g2: exptime, period, delayaftertrigger, burstperiod, m3: exptime, gatedelay, gateperiod, period, delayaftertrigger)
- g2 system frequency is the same irrespective of timing source
- (apparently) rxr doesnt get stuck anymore from 6.1.1
- rxr mem size changed (fifo header size from 8 to 16) due to sls rxr header = 112.. 112+ 16=128 (reduces packet losss especially for g2)
-udp_srcip and udp_Srcip2: can set to auto (for virtual or 1g data networks)
- set dataset name for all hdf5 files to "data" only
- number of storage cells is not updated in teh receiver. done. and also allowing it to be modified in running status
2. Resolved Issues
==================

130
cmk.sh
View File

@ -18,6 +18,7 @@ CTBGUI=0
MANUALS=0
MANUALS_ONLY_RST=0
MOENCHZMQ=0
ZMQ_HINT_DIR=""
CLEAN=0
@ -26,25 +27,26 @@ CMAKE_PRE=""
CMAKE_POST=""
usage() { echo -e "
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [m] [n] [-h] [z] [-d <HDF5 directory>] [-l Install directory] [-k <CMake command>] [-j <Number of threads>]
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of threads>] [-k <CMake command>] [-l <Install directory>] [m] [n] [-p] [-q <Zmq hint directory>] [r] [s] [t] [u] [z]
-[no option]: only make
-c: Clean
-b: Builds/Rebuilds CMake files normal mode
-p: Builds/Rebuilds Python API
-h: Builds/Rebuilds Cmake files with HDF5 package
-c: Clean
-d: HDF5 Custom Directory
-e: Debug mode
-g: Build/Rebuilds only gui
-h: Builds/Rebuilds Cmake files with HDF5 package
-i: Builds tests
-j: Number of threads to compile through
-k: CMake command
-l: Install directory
-t: Build/Rebuilds only text client
-r: Build/Rebuilds only receiver
-g: Build/Rebuilds only gui
-s: Simulator
-u: Chip Test Gui
-j: Number of threads to compile through
-e: Debug mode
-i: Builds tests
-m: Manuals
-n: Manuals without compiling doxygen (only rst)
-p: Builds/Rebuilds Python API
-q: Zmq hint directory
-r: Build/Rebuilds only receiver
-s: Simulator
-t: Build/Rebuilds only text client
-u: Chip Test Gui
-z: Moench zmq processor
Rebuild when you switch to a new build and compile in parallel:
@ -81,69 +83,50 @@ For rebuilding only certain sections
" ; exit 1; }
while getopts ":bpchd:k:l:j:trgeisumnz" opt ; do
while getopts ":bcd:eghij:k:l:mnpq:rstuz" opt ; do
case $opt in
b)
echo "Building of CMake files Required"
REBUILD=1
;;
p)
echo "Compiling Options: Python"
PYTHON=1
REBUILD=1
;;
c)
echo "Clean Required"
CLEAN=1
;;
h)
echo "Building of CMake files with HDF5 option Required"
HDF5=1
REBUILD=1
;;
d)
echo "New HDF5 directory: $OPTARG"
HDF5DIR=$OPTARG
;;
l)
echo "CMake install directory: $OPTARG"
INSTALLDIR="$OPTARG"
e)
echo "Compiling Options: Debug"
DEBUG=1
;;
g)
echo "Compiling Options: GUI"
GUI=1
REBUILD=1
;;
h)
echo "Building of CMake files with HDF5 option Required"
HDF5=1
REBUILD=1
;;
i)
echo "Compiling Options: Tests"
TESTS=1
;;
j)
echo "Number of compiler threads: $OPTARG"
COMPILERTHREADS=$OPTARG
;;
k)
echo "CMake command: $OPTARG"
CMAKE="$OPTARG"
;;
j)
echo "Number of compiler threads: $OPTARG"
COMPILERTHREADS=$OPTARG
l)
echo "CMake install directory: $OPTARG"
INSTALLDIR="$OPTARG"
;;
t)
echo "Compiling Options: Text Client"
TEXTCLIENT=1
REBUILD=1
;;
r)
echo "Compiling Options: Receiver"
RECEIVER=1
REBUILD=1
;;
g)
echo "Compiling Options: GUI"
GUI=1
REBUILD=1
;;
e)
echo "Compiling Options: Debug"
DEBUG=1
;;
i)
echo "Compiling Options: Tests"
TESTS=1
;;
s)
echo "Compiling Options: Simulator"
SIMULATOR=1
;;
m)
echo "Compiling Manuals"
MANUALS=1
@ -152,14 +135,37 @@ while getopts ":bpchd:k:l:j:trgeisumnz" opt ; do
echo "Compiling Manuals (Only RST)"
MANUALS_ONLY_RST=1
;;
z)
echo "Compiling Moench Zmq Processor"
MOENCHZMQ=1
p)
echo "Compiling Options: Python"
PYTHON=1
REBUILD=1
;;
q)
echo "Zmq hint directory: $OPTARG"
ZMQ_HINT_DIR=$OPTARG
;;
r)
echo "Compiling Options: Receiver"
RECEIVER=1
REBUILD=1
;;
s)
echo "Compiling Options: Simulator"
SIMULATOR=1
;;
t)
echo "Compiling Options: Text Client"
TEXTCLIENT=1
REBUILD=1
;;
u)
echo "Compiling Options: Chip Test Gui"
CTBGUI=1
;;
z)
echo "Compiling Moench Zmq Processor"
MOENCHZMQ=1
;;
\?)
echo "Invalid option: -$OPTARG"
usage
@ -254,6 +260,12 @@ if [ $TESTS -eq 1 ]; then
echo "Tests Option enabled"
fi
#zmq hint dir
if [ -n "$ZMQ_HINT_DIR" ]; then
CMAKE_POST+=" -DZeroMQ_HINT="$ZMQ_HINT_DIR
CMAKE_POST+=" -DZeroMQ_DIR="
# echo "Enabling Zmq Hint Directory: $ZMQ_HINT_DIR"
fi
#hdf5 rebuild
if [ $HDF5 -eq 1 ]; then

View File

@ -828,14 +828,14 @@ void ctbAcquisition::setCanvas(TCanvas* c) {
myCanvas->AddExec("dynamic",Form("((ctbAcquisition*)%p)->canvasClicked()",this));
// myCanvas->AddExec("ex","canvasClicked()");
}
void ctbAcquisition::dataCallback(detectorData *data, long unsigned int index, unsigned int dum, void* pArgs) {
void ctbAcquisition::dataCallback(sls::detectorData *data, long unsigned int index, unsigned int dum, void* pArgs) {
// return
((ctbAcquisition*)pArgs)->plotData(data,index);
}
int ctbAcquisition::plotData(detectorData *data, int index) {
int ctbAcquisition::plotData(sls::detectorData *data, int index) {
/*
******************************************************************

View File

@ -28,8 +28,8 @@ class TGTextButton;
namespace sls
{
class Detector;
class detectorData;
};
class detectorData;
template <class dataType> class slsDetectorData;
@ -201,10 +201,10 @@ class ctbAcquisition : public TGGroupFrame {
void setBitGraph (int i ,int en, Pixel_t col);
void startAcquisition();
static void progressCallback(double,void*);
static void dataCallback(detectorData*, long unsigned int, unsigned int, void*);
static void dataCallback(sls::detectorData*, long unsigned int, unsigned int, void*);
int StopFlag;
int plotData(detectorData*, int);
int plotData(sls::detectorData*, int);
void setPatternFile(const char* t);

View File

@ -409,18 +409,18 @@ patword 018d 0008599f0008503a
patioctrl 8f0effff6dbffdbf
patclkctrl 0000000000000000
patlimits 0000 018c
patloop0 013a 016b
patnloop0 199
patloop1 0400 0400
patnloop1 0
patloop2 0400 0400
patnloop2 0
patwait0 00aa
patwaittime0 10000
patwait1 0400
patwaittime1 0
patwait2 0400
patwaittime2 0
patloop 0 013a 016b
patnloop 0 199
patloop 1 0400 0400
patnloop 1 0
patloop 2 0400 0400
patnloop 2 0
patwait 0 00aa
patwaittime 0 10000
patwait 1 0400
patwaittime 1 0
patwait 2 0400
patwaittime 2 0
#############################################
### edit with hostname or 1Gbs IP address of your server

View File

@ -427,18 +427,18 @@ patword 0x018c 0x0008599f0008503a
patword 0x018d 0x0008599f0008503a
patioctrl 0x8f0effff6dbffdbf
patlimits 0x0000 0x018c
patloop0 0x013a 0x016b
patnloop0 0x199
patloop1 0x0400 0x0400
patnloop1 0
patloop2 0x0400 0x0400
patnloop2 0
patwait0 0x00aa
patwaittime0 10000
patwait1 0x0400
patwaittime1 0
patwait2 0x0400
patwaittime2 0
patloop 0 0x013a 0x016b
patnloop 0 0x199
patloop 1 0x0400 0x0400
patnloop 1 0
patloop 2 0x0400 0x0400
patnloop 2 0
patwait 0 0x00aa
patwaittime 0 10000
patwait 1 0x0400
patwaittime 1 0
patwait 2 0x0400
patwaittime 2 0
# dacs
dac 6 800

View File

@ -29,6 +29,7 @@ set( PYTHON_FILES
decorators.py
detector_property.py
detector.py
defines.py
eiger.py
enums.py
errors.py

View File

@ -11,7 +11,7 @@ enums.cpp
import re
import subprocess
from parse import remove_comments
from parse import remove_comments, remove_ifdefs
allow_bitwise_op = ["streamingInterface", "M3_GainCaps"]
@ -98,25 +98,25 @@ def generate_enum_string(enums):
return ''.join(data)
def remove_ifdefs(lines):
"""Keeps C++ version of the code"""
out = []
it = iter(lines)
skip = False
for line in it:
# def remove_ifdefs(lines):
# """Keeps C++ version of the code"""
# out = []
# it = iter(lines)
# skip = False
# for line in it:
if "#ifdef __cplusplus" in line:
line = next(it)
# if "#ifdef __cplusplus" in line:
# line = next(it)
if "#else" in line:
skip = True
# if "#else" in line:
# skip = True
if "#endif" in line:
skip = False
# if "#endif" in line:
# skip = False
if not skip and "#endif" not in line:
out.append(line)
return out
# if not skip and "#endif" not in line:
# out.append(line)
# return out
with open('../../slsSupportLib/include/sls/sls_detector_defs.h') as f:

View File

@ -0,0 +1,30 @@
import re
import subprocess
from parse import remove_comments, remove_ifdefs
with open('../../slsSupportLib/include/sls/sls_detector_defs.h') as f:
data = f.read()
data = remove_comments(data)
data = data.splitlines()
# data = remove_ifdefs(data)
ignore = ['#define MYROOT', '#define __cplusplus']
defines = {}
for i, line in enumerate(data):
if line.startswith('#define') and line not in ignore:
_, name, value = line.split(maxsplit = 2)
print(f'{name}={value}')
defines[name]=value
warning = '#WARINING This file is auto generated any edits might be overwritten without warning\n\n'
with open('../slsdet/defines.py', 'w') as f:
f.write(warning)
for key, value in defines.items():
f.write(f'{key}={value}\n')

View File

@ -25,7 +25,25 @@ def remove_comments(text):
)
return re.sub(pattern, replacer, text)
def remove_ifdefs(lines):
"""Keeps C++ version of the code"""
out = []
it = iter(lines)
skip = False
for line in it:
if "#ifdef __cplusplus" in line:
line = next(it)
if "#else" in line:
skip = True
if "#endif" in line:
skip = False
if not skip and "#endif" not in line:
out.append(line)
return out
#based on ccsyspath: https://github.com/AndrewWalker/ccsyspath

View File

@ -17,8 +17,9 @@ import _slsdet
xy = _slsdet.xy
defs = _slsdet.slsDetectorDefs
#Make enums and #defines available at top level
from .enums import *
from .defines import *
IpAddr = _slsdet.IpAddr
MacAddr = _slsdet.MacAddr

31
python/slsdet/defines.py Normal file
View File

@ -0,0 +1,31 @@
#WARINING This file is auto generated any edits might be overwritten without warning
BIT32_MASK=0xFFFFFFFF
MAX_RX_DBIT=64
DEFAULT_PORTNO=1952
DEFAULT_UDP_PORTNO=50001
DEFAULT_ZMQ_CL_PORTNO=30001
DEFAULT_ZMQ_RX_PORTNO=30001
DEFAULT_UDP_SRC_PORTNO=32410
DEFAULT_UDP_DST_PORTNO=50001
MAX_UDP_DESTINATION=32
SLS_DETECTOR_HEADER_VERSION=0x2
SLS_DETECTOR_JSON_HEADER_VERSION=0x4
UDP_PACKET_DATA_BYTES=(1344)
MAX_TRIMEN=100
MAX_BLACKFIN_PROGRAM_SIZE=(128 * 1024)
GET_FLAG=-1
DEFAULT_DET_MAC="00:aa:bb:cc:dd:ee"
DEFAULT_DET_IP="129.129.202.45"
DEFAULT_DET_MAC2="00:aa:bb:cc:dd:ff"
DEFAULT_DET_IP2="129.129.202.46"
LOCALHOST_IP="127.0.0.1"
MAX_STR_LENGTH=1000
SHORT_STR_LENGTH=20
MAX_PATTERN_LENGTH=0x2000
MAX_PATTERN_LEVELS=6
M3_MAX_PATTERN_LEVELS=3
DEFAULT_STREAMING_TIMER_IN_MS=500
NUM_RX_THREAD_IDS=9
MAX_NUM_PACKETS=512
TRIMBITMASK=0x3f

View File

@ -17,7 +17,7 @@ from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
from .utils import Geometry, to_geo, element, reduce_time, is_iterable
from _slsdet import xy
from . import utils as ut
from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy, MaxPhaseProxy, ClkFreqProxy
from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy, MaxPhaseProxy, ClkFreqProxy, PatLoopProxy, PatNLoopProxy, PatWaitProxy, PatWaitTimeProxy
from .registers import Register, Adc_register
import datetime as dt
@ -3098,6 +3098,24 @@ class Detector(CppDetectorApi):
def patmask(self, mask):
ut.set_using_dict(self.setPatternMask, mask)
@property
# @element
def patwait(self):
"""
[Ctb][Moench][Mythen3] Wait address of loop level provided.
Example
-------
>>> d.patwait[0] = 5
>>> d.patwait[0]
5
>>> d.patwait
0: 5
1: 20
2: 30
"""
return PatWaitProxy(self)
@property
@element
def patwait0(self):
@ -3158,6 +3176,23 @@ class Detector(CppDetectorApi):
addr = ut.merge_args(2, addr)
ut.set_using_dict(self.setPatternWaitAddr, *addr)
@property
def patwaittime(self):
"""
[Ctb][Moench][Mythen3] Wait time in clock cycles of loop level provided.
Example
-------
>>> d.patwaittime[0] = 5
>>> d.patwaittime[0]
5
>>> d.patwaittime
0: 5
1: 20
2: 30
"""
return PatWaitTimeProxy(self)
@property
@element
def patwaittime0(self):
@ -3192,6 +3227,23 @@ class Detector(CppDetectorApi):
ut.set_using_dict(self.setPatternWaitTime, *nclk)
@property
def patloop(self):
"""
[Ctb][Moench][Mythen3] Limits (start and stop address) of the loop provided.
Example
-------
>>> d.patloop[0] = [5, 20]
>>> d.patloop[0]
[5, 20]
>>> d.patloop
0: [5, 20]
1: [20, 4]
2: [30, 5]
"""
return PatLoopProxy(self)
@property
@element
def patloop0(self):
@ -3254,6 +3306,24 @@ class Detector(CppDetectorApi):
addr = ut.merge_args(2, addr)
ut.set_using_dict(self.setPatternLoopAddresses, *addr)
@property
def patnloop(self):
"""
[Ctb][Moench][Mythen3] Number of cycles of the loop provided.
Example
-------
>>> d.patnloop[0] = 5
>>> d.patnloop[0]
5
>>> d.patnloop
0: 5
1: 20
2: 30
"""
return PatNLoopProxy(self)
@property
@element
def patnloop0(self):

View File

@ -2,14 +2,24 @@
# Copyright (C) 2021 Contributors to the SLS Detector Package
from .utils import element_if_equal
from .enums import dacIndex
from .defines import M3_MAX_PATTERN_LEVELS, MAX_PATTERN_LEVELS
from _slsdet import slsDetectorDefs
def set_proxy_using_dict(func, key, value):
def set_proxy_using_dict(func, key, value, unpack = False):
if isinstance(value, dict) and all(isinstance(k, int) for k in value.keys()):
for dkey, dvalue in value.items():
func(key, dvalue, [dkey])
if unpack:
for dkey, dvalue in value.items():
func(key, *dvalue, [dkey])
else:
for dkey, dvalue in value.items():
func(key, dvalue, [dkey])
else:
func(key, value)
if unpack:
func(key, *value)
else:
func(key, value)
class JsonProxy:
"""
@ -127,4 +137,118 @@ class ClkFreqProxy:
else:
rstr += f'{i}: {r}\n'
return rstr.strip('\n')
return rstr.strip('\n')
class PatLoopProxy:
"""
Proxy class to allow for more intuitive reading patloop
"""
def __init__(self, det):
self.det = det
def __getitem__(self, key):
return element_if_equal(self.det.getPatternLoopAddresses(key))
def __setitem__(self, key, value):
set_proxy_using_dict(self.det.setPatternLoopAddresses, key, value, unpack = True)
def __repr__(self):
max_levels = MAX_PATTERN_LEVELS
if self.det.type == slsDetectorDefs.detectorType.MYTHEN3:
max_levels = M3_MAX_PATTERN_LEVELS
rstr = ''
for i in range(max_levels):
r = self.__getitem__(i)
if isinstance(r[0], list):
part = ' '.join(f'{item}' for item in r)
rstr += f'{i}: {part}\n'
else:
rstr += f'{i}: {r}\n'
return rstr.strip('\n')
class PatNLoopProxy:
"""
Proxy class to allow for more intuitive reading patnloop
"""
def __init__(self, det):
self.det = det
def __getitem__(self, key):
return element_if_equal(self.det.getPatternLoopCycles(key))
def __setitem__(self, key, value):
set_proxy_using_dict(self.det.setPatternLoopCycles, key, value)
def __repr__(self):
max_levels = MAX_PATTERN_LEVELS
if self.det.type == slsDetectorDefs.detectorType.MYTHEN3:
max_levels = M3_MAX_PATTERN_LEVELS
rstr = ''
for i in range(max_levels):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
part = ', '.join(f'{item}' for item in r)
rstr += f'{i}: {part}\n'
else:
rstr += f'{i}: {r}\n'
return rstr.strip('\n')
class PatWaitProxy:
"""
Proxy class to allow for more intuitive reading patwait
"""
def __init__(self, det):
self.det = det
def __getitem__(self, key):
return element_if_equal(self.det.getPatternWaitAddr(key))
def __setitem__(self, key, value):
set_proxy_using_dict(self.det.setPatternWaitAddr, key, value)
def __repr__(self):
max_levels = MAX_PATTERN_LEVELS
if self.det.type == slsDetectorDefs.detectorType.MYTHEN3:
max_levels = M3_MAX_PATTERN_LEVELS
rstr = ''
for i in range(max_levels):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
part = ', '.join(f'{item}' for item in r)
rstr += f'{i}: {part}\n'
else:
rstr += f'{i}: {r}\n'
return rstr.strip('\n')
class PatWaitTimeProxy:
"""
Proxy class to allow for more intuitive reading patwaittime
"""
def __init__(self, det):
self.det = det
def __getitem__(self, key):
return element_if_equal(self.det.getPatternWaitTime(key))
def __setitem__(self, key, value):
set_proxy_using_dict(self.det.setPatternWaitTime, key, value)
def __repr__(self):
max_levels = MAX_PATTERN_LEVELS
if self.det.type == slsDetectorDefs.detectorType.MYTHEN3:
max_levels = M3_MAX_PATTERN_LEVELS
rstr = ''
for i in range(max_levels):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
part = ', '.join(f'{item}' for item in r)
rstr += f'{i}: {part}\n'
else:
rstr += f'{i}: {r}\n'
return rstr.strip('\n')

View File

@ -14,7 +14,7 @@ void init_pattern(py::module &m) {
using pat = sls::patternParameters;
py::class_<pat> patternParameters(m, "patternParameters");
PYBIND11_NUMPY_DTYPE(pat, word, ioctrl, limits, loop, nloop, wait,
PYBIND11_NUMPY_DTYPE(pat, word, ioctrl, limits, startloop, stoploop, nloop, wait,
waittime);
patternParameters.def(py::init());

View File

@ -32,17 +32,29 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="lblReadout">
<item row="1" column="0" colspan="3">
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>5</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Readout: </string>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tabDAC">
<attribute name="title">
<string>DACs</string>
</attribute>
<layout class="QGridLayout" name="gridlayoutDac"/>
</widget>
<widget class="QWidget" name="tabADC">
<attribute name="title">
<string>ADCs</string>
</attribute>
<layout class="QGridLayout" name="gridlayoutAdc"/>
</widget>
</widget>
</item>
<item row="0" column="1">
@ -77,145 +89,19 @@
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblComboHV">
<item row="0" column="0">
<widget class="QLabel" name="lblReadout">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage&lt;/p&gt;&lt;p&gt; #highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>High Voltage: </string>
<string>Readout: </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage&lt;/p&gt;&lt;p&gt; #highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>0</string>
</property>
</item>
<item>
<property name="text">
<string>90</string>
</property>
</item>
<item>
<property name="text">
<string>110</string>
</property>
</item>
<item>
<property name="text">
<string>120</string>
</property>
</item>
<item>
<property name="text">
<string>150</string>
</property>
</item>
<item>
<property name="text">
<string>180</string>
</property>
</item>
<item>
<property name="text">
<string>200</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblSpinHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.&lt;/p&gt;&lt;p&gt;-1 corresponds to different values from detectors.&lt;/p&gt;&lt;p&gt;#highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>High Voltage: </string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="spinHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.&lt;/p&gt;&lt;p&gt;-1 corresponds to different values from detectors.&lt;/p&gt;&lt;p&gt;#highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>200</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>5</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tabDAC">
<attribute name="title">
<string>DACs</string>
</attribute>
<layout class="QGridLayout" name="gridlayoutDac"/>
</widget>
<widget class="QWidget" name="tabADC">
<attribute name="title">
<string>ADCs</string>
</attribute>
<layout class="QGridLayout" name="gridlayoutAdc"/>
</widget>
</widget>
</item>
</layout>
</widget>
<resources>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>775</width>
<height>385</height>
<height>400</height>
</rect>
</property>
<property name="sizePolicy">
@ -32,7 +32,77 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<item row="0" column="2" colspan="5">
<widget class="QComboBox" name="comboHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage&lt;/p&gt;&lt;p&gt; #highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>0</string>
</property>
</item>
<item>
<property name="text">
<string>90</string>
</property>
</item>
<item>
<property name="text">
<string>110</string>
</property>
</item>
<item>
<property name="text">
<string>120</string>
</property>
</item>
<item>
<property name="text">
<string>150</string>
</property>
</item>
<item>
<property name="text">
<string>180</string>
</property>
</item>
<item>
<property name="text">
<string>200</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblComboHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage&lt;/p&gt;&lt;p&gt; #highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>High Voltage: </string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lblThreshold">
<property name="enabled">
<bool>false</bool>
@ -54,7 +124,7 @@
</property>
</widget>
</item>
<item row="4" column="4">
<item row="6" column="4">
<widget class="QCheckBox" name="chkCounter3">
<property name="enabled">
<bool>false</bool>
@ -73,7 +143,7 @@
</property>
</widget>
</item>
<item row="2" column="14">
<item row="4" column="14">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -89,7 +159,7 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<item row="2" column="0">
<widget class="QLabel" name="lblSettings">
<property name="enabled">
<bool>true</bool>
@ -111,7 +181,7 @@
</property>
</widget>
</item>
<item row="4" column="2">
<item row="6" column="2">
<widget class="QCheckBox" name="chkCounter1">
<property name="enabled">
<bool>false</bool>
@ -130,7 +200,7 @@
</property>
</widget>
</item>
<item row="0" column="2" colspan="9">
<item row="2" column="2" colspan="9">
<widget class="QComboBox" name="comboSettings">
<property name="enabled">
<bool>true</bool>
@ -144,7 +214,7 @@
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
<height>28</height>
</size>
</property>
<property name="maximumSize">
@ -269,7 +339,7 @@
</item>
</widget>
</item>
<item row="2" column="11">
<item row="4" column="11">
<widget class="QSpinBox" name="spinThreshold2">
<property name="enabled">
<bool>false</bool>
@ -306,7 +376,7 @@
</property>
</widget>
</item>
<item row="2" column="13">
<item row="4" column="13">
<widget class="QPushButton" name="btnSetThreshold">
<property name="enabled">
<bool>true</bool>
@ -381,7 +451,7 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="2" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -397,7 +467,7 @@
</property>
</spacer>
</item>
<item row="2" column="12">
<item row="4" column="12">
<widget class="QSpinBox" name="spinThreshold3">
<property name="enabled">
<bool>false</bool>
@ -434,7 +504,23 @@
</property>
</widget>
</item>
<item row="2" column="2" colspan="9">
<item row="7" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>190</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="2" colspan="9">
<widget class="QSpinBox" name="spinThreshold">
<property name="enabled">
<bool>false</bool>
@ -471,7 +557,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="6" column="0">
<widget class="QLabel" name="lblCounter">
<property name="enabled">
<bool>false</bool>
@ -493,7 +579,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="5" column="0">
<widget class="QLabel" name="lblDynamicRange">
<property name="enabled">
<bool>false</bool>
@ -515,23 +601,7 @@
</property>
</widget>
</item>
<item row="5" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>190</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<item row="3" column="0">
<widget class="QLabel" name="lblGainMode">
<property name="enabled">
<bool>false</bool>
@ -553,7 +623,7 @@
</property>
</widget>
</item>
<item row="3" column="2" colspan="9">
<item row="5" column="2" colspan="9">
<widget class="QComboBox" name="comboDynamicRange">
<property name="enabled">
<bool>false</bool>
@ -561,7 +631,7 @@
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
<height>28</height>
</size>
</property>
<property name="maximumSize">
@ -597,7 +667,7 @@
</item>
</widget>
</item>
<item row="4" column="3">
<item row="6" column="3">
<widget class="QCheckBox" name="chkCounter2">
<property name="enabled">
<bool>false</bool>
@ -616,7 +686,7 @@
</property>
</widget>
</item>
<item row="1" column="2" colspan="9">
<item row="3" column="2" colspan="9">
<widget class="QComboBox" name="comboGainMode">
<property name="enabled">
<bool>false</bool>
@ -630,7 +700,7 @@
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
<height>28</height>
</size>
</property>
<property name="maximumSize">
@ -674,6 +744,50 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblSpinHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.&lt;/p&gt;&lt;p&gt;-1 corresponds to different values from detectors.&lt;/p&gt;&lt;p&gt;#highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>High Voltage: </string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="5">
<widget class="QSpinBox" name="spinHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.&lt;/p&gt;&lt;p&gt;-1 corresponds to different values from detectors.&lt;/p&gt;&lt;p&gt;#highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>200</number>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>

View File

@ -20,25 +20,16 @@ class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject {
public slots:
void Refresh();
private slots:
void SetHighVoltage();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void GetHighVoltage();
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType,
int index);
Detector *det;
std::vector<qDacWidget *> dacWidgets;
std::vector<qDacWidget *> adcWidgets;
enum hvVals { HV_0, HV_90, HV_110, HV_120, HV_150, HV_180, HV_200 };
int hvmin;
static const int HV_MIN = 60;
static const int HV_MAX = 200;
};
} // namespace sls

View File

@ -18,6 +18,7 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
void SetExportMode(bool exportMode);
private slots:
void SetHighVoltage();
void SetSettings(int index);
void SetGainMode(int index);
void SetDynamicRange(int index);
@ -32,6 +33,7 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
void ShowFixG0(bool expertMode);
void Initialization();
void GetHighVoltage();
void GetSettings();
void GetGainMode();
void GetDynamicRange();
@ -42,6 +44,12 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
Detector *det;
std::vector<QCheckBox *> counters;
enum hvVals { HV_0, HV_90, HV_110, HV_120, HV_150, HV_180, HV_200 };
int hvmin;
static const int HV_MIN = 60;
static const int HV_MAX = 200;
enum {
STANDARD,
FAST,

View File

@ -15,6 +15,8 @@
#include <qwt_symbol.h>
#include <stdlib.h>
#include <array>
namespace sls {
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm

View File

@ -2,6 +2,7 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include "SlsQt2DPlot.h"
// #include "sls/ansi.h"
#include <array>
#include <qlist.h>
#include <qprinter.h>

View File

@ -18,12 +18,6 @@ qTabDeveloper::~qTabDeveloper() {}
void qTabDeveloper::SetupWidgetWindow() {
int tempid = 0;
comboHV->hide();
lblComboHV->hide();
lblSpinHV->hide();
spinHV->hide();
hvmin = HV_MIN;
try {
slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
switch (detType) {
@ -84,8 +78,6 @@ void qTabDeveloper::SetupWidgetWindow() {
break;
case slsDetectorDefs::GOTTHARD:
comboHV->show();
lblComboHV->show();
dacWidgets.push_back(new qDacWidget(
this, det, true,
"v Reference: ", getSLSIndex(detType, tempid++)));
@ -119,8 +111,6 @@ void qTabDeveloper::SetupWidgetWindow() {
break;
case slsDetectorDefs::JUNGFRAU:
lblSpinHV->show();
spinHV->show();
dacWidgets.push_back(
new qDacWidget(this, det, true,
"v vb comp: ", getSLSIndex(detType, tempid++)));
@ -150,8 +140,6 @@ void qTabDeveloper::SetupWidgetWindow() {
break;
case slsDetectorDefs::MOENCH:
lblSpinHV->show();
spinHV->show();
dacWidgets.push_back(
new qDacWidget(this, det, true,
"vbp_colbuf: ", getSLSIndex(detType, tempid++)));
@ -175,9 +163,6 @@ void qTabDeveloper::SetupWidgetWindow() {
break;
case slsDetectorDefs::MYTHEN3:
lblSpinHV->show();
spinHV->show();
hvmin = 0;
dacWidgets.push_back(new qDacWidget(
this, det, true, "vcassh: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
@ -218,9 +203,6 @@ void qTabDeveloper::SetupWidgetWindow() {
break;
case slsDetectorDefs::GOTTHARD2:
lblSpinHV->show();
spinHV->show();
hvmin = 0;
dacWidgets.push_back(
new qDacWidget(this, det, true,
"vref_h_adc: ", getSLSIndex(detType, tempid++)));
@ -292,9 +274,6 @@ void qTabDeveloper::SetupWidgetWindow() {
void qTabDeveloper::Initialization() {
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(Refresh()));
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
}
void qTabDeveloper::PopulateDetectors() {
@ -311,75 +290,6 @@ void qTabDeveloper::PopulateDetectors() {
comboDetector->setCurrentIndex(0);
}
void qTabDeveloper::GetHighVoltage() {
// not enabled for eiger
if (!comboHV->isVisible() && !spinHV->isVisible())
return;
LOG(logDEBUG) << "Getting High Voltage";
disconnect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
try {
// dac units
auto retval = det->getHighVoltage({comboDetector->currentIndex() - 1})
.tsquash("Inconsistent values for high voltage.");
// spinHV
if (spinHV->isVisible()) {
if (retval != 0 && retval < hvmin && retval > HV_MAX) {
throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
spinHV->setValue(retval);
}
// combo HV
else {
switch (retval) {
case 0:
comboHV->setCurrentIndex(HV_0);
break;
case 90:
comboHV->setCurrentIndex(HV_90);
break;
case 110:
comboHV->setCurrentIndex(HV_110);
break;
case 120:
comboHV->setCurrentIndex(HV_120);
break;
case 150:
comboHV->setCurrentIndex(HV_150);
break;
case 180:
comboHV->setCurrentIndex(HV_180);
break;
case 200:
comboHV->setCurrentIndex(HV_200);
break;
default:
throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
}
}
CATCH_DISPLAY("Could not get high voltage.",
"qTabDeveloper::GetHighVoltage")
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
}
void qTabDeveloper::SetHighVoltage() {
int val = (comboHV->isVisible() ? comboHV->currentText().toInt()
: spinHV->value());
LOG(logINFO) << "Setting high voltage:" << val;
try {
det->setHighVoltage({comboDetector->currentIndex() - 1});
}
CATCH_HANDLE("Could not set high voltage.", "qTabDeveloper::SetHighVoltage",
this, &qTabDeveloper::GetHighVoltage)
}
slsDetectorDefs::dacIndex
qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
switch (detType) {
@ -606,7 +516,6 @@ void qTabDeveloper::Refresh() {
for (const auto &it : adcWidgets) {
it->SetDetectorIndex(comboDetector->currentIndex() - 1);
}
GetHighVoltage();
LOG(logDEBUG) << "**Updated Developer Tab";
}

View File

@ -19,6 +19,12 @@ qTabSettings::~qTabSettings() {}
void qTabSettings::SetupWidgetWindow() {
comboHV->hide();
lblComboHV->hide();
lblSpinHV->hide();
spinHV->hide();
hvmin = HV_MIN;
counters = std::vector<QCheckBox *>{chkCounter1, chkCounter2, chkCounter3};
spinThreshold2->hide();
@ -37,6 +43,9 @@ void qTabSettings::SetupWidgetWindow() {
// enabling according to det type
slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
if (detType == slsDetectorDefs::MYTHEN3) {
lblSpinHV->show();
spinHV->show();
hvmin = 0;
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
@ -77,13 +86,28 @@ void qTabSettings::SetupWidgetWindow() {
}
}
} else if (detType == slsDetectorDefs::EIGER) {
lblSpinHV->show();
spinHV->show();
hvmin = 0;
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
} else if (detType == slsDetectorDefs::JUNGFRAU) {
lblSpinHV->show();
spinHV->show();
lblGainMode->setEnabled(true);
comboGainMode->setEnabled(true);
} else if (detType == slsDetectorDefs::GOTTHARD) {
comboHV->show();
lblComboHV->show();
} else if (detType == slsDetectorDefs::MOENCH) {
lblSpinHV->show();
spinHV->show();
} else if (detType == slsDetectorDefs::GOTTHARD2) {
lblSpinHV->show();
spinHV->show();
hvmin = 0;
}
// default settings for the disabled
@ -165,6 +189,11 @@ void qTabSettings::ShowFixG0(bool expertMode) {
}
void qTabSettings::Initialization() {
// High voltage
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
// Settings
if (comboSettings->isEnabled())
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
@ -201,6 +230,91 @@ void qTabSettings::Initialization() {
}
}
void qTabSettings::GetHighVoltage() {
// not enabled for eiger
if (!comboHV->isVisible() && !spinHV->isVisible())
return;
LOG(logDEBUG) << "Getting High Voltage";
disconnect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
try {
Result<int> retvals = det->getHighVoltage();
int retval = 0;
if (det->getDetectorType().squash() != slsDetectorDefs::EIGER) {
retval = retvals.tsquash("Inconsistent values for high voltage.");
}
// eiger slaves return -999
else {
auto is_master = det->getMaster();
Result<int> master_retvals;
for (size_t i = 0; i != retvals.size(); ++i) {
if (is_master[i]) {
master_retvals.push_back(retvals[i]);
}
}
retval = master_retvals.tsquash("Inconsistent values for high voltage.");
}
// spinHV
if (spinHV->isVisible()) {
if (retval != 0 && retval < hvmin && retval > HV_MAX) {
throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
spinHV->setValue(retval);
}
// combo HV
else {
switch (retval) {
case 0:
comboHV->setCurrentIndex(HV_0);
break;
case 90:
comboHV->setCurrentIndex(HV_90);
break;
case 110:
comboHV->setCurrentIndex(HV_110);
break;
case 120:
comboHV->setCurrentIndex(HV_120);
break;
case 150:
comboHV->setCurrentIndex(HV_150);
break;
case 180:
comboHV->setCurrentIndex(HV_180);
break;
case 200:
comboHV->setCurrentIndex(HV_200);
break;
default:
throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
}
}
CATCH_DISPLAY("Could not get high voltage.",
"qTabSettings::GetHighVoltage")
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
}
void qTabSettings::SetHighVoltage() {
int val = (comboHV->isVisible() ? comboHV->currentText().toInt()
: spinHV->value());
LOG(logINFO) << "Setting high voltage:" << val;
try {
det->setHighVoltage(val);
}
CATCH_HANDLE("Could not set high voltage.", "qTabSettings::SetHighVoltage",
this, &qTabSettings::GetHighVoltage)
}
void qTabSettings::GetSettings() {
LOG(logDEBUG) << "Getting settings";
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
@ -472,6 +586,8 @@ void qTabSettings::SetCounterMask() {
void qTabSettings::Refresh() {
LOG(logDEBUG) << "**Updating Settings Tab";
GetHighVoltage();
if (comboSettings->isEnabled()) {
GetSettings();
}

View File

@ -568,6 +568,72 @@
#define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT)
#define PATTERN_SET_MSB_REG (0x83 << MEM_MAP_SHIFT)
/* Pattern Loop 3 Address RW regiser */
#define PATTERN_LOOP_3_ADDR_REG (0x84 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_3_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_3_ADDR_STRT_MSK \
(0x00001FFF << PATTERN_LOOP_3_ADDR_STRT_OFST)
#define PATTERN_LOOP_3_ADDR_STP_OFST (16)
#define PATTERN_LOOP_3_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_3_ADDR_STP_OFST)
/* Pattern Loop 3 Iteration RW regiser */
#define PATTERN_LOOP_3_ITERATION_REG (0x85 << MEM_MAP_SHIFT)
/* Pattern Loop 4 Address RW regiser */
#define PATTERN_LOOP_4_ADDR_REG (0x86 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_4_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_4_ADDR_STRT_MSK \
(0x00001FFF << PATTERN_LOOP_4_ADDR_STRT_OFST)
#define PATTERN_LOOP_4_ADDR_STP_OFST (16)
#define PATTERN_LOOP_4_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_4_ADDR_STP_OFST)
/* Pattern Loop 4 Iteration RW regiser */
#define PATTERN_LOOP_4_ITERATION_REG (0x87 << MEM_MAP_SHIFT)
/* Pattern Loop 5 Address RW regiser */
#define PATTERN_LOOP_5_ADDR_REG (0x88 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_5_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_5_ADDR_STRT_MSK \
(0x00001FFF << PATTERN_LOOP_5_ADDR_STRT_OFST)
#define PATTERN_LOOP_5_ADDR_STP_OFST (16)
#define PATTERN_LOOP_5_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_5_ADDR_STP_OFST)
/* Pattern Loop 5 Iteration RW regiser */
#define PATTERN_LOOP_5_ITERATION_REG (0x89 << MEM_MAP_SHIFT)
/* Pattern Wait 3 RW regiser */
#define PATTERN_WAIT_3_ADDR_REG (0x8A << MEM_MAP_SHIFT)
#define PATTERN_WAIT_3_ADDR_OFST (0)
#define PATTERN_WAIT_3_ADDR_MSK (0x00001FFF << PATTERN_WAIT_3_ADDR_OFST)
/* Pattern Wait 4 RW regiser */
#define PATTERN_WAIT_4_ADDR_REG (0x8B << MEM_MAP_SHIFT)
#define PATTERN_WAIT_4_ADDR_OFST (0)
#define PATTERN_WAIT_4_ADDR_MSK (0x00001FFF << PATTERN_WAIT_4_ADDR_OFST)
/* Pattern Wait 5 RW regiser */
#define PATTERN_WAIT_5_ADDR_REG (0x8C << MEM_MAP_SHIFT)
#define PATTERN_WAIT_5_ADDR_OFST (0)
#define PATTERN_WAIT_5_ADDR_MSK (0x00001FFF << PATTERN_WAIT_5_ADDR_OFST)
/* Pattern Wait Timer 3 64 bit RW register. t = PWT1 x T run clock */
#define PATTERN_WAIT_TIMER_3_LSB_REG (0x8D << MEM_MAP_SHIFT)
#define PATTERN_WAIT_TIMER_3_MSB_REG (0x8E << MEM_MAP_SHIFT)
/* Pattern Wait Timer 4 64 bit RW register. t = PWT1 x T run clock */
#define PATTERN_WAIT_TIMER_4_LSB_REG (0x8F << MEM_MAP_SHIFT)
#define PATTERN_WAIT_TIMER_4_MSB_REG (0x90 << MEM_MAP_SHIFT)
/* Pattern Wait Timer 5 64 bit RW register. t = PWT1 x T run clock */
#define PATTERN_WAIT_TIMER_5_LSB_REG (0x91 << MEM_MAP_SHIFT)
#define PATTERN_WAIT_TIMER_5_MSB_REG (0x92 << MEM_MAP_SHIFT)
/** I2C Control register */
#define I2C_TRANSFER_COMMAND_FIFO_REG (0x100 << MEM_MAP_SHIFT)
#define I2C_RX_DATA_FIFO_REG (0x101 << MEM_MAP_SHIFT)

View File

@ -5,7 +5,7 @@
#include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x181130
#define REQRD_FRMWR_VRSN 0x201005
#define REQRD_FRMWR_VRSN 0x220714
#define LINKED_SERVER_NAME "ctbDetectorServer"

View File

@ -274,15 +274,28 @@ patword 0x0110 0x0008599f0008503a
patword 0x0111 0x0008599f0008503a
patioctrl 0x8f0effff6dbffdbf
patlimits 0x0000 0x0110
patloop0 0x00be 0x00ef
patnloop0 199
patloop1 0x0400 0x0400
patnloop1 0
patloop2 0x0400 0x0400
patnloop2 0
patwait0 0x002e
patwaittime0 800
patwait1 0x0400
patwaittime1 0
patwait2 0x0400
patwaittime2 0
patloop 0 0x00be 0x00ef
patnloop 0 199
patloop 1 0x0400 0x0400
patnloop 1 0
patloop 2 0x0400 0x0400
patnloop 2 0
patwait 0 0x002e
patwaittime 0 800
patwait 1 0x0400
patwaittime 1 0
patwait 2 0x0400
patwaittime 2 0
patloop 3 0x0000 0x0000
patnloop 3 0
patloop 4 0x0000 0x0000
patnloop 4 0
patloop 5 0x0000 0x0000
patnloop 5 0
patwait 3 0x0000
patwaittime 3 0
patwait 4 0x0000
patwaittime 4 0
patwait 5 0x0000
patwaittime 5 0

View File

@ -572,5 +572,72 @@
#define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT)
#define PATTERN_SET_MSB_REG (0x83 << MEM_MAP_SHIFT)
/* Pattern Loop 3 Address RW regiser */
#define PATTERN_LOOP_3_ADDR_REG (0x84 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_3_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_3_ADDR_STRT_MSK \
(0x00001FFF << PATTERN_LOOP_3_ADDR_STRT_OFST)
#define PATTERN_LOOP_3_ADDR_STP_OFST (16)
#define PATTERN_LOOP_3_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_3_ADDR_STP_OFST)
/* Pattern Loop 3 Iteration RW regiser */
#define PATTERN_LOOP_3_ITERATION_REG (0x85 << MEM_MAP_SHIFT)
/* Pattern Loop 4 Address RW regiser */
#define PATTERN_LOOP_4_ADDR_REG (0x86 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_4_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_4_ADDR_STRT_MSK \
(0x00001FFF << PATTERN_LOOP_4_ADDR_STRT_OFST)
#define PATTERN_LOOP_4_ADDR_STP_OFST (16)
#define PATTERN_LOOP_4_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_4_ADDR_STP_OFST)
/* Pattern Loop 4 Iteration RW regiser */
#define PATTERN_LOOP_4_ITERATION_REG (0x87 << MEM_MAP_SHIFT)
/* Pattern Loop 5 Address RW regiser */
#define PATTERN_LOOP_5_ADDR_REG (0x88 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_5_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_5_ADDR_STRT_MSK \
(0x00001FFF << PATTERN_LOOP_5_ADDR_STRT_OFST)
#define PATTERN_LOOP_5_ADDR_STP_OFST (16)
#define PATTERN_LOOP_5_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_5_ADDR_STP_OFST)
/* Pattern Loop 5 Iteration RW regiser */
#define PATTERN_LOOP_5_ITERATION_REG (0x89 << MEM_MAP_SHIFT)
/* Pattern Wait 3 RW regiser */
#define PATTERN_WAIT_3_ADDR_REG (0x8A << MEM_MAP_SHIFT)
#define PATTERN_WAIT_3_ADDR_OFST (0)
#define PATTERN_WAIT_3_ADDR_MSK (0x00001FFF << PATTERN_WAIT_3_ADDR_OFST)
/* Pattern Wait 4 RW regiser */
#define PATTERN_WAIT_4_ADDR_REG (0x8B << MEM_MAP_SHIFT)
#define PATTERN_WAIT_4_ADDR_OFST (0)
#define PATTERN_WAIT_4_ADDR_MSK (0x00001FFF << PATTERN_WAIT_4_ADDR_OFST)
/* Pattern Wait 5 RW regiser */
#define PATTERN_WAIT_5_ADDR_REG (0x8C << MEM_MAP_SHIFT)
#define PATTERN_WAIT_5_ADDR_OFST (0)
#define PATTERN_WAIT_5_ADDR_MSK (0x00001FFF << PATTERN_WAIT_5_ADDR_OFST)
/* Pattern Wait Timer 3 64 bit RW register. t = PWT1 x T run clock */
#define PATTERN_WAIT_TIMER_3_LSB_REG (0x8D << MEM_MAP_SHIFT)
#define PATTERN_WAIT_TIMER_3_MSB_REG (0x8E << MEM_MAP_SHIFT)
/* Pattern Wait Timer 4 64 bit RW register. t = PWT1 x T run clock */
#define PATTERN_WAIT_TIMER_4_LSB_REG (0x8F << MEM_MAP_SHIFT)
#define PATTERN_WAIT_TIMER_4_MSB_REG (0x90 << MEM_MAP_SHIFT)
/* Pattern Wait Timer 5 64 bit RW register. t = PWT1 x T run clock */
#define PATTERN_WAIT_TIMER_5_LSB_REG (0x91 << MEM_MAP_SHIFT)
#define PATTERN_WAIT_TIMER_5_MSB_REG (0x92 << MEM_MAP_SHIFT)
/* Round Robin */
#define RXR_ENDPOINT_START_REG (0x1000 << MEM_MAP_SHIFT)

View File

@ -274,15 +274,28 @@ patword 0x0110 0x0008599f0008503a
patword 0x0111 0x0008599f0008503a
patioctrl 0x8f0effff6dbffdbf
patlimits 0x0000 0x0110
patloop0 0x00be 0x00ef
patnloop0 199
patloop1 0x0400 0x0400
patnloop1 0
patloop2 0x0400 0x0400
patnloop2 0
patwait0 0x002e
patwaittime0 800
patwait1 0x0400
patwaittime1 0
patwait2 0x0400
patwaittime2 0
patloop 0 0x00be 0x00ef
patnloop 0 199
patloop 1 0x0400 0x0400
patnloop 1 0
patloop 2 0x0400 0x0400
patnloop 2 0
patwait 0 0x002e
patwaittime 0 800
patwait 1 0x0400
patwaittime 1 0
patwait 2 0x0400
patwaittime 2 0
patloop 3 0x0000 0x0000
patnloop 3 0
patloop 4 0x0000 0x0000
patnloop 4 0
patloop 5 0x0000 0x0000
patnloop 5 0
patwait 3 0x0000
patwaittime 3 0
patwait 4 0x0000
patwaittime 4 0
patwait 5 0x0000
patwaittime 5 0

View File

@ -5,7 +5,7 @@
#include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x180314
#define REQRD_FRMWR_VRSN 0x201005
#define REQRD_FRMWR_VRSN 0x220714
#define LINKED_SERVER_NAME "moenchDetectorServer"

View File

@ -242,15 +242,15 @@ patword 0x00f0 0x0000000000000000
patword 0x00f1 0x0000000000000000
patword 0x00f2 0x0000000000000000
patlimits 0x0000 0x00f2
patloop0 0x0400 0x0400
patnloop0 0
patloop1 0x0400 0x0400
patnloop1 0
patloop2 0x0400 0x0400
patnloop2 0
patwait0 0x0400
patwaittime0 0
patwait1 0x0400
patwaittime1 0
patwait2 0x0400
patwaittime2 0
patloop 0 0x0400 0x0400
patnloop 0 0
patloop 1 0x0400 0x0400
patnloop 1 0
patloop 2 0x0400 0x0400
patnloop 2 0
patwait 0 0x0400
patwaittime 0 0
patwait 1 0x0400
patwaittime 1 0
patwait 2 0x0400
patwaittime 2 0

View File

@ -242,15 +242,15 @@ patword 0x00f0 0x0000000000000000
patword 0x00f1 0x0000000000000000
patword 0x00f2 0x0000000000000000
patlimits 0x0000 0x00f2
patloop0 0x0400 0x0400
patnloop0 0
patloop1 0x0400 0x0400
patnloop1 0
patloop2 0x0400 0x0400
patnloop2 0
patwait0 0x0400
patwaittime0 0
patwait1 0x0400
patwaittime1 0
patwait2 0x0400
patwaittime2 0
patloop 0 0x0400 0x0400
patnloop 0 0
patloop 1 0x0400 0x0400
patnloop 1 0
patloop 2 0x0400 0x0400
patnloop 2 0
patwait 0 0x0400
patwaittime 0 0
patwait 1 0x0400
patwaittime 1 0
patwait 2 0x0400
patwaittime 2 0

View File

@ -73,13 +73,13 @@ patternParameters *setChipStatusRegisterPattern(int csr) {
error = 1;
}
// set pattern wait address
for (int i = 0; i <= 2; i++)
for (int i = 0; i < M3_MAX_PATTERN_LEVELS; i++)
pat->wait[i] = MAX_PATTERN_LENGTH - 1;
// pattern loop
for (int i = 0; i <= 2; i++) {
for (int i = 0; i < M3_MAX_PATTERN_LEVELS; i++) {
// int stop = MAX_PATTERN_LENGTH - 1, nloop = 0;
pat->loop[i * 2 + 0] = MAX_PATTERN_LENGTH - 1;
pat->loop[i * 2 + 1] = MAX_PATTERN_LENGTH - 1;
pat->startloop[i] = MAX_PATTERN_LENGTH - 1;
pat->stoploop[i] = MAX_PATTERN_LENGTH - 1;
pat->nloop[i] = 0;
}
@ -349,13 +349,13 @@ patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits) {
error = 1;
}
// set pattern wait address
for (int i = 0; i <= 2; i++)
for (int i = 0; i < M3_MAX_PATTERN_LEVELS; i++)
pat->wait[i] = MAX_PATTERN_LENGTH - 1;
// pattern loop
for (int i = 0; i <= 2; i++) {
for (int i = 0; i < M3_MAX_PATTERN_LEVELS; i++) {
// int stop = MAX_PATTERN_LENGTH - 1, nloop = 0;
pat->loop[i * 2 + 0] = MAX_PATTERN_LENGTH - 1;
pat->loop[i * 2 + 1] = MAX_PATTERN_LENGTH - 1;
pat->startloop[i] = MAX_PATTERN_LENGTH - 1;
pat->stoploop[i] = MAX_PATTERN_LENGTH - 1;
pat->nloop[i] = 0;
}

View File

@ -2456,21 +2456,51 @@ void *start_timer(void *arg) {
// Generate data
char imageData[imageSize];
memset(imageData, 0, imageSize);
// {
// const int nchannels = NCHAN_1_COUNTER * NCHIP * ncounters;
// for (int i = 0; i < nchannels; ++i) {
// int j = rand();
// switch (dr) {
// //case 1: // TODO: Not implemented in firmware yet
// // break;
// case 8:
// *((uint8_t *)(imageData + i)) = (uint8_t)j;
// break;
// case 16:
// *((uint16_t *)(imageData + i * sizeof(uint16_t))) = (uint16_t)j;
// break;
// case 32:
// *((uint32_t *)(imageData + i * sizeof(uint32_t))) = ((uint32_t)j & 0xFFFFFF); // 24 bit
// break;
// default:
// break;
// }
// }
// }
// Send data
// loop over number of frames
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
{
const int nchannels = NCHAN_1_COUNTER * NCHIP * ncounters;
for (int i = 0; i < nchannels; ++i) {
int j = rand();
switch (dr) {
//case 1: // TODO: Not implemented in firmware yet
// break;
case 8:
*((uint8_t *)(imageData + i)) = (uint8_t)i;
*((uint8_t *)(imageData + i)) = (uint8_t)j;
break;
case 16:
*((uint16_t *)(imageData + i * sizeof(uint16_t))) = (uint16_t)i;
*((uint16_t *)(imageData + i * sizeof(uint16_t))) = (uint16_t)j;
break;
case 32:
*((uint32_t *)(imageData + i * sizeof(uint32_t))) = ((uint32_t)i & 0xFFFFFF); // 24 bit
*((uint32_t *)(imageData + i * sizeof(uint32_t))) = ((uint32_t)j & 0xFFFFFF); // 24 bit
break;
default:
break;
@ -2478,9 +2508,6 @@ void *start_timer(void *arg) {
}
}
// Send data
// loop over number of frames
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
// check if manual stop
if (sharedMemory_getStop() == 1) {

View File

@ -24,6 +24,12 @@ extern u_int32_t bus_r(u_int32_t offset);
extern int64_t get64BitReg(int aLSB, int aMSB);
extern int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
#ifdef MYTHEN3D
#define MAX_LEVELS M3_MAX_PATTERN_LEVELS
#else
#define MAX_LEVELS MAX_PATTERN_LEVELS
#endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
#ifdef VIRTUAL
void initializePatternWord() {
@ -157,9 +163,9 @@ void writePatternWord(int addr, uint64_t word) {
int validate_getPatternWaitAddresses(char *message, int level, int *addr) {
// validate input
if (level < 0 || level > 2) {
if (level < 0 || level >= MAX_LEVELS) {
sprintf(message,
"Cannot get patwait address. Level must be between 0 and 2.\n");
"Cannot get patwait address. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
LOG(logERROR, (message));
return FAIL;
}
@ -178,6 +184,17 @@ int getPatternWaitAddress(int level) {
case 2:
return ((bus_r(PATTERN_WAIT_2_ADDR_REG) & PATTERN_WAIT_2_ADDR_MSK) >>
PATTERN_WAIT_2_ADDR_OFST);
#ifndef MYTHEN3D
case 3:
return ((bus_r(PATTERN_WAIT_3_ADDR_REG) & PATTERN_WAIT_3_ADDR_MSK) >>
PATTERN_WAIT_3_ADDR_OFST);
case 4:
return ((bus_r(PATTERN_WAIT_4_ADDR_REG) & PATTERN_WAIT_4_ADDR_MSK) >>
PATTERN_WAIT_4_ADDR_OFST);
case 5:
return ((bus_r(PATTERN_WAIT_5_ADDR_REG) & PATTERN_WAIT_5_ADDR_MSK) >>
PATTERN_WAIT_5_ADDR_OFST);
#endif
default:
return -1;
}
@ -185,9 +202,9 @@ int getPatternWaitAddress(int level) {
int validate_setPatternWaitAddresses(char *message, int level, int addr) {
// validate input
if (level < 0 || level > 2) {
if (level < 0 || level >= MAX_LEVELS) {
sprintf(message,
"Cannot set patwait address. Level must be between 0 and 2.\n");
"Cannot set patwait address. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
LOG(logERROR, (message));
return FAIL;
}
@ -234,6 +251,20 @@ void setPatternWaitAddress(int level, int addr) {
bus_w(PATTERN_WAIT_2_ADDR_REG,
((addr << PATTERN_WAIT_2_ADDR_OFST) & PATTERN_WAIT_2_ADDR_MSK));
break;
#ifndef MYTHEN3D
case 3:
bus_w(PATTERN_WAIT_3_ADDR_REG,
((addr << PATTERN_WAIT_3_ADDR_OFST) & PATTERN_WAIT_3_ADDR_MSK));
break;
case 4:
bus_w(PATTERN_WAIT_4_ADDR_REG,
((addr << PATTERN_WAIT_4_ADDR_OFST) & PATTERN_WAIT_4_ADDR_MSK));
break;
case 5:
bus_w(PATTERN_WAIT_5_ADDR_REG,
((addr << PATTERN_WAIT_5_ADDR_OFST) & PATTERN_WAIT_5_ADDR_MSK));
break;
#endif
default:
return;
}
@ -241,9 +272,9 @@ void setPatternWaitAddress(int level, int addr) {
int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime) {
// validate input
if (level < 0 || level > 2) {
if (level < 0 || level >= MAX_LEVELS) {
sprintf(message,
"Cannot get patwaittime. Level must be between 0 and 2.\n");
"Cannot get patwaittime. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
LOG(logERROR, (message));
return FAIL;
}
@ -262,6 +293,17 @@ uint64_t getPatternWaitTime(int level) {
case 2:
return get64BitReg(PATTERN_WAIT_TIMER_2_LSB_REG,
PATTERN_WAIT_TIMER_2_MSB_REG);
#ifndef MYTHEN3D
case 3:
return get64BitReg(PATTERN_WAIT_TIMER_3_LSB_REG,
PATTERN_WAIT_TIMER_3_MSB_REG);
case 4:
return get64BitReg(PATTERN_WAIT_TIMER_4_LSB_REG,
PATTERN_WAIT_TIMER_4_MSB_REG);
case 5:
return get64BitReg(PATTERN_WAIT_TIMER_5_LSB_REG,
PATTERN_WAIT_TIMER_5_MSB_REG);
#endif
default:
return -1;
}
@ -269,9 +311,9 @@ uint64_t getPatternWaitTime(int level) {
int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) {
// validate input
if (level < 0 || level > 2) {
if (level < 0 || level >= MAX_LEVELS) {
sprintf(message,
"Cannot set patwaittime. Level must be between 0 and 2.\n");
"Cannot set patwaittime. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
LOG(logERROR, (message));
return FAIL;
}
@ -311,6 +353,20 @@ void setPatternWaitTime(int level, uint64_t t) {
set64BitReg(t, PATTERN_WAIT_TIMER_2_LSB_REG,
PATTERN_WAIT_TIMER_2_MSB_REG);
break;
#ifndef MYTHEN3D
case 3:
set64BitReg(t, PATTERN_WAIT_TIMER_3_LSB_REG,
PATTERN_WAIT_TIMER_3_MSB_REG);
break;
case 4:
set64BitReg(t, PATTERN_WAIT_TIMER_4_LSB_REG,
PATTERN_WAIT_TIMER_4_MSB_REG);
break;
case 5:
set64BitReg(t, PATTERN_WAIT_TIMER_5_LSB_REG,
PATTERN_WAIT_TIMER_5_MSB_REG);
break;
#endif
default:
return;
}
@ -318,9 +374,9 @@ void setPatternWaitTime(int level, uint64_t t) {
int validate_getPatternLoopCycles(char *message, int level, int *numLoops) {
// validate input
if (level < 0 || level > 2) {
if (level < 0 || level >= MAX_LEVELS) {
sprintf(message,
"Cannot get patnloop. Level must be between 0 and 2.\n");
"Cannot get patnloop. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
LOG(logERROR, (message));
return FAIL;
}
@ -336,6 +392,14 @@ int getPatternLoopCycles(int level) {
return bus_r(PATTERN_LOOP_1_ITERATION_REG);
case 2:
return bus_r(PATTERN_LOOP_2_ITERATION_REG);
#ifndef MYTHEN3D
case 3:
return bus_r(PATTERN_LOOP_3_ITERATION_REG);
case 4:
return bus_r(PATTERN_LOOP_4_ITERATION_REG);
case 5:
return bus_r(PATTERN_LOOP_5_ITERATION_REG);
#endif
default:
return -1;
}
@ -343,9 +407,9 @@ int getPatternLoopCycles(int level) {
int validate_setPatternLoopCycles(char *message, int level, int numLoops) {
// validate input
if (level < 0 || level > 2) {
if (level < 0 || level >= MAX_LEVELS) {
sprintf(message,
"Cannot set patnloop. Level must be between 0 and 2.\n");
"Cannot set patnloop. Level %d must be between 0 and %d.\n", level, MAX_LEVELS);
LOG(logERROR, (message));
return FAIL;
}
@ -385,6 +449,17 @@ void setPatternLoopCycles(int level, int nLoop) {
case 2:
bus_w(PATTERN_LOOP_2_ITERATION_REG, nLoop);
break;
#ifndef MYTHEN3D
case 3:
bus_w(PATTERN_LOOP_3_ITERATION_REG, nLoop);
break;
case 4:
bus_w(PATTERN_LOOP_4_ITERATION_REG, nLoop);
break;
case 5:
bus_w(PATTERN_LOOP_5_ITERATION_REG, nLoop);
break;
#endif
default:
return;
}
@ -443,10 +518,10 @@ void setPatternLoopLimits(int startAddr, int stopAddr) {
int validate_getPatternLoopAddresses(char *message, int level, int *startAddr,
int *stopAddr) {
// validate input
if (level < 0 || level > 2) {
if (level < 0 || level >= MAX_LEVELS) {
sprintf(
message,
"Cannot get patloop addresses. Level must be between 0 and 2.\n");
"Cannot get patloop addresses. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
LOG(logERROR, (message));
return FAIL;
}
@ -481,6 +556,32 @@ void getPatternLoopAddresses(int level, int *startAddr, int *stopAddr) {
((bus_r(PATTERN_LOOP_2_ADDR_REG) & PATTERN_LOOP_2_ADDR_STP_MSK) >>
PATTERN_LOOP_2_ADDR_STP_OFST);
break;
#ifndef MYTHEN3D
case 3:
*startAddr =
((bus_r(PATTERN_LOOP_3_ADDR_REG) & PATTERN_LOOP_3_ADDR_STRT_MSK) >>
PATTERN_LOOP_3_ADDR_STRT_OFST);
*stopAddr =
((bus_r(PATTERN_LOOP_3_ADDR_REG) & PATTERN_LOOP_3_ADDR_STP_MSK) >>
PATTERN_LOOP_3_ADDR_STP_OFST);
break;
case 4:
*startAddr =
((bus_r(PATTERN_LOOP_4_ADDR_REG) & PATTERN_LOOP_4_ADDR_STRT_MSK) >>
PATTERN_LOOP_4_ADDR_STRT_OFST);
*stopAddr =
((bus_r(PATTERN_LOOP_4_ADDR_REG) & PATTERN_LOOP_4_ADDR_STP_MSK) >>
PATTERN_LOOP_4_ADDR_STP_OFST);
break;
case 5:
*startAddr =
((bus_r(PATTERN_LOOP_5_ADDR_REG) & PATTERN_LOOP_5_ADDR_STRT_MSK) >>
PATTERN_LOOP_5_ADDR_STRT_OFST);
*stopAddr =
((bus_r(PATTERN_LOOP_5_ADDR_REG) & PATTERN_LOOP_5_ADDR_STP_MSK) >>
PATTERN_LOOP_5_ADDR_STP_OFST);
break;
#endif
default:
return;
}
@ -489,10 +590,10 @@ void getPatternLoopAddresses(int level, int *startAddr, int *stopAddr) {
int validate_setPatternLoopAddresses(char *message, int level, int startAddr,
int stopAddr) {
// validate input
if (level < 0 || level > 2) {
if (level < 0 || level >= MAX_LEVELS) {
sprintf(
message,
"Cannot set patloop addresses. Level must be between 0 and 2.\n");
"Cannot set patloop addresses. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
LOG(logERROR, (message));
return FAIL;
}
@ -559,6 +660,29 @@ void setPatternLoopAddresses(int level, int startAddr, int stopAddr) {
((stopAddr << PATTERN_LOOP_2_ADDR_STP_OFST) &
PATTERN_LOOP_2_ADDR_STP_MSK));
break;
#ifndef MYTHEN3D
case 3:
bus_w(PATTERN_LOOP_3_ADDR_REG,
((startAddr << PATTERN_LOOP_3_ADDR_STRT_OFST) &
PATTERN_LOOP_3_ADDR_STRT_MSK) |
((stopAddr << PATTERN_LOOP_3_ADDR_STP_OFST) &
PATTERN_LOOP_3_ADDR_STP_MSK));
break;
case 4:
bus_w(PATTERN_LOOP_4_ADDR_REG,
((startAddr << PATTERN_LOOP_4_ADDR_STRT_OFST) &
PATTERN_LOOP_4_ADDR_STRT_MSK) |
((stopAddr << PATTERN_LOOP_4_ADDR_STP_OFST) &
PATTERN_LOOP_4_ADDR_STP_MSK));
break;
case 5:
bus_w(PATTERN_LOOP_5_ADDR_REG,
((startAddr << PATTERN_LOOP_5_ADDR_STRT_OFST) &
PATTERN_LOOP_5_ADDR_STRT_MSK) |
((stopAddr << PATTERN_LOOP_5_ADDR_STP_OFST) &
PATTERN_LOOP_5_ADDR_STP_MSK));
break;
#endif
default:
return;
}
@ -625,10 +749,10 @@ int loadPattern(char *message, enum TLogLevel printLevel,
}
if (ret == OK) {
for (int i = 0; i <= 2; ++i) {
for (int i = 0; i < MAX_LEVELS; ++i) {
// loop addr
ret = validate_setPatternLoopAddresses(
message, i, pat->loop[i * 2 + 0], pat->loop[i * 2 + 1]);
message, i, pat->startloop[i], pat->stoploop[i]);
if (ret == FAIL) {
break;
}
@ -685,15 +809,15 @@ int getPattern(char *message, patternParameters *pat) {
pat->limits[1] = retval2;
}
if (ret == OK) {
for (int i = 0; i <= 2; ++i) {
for (int i = 0; i < MAX_LEVELS; ++i) {
// loop addr
ret = validate_getPatternLoopAddresses(message, i, &retval1,
&retval2);
if (ret == FAIL) {
break;
}
pat->loop[i * 2 + 0] = retval1;
pat->loop[i * 2 + 1] = retval2;
pat->startloop[i] = retval1;
pat->stoploop[i] = retval2;
// num loops
ret = validate_getPatternLoopCycles(message, i, &retval1);
@ -846,26 +970,14 @@ int loadPatternFile(char *patFname, char *errMessage) {
}
// patloop
if ((!strncmp(line, "patloop0", strlen("patloop0"))) ||
(!strncmp(line, "patloop1", strlen("patloop1"))) ||
(!strncmp(line, "patloop2", strlen("patloop2")))) {
// level
if (!strncmp(line, "patloop", strlen("patloop"))){
int level = -1;
if (!strncmp(line, "patloop0", strlen("patloop0"))) {
level = 0;
} else if (!strncmp(line, "patloop1", strlen("patloop1"))) {
level = 1;
} else {
level = 2;
}
int startAddr = 0;
int stopAddr = 0;
// cannot scan values
if (sscanf(line, "%s 0x%x 0x%x", command, &startAddr, &stopAddr) !=
3) {
sprintf(temp, "Could not scan patloop%d arguments.\n", level);
if (sscanf(line, "%s %d 0x%x 0x%x", command, &level, &startAddr, &stopAddr) !=
4) {
strcpy(temp, "Could not scan patloop arguments.\n");
break;
}
@ -876,24 +988,12 @@ int loadPatternFile(char *patFname, char *errMessage) {
}
// patnloop
if ((!strncmp(line, "patnloop0", strlen("patnloop0"))) ||
(!strncmp(line, "patnloop1", strlen("patnloop1"))) ||
(!strncmp(line, "patnloop2", strlen("patnloop2")))) {
// level
if (!strncmp(line, "patnloop", strlen("patnloop"))) {
int level = -1;
if (!strncmp(line, "patnloop0", strlen("patnloop0"))) {
level = 0;
} else if (!strncmp(line, "patnloop1", strlen("patnloop1"))) {
level = 1;
} else {
level = 2;
}
int numLoops = -1;
// cannot scan values
if (sscanf(line, "%s %d", command, &numLoops) != 2) {
sprintf(temp, "Could not scan patnloop %d arguments.\n", level);
if (sscanf(line, "%s %d %d", command, &level, &numLoops) != 3) {
strcpy(temp, "Could not scan patnloop arguments.\n");
break;
}
@ -903,24 +1003,12 @@ int loadPatternFile(char *patFname, char *errMessage) {
}
// patwait
if ((!strncmp(line, "patwait0", strlen("patwait0"))) ||
(!strncmp(line, "patwait1", strlen("patwait1"))) ||
(!strncmp(line, "patwait2", strlen("patwait2")))) {
// level
if (!strncmp(line, "patwait ", strlen("patwait "))) {
int level = -1;
if (!strncmp(line, "patwait0", strlen("patwait0"))) {
level = 0;
} else if (!strncmp(line, "patwait1", strlen("patwait1"))) {
level = 1;
} else {
level = 2;
}
int addr = 0;
// cannot scan values
if (sscanf(line, "%s 0x%x", command, &addr) != 2) {
sprintf(temp, "Could not scan patwait%d arguments.\n", level);
if (sscanf(line, "%s %d 0x%x", command, &level, &addr) != 3) {
strcpy(temp, "Could not scan patwait arguments.\n");
break;
}
@ -930,27 +1018,15 @@ int loadPatternFile(char *patFname, char *errMessage) {
}
// patwaittime
if ((!strncmp(line, "patwaittime0", strlen("patwaittime0"))) ||
(!strncmp(line, "patwaittime1", strlen("patwaittime1"))) ||
(!strncmp(line, "patwaittime2", strlen("patwaittime2")))) {
// level
if (!strncmp(line, "patwaittime", strlen("patwaittime"))) {
int level = -1;
if (!strncmp(line, "patwaittime0", strlen("patwaittime0"))) {
level = 0;
} else if (!strncmp(line, "patwaittime1", strlen("patwaittime1"))) {
level = 1;
} else {
level = 2;
}
uint64_t waittime = 0;
// cannot scan values
#ifdef VIRTUAL
if (sscanf(line, "%s %ld", command, &waittime) != 2) {
if (sscanf(line, "%s %d %ld", command, &level, &waittime) != 3) {
#else
if (sscanf(line, "%s %lld", command, &waittime) != 2) {
if (sscanf(line, "%s %d %lld", command, &level, &waittime) != 3) {
#endif
sprintf(temp, "Could not scan patwaittime%d arguments.\n",
level);

View File

@ -9249,8 +9249,25 @@ int clear_all_udp_dst(int file_des) {
if (check_detector_idle("clear all udp destinations") == OK) {
memset(udpDetails, 0, sizeof(udpDetails));
// minimum 1 destination in fpga
numUdpDestinations = 1;
configure_mac();
int numdest = 1;
// set number of destinations
#if defined(JUNGFRAUD) || defined(EIGERD)
if (setNumberofDestinations(numdest) == FAIL) {
ret = FAIL;
strcpy(mess, "Could not clear udp destinations to 1 entry.\n");
LOG(logERROR, (mess));
} else
#endif
{
numUdpDestinations = numdest;
LOG(logINFOBLUE, ("Number of UDP Destinations: %d\n",
numUdpDestinations));
ret = configureMAC();
if (ret == FAIL) {
strcpy(mess, "Could not clear all destinations in the fpga.\n");
LOG(logERROR, (mess));
}
}
}
}
return Server_SendResult(file_des, INT32, NULL, 0);

View File

@ -13,11 +13,11 @@ typedef struct __attribute__((packed)) {
uint64_t word[MAX_PATTERN_LENGTH];
uint64_t ioctrl;
uint32_t limits[2];
// loop0 start, loop0 stop .. loop2 start, loop2 stop
uint32_t loop[6];
uint32_t nloop[3];
uint32_t wait[3];
uint64_t waittime[3];
uint32_t startloop[MAX_PATTERN_LEVELS];
uint32_t stoploop[MAX_PATTERN_LEVELS];
uint32_t nloop[MAX_PATTERN_LEVELS];
uint32_t wait[MAX_PATTERN_LEVELS];
uint64_t waittime[MAX_PATTERN_LEVELS];
} patternParameters;
#ifdef __cplusplus

View File

@ -65,6 +65,11 @@ int main(int argc, char *argv[]) {
return 0;
}
// prevent mem size check
if (parser.command() == "config" && action == slsDetectorDefs::PUT_ACTION) {
sls::freeSharedMemory(parser.multi_id());
}
try {
sls::Detector det(parser.multi_id());
sls::CmdProxy proxy(&det);

View File

@ -1539,6 +1539,72 @@ std::string CmdProxy::UDPDestinationList(int action) {
return os.str();
}
std::string CmdProxy::UDPSourceIP(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[x.x.x.x] or auto\n\tIp address of the detector (source) udp interface. Must be same subnet as destination udp ip.\n\t[Eiger] Set only for 10G. For 1G, detector will replace with its own DHCP IP address. If 'auto' used, then ip is set to ip of rx_hostname."
<< '\n';
} else if (action == defs::GET_ACTION) {
auto t = det->getSourceUDPIP(std::vector<int>{det_id});
if (!args.empty()) {
WrongNumberOfParameters(0);
}
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
IpAddr val;
if (args[0] == "auto") {
val = getIpFromAuto();
LOG(logINFO) << "Setting udp_srcip of detector " << det_id << " to "
<< val;
} else {
val = IpAddr(args[0]);
}
det->setSourceUDPIP(val, std::vector<int>{det_id});
os << val << '\n';
} else {
throw RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::UDPSourceIP2(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[x.x.x.x] or auto\n\t[Jungfrau][Gotthard2] Ip address of the detector (source) udp interface 2. Must be same subnet as destination udp ip2.\n\t [Jungfrau] top half or inner interface\n\t [Gotthard2] veto debugging. If 'auto' used, then ip is set to ip of rx_hostname."
<< '\n';
} else if (action == defs::GET_ACTION) {
auto t = det->getSourceUDPIP2(std::vector<int>{det_id});
if (!args.empty()) {
WrongNumberOfParameters(0);
}
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
IpAddr val;
if (args[0] == "auto") {
val = getIpFromAuto();
LOG(logINFO) << "Setting udp_srcip2 of detector " << det_id << " to "
<< val;
} else {
val = IpAddr(args[0]);
}
det->setSourceUDPIP2(val, std::vector<int>{det_id});
os << val << '\n';
} else {
throw RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::UDPDestinationIP(int action) {
std::ostringstream os;
os << cmd << ' ';
@ -2639,7 +2705,30 @@ std::string CmdProxy::PatternWord(int action) {
return os.str();
}
void CmdProxy::GetLevelAndUpdateArgIndex(int action, std::string levelSeparatedCommand, int& level, int& iArg, size_t nGetArgs, size_t nPutArgs) {
if (cmd == levelSeparatedCommand) {
++nGetArgs;
++nPutArgs;
} else {
LOG(logWARNING) << "This command is deprecated and will be removed. Please migrate to " << levelSeparatedCommand;
}
if (action == defs::GET_ACTION && args.size() != nGetArgs) {
WrongNumberOfParameters(nGetArgs);
} else if (action == defs::PUT_ACTION && args.size() != nPutArgs) {
WrongNumberOfParameters(nPutArgs);
}
if (cmd == levelSeparatedCommand) {
level = StringTo<int>(args[iArg++]);
} else {
level = cmd[cmd.find_first_of("012")] - '0';
}
}
std::string CmdProxy::PatternLoopAddresses(int action) {
if (cmd != "patlimits" && cmd != "patloop0" && cmd != "patloop1" && cmd != "patloop2" && cmd != "patloop") {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
@ -2647,53 +2736,30 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
"of complete pattern."
<< '\n';
} else if (cmd == "patloop0") {
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
"of loop 0."
<< '\n';
} else if (cmd == "patloop1") {
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
"of loop 1."
<< '\n';
} else if (cmd == "patloop2") {
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
"of loop 2."
} else if (cmd == "patloop") {
os << "[0-6] [start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of the loop level provided."
<< "\n\t[Mythen3] Level options: 0-3 only."
<< '\n';
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
os << "Depreciated command. Use patloop."
<< '\n';
}
} else {
int level = -1;
if (cmd == "patlimits") {
level = -1;
} else if (cmd == "patloop0") {
level = 0;
} else if (cmd == "patloop1") {
level = 1;
} else if (cmd == "patloop2") {
level = 2;
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
if (cmd != "patlimits") {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, nPutArgs);
}
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t =
det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
int start = StringTo<int>(args[0]);
int stop = StringTo<int>(args[1]);
int start = StringTo<int>(args[iArg++]);
int stop = StringTo<int>(args[iArg++]);
det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id});
std::vector<int>{det_id});
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
<< "]\n";
<< "]\n";
} else {
throw RuntimeError("Unknown action");
}
@ -2702,50 +2768,32 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
}
std::string CmdProxy::PatternLoopCycles(int action) {
if (cmd != "patnloop0" && cmd != "patnloop1" && cmd != "patnloop2" && cmd != "patnloop") {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patnloop0") {
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
"loop 0."
<< '\n';
} else if (cmd == "patnloop1") {
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
"loop 1."
<< '\n';
} else if (cmd == "patnloop2") {
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
"loop 2."
if (cmd == "patnloop") {
os << "[0-6] [n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
"the loop level provided."
<< "\n\t[Mythen3] Level options: 0-3 only."
<< '\n';
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
os << "Depreciated command. Use patnloop."
<< '\n';
}
} else {
int level = -1;
if (cmd == "patnloop0") {
level = 0;
} else if (cmd == "patnloop1") {
level = 1;
} else if (cmd == "patnloop2") {
level = 2;
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, nPutArgs);
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setPatternLoopCycles(level, StringTo<int>(args[0]),
std::vector<int>{det_id});
os << args.front() << '\n';
int nloops = StringTo<int>(args[iArg++]);
det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
os << nloops << '\n';
} else {
throw RuntimeError("Unknown action");
}
@ -2754,42 +2802,28 @@ std::string CmdProxy::PatternLoopCycles(int action) {
}
std::string CmdProxy::PatternWaitAddress(int action) {
if (cmd != "patwait0" && cmd != "patwait1" && cmd != "patwait2" && cmd != "patwait") {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patwait0") {
os << "[addr] \n\t[Ctb][Moench][Mythen3] Wait 0 address." << '\n';
} else if (cmd == "patwait1") {
os << "[addr] \n\t[Ctb][Moench][Mythen3] Wait 1 address." << '\n';
} else if (cmd == "patwait2") {
os << "[addr] \n\t[Ctb][Moench][Mythen3] Wait 2 address." << '\n';
if (cmd == "patwait") {
os << "[0-6] [addr] \n\t[Ctb][Moench][Mythen3] Wait address for loop level provided."
<< "\n\t[Mythen3] Level options: 0-3 only.";
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
os << "Depreciated command. Use patwait.";
}
os << '\n';
} else {
int level = -1;
if (cmd == "patwait0") {
level = 0;
} else if (cmd == "patwait1") {
level = 1;
} else if (cmd == "patwait2") {
level = 2;
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, nPutArgs);
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
int addr = StringTo<int>(args[0]);
int addr = StringTo<int>(args[iArg++]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << ToStringHex(addr, 4) << '\n';
} else {
@ -2800,50 +2834,32 @@ std::string CmdProxy::PatternWaitAddress(int action) {
}
std::string CmdProxy::PatternWaitTime(int action) {
if (cmd != "patwaittime0" && cmd != "patwaittime1" && cmd != "patwaittime2" && cmd != "patwaittime") {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patwaittime0") {
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 0 time in clock "
"cycles."
<< '\n';
} else if (cmd == "patwaittime1") {
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 1 time in clock "
"cycles."
<< '\n';
} else if (cmd == "patwaittime2") {
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 2 time in clock "
"cycles."
if (cmd == "patwaittime") {
os << "[0-6] [n_clk] \n\t[Ctb][Moench][Mythen3] Wait time in clock "
"cycles for the loop provided."
<< "\n\t[Mythen3] Level options: 0-3 only."
<< '\n';
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
os << "Depreciated command. Use patwaittime."
<< '\n';
}
} else {
int level = -1;
if (cmd == "patwaittime0") {
level = 0;
} else if (cmd == "patwaittime1") {
level = 1;
} else if (cmd == "patwaittime2") {
level = 2;
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs, nPutArgs);
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setPatternWaitTime(level, StringTo<uint64_t>(args[0]),
{det_id});
os << args.front() << '\n';
uint64_t waittime = StringTo<uint64_t>(args[iArg++]);
det->setPatternWaitTime(level, waittime, {det_id});
os << waittime << '\n';
} else {
throw RuntimeError("Unknown action");
}

View File

@ -877,8 +877,8 @@ class CmdProxy {
{"udp_numdst", &CmdProxy::udp_numdst},
{"udp_cleardst", &CmdProxy::udp_cleardst},
{"udp_firstdst", &CmdProxy::udp_firstdst},
{"udp_srcip", &CmdProxy::udp_srcip},
{"udp_srcip2", &CmdProxy::udp_srcip2},
{"udp_srcip", &CmdProxy::UDPSourceIP},
{"udp_srcip2", &CmdProxy::UDPSourceIP2},
{"udp_dstip", &CmdProxy::UDPDestinationIP},
{"udp_dstip2", &CmdProxy::UDPDestinationIP2},
{"udp_srcmac", &CmdProxy::udp_srcmac},
@ -1049,15 +1049,19 @@ class CmdProxy {
{"patioctrl", &CmdProxy::patioctrl},
{"patword", &CmdProxy::PatternWord},
{"patlimits", &CmdProxy::PatternLoopAddresses},
{"patloop", &CmdProxy::PatternLoopAddresses},
{"patloop0", &CmdProxy::PatternLoopAddresses},
{"patloop1", &CmdProxy::PatternLoopAddresses},
{"patloop2", &CmdProxy::PatternLoopAddresses},
{"patnloop", &CmdProxy::PatternLoopCycles},
{"patnloop0", &CmdProxy::PatternLoopCycles},
{"patnloop1", &CmdProxy::PatternLoopCycles},
{"patnloop2", &CmdProxy::PatternLoopCycles},
{"patwait", &CmdProxy::PatternWaitAddress},
{"patwait0", &CmdProxy::PatternWaitAddress},
{"patwait1", &CmdProxy::PatternWaitAddress},
{"patwait2", &CmdProxy::PatternWaitAddress},
{"patwaittime", &CmdProxy::PatternWaitTime},
{"patwaittime0", &CmdProxy::PatternWaitTime},
{"patwaittime1", &CmdProxy::PatternWaitTime},
{"patwaittime2", &CmdProxy::PatternWaitTime},
@ -1148,6 +1152,8 @@ class CmdProxy {
IpAddr getIpFromAuto();
UdpDestination getUdpEntry();
std::string UDPDestinationList(int action);
std::string UDPSourceIP(int action);
std::string UDPSourceIP2(int action);
std::string UDPDestinationIP(int action);
std::string UDPDestinationIP2(int action);
/* Receiver Config */
@ -1190,6 +1196,7 @@ class CmdProxy {
/* Pattern */
std::string Pattern(int action);
std::string PatternWord(int action);
void GetLevelAndUpdateArgIndex(int action, std::string levelSeparatedCommand, int& level, int& iArg, size_t nGetArgs, size_t nPutArgs);
std::string PatternLoopAddresses(int action);
std::string PatternLoopCycles(int action);
std::string PatternWaitAddress(int action);
@ -1597,19 +1604,6 @@ class CmdProxy {
"out from in a round robin fashion. The entry must not have been "
"empty. Default: 0");
INTEGER_COMMAND_VEC_ID(
udp_srcip, getSourceUDPIP, setSourceUDPIP, IpAddr,
"[x.x.x.x]\n\tIp address of the detector (source) udp "
"interface. Must be same subnet as destination udp "
"ip.\n\t[Eiger] Set only for 10G. For 1G, detector will "
"replace with its own DHCP IP address.");
INTEGER_COMMAND_VEC_ID(
udp_srcip2, getSourceUDPIP2, setSourceUDPIP2, IpAddr,
"[x.x.x.x]\n\t[Jungfrau][Gotthard2] Ip address of the detector "
"(source) udp interface 2. Must be same subnet as destination udp "
"ip2.\n\t [Jungfrau] top half or inner interface\n\t [Gotthard2] veto "
"debugging.");
INTEGER_COMMAND_VEC_ID(
udp_srcmac, getSourceUDPMAC, setSourceUDPMAC, MacAddr,

View File

@ -1768,6 +1768,9 @@ int Module::getNumberOfAdditionalStorageCells() const {
void Module::setNumberOfAdditionalStorageCells(int value) {
sendToDetector(F_SET_NUM_ADDITIONAL_STORAGE_CELLS, value, nullptr);
if (shm()->useReceiverFlag) {
sendToReceiver(F_SET_RECEIVER_NUM_ADD_STORAGE_CELLS, value, nullptr);
}
}
int Module::getStorageCellStart() const {

View File

@ -29,8 +29,12 @@ bool Pattern::operator==(const Pattern &other) const {
if (pat->limits[i] != other.pat->limits[i])
return false;
}
for (size_t i = 0; i < (sizeof(pat->loop) / sizeof(pat->loop[0])); ++i) {
if (pat->loop[i] != other.pat->loop[i])
for (size_t i = 0; i < (sizeof(pat->startloop) / sizeof(pat->startloop[0])); ++i) {
if (pat->startloop[i] != other.pat->startloop[i])
return false;
}
for (size_t i = 0; i < (sizeof(pat->stoploop) / sizeof(pat->stoploop[0])); ++i) {
if (pat->stoploop[i] != other.pat->stoploop[i])
return false;
}
for (size_t i = 0; i < (sizeof(pat->nloop) / sizeof(pat->nloop[0])); ++i) {
@ -63,13 +67,13 @@ void Pattern::validate() const {
ToString(pat->limits[0]) + std::string(", ") +
ToString(pat->limits[1]) + std::string("]"));
}
for (int i = 0; i != 3; ++i) {
if (pat->loop[i * 2 + 0] >= MAX_PATTERN_LENGTH ||
pat->loop[i * 2 + 1] >= MAX_PATTERN_LENGTH) {
for (int i = 0; i != MAX_PATTERN_LEVELS; ++i) {
if (pat->startloop[i] >= MAX_PATTERN_LENGTH ||
pat->stoploop[i] >= MAX_PATTERN_LENGTH) {
throw RuntimeError(
"Invalid Pattern loop address for level " + ToString(i) +
std::string(" [") + ToString(pat->loop[i * 2 + 0]) +
std::string(", ") + ToString(pat->loop[i * 2 + 1]) +
std::string(" [") + ToString(pat->startloop[i]) +
std::string(", ") + ToString(pat->stoploop[i]) +
std::string("]"));
}
if (pat->wait[i] >= MAX_PATTERN_LENGTH) {
@ -125,41 +129,94 @@ void Pattern::load(const std::string &fname) {
}
pat->limits[0] = StringTo<uint32_t>(args[1]);
pat->limits[1] = StringTo<uint32_t>(args[2]);
} else if (cmd == "patloop0" || cmd == "patloop1" ||
cmd == "patloop2") {
if (nargs != 2) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
}
else if (cmd == "patloop0" || cmd == "patloop1" ||
cmd == "patloop2" || cmd == "patloop") {
int level = -1, iArg = 1;
if (cmd == "patloop") {
if (nargs != 3) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
}
level = StringTo<int>(args[iArg++]);
} else {
LOG(logWARNING) << "Depreciated command. Please use patloop next time.";
if (nargs != 2) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
}
level = cmd[cmd.find_first_of("012")] - '0';
}
int level = cmd[cmd.find_first_of("012")] - '0';
int loop1 = StringTo<uint32_t>(args[1]);
int loop2 = StringTo<uint32_t>(args[2]);
pat->loop[level * 2 + 0] = loop1;
pat->loop[level * 2 + 1] = loop2;
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
throw RuntimeError("Invalid Pattern level. Options 0-" + std::to_string(MAX_PATTERN_LEVELS - 1));
}
int loop1 = StringTo<uint32_t>(args[iArg++]);
int loop2 = StringTo<uint32_t>(args[iArg++]);
pat->startloop[level] = loop1;
pat->stoploop[level] = loop2;
} else if (cmd == "patnloop0" || cmd == "patnloop1" ||
cmd == "patnloop2") {
if (nargs != 1) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
cmd == "patnloop2" || cmd == "patnloop") {
int level = -1, iArg = 1;
if (cmd == "patnloop") {
if (nargs != 2) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
}
level = StringTo<int>(args[iArg++]);
} else {
LOG(logWARNING) << "Depreciated command. Please use patnloop next time.";
if (nargs != 1) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
}
level = cmd[cmd.find_first_of("012")] - '0';
}
int level = cmd[cmd.find_first_of("012")] - '0';
pat->nloop[level] = StringTo<uint32_t>(args[1]);
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
throw RuntimeError("Invalid Pattern level. Options 0-" + std::to_string(MAX_PATTERN_LEVELS - 1));
}
pat->nloop[level] = StringTo<uint32_t>(args[iArg++]);
} else if (cmd == "patwait0" || cmd == "patwait1" ||
cmd == "patwait2") {
if (nargs != 1) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
cmd == "patwait2" || cmd == "patwait") {
int level = -1, iArg = 1;
if (cmd == "patwait") {
if (nargs != 2) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
}
level = StringTo<int>(args[iArg++]);
} else {
LOG(logWARNING) << "Depreciated command. Please use patwait next time.";
if (nargs != 1) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
}
level = cmd[cmd.find_first_of("012")] - '0';
}
int level = cmd[cmd.find_first_of("012")] - '0';
pat->wait[level] = StringTo<uint32_t>(args[1]);
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
throw RuntimeError("Invalid Pattern level. Options 0-" + std::to_string(MAX_PATTERN_LEVELS - 1));
}
pat->wait[level] = StringTo<uint32_t>(args[iArg++]);
} else if (cmd == "patwaittime0" || cmd == "patwaittime1" ||
cmd == "patwaittime2") {
if (nargs != 1) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
cmd == "patwaittime2" || cmd == "patwaittime") {
int level = -1, iArg = 1;
if (cmd == "patwaittime") {
if (nargs != 2) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
}
level = StringTo<int>(args[iArg++]);
} else {
LOG(logWARNING) << "Depreciated command. Please use patwaittime next time.";
if (nargs != 1) {
throw RuntimeError("Invalid arguments for " +
ToString(args));
}
level = cmd[cmd.find_first_of("012")] - '0';
}
int level = cmd[cmd.find_first_of("012")] - '0';
pat->waittime[level] = StringTo<uint64_t>(args[1]);
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
throw RuntimeError("Invalid Pattern level. Options 0-" + std::to_string(MAX_PATTERN_LEVELS - 1));
}
pat->waittime[level] = StringTo<uint64_t>(args[iArg++]);
} else {
throw RuntimeError("Unknown command in pattern file " + cmd);
}
@ -187,21 +244,21 @@ void Pattern::save(const std::string &fname) {
output_file << "patlimits " << ToStringHex(pat->limits[0], 4) << " "
<< ToStringHex(pat->limits[1], 4) << std::endl;
for (size_t i = 0; i < 3; ++i) {
for (size_t i = 0; i < MAX_PATTERN_LEVELS; ++i) {
// patloop
output_file << "patloop" << i << " "
<< ToStringHex(pat->loop[i * 2 + 0], 4) << " "
<< ToStringHex(pat->loop[i * 2 + 1], 4) << std::endl;
output_file << "patloop " << i << " "
<< ToStringHex(pat->startloop[i], 4) << " "
<< ToStringHex(pat->stoploop[i], 4) << std::endl;
// patnloop
output_file << "patnloop" << i << " " << pat->nloop[i] << std::endl;
output_file << "patnloop " << i << " " << pat->nloop[i] << std::endl;
}
for (size_t i = 0; i < 3; ++i) {
for (size_t i = 0; i < MAX_PATTERN_LEVELS; ++i) {
// patwait
output_file << "patwait" << i << " " << ToStringHex(pat->wait[i], 4)
output_file << "patwait " << i << " " << ToStringHex(pat->wait[i], 4)
<< std::endl;
// patwaittime
output_file << "patwaittime" << i << " " << pat->waittime[i]
output_file << "patwaittime " << i << " " << pat->waittime[i]
<< std::endl;
}
}
@ -219,23 +276,17 @@ std::string Pattern::str() const {
}
oss << "patioctrl " << ToStringHex(pat->ioctrl, word_width) << std::endl
<< "patlimits " << ToStringHex(pat->limits[0], addr_width) << " "
<< ToStringHex(pat->limits[1], addr_width) << std::endl
<< "patloop0 " << ToStringHex(pat->loop[0], addr_width) << " "
<< ToStringHex(pat->loop[1], addr_width) << std::endl
<< "patnloop0 " << pat->nloop[0] << std::endl
<< "patloop1 " << ToStringHex(pat->loop[2], addr_width) << " "
<< ToStringHex(pat->loop[3], addr_width) << std::endl
<< "patnloop1 " << pat->nloop[1] << std::endl
<< "patloop2 " << ToStringHex(pat->loop[4], addr_width) << " "
<< ToStringHex(pat->loop[5], addr_width) << std::endl
<< "patnloop2 " << pat->nloop[2] << std::endl
<< "patwait0 " << ToStringHex(pat->wait[0], addr_width) << std::endl
<< "patwaittime0 " << pat->waittime[0] << std::endl
<< "patwait1 " << ToStringHex(pat->wait[1], addr_width) << std::endl
<< "patwaittime1 " << pat->waittime[1] << std::endl
<< "patwait2 " << ToStringHex(pat->wait[2], addr_width) << std::endl
<< "patwaittime2 " << pat->waittime[2] << std::endl
<< ']';
<< ToStringHex(pat->limits[1], addr_width) << std::endl;
for (int i = 0; i != MAX_PATTERN_LEVELS; ++i) {
oss << "patloop " << i << ' ' << ToStringHex(pat->startloop[i], addr_width) << " "
<< ToStringHex(pat->stoploop[i], addr_width) << std::endl
<< "patnloop " << pat->nloop[i] << std::endl
<< "patwait " << i << ' ' << ToStringHex(pat->wait[i], addr_width) << std::endl
<< "patwaittime " << i << ' ' << pat->waittime[i] << std::endl;
}
oss << ']';
return oss.str();
}

View File

@ -154,315 +154,187 @@ TEST_CASE("patlimits", "[.cmd]") {
}
}
TEST_CASE("patloop0", "[.cmd]") {
TEST_CASE("patloop", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopAddresses(0);
{
std::ostringstream oss;
proxy.Call("patloop0", {"0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patloop0 [0x0020, 0x005c]\n");
}
{
std::ostringstream oss;
proxy.Call("patloop0", {}, -1, GET, oss);
REQUIRE(oss.str() == "patloop0 [0x0020, 0x005c]\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopAddresses(0, prev_val[i][0], prev_val[i][1], {i});
for (int iLoop = 0; iLoop != MAX_PATTERN_LEVELS; ++iLoop) {
// m3 only has 3 levels
if (det_type == defs::MYTHEN3 && iLoop >= 3) {
continue;
}
auto prev_val = det.getPatternLoopAddresses(iLoop);
std::string sLoop = ToString(iLoop);
if (iLoop < 3) {
std::string deprecatedCmd = "patloop" + sLoop;
{// depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {"0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " [0x0020, 0x005c]\n");
}
{// depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " [0x0020, 0x005c]\n");
}
}
{
std::ostringstream oss;
proxy.Call("patloop", {sLoop, "0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patloop [0x0020, 0x005c]\n");
}
{
std::ostringstream oss;
proxy.Call("patloop", {sLoop}, -1, GET, oss);
REQUIRE(oss.str() == "patloop [0x0020, 0x005c]\n");
}
for (int iDet = 0; iDet != det.size(); ++iDet) {
det.setPatternLoopAddresses(iLoop, prev_val[iDet][0], prev_val[iDet][1], {iDet});
}
}
} else {
REQUIRE_THROWS(proxy.Call("patloop0", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("patloop", {"0"}, -1, GET));
}
}
TEST_CASE("patloop1", "[.cmd]") {
TEST_CASE("patnloop", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopAddresses(1);
{
std::ostringstream oss;
proxy.Call("patloop1", {"0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patloop1 [0x0020, 0x005c]\n");
}
{
std::ostringstream oss;
proxy.Call("patloop1", {}, -1, GET, oss);
REQUIRE(oss.str() == "patloop1 [0x0020, 0x005c]\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopAddresses(1, prev_val[i][0], prev_val[i][1], {i});
for (int iLoop = 0; iLoop != MAX_PATTERN_LEVELS; ++iLoop) {
// m3 only has 3 levels
if (det_type == defs::MYTHEN3 && iLoop >= 3) {
continue;
}
auto prev_val = det.getPatternLoopCycles(iLoop);
std::string sLoop = ToString(iLoop);
if (iLoop < 3) {
std::string deprecatedCmd = "patnloop" + sLoop;
{// depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {"5"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " 5\n");
}
{// depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " 5\n");
}
}
{
std::ostringstream oss;
proxy.Call("patnloop", {sLoop, "5"}, -1, PUT, oss);
REQUIRE(oss.str() == "patnloop 5\n");
}
{
std::ostringstream oss;
proxy.Call("patnloop", {sLoop}, -1, GET, oss);
REQUIRE(oss.str() == "patnloop 5\n");
}
for (int iDet = 0; iDet != det.size(); ++iDet) {
det.setPatternLoopCycles(iLoop, prev_val[iDet], {iDet});
}
}
} else {
REQUIRE_THROWS(proxy.Call("patloop1", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("patnloop", {"0"}, -1, GET));
}
}
TEST_CASE("patloop2", "[.cmd]") {
TEST_CASE("patwait", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopAddresses(2);
{
std::ostringstream oss;
proxy.Call("patloop2", {"0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patloop2 [0x0020, 0x005c]\n");
}
{
std::ostringstream oss;
proxy.Call("patloop2", {}, -1, GET, oss);
REQUIRE(oss.str() == "patloop2 [0x0020, 0x005c]\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopAddresses(2, prev_val[i][0], prev_val[i][1], {i});
for (int iLoop = 0; iLoop != MAX_PATTERN_LEVELS; ++iLoop) {
// m3 only has 3 levels
if (det_type == defs::MYTHEN3 && iLoop >= 3) {
continue;
}
auto prev_val = det.getPatternWaitAddr(iLoop);
std::string sLoop = ToString(iLoop);
if (iLoop < 3) {
std::string deprecatedCmd = "patwait" + sLoop;
{// depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {"0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " 0x005c\n");
}
{// depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " 0x005c\n");
}
}
{
std::ostringstream oss;
proxy.Call("patwait", {sLoop, "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwait 0x005c\n");
}
{
std::ostringstream oss;
proxy.Call("patwait", {sLoop}, -1, GET, oss);
REQUIRE(oss.str() == "patwait 0x005c\n");
}
for (int iDet = 0; iDet != det.size(); ++iDet) {
det.setPatternWaitAddr(iLoop, prev_val[iDet], {iDet});
}
}
} else {
REQUIRE_THROWS(proxy.Call("patloop2", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("patwait", {"0"}, -1, GET));
}
}
TEST_CASE("patnloop0", "[.cmd]") {
TEST_CASE("patwaittime", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopCycles(0);
{
std::ostringstream oss;
proxy.Call("patnloop0", {"5"}, -1, PUT, oss);
REQUIRE(oss.str() == "patnloop0 5\n");
}
{
std::ostringstream oss;
proxy.Call("patnloop0", {}, -1, GET, oss);
REQUIRE(oss.str() == "patnloop0 5\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopCycles(0, prev_val[i], {i});
for (int iLoop = 0; iLoop != MAX_PATTERN_LEVELS; ++iLoop) {
// m3 only has 3 levels
if (det_type == defs::MYTHEN3 && iLoop >= 3) {
continue;
}
auto prev_val = det.getPatternWaitTime(iLoop);
std::string sLoop = ToString(iLoop);
if (iLoop < 3) {
std::string deprecatedCmd = "patwaittime" + sLoop;
{// depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {"8589936640"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " 8589936640\n");
}
{// depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " 8589936640\n");
}
}
{
std::ostringstream oss;
proxy.Call("patwaittime", {sLoop, "8589936640"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwaittime 8589936640\n");
}
{
std::ostringstream oss;
proxy.Call("patwaittime", {sLoop}, -1, GET, oss);
REQUIRE(oss.str() == "patwaittime 8589936640\n");
}
for (int iDet = 0; iDet != det.size(); ++iDet) {
det.setPatternWaitTime(iLoop, prev_val[iDet], {iDet});
}
}
} else {
REQUIRE_THROWS(proxy.Call("patnloop0", {}, -1, GET));
}
}
TEST_CASE("patnloop1", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopCycles(1);
{
std::ostringstream oss;
proxy.Call("patnloop1", {"5"}, -1, PUT, oss);
REQUIRE(oss.str() == "patnloop1 5\n");
}
{
std::ostringstream oss;
proxy.Call("patnloop1", {}, -1, GET, oss);
REQUIRE(oss.str() == "patnloop1 5\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopCycles(1, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patnloop1", {}, -1, GET));
}
}
TEST_CASE("patnloop2", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternLoopCycles(2);
{
std::ostringstream oss;
proxy.Call("patnloop2", {"5"}, -1, PUT, oss);
REQUIRE(oss.str() == "patnloop2 5\n");
}
{
std::ostringstream oss;
proxy.Call("patnloop2", {}, -1, GET, oss);
REQUIRE(oss.str() == "patnloop2 5\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternLoopCycles(2, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patnloop2", {}, -1, GET));
}
}
TEST_CASE("patwait0", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitAddr(0);
{
std::ostringstream oss;
proxy.Call("patwait0", {"0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwait0 0x005c\n");
}
{
std::ostringstream oss;
proxy.Call("patwait0", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwait0 0x005c\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitAddr(0, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwait0", {}, -1, GET));
}
}
TEST_CASE("patwait1", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitAddr(1);
{
std::ostringstream oss;
proxy.Call("patwait1", {"0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwait1 0x005c\n");
}
{
std::ostringstream oss;
proxy.Call("patwait1", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwait1 0x005c\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitAddr(1, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwait1", {}, -1, GET));
}
}
TEST_CASE("patwait2", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitAddr(2);
{
std::ostringstream oss;
proxy.Call("patwait2", {"0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwait2 0x005c\n");
}
{
std::ostringstream oss;
proxy.Call("patwait2", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwait2 0x005c\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitAddr(2, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwait2", {}, -1, GET));
}
}
TEST_CASE("patwaittime0", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitTime(0);
{
std::ostringstream oss;
proxy.Call("patwaittime0", {"8589936640"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwaittime0 8589936640\n");
}
{
std::ostringstream oss;
proxy.Call("patwaittime0", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwaittime0 8589936640\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitTime(0, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwaittime0", {}, -1, GET));
}
}
TEST_CASE("patwaittime1", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitTime(1);
{
std::ostringstream oss;
proxy.Call("patwaittime1", {"8589936640"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwaittime1 8589936640\n");
}
{
std::ostringstream oss;
proxy.Call("patwaittime1", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwaittime1 8589936640\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitTime(1, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwaittime1", {}, -1, GET));
}
}
TEST_CASE("patwaittime2", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
det_type == defs::MYTHEN3) {
auto prev_val = det.getPatternWaitTime(2);
{
std::ostringstream oss;
proxy.Call("patwaittime2", {"8589936640"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwaittime2 8589936640\n");
}
{
std::ostringstream oss;
proxy.Call("patwaittime2", {}, -1, GET, oss);
REQUIRE(oss.str() == "patwaittime2 8589936640\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPatternWaitTime(2, prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("patwaittime2", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("patwaittime", {"0"}, -1, GET));
}
}

View File

@ -14,9 +14,9 @@ TEST_CASE("Pattern is default constructable and has zeroed fields") {
TEST_CASE("Copy construct pattern") {
Pattern p;
p.data()->loop[0] = 7;
p.data()->startloop[0] = 7;
Pattern p1(p);
REQUIRE(p1.data()->loop[0] == 7);
REQUIRE(p1.data()->startloop[0] == 7);
}
TEST_CASE("Compare patterns") {

View File

@ -581,7 +581,7 @@ int ClientInterface::set_num_add_storage_cells(Interface &socket) {
throw RuntimeError("Invalid number of additional storage cells " +
std::to_string(value));
}
verifyIdle(socket);
// allowing this to be done even when receiver not idle
LOG(logDEBUG1) << "Setting num additional storage cells to " << value;
impl()->setNumberOfAdditionalStorageCells(value);
return socket.Send(OK);

View File

@ -57,6 +57,7 @@ void DataProcessor::SetActivate(bool enable) { activated_ = enable; }
void DataProcessor::SetReceiverROI(ROI roi) {
receiverRoi_ = roi;
receiverRoiEnabled_ = receiverRoi_.completeRoi() ? false : true;
receiverNoRoi_ = receiverRoi_.noRoi();
}
void DataProcessor::ResetParametersforNewAcquisition() {
@ -125,8 +126,8 @@ void DataProcessor::CreateFirstFiles(
}
CloseFiles();
// deactivated (half module/ single port), dont write file
if (!activated_ || !detectorDataStream) {
// deactivated (half module/ single port or no roi), dont write file
if (!activated_ || !detectorDataStream || receiverNoRoi_) {
return;
}
@ -169,7 +170,7 @@ uint32_t DataProcessor::GetFilesInAcquisition() const {
return dataFile_->GetFilesInAcquisition();
}
std::array<std::string, 2> DataProcessor::CreateVirtualFile(
std::string DataProcessor::CreateVirtualFile(
const std::string &filePath, const std::string &fileNamePrefix,
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
const int modulePos, const int numUnitsPerReadout,
@ -195,7 +196,7 @@ std::array<std::string, 2> DataProcessor::CreateVirtualFile(
// stop acquisition)
return masterFileUtility::CreateVirtualHDF5File(
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
modulePos, numUnitsPerReadout, framesPerFile, numImages,
modulePos, numUnitsPerReadout, framesPerFile,
generalData_->nPixelsX, generalData_->nPixelsY, dynamicRange,
numFramesCaught_, numModX, numModY, dataFile_->GetPDataType(),
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes(),
@ -204,21 +205,18 @@ std::array<std::string, 2> DataProcessor::CreateVirtualFile(
void DataProcessor::LinkFileInMaster(const std::string &masterFileName,
const std::string &virtualFileName,
const std::string &virtualDatasetName,
const bool silentMode,
std::mutex *hdf5LibMutex) {
if (receiverRoiEnabled_) {
throw std::runtime_error("Should not be here, roi with hdf5 virtual should throw.");
}
std::string fname{virtualFileName}, datasetName{virtualDatasetName};
std::string fname{virtualFileName}, masterfname{masterFileName};
// if no virtual file, link data file
if (virtualFileName.empty()) {
auto res = dataFile_->GetFileAndDatasetName();
fname = res[0];
datasetName = res[1];
fname = dataFile_->GetFileName();
}
masterFileUtility::LinkHDF5FileInMaster(masterFileName, fname, datasetName,
masterFileUtility::LinkHDF5FileInMaster(masterfname, fname,
dataFile_->GetParameterNames(),
silentMode, hdf5LibMutex);
}

View File

@ -62,7 +62,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
const bool detectorDataStream);
#ifdef HDF5C
uint32_t GetFilesInAcquisition() const;
std::array<std::string, 2> CreateVirtualFile(
std::string CreateVirtualFile(
const std::string &filePath, const std::string &fileNamePrefix,
const uint64_t fileIndex, const bool overWriteEnable,
const bool silentMode, const int modulePos,
@ -71,7 +71,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
const uint32_t dynamicRange, std::mutex *hdf5LibMutex);
void LinkFileInMaster(const std::string &masterFileName,
const std::string &virtualFileName,
const std::string &virtualDatasetName,
const bool silentMode, std::mutex *hdf5LibMutex);
#endif
@ -157,6 +156,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
bool activated_{false};
ROI receiverRoi_{};
bool receiverRoiEnabled_{false};
bool receiverNoRoi_{false};
std::unique_ptr<char[]> completeImageToStreamBeforeCropping;
/** if 0, sending random images with a timer */
uint32_t *streamingFrequency_;

View File

@ -7,15 +7,12 @@
#include <array>
namespace sls {
#ifdef HDF5C
#include "H5Cpp.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
#endif
namespace sls {
struct MasterAttributes;
class File : private virtual slsDetectorDefs {
@ -28,11 +25,11 @@ class File : private virtual slsDetectorDefs {
virtual void CloseFile() = 0;
#ifdef HDF5C
virtual std::array<std::string, 2> GetFileAndDatasetName() const {
virtual std::string GetFileName() const {
LOG(logERROR)
<< "This is a generic function GetFilesInAcquisition that "
<< "This is a generic function GetFileName that "
"should be overloaded by a derived class";
return std::array<std::string, 2>{};
return std::string{};
}
virtual uint32_t GetFilesInAcquisition() const {
@ -42,24 +39,24 @@ class File : private virtual slsDetectorDefs {
return 0;
};
virtual DataType GetPDataType() const {
virtual H5::DataType GetPDataType() const {
LOG(logERROR) << "This is a generic function GetPDataType that "
"should be overloaded by a derived class";
return PredType::STD_U16LE;
return H5::PredType::STD_U16LE;
}
virtual std::vector<std::string> GetParameterNames() const {
LOG(logERROR)
<< "This is a generic function GetFilesInAcquisition that "
<< "This is a generic function GetParameterNames that "
"should be overloaded by a derived class";
return std::vector<std::string>{};
};
virtual std::vector<DataType> GetParameterDataTypes() const {
virtual std::vector<H5::DataType> GetParameterDataTypes() const {
LOG(logERROR)
<< "This is a generic function GetFilesInAcquisition that "
<< "This is a generic function GetParameterDataTypes that "
"should be overloaded by a derived class";
return std::vector<DataType>{};
return std::vector<H5::DataType>{};
};
virtual void CreateFirstHDF5DataFile(
@ -70,7 +67,7 @@ class File : private virtual slsDetectorDefs {
const uint32_t maxFramesPerFile, const uint64_t numImages,
const uint32_t nPixelsX, const uint32_t nPixelsY,
const uint32_t dynamicRange) {
LOG(logERROR) << "This is a generic function CreateFirstDataFile that "
LOG(logERROR) << "This is a generic function CreateFirstHDF5DataFile that "
"should be overloaded by a derived class";
};
#endif
@ -80,7 +77,7 @@ class File : private virtual slsDetectorDefs {
const bool silentMode, const int modulePos,
const int numUnitsPerReadout, const uint32_t udpPortNumber,
const uint32_t maxFramesPerFile) {
LOG(logERROR) << "This is a generic function CreateFirstDataFile that "
LOG(logERROR) << "This is a generic function CreateFirstBinaryDataFile that "
"should be overloaded by a derived class";
};

View File

@ -26,44 +26,44 @@ HDF5DataFile::HDF5DataFile(int index, std::mutex *hdf5Lib)
"detector header version",
"packets caught bit mask",
};
StrType strdatatype(PredType::C_S1, sizeof(bitset_storage));
parameterDataTypes_ = std::vector<DataType>{
PredType::STD_U64LE, PredType::STD_U32LE, PredType::STD_U32LE,
PredType::STD_U64LE, PredType::STD_U64LE, PredType::STD_U16LE,
PredType::STD_U16LE, PredType::STD_U16LE, PredType::STD_U16LE,
PredType::STD_U32LE, PredType::STD_U16LE, PredType::STD_U8LE,
PredType::STD_U8LE, strdatatype};
H5::StrType strdatatype(H5::PredType::C_S1, sizeof(bitset_storage));
parameterDataTypes_ = std::vector<H5::DataType>{
H5::PredType::STD_U64LE, H5::PredType::STD_U32LE, H5::PredType::STD_U32LE,
H5::PredType::STD_U64LE, H5::PredType::STD_U64LE, H5::PredType::STD_U16LE,
H5::PredType::STD_U16LE, H5::PredType::STD_U16LE, H5::PredType::STD_U16LE,
H5::PredType::STD_U32LE, H5::PredType::STD_U16LE, H5::PredType::STD_U8LE,
H5::PredType::STD_U8LE, strdatatype};
}
HDF5DataFile::~HDF5DataFile() { CloseFile(); }
std::array<std::string, 2> HDF5DataFile::GetFileAndDatasetName() const {
return std::array<std::string, 2>{fileName_, dataSetName_};
std::string HDF5DataFile::GetFileName() const {
return fileName_;
}
uint32_t HDF5DataFile::GetFilesInAcquisition() const {
return numFilesInAcquisition_;
}
DataType HDF5DataFile::GetPDataType() const { return dataType_; }
H5::DataType HDF5DataFile::GetPDataType() const { return dataType_; }
std::vector<std::string> HDF5DataFile::GetParameterNames() const {
return parameterNames_;
}
std::vector<DataType> HDF5DataFile::GetParameterDataTypes() const {
std::vector<H5::DataType> HDF5DataFile::GetParameterDataTypes() const {
return parameterDataTypes_;
}
void HDF5DataFile::CloseFile() {
std::lock_guard<std::mutex> lock(*hdf5Lib_);
try {
Exception::dontPrint(); // to handle errors
H5::Exception::dontPrint(); // to handle errors
if (fd_) {
fd_->close();
delete fd_;
fd_ = nullptr;
}
} catch (const Exception &error) {
} catch (const H5::Exception &error) {
LOG(logERROR) << "Could not close data HDF5 handles of index "
<< index_;
error.printErrorStack();
@ -116,13 +116,13 @@ void HDF5DataFile::CreateFirstHDF5DataFile(
switch (dynamicRange_) {
case 12:
case 16:
dataType_ = PredType::STD_U16LE;
dataType_ = H5::PredType::STD_U16LE;
break;
case 32:
dataType_ = PredType::STD_U32LE;
dataType_ = H5::PredType::STD_U32LE;
break;
default:
dataType_ = PredType::STD_U8LE;
dataType_ = H5::PredType::STD_U8LE;
break;
}
@ -153,42 +153,35 @@ void HDF5DataFile::CreateFile() {
uint32_t nDimz = ((dynamicRange_ == 4) ? (nPixelsX_ / 2) : nPixelsX_);
try {
Exception::dontPrint(); // to handle errors
H5::Exception::dontPrint(); // to handle errors
// file
FileAccPropList fapl;
H5::FileAccPropList fapl;
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
fd_ = nullptr;
if (!overWriteEnable_)
fd_ = new H5File(fileName_.c_str(), H5F_ACC_EXCL,
FileCreatPropList::DEFAULT, fapl);
fd_ = new H5::H5File(fileName_.c_str(), H5F_ACC_EXCL,
H5::FileCreatPropList::DEFAULT, fapl);
else
fd_ = new H5File(fileName_.c_str(), H5F_ACC_TRUNC,
FileCreatPropList::DEFAULT, fapl);
fd_ = new H5::H5File(fileName_.c_str(), H5F_ACC_TRUNC,
H5::FileCreatPropList::DEFAULT, fapl);
// attributes - version
double dValue = HDF5_WRITER_VERSION;
DataSpace dataspace_attr = DataSpace(H5S_SCALAR);
Attribute attribute = fd_->createAttribute(
"version", PredType::NATIVE_DOUBLE, dataspace_attr);
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
H5::DataSpace dataspace_attr = H5::DataSpace(H5S_SCALAR);
H5::Attribute attribute = fd_->createAttribute(
"version", H5::PredType::NATIVE_DOUBLE, dataspace_attr);
attribute.write(H5::PredType::NATIVE_DOUBLE, &dValue);
// dataspace
hsize_t srcdims[3] = {nDimx, nDimy, nDimz};
hsize_t srcdimsmax[3] = {H5S_UNLIMITED, nDimy, nDimz};
dataSpace_ = nullptr;
dataSpace_ = new DataSpace(3, srcdims, srcdimsmax);
// dataset name
std::ostringstream osfn;
osfn << "/data";
if (numImages_ > 1)
osfn << "_f" << std::setfill('0') << std::setw(12) << subFileIndex_;
dataSetName_ = osfn.str();
dataSpace_ = new H5::DataSpace(3, srcdims, srcdimsmax);
// dataset
// fill value
DSetCreatPropList plist;
H5::DSetCreatPropList plist;
int fill_value = -1;
plist.setFillValue(dataType_, &fill_value);
// always create chunked dataset as unlimited is only
@ -196,28 +189,28 @@ void HDF5DataFile::CreateFile() {
hsize_t chunk_dims[3] = {MAX_CHUNKED_IMAGES, nDimy, nDimz};
plist.setChunk(3, chunk_dims);
dataSet_ = nullptr;
dataSet_ = new DataSet(fd_->createDataSet(
dataSetName_.c_str(), dataType_, *dataSpace_, plist));
dataSet_ = new H5::DataSet(fd_->createDataSet(
DATASET_NAME, dataType_, *dataSpace_, plist));
// create parameter datasets
hsize_t dims[1] = {nDimx};
hsize_t dimsmax[1] = {H5S_UNLIMITED};
dataSpacePara_ = nullptr;
dataSpacePara_ = new DataSpace(1, dims, dimsmax);
dataSpacePara_ = new H5::DataSpace(1, dims, dimsmax);
// always create chunked dataset as unlimited is only
// supported with chunked layout
DSetCreatPropList paralist;
H5::DSetCreatPropList paralist;
hsize_t chunkpara_dims[3] = {MAX_CHUNKED_IMAGES};
paralist.setChunk(1, chunkpara_dims);
for (unsigned int i = 0; i < parameterNames_.size(); ++i) {
DataSet *ds = new DataSet(fd_->createDataSet(
H5::DataSet *ds = new H5::DataSet(fd_->createDataSet(
parameterNames_[i].c_str(), parameterDataTypes_[i],
*dataSpacePara_, paralist));
dataSetPara_.push_back(ds);
}
} catch (const Exception &error) {
} catch (const H5::Exception &error) {
error.printErrorStack();
CloseFile();
throw RuntimeError("Could not create HDF5 handles in object " +
@ -287,16 +280,16 @@ void HDF5DataFile::WriteDataFile(const uint64_t currentFrameNumber,
hsize_t start[3] = {nDimx, 0, 0};
hsize_t dims2[2] = {nDimy, nDimz};
try {
Exception::dontPrint(); // to handle errors
H5::Exception::dontPrint(); // to handle errors
dataSpace_->selectHyperslab(H5S_SELECT_SET, count, start);
DataSpace memspace(2, dims2);
H5::DataSpace memspace(2, dims2);
dataSet_->write(revBuffer, dataType_, memspace, *dataSpace_);
memspace.close();
if (dynamicRange_ == 12) {
free(revBuffer);
}
} catch (const Exception &error) {
} catch (const H5::Exception &error) {
if (dynamicRange_ == 12) {
free(revBuffer);
}
@ -320,9 +313,9 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
hsize_t start[1] = {fnum};
int i = 0;
try {
Exception::dontPrint(); // to handle errors
H5::Exception::dontPrint(); // to handle errors
dataSpacePara_->selectHyperslab(H5S_SELECT_SET, count, start);
DataSpace memspace(H5S_SCALAR);
H5::DataSpace memspace(H5S_SCALAR);
dataSetPara_[0]->write(&header.frameNumber, parameterDataTypes_[0],
memspace, *dataSpacePara_);
i = 1;
@ -383,7 +376,7 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
memspace, *dataSpacePara_);
}
i = 14;
} catch (const Exception &error) {
} catch (const H5::Exception &error) {
error.printErrorStack();
throw RuntimeError(
"Could not write parameters (index:" + std::to_string(i) +
@ -395,7 +388,7 @@ void HDF5DataFile::ExtendDataset() {
std::lock_guard<std::mutex> lock(*hdf5Lib_);
try {
Exception::dontPrint(); // to handle errors
H5::Exception::dontPrint(); // to handle errors
hsize_t dims[3];
dataSpace_->getSimpleExtentDims(dims);
@ -404,16 +397,16 @@ void HDF5DataFile::ExtendDataset() {
dataSet_->extend(dims);
delete dataSpace_;
dataSpace_ = nullptr;
dataSpace_ = new DataSpace(dataSet_->getSpace());
dataSpace_ = new H5::DataSpace(dataSet_->getSpace());
hsize_t dims_para[1] = {dims[0]};
for (unsigned int i = 0; i < dataSetPara_.size(); ++i)
dataSetPara_[i]->extend(dims_para);
delete dataSpacePara_;
dataSpacePara_ = nullptr;
dataSpacePara_ = new DataSpace(dataSetPara_[0]->getSpace());
dataSpacePara_ = new H5::DataSpace(dataSetPara_[0]->getSpace());
} catch (const Exception &error) {
} catch (const H5::Exception &error) {
error.printErrorStack();
throw RuntimeError("Could not extend dataset in object " +
std::to_string(index_));

View File

@ -14,11 +14,11 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
HDF5DataFile(const int index, std::mutex *hdf5Lib);
~HDF5DataFile();
std::array<std::string, 2> GetFileAndDatasetName() const override;
std::string GetFileName() const override;
uint32_t GetFilesInAcquisition() const override;
DataType GetPDataType() const override;
H5::DataType GetPDataType() const override;
std::vector<std::string> GetParameterNames() const override;
std::vector<DataType> GetParameterDataTypes() const override;
std::vector<H5::DataType> GetParameterDataTypes() const override;
void CloseFile() override;
@ -45,17 +45,17 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
int index_;
std::mutex *hdf5Lib_;
H5File *fd_{nullptr};
H5::H5File *fd_{nullptr};
std::string fileName_;
std::string dataSetName_;
DataSpace *dataSpace_{nullptr};
DataSet *dataSet_{nullptr};
DataType dataType_{PredType::STD_U16LE};
H5::DataSpace *dataSpace_{nullptr};
H5::DataSet *dataSet_{nullptr};
H5::DataType dataType_{H5::PredType::STD_U16LE};
DataSpace *dataSpacePara_{nullptr};
std::vector<DataSet *> dataSetPara_{nullptr};
H5::DataSpace *dataSpacePara_{nullptr};
std::vector<H5::DataSet *> dataSetPara_{nullptr};
std::vector<std::string> parameterNames_;
std::vector<DataType> parameterDataTypes_;
std::vector<H5::DataType> parameterDataTypes_;
uint32_t subFileIndex_{0};
uint32_t numFramesInFile_{0};

View File

@ -440,6 +440,8 @@ void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
portRois[iPort] = portRoi;
}
}
for (size_t i = 0; i != listener.size(); ++i)
listener[i]->SetNoRoi(portRois[i].noRoi());
for (size_t i = 0; i != dataProcessor.size(); ++i)
dataProcessor[i]->SetReceiverROI(portRois[i]);
LOG(logINFO) << "receiver roi: " << ToString(receiverRoi);
@ -721,7 +723,10 @@ void Implementation::stopReceiver() {
} else if (!detectorDataStream[i]) {
summary = (i == 0 ? "\n\tDeactivated Left Port"
: "\n\tDeactivated Right Port");
} else {
} else if (portRois[i].noRoi()) {
summary = (i == 0 ? "\n\tNo Roi on Left Port"
: "\n\tNo Roi on Right Port");
} else {
std::ostringstream os;
os << "\n\tMissing Packets\t\t: " << mpMessage
<< "\n\tComplete Frames\t\t: " << nf
@ -915,11 +920,11 @@ void Implementation::StartMasterWriter() {
}
#ifdef HDF5C
if (fileFormatType == HDF5) {
std::array<std::string, 2> virtualFileAndDatasetNames;
std::string virtualFileName;
// create virtual hdf5 file (if multiple files)
if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
(numPorts.x * numPorts.y) > 1) {
virtualFileAndDatasetNames =
virtualFileName =
dataProcessor[0]->CreateVirtualFile(
filePath, fileName, fileIndex, overwriteEnable,
silentMode, modulePos, numUDPInterfaces, framesPerFile,
@ -929,8 +934,7 @@ void Implementation::StartMasterWriter() {
// link file in master
if (masterFileWriteEnable) {
dataProcessor[0]->LinkFileInMaster(
masterFileName, virtualFileAndDatasetNames[0],
virtualFileAndDatasetNames[1], silentMode, &hdf5LibMutex);
masterFileName, virtualFileName, silentMode, &hdf5LibMutex);
}
}
#endif
@ -1003,6 +1007,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
&silentMode));
listener[i]->SetGeneralData(generalData);
listener[i]->SetActivate(activated);
listener[i]->SetNoRoi(portRois[i].noRoi());
int ctbAnalogDataBytes = 0;
if (detType == CHIPTESTBOARD) {

View File

@ -48,10 +48,7 @@ uint64_t Listener::GetLastFrameIndexCaught() const {
int64_t Listener::GetNumMissingPacket(bool stoppedFlag,
uint64_t numPackets) const {
if (!activated) {
return 0;
}
if (!(*detectorDataStream)) {
if (!activated || !(*detectorDataStream) || noRoi) {
return 0;
}
if (!stoppedFlag) {
@ -119,8 +116,10 @@ void Listener::SetGeneralData(GeneralData *g) { generalData = g; }
void Listener::SetActivate(bool enable) { activated = enable; }
void Listener::SetNoRoi(bool enable) {noRoi = enable; }
void Listener::CreateUDPSockets() {
if (!activated || !(*detectorDataStream)) {
if (!activated || !(*detectorDataStream) || noRoi) {
return;
}
@ -170,7 +169,7 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s) {
LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port "
<< *udpPortNumber;
if (!activated || !(*detectorDataStream)) {
if (!activated || !(*detectorDataStream) || noRoi) {
*actualUDPSocketBufferSize = (s * 2);
return;
}
@ -229,7 +228,7 @@ void Listener::ThreadExecution() {
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
// udpsocket doesnt exist
if (activated && *detectorDataStream && !udpSocketAlive && !carryOverFlag) {
if (activated && *detectorDataStream && !noRoi &&!udpSocketAlive && !carryOverFlag) {
// LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not
// created or shut down earlier";
(*((uint32_t *)buffer)) = 0;
@ -239,7 +238,7 @@ void Listener::ThreadExecution() {
// get data
if ((*status != TRANSMITTING &&
(!activated || !(*detectorDataStream) || udpSocketAlive)) ||
(!activated || !(*detectorDataStream) || noRoi || udpSocketAlive)) ||
carryOverFlag) {
rc = ListenToAnImage(buffer);
}
@ -317,12 +316,8 @@ uint32_t Listener::ListenToAnImage(char *buf) {
memset(buf, 0, fifohsize);
new_header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
// deactivated port (eiger)
if (!(*detectorDataStream)) {
return 0;
}
// deactivated (eiger)
if (!activated) {
// deactivated port (eiger) or deactivated (eiger)
if (!(*detectorDataStream) || !activated || noRoi) {
return 0;
}

View File

@ -65,6 +65,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
void ResetParametersforNewAcquisition();
void SetGeneralData(GeneralData *g);
void SetActivate(bool enable);
void SetNoRoi(bool enable);
void CreateUDPSockets();
void ShutDownUDPSocket();
@ -129,6 +130,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
frameDiscardPolicy *frameDiscardMode;
bool activated{false};
bool *detectorDataStream;
bool noRoi{false};
bool *silentMode;
/** row hardcoded as 1D or 2d,

View File

@ -1,6 +1,8 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include "MasterAttributes.h"
#include <time.h>
namespace sls {
@ -39,7 +41,7 @@ void MasterAttributes::GetBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5Attributes(H5::H5File *fd, H5::Group *group) {
WriteCommonHDF5Attributes(fd, group);
switch (detType) {
case slsDetectorDefs::GOTTHARD:
@ -167,40 +169,40 @@ void MasterAttributes::GetFinalBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *group) {
char c[1024]{};
// version
{
double version = BINARY_WRITER_VERSION;
DataSpace dataspace = DataSpace(H5S_SCALAR);
Attribute attribute =
fd->createAttribute("Version", PredType::NATIVE_DOUBLE, dataspace);
attribute.write(PredType::NATIVE_DOUBLE, &version);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::Attribute attribute =
fd->createAttribute("Version", H5::PredType::NATIVE_DOUBLE, dataspace);
attribute.write(H5::PredType::NATIVE_DOUBLE, &version);
}
// timestamp
{
time_t t = time(nullptr);
StrType strdatatype(PredType::C_S1, 256);
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
time_t t = std::time(nullptr);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Timestamp", strdatatype, dataspace);
strcpy_safe(c, std::string(ctime(&t)));
dataset.write(c, strdatatype);
}
// detector type
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset =
group->createDataSet("Detector Type", strdatatype, dataspace);
strcpy_safe(c, ToString(detType));
dataset.write(c, strdatatype);
}
// timing mode
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset =
group->createDataSet("Timing Mode", strdatatype, dataspace);
strcpy_safe(c, ToString(timingMode));
dataset.write(c, strdatatype);
@ -208,27 +210,27 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
// TODO: make this into an array?
// geometry x
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Geometry in x axis",
PredType::NATIVE_INT, dataspace);
dataset.write(&geometry.x, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Geometry in x axis",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&geometry.x, H5::PredType::NATIVE_INT);
}
// geometry y
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Geometry in y axis",
PredType::NATIVE_INT, dataspace);
dataset.write(&geometry.y, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Geometry in y axis",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&geometry.y, H5::PredType::NATIVE_INT);
}
// Image Size
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("Image Size", PredType::NATIVE_INT, dataspace);
dataset.write(&imageSize, PredType::NATIVE_INT);
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
Attribute attribute =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Image Size", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&imageSize, H5::PredType::NATIVE_INT);
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::Attribute attribute =
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
strcpy_safe(c, "bytes");
attribute.write(strdatatype, c);
@ -236,335 +238,335 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
// TODO: make this into an array?
// npixels x
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Number of pixels in x axis",
PredType::NATIVE_INT, dataspace);
dataset.write(&nPixels.x, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Number of pixels in x axis",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&nPixels.x, H5::PredType::NATIVE_INT);
}
// npixels y
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Number of pixels in y axis",
PredType::NATIVE_INT, dataspace);
dataset.write(&nPixels.y, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Number of pixels in y axis",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&nPixels.y, H5::PredType::NATIVE_INT);
}
// Maximum frames per file
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Maximum frames per file",
PredType::NATIVE_INT, dataspace);
dataset.write(&maxFramesPerFile, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Maximum frames per file",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&maxFramesPerFile, H5::PredType::NATIVE_INT);
}
// Frame Discard Policy
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset = group->createDataSet("Frame Discard Policy",
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset = group->createDataSet("Frame Discard Policy",
strdatatype, dataspace);
strcpy_safe(c, ToString(frameDiscardMode));
dataset.write(c, strdatatype);
}
// Frame Padding
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Frame Padding",
PredType::NATIVE_INT, dataspace);
dataset.write(&framePadding, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Frame Padding",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&framePadding, H5::PredType::NATIVE_INT);
}
// Scan Parameters
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset =
group->createDataSet("Scan Parameters", strdatatype, dataspace);
strcpy_safe(c, ToString(scanParams));
dataset.write(c, strdatatype);
}
// Total Frames
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Total Frames",
PredType::STD_U64LE, dataspace);
dataset.write(&totalFrames, PredType::STD_U64LE);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Total Frames",
H5::PredType::STD_U64LE, dataspace);
dataset.write(&totalFrames, H5::PredType::STD_U64LE);
}
// Receiver Roi xmin
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("receiver roi xmin",
PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.xmin, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("receiver roi xmin",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.xmin, H5::PredType::NATIVE_INT);
}
// Receiver Roi xmax
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("receiver roi xmax",
PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.xmax, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("receiver roi xmax",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.xmax, H5::PredType::NATIVE_INT);
}
// Receiver Roi ymin
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("receiver roi ymin",
PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.ymin, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("receiver roi ymin",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.ymin, H5::PredType::NATIVE_INT);
}
// Receiver Roi ymax
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("receiver roi ymax",
PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.ymax, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("receiver roi ymax",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.ymax, H5::PredType::NATIVE_INT);
}
}
void MasterAttributes::WriteFinalHDF5Attributes(H5File *fd, Group *group) {
void MasterAttributes::WriteFinalHDF5Attributes(H5::H5File *fd, H5::Group *group) {
char c[1024]{};
// Total Frames in file
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Frames in File",
PredType::STD_U64LE, dataspace);
dataset.write(&framesInFile, PredType::STD_U64LE);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Frames in File",
H5::PredType::STD_U64LE, dataspace);
dataset.write(&framesInFile, H5::PredType::STD_U64LE);
}
// additional json header
if (!additionalJsonHeader.empty()) {
std::string json = ToString(additionalJsonHeader);
StrType strdatatype(PredType::C_S1, json.length());
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Additional JSON Header",
H5::StrType strdatatype(H5::PredType::C_S1, json.length());
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Additional JSON Header",
strdatatype, dataspace);
strcpy_safe(c, ToString(additionalJsonHeader));
dataset.write(c, strdatatype);
}
}
void MasterAttributes::WriteHDF5Exptime(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
void MasterAttributes::WriteHDF5Exptime(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset =
group->createDataSet("Exposure Time", strdatatype, dataspace);
char c[1024]{};
strcpy_safe(c, ToString(exptime));
dataset.write(c, strdatatype);
}
void MasterAttributes::WriteHDF5Period(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
void MasterAttributes::WriteHDF5Period(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset =
group->createDataSet("Acquisition Period", strdatatype, dataspace);
char c[1024]{};
strcpy_safe(c, ToString(period));
dataset.write(c, strdatatype);
}
void MasterAttributes::WriteHDF5DynamicRange(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("Dynamic Range", PredType::NATIVE_INT, dataspace);
dataset.write(&dynamicRange, PredType::NATIVE_INT);
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
Attribute attribute =
void MasterAttributes::WriteHDF5DynamicRange(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Dynamic Range", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&dynamicRange, H5::PredType::NATIVE_INT);
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::Attribute attribute =
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
char c[1024] = "bits";
attribute.write(strdatatype, c);
}
void MasterAttributes::WriteHDF5TenGiga(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Ten Giga Enable",
PredType::NATIVE_INT, dataspace);
dataset.write(&tenGiga, PredType::NATIVE_INT);
void MasterAttributes::WriteHDF5TenGiga(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Ten Giga Enable",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&tenGiga, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5ROI(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5ROI(H5::H5File *fd, H5::Group *group) {
// Roi xmin
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("roi xmin", PredType::NATIVE_INT, dataspace);
dataset.write(&detectorRoi.xmin, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("roi xmin", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&detectorRoi.xmin, H5::PredType::NATIVE_INT);
}
// Roi xmax
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("roi xmax", PredType::NATIVE_INT, dataspace);
dataset.write(&detectorRoi.xmax, PredType::NATIVE_INT);
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("roi xmax", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&detectorRoi.xmax, H5::PredType::NATIVE_INT);
}
}
void MasterAttributes::WriteHDF5NumUDPInterfaces(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Number of UDP Interfaces",
PredType::NATIVE_INT, dataspace);
dataset.write(&numUDPInterfaces, PredType::NATIVE_INT);
void MasterAttributes::WriteHDF5NumUDPInterfaces(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Number of UDP Interfaces",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&numUDPInterfaces, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5ReadNRows(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("Number of rows", PredType::NATIVE_INT, dataspace);
dataset.write(&readNRows, PredType::NATIVE_INT);
void MasterAttributes::WriteHDF5ReadNRows(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Number of rows", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&readNRows, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5ThresholdEnergy(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5ThresholdEnergy(H5::H5File *fd, H5::Group *group) {
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Threshold Energy",
PredType::NATIVE_INT, dataspace);
dataset.write(&thresholdEnergyeV, PredType::NATIVE_INT);
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
Attribute attribute =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Threshold Energy",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&thresholdEnergyeV, H5::PredType::NATIVE_INT);
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::Attribute attribute =
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
strcpy_safe(c, "eV");
attribute.write(strdatatype, c);
}
void MasterAttributes::WriteHDF5ThresholdEnergies(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5ThresholdEnergies(H5::H5File *fd, H5::Group *group) {
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 1024);
DataSet dataset =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 1024);
H5::DataSet dataset =
group->createDataSet("Threshold Energies", strdatatype, dataspace);
strcpy_safe(c, ToString(thresholdAllEnergyeV));
dataset.write(c, strdatatype);
}
void MasterAttributes::WriteHDF5SubExpTime(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5SubExpTime(H5::H5File *fd, H5::Group *group) {
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset =
group->createDataSet("Sub Exposure Time", strdatatype, dataspace);
strcpy_safe(c, ToString(subExptime));
dataset.write(c, strdatatype);
}
void MasterAttributes::WriteHDF5SubPeriod(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5SubPeriod(H5::H5File *fd, H5::Group *group) {
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset =
group->createDataSet("Sub Period", strdatatype, dataspace);
strcpy_safe(c, ToString(subPeriod));
dataset.write(c, strdatatype);
}
void MasterAttributes::WriteHDF5SubQuad(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("Quad", PredType::NATIVE_INT, dataspace);
dataset.write(&quad, PredType::NATIVE_INT);
void MasterAttributes::WriteHDF5SubQuad(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Quad", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&quad, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5RateCorrections(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5RateCorrections(H5::H5File *fd, H5::Group *group) {
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 1024);
DataSet dataset =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 1024);
H5::DataSet dataset =
group->createDataSet("Rate Corrections", strdatatype, dataspace);
strcpy_safe(c, ToString(ratecorr));
dataset.write(c, strdatatype);
}
void MasterAttributes::WriteHDF5CounterMask(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("Counter Mask", PredType::STD_U32LE, dataspace);
dataset.write(&counterMask, PredType::STD_U32LE);
void MasterAttributes::WriteHDF5CounterMask(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Counter Mask", H5::PredType::STD_U32LE, dataspace);
dataset.write(&counterMask, H5::PredType::STD_U32LE);
}
void MasterAttributes::WriteHDF5ExptimeArray(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5ExptimeArray(H5::H5File *fd, H5::Group *group) {
for (int i = 0; i != 3; ++i) {
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset =
group->createDataSet("Exposure Time1", strdatatype, dataspace);
strcpy_safe(c, ToString(exptimeArray[i]));
dataset.write(c, strdatatype);
}
}
void MasterAttributes::WriteHDF5GateDelayArray(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5GateDelayArray(H5::H5File *fd, H5::Group *group) {
for (int i = 0; i != 3; ++i) {
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset =
group->createDataSet("Gate Delay1", strdatatype, dataspace);
strcpy_safe(c, ToString(gateDelayArray[i]));
dataset.write(c, strdatatype);
}
}
void MasterAttributes::WriteHDF5Gates(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("Gates", PredType::STD_U32LE, dataspace);
dataset.write(&gates, PredType::STD_U32LE);
void MasterAttributes::WriteHDF5Gates(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Gates", H5::PredType::STD_U32LE, dataspace);
dataset.write(&gates, H5::PredType::STD_U32LE);
}
void MasterAttributes::WriteHDF5BurstMode(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
void MasterAttributes::WriteHDF5BurstMode(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset =
group->createDataSet("Burst Mode", strdatatype, dataspace);
char c[1024]{};
strcpy_safe(c, ToString(burstMode));
dataset.write(c, strdatatype);
}
void MasterAttributes::WriteHDF5AdcMask(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("ADC Mask", PredType::NATIVE_INT, dataspace);
dataset.write(&adcmask, PredType::NATIVE_INT);
void MasterAttributes::WriteHDF5AdcMask(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("ADC Mask", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&adcmask, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5AnalogFlag(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("Analog Flag", PredType::NATIVE_INT, dataspace);
dataset.write(&analog, PredType::NATIVE_INT);
void MasterAttributes::WriteHDF5AnalogFlag(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Analog Flag", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&analog, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5AnalogSamples(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("Analog Samples", PredType::NATIVE_INT, dataspace);
dataset.write(&analogSamples, PredType::NATIVE_INT);
void MasterAttributes::WriteHDF5AnalogSamples(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Analog Samples", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&analogSamples, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5DigitalFlag(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("Digital Flag", PredType::NATIVE_INT, dataspace);
dataset.write(&digital, PredType::NATIVE_INT);
void MasterAttributes::WriteHDF5DigitalFlag(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Digital Flag", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&digital, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5DigitalSamples(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Digital Samples",
PredType::NATIVE_INT, dataspace);
dataset.write(&digitalSamples, PredType::NATIVE_INT);
void MasterAttributes::WriteHDF5DigitalSamples(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Digital Samples",
H5::PredType::NATIVE_INT, dataspace);
dataset.write(&digitalSamples, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5DbitOffset(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("Dbit Offset", PredType::NATIVE_INT, dataspace);
dataset.write(&dbitoffset, PredType::NATIVE_INT);
void MasterAttributes::WriteHDF5DbitOffset(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Dbit Offset", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&dbitoffset, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5DbitList(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Dbit Bitset List",
PredType::STD_U64LE, dataspace);
dataset.write(&dbitlist, PredType::STD_U64LE);
void MasterAttributes::WriteHDF5DbitList(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Dbit Bitset List",
H5::PredType::STD_U64LE, dataspace);
dataset.write(&dbitlist, H5::PredType::STD_U64LE);
}
#endif
@ -584,7 +586,7 @@ void MasterAttributes::GetGotthardBinaryAttributes(
};
#ifdef HDF5C
void MasterAttributes::WriteGotthardHDF5Attributes(H5File *fd, Group *group) {
void MasterAttributes::WriteGotthardHDF5Attributes(H5::H5File *fd, H5::Group *group) {
MasterAttributes::WriteHDF5Exptime(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
MasterAttributes::WriteHDF5ROI(fd, group);
@ -604,7 +606,7 @@ void MasterAttributes::GetJungfrauBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteJungfrauHDF5Attributes(H5File *fd, Group *group) {
void MasterAttributes::WriteJungfrauHDF5Attributes(H5::H5File *fd, H5::Group *group) {
MasterAttributes::WriteHDF5Exptime(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
MasterAttributes::WriteHDF5NumUDPInterfaces(fd, group);
@ -637,7 +639,7 @@ void MasterAttributes::GetEigerBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteEigerHDF5Attributes(H5File *fd, Group *group) {
void MasterAttributes::WriteEigerHDF5Attributes(H5::H5File *fd, H5::Group *group) {
MasterAttributes::WriteHDF5DynamicRange(fd, group);
MasterAttributes::WriteHDF5TenGiga(fd, group);
MasterAttributes::WriteHDF5Exptime(fd, group);
@ -676,7 +678,7 @@ void MasterAttributes::GetMythen3BinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteMythen3HDF5Attributes(H5File *fd, Group *group) {
void MasterAttributes::WriteMythen3HDF5Attributes(H5::H5File *fd, H5::Group *group) {
MasterAttributes::WriteHDF5DynamicRange(fd, group);
MasterAttributes::WriteHDF5TenGiga(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
@ -699,7 +701,7 @@ void MasterAttributes::GetGotthard2BinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteGotthard2HDF5Attributes(H5File *fd, Group *group) {
void MasterAttributes::WriteGotthard2HDF5Attributes(H5::H5File *fd, H5::Group *group) {
MasterAttributes::WriteHDF5Exptime(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
MasterAttributes::WriteHDF5BurstMode(fd, group);
@ -721,7 +723,7 @@ void MasterAttributes::GetMoenchBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteMoenchHDF5Attributes(H5File *fd, Group *group) {
void MasterAttributes::WriteMoenchHDF5Attributes(H5::H5File *fd, H5::Group *group) {
MasterAttributes::WriteHDF5Exptime(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
MasterAttributes::WriteHDF5TenGiga(fd, group);
@ -755,7 +757,7 @@ void MasterAttributes::GetCtbBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteCtbHDF5Attributes(H5File *fd, Group *group) {
void MasterAttributes::WriteCtbHDF5Attributes(H5::H5File *fd, H5::Group *group) {
MasterAttributes::WriteHDF5Exptime(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
MasterAttributes::WriteHDF5TenGiga(fd, group);

View File

@ -11,16 +11,16 @@
#include <rapidjson/stringbuffer.h>
#include <chrono>
#ifdef HDF5C
#include "H5Cpp.h"
#endif
namespace sls {
using ns = std::chrono::nanoseconds;
#ifdef HDF5C
#include "H5Cpp.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
#endif
class MasterAttributes {
public:
@ -71,7 +71,7 @@ class MasterAttributes {
void
GetBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteHDF5Attributes(H5File *fd, Group *group);
void WriteHDF5Attributes(H5::H5File *fd, H5::Group *group);
#endif
void GetCommonBinaryAttributes(
@ -79,75 +79,75 @@ class MasterAttributes {
void GetFinalBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteCommonHDF5Attributes(H5File *fd, Group *group);
void WriteFinalHDF5Attributes(H5File *fd, Group *group);
void WriteHDF5Exptime(H5File *fd, Group *group);
void WriteHDF5Period(H5File *fd, Group *group);
void WriteHDF5DynamicRange(H5File *fd, Group *group);
void WriteHDF5TenGiga(H5File *fd, Group *group);
void WriteHDF5ROI(H5File *fd, Group *group);
void WriteHDF5NumUDPInterfaces(H5File *fd, Group *group);
void WriteHDF5ReadNRows(H5File *fd, Group *group);
void WriteHDF5ThresholdEnergy(H5File *fd, Group *group);
void WriteHDF5ThresholdEnergies(H5File *fd, Group *group);
void WriteHDF5SubExpTime(H5File *fd, Group *group);
void WriteHDF5SubPeriod(H5File *fd, Group *group);
void WriteHDF5SubQuad(H5File *fd, Group *group);
void WriteHDF5RateCorrections(H5File *fd, Group *group);
void WriteHDF5CounterMask(H5File *fd, Group *group);
void WriteHDF5ExptimeArray(H5File *fd, Group *group);
void WriteHDF5GateDelayArray(H5File *fd, Group *group);
void WriteHDF5Gates(H5File *fd, Group *group);
void WriteHDF5BurstMode(H5File *fd, Group *group);
void WriteHDF5AdcMask(H5File *fd, Group *group);
void WriteHDF5AnalogFlag(H5File *fd, Group *group);
void WriteHDF5AnalogSamples(H5File *fd, Group *group);
void WriteHDF5DigitalFlag(H5File *fd, Group *group);
void WriteHDF5DigitalSamples(H5File *fd, Group *group);
void WriteHDF5DbitOffset(H5File *fd, Group *group);
void WriteHDF5DbitList(H5File *fd, Group *group);
void WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *group);
void WriteFinalHDF5Attributes(H5::H5File *fd, H5::Group *group);
void WriteHDF5Exptime(H5::H5File *fd, H5::Group *group);
void WriteHDF5Period(H5::H5File *fd, H5::Group *group);
void WriteHDF5DynamicRange(H5::H5File *fd, H5::Group *group);
void WriteHDF5TenGiga(H5::H5File *fd, H5::Group *group);
void WriteHDF5ROI(H5::H5File *fd, H5::Group *group);
void WriteHDF5NumUDPInterfaces(H5::H5File *fd, H5::Group *group);
void WriteHDF5ReadNRows(H5::H5File *fd, H5::Group *group);
void WriteHDF5ThresholdEnergy(H5::H5File *fd, H5::Group *group);
void WriteHDF5ThresholdEnergies(H5::H5File *fd, H5::Group *group);
void WriteHDF5SubExpTime(H5::H5File *fd, H5::Group *group);
void WriteHDF5SubPeriod(H5::H5File *fd, H5::Group *group);
void WriteHDF5SubQuad(H5::H5File *fd, H5::Group *group);
void WriteHDF5RateCorrections(H5::H5File *fd, H5::Group *group);
void WriteHDF5CounterMask(H5::H5File *fd, H5::Group *group);
void WriteHDF5ExptimeArray(H5::H5File *fd, H5::Group *group);
void WriteHDF5GateDelayArray(H5::H5File *fd, H5::Group *group);
void WriteHDF5Gates(H5::H5File *fd, H5::Group *group);
void WriteHDF5BurstMode(H5::H5File *fd, H5::Group *group);
void WriteHDF5AdcMask(H5::H5File *fd, H5::Group *group);
void WriteHDF5AnalogFlag(H5::H5File *fd, H5::Group *group);
void WriteHDF5AnalogSamples(H5::H5File *fd, H5::Group *group);
void WriteHDF5DigitalFlag(H5::H5File *fd, H5::Group *group);
void WriteHDF5DigitalSamples(H5::H5File *fd, H5::Group *group);
void WriteHDF5DbitOffset(H5::H5File *fd, H5::Group *group);
void WriteHDF5DbitList(H5::H5File *fd, H5::Group *group);
#endif
void GetGotthardBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteGotthardHDF5Attributes(H5File *fd, Group *group);
void WriteGotthardHDF5Attributes(H5::H5File *fd, H5::Group *group);
#endif
void GetJungfrauBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteJungfrauHDF5Attributes(H5File *fd, Group *group);
void WriteJungfrauHDF5Attributes(H5::H5File *fd, H5::Group *group);
#endif
void GetEigerBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteEigerHDF5Attributes(H5File *fd, Group *group);
void WriteEigerHDF5Attributes(H5::H5File *fd, H5::Group *group);
#endif
void GetMythen3BinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMythen3HDF5Attributes(H5File *fd, Group *group);
void WriteMythen3HDF5Attributes(H5::H5File *fd, H5::Group *group);
#endif
void GetGotthard2BinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteGotthard2HDF5Attributes(H5File *fd, Group *group);
void WriteGotthard2HDF5Attributes(H5::H5File *fd, H5::Group *group);
#endif
void GetMoenchBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMoenchHDF5Attributes(H5File *fd, Group *group);
void WriteMoenchHDF5Attributes(H5::H5File *fd, H5::Group *group);
#endif
void
GetCtbBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteCtbHDF5Attributes(H5File *fd, Group *group);
void WriteCtbHDF5Attributes(H5::H5File *fd, H5::Group *group);
#endif
};

View File

@ -47,32 +47,31 @@ std::string CreateMasterBinaryFile(const std::string &filePath,
}
#ifdef HDF5C
void LinkHDF5FileInMaster(const std::string &masterFileName,
const std::string &dataFilename,
const std::string &dataSetname,
const std::vector<std::string> parameterNames,
void LinkHDF5FileInMaster(std::string &masterFileName,
std::string &dataFilename,
std::vector<std::string> parameterNames,
const bool silentMode, std::mutex *hdf5LibMutex) {
std::lock_guard<std::mutex> lock(*hdf5LibMutex);
std::unique_ptr<H5File> fd{nullptr};
std::unique_ptr<H5::H5File> fd{nullptr};
try {
Exception::dontPrint(); // to handle errors
H5::Exception::dontPrint(); // to handle errors
FileAccPropList flist;
H5::FileAccPropList flist;
flist.setFcloseDegree(H5F_CLOSE_STRONG);
// open master file
H5File masterfd(masterFileName.c_str(), H5F_ACC_RDWR,
FileCreatPropList::DEFAULT, flist);
H5::H5File masterfd(masterFileName.c_str(), H5F_ACC_RDWR,
H5::FileCreatPropList::DEFAULT, flist);
// open data file
fd = make_unique<H5File>(dataFilename.c_str(), H5F_ACC_RDONLY,
FileCreatPropList::DEFAULT, flist);
fd = make_unique<H5::H5File>(dataFilename.c_str(), H5F_ACC_RDONLY,
H5::FileCreatPropList::DEFAULT, flist);
// create link for data dataset
DataSet dset = fd->openDataSet(dataSetname.c_str());
std::string linkname = std::string("/entry/data/") + dataSetname;
if (H5Lcreate_external(dataFilename.c_str(), dataSetname.c_str(),
H5::DataSet dset = fd->openDataSet(DATASET_NAME);
std::string linkname = std::string("/entry/data/") + std::string(DATASET_NAME);
if (H5Lcreate_external(dataFilename.c_str(), DATASET_NAME,
masterfd.getLocId(), linkname.c_str(),
H5P_DEFAULT, H5P_DEFAULT) < 0) {
throw RuntimeError(
@ -81,7 +80,7 @@ void LinkHDF5FileInMaster(const std::string &masterFileName,
// create link for parameter datasets
for (unsigned int i = 0; i < parameterNames.size(); ++i) {
DataSet pDset = fd->openDataSet(parameterNames[i].c_str());
H5::DataSet pDset = fd->openDataSet(parameterNames[i].c_str());
linkname = std::string("/entry/data/") + parameterNames[i];
if (H5Lcreate_external(dataFilename.c_str(),
parameterNames[i].c_str(),
@ -93,7 +92,7 @@ void LinkHDF5FileInMaster(const std::string &masterFileName,
}
fd->close();
masterfd.close();
} catch (const Exception &error) {
} catch (const H5::Exception &error) {
error.printErrorStack();
if (fd != nullptr)
fd->close();
@ -118,38 +117,38 @@ std::string CreateMasterHDF5File(const std::string &filePath,
std::lock_guard<std::mutex> lock(*hdf5LibMutex);
std::unique_ptr<H5File> fd{nullptr};
std::unique_ptr<H5::H5File> fd{nullptr};
try {
Exception::dontPrint(); // to handle errors
H5::Exception::dontPrint(); // to handle errors
FileAccPropList flist;
H5::FileAccPropList flist;
flist.setFcloseDegree(H5F_CLOSE_STRONG);
unsigned int createFlags = H5F_ACC_EXCL;
if (overWriteEnable) {
createFlags = H5F_ACC_TRUNC;
}
fd = make_unique<H5File>(fileName.c_str(), createFlags,
FileCreatPropList::DEFAULT, flist);
fd = make_unique<H5::H5File>(fileName.c_str(), createFlags,
H5::FileCreatPropList::DEFAULT, flist);
// attributes - version
double dValue = HDF5_WRITER_VERSION;
DataSpace dataspace_attr = DataSpace(H5S_SCALAR);
Attribute attribute = fd->createAttribute(
"version", PredType::NATIVE_DOUBLE, dataspace_attr);
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
H5::DataSpace dataspace_attr = H5::DataSpace(H5S_SCALAR);
H5::Attribute attribute = fd->createAttribute(
"version", H5::PredType::NATIVE_DOUBLE, dataspace_attr);
attribute.write(H5::PredType::NATIVE_DOUBLE, &dValue);
// Create a group in the file
Group group1(fd->createGroup("entry"));
Group group2(group1.createGroup("data"));
Group group3(group1.createGroup("instrument"));
Group group4(group3.createGroup("beam"));
Group group5(group3.createGroup("detector"));
Group group6(group1.createGroup("sample"));
H5::Group group1(fd->createGroup("entry"));
H5::Group group2(group1.createGroup("data"));
H5::Group group3(group1.createGroup("instrument"));
H5::Group group4(group3.createGroup("beam"));
H5::Group group5(group3.createGroup("detector"));
H5::Group group6(group1.createGroup("sample"));
attr->WriteHDF5Attributes(fd.get(), &group5);
fd->close();
} catch (const Exception &error) {
} catch (const H5::Exception &error) {
error.printErrorStack();
if (fd != nullptr)
fd->close();
@ -162,16 +161,16 @@ std::string CreateMasterHDF5File(const std::string &filePath,
return fileName;
}
std::array<std::string, 2> CreateVirtualHDF5File(
std::string CreateVirtualHDF5File(
const std::string &filePath, const std::string &fileNamePrefix,
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
const int modulePos, const int numUnitsPerReadout,
const uint32_t maxFramesPerFile, const uint64_t numImages,
const uint32_t maxFramesPerFile,
const uint32_t nPixelsX, const uint32_t nPixelsY,
const uint32_t dynamicRange, const uint64_t numImagesCaught,
const int numModX, const int numModY, const DataType dataType,
const int numModX, const int numModY, const H5::DataType dataType,
const std::vector<std::string> parameterNames,
const std::vector<DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
const std::vector<H5::DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
bool gotthard25um) {
// virtual file name
@ -180,8 +179,6 @@ std::array<std::string, 2> CreateVirtualHDF5File(
<< "_" << fileIndex << ".h5";
std::string fileName = osfn.str();
std::string dataSetName = "data";
unsigned int paraSize = parameterNames.size();
uint64_t numModZ = numModX;
uint32_t nDimy = nPixelsY;
@ -189,42 +186,42 @@ std::array<std::string, 2> CreateVirtualHDF5File(
std::lock_guard<std::mutex> lock(*hdf5LibMutex);
std::unique_ptr<H5File> fd{nullptr};
std::unique_ptr<H5::H5File> fd{nullptr};
try {
Exception::dontPrint(); // to handle errors
H5::Exception::dontPrint(); // to handle errors
// file
FileAccPropList fapl;
H5::FileAccPropList fapl;
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
if (!overWriteEnable)
fd = make_unique<H5File>(fileName.c_str(), H5F_ACC_EXCL,
FileCreatPropList::DEFAULT, fapl);
fd = make_unique<H5::H5File>(fileName.c_str(), H5F_ACC_EXCL,
H5::FileCreatPropList::DEFAULT, fapl);
else
fd = make_unique<H5File>(fileName.c_str(), H5F_ACC_TRUNC,
FileCreatPropList::DEFAULT, fapl);
fd = make_unique<H5::H5File>(fileName.c_str(), H5F_ACC_TRUNC,
H5::FileCreatPropList::DEFAULT, fapl);
// attributes - version
double dValue = HDF5_WRITER_VERSION;
DataSpace dataspace_attr = DataSpace(H5S_SCALAR);
Attribute attribute = fd->createAttribute(
"version", PredType::NATIVE_DOUBLE, dataspace_attr);
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
H5::DataSpace dataspace_attr = H5::DataSpace(H5S_SCALAR);
H5::Attribute attribute = fd->createAttribute(
"version", H5::PredType::NATIVE_DOUBLE, dataspace_attr);
attribute.write(H5::PredType::NATIVE_DOUBLE, &dValue);
// virtual dataspace
hsize_t vdsDims[3] = {numImagesCaught, numModY * nDimy,
numModZ * nDimz};
DataSpace vdsDataSpace(3, vdsDims, nullptr);
H5::DataSpace vdsDataSpace(3, vdsDims, nullptr);
hsize_t vdsDimsPara[2] = {numImagesCaught,
(unsigned int)numModY * numModZ};
DataSpace vdsDataSpacePara(2, vdsDimsPara, nullptr);
H5::DataSpace vdsDataSpacePara(2, vdsDimsPara, nullptr);
// property list (fill value and datatype)
int fill_value = -1;
DSetCreatPropList plist;
H5::DSetCreatPropList plist;
plist.setFillValue(dataType, &fill_value);
// property list for parameters (datatype)
std::vector<DSetCreatPropList> plistPara(paraSize);
std::vector<H5::DSetCreatPropList> plistPara(paraSize);
// hyperslab (files)
int numFiles = numImagesCaught / maxFramesPerFile;
@ -286,24 +283,17 @@ std::array<std::string, 2> CreateVirtualHDF5File(
p + 1, srcFileName.length() - p));
}
// source dataset name
std::ostringstream osfn;
osfn << "/data";
if (numImages > 1)
osfn << "_f" << std::setfill('0') << std::setw(12) << iFile;
std::string srcDatasetName = osfn.str();
// source dataspace
hsize_t srcDims[3] = {nDimx, nDimy, nDimz};
hsize_t srcDimsMax[3] = {H5S_UNLIMITED, nDimy, nDimz};
DataSpace srcDataSpace(3, srcDims, srcDimsMax);
H5::DataSpace srcDataSpace(3, srcDims, srcDimsMax);
hsize_t srcDimsPara[1] = {nDimx};
hsize_t srcDimsMaxPara[1] = {H5S_UNLIMITED};
DataSpace srcDataSpacePara(1, srcDimsPara, srcDimsMaxPara);
H5::DataSpace srcDataSpacePara(1, srcDimsPara, srcDimsMaxPara);
// mapping of property list
plist.setVirtual(vdsDataSpace, relative_srcFileName.c_str(),
srcDatasetName.c_str(), srcDataSpace);
DATASET_NAME, srcDataSpace);
for (unsigned int p = 0; p < paraSize; ++p) {
plistPara[p].setVirtual(
vdsDataSpacePara, relative_srcFileName.c_str(),
@ -325,17 +315,17 @@ std::array<std::string, 2> CreateVirtualHDF5File(
framesSaved += nDimx;
}
// datasets
DataSet vdsDataSet(fd->createDataSet(dataSetName.c_str(), dataType,
H5::DataSet vdsDataSet(fd->createDataSet(DATASET_NAME, dataType,
vdsDataSpace, plist));
for (unsigned int p = 0; p < paraSize; ++p) {
DataSet vdsDataSetPara(fd->createDataSet(
H5::DataSet vdsDataSetPara(fd->createDataSet(
parameterNames[p].c_str(), parameterDataTypes[p],
vdsDataSpacePara, plistPara[p]));
}
fd->close();
} catch (const Exception &error) {
} catch (const H5::Exception &error) {
error.printErrorStack();
if (fd) {
fd->close();
@ -346,7 +336,7 @@ std::array<std::string, 2> CreateVirtualHDF5File(
if (!silentMode) {
LOG(logINFO) << "Virtual File: " << fileName;
}
return std::array<std::string, 2>{fileName, dataSetName};
return fileName;
}
#endif

View File

@ -4,17 +4,13 @@
#include "MasterAttributes.h"
#include <mutex>
namespace sls {
namespace masterFileUtility {
#ifdef HDF5C
#include "H5Cpp.h"
#include <mutex>
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
#endif
std::string CreateMasterBinaryFile(const std::string &filePath,
@ -25,10 +21,9 @@ std::string CreateMasterBinaryFile(const std::string &filePath,
MasterAttributes *attr);
#ifdef HDF5C
void LinkHDF5FileInMaster(const std::string &masterFileName,
const std::string &dataFilename,
const std::string &dataSetname,
const std::vector<std::string> parameterNames,
void LinkHDF5FileInMaster(std::string &masterFileName,
std::string &dataFilename,
std::vector<std::string> parameterNames,
const bool silentMode, std::mutex *hdf5LibMutex);
std::string CreateMasterHDF5File(const std::string &filePath,
@ -38,16 +33,16 @@ std::string CreateMasterHDF5File(const std::string &filePath,
const bool silentMode, MasterAttributes *attr,
std::mutex *hdf5LibMutex);
std::array<std::string, 2> CreateVirtualHDF5File(
std::string CreateVirtualHDF5File(
const std::string &filePath, const std::string &fileNamePrefix,
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
const int modulePos, const int numUnitsPerReadout,
const uint32_t maxFramesPerFile, const uint64_t numImages,
const uint32_t maxFramesPerFile,
const uint32_t nPixelsX, const uint32_t nPixelsY,
const uint32_t dynamicRange, const uint64_t numImagesCaught,
const int numModX, const int numModY, const DataType dataType,
const int numModX, const int numModY, const H5::DataType dataType,
const std::vector<std::string> parameterNames,
const std::vector<DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
const std::vector<H5::DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
bool gotthard25um);
#endif
} // namespace masterFileUtility

View File

@ -37,7 +37,7 @@ namespace sls {
#define FILE_BUFFER_SIZE (16 * 1024 * 1024) // 16mb
// fifo
#define FIFO_HEADER_NUMBYTES (8)
#define FIFO_HEADER_NUMBYTES (16)
#define FIFO_DATASIZE_NUMBYTES (4)
#define FIFO_PADDING_NUMBYTES \
(4) // for 8 byte alignment due to sls_receiver_header structure
@ -59,4 +59,7 @@ namespace sls {
#define TCP_PRIORITY (10)
#ifdef HDF5C
#define DATASET_NAME "/data"
#endif
} // namespace sls

View File

@ -20,6 +20,7 @@
// C++ includes
#include "sls/sls_detector_exceptions.h"
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <cstdint>
@ -69,6 +70,8 @@
#define SHORT_STR_LENGTH 20
#define MAX_PATTERN_LENGTH 0x2000
#define MAX_PATTERN_LEVELS 6
#define M3_MAX_PATTERN_LEVELS 3
#define DEFAULT_STREAMING_TIMER_IN_MS 500

View File

@ -2,13 +2,13 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */
#define GITBRANCH "developer"
#define APILIB 0x220408
#define APIRECEIVER 0x220408
#define APIGUI 0x220328
#define APICTB 0x220524
#define APIGOTTHARD 0x220524
#define APIJUNGFRAU 0x220524
#define APIMOENCH 0x220519
#define APIEIGER 0x220524
#define APIGOTTHARD2 0x220602
#define APIMYTHEN3 0x220607
#define APILIB 0x220609
#define APIRECEIVER 0x220609
#define APIGUI 0x220609
#define APICTB 0x220714
#define APIGOTTHARD 0x220714
#define APIGOTTHARD2 0x220714
#define APIJUNGFRAU 0x220714
#define APIMYTHEN3 0x220714
#define APIMOENCH 0x220714
#define APIEIGER 0x220714

2
updateSubmodule.sh Normal file
View File

@ -0,0 +1,2 @@
git submodule update --init