Merge branch 'developer' into eiger26

This commit is contained in:
maliakal_d 2020-05-12 11:39:29 +02:00
commit d7563fdd1a
7 changed files with 178 additions and 537 deletions

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ target_sources(tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-global.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-Result.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdParser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-Module.cpp
)
target_include_directories(tests PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>")

View File

@ -0,0 +1,8 @@
#include "Module.h"
#include "catch.hpp"
using dt = slsDetectorDefs::detectorType;
TEST_CASE("Construction with a defined detector type") {
sls::Module m(dt::EIGER);
REQUIRE(m.getDetectorType() == dt::EIGER);
}

View File

@ -12,6 +12,7 @@
#include "sls_detector_defs.h"
#include "sls_detector_exceptions.h"
#include "string_utils.h"
#include "FixedCapacityContainer.h"
#include <chrono>
#include <iomanip>
#include <map>
@ -36,6 +37,14 @@ std::string ToString(const defs::detectorModeType s);
std::string ToString(const defs::burstMode s);
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){
return os << ToString(c);
}
const std::string &ToString(const std::string &s);
/** Convert std::chrono::duration with specified output unit */

View File

@ -2,6 +2,16 @@
namespace sls {
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){
return os << ToString(roi);
}
std::string ToString(const defs::runStatus s) {
switch (s) {
case defs::ERROR:

View File

@ -6,6 +6,7 @@
#include <array>
#include <map>
#include <vector>
#include <sstream>
// using namespace sls;
using sls::defs;
@ -217,3 +218,34 @@ TEST_CASE("Detector type") {
REQUIRE(ToString(dt) == "Eiger");
REQUIRE(StringTo<defs::detectorType>("Eiger") == dt);
}
TEST_CASE("Formatting slsDetectorDefs::ROI"){
slsDetectorDefs::ROI roi{5,159};
REQUIRE(ToString(roi) == "[5, 159]");
}
TEST_CASE("Streaming of slsDetectorDefs::ROI"){
using namespace sls;
slsDetectorDefs::ROI roi{-10,1};
std::ostringstream oss;
oss << roi;
REQUIRE(oss.str() == "[-10, 1]");
}
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"){
sls::FixedCapacityContainer<int, 5> vec;
vec.push_back(33);
vec.push_back(85667);
vec.push_back(2);
std::ostringstream oss;
oss << vec;
REQUIRE(oss.str() == "[33, 85667, 2]");
}

View File

@ -9,10 +9,10 @@ TEST_CASE("sls_detector_module default construction", "[support][new]") {
CHECK(m.nchan == 0);
CHECK(m.nchip == 0);
CHECK(m.ndac == 0);
CHECK(m.reg == 0);
CHECK(m.reg == -1);
CHECK(m.iodelay == 0);
CHECK(m.tau == 0);
CHECK(m.eV == 0);
CHECK(m.eV == -1);
CHECK(m.dacs == nullptr);
CHECK(m.chanregs == nullptr);
}
@ -23,10 +23,10 @@ TEST_CASE("sls_detector_module from type", "[support]") {
CHECK(m.nchan == 256 * 256 * 4);
CHECK(m.nchip == 4);
CHECK(m.ndac == 16);
CHECK(m.reg == 0);
CHECK(m.reg == -1);
CHECK(m.iodelay == 0);
CHECK(m.tau == 0);
CHECK(m.eV == 0);
CHECK(m.eV == -1);
CHECK(m.dacs != nullptr);
CHECK(m.chanregs != nullptr);
}