From 87d8682b1e02e5b48a356279a0fd8642ea2f30a3 Mon Sep 17 00:00:00 2001 From: Alice Date: Fri, 6 Jun 2025 11:31:39 +0200 Subject: [PATCH] added test cases --- include/aare/RawFile.hpp | 13 +- include/aare/RawMasterFile.hpp | 2 + src/RawFile.cpp | 27 ++-- src/RawFile.test.cpp | 156 ++++++++++++++++++---- src/RawMasterFile.cpp | 26 +++- src/RawMasterFile.test.cpp | 229 +++++++++++++++++---------------- 6 files changed, 298 insertions(+), 155 deletions(-) diff --git a/include/aare/RawFile.hpp b/include/aare/RawFile.hpp index 5c6e74b..78ebf4c 100644 --- a/include/aare/RawFile.hpp +++ b/include/aare/RawFile.hpp @@ -36,9 +36,12 @@ class RawFile : public FileInterface { RawMasterFile m_master; size_t m_current_frame{}; size_t m_current_subfile{}; - DetectorGeometry m_geometry; + std::vector m_modules_in_roi{}; + protected: + DetectorGeometry m_geometry; + public: /** * @brief RawFile constructor @@ -95,15 +98,17 @@ class RawFile : public FileInterface { */ Frame get_frame(size_t frame_index); + void open_subfiles(); + + protected: + void find_geometry(); + /** * @brief read the header of the file * @param fname path to the data subfile * @return DetectorHeader */ static DetectorHeader read_header(const std::filesystem::path &fname); - - void open_subfiles(); - void find_geometry(); }; } // namespace aare \ No newline at end of file diff --git a/include/aare/RawMasterFile.hpp b/include/aare/RawMasterFile.hpp index 9d65081..671fa36 100644 --- a/include/aare/RawMasterFile.hpp +++ b/include/aare/RawMasterFile.hpp @@ -81,6 +81,7 @@ class RawMasterFile { size_t m_pixels_y{}; size_t m_pixels_x{}; size_t m_bitdepth{}; + size_t m_num_udp_interfaces_per_module = 1; xy m_geometry{}; @@ -119,6 +120,7 @@ class RawMasterFile { size_t max_frames_per_file() const; size_t bitdepth() const; size_t frame_padding() const; + size_t num_udp_interfaces_per_module() const; const FrameDiscardPolicy &frame_discard_policy() const; size_t total_frames_expected() const; diff --git a/src/RawFile.cpp b/src/RawFile.cpp index fbf1dad..2a60de1 100644 --- a/src/RawFile.cpp +++ b/src/RawFile.cpp @@ -24,8 +24,8 @@ RawFile::RawFile(const std::filesystem::path &fname, const std::string &mode) m_modules_in_roi.reserve(n_modules()); for (size_t module_index = 0; module_index < n_modules(); ++module_index) { - if (m_geometry.module_pixel_0[module_index].width == 0 && - m_geometry.module_pixel_0[module_index].height == 0) + if (m_geometry.module_pixel_0[module_index].width != 0 && + m_geometry.module_pixel_0[module_index].height != 0) m_modules_in_roi.push_back(module_index); } } else { @@ -148,17 +148,20 @@ RawMasterFile RawFile::master() const { return m_master; } */ void RawFile::find_geometry() { - // TODO potentially update for Eiger - for (size_t col = 0; col < m_master.geometry().col; ++col) + for (size_t col = 0; col < m_master.geometry().col; + col += m_master.num_udp_interfaces_per_module()) for (size_t row = 0; row < m_master.geometry().row; ++row) { - ModuleGeometry g; - g.origin_x = col * m_master.pixels_x(); - g.origin_y = row * m_master.pixels_y(); - g.row_index = row; - g.col_index = col; - g.width = m_master.pixels_x(); - g.height = m_master.pixels_y(); - m_geometry.module_pixel_0.push_back(g); + for (size_t port = 0; + port < m_master.num_udp_interfaces_per_module(); ++port) { + ModuleGeometry g; + g.origin_x = (col + port) * m_master.pixels_x(); + g.origin_y = row * m_master.pixels_y(); + g.row_index = row; + g.col_index = col + port; + g.width = m_master.pixels_x(); + g.height = m_master.pixels_y(); + m_geometry.module_pixel_0.push_back(g); + } } m_geometry.pixels_y = (m_master.geometry().row * m_master.pixels_y()); diff --git a/src/RawFile.test.cpp b/src/RawFile.test.cpp index 9109985..239bfb2 100644 --- a/src/RawFile.test.cpp +++ b/src/RawFile.test.cpp @@ -1,18 +1,21 @@ +#include "aare/RawFile.hpp" #include "aare/File.hpp" #include "aare/RawMasterFile.hpp" //needed for ROI -#include "aare/RawFile.hpp" #include +#include #include #include "test_config.hpp" - using aare::File; +using aare::RawFile; +using namespace aare; TEST_CASE("Read number of frames from a jungfrau raw file", "[.integration]") { - auto fpath = test_data_path() / "jungfrau" / "jungfrau_single_master_0.json"; + auto fpath = + test_data_path() / "jungfrau" / "jungfrau_single_master_0.json"; REQUIRE(std::filesystem::exists(fpath)); File f(fpath, "r"); @@ -20,7 +23,8 @@ TEST_CASE("Read number of frames from a jungfrau raw file", "[.integration]") { } TEST_CASE("Read frame numbers from a jungfrau raw file", "[.integration]") { - auto fpath = test_data_path() / "jungfrau" / "jungfrau_single_master_0.json"; + auto fpath = + test_data_path() / "jungfrau" / "jungfrau_single_master_0.json"; REQUIRE(std::filesystem::exists(fpath)); File f(fpath, "r"); @@ -36,7 +40,8 @@ TEST_CASE("Read frame numbers from a jungfrau raw file", "[.integration]") { } TEST_CASE("Read a frame number too high throws", "[.integration]") { - auto fpath = test_data_path() / "jungfrau" / "jungfrau_single_master_0.json"; + auto fpath = + test_data_path() / "jungfrau" / "jungfrau_single_master_0.json"; REQUIRE(std::filesystem::exists(fpath)); File f(fpath, "r"); @@ -49,8 +54,10 @@ TEST_CASE("Read a frame number too high throws", "[.integration]") { REQUIRE_THROWS(f.frame_number(10)); } -TEST_CASE("Read a frame numbers where the subfile is missing throws", "[.integration]") { - auto fpath = test_data_path() / "jungfrau" / "jungfrau_missing_subfile_master_0.json"; +TEST_CASE("Read a frame numbers where the subfile is missing throws", + "[.integration]") { + auto fpath = test_data_path() / "jungfrau" / + "jungfrau_missing_subfile_master_0.json"; REQUIRE(std::filesystem::exists(fpath)); File f(fpath, "r"); @@ -58,7 +65,7 @@ TEST_CASE("Read a frame numbers where the subfile is missing throws", "[.integra // we know this file has 10 frames with frame numbers 1 to 10 // f0 1,2,3 // f1 4,5,6 - but files f1-f3 are missing - // f2 7,8,9 - gone + // f2 7,8,9 - gone // f3 10 - gone REQUIRE(f.frame_number(0) == 1); REQUIRE(f.frame_number(1) == 2); @@ -69,15 +76,18 @@ TEST_CASE("Read a frame numbers where the subfile is missing throws", "[.integra REQUIRE_THROWS(f.frame_number(10)); } - -TEST_CASE("Read data from a jungfrau 500k single port raw file", "[.integration]") { - auto fpath = test_data_path() / "jungfrau" / "jungfrau_single_master_0.json"; +TEST_CASE("Read data from a jungfrau 500k single port raw file", + "[.integration]") { + auto fpath = + test_data_path() / "jungfrau" / "jungfrau_single_master_0.json"; REQUIRE(std::filesystem::exists(fpath)); File f(fpath, "r"); - // we know this file has 10 frames with pixel 0,0 being: 2123, 2051, 2109, 2117, 2089, 2095, 2072, 2126, 2097, 2102 - std::vector pixel_0_0 = {2123, 2051, 2109, 2117, 2089, 2095, 2072, 2126, 2097, 2102}; + // we know this file has 10 frames with pixel 0,0 being: 2123, 2051, 2109, + // 2117, 2089, 2095, 2072, 2126, 2097, 2102 + std::vector pixel_0_0 = {2123, 2051, 2109, 2117, 2089, + 2095, 2072, 2126, 2097, 2102}; for (size_t i = 0; i < 10; i++) { auto frame = f.read_frame(); CHECK(frame.rows() == 512); @@ -100,10 +110,12 @@ TEST_CASE("Read frame numbers from a raw file", "[.integration]") { } TEST_CASE("Compare reading from a numpy file with a raw file", "[.files]") { - auto fpath_raw = test_data_path() / "raw/jungfrau" / "jungfrau_single_master_0.json"; + auto fpath_raw = + test_data_path() / "raw/jungfrau" / "jungfrau_single_master_0.json"; REQUIRE(std::filesystem::exists(fpath_raw)); - auto fpath_npy = test_data_path() / "raw/jungfrau" / "jungfrau_single_0.npy"; + auto fpath_npy = + test_data_path() / "raw/jungfrau" / "jungfrau_single_0.npy"; REQUIRE(std::filesystem::exists(fpath_npy)); File raw(fpath_raw, "r"); @@ -121,17 +133,23 @@ TEST_CASE("Compare reading from a numpy file with a raw file", "[.files]") { } TEST_CASE("Read multipart files", "[.integration]") { - auto fpath = test_data_path() / "jungfrau" / "jungfrau_double_master_0.json"; + auto fpath = + test_data_path() / "jungfrau" / "jungfrau_double_master_0.json"; REQUIRE(std::filesystem::exists(fpath)); File f(fpath, "r"); // we know this file has 10 frames check read_multiport.py for the values - std::vector pixel_0_0 = {2099, 2121, 2108, 2084, 2084, 2118, 2066, 2108, 2112, 2116}; - std::vector pixel_0_1 = {2842, 2796, 2865, 2798, 2805, 2817, 2852, 2789, 2792, 2833}; - std::vector pixel_255_1023 = {2149, 2037, 2115, 2102, 2118, 2090, 2036, 2071, 2073, 2142}; - std::vector pixel_511_1023 = {3231, 3169, 3167, 3162, 3168, 3160, 3171, 3171, 3169, 3171}; - std::vector pixel_1_0 = {2748, 2614, 2665, 2629, 2618, 2630, 2631, 2634, 2577, 2598}; + std::vector pixel_0_0 = {2099, 2121, 2108, 2084, 2084, + 2118, 2066, 2108, 2112, 2116}; + std::vector pixel_0_1 = {2842, 2796, 2865, 2798, 2805, + 2817, 2852, 2789, 2792, 2833}; + std::vector pixel_255_1023 = {2149, 2037, 2115, 2102, 2118, + 2090, 2036, 2071, 2073, 2142}; + std::vector pixel_511_1023 = {3231, 3169, 3167, 3162, 3168, + 3160, 3171, 3171, 3169, 3171}; + std::vector pixel_1_0 = {2748, 2614, 2665, 2629, 2618, + 2630, 2631, 2634, 2577, 2598}; for (size_t i = 0; i < 10; i++) { auto frame = f.read_frame(); @@ -145,12 +163,102 @@ TEST_CASE("Read multipart files", "[.integration]") { } } +// dummy test class for easy member access +class RawFileTestWrapper : public RawFile { + public: + RawFileTestWrapper(const std::filesystem::path &fname, + const std::string &mode = "r") + : RawFile(fname, mode) {} + void find_geometry() { RawFile::find_geometry(); } + + DetectorGeometry get_geometry() { return this->m_geometry; } + + static DetectorHeader read_header(const std::filesystem::path &fname) { + return RawFile::read_header(fname); + } +}; + +struct TestParameters { + const std::string master_filename{}; + const uint8_t num_ports{}; + const DetectorGeometry geometry{}; +}; + +TEST_CASE("check find_geometry", "[.integration][.files][.rawfile]") { + + auto test_parameters = GENERATE( + TestParameters{ + "raw/jungfrau_2modules_version6.1.2/run_master_0.raw", 2, + DetectorGeometry{1, 2, 1024, 1024, 0, 0, + std::vector{ + ModuleGeometry{0, 0, 512, 1024, 0, 0}, + ModuleGeometry{0, 512, 512, 1024, 0, 1}}}}, + TestParameters{ + "raw/eiger_1_module_version7.0.0/eiger_1mod_master_7.json", 4, + DetectorGeometry{2, 2, 1024, 512, 0, 0, + std::vector{ + ModuleGeometry{0, 0, 256, 512, 0, 0}, + ModuleGeometry{512, 0, 256, 512, 0, 1}, + ModuleGeometry{0, 256, 256, 512, 1, 0}, + ModuleGeometry{512, 256, 256, 512, 1, 1}}}}); + + auto fpath = test_data_path() / test_parameters.master_filename; + REQUIRE(std::filesystem::exists(fpath)); + + RawFileTestWrapper f(fpath, "r"); + + auto geometry = f.get_geometry(); + + CHECK(geometry.modules_x == test_parameters.geometry.modules_x); + CHECK(geometry.modules_y == test_parameters.geometry.modules_y); + CHECK(geometry.pixels_x == test_parameters.geometry.pixels_x); + CHECK(geometry.pixels_y == test_parameters.geometry.pixels_y); + + REQUIRE(geometry.module_pixel_0.size() == test_parameters.num_ports); + + // compare to data stored in header + for (size_t i = 0; i < test_parameters.num_ports; ++i) { + + auto subfile1_path = f.master().data_fname(i, 0); + REQUIRE(std::filesystem::exists(subfile1_path)); + + auto header = RawFileTestWrapper::read_header(subfile1_path); + + CHECK(header.column == geometry.module_pixel_0[i].col_index); + CHECK(header.row == geometry.module_pixel_0[i].row_index); + + CHECK(geometry.module_pixel_0[i].height == + test_parameters.geometry.module_pixel_0[i].height); + CHECK(geometry.module_pixel_0[i].width == + test_parameters.geometry.module_pixel_0[i].width); + + CHECK(geometry.module_pixel_0[i].origin_x == + test_parameters.geometry.module_pixel_0[i].origin_x); + CHECK(geometry.module_pixel_0[i].origin_y == + test_parameters.geometry.module_pixel_0[i].origin_y); + } +} + +TEST_CASE("Open multi module file with ROI", + "[.integration][.files][.rawfile]") { + + auto fpath = test_data_path() / "SingleChipROI/Data_master_0.json"; + REQUIRE(std::filesystem::exists(fpath)); + + RawFile f(fpath, "r"); + + REQUIRE(f.master().roi().value().width() == 256); + REQUIRE(f.master().roi().value().height() == 256); + + CHECK(f.n_modules() == 2); + + CHECK(f.n_modules_in_roi() == 1); +} + TEST_CASE("Read file with unordered frames", "[.integration]") { - //TODO! Better explanation and error message + // TODO! Better explanation and error message auto fpath = test_data_path() / "mythen" / "scan242_master_3.raw"; REQUIRE(std::filesystem::exists(fpath)); File f(fpath); REQUIRE_THROWS((f.read_frame())); } - - diff --git a/src/RawMasterFile.cpp b/src/RawMasterFile.cpp index d4adf2c..f9f277a 100644 --- a/src/RawMasterFile.cpp +++ b/src/RawMasterFile.cpp @@ -139,6 +139,10 @@ size_t RawMasterFile::n_modules() const { return m_geometry.row * m_geometry.col; } +size_t RawMasterFile::num_udp_interfaces_per_module() const { + return m_num_udp_interfaces_per_module; +} + std::optional RawMasterFile::quad() const { return m_quad; } // optional values, these may or may not be present in the master file @@ -262,6 +266,12 @@ void RawMasterFile::parse_json(const std::filesystem::path &fpath) { } catch (const json::out_of_range &e) { // not a scan } + try { + m_num_udp_interfaces_per_module = j.at("Number of UDP Interfaces"); + } catch (const json::out_of_range &e) { + if (m_type == DetectorType::Eiger) + m_num_udp_interfaces_per_module = 2; + } try { ROI tmp_roi; @@ -276,14 +286,14 @@ void RawMasterFile::parse_json(const std::filesystem::path &fpath) { tmp_roi.ymin != 4294967295 || tmp_roi.ymax != 4294967295) { if (v < 7.21) { - tmp_roi.xmax++; + tmp_roi.xmax++; // why is it updated tmp_roi.ymax++; } - m_roi = tmp_roi; } } catch (const json::out_of_range &e) { + std::cout << e.what() << std::endl; // leave the optional empty } @@ -337,6 +347,9 @@ void RawMasterFile::parse_raw(const std::filesystem::path &fpath) { if (m_type == DetectorType::Moench) { m_type = DetectorType::Moench03_old; } + if (m_type == DetectorType::Eiger) { + m_num_udp_interfaces_per_module = 2; + } } else if (key == "Timing Mode") { m_timing_mode = StringTo(value); } else if (key == "Image Size") { @@ -393,6 +406,8 @@ void RawMasterFile::parse_raw(const std::filesystem::path &fpath) { m_geometry = { static_cast(std::stoi(value.substr(1, pos))), static_cast(std::stoi(value.substr(pos + 1)))}; + } else if (key == "Number of UDP Interfaces") { + m_num_udp_interfaces_per_module = std::stoi(value); } } } @@ -417,15 +432,18 @@ void RawMasterFile::retrieve_geometry() { uint16_t rows = 0; uint16_t cols = 0; // TODO use case for Eiger + while (std::filesystem::exists(data_fname(module_index, 0))) { + auto header = RawFile::read_header(data_fname(module_index, 0)); rows = std::max(rows, header.row); cols = std::max(cols, header.column); - ++rows; - ++cols; + ++module_index; } + ++rows; + ++cols; m_geometry = {rows, cols}; } diff --git a/src/RawMasterFile.test.cpp b/src/RawMasterFile.test.cpp index 560217f..0342604 100644 --- a/src/RawMasterFile.test.cpp +++ b/src/RawMasterFile.test.cpp @@ -1,12 +1,12 @@ #include "aare/RawMasterFile.hpp" -#include #include "test_config.hpp" +#include +#include using namespace aare; - -TEST_CASE("Parse a master file fname"){ +TEST_CASE("Parse a master file fname") { RawFileNameComponents m("test_master_1.json"); REQUIRE(m.base_name() == "test"); REQUIRE(m.ext() == ".json"); @@ -14,7 +14,7 @@ TEST_CASE("Parse a master file fname"){ REQUIRE(m.base_path() == ""); } -TEST_CASE("Extraction of base path works"){ +TEST_CASE("Extraction of base path works") { RawFileNameComponents m("some/path/test_master_73.json"); REQUIRE(m.base_name() == "test"); REQUIRE(m.ext() == ".json"); @@ -22,7 +22,7 @@ TEST_CASE("Extraction of base path works"){ REQUIRE(m.base_path() == "some/path"); } -TEST_CASE("Construction of master file name and data files"){ +TEST_CASE("Construction of master file name and data files") { RawFileNameComponents m("test_master_1.json"); REQUIRE(m.master_fname() == "test_master_1.json"); REQUIRE(m.data_fname(0, 0) == "test_d0_f0_1.raw"); @@ -31,7 +31,7 @@ TEST_CASE("Construction of master file name and data files"){ REQUIRE(m.data_fname(1, 1) == "test_d1_f1_1.raw"); } -TEST_CASE("Construction of master file name and data files using old scheme"){ +TEST_CASE("Construction of master file name and data files using old scheme") { RawFileNameComponents m("test_master_1.raw"); m.set_old_scheme(true); REQUIRE(m.master_fname() == "test_master_1.raw"); @@ -41,16 +41,15 @@ TEST_CASE("Construction of master file name and data files using old scheme"){ REQUIRE(m.data_fname(1, 1) == "test_d1_f000000000001_1.raw"); } -TEST_CASE("Master file name does not fit pattern"){ +TEST_CASE("Master file name does not fit pattern") { REQUIRE_THROWS(RawFileNameComponents("somefile.json")); REQUIRE_THROWS(RawFileNameComponents("another_test_d0_f0_1.raw")); REQUIRE_THROWS(RawFileNameComponents("test_master_1.txt")); } - - -TEST_CASE("Parse scan parameters"){ - ScanParameters s("[enabled\ndac dac 4\nstart 500\nstop 2200\nstep 5\nsettleTime 100us\n]"); +TEST_CASE("Parse scan parameters") { + ScanParameters s("[enabled\ndac dac 4\nstart 500\nstop 2200\nstep " + "5\nsettleTime 100us\n]"); REQUIRE(s.enabled()); REQUIRE(s.dac() == "dac 4"); REQUIRE(s.start() == 500); @@ -58,7 +57,7 @@ TEST_CASE("Parse scan parameters"){ REQUIRE(s.step() == 5); } -TEST_CASE("A disabled scan"){ +TEST_CASE("A disabled scan") { ScanParameters s("[disabled]"); REQUIRE_FALSE(s.enabled()); REQUIRE(s.dac() == ""); @@ -67,9 +66,9 @@ TEST_CASE("A disabled scan"){ REQUIRE(s.step() == 0); } - -TEST_CASE("Parse a master file in .json format", "[.integration]"){ - auto fpath = test_data_path() / "jungfrau" / "jungfrau_single_master_0.json"; +TEST_CASE("Parse a master file in .json format", "[.integration]") { + auto fpath = + test_data_path() / "jungfrau" / "jungfrau_single_master_0.json"; REQUIRE(std::filesystem::exists(fpath)); RawMasterFile f(fpath); @@ -80,7 +79,7 @@ TEST_CASE("Parse a master file in .json format", "[.integration]"){ REQUIRE(f.detector_type() == DetectorType::Jungfrau); // "Timing Mode": "auto", REQUIRE(f.timing_mode() == TimingMode::Auto); - + // "Geometry": { // "x": 1, // "y": 1 @@ -100,10 +99,9 @@ TEST_CASE("Parse a master file in .json format", "[.integration]"){ // "Max Frames Per File": 3, REQUIRE(f.max_frames_per_file() == 3); - //Jungfrau doesn't write but it is 16 + // Jungfrau doesn't write but it is 16 REQUIRE(f.bitdepth() == 16); - // "Frame Discard Policy": "nodiscard", // "Frame Padding": 1, @@ -125,33 +123,48 @@ TEST_CASE("Parse a master file in .json format", "[.integration]"){ // "Frames in File": 10, REQUIRE(f.frames_in_file() == 10); - //TODO! Should we parse this? - // "Frame Header Format": { - // "Frame Number": "8 bytes", - // "SubFrame Number/ExpLength": "4 bytes", - // "Packet Number": "4 bytes", - // "Bunch ID": "8 bytes", - // "Timestamp": "8 bytes", - // "Module Id": "2 bytes", - // "Row": "2 bytes", - // "Column": "2 bytes", - // "Reserved": "2 bytes", - // "Debug": "4 bytes", - // "Round Robin Number": "2 bytes", - // "Detector Type": "1 byte", - // "Header Version": "1 byte", - // "Packets Caught Mask": "64 bytes" - // } - // } + // TODO! Should we parse this? + // "Frame Header Format": { + // "Frame Number": "8 bytes", + // "SubFrame Number/ExpLength": "4 bytes", + // "Packet Number": "4 bytes", + // "Bunch ID": "8 bytes", + // "Timestamp": "8 bytes", + // "Module Id": "2 bytes", + // "Row": "2 bytes", + // "Column": "2 bytes", + // "Reserved": "2 bytes", + // "Debug": "4 bytes", + // "Round Robin Number": "2 bytes", + // "Detector Type": "1 byte", + // "Header Version": "1 byte", + // "Packets Caught Mask": "64 bytes" + // } + // } REQUIRE_FALSE(f.analog_samples()); - REQUIRE_FALSE(f.digital_samples()); - + REQUIRE_FALSE(f.digital_samples()); } -TEST_CASE("Parse a master file in .raw format", "[.integration]"){ - - auto fpath = test_data_path() / "moench/moench04_noise_200V_sto_both_100us_no_light_thresh_900_master_0.raw"; +TEST_CASE("Parse a master file in old .raw format", + "[.integration][.files][.rawmasterfile]") { + auto fpath = test_data_path() / + "raw/jungfrau_2modules_version6.1.2/run_master_0.raw"; + REQUIRE(std::filesystem::exists(fpath)); + RawMasterFile f(fpath); + + CHECK(f.num_udp_interfaces_per_module() == 1); + CHECK(f.n_modules() == 2); + CHECK(f.geometry().row == 2); + CHECK(f.geometry().col == 1); +} + +TEST_CASE("Parse a master file in .raw format", "[.integration]") { + + auto fpath = + test_data_path() / + "moench/" + "moench04_noise_200V_sto_both_100us_no_light_thresh_900_master_0.raw"; REQUIRE(std::filesystem::exists(fpath)); RawMasterFile f(fpath); @@ -209,80 +222,74 @@ TEST_CASE("Parse a master file in .raw format", "[.integration]"){ // Detector Type : 1 byte // Header Version : 1 byte // Packets Caught Mask : 64 bytes - - } - -TEST_CASE("Read eiger master file", "[.integration]"){ -auto fpath = test_data_path() / "eiger" / "eiger_500k_32bit_master_0.json"; +TEST_CASE("Read eiger master file", "[.integration]") { + auto fpath = test_data_path() / "eiger" / "eiger_500k_32bit_master_0.json"; REQUIRE(std::filesystem::exists(fpath)); RawMasterFile f(fpath); - -// { -// "Version": 7.2, -REQUIRE(f.version() == "7.2"); -// "Timestamp": "Tue Mar 26 17:24:34 2024", -// "Detector Type": "Eiger", -REQUIRE(f.detector_type() == DetectorType::Eiger); -// "Timing Mode": "auto", -REQUIRE(f.timing_mode() == TimingMode::Auto); -// "Geometry": { -// "x": 2, -// "y": 2 -// }, -// "Image Size in bytes": 524288, -REQUIRE(f.image_size_in_bytes() == 524288); -// "Pixels": { -// "x": 512, -REQUIRE(f.pixels_x() == 512); -// "y": 256 -REQUIRE(f.pixels_y() == 256); -// }, -// "Max Frames Per File": 10000, -REQUIRE(f.max_frames_per_file() == 10000); -// "Frame Discard Policy": "nodiscard", -REQUIRE(f.frame_discard_policy() == FrameDiscardPolicy::NoDiscard); -// "Frame Padding": 1, -REQUIRE(f.frame_padding() == 1); - -// "Scan Parameters": "[disabled]", -// "Total Frames": 3, -// "Receiver Roi": { -// "xmin": 4294967295, -// "xmax": 4294967295, -// "ymin": 4294967295, -// "ymax": 4294967295 -// }, -// "Dynamic Range": 32, -// "Ten Giga": 0, -// "Exptime": "5s", -// "Period": "1s", -// "Threshold Energy": -1, -// "Sub Exptime": "2.62144ms", -// "Sub Period": "2.62144ms", -// "Quad": 0, -// "Number of rows": 256, -// "Rate Corrections": "[0, 0]", -// "Frames in File": 3, -// "Frame Header Format": { -// "Frame Number": "8 bytes", -// "SubFrame Number/ExpLength": "4 bytes", -// "Packet Number": "4 bytes", -// "Bunch ID": "8 bytes", -// "Timestamp": "8 bytes", -// "Module Id": "2 bytes", -// "Row": "2 bytes", -// "Column": "2 bytes", -// "Reserved": "2 bytes", -// "Debug": "4 bytes", -// "Round Robin Number": "2 bytes", -// "Detector Type": "1 byte", -// "Header Version": "1 byte", -// "Packets Caught Mask": "64 bytes" -// } -// } - + // { + // "Version": 7.2, + REQUIRE(f.version() == "7.2"); + // "Timestamp": "Tue Mar 26 17:24:34 2024", + // "Detector Type": "Eiger", + REQUIRE(f.detector_type() == DetectorType::Eiger); + // "Timing Mode": "auto", + REQUIRE(f.timing_mode() == TimingMode::Auto); + // "Geometry": { + // "x": 2, + // "y": 2 + // }, + // "Image Size in bytes": 524288, + REQUIRE(f.image_size_in_bytes() == 524288); + // "Pixels": { + // "x": 512, + REQUIRE(f.pixels_x() == 512); + // "y": 256 + REQUIRE(f.pixels_y() == 256); + // }, + // "Max Frames Per File": 10000, + REQUIRE(f.max_frames_per_file() == 10000); + // "Frame Discard Policy": "nodiscard", + REQUIRE(f.frame_discard_policy() == FrameDiscardPolicy::NoDiscard); + // "Frame Padding": 1, + REQUIRE(f.frame_padding() == 1); + // "Scan Parameters": "[disabled]", + // "Total Frames": 3, + // "Receiver Roi": { + // "xmin": 4294967295, + // "xmax": 4294967295, + // "ymin": 4294967295, + // "ymax": 4294967295 + // }, + // "Dynamic Range": 32, + // "Ten Giga": 0, + // "Exptime": "5s", + // "Period": "1s", + // "Threshold Energy": -1, + // "Sub Exptime": "2.62144ms", + // "Sub Period": "2.62144ms", + // "Quad": 0, + // "Number of rows": 256, + // "Rate Corrections": "[0, 0]", + // "Frames in File": 3, + // "Frame Header Format": { + // "Frame Number": "8 bytes", + // "SubFrame Number/ExpLength": "4 bytes", + // "Packet Number": "4 bytes", + // "Bunch ID": "8 bytes", + // "Timestamp": "8 bytes", + // "Module Id": "2 bytes", + // "Row": "2 bytes", + // "Column": "2 bytes", + // "Reserved": "2 bytes", + // "Debug": "4 bytes", + // "Round Robin Number": "2 bytes", + // "Detector Type": "1 byte", + // "Header Version": "1 byte", + // "Packets Caught Mask": "64 bytes" + // } + // } } \ No newline at end of file