mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-19 13:38:40 +01:00
Added parsing of exptime and period from master files (#256)
- New aare:to_string/string_to similar to what we have in slsDetectorPackage - Added members period and exptime to RawMasterFile - Parsing exposure time and period for json and raw master file formats - Parsing of RawMasterFile from string stream to enable test without files Comments: - to_string is at the moment not a public header. Can make it later if needed. This gives us full freedom with the API - FileConfig should probably be deprecated need to look into it. Meanwhile removed python bindings and string conv
This commit is contained in:
@@ -34,15 +34,15 @@ struct FileConfig {
|
||||
DetectorType detector_type{DetectorType::Unknown};
|
||||
int max_frames_per_file{};
|
||||
size_t total_frames{};
|
||||
std::string to_string() const {
|
||||
return "{ dtype: " + dtype.to_string() +
|
||||
", rows: " + std::to_string(rows) +
|
||||
", cols: " + std::to_string(cols) +
|
||||
", geometry: " + geometry.to_string() +
|
||||
", detector_type: " + ToString(detector_type) +
|
||||
", max_frames_per_file: " + std::to_string(max_frames_per_file) +
|
||||
", total_frames: " + std::to_string(total_frames) + " }";
|
||||
}
|
||||
// std::string to_string() const {
|
||||
// return "{ dtype: " + dtype.to_string() +
|
||||
// ", rows: " + std::to_string(rows) +
|
||||
// ", cols: " + std::to_string(cols) +
|
||||
// ", geometry: " + geometry.to_string() +
|
||||
// ", detector_type: " + ToString(detector_type) +
|
||||
// ", max_frames_per_file: " + std::to_string(max_frames_per_file) +
|
||||
// ", total_frames: " + std::to_string(total_frames) + " }";
|
||||
// }
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <fmt/format.h>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <chrono>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
using json = nlohmann::json;
|
||||
@@ -84,6 +85,9 @@ class RawMasterFile {
|
||||
size_t m_bitdepth{};
|
||||
uint8_t m_quad = 0;
|
||||
|
||||
std::optional<std::chrono::nanoseconds> m_exptime;
|
||||
std::chrono::nanoseconds m_period{0};
|
||||
|
||||
xy m_geometry{};
|
||||
xy m_udp_interfaces_per_module{1, 1};
|
||||
|
||||
@@ -109,6 +113,7 @@ class RawMasterFile {
|
||||
|
||||
public:
|
||||
RawMasterFile(const std::filesystem::path &fpath);
|
||||
RawMasterFile(std::istream &is, const std::string &fname); // for testing
|
||||
|
||||
std::filesystem::path data_fname(size_t mod_id, size_t file_id) const;
|
||||
|
||||
@@ -140,9 +145,12 @@ class RawMasterFile {
|
||||
|
||||
ScanParameters scan_parameters() const;
|
||||
|
||||
std::optional<std::chrono::nanoseconds> exptime() const { return m_exptime; }
|
||||
std::chrono::nanoseconds period() const { return m_period; }
|
||||
|
||||
private:
|
||||
void parse_json(const std::filesystem::path &fpath);
|
||||
void parse_raw(const std::filesystem::path &fpath);
|
||||
void parse_json(std::istream &is);
|
||||
void parse_raw(std::istream &is);
|
||||
void retrieve_geometry();
|
||||
};
|
||||
|
||||
|
||||
@@ -348,29 +348,11 @@ enum class corner : int {
|
||||
enum class TimingMode { Auto, Trigger };
|
||||
enum class FrameDiscardPolicy { NoDiscard, Discard, DiscardPartial };
|
||||
|
||||
template <class T> T StringTo(const std::string &arg) { return T(arg); }
|
||||
|
||||
template <class T> std::string ToString(T arg) { return T(arg); }
|
||||
|
||||
template <> DetectorType StringTo(const std::string & /*name*/);
|
||||
template <> std::string ToString(DetectorType arg);
|
||||
|
||||
template <> TimingMode StringTo(const std::string & /*mode*/);
|
||||
|
||||
template <> FrameDiscardPolicy StringTo(const std::string & /*mode*/);
|
||||
|
||||
using DataTypeVariants = std::variant<uint16_t, uint32_t>;
|
||||
|
||||
constexpr uint16_t ADC_MASK =
|
||||
0x3FFF; // used to mask out the gain bits in Jungfrau
|
||||
|
||||
/**
|
||||
* @brief Convert a string to a DACIndex
|
||||
* @param arg string representation of the dacIndex
|
||||
* @return DACIndex
|
||||
* @throw invalid argument error if the string does not match any DACIndex
|
||||
*/
|
||||
template <> DACIndex StringTo(const std::string &arg);
|
||||
|
||||
class BitOffset{
|
||||
uint8_t m_offset{};
|
||||
|
||||
@@ -106,7 +106,7 @@ class Logger {
|
||||
}
|
||||
|
||||
std::ostringstream &Get() {
|
||||
os << Color(m_level) << "- " << Timestamp() << " " << ToString(m_level)
|
||||
os << Color(m_level) << "- " << Timestamp() << " " << Logger::ToString(m_level)
|
||||
<< ": ";
|
||||
return os;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user