Merge branch 'developer' into jf_h5reader

This commit is contained in:
hinger_v 2025-02-03 17:29:11 +01:00
commit b73684612b
57 changed files with 2369 additions and 1577 deletions

View File

@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev
packages: libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev libpng-dev libtiff-dev
version: 1.0
- name: Configure CMake

View File

@ -28,7 +28,7 @@ This document describes the differences between vx.x.x and vx.0.2
=====================================
2 On-board Detector Server Compatibility

View File

@ -11,6 +11,7 @@ cp build/install/lib/* $PREFIX/lib/
#Binaries
cp build/install/bin/sls_detector_acquire $PREFIX/bin/.
cp build/install/bin/sls_detector_acquire_zmq $PREFIX/bin/.
cp build/install/bin/sls_detector_get $PREFIX/bin/.
cp build/install/bin/sls_detector_put $PREFIX/bin/.
cp build/install/bin/sls_detector_help $PREFIX/bin/.

View File

@ -23,11 +23,15 @@ Conda is not only useful to manage python environments but can also
be used as a user space package manager. Dates in the tag (for eg. 2020.07.23.dev0)
are from the developer branch. Please use released tags for stability.
We have three different packages available:
* **slsdetlib** shared libraries and command line utilities
* **slsdetgui** GUI
* **slsdet** Python bindings
We have four different packages available:
============== =============================================
Package Description
============== =============================================
slsdetlib shared libraries and command line utilities
slsdetgui GUI
slsdet Python bindings
moenchzmq moench
============== =============================================
.. code-block:: bash
@ -43,7 +47,7 @@ We have three different packages available:
#ready to use
sls_detector_get exptime
etc ...
...
.. code-block:: bash
@ -55,6 +59,8 @@ We have three different packages available:
conda search slsdet
# gui
conda search slsdetgui
# moench
conda search moenchzmq

View File

@ -14,6 +14,8 @@ from pyctbgui.utils.defines import Defines
import pyctbgui.utils.pixelmap as pm
from pyctbgui.utils.recordOrApplyPedestal import recordOrApplyPedestal
from slsdet import detectorType
if typing.TYPE_CHECKING:
from pyctbgui.services import AcquisitionTab, PlotTab
@ -30,6 +32,7 @@ class AdcTab(QtWidgets.QWidget):
self.acquisitionTab: AcquisitionTab | None = None
self.legend: LegendItem | None = None
self.logger = logging.getLogger('AdcTab')
self.tengiga = True
def setup_ui(self):
self.plotTab = self.mainWindow.plotTab
@ -42,6 +45,12 @@ class AdcTab(QtWidgets.QWidget):
self.legend.clear()
# subscribe to toggle legend
self.plotTab.subscribeToggleLegend(self.updateLegend)
if self.det.type == detectorType.XILINX_CHIPTESTBOARD:
self.view.checkBoxADC0_15Inv.setDisabled(True)
self.view.checkBoxADC16_31Inv.setDisabled(True)
self.view.lineEditADCInversion.setDisabled(True)
self.view.labelADCInversion.setDisabled(True)
def initializeAllAnalogPlots(self):
self.mainWindow.plotAnalogWaveform = pg.plot()
@ -67,7 +76,8 @@ class AdcTab(QtWidgets.QWidget):
def connect_ui(self):
for i in range(Defines.adc.count):
getattr(self.view, f"checkBoxADC{i}Inv").stateChanged.connect(partial(self.setADCInv, i))
if self.det.type == detectorType.CHIPTESTBOARD:
getattr(self.view, f"checkBoxADC{i}Inv").stateChanged.connect(partial(self.setADCInv, i))
getattr(self.view, f"checkBoxADC{i}En").stateChanged.connect(partial(self.setADCEnable, i))
getattr(self.view, f"checkBoxADC{i}Plot").stateChanged.connect(partial(self.setADCEnablePlot, i))
getattr(self.view, f"pushButtonADC{i}").clicked.connect(partial(self.selectADCColor, i))
@ -77,15 +87,17 @@ class AdcTab(QtWidgets.QWidget):
self.view.checkBoxADC0_15Plot.stateChanged.connect(partial(self.setADCEnablePlotRange, 0, Defines.adc.half))
self.view.checkBoxADC16_31Plot.stateChanged.connect(
partial(self.setADCEnablePlotRange, Defines.adc.half, Defines.adc.count))
self.view.checkBoxADC0_15Inv.stateChanged.connect(partial(self.setADCInvRange, 0, Defines.adc.half))
self.view.checkBoxADC16_31Inv.stateChanged.connect(
partial(self.setADCInvRange, Defines.adc.half, Defines.adc.count))
self.view.lineEditADCInversion.editingFinished.connect(self.setADCInvReg)
self.view.lineEditADCEnable.editingFinished.connect(self.setADCEnableReg)
if self.det.type == detectorType.CHIPTESTBOARD:
self.view.checkBoxADC0_15Inv.stateChanged.connect(partial(self.setADCInvRange, 0, Defines.adc.half))
self.view.checkBoxADC16_31Inv.stateChanged.connect(
partial(self.setADCInvRange, Defines.adc.half, Defines.adc.count))
self.view.lineEditADCInversion.editingFinished.connect(self.setADCInvReg)
def refresh(self):
self.updateADCNames()
self.updateADCInv()
if self.det.type == detectorType.CHIPTESTBOARD:
self.updateADCInv()
self.updateADCEnable()
# ADCs Tab functions
@ -196,9 +208,11 @@ class AdcTab(QtWidgets.QWidget):
return decoder.decode(analog_array, pm.moench04_analog())
def getADCEnableReg(self):
retval = self.det.adcenable
if self.det.tengiga:
retval = self.det.adcenable10g
if self.det.type == detectorType.CHIPTESTBOARD:
self.tengiga = self.det.tengiga
retval = self.det.adcenable10g
if not self.tengiga:
retval = self.det.adcenable
self.view.lineEditADCEnable.editingFinished.disconnect()
self.view.lineEditADCEnable.setText("0x{:08x}".format(retval))
self.view.lineEditADCEnable.editingFinished.connect(self.setADCEnableReg)
@ -207,8 +221,8 @@ class AdcTab(QtWidgets.QWidget):
def setADCEnableReg(self):
self.view.lineEditADCEnable.editingFinished.disconnect()
try:
mask = int(self.mainWindow.lineEditADCEnable.text(), 16)
if self.det.tengiga:
mask = int(self.view.lineEditADCEnable.text(), 16)
if self.tengiga:
self.det.adcenable10g = mask
else:
self.det.adcenable = mask
@ -239,7 +253,7 @@ class AdcTab(QtWidgets.QWidget):
def setADCEnable(self, i):
checkBox = getattr(self.view, f"checkBoxADC{i}En")
try:
if self.det.tengiga:
if self.tengiga:
enableMask = manipulate_bit(checkBox.isChecked(), self.det.adcenable10g, i)
self.det.adcenable10g = enableMask
else:
@ -265,7 +279,7 @@ class AdcTab(QtWidgets.QWidget):
for i in range(start_nr, end_nr):
mask = manipulate_bit(checkBox.isChecked(), mask, i)
try:
if self.det.tengiga:
if self.tengiga:
self.det.adcenable10g = mask
else:
self.det.adcenable = mask
@ -344,7 +358,7 @@ class AdcTab(QtWidgets.QWidget):
def setADCInvReg(self):
self.view.lineEditADCInversion.editingFinished.disconnect()
try:
self.det.adcinvert = int(self.mainWindow.lineEditADCInversion.text(), 16)
self.det.adcinvert = int(self.view.lineEditADCInversion.text(), 16)
except Exception as e:
QtWidgets.QMessageBox.warning(self.mainWindow, "ADC Inversion Fail", str(e), QtWidgets.QMessageBox.Ok)
pass
@ -395,7 +409,12 @@ class AdcTab(QtWidgets.QWidget):
self.updateADCInv()
def saveParameters(self) -> list[str]:
return [
f"adcenable {self.view.lineEditADCEnable.text()}",
f"adcinvert {self.view.lineEditADCInversion.text()}",
]
if self.det.type == detectorType.CHIPTESTBOARD:
return [
f"adcenable {self.view.lineEditADCEnable.text()}",
f"adcinvert {self.view.lineEditADCInversion.text()}",
]
else:
return [
f"adcenable {self.view.lineEditADCEnable.text()}"
]

View File

@ -7,7 +7,7 @@ import zmq
from PyQt5 import QtWidgets, uic
import logging
from slsdet import readoutMode, runStatus
from slsdet import readoutMode, runStatus, detectorType
from pyctbgui.utils.defines import Defines
from pyctbgui.utils.numpyWriter.npy_writer import NumpyFileManager
from pyctbgui.utils.numpyWriter.npz_writer import NpzFileWriter
@ -49,20 +49,37 @@ class AcquisitionTab(QtWidgets.QWidget):
self.adcTab = self.mainWindow.adcTab
self.plotTab = self.mainWindow.plotTab
self.toggleStartButton(False)
if self.det.type == detectorType.XILINX_CHIPTESTBOARD:
self.view.labelRunF.setDisabled(True)
self.view.labelADCF.setDisabled(True)
self.view.labelADCPhase.setDisabled(True)
self.view.labelADCPipeline.setDisabled(True)
self.view.labelDBITF.setDisabled(True)
self.view.labelDBITPhase.setDisabled(True)
self.view.labelDBITPipeline.setDisabled(True)
self.view.spinBoxRunF.setDisabled(True)
self.view.spinBoxADCF.setDisabled(True)
self.view.spinBoxADCPhase.setDisabled(True)
self.view.spinBoxADCPipeline.setDisabled(True)
self.view.spinBoxDBITF.setDisabled(True)
self.view.spinBoxDBITPhase.setDisabled(True)
self.view.spinBoxDBITPipeline.setDisabled(True)
def connect_ui(self):
# For Acquistions Tab
self.view.comboBoxROMode.currentIndexChanged.connect(self.setReadOut)
self.view.spinBoxRunF.editingFinished.connect(self.setRunFrequency)
self.view.spinBoxTransceiver.editingFinished.connect(self.setTransceiver)
self.view.spinBoxAnalog.editingFinished.connect(self.setAnalog)
self.view.spinBoxDigital.editingFinished.connect(self.setDigital)
self.view.spinBoxADCF.editingFinished.connect(self.setADCFrequency)
self.view.spinBoxADCPhase.editingFinished.connect(self.setADCPhase)
self.view.spinBoxADCPipeline.editingFinished.connect(self.setADCPipeline)
self.view.spinBoxDBITF.editingFinished.connect(self.setDBITFrequency)
self.view.spinBoxDBITPhase.editingFinished.connect(self.setDBITPhase)
self.view.spinBoxDBITPipeline.editingFinished.connect(self.setDBITPipeline)
if self.det.type == detectorType.CHIPTESTBOARD:
self.view.spinBoxRunF.editingFinished.connect(self.setRunFrequency)
self.view.spinBoxADCF.editingFinished.connect(self.setADCFrequency)
self.view.spinBoxADCPhase.editingFinished.connect(self.setADCPhase)
self.view.spinBoxADCPipeline.editingFinished.connect(self.setADCPipeline)
self.view.spinBoxDBITF.editingFinished.connect(self.setDBITFrequency)
self.view.spinBoxDBITPhase.editingFinished.connect(self.setDBITPhase)
self.view.spinBoxDBITPipeline.editingFinished.connect(self.setDBITPipeline)
self.view.checkBoxFileWriteRaw.stateChanged.connect(self.setFileWrite)
self.view.checkBoxFileWriteNumpy.stateChanged.connect(self.setFileWriteNumpy)
@ -77,16 +94,19 @@ class AcquisitionTab(QtWidgets.QWidget):
def refresh(self):
self.getReadout()
self.getRunFrequency()
self.getTransceiver()
self.getAnalog()
self.getDigital()
self.getADCFrequency()
self.getADCPhase()
self.getADCPipeline()
self.getDBITFrequency()
self.getDBITPhase()
self.getDBITPipeline()
if self.det.type == detectorType.CHIPTESTBOARD:
self.getRunFrequency()
self.getADCFrequency()
self.getADCPhase()
self.getADCPipeline()
self.getDBITFrequency()
self.getDBITPhase()
self.getDBITPipeline()
self.getFileWrite()
self.getFileName()
self.getFilePath()
@ -697,23 +717,39 @@ class AcquisitionTab(QtWidgets.QWidget):
self.socket.subscribe("")
def saveParameters(self) -> list[str]:
return [
f'romode {self.view.comboBoxROMode.currentText().lower()}',
f'runclk {self.view.spinBoxRunF.value()}',
f'adcclk {self.view.spinBoxADCF.value()}',
f'adcphase {self.view.spinBoxADCPhase.value()}',
f'adcpipeline {self.view.spinBoxADCPipeline.value()}',
f'dbitclk {self.view.spinBoxDBITF.value()}',
f'dbitphase {self.view.spinBoxDBITPhase.value()}',
f'dbitpipeline {self.view.spinBoxDBITPipeline.value()}',
f'fwrite {int(self.view.checkBoxFileWriteRaw.isChecked())}',
f'fname {self.view.lineEditFileName.text()}',
f'fpath {self.view.lineEditFilePath.text()}',
f'findex {self.view.spinBoxAcquisitionIndex.value()}',
f'frames {self.view.spinBoxFrames.value()}',
f'triggers {self.view.spinBoxTriggers.value()}',
f'period {self.view.spinBoxPeriod.value()} {self.view.comboBoxPeriod.currentText().lower()}',
f'asamples {self.view.spinBoxAnalog.value()}',
f'dsamples {self.view.spinBoxDigital.value()}',
f'tsamples {self.view.spinBoxTransceiver.value()}',
]
if self.det.type == detectorType.CHIPTESTBOARD:
return [
f'romode {self.view.comboBoxROMode.currentText().lower()}',
f'runclk {self.view.spinBoxRunF.value()}',
f'adcclk {self.view.spinBoxADCF.value()}',
f'adcphase {self.view.spinBoxADCPhase.value()}',
f'adcpipeline {self.view.spinBoxADCPipeline.value()}',
f'dbitclk {self.view.spinBoxDBITF.value()}',
f'dbitphase {self.view.spinBoxDBITPhase.value()}',
f'dbitpipeline {self.view.spinBoxDBITPipeline.value()}',
f'fwrite {int(self.view.checkBoxFileWriteRaw.isChecked())}',
f'fname {self.view.lineEditFileName.text()}',
f'fpath {self.view.lineEditFilePath.text()}',
f'findex {self.view.spinBoxAcquisitionIndex.value()}',
f'frames {self.view.spinBoxFrames.value()}',
f'triggers {self.view.spinBoxTriggers.value()}',
f'period {self.view.spinBoxPeriod.value()} {self.view.comboBoxPeriod.currentText().lower()}',
f'asamples {self.view.spinBoxAnalog.value()}',
f'dsamples {self.view.spinBoxDigital.value()}',
f'tsamples {self.view.spinBoxTransceiver.value()}',
]
else:
return [
f'romode {self.view.comboBoxROMode.currentText().lower()}',
f'fwrite {int(self.view.checkBoxFileWriteRaw.isChecked())}',
f'fname {self.view.lineEditFileName.text()}',
f'fpath {self.view.lineEditFilePath.text()}',
f'findex {self.view.spinBoxAcquisitionIndex.value()}',
f'frames {self.view.spinBoxFrames.value()}',
f'triggers {self.view.spinBoxTriggers.value()}',
f'period {self.view.spinBoxPeriod.value()} {self.view.comboBoxPeriod.currentText().lower()}',
f'asamples {self.view.spinBoxAnalog.value()}',
f'dsamples {self.view.spinBoxDigital.value()}',
f'tsamples {self.view.spinBoxTransceiver.value()}',
]

View File

@ -4,7 +4,7 @@ from pathlib import Path
from PyQt5 import QtWidgets, uic
from pyctbgui.utils.defines import Defines
from slsdet import dacIndex
from slsdet import dacIndex, detectorType
class DacTab(QtWidgets.QWidget):
@ -19,7 +19,14 @@ class DacTab(QtWidgets.QWidget):
dac = getattr(dacIndex, f"DAC_{i}")
getattr(self.view, f"spinBoxDAC{i}").setValue(self.det.getDAC(dac)[0])
if self.det.highvoltage == 0:
if self.det.type == detectorType.XILINX_CHIPTESTBOARD:
self.view.checkBoxHighVoltage.setDisabled(True)
self.view.spinBoxHighVoltage.setDisabled(True)
self.view.labelHighVoltage.setDisabled(True)
self.view.labelADCVppDacName.setDisabled(True)
self.view.labelADCVpp.setDisabled(True)
self.view.comboBoxADCVpp.setDisabled(True)
elif self.det.highvoltage == 0:
self.view.spinBoxHighVoltage.setDisabled(True)
self.view.checkBoxHighVoltage.setChecked(False)
@ -30,9 +37,11 @@ class DacTab(QtWidgets.QWidget):
getattr(self.view, f"checkBoxDAC{i}").stateChanged.connect(partial(self.setDACTristate, i))
getattr(self.view, f"checkBoxDAC{i}mV").stateChanged.connect(partial(self.getDAC, i))
self.view.comboBoxADCVpp.currentIndexChanged.connect(self.setADCVpp)
self.view.spinBoxHighVoltage.editingFinished.connect(self.setHighVoltage)
self.view.checkBoxHighVoltage.stateChanged.connect(self.setHighVoltage)
if self.view.comboBoxADCVpp.isEnabled():
self.view.comboBoxADCVpp.currentIndexChanged.connect(self.setADCVpp)
if self.view.checkBoxHighVoltage.isEnabled():
self.view.spinBoxHighVoltage.editingFinished.connect(self.setHighVoltage)
self.view.checkBoxHighVoltage.stateChanged.connect(self.setHighVoltage)
def refresh(self):
self.updateDACNames()
@ -40,8 +49,10 @@ class DacTab(QtWidgets.QWidget):
self.getDACTristate(i)
self.getDAC(i)
self.getADCVpp()
self.getHighVoltage()
if self.view.comboBoxADCVpp.isEnabled():
self.getADCVpp()
if self.view.checkBoxHighVoltage.isEnabled():
self.getHighVoltage()
def updateDACNames(self):
for i, name in enumerate(self.det.getDacNames()):
@ -165,6 +176,8 @@ class DacTab(QtWidgets.QWidget):
unit = " mV" if inMV else ""
commands.append(f"dac {i} {value}{unit}")
commands.append(f"adcvpp {self.view.comboBoxADCVpp.currentText()} mV")
commands.append(f"highvoltage {self.view.spinBoxHighVoltage.value()}")
if self.view.comboBoxADCVpp.isEnabled():
commands.append(f"adcvpp {self.view.comboBoxADCVpp.currentText()} mV")
if self.view.checkBoxHighVoltage.isEnabled():
commands.append(f"highvoltage {self.view.spinBoxHighVoltage.value()}")
return commands

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

View File

@ -4,7 +4,7 @@ from pathlib import Path
from PyQt5 import QtWidgets, uic
from pyctbgui.utils.defines import Defines
from slsdet import dacIndex
from slsdet import dacIndex, detectorType
class PowerSuppliesTab(QtWidgets.QWidget):
@ -18,7 +18,8 @@ class PowerSuppliesTab(QtWidgets.QWidget):
self.updateVoltageNames()
for i in Defines.powerSupplies:
self.getVoltage(i)
self.getCurrent(i)
if self.det.type == detectorType.CHIPTESTBOARD:
self.getCurrent(i)
def connect_ui(self):
for i in Defines.powerSupplies:
@ -38,6 +39,12 @@ class PowerSuppliesTab(QtWidgets.QWidget):
if retval == 0:
checkBox.setChecked(False)
spinBox.setDisabled(True)
if self.det.type == detectorType.XILINX_CHIPTESTBOARD:
label = getattr(self.view, f"labelI{i}")
label.setDisabled(True)
if self.det.type == detectorType.XILINX_CHIPTESTBOARD:
self.view.spinBoxVChip.setDisabled(True)
def updateVoltageNames(self):
retval = self.det.getPowerNames()
@ -56,7 +63,10 @@ class PowerSuppliesTab(QtWidgets.QWidget):
spinBox.editingFinished.disconnect()
checkBox.stateChanged.disconnect()
retval = self.det.getMeasuredPower(voltageIndex)[0]
if self.det.type == detectorType.XILINX_CHIPTESTBOARD:
retval = self.det.getPower(voltageIndex)[0]
else:
retval = self.det.getMeasuredPower(voltageIndex)[0]
# spinBox.setValue(retval)
if retval > 1:
checkBox.setChecked(True)
@ -68,8 +78,9 @@ class PowerSuppliesTab(QtWidgets.QWidget):
spinBox.editingFinished.connect(partial(self.setVoltage, i))
checkBox.stateChanged.connect(partial(self.setVoltage, i))
self.getVChip()
if self.det.type == detectorType.CHIPTESTBOARD:
self.getVChip()
# TODO: handle multiple events when pressing enter (twice)
@ -91,7 +102,8 @@ class PowerSuppliesTab(QtWidgets.QWidget):
# TODO: (properly) disconnecting and connecting to handle multiple events (out of focus and pressing enter).
spinBox.editingFinished.connect(partial(self.setVoltage, i))
self.getVoltage(i)
self.getCurrent(i)
if self.det.type == detectorType.CHIPTESTBOARD:
self.getCurrent(i)
def getCurrent(self, i):
label = getattr(self.view, f"labelI{i}")

View File

@ -4,7 +4,7 @@ from pathlib import Path
from PyQt5 import uic, QtWidgets
from pyctbgui.utils.defines import Defines
from slsdet import dacIndex
from slsdet import dacIndex, detectorType
class SlowAdcTab(QtWidgets.QWidget):
@ -17,7 +17,8 @@ class SlowAdcTab(QtWidgets.QWidget):
self.det = None
def setup_ui(self):
pass
if self.det.type == detectorType.XILINX_CHIPTESTBOARD:
self.view.pushButtonTemp.setDisabled(True)
def connect_ui(self):
for i in range(Defines.slowAdc.count):
@ -28,7 +29,8 @@ class SlowAdcTab(QtWidgets.QWidget):
self.updateSlowAdcNames()
for i in range(Defines.slowAdc.count):
self.updateSlowAdc(i)
self.updateTemperature()
if self.det.type == detectorType.CHIPTESTBOARD:
self.updateTemperature()
def updateSlowAdcNames(self):
for i, name in enumerate(self.mainWindow.det.getSlowADCNames()):

View File

@ -817,7 +817,7 @@ Only pressing enter on spinbox will set DAC (with this condition).</string>
</widget>
</item>
<item row="18" column="0">
<widget class="QLabel" name="label_125">
<widget class="QLabel" name="labelADCVppDacName">
<property name="text">
<string>ADC_VPP</string>
</property>

View File

@ -118,7 +118,7 @@
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label_70">
<widget class="QLabel" name="labelRunF">
<property name="text">
<string>Run Clock Frequency (MHz):</string>
</property>
@ -218,7 +218,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="2" column="3">
<widget class="QLabel" name="label_74">
<widget class="QLabel" name="labelDBITF">
<property name="minimumSize">
<size>
<width>200</width>
@ -231,7 +231,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_71">
<widget class="QLabel" name="labelADCF">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -278,7 +278,7 @@
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="label_76">
<widget class="QLabel" name="labelDBITPipeline">
<property name="text">
<string>DBIT Pipeline:</string>
</property>
@ -338,21 +338,21 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_73">
<widget class="QLabel" name="labelADCPipeline">
<property name="text">
<string>ADC Pipeline:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_72">
<widget class="QLabel" name="labelADCPhase">
<property name="text">
<string>ADC Clock Phase (a.u.):</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label_75">
<widget class="QLabel" name="labelDBITPhase">
<property name="text">
<string>DBIT Clock Phase (a.u.):</string>
</property>

View File

@ -19,7 +19,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QFrame" name="frame_7">
<widget class="QFrame" name="frame_ADC">
<property name="geometry">
<rect>
<x>0</x>
@ -3142,7 +3142,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_20">
<item row="0" column="0">
<widget class="QLabel" name="label_67">
<widget class="QLabel" name="labelADCInversion">
<property name="font">
<font>
<pointsize>10</pointsize>
@ -3188,7 +3188,7 @@
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_68">
<widget class="QLabel" name="labelADCEnable">
<property name="font">
<font>
<pointsize>10</pointsize>

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QFrame" name="frame_4">
<widget class="QFrame" name="frame_slowadcs">
<property name="geometry">
<rect>
<x>0</x>

View File

@ -3702,7 +3702,13 @@ class Detector(CppDetectorApi):
@property
def patwaittime(self):
"""
[Ctb][Mythen3][Xilinx Ctb] Wait time in clock cycles of loop level provided.
[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
-------
@ -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)
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)
@property
@element
def patwaittime2(self):
"""[Ctb][Mythen3][Xilinx Ctb] Wait 2 time in clock cycles."""
return self.getPatternWaitTime(2)
@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)
@patwaittime2.setter
def patwaittime2(self, nclk):
nclk = ut.merge_args(2, nclk)
ut.set_using_dict(self.setPatternWaitTime, *nclk)
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

@ -61,7 +61,9 @@ class qDefs : public QWidget {
}
}
template <class CT> struct NonDeduced { using type = CT; };
template <class CT> struct NonDeduced {
using type = CT;
};
template <class S, typename RT, typename... CT>
static void HandleExceptions(const std::string emsg, const std::string src,
S *s, RT (S::*somefunc)(CT...),

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

@ -17,7 +17,7 @@
#define BUFFERSIZE 16
#define I2C_DEVICE_FILE "/dev/i2c-0"
#define I2C_DEVICE_ADDRESS 0x4C
//#define I2C_DEVICE_ADDRESS 0x48
// #define I2C_DEVICE_ADDRESS 0x48
#define I2C_REGISTER_ADDRESS 0x40
int i2c_open(const char *file, unsigned int addr) {

View File

@ -98,8 +98,8 @@
// everything at ~200 kHz (200 kHz MHz ddr readout)
#define DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED 0x000c0000
//#define DAQ_FIFO_ENABLE 0x00100000 commented out as it
// is not used anywhere
// #define DAQ_FIFO_ENABLE 0x00100000 commented out as it
// is not used anywhere
#define DAQ_REG_CHIP_CMDS_INT_TRIGGER 0x00100000
// direct chip commands to the DAQ_REG_CHIP_CMDS register
@ -131,8 +131,9 @@
#define DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING 0x20000000
#define DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION 0x40000000
//#define DAQ_MASTER_HALF_MODULE 0x80000000 currently not
// used
// #define DAQ_MASTER_HALF_MODULE 0x80000000 currently
// not
// used
// chips static bits
#define DAQ_STATIC_BIT_PROGRAM 0x00000001

View File

@ -2,7 +2,7 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
//#include "types.h"
// #include "types.h"
#include <stdint.h>
/******************************************************************************/
/* types */

