From b39c64032db0a1045b6194435424cbd9c4ad96f6 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 19 Oct 2021 14:49:43 +0200 Subject: [PATCH] clang format --- python/src/detector_in.cpp | 13 +- python/src/enums_in.cpp | 2 +- python/src/main.cpp | 16 +- python/src/mythenFileIO.h | 2 +- python/src/network.cpp | 45 +++--- python/src/scan.cpp | 22 ++- python/src/typecaster.h | 2 +- slsDetectorGui/include/qTabSettings.h | 9 +- .../slsDetectorPlotting/include/SlsQt1DPlot.h | 4 +- .../slsDetectorPlotting/include/SlsQt2DPlot.h | 4 +- .../slsDetectorPlotting/src/SlsQt1DPlot.cpp | 4 +- .../slsDetectorPlotting/src/SlsQt2DPlot.cpp | 4 +- slsDetectorGui/src/qDetectorMain.cpp | 45 +++--- slsDetectorGui/src/qTabDataOutput.cpp | 8 +- slsDetectorGui/src/qTabSettings.cpp | 4 +- slsDetectorServers/eigerDetectorServer/Beb.c | 20 +-- .../eigerDetectorServer/FebControl.c | 9 +- .../eigerDetectorServer/FebRegisterDefs.h | 2 +- .../HardwareMMappingDefs.h | 1 - .../slsDetectorFunctionList.c | 42 +++--- .../slsDetectorFunctionList.c | 95 ++++++------ .../slsDetectorFunctionList.c | 138 ++++++++++-------- .../slsDetectorFunctionList.c | 1 - .../mythen3DetectorServer/mythen3.c | 2 +- .../mythen3DetectorServer/mythen3.h | 32 ++-- .../slsDetectorFunctionList.c | 11 +- .../include/programFpgaNios.h | 3 +- .../include/slsDetectorFunctionList.h | 6 +- .../slsDetectorServer/src/common.c | 4 +- .../src/communication_funcs_UDP.c | 73 +++++---- slsDetectorSoftware/include/sls/Result.h | 2 +- slsDetectorSoftware/src/CmdProxy.h | 57 +++++--- slsDetectorSoftware/src/Detector.cpp | 39 ++--- slsDetectorSoftware/src/DetectorImpl.cpp | 14 +- slsDetectorSoftware/src/DetectorImpl.h | 2 +- slsDetectorSoftware/src/Module.h | 2 +- slsDetectorSoftware/src/SharedMemory.h | 2 +- slsDetectorSoftware/tests/test-CmdParser.cpp | 73 +++++---- .../tests/test-CmdProxy-jungfrau.cpp | 23 +-- slsDetectorSoftware/tests/test-CmdProxy.cpp | 52 +++---- slsDetectorSoftware/tests/test-Pattern.cpp | 12 +- .../tests/test-SharedMemory.cpp | 12 +- slsReceiverSoftware/src/ClientInterface.cpp | 18 +-- slsReceiverSoftware/src/ClientInterface.h | 1 - slsReceiverSoftware/src/DataProcessor.h | 16 +- slsReceiverSoftware/src/DataStreamer.cpp | 4 +- slsReceiverSoftware/src/Implementation.cpp | 25 ++-- slsReceiverSoftware/src/Implementation.h | 6 +- slsReceiverSoftware/src/Listener.cpp | 8 +- slsReceiverSoftware/src/Listener.h | 5 +- slsReceiverSoftware/src/MasterAttributes.h | 6 +- slsReceiverSoftware/src/receiver_defs.h | 2 +- slsSupportLib/include/sls/DataSocket.h | 4 +- slsSupportLib/include/sls/container_utils.h | 2 +- slsSupportLib/include/sls/md5.h | 126 ++++++++-------- slsSupportLib/include/sls/network_utils.h | 2 +- slsSupportLib/include/sls/sls_detector_defs.h | 31 ++-- slsSupportLib/include/sls/string_utils.h | 3 +- slsSupportLib/include/sls/versionAPI.h | 20 +-- slsSupportLib/src/DataSocket.cpp | 12 +- slsSupportLib/src/ToString.cpp | 2 +- slsSupportLib/src/string_utils.cpp | 6 +- slsSupportLib/tests/test-Sockets.cpp | 1 - slsSupportLib/tests/test-ToString.cpp | 25 ++-- slsSupportLib/tests/test-network_utils.cpp | 19 +-- slsSupportLib/tests/test-string_utils.cpp | 9 +- 66 files changed, 642 insertions(+), 624 deletions(-) mode change 100755 => 100644 python/src/main.cpp mode change 100755 => 100644 slsReceiverSoftware/src/receiver_defs.h mode change 100755 => 100644 slsSupportLib/src/string_utils.cpp diff --git a/python/src/detector_in.cpp b/python/src/detector_in.cpp index 0aa492189..b2f8afc9b 100644 --- a/python/src/detector_in.cpp +++ b/python/src/detector_in.cpp @@ -16,15 +16,14 @@ #include namespace py = pybind11; void init_det(py::module &m) { + using sls::defs; using sls::Detector; + using sls::ns; using sls::Positions; using sls::Result; - using sls::defs; - using sls::ns; - - py::class_ CppDetectorApi(m, "CppDetectorApi"); - CppDetectorApi - .def(py::init()) - [[FUNCTIONS]] + py::class_ CppDetectorApi(m, "CppDetectorApi"); + CppDetectorApi.def(py::init()) + + [[FUNCTIONS]] } diff --git a/python/src/enums_in.cpp b/python/src/enums_in.cpp index 4530ca924..12d72b262 100644 --- a/python/src/enums_in.cpp +++ b/python/src/enums_in.cpp @@ -6,8 +6,8 @@ #include #include -#include "sls/sls_detector_defs.h" #include "sls/Pattern.h" +#include "sls/sls_detector_defs.h" namespace py = pybind11; void init_enums(py::module &m) { py::class_ Defs(m, "slsDetectorDefs"); diff --git a/python/src/main.cpp b/python/src/main.cpp old mode 100755 new mode 100644 index 67a9f89e5..76657d374 --- a/python/src/main.cpp +++ b/python/src/main.cpp @@ -5,15 +5,14 @@ #include #include +#include "mythenFileIO.h" #include "sls/Detector.h" #include "sls/Result.h" -#include "mythenFileIO.h" #include #include #include "typecaster.h" - using ds = std::chrono::duration; namespace py = pybind11; @@ -35,14 +34,13 @@ PYBIND11_MODULE(_slsdet, m) { )pbdoc"; - init_enums(m); - init_det(m); - init_network(m); - init_pattern(m); - init_scan(m); - init_source(m); + init_enums(m); + init_det(m); + init_network(m); + init_pattern(m); + init_scan(m); + init_source(m); // init_experimental(m); - py::module io = m.def_submodule("io", "Submodule for io"); io.def("read_my302_file", &read_my302_file, "some"); diff --git a/python/src/mythenFileIO.h b/python/src/mythenFileIO.h index c9551a273..1771c96f1 100644 --- a/python/src/mythenFileIO.h +++ b/python/src/mythenFileIO.h @@ -81,7 +81,7 @@ std::vector ReadFile(const std::string &fname, int byte_offset = 8, } py::array_t read_my302_file(const std::string &fname, int offset = 8, - int dr = 24) { + int dr = 24) { auto data = ExtractBits<17, 6>(ReadFile(fname, offset, dr)); return py::array(data.size(), data.data()); } diff --git a/python/src/network.cpp b/python/src/network.cpp index f6c8a1fad..17e90d78c 100644 --- a/python/src/network.cpp +++ b/python/src/network.cpp @@ -2,10 +2,9 @@ // Copyright (C) 2021 Contributors to the SLS Detector Package /* This file contains Python bindings for the IpAddr and MacAddr -classes. +classes. */ - #include #include #include @@ -17,27 +16,25 @@ using sls::IpAddr; using sls::MacAddr; void init_network(py::module &m) { - py::class_ (m, "IpAddr") - .def(py::init()) - .def(py::init()) - .def(py::init()) - .def(py::init()) - .def("hex", &IpAddr::hex) - .def("uint32", &IpAddr::uint32) - .def(py::self == py::self) - .def("__repr__", &IpAddr::str) - .def("str", &IpAddr::str); - - - py::class_ (m, "MacAddr") - .def(py::init()) - .def(py::init()) - .def(py::init()) - .def(py::init()) - .def("hex", &MacAddr::hex) - .def(py::self == py::self) - .def("uint64", &MacAddr::uint64) - .def("__repr__", &MacAddr::str) - .def("str", &MacAddr::str); + py::class_(m, "IpAddr") + .def(py::init()) + .def(py::init()) + .def(py::init()) + .def(py::init()) + .def("hex", &IpAddr::hex) + .def("uint32", &IpAddr::uint32) + .def(py::self == py::self) + .def("__repr__", &IpAddr::str) + .def("str", &IpAddr::str); + py::class_(m, "MacAddr") + .def(py::init()) + .def(py::init()) + .def(py::init()) + .def(py::init()) + .def("hex", &MacAddr::hex) + .def(py::self == py::self) + .def("uint64", &MacAddr::uint64) + .def("__repr__", &MacAddr::str) + .def("str", &MacAddr::str); } diff --git a/python/src/scan.cpp b/python/src/scan.cpp index 308c28c1a..13e0e4bf2 100644 --- a/python/src/scan.cpp +++ b/python/src/scan.cpp @@ -1,12 +1,12 @@ // SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package +#include "sls/sls_detector_defs.h" #include #include #include #include #include #include -#include "sls/sls_detector_defs.h" namespace py = pybind11; void init_scan(py::module &m) { @@ -16,26 +16,24 @@ void init_scan(py::module &m) { scanParameters.def(py::init()); scanParameters.def(py::init()); - scanParameters.def(py::init()); + scanParameters.def(py::init()); scanParameters.def_readwrite("enable", &sp::enable); scanParameters.def_readwrite("dacInd", &sp::dacInd); scanParameters.def_readwrite("startOffset", &sp::startOffset); scanParameters.def_readwrite("stopOffset", &sp::stopOffset); scanParameters.def_readwrite("stepSize", &sp::stepSize); scanParameters.def_readwrite("dacSettleTime_ns", &sp::dacSettleTime_ns); - scanParameters.def("__repr__", [](const sp &a){ + scanParameters.def("__repr__", [](const sp &a) { std::ostringstream oss; auto indent = " "; oss << "\n"; - oss << indent << "enable: " << a.enable << '\n'; - oss << indent << "dacInd: " << a.dacInd << '\n'; - oss << indent << "startOffset: " << a.startOffset << '\n'; - oss << indent << "stopOffset: " << a.stopOffset << '\n'; - oss << indent << "stepSize: " << a.stepSize << '\n'; - oss << indent << "dacSettleTime_ns: " << a.dacSettleTime_ns; + oss << indent << "enable: " << a.enable << '\n'; + oss << indent << "dacInd: " << a.dacInd << '\n'; + oss << indent << "startOffset: " << a.startOffset << '\n'; + oss << indent << "stopOffset: " << a.stopOffset << '\n'; + oss << indent << "stepSize: " << a.stepSize << '\n'; + oss << indent << "dacSettleTime_ns: " << a.dacSettleTime_ns; return oss.str(); }); - - - } diff --git a/python/src/typecaster.h b/python/src/typecaster.h index dfe562640..8e2aa6d4d 100644 --- a/python/src/typecaster.h +++ b/python/src/typecaster.h @@ -1,8 +1,8 @@ // SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package #pragma once -#include #include "sls/Result.h" +#include // Add type_typecaster to pybind for our wrapper type namespace pybind11 { namespace detail { diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h index 28f61e09c..2a2a2c8af 100644 --- a/slsDetectorGui/include/qTabSettings.h +++ b/slsDetectorGui/include/qTabSettings.h @@ -66,14 +66,7 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject { NUMSETTINGS }; - enum { - DYNAMIC, - FORCE_SWITCH_G1, - FORCE_SWITCH_G2, - FIX_G1, - FIX_G2, - FIX_G0 - }; + enum { DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 }; bool isVisibleFixG0{false}; enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 }; diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h index 4e86e32a0..e3cbb4e21 100644 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h +++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: LGPL-3.0-or-other -// Copyright (C) 2021 Contributors to the SLS Detector Package +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package #ifndef SLSQT1DPLOT_H #define SLSQT1DPLOT_H diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h index bc49f0dcf..b0067bc98 100644 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h +++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: LGPL-3.0-or-other -// Copyright (C) 2021 Contributors to the SLS Detector Package +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package #pragma once #include "SlsQt2DHist.h" #include "SlsQt2DZoomer.h" diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cpp b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cpp index b7b2baf98..cf3450a0d 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cpp +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cpp @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: LGPL-3.0-or-other -// Copyright (C) 2021 Contributors to the SLS Detector Package +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package /* TODO! short description */ #include "SlsQt1DPlot.h" diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cpp b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cpp index 55734dbc5..4a686e617 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cpp +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cpp @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: LGPL-3.0-or-other -// Copyright (C) 2021 Contributors to the SLS Detector Package +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package #include "SlsQt2DPlot.h" // #include "sls/ansi.h" diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index 103d691bc..7d136aaba 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -449,36 +449,35 @@ void qDetectorMain::ExecuteHelp(QAction *action) { CATCH_DISPLAY("Could not get client version.", "qDetectorMain::ExecuteHelp") - qDefs::Message(qDefs::INFORMATION, - "

" + qDefs::Message( + qDefs::INFORMATION, + "

" - "SLS Detector GUI version:   " + - guiVersion + - "
SLS Detector Client version: " + - clientVersion + - "


" + "SLS Detector GUI version:   " + + guiVersion + + "
SLS Detector Client version: " + clientVersion + + "


" - "Common GUI to control the SLS Detectors: " - "Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and " - "Moench.

" + "Common GUI to control the SLS Detectors: " + "Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and " + "Moench.

" - "It can be operated in parallel with the command " - "line interface: sls_detector_put, sls_detector_get, " - "sls_detector_acquire and sls_detector_help.

" + "It can be operated in parallel with the command " + "line interface: sls_detector_put, sls_detector_get, " + "sls_detector_acquire and sls_detector_help.

" + "Support:
" + "Dhanya.Thattil@psi.ch
" + "Erik.Froejdh@psi.ch.


" - "Support:
" - "Dhanya.Thattil@psi.ch
" - "Erik.Froejdh@psi.ch.


" + "
slsDetectorGui Copyright (C) 2021 Contributors to SLS " + "Detector Package

" - "
slsDetectorGui Copyright (C) 2021 Contributors to SLS Detector Package

