Merge branch 'developer' into jf_h5reader

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

View File

@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: awalsh128/cache-apt-pkgs-action@latest - uses: awalsh128/cache-apt-pkgs-action@latest
with: 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 version: 1.0
- name: Configure CMake - 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 2 On-board Detector Server Compatibility

View File

@ -11,6 +11,7 @@ cp build/install/lib/* $PREFIX/lib/
#Binaries #Binaries
cp build/install/bin/sls_detector_acquire $PREFIX/bin/. 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_get $PREFIX/bin/.
cp build/install/bin/sls_detector_put $PREFIX/bin/. cp build/install/bin/sls_detector_put $PREFIX/bin/.
cp build/install/bin/sls_detector_help $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) 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. are from the developer branch. Please use released tags for stability.
We have three different packages available: We have four different packages available:
============== =============================================
* **slsdetlib** shared libraries and command line utilities Package Description
* **slsdetgui** GUI ============== =============================================
* **slsdet** Python bindings slsdetlib shared libraries and command line utilities
slsdetgui GUI
slsdet Python bindings
moenchzmq moench
============== =============================================
.. code-block:: bash .. code-block:: bash
@ -43,7 +47,7 @@ We have three different packages available:
#ready to use #ready to use
sls_detector_get exptime sls_detector_get exptime
etc ... ...
.. code-block:: bash .. code-block:: bash
@ -55,6 +59,8 @@ We have three different packages available:
conda search slsdet conda search slsdet
# gui # gui
conda search slsdetgui 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 import pyctbgui.utils.pixelmap as pm
from pyctbgui.utils.recordOrApplyPedestal import recordOrApplyPedestal from pyctbgui.utils.recordOrApplyPedestal import recordOrApplyPedestal
from slsdet import detectorType
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
from pyctbgui.services import AcquisitionTab, PlotTab from pyctbgui.services import AcquisitionTab, PlotTab
@ -30,6 +32,7 @@ class AdcTab(QtWidgets.QWidget):
self.acquisitionTab: AcquisitionTab | None = None self.acquisitionTab: AcquisitionTab | None = None
self.legend: LegendItem | None = None self.legend: LegendItem | None = None
self.logger = logging.getLogger('AdcTab') self.logger = logging.getLogger('AdcTab')
self.tengiga = True
def setup_ui(self): def setup_ui(self):
self.plotTab = self.mainWindow.plotTab self.plotTab = self.mainWindow.plotTab
@ -42,6 +45,12 @@ class AdcTab(QtWidgets.QWidget):
self.legend.clear() self.legend.clear()
# subscribe to toggle legend # subscribe to toggle legend
self.plotTab.subscribeToggleLegend(self.updateLegend) 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): def initializeAllAnalogPlots(self):
self.mainWindow.plotAnalogWaveform = pg.plot() self.mainWindow.plotAnalogWaveform = pg.plot()
@ -67,7 +76,8 @@ class AdcTab(QtWidgets.QWidget):
def connect_ui(self): def connect_ui(self):
for i in range(Defines.adc.count): 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}En").stateChanged.connect(partial(self.setADCEnable, i))
getattr(self.view, f"checkBoxADC{i}Plot").stateChanged.connect(partial(self.setADCEnablePlot, 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)) 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.checkBoxADC0_15Plot.stateChanged.connect(partial(self.setADCEnablePlotRange, 0, Defines.adc.half))
self.view.checkBoxADC16_31Plot.stateChanged.connect( self.view.checkBoxADC16_31Plot.stateChanged.connect(
partial(self.setADCEnablePlotRange, Defines.adc.half, Defines.adc.count)) 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) 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): def refresh(self):
self.updateADCNames() self.updateADCNames()
self.updateADCInv() if self.det.type == detectorType.CHIPTESTBOARD:
self.updateADCInv()
self.updateADCEnable() self.updateADCEnable()
# ADCs Tab functions # ADCs Tab functions
@ -196,9 +208,11 @@ class AdcTab(QtWidgets.QWidget):
return decoder.decode(analog_array, pm.moench04_analog()) return decoder.decode(analog_array, pm.moench04_analog())
def getADCEnableReg(self): def getADCEnableReg(self):
retval = self.det.adcenable if self.det.type == detectorType.CHIPTESTBOARD:
if self.det.tengiga: self.tengiga = self.det.tengiga
retval = self.det.adcenable10g retval = self.det.adcenable10g
if not self.tengiga:
retval = self.det.adcenable
self.view.lineEditADCEnable.editingFinished.disconnect() self.view.lineEditADCEnable.editingFinished.disconnect()
self.view.lineEditADCEnable.setText("0x{:08x}".format(retval)) self.view.lineEditADCEnable.setText("0x{:08x}".format(retval))
self.view.lineEditADCEnable.editingFinished.connect(self.setADCEnableReg) self.view.lineEditADCEnable.editingFinished.connect(self.setADCEnableReg)
@ -207,8 +221,8 @@ class AdcTab(QtWidgets.QWidget):
def setADCEnableReg(self): def setADCEnableReg(self):
self.view.lineEditADCEnable.editingFinished.disconnect() self.view.lineEditADCEnable.editingFinished.disconnect()
try: try:
mask = int(self.mainWindow.lineEditADCEnable.text(), 16) mask = int(self.view.lineEditADCEnable.text(), 16)
if self.det.tengiga: if self.tengiga:
self.det.adcenable10g = mask self.det.adcenable10g = mask
else: else:
self.det.adcenable = mask self.det.adcenable = mask
@ -239,7 +253,7 @@ class AdcTab(QtWidgets.QWidget):
def setADCEnable(self, i): def setADCEnable(self, i):
checkBox = getattr(self.view, f"checkBoxADC{i}En") checkBox = getattr(self.view, f"checkBoxADC{i}En")
try: try:
if self.det.tengiga: if self.tengiga:
enableMask = manipulate_bit(checkBox.isChecked(), self.det.adcenable10g, i) enableMask = manipulate_bit(checkBox.isChecked(), self.det.adcenable10g, i)
self.det.adcenable10g = enableMask self.det.adcenable10g = enableMask
else: else:
@ -265,7 +279,7 @@ class AdcTab(QtWidgets.QWidget):
for i in range(start_nr, end_nr): for i in range(start_nr, end_nr):
mask = manipulate_bit(checkBox.isChecked(), mask, i) mask = manipulate_bit(checkBox.isChecked(), mask, i)
try: try:
if self.det.tengiga: if self.tengiga:
self.det.adcenable10g = mask self.det.adcenable10g = mask
else: else:
self.det.adcenable = mask self.det.adcenable = mask
@ -344,7 +358,7 @@ class AdcTab(QtWidgets.QWidget):
def setADCInvReg(self): def setADCInvReg(self):
self.view.lineEditADCInversion.editingFinished.disconnect() self.view.lineEditADCInversion.editingFinished.disconnect()
try: try:
self.det.adcinvert = int(self.mainWindow.lineEditADCInversion.text(), 16) self.det.adcinvert = int(self.view.lineEditADCInversion.text(), 16)
except Exception as e: except Exception as e:
QtWidgets.QMessageBox.warning(self.mainWindow, "ADC Inversion Fail", str(e), QtWidgets.QMessageBox.Ok) QtWidgets.QMessageBox.warning(self.mainWindow, "ADC Inversion Fail", str(e), QtWidgets.QMessageBox.Ok)
pass pass
@ -395,7 +409,12 @@ class AdcTab(QtWidgets.QWidget):
self.updateADCInv() self.updateADCInv()
def saveParameters(self) -> list[str]: def saveParameters(self) -> list[str]:
return [ if self.det.type == detectorType.CHIPTESTBOARD:
f"adcenable {self.view.lineEditADCEnable.text()}", return [
f"adcinvert {self.view.lineEditADCInversion.text()}", 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 from PyQt5 import QtWidgets, uic
import logging import logging
from slsdet import readoutMode, runStatus from slsdet import readoutMode, runStatus, detectorType
from pyctbgui.utils.defines import Defines from pyctbgui.utils.defines import Defines
from pyctbgui.utils.numpyWriter.npy_writer import NumpyFileManager from pyctbgui.utils.numpyWriter.npy_writer import NumpyFileManager
from pyctbgui.utils.numpyWriter.npz_writer import NpzFileWriter from pyctbgui.utils.numpyWriter.npz_writer import NpzFileWriter
@ -49,20 +49,37 @@ class AcquisitionTab(QtWidgets.QWidget):
self.adcTab = self.mainWindow.adcTab self.adcTab = self.mainWindow.adcTab
self.plotTab = self.mainWindow.plotTab self.plotTab = self.mainWindow.plotTab
self.toggleStartButton(False) 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): def connect_ui(self):
# For Acquistions Tab # For Acquistions Tab
self.view.comboBoxROMode.currentIndexChanged.connect(self.setReadOut) self.view.comboBoxROMode.currentIndexChanged.connect(self.setReadOut)
self.view.spinBoxRunF.editingFinished.connect(self.setRunFrequency)
self.view.spinBoxTransceiver.editingFinished.connect(self.setTransceiver) self.view.spinBoxTransceiver.editingFinished.connect(self.setTransceiver)
self.view.spinBoxAnalog.editingFinished.connect(self.setAnalog) self.view.spinBoxAnalog.editingFinished.connect(self.setAnalog)
self.view.spinBoxDigital.editingFinished.connect(self.setDigital) self.view.spinBoxDigital.editingFinished.connect(self.setDigital)
self.view.spinBoxADCF.editingFinished.connect(self.setADCFrequency)
self.view.spinBoxADCPhase.editingFinished.connect(self.setADCPhase) if self.det.type == detectorType.CHIPTESTBOARD:
self.view.spinBoxADCPipeline.editingFinished.connect(self.setADCPipeline) self.view.spinBoxRunF.editingFinished.connect(self.setRunFrequency)
self.view.spinBoxDBITF.editingFinished.connect(self.setDBITFrequency) self.view.spinBoxADCF.editingFinished.connect(self.setADCFrequency)
self.view.spinBoxDBITPhase.editingFinished.connect(self.setDBITPhase) self.view.spinBoxADCPhase.editingFinished.connect(self.setADCPhase)
self.view.spinBoxDBITPipeline.editingFinished.connect(self.setDBITPipeline) 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.checkBoxFileWriteRaw.stateChanged.connect(self.setFileWrite)
self.view.checkBoxFileWriteNumpy.stateChanged.connect(self.setFileWriteNumpy) self.view.checkBoxFileWriteNumpy.stateChanged.connect(self.setFileWriteNumpy)
@ -77,16 +94,19 @@ class AcquisitionTab(QtWidgets.QWidget):
def refresh(self): def refresh(self):
self.getReadout() self.getReadout()
self.getRunFrequency()
self.getTransceiver() self.getTransceiver()
self.getAnalog() self.getAnalog()
self.getDigital() self.getDigital()
self.getADCFrequency()
self.getADCPhase() if self.det.type == detectorType.CHIPTESTBOARD:
self.getADCPipeline() self.getRunFrequency()
self.getDBITFrequency() self.getADCFrequency()
self.getDBITPhase() self.getADCPhase()
self.getDBITPipeline() self.getADCPipeline()
self.getDBITFrequency()
self.getDBITPhase()
self.getDBITPipeline()
self.getFileWrite() self.getFileWrite()
self.getFileName() self.getFileName()
self.getFilePath() self.getFilePath()
@ -697,23 +717,39 @@ class AcquisitionTab(QtWidgets.QWidget):
self.socket.subscribe("") self.socket.subscribe("")
def saveParameters(self) -> list[str]: def saveParameters(self) -> list[str]:
return [ if self.det.type == detectorType.CHIPTESTBOARD:
f'romode {self.view.comboBoxROMode.currentText().lower()}', return [
f'runclk {self.view.spinBoxRunF.value()}', f'romode {self.view.comboBoxROMode.currentText().lower()}',
f'adcclk {self.view.spinBoxADCF.value()}', f'runclk {self.view.spinBoxRunF.value()}',
f'adcphase {self.view.spinBoxADCPhase.value()}', f'adcclk {self.view.spinBoxADCF.value()}',
f'adcpipeline {self.view.spinBoxADCPipeline.value()}', f'adcphase {self.view.spinBoxADCPhase.value()}',
f'dbitclk {self.view.spinBoxDBITF.value()}', f'adcpipeline {self.view.spinBoxADCPipeline.value()}',
f'dbitphase {self.view.spinBoxDBITPhase.value()}', f'dbitclk {self.view.spinBoxDBITF.value()}',
f'dbitpipeline {self.view.spinBoxDBITPipeline.value()}', f'dbitphase {self.view.spinBoxDBITPhase.value()}',
f'fwrite {int(self.view.checkBoxFileWriteRaw.isChecked())}', f'dbitpipeline {self.view.spinBoxDBITPipeline.value()}',
f'fname {self.view.lineEditFileName.text()}', f'fwrite {int(self.view.checkBoxFileWriteRaw.isChecked())}',
f'fpath {self.view.lineEditFilePath.text()}', f'fname {self.view.lineEditFileName.text()}',
f'findex {self.view.spinBoxAcquisitionIndex.value()}', f'fpath {self.view.lineEditFilePath.text()}',
f'frames {self.view.spinBoxFrames.value()}', f'findex {self.view.spinBoxAcquisitionIndex.value()}',
f'triggers {self.view.spinBoxTriggers.value()}', f'frames {self.view.spinBoxFrames.value()}',
f'period {self.view.spinBoxPeriod.value()} {self.view.comboBoxPeriod.currentText().lower()}', f'triggers {self.view.spinBoxTriggers.value()}',
f'asamples {self.view.spinBoxAnalog.value()}', f'period {self.view.spinBoxPeriod.value()} {self.view.comboBoxPeriod.currentText().lower()}',
f'dsamples {self.view.spinBoxDigital.value()}', f'asamples {self.view.spinBoxAnalog.value()}',
f'tsamples {self.view.spinBoxTransceiver.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 PyQt5 import QtWidgets, uic
from pyctbgui.utils.defines import Defines from pyctbgui.utils.defines import Defines
from slsdet import dacIndex from slsdet import dacIndex, detectorType
class DacTab(QtWidgets.QWidget): class DacTab(QtWidgets.QWidget):
@ -19,7 +19,14 @@ class DacTab(QtWidgets.QWidget):
dac = getattr(dacIndex, f"DAC_{i}") dac = getattr(dacIndex, f"DAC_{i}")
getattr(self.view, f"spinBoxDAC{i}").setValue(self.det.getDAC(dac)[0]) 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.spinBoxHighVoltage.setDisabled(True)
self.view.checkBoxHighVoltage.setChecked(False) 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}").stateChanged.connect(partial(self.setDACTristate, i))
getattr(self.view, f"checkBoxDAC{i}mV").stateChanged.connect(partial(self.getDAC, i)) getattr(self.view, f"checkBoxDAC{i}mV").stateChanged.connect(partial(self.getDAC, i))
self.view.comboBoxADCVpp.currentIndexChanged.connect(self.setADCVpp) if self.view.comboBoxADCVpp.isEnabled():
self.view.spinBoxHighVoltage.editingFinished.connect(self.setHighVoltage) self.view.comboBoxADCVpp.currentIndexChanged.connect(self.setADCVpp)
self.view.checkBoxHighVoltage.stateChanged.connect(self.setHighVoltage) if self.view.checkBoxHighVoltage.isEnabled():
self.view.spinBoxHighVoltage.editingFinished.connect(self.setHighVoltage)
self.view.checkBoxHighVoltage.stateChanged.connect(self.setHighVoltage)
def refresh(self): def refresh(self):
self.updateDACNames() self.updateDACNames()
@ -40,8 +49,10 @@ class DacTab(QtWidgets.QWidget):
self.getDACTristate(i) self.getDACTristate(i)
self.getDAC(i) self.getDAC(i)
self.getADCVpp() if self.view.comboBoxADCVpp.isEnabled():
self.getHighVoltage() self.getADCVpp()
if self.view.checkBoxHighVoltage.isEnabled():
self.getHighVoltage()
def updateDACNames(self): def updateDACNames(self):
for i, name in enumerate(self.det.getDacNames()): for i, name in enumerate(self.det.getDacNames()):
@ -165,6 +176,8 @@ class DacTab(QtWidgets.QWidget):
unit = " mV" if inMV else "" unit = " mV" if inMV else ""
commands.append(f"dac {i} {value}{unit}") commands.append(f"dac {i} {value}{unit}")
commands.append(f"adcvpp {self.view.comboBoxADCVpp.currentText()} mV") if self.view.comboBoxADCVpp.isEnabled():
commands.append(f"highvoltage {self.view.spinBoxHighVoltage.value()}") commands.append(f"adcvpp {self.view.comboBoxADCVpp.currentText()} mV")
if self.view.checkBoxHighVoltage.isEnabled():
commands.append(f"highvoltage {self.view.spinBoxHighVoltage.value()}")
return commands 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.defines import Defines
from pyctbgui.utils.plotPattern import PlotPattern from pyctbgui.utils.plotPattern import PlotPattern
from slsdet import DurationWrapper
class PatternTab(QtWidgets.QWidget): 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"lineEditLoop{i}Wait").editingFinished.connect(partial(self.setPatLoopWaitAddress, i))
getattr(self.view, getattr(self.view,
f"spinBoxLoop{i}Repetition").editingFinished.connect(partial(self.setPatLoopRepetition, i)) 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.pushButtonCompiler.clicked.connect(self.setCompiler)
self.view.pushButtonUncompiled.clicked.connect(self.setUncompiledPatternFile) self.view.pushButtonUncompiled.clicked.connect(self.setUncompiledPatternFile)
self.view.pushButtonPatternFile.clicked.connect(self.setPatternFile) self.view.pushButtonPatternFile.clicked.connect(self.setPatternFile)
@ -91,7 +95,8 @@ class PatternTab(QtWidgets.QWidget):
self.getPatLoopStartStopAddress(i) self.getPatLoopStartStopAddress(i)
self.getPatLoopWaitAddress(i) self.getPatLoopWaitAddress(i)
self.getPatLoopRepetition(i) self.getPatLoopRepetition(i)
self.getPatLoopWaitTime(i) self.getPatLoopWaitClocks(i)
self.getPatLoopWaitInterval(i)
# Pattern Tab functions # Pattern Tab functions
@ -182,17 +187,67 @@ class PatternTab(QtWidgets.QWidget):
self.det.patnloop[level] = spinBox.value() self.det.patnloop[level] = spinBox.value()
self.getPatLoopRepetition(level) self.getPatLoopRepetition(level)
def getPatLoopWaitTime(self, level): def getPatLoopWaitClocks(self, level):
retval = self.det.patwaittime[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.editingFinished.disconnect()
spinBox.setValue(retval) 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): def setCompiler(self):
response = QtWidgets.QFileDialog.getOpenFileName( response = QtWidgets.QFileDialog.getOpenFileName(
@ -450,7 +505,7 @@ class PatternTab(QtWidgets.QWidget):
f"{getattr(self.view, f'lineEditLoop{i}Stop').text()}") 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"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"patlimits {self.view.lineEditStartAddress.text()}, {self.view.lineEditStopAddress.text()}")
# commands.append(f"patfname {self.view.lineEditPatternFile.text()}") # commands.append(f"patfname {self.view.lineEditPatternFile.text()}")
return commands return commands

View File

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

View File

@ -4,7 +4,7 @@ from pathlib import Path
from PyQt5 import uic, QtWidgets from PyQt5 import uic, QtWidgets
from pyctbgui.utils.defines import Defines from pyctbgui.utils.defines import Defines
from slsdet import dacIndex from slsdet import dacIndex, detectorType
class SlowAdcTab(QtWidgets.QWidget): class SlowAdcTab(QtWidgets.QWidget):
@ -17,7 +17,8 @@ class SlowAdcTab(QtWidgets.QWidget):
self.det = None self.det = None
def setup_ui(self): def setup_ui(self):
pass if self.det.type == detectorType.XILINX_CHIPTESTBOARD:
self.view.pushButtonTemp.setDisabled(True)
def connect_ui(self): def connect_ui(self):
for i in range(Defines.slowAdc.count): for i in range(Defines.slowAdc.count):
@ -28,7 +29,8 @@ class SlowAdcTab(QtWidgets.QWidget):
self.updateSlowAdcNames() self.updateSlowAdcNames()
for i in range(Defines.slowAdc.count): for i in range(Defines.slowAdc.count):
self.updateSlowAdc(i) self.updateSlowAdc(i)
self.updateTemperature() if self.det.type == detectorType.CHIPTESTBOARD:
self.updateTemperature()
def updateSlowAdcNames(self): def updateSlowAdcNames(self):
for i, name in enumerate(self.mainWindow.det.getSlowADCNames()): 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> </widget>
</item> </item>
<item row="18" column="0"> <item row="18" column="0">
<widget class="QLabel" name="label_125"> <widget class="QLabel" name="labelADCVppDacName">
<property name="text"> <property name="text">
<string>ADC_VPP</string> <string>ADC_VPP</string>
</property> </property>

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -3702,7 +3702,13 @@ class Detector(CppDetectorApi):
@property @property
def patwaittime(self): 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 Example
------- -------
@ -3713,41 +3719,85 @@ class Detector(CppDetectorApi):
0: 5 0: 5
1: 20 1: 20
2: 30 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) 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 create_patwaittime_property(level):
def patwaittime0(self, nclk): docstring_template ="""
nclk = ut.merge_args(0, nclk) Deprecated command. Use patwaittime instead.
ut.set_using_dict(self.setPatternWaitTime, *nclk) [Ctb][Mythen3][Xilinx Ctb] Wait time in clock cycles of loop level {level} provided.
@property Info
@element ----
def patwaittime1(self):
"""[Ctb][Mythen3][Xilinx Ctb] Wait 1 time in clock cycles."""
return self.getPatternWaitTime(1)
@patwaittime1.setter :getter: Always return in clock cycles. To get in DurationWrapper, use getPatternWaitInterval
def patwaittime1(self, nclk): :setter: Accepts either a value in clock cycles or a time unit (timedelta, DurationWrapper)
nclk = ut.merge_args(1, nclk)
ut.set_using_dict(self.setPatternWaitTime, *nclk) 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 @patwaittime.setter
@element def patwaittime(self, value):
def patwaittime2(self): if isinstance(value, (int, float)) and not isinstance(value, bool):
"""[Ctb][Mythen3][Xilinx Ctb] Wait 2 time in clock cycles.""" nclk = ut.merge_args(level, value)
return self.getPatternWaitTime(2) 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 return patwaittime
def patwaittime2(self, nclk):
nclk = ut.merge_args(2, nclk) patwaittime0 = create_patwaittime_property(0)
ut.set_using_dict(self.setPatternWaitTime, *nclk) patwaittime1 = create_patwaittime_property(1)
patwaittime2 = create_patwaittime_property(2)
@property @property

View File

@ -275,10 +275,13 @@ class PatWaitTimeProxy:
self.det = det self.det = det
def __getitem__(self, key): 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): 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): def __repr__(self):
max_levels = MAX_PATTERN_LEVELS max_levels = MAX_PATTERN_LEVELS

View File

@ -1861,13 +1861,22 @@ void init_det(py::module &m) {
Detector::setPatternWaitAddr, Detector::setPatternWaitAddr,
py::arg(), py::arg(), py::arg() = Positions{}); py::arg(), py::arg(), py::arg() = Positions{});
CppDetectorApi.def( CppDetectorApi.def(
"getPatternWaitTime", "getPatternWaitClocks",
(Result<uint64_t>(Detector::*)(int, sls::Positions) const) & (Result<uint64_t>(Detector::*)(int, sls::Positions) const) &
Detector::getPatternWaitTime, Detector::getPatternWaitClocks,
py::arg(), py::arg() = Positions{}); py::arg(), py::arg() = Positions{});
CppDetectorApi.def("setPatternWaitTime", CppDetectorApi.def("setPatternWaitClocks",
(void (Detector::*)(int, uint64_t, sls::Positions)) & (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{}); py::arg(), py::arg(), py::arg() = Positions{});
CppDetectorApi.def("getPatternMask", CppDetectorApi.def("getPatternMask",
(Result<uint64_t>(Detector::*)(sls::Positions)) & (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> template <class S, typename RT, typename... CT>
static void HandleExceptions(const std::string emsg, const std::string src, static void HandleExceptions(const std::string emsg, const std::string src,
S *s, RT (S::*somefunc)(CT...), S *s, RT (S::*somefunc)(CT...),

View File

@ -1095,26 +1095,17 @@ int setNumTransceiverSamples(int val) {
int getNumTransceiverSamples() { return ntSamples; } int getNumTransceiverSamples() { return ntSamples; }
int setExpTime(int64_t val) { int setExpTime(int64_t val) {
if (val < 0) { setPatternWaitInterval(0, val);
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);
// validate for tolerance // validate for tolerance
int64_t retval = getExpTime(); int64_t retval = getExpTime();
val /= (1E-3 * clkFrequency[RUN_CLK]);
if (val != retval) { if (val != retval) {
return FAIL; return FAIL;
} }
return OK; return OK;
} }
int64_t getExpTime() { int64_t getExpTime() { return getPatternWaitInterval(0); }
return getPatternWaitTime(0) / (1E-3 * clkFrequency[RUN_CLK]);
}
int setPeriod(int64_t val) { int setPeriod(int64_t val) {
if (val < 0) { if (val < 0) {

View File

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

View File

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

View File

@ -2,7 +2,7 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once #pragma once
//#include "types.h" // #include "types.h"
#include <stdint.h> #include <stdint.h>
/******************************************************************************/ /******************************************************************************/
/* types */ /* 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 #define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_HIGHADDR 0xC410FFFF
/* Definitions for a new memory */ /* 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 */ /* Definitions for peripheral PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT */
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR 0xC4110000 #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) ((0x1 << GAIN_CONFGAIN_OFST) & GAIN_CONFGAIN_MSK)
/** Flow Control register */ /** Flow Control register */
//#define FLOW_CONTROL_REG (0x11 << MEM_MAP_SHIFT) // #define FLOW_CONTROL_REG (0x11 << MEM_MAP_SHIFT)
/** Flow Status register */ /** Flow Status register */
//#define FLOW_STATUS_REG (0x12 << MEM_MAP_SHIFT) // #define FLOW_STATUS_REG (0x12 << MEM_MAP_SHIFT)
/** Frame register */ /** Frame register */
//#define FRAME_REG (0x13 << MEM_MAP_SHIFT) // #define FRAME_REG (0x13 << MEM_MAP_SHIFT)
/** Multi Purpose register */ /** Multi Purpose register */
#define MULTI_PURPOSE_REG (0x14 << MEM_MAP_SHIFT) #define MULTI_PURPOSE_REG (0x14 << MEM_MAP_SHIFT)
@ -79,7 +79,7 @@
((0x0007f << DAQ_PCKT_LNGTH_OFST) & DAQ_PCKT_LNGTH_MSK) ((0x0007f << DAQ_PCKT_LNGTH_OFST) & DAQ_PCKT_LNGTH_MSK)
/** Time From Start register */ /** 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 */ /** DAC Control register */
#define SPI_REG (0x17 << MEM_MAP_SHIFT) #define SPI_REG (0x17 << MEM_MAP_SHIFT)
@ -139,7 +139,7 @@
((0x1b << ADC_SYNC_ENET_DELAY_OFST) & ADC_SYNC_ENET_DELAY_MSK) ((0x1b << ADC_SYNC_ENET_DELAY_OFST) & ADC_SYNC_ENET_DELAY_MSK)
/** Time From Start register */ /** Time From Start register */
//#define MU_TIME_REG (0x1a << MEM_MAP_SHIFT) // #define MU_TIME_REG (0x1a << MEM_MAP_SHIFT)
/** Temperatre SPI In register */ /** Temperatre SPI In register */
#define TEMP_SPI_IN_REG (0x1b << MEM_MAP_SHIFT) #define TEMP_SPI_IN_REG (0x1b << MEM_MAP_SHIFT)
@ -171,7 +171,7 @@
#define ENET_CONF_REG (0x1e << MEM_MAP_SHIFT) #define ENET_CONF_REG (0x1e << MEM_MAP_SHIFT)
/** Write TSE Shadow register */ /** 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 */ /** High Voltage register */
#define HV_REG (0x20 << MEM_MAP_SHIFT) #define HV_REG (0x20 << MEM_MAP_SHIFT)
@ -288,10 +288,10 @@
((0x4 << EXT_SIGNAL_OFST) & EXT_SIGNAL_MSK) ((0x4 << EXT_SIGNAL_OFST) & EXT_SIGNAL_MSK)
/** Look at me register */ /** 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 */ /** FPGA SVN register */
//#define FPGA_SVN_REG (0x29 << MEM_MAP_SHIFT) // #define FPGA_SVN_REG (0x29 << MEM_MAP_SHIFT)
/** Chip of Interest register */ /** Chip of Interest register */
#define CHIP_OF_INTRST_REG (0x2a << MEM_MAP_SHIFT) #define CHIP_OF_INTRST_REG (0x2a << MEM_MAP_SHIFT)
@ -303,7 +303,7 @@
(0x0000FFFF << CHIP_OF_INTRST_NUM_CHNNLS_OFST) (0x0000FFFF << CHIP_OF_INTRST_NUM_CHNNLS_OFST)
/** Out MUX register */ /** Out MUX register */
//#define OUT_MUX_REG (0x2b << MEM_MAP_SHIFT) // #define OUT_MUX_REG (0x2b << MEM_MAP_SHIFT)
/** Board Version register */ /** Board Version register */
#define BOARD_REVISION_REG (0x2c << MEM_MAP_SHIFT) #define BOARD_REVISION_REG (0x2c << MEM_MAP_SHIFT)
@ -312,29 +312,29 @@
#define BOARD_REVISION_MSK (0x0000FFFF << BOARD_REVISION_OFST) #define BOARD_REVISION_MSK (0x0000FFFF << BOARD_REVISION_OFST)
#define DETECTOR_TYPE_OFST (16) #define DETECTOR_TYPE_OFST (16)
#define DETECTOR_TYPE_MSK (0x0000000F << DETECTOR_TYPE_OFST) #define DETECTOR_TYPE_MSK (0x0000000F << DETECTOR_TYPE_OFST)
//#define DETECTOR_TYPE_GOTTHARD_VAL (??) // #define DETECTOR_TYPE_GOTTHARD_VAL (??)
#define DETECTOR_TYPE_MOENCH_VAL (2) #define DETECTOR_TYPE_MOENCH_VAL (2)
/** Memory Test register */ /** Memory Test register */
//#define MEMORY_TEST_REG (0x2d << MEM_MAP_SHIFT) // #define MEMORY_TEST_REG (0x2d << MEM_MAP_SHIFT)
/** Hit Threshold register */ /** Hit Threshold register */
//#define HIT_THRESHOLD_REG (0x2e << MEM_MAP_SHIFT) // #define HIT_THRESHOLD_REG (0x2e << MEM_MAP_SHIFT)
/** Hit Count register */ /** Hit Count register */
//#define HIT_COUNT_REG (0x2f << MEM_MAP_SHIFT) // #define HIT_COUNT_REG (0x2f << MEM_MAP_SHIFT)
/* 16 bit Fifo Data register */ /* 16 bit Fifo Data register */
#define FIFO_DATA_REG (0x50 << MEM_MAP_SHIFT) // Not used in FW and SW (16bit) #define FIFO_DATA_REG (0x50 << MEM_MAP_SHIFT) // Not used in FW and SW (16bit)
/** Dacs Set 1 register */ /** 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 */ /** 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 */ /** 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 */ /* Set Delay 64 bit register */
#define SET_DELAY_LSB_REG (0x68 << MEM_MAP_SHIFT) #define SET_DELAY_LSB_REG (0x68 << MEM_MAP_SHIFT)
@ -377,12 +377,12 @@
#define GET_EXPTIME_MSB_REG (0x7b << MEM_MAP_SHIFT) #define GET_EXPTIME_MSB_REG (0x7b << MEM_MAP_SHIFT)
/* Set Gates 64 bit register */ /* Set Gates 64 bit register */
//#define SET_GATES_LSB_REG (0x7c << MEM_MAP_SHIFT) // #define SET_GATES_LSB_REG (0x7c << MEM_MAP_SHIFT)
//#define SET_GATES_MSB_REG (0x7d << MEM_MAP_SHIFT) // #define SET_GATES_MSB_REG (0x7d << MEM_MAP_SHIFT)
/* Set Gates 64 bit register */ /* Set Gates 64 bit register */
//#define GET_GATES_LSB_REG (0x7e << MEM_MAP_SHIFT) // #define GET_GATES_LSB_REG (0x7e << MEM_MAP_SHIFT)
//#define GET_GATES_MSB_REG (0x7f << MEM_MAP_SHIFT) // #define GET_GATES_MSB_REG (0x7f << MEM_MAP_SHIFT)
/* Dark Image starting address */ /* Dark Image starting address */
#define DARK_IMAGE_REG (0x81 << MEM_MAP_SHIFT) #define DARK_IMAGE_REG (0x81 << MEM_MAP_SHIFT)

