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

This commit is contained in:
bergamaschi 2023-07-13 17:47:07 +02:00
commit c7c672ccde
57 changed files with 3090 additions and 1582 deletions

View File

@ -1,7 +1,7 @@
SLS Detector Package Major Release 7.x.x released on xx.xx.2023
===============================================================
This document describes the differences between v7.x.x and v7.0.0
This document describes the differences between v7.x.x and v7.0.2

View File

@ -138,8 +138,15 @@ if verbose:
# Load the pattern and get all lines
# Loop all lines
with open(Folder + "/" + File_pat + ".pat") as f_pat:
lines_pat = f_pat.readlines()
if os.path.exists(Folder + "/" + File_pat + ".pat"):
with open(Folder + "/" + File_pat + ".pat") as f_pat:
lines_pat = f_pat.readlines()
elif os.path.exists(Folder + "/" + File_pat + ".pyat"):
with open(Folder + "/" + File_pat + ".pyat") as f_pat:
lines_pat = f_pat.readlines()
else:
print("No file found - Check it")
exit()
f_pat.close()
# number of lines for pattern file
@ -586,7 +593,8 @@ for idx, i in enumerate(range(nbiteff)):
n_cols = count_nonzero([waittime0 != 0, waittime1 != 0, waittime2 != 0, waittime3 != 0, waittime4 != 0, waittime5 != 0,
nloop0 != 0, nloop1 != 0, nloop2 != 0, nloop3 != 0, nloop4 != 0, nloop5 != 0])
fig2.legend(loc="upper center", ncol=n_cols)
if n_cols > 0:
fig2.legend(loc="upper center", ncol=n_cols)
# manager = get_current_fig_manager()
# manager.window.showMaximized()

View File

