mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer
This commit is contained in:
commit
ad0fb44573
@ -106,10 +106,10 @@ endif()
|
||||
|
||||
|
||||
if(SLS_USE_SANITIZER)
|
||||
# target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
|
||||
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
|
||||
target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
|
||||
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
|
||||
target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
|
||||
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
|
||||
# target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
|
||||
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
|
||||
endif()
|
||||
|
||||
#rapidjson
|
||||
|
@ -4,7 +4,7 @@ set(SOURCES
|
||||
src/slsDetector.cpp
|
||||
src/Detector.cpp
|
||||
src/CmdProxy.cpp
|
||||
src/CmdLineParser.cpp
|
||||
src/CmdParser.cpp
|
||||
)
|
||||
|
||||
set(HEADERS
|
||||
|
@ -1,5 +1,11 @@
|
||||
|
||||
#include "CmdLineParser.h"
|
||||
/*
|
||||
This file is used to generate the command line binaries
|
||||
(sls_detector_get/put/acquire/help). By defines in CMake
|
||||
we get the different files.
|
||||
|
||||
*/
|
||||
#include "CmdParser.h"
|
||||
#include "CmdProxy.h"
|
||||
#include "Detector.h"
|
||||
#include "sls_detector_defs.h"
|
||||
@ -35,7 +41,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
sls::CmdLineParser parser;
|
||||
sls::CmdParser parser;
|
||||
parser.Parse(argc, argv);
|
||||
|
||||
// If we called sls_detector_acquire, add the acquire command
|
||||
@ -57,16 +63,11 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
try {
|
||||
//How big should this try block be?
|
||||
// How big should this try block be?
|
||||
sls::Detector det(parser.multi_id());
|
||||
sls::CmdProxy proxy(&det);
|
||||
auto cmd = proxy.Call(parser.command(), parser.arguments(),
|
||||
parser.detector_id(), action);
|
||||
// TODO! move this check into CmdProxy
|
||||
if (!cmd.empty()) {
|
||||
std::cout << cmd
|
||||
<< " Unknown command, use list to list all commands\n";
|
||||
}
|
||||
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
|
||||
action);
|
||||
} catch (const sls::RuntimeError &e) {
|
||||
// OK to catch and do nothing since this will print the error message
|
||||
// and command line app will anyway exit
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include "CmdLineParser.h"
|
||||
#include "CmdParser.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
@ -9,8 +9,8 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
void CmdLineParser::Print() {
|
||||
std::cout << "\nCmdLineParser::Print()\n";
|
||||
void CmdParser::Print() {
|
||||
std::cout << "\nCmdParser::Print()\n";
|
||||
std::cout << "\tmulti_id: " << multi_id_
|
||||
<< ", detector_id: " << detector_id_ << std::endl;
|
||||
std::cout << "\texecutable: " << executable_ << '\n';
|
||||
@ -23,7 +23,7 @@ void CmdLineParser::Print() {
|
||||
std::cout << "\n\n";
|
||||
};
|
||||
|
||||
void CmdLineParser::Parse(int argc, const char *const argv[]) {
|
||||
void CmdParser::Parse(int argc, const char *const argv[]) {
|
||||
Reset();
|
||||
executable_ = argv[0]; // first arg is calling binary
|
||||
if (argc > 1) {
|
||||
@ -36,7 +36,7 @@ void CmdLineParser::Parse(int argc, const char *const argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
void CmdLineParser::Parse(const std::string &s) {
|
||||
void CmdParser::Parse(const std::string &s) {
|
||||
Reset();
|
||||
std::istringstream iss(s);
|
||||
auto it = std::istream_iterator<std::string>(iss);
|
||||
@ -59,7 +59,7 @@ void CmdLineParser::Parse(const std::string &s) {
|
||||
DecodeIdAndPosition(command_.c_str());
|
||||
}
|
||||
|
||||
void CmdLineParser::DecodeIdAndPosition(const char *c) {
|
||||
void CmdParser::DecodeIdAndPosition(const char *c) {
|
||||
bool contains_id = std::strchr(c, '-') != nullptr;
|
||||
bool contains_pos = std::strchr(c, ':') != nullptr;
|
||||
char tmp[100];
|
||||
@ -91,7 +91,7 @@ void CmdLineParser::DecodeIdAndPosition(const char *c) {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<const char *> CmdLineParser::argv() const {
|
||||
std::vector<const char *> CmdParser::argv() const {
|
||||
std::vector<const char *> vec;
|
||||
if (command_.empty() != true) {
|
||||
vec.push_back(&command_.front());
|
||||
@ -103,7 +103,7 @@ std::vector<const char *> CmdLineParser::argv() const {
|
||||
}
|
||||
|
||||
|
||||
std::string CmdLineParser::cli_line() const{
|
||||
std::string CmdParser::cli_line() const{
|
||||
std::ostringstream os;
|
||||
os << command_;
|
||||
for (const auto & arg : arguments_)
|
||||
@ -111,7 +111,7 @@ std::string CmdLineParser::cli_line() const{
|
||||
return os.str();
|
||||
}
|
||||
|
||||
void CmdLineParser::Reset(){
|
||||
void CmdParser::Reset(){
|
||||
multi_id_ = 0;
|
||||
detector_id_ = -1;
|
||||
help_ = false;
|
@ -19,7 +19,7 @@ reason that the header file is not exposed.
|
||||
|
||||
namespace sls {
|
||||
|
||||
class CmdLineParser {
|
||||
class CmdParser {
|
||||
public:
|
||||
void Parse(int argc, const char *const argv[]);
|
||||
void Parse(const std::string &s);
|
@ -25,7 +25,7 @@ std::ostream &operator<<(std::ostream &os,
|
||||
return os;
|
||||
}
|
||||
|
||||
std::string CmdProxy::Call(const std::string &command,
|
||||
void CmdProxy::Call(const std::string &command,
|
||||
const std::vector<std::string> &arguments,
|
||||
int detector_id, int action, std::ostream &os) {
|
||||
cmd = command;
|
||||
@ -37,9 +37,8 @@ std::string CmdProxy::Call(const std::string &command,
|
||||
auto it = functions.find(cmd);
|
||||
if (it != functions.end()) {
|
||||
os << ((*this).*(it->second))(action);
|
||||
return {};
|
||||
} else {
|
||||
return cmd;
|
||||
throw sls::RuntimeError(cmd + " Unknown command, use list to list all commands");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ class CmdProxy {
|
||||
public:
|
||||
explicit CmdProxy(Detector *ptr) : det(ptr) {}
|
||||
|
||||
std::string Call(const std::string &command,
|
||||
void Call(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id = -1,
|
||||
int action = -1, std::ostream &os = std::cout);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "Detector.h"
|
||||
#include "CmdLineParser.h"
|
||||
#include "CmdParser.h"
|
||||
#include "CmdProxy.h"
|
||||
#include "container_utils.h"
|
||||
#include "detectorData.h"
|
||||
@ -58,7 +58,7 @@ void Detector::loadConfig(const std::string &fname) {
|
||||
|
||||
void Detector::loadParameters(const std::string &fname) {
|
||||
CmdProxy proxy(this);
|
||||
CmdLineParser parser;
|
||||
CmdParser parser;
|
||||
std::ifstream input_file;
|
||||
input_file.open(fname.c_str(), std::ios_base::in);
|
||||
if (!input_file.is_open()) {
|
||||
|
@ -6,7 +6,7 @@ target_sources(tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-eiger.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-jungfrau.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-Result.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdLineParser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdParser.cpp
|
||||
)
|
||||
|
||||
target_include_directories(tests PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>")
|
@ -1,4 +1,4 @@
|
||||
#include "CmdLineParser.h"
|
||||
#include "CmdParser.h"
|
||||
#include "catch.hpp"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
@ -9,11 +9,11 @@
|
||||
// command for all depreciated commands
|
||||
|
||||
using vs = std::vector<std::string>;
|
||||
using sls::CmdLineParser;
|
||||
using sls::CmdParser;
|
||||
|
||||
SCENARIO("Construction", "[support]") {
|
||||
GIVEN("A default constructed CmdLineParser") {
|
||||
CmdLineParser p;
|
||||
GIVEN("A default constructed CmdParser") {
|
||||
CmdParser p;
|
||||
THEN("The state of the object is valid") {
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
@ -26,8 +26,8 @@ SCENARIO("Construction", "[support]") {
|
||||
}
|
||||
|
||||
SCENARIO("Parsing a string with the command line parser", "[support]") {
|
||||
GIVEN("A CmdLineParser") {
|
||||
CmdLineParser p;
|
||||
GIVEN("A CmdParser") {
|
||||
CmdParser p;
|
||||
WHEN("Parsing an empty string") {
|
||||
std::string s;
|
||||
p.Parse(s);
|
||||
@ -121,7 +121,7 @@ SCENARIO("Parsing a string with the command line parser", "[support]") {
|
||||
|
||||
SCENARIO("Parsing strings with -h or --help", "[support]") {
|
||||
GIVEN("A parser") {
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
WHEN("Parsing a string with a command and help ") {
|
||||
std::string s = "-h list";
|
||||
|
||||
@ -159,7 +159,7 @@ SCENARIO("Parsing strings with -h or --help", "[support]") {
|
||||
}
|
||||
|
||||
TEST_CASE("Parsing consecutive strings resets not found det id"){
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
p.Parse("1:exptime 0.5");
|
||||
REQUIRE(p.detector_id() == 1);
|
||||
p.Parse("exptime 0.5");
|
||||
@ -170,7 +170,7 @@ TEST_CASE("Parsing consecutive strings resets not found det id"){
|
||||
}
|
||||
|
||||
TEST_CASE("Parsing consecutive strings resets not found multi id"){
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
p.Parse("1-1:exptime 0.5");
|
||||
REQUIRE(p.multi_id() == 1);
|
||||
p.Parse("1:exptime 0.5");
|
||||
@ -183,7 +183,7 @@ TEST_CASE("Parse with no arguments results in no command and default id",
|
||||
// first argument is the command used to call the binary
|
||||
int argc = 1;
|
||||
const char *const argv[]{"call"};
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
@ -197,7 +197,7 @@ TEST_CASE(
|
||||
"[support]") {
|
||||
int argc = 2;
|
||||
const char *const argv[]{"caller", "vrf"};
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
@ -210,7 +210,7 @@ TEST_CASE("Parse a command with value but without client or detector id",
|
||||
"[support]") {
|
||||
int argc = 3;
|
||||
const char *const argv[]{"caller", "vrf", "3000"};
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
@ -224,7 +224,7 @@ TEST_CASE("Decodes position") {
|
||||
int argc = 2;
|
||||
const char *const argv[]{"caller", "7:vrf"};
|
||||
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
REQUIRE(p.detector_id() == 7);
|
||||
@ -236,7 +236,7 @@ TEST_CASE("Decodes position") {
|
||||
TEST_CASE("Decodes double digit position", "[support]") {
|
||||
int argc = 2;
|
||||
const char *const argv[]{"caller", "73:vcmp"};
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
REQUIRE(p.detector_id() == 73);
|
||||
@ -248,7 +248,7 @@ TEST_CASE("Decodes double digit position", "[support]") {
|
||||
TEST_CASE("Decodes position and id", "[support]") {
|
||||
int argc = 2;
|
||||
const char *const argv[]{"caller", "5-8:vrf"};
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
REQUIRE(p.detector_id() == 8);
|
||||
@ -260,7 +260,7 @@ TEST_CASE("Decodes position and id", "[support]") {
|
||||
TEST_CASE("Double digit id", "[support]") {
|
||||
int argc = 2;
|
||||
const char *const argv[]{"caller", "56-8:vrf"};
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
p.Parse(argc, argv);
|
||||
REQUIRE(p.detector_id() == 8);
|
||||
REQUIRE(p.multi_id() == 56);
|
||||
@ -271,19 +271,19 @@ TEST_CASE("Double digit id", "[support]") {
|
||||
TEST_CASE("Calling with wrong id throws invalid_argument", "[support]") {
|
||||
int argc = 2;
|
||||
const char *const argv[]{"caller", "asvldkn:vrf"};
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
CHECK_THROWS(p.Parse(argc, argv));
|
||||
}
|
||||
|
||||
TEST_CASE("Calling with wrong client throws invalid_argument", "[support]") {
|
||||
int argc = 2;
|
||||
const char *const argv[]{"caller", "lki-3:vrf"};
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
CHECK_THROWS(p.Parse(argc, argv));
|
||||
}
|
||||
|
||||
TEST_CASE("Build up argv", "[support]") {
|
||||
CmdLineParser p;
|
||||
CmdParser p;
|
||||
REQUIRE(p.argv().empty());
|
||||
REQUIRE(p.argv().data() == nullptr);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "Detector.h"
|
||||
#include "catch.hpp"
|
||||
#include "sls_detector_defs.h"
|
||||
#include <array>
|
||||
#include <sstream>
|
||||
|
||||
#include "tests/globals.h"
|
||||
@ -12,6 +13,84 @@ using sls::Detector;
|
||||
using test::GET;
|
||||
using test::PUT;
|
||||
|
||||
TEST_CASE("dr", "[.cmd][.eiger]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
// The only detector currently supporting setting dr
|
||||
// is EIGER?
|
||||
auto dr = det.getDynamicRange().squash();
|
||||
std::array<int, 4> vals{4, 8, 16, 32};
|
||||
for (const auto val : vals) {
|
||||
std::ostringstream oss1, oss2;
|
||||
proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n');
|
||||
proxy.Call("dr", {}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n');
|
||||
}
|
||||
det.setDynamicRange(dr);
|
||||
} else {
|
||||
// For the other detectors we should get an error message
|
||||
// except for dr 16
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"32"}, -1, PUT));
|
||||
|
||||
std::ostringstream oss1, oss2;
|
||||
proxy.Call("dr", {"16"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dr 16\n");
|
||||
proxy.Call("dr", {"16"}, -1, PUT, oss2);
|
||||
REQUIRE(oss2.str() == "dr 16\n");
|
||||
}
|
||||
}
|
||||
|
||||
// TEST_CASE("subexptime", "[.cmd][.eiger]") {
|
||||
// if (test::type == slsDetectorDefs::EIGER) {
|
||||
// std::string s;
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("subexptime", GET, nullptr,
|
||||
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s,
|
||||
// PUT));
|
||||
// } else {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("subexptime", GET));
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("subdeadtime", "[.cmd][.eiger]") {
|
||||
// if (test::type == slsDetectorDefs::EIGER) {
|
||||
// std::string s;
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("subdeadtime", GET, nullptr,
|
||||
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s,
|
||||
// PUT));
|
||||
// } else {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("subdeadtime", GET));
|
||||
// }
|
||||
// }
|
||||
|
||||
TEST_CASE("tengiga", "[.cmd][.eiger][.ctb]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER || det_type == defs::CHIPTESTBOARD){
|
||||
auto tengiga = det.getTenGiga();
|
||||
det.setTenGiga(false);
|
||||
|
||||
std::ostringstream oss1, oss2;
|
||||
proxy.Call("tengiga", {"1"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "tengiga 1\n");
|
||||
proxy.Call("tengiga", {}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "tengiga 1\n");
|
||||
|
||||
for (int i = 0; i!=det.size(); ++i){
|
||||
det.setTenGiga(tengiga[i], {i});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("quad", "[.cmd]") {
|
||||
// TODO! set and get once available in virtual detector
|
||||
Detector det;
|
||||
@ -122,7 +201,6 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd]") {
|
||||
// REQUIRE(oss.str() == "trigger successful\n");
|
||||
// }
|
||||
|
||||
|
||||
// auto currentfnum = det.getStartingFrameNumber().tsquash(
|
||||
// "inconsistent frame nr in test");
|
||||
|
||||
@ -134,49 +212,49 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd]") {
|
||||
// REQUIRE(oss.str() == "timing auto\n");
|
||||
// }
|
||||
// }
|
||||
// if(test::type != slsDetectorDefs::EIGER) {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("trigger", PUT));
|
||||
// } else {
|
||||
// // trigger
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing trigger", PUT,
|
||||
// nullptr, oss)); REQUIRE(oss.str() == "timing trigger\n");
|
||||
// }
|
||||
// int startingfnum = 0;
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
|
||||
// nullptr, oss)); std::string s = (oss.str()).erase (0,
|
||||
// strlen("startingfnum ")); startingfnum = std::stoi(s);
|
||||
// }
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT, nullptr,
|
||||
// oss)); REQUIRE(oss.str() == "start successful\n");
|
||||
// }
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("status", GET,
|
||||
// nullptr, oss)); REQUIRE(oss.str() != "status idle\n");
|
||||
// REQUIRE(oss.str()
|
||||
// != "status stopped\n");
|
||||
// }
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("trigger", PUT,
|
||||
// nullptr, oss)); REQUIRE(oss.str() == "trigger successful\n");
|
||||
// }
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("stop", PUT));
|
||||
// int currentfnum = 0;
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
|
||||
// nullptr, oss)); std::string s = (oss.str()).erase (0,
|
||||
// strlen("startingfnum ")); currentfnum = std::stoi(s);
|
||||
// }
|
||||
// REQUIRE((startingfnum + 1) == currentfnum);
|
||||
// if(test::type != slsDetectorDefs::EIGER) {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("trigger", PUT));
|
||||
// } else {
|
||||
// // trigger
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing trigger", PUT,
|
||||
// nullptr, oss)); REQUIRE(oss.str() == "timing trigger\n");
|
||||
// }
|
||||
// int startingfnum = 0;
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
|
||||
// nullptr, oss)); std::string s = (oss.str()).erase (0,
|
||||
// strlen("startingfnum ")); startingfnum = std::stoi(s);
|
||||
// }
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT, nullptr,
|
||||
// oss)); REQUIRE(oss.str() == "start successful\n");
|
||||
// }
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("status", GET,
|
||||
// nullptr, oss)); REQUIRE(oss.str() != "status idle\n");
|
||||
// REQUIRE(oss.str()
|
||||
// != "status stopped\n");
|
||||
// }
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("trigger", PUT,
|
||||
// nullptr, oss)); REQUIRE(oss.str() == "trigger successful\n");
|
||||
// }
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("stop", PUT));
|
||||
// int currentfnum = 0;
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
|
||||
// nullptr, oss)); std::string s = (oss.str()).erase (0,
|
||||
// strlen("startingfnum ")); currentfnum = std::stoi(s);
|
||||
// }
|
||||
// REQUIRE((startingfnum + 1) == currentfnum);
|
||||
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing auto", PUT));
|
||||
// }
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing auto", PUT));
|
||||
// }
|
||||
// }
|
||||
|
@ -156,15 +156,6 @@ TEST_CASE("resetfpga", "[.cmd]") {
|
||||
}
|
||||
}
|
||||
|
||||
// TEST_CASE("resetfpga", "[.cmd][.ctb][.jungfrau]") {
|
||||
// if (test::type == slsDetectorDefs::JUNGFRAU || test::type ==
|
||||
// slsDetectorDefs::CHIPTESTBOARD) {
|
||||
// ;//REQUIRE_NOTHROW(multiSlsDetectorClient("resetfpga", PUT));
|
||||
// } else {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("resetfpga", GET));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue)
|
||||
|
@ -61,14 +61,15 @@ TEST_CASE("rx_framescaught", "[.cmd]") {
|
||||
REQUIRE(oss.str() == "rx_framescaught 0\n");
|
||||
}
|
||||
|
||||
// Currently disabled may activate if we have a stable env
|
||||
// Now take one frame and see that we caught it
|
||||
det.setNumberOfFrames(1);
|
||||
det.acquire();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_framescaught 1\n");
|
||||
}
|
||||
// det.setNumberOfFrames(1);
|
||||
// det.acquire();
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
||||
// REQUIRE(oss.str() == "rx_framescaught 1\n");
|
||||
// }
|
||||
}
|
||||
|
||||
TEST_CASE("rx_status", "[.cmd]") {
|
||||
|
@ -14,6 +14,12 @@ using sls::Detector;
|
||||
using test::GET;
|
||||
using test::PUT;
|
||||
|
||||
TEST_CASE("Unknown command", "[.cmd]"){
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
REQUIRE_THROWS(proxy.Call("vsaevrreavv", {}, -1, PUT));
|
||||
}
|
||||
|
||||
// TEST_CASE("vchip", "[.cmd]") {
|
||||
// int prev_val = 0;
|
||||
|
||||
@ -1386,10 +1392,6 @@ TEST_CASE("user", "[.cmd]") {
|
||||
REQUIRE_THROWS(proxy.Call("user", {}, -1, PUT));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TEST_CASE("execcommand", "[.cmd]") {
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("execcommand ls", PUT));
|
||||
// }
|
||||
@ -1428,28 +1430,6 @@ TEST_CASE("stopport", "[.cmd]") {
|
||||
REQUIRE(port == 1953);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TEST_CASE("bustest", "[.cmd]") {
|
||||
// if (test::type == slsDetectorDefs::JUNGFRAU || test::type ==
|
||||
// slsDetectorDefs::CHIPTESTBOARD || test::type ==
|
||||
// slsDetectorDefs::GOTTHARD) {
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("bustest", PUT));
|
||||
// } else {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("bustest", PUT));
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("firmwaretest", "[.cmd]") {
|
||||
// if (test::type == slsDetectorDefs::JUNGFRAU || test::type ==
|
||||
// slsDetectorDefs::CHIPTESTBOARD || test::type ==
|
||||
// slsDetectorDefs::GOTTHARD) {
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("firmwaretest", PUT));
|
||||
// } else {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("firmwaretest", PUT));
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("reg", "[.cmd]") {
|
||||
// if (test::type == slsDetectorDefs::JUNGFRAU) {
|
||||
// {
|
||||
@ -1606,15 +1586,6 @@ TEST_CASE("stopport", "[.cmd]") {
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("resetfpga", "[.cmd][.ctb][.jungfrau]") {
|
||||
// if (test::type == slsDetectorDefs::JUNGFRAU || test::type ==
|
||||
// slsDetectorDefs::CHIPTESTBOARD) {
|
||||
// ;//REQUIRE_NOTHROW(multiSlsDetectorClient("resetfpga", PUT));
|
||||
// } else {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("resetfpga", GET));
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("programfpga", "[.cmd][.ctb][.jungfrau]") {
|
||||
// if (test::type == slsDetectorDefs::JUNGFRAU || test::type ==
|
||||
// slsDetectorDefs::CHIPTESTBOARD) {
|
||||
@ -2741,8 +2712,6 @@ TEST_CASE("stopport", "[.cmd]") {
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// TEST_CASE("temp_", "[.cmd][.jungfrau]") {
|
||||
// if (test::type == slsDetectorDefs::JUNGFRAU) {
|
||||
// std::string s;
|
||||
@ -3137,66 +3106,27 @@ TEST_CASE("stopport", "[.cmd]") {
|
||||
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT));
|
||||
// }
|
||||
|
||||
// TEST_CASE("subdeadtime", "[.cmd][.eiger]") {
|
||||
// if (test::type == slsDetectorDefs::EIGER) {
|
||||
// std::string s;
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("subdeadtime", GET, nullptr,
|
||||
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s,
|
||||
// PUT));
|
||||
// } else {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("subdeadtime", GET));
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("subexptime", "[.cmd][.eiger]") {
|
||||
// if (test::type == slsDetectorDefs::EIGER) {
|
||||
// std::string s;
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("subexptime", GET, nullptr,
|
||||
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s,
|
||||
// PUT));
|
||||
// } else {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("subexptime", GET));
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("dr", "[.cmd][.eiger]") {
|
||||
// if (test::type == slsDetectorDefs::EIGER) {
|
||||
// int vals[4] = {4, 8, 16, 32};
|
||||
// for (int i = 0; i < 4; ++i) {
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("dr " +
|
||||
// std::to_string(vals[i]), PUT)); std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("dr", GET, nullptr, oss));
|
||||
// REQUIRE(oss.str() == "dr " + std::to_string(vals[i]) + '\n');
|
||||
// }
|
||||
// } else {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("dr 4", PUT));
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("dr 8", PUT));
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("dr 32", PUT));
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("dr 16", PUT));
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("dr", GET, nullptr, oss));
|
||||
// REQUIRE(oss.str() == "dr " + std::to_string(16) + '\n');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("zmqip", "[.cmd]") {
|
||||
// std::string s;
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:zmqip", GET, nullptr,
|
||||
// oss)); s = oss.str();
|
||||
// }
|
||||
// {
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT));
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:zmqip", GET, nullptr,
|
||||
// oss)); REQUIRE(oss.str() == s);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
TEST_CASE("zmqip", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
std::ostringstream oss1, oss2;
|
||||
auto zmqip = det.getClientZmqIp();
|
||||
proxy.Call("zmqip", {}, 0, GET, oss1);
|
||||
REQUIRE(oss1.str() == "zmqip " + zmqip[0].str() + '\n');
|
||||
|
||||
proxy.Call("zmqip", {zmqip[0].str()}, 0, PUT, oss2);
|
||||
REQUIRE(oss2.str() == "zmqip " + zmqip[0].str() + '\n');
|
||||
|
||||
for (int i = 0; i!=det.size(); ++i){
|
||||
det.setRxZmqIP(zmqip[i], {i});
|
||||
}
|
||||
}
|
||||
|
||||
// TEST_CASE("zmqport", "[.cmd]") {
|
||||
// multiSlsDetector d;
|
||||
@ -3228,29 +3158,41 @@ TEST_CASE("stopport", "[.cmd]") {
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("fpath", "[.cmd]") {
|
||||
// std::string s;
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:fpath", GET, nullptr,
|
||||
// oss)); s = oss.str();
|
||||
// }
|
||||
// {
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT));
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("fpath", GET, nullptr, oss));
|
||||
// REQUIRE(oss.str() == s);
|
||||
// }
|
||||
// }
|
||||
TEST_CASE("fpath", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto fpath = det.getFilePath().squash();
|
||||
|
||||
std::ostringstream oss1, oss2, oss3;
|
||||
proxy.Call("fpath", {}, -1, GET, oss1);
|
||||
REQUIRE(oss1.str() == "fpath " + fpath + "\n");
|
||||
proxy.Call("fpath", {fpath}, -1, PUT, oss2);
|
||||
REQUIRE(oss2.str() == "fpath " + fpath + "\n");
|
||||
proxy.Call("fpath", {}, -1, GET, oss3);
|
||||
REQUIRE(oss3.str() == "fpath " + fpath + "\n");
|
||||
}
|
||||
|
||||
TEST_CASE("fformat", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto fformat = det.getFileFormat();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("fformat", {"binary"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "fformat binary\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("fformat", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "fformat binary\n");
|
||||
}
|
||||
|
||||
// Reset file format after test
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setFileFormat(fformat[i], {i});
|
||||
}
|
||||
}
|
||||
|
||||
// TEST_CASE("fformat", "[.cmd]") {
|
||||
// {
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("fformat", GET, nullptr,
|
||||
// oss));
|
||||
// REQUIRE(oss.str() == "fformat binary\n");
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("txndelay", "[.cmd][.eiger][.jungfrau]") {
|
||||
// if (test::type == slsDetectorDefs::EIGER) {
|
||||
@ -3333,25 +3275,7 @@ TEST_CASE("stopport", "[.cmd]") {
|
||||
// }
|
||||
// }
|
||||
|
||||
// TEST_CASE("tengiga", "[.cmd][.eiger][.ctb]") {
|
||||
// if (test::type == slsDetectorDefs::EIGER || test::type ==
|
||||
// slsDetectorDefs::CHIPTESTBOARD) {
|
||||
// {
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("tengiga 1", PUT));
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:tengiga", GET, nullptr,
|
||||
// oss)); REQUIRE(oss.str() == "tengiga 1\n");
|
||||
// }
|
||||
// {
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("tengiga 0", PUT));
|
||||
// std::ostringstream oss;
|
||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:tengiga", GET, nullptr,
|
||||
// oss)); REQUIRE(oss.str() == "tengiga 0\n");
|
||||
// }
|
||||
// } else {
|
||||
// REQUIRE_THROWS(multiSlsDetectorClient("tengiga", GET));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// TEST_CASE("network", "[.cmd]") {
|
||||
// /* {TODO custom srcip in globals
|
||||
|
Loading…
x
Reference in New Issue
Block a user