Compare commits

...

18 Commits

Author SHA1 Message Date
3f7c9529dd m3: changed clk 0 1 2 to 100MHz (#636)
* m3: changed clk 0 1 2 to 100MHz

* m3:fix clk 2

* binaries in
2023-01-25 11:54:37 +01:00
c7af9c9f3e fix for versions command in python failing for eiger due to hardware version not implemented (#602) 2023-01-24 11:05:32 +01:00
0b17318f10 formatting 2023-01-24 10:37:52 +01:00
1f907b911e added documentation about zmq json header (#629)
* added documentation about zmq json header

* fix from 7.0.0 field name changes in zmq header
2023-01-23 14:15:14 +01:00
c5b621b684 intialize pattern addresses with default, else they are created with value 0 and overwrite the default in server (#628) 2023-01-23 10:59:18 +01:00
946e6aa817 badchannel segfault for multi module (#620)
* badchannels segfaults when there are no badchannels for next modules, fixed

* added example badchannels

* refactoring casting
2023-01-20 17:39:25 +01:00
3682644e15 incorrectly using detsize, caught and fixing it in background (#619) 2023-01-19 11:10:05 +01:00
a6aaa2c3c6 adding fliprows to python (#625) 2023-01-19 11:03:04 +01:00
ac64afe747 print also the level when using command line to set/get patloop, patnloop, patwait, patwaittime (#621) 2023-01-19 10:44:17 +01:00
d19f6a3d0d initialchecks werent being bypassed because of the wrong exception being caught. fixed (#623) 2023-01-19 10:43:27 +01:00
d77b353481 Corrected wrong coloring in plotPattern 2023-01-18 08:59:30 +01:00
7466c0bc8f M3 deserialize (#618)
* m3: updated serializing loop in trimming

* fixed the deserializing loop again
2023-01-17 09:39:58 +01:00
713639d001 Fix gotthard delay (#606)
* fix for set delay for gotthard1 (verification adds master delay even if its not master)

* binaries in

* binaries name
2023-01-17 09:16:43 +01:00
3cc4d25eb9 Merge branch '7.0.0.rc' of https://github.com/slsdetectorgroup/slsDetectorPackage into 7.0.0.rc 2023-01-16 15:05:59 +01:00
0d905923dd Corrected a typo in plotPattern.py 2023-01-16 15:03:16 +01:00
e747a5811f added missing equality operator for DurationWrapper in Python (M3 exptime fix) (#615) 2023-01-16 14:12:12 +01:00
22b3229d94 m3: updated serializing loop in trimming (#613) 2023-01-16 13:43:28 +01:00
d106109f6c fixed hostname not split (+) in python (#609)
* fixed hostname not split (+) in python

* also for rx_hostname
2023-01-16 13:33:11 +01:00
22 changed files with 286 additions and 41 deletions

View File

@ -86,6 +86,145 @@ Client Commands
sls_detector_get -h rx_framescaught
ZMQ: Json Header Format
------------------------
**Change in field names from slsDetectorPackage v6.x.x to v7.0.0**
* detSpec1 <- bunchId
* detSpec2 <- reserved
* detSpec3 <- debug
* detSpec4 <- roundRNumber
**Format**
.. code-block:: bash
{
"jsonversion": unsigned int,
"bitmode": unsigned int,
"fileIndex": unsigned long int,
"detshape": [
unsigned int,
unsigned int
],
"shape": [
unsigned int,
unsigned int
],
"size": unsigned int,
"acqIndex": unsigned long int,
"frameIndex": unsigned long int,
"progress": double,
"fname": string,
"data": unsigned int,
"completeImage": unsigned int,
"frameNumber": unsigned long long int,
"expLength": unsigned int,
"packetNumber": unsigned int,
"detSpec1": unsigned long int,
"timestamp": unsigned long int,
"modId": unsigned int,
"row": unsigned int,
"column": unsigned int,
"detSpec2": unsigned int,
"detSpec3": unsigned int,
"detSpec4": unsigned int,
"detType": unsigned int,
"version": unsigned int,
"flipRows": unsigned int,
"quad": unsigned int,
"addJsonHeader": {
string : string
}
}
+--------------+----------------------------------------------+
| Field | Description |
+--------------+----------------------------------------------+
| jsonversion | Version of the json header. |
| | Value at 4 for v6.x.x and v7.x.x |
+--------------+----------------------------------------------+
| bitmode | Bits per pixel [4|8|16|32] |
+--------------+----------------------------------------------+
| fileIndex | Current file acquisition index |
+--------------+----------------------------------------------+
| detshape | Geometry of the entire detector |
+--------------+----------------------------------------------+
| shape | Geometry of the current port streamed out |
+--------------+----------------------------------------------+
| size | Size of image of current port in bytesout |
+--------------+----------------------------------------------+
| acqIndex | Frame number from the detector (redundant) |
+--------------+----------------------------------------------+
| frameIndex | Frame number of current acquisition |
| | (Starting at 0) |
+--------------+----------------------------------------------+
| progress | Progress of current acquisition in % |
+--------------+----------------------------------------------+
| fname | Current file name |
+--------------+----------------------------------------------+
| data | 1 if there is data following |
| | 0 if dummy header |
+--------------+----------------------------------------------+
| completeImage| 1 if no missing packets for this frame |
| | in this port, else 0 |
+--------------+----------------------------------------------+
| frameNumber | Frame number |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| expLength | subframe number (32 bit eiger) |
| | or real time exposure time in 100ns (others) |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| packetNumber | Number of packets caught for that frame |
+--------------+----------------------------------------------+
| detSpec1 | See :ref:`here<Detector Specific Fields>` |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| timestamp | Timestamp with 10 MHz clock |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| modId | Module Id |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| row | Row number in detector |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| column | Column number in detector |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| detSpec2 | See :ref:`here<Detector Specific Fields>` |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| detSpec3 | See :ref:`here<Detector Specific Fields>` |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| detSpec4 | See :ref:`here<Detector Specific Fields>` |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| detType | Detector type enum |
| detSpec3 | See :ref:`Detector enum<Detector Enum>` |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| version | Detector header version. At 2 |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| flipRows | 1 if rows should be flipped. |
| | Usually for Eiger bottom. |
+--------------+----------------------------------------------+
| quad | 1 if its an Eiger quad. |
+--------------+----------------------------------------------+
| addJsonHeader| Optional custom parameters that is required |
| | for processing code. |
+--------------+----------------------------------------------+
File format
--------------

6
examples/badchannel.txt Normal file
View File

@ -0,0 +1,6 @@
0
10, 30
40:45 50:52
1279
# all bad channels are applied for all counters in deector

Binary file not shown.

Before

Width:  |  Height:  |  Size: 334 KiB

After

Width:  |  Height:  |  Size: 299 KiB

View File

@ -31,7 +31,7 @@ alpha_wait = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
alpha_wait_rect = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
# Loop colors and line styles (6 needed from 0 to 5)
colors_loop = ['tab:green', 'tab:red', 'tab:purple', 'tab:brown', 'tab:ping', 'tab:grey']
colors_loop = ['tab:green', 'tab:red', 'tab:purple', 'tab:brown', 'tab:pink', 'tab:grey']
linestyles_loop = ['-.', '-.', '-.', '-.', '-.', '-.']
alpha_loop = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
alpha_loop_rect = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
@ -527,7 +527,7 @@ for idx, i in enumerate(range(nbiteff)):
linestyle=linestyles_loop[2], color=colors_loop[2], alpha=alpha_loop[2],
label="loop 2: " + str(nloop2) + " times" if idx == 0 else "", linewidth=2.0)
axs2[idx].plot([loop2_end, loop2_end], [-10, 10],
linestyle=linestyles_loop[0], color=colors_loop[0], alpha=alpha_loop[2], linewidth=2.0)
linestyle=linestyles_loop[2], color=colors_loop[2], alpha=alpha_loop[2], linewidth=2.0)
# Loop 3
if nloop3 is not None:

View File

@ -14,7 +14,7 @@ streamingInterface = slsDetectorDefs.streamingInterface
defs = slsDetectorDefs
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
from .utils import Geometry, to_geo, element, reduce_time, is_iterable
from .utils import Geometry, to_geo, element, reduce_time, is_iterable, hostname_list
from _slsdet import xy
from . import utils as ut
from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy, MaxPhaseProxy, ClkFreqProxy, PatLoopProxy, PatNLoopProxy, PatWaitProxy, PatWaitTimeProxy
@ -162,12 +162,8 @@ class Detector(CppDetectorApi):
@hostname.setter
def hostname(self, hostnames):
if isinstance(hostnames, str):
hostnames = [hostnames]
if isinstance(hostnames, list):
self.setHostname(hostnames)
else:
raise ValueError("hostname needs to be string or list of strings")
args = hostname_list(hostnames)
self.setHostname(args)
@property
@ -784,7 +780,8 @@ class Detector(CppDetectorApi):
@rx_hostname.setter
def rx_hostname(self, hostname):
self.setRxHostname(hostname)
args = hostname_list(hostname)
self.setRxHostname(args)
@property
@element
@ -1568,6 +1565,20 @@ class Detector(CppDetectorApi):
def trimval(self, value):
ut.set_using_dict(self.setAllTrimbits, value)
@property
@element
def fliprows(self):
"""
[Eiger] flips rows paramater sent to slsreceiver to stream as json parameter to flip rows in gui. \n
[Jungfrau] flips rows in the detector itself. For bottom module and number of interfaces must be set to 2. slsReceiver and slsDetectorGui does not handle.
"""
return self.getFlipRows()
@fliprows.setter
def fliprows(self, value):
ut.set_using_dict(self.setFlipRows, value)
@property
@element
def master(self):
@ -1802,6 +1813,15 @@ class Detector(CppDetectorApi):
@property
def versions(self):
if self.type == detectorType.EIGER:
return {'type': self.type,
'package': self.packageversion,
'client': self.clientversion,
'firmware': self.firmwareversion,
'detectorserver': self.detectorserverversion,
'kernel': self.kernelversion,
'receiver': self.rx_version}
return {'type': self.type,
'package': self.packageversion,
'client': self.clientversion,

View File

@ -260,4 +260,21 @@ def merge_args(*args):
return (ret,)
else:
raise ValueError("Multiple dictionaries passes cannot merge args")
raise ValueError("Multiple dictionaries passes cannot merge args")
def hostname_list(args):
"""
Generates a list from a hostname string
* Lists are passed through
* as are tuples (conversion in pybind11 to vector)
* if + is found it splits the string
"""
if isinstance(args, (list, tuple)):
return args
elif(isinstance(args, str)):
hosts = args.split('+')
hosts = [it for it in hosts if len(it)]
return hosts
else:
raise ValueError("hostname needs to be string or list of strings")

View File

@ -12,6 +12,7 @@ void init_duration(py::module &m) {
.def("total_seconds", &DurationWrapper::total_seconds)
.def("count", &DurationWrapper::count)
.def("set_count", &DurationWrapper::set_count)
.def("__eq__", &DurationWrapper::operator==)
.def("__repr__", [](const DurationWrapper &self) {
std::stringstream ss;
ss << "sls::DurationWrapper(total_seconds: " << self.total_seconds()

View File

@ -8,7 +8,7 @@ Testing functions from utils.py
import pytest
from slsdet.utils import *
from slsdet import IpAddr, MacAddr
from slsdet import IpAddr, MacAddr, DurationWrapper
import datetime as dt
import pathlib
from pathlib import Path
@ -22,7 +22,11 @@ def test_iterable():
def test_reduce_time_to_single_value_from_list():
t = 3 * [dt.timedelta(seconds=1)]
t = [dt.timedelta(seconds=1) for i in range(3)]
assert reduce_time(t) == 1
def test_reduce_time_to_single_value_from_list_DurationWrapper():
t = [DurationWrapper(1) for i in range(3)]
assert reduce_time(t) == 1
@ -83,6 +87,12 @@ def test_all_equal_str_fails():
assert all_equal('aaab') == False
def test_all_equal_DurationWrapper():
assert all_equal([DurationWrapper(1), DurationWrapper(1)])
def test_all_equal_DurationWrapper_fail():
assert not all_equal([DurationWrapper(1), DurationWrapper(2)])
def test_element_if_equal_int():
assert element_if_equal([5, 5]) == 5
@ -341,4 +351,33 @@ def test_merge_args_tuple():
assert merge_args(*("a", "b"), 5) == ("a", "b", 5)
def test_merge_args_dict_with_tuple():
assert merge_args({0: (1,2)}, 3) == ({0: (1,2,3)},)
assert merge_args({0: (1,2)}, 3) == ({0: (1,2,3)},)
def test_hostname_to_list():
s = "localhost"
r = hostname_list(s)
assert r == [s]
def test_hostname_to_list_passthrough():
args = ["localhost"]
ret = hostname_list(args)
assert ret == args
args = ("localhost",)
ret = hostname_list(args)
assert ret == args
def test_splitting_hostname():
args = 'apple+banana+pear+'
ret = hostname_list(args)
assert ret == ['apple', 'banana', 'pear']
#not sensitive to trailing +
args = 'apple+banana+pear'
ret = hostname_list(args)
assert ret == ['apple', 'banana', 'pear']
def test_hostame_throws_on_wrong_args():
with pytest.raises(Exception) as e:
hostname_list(5)

View File

@ -1 +0,0 @@
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv7.0.0.rc1

View File

@ -0,0 +1 @@
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv7.0.0.rc2

View File

@ -1 +0,0 @@
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv7.0.0.rc1

View File

@ -0,0 +1 @@
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv7.0.0.rc2

View File

@ -1007,7 +1007,9 @@ int setDelayAfterTrigger(int64_t val) {
// validate for tolerance
int64_t retval = getDelayAfterTrigger();
val /= (1E-9 * CLK_FREQ);
val -= masterdefaultdelay;
if (master) {
val -= masterdefaultdelay;
}
if (val != retval) {
return FAIL;
}

View File

@ -313,7 +313,7 @@ patternParameters *setChannelRegisterChip(int ichip, char *mask,
chanReg, ichip * NCHAN + ich * NCOUNTERS,
ichip * NCHAN_1_COUNTER + ich, ichip, ich));
}
for (int i = 0; i < 24; i++) {
for (int i = 0; i < 23; i++) {
patword = clearBit(SIGNAL_clk, patword);
pat->word[iaddr++] = patword;

View File

@ -57,9 +57,9 @@
#define DEFAULT_TRIMBIT_VALUE (0)
#define DEFAULT_COUNTER_DISABLED_VTH_VAL (2800)
#define DEFAULT_READOUT_C0 (12) //(083333333) // rdo_clk, 83.33 MHz
#define DEFAULT_READOUT_C1 (12) //(083333333) // rdo_smp_clk, 83.33 MHz
#define DEFAULT_SYSTEM_C0 (20) //(050000000) // run_clk, 20 MHz
#define DEFAULT_READOUT_C0 (10) //(100000000) // rdo_clk, 100 MHz
#define DEFAULT_READOUT_C1 (10) //(100000000) // rdo_smp_clk, 100 MHz
#define DEFAULT_SYSTEM_C0 (10) //(100000000) // run_clk, 100 MHz
#define DEFAULT_SYSTEM_C1 (8) //(125000000) // str_clk, 125 MHz const
#define DEFAULT_SYSTEM_C2 (5) //(200000000) // smp_clk, 200 MHz const
#define DEFAULT_TRIMMING_RUN_CLKDIV (40) // (25000000) // 25 MHz

View File

@ -2839,6 +2839,7 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
if (cmd != "patlimits") {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
nPutArgs);
os << level << ' ';
}
if (action == defs::GET_ACTION) {
auto t =
@ -2878,6 +2879,7 @@ std::string CmdProxy::PatternLoopCycles(int action) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs,
nPutArgs);
os << level << ' ';
if (action == defs::GET_ACTION) {
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
@ -2912,6 +2914,7 @@ std::string CmdProxy::PatternWaitAddress(int action) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs,
nPutArgs);
os << level << ' ';
if (action == defs::GET_ACTION) {
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
@ -2945,6 +2948,7 @@ std::string CmdProxy::PatternWaitTime(int action) {
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs,
nPutArgs);
os << level << ' ';
if (action == defs::GET_ACTION) {
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
os << OutString(t) << '\n';

View File

@ -342,28 +342,32 @@ void DetectorImpl::updateDetectorSize() {
"updating detector size. ");
}
int maxx = shm()->numberOfChannels.x;
int maxy = shm()->numberOfChannels.y;
int nModx = 0, nMody = 0;
// 1d, add modules along x axis
if (modSize.y == 1) {
if (maxx == 0) {
maxx = modSize.x * size();
int detSizeX = shm()->numberOfChannels.x;
int maxChanX = modSize.x * size();
// user given detsizex used only within max value
if (detSizeX > 1 && detSizeX <= maxChanX) {
maxChanX = detSizeX;
}
nModx = maxx / modSize.x;
nModx = maxChanX / modSize.x;
nMody = size() / nModx;
if ((maxx % modSize.x) > 0) {
if ((maxChanX % modSize.x) > 0) {
++nMody;
}
}
// 2d, add modules along y axis (due to eiger top/bottom)
else {
if (maxy == 0) {
maxy = modSize.y * size();
int detSizeY = shm()->numberOfChannels.y;
int maxChanY = modSize.y * size();
// user given detsizey used only within max value
if (detSizeY > 1 && detSizeY <= maxChanY) {
maxChanY = detSizeY;
}
nMody = maxy / modSize.y;
nMody = maxChanY / modSize.y;
nModx = size() / nMody;
if ((maxy % modSize.y) > 0) {
if ((maxChanY % modSize.y) > 0) {
++nModx;
}
}
@ -1790,20 +1794,24 @@ void DetectorImpl::setBadChannels(const std::string &fname, Positions pos) {
" out of bounds.");
}
int ch = badchannel % nchan;
int imod = badchannel / nchan;
if (imod >= (int)modules.size()) {
size_t imod = badchannel / nchan;
if (imod >= modules.size()) {
throw RuntimeError("Invalid bad channel list. " +
std::to_string(badchannel) +
" out of bounds.");
}
if ((int)badchannels.size() != imod + 1) {
if (badchannels.size() != imod + 1) {
badchannels.push_back(std::vector<int>{});
}
badchannels[imod].push_back(ch);
}
for (int imod = 0; imod != (int)modules.size(); ++imod) {
Parallel(&Module::setBadChannels, {imod}, badchannels[imod]);
for (size_t imod = 0; imod != modules.size(); ++imod) {
// add empty vector if no bad channels in this module
if (badchannels.size() != imod + 1) {
badchannels.push_back(std::vector<int>{});
}
Parallel(&Module::setBadChannels, {static_cast<int>(imod)},
badchannels[imod]);
}
} else if (pos.size() != 1) {

View File

@ -76,7 +76,7 @@ void Module::setHostname(const std::string &hostname,
initialDetectorServerChecks();
checkDetectorVersionCompatibility();
LOG(logINFO) << "Module Version Compatibility - Success";
} catch (const DetectorError &e) {
} catch (const RuntimeError &e) {
if (!initialChecks) {
LOG(logWARNING) << "Bypassing Initial Checks at your own risk!";
} else {

View File

@ -9,7 +9,15 @@
namespace sls {
Pattern::Pattern() = default;
Pattern::Pattern() {
// initialize pattern addresses
for (int i = 0; i != MAX_PATTERN_LEVELS; ++i) {
pat->startloop[i] = MAX_PATTERN_LENGTH - 1;
pat->stoploop[i] = MAX_PATTERN_LENGTH - 1;
pat->wait[i] = MAX_PATTERN_LENGTH - 1;
}
}
Pattern::~Pattern() { delete pat; }
Pattern::Pattern(const Pattern &other) {

View File

@ -5,9 +5,10 @@
#define APILIB "7.0.0.rc1 0x221208"
#define APIRECEIVER "7.0.0.rc1 0x221208"
#define APICTB "7.0.0.rc1 0x221212"
#define APIGOTTHARD "7.0.0.rc1 0x221212"
#define APIGOTTHARD2 "7.0.0.rc1 0x221212"
#define APIJUNGFRAU "7.0.0.rc1 0x221212"
#define APIMYTHEN3 "7.0.0.rc1 0x221212"
#define APIMOENCH "7.0.0.rc1 0x221212"
#define APIEIGER "7.0.0.rc1 0x221212"
#define APIGOTTHARD "7.0.0.rc2 0x221220"
#define APIMYTHEN3 "7.0.0.rc2 0x230125"