ctb: patwaittime and exptime (#1076)

* cli: patwaittime also takes time argument, api: patwaitclocks and patwaitinterval, tcp: patwaitinterval is 2 functions for set and get, patwaitclocks remains a single for backward compatibility with -1 for get, server (loadpattern): clks using member names (needs to be refactored). needs tobe discussed what to do with pattern files.

* all tests passed

* fixed test 
* exptime deprecated for ctb and xilinx

* pyctbgui..not there yet

* fixed in pyctbgui

* removed redundant warning for ctb and xilinx exptime in Detector class (already in module class handling all exptime signatures), patwait, patloop and patnloop have to be non inferrable commands because of support for old commands (level as suffix)

* fix formatting error from command line parsing

* fix tests for patwaittime
This commit is contained in:
maliakal_d 2025-01-31 16:48:32 +01:00 committed by GitHub
parent e92578f89d
commit 315d49f8df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 1961 additions and 1352 deletions

View File

@ -10,6 +10,7 @@ from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as Navigatio
from pyctbgui.utils.defines import Defines
from pyctbgui.utils.plotPattern import PlotPattern
from slsdet import DurationWrapper
class PatternTab(QtWidgets.QWidget):
@ -61,7 +62,10 @@ class PatternTab(QtWidgets.QWidget):
getattr(self.view, f"lineEditLoop{i}Wait").editingFinished.connect(partial(self.setPatLoopWaitAddress, i))
getattr(self.view,
f"spinBoxLoop{i}Repetition").editingFinished.connect(partial(self.setPatLoopRepetition, i))
getattr(self.view, f"spinBoxLoop{i}WaitTime").editingFinished.connect(partial(self.setPatLoopWaitTime, i))
getattr(self.view, f"doubleSpinBoxLoop{i}WaitClocks").editingFinished.connect(partial(self.setPatLoopWaitClocks, i))
getattr(self.view, f"spinBoxLoop{i}WaitInterval").editingFinished.connect(partial(self.setPatLoopWaitInterval, i))
getattr(self.view, f"comboBoxLoop{i}WaitInterval").currentIndexChanged.connect(partial(self.setPatLoopWaitInterval, i))
self.view.toolButtonTogglePageWaitTime.clicked.connect(self.setTogglePageWaitTime)
self.view.pushButtonCompiler.clicked.connect(self.setCompiler)
self.view.pushButtonUncompiled.clicked.connect(self.setUncompiledPatternFile)
self.view.pushButtonPatternFile.clicked.connect(self.setPatternFile)
@ -91,7 +95,8 @@ class PatternTab(QtWidgets.QWidget):
self.getPatLoopStartStopAddress(i)
self.getPatLoopWaitAddress(i)
self.getPatLoopRepetition(i)
self.getPatLoopWaitTime(i)
self.getPatLoopWaitClocks(i)
self.getPatLoopWaitInterval(i)
# Pattern Tab functions
@ -182,17 +187,67 @@ class PatternTab(QtWidgets.QWidget):
self.det.patnloop[level] = spinBox.value()
self.getPatLoopRepetition(level)
def getPatLoopWaitTime(self, level):
def getPatLoopWaitClocks(self, level):
retval = self.det.patwaittime[level]
spinBox = getattr(self.view, f"spinBoxLoop{level}WaitTime")
spinBox = getattr(self.view, f"doubleSpinBoxLoop{level}WaitClocks")
spinBox.editingFinished.disconnect()
spinBox.setValue(retval)
spinBox.editingFinished.connect(partial(self.setPatLoopWaitTime, level))
spinBox.editingFinished.connect(partial(self.setPatLoopWaitClocks, level))
def setPatLoopWaitClocks(self, level):
spinBox = getattr(self.view, f"doubleSpinBoxLoop{level}WaitClocks")
self.det.patwaittime[level] = int(spinBox.value())
self.getPatLoopWaitClocks(level)
def getPatLoopWaitInterval(self, level):
retval = self.det.getPatternWaitInterval(level)[0].count()
spinBox = getattr(self.view, f"spinBoxLoop{level}WaitInterval")
comboBox = getattr(self.view, f"comboBoxLoop{level}WaitInterval")
spinBox.editingFinished.disconnect()
comboBox.currentIndexChanged.disconnect()
# Converting to right time unit for period
if retval >= 1e9:
comboBox.setCurrentIndex(0)
spinBox.setValue(retval / 1e9)
elif retval >= 1e6:
comboBox.setCurrentIndex(1)
spinBox.setValue(retval / 1e6)
elif retval >= 1e3:
comboBox.setCurrentIndex(2)
spinBox.setValue(retval / 1e3)
else:
comboBox.setCurrentIndex(3)
spinBox.setValue(retval)
spinBox.editingFinished.connect(partial(self.setPatLoopWaitInterval, level))
comboBox.currentIndexChanged.connect(partial(self.setPatLoopWaitInterval, level))
def setPatLoopWaitInterval(self, level):
spinBox = getattr(self.view, f"spinBoxLoop{level}WaitInterval")
comboBox = getattr(self.view, f"comboBoxLoop{level}WaitInterval")
value = spinBox.value()
if comboBox.currentIndex() == 0:
value *= 1e9
elif comboBox.currentIndex() == 1:
value *= 1e6
elif comboBox.currentIndex() == 2:
value *= 1e3
t = DurationWrapper()
t.set_count(int(value))
self.det.patwaittime[level] = t
self.getPatLoopWaitInterval(level)
def setTogglePageWaitTime(self):
if self.view.stackedWidgetWaitTime.currentIndex() == 0:
self.view.stackedWidgetWaitTime.setCurrentIndex(1)
self.view.labelWaitTime.setText("Time")
for i in range(Defines.pattern.loops_count):
self.getPatLoopWaitInterval(i)
else:
self.view.stackedWidgetWaitTime.setCurrentIndex(0)
self.view.labelWaitTime.setText("Clocks")
for i in range(Defines.pattern.loops_count):
self.getPatLoopWaitClocks(i)
def setPatLoopWaitTime(self, level):
spinBox = getattr(self.view, f"spinBoxLoop{level}WaitTime")
self.det.patwaittime[level] = spinBox.value()
self.getPatLoopWaitTime(level)
def setCompiler(self):
response = QtWidgets.QFileDialog.getOpenFileName(
@ -450,7 +505,7 @@ class PatternTab(QtWidgets.QWidget):
f"{getattr(self.view, f'lineEditLoop{i}Stop').text()}")
commands.append(f"patwait {i} {getattr(self.view, f'lineEditLoop{i}Wait').text()}")
commands.append(f"patwaittime {i} {getattr(self.view, f'spinBoxLoop{i}WaitTime').text()}")
commands.append(f"patwaittime {i} {getattr(self.view, f'doubleSpinBoxLoop{i}WaitClocks').text()}")
commands.append(f"patlimits {self.view.lineEditStartAddress.text()}, {self.view.lineEditStopAddress.text()}")
# commands.append(f"patfname {self.view.lineEditPatternFile.text()}")
return commands

File diff suppressed because it is too large Load Diff

View File

@ -3704,6 +3704,12 @@ class Detector(CppDetectorApi):
"""
[Ctb][Mythen3][Xilinx Ctb] Wait time in clock cycles of loop level provided.
Info
----
:getter: Always return in clock cycles. To get in DurationWrapper, use getPatternWaitInterval
:setter: Accepts either a value in clock cycles or a time unit (timedelta, DurationWrapper)
Example
-------
>>> d.patwaittime[0] = 5
@ -3713,41 +3719,85 @@ class Detector(CppDetectorApi):
0: 5
1: 20
2: 30
>>> # using timedelta (up to microseconds precision)
>>> from datetime import timedelta
>>> d.patwaittime[0] = timedelta(seconds=1, microseconds=3)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.patwaittime[0] = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.patwaittime = t
>>>
>>> # to get in clock cycles
>>> d.patwaittime
1000
>>>
>>> d.getPatternWaitInterval(0)
sls::DurationWrapper(total_seconds: 1.23 count: 1230000000)
"""
return PatWaitTimeProxy(self)
@property
@element
def patwaittime0(self):
"""[Ctb][Mythen3][Xilinx Ctb] Wait 0 time in clock cycles."""
return self.getPatternWaitTime(0)
@patwaittime0.setter
def patwaittime0(self, nclk):
nclk = ut.merge_args(0, nclk)
ut.set_using_dict(self.setPatternWaitTime, *nclk)
def create_patwaittime_property(level):
docstring_template ="""
Deprecated command. Use patwaittime instead.
[Ctb][Mythen3][Xilinx Ctb] Wait time in clock cycles of loop level {level} provided.
@property
@element
def patwaittime1(self):
"""[Ctb][Mythen3][Xilinx Ctb] Wait 1 time in clock cycles."""
return self.getPatternWaitTime(1)
Info
----
@patwaittime1.setter
def patwaittime1(self, nclk):
nclk = ut.merge_args(1, nclk)
ut.set_using_dict(self.setPatternWaitTime, *nclk)
:getter: Always return in clock cycles. To get in DurationWrapper, use getPatternWaitInterval
:setter: Accepts either a value in clock cycles or a time unit (timedelta, DurationWrapper)
@property
@element
def patwaittime2(self):
"""[Ctb][Mythen3][Xilinx Ctb] Wait 2 time in clock cycles."""
return self.getPatternWaitTime(2)
Example
-------
>>> d.patwaittime{level} = 5
>>> d.patwaittime{level}
5
>>> # using timedelta (up to microseconds precision)
>>> from datetime import timedelta
>>> d.patwaittime{level} = timedelta(seconds=1, microseconds=3)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.patwaittime{level} = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.patwaittime{level} = t
>>>
>>> # to get in clock cycles
>>> d.patwaittime{level}
1000
>>>
>>> d.getPatternWaitInterval(level)
sls::DurationWrapper(total_seconds: 1.23 count: 1230000000)
"""
@property
@element
def patwaittime(self):
return self.getPatternWaitClocks(level)
@patwaittime2.setter
def patwaittime2(self, nclk):
nclk = ut.merge_args(2, nclk)
ut.set_using_dict(self.setPatternWaitTime, *nclk)
@patwaittime.setter
def patwaittime(self, value):
if isinstance(value, (int, float)) and not isinstance(value, bool):
nclk = ut.merge_args(level, value)
ut.set_using_dict(self.setPatternWaitClocks, level, *nclk)
else:
ut.set_time_using_dict(self.setPatternWaitInterval, level, value)
patwaittime.__doc__ = docstring_template.format(level=level)
return patwaittime
patwaittime0 = create_patwaittime_property(0)
patwaittime1 = create_patwaittime_property(1)
patwaittime2 = create_patwaittime_property(2)
@property

View File

@ -275,10 +275,13 @@ class PatWaitTimeProxy:
self.det = det
def __getitem__(self, key):
return element_if_equal(self.det.getPatternWaitTime(key))
return element_if_equal(self.det.getPatternWaitClocks(key))
def __setitem__(self, key, value):
set_proxy_using_dict(self.det.setPatternWaitTime, key, value)
if isinstance(value, (int, float)) and not isinstance(value, bool):
set_proxy_using_dict(self.det.setPatternWaitClocks, key, value)
else:
set_proxy_using_dict(self.det.setPatternWaitInterval, key, value)
def __repr__(self):
max_levels = MAX_PATTERN_LEVELS

View File

@ -1861,13 +1861,22 @@ void init_det(py::module &m) {
Detector::setPatternWaitAddr,
py::arg(), py::arg(), py::arg() = Positions{});
CppDetectorApi.def(
"getPatternWaitTime",
"getPatternWaitClocks",
(Result<uint64_t>(Detector::*)(int, sls::Positions) const) &
Detector::getPatternWaitTime,
Detector::getPatternWaitClocks,
py::arg(), py::arg() = Positions{});
CppDetectorApi.def("setPatternWaitTime",
CppDetectorApi.def("setPatternWaitClocks",
(void (Detector::*)(int, uint64_t, sls::Positions)) &
Detector::setPatternWaitTime,
Detector::setPatternWaitClocks,
py::arg(), py::arg(), py::arg() = Positions{});
CppDetectorApi.def(
"getPatternWaitInterval",
(Result<sls::ns>(Detector::*)(int, sls::Positions) const) &
Detector::getPatternWaitInterval,
py::arg(), py::arg() = Positions{});
CppDetectorApi.def("setPatternWaitInterval",
(void (Detector::*)(int, sls::ns, sls::Positions)) &
Detector::setPatternWaitInterval,
py::arg(), py::arg(), py::arg() = Positions{});
CppDetectorApi.def("getPatternMask",
(Result<uint64_t>(Detector::*)(sls::Positions)) &

View File

@ -1095,26 +1095,17 @@ int setNumTransceiverSamples(int val) {
int getNumTransceiverSamples() { return ntSamples; }
int setExpTime(int64_t val) {
if (val < 0) {
LOG(logERROR, ("Invalid exptime: %lld ns\n", (long long int)val));
return FAIL;
}
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
val *= (1E-3 * clkFrequency[RUN_CLK]);
setPatternWaitTime(0, val);
setPatternWaitInterval(0, val);
// validate for tolerance
int64_t retval = getExpTime();
val /= (1E-3 * clkFrequency[RUN_CLK]);
if (val != retval) {
return FAIL;
}
return OK;
}
int64_t getExpTime() {
return getPatternWaitTime(0) / (1E-3 * clkFrequency[RUN_CLK]);
}
int64_t getExpTime() { return getPatternWaitInterval(0); }
int setPeriod(int64_t val) {
if (val < 0) {

View File

@ -27,10 +27,15 @@ int getPatternWaitAddress(int level);
int validate_setPatternWaitAddresses(char *message, int level, int addr);
void setPatternWaitAddress(int level, int addr);
int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime);
uint64_t getPatternWaitTime(int level);
int validate_setPatternWaitTime(char *message, int level, uint64_t waittime);
void setPatternWaitTime(int level, uint64_t t);
int validate_getPatternWaitClocksAndInterval(char *message, int level,
uint64_t *waittime, int clocks);
uint64_t getPatternWaitClocks(int level);
uint64_t getPatternWaitInterval(int level);
int validate_setPatternWaitClocksAndInterval(char *message, int level,
uint64_t waittime, int clocks);
void setPatternWaitClocks(int level, uint64_t t);
void setPatternWaitInterval(int level, uint64_t t);
int validate_getPatternLoopCycles(char *message, int level, int *numLoops);
int getPatternLoopCycles(int level);

View File

@ -104,7 +104,7 @@ int set_pattern_word(int);
int set_pattern_loop_addresses(int);
int set_pattern_loop_cycles(int);
int set_pattern_wait_addr(int);
int set_pattern_wait_time(int);
int set_pattern_wait_clocks(int);
int set_pattern_mask(int);
int get_pattern_mask(int);
int set_pattern_bit_mask(int);
@ -336,3 +336,5 @@ int get_timing_info_decoder(int);
int set_timing_info_decoder(int);
int get_collection_mode(int);
int set_collection_mode(int);
int get_pattern_wait_interval(int);
int set_pattern_wait_interval(int);

View File

@ -11,6 +11,10 @@
#ifdef MYTHEN3D
extern enum TLogLevel trimmingPrint;
extern uint32_t clkDivider[];
#endif
#ifdef CHIPTESTBOARDD
extern uint32_t clkFrequency[];
#endif
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
@ -317,7 +321,8 @@ void setPatternWaitAddress(int level, int addr) {
}
}
int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime) {
int validate_getPatternWaitClocksAndInterval(char *message, int level,
uint64_t *waittime, int clocks) {
// validate input
if (level < 0 || level >= MAX_LEVELS) {
sprintf(message,
@ -326,11 +331,15 @@ int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime) {
LOG(logERROR, (message));
return FAIL;
}
*waittime = getPatternWaitTime(level);
if (clocks) {
*waittime = getPatternWaitClocks(level);
} else {
*waittime = getPatternWaitInterval(level);
}
return OK;
}
uint64_t getPatternWaitTime(int level) {
uint64_t getPatternWaitClocks(int level) {
switch (level) {
case 0:
return getU64BitReg(PATTERN_WAIT_TIMER_0_LSB_REG,
@ -357,7 +366,25 @@ uint64_t getPatternWaitTime(int level) {
}
}
int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) {
uint64_t getPatternWaitInterval(int level) {
uint64_t numClocks = getPatternWaitClocks(level);
int runclk = 0;
#ifdef CHIPTESTBOARDD
runclk = clkFrequency[RUN_CLK];
#elif XILINX_CHIPTESTBOARDD
runclk = RUN_CLK;
#elif MYTHEN3D
runclk = clkDivider[SYSTEM_C0];
#endif
if (runclk == 0) {
LOG(logERROR, ("runclk is 0. Cannot divide by 0. Returning -1.\n"));
return -1;
}
return numClocks / (1E-3 * runclk);
}
int validate_setPatternWaitClocksAndInterval(char *message, int level,
uint64_t waittime, int clocks) {
// validate input
if (level < 0 || level >= MAX_LEVELS) {
sprintf(message,
@ -367,12 +394,21 @@ int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) {
return FAIL;
}
setPatternWaitTime(level, waittime);
uint64_t retval = 0;
if (clocks) {
setPatternWaitClocks(level, waittime);
// validate result
retval = getPatternWaitClocks(level);
LOG(logDEBUG1, ("Pattern wait time in clocks (level:%d) retval: %d\n",
level, (long long int)retval));
} else {
setPatternWaitInterval(level, waittime);
// validate result
retval = getPatternWaitInterval(level);
LOG(logDEBUG1, ("Pattern wait time (level:%d) retval: %d\n", level,
(long long int)retval));
}
// validate result
uint64_t retval = getPatternWaitTime(level);
LOG(logDEBUG1, ("Pattern wait time (level:%d) retval: %d\n", level,
(long long int)retval));
int ret = OK;
char mode[128];
memset(mode, 0, sizeof(mode));
@ -381,13 +417,13 @@ int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) {
return ret;
}
void setPatternWaitTime(int level, uint64_t t) {
void setPatternWaitClocks(int level, uint64_t t) {
#ifdef MYTHEN3D
LOG(trimmingPrint,
#else
LOG(logINFO,
#endif
("Setting Pattern Wait Time (level:%d) :%lld\n", level,
("Setting Pattern Wait Time in clocks (level:%d) :%lld\n", level,
(long long int)t));
switch (level) {
case 0:
@ -421,6 +457,26 @@ void setPatternWaitTime(int level, uint64_t t) {
}
}
void setPatternWaitInterval(int level, uint64_t t) {
#ifdef MYTHEN3D
LOG(trimmingPrint,
#else
LOG(logINFO,
#endif
("Setting Pattern Wait Time (level:%d) :%lld ns\n", level,
(long long int)t));
int runclk = 0;
#ifdef CHIPTESTBOARDD
runclk = clkFrequency[RUN_CLK];
#elif XILINX_CHIPTESTBOARDD
runclk = RUN_CLK;
#elif MYTHEN3D
runclk = clkDivider[SYSTEM_C0];
#endif
uint64_t numClocks = t * (1E-3 * runclk);
setPatternWaitClocks(level, numClocks);
}
int validate_getPatternLoopCycles(char *message, int level, int *numLoops) {
// validate input
if (level < 0 || level >= MAX_LEVELS) {
@ -830,7 +886,8 @@ int loadPattern(char *message, enum TLogLevel printLevel,
}
// wait time
ret = validate_setPatternWaitTime(message, i, pat->waittime[i]);
ret = validate_setPatternWaitClocksAndInterval(message, i,
pat->waittime[i], 1);
if (ret == FAIL) {
break;
}
@ -894,7 +951,8 @@ int getPattern(char *message, patternParameters *pat) {
pat->wait[i] = retval1;
// wait time
ret = validate_getPatternWaitTime(message, i, &retval64);
ret = validate_getPatternWaitClocksAndInterval(message, i,
&retval64, 1);
if (ret == FAIL) {
break;
}
@ -1095,7 +1153,8 @@ int loadPatternFile(char *patFname, char *errMessage) {
break;
}
if (validate_setPatternWaitTime(temp, level, waittime) == FAIL) {
if (validate_setPatternWaitClocksAndInterval(temp, level, waittime,
1) == FAIL) {
break;
}
}

View File

@ -302,7 +302,7 @@ void function_table() {
flist[F_SET_PATTERN_LOOP_ADDRESSES] = &set_pattern_loop_addresses;
flist[F_SET_PATTERN_LOOP_CYCLES] = &set_pattern_loop_cycles;
flist[F_SET_PATTERN_WAIT_ADDR] = &set_pattern_wait_addr;
flist[F_SET_PATTERN_WAIT_TIME] = &set_pattern_wait_time;
flist[F_SET_PATTERN_WAIT_CLOCKS] = &set_pattern_wait_clocks;
flist[F_SET_PATTERN_MASK] = &set_pattern_mask;
flist[F_GET_PATTERN_MASK] = &get_pattern_mask;
flist[F_SET_PATTERN_BIT_MASK] = &set_pattern_bit_mask;
@ -518,7 +518,8 @@ void function_table() {
flist[F_SET_TIMING_INFO_DECODER] = &set_timing_info_decoder;
flist[F_GET_COLLECTION_MODE] = &get_collection_mode;
flist[F_SET_COLLECTION_MODE] = &set_collection_mode;
flist[F_GET_PATTERN_WAIT_INTERVAL] = &get_pattern_wait_interval;
flist[F_SET_PATTERN_WAIT_INTERVAL] = &set_pattern_wait_interval;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
LOG(logERROR, ("The last detector function enum has reached its "
@ -3535,13 +3536,13 @@ int set_pattern_wait_addr(int file_des) {
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_pattern_wait_time(int file_des) {
int set_pattern_wait_clocks(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint64_t args[2] = {-1, -1};
uint64_t retval = -1;
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
if (receiveData(file_des, args, sizeof(args), INT64) < 0)
return printSocketReadError();
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
@ -3549,16 +3550,23 @@ int set_pattern_wait_time(int file_des) {
#else
int loopLevel = (int)args[0];
uint64_t timeval = args[1];
LOG(logDEBUG1, ("Setting Pattern wait time (loopLevel:%d timeval:0x%llx)\n",
loopLevel, (long long int)timeval));
LOG(logDEBUG1,
("Setting Pattern wait clocks (loopLevel:%d clocks:0x%lld)\n",
loopLevel, (long long int)timeval));
if (((int64_t)timeval == GET_FLAG) || (Server_VerifyLock() == OK)) {
// set
if ((int64_t)timeval != GET_FLAG) {
ret = validate_setPatternWaitTime(mess, loopLevel, timeval);
ret = validate_setPatternWaitClocksAndInterval(mess, loopLevel,
timeval, 1);
}
// get
if (ret == OK) {
ret = validate_getPatternWaitTime(mess, loopLevel, &retval);
ret = validate_getPatternWaitClocksAndInterval(mess, loopLevel,
&retval, 1);
if ((int64_t)timeval != GET_FLAG) {
validate64(&ret, mess, (int64_t)timeval, retval,
"set pattern wait clocks", DEC);
}
}
}
#endif
@ -11210,3 +11218,54 @@ int set_collection_mode(int file_des) {
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_pattern_wait_interval(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int loopLevel = -1;
uint64_t retval = -1;
if (receiveData(file_des, &loopLevel, sizeof(loopLevel), INT32) < 0)
return printSocketReadError();
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
LOG(logDEBUG1,
("Getting Pattern wait interva (loopLevel:%d)\n", loopLevel));
ret = validate_getPatternWaitClocksAndInterval(mess, loopLevel, &retval, 0);
#endif
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
}
int set_pattern_wait_interval(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint64_t args[2] = {-1, -1};
if (receiveData(file_des, args, sizeof(args), INT64) < 0)
return printSocketReadError();
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
int loopLevel = (int)args[0];
uint64_t timeval = args[1];
LOG(logDEBUG1,
("Setting Pattern wait interval (loopLevel:%d timeval:0x%llx ns)\n",
loopLevel, (long long int)timeval));
if (Server_VerifyLock() == OK) {
ret = validate_setPatternWaitClocksAndInterval(mess, loopLevel, timeval,
0);
if (ret == OK) {
uint64_t retval = 0;
ret = validate_getPatternWaitClocksAndInterval(mess, loopLevel,
&retval, 0);
validate64(&ret, mess, (int64_t)timeval, retval,
"set pattern wait interval", DEC);
}
}
#endif
return Server_SendResult(file_des, INT64, NULL, 0);
}

View File

@ -863,24 +863,17 @@ int getNumTransceiverSamples() {
}
int setExpTime(int64_t val) {
if (val < 0) {
LOG(logERROR, ("Invalid exptime: %lld ns\n", (long long int)val));
return FAIL;
}
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
val *= (1E-3 * RUN_CLK);
setPatternWaitTime(0, val);
setPatternWaitInterval(0, val);
// validate for tolerance
int64_t retval = getExpTime();
val /= (1E-3 * RUN_CLK);
if (val != retval) {
return FAIL;
}
return OK;
}
int64_t getExpTime() { return getPatternWaitTime(0) / (1E-3 * RUN_CLK); }
int64_t getExpTime() { return getPatternWaitInterval(0); }
int setPeriod(int64_t val) {
if (val < 0) {

View File

@ -19,10 +19,7 @@ class Caller {
IpAddr getDstIpFromAuto();
IpAddr getSrcIpFromAuto();
UdpDestination getUdpEntry();
void GetLevelAndUpdateArgIndex(int action,
std::string levelSeparatedCommand,
int &level, int &iArg, size_t nGetArgs,
size_t nPutArgs);
int GetLevelAndInsertIntoArgs(std::string levelSeparatedCommand);
void WrongNumberOfParameters(size_t expected);
template <typename V> std::string OutStringHex(const V &value) {

View File

@ -2656,6 +2656,44 @@ slowadc:
argc: 1
arg_types: [ int ]
patwaittime:
is_description: true
actions:
GET:
argc: -1
PUT:
argc: -1
patwaittime0:
is_description: true
duplicate_function: true
function_alias: patwaittime
actions:
GET:
argc: -1
PUT:
argc: -1
patwaittime1:
is_description: true
duplicate_function: true
function_alias: patwaittime
actions:
GET:
argc: -1
PUT:
argc: -1
patwaittime2:
is_description: true
duplicate_function: true
function_alias: patwaittime
actions:
GET:
argc: -1
PUT:
argc: -1
rx_dbitlist:
is_description: true
actions:
@ -3930,34 +3968,34 @@ patlimits:
patloop:
help: "[0-6] [start addr] [stop addr] \n\t[Ctb][Mythen3][Xilinx Ctb] Limits of the loop level provided.\n\t[Mythen3] Level options: 0-3 only."
infer_action: false
pattern_command: patloop
actions:
GET:
argc: -1
pattern_command:
command_name: patloop
nGetArgs: 0
nPutArgs: 2
argc: 1
require_det_id: true
function: getPatternLoopAddresses
extra_variables:
- name: level
type: int
value: "StringTo<int>(args[0])"
input: [ level ]
input_types: [ int ]
cast_input: [ false ]
output: [level,"' '" ,"OutStringHex(t, 4)" ]
PUT:
argc: -1
extra_variables:
- name: start
type: int
value: "StringTo<int>(args[iArg++])"
- name: stop
type: int
value: "StringTo<int>(args[iArg++])"
pattern_command:
command_name: patloop
nGetArgs: 0
nPutArgs: 2
argc: 3
require_det_id: true
function: setPatternLoopAddresses
extra_variables:
- name: level
type: int
value: "StringTo<int>(args[0])"
- name: start
type: int
value: "StringTo<int>(args[1])"
- name: stop
type: int
value: "StringTo<int>(args[2])"
input: [ level, start, stop ]
input_types: [ int, int, int ]
output: [level,"' '" , "'['" , "ToStringHex(start, 4)" , '", "' , "ToStringHex(stop, 4)", "']'" ]
@ -3979,34 +4017,33 @@ patloop2:
patnloop:
help: "[0-6] [n_cycles] \n\t[Ctb][Mythen3][Xilinx Ctb] Number of cycles of the loop level provided.\n\t[Mythen3] Level options: 0-3 only."
infer_action: false
pattern_command: patnloop
actions:
GET:
argc: -1
pattern_command:
command_name: patnloop
nGetArgs: 0
nPutArgs: 1
argc: 1
require_det_id: true
function: getPatternLoopCycles
extra_variables:
- name: level
type: int
value: "StringTo<int>(args[0])"
input: [ level ]
input_types: [ int ]
cast_input: [ false ]
output: [ level,"' '" , "OutString(t)" ]
PUT:
argc: -1
extra_variables:
- name: nloops
type: std::string
value: "args[iArg++]"
pattern_command:
command_name: patnloop
nGetArgs: 0
nPutArgs: 1
argc: 2
require_det_id: true
function: setPatternLoopCycles
extra_variables:
- name: level
type: int
value: "StringTo<int>(args[0])"
- name: nloops
type: int
value: "StringTo<int>(args[1])"
input: [ level, nloops ]
input_types: [ int, int ]
cast_input: [ false, true ]
output: [ level,"' '" , nloops ]
patnloop0:
@ -4014,9 +4051,9 @@ patnloop0:
inherit_actions: patnloop
actions:
GET:
output: [ "OutString(t)" ]
output: [ OutString(t) ]
PUT:
output: [ "nloops" ]
output: [ nloops ]
patnloop1:
inherit_actions: patnloop0
@ -4026,31 +4063,31 @@ patnloop2:
patwait:
help: "[0-6] [addr] \n\t[Ctb][Mythen3][Xilinx Ctb] Wait address for loop level provided. \n\t[Mythen3] Level options: 0-3 only."
infer_action: false
pattern_command: patwait
actions:
GET:
argc: -1
pattern_command:
command_name: patwait
nGetArgs: 0
nPutArgs: 1
argc: 1
require_det_id: true
function: getPatternWaitAddr
extra_variables:
- name: level
type: int
value: "StringTo<int>(args[0])"
input: [ level ]
input_types: [ int ]
cast_input: [ false ]
output: [level,"' '" , "OutStringHex(t, 4)" ]
PUT:
argc: -1
extra_variables:
- name: addr
type: int
value: "StringTo<int>(args[iArg++])"
pattern_command:
command_name: patwait
nGetArgs: 0
nPutArgs: 1
argc: 2
require_det_id: true
function: setPatternWaitAddr
extra_variables:
- name: level
type: int
value: "StringTo<int>(args[0])"
- name: addr
type: int
value: "StringTo<int>(args[1])"
input: [ level, addr ]
input_types: [ int, int ]
output: [level,"' '" , "ToStringHex(addr, 4)" ]
@ -4070,52 +4107,6 @@ patwait1:
patwait2:
inherit_actions: patwait0
patwaittime:
help: "[0-6] [n_clk] \n\t[Ctb][Mythen3][Xilinx Ctb] Wait time in clock cycles for the loop provided.\n\t[Mythen3] Level options: 0-3 only."
actions:
GET:
argc: -1
pattern_command:
command_name: patwaittime
nGetArgs: 0
nPutArgs: 1
require_det_id: true
function: getPatternWaitTime
input: [ level ]
input_types: [ int ]
cast_input: [ false ]
output: [ level,"' '" , "OutString(t)" ]
PUT:
argc: -1
extra_variables:
- name: waittime
type: uint64_t
value: "StringTo<uint64_t>(args[iArg++])"
pattern_command:
command_name: patwaittime
nGetArgs: 0
nPutArgs: 1
require_det_id: true
function: setPatternWaitTime
input: [ level, waittime ]
input_types: [ int, int ]
output: [level,"' '" , "waittime" ]
patwaittime0:
help: "\n\tDeprecated command. Use patwaittime."
inherit_actions: patwaittime
actions:
GET:
output: [ "OutString(t)" ]
PUT:
output: [ "waittime" ]
patwaittime1:
inherit_actions: patwaittime0
patwaittime2:
inherit_actions: patwaittime0
rx_jsonpara:
help: "[key1] [value1]\n\t[Receiver] Additional json header parameter streamed out from receiver. If not found in header, the pair is appended. An empty values deletes parameter. Max 20 characters for each key/value."
actions:

View File

@ -119,17 +119,11 @@ class CodeGenerator:
def write_check_arg(self):
pass
def write_arg(self, args, action, command_name):
for arg in args:
if arg['argc'] != -1:
if_block(f'args.size() == {arg["argc"]}',).__enter__()
if 'pattern_command' in arg and arg['pattern_command']:
self.write_line(f'int level = -1, iArg = 0, '
f'nGetArgs = {arg["pattern_command"]["nGetArgs"]},'
f' nPutArgs = {arg["pattern_command"]["nPutArgs"]};\nGetLevelAndUpdateArgIndex(action, '
f'"{arg["pattern_command"]["command_name"]}", level, iArg, nGetArgs,nPutArgs);'
)
if 'extra_variables' in arg:
for var in arg['extra_variables']:
codegen.write_line(f'{var["type"]} {var["name"]} = {var["value"]};')

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,11 @@ def generate(
codegen.write_line(f'os << R"V0G0N({command["help"]} )V0G0N" << std::endl;')
codegen.write_line('return os.str();')
# inserting arguments if needed
if 'pattern_command' in command and command['pattern_command']:
codegen.write_line(f'GetLevelAndInsertIntoArgs("{command["pattern_command"]}");')
# check if action and arguments are valid
codegen.write_line('// check if action and arguments are valid')

View File

@ -1930,10 +1930,15 @@ class Detector {
void setPatternWaitAddr(int level, int addr, Positions pos = {});
/** [CTB][Mythen3][Xilinx CTB] */
Result<uint64_t> getPatternWaitTime(int level, Positions pos = {}) const;
Result<uint64_t> getPatternWaitClocks(int level, Positions pos = {}) const;
/** [CTB][Mythen3][Xilinx CTB] Options: level 0-2 */
void setPatternWaitTime(int level, uint64_t t, Positions pos = {});
void setPatternWaitClocks(int level, uint64_t t, Positions pos = {});
Result<ns> getPatternWaitInterval(int level, Positions pos = {}) const;
/** [CTB][Mythen3][Xilinx CTB] Options: level 0-2 */
void setPatternWaitInterval(int level, ns t, Positions pos = {});
/** [CTB][Mythen3][Xilinx CTB] */
Result<uint64_t> getPatternMask(Positions pos = {});

View File

@ -7859,19 +7859,30 @@ std::string Caller::patloop(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patloop");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 3) {
int level = StringTo<int>(args[0]);
int start = StringTo<int>(args[1]);
int stop = StringTo<int>(args[2]);
}
}
else {
@ -7882,23 +7893,24 @@ std::string Caller::patloop(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << level << ' ' << OutStringHex(t, 4) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t =
det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << level << ' ' << OutStringHex(t, 4) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
nPutArgs);
int start = StringTo<int>(args[iArg++]);
int stop = StringTo<int>(args[iArg++]);
det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id});
os << level << ' ' << '[' << ToStringHex(start, 4) << ", "
<< ToStringHex(stop, 4) << ']' << '\n';
if (args.size() == 3) {
int level = StringTo<int>(args[0]);
int start = StringTo<int>(args[1]);
int stop = StringTo<int>(args[2]);
det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id});
os << level << ' ' << '[' << ToStringHex(start, 4) << ", "
<< ToStringHex(stop, 4) << ']' << '\n';
}
}
return os.str();
@ -7915,19 +7927,30 @@ std::string Caller::patloop0(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patloop");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 3) {
int level = StringTo<int>(args[0]);
int start = StringTo<int>(args[1]);
int stop = StringTo<int>(args[2]);
}
}
else {
@ -7938,23 +7961,24 @@ std::string Caller::patloop0(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t =
det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
nPutArgs);
int start = StringTo<int>(args[iArg++]);
int stop = StringTo<int>(args[iArg++]);
det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id});
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
<< ']' << '\n';
if (args.size() == 3) {
int level = StringTo<int>(args[0]);
int start = StringTo<int>(args[1]);
int stop = StringTo<int>(args[2]);
det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id});
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
<< ']' << '\n';
}
}
return os.str();
@ -7971,19 +7995,30 @@ std::string Caller::patloop1(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patloop");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 3) {
int level = StringTo<int>(args[0]);
int start = StringTo<int>(args[1]);
int stop = StringTo<int>(args[2]);
}
}
else {
@ -7994,23 +8029,24 @@ std::string Caller::patloop1(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t =
det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
nPutArgs);
int start = StringTo<int>(args[iArg++]);
int stop = StringTo<int>(args[iArg++]);
det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id});
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
<< ']' << '\n';
if (args.size() == 3) {
int level = StringTo<int>(args[0]);
int start = StringTo<int>(args[1]);
int stop = StringTo<int>(args[2]);
det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id});
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
<< ']' << '\n';
}
}
return os.str();
@ -8027,19 +8063,30 @@ std::string Caller::patloop2(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patloop");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 3) {
int level = StringTo<int>(args[0]);
int start = StringTo<int>(args[1]);
int stop = StringTo<int>(args[2]);
}
}
else {
@ -8050,23 +8097,24 @@ std::string Caller::patloop2(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t =
det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
nPutArgs);
int start = StringTo<int>(args[iArg++]);
int stop = StringTo<int>(args[iArg++]);
det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id});
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
<< ']' << '\n';
if (args.size() == 3) {
int level = StringTo<int>(args[0]);
int start = StringTo<int>(args[1]);
int stop = StringTo<int>(args[2]);
det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id});
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
<< ']' << '\n';
}
}
return os.str();
@ -8146,19 +8194,29 @@ std::string Caller::patnloop(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patnloop");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int nloops = StringTo<int>(args[1]);
}
}
else {
@ -8169,21 +8227,20 @@ std::string Caller::patnloop(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << level << ' ' << OutString(t) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << level << ' ' << OutString(t) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs,
nPutArgs);
std::string nloops = args[iArg++];
auto arg1 = StringTo<int>(nloops);
det->setPatternLoopCycles(level, arg1, std::vector<int>{det_id});
os << level << ' ' << nloops << '\n';
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int nloops = StringTo<int>(args[1]);
det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
os << level << ' ' << nloops << '\n';
}
}
return os.str();
@ -8200,19 +8257,29 @@ std::string Caller::patnloop0(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patnloop");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int nloops = StringTo<int>(args[1]);
}
}
else {
@ -8223,21 +8290,20 @@ std::string Caller::patnloop0(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs,
nPutArgs);
std::string nloops = args[iArg++];
auto arg1 = StringTo<int>(nloops);
det->setPatternLoopCycles(level, arg1, std::vector<int>{det_id});
os << nloops << '\n';
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int nloops = StringTo<int>(args[1]);
det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
os << nloops << '\n';
}
}
return os.str();
@ -8254,19 +8320,29 @@ std::string Caller::patnloop1(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patnloop");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int nloops = StringTo<int>(args[1]);
}
}
else {
@ -8277,21 +8353,20 @@ std::string Caller::patnloop1(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs,
nPutArgs);
std::string nloops = args[iArg++];
auto arg1 = StringTo<int>(nloops);
det->setPatternLoopCycles(level, arg1, std::vector<int>{det_id});
os << nloops << '\n';
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int nloops = StringTo<int>(args[1]);
det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
os << nloops << '\n';
}
}
return os.str();
@ -8308,19 +8383,29 @@ std::string Caller::patnloop2(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patnloop");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int nloops = StringTo<int>(args[1]);
}
}
else {
@ -8331,21 +8416,20 @@ std::string Caller::patnloop2(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs,
nPutArgs);
std::string nloops = args[iArg++];
auto arg1 = StringTo<int>(nloops);
det->setPatternLoopCycles(level, arg1, std::vector<int>{det_id});
os << nloops << '\n';
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int nloops = StringTo<int>(args[1]);
det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
os << nloops << '\n';
}
}
return os.str();
@ -8503,19 +8587,29 @@ std::string Caller::patwait(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patwait");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int addr = StringTo<int>(args[1]);
}
}
else {
@ -8526,20 +8620,20 @@ std::string Caller::patwait(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << level << ' ' << OutStringHex(t, 4) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << level << ' ' << OutStringHex(t, 4) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs,
nPutArgs);
int addr = StringTo<int>(args[iArg++]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << level << ' ' << ToStringHex(addr, 4) << '\n';
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int addr = StringTo<int>(args[1]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << level << ' ' << ToStringHex(addr, 4) << '\n';
}
}
return os.str();
@ -8556,19 +8650,29 @@ std::string Caller::patwait0(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patwait");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int addr = StringTo<int>(args[1]);
}
}
else {
@ -8579,20 +8683,20 @@ std::string Caller::patwait0(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs,
nPutArgs);
int addr = StringTo<int>(args[iArg++]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << ToStringHex(addr, 4) << '\n';
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int addr = StringTo<int>(args[1]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << ToStringHex(addr, 4) << '\n';
}
}
return os.str();
@ -8609,19 +8713,29 @@ std::string Caller::patwait1(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patwait");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int addr = StringTo<int>(args[1]);
}
}
else {
@ -8632,20 +8746,20 @@ std::string Caller::patwait1(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs,
nPutArgs);
int addr = StringTo<int>(args[iArg++]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << ToStringHex(addr, 4) << '\n';
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int addr = StringTo<int>(args[1]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << ToStringHex(addr, 4) << '\n';
}
}
return os.str();
@ -8662,19 +8776,29 @@ std::string Caller::patwait2(int action) {
return os.str();
}
GetLevelAndInsertIntoArgs("patwait");
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int addr = StringTo<int>(args[1]);
}
}
else {
@ -8685,233 +8809,20 @@ std::string Caller::patwait2(int action) {
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
if (args.size() == 1) {
int level = StringTo<int>(args[0]);
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs,
nPutArgs);
int addr = StringTo<int>(args[iArg++]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << ToStringHex(addr, 4) << '\n';
}
return os.str();
}
std::string Caller::patwaittime(int action) {
std::ostringstream os;
// print help
if (action == slsDetectorDefs::HELP_ACTION) {
os << R"V0G0N([0-6] [n_clk]
[Ctb][Mythen3][Xilinx Ctb] Wait time in clock cycles for the loop provided.
[Mythen3] Level options: 0-3 only. )V0G0N"
<< std::endl;
return os.str();
}
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
throw RuntimeError("Wrong number of arguments for action GET");
if (args.size() == 2) {
int level = StringTo<int>(args[0]);
int addr = StringTo<int>(args[1]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << ToStringHex(addr, 4) << '\n';
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
}
else {
throw RuntimeError("INTERNAL ERROR: Invalid action: supported actions "
"are ['GET', 'PUT']");
}
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
os << level << ' ' << OutString(t) << '\n';
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs,
nPutArgs);
uint64_t waittime = StringTo<uint64_t>(args[iArg++]);
det->setPatternWaitTime(level, waittime, std::vector<int>{det_id});
os << level << ' ' << waittime << '\n';
}
return os.str();
}
std::string Caller::patwaittime0(int action) {
std::ostringstream os;
// print help
if (action == slsDetectorDefs::HELP_ACTION) {
os << R"V0G0N(
Deprecated command. Use patwaittime. )V0G0N"
<< std::endl;
return os.str();
}
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
throw RuntimeError("Wrong number of arguments for action GET");
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
}
else {
throw RuntimeError("INTERNAL ERROR: Invalid action: supported actions "
"are ['GET', 'PUT']");
}
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs,
nPutArgs);
uint64_t waittime = StringTo<uint64_t>(args[iArg++]);
det->setPatternWaitTime(level, waittime, std::vector<int>{det_id});
os << waittime << '\n';
}
return os.str();
}
std::string Caller::patwaittime1(int action) {
std::ostringstream os;
// print help
if (action == slsDetectorDefs::HELP_ACTION) {
os << R"V0G0N(
Deprecated command. Use patwaittime. )V0G0N"
<< std::endl;
return os.str();
}
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
throw RuntimeError("Wrong number of arguments for action GET");
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
}
else {
throw RuntimeError("INTERNAL ERROR: Invalid action: supported actions "
"are ['GET', 'PUT']");
}
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs,
nPutArgs);
uint64_t waittime = StringTo<uint64_t>(args[iArg++]);
det->setPatternWaitTime(level, waittime, std::vector<int>{det_id});
os << waittime << '\n';
}
return os.str();
}
std::string Caller::patwaittime2(int action) {
std::ostringstream os;
// print help
if (action == slsDetectorDefs::HELP_ACTION) {
os << R"V0G0N(
Deprecated command. Use patwaittime. )V0G0N"
<< std::endl;
return os.str();
}
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (0) {
throw RuntimeError("Wrong number of arguments for action GET");
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
}
else {
throw RuntimeError("INTERNAL ERROR: Invalid action: supported actions "
"are ['GET', 'PUT']");
}
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs,
nPutArgs);
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
}
if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs,
nPutArgs);
uint64_t waittime = StringTo<uint64_t>(args[iArg++]);
det->setPatternWaitTime(level, waittime, std::vector<int>{det_id});
os << waittime << '\n';
}
return os.str();

