From 3b65e92cb7169e780b19b572bedc05e361767438 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 9 Jun 2025 15:14:35 +0200 Subject: [PATCH] added num interfaces and ten giga enable --- include/aare/Hdf5MasterFile.hpp | 12 ++++----- include/aare/defs.hpp | 9 +++++++ src/Hdf5MasterFile.cpp | 43 +++++++++++++++++++++++++++++---- src/defs.cpp | 31 ++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 11 deletions(-) diff --git a/include/aare/Hdf5MasterFile.hpp b/include/aare/Hdf5MasterFile.hpp index 9f4d038..a74aee0 100644 --- a/include/aare/Hdf5MasterFile.hpp +++ b/include/aare/Hdf5MasterFile.hpp @@ -62,10 +62,10 @@ class Hdf5MasterFile { size_t m_total_frames_expected{}; std::optional m_exptime{}; std::optional m_period{}; - // burst mode - // num udp interfaces + std::optional m_burst_mode; + std::optional m_number_of_udp_interfaces; size_t m_bitdepth{}; - // ten giga + std::optional m_ten_giga; // thresholdenergy // thresholdall energy std::optional m_subexptime{}; @@ -120,10 +120,10 @@ class Hdf5MasterFile { size_t total_frames_expected() const; std::optional exptime() const; std::optional period() const; - // burst mode - // num udp interfaces + std::optional burst_mode() const; + std::optional number_of_udp_interfaces() const; size_t bitdepth() const; - // ten giga + std::optional ten_giga() const; // thresholdenergy // thresholdall energy std::optional subexptime() const; diff --git a/include/aare/defs.hpp b/include/aare/defs.hpp index 37906a7..344267e 100644 --- a/include/aare/defs.hpp +++ b/include/aare/defs.hpp @@ -295,6 +295,9 @@ enum class DetectorType { enum class TimingMode { Auto, Trigger }; enum class FrameDiscardPolicy { NoDiscard, Discard, DiscardPartial }; +enum class BurstMode { Burst_Interal, Burst_External, Continuous_Internal, + Continuous_External }; + std::string RemoveUnit(std::string &str); @@ -385,12 +388,18 @@ template <> std::string ToString(TimingMode arg); template <> FrameDiscardPolicy StringTo(const std::string & /*mode*/); template <> std::string ToString(FrameDiscardPolicy arg); + +template <> BurstMode StringTo(const std::string & /*mode*/); +template <> std::string ToString(BurstMode arg); + std::ostream &operator<<(std::ostream &os, const ScanParameters &r); template <> std::string ToString(ScanParameters arg); + std::ostream &operator<<(std::ostream &os, const ROI &roi); template <> std::string ToString(ROI arg); + using DataTypeVariants = std::variant; template diff --git a/src/Hdf5MasterFile.cpp b/src/Hdf5MasterFile.cpp index d41abfd..a9e0472 100644 --- a/src/Hdf5MasterFile.cpp +++ b/src/Hdf5MasterFile.cpp @@ -112,10 +112,16 @@ std::optional Hdf5MasterFile::exptime() const { std::optional Hdf5MasterFile::period() const { return m_period; } -// burst mode -// num udp interfaces +std::optional Hdf5MasterFile::burst_mode() const { + return m_burst_mode; +} +std::optional Hdf5MasterFile::number_of_udp_interfaces() const { + return m_number_of_udp_interfaces; +} size_t Hdf5MasterFile::bitdepth() const { return m_bitdepth; } -// ten giga +std::optional Hdf5MasterFile::ten_giga() const { + return m_ten_giga; +} // thresholdenergy // thresholdall energy std::optional Hdf5MasterFile::subexptime() const { @@ -303,7 +309,24 @@ void Hdf5MasterFile::parse_acquisition_metadata( H5Eset_auto(H5E_DEFAULT, reinterpret_cast(H5Eprint2), stderr); // burst mode - // num udp interfaces + m_burst_mode = StringTo(h5_get_scalar_dataset( + file, std::string(metadata_group_name + "Burst Mode"))); + LOG(logDEBUG) << "Burst Mode: " << ToString(m_burst_mode); + + + // Number of UDP Interfaces + // Not all detectors write the Number of UDP Interfaces but in case + H5::Exception::dontPrint(); + try { + m_number_of_udp_interfaces = h5_get_scalar_dataset( + file, std::string(metadata_group_name + "Number of UDP Interfaces")); + } catch (H5::FileIException &e) { + // keep the optional empty + } + LOG(logDEBUG) << "Number of UDP Interfaces: " << m_number_of_udp_interfaces; + H5Eset_auto(H5E_DEFAULT, reinterpret_cast(H5Eprint2), + stderr); + // Bit Depth // Not all detectors write the bitdepth but in case @@ -318,7 +341,17 @@ void Hdf5MasterFile::parse_acquisition_metadata( LOG(logDEBUG) << "Bit Depth: " << m_bitdepth; H5Eset_auto(H5E_DEFAULT, reinterpret_cast(H5Eprint2), stderr); - // ten giga + // Ten Giga + H5::Exception::dontPrint(); + try { + m_ten_giga = h5_get_scalar_dataset( + file, std::string(metadata_group_name + "Ten Giga")); + } catch (H5::FileIException &e) { + // keep the optional empty + } + LOG(logDEBUG) << "Ten Giga: " << ToString(m_ten_giga); + H5Eset_auto(H5E_DEFAULT, reinterpret_cast(H5Eprint2), stderr); + // thresholdenergy // thresholdall energy diff --git a/src/defs.cpp b/src/defs.cpp index cb44cd3..e26ab9a 100644 --- a/src/defs.cpp +++ b/src/defs.cpp @@ -154,6 +154,37 @@ template <> FrameDiscardPolicy StringTo(const std::string &arg) { throw std::runtime_error("Could not decode frame discard policy from: \"" + arg + "\""); } +/** + * @brief Convert a BurstMode to a string + * @param type BurstMode + * @return string representation of the BurstMode + */ +template <> std::string ToString(BurstMode arg) { + switch (arg) { + case BurstMode::Burst_Interal: + return "burst_internal"; + case BurstMode::Burst_External: + return "burst_external"; + case BurstMode::Continuous_Internal: + return "continuous_internal"; + case BurstMode::Continuous_External: + return "continuous_external"; + } + throw std::runtime_error("Could not decode burst mode to string"); +} + +template <> BurstMode StringTo(const std::string &arg) { + if (arg == "burst_internal") + return BurstMode::Burst_Interal; + if (arg == "burst_external") + return BurstMode::Burst_External; + if (arg == "continuous_internal") + return BurstMode::Continuous_Internal; + if (arg == "continuous_external") + return BurstMode::Continuous_External; + throw std::runtime_error("Could not decode burst mode from: \"" + arg + "\""); +} + /** * @brief Convert a ScanParameters to a string * @param type ScanParameters