clang-tidy

This commit is contained in:
froejdh_e
2025-12-16 14:26:14 +01:00
parent 497b3ed00e
commit ec546bf4fb
65 changed files with 910 additions and 910 deletions
+3 -3
View File
@@ -38,7 +38,7 @@ void Arping::SetInterfacesAndIps(const int index, const std::string &interface,
// create commands to arping
std::ostringstream os;
os << "arping -c 1 -U -I " << interface << " " << ip;
std::string cmd = os.str();
std::string const cmd = os.str();
commands[index] = cmd;
}
@@ -84,7 +84,7 @@ void Arping::StopProcess() {
void Arping::ProcessExecution() {
while (true) {
std::string error = ExecuteCommands();
std::string const error = ExecuteCommands();
// just print (was already tested at Process start)
if (!error.empty()) {
LOG(logERROR) << error;
@@ -101,7 +101,7 @@ void Arping::TestForErrors() {
"Could not arping. Interface not set up in arping Process");
}
// test if arping commands throw an error
std::string error = ExecuteCommands();
std::string const error = ExecuteCommands();
if (!error.empty()) {
throw RuntimeError(error);
}
+19 -19
View File
@@ -57,14 +57,14 @@ std::string ClientInterface::getReceiverVersion() { return APIRECEIVER; }
/***callback functions***/
void ClientInterface::registerCallBackStartAcquisition(
void (*func)(const startCallbackHeader, void *), void *arg) {
std::lock_guard<std::mutex> lock(callbackMutex);
std::lock_guard<std::mutex> const lock(callbackMutex);
startAcquisitionCallBack = func;
pStartAcquisition = arg;
}
void ClientInterface::registerCallBackAcquisitionFinished(
void (*func)(const endCallbackHeader, void *), void *arg) {
std::lock_guard<std::mutex> lock(callbackMutex);
std::lock_guard<std::mutex> const lock(callbackMutex);
acquisitionFinishedCallBack = func;
pAcquisitionFinished = arg;
}
@@ -73,7 +73,7 @@ void ClientInterface::registerCallBackRawDataReady(
void (*func)(sls_receiver_header &, dataCallbackHeader, char *, size_t &,
void *),
void *arg) {
std::lock_guard<std::mutex> lock(callbackMutex);
std::lock_guard<std::mutex> const lock(callbackMutex);
rawDataReadyCallBack = func;
pRawDataReady = arg;
}
@@ -338,15 +338,15 @@ int ClientInterface::setup_receiver(Interface &socket) {
// udp setup
// update retvals only if detmac is not the same as in detector
if (arg.udp_dstip != 0) {
MacAddr r = setUdpIp(IpAddr(arg.udp_dstip));
MacAddr detMac{arg.udp_dstmac};
MacAddr const r = setUdpIp(IpAddr(arg.udp_dstip));
MacAddr const detMac{arg.udp_dstmac};
if (detMac != r) {
retvals[0] = r;
}
}
if (arg.udp_dstip2 != 0) {
MacAddr r = setUdpIp2(IpAddr(arg.udp_dstip2));
MacAddr detMac{arg.udp_dstmac2};
MacAddr const r = setUdpIp2(IpAddr(arg.udp_dstip2));
MacAddr const detMac{arg.udp_dstmac2};
if (detMac != r) {
retvals[1] = r;
}
@@ -467,7 +467,7 @@ void ClientInterface::setDetectorType(detectorType arg) {
}
// callbacks after (in setdetectortype, the object is reinitialized)
{
std::lock_guard<std::mutex> lock(callbackMutex);
std::lock_guard<std::mutex> const lock(callbackMutex);
if (startAcquisitionCallBack != nullptr)
impl()->registerCallBackStartAcquisition(startAcquisitionCallBack,
pStartAcquisition);
@@ -586,8 +586,8 @@ int ClientInterface::set_num_digital_samples(Interface &socket) {
int ClientInterface::set_exptime(Interface &socket) {
int64_t args[2]{-1, -1};
socket.Receive(args);
int gateIndex = static_cast<int>(args[0]);
ns value = std::chrono::nanoseconds(args[1]);
int const gateIndex = static_cast<int>(args[0]);
ns const value = std::chrono::nanoseconds(args[1]);
LOG(logDEBUG1) << "Setting exptime to " << ToString(value)
<< " (gateIndex: " << gateIndex << ")";
switch (gateIndex) {
@@ -635,7 +635,7 @@ int ClientInterface::set_period(Interface &socket) {
int ClientInterface::set_subexptime(Interface &socket) {
auto value = std::chrono::nanoseconds(socket.Receive<int64_t>());
LOG(logDEBUG1) << "Setting period to " << ToString(value);
ns subdeadtime = impl()->getSubPeriod() - impl()->getSubExpTime();
ns const subdeadtime = impl()->getSubPeriod() - impl()->getSubExpTime();
impl()->setSubExpTime(value);
impl()->setSubPeriod(impl()->getSubExpTime() + subdeadtime);
return socket.Send(OK);
@@ -780,7 +780,7 @@ int ClientInterface::get_file_dir(Interface &socket) {
}
int ClientInterface::set_file_name(Interface &socket) {
std::string fname = socket.Receive(MAX_STR_LENGTH);
std::string const fname = socket.Receive(MAX_STR_LENGTH);
if (fname.empty()) {
throw RuntimeError("Cannot set empty file name");
}
@@ -1115,7 +1115,7 @@ int ClientInterface::set_additional_json_header(Interface &socket) {
}
int ClientInterface::get_additional_json_header(Interface &socket) {
std::map<std::string, std::string> json = impl()->getAdditionalJsonHeader();
std::map<std::string, std::string> const json = impl()->getAdditionalJsonHeader();
LOG(logDEBUG1) << "additional json header:" << ToString(json);
std::ostringstream oss;
for (auto &it : json) {
@@ -1319,7 +1319,7 @@ int ClientInterface::set_quad_type(Interface &socket) {
std::string(e.what()) + ']');
}
}
int retval = impl()->getQuad() ? 1 : 0;
int const retval = impl()->getQuad() ? 1 : 0;
validate(quadEnable, retval, "set quad", DEC);
LOG(logDEBUG1) << "quad retval:" << retval;
return socket.Send(OK);
@@ -1336,7 +1336,7 @@ int ClientInterface::set_read_n_rows(Interface &socket) {
LOG(logDEBUG1) << "Setting number of rows:" << arg;
impl()->setReadNRows(arg);
}
int retval = impl()->getReadNRows();
int const retval = impl()->getReadNRows();
validate(arg, retval, "set number of rows", DEC);
LOG(logDEBUG1) << "read number of rows:" << retval;
return socket.Send(OK);
@@ -1516,7 +1516,7 @@ int ClientInterface::set_additional_json_parameter(Interface &socket) {
}
int ClientInterface::get_additional_json_parameter(Interface &socket) {
std::string key = socket.Receive(SHORT_STR_LENGTH);
std::string const key = socket.Receive(SHORT_STR_LENGTH);
std::string value = impl()->getAdditionalJsonParameter(key);
value.resize(SHORT_STR_LENGTH);
return socket.sendResult(value);
@@ -1541,7 +1541,7 @@ int ClientInterface::set_num_gates(Interface &socket) {
int ClientInterface::set_gate_delay(Interface &socket) {
int64_t args[2]{-1, -1};
socket.Receive(args);
int gateIndex = static_cast<int>(args[0]);
int const gateIndex = static_cast<int>(args[0]);
auto value = std::chrono::nanoseconds(args[1]);
LOG(logDEBUG1) << "Setting gate delay to " << ToString(value)
<< " (gateIndex: " << gateIndex << ")";
@@ -1657,7 +1657,7 @@ int ClientInterface::set_all_threshold(Interface &socket) {
int ClientInterface::set_detector_datastream(Interface &socket) {
int args[2]{-1, -1};
socket.Receive(args);
portPosition port = static_cast<portPosition>(args[0]);
portPosition const port = static_cast<portPosition>(args[0]);
switch (port) {
case LEFT:
case RIGHT:
@@ -1665,7 +1665,7 @@ int ClientInterface::set_detector_datastream(Interface &socket) {
default:
throw RuntimeError("Invalid port type");
}
bool enable = static_cast<int>(args[1]);
bool const enable = static_cast<int>(args[1]);
LOG(logDEBUG1) << "Setting datastream (" << ToString(port) << ") to "
<< ToString(enable);
if (detType != EIGER)
@@ -21,7 +21,7 @@ ParsedOptions CommandLineOptions::parse(const std::vector<std::string> &args) {
for (const auto &arg : args) {
argv.push_back(const_cast<char *>(arg.c_str()));
}
int argc = static_cast<int>(argv.size());
int const argc = static_cast<int>(argv.size());
return parse(argc, argv.data());
}
@@ -76,7 +76,7 @@ ParsedOptions CommandLineOptions::parse(int argc, char *argv[]) {
}
// parse deprecated arguments
std::vector<std::string> args(argv, argv + argc);
std::vector<std::string> const args(argv, argv + argc);
auto [p, n, o] = ParseDeprecated(args);
// set options
base.port = p;
@@ -251,7 +251,7 @@ void CommandLineOptions::handleAppSpecificOption(int opt, const char *optarg,
std::tuple<uint16_t, uint16_t, bool>
CommandLineOptions::ParseDeprecated(const std::vector<std::string> &args) {
size_t nargs = args.size();
size_t const nargs = args.size();
if (nargs != 1 && nargs != 3 && nargs != 4) {
throw sls::RuntimeError("Invalid number of arguments.");
}
@@ -266,8 +266,8 @@ CommandLineOptions::ParseDeprecated(const std::vector<std::string> &args) {
}
// parse deprecated arguments
uint16_t p = parsePort(args[1].c_str());
uint16_t n = parseNumReceivers(args[2].c_str());
uint16_t const p = parsePort(args[1].c_str());
uint16_t const n = parseNumReceivers(args[2].c_str());
bool o = false;
if (nargs == 4) {
try {
+23 -23
View File
@@ -93,7 +93,7 @@ void DataProcessor::SetNumberofTotalFrames(uint64_t value) {
void DataProcessor::SetAdditionalJsonHeader(
const std::map<std::string, std::string> &json) {
std::lock_guard<std::mutex> lock(additionalJsonMutex);
std::lock_guard<std::mutex> const lock(additionalJsonMutex);
additionalJsonHeader = json;
isAdditionalJsonUpdated = true;
}
@@ -254,7 +254,7 @@ std::string DataProcessor::CreateMasterFile(
attr->framesInFile = numFramesCaught;
std::unique_ptr<File> masterFile{nullptr};
std::unique_ptr<File> const masterFile{nullptr};
switch (fileFormatType) {
#ifdef HDF5C
case HDF5:
@@ -325,11 +325,11 @@ void DataProcessor::StopProcessing(char *buf) {
void DataProcessor::ProcessAnImage(sls_receiver_header &header, size_t &size,
size_t &firstImageIndex, char *data) {
uint64_t fnum = header.detHeader.frameNumber;
uint64_t const fnum = header.detHeader.frameNumber;
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
currentFrameIndex = fnum;
numFramesCaught++;
uint32_t nump = header.detHeader.packetNumber;
uint32_t const nump = header.detHeader.packetNumber;
if (!startedFlag) {
RecordFirstIndex(fnum);
@@ -390,16 +390,16 @@ void DataProcessor::ProcessAnImage(sls_receiver_header &header, size_t &size,
// callbacks
if (rawDataReadyCallBack != nullptr) {
uint64_t frameIndex = fnum - firstIndex;
uint64_t const frameIndex = fnum - firstIndex;
// update local copy only if it was updated (to prevent locking each
// time)
if (isAdditionalJsonUpdated) {
std::lock_guard<std::mutex> lock(additionalJsonMutex);
std::lock_guard<std::mutex> const lock(additionalJsonMutex);
localAdditionalJsonHeader = additionalJsonHeader;
isAdditionalJsonUpdated = false;
}
dataCallbackHeader callbackHeader = {
dataCallbackHeader const callbackHeader = {
udpPortNumber,
{static_cast<int>(generalData->nPixelsX),
static_cast<int>(generalData->nPixelsY)},
@@ -446,7 +446,7 @@ bool DataProcessor::CheckTimer() {
auto elapsed_s = (end.tv_sec - timerbegin.tv_sec) +
(end.tv_nsec - timerbegin.tv_nsec) / 1e9;
double timer_s = streamingTimerInMs / 1e3;
double const timer_s = streamingTimerInMs / 1e3;
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
<< " seconds";
@@ -480,7 +480,7 @@ void DataProcessor::registerCallBackRawDataReady(
void DataProcessor::PadMissingPackets(sls_receiver_header header, char *data) {
LOG(logDEBUG) << index << ": Padding Missing Packets";
uint32_t pperFrame = generalData->packetsPerFrame;
uint32_t const pperFrame = generalData->packetsPerFrame;
uint32_t nmissing = pperFrame - header.detHeader.packetNumber;
sls_bitset pmask = header.packetsMask;
@@ -489,7 +489,7 @@ void DataProcessor::PadMissingPackets(sls_receiver_header header, char *data) {
if (generalData->detType == GOTTHARD2 && index != 0) {
dsize = generalData->vetoDataSize;
}
uint32_t corrected_dsize =
uint32_t const corrected_dsize =
dsize - ((pperFrame * dsize) - generalData->imageSize);
LOG(logDEBUG1) << "bitmask: " << pmask.to_string();
@@ -571,7 +571,7 @@ void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
const auto ctbDbitList = generalData->ctbDbitList;
// TODO! (Erik) Refactor and add tests
int ctbDigitalDataBytes = nDigitalDataBytes - ctbDbitOffset;
int const ctbDigitalDataBytes = nDigitalDataBytes - ctbDbitOffset;
// no digital data
if (ctbDigitalDataBytes == 0) {
@@ -618,13 +618,13 @@ void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
++dest;
}
uint8_t byte_index = bi / 8;
uint8_t const byte_index = bi / 8;
// loop through the frame digital data
for (auto *ptr = source + byte_index;
ptr < (source + 8 * numDigitalSamples); ptr += 8) {
// get selected bit from each 8 bit
uint8_t bit = (*ptr >> bi % 8) & 1;
uint8_t const bit = (*ptr >> bi % 8) & 1;
*dest |= bit << bitoffset; // stored as least significant
++bitoffset;
// extract destination in 8 bit batches
@@ -648,9 +648,9 @@ void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
// loop through digital bit enable vector
for (auto bi : ctbDbitList) {
// get selected bit from each 64 bit
uint8_t byte_index = bi / 8;
uint8_t const byte_index = bi / 8;
uint8_t bit = (*(ptr + byte_index) >> (bi % 8)) & 1;
uint8_t const bit = (*(ptr + byte_index) >> (bi % 8)) & 1;
*dest |= bit << bitoffset;
++bitoffset;
// extract destination in 8 bit batches
@@ -684,12 +684,12 @@ void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
void DataProcessor::CropImage(size_t &size, char *data) {
LOG(logDEBUG1) << "Cropping Image to ROI " << ToString(portRoi);
int nPixelsX = generalData->nPixelsX;
int xmin = portRoi.xmin;
int xmax = portRoi.xmax;
int const nPixelsX = generalData->nPixelsX;
int const xmin = portRoi.xmin;
int const xmax = portRoi.xmax;
int ymin = portRoi.ymin;
int ymax = portRoi.ymax;
int xwidth = xmax - xmin + 1;
int const ymax = portRoi.ymax;
int const xwidth = xmax - xmin + 1;
int ywidth = ymax - ymin + 1;
if (ymin == -1 || ymax == -1) {
ywidth = 1;
@@ -697,11 +697,11 @@ void DataProcessor::CropImage(size_t &size, char *data) {
}
// calculate total roi size
double bytesPerPixel = generalData->dynamicRange / 8.00;
int startOffset = (int)((nPixelsX * ymin + xmin) * bytesPerPixel);
double const bytesPerPixel = generalData->dynamicRange / 8.00;
int const startOffset = (int)((nPixelsX * ymin + xmin) * bytesPerPixel);
// write size into memory
std::size_t roiImageSize = xwidth * ywidth * bytesPerPixel;
std::size_t const roiImageSize = xwidth * ywidth * bytesPerPixel;
LOG(logDEBUG) << "roiImageSize:" << roiImageSize;
size = roiImageSize;
+6 -6
View File
@@ -48,7 +48,7 @@ void DataStreamer::SetNumberofTotalFrames(uint64_t value) {
void DataStreamer::SetAdditionalJsonHeader(
const std::map<std::string, std::string> &json) {
std::lock_guard<std::mutex> lock(additionalJsonMutex);
std::lock_guard<std::mutex> const lock(additionalJsonMutex);
additionalJsonHeader = json;
isAdditionalJsonUpdated = true;
}
@@ -77,7 +77,7 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum, size_t firstImageIndex) {
}
void DataStreamer::CreateZmqSockets(uint16_t port, int hwm) {
uint16_t portnum = port + index;
uint16_t const portnum = port + index;
try {
zmqSocket = new ZmqSocket(portnum);
@@ -149,7 +149,7 @@ void DataStreamer::StopProcessing(char *buf) {
void DataStreamer::ProcessAnImage(sls_detector_header header, size_t size,
char *data) {
uint64_t fnum = header.frameNumber;
uint64_t const fnum = header.frameNumber;
LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
if (!SendDataHeader(header, size, generalData->nPixelsX,
@@ -177,8 +177,8 @@ int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
zHeader.data = true;
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
uint64_t frameIndex = header.frameNumber - firstIndex;
uint64_t acquisitionIndex = header.frameNumber;
uint64_t const frameIndex = header.frameNumber - firstIndex;
uint64_t const acquisitionIndex = header.frameNumber;
zHeader.dynamicRange = generalData->dynamicRange;
zHeader.fileIndex = fileIndex;
@@ -212,7 +212,7 @@ int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
// update local copy only if it was updated (to prevent locking each time)
if (isAdditionalJsonUpdated) {
std::lock_guard<std::mutex> lock(additionalJsonMutex);
std::lock_guard<std::mutex> const lock(additionalJsonMutex);
localAdditionalJsonHeader = additionalJsonHeader;
isAdditionalJsonUpdated = false;
}
+6 -6
View File
@@ -41,13 +41,13 @@ void Fifo::CreateFifos(size_t fifoItemSize) {
fifoFree = new CircularFifo<char>(fifoDepth);
fifoStream = new CircularFifo<char>(fifoDepth);
// allocate memory
size_t mem_len = fifoItemSize * (size_t)fifoDepth * sizeof(char);
size_t const mem_len = fifoItemSize * (size_t)fifoDepth * sizeof(char);
memory = (char *)malloc(mem_len);
if (memory == nullptr) {
throw RuntimeError("Could not allocate memory for fifos");
}
memset(memory, 0, mem_len);
int pagesize = getpagesize();
int const pagesize = getpagesize();
for (size_t i = 0; i < mem_len; i += pagesize) {
strcpy(memory + i, "memory");
}
@@ -84,14 +84,14 @@ void Fifo::DestroyFifos() {
void Fifo::FreeAddress(char *&address) { fifoFree->push(address); }
void Fifo::GetNewAddress(char *&address) {
int temp = fifoFree->getDataValue();
int const temp = fifoFree->getDataValue();
if (temp < status_fifoFree)
status_fifoFree = temp;
fifoFree->pop(address);
}
void Fifo::PushAddress(char *&address) {
int temp = fifoBound->getDataValue();
int const temp = fifoBound->getDataValue();
if (temp > status_fifoBound)
status_fifoBound = temp;
while (!fifoBound->push(address))
@@ -108,13 +108,13 @@ void Fifo::PushAddressToStream(char *&address) { fifoStream->push(address); }
void Fifo::PopAddressToStream(char *&address) { fifoStream->pop(address); }
int Fifo::GetMaxLevelForFifoBound() {
int temp = status_fifoBound;
int const temp = status_fifoBound;
status_fifoBound = 0;
return temp;
}
int Fifo::GetMinLevelForFifoFree() {
int temp = status_fifoFree;
int const temp = status_fifoFree;
status_fifoFree = fifoDepth;
return temp;
}
@@ -65,7 +65,7 @@ FrameStatus *global_frame_status = nullptr;
void cleanup() {
if (global_frame_status) {
std::lock_guard<std::mutex> lock(global_frame_status->mtx);
std::lock_guard<std::mutex> const lock(global_frame_status->mtx);
for (auto &outer_pair : global_frame_status->frames) {
for (auto &inner_pair : outer_pair.second) {
for (zmq_msg_t *msg : inner_pair.second) {
@@ -146,11 +146,11 @@ std::set<uint64_t> get_valid_fnums(const PortFrameMap &port_frame_map) {
}
int zmq_send_multipart(void *socket, const ZmqMsgList &messages) {
size_t num_messages = messages.size();
size_t const num_messages = messages.size();
for (size_t i = 0; i != num_messages; ++i) {
zmq_msg_t *msg = messages[i];
// determine flags: ZMQ_SNDMORE for all messages except the last
int flags = (i == num_messages - 1) ? 0 : ZMQ_SNDMORE;
int const flags = (i == num_messages - 1) ? 0 : ZMQ_SNDMORE;
if (zmq_msg_send(msg, socket, flags) == -1) {
LOG(sls::logERROR)
<< "Error sending message: " << zmq_strerror(zmq_errno());
@@ -164,7 +164,7 @@ void Correlate(FrameStatus *stat) {
void *context = zmq_ctx_new();
void *socket = zmq_socket(context, ZMQ_PUSH);
int rc = zmq_bind(socket, "tcp://*:5555");
int const rc = zmq_bind(socket, "tcp://*:5555");
if (rc != 0) {
LOG(sls::logERROR) << "failed to bind";
}
@@ -172,7 +172,7 @@ void Correlate(FrameStatus *stat) {
while (true) {
sem_wait(&(stat->available));
{
std::lock_guard<std::mutex> lock(stat->mtx);
std::lock_guard<std::mutex> const lock(stat->mtx);
if (stat->terminate) {
break;
@@ -304,10 +304,10 @@ void StartAcquisitionCallback(
}
oss << "}\n";
std::string message = oss.str();
std::string const message = oss.str();
LOG(sls::logDEBUG) << "Start Acquisition message:" << std::endl << message;
int length = message.length();
int const length = message.length();
char *hdata = new char[length];
memcpy(hdata, message.c_str(), length);
zmq_msg_t *hmsg = new zmq_msg_t;
@@ -316,7 +316,7 @@ void StartAcquisitionCallback(
// push zmq msg into stat to be processed
FrameStatus *stat = static_cast<FrameStatus *>(objectPointer);
{
std::lock_guard<std::mutex> lock(stat->mtx);
std::lock_guard<std::mutex> const lock(stat->mtx);
stat->headers.push_back(hmsg);
stat->starting = true;
// clean up old frames
@@ -355,8 +355,8 @@ void AcquisitionFinishedCallback(
<< sls::ToString(callbackHeader.completeFrames)
<< ", \"lastFrameIndex\":"
<< sls::ToString(callbackHeader.lastFrameIndex) << "}\n";
std::string message = oss.str();
int length = message.length();
std::string const message = oss.str();
int const length = message.length();
LOG(sls::logDEBUG) << "Acquisition Finished message:" << std::endl
<< message;
@@ -368,7 +368,7 @@ void AcquisitionFinishedCallback(
// push zmq msg into stat to be processed
FrameStatus *stat = static_cast<FrameStatus *>(objectPointer);
{
std::lock_guard<std::mutex> lock(stat->mtx);
std::lock_guard<std::mutex> const lock(stat->mtx);
stat->ends.push_back(hmsg);
}
sem_post(&stat->available);
@@ -379,7 +379,7 @@ void GetDataCallback(slsDetectorDefs::sls_receiver_header &header,
char *dataPointer, size_t &imageSize,
void *objectPointer) {
slsDetectorDefs::sls_detector_header detectorHeader = header.detHeader;
slsDetectorDefs::sls_detector_header const detectorHeader = header.detHeader;
if (printHeadersLevel < sls::logDEBUG) {
// print in different color for each udp port
@@ -468,11 +468,11 @@ void GetDataCallback(slsDetectorDefs::sls_receiver_header &header,
oss << " } ";
}
oss << "}\n";
std::string message = oss.str();
std::string const message = oss.str();
LOG(sls::logDEBUG) << "Data message:" << std::endl << message;
// creating header part of data packet
int length = message.length();
int const length = message.length();
char *hdata = new char[length];
memcpy(hdata, message.c_str(), length);
zmq_msg_t *hmsg = new zmq_msg_t;
@@ -486,7 +486,7 @@ void GetDataCallback(slsDetectorDefs::sls_receiver_header &header,
// push both parts into stat to be processed
FrameStatus *stat = static_cast<FrameStatus *>(objectPointer);
{
std::lock_guard<std::mutex> lock(stat->mtx);
std::lock_guard<std::mutex> const lock(stat->mtx);
stat->frames[callbackHeader.udpPort][header.detHeader.frameNumber]
.push_back(hmsg);
stat->frames[callbackHeader.udpPort][header.detHeader.frameNumber]
@@ -544,7 +544,7 @@ int main(int argc, char *argv[]) {
std::exception_ptr threadException = nullptr;
for (int i = 0; i != f.numReceivers; ++i) {
uint16_t port = f.port + i;
uint16_t const port = f.port + i;
sem_t *semaphore = &semaphores[i];
threads.emplace_back(
[i, semaphore, port, user_data, &threadException]() {
@@ -581,7 +581,7 @@ int main(int argc, char *argv[]) {
cleanup();
{
std::lock_guard<std::mutex> lock(stat.mtx);
std::lock_guard<std::mutex> const lock(stat.mtx);
stat.terminate = true;
sem_post(&stat.available);
}
+23 -23
View File
@@ -238,9 +238,9 @@ const slsDetectorDefs::xy Implementation::GetPortGeometry() const {
}
void Implementation::setDetectorSize(const slsDetectorDefs::xy size) {
xy portGeometry = GetPortGeometry();
xy const portGeometry = GetPortGeometry();
std::string log_message = "Detector Size (ports): (";
std::string const log_message = "Detector Size (ports): (";
numModules = size;
numPorts.x = portGeometry.x * numModules.x;
numPorts.y = portGeometry.y * numModules.y;
@@ -262,7 +262,7 @@ void Implementation::setModulePositionId(const int id) {
LOG(logINFO) << "Module Position Id:" << modulePos;
// update zmq port
xy portGeometry = GetPortGeometry();
xy const portGeometry = GetPortGeometry();
streamingPort = DEFAULT_ZMQ_RX_PORTNO + modulePos * portGeometry.x;
assert(numModules.y != 0);
@@ -285,14 +285,14 @@ void Implementation::setModulePositionId(const int id) {
void Implementation::setRow(const int value) {
for (unsigned int i = 0; i < listener.size(); ++i) {
int col = listener[i]->GetHardCodedPosition().second;
int const col = listener[i]->GetHardCodedPosition().second;
listener[i]->SetHardCodedPosition(value, col);
}
}
void Implementation::setColumn(const int value) {
for (unsigned int i = 0; i < listener.size(); ++i) {
int row = listener[i]->GetHardCodedPosition().first;
int const row = listener[i]->GetHardCodedPosition().first;
listener[i]->SetHardCodedPosition(row, value);
}
}
@@ -405,16 +405,16 @@ std::vector<slsDetectorDefs::ROI> Implementation::getPortROIs() const {
}
void Implementation::ResetRois() {
int numports = generalData->numUDPInterfaces;
std::vector<ROI> rois(numports);
std::vector<ROI> multiRoi(1);
int const numports = generalData->numUDPInterfaces;
std::vector<ROI> const rois(numports);
std::vector<ROI> const multiRoi(1);
setPortROIs(rois);
setMultiROIMetadata(multiRoi);
}
void Implementation::setPortROIs(const std::vector<defs::ROI> &args) {
int nx = static_cast<int>(generalData->nPixelsX);
int ny = static_cast<int>(generalData->nPixelsY);
int const nx = static_cast<int>(generalData->nPixelsX);
int const ny = static_cast<int>(generalData->nPixelsY);
// validate rois
for (auto &it : args) {
if (it.completeRoi() || it.noRoi()) {
@@ -614,7 +614,7 @@ double Implementation::getProgress() const {
std::vector<int64_t> Implementation::getNumMissingPackets() const {
std::vector<int64_t> mp(generalData->numUDPInterfaces);
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
int np = generalData->packetsPerFrame;
int const np = generalData->packetsPerFrame;
uint64_t totnp = np;
// ReadNRows
if (readNRows != (int)generalData->maxRowsPerReadout) {
@@ -646,7 +646,7 @@ void Implementation::startReceiver() {
for (size_t i = 0; i != listener.size(); ++i) {
udpPort.push_back(udpPortNum[i]);
}
startCallbackHeader callbackHeader = {
startCallbackHeader const callbackHeader = {
udpPort,
generalData->dynamicRange,
numPorts,
@@ -731,7 +731,7 @@ void Implementation::stopReceiver() {
// print summary
uint64_t tot = 0;
for (int i = 0; i < generalData->numUDPInterfaces; i++) {
int nf = listener[i]->GetNumCompleteFramesCaught();
int const nf = listener[i]->GetNumCompleteFramesCaught();
tot += nf;
std::string mpMessage = std::to_string(mp[i]);
if (mp[i] < 0) {
@@ -756,7 +756,7 @@ void Implementation::stopReceiver() {
summary = os.str();
}
TLogLevel lev = ((mp[i]) > 0) ? logINFORED : logINFOGREEN;
TLogLevel const lev = ((mp[i]) > 0) ? logINFORED : logINFOGREEN;
LOG(lev) << "Summary of Port " << udpPortNum[i] << " (" << eth[i]
<< ')' << summary;
}
@@ -774,7 +774,7 @@ void Implementation::stopReceiver() {
lastFrameIndexCaught.push_back(
listener[i]->GetLastFrameIndexCaught());
}
endCallbackHeader callHeader = {udpPort, completeFramesCaught,
endCallbackHeader const callHeader = {udpPort, completeFramesCaught,
lastFrameIndexCaught};
acquisitionFinishedCallBack(callHeader, pAcquisitionFinished);
} catch (const std::exception &e) {
@@ -852,7 +852,7 @@ void Implementation::ResetParametersforNewAcquisition() {
if (dataStreamEnable) {
std::ostringstream os;
os << filePath << '/' << fileName;
std::string fnametostream = os.str();
std::string const fnametostream = os.str();
for (const auto &it : dataStreamer)
it->ResetParametersforNewAcquisition(fnametostream);
}
@@ -884,7 +884,7 @@ void Implementation::SetupWriter() {
std::ostringstream os;
os << filePath << "/" << fileName << "_d"
<< (modulePos * generalData->numUDPInterfaces + i);
std::string fileNamePrefix = os.str();
std::string const fileNamePrefix = os.str();
dataProcessor[i]->CreateFirstFiles(fileNamePrefix, fileIndex,
overwriteEnable, silentMode,
detectorDataStream[i]);
@@ -919,8 +919,8 @@ void Implementation::StartMasterWriter() {
// complete ROI (for each port TODO?)
if (multiRoiMetadata.size() == 1 &&
multiRoiMetadata[0].completeRoi()) {
int nTotalPixelsX = (generalData->nPixelsX * numPorts.x);
int nTotalPixelsY = (generalData->nPixelsY * numPorts.y);
int const nTotalPixelsX = (generalData->nPixelsX * numPorts.x);
int const nTotalPixelsY = (generalData->nPixelsY * numPorts.y);
if (nTotalPixelsY == 1) {
masterAttributes.rois.push_back(ROI{0, nTotalPixelsX - 1});
} else {
@@ -1180,7 +1180,7 @@ int Implementation::getUDPSocketBufferSize() const {
}
void Implementation::setUDPSocketBufferSize(const int s) {
size_t listSize = listener.size();
size_t const listSize = listener.size();
if ((generalData->detType == JUNGFRAU || generalData->detType == MOENCH ||
generalData->detType == GOTTHARD2) &&
(int)listSize != generalData->numUDPInterfaces) {
@@ -1572,7 +1572,7 @@ void Implementation::setCounterMask(const uint32_t i) {
SetupFifoStructure();
}
LOG(logINFO) << "Counter mask: " << ToStringHex(generalData->counterMask);
int ncounters = __builtin_popcount(generalData->counterMask);
int const ncounters = __builtin_popcount(generalData->counterMask);
LOG(logINFO) << "Number of counters: " << ncounters;
}
@@ -1661,13 +1661,13 @@ void Implementation::setActivate(bool enable) {
}
bool Implementation::getDetectorDataStream(const portPosition port) const {
int index = (port == LEFT ? 0 : 1);
int const index = (port == LEFT ? 0 : 1);
return detectorDataStream[index];
}
void Implementation::setDetectorDataStream(const portPosition port,
const bool enable) {
int index = (port == LEFT ? 0 : 1);
int const index = (port == LEFT ? 0 : 1);
detectorDataStream10GbE[index] = enable;
LOG(logINFO) << "Detector 10GbE datastream (" << ToString(port)
<< " Port): " << ToString(detectorDataStream10GbE[index]);
+9 -9
View File
@@ -193,10 +193,10 @@ void Listener::DeleteUDPSocket() {
void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int &actualSize) {
// custom setup (s != 0)
// default setup at startup (s = 0)
int size = (s == 0 ? generalData->udpSocketBufferSize : s);
int const size = (s == 0 ? generalData->udpSocketBufferSize : s);
LOG(logINFO) << "Testing UDP Socket Buffer size " << size
<< " with test port " << udpPortNumber;
int previousSize = generalData->udpSocketBufferSize;
int const previousSize = generalData->udpSocketBufferSize;
generalData->udpSocketBufferSize = size;
if (disabledPort) {
@@ -217,7 +217,7 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int &actualSize) {
std::string ip;
if (eth.length() > 0)
ip = InterfaceNameToIp(eth).str();
UdpRxSocket g(udpPortNumber, packetSize,
UdpRxSocket const g(udpPortNumber, packetSize,
(ip.empty() ? nullptr : ip.c_str()),
generalData->udpSocketBufferSize);
@@ -268,7 +268,7 @@ void Listener::ThreadExecution() {
// reset header and size and get data
memset(memImage, 0, IMAGE_STRUCTURE_HEADER_SIZE);
int rc = ListenToAnImage(memImage->header, memImage->data);
int const rc = ListenToAnImage(memImage->header, memImage->data);
// end of acquisition or discarding image
if (rc <= 0) {
@@ -320,9 +320,9 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header &dstHeader,
hsize = generalData->vetoHsize;
standardHeader = false;
}
uint32_t pperFrame = generalData->packetsPerFrame;
uint32_t const pperFrame = generalData->packetsPerFrame;
bool isHeaderEmpty = true;
uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - imageSize);
uint32_t const corrected_dsize = dsize - ((pperFrame * dsize) - imageSize);
sls_detector_header *srcDetHeader = nullptr;
// carry over packet
@@ -516,9 +516,9 @@ void Listener::PrintFifoStatistics() {
<< " packetsperframe:" << generalData->packetsPerFrame;
// calculate packet loss
int64_t totalP = numFramesStatistic * (generalData->packetsPerFrame);
int64_t loss = totalP - numPacketsStatistic;
int lossPercent = ((double)loss / (double)totalP) * 100.00;
int64_t const totalP = numFramesStatistic * (generalData->packetsPerFrame);
int64_t const loss = totalP - numPacketsStatistic;
int const lossPercent = ((double)loss / (double)totalP) * 100.00;
numPacketsStatistic = 0;
numFramesStatistic = 0;
+1 -1
View File
@@ -756,7 +756,7 @@ void MasterAttributes::WriteHDF5Version(H5::H5File *fd) {
#endif
void MasterAttributes::WriteBinaryTimestamp(writer *w) {
time_t t = std::time(nullptr);
time_t const t = std::time(nullptr);
std::string sTime(ctime(&t));
std::replace(sTime.begin(), sTime.end(), '\n', '\0');
WriteBinary(w, N_TIMESTAMP.data(), sTime);
+4 -4
View File
@@ -76,7 +76,7 @@ void GetData(slsDetectorDefs::sls_receiver_header &header,
slsDetectorDefs::dataCallbackHeader callbackHeader,
char *dataPointer, size_t &imageSize, void *objectPointer) {
slsDetectorDefs::sls_detector_header detectorHeader = header.detHeader;
slsDetectorDefs::sls_detector_header const detectorHeader = header.detHeader;
PRINT_IN_COLOR(
(callbackHeader.udpPort % 10),
@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) {
for (int i = 0; i < m.numReceivers; ++i) {
/** - fork process to create child process */
pid_t pid = fork();
pid_t const pid = fork();
/** - if fork failed, raise SIGINT and properly destroy all child
* processes */
@@ -185,7 +185,7 @@ int main(int argc, char *argv[]) {
<< "Child process " << i << " [ Tid: " << gettid() << ']';
try {
uint16_t port = m.port + i;
uint16_t const port = m.port + i;
sls::Receiver receiver(port);
/** - register callbacks. remember to set file write enable
@@ -236,7 +236,7 @@ int main(int argc, char *argv[]) {
/** - Parent process waits for all child processes to exit */
for (;;) {
int status;
pid_t childPid = waitpid(-1, &status, 0);
pid_t const childPid = waitpid(-1, &status, 0);
// no child closed
if (childPid == -1) {
+1 -1
View File
@@ -54,7 +54,7 @@ int main(int argc, char *argv[]) {
sem_init(&semaphore, 1, 0);
try {
sls::Receiver r(o.port);
sls::Receiver const r(o.port);
LOG(sls::logINFO) << "[ Press \'Ctrl+c\' to exit ]";
sem_wait(&semaphore);
sem_destroy(&semaphore);