mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-22 10:09:48 +01:00
10.0.0.rc (#1260)
* 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>
This commit is contained in:
@@ -13,11 +13,12 @@ target_sources(tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-jungfrau.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-mythen3.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-gotthard2.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-gotthard.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-chiptestboard.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-xilinx-chiptestboard.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-moench.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-global.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-acquire.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-master-attributes.cpp
|
||||
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-Result.cpp
|
||||
@@ -25,15 +26,27 @@ target_sources(tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-Module.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-Pattern.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CtbConfig.cpp
|
||||
|
||||
|
||||
|
||||
)
|
||||
|
||||
# HDF5 file
|
||||
if (SLS_USE_HDF5)
|
||||
target_compile_definitions(tests
|
||||
PUBLIC
|
||||
-DHDF5C ${HDF5_DEFINITIONS}
|
||||
)
|
||||
endif (SLS_USE_HDF5)
|
||||
|
||||
target_compile_options(tests
|
||||
PRIVATE
|
||||
# Suppress warnings for deprecated functions in rapidjson
|
||||
-Wno-deprecated-declarations
|
||||
)
|
||||
|
||||
target_include_directories(tests
|
||||
PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>"
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include/sls>"
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../slsReceiverSoftware/src>"
|
||||
PRIVATE
|
||||
${SLS_INTERNAL_RAPIDJSON_DIR}
|
||||
)
|
||||
280
slsDetectorSoftware/tests/Caller/test-Caller-acquire.cpp
Normal file
280
slsDetectorSoftware/tests/Caller/test-Caller-acquire.cpp
Normal file
@@ -0,0 +1,280 @@
|
||||
// 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/sls_detector_defs.h"
|
||||
#include "sls/versionAPI.h"
|
||||
#include "test-Caller-global.h"
|
||||
#include "tests/globals.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
|
||||
namespace sls {
|
||||
|
||||
using test::GET;
|
||||
using test::PUT;
|
||||
|
||||
TEST_CASE("jungfrau_or_moench_acquire_check_file_size",
|
||||
"[.cmdcall][.cmdacquire]") {
|
||||
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type =
|
||||
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
||||
|
||||
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
||||
|
||||
auto num_udp_interfaces = det.getNumberofUDPInterfaces().tsquash(
|
||||
"inconsistent number of udp interfaces");
|
||||
|
||||
int num_frames_to_acquire = 2;
|
||||
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
||||
|
||||
// check file size (assuming local pc)
|
||||
{
|
||||
detParameters par(det_type);
|
||||
int bytes_per_pixel = det.getDynamicRange().squash() / 8;
|
||||
// if 2 udp interfaces, data split into half
|
||||
size_t expected_image_size = (par.nChanX * par.nChanY * par.nChipX *
|
||||
par.nChipY * bytes_per_pixel) /
|
||||
num_udp_interfaces;
|
||||
testFileInfo test_file_info;
|
||||
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
||||
expected_image_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("eiger_acquire_check_file_size", "[.cmdcall][.cmdacquire]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type =
|
||||
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
||||
|
||||
if (det_type == defs::EIGER) {
|
||||
|
||||
int dynamic_range = det.getDynamicRange().squash();
|
||||
if (dynamic_range != 16) {
|
||||
throw RuntimeError(
|
||||
"Eiger detector must have dynamic range 16 to test");
|
||||
}
|
||||
int num_frames_to_acquire = 2;
|
||||
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
||||
|
||||
// check file size (assuming local pc)
|
||||
{
|
||||
detParameters par(det_type);
|
||||
// data split into half due to 2 udp interfaces per half module
|
||||
int num_chips = (par.nChipX / 2);
|
||||
int bytes_per_pixel = (dynamic_range / 8);
|
||||
size_t expected_image_size =
|
||||
par.nChanX * par.nChanY * num_chips * bytes_per_pixel;
|
||||
testFileInfo test_file_info;
|
||||
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
||||
expected_image_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("mythen3_acquire_check_file_size", "[.cmdcall][.cmdacquire]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type =
|
||||
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
||||
|
||||
if (det_type == defs::MYTHEN3) {
|
||||
|
||||
int dynamic_range = det.getDynamicRange().squash();
|
||||
int counter_mask = det.getCounterMask().squash();
|
||||
if (dynamic_range != 16 && counter_mask != 0x3) {
|
||||
throw RuntimeError("Mythen3 detector must have dynamic range 16 "
|
||||
"and counter mask 0x3 to test");
|
||||
}
|
||||
int num_counters = __builtin_popcount(counter_mask);
|
||||
int num_frames_to_acquire = 2;
|
||||
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
||||
|
||||
// check file size (assuming local pc)
|
||||
{
|
||||
detParameters par(det_type);
|
||||
int bytes_per_pixel = dynamic_range / 8;
|
||||
int num_channels_per_counter = par.nChanX / 3;
|
||||
size_t expected_image_size = num_channels_per_counter *
|
||||
num_counters * par.nChipX *
|
||||
bytes_per_pixel;
|
||||
testFileInfo test_file_info;
|
||||
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
||||
expected_image_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("gotthard2_acquire_check_file_size", "[.cmdcall][.cmdacquire]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type =
|
||||
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
||||
|
||||
if (det_type == defs::GOTTHARD2) {
|
||||
|
||||
int num_frames_to_acquire = 2;
|
||||
create_files_for_acquire(det, caller, num_frames_to_acquire);
|
||||
|
||||
// check file size (assuming local pc)
|
||||
{
|
||||
detParameters par(det_type);
|
||||
int bytes_per_pixel = det.getDynamicRange().squash() / 8;
|
||||
size_t expected_image_size =
|
||||
par.nChanX * par.nChipX * bytes_per_pixel;
|
||||
testFileInfo test_file_info;
|
||||
test_acquire_binary_file_size(test_file_info, num_frames_to_acquire,
|
||||
expected_image_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_ctb_file_size_with_acquire(Detector &det, Caller &caller,
|
||||
int64_t num_frames,
|
||||
const testCtbAcquireInfo &test_info,
|
||||
bool isXilinxCtb) {
|
||||
|
||||
create_files_for_acquire(det, caller, num_frames, test_info);
|
||||
|
||||
// check file size (assuming local pc)
|
||||
uint64_t expected_image_size =
|
||||
calculate_ctb_image_size(test_info, isXilinxCtb).first;
|
||||
testFileInfo test_file_info;
|
||||
REQUIRE_NOTHROW(test_acquire_binary_file_size(test_file_info, num_frames,
|
||||
expected_image_size));
|
||||
}
|
||||
|
||||
TEST_CASE("ctb_acquire_check_file_size", "[.cmdcall][.cmdacquire]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type =
|
||||
det.getDetectorType().tsquash("Inconsistent detector types to test");
|
||||
|
||||
if (det_type == defs::CHIPTESTBOARD ||
|
||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||
bool isXilinxCtb = (det_type == defs::XILINX_CHIPTESTBOARD);
|
||||
int num_frames_to_acquire = 2;
|
||||
// all the test cases
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::ANALOG_AND_DIGITAL;
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::ANALOG_AND_DIGITAL;
|
||||
test_ctb_config.dbit_offset = 16;
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::ANALOG_AND_DIGITAL;
|
||||
test_ctb_config.dbit_reorder = true;
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::ANALOG_AND_DIGITAL;
|
||||
test_ctb_config.dbit_offset = 16;
|
||||
test_ctb_config.dbit_reorder = true;
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::ANALOG_AND_DIGITAL;
|
||||
test_ctb_config.dbit_offset = 16;
|
||||
test_ctb_config.dbit_list.clear();
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::ANALOG_AND_DIGITAL;
|
||||
test_ctb_config.dbit_offset = 16;
|
||||
test_ctb_config.dbit_list.clear();
|
||||
test_ctb_config.dbit_reorder = true;
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::DIGITAL_AND_TRANSCEIVER;
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::DIGITAL_AND_TRANSCEIVER;
|
||||
test_ctb_config.dbit_offset = 16;
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::DIGITAL_AND_TRANSCEIVER;
|
||||
test_ctb_config.dbit_list.clear();
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::DIGITAL_AND_TRANSCEIVER;
|
||||
test_ctb_config.dbit_offset = 16;
|
||||
test_ctb_config.dbit_list.clear();
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::DIGITAL_AND_TRANSCEIVER;
|
||||
test_ctb_config.dbit_offset = 16;
|
||||
test_ctb_config.dbit_list.clear();
|
||||
test_ctb_config.dbit_reorder = true;
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::TRANSCEIVER_ONLY;
|
||||
test_ctb_config.dbit_offset = 16;
|
||||
test_ctb_config.dbit_list.clear();
|
||||
test_ctb_config.dbit_reorder = true;
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
{
|
||||
testCtbAcquireInfo test_ctb_config{};
|
||||
test_ctb_config.readout_mode = defs::ANALOG_ONLY;
|
||||
test_ctb_config.dbit_offset = 16;
|
||||
test_ctb_config.dbit_list.clear();
|
||||
test_ctb_config.dbit_reorder = true;
|
||||
REQUIRE_NOTHROW(test_ctb_file_size_with_acquire(
|
||||
det, caller, num_frames_to_acquire, test_ctb_config,
|
||||
isXilinxCtb));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
@@ -530,15 +530,6 @@ TEST_CASE("dac", "[.cmdcall][.dacs]") {
|
||||
REQUIRE_THROWS(caller.call("dac", {"vb_ds"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vref_ds"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vref_comp"}, -1, GET));
|
||||
// gotthard
|
||||
REQUIRE_THROWS(caller.call("dac", {"vref_ds"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcascn_pb"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcascp_pb"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vout_cm"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcasc_out"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vin_cm"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vref_comp"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"ib_test_c"}, -1, GET));
|
||||
// mythen3
|
||||
REQUIRE_THROWS(caller.call("dac", {"vrpreamp"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vrshaper"}, -1, GET));
|
||||
@@ -1009,7 +1000,7 @@ TEST_CASE("dbitclk", "[.cmdcall]") {
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
|
||||
if (det_type == defs::CHIPTESTBOARD) {
|
||||
auto prev_val = det.getRUNClock();
|
||||
auto prev_val = det.getDBITClock();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("dbitclk", {"20"}, -1, PUT, oss);
|
||||
@@ -1026,7 +1017,7 @@ TEST_CASE("dbitclk", "[.cmdcall]") {
|
||||
REQUIRE(oss.str() == "dbitclk 10\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRUNClock(prev_val[i], {i});
|
||||
det.setDBITClock(prev_val[i], {i});
|
||||
}
|
||||
} else {
|
||||
// clock index might work
|
||||
|
||||
@@ -185,15 +185,6 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmdcall][.dacs]") {
|
||||
det.setDAC(defs::VCP, vcp[i], false, {i});
|
||||
}
|
||||
}
|
||||
// gotthard
|
||||
REQUIRE_THROWS(caller.call("vref_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vcascn_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vcascp_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vout_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vcasc_out", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vin_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vref_comp", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("ib_test_c", {}, -1, GET));
|
||||
// mythen3
|
||||
// REQUIRE_THROWS(caller.call("vrpreamp", {}, -1, GET));
|
||||
// REQUIRE_THROWS(caller.call("vrshaper", {}, -1, GET));
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "test-Caller-global.h"
|
||||
#include "Caller.h"
|
||||
#include "GeneralData.h"
|
||||
#include "catch.hpp"
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/logger.h"
|
||||
#include "tests/globals.h"
|
||||
|
||||
namespace sls {
|
||||
@@ -88,4 +90,187 @@ void test_onchip_dac_caller(defs::dacIndex index, const std::string &dacname,
|
||||
}
|
||||
}
|
||||
|
||||
testFileInfo get_file_state(const Detector &det) {
|
||||
return testFileInfo{
|
||||
det.getFilePath().tsquash("Inconsistent file path"),
|
||||
det.getFileNamePrefix().tsquash("Inconsistent file prefix"),
|
||||
det.getAcquisitionIndex().tsquash(
|
||||
"Inconsistent file acquisition index"),
|
||||
det.getFileWrite().tsquash("Inconsistent file write state"),
|
||||
det.getFileOverWrite().tsquash("Inconsistent file overwrite state"),
|
||||
det.getFileFormat().tsquash("Inconsistent file format")};
|
||||
}
|
||||
|
||||
void set_file_state(Detector &det, const testFileInfo &file_info) {
|
||||
if (!file_info.file_path.empty())
|
||||
det.setFilePath(file_info.file_path);
|
||||
det.setFileNamePrefix(file_info.file_prefix);
|
||||
det.setAcquisitionIndex(file_info.file_acq_index);
|
||||
det.setFileWrite(file_info.file_write);
|
||||
det.setFileOverWrite(file_info.file_overwrite);
|
||||
det.setFileFormat(file_info.file_format);
|
||||
}
|
||||
|
||||
void test_acquire_binary_file_size(const testFileInfo &file_info,
|
||||
uint64_t num_frames_to_acquire,
|
||||
uint64_t expected_image_size) {
|
||||
assert(file_info.file_format == defs::BINARY);
|
||||
std::string fname = file_info.file_path + "/" + file_info.file_prefix +
|
||||
"_d0_f0_" + std::to_string(file_info.file_acq_index) +
|
||||
".raw";
|
||||
uint64_t expected_file_size =
|
||||
num_frames_to_acquire *
|
||||
(expected_image_size + sizeof(defs::sls_receiver_header));
|
||||
auto actual_file_size = std::filesystem::file_size(fname);
|
||||
REQUIRE(actual_file_size == expected_file_size);
|
||||
}
|
||||
|
||||
void test_frames_caught(const Detector &det, int num_frames_to_acquire) {
|
||||
auto frames_caught = det.getFramesCaught().tsquash(
|
||||
"Inconsistent number of frames caught")[0];
|
||||
REQUIRE(frames_caught == num_frames_to_acquire);
|
||||
}
|
||||
|
||||
void test_acquire_with_receiver(Caller &caller, const Detector &det) {
|
||||
REQUIRE_NOTHROW(caller.call("rx_start", {}, -1, PUT));
|
||||
REQUIRE_NOTHROW(caller.call("start", {}, -1, PUT));
|
||||
bool idle = false;
|
||||
while (!idle) {
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(caller.call("status", {}, -1, GET));
|
||||
auto statusList = det.getDetectorStatus();
|
||||
if (statusList.any(defs::ERROR)) {
|
||||
throw std::runtime_error("error status while acquiring");
|
||||
}
|
||||
if (statusList.contains_only(defs::IDLE, defs::STOPPED)) {
|
||||
idle = true;
|
||||
}
|
||||
}
|
||||
REQUIRE_NOTHROW(caller.call("rx_stop", {}, -1, PUT));
|
||||
}
|
||||
|
||||
void create_files_for_acquire(
|
||||
Detector &det, Caller &caller, int64_t num_frames,
|
||||
const std::optional<testCtbAcquireInfo> &test_info) {
|
||||
|
||||
// save previous state
|
||||
testFileInfo prev_file_info = get_file_state(det);
|
||||
auto prev_num_frames = det.getNumberOfFrames().tsquash(
|
||||
"Inconsistent number of frames to acquire");
|
||||
std::optional<testCtbAcquireInfo> prev_ctb_config_info{};
|
||||
if (test_info) {
|
||||
prev_ctb_config_info = get_ctb_config_state(det);
|
||||
}
|
||||
|
||||
// set state for acquire
|
||||
testFileInfo test_file_info;
|
||||
set_file_state(det, test_file_info);
|
||||
det.setNumberOfFrames(num_frames);
|
||||
if (test_info) {
|
||||
set_ctb_config_state(det, *test_info);
|
||||
}
|
||||
|
||||
// acquire and get num frames caught
|
||||
REQUIRE_NOTHROW(test_acquire_with_receiver(caller, det));
|
||||
auto frames_caught = det.getFramesCaught().tsquash(
|
||||
"Inconsistent number of frames caught")[0];
|
||||
REQUIRE(frames_caught == num_frames);
|
||||
|
||||
// hdf5
|
||||
#ifdef HDF5C
|
||||
test_file_info.file_format = defs::HDF5;
|
||||
test_file_info.file_acq_index = 0;
|
||||
set_file_state(det, test_file_info);
|
||||
|
||||
// acquire and get num frames caught
|
||||
test_acquire_with_receiver(caller, det);
|
||||
frames_caught = det.getFramesCaught().tsquash(
|
||||
"Inconsistent number of frames caught")[0];
|
||||
REQUIRE(frames_caught == num_frames);
|
||||
#endif
|
||||
|
||||
// restore previous state
|
||||
// file
|
||||
set_file_state(det, prev_file_info);
|
||||
det.setNumberOfFrames(prev_num_frames);
|
||||
if (test_info) {
|
||||
set_ctb_config_state(det, *prev_ctb_config_info);
|
||||
}
|
||||
}
|
||||
|
||||
testCtbAcquireInfo get_ctb_config_state(const Detector &det) {
|
||||
testCtbAcquireInfo ctb_config_info{
|
||||
det.getReadoutMode().tsquash("inconsistent readout mode to test"),
|
||||
true,
|
||||
det.getNumberOfAnalogSamples().tsquash(
|
||||
"inconsistent number of analog samples to test"),
|
||||
det.getNumberOfDigitalSamples().tsquash(
|
||||
"inconsistent number of digital samples to test"),
|
||||
det.getNumberOfTransceiverSamples().tsquash(
|
||||
"inconsistent number of transceiver samples to test"),
|
||||
0,
|
||||
det.getTenGigaADCEnableMask().tsquash(
|
||||
"inconsistent ten giga adc enable mask to test"),
|
||||
det.getRxDbitOffset().tsquash("inconsistent rx dbit offset to test"),
|
||||
det.getRxDbitList().tsquash("inconsistent rx dbit list to test"),
|
||||
det.getRxDbitReorder().tsquash("inconsistent rx dbit reorder to test"),
|
||||
det.getTransceiverEnableMask().tsquash(
|
||||
"inconsistent transceiver mask to test")};
|
||||
|
||||
if (det.getDetectorType().tsquash("inconsistent detector type to test") ==
|
||||
slsDetectorDefs::CHIPTESTBOARD) {
|
||||
ctb_config_info.ten_giga =
|
||||
det.getTenGiga().tsquash("inconsistent ten giga enable to test");
|
||||
ctb_config_info.adc_enable_1g = det.getADCEnableMask().tsquash(
|
||||
"inconsistent adc enable mask to test");
|
||||
}
|
||||
return ctb_config_info;
|
||||
}
|
||||
|
||||
void set_ctb_config_state(Detector &det,
|
||||
const testCtbAcquireInfo &ctb_config_info) {
|
||||
det.setReadoutMode(ctb_config_info.readout_mode);
|
||||
if (det.getDetectorType().tsquash("inconsistent detector type to test") ==
|
||||
slsDetectorDefs::CHIPTESTBOARD) {
|
||||
det.setTenGiga(ctb_config_info.ten_giga);
|
||||
det.setADCEnableMask(ctb_config_info.adc_enable_1g);
|
||||
}
|
||||
det.setNumberOfAnalogSamples(ctb_config_info.num_adc_samples);
|
||||
det.setNumberOfDigitalSamples(ctb_config_info.num_dbit_samples);
|
||||
det.setNumberOfTransceiverSamples(ctb_config_info.num_trans_samples);
|
||||
det.setTenGigaADCEnableMask(ctb_config_info.adc_enable_10g);
|
||||
det.setRxDbitOffset(ctb_config_info.dbit_offset);
|
||||
det.setRxDbitList(ctb_config_info.dbit_list);
|
||||
det.setRxDbitReorder(ctb_config_info.dbit_reorder);
|
||||
det.setTransceiverEnableMask(ctb_config_info.transceiver_mask);
|
||||
}
|
||||
|
||||
std::pair<uint64_t, int>
|
||||
calculate_ctb_image_size(const testCtbAcquireInfo &test_info,
|
||||
bool isXilinxCtb) {
|
||||
|
||||
// test_info.print(); // for debugging
|
||||
sls::CtbImageInputs inputs{};
|
||||
inputs.mode = test_info.readout_mode;
|
||||
inputs.nAnalogSamples = test_info.num_adc_samples;
|
||||
inputs.adcMask = test_info.adc_enable_10g;
|
||||
if (!isXilinxCtb && !test_info.ten_giga) {
|
||||
inputs.adcMask = test_info.adc_enable_1g;
|
||||
}
|
||||
inputs.nTransceiverSamples = test_info.num_trans_samples;
|
||||
inputs.transceiverMask = test_info.transceiver_mask;
|
||||
inputs.nDigitalSamples = test_info.num_dbit_samples;
|
||||
inputs.dbitOffset = test_info.dbit_offset;
|
||||
inputs.dbitReorder = test_info.dbit_reorder;
|
||||
inputs.dbitList = test_info.dbit_list;
|
||||
|
||||
auto out = computeCtbImageSize(inputs);
|
||||
uint64_t image_size =
|
||||
out.nAnalogBytes + out.nDigitalBytes + out.nTransceiverBytes;
|
||||
LOG(logDEBUG1) << "Expected image size: " << image_size;
|
||||
int npixelx = out.nPixelsX;
|
||||
LOG(logDEBUG1) << "Expected number of pixels in x: " << npixelx;
|
||||
return std::make_pair(image_size, npixelx);
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
|
||||
@@ -1,9 +1,78 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include "Caller.h"
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/ToString.h"
|
||||
#include "sls/logger.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
|
||||
namespace sls {
|
||||
struct testFileInfo {
|
||||
std::string file_path{"/tmp"};
|
||||
std::string file_prefix{"sls_test"};
|
||||
int64_t file_acq_index{0};
|
||||
bool file_write{true};
|
||||
bool file_overwrite{true};
|
||||
slsDetectorDefs::fileFormat file_format{slsDetectorDefs::BINARY};
|
||||
std::string getMasterFileNamePrefix() const {
|
||||
return file_path + "/" + file_prefix + "_master_" +
|
||||
std::to_string(file_acq_index);
|
||||
}
|
||||
std::string getVirtualFileName() const {
|
||||
return file_path + "/" + file_prefix + "_virtual_" +
|
||||
std::to_string(file_acq_index) + ".h5";
|
||||
}
|
||||
inline void print() const {
|
||||
LOG(logINFO) << "File Info: "
|
||||
<< "\n\tFile Path: " << file_path
|
||||
<< "\n\tFile Prefix: " << file_prefix
|
||||
<< "\n\tFile Acquisition Index: " << file_acq_index
|
||||
<< "\n\tFile Write: " << file_write
|
||||
<< "\n\tFile Overwrite: " << file_overwrite
|
||||
<< "\n\tFile Format: " << ToString(file_format)
|
||||
<< "\n\tMaster Filename: " << getMasterFileNamePrefix()
|
||||
<< "\n\tVirtual Filename: " << getVirtualFileName();
|
||||
}
|
||||
};
|
||||
|
||||
struct testCtbAcquireInfo {
|
||||
defs::readoutMode readout_mode{defs::ANALOG_AND_DIGITAL};
|
||||
bool ten_giga{false};
|
||||
int num_adc_samples{5000};
|
||||
int num_dbit_samples{6000};
|
||||
int num_trans_samples{288};
|
||||
uint32_t adc_enable_1g{0xFFFFFF00};
|
||||
uint32_t adc_enable_10g{0xFF00FFFF};
|
||||
int dbit_offset{0};
|
||||
std::vector<int> dbit_list{0, 12, 2, 43};
|
||||
bool dbit_reorder{false};
|
||||
uint32_t transceiver_mask{0x3};
|
||||
|
||||
inline void print() const {
|
||||
LOG(logINFO) << "CTB Acquire Info: "
|
||||
<< "\n\tReadout Mode: " << ToString(readout_mode)
|
||||
<< "\n\tTen Giga: " << ten_giga
|
||||
<< "\n\tADC Enable 1G: " << std::hex << adc_enable_1g
|
||||
<< std::dec << "\n\tADC Enable 10G: " << std::hex
|
||||
<< adc_enable_10g << std::dec
|
||||
<< "\n\tNumber of Analog Samples: " << num_adc_samples
|
||||
<< "\n\tNumber of Digital Samples: " << num_dbit_samples
|
||||
<< "\n\tNumber of Transceiver Samples: "
|
||||
<< num_trans_samples << "\n\tDBIT Offset: " << dbit_offset
|
||||
<< "\n\tDBIT Reorder: " << dbit_reorder
|
||||
<< "\n\tDBIT List: " << ToString(dbit_list)
|
||||
<< "\n\tTransceiver Mask: " << std::hex << transceiver_mask
|
||||
<< std::dec << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
void test_valid_port_caller(const std::string &command,
|
||||
const std::vector<std::string> &arguments,
|
||||
int detector_id, int action);
|
||||
@@ -13,4 +82,24 @@ void test_dac_caller(slsDetectorDefs::dacIndex index,
|
||||
void test_onchip_dac_caller(slsDetectorDefs::dacIndex index,
|
||||
const std::string &dacname, int dacvalue);
|
||||
|
||||
testFileInfo get_file_state(const Detector &det);
|
||||
void set_file_state(Detector &det, const testFileInfo &file_info);
|
||||
void test_acquire_binary_file_size(const testFileInfo &file_info,
|
||||
uint64_t num_frames_to_acquire,
|
||||
uint64_t expected_image_size);
|
||||
|
||||
void test_frames_caught(const Detector &det, int num_frames_to_acquire);
|
||||
|
||||
void test_acquire_with_receiver(Caller &caller, const Detector &det);
|
||||
|
||||
void create_files_for_acquire(
|
||||
Detector &det, Caller &caller, int64_t num_frames = 1,
|
||||
const std::optional<testCtbAcquireInfo> &test_info = std::nullopt);
|
||||
|
||||
testCtbAcquireInfo get_ctb_config_state(const Detector &det);
|
||||
void set_ctb_config_state(Detector &det,
|
||||
const testCtbAcquireInfo &ctb_config_info);
|
||||
std::pair<uint64_t, int>
|
||||
calculate_ctb_image_size(const testCtbAcquireInfo &test_info, bool isXilinxCtb);
|
||||
|
||||
} // namespace sls
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
// 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/sls_detector_defs.h"
|
||||
#include <sstream>
|
||||
|
||||
#include "sls/Result.h"
|
||||
#include "sls/ToString.h"
|
||||
#include "sls/versionAPI.h"
|
||||
#include "test-Caller-global.h"
|
||||
#include "tests/globals.h"
|
||||
|
||||
namespace sls {
|
||||
|
||||
using test::GET;
|
||||
using test::PUT;
|
||||
|
||||
/* dacs */
|
||||
|
||||
TEST_CASE("Setting and reading back GOTTHARD dacs", "[.cmdcall][.dacs]") {
|
||||
// vref_ds, vcascn_pb, vcascp_pb, vout_cm, vcasc_out, vin_cm, vref_comp,
|
||||
// ib_test_c
|
||||
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::GOTTHARD) {
|
||||
SECTION("vref_ds") { test_dac_caller(defs::VREF_DS, "vref_ds", 660); }
|
||||
SECTION("vcascn_pb") {
|
||||
test_dac_caller(defs::VCASCN_PB, "vcascn_pb", 650);
|
||||
}
|
||||
SECTION("vcascp_pb") {
|
||||
test_dac_caller(defs::VCASCP_PB, "vcascp_pb", 1480);
|
||||
}
|
||||
SECTION("vout_cm") { test_dac_caller(defs::VOUT_CM, "vout_cm", 1520); }
|
||||
SECTION("vcasc_out") {
|
||||
test_dac_caller(defs::VCASC_OUT, "vcasc_out", 1320);
|
||||
}
|
||||
SECTION("vin_cm") { test_dac_caller(defs::VIN_CM, "vin_cm", 1350); }
|
||||
SECTION("vref_comp") {
|
||||
test_dac_caller(defs::VREF_COMP, "vref_comp", 350);
|
||||
}
|
||||
SECTION("ib_test_c") {
|
||||
test_dac_caller(defs::IB_TESTC, "ib_test_c", 2001);
|
||||
}
|
||||
// eiger
|
||||
REQUIRE_THROWS(caller.call("dac", {"vthreshold"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vsvp"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vsvn"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vtrim"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vrpreamp"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vrshaper"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vtgstv"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcmp_ll"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcmp_lr"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcal"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcmp_rl"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcmp_rr"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"rxb_rb"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"rxb_lb"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcp"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcn"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vishaper"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"iodelay"}, -1, GET));
|
||||
// jungfrau
|
||||
REQUIRE_THROWS(caller.call("dac", {"vb_comp"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vdd_prot"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vin_com"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vref_prech"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vb_pixbuf"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vb_ds"}, -1, GET));
|
||||
// REQUIRE_THROWS(caller.call("dac", {"vref_ds"}, -1, GET));
|
||||
// REQUIRE_THROWS(caller.call("dac", {"vref_comp"}, -1, GET));
|
||||
// mythen3
|
||||
REQUIRE_THROWS(caller.call("dac", {"vrpreamp"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vrshaper"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vrshaper_n"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vipre"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vishaper"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vdcsh"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vth1"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vth2"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vth3"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcal_n"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcal_p"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vtrim"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcassh"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcas"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vicin"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vipre_out"}, -1, GET));
|
||||
// gotthard2
|
||||
REQUIRE_THROWS(caller.call("dac", {"vref_h_adc"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vb_comp_fe"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vb_comp_adc"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcom_cds"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vref_rstore"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vb_opa_1st"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vref_comp_fe"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcom_adc1"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vref_l_adc"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vref_cds"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vb_cs"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vb_opa_fd"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("dac", {"vcom_adc2"}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
/* Gotthard Specific */
|
||||
|
||||
TEST_CASE("roi", "[.cmdcall]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
|
||||
if (det_type == defs::GOTTHARD) {
|
||||
if (det.size() > 1) {
|
||||
REQUIRE_THROWS(caller.call("roi", {"0", "255"}, -1, PUT));
|
||||
REQUIRE_NOTHROW(caller.call("roi", {}, -1, GET));
|
||||
} else {
|
||||
auto prev_val = det.getROI();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("roi", {"0", "255"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "roi [0, 255]\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("roi", {"256", "511"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "roi [256, 511]\n");
|
||||
}
|
||||
REQUIRE_THROWS(caller.call("roi", {"0", "256"}, -1, PUT));
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setROI(prev_val[i], i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(caller.call("roi", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("clearroi", "[.cmdcall]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
|
||||
if (det_type == defs::GOTTHARD) {
|
||||
auto prev_val = det.getROI();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("clearroi", {}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "clearroi successful\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setROI(prev_val[i], i);
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(caller.call("clearroi", {}, -1, PUT));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("exptimel", "[.cmdcall]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::GOTTHARD) {
|
||||
REQUIRE_NOTHROW(caller.call("exptimel", {}, -1, GET));
|
||||
} else {
|
||||
REQUIRE_THROWS(caller.call("exptimel", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
@@ -59,15 +59,6 @@ TEST_CASE("Setting and reading back Jungfrau dacs", "[.cmdcall][.dacs]") {
|
||||
REQUIRE_THROWS(caller.call("vcn", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vishaper", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("iodelay", {}, -1, GET));
|
||||
// gotthard
|
||||
// REQUIRE_THROWS(caller.call("vref_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vcascn_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vcascp_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vout_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vcasc_out", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vin_cm", {}, -1, GET));
|
||||
// REQUIRE_THROWS(caller.call("vref_comp", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("ib_test_c", {}, -1, GET));
|
||||
// mythen3
|
||||
REQUIRE_THROWS(caller.call("vrpreamp", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vrshaper", {}, -1, GET));
|
||||
|
||||
1084
slsDetectorSoftware/tests/Caller/test-Caller-master-attributes.cpp
Normal file
1084
slsDetectorSoftware/tests/Caller/test-Caller-master-attributes.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -59,15 +59,6 @@ TEST_CASE("Setting and reading back moench dacs", "[.cmdcall][.dacs]") {
|
||||
REQUIRE_THROWS(caller.call("vcn", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vishaper", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("iodelay", {}, -1, GET));
|
||||
// gotthard
|
||||
REQUIRE_THROWS(caller.call("vref_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vcascn_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vcascp_pb", {}, -1, GET));
|
||||
// REQUIRE_THROWS(caller.call("vout_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vcasc_out", {}, -1, GET));
|
||||
// REQUIRE_THROWS(caller.call("vin_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vref_comp", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("ib_test_c", {}, -1, GET));
|
||||
// mythen3
|
||||
REQUIRE_THROWS(caller.call("vrpreamp", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("vrshaper", {}, -1, GET));
|
||||
|
||||
@@ -329,7 +329,7 @@ TEST_CASE("patwaittime", "[.cmdcall]") {
|
||||
if (det_type == defs::MYTHEN3 && iLoop >= 3) {
|
||||
continue;
|
||||
}
|
||||
auto prev_val = det.getPatternWaitTime(iLoop);
|
||||
auto prev_val = det.getPatternWaitClocks(iLoop);
|
||||
std::string sLoop = ToString(iLoop);
|
||||
if (iLoop < 3) {
|
||||
std::string deprecatedCmd = "patwaittime" + sLoop;
|
||||
@@ -354,8 +354,24 @@ TEST_CASE("patwaittime", "[.cmdcall]") {
|
||||
caller.call("patwaittime", {sLoop}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "patwaittime " + sLoop + " 8589936640\n");
|
||||
}
|
||||
// time units
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("patwaittime", {sLoop, "50us"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "patwaittime " + sLoop + " 50us\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("patwaittime", {sLoop, "us"}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "patwaittime " + sLoop + " 50us\n");
|
||||
if (iLoop == 0 && det_type != defs::MYTHEN3) {
|
||||
std::ostringstream oss;
|
||||
caller.call("exptime", {"us"}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "exptime 50us\n");
|
||||
}
|
||||
}
|
||||
for (int iDet = 0; iDet != det.size(); ++iDet) {
|
||||
det.setPatternWaitTime(iLoop, prev_val[iDet], {iDet});
|
||||
det.setPatternWaitClocks(iLoop, prev_val[iDet], {iDet});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "test-Caller-global.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
|
||||
#include "sls/versionAPI.h"
|
||||
@@ -466,7 +467,6 @@ TEST_CASE("rx_arping", "[.cmdcall][.rx]") {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("rx_roi", "[.cmdcall]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
@@ -477,35 +477,103 @@ TEST_CASE("rx_roi", "[.cmdcall]") {
|
||||
} else {
|
||||
auto prev_val = det.getRxROI();
|
||||
defs::xy detsize = det.getDetectorSize();
|
||||
auto portSize = det.getPortSize()[0];
|
||||
int delta = 50;
|
||||
int numinterfaces = det.getNumberofUDPInterfaces().tsquash(
|
||||
"inconsistent number of interfaces");
|
||||
|
||||
// 1d
|
||||
if (det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2 ||
|
||||
det_type == defs::MYTHEN3) {
|
||||
if (det_type == defs::GOTTHARD2 || det_type == defs::MYTHEN3) {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_roi", {"5", "10"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_roi [5, 10]\n");
|
||||
REQUIRE(oss.str() == "rx_roi [[5, 10]]\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_roi", {"10", "15"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_roi [10, 15]\n");
|
||||
REQUIRE(oss.str() == "rx_roi [[10, 15]]\n");
|
||||
}
|
||||
REQUIRE_THROWS(caller.call("rx_roi", {"0", "0"}, -1, PUT));
|
||||
REQUIRE_THROWS(caller.call("rx_roi", {"-1", "-1"}, -1, PUT));
|
||||
REQUIRE_THROWS(
|
||||
caller.call("rx_roi", {"10", "15", "25", "30"}, -1, PUT));
|
||||
// xmin > xmax
|
||||
REQUIRE_THROWS(caller.call("rx_roi", {"[12, 8, -1, -1]"}, -1, PUT));
|
||||
// outside detector bounds
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi",
|
||||
{"[95," + std::to_string(detsize.x + 5) + ", -1, -1]"}, -1,
|
||||
PUT));
|
||||
// module level not allowed
|
||||
REQUIRE_THROWS(caller.call("rx_roi", {"[5, 10, -1, -1]"}, 0, PUT));
|
||||
|
||||
// vector of rois
|
||||
// square brackets missing
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[5, 20, -1, -1]; 25, 30, -1, -1]"}, -1, PUT));
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[5, 20, -1, -1]; [25, 30, -1, -1"}, -1, PUT));
|
||||
// invalid roi, 4 parts expected
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[5, 20, -1] [25, 30, -1, -1]"}, -1, PUT));
|
||||
// overlapping rois
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[0, 10,-1, -1] [5, 15, -1, -1]"}, -1, PUT));
|
||||
|
||||
if (det.size() == 2) {
|
||||
auto moduleSize = det.getModuleSize()[0];
|
||||
std::string stringMin = std::to_string(moduleSize.x);
|
||||
std::string stringMax = std::to_string(moduleSize.x + 1);
|
||||
|
||||
// separated by space is allowed
|
||||
REQUIRE_NOTHROW(caller.call(
|
||||
"rx_roi",
|
||||
{"[5, 10, -1, -1]",
|
||||
"[" + stringMin + ", " + stringMax + ", -1, -1]"},
|
||||
-1, PUT));
|
||||
std::ostringstream oss;
|
||||
// separated by semicolon with quotes is allowed (skips
|
||||
// cmdParser)
|
||||
REQUIRE_NOTHROW(caller.call("rx_roi",
|
||||
{"[5, 10, -1, -1];[" + stringMin +
|
||||
", " + stringMax + ", -1, -1]"},
|
||||
-1, PUT, oss));
|
||||
REQUIRE(oss.str() == "rx_roi [[5, 10], [" + stringMin + ", " +
|
||||
stringMax + "]]\n");
|
||||
|
||||
// verify individual roi
|
||||
{
|
||||
stringMin = std::to_string(moduleSize.x - 50);
|
||||
stringMax = std::to_string(moduleSize.x + 50);
|
||||
std::ostringstream oss, oss1;
|
||||
REQUIRE_NOTHROW(caller.call(
|
||||
"rx_roi", {"[" + stringMin + ", " + stringMax + "]"},
|
||||
-1, PUT, oss));
|
||||
REQUIRE(oss.str() == "rx_roi [[" + stringMin + ", " +
|
||||
stringMax + "]]\n");
|
||||
REQUIRE_NOTHROW(caller.call("rx_roi", {}, 0, GET, oss1));
|
||||
REQUIRE(oss1.str() == "rx_roi [[" + stringMin + ", " +
|
||||
std::to_string(moduleSize.x - 1) +
|
||||
"]]\n");
|
||||
}
|
||||
}
|
||||
// valid roi before acquiring
|
||||
else {
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_roi", {"10", "15"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_roi [[10, 15]]\n");
|
||||
}
|
||||
}
|
||||
// 2d
|
||||
// 2d eiger, jungfrau, moench
|
||||
else {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_roi", {"10", "15", "1", "5"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_roi [10, 15, 1, 5]\n");
|
||||
REQUIRE(oss.str() == "rx_roi [[10, 15, 1, 5]]\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_roi", {"10", "22", "18", "19"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_roi [10, 22, 18, 19]\n");
|
||||
REQUIRE(oss.str() == "rx_roi [[10, 22, 18, 19]]\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@@ -513,18 +581,203 @@ TEST_CASE("rx_roi", "[.cmdcall]") {
|
||||
{"1", std::to_string(detsize.x - 5), "1",
|
||||
std::to_string(detsize.y - 5)},
|
||||
-1, PUT, oss);
|
||||
REQUIRE(oss.str() == std::string("rx_roi [1, ") +
|
||||
REQUIRE(oss.str() == std::string("rx_roi [[1, ") +
|
||||
std::to_string(detsize.x - 5) +
|
||||
std::string(", 1, ") +
|
||||
std::to_string(detsize.y - 5) +
|
||||
std::string("]\n"));
|
||||
std::string("]]\n"));
|
||||
}
|
||||
REQUIRE_THROWS(
|
||||
caller.call("rx_roi", {"0", "0", "0", "0"}, -1, PUT));
|
||||
REQUIRE_THROWS(
|
||||
caller.call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT));
|
||||
// xmin > xmax
|
||||
REQUIRE_THROWS(caller.call("rx_roi", {"[12, 8, 0, 10]"}, -1, PUT));
|
||||
// ymin > ymax
|
||||
REQUIRE_THROWS(caller.call("rx_roi", {"[0, 10, 20, 5]"}, -1, PUT));
|
||||
// outside detector bounds
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[95," + std::to_string(detsize.x + 5) + ", 0, 10]"},
|
||||
-1, PUT));
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi",
|
||||
{"[95, 100, 0, " + std::to_string(detsize.y + 5) + "]"}, -1,
|
||||
PUT));
|
||||
// module level not allowed
|
||||
REQUIRE_THROWS(caller.call("rx_roi", {"[5, 10, 20, 30]"}, 0, PUT));
|
||||
|
||||
// vector of rois
|
||||
// square brackets missing
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[5, 20, 20, 30]; 25, 30, 14, 15]"}, -1, PUT));
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[5, 20, 20, 30]; [25, 30, 14, 15"}, -1, PUT));
|
||||
// invalid roi, 4 parts expected
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[5, 20, 20] [25, 30, 14, 15]"}, -1, PUT));
|
||||
// overlapping rois
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[0, 10, 0, 10] [5, 15, 0, 10]"}, -1, PUT));
|
||||
REQUIRE_THROWS(caller.call(
|
||||
"rx_roi", {"[0, 10, 0, 10] [0, 10, 9, 11]"}, -1, PUT));
|
||||
|
||||
// multiple ports horizontally
|
||||
if (det_type == defs::EIGER ||
|
||||
(det.size() == 2 && det.getModuleGeometry().x > 1)) {
|
||||
std::string stringMin = std::to_string(portSize.x);
|
||||
std::string stringMax = std::to_string(portSize.x + 1);
|
||||
|
||||
// separated by space is allowed
|
||||
REQUIRE_NOTHROW(caller.call(
|
||||
"rx_roi",
|
||||
{"[5, 10, 20, 30]",
|
||||
"[" + stringMin + ", " + stringMax + ", 20, 30]"},
|
||||
-1, PUT));
|
||||
std::ostringstream oss;
|
||||
// separated by semicolon with quotes is allowed (skips
|
||||
// cmdParser)
|
||||
REQUIRE_NOTHROW(caller.call("rx_roi",
|
||||
{"[5, 10, 20, 30];[" + stringMin +
|
||||
", " + stringMax + ", 20, 30]"},
|
||||
-1, PUT, oss));
|
||||
REQUIRE(oss.str() == "rx_roi [[5, 10, 20, 30], [" + stringMin +
|
||||
", " + stringMax + ", 20, 30]]\n");
|
||||
|
||||
// verify individual roi
|
||||
{
|
||||
stringMin = std::to_string(portSize.x - delta);
|
||||
stringMax = std::to_string(portSize.x + delta);
|
||||
std::ostringstream oss, oss1;
|
||||
REQUIRE_NOTHROW(caller.call(
|
||||
"rx_roi",
|
||||
{"[" + stringMin + ", " + stringMax + ", 20, 30]"}, -1,
|
||||
PUT, oss));
|
||||
REQUIRE(oss.str() == "rx_roi [[" + stringMin + ", " +
|
||||
stringMax + ", 20, 30]]\n");
|
||||
REQUIRE_NOTHROW(caller.call("rx_roi", {}, 0, GET, oss1));
|
||||
// eiger returns 2 values for 2 ports per module
|
||||
if (det_type == defs::EIGER) {
|
||||
REQUIRE(oss1.str() ==
|
||||
"rx_roi [[" + stringMin + ", " +
|
||||
std::to_string(portSize.x - 1) +
|
||||
", 20, 30], [0, " + std::to_string(delta) +
|
||||
", 20, 30]]\n");
|
||||
}
|
||||
// others return only 1 roi per module (1 port per module)
|
||||
else {
|
||||
REQUIRE(oss1.str() ==
|
||||
"rx_roi [[" + stringMin + ", " +
|
||||
std::to_string(portSize.x - 1) +
|
||||
", 20, 30]]\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
// valid roi before acquiring
|
||||
else {
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_roi",
|
||||
{"1", std::to_string(detsize.x - 5), "1",
|
||||
std::to_string(detsize.y - 5)},
|
||||
-1, PUT, oss);
|
||||
REQUIRE(oss.str() == std::string("rx_roi [[1, ") +
|
||||
std::to_string(detsize.x - 5) +
|
||||
std::string(", 1, ") +
|
||||
std::to_string(detsize.y - 5) +
|
||||
std::string("]]\n"));
|
||||
}
|
||||
|
||||
// multiple ports vertically
|
||||
if (((det_type == defs::JUNGFRAU || det_type == defs::MOENCH) &&
|
||||
(numinterfaces == 2)) ||
|
||||
(det.size() == 2 && det.getModuleGeometry().y > 1)) {
|
||||
std::string stringMin = std::to_string(portSize.y);
|
||||
std::string stringMax = std::to_string(portSize.y + 1);
|
||||
|
||||
// separated by space is allowed
|
||||
REQUIRE_NOTHROW(
|
||||
caller.call("rx_roi",
|
||||
{"[5, 10, 20, 30]", "[25, 28, " + stringMin +
|
||||
", " + stringMax + "]"},
|
||||
-1, PUT));
|
||||
std::ostringstream oss;
|
||||
// separated by semicolon is allowed with quotes (skips
|
||||
// cmdParser)
|
||||
REQUIRE_NOTHROW(
|
||||
caller.call("rx_roi",
|
||||
{"[5, 10, 20, 30];[25, 28, " + stringMin +
|
||||
", " + stringMax + "]"},
|
||||
-1, PUT, oss));
|
||||
REQUIRE(oss.str() == "rx_roi [[5, 10, 20, 30], [25, 28, " +
|
||||
stringMin + ", " + stringMax + "]]\n");
|
||||
|
||||
// verify individual roi
|
||||
{
|
||||
stringMin = std::to_string(portSize.y - delta);
|
||||
stringMax = std::to_string(portSize.y + delta);
|
||||
std::ostringstream oss, oss1;
|
||||
REQUIRE_NOTHROW(caller.call(
|
||||
"rx_roi",
|
||||
{"[ 20, 30, " + stringMin + ", " + stringMax + "]"}, -1,
|
||||
PUT, oss));
|
||||
REQUIRE(oss.str() == "rx_roi [[20, 30, " + stringMin +
|
||||
", " + stringMax + "]]\n");
|
||||
REQUIRE_NOTHROW(caller.call("rx_roi", {}, 0, GET, oss1));
|
||||
|
||||
// non-eiger with 2 interfaces returns 2 values for 2 ports
|
||||
// per module
|
||||
if ((det_type == defs::JUNGFRAU ||
|
||||
det_type == defs::MOENCH) &&
|
||||
(numinterfaces == 2)) {
|
||||
REQUIRE(oss1.str() ==
|
||||
"rx_roi [[20, 30, " + stringMin + ", " +
|
||||
std::to_string(portSize.y - 1) +
|
||||
"], [20, 30, 0, " + std::to_string(delta) +
|
||||
"]]\n");
|
||||
}
|
||||
// others return only 1 roi per module (1 port per module)
|
||||
else {
|
||||
// (eiger 2 ports)
|
||||
if (det_type == defs::EIGER) {
|
||||
REQUIRE(oss1.str() ==
|
||||
"rx_roi [[20, 30, " + stringMin + ", " +
|
||||
std::to_string(portSize.y - 1) +
|
||||
"], [-1, -1]]\n");
|
||||
} else {
|
||||
REQUIRE(oss1.str() ==
|
||||
"rx_roi [[20, 30, " + stringMin + ", " +
|
||||
std::to_string(portSize.y - 1) +
|
||||
"]]\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check master file creation
|
||||
// TODO: check roi in master file
|
||||
{
|
||||
REQUIRE_NOTHROW(create_files_for_acquire(det, caller));
|
||||
testFileInfo file_info;
|
||||
std::string master_file_prefix =
|
||||
file_info.getMasterFileNamePrefix();
|
||||
|
||||
std::string fname = master_file_prefix + ".json";
|
||||
REQUIRE(std::filesystem::exists(fname) == true);
|
||||
#ifdef HDF5C
|
||||
fname = master_file_prefix + ".h5";
|
||||
REQUIRE(std::filesystem::exists(fname) == true);
|
||||
if (det.size() > 1 || numinterfaces > 1) {
|
||||
fname = file_info.getVirtualFileName();
|
||||
REQUIRE(std::filesystem::exists(fname) == true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxROI(prev_val);
|
||||
if (prev_val.size() == 1 && prev_val[0].completeRoi()) {
|
||||
det.clearRxROI();
|
||||
} else
|
||||
det.setRxROI(prev_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,7 +797,11 @@ TEST_CASE("rx_clearroi", "[.cmdcall]") {
|
||||
REQUIRE(oss.str() == "rx_clearroi successful\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxROI(prev_val);
|
||||
if (prev_val.size() == 1 && prev_val[0].completeRoi()) {
|
||||
det.clearRxROI();
|
||||
} else {
|
||||
det.setRxROI(prev_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -585,6 +842,9 @@ TEST_CASE("fpath", "[.cmdcall]") {
|
||||
REQUIRE(oss.str() == "fpath /tmp\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
if (prev_val[i].empty()) {
|
||||
continue;
|
||||
}
|
||||
det.setFilePath(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
@@ -958,6 +1218,37 @@ TEST_CASE("rx_dbitoffset", "[.cmdcall][.rx]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("rx_dbitreorder", "[.cmdcall][.rx]") {
|
||||
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.getRxDbitReorder();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_dbitreorder", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_dbitreorder 0\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_dbitreorder", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_dbitreorder 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_dbitreorder", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_dbitreorder 1\n");
|
||||
}
|
||||
REQUIRE_THROWS(caller.call("rx_dbitreorder", {"15"}, -1, PUT));
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxDbitReorder(prev_val[i], {i});
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(caller.call("rx_dbitreorder", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("rx_jsonaddheader", "[.cmdcall][.rx]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include <variant>
|
||||
|
||||
#include "tests/globals.h"
|
||||
#include <filesystem>
|
||||
|
||||
namespace sls {
|
||||
|
||||
@@ -232,13 +234,6 @@ TEST_CASE("settings", "[.cmdcall]") {
|
||||
sett.push_back("g4_hg");
|
||||
sett.push_back("g4_lg");
|
||||
break;
|
||||
case defs::GOTTHARD:
|
||||
sett.push_back("highgain");
|
||||
sett.push_back("dynamicgain");
|
||||
sett.push_back("lowgain");
|
||||
sett.push_back("mediumgain");
|
||||
sett.push_back("veryhighgain");
|
||||
break;
|
||||
case defs::GOTTHARD2:
|
||||
sett.push_back("dynamicgain");
|
||||
sett.push_back("fixgain1");
|
||||
@@ -613,8 +608,8 @@ TEST_CASE("master", "[.cmdcall]") {
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
||||
det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2 ||
|
||||
det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
||||
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) {
|
||||
@@ -825,7 +820,7 @@ TEST_CASE("exptime", "[.cmdcall][.time]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
std::chrono::nanoseconds prev_val;
|
||||
ns prev_val;
|
||||
if (det_type != defs::MYTHEN3) {
|
||||
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
|
||||
} else {
|
||||
@@ -902,9 +897,6 @@ TEST_CASE("delay", "[.cmdcall]") {
|
||||
if (det_type == defs::EIGER) {
|
||||
REQUIRE_THROWS(caller.call("delay", {"1"}, -1, PUT));
|
||||
REQUIRE_THROWS(caller.call("delay", {}, -1, GET));
|
||||
} else if (det_type == defs::GOTTHARD) {
|
||||
// extra delays for master (can throw when setting)
|
||||
REQUIRE_NOTHROW(caller.call("delay", {}, -1, GET));
|
||||
} else {
|
||||
auto prev_val = det.getDelayAfterTrigger();
|
||||
{
|
||||
@@ -1204,34 +1196,25 @@ TEST_CASE("adcphase", "[.cmdcall]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::GOTTHARD || det_type == defs::JUNGFRAU ||
|
||||
det_type == defs::MOENCH || det_type == defs::CHIPTESTBOARD) {
|
||||
if (det_type == defs::GOTTHARD) {
|
||||
std::ostringstream oss1;
|
||||
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");
|
||||
// cant get, cant use deg
|
||||
REQUIRE_THROWS(caller.call("adcphase", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("adcphase", {"20", "deg"}, -1, PUT));
|
||||
} else {
|
||||
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});
|
||||
}
|
||||
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));
|
||||
@@ -1376,6 +1359,22 @@ TEST_CASE("clkdiv", "[.cmdcall]") {
|
||||
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);
|
||||
@@ -1386,6 +1385,19 @@ TEST_CASE("clkdiv", "[.cmdcall]") {
|
||||
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));
|
||||
@@ -1426,27 +1438,9 @@ TEST_CASE("highvoltage", "[.cmdcall]") {
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type != defs::XILINX_CHIPTESTBOARD) {
|
||||
auto prev_val = det.getHighVoltage();
|
||||
// selected values
|
||||
if (det_type == defs::GOTTHARD) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
// range 0, 60 - 200
|
||||
else if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH ||
|
||||
det_type == defs::CHIPTESTBOARD) {
|
||||
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;
|
||||
@@ -1580,27 +1574,8 @@ TEST_CASE("imagetest", "[.cmdcall]") {
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
// cannot test only for virtual eiger/jungfrau
|
||||
if (det_type == defs::GOTTHARD) {
|
||||
auto prev_val = det.getImageTestMode();
|
||||
{
|
||||
std::ostringstream oss1, oss2;
|
||||
caller.call("imagetest", {"1"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "imagetest 1\n");
|
||||
caller.call("imagetest", {}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "imagetest 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss1, oss2;
|
||||
caller.call("imagetest", {"0"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "imagetest 0\n");
|
||||
caller.call("imagetest", {}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "imagetest 0\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setImageTestMode(prev_val[i], {i});
|
||||
}
|
||||
} else if (det_type != defs::JUNGFRAU && det_type != defs::MOENCH &&
|
||||
det_type != defs::EIGER) {
|
||||
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));
|
||||
}
|
||||
@@ -1610,32 +1585,7 @@ TEST_CASE("extsig", "[.cmdcall]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::GOTTHARD) {
|
||||
auto prev_val = det.getExternalSignalFlags(0);
|
||||
REQUIRE_THROWS(caller.call("extsig", {}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("extsig", {"1"}, -1, GET));
|
||||
REQUIRE_THROWS(caller.call("extsig", {"0", "inversion_on"}, -1, PUT));
|
||||
REQUIRE_THROWS(caller.call("extsig", {"0", "inversion_off"}, -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");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setExternalSignalFlags(0, prev_val[i], {i});
|
||||
}
|
||||
} else if (det_type == defs::MYTHEN3) {
|
||||
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));
|
||||
@@ -2022,8 +1972,7 @@ 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 ||
|
||||
det_type == defs::GOTTHARD) {
|
||||
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));
|
||||
@@ -2280,7 +2229,7 @@ TEST_CASE("start", "[.cmdcall]") {
|
||||
// PUT only command
|
||||
REQUIRE_THROWS(caller.call("start", {}, -1, GET));
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
std::chrono::nanoseconds prev_val;
|
||||
ns prev_val;
|
||||
if (det_type != defs::MYTHEN3) {
|
||||
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
|
||||
} else {
|
||||
@@ -2319,7 +2268,7 @@ TEST_CASE("stop", "[.cmdcall]") {
|
||||
// PUT only command
|
||||
REQUIRE_THROWS(caller.call("stop", {}, -1, GET));
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
std::chrono::nanoseconds prev_val;
|
||||
ns prev_val;
|
||||
if (det_type != defs::MYTHEN3) {
|
||||
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
|
||||
} else {
|
||||
@@ -2362,7 +2311,7 @@ TEST_CASE("status", "[.cmdcall]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
std::chrono::nanoseconds prev_val;
|
||||
ns prev_val;
|
||||
if (det_type != defs::MYTHEN3) {
|
||||
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
|
||||
} else {
|
||||
@@ -2518,7 +2467,7 @@ TEST_CASE("scan", "[.cmdcall]") {
|
||||
break;
|
||||
case defs::EIGER:
|
||||
ind = defs::VCMP_LL;
|
||||
notImplementedInd = defs::VCASCP_PB;
|
||||
notImplementedInd = defs::VIN_COM;
|
||||
break;
|
||||
case defs::JUNGFRAU:
|
||||
ind = defs::VB_COMP;
|
||||
@@ -2528,10 +2477,6 @@ TEST_CASE("scan", "[.cmdcall]") {
|
||||
ind = defs::VIN_CM;
|
||||
notImplementedInd = defs::VSVP;
|
||||
break;
|
||||
case defs::GOTTHARD:
|
||||
ind = defs::VREF_DS;
|
||||
notImplementedInd = defs::VSVP;
|
||||
break;
|
||||
case defs::GOTTHARD2:
|
||||
ind = defs::VB_COMP_FE;
|
||||
notImplementedInd = defs::VSVP;
|
||||
@@ -2650,6 +2595,12 @@ TEST_CASE("numinterfaces", "[.cmdcall]") {
|
||||
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);
|
||||
@@ -2665,6 +2616,10 @@ TEST_CASE("numinterfaces", "[.cmdcall]") {
|
||||
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));
|
||||
@@ -3284,8 +3239,7 @@ TEST_CASE("rebootcontroller", "[.cmdcall]") {
|
||||
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::GOTTHARD ||
|
||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||
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));
|
||||
@@ -3357,10 +3311,13 @@ TEST_CASE("adcreg", "[.cmdcall]") {
|
||||
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::GOTTHARD) {
|
||||
std::ostringstream oss;
|
||||
caller.call("adcreg", {"0x8", "0x3"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "adcreg [0x8, 0x3]\n");
|
||||
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 {
|
||||
@@ -3464,9 +3421,8 @@ TEST_CASE("firmwaretest", "[.cmdcall]") {
|
||||
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::GOTTHARD ||
|
||||
det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2 ||
|
||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||
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");
|
||||
@@ -3482,8 +3438,8 @@ TEST_CASE("bustest", "[.cmdcall]") {
|
||||
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::GOTTHARD ||
|
||||
det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
|
||||
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");
|
||||
@@ -3679,11 +3635,8 @@ TEST_CASE("frametime", "[.cmdcall]") {
|
||||
TEST_CASE("user", "[.cmdcall]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
caller.call("user", {}, -1, GET);
|
||||
|
||||
// This is a get only command
|
||||
REQUIRE_THROWS(caller.call("user", {}, -1, PUT));
|
||||
REQUIRE_NOTHROW(caller.call("user", {}, -1, GET));
|
||||
// caller only has help. cmdApp takes care of put and get
|
||||
REQUIRE_NOTHROW(caller.call("user", {}, -1, defs::HELP_ACTION));
|
||||
}
|
||||
|
||||
TEST_CASE("sleep", "[.cmdcall]") {
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
namespace sls {
|
||||
|
||||
TEST_CASE("Default construction") {
|
||||
static_assert(sizeof(CtbConfig) == ((18 + 32 + 64 + 5 + 8) * 20),
|
||||
"Size of CtbConfig does not match");
|
||||
static_assert(sizeof(CtbConfig) ==
|
||||
(2 * sizeof(int) + (18 + 32 + 64 + 5 + 8) * 20),
|
||||
"Size of CtbConfig does not match ");
|
||||
|
||||
CtbConfig c;
|
||||
auto dacnames = c.getDacNames();
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace sls {
|
||||
|
||||
using dt = slsDetectorDefs::detectorType;
|
||||
TEST_CASE("Construction with a defined detector type") {
|
||||
freeSharedMemory(0, 0); // clean up to start test
|
||||
Module m(dt::EIGER);
|
||||
REQUIRE(m.getDetectorType() == dt::EIGER);
|
||||
freeSharedMemory(0, 0); // clean up
|
||||
|
||||
@@ -1,29 +1,105 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
#define DISABLE_STATIC_ASSERT // to be able to test obsolete shm without isValid
|
||||
#include "SharedMemory.h"
|
||||
#include "catch.hpp"
|
||||
#include "sls/string_utils.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
|
||||
namespace sls {
|
||||
|
||||
struct Data {
|
||||
int shmversion{SHM_IS_VALID_CHECK_VERSION};
|
||||
int x;
|
||||
double y;
|
||||
char mess[50];
|
||||
bool isValid{true};
|
||||
};
|
||||
|
||||
struct ObsoleteData {
|
||||
int shmversion{SHM_IS_VALID_CHECK_VERSION - 10};
|
||||
int x;
|
||||
double y;
|
||||
char mess[50];
|
||||
};
|
||||
|
||||
struct ObsoleteCtbData {
|
||||
int x;
|
||||
double y;
|
||||
char mess[50];
|
||||
};
|
||||
|
||||
void freeShm(const int dindex, const int mIndex) {
|
||||
SharedMemory<Data> shm(dindex, mIndex);
|
||||
if (shm.exists()) {
|
||||
shm.removeSharedMemory();
|
||||
}
|
||||
}
|
||||
|
||||
constexpr int shm_id = 10;
|
||||
const std::string file_path =
|
||||
std::string("/dev/shm/slsDetectorPackage_detector_") +
|
||||
std::to_string(shm_id);
|
||||
|
||||
TEST_CASE("Create SharedMemory read and write", "[detector]") {
|
||||
TEST_CASE("Free obsolete (without isValid)", "[detector][shm]") {
|
||||
|
||||
// ensure its clean to start
|
||||
freeShm(shm_id, -1);
|
||||
|
||||
{
|
||||
// create actual shm and free
|
||||
SharedMemory<Data> shm(shm_id, -1);
|
||||
shm.createSharedMemory();
|
||||
REQUIRE(std::filesystem::exists(file_path) == true);
|
||||
REQUIRE(shm.memoryHasValidFlag() == true);
|
||||
REQUIRE_NOTHROW(freeShm(shm_id, -1));
|
||||
REQUIRE(std::filesystem::exists(file_path) == false);
|
||||
}
|
||||
|
||||
{
|
||||
// create obsolete and free
|
||||
SharedMemory<ObsoleteData> shm(shm_id, -1);
|
||||
shm.createSharedMemory();
|
||||
REQUIRE(std::filesystem::exists(file_path) == true);
|
||||
shm.unmapSharedMemory();
|
||||
}
|
||||
|
||||
{
|
||||
SharedMemory<Data> shm(shm_id, -1);
|
||||
shm.openSharedMemory(false);
|
||||
REQUIRE(shm.memoryHasValidFlag() == false);
|
||||
REQUIRE_NOTHROW(freeShm(shm_id, -1));
|
||||
REQUIRE(std::filesystem::exists(file_path) == false);
|
||||
}
|
||||
|
||||
{
|
||||
// create obsolete ctb (without shmversion) and free
|
||||
SharedMemory<ObsoleteCtbData> shm(shm_id, -1);
|
||||
shm.createSharedMemory();
|
||||
REQUIRE(std::filesystem::exists(file_path) == true);
|
||||
shm.unmapSharedMemory();
|
||||
}
|
||||
{
|
||||
SharedMemory<Data> shm(shm_id, -1);
|
||||
shm.openSharedMemory(false);
|
||||
REQUIRE(shm.memoryHasValidFlag() == false);
|
||||
REQUIRE_NOTHROW(freeShm(shm_id, -1));
|
||||
REQUIRE(std::filesystem::exists(file_path) == false);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Create SharedMemory read and write", "[detector][shm]") {
|
||||
SharedMemory<Data> shm(shm_id, -1);
|
||||
if (shm.exists()) {
|
||||
shm.removeSharedMemory();
|
||||
}
|
||||
shm.createSharedMemory();
|
||||
CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") +
|
||||
std::to_string(shm_id));
|
||||
|
||||
const char *env_p = std::getenv("SLSDETNAME");
|
||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||
CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") +
|
||||
std::to_string(shm_id) + env_name);
|
||||
shm()->x = 3;
|
||||
shm()->y = 5.7;
|
||||
strcpy_safe(shm()->mess, "Some string");
|
||||
@@ -32,39 +108,41 @@ TEST_CASE("Create SharedMemory read and write", "[detector]") {
|
||||
CHECK(shm()->y == 5.7);
|
||||
CHECK(std::string(shm()->mess) == "Some string");
|
||||
|
||||
shm.unmapSharedMemory();
|
||||
shm.removeSharedMemory();
|
||||
|
||||
CHECK(shm.exists() == false);
|
||||
}
|
||||
|
||||
TEST_CASE("Open existing SharedMemory and read", "[detector]") {
|
||||
|
||||
TEST_CASE("Open existing SharedMemory and read", "[detector][shm]") {
|
||||
{
|
||||
SharedMemory<double> shm(shm_id, -1);
|
||||
SharedMemory<Data> shm(shm_id, -1);
|
||||
if (shm.exists()) {
|
||||
shm.removeSharedMemory();
|
||||
}
|
||||
shm.createSharedMemory();
|
||||
*shm() = 5.3;
|
||||
shm()->x = 3;
|
||||
shm()->y = 5.9;
|
||||
}
|
||||
|
||||
SharedMemory<double> shm2(shm_id, -1);
|
||||
SharedMemory<Data> shm2(shm_id, -1);
|
||||
shm2.openSharedMemory(true);
|
||||
CHECK(*shm2() == 5.3);
|
||||
CHECK(shm2()->y == 5.9);
|
||||
|
||||
shm2.removeSharedMemory();
|
||||
}
|
||||
|
||||
TEST_CASE("Creating a second shared memory with the same name throws",
|
||||
"[detector]") {
|
||||
"[detector][shm]") {
|
||||
|
||||
SharedMemory<double> shm0(shm_id, -1);
|
||||
SharedMemory<double> shm1(shm_id, -1);
|
||||
SharedMemory<Data> shm0(shm_id, -1);
|
||||
SharedMemory<Data> shm1(shm_id, -1);
|
||||
|
||||
shm0.createSharedMemory();
|
||||
CHECK_THROWS(shm1.createSharedMemory());
|
||||
shm0.removeSharedMemory();
|
||||
}
|
||||
|
||||
TEST_CASE("Open two shared memories to the same place", "[detector]") {
|
||||
TEST_CASE("Open two shared memories to the same place", "[detector][shm]") {
|
||||
|
||||
// Create the first shared memory
|
||||
SharedMemory<Data> shm(shm_id, -1);
|
||||
@@ -89,11 +167,13 @@ TEST_CASE("Open two shared memories to the same place", "[detector]") {
|
||||
CHECK(shm2.exists() == false);
|
||||
}
|
||||
|
||||
TEST_CASE("Move SharedMemory", "[detector]") {
|
||||
TEST_CASE("Move SharedMemory", "[detector][shm]") {
|
||||
const char *env_p = std::getenv("SLSDETNAME");
|
||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||
|
||||
SharedMemory<Data> shm(shm_id, -1);
|
||||
CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") +
|
||||
std::to_string(shm_id));
|
||||
std::to_string(shm_id) + env_name);
|
||||
shm.createSharedMemory();
|
||||
shm()->x = 9;
|
||||
|
||||
@@ -104,26 +184,29 @@ TEST_CASE("Move SharedMemory", "[detector]") {
|
||||
REQUIRE_THROWS(
|
||||
shm()); // trying to access should throw instead of returning a nullptr
|
||||
CHECK(shm2.getName() == std::string("/slsDetectorPackage_detector_") +
|
||||
std::to_string(shm_id));
|
||||
std::to_string(shm_id) + env_name);
|
||||
shm2.removeSharedMemory();
|
||||
}
|
||||
|
||||
TEST_CASE("Create several shared memories", "[detector]") {
|
||||
TEST_CASE("Create several shared memories", "[detector][shm]") {
|
||||
const char *env_p = std::getenv("SLSDETNAME");
|
||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||
|
||||
constexpr int N = 5;
|
||||
std::vector<SharedMemory<int>> v;
|
||||
std::vector<SharedMemory<Data>> v;
|
||||
v.reserve(N);
|
||||
for (int i = 0; i != N; ++i) {
|
||||
v.emplace_back(shm_id + i, -1);
|
||||
CHECK(v[i].exists() == false);
|
||||
v[i].createSharedMemory();
|
||||
*v[i]() = i;
|
||||
CHECK(*v[i]() == i);
|
||||
v[i]()->x = i;
|
||||
CHECK(v[i]()->x == i);
|
||||
}
|
||||
|
||||
for (int i = 0; i != N; ++i) {
|
||||
CHECK(*v[i]() == i);
|
||||
CHECK(v[i]()->x == i);
|
||||
CHECK(v[i].getName() == std::string("/slsDetectorPackage_detector_") +
|
||||
std::to_string(i + shm_id));
|
||||
std::to_string(i + shm_id) + env_name);
|
||||
}
|
||||
|
||||
for (int i = 0; i != N; ++i) {
|
||||
@@ -133,8 +216,12 @@ TEST_CASE("Create several shared memories", "[detector]") {
|
||||
}
|
||||
|
||||
TEST_CASE("Create create a shared memory with a tag") {
|
||||
SharedMemory<int> shm(0, -1, "ctbdacs");
|
||||
REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs");
|
||||
const char *env_p = std::getenv("SLSDETNAME");
|
||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||
|
||||
SharedMemory<Data> shm(0, -1, "ctbdacs");
|
||||
REQUIRE(shm.getName() ==
|
||||
"/slsDetectorPackage_detector_0" + env_name + "_ctbdacs");
|
||||
}
|
||||
|
||||
TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") {
|
||||
@@ -147,7 +234,7 @@ TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") {
|
||||
unsetenv(SHM_ENV_NAME);
|
||||
setenv(SHM_ENV_NAME, "myprefix", 1);
|
||||
|
||||
SharedMemory<int> shm(0, -1, "ctbdacs");
|
||||
SharedMemory<Data> shm(0, -1, "ctbdacs");
|
||||
REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_myprefix_ctbdacs");
|
||||
|
||||
// Clean up after us
|
||||
@@ -157,15 +244,14 @@ TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") {
|
||||
setenv(SHM_ENV_NAME, old_slsdetname.c_str(), 1);
|
||||
}
|
||||
|
||||
TEST_CASE("map int64 to int32 throws") {
|
||||
SharedMemory<int32_t> shm(shm_id, -1);
|
||||
TEST_CASE("Access to already freed shm object", "[detector][shm]") {
|
||||
SharedMemory<Data> shm(shm_id, -1);
|
||||
shm.createSharedMemory();
|
||||
*shm() = 7;
|
||||
shm()->x = 10;
|
||||
|
||||
SharedMemory<int64_t> shm2(shm_id, -1);
|
||||
REQUIRE_THROWS(shm2.openSharedMemory(true));
|
||||
|
||||
shm.removeSharedMemory();
|
||||
freeShm(shm_id, -1);
|
||||
CHECK(shm.exists() == false);
|
||||
REQUIRE_THROWS(shm()); // trying to access should throw
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
|
||||
Reference in New Issue
Block a user