View File

@ -92,7 +92,7 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_HIGHADDR 0xC410FFFF
/* Definitions for a new memory */
//#define XPAR_PLB_LL_NEW_MEMORY 0xD1000000//0xD1000084//0xC4200000
// #define XPAR_PLB_LL_NEW_MEMORY 0xD1000000//0xD1000084//0xC4200000
/* Definitions for peripheral PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT */
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR 0xC4110000

View File

@ -22,13 +22,13 @@
((0x1 << GAIN_CONFGAIN_OFST) & GAIN_CONFGAIN_MSK)
/** Flow Control register */
//#define FLOW_CONTROL_REG (0x11 << MEM_MAP_SHIFT)
// #define FLOW_CONTROL_REG (0x11 << MEM_MAP_SHIFT)
/** Flow Status register */
//#define FLOW_STATUS_REG (0x12 << MEM_MAP_SHIFT)
// #define FLOW_STATUS_REG (0x12 << MEM_MAP_SHIFT)
/** Frame register */
//#define FRAME_REG (0x13 << MEM_MAP_SHIFT)
// #define FRAME_REG (0x13 << MEM_MAP_SHIFT)
/** Multi Purpose register */
#define MULTI_PURPOSE_REG (0x14 << MEM_MAP_SHIFT)
@ -79,7 +79,7 @@
((0x0007f << DAQ_PCKT_LNGTH_OFST) & DAQ_PCKT_LNGTH_MSK)
/** Time From Start register */
//#define TIME_FROM_START_REG (0x16 << MEM_MAP_SHIFT)
// #define TIME_FROM_START_REG (0x16 << MEM_MAP_SHIFT)
/** DAC Control register */
#define SPI_REG (0x17 << MEM_MAP_SHIFT)
@ -139,7 +139,7 @@
((0x1b << ADC_SYNC_ENET_DELAY_OFST) & ADC_SYNC_ENET_DELAY_MSK)
/** Time From Start register */
//#define MU_TIME_REG (0x1a << MEM_MAP_SHIFT)
// #define MU_TIME_REG (0x1a << MEM_MAP_SHIFT)
/** Temperatre SPI In register */
#define TEMP_SPI_IN_REG (0x1b << MEM_MAP_SHIFT)
@ -171,7 +171,7 @@
#define ENET_CONF_REG (0x1e << MEM_MAP_SHIFT)
/** Write TSE Shadow register */
//#define WRITE_TSE_SHADOW_REG (0x1f << MEM_MAP_SHIFT)
// #define WRITE_TSE_SHADOW_REG (0x1f << MEM_MAP_SHIFT)
/** High Voltage register */
#define HV_REG (0x20 << MEM_MAP_SHIFT)
@ -288,10 +288,10 @@
((0x4 << EXT_SIGNAL_OFST) & EXT_SIGNAL_MSK)
/** Look at me register */
//#define LOOK_AT_ME_REG (0x28 << MEM_MAP_SHIFT)
// #define LOOK_AT_ME_REG (0x28 << MEM_MAP_SHIFT)
/** FPGA SVN register */
//#define FPGA_SVN_REG (0x29 << MEM_MAP_SHIFT)
// #define FPGA_SVN_REG (0x29 << MEM_MAP_SHIFT)
/** Chip of Interest register */
#define CHIP_OF_INTRST_REG (0x2a << MEM_MAP_SHIFT)
@ -303,7 +303,7 @@
(0x0000FFFF << CHIP_OF_INTRST_NUM_CHNNLS_OFST)
/** Out MUX register */
//#define OUT_MUX_REG (0x2b << MEM_MAP_SHIFT)
// #define OUT_MUX_REG (0x2b << MEM_MAP_SHIFT)
/** Board Version register */
#define BOARD_REVISION_REG (0x2c << MEM_MAP_SHIFT)
@ -312,29 +312,29 @@
#define BOARD_REVISION_MSK (0x0000FFFF << BOARD_REVISION_OFST)
#define DETECTOR_TYPE_OFST (16)
#define DETECTOR_TYPE_MSK (0x0000000F << DETECTOR_TYPE_OFST)
//#define DETECTOR_TYPE_GOTTHARD_VAL (??)
// #define DETECTOR_TYPE_GOTTHARD_VAL (??)
#define DETECTOR_TYPE_MOENCH_VAL (2)
/** Memory Test register */
//#define MEMORY_TEST_REG (0x2d << MEM_MAP_SHIFT)
// #define MEMORY_TEST_REG (0x2d << MEM_MAP_SHIFT)
/** Hit Threshold register */
//#define HIT_THRESHOLD_REG (0x2e << MEM_MAP_SHIFT)
// #define HIT_THRESHOLD_REG (0x2e << MEM_MAP_SHIFT)
/** Hit Count register */
//#define HIT_COUNT_REG (0x2f << MEM_MAP_SHIFT)
// #define HIT_COUNT_REG (0x2f << MEM_MAP_SHIFT)
/* 16 bit Fifo Data register */
#define FIFO_DATA_REG (0x50 << MEM_MAP_SHIFT) // Not used in FW and SW (16bit)
/** Dacs Set 1 register */
//#define DACS_SET_1_REG (0x65 << MEM_MAP_SHIFT)
// #define DACS_SET_1_REG (0x65 << MEM_MAP_SHIFT)
/** Dacs Set 2 register */
//#define DACS_SET_2_REG (0x66 << MEM_MAP_SHIFT)
// #define DACS_SET_2_REG (0x66 << MEM_MAP_SHIFT)
/** Dacs Set 3 register */
//#define DACS_SET_3_REG (0x67 << MEM_MAP_SHIFT)
// #define DACS_SET_3_REG (0x67 << MEM_MAP_SHIFT)
/* Set Delay 64 bit register */
#define SET_DELAY_LSB_REG (0x68 << MEM_MAP_SHIFT)
@ -377,12 +377,12 @@
#define GET_EXPTIME_MSB_REG (0x7b << MEM_MAP_SHIFT)
/* Set Gates 64 bit register */
//#define SET_GATES_LSB_REG (0x7c << MEM_MAP_SHIFT)
//#define SET_GATES_MSB_REG (0x7d << MEM_MAP_SHIFT)
// #define SET_GATES_LSB_REG (0x7c << MEM_MAP_SHIFT)
// #define SET_GATES_MSB_REG (0x7d << MEM_MAP_SHIFT)
/* Set Gates 64 bit register */
//#define GET_GATES_LSB_REG (0x7e << MEM_MAP_SHIFT)
//#define GET_GATES_MSB_REG (0x7f << MEM_MAP_SHIFT)
// #define GET_GATES_LSB_REG (0x7e << MEM_MAP_SHIFT)
// #define GET_GATES_MSB_REG (0x7f << MEM_MAP_SHIFT)
/* Dark Image starting address */
#define DARK_IMAGE_REG (0x81 << MEM_MAP_SHIFT)