View File

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

View File

@ -38,11 +38,11 @@
#define CSR_invpol 4 #define CSR_invpol 4
#define CSR_dpulse 5 #define CSR_dpulse 5
#define CSR_interp 6 #define CSR_interp 6
#define _CSR_C10pre 7 //#default, negative polarity #define _CSR_C10pre 7 // #default, negative polarity
#define CSR_pumprobe 8 #define CSR_pumprobe 8
#define CSR_apulse 9 #define CSR_apulse 9
#define CSR_C15sh 10 #define CSR_C15sh 10
#define CSR_C30sh 11 //#default #define CSR_C30sh 11 // #default
#define CSR_C50sh 12 #define CSR_C50sh 12
#define CSR_C225ACsh \ #define CSR_C225ACsh \
13 // Connects 225fF SHAPER AC cap (1: 225 to shaper, 225 to GND. 0: 450 to 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); int validate_setPatternWaitAddresses(char *message, int level, int addr);
void setPatternWaitAddress(int level, int addr); 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 getPatternWaitTime(int level); uint64_t *waittime, int clocks);
int validate_setPatternWaitTime(char *message, int level, uint64_t waittime); uint64_t getPatternWaitClocks(int level);
void setPatternWaitTime(int level, uint64_t t); 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 validate_getPatternLoopCycles(char *message, int level, int *numLoops);
int getPatternLoopCycles(int level); 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_addresses(int);
int set_pattern_loop_cycles(int); int set_pattern_loop_cycles(int);
int set_pattern_wait_addr(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 set_pattern_mask(int);
int get_pattern_mask(int); int get_pattern_mask(int);
int set_pattern_bit_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 set_timing_info_decoder(int);
int get_collection_mode(int); int get_collection_mode(int);
int set_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) (0x0000FFFF << I2C_SDA_HOLD_COUNT_PERIOD_OFST)
/** Receive Data Fifo Level register */ /** Receive Data Fifo Level register */
//#define I2C_RX_DATA_FIFO_LVL_OFST (0) // #define I2C_RX_DATA_FIFO_LVL_OFST (0)
//#define I2C_RX_DATA_FIFO_LVL_MSK (0x000000FF << // #define I2C_RX_DATA_FIFO_LVL_MSK (0x000000FF <<
// I2C_RX_DATA_FIFO_LVL_OFST) // I2C_RX_DATA_FIFO_LVL_OFST)
// defines in the fpga // defines in the fpga
uint32_t I2C_Control_Reg = 0x0; 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); inet_ntop(AF_INET, &ip, cip, INET_ADDRSTRLEN);
#else #else
sprintf(cip, "%d.%d.%d.%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff, sprintf(cip, "%d.%d.%d.%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff,
(ip >> 8) & 0xff, (ip)&0xff); (ip >> 8) & 0xff, (ip) & 0xff);
#endif #endif
} }