" + "See COPYING in root folder for Licensing details:
" + "LGPL-3.0-or-other" - "See COPYING in root folder for Licensing details:
" - "LGPL-3.0-or-other" - - - "<\\p>", - "qDetectorMain::ExecuteHelp"); + "<\\p>", + "qDetectorMain::ExecuteHelp"); } } diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index eda5f9817..171ec7f3e 100644 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -375,8 +375,8 @@ void qTabDataOutput::GetSpeed() { disconnect(comboClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int))); try { - auto retval = - det->getReadoutSpeed().tsquash("Readout Speed is inconsistent for all detectors."); + auto retval = det->getReadoutSpeed().tsquash( + "Readout Speed is inconsistent for all detectors."); comboClkDivider->setCurrentIndex(static_cast(retval)); } CATCH_DISPLAY("Could not get readout speed.", "qTabDataOutput::GetSpeed") @@ -390,8 +390,8 @@ void qTabDataOutput::SetSpeed(int speed) { try { det->setReadoutSpeed(static_cast(speed)); } - CATCH_HANDLE("Could not set readout speed.", "qTabDataOutput::SetSpeed", this, - &qTabDataOutput::GetSpeed) + CATCH_HANDLE("Could not set readout speed.", "qTabDataOutput::SetSpeed", + this, &qTabDataOutput::GetSpeed) } void qTabDataOutput::GetParallel() { diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index aff785855..dcee0a450 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -128,8 +128,8 @@ void qTabSettings::SetupDetectorSettings() { item[(int)it]->setEnabled(true); } } - CATCH_DISPLAY(std::string("Could not setup settings"), - "qTabSettings::SetupDetectorSettings") + CATCH_DISPLAY(std::string("Could not setup settings"), + "qTabSettings::SetupDetectorSettings") } } diff --git a/slsDetectorServers/eigerDetectorServer/Beb.c b/slsDetectorServers/eigerDetectorServer/Beb.c index 88163dfd7..57fcd5a9a 100644 --- a/slsDetectorServers/eigerDetectorServer/Beb.c +++ b/slsDetectorServers/eigerDetectorServer/Beb.c @@ -14,7 +14,6 @@ extern int isControlServer; #define MAX(x, y) (((x) > (y)) ? (x) : (y)) - struct LocalLinkInterface ll_beb_local, *ll_beb; struct udp_header_type udp_header; @@ -47,7 +46,6 @@ int Beb_deactivated_left_datastream = 1; int Beb_deactivated_right_datastream = 1; int Beb_deactivated_num_destinations = 1; - void Beb_Beb() { Beb_send_ndata = 0; Beb_send_buffer_size = 1026; @@ -90,7 +88,9 @@ void Beb_Beb() { void Beb_ClearHeaderData(int ten_gig) { for (int i = 0; i < MAX_UDP_DESTINATION; ++i) { if (!Beb_SetUpUDPHeader(i, ten_gig, 0, 0, 0, 0, 0, 0)) { - LOG(logERROR, ("Could not clear header data for entry %d (tengiga:%d)\n", i, ten_gig)); + LOG(logERROR, + ("Could not clear header data for entry %d (tengiga:%d)\n", i, + ten_gig)); } } } @@ -112,7 +112,8 @@ int Beb_SetUpUDPHeader(unsigned int header_number, int ten_gig, else bram_phy_addr = 0xC6001000; - if (!Beb_SetHeaderData(src_mac, src_ip, src_port, dst_mac, dst_ip, dst_port)) + if (!Beb_SetHeaderData(src_mac, src_ip, src_port, dst_mac, dst_ip, + dst_port)) return 0; int fd = Beb_open(&csp0base, bram_phy_addr); @@ -493,7 +494,7 @@ int Beb_SetDataStream(enum portPosition port, int enable) { : XPAR_GPIO_RGHT_STRM_DSBL_MSK); u_int32_t value = Beb_Read32(csp0base, reg); - // disabling in firmware + // disabling in firmware if (!enable) value |= mask; else @@ -875,11 +876,12 @@ int Beb_StopAcquisition() { return 1; } -int Beb_RequestNImages(int ten_gig, unsigned int nimages, int test_just_send_out_packets_no_wait) { +int Beb_RequestNImages(int ten_gig, unsigned int nimages, + int test_just_send_out_packets_no_wait) { if (!Beb_activated) return 1; - unsigned int maxnl = MAX_ROWS_PER_READOUT; + unsigned int maxnl = MAX_ROWS_PER_READOUT; unsigned int maxnp = (ten_gig ? 4 : 16) * Beb_bit_mode; unsigned int nl = Beb_readNRows; unsigned int npackets = (nl * maxnp) / maxnl; @@ -899,8 +901,8 @@ int Beb_RequestNImages(int ten_gig, unsigned int nimages, int test_just_send_out LOG(logINFO, ("ten_gig:%d, npackets:%d, " "Beb_bit_mode:%d, header_size:%d, nimages:%d, " "test_just_send_out_packets_no_wait:%d\n", - ten_gig, npackets, Beb_bit_mode, - header_size, nimages, test_just_send_out_packets_no_wait)); + ten_gig, npackets, Beb_bit_mode, header_size, nimages, + test_just_send_out_packets_no_wait)); u_int32_t right_port_value = 0x2000; u_int32_t *csp0base = 0; diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.c b/slsDetectorServers/eigerDetectorServer/FebControl.c index bfcc1838f..27d98a30a 100644 --- a/slsDetectorServers/eigerDetectorServer/FebControl.c +++ b/slsDetectorServers/eigerDetectorServer/FebControl.c @@ -1143,7 +1143,8 @@ int Feb_Control_SoftwareTrigger(int block) { // end of acquisition (cannot monitor readyForTrigger) int status = Feb_Control_AcquisitionInProgress(); if (status == STATUS_ERROR) { - LOG(logERROR, ("Status: ERROR reading DAQ status register\n")); + LOG(logERROR, + ("Status: ERROR reading DAQ status register\n")); return 0; } else if (status == STATUS_IDLE) { break; @@ -1158,8 +1159,10 @@ int Feb_Control_SoftwareTrigger(int block) { } LOG(logDEBUG2, ("Done waiting (wait for trigger)!\n")); } - LOG(logINFO, ("%s Software Trigger %s\n", (block ? "Blocking" : "Non blocking"), (block ? "Acquired" : "Sent"))); - fflush(stdout); + LOG(logINFO, + ("%s Software Trigger %s\n", (block ? "Blocking" : "Non blocking"), + (block ? "Acquired" : "Sent"))); + fflush(stdout); } return 1; diff --git a/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h b/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h index a9a8afe96..db2627181 100644 --- a/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h +++ b/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h @@ -15,7 +15,7 @@ #define DAQ_REG_EXPOSURE_REPEAT_TIMER 5 // == (31 downto 3) * 10^(2 downto 0) #define DAQ_REG_SUBFRAME_EXPOSURES 6 #define DAQ_REG_SUBFRAME_PERIOD 7 // also pg and fifo status register -#define DAQ_REG_READ_N_ROWS 8 +#define DAQ_REG_READ_N_ROWS 8 #define DAQ_REG_HRDWRE 12 // clang-format off diff --git a/slsDetectorServers/eigerDetectorServer/HardwareMMappingDefs.h b/slsDetectorServers/eigerDetectorServer/HardwareMMappingDefs.h index 631f298d2..e8a99aac6 100644 --- a/slsDetectorServers/eigerDetectorServer/HardwareMMappingDefs.h +++ b/slsDetectorServers/eigerDetectorServer/HardwareMMappingDefs.h @@ -1,7 +1,6 @@ // SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package - // from Gerd and was called mmap_test.h #ifndef __PLB_LL_FIFO_H__ diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 292604a33..3e1ff4ef3 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -692,7 +692,7 @@ void setupDetector() { eiger_photonenergy = DEFAULT_PHOTON_ENERGY; setParallelMode(DEFAULT_PARALLEL_MODE); setOverFlowMode(DEFAULT_READOUT_OVERFLOW32_MODE); - setReadoutSpeed(DEFAULT_CLK_SPEED); + setReadoutSpeed(DEFAULT_CLK_SPEED); setIODelay(DEFAULT_IO_DELAY); setTiming(DEFAULT_TIMING_MODE); setNextFrameNumber(DEFAULT_STARTING_FRAME_NUMBER); @@ -1544,13 +1544,13 @@ int configureMAC() { LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry)); LOG(logINFO, ("\tSource IP : %s\n" - "\tSource MAC : %s\n" - "\tSource Port : %d\n" - "\tDest IP : %s\n" - "\tDest MAC : %s\n" - "\tDest Port : %d\n" - "\tDest Port2 : %d\n", - src_ip, src_mac, srcport, dst_ip, dst_mac, dstport, dstport2)); + "\tSource MAC : %s\n" + "\tSource Port : %d\n" + "\tDest IP : %s\n" + "\tDest MAC : %s\n" + "\tDest Port : %d\n" + "\tDest Port2 : %d\n", + src_ip, src_mac, srcport, dst_ip, dst_mac, dstport, dstport2)); } #ifdef VIRTUAL @@ -1730,7 +1730,7 @@ int setReadoutSpeed(int val) { return OK; } -int getReadoutSpeed(int* retval) { +int getReadoutSpeed(int *retval) { *retval = eiger_readoutspeed; return OK; } @@ -2311,14 +2311,11 @@ void *start_timer(void *arg) { int readNRows = getReadNRows(); if (readNRows == -1) { - LOG(logERROR, - ("readNRows is -1. Assuming no readNRows.\n")); + LOG(logERROR, ("readNRows is -1. Assuming no readNRows.\n")); readNRows = MAX_ROWS_PER_READOUT; } const int maxRows = MAX_ROWS_PER_READOUT; - const int packetsPerFrame = - (maxPacketsPerFrame * readNRows) / maxRows; - + const int packetsPerFrame = (maxPacketsPerFrame * readNRows) / maxRows; LOG(logDEBUG1, (" dr:%d\n bytesperpixel:%f\n tgenable:%d\n datasize:%d\n " @@ -2358,19 +2355,16 @@ void *start_timer(void *arg) { break; case 16: *((uint16_t *)(imageData + i * sizeof(uint16_t))) = - eiger_virtual_test_mode ? 0xFFE - : (uint16_t)pixelVal; + eiger_virtual_test_mode ? 0xFFE : (uint16_t)pixelVal; break; case 32: *((uint32_t *)(imageData + i * sizeof(uint32_t))) = - eiger_virtual_test_mode ? 0xFFFFFE - : (uint32_t)pixelVal; + eiger_virtual_test_mode ? 0xFFFFFE : (uint32_t)pixelVal; break; default: break; } } - } // Send data @@ -2404,7 +2398,6 @@ void *start_timer(void *arg) { const int startval = 0; const int endval = startval + packetsPerFrame - 1; - // set header char packetData[packetsize]; memset(packetData, 0, packetsize); @@ -2466,18 +2459,21 @@ void *start_timer(void *arg) { } } } - if (eiger_virtual_left_datastream && i >= startval && i <= endval) { + if (eiger_virtual_left_datastream && i >= startval && + i <= endval) { usleep(eiger_virtual_transmission_delay_left); sendUDPPacket(iRxEntry, 0, packetData, packetsize); LOG(logDEBUG1, ("Sent left packet: %d\n", i)); } - if (eiger_virtual_right_datastream && i >= startval && i <= endval) { + if (eiger_virtual_right_datastream && i >= startval && + i <= endval) { usleep(eiger_virtual_transmission_delay_right); sendUDPPacket(iRxEntry, 1, packetData2, packetsize); LOG(logDEBUG1, ("Sent right packet: %d\n", i)); } } - LOG(logINFO, ("Sent frame %d [#%ld] to E%d\n", iframes, frameNr + iframes, iRxEntry)); + LOG(logINFO, ("Sent frame %d [#%ld] to E%d\n", iframes, + frameNr + iframes, iRxEntry)); clock_gettime(CLOCK_REALTIME, &end); int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec)); diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index f4901da8f..a9ae54ae6 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -296,7 +296,8 @@ int getModuleId(int *ret, char *mess) { void setModuleId(int modid) { LOG(logINFOBLUE, ("Setting module id in fpga: %d\n", modid)) bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK); - bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK)); + bus_w(MOD_ID_REG, + bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK)); } u_int64_t getDetectorMAC() { @@ -1915,23 +1916,21 @@ int checkDetectorType() { int type = atoi(buffer); if (type > TYPE_NO_MODULE_STARTING_VAL) { LOG(logERROR, - ("No Module attached! Expected %d, %d or %d for Gotthard2, got %d\n", - TYPE_GOTTHARD2_MODULE_VAL, - TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL, - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL, - type)); + ("No Module attached! Expected %d, %d or %d for Gotthard2, got " + "%d\n", + TYPE_GOTTHARD2_MODULE_VAL, TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL, + TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL, type)); return -2; } if ((abs(type - TYPE_GOTTHARD2_MODULE_VAL) > TYPE_TOLERANCE) && - (abs(type - TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL) > TYPE_TOLERANCE) && - (abs(type - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL) > TYPE_TOLERANCE)) { + (abs(type - TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL) > TYPE_TOLERANCE) && + (abs(type - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL) > TYPE_TOLERANCE)) { LOG(logERROR, - ("Wrong Module attached! Expected %d, %d or %d for Gotthard2, got %d\n", - TYPE_GOTTHARD2_MODULE_VAL, - TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL, - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL, - type)); + ("Wrong Module attached! Expected %d, %d or %d for Gotthard2, got " + "%d\n", + TYPE_GOTTHARD2_MODULE_VAL, TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL, + TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL, type)); return FAIL; } return OK; @@ -2088,52 +2087,52 @@ int getVCOFrequency(enum CLKINDEX ind) { int setReadoutSpeed(int val) { switch (val) { - case G2_108MHZ: - LOG(logINFOBLUE, ("Setting readout speed to 108 MHz\n")); - if (setClockDivider(READOUT_C0, SPEED_108_CLKDIV_0) == FAIL) { - return FAIL; - } - if (setClockDivider(READOUT_C1, SPEED_108_CLKDIV_1) == FAIL) { - return FAIL; - } - if (setPhase(READOUT_C1, SPEED_108_CLKPHASE_DEG_1, 1) == FAIL) { - return FAIL; - } - break; - case G2_144MHZ: - LOG(logINFOBLUE, ("Setting readout speed to 144 MHz\n")); - if (setClockDivider(READOUT_C0, SPEED_144_CLKDIV_0) == FAIL) { - return FAIL; - } - if (setClockDivider(READOUT_C1, SPEED_144_CLKDIV_1) == FAIL) { - return FAIL; - } - if (setPhase(READOUT_C1, SPEED_144_CLKPHASE_DEG_1, 1) == FAIL) { - return FAIL; - } - break; - default: - LOG(logERROR, ("Unknown readout speed %d\n", val)); + case G2_108MHZ: + LOG(logINFOBLUE, ("Setting readout speed to 108 MHz\n")); + if (setClockDivider(READOUT_C0, SPEED_108_CLKDIV_0) == FAIL) { return FAIL; + } + if (setClockDivider(READOUT_C1, SPEED_108_CLKDIV_1) == FAIL) { + return FAIL; + } + if (setPhase(READOUT_C1, SPEED_108_CLKPHASE_DEG_1, 1) == FAIL) { + return FAIL; + } + break; + case G2_144MHZ: + LOG(logINFOBLUE, ("Setting readout speed to 144 MHz\n")); + if (setClockDivider(READOUT_C0, SPEED_144_CLKDIV_0) == FAIL) { + return FAIL; + } + if (setClockDivider(READOUT_C1, SPEED_144_CLKDIV_1) == FAIL) { + return FAIL; + } + if (setPhase(READOUT_C1, SPEED_144_CLKPHASE_DEG_1, 1) == FAIL) { + return FAIL; + } + break; + default: + LOG(logERROR, ("Unknown readout speed %d\n", val)); + return FAIL; } return OK; } -int getReadoutSpeed(int* retval) { -//TODO ASIC and ADIFreg need to check???? -// clkdiv 2, 3, 4, 5? +int getReadoutSpeed(int *retval) { + // TODO ASIC and ADIFreg need to check???? + // clkdiv 2, 3, 4, 5? if (clkDivider[READOUT_C0] == SPEED_108_CLKDIV_0 && - clkDivider[READOUT_C1] == SPEED_108_CLKDIV_1 && - getPhase(READOUT_C1, 1) == SPEED_108_CLKPHASE_DEG_1) { + clkDivider[READOUT_C1] == SPEED_108_CLKDIV_1 && + getPhase(READOUT_C1, 1) == SPEED_108_CLKPHASE_DEG_1) { *retval = G2_108MHZ; } else if (clkDivider[READOUT_C0] == SPEED_144_CLKDIV_0 && - clkDivider[READOUT_C1] == SPEED_144_CLKDIV_1 && - getPhase(READOUT_C1, 1) == SPEED_144_CLKPHASE_DEG_1) { + clkDivider[READOUT_C1] == SPEED_144_CLKDIV_1 && + getPhase(READOUT_C1, 1) == SPEED_144_CLKPHASE_DEG_1) { *retval = G2_144MHZ; } - + else { *retval = -1; return FAIL; @@ -2154,7 +2153,7 @@ int setClockDivider(enum CLKINDEX ind, int val) { char *clock_names[] = {CLK_NAMES}; LOG(logINFOBLUE, ("Setting %s clock (%d) divider from %d to %d\n", - clock_names[ind], ind, clkDivider[ind], val)); + clock_names[ind], ind, clkDivider[ind], val)); // Remembering old phases in degrees int oldPhases[NUM_CLOCKS]; diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index b1919fd4e..8c54ca640 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -516,11 +516,11 @@ int resetToDefaultDacs(int hardReset) { const int vals_G0[] = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS; for (int i = 0; i < NSPECIALDACS; ++i) { defaultDacValue_G0[i] = vals_G0[i]; - } + } const int vals_HG0[] = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS; for (int i = 0; i < NSPECIALDACS; ++i) { defaultDacValue_HG0[i] = vals_HG0[i]; - } + } } // remember settings @@ -734,7 +734,9 @@ int readConfigFile() { // version 1.1 and HW 1.0 (version reg value = 2) is incompatible if (version == 11 && isHardwareVersion2()) { strcpy(initErrorMessage, - "Chip version 1.1 (from on-board config file) is incompatible with old board (v1.0). Please update board or correct on-board config file.\n"); + "Chip version 1.1 (from on-board config file) is " + "incompatible with old board (v1.0). Please update " + "board or correct on-board config file.\n"); break; } @@ -1352,7 +1354,9 @@ int setNumberofDestinations(int value) { LOG(logINFO, ("Setting number of entries to %d\n", value)); --value; bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_RX_ADDTNL_ENDPTS_NUM_MSK); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | ((value << CONTROL_RX_ADDTNL_ENDPTS_NUM_OFST) & CONTROL_RX_ADDTNL_ENDPTS_NUM_MSK)); + bus_w(CONTROL_REG, + bus_r(CONTROL_REG) | ((value << CONTROL_RX_ADDTNL_ENDPTS_NUM_OFST) & + CONTROL_RX_ADDTNL_ENDPTS_NUM_MSK)); return OK; } @@ -1391,7 +1395,7 @@ int getPrimaryInterface() { void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, uint64_t destmac, uint32_t destport, uint64_t sourcemac, uint32_t sourceip, uint32_t sourceport) { - + // start addr uint32_t addr = (type == INNER ? RXR_ENDPOINT_INNER_START_REG : RXR_ENDPOINT_OUTER_START_REG); @@ -1506,27 +1510,30 @@ int configureMAC() { if (iRxEntry < numUdpDestinations) { LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry)); - LOG(logINFO, ("\tOuter %s\n", (numInterfaces == 2) - ? "(Bottom)" - : (selInterface ? "Not Used" : "Used"))); + LOG(logINFO, + ("\tOuter %s\n", (numInterfaces == 2) + ? "(Bottom)" + : (selInterface ? "Not Used" : "Used"))); LOG(logINFO, ("\tSource IP : %s\n" - "\tSource MAC : %s\n" - "\tSource Port : %d\n" - "\tDest IP : %s\n" - "\tDest MAC : %s\n" - "\tDest Port : %d\n\n", - src_ip, src_mac, srcport, dst_ip, dst_mac, dstport)); + "\tSource MAC : %s\n" + "\tSource Port : %d\n" + "\tDest IP : %s\n" + "\tDest MAC : %s\n" + "\tDest Port : %d\n\n", + src_ip, src_mac, srcport, dst_ip, dst_mac, dstport)); - LOG(logINFO, ("\tInner %s\n", (numInterfaces == 2) - ? "(Top)" - : (selInterface ? "Used" : "Not Used"))); - LOG(logINFO, ("\tSource IP2 : %s\n" - "\tSource MAC2 : %s\n" - "\tSource Port2: %d\n" - "\tDest IP2 : %s\n" - "\tDest MAC2 : %s\n" - "\tDest Port2 : %d\n\n", - src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2)); + LOG(logINFO, + ("\tInner %s\n", (numInterfaces == 2) + ? "(Top)" + : (selInterface ? "Used" : "Not Used"))); + LOG(logINFO, + ("\tSource IP2 : %s\n" + "\tSource MAC2 : %s\n" + "\tSource Port2: %d\n" + "\tDest IP2 : %s\n" + "\tDest MAC2 : %s\n" + "\tDest Port2 : %d\n\n", + src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2)); } #ifdef VIRTUAL if (setUDPDestinationDetails(iRxEntry, 0, dst_ip, dstport) == FAIL) { @@ -1548,18 +1555,18 @@ int configureMAC() { setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, srcip, srcport); // top - setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, srcip2, - srcport2); + setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, + srcip2, srcport2); } // single interface else { // default if (selInterface == 0) { - setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, srcip, - srcport); + setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, + srcip, srcport); } else { - setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, srcip, - srcport2); + setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, + srcip, srcport2); } } } @@ -1652,16 +1659,17 @@ int setReadNRows(int value) { return FAIL; } - // regval is numpackets - 1 + // regval is numpackets - 1 int regval = (value / READ_N_ROWS_MULTIPLE) - 1; uint32_t addr = READ_N_ROWS_REG; LOG(logINFO, ("Setting number of rows: %d (regval:%d)\n", value, regval)); - bus_w(addr, bus_r(addr) &~READ_N_ROWS_NUM_ROWS_MSK); - bus_w(addr, bus_r(addr) | ((regval << READ_N_ROWS_NUM_ROWS_OFST) & READ_N_ROWS_NUM_ROWS_MSK)); + bus_w(addr, bus_r(addr) & ~READ_N_ROWS_NUM_ROWS_MSK); + bus_w(addr, bus_r(addr) | ((regval << READ_N_ROWS_NUM_ROWS_OFST) & + READ_N_ROWS_NUM_ROWS_MSK)); if (value == MAX_ROWS_PER_READOUT) { LOG(logINFO, ("Disabling Partial Readout (#rows)\n")); - bus_w(addr, bus_r(addr) &~READ_N_ROWS_ENBL_MSK); + bus_w(addr, bus_r(addr) & ~READ_N_ROWS_ENBL_MSK); } else { LOG(logINFO, ("Enabling Partial Readout (#rows)\n")); bus_w(addr, bus_r(addr) | READ_N_ROWS_ENBL_MSK); @@ -1671,14 +1679,15 @@ int setReadNRows(int value) { int getReadNRows() { int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK); - int regval = ((bus_r(READ_N_ROWS_REG) & READ_N_ROWS_NUM_ROWS_MSK) >> READ_N_ROWS_NUM_ROWS_OFST); - - int maxRegval = (MAX_ROWS_PER_READOUT/ READ_N_ROWS_MULTIPLE) - 1; + int regval = ((bus_r(READ_N_ROWS_REG) & READ_N_ROWS_NUM_ROWS_MSK) >> + READ_N_ROWS_NUM_ROWS_OFST); + + int maxRegval = (MAX_ROWS_PER_READOUT / READ_N_ROWS_MULTIPLE) - 1; if ((regval == maxRegval && enable) || (regval != maxRegval && !enable)) { return -1; } - return (regval + 1) * READ_N_ROWS_MULTIPLE; + return (regval + 1) * READ_N_ROWS_MULTIPLE; } void initReadoutConfiguration() { @@ -1724,13 +1733,13 @@ int powerChip(int on) { LOG(logINFOBLUE, ("Powering chip: on\n")); bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) | CHIP_POWER_ENABLE_MSK); - - configureChip(); + + configureChip(); } else { LOG(logINFOBLUE, ("Powering chip: off\n")); bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK); - + chipConfigured = 0; } } @@ -1742,15 +1751,13 @@ int powerChip(int on) { CHIP_POWER_STATUS_OFST); } -int isChipConfigured() { - return chipConfigured; -} +int isChipConfigured() { return chipConfigured; } void configureChip() { // only for chipv1.1 and chip is powered on if (getChipVersion() == 11 && powerChip(-1)) { LOG(logINFOBLUE, ("\tConfiguring chip\n")); - + // waiting 500 ms before configuring selection usleep(500 * 1000); @@ -1766,12 +1773,11 @@ void configureChip() { // write same register values back to configure chip bus_w(CONFIG_V11_REG, bus_r(CONFIG_V11_REG)); - LOG(logINFOBLUE, ("\tChip configured\n")); + LOG(logINFOBLUE, ("\tChip configured\n")); chipConfigured = 1; } } - int autoCompDisable(int on) { if (on != -1) { if (on) { @@ -1922,7 +1928,7 @@ int setReadoutSpeed(int val) { return OK; } -int getReadoutSpeed(int* retval) { +int getReadoutSpeed(int *retval) { u_int32_t speed = bus_r(CONFIG_REG) & CONFIG_READOUT_SPEED_MSK; switch (speed) { case CONFIG_FULL_SPEED_40MHZ_VAL: @@ -2191,7 +2197,8 @@ int getFilterCell() { #else uint32_t addr = CONFIG_V11_STATUS_REG; #endif - uint32_t value = (bus_r(addr) & CONFIG_V11_FLTR_CLL_MSK) >> CONFIG_V11_FLTR_CLL_OFST; + uint32_t value = + (bus_r(addr) & CONFIG_V11_FLTR_CLL_MSK) >> CONFIG_V11_FLTR_CLL_OFST; // count number of bits = which icell return (__builtin_popcount(value)); } @@ -2202,7 +2209,7 @@ void setFilterCell(int iCell) { } uint32_t addr = CONFIG_V11_REG; - bus_w(addr, bus_r(addr) &~ CONFIG_V11_FLTR_CLL_MSK); + bus_w(addr, bus_r(addr) & ~CONFIG_V11_FLTR_CLL_MSK); if (iCell > 0) { // enables as many cells @@ -2210,9 +2217,11 @@ void setFilterCell(int iCell) { for (int i = 0; i != iCell; ++i) { value |= (1 << i); } - bus_w(addr, bus_r(addr) | ((value << CONFIG_V11_FLTR_CLL_OFST) & CONFIG_V11_FLTR_CLL_MSK)); + bus_w(addr, bus_r(addr) | ((value << CONFIG_V11_FLTR_CLL_OFST) & + CONFIG_V11_FLTR_CLL_MSK)); } - LOG(logINFO, ("Setting Filter Cell to %d [Reg:0x%x]\n", iCell, bus_r(addr))); + LOG(logINFO, + ("Setting Filter Cell to %d [Reg:0x%x]\n", iCell, bus_r(addr))); } void disableCurrentSource() { @@ -2239,8 +2248,8 @@ void enableCurrentSource(int fix, uint64_t select, int normal) { (long unsigned int)select)); } else { LOG(logINFO, - ("Enabling current source [fix:%d, select:%ld, normal:%d]\n", - fix, (long int)select, normal)); + ("Enabling current source [fix:%d, select:%ld, normal:%d]\n", fix, + (long int)select, normal)); } // fix if (fix) { @@ -2269,8 +2278,8 @@ void enableCurrentSource(int fix, uint64_t select, int normal) { // push the bit into MSB side inverted |= (bit << (63 - i)); } - LOG(logINFO, ("\tSetting selection to 0x%lx (inverted from 0x%lx)\n", - (long unsigned int) inverted, (long unsigned int)select)); + LOG(logINFO, ("\tSetting selection to 0x%lx (inverted from 0x%lx)\n", + (long unsigned int)inverted, (long unsigned int)select)); set64BitReg(inverted, CRRNT_SRC_COL_LSB_REG, CRRNT_SRC_COL_MSB_REG); // normal @@ -2326,7 +2335,8 @@ uint64_t getSelectCurrentSource() { DAQ_CRRNT_SRC_CLMN_SLCT_OFST); } else { // invert the select - uint64_t retval = get64BitReg(CRRNT_SRC_COL_LSB_REG, CRRNT_SRC_COL_MSB_REG); + uint64_t retval = + get64BitReg(CRRNT_SRC_COL_LSB_REG, CRRNT_SRC_COL_MSB_REG); uint64_t tmp = retval; uint64_t inverted = 0; @@ -2335,8 +2345,8 @@ uint64_t getSelectCurrentSource() { uint64_t bit = (tmp >> i) & 0x1; // push the bit into MSB side inverted |= (bit << (63 - i)); - } - return inverted; + } + return inverted; } } @@ -2489,7 +2499,7 @@ void *start_timer(void *arg) { for (int i = 0; i != maxPacketsPerFrame; ++i) { const int startval = - (maxPacketsPerFrame / 2) - (packetsPerFrame / 2); + (maxPacketsPerFrame / 2) - (packetsPerFrame / 2); const int endval = startval + packetsPerFrame - 1; int pnum = i; @@ -2538,14 +2548,16 @@ void *start_timer(void *arg) { memcpy(packetData2 + sizeof(sls_detector_header), imageData + srcOffset2, dataSize); srcOffset2 += dataSize; - + if (i >= startval && i <= endval) { sendUDPPacket(iRxEntry, 1, packetData2, packetsize); - LOG(logDEBUG1, ("Sent packet: %d [interface 1]\n", pnum)); + LOG(logDEBUG1, + ("Sent packet: %d [interface 1]\n", pnum)); } } } - LOG(logINFO, ("Sent frame %d [#%ld] to E%d\n", iframes, frameNr + iframes, iRxEntry)); + LOG(logINFO, ("Sent frame %d [#%ld] to E%d\n", iframes, + frameNr + iframes, iRxEntry)); clock_gettime(CLOCK_REALTIME, &end); int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec)); diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 1d48623a0..1c0c703fd 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -1581,7 +1581,6 @@ int getADCPipeline() { ADC_OFFSET_ADC_PPLN_OFST); } - /* aquisition */ int startStateMachine() { diff --git a/slsDetectorServers/mythen3DetectorServer/mythen3.c b/slsDetectorServers/mythen3DetectorServer/mythen3.c index 7d98a9734..88d13b4ea 100644 --- a/slsDetectorServers/mythen3DetectorServer/mythen3.c +++ b/slsDetectorServers/mythen3DetectorServer/mythen3.c @@ -92,7 +92,7 @@ patternParameters *setChipStatusRegisterPattern(int csr) { for (int i = 0; i < 8; i++) pat->word[iaddr++] = patword; //#This version of the serializer pushes in the MSB first (compatible with - //the CSR bit numbering) + // the CSR bit numbering) for (int ib = nbits - 1; ib >= 0; ib--) { if (csr & (1 << ib)) patword = setBit(SIGNAL_serialIN, patword); diff --git a/slsDetectorServers/mythen3DetectorServer/mythen3.h b/slsDetectorServers/mythen3DetectorServer/mythen3.h index 14ec2226e..16b691250 100644 --- a/slsDetectorServers/mythen3DetectorServer/mythen3.h +++ b/slsDetectorServers/mythen3DetectorServer/mythen3.h @@ -33,25 +33,27 @@ #define SIGNAL_CHSclk (24) #define SIGNAL_exposing (25) - -//CHIP STARTUS REGISTER BITS +// CHIP STARTUS REGISTER BITS #define CSR_spypads 0 -#define CSR_invpol 4 -#define CSR_dpulse 5 -#define CSR_interp 6 +#define CSR_invpol 4 +#define CSR_dpulse 5 +#define CSR_interp 6 #define _CSR_C10pre 7 //#default, negative polarity -#define CSR_pumprobe 8 -#define CSR_apulse 9 -#define CSR_C15sh 10 -#define CSR_C30sh 11 //#default -#define CSR_C50sh 12 -#define CSR_C225ACsh 13 // Connects 225fF SHAPER AC cap (1: 225 to shaper, 225 to GND. 0: 450 to shaper) -#define _CSR_C15pre 14 // negative polarity +#define CSR_pumprobe 8 +#define CSR_apulse 9 +#define CSR_C15sh 10 +#define CSR_C30sh 11 //#default +#define CSR_C50sh 12 +#define CSR_C225ACsh \ + 13 // Connects 225fF SHAPER AC cap (1: 225 to shaper, 225 to GND. 0: 450 to + // shaper) +#define _CSR_C15pre 14 // negative polarity -#define CSR_default (1<<_CSR_C10pre )|(1<< CSR_C30sh) - -#define GAIN_MASK ((1 << _CSR_C10pre) | ( 1 << CSR_C15sh) | (1 << CSR_C30sh) | (1 << CSR_C50sh) | (1 << CSR_C225ACsh) | ( 1 << _CSR_C15pre)) +#define CSR_default (1 << _CSR_C10pre) | (1 << CSR_C30sh) +#define GAIN_MASK \ + ((1 << _CSR_C10pre) | (1 << CSR_C15sh) | (1 << CSR_C30sh) | \ + (1 << CSR_C50sh) | (1 << CSR_C225ACsh) | (1 << _CSR_C15pre)) int setBit(int ibit, int patword); int clearBit(int ibit, int patword); diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 8c9288b7e..51a0c0895 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -283,7 +283,6 @@ u_int32_t getDetectorNumber() { return bus_r(MCB_SERIAL_NO_REG); } - int getModuleId(int *ret, char *mess) { return ((bus_r(MOD_ID_REG) & MOD_ID_MSK) >> MOD_ID_OFST); } @@ -543,18 +542,18 @@ int resetToDefaultDacs(int hardReset) { for (int i = 0; i < NDAC; ++i) { defaultDacValues[i] = vals[i]; } - const int vals_standard[] = SPECIAL_DEFAULT_STANDARD_DAC_VALS; + const int vals_standard[] = SPECIAL_DEFAULT_STANDARD_DAC_VALS; for (int i = 0; i < NSPECIALDACS; ++i) { defaultDacValue_standard[i] = vals_standard[i]; - } + } const int vals_fast[] = SPECIAL_DEFAULT_FAST_DAC_VALS; for (int i = 0; i < NSPECIALDACS; ++i) { defaultDacValue_fast[i] = vals_fast[i]; - } - const int vals_highgain[] = SPECIAL_DEFAULT_HIGHGAIN_DAC_VALS; + } + const int vals_highgain[] = SPECIAL_DEFAULT_HIGHGAIN_DAC_VALS; for (int i = 0; i < NSPECIALDACS; ++i) { defaultDacValue_highgain[i] = vals_highgain[i]; - } + } } // remember settings diff --git a/slsDetectorServers/slsDetectorServer/include/programFpgaNios.h b/slsDetectorServers/slsDetectorServer/include/programFpgaNios.h index e2929ce40..7e9d0be7c 100644 --- a/slsDetectorServers/slsDetectorServer/include/programFpgaNios.h +++ b/slsDetectorServers/slsDetectorServer/include/programFpgaNios.h @@ -13,7 +13,8 @@ void NotifyServerStartSuccess(); /** reset fpga and controller(only implemented for >= v1.1 boards) */ void rebootControllerAndFPGA(); -int eraseAndWriteToFlash(char *mess, char *checksum, char *fpgasrc, uint64_t fsize); +int eraseAndWriteToFlash(char *mess, char *checksum, char *fpgasrc, + uint64_t fsize); int getDrive(char *mess); int openFileForFlash(FILE **flashfd, char *mess); int eraseFlash(char *mess); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 92fc54307..0f8f4a638 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -473,7 +473,7 @@ int setComparatorDisableTime(int64_t val); int64_t getComparatorDisableTime(); void configureASICTimer(); int setReadoutSpeed(int val); -int getReadoutSpeed(int* retval); +int getReadoutSpeed(int *retval); int setPhase(enum CLKINDEX ind, int val, int degrees); int getPhase(enum CLKINDEX ind, int degrees); int getMaxPhase(enum CLKINDEX ind); @@ -498,7 +498,7 @@ uint64_t getSelectCurrentSource(); // eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter #elif EIGERD int setReadoutSpeed(int val); -int getReadoutSpeed(int* retval); +int getReadoutSpeed(int *retval); int setIODelay(int val); int setCounterBit(int val); int pulsePixel(int n, int x, int y); @@ -551,7 +551,7 @@ int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); int getFrequency(enum CLKINDEX ind); int getVCOFrequency(enum CLKINDEX ind); int setReadoutSpeed(int val); -int getReadoutSpeed(int* retval); +int getReadoutSpeed(int *retval); int getMaxClockDivider(); int setClockDivider(enum CLKINDEX ind, int val); int getClockDivider(enum CLKINDEX ind); diff --git a/slsDetectorServers/slsDetectorServer/src/common.c b/slsDetectorServers/slsDetectorServer/src/common.c index a784d43c2..5c2390172 100644 --- a/slsDetectorServers/slsDetectorServer/src/common.c +++ b/slsDetectorServers/slsDetectorServer/src/common.c @@ -9,7 +9,6 @@ #include #include // readlink - int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int outputMax, int inputValue, int *outputValue) { LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n", @@ -245,7 +244,8 @@ int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname, // read only until a particular size (drive) if (fsize != 0 && totalBytesRead >= fsize) { - LOG(logINFO, ("\tReached %lu bytes. Not reading more\n", totalBytesRead)); + LOG(logINFO, + ("\tReached %lu bytes. Not reading more\n", totalBytesRead)); break; } bytes = fread(buf, 1, readUnitSize, fp); diff --git a/slsDetectorServers/slsDetectorServer/src/communication_funcs_UDP.c b/slsDetectorServers/slsDetectorServer/src/communication_funcs_UDP.c index 3e62ab323..d74c8ca6b 100644 --- a/slsDetectorServers/slsDetectorServer/src/communication_funcs_UDP.c +++ b/slsDetectorServers/slsDetectorServer/src/communication_funcs_UDP.c @@ -30,8 +30,9 @@ void setupUDPCommParameters() { memset(udpDestinationIp, 0, sizeof(udpDestinationIp)); } -int getUdPSocketDescriptor(int iRxEntry, int index) { return udpSockfd[iRxEntry][index]; } - +int getUdPSocketDescriptor(int iRxEntry, int index) { + return udpSockfd[iRxEntry][index]; +} int setUDPDestinationDetails(int iRxEntry, int index, const char *ip, unsigned short int port) { @@ -62,16 +63,20 @@ int setUDPDestinationDetails(int iRxEntry, int index, const char *ip, int err = getaddrinfo(udpDestinationIp[iRxEntry][index], sport, &hints, &udpServerAddrInfo[iRxEntry][index]); if (err != 0) { - LOG(logERROR, ("Failed to resolve remote socket address %s at port %d [entry:%d]. " + LOG(logERROR, ("Failed to resolve remote socket address %s at port %d " + "[entry:%d]. " "(Error code:%d, %s)\n", - udpDestinationIp[iRxEntry][index], udpDestinationPort[iRxEntry][index], iRxEntry, err, + udpDestinationIp[iRxEntry][index], + udpDestinationPort[iRxEntry][index], iRxEntry, err, gai_strerror(err))); return FAIL; } if (udpServerAddrInfo[iRxEntry][index] == NULL) { - LOG(logERROR, ("Failed to resolve remote socket address %s at port %d [entry:%d]." - "(getaddrinfo returned NULL)\n", - udpDestinationIp[iRxEntry][index], udpDestinationPort[iRxEntry][index], iRxEntry)); + LOG(logERROR, + ("Failed to resolve remote socket address %s at port %d [entry:%d]." + "(getaddrinfo returned NULL)\n", + udpDestinationIp[iRxEntry][index], + udpDestinationPort[iRxEntry][index], iRxEntry)); udpServerAddrInfo[iRxEntry][index] = 0; return FAIL; } @@ -80,41 +85,51 @@ int setUDPDestinationDetails(int iRxEntry, int index, const char *ip, } int createUDPSocket(int index) { - + for (int iRxEntry = 0; iRxEntry != numUdpDestinations; ++iRxEntry) { - LOG(logDEBUG2, ("Creating UDP Socket %d [entry:%d]\n", index, iRxEntry)); + LOG(logDEBUG2, + ("Creating UDP Socket %d [entry:%d]\n", index, iRxEntry)); if (!strlen(udpDestinationIp[iRxEntry][index])) { - LOG(logERROR, ("No destination UDP ip specified for socket %d [entry:%d].\n", index, iRxEntry)); + LOG(logERROR, + ("No destination UDP ip specified for socket %d [entry:%d].\n", + index, iRxEntry)); return FAIL; } if (udpSockfd[iRxEntry][index] != -1) { - LOG(logERROR, ("Strange that Udp socket was still open [socket:%d, entry:%d]. Closing it to " - "create a new one.\n", index, iRxEntry)); + LOG(logERROR, ("Strange that Udp socket was still open [socket:%d, " + "entry:%d]. Closing it to " + "create a new one.\n", + index, iRxEntry)); close(udpSockfd[iRxEntry][index]); udpSockfd[iRxEntry][index] = -1; } // Creating socket file descriptor - udpSockfd[iRxEntry][index] = socket(udpServerAddrInfo[iRxEntry][index]->ai_family, - udpServerAddrInfo[iRxEntry][index]->ai_socktype, - udpServerAddrInfo[iRxEntry][index]->ai_protocol); + udpSockfd[iRxEntry][index] = + socket(udpServerAddrInfo[iRxEntry][index]->ai_family, + udpServerAddrInfo[iRxEntry][index]->ai_socktype, + udpServerAddrInfo[iRxEntry][index]->ai_protocol); if (udpSockfd[iRxEntry][index] == -1) { - LOG(logERROR, ("UDP socket at port %d failed [entry:%d]. (Error code:%d, %s)\n", - udpDestinationPort[iRxEntry][index], iRxEntry, errno, gai_strerror(errno))); + LOG(logERROR, ("UDP socket at port %d failed [entry:%d]. (Error " + "code:%d, %s)\n", + udpDestinationPort[iRxEntry][index], iRxEntry, errno, + gai_strerror(errno))); return FAIL; } - LOG(logINFO, ("Udp client socket created for server (entry:%d, port %d, ip:%s)\n", - iRxEntry, udpDestinationPort[iRxEntry][index], udpDestinationIp[iRxEntry][index])); - - // Using connect expects that the receiver (udp server) exists to listen to - // these packets connecting allows to use "send/write" instead of "sendto", - // avoiding checking for server address for each packet using write without - // a connect will end in segv - LOG(logINFO, ("Udp client socket connected [%d, %d, %s]\n", iRxEntry, udpDestinationPort[iRxEntry][index], - udpDestinationIp[iRxEntry][index])); + LOG(logINFO, ("Udp client socket created for server (entry:%d, port " + "%d, ip:%s)\n", + iRxEntry, udpDestinationPort[iRxEntry][index], + udpDestinationIp[iRxEntry][index])); + // Using connect expects that the receiver (udp server) exists to listen + // to these packets connecting allows to use "send/write" instead of + // "sendto", avoiding checking for server address for each packet using + // write without a connect will end in segv + LOG(logINFO, ("Udp client socket connected [%d, %d, %s]\n", iRxEntry, + udpDestinationPort[iRxEntry][index], + udpDestinationIp[iRxEntry][index])); } return OK; } @@ -125,9 +140,9 @@ int sendUDPPacket(int iRxEntry, int index, const char *buf, int length) { udpServerAddrInfo[iRxEntry][index]->ai_addrlen); // udp sends atomically, no need to handle partial data if (n == -1) { - LOG(logERROR, - ("Could not send udp packet for socket %d [entry:%d]. (Error code:%d, %s)\n", - index, iRxEntry, errno, gai_strerror(errno))); + LOG(logERROR, ("Could not send udp packet for socket %d [entry:%d]. " + "(Error code:%d, %s)\n", + index, iRxEntry, errno, gai_strerror(errno))); } else { LOG(logDEBUG2, ("%d bytes sent\n", n)); } diff --git a/slsDetectorSoftware/include/sls/Result.h b/slsDetectorSoftware/include/sls/Result.h index c8653b790..2578ad2ba 100644 --- a/slsDetectorSoftware/include/sls/Result.h +++ b/slsDetectorSoftware/include/sls/Result.h @@ -70,7 +70,7 @@ template > class Result { * @tparam Args template paramter pack to forward */ template - Result(Args &&... args) : vec(std::forward(args)...) {} + Result(Args &&...args) : vec(std::forward(args)...) {} using value_type = typename std::vector::value_type; using iterator = typename std::vector::iterator; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index b1f76e0dc..c96c4f2e2 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1209,10 +1209,10 @@ class CmdProxy { "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench]" "Serial number of detector."); - GET_COMMAND( - moduleid, getModuleId, - "\n\t[Gotthard2][Eiger][Mythen3] 16 bit value (ideally unique) " - "that is streamed out in the UDP header of the detector. Picked up from a file on the module."); + GET_COMMAND(moduleid, getModuleId, + "\n\t[Gotthard2][Eiger][Mythen3] 16 bit value (ideally unique) " + "that is streamed out in the UDP header of the detector. " + "Picked up from a file on the module."); GET_COMMAND(type, getDetectorType, "\n\tReturns detector type. Can be Eiger, Jungfrau, Gotthard, " @@ -1332,9 +1332,9 @@ class CmdProxy { GET_COMMAND_NOID(timinglist, getTimingModeList, "\n\tGets the list of timing modes for this detector."); - GET_COMMAND_NOID(readoutspeedlist, getReadoutSpeedList, - "\n\tList of readout speed levels implemented for this detector."); - + GET_COMMAND_NOID( + readoutspeedlist, getReadoutSpeedList, + "\n\tList of readout speed levels implemented for this detector."); GET_COMMAND(maxadcphaseshift, getMaxADCPhaseShift, "\n\t[Jungfrau][CTB][Moench] Absolute maximum Phase shift of " @@ -1357,7 +1357,8 @@ class CmdProxy { "the chip. \n\t[Moench] Default is 0. \n\t[Jungfrau] Default is 0. Get " "will return power status. Can be off if temperature event occured " "(temperature over temp_threshold with temp_control " - "enabled. Will configure chip (only chip v1.1)\n\t[Mythen3][Gotthard2] Default is 1. If module not " + "enabled. Will configure chip (only chip v1.1)\n\t[Mythen3][Gotthard2] " + "Default is 1. If module not " "connected or wrong module, powerchip will fail."); INTEGER_COMMAND_VEC_ID( @@ -1390,7 +1391,10 @@ class CmdProxy { readnrows, getReadNRows, setReadNRows, StringTo, "\n\t[1-256]\n\t\t[Eiger] Number of rows to readout per half module " "starting from the centre. Options: 0 - 256. 256 is default. The " - "permissible values depend on dynamic range and 10Gbe enabled.\n\t[8-512 (multiple of 8)]\n\t\t[Jungfrau] Number of rows per module starting from the centre. Options: 8 - 512, must be multiples of 8. Default is 512."); + "permissible values depend on dynamic range and 10Gbe " + "enabled.\n\t[8-512 (multiple of 8)]\n\t\t[Jungfrau] Number of rows " + "per module starting from the centre. Options: 8 - 512, must be " + "multiples of 8. Default is 512."); /** temperature */ GET_COMMAND_NOID( @@ -1545,10 +1549,11 @@ class CmdProxy { "[0, 1]\n\t[Jungfrau] The udp interface to stream data from detector. " "Effective only when number of interfaces is 1. Default: 0 (outer)"); - GET_COMMAND(udp_numdst, getNumberofUDPDestinations, - "\n\t[Jungfrau][Eiger] One can enter upto 32 " - "destinations that the detector will stream images " - "out in a round robin fashion. This is get only command. Default: 1"); + GET_COMMAND( + udp_numdst, getNumberofUDPDestinations, + "\n\t[Jungfrau][Eiger] One can enter upto 32 " + "destinations that the detector will stream images " + "out in a round robin fashion. This is get only command. Default: 1"); EXECUTE_SET_COMMAND(udp_cleardst, clearUDPDestinations, "\n\tClears udp destination details on the detector."); @@ -1556,7 +1561,8 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( udp_firstdst, getFirstUDPDestination, setFirstUDPDestination, StringTo, - "[0 - 31 (or number of udp destinations)]\n\t[Jungfrau] One can set which is the first " + "[0 - 31 (or number of udp destinations)]\n\t[Jungfrau] One can set " + "which is the first " "destination that the detector will stream images " "out from in a round robin fashion. The entry must not have been " "empty. Default: 0"); @@ -1864,10 +1870,9 @@ class CmdProxy { "[(optional unit) ns|us|ms|s]\n\t[Eiger] Measured sub " "frame period between last sub frame and previous one."); - - INTEGER_COMMAND_VEC_ID( - activate, getActive, setActive, StringTo, - "[0, 1] \n\t[Eiger] 1 is default. 0 deactivates readout and does not send data."); + INTEGER_COMMAND_VEC_ID(activate, getActive, setActive, StringTo, + "[0, 1] \n\t[Eiger] 1 is default. 0 deactivates " + "readout and does not send data."); INTEGER_COMMAND_VEC_ID( partialreset, getPartialReset, setPartialReset, StringTo, @@ -1920,7 +1925,8 @@ class CmdProxy { INTEGER_COMMAND_SET_NOID_GET_ID( storagecells, getNumberOfAdditionalStorageCells, setNumberOfAdditionalStorageCells, StringTo, - "[0-15]\n\t[Jungfrau] Only for chipv1.0. Number of additional storage cells. Default is " + "[0-15]\n\t[Jungfrau] Only for chipv1.0. Number of additional storage " + "cells. Default is " "0. For advanced users only. \n\tThe #images = #frames x #triggers x " "(#storagecells + 1)."); @@ -1928,13 +1934,15 @@ class CmdProxy { storagecell_start, getStorageCellStart, setStorageCellStart, StringTo, "[0-max]\n\t[Jungfrau] Storage cell that stores the first acquisition " - "of the series. max is 15 (default) for chipv1.0 and 3 (default) for chipv1.1. For advanced users only."); + "of the series. max is 15 (default) for chipv1.0 and 3 (default) for " + "chipv1.1. For advanced users only."); TIME_COMMAND( storagecell_delay, getStorageCellDelay, setStorageCellDelay, "[duration (0-1638375 ns)] [(optional unit) ns|us|ms|s]\n\t[Jungfrau] " "Additional time delay between 2 consecutive exposures in burst mode " - "(resolution of 25ns). Only applicable for chipv1.0. For advanced users only."); + "(resolution of 25ns). Only applicable for chipv1.0. For advanced " + "users only."); INTEGER_COMMAND_VEC_ID( gainmode, getGainMode, setGainMode, @@ -1943,9 +1951,10 @@ class CmdProxy { "Jungfrau] Gain mode.\n\tCAUTION: Do not use fixg0 without caution, " "you can damage the detector!!!"); - INTEGER_COMMAND_VEC_ID( - filtercell, getFilterCell, setFilterCell, sls::StringTo, - "[0-12]\n\t[Jungfrau] Set Filter Cell. Only for chipv1.1. Advanced user Command"); + INTEGER_COMMAND_VEC_ID(filtercell, getFilterCell, setFilterCell, + sls::StringTo, + "[0-12]\n\t[Jungfrau] Set Filter Cell. Only for " + "chipv1.1. Advanced user Command"); /* Gotthard Specific */ TIME_GET_COMMAND(exptimel, getExptimeLeft, diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 2c2d6a86a..5a148e3f2 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -422,23 +422,19 @@ void Detector::setReadoutSpeed(defs::speedLevel value, Positions pos) { pimpl->Parallel(&Module::setReadoutSpeed, pos, value); } - std::vector Detector::getReadoutSpeedList() const { switch (getDetectorType().squash()) { case defs::EIGER: case defs::JUNGFRAU: - return std::vector{defs::FULL_SPEED, - defs::HALF_SPEED, + return std::vector{defs::FULL_SPEED, defs::HALF_SPEED, defs::QUARTER_SPEED}; case defs::GOTTHARD2: - return std::vector{defs::G2_108MHZ, - defs::G2_144MHZ}; + return std::vector{defs::G2_108MHZ, defs::G2_144MHZ}; default: throw RuntimeError("Readout speed not implemented for this detector"); } } - Result Detector::getADCPhase(Positions pos) const { return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK, false); } @@ -670,10 +666,6 @@ void Detector::setDefaultDac(defs::dacIndex index, int defaultValue, pimpl->setDefaultDac(index, defaultValue, sett, pos); } - - - - void Detector::resetToDefaultDacs(const bool hardReset, Positions pos) { pimpl->Parallel(&Module::resetToDefaultDacs, pos, hardReset); } @@ -1439,7 +1431,6 @@ void Detector::setActive(const bool active, Positions pos) { pimpl->Parallel(&Module::setActivate, pos, active); } - Result Detector::getPartialReset(Positions pos) const { return pimpl->Parallel(&Module::getCounterBit, pos); } @@ -1554,12 +1545,9 @@ void Detector::setStorageCellDelay(ns value, Positions pos) { std::vector Detector::getGainModeList() const { switch (getDetectorType().squash()) { case defs::JUNGFRAU: - return std::vector{defs::DYNAMIC, - defs::FORCE_SWITCH_G1, - defs::FORCE_SWITCH_G2, - defs::FIX_G1, - defs::FIX_G2, - defs::FIX_G0}; + return std::vector{ + defs::DYNAMIC, defs::FORCE_SWITCH_G1, defs::FORCE_SWITCH_G2, + defs::FIX_G1, defs::FIX_G2, defs::FIX_G0}; break; default: throw RuntimeError("Gain mode is not implemented for this detector."); @@ -1706,19 +1694,22 @@ Result Detector::getVetoStream(Positions pos) const { return res; } -void Detector::setVetoStream(defs::streamingInterface interface, Positions pos) { +void Detector::setVetoStream(defs::streamingInterface interface, + Positions pos) { // 3gbe - bool LOW_LATENCY_LINK = ((interface & defs::streamingInterface::LOW_LATENCY_LINK) == - defs::streamingInterface::LOW_LATENCY_LINK); + bool LOW_LATENCY_LINK = + ((interface & defs::streamingInterface::LOW_LATENCY_LINK) == + defs::streamingInterface::LOW_LATENCY_LINK); pimpl->Parallel(&Module::setVetoStream, pos, LOW_LATENCY_LINK); // 10gbe (debugging interface) opens 2nd udp interface in receiver int old_numinterfaces = pimpl->getNumberofUDPInterfaces(pos).tsquash( "retrieved inconsistent number of udp interfaces"); - int numinterfaces = (((interface & defs::streamingInterface::ETHERNET_10GB) == - defs::streamingInterface::ETHERNET_10GB) - ? 2 - : 1); + int numinterfaces = + (((interface & defs::streamingInterface::ETHERNET_10GB) == + defs::streamingInterface::ETHERNET_10GB) + ? 2 + : 1); if (numinterfaces != old_numinterfaces) { setNumberofUDPInterfaces_(numinterfaces, pos); } diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index 2c1c011de..f9aa1a1ab 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -291,7 +291,9 @@ void DetectorImpl::updateDetectorSize() { const slsDetectorDefs::xy det_size = modules[0]->getNumberOfChannels(); if (det_size.x == 0 || det_size.y == 0) { - throw sls::RuntimeError("Module size for x or y dimensions is 0. Unable to proceed in updating detector size. "); + throw sls::RuntimeError( + "Module size for x or y dimensions is 0. Unable to proceed in " + "updating detector size. "); } int maxx = shm()->numberOfChannels.x; @@ -1094,13 +1096,13 @@ int DetectorImpl::acquire() { // start and read all try { if (detector_type == defs::MYTHEN3 && modules.size() > 1) { - //Multi module mythen + // Multi module mythen std::vector master; std::vector slaves; auto is_master = Parallel(&Module::isMaster, {}); slaves.reserve(modules.size() - 1); // check this one!! for (size_t i = 0; i < modules.size(); ++i) { - if(is_master[i]) + if (is_master[i]) master.push_back(i); else slaves.push_back(i); @@ -1108,7 +1110,7 @@ int DetectorImpl::acquire() { Parallel(&Module::startAcquisition, slaves); Parallel(&Module::startAndReadAll, master); } else { - //Normal acquire + // Normal acquire Parallel(&Module::startAndReadAll, {}); } @@ -1360,7 +1362,7 @@ std::vector DetectorImpl::readProgrammingFile(const std::string &fname) { LOG(logINFOBLUE) << "File has been converted to " << destfname; // loading dst file to memory - // FILE *fp = fopen("/tmp/SLS_DET_MCB.tzgmUT", "r"); + // FILE *fp = fopen("/tmp/SLS_DET_MCB.tzgmUT", "r"); FILE *fp = fopen(destfname, "r"); if (fp == nullptr) { throw RuntimeError("Program FPGA: Could not open rawbin file"); @@ -1384,7 +1386,7 @@ std::vector DetectorImpl::readProgrammingFile(const std::string &fname) { "Program FPGA: Could not close destination file after converting"); } - //unlink(destfname); // delete temporary file + // unlink(destfname); // delete temporary file LOG(logDEBUG1) << "Successfully loaded the rawbin file to program memory"; LOG(logDEBUG1) << "Read file into memory"; return buffer; diff --git a/slsDetectorSoftware/src/DetectorImpl.h b/slsDetectorSoftware/src/DetectorImpl.h index 08f83e757..37d57d7bf 100644 --- a/slsDetectorSoftware/src/DetectorImpl.h +++ b/slsDetectorSoftware/src/DetectorImpl.h @@ -19,7 +19,7 @@ class detectorData; #define DETECTOR_SHMAPIVERSION 0x190809 #define DETECTOR_SHMVERSION 0x201007 -#define SHORT_STRING_LENGTH 50 +#define SHORT_STRING_LENGTH 50 #include #include diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 1ed360f03..a8ee9d9c5 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -389,7 +389,7 @@ class Module : public virtual slsDetectorDefs { void setGainMode(const gainMode mode); int getFilterCell() const; void setFilterCell(int value); - + /************************************************** * * * Gotthard Specific * diff --git a/slsDetectorSoftware/src/SharedMemory.h b/slsDetectorSoftware/src/SharedMemory.h index 080aa6e8d..e50662487 100644 --- a/slsDetectorSoftware/src/SharedMemory.h +++ b/slsDetectorSoftware/src/SharedMemory.h @@ -26,7 +26,7 @@ #define SHM_DETECTOR_PREFIX "/slsDetectorPackage_detector_" #define SHM_MODULE_PREFIX "_module_" -#define SHM_ENV_NAME "SLSDETNAME" +#define SHM_ENV_NAME "SLSDETNAME" #include #include diff --git a/slsDetectorSoftware/tests/test-CmdParser.cpp b/slsDetectorSoftware/tests/test-CmdParser.cpp index 1e530d8c8..a95b7eeee 100644 --- a/slsDetectorSoftware/tests/test-CmdParser.cpp +++ b/slsDetectorSoftware/tests/test-CmdParser.cpp @@ -149,18 +149,18 @@ SCENARIO("Parsing strings with -h or --help", "[support]") { } } -TEST_CASE("Parse string with --help"){ +TEST_CASE("Parse string with --help") { CmdParser p; p.Parse("list --help"); - REQUIRE(p.isHelp()==true); - REQUIRE(p.command()=="list"); + REQUIRE(p.isHelp() == true); + REQUIRE(p.command() == "list"); } -TEST_CASE("Parse string with -h"){ +TEST_CASE("Parse string with -h") { CmdParser p; p.Parse("list -h"); - REQUIRE(p.isHelp()==true); - REQUIRE(p.command()=="list"); + REQUIRE(p.isHelp() == true); + REQUIRE(p.command() == "list"); } TEST_CASE("Parsing consecutive strings resets not found det id") { @@ -272,9 +272,7 @@ TEST_CASE("Double digit id", "[support]") { REQUIRE(p.arguments().empty()); } - - -TEST_CASE("Allows space between mod id and command"){ +TEST_CASE("Allows space between mod id and command") { CmdParser p; p.Parse("7: exptime 0.5"); REQUIRE(p.detector_id() == 7); @@ -283,7 +281,7 @@ TEST_CASE("Allows space between mod id and command"){ REQUIRE(p.arguments()[0] == "0.5"); } -TEST_CASE("Allows space between mod id and command also without :"){ +TEST_CASE("Allows space between mod id and command also without :") { CmdParser p; p.Parse("1 exptime 0.5"); REQUIRE(p.detector_id() == 1); @@ -292,7 +290,7 @@ TEST_CASE("Allows space between mod id and command also without :"){ REQUIRE(p.arguments()[0] == "0.5"); } -TEST_CASE("Allows space between mod id and command when detector id is used"){ +TEST_CASE("Allows space between mod id and command when detector id is used") { CmdParser p; p.Parse("1-5 exptime 0.5"); REQUIRE(p.detector_id() == 5); @@ -302,7 +300,7 @@ TEST_CASE("Allows space between mod id and command when detector id is used"){ REQUIRE(p.arguments()[0] == "0.5"); } -TEST_CASE("Allows space between mod id and command with detector id and :"){ +TEST_CASE("Allows space between mod id and command with detector id and :") { CmdParser p; p.Parse("1-5: exptime 0.5"); REQUIRE(p.detector_id() == 5); @@ -312,7 +310,7 @@ TEST_CASE("Allows space between mod id and command with detector id and :"){ REQUIRE(p.arguments()[0] == "0.5"); } -TEST_CASE("Parse receiver ID"){ +TEST_CASE("Parse receiver ID") { CmdParser p; p.Parse("2-5:3 flowcontrol10g 1"); REQUIRE(p.detector_id() == 5); @@ -320,84 +318,81 @@ TEST_CASE("Parse receiver ID"){ REQUIRE(p.command() == "flowcontrol10g"); REQUIRE(p.arguments().size() == 1); REQUIRE(p.arguments()[0] == "1"); - REQUIRE(p.receiver_id()==3); + REQUIRE(p.receiver_id() == 3); } -TEST_CASE("Parse receiver ID no det id"){ +TEST_CASE("Parse receiver ID no det id") { CmdParser p; p.Parse("5:95 flowcontrol10g"); REQUIRE(p.detector_id() == 5); REQUIRE(p.multi_id() == 0); REQUIRE(p.command() == "flowcontrol10g"); REQUIRE(p.arguments().size() == 0); - REQUIRE(p.receiver_id()==95); + REQUIRE(p.receiver_id() == 95); } - - -TEST_CASE("Det id but no mod id"){ +TEST_CASE("Det id but no mod id") { CmdParser p; p.Parse("1-exptime"); - REQUIRE(p.detector_id() == -1); //not there + REQUIRE(p.detector_id() == -1); // not there REQUIRE(p.multi_id() == 1); REQUIRE(p.command() == "exptime"); } -TEST_CASE("Det id but no mod id but with space after -"){ +TEST_CASE("Det id but no mod id but with space after -") { CmdParser p; p.Parse("1- exptime"); - REQUIRE(p.detector_id() == -1); //not there + REQUIRE(p.detector_id() == -1); // not there REQUIRE(p.multi_id() == 1); REQUIRE(p.command() == "exptime"); } -TEST_CASE("Parse receiver ID no det id no mod"){ +TEST_CASE("Parse receiver ID no det id no mod") { CmdParser p; p.Parse(":95 flowcontrol10g"); - REQUIRE(p.detector_id() == -1); //not there + REQUIRE(p.detector_id() == -1); // not there REQUIRE(p.multi_id() == 0); REQUIRE(p.command() == "flowcontrol10g"); REQUIRE(p.arguments().size() == 0); - REQUIRE(p.receiver_id()==95); + REQUIRE(p.receiver_id() == 95); } -TEST_CASE("Parse mod and receiver id"){ +TEST_CASE("Parse mod and receiver id") { CmdParser p; p.Parse("1:3 exptime"); - REQUIRE(p.detector_id() == 1); - REQUIRE(p.receiver_id()==3); + REQUIRE(p.detector_id() == 1); + REQUIRE(p.receiver_id() == 3); REQUIRE(p.command() == "exptime"); } -TEST_CASE("Det id but no no mod"){ +TEST_CASE("Det id but no no mod") { CmdParser p; p.Parse("2-:35 exptime"); - REQUIRE(p.detector_id() == -1); - REQUIRE(p.receiver_id()==35); + REQUIRE(p.detector_id() == -1); + REQUIRE(p.receiver_id() == 35); REQUIRE(p.multi_id() == 2); REQUIRE(p.command() == "exptime"); } -TEST_CASE("All stuff"){ +TEST_CASE("All stuff") { CmdParser p; p.Parse("3-4:2 exptime"); - REQUIRE(p.detector_id() == 4); - REQUIRE(p.receiver_id()==2); + REQUIRE(p.detector_id() == 4); + REQUIRE(p.receiver_id() == 2); REQUIRE(p.multi_id() == 3); REQUIRE(p.command() == "exptime"); } -TEST_CASE("Parse a command that has -h in it"){ +TEST_CASE("Parse a command that has -h in it") { CmdParser p; p.Parse("1-hostname somepc"); REQUIRE(p.multi_id() == 1); REQUIRE(p.command() == "hostname"); REQUIRE(p.arguments().size() == 1); - REQUIRE(p.arguments()[0]== "somepc"); - + REQUIRE(p.arguments()[0] == "somepc"); } -TEST_CASE("Parse a command in the form 0-1 command"){ +TEST_CASE("Parse a command in the form 0-1 command") { CmdParser p; p.Parse("3-5 exptime"); REQUIRE(p.multi_id() == 3); @@ -405,7 +400,7 @@ TEST_CASE("Parse a command in the form 0-1 command"){ REQUIRE(p.command() == "exptime"); } -TEST_CASE("Parse a command in the form 0-1:command"){ +TEST_CASE("Parse a command in the form 0-1:command") { CmdParser p; p.Parse("3-5:exptime"); REQUIRE(p.multi_id() == 3); diff --git a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp index bc798ecd0..bd43f1784 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp @@ -289,7 +289,8 @@ TEST_CASE("comp_disable_time", "[.cmd]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::JUNGFRAU && det.getChipVersion().squash()*10 == 11) { + if (det_type == defs::JUNGFRAU && + det.getChipVersion().squash() * 10 == 11) { auto prev_val = det.getComparatorDisableTime(); { std::ostringstream oss; @@ -321,7 +322,7 @@ TEST_CASE("storagecells", "[.cmd]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU) { // chip version 1.0 - if (det.getChipVersion().squash()*10 == 10) { + if (det.getChipVersion().squash() * 10 == 10) { auto prev_val = det.getNumberOfAdditionalStorageCells().tsquash( "inconsistent #additional storage cells to test"); { @@ -346,11 +347,11 @@ TEST_CASE("storagecells", "[.cmd]") { } REQUIRE_THROWS(proxy.Call("storagecells", {"16"}, -1, PUT)); det.setNumberOfAdditionalStorageCells(prev_val); - } + } // chip version 1.1 else { // cannot set number of addl. storage cells - REQUIRE_THROWS(proxy.Call("storagecells", {"1"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("storagecells", {"1"}, -1, PUT)); } } else { REQUIRE_THROWS(proxy.Call("storagecells", {}, -1, GET)); @@ -370,11 +371,11 @@ TEST_CASE("storagecell_start", "[.cmd]") { REQUIRE(oss.str() == "storagecell_start 1\n"); } // chip version 1.0 - if (det.getChipVersion().squash()*10 == 10) { + if (det.getChipVersion().squash() * 10 == 10) { std::ostringstream oss; proxy.Call("storagecell_start", {"15"}, -1, PUT, oss); REQUIRE(oss.str() == "storagecell_start 15\n"); - } + } // chip version 1.1 else { // max is 3 @@ -409,7 +410,7 @@ TEST_CASE("storagecell_delay", "[.cmd]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU) { // chip version 1.0 - if (det.getChipVersion().squash()*10 == 10) { + if (det.getChipVersion().squash() * 10 == 10) { auto prev_val = det.getStorageCellDelay(); { std::ostringstream oss; @@ -426,15 +427,17 @@ TEST_CASE("storagecell_delay", "[.cmd]") { proxy.Call("storagecell_delay", {"0"}, -1, PUT, oss); REQUIRE(oss.str() == "storagecell_delay 0\n"); } - REQUIRE_THROWS(proxy.Call("storagecell_delay", {"1638376ns"}, -1, PUT)); + REQUIRE_THROWS( + proxy.Call("storagecell_delay", {"1638376ns"}, -1, PUT)); for (int i = 0; i != det.size(); ++i) { det.setStorageCellDelay(prev_val[i], {i}); } - } + } // chip version 1.1 else { // cannot set storage cell delay - REQUIRE_THROWS(proxy.Call("storagecell_delay", {"1.62ms"}, -1, PUT)); + REQUIRE_THROWS( + proxy.Call("storagecell_delay", {"1.62ms"}, -1, PUT)); } } else { REQUIRE_THROWS(proxy.Call("storagecell_delay", {}, -1, GET)); diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 6d96e55a3..2278c096f 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -347,7 +347,8 @@ TEST_CASE("thresholdnotb", "[.cmd]") { std::string senergy = std::to_string(prev_energies[0]); std::ostringstream oss1, oss2; proxy.Call("thresholdnotb", {senergy, "standard"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "thresholdnotb [" + senergy + ", standard]\n"); + REQUIRE(oss1.str() == + "thresholdnotb [" + senergy + ", standard]\n"); proxy.Call("threshold", {}, -1, GET, oss2); REQUIRE(oss2.str() == "threshold " + senergy + "\n"); REQUIRE_THROWS(proxy.Call("thresholdnotb", @@ -895,12 +896,15 @@ TEST_CASE("readoutspeed", "[.cmd]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER || det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD2) { + if (det_type == defs::EIGER || det_type == defs::JUNGFRAU || + det_type == defs::GOTTHARD2) { auto prev_val = det.getReadoutSpeed(); - // full speed for jungfrau only works for new boards (chipv1.1 is with new board [hw1.0 and chipv1.0 not tested here]) - if ((det_type == defs::JUNGFRAU && det.getChipVersion().squash() * 10 == 11) || (det_type == defs::EIGER)) - { + // full speed for jungfrau only works for new boards (chipv1.1 is with + // new board [hw1.0 and chipv1.0 not tested here]) + if ((det_type == defs::JUNGFRAU && + det.getChipVersion().squash() * 10 == 11) || + (det_type == defs::EIGER)) { std::ostringstream oss1, oss2, oss3, oss4; proxy.Call("readoutspeed", {"0"}, -1, PUT, oss1); REQUIRE(oss1.str() == "readoutspeed full_speed\n"); @@ -911,7 +915,7 @@ TEST_CASE("readoutspeed", "[.cmd]") { proxy.Call("readoutspeed", {}, -1, GET, oss4); REQUIRE(oss4.str() == "readoutspeed full_speed\n"); } - + if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) { { std::ostringstream oss1, oss2, oss3, oss4; @@ -954,10 +958,11 @@ TEST_CASE("readoutspeed", "[.cmd]") { REQUIRE(oss1.str() == "readoutspeed 144\n"); proxy.Call("readoutspeed", {}, -1, GET, oss2); REQUIRE(oss2.str() == "readoutspeed 144\n"); - } + } REQUIRE_THROWS(proxy.Call("readoutspeed", {"full_speed"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("readoutspeed", {"half_speed"}, -1, PUT)); - REQUIRE_THROWS(proxy.Call("readoutspeed", {"quarter_speed"}, -1, PUT)); + REQUIRE_THROWS( + proxy.Call("readoutspeed", {"quarter_speed"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("readoutspeed", {"0"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("readoutspeed", {"1"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("readoutspeed", {"2"}, -1, PUT)); @@ -976,8 +981,8 @@ TEST_CASE("readoutspeedlist", "[.cmd]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU || det_type == defs::EIGER) - { + if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU || + det_type == defs::EIGER) { REQUIRE_NOTHROW(proxy.Call("readoutspeedlist", {}, -1, GET)); REQUIRE_THROWS(proxy.Call("readoutspeedlist", {}, -1, PUT)); } else { @@ -1795,33 +1800,30 @@ TEST_CASE("defaultdac", "[.cmd]") { std::ostringstream oss; proxy.Call("defaultdac", {dacname}, -1, GET, oss); REQUIRE(oss.str() == std::string("defaultdac ") + dacname + - std::string(" 1000\n")); + std::string(" 1000\n")); } for (int i = 0; i != det.size(); ++i) { det.setDefaultDac(it, prev_val[i], {i}); } } if (det_type == defs::JUNGFRAU) { - std::vector daclist = {defs::VREF_PRECH, defs::VREF_DS, - defs::VREF_COMP}; + std::vector daclist = { + defs::VREF_PRECH, defs::VREF_DS, defs::VREF_COMP}; for (auto it : daclist) { auto dacname = sls::ToString(it); auto prev_val = det.getDefaultDac(it, defs::GAIN0); { std::ostringstream oss; proxy.Call("defaultdac", {dacname, "1000", "gain0"}, -1, - PUT, oss); - REQUIRE(oss.str() == - std::string("defaultdac ") + dacname + - std::string(" gain0 1000\n")); + PUT, oss); + REQUIRE(oss.str() == std::string("defaultdac ") + dacname + + std::string(" gain0 1000\n")); } { std::ostringstream oss; - proxy.Call("defaultdac", {dacname, "gain0"}, -1, GET, - oss); - REQUIRE(oss.str() == - std::string("defaultdac ") + dacname + - std::string(" gain0 1000\n")); + proxy.Call("defaultdac", {dacname, "gain0"}, -1, GET, oss); + REQUIRE(oss.str() == std::string("defaultdac ") + dacname + + std::string(" gain0 1000\n")); } for (int i = 0; i != det.size(); ++i) { det.setDefaultDac(it, prev_val[i], defs::GAIN0, {i}); @@ -1829,7 +1831,7 @@ TEST_CASE("defaultdac", "[.cmd]") { } } } else { - REQUIRE_THROWS(proxy.Call("defaultdac", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("defaultdac", {}, -1, GET)); } } @@ -1927,7 +1929,8 @@ TEST_CASE("blockingtrigger", "[.cmd]") { proxy.Call("blockingtrigger", {}, -1, PUT, oss); REQUIRE(oss.str() == "blockingtrigger successful\n"); } - if (det.isVirtualDetectorServer().tsquash("inconsistent virtual detectors")) { + if (det.isVirtualDetectorServer().tsquash( + "inconsistent virtual detectors")) { std::this_thread::sleep_for(std::chrono::seconds(2)); } auto currentfnum = @@ -2286,7 +2289,6 @@ TEST_CASE("udp_numdst", "[.cmd]") { } } - TEST_CASE("udp_cleardst", "[.cmd]") { Detector det; CmdProxy proxy(&det); diff --git a/slsDetectorSoftware/tests/test-Pattern.cpp b/slsDetectorSoftware/tests/test-Pattern.cpp index 868af4b2e..6128fe0b8 100644 --- a/slsDetectorSoftware/tests/test-Pattern.cpp +++ b/slsDetectorSoftware/tests/test-Pattern.cpp @@ -5,21 +5,21 @@ using sls::Pattern; -TEST_CASE("Pattern is default constructable and has zeroed fields"){ +TEST_CASE("Pattern is default constructable and has zeroed fields") { Pattern p; - for (int i = 0; i!=MAX_PATTERN_LENGTH; ++i) + for (int i = 0; i != MAX_PATTERN_LENGTH; ++i) REQUIRE(p.data()->word[i] == 0); REQUIRE(p.data()->ioctrl == 0); } -TEST_CASE("Copy construct pattern"){ +TEST_CASE("Copy construct pattern") { Pattern p; p.data()->loop[0] = 7; Pattern p1(p); REQUIRE(p1.data()->loop[0] == 7); } -TEST_CASE("Compare patterns"){ +TEST_CASE("Compare patterns") { Pattern p; Pattern p1; REQUIRE(p == p1); @@ -27,7 +27,3 @@ TEST_CASE("Compare patterns"){ p1.data()->word[500] = 1; REQUIRE_FALSE(p == p1); } - - - - diff --git a/slsDetectorSoftware/tests/test-SharedMemory.cpp b/slsDetectorSoftware/tests/test-SharedMemory.cpp index 337929116..fb1248653 100644 --- a/slsDetectorSoftware/tests/test-SharedMemory.cpp +++ b/slsDetectorSoftware/tests/test-SharedMemory.cpp @@ -21,8 +21,8 @@ TEST_CASE("Create SharedMemory read and write", "[detector]") { SharedMemory shm(shm_id, -1); shm.CreateSharedMemory(); - CHECK(shm.GetName() == - std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id)); + CHECK(shm.GetName() == std::string("/slsDetectorPackage_detector_") + + std::to_string(shm_id)); shm()->x = 3; shm()->y = 5.7; @@ -92,8 +92,8 @@ TEST_CASE("Open two shared memories to the same place", "[detector]") { TEST_CASE("Move SharedMemory", "[detector]") { SharedMemory shm(shm_id, -1); - CHECK(shm.GetName() == - std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id)); + CHECK(shm.GetName() == std::string("/slsDetectorPackage_detector_") + + std::to_string(shm_id)); shm.CreateSharedMemory(); shm()->x = 9; @@ -106,8 +106,8 @@ TEST_CASE("Move SharedMemory", "[detector]") { CHECK(shm() == nullptr); CHECK(shm.size() == 0); - CHECK(shm2.GetName() == - std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id)); + CHECK(shm2.GetName() == std::string("/slsDetectorPackage_detector_") + + std::to_string(shm_id)); shm2.RemoveSharedMemory(); } diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index a3d489423..541c14757 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -1027,14 +1027,14 @@ int ClientInterface::set_flip_rows(Interface &socket) { throw RuntimeError("Could not set flip rows. Invalid argument: " + std::to_string(arg)); } - verifyIdle(socket); - LOG(logDEBUG1) << "Setting flip rows:" << arg; - impl()->setFlipRows(static_cast(arg)); + verifyIdle(socket); + LOG(logDEBUG1) << "Setting flip rows:" << arg; + impl()->setFlipRows(static_cast(arg)); - int retval = impl()->getFlipRows(); - validate(arg, retval, std::string("set flip rows"), DEC); - LOG(logDEBUG1) << "Flip rows:" << retval; - return socket.sendResult(retval); + int retval = impl()->getFlipRows(); + validate(arg, retval, std::string("set flip rows"), DEC); + LOG(logDEBUG1) << "Flip rows:" << retval; + return socket.sendResult(retval); } int ClientInterface::set_file_format(Interface &socket) { @@ -1372,7 +1372,8 @@ int ClientInterface::set_read_n_rows(Interface &socket) { if (arg >= 0) { verifyIdle(socket); if (detType != EIGER && detType != JUNGFRAU) { - throw RuntimeError("Could not set number of rows. Not implemented for this detector"); + throw RuntimeError("Could not set number of rows. Not implemented " + "for this detector"); } LOG(logDEBUG1) << "Setting number of rows:" << arg; impl()->setReadNRows(arg); @@ -1699,4 +1700,3 @@ int ClientInterface::set_detector_datastream(Interface &socket) { impl()->setDetectorDataStream(port, enable); return socket.Send(OK); } - diff --git a/slsReceiverSoftware/src/ClientInterface.h b/slsReceiverSoftware/src/ClientInterface.h index 549243f3b..6fd30cb98 100644 --- a/slsReceiverSoftware/src/ClientInterface.h +++ b/slsReceiverSoftware/src/ClientInterface.h @@ -164,7 +164,6 @@ class ClientInterface : private virtual slsDetectorDefs { int set_all_threshold(sls::ServerInterface &socket); int set_detector_datastream(sls::ServerInterface &socket); - Implementation *impl() { if (receiver != nullptr) { return receiver.get(); diff --git a/slsReceiverSoftware/src/DataProcessor.h b/slsReceiverSoftware/src/DataProcessor.h index ff696abb1..a76029fe7 100644 --- a/slsReceiverSoftware/src/DataProcessor.h +++ b/slsReceiverSoftware/src/DataProcessor.h @@ -28,11 +28,11 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { public: DataProcessor(int index, detectorType detectorType, Fifo *fifo, - bool *activated, bool *dataStreamEnable, uint32_t *streamingFrequency, - uint32_t *streamingTimerInMs, uint32_t *streamingStartFnum, - bool *framePadding, std::vector *ctbDbitList, - int *ctbDbitOffset, int *ctbAnalogDataBytes, - std::mutex *hdf5Lib); + bool *activated, bool *dataStreamEnable, + uint32_t *streamingFrequency, uint32_t *streamingTimerInMs, + uint32_t *streamingStartFnum, bool *framePadding, + std::vector *ctbDbitList, int *ctbDbitOffset, + int *ctbAnalogDataBytes, std::mutex *hdf5Lib); ~DataProcessor() override; @@ -61,10 +61,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { const int numUnitsPerReadout, const uint32_t udpPortNumber, const uint32_t maxFramesPerFile, - const uint64_t numImages, - const uint32_t dynamicRange, - const bool detectorDataStream - ); + const uint64_t numImages, const uint32_t dynamicRange, + const bool detectorDataStream); #ifdef HDF5C uint32_t GetFilesInAcquisition() const; void CreateVirtualFile(const std::string filePath, diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp index 10a682e67..f3699a752 100644 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ b/slsReceiverSoftware/src/DataStreamer.cpp @@ -193,8 +193,8 @@ void DataStreamer::ProcessAnImage(char *buf) { } if (!zmqSocket->SendData( buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), - (uint32_t)( - *((uint32_t *)buf)))) { // new size possibly from callback + (uint32_t)(*( + (uint32_t *)buf)))) { // new size possibly from callback LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index; } diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 80655a099..75d820c7f 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -171,10 +171,10 @@ void Implementation::setDetectorType(const detectorType d) { &actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode, &activated, &detectorDataStream[i], &silentMode)); dataProcessor.push_back(sls::make_unique( - i, detType, fifo_ptr, &activated, - &dataStreamEnable, &streamingFrequency, &streamingTimerInMs, - &streamingStartFnum, &framePadding, &ctbDbitList, - &ctbDbitOffset, &ctbAnalogDataBytes, &hdf5Lib)); + i, detType, fifo_ptr, &activated, &dataStreamEnable, + &streamingFrequency, &streamingTimerInMs, &streamingStartFnum, + &framePadding, &ctbDbitList, &ctbDbitOffset, + &ctbAnalogDataBytes, &hdf5Lib)); } catch (...) { listener.clear(); dataProcessor.clear(); @@ -621,10 +621,10 @@ void Implementation::stopReceiver() { } if (!detectorDataStream[0]) { LOG(logINFORED) << "Deactivated Left Port"; - } - if (!detectorDataStream[1]) { + } + if (!detectorDataStream[1]) { LOG(logINFORED) << "Deactivated Right Port"; - } + } // callback if (acquisitionFinishedCallBack) { try { @@ -810,8 +810,8 @@ void Implementation::SetupWriter() { dataProcessor[i]->CreateFirstFiles( masterAttributes.get(), filePath, fileName, fileIndex, overwriteEnable, silentMode, modulePos, numThreads, - udpPortNum[i], framesPerFile, numberOfTotalFrames, - dynamicRange, detectorDataStream[i]); + udpPortNum[i], framesPerFile, numberOfTotalFrames, dynamicRange, + detectorDataStream[i]); } } catch (const sls::RuntimeError &e) { shutDownUDPSockets(); @@ -882,12 +882,13 @@ void Implementation::setNumberofUDPInterfaces(const int n) { i, detType, fifo_ptr, &status, &udpPortNum[i], ð[i], &numberOfTotalFrames, &udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile, - &frameDiscardMode, &activated, &detectorDataStream[i], &silentMode)); + &frameDiscardMode, &activated, &detectorDataStream[i], + &silentMode)); listener[i]->SetGeneralData(generalData); dataProcessor.push_back(sls::make_unique( - i, detType, fifo_ptr, &activated, - &dataStreamEnable, &streamingFrequency, &streamingTimerInMs, + i, detType, fifo_ptr, &activated, &dataStreamEnable, + &streamingFrequency, &streamingTimerInMs, &streamingStartFnum, &framePadding, &ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes, &hdf5Lib)); dataProcessor[i]->SetGeneralData(generalData); diff --git a/slsReceiverSoftware/src/Implementation.h b/slsReceiverSoftware/src/Implementation.h index f97f92c92..5e5baf863 100644 --- a/slsReceiverSoftware/src/Implementation.h +++ b/slsReceiverSoftware/src/Implementation.h @@ -214,8 +214,10 @@ class Implementation : private virtual slsDetectorDefs { * padding is enabled (as it will receive nothing from detector) */ void setActivate(const bool enable); bool getDetectorDataStream(const portPosition port) const; - /** [Eiger] If datastream is disabled, receiver will create dummy data if deactivated - * padding for that port is enabled (as it will receive nothing from detector) */ + /** [Eiger] If datastream is disabled, receiver will create dummy data if + * deactivated + * padding for that port is enabled (as it will receive nothing from + * detector) */ void setDetectorDataStream(const portPosition port, const bool enable); int getReadNRows() const; /* [Eiger][Jungfrau] */ diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index 675a91553..2e744bd8a 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -24,7 +24,7 @@ const std::string Listener::TypeName = "Listener"; Listener::Listener(int ind, detectorType dtype, Fifo *f, std::atomic *s, uint32_t *portno, std::string *e, uint64_t *nf, int *us, int *as, uint32_t *fpf, - frameDiscardPolicy *fdp, bool *act, bool* detds, bool *sm) + frameDiscardPolicy *fdp, bool *act, bool *detds, bool *sm) : ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype), status(s), udpPortNumber(portno), eth(e), numImages(nf), udpSocketBufferSize(us), actualUDPSocketBufferSize(as), framesPerFile(fpf), frameDiscardMode(fdp), @@ -203,7 +203,8 @@ void Listener::ThreadExecution() { << std::hex << (void *)(buffer) << std::dec << ":" << buffer; // udpsocket doesnt exist - if (*activated && *detectorDataStream && !udpSocketAlive && !carryOverFlag) { + if (*activated && *detectorDataStream && !udpSocketAlive && + !carryOverFlag) { // LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not // created or shut down earlier"; (*((uint32_t *)buffer)) = 0; @@ -212,7 +213,8 @@ void Listener::ThreadExecution() { } // get data - if ((*status != TRANSMITTING && (!(*activated) || !(*detectorDataStream) || udpSocketAlive)) || + if ((*status != TRANSMITTING && + (!(*activated) || !(*detectorDataStream) || udpSocketAlive)) || carryOverFlag) { rc = ListenToAnImage(buffer); } diff --git a/slsReceiverSoftware/src/Listener.h b/slsReceiverSoftware/src/Listener.h index d588fb747..7afafcf91 100644 --- a/slsReceiverSoftware/src/Listener.h +++ b/slsReceiverSoftware/src/Listener.h @@ -44,7 +44,8 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { */ Listener(int ind, detectorType dtype, Fifo *f, std::atomic *s, uint32_t *portno, std::string *e, uint64_t *nf, int *us, int *as, - uint32_t *fpf, frameDiscardPolicy *fdp, bool *act, bool* detds, bool *sm); + uint32_t *fpf, frameDiscardPolicy *fdp, bool *act, bool *detds, + bool *sm); /** * Destructor @@ -189,7 +190,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { bool *activated; /** detector data stream */ - bool* detectorDataStream; + bool *detectorDataStream; /** Silent Mode */ bool *silentMode; diff --git a/slsReceiverSoftware/src/MasterAttributes.h b/slsReceiverSoftware/src/MasterAttributes.h index 606112a48..992a73381 100644 --- a/slsReceiverSoftware/src/MasterAttributes.h +++ b/slsReceiverSoftware/src/MasterAttributes.h @@ -436,7 +436,7 @@ class EigerMasterAttributes : public MasterAttributes { DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); StrType strdatatype(PredType::C_S1, 256); Attribute attribute = - dataset.createAttribute("Unit", strdatatype, dataspaceAttr); + dataset.createAttribute("Unit", strdatatype, dataspaceAttr); sls::strcpy_safe(c, "eV"); attribute.write(strdatatype, c); } @@ -454,7 +454,7 @@ class EigerMasterAttributes : public MasterAttributes { DataSpace dataspace = DataSpace(H5S_SCALAR); StrType strdatatype(PredType::C_S1, 256); DataSet dataset = - group->createDataSet("Sub Period", strdatatype, dataspace); + group->createDataSet("Sub Period", strdatatype, dataspace); sls::strcpy_safe(c, sls::ToString(subPeriod)); dataset.write(c, strdatatype); } @@ -462,7 +462,7 @@ class EigerMasterAttributes : public MasterAttributes { { DataSpace dataspace = DataSpace(H5S_SCALAR); DataSet dataset = - group->createDataSet("Quad", PredType::NATIVE_INT, dataspace); + group->createDataSet("Quad", PredType::NATIVE_INT, dataspace); dataset.write(&quad, PredType::NATIVE_INT); } // readNRows diff --git a/slsReceiverSoftware/src/receiver_defs.h b/slsReceiverSoftware/src/receiver_defs.h old mode 100755 new mode 100644 index de9f4f1d7..7e1982d62 --- a/slsReceiverSoftware/src/receiver_defs.h +++ b/slsReceiverSoftware/src/receiver_defs.h @@ -44,7 +44,7 @@ #define MAX_CHUNKED_IMAGES (1) // parameters to calculate fifo depth -#define SAMPLE_TIME_IN_NS (100000000) // 100ms +#define SAMPLE_TIME_IN_NS (100000000) // 100ms // to differentiate between gotthard and short gotthard #define GOTTHARD_PACKET_SIZE (1286) diff --git a/slsSupportLib/include/sls/DataSocket.h b/slsSupportLib/include/sls/DataSocket.h index f7f0bfe04..01215c20e 100644 --- a/slsSupportLib/include/sls/DataSocket.h +++ b/slsSupportLib/include/sls/DataSocket.h @@ -53,7 +53,7 @@ class DataSocket { int Send(const std::string &s); // Variadic template to send all arguments - template int SendAll(Args &&... args) { + template int SendAll(Args &&...args) { auto l = std::initializer_list{Send(args)...}; auto sum = std::accumulate(begin(l), end(l), 0); return sum; @@ -86,7 +86,7 @@ class DataSocket { private: int sockfd_ = -1; - int fnum_ {0}; + int fnum_{0}; }; }; // namespace sls diff --git a/slsSupportLib/include/sls/container_utils.h b/slsSupportLib/include/sls/container_utils.h index c9cab4ba2..08fa534d6 100644 --- a/slsSupportLib/include/sls/container_utils.h +++ b/slsSupportLib/include/sls/container_utils.h @@ -19,7 +19,7 @@ namespace sls { // already available as std::make_unique in C++14 template typename std::enable_if::value, std::unique_ptr>::type -make_unique(Args &&... args) { +make_unique(Args &&...args) { return std::unique_ptr(new T(std::forward(args)...)); } diff --git a/slsSupportLib/include/sls/md5.h b/slsSupportLib/include/sls/md5.h index 0d79c0d55..a4f0c8364 100644 --- a/slsSupportLib/include/sls/md5.h +++ b/slsSupportLib/include/sls/md5.h @@ -13,36 +13,34 @@ * Removed most of the code that is not relevant for our scope. * Snippets copied from md5_local.h or md32_common.h has been marked */ - #ifndef HEADER_MD5_H -# define HEADER_MD5_H +#define HEADER_MD5_H -# include +#include - -# ifdef __cplusplus +#ifdef __cplusplus /* * Modifications 2021 Paul Scherrer Institut * namespace sls added */ namespace sls { extern "C" { -# endif +#endif /* * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * ! MD5_LONG has to be at least 32 bits wide. ! * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -# define MD5_LONG unsigned int -# define MD5_CBLOCK 64 -# define MD5_LBLOCK (MD5_CBLOCK/4) -# define MD5_DIGEST_LENGTH 16 +#define MD5_LONG unsigned int +#define MD5_CBLOCK 64 +#define MD5_LBLOCK (MD5_CBLOCK / 4) +#define MD5_DIGEST_LENGTH 16 -/** - * Modification 2021 Paul Scherrer Institut - * Comment from md32_common.h +/** + * Modification 2021 Paul Scherrer Institut + * Comment from md32_common.h */ /*- * This is a generic 32 bit "collector" for message digest algorithms. @@ -99,65 +97,68 @@ extern "C" { * #define HASH_FINAL MD5_Final_SLS * #define HASH_BLOCK_DATA_ORDER md5_block_data_order */ -# define MD32_REG_T int +#define MD32_REG_T int -/** - * Modification 2021 Paul Scherrer Institut - * Made default little endian if big endian not defined +/** + * Modification 2021 Paul Scherrer Institut + * Made default little endian if big endian not defined */ #ifndef DATA_ORDER_IS_BIG_ENDIAN #define DATA_ORDER_IS_LITTLE_ENDIAN #endif -/** - * Modification 2021 Paul Scherrer Institut +/** + * Modification 2021 Paul Scherrer Institut * Macros exported from md32_common.h */ -#define HASH_LONG MD5_LONG -#define HASH_CTX MD5_CTX -#define HASH_CBLOCK MD5_CBLOCK -#define HASH_UPDATE MD5_Update_SLS -#define HASH_TRANSFORM MD5_Transform -#define HASH_FINAL MD5_Final_SLS -#define HASH_BLOCK_DATA_ORDER md5_block_data_order -#define HASH_MAKE_STRING(c,s) do { \ - unsigned long ll; \ - ll=(c)->A; (void)HOST_l2c(ll,(s)); \ - ll=(c)->B; (void)HOST_l2c(ll,(s)); \ - ll=(c)->C; (void)HOST_l2c(ll,(s)); \ - ll=(c)->D; (void)HOST_l2c(ll,(s)); \ - } while (0) -#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n)))) +#define HASH_LONG MD5_LONG +#define HASH_CTX MD5_CTX +#define HASH_CBLOCK MD5_CBLOCK +#define HASH_UPDATE MD5_Update_SLS +#define HASH_TRANSFORM MD5_Transform +#define HASH_FINAL MD5_Final_SLS +#define HASH_BLOCK_DATA_ORDER md5_block_data_order +#define HASH_MAKE_STRING(c, s) \ + do { \ + unsigned long ll; \ + ll = (c)->A; \ + (void)HOST_l2c(ll, (s)); \ + ll = (c)->B; \ + (void)HOST_l2c(ll, (s)); \ + ll = (c)->C; \ + (void)HOST_l2c(ll, (s)); \ + ll = (c)->D; \ + (void)HOST_l2c(ll, (s)); \ + } while (0) +#define ROTATE(a, n) (((a) << (n)) | (((a)&0xffffffff) >> (32 - (n)))) #if defined(DATA_ORDER_IS_BIG_ENDIAN) -# define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++)))<<24), \ - l|=(((unsigned long)(*((c)++)))<<16), \ - l|=(((unsigned long)(*((c)++)))<< 8), \ - l|=(((unsigned long)(*((c)++))) ) ) -# define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff), \ - l) +#define HOST_c2l(c, l) \ + (l = (((unsigned long)(*((c)++))) << 24), \ + l |= (((unsigned long)(*((c)++))) << 16), \ + l |= (((unsigned long)(*((c)++))) << 8), \ + l |= (((unsigned long)(*((c)++))))) +#define HOST_l2c(l, c) \ + (*((c)++) = (unsigned char)(((l) >> 24) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 16) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 8) & 0xff), \ + *((c)++) = (unsigned char)(((l)) & 0xff), l) #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) -# define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \ - l|=(((unsigned long)(*((c)++)))<< 8), \ - l|=(((unsigned long)(*((c)++)))<<16), \ - l|=(((unsigned long)(*((c)++)))<<24) ) -# define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24)&0xff), \ - l) +#define HOST_c2l(c, l) \ + (l = (((unsigned long)(*((c)++)))), \ + l |= (((unsigned long)(*((c)++))) << 8), \ + l |= (((unsigned long)(*((c)++))) << 16), \ + l |= (((unsigned long)(*((c)++))) << 24)) +#define HOST_l2c(l, c) \ + (*((c)++) = (unsigned char)(((l)) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 8) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 16) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 24) & 0xff), l) #endif - - - - typedef struct MD5state_st { MD5_LONG A, B, C, D; MD5_LONG Nl, Nh; @@ -169,15 +170,14 @@ int MD5_Init_SLS(MD5_CTX *c); int MD5_Update_SLS(MD5_CTX *c, const void *data, size_t len); int MD5_Final_SLS(unsigned char *md, MD5_CTX *c); -/** - * Modification 2021 Paul Scherrer Institut - * from md32_common.h +/** + * Modification 2021 Paul Scherrer Institut + * from md32_common.h */ void md5_block_data_order(MD5_CTX *c, const void *p, size_t num); -# ifdef __cplusplus +#ifdef __cplusplus } } // namespace sls -# endif -# endif - +#endif +#endif diff --git a/slsSupportLib/include/sls/network_utils.h b/slsSupportLib/include/sls/network_utils.h index 9725d95aa..aeaed5aa9 100644 --- a/slsSupportLib/include/sls/network_utils.h +++ b/slsSupportLib/include/sls/network_utils.h @@ -73,7 +73,7 @@ struct UdpDestination { constexpr bool operator==(const UdpDestination &other) const { return ((entry == other.entry) && (port == other.port) && - (port2 == other.port2) && (ip== other.ip) && + (port2 == other.port2) && (ip == other.ip) && (ip2 == other.ip2) && (mac == other.mac) && (mac2 == other.mac2)); } diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index a1aa8b803..0f65441b7 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -34,10 +34,10 @@ #define MAX_RX_DBIT 64 /** default ports */ -#define DEFAULT_PORTNO 1952 -#define DEFAULT_UDP_PORTNO 50001 -#define DEFAULT_ZMQ_CL_PORTNO 30001 -#define DEFAULT_ZMQ_RX_PORTNO 30001 +#define DEFAULT_PORTNO 1952 +#define DEFAULT_UDP_PORTNO 50001 +#define DEFAULT_ZMQ_CL_PORTNO 30001 +#define DEFAULT_ZMQ_RX_PORTNO 30001 #define DEFAULT_UDP_SRC_PORTNO 32410 #define DEFAULT_UDP_DST_PORTNO 50001 @@ -379,7 +379,13 @@ typedef struct { enum readoutMode { ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL }; /** chip speed */ - enum speedLevel { FULL_SPEED, HALF_SPEED, QUARTER_SPEED, G2_108MHZ, G2_144MHZ }; + enum speedLevel { + FULL_SPEED, + HALF_SPEED, + QUARTER_SPEED, + G2_108MHZ, + G2_144MHZ + }; /** * burst mode for gotthard2 @@ -412,7 +418,7 @@ typedef struct { #ifdef __cplusplus enum class streamingInterface { #else - enum streamingInterface { +enum streamingInterface { #endif NONE = 0, LOW_LATENCY_LINK = 1 << 0, @@ -470,8 +476,7 @@ typedef struct { uint64_t select; /** [Gotthard2][Jungfrau] disable */ - currentSrcParameters() - : enable(0), fix(-1), normal(-1), select(0) {} + currentSrcParameters() : enable(0), fix(-1), normal(-1), select(0) {} /** [Gotthard2] enable or disable */ explicit currentSrcParameters(bool srcEnable) @@ -487,7 +492,8 @@ typedef struct { /** [Jungfrau](chipv1.1) enable current src, fix[fix|no fix], * select is a mask of 63 bits (muliple columns can be selected * simultaneously, normal [normal|low] */ - currentSrcParameters(bool fixCurrent, uint64_t selectCurrent, bool normalCurrent) + currentSrcParameters(bool fixCurrent, uint64_t selectCurrent, + bool normalCurrent) : enable(1), fix(static_cast(fixCurrent)), normal(static_cast(normalCurrent)), select(selectCurrent) {} @@ -562,14 +568,14 @@ inline slsDetectorDefs::streamingInterface operator|(const slsDetectorDefs::streamingInterface &a, const slsDetectorDefs::streamingInterface &b) { return slsDetectorDefs::streamingInterface(static_cast(a) | - static_cast(b)); + static_cast(b)); }; inline slsDetectorDefs::streamingInterface operator&(const slsDetectorDefs::streamingInterface &a, const slsDetectorDefs::streamingInterface &b) { return slsDetectorDefs::streamingInterface(static_cast(a) & - static_cast(b)); + static_cast(b)); }; #endif @@ -647,7 +653,7 @@ struct detParameters { #ifdef __cplusplus struct sls_detector_module { #else - typedef struct { +typedef struct { #endif int serialnumber; /**< is the module serial number */ int nchan; /**< is the number of channels on the module*/ @@ -718,4 +724,3 @@ using Positions = const std::vector &; using defs = slsDetectorDefs; } // namespace sls #endif - diff --git a/slsSupportLib/include/sls/string_utils.h b/slsSupportLib/include/sls/string_utils.h index 4bba4a4c0..762a8a3b5 100644 --- a/slsSupportLib/include/sls/string_utils.h +++ b/slsSupportLib/include/sls/string_utils.h @@ -56,6 +56,7 @@ std::string RemoveUnit(std::string &str); bool is_int(const std::string &s); -bool replace_first(std::string *s, const std::string& substr, const std::string& repl); +bool replace_first(std::string *s, const std::string &substr, + const std::string &repl); } // namespace sls diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 3c6eed92a..d19db88bc 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -1,15 +1,15 @@ // SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package /** API versions */ -#define GITBRANCH "6.0.0-rc1" +#define GITBRANCH "6.0.0-rc1" -#define APILIB 0x211008 -#define APIRECEIVER 0x211007 -#define APIGUI 0x210819 -#define APICTB 0x211019 -#define APIGOTTHARD 0x211019 +#define APILIB 0x211008 +#define APIRECEIVER 0x211007 +#define APIGUI 0x210819 +#define APICTB 0x211019 +#define APIGOTTHARD 0x211019 #define APIGOTTHARD2 0x211019 -#define APIMYTHEN3 0x211019 -#define APIMOENCH 0x211019 -#define APIEIGER 0x211019 -#define APIJUNGFRAU 0x211019 +#define APIMYTHEN3 0x211019 +#define APIMOENCH 0x211019 +#define APIEIGER 0x211019 +#define APIJUNGFRAU 0x211019 diff --git a/slsSupportLib/src/DataSocket.cpp b/slsSupportLib/src/DataSocket.cpp index 0d1b79921..02f1c3cdb 100644 --- a/slsSupportLib/src/DataSocket.cpp +++ b/slsSupportLib/src/DataSocket.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2021 Contributors to the SLS Detector Package #include "sls/DataSocket.h" #include "sls/logger.h" -#include "sls/sls_detector_funcs.h" #include "sls/sls_detector_exceptions.h" +#include "sls/sls_detector_funcs.h" #include #include #include @@ -44,9 +44,7 @@ DataSocket &DataSocket::operator=(DataSocket &&move) noexcept { return *this; } -void DataSocket::setFnum(const int fnum) { - fnum_ = fnum; -} +void DataSocket::setFnum(const int fnum) { fnum_ = fnum; } int DataSocket::Receive(void *buffer, size_t size) { // TODO!(Erik) Add sleep? how many reties? @@ -65,7 +63,8 @@ int DataSocket::Receive(void *buffer, size_t size) { } else { std::ostringstream ss; ss << "TCP socket read " << bytes_read << " bytes instead of " - << bytes_expected << " bytes (" << getFunctionNameFromEnum(static_cast(fnum_)) << ')'; + << bytes_expected << " bytes (" + << getFunctionNameFromEnum(static_cast(fnum_)) << ')'; throw sls::SocketError(ss.str()); } } @@ -90,7 +89,8 @@ int DataSocket::Send(const void *buffer, size_t size) { if (bytes_sent != data_size) { std::ostringstream ss; ss << "TCP socket sent " << bytes_sent << " bytes instead of " - << data_size << " bytes (" << getFunctionNameFromEnum(static_cast(fnum_)) << ')'; + << data_size << " bytes (" + << getFunctionNameFromEnum(static_cast(fnum_)) << ')'; throw sls::SocketError(ss.str()); } return bytes_sent; diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index de920cc05..bbeea09d5 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -252,7 +252,7 @@ std::string ToString(const defs::speedLevel s) { case defs::G2_108MHZ: return std::string("108"); case defs::G2_144MHZ: - return std::string("144"); + return std::string("144"); default: return std::string("Unknown"); } diff --git a/slsSupportLib/src/string_utils.cpp b/slsSupportLib/src/string_utils.cpp old mode 100755 new mode 100644 index ba672643e..a86003251 --- a/slsSupportLib/src/string_utils.cpp +++ b/slsSupportLib/src/string_utils.cpp @@ -38,14 +38,14 @@ bool is_int(const std::string &s) { }) == s.end(); } -bool replace_first(std::string *s, const std::string& substr, const std::string& repl){ +bool replace_first(std::string *s, const std::string &substr, + const std::string &repl) { auto pos = s->find(substr); - if (pos != std::string::npos){ + if (pos != std::string::npos) { s->replace(pos, substr.size(), repl); return true; } return false; } - }; // namespace sls \ No newline at end of file diff --git a/slsSupportLib/tests/test-Sockets.cpp b/slsSupportLib/tests/test-Sockets.cpp index 410bb2b69..f8d7e80c5 100644 --- a/slsSupportLib/tests/test-Sockets.cpp +++ b/slsSupportLib/tests/test-Sockets.cpp @@ -4,7 +4,6 @@ #include "sls/ClientSocket.h" #include "sls/ServerSocket.h" #include -#include #include #include #include diff --git a/slsSupportLib/tests/test-ToString.cpp b/slsSupportLib/tests/test-ToString.cpp index 6ccad119b..cfc7e70d6 100644 --- a/slsSupportLib/tests/test-ToString.cpp +++ b/slsSupportLib/tests/test-ToString.cpp @@ -331,12 +331,12 @@ TEST_CASE("streamingInterface") { REQUIRE(ToString(sls::defs::streamingInterface::ETHERNET_10GB) == "10gbe"); REQUIRE(ToString(sls::defs::streamingInterface::LOW_LATENCY_LINK) == "lll"); REQUIRE(ToString(sls::defs::streamingInterface::LOW_LATENCY_LINK | - sls::defs::streamingInterface::ETHERNET_10GB) == "lll, 10gbe"); + sls::defs::streamingInterface::ETHERNET_10GB) == + "lll, 10gbe"); } - -//Speed level -TEST_CASE("speedLevel to string"){ +// Speed level +TEST_CASE("speedLevel to string") { REQUIRE(ToString(sls::defs::speedLevel::FULL_SPEED) == "full_speed"); REQUIRE(ToString(sls::defs::speedLevel::HALF_SPEED) == "half_speed"); REQUIRE(ToString(sls::defs::speedLevel::QUARTER_SPEED) == "quarter_speed"); @@ -344,10 +344,15 @@ TEST_CASE("speedLevel to string"){ REQUIRE(ToString(sls::defs::speedLevel::G2_144MHZ) == "144"); } -TEST_CASE("string to speedLevel"){ - REQUIRE(StringTo("full_speed") == sls::defs::speedLevel::FULL_SPEED); - REQUIRE(StringTo("half_speed") == sls::defs::speedLevel::HALF_SPEED); - REQUIRE(StringTo("quarter_speed") == sls::defs::speedLevel::QUARTER_SPEED); - REQUIRE(StringTo("108") == sls::defs::speedLevel::G2_108MHZ); - REQUIRE(StringTo("144") == sls::defs::speedLevel::G2_144MHZ); +TEST_CASE("string to speedLevel") { + REQUIRE(StringTo("full_speed") == + sls::defs::speedLevel::FULL_SPEED); + REQUIRE(StringTo("half_speed") == + sls::defs::speedLevel::HALF_SPEED); + REQUIRE(StringTo("quarter_speed") == + sls::defs::speedLevel::QUARTER_SPEED); + REQUIRE(StringTo("108") == + sls::defs::speedLevel::G2_108MHZ); + REQUIRE(StringTo("144") == + sls::defs::speedLevel::G2_144MHZ); } \ No newline at end of file diff --git a/slsSupportLib/tests/test-network_utils.cpp b/slsSupportLib/tests/test-network_utils.cpp index 7751ad96b..0035a6cca 100644 --- a/slsSupportLib/tests/test-network_utils.cpp +++ b/slsSupportLib/tests/test-network_utils.cpp @@ -114,19 +114,16 @@ TEST_CASE("Copy construct a MacAddr") { CHECK(addr == addr2); } - -TEST_CASE("udp dst struct basic properties"){ +TEST_CASE("udp dst struct basic properties") { static_assert(sizeof(UdpDestination) == 36); UdpDestination dst{}; - REQUIRE(dst.entry == 0); - REQUIRE(dst.port == 0); - REQUIRE(dst.port2 == 0); - REQUIRE(dst.ip == 0); - REQUIRE(dst.ip2 == 0); - REQUIRE(dst.mac == 0); - REQUIRE(dst.mac2 == 0); - + REQUIRE(dst.entry == 0); + REQUIRE(dst.port == 0); + REQUIRE(dst.port2 == 0); + REQUIRE(dst.ip == 0); + REQUIRE(dst.ip2 == 0); + REQUIRE(dst.mac == 0); + REQUIRE(dst.mac2 == 0); } - // TODO!(Erik) Look up a real hostname and verify the IP diff --git a/slsSupportLib/tests/test-string_utils.cpp b/slsSupportLib/tests/test-string_utils.cpp index 9e8221580..860f155bd 100644 --- a/slsSupportLib/tests/test-string_utils.cpp +++ b/slsSupportLib/tests/test-string_utils.cpp @@ -78,29 +78,28 @@ TEST_CASE("Check is string is integer") { REQUIRE_FALSE(sls::is_int("")); } - -TEST_CASE("Replace substring in string"){ +TEST_CASE("Replace substring in string") { std::string s = "this string should be replaced"; auto r = sls::replace_first(&s, "string ", ""); REQUIRE(r == true); REQUIRE(s == "this should be replaced"); } -TEST_CASE("Replace --help in command"){ +TEST_CASE("Replace --help in command") { std::string s = "sls_detector_get --help exptime"; auto r = sls::replace_first(&s, " --help", ""); REQUIRE(r == true); REQUIRE(s == "sls_detector_get exptime"); } -TEST_CASE("Replace -h in command"){ +TEST_CASE("Replace -h in command") { std::string s = "sls_detector_get -h exptime"; auto r = sls::replace_first(&s, " -h", ""); REQUIRE(r == true); REQUIRE(s == "sls_detector_get exptime"); } -TEST_CASE("replace --help"){ +TEST_CASE("replace --help") { std::string s = "list --help"; auto r = sls::replace_first(&s, " --help", ""); REQUIRE(r == true);