mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-14 13:57:13 +02:00
Compare commits
62 Commits
2022.2.3.d
...
2022.2.23.
Author | SHA1 | Date | |
---|---|---|---|
939fc70284 | |||
2034362eca | |||
7245db5cc8 | |||
8c4a4b7182 | |||
11ad019d47 | |||
e29d73251e | |||
c14fb92c16 | |||
8f632db2a0 | |||
bf1df92303 | |||
5e97bcde7f | |||
6d794cdf4b | |||
29cd944c11 | |||
e5ec218e5f | |||
0ac20a3bc8 | |||
c38f292613 | |||
faa9ecf97c | |||
6e32679def | |||
649451f824 | |||
83a65f85ab | |||
fa929b138e | |||
7eb9cb1840 | |||
7e5e9faf1c | |||
9a9a8ae836 | |||
e8ededc1d1 | |||
dc1fbb8ce4 | |||
2cf539c16e | |||
bcca99e38c | |||
abfa627246 | |||
f9a88b0f79 | |||
75f98b27a3 | |||
c9fbd7afdf | |||
83e0599a37 | |||
b8de1955e3 | |||
ac5d60155d | |||
7535decd7f | |||
8f2bacfd53 | |||
771b1e7877 | |||
e8cf366616 | |||
3350e3997e | |||
dae77a50e6 | |||
bb5782eb92 | |||
26faaa307b | |||
bc4cf95d0e | |||
97417737b6 | |||
47c6954044 | |||
7af5d991d9 | |||
cace18e535 | |||
1a1533cad8 | |||
59085f7dc3 | |||
8f30394f63 | |||
f49e45ca6c | |||
ef1e41fc12 | |||
d0f761b2ad | |||
5825428779 | |||
0ed7d1e9b1 | |||
9168bc3ec9 | |||
158719e325 | |||
2a63548f40 | |||
bf83c9b3e2 | |||
c236cbf17b | |||
ca8a1c046a | |||
a4cd4fd14a |
17
RELEASE.txt
17
RELEASE.txt
@ -1,7 +1,7 @@
|
||||
SLS Detector Package Minor Release 6.1.0 released on 25.11.2021
|
||||
SLS Detector Package Minor Release 7.0.0 released on 25.11.2021
|
||||
===============================================================
|
||||
|
||||
This document describes the differences between v6.1.0 and v6.0.0.
|
||||
This document describes the differences between v7.0.0 and v6.x.x
|
||||
|
||||
|
||||
|
||||
@ -28,9 +28,20 @@ This document describes the differences between v6.1.0 and v6.0.0.
|
||||
- changed default vref of adc9257 to 2V for moench (from 1.33V)
|
||||
- moench and ctb - can set the starting frame number of next acquisition
|
||||
- mythen server kernel check incompatible (cet timezone)
|
||||
- rx_arping
|
||||
- rx_threadsids max is now 9 (breaking api)
|
||||
- fixed datastream disabling for eiger. Its only available in 10g mode.
|
||||
- m3 server crash (vthrehsold)
|
||||
- allow vtrim to be interpolated for Eiger settings
|
||||
|
||||
- m3 setThresholdEnergy and setAllThresholdEnergy was overwriting gaincaps with settings enum
|
||||
- can set localhost with virtual server with minimum configuration: (hostname localhost, rx_hostname localhost, udp_dstip auto)
|
||||
- increases the progress according to listened index. (not processed index)
|
||||
- current frame index points to listened frame index (not processed index)
|
||||
- when in discard partial frames or empty mode, the frame number doesnt increase by 1, it increases to that number (so its faster)
|
||||
- file write disabled by default
|
||||
- start non blocking acquisition at modular level
|
||||
- hostname cmd failed when connecting to servers in update mode (ctb, moench, jungfrau, eiger)
|
||||
- missingpackets signed (negative => extra packets)
|
||||
|
||||
|
||||
2. Resolved Issues
|
||||
|
@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
#Copy the Moench executables
|
||||
mkdir -p $PREFIX/bin
|
||||
cp build/install/bin/moench04ZmqProcess $PREFIX/bin/.
|
||||
cp build/install/bin/moenchZmqProcess $PREFIX/bin/.
|
||||
cp build/install/bin/moench* $PREFIX/bin/.
|
||||
|
@ -34,7 +34,7 @@ add_executable(ctbGui
|
||||
ctbAdcs.cpp
|
||||
ctbPattern.cpp
|
||||
ctbAcquisition.cpp
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffIO.cpp
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffio/src/tiffIO.cpp
|
||||
)
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ target_include_directories(ctbGui PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/dataStructures
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/interpolations
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffio/include/
|
||||
)
|
||||
|
||||
# Headders needed for ROOT dictionary generation
|
||||
|
@ -258,7 +258,7 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def rx_threads(self):
|
||||
"""
|
||||
Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1].
|
||||
Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1, arping].
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -268,6 +268,17 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
return self.getRxThreadIds()
|
||||
|
||||
@property
|
||||
@element
|
||||
def rx_arping(self):
|
||||
"""Starts a thread in slsReceiver to arping the interface it is listening every minute. Useful in 10G mode. """
|
||||
return self.getRxArping()
|
||||
|
||||
@rx_arping.setter
|
||||
def rx_arping(self, value):
|
||||
ut.set_using_dict(self.setRxArping, value)
|
||||
|
||||
|
||||
@property
|
||||
@element
|
||||
def dr(self):
|
||||
@ -1900,7 +1911,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def rx_missingpackets(self):
|
||||
"""Gets the number of missing packets for each port in receiver."""
|
||||
"""Gets the number of missing packets for each port in receiver. Negative number denotes extra packets. """
|
||||
return self.getNumMissingPackets()
|
||||
|
||||
"""
|
||||
@ -1913,7 +1924,7 @@ class Detector(CppDetectorApi):
|
||||
def datastream(self):
|
||||
"""
|
||||
datastream [left|right] [0, 1]
|
||||
[Eiger] Enables or disables data streaming from left or/and right side of detector. 1 (enabled) by default.
|
||||
[Eiger] Enables or disables data streaming from left or/and right side of detector for 10GbE mode. 1 (enabled) by default.
|
||||
"""
|
||||
result = {}
|
||||
for port in [defs.LEFT, defs.RIGHT]:
|
||||
|
@ -470,7 +470,9 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)()) & Detector::clearAcquiringFlag)
|
||||
.def("startReceiver", (void (Detector::*)()) & Detector::startReceiver)
|
||||
.def("stopReceiver", (void (Detector::*)()) & Detector::stopReceiver)
|
||||
.def("startDetector", (void (Detector::*)()) & Detector::startDetector)
|
||||
.def("startDetector",
|
||||
(void (Detector::*)(sls::Positions)) & Detector::startDetector,
|
||||
py::arg() = Positions{})
|
||||
.def("startDetectorReadout",
|
||||
(void (Detector::*)()) & Detector::startDetectorReadout)
|
||||
.def("stopDetector",
|
||||
@ -488,11 +490,10 @@ void init_det(py::module &m) {
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getFramesCaught,
|
||||
py::arg() = Positions{})
|
||||
.def(
|
||||
"getNumMissingPackets",
|
||||
(Result<std::vector<uint64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNumMissingPackets,
|
||||
py::arg() = Positions{})
|
||||
.def("getNumMissingPackets",
|
||||
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNumMissingPackets,
|
||||
py::arg() = Positions{})
|
||||
.def("getNextFrameNumber",
|
||||
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNextFrameNumber,
|
||||
@ -768,6 +769,13 @@ void init_det(py::module &m) {
|
||||
(Result<std::array<pid_t, 8>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxThreadIds,
|
||||
py::arg() = Positions{})
|
||||
.def("getRxArping",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxArping,
|
||||
py::arg() = Positions{})
|
||||
.def("setRxArping",
|
||||
(void (Detector::*)(bool, sls::Positions)) & Detector::setRxArping,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getFileFormat",
|
||||
(Result<defs::fileFormat>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getFileFormat,
|
||||
|
Binary file not shown.
@ -492,6 +492,11 @@ int Beb_SetDataStream(enum portPosition port, int enable) {
|
||||
u_int32_t reg = XPAR_GPIO_P15_STREAMING_REG;
|
||||
u_int32_t mask = (port == LEFT ? XPAR_GPIO_LFT_STRM_DSBL_MSK
|
||||
: XPAR_GPIO_RGHT_STRM_DSBL_MSK);
|
||||
// invert left/right if bottom
|
||||
if (!Beb_top) {
|
||||
mask = (port == LEFT ? XPAR_GPIO_RGHT_STRM_DSBL_MSK
|
||||
: XPAR_GPIO_LFT_STRM_DSBL_MSK);
|
||||
}
|
||||
|
||||
u_int32_t value = Beb_Read32(csp0base, reg);
|
||||
// disabling in firmware
|
||||
@ -529,6 +534,11 @@ int Beb_GetDataStream(enum portPosition port, int *retval) {
|
||||
u_int32_t reg = XPAR_GPIO_P15_STREAMING_REG;
|
||||
u_int32_t mask = (port == LEFT ? XPAR_GPIO_LFT_STRM_DSBL_MSK
|
||||
: XPAR_GPIO_RGHT_STRM_DSBL_MSK);
|
||||
// invert left/right if bottom
|
||||
if (!Beb_top) {
|
||||
mask = (port == LEFT ? XPAR_GPIO_RGHT_STRM_DSBL_MSK
|
||||
: XPAR_GPIO_LFT_STRM_DSBL_MSK);
|
||||
}
|
||||
|
||||
u_int32_t value = Beb_Read32(csp0base, reg);
|
||||
// disabling in firmware
|
||||
@ -682,6 +692,10 @@ int Beb_GetTransmissionDelayLeft() {
|
||||
return Beb_deactivated_transmission_delay_left;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_LEFT_OFFSET;
|
||||
// invert left/right if bottom
|
||||
if (!Beb_top) {
|
||||
offset = TXM_DELAY_RIGHT_OFFSET;
|
||||
}
|
||||
u_int32_t *csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
@ -706,6 +720,10 @@ int Beb_SetTransmissionDelayLeft(int value) {
|
||||
return 1;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_LEFT_OFFSET;
|
||||
// invert left/right if bottom
|
||||
if (!Beb_top) {
|
||||
offset = TXM_DELAY_RIGHT_OFFSET;
|
||||
}
|
||||
u_int32_t *csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
@ -726,6 +744,10 @@ int Beb_GetTransmissionDelayRight() {
|
||||
}
|
||||
|
||||
u_int32_t offset = TXM_DELAY_RIGHT_OFFSET;
|
||||
// invert left/right if bottom
|
||||
if (!Beb_top) {
|
||||
offset = TXM_DELAY_LEFT_OFFSET;
|
||||
}
|
||||
u_int32_t *csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
@ -750,6 +772,10 @@ int Beb_SetTransmissionDelayRight(int value) {
|
||||
return 1;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_RIGHT_OFFSET;
|
||||
// invert left/right if bottom
|
||||
if (!Beb_top) {
|
||||
offset = TXM_DELAY_LEFT_OFFSET;
|
||||
}
|
||||
u_int32_t *csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
|
Binary file not shown.
@ -2105,6 +2105,9 @@ int setDataStream(enum portPosition port, int enable) {
|
||||
LOG(logERROR, ("Invalid setDataStream enable argument: %d\n", enable));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO,
|
||||
("%s 10GbE %s datastream\n", (enable ? "Enabling" : "Disabling"),
|
||||
(port == LEFT ? "left" : "right")));
|
||||
#ifdef VIRTUAL
|
||||
if (port == LEFT) {
|
||||
eiger_virtual_left_datastream = enable;
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1675,7 +1675,7 @@ int setReadNRows(int value) {
|
||||
}
|
||||
if (isHardwareVersion2()) {
|
||||
LOG(logERROR, ("Could not set number of rows. Only available for "
|
||||
"Hardware Board version 2.0.\n"));
|
||||
"Hardware Board version 2.0.\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -2175,7 +2175,7 @@ int getFlipRows() {
|
||||
void setFlipRows(int arg) {
|
||||
if (isHardwareVersion2()) {
|
||||
LOG(logERROR, ("Could not set flip rows. Only available for "
|
||||
"Hardware Board version 2.0.\n"));
|
||||
"Hardware Board version 2.0.\n"));
|
||||
return;
|
||||
}
|
||||
if (arg >= 0) {
|
||||
|
Binary file not shown.
@ -67,7 +67,13 @@ int defaultDacValues[NDAC] = DEFAULT_DAC_VALS;
|
||||
int vLimit = 0;
|
||||
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||
int highvoltage = 0;
|
||||
|
||||
// getNumberofchannels return 0 for y in --update mode (virtual servers)
|
||||
#ifdef VIRTUAL
|
||||
int nSamples = DEFAULT_NUM_SAMPLES;
|
||||
#else
|
||||
int nSamples = 1;
|
||||
#endif
|
||||
int detPos[2] = {0, 0};
|
||||
|
||||
int isInitCheckDone() { return initCheckDone; }
|
||||
|
Binary file not shown.
@ -37,6 +37,8 @@ const enum detectorType myDetectorType = GOTTHARD2;
|
||||
const enum detectorType myDetectorType = GENERIC;
|
||||
#endif
|
||||
|
||||
#define LOCALHOSTIP_INT 2130706433
|
||||
|
||||
// Global variables from communication_funcs
|
||||
extern int lockStatus;
|
||||
extern uint32_t lastClientIP;
|
||||
@ -78,28 +80,32 @@ char scanErrMessage[MAX_STR_LENGTH] = "";
|
||||
/* initialization functions */
|
||||
|
||||
int updateModeAllowedFunction(int file_des) {
|
||||
unsigned int listsize = 19;
|
||||
enum detFuncs list[] = {F_EXEC_COMMAND,
|
||||
F_GET_DETECTOR_TYPE,
|
||||
F_GET_FIRMWARE_VERSION,
|
||||
F_GET_SERVER_VERSION,
|
||||
F_GET_SERIAL_NUMBER,
|
||||
F_WRITE_REGISTER,
|
||||
F_READ_REGISTER,
|
||||
F_LOCK_SERVER,
|
||||
F_GET_LAST_CLIENT_IP,
|
||||
F_PROGRAM_FPGA,
|
||||
F_RESET_FPGA,
|
||||
F_CHECK_VERSION,
|
||||
F_COPY_DET_SERVER,
|
||||
F_REBOOT_CONTROLLER,
|
||||
F_GET_KERNEL_VERSION,
|
||||
F_UPDATE_KERNEL,
|
||||
F_UPDATE_DETECTOR_SERVER,
|
||||
F_GET_UPDATE_MODE,
|
||||
F_SET_UPDATE_MODE};
|
||||
for (unsigned int i = 0; i < listsize; ++i) {
|
||||
if ((unsigned int)fnum == list[i]) {
|
||||
enum detFuncs allowedFuncs[] = {F_EXEC_COMMAND,
|
||||
F_GET_DETECTOR_TYPE,
|
||||
F_GET_FIRMWARE_VERSION,
|
||||
F_GET_SERVER_VERSION,
|
||||
F_GET_SERIAL_NUMBER,
|
||||
F_WRITE_REGISTER,
|
||||
F_READ_REGISTER,
|
||||
F_LOCK_SERVER,
|
||||
F_GET_LAST_CLIENT_IP,
|
||||
F_PROGRAM_FPGA,
|
||||
F_RESET_FPGA,
|
||||
F_CHECK_VERSION,
|
||||
F_COPY_DET_SERVER,
|
||||
F_REBOOT_CONTROLLER,
|
||||
F_GET_KERNEL_VERSION,
|
||||
F_UPDATE_KERNEL,
|
||||
F_UPDATE_DETECTOR_SERVER,
|
||||
F_GET_UPDATE_MODE,
|
||||
F_SET_UPDATE_MODE,
|
||||
F_GET_NUM_CHANNELS,
|
||||
F_GET_NUM_INTERFACES,
|
||||
F_ACTIVATE};
|
||||
size_t allowedFuncsSize = sizeof(allowedFuncs) / sizeof(enum detFuncs);
|
||||
|
||||
for (unsigned int i = 0; i < allowedFuncsSize; ++i) {
|
||||
if ((unsigned int)fnum == allowedFuncs[i]) {
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
@ -119,10 +125,11 @@ int printSocketReadError() {
|
||||
}
|
||||
|
||||
void init_detector() {
|
||||
memset(udpDetails, 0, sizeof(udpDetails));
|
||||
#ifdef VIRTUAL
|
||||
LOG(logINFO, ("This is a VIRTUAL detector\n"));
|
||||
udpDetails[0].srcip = LOCALHOSTIP_INT;
|
||||
#endif
|
||||
memset(udpDetails, 0, sizeof(udpDetails));
|
||||
udpDetails[0].srcport = DEFAULT_UDP_SRC_PORTNO;
|
||||
udpDetails[0].dstport = DEFAULT_UDP_DST_PORTNO;
|
||||
#ifdef EIGERD
|
||||
@ -2932,7 +2939,7 @@ int enable_ten_giga(int file_des) {
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFOBLUE, ("Setting 10GbE: %d\n", arg));
|
||||
LOG(logDEBUG, ("Setting 10GbE: %d\n", arg));
|
||||
|
||||
#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(GOTTHARD2D)
|
||||
functionNotImplemented();
|
||||
@ -4855,12 +4862,14 @@ int is_udp_configured() {
|
||||
LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
if (udpDetails[i].dstmac == 0) {
|
||||
sprintf(configureMessage,
|
||||
"udp destination mac not configured [entry:%d]\n", i);
|
||||
LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
|
||||
if (getNumberofUDPInterfaces() == 2) {
|
||||
if (udpDetails[i].srcip2 == 0) {
|
||||
@ -4881,12 +4890,14 @@ int is_udp_configured() {
|
||||
LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
if (udpDetails[i].dstmac2 == 0) {
|
||||
sprintf(configureMessage,
|
||||
"udp destination mac2 not configured [entry:%d]\n", i);
|
||||
LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ class Detector {
|
||||
/** Non blocking: start detector acquisition. Status changes to RUNNING or
|
||||
* WAITING and automatically returns to idle at the end of acquisition.
|
||||
[Mythen3] Master starts acquisition first */
|
||||
void startDetector();
|
||||
void startDetector(Positions pos = {});
|
||||
|
||||
/** [Mythen3] Non blocking: start detector readout of counters in chip.
|
||||
* Status changes to TRANSMITTING and automatically returns to idle at the
|
||||
@ -588,11 +588,9 @@ class Detector {
|
||||
|
||||
Result<int64_t> getFramesCaught(Positions pos = {}) const;
|
||||
|
||||
/** Gets the number of missing packets for each port in receiver.
|
||||
* Troubleshoot: If they are large numbers, convert it to signed to get
|
||||
* number of access packets received */
|
||||
Result<std::vector<uint64_t>>
|
||||
getNumMissingPackets(Positions pos = {}) const;
|
||||
/** Gets the number of missing packets for each port in receiver. Negative
|
||||
* number denotes extra packets. */
|
||||
Result<std::vector<int64_t>> getNumMissingPackets(Positions pos = {}) const;
|
||||
|
||||
/** [Eiger][Jungfrau][Moench][CTB] */
|
||||
Result<uint64_t> getNextFrameNumber(Positions pos = {}) const;
|
||||
@ -878,10 +876,18 @@ class Detector {
|
||||
Result<sls::IpAddr> getRxLastClientIP(Positions pos = {}) const;
|
||||
|
||||
/** Get thread ids from the receiver in order of [parent, tcp, listener 0,
|
||||
* processor 0, streamer 0, listener 1, processor 1, streamer 1]. If no
|
||||
* streamer yet or there is no second interface, it gives 0 in its place. */
|
||||
* processor 0, streamer 0, listener 1, processor 1, streamer 1, arping]. If
|
||||
* no streamer yet or there is no second interface, it gives 0 in its place.
|
||||
*/
|
||||
Result<std::array<pid_t, NUM_RX_THREAD_IDS>>
|
||||
getRxThreadIds(Positions pos = {}) const;
|
||||
|
||||
Result<bool> getRxArping(Positions pos = {}) const;
|
||||
|
||||
/** Starts a thread in slsReceiver to arping the interface it is listening
|
||||
* every minute. Useful in 10G mode. */
|
||||
void setRxArping(bool value, Positions pos = {});
|
||||
|
||||
///@}
|
||||
|
||||
/** @name File */
|
||||
@ -1139,8 +1145,8 @@ class Detector {
|
||||
Result<bool> getDataStream(const defs::portPosition port,
|
||||
Positions pos = {}) const;
|
||||
|
||||
/** [Eiger] enable or disable data streaming from left or right of detector.
|
||||
* Default: enabled
|
||||
/** [Eiger] enable or disable data streaming from left or right of detector
|
||||
* for 10GbE. Default: enabled
|
||||
*/
|
||||
void setDataStream(const defs::portPosition port, const bool enable,
|
||||
Positions pos = {});
|
||||
|
@ -1804,7 +1804,9 @@ std::string CmdProxy::DataStream(int action) {
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[left|right] [0, 1]\n\t[Eiger] Enables or disables data "
|
||||
"streaming from left or/and right side of detector. 1 (enabled) "
|
||||
"streaming from left or/and right side of detector for 10 GbE "
|
||||
"mode. "
|
||||
"1 (enabled) "
|
||||
"by default."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
|
@ -903,6 +903,7 @@ class CmdProxy {
|
||||
{"rx_lock", &CmdProxy::rx_lock},
|
||||
{"rx_lastclient", &CmdProxy::rx_lastclient},
|
||||
{"rx_threads", &CmdProxy::rx_threads},
|
||||
{"rx_arping", &CmdProxy::rx_arping},
|
||||
|
||||
/* File */
|
||||
{"fformat", &CmdProxy::fformat},
|
||||
@ -1515,7 +1516,7 @@ class CmdProxy {
|
||||
"\n\tStops receiver listener for detector data packets and closes "
|
||||
"current data file (if file write enabled).");
|
||||
|
||||
EXECUTE_SET_COMMAND_NOID(
|
||||
EXECUTE_SET_COMMAND(
|
||||
start, startDetector,
|
||||
"\n\tStarts detector acquisition. Status changes to RUNNING or WAITING "
|
||||
"and automatically returns to idle at the end of acquisition. If the "
|
||||
@ -1535,7 +1536,8 @@ class CmdProxy {
|
||||
"\n\tNumber of frames caught by receiver.");
|
||||
|
||||
GET_COMMAND(rx_missingpackets, getNumMissingPackets,
|
||||
"\n\tNumber of missing packets for each port in receiver.");
|
||||
"\n\tNumber of missing packets for each port in receiver. "
|
||||
"Negative number denotes extra packets.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
nextframenumber, getNextFrameNumber, setNextFrameNumber,
|
||||
@ -1738,13 +1740,16 @@ class CmdProxy {
|
||||
rx_lastclient, getRxLastClientIP,
|
||||
"\n\tClient IP Address that last communicated with the receiver.");
|
||||
|
||||
GET_COMMAND(
|
||||
rx_threads, getRxThreadIds,
|
||||
"\n\tGet thread ids from the receiver in order of [parent, tcp, "
|
||||
"listener 0, "
|
||||
"processor 0, streamer 0, listener 1, processor 1, streamer 1]. If no "
|
||||
"streamer yet or there is no second interface, it gives 0 in its "
|
||||
"place.");
|
||||
GET_COMMAND(rx_threads, getRxThreadIds,
|
||||
"\n\tGet thread ids from the receiver in order of [parent, "
|
||||
"tcp, listener 0, processor 0, streamer 0, listener 1, "
|
||||
"processor 1, streamer 1, arping]. If no streamer yet or there "
|
||||
"is no second interface, it gives 0 in its place.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(rx_arping, getRxArping, setRxArping, StringTo<int>,
|
||||
"[0, 1]\n\tStarts a thread in slsReceiver to arping "
|
||||
"the interface it is "
|
||||
"listening to every minute. Useful in 10G mode.");
|
||||
|
||||
/* File */
|
||||
|
||||
|
@ -756,22 +756,24 @@ void Detector::startReceiver() { pimpl->Parallel(&Module::startReceiver, {}); }
|
||||
|
||||
void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); }
|
||||
|
||||
void Detector::startDetector() {
|
||||
auto detector_type = getDetectorType().squash();
|
||||
void Detector::startDetector(Positions pos) {
|
||||
auto detector_type = getDetectorType(pos).squash();
|
||||
if (detector_type == defs::MYTHEN3 && size() > 1) {
|
||||
auto is_master = getMaster();
|
||||
int masterPosition = 0;
|
||||
std::vector<int> slaves;
|
||||
for (int i = 0; i < size(); ++i) {
|
||||
if (is_master[i])
|
||||
std::vector<int> slaves(pos);
|
||||
auto is_master = getMaster(pos);
|
||||
int masterPosition = -1;
|
||||
for (unsigned int i = 0; i < is_master.size(); ++i) {
|
||||
if (is_master[i]) {
|
||||
masterPosition = i;
|
||||
else
|
||||
slaves.push_back(i);
|
||||
slaves.erase(slaves.begin() + i);
|
||||
}
|
||||
}
|
||||
pimpl->Parallel(&Module::startAcquisition, pos);
|
||||
if (masterPosition != -1) {
|
||||
pimpl->Parallel(&Module::startAcquisition, {masterPosition});
|
||||
}
|
||||
pimpl->Parallel(&Module::startAcquisition, slaves);
|
||||
pimpl->Parallel(&Module::startAcquisition, {masterPosition});
|
||||
} else {
|
||||
pimpl->Parallel(&Module::startAcquisition, {});
|
||||
pimpl->Parallel(&Module::startAcquisition, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -795,7 +797,7 @@ Result<int64_t> Detector::getFramesCaught(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getFramesCaughtByReceiver, pos);
|
||||
}
|
||||
|
||||
Result<std::vector<uint64_t>>
|
||||
Result<std::vector<int64_t>>
|
||||
Detector::getNumMissingPackets(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getNumMissingPackets, pos);
|
||||
}
|
||||
@ -1170,6 +1172,14 @@ Detector::getRxThreadIds(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverThreadIds, pos);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getRxArping(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getRxArping, pos);
|
||||
}
|
||||
|
||||
void Detector::setRxArping(bool value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setRxArping, pos, value);
|
||||
}
|
||||
|
||||
// File
|
||||
|
||||
Result<defs::fileFormat> Detector::getFileFormat(Positions pos) const {
|
||||
|
@ -214,9 +214,21 @@ void Module::setThresholdEnergy(int e_eV, detectorSettings isettings,
|
||||
myMod.iodelay = myMod1.iodelay;
|
||||
myMod.tau =
|
||||
linearInterpolation(e_eV, trim1, trim2, myMod1.tau, myMod2.tau);
|
||||
// m3, reg is used for gaincaps
|
||||
if (shm()->detType == MYTHEN3) {
|
||||
if (myMod1.reg != myMod2.reg) {
|
||||
throw RuntimeError(
|
||||
"setThresholdEnergyAndSettings: gaincaps do not "
|
||||
"match between files");
|
||||
}
|
||||
myMod.reg = myMod1.reg;
|
||||
}
|
||||
}
|
||||
// m3, reg is used for gaincaps
|
||||
if (shm()->detType != MYTHEN3) {
|
||||
myMod.reg = isettings;
|
||||
}
|
||||
|
||||
myMod.reg = isettings;
|
||||
myMod.eV[0] = e_eV;
|
||||
setModule(myMod, trimbits);
|
||||
if (getSettings() != isettings) {
|
||||
@ -231,6 +243,7 @@ void Module::setThresholdEnergy(int e_eV, detectorSettings isettings,
|
||||
|
||||
void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
||||
detectorSettings isettings, bool trimbits) {
|
||||
// only mythen3
|
||||
if (shm()->trimEnergies.empty()) {
|
||||
throw RuntimeError(
|
||||
"Trim energies have not been defined for this module yet!");
|
||||
@ -311,6 +324,13 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
||||
|
||||
myMods[i] = interpolateTrim(&myMod1, &myMod2, energy[i], trim1,
|
||||
trim2, trimbits);
|
||||
// gaincaps
|
||||
if (myMod1.reg != myMod2.reg) {
|
||||
throw RuntimeError("setAllThresholdEnergy: gaincaps do not "
|
||||
"match between files for energy (eV) " +
|
||||
std::to_string(energy[i]));
|
||||
}
|
||||
myMods[i].reg = myMod1.reg;
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,6 +377,11 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
||||
for (int i = 0; i < myMod.nchan; ++i) {
|
||||
myMod.chanregs[i] = myMods[i % 3].chanregs[i];
|
||||
}
|
||||
// gain caps
|
||||
if (myMods[0].reg != myMods[1].reg || myMods[1].reg != myMods[2].reg) {
|
||||
throw RuntimeError("setAllThresholdEnergy: gaincaps do not "
|
||||
"match between files for all energies");
|
||||
}
|
||||
}
|
||||
|
||||
myMod.reg = isettings;
|
||||
@ -845,7 +870,7 @@ int64_t Module::getFramesCaughtByReceiver() const {
|
||||
return sendToReceiver<int64_t>(F_GET_RECEIVER_FRAMES_CAUGHT);
|
||||
}
|
||||
|
||||
std::vector<uint64_t> Module::getNumMissingPackets() const {
|
||||
std::vector<int64_t> Module::getNumMissingPackets() const {
|
||||
// TODO!(Erik) Refactor
|
||||
LOG(logDEBUG1) << "Getting num missing packets";
|
||||
if (shm()->useReceiverFlag) {
|
||||
@ -857,7 +882,7 @@ std::vector<uint64_t> Module::getNumMissingPackets() const {
|
||||
" returned error: " + client.readErrorMessage());
|
||||
} else {
|
||||
auto nports = client.Receive<int>();
|
||||
std::vector<uint64_t> retval(nports);
|
||||
std::vector<int64_t> retval(nports);
|
||||
client.Receive(retval);
|
||||
LOG(logDEBUG1) << "Missing packets of Receiver" << moduleIndex
|
||||
<< ": " << sls::ToString(retval);
|
||||
@ -1021,6 +1046,10 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
|
||||
if (ip == 0) {
|
||||
throw RuntimeError("Invalid destination udp ip address");
|
||||
}
|
||||
if (ip.str() == LOCALHOST_IP && !isVirtualDetectorServer()) {
|
||||
throw RuntimeError("Invalid destination udp ip. Change rx_hostname "
|
||||
"from localhost or change udp_dstip from auto?");
|
||||
}
|
||||
sendToDetector(F_SET_DEST_UDP_IP, ip, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
sls::MacAddr retval(0LU);
|
||||
@ -1040,7 +1069,10 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
|
||||
if (ip == 0) {
|
||||
throw RuntimeError("Invalid destination udp ip address2");
|
||||
}
|
||||
|
||||
if (ip.str() == LOCALHOST_IP && !isVirtualDetectorServer()) {
|
||||
throw RuntimeError("Invalid destination udp ip2. Change rx_hostname "
|
||||
"from localhost or change udp_dstip from auto?");
|
||||
}
|
||||
sendToDetector(F_SET_DEST_UDP_IP2, ip, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
sls::MacAddr retval(0LU);
|
||||
@ -1318,6 +1350,14 @@ std::array<pid_t, NUM_RX_THREAD_IDS> Module::getReceiverThreadIds() const {
|
||||
F_GET_RECEIVER_THREAD_IDS);
|
||||
}
|
||||
|
||||
bool Module::getRxArping() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_ARPING);
|
||||
}
|
||||
|
||||
void Module::setRxArping(bool enable) {
|
||||
sendToReceiver(F_SET_RECEIVER_ARPING, static_cast<int>(enable), nullptr);
|
||||
}
|
||||
|
||||
// File
|
||||
slsDetectorDefs::fileFormat Module::getFileFormat() const {
|
||||
return sendToReceiver<fileFormat>(F_GET_RECEIVER_FILE_FORMAT);
|
||||
@ -3322,9 +3362,9 @@ sls_detector_module Module::interpolateTrim(sls_detector_module *a,
|
||||
dacs_to_copy.end(),
|
||||
{E_SVP, E_SVN, E_VTGSTV, E_RXB_RB, E_RXB_LB, E_VCN, E_VIS});
|
||||
// interpolate vrf, vcmp, vcp
|
||||
dacs_to_interpolate.insert(
|
||||
dacs_to_interpolate.end(),
|
||||
{E_VTR, E_VRF, E_VCMP_LL, E_VCMP_LR, E_VCMP_RL, E_VCMP_RR, E_VCP, E_VRS});
|
||||
dacs_to_interpolate.insert(dacs_to_interpolate.end(),
|
||||
{E_VTR, E_VRF, E_VCMP_LL, E_VCMP_LR,
|
||||
E_VCMP_RL, E_VCMP_RR, E_VCP, E_VRS});
|
||||
} else {
|
||||
dacs_to_copy.insert(dacs_to_copy.end(),
|
||||
{M_VCASSH, M_VRSHAPER, M_VRSHAPER_N, M_VIPRE_OUT,
|
||||
|
@ -200,7 +200,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
runStatus getReceiverStatus() const;
|
||||
double getReceiverProgress() const;
|
||||
int64_t getFramesCaughtByReceiver() const;
|
||||
std::vector<uint64_t> getNumMissingPackets() const;
|
||||
std::vector<int64_t> getNumMissingPackets() const;
|
||||
uint64_t getNextFrameNumber() const;
|
||||
void setNextFrameNumber(uint64_t value);
|
||||
void sendSoftwareTrigger(const bool block);
|
||||
@ -283,6 +283,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setReceiverLock(bool lock);
|
||||
sls::IpAddr getReceiverLastClientIP() const;
|
||||
std::array<pid_t, NUM_RX_THREAD_IDS> getReceiverThreadIds() const;
|
||||
bool getRxArping() const;
|
||||
void setRxArping(bool enable);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
|
@ -385,6 +385,30 @@ TEST_CASE("rx_threads", "[.cmd][.rx]") {
|
||||
REQUIRE_NOTHROW(proxy.Call("rx_threads", {}, -1, GET, oss));
|
||||
}
|
||||
|
||||
TEST_CASE("rx_arping", "[.cmd][.rx]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto prev_val = det.getRxArping();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_arping", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_arping 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_arping", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_arping 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_arping", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_arping 0\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxArping(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
|
||||
/* File */
|
||||
|
||||
TEST_CASE("fformat", "[.cmd]") {
|
||||
|
@ -12,6 +12,7 @@ set(SOURCES
|
||||
src/DataProcessor.cpp
|
||||
src/DataStreamer.cpp
|
||||
src/Fifo.cpp
|
||||
src/Arping.cpp
|
||||
)
|
||||
|
||||
set(PUBLICHEADERS
|
||||
|
120
slsReceiverSoftware/src/Arping.cpp
Normal file
120
slsReceiverSoftware/src/Arping.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
#include "Arping.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <unistd.h>
|
||||
|
||||
// gettid added in glibc 2.30
|
||||
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
||||
#include <sys/syscall.h>
|
||||
#define gettid() syscall(SYS_gettid)
|
||||
#endif
|
||||
|
||||
void Arping::SetInterfacesAndIps(const int index, const std::string &interface,
|
||||
const std::string &ip) {
|
||||
|
||||
if (interface.empty() || ip.empty()) {
|
||||
throw sls::RuntimeError("Could not arping. Interface name and ip not "
|
||||
"set up for interface " +
|
||||
std::to_string(index));
|
||||
}
|
||||
// create commands to arping
|
||||
std::ostringstream os;
|
||||
os << "arping -c 1 -U -I " << interface << " " << ip;
|
||||
// to read error messages
|
||||
os << " 2>&1";
|
||||
std::string cmd = os.str();
|
||||
commands[index] = cmd;
|
||||
}
|
||||
|
||||
pid_t Arping::GetThreadId() const { return threadId; }
|
||||
|
||||
bool Arping::IsRunning() const { return runningFlag; }
|
||||
|
||||
void Arping::StartThread() {
|
||||
TestCommands();
|
||||
try {
|
||||
t = std::thread(&Arping::ThreadExecution, this);
|
||||
} catch (...) {
|
||||
throw sls::RuntimeError("Could not start arping thread");
|
||||
}
|
||||
runningFlag = true;
|
||||
}
|
||||
|
||||
void Arping::StopThread() {
|
||||
runningFlag = false;
|
||||
t.join();
|
||||
}
|
||||
|
||||
void Arping::ThreadExecution() {
|
||||
threadId = gettid();
|
||||
LOG(logINFOBLUE) << "Created [ Arping Thread, Tid: " << threadId << " ]";
|
||||
|
||||
while (runningFlag) {
|
||||
std::string error = ExecuteCommands();
|
||||
// just print (was already tested at thread start)
|
||||
if (!error.empty()) {
|
||||
LOG(logERROR) << error;
|
||||
}
|
||||
|
||||
// wait for 60s as long as thread not killed
|
||||
int nsecs = 0;
|
||||
while (runningFlag && nsecs != 60) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
++nsecs;
|
||||
}
|
||||
}
|
||||
|
||||
LOG(logINFOBLUE) << "Exiting [ Arping Thread, Tid: " << threadId << " ]";
|
||||
threadId = 0;
|
||||
}
|
||||
|
||||
void Arping::TestCommands() {
|
||||
// atleast one interface must be set up
|
||||
if (commands[0].empty()) {
|
||||
throw sls::RuntimeError(
|
||||
"Could not arping. Interface not set up in apring thread");
|
||||
}
|
||||
// test if arping commands throw an error
|
||||
std::string error = ExecuteCommands();
|
||||
if (!error.empty()) {
|
||||
throw sls::RuntimeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Arping::ExecuteCommands() {
|
||||
for (auto cmd : commands) {
|
||||
|
||||
// empty if 2nd interface not enabled
|
||||
if (cmd.empty())
|
||||
continue;
|
||||
|
||||
LOG(logDEBUG) << "Executing Arping Command: " << cmd;
|
||||
|
||||
// execute command
|
||||
FILE *sysFile = popen(cmd.c_str(), "r");
|
||||
if (sysFile == NULL) {
|
||||
std::ostringstream os;
|
||||
os << "Could not Arping [" << cmd << " ] : Popen fail";
|
||||
return os.str();
|
||||
}
|
||||
|
||||
// copy output
|
||||
char output[MAX_STR_LENGTH] = {0};
|
||||
fgets(output, sizeof(output), sysFile);
|
||||
output[sizeof(output) - 1] = '\0';
|
||||
|
||||
// check exit status of command
|
||||
if (pclose(sysFile)) {
|
||||
std::ostringstream os;
|
||||
os << "Could not arping[" << cmd << "] : " << output;
|
||||
return os.str();
|
||||
} else {
|
||||
LOG(logDEBUG) << output;
|
||||
}
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
35
slsReceiverSoftware/src/Arping.h
Normal file
35
slsReceiverSoftware/src/Arping.h
Normal file
@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
/**
|
||||
*@short creates/destroys an ARPing thread to arping the interfaces slsReceiver
|
||||
is listening to.
|
||||
*/
|
||||
|
||||
#include "receiver_defs.h"
|
||||
#include "sls/logger.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
|
||||
class Arping {
|
||||
|
||||
public:
|
||||
void SetInterfacesAndIps(const int index, const std::string &interface,
|
||||
const std::string &ip);
|
||||
pid_t GetThreadId() const;
|
||||
bool IsRunning() const;
|
||||
void StartThread();
|
||||
void StopThread();
|
||||
|
||||
private:
|
||||
void TestCommands();
|
||||
std::string ExecuteCommands();
|
||||
void ThreadExecution();
|
||||
|
||||
std::vector<std::string> commands =
|
||||
std::vector<std::string>(MAX_NUMBER_OF_LISTENING_THREADS);
|
||||
std::atomic<bool> runningFlag{false};
|
||||
std::thread t;
|
||||
std::atomic<pid_t> threadId{0};
|
||||
};
|
@ -19,7 +19,6 @@
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
@ -28,6 +27,12 @@ using sls::RuntimeError;
|
||||
using sls::SocketError;
|
||||
using Interface = sls::ServerInterface;
|
||||
|
||||
// gettid added in glibc 2.30
|
||||
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
||||
#include <sys/syscall.h>
|
||||
#define gettid() syscall(SYS_gettid)
|
||||
#endif
|
||||
|
||||
ClientInterface::~ClientInterface() {
|
||||
killTcpThread = true;
|
||||
LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
|
||||
@ -41,7 +46,7 @@ ClientInterface::ClientInterface(int portNumber)
|
||||
portNumber(portNumber > 0 ? portNumber : DEFAULT_PORTNO + 2),
|
||||
server(portNumber) {
|
||||
functionTable();
|
||||
parentThreadId = syscall(SYS_gettid);
|
||||
parentThreadId = gettid();
|
||||
tcpThread =
|
||||
sls::make_unique<std::thread>(&ClientInterface::startTCPServer, this);
|
||||
}
|
||||
@ -76,7 +81,7 @@ void ClientInterface::registerCallBackRawDataModifyReady(
|
||||
}
|
||||
|
||||
void ClientInterface::startTCPServer() {
|
||||
tcpThreadId = syscall(SYS_gettid);
|
||||
tcpThreadId = gettid();
|
||||
LOG(logINFOBLUE) << "Created [ TCP server Tid: " << tcpThreadId << "]";
|
||||
LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber
|
||||
<< '\n';
|
||||
@ -210,7 +215,8 @@ int ClientInterface::functionTable(){
|
||||
flist[F_SET_RECEIVER_STREAMING_HWM] = &ClientInterface::set_streaming_hwm;
|
||||
flist[F_RECEIVER_SET_ALL_THRESHOLD] = &ClientInterface::set_all_threshold;
|
||||
flist[F_RECEIVER_SET_DATASTREAM] = &ClientInterface::set_detector_datastream;
|
||||
|
||||
flist[F_GET_RECEIVER_ARPING] = &ClientInterface::get_arping;
|
||||
flist[F_SET_RECEIVER_ARPING] = &ClientInterface::set_arping;
|
||||
|
||||
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
|
||||
LOG(logDEBUG1) << "function fnum: " << i << " (" <<
|
||||
@ -1398,9 +1404,13 @@ sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) {
|
||||
if (detType == EIGER) {
|
||||
impl()->setEthernetInterface2(eth);
|
||||
}
|
||||
|
||||
// update locally to use for arping
|
||||
udpips[0] = arg.str();
|
||||
|
||||
// get mac address
|
||||
auto retval = sls::InterfaceNameToMac(eth);
|
||||
if (retval == 0) {
|
||||
if (retval == 0 && arg.str() != LOCALHOST_IP) {
|
||||
throw RuntimeError("Failed to get udp mac adddress to listen to (eth:" +
|
||||
eth + ", ip:" + arg.str() + ")\n");
|
||||
}
|
||||
@ -1430,9 +1440,12 @@ sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) {
|
||||
}
|
||||
impl()->setEthernetInterface2(eth);
|
||||
|
||||
// update locally to use for arping
|
||||
udpips[1] = arg.str();
|
||||
|
||||
// get mac address
|
||||
auto retval = sls::InterfaceNameToMac(eth);
|
||||
if (retval == 0) {
|
||||
if (retval == 0 && arg.str() != LOCALHOST_IP) {
|
||||
throw RuntimeError(
|
||||
"Failed to get udp mac adddress2 to listen to (eth:" + eth +
|
||||
", ip:" + arg.str() + ")\n");
|
||||
@ -1697,3 +1710,20 @@ int ClientInterface::set_detector_datastream(Interface &socket) {
|
||||
impl()->setDetectorDataStream(port, enable);
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
int ClientInterface::get_arping(Interface &socket) {
|
||||
auto retval = static_cast<int>(impl()->getArping());
|
||||
LOG(logDEBUG1) << "arping thread status:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::set_arping(Interface &socket) {
|
||||
auto value = socket.Receive<int>();
|
||||
if (value < 0) {
|
||||
throw RuntimeError("Invalid arping value: " + std::to_string(value));
|
||||
}
|
||||
verifyIdle(socket);
|
||||
LOG(logDEBUG1) << "Starting/ Killing arping thread:" << value;
|
||||
impl()->setArping(value, udpips);
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
@ -163,6 +163,8 @@ class ClientInterface : private virtual slsDetectorDefs {
|
||||
int set_streaming_hwm(sls::ServerInterface &socket);
|
||||
int set_all_threshold(sls::ServerInterface &socket);
|
||||
int set_detector_datastream(sls::ServerInterface &socket);
|
||||
int get_arping(sls::ServerInterface &socket);
|
||||
int set_arping(sls::ServerInterface &socket);
|
||||
|
||||
Implementation *impl() {
|
||||
if (receiver != nullptr) {
|
||||
@ -190,4 +192,6 @@ class ClientInterface : private virtual slsDetectorDefs {
|
||||
|
||||
pid_t parentThreadId{0};
|
||||
pid_t tcpThreadId{0};
|
||||
std::vector<std::string> udpips =
|
||||
std::vector<std::string>(MAX_NUMBER_OF_LISTENING_THREADS);
|
||||
};
|
||||
|
@ -107,6 +107,7 @@ void Implementation::SetupFifoStructure() {
|
||||
* ************************************************/
|
||||
|
||||
void Implementation::setDetectorType(const detectorType d) {
|
||||
|
||||
detType = d;
|
||||
switch (detType) {
|
||||
case GOTTHARD:
|
||||
@ -320,9 +321,33 @@ std::array<pid_t, NUM_RX_THREAD_IDS> Implementation::getThreadIds() const {
|
||||
retval[id++] = 0;
|
||||
}
|
||||
}
|
||||
retval[NUM_RX_THREAD_IDS - 1] = arping.GetThreadId();
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool Implementation::getArping() const { return arping.IsRunning(); }
|
||||
|
||||
pid_t Implementation::getArpingThreadId() const { return arping.GetThreadId(); }
|
||||
|
||||
void Implementation::setArping(const bool i,
|
||||
const std::vector<std::string> ips) {
|
||||
if (i != arping.IsRunning()) {
|
||||
if (!i) {
|
||||
arping.StopThread();
|
||||
} else {
|
||||
// setup interface
|
||||
for (int i = 0; i != numUDPInterfaces; ++i) {
|
||||
// ignore eiger with 2 interfaces (only udp port)
|
||||
if (i == 1 && (numUDPInterfaces == 1 || detType == EIGER)) {
|
||||
break;
|
||||
}
|
||||
arping.SetInterfacesAndIps(i, eth[i], ips[i]);
|
||||
}
|
||||
arping.StartThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* File Parameters *
|
||||
@ -610,25 +635,25 @@ void Implementation::stopReceiver() {
|
||||
std::to_string(std::abs(mp[i])) + std::string(" (Extra)");
|
||||
}
|
||||
|
||||
std::string summary;
|
||||
if (!activated) {
|
||||
summary = "\n\tDeactivated Receiver";
|
||||
} else if (!detectorDataStream[i]) {
|
||||
summary = (i == 0 ? "\n\tDeactivated Left Port"
|
||||
: "\n\tDeactivated Right Port");
|
||||
} else {
|
||||
std::ostringstream os;
|
||||
os << "\n\tMissing Packets\t\t: " << mpMessage
|
||||
<< "\n\tComplete Frames\t\t: " << nf
|
||||
<< "\n\tLast Frame Caught\t: "
|
||||
<< listener[i]->GetLastFrameIndexCaught();
|
||||
summary = os.str();
|
||||
}
|
||||
|
||||
TLogLevel lev = ((mp[i]) > 0) ? logINFORED : logINFOGREEN;
|
||||
LOG(lev) <<
|
||||
// udp port number could be the second if selected interface is
|
||||
// 2 for jungfrau
|
||||
"Summary of Port " << udpPortNum[i]
|
||||
<< "\n\tMissing Packets\t\t: " << mpMessage
|
||||
<< "\n\tComplete Frames\t\t: " << nf
|
||||
<< "\n\tLast Frame Caught\t: "
|
||||
<< listener[i]->GetLastFrameIndexCaught();
|
||||
}
|
||||
if (!activated) {
|
||||
LOG(logINFORED) << "Deactivated Receiver";
|
||||
}
|
||||
if (!detectorDataStream[0]) {
|
||||
LOG(logINFORED) << "Deactivated Left Port";
|
||||
}
|
||||
if (!detectorDataStream[1]) {
|
||||
LOG(logINFORED) << "Deactivated Right Port";
|
||||
LOG(lev) << "Summary of Port " << udpPortNum[i] << summary;
|
||||
}
|
||||
|
||||
// callback
|
||||
if (acquisitionFinishedCallBack) {
|
||||
try {
|
||||
@ -1441,6 +1466,21 @@ void Implementation::setTenGigaEnable(const bool b) {
|
||||
|
||||
generalData->SetTenGigaEnable(b);
|
||||
SetupFifoStructure();
|
||||
|
||||
// datastream can be disabled/enabled only for Eiger 10GbE
|
||||
if (detType == EIGER) {
|
||||
if (!b) {
|
||||
detectorDataStream[LEFT] = 1;
|
||||
detectorDataStream[RIGHT] = 1;
|
||||
} else {
|
||||
detectorDataStream[LEFT] = detectorDataStream10GbE[LEFT];
|
||||
detectorDataStream[RIGHT] = detectorDataStream10GbE[RIGHT];
|
||||
}
|
||||
LOG(logINFO) << "Detector datastream updated [Left: "
|
||||
<< sls::ToString(detectorDataStream[LEFT])
|
||||
<< ", Right: "
|
||||
<< sls::ToString(detectorDataStream[RIGHT]) << "]";
|
||||
}
|
||||
}
|
||||
LOG(logINFO) << "Ten Giga: " << (tengigaEnable ? "enabled" : "disabled");
|
||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||
@ -1507,9 +1547,9 @@ bool Implementation::getDetectorDataStream(const portPosition port) const {
|
||||
void Implementation::setDetectorDataStream(const portPosition port,
|
||||
const bool enable) {
|
||||
int index = (port == LEFT ? 0 : 1);
|
||||
detectorDataStream[index] = enable;
|
||||
LOG(logINFO) << "Detector datastream (" << sls::ToString(port)
|
||||
<< " Port): " << sls::ToString(detectorDataStream[index]);
|
||||
detectorDataStream10GbE[index] = enable;
|
||||
LOG(logINFO) << "Detector 10GbE datastream (" << sls::ToString(port)
|
||||
<< " Port): " << sls::ToString(detectorDataStream10GbE[index]);
|
||||
}
|
||||
|
||||
int Implementation::getReadNRows() const { return readNRows; }
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
#include "Arping.h"
|
||||
#include "receiver_defs.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/logger.h"
|
||||
@ -49,6 +50,9 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
void setFramePaddingEnable(const bool i);
|
||||
void setThreadIds(const pid_t parentTid, const pid_t tcpTid);
|
||||
std::array<pid_t, NUM_RX_THREAD_IDS> getThreadIds() const;
|
||||
bool getArping() const;
|
||||
pid_t getArpingThreadId() const;
|
||||
void setArping(const bool i, const std::vector<std::string> ips);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
@ -295,7 +299,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
std::string filePath{"/"};
|
||||
std::string fileName{"run"};
|
||||
uint64_t fileIndex{0};
|
||||
bool fileWriteEnable{true};
|
||||
bool fileWriteEnable{false};
|
||||
bool masterFileWriteEnable{true};
|
||||
bool overwriteEnable{true};
|
||||
uint32_t framesPerFile{0};
|
||||
@ -352,6 +356,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
bool quadEnable{false};
|
||||
bool activated{true};
|
||||
std::array<bool, 2> detectorDataStream = {{true, true}};
|
||||
std::array<bool, 2> detectorDataStream10GbE = {{true, true}};
|
||||
int readNRows{0};
|
||||
int thresholdEnergyeV{-1};
|
||||
std::array<int, 3> thresholdAllEnergyeV = {{-1, -1, -1}};
|
||||
@ -379,6 +384,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
std::vector<std::unique_ptr<DataProcessor>> dataProcessor;
|
||||
std::vector<std::unique_ptr<DataStreamer>> dataStreamer;
|
||||
std::vector<std::unique_ptr<Fifo>> fifo;
|
||||
Arping arping;
|
||||
|
||||
std::mutex hdf5Lib;
|
||||
};
|
||||
|
@ -11,10 +11,15 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <semaphore.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/wait.h> //wait
|
||||
#include <unistd.h>
|
||||
|
||||
// gettid added in glibc 2.30
|
||||
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
||||
#include <sys/syscall.h>
|
||||
#define gettid() syscall(SYS_gettid)
|
||||
#endif
|
||||
|
||||
/** Define Colors to print data call back in different colors for different
|
||||
* recievers */
|
||||
#define PRINT_IN_COLOR(c, f, ...) \
|
||||
@ -172,8 +177,7 @@ int main(int argc, char *argv[]) {
|
||||
(!sscanf(argv[3], "%d", &withCallback))))
|
||||
printHelp();
|
||||
|
||||
cprintf(BLUE, "Parent Process Created [ Tid: %ld ]\n",
|
||||
(long)syscall(SYS_gettid));
|
||||
cprintf(BLUE, "Parent Process Created [ Tid: %ld ]\n", (long)gettid());
|
||||
cprintf(RESET, "Number of Receivers: %d\n", numReceivers);
|
||||
cprintf(RESET, "Start TCP Port: %d\n", startTCPPort);
|
||||
cprintf(RESET, "Callback Enable: %d\n", withCallback);
|
||||
@ -215,16 +219,14 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
/** - if child process */
|
||||
else if (pid == 0) {
|
||||
cprintf(BLUE, "Child process %d [ Tid: %ld ]\n", i,
|
||||
(long)syscall(SYS_gettid));
|
||||
cprintf(BLUE, "Child process %d [ Tid: %ld ]\n", i, (long)gettid());
|
||||
|
||||
std::unique_ptr<sls::Receiver> receiver = nullptr;
|
||||
try {
|
||||
receiver = sls::make_unique<sls::Receiver>(startTCPPort + i);
|
||||
} catch (...) {
|
||||
LOG(logINFOBLUE)
|
||||
<< "Exiting Child Process [ Tid: " << syscall(SYS_gettid)
|
||||
<< " ]";
|
||||
<< "Exiting Child Process [ Tid: " << gettid() << " ]";
|
||||
throw;
|
||||
}
|
||||
/** - register callbacks. remember to set file write enable to 0
|
||||
@ -254,7 +256,7 @@ int main(int argc, char *argv[]) {
|
||||
sem_wait(&semaphore);
|
||||
sem_destroy(&semaphore);
|
||||
cprintf(BLUE, "Exiting Child Process [ Tid: %ld ]\n",
|
||||
(long)syscall(SYS_gettid));
|
||||
(long)gettid());
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
|
@ -14,9 +14,14 @@
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// gettid added in glibc 2.30
|
||||
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
||||
#include <sys/syscall.h>
|
||||
#define gettid() syscall(SYS_gettid)
|
||||
#endif
|
||||
|
||||
namespace sls {
|
||||
|
||||
Receiver::~Receiver() = default;
|
||||
@ -68,8 +73,7 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
||||
case 'v':
|
||||
std::cout << "SLS Receiver Version: " << GITBRANCH << " (0x"
|
||||
<< std::hex << APIRECEIVER << ")" << std::endl;
|
||||
LOG(logINFOBLUE)
|
||||
<< "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]";
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
case 'h':
|
||||
|
@ -8,9 +8,14 @@
|
||||
|
||||
#include <csignal> //SIGINT
|
||||
#include <semaphore.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// gettid added in glibc 2.30
|
||||
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
||||
#include <sys/syscall.h>
|
||||
#define gettid() syscall(SYS_gettid)
|
||||
#endif
|
||||
|
||||
sem_t semaphore;
|
||||
|
||||
void sigInterruptHandler(int p) { sem_post(&semaphore); }
|
||||
@ -19,7 +24,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
sem_init(&semaphore, 1, 0);
|
||||
|
||||
LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFOBLUE) << "Created [ Tid: " << gettid() << " ]";
|
||||
|
||||
// Catch signal SIGINT to close files and call destructors properly
|
||||
struct sigaction sa;
|
||||
@ -50,7 +55,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (...) {
|
||||
// pass
|
||||
}
|
||||
LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]";
|
||||
LOG(logINFO) << "Exiting Receiver";
|
||||
return 0;
|
||||
}
|
||||
|
@ -8,9 +8,14 @@
|
||||
#include "ThreadObject.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include <iostream>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// gettid added in glibc 2.30
|
||||
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
||||
#include <sys/syscall.h>
|
||||
#define gettid() syscall(SYS_gettid)
|
||||
#endif
|
||||
|
||||
ThreadObject::ThreadObject(int threadIndex, std::string threadType)
|
||||
: index(threadIndex), type(threadType) {
|
||||
LOG(logDEBUG) << type << " thread created: " << index;
|
||||
@ -39,7 +44,7 @@ void ThreadObject::StartRunning() { runningFlag = true; }
|
||||
void ThreadObject::StopRunning() { runningFlag = false; }
|
||||
|
||||
void ThreadObject::RunningThread() {
|
||||
threadId = syscall(SYS_gettid);
|
||||
threadId = gettid();
|
||||
LOG(logINFOBLUE) << "Created [ " << type << "Thread " << index
|
||||
<< ", Tid: " << threadId << "]";
|
||||
while (!killThread) {
|
||||
|
@ -21,14 +21,6 @@ class ThreadObject : private virtual slsDetectorDefs {
|
||||
protected:
|
||||
const int index{0};
|
||||
|
||||
private:
|
||||
std::atomic<bool> killThread{false};
|
||||
std::atomic<bool> runningFlag{false};
|
||||
std::thread threadObject;
|
||||
sem_t semaphore;
|
||||
const std::string type;
|
||||
pid_t threadId{0};
|
||||
|
||||
public:
|
||||
ThreadObject(int threadIndex, std::string threadType);
|
||||
virtual ~ThreadObject();
|
||||
@ -47,4 +39,11 @@ class ThreadObject : private virtual slsDetectorDefs {
|
||||
* Then it exits the thread on its own if killThread is true
|
||||
*/
|
||||
void RunningThread();
|
||||
|
||||
std::atomic<bool> killThread{false};
|
||||
std::atomic<bool> runningFlag{false};
|
||||
std::thread threadObject;
|
||||
sem_t semaphore;
|
||||
const std::string type;
|
||||
std::atomic<pid_t> threadId{0};
|
||||
};
|
||||
|
@ -65,6 +65,8 @@
|
||||
#define DEFAULT_DET_MAC2 "00:aa:bb:cc:dd:ff"
|
||||
#define DEFAULT_DET_IP2 "129.129.202.46"
|
||||
|
||||
#define LOCALHOST_IP "127.0.0.1"
|
||||
|
||||
/** default maximum string length */
|
||||
#define MAX_STR_LENGTH 1000
|
||||
#define SHORT_STR_LENGTH 20
|
||||
@ -73,7 +75,7 @@
|
||||
|
||||
#define DEFAULT_STREAMING_TIMER_IN_MS 500
|
||||
|
||||
#define NUM_RX_THREAD_IDS 8
|
||||
#define NUM_RX_THREAD_IDS 9
|
||||
|
||||
#ifdef __cplusplus
|
||||
class slsDetectorDefs {
|
||||
@ -564,7 +566,7 @@ enum streamingInterface {
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
//operators needed in ToString
|
||||
// operators needed in ToString
|
||||
inline slsDetectorDefs::streamingInterface
|
||||
operator|(const slsDetectorDefs::streamingInterface &a,
|
||||
const slsDetectorDefs::streamingInterface &b) {
|
||||
@ -579,8 +581,6 @@ operator&(const slsDetectorDefs::streamingInterface &a,
|
||||
static_cast<int32_t>(b));
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -361,6 +361,8 @@ enum detFuncs {
|
||||
F_SET_RECEIVER_STREAMING_HWM,
|
||||
F_RECEIVER_SET_ALL_THRESHOLD,
|
||||
F_RECEIVER_SET_DATASTREAM,
|
||||
F_GET_RECEIVER_ARPING,
|
||||
F_SET_RECEIVER_ARPING,
|
||||
|
||||
NUM_REC_FUNCTIONS
|
||||
};
|
||||
@ -720,6 +722,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_SET_RECEIVER_STREAMING_HWM: return "F_SET_RECEIVER_STREAMING_HWM";
|
||||
case F_RECEIVER_SET_ALL_THRESHOLD: return "F_RECEIVER_SET_ALL_THRESHOLD";
|
||||
case F_RECEIVER_SET_DATASTREAM: return "F_RECEIVER_SET_DATASTREAM";
|
||||
case F_GET_RECEIVER_ARPING: return "F_GET_RECEIVER_ARPING";
|
||||
case F_SET_RECEIVER_ARPING: return "F_SET_RECEIVER_ARPING";
|
||||
|
||||
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
|
||||
default: return "Unknown Function";
|
||||
|
@ -6,10 +6,10 @@
|
||||
#define APIRECEIVER 0x211124
|
||||
#define APIGUI 0x211124
|
||||
|
||||
#define APICTB 0x220203
|
||||
#define APIGOTTHARD 0x220203
|
||||
#define APIGOTTHARD2 0x220203
|
||||
#define APIJUNGFRAU 0x220203
|
||||
#define APIMYTHEN3 0x220203
|
||||
#define APIMOENCH 0x220202
|
||||
#define APIEIGER 0x220203
|
||||
#define APICTB 0x220223
|
||||
#define APIGOTTHARD 0x220223
|
||||
#define APIGOTTHARD2 0x220223
|
||||
#define APIJUNGFRAU 0x220223
|
||||
#define APIMYTHEN3 0x220223
|
||||
#define APIMOENCH 0x220223
|
||||
#define APIEIGER 0x220223
|
||||
|
Reference in New Issue
Block a user