View File

@ -11,6 +11,10 @@
#ifdef MYTHEN3D #ifdef MYTHEN3D
extern enum TLogLevel trimmingPrint; extern enum TLogLevel trimmingPrint;
extern uint32_t clkDivider[];
#endif
#ifdef CHIPTESTBOARDD
extern uint32_t clkFrequency[];
#endif #endif
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) #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 // validate input
if (level < 0 || level >= MAX_LEVELS) { if (level < 0 || level >= MAX_LEVELS) {
sprintf(message, sprintf(message,
@ -326,11 +331,15 @@ int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime) {
LOG(logERROR, (message)); LOG(logERROR, (message));
return FAIL; return FAIL;
} }
*waittime = getPatternWaitTime(level); if (clocks) {
*waittime = getPatternWaitClocks(level);
} else {
*waittime = getPatternWaitInterval(level);
}
return OK; return OK;
} }
uint64_t getPatternWaitTime(int level) { uint64_t getPatternWaitClocks(int level) {
switch (level) { switch (level) {
case 0: case 0:
return getU64BitReg(PATTERN_WAIT_TIMER_0_LSB_REG, 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 // validate input
if (level < 0 || level >= MAX_LEVELS) { if (level < 0 || level >= MAX_LEVELS) {
sprintf(message, sprintf(message,
@ -367,12 +394,21 @@ int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) {
return FAIL; 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; int ret = OK;
char mode[128]; char mode[128];
memset(mode, 0, sizeof(mode)); memset(mode, 0, sizeof(mode));
@ -381,13 +417,13 @@ int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) {
return ret; return ret;
} }
void setPatternWaitTime(int level, uint64_t t) { void setPatternWaitClocks(int level, uint64_t t) {
#ifdef MYTHEN3D #ifdef MYTHEN3D
LOG(trimmingPrint, LOG(trimmingPrint,
#else #else
LOG(logINFO, LOG(logINFO,
#endif #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)); (long long int)t));
switch (level) { switch (level) {
case 0: 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) { int validate_getPatternLoopCycles(char *message, int level, int *numLoops) {
// validate input // validate input
if (level < 0 || level >= MAX_LEVELS) { if (level < 0 || level >= MAX_LEVELS) {
@ -830,7 +886,8 @@ int loadPattern(char *message, enum TLogLevel printLevel,
} }
// wait time // wait time
ret = validate_setPatternWaitTime(message, i, pat->waittime[i]); ret = validate_setPatternWaitClocksAndInterval(message, i,
pat->waittime[i], 1);
if (ret == FAIL) { if (ret == FAIL) {
break; break;
} }
@ -894,7 +951,8 @@ int getPattern(char *message, patternParameters *pat) {
pat->wait[i] = retval1; pat->wait[i] = retval1;
// wait time // wait time
ret = validate_getPatternWaitTime(message, i, &retval64); ret = validate_getPatternWaitClocksAndInterval(message, i,
&retval64, 1);
if (ret == FAIL) { if (ret == FAIL) {
break; break;
} }
@ -1095,7 +1153,8 @@ int loadPatternFile(char *patFname, char *errMessage) {
break; break;
} }
if (validate_setPatternWaitTime(temp, level, waittime) == FAIL) { if (validate_setPatternWaitClocksAndInterval(temp, level, waittime,
1) == FAIL) {
break; 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_ADDRESSES] = &set_pattern_loop_addresses;
flist[F_SET_PATTERN_LOOP_CYCLES] = &set_pattern_loop_cycles; 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_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_SET_PATTERN_MASK] = &set_pattern_mask;
flist[F_GET_PATTERN_MASK] = &get_pattern_mask; flist[F_GET_PATTERN_MASK] = &get_pattern_mask;
flist[F_SET_PATTERN_BIT_MASK] = &set_pattern_bit_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_SET_TIMING_INFO_DECODER] = &set_timing_info_decoder;
flist[F_GET_COLLECTION_MODE] = &get_collection_mode; flist[F_GET_COLLECTION_MODE] = &get_collection_mode;
flist[F_SET_COLLECTION_MODE] = &set_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 // check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
LOG(logERROR, ("The last detector function enum has reached its " LOG(logERROR, ("The last detector function enum has reached its "
@ -2013,102 +2014,106 @@ int acquire(int blocking, int file_des) {
#if defined(JUNGFRAUD) #if defined(JUNGFRAUD)
// chipv1.1 has to be configured before acquisition // chipv1.1 has to be configured before acquisition
if (getChipVersion() == 11 && !isChipConfigured()) { if (getChipVersion() == 11 && !isChipConfigured()) {
ret = FAIL; ret = FAIL;
strcpy(mess, "Could not start acquisition. Chip is not configured. " strcpy(mess,
"Power it on to configure it.\n"); "Could not start acquisition. Chip is not configured. "
LOG(logERROR, (mess)); "Power it on to configure it.\n");
} else LOG(logERROR, (mess));
} else
#endif #endif
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) #if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
if ((getReadoutMode() == ANALOG_AND_DIGITAL || if ((getReadoutMode() == ANALOG_AND_DIGITAL ||
getReadoutMode() == ANALOG_ONLY) && getReadoutMode() == ANALOG_ONLY) &&
(getNumAnalogSamples() <= 0)) { (getNumAnalogSamples() <= 0)) {
ret = FAIL; ret = FAIL;
sprintf(mess, sprintf(mess,
"Could not start acquisition. Invalid number of analog " "Could not start acquisition. Invalid number of analog "
"samples: %d.\n", "samples: %d.\n",
getNumAnalogSamples()); getNumAnalogSamples());
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else if ((getReadoutMode() == ANALOG_AND_DIGITAL || } else if ((getReadoutMode() == ANALOG_AND_DIGITAL ||
getReadoutMode() == DIGITAL_ONLY || getReadoutMode() == DIGITAL_ONLY ||
getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && getReadoutMode() == DIGITAL_AND_TRANSCEIVER) &&
(getNumDigitalSamples() <= 0)) { (getNumDigitalSamples() <= 0)) {
ret = FAIL; ret = FAIL;
sprintf(mess, sprintf(
mess,
"Could not start acquisition. Invalid number of digital " "Could not start acquisition. Invalid number of digital "
"samples: %d.\n", "samples: %d.\n",
getNumDigitalSamples()); getNumDigitalSamples());
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else if ((getReadoutMode() == TRANSCEIVER_ONLY || } else if ((getReadoutMode() == TRANSCEIVER_ONLY ||
getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && getReadoutMode() == DIGITAL_AND_TRANSCEIVER) &&
(getNumTransceiverSamples() <= 0)) { (getNumTransceiverSamples() <= 0)) {
ret = FAIL; ret = FAIL;
sprintf(mess, sprintf(mess,
"Could not start acquisition. Invalid number of " "Could not start acquisition. Invalid number of "
"transceiver " "transceiver "
"samples: %d.\n", "samples: %d.\n",
getNumTransceiverSamples()); getNumTransceiverSamples());
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else } else
#endif #endif
#ifdef EIGERD #ifdef EIGERD
// check for hardware mac and hardware ip // check for hardware mac and hardware ip
if (udpDetails[0].srcmac != getDetectorMAC()) { if (udpDetails[0].srcmac != getDetectorMAC()) {
ret = FAIL; ret = FAIL;
uint64_t sourcemac = getDetectorMAC(); uint64_t sourcemac = getDetectorMAC();
char src_mac[MAC_ADDRESS_SIZE]; char src_mac[MAC_ADDRESS_SIZE];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
sprintf(mess, sprintf(mess,
"Invalid udp source mac address for this detector. " "Invalid udp source mac address for this detector. "
"Must be " "Must be "
"same as hardware detector mac address %s\n", "same as hardware detector mac address %s\n",
src_mac); src_mac);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else if (!enableTenGigabitEthernet(GET_FLAG) && } else if (!enableTenGigabitEthernet(GET_FLAG) &&
(udpDetails[0].srcip != getDetectorIP())) { (udpDetails[0].srcip != getDetectorIP())) {
ret = FAIL; ret = FAIL;
uint32_t sourceip = getDetectorIP(); uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN]; char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip); getIpAddressinString(src_ip, sourceip);
sprintf(mess, sprintf(
"Invalid udp source ip address for this detector. Must " mess,
"be " "Invalid udp source ip address for this detector. Must "
"same as hardware detector ip address %s in 1G readout " "be "
"mode \n", "same as hardware detector ip address %s in 1G readout "
src_ip); "mode \n",
LOG(logERROR, (mess)); src_ip);
} else LOG(logERROR, (mess));
#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 } 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); 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)); 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; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
uint64_t args[2] = {-1, -1}; uint64_t args[2] = {-1, -1};
uint64_t retval = -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(); return printSocketReadError();
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \ #if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D) !defined(MYTHEN3D)
@ -3545,16 +3550,23 @@ int set_pattern_wait_time(int file_des) {
#else #else
int loopLevel = (int)args[0]; int loopLevel = (int)args[0];
uint64_t timeval = args[1]; uint64_t timeval = args[1];
LOG(logDEBUG1, ("Setting Pattern wait time (loopLevel:%d timeval:0x%llx)\n", LOG(logDEBUG1,
loopLevel, (long long int)timeval)); ("Setting Pattern wait clocks (loopLevel:%d clocks:0x%lld)\n",
loopLevel, (long long int)timeval));
if (((int64_t)timeval == GET_FLAG) || (Server_VerifyLock() == OK)) { if (((int64_t)timeval == GET_FLAG) || (Server_VerifyLock() == OK)) {
// set // set
if ((int64_t)timeval != GET_FLAG) { if ((int64_t)timeval != GET_FLAG) {
ret = validate_setPatternWaitTime(mess, loopLevel, timeval); ret = validate_setPatternWaitClocksAndInterval(mess, loopLevel,
timeval, 1);
} }
// get // get
if (ret == OK) { 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 #endif
@ -11206,3 +11218,54 @@ int set_collection_mode(int file_des) {
#endif #endif
return Server_SendResult(file_des, INT32, NULL, 0); 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/ det_lib = ../../slsDetectorSoftware/include/sls/
md5_dir = ../../slsSupportLib/src/ 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 CC = $(CROSS)gcc
#TODO: allow these warnings and fix code #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 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) { int setExpTime(int64_t val) {
if (val < 0) { setPatternWaitInterval(0, val);
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);
// validate for tolerance // validate for tolerance
int64_t retval = getExpTime(); int64_t retval = getExpTime();
val /= (1E-3 * RUN_CLK);
if (val != retval) { if (val != retval) {
return FAIL; return FAIL;
} }
return OK; return OK;
} }
int64_t getExpTime() { return getPatternWaitTime(0) / (1E-3 * RUN_CLK); } int64_t getExpTime() { return getPatternWaitInterval(0); }
int setPeriod(int64_t val) { int setPeriod(int64_t val) {
if (val < 0) { if (val < 0) {
@ -1056,7 +1049,7 @@ int getPower(enum DACINDEX ind) {
// dac powered off // dac powered off
if (dacValues[ind] == LTC2620_D_GetPowerDownValue()) { 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(); return LTC2620_D_GetPowerDownValue();
} }

View File

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

View File

@ -2656,6 +2656,44 @@ slowadc:
argc: 1 argc: 1
arg_types: [ int ] 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: rx_dbitlist:
is_description: true is_description: true
actions: actions:
@ -3930,34 +3968,34 @@ patlimits:
patloop: 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." 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: actions:
GET: GET:
argc: -1 argc: 1
pattern_command:
command_name: patloop
nGetArgs: 0
nPutArgs: 2
require_det_id: true require_det_id: true
function: getPatternLoopAddresses function: getPatternLoopAddresses
extra_variables:
- name: level
type: int
value: "StringTo<int>(args[0])"
input: [ level ] input: [ level ]
input_types: [ int ] input_types: [ int ]
cast_input: [ false ]
output: [level,"' '" ,"OutStringHex(t, 4)" ] output: [level,"' '" ,"OutStringHex(t, 4)" ]
PUT: PUT:
argc: -1 argc: 3
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
require_det_id: true require_det_id: true
function: setPatternLoopAddresses 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: [ level, start, stop ]
input_types: [ int, int, int ] input_types: [ int, int, int ]
output: [level,"' '" , "'['" , "ToStringHex(start, 4)" , '", "' , "ToStringHex(stop, 4)", "']'" ] output: [level,"' '" , "'['" , "ToStringHex(start, 4)" , '", "' , "ToStringHex(stop, 4)", "']'" ]
@ -3979,34 +4017,33 @@ patloop2:
patnloop: 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." 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: actions:
GET: GET:
argc: -1 argc: 1
pattern_command:
command_name: patnloop
nGetArgs: 0
nPutArgs: 1
require_det_id: true require_det_id: true
function: getPatternLoopCycles function: getPatternLoopCycles
extra_variables:
- name: level
type: int
value: "StringTo<int>(args[0])"
input: [ level ] input: [ level ]
input_types: [ int ] input_types: [ int ]
cast_input: [ false ]
output: [ level,"' '" , "OutString(t)" ] output: [ level,"' '" , "OutString(t)" ]
PUT: PUT:
argc: -1 argc: 2
extra_variables:
- name: nloops
type: std::string
value: "args[iArg++]"
pattern_command:
command_name: patnloop
nGetArgs: 0
nPutArgs: 1
require_det_id: true require_det_id: true
function: setPatternLoopCycles 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: [ level, nloops ]
input_types: [ int, int ] input_types: [ int, int ]
cast_input: [ false, true ]
output: [ level,"' '" , nloops ] output: [ level,"' '" , nloops ]
patnloop0: patnloop0:
@ -4014,9 +4051,9 @@ patnloop0:
inherit_actions: patnloop inherit_actions: patnloop
actions: actions:
GET: GET:
output: [ "OutString(t)" ] output: [ OutString(t) ]
PUT: PUT:
output: [ "nloops" ] output: [ nloops ]
patnloop1: patnloop1:
inherit_actions: patnloop0 inherit_actions: patnloop0
@ -4026,31 +4063,31 @@ patnloop2:
patwait: 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." 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: actions:
GET: GET:
argc: -1 argc: 1
pattern_command:
command_name: patwait
nGetArgs: 0
nPutArgs: 1
require_det_id: true require_det_id: true
function: getPatternWaitAddr function: getPatternWaitAddr
extra_variables:
- name: level
type: int
value: "StringTo<int>(args[0])"
input: [ level ] input: [ level ]
input_types: [ int ] input_types: [ int ]
cast_input: [ false ]
output: [level,"' '" , "OutStringHex(t, 4)" ] output: [level,"' '" , "OutStringHex(t, 4)" ]
PUT: PUT:
argc: -1 argc: 2
extra_variables:
- name: addr
type: int
value: "StringTo<int>(args[iArg++])"
pattern_command:
command_name: patwait
nGetArgs: 0
nPutArgs: 1
require_det_id: true require_det_id: true
function: setPatternWaitAddr 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: [ level, addr ]
input_types: [ int, int ] input_types: [ int, int ]
output: [level,"' '" , "ToStringHex(addr, 4)" ] output: [level,"' '" , "ToStringHex(addr, 4)" ]
@ -4070,52 +4107,6 @@ patwait1:
patwait2: patwait2:
inherit_actions: patwait0 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: 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." 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: actions:

View File

@ -119,17 +119,11 @@ class CodeGenerator:
def write_check_arg(self): def write_check_arg(self):
pass pass
def write_arg(self, args, action, command_name): def write_arg(self, args, action, command_name):
for arg in args: for arg in args:
if arg['argc'] != -1: if arg['argc'] != -1:
if_block(f'args.size() == {arg["argc"]}',).__enter__() 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: if 'extra_variables' in arg:
for var in arg['extra_variables']: for var in arg['extra_variables']:
codegen.write_line(f'{var["type"]} {var["name"]} = {var["value"]};') 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(f'os << R"V0G0N({command["help"]} )V0G0N" << std::endl;')
codegen.write_line('return os.str();') 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 # check if action and arguments are valid
codegen.write_line('// 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; Result<std::vector<int>> getRxDbitList(Positions pos = {}) const;
/** [CTB] list contains the set of digital signal bits (0-63) to save, must /** [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 = {}); void setRxDbitList(const std::vector<int> &list, Positions pos = {});
/** [CTB] */ /** [CTB] */
@ -1929,10 +1930,15 @@ class Detector {
void setPatternWaitAddr(int level, int addr, Positions pos = {}); void setPatternWaitAddr(int level, int addr, Positions pos = {});
/** [CTB][Mythen3][Xilinx CTB] */ /** [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 */ /** [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] */ /** [CTB][Mythen3][Xilinx CTB] */
Result<uint64_t> getPatternMask(Positions pos = {}); Result<uint64_t> getPatternMask(Positions pos = {});

View File

@ -7859,19 +7859,30 @@ std::string Caller::patloop(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patloop");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -7882,23 +7893,24 @@ std::string Caller::patloop(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t =
auto t = det->getPatternLoopAddresses(level, std::vector<int>{det_id}); det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << level << ' ' << OutStringHex(t, 4) << '\n'; os << level << ' ' << OutStringHex(t, 4) << '\n';
}
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2; if (args.size() == 3) {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int start = StringTo<int>(args[1]);
int start = StringTo<int>(args[iArg++]); int stop = StringTo<int>(args[2]);
int stop = StringTo<int>(args[iArg++]); det->setPatternLoopAddresses(level, start, stop,
det->setPatternLoopAddresses(level, start, stop, std::vector<int>{det_id});
std::vector<int>{det_id}); os << level << ' ' << '[' << ToStringHex(start, 4) << ", "
os << level << ' ' << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4) << ']' << '\n';
<< ToStringHex(stop, 4) << ']' << '\n'; }
} }
return os.str(); return os.str();
@ -7915,19 +7927,30 @@ std::string Caller::patloop0(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patloop");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -7938,23 +7961,24 @@ std::string Caller::patloop0(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t =
auto t = det->getPatternLoopAddresses(level, std::vector<int>{det_id}); det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n'; os << OutStringHex(t, 4) << '\n';
}
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2; if (args.size() == 3) {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int start = StringTo<int>(args[1]);
int start = StringTo<int>(args[iArg++]); int stop = StringTo<int>(args[2]);
int stop = StringTo<int>(args[iArg++]); det->setPatternLoopAddresses(level, start, stop,
det->setPatternLoopAddresses(level, start, stop, std::vector<int>{det_id});
std::vector<int>{det_id}); os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4) << ']' << '\n';
<< ']' << '\n'; }
} }
return os.str(); return os.str();
@ -7971,19 +7995,30 @@ std::string Caller::patloop1(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patloop");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -7994,23 +8029,24 @@ std::string Caller::patloop1(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t =
auto t = det->getPatternLoopAddresses(level, std::vector<int>{det_id}); det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n'; os << OutStringHex(t, 4) << '\n';
}
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2; if (args.size() == 3) {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int start = StringTo<int>(args[1]);
int start = StringTo<int>(args[iArg++]); int stop = StringTo<int>(args[2]);
int stop = StringTo<int>(args[iArg++]); det->setPatternLoopAddresses(level, start, stop,
det->setPatternLoopAddresses(level, start, stop, std::vector<int>{det_id});
std::vector<int>{det_id}); os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4) << ']' << '\n';
<< ']' << '\n'; }
} }
return os.str(); return os.str();
@ -8027,19 +8063,30 @@ std::string Caller::patloop2(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patloop");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -8050,23 +8097,24 @@ std::string Caller::patloop2(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t =
auto t = det->getPatternLoopAddresses(level, std::vector<int>{det_id}); det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n'; os << OutStringHex(t, 4) << '\n';
}
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2; if (args.size() == 3) {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int start = StringTo<int>(args[1]);
int start = StringTo<int>(args[iArg++]); int stop = StringTo<int>(args[2]);
int stop = StringTo<int>(args[iArg++]); det->setPatternLoopAddresses(level, start, stop,
det->setPatternLoopAddresses(level, start, stop, std::vector<int>{det_id});
std::vector<int>{det_id}); os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4) << ']' << '\n';
<< ']' << '\n'; }
} }
return os.str(); return os.str();
@ -8146,19 +8194,29 @@ std::string Caller::patnloop(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patnloop");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -8169,21 +8227,20 @@ std::string Caller::patnloop(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id}); os << level << ' ' << OutString(t) << '\n';
os << level << ' ' << OutString(t) << '\n'; }
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 2) {
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int nloops = StringTo<int>(args[1]);
std::string nloops = args[iArg++]; det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
auto arg1 = StringTo<int>(nloops); os << level << ' ' << nloops << '\n';
det->setPatternLoopCycles(level, arg1, std::vector<int>{det_id}); }
os << level << ' ' << nloops << '\n';
} }
return os.str(); return os.str();
@ -8200,19 +8257,29 @@ std::string Caller::patnloop0(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patnloop");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -8223,21 +8290,20 @@ std::string Caller::patnloop0(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id}); os << OutString(t) << '\n';
os << OutString(t) << '\n'; }
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 2) {
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int nloops = StringTo<int>(args[1]);
std::string nloops = args[iArg++]; det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
auto arg1 = StringTo<int>(nloops); os << nloops << '\n';
det->setPatternLoopCycles(level, arg1, std::vector<int>{det_id}); }
os << nloops << '\n';
} }
return os.str(); return os.str();
@ -8254,19 +8320,29 @@ std::string Caller::patnloop1(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patnloop");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -8277,21 +8353,20 @@ std::string Caller::patnloop1(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id}); os << OutString(t) << '\n';
os << OutString(t) << '\n'; }
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 2) {
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int nloops = StringTo<int>(args[1]);
std::string nloops = args[iArg++]; det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
auto arg1 = StringTo<int>(nloops); os << nloops << '\n';
det->setPatternLoopCycles(level, arg1, std::vector<int>{det_id}); }
os << nloops << '\n';
} }
return os.str(); return os.str();
@ -8308,19 +8383,29 @@ std::string Caller::patnloop2(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patnloop");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -8331,21 +8416,20 @@ std::string Caller::patnloop2(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id}); os << OutString(t) << '\n';
os << OutString(t) << '\n'; }
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 2) {
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int nloops = StringTo<int>(args[1]);
std::string nloops = args[iArg++]; det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
auto arg1 = StringTo<int>(nloops); os << nloops << '\n';
det->setPatternLoopCycles(level, arg1, std::vector<int>{det_id}); }
os << nloops << '\n';
} }
return os.str(); return os.str();
@ -8503,19 +8587,29 @@ std::string Caller::patwait(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patwait");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -8526,20 +8620,20 @@ std::string Caller::patwait(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id}); os << level << ' ' << OutStringHex(t, 4) << '\n';
os << level << ' ' << OutStringHex(t, 4) << '\n'; }
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 2) {
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int addr = StringTo<int>(args[1]);
int addr = StringTo<int>(args[iArg++]); det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id}); os << level << ' ' << ToStringHex(addr, 4) << '\n';
os << level << ' ' << ToStringHex(addr, 4) << '\n'; }
} }
return os.str(); return os.str();
@ -8556,19 +8650,29 @@ std::string Caller::patwait0(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patwait");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -8579,20 +8683,20 @@ std::string Caller::patwait0(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id}); os << OutStringHex(t, 4) << '\n';
os << OutStringHex(t, 4) << '\n'; }
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 2) {
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int addr = StringTo<int>(args[1]);
int addr = StringTo<int>(args[iArg++]); det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id}); os << ToStringHex(addr, 4) << '\n';
os << ToStringHex(addr, 4) << '\n'; }
} }
return os.str(); return os.str();
@ -8609,19 +8713,29 @@ std::string Caller::patwait1(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patwait");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -8632,20 +8746,20 @@ std::string Caller::patwait1(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id}); os << OutStringHex(t, 4) << '\n';
os << OutStringHex(t, 4) << '\n'; }
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 2) {
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int addr = StringTo<int>(args[1]);
int addr = StringTo<int>(args[iArg++]); det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id}); os << ToStringHex(addr, 4) << '\n';
os << ToStringHex(addr, 4) << '\n'; }
} }
return os.str(); return os.str();
@ -8662,19 +8776,29 @@ std::string Caller::patwait2(int action) {
return os.str(); return os.str();
} }
GetLevelAndInsertIntoArgs("patwait");
// check if action and arguments are valid // check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
if (0) { if (1 && args.size() != 1) {
throw RuntimeError("Wrong number of arguments for action GET"); 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) { else if (action == slsDetectorDefs::PUT_ACTION) {
if (0) { if (1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action PUT"); 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 { else {
@ -8685,233 +8809,20 @@ std::string Caller::patwait2(int action) {
// generate code for each action // generate code for each action
if (action == slsDetectorDefs::GET_ACTION) { if (action == slsDetectorDefs::GET_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 1) {
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id}); os << OutStringHex(t, 4) << '\n';
os << OutStringHex(t, 4) << '\n'; }
} }
if (action == slsDetectorDefs::PUT_ACTION) { if (action == slsDetectorDefs::PUT_ACTION) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1; if (args.size() == 2) {
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, int level = StringTo<int>(args[0]);
nPutArgs); int addr = StringTo<int>(args[1]);
int addr = StringTo<int>(args[iArg++]); det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id}); os << ToStringHex(addr, 4) << '\n';
os << ToStringHex(addr, 4) << '\n';
}
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");
} }
}
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(); return os.str();

