From ea4044e4b14e4f8c23dddfd61c5b92b8f75f4a44 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 5 May 2020 10:07:19 +0200 Subject: [PATCH] format support lib --- CMakeLists.txt | 1 - slsReceiverSoftware/src/DataProcessor.cpp | 2 +- slsReceiverSoftware/src/Listener.cpp | 10 +- slsSupportLib/include/DataSocket.h | 7 +- .../include/FixedCapacityContainer.h | 3 +- slsSupportLib/include/ServerSocket.h | 2 +- slsSupportLib/include/TimeHelper.h | 5 +- slsSupportLib/include/Timer.h | 19 +- slsSupportLib/include/TypeTraits.h | 16 +- slsSupportLib/include/UdpRxSocket.h | 2 +- slsSupportLib/include/ZmqSocket.h | 112 ++-- slsSupportLib/include/ansi.h | 79 ++- slsSupportLib/include/container_utils.h | 5 +- slsSupportLib/include/file_utils.h | 18 +- slsSupportLib/include/logger.h | 36 +- slsSupportLib/include/network_utils.h | 6 +- slsSupportLib/include/sls_detector_defs.h | 154 +++-- .../include/sls_detector_exceptions.h | 51 +- slsSupportLib/include/sls_detector_funcs.h | 566 +++++++++--------- slsSupportLib/include/versionAPI.h | 18 +- slsSupportLib/src/ClientSocket.cpp | 2 +- slsSupportLib/src/DataSocket.cpp | 4 +- slsSupportLib/src/ServerInterface.cpp | 4 +- slsSupportLib/src/ServerSocket.cpp | 11 +- slsSupportLib/src/ToString.cpp | 1 - slsSupportLib/src/UdpRxSocket.cpp | 27 +- slsSupportLib/src/ZmqSocket.cpp | 68 +-- slsSupportLib/src/file_utils.cpp | 128 ++-- slsSupportLib/src/network_utils.cpp | 7 +- .../tests/test-FixedCapacityContainer.cpp | 23 +- slsSupportLib/tests/test-Sockets.cpp | 8 +- slsSupportLib/tests/test-ToString.cpp | 44 +- slsSupportLib/tests/test-TypeTraits.cpp | 14 +- slsSupportLib/tests/test-UdpRxSocket.cpp | 15 +- slsSupportLib/tests/test-container_utils.cpp | 12 +- slsSupportLib/tests/test-logger.cpp | 18 +- slsSupportLib/tests/test-network_utils.cpp | 2 +- slsSupportLib/tests/test-string_utils.cpp | 129 ++-- 38 files changed, 775 insertions(+), 854 deletions(-) mode change 100755 => 100644 slsSupportLib/include/DataSocket.h mode change 100755 => 100644 slsSupportLib/include/ServerSocket.h mode change 100755 => 100644 slsSupportLib/include/Timer.h mode change 100755 => 100644 slsSupportLib/include/ZmqSocket.h mode change 100755 => 100644 slsSupportLib/include/ansi.h mode change 100755 => 100644 slsSupportLib/include/container_utils.h mode change 100755 => 100644 slsSupportLib/include/file_utils.h mode change 100755 => 100644 slsSupportLib/include/network_utils.h mode change 100755 => 100644 slsSupportLib/include/sls_detector_defs.h mode change 100755 => 100644 slsSupportLib/include/sls_detector_exceptions.h mode change 100755 => 100644 slsSupportLib/src/ClientSocket.cpp mode change 100755 => 100644 slsSupportLib/src/DataSocket.cpp mode change 100755 => 100644 slsSupportLib/src/ServerSocket.cpp mode change 100755 => 100644 slsSupportLib/src/file_utils.cpp mode change 100755 => 100644 slsSupportLib/src/network_utils.cpp mode change 100755 => 100644 slsSupportLib/tests/test-container_utils.cpp mode change 100755 => 100644 slsSupportLib/tests/test-network_utils.cpp mode change 100755 => 100644 slsSupportLib/tests/test-string_utils.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 68591d848..50d7415c2 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,6 @@ set(ClangFormat_EXCLUDE_PATTERNS "build/" "slsDetectorCalibration/" "slsDetectorServers/" "ctbGui/" - "slsSupportLib/" "manual/" "slsDetectorGui/" "python/" diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index 35ac6c801..0c3ff3d4a 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -272,7 +272,7 @@ void DataProcessor::ProcessAnImage(char *buf) { buf + FIFO_HEADER_NUMBYTES, sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t *)buf)), //+ size of data (resizable - //from previous call back + // from previous call back fnum - firstIndex, nump); } catch (const sls::RuntimeError &e) { ; // ignore write exception for now (TODO: send error message via diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index 521329ef2..6d03067e8 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -344,8 +344,9 @@ uint32_t Listener::ListenToAnImage(char *buf) { // copy packet switch (myDetectorType) { // for gotthard, 1st packet: 4 bytes fnum, CACA - // + CACA, 639*2 bytes data 2nd packet: 4 bytes fnum, previous 1*2 bytes - //data + 640*2 bytes data !! + // + CACA, 639*2 bytes data 2nd packet: 4 bytes + // fnum, previous 1*2 bytes + // data + 640*2 bytes data !! case GOTTHARD: if (!pnum) memcpy(buf + fifohsize, &carryOverPacket[hsize + 4], dsize - 2); @@ -514,8 +515,9 @@ uint32_t Listener::ListenToAnImage(char *buf) { // copy packet switch (myDetectorType) { // for gotthard, 1st packet: 4 bytes fnum, CACA - // + CACA, 639*2 bytes data 2nd packet: 4 bytes fnum, previous 1*2 bytes - //data + 640*2 bytes data !! + // + CACA, 639*2 bytes data 2nd packet: 4 bytes + // fnum, previous 1*2 bytes + // data + 640*2 bytes data !! case GOTTHARD: if (!pnum) memcpy(buf + fifohsize + (pnum * dsize), diff --git a/slsSupportLib/include/DataSocket.h b/slsSupportLib/include/DataSocket.h old mode 100755 new mode 100644 index 470a72a13..ffe79030d --- a/slsSupportLib/include/DataSocket.h +++ b/slsSupportLib/include/DataSocket.h @@ -17,13 +17,12 @@ class DataSocket { virtual ~DataSocket(); DataSocket &operator=(DataSocket &&move) noexcept; void swap(DataSocket &other) noexcept; - - //No copy since the class manage the underlying socket + + // No copy since the class manage the underlying socket DataSocket(const DataSocket &) = delete; DataSocket &operator=(DataSocket const &) = delete; int getSocketId() const { return sockfd_; } - int Send(const void *buffer, size_t size); template int Send(T &&data) { return Send(&data, sizeof(data)); @@ -38,7 +37,7 @@ class DataSocket { template int Receive(T &arg) { return Receive(&arg, sizeof(arg)); } - + template T Receive() { T arg; Receive(&arg, sizeof(arg)); diff --git a/slsSupportLib/include/FixedCapacityContainer.h b/slsSupportLib/include/FixedCapacityContainer.h index 239ebd142..699a83db7 100644 --- a/slsSupportLib/include/FixedCapacityContainer.h +++ b/slsSupportLib/include/FixedCapacityContainer.h @@ -104,7 +104,8 @@ template class FixedCapacityContainer { } } - template bool is_equal(const Container &c) const noexcept { + template + bool is_equal(const Container &c) const noexcept { if (current_size != c.size()) { return false; } else { diff --git a/slsSupportLib/include/ServerSocket.h b/slsSupportLib/include/ServerSocket.h old mode 100755 new mode 100644 index 532980bbd..422f9120c --- a/slsSupportLib/include/ServerSocket.h +++ b/slsSupportLib/include/ServerSocket.h @@ -18,7 +18,7 @@ class ServerSocket : public DataSocket { IpAddr getLastClient() const noexcept { return lastClient; } IpAddr getThisClient() const noexcept { return thisClient; } IpAddr getLockedBy() const noexcept { return lockedBy; } - bool differentClients() const noexcept {return lastClient != thisClient;} + bool differentClients() const noexcept { return lastClient != thisClient; } void setLockedBy(IpAddr addr) { lockedBy = addr; } void setLastClient(IpAddr addr) { lastClient = addr; } int getPort() const noexcept { return serverPort; } diff --git a/slsSupportLib/include/TimeHelper.h b/slsSupportLib/include/TimeHelper.h index bf043b11c..daefc1eef 100644 --- a/slsSupportLib/include/TimeHelper.h +++ b/slsSupportLib/include/TimeHelper.h @@ -9,9 +9,10 @@ using us = std::chrono::microseconds; using ms = std::chrono::milliseconds; using s = std::chrono::seconds; -//Absolute value of std::chrono::duration +// Absolute value of std::chrono::duration template -constexpr std::chrono::duration abs(std::chrono::duration d) { +constexpr std::chrono::duration +abs(std::chrono::duration d) { return d >= d.zero() ? d : -d; } diff --git a/slsSupportLib/include/Timer.h b/slsSupportLib/include/Timer.h old mode 100755 new mode 100644 index 4d03860e2..9d4dc59f1 --- a/slsSupportLib/include/Timer.h +++ b/slsSupportLib/include/Timer.h @@ -4,35 +4,32 @@ #include #include -namespace sls{ +namespace sls { class Timer { using clock = std::chrono::high_resolution_clock; using time_point = std::chrono::time_point; public: - Timer(std::string name = "0") - : t0(clock::now()), name_(name) { - } + Timer(std::string name = "0") : t0(clock::now()), name_(name) {} double elapsed_ms() { - return std::chrono::duration(clock::now() - t0).count(); + return std::chrono::duration(clock::now() - t0) + .count(); } double elapsed_s() { return std::chrono::duration(clock::now() - t0).count(); } void print_elapsed() { - std::cout << "Timer \"" << name_ << "\": Elapsed time " << elapsed_ms() << " ms\n"; - } - void restart() { - t0 = clock::now(); + std::cout << "Timer \"" << name_ << "\": Elapsed time " << elapsed_ms() + << " ms\n"; } + void restart() { t0 = clock::now(); } private: time_point t0; std::string name_; }; - -}; //namespace sls +}; // namespace sls #endif // TIMER_H diff --git a/slsSupportLib/include/TypeTraits.h b/slsSupportLib/include/TypeTraits.h index 39b9525c2..6a5ef7fb4 100644 --- a/slsSupportLib/include/TypeTraits.h +++ b/slsSupportLib/include/TypeTraits.h @@ -31,22 +31,23 @@ template struct has_str_helper {}; template struct has_str().str())>, + false, has_str_helper().str())>, void>::type> : public std::true_type {}; /** * Has emplace_back method */ -template struct has_emplace_back : std::false_type {}; +template +struct has_emplace_back : std::false_type {}; template struct has_emplace_back_helper {}; template -struct has_emplace_back().emplace_back())>, - void>::type> : public std::true_type {}; +struct has_emplace_back< + T, typename std::conditional< + false, + has_emplace_back_helper().emplace_back())>, + void>::type> : public std::true_type {}; /** * Type trait to evaluate if template parameter is @@ -71,7 +72,6 @@ struct is_container< decltype(std::declval().empty())>, void>::type> : public std::true_type {}; - /** * Type trait to evaluate if template parameter is * complying with a standard container diff --git a/slsSupportLib/include/UdpRxSocket.h b/slsSupportLib/include/UdpRxSocket.h index 3a4ee5685..8f3c451dd 100644 --- a/slsSupportLib/include/UdpRxSocket.h +++ b/slsSupportLib/include/UdpRxSocket.h @@ -1,7 +1,7 @@ #pragma once /* -UDP socket class to receive data. The intended use is in the +UDP socket class to receive data. The intended use is in the receiver listener loop. Should be used RAII style... */ diff --git a/slsSupportLib/include/ZmqSocket.h b/slsSupportLib/include/ZmqSocket.h old mode 100755 new mode 100644 index 666c9e7ea..d529e32e1 --- a/slsSupportLib/include/ZmqSocket.h +++ b/slsSupportLib/include/ZmqSocket.h @@ -15,69 +15,66 @@ // #define ZMQ_DETAIL #define ROIVERBOSITY - class zmq_msg_t; #include /** zmq header structure */ struct zmqHeader { - /** true if incoming data, false if end of acquisition */ - bool data{true}; - uint32_t jsonversion{0}; - uint32_t dynamicRange{0}; - uint64_t fileIndex{0}; - /** number of detectors in x axis */ - uint32_t ndetx{0}; - /** number of detectors in y axis */ - uint32_t ndety{0}; - /** number of pixels/channels in x axis for this zmq socket */ - uint32_t npixelsx{0}; - /** number of pixels/channels in y axis for this zmq socket */ - uint32_t npixelsy{0}; - /** number of bytes for an image in this socket */ - uint32_t imageSize{0}; - /** frame number from detector */ - uint64_t acqIndex{0}; - /** frame index (starting at 0 for each acquisition) */ - uint64_t frameIndex{0}; - /** progress in percentage */ - int progress{0}; - /** file name prefix */ - std::string fname{""}; - /** header from detector */ - uint64_t frameNumber{0}; - uint32_t expLength{0}; - uint32_t packetNumber{0}; - uint64_t bunchId{0}; - uint64_t timestamp{0}; - uint16_t modId{0}; - uint16_t row{0}; - uint16_t column{0}; - uint16_t reserved{0}; - uint32_t debug{0}; - uint16_t roundRNumber{0}; - uint8_t detType{0}; - uint8_t version{0}; - /** if image should be flipped across x axis */ - int flippedDataX{0}; - /** quad type (eiger hardware specific) */ - uint32_t quad{0}; - /** true if complete image, else missing packets */ - bool completeImage{false}; - /** additional json header */ - std::map addJsonHeader; + /** true if incoming data, false if end of acquisition */ + bool data{true}; + uint32_t jsonversion{0}; + uint32_t dynamicRange{0}; + uint64_t fileIndex{0}; + /** number of detectors in x axis */ + uint32_t ndetx{0}; + /** number of detectors in y axis */ + uint32_t ndety{0}; + /** number of pixels/channels in x axis for this zmq socket */ + uint32_t npixelsx{0}; + /** number of pixels/channels in y axis for this zmq socket */ + uint32_t npixelsy{0}; + /** number of bytes for an image in this socket */ + uint32_t imageSize{0}; + /** frame number from detector */ + uint64_t acqIndex{0}; + /** frame index (starting at 0 for each acquisition) */ + uint64_t frameIndex{0}; + /** progress in percentage */ + int progress{0}; + /** file name prefix */ + std::string fname{""}; + /** header from detector */ + uint64_t frameNumber{0}; + uint32_t expLength{0}; + uint32_t packetNumber{0}; + uint64_t bunchId{0}; + uint64_t timestamp{0}; + uint16_t modId{0}; + uint16_t row{0}; + uint16_t column{0}; + uint16_t reserved{0}; + uint32_t debug{0}; + uint16_t roundRNumber{0}; + uint8_t detType{0}; + uint8_t version{0}; + /** if image should be flipped across x axis */ + int flippedDataX{0}; + /** quad type (eiger hardware specific) */ + uint32_t quad{0}; + /** true if complete image, else missing packets */ + bool completeImage{false}; + /** additional json header */ + std::map addJsonHeader; }; class ZmqSocket { public: - // Socket Options for optimization // ZMQ_LINGER default is already -1 means no messages discarded. use this - // options if optimizing required ZMQ_SNDHWM default is 0 means no limit. use - // this to optimize if optimizing required - // eg. int value = -1; - // if (zmq_setsockopt(socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) { + // options if optimizing required ZMQ_SNDHWM default is 0 means no limit. + // use this to optimize if optimizing required eg. int value = -1; if + // (zmq_setsockopt(socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) { // Close(); /** * Constructor for a client @@ -174,7 +171,7 @@ class ZmqSocket { * @returns 0 if error, else 1 */ int SendData(char *buf, int length); - + /** * Receive Header * @param index self index for debugging @@ -183,7 +180,7 @@ class ZmqSocket { * @returns 0 if error or end of acquisition, else 1 (call * CloseHeaderMessage after parsing header) */ - int ReceiveHeader(const int index, zmqHeader& zHeader, uint32_t version); + int ReceiveHeader(const int index, zmqHeader &zHeader, uint32_t version); /** * Receive Data @@ -200,8 +197,7 @@ class ZmqSocket { void PrintError(); private: - - /** + /** * Receive Message * @param index self index for debugging * @param message message @@ -218,8 +214,8 @@ class ZmqSocket { * @param version version that has to match, -1 to not care * @returns true if successful else false */ - int ParseHeader(const int index, int length, char *buff, - zmqHeader& zHeader, uint32_t version); + int ParseHeader(const int index, int length, char *buff, zmqHeader &zHeader, + uint32_t version); /** * Class to close socket descriptors automatically @@ -251,6 +247,4 @@ class ZmqSocket { /** Socket descriptor */ mySocketDescriptors sockfd; - - }; diff --git a/slsSupportLib/include/ansi.h b/slsSupportLib/include/ansi.h old mode 100755 new mode 100644 index 3bd8f6eb3..d129aa259 --- a/slsSupportLib/include/ansi.h +++ b/slsSupportLib/include/ansi.h @@ -1,26 +1,27 @@ -#define RED "\x1b[31m" -#define GREEN "\x1b[32m" -#define YELLOW "\x1b[33m" -#define BLUE "\x1b[34m" -#define MAGENTA "\x1b[35m" -#define CYAN "\x1b[36m" -#define GRAY "\x1b[37m" -#define DARKGRAY "\x1b[30m" +#define RED "\x1b[31m" +#define GREEN "\x1b[32m" +#define YELLOW "\x1b[33m" +#define BLUE "\x1b[34m" +#define MAGENTA "\x1b[35m" +#define CYAN "\x1b[36m" +#define GRAY "\x1b[37m" +#define DARKGRAY "\x1b[30m" -#define BG_BLACK "\x1b[48;5;232m" -#define BG_RED "\x1b[41m" -#define BG_GREEN "\x1b[42m" -#define BG_YELLOW "\x1b[43m" -#define BG_BLUE "\x1b[44m" -#define BG_MAGENTA "\x1b[45m" -#define BG_CYAN "\x1b[46m" -#define RESET "\x1b[0m" -#define BOLD "\x1b[1m" +#define BG_BLACK "\x1b[48;5;232m" +#define BG_RED "\x1b[41m" +#define BG_GREEN "\x1b[42m" +#define BG_YELLOW "\x1b[43m" +#define BG_BLUE "\x1b[44m" +#define BG_MAGENTA "\x1b[45m" +#define BG_CYAN "\x1b[46m" +#define RESET "\x1b[0m" +#define BOLD "\x1b[1m" -//on background black -#define bprintf(code, format, ...) printf(code BG_BLACK format RESET, ##__VA_ARGS__) +// on background black +#define bprintf(code, format, ...) \ + printf(code BG_BLACK format RESET, ##__VA_ARGS__) -//normal printout +// normal printout #define cprintf(code, format, ...) printf(code format RESET, ##__VA_ARGS__) /* @@ -30,11 +31,9 @@ example 1 (a snippet): #ifdef MARTIN - cprintf(BLUE, "LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base); - for (i=0; i < buffer_len/4; i++) - cprintf(BLUE, "%.8X ",*(((unsigned *) buffer)+i)); - printf("\n"); -#endif + cprintf(BLUE, "LL Write - Len: %2d - If: %X - Data: ",buffer_len, +ll->ll_fifo_base); for (i=0; i < buffer_len/4; i++) cprintf(BLUE, "%.8X +",*(((unsigned *) buffer)+i)); printf("\n"); #endif #ifdef MARTIN cprintf(CYAN, "LL Read - If: %X - Data: ",ll->ll_fifo_base); @@ -46,21 +45,21 @@ example 2: int main() { - int i=1; - printf("Normal %i\n", i); - cprintf(RED, "Red\n"); - cprintf(GREEN, "Green\n"); - cprintf(YELLOW, "Yellow\n"); - cprintf(BLUE, "Blue\n"); - cprintf(MAGENTA, "Mangenta %i\n", i); - cprintf(CYAN, "Cyan %i\n", i); - cprintf(BOLD, "White %i\n", i); - cprintf(RED BOLD, "Red %i\n", i); - cprintf(GREEN BOLD, "Green\n"); - cprintf(YELLOW BOLD, "Yellow\n"); - cprintf(BLUE BOLD, "Blue\n"); - cprintf(MAGENTA BOLD, "Mangenta %i\n", i); - cprintf(CYAN BOLD, "Cyan %i\n", i); + int i=1; + printf("Normal %i\n", i); + cprintf(RED, "Red\n"); + cprintf(GREEN, "Green\n"); + cprintf(YELLOW, "Yellow\n"); + cprintf(BLUE, "Blue\n"); + cprintf(MAGENTA, "Mangenta %i\n", i); + cprintf(CYAN, "Cyan %i\n", i); + cprintf(BOLD, "White %i\n", i); + cprintf(RED BOLD, "Red %i\n", i); + cprintf(GREEN BOLD, "Green\n"); + cprintf(YELLOW BOLD, "Yellow\n"); + cprintf(BLUE BOLD, "Blue\n"); + cprintf(MAGENTA BOLD, "Mangenta %i\n", i); + cprintf(CYAN BOLD, "Cyan %i\n", i); } */ diff --git a/slsSupportLib/include/container_utils.h b/slsSupportLib/include/container_utils.h old mode 100755 new mode 100644 index b364adb2c..d13719a57 --- a/slsSupportLib/include/container_utils.h +++ b/slsSupportLib/include/container_utils.h @@ -39,7 +39,7 @@ template bool allEqual(const Container &c) { return false; } -/** +/** * Compare elements but with specified tolerance, useful * for floating point values. */ @@ -129,7 +129,7 @@ minusOneIfDifferent(const std::vector> &container) { return arr; } -/** +/** * Return the first value if all values are equal * otherwise return default_value. If no default * value is supplied it will be default constructed @@ -146,7 +146,6 @@ Squash(const Container &c, typename Container::value_type default_value = {}) { return default_value; } - } // namespace sls #endif // CONTAINER_UTILS_H diff --git a/slsSupportLib/include/file_utils.h b/slsSupportLib/include/file_utils.h old mode 100755 new mode 100644 index dd208e62d..2345b8961 --- a/slsSupportLib/include/file_utils.h +++ b/slsSupportLib/include/file_utils.h @@ -1,13 +1,11 @@ #pragma once - #include "sls_detector_defs.h" #include #include #include - /** (used by multi and sls) * reads a short int raw data file * @param infile input file stream @@ -16,8 +14,8 @@ * @param offset start channel value * @returns OK or FAIL if it could not read the file or data=NULL */ -int readDataFile(std::ifstream &infile, short int *data, int nch, int offset=0); - +int readDataFile(std::ifstream &infile, short int *data, int nch, + int offset = 0); /** (used by multi and sls) * reads a short int rawdata file @@ -28,7 +26,6 @@ int readDataFile(std::ifstream &infile, short int *data, int nch, int offset=0); */ int readDataFile(std::string fname, short int *data, int nch); - /** (used by multi and sls) * writes a short int raw data file * @param outfile output file stream @@ -37,9 +34,8 @@ int readDataFile(std::string fname, short int *data, int nch); * @param offset start channel number * @returns OK or FAIL if it could not write the file or data=NULL */ -int writeDataFile(std::ofstream &outfile,int nch, short int *data, int offset=0); - - +int writeDataFile(std::ofstream &outfile, int nch, short int *data, + int offset = 0); /** (used by multi and sls) * writes a short int raw data file @@ -48,9 +44,7 @@ int writeDataFile(std::ofstream &outfile,int nch, short int *data, int offset=0 * @param data array of data values * @returns OK or FAIL if it could not write the file or data=NULL */ -int writeDataFile(std::string fname,int nch, short int *data); - - +int writeDataFile(std::string fname, int nch, short int *data); // mkdir -p path implemented by recursive calls -void mkdir_p(const std::string& path, std::string dir=""); +void mkdir_p(const std::string &path, std::string dir = ""); diff --git a/slsSupportLib/include/logger.h b/slsSupportLib/include/logger.h index a6c4f3786..7d16a2f5d 100644 --- a/slsSupportLib/include/logger.h +++ b/slsSupportLib/include/logger.h @@ -1,27 +1,39 @@ #pragma once /*Utility to log to console*/ -#include "ansi.h" //Colors -#include +#include "ansi.h" //Colors #include #include +#include -enum TLogLevel {logERROR, logWARNING, logINFOBLUE, logINFOGREEN, logINFORED, logINFO, - logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5}; +enum TLogLevel { + logERROR, + logWARNING, + logINFOBLUE, + logINFOGREEN, + logINFORED, + logINFO, + logDEBUG, + logDEBUG1, + logDEBUG2, + logDEBUG3, + logDEBUG4, + logDEBUG5 +}; // Compiler should optimize away anything below this value #ifndef LOG_MAX_REPORTING_LEVEL #define LOG_MAX_REPORTING_LEVEL logINFO #endif -#define __AT__ std::string(__FILE__) + std::string("::") + std::string(__func__) + std::string("(): ") -#define __SHORT_FORM_OF_FILE__ \ -(strrchr(__FILE__,'/') \ -? strrchr(__FILE__,'/')+1 \ -: __FILE__ \ -) -#define __SHORT_AT__ std::string(__SHORT_FORM_OF_FILE__) + std::string("::") + std::string(__func__) + std::string("(): ") - +#define __AT__ \ + std::string(__FILE__) + std::string("::") + std::string(__func__) + \ + std::string("(): ") +#define __SHORT_FORM_OF_FILE__ \ + (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) +#define __SHORT_AT__ \ + std::string(__SHORT_FORM_OF_FILE__) + std::string("::") + \ + std::string(__func__) + std::string("(): ") namespace sls { class Logger { diff --git a/slsSupportLib/include/network_utils.h b/slsSupportLib/include/network_utils.h old mode 100755 new mode 100644 index b010451f8..b741b6e5e --- a/slsSupportLib/include/network_utils.h +++ b/slsSupportLib/include/network_utils.h @@ -60,9 +60,9 @@ class MacAddr { }; IpAddr HostnameToIp(const char *hostname); -std::string IpToInterfaceName(const std::string& ip); -MacAddr InterfaceNameToMac(const std::string& inf); -IpAddr InterfaceNameToIp(const std::string& ifn); +std::string IpToInterfaceName(const std::string &ip); +MacAddr InterfaceNameToMac(const std::string &inf); +IpAddr InterfaceNameToIp(const std::string &ifn); std::ostream &operator<<(std::ostream &out, const IpAddr &addr); std::ostream &operator<<(std::ostream &out, const MacAddr &addr); diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h old mode 100755 new mode 100644 index 9d17713a1..8acee1a56 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -15,28 +15,27 @@ #endif #ifdef __cplusplus -//C++ includes +// C++ includes #include "sls_detector_exceptions.h" #include #include #include #include #else -//C includes +// C includes #include #endif - #define BIT32_MASK 0xFFFFFFFF #define MAX_RX_DBIT 64 /** default ports */ -#define DEFAULT_PORTNO 1952 -#define DEFAULT_UDP_PORTNO 50001 +#define DEFAULT_PORTNO 1952 +#define DEFAULT_UDP_PORTNO 50001 #define DEFAULT_ZMQ_CL_PORTNO 30001 #define DEFAULT_ZMQ_RX_PORTNO 30001 -#define SLS_DETECTOR_HEADER_VERSION 0x2 +#define SLS_DETECTOR_HEADER_VERSION 0x2 #define SLS_DETECTOR_JSON_HEADER_VERSION 0x4 // ctb/ moench 1g udp (read from fifo) @@ -54,18 +53,17 @@ /** get flag form most functions */ #define GET_FLAG -1 -#define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee" -#define DEFAULT_DET_IP "129.129.202.45" +#define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee" +#define DEFAULT_DET_IP "129.129.202.45" #define DEFAULT_DET_MAC2 "00:aa:bb:cc:dd:ff" -#define DEFAULT_DET_IP2 "129.129.202.46" +#define DEFAULT_DET_IP2 "129.129.202.46" /** default maximum string length */ -#define MAX_STR_LENGTH 1000 +#define MAX_STR_LENGTH 1000 #define SHORT_STR_LENGTH 20 #define DEFAULT_STREAMING_TIMER_IN_MS 200 - #ifdef __cplusplus class slsDetectorDefs { public: @@ -73,10 +71,10 @@ class slsDetectorDefs { /** Type of the detector */ enum detectorType { - GET_DETECTOR_TYPE = -1, + GET_DETECTOR_TYPE = -1, GENERIC, EIGER, - GOTTHARD, + GOTTHARD, JUNGFRAU, CHIPTESTBOARD, MOENCH, @@ -86,7 +84,7 @@ class slsDetectorDefs { /** return values */ enum { - OK, /**< function succeeded */ + OK, /**< function succeeded */ FAIL /**< function failed */ }; @@ -143,7 +141,7 @@ class slsDetectorDefs { #define MAX_NUM_PACKETS 512 using sls_bitset = std::bitset; using bitset_storage = uint8_t[MAX_NUM_PACKETS / 8]; - struct sls_receiver_header{ + struct sls_receiver_header { sls_detector_header detHeader; /**< is the detector header */ sls_bitset packetsMask; /**< is the packets caught bit mask */ }; @@ -171,24 +169,23 @@ class slsDetectorDefs { xmin,xmax,ymin,ymax define the limits of the region */ - #ifdef __cplusplus +#ifdef __cplusplus struct ROI { int xmin{-1}; /**< is the roi xmin (in channel number) */ int xmax{-1}; /**< is the roi xmax (in channel number)*/ - }__attribute__((packed)); - #else - typedef struct { - int xmin; /**< is the roi xmin (in channel number) */ - int xmax; /**< is the roi xmax (in channel number)*/ - } ROI; - #endif + } __attribute__((packed)); +#else +typedef struct { + int xmin; /**< is the roi xmin (in channel number) */ + int xmax; /**< is the roi xmax (in channel number)*/ +} ROI; +#endif /** type of action performed (for text client) */ enum { GET_ACTION, PUT_ACTION, READOUT_ACTION, HELP_ACTION }; - /** dimension indexes */ @@ -202,11 +199,10 @@ class slsDetectorDefs { int x{0}; int y{0}; xy() = default; - xy(int x, int y):x(x),y(y){}; - }__attribute__((packed)); + xy(int x, int y) : x(x), y(y){}; + } __attribute__((packed)); #endif - /** use of the external signals */ @@ -241,10 +237,10 @@ class slsDetectorDefs { */ enum timingMode { GET_TIMING_MODE = -1, /** //hmm... but currently no way around -namespace sls{ +namespace sls { using Positions = const std::vector &; using defs = slsDetectorDefs; } // namespace sls diff --git a/slsSupportLib/include/sls_detector_exceptions.h b/slsSupportLib/include/sls_detector_exceptions.h old mode 100755 new mode 100644 index 036a6ebd1..75dfe09d4 --- a/slsSupportLib/include/sls_detector_exceptions.h +++ b/slsSupportLib/include/sls_detector_exceptions.h @@ -4,57 +4,52 @@ #include #include -namespace sls{ +namespace sls { struct RuntimeError : public std::runtime_error { -public: - RuntimeError(): runtime_error("SLS Detector Package Failed") { - LOG(logERROR) << "SLS Detector Package Failed"; - } - RuntimeError(const std::string& msg): runtime_error(msg) { - LOG(logERROR) << msg; - } - RuntimeError(const char* msg): runtime_error(msg) { - LOG(logERROR) << msg; - } + public: + RuntimeError() : runtime_error("SLS Detector Package Failed") { + LOG(logERROR) << "SLS Detector Package Failed"; + } + RuntimeError(const std::string &msg) : runtime_error(msg) { + LOG(logERROR) << msg; + } + RuntimeError(const char *msg) : runtime_error(msg) { LOG(logERROR) << msg; } }; struct SharedMemoryError : public RuntimeError { -public: - SharedMemoryError(const std::string& msg):RuntimeError(msg) {} + public: + SharedMemoryError(const std::string &msg) : RuntimeError(msg) {} }; struct SocketError : public RuntimeError { -public: - SocketError(const std::string& msg):RuntimeError(msg) {} + public: + SocketError(const std::string &msg) : RuntimeError(msg) {} }; struct ZmqSocketError : public RuntimeError { -public: - ZmqSocketError(const std::string& msg):RuntimeError(msg) {} + public: + ZmqSocketError(const std::string &msg) : RuntimeError(msg) {} }; struct NotImplementedError : public RuntimeError { -public: - NotImplementedError(const std::string& msg):RuntimeError(msg) {} + public: + NotImplementedError(const std::string &msg) : RuntimeError(msg) {} }; struct DetectorError : public RuntimeError { -public: - DetectorError(const std::string& msg):RuntimeError(msg) {} + public: + DetectorError(const std::string &msg) : RuntimeError(msg) {} }; struct ReceiverError : public RuntimeError { -public: - ReceiverError(const std::string& msg):RuntimeError(msg) {} + public: + ReceiverError(const std::string &msg) : RuntimeError(msg) {} }; struct GuiError : public RuntimeError { -public: - GuiError(const std::string& msg):RuntimeError(msg) {} + public: + GuiError(const std::string &msg) : RuntimeError(msg) {} }; } // namespace sls - - - diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h index d31c78497..1eb1c8b94 100755 --- a/slsSupportLib/include/sls_detector_funcs.h +++ b/slsSupportLib/include/sls_detector_funcs.h @@ -8,293 +8,294 @@ *@short functions indices to call on server (detector/receiver) */ +enum detFuncs { + F_EXEC_COMMAND = 0, + F_GET_DETECTOR_TYPE, + F_SET_EXTERNAL_SIGNAL_FLAG, + F_SET_TIMING_MODE, + F_GET_FIRMWARE_VERSION, + F_GET_SERVER_VERSION, + F_GET_SERIAL_NUMBER, + F_SET_FIRMWARE_TEST, + F_SET_BUS_TEST, + F_SET_IMAGE_TEST_MODE, + F_GET_IMAGE_TEST_MODE, + F_SET_DAC, + F_GET_ADC, + F_WRITE_REGISTER, + F_READ_REGISTER, + F_SET_MODULE, + F_GET_MODULE, + F_SET_SETTINGS, + F_GET_THRESHOLD_ENERGY, + F_START_ACQUISITION, + F_STOP_ACQUISITION, + F_START_READOUT, + F_GET_RUN_STATUS, + F_START_AND_READ_ALL, + F_READ_ALL, + F_GET_NUM_FRAMES, + F_SET_NUM_FRAMES, + F_GET_NUM_TRIGGERS, + F_SET_NUM_TRIGGERS, + F_GET_NUM_ADDITIONAL_STORAGE_CELLS, + F_SET_NUM_ADDITIONAL_STORAGE_CELLS, + F_GET_NUM_ANALOG_SAMPLES, + F_SET_NUM_ANALOG_SAMPLES, + F_GET_NUM_DIGITAL_SAMPLES, + F_SET_NUM_DIGITAL_SAMPLES, + F_GET_EXPTIME, + F_SET_EXPTIME, + F_GET_PERIOD, + F_SET_PERIOD, + F_GET_DELAY_AFTER_TRIGGER, + F_SET_DELAY_AFTER_TRIGGER, + F_GET_SUB_EXPTIME, + F_SET_SUB_EXPTIME, + F_GET_SUB_DEADTIME, + F_SET_SUB_DEADTIME, + F_GET_STORAGE_CELL_DELAY, + F_SET_STORAGE_CELL_DELAY, + F_GET_FRAMES_LEFT, + F_GET_TRIGGERS_LEFT, + F_GET_EXPTIME_LEFT, + F_GET_PERIOD_LEFT, + F_GET_DELAY_AFTER_TRIGGER_LEFT, + F_GET_MEASURED_PERIOD, + F_GET_MEASURED_SUBPERIOD, + F_GET_FRAMES_FROM_START, + F_GET_ACTUAL_TIME, + F_GET_MEASUREMENT_TIME, + F_SET_DYNAMIC_RANGE, + F_SET_ROI, + F_GET_ROI, + F_EXIT_SERVER, + F_LOCK_SERVER, + F_GET_LAST_CLIENT_IP, + F_SET_PORT, + F_ENABLE_TEN_GIGA, + F_SET_ALL_TRIMBITS, + F_SET_PATTERN_IO_CONTROL, + F_SET_PATTERN_CLOCK_CONTROL, + F_SET_PATTERN_WORD, + F_SET_PATTERN_LOOP_ADDRESSES, + F_SET_PATTERN_LOOP_CYCLES, + F_SET_PATTERN_WAIT_ADDR, + F_SET_PATTERN_WAIT_TIME, + F_SET_PATTERN_MASK, + F_GET_PATTERN_MASK, + F_SET_PATTERN_BIT_MASK, + F_GET_PATTERN_BIT_MASK, + F_WRITE_ADC_REG, + F_SET_COUNTER_BIT, + F_PULSE_PIXEL, + F_PULSE_PIXEL_AND_MOVE, + F_PULSE_CHIP, + F_SET_RATE_CORRECT, + F_GET_RATE_CORRECT, + F_SET_TEN_GIGA_FLOW_CONTROL, + F_GET_TEN_GIGA_FLOW_CONTROL, + F_SET_TRANSMISSION_DELAY_FRAME, + F_GET_TRANSMISSION_DELAY_FRAME, + F_SET_TRANSMISSION_DELAY_LEFT, + F_GET_TRANSMISSION_DELAY_LEFT, + F_SET_TRANSMISSION_DELAY_RIGHT, + F_GET_TRANSMISSION_DELAY_RIGHT, + F_PROGRAM_FPGA, + F_RESET_FPGA, + F_POWER_CHIP, + F_ACTIVATE, + F_PREPARE_ACQUISITION, + F_THRESHOLD_TEMP, + F_TEMP_CONTROL, + F_TEMP_EVENT, + F_AUTO_COMP_DISABLE, + F_STORAGE_CELL_START, + F_CHECK_VERSION, + F_SOFTWARE_TRIGGER, + F_LED, + F_DIGITAL_IO_DELAY, + F_COPY_DET_SERVER, + F_REBOOT_CONTROLLER, + F_SET_ADC_ENABLE_MASK, + F_GET_ADC_ENABLE_MASK, + F_SET_ADC_INVERT, + F_GET_ADC_INVERT, + F_EXTERNAL_SAMPLING_SOURCE, + F_EXTERNAL_SAMPLING, + F_SET_STARTING_FRAME_NUMBER, + F_GET_STARTING_FRAME_NUMBER, + F_SET_QUAD, + F_GET_QUAD, + F_SET_INTERRUPT_SUBFRAME, + F_GET_INTERRUPT_SUBFRAME, + F_SET_READ_N_LINES, + F_GET_READ_N_LINES, + F_SET_POSITION, + F_SET_SOURCE_UDP_MAC, + F_GET_SOURCE_UDP_MAC, + F_SET_SOURCE_UDP_MAC2, + F_GET_SOURCE_UDP_MAC2, + F_SET_SOURCE_UDP_IP, + F_GET_SOURCE_UDP_IP, + F_SET_SOURCE_UDP_IP2, + F_GET_SOURCE_UDP_IP2, + F_SET_DEST_UDP_MAC, + F_GET_DEST_UDP_MAC, + F_SET_DEST_UDP_MAC2, + F_GET_DEST_UDP_MAC2, + F_SET_DEST_UDP_IP, + F_GET_DEST_UDP_IP, + F_SET_DEST_UDP_IP2, + F_GET_DEST_UDP_IP2, + F_SET_DEST_UDP_PORT, + F_GET_DEST_UDP_PORT, + F_SET_DEST_UDP_PORT2, + F_GET_DEST_UDP_PORT2, + F_SET_NUM_INTERFACES, + F_GET_NUM_INTERFACES, + F_SET_INTERFACE_SEL, + F_GET_INTERFACE_SEL, + F_SET_PARALLEL_MODE, + F_GET_PARALLEL_MODE, + F_SET_OVERFLOW_MODE, + F_GET_OVERFLOW_MODE, + F_SET_STOREINRAM_MODE, + F_GET_STOREINRAM_MODE, + F_SET_READOUT_MODE, + F_GET_READOUT_MODE, + F_SET_CLOCK_FREQUENCY, + F_GET_CLOCK_FREQUENCY, + F_SET_CLOCK_PHASE, + F_GET_CLOCK_PHASE, + F_GET_MAX_CLOCK_PHASE_SHIFT, + F_SET_CLOCK_DIVIDER, + F_GET_CLOCK_DIVIDER, + F_SET_PIPELINE, + F_GET_PIPELINE, + F_SET_ON_CHIP_DAC, + F_GET_ON_CHIP_DAC, + F_SET_INJECT_CHANNEL, + F_GET_INJECT_CHANNEL, + F_SET_VETO_PHOTON, + F_GET_VETO_PHOTON, + F_SET_VETO_REFERENCE, + F_GET_BURST_MODE, + F_SET_BURST_MODE, + F_SET_ADC_ENABLE_MASK_10G, + F_GET_ADC_ENABLE_MASK_10G, + F_SET_COUNTER_MASK, + F_GET_COUNTER_MASK, + F_GET_NUM_BURSTS, + F_SET_NUM_BURSTS, + F_GET_BURST_PERIOD, + F_SET_BURST_PERIOD, + F_GET_CURRENT_SOURCE, + F_SET_CURRENT_SOURCE, + F_GET_TIMING_SOURCE, + F_SET_TIMING_SOURCE, + F_GET_NUM_CHANNELS, + F_UPDATE_RATE_CORRECTION, + F_GET_RECEIVER_PARAMETERS, -enum detFuncs{ - F_EXEC_COMMAND=0, - F_GET_DETECTOR_TYPE, - F_SET_EXTERNAL_SIGNAL_FLAG, - F_SET_TIMING_MODE, - F_GET_FIRMWARE_VERSION, - F_GET_SERVER_VERSION, - F_GET_SERIAL_NUMBER, - F_SET_FIRMWARE_TEST, - F_SET_BUS_TEST, - F_SET_IMAGE_TEST_MODE, - F_GET_IMAGE_TEST_MODE, - F_SET_DAC, - F_GET_ADC, - F_WRITE_REGISTER, - F_READ_REGISTER, - F_SET_MODULE, - F_GET_MODULE, - F_SET_SETTINGS, - F_GET_THRESHOLD_ENERGY, - F_START_ACQUISITION, - F_STOP_ACQUISITION, - F_START_READOUT, - F_GET_RUN_STATUS, - F_START_AND_READ_ALL, - F_READ_ALL, - F_GET_NUM_FRAMES, - F_SET_NUM_FRAMES, - F_GET_NUM_TRIGGERS, - F_SET_NUM_TRIGGERS, - F_GET_NUM_ADDITIONAL_STORAGE_CELLS, - F_SET_NUM_ADDITIONAL_STORAGE_CELLS, - F_GET_NUM_ANALOG_SAMPLES, - F_SET_NUM_ANALOG_SAMPLES, - F_GET_NUM_DIGITAL_SAMPLES, - F_SET_NUM_DIGITAL_SAMPLES, - F_GET_EXPTIME, - F_SET_EXPTIME, - F_GET_PERIOD, - F_SET_PERIOD, - F_GET_DELAY_AFTER_TRIGGER, - F_SET_DELAY_AFTER_TRIGGER, - F_GET_SUB_EXPTIME, - F_SET_SUB_EXPTIME, - F_GET_SUB_DEADTIME, - F_SET_SUB_DEADTIME, - F_GET_STORAGE_CELL_DELAY, - F_SET_STORAGE_CELL_DELAY, - F_GET_FRAMES_LEFT, - F_GET_TRIGGERS_LEFT, - F_GET_EXPTIME_LEFT, - F_GET_PERIOD_LEFT, - F_GET_DELAY_AFTER_TRIGGER_LEFT, - F_GET_MEASURED_PERIOD, - F_GET_MEASURED_SUBPERIOD, - F_GET_FRAMES_FROM_START, - F_GET_ACTUAL_TIME, - F_GET_MEASUREMENT_TIME, - F_SET_DYNAMIC_RANGE, - F_SET_ROI, - F_GET_ROI, - F_EXIT_SERVER, - F_LOCK_SERVER, - F_GET_LAST_CLIENT_IP, - F_SET_PORT, - F_ENABLE_TEN_GIGA, - F_SET_ALL_TRIMBITS, - F_SET_PATTERN_IO_CONTROL, - F_SET_PATTERN_CLOCK_CONTROL, - F_SET_PATTERN_WORD, - F_SET_PATTERN_LOOP_ADDRESSES, - F_SET_PATTERN_LOOP_CYCLES, - F_SET_PATTERN_WAIT_ADDR, - F_SET_PATTERN_WAIT_TIME, - F_SET_PATTERN_MASK, - F_GET_PATTERN_MASK, - F_SET_PATTERN_BIT_MASK, - F_GET_PATTERN_BIT_MASK, - F_WRITE_ADC_REG, - F_SET_COUNTER_BIT, - F_PULSE_PIXEL, - F_PULSE_PIXEL_AND_MOVE, - F_PULSE_CHIP, - F_SET_RATE_CORRECT, - F_GET_RATE_CORRECT, - F_SET_TEN_GIGA_FLOW_CONTROL, - F_GET_TEN_GIGA_FLOW_CONTROL, - F_SET_TRANSMISSION_DELAY_FRAME, - F_GET_TRANSMISSION_DELAY_FRAME, - F_SET_TRANSMISSION_DELAY_LEFT, - F_GET_TRANSMISSION_DELAY_LEFT, - F_SET_TRANSMISSION_DELAY_RIGHT, - F_GET_TRANSMISSION_DELAY_RIGHT, - F_PROGRAM_FPGA, - F_RESET_FPGA, - F_POWER_CHIP, - F_ACTIVATE, - F_PREPARE_ACQUISITION, - F_THRESHOLD_TEMP, - F_TEMP_CONTROL, - F_TEMP_EVENT, - F_AUTO_COMP_DISABLE, - F_STORAGE_CELL_START, - F_CHECK_VERSION, - F_SOFTWARE_TRIGGER, - F_LED, - F_DIGITAL_IO_DELAY, - F_COPY_DET_SERVER, - F_REBOOT_CONTROLLER, - F_SET_ADC_ENABLE_MASK, - F_GET_ADC_ENABLE_MASK, - F_SET_ADC_INVERT, - F_GET_ADC_INVERT, - F_EXTERNAL_SAMPLING_SOURCE, - F_EXTERNAL_SAMPLING, - F_SET_STARTING_FRAME_NUMBER, - F_GET_STARTING_FRAME_NUMBER, - F_SET_QUAD, - F_GET_QUAD, - F_SET_INTERRUPT_SUBFRAME, - F_GET_INTERRUPT_SUBFRAME, - F_SET_READ_N_LINES, - F_GET_READ_N_LINES, - F_SET_POSITION, - F_SET_SOURCE_UDP_MAC, - F_GET_SOURCE_UDP_MAC, - F_SET_SOURCE_UDP_MAC2, - F_GET_SOURCE_UDP_MAC2, - F_SET_SOURCE_UDP_IP, - F_GET_SOURCE_UDP_IP, - F_SET_SOURCE_UDP_IP2, - F_GET_SOURCE_UDP_IP2, - F_SET_DEST_UDP_MAC, - F_GET_DEST_UDP_MAC, - F_SET_DEST_UDP_MAC2, - F_GET_DEST_UDP_MAC2, - F_SET_DEST_UDP_IP, - F_GET_DEST_UDP_IP, - F_SET_DEST_UDP_IP2, - F_GET_DEST_UDP_IP2, - F_SET_DEST_UDP_PORT, - F_GET_DEST_UDP_PORT, - F_SET_DEST_UDP_PORT2, - F_GET_DEST_UDP_PORT2, - F_SET_NUM_INTERFACES, - F_GET_NUM_INTERFACES, - F_SET_INTERFACE_SEL, - F_GET_INTERFACE_SEL, - F_SET_PARALLEL_MODE, - F_GET_PARALLEL_MODE, - F_SET_OVERFLOW_MODE, - F_GET_OVERFLOW_MODE, - F_SET_STOREINRAM_MODE, - F_GET_STOREINRAM_MODE, - F_SET_READOUT_MODE, - F_GET_READOUT_MODE, - F_SET_CLOCK_FREQUENCY, - F_GET_CLOCK_FREQUENCY, - F_SET_CLOCK_PHASE, - F_GET_CLOCK_PHASE, - F_GET_MAX_CLOCK_PHASE_SHIFT, - F_SET_CLOCK_DIVIDER, - F_GET_CLOCK_DIVIDER, - F_SET_PIPELINE, - F_GET_PIPELINE, - F_SET_ON_CHIP_DAC, - F_GET_ON_CHIP_DAC, - F_SET_INJECT_CHANNEL, - F_GET_INJECT_CHANNEL, - F_SET_VETO_PHOTON, - F_GET_VETO_PHOTON, - F_SET_VETO_REFERENCE, - F_GET_BURST_MODE, - F_SET_BURST_MODE, - F_SET_ADC_ENABLE_MASK_10G, - F_GET_ADC_ENABLE_MASK_10G, - F_SET_COUNTER_MASK, - F_GET_COUNTER_MASK, - F_GET_NUM_BURSTS, - F_SET_NUM_BURSTS, - F_GET_BURST_PERIOD, - F_SET_BURST_PERIOD, - F_GET_CURRENT_SOURCE, - F_SET_CURRENT_SOURCE, - F_GET_TIMING_SOURCE, - F_SET_TIMING_SOURCE, - F_GET_NUM_CHANNELS, - F_UPDATE_RATE_CORRECTION, - F_GET_RECEIVER_PARAMETERS, + NUM_DET_FUNCTIONS, + RECEIVER_ENUM_START = 256, /**< detector function should not exceed this + (detector server should not compile anyway) */ - NUM_DET_FUNCTIONS, - RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */ + F_EXEC_RECEIVER_COMMAND, + F_EXIT_RECEIVER, + F_LOCK_RECEIVER, + F_GET_LAST_RECEIVER_CLIENT_IP, + F_SET_RECEIVER_PORT, + F_GET_RECEIVER_VERSION, + F_RECEIVER_SET_ROI, + F_RECEIVER_SET_NUM_FRAMES, + F_SET_RECEIVER_NUM_TRIGGERS, + F_SET_RECEIVER_NUM_BURSTS, + F_SET_RECEIVER_NUM_ADD_STORAGE_CELLS, + F_SET_RECEIVER_TIMING_MODE, + F_SET_RECEIVER_BURST_MODE, + F_RECEIVER_SET_NUM_ANALOG_SAMPLES, + F_RECEIVER_SET_NUM_DIGITAL_SAMPLES, + F_RECEIVER_SET_EXPTIME, + F_RECEIVER_SET_PERIOD, + F_RECEIVER_SET_SUB_EXPTIME, + F_RECEIVER_SET_SUB_DEADTIME, + F_SET_RECEIVER_DYNAMIC_RANGE, + F_SET_RECEIVER_STREAMING_FREQUENCY, + F_GET_RECEIVER_STREAMING_FREQUENCY, + F_GET_RECEIVER_STATUS, + F_START_RECEIVER, + F_STOP_RECEIVER, + F_SET_RECEIVER_FILE_PATH, + F_GET_RECEIVER_FILE_PATH, + F_SET_RECEIVER_FILE_NAME, + F_GET_RECEIVER_FILE_NAME, + F_SET_RECEIVER_FILE_INDEX, + F_GET_RECEIVER_FILE_INDEX, + F_GET_RECEIVER_FRAME_INDEX, + F_GET_RECEIVER_FRAMES_CAUGHT, + F_GET_NUM_MISSING_PACKETS, + F_SET_RECEIVER_FILE_WRITE, + F_GET_RECEIVER_FILE_WRITE, + F_SET_RECEIVER_MASTER_FILE_WRITE, + F_GET_RECEIVER_MASTER_FILE_WRITE, + F_SET_RECEIVER_OVERWRITE, + F_GET_RECEIVER_OVERWRITE, + F_ENABLE_RECEIVER_TEN_GIGA, + F_SET_RECEIVER_FIFO_DEPTH, + F_RECEIVER_ACTIVATE, + F_SET_RECEIVER_STREAMING, + F_GET_RECEIVER_STREAMING, + F_RECEIVER_STREAMING_TIMER, + F_SET_FLIPPED_DATA_RECEIVER, + F_SET_RECEIVER_FILE_FORMAT, + F_GET_RECEIVER_FILE_FORMAT, + F_SET_RECEIVER_STREAMING_PORT, + F_GET_RECEIVER_STREAMING_PORT, + F_SET_RECEIVER_STREAMING_SRC_IP, + F_GET_RECEIVER_STREAMING_SRC_IP, + F_SET_RECEIVER_SILENT_MODE, + F_GET_RECEIVER_SILENT_MODE, + F_RESTREAM_STOP_FROM_RECEIVER, + F_SET_ADDITIONAL_JSON_HEADER, + F_GET_ADDITIONAL_JSON_HEADER, + F_RECEIVER_UDP_SOCK_BUF_SIZE, + F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, + F_SET_RECEIVER_FRAMES_PER_FILE, + F_GET_RECEIVER_FRAMES_PER_FILE, + F_RECEIVER_CHECK_VERSION, + F_SET_RECEIVER_DISCARD_POLICY, + F_GET_RECEIVER_DISCARD_POLICY, + F_SET_RECEIVER_PADDING, + F_GET_RECEIVER_PADDING, + F_SET_RECEIVER_DEACTIVATED_PADDING, + F_GET_RECEIVER_DEACTIVATED_PADDING, + F_RECEIVER_SET_READOUT_MODE, + F_RECEIVER_SET_ADC_MASK, + F_SET_RECEIVER_DBIT_LIST, + F_GET_RECEIVER_DBIT_LIST, + F_SET_RECEIVER_DBIT_OFFSET, + F_GET_RECEIVER_DBIT_OFFSET, + F_SET_RECEIVER_QUAD, + F_SET_RECEIVER_READ_N_LINES, + F_SET_RECEIVER_UDP_IP, + F_SET_RECEIVER_UDP_IP2, + F_SET_RECEIVER_UDP_PORT, + F_SET_RECEIVER_UDP_PORT2, + F_SET_RECEIVER_NUM_INTERFACES, + F_RECEIVER_SET_ADC_MASK_10G, + F_RECEIVER_SET_NUM_COUNTERS, + F_INCREMENT_FILE_INDEX, + F_SET_ADDITIONAL_JSON_PARAMETER, + F_GET_ADDITIONAL_JSON_PARAMETER, + F_GET_RECEIVER_PROGRESS, + F_SETUP_RECEIVER, - F_EXEC_RECEIVER_COMMAND, - F_EXIT_RECEIVER, - F_LOCK_RECEIVER, - F_GET_LAST_RECEIVER_CLIENT_IP, - F_SET_RECEIVER_PORT, - F_GET_RECEIVER_VERSION, - F_RECEIVER_SET_ROI, - F_RECEIVER_SET_NUM_FRAMES, - F_SET_RECEIVER_NUM_TRIGGERS, - F_SET_RECEIVER_NUM_BURSTS, - F_SET_RECEIVER_NUM_ADD_STORAGE_CELLS, - F_SET_RECEIVER_TIMING_MODE, - F_SET_RECEIVER_BURST_MODE, - F_RECEIVER_SET_NUM_ANALOG_SAMPLES, - F_RECEIVER_SET_NUM_DIGITAL_SAMPLES, - F_RECEIVER_SET_EXPTIME, - F_RECEIVER_SET_PERIOD, - F_RECEIVER_SET_SUB_EXPTIME, - F_RECEIVER_SET_SUB_DEADTIME, - F_SET_RECEIVER_DYNAMIC_RANGE, - F_SET_RECEIVER_STREAMING_FREQUENCY, - F_GET_RECEIVER_STREAMING_FREQUENCY, - F_GET_RECEIVER_STATUS, - F_START_RECEIVER, - F_STOP_RECEIVER, - F_SET_RECEIVER_FILE_PATH, - F_GET_RECEIVER_FILE_PATH, - F_SET_RECEIVER_FILE_NAME, - F_GET_RECEIVER_FILE_NAME, - F_SET_RECEIVER_FILE_INDEX, - F_GET_RECEIVER_FILE_INDEX, - F_GET_RECEIVER_FRAME_INDEX, - F_GET_RECEIVER_FRAMES_CAUGHT, - F_GET_NUM_MISSING_PACKETS, - F_SET_RECEIVER_FILE_WRITE, - F_GET_RECEIVER_FILE_WRITE, - F_SET_RECEIVER_MASTER_FILE_WRITE, - F_GET_RECEIVER_MASTER_FILE_WRITE, - F_SET_RECEIVER_OVERWRITE, - F_GET_RECEIVER_OVERWRITE, - F_ENABLE_RECEIVER_TEN_GIGA, - F_SET_RECEIVER_FIFO_DEPTH, - F_RECEIVER_ACTIVATE, - F_SET_RECEIVER_STREAMING, - F_GET_RECEIVER_STREAMING, - F_RECEIVER_STREAMING_TIMER, - F_SET_FLIPPED_DATA_RECEIVER, - F_SET_RECEIVER_FILE_FORMAT, - F_GET_RECEIVER_FILE_FORMAT, - F_SET_RECEIVER_STREAMING_PORT, - F_GET_RECEIVER_STREAMING_PORT, - F_SET_RECEIVER_STREAMING_SRC_IP, - F_GET_RECEIVER_STREAMING_SRC_IP, - F_SET_RECEIVER_SILENT_MODE, - F_GET_RECEIVER_SILENT_MODE, - F_RESTREAM_STOP_FROM_RECEIVER, - F_SET_ADDITIONAL_JSON_HEADER, - F_GET_ADDITIONAL_JSON_HEADER, - F_RECEIVER_UDP_SOCK_BUF_SIZE, - F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, - F_SET_RECEIVER_FRAMES_PER_FILE, - F_GET_RECEIVER_FRAMES_PER_FILE, - F_RECEIVER_CHECK_VERSION, - F_SET_RECEIVER_DISCARD_POLICY, - F_GET_RECEIVER_DISCARD_POLICY, - F_SET_RECEIVER_PADDING, - F_GET_RECEIVER_PADDING, - F_SET_RECEIVER_DEACTIVATED_PADDING, - F_GET_RECEIVER_DEACTIVATED_PADDING, - F_RECEIVER_SET_READOUT_MODE, - F_RECEIVER_SET_ADC_MASK, - F_SET_RECEIVER_DBIT_LIST, - F_GET_RECEIVER_DBIT_LIST, - F_SET_RECEIVER_DBIT_OFFSET, - F_GET_RECEIVER_DBIT_OFFSET, - F_SET_RECEIVER_QUAD, - F_SET_RECEIVER_READ_N_LINES, - F_SET_RECEIVER_UDP_IP, - F_SET_RECEIVER_UDP_IP2, - F_SET_RECEIVER_UDP_PORT, - F_SET_RECEIVER_UDP_PORT2, - F_SET_RECEIVER_NUM_INTERFACES, - F_RECEIVER_SET_ADC_MASK_10G, - F_RECEIVER_SET_NUM_COUNTERS, - F_INCREMENT_FILE_INDEX, - F_SET_ADDITIONAL_JSON_PARAMETER, - F_GET_ADDITIONAL_JSON_PARAMETER, - F_GET_RECEIVER_PROGRESS, - F_SETUP_RECEIVER, - - NUM_REC_FUNCTIONS + NUM_REC_FUNCTIONS }; +// clang-format off #ifdef __cplusplus static const char* getFunctionNameFromEnum(enum detFuncs func) { switch (func) { @@ -586,3 +587,4 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) { }; #endif +// clang-format on \ No newline at end of file diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 24dff6ead..a33ce6990 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -1,13 +1,13 @@ /** API versions */ -#define GITBRANCH "setrxhostname" -#define APILIB 0x200409 -#define APIRECEIVER 0x200409 -#define APIGUI 0x200409 -#define APIEIGER 0x200409 -#define APICTB 0x200409 -#define APIGOTTHARD 0x200409 -#define APIJUNGFRAU 0x200409 -#define APIMYTHEN3 0x200428 +#define GITBRANCH "setrxhostname" +#define APILIB 0x200409 +#define APIRECEIVER 0x200409 +#define APIGUI 0x200409 +#define APIEIGER 0x200409 +#define APICTB 0x200409 +#define APIGOTTHARD 0x200409 +#define APIJUNGFRAU 0x200409 +#define APIMYTHEN3 0x200428 #define APIGOTTHARD2 0x200429 #define APIMOENCH 0x200429 diff --git a/slsSupportLib/src/ClientSocket.cpp b/slsSupportLib/src/ClientSocket.cpp old mode 100755 new mode 100644 index 0e0352c90..fe20200a3 --- a/slsSupportLib/src/ClientSocket.cpp +++ b/slsSupportLib/src/ClientSocket.cpp @@ -72,7 +72,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) { try { Receive(&ret, sizeof(ret)); - } + } // debugging catch (sls::SocketError &e) { if (socketType == "Receiver") { diff --git a/slsSupportLib/src/DataSocket.cpp b/slsSupportLib/src/DataSocket.cpp old mode 100755 new mode 100644 index 48af8a9a6..49750cba9 --- a/slsSupportLib/src/DataSocket.cpp +++ b/slsSupportLib/src/DataSocket.cpp @@ -136,8 +136,6 @@ void DataSocket::shutDownSocket() { close(); } -void DataSocket::shutdown(){ - ::shutdown(sockfd_, SHUT_RDWR); -} +void DataSocket::shutdown() { ::shutdown(sockfd_, SHUT_RDWR); } } // namespace sls diff --git a/slsSupportLib/src/ServerInterface.cpp b/slsSupportLib/src/ServerInterface.cpp index c85813c38..75e97fea9 100644 --- a/slsSupportLib/src/ServerInterface.cpp +++ b/slsSupportLib/src/ServerInterface.cpp @@ -5,7 +5,7 @@ namespace sls { int ServerInterface::sendResult(int ret, void *retval, int retvalSize, - char *mess) { + char *mess) { write(&ret, sizeof(ret)); if (ret == defs::FAIL) { @@ -13,7 +13,7 @@ int ServerInterface::sendResult(int ret, void *retval, int retvalSize, write(mess, MAX_STR_LENGTH); } else { LOG(logERROR) << "No error message provided for this " - "failure. Will mess up TCP\n"; + "failure. Will mess up TCP\n"; } } else { write(retval, retvalSize); diff --git a/slsSupportLib/src/ServerSocket.cpp b/slsSupportLib/src/ServerSocket.cpp old mode 100755 new mode 100644 index 9cd5723b3..06c95096a --- a/slsSupportLib/src/ServerSocket.cpp +++ b/slsSupportLib/src/ServerSocket.cpp @@ -1,5 +1,5 @@ -#include "ServerInterface.h" #include "ServerSocket.h" +#include "ServerInterface.h" #include "DataSocket.h" #include "logger.h" @@ -13,8 +13,8 @@ #include #include #define DEFAULT_PACKET_SIZE 1286 -#define SOCKET_BUFFER_SIZE (100 * 1024 * 1024) // 100 MB -#define DEFAULT_BACKLOG 5 +#define SOCKET_BUFFER_SIZE (100 * 1024 * 1024) // 100 MB +#define DEFAULT_BACKLOG 5 namespace sls { @@ -29,7 +29,8 @@ ServerSocket::ServerSocket(int port) if (bind(getSocketId(), (struct sockaddr *)&serverAddr, sizeof(serverAddr)) != 0) { close(); - throw sls::SocketError("Server ERROR: cannot bind socket. Please check if another instance is running."); + throw sls::SocketError("Server ERROR: cannot bind socket. Please check " + "if another instance is running."); } if (listen(getSocketId(), DEFAULT_BACKLOG) != 0) { close(); @@ -38,7 +39,7 @@ ServerSocket::ServerSocket(int port) } ServerInterface ServerSocket::accept() { - lastClient = thisClient; //update from previous connection + lastClient = thisClient; // update from previous connection struct sockaddr_in clientAddr; socklen_t addr_size = sizeof clientAddr; int newSocket = diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index e119a7422..4e1ba5e10 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -403,7 +403,6 @@ template <> defs::burstMode StringTo(const std::string &s) { throw sls::RuntimeError("Unknown burst mode " + s); } - template <> defs::timingSourceType StringTo(const std::string &s) { if (s == "internal") return defs::TIMING_INTERNAL; diff --git a/slsSupportLib/src/UdpRxSocket.cpp b/slsSupportLib/src/UdpRxSocket.cpp index 558d9ee7e..e342d24e3 100644 --- a/slsSupportLib/src/UdpRxSocket.cpp +++ b/slsSupportLib/src/UdpRxSocket.cpp @@ -56,22 +56,21 @@ UdpRxSocket::UdpRxSocket(int port, ssize_t packet_size, const char *hostname, UdpRxSocket::~UdpRxSocket() { Shutdown(); } ssize_t UdpRxSocket::getPacketSize() const noexcept { return packet_size_; } -bool UdpRxSocket::ReceivePacket(char *dst) noexcept{ +bool UdpRxSocket::ReceivePacket(char *dst) noexcept { auto bytes_received = recvfrom(sockfd_, dst, packet_size_, 0, nullptr, nullptr); return bytes_received == packet_size_; } ssize_t UdpRxSocket::ReceiveDataOnly(char *dst) noexcept { - auto r = recvfrom(sockfd_, dst, packet_size_, 0, nullptr, nullptr); - constexpr ssize_t eiger_header_packet = - 40; // only detector that has this - if (r == eiger_header_packet) { - LOG(logWARNING) << "Got header pkg"; - r = recvfrom(sockfd_, dst, packet_size_, 0, nullptr, nullptr); - } - return r; + auto r = recvfrom(sockfd_, dst, packet_size_, 0, nullptr, nullptr); + constexpr ssize_t eiger_header_packet = 40; // only detector that has this + if (r == eiger_header_packet) { + LOG(logWARNING) << "Got header pkg"; + r = recvfrom(sockfd_, dst, packet_size_, 0, nullptr, nullptr); } + return r; +} size_t UdpRxSocket::getBufferSize() const { size_t ret = 0; @@ -87,10 +86,10 @@ void UdpRxSocket::setBufferSize(ssize_t size) { } void UdpRxSocket::Shutdown() { - shutdown(sockfd_, SHUT_RDWR); - if (sockfd_ >= 0) { - close(sockfd_); - sockfd_ = -1; - } + shutdown(sockfd_, SHUT_RDWR); + if (sockfd_ >= 0) { + close(sockfd_); + sockfd_ = -1; } +} } // namespace sls \ No newline at end of file diff --git a/slsSupportLib/src/ZmqSocket.cpp b/slsSupportLib/src/ZmqSocket.cpp index 2920dd4b2..ffef36bd5 100644 --- a/slsSupportLib/src/ZmqSocket.cpp +++ b/slsSupportLib/src/ZmqSocket.cpp @@ -1,12 +1,12 @@ #include "ZmqSocket.h" -#include -#include #include //inet_ntoa #include #include -#include //gethostbyname() +#include //gethostbyname() #include #include //usleep in some machines +#include +#include using namespace rapidjson; ZmqSocket::ZmqSocket(const char *const hostname_or_ip, @@ -145,8 +145,7 @@ int ZmqSocket::ConvertInternetAddresstoIpString(struct addrinfo *res, char *ip, return 1; } -int ZmqSocket::SendHeader( - int index, zmqHeader header) { +int ZmqSocket::SendHeader(int index, zmqHeader header) { /** Json Header Format */ const char jsonHeaderFormat[] = "{" @@ -183,44 +182,25 @@ int ZmqSocket::SendHeader( ; //"}\n"; char buf[MAX_STR_LENGTH] = ""; - sprintf(buf, jsonHeaderFormat, - header.jsonversion, - header.dynamicRange, - header.fileIndex, - header.ndetx, - header.ndety, - header.npixelsx, - header.npixelsy, - header.imageSize, - header.acqIndex, - header.frameIndex, - header.progress, - header.fname.c_str(), - header.data ? 1 : 0, - header.completeImage ? 1 : 0, + sprintf(buf, jsonHeaderFormat, header.jsonversion, header.dynamicRange, + header.fileIndex, header.ndetx, header.ndety, header.npixelsx, + header.npixelsy, header.imageSize, header.acqIndex, + header.frameIndex, header.progress, header.fname.c_str(), + header.data ? 1 : 0, header.completeImage ? 1 : 0, - header.frameNumber, - header.expLength, - header.packetNumber, - header.bunchId, - header.timestamp, - header.modId, - header.row, - header.column, - header.reserved, - header.debug, - header.roundRNumber, - header.detType, - header.version, + header.frameNumber, header.expLength, header.packetNumber, + header.bunchId, header.timestamp, header.modId, header.row, + header.column, header.reserved, header.debug, header.roundRNumber, + header.detType, header.version, // additional stuff - header.flippedDataX, - header.quad); + header.flippedDataX, header.quad); if (header.addJsonHeader.size() > 0) { strcat(buf, ", "); strcat(buf, "\"addJsonHeader\": {"); - for (auto it = header.addJsonHeader.begin(); it != header.addJsonHeader.end(); ++it) { + for (auto it = header.addJsonHeader.begin(); + it != header.addJsonHeader.end(); ++it) { if (it != header.addJsonHeader.begin()) { strcat(buf, ", "); } @@ -260,7 +240,7 @@ int ZmqSocket::SendData(char *buf, int length) { return 1; } -int ZmqSocket::ReceiveHeader(const int index, zmqHeader& zHeader, +int ZmqSocket::ReceiveHeader(const int index, zmqHeader &zHeader, uint32_t version) { std::vector buffer(MAX_STR_LENGTH); int len = @@ -292,7 +272,7 @@ int ZmqSocket::ReceiveHeader(const int index, zmqHeader& zHeader, }; int ZmqSocket::ParseHeader(const int index, int length, char *buff, - zmqHeader& zHeader, uint32_t version) { + zmqHeader &zHeader, uint32_t version) { Document document; if (document.Parse(buff, length).HasParseError()) { LOG(logERROR) << index << " Could not parse. len:" << length @@ -318,7 +298,7 @@ int ZmqSocket::ParseHeader(const int index, int length, char *buff, // parse zHeader.data = ((document["data"].GetUint()) == 0) ? false : true; zHeader.dynamicRange = document["bitmode"].GetUint(); - zHeader.fileIndex = document["fileIndex"].GetUint64(); + zHeader.fileIndex = document["fileIndex"].GetUint64(); zHeader.ndetx = document["detshape"][0].GetUint(); zHeader.ndety = document["detshape"][1].GetUint(); zHeader.npixelsx = document["shape"][0].GetUint(); @@ -348,10 +328,12 @@ int ZmqSocket::ParseHeader(const int index, int length, char *buff, zHeader.completeImage = document["completeImage"].GetUint(); if (document.HasMember("addJsonHeader")) { - const Value& V = document["addJsonHeader"]; + const Value &V = document["addJsonHeader"]; zHeader.addJsonHeader.clear(); - for (Value::ConstMemberIterator iter = V.MemberBegin(); iter != V.MemberEnd(); ++iter){ - zHeader.addJsonHeader[iter->name.GetString()] = iter->value.GetString(); + for (Value::ConstMemberIterator iter = V.MemberBegin(); + iter != V.MemberEnd(); ++iter) { + zHeader.addJsonHeader[iter->name.GetString()] = + iter->value.GetString(); } } @@ -451,7 +433,7 @@ void ZmqSocket::PrintError() { } } -//Nested class to do RAII handling of socket descriptors +// Nested class to do RAII handling of socket descriptors ZmqSocket::mySocketDescriptors::mySocketDescriptors() : server(false), contextDescriptor(0), socketDescriptor(0){}; ZmqSocket::mySocketDescriptors::~mySocketDescriptors() { diff --git a/slsSupportLib/src/file_utils.cpp b/slsSupportLib/src/file_utils.cpp old mode 100755 new mode 100644 index fd5acf33a..100019d8c --- a/slsSupportLib/src/file_utils.cpp +++ b/slsSupportLib/src/file_utils.cpp @@ -2,85 +2,79 @@ #include "logger.h" #include "sls_detector_exceptions.h" +#include #include #include #include #include -#include int readDataFile(std::ifstream &infile, short int *data, int nch, int offset) { - int ichan, iline=0; - short int idata; - int interrupt=0; - std::string str; - while (infile.good() and interrupt==0) { - getline(infile,str); - std::istringstream ssstr(str); - ssstr >> ichan >> idata; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - if (iline=offset) { - data[iline]=idata; - iline++; - } - } else { - interrupt=1; - break; - } - return iline; - }; - return iline; + int ichan, iline = 0; + short int idata; + int interrupt = 0; + std::string str; + while (infile.good() and interrupt == 0) { + getline(infile, str); + std::istringstream ssstr(str); + ssstr >> ichan >> idata; + if (ssstr.fail() || ssstr.bad()) { + interrupt = 1; + break; + } + if (iline < nch) { + if (ichan >= offset) { + data[iline] = idata; + iline++; + } + } else { + interrupt = 1; + break; + } + return iline; + }; + return iline; } - - int readDataFile(std::string fname, short int *data, int nch) { - std::ifstream infile; - int iline=0; - std::string str; - infile.open(fname.c_str(), std::ios_base::in); - if (infile.is_open()) { - iline=readDataFile(infile, data, nch, 0); - infile.close(); - } else { - LOG(logERROR) << "Could not read file " << fname; - return -1; - } - return iline; + std::ifstream infile; + int iline = 0; + std::string str; + infile.open(fname.c_str(), std::ios_base::in); + if (infile.is_open()) { + iline = readDataFile(infile, data, nch, 0); + infile.close(); + } else { + LOG(logERROR) << "Could not read file " << fname; + return -1; + } + return iline; } - - -int writeDataFile(std::ofstream &outfile,int nch, short int *data, int offset) { - if (data==nullptr) - return slsDetectorDefs::FAIL; - for (int ichan=0; ichan #include #include @@ -15,7 +16,6 @@ #include #include #include -#include "network_utils.h" namespace sls { @@ -85,7 +85,8 @@ IpAddr HostnameToIp(const char *hostname) { hints.ai_socktype = SOCK_STREAM; if (getaddrinfo(hostname, nullptr, &hints, &result)) { freeaddrinfo(result); - throw RuntimeError("Could not convert hostname (" + std::string(hostname) + ") to ip"); + throw RuntimeError("Could not convert hostname (" + + std::string(hostname) + ") to ip"); } uint32_t ip = ((sockaddr_in *)result->ai_addr)->sin_addr.s_addr; freeaddrinfo(result); @@ -133,7 +134,7 @@ IpAddr InterfaceNameToIp(const std::string &ifn) { continue; auto s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host, - NI_MAXHOST, NULL, 0, NI_NUMERICHOST); + NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if ((strcmp(ifa->ifa_name, ifn.c_str()) == 0) && (ifa->ifa_addr->sa_family == AF_INET)) { diff --git a/slsSupportLib/tests/test-FixedCapacityContainer.cpp b/slsSupportLib/tests/test-FixedCapacityContainer.cpp index 0c351fa37..90b460de7 100644 --- a/slsSupportLib/tests/test-FixedCapacityContainer.cpp +++ b/slsSupportLib/tests/test-FixedCapacityContainer.cpp @@ -10,19 +10,18 @@ TEST_CASE("FixedCapacityContainer is a container") { REQUIRE(sls::is_container>::value == true); } -TEST_CASE("Comparing FixedCapacity containers"){ - FixedCapacityContainer a{0,1,2}; - FixedCapacityContainer b{0,1,2}; - FixedCapacityContainer c{0,1,2,4}; - - REQUIRE(a==b); - REQUIRE_FALSE(a!=b); - REQUIRE_FALSE(a==c); - REQUIRE(a!=c); - REQUIRE(c!=a); - REQUIRE_FALSE(c==a); - REQUIRE_FALSE(b==c); +TEST_CASE("Comparing FixedCapacity containers") { + FixedCapacityContainer a{0, 1, 2}; + FixedCapacityContainer b{0, 1, 2}; + FixedCapacityContainer c{0, 1, 2, 4}; + REQUIRE(a == b); + REQUIRE_FALSE(a != b); + REQUIRE_FALSE(a == c); + REQUIRE(a != c); + REQUIRE(c != a); + REQUIRE_FALSE(c == a); + REQUIRE_FALSE(b == c); } TEST_CASE("Compare array and fixed capacity container") { diff --git a/slsSupportLib/tests/test-Sockets.cpp b/slsSupportLib/tests/test-Sockets.cpp index fbe53700d..34ddfd92a 100644 --- a/slsSupportLib/tests/test-Sockets.cpp +++ b/slsSupportLib/tests/test-Sockets.cpp @@ -13,7 +13,7 @@ std::vector server() { s.Receive(buffer.data(), buffer.size()); std::cout << "ServerReceived: " << std::string(buffer.begin(), buffer.end()) << '\n'; - + std::vector to_send(100, '\0'); to_send[0] = 'O'; to_send[1] = 'K'; @@ -27,7 +27,7 @@ TEST_CASE("The server recive the same message as we send", "[support]") { std::vector sent_message(100, '\0'); const char m[]{"some message"}; std::copy(std::begin(m), std::end(m), sent_message.data()); - + auto s = std::async(std::launch::async, server); std::this_thread::sleep_for(std::chrono::milliseconds(100)); auto client = sls::DetectorSocket("localhost", 1950); @@ -37,10 +37,10 @@ TEST_CASE("The server recive the same message as we send", "[support]") { auto server_message = s.get(); CHECK(server_message == sent_message); - CHECK(std::string(received_message.data()) == "OK" ); + CHECK(std::string(received_message.data()) == "OK"); CHECK(client.getSocketId() == -1); } -TEST_CASE("throws on no server", "[support]"){ +TEST_CASE("throws on no server", "[support]") { CHECK_THROWS(sls::DetectorSocket("localhost", 1950)); } \ No newline at end of file diff --git a/slsSupportLib/tests/test-ToString.cpp b/slsSupportLib/tests/test-ToString.cpp index 8bbbeb034..90ead582a 100644 --- a/slsSupportLib/tests/test-ToString.cpp +++ b/slsSupportLib/tests/test-ToString.cpp @@ -1,16 +1,16 @@ #include "TimeHelper.h" #include "ToString.h" +#include "catch.hpp" #include "network_utils.h" #include "sls_detector_defs.h" -#include "catch.hpp" #include #include #include // using namespace sls; +using sls::defs; using sls::StringTo; using sls::ToString; -using sls::defs; using namespace sls::time; TEST_CASE("Integer conversions", "[support]") { @@ -45,7 +45,6 @@ TEST_CASE("conversion from duration to string", "[support]") { REQUIRE(ToString(us(-100)) == "-100us"); } - TEST_CASE("Convert vector of time", "[support]") { std::vector vec{ns(150), us(10), ns(600)}; REQUIRE(ToString(vec) == "[150ns, 10us, 600ns]"); @@ -85,27 +84,26 @@ TEST_CASE("Array") { REQUIRE(ToString(arr) == "[1, 2, 3]"); } -TEST_CASE("Convert types with str method"){ +TEST_CASE("Convert types with str method") { sls::IpAddr addr; REQUIRE(ToString(addr) == "0.0.0.0"); REQUIRE(ToString(sls::IpAddr{}) == "0.0.0.0"); } -TEST_CASE("String to string", "[support]"){ +TEST_CASE("String to string", "[support]") { std::string s = "hej"; REQUIRE(ToString(s) == "hej"); } -TEST_CASE("vector of strings"){ +TEST_CASE("vector of strings") { std::vector vec{"5", "s"}; REQUIRE(ToString(vec) == "[5, s]"); - + std::vector vec2{"some", "strange", "words", "75"}; REQUIRE(ToString(vec2) == "[some, strange, words, 75]"); - } -TEST_CASE("run status"){ +TEST_CASE("run status") { using defs = slsDetectorDefs; REQUIRE(ToString(defs::runStatus::ERROR) == "error"); REQUIRE(ToString(defs::runStatus::WAITING) == "waiting"); @@ -126,7 +124,7 @@ TEST_CASE("string to std::chrono::duration", "[support]") { REQUIRE_THROWS(StringTo("asvn")); } -TEST_CASE("string to detectorType"){ +TEST_CASE("string to detectorType") { using dt = slsDetectorDefs::detectorType; REQUIRE(StringTo
("Eiger") == dt::EIGER); REQUIRE(StringTo
("Gotthard") == dt::GOTTHARD); @@ -137,14 +135,13 @@ TEST_CASE("string to detectorType"){ REQUIRE(StringTo
("Gotthard2") == dt::GOTTHARD2); } -TEST_CASE("vec"){ +TEST_CASE("vec") { using rs = slsDetectorDefs::runStatus; std::vector vec{rs::ERROR, rs::IDLE}; REQUIRE(ToString(vec) == "[error, idle]"); } - -TEST_CASE("uint32 from string"){ +TEST_CASE("uint32 from string") { REQUIRE(StringTo("0") == 0); REQUIRE(StringTo("5") == 5u); REQUIRE(StringTo("16") == 16u); @@ -153,10 +150,9 @@ TEST_CASE("uint32 from string"){ REQUIRE(StringTo("0x15") == 21u); REQUIRE(StringTo("0x15") == 0x15); REQUIRE(StringTo("0xffffff") == 0xffffff); - } -TEST_CASE("uint64 from string"){ +TEST_CASE("uint64 from string") { REQUIRE(StringTo("0") == 0); REQUIRE(StringTo("5") == 5u); REQUIRE(StringTo("16") == 16u); @@ -164,11 +160,9 @@ TEST_CASE("uint64 from string"){ REQUIRE(StringTo("0x14") == 20u); REQUIRE(StringTo("0x15") == 21u); REQUIRE(StringTo("0xffffff") == 0xffffff); - } - -TEST_CASE("int from string"){ +TEST_CASE("int from string") { REQUIRE(StringTo("-1") == -1); REQUIRE(StringTo("-0x1") == -0x1); REQUIRE(StringTo("-0x1") == -1); @@ -179,11 +173,9 @@ TEST_CASE("int from string"){ REQUIRE(StringTo("0x14") == 20); REQUIRE(StringTo("0x15") == 21); REQUIRE(StringTo("0xffffff") == 0xffffff); - } - -TEST_CASE("int64_t from string"){ +TEST_CASE("int64_t from string") { REQUIRE(StringTo("-1") == -1); REQUIRE(StringTo("-0x1") == -0x1); REQUIRE(StringTo("-0x1") == -1); @@ -194,11 +186,9 @@ TEST_CASE("int64_t from string"){ REQUIRE(StringTo("0x14") == 20); REQUIRE(StringTo("0x15") == 21); REQUIRE(StringTo("0xffffff") == 0xffffff); - } - -TEST_CASE("std::map of strings"){ +TEST_CASE("std::map of strings") { std::map m; m["key"] = "value"; auto s = ToString(m); @@ -209,10 +199,9 @@ TEST_CASE("std::map of strings"){ m["test"] = "tree"; REQUIRE(ToString(m) == "{chrusi: musi, key: value, test: tree}"); - } -TEST_CASE("std::map of ints"){ +TEST_CASE("std::map of ints") { std::map m; m[5] = 10; @@ -221,10 +210,9 @@ TEST_CASE("std::map of ints"){ REQUIRE(ToString(m) == "{5: 10, 500: 50}"); m[372] = 999; REQUIRE(ToString(m) == "{5: 10, 372: 999, 500: 50}"); - } -TEST_CASE("Detector type"){ +TEST_CASE("Detector type") { auto dt = defs::detectorType::EIGER; REQUIRE(ToString(dt) == "Eiger"); REQUIRE(StringTo("Eiger") == dt); diff --git a/slsSupportLib/tests/test-TypeTraits.cpp b/slsSupportLib/tests/test-TypeTraits.cpp index 0df0ed186..f12fc355d 100644 --- a/slsSupportLib/tests/test-TypeTraits.cpp +++ b/slsSupportLib/tests/test-TypeTraits.cpp @@ -1,12 +1,12 @@ #include "TypeTraits.h" #include "catch.hpp" #include -#include -#include #include #include +#include +#include -//Dummy classes only used here for testing +// Dummy classes only used here for testing class DummyWithStr { public: std::string str(); @@ -32,7 +32,7 @@ TEST_CASE("Check for str() on ostream") { REQUIRE(sls::has_str::value == true); } -TEST_CASE("sls::is_duration"){ +TEST_CASE("sls::is_duration") { REQUIRE(sls::is_duration::value == true); REQUIRE(sls::is_duration::value == true); REQUIRE(sls::is_duration::value == true); @@ -41,11 +41,11 @@ TEST_CASE("sls::is_duration"){ REQUIRE(sls::is_duration>::value == false); } -TEST_CASE("initializer list"){ +TEST_CASE("initializer list") { REQUIRE(sls::is_light_container>::value == true); } -TEST_CASE("Check for emplace back"){ - //we know vector should have this its the type trait that is tested +TEST_CASE("Check for emplace back") { + // we know vector should have this its the type trait that is tested REQUIRE(sls::has_emplace_back>::value == true); } \ No newline at end of file diff --git a/slsSupportLib/tests/test-UdpRxSocket.cpp b/slsSupportLib/tests/test-UdpRxSocket.cpp index 07c7e115c..de99fc054 100644 --- a/slsSupportLib/tests/test-UdpRxSocket.cpp +++ b/slsSupportLib/tests/test-UdpRxSocket.cpp @@ -1,17 +1,17 @@ #include "UdpRxSocket.h" #include "catch.hpp" #include "sls_detector_exceptions.h" -#include -#include -#include #include #include +#include #include #include #include #include #include +#include #include +#include constexpr int default_port = 50001; @@ -44,7 +44,7 @@ int open_socket(int port) { return fd; } -TEST_CASE("Get packet size returns the packet size we set in the constructor"){ +TEST_CASE("Get packet size returns the packet size we set in the constructor") { constexpr int port = 50001; constexpr ssize_t packet_size = 8000; sls::UdpRxSocket s{port, packet_size}; @@ -57,17 +57,16 @@ TEST_CASE("Receive data from a vector") { std::vector data_received(data_to_send.size()); ssize_t packet_size = sizeof(decltype(data_to_send)::value_type) * data_to_send.size(); - + sls::UdpRxSocket udpsock{port, packet_size}; int fd = open_socket(port); auto n = write(fd, data_to_send.data(), packet_size); CHECK(n == packet_size); - - CHECK(udpsock.ReceivePacket((char*)data_received.data())); + + CHECK(udpsock.ReceivePacket((char *)data_received.data())); close(fd); CHECK(data_to_send == data_received); - } TEST_CASE("Shutdown socket without hanging when waiting for data") { diff --git a/slsSupportLib/tests/test-container_utils.cpp b/slsSupportLib/tests/test-container_utils.cpp old mode 100755 new mode 100644 index 061f832f6..0defcd677 --- a/slsSupportLib/tests/test-container_utils.cpp +++ b/slsSupportLib/tests/test-container_utils.cpp @@ -113,8 +113,7 @@ TEST_CASE("Compare a vector containing two vectors", "[support]") { CHECK(minusOneIfDifferent(d) == d[2]); } - -TEST_CASE("vector of bool", "[support]"){ +TEST_CASE("vector of bool", "[support]") { std::vector a{true, true, true}; std::vector b{false, false, false}; std::vector c{true, false, true}; @@ -124,14 +123,13 @@ TEST_CASE("vector of bool", "[support]"){ CHECK(minusOneIfDifferent(c) == -1); } -TEST_CASE("compare a vector of arrays", "[support]"){ +TEST_CASE("compare a vector of arrays", "[support]") { - std::vector> vec0{{5,6,8},{5,6,8},{5,6,8}}; - CHECK(minusOneIfDifferent(vec0) == std::array{5,6,8}); + std::vector> vec0{{5, 6, 8}, {5, 6, 8}, {5, 6, 8}}; + CHECK(minusOneIfDifferent(vec0) == std::array{5, 6, 8}); std::array arr; arr.fill(-1); - std::vector> vec1{{5,90,8},{5,6,8},{5,6,8}}; + std::vector> vec1{{5, 90, 8}, {5, 6, 8}, {5, 6, 8}}; CHECK(minusOneIfDifferent(vec1) == arr); - } \ No newline at end of file diff --git a/slsSupportLib/tests/test-logger.cpp b/slsSupportLib/tests/test-logger.cpp index 19b934e76..41c260b86 100644 --- a/slsSupportLib/tests/test-logger.cpp +++ b/slsSupportLib/tests/test-logger.cpp @@ -1,8 +1,8 @@ #include "catch.hpp" #include "logger.h" -#include -#include #include +#include +#include using sls::Logger; @@ -27,25 +27,23 @@ TEST_CASE("Test output") { Logger::ReportingLevel() = logERROR; - //Redirect std::clog to local buffer + // Redirect std::clog to local buffer std::ostringstream local; auto clog_buff = std::clog.rdbuf(); std::clog.rdbuf(local.rdbuf()); - //Try printing something with too low level + // Try printing something with too low level LOG(logDEBUG) << "This should not be printed"; CHECK(local.str().empty()); - //Try printing something with a higher level + // Try printing something with a higher level LOG(logERROR) << "This should be printed"; CHECK(!local.str().empty()); - std::clog.rdbuf(clog_buff); // restore - Logger::ReportingLevel() = old_value; //reset + std::clog.rdbuf(clog_buff); // restore + Logger::ReportingLevel() = old_value; // reset - - //Check that the message is in the printed string + // Check that the message is in the printed string auto r = local.str(); auto pos = r.find("This should be printed"); CHECK(pos != std::string::npos); - } \ No newline at end of file diff --git a/slsSupportLib/tests/test-network_utils.cpp b/slsSupportLib/tests/test-network_utils.cpp old mode 100755 new mode 100644 index bfbc86713..39afd6cfb --- a/slsSupportLib/tests/test-network_utils.cpp +++ b/slsSupportLib/tests/test-network_utils.cpp @@ -105,7 +105,7 @@ TEST_CASE("MAC Output operator gives same result as string", "[support]") { CHECK(os.str() == addr.str()); } -TEST_CASE("Copy construct a MacAddr"){ +TEST_CASE("Copy construct a MacAddr") { MacAddr addr{"00:50:c2:46:d9:a6"}; MacAddr addr2(addr); CHECK(addr == addr2); diff --git a/slsSupportLib/tests/test-string_utils.cpp b/slsSupportLib/tests/test-string_utils.cpp old mode 100755 new mode 100644 index d31a7fbc2..8f297e052 --- a/slsSupportLib/tests/test-string_utils.cpp +++ b/slsSupportLib/tests/test-string_utils.cpp @@ -5,107 +5,102 @@ #include "string_utils.h" - TEST_CASE("copy a string") { char src[10] = "hej"; - REQUIRE(src[3]=='\0'); + REQUIRE(src[3] == '\0'); char dst[20]; sls::strcpy_safe(dst, src); - REQUIRE(dst[0]=='h'); - REQUIRE(dst[1]=='e'); - REQUIRE(dst[2]=='j'); - REQUIRE(dst[3]=='\0'); - + REQUIRE(dst[0] == 'h'); + REQUIRE(dst[1] == 'e'); + REQUIRE(dst[2] == 'j'); + REQUIRE(dst[3] == '\0'); } - #ifdef NDEBUG -//This test can only run in release since we assert on the length of the string -TEST_CASE("copy a long string"){ +// This test can only run in release since we assert on the length of the string +TEST_CASE("copy a long string") { auto src = "some very very long sting that does not fit"; char dst[3]; sls::strcpy_safe(dst, src); - REQUIRE(dst[0]=='s'); - REQUIRE(dst[1]=='o'); - REQUIRE(dst[2]=='\0'); - + REQUIRE(dst[0] == 's'); + REQUIRE(dst[1] == 'o'); + REQUIRE(dst[2] == '\0'); } #endif TEST_CASE("Concat") { - std::vector v{"one", "one", "one"}; - std::vector v2{"one", "one", "one"}; - auto r = sls::concatenateIfDifferent(v); - REQUIRE(r == std::string("one")); - r.clear(); + std::vector v{"one", "one", "one"}; + std::vector v2{"one", "one", "one"}; + auto r = sls::concatenateIfDifferent(v); + REQUIRE(r == std::string("one")); + r.clear(); - // make sure we didn't modify the string - REQUIRE(v == v2); + // make sure we didn't modify the string + REQUIRE(v == v2); - SECTION("add a different value"){ - v.emplace_back("two"); - REQUIRE(v!=v2); - REQUIRE( sls::concatenateIfDifferent(v) == "one+one+one+two+"); - } + SECTION("add a different value") { + v.emplace_back("two"); + REQUIRE(v != v2); + REQUIRE(sls::concatenateIfDifferent(v) == "one+one+one+two+"); + } } -TEST_CASE("split a string with end delimiter"){ - std::string s("abra+kadabra+"); - auto r =sls::split(s, '+'); - REQUIRE(r.size()==2); - REQUIRE(r[0]=="abra"); - REQUIRE(r[1]=="kadabra"); +TEST_CASE("split a string with end delimiter") { + std::string s("abra+kadabra+"); + auto r = sls::split(s, '+'); + REQUIRE(r.size() == 2); + REQUIRE(r[0] == "abra"); + REQUIRE(r[1] == "kadabra"); } -TEST_CASE("split a string without end delimiter"){ - std::string s("abra+kadabra+filibom"); - auto r =sls::split(s, '+'); - REQUIRE(r.size()==3); - REQUIRE(r[0]=="abra"); - REQUIRE(r[1]=="kadabra"); - REQUIRE(r[2]=="filibom"); +TEST_CASE("split a string without end delimiter") { + std::string s("abra+kadabra+filibom"); + auto r = sls::split(s, '+'); + REQUIRE(r.size() == 3); + REQUIRE(r[0] == "abra"); + REQUIRE(r[1] == "kadabra"); + REQUIRE(r[2] == "filibom"); } -TEST_CASE("concatenate non empty strings"){ - std::vector vec{"hej", "kalas", "", "foto"}; - REQUIRE(vec.size()==4); - auto ret = sls::concatenateNonEmptyStrings(vec); - REQUIRE(ret == "hej+kalas+foto+"); +TEST_CASE("concatenate non empty strings") { + std::vector vec{"hej", "kalas", "", "foto"}; + REQUIRE(vec.size() == 4); + auto ret = sls::concatenateNonEmptyStrings(vec); + REQUIRE(ret == "hej+kalas+foto+"); } -TEST_CASE("concatenate non empty strings with only emty"){ - std::vector vec{"", "", ""}; - REQUIRE(vec.size()==3); - auto ret = sls::concatenateNonEmptyStrings(vec); - REQUIRE(ret.empty()); +TEST_CASE("concatenate non empty strings with only emty") { + std::vector vec{"", "", ""}; + REQUIRE(vec.size() == 3); + auto ret = sls::concatenateNonEmptyStrings(vec); + REQUIRE(ret.empty()); } -TEST_CASE("concatenate non empty strings with one element"){ - std::vector vec{"", "hej", "", "", ""}; - REQUIRE(vec.size()==5); - auto ret = sls::concatenateNonEmptyStrings(vec); - REQUIRE(ret=="hej+"); +TEST_CASE("concatenate non empty strings with one element") { + std::vector vec{"", "hej", "", "", ""}; + REQUIRE(vec.size() == 5); + auto ret = sls::concatenateNonEmptyStrings(vec); + REQUIRE(ret == "hej+"); } - -TEST_CASE("Remove char from string"){ - char str[] = "sometest"; - sls::removeChar(str, 'e'); - REQUIRE(std::string(str) == "somtst"); +TEST_CASE("Remove char from string") { + char str[] = "sometest"; + sls::removeChar(str, 'e'); + REQUIRE(std::string(str) == "somtst"); } -TEST_CASE("Remove char from empty string"){ - char str[50] = {}; - sls::removeChar(str, 'e'); - REQUIRE(std::string(str) == ""); +TEST_CASE("Remove char from empty string") { + char str[50] = {}; + sls::removeChar(str, 'e'); + REQUIRE(std::string(str) == ""); } -TEST_CASE("Many characters in a row"){ - char str[] = "someeequitellll::ongstring"; - sls::removeChar(str, 'l'); - REQUIRE(std::string(str) == "someeequite::ongstring"); +TEST_CASE("Many characters in a row") { + char str[] = "someeequitellll::ongstring"; + sls::removeChar(str, 'l'); + REQUIRE(std::string(str) == "someeequite::ongstring"); } // TEST_CASE("concat things not being strings") \ No newline at end of file