mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-28 07:01:19 +01:00
Compare commits
36 Commits
dev/includ
...
fix/const
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec546bf4fb | ||
| 497b3ed00e | |||
| 300a296c20 | |||
| 01e392b112 | |||
| 5409cec73e | |||
|
|
1c31a85a43 | ||
| 134137ead0 | |||
| 6d3922f487 | |||
| f14cfb0b31 | |||
| cf4e6b65c1 | |||
| 0da80cd898 | |||
| 8e7921ae45 | |||
| b90851a855 | |||
| 683accd914 | |||
| 30e82e4740 | |||
| 08486b9812 | |||
| a5c661ce22 | |||
| 50448cefb4 | |||
| c1e5cfa101 | |||
| ae8c9175bf | |||
| e7f5a2aa11 | |||
| cad44943c3 | |||
| d4f8049623 | |||
| 925cd55b1c | |||
| ec11ba5a54 | |||
| eea4dca449 | |||
| 3285221e8a | |||
|
|
f32fcf1e88 | ||
| 3ff199822d | |||
| 0ba9a269a1 | |||
| afc51c9771 | |||
| 1cf9dc21ab | |||
| 3b92ffb902 | |||
|
|
0490c0ef23 | ||
| af2c6eca0c | |||
|
|
e243af045d |
@@ -28,8 +28,9 @@ Checks: '*,
|
|||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
-llvmlibc-*'
|
-llvmlibc-*'
|
||||||
|
|
||||||
HeaderFilterRegex: \.h
|
# HeaderFilterRegex: \.h
|
||||||
AnalyzeTemporaryDtors: false
|
HeaderFilterRegex: '^(?!.*([/\\])libs([/\\])).*'
|
||||||
|
#AnalyzeTemporaryDtors: false
|
||||||
FormatStyle: none
|
FormatStyle: none
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
|
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
|
||||||
|
|||||||
33
.gitea/workflows/rh8-local.yml
Normal file
33
.gitea/workflows/rh8-local.yml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
name: Build on local RHEL8
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- developer
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: "detectors-software-RH8"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build library
|
||||||
|
run: |
|
||||||
|
source /home/gitea_runner/.bashrc
|
||||||
|
conda activate det
|
||||||
|
mkdir build && cd build
|
||||||
|
conda activate det
|
||||||
|
cmake .. -DSLS_USE_PYTHON=ON
|
||||||
|
make -j 2
|
||||||
|
cd ../pyctbgui
|
||||||
|
make
|
||||||
|
|
||||||
|
- name: Deploy to NFS update server
|
||||||
|
if: gitea.ref == 'refs/heads/developer'
|
||||||
|
run: |
|
||||||
|
sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put build/bin'
|
||||||
|
sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put pyctbgui'
|
||||||
30
.gitea/workflows/rh9-local.yml
Normal file
30
.gitea/workflows/rh9-local.yml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
name: Build on local RHEL9
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- developer
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: "detectors-software-RH9"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build library
|
||||||
|
run: |
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake -DSLS_USE_PYTHON=ON -DPython_EXECUTABLE=/usr/bin/python3.13 -DPython_INCLUDE_DIR=/usr/include/python3.13 -DPython_LIBRARY=/usr/lib64/libpython3.13.so ..
|
||||||
|
make -j 2
|
||||||
|
cd ../pyctbgui
|
||||||
|
make
|
||||||
|
|
||||||
|
- name: Deploy to NFS update server
|
||||||
|
if: gitea.ref == 'refs/heads/developer'
|
||||||
|
run: |
|
||||||
|
sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH9 <<< $'put build/bin'
|
||||||
|
sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH9 <<< $'put pyctbgui'
|
||||||
2
.github/workflows/build_wheel.yml
vendored
2
.github/workflows/build_wheel.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
run: pipx run cibuildwheel==2.23.0
|
run: pipx run cibuildwheel==3.2.1
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
2
.github/workflows/cmake.yaml
vendored
2
.github/workflows/cmake.yaml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: 3.12
|
python-version: 3.12
|
||||||
cache: 'pip'
|
cache: 'pip'
|
||||||
- run: pip install pytest numpy
|
- run: pip install pytest numpy colorama
|
||||||
|
|
||||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
SLS Detector Package Major Release x.x.x released on xx.xx.202x
|
SLS Detector Package Major Release x.x.x released on xx.xx.202x
|
||||||
===============================================================
|
===============================================================
|
||||||
|
|
||||||
This document describes the differences between vx.x.x and vx.0.2
|
This document describes the differences between vx.x.x and v10.0.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -35,6 +35,8 @@ instead of the one included in our repo.
|
|||||||
|
|
||||||
Experimental support for building the detector client (including python bindings) on macOS
|
Experimental support for building the detector client (including python bindings) on macOS
|
||||||
|
|
||||||
|
``rx_dbitlist`` keeps the order of the passed bit list
|
||||||
|
|
||||||
2 On-board Detector Server Compatibility
|
2 On-board Detector Server Compatibility
|
||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ python:
|
|||||||
- 3.11
|
- 3.11
|
||||||
- 3.12
|
- 3.12
|
||||||
- 3.13
|
- 3.13
|
||||||
|
- 3.14
|
||||||
|
|
||||||
|
|
||||||
c_compiler:
|
c_compiler:
|
||||||
- gcc # [linux]
|
- gcc # [linux]
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ package:
|
|||||||
build:
|
build:
|
||||||
number: 0
|
number: 0
|
||||||
script:
|
script:
|
||||||
- unset CMAKE_GENERATOR && {{ PYTHON }} -m pip install . -vv # [not win]
|
- unset CMAKE_GENERATOR && {{ PYTHON }} -m pip install . -vv --config-settings=cmake.define.SLS_USE_SYSTEM_ZMQ=ON # [not win]
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
build:
|
build:
|
||||||
- python {{python}}
|
- python
|
||||||
- {{ compiler('c') }}
|
- {{ compiler('c') }}
|
||||||
- {{ stdlib("c") }}
|
- {{ stdlib("c") }}
|
||||||
- {{ compiler('cxx') }}
|
- {{ compiler('cxx') }}
|
||||||
@@ -21,7 +21,7 @@ requirements:
|
|||||||
host:
|
host:
|
||||||
- cmake
|
- cmake
|
||||||
- ninja
|
- ninja
|
||||||
- python {{python}}
|
- python
|
||||||
- pip
|
- pip
|
||||||
- scikit-build-core
|
- scikit-build-core
|
||||||
- pybind11 >=2.13.0
|
- pybind11 >=2.13.0
|
||||||
@@ -31,7 +31,7 @@ requirements:
|
|||||||
- catch2
|
- catch2
|
||||||
|
|
||||||
run:
|
run:
|
||||||
- python {{python}}
|
- python
|
||||||
- numpy
|
- numpy
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ std::string replace_all(const std::string &src, const std::string &from,
|
|||||||
const std::string &to) {
|
const std::string &to) {
|
||||||
|
|
||||||
std::string results;
|
std::string results;
|
||||||
std::string::const_iterator end = src.end();
|
std::string::const_iterator const end = src.end();
|
||||||
std::string::const_iterator current = src.begin();
|
std::string::const_iterator current = src.begin();
|
||||||
std::string::const_iterator next =
|
std::string::const_iterator next =
|
||||||
std::search(current, end, from.begin(), from.end());
|
std::search(current, end, from.begin(), from.end());
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ datetime.timedelta, DurationWrapper or by setting the time in seconds.
|
|||||||
>>> d.getExptime()
|
>>> d.getExptime()
|
||||||
[sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
|
[sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
|
||||||
|
|
||||||
|
# In C++ it is possible to use chrono literals to set time more easily
|
||||||
|
# d.setExptime(7ms). However, this is not possible due to pythons syntax.
|
||||||
|
# instead we can create a unit that we use for conversion.
|
||||||
|
>>> ms = dt.timedelta(milliseconds = 1)
|
||||||
|
>>> d.exptime = 7.5*ms
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ dependencies = [
|
|||||||
|
|
||||||
[tool.cibuildwheel]
|
[tool.cibuildwheel]
|
||||||
before-all = "uname -a"
|
before-all = "uname -a"
|
||||||
build = "cp{311,312,313}-manylinux_x86_64"
|
build = "cp{311,312,313,314}-manylinux_x86_64"
|
||||||
|
|
||||||
[tool.scikit-build.build]
|
[tool.scikit-build.build]
|
||||||
verbose = true
|
verbose = true
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import datetime as dt
|
|||||||
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from collections.abc import Sequence
|
||||||
import socket
|
import socket
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
@@ -147,33 +148,6 @@ class Detector(CppDetectorApi):
|
|||||||
value = ut.make_string_path(value)
|
value = ut.make_string_path(value)
|
||||||
self.loadParameters(value)
|
self.loadParameters(value)
|
||||||
|
|
||||||
|
|
||||||
@property
|
|
||||||
def include(self):
|
|
||||||
"""Sets detector measurement parameters to those contained in fname.
|
|
||||||
Set up per measurement.
|
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
Equivalent to config, but does not free shared memory. Same as parameters command.
|
|
||||||
|
|
||||||
:getter: Not implemented
|
|
||||||
:setter: loads parameters file
|
|
||||||
|
|
||||||
Example
|
|
||||||
---------
|
|
||||||
|
|
||||||
>>> d.include = 'path/to/file.par'
|
|
||||||
|
|
||||||
"""
|
|
||||||
return NotImplementedError("include is set only")
|
|
||||||
|
|
||||||
@include.setter
|
|
||||||
def include(self, value):
|
|
||||||
if isinstance(value, str):
|
|
||||||
value = ut.make_string_path(value)
|
|
||||||
self.loadParameters(value)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hostname(self):
|
def hostname(self):
|
||||||
"""Frees shared memory and sets hostname (or IP address) of all modules concatenated by +
|
"""Frees shared memory and sets hostname (or IP address) of all modules concatenated by +
|
||||||
@@ -328,6 +302,46 @@ class Detector(CppDetectorApi):
|
|||||||
def rx_arping(self, value):
|
def rx_arping(self, value):
|
||||||
ut.set_using_dict(self.setRxArping, value)
|
ut.set_using_dict(self.setRxArping, value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rx_roi(self):
|
||||||
|
"""Gets the list of ROIs configured in the receiver.
|
||||||
|
|
||||||
|
Note
|
||||||
|
-----
|
||||||
|
Each ROI is represented as a tuple of (x_start, y_start, x_end, y_end). \n
|
||||||
|
If no ROIs are configured, returns [[-1,-1,-1,-1]].
|
||||||
|
"""
|
||||||
|
return self.getRxROI() #vector of Roi structs how represented?
|
||||||
|
|
||||||
|
@rx_roi.setter
|
||||||
|
def rx_roi(self, rois):
|
||||||
|
"""
|
||||||
|
Sets the list of ROIs in the receiver.
|
||||||
|
Can only set multiple ROIs at multi module level without gap pixels. If more than 1 ROI per
|
||||||
|
UDP port, it will throw. Setting number of udp interfaces will clear the
|
||||||
|
roi. Cannot be set for CTB or Xilinx CTB.
|
||||||
|
|
||||||
|
Note
|
||||||
|
-----
|
||||||
|
Each ROI should be represented as a sequence of 4 ints (x_start, y_start, x_end, y_end). \n
|
||||||
|
For mythen3 or gotthard2 pass a sequence of 2 ints (x_start, x_end) \n
|
||||||
|
For multiple ROI's pass a sequence of sequence \n
|
||||||
|
Example: [[0, 100, 50, 100], [260, 270, 50,100]] \n
|
||||||
|
"""
|
||||||
|
# TODO: maybe better to accept py::object in setRxROI and handle there?
|
||||||
|
if not isinstance(rois, Sequence):
|
||||||
|
raise TypeError(
|
||||||
|
"setRxROI failed: expected a tuple/list of ints x_min, x_max, y_min, y_max "
|
||||||
|
"or a sequence of such."
|
||||||
|
)
|
||||||
|
if(not isinstance(rois[0], Sequence)):
|
||||||
|
self.setRxROI([rois])
|
||||||
|
else:
|
||||||
|
self.setRxROI(rois)
|
||||||
|
|
||||||
|
def rx_clearroi(self):
|
||||||
|
"""Clears all the ROIs configured in the receiver."""
|
||||||
|
self.clearRxROI()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
|
|||||||
@@ -942,6 +942,7 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(const std::vector<defs::ROI> &)) &
|
(void (Detector::*)(const std::vector<defs::ROI> &)) &
|
||||||
Detector::setRxROI,
|
Detector::setRxROI,
|
||||||
py::arg());
|
py::arg());
|
||||||
|
|
||||||
CppDetectorApi.def("clearRxROI",
|
CppDetectorApi.def("clearRxROI",
|
||||||
(void (Detector::*)()) & Detector::clearRxROI);
|
(void (Detector::*)()) & Detector::clearRxROI);
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ void init_duration(py::module &m) {
|
|||||||
m.def(
|
m.def(
|
||||||
"test_return_DurationWrapper",
|
"test_return_DurationWrapper",
|
||||||
[]() {
|
[]() {
|
||||||
DurationWrapper t(1.3);
|
DurationWrapper const t(1.3);
|
||||||
return t;
|
return t;
|
||||||
},
|
},
|
||||||
R"(
|
R"(
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
void init_enums(py::module &m) {
|
void init_enums(py::module &m) {
|
||||||
py::class_<slsDetectorDefs> Defs(m, "slsDetectorDefs");
|
py::class_<slsDetectorDefs> const Defs(m, "slsDetectorDefs");
|
||||||
py::class_<slsDetectorDefs::xy> xy(m, "xy");
|
py::class_<slsDetectorDefs::xy> xy(m, "xy");
|
||||||
xy.def(py::init());
|
xy.def(py::init());
|
||||||
xy.def(py::init<int, int>());
|
xy.def(py::init<int, int>());
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void init_pattern(py::module &m) {
|
|||||||
|
|
||||||
patternParameters.def(py::init());
|
patternParameters.def(py::init());
|
||||||
patternParameters.def("numpy_view", [](py::object &obj) {
|
patternParameters.def("numpy_view", [](py::object &obj) {
|
||||||
pat &o = obj.cast<pat &>();
|
pat const&o = obj.cast<pat &>();
|
||||||
return py::array_t<pat>(1, &o, obj);
|
return py::array_t<pat>(1, &o, obj);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <pybind11/pybind11.h>
|
|
||||||
#include <datetime.h>
|
#include <datetime.h>
|
||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
|
||||||
#include "sls/Result.h"
|
|
||||||
#include "DurationWrapper.h"
|
#include "DurationWrapper.h"
|
||||||
|
#include "sls/Result.h"
|
||||||
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
namespace pybind11 {
|
namespace pybind11 {
|
||||||
@@ -14,84 +15,130 @@ template <typename Type, typename Alloc>
|
|||||||
struct type_caster<sls::Result<Type, Alloc>>
|
struct type_caster<sls::Result<Type, Alloc>>
|
||||||
: list_caster<sls::Result<Type, Alloc>, Type> {};
|
: list_caster<sls::Result<Type, Alloc>, Type> {};
|
||||||
|
|
||||||
|
|
||||||
// Based on the typecaster in pybind11/chrono.h
|
// Based on the typecaster in pybind11/chrono.h
|
||||||
template <> struct type_caster<std::chrono::nanoseconds> {
|
template <> struct type_caster<std::chrono::nanoseconds> {
|
||||||
public:
|
public:
|
||||||
PYBIND11_TYPE_CASTER(std::chrono::nanoseconds, const_name("DurationWrapper"));
|
PYBIND11_TYPE_CASTER(std::chrono::nanoseconds,
|
||||||
|
const_name("DurationWrapper"));
|
||||||
|
|
||||||
// signed 25 bits required by the standard.
|
// signed 25 bits required by the standard.
|
||||||
using days = std::chrono::duration<int_least32_t, std::ratio<86400>>;
|
using days = std::chrono::duration<int_least32_t, std::ratio<86400>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conversion part 1 (Python->C++): convert a PyObject into std::chrono::nanoseconds
|
* Conversion part 1 (Python->C++): convert a PyObject into
|
||||||
* try datetime.timedelta, floats and our DurationWrapper wrapper
|
* std::chrono::nanoseconds try datetime.timedelta, floats and our
|
||||||
*/
|
* DurationWrapper wrapper
|
||||||
|
*/
|
||||||
|
|
||||||
bool load(handle src, bool) {
|
bool load(handle src, bool) {
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
// Lazy initialise the PyDateTime import
|
// Lazy initialise the PyDateTime import
|
||||||
if (!PyDateTimeAPI) {
|
if (!PyDateTimeAPI) {
|
||||||
PyDateTime_IMPORT;
|
PyDateTime_IMPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!src) {
|
if (!src) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// If invoked with datetime.delta object, same as in chrono.h
|
||||||
|
if (PyDelta_Check(src.ptr())) {
|
||||||
|
value = duration_cast<nanoseconds>(
|
||||||
|
days(PyDateTime_DELTA_GET_DAYS(src.ptr())) +
|
||||||
|
seconds(PyDateTime_DELTA_GET_SECONDS(src.ptr())) +
|
||||||
|
microseconds(PyDateTime_DELTA_GET_MICROSECONDS(src.ptr()))
|
||||||
|
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// If invoked with a float we assume it is seconds and convert, same as
|
||||||
|
// in chrono.h
|
||||||
|
if (PyFloat_Check(src.ptr())) {
|
||||||
|
value = duration_cast<nanoseconds>(
|
||||||
|
duration<double>(PyFloat_AsDouble(src.ptr())));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// If invoked with an int we assume it is nanoseconds and convert, same
|
||||||
|
// as in chrono.h
|
||||||
|
if (PyLong_Check(src.ptr())) {
|
||||||
|
value = duration_cast<nanoseconds>(
|
||||||
|
duration<int64_t>(PyLong_AsLongLong(src.ptr())));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lastly if we were actually called with a DurationWrapper object we
|
||||||
|
// get the number of nanoseconds and create a std::chrono::nanoseconds
|
||||||
|
// from it
|
||||||
|
py::object py_cls =
|
||||||
|
py::module::import("slsdet._slsdet").attr("DurationWrapper");
|
||||||
|
if (py::isinstance(src, py_cls)) {
|
||||||
|
sls::DurationWrapper *cls = src.cast<sls::DurationWrapper *>();
|
||||||
|
value = nanoseconds(cls->count());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversion part 2 (C++ -> Python)
|
||||||
|
* import the module to get a handle to the wrapped class
|
||||||
|
* Default construct an object of (wrapped) DurationWrapper
|
||||||
|
* set the count from chrono::nanoseconds and return
|
||||||
|
*/
|
||||||
|
static handle cast(std::chrono::nanoseconds src,
|
||||||
|
return_value_policy /* policy */, handle /* parent */) {
|
||||||
|
py::object py_cls =
|
||||||
|
py::module::import("slsdet._slsdet").attr("DurationWrapper");
|
||||||
|
py::object *obj = new py::object;
|
||||||
|
*obj = py_cls();
|
||||||
|
sls::DurationWrapper *dur = obj->cast<sls::DurationWrapper *>();
|
||||||
|
dur->set_count(src.count());
|
||||||
|
return *obj;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Type caster for sls::defs::ROI from tuple
|
||||||
|
template <> struct type_caster<sls::defs::ROI> {
|
||||||
|
PYBIND11_TYPE_CASTER(sls::defs::ROI, _("Sequence[int, int, int, int] or "
|
||||||
|
"Sequence[int, int]"));
|
||||||
|
|
||||||
|
// convert c++ ROI to python tuple
|
||||||
|
static handle cast(const sls::defs::ROI &roi, return_value_policy, handle) {
|
||||||
|
return py::make_tuple(roi.xmin, roi.xmax, roi.ymin, roi.ymax).release();
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert from python to c++ ROI
|
||||||
|
bool load(handle roi, bool /*allow implicit conversion*/) {
|
||||||
|
|
||||||
|
// accept tuple, list, numpy array any sequence
|
||||||
|
py::sequence seq;
|
||||||
|
try {
|
||||||
|
seq = py::reinterpret_borrow<py::sequence>(roi);
|
||||||
|
} catch (...) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seq.size() != 4 && seq.size() != 2)
|
||||||
|
return false;
|
||||||
|
// Check if each element is an int
|
||||||
|
for (auto item : seq) {
|
||||||
|
if (!py::isinstance<py::int_>(item)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// If invoked with datetime.delta object, same as in chrono.h
|
|
||||||
if (PyDelta_Check(src.ptr())) {
|
|
||||||
value = duration_cast<nanoseconds>(
|
|
||||||
days(PyDateTime_DELTA_GET_DAYS(src.ptr())) +
|
|
||||||
seconds(PyDateTime_DELTA_GET_SECONDS(src.ptr())) +
|
|
||||||
microseconds(PyDateTime_DELTA_GET_MICROSECONDS(src.ptr()))
|
|
||||||
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// If invoked with a float we assume it is seconds and convert, same as in chrono.h
|
|
||||||
if (PyFloat_Check(src.ptr())) {
|
|
||||||
value = duration_cast<nanoseconds>(duration<double>(PyFloat_AsDouble(src.ptr())));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// If invoked with an int we assume it is nanoseconds and convert, same as in chrono.h
|
|
||||||
if (PyLong_Check(src.ptr())) {
|
|
||||||
value = duration_cast<nanoseconds>(duration<int64_t>(PyLong_AsLongLong(src.ptr())));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Lastly if we were actually called with a DurationWrapper object we get
|
|
||||||
// the number of nanoseconds and create a std::chrono::nanoseconds from it
|
|
||||||
py::object py_cls = py::module::import("slsdet._slsdet").attr("DurationWrapper");
|
|
||||||
if (py::isinstance(src, py_cls)){
|
|
||||||
sls::DurationWrapper *cls = src.cast<sls::DurationWrapper *>();
|
|
||||||
value = nanoseconds(cls->count());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
value.xmin = seq[0].cast<int>();
|
||||||
* Conversion part 2 (C++ -> Python)
|
value.xmax = seq[1].cast<int>();
|
||||||
* import the module to get a handle to the wrapped class
|
|
||||||
* Default construct an object of (wrapped) DurationWrapper
|
if (seq.size() == 4) {
|
||||||
* set the count from chrono::nanoseconds and return
|
value.ymin = seq[2].cast<int>();
|
||||||
*/
|
value.ymax = seq[3].cast<int>();
|
||||||
static handle cast(std::chrono::nanoseconds src, return_value_policy /* policy */, handle /* parent */) {
|
|
||||||
py::object py_cls = py::module::import("slsdet._slsdet").attr("DurationWrapper");
|
|
||||||
py::object* obj = new py::object;
|
|
||||||
*obj = py_cls();
|
|
||||||
sls::DurationWrapper *dur = obj->cast<sls::DurationWrapper *>();
|
|
||||||
dur->set_count(src.count());
|
|
||||||
return *obj;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace pybind11
|
} // namespace pybind11
|
||||||
85
python/tests/conftest.py
Normal file
85
python/tests/conftest.py
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import pytest
|
||||||
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
current_dir = Path(__file__).resolve().parents[2]
|
||||||
|
|
||||||
|
scripts_dir = current_dir / "tests" / "scripts"
|
||||||
|
|
||||||
|
sys.path.append(str(scripts_dir))
|
||||||
|
|
||||||
|
print(sys.path)
|
||||||
|
|
||||||
|
from utils_for_test import (
|
||||||
|
Log,
|
||||||
|
LogLevel,
|
||||||
|
cleanup,
|
||||||
|
startReceiver,
|
||||||
|
startDetectorVirtualServer,
|
||||||
|
loadConfig,
|
||||||
|
loadBasicSettings,
|
||||||
|
)
|
||||||
|
|
||||||
|
def pytest_addoption(parser):
|
||||||
|
parser.addoption(
|
||||||
|
"--with-detector-simulators", action="store_true", default=False, help="Run tests that require detector simulators"
|
||||||
|
)
|
||||||
|
|
||||||
|
def pytest_configure(config):
|
||||||
|
config.addinivalue_line("markers", "withdetectorsimulators: mark test as needing detector simulators to run")
|
||||||
|
|
||||||
|
def pytest_collection_modifyitems(config, items):
|
||||||
|
if config.getoption("--with-detector-simulators"):
|
||||||
|
return
|
||||||
|
skip = pytest.mark.skip(reason="need --with-detector-simulators option to run")
|
||||||
|
for item in items:
|
||||||
|
if "withdetectorsimulators" in item.keywords:
|
||||||
|
item.add_marker(skip)
|
||||||
|
|
||||||
|
#helper fixture for servers
|
||||||
|
@pytest.fixture
|
||||||
|
def servers(request):
|
||||||
|
try:
|
||||||
|
return request.param # comes from @pytest.mark.parametrize(..., indirect=True)
|
||||||
|
except AttributeError:
|
||||||
|
# fallback default if the test did not parametrize
|
||||||
|
return ['eiger', 'jungfrau', 'mythen3', 'gotthard2', 'ctb', 'moench', 'xilinx_ctb']
|
||||||
|
return request.param
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def test_with_simulators(servers):
|
||||||
|
""" Fixture to automatically setup virtual detector servers for testing. """
|
||||||
|
|
||||||
|
LOG_PREFIX_FNAME = '/tmp/slsDetectorPackage_virtual_PythonAPI_test'
|
||||||
|
MAIN_LOG_FNAME = LOG_PREFIX_FNAME + '_log.txt'
|
||||||
|
|
||||||
|
with open(MAIN_LOG_FNAME, 'w') as fp:
|
||||||
|
try:
|
||||||
|
nmods = 2
|
||||||
|
for server in servers:
|
||||||
|
for ninterfaces in range(1,2):
|
||||||
|
if ninterfaces == 2 and server != 'jungfrau' and server != 'moench':
|
||||||
|
continue
|
||||||
|
|
||||||
|
msg = f'Starting Python API Tests for {server}'
|
||||||
|
|
||||||
|
if server == 'jungfrau' or server == 'moench':
|
||||||
|
msg += f' with {ninterfaces} interfaces'
|
||||||
|
|
||||||
|
Log(LogLevel.INFOBLUE, msg, fp)
|
||||||
|
cleanup(fp)
|
||||||
|
startDetectorVirtualServer(server, nmods, fp)
|
||||||
|
startReceiver(nmods, fp)
|
||||||
|
d = loadConfig(name=server, log_file_fp=fp, num_mods=nmods, num_frames=1, num_interfaces=ninterfaces)
|
||||||
|
loadBasicSettings(name=server, d=d, fp=fp)
|
||||||
|
yield # run test
|
||||||
|
cleanup(fp) # teardown
|
||||||
|
except Exception as e:
|
||||||
|
with open(MAIN_LOG_FNAME, 'a') as fp_error:
|
||||||
|
traceback.print_exc(file=fp_error)
|
||||||
|
Log(LogLevel.ERROR, f'Tests Failed.', fp)
|
||||||
|
cleanup(fp)
|
||||||
|
|
||||||
|
|
||||||
48
python/tests/test_pythonAPI.py
Normal file
48
python/tests/test_pythonAPI.py
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import pytest
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from conftest import test_with_simulators
|
||||||
|
|
||||||
|
from slsdet import Detector
|
||||||
|
|
||||||
|
@pytest.mark.withdetectorsimulators
|
||||||
|
@pytest.mark.parametrize("servers", [["moench"]], indirect=True)
|
||||||
|
def test_rx_ROI_moench(test_with_simulators, servers):
|
||||||
|
""" Test setting and getting rx_ROI property of Detector class for moench. """
|
||||||
|
|
||||||
|
d = Detector()
|
||||||
|
d.rx_roi = (0, 10, 10, 20)
|
||||||
|
roi = d.rx_roi
|
||||||
|
assert roi == [(0, 10, 10, 20)]
|
||||||
|
|
||||||
|
d.rx_roi = [5,15,15,25]
|
||||||
|
|
||||||
|
assert d.rx_roi == [(5,15,15,25)]
|
||||||
|
|
||||||
|
d.rx_roi = [[0,10,0,20], [5,20,410,420]]
|
||||||
|
|
||||||
|
roi = d.rx_roi
|
||||||
|
assert roi == [(0,10,0,20), (5,20,410,420)]
|
||||||
|
|
||||||
|
d.rx_clearroi()
|
||||||
|
roi = d.rx_roi
|
||||||
|
assert roi == [(-1,-1,-1,-1)]
|
||||||
|
|
||||||
|
@pytest.mark.withdetectorsimulators
|
||||||
|
@pytest.mark.parametrize("servers", [["mythen3"]], indirect=True)
|
||||||
|
def test_rx_ROI_mythen(test_with_simulators, servers):
|
||||||
|
""" Test setting and getting rx_ROI property of Detector class for mythen. """
|
||||||
|
|
||||||
|
d = Detector()
|
||||||
|
d.rx_roi = (0, 10)
|
||||||
|
roi = d.rx_roi
|
||||||
|
assert roi == [(0, 10, -1, -1)]
|
||||||
|
|
||||||
|
#d.rx_roi = [[5,15, 0, 1]] # not allowed for mythen3
|
||||||
|
|
||||||
|
d.rx_roi = [0,10, -1, -1]
|
||||||
|
|
||||||
|
assert d.rx_roi == [(0,10,-1,-1)]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Prepare MH02 configuration
|
# Prepare MH02 configuration
|
||||||
reg 0xC00C 0x00000041
|
reg 0xC00C 0x00040041
|
||||||
reg 0xC010 0x01200004
|
reg 0xC010 0x01200004
|
||||||
|
|
||||||
# configure Matterhorn SPI
|
# configure Matterhorn SPI
|
||||||
@@ -14,7 +14,7 @@ reg 0xC120 0x1
|
|||||||
reg 0xC120 0x0
|
reg 0xC120 0x0
|
||||||
|
|
||||||
# set MSB LSB inversions and polarity for transceiver
|
# set MSB LSB inversions and polarity for transceiver
|
||||||
reg 0xC120 0x61e0
|
reg 0xC120 0x1e0
|
||||||
|
|
||||||
# Enable MH02 PLL clock
|
# Enable MH02 PLL clock
|
||||||
pattern enable_clock_pattern.pyat
|
pattern enable_clock_pattern.pyat
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
# turn off clock
|
# turn off clock
|
||||||
setbit 0xC00C 16
|
clearbit 0xB018 15
|
||||||
setbit 0xC014 0
|
setbit 0xB010 15
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# reset Matterhorn periphery
|
# reset Matterhorn periphery
|
||||||
@@ -9,8 +9,7 @@ setbit 0xC014 1
|
|||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# turn on clock
|
# turn on clock
|
||||||
clearbit 0xC00C 16
|
clearbit 0xB010 15
|
||||||
setbit 0xC014 0
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# reset rx transceiver datapath
|
# reset rx transceiver datapath
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ _sd() {
|
|||||||
local IS_PATH=0
|
local IS_PATH=0
|
||||||
|
|
||||||
|
|
||||||
local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest include initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit pattern patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_dbitreorder rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport "
|
local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit pattern patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_dbitreorder rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport "
|
||||||
__acquire() {
|
__acquire() {
|
||||||
FCN_RETURN=""
|
FCN_RETURN=""
|
||||||
return 0
|
return 0
|
||||||
@@ -1214,21 +1214,6 @@ fi
|
|||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
__include() {
|
|
||||||
FCN_RETURN=""
|
|
||||||
if [[ ${IS_GET} -eq 1 ]]; then
|
|
||||||
if [[ "${cword}" == "2" ]]; then
|
|
||||||
FCN_RETURN="0 1"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ ${IS_GET} -eq 0 ]]; then
|
|
||||||
if [[ "${cword}" == "2" ]]; then
|
|
||||||
FCN_RETURN=""
|
|
||||||
IS_PATH=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
__initialchecks() {
|
__initialchecks() {
|
||||||
FCN_RETURN=""
|
FCN_RETURN=""
|
||||||
if [[ ${IS_GET} -eq 0 ]]; then
|
if [[ ${IS_GET} -eq 0 ]]; then
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
_sd() {
|
_sd() {
|
||||||
|
|
||||||
|
|
||||||
local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest include initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit pattern patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_dbitreorder rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport "
|
local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit pattern patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_dbitreorder rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport "
|
||||||
__acquire() {
|
__acquire() {
|
||||||
FCN_RETURN=""
|
FCN_RETURN=""
|
||||||
return 0
|
return 0
|
||||||
@@ -1138,21 +1138,6 @@ fi
|
|||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
__include() {
|
|
||||||
FCN_RETURN=""
|
|
||||||
if [[ ${IS_GET} -eq 1 ]]; then
|
|
||||||
if [[ "${cword}" == "2" ]]; then
|
|
||||||
FCN_RETURN="0 1"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ ${IS_GET} -eq 0 ]]; then
|
|
||||||
if [[ "${cword}" == "2" ]]; then
|
|
||||||
FCN_RETURN=""
|
|
||||||
IS_PATH=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
__initialchecks() {
|
__initialchecks() {
|
||||||
FCN_RETURN=""
|
FCN_RETURN=""
|
||||||
if [[ ${IS_GET} -eq 0 ]]; then
|
if [[ ${IS_GET} -eq 0 ]]; then
|
||||||
|
|||||||
@@ -1846,13 +1846,6 @@ parameters:
|
|||||||
PUT:
|
PUT:
|
||||||
function: loadParameters
|
function: loadParameters
|
||||||
|
|
||||||
include:
|
|
||||||
inherit_actions: EXECUTE_SET_COMMAND_NOID_1ARG
|
|
||||||
help: "\n\tSets detector measurement parameters to those contained in fname. Set up per measurement. Same as parameters command."
|
|
||||||
actions:
|
|
||||||
PUT:
|
|
||||||
function: loadParameters
|
|
||||||
|
|
||||||
savepattern:
|
savepattern:
|
||||||
inherit_actions: EXECUTE_SET_COMMAND_NOID_1ARG
|
inherit_actions: EXECUTE_SET_COMMAND_NOID_1ARG
|
||||||
help: "\n\t[Ctb][Mythen3][Xilinx Ctb] Saves pattern to file (ascii). \n\t[Ctb] Also executes pattern."
|
help: "\n\t[Ctb][Mythen3][Xilinx Ctb] Saves pattern to file (ascii). \n\t[Ctb] Also executes pattern."
|
||||||
|
|||||||
@@ -4988,32 +4988,6 @@ imagetest:
|
|||||||
\ pixel intensity incremented by 1. If 1, all pixels almost saturated."
|
\ pixel intensity incremented by 1. If 1, all pixels almost saturated."
|
||||||
infer_action: true
|
infer_action: true
|
||||||
template: true
|
template: true
|
||||||
include:
|
|
||||||
actions:
|
|
||||||
PUT:
|
|
||||||
args:
|
|
||||||
- arg_types:
|
|
||||||
- special::path
|
|
||||||
argc: 1
|
|
||||||
cast_input:
|
|
||||||
- false
|
|
||||||
check_det_id: true
|
|
||||||
convert_det_id: true
|
|
||||||
function: loadParameters
|
|
||||||
input:
|
|
||||||
- args[0]
|
|
||||||
input_types:
|
|
||||||
- std::string
|
|
||||||
output:
|
|
||||||
- args.front()
|
|
||||||
require_det_id: false
|
|
||||||
store_result_in_t: false
|
|
||||||
command_name: include
|
|
||||||
function_alias: include
|
|
||||||
help: "\n\tSets detector measurement parameters to those contained in fname. Set\
|
|
||||||
\ up per measurement. Same as parameters command."
|
|
||||||
infer_action: true
|
|
||||||
template: true
|
|
||||||
initialchecks:
|
initialchecks:
|
||||||
actions:
|
actions:
|
||||||
GET:
|
GET:
|
||||||
|
|||||||
@@ -25,21 +25,21 @@ class detectorData {
|
|||||||
~detectorData(){};
|
~detectorData(){};
|
||||||
|
|
||||||
int64_t getChannel(int i) {
|
int64_t getChannel(int i) {
|
||||||
int off = dynamicRange / 8;
|
const int off = dynamicRange / 8;
|
||||||
if (off == 1) {
|
if (off == 1) {
|
||||||
char val = *(data + i);
|
const char val = *(data + i);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
if (off == 2) {
|
if (off == 2) {
|
||||||
int16_t val = *((int16_t *)(data + i * off));
|
const int16_t val = *((int16_t *)(data + i * off));
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
if (off == 4) {
|
if (off == 4) {
|
||||||
int32_t val = *((int32_t *)(data + i * off));
|
const int32_t val = *((int32_t *)(data + i * off));
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
if (off == 8) {
|
if (off == 8) {
|
||||||
int64_t val = *((int64_t *)(data + i * off));
|
const int64_t val = *((int64_t *)(data + i * off));
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -161,7 +161,6 @@ class Caller {
|
|||||||
std::string im_d(int action);
|
std::string im_d(int action);
|
||||||
std::string im_io(int action);
|
std::string im_io(int action);
|
||||||
std::string imagetest(int action);
|
std::string imagetest(int action);
|
||||||
std::string include(int action);
|
|
||||||
std::string initialchecks(int action);
|
std::string initialchecks(int action);
|
||||||
std::string inj_ch(int action);
|
std::string inj_ch(int action);
|
||||||
std::string interpolation(int action);
|
std::string interpolation(int action);
|
||||||
@@ -506,7 +505,6 @@ class Caller {
|
|||||||
{"im_d", &Caller::im_d},
|
{"im_d", &Caller::im_d},
|
||||||
{"im_io", &Caller::im_io},
|
{"im_io", &Caller::im_io},
|
||||||
{"imagetest", &Caller::imagetest},
|
{"imagetest", &Caller::imagetest},
|
||||||
{"include", &Caller::include},
|
|
||||||
{"initialchecks", &Caller::initialchecks},
|
{"initialchecks", &Caller::initialchecks},
|
||||||
{"inj_ch", &Caller::inj_ch},
|
{"inj_ch", &Caller::inj_ch},
|
||||||
{"interpolation", &Caller::interpolation},
|
{"interpolation", &Caller::interpolation},
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ std::string Caller::list(int action) {
|
|||||||
/* Network Configuration (Detector<->Receiver) */
|
/* Network Configuration (Detector<->Receiver) */
|
||||||
|
|
||||||
IpAddr Caller::getDstIpFromAuto() {
|
IpAddr Caller::getDstIpFromAuto() {
|
||||||
std::string rxHostname =
|
std::string const rxHostname =
|
||||||
det->getRxHostname(std::vector<int>{det_id}).squash("none");
|
det->getRxHostname(std::vector<int>{det_id}).squash("none");
|
||||||
// Hostname could be ip try to decode otherwise look up the hostname
|
// Hostname could be ip try to decode otherwise look up the hostname
|
||||||
auto val = IpAddr{rxHostname};
|
auto val = IpAddr{rxHostname};
|
||||||
@@ -113,7 +113,7 @@ IpAddr Caller::getDstIpFromAuto() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IpAddr Caller::getSrcIpFromAuto() {
|
IpAddr Caller::getSrcIpFromAuto() {
|
||||||
std::string hostname =
|
std::string const hostname =
|
||||||
det->getHostname(std::vector<int>{det_id}).squash("none");
|
det->getHostname(std::vector<int>{det_id}).squash("none");
|
||||||
// Hostname could be ip try to decode otherwise look up the hostname
|
// Hostname could be ip try to decode otherwise look up the hostname
|
||||||
auto val = IpAddr{hostname};
|
auto val = IpAddr{hostname};
|
||||||
@@ -128,9 +128,9 @@ UdpDestination Caller::getUdpEntry() {
|
|||||||
udpDestination.entry = rx_id;
|
udpDestination.entry = rx_id;
|
||||||
|
|
||||||
for (auto it : args) {
|
for (auto it : args) {
|
||||||
size_t pos = it.find('=');
|
size_t const pos = it.find('=');
|
||||||
std::string key = it.substr(0, pos);
|
std::string const key = it.substr(0, pos);
|
||||||
std::string value = it.substr(pos + 1);
|
std::string const value = it.substr(pos + 1);
|
||||||
if (key == "ip") {
|
if (key == "ip") {
|
||||||
if (value == "auto") {
|
if (value == "auto") {
|
||||||
auto val = getDstIpFromAuto();
|
auto val = getDstIpFromAuto();
|
||||||
@@ -177,7 +177,7 @@ int Caller::GetLevelAndInsertIntoArgs(std::string levelSeparatedCommand) {
|
|||||||
LOG(logWARNING) << "This command is deprecated and will be removed. "
|
LOG(logWARNING) << "This command is deprecated and will be removed. "
|
||||||
"Please migrate to "
|
"Please migrate to "
|
||||||
<< levelSeparatedCommand;
|
<< levelSeparatedCommand;
|
||||||
int level = cmd[cmd.find_first_of("012")] - '0';
|
int const level = cmd[cmd.find_first_of("012")] - '0';
|
||||||
args.insert(args.begin(), std::to_string(level));
|
args.insert(args.begin(), std::to_string(level));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -295,8 +295,8 @@ std::string Caller::versions(int action) {
|
|||||||
bool receiver = false;
|
bool receiver = false;
|
||||||
std::string vReceiver = "Unknown";
|
std::string vReceiver = "Unknown";
|
||||||
|
|
||||||
std::string vRelease = det->getPackageVersion();
|
std::string const vRelease = det->getPackageVersion();
|
||||||
std::string vClient = det->getClientVersion();
|
std::string const vClient = det->getClientVersion();
|
||||||
|
|
||||||
if (det->size() != 0) {
|
if (det->size() != 0) {
|
||||||
// shared memory has detectors
|
// shared memory has detectors
|
||||||
@@ -382,7 +382,7 @@ std::string Caller::threshold(int action) {
|
|||||||
if (!args.empty()) {
|
if (!args.empty()) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
}
|
}
|
||||||
defs::detectorType type = det->getDetectorType().squash();
|
defs::detectorType const type = det->getDetectorType().squash();
|
||||||
if (type == defs::EIGER) {
|
if (type == defs::EIGER) {
|
||||||
auto t = det->getThresholdEnergy(std::vector<int>{det_id});
|
auto t = det->getThresholdEnergy(std::vector<int>{det_id});
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
@@ -393,7 +393,7 @@ std::string Caller::threshold(int action) {
|
|||||||
throw RuntimeError("Not implemented for this detector\n");
|
throw RuntimeError("Not implemented for this detector\n");
|
||||||
}
|
}
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
defs::detectorType type = det->getDetectorType().squash();
|
defs::detectorType const type = det->getDetectorType().squash();
|
||||||
if (type == defs::EIGER && args.size() != 1 && args.size() != 2) {
|
if (type == defs::EIGER && args.size() != 1 && args.size() != 2) {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
@@ -401,7 +401,7 @@ std::string Caller::threshold(int action) {
|
|||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool trimbits = (cmd == "thresholdnotb") ? false : true;
|
bool const trimbits = (cmd == "thresholdnotb") ? false : true;
|
||||||
std::array<int, 3> energy = {StringTo<int>(args[0]), 0, 0};
|
std::array<int, 3> energy = {StringTo<int>(args[0]), 0, 0};
|
||||||
energy[1] = energy[0];
|
energy[1] = energy[0];
|
||||||
energy[2] = energy[0];
|
energy[2] = energy[0];
|
||||||
@@ -708,7 +708,7 @@ std::string Caller::rx_hostname(int action) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
std::string Caller::rx_zmqip(int action) {
|
std::string Caller::rx_zmqip(int action) {
|
||||||
std::string helpMessage =
|
std::string const helpMessage =
|
||||||
"\n\t[deprecated] The receiver zmq socket (publisher) will "
|
"\n\t[deprecated] The receiver zmq socket (publisher) will "
|
||||||
"listen to all interfaces ('tcp://0.0.0.0:[port]'to all interfaces "
|
"listen to all interfaces ('tcp://0.0.0.0:[port]'to all interfaces "
|
||||||
"(from v9.0.0). This command does nothing and will be removed "
|
"(from v9.0.0). This command does nothing and will be removed "
|
||||||
@@ -729,7 +729,7 @@ std::string Caller::rx_zmqip(int action) {
|
|||||||
|
|
||||||
std::string Caller::rx_roi(int action) {
|
std::string Caller::rx_roi(int action) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
std::string helpMessage =
|
std::string const helpMessage =
|
||||||
std::string("[xmin] [xmax] [ymin] [ymax]\n") +
|
std::string("[xmin] [xmax] [ymin] [ymax]\n") +
|
||||||
"\tDefines a single region of interest (ROI) in the receiver.\n"
|
"\tDefines a single region of interest (ROI) in the receiver.\n"
|
||||||
"\tFor example, to set a single ROI: 0 100 20 30\n\n"
|
"\tFor example, to set a single ROI: 0 100 20 30\n\n"
|
||||||
@@ -771,7 +771,7 @@ std::string Caller::rx_roi(int action) {
|
|||||||
}
|
}
|
||||||
// Support multiple args with bracketed ROIs, or single arg with
|
// Support multiple args with bracketed ROIs, or single arg with
|
||||||
// semicolon-separated vector in quotes
|
// semicolon-separated vector in quotes
|
||||||
bool isVectorInput =
|
bool const isVectorInput =
|
||||||
std::all_of(args.begin(), args.end(), [](const std::string &a) {
|
std::all_of(args.begin(), args.end(), [](const std::string &a) {
|
||||||
return a.find('[') != std::string::npos &&
|
return a.find('[') != std::string::npos &&
|
||||||
a.find(']') != std::string::npos;
|
a.find(']') != std::string::npos;
|
||||||
@@ -870,7 +870,7 @@ std::string Caller::ratecorr(int action) {
|
|||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
int tau = StringTo<int>(args[0]);
|
int const tau = StringTo<int>(args[0]);
|
||||||
if (tau == -1) {
|
if (tau == -1) {
|
||||||
det->setDefaultRateCorrection(std::vector<int>{det_id});
|
det->setDefaultRateCorrection(std::vector<int>{det_id});
|
||||||
auto t = det->getRateCorrection(std::vector<int>{det_id});
|
auto t = det->getRateCorrection(std::vector<int>{det_id});
|
||||||
@@ -905,7 +905,7 @@ std::string Caller::burstmode(int action) {
|
|||||||
}
|
}
|
||||||
defs::burstMode t;
|
defs::burstMode t;
|
||||||
try {
|
try {
|
||||||
int ival = StringTo<int>(args[0]);
|
int const ival = StringTo<int>(args[0]);
|
||||||
switch (ival) {
|
switch (ival) {
|
||||||
case 0:
|
case 0:
|
||||||
t = defs::BURST_INTERNAL;
|
t = defs::BURST_INTERNAL;
|
||||||
@@ -1001,7 +1001,7 @@ std::string Caller::counters(int action) {
|
|||||||
// convert vector to counter enable mask
|
// convert vector to counter enable mask
|
||||||
uint32_t mask = 0;
|
uint32_t mask = 0;
|
||||||
for (size_t i = 0; i < args.size(); ++i) {
|
for (size_t i = 0; i < args.size(); ++i) {
|
||||||
int val = StringTo<int>(args[i]);
|
int const val = StringTo<int>(args[i]);
|
||||||
// already enabled earlier
|
// already enabled earlier
|
||||||
if (mask & (1 << val)) {
|
if (mask & (1 << val)) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@@ -1036,9 +1036,9 @@ std::string Caller::samples(int action) {
|
|||||||
auto d = det->getNumberOfDigitalSamples(std::vector<int>{det_id});
|
auto d = det->getNumberOfDigitalSamples(std::vector<int>{det_id});
|
||||||
auto t =
|
auto t =
|
||||||
det->getNumberOfTransceiverSamples(std::vector<int>{det_id});
|
det->getNumberOfTransceiverSamples(std::vector<int>{det_id});
|
||||||
int as = a.squash(-1);
|
int const as = a.squash(-1);
|
||||||
int ds = d.squash(-1);
|
int const ds = d.squash(-1);
|
||||||
int ts = t.squash(-1);
|
int const ts = t.squash(-1);
|
||||||
if (as == -1 || ds == -1 || ts == -1 || as != ds ||
|
if (as == -1 || ds == -1 || ts == -1 || as != ds ||
|
||||||
as != ts) { // check if a == d?
|
as != ts) { // check if a == d?
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
@@ -1077,7 +1077,7 @@ std::string Caller::slowadc(int action) {
|
|||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
}
|
}
|
||||||
int nchan = StringTo<int>(args[0]);
|
int const nchan = StringTo<int>(args[0]);
|
||||||
if (nchan < 0 || nchan > 7) {
|
if (nchan < 0 || nchan > 7) {
|
||||||
throw RuntimeError("Unknown adc argument " + args[0]);
|
throw RuntimeError("Unknown adc argument " + args[0]);
|
||||||
}
|
}
|
||||||
@@ -1109,7 +1109,7 @@ std::string Caller::patwaittime(int action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse level
|
// parse level
|
||||||
bool deprecated_cmd = GetLevelAndInsertIntoArgs("patwaittime");
|
bool const deprecated_cmd = GetLevelAndInsertIntoArgs("patwaittime");
|
||||||
int level = 0;
|
int level = 0;
|
||||||
try {
|
try {
|
||||||
if (args.size() > 0)
|
if (args.size() > 0)
|
||||||
@@ -1141,7 +1141,7 @@ std::string Caller::patwaittime(int action) {
|
|||||||
// clocks (all digits)
|
// clocks (all digits)
|
||||||
if (args.size() == 2 &&
|
if (args.size() == 2 &&
|
||||||
std::all_of(args[1].begin(), args[1].end(), ::isdigit)) {
|
std::all_of(args[1].begin(), args[1].end(), ::isdigit)) {
|
||||||
uint64_t waittime = StringTo<uint64_t>(args[1]);
|
uint64_t const waittime = StringTo<uint64_t>(args[1]);
|
||||||
det->setPatternWaitClocks(level, waittime,
|
det->setPatternWaitClocks(level, waittime,
|
||||||
std::vector<int>{det_id});
|
std::vector<int>{det_id});
|
||||||
os << waittime << '\n';
|
os << waittime << '\n';
|
||||||
@@ -1152,7 +1152,7 @@ std::string Caller::patwaittime(int action) {
|
|||||||
try {
|
try {
|
||||||
if (args.size() == 2) {
|
if (args.size() == 2) {
|
||||||
std::string tmp_time(args[1]);
|
std::string tmp_time(args[1]);
|
||||||
std::string unit = RemoveUnit(tmp_time);
|
std::string const unit = RemoveUnit(tmp_time);
|
||||||
converted_time = StringTo<time::ns>(tmp_time, unit);
|
converted_time = StringTo<time::ns>(tmp_time, unit);
|
||||||
} else {
|
} else {
|
||||||
converted_time = StringTo<time::ns>(args[1], args[2]);
|
converted_time = StringTo<time::ns>(args[1], args[2]);
|
||||||
@@ -1205,7 +1205,7 @@ std::string Caller::rx_dbitlist(int action) {
|
|||||||
}
|
}
|
||||||
// 'none' option already covered as t is empty by default
|
// 'none' option already covered as t is empty by default
|
||||||
else if (args[0] != "none") {
|
else if (args[0] != "none") {
|
||||||
unsigned int ntrim = args.size();
|
unsigned int const ntrim = args.size();
|
||||||
t.resize(ntrim);
|
t.resize(ntrim);
|
||||||
for (unsigned int i = 0; i < ntrim; ++i) {
|
for (unsigned int i = 0; i < ntrim; ++i) {
|
||||||
t[i] = StringTo<int>(args[i]);
|
t[i] = StringTo<int>(args[i]);
|
||||||
@@ -1421,7 +1421,7 @@ std::string Caller::sleep(int action) {
|
|||||||
try {
|
try {
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
std::string tmp_time(args[0]);
|
std::string tmp_time(args[0]);
|
||||||
std::string unit = RemoveUnit(tmp_time);
|
std::string const unit = RemoveUnit(tmp_time);
|
||||||
converted_time = StringTo<time::ns>(tmp_time, unit);
|
converted_time = StringTo<time::ns>(tmp_time, unit);
|
||||||
} else {
|
} else {
|
||||||
converted_time = StringTo<time::ns>(args[0], args[1]);
|
converted_time = StringTo<time::ns>(args[0], args[1]);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ int main(int argc, char *argv[]) {
|
|||||||
try {
|
try {
|
||||||
if (action == -1) {
|
if (action == -1) {
|
||||||
action = inferAction.infer(parser);
|
action = inferAction.infer(parser);
|
||||||
std::string actionString =
|
std::string const actionString =
|
||||||
(action == slsDetectorDefs::GET_ACTION) ? "GET" : "PUT";
|
(action == slsDetectorDefs::GET_ACTION) ? "GET" : "PUT";
|
||||||
std::cout << "inferred action: " << actionString << std::endl;
|
std::cout << "inferred action: " << actionString << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ Detector &Detector::operator=(Detector &&other) noexcept = default;
|
|||||||
// Configuration
|
// Configuration
|
||||||
|
|
||||||
void Detector::loadConfig(const std::string &fname) {
|
void Detector::loadConfig(const std::string &fname) {
|
||||||
int shm_id = getShmId();
|
const int shm_id = getShmId();
|
||||||
freeSharedMemory(shm_id);
|
freeSharedMemory(shm_id);
|
||||||
pimpl = make_unique<DetectorImpl>(shm_id);
|
pimpl = make_unique<DetectorImpl>(shm_id);
|
||||||
LOG(logINFO) << "Loading configuration file: " << fname;
|
LOG(logINFO) << "Loading configuration file: " << fname;
|
||||||
@@ -205,7 +205,7 @@ int Detector::getShmId() const { return pimpl->getDetectorIndex(); }
|
|||||||
std::string Detector::getPackageVersion() const { return SLS_DET_VERSION; }
|
std::string Detector::getPackageVersion() const { return SLS_DET_VERSION; }
|
||||||
|
|
||||||
std::string Detector::getClientVersion() const {
|
std::string Detector::getClientVersion() const {
|
||||||
Version v(APILIB);
|
const Version v(APILIB);
|
||||||
return v.concise();
|
return v.concise();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ defs::xy Detector::getPortPerModuleGeometry() const {
|
|||||||
|
|
||||||
Result<defs::xy> Detector::getPortSize(Positions pos) const {
|
Result<defs::xy> Detector::getPortSize(Positions pos) const {
|
||||||
Result<defs::xy> res = pimpl->Parallel(&Module::getNumberOfChannels, pos);
|
Result<defs::xy> res = pimpl->Parallel(&Module::getNumberOfChannels, pos);
|
||||||
defs::xy portGeometry = getPortPerModuleGeometry();
|
const defs::xy portGeometry = getPortPerModuleGeometry();
|
||||||
if ((portGeometry.x != 1 && portGeometry.x != 2) ||
|
if ((portGeometry.x != 1 && portGeometry.x != 2) ||
|
||||||
(portGeometry.y != 1 && portGeometry.y != 2)) {
|
(portGeometry.y != 1 && portGeometry.y != 2)) {
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
@@ -346,9 +346,9 @@ Detector::getAllThresholdEnergy(Positions pos) const {
|
|||||||
void Detector::setThresholdEnergy(int threshold_ev,
|
void Detector::setThresholdEnergy(int threshold_ev,
|
||||||
defs::detectorSettings settings,
|
defs::detectorSettings settings,
|
||||||
bool trimbits, Positions pos) {
|
bool trimbits, Positions pos) {
|
||||||
defs::detectorType type = getDetectorType().squash();
|
const defs::detectorType type = getDetectorType().squash();
|
||||||
if (type == defs::MYTHEN3) {
|
if (type == defs::MYTHEN3) {
|
||||||
std::array<int, 3> energy = {threshold_ev, threshold_ev, threshold_ev};
|
const std::array<int, 3> energy = {threshold_ev, threshold_ev, threshold_ev};
|
||||||
setThresholdEnergy(energy, settings, trimbits, pos);
|
setThresholdEnergy(energy, settings, trimbits, pos);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -753,7 +753,6 @@ void Detector::setImageTestMode(int value, Positions pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<defs::dacIndex> Detector::getTemperatureList() const {
|
std::vector<defs::dacIndex> Detector::getTemperatureList() const {
|
||||||
std::vector<defs::dacIndex> retval;
|
|
||||||
switch (getDetectorType().squash()) {
|
switch (getDetectorType().squash()) {
|
||||||
case defs::CHIPTESTBOARD:
|
case defs::CHIPTESTBOARD:
|
||||||
return std::vector<defs::dacIndex>{defs::SLOW_ADC_TEMP};
|
return std::vector<defs::dacIndex>{defs::SLOW_ADC_TEMP};
|
||||||
@@ -1096,9 +1095,9 @@ void Detector::setNumberofUDPInterfaces_(int n, Positions pos) {
|
|||||||
if (!size()) {
|
if (!size()) {
|
||||||
throw RuntimeError("No modules added.");
|
throw RuntimeError("No modules added.");
|
||||||
}
|
}
|
||||||
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
const bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
||||||
uint16_t clientStartingPort = getClientZmqPort({0}).squash(0);
|
const uint16_t clientStartingPort = getClientZmqPort({0}).squash(0);
|
||||||
bool useReceiver = getUseReceiverFlag().squash(false);
|
const bool useReceiver = getUseReceiverFlag().squash(false);
|
||||||
bool previouslyReceiverStreaming = false;
|
bool previouslyReceiverStreaming = false;
|
||||||
uint16_t rxStartingPort = 0;
|
uint16_t rxStartingPort = 0;
|
||||||
if (useReceiver) {
|
if (useReceiver) {
|
||||||
@@ -1564,7 +1563,7 @@ Result<uint16_t> Detector::getRxZmqPort(Positions pos) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setRxZmqPort(uint16_t port, int module_id) {
|
void Detector::setRxZmqPort(uint16_t port, int module_id) {
|
||||||
bool previouslyReceiverStreaming =
|
const bool previouslyReceiverStreaming =
|
||||||
getRxZmqDataStream(std::vector<int>{module_id}).squash(false);
|
getRxZmqDataStream(std::vector<int>{module_id}).squash(false);
|
||||||
if (module_id == -1) {
|
if (module_id == -1) {
|
||||||
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
||||||
@@ -1587,7 +1586,7 @@ Result<uint16_t> Detector::getClientZmqPort(Positions pos) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setClientZmqPort(uint16_t port, int module_id) {
|
void Detector::setClientZmqPort(uint16_t port, int module_id) {
|
||||||
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
const bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
||||||
if (module_id == -1) {
|
if (module_id == -1) {
|
||||||
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
@@ -1609,7 +1608,7 @@ Result<IpAddr> Detector::getClientZmqIp(Positions pos) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setClientZmqIp(const IpAddr ip, Positions pos) {
|
void Detector::setClientZmqIp(const IpAddr ip, Positions pos) {
|
||||||
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
const bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
||||||
pimpl->Parallel(&Module::setClientStreamingIP, pos, ip);
|
pimpl->Parallel(&Module::setClientStreamingIP, pos, ip);
|
||||||
if (previouslyClientStreaming) {
|
if (previouslyClientStreaming) {
|
||||||
pimpl->setDataStreamingToClient(false);
|
pimpl->setDataStreamingToClient(false);
|
||||||
@@ -1628,7 +1627,7 @@ Result<int> Detector::getRxZmqHwm(Positions pos) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setRxZmqHwm(const int limit) {
|
void Detector::setRxZmqHwm(const int limit) {
|
||||||
bool previouslyReceiverStreaming = getRxZmqDataStream().squash(false);
|
const bool previouslyReceiverStreaming = getRxZmqDataStream().squash(false);
|
||||||
pimpl->Parallel(&Module::setReceiverStreamingHwm, {}, limit);
|
pimpl->Parallel(&Module::setReceiverStreamingHwm, {}, limit);
|
||||||
if (previouslyReceiverStreaming) {
|
if (previouslyReceiverStreaming) {
|
||||||
setRxZmqDataStream(false, {});
|
setRxZmqDataStream(false, {});
|
||||||
@@ -1994,15 +1993,15 @@ Result<defs::streamingInterface> Detector::getVetoStream(Positions pos) const {
|
|||||||
void Detector::setVetoStream(defs::streamingInterface interface,
|
void Detector::setVetoStream(defs::streamingInterface interface,
|
||||||
Positions pos) {
|
Positions pos) {
|
||||||
// 3gbe
|
// 3gbe
|
||||||
bool LOW_LATENCY_LINK =
|
const bool LOW_LATENCY_LINK =
|
||||||
((interface & defs::streamingInterface::LOW_LATENCY_LINK) ==
|
((interface & defs::streamingInterface::LOW_LATENCY_LINK) ==
|
||||||
defs::streamingInterface::LOW_LATENCY_LINK);
|
defs::streamingInterface::LOW_LATENCY_LINK);
|
||||||
pimpl->Parallel(&Module::setVetoStream, pos, LOW_LATENCY_LINK);
|
pimpl->Parallel(&Module::setVetoStream, pos, LOW_LATENCY_LINK);
|
||||||
|
|
||||||
// 10gbe (debugging interface) opens 2nd udp interface in receiver
|
// 10gbe (debugging interface) opens 2nd udp interface in receiver
|
||||||
int old_numinterfaces = getNumberofUDPInterfaces(pos).tsquash(
|
const int old_numinterfaces = getNumberofUDPInterfaces(pos).tsquash(
|
||||||
"retrieved inconsistent number of udp interfaces");
|
"retrieved inconsistent number of udp interfaces");
|
||||||
int numinterfaces =
|
const int numinterfaces =
|
||||||
(((interface & defs::streamingInterface::ETHERNET_10GB) ==
|
(((interface & defs::streamingInterface::ETHERNET_10GB) ==
|
||||||
defs::streamingInterface::ETHERNET_10GB)
|
defs::streamingInterface::ETHERNET_10GB)
|
||||||
? 2
|
? 2
|
||||||
@@ -2730,7 +2729,7 @@ void Detector::programFPGA(const std::string &fname,
|
|||||||
const bool forceDeleteNormalFile, Positions pos) {
|
const bool forceDeleteNormalFile, Positions pos) {
|
||||||
LOG(logINFO) << "Updating Firmware...";
|
LOG(logINFO) << "Updating Firmware...";
|
||||||
LOG(logINFO) << "Hardware Version: " << getHardwareVersion();
|
LOG(logINFO) << "Hardware Version: " << getHardwareVersion();
|
||||||
std::vector<char> buffer = pimpl->readProgrammingFile(fname);
|
const std::vector<char> buffer = pimpl->readProgrammingFile(fname);
|
||||||
pimpl->Parallel(&Module::programFPGA, pos, buffer, forceDeleteNormalFile);
|
pimpl->Parallel(&Module::programFPGA, pos, buffer, forceDeleteNormalFile);
|
||||||
rebootController(pos);
|
rebootController(pos);
|
||||||
}
|
}
|
||||||
@@ -2741,8 +2740,8 @@ void Detector::resetFPGA(Positions pos) {
|
|||||||
|
|
||||||
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
||||||
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
||||||
std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
|
const std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
|
||||||
std::string filename = getFileNameFromFilePath(fname);
|
const std::string filename = getFileNameFromFilePath(fname);
|
||||||
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
||||||
if (getDetectorType().squash() != defs::EIGER) {
|
if (getDetectorType().squash() != defs::EIGER) {
|
||||||
rebootController(pos);
|
rebootController(pos);
|
||||||
@@ -2751,7 +2750,7 @@ void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
|||||||
|
|
||||||
void Detector::updateKernel(const std::string &fname, Positions pos) {
|
void Detector::updateKernel(const std::string &fname, Positions pos) {
|
||||||
LOG(logINFO) << "Updating Kernel...";
|
LOG(logINFO) << "Updating Kernel...";
|
||||||
std::vector<char> buffer = readBinaryFile(fname, "Update Kernel");
|
const std::vector<char> buffer = readBinaryFile(fname, "Update Kernel");
|
||||||
pimpl->Parallel(&Module::updateKernel, pos, buffer);
|
pimpl->Parallel(&Module::updateKernel, pos, buffer);
|
||||||
rebootController(pos);
|
rebootController(pos);
|
||||||
}
|
}
|
||||||
@@ -2765,8 +2764,8 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
|
|||||||
Positions pos) {
|
Positions pos) {
|
||||||
LOG(logINFO) << "Updating Firmware and Detector Server (no tftp)...";
|
LOG(logINFO) << "Updating Firmware and Detector Server (no tftp)...";
|
||||||
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
||||||
std::vector<char> buffer = readBinaryFile(sname, "Update Detector Server");
|
const std::vector<char> buffer = readBinaryFile(sname, "Update Detector Server");
|
||||||
std::string filename = getFileNameFromFilePath(sname);
|
const std::string filename = getFileNameFromFilePath(sname);
|
||||||
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
||||||
programFPGA(fname, false, pos);
|
programFPGA(fname, false, pos);
|
||||||
}
|
}
|
||||||
@@ -2882,7 +2881,7 @@ Result<ns> Detector::getMeasurementTime(Positions pos) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint16_t> Detector::getValidPortNumbers(uint16_t start_port) {
|
std::vector<uint16_t> Detector::getValidPortNumbers(uint16_t start_port) {
|
||||||
int num_sockets_per_detector = getNumberofUDPInterfaces({}).tsquash(
|
const int num_sockets_per_detector = getNumberofUDPInterfaces({}).tsquash(
|
||||||
"Number of UDP Interfaces is not consistent among modules");
|
"Number of UDP Interfaces is not consistent among modules");
|
||||||
|
|
||||||
validatePortRange(start_port, size() * num_sockets_per_detector);
|
validatePortRange(start_port, size() * num_sockets_per_detector);
|
||||||
@@ -2890,7 +2889,7 @@ std::vector<uint16_t> Detector::getValidPortNumbers(uint16_t start_port) {
|
|||||||
std::vector<uint16_t> res;
|
std::vector<uint16_t> res;
|
||||||
res.reserve(size());
|
res.reserve(size());
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
uint16_t port = start_port + (idet * num_sockets_per_detector);
|
const uint16_t port = start_port + (idet * num_sockets_per_detector);
|
||||||
res.push_back(port);
|
res.push_back(port);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -198,11 +198,11 @@ void DetectorImpl::setHostname(const std::vector<std::string> &name) {
|
|||||||
void DetectorImpl::addModule(const std::string &name) {
|
void DetectorImpl::addModule(const std::string &name) {
|
||||||
LOG(logINFO) << "Adding module " << name;
|
LOG(logINFO) << "Adding module " << name;
|
||||||
auto host = verifyUniqueDetHost(name);
|
auto host = verifyUniqueDetHost(name);
|
||||||
std::string hostname = host.first;
|
std::string const hostname = host.first;
|
||||||
uint16_t port = host.second;
|
uint16_t const port = host.second;
|
||||||
|
|
||||||
// get type by connecting
|
// get type by connecting
|
||||||
detectorType type = Module::getTypeFromDetector(hostname, port);
|
detectorType const type = Module::getTypeFromDetector(hostname, port);
|
||||||
|
|
||||||
// gotthard2 cannot have more than 2 modules (50um=1, 25um=2
|
// gotthard2 cannot have more than 2 modules (50um=1, 25um=2
|
||||||
if (type == GOTTHARD2 && modules.size() > 2) {
|
if (type == GOTTHARD2 && modules.size() > 2) {
|
||||||
@@ -227,7 +227,7 @@ void DetectorImpl::addModule(const std::string &name) {
|
|||||||
modules[pos]->updateNumberofUDPInterfaces();
|
modules[pos]->updateNumberofUDPInterfaces();
|
||||||
|
|
||||||
// update zmq port in case numudpinterfaces changed
|
// update zmq port in case numudpinterfaces changed
|
||||||
int numInterfaces = modules[pos]->getNumberofUDPInterfacesFromShm();
|
int const numInterfaces = modules[pos]->getNumberofUDPInterfacesFromShm();
|
||||||
modules[pos]->setClientStreamingPort(DEFAULT_ZMQ_CL_PORTNO +
|
modules[pos]->setClientStreamingPort(DEFAULT_ZMQ_CL_PORTNO +
|
||||||
pos * numInterfaces);
|
pos * numInterfaces);
|
||||||
}
|
}
|
||||||
@@ -245,7 +245,7 @@ void DetectorImpl::updateDetectorSize() {
|
|||||||
int nModx = 0, nMody = 0;
|
int nModx = 0, nMody = 0;
|
||||||
// 1d, add modules along x axis
|
// 1d, add modules along x axis
|
||||||
if (modSize.y == 1) {
|
if (modSize.y == 1) {
|
||||||
int detSizeX = shm()->numberOfChannels.x;
|
int const detSizeX = shm()->numberOfChannels.x;
|
||||||
int maxChanX = modSize.x * size();
|
int maxChanX = modSize.x * size();
|
||||||
// user given detsizex used only within max value
|
// user given detsizex used only within max value
|
||||||
if (detSizeX > 1 && detSizeX <= maxChanX) {
|
if (detSizeX > 1 && detSizeX <= maxChanX) {
|
||||||
@@ -271,7 +271,7 @@ void DetectorImpl::updateDetectorSize() {
|
|||||||
}
|
}
|
||||||
// 2d, add modules along y axis (due to eiger top/bottom)
|
// 2d, add modules along y axis (due to eiger top/bottom)
|
||||||
else {
|
else {
|
||||||
int detSizeY = shm()->numberOfChannels.y;
|
int const detSizeY = shm()->numberOfChannels.y;
|
||||||
int maxChanY = modSize.y * size();
|
int maxChanY = modSize.y * size();
|
||||||
// user given detsizey used only within max value
|
// user given detsizey used only within max value
|
||||||
if (detSizeY > 1 && detSizeY <= maxChanY) {
|
if (detSizeY > 1 && detSizeY <= maxChanY) {
|
||||||
@@ -467,7 +467,7 @@ void DetectorImpl::createReceivingDataSockets() {
|
|||||||
if (shm()->detType == GOTTHARD2) {
|
if (shm()->detType == GOTTHARD2) {
|
||||||
numUDPInterfaces = 1;
|
numUDPInterfaces = 1;
|
||||||
}
|
}
|
||||||
size_t numSockets = modules.size() * numUDPInterfaces;
|
size_t const numSockets = modules.size() * numUDPInterfaces;
|
||||||
|
|
||||||
for (size_t iSocket = 0; iSocket < numSockets; ++iSocket) {
|
for (size_t iSocket = 0; iSocket < numSockets; ++iSocket) {
|
||||||
uint32_t portnum =
|
uint32_t portnum =
|
||||||
@@ -481,7 +481,7 @@ void DetectorImpl::createReceivingDataSockets() {
|
|||||||
.c_str(),
|
.c_str(),
|
||||||
portnum));
|
portnum));
|
||||||
// set high water mark
|
// set high water mark
|
||||||
int hwm = shm()->zmqHwm;
|
int const hwm = shm()->zmqHwm;
|
||||||
if (hwm >= 0) {
|
if (hwm >= 0) {
|
||||||
zmqSocket[iSocket]->SetReceiveHighWaterMark(hwm);
|
zmqSocket[iSocket]->SetReceiveHighWaterMark(hwm);
|
||||||
// need not reconnect. cannot be connected (detector idle)
|
// need not reconnect. cannot be connected (detector idle)
|
||||||
@@ -504,7 +504,7 @@ void DetectorImpl::createReceivingDataSockets() {
|
|||||||
|
|
||||||
void DetectorImpl::readFrameFromReceiver() {
|
void DetectorImpl::readFrameFromReceiver() {
|
||||||
|
|
||||||
bool gapPixels = shm()->gapPixels;
|
bool const gapPixels = shm()->gapPixels;
|
||||||
LOG(logDEBUG) << "Gap pixels: " << gapPixels;
|
LOG(logDEBUG) << "Gap pixels: " << gapPixels;
|
||||||
int nX = 0;
|
int nX = 0;
|
||||||
int nY = 0;
|
int nY = 0;
|
||||||
@@ -644,10 +644,10 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
|
|
||||||
// creating multi image
|
// creating multi image
|
||||||
{
|
{
|
||||||
uint32_t xoffset = coordX * nPixelsX * bytesPerPixel;
|
uint32_t const xoffset = coordX * nPixelsX * bytesPerPixel;
|
||||||
uint32_t yoffset = coordY * nPixelsY;
|
uint32_t const yoffset = coordY * nPixelsY;
|
||||||
uint32_t singledetrowoffset = nPixelsX * bytesPerPixel;
|
uint32_t singledetrowoffset = nPixelsX * bytesPerPixel;
|
||||||
uint32_t rowoffset = nX * singledetrowoffset;
|
uint32_t const rowoffset = nX * singledetrowoffset;
|
||||||
if (shm()->detType == CHIPTESTBOARD ||
|
if (shm()->detType == CHIPTESTBOARD ||
|
||||||
shm()->detType == defs::XILINX_CHIPTESTBOARD) {
|
shm()->detType == defs::XILINX_CHIPTESTBOARD) {
|
||||||
singledetrowoffset = size;
|
singledetrowoffset = size;
|
||||||
@@ -694,7 +694,7 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
int nDetActualPixelsY = nDetPixelsY;
|
int nDetActualPixelsY = nDetPixelsY;
|
||||||
|
|
||||||
if (gapPixels) {
|
if (gapPixels) {
|
||||||
int n = insertGapPixels(multiframe.get(), multigappixels,
|
int const n = insertGapPixels(multiframe.get(), multigappixels,
|
||||||
quadEnable, dynamicRange,
|
quadEnable, dynamicRange,
|
||||||
nDetActualPixelsX, nDetActualPixelsY);
|
nDetActualPixelsX, nDetActualPixelsY);
|
||||||
callbackImage = multigappixels;
|
callbackImage = multigappixels;
|
||||||
@@ -742,38 +742,38 @@ int DetectorImpl::insertGapPixels(char *image, char *&gpImage, bool quadEnable,
|
|||||||
<< "\n\t quadEnable: " << quadEnable << "\n\t dr: " << dr;
|
<< "\n\t quadEnable: " << quadEnable << "\n\t dr: " << dr;
|
||||||
|
|
||||||
// inter module gap pixels
|
// inter module gap pixels
|
||||||
int modGapPixelsx = 8;
|
int const modGapPixelsx = 8;
|
||||||
int modGapPixelsy = 36;
|
int const modGapPixelsy = 36;
|
||||||
// inter chip gap pixels
|
// inter chip gap pixels
|
||||||
int chipGapPixelsx = 2;
|
int const chipGapPixelsx = 2;
|
||||||
int chipGapPixelsy = 2;
|
int const chipGapPixelsy = 2;
|
||||||
// number of pixels in a chip
|
// number of pixels in a chip
|
||||||
int nChipPixelsx = 256;
|
int const nChipPixelsx = 256;
|
||||||
int nChipPixelsy = 256;
|
int const nChipPixelsy = 256;
|
||||||
// 1 module
|
// 1 module
|
||||||
// number of chips in a module
|
// number of chips in a module
|
||||||
int nMod1Chipx = 4;
|
int nMod1Chipx = 4;
|
||||||
int nMod1Chipy = 2;
|
int const nMod1Chipy = 2;
|
||||||
if (quadEnable) {
|
if (quadEnable) {
|
||||||
nMod1Chipx = 2;
|
nMod1Chipx = 2;
|
||||||
}
|
}
|
||||||
// number of pixels in a module
|
// number of pixels in a module
|
||||||
int nMod1Pixelsx = nChipPixelsx * nMod1Chipx;
|
int const nMod1Pixelsx = nChipPixelsx * nMod1Chipx;
|
||||||
int nMod1Pixelsy = nChipPixelsy * nMod1Chipy;
|
int const nMod1Pixelsy = nChipPixelsy * nMod1Chipy;
|
||||||
// number of gap pixels in a module
|
// number of gap pixels in a module
|
||||||
int nMod1GapPixelsx = (nMod1Chipx - 1) * chipGapPixelsx;
|
int const nMod1GapPixelsx = (nMod1Chipx - 1) * chipGapPixelsx;
|
||||||
int nMod1GapPixelsy = (nMod1Chipy - 1) * chipGapPixelsy;
|
int const nMod1GapPixelsy = (nMod1Chipy - 1) * chipGapPixelsy;
|
||||||
// total number of modules
|
// total number of modules
|
||||||
int nModx = nPixelsx / nMod1Pixelsx;
|
int const nModx = nPixelsx / nMod1Pixelsx;
|
||||||
int nMody = nPixelsy / nMod1Pixelsy;
|
int const nMody = nPixelsy / nMod1Pixelsy;
|
||||||
|
|
||||||
// check if not full modules
|
// check if not full modules
|
||||||
// (setting gap pixels and then adding half module or disabling quad)
|
// (setting gap pixels and then adding half module or disabling quad)
|
||||||
if (nPixelsy / nMod1Pixelsy == 0) {
|
if (nPixelsy / nMod1Pixelsy == 0) {
|
||||||
LOG(logERROR) << "Gap pixels can only be enabled with full modules. "
|
LOG(logERROR) << "Gap pixels can only be enabled with full modules. "
|
||||||
"Sending dummy data without gap pixels.\n";
|
"Sending dummy data without gap pixels.\n";
|
||||||
double bytesPerPixel = (double)dr / 8.00;
|
double const bytesPerPixel = (double)dr / 8.00;
|
||||||
int imagesize = nPixelsy * nPixelsx * bytesPerPixel;
|
int const imagesize = nPixelsy * nPixelsx * bytesPerPixel;
|
||||||
if (gpImage == nullptr) {
|
if (gpImage == nullptr) {
|
||||||
gpImage = new char[imagesize];
|
gpImage = new char[imagesize];
|
||||||
}
|
}
|
||||||
@@ -782,28 +782,28 @@ int DetectorImpl::insertGapPixels(char *image, char *&gpImage, bool quadEnable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// total number of pixels
|
// total number of pixels
|
||||||
int nTotx =
|
int const nTotx =
|
||||||
nPixelsx + (nMod1GapPixelsx * nModx) + (modGapPixelsx * (nModx - 1));
|
nPixelsx + (nMod1GapPixelsx * nModx) + (modGapPixelsx * (nModx - 1));
|
||||||
int nToty =
|
int const nToty =
|
||||||
nPixelsy + (nMod1GapPixelsy * nMody) + (modGapPixelsy * (nMody - 1));
|
nPixelsy + (nMod1GapPixelsy * nMody) + (modGapPixelsy * (nMody - 1));
|
||||||
// total number of chips
|
// total number of chips
|
||||||
int nChipx = nPixelsx / nChipPixelsx;
|
int const nChipx = nPixelsx / nChipPixelsx;
|
||||||
int nChipy = nPixelsy / nChipPixelsy;
|
int const nChipy = nPixelsy / nChipPixelsy;
|
||||||
|
|
||||||
double bytesPerPixel = (double)dr / 8.00;
|
double const bytesPerPixel = (double)dr / 8.00;
|
||||||
int imagesize = nTotx * nToty * bytesPerPixel;
|
int const imagesize = nTotx * nToty * bytesPerPixel;
|
||||||
|
|
||||||
int nChipBytesx = nChipPixelsx * bytesPerPixel; // 1 chip bytes in x
|
int const nChipBytesx = nChipPixelsx * bytesPerPixel; // 1 chip bytes in x
|
||||||
int nChipGapBytesx = chipGapPixelsx * bytesPerPixel; // 2 pixel bytes
|
int const nChipGapBytesx = chipGapPixelsx * bytesPerPixel; // 2 pixel bytes
|
||||||
int nModGapBytesx = modGapPixelsx * bytesPerPixel; // 8 pixel bytes
|
int const nModGapBytesx = modGapPixelsx * bytesPerPixel; // 8 pixel bytes
|
||||||
int nChipBytesy = nChipPixelsy * nTotx * bytesPerPixel; // 1 chip bytes in y
|
int const nChipBytesy = nChipPixelsy * nTotx * bytesPerPixel; // 1 chip bytes in y
|
||||||
int nChipGapBytesy = chipGapPixelsy * nTotx * bytesPerPixel; // 2 lines
|
int const nChipGapBytesy = chipGapPixelsy * nTotx * bytesPerPixel; // 2 lines
|
||||||
int nModGapBytesy = modGapPixelsy * nTotx *
|
int const nModGapBytesy = modGapPixelsy * nTotx *
|
||||||
bytesPerPixel; // 36 lines
|
bytesPerPixel; // 36 lines
|
||||||
// 4 bit mode, its 1 byte (because for 4
|
// 4 bit mode, its 1 byte (because for 4
|
||||||
// bit mode, we handle 1 byte at a time)
|
// bit mode, we handle 1 byte at a time)
|
||||||
int pixel1 = (int)(ceil(bytesPerPixel));
|
int const pixel1 = (int)(ceil(bytesPerPixel));
|
||||||
int row1Bytes = nTotx * bytesPerPixel;
|
int const row1Bytes = nTotx * bytesPerPixel;
|
||||||
int nMod1TotPixelsx = nMod1Pixelsx + nMod1GapPixelsx;
|
int nMod1TotPixelsx = nMod1Pixelsx + nMod1GapPixelsx;
|
||||||
if (dr == 4) {
|
if (dr == 4) {
|
||||||
nMod1TotPixelsx /= 2;
|
nMod1TotPixelsx /= 2;
|
||||||
@@ -811,7 +811,7 @@ int DetectorImpl::insertGapPixels(char *image, char *&gpImage, bool quadEnable,
|
|||||||
// eiger requires inter chip gap pixels are halved
|
// eiger requires inter chip gap pixels are halved
|
||||||
// jungfrau/moench prefers same inter chip gap pixels as the boundary pixels
|
// jungfrau/moench prefers same inter chip gap pixels as the boundary pixels
|
||||||
int divisionValue = 2;
|
int divisionValue = 2;
|
||||||
slsDetectorDefs::detectorType detType = shm()->detType;
|
slsDetectorDefs::detectorType const detType = shm()->detType;
|
||||||
if (detType == JUNGFRAU || detType == MOENCH) {
|
if (detType == JUNGFRAU || detType == MOENCH) {
|
||||||
divisionValue = 1;
|
divisionValue = 1;
|
||||||
}
|
}
|
||||||
@@ -1053,7 +1053,7 @@ int DetectorImpl::getClientStreamingHwm() const {
|
|||||||
for (auto &it : zmqSocket) {
|
for (auto &it : zmqSocket) {
|
||||||
result.push_back(it->GetReceiveHighWaterMark());
|
result.push_back(it->GetReceiveHighWaterMark());
|
||||||
}
|
}
|
||||||
int res = result.tsquash("Inconsistent zmq receive hwm values");
|
int const res = result.tsquash("Inconsistent zmq receive hwm values");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1110,7 +1110,7 @@ int DetectorImpl::acquire() {
|
|||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
|
|
||||||
bool receiver = Parallel(&Module::getUseReceiverFlag, {}).squash(false);
|
bool const receiver = Parallel(&Module::getUseReceiverFlag, {}).squash(false);
|
||||||
|
|
||||||
if (dataReady == nullptr) {
|
if (dataReady == nullptr) {
|
||||||
setJoinThreadFlag(false);
|
setJoinThreadFlag(false);
|
||||||
@@ -1172,7 +1172,7 @@ int DetectorImpl::acquire() {
|
|||||||
|
|
||||||
// progress
|
// progress
|
||||||
auto a = Parallel(&Module::getReceiverProgress, {});
|
auto a = Parallel(&Module::getReceiverProgress, {});
|
||||||
double progress = (*std::max_element(a.begin(), a.end()));
|
double const progress = (*std::max_element(a.begin(), a.end()));
|
||||||
|
|
||||||
// callback
|
// callback
|
||||||
acquisition_finished(progress, static_cast<int>(status),
|
acquisition_finished(progress, static_cast<int>(status),
|
||||||
@@ -1340,7 +1340,7 @@ void DetectorImpl::processData(bool receiver) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get and print progress
|
// get and print progress
|
||||||
double temp =
|
double const temp =
|
||||||
(double)Parallel(&Module::getReceiverProgress, {0})
|
(double)Parallel(&Module::getReceiverProgress, {0})
|
||||||
.squash();
|
.squash();
|
||||||
if (temp != progress) {
|
if (temp != progress) {
|
||||||
@@ -1365,12 +1365,12 @@ void DetectorImpl::processData(bool receiver) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DetectorImpl::getJoinThreadFlag() const {
|
bool DetectorImpl::getJoinThreadFlag() const {
|
||||||
std::lock_guard<std::mutex> lock(mp);
|
std::lock_guard<std::mutex> const lock(mp);
|
||||||
return jointhread;
|
return jointhread;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::setJoinThreadFlag(bool value) {
|
void DetectorImpl::setJoinThreadFlag(bool value) {
|
||||||
std::lock_guard<std::mutex> lock(mp);
|
std::lock_guard<std::mutex> const lock(mp);
|
||||||
jointhread = value;
|
jointhread = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1430,11 +1430,11 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get srcSize to print progress
|
// get srcSize to print progress
|
||||||
ssize_t srcSize = getFileSize(src, "Program FPGA");
|
ssize_t const srcSize = getFileSize(src, "Program FPGA");
|
||||||
|
|
||||||
// create temp destination file
|
// create temp destination file
|
||||||
char destfname[] = "/tmp/SLS_DET_MCB.XXXXXX";
|
char destfname[] = "/tmp/SLS_DET_MCB.XXXXXX";
|
||||||
int dst = mkstemp(destfname); // create temporary file and open it in r/w
|
int const dst = mkstemp(destfname); // create temporary file and open it in r/w
|
||||||
if (dst == -1) {
|
if (dst == -1) {
|
||||||
fclose(src);
|
fclose(src);
|
||||||
throw RuntimeError(std::string("Could not create destination file "
|
throw RuntimeError(std::string("Could not create destination file "
|
||||||
@@ -1466,7 +1466,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
|||||||
int oldProgress = 0;
|
int oldProgress = 0;
|
||||||
while (!feof(src)) {
|
while (!feof(src)) {
|
||||||
// print progress
|
// print progress
|
||||||
int progress = (int)(((double)(dstFilePos) / srcSize) * 100);
|
int const progress = (int)(((double)(dstFilePos) / srcSize) * 100);
|
||||||
if (oldProgress != progress) {
|
if (oldProgress != progress) {
|
||||||
printf("%d%%\r", progress);
|
printf("%d%%\r", progress);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@@ -1477,7 +1477,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// read source
|
// read source
|
||||||
int s = fgetc(src);
|
int const s = fgetc(src);
|
||||||
if (s < 0) {
|
if (s < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1547,13 +1547,13 @@ DetectorImpl::verifyUniqueDetHost(const std::string &name) {
|
|||||||
// extract port
|
// extract port
|
||||||
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
||||||
auto res = ParseHostPort(name);
|
auto res = ParseHostPort(name);
|
||||||
std::string hostname = res.first;
|
std::string const hostname = res.first;
|
||||||
uint16_t port = res.second;
|
uint16_t port = res.second;
|
||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
port = DEFAULT_TCP_CNTRL_PORTNO;
|
port = DEFAULT_TCP_CNTRL_PORTNO;
|
||||||
}
|
}
|
||||||
|
|
||||||
int detSize = size();
|
int const detSize = size();
|
||||||
// mod not yet added
|
// mod not yet added
|
||||||
std::vector<std::pair<std::string, uint16_t>> hosts(detSize + 1);
|
std::vector<std::pair<std::string, uint16_t>> hosts(detSize + 1);
|
||||||
hosts[detSize].first = hostname;
|
hosts[detSize].first = hostname;
|
||||||
@@ -1573,8 +1573,8 @@ DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
|||||||
// extract port
|
// extract port
|
||||||
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
||||||
auto res = ParseHostPort(name);
|
auto res = ParseHostPort(name);
|
||||||
std::string hostname = res.first;
|
std::string const hostname = res.first;
|
||||||
uint16_t port = res.second;
|
uint16_t const port = res.second;
|
||||||
|
|
||||||
// hostname and port for given positions
|
// hostname and port for given positions
|
||||||
if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) {
|
if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) {
|
||||||
@@ -1669,7 +1669,7 @@ void DetectorImpl::validateROIs(const std::vector<defs::ROI> &rois) {
|
|||||||
if (roi.noRoi()) {
|
if (roi.noRoi()) {
|
||||||
throw RuntimeError("Invalid Roi of size 0. Roi: " + ToString(roi));
|
throw RuntimeError("Invalid Roi of size 0. Roi: " + ToString(roi));
|
||||||
}
|
}
|
||||||
bool is2D = (modules[0]->getNumberOfChannels().y > 1 ? true : false);
|
bool const is2D = (modules[0]->getNumberOfChannels().y > 1 ? true : false);
|
||||||
if (roi.completeRoi()) {
|
if (roi.completeRoi()) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Did you mean the clear roi command (API: clearRxROI, cmd: "
|
oss << "Did you mean the clear roi command (API: clearRxROI, cmd: "
|
||||||
@@ -1730,9 +1730,9 @@ defs::xy DetectorImpl::getPortGeometry() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defs::xy DetectorImpl::calculatePosition(int moduleIndex) const {
|
defs::xy DetectorImpl::calculatePosition(int moduleIndex) const {
|
||||||
int maxYMods = shm()->numberOfModules.y;
|
int const maxYMods = shm()->numberOfModules.y;
|
||||||
int y = (moduleIndex % maxYMods);
|
int const y = (moduleIndex % maxYMods);
|
||||||
int x = (moduleIndex / maxYMods);
|
int const x = (moduleIndex / maxYMods);
|
||||||
return defs::xy{x, y};
|
return defs::xy{x, y};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1771,13 +1771,13 @@ void DetectorImpl::convertGlobalRoiToPortLevel(
|
|||||||
defs::ROI portRoi = moduleRoi;
|
defs::ROI portRoi = moduleRoi;
|
||||||
// Recalculate port ROI boundaries (split vertically or horizontally)
|
// Recalculate port ROI boundaries (split vertically or horizontally)
|
||||||
if (portGeometry.x == 2) {
|
if (portGeometry.x == 2) {
|
||||||
int midX = (moduleRoi.xmin + moduleRoi.xmax) / 2;
|
int const midX = (moduleRoi.xmin + moduleRoi.xmax) / 2;
|
||||||
if (port == 0)
|
if (port == 0)
|
||||||
portRoi.xmax = midX;
|
portRoi.xmax = midX;
|
||||||
else
|
else
|
||||||
portRoi.xmin = midX + 1;
|
portRoi.xmin = midX + 1;
|
||||||
} else if (portGeometry.y == 2) {
|
} else if (portGeometry.y == 2) {
|
||||||
int midY = (moduleRoi.ymin + moduleRoi.ymax) / 2;
|
int const midY = (moduleRoi.ymin + moduleRoi.ymax) / 2;
|
||||||
if (port == 0)
|
if (port == 0)
|
||||||
portRoi.ymax = midY;
|
portRoi.ymax = midY;
|
||||||
else
|
else
|
||||||
@@ -1823,7 +1823,7 @@ void DetectorImpl::setRxROI(const std::vector<defs::ROI> &args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validateROIs(args);
|
validateROIs(args);
|
||||||
int nPortsPerModule =
|
int const nPortsPerModule =
|
||||||
Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
||||||
.tsquash("Inconsistent number of udp ports set up per module");
|
.tsquash("Inconsistent number of udp ports set up per module");
|
||||||
|
|
||||||
@@ -1845,7 +1845,7 @@ void DetectorImpl::setRxROI(const std::vector<defs::ROI> &args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::clearRxROI() {
|
void DetectorImpl::clearRxROI() {
|
||||||
int nPortsPerModule =
|
int const nPortsPerModule =
|
||||||
Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
||||||
.tsquash("Inconsistent number of udp ports set up per module");
|
.tsquash("Inconsistent number of udp ports set up per module");
|
||||||
for (size_t iModule = 0; iModule < modules.size(); ++iModule) {
|
for (size_t iModule = 0; iModule < modules.size(); ++iModule) {
|
||||||
@@ -1890,7 +1890,7 @@ void DetectorImpl::getBadChannels(const std::string &fname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::setBadChannels(const std::string &fname, Positions pos) {
|
void DetectorImpl::setBadChannels(const std::string &fname, Positions pos) {
|
||||||
std::vector<int> list = sls::getChannelsFromFile(fname);
|
std::vector<int> const list = sls::getChannelsFromFile(fname);
|
||||||
if (list.empty()) {
|
if (list.empty()) {
|
||||||
throw RuntimeError("Bad channel file is empty.");
|
throw RuntimeError("Bad channel file is empty.");
|
||||||
}
|
}
|
||||||
@@ -1913,8 +1913,8 @@ void DetectorImpl::setBadChannels(const std::vector<int> list, Positions pos) {
|
|||||||
std::to_string(badchannel) +
|
std::to_string(badchannel) +
|
||||||
" out of bounds.");
|
" out of bounds.");
|
||||||
}
|
}
|
||||||
int ch = badchannel % nchan;
|
int const ch = badchannel % nchan;
|
||||||
size_t imod = badchannel / nchan;
|
size_t const imod = badchannel / nchan;
|
||||||
if (imod >= modules.size()) {
|
if (imod >= modules.size()) {
|
||||||
throw RuntimeError("Invalid bad channel list. " +
|
throw RuntimeError("Invalid bad channel list. " +
|
||||||
std::to_string(badchannel) +
|
std::to_string(badchannel) +
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
std::vector<std::future<RT>> futures;
|
std::vector<std::future<RT>> futures;
|
||||||
futures.reserve(positions.size());
|
futures.reserve(positions.size());
|
||||||
for (size_t i : positions) {
|
for (const size_t i : positions) {
|
||||||
if (i >= modules.size())
|
if (i >= modules.size())
|
||||||
throw RuntimeError("Module out of range");
|
throw RuntimeError("Module out of range");
|
||||||
futures.push_back(std::async(std::launch::async, somefunc,
|
futures.push_back(std::async(std::launch::async, somefunc,
|
||||||
@@ -118,7 +118,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
std::vector<std::future<RT>> futures;
|
std::vector<std::future<RT>> futures;
|
||||||
futures.reserve(positions.size());
|
futures.reserve(positions.size());
|
||||||
for (size_t i : positions) {
|
for (const size_t i : positions) {
|
||||||
if (i >= modules.size())
|
if (i >= modules.size())
|
||||||
throw RuntimeError("Module out of range");
|
throw RuntimeError("Module out of range");
|
||||||
futures.push_back(std::async(std::launch::async, somefunc,
|
futures.push_back(std::async(std::launch::async, somefunc,
|
||||||
@@ -145,7 +145,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
std::vector<std::future<void>> futures;
|
std::vector<std::future<void>> futures;
|
||||||
futures.reserve(positions.size());
|
futures.reserve(positions.size());
|
||||||
for (size_t i : positions) {
|
for (const size_t i : positions) {
|
||||||
if (i >= modules.size())
|
if (i >= modules.size())
|
||||||
throw RuntimeError("Module out of range");
|
throw RuntimeError("Module out of range");
|
||||||
futures.push_back(std::async(std::launch::async, somefunc,
|
futures.push_back(std::async(std::launch::async, somefunc,
|
||||||
@@ -170,7 +170,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
std::vector<std::future<void>> futures;
|
std::vector<std::future<void>> futures;
|
||||||
futures.reserve(positions.size());
|
futures.reserve(positions.size());
|
||||||
for (size_t i : positions) {
|
for (const size_t i : positions) {
|
||||||
if (i >= modules.size())
|
if (i >= modules.size())
|
||||||
throw RuntimeError("Module out of range");
|
throw RuntimeError("Module out of range");
|
||||||
futures.push_back(std::async(std::launch::async, somefunc,
|
futures.push_back(std::async(std::launch::async, somefunc,
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ std::string Module::getControlServerLongVersion() const {
|
|||||||
}
|
}
|
||||||
// throw with old server version (sends 8 bytes)
|
// throw with old server version (sends 8 bytes)
|
||||||
catch (RuntimeError &e) {
|
catch (RuntimeError &e) {
|
||||||
std::string emsg = std::string(e.what());
|
std::string const emsg = std::string(e.what());
|
||||||
if (emsg.find(F_GET_SERVER_VERSION) && emsg.find("8 bytes")) {
|
if (emsg.find(F_GET_SERVER_VERSION) && emsg.find("8 bytes")) {
|
||||||
throwDeprecatedServerVersion();
|
throwDeprecatedServerVersion();
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ std::string Module::getControlServerLongVersion() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::throwDeprecatedServerVersion() const {
|
void Module::throwDeprecatedServerVersion() const {
|
||||||
uint64_t res = sendToDetectorStop<int64_t>(F_GET_SERVER_VERSION);
|
uint64_t const res = sendToDetectorStop<int64_t>(F_GET_SERVER_VERSION);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "Detector Server (Control) version (0x" << std::hex << res
|
os << "Detector Server (Control) version (0x" << std::hex << res
|
||||||
@@ -110,7 +110,7 @@ std::string Module::getStopServerLongVersion() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string Module::getDetectorServerVersion() const {
|
std::string Module::getDetectorServerVersion() const {
|
||||||
Version v(getControlServerLongVersion());
|
Version const v(getControlServerLongVersion());
|
||||||
return v.concise();
|
return v.concise();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ std::string Module::getReceiverLongVersion() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string Module::getReceiverSoftwareVersion() const {
|
std::string Module::getReceiverSoftwareVersion() const {
|
||||||
Version v(getReceiverLongVersion());
|
Version const v(getReceiverLongVersion());
|
||||||
return v.concise();
|
return v.concise();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ slsDetectorDefs::xy Module::getNumberOfChannels() const {
|
|||||||
|
|
||||||
void Module::updateNumberOfModule(slsDetectorDefs::xy det) {
|
void Module::updateNumberOfModule(slsDetectorDefs::xy det) {
|
||||||
shm()->numberOfModule = det;
|
shm()->numberOfModule = det;
|
||||||
int args[2] = {shm()->numberOfModule.y, moduleIndex};
|
int const args[2] = {shm()->numberOfModule.y, moduleIndex};
|
||||||
sendToDetector(F_SET_POSITION, args, nullptr);
|
sendToDetector(F_SET_POSITION, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,14 +218,14 @@ void Module::setThresholdEnergy(int e_eV, detectorSettings isettings,
|
|||||||
throw RuntimeError("This energy " + std::to_string(e_eV) +
|
throw RuntimeError("This energy " + std::to_string(e_eV) +
|
||||||
" not defined for this module!");
|
" not defined for this module!");
|
||||||
}
|
}
|
||||||
bool interpolate =
|
bool const interpolate =
|
||||||
std::all_of(shm()->trimEnergies.begin(), shm()->trimEnergies.end(),
|
std::all_of(shm()->trimEnergies.begin(), shm()->trimEnergies.end(),
|
||||||
[e_eV](const int &e) { return e != e_eV; });
|
[e_eV](const int &e) { return e != e_eV; });
|
||||||
|
|
||||||
sls_detector_module myMod{shm()->detType};
|
sls_detector_module myMod{shm()->detType};
|
||||||
|
|
||||||
if (!interpolate) {
|
if (!interpolate) {
|
||||||
std::string settingsfname = getTrimbitFilename(isettings, e_eV);
|
std::string const settingsfname = getTrimbitFilename(isettings, e_eV);
|
||||||
LOG(logDEBUG1) << "Settings File is " << settingsfname;
|
LOG(logDEBUG1) << "Settings File is " << settingsfname;
|
||||||
myMod = readSettingsFile(settingsfname, trimbits);
|
myMod = readSettingsFile(settingsfname, trimbits);
|
||||||
} else {
|
} else {
|
||||||
@@ -238,8 +238,8 @@ void Module::setThresholdEnergy(int e_eV, detectorSettings isettings,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string settingsfname1 = getTrimbitFilename(isettings, trim1);
|
std::string const settingsfname1 = getTrimbitFilename(isettings, trim1);
|
||||||
std::string settingsfname2 = getTrimbitFilename(isettings, trim2);
|
std::string const settingsfname2 = getTrimbitFilename(isettings, trim2);
|
||||||
LOG(logDEBUG1) << "Settings Files are " << settingsfname1 << " and "
|
LOG(logDEBUG1) << "Settings Files are " << settingsfname1 << " and "
|
||||||
<< settingsfname2;
|
<< settingsfname2;
|
||||||
auto myMod1 = readSettingsFile(settingsfname1, trimbits);
|
auto myMod1 = readSettingsFile(settingsfname1, trimbits);
|
||||||
@@ -291,17 +291,17 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
|||||||
std::vector<sls_detector_module> myMods;
|
std::vector<sls_detector_module> myMods;
|
||||||
for (size_t i = 0; i < energy.size(); ++i) {
|
for (size_t i = 0; i < energy.size(); ++i) {
|
||||||
if (energy[i] == -1) {
|
if (energy[i] == -1) {
|
||||||
sls_detector_module mod = getModule();
|
sls_detector_module const mod = getModule();
|
||||||
myMods.push_back(mod);
|
myMods.push_back(mod);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sls_detector_module mod{shm()->detType};
|
sls_detector_module const mod{shm()->detType};
|
||||||
myMods.push_back(mod);
|
myMods.push_back(mod);
|
||||||
|
|
||||||
// don't interpolate
|
// don't interpolate
|
||||||
if (shm()->trimEnergies.anyEqualTo(energy[i])) {
|
if (shm()->trimEnergies.anyEqualTo(energy[i])) {
|
||||||
std::string settingsfname =
|
std::string const settingsfname =
|
||||||
getTrimbitFilename(isettings, energy[i]);
|
getTrimbitFilename(isettings, energy[i]);
|
||||||
LOG(logDEBUG1) << "Settings File is " << settingsfname;
|
LOG(logDEBUG1) << "Settings File is " << settingsfname;
|
||||||
myMods[i] = readSettingsFile(settingsfname, trimbits);
|
myMods[i] = readSettingsFile(settingsfname, trimbits);
|
||||||
@@ -335,8 +335,8 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
|||||||
LOG(logINFO) << "e_eV:" << energy[i] << " [" << trim1 << ", "
|
LOG(logINFO) << "e_eV:" << energy[i] << " [" << trim1 << ", "
|
||||||
<< trim2 << "]";
|
<< trim2 << "]";
|
||||||
|
|
||||||
std::string settingsfname1 = getTrimbitFilename(isettings, trim1);
|
std::string const settingsfname1 = getTrimbitFilename(isettings, trim1);
|
||||||
std::string settingsfname2 = getTrimbitFilename(isettings, trim2);
|
std::string const settingsfname2 = getTrimbitFilename(isettings, trim2);
|
||||||
LOG(logDEBUG1) << "Settings Files are " << settingsfname1 << " and "
|
LOG(logDEBUG1) << "Settings Files are " << settingsfname1 << " and "
|
||||||
<< settingsfname2;
|
<< settingsfname2;
|
||||||
auto myMod1 = readSettingsFile(settingsfname1, trimbits);
|
auto myMod1 = readSettingsFile(settingsfname1, trimbits);
|
||||||
@@ -755,17 +755,17 @@ int Module::getClockDivider(int clkIndex) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::setClockDivider(int clkIndex, int value) {
|
void Module::setClockDivider(int clkIndex, int value) {
|
||||||
int args[]{clkIndex, value};
|
int const args[]{clkIndex, value};
|
||||||
sendToDetector(F_SET_CLOCK_DIVIDER, args, nullptr);
|
sendToDetector(F_SET_CLOCK_DIVIDER, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getClockPhase(int clkIndex, bool inDegrees) const {
|
int Module::getClockPhase(int clkIndex, bool inDegrees) const {
|
||||||
int args[]{clkIndex, static_cast<int>(inDegrees)};
|
int const args[]{clkIndex, static_cast<int>(inDegrees)};
|
||||||
return sendToDetector<int>(F_GET_CLOCK_PHASE, args);
|
return sendToDetector<int>(F_GET_CLOCK_PHASE, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setClockPhase(int clkIndex, int value, bool inDegrees) {
|
void Module::setClockPhase(int clkIndex, int value, bool inDegrees) {
|
||||||
int args[]{clkIndex, value, static_cast<int>(inDegrees)};
|
int const args[]{clkIndex, value, static_cast<int>(inDegrees)};
|
||||||
sendToDetector(F_SET_CLOCK_PHASE, args, nullptr);
|
sendToDetector(F_SET_CLOCK_PHASE, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -778,22 +778,22 @@ int Module::getClockFrequency(int clkIndex) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::setClockFrequency(int clkIndex, int value) {
|
void Module::setClockFrequency(int clkIndex, int value) {
|
||||||
int args[]{clkIndex, value};
|
int const args[]{clkIndex, value};
|
||||||
sendToDetector(F_SET_CLOCK_FREQUENCY, args, nullptr);
|
sendToDetector(F_SET_CLOCK_FREQUENCY, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getDAC(dacIndex index, bool mV) const {
|
int Module::getDAC(dacIndex index, bool mV) const {
|
||||||
int args[]{static_cast<int>(index), static_cast<int>(mV), GET_FLAG};
|
int const args[]{static_cast<int>(index), static_cast<int>(mV), GET_FLAG};
|
||||||
return sendToDetector<int>(F_SET_DAC, args);
|
return sendToDetector<int>(F_SET_DAC, args);
|
||||||
}
|
}
|
||||||
int Module::getDefaultDac(slsDetectorDefs::dacIndex index,
|
int Module::getDefaultDac(slsDetectorDefs::dacIndex index,
|
||||||
slsDetectorDefs::detectorSettings sett) {
|
slsDetectorDefs::detectorSettings sett) {
|
||||||
int args[]{static_cast<int>(index), static_cast<int>(sett)};
|
int const args[]{static_cast<int>(index), static_cast<int>(sett)};
|
||||||
return sendToDetector<int>(F_GET_DEFAULT_DAC, args);
|
return sendToDetector<int>(F_GET_DEFAULT_DAC, args);
|
||||||
}
|
}
|
||||||
void Module::setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
|
void Module::setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
|
||||||
defs::detectorSettings sett) {
|
defs::detectorSettings sett) {
|
||||||
int args[]{static_cast<int>(index), static_cast<int>(sett), defaultValue};
|
int const args[]{static_cast<int>(index), static_cast<int>(sett), defaultValue};
|
||||||
return sendToDetector(F_SET_DEFAULT_DAC, args, nullptr);
|
return sendToDetector(F_SET_DEFAULT_DAC, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -803,7 +803,7 @@ void Module::resetToDefaultDacs(const bool hardReset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDAC(int val, dacIndex index, bool mV) {
|
void Module::setDAC(int val, dacIndex index, bool mV) {
|
||||||
int args[]{static_cast<int>(index), static_cast<int>(mV), val};
|
int const args[]{static_cast<int>(index), static_cast<int>(mV), val};
|
||||||
sendToDetector<int>(F_SET_DAC, args);
|
sendToDetector<int>(F_SET_DAC, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -844,13 +844,13 @@ int Module::getADC(dacIndex index) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Module::getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex) const {
|
int Module::getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex) const {
|
||||||
int args[]{static_cast<int>(index), chipIndex};
|
int const args[]{static_cast<int>(index), chipIndex};
|
||||||
return sendToDetector<int>(F_GET_ON_CHIP_DAC, args);
|
return sendToDetector<int>(F_GET_ON_CHIP_DAC, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex,
|
void Module::setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex,
|
||||||
int value) {
|
int value) {
|
||||||
int args[]{static_cast<int>(index), chipIndex, value};
|
int const args[]{static_cast<int>(index), chipIndex, value};
|
||||||
sendToDetector(F_SET_ON_CHIP_DAC, args, nullptr);
|
sendToDetector(F_SET_ON_CHIP_DAC, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -861,7 +861,7 @@ Module::getExternalSignalFlags(int signalIndex) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::setExternalSignalFlags(int signalIndex, externalSignalFlag type) {
|
void Module::setExternalSignalFlags(int signalIndex, externalSignalFlag type) {
|
||||||
int args[]{signalIndex, static_cast<int>(type)};
|
int const args[]{signalIndex, static_cast<int>(type)};
|
||||||
sendToDetector(F_SET_EXTERNAL_SIGNAL_FLAG, args, nullptr);
|
sendToDetector(F_SET_EXTERNAL_SIGNAL_FLAG, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1483,7 +1483,7 @@ void Module::setPartialFramesPadding(bool padding) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Module::getReceiverUDPSocketBufferSize() const {
|
int Module::getReceiverUDPSocketBufferSize() const {
|
||||||
int arg = GET_FLAG;
|
int const arg = GET_FLAG;
|
||||||
return sendToReceiver<int>(F_RECEIVER_UDP_SOCK_BUF_SIZE, arg);
|
return sendToReceiver<int>(F_RECEIVER_UDP_SOCK_BUF_SIZE, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1809,7 +1809,7 @@ int64_t Module::getRateCorrection() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDefaultRateCorrection() {
|
void Module::setDefaultRateCorrection() {
|
||||||
int64_t arg = -1;
|
int64_t const arg = -1;
|
||||||
sendToDetector(F_SET_RATE_CORRECT, arg, nullptr);
|
sendToDetector(F_SET_RATE_CORRECT, arg, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1860,7 +1860,7 @@ bool Module::getActivate() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::setActivate(const bool enable) {
|
void Module::setActivate(const bool enable) {
|
||||||
int arg = static_cast<int>(enable);
|
int const arg = static_cast<int>(enable);
|
||||||
auto retval = sendToDetector<int>(F_ACTIVATE, arg);
|
auto retval = sendToDetector<int>(F_ACTIVATE, arg);
|
||||||
sendToDetectorStop<int>(F_ACTIVATE, arg);
|
sendToDetectorStop<int>(F_ACTIVATE, arg);
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
@@ -1894,7 +1894,7 @@ void Module::pulseChip(int n_pulses) {
|
|||||||
bool Module::getQuad() const { return sendToDetector<int>(F_GET_QUAD) != 0; }
|
bool Module::getQuad() const { return sendToDetector<int>(F_GET_QUAD) != 0; }
|
||||||
|
|
||||||
void Module::setQuad(const bool enable) {
|
void Module::setQuad(const bool enable) {
|
||||||
int value = enable ? 1 : 0;
|
int const value = enable ? 1 : 0;
|
||||||
sendToDetector(F_SET_QUAD, value, nullptr);
|
sendToDetector(F_SET_QUAD, value, nullptr);
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sendToReceiver(F_SET_RECEIVER_QUAD, value, nullptr);
|
sendToReceiver(F_SET_RECEIVER_QUAD, value, nullptr);
|
||||||
@@ -1906,7 +1906,7 @@ bool Module::getDataStream(const portPosition port) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDataStream(const portPosition port, const bool enable) {
|
void Module::setDataStream(const portPosition port, const bool enable) {
|
||||||
int args[]{static_cast<int>(port), static_cast<int>(enable)};
|
int const args[]{static_cast<int>(port), static_cast<int>(enable)};
|
||||||
sendToDetector(F_SET_DATASTREAM, args, nullptr);
|
sendToDetector(F_SET_DATASTREAM, args, nullptr);
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sendToReceiver(F_RECEIVER_SET_DATASTREAM, args, nullptr);
|
sendToReceiver(F_RECEIVER_SET_DATASTREAM, args, nullptr);
|
||||||
@@ -2076,7 +2076,7 @@ std::array<int, 2> Module::getInjectChannel() const {
|
|||||||
|
|
||||||
void Module::setInjectChannel(const int offsetChannel,
|
void Module::setInjectChannel(const int offsetChannel,
|
||||||
const int incrementChannel) {
|
const int incrementChannel) {
|
||||||
int args[]{offsetChannel, incrementChannel};
|
int const args[]{offsetChannel, incrementChannel};
|
||||||
sendToDetector(F_SET_INJECT_CHANNEL, args, nullptr);
|
sendToDetector(F_SET_INJECT_CHANNEL, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2331,18 +2331,18 @@ slsDetectorDefs::vetoAlgorithm Module::getVetoAlgorithm(
|
|||||||
void Module::setVetoAlgorithm(
|
void Module::setVetoAlgorithm(
|
||||||
const slsDetectorDefs::vetoAlgorithm alg,
|
const slsDetectorDefs::vetoAlgorithm alg,
|
||||||
const slsDetectorDefs::streamingInterface interface) {
|
const slsDetectorDefs::streamingInterface interface) {
|
||||||
int args[]{static_cast<int>(alg), static_cast<int>(interface)};
|
int const args[]{static_cast<int>(alg), static_cast<int>(interface)};
|
||||||
sendToDetector(F_SET_VETO_ALGORITHM, args, nullptr);
|
sendToDetector(F_SET_VETO_ALGORITHM, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getADCConfiguration(const int chipIndex, const int adcIndex) const {
|
int Module::getADCConfiguration(const int chipIndex, const int adcIndex) const {
|
||||||
int args[]{chipIndex, adcIndex};
|
int const args[]{chipIndex, adcIndex};
|
||||||
return sendToDetector<int>(F_GET_ADC_CONFIGURATION, args);
|
return sendToDetector<int>(F_GET_ADC_CONFIGURATION, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setADCConfiguration(const int chipIndex, const int adcIndex,
|
void Module::setADCConfiguration(const int chipIndex, const int adcIndex,
|
||||||
int value) {
|
int value) {
|
||||||
int args[]{chipIndex, adcIndex, value};
|
int const args[]{chipIndex, adcIndex, value};
|
||||||
sendToDetector(F_SET_ADC_CONFIGURATION, args, nullptr);
|
sendToDetector(F_SET_ADC_CONFIGURATION, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2417,7 +2417,7 @@ bool Module::getInterpolation() const {
|
|||||||
|
|
||||||
void Module::setInterpolation(const bool enable) {
|
void Module::setInterpolation(const bool enable) {
|
||||||
sendToDetector(F_SET_INTERPOLATION, static_cast<int>(enable), nullptr);
|
sendToDetector(F_SET_INTERPOLATION, static_cast<int>(enable), nullptr);
|
||||||
int mask = getCounterMask();
|
int const mask = getCounterMask();
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sendToReceiver(F_RECEIVER_SET_COUNTER_MASK, mask, nullptr);
|
sendToReceiver(F_RECEIVER_SET_COUNTER_MASK, mask, nullptr);
|
||||||
}
|
}
|
||||||
@@ -2568,19 +2568,17 @@ std::vector<int> Module::getReceiverDbitList() const {
|
|||||||
|
|
||||||
void Module::setReceiverDbitList(std::vector<int> list) {
|
void Module::setReceiverDbitList(std::vector<int> list) {
|
||||||
LOG(logDEBUG1) << "Setting Receiver Dbit List";
|
LOG(logDEBUG1) << "Setting Receiver Dbit List";
|
||||||
if (list.size() > 64) {
|
|
||||||
throw RuntimeError("Dbit list size cannot be greater than 64\n");
|
|
||||||
}
|
|
||||||
for (auto &it : list) {
|
for (auto &it : list) {
|
||||||
if (it < 0 || it > 63) {
|
if (it < 0 || it > 63) {
|
||||||
throw RuntimeError("Dbit list value must be between 0 and 63\n");
|
throw RuntimeError("Dbit list value must be between 0 and 63\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::sort(begin(list), end(list));
|
auto r = stableRemoveDuplicates(list);
|
||||||
auto last = std::unique(begin(list), end(list));
|
if(r)
|
||||||
list.erase(last, list.end());
|
LOG(logWARNING) << "Removed duplicated from receiver dbit list";
|
||||||
|
|
||||||
StaticVector<int, MAX_RX_DBIT> arg = list;
|
StaticVector<int, MAX_RX_DBIT> const arg = list;
|
||||||
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
|
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2602,7 +2600,7 @@ void Module::setReceiverDbitReorder(bool reorder) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDigitalIODelay(uint64_t pinMask, int delay) {
|
void Module::setDigitalIODelay(uint64_t pinMask, int delay) {
|
||||||
uint64_t args[]{pinMask, static_cast<uint64_t>(delay)};
|
uint64_t const args[]{pinMask, static_cast<uint64_t>(delay)};
|
||||||
sendToDetector(F_DIGITAL_IO_DELAY, args, nullptr);
|
sendToDetector(F_DIGITAL_IO_DELAY, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2659,57 +2657,57 @@ void Module::setPatternIOControl(uint64_t word) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Module::getPatternWord(int addr) const {
|
uint64_t Module::getPatternWord(int addr) const {
|
||||||
uint64_t args[]{static_cast<uint64_t>(addr),
|
uint64_t const args[]{static_cast<uint64_t>(addr),
|
||||||
static_cast<uint64_t>(GET_FLAG)};
|
static_cast<uint64_t>(GET_FLAG)};
|
||||||
return sendToDetector<uint64_t>(F_SET_PATTERN_WORD, args);
|
return sendToDetector<uint64_t>(F_SET_PATTERN_WORD, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setPatternWord(int addr, uint64_t word) {
|
void Module::setPatternWord(int addr, uint64_t word) {
|
||||||
uint64_t args[]{static_cast<uint64_t>(addr), word};
|
uint64_t const args[]{static_cast<uint64_t>(addr), word};
|
||||||
sendToDetector<uint64_t>(F_SET_PATTERN_WORD, args);
|
sendToDetector<uint64_t>(F_SET_PATTERN_WORD, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<int, 2> Module::getPatternLoopAddresses(int level) const {
|
std::array<int, 2> Module::getPatternLoopAddresses(int level) const {
|
||||||
int args[]{level, GET_FLAG, GET_FLAG};
|
int const args[]{level, GET_FLAG, GET_FLAG};
|
||||||
std::array<int, 2> retvals{};
|
std::array<int, 2> retvals{};
|
||||||
sendToDetector(F_SET_PATTERN_LOOP_ADDRESSES, args, retvals);
|
sendToDetector(F_SET_PATTERN_LOOP_ADDRESSES, args, retvals);
|
||||||
return retvals;
|
return retvals;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setPatternLoopAddresses(int level, int start, int stop) {
|
void Module::setPatternLoopAddresses(int level, int start, int stop) {
|
||||||
int args[]{level, start, stop};
|
int const args[]{level, start, stop};
|
||||||
std::array<int, 2> retvals{};
|
std::array<int, 2> retvals{};
|
||||||
sendToDetector(F_SET_PATTERN_LOOP_ADDRESSES, args, retvals);
|
sendToDetector(F_SET_PATTERN_LOOP_ADDRESSES, args, retvals);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getPatternLoopCycles(int level) const {
|
int Module::getPatternLoopCycles(int level) const {
|
||||||
int args[]{level, GET_FLAG};
|
int const args[]{level, GET_FLAG};
|
||||||
return sendToDetector<int>(F_SET_PATTERN_LOOP_CYCLES, args);
|
return sendToDetector<int>(F_SET_PATTERN_LOOP_CYCLES, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setPatternLoopCycles(int level, int n) {
|
void Module::setPatternLoopCycles(int level, int n) {
|
||||||
int args[]{level, n};
|
int const args[]{level, n};
|
||||||
sendToDetector<int>(F_SET_PATTERN_LOOP_CYCLES, args);
|
sendToDetector<int>(F_SET_PATTERN_LOOP_CYCLES, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getPatternWaitAddr(int level) const {
|
int Module::getPatternWaitAddr(int level) const {
|
||||||
int args[]{level, GET_FLAG};
|
int const args[]{level, GET_FLAG};
|
||||||
return sendToDetector<int>(F_SET_PATTERN_WAIT_ADDR, args);
|
return sendToDetector<int>(F_SET_PATTERN_WAIT_ADDR, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setPatternWaitAddr(int level, int addr) {
|
void Module::setPatternWaitAddr(int level, int addr) {
|
||||||
int args[]{level, addr};
|
int const args[]{level, addr};
|
||||||
sendToDetector<int>(F_SET_PATTERN_WAIT_ADDR, args);
|
sendToDetector<int>(F_SET_PATTERN_WAIT_ADDR, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Module::getPatternWaitClocks(int level) const {
|
uint64_t Module::getPatternWaitClocks(int level) const {
|
||||||
uint64_t args[]{static_cast<uint64_t>(level),
|
uint64_t const args[]{static_cast<uint64_t>(level),
|
||||||
static_cast<uint64_t>(GET_FLAG)};
|
static_cast<uint64_t>(GET_FLAG)};
|
||||||
return sendToDetector<uint64_t>(F_SET_PATTERN_WAIT_CLOCKS, args);
|
return sendToDetector<uint64_t>(F_SET_PATTERN_WAIT_CLOCKS, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setPatternWaitClocks(int level, uint64_t t) {
|
void Module::setPatternWaitClocks(int level, uint64_t t) {
|
||||||
uint64_t args[]{static_cast<uint64_t>(level), t};
|
uint64_t const args[]{static_cast<uint64_t>(level), t};
|
||||||
sendToDetector<uint64_t>(F_SET_PATTERN_WAIT_CLOCKS, args);
|
sendToDetector<uint64_t>(F_SET_PATTERN_WAIT_CLOCKS, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2717,7 +2715,7 @@ uint64_t Module::getPatternWaitInterval(int level) const {
|
|||||||
return sendToDetector<uint64_t>(F_GET_PATTERN_WAIT_INTERVAL, level);
|
return sendToDetector<uint64_t>(F_GET_PATTERN_WAIT_INTERVAL, level);
|
||||||
}
|
}
|
||||||
void Module::setPatternWaitInterval(int level, uint64_t t) {
|
void Module::setPatternWaitInterval(int level, uint64_t t) {
|
||||||
uint64_t args[]{static_cast<uint64_t>(level), t};
|
uint64_t const args[]{static_cast<uint64_t>(level), t};
|
||||||
sendToDetector(F_SET_PATTERN_WAIT_INTERVAL, args, nullptr);
|
sendToDetector(F_SET_PATTERN_WAIT_INTERVAL, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2921,24 +2919,24 @@ uint32_t Module::readRegister(uint32_t addr) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::writeRegister(uint32_t addr, uint32_t val, bool validate) {
|
void Module::writeRegister(uint32_t addr, uint32_t val, bool validate) {
|
||||||
uint32_t args[]{addr, val, static_cast<uint32_t>(validate)};
|
uint32_t const args[]{addr, val, static_cast<uint32_t>(validate)};
|
||||||
return sendToDetectorStop(F_WRITE_REGISTER, args, nullptr);
|
return sendToDetectorStop(F_WRITE_REGISTER, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setBit(uint32_t addr, int n, bool validate) {
|
void Module::setBit(uint32_t addr, int n, bool validate) {
|
||||||
uint32_t args[] = {addr, static_cast<uint32_t>(n),
|
uint32_t const args[] = {addr, static_cast<uint32_t>(n),
|
||||||
static_cast<uint32_t>(validate)};
|
static_cast<uint32_t>(validate)};
|
||||||
sendToDetectorStop(F_SET_BIT, args, nullptr);
|
sendToDetectorStop(F_SET_BIT, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::clearBit(uint32_t addr, int n, bool validate) {
|
void Module::clearBit(uint32_t addr, int n, bool validate) {
|
||||||
uint32_t args[] = {addr, static_cast<uint32_t>(n),
|
uint32_t const args[] = {addr, static_cast<uint32_t>(n),
|
||||||
static_cast<uint32_t>(validate)};
|
static_cast<uint32_t>(validate)};
|
||||||
sendToDetectorStop(F_CLEAR_BIT, args, nullptr);
|
sendToDetectorStop(F_CLEAR_BIT, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getBit(uint32_t addr, int n) {
|
int Module::getBit(uint32_t addr, int n) {
|
||||||
uint32_t args[2] = {addr, static_cast<uint32_t>(n)};
|
uint32_t const args[2] = {addr, static_cast<uint32_t>(n)};
|
||||||
return sendToDetectorStop<int>(F_GET_BIT, args);
|
return sendToDetectorStop<int>(F_GET_BIT, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2947,7 +2945,7 @@ void Module::executeFirmwareTest() { sendToDetector(F_SET_FIRMWARE_TEST); }
|
|||||||
void Module::executeBusTest() { sendToDetector(F_SET_BUS_TEST); }
|
void Module::executeBusTest() { sendToDetector(F_SET_BUS_TEST); }
|
||||||
|
|
||||||
void Module::writeAdcRegister(uint32_t addr, uint32_t val) {
|
void Module::writeAdcRegister(uint32_t addr, uint32_t val) {
|
||||||
uint32_t args[]{addr, val};
|
uint32_t const args[]{addr, val};
|
||||||
sendToDetector(F_WRITE_ADC_REG, args, nullptr);
|
sendToDetector(F_WRITE_ADC_REG, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3451,7 +3449,7 @@ void Module::initializeModuleStructure(detectorType type) {
|
|||||||
shm()->stoppedFlag = false;
|
shm()->stoppedFlag = false;
|
||||||
|
|
||||||
// get the Module parameters based on type
|
// get the Module parameters based on type
|
||||||
detParameters parameters{type};
|
detParameters const parameters{type};
|
||||||
shm()->nChan.x = parameters.nChanX;
|
shm()->nChan.x = parameters.nChanX;
|
||||||
shm()->nChan.y = parameters.nChanY;
|
shm()->nChan.y = parameters.nChanY;
|
||||||
shm()->nChip.x = parameters.nChipX;
|
shm()->nChip.x = parameters.nChipX;
|
||||||
@@ -3465,12 +3463,12 @@ void Module::initialDetectorServerChecks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::checkDetectorVersionCompatibility() {
|
void Module::checkDetectorVersionCompatibility() {
|
||||||
std::string detServers[2] = {getControlServerLongVersion(),
|
std::string const detServers[2] = {getControlServerLongVersion(),
|
||||||
getStopServerLongVersion()};
|
getStopServerLongVersion()};
|
||||||
for (int i = 0; i != 2; ++i) {
|
for (int i = 0; i != 2; ++i) {
|
||||||
// det and client (sem. versioning)
|
// det and client (sem. versioning)
|
||||||
Version det(detServers[i]);
|
Version const det(detServers[i]);
|
||||||
Version client(APILIB);
|
Version const client(APILIB);
|
||||||
if (det.hasSemanticVersioning() && client.hasSemanticVersioning()) {
|
if (det.hasSemanticVersioning() && client.hasSemanticVersioning()) {
|
||||||
if (!det.isBackwardCompatible(client)) {
|
if (!det.isBackwardCompatible(client)) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@@ -3484,7 +3482,7 @@ void Module::checkDetectorVersionCompatibility() {
|
|||||||
}
|
}
|
||||||
// comparing dates(exact match to expected)
|
// comparing dates(exact match to expected)
|
||||||
else {
|
else {
|
||||||
Version expectedDetector(getDetectorAPI());
|
Version const expectedDetector(getDetectorAPI());
|
||||||
if (det != expectedDetector) {
|
if (det != expectedDetector) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Detector (" << (i == 0 ? "Control" : "Stop")
|
oss << "Detector (" << (i == 0 ? "Control" : "Stop")
|
||||||
@@ -3523,8 +3521,8 @@ const std::string Module::getDetectorAPI() const {
|
|||||||
|
|
||||||
void Module::checkReceiverVersionCompatibility() {
|
void Module::checkReceiverVersionCompatibility() {
|
||||||
// rxr and client (sem. versioning)
|
// rxr and client (sem. versioning)
|
||||||
Version rxr(getReceiverLongVersion());
|
Version const rxr(getReceiverLongVersion());
|
||||||
Version client(APILIB);
|
Version const client(APILIB);
|
||||||
if (rxr.hasSemanticVersioning() && client.hasSemanticVersioning()) {
|
if (rxr.hasSemanticVersioning() && client.hasSemanticVersioning()) {
|
||||||
if (!rxr.isBackwardCompatible(client)) {
|
if (!rxr.isBackwardCompatible(client)) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@@ -3537,7 +3535,7 @@ void Module::checkReceiverVersionCompatibility() {
|
|||||||
}
|
}
|
||||||
// comparing dates(exact match to expected)
|
// comparing dates(exact match to expected)
|
||||||
else {
|
else {
|
||||||
Version expectedReceiver(APIRECEIVER);
|
Version const expectedReceiver(APIRECEIVER);
|
||||||
if (rxr != expectedReceiver) {
|
if (rxr != expectedReceiver) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Receiver version (" << rxr.getDate()
|
oss << "Receiver version (" << rxr.getDate()
|
||||||
@@ -3668,7 +3666,7 @@ void Module::sendModule(sls_detector_module *myMod, ClientSocket &client) {
|
|||||||
ts += n;
|
ts += n;
|
||||||
LOG(level) << "channels sent. " << n << " bytes";
|
LOG(level) << "channels sent. " << n << " bytes";
|
||||||
|
|
||||||
int expectedBytesSent = sizeof(sls_detector_module) - sizeof(myMod->dacs) -
|
int const expectedBytesSent = sizeof(sls_detector_module) - sizeof(myMod->dacs) -
|
||||||
sizeof(myMod->chanregs) +
|
sizeof(myMod->chanregs) +
|
||||||
(myMod->ndac * sizeof(int)) +
|
(myMod->ndac * sizeof(int)) +
|
||||||
(myMod->nchan * sizeof(int));
|
(myMod->nchan * sizeof(int));
|
||||||
@@ -3734,7 +3732,7 @@ sls_detector_module Module::interpolateTrim(sls_detector_module *a,
|
|||||||
"Interpolation of Trim values not implemented for this detector!");
|
"Interpolation of Trim values not implemented for this detector!");
|
||||||
}
|
}
|
||||||
|
|
||||||
sls_detector_module myMod{shm()->detType};
|
sls_detector_module const myMod{shm()->detType};
|
||||||
|
|
||||||
// create copy and interpolate dac lists
|
// create copy and interpolate dac lists
|
||||||
std::vector<int> dacs_to_copy, dacs_to_interpolate;
|
std::vector<int> dacs_to_copy, dacs_to_interpolate;
|
||||||
@@ -3880,7 +3878,7 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
|
|||||||
|
|
||||||
// mythen3 (dacs, trimbits)
|
// mythen3 (dacs, trimbits)
|
||||||
else if (shm()->detType == MYTHEN3) {
|
else if (shm()->detType == MYTHEN3) {
|
||||||
int expected_size = sizeof(int) * myMod.ndac +
|
int const expected_size = sizeof(int) * myMod.ndac +
|
||||||
sizeof(int) * myMod.nchan + sizeof(myMod.reg);
|
sizeof(int) * myMod.nchan + sizeof(myMod.reg);
|
||||||
if (file_size != expected_size) {
|
if (file_size != expected_size) {
|
||||||
throw RuntimeError("The size of the settings file: " + fname +
|
throw RuntimeError("The size of the settings file: " + fname +
|
||||||
@@ -3959,7 +3957,7 @@ void Module::sendProgram(bool blackfin, std::vector<char> buffer,
|
|||||||
client.Send(filesize);
|
client.Send(filesize);
|
||||||
|
|
||||||
// send checksum
|
// send checksum
|
||||||
std::string checksum = md5_calculate_checksum(buffer.data(), filesize);
|
std::string const checksum = md5_calculate_checksum(buffer.data(), filesize);
|
||||||
LOG(logDEBUG1) << "Checksum:" << checksum;
|
LOG(logDEBUG1) << "Checksum:" << checksum;
|
||||||
char cChecksum[MAX_STR_LENGTH] = {0};
|
char cChecksum[MAX_STR_LENGTH] = {0};
|
||||||
strcpy(cChecksum, checksum.c_str());
|
strcpy(cChecksum, checksum.c_str());
|
||||||
|
|||||||
@@ -114,14 +114,14 @@ size_t Pattern::load(const std::string &fname) {
|
|||||||
it, std::istream_iterator<std::string>());
|
it, std::istream_iterator<std::string>());
|
||||||
|
|
||||||
std::string cmd = args[0];
|
std::string cmd = args[0];
|
||||||
int nargs = args.size() - 1;
|
int const nargs = args.size() - 1;
|
||||||
|
|
||||||
if (cmd == "patword") {
|
if (cmd == "patword") {
|
||||||
if (nargs != 2) {
|
if (nargs != 2) {
|
||||||
throw RuntimeError("Invalid arguments for " +
|
throw RuntimeError("Invalid arguments for " +
|
||||||
ToString(args));
|
ToString(args));
|
||||||
}
|
}
|
||||||
uint32_t addr = StringTo<uint32_t>(args[1]);
|
uint32_t const addr = StringTo<uint32_t>(args[1]);
|
||||||
if (addr >= MAX_PATTERN_LENGTH) {
|
if (addr >= MAX_PATTERN_LENGTH) {
|
||||||
throw RuntimeError("Invalid address for " + ToString(args));
|
throw RuntimeError("Invalid address for " + ToString(args));
|
||||||
}
|
}
|
||||||
@@ -162,8 +162,8 @@ size_t Pattern::load(const std::string &fname) {
|
|||||||
throw RuntimeError("Invalid Pattern level. Options 0-" +
|
throw RuntimeError("Invalid Pattern level. Options 0-" +
|
||||||
std::to_string(MAX_PATTERN_LEVELS - 1));
|
std::to_string(MAX_PATTERN_LEVELS - 1));
|
||||||
}
|
}
|
||||||
int loop1 = StringTo<uint32_t>(args[iArg++]);
|
int const loop1 = StringTo<uint32_t>(args[iArg++]);
|
||||||
int loop2 = StringTo<uint32_t>(args[iArg++]);
|
int const loop2 = StringTo<uint32_t>(args[iArg++]);
|
||||||
pat->startloop[level] = loop1;
|
pat->startloop[level] = loop1;
|
||||||
pat->stoploop[level] = loop2;
|
pat->stoploop[level] = loop2;
|
||||||
} else if (cmd == "patnloop0" || cmd == "patnloop1" ||
|
} else if (cmd == "patnloop0" || cmd == "patnloop1" ||
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ template <typename T> class SharedMemory {
|
|||||||
std::string getName() const { return name; }
|
std::string getName() const { return name; }
|
||||||
|
|
||||||
bool exists() {
|
bool exists() {
|
||||||
int tempfd = shm_open(name.c_str(), O_RDWR, 0);
|
const int tempfd = shm_open(name.c_str(), O_RDWR, 0);
|
||||||
if ((tempfd < 0) && (errno == ENOENT)) {
|
if ((tempfd < 0) && (errno == ENOENT)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ template <typename T> class SharedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void createSharedMemory() {
|
void createSharedMemory() {
|
||||||
int fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR,
|
const int fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR,
|
||||||
S_IRUSR | S_IWUSR);
|
S_IRUSR | S_IWUSR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
std::string msg =
|
std::string msg =
|
||||||
@@ -184,9 +184,9 @@ template <typename T> class SharedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void openSharedMemory(bool verifySize) {
|
void openSharedMemory(bool verifySize) {
|
||||||
int fd = shm_open(name.c_str(), O_RDWR, 0);
|
const int fd = shm_open(name.c_str(), O_RDWR, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
std::string msg = "Open existing shared memory " + name +
|
const std::string msg = "Open existing shared memory " + name +
|
||||||
" failed: " + strerror(errno);
|
" failed: " + strerror(errno);
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ template <typename T> class SharedMemory {
|
|||||||
void unmapSharedMemory() {
|
void unmapSharedMemory() {
|
||||||
if (shared_struct != nullptr) {
|
if (shared_struct != nullptr) {
|
||||||
if (munmap(shared_struct, sizeof(T)) < 0) {
|
if (munmap(shared_struct, sizeof(T)) < 0) {
|
||||||
std::string msg = "Unmapping shared memory " + name +
|
const std::string msg = "Unmapping shared memory " + name +
|
||||||
" failed: " + strerror(errno);
|
" failed: " + strerror(errno);
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ template <typename T> class SharedMemory {
|
|||||||
// silent exit if shm did not exist anyway
|
// silent exit if shm did not exist anyway
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return;
|
return;
|
||||||
std::string msg =
|
const std::string msg =
|
||||||
"Free Shared Memory " + name + " Failed: " + strerror(errno);
|
"Free Shared Memory " + name + " Failed: " + strerror(errno);
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
@@ -244,7 +244,7 @@ template <typename T> class SharedMemory {
|
|||||||
|
|
||||||
std::string shm_name = ss.str();
|
std::string shm_name = ss.str();
|
||||||
if (shm_name.length() > NAME_MAX_LENGTH) {
|
if (shm_name.length() > NAME_MAX_LENGTH) {
|
||||||
std::string msg =
|
const std::string msg =
|
||||||
"Shared memory initialization failed. " + shm_name + " has " +
|
"Shared memory initialization failed. " + shm_name + " has " +
|
||||||
std::to_string(shm_name.length()) + " characters. \n" +
|
std::to_string(shm_name.length()) + " characters. \n" +
|
||||||
"Maximum is " + std::to_string(NAME_MAX_LENGTH) +
|
"Maximum is " + std::to_string(NAME_MAX_LENGTH) +
|
||||||
@@ -262,7 +262,7 @@ template <typename T> class SharedMemory {
|
|||||||
mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
close(fd);
|
close(fd);
|
||||||
if (addr == MAP_FAILED) {
|
if (addr == MAP_FAILED) {
|
||||||
std::string msg =
|
const std::string msg =
|
||||||
"Mapping shared memory " + name + " failed: " + strerror(errno);
|
"Mapping shared memory " + name + " failed: " + strerror(errno);
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ template <typename T> class SharedMemory {
|
|||||||
void checkSize(int fd) {
|
void checkSize(int fd) {
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
if (fstat(fd, &sb) < 0) {
|
if (fstat(fd, &sb) < 0) {
|
||||||
std::string msg = "Could not verify existing shared memory " +
|
const std::string msg = "Could not verify existing shared memory " +
|
||||||
name + " size match " +
|
name + " size match " +
|
||||||
"(could not fstat): " + strerror(errno);
|
"(could not fstat): " + strerror(errno);
|
||||||
close(fd);
|
close(fd);
|
||||||
@@ -287,7 +287,7 @@ template <typename T> class SharedMemory {
|
|||||||
auto actual_size = static_cast<size_t>(sb.st_size);
|
auto actual_size = static_cast<size_t>(sb.st_size);
|
||||||
auto expected_size = sizeof(T);
|
auto expected_size = sizeof(T);
|
||||||
if (actual_size != expected_size) {
|
if (actual_size != expected_size) {
|
||||||
std::string msg =
|
const std::string msg =
|
||||||
"Existing shared memory " + name + " size does not match. " +
|
"Existing shared memory " + name + " size does not match. " +
|
||||||
"Expected " + std::to_string(expected_size) + ", found " +
|
"Expected " + std::to_string(expected_size) + ", found " +
|
||||||
std::to_string(actual_size) +
|
std::to_string(actual_size) +
|
||||||
|
|||||||
@@ -1618,18 +1618,6 @@ int InferAction::imagetest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int InferAction::include() {
|
|
||||||
|
|
||||||
if (args.size() == 1) {
|
|
||||||
return slsDetectorDefs::PUT_ACTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
|
|
||||||
throw RuntimeError("Could not infer action: Wrong number of arguments");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int InferAction::initialchecks() {
|
int InferAction::initialchecks() {
|
||||||
|
|
||||||
if (args.size() == 0) {
|
if (args.size() == 0) {
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ class InferAction {
|
|||||||
int im_d();
|
int im_d();
|
||||||
int im_io();
|
int im_io();
|
||||||
int imagetest();
|
int imagetest();
|
||||||
int include();
|
|
||||||
int initialchecks();
|
int initialchecks();
|
||||||
int inj_ch();
|
int inj_ch();
|
||||||
int interpolation();
|
int interpolation();
|
||||||
@@ -449,7 +448,6 @@ class InferAction {
|
|||||||
{"im_d", &InferAction::im_d},
|
{"im_d", &InferAction::im_d},
|
||||||
{"im_io", &InferAction::im_io},
|
{"im_io", &InferAction::im_io},
|
||||||
{"imagetest", &InferAction::imagetest},
|
{"imagetest", &InferAction::imagetest},
|
||||||
{"include", &InferAction::include},
|
|
||||||
{"initialchecks", &InferAction::initialchecks},
|
{"initialchecks", &InferAction::initialchecks},
|
||||||
{"inj_ch", &InferAction::inj_ch},
|
{"inj_ch", &InferAction::inj_ch},
|
||||||
{"interpolation", &InferAction::interpolation},
|
{"interpolation", &InferAction::interpolation},
|
||||||
|
|||||||
@@ -29,18 +29,18 @@ TEST_CASE("jungfrau_or_moench_acquire_check_file_size",
|
|||||||
auto num_udp_interfaces = det.getNumberofUDPInterfaces().tsquash(
|
auto num_udp_interfaces = det.getNumberofUDPInterfaces().tsquash(
|
||||||
"inconsistent number of udp interfaces");
|
"inconsistent number of udp interfaces");
|
||||||
|
|
||||||
int num_frames_to_acquire = 2;
|
int const num_frames_to_acquire = 2;
|
||||||
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
||||||
|
|
||||||
// check file size (assuming local pc)
|
// check file size (assuming local pc)
|
||||||
{
|
{
|
||||||
detParameters par(det_type);
|
detParameters const par(det_type);
|
||||||
int bytes_per_pixel = det.getDynamicRange().squash() / 8;
|
int const bytes_per_pixel = det.getDynamicRange().squash() / 8;
|
||||||
// if 2 udp interfaces, data split into half
|
// if 2 udp interfaces, data split into half
|
||||||
size_t expected_image_size = (par.nChanX * par.nChanY * par.nChipX *
|
size_t const expected_image_size = (par.nChanX * par.nChanY * par.nChipX *
|
||||||
par.nChipY * bytes_per_pixel) /
|
par.nChipY * bytes_per_pixel) /
|
||||||
num_udp_interfaces;
|
num_udp_interfaces;
|
||||||
testFileInfo test_file_info;
|
testFileInfo const test_file_info;
|
||||||
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
||||||
expected_image_size);
|
expected_image_size);
|
||||||
}
|
}
|
||||||
@@ -55,23 +55,23 @@ TEST_CASE("eiger_acquire_check_file_size", "[.cmdcall][.cmdacquire]") {
|
|||||||
|
|
||||||
if (det_type == defs::EIGER) {
|
if (det_type == defs::EIGER) {
|
||||||
|
|
||||||
int dynamic_range = det.getDynamicRange().squash();
|
int const dynamic_range = det.getDynamicRange().squash();
|
||||||
if (dynamic_range != 16) {
|
if (dynamic_range != 16) {
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Eiger detector must have dynamic range 16 to test");
|
"Eiger detector must have dynamic range 16 to test");
|
||||||
}
|
}
|
||||||
int num_frames_to_acquire = 2;
|
int const num_frames_to_acquire = 2;
|
||||||
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
||||||
|
|
||||||
// check file size (assuming local pc)
|
// check file size (assuming local pc)
|
||||||
{
|
{
|
||||||
detParameters par(det_type);
|
detParameters const par(det_type);
|
||||||
// data split into half due to 2 udp interfaces per half module
|
// data split into half due to 2 udp interfaces per half module
|
||||||
int num_chips = (par.nChipX / 2);
|
int const num_chips = (par.nChipX / 2);
|
||||||
int bytes_per_pixel = (dynamic_range / 8);
|
int const bytes_per_pixel = (dynamic_range / 8);
|
||||||
size_t expected_image_size =
|
size_t const expected_image_size =
|
||||||
par.nChanX * par.nChanY * num_chips * bytes_per_pixel;
|
par.nChanX * par.nChanY * num_chips * bytes_per_pixel;
|
||||||
testFileInfo test_file_info;
|
testFileInfo const test_file_info;
|
||||||
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
||||||
expected_image_size);
|
expected_image_size);
|
||||||
}
|
}
|
||||||
@@ -86,25 +86,25 @@ TEST_CASE("mythen3_acquire_check_file_size", "[.cmdcall][.cmdacquire]") {
|
|||||||
|
|
||||||
if (det_type == defs::MYTHEN3) {
|
if (det_type == defs::MYTHEN3) {
|
||||||
|
|
||||||
int dynamic_range = det.getDynamicRange().squash();
|
int const dynamic_range = det.getDynamicRange().squash();
|
||||||
int counter_mask = det.getCounterMask().squash();
|
int const counter_mask = det.getCounterMask().squash();
|
||||||
if (dynamic_range != 16 && counter_mask != 0x3) {
|
if (dynamic_range != 16 && counter_mask != 0x3) {
|
||||||
throw RuntimeError("Mythen3 detector must have dynamic range 16 "
|
throw RuntimeError("Mythen3 detector must have dynamic range 16 "
|
||||||
"and counter mask 0x3 to test");
|
"and counter mask 0x3 to test");
|
||||||
}
|
}
|
||||||
int num_counters = __builtin_popcount(counter_mask);
|
int const num_counters = __builtin_popcount(counter_mask);
|
||||||
int num_frames_to_acquire = 2;
|
int const num_frames_to_acquire = 2;
|
||||||
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
||||||
|
|
||||||
// check file size (assuming local pc)
|
// check file size (assuming local pc)
|
||||||
{
|
{
|
||||||
detParameters par(det_type);
|
detParameters const par(det_type);
|
||||||
int bytes_per_pixel = dynamic_range / 8;
|
int const bytes_per_pixel = dynamic_range / 8;
|
||||||
int num_channels_per_counter = par.nChanX / 3;
|
int const num_channels_per_counter = par.nChanX / 3;
|
||||||
size_t expected_image_size = num_channels_per_counter *
|
size_t const expected_image_size = num_channels_per_counter *
|
||||||
num_counters * par.nChipX *
|
num_counters * par.nChipX *
|
||||||
bytes_per_pixel;
|
bytes_per_pixel;
|
||||||
testFileInfo test_file_info;
|
testFileInfo const test_file_info;
|
||||||
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
||||||
expected_image_size);
|
expected_image_size);
|
||||||
}
|
}
|
||||||
@@ -119,16 +119,16 @@ TEST_CASE("gotthard2_acquire_check_file_size", "[.cmdcall][.cmdacquire]") {
|
|||||||
|
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
|
|
||||||
int num_frames_to_acquire = 2;
|
int const num_frames_to_acquire = 2;
|
||||||
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
||||||
|
|
||||||
// check file size (assuming local pc)
|
// check file size (assuming local pc)
|
||||||
{
|
{
|
||||||
detParameters par(det_type);
|
detParameters const par(det_type);
|
||||||
int bytes_per_pixel = det.getDynamicRange().squash() / 8;
|
int const bytes_per_pixel = det.getDynamicRange().squash() / 8;
|
||||||
size_t expected_image_size =
|
size_t const expected_image_size =
|
||||||
par.nChanX * par.nChipX * bytes_per_pixel;
|
par.nChanX * par.nChipX * bytes_per_pixel;
|
||||||
testFileInfo test_file_info;
|
testFileInfo const test_file_info;
|
||||||
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
||||||
expected_image_size);
|
expected_image_size);
|
||||||
}
|
}
|
||||||
@@ -143,9 +143,9 @@ void test_ctb_file_size_with_acquire(Detector &det, Caller &caller,
|
|||||||
create_files_for_acquire(det, caller, num_frames, test_info);
|
create_files_for_acquire(det, caller, num_frames, test_info);
|
||||||
|
|
||||||
// check file size (assuming local pc)
|
// check file size (assuming local pc)
|
||||||
uint64_t expected_image_size =
|
uint64_t const expected_image_size =
|
||||||
calculate_ctb_image_size(test_info, isXilinxCtb).first;
|
calculate_ctb_image_size(test_info, isXilinxCtb).first;
|
||||||
testFileInfo test_file_info;
|
testFileInfo const test_file_info;
|
||||||
REQUIRE_NOTHROW(test_acquire_binary_file_size(test_file_info, num_frames,
|
REQUIRE_NOTHROW(test_acquire_binary_file_size(test_file_info, num_frames,
|
||||||
expected_image_size));
|
expected_image_size));
|
||||||
}
|
}
|
||||||
@@ -158,8 +158,8 @@ TEST_CASE("ctb_acquire_check_file_size", "[.cmdcall][.cmdacquire]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
bool isXilinxCtb = (det_type == defs::XILINX_CHIPTESTBOARD);
|
bool const isXilinxCtb = (det_type == defs::XILINX_CHIPTESTBOARD);
|
||||||
int num_frames_to_acquire = 2;
|
int const num_frames_to_acquire = 2;
|
||||||
// all the test cases
|
// all the test cases
|
||||||
{
|
{
|
||||||
testCtbAcquireInfo test_ctb_config{};
|
testCtbAcquireInfo test_ctb_config{};
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ TEST_CASE("dacname", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
defs::dacIndex ind = static_cast<defs::dacIndex>(2);
|
defs::dacIndex const ind = static_cast<defs::dacIndex>(2);
|
||||||
std::string str_dac_index = "2";
|
std::string const str_dac_index = "2";
|
||||||
auto prev = det.getDacName(ind);
|
auto prev = det.getDacName(ind);
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
@@ -61,8 +61,8 @@ TEST_CASE("dacindex", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
defs::dacIndex ind = static_cast<defs::dacIndex>(2);
|
defs::dacIndex const ind = static_cast<defs::dacIndex>(2);
|
||||||
std::string str_dac_index = "2";
|
std::string const str_dac_index = "2";
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
REQUIRE_THROWS(caller.call("dacindex", {"2", "2"}, -1, PUT));
|
REQUIRE_THROWS(caller.call("dacindex", {"2", "2"}, -1, PUT));
|
||||||
@@ -120,8 +120,8 @@ TEST_CASE("adcname", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
int ind = 2;
|
int const ind = 2;
|
||||||
std::string str_adc_index = "2";
|
std::string const str_adc_index = "2";
|
||||||
auto prev = det.getAdcName(ind);
|
auto prev = det.getAdcName(ind);
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
@@ -155,8 +155,8 @@ TEST_CASE("adcindex", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
int ind = 2;
|
int const ind = 2;
|
||||||
std::string str_adc_index = "2";
|
std::string const str_adc_index = "2";
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
REQUIRE_THROWS(caller.call("adcindex", {"2", "2"}, -1, PUT));
|
REQUIRE_THROWS(caller.call("adcindex", {"2", "2"}, -1, PUT));
|
||||||
@@ -214,8 +214,8 @@ TEST_CASE("signalname", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
int ind = 2;
|
int const ind = 2;
|
||||||
std::string str_signal_index = "2";
|
std::string const str_signal_index = "2";
|
||||||
auto prev = det.getSignalName(ind);
|
auto prev = det.getSignalName(ind);
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
@@ -249,8 +249,8 @@ TEST_CASE("signalindex", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
int ind = 2;
|
int const ind = 2;
|
||||||
std::string str_signal_index = "2";
|
std::string const str_signal_index = "2";
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
REQUIRE_THROWS(caller.call("signalindex", {"2", "2"}, -1, PUT));
|
REQUIRE_THROWS(caller.call("signalindex", {"2", "2"}, -1, PUT));
|
||||||
@@ -309,8 +309,8 @@ TEST_CASE("powername", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
|
defs::dacIndex const ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
|
||||||
std::string str_power_index = "2";
|
std::string const str_power_index = "2";
|
||||||
auto prev = det.getPowerName(ind);
|
auto prev = det.getPowerName(ind);
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
@@ -344,8 +344,8 @@ TEST_CASE("powerindex", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
|
defs::dacIndex const ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
|
||||||
std::string str_power_index = "2";
|
std::string const str_power_index = "2";
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
REQUIRE_THROWS(caller.call("powerindex", {"2", "2"}, -1, PUT));
|
REQUIRE_THROWS(caller.call("powerindex", {"2", "2"}, -1, PUT));
|
||||||
@@ -430,8 +430,8 @@ TEST_CASE("slowadcname", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
|
defs::dacIndex const ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
|
||||||
std::string str_slowadc_index = "2";
|
std::string const str_slowadc_index = "2";
|
||||||
auto prev = det.getSlowADCName(ind);
|
auto prev = det.getSlowADCName(ind);
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
@@ -466,8 +466,8 @@ TEST_CASE("slowadcindex", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
|
defs::dacIndex const ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
|
||||||
std::string str_slowadc_index = "2";
|
std::string const str_slowadc_index = "2";
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
REQUIRE_THROWS(caller.call("slowadcindex", {"2", "2"}, -1, PUT));
|
REQUIRE_THROWS(caller.call("slowadcindex", {"2", "2"}, -1, PUT));
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ TEST_CASE("temp_fpgaext", "[.cmdcall]") {
|
|||||||
REQUIRE_NOTHROW(caller.call("temp_fpgaext", {}, -1, GET));
|
REQUIRE_NOTHROW(caller.call("temp_fpgaext", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(caller.call("temp_fpgaext", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(caller.call("temp_fpgaext", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase(0, strlen("temp_fpgaext "));
|
std::string const s = (oss.str()).erase(0, strlen("temp_fpgaext "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(caller.call("temp_fpgaext", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("temp_fpgaext", {}, -1, GET));
|
||||||
@@ -42,7 +42,7 @@ TEST_CASE("temp_10ge", "[.cmdcall]") {
|
|||||||
REQUIRE_NOTHROW(caller.call("temp_10ge", {}, -1, GET));
|
REQUIRE_NOTHROW(caller.call("temp_10ge", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(caller.call("temp_10ge", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(caller.call("temp_10ge", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase(0, strlen("temp_10ge "));
|
std::string const s = (oss.str()).erase(0, strlen("temp_10ge "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(caller.call("temp_10ge", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("temp_10ge", {}, -1, GET));
|
||||||
@@ -57,7 +57,7 @@ TEST_CASE("temp_dcdc", "[.cmdcall]") {
|
|||||||
REQUIRE_NOTHROW(caller.call("temp_dcdc", {}, -1, GET));
|
REQUIRE_NOTHROW(caller.call("temp_dcdc", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(caller.call("temp_dcdc", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(caller.call("temp_dcdc", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase(0, strlen("temp_dcdc "));
|
std::string const s = (oss.str()).erase(0, strlen("temp_dcdc "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(caller.call("temp_dcdc", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("temp_dcdc", {}, -1, GET));
|
||||||
@@ -72,7 +72,7 @@ TEST_CASE("temp_sodl", "[.cmdcall]") {
|
|||||||
REQUIRE_NOTHROW(caller.call("temp_sodl", {}, -1, GET));
|
REQUIRE_NOTHROW(caller.call("temp_sodl", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(caller.call("temp_sodl", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(caller.call("temp_sodl", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase(0, strlen("temp_sodl "));
|
std::string const s = (oss.str()).erase(0, strlen("temp_sodl "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(caller.call("temp_sodl", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("temp_sodl", {}, -1, GET));
|
||||||
@@ -87,7 +87,7 @@ TEST_CASE("temp_sodr", "[.cmdcall]") {
|
|||||||
REQUIRE_NOTHROW(caller.call("temp_sodr", {}, -1, GET));
|
REQUIRE_NOTHROW(caller.call("temp_sodr", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(caller.call("temp_sodr", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(caller.call("temp_sodr", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase(0, strlen("temp_sodr "));
|
std::string const s = (oss.str()).erase(0, strlen("temp_sodr "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(caller.call("temp_sodr", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("temp_sodr", {}, -1, GET));
|
||||||
@@ -102,7 +102,7 @@ TEST_CASE("temp_fpgafl", "[.cmdcall]") {
|
|||||||
REQUIRE_NOTHROW(caller.call("temp_fpgafl", {}, -1, GET));
|
REQUIRE_NOTHROW(caller.call("temp_fpgafl", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(caller.call("temp_fpgafl", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(caller.call("temp_fpgafl", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase(0, strlen("temp_fpgafl "));
|
std::string const s = (oss.str()).erase(0, strlen("temp_fpgafl "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(caller.call("temp_fpgafl", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("temp_fpgafl", {}, -1, GET));
|
||||||
@@ -117,7 +117,7 @@ TEST_CASE("temp_fpgafr", "[.cmdcall]") {
|
|||||||
REQUIRE_NOTHROW(caller.call("temp_fpgafr", {}, -1, GET));
|
REQUIRE_NOTHROW(caller.call("temp_fpgafr", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(caller.call("temp_fpgafr", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(caller.call("temp_fpgafr", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase(0, strlen("temp_fpgafr "));
|
std::string const s = (oss.str()).erase(0, strlen("temp_fpgafr "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(caller.call("temp_fpgafr", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("temp_fpgafr", {}, -1, GET));
|
||||||
@@ -421,7 +421,7 @@ TEST_CASE("measuredperiod", "[.cmdcall]") {
|
|||||||
} else {
|
} else {
|
||||||
s = st.erase(0, strlen("measuredperiod "));
|
s = st.erase(0, strlen("measuredperiod "));
|
||||||
}
|
}
|
||||||
double val = std::stod(s);
|
double const val = std::stod(s);
|
||||||
// REQUIRE(val >= 1.0);
|
// REQUIRE(val >= 1.0);
|
||||||
REQUIRE(val < 2.0);
|
REQUIRE(val < 2.0);
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
@@ -460,7 +460,7 @@ TEST_CASE("measuredsubperiod", "[.cmdcall]") {
|
|||||||
} else {
|
} else {
|
||||||
s = st.erase(0, strlen("measuredsubperiod "));
|
s = st.erase(0, strlen("measuredsubperiod "));
|
||||||
}
|
}
|
||||||
double val = std::stod(s);
|
double const val = std::stod(s);
|
||||||
REQUIRE(val >= 0);
|
REQUIRE(val >= 0);
|
||||||
REQUIRE(val < 1000);
|
REQUIRE(val < 1000);
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ void test_valid_port_caller(const std::string &command,
|
|||||||
if (arg.empty())
|
if (arg.empty())
|
||||||
arg.push_back("0");
|
arg.push_back("0");
|
||||||
|
|
||||||
int test_values[3] = {77797, -1, 0};
|
int const test_values[3] = {77797, -1, 0};
|
||||||
for (int i = 0; i != 3; ++i) {
|
for (int i = 0; i != 3; ++i) {
|
||||||
int port_number = test_values[i];
|
int const port_number = test_values[i];
|
||||||
arg[arg.size() - 1] = std::to_string(port_number);
|
arg[arg.size() - 1] = std::to_string(port_number);
|
||||||
REQUIRE_THROWS(caller.call(command, arg, detector_id, action));
|
REQUIRE_THROWS(caller.call(command, arg, detector_id, action));
|
||||||
/*REQUIRE_THROWS_WITH(proxy.Call(command, arguments, detector_id,
|
/*REQUIRE_THROWS_WITH(proxy.Call(command, arguments, detector_id,
|
||||||
@@ -72,7 +72,7 @@ void test_onchip_dac_caller(defs::dacIndex index, const std::string &dacname,
|
|||||||
REQUIRE_THROWS(
|
REQUIRE_THROWS(
|
||||||
caller.call(dacname, {"-1", "0x400"}, -1, PUT)); // max val is 0x3ff
|
caller.call(dacname, {"-1", "0x400"}, -1, PUT)); // max val is 0x3ff
|
||||||
|
|
||||||
int chipIndex = -1; // for now, it is -1 only
|
int const chipIndex = -1; // for now, it is -1 only
|
||||||
auto prev_val = det.getOnChipDAC(index, chipIndex);
|
auto prev_val = det.getOnChipDAC(index, chipIndex);
|
||||||
auto dacValueStr = ToStringHex(dacvalue);
|
auto dacValueStr = ToStringHex(dacvalue);
|
||||||
auto chipIndexStr = std::to_string(chipIndex);
|
auto chipIndexStr = std::to_string(chipIndex);
|
||||||
@@ -115,10 +115,10 @@ void test_acquire_binary_file_size(const testFileInfo &file_info,
|
|||||||
uint64_t num_frames_to_acquire,
|
uint64_t num_frames_to_acquire,
|
||||||
uint64_t expected_image_size) {
|
uint64_t expected_image_size) {
|
||||||
assert(file_info.file_format == defs::BINARY);
|
assert(file_info.file_format == defs::BINARY);
|
||||||
std::string fname = file_info.file_path + "/" + file_info.file_prefix +
|
std::string const fname = file_info.file_path + "/" + file_info.file_prefix +
|
||||||
"_d0_f0_" + std::to_string(file_info.file_acq_index) +
|
"_d0_f0_" + std::to_string(file_info.file_acq_index) +
|
||||||
".raw";
|
".raw";
|
||||||
uint64_t expected_file_size =
|
uint64_t const expected_file_size =
|
||||||
num_frames_to_acquire *
|
num_frames_to_acquire *
|
||||||
(expected_image_size + sizeof(defs::sls_receiver_header));
|
(expected_image_size + sizeof(defs::sls_receiver_header));
|
||||||
auto actual_file_size = std::filesystem::file_size(fname);
|
auto actual_file_size = std::filesystem::file_size(fname);
|
||||||
@@ -136,7 +136,7 @@ void test_acquire_with_receiver(Caller &caller, const Detector &det) {
|
|||||||
REQUIRE_NOTHROW(caller.call("start", {}, -1, PUT));
|
REQUIRE_NOTHROW(caller.call("start", {}, -1, PUT));
|
||||||
bool idle = false;
|
bool idle = false;
|
||||||
while (!idle) {
|
while (!idle) {
|
||||||
std::ostringstream oss;
|
std::ostringstream const oss;
|
||||||
REQUIRE_NOTHROW(caller.call("status", {}, -1, GET));
|
REQUIRE_NOTHROW(caller.call("status", {}, -1, GET));
|
||||||
auto statusList = det.getDetectorStatus();
|
auto statusList = det.getDetectorStatus();
|
||||||
if (statusList.any(defs::ERROR)) {
|
if (statusList.any(defs::ERROR)) {
|
||||||
@@ -154,7 +154,7 @@ void create_files_for_acquire(
|
|||||||
const std::optional<testCtbAcquireInfo> &test_info) {
|
const std::optional<testCtbAcquireInfo> &test_info) {
|
||||||
|
|
||||||
// save previous state
|
// save previous state
|
||||||
testFileInfo prev_file_info = get_file_state(det);
|
testFileInfo const prev_file_info = get_file_state(det);
|
||||||
auto prev_num_frames = det.getNumberOfFrames().tsquash(
|
auto prev_num_frames = det.getNumberOfFrames().tsquash(
|
||||||
"Inconsistent number of frames to acquire");
|
"Inconsistent number of frames to acquire");
|
||||||
std::optional<testCtbAcquireInfo> prev_ctb_config_info{};
|
std::optional<testCtbAcquireInfo> prev_ctb_config_info{};
|
||||||
@@ -163,7 +163,7 @@ void create_files_for_acquire(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set state for acquire
|
// set state for acquire
|
||||||
testFileInfo test_file_info;
|
testFileInfo const test_file_info;
|
||||||
set_file_state(det, test_file_info);
|
set_file_state(det, test_file_info);
|
||||||
det.setNumberOfFrames(num_frames);
|
det.setNumberOfFrames(num_frames);
|
||||||
if (test_info) {
|
if (test_info) {
|
||||||
@@ -265,10 +265,10 @@ calculate_ctb_image_size(const testCtbAcquireInfo &test_info,
|
|||||||
inputs.dbitList = test_info.dbit_list;
|
inputs.dbitList = test_info.dbit_list;
|
||||||
|
|
||||||
auto out = computeCtbImageSize(inputs);
|
auto out = computeCtbImageSize(inputs);
|
||||||
uint64_t image_size =
|
uint64_t const image_size =
|
||||||
out.nAnalogBytes + out.nDigitalBytes + out.nTransceiverBytes;
|
out.nAnalogBytes + out.nDigitalBytes + out.nTransceiverBytes;
|
||||||
LOG(logDEBUG1) << "Expected image size: " << image_size;
|
LOG(logDEBUG1) << "Expected image size: " << image_size;
|
||||||
int npixelx = out.nPixelsX;
|
int const npixelx = out.nPixelsX;
|
||||||
LOG(logDEBUG1) << "Expected number of pixels in x: " << npixelx;
|
LOG(logDEBUG1) << "Expected number of pixels in x: " << npixelx;
|
||||||
return std::make_pair(image_size, npixelx);
|
return std::make_pair(image_size, npixelx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -580,9 +580,9 @@ TEST_CASE("pedestalmode", "[.cmdcall]") {
|
|||||||
REQUIRE(oss.str() == "pedestalmode [disabled]\n");
|
REQUIRE(oss.str() == "pedestalmode [disabled]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t pedestalFrames = 50;
|
uint8_t const pedestalFrames = 50;
|
||||||
uint16_t pedestalLoops = 100;
|
uint16_t const pedestalLoops = 100;
|
||||||
int64_t expNumFrames = pedestalFrames * pedestalLoops * 2;
|
int64_t const expNumFrames = pedestalFrames * pedestalLoops * 2;
|
||||||
auto origFrames = det.getNumberOfFrames().squash(-1);
|
auto origFrames = det.getNumberOfFrames().squash(-1);
|
||||||
auto origTriggers = det.getNumberOfTriggers().squash(-1);
|
auto origTriggers = det.getNumberOfTriggers().squash(-1);
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ void read_from_json(const Document &doc, const std::string &name,
|
|||||||
}
|
}
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (const auto &item : json_values) {
|
for (const auto &item : json_values) {
|
||||||
std::string sval = item.GetString();
|
std::string const sval = item.GetString();
|
||||||
retval[index++] = StringTo<sls::ns>(sval);
|
retval[index++] = StringTo<sls::ns>(sval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,7 +330,7 @@ void test_master_file_version(const Detector &det,
|
|||||||
// different values for json and hdf5
|
// different values for json and hdf5
|
||||||
// hdf5 version in atttribute and not dataset
|
// hdf5 version in atttribute and not dataset
|
||||||
double retval{};
|
double retval{};
|
||||||
std::string name = MasterAttributes::N_VERSION.data();
|
std::string const name = MasterAttributes::N_VERSION.data();
|
||||||
if (doc.has_value()) {
|
if (doc.has_value()) {
|
||||||
const auto &d = *doc;
|
const auto &d = *doc;
|
||||||
REQUIRE(d.HasMember(MasterAttributes::N_VERSION.data()));
|
REQUIRE(d.HasMember(MasterAttributes::N_VERSION.data()));
|
||||||
@@ -381,14 +381,14 @@ void test_master_file_image_size(const Detector &det,
|
|||||||
|
|
||||||
auto det_type =
|
auto det_type =
|
||||||
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
||||||
int bytes_per_pixel = det.getDynamicRange().squash() / 8;
|
int const bytes_per_pixel = det.getDynamicRange().squash() / 8;
|
||||||
detParameters par(det_type);
|
detParameters const par(det_type);
|
||||||
|
|
||||||
int image_size = 0;
|
int image_size = 0;
|
||||||
switch (det_type) {
|
switch (det_type) {
|
||||||
|
|
||||||
case defs::EIGER: {
|
case defs::EIGER: {
|
||||||
int num_chips = (par.nChipX / 2);
|
int const num_chips = (par.nChipX / 2);
|
||||||
image_size = par.nChanX * par.nChanY * num_chips * bytes_per_pixel;
|
image_size = par.nChanX * par.nChanY * num_chips * bytes_per_pixel;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@@ -402,9 +402,9 @@ void test_master_file_image_size(const Detector &det,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case defs::MYTHEN3: {
|
case defs::MYTHEN3: {
|
||||||
int counter_mask = det.getCounterMask().squash();
|
int const counter_mask = det.getCounterMask().squash();
|
||||||
int num_counters = __builtin_popcount(counter_mask);
|
int const num_counters = __builtin_popcount(counter_mask);
|
||||||
int num_channels_per_counter = par.nChanX / MAX_NUM_COUNTERS;
|
int const num_channels_per_counter = par.nChanX / MAX_NUM_COUNTERS;
|
||||||
image_size = num_channels_per_counter * num_counters * par.nChipX *
|
image_size = num_channels_per_counter * num_counters * par.nChipX *
|
||||||
bytes_per_pixel;
|
bytes_per_pixel;
|
||||||
} break;
|
} break;
|
||||||
@@ -415,7 +415,7 @@ void test_master_file_image_size(const Detector &det,
|
|||||||
|
|
||||||
case defs::CHIPTESTBOARD:
|
case defs::CHIPTESTBOARD:
|
||||||
case defs::XILINX_CHIPTESTBOARD: {
|
case defs::XILINX_CHIPTESTBOARD: {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
image_size = calculate_ctb_image_size(
|
image_size = calculate_ctb_image_size(
|
||||||
test_info, (det_type == defs::XILINX_CHIPTESTBOARD))
|
test_info, (det_type == defs::XILINX_CHIPTESTBOARD))
|
||||||
.first;
|
.first;
|
||||||
@@ -439,14 +439,14 @@ void test_master_file_det_size(const Detector &det,
|
|||||||
// m3 assumes all counters enabled when getting num channels from client
|
// m3 assumes all counters enabled when getting num channels from client
|
||||||
// TODO: in future, remove assumption
|
// TODO: in future, remove assumption
|
||||||
if (det_type == defs::MYTHEN3) {
|
if (det_type == defs::MYTHEN3) {
|
||||||
int nchan = portSize.x / MAX_NUM_COUNTERS;
|
int const nchan = portSize.x / MAX_NUM_COUNTERS;
|
||||||
auto counter_mask = det.getCounterMask().tsquash(
|
auto counter_mask = det.getCounterMask().tsquash(
|
||||||
"Inconsistent counter mask for Mythen3 detector");
|
"Inconsistent counter mask for Mythen3 detector");
|
||||||
int num_counters = __builtin_popcount(counter_mask);
|
int const num_counters = __builtin_popcount(counter_mask);
|
||||||
portSize.x = nchan * num_counters;
|
portSize.x = nchan * num_counters;
|
||||||
} else if (det_type == defs::CHIPTESTBOARD ||
|
} else if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
portSize.x = calculate_ctb_image_size(
|
portSize.x = calculate_ctb_image_size(
|
||||||
test_info, det_type == defs::XILINX_CHIPTESTBOARD)
|
test_info, det_type == defs::XILINX_CHIPTESTBOARD)
|
||||||
.second;
|
.second;
|
||||||
@@ -534,7 +534,7 @@ void test_master_file_total_frames(const Detector &det,
|
|||||||
det.getNumberOfAdditionalStorageCells().tsquash(
|
det.getNumberOfAdditionalStorageCells().tsquash(
|
||||||
"Inconsistent number of additional storage cells");
|
"Inconsistent number of additional storage cells");
|
||||||
}
|
}
|
||||||
uint64_t total_frames =
|
uint64_t const total_frames =
|
||||||
numFrames * repeats * (int64_t)(numAdditionalStorageCells + 1);
|
numFrames * repeats * (int64_t)(numAdditionalStorageCells + 1);
|
||||||
|
|
||||||
REQUIRE_NOTHROW(check_master_file<uint64_t>(
|
REQUIRE_NOTHROW(check_master_file<uint64_t>(
|
||||||
@@ -549,14 +549,14 @@ void test_master_file_rois(const Detector &det,
|
|||||||
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
||||||
// compensate for m3 channel size and counter mask mess
|
// compensate for m3 channel size and counter mask mess
|
||||||
if (det_type == defs::MYTHEN3) {
|
if (det_type == defs::MYTHEN3) {
|
||||||
int nchan = detsize.x / MAX_NUM_COUNTERS;
|
int const nchan = detsize.x / MAX_NUM_COUNTERS;
|
||||||
auto counter_mask = det.getCounterMask().tsquash(
|
auto counter_mask = det.getCounterMask().tsquash(
|
||||||
"Inconsistent counter mask for Mythen3 detector");
|
"Inconsistent counter mask for Mythen3 detector");
|
||||||
int num_counters = __builtin_popcount(counter_mask);
|
int const num_counters = __builtin_popcount(counter_mask);
|
||||||
detsize.x = nchan * num_counters;
|
detsize.x = nchan * num_counters;
|
||||||
}
|
}
|
||||||
// replace -1 for complete ROI
|
// replace -1 for complete ROI
|
||||||
bool is2D = (detsize.y > 1);
|
bool const is2D = (detsize.y > 1);
|
||||||
for (auto &roi : rois) {
|
for (auto &roi : rois) {
|
||||||
if (roi.completeRoi()) {
|
if (roi.completeRoi()) {
|
||||||
roi.xmin = 0;
|
roi.xmin = 0;
|
||||||
@@ -751,7 +751,7 @@ void test_master_file_burst_mode(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_adc_mask(const Detector &det,
|
void test_master_file_adc_mask(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_ctb_config{};
|
testCtbAcquireInfo const test_ctb_config{};
|
||||||
auto adc_mask = test_ctb_config.adc_enable_10g;
|
auto adc_mask = test_ctb_config.adc_enable_10g;
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::CHIPTESTBOARD) {
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
@@ -766,7 +766,7 @@ void test_master_file_adc_mask(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_analog_flag(const Detector &det,
|
void test_master_file_analog_flag(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
auto romode = test_info.readout_mode;
|
auto romode = test_info.readout_mode;
|
||||||
auto analog = static_cast<int>(
|
auto analog = static_cast<int>(
|
||||||
(romode == defs::ANALOG_ONLY || romode == defs::ANALOG_AND_DIGITAL));
|
(romode == defs::ANALOG_ONLY || romode == defs::ANALOG_AND_DIGITAL));
|
||||||
@@ -777,7 +777,7 @@ void test_master_file_analog_flag(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_analog_samples(const Detector &det,
|
void test_master_file_analog_samples(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
auto analog_samples = test_info.num_adc_samples;
|
auto analog_samples = test_info.num_adc_samples;
|
||||||
|
|
||||||
REQUIRE_NOTHROW(check_master_file<int>(
|
REQUIRE_NOTHROW(check_master_file<int>(
|
||||||
@@ -786,7 +786,7 @@ void test_master_file_analog_samples(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_digital_flag(const Detector &det,
|
void test_master_file_digital_flag(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
auto romode = test_info.readout_mode;
|
auto romode = test_info.readout_mode;
|
||||||
auto digital = static_cast<int>(romode == defs::DIGITAL_ONLY ||
|
auto digital = static_cast<int>(romode == defs::DIGITAL_ONLY ||
|
||||||
romode == defs::ANALOG_AND_DIGITAL ||
|
romode == defs::ANALOG_AND_DIGITAL ||
|
||||||
@@ -798,7 +798,7 @@ void test_master_file_digital_flag(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_digital_samples(const Detector &det,
|
void test_master_file_digital_samples(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
auto digital_samples = test_info.num_dbit_samples;
|
auto digital_samples = test_info.num_dbit_samples;
|
||||||
|
|
||||||
REQUIRE_NOTHROW(check_master_file<int>(
|
REQUIRE_NOTHROW(check_master_file<int>(
|
||||||
@@ -807,7 +807,7 @@ void test_master_file_digital_samples(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_dbit_offset(const Detector &det,
|
void test_master_file_dbit_offset(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
auto dbit_offset = test_info.dbit_offset;
|
auto dbit_offset = test_info.dbit_offset;
|
||||||
|
|
||||||
REQUIRE_NOTHROW(check_master_file<int>(
|
REQUIRE_NOTHROW(check_master_file<int>(
|
||||||
@@ -816,7 +816,7 @@ void test_master_file_dbit_offset(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_dbit_reorder(const Detector &det,
|
void test_master_file_dbit_reorder(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
auto dbit_reorder = test_info.dbit_reorder;
|
auto dbit_reorder = test_info.dbit_reorder;
|
||||||
|
|
||||||
REQUIRE_NOTHROW(check_master_file<int>(
|
REQUIRE_NOTHROW(check_master_file<int>(
|
||||||
@@ -825,7 +825,7 @@ void test_master_file_dbit_reorder(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_dbit_bitset(const Detector &det,
|
void test_master_file_dbit_bitset(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
uint64_t dbit_bitset = 0;
|
uint64_t dbit_bitset = 0;
|
||||||
for (auto &i : test_info.dbit_list) {
|
for (auto &i : test_info.dbit_list) {
|
||||||
dbit_bitset |= (static_cast<uint64_t>(1) << i);
|
dbit_bitset |= (static_cast<uint64_t>(1) << i);
|
||||||
@@ -837,7 +837,7 @@ void test_master_file_dbit_bitset(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_transceiver_mask(const Detector &det,
|
void test_master_file_transceiver_mask(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
auto trans_mask = test_info.transceiver_mask;
|
auto trans_mask = test_info.transceiver_mask;
|
||||||
|
|
||||||
REQUIRE_NOTHROW(check_master_file<int>(
|
REQUIRE_NOTHROW(check_master_file<int>(
|
||||||
@@ -846,7 +846,7 @@ void test_master_file_transceiver_mask(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_transceiver_flag(const Detector &det,
|
void test_master_file_transceiver_flag(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
auto romode = test_info.readout_mode;
|
auto romode = test_info.readout_mode;
|
||||||
auto trans = static_cast<int>(romode == defs::DIGITAL_AND_TRANSCEIVER ||
|
auto trans = static_cast<int>(romode == defs::DIGITAL_AND_TRANSCEIVER ||
|
||||||
romode == defs::TRANSCEIVER_ONLY);
|
romode == defs::TRANSCEIVER_ONLY);
|
||||||
@@ -857,7 +857,7 @@ void test_master_file_transceiver_flag(const Detector &det,
|
|||||||
|
|
||||||
void test_master_file_transceiver_samples(const Detector &det,
|
void test_master_file_transceiver_samples(const Detector &det,
|
||||||
const std::optional<Document> &doc) {
|
const std::optional<Document> &doc) {
|
||||||
testCtbAcquireInfo test_info{};
|
testCtbAcquireInfo const test_info{};
|
||||||
auto trans_samples = test_info.num_trans_samples;
|
auto trans_samples = test_info.num_trans_samples;
|
||||||
REQUIRE_NOTHROW(check_master_file<int>(
|
REQUIRE_NOTHROW(check_master_file<int>(
|
||||||
doc, MasterAttributes::N_TRANSCEIVER_SAMPLES.data(), trans_samples));
|
doc, MasterAttributes::N_TRANSCEIVER_SAMPLES.data(), trans_samples));
|
||||||
@@ -1005,17 +1005,17 @@ Document parse_binary_master_attributes(std::string file_path) {
|
|||||||
REQUIRE(file.is_open());
|
REQUIRE(file.is_open());
|
||||||
std::stringstream buffer;
|
std::stringstream buffer;
|
||||||
buffer << file.rdbuf();
|
buffer << file.rdbuf();
|
||||||
std::string json_str = buffer.str();
|
std::string const json_str = buffer.str();
|
||||||
|
|
||||||
Document doc;
|
Document doc;
|
||||||
ParseResult result = doc.Parse(json_str.c_str());
|
ParseResult const result = doc.Parse(json_str.c_str());
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
std::cout << "JSON parse error: " << GetParseError_En(result.Code())
|
std::cout << "JSON parse error: " << GetParseError_En(result.Code())
|
||||||
<< " (at offset " << result.Offset() << ")" << std::endl;
|
<< " (at offset " << result.Offset() << ")" << std::endl;
|
||||||
|
|
||||||
// Optional: Show problematic snippet
|
// Optional: Show problematic snippet
|
||||||
size_t offset = result.Offset();
|
size_t const offset = result.Offset();
|
||||||
std::string context =
|
std::string const context =
|
||||||
json_str.substr(std::max(0, (int)offset - 20), 40);
|
json_str.substr(std::max(0, (int)offset - 20), 40);
|
||||||
std::cout << "Context around error: \"" << context << "\"" << std::endl;
|
std::cout << "Context around error: \"" << context << "\"" << std::endl;
|
||||||
}
|
}
|
||||||
@@ -1039,7 +1039,7 @@ TEST_CASE("check_master_file_attributes", "[.cmdcall][.cmdacquire][.cmdattr]") {
|
|||||||
auto det_type =
|
auto det_type =
|
||||||
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
||||||
|
|
||||||
int64_t num_frames = 1;
|
int64_t const num_frames = 1;
|
||||||
switch (det_type) {
|
switch (det_type) {
|
||||||
case defs::EIGER:
|
case defs::EIGER:
|
||||||
case defs::JUNGFRAU:
|
case defs::JUNGFRAU:
|
||||||
@@ -1057,11 +1057,11 @@ TEST_CASE("check_master_file_attributes", "[.cmdcall][.cmdacquire][.cmdattr]") {
|
|||||||
throw sls::RuntimeError("Unsupported detector type for this test");
|
throw sls::RuntimeError("Unsupported detector type for this test");
|
||||||
}
|
}
|
||||||
|
|
||||||
testFileInfo file_info;
|
testFileInfo const file_info;
|
||||||
std::string master_file_prefix = file_info.getMasterFileNamePrefix();
|
std::string const master_file_prefix = file_info.getMasterFileNamePrefix();
|
||||||
|
|
||||||
// binary
|
// binary
|
||||||
std::string fname =
|
std::string const fname =
|
||||||
master_file_prefix + ".json"; // /tmp/sls_test_master_0.json
|
master_file_prefix + ".json"; // /tmp/sls_test_master_0.json
|
||||||
auto doc = std::make_optional(parse_binary_master_attributes(fname));
|
auto doc = std::make_optional(parse_binary_master_attributes(fname));
|
||||||
test_master_file_metadata(det, doc);
|
test_master_file_metadata(det, doc);
|
||||||
|
|||||||
@@ -509,11 +509,11 @@ TEST_CASE("interpolation", "[.cmdcall]") {
|
|||||||
auto prev_mask = det.getCounterMask();
|
auto prev_mask = det.getCounterMask();
|
||||||
auto prev_vth3DacVal = det.getDAC(defs::VTH3, 0, {});
|
auto prev_vth3DacVal = det.getDAC(defs::VTH3, 0, {});
|
||||||
|
|
||||||
int disabledDacValue = 2800;
|
int const disabledDacValue = 2800;
|
||||||
auto fixedVth3DacVal = 1000;
|
auto fixedVth3DacVal = 1000;
|
||||||
det.setDAC(defs::VTH3, fixedVth3DacVal, 0, {});
|
det.setDAC(defs::VTH3, fixedVth3DacVal, 0, {});
|
||||||
// mask with counter 3 disabled and enabled(to test vth3)
|
// mask with counter 3 disabled and enabled(to test vth3)
|
||||||
uint32_t fixedMask[2] = {0x2, 0x4};
|
uint32_t const fixedMask[2] = {0x2, 0x4};
|
||||||
for (int i = 0; i != 2; ++i) {
|
for (int i = 0; i != 2; ++i) {
|
||||||
det.setCounterMask(fixedMask[i]);
|
det.setCounterMask(fixedMask[i]);
|
||||||
{
|
{
|
||||||
@@ -532,7 +532,7 @@ TEST_CASE("interpolation", "[.cmdcall]") {
|
|||||||
REQUIRE(oss.str() == "interpolation 0\n");
|
REQUIRE(oss.str() == "interpolation 0\n");
|
||||||
REQUIRE(det.getCounterMask().tsquash(
|
REQUIRE(det.getCounterMask().tsquash(
|
||||||
"inconsistent counter mask") == fixedMask[i]);
|
"inconsistent counter mask") == fixedMask[i]);
|
||||||
int expectedVth3DacVal =
|
int const expectedVth3DacVal =
|
||||||
(fixedMask[i] & 0x4 ? fixedVth3DacVal : disabledDacValue);
|
(fixedMask[i] & 0x4 ? fixedVth3DacVal : disabledDacValue);
|
||||||
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
|
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
|
||||||
.tsquash("inconsistent vth3 dac value") ==
|
.tsquash("inconsistent vth3 dac value") ==
|
||||||
@@ -566,13 +566,13 @@ TEST_CASE("pumpprobe", "[.cmdcall]") {
|
|||||||
auto prev_vth2DacVal = det.getDAC(defs::VTH2, 0, {});
|
auto prev_vth2DacVal = det.getDAC(defs::VTH2, 0, {});
|
||||||
auto prev_vth3DacVal = det.getDAC(defs::VTH3, 0, {});
|
auto prev_vth3DacVal = det.getDAC(defs::VTH3, 0, {});
|
||||||
|
|
||||||
int disabledDacValue = 2800;
|
int const disabledDacValue = 2800;
|
||||||
auto fixedVthDacVal = 1000;
|
auto fixedVthDacVal = 1000;
|
||||||
det.setDAC(defs::VTH1, fixedVthDacVal, 0, {});
|
det.setDAC(defs::VTH1, fixedVthDacVal, 0, {});
|
||||||
det.setDAC(defs::VTH2, fixedVthDacVal, 0, {});
|
det.setDAC(defs::VTH2, fixedVthDacVal, 0, {});
|
||||||
det.setDAC(defs::VTH3, fixedVthDacVal, 0, {});
|
det.setDAC(defs::VTH3, fixedVthDacVal, 0, {});
|
||||||
// mask with counter 2 disabled and enabled(to test vth2)
|
// mask with counter 2 disabled and enabled(to test vth2)
|
||||||
uint32_t fixedMask[2] = {0x4, 0x3};
|
uint32_t const fixedMask[2] = {0x4, 0x3};
|
||||||
for (int i = 0; i != 2; ++i) {
|
for (int i = 0; i != 2; ++i) {
|
||||||
std::cout << "i:" << i << std::endl;
|
std::cout << "i:" << i << std::endl;
|
||||||
det.setCounterMask(fixedMask[i]);
|
det.setCounterMask(fixedMask[i]);
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ TEST_CASE("patword", "[.cmdcall]") {
|
|||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD ||
|
if (det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::XILINX_CHIPTESTBOARD || det_type == defs::MYTHEN3) {
|
det_type == defs::XILINX_CHIPTESTBOARD || det_type == defs::MYTHEN3) {
|
||||||
int addr = 0x23;
|
int const addr = 0x23;
|
||||||
std::string saddr = ToStringHex(addr, 4);
|
std::string const saddr = ToStringHex(addr, 4);
|
||||||
auto prev_val = det.getPatternWord(addr);
|
auto prev_val = det.getPatternWord(addr);
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@@ -189,9 +189,9 @@ TEST_CASE("patloop", "[.cmdcall]") {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto prev_val = det.getPatternLoopAddresses(iLoop);
|
auto prev_val = det.getPatternLoopAddresses(iLoop);
|
||||||
std::string sLoop = ToString(iLoop);
|
std::string const sLoop = ToString(iLoop);
|
||||||
if (iLoop < 3) {
|
if (iLoop < 3) {
|
||||||
std::string deprecatedCmd = "patloop" + sLoop;
|
std::string const deprecatedCmd = "patloop" + sLoop;
|
||||||
{ // deprecated
|
{ // deprecated
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
caller.call(deprecatedCmd, {"0x20", "0x5c"}, -1, PUT, oss);
|
caller.call(deprecatedCmd, {"0x20", "0x5c"}, -1, PUT, oss);
|
||||||
@@ -238,9 +238,9 @@ TEST_CASE("patnloop", "[.cmdcall]") {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto prev_val = det.getPatternLoopCycles(iLoop);
|
auto prev_val = det.getPatternLoopCycles(iLoop);
|
||||||
std::string sLoop = ToString(iLoop);
|
std::string const sLoop = ToString(iLoop);
|
||||||
if (iLoop < 3) {
|
if (iLoop < 3) {
|
||||||
std::string deprecatedCmd = "patnloop" + sLoop;
|
std::string const deprecatedCmd = "patnloop" + sLoop;
|
||||||
{ // deprecated
|
{ // deprecated
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
caller.call(deprecatedCmd, {"5"}, -1, PUT, oss);
|
caller.call(deprecatedCmd, {"5"}, -1, PUT, oss);
|
||||||
@@ -284,9 +284,9 @@ TEST_CASE("patwait", "[.cmdcall]") {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto prev_val = det.getPatternWaitAddr(iLoop);
|
auto prev_val = det.getPatternWaitAddr(iLoop);
|
||||||
std::string sLoop = ToString(iLoop);
|
std::string const sLoop = ToString(iLoop);
|
||||||
if (iLoop < 3) {
|
if (iLoop < 3) {
|
||||||
std::string deprecatedCmd = "patwait" + sLoop;
|
std::string const deprecatedCmd = "patwait" + sLoop;
|
||||||
{ // deprecated
|
{ // deprecated
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
caller.call(deprecatedCmd, {"0x5c"}, -1, PUT, oss);
|
caller.call(deprecatedCmd, {"0x5c"}, -1, PUT, oss);
|
||||||
@@ -330,9 +330,9 @@ TEST_CASE("patwaittime", "[.cmdcall]") {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto prev_val = det.getPatternWaitClocks(iLoop);
|
auto prev_val = det.getPatternWaitClocks(iLoop);
|
||||||
std::string sLoop = ToString(iLoop);
|
std::string const sLoop = ToString(iLoop);
|
||||||
if (iLoop < 3) {
|
if (iLoop < 3) {
|
||||||
std::string deprecatedCmd = "patwaittime" + sLoop;
|
std::string const deprecatedCmd = "patwaittime" + sLoop;
|
||||||
{ // deprecated
|
{ // deprecated
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
caller.call(deprecatedCmd, {"8589936640"}, -1, PUT, oss);
|
caller.call(deprecatedCmd, {"8589936640"}, -1, PUT, oss);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ TEST_CASE("rx_version", "[.cmdcall][.rx]") {
|
|||||||
Caller caller(&det);
|
Caller caller(&det);
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
caller.call("rx_version", {}, -1, GET, oss);
|
caller.call("rx_version", {}, -1, GET, oss);
|
||||||
sls::Version v(APIRECEIVER);
|
sls::Version const v(APIRECEIVER);
|
||||||
std::ostringstream vs;
|
std::ostringstream vs;
|
||||||
vs << "rx_version " << v.concise() << '\n';
|
vs << "rx_version " << v.concise() << '\n';
|
||||||
REQUIRE(oss.str() == vs.str());
|
REQUIRE(oss.str() == vs.str());
|
||||||
@@ -365,9 +365,9 @@ TEST_CASE("rx_padding", "[.cmdcall][.rx]") {
|
|||||||
TEST_CASE("rx_udpsocksize", "[.cmdcall][.rx]") {
|
TEST_CASE("rx_udpsocksize", "[.cmdcall][.rx]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
Caller caller(&det);
|
Caller caller(&det);
|
||||||
int64_t prev_val = det.getRxUDPSocketBufferSize().tsquash(
|
int64_t const prev_val = det.getRxUDPSocketBufferSize().tsquash(
|
||||||
"Need same udp socket buffer size to test");
|
"Need same udp socket buffer size to test");
|
||||||
std::string s_new_val = std::to_string(prev_val);
|
std::string const s_new_val = std::to_string(prev_val);
|
||||||
/*std::string s_new_val = std::to_string(prev_val - 1000);
|
/*std::string s_new_val = std::to_string(prev_val - 1000);
|
||||||
{ Need permissions
|
{ Need permissions
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@@ -389,14 +389,14 @@ TEST_CASE("rx_realudpsocksize", "[.cmdcall][.rx]") {
|
|||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
caller.call("rx_udpsocksize", {}, -1, GET, oss);
|
caller.call("rx_udpsocksize", {}, -1, GET, oss);
|
||||||
std::string s = (oss.str()).erase(0, strlen("rx_udpsocksize "));
|
std::string const s = (oss.str()).erase(0, strlen("rx_udpsocksize "));
|
||||||
val = std::stol(s);
|
val = std::stol(s);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
caller.call("rx_realudpsocksize", {}, -1, GET, oss);
|
caller.call("rx_realudpsocksize", {}, -1, GET, oss);
|
||||||
std::string s = (oss.str()).erase(0, strlen("rx_realudpsocksize "));
|
std::string const s = (oss.str()).erase(0, strlen("rx_realudpsocksize "));
|
||||||
uint64_t rval = std::stol(s);
|
uint64_t const rval = std::stol(s);
|
||||||
REQUIRE(rval >= val * 2);
|
REQUIRE(rval >= val * 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -476,10 +476,10 @@ TEST_CASE("rx_roi", "[.cmdcall]") {
|
|||||||
REQUIRE_THROWS(caller.call("rx_roi", {"5", "10"}, -1, PUT));
|
REQUIRE_THROWS(caller.call("rx_roi", {"5", "10"}, -1, PUT));
|
||||||
} else {
|
} else {
|
||||||
auto prev_val = det.getRxROI();
|
auto prev_val = det.getRxROI();
|
||||||
defs::xy detsize = det.getDetectorSize();
|
defs::xy const detsize = det.getDetectorSize();
|
||||||
auto portSize = det.getPortSize()[0];
|
auto portSize = det.getPortSize()[0];
|
||||||
int delta = 50;
|
int const delta = 50;
|
||||||
int numinterfaces = det.getNumberofUDPInterfaces().tsquash(
|
int const numinterfaces = det.getNumberofUDPInterfaces().tsquash(
|
||||||
"inconsistent number of interfaces");
|
"inconsistent number of interfaces");
|
||||||
|
|
||||||
// 1d
|
// 1d
|
||||||
@@ -757,11 +757,11 @@ TEST_CASE("rx_roi", "[.cmdcall]") {
|
|||||||
// TODO: check roi in master file
|
// TODO: check roi in master file
|
||||||
{
|
{
|
||||||
REQUIRE_NOTHROW(create_files_for_acquire(det, caller));
|
REQUIRE_NOTHROW(create_files_for_acquire(det, caller));
|
||||||
testFileInfo file_info;
|
testFileInfo const file_info;
|
||||||
std::string master_file_prefix =
|
std::string const master_file_prefix =
|
||||||
file_info.getMasterFileNamePrefix();
|
file_info.getMasterFileNamePrefix();
|
||||||
|
|
||||||
std::string fname = master_file_prefix + ".json";
|
std::string const fname = master_file_prefix + ".json";
|
||||||
REQUIRE(std::filesystem::exists(fname) == true);
|
REQUIRE(std::filesystem::exists(fname) == true);
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
fname = master_file_prefix + ".h5";
|
fname = master_file_prefix + ".h5";
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ TEST_CASE("Calling help doesn't throw or cause segfault") {
|
|||||||
// Dont add [.cmdcall] tag this should run with normal tests
|
// Dont add [.cmdcall] tag this should run with normal tests
|
||||||
Caller caller(nullptr);
|
Caller caller(nullptr);
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
for (std::string cmd : caller.getAllCommands())
|
for (std::string const& cmd : caller.getAllCommands())
|
||||||
REQUIRE_NOTHROW(
|
REQUIRE_NOTHROW(
|
||||||
caller.call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os));
|
caller.call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os));
|
||||||
}
|
}
|
||||||
@@ -46,46 +46,32 @@ TEST_CASE("config", "[.cmdcall]") {
|
|||||||
|
|
||||||
// free: not testing
|
// free: not testing
|
||||||
|
|
||||||
void test_include_file(const std::string &cmd) {
|
TEST_CASE("parameters", "[.cmdcall]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
Caller caller(&det);
|
Caller caller(&det);
|
||||||
|
|
||||||
// put only
|
// put only
|
||||||
REQUIRE_THROWS(caller.call(cmd, {}, -1, GET));
|
REQUIRE_THROWS(caller.call("parameters", {}, -1, GET));
|
||||||
|
/*
|
||||||
auto prev_frames = det.getNumberOfFrames().tsquash(
|
auto prev_val = det.getNumberOfFrames().tsquash("Number of frames has to
|
||||||
"Number of frames has to be same to test");
|
be same to test");
|
||||||
auto prev_fwrite =
|
{
|
||||||
det.getFileWrite().tsquash("File write enable has to be same to test");
|
system("echo 'frames 2' > /tmp/tempsetup.det ");
|
||||||
|
std::ostringstream oss;
|
||||||
{
|
caller.call("parameters", {"/tmp/tempsetup.det"}, -1, PUT, oss);
|
||||||
system("echo -e 'frames 2\nfwrite 1' > /tmp/tempsetup.det ");
|
REQUIRE(oss.str() == "parameters /tmp/tempsetup.det\n");
|
||||||
std::ostringstream oss;
|
REQUIRE(det.getNumberOfFrames().tsquash("failed") == 2);
|
||||||
caller.call(cmd, {"/tmp/tempsetup.det"}, -1, PUT, oss);
|
}
|
||||||
REQUIRE(oss.str() == cmd + " /tmp/tempsetup.det\n");
|
{
|
||||||
REQUIRE(det.getNumberOfFrames().tsquash(
|
system("echo '0:frames 1' > /tmp/tempsetup.det ");
|
||||||
"frames inconsistent and failed") == 2);
|
std::ostringstream oss;
|
||||||
REQUIRE(det.getFileWrite().tsquash("fwrite inconsistent and failed") ==
|
caller.call("parameters", {"/tmp/tempsetup.det"}, -1, PUT, oss);
|
||||||
1);
|
REQUIRE(oss.str() == "parameters /tmp/tempsetup.det\n");
|
||||||
}
|
REQUIRE(det.getNumberOfFrames({0}).tsquash("failed") == 1);
|
||||||
{
|
}
|
||||||
system("echo -e 'frames 3\nfwrite 0' > /tmp/tempsetup.det ");
|
det.setNumberOfFrames(prev_val);
|
||||||
std::ostringstream oss;
|
*/
|
||||||
caller.call(cmd, {"/tmp/tempsetup.det"}, -1, PUT, oss);
|
|
||||||
REQUIRE(oss.str() == cmd + " /tmp/tempsetup.det\n");
|
|
||||||
REQUIRE(det.getNumberOfFrames().tsquash(
|
|
||||||
"frames inconsistent and failed") == 3);
|
|
||||||
REQUIRE(det.getFileWrite().tsquash("fwrite inconsistent and failed") ==
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
det.setNumberOfFrames(prev_frames);
|
|
||||||
det.setFileWrite(prev_fwrite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("parameters", "[.cmdcall]") { test_include_file("parameters"); }
|
|
||||||
|
|
||||||
TEST_CASE("include", "[.cmdcall]") { test_include_file("include"); }
|
|
||||||
|
|
||||||
TEST_CASE("hostname", "[.cmdcall]") {
|
TEST_CASE("hostname", "[.cmdcall]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
Caller caller(&det);
|
Caller caller(&det);
|
||||||
@@ -305,7 +291,7 @@ TEST_CASE("threshold", "[.cmdcall]") {
|
|||||||
auto prev_energies =
|
auto prev_energies =
|
||||||
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
||||||
if (!prev_energies.empty()) {
|
if (!prev_energies.empty()) {
|
||||||
std::string senergy = std::to_string(prev_energies[0]);
|
std::string const senergy = std::to_string(prev_energies[0]);
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
caller.call("threshold", {senergy, "standard"}, -1, PUT, oss1);
|
caller.call("threshold", {senergy, "standard"}, -1, PUT, oss1);
|
||||||
REQUIRE(oss1.str() == "threshold [" + senergy + ", standard]\n");
|
REQUIRE(oss1.str() == "threshold [" + senergy + ", standard]\n");
|
||||||
@@ -333,15 +319,15 @@ TEST_CASE("threshold", "[.cmdcall]") {
|
|||||||
auto prev_energies =
|
auto prev_energies =
|
||||||
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
||||||
if (!prev_energies.empty()) {
|
if (!prev_energies.empty()) {
|
||||||
std::string senergy = std::to_string(prev_energies[0]);
|
std::string const senergy = std::to_string(prev_energies[0]);
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
caller.call("threshold", {senergy, "standard"}, -1, PUT, oss1);
|
caller.call("threshold", {senergy, "standard"}, -1, PUT, oss1);
|
||||||
REQUIRE(oss1.str() == "threshold [" + senergy + ", standard]\n");
|
REQUIRE(oss1.str() == "threshold [" + senergy + ", standard]\n");
|
||||||
caller.call("threshold", {}, -1, GET, oss2);
|
caller.call("threshold", {}, -1, GET, oss2);
|
||||||
REQUIRE(oss2.str() == "threshold [" + senergy + ", " + senergy +
|
REQUIRE(oss2.str() == "threshold [" + senergy + ", " + senergy +
|
||||||
", " + senergy + "]\n");
|
", " + senergy + "]\n");
|
||||||
std::string senergy2 = std::to_string(prev_energies[1]);
|
std::string const senergy2 = std::to_string(prev_energies[1]);
|
||||||
std::string senergy3 = std::to_string(prev_energies[2]);
|
std::string const senergy3 = std::to_string(prev_energies[2]);
|
||||||
std::ostringstream oss3, oss4;
|
std::ostringstream oss3, oss4;
|
||||||
caller.call("threshold", {senergy, senergy2, senergy3, "standard"},
|
caller.call("threshold", {senergy, senergy2, senergy3, "standard"},
|
||||||
-1, PUT, oss3);
|
-1, PUT, oss3);
|
||||||
@@ -384,7 +370,7 @@ TEST_CASE("thresholdnotb", "[.cmdcall]") {
|
|||||||
auto prev_energies =
|
auto prev_energies =
|
||||||
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
||||||
if (!prev_energies.empty()) {
|
if (!prev_energies.empty()) {
|
||||||
std::string senergy = std::to_string(prev_energies[0]);
|
std::string const senergy = std::to_string(prev_energies[0]);
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
caller.call("thresholdnotb", {senergy, "standard"}, -1, PUT, oss1);
|
caller.call("thresholdnotb", {senergy, "standard"}, -1, PUT, oss1);
|
||||||
REQUIRE(oss1.str() ==
|
REQUIRE(oss1.str() ==
|
||||||
@@ -412,7 +398,7 @@ TEST_CASE("thresholdnotb", "[.cmdcall]") {
|
|||||||
auto prev_energies =
|
auto prev_energies =
|
||||||
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
||||||
if (!prev_energies.empty()) {
|
if (!prev_energies.empty()) {
|
||||||
std::string senergy = std::to_string(prev_energies[0]);
|
std::string const senergy = std::to_string(prev_energies[0]);
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
caller.call("thresholdnotb", {senergy, "standard"}, -1, PUT, oss1);
|
caller.call("thresholdnotb", {senergy, "standard"}, -1, PUT, oss1);
|
||||||
REQUIRE(oss1.str() ==
|
REQUIRE(oss1.str() ==
|
||||||
@@ -420,8 +406,8 @@ TEST_CASE("thresholdnotb", "[.cmdcall]") {
|
|||||||
caller.call("threshold", {}, -1, GET, oss2);
|
caller.call("threshold", {}, -1, GET, oss2);
|
||||||
REQUIRE(oss2.str() == "threshold [" + senergy + ", " + senergy +
|
REQUIRE(oss2.str() == "threshold [" + senergy + ", " + senergy +
|
||||||
", " + senergy + "]\n");
|
", " + senergy + "]\n");
|
||||||
std::string senergy2 = std::to_string(prev_energies[1]);
|
std::string const senergy2 = std::to_string(prev_energies[1]);
|
||||||
std::string senergy3 = std::to_string(prev_energies[2]);
|
std::string const senergy3 = std::to_string(prev_energies[2]);
|
||||||
std::ostringstream oss3, oss4;
|
std::ostringstream oss3, oss4;
|
||||||
caller.call("thresholdnotb",
|
caller.call("thresholdnotb",
|
||||||
{senergy, senergy2, senergy3, "standard"}, -1, PUT,
|
{senergy, senergy2, senergy3, "standard"}, -1, PUT,
|
||||||
@@ -542,8 +528,8 @@ TEST_CASE("gappixels", "[.cmdcall]") {
|
|||||||
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH)
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH)
|
||||||
gapPixelTest = true;
|
gapPixelTest = true;
|
||||||
else if (det_type == defs::EIGER) {
|
else if (det_type == defs::EIGER) {
|
||||||
bool quad = det.getQuad().squash(false);
|
bool const quad = det.getQuad().squash(false);
|
||||||
bool fullModule = (det.getModuleGeometry().y % 2 == 0);
|
bool const fullModule = (det.getModuleGeometry().y % 2 == 0);
|
||||||
if (quad || fullModule) {
|
if (quad || fullModule) {
|
||||||
gapPixelTest = true;
|
gapPixelTest = true;
|
||||||
}
|
}
|
||||||
@@ -672,9 +658,9 @@ TEST_CASE("badchannels", "[.cmdcall]") {
|
|||||||
|
|
||||||
REQUIRE_THROWS(caller.call("badchannels", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("badchannels", {}, -1, GET));
|
||||||
|
|
||||||
std::string fname_put =
|
std::string const fname_put =
|
||||||
getAbsolutePathFromCurrentProcess(TEST_FILE_NAME_BAD_CHANNELS);
|
getAbsolutePathFromCurrentProcess(TEST_FILE_NAME_BAD_CHANNELS);
|
||||||
std::string fname_get = "/tmp/sls_test_channels.txt";
|
std::string const fname_get = "/tmp/sls_test_channels.txt";
|
||||||
|
|
||||||
REQUIRE_NOTHROW(caller.call("badchannels", {fname_put}, 0, PUT));
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_put}, 0, PUT));
|
||||||
REQUIRE_NOTHROW(caller.call("badchannels", {fname_get}, 0, GET));
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_get}, 0, GET));
|
||||||
@@ -990,7 +976,7 @@ TEST_CASE("dr", "[.cmdcall]") {
|
|||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::EIGER) {
|
if (det_type == defs::EIGER) {
|
||||||
auto dr = det.getDynamicRange().squash();
|
auto dr = det.getDynamicRange().squash();
|
||||||
std::array<int, 4> vals{4, 8, 16, 32};
|
std::array<int, 4> const vals{4, 8, 16, 32};
|
||||||
for (const auto val : vals) {
|
for (const auto val : vals) {
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
caller.call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
caller.call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
||||||
@@ -1002,7 +988,7 @@ TEST_CASE("dr", "[.cmdcall]") {
|
|||||||
} else if (det_type == defs::MYTHEN3) {
|
} else if (det_type == defs::MYTHEN3) {
|
||||||
auto dr = det.getDynamicRange().squash();
|
auto dr = det.getDynamicRange().squash();
|
||||||
// not updated in firmware to support dr 1
|
// not updated in firmware to support dr 1
|
||||||
std::array<int, 3> vals{8, 16, 32};
|
std::array<int, 3> const vals{8, 16, 32};
|
||||||
for (const auto val : vals) {
|
for (const auto val : vals) {
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
caller.call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
caller.call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
||||||
@@ -1556,7 +1542,7 @@ TEST_CASE("powerchip", "[.cmdcall]") {
|
|||||||
"Inconsistent virtual detector "
|
"Inconsistent virtual detector "
|
||||||
"server to test powerchip command")) {
|
"server to test powerchip command")) {
|
||||||
det.setPowerChip(1);
|
det.setPowerChip(1);
|
||||||
int hv = det.getHighVoltage().tsquash(
|
int const hv = det.getHighVoltage().tsquash(
|
||||||
"Inconsistent high voltage to test "
|
"Inconsistent high voltage to test "
|
||||||
"powerchip command");
|
"powerchip command");
|
||||||
|
|
||||||
@@ -1990,7 +1976,7 @@ TEST_CASE("temp_adc", "[.cmdcall]") {
|
|||||||
REQUIRE_NOTHROW(caller.call("temp_adc", {}, -1, GET));
|
REQUIRE_NOTHROW(caller.call("temp_adc", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(caller.call("temp_adc", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(caller.call("temp_adc", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase(0, strlen("temp_adc "));
|
std::string const s = (oss.str()).erase(0, strlen("temp_adc "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(caller.call("temp_adc", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("temp_adc", {}, -1, GET));
|
||||||
@@ -2005,7 +1991,7 @@ TEST_CASE("temp_fpga", "[.cmdcall]") {
|
|||||||
REQUIRE_NOTHROW(caller.call("temp_fpga", {}, -1, GET));
|
REQUIRE_NOTHROW(caller.call("temp_fpga", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(caller.call("temp_fpga", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(caller.call("temp_fpga", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase(0, strlen("temp_fpga "));
|
std::string const s = (oss.str()).erase(0, strlen("temp_fpga "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(caller.call("temp_fpga", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("temp_fpga", {}, -1, GET));
|
||||||
@@ -2089,7 +2075,7 @@ TEST_CASE("defaultdac", "[.cmdcall]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (det_type == defs::JUNGFRAU) {
|
if (det_type == defs::JUNGFRAU) {
|
||||||
std::vector<defs::dacIndex> daclist = {
|
std::vector<defs::dacIndex> const daclist = {
|
||||||
defs::VREF_PRECH, defs::VREF_DS, defs::VREF_COMP};
|
defs::VREF_PRECH, defs::VREF_DS, defs::VREF_COMP};
|
||||||
for (auto it : daclist) {
|
for (auto it : daclist) {
|
||||||
auto dacname = ToString(it);
|
auto dacname = ToString(it);
|
||||||
@@ -2969,7 +2955,7 @@ TEST_CASE("txdelay_frame", "[.cmdcall]") {
|
|||||||
det_type == defs::MYTHEN3) {
|
det_type == defs::MYTHEN3) {
|
||||||
val = 5;
|
val = 5;
|
||||||
}
|
}
|
||||||
std::string sval = std::to_string(val);
|
std::string const sval = std::to_string(val);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
caller.call("txdelay_frame", {sval}, -1, PUT, oss1);
|
caller.call("txdelay_frame", {sval}, -1, PUT, oss1);
|
||||||
@@ -2997,8 +2983,8 @@ TEST_CASE("txdelay", "[.cmdcall]") {
|
|||||||
det_type == defs::MYTHEN3) &&
|
det_type == defs::MYTHEN3) &&
|
||||||
(det.size() < 2)) {
|
(det.size() < 2)) {
|
||||||
REQUIRE_THROWS(caller.call("txdelay", {}, -1, GET));
|
REQUIRE_THROWS(caller.call("txdelay", {}, -1, GET));
|
||||||
int val = 5;
|
int const val = 5;
|
||||||
std::string sval = std::to_string(val);
|
std::string const sval = std::to_string(val);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1;
|
std::ostringstream oss1;
|
||||||
caller.call("txdelay", {sval}, -1, PUT, oss1);
|
caller.call("txdelay", {sval}, -1, PUT, oss1);
|
||||||
@@ -3020,7 +3006,7 @@ TEST_CASE("txdelay", "[.cmdcall]") {
|
|||||||
det_type == defs::MYTHEN3) {
|
det_type == defs::MYTHEN3) {
|
||||||
val = 5;
|
val = 5;
|
||||||
}
|
}
|
||||||
std::string sval = std::to_string(val);
|
std::string const sval = std::to_string(val);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
caller.call("txdelay", {sval}, -1, PUT, oss1);
|
caller.call("txdelay", {sval}, -1, PUT, oss1);
|
||||||
@@ -3293,7 +3279,7 @@ TEST_CASE("reg", "[.cmdcall]") {
|
|||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
addr = 0x298;
|
addr = 0x298;
|
||||||
}
|
}
|
||||||
std::string saddr = ToStringHex(addr);
|
std::string const saddr = ToStringHex(addr);
|
||||||
auto prev_val = det.readRegister(addr);
|
auto prev_val = det.readRegister(addr);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
@@ -3352,7 +3338,7 @@ TEST_CASE("setbit", "[.cmdcall]") {
|
|||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
addr = 0x298;
|
addr = 0x298;
|
||||||
}
|
}
|
||||||
std::string saddr = ToStringHex(addr);
|
std::string const saddr = ToStringHex(addr);
|
||||||
auto prev_val = det.readRegister(addr);
|
auto prev_val = det.readRegister(addr);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2, oss3;
|
std::ostringstream oss1, oss2, oss3;
|
||||||
@@ -3382,7 +3368,7 @@ TEST_CASE("clearbit", "[.cmdcall]") {
|
|||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
addr = 0x298;
|
addr = 0x298;
|
||||||
}
|
}
|
||||||
std::string saddr = ToStringHex(addr);
|
std::string const saddr = ToStringHex(addr);
|
||||||
auto prev_val = det.readRegister(addr);
|
auto prev_val = det.readRegister(addr);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2, oss3;
|
std::ostringstream oss1, oss2, oss3;
|
||||||
@@ -3412,7 +3398,7 @@ TEST_CASE("getbit", "[.cmdcall]") {
|
|||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
addr = 0x298;
|
addr = 0x298;
|
||||||
}
|
}
|
||||||
std::string saddr = ToStringHex(addr);
|
std::string const saddr = ToStringHex(addr);
|
||||||
auto prev_val = det.readRegister(addr);
|
auto prev_val = det.readRegister(addr);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ using vs = std::vector<std::string>;
|
|||||||
|
|
||||||
SCENARIO("Construction", "[support]") {
|
SCENARIO("Construction", "[support]") {
|
||||||
GIVEN("A default constructed CmdParser") {
|
GIVEN("A default constructed CmdParser") {
|
||||||
CmdParser p;
|
CmdParser const p;
|
||||||
THEN("The state of the object is valid") {
|
THEN("The state of the object is valid") {
|
||||||
REQUIRE(p.detector_id() == -1);
|
REQUIRE(p.detector_id() == -1);
|
||||||
REQUIRE(p.multi_id() == 0);
|
REQUIRE(p.multi_id() == 0);
|
||||||
@@ -31,7 +31,7 @@ SCENARIO("Parsing a string with the command line parser", "[support]") {
|
|||||||
GIVEN("A CmdParser") {
|
GIVEN("A CmdParser") {
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
WHEN("Parsing an empty string") {
|
WHEN("Parsing an empty string") {
|
||||||
std::string s;
|
std::string const s;
|
||||||
p.Parse(s);
|
p.Parse(s);
|
||||||
THEN("command and arguments are empty") {
|
THEN("command and arguments are empty") {
|
||||||
REQUIRE(p.detector_id() == -1);
|
REQUIRE(p.detector_id() == -1);
|
||||||
@@ -42,7 +42,7 @@ SCENARIO("Parsing a string with the command line parser", "[support]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Parsing a string with a single command") {
|
WHEN("Parsing a string with a single command") {
|
||||||
std::string s = "vrf";
|
std::string const s = "vrf";
|
||||||
p.Parse(s);
|
p.Parse(s);
|
||||||
THEN("command is assigned and id's remain default") {
|
THEN("command is assigned and id's remain default") {
|
||||||
REQUIRE(p.command() == "vrf");
|
REQUIRE(p.command() == "vrf");
|
||||||
@@ -53,7 +53,7 @@ SCENARIO("Parsing a string with the command line parser", "[support]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Parsing a string with command and value") {
|
WHEN("Parsing a string with command and value") {
|
||||||
std::string s = "vthreshold 1500";
|
std::string const s = "vthreshold 1500";
|
||||||
p.Parse(s);
|
p.Parse(s);
|
||||||
THEN("cmd and value are assigned and id's remain default") {
|
THEN("cmd and value are assigned and id's remain default") {
|
||||||
REQUIRE(p.command() == "vthreshold");
|
REQUIRE(p.command() == "vthreshold");
|
||||||
@@ -98,7 +98,7 @@ SCENARIO("Parsing a string with the command line parser", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WHEN("Parsing string with cmd and multiple arguments") {
|
WHEN("Parsing string with cmd and multiple arguments") {
|
||||||
std::string s = "trimen 5000 6000 7000";
|
std::string const s = "trimen 5000 6000 7000";
|
||||||
p.Parse(s);
|
p.Parse(s);
|
||||||
THEN("cmd and args are correct") {
|
THEN("cmd and args are correct") {
|
||||||
REQUIRE(p.command() == "trimen");
|
REQUIRE(p.command() == "trimen");
|
||||||
@@ -115,7 +115,7 @@ SCENARIO("Parsing strings with -h or --help", "[support]") {
|
|||||||
GIVEN("A parser") {
|
GIVEN("A parser") {
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
WHEN("Parsing a string with a command and help ") {
|
WHEN("Parsing a string with a command and help ") {
|
||||||
std::string s = "-h list";
|
std::string const s = "-h list";
|
||||||
|
|
||||||
THEN("the command is correct and isHelp is set") {
|
THEN("the command is correct and isHelp is set") {
|
||||||
p.Parse(s);
|
p.Parse(s);
|
||||||
@@ -128,7 +128,7 @@ SCENARIO("Parsing strings with -h or --help", "[support]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Parsing a string with -h at a different position") {
|
WHEN("Parsing a string with -h at a different position") {
|
||||||
std::string s = "list -h something";
|
std::string const s = "list -h something";
|
||||||
THEN("its also done right") {
|
THEN("its also done right") {
|
||||||
p.Parse(s);
|
p.Parse(s);
|
||||||
REQUIRE(p.isHelp());
|
REQUIRE(p.isHelp());
|
||||||
@@ -138,7 +138,7 @@ SCENARIO("Parsing strings with -h or --help", "[support]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Parsing a string with -help at a different position") {
|
WHEN("Parsing a string with -help at a different position") {
|
||||||
std::string s = "list --help something";
|
std::string const s = "list --help something";
|
||||||
THEN("its also done right") {
|
THEN("its also done right") {
|
||||||
p.Parse(s);
|
p.Parse(s);
|
||||||
REQUIRE(p.isHelp());
|
REQUIRE(p.isHelp());
|
||||||
@@ -186,7 +186,7 @@ TEST_CASE("Parse with no arguments results in no command and default id",
|
|||||||
"[support]") {
|
"[support]") {
|
||||||
// build up argc and argv
|
// build up argc and argv
|
||||||
// first argument is the command used to call the binary
|
// first argument is the command used to call the binary
|
||||||
int argc = 1;
|
int const argc = 1;
|
||||||
const char *const argv[]{"call"};
|
const char *const argv[]{"call"};
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
p.Parse(argc, argv);
|
p.Parse(argc, argv);
|
||||||
@@ -200,7 +200,7 @@ TEST_CASE("Parse with no arguments results in no command and default id",
|
|||||||
TEST_CASE(
|
TEST_CASE(
|
||||||
"Parse a command without client id and detector id results in default",
|
"Parse a command without client id and detector id results in default",
|
||||||
"[support]") {
|
"[support]") {
|
||||||
int argc = 2;
|
int const argc = 2;
|
||||||
const char *const argv[]{"caller", "vrf"};
|
const char *const argv[]{"caller", "vrf"};
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
p.Parse(argc, argv);
|
p.Parse(argc, argv);
|
||||||
@@ -213,7 +213,7 @@ TEST_CASE(
|
|||||||
|
|
||||||
TEST_CASE("Parse a command with value but without client or detector id",
|
TEST_CASE("Parse a command with value but without client or detector id",
|
||||||
"[support]") {
|
"[support]") {
|
||||||
int argc = 3;
|
int const argc = 3;
|
||||||
const char *const argv[]{"caller", "vrf", "3000"};
|
const char *const argv[]{"caller", "vrf", "3000"};
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
p.Parse(argc, argv);
|
p.Parse(argc, argv);
|
||||||
@@ -226,7 +226,7 @@ TEST_CASE("Parse a command with value but without client or detector id",
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Decodes position") {
|
TEST_CASE("Decodes position") {
|
||||||
int argc = 2;
|
int const argc = 2;
|
||||||
const char *const argv[]{"caller", "7:vrf"};
|
const char *const argv[]{"caller", "7:vrf"};
|
||||||
|
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
@@ -239,7 +239,7 @@ TEST_CASE("Decodes position") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Decodes double digit position", "[support]") {
|
TEST_CASE("Decodes double digit position", "[support]") {
|
||||||
int argc = 2;
|
int const argc = 2;
|
||||||
const char *const argv[]{"caller", "73:vcmp"};
|
const char *const argv[]{"caller", "73:vcmp"};
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
p.Parse(argc, argv);
|
p.Parse(argc, argv);
|
||||||
@@ -251,7 +251,7 @@ TEST_CASE("Decodes double digit position", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Decodes position and id", "[support]") {
|
TEST_CASE("Decodes position and id", "[support]") {
|
||||||
int argc = 2;
|
int const argc = 2;
|
||||||
const char *const argv[]{"caller", "5-8:vrf"};
|
const char *const argv[]{"caller", "5-8:vrf"};
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
p.Parse(argc, argv);
|
p.Parse(argc, argv);
|
||||||
@@ -263,7 +263,7 @@ TEST_CASE("Decodes position and id", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Double digit id", "[support]") {
|
TEST_CASE("Double digit id", "[support]") {
|
||||||
int argc = 2;
|
int const argc = 2;
|
||||||
const char *const argv[]{"caller", "56-8:vrf"};
|
const char *const argv[]{"caller", "56-8:vrf"};
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
p.Parse(argc, argv);
|
p.Parse(argc, argv);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ TEST_CASE("Default construction") {
|
|||||||
(2 * sizeof(int) + (18 + 32 + 64 + 5 + 8) * 20),
|
(2 * sizeof(int) + (18 + 32 + 64 + 5 + 8) * 20),
|
||||||
"Size of CtbConfig does not match ");
|
"Size of CtbConfig does not match ");
|
||||||
|
|
||||||
CtbConfig c;
|
CtbConfig const c;
|
||||||
auto dacnames = c.getDacNames();
|
auto dacnames = c.getDacNames();
|
||||||
REQUIRE(dacnames.size() == 18);
|
REQUIRE(dacnames.size() == 18);
|
||||||
REQUIRE(dacnames[0] == "DAC0");
|
REQUIRE(dacnames[0] == "DAC0");
|
||||||
@@ -81,7 +81,7 @@ TEST_CASE("Copy a CTB config") {
|
|||||||
TEST_CASE("Move CtbConfig ") {
|
TEST_CASE("Move CtbConfig ") {
|
||||||
CtbConfig c1;
|
CtbConfig c1;
|
||||||
c1.setDacName(3, "yetanothername");
|
c1.setDacName(3, "yetanothername");
|
||||||
CtbConfig c2(std::move(c1));
|
CtbConfig const c2(std::move(c1));
|
||||||
REQUIRE(c2.getDacName(3) == "yetanothername");
|
REQUIRE(c2.getDacName(3) == "yetanothername");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace sls {
|
|||||||
using dt = slsDetectorDefs::detectorType;
|
using dt = slsDetectorDefs::detectorType;
|
||||||
TEST_CASE("Construction with a defined detector type") {
|
TEST_CASE("Construction with a defined detector type") {
|
||||||
freeSharedMemory(0, 0); // clean up to start test
|
freeSharedMemory(0, 0); // clean up to start test
|
||||||
Module m(dt::EIGER);
|
Module const m(dt::EIGER);
|
||||||
REQUIRE(m.getDetectorType() == dt::EIGER);
|
REQUIRE(m.getDetectorType() == dt::EIGER);
|
||||||
freeSharedMemory(0, 0); // clean up
|
freeSharedMemory(0, 0); // clean up
|
||||||
SharedMemory<sharedModule> moduleShm(0, 0);
|
SharedMemory<sharedModule> moduleShm(0, 0);
|
||||||
@@ -19,10 +19,10 @@ TEST_CASE("Construction with a defined detector type") {
|
|||||||
|
|
||||||
TEST_CASE("Read back detector type from shm") {
|
TEST_CASE("Read back detector type from shm") {
|
||||||
// Create specific detector in order to create shm
|
// Create specific detector in order to create shm
|
||||||
Module m(dt::JUNGFRAU);
|
Module const m(dt::JUNGFRAU);
|
||||||
|
|
||||||
// New detector that reads type from shm
|
// New detector that reads type from shm
|
||||||
Module m2;
|
Module const m2;
|
||||||
REQUIRE(m2.getDetectorType() == dt::JUNGFRAU);
|
REQUIRE(m2.getDetectorType() == dt::JUNGFRAU);
|
||||||
|
|
||||||
// Now both objects point to the same shm so we can only
|
// Now both objects point to the same shm so we can only
|
||||||
@@ -33,7 +33,7 @@ TEST_CASE("Read back detector type from shm") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Is shm fixed pattern shm compatible") {
|
TEST_CASE("Is shm fixed pattern shm compatible") {
|
||||||
Module m(dt::JUNGFRAU);
|
Module const m(dt::JUNGFRAU);
|
||||||
|
|
||||||
// Should be true since we just created the shm
|
// Should be true since we just created the shm
|
||||||
REQUIRE(m.isFixedPatternSharedMemoryCompatible() == true);
|
REQUIRE(m.isFixedPatternSharedMemoryCompatible() == true);
|
||||||
@@ -53,7 +53,7 @@ TEST_CASE("Is shm fixed pattern shm compatible") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Get default control port") {
|
TEST_CASE("Get default control port") {
|
||||||
Module m(dt::MYTHEN3);
|
Module const m(dt::MYTHEN3);
|
||||||
REQUIRE(m.getControlPort() == 1952);
|
REQUIRE(m.getControlPort() == 1952);
|
||||||
freeSharedMemory(0, 0);
|
freeSharedMemory(0, 0);
|
||||||
SharedMemory<sharedModule> moduleShm(0, 0);
|
SharedMemory<sharedModule> moduleShm(0, 0);
|
||||||
@@ -61,7 +61,7 @@ TEST_CASE("Get default control port") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Get default stop port") {
|
TEST_CASE("Get default stop port") {
|
||||||
Module m(dt::GOTTHARD2);
|
Module const m(dt::GOTTHARD2);
|
||||||
REQUIRE(m.getStopPort() == 1953);
|
REQUIRE(m.getStopPort() == 1953);
|
||||||
freeSharedMemory(0, 0);
|
freeSharedMemory(0, 0);
|
||||||
SharedMemory<sharedModule> moduleShm(0, 0);
|
SharedMemory<sharedModule> moduleShm(0, 0);
|
||||||
@@ -69,7 +69,7 @@ TEST_CASE("Get default stop port") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Get default receiver TCP port") {
|
TEST_CASE("Get default receiver TCP port") {
|
||||||
Module m(dt::MYTHEN3);
|
Module const m(dt::MYTHEN3);
|
||||||
REQUIRE(m.getReceiverPort() == 1954);
|
REQUIRE(m.getReceiverPort() == 1954);
|
||||||
freeSharedMemory(0, 0);
|
freeSharedMemory(0, 0);
|
||||||
SharedMemory<sharedModule> moduleShm(0, 0);
|
SharedMemory<sharedModule> moduleShm(0, 0);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ TEST_CASE("Copy construct pattern") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Compare patterns") {
|
TEST_CASE("Compare patterns") {
|
||||||
Pattern p;
|
Pattern const p;
|
||||||
Pattern p1;
|
Pattern p1;
|
||||||
REQUIRE(p == p1);
|
REQUIRE(p == p1);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ TEST_CASE("Result looks and behaves like a standard container") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Default construction is possible and gives an empty result") {
|
TEST_CASE("Default construction is possible and gives an empty result") {
|
||||||
Result<int> res;
|
Result<int> const res;
|
||||||
REQUIRE(res.size() == 0);
|
REQUIRE(res.size() == 0);
|
||||||
REQUIRE(res.empty() == true);
|
REQUIRE(res.empty() == true);
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ TEST_CASE("Like vector it can be constructed from size and value") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Result can be iterated using modern syntax") {
|
TEST_CASE("Result can be iterated using modern syntax") {
|
||||||
Result<int> res{0, 1, 2, 3, 4, 5};
|
Result<int> const res{0, 1, 2, 3, 4, 5};
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto &r : res)
|
for (const auto &r : res)
|
||||||
@@ -46,28 +46,28 @@ TEST_CASE("Result can be iterated using modern syntax") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Calling squash on an empty Result produces default value") {
|
TEST_CASE("Calling squash on an empty Result produces default value") {
|
||||||
Result<double> res;
|
Result<double> const res;
|
||||||
REQUIRE(res.squash() == 0.);
|
REQUIRE(res.squash() == 0.);
|
||||||
|
|
||||||
Result<unsigned> res2;
|
Result<unsigned> const res2;
|
||||||
REQUIRE(res2.squash() == 0u);
|
REQUIRE(res2.squash() == 0u);
|
||||||
|
|
||||||
Result<std::string> res3;
|
Result<std::string> const res3;
|
||||||
REQUIRE(res3.squash() == "");
|
REQUIRE(res3.squash() == "");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("When equal squash gives the front value") {
|
TEST_CASE("When equal squash gives the front value") {
|
||||||
Result<int> res{3, 3, 3};
|
Result<int> const res{3, 3, 3};
|
||||||
REQUIRE(res.squash() == 3);
|
REQUIRE(res.squash() == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("When elements are not equal squash gives default value") {
|
TEST_CASE("When elements are not equal squash gives default value") {
|
||||||
Result<int> res{3, 3, 3, 5};
|
Result<int> const res{3, 3, 3, 5};
|
||||||
REQUIRE(res.squash() == 0);
|
REQUIRE(res.squash() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("String compare with squash") {
|
TEST_CASE("String compare with squash") {
|
||||||
Result<std::string> res{"hej", "hej", "hej"};
|
Result<std::string> const res{"hej", "hej", "hej"};
|
||||||
REQUIRE(res.squash() == "hej");
|
REQUIRE(res.squash() == "hej");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,13 +113,13 @@ TEST_CASE("Check if elements are equal") {
|
|||||||
|
|
||||||
TEST_CASE("Result can be converted to std::vector") {
|
TEST_CASE("Result can be converted to std::vector") {
|
||||||
Result<short> res{1, 2, 3, 4, 5};
|
Result<short> res{1, 2, 3, 4, 5};
|
||||||
std::vector<short> vec{1, 2, 3, 4, 5};
|
std::vector<short> const vec{1, 2, 3, 4, 5};
|
||||||
std::vector<short> vec2 = res;
|
std::vector<short> const vec2 = res;
|
||||||
REQUIRE(vec2 == vec);
|
REQUIRE(vec2 == vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Result can be printed using <<") {
|
TEST_CASE("Result can be printed using <<") {
|
||||||
Result<int> res{1, 2, 3};
|
Result<int> const res{1, 2, 3};
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << res;
|
os << res;
|
||||||
REQUIRE(os.str() == "[1, 2, 3]");
|
REQUIRE(os.str() == "[1, 2, 3]");
|
||||||
@@ -139,8 +139,8 @@ TEST_CASE("Convert from Result<int> to Result<ns>") {
|
|||||||
|
|
||||||
TEST_CASE("Result of vectors") {
|
TEST_CASE("Result of vectors") {
|
||||||
using VecVec = std::vector<std::vector<int>>;
|
using VecVec = std::vector<std::vector<int>>;
|
||||||
VecVec vecvec{{1, 2, 3}, {4, 5, 6}};
|
VecVec const vecvec{{1, 2, 3}, {4, 5, 6}};
|
||||||
Result<VecVec> res{vecvec};
|
Result<VecVec> const res{vecvec};
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Free function begin end") {
|
TEST_CASE("Free function begin end") {
|
||||||
@@ -159,30 +159,30 @@ TEST_CASE("Sorting a Result") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Printing Result<std::string>") {
|
TEST_CASE("Printing Result<std::string>") {
|
||||||
Result<std::string> res{"ein", "zwei", "drei"};
|
Result<std::string> const res{"ein", "zwei", "drei"};
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << res;
|
os << res;
|
||||||
REQUIRE(os.str() == "[ein, zwei, drei]");
|
REQUIRE(os.str() == "[ein, zwei, drei]");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Printing Result<int>") {
|
TEST_CASE("Printing Result<int>") {
|
||||||
Result<int> res{1, 2, 3};
|
Result<int> const res{1, 2, 3};
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << res;
|
os << res;
|
||||||
REQUIRE(os.str() == "[1, 2, 3]");
|
REQUIRE(os.str() == "[1, 2, 3]");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("String conversions") {
|
TEST_CASE("String conversions") {
|
||||||
Result<int> res{1, 2, 3};
|
Result<int> const res{1, 2, 3};
|
||||||
REQUIRE(ToString(res) == "[1, 2, 3]");
|
REQUIRE(ToString(res) == "[1, 2, 3]");
|
||||||
|
|
||||||
Result<std::string> res2{"one", "two", "three"};
|
Result<std::string> const res2{"one", "two", "three"};
|
||||||
REQUIRE(ToString(res2) == "[one, two, three]");
|
REQUIRE(ToString(res2) == "[one, two, three]");
|
||||||
|
|
||||||
using Smap = std::map<std::string, std::string>;
|
using Smap = std::map<std::string, std::string>;
|
||||||
Smap m;
|
Smap m;
|
||||||
m["one"] = "1";
|
m["one"] = "1";
|
||||||
Result<Smap> res3{m, m, m};
|
Result<Smap> const res3{m, m, m};
|
||||||
REQUIRE(res3.size() == 3);
|
REQUIRE(res3.size() == 3);
|
||||||
REQUIRE(ToString(res3) == "[{one: 1}, {one: 1}, {one: 1}]");
|
REQUIRE(ToString(res3) == "[{one: 1}, {one: 1}, {one: 1}]");
|
||||||
|
|
||||||
@@ -191,25 +191,25 @@ TEST_CASE("String conversions") {
|
|||||||
m2["two"] = "2";
|
m2["two"] = "2";
|
||||||
m2["three"] = "3";
|
m2["three"] = "3";
|
||||||
|
|
||||||
Result<Smap> res4{m, m2, m};
|
Result<Smap> const res4{m, m2, m};
|
||||||
REQUIRE(ToString(res4) ==
|
REQUIRE(ToString(res4) ==
|
||||||
"[{one: 1}, {one: 1, three: 3, two: 2}, {one: 1}]");
|
"[{one: 1}, {one: 1, three: 3, two: 2}, {one: 1}]");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Any element is equal") {
|
TEST_CASE("Any element is equal") {
|
||||||
Result<int> r{1, 2, 3, 4, 5};
|
Result<int> const r{1, 2, 3, 4, 5};
|
||||||
REQUIRE(r.any(3));
|
REQUIRE(r.any(3));
|
||||||
REQUIRE_FALSE(r.any(9));
|
REQUIRE_FALSE(r.any(9));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Result contains only the specified elements") {
|
TEST_CASE("Result contains only the specified elements") {
|
||||||
Result<int> r{1, 1, 1};
|
Result<int> const r{1, 1, 1};
|
||||||
REQUIRE(r.contains_only(1));
|
REQUIRE(r.contains_only(1));
|
||||||
REQUIRE(r.contains_only(1, 1));
|
REQUIRE(r.contains_only(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Only with multiple values") {
|
TEST_CASE("Only with multiple values") {
|
||||||
Result<int> r{1, 1, 2, 1, 2, 1, 1};
|
Result<int> const r{1, 1, 2, 1, 2, 1, 1};
|
||||||
REQUIRE_FALSE(r.contains_only(1));
|
REQUIRE_FALSE(r.contains_only(1));
|
||||||
REQUIRE_FALSE(r.contains_only(2));
|
REQUIRE_FALSE(r.contains_only(2));
|
||||||
REQUIRE(r.contains_only(1, 2));
|
REQUIRE(r.contains_only(1, 2));
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ TEST_CASE("Create SharedMemory read and write", "[detector][shm]") {
|
|||||||
shm.createSharedMemory();
|
shm.createSharedMemory();
|
||||||
|
|
||||||
const char *env_p = std::getenv(SHM_ENV_NAME);
|
const char *env_p = std::getenv(SHM_ENV_NAME);
|
||||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
std::string const env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||||
CHECK(shm.getName() == std::string(SHM_DETECTOR_PREFIX) +
|
CHECK(shm.getName() == std::string(SHM_DETECTOR_PREFIX) +
|
||||||
std::to_string(shm_id) + env_name);
|
std::to_string(shm_id) + env_name);
|
||||||
shm()->x = 3;
|
shm()->x = 3;
|
||||||
@@ -177,7 +177,7 @@ TEST_CASE("Open two shared memories to the same place", "[detector][shm]") {
|
|||||||
|
|
||||||
TEST_CASE("Move SharedMemory", "[detector][shm]") {
|
TEST_CASE("Move SharedMemory", "[detector][shm]") {
|
||||||
const char *env_p = std::getenv(SHM_ENV_NAME);
|
const char *env_p = std::getenv(SHM_ENV_NAME);
|
||||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
std::string const env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||||
|
|
||||||
SharedMemory<Data> shm(shm_id, -1);
|
SharedMemory<Data> shm(shm_id, -1);
|
||||||
CHECK(shm.getName() == std::string(SHM_DETECTOR_PREFIX) +
|
CHECK(shm.getName() == std::string(SHM_DETECTOR_PREFIX) +
|
||||||
@@ -198,7 +198,7 @@ TEST_CASE("Move SharedMemory", "[detector][shm]") {
|
|||||||
|
|
||||||
TEST_CASE("Create several shared memories", "[detector][shm]") {
|
TEST_CASE("Create several shared memories", "[detector][shm]") {
|
||||||
const char *env_p = std::getenv(SHM_ENV_NAME);
|
const char *env_p = std::getenv(SHM_ENV_NAME);
|
||||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
std::string const env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||||
|
|
||||||
constexpr int N = 5;
|
constexpr int N = 5;
|
||||||
std::vector<SharedMemory<Data>> v;
|
std::vector<SharedMemory<Data>> v;
|
||||||
@@ -225,9 +225,9 @@ TEST_CASE("Create several shared memories", "[detector][shm]") {
|
|||||||
|
|
||||||
TEST_CASE("Create create a shared memory with a tag") {
|
TEST_CASE("Create create a shared memory with a tag") {
|
||||||
const char *env_p = std::getenv(SHM_ENV_NAME);
|
const char *env_p = std::getenv(SHM_ENV_NAME);
|
||||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
std::string const env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||||
|
|
||||||
SharedMemory<Data> shm(0, -1, "ctbdacs");
|
SharedMemory<Data> const shm(0, -1, "ctbdacs");
|
||||||
REQUIRE(shm.getName() ==
|
REQUIRE(shm.getName() ==
|
||||||
std::string(SHM_DETECTOR_PREFIX) + "0" + env_name + "_ctbdacs");
|
std::string(SHM_DETECTOR_PREFIX) + "0" + env_name + "_ctbdacs");
|
||||||
}
|
}
|
||||||
@@ -242,7 +242,7 @@ TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") {
|
|||||||
unsetenv(SHM_ENV_NAME);
|
unsetenv(SHM_ENV_NAME);
|
||||||
setenv(SHM_ENV_NAME, "myprefix", 1);
|
setenv(SHM_ENV_NAME, "myprefix", 1);
|
||||||
|
|
||||||
SharedMemory<Data> shm(0, -1, "ctbdacs");
|
SharedMemory<Data> const shm(0, -1, "ctbdacs");
|
||||||
REQUIRE(shm.getName() == std::string(SHM_DETECTOR_PREFIX) + "0_myprefix_ctbdacs");
|
REQUIRE(shm.getName() == std::string(SHM_DETECTOR_PREFIX) + "0_myprefix_ctbdacs");
|
||||||
|
|
||||||
// Clean up after us
|
// Clean up after us
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ void Arping::SetInterfacesAndIps(const int index, const std::string &interface,
|
|||||||
// create commands to arping
|
// create commands to arping
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "arping -c 1 -U -I " << interface << " " << ip;
|
os << "arping -c 1 -U -I " << interface << " " << ip;
|
||||||
std::string cmd = os.str();
|
std::string const cmd = os.str();
|
||||||
commands[index] = cmd;
|
commands[index] = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ void Arping::StopProcess() {
|
|||||||
|
|
||||||
void Arping::ProcessExecution() {
|
void Arping::ProcessExecution() {
|
||||||
while (true) {
|
while (true) {
|
||||||
std::string error = ExecuteCommands();
|
std::string const error = ExecuteCommands();
|
||||||
// just print (was already tested at Process start)
|
// just print (was already tested at Process start)
|
||||||
if (!error.empty()) {
|
if (!error.empty()) {
|
||||||
LOG(logERROR) << error;
|
LOG(logERROR) << error;
|
||||||
@@ -101,7 +101,7 @@ void Arping::TestForErrors() {
|
|||||||
"Could not arping. Interface not set up in arping Process");
|
"Could not arping. Interface not set up in arping Process");
|
||||||
}
|
}
|
||||||
// test if arping commands throw an error
|
// test if arping commands throw an error
|
||||||
std::string error = ExecuteCommands();
|
std::string const error = ExecuteCommands();
|
||||||
if (!error.empty()) {
|
if (!error.empty()) {
|
||||||
throw RuntimeError(error);
|
throw RuntimeError(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,14 +57,14 @@ std::string ClientInterface::getReceiverVersion() { return APIRECEIVER; }
|
|||||||
/***callback functions***/
|
/***callback functions***/
|
||||||
void ClientInterface::registerCallBackStartAcquisition(
|
void ClientInterface::registerCallBackStartAcquisition(
|
||||||
void (*func)(const startCallbackHeader, void *), void *arg) {
|
void (*func)(const startCallbackHeader, void *), void *arg) {
|
||||||
std::lock_guard<std::mutex> lock(callbackMutex);
|
std::lock_guard<std::mutex> const lock(callbackMutex);
|
||||||
startAcquisitionCallBack = func;
|
startAcquisitionCallBack = func;
|
||||||
pStartAcquisition = arg;
|
pStartAcquisition = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientInterface::registerCallBackAcquisitionFinished(
|
void ClientInterface::registerCallBackAcquisitionFinished(
|
||||||
void (*func)(const endCallbackHeader, void *), void *arg) {
|
void (*func)(const endCallbackHeader, void *), void *arg) {
|
||||||
std::lock_guard<std::mutex> lock(callbackMutex);
|
std::lock_guard<std::mutex> const lock(callbackMutex);
|
||||||
acquisitionFinishedCallBack = func;
|
acquisitionFinishedCallBack = func;
|
||||||
pAcquisitionFinished = arg;
|
pAcquisitionFinished = arg;
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ void ClientInterface::registerCallBackRawDataReady(
|
|||||||
void (*func)(sls_receiver_header &, dataCallbackHeader, char *, size_t &,
|
void (*func)(sls_receiver_header &, dataCallbackHeader, char *, size_t &,
|
||||||
void *),
|
void *),
|
||||||
void *arg) {
|
void *arg) {
|
||||||
std::lock_guard<std::mutex> lock(callbackMutex);
|
std::lock_guard<std::mutex> const lock(callbackMutex);
|
||||||
rawDataReadyCallBack = func;
|
rawDataReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
@@ -338,15 +338,15 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
|||||||
// udp setup
|
// udp setup
|
||||||
// update retvals only if detmac is not the same as in detector
|
// update retvals only if detmac is not the same as in detector
|
||||||
if (arg.udp_dstip != 0) {
|
if (arg.udp_dstip != 0) {
|
||||||
MacAddr r = setUdpIp(IpAddr(arg.udp_dstip));
|
MacAddr const r = setUdpIp(IpAddr(arg.udp_dstip));
|
||||||
MacAddr detMac{arg.udp_dstmac};
|
MacAddr const detMac{arg.udp_dstmac};
|
||||||
if (detMac != r) {
|
if (detMac != r) {
|
||||||
retvals[0] = r;
|
retvals[0] = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (arg.udp_dstip2 != 0) {
|
if (arg.udp_dstip2 != 0) {
|
||||||
MacAddr r = setUdpIp2(IpAddr(arg.udp_dstip2));
|
MacAddr const r = setUdpIp2(IpAddr(arg.udp_dstip2));
|
||||||
MacAddr detMac{arg.udp_dstmac2};
|
MacAddr const detMac{arg.udp_dstmac2};
|
||||||
if (detMac != r) {
|
if (detMac != r) {
|
||||||
retvals[1] = r;
|
retvals[1] = r;
|
||||||
}
|
}
|
||||||
@@ -467,7 +467,7 @@ void ClientInterface::setDetectorType(detectorType arg) {
|
|||||||
}
|
}
|
||||||
// callbacks after (in setdetectortype, the object is reinitialized)
|
// callbacks after (in setdetectortype, the object is reinitialized)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(callbackMutex);
|
std::lock_guard<std::mutex> const lock(callbackMutex);
|
||||||
if (startAcquisitionCallBack != nullptr)
|
if (startAcquisitionCallBack != nullptr)
|
||||||
impl()->registerCallBackStartAcquisition(startAcquisitionCallBack,
|
impl()->registerCallBackStartAcquisition(startAcquisitionCallBack,
|
||||||
pStartAcquisition);
|
pStartAcquisition);
|
||||||
@@ -586,8 +586,8 @@ int ClientInterface::set_num_digital_samples(Interface &socket) {
|
|||||||
int ClientInterface::set_exptime(Interface &socket) {
|
int ClientInterface::set_exptime(Interface &socket) {
|
||||||
int64_t args[2]{-1, -1};
|
int64_t args[2]{-1, -1};
|
||||||
socket.Receive(args);
|
socket.Receive(args);
|
||||||
int gateIndex = static_cast<int>(args[0]);
|
int const gateIndex = static_cast<int>(args[0]);
|
||||||
ns value = std::chrono::nanoseconds(args[1]);
|
ns const value = std::chrono::nanoseconds(args[1]);
|
||||||
LOG(logDEBUG1) << "Setting exptime to " << ToString(value)
|
LOG(logDEBUG1) << "Setting exptime to " << ToString(value)
|
||||||
<< " (gateIndex: " << gateIndex << ")";
|
<< " (gateIndex: " << gateIndex << ")";
|
||||||
switch (gateIndex) {
|
switch (gateIndex) {
|
||||||
@@ -635,7 +635,7 @@ int ClientInterface::set_period(Interface &socket) {
|
|||||||
int ClientInterface::set_subexptime(Interface &socket) {
|
int ClientInterface::set_subexptime(Interface &socket) {
|
||||||
auto value = std::chrono::nanoseconds(socket.Receive<int64_t>());
|
auto value = std::chrono::nanoseconds(socket.Receive<int64_t>());
|
||||||
LOG(logDEBUG1) << "Setting period to " << ToString(value);
|
LOG(logDEBUG1) << "Setting period to " << ToString(value);
|
||||||
ns subdeadtime = impl()->getSubPeriod() - impl()->getSubExpTime();
|
ns const subdeadtime = impl()->getSubPeriod() - impl()->getSubExpTime();
|
||||||
impl()->setSubExpTime(value);
|
impl()->setSubExpTime(value);
|
||||||
impl()->setSubPeriod(impl()->getSubExpTime() + subdeadtime);
|
impl()->setSubPeriod(impl()->getSubExpTime() + subdeadtime);
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
@@ -780,7 +780,7 @@ int ClientInterface::get_file_dir(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::set_file_name(Interface &socket) {
|
int ClientInterface::set_file_name(Interface &socket) {
|
||||||
std::string fname = socket.Receive(MAX_STR_LENGTH);
|
std::string const fname = socket.Receive(MAX_STR_LENGTH);
|
||||||
if (fname.empty()) {
|
if (fname.empty()) {
|
||||||
throw RuntimeError("Cannot set empty file name");
|
throw RuntimeError("Cannot set empty file name");
|
||||||
}
|
}
|
||||||
@@ -1115,7 +1115,7 @@ int ClientInterface::set_additional_json_header(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::get_additional_json_header(Interface &socket) {
|
int ClientInterface::get_additional_json_header(Interface &socket) {
|
||||||
std::map<std::string, std::string> json = impl()->getAdditionalJsonHeader();
|
std::map<std::string, std::string> const json = impl()->getAdditionalJsonHeader();
|
||||||
LOG(logDEBUG1) << "additional json header:" << ToString(json);
|
LOG(logDEBUG1) << "additional json header:" << ToString(json);
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
for (auto &it : json) {
|
for (auto &it : json) {
|
||||||
@@ -1319,7 +1319,7 @@ int ClientInterface::set_quad_type(Interface &socket) {
|
|||||||
std::string(e.what()) + ']');
|
std::string(e.what()) + ']');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int retval = impl()->getQuad() ? 1 : 0;
|
int const retval = impl()->getQuad() ? 1 : 0;
|
||||||
validate(quadEnable, retval, "set quad", DEC);
|
validate(quadEnable, retval, "set quad", DEC);
|
||||||
LOG(logDEBUG1) << "quad retval:" << retval;
|
LOG(logDEBUG1) << "quad retval:" << retval;
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
@@ -1336,7 +1336,7 @@ int ClientInterface::set_read_n_rows(Interface &socket) {
|
|||||||
LOG(logDEBUG1) << "Setting number of rows:" << arg;
|
LOG(logDEBUG1) << "Setting number of rows:" << arg;
|
||||||
impl()->setReadNRows(arg);
|
impl()->setReadNRows(arg);
|
||||||
}
|
}
|
||||||
int retval = impl()->getReadNRows();
|
int const retval = impl()->getReadNRows();
|
||||||
validate(arg, retval, "set number of rows", DEC);
|
validate(arg, retval, "set number of rows", DEC);
|
||||||
LOG(logDEBUG1) << "read number of rows:" << retval;
|
LOG(logDEBUG1) << "read number of rows:" << retval;
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
@@ -1516,7 +1516,7 @@ int ClientInterface::set_additional_json_parameter(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::get_additional_json_parameter(Interface &socket) {
|
int ClientInterface::get_additional_json_parameter(Interface &socket) {
|
||||||
std::string key = socket.Receive(SHORT_STR_LENGTH);
|
std::string const key = socket.Receive(SHORT_STR_LENGTH);
|
||||||
std::string value = impl()->getAdditionalJsonParameter(key);
|
std::string value = impl()->getAdditionalJsonParameter(key);
|
||||||
value.resize(SHORT_STR_LENGTH);
|
value.resize(SHORT_STR_LENGTH);
|
||||||
return socket.sendResult(value);
|
return socket.sendResult(value);
|
||||||
@@ -1541,7 +1541,7 @@ int ClientInterface::set_num_gates(Interface &socket) {
|
|||||||
int ClientInterface::set_gate_delay(Interface &socket) {
|
int ClientInterface::set_gate_delay(Interface &socket) {
|
||||||
int64_t args[2]{-1, -1};
|
int64_t args[2]{-1, -1};
|
||||||
socket.Receive(args);
|
socket.Receive(args);
|
||||||
int gateIndex = static_cast<int>(args[0]);
|
int const gateIndex = static_cast<int>(args[0]);
|
||||||
auto value = std::chrono::nanoseconds(args[1]);
|
auto value = std::chrono::nanoseconds(args[1]);
|
||||||
LOG(logDEBUG1) << "Setting gate delay to " << ToString(value)
|
LOG(logDEBUG1) << "Setting gate delay to " << ToString(value)
|
||||||
<< " (gateIndex: " << gateIndex << ")";
|
<< " (gateIndex: " << gateIndex << ")";
|
||||||
@@ -1657,7 +1657,7 @@ int ClientInterface::set_all_threshold(Interface &socket) {
|
|||||||
int ClientInterface::set_detector_datastream(Interface &socket) {
|
int ClientInterface::set_detector_datastream(Interface &socket) {
|
||||||
int args[2]{-1, -1};
|
int args[2]{-1, -1};
|
||||||
socket.Receive(args);
|
socket.Receive(args);
|
||||||
portPosition port = static_cast<portPosition>(args[0]);
|
portPosition const port = static_cast<portPosition>(args[0]);
|
||||||
switch (port) {
|
switch (port) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
@@ -1665,7 +1665,7 @@ int ClientInterface::set_detector_datastream(Interface &socket) {
|
|||||||
default:
|
default:
|
||||||
throw RuntimeError("Invalid port type");
|
throw RuntimeError("Invalid port type");
|
||||||
}
|
}
|
||||||
bool enable = static_cast<int>(args[1]);
|
bool const enable = static_cast<int>(args[1]);
|
||||||
LOG(logDEBUG1) << "Setting datastream (" << ToString(port) << ") to "
|
LOG(logDEBUG1) << "Setting datastream (" << ToString(port) << ") to "
|
||||||
<< ToString(enable);
|
<< ToString(enable);
|
||||||
if (detType != EIGER)
|
if (detType != EIGER)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ ParsedOptions CommandLineOptions::parse(const std::vector<std::string> &args) {
|
|||||||
for (const auto &arg : args) {
|
for (const auto &arg : args) {
|
||||||
argv.push_back(const_cast<char *>(arg.c_str()));
|
argv.push_back(const_cast<char *>(arg.c_str()));
|
||||||
}
|
}
|
||||||
int argc = static_cast<int>(argv.size());
|
int const argc = static_cast<int>(argv.size());
|
||||||
return parse(argc, argv.data());
|
return parse(argc, argv.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ ParsedOptions CommandLineOptions::parse(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse deprecated arguments
|
// parse deprecated arguments
|
||||||
std::vector<std::string> args(argv, argv + argc);
|
std::vector<std::string> const args(argv, argv + argc);
|
||||||
auto [p, n, o] = ParseDeprecated(args);
|
auto [p, n, o] = ParseDeprecated(args);
|
||||||
// set options
|
// set options
|
||||||
base.port = p;
|
base.port = p;
|
||||||
@@ -251,7 +251,7 @@ void CommandLineOptions::handleAppSpecificOption(int opt, const char *optarg,
|
|||||||
std::tuple<uint16_t, uint16_t, bool>
|
std::tuple<uint16_t, uint16_t, bool>
|
||||||
CommandLineOptions::ParseDeprecated(const std::vector<std::string> &args) {
|
CommandLineOptions::ParseDeprecated(const std::vector<std::string> &args) {
|
||||||
|
|
||||||
size_t nargs = args.size();
|
size_t const nargs = args.size();
|
||||||
if (nargs != 1 && nargs != 3 && nargs != 4) {
|
if (nargs != 1 && nargs != 3 && nargs != 4) {
|
||||||
throw sls::RuntimeError("Invalid number of arguments.");
|
throw sls::RuntimeError("Invalid number of arguments.");
|
||||||
}
|
}
|
||||||
@@ -266,8 +266,8 @@ CommandLineOptions::ParseDeprecated(const std::vector<std::string> &args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse deprecated arguments
|
// parse deprecated arguments
|
||||||
uint16_t p = parsePort(args[1].c_str());
|
uint16_t const p = parsePort(args[1].c_str());
|
||||||
uint16_t n = parseNumReceivers(args[2].c_str());
|
uint16_t const n = parseNumReceivers(args[2].c_str());
|
||||||
bool o = false;
|
bool o = false;
|
||||||
if (nargs == 4) {
|
if (nargs == 4) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ void DataProcessor::SetNumberofTotalFrames(uint64_t value) {
|
|||||||
|
|
||||||
void DataProcessor::SetAdditionalJsonHeader(
|
void DataProcessor::SetAdditionalJsonHeader(
|
||||||
const std::map<std::string, std::string> &json) {
|
const std::map<std::string, std::string> &json) {
|
||||||
std::lock_guard<std::mutex> lock(additionalJsonMutex);
|
std::lock_guard<std::mutex> const lock(additionalJsonMutex);
|
||||||
additionalJsonHeader = json;
|
additionalJsonHeader = json;
|
||||||
isAdditionalJsonUpdated = true;
|
isAdditionalJsonUpdated = true;
|
||||||
}
|
}
|
||||||
@@ -254,7 +254,7 @@ std::string DataProcessor::CreateMasterFile(
|
|||||||
|
|
||||||
attr->framesInFile = numFramesCaught;
|
attr->framesInFile = numFramesCaught;
|
||||||
|
|
||||||
std::unique_ptr<File> masterFile{nullptr};
|
std::unique_ptr<File> const masterFile{nullptr};
|
||||||
switch (fileFormatType) {
|
switch (fileFormatType) {
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
case HDF5:
|
case HDF5:
|
||||||
@@ -325,11 +325,11 @@ void DataProcessor::StopProcessing(char *buf) {
|
|||||||
void DataProcessor::ProcessAnImage(sls_receiver_header &header, size_t &size,
|
void DataProcessor::ProcessAnImage(sls_receiver_header &header, size_t &size,
|
||||||
size_t &firstImageIndex, char *data) {
|
size_t &firstImageIndex, char *data) {
|
||||||
|
|
||||||
uint64_t fnum = header.detHeader.frameNumber;
|
uint64_t const fnum = header.detHeader.frameNumber;
|
||||||
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
|
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
|
||||||
currentFrameIndex = fnum;
|
currentFrameIndex = fnum;
|
||||||
numFramesCaught++;
|
numFramesCaught++;
|
||||||
uint32_t nump = header.detHeader.packetNumber;
|
uint32_t const nump = header.detHeader.packetNumber;
|
||||||
|
|
||||||
if (!startedFlag) {
|
if (!startedFlag) {
|
||||||
RecordFirstIndex(fnum);
|
RecordFirstIndex(fnum);
|
||||||
@@ -390,16 +390,16 @@ void DataProcessor::ProcessAnImage(sls_receiver_header &header, size_t &size,
|
|||||||
// callbacks
|
// callbacks
|
||||||
if (rawDataReadyCallBack != nullptr) {
|
if (rawDataReadyCallBack != nullptr) {
|
||||||
|
|
||||||
uint64_t frameIndex = fnum - firstIndex;
|
uint64_t const frameIndex = fnum - firstIndex;
|
||||||
// update local copy only if it was updated (to prevent locking each
|
// update local copy only if it was updated (to prevent locking each
|
||||||
// time)
|
// time)
|
||||||
if (isAdditionalJsonUpdated) {
|
if (isAdditionalJsonUpdated) {
|
||||||
std::lock_guard<std::mutex> lock(additionalJsonMutex);
|
std::lock_guard<std::mutex> const lock(additionalJsonMutex);
|
||||||
localAdditionalJsonHeader = additionalJsonHeader;
|
localAdditionalJsonHeader = additionalJsonHeader;
|
||||||
isAdditionalJsonUpdated = false;
|
isAdditionalJsonUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataCallbackHeader callbackHeader = {
|
dataCallbackHeader const callbackHeader = {
|
||||||
udpPortNumber,
|
udpPortNumber,
|
||||||
{static_cast<int>(generalData->nPixelsX),
|
{static_cast<int>(generalData->nPixelsX),
|
||||||
static_cast<int>(generalData->nPixelsY)},
|
static_cast<int>(generalData->nPixelsY)},
|
||||||
@@ -446,7 +446,7 @@ bool DataProcessor::CheckTimer() {
|
|||||||
|
|
||||||
auto elapsed_s = (end.tv_sec - timerbegin.tv_sec) +
|
auto elapsed_s = (end.tv_sec - timerbegin.tv_sec) +
|
||||||
(end.tv_nsec - timerbegin.tv_nsec) / 1e9;
|
(end.tv_nsec - timerbegin.tv_nsec) / 1e9;
|
||||||
double timer_s = streamingTimerInMs / 1e3;
|
double const timer_s = streamingTimerInMs / 1e3;
|
||||||
|
|
||||||
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
|
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
|
||||||
<< " seconds";
|
<< " seconds";
|
||||||
@@ -480,7 +480,7 @@ void DataProcessor::registerCallBackRawDataReady(
|
|||||||
void DataProcessor::PadMissingPackets(sls_receiver_header header, char *data) {
|
void DataProcessor::PadMissingPackets(sls_receiver_header header, char *data) {
|
||||||
LOG(logDEBUG) << index << ": Padding Missing Packets";
|
LOG(logDEBUG) << index << ": Padding Missing Packets";
|
||||||
|
|
||||||
uint32_t pperFrame = generalData->packetsPerFrame;
|
uint32_t const pperFrame = generalData->packetsPerFrame;
|
||||||
|
|
||||||
uint32_t nmissing = pperFrame - header.detHeader.packetNumber;
|
uint32_t nmissing = pperFrame - header.detHeader.packetNumber;
|
||||||
sls_bitset pmask = header.packetsMask;
|
sls_bitset pmask = header.packetsMask;
|
||||||
@@ -489,7 +489,7 @@ void DataProcessor::PadMissingPackets(sls_receiver_header header, char *data) {
|
|||||||
if (generalData->detType == GOTTHARD2 && index != 0) {
|
if (generalData->detType == GOTTHARD2 && index != 0) {
|
||||||
dsize = generalData->vetoDataSize;
|
dsize = generalData->vetoDataSize;
|
||||||
}
|
}
|
||||||
uint32_t corrected_dsize =
|
uint32_t const corrected_dsize =
|
||||||
dsize - ((pperFrame * dsize) - generalData->imageSize);
|
dsize - ((pperFrame * dsize) - generalData->imageSize);
|
||||||
LOG(logDEBUG1) << "bitmask: " << pmask.to_string();
|
LOG(logDEBUG1) << "bitmask: " << pmask.to_string();
|
||||||
|
|
||||||
@@ -571,7 +571,7 @@ void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
|
|||||||
const auto ctbDbitList = generalData->ctbDbitList;
|
const auto ctbDbitList = generalData->ctbDbitList;
|
||||||
|
|
||||||
// TODO! (Erik) Refactor and add tests
|
// TODO! (Erik) Refactor and add tests
|
||||||
int ctbDigitalDataBytes = nDigitalDataBytes - ctbDbitOffset;
|
int const ctbDigitalDataBytes = nDigitalDataBytes - ctbDbitOffset;
|
||||||
|
|
||||||
// no digital data
|
// no digital data
|
||||||
if (ctbDigitalDataBytes == 0) {
|
if (ctbDigitalDataBytes == 0) {
|
||||||
@@ -618,13 +618,13 @@ void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
|
|||||||
++dest;
|
++dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t byte_index = bi / 8;
|
uint8_t const byte_index = bi / 8;
|
||||||
|
|
||||||
// loop through the frame digital data
|
// loop through the frame digital data
|
||||||
for (auto *ptr = source + byte_index;
|
for (auto *ptr = source + byte_index;
|
||||||
ptr < (source + 8 * numDigitalSamples); ptr += 8) {
|
ptr < (source + 8 * numDigitalSamples); ptr += 8) {
|
||||||
// get selected bit from each 8 bit
|
// get selected bit from each 8 bit
|
||||||
uint8_t bit = (*ptr >> bi % 8) & 1;
|
uint8_t const bit = (*ptr >> bi % 8) & 1;
|
||||||
*dest |= bit << bitoffset; // stored as least significant
|
*dest |= bit << bitoffset; // stored as least significant
|
||||||
++bitoffset;
|
++bitoffset;
|
||||||
// extract destination in 8 bit batches
|
// extract destination in 8 bit batches
|
||||||
@@ -648,9 +648,9 @@ void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
|
|||||||
// loop through digital bit enable vector
|
// loop through digital bit enable vector
|
||||||
for (auto bi : ctbDbitList) {
|
for (auto bi : ctbDbitList) {
|
||||||
// get selected bit from each 64 bit
|
// get selected bit from each 64 bit
|
||||||
uint8_t byte_index = bi / 8;
|
uint8_t const byte_index = bi / 8;
|
||||||
|
|
||||||
uint8_t bit = (*(ptr + byte_index) >> (bi % 8)) & 1;
|
uint8_t const bit = (*(ptr + byte_index) >> (bi % 8)) & 1;
|
||||||
*dest |= bit << bitoffset;
|
*dest |= bit << bitoffset;
|
||||||
++bitoffset;
|
++bitoffset;
|
||||||
// extract destination in 8 bit batches
|
// extract destination in 8 bit batches
|
||||||
@@ -684,12 +684,12 @@ void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
|
|||||||
|
|
||||||
void DataProcessor::CropImage(size_t &size, char *data) {
|
void DataProcessor::CropImage(size_t &size, char *data) {
|
||||||
LOG(logDEBUG1) << "Cropping Image to ROI " << ToString(portRoi);
|
LOG(logDEBUG1) << "Cropping Image to ROI " << ToString(portRoi);
|
||||||
int nPixelsX = generalData->nPixelsX;
|
int const nPixelsX = generalData->nPixelsX;
|
||||||
int xmin = portRoi.xmin;
|
int const xmin = portRoi.xmin;
|
||||||
int xmax = portRoi.xmax;
|
int const xmax = portRoi.xmax;
|
||||||
int ymin = portRoi.ymin;
|
int ymin = portRoi.ymin;
|
||||||
int ymax = portRoi.ymax;
|
int const ymax = portRoi.ymax;
|
||||||
int xwidth = xmax - xmin + 1;
|
int const xwidth = xmax - xmin + 1;
|
||||||
int ywidth = ymax - ymin + 1;
|
int ywidth = ymax - ymin + 1;
|
||||||
if (ymin == -1 || ymax == -1) {
|
if (ymin == -1 || ymax == -1) {
|
||||||
ywidth = 1;
|
ywidth = 1;
|
||||||
@@ -697,11 +697,11 @@ void DataProcessor::CropImage(size_t &size, char *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculate total roi size
|
// calculate total roi size
|
||||||
double bytesPerPixel = generalData->dynamicRange / 8.00;
|
double const bytesPerPixel = generalData->dynamicRange / 8.00;
|
||||||
int startOffset = (int)((nPixelsX * ymin + xmin) * bytesPerPixel);
|
int const startOffset = (int)((nPixelsX * ymin + xmin) * bytesPerPixel);
|
||||||
|
|
||||||
// write size into memory
|
// write size into memory
|
||||||
std::size_t roiImageSize = xwidth * ywidth * bytesPerPixel;
|
std::size_t const roiImageSize = xwidth * ywidth * bytesPerPixel;
|
||||||
LOG(logDEBUG) << "roiImageSize:" << roiImageSize;
|
LOG(logDEBUG) << "roiImageSize:" << roiImageSize;
|
||||||
size = roiImageSize;
|
size = roiImageSize;
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void DataStreamer::SetNumberofTotalFrames(uint64_t value) {
|
|||||||
|
|
||||||
void DataStreamer::SetAdditionalJsonHeader(
|
void DataStreamer::SetAdditionalJsonHeader(
|
||||||
const std::map<std::string, std::string> &json) {
|
const std::map<std::string, std::string> &json) {
|
||||||
std::lock_guard<std::mutex> lock(additionalJsonMutex);
|
std::lock_guard<std::mutex> const lock(additionalJsonMutex);
|
||||||
additionalJsonHeader = json;
|
additionalJsonHeader = json;
|
||||||
isAdditionalJsonUpdated = true;
|
isAdditionalJsonUpdated = true;
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum, size_t firstImageIndex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::CreateZmqSockets(uint16_t port, int hwm) {
|
void DataStreamer::CreateZmqSockets(uint16_t port, int hwm) {
|
||||||
uint16_t portnum = port + index;
|
uint16_t const portnum = port + index;
|
||||||
try {
|
try {
|
||||||
zmqSocket = new ZmqSocket(portnum);
|
zmqSocket = new ZmqSocket(portnum);
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ void DataStreamer::StopProcessing(char *buf) {
|
|||||||
void DataStreamer::ProcessAnImage(sls_detector_header header, size_t size,
|
void DataStreamer::ProcessAnImage(sls_detector_header header, size_t size,
|
||||||
char *data) {
|
char *data) {
|
||||||
|
|
||||||
uint64_t fnum = header.frameNumber;
|
uint64_t const fnum = header.frameNumber;
|
||||||
LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
|
LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
|
||||||
|
|
||||||
if (!SendDataHeader(header, size, generalData->nPixelsX,
|
if (!SendDataHeader(header, size, generalData->nPixelsX,
|
||||||
@@ -177,8 +177,8 @@ int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
|
|||||||
zHeader.data = true;
|
zHeader.data = true;
|
||||||
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
||||||
|
|
||||||
uint64_t frameIndex = header.frameNumber - firstIndex;
|
uint64_t const frameIndex = header.frameNumber - firstIndex;
|
||||||
uint64_t acquisitionIndex = header.frameNumber;
|
uint64_t const acquisitionIndex = header.frameNumber;
|
||||||
|
|
||||||
zHeader.dynamicRange = generalData->dynamicRange;
|
zHeader.dynamicRange = generalData->dynamicRange;
|
||||||
zHeader.fileIndex = fileIndex;
|
zHeader.fileIndex = fileIndex;
|
||||||
@@ -212,7 +212,7 @@ int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
|
|||||||
|
|
||||||
// update local copy only if it was updated (to prevent locking each time)
|
// update local copy only if it was updated (to prevent locking each time)
|
||||||
if (isAdditionalJsonUpdated) {
|
if (isAdditionalJsonUpdated) {
|
||||||
std::lock_guard<std::mutex> lock(additionalJsonMutex);
|
std::lock_guard<std::mutex> const lock(additionalJsonMutex);
|
||||||
localAdditionalJsonHeader = additionalJsonHeader;
|
localAdditionalJsonHeader = additionalJsonHeader;
|
||||||
isAdditionalJsonUpdated = false;
|
isAdditionalJsonUpdated = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ void Fifo::CreateFifos(size_t fifoItemSize) {
|
|||||||
fifoFree = new CircularFifo<char>(fifoDepth);
|
fifoFree = new CircularFifo<char>(fifoDepth);
|
||||||
fifoStream = new CircularFifo<char>(fifoDepth);
|
fifoStream = new CircularFifo<char>(fifoDepth);
|
||||||
// allocate memory
|
// allocate memory
|
||||||
size_t mem_len = fifoItemSize * (size_t)fifoDepth * sizeof(char);
|
size_t const mem_len = fifoItemSize * (size_t)fifoDepth * sizeof(char);
|
||||||
memory = (char *)malloc(mem_len);
|
memory = (char *)malloc(mem_len);
|
||||||
if (memory == nullptr) {
|
if (memory == nullptr) {
|
||||||
throw RuntimeError("Could not allocate memory for fifos");
|
throw RuntimeError("Could not allocate memory for fifos");
|
||||||
}
|
}
|
||||||
memset(memory, 0, mem_len);
|
memset(memory, 0, mem_len);
|
||||||
int pagesize = getpagesize();
|
int const pagesize = getpagesize();
|
||||||
for (size_t i = 0; i < mem_len; i += pagesize) {
|
for (size_t i = 0; i < mem_len; i += pagesize) {
|
||||||
strcpy(memory + i, "memory");
|
strcpy(memory + i, "memory");
|
||||||
}
|
}
|
||||||
@@ -84,14 +84,14 @@ void Fifo::DestroyFifos() {
|
|||||||
void Fifo::FreeAddress(char *&address) { fifoFree->push(address); }
|
void Fifo::FreeAddress(char *&address) { fifoFree->push(address); }
|
||||||
|
|
||||||
void Fifo::GetNewAddress(char *&address) {
|
void Fifo::GetNewAddress(char *&address) {
|
||||||
int temp = fifoFree->getDataValue();
|
int const temp = fifoFree->getDataValue();
|
||||||
if (temp < status_fifoFree)
|
if (temp < status_fifoFree)
|
||||||
status_fifoFree = temp;
|
status_fifoFree = temp;
|
||||||
fifoFree->pop(address);
|
fifoFree->pop(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fifo::PushAddress(char *&address) {
|
void Fifo::PushAddress(char *&address) {
|
||||||
int temp = fifoBound->getDataValue();
|
int const temp = fifoBound->getDataValue();
|
||||||
if (temp > status_fifoBound)
|
if (temp > status_fifoBound)
|
||||||
status_fifoBound = temp;
|
status_fifoBound = temp;
|
||||||
while (!fifoBound->push(address))
|
while (!fifoBound->push(address))
|
||||||
@@ -108,13 +108,13 @@ void Fifo::PushAddressToStream(char *&address) { fifoStream->push(address); }
|
|||||||
void Fifo::PopAddressToStream(char *&address) { fifoStream->pop(address); }
|
void Fifo::PopAddressToStream(char *&address) { fifoStream->pop(address); }
|
||||||
|
|
||||||
int Fifo::GetMaxLevelForFifoBound() {
|
int Fifo::GetMaxLevelForFifoBound() {
|
||||||
int temp = status_fifoBound;
|
int const temp = status_fifoBound;
|
||||||
status_fifoBound = 0;
|
status_fifoBound = 0;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Fifo::GetMinLevelForFifoFree() {
|
int Fifo::GetMinLevelForFifoFree() {
|
||||||
int temp = status_fifoFree;
|
int const temp = status_fifoFree;
|
||||||
status_fifoFree = fifoDepth;
|
status_fifoFree = fifoDepth;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ FrameStatus *global_frame_status = nullptr;
|
|||||||
|
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
if (global_frame_status) {
|
if (global_frame_status) {
|
||||||
std::lock_guard<std::mutex> lock(global_frame_status->mtx);
|
std::lock_guard<std::mutex> const lock(global_frame_status->mtx);
|
||||||
for (auto &outer_pair : global_frame_status->frames) {
|
for (auto &outer_pair : global_frame_status->frames) {
|
||||||
for (auto &inner_pair : outer_pair.second) {
|
for (auto &inner_pair : outer_pair.second) {
|
||||||
for (zmq_msg_t *msg : inner_pair.second) {
|
for (zmq_msg_t *msg : inner_pair.second) {
|
||||||
@@ -146,11 +146,11 @@ std::set<uint64_t> get_valid_fnums(const PortFrameMap &port_frame_map) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int zmq_send_multipart(void *socket, const ZmqMsgList &messages) {
|
int zmq_send_multipart(void *socket, const ZmqMsgList &messages) {
|
||||||
size_t num_messages = messages.size();
|
size_t const num_messages = messages.size();
|
||||||
for (size_t i = 0; i != num_messages; ++i) {
|
for (size_t i = 0; i != num_messages; ++i) {
|
||||||
zmq_msg_t *msg = messages[i];
|
zmq_msg_t *msg = messages[i];
|
||||||
// determine flags: ZMQ_SNDMORE for all messages except the last
|
// determine flags: ZMQ_SNDMORE for all messages except the last
|
||||||
int flags = (i == num_messages - 1) ? 0 : ZMQ_SNDMORE;
|
int const flags = (i == num_messages - 1) ? 0 : ZMQ_SNDMORE;
|
||||||
if (zmq_msg_send(msg, socket, flags) == -1) {
|
if (zmq_msg_send(msg, socket, flags) == -1) {
|
||||||
LOG(sls::logERROR)
|
LOG(sls::logERROR)
|
||||||
<< "Error sending message: " << zmq_strerror(zmq_errno());
|
<< "Error sending message: " << zmq_strerror(zmq_errno());
|
||||||
@@ -164,7 +164,7 @@ void Correlate(FrameStatus *stat) {
|
|||||||
void *context = zmq_ctx_new();
|
void *context = zmq_ctx_new();
|
||||||
|
|
||||||
void *socket = zmq_socket(context, ZMQ_PUSH);
|
void *socket = zmq_socket(context, ZMQ_PUSH);
|
||||||
int rc = zmq_bind(socket, "tcp://*:5555");
|
int const rc = zmq_bind(socket, "tcp://*:5555");
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
LOG(sls::logERROR) << "failed to bind";
|
LOG(sls::logERROR) << "failed to bind";
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ void Correlate(FrameStatus *stat) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
sem_wait(&(stat->available));
|
sem_wait(&(stat->available));
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(stat->mtx);
|
std::lock_guard<std::mutex> const lock(stat->mtx);
|
||||||
|
|
||||||
if (stat->terminate) {
|
if (stat->terminate) {
|
||||||
break;
|
break;
|
||||||
@@ -304,10 +304,10 @@ void StartAcquisitionCallback(
|
|||||||
}
|
}
|
||||||
oss << "}\n";
|
oss << "}\n";
|
||||||
|
|
||||||
std::string message = oss.str();
|
std::string const message = oss.str();
|
||||||
LOG(sls::logDEBUG) << "Start Acquisition message:" << std::endl << message;
|
LOG(sls::logDEBUG) << "Start Acquisition message:" << std::endl << message;
|
||||||
|
|
||||||
int length = message.length();
|
int const length = message.length();
|
||||||
char *hdata = new char[length];
|
char *hdata = new char[length];
|
||||||
memcpy(hdata, message.c_str(), length);
|
memcpy(hdata, message.c_str(), length);
|
||||||
zmq_msg_t *hmsg = new zmq_msg_t;
|
zmq_msg_t *hmsg = new zmq_msg_t;
|
||||||
@@ -316,7 +316,7 @@ void StartAcquisitionCallback(
|
|||||||
// push zmq msg into stat to be processed
|
// push zmq msg into stat to be processed
|
||||||
FrameStatus *stat = static_cast<FrameStatus *>(objectPointer);
|
FrameStatus *stat = static_cast<FrameStatus *>(objectPointer);
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(stat->mtx);
|
std::lock_guard<std::mutex> const lock(stat->mtx);
|
||||||
stat->headers.push_back(hmsg);
|
stat->headers.push_back(hmsg);
|
||||||
stat->starting = true;
|
stat->starting = true;
|
||||||
// clean up old frames
|
// clean up old frames
|
||||||
@@ -355,8 +355,8 @@ void AcquisitionFinishedCallback(
|
|||||||
<< sls::ToString(callbackHeader.completeFrames)
|
<< sls::ToString(callbackHeader.completeFrames)
|
||||||
<< ", \"lastFrameIndex\":"
|
<< ", \"lastFrameIndex\":"
|
||||||
<< sls::ToString(callbackHeader.lastFrameIndex) << "}\n";
|
<< sls::ToString(callbackHeader.lastFrameIndex) << "}\n";
|
||||||
std::string message = oss.str();
|
std::string const message = oss.str();
|
||||||
int length = message.length();
|
int const length = message.length();
|
||||||
LOG(sls::logDEBUG) << "Acquisition Finished message:" << std::endl
|
LOG(sls::logDEBUG) << "Acquisition Finished message:" << std::endl
|
||||||
<< message;
|
<< message;
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ void AcquisitionFinishedCallback(
|
|||||||
// push zmq msg into stat to be processed
|
// push zmq msg into stat to be processed
|
||||||
FrameStatus *stat = static_cast<FrameStatus *>(objectPointer);
|
FrameStatus *stat = static_cast<FrameStatus *>(objectPointer);
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(stat->mtx);
|
std::lock_guard<std::mutex> const lock(stat->mtx);
|
||||||
stat->ends.push_back(hmsg);
|
stat->ends.push_back(hmsg);
|
||||||
}
|
}
|
||||||
sem_post(&stat->available);
|
sem_post(&stat->available);
|
||||||
@@ -379,7 +379,7 @@ void GetDataCallback(slsDetectorDefs::sls_receiver_header &header,
|
|||||||
char *dataPointer, size_t &imageSize,
|
char *dataPointer, size_t &imageSize,
|
||||||
void *objectPointer) {
|
void *objectPointer) {
|
||||||
|
|
||||||
slsDetectorDefs::sls_detector_header detectorHeader = header.detHeader;
|
slsDetectorDefs::sls_detector_header const detectorHeader = header.detHeader;
|
||||||
|
|
||||||
if (printHeadersLevel < sls::logDEBUG) {
|
if (printHeadersLevel < sls::logDEBUG) {
|
||||||
// print in different color for each udp port
|
// print in different color for each udp port
|
||||||
@@ -468,11 +468,11 @@ void GetDataCallback(slsDetectorDefs::sls_receiver_header &header,
|
|||||||
oss << " } ";
|
oss << " } ";
|
||||||
}
|
}
|
||||||
oss << "}\n";
|
oss << "}\n";
|
||||||
std::string message = oss.str();
|
std::string const message = oss.str();
|
||||||
LOG(sls::logDEBUG) << "Data message:" << std::endl << message;
|
LOG(sls::logDEBUG) << "Data message:" << std::endl << message;
|
||||||
|
|
||||||
// creating header part of data packet
|
// creating header part of data packet
|
||||||
int length = message.length();
|
int const length = message.length();
|
||||||
char *hdata = new char[length];
|
char *hdata = new char[length];
|
||||||
memcpy(hdata, message.c_str(), length);
|
memcpy(hdata, message.c_str(), length);
|
||||||
zmq_msg_t *hmsg = new zmq_msg_t;
|
zmq_msg_t *hmsg = new zmq_msg_t;
|
||||||
@@ -486,7 +486,7 @@ void GetDataCallback(slsDetectorDefs::sls_receiver_header &header,
|
|||||||
// push both parts into stat to be processed
|
// push both parts into stat to be processed
|
||||||
FrameStatus *stat = static_cast<FrameStatus *>(objectPointer);
|
FrameStatus *stat = static_cast<FrameStatus *>(objectPointer);
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(stat->mtx);
|
std::lock_guard<std::mutex> const lock(stat->mtx);
|
||||||
stat->frames[callbackHeader.udpPort][header.detHeader.frameNumber]
|
stat->frames[callbackHeader.udpPort][header.detHeader.frameNumber]
|
||||||
.push_back(hmsg);
|
.push_back(hmsg);
|
||||||
stat->frames[callbackHeader.udpPort][header.detHeader.frameNumber]
|
stat->frames[callbackHeader.udpPort][header.detHeader.frameNumber]
|
||||||
@@ -544,7 +544,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
std::exception_ptr threadException = nullptr;
|
std::exception_ptr threadException = nullptr;
|
||||||
for (int i = 0; i != f.numReceivers; ++i) {
|
for (int i = 0; i != f.numReceivers; ++i) {
|
||||||
uint16_t port = f.port + i;
|
uint16_t const port = f.port + i;
|
||||||
sem_t *semaphore = &semaphores[i];
|
sem_t *semaphore = &semaphores[i];
|
||||||
threads.emplace_back(
|
threads.emplace_back(
|
||||||
[i, semaphore, port, user_data, &threadException]() {
|
[i, semaphore, port, user_data, &threadException]() {
|
||||||
@@ -581,7 +581,7 @@ int main(int argc, char *argv[]) {
|
|||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(stat.mtx);
|
std::lock_guard<std::mutex> const lock(stat.mtx);
|
||||||
stat.terminate = true;
|
stat.terminate = true;
|
||||||
sem_post(&stat.available);
|
sem_post(&stat.available);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,9 +238,9 @@ const slsDetectorDefs::xy Implementation::GetPortGeometry() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setDetectorSize(const slsDetectorDefs::xy size) {
|
void Implementation::setDetectorSize(const slsDetectorDefs::xy size) {
|
||||||
xy portGeometry = GetPortGeometry();
|
xy const portGeometry = GetPortGeometry();
|
||||||
|
|
||||||
std::string log_message = "Detector Size (ports): (";
|
std::string const log_message = "Detector Size (ports): (";
|
||||||
numModules = size;
|
numModules = size;
|
||||||
numPorts.x = portGeometry.x * numModules.x;
|
numPorts.x = portGeometry.x * numModules.x;
|
||||||
numPorts.y = portGeometry.y * numModules.y;
|
numPorts.y = portGeometry.y * numModules.y;
|
||||||
@@ -262,7 +262,7 @@ void Implementation::setModulePositionId(const int id) {
|
|||||||
LOG(logINFO) << "Module Position Id:" << modulePos;
|
LOG(logINFO) << "Module Position Id:" << modulePos;
|
||||||
|
|
||||||
// update zmq port
|
// update zmq port
|
||||||
xy portGeometry = GetPortGeometry();
|
xy const portGeometry = GetPortGeometry();
|
||||||
streamingPort = DEFAULT_ZMQ_RX_PORTNO + modulePos * portGeometry.x;
|
streamingPort = DEFAULT_ZMQ_RX_PORTNO + modulePos * portGeometry.x;
|
||||||
|
|
||||||
assert(numModules.y != 0);
|
assert(numModules.y != 0);
|
||||||
@@ -285,14 +285,14 @@ void Implementation::setModulePositionId(const int id) {
|
|||||||
|
|
||||||
void Implementation::setRow(const int value) {
|
void Implementation::setRow(const int value) {
|
||||||
for (unsigned int i = 0; i < listener.size(); ++i) {
|
for (unsigned int i = 0; i < listener.size(); ++i) {
|
||||||
int col = listener[i]->GetHardCodedPosition().second;
|
int const col = listener[i]->GetHardCodedPosition().second;
|
||||||
listener[i]->SetHardCodedPosition(value, col);
|
listener[i]->SetHardCodedPosition(value, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setColumn(const int value) {
|
void Implementation::setColumn(const int value) {
|
||||||
for (unsigned int i = 0; i < listener.size(); ++i) {
|
for (unsigned int i = 0; i < listener.size(); ++i) {
|
||||||
int row = listener[i]->GetHardCodedPosition().first;
|
int const row = listener[i]->GetHardCodedPosition().first;
|
||||||
listener[i]->SetHardCodedPosition(row, value);
|
listener[i]->SetHardCodedPosition(row, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -405,16 +405,16 @@ std::vector<slsDetectorDefs::ROI> Implementation::getPortROIs() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::ResetRois() {
|
void Implementation::ResetRois() {
|
||||||
int numports = generalData->numUDPInterfaces;
|
int const numports = generalData->numUDPInterfaces;
|
||||||
std::vector<ROI> rois(numports);
|
std::vector<ROI> const rois(numports);
|
||||||
std::vector<ROI> multiRoi(1);
|
std::vector<ROI> const multiRoi(1);
|
||||||
setPortROIs(rois);
|
setPortROIs(rois);
|
||||||
setMultiROIMetadata(multiRoi);
|
setMultiROIMetadata(multiRoi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setPortROIs(const std::vector<defs::ROI> &args) {
|
void Implementation::setPortROIs(const std::vector<defs::ROI> &args) {
|
||||||
int nx = static_cast<int>(generalData->nPixelsX);
|
int const nx = static_cast<int>(generalData->nPixelsX);
|
||||||
int ny = static_cast<int>(generalData->nPixelsY);
|
int const ny = static_cast<int>(generalData->nPixelsY);
|
||||||
// validate rois
|
// validate rois
|
||||||
for (auto &it : args) {
|
for (auto &it : args) {
|
||||||
if (it.completeRoi() || it.noRoi()) {
|
if (it.completeRoi() || it.noRoi()) {
|
||||||
@@ -614,7 +614,7 @@ double Implementation::getProgress() const {
|
|||||||
std::vector<int64_t> Implementation::getNumMissingPackets() const {
|
std::vector<int64_t> Implementation::getNumMissingPackets() const {
|
||||||
std::vector<int64_t> mp(generalData->numUDPInterfaces);
|
std::vector<int64_t> mp(generalData->numUDPInterfaces);
|
||||||
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
|
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
|
||||||
int np = generalData->packetsPerFrame;
|
int const np = generalData->packetsPerFrame;
|
||||||
uint64_t totnp = np;
|
uint64_t totnp = np;
|
||||||
// ReadNRows
|
// ReadNRows
|
||||||
if (readNRows != (int)generalData->maxRowsPerReadout) {
|
if (readNRows != (int)generalData->maxRowsPerReadout) {
|
||||||
@@ -646,7 +646,7 @@ void Implementation::startReceiver() {
|
|||||||
for (size_t i = 0; i != listener.size(); ++i) {
|
for (size_t i = 0; i != listener.size(); ++i) {
|
||||||
udpPort.push_back(udpPortNum[i]);
|
udpPort.push_back(udpPortNum[i]);
|
||||||
}
|
}
|
||||||
startCallbackHeader callbackHeader = {
|
startCallbackHeader const callbackHeader = {
|
||||||
udpPort,
|
udpPort,
|
||||||
generalData->dynamicRange,
|
generalData->dynamicRange,
|
||||||
numPorts,
|
numPorts,
|
||||||
@@ -731,7 +731,7 @@ void Implementation::stopReceiver() {
|
|||||||
// print summary
|
// print summary
|
||||||
uint64_t tot = 0;
|
uint64_t tot = 0;
|
||||||
for (int i = 0; i < generalData->numUDPInterfaces; i++) {
|
for (int i = 0; i < generalData->numUDPInterfaces; i++) {
|
||||||
int nf = listener[i]->GetNumCompleteFramesCaught();
|
int const nf = listener[i]->GetNumCompleteFramesCaught();
|
||||||
tot += nf;
|
tot += nf;
|
||||||
std::string mpMessage = std::to_string(mp[i]);
|
std::string mpMessage = std::to_string(mp[i]);
|
||||||
if (mp[i] < 0) {
|
if (mp[i] < 0) {
|
||||||
@@ -756,7 +756,7 @@ void Implementation::stopReceiver() {
|
|||||||
summary = os.str();
|
summary = os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
TLogLevel lev = ((mp[i]) > 0) ? logINFORED : logINFOGREEN;
|
TLogLevel const lev = ((mp[i]) > 0) ? logINFORED : logINFOGREEN;
|
||||||
LOG(lev) << "Summary of Port " << udpPortNum[i] << " (" << eth[i]
|
LOG(lev) << "Summary of Port " << udpPortNum[i] << " (" << eth[i]
|
||||||
<< ')' << summary;
|
<< ')' << summary;
|
||||||
}
|
}
|
||||||
@@ -774,7 +774,7 @@ void Implementation::stopReceiver() {
|
|||||||
lastFrameIndexCaught.push_back(
|
lastFrameIndexCaught.push_back(
|
||||||
listener[i]->GetLastFrameIndexCaught());
|
listener[i]->GetLastFrameIndexCaught());
|
||||||
}
|
}
|
||||||
endCallbackHeader callHeader = {udpPort, completeFramesCaught,
|
endCallbackHeader const callHeader = {udpPort, completeFramesCaught,
|
||||||
lastFrameIndexCaught};
|
lastFrameIndexCaught};
|
||||||
acquisitionFinishedCallBack(callHeader, pAcquisitionFinished);
|
acquisitionFinishedCallBack(callHeader, pAcquisitionFinished);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
@@ -852,7 +852,7 @@ void Implementation::ResetParametersforNewAcquisition() {
|
|||||||
if (dataStreamEnable) {
|
if (dataStreamEnable) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << filePath << '/' << fileName;
|
os << filePath << '/' << fileName;
|
||||||
std::string fnametostream = os.str();
|
std::string const fnametostream = os.str();
|
||||||
for (const auto &it : dataStreamer)
|
for (const auto &it : dataStreamer)
|
||||||
it->ResetParametersforNewAcquisition(fnametostream);
|
it->ResetParametersforNewAcquisition(fnametostream);
|
||||||
}
|
}
|
||||||
@@ -884,7 +884,7 @@ void Implementation::SetupWriter() {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << filePath << "/" << fileName << "_d"
|
os << filePath << "/" << fileName << "_d"
|
||||||
<< (modulePos * generalData->numUDPInterfaces + i);
|
<< (modulePos * generalData->numUDPInterfaces + i);
|
||||||
std::string fileNamePrefix = os.str();
|
std::string const fileNamePrefix = os.str();
|
||||||
dataProcessor[i]->CreateFirstFiles(fileNamePrefix, fileIndex,
|
dataProcessor[i]->CreateFirstFiles(fileNamePrefix, fileIndex,
|
||||||
overwriteEnable, silentMode,
|
overwriteEnable, silentMode,
|
||||||
detectorDataStream[i]);
|
detectorDataStream[i]);
|
||||||
@@ -919,8 +919,8 @@ void Implementation::StartMasterWriter() {
|
|||||||
// complete ROI (for each port TODO?)
|
// complete ROI (for each port TODO?)
|
||||||
if (multiRoiMetadata.size() == 1 &&
|
if (multiRoiMetadata.size() == 1 &&
|
||||||
multiRoiMetadata[0].completeRoi()) {
|
multiRoiMetadata[0].completeRoi()) {
|
||||||
int nTotalPixelsX = (generalData->nPixelsX * numPorts.x);
|
int const nTotalPixelsX = (generalData->nPixelsX * numPorts.x);
|
||||||
int nTotalPixelsY = (generalData->nPixelsY * numPorts.y);
|
int const nTotalPixelsY = (generalData->nPixelsY * numPorts.y);
|
||||||
if (nTotalPixelsY == 1) {
|
if (nTotalPixelsY == 1) {
|
||||||
masterAttributes.rois.push_back(ROI{0, nTotalPixelsX - 1});
|
masterAttributes.rois.push_back(ROI{0, nTotalPixelsX - 1});
|
||||||
} else {
|
} else {
|
||||||
@@ -1180,7 +1180,7 @@ int Implementation::getUDPSocketBufferSize() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setUDPSocketBufferSize(const int s) {
|
void Implementation::setUDPSocketBufferSize(const int s) {
|
||||||
size_t listSize = listener.size();
|
size_t const listSize = listener.size();
|
||||||
if ((generalData->detType == JUNGFRAU || generalData->detType == MOENCH ||
|
if ((generalData->detType == JUNGFRAU || generalData->detType == MOENCH ||
|
||||||
generalData->detType == GOTTHARD2) &&
|
generalData->detType == GOTTHARD2) &&
|
||||||
(int)listSize != generalData->numUDPInterfaces) {
|
(int)listSize != generalData->numUDPInterfaces) {
|
||||||
@@ -1572,7 +1572,7 @@ void Implementation::setCounterMask(const uint32_t i) {
|
|||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Counter mask: " << ToStringHex(generalData->counterMask);
|
LOG(logINFO) << "Counter mask: " << ToStringHex(generalData->counterMask);
|
||||||
int ncounters = __builtin_popcount(generalData->counterMask);
|
int const ncounters = __builtin_popcount(generalData->counterMask);
|
||||||
LOG(logINFO) << "Number of counters: " << ncounters;
|
LOG(logINFO) << "Number of counters: " << ncounters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1661,13 +1661,13 @@ void Implementation::setActivate(bool enable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Implementation::getDetectorDataStream(const portPosition port) const {
|
bool Implementation::getDetectorDataStream(const portPosition port) const {
|
||||||
int index = (port == LEFT ? 0 : 1);
|
int const index = (port == LEFT ? 0 : 1);
|
||||||
return detectorDataStream[index];
|
return detectorDataStream[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setDetectorDataStream(const portPosition port,
|
void Implementation::setDetectorDataStream(const portPosition port,
|
||||||
const bool enable) {
|
const bool enable) {
|
||||||
int index = (port == LEFT ? 0 : 1);
|
int const index = (port == LEFT ? 0 : 1);
|
||||||
detectorDataStream10GbE[index] = enable;
|
detectorDataStream10GbE[index] = enable;
|
||||||
LOG(logINFO) << "Detector 10GbE datastream (" << ToString(port)
|
LOG(logINFO) << "Detector 10GbE datastream (" << ToString(port)
|
||||||
<< " Port): " << ToString(detectorDataStream10GbE[index]);
|
<< " Port): " << ToString(detectorDataStream10GbE[index]);
|
||||||
|
|||||||
@@ -193,10 +193,10 @@ void Listener::DeleteUDPSocket() {
|
|||||||
void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int &actualSize) {
|
void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int &actualSize) {
|
||||||
// custom setup (s != 0)
|
// custom setup (s != 0)
|
||||||
// default setup at startup (s = 0)
|
// default setup at startup (s = 0)
|
||||||
int size = (s == 0 ? generalData->udpSocketBufferSize : s);
|
int const size = (s == 0 ? generalData->udpSocketBufferSize : s);
|
||||||
LOG(logINFO) << "Testing UDP Socket Buffer size " << size
|
LOG(logINFO) << "Testing UDP Socket Buffer size " << size
|
||||||
<< " with test port " << udpPortNumber;
|
<< " with test port " << udpPortNumber;
|
||||||
int previousSize = generalData->udpSocketBufferSize;
|
int const previousSize = generalData->udpSocketBufferSize;
|
||||||
generalData->udpSocketBufferSize = size;
|
generalData->udpSocketBufferSize = size;
|
||||||
|
|
||||||
if (disabledPort) {
|
if (disabledPort) {
|
||||||
@@ -217,7 +217,7 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int &actualSize) {
|
|||||||
std::string ip;
|
std::string ip;
|
||||||
if (eth.length() > 0)
|
if (eth.length() > 0)
|
||||||
ip = InterfaceNameToIp(eth).str();
|
ip = InterfaceNameToIp(eth).str();
|
||||||
UdpRxSocket g(udpPortNumber, packetSize,
|
UdpRxSocket const g(udpPortNumber, packetSize,
|
||||||
(ip.empty() ? nullptr : ip.c_str()),
|
(ip.empty() ? nullptr : ip.c_str()),
|
||||||
generalData->udpSocketBufferSize);
|
generalData->udpSocketBufferSize);
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ void Listener::ThreadExecution() {
|
|||||||
|
|
||||||
// reset header and size and get data
|
// reset header and size and get data
|
||||||
memset(memImage, 0, IMAGE_STRUCTURE_HEADER_SIZE);
|
memset(memImage, 0, IMAGE_STRUCTURE_HEADER_SIZE);
|
||||||
int rc = ListenToAnImage(memImage->header, memImage->data);
|
int const rc = ListenToAnImage(memImage->header, memImage->data);
|
||||||
|
|
||||||
// end of acquisition or discarding image
|
// end of acquisition or discarding image
|
||||||
if (rc <= 0) {
|
if (rc <= 0) {
|
||||||
@@ -320,9 +320,9 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header &dstHeader,
|
|||||||
hsize = generalData->vetoHsize;
|
hsize = generalData->vetoHsize;
|
||||||
standardHeader = false;
|
standardHeader = false;
|
||||||
}
|
}
|
||||||
uint32_t pperFrame = generalData->packetsPerFrame;
|
uint32_t const pperFrame = generalData->packetsPerFrame;
|
||||||
bool isHeaderEmpty = true;
|
bool isHeaderEmpty = true;
|
||||||
uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - imageSize);
|
uint32_t const corrected_dsize = dsize - ((pperFrame * dsize) - imageSize);
|
||||||
sls_detector_header *srcDetHeader = nullptr;
|
sls_detector_header *srcDetHeader = nullptr;
|
||||||
|
|
||||||
// carry over packet
|
// carry over packet
|
||||||
@@ -516,9 +516,9 @@ void Listener::PrintFifoStatistics() {
|
|||||||
<< " packetsperframe:" << generalData->packetsPerFrame;
|
<< " packetsperframe:" << generalData->packetsPerFrame;
|
||||||
|
|
||||||
// calculate packet loss
|
// calculate packet loss
|
||||||
int64_t totalP = numFramesStatistic * (generalData->packetsPerFrame);
|
int64_t const totalP = numFramesStatistic * (generalData->packetsPerFrame);
|
||||||
int64_t loss = totalP - numPacketsStatistic;
|
int64_t const loss = totalP - numPacketsStatistic;
|
||||||
int lossPercent = ((double)loss / (double)totalP) * 100.00;
|
int const lossPercent = ((double)loss / (double)totalP) * 100.00;
|
||||||
numPacketsStatistic = 0;
|
numPacketsStatistic = 0;
|
||||||
numFramesStatistic = 0;
|
numFramesStatistic = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -756,7 +756,7 @@ void MasterAttributes::WriteHDF5Version(H5::H5File *fd) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void MasterAttributes::WriteBinaryTimestamp(writer *w) {
|
void MasterAttributes::WriteBinaryTimestamp(writer *w) {
|
||||||
time_t t = std::time(nullptr);
|
time_t const t = std::time(nullptr);
|
||||||
std::string sTime(ctime(&t));
|
std::string sTime(ctime(&t));
|
||||||
std::replace(sTime.begin(), sTime.end(), '\n', '\0');
|
std::replace(sTime.begin(), sTime.end(), '\n', '\0');
|
||||||
WriteBinary(w, N_TIMESTAMP.data(), sTime);
|
WriteBinary(w, N_TIMESTAMP.data(), sTime);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void GetData(slsDetectorDefs::sls_receiver_header &header,
|
|||||||
slsDetectorDefs::dataCallbackHeader callbackHeader,
|
slsDetectorDefs::dataCallbackHeader callbackHeader,
|
||||||
char *dataPointer, size_t &imageSize, void *objectPointer) {
|
char *dataPointer, size_t &imageSize, void *objectPointer) {
|
||||||
|
|
||||||
slsDetectorDefs::sls_detector_header detectorHeader = header.detHeader;
|
slsDetectorDefs::sls_detector_header const detectorHeader = header.detHeader;
|
||||||
|
|
||||||
PRINT_IN_COLOR(
|
PRINT_IN_COLOR(
|
||||||
(callbackHeader.udpPort % 10),
|
(callbackHeader.udpPort % 10),
|
||||||
@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) {
|
|||||||
for (int i = 0; i < m.numReceivers; ++i) {
|
for (int i = 0; i < m.numReceivers; ++i) {
|
||||||
|
|
||||||
/** - fork process to create child process */
|
/** - fork process to create child process */
|
||||||
pid_t pid = fork();
|
pid_t const pid = fork();
|
||||||
|
|
||||||
/** - if fork failed, raise SIGINT and properly destroy all child
|
/** - if fork failed, raise SIGINT and properly destroy all child
|
||||||
* processes */
|
* processes */
|
||||||
@@ -185,7 +185,7 @@ int main(int argc, char *argv[]) {
|
|||||||
<< "Child process " << i << " [ Tid: " << gettid() << ']';
|
<< "Child process " << i << " [ Tid: " << gettid() << ']';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
uint16_t port = m.port + i;
|
uint16_t const port = m.port + i;
|
||||||
sls::Receiver receiver(port);
|
sls::Receiver receiver(port);
|
||||||
|
|
||||||
/** - register callbacks. remember to set file write enable
|
/** - register callbacks. remember to set file write enable
|
||||||
@@ -236,7 +236,7 @@ int main(int argc, char *argv[]) {
|
|||||||
/** - Parent process waits for all child processes to exit */
|
/** - Parent process waits for all child processes to exit */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int status;
|
int status;
|
||||||
pid_t childPid = waitpid(-1, &status, 0);
|
pid_t const childPid = waitpid(-1, &status, 0);
|
||||||
|
|
||||||
// no child closed
|
// no child closed
|
||||||
if (childPid == -1) {
|
if (childPid == -1) {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ int main(int argc, char *argv[]) {
|
|||||||
sem_init(&semaphore, 1, 0);
|
sem_init(&semaphore, 1, 0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sls::Receiver r(o.port);
|
sls::Receiver const r(o.port);
|
||||||
LOG(sls::logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
LOG(sls::logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
||||||
sem_wait(&semaphore);
|
sem_wait(&semaphore);
|
||||||
sem_destroy(&semaphore);
|
sem_destroy(&semaphore);
|
||||||
|
|||||||
@@ -14,19 +14,19 @@ template <typename T, typename U> constexpr bool is_type() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("CommandLineOption construction", "[detector]") {
|
TEST_CASE("CommandLineOption construction", "[detector]") {
|
||||||
CommandLineOptions s(AppType::SingleReceiver);
|
CommandLineOptions const s(AppType::SingleReceiver);
|
||||||
REQUIRE(s.getTypeString() == "slsReceiver");
|
REQUIRE(s.getTypeString() == "slsReceiver");
|
||||||
REQUIRE(s.getVersion() ==
|
REQUIRE(s.getVersion() ==
|
||||||
std::string("slsReceiver Version: ") + APIRECEIVER);
|
std::string("slsReceiver Version: ") + APIRECEIVER);
|
||||||
REQUIRE_NOTHROW(s.getHelpMessage());
|
REQUIRE_NOTHROW(s.getHelpMessage());
|
||||||
|
|
||||||
CommandLineOptions m(AppType::MultiReceiver);
|
CommandLineOptions const m(AppType::MultiReceiver);
|
||||||
REQUIRE(m.getTypeString() == "slsMultiReceiver");
|
REQUIRE(m.getTypeString() == "slsMultiReceiver");
|
||||||
REQUIRE(m.getVersion() ==
|
REQUIRE(m.getVersion() ==
|
||||||
std::string("slsMultiReceiver Version: ") + APIRECEIVER);
|
std::string("slsMultiReceiver Version: ") + APIRECEIVER);
|
||||||
REQUIRE_NOTHROW(m.getHelpMessage());
|
REQUIRE_NOTHROW(m.getHelpMessage());
|
||||||
|
|
||||||
CommandLineOptions f(AppType::FrameSynchronizer);
|
CommandLineOptions const f(AppType::FrameSynchronizer);
|
||||||
REQUIRE(f.getTypeString() == "slsFrameSynchronizer");
|
REQUIRE(f.getTypeString() == "slsFrameSynchronizer");
|
||||||
REQUIRE(f.getVersion() ==
|
REQUIRE(f.getVersion() ==
|
||||||
std::string("slsFrameSynchronizer Version: ") + APIRECEIVER);
|
std::string("slsFrameSynchronizer Version: ") + APIRECEIVER);
|
||||||
@@ -49,7 +49,7 @@ TEST_CASE("Parse Help", "[detector]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Validate common options", "[detector]") {
|
TEST_CASE("Validate common options", "[detector]") {
|
||||||
std::string uidStr = std::to_string(getuid());
|
std::string const uidStr = std::to_string(getuid());
|
||||||
|
|
||||||
for (auto app : {AppType::SingleReceiver, AppType::MultiReceiver,
|
for (auto app : {AppType::SingleReceiver, AppType::MultiReceiver,
|
||||||
AppType::FrameSynchronizer}) {
|
AppType::FrameSynchronizer}) {
|
||||||
@@ -65,7 +65,7 @@ TEST_CASE("Validate common options", "[detector]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Validate specific options", "[detector]") {
|
TEST_CASE("Validate specific options", "[detector]") {
|
||||||
std::string uidStr = std::to_string(getuid());
|
std::string const uidStr = std::to_string(getuid());
|
||||||
|
|
||||||
CommandLineOptions s(AppType::SingleReceiver);
|
CommandLineOptions s(AppType::SingleReceiver);
|
||||||
REQUIRE_NOTHROW(s.parse({"", "-t", "1955"}));
|
REQUIRE_NOTHROW(s.parse({"", "-t", "1955"}));
|
||||||
@@ -138,11 +138,12 @@ TEST_CASE("Parse version and help", "[detector]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Parse port and uid", "[detector]") {
|
// TODO: fails on gitea CI due to uid issue, fix later
|
||||||
|
TEST_CASE("Parse port and uid", "[.failsongitea][detector]") {
|
||||||
uid_t uid = getuid();
|
uid_t uid = getuid();
|
||||||
std::string uidStr = std::to_string(uid);
|
std::string const uidStr = std::to_string(uid);
|
||||||
uid_t invalidUid = uid + 1000;
|
uid_t const invalidUid = uid + 1000;
|
||||||
std::string invalidUidStr = std::to_string(invalidUid);
|
std::string const invalidUidStr = std::to_string(invalidUid);
|
||||||
|
|
||||||
for (auto app : {AppType::SingleReceiver, AppType::MultiReceiver,
|
for (auto app : {AppType::SingleReceiver, AppType::MultiReceiver,
|
||||||
AppType::FrameSynchronizer}) {
|
AppType::FrameSynchronizer}) {
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ class DataProcessorTest : public DataProcessor {
|
|||||||
* num_transceiver_bytes = 2 both bytes have a value of 125
|
* num_transceiver_bytes = 2 both bytes have a value of 125
|
||||||
* num_digital_bytes is variable and is defined by number of samples
|
* num_digital_bytes is variable and is defined by number of samples
|
||||||
* default num sample is 5
|
* default num sample is 5
|
||||||
* all bytes in digital data take a value of 255
|
* all bytes in digital data take a value of 0xFF (alternating bits between 0,
|
||||||
|
* 1)
|
||||||
*/
|
*/
|
||||||
class DataProcessorTestFixture {
|
class DataProcessorTestFixture {
|
||||||
public:
|
public:
|
||||||
@@ -106,11 +107,11 @@ class DataProcessorTestFixture {
|
|||||||
num_random_offset_bytes);
|
num_random_offset_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_data() {
|
void set_data(const std::bitset<8> pattern = 0xFF) {
|
||||||
delete[] data;
|
delete[] data;
|
||||||
uint64_t max_bytes_per_bit =
|
uint64_t const max_bytes_per_bit =
|
||||||
num_samples % 8 == 0 ? num_samples / 8 : num_samples / 8 + 1;
|
num_samples % 8 == 0 ? num_samples / 8 : num_samples / 8 + 1;
|
||||||
uint64_t reserved_size =
|
uint64_t const reserved_size =
|
||||||
get_size() - num_digital_bytes + max_bytes_per_bit * 64;
|
get_size() - num_digital_bytes + max_bytes_per_bit * 64;
|
||||||
data = new char[reserved_size];
|
data = new char[reserved_size];
|
||||||
|
|
||||||
@@ -118,7 +119,8 @@ class DataProcessorTestFixture {
|
|||||||
memset(data, dummy_value, num_analog_bytes); // set to dummy value
|
memset(data, dummy_value, num_analog_bytes); // set to dummy value
|
||||||
memset(data + num_analog_bytes, 0,
|
memset(data + num_analog_bytes, 0,
|
||||||
num_random_offset_bytes); // set to zero
|
num_random_offset_bytes); // set to zero
|
||||||
memset(data + num_analog_bytes + num_random_offset_bytes, 0xFF,
|
memset(data + num_analog_bytes + num_random_offset_bytes,
|
||||||
|
static_cast<uint8_t>(pattern.to_ulong()),
|
||||||
num_digital_bytes); // all digital bits are one
|
num_digital_bytes); // all digital bits are one
|
||||||
memset(data + num_digital_bytes + num_analog_bytes +
|
memset(data + num_digital_bytes + num_analog_bytes +
|
||||||
num_random_offset_bytes,
|
num_random_offset_bytes,
|
||||||
@@ -146,7 +148,7 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Remove Trailing Bits",
|
|||||||
|
|
||||||
generaldata->SetCtbDbitOffset(num_random_offset_bytes);
|
generaldata->SetCtbDbitOffset(num_random_offset_bytes);
|
||||||
|
|
||||||
size_t expected_size = get_size() - num_random_offset_bytes;
|
size_t const expected_size = get_size() - num_random_offset_bytes;
|
||||||
|
|
||||||
char *expected_data = new char[expected_size];
|
char *expected_data = new char[expected_size];
|
||||||
memset(expected_data, dummy_value, num_analog_bytes); // set to 125
|
memset(expected_data, dummy_value, num_analog_bytes); // set to 125
|
||||||
@@ -170,7 +172,7 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Remove Trailing Bits",
|
|||||||
TEST_CASE_METHOD(DataProcessorTestFixture, "Reorder all",
|
TEST_CASE_METHOD(DataProcessorTestFixture, "Reorder all",
|
||||||
"[.dataprocessor][.reorder]") {
|
"[.dataprocessor][.reorder]") {
|
||||||
// parameters: num_samples, expected_num_digital_bytes,
|
// parameters: num_samples, expected_num_digital_bytes,
|
||||||
// expected_digital_part
|
// expected_digital_part_for_each_bit
|
||||||
auto parameters = GENERATE(
|
auto parameters = GENERATE(
|
||||||
std::make_tuple(5, 64, std::vector<uint8_t>{0b00011111}),
|
std::make_tuple(5, 64, std::vector<uint8_t>{0b00011111}),
|
||||||
std::make_tuple(10, 2 * 64, std::vector<uint8_t>{0xFF, 0b00000011}),
|
std::make_tuple(10, 2 * 64, std::vector<uint8_t>{0xFF, 0b00000011}),
|
||||||
@@ -264,11 +266,13 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder false",
|
|||||||
// expected_digital_part
|
// expected_digital_part
|
||||||
auto parameters = GENERATE(
|
auto parameters = GENERATE(
|
||||||
std::make_tuple(5, std::vector<int>{1, 4, 5}, 5,
|
std::make_tuple(5, std::vector<int>{1, 4, 5}, 5,
|
||||||
std::vector<uint8_t>{0b00000111}),
|
std::vector<uint8_t>{0b00000010}),
|
||||||
|
std::make_tuple(5, std::vector<int>{1, 5, 4}, 5,
|
||||||
|
std::vector<uint8_t>{0b00000100}),
|
||||||
std::make_tuple(5, std::vector<int>{1, 5, 3, 7, 8, 50, 42, 60, 39}, 10,
|
std::make_tuple(5, std::vector<int>{1, 5, 3, 7, 8, 50, 42, 60, 39}, 10,
|
||||||
std::vector<uint8_t>{0xFF, 0b00000001}),
|
std::vector<uint8_t>{0b11110000, 0b00000000}),
|
||||||
std::make_tuple(5, std::vector<int>{1, 5, 3, 7, 8, 50, 42, 60}, 5,
|
std::make_tuple(5, std::vector<int>{1, 5, 3, 7, 8, 50, 42, 60}, 5,
|
||||||
std::vector<uint8_t>{0xFF}));
|
std::vector<uint8_t>{0b11110000}));
|
||||||
|
|
||||||
size_t num_samples, expected_num_digital_bytes;
|
size_t num_samples, expected_num_digital_bytes;
|
||||||
std::vector<uint8_t> expected_digital_part;
|
std::vector<uint8_t> expected_digital_part;
|
||||||
@@ -281,9 +285,9 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder false",
|
|||||||
generaldata->SetCtbDbitReorder(false);
|
generaldata->SetCtbDbitReorder(false);
|
||||||
|
|
||||||
set_num_samples(num_samples);
|
set_num_samples(num_samples);
|
||||||
set_data();
|
set_data(0b01010101); // set digital data to 0x55 to have alternating bits
|
||||||
|
|
||||||
size_t expected_size =
|
size_t const expected_size =
|
||||||
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
||||||
|
|
||||||
// create expected data
|
// create expected data
|
||||||
@@ -316,11 +320,15 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder true",
|
|||||||
// expected_digital_part
|
// expected_digital_part
|
||||||
auto parameters = GENERATE(
|
auto parameters = GENERATE(
|
||||||
std::make_tuple(5, std::vector<int>{1, 4, 5}, 3,
|
std::make_tuple(5, std::vector<int>{1, 4, 5}, 3,
|
||||||
std::vector<uint8_t>{0b00011111}),
|
std::vector<uint8_t>{0x00, 0b00011111, 0x00}),
|
||||||
|
std::make_tuple(5, std::vector<int>{1, 5, 4}, 3,
|
||||||
|
std::vector<uint8_t>{0x00, 0x00, 0b00011111}),
|
||||||
std::make_tuple(10, std::vector<int>{1, 4, 5}, 6,
|
std::make_tuple(10, std::vector<int>{1, 4, 5}, 6,
|
||||||
std::vector<uint8_t>{0xFF, 0b00000011}),
|
std::vector<uint8_t>{0x00, 0x00, 0b11111111, 0b00000011,
|
||||||
|
0x00, 0x00}),
|
||||||
std::make_tuple(8, std::vector<int>{1, 5, 3, 7, 8, 50, 42, 60, 39}, 9,
|
std::make_tuple(8, std::vector<int>{1, 5, 3, 7, 8, 50, 42, 60, 39}, 9,
|
||||||
std::vector<uint8_t>{0xFF}));
|
std::vector<uint8_t>{0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||||
|
0xFF, 0xFF, 0x00}));
|
||||||
|
|
||||||
size_t num_samples, expected_num_digital_bytes;
|
size_t num_samples, expected_num_digital_bytes;
|
||||||
std::vector<uint8_t> expected_digital_part;
|
std::vector<uint8_t> expected_digital_part;
|
||||||
@@ -333,9 +341,9 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder true",
|
|||||||
generaldata->SetCtbDbitReorder(true);
|
generaldata->SetCtbDbitReorder(true);
|
||||||
|
|
||||||
set_num_samples(num_samples);
|
set_num_samples(num_samples);
|
||||||
set_data();
|
set_data(0b01010101);
|
||||||
|
|
||||||
size_t expected_size =
|
size_t const expected_size =
|
||||||
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
||||||
|
|
||||||
// create expected data
|
// create expected data
|
||||||
@@ -343,11 +351,8 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder true",
|
|||||||
|
|
||||||
memset(expected_data, dummy_value, num_analog_bytes);
|
memset(expected_data, dummy_value, num_analog_bytes);
|
||||||
|
|
||||||
for (size_t sample = 0; sample < bitlist.size(); ++sample) {
|
memcpy(expected_data + num_analog_bytes, expected_digital_part.data(),
|
||||||
memcpy(expected_data + num_analog_bytes +
|
expected_digital_part.size());
|
||||||
expected_digital_part.size() * sample,
|
|
||||||
expected_digital_part.data(), expected_digital_part.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(expected_data + expected_num_digital_bytes + num_analog_bytes,
|
memset(expected_data + expected_num_digital_bytes + num_analog_bytes,
|
||||||
dummy_value, num_transceiver_bytes);
|
dummy_value, num_transceiver_bytes);
|
||||||
@@ -366,8 +371,8 @@ TEST_CASE_METHOD(DataProcessorTestFixture,
|
|||||||
"Arrange bitlist and remove trailing bits",
|
"Arrange bitlist and remove trailing bits",
|
||||||
"[.dataprocessor][.retrievebitlist]") {
|
"[.dataprocessor][.retrievebitlist]") {
|
||||||
|
|
||||||
size_t num_random_offset_bytes = 3;
|
size_t const num_random_offset_bytes = 3;
|
||||||
std::vector<int> bitlist{1, 4, 5};
|
std::vector<int> const bitlist{1, 4, 5};
|
||||||
|
|
||||||
set_random_offset_bytes(num_random_offset_bytes);
|
set_random_offset_bytes(num_random_offset_bytes);
|
||||||
set_data();
|
set_data();
|
||||||
@@ -381,7 +386,7 @@ TEST_CASE_METHOD(DataProcessorTestFixture,
|
|||||||
std::vector<uint8_t> expected_digital_part{0b00000111};
|
std::vector<uint8_t> expected_digital_part{0b00000111};
|
||||||
const size_t expected_num_digital_bytes = 5;
|
const size_t expected_num_digital_bytes = 5;
|
||||||
|
|
||||||
size_t expected_size =
|
size_t const expected_size =
|
||||||
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
||||||
|
|
||||||
// create expected data
|
// create expected data
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@@ -155,6 +156,10 @@ template <typename Container> bool hasDuplicates(Container c) {
|
|||||||
return pos != c.end(); // if we found something there are duplicates
|
return pos != c.end(); // if we found something there are duplicates
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sorts the container and removes duplicated elements
|
||||||
|
* returns true if elements were removed otherwiese false
|
||||||
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename std::enable_if<is_container<T>::value, bool>::type
|
typename std::enable_if<is_container<T>::value, bool>::type
|
||||||
removeDuplicates(T &c) {
|
removeDuplicates(T &c) {
|
||||||
@@ -167,6 +172,29 @@ removeDuplicates(T &c) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Removed duplicated entries while preserving the oder
|
||||||
|
* returns true if elements were removed otherwiese false
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
typename std::enable_if<is_container<T>::value, bool>::type
|
||||||
|
stableRemoveDuplicates(T &c) {
|
||||||
|
auto containerSize = c.size();
|
||||||
|
std::set<typename T::value_type> seen;
|
||||||
|
c.erase(
|
||||||
|
std::remove_if(c.begin(), c.end(),
|
||||||
|
[&](const typename T::value_type& val) {
|
||||||
|
return !seen.insert(val).second; // erase if already seen
|
||||||
|
}),
|
||||||
|
c.end()
|
||||||
|
);
|
||||||
|
if (c.size() != containerSize) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
|
||||||
#endif // CONTAINER_UTILS_H
|
#endif // CONTAINER_UTILS_H
|
||||||
|
|||||||
@@ -788,9 +788,9 @@ typedef struct {
|
|||||||
|
|
||||||
explicit sls_detector_module(slsDetectorDefs::detectorType type)
|
explicit sls_detector_module(slsDetectorDefs::detectorType type)
|
||||||
: sls_detector_module() {
|
: sls_detector_module() {
|
||||||
detParameters parameters{type};
|
const detParameters parameters{type}; //used to initialize
|
||||||
int nch = parameters.nChanX * parameters.nChanY;
|
const int nch = parameters.nChanX * parameters.nChanY;
|
||||||
int nc = parameters.nChipX * parameters.nChipY;
|
const int nc = parameters.nChipX * parameters.nChipY;
|
||||||
ndac = parameters.nDacs;
|
ndac = parameters.nDacs;
|
||||||
nchip = nc;
|
nchip = nc;
|
||||||
nchan = nch * nc;
|
nchan = nch * nc;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ ClientSocket::ClientSocket(std::string stype, const std::string &host,
|
|||||||
hints.ai_flags |= AI_CANONNAME;
|
hints.ai_flags |= AI_CANONNAME;
|
||||||
|
|
||||||
if (getaddrinfo(host.c_str(), nullptr, &hints, &result) != 0) {
|
if (getaddrinfo(host.c_str(), nullptr, &hints, &result) != 0) {
|
||||||
std::string msg = "ClientSocket cannot decode host:" + host +
|
std::string const msg = "ClientSocket cannot decode host:" + host +
|
||||||
" on port " + std::to_string(port) + "\n";
|
" on port " + std::to_string(port) + "\n";
|
||||||
throw SocketError(msg);
|
throw SocketError(msg);
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ ClientSocket::ClientSocket(std::string stype, const std::string &host,
|
|||||||
if (::connect(getSocketId(), (struct sockaddr *)&serverAddr,
|
if (::connect(getSocketId(), (struct sockaddr *)&serverAddr,
|
||||||
sizeof(serverAddr)) != 0) {
|
sizeof(serverAddr)) != 0) {
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
std::string msg = "ClientSocket: Cannot connect to " + socketType +
|
std::string const msg = "ClientSocket: Cannot connect to " + socketType +
|
||||||
":" + host + " on port " + std::to_string(port) +
|
":" + host + " on port " + std::to_string(port) +
|
||||||
"\n";
|
"\n";
|
||||||
throw SocketError(msg);
|
throw SocketError(msg);
|
||||||
@@ -54,7 +54,7 @@ ClientSocket::ClientSocket(std::string sType, struct sockaddr_in addr)
|
|||||||
if (::connect(getSocketId(), (struct sockaddr *)&addr, sizeof(addr)) != 0) {
|
if (::connect(getSocketId(), (struct sockaddr *)&addr, sizeof(addr)) != 0) {
|
||||||
char address[INET_ADDRSTRLEN];
|
char address[INET_ADDRSTRLEN];
|
||||||
inet_ntop(AF_INET, &addr.sin_addr, address, INET_ADDRSTRLEN);
|
inet_ntop(AF_INET, &addr.sin_addr, address, INET_ADDRSTRLEN);
|
||||||
std::string msg = "ClientSocket: Cannot connect to " + socketType +
|
std::string const msg = "ClientSocket: Cannot connect to " + socketType +
|
||||||
":" + address + " on port " +
|
":" + address + " on port " +
|
||||||
std::to_string(addr.sin_port) + "\n";
|
std::to_string(addr.sin_port) + "\n";
|
||||||
throw SocketError(msg);
|
throw SocketError(msg);
|
||||||
@@ -77,7 +77,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
|
|||||||
try {
|
try {
|
||||||
Receive(&ret, sizeof(ret));
|
Receive(&ret, sizeof(ret));
|
||||||
if (ret == slsDetectorDefs::FAIL) {
|
if (ret == slsDetectorDefs::FAIL) {
|
||||||
std::string mess = readErrorMessage();
|
std::string const mess = readErrorMessage();
|
||||||
// Do we need to know hostname here?
|
// Do we need to know hostname here?
|
||||||
// In that case save it???
|
// In that case save it???
|
||||||
if (socketType == "Receiver") {
|
if (socketType == "Receiver") {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void DataSocket::setFnum(const int fnum) { fnum_ = fnum; }
|
|||||||
|
|
||||||
int DataSocket::Receive(void *buffer, size_t size) {
|
int DataSocket::Receive(void *buffer, size_t size) {
|
||||||
// TODO!(Erik) Add sleep? how many reties?
|
// TODO!(Erik) Add sleep? how many reties?
|
||||||
int bytes_expected = static_cast<int>(size); // signed size
|
int const bytes_expected = static_cast<int>(size); // signed size
|
||||||
int bytes_read = 0;
|
int bytes_read = 0;
|
||||||
while (bytes_read < bytes_expected) {
|
while (bytes_read < bytes_expected) {
|
||||||
auto this_read =
|
auto this_read =
|
||||||
@@ -79,7 +79,7 @@ std::string DataSocket::Receive(size_t length) {
|
|||||||
}
|
}
|
||||||
int DataSocket::Send(const void *buffer, size_t size) {
|
int DataSocket::Send(const void *buffer, size_t size) {
|
||||||
int bytes_sent = 0;
|
int bytes_sent = 0;
|
||||||
int data_size = static_cast<int>(size); // signed size
|
int const data_size = static_cast<int>(size); // signed size
|
||||||
while (bytes_sent < (data_size)) {
|
while (bytes_sent < (data_size)) {
|
||||||
auto this_send = ::write(getSocketId(), buffer, size);
|
auto this_send = ::write(getSocketId(), buffer, size);
|
||||||
if (this_send <= 0)
|
if (this_send <= 0)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ ServerInterface ServerSocket::accept() {
|
|||||||
lastClient = thisClient; // update from previous connection
|
lastClient = thisClient; // update from previous connection
|
||||||
struct sockaddr_in clientAddr;
|
struct sockaddr_in clientAddr;
|
||||||
socklen_t addr_size = sizeof clientAddr;
|
socklen_t addr_size = sizeof clientAddr;
|
||||||
int newSocket =
|
int const newSocket =
|
||||||
::accept(getSocketId(), (struct sockaddr *)&clientAddr, &addr_size);
|
::accept(getSocketId(), (struct sockaddr *)&clientAddr, &addr_size);
|
||||||
if (newSocket == -1) {
|
if (newSocket == -1) {
|
||||||
throw SocketError("Server ERROR: socket accept failed\n");
|
throw SocketError("Server ERROR: socket accept failed\n");
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ std::string ToString(const defs::portPosition s) {
|
|||||||
|
|
||||||
std::string ToString(const defs::streamingInterface s) {
|
std::string ToString(const defs::streamingInterface s) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
std::string rs;
|
std::string const rs;
|
||||||
switch (s) {
|
switch (s) {
|
||||||
case defs::streamingInterface::NONE:
|
case defs::streamingInterface::NONE:
|
||||||
return std::string("none");
|
return std::string("none");
|
||||||
@@ -1128,8 +1128,8 @@ template <> defs::collectionMode StringTo(const std::string &s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <> uint8_t StringTo(const std::string &s) {
|
template <> uint8_t StringTo(const std::string &s) {
|
||||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
int const base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||||
int value = std::stoi(s, nullptr, base);
|
int const value = std::stoi(s, nullptr, base);
|
||||||
if (value < std::numeric_limits<uint8_t>::min() ||
|
if (value < std::numeric_limits<uint8_t>::min() ||
|
||||||
value > std::numeric_limits<uint8_t>::max()) {
|
value > std::numeric_limits<uint8_t>::max()) {
|
||||||
throw RuntimeError("Cannot scan uint8_t from string '" + s +
|
throw RuntimeError("Cannot scan uint8_t from string '" + s +
|
||||||
@@ -1139,8 +1139,8 @@ template <> uint8_t StringTo(const std::string &s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <> uint16_t StringTo(const std::string &s) {
|
template <> uint16_t StringTo(const std::string &s) {
|
||||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
int const base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||||
int value = std::stoi(s, nullptr, base);
|
int const value = std::stoi(s, nullptr, base);
|
||||||
if (value < std::numeric_limits<uint16_t>::min() ||
|
if (value < std::numeric_limits<uint16_t>::min() ||
|
||||||
value > std::numeric_limits<uint16_t>::max()) {
|
value > std::numeric_limits<uint16_t>::max()) {
|
||||||
throw RuntimeError("Cannot scan uint16_t from string '" + s +
|
throw RuntimeError("Cannot scan uint16_t from string '" + s +
|
||||||
@@ -1150,22 +1150,22 @@ template <> uint16_t StringTo(const std::string &s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <> uint32_t StringTo(const std::string &s) {
|
template <> uint32_t StringTo(const std::string &s) {
|
||||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
int const base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||||
return std::stoul(s, nullptr, base);
|
return std::stoul(s, nullptr, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> uint64_t StringTo(const std::string &s) {
|
template <> uint64_t StringTo(const std::string &s) {
|
||||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
int const base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||||
return std::stoull(s, nullptr, base);
|
return std::stoull(s, nullptr, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> int StringTo(const std::string &s) {
|
template <> int StringTo(const std::string &s) {
|
||||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
int const base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||||
return std::stoi(s, nullptr, base);
|
return std::stoi(s, nullptr, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> bool StringTo(const std::string &s) {
|
template <> bool StringTo(const std::string &s) {
|
||||||
int i = std::stoi(s, nullptr, 10);
|
int const i = std::stoi(s, nullptr, 10);
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
return false;
|
return false;
|
||||||
@@ -1177,7 +1177,7 @@ template <> bool StringTo(const std::string &s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <> int64_t StringTo(const std::string &s) {
|
template <> int64_t StringTo(const std::string &s) {
|
||||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
int const base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||||
return std::stol(s, nullptr, base);
|
return std::stol(s, nullptr, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -305,8 +305,8 @@ int ZmqSocket::SendHeader(int index, zmqHeader header) {
|
|||||||
oss << ", \"rx_roi\":[" << header.rx_roi[0] << ", " << header.rx_roi[1]
|
oss << ", \"rx_roi\":[" << header.rx_roi[0] << ", " << header.rx_roi[1]
|
||||||
<< ", " << header.rx_roi[2] << ", " << header.rx_roi[3] << "]";
|
<< ", " << header.rx_roi[2] << ", " << header.rx_roi[3] << "]";
|
||||||
oss << "}\n";
|
oss << "}\n";
|
||||||
std::string message = oss.str();
|
std::string const message = oss.str();
|
||||||
int length = message.length();
|
int const length = message.length();
|
||||||
#ifdef ZMQ_DETAIL
|
#ifdef ZMQ_DETAIL
|
||||||
// if(!index)
|
// if(!index)
|
||||||
LOG(logINFOBLUE) << index << " : Streamer: buf: " << message;
|
LOG(logINFOBLUE) << index << " : Streamer: buf: " << message;
|
||||||
@@ -436,7 +436,7 @@ int ZmqSocket::ParseHeader(const int index, int length, char *buff,
|
|||||||
int ZmqSocket::ReceiveData(const int index, char *buf, const int size) {
|
int ZmqSocket::ReceiveData(const int index, char *buf, const int size) {
|
||||||
zmq_msg_t message;
|
zmq_msg_t message;
|
||||||
zmq_msg_init(&message);
|
zmq_msg_init(&message);
|
||||||
int length = ReceiveMessage(index, message);
|
int const length = ReceiveMessage(index, message);
|
||||||
if (length == size) {
|
if (length == size) {
|
||||||
memcpy(buf, (char *)zmq_msg_data(&message), size);
|
memcpy(buf, (char *)zmq_msg_data(&message), size);
|
||||||
} else if (length < size) {
|
} else if (length < size) {
|
||||||
@@ -453,7 +453,7 @@ int ZmqSocket::ReceiveData(const int index, char *buf, const int size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ZmqSocket::ReceiveMessage(const int index, zmq_msg_t &message) {
|
int ZmqSocket::ReceiveMessage(const int index, zmq_msg_t &message) {
|
||||||
int length = zmq_msg_recv(&message, sockfd.socketDescriptor, 0);
|
int const length = zmq_msg_recv(&message, sockfd.socketDescriptor, 0);
|
||||||
if (length == -1) {
|
if (length == -1) {
|
||||||
PrintError();
|
PrintError();
|
||||||
LOG(logERROR) << "Could not read header for socket " << index;
|
LOG(logERROR) << "Could not read header for socket " << index;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ int readDataFile(std::ifstream &infile, short int *data, int nch, int offset) {
|
|||||||
int readDataFile(std::string fname, short int *data, int nch) {
|
int readDataFile(std::string fname, short int *data, int nch) {
|
||||||
std::ifstream infile;
|
std::ifstream infile;
|
||||||
int iline = 0;
|
int iline = 0;
|
||||||
std::string str;
|
std::string const str;
|
||||||
infile.open(fname.c_str(), std::ios_base::in);
|
infile.open(fname.c_str(), std::ios_base::in);
|
||||||
if (infile.is_open()) {
|
if (infile.is_open()) {
|
||||||
iline = readDataFile(infile, data, nch, 0);
|
iline = readDataFile(infile, data, nch, 0);
|
||||||
@@ -80,7 +80,7 @@ std::vector<char> readBinaryFile(const std::string &fname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get file size to print progress
|
// get file size to print progress
|
||||||
ssize_t filesize = getFileSize(fp, errorPrefix);
|
ssize_t const filesize = getFileSize(fp, errorPrefix);
|
||||||
|
|
||||||
std::vector<char> buffer(filesize, 0);
|
std::vector<char> buffer(filesize, 0);
|
||||||
if ((ssize_t)fread(buffer.data(), sizeof(char), filesize, fp) != filesize) {
|
if ((ssize_t)fread(buffer.data(), sizeof(char), filesize, fp) != filesize) {
|
||||||
@@ -142,14 +142,14 @@ void mkdir_p(const std::string &path, std::string dir) {
|
|||||||
int getFileSize(std::ifstream &ifs) {
|
int getFileSize(std::ifstream &ifs) {
|
||||||
auto current_pos = ifs.tellg();
|
auto current_pos = ifs.tellg();
|
||||||
ifs.seekg(0, std::ios::end);
|
ifs.seekg(0, std::ios::end);
|
||||||
int file_size = ifs.tellg();
|
int const file_size = ifs.tellg();
|
||||||
ifs.seekg(current_pos);
|
ifs.seekg(current_pos);
|
||||||
return file_size;
|
return file_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getFileNameFromFilePath(const std::string &fpath) {
|
std::string getFileNameFromFilePath(const std::string &fpath) {
|
||||||
std::string fname(fpath);
|
std::string fname(fpath);
|
||||||
std::size_t slashPos = fpath.rfind('/');
|
std::size_t const slashPos = fpath.rfind('/');
|
||||||
if (slashPos != std::string::npos) {
|
if (slashPos != std::string::npos) {
|
||||||
fname = fpath.substr(slashPos + 1, fpath.size() - 1);
|
fname = fpath.substr(slashPos + 1, fpath.size() - 1);
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ ssize_t getFileSize(FILE *fd, const std::string &prependErrorString) {
|
|||||||
throw RuntimeError(prependErrorString +
|
throw RuntimeError(prependErrorString +
|
||||||
std::string(" (Seek error in src file)"));
|
std::string(" (Seek error in src file)"));
|
||||||
}
|
}
|
||||||
size_t fileSize = ftell(fd);
|
size_t const fileSize = ftell(fd);
|
||||||
if (fileSize <= 0) {
|
if (fileSize <= 0) {
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
prependErrorString +
|
prependErrorString +
|
||||||
@@ -181,7 +181,7 @@ getChannelsFromStringList(const std::vector<std::string> list) {
|
|||||||
begin(line), end(line), [](char c) { return (c == ','); }, ' ');
|
begin(line), end(line), [](char c) { return (c == ','); }, ' ');
|
||||||
|
|
||||||
// split line (delim space)
|
// split line (delim space)
|
||||||
std::vector<std::string> vec = split(line, ' ');
|
std::vector<std::string> const vec = split(line, ' ');
|
||||||
|
|
||||||
// for every channel separated by space
|
// for every channel separated by space
|
||||||
for (auto it : vec) {
|
for (auto it : vec) {
|
||||||
@@ -189,8 +189,8 @@ getChannelsFromStringList(const std::vector<std::string> list) {
|
|||||||
auto result = it.find(':');
|
auto result = it.find(':');
|
||||||
if (result != std::string::npos) {
|
if (result != std::string::npos) {
|
||||||
try {
|
try {
|
||||||
int istart = StringTo<int>(it.substr(0, result));
|
int const istart = StringTo<int>(it.substr(0, result));
|
||||||
int istop = StringTo<int>(
|
int const istop = StringTo<int>(
|
||||||
it.substr(result + 1, it.length() - result - 1));
|
it.substr(result + 1, it.length() - result - 1));
|
||||||
LOG(logDEBUG1) << "istart:" << istart << " istop:" << istop;
|
LOG(logDEBUG1) << "istart:" << istart << " istop:" << istop;
|
||||||
std::vector<int> range(istop - istart);
|
std::vector<int> range(istop - istart);
|
||||||
@@ -275,7 +275,7 @@ std::string getAbsolutePathFromCurrentProcess(const std::string &fname) {
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
ssize_t len = readlink("/proc/self/exe", path.data(), PATH_MAX - 1);
|
ssize_t const len = readlink("/proc/self/exe", path.data(), PATH_MAX - 1);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
throw RuntimeError("Could not get absolute path for " + fname);
|
throw RuntimeError("Could not get absolute path for " + fname);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ IpAddr HostnameToIp(const char *hostname) {
|
|||||||
throw RuntimeError("Could not convert hostname (" +
|
throw RuntimeError("Could not convert hostname (" +
|
||||||
std::string(hostname) + ") to ip");
|
std::string(hostname) + ") to ip");
|
||||||
}
|
}
|
||||||
uint32_t ip = ((sockaddr_in *)result->ai_addr)->sin_addr.s_addr;
|
uint32_t const ip = ((sockaddr_in *)result->ai_addr)->sin_addr.s_addr;
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
return IpAddr(ip);
|
return IpAddr(ip);
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ MacAddr InterfaceNameToMac(const std::string &inf) {
|
|||||||
const int mac_len = sizeof(mac);
|
const int mac_len = sizeof(mac);
|
||||||
memset(mac, 0, mac_len);
|
memset(mac, 0, mac_len);
|
||||||
|
|
||||||
int sock = socket(PF_INET, SOCK_STREAM, 0);
|
int const sock = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
strncpy(ifr.ifr_name, inf.c_str(), sizeof(ifr.ifr_name) - 1);
|
strncpy(ifr.ifr_name, inf.c_str(), sizeof(ifr.ifr_name) - 1);
|
||||||
ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
|
ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ TEST_CASE("StaticVector is a container") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Comparing StaticVector containers") {
|
TEST_CASE("Comparing StaticVector containers") {
|
||||||
StaticVector<int, 5> a{0, 1, 2};
|
StaticVector<int, 5> const a{0, 1, 2};
|
||||||
StaticVector<int, 5> b{0, 1, 2};
|
StaticVector<int, 5> const b{0, 1, 2};
|
||||||
StaticVector<int, 5> c{0, 1, 2, 4};
|
StaticVector<int, 5> const c{0, 1, 2, 4};
|
||||||
|
|
||||||
REQUIRE(a == b);
|
REQUIRE(a == b);
|
||||||
REQUIRE_FALSE(a != b);
|
REQUIRE_FALSE(a != b);
|
||||||
@@ -29,9 +29,9 @@ TEST_CASE("Comparing StaticVector containers") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Compare array and fixed capacity container") {
|
TEST_CASE("Compare array and fixed capacity container") {
|
||||||
std::array<int, 3> arr{1, 2, 3};
|
std::array<int, 3> const arr{1, 2, 3};
|
||||||
std::array<int, 3> arr2{1, 7, 3};
|
std::array<int, 3> const arr2{1, 7, 3};
|
||||||
StaticVector<int, 7> fcc{1, 2, 3};
|
StaticVector<int, 7> const fcc{1, 2, 3};
|
||||||
REQUIRE(fcc == arr);
|
REQUIRE(fcc == arr);
|
||||||
REQUIRE(arr == fcc);
|
REQUIRE(arr == fcc);
|
||||||
REQUIRE_FALSE(fcc != arr);
|
REQUIRE_FALSE(fcc != arr);
|
||||||
@@ -41,9 +41,9 @@ TEST_CASE("Compare array and fixed capacity container") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Compare vector and fixed capacity container") {
|
TEST_CASE("Compare vector and fixed capacity container") {
|
||||||
std::vector<int> vec{1, 2, 3};
|
std::vector<int> const vec{1, 2, 3};
|
||||||
std::vector<int> vec2{10, 2, 3};
|
std::vector<int> const vec2{10, 2, 3};
|
||||||
StaticVector<int, 7> fcc{1, 2, 3};
|
StaticVector<int, 7> const fcc{1, 2, 3};
|
||||||
REQUIRE(fcc == vec);
|
REQUIRE(fcc == vec);
|
||||||
REQUIRE(vec == fcc);
|
REQUIRE(vec == fcc);
|
||||||
REQUIRE_FALSE(fcc != vec);
|
REQUIRE_FALSE(fcc != vec);
|
||||||
@@ -53,46 +53,46 @@ TEST_CASE("Compare vector and fixed capacity container") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Construct from vector") {
|
TEST_CASE("Construct from vector") {
|
||||||
std::vector<int> vec{1, 2, 3};
|
std::vector<int> const vec{1, 2, 3};
|
||||||
StaticVector<int, 5> fcc{vec};
|
StaticVector<int, 5> const fcc{vec};
|
||||||
REQUIRE(fcc == vec);
|
REQUIRE(fcc == vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Copy construct from vector") {
|
TEST_CASE("Copy construct from vector") {
|
||||||
std::vector<int> vec{1, 2, 3};
|
std::vector<int> const vec{1, 2, 3};
|
||||||
StaticVector<int, 5> fcc = vec;
|
StaticVector<int, 5> const fcc = vec;
|
||||||
REQUIRE(fcc == vec);
|
REQUIRE(fcc == vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Copy assignment from vector") {
|
TEST_CASE("Copy assignment from vector") {
|
||||||
std::vector<int> vec{1, 2, 3};
|
std::vector<int> const vec{1, 2, 3};
|
||||||
StaticVector<int, 5> fcc;
|
StaticVector<int, 5> fcc;
|
||||||
fcc = vec;
|
fcc = vec;
|
||||||
REQUIRE(fcc == vec);
|
REQUIRE(fcc == vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Construct from array") {
|
TEST_CASE("Construct from array") {
|
||||||
std::array<int, 3> arr{1, 2, 3};
|
std::array<int, 3> const arr{1, 2, 3};
|
||||||
StaticVector<int, 5> fcc{arr};
|
StaticVector<int, 5> const fcc{arr};
|
||||||
REQUIRE(fcc == arr);
|
REQUIRE(fcc == arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Copy assign from array") {
|
TEST_CASE("Copy assign from array") {
|
||||||
std::array<int, 3> arr{1, 2, 3};
|
std::array<int, 3> const arr{1, 2, 3};
|
||||||
StaticVector<int, 5> fcc;
|
StaticVector<int, 5> fcc;
|
||||||
fcc = arr;
|
fcc = arr;
|
||||||
REQUIRE(fcc == arr);
|
REQUIRE(fcc == arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Copy construct from array") {
|
TEST_CASE("Copy construct from array") {
|
||||||
std::array<int, 3> arr{1, 2, 3};
|
std::array<int, 3> const arr{1, 2, 3};
|
||||||
StaticVector<int, 5> fcc = arr;
|
StaticVector<int, 5> const fcc = arr;
|
||||||
REQUIRE(fcc == arr);
|
REQUIRE(fcc == arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Construct from a smaller StaticVector") {
|
TEST_CASE("Construct from a smaller StaticVector") {
|
||||||
StaticVector<int, 3> sv{1, 2, 3};
|
StaticVector<int, 3> const sv{1, 2, 3};
|
||||||
StaticVector<int, 5> sv2{sv};
|
StaticVector<int, 5> const sv2{sv};
|
||||||
REQUIRE(sv == sv2);
|
REQUIRE(sv == sv2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ SCENARIO("StaticVectors can be sized and resized", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GIVEN("An std::vector of size 3") {
|
GIVEN("An std::vector of size 3") {
|
||||||
std::vector<int> standard_vector{5, 2, 1};
|
std::vector<int> const standard_vector{5, 2, 1};
|
||||||
WHEN("we construct a fixed capacity container from it") {
|
WHEN("we construct a fixed capacity container from it") {
|
||||||
StaticVector<int, 5> vec(standard_vector);
|
StaticVector<int, 5> vec(standard_vector);
|
||||||
THEN("size and data matches") {
|
THEN("size and data matches") {
|
||||||
@@ -202,7 +202,7 @@ SCENARIO("StaticVectors can be sized and resized", "[support]") {
|
|||||||
SCENARIO("Comparison of StaticVectors", "[support]") {
|
SCENARIO("Comparison of StaticVectors", "[support]") {
|
||||||
GIVEN("Two containers containers that are equal at the start") {
|
GIVEN("Two containers containers that are equal at the start") {
|
||||||
StaticVector<int, 5> a{0, 1, 2};
|
StaticVector<int, 5> a{0, 1, 2};
|
||||||
StaticVector<int, 5> b{0, 1, 2};
|
StaticVector<int, 5> const b{0, 1, 2};
|
||||||
REQUIRE(a == b);
|
REQUIRE(a == b);
|
||||||
REQUIRE_FALSE(a != b);
|
REQUIRE_FALSE(a != b);
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ SCENARIO("Comparison of StaticVectors", "[support]") {
|
|||||||
THEN("they are not equal anymore") { REQUIRE(a != b); }
|
THEN("they are not equal anymore") { REQUIRE(a != b); }
|
||||||
}
|
}
|
||||||
WHEN("Compared to a StaticVector with different capacity") {
|
WHEN("Compared to a StaticVector with different capacity") {
|
||||||
StaticVector<int, 8> c{0, 1, 2};
|
StaticVector<int, 8> const c{0, 1, 2};
|
||||||
THEN("The comparison still holds") {
|
THEN("The comparison still holds") {
|
||||||
REQUIRE(a == c);
|
REQUIRE(a == c);
|
||||||
REQUIRE_FALSE(a != c);
|
REQUIRE_FALSE(a != c);
|
||||||
@@ -316,7 +316,7 @@ SCENARIO("Converting to vector", "[support]") {
|
|||||||
GIVEN("a StaticVector") {
|
GIVEN("a StaticVector") {
|
||||||
StaticVector<int, 5> a{1, 2, 3};
|
StaticVector<int, 5> a{1, 2, 3};
|
||||||
WHEN("Converted into a vector") {
|
WHEN("Converted into a vector") {
|
||||||
std::vector<int> b(a);
|
std::vector<int> const b(a);
|
||||||
THEN("Data and size matches") {
|
THEN("Data and size matches") {
|
||||||
REQUIRE(a == b);
|
REQUIRE(a == b);
|
||||||
REQUIRE(a.size() == b.size());
|
REQUIRE(a.size() == b.size());
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ TEST_CASE("conversion from duration to string", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Convert vector of time", "[support]") {
|
TEST_CASE("Convert vector of time", "[support]") {
|
||||||
std::vector<ns> vec{ns(150), us(10), ns(600)};
|
std::vector<ns> const vec{ns(150), us(10), ns(600)};
|
||||||
REQUIRE(ToString(vec) == "[150ns, 10us, 600ns]");
|
REQUIRE(ToString(vec) == "[150ns, 10us, 600ns]");
|
||||||
REQUIRE(ToString(vec, "ns") == "[150ns, 10000ns, 600ns]");
|
REQUIRE(ToString(vec, "ns") == "[150ns, 10000ns, 600ns]");
|
||||||
}
|
}
|
||||||
@@ -93,26 +93,26 @@ TEST_CASE("Vector of double", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Array") {
|
TEST_CASE("Array") {
|
||||||
std::array<int, 3> arr{1, 2, 3};
|
std::array<int, 3> const arr{1, 2, 3};
|
||||||
REQUIRE(ToString(arr) == "[1, 2, 3]");
|
REQUIRE(ToString(arr) == "[1, 2, 3]");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Convert types with str method") {
|
TEST_CASE("Convert types with str method") {
|
||||||
IpAddr addr;
|
IpAddr const addr;
|
||||||
REQUIRE(ToString(addr) == "0.0.0.0");
|
REQUIRE(ToString(addr) == "0.0.0.0");
|
||||||
REQUIRE(ToString(IpAddr{}) == "0.0.0.0");
|
REQUIRE(ToString(IpAddr{}) == "0.0.0.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("String to string", "[support]") {
|
TEST_CASE("String to string", "[support]") {
|
||||||
std::string s = "hej";
|
std::string const s = "hej";
|
||||||
REQUIRE(ToString(s) == "hej");
|
REQUIRE(ToString(s) == "hej");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("vector of strings") {
|
TEST_CASE("vector of strings") {
|
||||||
std::vector<std::string> vec{"5", "s"};
|
std::vector<std::string> const vec{"5", "s"};
|
||||||
REQUIRE(ToString(vec) == "[5, s]");
|
REQUIRE(ToString(vec) == "[5, s]");
|
||||||
|
|
||||||
std::vector<std::string> vec2{"some", "strange", "words", "75"};
|
std::vector<std::string> const vec2{"some", "strange", "words", "75"};
|
||||||
REQUIRE(ToString(vec2) == "[some, strange, words, 75]");
|
REQUIRE(ToString(vec2) == "[some, strange, words, 75]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ TEST_CASE("string to detectorType") {
|
|||||||
|
|
||||||
TEST_CASE("vec") {
|
TEST_CASE("vec") {
|
||||||
using rs = slsDetectorDefs::runStatus;
|
using rs = slsDetectorDefs::runStatus;
|
||||||
std::vector<rs> vec{rs::ERROR, rs::IDLE};
|
std::vector<rs> const vec{rs::ERROR, rs::IDLE};
|
||||||
REQUIRE(ToString(vec) == "[error, idle]");
|
REQUIRE(ToString(vec) == "[error, idle]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,25 +232,25 @@ TEST_CASE("Detector type") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Formatting slsDetectorDefs::ROI") {
|
TEST_CASE("Formatting slsDetectorDefs::ROI") {
|
||||||
slsDetectorDefs::ROI roi(5, 159);
|
slsDetectorDefs::ROI const roi(5, 159);
|
||||||
REQUIRE(ToString(roi) == "[5, 159]");
|
REQUIRE(ToString(roi) == "[5, 159]");
|
||||||
slsDetectorDefs::ROI roi1(5, 159, 6, 170);
|
slsDetectorDefs::ROI const roi1(5, 159, 6, 170);
|
||||||
REQUIRE(ToString(roi1) == "[5, 159, 6, 170]");
|
REQUIRE(ToString(roi1) == "[5, 159, 6, 170]");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Streaming of slsDetectorDefs::ROI") {
|
TEST_CASE("Streaming of slsDetectorDefs::ROI") {
|
||||||
using namespace sls;
|
using namespace sls;
|
||||||
slsDetectorDefs::ROI roi(-10, 1);
|
slsDetectorDefs::ROI const roi(-10, 1);
|
||||||
std::ostringstream oss, oss1;
|
std::ostringstream oss, oss1;
|
||||||
oss << roi;
|
oss << roi;
|
||||||
REQUIRE(oss.str() == "[-10, 1]");
|
REQUIRE(oss.str() == "[-10, 1]");
|
||||||
slsDetectorDefs::ROI roi1(-10, 1, 5, 11);
|
slsDetectorDefs::ROI const roi1(-10, 1, 5, 11);
|
||||||
oss1 << roi1;
|
oss1 << roi1;
|
||||||
REQUIRE(oss1.str() == "[-10, 1, 5, 11]");
|
REQUIRE(oss1.str() == "[-10, 1, 5, 11]");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("std::array") {
|
TEST_CASE("std::array") {
|
||||||
std::array<int, 3> arr{4, 6, 7};
|
std::array<int, 3> const arr{4, 6, 7};
|
||||||
REQUIRE(ToString(arr) == "[4, 6, 7]");
|
REQUIRE(ToString(arr) == "[4, 6, 7]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,14 +267,14 @@ TEST_CASE("dac index to string") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("convert vector of strings to dac index") {
|
TEST_CASE("convert vector of strings to dac index") {
|
||||||
std::vector<std::string> dacs{"vcassh", "vth2", "vrshaper"};
|
std::vector<std::string> const dacs{"vcassh", "vth2", "vrshaper"};
|
||||||
std::vector<defs::dacIndex> daci{defs::VCASSH, defs::VTH2, defs::VRSHAPER};
|
std::vector<defs::dacIndex> const daci{defs::VCASSH, defs::VTH2, defs::VRSHAPER};
|
||||||
auto r = StringTo<defs::dacIndex>(dacs);
|
auto r = StringTo<defs::dacIndex>(dacs);
|
||||||
REQUIRE(r == daci);
|
REQUIRE(r == daci);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("vector of dac index to string") {
|
TEST_CASE("vector of dac index to string") {
|
||||||
std::vector<defs::dacIndex> daci{defs::VCASSH, defs::VTH2, defs::VRSHAPER};
|
std::vector<defs::dacIndex> const daci{defs::VCASSH, defs::VTH2, defs::VRSHAPER};
|
||||||
auto r = ToString(daci);
|
auto r = ToString(daci);
|
||||||
REQUIRE(r == "[vcassh, vth2, vrshaper]");
|
REQUIRE(r == "[vcassh, vth2, vrshaper]");
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ TEST_CASE("int or uin64_t to a string in hex") {
|
|||||||
REQUIRE(ToStringHex(65535, 8) == "0x0000ffff");
|
REQUIRE(ToStringHex(65535, 8) == "0x0000ffff");
|
||||||
REQUIRE(ToStringHex(8927748192) == "0x21422a060");
|
REQUIRE(ToStringHex(8927748192) == "0x21422a060");
|
||||||
REQUIRE(ToStringHex(8927748192, 16) == "0x000000021422a060");
|
REQUIRE(ToStringHex(8927748192, 16) == "0x000000021422a060");
|
||||||
std::vector<int> temp{244, 65535, 1638582};
|
std::vector<int> const temp{244, 65535, 1638582};
|
||||||
auto r = ToStringHex(temp);
|
auto r = ToStringHex(temp);
|
||||||
REQUIRE(r == "[0xf4, 0xffff, 0x1900b6]");
|
REQUIRE(r == "[0xf4, 0xffff, 0x1900b6]");
|
||||||
r = ToStringHex(temp, 8);
|
r = ToStringHex(temp, 8);
|
||||||
@@ -294,20 +294,20 @@ TEST_CASE("int or uin64_t to a string in hex") {
|
|||||||
TEST_CASE("Streaming of slsDetectorDefs::scanParameters") {
|
TEST_CASE("Streaming of slsDetectorDefs::scanParameters") {
|
||||||
using namespace sls;
|
using namespace sls;
|
||||||
{
|
{
|
||||||
defs::scanParameters t{};
|
defs::scanParameters const t{};
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << t;
|
oss << t;
|
||||||
REQUIRE(oss.str() == "[disabled]");
|
REQUIRE(oss.str() == "[disabled]");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
defs::scanParameters t{defs::VTH2, 500, 1500, 500};
|
defs::scanParameters const t{defs::VTH2, 500, 1500, 500};
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << t;
|
oss << t;
|
||||||
REQUIRE(oss.str() == "[enabled\ndac vth2\nstart 500\nstop 1500\nstep "
|
REQUIRE(oss.str() == "[enabled\ndac vth2\nstart 500\nstop 1500\nstep "
|
||||||
"500\nsettleTime 1ms\n]");
|
"500\nsettleTime 1ms\n]");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
defs::scanParameters t{defs::VTH2, 500, 1500, 500,
|
defs::scanParameters const t{defs::VTH2, 500, 1500, 500,
|
||||||
std::chrono::milliseconds{500}};
|
std::chrono::milliseconds{500}};
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << t;
|
oss << t;
|
||||||
@@ -317,17 +317,17 @@ TEST_CASE("Streaming of slsDetectorDefs::scanParameters") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Printing c style arrays of int") {
|
TEST_CASE("Printing c style arrays of int") {
|
||||||
int arr[]{3, 5};
|
int const arr[]{3, 5};
|
||||||
REQUIRE(ToString(arr) == "[3, 5]");
|
REQUIRE(ToString(arr) == "[3, 5]");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Printing c style arrays of uint8") {
|
TEST_CASE("Printing c style arrays of uint8") {
|
||||||
uint8_t arr[]{1, 2, 3, 4, 5};
|
uint8_t const arr[]{1, 2, 3, 4, 5};
|
||||||
REQUIRE(ToString(arr) == "[1, 2, 3, 4, 5]");
|
REQUIRE(ToString(arr) == "[1, 2, 3, 4, 5]");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Printing c style arrays of double") {
|
TEST_CASE("Printing c style arrays of double") {
|
||||||
double arr[]{3.4, 5.3, 6.2};
|
double const arr[]{3.4, 5.3, 6.2};
|
||||||
REQUIRE(ToString(arr) == "[3.4, 5.3, 6.2]");
|
REQUIRE(ToString(arr) == "[3.4, 5.3, 6.2]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ int open_socket(int port) {
|
|||||||
if (getaddrinfo(host, portname.c_str(), &hints, &res)) {
|
if (getaddrinfo(host, portname.c_str(), &hints, &res)) {
|
||||||
throw RuntimeError("Failed at getaddrinfo with " + std::string(host));
|
throw RuntimeError("Failed at getaddrinfo with " + std::string(host));
|
||||||
}
|
}
|
||||||
int fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
int const fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
throw RuntimeError("Failed to create UDP RX socket");
|
throw RuntimeError("Failed to create UDP RX socket");
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ int open_socket(int port) {
|
|||||||
TEST_CASE("Get packet size returns the packet size we set in the constructor") {
|
TEST_CASE("Get packet size returns the packet size we set in the constructor") {
|
||||||
constexpr int port = 50001;
|
constexpr int port = 50001;
|
||||||
constexpr ssize_t packet_size = 8000;
|
constexpr ssize_t packet_size = 8000;
|
||||||
UdpRxSocket s{port, packet_size};
|
UdpRxSocket const s{port, packet_size};
|
||||||
CHECK(s.getPacketSize() == packet_size);
|
CHECK(s.getPacketSize() == packet_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,12 +58,12 @@ TEST_CASE("Receive data from a vector") {
|
|||||||
constexpr int port = 50001;
|
constexpr int port = 50001;
|
||||||
std::vector<int> data_to_send{4, 5, 3, 2, 5, 7, 2, 3};
|
std::vector<int> data_to_send{4, 5, 3, 2, 5, 7, 2, 3};
|
||||||
std::vector<int> data_received(data_to_send.size());
|
std::vector<int> data_received(data_to_send.size());
|
||||||
ssize_t packet_size =
|
ssize_t const packet_size =
|
||||||
sizeof(decltype(data_to_send)::value_type) * data_to_send.size();
|
sizeof(decltype(data_to_send)::value_type) * data_to_send.size();
|
||||||
|
|
||||||
UdpRxSocket udpsock{port, packet_size};
|
UdpRxSocket udpsock{port, packet_size};
|
||||||
|
|
||||||
int fd = open_socket(port);
|
int const fd = open_socket(port);
|
||||||
auto n = write(fd, data_to_send.data(), packet_size);
|
auto n = write(fd, data_to_send.data(), packet_size);
|
||||||
CHECK(n == packet_size);
|
CHECK(n == packet_size);
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ TEST_CASE("check if version is semantic", "[.version]") {
|
|||||||
GENERATE(std::make_tuple("developer 0x250512", false),
|
GENERATE(std::make_tuple("developer 0x250512", false),
|
||||||
std::make_tuple("0.0.0 0x250512", false));
|
std::make_tuple("0.0.0 0x250512", false));
|
||||||
|
|
||||||
Version version(version_string);
|
Version const version(version_string);
|
||||||
|
|
||||||
CHECK(version.hasSemanticVersioning() == has_semantic_version);
|
CHECK(version.hasSemanticVersioning() == has_semantic_version);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ TEST_CASE("Get set bits from 3") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("All bits set") {
|
TEST_CASE("All bits set") {
|
||||||
uint8_t val = -1;
|
uint8_t const val = -1;
|
||||||
auto vec = getSetBits(val);
|
auto vec = getSetBits(val);
|
||||||
REQUIRE(vec == std::vector<int>{0, 1, 2, 3, 4, 5, 6, 7});
|
REQUIRE(vec == std::vector<int>{0, 1, 2, 3, 4, 5, 6, 7});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
TEST_CASE("Equality of an empty vector", "[support]") {
|
TEST_CASE("Equality of an empty vector", "[support]") {
|
||||||
std::vector<int> v;
|
std::vector<int> const v;
|
||||||
REQUIRE(v.empty());
|
REQUIRE(v.empty());
|
||||||
REQUIRE_FALSE(allEqual(v));
|
REQUIRE_FALSE(allEqual(v));
|
||||||
REQUIRE_FALSE(allEqualWithTol(v, 2));
|
REQUIRE_FALSE(allEqualWithTol(v, 2));
|
||||||
@@ -19,7 +19,7 @@ TEST_CASE("Equality of an empty vector", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Equality of a vector with one element", "[support]") {
|
TEST_CASE("Equality of a vector with one element", "[support]") {
|
||||||
std::vector<int> v{5};
|
std::vector<int> const v{5};
|
||||||
REQUIRE(v.size() == 1);
|
REQUIRE(v.size() == 1);
|
||||||
REQUIRE(allEqual(v));
|
REQUIRE(allEqual(v));
|
||||||
REQUIRE(allEqualWithTol(v, 1));
|
REQUIRE(allEqualWithTol(v, 1));
|
||||||
@@ -55,7 +55,7 @@ TEST_CASE("A larger vector of the same elements", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("A vector of double with different values", "[support]") {
|
TEST_CASE("A vector of double with different values", "[support]") {
|
||||||
std::vector<double> v{1.2, 2., 4.2, 4, 1.1};
|
std::vector<double> const v{1.2, 2., 4.2, 4, 1.1};
|
||||||
|
|
||||||
REQUIRE(allEqual(v) == false);
|
REQUIRE(allEqual(v) == false);
|
||||||
REQUIRE(allEqualWithTol(v, 0.3) == false);
|
REQUIRE(allEqualWithTol(v, 0.3) == false);
|
||||||
@@ -63,19 +63,19 @@ TEST_CASE("A vector of double with different values", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Sum of empty vector", "[support]") {
|
TEST_CASE("Sum of empty vector", "[support]") {
|
||||||
std::vector<float> v;
|
std::vector<float> const v;
|
||||||
REQUIRE(sum(v) == Approx(0));
|
REQUIRE(sum(v) == Approx(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Sum of vector", "[support]") {
|
TEST_CASE("Sum of vector", "[support]") {
|
||||||
std::vector<double> v{1.2, 2., 4.2, 4, 1.13};
|
std::vector<double> const v{1.2, 2., 4.2, 4, 1.13};
|
||||||
REQUIRE(sum(v) == Approx(12.53));
|
REQUIRE(sum(v) == Approx(12.53));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Minus one if different", "[support]") {
|
TEST_CASE("Minus one if different", "[support]") {
|
||||||
std::vector<double> v;
|
std::vector<double> v;
|
||||||
REQUIRE(v.empty());
|
REQUIRE(v.empty());
|
||||||
double d = -1;
|
double const d = -1;
|
||||||
REQUIRE(minusOneIfDifferent(v) == d);
|
REQUIRE(minusOneIfDifferent(v) == d);
|
||||||
|
|
||||||
SECTION("single element") {
|
SECTION("single element") {
|
||||||
@@ -102,11 +102,11 @@ TEST_CASE("minus one does not have side effects", "[support]") {
|
|||||||
TEST_CASE("Compare a vector containing two vectors", "[support]") {
|
TEST_CASE("Compare a vector containing two vectors", "[support]") {
|
||||||
|
|
||||||
std::vector<std::vector<int>> a{{0, 1, 2, 3, 4, 5}, {0, 1, 2, 3, 4, 5}};
|
std::vector<std::vector<int>> a{{0, 1, 2, 3, 4, 5}, {0, 1, 2, 3, 4, 5}};
|
||||||
std::vector<std::vector<int>> b{{0, 1, 2, 3, 4, 5}, {0, 1, 2, 3, 3, 5}};
|
std::vector<std::vector<int>> const b{{0, 1, 2, 3, 4, 5}, {0, 1, 2, 3, 3, 5}};
|
||||||
std::vector<std::vector<int>> c{{0, 1, 2, 3, 4}, {0, 1, 2, 3, 3, 5}};
|
std::vector<std::vector<int>> const c{{0, 1, 2, 3, 4}, {0, 1, 2, 3, 3, 5}};
|
||||||
std::vector<std::vector<int>> d{
|
std::vector<std::vector<int>> d{
|
||||||
{0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}};
|
{0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}};
|
||||||
std::vector<int> e{0, 1, 2, 3, 4, 5};
|
std::vector<int> const e{0, 1, 2, 3, 4, 5};
|
||||||
|
|
||||||
CHECK(minusOneIfDifferent(a) == a[0]);
|
CHECK(minusOneIfDifferent(a) == a[0]);
|
||||||
CHECK(minusOneIfDifferent(a) == e);
|
CHECK(minusOneIfDifferent(a) == e);
|
||||||
@@ -116,9 +116,9 @@ TEST_CASE("Compare a vector containing two vectors", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("vector of bool", "[support]") {
|
TEST_CASE("vector of bool", "[support]") {
|
||||||
std::vector<bool> a{true, true, true};
|
std::vector<bool> const a{true, true, true};
|
||||||
std::vector<bool> b{false, false, false};
|
std::vector<bool> const b{false, false, false};
|
||||||
std::vector<bool> c{true, false, true};
|
std::vector<bool> const c{true, false, true};
|
||||||
|
|
||||||
CHECK(minusOneIfDifferent(a) == 1);
|
CHECK(minusOneIfDifferent(a) == 1);
|
||||||
CHECK(minusOneIfDifferent(b) == 0);
|
CHECK(minusOneIfDifferent(b) == 0);
|
||||||
@@ -127,17 +127,17 @@ TEST_CASE("vector of bool", "[support]") {
|
|||||||
|
|
||||||
TEST_CASE("compare a vector of arrays", "[support]") {
|
TEST_CASE("compare a vector of arrays", "[support]") {
|
||||||
|
|
||||||
std::vector<std::array<uint64_t, 3>> vec0{{5, 6, 8}, {5, 6, 8}, {5, 6, 8}};
|
std::vector<std::array<uint64_t, 3>> const vec0{{5, 6, 8}, {5, 6, 8}, {5, 6, 8}};
|
||||||
CHECK(minusOneIfDifferent(vec0) == std::array<uint64_t, 3>{5, 6, 8});
|
CHECK(minusOneIfDifferent(vec0) == std::array<uint64_t, 3>{5, 6, 8});
|
||||||
|
|
||||||
std::array<uint64_t, 3> arr;
|
std::array<uint64_t, 3> arr;
|
||||||
arr.fill(-1);
|
arr.fill(-1);
|
||||||
std::vector<std::array<uint64_t, 3>> vec1{{5, 90, 8}, {5, 6, 8}, {5, 6, 8}};
|
std::vector<std::array<uint64_t, 3>> const vec1{{5, 90, 8}, {5, 6, 8}, {5, 6, 8}};
|
||||||
CHECK(minusOneIfDifferent(vec1) == arr);
|
CHECK(minusOneIfDifferent(vec1) == arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("check if vector has duplicates") {
|
TEST_CASE("check if vector has duplicates") {
|
||||||
std::vector<int> vec{1, 0, 2, 5, 3, 1, 8, 6};
|
std::vector<int> const vec{1, 0, 2, 5, 3, 1, 8, 6};
|
||||||
REQUIRE(hasDuplicates(vec) == true);
|
REQUIRE(hasDuplicates(vec) == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,13 +153,35 @@ TEST_CASE("check for duplicates in vector of pairs") {
|
|||||||
REQUIRE(hasDuplicates(vec) == true);
|
REQUIRE(hasDuplicates(vec) == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("remove duplicates from vector") {
|
TEST_CASE("sorts the vector and remove duplicates") {
|
||||||
std::vector<int> v{5, 6, 5, 3};
|
std::vector<int> v{5, 6, 5, 3};
|
||||||
auto r = removeDuplicates(v);
|
auto r = removeDuplicates(v);
|
||||||
CHECK(r == true); // did indeed remove elements
|
CHECK(r == true); // did indeed remove elements
|
||||||
CHECK(v == std::vector<int>{3, 5, 6});
|
CHECK(v == std::vector<int>{3, 5, 6});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("remove duplicates but keep order") {
|
||||||
|
std::vector<int> v{5, 6, 5, 3};
|
||||||
|
auto r = stableRemoveDuplicates(v);
|
||||||
|
CHECK(r == true); // did indeed remove elements
|
||||||
|
CHECK(v == std::vector<int>{5, 6, 3});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("remove duplicates but keep order, all elements the same ") {
|
||||||
|
std::vector<char> v{'c', 'c', 'c', 'c', 'c', 'c'};
|
||||||
|
auto r = stableRemoveDuplicates(v);
|
||||||
|
CHECK(r == true); // did indeed remove elements
|
||||||
|
CHECK(v == std::vector<char>{'c'});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("remove duplicates but keep order, pattern ") {
|
||||||
|
std::vector<int> v{8,1,2,8,8,3,2};
|
||||||
|
auto r = stableRemoveDuplicates(v);
|
||||||
|
CHECK(r == true); // did indeed remove elements
|
||||||
|
CHECK(v == std::vector<int>{8,1,2,3});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("remove duplicated empty vector") {
|
TEST_CASE("remove duplicated empty vector") {
|
||||||
std::vector<int> v;
|
std::vector<int> v;
|
||||||
auto r = removeDuplicates(v);
|
auto r = removeDuplicates(v);
|
||||||
@@ -167,4 +189,11 @@ TEST_CASE("remove duplicated empty vector") {
|
|||||||
CHECK(v == std::vector<int>{});
|
CHECK(v == std::vector<int>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("remove duplicated empty vector using stable version") {
|
||||||
|
std::vector<int> v;
|
||||||
|
auto r = stableRemoveDuplicates(v);
|
||||||
|
CHECK(r == false); // no elements to remove
|
||||||
|
CHECK(v == std::vector<int>{});
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ TEST_CASE("Get size of file with data") {
|
|||||||
constexpr size_t n_bytes = 137;
|
constexpr size_t n_bytes = 137;
|
||||||
std::vector<char> data(n_bytes);
|
std::vector<char> data(n_bytes);
|
||||||
char fname[] = "temfile_XXXXXX";
|
char fname[] = "temfile_XXXXXX";
|
||||||
int fh = mkstemp(fname);
|
int const fh = mkstemp(fname);
|
||||||
write(fh, data.data(), n_bytes);
|
write(fh, data.data(), n_bytes);
|
||||||
|
|
||||||
std::ifstream ifs(fname);
|
std::ifstream ifs(fname);
|
||||||
@@ -32,11 +32,11 @@ TEST_CASE("Get size of file with data") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Channel file reading") {
|
TEST_CASE("Channel file reading") {
|
||||||
std::string fname =
|
std::string const fname =
|
||||||
getAbsolutePathFromCurrentProcess(TEST_FILE_NAME_BAD_CHANNELS);
|
getAbsolutePathFromCurrentProcess(TEST_FILE_NAME_BAD_CHANNELS);
|
||||||
std::vector<int> list;
|
std::vector<int> list;
|
||||||
REQUIRE_NOTHROW(list = getChannelsFromFile(fname));
|
REQUIRE_NOTHROW(list = getChannelsFromFile(fname));
|
||||||
std::vector<int> expected = {0, 12, 15, 40, 41, 42, 43, 44, 1279};
|
std::vector<int> const expected = {0, 12, 15, 40, 41, 42, 43, 44, 1279};
|
||||||
REQUIRE(list == expected);
|
REQUIRE(list == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ TEST_CASE("Test output") {
|
|||||||
Logger::ReportingLevel() = logERROR;
|
Logger::ReportingLevel() = logERROR;
|
||||||
|
|
||||||
// Redirect std::clog to local buffer
|
// Redirect std::clog to local buffer
|
||||||
std::ostringstream local;
|
std::ostringstream const local;
|
||||||
auto clog_buff = std::clog.rdbuf();
|
auto clog_buff = std::clog.rdbuf();
|
||||||
std::clog.rdbuf(local.rdbuf());
|
std::clog.rdbuf(local.rdbuf());
|
||||||
|
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ TEST_CASE("Convert mac address using classes", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Hex representation of MAC", "[support]") {
|
TEST_CASE("Hex representation of MAC", "[support]") {
|
||||||
MacAddr m{346856806822};
|
MacAddr const m{346856806822};
|
||||||
CHECK(m.hex() == "0050c246d9a6");
|
CHECK(m.hex() == "0050c246d9a6");
|
||||||
CHECK(m.str() == "00:50:c2:46:d9:a6");
|
CHECK(m.str() == "00:50:c2:46:d9:a6");
|
||||||
CHECK_FALSE(m == 7);
|
CHECK_FALSE(m == 7);
|
||||||
|
|
||||||
MacAddr m2{"00:50:c2:46:d9:c4"};
|
MacAddr const m2{"00:50:c2:46:d9:c4"};
|
||||||
CHECK(m2 == 346856806852);
|
CHECK(m2 == 346856806852);
|
||||||
CHECK(m2.hex() == "0050c246d9c4");
|
CHECK(m2.hex() == "0050c246d9c4");
|
||||||
CHECK(m2.str() == "00:50:c2:46:d9:c4");
|
CHECK(m2.str() == "00:50:c2:46:d9:c4");
|
||||||
@@ -79,12 +79,12 @@ TEST_CASE("Strange input gives 0", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Convert to uint for sending over network", "[support]") {
|
TEST_CASE("Convert to uint for sending over network", "[support]") {
|
||||||
MacAddr addr{346856806822};
|
MacAddr const addr{346856806822};
|
||||||
uint64_t a = addr.uint64();
|
uint64_t const a = addr.uint64();
|
||||||
CHECK(a == 346856806822);
|
CHECK(a == 346856806822);
|
||||||
|
|
||||||
IpAddr addr2{"129.129.205.242"};
|
IpAddr const addr2{"129.129.205.242"};
|
||||||
uint32_t b = addr2.uint32();
|
uint32_t const b = addr2.uint32();
|
||||||
CHECK(b == 4073554305);
|
CHECK(b == 4073554305);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ TEST_CASE("Hostname lookup failed throws", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("IP Output operator gives same result as string", "[support]") {
|
TEST_CASE("IP Output operator gives same result as string", "[support]") {
|
||||||
IpAddr addr{"129.129.205.242"};
|
IpAddr const addr{"129.129.205.242"};
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << addr;
|
os << addr;
|
||||||
CHECK(os.str() == "129.129.205.242");
|
CHECK(os.str() == "129.129.205.242");
|
||||||
@@ -101,7 +101,7 @@ TEST_CASE("IP Output operator gives same result as string", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("MAC Output operator gives same result as string", "[support]") {
|
TEST_CASE("MAC Output operator gives same result as string", "[support]") {
|
||||||
MacAddr addr{"00:50:c2:46:d9:a6"};
|
MacAddr const addr{"00:50:c2:46:d9:a6"};
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << addr;
|
os << addr;
|
||||||
CHECK(os.str() == "00:50:c2:46:d9:a6");
|
CHECK(os.str() == "00:50:c2:46:d9:a6");
|
||||||
@@ -109,15 +109,15 @@ TEST_CASE("MAC Output operator gives same result as string", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Copy construct a MacAddr") {
|
TEST_CASE("Copy construct a MacAddr") {
|
||||||
MacAddr addr{"00:50:c2:46:d9:a6"};
|
MacAddr const addr{"00:50:c2:46:d9:a6"};
|
||||||
MacAddr addr2(addr);
|
MacAddr const addr2(addr);
|
||||||
CHECK(addr == addr2);
|
CHECK(addr == addr2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("udp dst struct basic properties") {
|
TEST_CASE("udp dst struct basic properties") {
|
||||||
static_assert(sizeof(UdpDestination) == 32,
|
static_assert(sizeof(UdpDestination) == 32,
|
||||||
"udpDestination struct size does not match");
|
"udpDestination struct size does not match");
|
||||||
UdpDestination dst{};
|
UdpDestination const dst{};
|
||||||
REQUIRE(dst.entry == 0);
|
REQUIRE(dst.entry == 0);
|
||||||
REQUIRE(dst.port == 0);
|
REQUIRE(dst.port == 0);
|
||||||
REQUIRE(dst.port2 == 0);
|
REQUIRE(dst.port2 == 0);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace sls {
|
|||||||
using dt = slsDetectorDefs::detectorType;
|
using dt = slsDetectorDefs::detectorType;
|
||||||
|
|
||||||
TEST_CASE("sls_detector_module default construction", "[support][new]") {
|
TEST_CASE("sls_detector_module default construction", "[support][new]") {
|
||||||
sls_detector_module m;
|
sls_detector_module const m;
|
||||||
CHECK(m.serialnumber == 0);
|
CHECK(m.serialnumber == 0);
|
||||||
CHECK(m.nchan == 0);
|
CHECK(m.nchan == 0);
|
||||||
CHECK(m.nchip == 0);
|
CHECK(m.nchip == 0);
|
||||||
@@ -24,7 +24,7 @@ TEST_CASE("sls_detector_module default construction", "[support][new]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("sls_detector_module from type", "[support]") {
|
TEST_CASE("sls_detector_module from type", "[support]") {
|
||||||
sls_detector_module m(dt::EIGER);
|
sls_detector_module const m(dt::EIGER);
|
||||||
CHECK(m.serialnumber == 0);
|
CHECK(m.serialnumber == 0);
|
||||||
CHECK(m.nchan == 256 * 256 * 4);
|
CHECK(m.nchan == 256 * 256 * 4);
|
||||||
CHECK(m.nchip == 4);
|
CHECK(m.nchip == 4);
|
||||||
@@ -60,7 +60,7 @@ TEST_CASE("assign module", "[support]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("default construct scanParameters") {
|
TEST_CASE("default construct scanParameters") {
|
||||||
slsDetectorDefs::scanParameters p;
|
slsDetectorDefs::scanParameters const p;
|
||||||
CHECK(p.dacSettleTime_ns == 0);
|
CHECK(p.dacSettleTime_ns == 0);
|
||||||
CHECK(p.dacInd == slsDetectorDefs::DAC_0);
|
CHECK(p.dacInd == slsDetectorDefs::DAC_0);
|
||||||
CHECK(p.enable == 0);
|
CHECK(p.enable == 0);
|
||||||
@@ -71,7 +71,7 @@ TEST_CASE("default construct scanParameters") {
|
|||||||
|
|
||||||
TEST_CASE("compare two scanParameters") {
|
TEST_CASE("compare two scanParameters") {
|
||||||
slsDetectorDefs::scanParameters p0;
|
slsDetectorDefs::scanParameters p0;
|
||||||
slsDetectorDefs::scanParameters p1;
|
slsDetectorDefs::scanParameters const p1;
|
||||||
|
|
||||||
CHECK(p0 == p1);
|
CHECK(p0 == p1);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ TEST_CASE("copy a long string") {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST_CASE("split a string with end delimiter") {
|
TEST_CASE("split a string with end delimiter") {
|
||||||
std::string s("abra+kadabra+");
|
std::string const s("abra+kadabra+");
|
||||||
auto r = split(s, '+');
|
auto r = split(s, '+');
|
||||||
REQUIRE(r.size() == 2);
|
REQUIRE(r.size() == 2);
|
||||||
REQUIRE(r[0] == "abra");
|
REQUIRE(r[0] == "abra");
|
||||||
@@ -44,7 +44,7 @@ TEST_CASE("split a string with end delimiter") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("split a string without end delimiter") {
|
TEST_CASE("split a string without end delimiter") {
|
||||||
std::string s("abra+kadabra+filibom");
|
std::string const s("abra+kadabra+filibom");
|
||||||
auto r = split(s, '+');
|
auto r = split(s, '+');
|
||||||
REQUIRE(r.size() == 3);
|
REQUIRE(r.size() == 3);
|
||||||
REQUIRE(r[0] == "abra");
|
REQUIRE(r[0] == "abra");
|
||||||
@@ -109,7 +109,7 @@ TEST_CASE("replace --help") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("port host") {
|
TEST_CASE("port host") {
|
||||||
std::string hostport = "localhost:1954";
|
std::string const hostport = "localhost:1954";
|
||||||
auto res = ParseHostPort(hostport);
|
auto res = ParseHostPort(hostport);
|
||||||
REQUIRE(res.first == "localhost");
|
REQUIRE(res.first == "localhost");
|
||||||
REQUIRE(res.second == 1954);
|
REQUIRE(res.second == 1954);
|
||||||
@@ -117,7 +117,7 @@ TEST_CASE("port host") {
|
|||||||
|
|
||||||
TEST_CASE("port missing") {
|
TEST_CASE("port missing") {
|
||||||
// TODO! is this the intended result?
|
// TODO! is this the intended result?
|
||||||
std::string host = "localhost";
|
std::string const host = "localhost";
|
||||||
auto res = ParseHostPort(host);
|
auto res = ParseHostPort(host);
|
||||||
REQUIRE(res.first == "localhost");
|
REQUIRE(res.first == "localhost");
|
||||||
REQUIRE(res.second == 0);
|
REQUIRE(res.second == 0);
|
||||||
|
|||||||
@@ -62,5 +62,3 @@ configure_file(scripts/test_frame_synchronizer.py ${CMAKE_BINARY_DIR}/bin/test_f
|
|||||||
configure_file(scripts/utils_for_test.py ${CMAKE_BINARY_DIR}/bin/utils_for_test.py COPYONLY)
|
configure_file(scripts/utils_for_test.py ${CMAKE_BINARY_DIR}/bin/utils_for_test.py COPYONLY)
|
||||||
configure_file(scripts/test_roi.py ${CMAKE_BINARY_DIR}/bin/test_roi.py COPYONLY)
|
configure_file(scripts/test_roi.py ${CMAKE_BINARY_DIR}/bin/test_roi.py COPYONLY)
|
||||||
configure_file(scripts/test_free.py ${CMAKE_BINARY_DIR}/bin/test_free.py COPYONLY)
|
configure_file(scripts/test_free.py ${CMAKE_BINARY_DIR}/bin/test_free.py COPYONLY)
|
||||||
configure_file(scripts/test_commands.py ${CMAKE_BINARY_DIR}/bin/test_commands.py COPYONLY)
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
'''
|
|
||||||
This file is used to start up simulators and test for freeing shm and accessing it from python.
|
|
||||||
Run this using: pytest -s test_free.py
|
|
||||||
'''
|
|
||||||
|
|
||||||
from time import time
|
|
||||||
import pytest, sys, time
|
|
||||||
|
|
||||||
from slsdet import Detector, Ctb, freeSharedMemory
|
|
||||||
from slsdet.defines import DEFAULT_TCP_RX_PORTNO
|
|
||||||
from utils_for_test import (
|
|
||||||
Log,
|
|
||||||
LogLevel,
|
|
||||||
cleanup,
|
|
||||||
startDetectorVirtualServer,
|
|
||||||
startProcessInBackground,
|
|
||||||
loadConfig,
|
|
||||||
loadBasicSettings
|
|
||||||
)
|
|
||||||
|
|
||||||
def startReceiver(num_mods, fp):
|
|
||||||
if num_mods == 1:
|
|
||||||
cmd = ['slsReceiver']
|
|
||||||
else:
|
|
||||||
cmd = ['slsMultiReceiver', str(DEFAULT_TCP_RX_PORTNO), str(num_mods)]
|
|
||||||
# in 10.0.0
|
|
||||||
#cmd = ['slsMultiReceiver', '-p', str(DEFAULT_TCP_RX_PORTNO), '-n', str(num_mods)]
|
|
||||||
startProcessInBackground(cmd, fp)
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
'''
|
|
||||||
scope = module =>Once per test file/module
|
|
||||||
to share expensive setup like startDetectorVirtualServer
|
|
||||||
'''
|
|
||||||
@pytest.fixture(scope="module")
|
|
||||||
def det_config():
|
|
||||||
return {
|
|
||||||
"name": "ctb",
|
|
||||||
"num_mods": 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# autouse is false to pass explictly
|
|
||||||
@pytest.fixture(scope="module", autouse=False)
|
|
||||||
def setup_simulator(det_config):
|
|
||||||
"""Fixture to start the detector server once and clean up at the end."""
|
|
||||||
fp = sys.stdout
|
|
||||||
|
|
||||||
cleanup(fp)
|
|
||||||
# server
|
|
||||||
startDetectorVirtualServer(det_config["name"], det_config["num_mods"], fp)
|
|
||||||
# receiver
|
|
||||||
startReceiver(det_config["num_mods"], fp)
|
|
||||||
# config and basic settings
|
|
||||||
d = loadConfig(name=det_config["name"], rx_hostname="localhost", settingsdir="", fp=fp, num_mods=det_config["num_mods"])
|
|
||||||
loadBasicSettings(name=det_config["name"], d=d, fp=fp)
|
|
||||||
|
|
||||||
yield d # tests run here
|
|
||||||
|
|
||||||
cleanup(fp)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_parameters_file(setup_simulator):
|
|
||||||
d = setup_simulator
|
|
||||||
Log(LogLevel.INFOBLUE, f'\nRunning test_parameters_file')
|
|
||||||
|
|
||||||
assert isinstance(d, Detector)
|
|
||||||
|
|
||||||
with open("/tmp/params.det", "w") as f:
|
|
||||||
f.write("frames 2\n")
|
|
||||||
f.write("fwrite 1\n")
|
|
||||||
|
|
||||||
# this should not throw
|
|
||||||
d.parameters = "/tmp/params.det"
|
|
||||||
|
|
||||||
assert d.frames == 2
|
|
||||||
assert d.fwrite == 1
|
|
||||||
|
|
||||||
Log(LogLevel.INFOGREEN, f"✅ Test passed. Command: parameters")
|
|
||||||
|
|
||||||
|
|
||||||
def test_include_file(setup_simulator):
|
|
||||||
d = setup_simulator
|
|
||||||
Log(LogLevel.INFOBLUE, f'\test_include_file test_parameters_file')
|
|
||||||
|
|
||||||
assert isinstance(d, Detector)
|
|
||||||
|
|
||||||
with open("/tmp/params.det", "w") as f:
|
|
||||||
f.write("frames 3\n")
|
|
||||||
f.write("fwrite 0\n")
|
|
||||||
|
|
||||||
# this should not throw
|
|
||||||
d.include = "/tmp/params.det"
|
|
||||||
|
|
||||||
assert d.frames == 3
|
|
||||||
assert d.fwrite == 0
|
|
||||||
|
|
||||||
Log(LogLevel.INFOGREEN, f"✅ Test passed. Command: include")
|
|
||||||
@@ -113,7 +113,7 @@ def startTestsForAll(args, fp):
|
|||||||
startDetectorVirtualServer(server, args.num_mods, fp)
|
startDetectorVirtualServer(server, args.num_mods, fp)
|
||||||
startFrameSynchronizerPullSocket(server, fp)
|
startFrameSynchronizerPullSocket(server, fp)
|
||||||
startFrameSynchronizer(args.num_mods, fp)
|
startFrameSynchronizer(args.num_mods, fp)
|
||||||
d = loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, fp=fp, num_mods=args.num_mods, num_frames=args.num_frames)
|
d = loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, log_file_fp=fp, num_mods=args.num_mods, num_frames=args.num_frames)
|
||||||
loadBasicSettings(name=server, d=d, fp=fp)
|
loadBasicSettings(name=server, d=d, fp=fp)
|
||||||
acquire(fp, d)
|
acquire(fp, d)
|
||||||
testFramesCaught(server, d, args.num_frames)
|
testFramesCaught(server, d, args.num_frames)
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ from utils_for_test import (
|
|||||||
RuntimeException,
|
RuntimeException,
|
||||||
cleanup,
|
cleanup,
|
||||||
startProcessInBackground,
|
startProcessInBackground,
|
||||||
|
startReceiver,
|
||||||
startDetectorVirtualServer,
|
startDetectorVirtualServer,
|
||||||
connectToVirtualServers,
|
connectToVirtualServers,
|
||||||
loadBasicSettings,
|
loadBasicSettings,
|
||||||
|
loadConfig,
|
||||||
runProcessWithLogFile
|
runProcessWithLogFile
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,45 +30,6 @@ LOG_PREFIX_FNAME = '/tmp/slsDetectorPackage_virtual_roi_test'
|
|||||||
MAIN_LOG_FNAME = LOG_PREFIX_FNAME + '_log.txt'
|
MAIN_LOG_FNAME = LOG_PREFIX_FNAME + '_log.txt'
|
||||||
ROI_TEST_FNAME = LOG_PREFIX_FNAME + '_results_'
|
ROI_TEST_FNAME = LOG_PREFIX_FNAME + '_results_'
|
||||||
|
|
||||||
def startReceiver(num_mods, fp):
|
|
||||||
if num_mods == 1:
|
|
||||||
cmd = ['slsReceiver']
|
|
||||||
else:
|
|
||||||
cmd = ['slsMultiReceiver', str(DEFAULT_TCP_RX_PORTNO), str(num_mods)]
|
|
||||||
# in 10.0.0
|
|
||||||
#cmd = ['slsMultiReceiver', '-p', str(DEFAULT_TCP_RX_PORTNO), '-n', str(num_mods)]
|
|
||||||
startProcessInBackground(cmd, fp)
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
def loadConfigForRoi(name, fp, num_mods = 1, num_interfaces = 1):
|
|
||||||
Log(LogLevel.INFO, 'Loading config')
|
|
||||||
Log(LogLevel.INFO, 'Loading config', fp)
|
|
||||||
try:
|
|
||||||
d = connectToVirtualServers(name, num_mods)
|
|
||||||
|
|
||||||
if name == 'jungfrau' or name == 'moench':
|
|
||||||
d.numinterfaces = num_interfaces
|
|
||||||
|
|
||||||
d.udp_dstport = DEFAULT_UDP_DST_PORTNO
|
|
||||||
if name == 'eiger' or name == 'jungfrau' or name == 'moench':
|
|
||||||
d.udp_dstport2 = DEFAULT_UDP_DST_PORTNO + 1
|
|
||||||
|
|
||||||
d.rx_hostname = 'localhost'
|
|
||||||
d.udp_dstip = 'auto'
|
|
||||||
if name != "eiger":
|
|
||||||
d.udp_srcip = 'auto'
|
|
||||||
if name == 'jungfrau' or name == 'moench':
|
|
||||||
d.udp_dstip2 = 'auto'
|
|
||||||
d.powerchip = 1
|
|
||||||
|
|
||||||
d.frames = 5
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
raise RuntimeException(f'Could not load config for {name}. Error: {str(e)}') from e
|
|
||||||
|
|
||||||
return d
|
|
||||||
|
|
||||||
def startTestsForAll(fp):
|
def startTestsForAll(fp):
|
||||||
servers = [
|
servers = [
|
||||||
'eiger',
|
'eiger',
|
||||||
@@ -89,7 +52,7 @@ def startTestsForAll(fp):
|
|||||||
cleanup(fp)
|
cleanup(fp)
|
||||||
startDetectorVirtualServer(server, nmods, fp)
|
startDetectorVirtualServer(server, nmods, fp)
|
||||||
startReceiver(nmods, fp)
|
startReceiver(nmods, fp)
|
||||||
d = loadConfigForRoi(name=server, fp=fp, num_mods=nmods, num_interfaces=ninterfaces)
|
d = loadConfig(name=server, log_file_fp = fp, num_mods=nmods, num_frames=5, num_interfaces=ninterfaces)
|
||||||
loadBasicSettings(name=server, d=d, fp=fp)
|
loadBasicSettings(name=server, d=d, fp=fp)
|
||||||
|
|
||||||
fname = ROI_TEST_FNAME + server + '.txt'
|
fname = ROI_TEST_FNAME + server + '.txt'
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ def startCmdTestsForAll(args, fp):
|
|||||||
cleanup(fp)
|
cleanup(fp)
|
||||||
startDetectorVirtualServer(name=server, num_mods=num_mods, fp=fp)
|
startDetectorVirtualServer(name=server, num_mods=num_mods, fp=fp)
|
||||||
startReceiver(num_mods, fp)
|
startReceiver(num_mods, fp)
|
||||||
d = loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, fp=fp, num_mods=num_mods)
|
d = loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, log_file_fp=fp, num_mods=num_mods)
|
||||||
loadBasicSettings(name=server, d=d, fp=fp)
|
loadBasicSettings(name=server, d=d, fp=fp)
|
||||||
runProcessWithLogFile('Cmd Tests (' + args.markers + ') for ' + server, cmd, fp, fname)
|
runProcessWithLogFile('Cmd Tests (' + args.markers + ') for ' + server, cmd, fp, fname)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ SERVER_START_PORTNO=1900
|
|||||||
|
|
||||||
init(autoreset=True)
|
init(autoreset=True)
|
||||||
|
|
||||||
|
|
||||||
class LogLevel(Enum):
|
class LogLevel(Enum):
|
||||||
INFO = 0
|
INFO = 0
|
||||||
INFORED = 1
|
INFORED = 1
|
||||||
@@ -193,30 +192,49 @@ def connectToVirtualServers(name, num_mods, ctb_object=False):
|
|||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def startReceiver(num_mods, fp):
|
||||||
|
if num_mods == 1:
|
||||||
|
cmd = ['slsReceiver']
|
||||||
|
else:
|
||||||
|
cmd = ['slsMultiReceiver', str(DEFAULT_TCP_RX_PORTNO), str(num_mods)]
|
||||||
|
# in 10.0.0
|
||||||
|
#cmd = ['slsMultiReceiver', '-p', str(DEFAULT_TCP_RX_PORTNO), '-n', str(num_mods)]
|
||||||
|
startProcessInBackground(cmd, fp)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
def loadConfig(name, rx_hostname, settingsdir, fp, num_mods = 1, num_frames = 1):
|
|
||||||
|
def loadConfig(name, rx_hostname = 'localhost', settingsdir = None, log_file_fp = None, num_mods = 1, num_frames = 1, num_interfaces = 1):
|
||||||
Log(LogLevel.INFO, 'Loading config')
|
Log(LogLevel.INFO, 'Loading config')
|
||||||
Log(LogLevel.INFO, 'Loading config', fp)
|
Log(LogLevel.INFO, 'Loading config', log_file_fp)
|
||||||
try:
|
try:
|
||||||
d = connectToVirtualServers(name, num_mods)
|
d = connectToVirtualServers(name, num_mods)
|
||||||
|
|
||||||
|
if name == 'jungfrau' or name == 'moench':
|
||||||
|
d.numinterfaces = num_interfaces
|
||||||
|
|
||||||
d.udp_dstport = DEFAULT_UDP_DST_PORTNO
|
d.udp_dstport = DEFAULT_UDP_DST_PORTNO
|
||||||
if name == 'eiger':
|
if name == 'eiger' or name == 'jungfrau' or name == 'moench':
|
||||||
d.udp_dstport2 = DEFAULT_UDP_DST_PORTNO + 1
|
d.udp_dstport2 = DEFAULT_UDP_DST_PORTNO + 1
|
||||||
|
|
||||||
d.rx_hostname = rx_hostname
|
d.rx_hostname = rx_hostname
|
||||||
|
|
||||||
d.udp_dstip = 'auto'
|
d.udp_dstip = 'auto'
|
||||||
|
|
||||||
if name != "eiger":
|
if name != "eiger":
|
||||||
d.udp_srcip = 'auto'
|
d.udp_srcip = 'auto'
|
||||||
|
|
||||||
|
if name == "jungfrau" or name == "moench":
|
||||||
|
d.udp_dstip2 = 'auto'
|
||||||
|
|
||||||
if name == "jungfrau" or name == "moench" or name == "xilinx_ctb":
|
if name == "jungfrau" or name == "moench" or name == "xilinx_ctb":
|
||||||
d.powerchip = 1
|
d.powerchip = 1
|
||||||
|
|
||||||
if name == "xilinx_ctb":
|
if name == "xilinx_ctb":
|
||||||
d.configureTransceiver()
|
d.configureTransceiver()
|
||||||
|
|
||||||
if name == "eiger":
|
if settingsdir is not None and name in ['eiger', 'mythen3']:
|
||||||
d.trimen = [4500, 5400, 6400]
|
d.settingspath = settingsdir + '/' + name + '/'
|
||||||
d.settingspath = settingsdir + '/eiger/'
|
d.trimen = [4500, 5400, 6400] if name == 'eiger' else [4000, 6000, 8000, 12000]
|
||||||
d.setThresholdEnergy(4500, detectorSettings.STANDARD)
|
d.setThresholdEnergy(4500, detectorSettings.STANDARD)
|
||||||
|
|
||||||
d.frames = num_frames
|
d.frames = num_frames
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ int main(int argc, char **argv) {
|
|||||||
double b = 18.3;
|
double b = 18.3;
|
||||||
float c = -1.2;
|
float c = -1.2;
|
||||||
auto socket = sls::ClientSocket("test", hostname, port);
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
int s = socket.SendAll(sls::func_id::combined, a, b, c);
|
int const s = socket.SendAll(sls::func_id::combined, a, b, c);
|
||||||
std::cout << "send all: " << s << "\n";
|
std::cout << "send all: " << s << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,14 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
#!/bin/bash
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
#echo $#
|
# Since this script could be sourced, $0 is not sufficent, BASH_SOURCE[0] is necessary
|
||||||
#if [ $# = 0 ]; then
|
SCRIPT_LOCATION="$(realpath ${BASH_SOURCE[0]})"
|
||||||
# f=$0
|
SCRIPT_LOCATION="$(dirname ${SCRIPT_LOCATION})"
|
||||||
#else
|
BUILDBIN_LOCATION="${SCRIPT_LOCATION}/build/bin"
|
||||||
# f=$1
|
|
||||||
#fi
|
if [ ! -d "${BUILDBIN_LOCATION}" ]; then
|
||||||
#echo $f
|
echo Cannot find path ${BUILDBIN_LOCATION}
|
||||||
if [ "x${BASH_ARGV[0]}" = "x" ]; then
|
|
||||||
#if [ "x$f" = "x" ]; then
|
|
||||||
if [ ! -f this_build_bin_path.sh ]; then
|
|
||||||
f=$0
|
|
||||||
echo "aaaa"
|
|
||||||
#thispath=$(dirname ${BASH_ARGV[0]})
|
|
||||||
thispath=$(dirname $f)
|
|
||||||
p=$(cd ${thispath};pwd);
|
|
||||||
THIS_PATH="$p/build/bin/"
|
|
||||||
# echo "ERROR: must cd where/this/package/is before calling this_path.sh"
|
|
||||||
# echo "Try sourcing it"
|
|
||||||
else
|
|
||||||
echo "bbb"
|
|
||||||
THIS_PATH="$PWD/build/bin/";
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
thispath=$(dirname ${BASH_ARGV[0]})
|
echo Adding ${BUILDBIN_LOCATION} to PATH and PYTHONPATH
|
||||||
p=$(cd ${thispath};pwd);
|
export PATH=${BUILDBIN_LOCATION}:${PATH}
|
||||||
THIS_PATH="$p/build/bin/"
|
export PYTHONPATH=${BUILDBIN_LOCATION}:${PYTHONPATH}
|
||||||
echo "ccc"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "this_path="$THIS_PATH
|
|
||||||
export PATH=$THIS_PATH:$PATH
|
|
||||||
export LD_LIBRARY_PATH=$THIS_PATH:$LD_LIBRARY_PATH
|
|
||||||
export PYTHONPATH=$THIS_PATH:$PYTHONPATH
|
|
||||||
|
|
||||||
echo "path="$PATH
|
|
||||||
echo "ld_library_path="$LD_LIBRARY_PATH
|
|
||||||
echo "pythonpath="$PYTHON_PATH
|
|
||||||
|
|||||||
Reference in New Issue
Block a user