mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
rxr sls namespace (#457)
* rxr src files and classes (detectordata, ZmqSocket) added to sls namespace * moving defines inside namespace * moving defines inside namespace, added helpdacs to namespace * added namespace to gui * gui also updated * removed unnecessary sls:: when already in sls namespace for slsDetectoSoftware, receverSoftware, slsDetectorGui and slsSupportlib
This commit is contained in:
@ -193,7 +193,7 @@ bool operator!=(const std::vector<T> &lhs,
|
||||
|
||||
template <typename T, size_t Capacity>
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const sls::StaticVector<T, Capacity> &c) {
|
||||
const StaticVector<T, Capacity> &c) {
|
||||
return os << ToString(c);
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ T StringTo(const std::string &t, const std::string &unit) {
|
||||
try {
|
||||
tval = std::stod(t);
|
||||
} catch (const std::invalid_argument &e) {
|
||||
throw sls::RuntimeError("Could not convert string to time");
|
||||
throw RuntimeError("Could not convert string to time");
|
||||
}
|
||||
|
||||
using std::chrono::duration;
|
||||
@ -287,7 +287,7 @@ T StringTo(const std::string &t, const std::string &unit) {
|
||||
} else if (unit == "s" || unit.empty()) {
|
||||
return duration_cast<T>(std::chrono::duration<double>(tval));
|
||||
} else {
|
||||
throw sls::RuntimeError(
|
||||
throw RuntimeError(
|
||||
"Invalid unit in conversion from string to std::chrono::duration");
|
||||
}
|
||||
}
|
||||
|
@ -10,17 +10,20 @@
|
||||
*/
|
||||
|
||||
#include "sls/sls_detector_exceptions.h"
|
||||
#include "sls/container_utils.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#include <zmq.h>
|
||||
|
||||
namespace sls {
|
||||
|
||||
#define MAX_STR_LENGTH 1000
|
||||
|
||||
// #define ZMQ_DETAIL
|
||||
#define ROIVERBOSITY
|
||||
|
||||
class zmq_msg_t;
|
||||
#include "sls/container_utils.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
/** zmq header structure */
|
||||
struct zmqHeader {
|
||||
/** true if incoming data, false if end of acquisition */
|
||||
@ -222,5 +225,7 @@ class ZmqSocket {
|
||||
mySocketDescriptors sockfd;
|
||||
|
||||
std::unique_ptr<char[]> header_buffer =
|
||||
sls::make_unique<char[]>(MAX_STR_LENGTH);
|
||||
make_unique<char[]>(MAX_STR_LENGTH);
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <sstream>
|
||||
#include <sys/time.h>
|
||||
|
||||
namespace sls {
|
||||
|
||||
enum TLogLevel {
|
||||
logERROR,
|
||||
logWARNING,
|
||||
@ -25,7 +27,7 @@ enum TLogLevel {
|
||||
|
||||
// Compiler should optimize away anything below this value
|
||||
#ifndef LOG_MAX_REPORTING_LEVEL
|
||||
#define LOG_MAX_REPORTING_LEVEL logINFO
|
||||
#define LOG_MAX_REPORTING_LEVEL sls::logINFO
|
||||
#endif
|
||||
|
||||
#define __AT__ \
|
||||
@ -37,7 +39,6 @@ enum TLogLevel {
|
||||
std::string(__SHORT_FORM_OF_FILE__) + std::string("::") + \
|
||||
std::string(__func__) + std::string("(): ")
|
||||
|
||||
namespace sls {
|
||||
class Logger {
|
||||
std::ostringstream os;
|
||||
TLogLevel level = LOG_MAX_REPORTING_LEVEL;
|
||||
|
@ -93,7 +93,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
|
||||
Receive(retval, retval_size);
|
||||
}
|
||||
// debugging
|
||||
catch (sls::SocketError &e) {
|
||||
catch (SocketError &e) {
|
||||
if (socketType == "Receiver") {
|
||||
throw ReceiverError("Receiver returned: " + std::string(e.what()));
|
||||
} else if (socketType == "Detector") {
|
||||
|
@ -65,7 +65,7 @@ int DataSocket::Receive(void *buffer, size_t size) {
|
||||
ss << "TCP socket read " << bytes_read << " bytes instead of "
|
||||
<< bytes_expected << " bytes ("
|
||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum_)) << ')';
|
||||
throw sls::SocketError(ss.str());
|
||||
throw SocketError(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ int DataSocket::Send(const void *buffer, size_t size) {
|
||||
ss << "TCP socket sent " << bytes_sent << " bytes instead of "
|
||||
<< data_size << " bytes ("
|
||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum_)) << ')';
|
||||
throw sls::SocketError(ss.str());
|
||||
throw SocketError(ss.str());
|
||||
}
|
||||
return bytes_sent;
|
||||
}
|
||||
|
@ -14,12 +14,14 @@
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
namespace sls {
|
||||
|
||||
#define DEFAULT_PACKET_SIZE 1286
|
||||
#define SOCKET_BUFFER_SIZE (100 * 1024 * 1024) // 100 MB
|
||||
#define DEFAULT_BACKLOG 5
|
||||
|
||||
namespace sls {
|
||||
|
||||
ServerSocket::ServerSocket(int port)
|
||||
: DataSocket(socket(AF_INET, SOCK_STREAM, 0)), serverPort(port) {
|
||||
|
||||
@ -31,7 +33,7 @@ ServerSocket::ServerSocket(int port)
|
||||
if (bind(getSocketId(), (struct sockaddr *)&serverAddr,
|
||||
sizeof(serverAddr)) != 0) {
|
||||
close();
|
||||
throw sls::SocketError(
|
||||
throw SocketError(
|
||||
std::string("Server ERROR: cannot bind socket with port number ") +
|
||||
std::to_string(port) +
|
||||
std::string(". Please check if another instance is running."));
|
||||
@ -49,7 +51,7 @@ ServerInterface ServerSocket::accept() {
|
||||
int newSocket =
|
||||
::accept(getSocketId(), (struct sockaddr *)&clientAddr, &addr_size);
|
||||
if (newSocket == -1) {
|
||||
throw sls::SocketError("Server ERROR: socket accept failed\n");
|
||||
throw SocketError("Server ERROR: socket accept failed\n");
|
||||
}
|
||||
char tc[INET_ADDRSTRLEN]{};
|
||||
inet_ntop(AF_INET, &(clientAddr.sin_addr), tc, INET_ADDRSTRLEN);
|
||||
|
@ -38,11 +38,11 @@ std::string ToString(const slsDetectorDefs::rxParameters &r) {
|
||||
<< "hostname:" << r.hostname << std::endl
|
||||
<< "udpInterfaces:" << r.udpInterfaces << std::endl
|
||||
<< "udp_dstport:" << r.udp_dstport << std::endl
|
||||
<< "udp_dstip:" << sls::IpAddr(r.udp_dstip) << std::endl
|
||||
<< "udp_dstmac:" << sls::MacAddr(r.udp_dstmac) << std::endl
|
||||
<< "udp_dstip:" << IpAddr(r.udp_dstip) << std::endl
|
||||
<< "udp_dstmac:" << MacAddr(r.udp_dstmac) << std::endl
|
||||
<< "udp_dstport2:" << r.udp_dstport2 << std::endl
|
||||
<< "udp_dstip2:" << sls::IpAddr(r.udp_dstip2) << std::endl
|
||||
<< "udp_dstmac2:" << sls::MacAddr(r.udp_dstmac2) << std::endl
|
||||
<< "udp_dstip2:" << IpAddr(r.udp_dstip2) << std::endl
|
||||
<< "udp_dstmac2:" << MacAddr(r.udp_dstmac2) << std::endl
|
||||
<< "frames:" << r.frames << std::endl
|
||||
<< "triggers:" << r.triggers << std::endl
|
||||
<< "bursts:" << r.bursts << std::endl
|
||||
@ -86,7 +86,7 @@ std::string ToString(const slsDetectorDefs::rxParameters &r) {
|
||||
<< "gateDelay3:" << ToString(std::chrono::nanoseconds(r.gateDelay3Ns))
|
||||
<< std::endl
|
||||
<< "gates:" << r.gates << std::endl
|
||||
<< "scanParams:" << sls::ToString(r.scanParams) << std::endl
|
||||
<< "scanParams:" << ToString(r.scanParams) << std::endl
|
||||
<< ']';
|
||||
return oss.str();
|
||||
}
|
||||
@ -123,7 +123,7 @@ std::ostream &operator<<(std::ostream &os,
|
||||
std::string ToString(const slsDetectorDefs::currentSrcParameters &r) {
|
||||
std::ostringstream oss;
|
||||
if (r.fix < -1 || r.fix > 1 || r.normal < -1 || r.normal > 1) {
|
||||
throw sls::RuntimeError(
|
||||
throw RuntimeError(
|
||||
"Invalid current source parameters. Cannot print.");
|
||||
}
|
||||
oss << '[';
|
||||
@ -674,7 +674,7 @@ template <> defs::detectorType StringTo(const std::string &s) {
|
||||
return defs::MYTHEN3;
|
||||
if (s == "Gotthard2")
|
||||
return defs::GOTTHARD2;
|
||||
throw sls::RuntimeError("Unknown detector type " + s);
|
||||
throw RuntimeError("Unknown detector type " + s);
|
||||
}
|
||||
|
||||
template <> defs::detectorSettings StringTo(const std::string &s) {
|
||||
@ -718,7 +718,7 @@ template <> defs::detectorSettings StringTo(const std::string &s) {
|
||||
return defs::GAIN0;
|
||||
if (s == "g4_lg")
|
||||
return defs::G4_LOWGAIN;
|
||||
throw sls::RuntimeError("Unknown setting " + s);
|
||||
throw RuntimeError("Unknown setting " + s);
|
||||
}
|
||||
|
||||
template <> defs::speedLevel StringTo(const std::string &s) {
|
||||
@ -738,7 +738,7 @@ template <> defs::speedLevel StringTo(const std::string &s) {
|
||||
return defs::G2_108MHZ;
|
||||
if (s == "144")
|
||||
return defs::G2_144MHZ;
|
||||
throw sls::RuntimeError("Unknown speed " + s);
|
||||
throw RuntimeError("Unknown speed " + s);
|
||||
}
|
||||
|
||||
template <> defs::timingMode StringTo(const std::string &s) {
|
||||
@ -752,7 +752,7 @@ template <> defs::timingMode StringTo(const std::string &s) {
|
||||
return defs::BURST_TRIGGER;
|
||||
if (s == "trigger_gating")
|
||||
return defs::TRIGGER_GATED;
|
||||
throw sls::RuntimeError("Unknown timing mode " + s);
|
||||
throw RuntimeError("Unknown timing mode " + s);
|
||||
}
|
||||
|
||||
template <> defs::frameDiscardPolicy StringTo(const std::string &s) {
|
||||
@ -762,7 +762,7 @@ template <> defs::frameDiscardPolicy StringTo(const std::string &s) {
|
||||
return defs::DISCARD_EMPTY_FRAMES;
|
||||
if (s == "discardpartial")
|
||||
return defs::DISCARD_PARTIAL_FRAMES;
|
||||
throw sls::RuntimeError("Unknown frame discard policy " + s);
|
||||
throw RuntimeError("Unknown frame discard policy " + s);
|
||||
}
|
||||
|
||||
template <> defs::fileFormat StringTo(const std::string &s) {
|
||||
@ -770,7 +770,7 @@ template <> defs::fileFormat StringTo(const std::string &s) {
|
||||
return defs::HDF5;
|
||||
if (s == "binary")
|
||||
return defs::BINARY;
|
||||
throw sls::RuntimeError("Unknown file format " + s);
|
||||
throw RuntimeError("Unknown file format " + s);
|
||||
}
|
||||
|
||||
template <> defs::externalSignalFlag StringTo(const std::string &s) {
|
||||
@ -782,7 +782,7 @@ template <> defs::externalSignalFlag StringTo(const std::string &s) {
|
||||
return defs::INVERSION_ON;
|
||||
if (s == "inversion_off")
|
||||
return defs::INVERSION_OFF;
|
||||
throw sls::RuntimeError("Unknown external signal flag " + s);
|
||||
throw RuntimeError("Unknown external signal flag " + s);
|
||||
}
|
||||
|
||||
template <> defs::readoutMode StringTo(const std::string &s) {
|
||||
@ -792,7 +792,7 @@ template <> defs::readoutMode StringTo(const std::string &s) {
|
||||
return defs::DIGITAL_ONLY;
|
||||
if (s == "analog_digital")
|
||||
return defs::ANALOG_AND_DIGITAL;
|
||||
throw sls::RuntimeError("Unknown readout mode " + s);
|
||||
throw RuntimeError("Unknown readout mode " + s);
|
||||
}
|
||||
|
||||
template <> defs::dacIndex StringTo(const std::string &s) {
|
||||
@ -982,7 +982,7 @@ template <> defs::dacIndex StringTo(const std::string &s) {
|
||||
return defs::TEMPERATURE_FPGA3;
|
||||
if (s == "temp_slowadc")
|
||||
return defs::SLOW_ADC_TEMP;
|
||||
throw sls::RuntimeError("Unknown dac Index " + s);
|
||||
throw RuntimeError("Unknown dac Index " + s);
|
||||
}
|
||||
|
||||
template <> defs::burstMode StringTo(const std::string &s) {
|
||||
@ -994,7 +994,7 @@ template <> defs::burstMode StringTo(const std::string &s) {
|
||||
return defs::CONTINUOUS_INTERNAL;
|
||||
if (s == "cw_external")
|
||||
return defs::CONTINUOUS_EXTERNAL;
|
||||
throw sls::RuntimeError("Unknown burst mode " + s);
|
||||
throw RuntimeError("Unknown burst mode " + s);
|
||||
}
|
||||
|
||||
template <> defs::timingSourceType StringTo(const std::string &s) {
|
||||
@ -1002,7 +1002,7 @@ template <> defs::timingSourceType StringTo(const std::string &s) {
|
||||
return defs::TIMING_INTERNAL;
|
||||
if (s == "external")
|
||||
return defs::TIMING_EXTERNAL;
|
||||
throw sls::RuntimeError("Unknown timing source type " + s);
|
||||
throw RuntimeError("Unknown timing source type " + s);
|
||||
}
|
||||
|
||||
template <> defs::M3_GainCaps StringTo(const std::string &s) {
|
||||
@ -1018,7 +1018,7 @@ template <> defs::M3_GainCaps StringTo(const std::string &s) {
|
||||
return defs::M3_C225ACsh;
|
||||
if (s == "C15pre")
|
||||
return defs::M3_C15pre;
|
||||
throw sls::RuntimeError("Unknown gain cap " + s);
|
||||
throw RuntimeError("Unknown gain cap " + s);
|
||||
}
|
||||
|
||||
template <> defs::portPosition StringTo(const std::string &s) {
|
||||
@ -1030,7 +1030,7 @@ template <> defs::portPosition StringTo(const std::string &s) {
|
||||
return defs::TOP;
|
||||
if (s == "bottom")
|
||||
return defs::BOTTOM;
|
||||
throw sls::RuntimeError("Unknown port position " + s);
|
||||
throw RuntimeError("Unknown port position " + s);
|
||||
}
|
||||
|
||||
template <> defs::streamingInterface StringTo(const std::string &s) {
|
||||
@ -1043,7 +1043,7 @@ template <> defs::streamingInterface StringTo(const std::string &s) {
|
||||
return defs::streamingInterface::LOW_LATENCY_LINK;
|
||||
if (rs == "10gbe")
|
||||
return defs::streamingInterface::ETHERNET_10GB;
|
||||
throw sls::RuntimeError("Unknown streamingInterface type " + s);
|
||||
throw RuntimeError("Unknown streamingInterface type " + s);
|
||||
}
|
||||
|
||||
template <> defs::vetoAlgorithm StringTo(const std::string &s) {
|
||||
@ -1051,7 +1051,7 @@ template <> defs::vetoAlgorithm StringTo(const std::string &s) {
|
||||
return defs::ALG_HITS;
|
||||
if (s == "raw")
|
||||
return defs::ALG_RAW;
|
||||
throw sls::RuntimeError("Unknown veto algorithm " + s);
|
||||
throw RuntimeError("Unknown veto algorithm " + s);
|
||||
}
|
||||
|
||||
template <> defs::gainMode StringTo(const std::string &s) {
|
||||
@ -1067,7 +1067,7 @@ template <> defs::gainMode StringTo(const std::string &s) {
|
||||
return defs::FIX_G2;
|
||||
if (s == "fixg0")
|
||||
return defs::FIX_G0;
|
||||
throw sls::RuntimeError("Unknown gain mode " + s);
|
||||
throw RuntimeError("Unknown gain mode " + s);
|
||||
}
|
||||
|
||||
template <> defs::polarity StringTo(const std::string &s) {
|
||||
@ -1075,7 +1075,7 @@ template <> defs::polarity StringTo(const std::string &s) {
|
||||
return defs::POSITIVE;
|
||||
if (s == "neg")
|
||||
return defs::NEGATIVE;
|
||||
throw sls::RuntimeError("Unknown polarity mode " + s);
|
||||
throw RuntimeError("Unknown polarity mode " + s);
|
||||
}
|
||||
|
||||
template <> uint32_t StringTo(const std::string &s) {
|
||||
@ -1101,7 +1101,7 @@ template <> bool StringTo(const std::string &s) {
|
||||
case 1:
|
||||
return true;
|
||||
default:
|
||||
throw sls::RuntimeError("Unknown boolean. Expecting be 0 or 1.");
|
||||
throw RuntimeError("Unknown boolean. Expecting be 0 or 1.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,14 +10,15 @@
|
||||
#include <string.h>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <zmq.h>
|
||||
|
||||
namespace sls {
|
||||
|
||||
using namespace rapidjson;
|
||||
ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
|
||||
const uint32_t portnumber)
|
||||
: portno(portnumber), sockfd(false) {
|
||||
// Extra check that throws if conversion fails, could be removed
|
||||
auto ipstr = sls::HostnameToIp(hostname_or_ip).str();
|
||||
auto ipstr = HostnameToIp(hostname_or_ip).str();
|
||||
std::ostringstream oss;
|
||||
oss << "tcp://" << ipstr << ":" << portno;
|
||||
sockfd.serverAddress = oss.str();
|
||||
@ -26,20 +27,20 @@ ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
|
||||
// create context
|
||||
sockfd.contextDescriptor = zmq_ctx_new();
|
||||
if (sockfd.contextDescriptor == nullptr)
|
||||
throw sls::ZmqSocketError("Could not create contextDescriptor");
|
||||
throw ZmqSocketError("Could not create contextDescriptor");
|
||||
|
||||
// create subscriber
|
||||
sockfd.socketDescriptor = zmq_socket(sockfd.contextDescriptor, ZMQ_SUB);
|
||||
if (sockfd.socketDescriptor == nullptr) {
|
||||
PrintError();
|
||||
throw sls::ZmqSocketError("Could not create socket");
|
||||
throw ZmqSocketError("Could not create socket");
|
||||
}
|
||||
|
||||
// Socket Options provided above
|
||||
// an empty string implies receiving any messages
|
||||
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_SUBSCRIBE, "", 0)) {
|
||||
PrintError();
|
||||
throw sls::ZmqSocketError("Could set socket opt");
|
||||
throw ZmqSocketError("Could set socket opt");
|
||||
}
|
||||
// ZMQ_LINGER default is already -1 means no messages discarded. use this
|
||||
// options if optimizing required ZMQ_SNDHWM default is 0 means no limit.
|
||||
@ -48,7 +49,7 @@ ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
|
||||
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_LINGER, &value,
|
||||
sizeof(value))) {
|
||||
PrintError();
|
||||
throw sls::ZmqSocketError("Could not set ZMQ_LINGER");
|
||||
throw ZmqSocketError("Could not set ZMQ_LINGER");
|
||||
}
|
||||
LOG(logDEBUG) << "Default receive high water mark:"
|
||||
<< GetReceiveHighWaterMark();
|
||||
@ -59,13 +60,13 @@ ZmqSocket::ZmqSocket(const uint32_t portnumber, const char *ethip)
|
||||
// create context
|
||||
sockfd.contextDescriptor = zmq_ctx_new();
|
||||
if (sockfd.contextDescriptor == nullptr)
|
||||
throw sls::ZmqSocketError("Could not create contextDescriptor");
|
||||
throw ZmqSocketError("Could not create contextDescriptor");
|
||||
|
||||
// create publisher
|
||||
sockfd.socketDescriptor = zmq_socket(sockfd.contextDescriptor, ZMQ_PUB);
|
||||
if (sockfd.socketDescriptor == nullptr) {
|
||||
PrintError();
|
||||
throw sls::ZmqSocketError("Could not create socket");
|
||||
throw ZmqSocketError("Could not create socket");
|
||||
}
|
||||
LOG(logDEBUG) << "Default send high water mark:" << GetSendHighWaterMark();
|
||||
|
||||
@ -78,7 +79,7 @@ ZmqSocket::ZmqSocket(const uint32_t portnumber, const char *ethip)
|
||||
// bind address
|
||||
if (zmq_bind(sockfd.socketDescriptor, sockfd.serverAddress.c_str())) {
|
||||
PrintError();
|
||||
throw sls::ZmqSocketError("Could not bind socket");
|
||||
throw ZmqSocketError("Could not bind socket");
|
||||
}
|
||||
// sleep to allow a slow-joiner
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
@ -90,7 +91,7 @@ int ZmqSocket::GetSendHighWaterMark() {
|
||||
if (zmq_getsockopt(sockfd.socketDescriptor, ZMQ_SNDHWM, &value,
|
||||
&value_size)) {
|
||||
PrintError();
|
||||
throw sls::ZmqSocketError("Could not get ZMQ_SNDHWM");
|
||||
throw ZmqSocketError("Could not get ZMQ_SNDHWM");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -99,7 +100,7 @@ void ZmqSocket::SetSendHighWaterMark(int limit) {
|
||||
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_SNDHWM, &limit,
|
||||
sizeof(limit))) {
|
||||
PrintError();
|
||||
throw sls::ZmqSocketError("Could not set ZMQ_SNDHWM");
|
||||
throw ZmqSocketError("Could not set ZMQ_SNDHWM");
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +110,7 @@ int ZmqSocket::GetReceiveHighWaterMark() {
|
||||
if (zmq_getsockopt(sockfd.socketDescriptor, ZMQ_RCVHWM, &value,
|
||||
&value_size)) {
|
||||
PrintError();
|
||||
throw sls::ZmqSocketError("Could not get ZMQ_SNDHWM");
|
||||
throw ZmqSocketError("Could not get ZMQ_SNDHWM");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -118,7 +119,7 @@ void ZmqSocket::SetReceiveHighWaterMark(int limit) {
|
||||
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_RCVHWM, &limit,
|
||||
sizeof(limit))) {
|
||||
PrintError();
|
||||
throw sls::ZmqSocketError("Could not set ZMQ_SNDHWM");
|
||||
throw ZmqSocketError("Could not set ZMQ_SNDHWM");
|
||||
}
|
||||
}
|
||||
|
||||
@ -414,3 +415,6 @@ void ZmqSocket::mySocketDescriptors::Close() {
|
||||
contextDescriptor = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
||||
|
@ -60,28 +60,28 @@ std::vector<char> readBinaryFile(const std::string &fname,
|
||||
// check if it exists
|
||||
struct stat st;
|
||||
if (stat(fname.c_str(), &st) != 0) {
|
||||
throw sls::RuntimeError(errorPrefix +
|
||||
throw RuntimeError(errorPrefix +
|
||||
std::string(" (file does not exist)"));
|
||||
}
|
||||
|
||||
FILE *fp = fopen(fname.c_str(), "rb");
|
||||
if (fp == nullptr) {
|
||||
throw sls::RuntimeError(errorPrefix +
|
||||
throw RuntimeError(errorPrefix +
|
||||
std::string(" (Could not open file: ") + fname +
|
||||
std::string(")"));
|
||||
}
|
||||
|
||||
// get file size to print progress
|
||||
ssize_t filesize = sls::getFileSize(fp, errorPrefix);
|
||||
ssize_t filesize = getFileSize(fp, errorPrefix);
|
||||
|
||||
std::vector<char> buffer(filesize, 0);
|
||||
if ((ssize_t)fread(buffer.data(), sizeof(char), filesize, fp) != filesize) {
|
||||
throw sls::RuntimeError(errorPrefix +
|
||||
throw RuntimeError(errorPrefix +
|
||||
std::string(" (Could not read file)"));
|
||||
}
|
||||
|
||||
if (fclose(fp) != 0) {
|
||||
throw sls::RuntimeError(errorPrefix +
|
||||
throw RuntimeError(errorPrefix +
|
||||
std::string(" (Could not close file)"));
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ void mkdir_p(const std::string &path, std::string dir) {
|
||||
}
|
||||
if (mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
|
||||
if (errno != EEXIST)
|
||||
throw sls::RuntimeError("Could not create: " + dir);
|
||||
throw RuntimeError("Could not create: " + dir);
|
||||
}
|
||||
|
||||
if (i + 1 < path.length())
|
||||
|
Reference in New Issue
Block a user