View File

@ -39,8 +39,8 @@ patternParameters *setChipStatusRegisterPattern(int csr) {
patword = clearBit(SIGNAL_resCounter, patword);
for (int i = 0; i < 8; i++)
pat->word[iaddr++] = patword;
//#This version of the serializer pushes in the MSB first (compatible with
// the CSR bit numbering)
// #This version of the serializer pushes in the MSB first (compatible with
// the CSR bit numbering)
for (int ib = nbits - 1; ib >= 0; ib--) {
if (csr & (1 << ib))
patword = setBit(SIGNAL_serialIN, patword);

View File

@ -38,11 +38,11 @@
#define CSR_invpol 4
#define CSR_dpulse 5
#define CSR_interp 6
#define _CSR_C10pre 7 //#default, negative polarity
#define _CSR_C10pre 7 // #default, negative polarity
#define CSR_pumprobe 8
#define CSR_apulse 9
#define CSR_C15sh 10
#define CSR_C30sh 11 //#default
#define CSR_C30sh 11 // #default
#define CSR_C50sh 12
#define CSR_C225ACsh \
13 // Connects 225fF SHAPER AC cap (1: 225 to shaper, 225 to GND. 0: 450 to

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

@ -106,9 +106,9 @@
(0x0000FFFF << I2C_SDA_HOLD_COUNT_PERIOD_OFST)
/** Receive Data Fifo Level register */
//#define I2C_RX_DATA_FIFO_LVL_OFST (0)
//#define I2C_RX_DATA_FIFO_LVL_MSK (0x000000FF <<
// I2C_RX_DATA_FIFO_LVL_OFST)
// #define I2C_RX_DATA_FIFO_LVL_OFST (0)
// #define I2C_RX_DATA_FIFO_LVL_MSK (0x000000FF <<
// I2C_RX_DATA_FIFO_LVL_OFST)
// defines in the fpga
uint32_t I2C_Control_Reg = 0x0;

View File

@ -622,7 +622,7 @@ void getIpAddressinString(char *cip, uint32_t ip) {
inet_ntop(AF_INET, &ip, cip, INET_ADDRSTRLEN);
#else
sprintf(cip, "%d.%d.%d.%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff,
(ip >> 8) & 0xff, (ip)&0xff);
(ip >> 8) & 0xff, (ip) & 0xff);
#endif
}

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 "
@ -2013,102 +2014,106 @@ int acquire(int blocking, int file_des) {
#if defined(JUNGFRAUD)
// chipv1.1 has to be configured before acquisition
if (getChipVersion() == 11 && !isChipConfigured()) {
ret = FAIL;
strcpy(mess, "Could not start acquisition. Chip is not configured. "
"Power it on to configure it.\n");
LOG(logERROR, (mess));
} else
ret = FAIL;
strcpy(mess,
"Could not start acquisition. Chip is not configured. "
"Power it on to configure it.\n");
LOG(logERROR, (mess));
} else
#endif
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
if ((getReadoutMode() == ANALOG_AND_DIGITAL ||
getReadoutMode() == ANALOG_ONLY) &&
(getNumAnalogSamples() <= 0)) {
ret = FAIL;
sprintf(mess,
"Could not start acquisition. Invalid number of analog "
"samples: %d.\n",
getNumAnalogSamples());
LOG(logERROR, (mess));
} else if ((getReadoutMode() == ANALOG_AND_DIGITAL ||
getReadoutMode() == DIGITAL_ONLY ||
getReadoutMode() == DIGITAL_AND_TRANSCEIVER) &&
(getNumDigitalSamples() <= 0)) {
ret = FAIL;
sprintf(mess,
if ((getReadoutMode() == ANALOG_AND_DIGITAL ||
getReadoutMode() == ANALOG_ONLY) &&
(getNumAnalogSamples() <= 0)) {
ret = FAIL;
sprintf(mess,
"Could not start acquisition. Invalid number of analog "
"samples: %d.\n",
getNumAnalogSamples());
LOG(logERROR, (mess));
} else if ((getReadoutMode() == ANALOG_AND_DIGITAL ||
getReadoutMode() == DIGITAL_ONLY ||
getReadoutMode() == DIGITAL_AND_TRANSCEIVER) &&
(getNumDigitalSamples() <= 0)) {
ret = FAIL;
sprintf(
mess,
"Could not start acquisition. Invalid number of digital "
"samples: %d.\n",
getNumDigitalSamples());
LOG(logERROR, (mess));
} else if ((getReadoutMode() == TRANSCEIVER_ONLY ||
getReadoutMode() == DIGITAL_AND_TRANSCEIVER) &&
(getNumTransceiverSamples() <= 0)) {
ret = FAIL;
sprintf(mess,
"Could not start acquisition. Invalid number of "
"transceiver "
"samples: %d.\n",
getNumTransceiverSamples());
LOG(logERROR, (mess));
} else
LOG(logERROR, (mess));
} else if ((getReadoutMode() == TRANSCEIVER_ONLY ||
getReadoutMode() == DIGITAL_AND_TRANSCEIVER) &&
(getNumTransceiverSamples() <= 0)) {
ret = FAIL;
sprintf(mess,
"Could not start acquisition. Invalid number of "
"transceiver "
"samples: %d.\n",
getNumTransceiverSamples());
LOG(logERROR, (mess));
} else
#endif
#ifdef EIGERD
// check for hardware mac and hardware ip
if (udpDetails[0].srcmac != getDetectorMAC()) {
ret = FAIL;
uint64_t sourcemac = getDetectorMAC();
char src_mac[MAC_ADDRESS_SIZE];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
sprintf(mess,
"Invalid udp source mac address for this detector. "
"Must be "
"same as hardware detector mac address %s\n",
src_mac);
LOG(logERROR, (mess));
} else if (!enableTenGigabitEthernet(GET_FLAG) &&
(udpDetails[0].srcip != getDetectorIP())) {
ret = FAIL;
uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip);
sprintf(mess,
"Invalid udp source ip address for this detector. Must "
"be "
"same as hardware detector ip address %s in 1G readout "
"mode \n",
src_ip);
LOG(logERROR, (mess));
} else
#endif
if (configured == FAIL) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because a scan is "
"already running!\n");
LOG(logERROR, (mess));
} else {
memset(scanErrMessage, 0, MAX_STR_LENGTH);
sharedMemory_setScanStop(0);
sharedMemory_setScanStatus(IDLE); // if it was error
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
&blocking)) {
ret = FAIL;
strcpy(mess, "Could not start acquisition thread!\n");
LOG(logERROR, (mess));
} else {
// wait for blocking always (scan or not)
// non blocking-no scan also wait (for error message)
// non blcoking-scan dont wait (there is
// scanErrorMessage)
if (blocking || !scan) {
pthread_join(pthread_tid, NULL);
// check for hardware mac and hardware ip
if (udpDetails[0].srcmac != getDetectorMAC()) {
ret = FAIL;
uint64_t sourcemac = getDetectorMAC();
char src_mac[MAC_ADDRESS_SIZE];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
sprintf(mess,
"Invalid udp source mac address for this detector. "
"Must be "
"same as hardware detector mac address %s\n",
src_mac);
LOG(logERROR, (mess));
} else if (!enableTenGigabitEthernet(GET_FLAG) &&
(udpDetails[0].srcip != getDetectorIP())) {
ret = FAIL;
uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip);
sprintf(
mess,
"Invalid udp source ip address for this detector. Must "
"be "
"same as hardware detector ip address %s in 1G readout "
"mode \n",
src_ip);
LOG(logERROR, (mess));
} else
pthread_detach(pthread_tid);
}
}
#endif
if (configured == FAIL) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess,
"Could not start acquisition because a scan is "
"already running!\n");
LOG(logERROR, (mess));
} else {
memset(scanErrMessage, 0, MAX_STR_LENGTH);
sharedMemory_setScanStop(0);
sharedMemory_setScanStatus(IDLE); // if it was error
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
&blocking)) {
ret = FAIL;
strcpy(mess, "Could not start acquisition thread!\n");
LOG(logERROR, (mess));
} else {
// wait for blocking always (scan or not)
// non blocking-no scan also wait (for error message)
// non blcoking-scan dont wait (there is
// scanErrorMessage)
if (blocking || !scan) {
pthread_join(pthread_tid, NULL);
} else
pthread_detach(pthread_tid);
}
}
}
return Server_SendResult(file_des, INT32, NULL, 0);
}
@ -3531,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)
@ -3545,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
@ -11206,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

