mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-31 08:31:18 +01:00
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
280 lines
11 KiB
C++
280 lines
11 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
#include "Caller.h"
|
|
#include "catch.hpp"
|
|
#include "sls/Detector.h"
|
|
#include "sls/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
|