mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-29 23:51:18 +01:00
* alignedData now uses std::align_alloc * imagedata is now allocated on the heap * m3 server fix for trimbits and badchannels that are shifted by 1 * formatting * binary in * added check for proper memory allocation * commenting out the example in receiver data call back changing size as it affects users using debugging mode to print out headers * fixed warnings * commenting out the example in receiver data call back changing size as it affects users using debugging mode to print out headers * got rid of cast to uint64 * got rid of Reorder function * added sanity check to only enable for chipttestboard and xilinx * removed Gotthard stuff * update the comment about how to modify data on a data call back from the receiver * autogenerated commands and make format * changed font size in GUI * clang-format with clang-format version 17 * updated update_image_size in xilinx * version number automated for python build * mistakenly set version back to 0.0.0 * updated github workflow scripts to support automatic version numbering with environment variable * managed to load VERSION file in yaml file - simplifies things * saving changes in git workflow failed * got typo in github workflow * updatet regex pattern to support postfix * normalized version to PEP 440 specification in update_version.py * bug did not support version 0.0.0 * upgrading to c++17 from c++11 and patch command has to be found before applying patch on libzmq (#1195) * Dev/allow localhost for virtual tests (#1190) * remove the check for localhost being used in rx_hostname for python test for simulators, run rx_arping test only if hostname is not 'localhost' * fix tests for fpath: cannot set back to empty anymore (empty is default) * default rx_hostname arg = localhost, and default settings path =../../settingsdir * changed virtual tests script for better printout on exceptions * fix for catching generaltests exceptions and exiting instead of continuing * fix minor * fixed shared memeory tests to include current env and fixed prints for errors --------- Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com> * added regex pattern matching to version in toml file * Dev/gitea docker (#1194) * gitea workflows for RH8 and RH9 * using our docker images * version now supports . before postfix * rough draft of test acquire of all detectors for frames caught and file size. ctb not included yet * moved dbitoffset, dbitreorder and dbitlist to GeneralData * added error message on receiver side, throw error * removed log as error already printed * added tests to check file size and frames caught with an acquire (virtual) for every detector * minor printout removed * typo fixed * removed minor printout * incorrect counter mask tested * fix 10g adc enable mask, switched with 1g * fixed hardcoded values of nchip nchan etc from detPArameters * fixed ctb tests, need to fix in develoepr (if digital modfe not enabled, should not take into accoutn dbitlist or dbitoffset or dbitreorder * only reorder bits if some sort of digital readout mode enabled * trying to fix acquire for xilinx * fix for xilinx ctb virtual * alloweing all tests * typo * fix for slsreceiver killed but complaining for virtual tests with script * fixed bug found by @AliceMazzoleni99 that for ctb server is still shown in pgrep -f if xilinx server running, so now the pid is killed and looking for any DetectorServer_virtual instead. also reset color coding after Log * check if process running for kill -9 slsReceiver fail * removed -9 to kill with cleanup * frame synchonrizer fixes: typo of iterator for loop and zmg_msg_t list cleaned up before sending multi part zmq; test written for the frame synchronizer, test_simulator.py rewritten for more robustness and refactoring commonality between both scripts * better error messageS * minor * typo * moving the erasure of the fnum to after sending the zmg packets and also deleteing all old frames when end of acquisition * fix bug in blackfin read access to firmware registers * updates api version based on version file & converted shell script files to python * updated all makefiles * refactoring code and compiling binary * formatting * rewrote end() for StaticVector * rearranged receiver topics, differentiated btween receiver variants and added info about slsFrameSynchronizer * typo * minor aesthetics * minor * added extra fs link and fixed execute_program warning * and now with link * updating pmods * adresses review comments * dummy commit for versionAPI * formatted and updated versionAPI.h * added expat to host section * updated documentation for pip installation as well * Dev/add numpy (#1227) * added numpy dependency * added build specifications for python version and platform * updates files/variants for pmods for 9.2.0 (#1233) * tests for bool in ToString/StringTo (#1230) - Added tests for ToString/StringTo<bool> - Added overload for ToString of bool (previously went through int) * added docs for SLSDETNAME (#1228) * added docs for SLSDETNAME * clarification on hostname * added examples on module index * fixes * fixed typo * Dev/update test framesynchronizer (#1221) * raise an exception if the pull socket python script had errors at startup (for eg if pyzmq was not installed) * minor changes that got lost in the merge of automate_version_part 2 PR --------- Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com> * added workflow for python wheels * wip * formatting * wip * wip to parse vector of rois at command line * wip * first level test * can get individual rois, but not connected to command yet * rois shoudl work. left to implement tests for individual rois, create multiple datasets (1 for each roi) in the virutal data file. currently virutal dataset with roi is not implemented and a warning is given instead. wonder why since the inviduviaual roi files are clipped * all tests pased * minor * fixed rx_roi for multi modules jungfrau , tests for eiger, multi modules jungfrau in x and 2 interfaces * works for eiger as well * switched to vector instead of std::array<ROI, 2>>, which prints extra [-1, -1] when theres only 1 udp interface * wip * fix for empty roi vectors (which shouldnt be) as you cant know if its all or not in roi * wip: to map roi to virutal * fix for eiger, added python test for testig roi in different module and detector type configurations * wip, fails with master and virtual * works for complete roi * wip, works for a single roi * works for all rois * wip to fix tests * 1d fixes * rois test work on 1d as well * check master file creation as well in rx_roi tests * get rx_roi from metadata from rxr, cant reconstruct. fixed clear roi should give 1 roi min * gui shows roi now * format * updated python bindings * updated master file versions * cmd generation and formatting * minor fixes in command line and help * minor * doesnt happen anymore * comment * minor * redundant getRxROI in Detector class for multi level and module level * refactor cmd parsing (detid can be parsed directly) * refactor cmd line * refactor command line parsing of roi * modified comments about ctb and xilinx not using roi * refactoring * refactorign * refactoring wip * wip refactoring * formattin * to avoid confusion, moved default initialized, single sized declared vector of roi to be created at setDetectorType * pybind only 1 function for getRxROI * command line help * specified number of receiver error message * minor comment * refactored to take out repetitive code, need to adjust for slsMulti and slsFrameSync * wip * works, need to add tests * made Commadnlineoptions into a class * wip test * fixed tests * cleaning up properly , semaphore leaks, child process/thread throwing handled * getuid issue on github workflow * constexpr and checking if options object type is same * unnecessary capture * remove testing code, minor * fixed help, -t for multi should not be supported as it never had it * Formatting * hdf5 definitions in test when not compiled with hdf5 * typo * moved optstring and long options to the constructor * raising a SIGINT when the child thread has an exception so that the parent thread can exit all the threads and clean up gracefully * minor test typo * check status of child exiting and use that to send sigint to all the child processes from the parent * fixed validation in network_utils, added a tests to throw for port 65535 in test mode (option on for sls_use_tests), multi:parent process checks child process exit status to send sigint to others * moving set signal handler to network utils * readoutspeed in rx master file and other master file inconsistencies (#1245) readout speed added to json and h5 master files. Also fixed master file inconsistencies Sserver binaries - update server binaries because readoutspeed needs to be sent to receiver with rx_hostname command API - added const to Detector class set/getburstmode Python - updated python bindings (burstmode const and roi arguments) Cmd generation - added pragma once in Caller.in.h as Caller is included in test files m3: num channels due to #counters < 3 * workaround for m3 for messed up num channels (client always assumes all counters enabled and adds them to num channels), fix for hdf5 g2: exptime master file inconsistency - exptime didnt match because of round of when setting burst mode (sets to a different clk divider) - so updating actual time for all timers (exptime, period, subexptime etc, ) in Module class, get timer values from detector when setting it and then send to receiver to write in master file ctb image size incorrect: - write actual size into master file and not the reserved size (digital reduces depending on dbit list and dbit offset) - added a calculate ctb image size free function in generalData.h that is used there as well as for the tests. master file inconsistencies - refactored master attributes writing using templates - names changed to keep it consistent between json and hdf5 master file (Version, Pixels, Exposure Times, GateDelays, Acquisition Period, etc.) - datatypes changed to keep it simple where possible: imageSize, dynamicRange, tengiga, quad, readnrows, analog, analogsamples, digital, digitalsamples, dbitreorder, dbitoffset, transceivermask, transeiver, transceiversamples, countermask, gates =>int - replacing "toString" with arrays, objects etc for eg for scan, rois, etc. - json header always written (empty dataset or empty brackets) - hdf5 needs const char* so have to convert strings to it, but taking care that strings exist prior to push_back - master attributes (redundant string literals->error prone tests for master file - suppressed deprecated functions in rapidjson warnings just for the tests - added slsREceiverSoftware/src to allow access to receiver_defs.h to test binary/hdf5 version - refactored acquire tests by moving all the acquire tests from individual detector type files to a single one=test-Caller-acquire.cpp - set some default settings (loadBasicSettings) for a basic acquire at load config part for the test_simulator python scripts. so minimum number of settings for detector to be set for any acquire tests. - added tests to test master files for json and hdf5= test-Caller-master-attributes.cpp - added option to add '-m' markers for tests using test_simulator python script * doc: added inst on how to set persistentn NIC changes after reboot for each ethernet interface such as rx 4096, rx-usecs, adaptive-rx and gro etc. * added permanent ethtool settings also for fedora or modern rhel * troubleshooting doc: permanent changes for 10g pc tuning (#1247) * doc: added inst on how to set persistentn NIC changes after reboot for each ethernet interface such as rx 4096, rx-usecs, adaptive-rx and gro etc. * added permanent ethtool settings also for fedora or modern rhel * ifcfg scripts still work on rhel8, just not preferred * added dataformat for jungfrau * eiger basic mod * eiger doc done * added moench * done * free shm exposed in python as free function and detector function * minimum change * added quad and updated about 1gbe/10gbe * more info * remove arguments info * replacing commands with links * minor * detail explanation of eiger * fixed imagesize ctb issue (out values not transferred, setting any dbit values was not recalculatign image size in generaldata) * fixed ctb dbit clock changing period in tests as it was setting run clock instead * python accessing freed shared memory object (#1253) * added a 'isValid' member in shared memory (also updated shm version) with default true, any access to shared memory() checks also for validity. any free will set this to false and then unmap shm. Any access to shm will then check validity in python. * fixed tests for shm * added tests in python as well --------- Co-authored-by: Alice <alice.mazzoleni@psi.ch> * updated error message * made markers argument in ParseArguments a boolean instead of an int * removed relative path compared to where executable run in test script for settingsdir * fix roi test * updating versions (#1258) * updating package version, client version, server versions. Renaming server versions, using hardlinks in serverBin. Removing ctb servers in serverBin. (#1259) * fixed no interpolation mode for moench (#1262) Co-authored-by: Anna Bergamaschi <anna.bergamaschi@psi.ch> * fixed multi receiver and frames sync help throw of bad variant access (#1265) * 1000/doc c standard (#1267) * updated c++11 to c++17 * more about c++11 and updating readme * updated documentation for receiver arguments and also making receiver constructor explicit * minor fix for rxr err message * fixed doc about gcc version * 1000/release notes (#1269) * updated firmware and server version in release notes * release notes wip * updated notes(prs done) * updated release notes. wip * Release notes * minor * minor fix * 1000/doc architecture commands (#1271) * sw architecture and setup commands * 1000/shm free obsolete (#1273) * freeing obsolete shm withoua a 'isValid' should access raw pointers. Need to move this all into the shm class * fixed obsolete shm free issue * minor * ensuring the test works platform independent for size of int * removed verify, update, fixed getUser to be a free function, generated commands, python bindings yet to do * python bindings * fixed tests * minor * minor * format * userdetails refinedg * fixed caller test * updated client api version (#1277) * one doesnt need to open shared memory to call removesharedmemory, and calling hasMemoryvalid without opening will cause segfault (not used now, but could in the future) * fix test on shm * minor * added image source files from draw.io to create the images (#1280) * 1000/fix_actual_tests (#1282) - fix acquire fail in tests (adcreg test) - roi tests fail after overlapping invalid test and acquire after - print udp dest mac in server properly - fixed udp dst list get (server was not sending entry proper size to match proper struct size in client) - updated server binaries and updated hard links in serverBin - added documentation regarding gui: zmqport and zmqip in terms of gui, rx_zmqstream - removed print - probably ended there for debuggung --------- Co-authored-by: Alice <alice.mazzoleni@psi.ch> * 1000/fix_m3_tests (#1286) * testing clkdiv one must ensure the exptime delay etc all are reset to the exact values for tests * change dac max values for vth values for m3 in client side (set module * 1000/doc_cmake (#1289) * more detail documentation in installation * more detail documentation in installation * added links to api examples * reverted back that vthreshold dacs in m3 have min and max as 200 and 2400 (#1294) * update release notes and date (#1298) --------- Co-authored-by: Mazzoleni Alice Francesca <mazzol_a@pc17378.psi.ch> Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com> Co-authored-by: AliceMazzoleni99 <alice.mazzoleni@psi.ch> Co-authored-by: Martin Mueller <martin.mueller@psi.ch> Co-authored-by: froejdh_e <erik.frojdh@psi.ch> Co-authored-by: Anna Bergamaschi <anna.bergamaschi@psi.ch>
3652 lines
132 KiB
C++
3652 lines
132 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
#include "Caller.h"
|
|
#include "catch.hpp"
|
|
#include "sls/Detector.h"
|
|
#include "sls/file_utils.h"
|
|
#include "sls/sls_detector_defs.h"
|
|
#include "test-Caller-global.h"
|
|
|
|
#include <chrono>
|
|
#include <sstream>
|
|
#include <thread>
|
|
#include <variant>
|
|
|
|
#include "tests/globals.h"
|
|
#include <filesystem>
|
|
|
|
namespace sls {
|
|
|
|
using test::GET;
|
|
using test::PUT;
|
|
|
|
TEST_CASE("Calling help doesn't throw or cause segfault") {
|
|
// Dont add [.cmdcall] tag this should run with normal tests
|
|
Caller caller(nullptr);
|
|
std::ostringstream os;
|
|
for (std::string cmd : caller.getAllCommands())
|
|
REQUIRE_NOTHROW(
|
|
caller.call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os));
|
|
}
|
|
|
|
TEST_CASE("Unknown command", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_THROWS(caller.call("vsaevrreavv", {}, -1, PUT));
|
|
}
|
|
|
|
/* configuration */
|
|
|
|
TEST_CASE("config", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
// put only
|
|
REQUIRE_THROWS(caller.call("config", {}, -1, GET));
|
|
}
|
|
|
|
// free: not testing
|
|
|
|
TEST_CASE("parameters", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
// put only
|
|
REQUIRE_THROWS(caller.call("parameters", {}, -1, GET));
|
|
/*
|
|
auto prev_val = det.getNumberOfFrames().tsquash("Number of frames has to
|
|
be same to test");
|
|
{
|
|
system("echo 'frames 2' > /tmp/tempsetup.det ");
|
|
std::ostringstream oss;
|
|
caller.call("parameters", {"/tmp/tempsetup.det"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "parameters /tmp/tempsetup.det\n");
|
|
REQUIRE(det.getNumberOfFrames().tsquash("failed") == 2);
|
|
}
|
|
{
|
|
system("echo '0:frames 1' > /tmp/tempsetup.det ");
|
|
std::ostringstream oss;
|
|
caller.call("parameters", {"/tmp/tempsetup.det"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "parameters /tmp/tempsetup.det\n");
|
|
REQUIRE(det.getNumberOfFrames({0}).tsquash("failed") == 1);
|
|
}
|
|
det.setNumberOfFrames(prev_val);
|
|
*/
|
|
}
|
|
|
|
TEST_CASE("hostname", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("hostname", {}, -1, GET));
|
|
}
|
|
|
|
TEST_CASE("virtual", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_THROWS(caller.call("virtual", {}, -1, GET));
|
|
test_valid_port_caller("virtual", {"1"}, -1, PUT);
|
|
REQUIRE_THROWS(caller.call("virtual", {"3", "65534"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("versions", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("versions", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("versions", {"0"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("packageversion", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("packageversion", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("packageversion", {"0"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("clientversion", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("clientversion", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("clientversion", {"0"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("firmwareversion", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("firmwareversion", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("firmwareversion", {"0"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("detectorserverversion", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("detectorserverversion", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("detectorserverversion", {"0"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("hardwareversion", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("hardwareversion", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("hardwareversion", {"0"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("kernelversion", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("kernelversion", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("kernelversion", {"0"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("serialnumber", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER || det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
REQUIRE_THROWS(caller.call("serialnumber", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_NOTHROW(caller.call("serialnumber", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("moduleid", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::GOTTHARD2 || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH) {
|
|
REQUIRE_NOTHROW(caller.call("moduleid", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("moduleid", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("type", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto dt = det.getDetectorType().squash();
|
|
|
|
std::ostringstream oss;
|
|
caller.call("type", {}, -1, GET, oss);
|
|
auto ans = oss.str().erase(0, strlen("type "));
|
|
REQUIRE(ans == ToString(dt) + '\n');
|
|
// REQUIRE(dt == test::type);
|
|
}
|
|
|
|
TEST_CASE("detsize", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("detsize", {}, -1, GET));
|
|
}
|
|
|
|
TEST_CASE("settingslist", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::CHIPTESTBOARD ||
|
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
REQUIRE_THROWS(caller.call("settingslist", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_NOTHROW(caller.call("settingslist", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("settingslist", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("settings", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
std::vector<std::string> allSett;
|
|
allSett.push_back("standard");
|
|
allSett.push_back("fast");
|
|
allSett.push_back("highgain");
|
|
allSett.push_back("dynamicgain");
|
|
allSett.push_back("lowgain");
|
|
allSett.push_back("mediumgain");
|
|
allSett.push_back("veryhighgain");
|
|
allSett.push_back("highgain0");
|
|
allSett.push_back("fixgain1");
|
|
allSett.push_back("fixgain2");
|
|
allSett.push_back("verylowgain");
|
|
allSett.push_back("g1_hg");
|
|
allSett.push_back("g1_lg");
|
|
allSett.push_back("g2_hc_hg");
|
|
allSett.push_back("g2_hc_lg");
|
|
allSett.push_back("g2_lc_hg");
|
|
allSett.push_back("g2_lc_lg");
|
|
allSett.push_back("g4_hg");
|
|
allSett.push_back("g4_lg");
|
|
allSett.push_back("forceswitchg1");
|
|
allSett.push_back("forceswitchg2");
|
|
allSett.push_back("gain0");
|
|
|
|
std::vector<std::string> sett;
|
|
switch (det_type) {
|
|
case defs::JUNGFRAU:
|
|
sett.push_back("gain0");
|
|
sett.push_back("highgain0");
|
|
break;
|
|
case defs::MOENCH:
|
|
sett.push_back("g1_hg");
|
|
sett.push_back("g1_lg");
|
|
sett.push_back("g2_hc_hg");
|
|
sett.push_back("g2_hc_lg");
|
|
sett.push_back("g2_lc_hg");
|
|
sett.push_back("g2_lc_lg");
|
|
sett.push_back("g4_hg");
|
|
sett.push_back("g4_lg");
|
|
break;
|
|
case defs::GOTTHARD2:
|
|
sett.push_back("dynamicgain");
|
|
sett.push_back("fixgain1");
|
|
sett.push_back("fixgain2");
|
|
break;
|
|
case defs::MYTHEN3:
|
|
sett.push_back("standard");
|
|
sett.push_back("fast");
|
|
sett.push_back("highgain");
|
|
break;
|
|
default:
|
|
if (det_type == defs::EIGER) {
|
|
// FIXME: need to remove when settings removed
|
|
REQUIRE_NOTHROW(caller.call("settings", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("settings", {"standard"}, -1, PUT));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("settings", {}, -1, GET));
|
|
}
|
|
return;
|
|
}
|
|
|
|
auto prev_val = det.getSettings();
|
|
for (auto &it : sett) {
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("settings", {it}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "settings " + it + "\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("settings", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "settings " + it + "\n");
|
|
}
|
|
}
|
|
for (auto &it : allSett) {
|
|
if (std::find(sett.begin(), sett.end(), it) == sett.end()) {
|
|
REQUIRE_THROWS(caller.call("settings", {it}, -1, PUT));
|
|
}
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (prev_val[i] != defs::UNDEFINED &&
|
|
prev_val[i] != defs::UNINITIALIZED) {
|
|
det.setSettings(prev_val[i], {i});
|
|
}
|
|
}
|
|
}
|
|
|
|
TEST_CASE("threshold", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER) {
|
|
auto prev_threshold = det.getThresholdEnergy();
|
|
auto prev_energies =
|
|
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
|
if (!prev_energies.empty()) {
|
|
std::string senergy = std::to_string(prev_energies[0]);
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("threshold", {senergy, "standard"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "threshold [" + senergy + ", standard]\n");
|
|
caller.call("threshold", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "threshold " + senergy + "\n");
|
|
|
|
REQUIRE_THROWS(caller.call(
|
|
"threshold", {senergy, senergy, senergy, "standard"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("threshold", {senergy, "undefined"}, -1, PUT));
|
|
|
|
det.setTrimEnergies(prev_energies);
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (prev_threshold[i] >= 0) {
|
|
det.setThresholdEnergy(prev_threshold[i], defs::STANDARD,
|
|
true, {i});
|
|
}
|
|
}
|
|
}
|
|
REQUIRE_NOTHROW(caller.call("threshold", {}, -1, GET));
|
|
} else if (det_type == defs::MYTHEN3) {
|
|
auto prev_threshold = det.getAllThresholdEnergy();
|
|
auto prev_settings =
|
|
det.getSettings().tsquash("inconsistent settings to test");
|
|
auto prev_energies =
|
|
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
|
if (!prev_energies.empty()) {
|
|
std::string senergy = std::to_string(prev_energies[0]);
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("threshold", {senergy, "standard"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "threshold [" + senergy + ", standard]\n");
|
|
caller.call("threshold", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "threshold [" + senergy + ", " + senergy +
|
|
", " + senergy + "]\n");
|
|
std::string senergy2 = std::to_string(prev_energies[1]);
|
|
std::string senergy3 = std::to_string(prev_energies[2]);
|
|
std::ostringstream oss3, oss4;
|
|
caller.call("threshold", {senergy, senergy2, senergy3, "standard"},
|
|
-1, PUT, oss3);
|
|
REQUIRE(oss3.str() == "threshold [" + senergy + ", " + senergy2 +
|
|
", " + senergy3 + ", standard]\n");
|
|
caller.call("threshold", {}, -1, GET, oss4);
|
|
REQUIRE(oss4.str() == "threshold [" + senergy + ", " + senergy2 +
|
|
", " + senergy3 + "]\n");
|
|
|
|
REQUIRE_THROWS(caller.call(
|
|
"threshold", {senergy, senergy, "standard"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("threshold", {senergy, "undefined"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("threshold", {senergy}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call(
|
|
"threshold", {senergy, senergy2, senergy3}, -1, PUT));
|
|
det.setTrimEnergies(prev_energies);
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (prev_threshold[i][0] >= 0) {
|
|
std::cout << "prev cvalues:" << ToString(prev_threshold[i])
|
|
<< std::endl;
|
|
det.setThresholdEnergy(prev_threshold[i], prev_settings,
|
|
true, {i});
|
|
}
|
|
}
|
|
}
|
|
REQUIRE_NOTHROW(caller.call("threshold", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("threshold", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("thresholdnotb", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER) {
|
|
auto prev_threshold = det.getThresholdEnergy();
|
|
auto prev_energies =
|
|
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
|
if (!prev_energies.empty()) {
|
|
std::string senergy = std::to_string(prev_energies[0]);
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("thresholdnotb", {senergy, "standard"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() ==
|
|
"thresholdnotb [" + senergy + ", standard]\n");
|
|
caller.call("threshold", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "threshold " + senergy + "\n");
|
|
REQUIRE_THROWS(caller.call("thresholdnotb",
|
|
{senergy, senergy, senergy, "standard"},
|
|
-1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("thresholdnotb", {senergy, "undefined"}, -1, PUT));
|
|
det.setTrimEnergies(prev_energies);
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (prev_threshold[i] >= 0) {
|
|
det.setThresholdEnergy(prev_threshold[i], defs::STANDARD,
|
|
false, {i});
|
|
}
|
|
}
|
|
}
|
|
REQUIRE_NOTHROW(caller.call("threshold", {}, -1, GET));
|
|
} else if (det_type == defs::MYTHEN3) {
|
|
auto prev_threshold = det.getAllThresholdEnergy();
|
|
auto prev_settings =
|
|
det.getSettings().tsquash("inconsistent settings to test");
|
|
auto prev_energies =
|
|
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
|
if (!prev_energies.empty()) {
|
|
std::string senergy = std::to_string(prev_energies[0]);
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("thresholdnotb", {senergy, "standard"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() ==
|
|
"thresholdnotb [" + senergy + ", standard]\n");
|
|
caller.call("threshold", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "threshold [" + senergy + ", " + senergy +
|
|
", " + senergy + "]\n");
|
|
std::string senergy2 = std::to_string(prev_energies[1]);
|
|
std::string senergy3 = std::to_string(prev_energies[2]);
|
|
std::ostringstream oss3, oss4;
|
|
caller.call("thresholdnotb",
|
|
{senergy, senergy2, senergy3, "standard"}, -1, PUT,
|
|
oss3);
|
|
REQUIRE(oss3.str() == "thresholdnotb [" + senergy + ", " +
|
|
senergy2 + ", " + senergy3 +
|
|
", standard]\n");
|
|
caller.call("threshold", {}, -1, GET, oss4);
|
|
REQUIRE(oss4.str() == "threshold [" + senergy + ", " + senergy2 +
|
|
", " + senergy3 + "]\n");
|
|
|
|
REQUIRE_THROWS(caller.call(
|
|
"thresholdnotb", {senergy, senergy, "standard"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("thresholdnotb", {senergy, "undefined"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("thresholdnotb", {senergy}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call(
|
|
"thresholdnotb", {senergy, senergy2, senergy3}, -1, PUT));
|
|
det.setTrimEnergies(prev_energies);
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (prev_threshold[i][0] >= 0) {
|
|
det.setThresholdEnergy(prev_threshold[i], prev_settings,
|
|
true, {i});
|
|
}
|
|
}
|
|
}
|
|
REQUIRE_NOTHROW(caller.call("threshold", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("thresholdnotb", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("settingspath", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getSettingsPath();
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("settingspath", {"/tmp"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "settingspath /tmp\n");
|
|
caller.call("settingspath", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "settingspath /tmp\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setSettingsPath(prev_val[i], {i});
|
|
}
|
|
}
|
|
|
|
TEST_CASE("trimbits", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_THROWS(caller.call("trimbits", {}, -1, GET));
|
|
}
|
|
|
|
TEST_CASE("trimval", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::MYTHEN3 || det_type == defs::EIGER) {
|
|
auto prev_val = det.getAllTrimbits();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("trimval", {"63"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "trimval 63\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("trimval", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "trimval 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("trimval", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "trimval 0\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("trimval", {"64"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("trimval", {"-2"}, -1, PUT));
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (prev_val[i] != -1) {
|
|
det.setAllTrimbits(prev_val[i], {i});
|
|
}
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("trimval", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("trimen", "[.cmdcall][.this]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER || det_type == defs::MYTHEN3) {
|
|
auto previous = det.getTrimEnergies();
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("trimen", {"4500", "5400", "6400"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "trimen [4500, 5400, 6400]\n");
|
|
caller.call("trimen", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "trimen [4500, 5400, 6400]\n");
|
|
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setTrimEnergies(previous[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(
|
|
caller.call("trimen", {"4500", "5400", "6400"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("trimen", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("gappixels", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
// test eiger(quad or full module only)
|
|
bool gapPixelTest = false;
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH)
|
|
gapPixelTest = true;
|
|
else if (det_type == defs::EIGER) {
|
|
bool quad = det.getQuad().squash(false);
|
|
bool fullModule = (det.getModuleGeometry().y % 2 == 0);
|
|
if (quad || fullModule) {
|
|
gapPixelTest = true;
|
|
}
|
|
}
|
|
|
|
if (gapPixelTest) {
|
|
auto prev_val = det.getGapPixelsinCallback();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("gappixels", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "gappixels 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("gappixels", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "gappixels 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("gappixels", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "gappixels 0\n");
|
|
}
|
|
det.setGapPixelsinCallback(prev_val);
|
|
} else {
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("gappixels", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "gappixels 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("gappixels", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "gappixels 0\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("gappixels", {"1"}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("fliprows", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
bool hw2 = false;
|
|
if ((det_type == defs::JUNGFRAU || det_type == defs::MOENCH) &&
|
|
((det.getHardwareVersion().tsquash(
|
|
"inconsistent serial number to test") == "2.0"))) {
|
|
hw2 = true;
|
|
}
|
|
if (det_type == defs::EIGER || hw2) {
|
|
auto previous = det.getFlipRows();
|
|
auto previous_numudp = det.getNumberofUDPInterfaces().tsquash(
|
|
"inconsistent number of udp interfaces to test");
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
|
det.setNumberofUDPInterfaces(2);
|
|
}
|
|
std::ostringstream oss1, oss2, oss3;
|
|
caller.call("fliprows", {"1"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "fliprows 1\n");
|
|
caller.call("fliprows", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "fliprows 1\n");
|
|
caller.call("fliprows", {"0"}, -1, PUT, oss3);
|
|
REQUIRE(oss3.str() == "fliprows 0\n");
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setFlipRows(previous[i], {i});
|
|
}
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
|
det.setNumberofUDPInterfaces(previous_numudp);
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("fliprows", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("master", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH) {
|
|
REQUIRE_NOTHROW(caller.call("master", {}, -1, GET));
|
|
if (det_type == defs::EIGER || det_type == defs::GOTTHARD2 ||
|
|
det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
|
// get previous master
|
|
int prevMaster = 0;
|
|
{
|
|
auto previous = det.getMaster();
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (previous[i] == 1) {
|
|
prevMaster = i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
std::ostringstream oss1;
|
|
caller.call("master", {"0"}, 0, PUT, oss1);
|
|
REQUIRE(oss1.str() == "master 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1;
|
|
caller.call("master", {"1"}, 0, PUT, oss1);
|
|
REQUIRE(oss1.str() == "master 1\n");
|
|
}
|
|
if (det.size() > 1) {
|
|
REQUIRE_THROWS(caller.call("master", {"1"}, -1, PUT));
|
|
}
|
|
// set all to slaves, and then master
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setMaster(0, {i});
|
|
}
|
|
det.setMaster(1, prevMaster);
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("master", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("badchannels", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::GOTTHARD2 || det_type == defs::MYTHEN3) {
|
|
auto prev = det.getBadChannels();
|
|
|
|
REQUIRE_THROWS(caller.call("badchannels", {}, -1, GET));
|
|
|
|
std::string fname_put =
|
|
getAbsolutePathFromCurrentProcess(TEST_FILE_NAME_BAD_CHANNELS);
|
|
std::string fname_get = "/tmp/sls_test_channels.txt";
|
|
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_put}, 0, PUT));
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_get}, 0, GET));
|
|
auto list = getChannelsFromFile(fname_get);
|
|
std::vector<int> expected = {0, 12, 15, 40, 41, 42, 43, 44, 1279};
|
|
REQUIRE(list == expected);
|
|
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {"none"}, 0, PUT));
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_get}, 0, GET));
|
|
list = getChannelsFromFile(fname_get);
|
|
REQUIRE(list.empty());
|
|
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_put}, 0, PUT));
|
|
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {"0"}, 0, PUT));
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_get}, 0, GET));
|
|
list = getChannelsFromFile(fname_get);
|
|
REQUIRE(list.empty());
|
|
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {"12"}, 0, PUT));
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_get}, 0, GET));
|
|
list = getChannelsFromFile(fname_get);
|
|
expected = {12};
|
|
REQUIRE(list == expected);
|
|
|
|
REQUIRE_NOTHROW(caller.call(
|
|
"badchannels", {"0", "12,", "15", "43", "40:45", "1279"}, 0, PUT));
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_get}, 0, GET));
|
|
list = getChannelsFromFile(fname_get);
|
|
expected = {0, 12, 15, 40, 41, 42, 43, 44, 1279};
|
|
REQUIRE(list == expected);
|
|
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {"40:45"}, 0, PUT));
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_get}, 0, GET));
|
|
list = getChannelsFromFile(fname_get);
|
|
expected = {40, 41, 42, 43, 44};
|
|
REQUIRE(list == expected);
|
|
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {"5,6,7"}, 0, PUT));
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_get}, 0, GET));
|
|
list = getChannelsFromFile(fname_get);
|
|
expected = {5, 6, 7};
|
|
REQUIRE(list == expected);
|
|
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {"1:5,6,7"}, 0, PUT));
|
|
REQUIRE_NOTHROW(caller.call("badchannels", {fname_get}, 0, GET));
|
|
list = getChannelsFromFile(fname_get);
|
|
expected = {1, 2, 3, 4, 6, 7};
|
|
REQUIRE(list == expected);
|
|
|
|
det.setBadChannels(prev);
|
|
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("badchannels", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("row", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getRow()[0];
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("row", {"1"}, 0, PUT, oss);
|
|
REQUIRE(oss.str() == "row 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("row", {}, 0, GET, oss);
|
|
REQUIRE(oss.str() == "row 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("row", {"0"}, 0, PUT, oss);
|
|
REQUIRE(oss.str() == "row 0\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("row", {"-5"}, -1, PUT));
|
|
det.setRow(prev_val, {0});
|
|
}
|
|
|
|
TEST_CASE("column", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getColumn()[0];
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("column", {"1"}, 0, PUT, oss);
|
|
REQUIRE(oss.str() == "column 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("column", {}, 0, GET, oss);
|
|
REQUIRE(oss.str() == "column 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("column", {"0"}, 0, PUT, oss);
|
|
REQUIRE(oss.str() == "column 0\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("column", {"-5"}, -1, PUT));
|
|
det.setColumn(prev_val, {0});
|
|
}
|
|
|
|
/* acquisition parameters */
|
|
|
|
// acquire: not testing
|
|
|
|
TEST_CASE("frames", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val =
|
|
det.getNumberOfFrames().tsquash("#frames must be same to test");
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("frames", {"1000"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "frames 1000\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("frames", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "frames 1000\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("frames", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "frames 1\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("frames", {"0"}, -1, PUT));
|
|
det.setNumberOfFrames(prev_val);
|
|
}
|
|
|
|
TEST_CASE("triggers", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val =
|
|
det.getNumberOfTriggers().tsquash("#triggers must be same to test");
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("triggers", {"1000"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "triggers 1000\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("triggers", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "triggers 1000\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("triggers", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "triggers 1\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("triggers", {"0"}, -1, PUT));
|
|
det.setNumberOfTriggers(prev_val);
|
|
}
|
|
|
|
TEST_CASE("exptime", "[.cmdcall][.time]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
ns prev_val;
|
|
if (det_type != defs::MYTHEN3) {
|
|
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
|
|
} else {
|
|
auto t =
|
|
det.getExptimeForAllGates().tsquash("inconsistent exptime to test");
|
|
if (t[0] != t[1] || t[1] != t[2]) {
|
|
throw RuntimeError("inconsistent exptime for all gates");
|
|
}
|
|
prev_val = t[0];
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("exptime", {"0.05"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "exptime 0.05\n");
|
|
}
|
|
if (det_type != defs::MYTHEN3) {
|
|
std::ostringstream oss;
|
|
caller.call("exptime", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "exptime 50ms\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("exptime", {"1s"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "exptime 1s\n");
|
|
}
|
|
if (det_type != defs::JUNGFRAU && det_type != defs::MOENCH) {
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("exptime", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "exptime 0\n");
|
|
}
|
|
{
|
|
// Get exptime of single module
|
|
std::ostringstream oss;
|
|
caller.call("exptime", {}, 0, GET, oss);
|
|
if (det_type == defs::MYTHEN3) {
|
|
REQUIRE(oss.str() == "exptime [0ns, 0ns, 0ns]\n");
|
|
} else {
|
|
REQUIRE(oss.str() == "exptime 0ns\n");
|
|
}
|
|
}
|
|
}
|
|
det.setExptime(-1, prev_val);
|
|
}
|
|
|
|
TEST_CASE("period", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getPeriod();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("period", {"1.25s"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "period 1.25s\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("period", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "period 1.25s\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("period", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "period 0\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setPeriod(prev_val[i], {i});
|
|
}
|
|
}
|
|
|
|
TEST_CASE("delay", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER) {
|
|
REQUIRE_THROWS(caller.call("delay", {"1"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("delay", {}, -1, GET));
|
|
} else {
|
|
auto prev_val = det.getDelayAfterTrigger();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("delay", {"1.25s"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "delay 1.25s\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("delay", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "delay 1.25s\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("delay", {"0s"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "delay 0s\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setDelayAfterTrigger(prev_val[i], {i});
|
|
}
|
|
}
|
|
}
|
|
|
|
TEST_CASE("framesl", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER) {
|
|
REQUIRE_THROWS(caller.call("framesl", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_NOTHROW(caller.call("framesl", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("triggersl", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER) {
|
|
REQUIRE_THROWS(caller.call("triggersl", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_NOTHROW(caller.call("triggersl", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("delayl", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
switch (det_type) {
|
|
case defs::EIGER:
|
|
REQUIRE_THROWS(caller.call("delayl", {}, -1, GET));
|
|
break;
|
|
default:
|
|
REQUIRE_NOTHROW(caller.call("delayl", {}, -1, GET));
|
|
break;
|
|
}
|
|
}
|
|
|
|
TEST_CASE("periodl", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
switch (det_type) {
|
|
case defs::EIGER:
|
|
REQUIRE_THROWS(caller.call("periodl", {}, -1, GET));
|
|
break;
|
|
default:
|
|
REQUIRE_NOTHROW(caller.call("periodl", {}, -1, GET));
|
|
break;
|
|
}
|
|
}
|
|
|
|
TEST_CASE("dr", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER) {
|
|
auto dr = det.getDynamicRange().squash();
|
|
std::array<int, 4> vals{4, 8, 16, 32};
|
|
for (const auto val : vals) {
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n');
|
|
caller.call("dr", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n');
|
|
}
|
|
det.setDynamicRange(dr);
|
|
} else if (det_type == defs::MYTHEN3) {
|
|
auto dr = det.getDynamicRange().squash();
|
|
// not updated in firmware to support dr 1
|
|
std::array<int, 3> vals{8, 16, 32};
|
|
for (const auto val : vals) {
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n');
|
|
caller.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(caller.call("dr", {"4"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("dr", {"8"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("dr", {"32"}, -1, PUT));
|
|
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("dr", {"16"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "dr 16\n");
|
|
caller.call("dr", {"16"}, -1, PUT, oss2);
|
|
REQUIRE(oss2.str() == "dr 16\n");
|
|
}
|
|
}
|
|
|
|
TEST_CASE("drlist", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("drlist", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("drlist", {}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("timing", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
auto prev_val = det.getTimingMode();
|
|
det.setTimingMode(defs::AUTO_TIMING);
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("timing", {"auto"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "timing auto\n");
|
|
caller.call("timing", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "timing auto\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("timing", {"trigger"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "timing trigger\n");
|
|
caller.call("timing", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "timing trigger\n");
|
|
}
|
|
if (det_type == defs::EIGER) {
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("timing", {"gating"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "timing gating\n");
|
|
caller.call("timing", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "timing gating\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("timing", {"burst_trigger"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "timing burst_trigger\n");
|
|
caller.call("timing", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "timing burst_trigger\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("timing", {"trigger_gating"}, -1, PUT));
|
|
} else if (det_type == defs::MYTHEN3) {
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("timing", {"gating"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "timing gating\n");
|
|
caller.call("timing", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "timing gating\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("timing", {"trigger_gating"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "timing trigger_gating\n");
|
|
caller.call("timing", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "timing trigger_gating\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("timing", {"burst_trigger"}, -1, PUT));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("timing", {"gating"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("timing", {"burst_trigger"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("timing", {"trigger_gating"}, -1, PUT));
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setTimingMode(prev_val[i], {i});
|
|
}
|
|
}
|
|
|
|
TEST_CASE("timinglist", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("timinglist", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("timinglist", {}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("readoutspeed", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH || det_type == defs::GOTTHARD2 ||
|
|
det_type == defs::MYTHEN3) {
|
|
auto prev_val = det.getReadoutSpeed();
|
|
|
|
// full speed for jungfrau/moench only works for new boards (chipv1.1 is
|
|
// with new board [hw1.0 and chipv1.0 not tested here])
|
|
if (((det_type == defs::JUNGFRAU) &&
|
|
det.getChipVersion().squash() * 10 == 11) ||
|
|
det_type == defs::EIGER || det_type == defs::MOENCH ||
|
|
det_type == defs::MYTHEN3) {
|
|
std::ostringstream oss1, oss2, oss3, oss4;
|
|
caller.call("readoutspeed", {"0"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "readoutspeed full_speed\n");
|
|
caller.call("readoutspeed", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "readoutspeed full_speed\n");
|
|
caller.call("readoutspeed", {"full_speed"}, -1, PUT, oss3);
|
|
REQUIRE(oss3.str() == "readoutspeed full_speed\n");
|
|
caller.call("readoutspeed", {}, -1, GET, oss4);
|
|
REQUIRE(oss4.str() == "readoutspeed full_speed\n");
|
|
}
|
|
|
|
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH || det_type == defs::MYTHEN3) {
|
|
{
|
|
std::ostringstream oss1, oss2, oss3, oss4;
|
|
caller.call("readoutspeed", {"1"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "readoutspeed half_speed\n");
|
|
caller.call("readoutspeed", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "readoutspeed half_speed\n");
|
|
caller.call("readoutspeed", {"half_speed"}, -1, PUT, oss3);
|
|
REQUIRE(oss3.str() == "readoutspeed half_speed\n");
|
|
caller.call("readoutspeed", {}, -1, GET, oss4);
|
|
REQUIRE(oss4.str() == "readoutspeed half_speed\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2, oss3, oss4;
|
|
caller.call("readoutspeed", {"2"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "readoutspeed quarter_speed\n");
|
|
caller.call("readoutspeed", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "readoutspeed quarter_speed\n");
|
|
caller.call("readoutspeed", {"quarter_speed"}, -1, PUT, oss3);
|
|
REQUIRE(oss3.str() == "readoutspeed quarter_speed\n");
|
|
caller.call("readoutspeed", {}, -1, GET, oss4);
|
|
REQUIRE(oss4.str() == "readoutspeed quarter_speed\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("readoutspeed", {"108"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("readoutspeed", {"144"}, -1, PUT));
|
|
}
|
|
|
|
if (det_type == defs::GOTTHARD2) {
|
|
{
|
|
std::ostringstream oss1, oss2, oss3, oss4;
|
|
caller.call("readoutspeed", {"108"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "readoutspeed 108\n");
|
|
caller.call("readoutspeed", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "readoutspeed 108\n");
|
|
}
|
|
|
|
{
|
|
std::ostringstream oss1, oss2, oss3, oss4;
|
|
caller.call("readoutspeed", {"144"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "readoutspeed 144\n");
|
|
caller.call("readoutspeed", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "readoutspeed 144\n");
|
|
}
|
|
REQUIRE_THROWS(
|
|
caller.call("readoutspeed", {"full_speed"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("readoutspeed", {"half_speed"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("readoutspeed", {"quarter_speed"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("readoutspeed", {"0"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("readoutspeed", {"1"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("readoutspeed", {"2"}, -1, PUT));
|
|
}
|
|
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setReadoutSpeed(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("readoutspeed", {"0"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("readoutspeed", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("readoutspeedlist", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH || det_type == defs::EIGER ||
|
|
det_type == defs::MYTHEN3) {
|
|
REQUIRE_NOTHROW(caller.call("readoutspeedlist", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("readoutspeedlist", {}, -1, PUT));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("readoutspeedlist", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("adcphase", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD) {
|
|
auto prev_val = det.getADCPhase();
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("adcphase", {"20"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "adcphase 20\n");
|
|
caller.call("adcphase", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "adcphase 20\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("adcphase", {"20", "deg"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "adcphase 20 deg\n");
|
|
caller.call("adcphase", {"deg"}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "adcphase 20 deg\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setADCPhase(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("adcphase", {"0"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("adcphase", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("maxadcphaseshift", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD ||
|
|
det_type == defs::MYTHEN3 || // only because clk index of 0 exists
|
|
det_type == defs::GOTTHARD2) { // only because clk index of 0 exists
|
|
REQUIRE_NOTHROW(caller.call("maxadcphaseshift", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("maxadcphaseshift", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("dbitphase", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) {
|
|
auto prev_val = det.getDBITPhase();
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("dbitphase", {"20"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "dbitphase 20\n");
|
|
caller.call("dbitphase", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "dbitphase 20\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("dbitphase", {"23", "deg"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "dbitphase 23 deg\n");
|
|
caller.call("dbitphase", {"deg"}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "dbitphase 23 deg\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setDBITPhase(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("dbitphase", {"0"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("dbitphase", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("maxdbitphaseshift", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
|
|
det_type == defs::MYTHEN3 || // only because clk index of 0 exists
|
|
det_type == defs::GOTTHARD2) { // only because clk index of 0 exists
|
|
REQUIRE_NOTHROW(caller.call("maxdbitphaseshift", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("maxdbitphaseshift", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("clkfreq", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
|
|
REQUIRE_THROWS(caller.call("clkfreq", {"0", "2"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("clkfreq", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("clkfreq", {"7"}, -1, GET));
|
|
REQUIRE_NOTHROW(caller.call("clkfreq", {"0"}, -1, GET));
|
|
// other clocks removed for m3 (setting not supported)
|
|
if (det_type == defs::MYTHEN3) {
|
|
REQUIRE_NOTHROW(caller.call("clkfreq", {"1"}, -1, GET));
|
|
REQUIRE_NOTHROW(caller.call("clkfreq", {"2"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("clkfreq", {"3"}, -1, GET));
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("clkfreq", {"0"}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("clkphase", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
|
|
REQUIRE_THROWS(caller.call("clkphase", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("clkphase", {"7"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("clkphase", {"4"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("clkphase", {"7", "4"}, -1, PUT));
|
|
auto prev_val = det.getClockPhase(0);
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("clkphase", {"0", "20"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "clkphase 20\n");
|
|
caller.call("clkphase", {"0"}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "clkphase 20\n");
|
|
}
|
|
std::string s_deg_val = "15";
|
|
if (det_type == defs::MYTHEN3) {
|
|
s_deg_val = "14";
|
|
} else if (det_type == defs::GOTTHARD2) {
|
|
s_deg_val = "23";
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("clkphase", {"0", s_deg_val, "deg"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "clkphase " + s_deg_val + " deg\n");
|
|
caller.call("clkphase", {"0", "deg"}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "clkphase " + s_deg_val + " deg\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setClockPhase(0, prev_val[i], {i});
|
|
}
|
|
// other clocks removed for m3 (setting not supported)
|
|
if (det_type == defs::MYTHEN3) {
|
|
REQUIRE_THROWS(
|
|
caller.call("clkphase", {"1", s_deg_val, "deg"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("clkphase", {"1"}, -1, GET));
|
|
REQUIRE_THROWS(
|
|
caller.call("clkphase", {"2", s_deg_val, "deg"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("clkphase", {"2"}, -1, GET));
|
|
REQUIRE_THROWS(
|
|
caller.call("clkphase", {"3", s_deg_val, "deg"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("clkphase", {"3"}, -1, GET));
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("clkphase", {"0"}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("clkdiv", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
|
|
REQUIRE_THROWS(caller.call("clkdiv", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("clkdiv", {"7"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("clkdiv", {"7", "4"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("clkdiv", {"7", "4"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("clkdiv", {"0", "1"}, -1, PUT));
|
|
auto prev_val = det.getClockDivider(0);
|
|
auto prev_period = det.getPeriod().tsquash("Inconsistent period");
|
|
auto prev_delay =
|
|
det.getDelayAfterTrigger().tsquash("Inconsistent delay");
|
|
std::variant<ns, std::array<ns, 3>> prev_exptime{};
|
|
std::array<ns, 3> prev_gate_delay{};
|
|
ns prev_burst_period{};
|
|
if (det_type == defs::MYTHEN3) {
|
|
prev_exptime =
|
|
det.getExptimeForAllGates().tsquash("Inconsistent exptime");
|
|
prev_gate_delay = det.getGateDelayForAllGates().tsquash(
|
|
"Inconsistent gate delay");
|
|
} else {
|
|
prev_exptime = det.getExptime().tsquash("Inconsistent exptime");
|
|
prev_burst_period =
|
|
det.getBurstPeriod().tsquash("Inconsistent burst period");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("clkdiv", {"0", "3"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "clkdiv 0 3\n");
|
|
caller.call("clkdiv", {"0"}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "clkdiv 0 3\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setClockDivider(0, prev_val[i], {i});
|
|
}
|
|
det.setPeriod(prev_period);
|
|
det.setDelayAfterTrigger(prev_delay);
|
|
if (det_type == defs::MYTHEN3) {
|
|
auto exptimes = std::get<std::array<ns, 3>>(prev_exptime);
|
|
for (int iCounter = 0; iCounter != 3; ++iCounter) {
|
|
det.setExptime(iCounter, exptimes[iCounter]);
|
|
det.setGateDelay(iCounter, prev_gate_delay[iCounter]);
|
|
}
|
|
} else {
|
|
auto exptime = std::get<ns>(prev_exptime);
|
|
det.setExptime(exptime);
|
|
det.setBurstPeriod(prev_burst_period);
|
|
}
|
|
// other clocks removed for m3 (setting not supported)
|
|
if (det_type == defs::MYTHEN3) {
|
|
REQUIRE_THROWS(caller.call("clkdiv", {"1", "2"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("clkdiv", {"1"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("clkdiv", {"2", "2"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("clkdiv", {"2"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("clkdiv", {"3", "2"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("clkdiv", {"3"}, -1, GET));
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("clkdiv", {"0"}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("maxclkphaseshift", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
|
|
REQUIRE_THROWS(caller.call("maxclkphaseshift", {"0", "2"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("maxclkphaseshift", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("maxclkphaseshift", {"7"}, -1, GET));
|
|
REQUIRE_NOTHROW(caller.call("maxclkphaseshift", {"0"}, -1, GET));
|
|
// other clocks removed for m3 (setting not supported)
|
|
if (det_type == defs::MYTHEN3) {
|
|
REQUIRE_NOTHROW(caller.call("maxclkphaseshift", {"1"}, -1, GET));
|
|
REQUIRE_NOTHROW(caller.call("maxclkphaseshift", {"2"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("maxclkphaseshift", {"3"}, -1, GET));
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("maxclkphaseshift", {"0"}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("highvoltage", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type != defs::XILINX_CHIPTESTBOARD) {
|
|
auto prev_val = det.getHighVoltage();
|
|
// range 0, 60 - 200
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD) {
|
|
REQUIRE_THROWS(caller.call("highvoltage", {"50"}, -1, PUT));
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("highvoltage", {"90"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "highvoltage 90\n");
|
|
caller.call("highvoltage", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "highvoltage 90\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("highvoltage", {"0"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "highvoltage 0\n");
|
|
caller.call("highvoltage", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "highvoltage 0\n");
|
|
}
|
|
}
|
|
// full range 0 - 200 (get needs to wait)
|
|
else if (det_type == defs::EIGER) {
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("highvoltage", {"50"}, 0, PUT, oss1);
|
|
REQUIRE(oss1.str() == "highvoltage 50\n");
|
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
caller.call("highvoltage", {}, 0, GET, oss2);
|
|
REQUIRE(oss2.str() == "highvoltage 50\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("highvoltage", {"120"}, 0, PUT, oss1);
|
|
REQUIRE(oss1.str() == "highvoltage 120\n");
|
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
caller.call("highvoltage", {}, 0, GET, oss2);
|
|
REQUIRE(oss2.str() == "highvoltage 120\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("highvoltage", {"0"}, 0, PUT, oss1);
|
|
REQUIRE(oss1.str() == "highvoltage 0\n");
|
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
caller.call("highvoltage", {}, 0, GET, oss2);
|
|
REQUIRE(oss2.str() == "highvoltage 0\n");
|
|
}
|
|
}
|
|
// full range 0 - 200
|
|
else {
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("highvoltage", {"50"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "highvoltage 50\n");
|
|
caller.call("highvoltage", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "highvoltage 50\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("highvoltage", {"120"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "highvoltage 120\n");
|
|
caller.call("highvoltage", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "highvoltage 120\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("highvoltage", {"0"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "highvoltage 0\n");
|
|
caller.call("highvoltage", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "highvoltage 0\n");
|
|
}
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setHighVoltage(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("highvoltage", {"0"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("highvoltage", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("powerchip", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2 ||
|
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
auto prev_val = det.getPowerChip();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("powerchip", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "powerchip 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("powerchip", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "powerchip 0\n");
|
|
}
|
|
// powering off chip throws if hv on (only test virtualserver - safety
|
|
if (det_type == defs::GOTTHARD2 &&
|
|
det.isVirtualDetectorServer().tsquash(
|
|
"Inconsistent virtual detector "
|
|
"server to test powerchip command")) {
|
|
det.setPowerChip(1);
|
|
int hv = det.getHighVoltage().tsquash(
|
|
"Inconsistent high voltage to test "
|
|
"powerchip command");
|
|
|
|
det.setHighVoltage(100);
|
|
REQUIRE_THROWS(caller.call("powerchip", {"0"}, -1, PUT));
|
|
|
|
// previous settings
|
|
det.setHighVoltage(hv);
|
|
det.setPowerChip(0);
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("powerchip", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "powerchip 0\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setPowerChip(prev_val[i], {i});
|
|
if (det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
det.configureTransceiver();
|
|
}
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("powerchip", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("imagetest", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
// cannot test only for virtual eiger/jungfrau
|
|
if (det_type != defs::JUNGFRAU && det_type != defs::MOENCH &&
|
|
det_type != defs::EIGER) {
|
|
// wont fail for eiger and jungfrau/moench virtual servers
|
|
REQUIRE_THROWS(caller.call("imagetest", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("extsig", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::MYTHEN3) {
|
|
auto prev_val_0 = det.getExternalSignalFlags(0);
|
|
auto prev_val_1 = det.getExternalSignalFlags(1);
|
|
REQUIRE_THROWS(caller.call("extsig", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("extsig", {"8"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("extsig", {"0", "inversion_on"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("extsig", {"0", "inversion_off"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("extsig", {"1", "trigger_in_rising_edge"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("extsig", {"1", "trigger_in_falling_edge"}, -1, PUT));
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("extsig", {"0", "trigger_in_rising_edge"}, -1, PUT,
|
|
oss1);
|
|
REQUIRE(oss1.str() == "extsig 0 trigger_in_rising_edge\n");
|
|
caller.call("extsig", {"0"}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "extsig 0 trigger_in_rising_edge\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("extsig", {"0", "trigger_in_falling_edge"}, -1, PUT,
|
|
oss1);
|
|
REQUIRE(oss1.str() == "extsig 0 trigger_in_falling_edge\n");
|
|
caller.call("extsig", {"0"}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "extsig 0 trigger_in_falling_edge\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("extsig", {"1", "inversion_off"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "extsig 1 inversion_off\n");
|
|
caller.call("extsig", {"1"}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "extsig 1 inversion_off\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("extsig", {"1", "inversion_on"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "extsig 1 inversion_on\n");
|
|
caller.call("extsig", {"1"}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "extsig 1 inversion_on\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setExternalSignalFlags(0, prev_val_0[i], {i});
|
|
det.setExternalSignalFlags(1, prev_val_1[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("extsig", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("parallel", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2 || det_type == defs::MOENCH) {
|
|
auto prev_val = det.getParallelMode();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("parallel", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "parallel 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("parallel", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "parallel 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("parallel", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "parallel 0\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setParallelMode(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("parallel", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("filterresistor", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
// only for chipv1.1
|
|
bool chip11 = false;
|
|
if (det_type == defs::JUNGFRAU &&
|
|
det.getChipVersion().squash() * 10 == 11) {
|
|
chip11 = true;
|
|
}
|
|
|
|
if (det_type == defs::GOTTHARD2 || chip11) {
|
|
auto prev_val = det.getFilterResistor();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("filterresistor", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "filterresistor 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("filterresistor", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "filterresistor 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("filterresistor", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "filterresistor 0\n");
|
|
}
|
|
if (det_type == defs::GOTTHARD2) {
|
|
REQUIRE_NOTHROW(caller.call("filterresistor", {"2"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("filterresistor", {"3"}, -1, PUT));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("filterresistor", {"2"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("filterresistor", {"3"}, -1, PUT));
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setFilterResistor(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("filterresistor", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("dbitpipeline", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::CHIPTESTBOARD || det_type == defs::GOTTHARD2) {
|
|
auto prev_val = det.getDBITPipeline();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("dbitpipeline", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "dbitpipeline 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("dbitpipeline", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "dbitpipeline 0\n");
|
|
}
|
|
if (det_type == defs::CHIPTESTBOARD) {
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("dbitpipeline", {"15"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "dbitpipeline 15\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("dbitpipeline", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "dbitpipeline 15\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("dbitpipeline", {"256"}, -1, PUT));
|
|
} else {
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("dbitpipeline", {"7"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "dbitpipeline 7\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("dbitpipeline", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "dbitpipeline 7\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("dbitpipeline", {"8"}, -1, PUT));
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setDBITPipeline(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("dbitpipeline", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("readnrows", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH) {
|
|
bool hw2 = false;
|
|
if ((det_type == defs::JUNGFRAU || det_type == defs::MOENCH) &&
|
|
((det.getHardwareVersion().tsquash(
|
|
"inconsistent hardware version number to test") == "2.0"))) {
|
|
hw2 = true;
|
|
}
|
|
if ((det_type == defs::JUNGFRAU || det_type == defs::MOENCH) && !hw2) {
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("readnrows", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "readnrows 512\n");
|
|
}
|
|
} else {
|
|
auto prev_val = det.getReadNRows();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("readnrows", {"256"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "readnrows 256\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("readnrows", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "readnrows 256\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("readnrows", {"16"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "readnrows 16\n");
|
|
}
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
|
REQUIRE_THROWS(caller.call("readnrows", {"7"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("readnrows", {"20"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("readnrows", {"44"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("readnrows", {"513"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("readnrows", {"1"}, -1, PUT));
|
|
}
|
|
REQUIRE_THROWS(caller.call("readnrows", {"0"}, -1, PUT));
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setReadNRows(prev_val[i], {i});
|
|
}
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("readnrows", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("currentsource", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU) {
|
|
auto prev_val = det.getCurrentSource();
|
|
|
|
if (det_type == defs::GOTTHARD2) {
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "currentsource [1]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "currentsource [0]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "currentsource [disabled]\n");
|
|
}
|
|
REQUIRE_THROWS(
|
|
caller.call("currentsource", {"1", "fix", "42"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("currentsource",
|
|
{"1", "fix", "42", "normal"}, -1, PUT));
|
|
}
|
|
// jungfrau
|
|
else {
|
|
int chipVersion = 10;
|
|
if (det_type == defs::JUNGFRAU) {
|
|
chipVersion = det.getChipVersion().tsquash(
|
|
"inconsistent chip versions to test") *
|
|
10;
|
|
}
|
|
if (chipVersion == 10) {
|
|
REQUIRE_THROWS(caller.call("currentsource", {"1"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("currentsource", {"1", "fix"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("currentsource", {"1", "fix", "64"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("currentsource", {"1", "dfg", "64"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call(
|
|
"currentsource", {"1", "fix", "63", "normal"}, -1, PUT));
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {"1", "fix", "63"}, -1, PUT,
|
|
oss);
|
|
REQUIRE(oss.str() == "currentsource [1, fix, 63]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "currentsource [0]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "currentsource [disabled]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {"1", "nofix", "63"}, -1, PUT,
|
|
oss);
|
|
REQUIRE(oss.str() == "currentsource [1, nofix, 63]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() ==
|
|
"currentsource [enabled, nofix, 63]\n");
|
|
}
|
|
}
|
|
// chipv1.1
|
|
else {
|
|
REQUIRE_THROWS(caller.call("currentsource", {"1"}, -1, PUT));
|
|
REQUIRE_THROWS(
|
|
caller.call("currentsource", {"1", "fix"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call(
|
|
"currentsource", {"1", "ffgdfgix", "0x0000000000000041"},
|
|
-1, PUT));
|
|
REQUIRE_THROWS(caller.call(
|
|
"currentsource",
|
|
{"1", "fix", "0x0000000000000041", "normaldgf"}, -1, PUT));
|
|
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource",
|
|
{"1", "fix", "0x0000000000000041", "normal"},
|
|
-1, PUT, oss);
|
|
REQUIRE(
|
|
oss.str() ==
|
|
"currentsource [1, fix, 0x0000000000000041, normal]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "currentsource [0]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "currentsource [disabled]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource",
|
|
{"1", "nofix", "0x0000000000000041", "normal"},
|
|
-1, PUT, oss);
|
|
REQUIRE(oss.str() == "currentsource [1, nofix, "
|
|
"0x0000000000000041, normal]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "currentsource [enabled, nofix, "
|
|
"0x0000000000000041, normal]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("currentsource",
|
|
{"1", "nofix", "0x0000000000000041", "low"}, -1,
|
|
PUT, oss);
|
|
REQUIRE(
|
|
oss.str() ==
|
|
"currentsource [1, nofix, 0x0000000000000041, low]\n");
|
|
}
|
|
}
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setCurrentSource(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("currentsource", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
/** temperature */
|
|
|
|
TEST_CASE("templist", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("templist", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("templist", {}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("tempvalues", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("tempvalues", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("tempvalues", {}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("temp_adc", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
|
REQUIRE_NOTHROW(caller.call("temp_adc", {}, -1, GET));
|
|
std::ostringstream oss;
|
|
REQUIRE_NOTHROW(caller.call("temp_adc", {}, 0, GET, oss));
|
|
std::string s = (oss.str()).erase(0, strlen("temp_adc "));
|
|
REQUIRE(std::stoi(s) != -1);
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("temp_adc", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("temp_fpga", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type != defs::CHIPTESTBOARD) {
|
|
REQUIRE_NOTHROW(caller.call("temp_fpga", {}, -1, GET));
|
|
std::ostringstream oss;
|
|
REQUIRE_NOTHROW(caller.call("temp_fpga", {}, 0, GET, oss));
|
|
std::string s = (oss.str()).erase(0, strlen("temp_fpga "));
|
|
REQUIRE(std::stoi(s) != -1);
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("temp_fpga", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
/* list */
|
|
|
|
TEST_CASE("daclist", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::CHIPTESTBOARD ||
|
|
det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
REQUIRE_NOTHROW(caller.call("daclist", {}, -1, GET));
|
|
|
|
auto prev = det.getDacNames();
|
|
REQUIRE_THROWS(caller.call("daclist", {"a", "s", "d"}, -1, PUT));
|
|
|
|
std::vector<std::string> names;
|
|
for (int iarg = 0; iarg != 18; ++iarg) {
|
|
names.push_back("a");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
REQUIRE_NOTHROW(caller.call("daclist", names, -1, PUT, oss));
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
REQUIRE_NOTHROW(caller.call("daclist", {}, -1, GET, oss));
|
|
REQUIRE(oss.str() ==
|
|
std::string("daclist ") + ToString(names) + '\n');
|
|
}
|
|
det.setDacNames(prev);
|
|
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("daclist", {"a", "b"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("daclist", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
/* dacs */
|
|
|
|
TEST_CASE("dacvalues", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("dacvalues", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dacvalues", {}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("defaultdac", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type != defs::CHIPTESTBOARD &&
|
|
det_type != defs::XILINX_CHIPTESTBOARD) {
|
|
REQUIRE_THROWS(caller.call("defaultdac", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("defaultdac", {"blabla"}, -1, PUT));
|
|
auto daclist = det.getDacList();
|
|
for (auto it : daclist) {
|
|
if (it == defs::VTHRESHOLD) {
|
|
continue;
|
|
}
|
|
auto dacname = ToString(it);
|
|
auto prev_val = det.getDefaultDac(it);
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("defaultdac", {dacname, "1000"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
|
|
std::string(" 1000\n"));
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("defaultdac", {dacname}, -1, GET, oss);
|
|
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
|
|
std::string(" 1000\n"));
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setDefaultDac(it, prev_val[i], {i});
|
|
}
|
|
}
|
|
if (det_type == defs::JUNGFRAU) {
|
|
std::vector<defs::dacIndex> daclist = {
|
|
defs::VREF_PRECH, defs::VREF_DS, defs::VREF_COMP};
|
|
for (auto it : daclist) {
|
|
auto dacname = ToString(it);
|
|
auto prev_val = det.getDefaultDac(it, defs::GAIN0);
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("defaultdac", {dacname, "1000", "gain0"}, -1,
|
|
PUT, oss);
|
|
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
|
|
std::string(" gain0 1000\n"));
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("defaultdac", {dacname, "gain0"}, -1, GET, oss);
|
|
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
|
|
std::string(" gain0 1000\n"));
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setDefaultDac(it, prev_val[i], defs::GAIN0, {i});
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("defaultdac", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("resetdacs", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type != defs::CHIPTESTBOARD &&
|
|
det_type != defs::XILINX_CHIPTESTBOARD) {
|
|
auto prev_val = det.getSettings();
|
|
|
|
REQUIRE_THROWS(caller.call("resetdacs", {}, -1, GET));
|
|
REQUIRE_NOTHROW(caller.call("resetdacs", {}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("resetdacs", {"hard"}, -1, PUT));
|
|
|
|
// settings should not change especially for jungfrau/moench and m3
|
|
auto next_val = det.getSettings();
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
REQUIRE(prev_val[i] == next_val[i]);
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("resetdacs", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("resetdacs", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
/* acquisition */
|
|
|
|
TEST_CASE("trigger", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_THROWS(caller.call("trigger", {}, -1, GET));
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::MYTHEN3) {
|
|
REQUIRE_NOTHROW(caller.call("trigger", {}, -1, PUT));
|
|
} else if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH) {
|
|
auto prev_timing =
|
|
det.getTimingMode().tsquash("inconsistent timing mode in test");
|
|
auto prev_frames =
|
|
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
|
|
auto prev_exptime =
|
|
det.getExptime().tsquash("inconsistent exptime in test");
|
|
auto prev_period =
|
|
det.getPeriod().tsquash("inconsistent period in test");
|
|
det.setTimingMode(defs::TRIGGER_EXPOSURE);
|
|
det.setNumberOfFrames(1);
|
|
det.setExptime(std::chrono::microseconds(200));
|
|
det.setPeriod(std::chrono::milliseconds(1));
|
|
auto nextframenumber =
|
|
det.getNextFrameNumber().tsquash("inconsistent frame nr in test");
|
|
det.startDetector();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("trigger", {}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "trigger successful\n");
|
|
}
|
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
auto currentfnum =
|
|
det.getNextFrameNumber().tsquash("inconsistent frame nr in test");
|
|
REQUIRE(nextframenumber + 1 == currentfnum);
|
|
det.stopDetector();
|
|
det.setTimingMode(prev_timing);
|
|
det.setNumberOfFrames(prev_frames);
|
|
det.setExptime(prev_exptime);
|
|
det.setPeriod(prev_period);
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("trigger", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("blockingtrigger", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_THROWS(caller.call("blockingtrigger", {}, -1, GET));
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH) {
|
|
auto prev_timing =
|
|
det.getTimingMode().tsquash("inconsistent timing mode in test");
|
|
auto prev_frames =
|
|
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
|
|
auto prev_exptime =
|
|
det.getExptime().tsquash("inconsistent exptime in test");
|
|
auto prev_period =
|
|
det.getPeriod().tsquash("inconsistent period in test");
|
|
det.setTimingMode(defs::TRIGGER_EXPOSURE);
|
|
det.setNumberOfFrames(1);
|
|
det.setExptime(std::chrono::microseconds(200));
|
|
det.setPeriod(std::chrono::milliseconds(1));
|
|
auto nextframenumber =
|
|
det.getNextFrameNumber().tsquash("inconsistent frame nr in test");
|
|
det.startDetector();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("blockingtrigger", {}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "blockingtrigger successful\n");
|
|
}
|
|
if (det.isVirtualDetectorServer().tsquash(
|
|
"inconsistent virtual detectors")) {
|
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
}
|
|
auto currentfnum =
|
|
det.getNextFrameNumber().tsquash("inconsistent frame nr in test");
|
|
REQUIRE(nextframenumber + 1 == currentfnum);
|
|
det.stopDetector();
|
|
det.setTimingMode(prev_timing);
|
|
det.setNumberOfFrames(prev_frames);
|
|
det.setExptime(prev_exptime);
|
|
det.setPeriod(prev_period);
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("blockingtrigger", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("clearbusy", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("clearbusy", {}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("clearbusy", {"0"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("clearbusy", {}, -1, GET));
|
|
}
|
|
|
|
TEST_CASE("start", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
// PUT only command
|
|
REQUIRE_THROWS(caller.call("start", {}, -1, GET));
|
|
auto det_type = det.getDetectorType().squash();
|
|
ns prev_val;
|
|
if (det_type != defs::MYTHEN3) {
|
|
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
|
|
} else {
|
|
auto t =
|
|
det.getExptimeForAllGates().tsquash("inconsistent exptime to test");
|
|
if (t[0] != t[1] || t[1] != t[2]) {
|
|
throw RuntimeError("inconsistent exptime for all gates");
|
|
}
|
|
prev_val = t[0];
|
|
}
|
|
auto prev_frames =
|
|
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
|
|
auto prev_period = det.getPeriod().tsquash("inconsistent period in test");
|
|
det.setExptime(-1, std::chrono::microseconds(200));
|
|
det.setPeriod(std::chrono::milliseconds(1));
|
|
det.setNumberOfFrames(2000);
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("start", {}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "start successful\n");
|
|
}
|
|
if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) {
|
|
std::ostringstream oss;
|
|
caller.call("status", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "status running\n");
|
|
}
|
|
det.stopDetector();
|
|
det.setExptime(-1, prev_val);
|
|
det.setPeriod(prev_period);
|
|
det.setNumberOfFrames(prev_frames);
|
|
}
|
|
|
|
TEST_CASE("stop", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
// PUT only command
|
|
REQUIRE_THROWS(caller.call("stop", {}, -1, GET));
|
|
auto det_type = det.getDetectorType().squash();
|
|
ns prev_val;
|
|
if (det_type != defs::MYTHEN3) {
|
|
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
|
|
} else {
|
|
auto t =
|
|
det.getExptimeForAllGates().tsquash("inconsistent exptime to test");
|
|
if (t[0] != t[1] || t[1] != t[2]) {
|
|
throw RuntimeError("inconsistent exptime for all gates");
|
|
}
|
|
prev_val = t[0];
|
|
}
|
|
auto prev_frames =
|
|
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
|
|
auto prev_period = det.getPeriod().tsquash("inconsistent period in test");
|
|
det.setExptime(-1, std::chrono::microseconds(200));
|
|
det.setPeriod(std::chrono::milliseconds(1));
|
|
det.setNumberOfFrames(2000);
|
|
det.startDetector();
|
|
if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) {
|
|
std::ostringstream oss;
|
|
caller.call("status", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "status running\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("stop", {}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "stop successful\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("status", {}, -1, GET, oss);
|
|
REQUIRE(((oss.str() == "status stopped\n") ||
|
|
(oss.str() == "status idle\n")));
|
|
}
|
|
det.setExptime(-1, prev_val);
|
|
det.setPeriod(prev_period);
|
|
det.setNumberOfFrames(prev_frames);
|
|
}
|
|
|
|
TEST_CASE("status", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
ns prev_val;
|
|
if (det_type != defs::MYTHEN3) {
|
|
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
|
|
} else {
|
|
auto t =
|
|
det.getExptimeForAllGates().tsquash("inconsistent exptime to test");
|
|
if (t[0] != t[1] || t[1] != t[2]) {
|
|
throw RuntimeError("inconsistent exptime for all gates");
|
|
}
|
|
prev_val = t[0];
|
|
}
|
|
auto prev_frames =
|
|
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
|
|
auto prev_period = det.getPeriod().tsquash("inconsistent period in test");
|
|
det.setExptime(-1, std::chrono::microseconds(200));
|
|
det.setPeriod(std::chrono::milliseconds(1));
|
|
det.setNumberOfFrames(2000);
|
|
det.startDetector();
|
|
if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) {
|
|
std::ostringstream oss;
|
|
caller.call("status", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "status running\n");
|
|
}
|
|
det.stopDetector();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("status", {}, -1, GET, oss);
|
|
REQUIRE(((oss.str() == "status stopped\n") ||
|
|
(oss.str() == "status idle\n")));
|
|
}
|
|
det.setExptime(-1, prev_val);
|
|
det.setPeriod(prev_period);
|
|
det.setNumberOfFrames(prev_frames);
|
|
}
|
|
|
|
TEST_CASE("nextframenumber", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH || det_type == defs::CHIPTESTBOARD ||
|
|
det_type == defs::XILINX_CHIPTESTBOARD || det_type == defs::GOTTHARD2) {
|
|
auto prev_sfnum = det.getNextFrameNumber();
|
|
REQUIRE_THROWS(caller.call("nextframenumber", {"0"}, -1, PUT));
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("nextframenumber", {"3"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "nextframenumber 3\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("nextframenumber", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "nextframenumber 3\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("nextframenumber", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "nextframenumber 1\n");
|
|
}
|
|
|
|
if (det_type == defs::GOTTHARD2) {
|
|
auto prev_timing =
|
|
det.getTimingMode().tsquash("inconsistent timing mode in test");
|
|
auto prev_frames =
|
|
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
|
|
auto prev_exptime =
|
|
det.getExptime().tsquash("inconsistent exptime in test");
|
|
auto prev_period =
|
|
det.getPeriod().tsquash("inconsistent period in test");
|
|
auto prev_burstmode =
|
|
det.getBurstMode().tsquash("inconsistent burst mode in test");
|
|
auto prev_bursts =
|
|
det.getNumberOfBursts().tsquash("inconsistent #bursts in test");
|
|
auto prev_burstperiod = det.getBurstPeriod().tsquash(
|
|
"inconsistent burst period in test");
|
|
|
|
det.setTimingMode(defs::AUTO_TIMING);
|
|
det.setNumberOfFrames(1);
|
|
det.setExptime(std::chrono::microseconds(200));
|
|
det.setPeriod(std::chrono::milliseconds(1));
|
|
det.setBurstMode(defs::CONTINUOUS_EXTERNAL);
|
|
det.setNumberOfBursts(1);
|
|
det.setBurstPeriod(std::chrono::milliseconds(0));
|
|
|
|
det.startDetector();
|
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
auto currentfnum = det.getNextFrameNumber().tsquash(
|
|
"inconsistent frame nr in test");
|
|
REQUIRE(currentfnum == 2);
|
|
|
|
det.setTimingMode(prev_timing);
|
|
det.setNumberOfFrames(prev_frames);
|
|
det.setExptime(prev_exptime);
|
|
det.setPeriod(prev_period);
|
|
det.setBurstMode(prev_burstmode);
|
|
det.setNumberOfBursts(prev_bursts);
|
|
det.setBurstPeriod(prev_burstperiod);
|
|
} else {
|
|
auto prev_timing =
|
|
det.getTimingMode().tsquash("inconsistent timing mode in test");
|
|
auto prev_frames =
|
|
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
|
|
auto prev_exptime =
|
|
det.getExptime().tsquash("inconsistent exptime in test");
|
|
auto prev_period =
|
|
det.getPeriod().tsquash("inconsistent period in test");
|
|
det.setTimingMode(defs::AUTO_TIMING);
|
|
det.setNumberOfFrames(1);
|
|
det.setExptime(std::chrono::microseconds(200));
|
|
det.setPeriod(std::chrono::milliseconds(1));
|
|
det.startDetector();
|
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
auto currentfnum = det.getNextFrameNumber().tsquash(
|
|
"inconsistent frame nr in test");
|
|
REQUIRE(currentfnum == 2);
|
|
if (det_type == defs::EIGER) {
|
|
auto prev_tengiga =
|
|
det.getTenGiga().tsquash("inconsistent ten giga enable");
|
|
det.setTenGiga(true);
|
|
det.setNextFrameNumber(1);
|
|
det.startDetector();
|
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
auto currentfnum = det.getNextFrameNumber().tsquash(
|
|
"inconsistent frame nr in test");
|
|
REQUIRE(currentfnum == 2);
|
|
det.setTenGiga(prev_tengiga);
|
|
}
|
|
|
|
det.setTimingMode(prev_timing);
|
|
det.setNumberOfFrames(prev_frames);
|
|
det.setExptime(prev_exptime);
|
|
det.setPeriod(prev_period);
|
|
}
|
|
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setNextFrameNumber(prev_sfnum[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("nextframenumber", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("scan", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
defs::dacIndex ind = defs::DAC_0;
|
|
defs::dacIndex notImplementedInd = defs::DAC_0;
|
|
auto det_type = det.getDetectorType().squash();
|
|
switch (det_type) {
|
|
case defs::CHIPTESTBOARD:
|
|
case defs::XILINX_CHIPTESTBOARD:
|
|
ind = defs::DAC_0;
|
|
notImplementedInd = defs::VSVP;
|
|
break;
|
|
case defs::EIGER:
|
|
ind = defs::VCMP_LL;
|
|
notImplementedInd = defs::VIN_COM;
|
|
break;
|
|
case defs::JUNGFRAU:
|
|
ind = defs::VB_COMP;
|
|
notImplementedInd = defs::VSVP;
|
|
break;
|
|
case defs::MOENCH:
|
|
ind = defs::VIN_CM;
|
|
notImplementedInd = defs::VSVP;
|
|
break;
|
|
case defs::GOTTHARD2:
|
|
ind = defs::VB_COMP_FE;
|
|
notImplementedInd = defs::VSVP;
|
|
break;
|
|
case defs::MYTHEN3:
|
|
ind = defs::VTH2;
|
|
notImplementedInd = defs::VSVP;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
// when taking acquisition
|
|
// auto previous = det.getDAC(ind, false);
|
|
// auto notImplementedPrevious = det.getDAC(notImplementedInd, false);
|
|
|
|
if (det_type == defs::MYTHEN3 && det.size() > 1) {
|
|
; // scan only allowed for single module due to sync
|
|
} else {
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("scan", {ToString(ind), "500", "1500", "500"}, -1, PUT,
|
|
oss);
|
|
CHECK(oss.str() ==
|
|
"scan [" + ToString(ind) + ", 500, 1500, 500]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("scan", {}, -1, GET, oss);
|
|
CHECK(oss.str() == "scan [enabled\ndac " + ToString(ind) +
|
|
"\nstart 500\nstop 1500\nstep "
|
|
"500\nsettleTime 1ms\n]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("scan", {ToString(ind), "500", "1500", "500", "2s"}, -1,
|
|
PUT, oss);
|
|
CHECK(oss.str() ==
|
|
"scan [" + ToString(ind) + ", 500, 1500, 500, 2s]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("scan", {}, -1, GET, oss);
|
|
CHECK(oss.str() == "scan [enabled\ndac " + ToString(ind) +
|
|
"\nstart 500\nstop 1500\nstep "
|
|
"500\nsettleTime 2s\n]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("scan", {"0"}, -1, PUT, oss);
|
|
CHECK(oss.str() == "scan [0]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("scan", {}, -1, GET, oss);
|
|
CHECK(oss.str() == "scan [disabled]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("scan", {ToString(ind), "1500", "500", "-500"}, -1, PUT,
|
|
oss);
|
|
CHECK(oss.str() ==
|
|
"scan [" + ToString(ind) + ", 1500, 500, -500]\n");
|
|
}
|
|
CHECK_THROWS(caller.call(
|
|
"scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1,
|
|
PUT));
|
|
CHECK_THROWS(caller.call("scan", {ToString(ind), "500", "1500", "-500"},
|
|
-1, PUT));
|
|
CHECK_THROWS(caller.call("scan", {ToString(ind), "1500", "500", "500"},
|
|
-1, PUT));
|
|
|
|
if (det_type == defs::MYTHEN3 || defs::EIGER) {
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("scan", {"trimbits", "0", "63", "16", "2s"}, -1,
|
|
PUT, oss);
|
|
CHECK(oss.str() == "scan [trimbits, 0, 63, 16, 2s]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("scan", {}, -1, GET, oss);
|
|
CHECK(oss.str() ==
|
|
"scan [enabled\ndac trimbits\nstart 0\nstop 48\nstep "
|
|
"16\nsettleTime 2s\n]\n");
|
|
}
|
|
}
|
|
|
|
// Switch off scan for future tests
|
|
det.setScan(defs::scanParameters());
|
|
// acquire for each?
|
|
|
|
// when taking acquisition
|
|
// Reset all dacs to previous value
|
|
// for (int i = 0; i != det.size(); ++i) {
|
|
// det.setDAC(ind, previous[i], false, {i});
|
|
// det.setDAC(notImplementedInd, notImplementedPrevious[i],
|
|
// false, {i});
|
|
// }
|
|
}
|
|
}
|
|
|
|
TEST_CASE("scanerrmsg", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("scanerrmsg", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("scanerrmsg", {""}, -1, PUT));
|
|
}
|
|
|
|
/* Network Configuration (Detector<->Receiver) */
|
|
|
|
TEST_CASE("numinterfaces", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
|
auto prev_val = det.getNumberofUDPInterfaces().tsquash(
|
|
"inconsistent numinterfaces to test");
|
|
UdpDestination prev_udp_dest{};
|
|
IpAddr prev_src_ip2{};
|
|
if (prev_val == 2 && det_type != defs::EIGER) {
|
|
prev_udp_dest = det.getDestinationUDPList(0)[0];
|
|
prev_src_ip2 = det.getSourceUDPIP2()[0];
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("numinterfaces", {"2"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "numinterfaces 2\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("numinterfaces", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "numinterfaces 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("numinterfaces", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "numinterfaces 1\n");
|
|
}
|
|
if (prev_val == 2 && det_type != defs::EIGER) {
|
|
det.setDestinationUDPList({prev_udp_dest}, 0);
|
|
det.setSourceUDPIP2({prev_src_ip2}, {0});
|
|
}
|
|
det.setNumberofUDPInterfaces(prev_val);
|
|
} else if (det_type == defs::EIGER) {
|
|
REQUIRE_THROWS(caller.call("numinterfaces", {"1"}, -1, PUT));
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("numinterfaces", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "numinterfaces 2\n");
|
|
}
|
|
} else {
|
|
std::ostringstream oss;
|
|
caller.call("numinterfaces", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "numinterfaces 1\n");
|
|
REQUIRE_THROWS(caller.call("numinterfaces", {"1"}, -1, PUT));
|
|
}
|
|
REQUIRE_THROWS(caller.call("numinterfaces", {"3"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("numinterfaces", {"0"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("udp_srcip", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getSourceUDPIP();
|
|
REQUIRE_THROWS(caller.call("udp_srcip", {"0.0.0.0"}, -1, PUT));
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("udp_srcip", {"129.129.205.12"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "udp_srcip 129.129.205.12\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setSourceUDPIP(prev_val[i], {i});
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_dstlist", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2) {
|
|
REQUIRE_NOTHROW(caller.call("udp_dstlist", {}, 0, GET, std::cout, 0));
|
|
REQUIRE_THROWS(caller.call(
|
|
"udp_dstlist", {"ip=0.0.0.0", "mac=00:00:00:00:00:00", "port=1233"},
|
|
-1, PUT, std::cout, 0));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("udp_dstlist", {}, -1, GET, std::cout, 0));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_numdst", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2) {
|
|
REQUIRE_NOTHROW(caller.call("udp_numdst", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("udp_numdst", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_cleardst", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_THROWS(caller.call("udp_cleardst", {}, -1, GET));
|
|
/* dont clear all udp destinations */
|
|
/*REQUIRE_NOTHROW(caller.call("udp_cleardst", {}, -1, PUT));*/
|
|
}
|
|
|
|
TEST_CASE("udp_firstdst", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
|
|
auto prev_val = det.getFirstUDPDestination();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("udp_firstdst", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "udp_firstdst 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("udp_firstdst", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "udp_firstdst 0\n");
|
|
}
|
|
/*
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("udp_firstdst", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "udp_firstdst 1\n");
|
|
}
|
|
*/
|
|
REQUIRE_THROWS(caller.call("udp_firstdst", {"33"}, -1, PUT));
|
|
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setFirstUDPDestination(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("udp_firstdst", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_dstip", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_THROWS(caller.call("udp_dstip", {"0.0.0.0"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("udp_srcmac", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getSourceUDPMAC();
|
|
REQUIRE_THROWS(caller.call("udp_srcmac", {"00:00:00:00:00:00"}, -1, PUT));
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("udp_srcmac", {"00:50:c2:42:34:12"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "udp_srcmac 00:50:c2:42:34:12\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (prev_val[i].str() != "00:00:00:00:00:00") {
|
|
det.setSourceUDPMAC(prev_val[i], {i});
|
|
}
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_dstmac", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_THROWS(caller.call("udp_dstmac", {"00:00:00:00:00:00"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("udp_dstport", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getDestinationUDPPort();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("udp_dstport", {"50084"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "udp_dstport 50084\n");
|
|
}
|
|
test_valid_port_caller("udp_dstport", {}, -1, PUT);
|
|
test_valid_port_caller("udp_dstport", {}, 0, PUT);
|
|
// should fail for the second module
|
|
if (det.size() > 1) {
|
|
REQUIRE_THROWS(caller.call("udp_dstport", {"65535"}, -1, PUT));
|
|
}
|
|
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setDestinationUDPPort(prev_val[i], {i});
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_srcip2", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::GOTTHARD2) {
|
|
auto prev_val = det.getSourceUDPIP2();
|
|
REQUIRE_THROWS(caller.call("udp_srcip2", {"0.0.0.0"}, -1, PUT));
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("udp_srcip2", {"129.129.205.12"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "udp_srcip2 129.129.205.12\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (prev_val[i] != IpAddr{"0.0.0.0"})
|
|
det.setSourceUDPIP2(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("udp_srcip2", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_dstip2", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::GOTTHARD2) {
|
|
REQUIRE_THROWS(caller.call("udp_dstip2", {"0.0.0.0"}, -1, PUT));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("udp_dstip2", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_srcmac2", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::GOTTHARD2) {
|
|
auto prev_val = det.getSourceUDPMAC2();
|
|
REQUIRE_THROWS(
|
|
caller.call("udp_srcmac2", {"00:00:00:00:00:00"}, -1, PUT));
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("udp_srcmac2", {"00:50:c2:42:34:12"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "udp_srcmac2 00:50:c2:42:34:12\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (prev_val[i].str() != "00:00:00:00:00:00") {
|
|
det.setSourceUDPMAC2(prev_val[i], {i});
|
|
}
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("udp_srcmac2", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_dstmac2", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::GOTTHARD2) {
|
|
REQUIRE_THROWS(
|
|
caller.call("udp_dstmac2", {"00:00:00:00:00:00"}, -1, PUT));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("udp_dstmac2", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_dstport2", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::GOTTHARD2 || det_type == defs::EIGER) {
|
|
auto prev_val = det.getDestinationUDPPort2();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("udp_dstport2", {"50084"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "udp_dstport2 50084\n");
|
|
}
|
|
test_valid_port_caller("udp_dstport2", {}, -1, PUT);
|
|
test_valid_port_caller("udp_dstport2", {}, 0, PUT);
|
|
// should fail for the second module
|
|
if (det.size() > 1) {
|
|
REQUIRE_THROWS(caller.call("udp_dstport2", {"65535"}, -1, PUT));
|
|
}
|
|
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (prev_val[i] != 0) {
|
|
det.setDestinationUDPPort2(prev_val[i], {i});
|
|
}
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("udp_dstport2", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("udp_reconfigure", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_THROWS(caller.call("udp_reconfigure", {}, -1, GET));
|
|
REQUIRE_NOTHROW(caller.call("udp_reconfigure", {}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("udp_validate", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_THROWS(caller.call("udp_validate", {}, -1, GET));
|
|
REQUIRE_NOTHROW(caller.call("udp_validate", {}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("tengiga", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER || det_type == defs::CHIPTESTBOARD ||
|
|
det_type == defs::MYTHEN3) {
|
|
auto tengiga = det.getTenGiga();
|
|
det.setTenGiga(false);
|
|
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("tengiga", {"1"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "tengiga 1\n");
|
|
caller.call("tengiga", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "tengiga 1\n");
|
|
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setTenGiga(tengiga[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("tengiga", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("flowcontrol10g", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH) {
|
|
auto prev_val = det.getTenGigaFlowControl();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("flowcontrol10g", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "flowcontrol10g 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("flowcontrol10g", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "flowcontrol10g 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("flowcontrol10g", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "flowcontrol10g 0\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setTenGigaFlowControl(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("flowcontrol10g", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("txdelay_frame", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH || det_type == defs::MYTHEN3) {
|
|
auto prev_val = det.getTransmissionDelayFrame();
|
|
auto val = 5000;
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::MYTHEN3) {
|
|
val = 5;
|
|
}
|
|
std::string sval = std::to_string(val);
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("txdelay_frame", {sval}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "txdelay_frame " + sval + "\n");
|
|
caller.call("txdelay_frame", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "txdelay_frame " + sval + "\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setTransmissionDelayFrame(prev_val[i]);
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("txdelay_frame", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("txdelay", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH || det_type == defs::MYTHEN3) {
|
|
|
|
// cannot get transmission delay with just one module
|
|
if ((det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::MYTHEN3) &&
|
|
(det.size() < 2)) {
|
|
REQUIRE_THROWS(caller.call("txdelay", {}, -1, GET));
|
|
int val = 5;
|
|
std::string sval = std::to_string(val);
|
|
{
|
|
std::ostringstream oss1;
|
|
caller.call("txdelay", {sval}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "txdelay " + sval + "\n");
|
|
}
|
|
}
|
|
|
|
else {
|
|
Result<int> prev_left, prev_right;
|
|
bool eiger = false;
|
|
if (det_type == defs::EIGER) {
|
|
eiger = true;
|
|
prev_left = det.getTransmissionDelayLeft();
|
|
prev_right = det.getTransmissionDelayRight();
|
|
}
|
|
auto prev_frame = det.getTransmissionDelayFrame();
|
|
auto val = 5000;
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::MYTHEN3) {
|
|
val = 5;
|
|
}
|
|
std::string sval = std::to_string(val);
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("txdelay", {sval}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "txdelay " + sval + "\n");
|
|
caller.call("txdelay", {}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "txdelay " + sval + "\n");
|
|
}
|
|
// test other mods
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (eiger) {
|
|
REQUIRE(det.getTransmissionDelayLeft({i}).squash(-1) ==
|
|
(2 * i * val));
|
|
REQUIRE(det.getTransmissionDelayRight({i}).squash(-1) ==
|
|
((2 * i + 1) * val));
|
|
REQUIRE(det.getTransmissionDelayFrame({i}).squash(-1) ==
|
|
(2 * det.size() * val));
|
|
} else {
|
|
REQUIRE(det.getTransmissionDelayFrame({i}).squash(-1) ==
|
|
(i * val));
|
|
}
|
|
}
|
|
// not a module level command
|
|
REQUIRE_THROWS(caller.call("txdelay", {"5"}, 0, PUT));
|
|
REQUIRE_THROWS(caller.call("txdelay", {}, 0, GET));
|
|
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
if (eiger) {
|
|
det.setTransmissionDelayLeft(prev_left[i]);
|
|
det.setTransmissionDelayRight(prev_right[i]);
|
|
}
|
|
det.setTransmissionDelayFrame(prev_frame[i]);
|
|
}
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("txdelay", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
|
|
|
TEST_CASE("zmqport", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
|
|
int socketsperdetector = 1;
|
|
auto det_type = det.getDetectorType().squash();
|
|
int prev = 1;
|
|
if (det_type == defs::EIGER) {
|
|
socketsperdetector *= 2;
|
|
} else if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
|
prev = det.getNumberofUDPInterfaces().squash();
|
|
det.setNumberofUDPInterfaces(2);
|
|
socketsperdetector *= 2;
|
|
}
|
|
uint16_t port = 3500;
|
|
auto port_str = std::to_string(port);
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("zmqport", {port_str}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "zmqport " + port_str + '\n');
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
std::ostringstream oss;
|
|
caller.call("zmqport", {}, i, GET, oss);
|
|
REQUIRE(oss.str() == "zmqport " +
|
|
std::to_string(port + i * socketsperdetector) +
|
|
'\n');
|
|
}
|
|
|
|
port = 1954;
|
|
port_str = std::to_string(port);
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("zmqport", {port_str}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "zmqport " + port_str + '\n');
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
std::ostringstream oss;
|
|
caller.call("zmqport", {}, i, GET, oss);
|
|
REQUIRE(oss.str() == "zmqport " +
|
|
std::to_string(port + i * socketsperdetector) +
|
|
'\n');
|
|
}
|
|
test_valid_port_caller("zmqport", {}, -1, PUT);
|
|
test_valid_port_caller("zmqport", {}, 0, PUT);
|
|
// should fail for the second module
|
|
if (det.size() > 1) {
|
|
REQUIRE_THROWS(caller.call("zmqport", {"65535"}, -1, PUT));
|
|
}
|
|
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
|
det.setNumberofUDPInterfaces(prev);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("zmqip", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
std::ostringstream oss1, oss2;
|
|
auto zmqip = det.getClientZmqIp();
|
|
caller.call("zmqip", {}, 0, GET, oss1);
|
|
REQUIRE(oss1.str() == "zmqip " + zmqip[0].str() + '\n');
|
|
|
|
caller.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.setClientZmqIp(zmqip[i], {i});
|
|
}
|
|
}
|
|
|
|
TEST_CASE("zmqhwm", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getClientZmqHwm();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("zmqhwm", {"50"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "zmqhwm 50\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("zmqhwm", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "zmqhwm 50\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("zmqhwm", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "zmqhwm 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("zmqhwm", {"-1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "zmqhwm -1\n");
|
|
}
|
|
det.setClientZmqHwm(prev_val);
|
|
}
|
|
|
|
/* Advanced */
|
|
|
|
TEST_CASE("adcpipeline", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
|
|
auto prev_val = det.getADCPipeline();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("adcpipeline", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "adcpipeline 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("adcpipeline", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "adcpipeline 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("adcpipeline", {"15"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "adcpipeline 15\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("adcpipeline", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "adcpipeline 15\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setADCPipeline(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("adcpipeline", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("programfpga", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::CHIPTESTBOARD || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2) {
|
|
// TODO program a real board?
|
|
/// afs/psi.ch/project/sls_det_firmware/jungfrau_firmware/cyclone_V/v0_8/Jungfrau_MCB.pof
|
|
REQUIRE_THROWS(caller.call("programfpga", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("programfpga", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("programfpga", {"/tmp/test.pof"}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("resetfpga", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
|
|
det_type == defs::MOENCH || det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
// reset will also reset udp info from config file (comment out for
|
|
// invdividual tests) std::ostringstream oss; caller.call("resetfpga",
|
|
// {}, -1, PUT, oss); REQUIRE(oss.str() == "resetfpga successful\n");
|
|
REQUIRE_THROWS(caller.call("resetfpga", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("resetfpga", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("resetfpga", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("updatekernel", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2) {
|
|
// TODO: send real server?
|
|
// std::ostringstream oss;
|
|
// caller.call("updatekernel",{"juImage_detector.lzma",
|
|
// "pc13784"}, -1, PUT, oss);
|
|
// REQUIRE(oss.str() == "updatekernel successful\n");
|
|
REQUIRE_THROWS(caller.call("updatekernel", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("updatekernel", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("updatekernel", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("rebootcontroller", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2 || det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
// TODO: reboot real server?
|
|
// REQUIRE_NOTHROW(caller.call("rebootcontroller", {}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("rebootcontroller", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("rebootcontroller", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("rebootcontroller", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("update", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD) {
|
|
// TODO: update real server and firmware?
|
|
// REQUIRE_NOTHROW(caller.call("update",
|
|
// {"jungfrauDetectorServerv4.0.1.0", "pc13784",
|
|
// "/afs/psi.ch/project/sls_det_firmware/jungfrau_firmware/cyclone_V/v0_8/Jungfrau_MCB.pof"},
|
|
// -1, PUT));
|
|
REQUIRE_THROWS(caller.call("update", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("update", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("update", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("reg", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type != defs::EIGER) {
|
|
uint32_t addr = 0x64;
|
|
if (det_type == defs::MYTHEN3) {
|
|
addr = 0x80;
|
|
}
|
|
if (det_type == defs::GOTTHARD2) {
|
|
addr = 0x298;
|
|
}
|
|
std::string saddr = ToStringHex(addr);
|
|
auto prev_val = det.readRegister(addr);
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("reg", {saddr, "0x6", "--validate"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "reg [" + saddr + ", 0x6]\n");
|
|
caller.call("reg", {saddr}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "reg 0x6\n");
|
|
}
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("reg", {saddr, "0x5"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "reg [" + saddr + ", 0x5]\n");
|
|
caller.call("reg", {saddr}, -1, GET, oss2);
|
|
REQUIRE(oss2.str() == "reg 0x5\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.writeRegister(addr, prev_val[i], false, {i});
|
|
}
|
|
}
|
|
// cannot check for eiger virtual server
|
|
else {
|
|
REQUIRE_NOTHROW(caller.call("reg", {"0x64"}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("adcreg", "[.cmdcall]") {
|
|
// TODO! what is a safe value to use?
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD) {
|
|
if (det.isVirtualDetectorServer().tsquash(
|
|
"Inconsistent virtual detector server to test adcreg")) {
|
|
std::ostringstream oss;
|
|
caller.call("adcreg", {"0x8", "0x3"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "adcreg [0x8, 0x3]\n");
|
|
}
|
|
// This is a put only command
|
|
REQUIRE_THROWS(caller.call("adcreg", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("adcreg", {"0x0", "0"}, -1, PUT));
|
|
REQUIRE_THROWS(caller.call("adcreg", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("setbit", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type != defs::EIGER) {
|
|
uint32_t addr = 0x64;
|
|
if (det_type == defs::MYTHEN3) {
|
|
addr = 0x80;
|
|
}
|
|
if (det_type == defs::GOTTHARD2) {
|
|
addr = 0x298;
|
|
}
|
|
std::string saddr = ToStringHex(addr);
|
|
auto prev_val = det.readRegister(addr);
|
|
{
|
|
std::ostringstream oss1, oss2, oss3;
|
|
caller.call("reg", {saddr, "0x0"}, -1, PUT);
|
|
caller.call("setbit", {saddr, "1"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "setbit [" + saddr + ", 1]\n");
|
|
caller.call("setbit", {saddr, "2", "--validate"}, -1, PUT, oss2);
|
|
REQUIRE(oss2.str() == "setbit [" + saddr + ", 2]\n");
|
|
caller.call("reg", {saddr}, -1, GET, oss3);
|
|
REQUIRE(oss3.str() == "reg 0x6\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.writeRegister(addr, prev_val[i], false, {i});
|
|
}
|
|
}
|
|
}
|
|
|
|
TEST_CASE("clearbit", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type != defs::EIGER) {
|
|
uint32_t addr = 0x64;
|
|
if (det_type == defs::MYTHEN3) {
|
|
addr = 0x80;
|
|
}
|
|
if (det_type == defs::GOTTHARD2) {
|
|
addr = 0x298;
|
|
}
|
|
std::string saddr = ToStringHex(addr);
|
|
auto prev_val = det.readRegister(addr);
|
|
{
|
|
std::ostringstream oss1, oss2, oss3;
|
|
caller.call("reg", {saddr, "0x7"}, -1, PUT);
|
|
caller.call("clearbit", {saddr, "1"}, -1, PUT, oss1);
|
|
REQUIRE(oss1.str() == "clearbit [" + saddr + ", 1]\n");
|
|
caller.call("clearbit", {saddr, "2", "--validate"}, -1, PUT, oss2);
|
|
REQUIRE(oss2.str() == "clearbit [" + saddr + ", 2]\n");
|
|
caller.call("reg", {saddr}, -1, GET, oss3);
|
|
REQUIRE(oss3.str() == "reg 0x1\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.writeRegister(addr, prev_val[i], false, {i});
|
|
}
|
|
}
|
|
}
|
|
|
|
TEST_CASE("getbit", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type != defs::EIGER) {
|
|
uint32_t addr = 0x64;
|
|
if (det_type == defs::MYTHEN3) {
|
|
addr = 0x80;
|
|
}
|
|
if (det_type == defs::GOTTHARD2) {
|
|
addr = 0x298;
|
|
}
|
|
std::string saddr = ToStringHex(addr);
|
|
auto prev_val = det.readRegister(addr);
|
|
{
|
|
std::ostringstream oss1, oss2;
|
|
caller.call("reg", {saddr, "0x3"}, -1, PUT);
|
|
caller.call("getbit", {saddr, "1"}, -1, GET, oss1);
|
|
REQUIRE(oss1.str() == "getbit 1\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.writeRegister(addr, prev_val[i], false, {i});
|
|
}
|
|
}
|
|
// cannot check for eiger virtual server
|
|
else {
|
|
REQUIRE_NOTHROW(caller.call("getbit", {"0x64", "1"}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("firmwaretest", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2 || det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
std::ostringstream oss;
|
|
caller.call("firmwaretest", {}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "firmwaretest successful\n");
|
|
REQUIRE_THROWS(caller.call("firmwaretest", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("firmwaretest", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("firmwaretest", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("bustest", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2) {
|
|
std::ostringstream oss;
|
|
caller.call("bustest", {}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "bustest successful\n");
|
|
REQUIRE_THROWS(caller.call("bustest", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("bustest", {}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("bustest", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("initialchecks", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto check = det.getInitialChecks();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("initialchecks", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "initialchecks 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("initialchecks", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "initialchecks 0\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("initialchecks", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "initialchecks 0\n");
|
|
}
|
|
det.setInitialChecks(check);
|
|
}
|
|
|
|
TEST_CASE("adcinvert", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::CHIPTESTBOARD || det_type == defs::JUNGFRAU ||
|
|
det_type == defs::MOENCH) {
|
|
auto prev_val = det.getADCInvert();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("adcinvert", {"0x8d0a21d4"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "adcinvert 0x8d0a21d4\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("adcinvert", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "adcinvert 0x8d0a21d4\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setADCInvert(prev_val[i], {i});
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("adcinvert", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
/* Insignificant */
|
|
|
|
TEST_CASE("port", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getControlPort({0}).squash();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("port", {"1942"}, 0, PUT, oss);
|
|
REQUIRE(oss.str() == "port 1942\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("port", {}, 0, GET, oss);
|
|
REQUIRE(oss.str() == "port 1942\n");
|
|
}
|
|
test_valid_port_caller("port", {}, -1, PUT);
|
|
test_valid_port_caller("port", {}, 0, PUT);
|
|
// should fail for the second module
|
|
if (det.size() > 1) {
|
|
REQUIRE_THROWS(caller.call("port", {"65536"}, -1, PUT));
|
|
}
|
|
|
|
det.setControlPort(prev_val, {0});
|
|
}
|
|
|
|
TEST_CASE("stopport", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getStopPort({0}).squash();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("stopport", {"1942"}, 0, PUT, oss);
|
|
REQUIRE(oss.str() == "stopport 1942\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("stopport", {}, 0, GET, oss);
|
|
REQUIRE(oss.str() == "stopport 1942\n");
|
|
}
|
|
test_valid_port_caller("stopport", {}, -1, PUT);
|
|
test_valid_port_caller("stopport", {}, 0, PUT);
|
|
// should fail for the second module
|
|
if (det.size() > 1) {
|
|
REQUIRE_THROWS(caller.call("stopport", {"65536"}, -1, PUT));
|
|
}
|
|
|
|
det.setStopPort(prev_val, {0});
|
|
}
|
|
|
|
TEST_CASE("lock", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto prev_val = det.getDetectorLock();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("lock", {"1"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "lock 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("lock", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() == "lock 1\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("lock", {"0"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "lock 0\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setDetectorLock(prev_val[i], {i});
|
|
}
|
|
}
|
|
|
|
TEST_CASE("execcommand", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("execcommand", {"ls *.txt"}, -1, PUT));
|
|
}
|
|
|
|
TEST_CASE("framecounter", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2 || det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
auto framecounter = det.getNumberOfFramesFromStart().squash();
|
|
std::ostringstream oss;
|
|
caller.call("framecounter", {}, -1, GET, oss);
|
|
REQUIRE(oss.str() ==
|
|
"framecounter " + std::to_string(framecounter) + "\n");
|
|
REQUIRE_NOTHROW(caller.call("framecounter", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("framecounter", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("runtime", "[.cmdcall]") {
|
|
// TODO! can we test this?
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2 || det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
std::ostringstream oss;
|
|
caller.call("runtime", {}, -1, GET, oss);
|
|
// Get only
|
|
REQUIRE_THROWS(caller.call("runtime", {"2019"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("runtime", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("runtime", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("frametime", "[.cmdcall]") {
|
|
// TODO! can we test this?
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
|
det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 ||
|
|
det_type == defs::GOTTHARD2 || det_type == defs::XILINX_CHIPTESTBOARD) {
|
|
std::ostringstream oss;
|
|
caller.call("frametime", {}, -1, GET, oss);
|
|
// Get only
|
|
REQUIRE_THROWS(caller.call("frametime", {"2019"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("frametime", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("frametime", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("user", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
// caller only has help. cmdApp takes care of put and get
|
|
REQUIRE_NOTHROW(caller.call("user", {}, -1, defs::HELP_ACTION));
|
|
}
|
|
|
|
TEST_CASE("sleep", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
REQUIRE_NOTHROW(caller.call("sleep", {"1"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("sleep", {"100", "ms"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("sleep", {"1000", "ns"}, -1, PUT));
|
|
// This is a put only command
|
|
REQUIRE_THROWS(caller.call("sleep", {}, -1, GET));
|
|
}
|
|
|
|
} // namespace sls
|