@ -7,7 +7,12 @@ support_lib = ../../slsSupportLib/include/
det_lib = ../../slsDetectorSoftware/include/sls/
md5_dir = ../../slsSupportLib/src/
CROSS = aarch64-none-linux-gnu-
ifeq ($(shell uname -m),aarch64)
# no cross compilation needed when on aarch64
CROSS =
else
CROSS = aarch64-none-linux-gnu-
endif
CC = $(CROSS)gcc
#TODO: allow these warnings and fix code
CFLAGS += -Wall -std=gnu99 -Wno-format-overflow -Wno-format-truncation -DXILINX_CHIPTESTBOARDD -DARMPROCESSOR -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(det_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE

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) {
@ -1056,7 +1049,7 @@ int getPower(enum DACINDEX ind) {
// dac powered off
if (dacValues[ind] == LTC2620_D_GetPowerDownValue()) {
LOG(logWARNING, ("Power V%s powered down\n", powerNames[pwrIndex]));
LOG(logWARNING, ("Power V%s is powered down\n", powerNames[pwrIndex]));
return LTC2620_D_GetPowerDownValue();
}

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

@ -1749,7 +1749,8 @@ class Detector {
Result<std::vector<int>> getRxDbitList(Positions pos = {}) const;
/** [CTB] list contains the set of digital signal bits (0-63) to save, must
* be non repetitive */
* be non repetitive. Note: data will be rearranged according to signal bits
*/
void setRxDbitList(const std::vector<int> &list, Positions pos = {});
/** [CTB] */
@ -1929,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,13 +1005,94 @@ 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) {
os << "[all] or [i0] [i1] [i2]... \n\t[Ctb] List of digital signal "
"bits read out. If all is used instead of a list, all digital "
"bits (64) enabled. Each element in list can be 0 - 63 and must "
"be non repetitive."
os << "[all] or [none] or [i0] [i1] [i2]... \n\t[Ctb] List of digital "
"signal bits enabled and rearranged according to the signals "
"(all samples of each signal is put together). If 'all' is used "
"instead of a list, all digital bits (64) enabled. Each element "
"in list can be 0 - 63 and must be non repetitive. The option "
"'none' will still spit out all data as is from the detector, "
"but without rearranging it. Please note that when using the "
"receiver list, the data size will be bigger if the number of "
"samples is not divisible by 8 as every signal bit is padded to "
"the next byte when combining all the samples in the receiver."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (!args.empty()) {
@ -1041,7 +1110,9 @@ std::string Caller::rx_dbitlist(int action) {
for (unsigned int i = 0; i < 64; ++i) {
t[i] = i;
}
} else {
}
// 'none' option already covered as t is empty by default
else if (args[0] != "none") {
unsigned int ntrim = args.size();
t.resize(ntrim);
for (unsigned int i = 0; i < ntrim; ++i) {

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

@ -79,7 +79,9 @@ class DetectorImpl : public virtual slsDetectorDefs {
explicit DetectorImpl(int detector_index = 0, bool verify = true,
bool update = true);
template <class CT> struct NonDeduced { using type = CT; };
template <class CT> struct NonDeduced {
using type = CT;
};
template <typename RT, typename... CT>
Result<RT> Parallel(RT (Module::*somefunc)(CT...),
std::vector<int> positions,

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

@ -130,7 +130,7 @@ extern "C" {
ll = (c)->D; \
(void)HOST_l2c(ll, (s)); \
} while (0)
#define ROTATE(a, n) (((a) << (n)) | (((a)&0xffffffff) >> (32 - (n))))
#define ROTATE(a, n) (((a) << (n)) | (((a) & 0xffffffff) >> (32 - (n))))
#if defined(DATA_ORDER_IS_BIG_ENDIAN)
#define HOST_c2l(c, l) \

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"