View File

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

View File

@ -175,28 +175,16 @@ void Caller::WrongNumberOfParameters(size_t expected) {
std::to_string(args.size()) + "\n"); std::to_string(args.size()) + "\n");
} }
void Caller::GetLevelAndUpdateArgIndex(int action, int Caller::GetLevelAndInsertIntoArgs(std::string levelSeparatedCommand) {
std::string levelSeparatedCommand, if (cmd != levelSeparatedCommand) {
int &level, int &iArg, size_t nGetArgs,
size_t nPutArgs) {
if (cmd == levelSeparatedCommand) {
++nGetArgs;
++nPutArgs;
} else {
LOG(logWARNING) << "This command is deprecated and will be removed. " LOG(logWARNING) << "This command is deprecated and will be removed. "
"Please migrate to " "Please migrate to "
<< levelSeparatedCommand; << 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) { return false;
WrongNumberOfParameters(nGetArgs);
} else if (action == defs::PUT_ACTION && args.size() != nPutArgs) {
WrongNumberOfParameters(nPutArgs);
}
if (cmd == levelSeparatedCommand) {
level = StringTo<int>(args[iArg++]);
} else {
level = cmd[cmd.find_first_of("012")] - '0';
}
} }
std::string Caller::free(int action) { std::string Caller::free(int action) {
@ -1017,13 +1005,94 @@ std::string Caller::slowadc(int action) {
} }
return os.str(); 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::string Caller::rx_dbitlist(int action) {
std::ostringstream os; std::ostringstream os;
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[all] or [i0] [i1] [i2]... \n\t[Ctb] List of digital signal " os << "[all] or [none] or [i0] [i1] [i2]... \n\t[Ctb] List of digital "
"bits read out. If all is used instead of a list, all digital " "signal bits enabled and rearranged according to the signals "
"bits (64) enabled. Each element in list can be 0 - 63 and must " "(all samples of each signal is put together). If 'all' is used "
"be non repetitive." "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'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (!args.empty()) { if (!args.empty()) {
@ -1041,7 +1110,9 @@ std::string Caller::rx_dbitlist(int action) {
for (unsigned int i = 0; i < 64; ++i) { for (unsigned int i = 0; i < 64; ++i) {
t[i] = 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(); unsigned int ntrim = args.size();
t.resize(ntrim); t.resize(ntrim);
for (unsigned int i = 0; i < ntrim; ++i) { 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); pimpl->Parallel(&Module::setPatternWaitAddr, pos, level, addr);
} }
Result<uint64_t> Detector::getPatternWaitTime(int level, Positions pos) const { Result<uint64_t> Detector::getPatternWaitClocks(int level,
return pimpl->Parallel(&Module::getPatternWaitTime, pos, level); Positions pos) const {
return pimpl->Parallel(&Module::getPatternWaitClocks, pos, level);
} }
void Detector::setPatternWaitTime(int level, uint64_t t, Positions pos) { void Detector::setPatternWaitClocks(int level, uint64_t t, Positions pos) {
pimpl->Parallel(&Module::setPatternWaitTime, pos, level, t); 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) { 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, explicit DetectorImpl(int detector_index = 0, bool verify = true,
bool update = 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> template <typename RT, typename... CT>
Result<RT> Parallel(RT (Module::*somefunc)(CT...), Result<RT> Parallel(RT (Module::*somefunc)(CT...),
std::vector<int> positions, std::vector<int> positions,

View File

@ -634,10 +634,22 @@ void Module::setNumberOfTriggers(int64_t value) {
} }
int64_t Module::getExptime(int gateIndex) const { 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); return sendToDetector<int64_t>(F_GET_EXPTIME, gateIndex);
} }
void Module::setExptime(int gateIndex, int64_t value) { 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; int64_t prevVal = value;
if (shm()->detType == EIGER) { if (shm()->detType == EIGER) {
prevVal = getExptime(-1); prevVal = getExptime(-1);
@ -2621,15 +2633,23 @@ void Module::setPatternWaitAddr(int level, int addr) {
sendToDetector<int>(F_SET_PATTERN_WAIT_ADDR, args); 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), uint64_t args[]{static_cast<uint64_t>(level),
static_cast<uint64_t>(GET_FLAG)}; 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}; 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 { uint64_t Module::getPatternMask() const {

View File

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

View File

@ -2012,29 +2012,13 @@ int InferAction::patlimits() {
"sls_detector_get or sls_detector_put"); "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 " int InferAction::patloop0() { throw RuntimeError("infer_action is disabled"); }
"sls_detector_get or sls_detector_put");
}
int InferAction::patloop0() { int InferAction::patloop1() { throw RuntimeError("infer_action is disabled"); }
throw RuntimeError("sls_detector is disabled for command: patloop0. Use " int InferAction::patloop2() { throw RuntimeError("infer_action is disabled"); }
"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::patmask() { 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 " int InferAction::patnloop0() { throw RuntimeError("infer_action is disabled"); }
"sls_detector_get or sls_detector_put");
}
int InferAction::patnloop0() { int InferAction::patnloop1() { throw RuntimeError("infer_action is disabled"); }
throw RuntimeError("sls_detector is disabled for command: patnloop0. Use " int InferAction::patnloop2() { throw RuntimeError("infer_action is disabled"); }
"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::patsetbit() { 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 " int InferAction::patwait0() { throw RuntimeError("infer_action is disabled"); }
"sls_detector_get or sls_detector_put");
}
int InferAction::patwait0() { int InferAction::patwait1() { throw RuntimeError("infer_action is disabled"); }
throw RuntimeError("sls_detector is disabled for command: patwait0. Use " int InferAction::patwait2() { throw RuntimeError("infer_action is disabled"); }
"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::patwaittime() { int InferAction::patwaittime() {
@ -2146,24 +2098,6 @@ int InferAction::patwaittime() {
"sls_detector_get or sls_detector_put"); "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() { int InferAction::patword() {
if (args.size() == 1) { if (args.size() == 1) {

View File

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

View File

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

View File

@ -130,7 +130,7 @@ extern "C" {
ll = (c)->D; \ ll = (c)->D; \
(void)HOST_l2c(ll, (s)); \ (void)HOST_l2c(ll, (s)); \
} while (0) } 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) #if defined(DATA_ORDER_IS_BIG_ENDIAN)
#define HOST_c2l(c, l) \ #define HOST_c2l(c, l) \

View File

@ -80,7 +80,7 @@ enum detFuncs {
F_SET_PATTERN_LOOP_ADDRESSES, F_SET_PATTERN_LOOP_ADDRESSES,
F_SET_PATTERN_LOOP_CYCLES, F_SET_PATTERN_LOOP_CYCLES,
F_SET_PATTERN_WAIT_ADDR, F_SET_PATTERN_WAIT_ADDR,
F_SET_PATTERN_WAIT_TIME, F_SET_PATTERN_WAIT_CLOCKS,
F_SET_PATTERN_MASK, F_SET_PATTERN_MASK,
F_GET_PATTERN_MASK, F_GET_PATTERN_MASK,
F_SET_PATTERN_BIT_MASK, F_SET_PATTERN_BIT_MASK,
@ -297,6 +297,8 @@ enum detFuncs {
F_SET_TIMING_INFO_DECODER, F_SET_TIMING_INFO_DECODER,
F_GET_COLLECTION_MODE, F_GET_COLLECTION_MODE,
F_SET_COLLECTION_MODE, F_SET_COLLECTION_MODE,
F_GET_PATTERN_WAIT_INTERVAL,
F_SET_PATTERN_WAIT_INTERVAL,
NUM_DET_FUNCTIONS, NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 512, /**< detector function should not exceed this 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_ADDRESSES: return "F_SET_PATTERN_LOOP_ADDRESSES";
case F_SET_PATTERN_LOOP_CYCLES: return "F_SET_PATTERN_LOOP_CYCLES"; 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_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_SET_PATTERN_MASK: return "F_SET_PATTERN_MASK";
case F_GET_PATTERN_MASK: return "F_GET_PATTERN_MASK"; case F_GET_PATTERN_MASK: return "F_GET_PATTERN_MASK";
case F_SET_PATTERN_BIT_MASK: return "F_SET_PATTERN_BIT_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_SET_TIMING_INFO_DECODER: return "F_SET_TIMING_INFO_DECODER";
case F_GET_COLLECTION_MODE: return "F_GET_COLLECTION_MODE"; case F_GET_COLLECTION_MODE: return "F_GET_COLLECTION_MODE";
case F_SET_COLLECTION_MODE: return "F_SET_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 NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

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