View File

@ -19,10 +19,7 @@ class Caller {
IpAddr getDstIpFromAuto();
IpAddr getSrcIpFromAuto();
UdpDestination getUdpEntry();
void GetLevelAndUpdateArgIndex(int action,
std::string levelSeparatedCommand,
int &level, int &iArg, size_t nGetArgs,
size_t nPutArgs);
int GetLevelAndInsertIntoArgs(std::string levelSeparatedCommand);
void WrongNumberOfParameters(size_t expected);
template <typename V> std::string OutStringHex(const V &value) {
@ -207,9 +204,6 @@ class Caller {
std::string patwait1(int action);
std::string patwait2(int action);
std::string patwaittime(int action);
std::string patwaittime0(int action);
std::string patwaittime1(int action);
std::string patwaittime2(int action);
std::string patword(int action);
std::string pedestalmode(int action);
std::string period(int action);
@ -556,9 +550,9 @@ class Caller {
{"patwait1", &Caller::patwait1},
{"patwait2", &Caller::patwait2},
{"patwaittime", &Caller::patwaittime},
{"patwaittime0", &Caller::patwaittime0},
{"patwaittime1", &Caller::patwaittime1},
{"patwaittime2", &Caller::patwaittime2},
{"patwaittime0", &Caller::patwaittime},
{"patwaittime1", &Caller::patwaittime},
{"patwaittime2", &Caller::patwaittime},
{"patword", &Caller::patword},
{"pedestalmode", &Caller::pedestalmode},
{"period", &Caller::period},

View File

@ -175,28 +175,16 @@ void Caller::WrongNumberOfParameters(size_t expected) {
std::to_string(args.size()) + "\n");
}
void Caller::GetLevelAndUpdateArgIndex(int action,
std::string levelSeparatedCommand,
int &level, int &iArg, size_t nGetArgs,
size_t nPutArgs) {
if (cmd == levelSeparatedCommand) {
++nGetArgs;
++nPutArgs;
} else {
int Caller::GetLevelAndInsertIntoArgs(std::string levelSeparatedCommand) {
if (cmd != levelSeparatedCommand) {
LOG(logWARNING) << "This command is deprecated and will be removed. "
"Please migrate to "
<< levelSeparatedCommand;
int level = cmd[cmd.find_first_of("012")] - '0';
args.insert(args.begin(), std::to_string(level));
return true;
}
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';
}
return false;
}
std::string Caller::free(int action) {
@ -1017,6 +1005,81 @@ std::string Caller::slowadc(int action) {
}
return os.str();
}
std::string Caller::patwaittime(int action) {
std::ostringstream os;
if (action == defs::HELP_ACTION) {
os << "[0-6] [n_clk] \n\t[Ctb][Mythen3][Xilinx Ctb] Wait time in clock "
"cycles for the loop provided.\n\t[Mythen3] Level options: 0-3 "
"only."
<< '\n';
return os.str();
}
// parse level
bool deprecated_cmd = GetLevelAndInsertIntoArgs("patwaittime");
int level = 0;
try {
if (args.size() > 0)
level = StringTo<int>(args[0]);
} catch (const std::exception &e) {
LOG(logERROR) << "Could not scan level.";
throw;
}
if (!deprecated_cmd && args.size() >= 1)
os << args[0] << ' ';
if (action == defs::GET_ACTION) {
if (args.size() != 1 && args.size() != 2)
WrongNumberOfParameters(1);
// with time unit
if (args.size() == 2) {
auto t =
det->getPatternWaitInterval(level, std::vector<int>{det_id});
os << OutString(t, args[1]) << '\n';
}
// in clocks
else {
auto t = det->getPatternWaitClocks(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
}
} else if (action == defs::PUT_ACTION) {
if (args.size() != 2 && args.size() != 3)
WrongNumberOfParameters(2);
// clocks (all digits)
if (args.size() == 2 &&
std::all_of(args[1].begin(), args[1].end(), ::isdigit)) {
uint64_t waittime = StringTo<uint64_t>(args[1]);
det->setPatternWaitClocks(level, waittime,
std::vector<int>{det_id});
os << waittime << '\n';
}
// time
else {
time::ns converted_time{0};
try {
if (args.size() == 2) {
std::string tmp_time(args[1]);
std::string unit = RemoveUnit(tmp_time);
converted_time = StringTo<time::ns>(tmp_time, unit);
} else {
converted_time = StringTo<time::ns>(args[1], args[2]);
}
} catch (...) {
throw RuntimeError("Could not convert argument to time::ns");
}
det->setPatternWaitInterval(level, converted_time,
std::vector<int>{det_id});
os << args[1];
if (args.size() == 3)
os << ' ' << args[2];
os << '\n';
}
} else {
throw RuntimeError("Unknown action");
}
return os.str();
}
std::string Caller::rx_dbitlist(int action) {
std::ostringstream os;
if (action == defs::HELP_ACTION) {

View File

@ -2593,12 +2593,21 @@ void Detector::setPatternWaitAddr(int level, int addr, Positions pos) {
pimpl->Parallel(&Module::setPatternWaitAddr, pos, level, addr);
}
Result<uint64_t> Detector::getPatternWaitTime(int level, Positions pos) const {
return pimpl->Parallel(&Module::getPatternWaitTime, pos, level);
Result<uint64_t> Detector::getPatternWaitClocks(int level,
Positions pos) const {
return pimpl->Parallel(&Module::getPatternWaitClocks, pos, level);
}
void Detector::setPatternWaitTime(int level, uint64_t t, Positions pos) {
pimpl->Parallel(&Module::setPatternWaitTime, pos, level, t);
void Detector::setPatternWaitClocks(int level, uint64_t t, Positions pos) {
pimpl->Parallel(&Module::setPatternWaitClocks, pos, level, t);
}
Result<ns> Detector::getPatternWaitInterval(int level, Positions pos) const {
return pimpl->Parallel(&Module::getPatternWaitInterval, pos, level);
}
void Detector::setPatternWaitInterval(int level, ns t, Positions pos) {
pimpl->Parallel(&Module::setPatternWaitInterval, pos, level, t.count());
}
Result<uint64_t> Detector::getPatternMask(Positions pos) {

View File

@ -634,10 +634,22 @@ void Module::setNumberOfTriggers(int64_t value) {
}
int64_t Module::getExptime(int gateIndex) const {
if (shm()->detType == CHIPTESTBOARD ||
shm()->detType == XILINX_CHIPTESTBOARD) {
LOG(logWARNING)
<< "Exposure time is deprecated and will be removed for this "
"detector. Please migrate to patwaittime.";
}
return sendToDetector<int64_t>(F_GET_EXPTIME, gateIndex);
}
void Module::setExptime(int gateIndex, int64_t value) {
if (shm()->detType == CHIPTESTBOARD ||
shm()->detType == XILINX_CHIPTESTBOARD) {
LOG(logWARNING)
<< "Exposure time is deprecated and will be removed for this "
"detector. Please migrate to patwaittime.";
}
int64_t prevVal = value;
if (shm()->detType == EIGER) {
prevVal = getExptime(-1);
@ -2621,15 +2633,23 @@ void Module::setPatternWaitAddr(int level, int addr) {
sendToDetector<int>(F_SET_PATTERN_WAIT_ADDR, args);
}
uint64_t Module::getPatternWaitTime(int level) const {
uint64_t Module::getPatternWaitClocks(int level) const {
uint64_t args[]{static_cast<uint64_t>(level),
static_cast<uint64_t>(GET_FLAG)};
return sendToDetector<uint64_t>(F_SET_PATTERN_WAIT_TIME, args);
return sendToDetector<uint64_t>(F_SET_PATTERN_WAIT_CLOCKS, args);
}
void Module::setPatternWaitTime(int level, uint64_t t) {
void Module::setPatternWaitClocks(int level, uint64_t t) {
uint64_t args[]{static_cast<uint64_t>(level), t};
sendToDetector<uint64_t>(F_SET_PATTERN_WAIT_TIME, args);
sendToDetector<uint64_t>(F_SET_PATTERN_WAIT_CLOCKS, args);
}
uint64_t Module::getPatternWaitInterval(int level) const {
return sendToDetector<uint64_t>(F_GET_PATTERN_WAIT_INTERVAL, level);
}
void Module::setPatternWaitInterval(int level, uint64_t t) {
uint64_t args[]{static_cast<uint64_t>(level), t};
sendToDetector(F_SET_PATTERN_WAIT_INTERVAL, args, nullptr);
}
uint64_t Module::getPatternMask() const {

View File

@ -550,8 +550,10 @@ class Module : public virtual slsDetectorDefs {
void setPatternLoopCycles(int level, int n);
int getPatternWaitAddr(int level) const;
void setPatternWaitAddr(int level, int addr);
uint64_t getPatternWaitTime(int level) const;
void setPatternWaitTime(int level, uint64_t t);
uint64_t getPatternWaitClocks(int level) const;
void setPatternWaitClocks(int level, uint64_t t);
uint64_t getPatternWaitInterval(int level) const;
void setPatternWaitInterval(int level, uint64_t t);
uint64_t getPatternMask() const;
void setPatternMask(uint64_t mask);
uint64_t getPatternBitMask() const;

View File

@ -2012,29 +2012,13 @@ int InferAction::patlimits() {
"sls_detector_get or sls_detector_put");
}
int InferAction::patloop() {
int InferAction::patloop() { throw RuntimeError("infer_action is disabled"); }
throw RuntimeError("sls_detector is disabled for command: patloop. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patloop0() { throw RuntimeError("infer_action is disabled"); }
int InferAction::patloop0() {
int InferAction::patloop1() { throw RuntimeError("infer_action is disabled"); }
throw RuntimeError("sls_detector is disabled for command: patloop0. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patloop1() {
throw RuntimeError("sls_detector is disabled for command: patloop1. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patloop2() {
throw RuntimeError("sls_detector is disabled for command: patloop2. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patloop2() { throw RuntimeError("infer_action is disabled"); }
int InferAction::patmask() {
@ -2052,29 +2036,13 @@ int InferAction::patmask() {
}
}
int InferAction::patnloop() {
int InferAction::patnloop() { throw RuntimeError("infer_action is disabled"); }
throw RuntimeError("sls_detector is disabled for command: patnloop. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patnloop0() { throw RuntimeError("infer_action is disabled"); }
int InferAction::patnloop0() {
int InferAction::patnloop1() { throw RuntimeError("infer_action is disabled"); }
throw RuntimeError("sls_detector is disabled for command: patnloop0. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patnloop1() {
throw RuntimeError("sls_detector is disabled for command: patnloop1. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patnloop2() {
throw RuntimeError("sls_detector is disabled for command: patnloop2. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patnloop2() { throw RuntimeError("infer_action is disabled"); }
int InferAction::patsetbit() {
@ -2116,29 +2084,13 @@ int InferAction::patternstart() {
}
}
int InferAction::patwait() {
int InferAction::patwait() { throw RuntimeError("infer_action is disabled"); }
throw RuntimeError("sls_detector is disabled for command: patwait. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patwait0() { throw RuntimeError("infer_action is disabled"); }
int InferAction::patwait0() {
int InferAction::patwait1() { throw RuntimeError("infer_action is disabled"); }
throw RuntimeError("sls_detector is disabled for command: patwait0. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patwait1() {
throw RuntimeError("sls_detector is disabled for command: patwait1. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patwait2() {
throw RuntimeError("sls_detector is disabled for command: patwait2. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::patwait2() { throw RuntimeError("infer_action is disabled"); }
int InferAction::patwaittime() {
@ -2146,24 +2098,6 @@ int InferAction::patwaittime() {
"sls_detector_get or sls_detector_put");
}
int InferAction::patwaittime0() {
throw RuntimeError("sls_detector is disabled for command: patwaittime0. "
"Use sls_detector_get or sls_detector_put");
}
int InferAction::patwaittime1() {
throw RuntimeError("sls_detector is disabled for command: patwaittime1. "
"Use sls_detector_get or sls_detector_put");
}
int InferAction::patwaittime2() {
throw RuntimeError("sls_detector is disabled for command: patwaittime2. "
"Use sls_detector_get or sls_detector_put");
}
int InferAction::patword() {
if (args.size() == 1) {

View File

@ -161,9 +161,6 @@ class InferAction {
int patwait1();
int patwait2();
int patwaittime();
int patwaittime0();
int patwaittime1();
int patwaittime2();
int patword();
int pedestalmode();
int period();
@ -498,9 +495,9 @@ class InferAction {
{"patwait1", &InferAction::patwait1},
{"patwait2", &InferAction::patwait2},
{"patwaittime", &InferAction::patwaittime},
{"patwaittime0", &InferAction::patwaittime0},
{"patwaittime1", &InferAction::patwaittime1},
{"patwaittime2", &InferAction::patwaittime2},
{"patwaittime0", &InferAction::patwaittime},
{"patwaittime1", &InferAction::patwaittime},
{"patwaittime2", &InferAction::patwaittime},
{"patword", &InferAction::patword},
{"pedestalmode", &InferAction::pedestalmode},
{"period", &InferAction::period},

View File

@ -329,7 +329,7 @@ TEST_CASE("patwaittime", "[.cmdcall]") {
if (det_type == defs::MYTHEN3 && iLoop >= 3) {
continue;
}
auto prev_val = det.getPatternWaitTime(iLoop);
auto prev_val = det.getPatternWaitClocks(iLoop);
std::string sLoop = ToString(iLoop);
if (iLoop < 3) {
std::string deprecatedCmd = "patwaittime" + sLoop;
@ -354,8 +354,24 @@ TEST_CASE("patwaittime", "[.cmdcall]") {
caller.call("patwaittime", {sLoop}, -1, GET, oss);
REQUIRE(oss.str() == "patwaittime " + sLoop + " 8589936640\n");
}
// time units
{
std::ostringstream oss;
caller.call("patwaittime", {sLoop, "50us"}, -1, PUT, oss);
REQUIRE(oss.str() == "patwaittime " + sLoop + " 50us\n");
}
{
std::ostringstream oss;
caller.call("patwaittime", {sLoop, "us"}, -1, GET, oss);
REQUIRE(oss.str() == "patwaittime " + sLoop + " 50us\n");
if (iLoop == 0 && det_type != defs::MYTHEN3) {
std::ostringstream oss;
caller.call("exptime", {"us"}, -1, GET, oss);
REQUIRE(oss.str() == "exptime 50us\n");
}
}
for (int iDet = 0; iDet != det.size(); ++iDet) {
det.setPatternWaitTime(iLoop, prev_val[iDet], {iDet});
det.setPatternWaitClocks(iLoop, prev_val[iDet], {iDet});
}
}
} else {

View File

@ -80,7 +80,7 @@ enum detFuncs {
F_SET_PATTERN_LOOP_ADDRESSES,
F_SET_PATTERN_LOOP_CYCLES,
F_SET_PATTERN_WAIT_ADDR,
F_SET_PATTERN_WAIT_TIME,
F_SET_PATTERN_WAIT_CLOCKS,
F_SET_PATTERN_MASK,
F_GET_PATTERN_MASK,
F_SET_PATTERN_BIT_MASK,
@ -297,6 +297,8 @@ enum detFuncs {
F_SET_TIMING_INFO_DECODER,
F_GET_COLLECTION_MODE,
F_SET_COLLECTION_MODE,
F_GET_PATTERN_WAIT_INTERVAL,
F_SET_PATTERN_WAIT_INTERVAL,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 512, /**< detector function should not exceed this
@ -486,7 +488,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_PATTERN_LOOP_ADDRESSES: return "F_SET_PATTERN_LOOP_ADDRESSES";
case F_SET_PATTERN_LOOP_CYCLES: return "F_SET_PATTERN_LOOP_CYCLES";
case F_SET_PATTERN_WAIT_ADDR: return "F_SET_PATTERN_WAIT_ADDR";
case F_SET_PATTERN_WAIT_TIME: return "F_SET_PATTERN_WAIT_TIME";
case F_SET_PATTERN_WAIT_CLOCKS: return "F_SET_PATTERN_WAIT_CLOCKS";
case F_SET_PATTERN_MASK: return "F_SET_PATTERN_MASK";
case F_GET_PATTERN_MASK: return "F_GET_PATTERN_MASK";
case F_SET_PATTERN_BIT_MASK: return "F_SET_PATTERN_BIT_MASK";
@ -701,6 +703,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_TIMING_INFO_DECODER: return "F_SET_TIMING_INFO_DECODER";
case F_GET_COLLECTION_MODE: return "F_GET_COLLECTION_MODE";
case F_SET_COLLECTION_MODE: return "F_SET_COLLECTION_MODE";
case F_GET_PATTERN_WAIT_INTERVAL: return "F_GET_PATTERN_WAIT_INTERVAL";
case F_SET_PATTERN_WAIT_INTERVAL: return "F_SET_PATTERN_WAIT_INTERVAL";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -1,13 +1,13 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */
#define APICTB "developer 0x241107"
#define APIGOTTHARD "developer 0x241107"
#define APIGOTTHARD2 "developer 0x241107"
#define APIMOENCH "developer 0x241107"
#define APIXILINXCTB "developer 0x241107"
#define APIEIGER "developer 0x241107"
#define APIJUNGFRAU "developer 0x241120"
#define APIMYTHEN3 "developer 0x241121"
#define APILIB "developer 0x241122"
#define APIRECEIVER "developer 0x241122"
#define APIXILINXCTB "developer 0x250131"
#define APICTB "developer 0x250131"
#define APIMYTHEN3 "developer 0x250131"