merge conflict

This commit is contained in:
2021-07-22 11:15:57 +02:00
28 changed files with 655 additions and 116 deletions

View File

@ -38,6 +38,7 @@ std::string ToString(const defs::burstMode s);
std::string ToString(const defs::timingSourceType s);
std::string ToString(const defs::M3_GainCaps s);
std::string ToString(const defs::portPosition s);
std::string ToString(const defs::EthernetInterface s);
std::string ToString(const slsDetectorDefs::xy &coord);
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
@ -301,6 +302,7 @@ template <> defs::burstMode StringTo(const std::string &s);
template <> defs::timingSourceType StringTo(const std::string &s);
template <> defs::M3_GainCaps StringTo(const std::string &s);
template <> defs::portPosition StringTo(const std::string &s);
template <> defs::EthernetInterface StringTo(const std::string &s);
template <> uint32_t StringTo(const std::string &s);
template <> uint64_t StringTo(const std::string &s);

View File

@ -403,6 +403,17 @@ typedef struct {
enum portPosition { LEFT, RIGHT, TOP, BOTTOM };
#ifdef __cplusplus
enum class EthernetInterface {
#else
enum EthernetInterface {
#endif
NONE = 0,
I3GBE = 1 << 1,
I10GBE = 1 << 2,
ALL = I3GBE | I10GBE
};
#ifdef __cplusplus
/** scan structure */
@ -496,8 +507,18 @@ typedef struct {
#ifdef __cplusplus
};
inline slsDetectorDefs::EthernetInterface
operator|( const slsDetectorDefs::EthernetInterface &a,
const slsDetectorDefs::EthernetInterface &b) {
return slsDetectorDefs::EthernetInterface(static_cast<int32_t>(a) |
static_cast<int32_t>(b));
};
inline slsDetectorDefs::EthernetInterface operator&( const slsDetectorDefs::EthernetInterface &a,
const slsDetectorDefs::EthernetInterface &b) {
return slsDetectorDefs::EthernetInterface(static_cast<int32_t>(a) & static_cast<int32_t>(b));
};
#endif
;
#ifdef __cplusplus
struct detParameters {
@ -644,3 +665,4 @@ using Positions = const std::vector<int> &;
using defs = slsDetectorDefs;
} // namespace sls
#endif

View File

@ -226,6 +226,8 @@ enum detFuncs {
F_GET_GAIN_CAPS,
F_GET_DATASTREAM,
F_SET_DATASTREAM,
F_GET_VETO_STREAM,
F_SET_VETO_STREAM,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
@ -554,8 +556,12 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_LOAD_DEFAULT_PATTERN: return "F_LOAD_DEFAULT_PATTERN";
case F_GET_ALL_THRESHOLD_ENERGY: return "F_GET_ALL_THRESHOLD_ENERGY";
case F_GET_MASTER: return "F_GET_MASTER";
case F_SET_GAIN_CAPS: return "F_SET_GAIN_CAPS";
case F_GET_GAIN_CAPS: return "F_GET_GAIN_CAPS";
case F_GET_DATASTREAM: return "F_GET_DATASTREAM";
case F_SET_DATASTREAM: return "F_SET_DATASTREAM";
case F_GET_VETO_STREAM: return "F_GET_VETO_STREAM";
case F_SET_VETO_STREAM: return "F_SET_VETO_STREAM";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -5,9 +5,8 @@
#define APIGUI 0x210225
#define APICTB 0x210621
#define APIGOTTHARD 0x210621
#define APIGOTTHARD2 0x210621
#define APIJUNGFRAU 0x210621
#define APIGOTTHARD2 0x210715
#define APIJUNGFRAU 0x210714
#define APIMYTHEN3 0x210621
#define APIMOENCH 0x210621
#define APIEIGER 0x210721
#define APIEIGER 0x210721

View File

@ -53,7 +53,7 @@ std::string ToString(const slsDetectorDefs::rxParameters &r) {
<< std::endl
<< "activate:" << r.activate << std::endl
<< "leftDataStream:" << r.dataStreamLeft << std::endl
<< "rightDataStream:" << r.dataStreamRight << std::endl
<< "rightDataStream:" << r.dataStreamRight << std::endl
<< "quad:" << r.quad << std::endl
<< "numLinesReadout:" << r.numLinesReadout << std::endl
<< "thresholdEnergyeV:" << ToString(r.thresholdEnergyeV) << std::endl
@ -555,6 +555,25 @@ std::string ToString(const defs::portPosition s) {
}
}
std::string ToString(const defs::EthernetInterface s) {
std::ostringstream os;
std::string rs;
switch (s) {
case defs::EthernetInterface::NONE:
return std::string("none");
default:
if ((s & defs::EthernetInterface::I3GBE) !=
defs::EthernetInterface::NONE)
os << "3gbe, ";
if ((s & defs::EthernetInterface::I10GBE) !=
defs::EthernetInterface::NONE)
os << "10gbe, ";
auto rs = os.str();
rs.erase(rs.end() - 2, rs.end());
return rs;
}
}
const std::string &ToString(const std::string &s) { return s; }
template <> defs::detectorType StringTo(const std::string &s) {
@ -923,6 +942,19 @@ template <> defs::portPosition StringTo(const std::string &s) {
throw sls::RuntimeError("Unknown port position " + s);
}
template <> defs::EthernetInterface StringTo(const std::string &s) {
std::string rs = s;
if (s.find(',') != std::string::npos)
rs.erase(rs.find(','));
if (rs == "none")
return defs::EthernetInterface::NONE;
if (rs == "3gbe")
return defs::EthernetInterface::I3GBE;
if (rs == "10gbe")
return defs::EthernetInterface::I10GBE;
throw sls::RuntimeError("Unknown EthernetInterface type " + s);
}
template <> uint32_t StringTo(const std::string &s) {
int base = s.find("0x") != std::string::npos ? 16 : 10;
return std::stoul(s, nullptr, base);

View File

@ -5,6 +5,7 @@
#include <thread>
#include <future>
#include <iostream>
#include <thread>
std::vector<char> server() {
std::cout << "starting server\n";

View File

@ -1,10 +1,10 @@
#include "catch.hpp"
#include "sls/Pattern.h"
#include "sls/TimeHelper.h"
#include "sls/ToString.h"
#include "sls/network_utils.h"
#include "sls/Pattern.h"
#include "sls/sls_detector_defs.h"
#include "sls/container_utils.h"
#include "sls/network_utils.h"
#include "sls/sls_detector_defs.h"
#include <array>
#include <map>
#include <sstream>
@ -302,25 +302,32 @@ TEST_CASE("Streaming of slsDetectorDefs::scanParameters") {
}
}
TEST_CASE("Printing c style arrays of int"){
TEST_CASE("Printing c style arrays of int") {
int arr[]{3, 5};
REQUIRE(ToString(arr) == "[3, 5]");
}
TEST_CASE("Printing c style arrays of uint8"){
uint8_t arr[]{1,2,3,4,5};
TEST_CASE("Printing c style arrays of uint8") {
uint8_t arr[]{1, 2, 3, 4, 5};
REQUIRE(ToString(arr) == "[1, 2, 3, 4, 5]");
}
TEST_CASE("Printing c style arrays of double"){
TEST_CASE("Printing c style arrays of double") {
double arr[]{3.4, 5.3, 6.2};
REQUIRE(ToString(arr) == "[3.4, 5.3, 6.2]");
}
TEST_CASE("Print a member of patternParameters"){
TEST_CASE("Print a member of patternParameters") {
auto pat = sls::make_unique<sls::patternParameters>();
pat->limits[0] = 4;
pat->limits[1] = 100;
REQUIRE(ToString(pat->limits) == "[4, 100]");
}
TEST_CASE("EthernetInterface") {
REQUIRE(ToString(sls::defs::EthernetInterface::NONE) == "none");
REQUIRE(ToString(sls::defs::EthernetInterface::I10GBE) == "10gbe");
REQUIRE(ToString(sls::defs::EthernetInterface::I3GBE) == "3gbe");
REQUIRE(ToString(sls::defs::EthernetInterface::I3GBE |
sls::defs::EthernetInterface::I10GBE) == "3gbe, 10gbe");
}