mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
format + exception.cpp
This commit is contained in:
@ -9,13 +9,13 @@ set(SOURCES
|
||||
src/network_utils.cpp
|
||||
src/ZmqSocket.cpp
|
||||
src/UdpRxSocket.cpp
|
||||
src/sls_detector_exceptions.cpp
|
||||
)
|
||||
|
||||
set(HEADERS
|
||||
)
|
||||
|
||||
set(PUBLICHEADERS
|
||||
include/ansi.h
|
||||
include/sls_detector_defs.h
|
||||
include/sls_detector_funcs.h
|
||||
include/versionAPI.h
|
||||
@ -23,7 +23,6 @@ set(PUBLICHEADERS
|
||||
include/file_utils.h
|
||||
include/container_utils.h
|
||||
include/string_utils.h
|
||||
include/logger.h
|
||||
include/ClientSocket.h
|
||||
include/DataSocket.h
|
||||
include/ServerSocket.h
|
||||
|
@ -7,12 +7,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "FixedCapacityContainer.h"
|
||||
#include "TimeHelper.h"
|
||||
#include "TypeTraits.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "string_utils.h"
|
||||
#include "FixedCapacityContainer.h"
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
@ -40,8 +40,9 @@ std::string ToString(const defs::timingSourceType s);
|
||||
std::string ToString(const slsDetectorDefs::ROI &roi);
|
||||
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::ROI &roi);
|
||||
|
||||
template<typename T, size_t Capacity>
|
||||
std::ostream &operator<<(std::ostream &os, const sls::FixedCapacityContainer<T, Capacity>& c){
|
||||
template <typename T, size_t Capacity>
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const sls::FixedCapacityContainer<T, Capacity> &c) {
|
||||
return os << ToString(c);
|
||||
}
|
||||
|
||||
|
@ -1,55 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "logger.h"
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
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; }
|
||||
RuntimeError();
|
||||
RuntimeError(const std::string &msg);
|
||||
RuntimeError(const char *msg);
|
||||
};
|
||||
|
||||
struct SharedMemoryError : public RuntimeError {
|
||||
public:
|
||||
SharedMemoryError(const std::string &msg) : RuntimeError(msg) {}
|
||||
SharedMemoryError(const std::string &msg);
|
||||
};
|
||||
|
||||
struct SocketError : public RuntimeError {
|
||||
public:
|
||||
SocketError(const std::string &msg) : RuntimeError(msg) {}
|
||||
SocketError(const std::string &msg);
|
||||
};
|
||||
|
||||
struct ZmqSocketError : public RuntimeError {
|
||||
public:
|
||||
ZmqSocketError(const std::string &msg) : RuntimeError(msg) {}
|
||||
ZmqSocketError(const std::string &msg);
|
||||
};
|
||||
|
||||
struct NotImplementedError : public RuntimeError {
|
||||
public:
|
||||
NotImplementedError(const std::string &msg) : RuntimeError(msg) {}
|
||||
NotImplementedError(const std::string &msg);
|
||||
};
|
||||
|
||||
struct DetectorError : public RuntimeError {
|
||||
public:
|
||||
DetectorError(const std::string &msg) : RuntimeError(msg) {}
|
||||
DetectorError(const std::string &msg);
|
||||
};
|
||||
|
||||
struct ReceiverError : public RuntimeError {
|
||||
public:
|
||||
ReceiverError(const std::string &msg) : RuntimeError(msg) {}
|
||||
ReceiverError(const std::string &msg);
|
||||
};
|
||||
|
||||
struct GuiError : public RuntimeError {
|
||||
public:
|
||||
GuiError(const std::string &msg) : RuntimeError(msg) {}
|
||||
GuiError(const std::string &msg);
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
@ -10,4 +10,4 @@
|
||||
#define APIJUNGFRAU 0x200508
|
||||
#define APIMYTHEN3 0x200508
|
||||
#define APIMOENCH 0x200508
|
||||
#define APIEIGER 0x200513
|
||||
#define APIEIGER 0x200513
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "ServerInterface.h"
|
||||
#include "logger.h"
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
std::string ToString(const slsDetectorDefs::ROI& roi){
|
||||
std::string ToString(const slsDetectorDefs::ROI &roi) {
|
||||
std::ostringstream oss;
|
||||
oss << '[' << roi.xmin << ", " << roi.xmax << ']';
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
std::ostream&operator<<(std::ostream &os, const slsDetectorDefs::ROI& roi){
|
||||
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::ROI &roi) {
|
||||
return os << ToString(roi);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "UdpRxSocket.h"
|
||||
#include "logger.h"
|
||||
#include "network_utils.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include <cstdint>
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "ZmqSocket.h"
|
||||
#include "logger.h"
|
||||
#include <arpa/inet.h> //inet_ntoa
|
||||
#include <errno.h>
|
||||
#include <iostream>
|
||||
|
23
slsSupportLib/src/sls_detector_exceptions.cpp
Normal file
23
slsSupportLib/src/sls_detector_exceptions.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "logger.h"
|
||||
namespace sls {
|
||||
RuntimeError::RuntimeError() : runtime_error("SLS Detector Package Failed") {
|
||||
LOG(logERROR) << "SLS Detector Package Failed";
|
||||
}
|
||||
RuntimeError::RuntimeError(const std::string &msg) : runtime_error(msg) {
|
||||
LOG(logERROR) << msg;
|
||||
}
|
||||
RuntimeError::RuntimeError(const char *msg) : runtime_error(msg) {
|
||||
LOG(logERROR) << msg;
|
||||
}
|
||||
SharedMemoryError::SharedMemoryError(const std::string &msg)
|
||||
: RuntimeError(msg) {}
|
||||
SocketError::SocketError(const std::string &msg) : RuntimeError(msg) {}
|
||||
ZmqSocketError::ZmqSocketError(const std::string &msg) : RuntimeError(msg) {}
|
||||
NotImplementedError::NotImplementedError(const std::string &msg)
|
||||
: RuntimeError(msg) {}
|
||||
DetectorError::DetectorError(const std::string &msg) : RuntimeError(msg) {}
|
||||
ReceiverError::ReceiverError(const std::string &msg) : RuntimeError(msg) {}
|
||||
GuiError::GuiError(const std::string &msg) : RuntimeError(msg) {}
|
||||
|
||||
} // namespace sls
|
@ -5,8 +5,8 @@
|
||||
#include "sls_detector_defs.h"
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
// using namespace sls;
|
||||
using sls::defs;
|
||||
@ -219,28 +219,27 @@ TEST_CASE("Detector type") {
|
||||
REQUIRE(StringTo<defs::detectorType>("Eiger") == dt);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Formatting slsDetectorDefs::ROI"){
|
||||
slsDetectorDefs::ROI roi{5,159};
|
||||
TEST_CASE("Formatting slsDetectorDefs::ROI") {
|
||||
slsDetectorDefs::ROI roi{5, 159};
|
||||
REQUIRE(ToString(roi) == "[5, 159]");
|
||||
}
|
||||
|
||||
TEST_CASE("Streaming of slsDetectorDefs::ROI"){
|
||||
TEST_CASE("Streaming of slsDetectorDefs::ROI") {
|
||||
using namespace sls;
|
||||
slsDetectorDefs::ROI roi{-10,1};
|
||||
slsDetectorDefs::ROI roi{-10, 1};
|
||||
std::ostringstream oss;
|
||||
oss << roi;
|
||||
REQUIRE(oss.str() == "[-10, 1]");
|
||||
}
|
||||
|
||||
TEST_CASE("sls::FixedCapacityContainer"){
|
||||
TEST_CASE("sls::FixedCapacityContainer") {
|
||||
sls::FixedCapacityContainer<int, 5> vec;
|
||||
vec.push_back(3);
|
||||
vec.push_back(8);
|
||||
REQUIRE(ToString(vec) == "[3, 8]");
|
||||
}
|
||||
|
||||
TEST_CASE("sls::FixedCapacityContainer stream"){
|
||||
TEST_CASE("sls::FixedCapacityContainer stream") {
|
||||
sls::FixedCapacityContainer<int, 5> vec;
|
||||
vec.push_back(33);
|
||||
vec.push_back(85667);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "catch.hpp"
|
||||
#include "network_utils.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "sls_detector_exceptions.h"
|
||||
|
Reference in New Issue
Block a user