@ -27,6 +27,8 @@ set( PYTHON_FILES
slsdet/__init__.py
slsdet/adcs.py
slsdet/dacs.py
slsdet/voltages.py
slsdet/slowadcs.py
slsdet/decorators.py
slsdet/detector_property.py
slsdet/detector.py

View File

@ -4,6 +4,8 @@
from .eiger import Eiger
from .ctb import Ctb
from .dacs import DetectorDacs, Dac
from .voltages import DetectorVoltages, Voltage
from .slowadcs import DetectorSlowAdcs, SlowAdc
from .detector import Detector
from .jungfrau import Jungfrau
from .mythen3 import Mythen3

View File

@ -3,6 +3,8 @@
from .detector import Detector, freeze
from .utils import element_if_equal
from .dacs import DetectorDacs, NamedDacs
from .voltages import DetectorVoltages, NamedVoltages
from .slowadcs import DetectorSlowAdcs, NamedSlowAdcs
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
@ -15,8 +17,17 @@ class Ctb(Detector):
super().__init__(id)
self._frozen = False
self._dacs = NamedDacs(self)
self._voltages = NamedVoltages(self)
self._slowadcs = NamedSlowAdcs(self)
@property
def dacs(self):
return self._dacs
@property
def voltages(self):
return self._voltages
@property
def slowadcs(self):
return self._slowadcs

View File

@ -364,10 +364,11 @@ class Detector(CppDetectorApi):
-----
[Eiger] Use threshold command to load settings
[Jungfrau][Moench] GAIN0, HIGHGAIN0 \n
[Jungfrau] GAIN0, HIGHGAIN0 \n
[Gotthard] DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN \n
[Gotthard2] DYNAMICGAIN, FIXGAIN1, FIXGAIN2 \n
[Eiger] settings loaded from file found in settingspath
[Moench] G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN
"""
return element_if_equal(self.getSettings())
@ -1766,7 +1767,7 @@ class Detector(CppDetectorApi):
@property
def daclist(self):
"""
List of enums for every dac for this detector.
List of enums/names for every dac for this detector
:setter: Only implemented for Chiptestboard
"""
@ -1776,6 +1777,58 @@ class Detector(CppDetectorApi):
def daclist(self, value):
self.setDacNames(value)
@property
def adclist(self):
"""
List of names for every adc for this board. 32 adcs
:setter: Only implemented for Chiptestboard
"""
return self.getAdcNames()
@adclist.setter
def adclist(self, value):
self.setAdcNames(value)
@property
def signallist(self):
"""
List of names for every io signal for this board. 64 signals
:setter: Only implemented for Chiptestboard
"""
return self.getSignalNames()
@signallist.setter
def signallist(self, value):
self.setSignalNames(value)
@property
def voltagelist(self):
"""
List of names for every voltage for this board. 5 voltage supply
:setter: Only implemented for Chiptestboard
"""
return self.getVoltageNames()
@voltagelist.setter
def voltagelist(self, value):
self.setVoltageNames(value)
@property
def slowadclist(self):
"""
List of names for every slowadc for this board. 8 slowadc
:setter: Only implemented for Chiptestboard
"""
return self.getSlowAdcNames()
@slowadclist.setter
def slowadclist(self, value):
self.setSlowAdcNames(value)
@property
def dacvalues(self):
"""Gets the dac values for every dac for this detector."""
@ -1784,6 +1837,22 @@ class Detector(CppDetectorApi):
for dac in self.getDacList()
}
@property
def voltagevalues(self):
"""Gets the voltage values for every voltage for this detector."""
return {
voltage.name.lower(): element_if_equal(np.array(self.getVoltage(voltage)))
for voltage in self.getVoltageList()
}
@property
def slowadcvalues(self):
"""Gets the slow adc values for every slow adc for this detector."""
return {
slowadc.name.lower(): element_if_equal(np.array(self.getSlowADC(slowadc)))
for slowadc in self.getSlowADCList()
}
@property
def timinglist(self):
"""Gets the list of timing modes (timingMode) for this detector."""
@ -1982,8 +2051,9 @@ class Detector(CppDetectorApi):
-----
[Jungfrau][Moench] FULL_SPEED, HALF_SPEED (Default), QUARTER_SPEED
[Eiger] FULL_SPEED (Default), HALF_SPEED, QUARTER_SPEED
[Moench] FULL_SPEED (Default), HALF_SPEED, QUARTER_SPEED
[Gottthard2] G2_108MHZ (Default), G2_144MHZ
[Jungfrau][Moench] FULL_SPEED option only available from v2.0 boards and is recommended to set number of interfaces to 2. \n
[Jungfrau] FULL_SPEED option only available from v2.0 boards and is recommended to set number of interfaces to 2. \n
Also overwrites adcphase to recommended default.
"""
return element_if_equal(self.getReadoutSpeed())
@ -2293,12 +2363,12 @@ class Detector(CppDetectorApi):
@element
def parallel(self):
"""
[Eiger][Mythen3][Gotthard2] Enable or disable the parallel readout mode of detector.
[Eiger][Mythen3][Gotthard2][Moench] Enable or disable the parallel readout mode of detector.
Note
----
[Mythen3] If exposure time is too short, acquisition will return with an ERROR and take fewer frames than expected.
[Mythen3][Eiger] Default: Non parallel
[Mythen3][Eiger][Moench] Default: Non parallel
[Gotthard2] Default: parallel. Non parallel mode works only in continuous mode.
"""
return self.getParallelMode()
@ -2421,7 +2491,7 @@ class Detector(CppDetectorApi):
@element
def chipversion(self):
"""
[Jungfrau][Moench] Chip version of module. Can be 1.0 or 1.1.
[Jungfrau] Chip version of module. Can be 1.0 or 1.1.
Example
-------
@ -2434,7 +2504,7 @@ class Detector(CppDetectorApi):
@property
@element
def autocompdisable(self):
"""[Jungfrau][Moench] Enable or disable auto comparator disable mode.
"""[Jungfrau] Enable or disable auto comparator disable mode.
Note
-----
@ -2450,7 +2520,7 @@ class Detector(CppDetectorApi):
@property
@element
def compdisabletime(self):
"""[Jungfrau][Moench] Time before end of exposure when comparator is disabled.
"""[Jungfrau] Time before end of exposure when comparator is disabled.
Note
-----
@ -2671,11 +2741,11 @@ class Detector(CppDetectorApi):
@property
def gainmode(self):
"""
[Jungfrau][Moench] Detector gain mode. Enum: gainMode
[Jungfrau] Detector gain mode. Enum: gainMode
Note
-----
[Jungfrau][Moench] DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 \n
[Jungfrau] DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 \n
CAUTION: Do not use FIX_G0 without caution, you can damage the detector!!!
"""
return element_if_equal(self.getGainMode())
@ -2688,7 +2758,7 @@ class Detector(CppDetectorApi):
@element
def currentsource(self):
"""
Pass in a currentSrcParameters object
[Gotthard2][Jungfrau] Pass in a currentSrcParameters object
see python/examples/use_currentsource.py
"""
@ -2730,14 +2800,14 @@ class Detector(CppDetectorApi):
@element
def filterresistor(self):
"""
[Gotthard2][Jungfrau][Moench] Set filter resistor. Increasing values for increasing "
[Gotthard2][Jungfrau] Set filter resistor. Increasing values for increasing "
"resistance.
Note
----
Advanced user command.
[Gotthard2] Default is 0. Options: 0-3.
[Jungfrau][Moench] Default is 1. Options: 0-1.
[Jungfrau] Default is 1. Options: 0-1.
"""
return self.getFilterResistor()
@ -2749,11 +2819,11 @@ class Detector(CppDetectorApi):
@element
def filtercells(self):
"""
[Jungfrau][Moench] Set filter capacitor.
[Jungfrau] Set filter capacitor.
Note
----
[Jungfrau][Moench] Options: 0-12. Default: 0. Advanced user command. Only for chipv1.1.
[Jungfrau] Options: 0-12. Default: 0. Advanced user command. Only for chipv1.1.
"""
return self.getNumberOfFilterCells()
@ -3179,7 +3249,7 @@ class Detector(CppDetectorApi):
@property
@element
def dbitphase(self):
"""[Ctb][Jungfrau][Moench] Phase shift of clock to latch digital bits. Absolute phase shift.
"""[Ctb][Jungfrau] Phase shift of clock to latch digital bits. Absolute phase shift.
Note
-----
@ -3231,7 +3301,7 @@ class Detector(CppDetectorApi):
@property
@element
def maxdbitphaseshift(self):
"""[CTB][Jungfrau][Moench] Absolute maximum Phase shift of of the clock to latch digital bits.
"""[CTB][Jungfrau] Absolute maximum Phase shift of of the clock to latch digital bits.
Note
-----
@ -3359,6 +3429,13 @@ class Detector(CppDetectorApi):
fname = ut.make_string_path(fname)
ut.set_using_dict(self.setPattern, fname)
@property
def patfname(self):
"""
[Ctb][Mythen3] Gets the pattern file name including path of the last pattern uploaded. Returns an empty if nothing was uploaded or via a server default
file
"""
return self.getPatterFileName()
@property
@element
@ -3694,45 +3771,45 @@ class Detector(CppDetectorApi):
@element
def v_a(self):
"""[Ctb] Voltage supply a in mV."""
return self.getDAC(dacIndex.V_POWER_A, True)
return self.getVoltage(dacIndex.V_POWER_A)
@v_a.setter
def v_a(self, value):
value = ut.merge_args(dacIndex.V_POWER_A, value, True)
ut.set_using_dict(self.setDAC, *value)
value = ut.merge_args(dacIndex.V_POWER_A, value)
ut.set_using_dict(self.setVoltage, *value)
@property
@element
def v_b(self):
"""[Ctb] Voltage supply b in mV."""
return self.getDAC(dacIndex.V_POWER_B, True)
return self.getVoltage(dacIndex.V_POWER_B)
@v_b.setter
def v_b(self, value):
value = ut.merge_args(dacIndex.V_POWER_B, value, True)
ut.set_using_dict(self.setDAC, *value)
value = ut.merge_args(dacIndex.V_POWER_B, value)
ut.set_using_dict(self.setVoltage, *value)
@property
@element
def v_c(self):
"""[Ctb] Voltage supply c in mV."""
return self.getDAC(dacIndex.V_POWER_C, True)
return self.getVoltage(dacIndex.V_POWER_C)
@v_c.setter
def v_c(self, value):
value = ut.merge_args(dacIndex.V_POWER_C, value, True)
ut.set_using_dict(self.setDAC, *value)
value = ut.merge_args(dacIndex.V_POWER_C, value)
ut.set_using_dict(self.setVoltage, *value)
@property
@element
def v_d(self):
"""[Ctb] Voltage supply d in mV."""
return self.getDAC(dacIndex.V_POWER_D, True)
return self.getVoltage(dacIndex.V_POWER_D)
@v_d.setter
def v_d(self, value):
value = ut.merge_args(dacIndex.V_POWER_D, value, True)
ut.set_using_dict(self.setDAC, *value)
value = ut.merge_args(dacIndex.V_POWER_D, value)
ut.set_using_dict(self.setVoltage, *value)
@property
@element
@ -3743,23 +3820,23 @@ class Detector(CppDetectorApi):
----
Must be the first power regulator to be set after fpga reset (on-board detector server start up).
"""
return self.getDAC(dacIndex.V_POWER_IO, True)
return self.getVoltage(dacIndex.V_POWER_IO)
@v_io.setter
def v_io(self, value):
value = ut.merge_args(dacIndex.V_POWER_IO, value, True)
ut.set_using_dict(self.setDAC, *value)
value = ut.merge_args(dacIndex.V_POWER_IO, value)
ut.set_using_dict(self.setVoltage, *value)
@property
@element
def v_limit(self):
"""[Ctb] Soft limit for power supplies (ctb only) and DACS in mV."""
return self.getDAC(dacIndex.V_LIMIT, True)
return self.getVoltage(dacIndex.V_LIMIT)
@v_limit.setter
def v_limit(self, value):
value = ut.merge_args(dacIndex.V_LIMIT, value, True)
ut.set_using_dict(self.setDAC, *value)
value = ut.merge_args(dacIndex.V_LIMIT, value)
ut.set_using_dict(self.setVoltage, *value)
@property

195
python/slsdet/slowadcs.py Executable file
View File

@ -0,0 +1,195 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
from .detector_property import DetectorProperty
from functools import partial
import numpy as np
import _slsdet
from .detector import freeze
dacIndex = _slsdet.slsDetectorDefs.dacIndex
class SlowAdc(DetectorProperty):
"""
This class represents a slowadc on the Chip Test Board. One instance handles all
slowadcs with the same name for a multi detector instance. (TODO: Not needed for CTB)
.. note ::
This class is used to build up DetectorSlowAdcs and is in general
not directly accessible to the user.
"""
def __init__(self, name, enum, default, detector):
super().__init__(partial(detector.getVoltage, enum),
lambda x, y : detector.setVoltage(enum, x, y),
detector.size,
name)
self.default = default
def __repr__(self):
"""String representation for a single slowadc in all modules"""
slowadcstr = ''.join([f'{item:5d}' for item in self.get()])
return f'{self.__name__:15s}:{slowadcstr}'
class NamedSlowAdcs:
"""
New implementation of the detector slowadcs.
"""
_frozen = False
_direct_access = ['_detector', '_current', '_voltagenames']
def __init__(self, detector):
self._detector = detector
self._current = 0
#only get the voltagenames if we have modules attached
if detector.size() == 0:
self._voltagenames = ["VA", "VB", "VC", "VD", "VIO"]
else:
self._voltagenames = [n.replace(" ", "") for n in detector.getVoltageNames()]
# Populate the slowadcs
for i,name in enumerate(self._voltagenames):
#name, enum, low, high, default, detector
k = dacIndex(i + int(dacIndex.V_POWER_A))
setattr(self, name, SlowAdc(name, k, 0, detector))
self._frozen = True
# def __getattr__(self, name):
# return self.__getattribute__('_' + name)
def __setattr__(self, name, value):
if not self._frozen:
#durning init we need to be able to set up the class
super().__setattr__(name, value)
else:
#Later we restrict us to manipulate slowadcs and a few fields
if name in self._direct_access:
super().__setattr__(name, value)
elif name in self._voltagenames:
return self.__getattribute__(name).__setitem__(slice(None, None), value)
else:
raise AttributeError(f'SlowAdc not found: {name}')
def __next__(self):
if self._current >= len(self._voltagenames):
self._current = 0
raise StopIteration
else:
self._current += 1
return self.__getattribute__(self._voltagenames[self._current-1])
# return self.__getattr__(self._voltagenames[self._current-1])
def __iter__(self):
return self
def __repr__(self):
r_str = ['========== SLOW ADCS =========']
r_str += [repr(slowadc) for slowadc in self]
return '\n'.join(r_str)
def get_asarray(self):
"""
Read the slowadcs into a numpy array with dimensions [nslowadcs, nmodules]
"""
voltage_array = np.zeros((len(self._voltagenames), len(self._detector)))
for i, _d in enumerate(self):
voltage_array[i,:] = _d[:]
return voltage_array
def to_array(self):
return self.get_asarray()
def set_from_array(self, voltage_array):
"""
Set the slowadc from an numpy array with slowadc values. [nslowadcs, nmodules]
"""
voltage_array = voltage_array.astype(np.int)
for i, _d in enumerate(self):
_d[:] = voltage_array[i]
def from_array(self, voltage_array):
self.set_from_array(voltage_array)
class DetectorSlowAdcs:
_slowadcs = []
_voltagenames = [_d[0] for _d in _slowadcs]
_allowed_attr = ['_detector', '_current']
_frozen = False
def __init__(self, detector):
# We need to at least initially know which detector we are connected to
self._detector = detector
# Index to support iteration
self._current = 0
# Name the attributes?
for _d in self._slowadcs:
setattr(self, '_'+_d[0], SlowAdc(*_d, detector))
self._frozen = True
def __getattr__(self, name):
return self.__getattribute__('_' + name)
@property
def voltagenames(self):
return [_d[0] for _d in _slowadcs]
def __setattr__(self, name, value):
if name in self._voltagenames:
return self.__getattribute__('_' + name).__setitem__(slice(None, None), value)
else:
if self._frozen == True and name not in self._allowed_attr:
raise AttributeError(f'SlowAdc not found: {name}')
super().__setattr__(name, value)
def __next__(self):
if self._current >= len(self._slowadcs):
self._current = 0
raise StopIteration
else:
self._current += 1
return self.__getattr__(self._voltagenames[self._current-1])
def __iter__(self):
return self
def __repr__(self):
r_str = ['========== SLOW ADCS =========']
r_str += [repr(slowadc) for slowadc in self]
return '\n'.join(r_str)
def get_asarray(self):
"""
Read the slowadcs into a numpy array with dimensions [nslowadcs, nmodules]
"""
voltage_array = np.zeros((len(self._slowadcs), len(self._detector)))
for i, _d in enumerate(self):
voltage_array[i,:] = _d[:]
return voltage_array
def to_array(self):
return self.get_asarray()
def set_from_array(self, voltage_array):
"""
Set the slowadcs from an numpy array with slowadc values. [nslowadcs, nmodules]
"""
voltage_array = voltage_array.astype(np.int)
for i, _d in enumerate(self):
_d[:] = voltage_array[i]
def from_array(self, voltage_array):
self.set_from_array(voltage_array)
def set_default(self):
"""
Set all slowadcs to their default values
"""
for _d in self:
_d[:] = _d.default

195
python/slsdet/voltages.py Executable file
View File

@ -0,0 +1,195 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
from .detector_property import DetectorProperty
from functools import partial
import numpy as np
import _slsdet
from .detector import freeze
dacIndex = _slsdet.slsDetectorDefs.dacIndex
class Voltage(DetectorProperty):
"""
This class represents a voltage on the Chip Test Board. One instance handles all
voltages with the same name for a multi detector instance. (TODO: Not needed for CTB)
.. note ::
This class is used to build up DetectorVoltages and is in general
not directly accessible to the user.
"""
def __init__(self, name, enum, default, detector):
super().__init__(partial(detector.getVoltage, enum),
lambda x, y : detector.setVoltage(enum, x, y),
detector.size,
name)
self.default = default
def __repr__(self):
"""String representation for a single voltage in all modules"""
voltagestr = ''.join([f'{item:5d}' for item in self.get()])
return f'{self.__name__:15s}:{voltagestr}'
class NamedVoltages:
"""
New implementation of the detector voltages.
"""
_frozen = False
_direct_access = ['_detector', '_current', '_voltagenames']
def __init__(self, detector):
self._detector = detector
self._current = 0
#only get the voltagenames if we have modules attached
if detector.size() == 0:
self._voltagenames = ["VA", "VB", "VC", "VD", "VIO"]
else:
self._voltagenames = [n.replace(" ", "") for n in detector.getVoltageNames()]
# Populate the voltages
for i,name in enumerate(self._voltagenames):
#name, enum, low, high, default, detector
k = dacIndex(i + int(dacIndex.V_POWER_A))
setattr(self, name, Voltage(name, k, 0, detector))
self._frozen = True
# def __getattr__(self, name):
# return self.__getattribute__('_' + name)
def __setattr__(self, name, value):
if not self._frozen:
#durning init we need to be able to set up the class
super().__setattr__(name, value)
else:
#Later we restrict us to manipulate voltages and a few fields
if name in self._direct_access:
super().__setattr__(name, value)
elif name in self._voltagenames:
return self.__getattribute__(name).__setitem__(slice(None, None), value)
else:
raise AttributeError(f'Voltage not found: {name}')
def __next__(self):
if self._current >= len(self._voltagenames):
self._current = 0
raise StopIteration
else:
self._current += 1
return self.__getattribute__(self._voltagenames[self._current-1])
# return self.__getattr__(self._voltagenames[self._current-1])
def __iter__(self):
return self
def __repr__(self):
r_str = ['========== VOLTAGES =========']
r_str += [repr(voltage) for voltage in self]
return '\n'.join(r_str)
def get_asarray(self):
"""
Read the voltages into a numpy array with dimensions [nvoltages, nmodules]
"""
voltage_array = np.zeros((len(self._voltagenames), len(self._detector)))
for i, _d in enumerate(self):
voltage_array[i,:] = _d[:]
return voltage_array
def to_array(self):
return self.get_asarray()
def set_from_array(self, voltage_array):
"""
Set the voltage from an numpy array with voltage values. [nvoltages, nmodules]
"""
voltage_array = voltage_array.astype(np.int)
for i, _d in enumerate(self):
_d[:] = voltage_array[i]
def from_array(self, voltage_array):
self.set_from_array(voltage_array)
class DetectorVoltages:
_voltages = []
_voltagenames = [_d[0] for _d in _voltages]
_allowed_attr = ['_detector', '_current']
_frozen = False
def __init__(self, detector):
# We need to at least initially know which detector we are connected to
self._detector = detector
# Index to support iteration
self._current = 0
# Name the attributes?
for _d in self._voltages:
setattr(self, '_'+_d[0], Voltage(*_d, detector))
self._frozen = True
def __getattr__(self, name):
return self.__getattribute__('_' + name)
@property
def voltagenames(self):
return [_d[0] for _d in _voltages]
def __setattr__(self, name, value):
if name in self._voltagenames:
return self.__getattribute__('_' + name).__setitem__(slice(None, None), value)
else:
if self._frozen == True and name not in self._allowed_attr:
raise AttributeError(f'Voltage not found: {name}')
super().__setattr__(name, value)
def __next__(self):
if self._current >= len(self._voltages):
self._current = 0
raise StopIteration
else:
self._current += 1
return self.__getattr__(self._voltagenames[self._current-1])
def __iter__(self):
return self
def __repr__(self):
r_str = ['========== VOLTAGES =========']
r_str += [repr(voltage) for voltage in self]
return '\n'.join(r_str)
def get_asarray(self):
"""
Read the voltages into a numpy array with dimensions [nvoltages, nmodules]
"""
voltage_array = np.zeros((len(self._voltages), len(self._detector)))
for i, _d in enumerate(self):
voltage_array[i,:] = _d[:]
return voltage_array
def to_array(self):
return self.get_asarray()
def set_from_array(self, voltage_array):
"""
Set the voltages from an numpy array with voltage values. [nvoltages, nmodules]
"""
voltage_array = voltage_array.astype(np.int)
for i, _d in enumerate(self):
_d[:] = voltage_array[i]
def from_array(self, voltage_array):
self.set_from_array(voltage_array)
def set_default(self):
"""
Set all voltages to their default values
"""
for _d in self:
_d[:] = _d.default

View File

@ -1516,6 +1516,12 @@ void init_det(py::module &m) {
(void (Detector::*)(int, sls::Positions)) &
Detector::setADCPipeline,
py::arg(), py::arg() = Positions{});
CppDetectorApi.def("getVoltageList",
(std::vector<defs::dacIndex>(Detector::*)() const) &
Detector::getVoltageList);
CppDetectorApi.def("getSlowADCList",
(std::vector<defs::dacIndex>(Detector::*)() const) &
Detector::getSlowADCList);
CppDetectorApi.def(
"getVoltage",
(Result<int>(Detector::*)(defs::dacIndex, sls::Positions) const) &
@ -1643,14 +1649,105 @@ void init_det(py::module &m) {
CppDetectorApi.def("getDacNames",
(std::vector<std::string>(Detector::*)() const) &
Detector::getDacNames);
CppDetectorApi.def("getDacIndex",
(defs::dacIndex(Detector::*)(const std::string &)) &
Detector::getDacIndex,
py::arg());
CppDetectorApi.def(
"getDacIndex",
(defs::dacIndex(Detector::*)(const std::string &) const) &
Detector::getDacIndex,
py::arg());
CppDetectorApi.def(
"setDacName",
(void (Detector::*)(const defs::dacIndex, const std::string &)) &
Detector::setDacName,
py::arg(), py::arg());
CppDetectorApi.def("getDacName",
(std::string(Detector::*)(defs::dacIndex)) &
(std::string(Detector::*)(const defs::dacIndex) const) &
Detector::getDacName,
py::arg());
CppDetectorApi.def("setAdcNames",
(void (Detector::*)(const std::vector<std::string>)) &
Detector::setAdcNames,
py::arg());
CppDetectorApi.def("getAdcNames",
(std::vector<std::string>(Detector::*)() const) &
Detector::getAdcNames);
CppDetectorApi.def("getAdcIndex",
(int (Detector::*)(const std::string &) const) &
Detector::getAdcIndex,
py::arg());
CppDetectorApi.def("setAdcName",
(void (Detector::*)(const int, const std::string &)) &
Detector::setAdcName,
py::arg(), py::arg());
CppDetectorApi.def("getAdcName",
(std::string(Detector::*)(const int) const) &
Detector::getAdcName,
py::arg());
CppDetectorApi.def("setSignalNames",
(void (Detector::*)(const std::vector<std::string>)) &
Detector::setSignalNames,
py::arg());
CppDetectorApi.def("getSignalNames",
(std::vector<std::string>(Detector::*)() const) &
Detector::getSignalNames);
CppDetectorApi.def("getSignalIndex",
(int (Detector::*)(const std::string &) const) &
Detector::getSignalIndex,
py::arg());
CppDetectorApi.def("setSignalName",
(void (Detector::*)(const int, const std::string &)) &
Detector::setSignalName,
py::arg(), py::arg());
CppDetectorApi.def("getSignalName",
(std::string(Detector::*)(const int) const) &
Detector::getSignalName,
py::arg());
CppDetectorApi.def("setVoltageNames",
(void (Detector::*)(const std::vector<std::string>)) &
Detector::setVoltageNames,
py::arg());
CppDetectorApi.def("getVoltageNames",
(std::vector<std::string>(Detector::*)() const) &
Detector::getVoltageNames);
CppDetectorApi.def(
"getVoltageIndex",
(defs::dacIndex(Detector::*)(const std::string &) const) &
Detector::getVoltageIndex,
py::arg());
CppDetectorApi.def(
"setVoltageName",
(void (Detector::*)(const defs::dacIndex, const std::string &)) &
Detector::setVoltageName,
py::arg(), py::arg());
CppDetectorApi.def("getVoltageName",
(std::string(Detector::*)(const defs::dacIndex) const) &
Detector::getVoltageName,
py::arg());
CppDetectorApi.def("setSlowADCNames",
(void (Detector::*)(const std::vector<std::string>)) &
Detector::setSlowADCNames,
py::arg());
CppDetectorApi.def("getSlowADCNames",
(std::vector<std::string>(Detector::*)() const) &
Detector::getSlowADCNames);
CppDetectorApi.def(
"getSlowADCIndex",
(defs::dacIndex(Detector::*)(const std::string &) const) &
Detector::getSlowADCIndex,
py::arg());
CppDetectorApi.def(
"setSlowADCName",
(void (Detector::*)(const defs::dacIndex, const std::string &)) &
Detector::setSlowADCName,
py::arg(), py::arg());
CppDetectorApi.def("getSlowADCName",
(std::string(Detector::*)(const defs::dacIndex) const) &
Detector::getSlowADCName,
py::arg());
CppDetectorApi.def(
"getPatterFileName",
(Result<std::string>(Detector::*)(sls::Positions) const) &
Detector::getPatterFileName,
py::arg() = Positions{});
CppDetectorApi.def(
"setPattern",
(void (Detector::*)(const std::string &, sls::Positions)) &

View File

@ -52,7 +52,6 @@ void qDrawPlot::SetupWidgetWindow() {
detType = det->getDetectorType().squash();
switch (detType) {
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH:
pixelMask = ((1 << 14) - 1);
gainMask = (3 << 14);
gainOffset = 14;
@ -1143,8 +1142,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
break;
case 16:
if (detType == slsDetectorDefs::MOENCH ||
detType == slsDetectorDefs::JUNGFRAU ||
if (detType == slsDetectorDefs::JUNGFRAU ||
detType == slsDetectorDefs::GOTTHARD2) {
// show gain plot

View File

@ -43,8 +43,8 @@ void qTabDataOutput::SetupWidgetWindow() {
case slsDetectorDefs::MYTHEN3:
chkParallel->setEnabled(true);
break;
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH:
case slsDetectorDefs::JUNGFRAU:
lblClkDivider->setEnabled(true);
comboClkDivider->setEnabled(true);
break;

View File

@ -62,11 +62,6 @@ void qTabPlot::SetupWidgetWindow() {
chkGainPlot->setChecked(true);
plot->EnableGainPlot(true);
break;
case slsDetectorDefs::MOENCH:
chkGainPlot->setEnabled(true);
chkGainPlot->setChecked(true);
plot->EnableGainPlot(true);
break;
default:
break;
}
@ -804,9 +799,6 @@ void qTabPlot::Refresh() {
chkGainPlot->setEnabled(true);
GetGapPixels();
break;
case slsDetectorDefs::MOENCH:
chkGainPlot->setEnabled(true);
break;
case slsDetectorDefs::GOTTHARD2:
chkGainPlot1D->setEnabled(true);
break;

View File

@ -92,12 +92,14 @@ void qTabSettings::SetupWidgetWindow() {
comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
} else if (detType == slsDetectorDefs::JUNGFRAU ||
detType == slsDetectorDefs::MOENCH) {
} else if (detType == slsDetectorDefs::JUNGFRAU) {
lblSpinHV->show();
spinHV->show();
lblGainMode->setEnabled(true);
comboGainMode->setEnabled(true);
} else if (detType == slsDetectorDefs::MOENCH) {
lblSpinHV->show();
spinHV->show();
} else if (detType == slsDetectorDefs::GOTTHARD) {
comboHV->show();
lblComboHV->show();

View File

@ -1149,7 +1149,7 @@ int checkVLimitCompliant(int mV) {
}
int checkVLimitDacCompliant(int dac) {
if (vLimit > 0) {
if (vLimit > 0 && dac != -1 && dac != LTC2620_GetPowerDownValue()) {
int mv = 0;
// could not convert
if (LTC2620_DacToVoltage(dac, &mv) == FAIL)
@ -2289,6 +2289,11 @@ enum runStatus getRunStatus() {
return TRANSMITTING;
}
// 1g might still be transmitting or reading from fifo (not virtual)
if (!enableTenGigabitEthernet(-1) && checkDataInFifo()) {
return TRANSMITTING;
}
if (!(retval & STATUS_IDLE_MSK)) {
LOG(logINFOBLUE, ("Status: Idle\n"));
return IDLE;
@ -2299,19 +2304,17 @@ enum runStatus getRunStatus() {
}
}
void readandSendUDPFrames(int *ret, char *mess) {
int validateUDPSocket() {
if (getUdPSocketDescriptor(0, 0) <= 0) {
return FAIL;
}
return OK;
}
void readandSendUDPFrames() {
LOG(logDEBUG1, ("Reading from 1G UDP\n"));
// validate udp socket
if (getUdPSocketDescriptor(0, 0) <= 0) {
*ret = FAIL;
sprintf(mess, "UDP Socket not created. sockfd:%d\n",
getUdPSocketDescriptor(0, 0));
LOG(logERROR, (mess));
return;
}
// every frame read
// read every frame
while (readFrameFromFifo() == OK) {
int bytesToSend = 0, n = 0;
while ((bytesToSend = fillUDPPacket(udpPacketData))) {
@ -2324,6 +2327,7 @@ void readandSendUDPFrames(int *ret, char *mess) {
}
}
closeUDPSocket(0);
LOG(logINFOBLUE, ("Transmitting frames done\n"));
}
void waitForAcquisitionEnd() {
@ -2339,20 +2343,6 @@ void waitForAcquisitionEnd() {
LOG(logINFOGREEN, ("Blocking Acquisition done\n"));
}
void readFrames(int *ret, char *mess) {
#ifdef VIRTUAL
while (runBusy()) {
usleep(500);
}
#else
// 1G force reading of frames
if (!enableTenGigabitEthernet(-1)) {
readandSendUDPFrames(ret, mess);
LOG(logINFOBLUE, ("Transmitting frames done\n"));
}
#endif
}
void unsetFifoReadStrobes() {
bus_w(DUMMY_REG, bus_r(DUMMY_REG) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK) &
(~DUMMY_DGTL_FIFO_RD_STRBE_MSK));
@ -2444,7 +2434,7 @@ uint32_t checkDataInFifo() {
uint32_t dataPresent = 0;
if (analogEnable) {
uint32_t analogFifoEmpty = bus_r(FIFO_EMPTY_REG);
LOG(logINFO,
LOG(logDEBUG1,
("Analog Fifo Empty (32 channels): 0x%08x\n", analogFifoEmpty));
dataPresent = (~analogFifoEmpty);
}

View File

@ -932,6 +932,59 @@ int readRegister(uint32_t offset, uint32_t *retval) {
#endif
}
int setBit(const uint32_t addr, const int nBit) {
#ifndef VIRTUAL
uint32_t regval = 0;
if (readRegister(addr, &regval) == FAIL) {
return FAIL;
}
uint32_t bitmask = (1 << nBit);
uint32_t val = regval | bitmask;
sharedMemory_lockLocalLink();
if (!Feb_Control_WriteRegister_BitMask(addr, val, bitmask)) {
sharedMemory_unlockLocalLink();
return FAIL;
}
sharedMemory_unlockLocalLink();
#endif
return OK;
}
int clearBit(const uint32_t addr, const int nBit) {
#ifndef VIRTUAL
uint32_t regval = 0;
if (readRegister(addr, &regval) == FAIL) {
return FAIL;
}
uint32_t bitmask = (1 << nBit);
uint32_t val = regval & ~bitmask;
sharedMemory_lockLocalLink();
if (!Feb_Control_WriteRegister_BitMask(addr, val, bitmask)) {
sharedMemory_unlockLocalLink();
return FAIL;
}
sharedMemory_unlockLocalLink();
#endif
return OK;
}
int getBit(const uint32_t addr, const int nBit, int *retval) {
#ifndef VIRTUAL
uint32_t regval = 0;
uint32_t bitmask = (1 << nBit);
sharedMemory_lockLocalLink();
if (!Feb_Control_ReadRegister_BitMask(addr, &regval, bitmask)) {
sharedMemory_unlockLocalLink();
return FAIL;
}
sharedMemory_unlockLocalLink();
*retval = (regval >> nBit);
#endif
return OK;
}
/* set parameters - dr, roi */
int setDynamicRange(int dr) {

View File

@ -1388,14 +1388,18 @@ int setMaster(enum MASTERINDEX m) {
char *master_names[] = {MASTER_NAMES};
LOG(logINFOBLUE, ("Setting up as %s in (%s server)\n", master_names[m],
(isControlServer ? "control" : "stop")));
int prevSync = getSynchronization();
setSynchronization(0);
int retval = -1;
int retMaster = OK;
switch (m) {
case OW_MASTER:
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_MASTER_MSK);
isMaster(&retval);
if (retval != 1) {
LOG(logERROR, ("Could not set master\n"));
return FAIL;
retMaster = FAIL;
}
break;
case OW_SLAVE:
@ -1403,15 +1407,16 @@ int setMaster(enum MASTERINDEX m) {
isMaster(&retval);
if (retval != 0) {
LOG(logERROR, ("Could not set slave\n"));
return FAIL;
retMaster = FAIL;
}
break;
default:
LOG(logERROR, ("Cannot reset to hardware settings from client. Restart "
"detector server.\n"));
return FAIL;
retMaster = FAIL;
}
return OK;
setSynchronization(prevSync);
return retMaster;
}
int isMaster(int *retval) {

View File

@ -5,7 +5,7 @@
#include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x171220
#define REQRD_FRMWRE_VRSN_BOARD2 0x221104 // 1.0 pcb (version = 010)
#define REQRD_FRMWRE_VRSN_BOARD2 0x230515 // 1.0 pcb (version = 010)
#define REQRD_FRMWRE_VRSN 0x221103 // 2.0 pcb (version = 011)
#define NUM_HARDWARE_VERSIONS (2)

View File

@ -41,5 +41,4 @@ install(TARGETS moenchDetectorServer_virtual
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
configure_file(config_moench.txt ${CMAKE_BINARY_DIR}/bin/config_moench.txt COPYONLY)
configure_file(detid_moench.txt ${CMAKE_BINARY_DIR}/bin/detid_moench.txt COPYONLY)

View File

@ -36,7 +36,6 @@ $(PROGS): $(OBJS)
mkdir -p $(DESTDIR)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR)
cp config_moench.txt $(DESTDIR)
cp detid_moench.txt $(DESTDIR)
rm *.gdb
rm $(main_src)*.o $(md5_dir)*.o

View File

@ -26,33 +26,28 @@
#define RUN_BUSY_MSK (0x00000001 << RUN_BUSY_OFST)
#define WAITING_FOR_TRIGGER_OFST (3)
#define WAITING_FOR_TRIGGER_MSK (0x00000001 << WAITING_FOR_TRIGGER_OFST)
#define DELAYBEFORE_OFST (4) // Not used in software
#define DELAYBEFORE_MSK (0x00000001 << DELAYBEFORE_OFST) // Not used in software
#define DELAYAFTER_OFST (5) // Not used in software
#define DELAYAFTER_MSK (0x00000001 << DELAYAFTER_OFST) // Not used in software
#define DELAYBEFORE_OFST (4) // delay before acq and after trigger
#define DELAYBEFORE_MSK (0x00000001 << DELAYBEFORE_OFST)
#define DELAYAFTER_OFST (5) // delay after acq until next frame
#define DELAYAFTER_MSK (0x00000001 << DELAYAFTER_OFST)
#define EXPOSING_OFST (6)
#define EXPOSING_MSK (0x00000001 << EXPOSING_OFST)
#define STOPPED_OFST (15)
#define STOPPED_MSK (0x00000001 << STOPPED_OFST)
#define FRAME_BUSY_OFST (18)
#define FRAME_BUSY_MSK (0x00000001 << FRAME_BUSY_OFST)
#define ADC_DESERON_OFST (19)
#define ADC_DESERON_MSK (0x00000001 << ADC_DESERON_OFST)
#define RUNMACHINE_BUSY_OFST (17)
#define RUNMACHINE_BUSY_MSK (0x00000001 << RUNMACHINE_BUSY_OFST)
/* Look at me register */
#define LOOK_AT_ME_REG (0x03 << MEM_MAP_SHIFT) // Not used in firmware or software
/* System Status register */
#define SYSTEM_STATUS_REG (0x04 << MEM_MAP_SHIFT) // Not used in software
#define DDR3_CAL_DONE_OFST (0) // Not used in software
#define DDR3_CAL_DONE_MSK (0x00000001 << DDR3_CAL_DONE_OFST) // Not used in software
#define DDR3_CAL_FAIL_OFST (1) // Not used in software
#define DDR3_CAL_FAIL_MSK (0x00000001 << DDR3_CAL_FAIL_OFST) // Not used in software
#define DDR3_INIT_DONE_OFST (2) // Not used in software
#define DDR3_INIT_DONE_MSK (0x00000001 << DDR3_INIT_DONE_OFST) // Not used in software
#define RECONFIG_PLL_LCK_OFST (3) // Not used in software
#define RECONFIG_PLL_LCK_MSK (0x00000001 << RECONFIG_PLL_LCK_OFST) // Not used in software
#define PLL_A_LCK_OFST (4) // Not used in software
#define PLL_A_LCK_MSK (0x00000001 << PLL_A_LCK_OFST) // Not used in software
#define DD3_PLL_LCK_OFST (5) // Not used in software
#define DD3_PLL_LCK_MSK (0x00000001 << DD3_PLL_LCK_OFST) // Not used in software
#define RECONFIG_PLL_LCK_OFST (3)
#define RECONFIG_PLL_LCK_MSK (0x00000001 << RECONFIG_PLL_LCK_OFST)
#define PLL_A_LCK_OFST (4)
#define PLL_A_LCK_MSK (0x00000001 << PLL_A_LCK_OFST)
/* Module Control Board Serial Number Register */
#define MOD_SERIAL_NUM_REG (0x0A << MEM_MAP_SHIFT)
@ -67,8 +62,6 @@
#define API_VERSION_OFST (0)
#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
#define API_VERSION_DETECTOR_TYPE_OFST (24) // Not used in software
#define API_VERSION_DETECTOR_TYPE_MSK (0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) // Not used in software
/* Time from Start 64 bit register */
#define TIME_FROM_START_LSB_REG (0x10 << MEM_MAP_SHIFT)
@ -90,7 +83,7 @@
#define GET_PERIOD_LSB_REG (0x18 << MEM_MAP_SHIFT)
#define GET_PERIOD_MSB_REG (0x19 << MEM_MAP_SHIFT)
/** Get Temperature Carlos, incorrectl as get gates */
/** Get Temperature */
#define GET_TEMPERATURE_TMP112_REG (0x1c << MEM_MAP_SHIFT) // (after multiplying by 625) in 10ths of
// millidegrees of TMP112
@ -99,27 +92,14 @@
#define TEMPERATURE_POLARITY_BIT (11)
#define TEMPERATURE_POLARITY_MSK (0x00000001 << TEMPERATURE_POLARITY_BIT)
/* Config Status Register for chip 1.1 */
#define CONFIG_V11_STATUS_REG (0x1D << MEM_MAP_SHIFT)
#define CONFIG_V11_STATUS_FLTR_CLL_OFST (0)
#define CONFIG_V11_STATUS_FLTR_CLL_MSK (0x00000FFF << CONFIG_V11_STATUS_FLTR_CLL_OFST)
// CSM mode = high current (100%), low current (16%)
#define CONFIG_V11_STATUS_CRRNT_SRC_LOW_OFST (19)
#define CONFIG_V11_STATUS_CRRNT_SRC_LOW_MSK (0x00000001 << CONFIG_V11_STATUS_CRRNT_SRC_LOW_OFST)
#define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST (21)
#define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST)
#define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST (23)
#define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_MSK (0x00000001 << CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST)
/* Get Frames from Start 64 bit register (frames from last reset using
* CONTROL_CRST) */
#define FRAMES_FROM_START_LSB_REG (0x22 << MEM_MAP_SHIFT)
#define FRAMES_FROM_START_MSB_REG (0x23 << MEM_MAP_SHIFT)
/* Get Starting Frame Number */
#define GET_FRAME_NUMBER_LSB_REG (0x24 << MEM_MAP_SHIFT)
#define GET_FRAME_NUMBER_MSB_REG (0x25 << MEM_MAP_SHIFT)
/* Get Next Frame Number */
#define GET_NEXT_FRAME_NUMBER_LSB_REG (0x24 << MEM_MAP_SHIFT)
#define GET_NEXT_FRAME_NUMBER_MSB_REG (0x25 << MEM_MAP_SHIFT)
/* Measurement Time 64 bit register (timestamp at a frame start until reset)*/
#define START_FRAME_TIME_LSB_REG (0x26 << MEM_MAP_SHIFT)
@ -154,6 +134,9 @@
/* ADC offset Register */
#define ADC_OFST_REG (0x42 << MEM_MAP_SHIFT)
#define ADC_OFFSET_OFST (0)
#define ADC_OFFSET_MSK (0x0000001F << ADC_OFFSET_OFST)
/* ADC Port Invert Register */
#define ADC_PORT_INVERT_REG (0x43 << MEM_MAP_SHIFT)
@ -178,10 +161,6 @@
/* Configuration Register */
#define CONFIG_REG (0x4D << MEM_MAP_SHIFT)
// readout timer (from chip) to stabilize (esp in burst acquisition mode) tRDT =
// (RDT + 1) * 25ns
#define CONFIG_RDT_TMR_OFST (0)
#define CONFIG_RDT_TMR_MSK (0x0000FFFF << CONFIG_RDT_TMR_OFST)
// if 0, outer is the primary interface
// bottom via port 0 (outer)
#define CONFIG_OPRTN_MDE_2_X_10GbE_OFST (16)
@ -219,12 +198,10 @@
#define CONTROL_STOP_ACQ_MSK (0x00000001 << CONTROL_STOP_ACQ_OFST)
#define CONTROL_SOFTWARE_TRIGGER_OFST (2)
#define CONTROL_SOFTWARE_TRIGGER_MSK (0x00000001 << CONTROL_SOFTWARE_TRIGGER_OFST)
#define CONTROL_CORE_RST_OFST (10)
#define CONTROL_CORE_RST_OFST (10) // flow, dac driver, 10GbE
#define CONTROL_CORE_RST_MSK (0x00000001 << CONTROL_CORE_RST_OFST)
#define CONTROL_PERIPHERAL_RST_OFST (11) // DDR3 HMem Ctrlr, GBE, Temp
#define CONTROL_PERIPHERAL_RST_MSK (0x00000001 << CONTROL_PERIPHERAL_RST_OFST) // DDR3 HMem Ctrlr, GBE, Temp
#define CONTROL_DDR3_MEM_RST_OFST (12) // only PHY, not DDR3 PLL ,Not used in software
#define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) // only PHY, not DDR3 PLL ,Not used in software
#define CONTROL_PERIPHERAL_RST_OFST (11) // 10GBE
#define CONTROL_PERIPHERAL_RST_MSK (0x00000001 << CONTROL_PERIPHERAL_RST_OFST)
#define CONTROL_ACQ_FIFO_CLR_OFST (14)
#define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST)
#define CONTROL_MASTER_OFST (15)
@ -246,24 +223,9 @@
#define PLL_CNTRL_WR_PRMTR_MSK (0x00000001 << PLL_CNTRL_WR_PRMTR_OFST)
#define PLL_CNTRL_PLL_RST_OFST (3)
#define PLL_CNTRL_PLL_RST_MSK (0x00000001 << PLL_CNTRL_PLL_RST_OFST)
#define PLL_CNTRL_DBIT_WR_PRMTR_OFST (5)
#define PLL_CNTRL_DBIT_WR_PRMTR_MSK (0x00000001 << PLL_CNTRL_DBIT_WR_PRMTR_OFST)
#define PLL_CNTRL_ADDR_OFST (16)
#define PLL_CNTRL_ADDR_MSK (0x0000003F << PLL_CNTRL_ADDR_OFST)
/* Config Register for chip 1.1 */
#define CONFIG_V11_REG (0x58 << MEM_MAP_SHIFT)
#define CONFIG_V11_FLTR_CLL_OFST (0)
#define CONFIG_V11_FLTR_CLL_MSK (0x00000FFF << CONFIG_V11_FLTR_CLL_OFST)
// CSM mode = high current (100%), low current (16%)
#define CONFIG_V11_CRRNT_SRC_LOW_OFST (19)
#define CONFIG_V11_CRRNT_SRC_LOW_MSK (0x00000001 << CONFIG_V11_CRRNT_SRC_LOW_OFST)
#define CONFIG_V11_FLTR_RSSTR_SMLR_OFST (21)
#define CONFIG_V11_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_FLTR_RSSTR_SMLR_OFST)
#define CONFIG_V11_AUTO_MODE_OVRRD_OFST (23)
#define CONFIG_V11_AUTO_MODE_OVRRD_MSK (0x00000001 << CONFIG_V11_AUTO_MODE_OVRRD_OFST)
/* Sample Register */
#define SAMPLE_REG (0x59 << MEM_MAP_SHIFT)
@ -289,80 +251,6 @@
#define SAMPLE_ADC_DECMT_FACTOR_6_VAL ((0x6 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
#define SAMPLE_ADC_DECMT_FACTOR_7_VAL ((0x7 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
#define SAMPLE_DGTL_SAMPLE_SEL_OFST (8)
#define SAMPLE_DGTL_SAMPLE_SEL_MSK (0x0000000F << SAMPLE_DGTL_SAMPLE_SEL_OFST)
#define SAMPLE_DGTL_SAMPLE_0_VAL ((0x0 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_1_VAL ((0x1 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_2_VAL ((0x2 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_3_VAL ((0x3 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_4_VAL ((0x4 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_5_VAL ((0x5 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_6_VAL ((0x6 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_7_VAL ((0x7 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_8_VAL ((0x8 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_9_VAL ((0x9 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_10_VAL ((0xa << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_11_VAL ((0xb << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_12_VAL ((0xc << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_13_VAL ((0xd << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_14_VAL ((0xe << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_SAMPLE_15_VAL ((0xf << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
#define SAMPLE_DGTL_DECMT_FACTOR_OFST (12)
#define SAMPLE_DGTL_DECMT_FACTOR_MSK (0x00000003 << SAMPLE_DGTL_DECMT_FACTOR_OFST)
#define SAMPLE_DECMT_FACTOR_FULL_VAL ((0x0 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
#define SAMPLE_DECMT_FACTOR_HALF_VAL ((0x1 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
#define SAMPLE_DECMT_FACTOR_QUARTER_VAL ((0x2 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
/** Current Source Column 0 (0 - 31)) */
#define CRRNT_SRC_COL_LSB_REG (0x5A << MEM_MAP_SHIFT)
/** Current Source Column 1 (32 - 63) */
#define CRRNT_SRC_COL_MSB_REG (0x5B << MEM_MAP_SHIFT)
/** Vref Comp Mod Register */
#define EXT_DAQ_CTRL_REG (0x5C << MEM_MAP_SHIFT)
#define EXT_DAQ_CTRL_VREF_COMP_OFST (0)
#define EXT_DAQ_CTRL_VREF_COMP_MSK (0x00000FFF << EXT_DAQ_CTRL_VREF_COMP_OFST)
#define EXT_DAQ_CTRL_CMP_LGC_ENBL_OFST (15)
#define EXT_DAQ_CTRL_CMP_LGC_ENBL_MSK (0x00000001 << EXT_DAQ_CTRL_CMP_LGC_ENBL_OFST)
#define EXT_DAQ_CTRL_INPT_DETECT_OFST (16)
#define EXT_DAQ_CTRL_INPT_DETECT_MSK (0x00000007 << EXT_DAQ_CTRL_INPT_DETECT_OFST)
#define EXT_DAQ_CTRL_INPT_DETECT_ENBL_OFST (19)
#define EXT_DAQ_CTRL_INPT_DETECT_ENBL_MSK (0x00000001 << EXT_DAQ_CTRL_INPT_DETECT_ENBL_OFST)
/** DAQ Register */
#define DAQ_REG (0x5D << MEM_MAP_SHIFT)
// dynamic gain (default)
#define DAQ_HIGH_GAIN_OFST (0)
#define DAQ_HIGH_GAIN_MSK (0x00000001 << DAQ_HIGH_GAIN_OFST)
#define DAQ_FIX_GAIN_OFST (1)
#define DAQ_FIX_GAIN_MSK (0x00000003 << DAQ_FIX_GAIN_OFST)
#define DAQ_FIX_GAIN_STG_1_VAL ((0x1 << DAQ_FIX_GAIN_OFST) & DAQ_FIX_GAIN_MSK)
#define DAQ_FIX_GAIN_STG_2_VAL ((0x3 << DAQ_FIX_GAIN_OFST) & DAQ_FIX_GAIN_MSK)
#define DAQ_CMP_RST_OFST (4)
#define DAQ_CMP_RST_MSK (0x00000001 << DAQ_CMP_RST_OFST)
#define DAQ_CHIP11_VRSN_OFST (7)
#define DAQ_CHIP11_VRSN_MSK (0x00000001 << DAQ_CHIP11_VRSN_OFST)
#define DAQ_FRCE_SWTCH_GAIN_OFST (12)
#define DAQ_FRCE_SWTCH_GAIN_MSK (0x00000003 << DAQ_FRCE_SWTCH_GAIN_OFST)
#define DAQ_FRCE_GAIN_STG_0_VAL ((0x0 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
#define DAQ_FRCE_GAIN_STG_1_VAL ((0x1 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
#define DAQ_FRCE_GAIN_STG_2_VAL ((0x3 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
#define DAQ_ELCTRN_CLLCTN_MDE_OFST (14)
#define DAQ_ELCTRN_CLLCTN_MDE_MSK (0x00000001 << DAQ_ELCTRN_CLLCTN_MDE_OFST)
#define DAQ_G2_CNNT_OFST (15)
#define DAQ_G2_CNNT_MSK (0x00000001 << DAQ_G2_CNNT_OFST)
#define DAQ_CRRNT_SRC_ENBL_OFST (16)
#define DAQ_CRRNT_SRC_ENBL_MSK (0x00000001 << DAQ_CRRNT_SRC_ENBL_OFST)
#define DAQ_CRRNT_SRC_CLMN_FIX_OFST (17)
#define DAQ_CRRNT_SRC_CLMN_FIX_MSK (0x00000001 << DAQ_CRRNT_SRC_CLMN_FIX_OFST)
#define DAQ_CRRNT_SRC_CLMN_SLCT_OFST (20)
#define DAQ_CRRNT_SRC_CLMN_SLCT_MSK (0x0000003F << DAQ_CRRNT_SRC_CLMN_SLCT_OFST)
#define DAQ_GAIN_MODE_MASK (DAQ_FRCE_SWTCH_GAIN_MSK | DAQ_FIX_GAIN_MSK | DAQ_CMP_RST_MSK)
/** Chip Power Register */
#define CHIP_POWER_REG (0x5E << MEM_MAP_SHIFT)
@ -402,13 +290,9 @@
#define SET_EXPTIME_LSB_REG (0x68 << MEM_MAP_SHIFT)
#define SET_EXPTIME_MSB_REG (0x69 << MEM_MAP_SHIFT)
/* Starting Frame number 64 bit register */
#define FRAME_NUMBER_LSB_REG (0x6A << MEM_MAP_SHIFT)
#define FRAME_NUMBER_MSB_REG (0x6B << MEM_MAP_SHIFT)
/* Comparator disable time (chipv1.1) 32 bit register tT = T x 25 ns
Time before end of exposure when comparator is disabled */
#define COMP_DSBLE_TIME_REG (0x6C << MEM_MAP_SHIFT)
/* Set next Frame number 64 bit register */
#define SET_NEXT_FRAME_NUMBER_LSB_REG (0x6A << MEM_MAP_SHIFT)
#define SET_NEXT_FRAME_NUMBER_MSB_REG (0x6B << MEM_MAP_SHIFT)
/* Trigger Delay 32 bit register */
@ -437,23 +321,121 @@ Time before end of exposure when comparator is disabled */
#define MOD_ID_OFST (0)
#define MOD_ID_MSK (0x0000FFFF << MOD_ID_OFST)
/* ASIC Control Register */
#define ASIC_CTRL_REG (0x7F << MEM_MAP_SHIFT)
#define ASIC_CTRL_PARALLEL_RD_OFST (0)
#define ASIC_CTRL_PARALLEL_RD_MSK (0x00000001 << ASIC_CTRL_PARALLEL_RD_OFST)
#define ASIC_CTRL_INTRFCE_CLK_PLRTY_OFST (1)
#define ASIC_CTRL_INTRFCE_CLK_PLRTY_MSK (0x00000001 << ASIC_CTRL_INTRFCE_CLK_PLRTY_OFST)
#define ASIC_CTRL_PULSETOP_OFST (4)
#define ASIC_CTRL_PULSETOP_MSK (0x00000001 << ASIC_CTRL_PULSETOP_OFST
#define ASIC_CTRL_PULSEBOT_OFST (5)
#define ASIC_CTRL_PULSEBOT_MSK (0x00000001 << ASIC_CTRL_PULSEBOT_OFST)
#define ASIC_CTRL_ENPRECHPREBOT_OFST (6)
#define ASIC_CTRL_ENPRECHPREBOT_MSK (0x00000001 << ASIC_CTRL_ENPRECHPREBOT_OFST)
#define ASIC_CTRL_DSG1_BOT_OFST (7)
#define ASIC_CTRL_DSG1_BOT_MSK (0x00000001 << ASIC_CTRL_DSG1_BOT_OFST)
#define ASIC_CTRL_BYPASSCDSBOT_OFST (8)
#define ASIC_CTRL_BYPASSCDSBOT_MSK (0x00000001 << ASIC_CTRL_BYPASSCDSBOT_OFST)
#define ASIC_CTRL_HG_BOT_OFST (9)
#define ASIC_CTRL_HG_BOT_MSK (0x00000001 << ASIC_CTRL_HG_BOT_OFST)
#define ASIC_CTRL_STO2TOP_OFST (10)
#define ASIC_CTRL_STO2TOP_MSK (0x00000001 << ASIC_CTRL_STO2TOP_OFST)
#define ASIC_CTRL_PRECHARGECONNECTBOT_OFST (11)
#define ASIC_CTRL_PRECHARGECONNECTBOT_MSK (0x00000001 << ASIC_CTRL_PRECHARGECONNECTBOT_OFST)
#define ASIC_CTRL_CONNCDSTOP_OFST (12)
#define ASIC_CTRL_CONNCDSTOP_MSK (0x00000001 << ASIC_CTRL_CONNCDSTOP_OFST)
#define ASIC_CTRL_BYPASSTOP_OFST (13)
#define ASIC_CTRL_BYPASSTOP_MSK (0x00000001 << ASIC_CTRL_BYPASSTOP_OFST)
#define ASIC_CTRL_STO1TOP_OFST (14)
#define ASIC_CTRL_STO1TOP_MSK (0x00000001 << ASIC_CTRL_STO1TOP_OFST)
#define ASIC_CTRL_DSG3_TOP_OFST (15)
#define ASIC_CTRL_DSG3_TOP_MSK (0x00000001 << ASIC_CTRL_DSG3_TOP_OFST)
#define ASIC_CTRL_S2DTESTEN_OFST (16)
#define ASIC_CTRL_S2DTESTEN_MSK (0x00000001 << ASIC_CTRL_S2DTESTEN_OFST)
#define ASIC_CTRL_BOTSRTESTBOT_OFST (17)
#define ASIC_CTRL_BOTSRTESTBOT_MSK (0x00000001 << ASIC_CTRL_BOTSRTESTBOT_OFST)
#define ASIC_CTRL_PRESETSSR_OFST (18)
#define ASIC_CTRL_PRESETSSR_MSK (0x00000001 << ASIC_CTRL_PRESETSSR_OFST)
#define ASIC_CTRL_PULSEOFFTOP_OFST (19)
#define ASIC_CTRL_PULSEOFFTOP_MSK (0x00000001 << ASIC_CTRL_PULSEOFFTOP_OFST)
#define ASIC_CTRL_PULSEOFFBOT_OFST (20)
#define ASIC_CTRL_PULSEOFFBOT_MSK (0x00000001 << ASIC_CTRL_PULSEOFFBOT_OFST)
#define ASIC_CTRL_CONNCDSBOT_OFST (21)
#define ASIC_CTRL_CONNCDSBOT_MSK (0x00000001 << ASIC_CTRL_CONNCDSBOT_OFST)
#define ASIC_CTRL_ENPRECHPRETOP_OFST (22)
#define ASIC_CTRL_ENPRECHPRETOP_MSK (0x00000001 << ASIC_CTRL_ENPRECHPRETOP_OFST)
#define ASIC_CTRL_BYPASSBOT_OFST (23)
#define ASIC_CTRL_BYPASSBOT_MSK (0x00000001 << ASIC_CTRL_BYPASSBOT_OFST)
#define ASIC_CTRL_DSG1_TOP_OFST (24)
#define ASIC_CTRL_DSG1_TOP_MSK (0x00000001 << ASIC_CTRL_DSG1_TOP_OFST)
#define ASIC_CTRL_STO1BOT_OFST (25)
#define ASIC_CTRL_STO1BOT_MSK (0x00000001 << ASIC_CTRL_STO1BOT_OFST)
#define ASIC_CTRL_BYPASSCDSTOP_OFST (26)
#define ASIC_CTRL_BYPASSCDSTOP_MSK (0x00000001 << ASIC_CTRL_BYPASSCDSTOP_OFST)
#define ASIC_CTRL_DSG3_BOT_OFST (27)
#define ASIC_CTRL_DSG3_BOT_MSK (0x00000001 << ASIC_CTRL_DSG3_BOT_OFST)
#define ASIC_CTRL_HG_TOP_OFST (28)
#define ASIC_CTRL_HG_TOP_MSK (0x00000001 << ASIC_CTRL_HG_TOP_OFST)
#define ASIC_CTRL_STO2BOT_OFST (29)
#define ASIC_CTRL_STO2BOT_MSK (0x00000001 << ASIC_CTRL_STO2BOT_OFST)
#define ASIC_CTRL_PRECHARGECONNECTTOP_OFST (30)
#define ASIC_CTRL_PRECHARGECONNECTTOP_MSK (0x00000001 << ASIC_CTRL_PRECHARGECONNECTTOP_OFST)
#define ASIC_CTRL_BOTSRTESTTOP_OFST (31)
#define ASIC_CTRL_BOTSRTESTTOP_MSK (0x00000001 << ASIC_CTRL_BOTSRTESTTOP_OFST)
#define ASIC_CTRL_DEFAULT_VAL (ASIC_CTRL_INTRFCE_CLK_PLRTY_MSK | ASIC_CTRL_DSG1_BOT_MSK | \
ASIC_CTRL_HG_BOT_MSK | ASIC_CTRL_STO2TOP_MSK | \
ASIC_CTRL_CONNCDSTOP_MSK | ASIC_CTRL_STO1TOP_MSK | \
ASIC_CTRL_BOTSRTESTBOT_MSK | ASIC_CTRL_PULSEOFFTOP_MSK | \
ASIC_CTRL_PULSEOFFBOT_MSK | ASIC_CTRL_CONNCDSBOT_MSK | \
ASIC_CTRL_DSG1_TOP_MSK | ASIC_CTRL_STO1BOT_MSK | \
ASIC_CTRL_HG_TOP_MSK | ASIC_CTRL_STO2BOT_MSK | \
ASIC_CTRL_BOTSRTESTTOP_MSK)
#define ASIC_CTRL_HG_MSK (ASIC_CTRL_HG_TOP_MSK | ASIC_CTRL_HG_BOT_MSK)
#define ASIC_CTRL_DSG1_MSK (ASIC_CTRL_DSG1_TOP_MSK | ASIC_CTRL_DSG1_BOT_MSK)
#define ASIC_CTRL_DSG3_MSK (ASIC_CTRL_DSG3_TOP_MSK | ASIC_CTRL_DSG3_BOT_MSK)
#define SETTINGS_MSK (ASIC_CTRL_HG_MSK | ASIC_CTRL_DSG1_MSK | ASIC_CTRL_DSG3_MSK)
#define SETTINGS_G1_HG (ASIC_CTRL_HG_MSK | ASIC_CTRL_DSG3_MSK)
#define SETTINGS_G1_LG (ASIC_CTRL_DSG3_MSK)
#define SETTINGS_G2_HC_HG (ASIC_CTRL_HG_MSK)
#define SETTINGS_G2_HC_LG (0)
#define SETTINGS_G2_LC_HG (ASIC_CTRL_HG_MSK | ASIC_CTRL_DSG1_MSK | ASIC_CTRL_DSG3_MSK)
#define SETTINGS_G2_LC_LG (ASIC_CTRL_DSG1_MSK | ASIC_CTRL_DSG3_MSK)
#define SETTINGS_G4_HG (ASIC_CTRL_HG_MSK | ASIC_CTRL_DSG1_MSK)
#define SETTINGS_G4_LG (ASIC_CTRL_DSG1_MSK)
/* ADC 0 Deserializer Control */
#define ADC_DSRLZR_0_REG (0xF0 << MEM_MAP_SHIFT)
#define ADC_DSRLZR_0_RESET_ALGNMNT_OFST (30)
#define ADC_DSRLZR_0_RESET_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_0_RESET_ALGNMNT_OFST)
#define ADC_DSRLZR_0_RFRSH_ALGNMNT_OFST (31) /* Refresh alignment */
#define ADC_DSRLZR_0_RFRSH_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_0_RFRSH_ALGNMNT_OFST)
/* ADC 0 Deserializer Control */
#define ADC_DSRLZR_1_REG (0xF1 << MEM_MAP_SHIFT)
#define ADC_DSRLZR_1_RESET_ALGNMNT_OFST (30)
#define ADC_DSRLZR_1_RESET_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_1_RESET_ALGNMNT_OFST)
#define ADC_DSRLZR_1_RFRSH_ALGNMNT_OFST (31)
#define ADC_DSRLZR_1_RFRSH_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_1_RFRSH_ALGNMNT_OFST)
/* ADC 0 Deserializer Control */
#define ADC_DSRLZR_2_REG (0xF2 << MEM_MAP_SHIFT)
#define ADC_DSRLZR_2_RESET_ALGNMNT_OFST (30)
#define ADC_DSRLZR_2_RESET_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_2_RESET_ALGNMNT_OFST)
#define ADC_DSRLZR_2_RFRSH_ALGNMNT_OFST (31)
#define ADC_DSRLZR_2_RFRSH_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_2_RFRSH_ALGNMNT_OFST)
/* ADC 0 Deserializer Control */
#define ADC_DSRLZR_3_REG (0xF3 << MEM_MAP_SHIFT)
#define ADC_DSRLZR_3_RESET_ALGNMNT_OFST (30)
#define ADC_DSRLZR_3_RESET_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_3_RESET_ALGNMNT_OFST)
#define ADC_DSRLZR_3_RFRSH_ALGNMNT_OFST (31)
#define ADC_DSRLZR_3_RFRSH_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_3_RFRSH_ALGNMNT_OFST)

View File

@ -1,4 +0,0 @@
#chip version version (multiplied by 10)
chipversion 11

View File

@ -4,8 +4,8 @@
#include "RegisterDefs.h"
#include "sls/sls_detector_defs.h"
#define REQRD_FRMWRE_VRSN_BOARD2 0x221130 // 1.0 pcb (version = 010)
#define REQRD_FRMWRE_VRSN 0x221130 // 2.0 pcb (version = 011)
#define REQRD_FRMWRE_VRSN_BOARD2 0x444445 // 1.0 pcb (version = 010)
#define REQRD_FRMWRE_VRSN 0x230710 // 2.0 pcb (version = 011)
#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS \
@ -14,7 +14,6 @@
{ "1.0", "2.0" }
#define ID_FILE ("detid_moench.txt")
#define CONFIG_FILE ("config_moench.txt")
#define LINKED_SERVER_NAME "moenchDetectorServer"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
@ -27,9 +26,7 @@
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
#define DATA_BYTES (NCHIP * NCHAN * NUM_BYTES_PER_PIXEL)
#define CLK_RUN (40) // MHz
#define CLK_SYNC (20) // MHz
#define ADC_CLK_INDEX (1)
#define DBIT_CLK_INDEX (0)
#define ADC_CLK_INDEX (0)
/** Default Parameters */
#define DEFAULT_NUM_FRAMES (1)
@ -40,13 +37,12 @@
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_SETTINGS (GAIN0)
#define DEFAULT_GAINMODE (DYNAMIC)
#define DEFAULT_SETTINGS (G4_HIGHGAIN)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_TMP_THRSHLD (65 * 1000) // milli degree Celsius
#define DEFAULT_FLIP_ROWS (0)
#define DEFAULT_FILTER_RESISTOR (1) // higher resistor
#define DEFAULT_FILTER_CELL (0)
#define DEFAULT_SPEED (FULL_SPEED)
#define DEFAULT_PARALLEL_ENABLE (0)
#define HIGHVOLTAGE_MIN (60)
#define HIGHVOLTAGE_MAX (200)
@ -69,75 +65,17 @@
#define MAX_PHASE_SHIFTS (240)
#define BIT16_MASK (0xFFFF)
#define GAIN_VAL_OFST (14)
#define GAIN_VAL_MSK (0x3 << GAIN_VAL_OFST)
#define ADC_DECMT_QUARTER_SPEED (0x3)
#define ADC_DECMT_HALF_SPEED (0x1)
#define ADC_DECMT_FULL_SPEED (0x0)
// pipeline
#define ADC_PORT_INVERT_VAL (0x5A5A5A5A)
#define ADC_PORT_INVERT_BOARD2_VAL (0x453b2a9c)
#define ADC_PORT_INVERT_VAL (0x55555555)
// 2.0 pcb (chipv1.1)
#define SAMPLE_ADC_FULL_SPEED_CHIP11 \
(SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + \
SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_DECMT_FACTOR_FULL_VAL) // 0x0000
#define SAMPLE_ADC_HALF_SPEED_CHIP11 \
(SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + \
SAMPLE_DGTL_SAMPLE_1_VAL + SAMPLE_DECMT_FACTOR_HALF_VAL) // 0x1110
#define SAMPLE_ADC_QUARTER_SPEED_CHIP11 \
(SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_3_VAL + \
SAMPLE_DGTL_SAMPLE_2_VAL + SAMPLE_DECMT_FACTOR_QUARTER_VAL) // 0x2230
#define ADC_PHASE_FULL_SPEED_CHIP11 (160)
#define ADC_PHASE_HALF_SPEED_CHIP11 (160)
#define ADC_PHASE_QUARTER_SPEED_CHIP11 (160)
#define DBIT_PHASE_FULL_SPEED_CHIP11 (80)
#define DBIT_PHASE_HALF_SPEED_CHIP11 (135)
#define DBIT_PHASE_QUARTER_SPEED_CHIP11 (135)
#define ADC_OFST_FULL_SPEED_VAL_CHIP11 (0x10)
#define ADC_OFST_HALF_SPEED_VAL_CHIP11 (0x08)
#define ADC_OFST_QUARTER_SPEED_VAL_CHIP11 (0x04)
// 2.0 pcb (chipv1.0)
#define SAMPLE_ADC_FULL_SPEED_CHIP10 \
(SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + \
SAMPLE_DGTL_SAMPLE_1_VAL + SAMPLE_DECMT_FACTOR_FULL_VAL) // 0x0100
#define SAMPLE_ADC_HALF_SPEED_CHIP10 \
(SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + \
SAMPLE_DGTL_SAMPLE_3_VAL + SAMPLE_DECMT_FACTOR_HALF_VAL) // 0x1310
#define SAMPLE_ADC_QUARTER_SPEED_CHIP10 \
(SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_3_VAL + \
SAMPLE_DGTL_SAMPLE_6_VAL + SAMPLE_DECMT_FACTOR_QUARTER_VAL) // 0x2630
#define ADC_PHASE_FULL_SPEED_CHIP10 (160)
#define ADC_PHASE_HALF_SPEED_CHIP10 (160)
#define ADC_PHASE_QUARTER_SPEED_CHIP10 (160)
#define DBIT_PHASE_FULL_SPEED_CHIP10 (125)
#define DBIT_PHASE_HALF_SPEED_CHIP10 (175)
#define DBIT_PHASE_QUARTER_SPEED_CHIP10 (175)
#define ADC_OFST_FULL_SPEED_VAL_CHIP10 (0x10)
#define ADC_OFST_HALF_SPEED_VAL_CHIP10 (0x08)
#define ADC_OFST_QUARTER_SPEED_VAL_CHIP10 (0x04)
// 1.0 pcb (2 resistor network)
#define SAMPLE_ADC_HALF_SPEED_BOARD2 \
(SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + \
SAMPLE_DGTL_SAMPLE_3_VAL + SAMPLE_DECMT_FACTOR_HALF_VAL) // 0x1300
#define SAMPLE_ADC_QUARTER_SPEED_BOARD2 \
(SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + \
SAMPLE_DGTL_SAMPLE_6_VAL + SAMPLE_DECMT_FACTOR_QUARTER_VAL) // 0x2610
#define ADC_PHASE_HALF_SPEED_BOARD2 (110)
#define ADC_PHASE_QUARTER_SPEED_BOARD2 (220)
#define DBIT_PHASE_HALF_SPEED_BOARD2 (150)
#define DBIT_PHASE_QUARTER_SPEED_BOARD2 (150)
#define ADC_OFST_HALF_SPEED_BOARD2_VAL (0x10)
#define ADC_OFST_QUARTER_SPEED_BOARD2_VAL (0x08)
#define SAMPLE_ADC_FULL_SPEED \
(SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL) // 0x0
#define ADC_PHASE_DEG_FULL_SPEED (140)
#define ADC_OFST_FULL_SPEED_VAL (0xf)
/* Struct Definitions */
typedef struct udp_header_struct {
@ -197,14 +135,8 @@ enum DACINDEX {
enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define MASTER_NAMES "hardware", "master", "slave"
#define NUMSETTINGS (2)
#define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS \
{ 1450, 480, 420 }
#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS \
{ 1550, 450, 620 }
#define NUMSETTINGS (0)
enum NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G };
enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
enum CLKINDEX { RUN_CLK, ADC_CLK, NUM_CLOCKS };
#define CLK_NAMES "run", "adc", "dbit"

View File

@ -1375,7 +1375,7 @@ int setTrimbits(int *trimbits) {
error = 1;
} else {
memset(cmess, 0, MAX_STR_LENGTH);
error |= loadPattern(cmess, logDEBUG5, pat);
error |= loadPattern(cmess, logDEBUG5, pat, "");
if (!error)
startPattern();
free(pat);
@ -2827,7 +2827,7 @@ int setChipStatusRegister(int csr) {
iret = FAIL;
} else {
memset(cmess, 0, MAX_STR_LENGTH);
iret = loadPattern(cmess, logDEBUG5, pat);
iret = loadPattern(cmess, logDEBUG5, pat, "");
if (iret == OK) {
startPattern();
LOG(logINFO, ("CSR is now: 0x%x\n", csr));

View File

@ -4,7 +4,7 @@
#include <inttypes.h>
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
/**
* Set Defines
* @param creg control register
@ -14,9 +14,8 @@
* @param prmsk pll reset mask
* @param amsk address mask
* @param aofst address offset
* @param wd2msk write parameter mask for pll for dbit clock (Jungfrau/moench
* only)
* @param clk2Index clkIndex of second pll (Jungfrau/moench only)
* @param wd2msk write parameter mask for pll for dbit clock (Jungfrau only)
* @param clk2Index clkIndex of second pll (Jungfrau only)
*/
void ALTERA_PLL_SetDefines(uint32_t creg, uint32_t preg, uint32_t rprmsk,
uint32_t wpmsk, uint32_t prmsk, uint32_t amsk,
@ -51,7 +50,7 @@ void ALTERA_PLL_ResetPLLAndReconfiguration();
* Set PLL Reconfig register
* @param reg register
* @param val value
* @param useDefaultWRMask only jungfrau/moench for dbit clk (clkindex1, use
* @param useDefaultWRMask only jungfrau for dbit clk (clkindex1, use
* second WR mask)
*/
void ALTERA_PLL_SetPllReconfigReg(uint32_t reg, uint32_t val,

View File

@ -54,8 +54,9 @@ uint64_t getPatternBitMask();
#ifdef MYTHEN3D
void startPattern();
#endif
int loadPattern(char *mess, enum TLogLevel printLevel, patternParameters *pat);
char *getPatternFileName();
int loadPattern(char *mess, enum TLogLevel printLevel, patternParameters *pat,
char *patfname);
int getPattern(char *mess, patternParameters *pat);
int loadPatternFile(char *patFname, char *errMessage);

View File

@ -95,7 +95,7 @@ u_int16_t getHardwareSerialNumber();
defined(MYTHEN3D) || defined(GOTTHARDD)
int isHardwareVersion_1_0();
#endif
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
int getChipVersion();
void setChipVersion(int version);
#endif
@ -147,8 +147,7 @@ void setASICDefaults();
#ifdef MYTHEN3D
void setADIFDefaults();
#endif
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(JUNGFRAUD) || \
defined(MOENCHD)
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(JUNGFRAUD)
int readConfigFile();
#endif
#if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \
@ -163,6 +162,9 @@ void resetToHardwareSettings();
#ifdef EIGERD
int writeRegister(uint32_t offset, uint32_t data);
int readRegister(uint32_t offset, uint32_t *retval);
int setBit(const uint32_t addr, int nBit);
int clearBit(const uint32_t addr, int nBit);
int getBit(const uint32_t addr, const int nBit, int *retval);
#elif GOTTHARDD
uint32_t writeRegister16And32(uint32_t offset,
uint32_t data); // FIXME its not there in ctb
@ -213,7 +215,8 @@ int setExternalSampling(int val);
#endif
// parameters - readout
#if defined(EIGERD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
#if defined(EIGERD) || defined(MYTHEN3D) || defined(GOTTHARD2D) || \
defined(MOENCHD)
int setParallelMode(int mode);
int getParallelMode();
#endif
@ -334,7 +337,7 @@ int getAllTrimbits();
enum detectorSettings setSettings(enum detectorSettings sett);
#endif
enum detectorSettings getSettings();
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
enum gainMode getGainMode();
void setGainMode(enum gainMode mode);
#endif
@ -517,12 +520,12 @@ int setReadNRows(int value);
int getReadNRows();
void initReadoutConfiguration();
int powerChip(int on);
#ifndef MOENCHD
int isChipConfigured();
void configureChip();
int autoCompDisable(int on);
int setComparatorDisableTime(int64_t val);
int64_t getComparatorDisableTime();
#ifndef MOENCHD
void configureASICTimer();
#endif
int setReadoutSpeed(int val);
@ -537,6 +540,7 @@ int setTemperatureEvent(int val);
void alignDeserializer();
int getFlipRows();
void setFlipRows(int arg);
#ifndef MOENCHD
int setFilterResistor(int value);
int getFilterResistor();
int getNumberOfFilterCells();
@ -547,6 +551,7 @@ int getCurrentSource();
int getFixCurrentSource();
int getNormalCurrentSource();
uint64_t getSelectCurrentSource();
#endif
// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter
#elif EIGERD
@ -676,16 +681,14 @@ int softwareTrigger(int block);
int startReadOut();
#endif
enum runStatus getRunStatus();
#if defined(CHIPTESTBOARDD)
void readFrames(int *ret, char *mess);
#endif
#ifdef EIGERD
void waitForAcquisitionEnd(int *ret, char *mess);
#else
void waitForAcquisitionEnd();
#endif
#if defined(CHIPTESTBOARDD)
void readandSendUDPFrames(int *ret, char *mess);
int validateUDPSocket();
void readandSendUDPFrames();
void unsetFifoReadStrobes();
void readSample(int ns);
uint32_t checkDataInFifo();

View File

@ -48,6 +48,9 @@ int set_settings(int);
int get_threshold_energy(int);
int acquire(int blocking, int file_des);
void *start_state_machine(void *arg);
#if defined(CHIPTESTBOARDD) && !defined(VIRTUAL)
void *start_reading_and_sending_udp_frames(void *arg);
#endif
int start_acquisition(int);
int stop_acquisition(int);
int get_run_status(int);
@ -94,6 +97,7 @@ int enable_ten_giga(int);
int validateAndSetAllTrimbits(int arg);
int set_all_trimbits(int);
int set_pattern_io_control(int);
int get_pattern_io_control(int);
int set_pattern_word(int);
int set_pattern_loop_addresses(int);
int set_pattern_loop_cycles(int);
@ -222,6 +226,7 @@ int get_gate_delay_all_gates(int);
int get_veto(int);
int set_veto(int);
int set_pattern(int);
int get_pattern_file(int);
int get_scan(int);
int set_scan(int);
int get_scan_error_message(int);
@ -307,3 +312,6 @@ int get_synchronization(int);
int set_synchronization(int);
int get_hardware_version(int);
int get_frontend_firmware_version(int);
int get_bit(int);
int set_bit(int);
int clear_bit(int);

View File

@ -127,7 +127,7 @@ uint32_t ALTERA_PLL_Cntrl_Reg = 0x0;
uint32_t ALTERA_PLL_Param_Reg = 0x0;
uint32_t ALTERA_PLL_Cntrl_RcnfgPrmtrRstMask = 0x0;
uint32_t ALTERA_PLL_Cntrl_WrPrmtrMask = 0x0;
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
uint32_t ALTERA_PLL_Cntrl_DBIT_PLL_WrPrmtrMask = 0x0;
int ALTERA_PLL_Cntrl_DBIT_ClkIndex = 0;
@ -136,7 +136,7 @@ uint32_t ALTERA_PLL_Cntrl_PLLRstMask = 0x0;
uint32_t ALTERA_PLL_Cntrl_AddrMask = 0x0;
int ALTERA_PLL_Cntrl_AddrOfst = 0;
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
void ALTERA_PLL_SetDefines(uint32_t creg, uint32_t preg, uint32_t rprmsk,
uint32_t wpmsk, uint32_t prmsk, uint32_t amsk,
int aofst, uint32_t wd2msk, int clk2Index) {
@ -201,7 +201,7 @@ void ALTERA_PLL_SetPllReconfigReg(uint32_t reg, uint32_t val,
reg, val, useSecondWRMask));
uint32_t wrmask = ALTERA_PLL_Cntrl_WrPrmtrMask;
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
if (useSecondWRMask) {
wrmask = ALTERA_PLL_Cntrl_DBIT_PLL_WrPrmtrMask;
}
@ -252,7 +252,7 @@ void ALTERA_PLL_SetPhaseShift(int32_t phase, int clkIndex, int pos) {
LOG(logDEBUG1, ("C%d phase word:0x%08x\n", clkIndex, value));
int useSecondWR = 0;
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
if (clkIndex == ALTERA_PLL_Cntrl_DBIT_ClkIndex) {
useSecondWR = 1;
}

View File

@ -23,6 +23,8 @@ extern void bus_w(u_int32_t offset, u_int32_t data);
extern u_int32_t bus_r(u_int32_t offset);
extern int64_t get64BitReg(int aLSB, int aMSB);
extern int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
extern uint64_t getU64BitReg(int aLSB, int aMSB);
extern void setU64BitReg(uint64_t value, int aLSB, int aMSB);
#ifdef MYTHEN3D
#define MAX_LEVELS M3_MAX_PATTERN_LEVELS
@ -30,6 +32,8 @@ extern int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
#define MAX_LEVELS MAX_PATTERN_LEVELS
#endif
char clientPatternfile[MAX_STR_LENGTH];
void initializePatternAddresses() {
LOG(logDEBUG1, ("Setting default Loop and Wait Addresses(0x%x)\n",
MAX_PATTERN_LENGTH - 1));
@ -48,7 +52,7 @@ void initializePatternWord() {
#endif
uint64_t validate_readPatternIOControl() {
return get64BitReg(PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
return getU64BitReg(PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
}
int validate_writePatternIOControl(char *message, uint64_t arg) {
@ -59,14 +63,21 @@ int validate_writePatternIOControl(char *message, uint64_t arg) {
LOG(logDEBUG1,
("Pattern IO Control retval: 0x%llx\n", (long long int)retval));
int ret = OK;
validate64(&ret, message, arg, retval, "set pattern IO Control", HEX);
if (retval != arg) {
ret = FAIL;
sprintf(
message,
"Could not set pattern IO Control. Set 0x%llx, but read 0x%llx\n",
(long long unsigned int)arg, (long long unsigned int)retval);
LOG(logERROR, (message));
}
return ret;
}
void writePatternIOControl(uint64_t word) {
LOG(logINFO,
("Setting Pattern I/O Control: 0x%llx\n", (long long int)word));
set64BitReg(word, PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
setU64BitReg(word, PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
}
#endif
@ -710,20 +721,20 @@ void setPatternLoopAddresses(int level, int startAddr, int stopAddr) {
void setPatternMask(uint64_t mask) {
LOG(logINFO, ("Setting pattern mask to 0x%llx\n", mask));
set64BitReg(mask, PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
setU64BitReg(mask, PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
}
uint64_t getPatternMask() {
return get64BitReg(PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
return getU64BitReg(PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
}
void setPatternBitMask(uint64_t mask) {
LOG(logINFO, ("Setting pattern bit mask to 0x%llx\n", mask));
set64BitReg(mask, PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
setU64BitReg(mask, PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
}
uint64_t getPatternBitMask() {
return get64BitReg(PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
return getU64BitReg(PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
}
#ifdef MYTHEN3D
@ -738,10 +749,15 @@ void startPattern() {
}
#endif
char *getPatternFileName() { return clientPatternfile; }
int loadPattern(char *message, enum TLogLevel printLevel,
patternParameters *pat) {
patternParameters *pat, char *patfname) {
LOG(logINFOBLUE, ("Loading Pattern from structure\n"));
int ret = OK;
memset(clientPatternfile, 0, MAX_STR_LENGTH);
memcpy(clientPatternfile, patfname, MAX_STR_LENGTH);
printf("Client Pattern File:%s\n", clientPatternfile);
#ifdef MYTHEN3D
trimmingPrint = printLevel;
#endif

View File

@ -88,7 +88,7 @@ int main(int argc, char *argv[]) {
"and "
"initial detector setup. \n"
"\t-i, --ignore-config : "
"[Eiger][Jungfrau][Gotthard][Gotthard2][Moench] \n"
"[Eiger][Jungfrau][Gotthard][Gotthard2] \n"
"\t Ignore config file. \n"
"\t-m, --master <master> : "
"[Eiger][Mythen3][Gotthard][Gotthard2] \n"
@ -205,7 +205,7 @@ int main(int argc, char *argv[]) {
case 'i':
#if defined(EIGERD) || defined(GOTTHARDD) || defined(GOTTHARD2D) || \
defined(JUNGFRAUD) || defined(MOENCHD)
defined(JUNGFRAUD)
LOG(logINFO, ("Ignoring config file\n"));
ignoreConfigFileFlag = 1;
#else

View File

@ -67,6 +67,7 @@ int moduleIndex = -1;
// Local variables
int (*flist[NUM_DET_FUNCTIONS])(int);
pthread_t pthread_tid;
pthread_t pthread_tid_ctb_1g;
// scan variables
int scan = 0;
@ -271,6 +272,7 @@ void function_table() {
flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga;
flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits;
flist[F_SET_PATTERN_IO_CONTROL] = &set_pattern_io_control;
flist[F_GET_PATTERN_IO_CONTROL] = &get_pattern_io_control;
flist[F_SET_PATTERN_WORD] = &set_pattern_word;
flist[F_SET_PATTERN_LOOP_ADDRESSES] = &set_pattern_loop_addresses;
flist[F_SET_PATTERN_LOOP_CYCLES] = &set_pattern_loop_cycles;
@ -395,6 +397,7 @@ void function_table() {
flist[F_GET_VETO] = &get_veto;
flist[F_SET_VETO] = &set_veto;
flist[F_SET_PATTERN] = &set_pattern;
flist[F_GET_PATTERN_FILE_NAME] = &get_pattern_file;
flist[F_GET_SCAN] = &get_scan;
flist[F_SET_SCAN] = &set_scan;
flist[F_GET_SCAN_ERROR_MESSAGE] = &get_scan_error_message;
@ -472,6 +475,9 @@ void function_table() {
flist[F_SET_SYNCHRONIZATION] = &set_synchronization;
flist[F_GET_HARDWARE_VERSION] = &get_hardware_version;
flist[F_GET_FRONTEND_FIRMWARE_VERSION] = &get_frontend_firmware_version;
flist[F_GET_BIT] = &get_bit;
flist[F_SET_BIT] = &set_bit;
flist[F_CLEAR_BIT] = &clear_bit;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -1728,7 +1734,7 @@ void validate_settings(enum detectorSettings sett) {
switch (sett) {
#ifdef EIGERD
case STANDARD:
#elif defined(JUNGFRAUD) || defined(MOENCHD)
#elif JUNGFRAUD
case GAIN0:
case HIGHGAIN0:
#elif GOTTHARDD
@ -1745,6 +1751,15 @@ void validate_settings(enum detectorSettings sett) {
case STANDARD:
case FAST:
case HIGHGAIN:
#elif MOENCHD
case G1_HIGHGAIN:
case G1_LOWGAIN:
case G2_HIGHCAP_HIGHGAIN:
case G2_HIGHCAP_LOWGAIN:
case G2_LOWCAP_HIGHGAIN:
case G2_LOWCAP_LOWGAIN:
case G4_HIGHGAIN:
case G4_LOWGAIN:
#endif
break;
default:
@ -1841,7 +1856,7 @@ int acquire(int blocking, int file_des) {
}
// only set
if (Server_VerifyLock() == OK) {
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
// chipv1.1 has to be configured before acquisition
if (getChipVersion() == 11 && !isChipConfigured()) {
ret = FAIL;
@ -1917,7 +1932,9 @@ int acquire(int blocking, int file_des) {
strcpy(mess, "Could not start acquisition thread!\n");
LOG(logERROR, (mess));
} else {
// only does not wait for non blocking and scan
// 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);
}
@ -1999,18 +2016,43 @@ void *start_state_machine(void *arg) {
}
break;
}
#if defined(CHIPTESTBOARDD)
readFrames(&ret, mess);
if (ret == FAIL && scan) {
sprintf(scanErrMessage, "Cannot scan at %d. ", scanSteps[i]);
strcat(scanErrMessage, mess);
sharedMemory_setScanStatus(ERROR);
break;
// only 1g real ctb needs to read from fifo
// to avoid blocking, in another thread
#if defined(CHIPTESTBOARDD) && !defined(VIRTUAL)
if (!enableTenGigabitEthernet(-1)) {
ret = validateUDPSocket();
if (ret == FAIL) {
strcpy(mess, "UDP socket not created!\n");
LOG(logERROR, (mess));
} else {
if (pthread_create(&pthread_tid_ctb_1g, NULL,
&start_reading_and_sending_udp_frames,
NULL)) {
ret = FAIL;
strcpy(mess, "Could not start read frames thread!\n");
LOG(logERROR, (mess));
}
}
// add scan error message
if (ret == FAIL) {
if (scan) {
sprintf(scanErrMessage, "Cannot scan at %d. ",
scanSteps[i]);
strcat(scanErrMessage, mess);
sharedMemory_setScanStatus(ERROR);
}
break;
}
}
#endif
// blocking or scan
if (*blocking || times > 1) {
// wait to finish reading from fifo (1g real ctb)
#if defined(CHIPTESTBOARDD) && !defined(VIRTUAL)
if (!enableTenGigabitEthernet(-1)) {
pthread_join(pthread_tid_ctb_1g, NULL);
}
#endif
#ifdef EIGERD
waitForAcquisitionEnd(&ret, mess);
if (ret == FAIL && scan) {
@ -2031,6 +2073,13 @@ void *start_state_machine(void *arg) {
return NULL;
}
#if defined(CHIPTESTBOARDD) && !defined(VIRTUAL)
void *start_reading_and_sending_udp_frames(void *arg) {
readandSendUDPFrames();
return NULL;
}
#endif
int start_acquisition(int file_des) { return acquire(0, file_des); }
int stop_acquisition(int file_des) {
@ -3116,7 +3165,6 @@ int set_pattern_io_control(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint64_t arg = -1;
uint64_t retval = -1;
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
return printSocketReadError();
@ -3125,14 +3173,25 @@ int set_pattern_io_control(int file_des) {
#else
LOG(logDEBUG1,
("Setting Pattern IO Control to 0x%llx\n", (long long int)arg));
if (((int64_t)arg == GET_FLAG) || (Server_VerifyLock() == OK)) {
if ((int64_t)arg != GET_FLAG) {
ret = validate_writePatternIOControl(mess, arg);
}
retval = validate_readPatternIOControl();
if (Server_VerifyLock() == OK) {
ret = validate_writePatternIOControl(mess, arg);
}
#endif
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
return Server_SendResult(file_des, INT64, NULL, 0);
}
int get_pattern_io_control(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint64_t retval64 = -1;
#if !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
LOG(logDEBUG1, ("Getting Pattern IO Control\n"));
retval64 = validate_readPatternIOControl();
#endif
return Server_SendResult(file_des, INT64, &retval64, sizeof(retval64));
}
int set_pattern_word(int file_des) {
@ -3314,7 +3373,13 @@ int set_pattern_mask(int file_des) {
uint64_t retval64 = getPatternMask();
LOG(logDEBUG1,
("Pattern mask: 0x%llx\n", (long long unsigned int)retval64));
validate64(&ret, mess, arg, retval64, "set Pattern Mask", HEX);
if (retval64 != arg) {
ret = FAIL;
sprintf(
mess, "Could not pattern mask. Set 0x%llx, but read 0x%llx\n",
(long long unsigned int)arg, (long long unsigned int)retval64);
LOG(logERROR, (mess));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
@ -3357,7 +3422,14 @@ int set_pattern_bit_mask(int file_des) {
uint64_t retval64 = getPatternBitMask();
LOG(logDEBUG1,
("Pattern bit mask: 0x%llx\n", (long long unsigned int)retval64));
validate64(&ret, mess, arg, retval64, "set Pattern Bit Mask", HEX);
if (retval64 != arg) {
ret = FAIL;
sprintf(mess,
"Could not pattern bit mask. Set 0x%llx, but read 0x%llx\n",
(long long unsigned int)arg,
(long long unsigned int)retval64);
LOG(logERROR, (mess));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
@ -3999,7 +4071,7 @@ int auto_comp_disable(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting Auto comp disable to %d\n", arg));
#if !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// set & get
@ -5479,7 +5551,8 @@ int set_parallel_mode(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting parallel mode: %u\n", arg));
#if !defined(EIGERD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
#if !defined(EIGERD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \
!defined(MOENCHD)
functionNotImplemented();
#else
// only set
@ -5510,7 +5583,8 @@ int get_parallel_mode(int file_des) {
LOG(logDEBUG1, ("Getting parallel mode\n"));
#if !defined(EIGERD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
#if !defined(EIGERD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \
!defined(MOENCHD)
functionNotImplemented();
#else
// get only
@ -5783,7 +5857,7 @@ int set_clock_phase(int file_des) {
c = ADC_CLK;
break;
#endif
#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD)
case DBIT_CLOCK:
c = DBIT_CLK;
break;
@ -5889,7 +5963,7 @@ int get_clock_phase(int file_des) {
c = ADC_CLK;
break;
#endif
#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD)
case DBIT_CLOCK:
c = DBIT_CLK;
break;
@ -5937,7 +6011,7 @@ int get_max_clock_phase_shift(int file_des) {
c = ADC_CLK;
break;
#endif
#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD)
case DBIT_CLOCK:
c = DBIT_CLK;
break;
@ -6659,7 +6733,7 @@ int set_current_source(int file_des) {
"normal:%d]\n",
enable, fix, (long long int)select, normal));
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// only set
@ -6732,7 +6806,7 @@ int set_current_source(int file_des) {
}
if (ret == OK) {
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
if (enable == 0) {
disableCurrentSource();
} else {
@ -6759,13 +6833,13 @@ int get_current_source(int file_des) {
LOG(logDEBUG1, ("Getting current source\n"));
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only
retvals[0] = getCurrentSource();
LOG(logDEBUG1, ("current source enable retval: %u\n", retvals[0]));
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
if (retvals[0]) {
retvals[1] = getFixCurrentSource();
retvals[2] = getNormalCurrentSource();
@ -7149,7 +7223,7 @@ int get_receiver_parameters(int file_des) {
return printSocketReadError();
// readout mode
#ifdef CHIPTESTBOARD
#ifdef CHIPTESTBOARDD
i32 = getReadoutMode();
#else
i32 = 0;
@ -7540,6 +7614,8 @@ int set_veto(int file_des) {
int set_pattern(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
char args[MAX_STR_LENGTH];
memset(args, 0, MAX_STR_LENGTH);
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
@ -7553,10 +7629,15 @@ int set_pattern(int file_des) {
free(pat);
return printSocketReadError();
}
if (receiveData(file_des, args, MAX_STR_LENGTH, OTHER) < 0) {
if (pat != NULL)
free(pat);
return printSocketReadError();
}
if (Server_VerifyLock() == OK) {
LOG(logINFO, ("Setting Pattern from structure\n"));
ret = loadPattern(mess, logINFO, pat);
LOG(logDEBUG1, ("Setting Pattern from structure\n"));
ret = loadPattern(mess, logINFO, pat, args);
}
if (pat != NULL)
free(pat);
@ -7565,6 +7646,24 @@ int set_pattern(int file_des) {
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_pattern_file(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
char retvals[MAX_STR_LENGTH];
memset(retvals, 0, MAX_STR_LENGTH);
LOG(logDEBUG1, ("Getting pattern file name\n"));
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// get only
strcpy(retvals, getPatternFileName());
LOG(logDEBUG1, ("pattern file name retval: %s\n", retvals));
#endif
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
}
int get_pattern(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
@ -7780,11 +7879,11 @@ int get_filter_resistor(int file_des) {
LOG(logDEBUG1, ("Getting filter resistor\n"));
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
if (getChipVersion() == 10) {
ret = FAIL;
strcpy(mess, "Could not get filter cell. Not available for this chip "
@ -7809,7 +7908,7 @@ int set_filter_resistor(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting filter resistor: %u\n", arg));
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// only set
@ -7823,7 +7922,7 @@ int set_filter_resistor(int file_des) {
arg, ASIC_FILTER_MAX_RES_VALUE);
LOG(logERROR, (mess));
}
#if defined(JUNGFRAUD) || defined(MOENCHD)
#if defined(JUNGFRAUD)
else if (getChipVersion() == 10) {
ret = FAIL;
strcpy(mess, "Could not set filter cell. Not available for this "
@ -7837,9 +7936,8 @@ int set_filter_resistor(int file_des) {
strcpy(mess, "Could not set filter resistor.\n");
LOG(logERROR, (mess));
}
#if !defined(JUNGFRAUD) && !defined(MOENCHD)
// jungfrau/moench might take time to update status register if
// acquiring
#if defined(GOTTHARD2D)
// jungfrau might take time to update status register if acquiring
int retval = getFilterResistor();
LOG(logDEBUG1, ("filter resistor retval: %u\n", retval));
validate(&ret, mess, arg, retval, "set filter resistor", DEC);
@ -8550,7 +8648,7 @@ int get_chip_version(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
#if !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
retval = getChipVersion();
@ -8657,7 +8755,7 @@ int get_gain_mode(int file_des) {
enum gainMode retval = DYNAMIC;
LOG(logDEBUG1, ("Getting gain mode\n"));
#if !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only
@ -8681,7 +8779,7 @@ int set_gain_mode(int file_des) {
enum gainMode gainmode = arg;
LOG(logDEBUG1, ("Setting gain mode %d\n", (int)gainmode));
#if !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// only set
@ -8717,7 +8815,7 @@ int get_comp_disable_time(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
#if !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only
@ -8743,7 +8841,7 @@ int set_comp_disable_time(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting comp disable time %lld ns\n", (long long int)arg));
#if !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// only set
@ -8843,7 +8941,7 @@ int get_num_filter_cells(int file_des) {
LOG(logDEBUG1, ("Getting number of filter cellsn"));
#if !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only
@ -8870,7 +8968,7 @@ int set_num_filter_cells(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting number of filter cells: %u\n", (int)arg));
#if !defined(JUNGFRAUD) && !defined(MOENCHD)
#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// only set
@ -10201,4 +10299,136 @@ int get_frontend_firmware_version(int file_des) {
}
#endif
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
}
int set_bit(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint32_t args[2] = {-1, -1};
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
uint32_t addr = args[0];
int nBit = (int)args[1];
LOG(logDEBUG1, ("Setting bit %d of reg 0x%x\n", nBit, addr));
// only set
if (Server_VerifyLock() == OK) {
if (nBit < 0 || nBit > 31) {
ret = FAIL;
sprintf(
mess,
"Could not set bit. Bit nr %d out of range. Must be 0-31\n",
nBit);
LOG(logERROR, (mess));
} else {
#ifdef EIGERD
ret = setBit(addr, nBit);
if (ret == FAIL) {
#else
uint32_t bitmask = (1 << nBit);
#ifdef GOTTHARDD
uint32_t val = readRegister16And32(addr) | bitmask;
uint32_t retval = writeRegister16And32(addr, val);
#else
uint32_t val = readRegister(addr) | bitmask;
uint32_t retval = writeRegister(addr, val);
#endif
if (!(retval & bitmask)) {
ret = FAIL;
#endif
sprintf(mess, "Could not set bit %d.\n", nBit);
LOG(logERROR, (mess));
}
}
}
return Server_SendResult(file_des, INT32, NULL, 0);
}
int clear_bit(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint32_t args[2] = {-1, -1};
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
uint32_t addr = args[0];
int nBit = (int)args[1];
LOG(logDEBUG1, ("Clearing bit %d of reg 0x%x\n", nBit, addr));
// only set
if (Server_VerifyLock() == OK) {
if (nBit < 0 || nBit > 31) {
ret = FAIL;
sprintf(
mess,
"Could not clear bit. Bit nr %d out of range. Must be 0-31\n",
nBit);
LOG(logERROR, (mess));
} else {
#ifdef EIGERD
ret = clearBit(addr, nBit);
if (ret == FAIL) {
#else
uint32_t bitmask = (1 << nBit);
#ifdef GOTTHARDD
uint32_t val = readRegister16And32(addr) & ~bitmask;
uint32_t retval = writeRegister16And32(addr, val);
#else
uint32_t val = readRegister(addr) & ~bitmask;
uint32_t retval = writeRegister(addr, val);
#endif
if (retval & bitmask) {
ret = FAIL;
#endif
sprintf(mess, "Could not clear bit %d.\n", nBit);
LOG(logERROR, (mess));
}
}
}
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_bit(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint32_t args[2] = {-1, -1};
int retval = 0;
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
uint32_t addr = args[0];
int nBit = (int)args[1];
LOG(logDEBUG1, ("Getting bit %d of reg 0x%x\n", nBit, addr));
// only set
if (Server_VerifyLock() == OK) {
if (nBit < 0 || nBit > 31) {
ret = FAIL;
sprintf(
mess,
"Could not get bit. Bit nr %d out of range. Must be 0-31\n",
nBit);
LOG(logERROR, (mess));
} else {
#ifdef EIGERD
ret = getBit(addr, nBit, &retval);
LOG(logDEBUG1, ("retval: %d\n", retval));
if (ret == FAIL) {
#else
#ifdef GOTTHARDD
retval = readRegister16And32(addr);
#else
retval = readRegister(addr);
#endif
LOG(logDEBUG1, ("retval: %d\n", retval));
if (retval & (1 << nBit)) {
ret = FAIL;
#endif
sprintf(mess, "Could not get bit %d.\n", nBit);
LOG(logERROR, (mess));
}
}
}
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}

View File

@ -129,11 +129,14 @@ class Detector {
/** [Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
Result<defs::detectorSettings> getSettings(Positions pos = {}) const;
/** [Jungfrau][Moench] GAIN0, HIGHGAIN0 \n [Gotthard] DYNAMICGAIN, HIGHGAIN,
/** [Jungfrau] GAIN0, HIGHGAIN0 \n [Gotthard] DYNAMICGAIN, HIGHGAIN,
* LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN \n [Gotthard2] DYNAMICGAIN,
* FIXGAIN1, FIXGAIN2 \n [Mythen3] STANDARD, FAST,
* HIGHGAIN. Also changes vrshaper and vrpreamp \n [Eiger] Use threshold
* command. Settings loaded from file found in settingspath
* command. Settings loaded from file found in settingspath \n
* [Moench] G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN,
* G2_HIGHCAP_LOWGAIN, G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN,
* G4_LOWGAIN
*/
void setSettings(defs::detectorSettings value, Positions pos = {});
@ -352,12 +355,12 @@ class Detector {
Result<defs::speedLevel> getReadoutSpeed(Positions pos = {}) const;
/** [Eiger][Jungfrau][Moench][Gotthard2]
* [Jungfrau][Moench] Options: FULL_SPEED, HALF_SPEED (Default),
* QUARTER_SPEED \n [Eiger] Options: FULL_SPEED (Default), HALF_SPEED,
* QUARTER_SPEED \n [Gotthard2] Options: G2_108MHZ (Default), G2_144MHZ \n
* [Jungfrau][Moench] FULL_SPEED option only available from v2.0 boards and
* is recommended to set number of interfaces to 2. \n Also overwrites
* adcphase to recommended default.
* [Jungfrau] Options: FULL_SPEED, HALF_SPEED (Default),
* QUARTER_SPEED \n [Moench] Options: FULL_SPEED (Default) \n [Eiger]
* Options: FULL_SPEED (Default), HALF_SPEED, QUARTER_SPEED \n [Gotthard2]
* Options: G2_108MHZ (Default), G2_144MHZ \n [Jungfrau][Moench] FULL_SPEED
* option only available from v2.0 boards and is recommended to set number
* of interfaces to 2. \n Also overwrites adcphase to recommended default.
*/
void setReadoutSpeed(defs::speedLevel value, Positions pos = {});
@ -389,21 +392,21 @@ class Detector {
*/
void setADCPhaseInDegrees(int value, Positions pos = {});
/** [CTB][Jungfrau][Moench] */
/** [CTB][Jungfrau] */
Result<int> getDBITPhase(Positions pos = {}) const;
/** [CTB][Jungfrau][Moench] Absolute phase shift \n
/** [CTB][Jungfrau] Absolute phase shift \n
* [CTB] changing dbitclk also resets dbitphase and sets to previous values.
*/
void setDBITPhase(int value, Positions pos = {});
/** [CTB][Jungfrau][Moench] */
/** [CTB][Jungfrau] */
Result<int> getMaxDBITPhaseShift(Positions pos = {}) const;
/** [CTB][Jungfrau][Moench] */
/** [CTB][Jungfrau] */
Result<int> getDBITPhaseInDegrees(Positions pos = {}) const;
/** [CTB][Jungfrau][Moench] Absolute phase shift \n
/** [CTB][Jungfrau] Absolute phase shift \n
* [CTB] changing dbitclk also resets dbitphase and sets to previous values.
*/
void setDBITPhaseInDegrees(int value, Positions pos = {});
@ -529,30 +532,30 @@ class Detector {
void setExternalSignalFlags(int signalIndex, defs::externalSignalFlag value,
Positions pos = {});
/** [Eiger][Mythen3][Gotthard2] */
/** [Eiger][Mythen3][Gotthard2][Moench] */
Result<bool> getParallelMode(Positions pos = {}) const;
/** [Eiger][Mythen3][Gotthard2]
/** [Eiger][Mythen3][Gotthard2][Moench]
* [Mythen3] If exposure time is too short, acquisition will return with an
* ERROR and take fewer frames than expected \n
* [Mythen3][Eiger] Default: Non parallel \n
* [Mythen3][Eiger][Moench] Default: Non parallel \n
* [Gotthard2] Default: Parallel. Non parallel mode works only in continuous
* mode.*/
void setParallelMode(bool value, Positions pos = {});
/** [Gotthard2][Jungfrau][Moench] */
/** [Gotthard2][Jungfrau] */
Result<int> getFilterResistor(Positions pos = {}) const;
/** [Gotthard2][Jungfrau][Moench] Set filter resistor. Increasing values for
/** [Gotthard2][Jungfrau] Set filter resistor. Increasing values for
* increasing resistance.\n[Gotthard2] Options: [0|1|2|3]. Default is
* 0.\n[Jungfrau][Moench] Options: [0|1]. Default is 1.*/
* 0.\n[Jungfrau] Options: [0|1]. Default is 1.*/
void setFilterResistor(int value, Positions pos = {});
/** [Gotthard2][Jungfrau][Moench] */
/** [Gotthard2][Jungfrau] */
Result<defs::currentSrcParameters>
getCurrentSource(Positions pos = {}) const;
/** [Gotthard2][Jungfrau][Moench] Please refer documentation on
/** [Gotthard2][Jungfrau] Please refer documentation on
* currentSrcParameters (sls_detector_defs.h) on the structure and its
* members */
void setCurrentSource(defs::currentSrcParameters par, Positions pos = {});
@ -1250,7 +1253,7 @@ class Detector {
* *
* ************************************************/
/** [Jungfrau][Moench] */
/** [Jungfrau] */
Result<double> getChipVersion(Positions pos = {}) const;
/** [Jungfrau][Moench] */
@ -1279,10 +1282,10 @@ class Detector {
/** [Jungfrau][Moench] refer to setThresdholdTemperature */
void resetTemperatureEvent(Positions pos = {});
/** [Jungfrau][Moench] */
/** [Jungfrau] */
Result<bool> getAutoComparatorDisable(Positions pos = {}) const;
/** [Jungfrau][Moench] Advanced
/** [Jungfrau] Advanced
* //TODO naming
* By default, the on-chip gain switching is active during the
* entire exposure. This mode disables the on-chip gain switching comparator
@ -1294,10 +1297,10 @@ class Detector {
*/
void setAutoComparatorDisable(bool value, Positions pos = {});
/** [Jungfrau][Moench] */
/** [Jungfrau] */
Result<ns> getComparatorDisableTime(Positions pos = {}) const;
/** [Jungfrau][Moench] Time before end of exposure when comparator is
/** [Jungfrau] Time before end of exposure when comparator is
* disabled. It is only possible for chipv1.1.*/
void setComparatorDisableTime(ns t, Positions pos = {});
@ -1330,19 +1333,19 @@ class Detector {
/** list of possible gainmode */
std::vector<defs::gainMode> getGainModeList() const;
/** [Jungfrau][Moench]*/
/** [Jungfrau]*/
Result<defs::gainMode> getGainMode(Positions pos = {}) const;
/** [Jungfrau][Moench] Options: DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2,
/** [Jungfrau] Options: DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2,
* FIX_G1, FIX_G2, FIX_G0 \n\CAUTION: Do not use FIX_G0 without caution, you
* can damage the detector!!!\n
*/
void setGainMode(const defs::gainMode mode, Positions pos = {});
/** [Jungfrau][Moench] Advanced */
/** [Jungfrau] Advanced */
Result<int> getNumberOfFilterCells(Positions pos = {}) const;
/** [Jungfrau][Moench] Advanced Options[0-12], only for chip v1.1
/** [Jungfrau] Advanced Options[0-12], only for chip v1.1
*/
void setNumberOfFilterCells(int cell, Positions pos = {});
@ -1608,6 +1611,12 @@ class Detector {
/** [CTB] */
void setADCPipeline(int value, Positions pos = {});
/** gets list of voltage enums */
std::vector<defs::dacIndex> getVoltageList() const;
/** gets list of slow adc enums */
std::vector<defs::dacIndex> getSlowADCList() const;
/** [CTB] */
Result<int> getVoltage(defs::dacIndex index, Positions pos = {}) const;
@ -1721,12 +1730,79 @@ class Detector {
/** [CTB] Default is enabled. */
void setLEDEnable(bool enable, Positions pos = {});
/** [CTB] */
void setDacNames(const std::vector<std::string> names);
std::vector<std::string> getDacNames() const;
defs::dacIndex getDacIndex(const std::string &name);
std::string getDacName(defs::dacIndex i);
defs::dacIndex getDacIndex(const std::string &name) const;
/** [CTB] */
void setDacName(const defs::dacIndex i, const std::string &name);
/** [CTB] */
std::string getDacName(const defs::dacIndex i) const;
/** [CTB] */
void setAdcNames(const std::vector<std::string> names);
/** [CTB] */
std::vector<std::string> getAdcNames() const;
/** [CTB] */
int getAdcIndex(const std::string &name) const;
/** [CTB] */
void setAdcName(const int i, const std::string &name);
/** [CTB] */
std::string getAdcName(const int i) const;
/** [CTB] */
void setSignalNames(const std::vector<std::string> names);
/** [CTB] */
std::vector<std::string> getSignalNames() const;
/** [CTB] */
int getSignalIndex(const std::string &name) const;
/** [CTB] */
void setSignalName(const int i, const std::string &name);
/** [CTB] */
std::string getSignalName(const int i) const;
/** [CTB] */
void setVoltageNames(const std::vector<std::string> names);
/** [CTB] */
std::vector<std::string> getVoltageNames() const;
/** [CTB] */
defs::dacIndex getVoltageIndex(const std::string &name) const;
/** [CTB] */
void setVoltageName(const defs::dacIndex i, const std::string &name);
/** [CTB] */
std::string getVoltageName(const defs::dacIndex i) const;
/** [CTB] */
void setSlowADCNames(const std::vector<std::string> names);
/** [CTB] */
std::vector<std::string> getSlowADCNames() const;
/** [CTB] */
defs::dacIndex getSlowADCIndex(const std::string &name) const;
/** [CTB] */
void setSlowADCName(const defs::dacIndex i, const std::string &name);
/** [CTB] */
std::string getSlowADCName(const defs::dacIndex i) const;
///@}
/** @name Pattern */
@ -1736,6 +1812,10 @@ class Detector {
* Pattern *
* *
* ************************************************/
/** [CTB][Mythen3] Gets the pattern file name including path of the last
* pattern uploaded. \n Returns an empty if nothing was uploaded or via a
* server default file*/
Result<std::string> getPatterFileName(Positions pos = {}) const;
/** [CTB][Mythen3] Loads ASCII pattern file directly to server
* (instead of executing line by line)*/

View File

@ -702,13 +702,11 @@ std::string CmdProxy::ReadoutSpeed(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "\n\t[0 or full_speed|1 or half_speed|2 or "
"quarter_speed]\n\t\t[Eiger][Jungfrau][Moench] Readout "
"speed of chip.\n\t\t[Eiger] Default speed is full_speed."
"\n\t\t[Jungfrau][Moench] Default speed is half_speed. "
"full_speed "
"option only available from v2.0 boards and is recommended to "
"set "
"number of interfaces to 2. Also overwrites "
"quarter_speed]\n\t\t[Eiger][Jungfrau][Moench] Readout speed of "
"chip.\n\t\t[Eiger][Moench] Default speed is "
"full_speed.\n\t\t[Jungfrau] Default speed is half_speed. "
"full_speed option only available from v2.0 boards and is "
"recommended to set number of interfaces to 2. Also overwrites "
"adcphase to recommended default.\n\t [144|108]\n\t\t[Gotthard2] "
"Readout speed of chip in MHz. Default is 108."
<< '\n';
@ -800,8 +798,7 @@ std::string CmdProxy::Dbitphase(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[n_value] [(optional)deg]\n\t[Ctb][Jungfrau][Moench] Phase "
"shift of "
os << "[n_value] [(optional)deg]\n\t[Ctb][Jungfrau] Phase shift of "
"clock to latch digital bits. Absolute phase shift. If deg used, "
"then shift in degrees. \n\t[Ctb]Changing dbitclk also resets "
"dbitphase and sets to previous values."
@ -809,7 +806,7 @@ std::string CmdProxy::Dbitphase(int action) {
} else {
auto det_type = det->getDetectorType().squash(defs::GENERIC);
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD2) {
det_type == defs::GOTTHARD2 || det_type == defs::MOENCH) {
throw RuntimeError("dbitphase not implemented for this detector");
}
if (action == defs::GET_ACTION) {
@ -1038,8 +1035,7 @@ std::string CmdProxy::CurrentSource(int action) {
os << "\n\t[0|1]\n\t\t[Gotthard2] Enable or disable current source. "
"Default "
"is disabled.\n\t[0|1] [fix|nofix] [select source] [(only for "
"chipv1.1)normal|low]\n\t\t[Jungfrau][Moench] Disable or enable "
"current "
"chipv1.1)normal|low]\n\t\t[Jungfrau] Disable or enable current "
"source with some parameters. The select source is 0-63 for "
"chipv1.0 and a 64 bit mask for chipv1.1. To disable, one needs "
"only one argument '0'."
@ -1130,6 +1126,8 @@ std::string CmdProxy::TemperatureValues(int action) {
return os.str();
}
/* list */
/* dacs */
std::string CmdProxy::Dac(int action) {
std::ostringstream os;
@ -1208,41 +1206,6 @@ std::string CmdProxy::Dac(int action) {
return os.str();
}
std::string CmdProxy::DacList(const int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == slsDetectorDefs::HELP_ACTION) {
os << "\n\t[dacname1 dacname2 .. dacname18] \n\t\t[ChipTestBoard] Set "
"the list of dac names for this detector.\n\t\t[All] Gets the "
"list "
"of "
"dac names for every dac for this detector."
<< '\n';
} else if (action == slsDetectorDefs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getDacNames();
os << ToString(t) << '\n';
} else if (action == slsDetectorDefs::PUT_ACTION) {
if (det->getDetectorType().squash() != defs::CHIPTESTBOARD) {
throw RuntimeError("This detector already has fixed dac "
"names. Cannot change them.");
}
if (det_id != -1) {
throw RuntimeError("Cannot configure dacnames at module level");
}
if (args.size() != 18) {
WrongNumberOfParameters(18);
}
det->setDacNames(args);
os << ToString(args) << '\n';
} else {
throw RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::DacValues(int action) {
std::ostringstream os;
os << cmd << ' ';
@ -2696,7 +2659,7 @@ std::string CmdProxy::AdcVpp(int action) {
return os.str();
}
std::string CmdProxy::SlowAdc(int action) {
std::string CmdProxy::SlowADC(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {

File diff suppressed because it is too large Load Diff

View File

@ -12,14 +12,62 @@ namespace sls {
CtbConfig::CtbConfig() {
for (size_t i = 0; i != num_dacs; ++i) {
setDacName(i, "dac" + ToString(i));
setDacName(i, "DAC" + ToString(i));
}
for (size_t i = 0; i != num_adcs; ++i) {
setAdcName(i, "ADC" + ToString(i));
}
for (size_t i = 0; i != num_signals; ++i) {
setSignalName(i, "BIT" + ToString(i));
}
setVoltageName(0, "VA");
setVoltageName(1, "VB");
setVoltageName(2, "VC");
setVoltageName(3, "VD");
setVoltageName(4, "VIO");
for (size_t i = 0; i != num_slowADCs; ++i) {
setSlowADCName(i, "SLOWADC" + ToString(i));
}
}
void CtbConfig::check_index(size_t i) const {
if (!(i < num_dacs)) {
void CtbConfig::check_dac_index(size_t i) const {
if (i >= num_dacs) {
std::ostringstream oss;
oss << "DAC index is too large needs to be below " << num_dacs;
oss << "Invalid DAC index. Options: 0 - " << num_dacs;
throw RuntimeError(oss.str());
}
}
void CtbConfig::check_adc_index(size_t i) const {
if (i >= num_adcs) {
std::ostringstream oss;
oss << "Invalid ADC index. Options: 0 - " << num_adcs;
throw RuntimeError(oss.str());
}
}
void CtbConfig::check_signal_index(size_t i) const {
if (i >= num_signals) {
std::ostringstream oss;
oss << "Invalid Signal index. Options: 0 - " << num_signals;
throw RuntimeError(oss.str());
}
}
void CtbConfig::check_voltage_index(size_t i) const {
if (i >= num_voltages) {
std::ostringstream oss;
oss << "Invalid Voltage index. Options: 0 - " << num_voltages
<< " or V_POWER_A - V_POWER_IO";
throw RuntimeError(oss.str());
}
}
void CtbConfig::check_slow_adc_index(size_t i) const {
if (i >= num_slowADCs) {
std::ostringstream oss;
oss << "Invalid Slow ADC index. Options: 0 - " << num_slowADCs
<< " or SLOW_ADC0 - SLOW_ADC7";
throw RuntimeError(oss.str());
}
}
@ -29,7 +77,7 @@ void CtbConfig::check_size(const std::string &name) const {
if (name.empty())
throw RuntimeError("Name needs to be at least one character");
// dacname_length -1 to account for \0 termination
// name_length -1 to account for \0 termination
if (!(name.size() < (name_length - 1))) {
std::ostringstream oss;
oss << "Length of name needs to be less than " << name_length - 1
@ -39,22 +87,25 @@ void CtbConfig::check_size(const std::string &name) const {
}
void CtbConfig::setDacName(size_t index, const std::string &name) {
check_index(index);
check_dac_index(index);
check_size(name);
char *dst = &dacnames[index * name_length];
memset(dst, '\0', name_length);
memcpy(dst, &name[0], name.size());
}
void CtbConfig::setDacNames(const std::vector<std::string> &names) {
if (names.size() != num_dacs) {
throw RuntimeError("Dac names need to be of size " +
std::to_string(num_dacs));
}
for (size_t i = 0; i != num_dacs; ++i) {
setDacName(i, names[i]);
}
}
std::string CtbConfig::getDacName(size_t index) const {
check_dac_index(index);
return dacnames + index * name_length;
}
@ -65,6 +116,126 @@ std::vector<std::string> CtbConfig::getDacNames() const {
return names;
}
void CtbConfig::setAdcName(size_t index, const std::string &name) {
check_adc_index(index);
check_size(name);
char *dst = &adcnames[index * name_length];
memset(dst, '\0', name_length);
memcpy(dst, &name[0], name.size());
}
void CtbConfig::setAdcNames(const std::vector<std::string> &names) {
if (names.size() != num_adcs) {
throw RuntimeError("Adc names need to be of size " +
std::to_string(num_adcs));
}
for (size_t i = 0; i != num_adcs; ++i) {
setAdcName(i, names[i]);
}
}
std::string CtbConfig::getAdcName(size_t index) const {
check_adc_index(index);
return adcnames + index * name_length;
}
std::vector<std::string> CtbConfig::getAdcNames() const {
std::vector<std::string> names;
for (size_t i = 0; i != num_adcs; ++i)
names.push_back(getAdcName(i));
return names;
}
void CtbConfig::setSignalName(size_t index, const std::string &name) {
check_signal_index(index);
check_size(name);
char *dst = &signalnames[index * name_length];
memset(dst, '\0', name_length);
memcpy(dst, &name[0], name.size());
}
void CtbConfig::setSignalNames(const std::vector<std::string> &names) {
if (names.size() != num_signals) {
throw RuntimeError("Signal names need to be of size " +
std::to_string(num_signals));
}
for (size_t i = 0; i != num_signals; ++i) {
setSignalName(i, names[i]);
}
}
std::string CtbConfig::getSignalName(size_t index) const {
check_signal_index(index);
return signalnames + index * name_length;
}
std::vector<std::string> CtbConfig::getSignalNames() const {
std::vector<std::string> names;
for (size_t i = 0; i != num_signals; ++i)
names.push_back(getSignalName(i));
return names;
}
void CtbConfig::setVoltageName(size_t index, const std::string &name) {
check_voltage_index(index);
check_size(name);
char *dst = &voltagenames[index * name_length];
memset(dst, '\0', name_length);
memcpy(dst, &name[0], name.size());
}
void CtbConfig::setVoltageNames(const std::vector<std::string> &names) {
if (names.size() != num_voltages) {
throw RuntimeError("Voltage names need to be of size " +
std::to_string(num_voltages));
}
for (size_t i = 0; i != num_voltages; ++i) {
setVoltageName(i, names[i]);
}
}
std::string CtbConfig::getVoltageName(size_t index) const {
check_voltage_index(index);
return voltagenames + index * name_length;
}
std::vector<std::string> CtbConfig::getVoltageNames() const {
std::vector<std::string> names;
for (size_t i = 0; i != num_voltages; ++i)
names.push_back(getVoltageName(i));
return names;
}
void CtbConfig::setSlowADCName(size_t index, const std::string &name) {
check_slow_adc_index(index);
check_size(name);
char *dst = &slowADCnames[index * name_length];
memset(dst, '\0', name_length);
memcpy(dst, &name[0], name.size());
}
void CtbConfig::setSlowADCNames(const std::vector<std::string> &names) {
if (names.size() != num_slowADCs) {
throw RuntimeError("Slow ADC names need to be of size " +
std::to_string(num_slowADCs));
}
for (size_t i = 0; i != num_slowADCs; ++i) {
setSlowADCName(i, names[i]);
}
}
std::string CtbConfig::getSlowADCName(size_t index) const {
check_slow_adc_index(index);
return slowADCnames + index * name_length;
}
std::vector<std::string> CtbConfig::getSlowADCNames() const {
std::vector<std::string> names;
for (size_t i = 0; i != num_slowADCs; ++i)
names.push_back(getSlowADCName(i));
return names;
}
const char *CtbConfig::shm_tag() { return shm_tag_; }
} // namespace sls

View File

@ -6,10 +6,22 @@ namespace sls {
class CtbConfig {
static constexpr size_t name_length = 20;
static constexpr size_t num_dacs = 18;
static constexpr size_t num_adcs = 32;
static constexpr size_t num_signals = 64;
static constexpr size_t num_voltages = 5;
static constexpr size_t num_slowADCs = 8;
static constexpr const char *shm_tag_ = "ctbdacs";
char dacnames[name_length * num_dacs]{};
char adcnames[name_length * num_adcs]{};
char signalnames[name_length * num_signals]{};
char voltagenames[name_length * num_voltages]{};
char slowADCnames[name_length * num_slowADCs]{};
void check_index(size_t i) const;
void check_dac_index(size_t i) const;
void check_adc_index(size_t i) const;
void check_signal_index(size_t i) const;
void check_voltage_index(size_t i) const;
void check_slow_adc_index(size_t i) const;
void check_size(const std::string &name) const;
public:
@ -23,6 +35,26 @@ class CtbConfig {
void setDacName(size_t index, const std::string &name);
std::string getDacName(size_t index) const;
std::vector<std::string> getDacNames() const;
void setAdcNames(const std::vector<std::string> &names);
void setAdcName(size_t index, const std::string &name);
std::string getAdcName(size_t index) const;
std::vector<std::string> getAdcNames() const;
void setSignalNames(const std::vector<std::string> &names);
void setSignalName(size_t index, const std::string &name);
std::string getSignalName(size_t index) const;
std::vector<std::string> getSignalNames() const;
void setVoltageNames(const std::vector<std::string> &names);
void setVoltageName(size_t index, const std::string &name);
std::string getVoltageName(size_t index) const;
std::vector<std::string> getVoltageNames() const;
void setSlowADCNames(const std::vector<std::string> &names);
void setSlowADCName(size_t index, const std::string &name);
std::string getSlowADCName(size_t index) const;
std::vector<std::string> getSlowADCNames() const;
static const char *shm_tag();
};

View File

@ -190,7 +190,6 @@ std::vector<defs::detectorSettings> Detector::getSettingsList() const {
defs::HIGHGAIN, defs::DYNAMICGAIN, defs::LOWGAIN, defs::MEDIUMGAIN,
defs::VERYHIGHGAIN};
case defs::JUNGFRAU:
case defs::MOENCH:
return std::vector<defs::detectorSettings>{defs::GAIN0,
defs::HIGHGAIN0};
case defs::GOTTHARD2:
@ -199,6 +198,12 @@ std::vector<defs::detectorSettings> Detector::getSettingsList() const {
case defs::MYTHEN3:
return std::vector<defs::detectorSettings>{defs::STANDARD, defs::FAST,
defs::HIGHGAIN};
case defs::MOENCH:
return std::vector<defs::detectorSettings>{
defs::G1_HIGHGAIN, defs::G1_LOWGAIN,
defs::G2_HIGHCAP_HIGHGAIN, defs::G2_HIGHCAP_LOWGAIN,
defs::G2_LOWCAP_HIGHGAIN, defs::G2_LOWCAP_LOWGAIN,
defs::G4_HIGHGAIN, defs::G4_LOWGAIN};
case defs::CHIPTESTBOARD:
throw RuntimeError("Settings not implemented for this detector");
default:
@ -1704,7 +1709,6 @@ void Detector::setStorageCellDelay(ns value, Positions pos) {
std::vector<defs::gainMode> Detector::getGainModeList() const {
switch (getDetectorType().squash()) {
case defs::JUNGFRAU:
case defs::MOENCH:
return std::vector<defs::gainMode>{
defs::DYNAMIC, defs::FORCE_SWITCH_G1, defs::FORCE_SWITCH_G2,
defs::FIX_G1, defs::FIX_G2, defs::FIX_G0};
@ -2036,6 +2040,24 @@ void Detector::setADCPipeline(int value, Positions pos) {
pimpl->Parallel(&Module::setADCPipeline, pos, value);
}
std::vector<defs::dacIndex> Detector::getVoltageList() const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) {
throw RuntimeError("Voltage list not implemented for this detector");
}
return std::vector<defs::dacIndex>{defs::V_POWER_A, defs::V_POWER_B,
defs::V_POWER_C, defs::V_POWER_D,
defs::V_POWER_IO};
}
std::vector<defs::dacIndex> Detector::getSlowADCList() const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) {
throw RuntimeError("Slow ADC list not implemented for this detector");
}
return std::vector<defs::dacIndex>{
defs::SLOW_ADC0, defs::SLOW_ADC1, defs::SLOW_ADC2, defs::SLOW_ADC3,
defs::SLOW_ADC4, defs::SLOW_ADC5, defs::SLOW_ADC6, defs::SLOW_ADC7};
}
Result<int> Detector::getVoltage(defs::dacIndex index, Positions pos) const {
switch (index) {
case defs::V_LIMIT:
@ -2220,37 +2242,185 @@ std::vector<std::string> Detector::getDacNames() const {
return names;
}
defs::dacIndex Detector::getDacIndex(const std::string &name) {
defs::dacIndex Detector::getDacIndex(const std::string &name) const {
auto type = getDetectorType().squash();
if (type == defs::CHIPTESTBOARD) {
auto names = getDacNames();
auto it = std::find(names.begin(), names.end(), name);
if (it == names.end())
throw RuntimeError("Dacname not found");
throw RuntimeError("Dac name not found");
return static_cast<defs::dacIndex>(it - names.begin());
}
return StringTo<defs::dacIndex>(name);
}
std::string Detector::getDacName(defs::dacIndex i) {
void Detector::setDacName(const defs::dacIndex i, const std::string &name) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named dacs only for CTB");
pimpl->setCtbDacName(i, name);
}
std::string Detector::getDacName(const defs::dacIndex i) const {
auto type = getDetectorType().squash();
if (type == defs::CHIPTESTBOARD)
return pimpl->getCtbDacName(i);
return ToString(i);
}
void Detector::setAdcNames(const std::vector<std::string> names) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named adcs only for CTB");
pimpl->setCtbAdcNames(names);
}
std::vector<std::string> Detector::getAdcNames() const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named adcs only for CTB");
return pimpl->getCtbAdcNames();
}
int Detector::getAdcIndex(const std::string &name) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named adcs only for CTB");
auto names = getAdcNames();
auto it = std::find(names.begin(), names.end(), name);
if (it == names.end())
throw RuntimeError("Adc name not found");
return (it - names.begin());
}
void Detector::setAdcName(const int index, const std::string &name) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named adcs only for CTB");
pimpl->setCtbAdcName(index, name);
}
std::string Detector::getAdcName(const int i) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named adcs only for CTB");
return pimpl->getCtbAdcName(i);
}
void Detector::setSignalNames(const std::vector<std::string> names) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named signals only for CTB");
pimpl->setCtbSignalNames(names);
}
std::vector<std::string> Detector::getSignalNames() const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named signals only for CTB");
return pimpl->getCtbSignalNames();
}
int Detector::getSignalIndex(const std::string &name) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named signals only for CTB");
auto names = getSignalNames();
auto it = std::find(names.begin(), names.end(), name);
if (it == names.end())
throw RuntimeError("Signalname not found");
return (it - names.begin());
}
void Detector::setSignalName(const int index, const std::string &name) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named signals only for CTB");
pimpl->setCtbSignalName(index, name);
}
std::string Detector::getSignalName(const int i) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named signals only for CTB");
return pimpl->getCtbSignalName(i);
}
void Detector::setVoltageNames(const std::vector<std::string> names) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named powers only for CTB");
pimpl->setCtbVoltageNames(names);
}
std::vector<std::string> Detector::getVoltageNames() const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named powers only for CTB");
return pimpl->getCtbVoltageNames();
}
defs::dacIndex Detector::getVoltageIndex(const std::string &name) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named powers only for CTB");
auto names = getVoltageNames();
auto it = std::find(names.begin(), names.end(), name);
if (it == names.end())
throw RuntimeError("Voltage name not found");
return static_cast<defs::dacIndex>(it - names.begin() + defs::V_POWER_A);
}
void Detector::setVoltageName(const defs::dacIndex index,
const std::string &name) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named powers only for CTB");
pimpl->setCtbVoltageName(index, name);
}
std::string Detector::getVoltageName(const defs::dacIndex i) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named powers only for CTB");
return pimpl->getCtbVoltageName(i);
}
void Detector::setSlowADCNames(const std::vector<std::string> names) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named SlowADCs only for CTB");
pimpl->setCtbSlowADCNames(names);
}
std::vector<std::string> Detector::getSlowADCNames() const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named SlowADCs only for CTB");
return pimpl->getCtbSlowADCNames();
}
defs::dacIndex Detector::getSlowADCIndex(const std::string &name) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named SlowADCs only for CTB");
auto names = getSlowADCNames();
auto it = std::find(names.begin(), names.end(), name);
if (it == names.end())
throw RuntimeError("SlowADC name not found");
return static_cast<defs::dacIndex>(it - names.begin() + defs::SLOW_ADC0);
}
void Detector::setSlowADCName(const defs::dacIndex index,
const std::string &name) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named SlowADCs only for CTB");
pimpl->setCtbSlowADCName(index, name);
}
std::string Detector::getSlowADCName(const defs::dacIndex i) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named SlowADCs only for CTB");
return pimpl->getCtbSlowADCName(i);
}
// Pattern
Result<std::string> Detector::getPatterFileName(Positions pos) const {
return pimpl->Parallel(&Module::getPatterFileName, pos);
}
void Detector::setPattern(const std::string &fname, Positions pos) {
Pattern pat;
pat.load(fname);
pat.validate();
setPattern(pat, pos);
pimpl->Parallel(&Module::setPattern, pos, pat, fname);
}
void Detector::setPattern(const Pattern &pat, Positions pos) {
pat.validate();
pimpl->Parallel(&Module::setPattern, pos, pat);
pimpl->Parallel(&Module::setPattern, pos, pat, "");
}
void Detector::savePattern(const std::string &fname) {

View File

@ -1298,7 +1298,7 @@ void DetectorImpl::startAcquisition(const bool blocking, Positions pos) {
if (!masters.empty()) {
Parallel((blocking ? &Module::startAndReadAll
: &Module::startAcquisition),
pos);
masters);
}
}
// all in parallel
@ -1372,7 +1372,7 @@ void DetectorImpl::processData(bool receiver) {
if (fgetc(stdin) == 'q') {
LOG(logINFO)
<< "Caught the command to stop acquisition";
Parallel(&Module::stopAcquisition, {});
stopDetector({});
}
}
// get and print progress
@ -2001,4 +2001,75 @@ std::string DetectorImpl::getCtbDacName(defs::dacIndex i) const {
return ctb_shm()->getDacName(static_cast<int>(i));
}
void DetectorImpl::setCtbDacName(const defs::dacIndex index,
const std::string &name) {
ctb_shm()->setDacName(index, name);
}
std::vector<std::string> DetectorImpl::getCtbAdcNames() const {
return ctb_shm()->getAdcNames();
}
void DetectorImpl::setCtbAdcNames(const std::vector<std::string> &names) {
ctb_shm()->setAdcNames(names);
}
std::string DetectorImpl::getCtbAdcName(const int i) const {
return ctb_shm()->getAdcName(i);
}
void DetectorImpl::setCtbAdcName(const int index, const std::string &name) {
ctb_shm()->setAdcName(index, name);
}
std::vector<std::string> DetectorImpl::getCtbSignalNames() const {
return ctb_shm()->getSignalNames();
}
void DetectorImpl::setCtbSignalNames(const std::vector<std::string> &names) {
ctb_shm()->setSignalNames(names);
}
std::string DetectorImpl::getCtbSignalName(const int i) const {
return ctb_shm()->getSignalName(i);
}
void DetectorImpl::setCtbSignalName(const int index, const std::string &name) {
ctb_shm()->setSignalName(index, name);
}
std::vector<std::string> DetectorImpl::getCtbVoltageNames() const {
return ctb_shm()->getVoltageNames();
}
void DetectorImpl::setCtbVoltageNames(const std::vector<std::string> &names) {
ctb_shm()->setVoltageNames(names);
}
std::string DetectorImpl::getCtbVoltageName(const defs::dacIndex i) const {
return ctb_shm()->getVoltageName(static_cast<int>(i - defs::V_POWER_A));
}
void DetectorImpl::setCtbVoltageName(const defs::dacIndex index,
const std::string &name) {
ctb_shm()->setVoltageName(static_cast<int>(index - defs::V_POWER_A), name);
}
std::vector<std::string> DetectorImpl::getCtbSlowADCNames() const {
return ctb_shm()->getSlowADCNames();
}
void DetectorImpl::setCtbSlowADCNames(const std::vector<std::string> &names) {
ctb_shm()->setSlowADCNames(names);
}
std::string DetectorImpl::getCtbSlowADCName(const defs::dacIndex i) const {
return ctb_shm()->getSlowADCName(static_cast<int>(i - defs::SLOW_ADC0));
}
void DetectorImpl::setCtbSlowADCName(const defs::dacIndex index,
const std::string &name) {
ctb_shm()->setSlowADCName(static_cast<int>(index - defs::SLOW_ADC0), name);
}
} // namespace sls

View File

@ -326,8 +326,29 @@ class DetectorImpl : public virtual slsDetectorDefs {
void setBadChannels(const std::vector<int> list, Positions pos);
std::vector<std::string> getCtbDacNames() const;
std::string getCtbDacName(defs::dacIndex i) const;
std::string getCtbDacName(const defs::dacIndex i) const;
void setCtbDacNames(const std::vector<std::string> &names);
void setCtbDacName(const defs::dacIndex index, const std::string &name);
std::vector<std::string> getCtbAdcNames() const;
std::string getCtbAdcName(const int i) const;
void setCtbAdcNames(const std::vector<std::string> &names);
void setCtbAdcName(const int index, const std::string &name);
std::vector<std::string> getCtbSignalNames() const;
std::string getCtbSignalName(const int i) const;
void setCtbSignalNames(const std::vector<std::string> &names);
void setCtbSignalName(const int index, const std::string &name);
std::vector<std::string> getCtbVoltageNames() const;
std::string getCtbVoltageName(const defs::dacIndex i) const;
void setCtbVoltageNames(const std::vector<std::string> &names);
void setCtbVoltageName(const defs::dacIndex index, const std::string &name);
std::vector<std::string> getCtbSlowADCNames() const;
std::string getCtbSlowADCName(const defs::dacIndex i) const;
void setCtbSlowADCNames(const std::vector<std::string> &names);
void setCtbSlowADCName(const defs::dacIndex index, const std::string &name);
private:
/**

View File

@ -2478,9 +2478,23 @@ void Module::setLEDEnable(bool enable) {
}
// Pattern
std::string Module::getPatterFileName() const {
char retval[MAX_STR_LENGTH]{};
sendToDetector(F_GET_PATTERN_FILE_NAME, nullptr, retval);
return retval;
}
void Module::setPattern(const Pattern &pat) {
sendToDetector(F_SET_PATTERN, pat.data(), pat.size(), nullptr, 0);
void Module::setPattern(const Pattern &pat, const std::string &fname) {
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_SET_PATTERN);
client.Send(pat.data(), pat.size());
char args[MAX_STR_LENGTH]{};
strcpy_safe(args, fname.c_str());
client.Send(args);
if (client.Receive<int>() == FAIL) {
throw DetectorError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
Pattern Module::getPattern() {
@ -2492,12 +2506,11 @@ Pattern Module::getPattern() {
void Module::loadDefaultPattern() { sendToDetector(F_LOAD_DEFAULT_PATTERN); }
uint64_t Module::getPatternIOControl() const {
return sendToDetector<uint64_t>(F_SET_PATTERN_IO_CONTROL,
int64_t(GET_FLAG));
return sendToDetector<uint64_t>(F_GET_PATTERN_IO_CONTROL);
}
void Module::setPatternIOControl(uint64_t word) {
sendToDetector<uint64_t>(F_SET_PATTERN_IO_CONTROL, word);
sendToDetector(F_SET_PATTERN_IO_CONTROL, word, nullptr);
}
uint64_t Module::getPatternWord(int addr) const {
@ -2747,29 +2760,18 @@ uint32_t Module::writeRegister(uint32_t addr, uint32_t val) {
}
void Module::setBit(uint32_t addr, int n) {
if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else {
uint32_t val = readRegister(addr);
writeRegister(addr, val | 1 << n);
}
uint32_t args[2] = {addr, static_cast<uint32_t>(n)};
sendToDetectorStop(F_SET_BIT, args, nullptr);
}
void Module::clearBit(uint32_t addr, int n) {
if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else {
uint32_t val = readRegister(addr);
writeRegister(addr, val & ~(1 << n));
}
uint32_t args[2] = {addr, static_cast<uint32_t>(n)};
sendToDetectorStop(F_CLEAR_BIT, args, nullptr);
}
int Module::getBit(uint32_t addr, int n) {
if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else {
return ((readRegister(addr) >> n) & 0x1);
}
uint32_t args[2] = {addr, static_cast<uint32_t>(n)};
return sendToDetectorStop<int>(F_GET_BIT, args);
}
void Module::executeFirmwareTest() { sendToDetector(F_SET_FIRMWARE_TEST); }

View File

@ -525,7 +525,8 @@ class Module : public virtual slsDetectorDefs {
* Pattern *
* *
* ************************************************/
void setPattern(const Pattern &pat);
std::string getPatterFileName() const;
void setPattern(const Pattern &pat, const std::string &fname);
Pattern getPattern();
void loadDefaultPattern();
uint64_t getPatternIOControl() const;

View File

@ -19,6 +19,448 @@ using test::PUT;
/* dacs */
TEST_CASE("dacname", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2);
std::string str_dac_index = "2";
auto prev = det.getDacName(ind);
// 1 arg throw
REQUIRE_THROWS(proxy.Call("dacname", {"2", "3", "bname"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("dacname", {"18", "bname"}, -1, PUT));
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("dacname", {str_dac_index, "bname"}, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("dacname", {str_dac_index}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("dacname ") + str_dac_index + " bname\n");
}
det.setDacName(ind, prev);
} else {
REQUIRE_THROWS(proxy.Call("dacname", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("dacname", {"2"}, -1, GET));
}
}
TEST_CASE("dacindex", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2);
std::string str_dac_index = "2";
// 1 arg throw
REQUIRE_THROWS(proxy.Call("dacindex", {"2", "2"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("dacindex", {"18"}, -1, PUT));
auto dacname = det.getDacName(ind);
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("dacindex", {dacname}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("dacindex ") + str_dac_index + '\n');
}
} else {
REQUIRE_THROWS(proxy.Call("dacindex", {"2"}, -1, GET));
}
}
TEST_CASE("adclist", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev = det.getAdcNames();
REQUIRE_THROWS(proxy.Call("adclist", {"a", "s", "d"}, -1, PUT));
std::vector<std::string> names;
for (int iarg = 0; iarg != 32; ++iarg) {
names.push_back("a");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("adclist", names, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("adclist", {}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("adclist ") + ToString(names) + '\n');
}
det.setAdcNames(prev);
} else {
REQUIRE_THROWS(proxy.Call("adclist", {"a", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("adclist", {}, -1, GET));
}
}
TEST_CASE("adcname", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
int ind = 2;
std::string str_adc_index = "2";
auto prev = det.getAdcName(ind);
// 1 arg throw
REQUIRE_THROWS(proxy.Call("adcname", {"2", "3", "bname"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("adcname", {"32", "bname"}, -1, PUT));
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("adcname", {str_adc_index, "bname"}, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("adcname", {str_adc_index}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("adcname ") + str_adc_index + " bname\n");
}
det.setAdcName(ind, prev);
} else {
REQUIRE_THROWS(proxy.Call("adcname", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("adcname", {"2"}, -1, GET));
}
}
TEST_CASE("adcindex", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
int ind = 2;
std::string str_adc_index = "2";
// 1 arg throw
REQUIRE_THROWS(proxy.Call("adcindex", {"2", "2"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("adcindex", {"32"}, -1, PUT));
auto adcname = det.getAdcName(ind);
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("adcindex", {adcname}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("adcindex ") + str_adc_index + '\n');
}
} else {
REQUIRE_THROWS(proxy.Call("adcindex", {"2"}, -1, GET));
}
}
TEST_CASE("signallist", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev = det.getSignalNames();
REQUIRE_THROWS(proxy.Call("signallist", {"a", "s", "d"}, -1, PUT));
std::vector<std::string> names;
for (int iarg = 0; iarg != 64; ++iarg) {
names.push_back("a");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("signallist", names, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("signallist", {}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("signallist ") + ToString(names) + '\n');
}
det.setSignalNames(prev);
} else {
REQUIRE_THROWS(proxy.Call("signallist", {"a", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("signallist", {}, -1, GET));
}
}
TEST_CASE("signalname", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
int ind = 2;
std::string str_signal_index = "2";
auto prev = det.getSignalName(ind);
// 1 arg throw
REQUIRE_THROWS(proxy.Call("signalname", {"2", "3", "bname"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("signalname", {"64", "bname"}, -1, PUT));
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call(
"signalname", {str_signal_index, "bname"}, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("signalname", {str_signal_index}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("signalname ") + str_signal_index + " bname\n");
}
det.setSignalName(ind, prev);
} else {
REQUIRE_THROWS(proxy.Call("signalname", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("signalname", {"2"}, -1, GET));
}
}
TEST_CASE("signalindex", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
int ind = 2;
std::string str_signal_index = "2";
// 1 arg throw
REQUIRE_THROWS(proxy.Call("signalindex", {"2", "2"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("signalindex", {"64"}, -1, PUT));
auto signalname = det.getSignalName(ind);
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("signalindex", {signalname}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("signalindex ") + str_signal_index + '\n');
}
} else {
REQUIRE_THROWS(proxy.Call("signalindex", {"2"}, -1, GET));
}
}
TEST_CASE("voltagelist", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev = det.getVoltageNames();
REQUIRE_THROWS(proxy.Call("voltagelist", {"a", "s", "d"}, -1, PUT));
std::vector<std::string> names;
for (int iarg = 0; iarg != 5; ++iarg) {
names.push_back("a");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("voltagelist", names, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("voltagelist", {}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("voltagelist ") + ToString(names) + '\n');
}
det.setVoltageNames(prev);
} else {
REQUIRE_THROWS(proxy.Call("voltagelist", {"a", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("voltagelist", {}, -1, GET));
}
}
TEST_CASE("voltagename", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
std::string str_voltage_index = "2";
auto prev = det.getVoltageName(ind);
// 1 arg throw
REQUIRE_THROWS(proxy.Call("voltagename", {"2", "3", "bname"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("voltagename", {"5", "bname"}, -1, PUT));
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call(
"voltagename", {str_voltage_index, "bname"}, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("voltagename", {str_voltage_index}, -1, GET, oss));
REQUIRE(oss.str() == std::string("voltagename ") +
str_voltage_index + " bname\n");
}
det.setVoltageName(ind, prev);
} else {
REQUIRE_THROWS(proxy.Call("voltagename", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("voltagename", {"2"}, -1, GET));
}
}
TEST_CASE("voltageindex", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
std::string str_voltage_index = "2";
// 1 arg throw
REQUIRE_THROWS(proxy.Call("voltageindex", {"2", "2"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("voltageindex", {"5"}, -1, PUT));
auto voltagename = det.getVoltageName(ind);
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("voltageindex", {voltagename}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("voltageindex ") + str_voltage_index + '\n');
}
} else {
REQUIRE_THROWS(proxy.Call("voltageindex", {"2"}, -1, GET));
}
}
TEST_CASE("voltagevalues", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_NOTHROW(proxy.Call("voltagevalues", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("voltagevalues", {}, -1, PUT));
}
TEST_CASE("slowadcvalues", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_NOTHROW(proxy.Call("slowadcvalues", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("slowadcvalues", {}, -1, PUT));
}
TEST_CASE("slowadclist", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto prev = det.getSlowADCNames();
REQUIRE_THROWS(proxy.Call("slowadclist", {"a", "s", "d"}, -1, PUT));
std::vector<std::string> names;
for (int iarg = 0; iarg != 8; ++iarg) {
names.push_back("a");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("slowadclist", names, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("slowadclist", {}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("slowadclist ") + ToString(names) + '\n');
}
det.setSlowADCNames(prev);
} else {
REQUIRE_THROWS(proxy.Call("slowadclist", {"a", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("slowadclist", {}, -1, GET));
}
}
TEST_CASE("slowadcname", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
std::string str_slowadc_index = "2";
auto prev = det.getSlowADCName(ind);
// 1 arg throw
REQUIRE_THROWS(proxy.Call("slowadcname", {"2", "3", "bname"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("slowadcname", {"8", "bname"}, -1, PUT));
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call(
"slowadcname", {str_slowadc_index, "bname"}, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("slowadcname", {str_slowadc_index}, -1, GET, oss));
REQUIRE(oss.str() == std::string("slowadcname ") +
str_slowadc_index + " bname\n");
}
det.setSlowADCName(ind, prev);
} else {
REQUIRE_THROWS(proxy.Call("slowadcname", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("slowadcname", {"2"}, -1, GET));
}
}
TEST_CASE("slowadcindex", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
std::string str_slowadc_index = "2";
// 1 arg throw
REQUIRE_THROWS(proxy.Call("slowadcindex", {"2", "2"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("slowadcindex", {"8"}, -1, PUT));
auto slowadcname = det.getSlowADCName(ind);
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("slowadcindex", {slowadcname}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("slowadcindex ") + str_slowadc_index + '\n');
}
} else {
REQUIRE_THROWS(proxy.Call("slowadcindex", {"2"}, -1, GET));
}
}
/* dacs */
TEST_CASE("dac", "[.cmd][.dacs]") {
// dac 0 to dac 17
@ -86,7 +528,7 @@ TEST_CASE("dac", "[.cmd][.dacs]") {
REQUIRE_THROWS(proxy.Call("dac", {"vicin"}, -1, GET));
REQUIRE_THROWS(proxy.Call("dac", {"vipre_out"}, -1, GET));
// gotthard2
REQUIRE_THROWS(proxy.Call("dac", {"vref_h_adc"}, -1, GET));
REQUIRE_THROWS(proxy.Call("dac", {"vref_h_Signal"}, -1, GET));
REQUIRE_THROWS(proxy.Call("dac", {"vb_comp_fe"}, -1, GET));
REQUIRE_THROWS(proxy.Call("dac", {"vb_comp_adc"}, -1, GET));
REQUIRE_THROWS(proxy.Call("dac", {"vcom_cds"}, -1, GET));

View File

@ -226,7 +226,7 @@ TEST_CASE("autocompdisable", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getAutoComparatorDisable();
{
std::ostringstream oss;
@ -256,7 +256,7 @@ TEST_CASE("compdisabletime", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if ((det_type == defs::JUNGFRAU || det_type == defs::MOENCH) &&
if (det_type == defs::JUNGFRAU &&
det.getChipVersion().squash() * 10 == 11) {
auto prev_val = det.getComparatorDisableTime();
{
@ -416,7 +416,7 @@ TEST_CASE("gainmode", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getGainMode();
{
std::ostringstream oss;
@ -465,7 +465,7 @@ TEST_CASE("filtercells", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
if (det_type == defs::JUNGFRAU) {
// chip version 1.1
if (det.getChipVersion().squash() * 10 == 11) {
auto prev_val = det.getNumberOfFilterCells();
@ -523,6 +523,28 @@ TEST_CASE("sync", "[.cmd]") {
proxy.Call("sync", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "sync 1\n");
}
// setting to master or slave when synced
{
// get previous master
int prevMaster = 0;
auto previous = det.getMaster();
for (int i = 0; i != det.size(); ++i) {
if (previous[i] == 1) {
prevMaster = i;
break;
}
}
proxy.Call("master", {"1"}, 0, PUT);
proxy.Call("master", {"0"}, 0, PUT);
std::ostringstream oss;
proxy.Call("status", {}, -1, GET, oss);
REQUIRE(oss.str() != "status running\n");
// set all to slaves, and then master
for (int i = 0; i != det.size(); ++i) {
det.setMaster(0, {i});
}
det.setMaster(1, prevMaster);
}
{
std::ostringstream oss;
proxy.Call("sync", {}, -1, GET, oss);

View File

@ -19,6 +19,18 @@ using test::PUT;
/* Pattern */
TEST_CASE("patfname", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3) {
REQUIRE_THROWS(proxy.Call("patfname", {}, -1, PUT));
REQUIRE_NOTHROW(proxy.Call("patfname", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("patfname", {}, -1, GET));
}
}
TEST_CASE("pattern", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -212,10 +212,19 @@ TEST_CASE("settings", "[.cmd]") {
std::vector<std::string> sett;
switch (det_type) {
case defs::JUNGFRAU:
case defs::MOENCH:
sett.push_back("gain0");
sett.push_back("highgain0");
break;
case defs::MOENCH:
sett.push_back("g1_hg");
sett.push_back("g1_lg");
sett.push_back("g2_hc_hg");
sett.push_back("g2_hc_lg");
sett.push_back("g2_lc_hg");
sett.push_back("g2_lc_lg");
sett.push_back("g4_hg");
sett.push_back("g4_lg");
break;
case defs::GOTTHARD:
sett.push_back("highgain");
sett.push_back("dynamicgain");
@ -1049,9 +1058,9 @@ TEST_CASE("readoutspeed", "[.cmd]") {
// full speed for jungfrau/moench only works for new boards (chipv1.1 is
// with new board [hw1.0 and chipv1.0 not tested here])
if (((det_type == defs::JUNGFRAU || det_type == defs::MOENCH) &&
if (((det_type == defs::JUNGFRAU) &&
det.getChipVersion().squash() * 10 == 11) ||
(det_type == defs::EIGER)) {
(det_type == defs::EIGER) || (det_type == defs::MOENCH)) {
std::ostringstream oss1, oss2, oss3, oss4;
proxy.Call("readoutspeed", {"0"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "readoutspeed full_speed\n");
@ -1195,8 +1204,7 @@ TEST_CASE("dbitphase", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
det_type == defs::CHIPTESTBOARD) {
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) {
auto prev_val = det.getDBITPhase();
{
std::ostringstream oss1, oss2;
@ -1225,8 +1233,7 @@ TEST_CASE("maxdbitphaseshift", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
det_type == defs::CHIPTESTBOARD ||
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
det_type == defs::MYTHEN3 || // only because clk index of 0 exists
det_type == defs::GOTTHARD2) { // only because clk index of 0 exists
REQUIRE_NOTHROW(proxy.Call("maxdbitphaseshift", {}, -1, GET));
@ -1572,7 +1579,7 @@ TEST_CASE("parallel", "[.cmd]") {
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD2) {
det_type == defs::GOTTHARD2 || det_type == defs::MOENCH) {
auto prev_val = det.getParallelMode();
{
std::ostringstream oss;
@ -1604,7 +1611,7 @@ TEST_CASE("filterresistor", "[.cmd]") {
// only for chipv1.1
bool chip11 = false;
if ((det_type == defs::JUNGFRAU || det_type == defs::MOENCH) &&
if (det_type == defs::JUNGFRAU &&
det.getChipVersion().squash() * 10 == 11) {
chip11 = true;
}
@ -1748,8 +1755,7 @@ TEST_CASE("currentsource", "[.cmd]") {
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU ||
det_type == defs::MOENCH) {
if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU) {
auto prev_val = det.getCurrentSource();
if (det_type == defs::GOTTHARD2) {
@ -1773,11 +1779,14 @@ TEST_CASE("currentsource", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("currentsource",
{"1", "fix", "42", "normal"}, -1, PUT));
}
// jungfrau/moench
// jungfrau
else {
int chipVersion = det.getChipVersion().tsquash(
int chipVersion = 10;
if (det_type == defs::JUNGFRAU) {
chipVersion = det.getChipVersion().tsquash(
"inconsistent chip versions to test") *
10;
}
if (chipVersion == 10) {
REQUIRE_THROWS(proxy.Call("currentsource", {"1"}, -1, PUT));
REQUIRE_THROWS(
@ -1928,15 +1937,43 @@ TEST_CASE("temp_fpga", "[.cmd]") {
}
}
/* dacs */
/* list */
TEST_CASE("daclist", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_NOTHROW(proxy.Call("daclist", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("daclist", {}, -1, PUT));
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(proxy.Call("daclist", {}, -1, GET));
auto prev = det.getDacNames();
REQUIRE_THROWS(proxy.Call("daclist", {"a", "s", "d"}, -1, PUT));
std::vector<std::string> names;
for (int iarg = 0; iarg != 18; ++iarg) {
names.push_back("a");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("daclist", names, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("daclist", {}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("daclist ") + ToString(names) + '\n');
}
det.setDacNames(prev);
} else {
REQUIRE_THROWS(proxy.Call("daclist", {"a", "b"}, -1, PUT));
REQUIRE_NOTHROW(proxy.Call("daclist", {}, -1, GET));
}
}
/* dacs */
TEST_CASE("dacvalues", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -10,16 +10,41 @@
namespace sls {
TEST_CASE("Default construction") {
static_assert(sizeof(CtbConfig) == 360,
"Size of CtbConfig does not match"); // 18*20
static_assert(sizeof(CtbConfig) == ((18 + 32 + 64 + 5 + 8) * 20),
"Size of CtbConfig does not match");
CtbConfig c;
auto names = c.getDacNames();
REQUIRE(names.size() == 18);
REQUIRE(names[0] == "dac0");
REQUIRE(names[1] == "dac1");
REQUIRE(names[2] == "dac2");
REQUIRE(names[3] == "dac3");
auto dacnames = c.getDacNames();
REQUIRE(dacnames.size() == 18);
REQUIRE(dacnames[0] == "DAC0");
REQUIRE(dacnames[1] == "DAC1");
REQUIRE(dacnames[2] == "DAC2");
REQUIRE(dacnames[3] == "DAC3");
auto adcnames = c.getAdcNames();
REQUIRE(adcnames.size() == 32);
REQUIRE(adcnames[0] == "ADC0");
REQUIRE(adcnames[1] == "ADC1");
REQUIRE(adcnames[2] == "ADC2");
REQUIRE(adcnames[3] == "ADC3");
auto powernames = c.getVoltageNames();
REQUIRE(powernames.size() == 5);
REQUIRE(powernames[0] == "VA");
REQUIRE(powernames[1] == "VB");
REQUIRE(powernames[2] == "VC");
REQUIRE(powernames[3] == "VD");
REQUIRE(powernames[4] == "VIO");
auto signalnames = c.getSignalNames();
REQUIRE(signalnames.size() == 64);
REQUIRE(signalnames[0] == "BIT0");
REQUIRE(signalnames[1] == "BIT1");
REQUIRE(signalnames[2] == "BIT2");
REQUIRE(signalnames[3] == "BIT3");
auto sensenames = c.getSlowADCNames();
REQUIRE(sensenames.size() == 8);
REQUIRE(sensenames[0] == "SLOWADC0");
REQUIRE(sensenames[1] == "SLOWADC1");
REQUIRE(sensenames[2] == "SLOWADC2");
REQUIRE(sensenames[3] == "SLOWADC3");
}
TEST_CASE("Set and get a single dac name") {

View File

@ -541,7 +541,7 @@ void DataProcessor::RearrangeDbitData(size_t &size, char *data) {
// copy back to memory and update size
memcpy(data + nAnalogDataBytes, result.data(),
numResult8Bits * sizeof(uint8_t));
size = numResult8Bits * sizeof(uint8_t);
size = numResult8Bits * sizeof(uint8_t) + nAnalogDataBytes + ctbDbitOffset;
}
void DataProcessor::CropImage(size_t &size, char *data) {

View File

@ -277,6 +277,11 @@ enum detFuncs {
F_SET_SYNCHRONIZATION,
F_GET_HARDWARE_VERSION,
F_GET_FRONTEND_FIRMWARE_VERSION,
F_GET_BIT,
F_SET_BIT,
F_CLEAR_BIT,
F_GET_PATTERN_IO_CONTROL,
F_GET_PATTERN_FILE_NAME,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 512, /**< detector function should not exceed this
@ -657,6 +662,12 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_SYNCHRONIZATION: return "F_SET_SYNCHRONIZATION";
case F_GET_HARDWARE_VERSION: return "F_GET_HARDWARE_VERSION";
case F_GET_FRONTEND_FIRMWARE_VERSION: return "F_GET_FRONTEND_FIRMWARE_VERSION";
case F_GET_BIT: return "F_GET_BIT";
case F_SET_BIT: return "F_SET_BIT";
case F_CLEAR_BIT: return "F_CLEAR_BIT";
case F_GET_PATTERN_IO_CONTROL: return "F_GET_PATTERN_IO_CONTROL";
case F_GET_PATTERN_FILE_NAME: return "F_GET_PATTERN_FILE_NAME";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -2,12 +2,12 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */
#define RELEASE "developer"
#define APIGOTTHARD "developer 0x230224"
#define APIGOTTHARD2 "developer 0x230224"
#define APIMYTHEN3 "developer 0x230224"
#define APILIB "developer 0x230224"
#define APIRECEIVER "developer 0x230224"
#define APIEIGER "developer 0x230224"
#define APIJUNGFRAU "developer 0x230508"
#define APIMOENCH "developer 0x230508"
#define APICTB "developer 0x230522"
#define APIEIGER "developer 0x230525"
#define APIGOTTHARD "developer 0x230615"
#define APIGOTTHARD2 "developer 0x230615"
#define APIJUNGFRAU "developer 0x230615"
#define APICTB "developer 0x230621"
#define APIMYTHEN3 "developer 0x230621"
#define APIMOENCH "developer 0x230707"