Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
bergamaschi 2022-07-14 12:19:45 +02:00
commit 26cbfbdb30
47 changed files with 1175 additions and 743 deletions

130
cmk.sh
View File

@ -18,6 +18,7 @@ CTBGUI=0
MANUALS=0 MANUALS=0
MANUALS_ONLY_RST=0 MANUALS_ONLY_RST=0
MOENCHZMQ=0 MOENCHZMQ=0
ZMQ_HINT_DIR=""
CLEAN=0 CLEAN=0
@ -26,25 +27,26 @@ CMAKE_PRE=""
CMAKE_POST="" CMAKE_POST=""
usage() { echo -e " 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 -[no option]: only make
-c: Clean
-b: Builds/Rebuilds CMake files normal mode -b: Builds/Rebuilds CMake files normal mode
-p: Builds/Rebuilds Python API -c: Clean
-h: Builds/Rebuilds Cmake files with HDF5 package
-d: HDF5 Custom Directory -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 -k: CMake command
-l: Install directory -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 -m: Manuals
-n: Manuals without compiling doxygen (only rst) -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 -z: Moench zmq processor
Rebuild when you switch to a new build and compile in parallel: Rebuild when you switch to a new build and compile in parallel:
@ -81,69 +83,50 @@ For rebuilding only certain sections
" ; exit 1; } " ; exit 1; }
while getopts ":bpchd:k:l:j:trgeisumnz" opt ; do while getopts ":bcd:eghij:k:l:mnpq:rstuz" opt ; do
case $opt in case $opt in
b) b)
echo "Building of CMake files Required" echo "Building of CMake files Required"
REBUILD=1 REBUILD=1
;; ;;
p)
echo "Compiling Options: Python"
PYTHON=1
REBUILD=1
;;
c) c)
echo "Clean Required" echo "Clean Required"
CLEAN=1 CLEAN=1
;; ;;
h)
echo "Building of CMake files with HDF5 option Required"
HDF5=1
REBUILD=1
;;
d) d)
echo "New HDF5 directory: $OPTARG" echo "New HDF5 directory: $OPTARG"
HDF5DIR=$OPTARG HDF5DIR=$OPTARG
;; ;;
l) e)
echo "CMake install directory: $OPTARG" echo "Compiling Options: Debug"
INSTALLDIR="$OPTARG" 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) k)
echo "CMake command: $OPTARG" echo "CMake command: $OPTARG"
CMAKE="$OPTARG" CMAKE="$OPTARG"
;; ;;
j) l)
echo "Number of compiler threads: $OPTARG" echo "CMake install directory: $OPTARG"
COMPILERTHREADS=$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) m)
echo "Compiling Manuals" echo "Compiling Manuals"
MANUALS=1 MANUALS=1
@ -152,14 +135,37 @@ while getopts ":bpchd:k:l:j:trgeisumnz" opt ; do
echo "Compiling Manuals (Only RST)" echo "Compiling Manuals (Only RST)"
MANUALS_ONLY_RST=1 MANUALS_ONLY_RST=1
;; ;;
z) p)
echo "Compiling Moench Zmq Processor" echo "Compiling Options: Python"
MOENCHZMQ=1 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) u)
echo "Compiling Options: Chip Test Gui" echo "Compiling Options: Chip Test Gui"
CTBGUI=1 CTBGUI=1
;; ;;
z)
echo "Compiling Moench Zmq Processor"
MOENCHZMQ=1
;;
\?) \?)
echo "Invalid option: -$OPTARG" echo "Invalid option: -$OPTARG"
usage usage
@ -254,6 +260,12 @@ if [ $TESTS -eq 1 ]; then
echo "Tests Option enabled" echo "Tests Option enabled"
fi 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 #hdf5 rebuild
if [ $HDF5 -eq 1 ]; then 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("dynamic",Form("((ctbAcquisition*)%p)->canvasClicked()",this));
// myCanvas->AddExec("ex","canvasClicked()"); // 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 // return
((ctbAcquisition*)pArgs)->plotData(data,index); ((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 namespace sls
{ {
class Detector; class Detector;
class detectorData;
}; };
class detectorData;
template <class dataType> class slsDetectorData; template <class dataType> class slsDetectorData;
@ -201,10 +201,10 @@ class ctbAcquisition : public TGGroupFrame {
void setBitGraph (int i ,int en, Pixel_t col); void setBitGraph (int i ,int en, Pixel_t col);
void startAcquisition(); void startAcquisition();
static void progressCallback(double,void*); 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 StopFlag;
int plotData(detectorData*, int); int plotData(sls::detectorData*, int);
void setPatternFile(const char* t); void setPatternFile(const char* t);

View File

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

View File

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

View File

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

View File

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

View File

@ -17,8 +17,9 @@ import _slsdet
xy = _slsdet.xy xy = _slsdet.xy
defs = _slsdet.slsDetectorDefs defs = _slsdet.slsDetectorDefs
#Make enums and #defines available at top level
from .enums import * from .enums import *
from .defines import *
IpAddr = _slsdet.IpAddr IpAddr = _slsdet.IpAddr
MacAddr = _slsdet.MacAddr 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 .utils import Geometry, to_geo, element, reduce_time, is_iterable
from _slsdet import xy from _slsdet import xy
from . import utils as ut 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 from .registers import Register, Adc_register
import datetime as dt import datetime as dt
@ -3098,6 +3098,24 @@ class Detector(CppDetectorApi):
def patmask(self, mask): def patmask(self, mask):
ut.set_using_dict(self.setPatternMask, 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 @property
@element @element
def patwait0(self): def patwait0(self):
@ -3158,6 +3176,23 @@ class Detector(CppDetectorApi):
addr = ut.merge_args(2, addr) addr = ut.merge_args(2, addr)
ut.set_using_dict(self.setPatternWaitAddr, *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 @property
@element @element
def patwaittime0(self): def patwaittime0(self):
@ -3192,6 +3227,23 @@ class Detector(CppDetectorApi):
ut.set_using_dict(self.setPatternWaitTime, *nclk) 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 @property
@element @element
def patloop0(self): def patloop0(self):
@ -3254,6 +3306,24 @@ class Detector(CppDetectorApi):
addr = ut.merge_args(2, addr) addr = ut.merge_args(2, addr)
ut.set_using_dict(self.setPatternLoopAddresses, *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 @property
@element @element
def patnloop0(self): def patnloop0(self):

View File

@ -2,14 +2,24 @@
# Copyright (C) 2021 Contributors to the SLS Detector Package # Copyright (C) 2021 Contributors to the SLS Detector Package
from .utils import element_if_equal from .utils import element_if_equal
from .enums import dacIndex 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()): if isinstance(value, dict) and all(isinstance(k, int) for k in value.keys()):
for dkey, dvalue in value.items(): if unpack:
func(key, dvalue, [dkey]) for dkey, dvalue in value.items():
func(key, *dvalue, [dkey])
else:
for dkey, dvalue in value.items():
func(key, dvalue, [dkey])
else: else:
func(key, value) if unpack:
func(key, *value)
else:
func(key, value)
class JsonProxy: class JsonProxy:
""" """
@ -127,4 +137,118 @@ class ClkFreqProxy:
else: else:
rstr += f'{i}: {r}\n' 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; using pat = sls::patternParameters;
py::class_<pat> patternParameters(m, "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); waittime);
patternParameters.def(py::init()); patternParameters.def(py::init());

View File

@ -568,6 +568,72 @@
#define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT) #define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT)
#define PATTERN_SET_MSB_REG (0x83 << 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 */ /** I2C Control register */
#define I2C_TRANSFER_COMMAND_FIFO_REG (0x100 << MEM_MAP_SHIFT) #define I2C_TRANSFER_COMMAND_FIFO_REG (0x100 << MEM_MAP_SHIFT)
#define I2C_RX_DATA_FIFO_REG (0x101 << 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" #include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x181130 #define MIN_REQRD_VRSN_T_RD_API 0x181130
#define REQRD_FRMWR_VRSN 0x201005 #define REQRD_FRMWR_VRSN 0x220714
#define LINKED_SERVER_NAME "ctbDetectorServer" #define LINKED_SERVER_NAME "ctbDetectorServer"

View File

@ -274,15 +274,28 @@ patword 0x0110 0x0008599f0008503a
patword 0x0111 0x0008599f0008503a patword 0x0111 0x0008599f0008503a
patioctrl 0x8f0effff6dbffdbf patioctrl 0x8f0effff6dbffdbf
patlimits 0x0000 0x0110 patlimits 0x0000 0x0110
patloop0 0x00be 0x00ef patloop 0 0x00be 0x00ef
patnloop0 199 patnloop 0 199
patloop1 0x0400 0x0400 patloop 1 0x0400 0x0400
patnloop1 0 patnloop 1 0
patloop2 0x0400 0x0400 patloop 2 0x0400 0x0400
patnloop2 0 patnloop 2 0
patwait0 0x002e patwait 0 0x002e
patwaittime0 800 patwaittime 0 800
patwait1 0x0400 patwait 1 0x0400
patwaittime1 0 patwaittime 1 0
patwait2 0x0400 patwait 2 0x0400
patwaittime2 0 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_LSB_REG (0x82 << MEM_MAP_SHIFT)
#define PATTERN_SET_MSB_REG (0x83 << 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 */ /* Round Robin */
#define RXR_ENDPOINT_START_REG (0x1000 << MEM_MAP_SHIFT) #define RXR_ENDPOINT_START_REG (0x1000 << MEM_MAP_SHIFT)

View File

@ -274,15 +274,28 @@ patword 0x0110 0x0008599f0008503a
patword 0x0111 0x0008599f0008503a patword 0x0111 0x0008599f0008503a
patioctrl 0x8f0effff6dbffdbf patioctrl 0x8f0effff6dbffdbf
patlimits 0x0000 0x0110 patlimits 0x0000 0x0110
patloop0 0x00be 0x00ef patloop 0 0x00be 0x00ef
patnloop0 199 patnloop 0 199
patloop1 0x0400 0x0400 patloop 1 0x0400 0x0400
patnloop1 0 patnloop 1 0
patloop2 0x0400 0x0400 patloop 2 0x0400 0x0400
patnloop2 0 patnloop 2 0
patwait0 0x002e patwait 0 0x002e
patwaittime0 800 patwaittime 0 800
patwait1 0x0400 patwait 1 0x0400
patwaittime1 0 patwaittime 1 0
patwait2 0x0400 patwait 2 0x0400
patwaittime2 0 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" #include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x180314 #define MIN_REQRD_VRSN_T_RD_API 0x180314
#define REQRD_FRMWR_VRSN 0x201005 #define REQRD_FRMWR_VRSN 0x220714
#define LINKED_SERVER_NAME "moenchDetectorServer" #define LINKED_SERVER_NAME "moenchDetectorServer"

View File

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

View File

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

View File

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

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 get64BitReg(int aLSB, int aMSB);
extern int64_t set64BitReg(int64_t value, 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) #if defined(CHIPTESTBOARDD) || defined(MOENCHD)
#ifdef VIRTUAL #ifdef VIRTUAL
void initializePatternWord() { void initializePatternWord() {
@ -157,9 +163,9 @@ void writePatternWord(int addr, uint64_t word) {
int validate_getPatternWaitAddresses(char *message, int level, int *addr) { int validate_getPatternWaitAddresses(char *message, int level, int *addr) {
// validate input // validate input
if (level < 0 || level > 2) { if (level < 0 || level >= MAX_LEVELS) {
sprintf(message, 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)); LOG(logERROR, (message));
return FAIL; return FAIL;
} }
@ -178,6 +184,17 @@ int getPatternWaitAddress(int level) {
case 2: case 2:
return ((bus_r(PATTERN_WAIT_2_ADDR_REG) & PATTERN_WAIT_2_ADDR_MSK) >> return ((bus_r(PATTERN_WAIT_2_ADDR_REG) & PATTERN_WAIT_2_ADDR_MSK) >>
PATTERN_WAIT_2_ADDR_OFST); 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: default:
return -1; return -1;
} }
@ -185,9 +202,9 @@ int getPatternWaitAddress(int level) {
int validate_setPatternWaitAddresses(char *message, int level, int addr) { int validate_setPatternWaitAddresses(char *message, int level, int addr) {
// validate input // validate input
if (level < 0 || level > 2) { if (level < 0 || level >= MAX_LEVELS) {
sprintf(message, 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)); LOG(logERROR, (message));
return FAIL; return FAIL;
} }
@ -234,6 +251,20 @@ void setPatternWaitAddress(int level, int addr) {
bus_w(PATTERN_WAIT_2_ADDR_REG, bus_w(PATTERN_WAIT_2_ADDR_REG,
((addr << PATTERN_WAIT_2_ADDR_OFST) & PATTERN_WAIT_2_ADDR_MSK)); ((addr << PATTERN_WAIT_2_ADDR_OFST) & PATTERN_WAIT_2_ADDR_MSK));
break; 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: default:
return; return;
} }
@ -241,9 +272,9 @@ void setPatternWaitAddress(int level, int addr) {
int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime) { int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime) {
// validate input // validate input
if (level < 0 || level > 2) { if (level < 0 || level >= MAX_LEVELS) {
sprintf(message, 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)); LOG(logERROR, (message));
return FAIL; return FAIL;
} }
@ -262,6 +293,17 @@ uint64_t getPatternWaitTime(int level) {
case 2: case 2:
return get64BitReg(PATTERN_WAIT_TIMER_2_LSB_REG, return get64BitReg(PATTERN_WAIT_TIMER_2_LSB_REG,
PATTERN_WAIT_TIMER_2_MSB_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: default:
return -1; return -1;
} }
@ -269,9 +311,9 @@ uint64_t getPatternWaitTime(int level) {
int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) { int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) {
// validate input // validate input
if (level < 0 || level > 2) { if (level < 0 || level >= MAX_LEVELS) {
sprintf(message, 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)); LOG(logERROR, (message));
return FAIL; return FAIL;
} }
@ -311,6 +353,20 @@ void setPatternWaitTime(int level, uint64_t t) {
set64BitReg(t, PATTERN_WAIT_TIMER_2_LSB_REG, set64BitReg(t, PATTERN_WAIT_TIMER_2_LSB_REG,
PATTERN_WAIT_TIMER_2_MSB_REG); PATTERN_WAIT_TIMER_2_MSB_REG);
break; 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: default:
return; return;
} }
@ -318,9 +374,9 @@ void setPatternWaitTime(int level, uint64_t t) {
int validate_getPatternLoopCycles(char *message, int level, int *numLoops) { int validate_getPatternLoopCycles(char *message, int level, int *numLoops) {
// validate input // validate input
if (level < 0 || level > 2) { if (level < 0 || level >= MAX_LEVELS) {
sprintf(message, 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)); LOG(logERROR, (message));
return FAIL; return FAIL;
} }
@ -336,6 +392,14 @@ int getPatternLoopCycles(int level) {
return bus_r(PATTERN_LOOP_1_ITERATION_REG); return bus_r(PATTERN_LOOP_1_ITERATION_REG);
case 2: case 2:
return bus_r(PATTERN_LOOP_2_ITERATION_REG); 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: default:
return -1; return -1;
} }
@ -343,9 +407,9 @@ int getPatternLoopCycles(int level) {
int validate_setPatternLoopCycles(char *message, int level, int numLoops) { int validate_setPatternLoopCycles(char *message, int level, int numLoops) {
// validate input // validate input
if (level < 0 || level > 2) { if (level < 0 || level >= MAX_LEVELS) {
sprintf(message, 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)); LOG(logERROR, (message));
return FAIL; return FAIL;
} }
@ -385,6 +449,17 @@ void setPatternLoopCycles(int level, int nLoop) {
case 2: case 2:
bus_w(PATTERN_LOOP_2_ITERATION_REG, nLoop); bus_w(PATTERN_LOOP_2_ITERATION_REG, nLoop);
break; 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: default:
return; return;
} }
@ -443,10 +518,10 @@ void setPatternLoopLimits(int startAddr, int stopAddr) {
int validate_getPatternLoopAddresses(char *message, int level, int *startAddr, int validate_getPatternLoopAddresses(char *message, int level, int *startAddr,
int *stopAddr) { int *stopAddr) {
// validate input // validate input
if (level < 0 || level > 2) { if (level < 0 || level >= MAX_LEVELS) {
sprintf( sprintf(
message, 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)); LOG(logERROR, (message));
return FAIL; 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) >> ((bus_r(PATTERN_LOOP_2_ADDR_REG) & PATTERN_LOOP_2_ADDR_STP_MSK) >>
PATTERN_LOOP_2_ADDR_STP_OFST); PATTERN_LOOP_2_ADDR_STP_OFST);
break; 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: default:
return; return;
} }
@ -489,10 +590,10 @@ void getPatternLoopAddresses(int level, int *startAddr, int *stopAddr) {
int validate_setPatternLoopAddresses(char *message, int level, int startAddr, int validate_setPatternLoopAddresses(char *message, int level, int startAddr,
int stopAddr) { int stopAddr) {
// validate input // validate input
if (level < 0 || level > 2) { if (level < 0 || level >= MAX_LEVELS) {
sprintf( sprintf(
message, 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)); LOG(logERROR, (message));
return FAIL; return FAIL;
} }
@ -559,6 +660,29 @@ void setPatternLoopAddresses(int level, int startAddr, int stopAddr) {
((stopAddr << PATTERN_LOOP_2_ADDR_STP_OFST) & ((stopAddr << PATTERN_LOOP_2_ADDR_STP_OFST) &
PATTERN_LOOP_2_ADDR_STP_MSK)); PATTERN_LOOP_2_ADDR_STP_MSK));
break; 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: default:
return; return;
} }
@ -625,10 +749,10 @@ int loadPattern(char *message, enum TLogLevel printLevel,
} }
if (ret == OK) { if (ret == OK) {
for (int i = 0; i <= 2; ++i) { for (int i = 0; i < MAX_LEVELS; ++i) {
// loop addr // loop addr
ret = validate_setPatternLoopAddresses( 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) { if (ret == FAIL) {
break; break;
} }
@ -685,15 +809,15 @@ int getPattern(char *message, patternParameters *pat) {
pat->limits[1] = retval2; pat->limits[1] = retval2;
} }
if (ret == OK) { if (ret == OK) {
for (int i = 0; i <= 2; ++i) { for (int i = 0; i < MAX_LEVELS; ++i) {
// loop addr // loop addr
ret = validate_getPatternLoopAddresses(message, i, &retval1, ret = validate_getPatternLoopAddresses(message, i, &retval1,
&retval2); &retval2);
if (ret == FAIL) { if (ret == FAIL) {
break; break;
} }
pat->loop[i * 2 + 0] = retval1; pat->startloop[i] = retval1;
pat->loop[i * 2 + 1] = retval2; pat->stoploop[i] = retval2;
// num loops // num loops
ret = validate_getPatternLoopCycles(message, i, &retval1); ret = validate_getPatternLoopCycles(message, i, &retval1);
@ -846,26 +970,14 @@ int loadPatternFile(char *patFname, char *errMessage) {
} }
// patloop // patloop
if ((!strncmp(line, "patloop0", strlen("patloop0"))) || if (!strncmp(line, "patloop", strlen("patloop"))){
(!strncmp(line, "patloop1", strlen("patloop1"))) ||
(!strncmp(line, "patloop2", strlen("patloop2")))) {
// level
int level = -1; 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 startAddr = 0;
int stopAddr = 0; int stopAddr = 0;
// cannot scan values // cannot scan values
if (sscanf(line, "%s 0x%x 0x%x", command, &startAddr, &stopAddr) != if (sscanf(line, "%s %d 0x%x 0x%x", command, &level, &startAddr, &stopAddr) !=
3) { 4) {
sprintf(temp, "Could not scan patloop%d arguments.\n", level); strcpy(temp, "Could not scan patloop arguments.\n");
break; break;
} }
@ -876,24 +988,12 @@ int loadPatternFile(char *patFname, char *errMessage) {
} }
// patnloop // patnloop
if ((!strncmp(line, "patnloop0", strlen("patnloop0"))) || if (!strncmp(line, "patnloop", strlen("patnloop"))) {
(!strncmp(line, "patnloop1", strlen("patnloop1"))) ||
(!strncmp(line, "patnloop2", strlen("patnloop2")))) {
// level
int level = -1; 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; int numLoops = -1;
// cannot scan values // cannot scan values
if (sscanf(line, "%s %d", command, &numLoops) != 2) { if (sscanf(line, "%s %d %d", command, &level, &numLoops) != 3) {
sprintf(temp, "Could not scan patnloop %d arguments.\n", level); strcpy(temp, "Could not scan patnloop arguments.\n");
break; break;
} }
@ -903,24 +1003,12 @@ int loadPatternFile(char *patFname, char *errMessage) {
} }
// patwait // patwait
if ((!strncmp(line, "patwait0", strlen("patwait0"))) || if (!strncmp(line, "patwait ", strlen("patwait "))) {
(!strncmp(line, "patwait1", strlen("patwait1"))) ||
(!strncmp(line, "patwait2", strlen("patwait2")))) {
// level
int level = -1; 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; int addr = 0;
// cannot scan values // cannot scan values
if (sscanf(line, "%s 0x%x", command, &addr) != 2) { if (sscanf(line, "%s %d 0x%x", command, &level, &addr) != 3) {
sprintf(temp, "Could not scan patwait%d arguments.\n", level); strcpy(temp, "Could not scan patwait arguments.\n");
break; break;
} }
@ -930,27 +1018,15 @@ int loadPatternFile(char *patFname, char *errMessage) {
} }
// patwaittime // patwaittime
if ((!strncmp(line, "patwaittime0", strlen("patwaittime0"))) || if (!strncmp(line, "patwaittime", strlen("patwaittime"))) {
(!strncmp(line, "patwaittime1", strlen("patwaittime1"))) ||
(!strncmp(line, "patwaittime2", strlen("patwaittime2")))) {
// level
int level = -1; 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; uint64_t waittime = 0;
// cannot scan values // cannot scan values
#ifdef VIRTUAL #ifdef VIRTUAL
if (sscanf(line, "%s %ld", command, &waittime) != 2) { if (sscanf(line, "%s %d %ld", command, &level, &waittime) != 3) {
#else #else
if (sscanf(line, "%s %lld", command, &waittime) != 2) { if (sscanf(line, "%s %d %lld", command, &level, &waittime) != 3) {
#endif #endif
sprintf(temp, "Could not scan patwaittime%d arguments.\n", sprintf(temp, "Could not scan patwaittime%d arguments.\n",
level); level);

View File

@ -9249,8 +9249,25 @@ int clear_all_udp_dst(int file_des) {
if (check_detector_idle("clear all udp destinations") == OK) { if (check_detector_idle("clear all udp destinations") == OK) {
memset(udpDetails, 0, sizeof(udpDetails)); memset(udpDetails, 0, sizeof(udpDetails));
// minimum 1 destination in fpga // minimum 1 destination in fpga
numUdpDestinations = 1; int numdest = 1;
configure_mac(); // 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); 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 word[MAX_PATTERN_LENGTH];
uint64_t ioctrl; uint64_t ioctrl;
uint32_t limits[2]; uint32_t limits[2];
// loop0 start, loop0 stop .. loop2 start, loop2 stop uint32_t startloop[MAX_PATTERN_LEVELS];
uint32_t loop[6]; uint32_t stoploop[MAX_PATTERN_LEVELS];
uint32_t nloop[3]; uint32_t nloop[MAX_PATTERN_LEVELS];
uint32_t wait[3]; uint32_t wait[MAX_PATTERN_LEVELS];
uint64_t waittime[3]; uint64_t waittime[MAX_PATTERN_LEVELS];
} patternParameters; } patternParameters;
#ifdef __cplusplus #ifdef __cplusplus

View File

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

View File

@ -2705,7 +2705,30 @@ std::string CmdProxy::PatternWord(int action) {
return os.str(); 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) { 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; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
@ -2713,53 +2736,30 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits " os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
"of complete pattern." "of complete pattern."
<< '\n'; << '\n';
} else if (cmd == "patloop0") { } else if (cmd == "patloop") {
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits " os << "[0-6] [start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of the loop level provided."
"of loop 0." << "\n\t[Mythen3] Level options: 0-3 only."
<< '\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."
<< '\n'; << '\n';
} else { } else {
throw RuntimeError( os << "Depreciated command. Use patloop."
"Unknown command, use list to list all commands"); << '\n';
} }
} else { } else {
int level = -1; int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
if (cmd == "patlimits") { if (cmd != "patlimits") {
level = -1; GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, nPutArgs);
} 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");
} }
if (action == defs::GET_ACTION) { if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = auto t =
det->getPatternLoopAddresses(level, std::vector<int>{det_id}); det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n'; os << OutStringHex(t, 4) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (args.size() != 2) { int start = StringTo<int>(args[iArg++]);
WrongNumberOfParameters(2); int stop = StringTo<int>(args[iArg++]);
}
int start = StringTo<int>(args[0]);
int stop = StringTo<int>(args[1]);
det->setPatternLoopAddresses(level, start, stop, det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id}); std::vector<int>{det_id});
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4) os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
<< "]\n"; << "]\n";
} else { } else {
throw RuntimeError("Unknown action"); throw RuntimeError("Unknown action");
} }
@ -2768,50 +2768,32 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
} }
std::string CmdProxy::PatternLoopCycles(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; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
if (cmd == "patnloop0") { if (cmd == "patnloop") {
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of " os << "[0-6] [n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
"loop 0." "the loop level provided."
<< '\n'; << "\n\t[Mythen3] Level options: 0-3 only."
} 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."
<< '\n'; << '\n';
} else { } else {
throw RuntimeError( os << "Depreciated command. Use patnloop."
"Unknown command, use list to list all commands"); << '\n';
} }
} else { } else {
int level = -1; int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
if (cmd == "patnloop0") { GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, nPutArgs);
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");
}
if (action == defs::GET_ACTION) { if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id}); auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << OutString(t) << '\n'; os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (args.size() != 1) { int nloops = StringTo<int>(args[iArg++]);
WrongNumberOfParameters(1); det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
} os << nloops << '\n';
det->setPatternLoopCycles(level, StringTo<int>(args[0]),
std::vector<int>{det_id});
os << args.front() << '\n';
} else { } else {
throw RuntimeError("Unknown action"); throw RuntimeError("Unknown action");
} }
@ -2820,42 +2802,28 @@ std::string CmdProxy::PatternLoopCycles(int action) {
} }
std::string CmdProxy::PatternWaitAddress(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; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
if (cmd == "patwait0") { if (cmd == "patwait") {
os << "[addr] \n\t[Ctb][Moench][Mythen3] Wait 0 address." << '\n'; os << "[0-6] [addr] \n\t[Ctb][Moench][Mythen3] Wait address for loop level provided."
} else if (cmd == "patwait1") { << "\n\t[Mythen3] Level options: 0-3 only.";
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';
} else { } else {
throw RuntimeError( os << "Depreciated command. Use patwait.";
"Unknown command, use list to list all commands");
} }
os << '\n';
} else { } else {
int level = -1; int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
if (cmd == "patwait0") { GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, nPutArgs);
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");
}
if (action == defs::GET_ACTION) { if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id}); auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n'; os << OutStringHex(t, 4) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (args.size() != 1) { int addr = StringTo<int>(args[iArg++]);
WrongNumberOfParameters(1);
}
int addr = StringTo<int>(args[0]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id}); det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << ToStringHex(addr, 4) << '\n'; os << ToStringHex(addr, 4) << '\n';
} else { } else {
@ -2866,50 +2834,32 @@ std::string CmdProxy::PatternWaitAddress(int action) {
} }
std::string CmdProxy::PatternWaitTime(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; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
if (cmd == "patwaittime0") { if (cmd == "patwaittime") {
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 0 time in clock " os << "[0-6] [n_clk] \n\t[Ctb][Moench][Mythen3] Wait time in clock "
"cycles." "cycles for the loop provided."
<< '\n'; << "\n\t[Mythen3] Level options: 0-3 only."
} 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."
<< '\n'; << '\n';
} else { } else {
throw RuntimeError( os << "Depreciated command. Use patwaittime."
"Unknown command, use list to list all commands"); << '\n';
} }
} else { } else {
int level = -1; int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
if (cmd == "patwaittime0") { GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs, nPutArgs);
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");
}
if (action == defs::GET_ACTION) { if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id}); auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
os << OutString(t) << '\n'; os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (args.size() != 1) { uint64_t waittime = StringTo<uint64_t>(args[iArg++]);
WrongNumberOfParameters(1); det->setPatternWaitTime(level, waittime, {det_id});
} os << waittime << '\n';
det->setPatternWaitTime(level, StringTo<uint64_t>(args[0]),
{det_id});
os << args.front() << '\n';
} else { } else {
throw RuntimeError("Unknown action"); throw RuntimeError("Unknown action");
} }

View File

@ -1049,15 +1049,19 @@ class CmdProxy {
{"patioctrl", &CmdProxy::patioctrl}, {"patioctrl", &CmdProxy::patioctrl},
{"patword", &CmdProxy::PatternWord}, {"patword", &CmdProxy::PatternWord},
{"patlimits", &CmdProxy::PatternLoopAddresses}, {"patlimits", &CmdProxy::PatternLoopAddresses},
{"patloop", &CmdProxy::PatternLoopAddresses},
{"patloop0", &CmdProxy::PatternLoopAddresses}, {"patloop0", &CmdProxy::PatternLoopAddresses},
{"patloop1", &CmdProxy::PatternLoopAddresses}, {"patloop1", &CmdProxy::PatternLoopAddresses},
{"patloop2", &CmdProxy::PatternLoopAddresses}, {"patloop2", &CmdProxy::PatternLoopAddresses},
{"patnloop", &CmdProxy::PatternLoopCycles},
{"patnloop0", &CmdProxy::PatternLoopCycles}, {"patnloop0", &CmdProxy::PatternLoopCycles},
{"patnloop1", &CmdProxy::PatternLoopCycles}, {"patnloop1", &CmdProxy::PatternLoopCycles},
{"patnloop2", &CmdProxy::PatternLoopCycles}, {"patnloop2", &CmdProxy::PatternLoopCycles},
{"patwait", &CmdProxy::PatternWaitAddress},
{"patwait0", &CmdProxy::PatternWaitAddress}, {"patwait0", &CmdProxy::PatternWaitAddress},
{"patwait1", &CmdProxy::PatternWaitAddress}, {"patwait1", &CmdProxy::PatternWaitAddress},
{"patwait2", &CmdProxy::PatternWaitAddress}, {"patwait2", &CmdProxy::PatternWaitAddress},
{"patwaittime", &CmdProxy::PatternWaitTime},
{"patwaittime0", &CmdProxy::PatternWaitTime}, {"patwaittime0", &CmdProxy::PatternWaitTime},
{"patwaittime1", &CmdProxy::PatternWaitTime}, {"patwaittime1", &CmdProxy::PatternWaitTime},
{"patwaittime2", &CmdProxy::PatternWaitTime}, {"patwaittime2", &CmdProxy::PatternWaitTime},
@ -1192,6 +1196,7 @@ class CmdProxy {
/* Pattern */ /* Pattern */
std::string Pattern(int action); std::string Pattern(int action);
std::string PatternWord(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 PatternLoopAddresses(int action);
std::string PatternLoopCycles(int action); std::string PatternLoopCycles(int action);
std::string PatternWaitAddress(int action); std::string PatternWaitAddress(int action);

View File

@ -29,8 +29,12 @@ bool Pattern::operator==(const Pattern &other) const {
if (pat->limits[i] != other.pat->limits[i]) if (pat->limits[i] != other.pat->limits[i])
return false; return false;
} }
for (size_t i = 0; i < (sizeof(pat->loop) / sizeof(pat->loop[0])); ++i) { for (size_t i = 0; i < (sizeof(pat->startloop) / sizeof(pat->startloop[0])); ++i) {
if (pat->loop[i] != other.pat->loop[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; return false;
} }
for (size_t i = 0; i < (sizeof(pat->nloop) / sizeof(pat->nloop[0])); ++i) { 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[0]) + std::string(", ") +
ToString(pat->limits[1]) + std::string("]")); ToString(pat->limits[1]) + std::string("]"));
} }
for (int i = 0; i != 3; ++i) { for (int i = 0; i != MAX_PATTERN_LEVELS; ++i) {
if (pat->loop[i * 2 + 0] >= MAX_PATTERN_LENGTH || if (pat->startloop[i] >= MAX_PATTERN_LENGTH ||
pat->loop[i * 2 + 1] >= MAX_PATTERN_LENGTH) { pat->stoploop[i] >= MAX_PATTERN_LENGTH) {
throw RuntimeError( throw RuntimeError(
"Invalid Pattern loop address for level " + ToString(i) + "Invalid Pattern loop address for level " + ToString(i) +
std::string(" [") + ToString(pat->loop[i * 2 + 0]) + std::string(" [") + ToString(pat->startloop[i]) +
std::string(", ") + ToString(pat->loop[i * 2 + 1]) + std::string(", ") + ToString(pat->stoploop[i]) +
std::string("]")); std::string("]"));
} }
if (pat->wait[i] >= MAX_PATTERN_LENGTH) { 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[0] = StringTo<uint32_t>(args[1]);
pat->limits[1] = StringTo<uint32_t>(args[2]); pat->limits[1] = StringTo<uint32_t>(args[2]);
} else if (cmd == "patloop0" || cmd == "patloop1" || }
cmd == "patloop2") { else if (cmd == "patloop0" || cmd == "patloop1" ||
if (nargs != 2) { cmd == "patloop2" || cmd == "patloop") {
throw RuntimeError("Invalid arguments for " + int level = -1, iArg = 1;
ToString(args)); 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'; if (level < 0 || level >= MAX_PATTERN_LEVELS) {
int loop1 = StringTo<uint32_t>(args[1]); throw RuntimeError("Invalid Pattern level. Options 0-" + std::to_string(MAX_PATTERN_LEVELS - 1));
int loop2 = StringTo<uint32_t>(args[2]); }
pat->loop[level * 2 + 0] = loop1; int loop1 = StringTo<uint32_t>(args[iArg++]);
pat->loop[level * 2 + 1] = loop2; int loop2 = StringTo<uint32_t>(args[iArg++]);
pat->startloop[level] = loop1;
pat->stoploop[level] = loop2;
} else if (cmd == "patnloop0" || cmd == "patnloop1" || } else if (cmd == "patnloop0" || cmd == "patnloop1" ||
cmd == "patnloop2") { cmd == "patnloop2" || cmd == "patnloop") {
if (nargs != 1) { int level = -1, iArg = 1;
throw RuntimeError("Invalid arguments for " + if (cmd == "patnloop") {
ToString(args)); 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'; if (level < 0 || level >= MAX_PATTERN_LEVELS) {
pat->nloop[level] = StringTo<uint32_t>(args[1]); 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" || } else if (cmd == "patwait0" || cmd == "patwait1" ||
cmd == "patwait2") { cmd == "patwait2" || cmd == "patwait") {
if (nargs != 1) { int level = -1, iArg = 1;
throw RuntimeError("Invalid arguments for " + if (cmd == "patwait") {
ToString(args)); 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'; if (level < 0 || level >= MAX_PATTERN_LEVELS) {
pat->wait[level] = StringTo<uint32_t>(args[1]); 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" || } else if (cmd == "patwaittime0" || cmd == "patwaittime1" ||
cmd == "patwaittime2") { cmd == "patwaittime2" || cmd == "patwaittime") {
if (nargs != 1) { int level = -1, iArg = 1;
throw RuntimeError("Invalid arguments for " + if (cmd == "patwaittime") {
ToString(args)); 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'; if (level < 0 || level >= MAX_PATTERN_LEVELS) {
pat->waittime[level] = StringTo<uint64_t>(args[1]); throw RuntimeError("Invalid Pattern level. Options 0-" + std::to_string(MAX_PATTERN_LEVELS - 1));
}
pat->waittime[level] = StringTo<uint64_t>(args[iArg++]);
} else { } else {
throw RuntimeError("Unknown command in pattern file " + cmd); 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) << " " output_file << "patlimits " << ToStringHex(pat->limits[0], 4) << " "
<< ToStringHex(pat->limits[1], 4) << std::endl; << 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 // patloop
output_file << "patloop" << i << " " output_file << "patloop " << i << " "
<< ToStringHex(pat->loop[i * 2 + 0], 4) << " " << ToStringHex(pat->startloop[i], 4) << " "
<< ToStringHex(pat->loop[i * 2 + 1], 4) << std::endl; << ToStringHex(pat->stoploop[i], 4) << std::endl;
// patnloop // 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 // patwait
output_file << "patwait" << i << " " << ToStringHex(pat->wait[i], 4) output_file << "patwait " << i << " " << ToStringHex(pat->wait[i], 4)
<< std::endl; << std::endl;
// patwaittime // patwaittime
output_file << "patwaittime" << i << " " << pat->waittime[i] output_file << "patwaittime " << i << " " << pat->waittime[i]
<< std::endl; << std::endl;
} }
} }
@ -219,23 +276,17 @@ std::string Pattern::str() const {
} }
oss << "patioctrl " << ToStringHex(pat->ioctrl, word_width) << std::endl oss << "patioctrl " << ToStringHex(pat->ioctrl, word_width) << std::endl
<< "patlimits " << ToStringHex(pat->limits[0], addr_width) << " " << "patlimits " << ToStringHex(pat->limits[0], addr_width) << " "
<< ToStringHex(pat->limits[1], addr_width) << std::endl << ToStringHex(pat->limits[1], addr_width) << std::endl;
<< "patloop0 " << ToStringHex(pat->loop[0], addr_width) << " "
<< ToStringHex(pat->loop[1], addr_width) << std::endl for (int i = 0; i != MAX_PATTERN_LEVELS; ++i) {
<< "patnloop0 " << pat->nloop[0] << std::endl oss << "patloop " << i << ' ' << ToStringHex(pat->startloop[i], addr_width) << " "
<< "patloop1 " << ToStringHex(pat->loop[2], addr_width) << " " << ToStringHex(pat->stoploop[i], addr_width) << std::endl
<< ToStringHex(pat->loop[3], addr_width) << std::endl << "patnloop " << pat->nloop[i] << std::endl
<< "patnloop1 " << pat->nloop[1] << std::endl << "patwait " << i << ' ' << ToStringHex(pat->wait[i], addr_width) << std::endl
<< "patloop2 " << ToStringHex(pat->loop[4], addr_width) << " " << "patwaittime " << i << ' ' << pat->waittime[i] << std::endl;
<< ToStringHex(pat->loop[5], addr_width) << std::endl }
<< "patnloop2 " << pat->nloop[2] << std::endl
<< "patwait0 " << ToStringHex(pat->wait[0], addr_width) << std::endl oss << ']';
<< "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
<< ']';
return oss.str(); return oss.str();
} }

View File

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

View File

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

View File

@ -57,6 +57,7 @@ void DataProcessor::SetActivate(bool enable) { activated_ = enable; }
void DataProcessor::SetReceiverROI(ROI roi) { void DataProcessor::SetReceiverROI(ROI roi) {
receiverRoi_ = roi; receiverRoi_ = roi;
receiverRoiEnabled_ = receiverRoi_.completeRoi() ? false : true; receiverRoiEnabled_ = receiverRoi_.completeRoi() ? false : true;
receiverNoRoi_ = receiverRoi_.noRoi();
} }
void DataProcessor::ResetParametersforNewAcquisition() { void DataProcessor::ResetParametersforNewAcquisition() {
@ -125,8 +126,8 @@ void DataProcessor::CreateFirstFiles(
} }
CloseFiles(); CloseFiles();
// deactivated (half module/ single port), dont write file // deactivated (half module/ single port or no roi), dont write file
if (!activated_ || !detectorDataStream) { if (!activated_ || !detectorDataStream || receiverNoRoi_) {
return; return;
} }

View File

@ -156,6 +156,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
bool activated_{false}; bool activated_{false};
ROI receiverRoi_{}; ROI receiverRoi_{};
bool receiverRoiEnabled_{false}; bool receiverRoiEnabled_{false};
bool receiverNoRoi_{false};
std::unique_ptr<char[]> completeImageToStreamBeforeCropping; std::unique_ptr<char[]> completeImageToStreamBeforeCropping;
/** if 0, sending random images with a timer */ /** if 0, sending random images with a timer */
uint32_t *streamingFrequency_; uint32_t *streamingFrequency_;

View File

@ -440,6 +440,8 @@ void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
portRois[iPort] = portRoi; 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) for (size_t i = 0; i != dataProcessor.size(); ++i)
dataProcessor[i]->SetReceiverROI(portRois[i]); dataProcessor[i]->SetReceiverROI(portRois[i]);
LOG(logINFO) << "receiver roi: " << ToString(receiverRoi); LOG(logINFO) << "receiver roi: " << ToString(receiverRoi);
@ -721,7 +723,10 @@ void Implementation::stopReceiver() {
} else if (!detectorDataStream[i]) { } else if (!detectorDataStream[i]) {
summary = (i == 0 ? "\n\tDeactivated Left Port" summary = (i == 0 ? "\n\tDeactivated Left Port"
: "\n\tDeactivated Right 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; std::ostringstream os;
os << "\n\tMissing Packets\t\t: " << mpMessage os << "\n\tMissing Packets\t\t: " << mpMessage
<< "\n\tComplete Frames\t\t: " << nf << "\n\tComplete Frames\t\t: " << nf
@ -1002,6 +1007,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
&silentMode)); &silentMode));
listener[i]->SetGeneralData(generalData); listener[i]->SetGeneralData(generalData);
listener[i]->SetActivate(activated); listener[i]->SetActivate(activated);
listener[i]->SetNoRoi(portRois[i].noRoi());
int ctbAnalogDataBytes = 0; int ctbAnalogDataBytes = 0;
if (detType == CHIPTESTBOARD) { if (detType == CHIPTESTBOARD) {

View File

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

View File

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

View File

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

View File

@ -2,13 +2,13 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */ /** API versions */
#define GITBRANCH "developer" #define GITBRANCH "developer"
#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 APILIB 0x220609
#define APIRECEIVER 0x220609 #define APIRECEIVER 0x220609
#define APIGUI 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