mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-23 11:57:58 +02:00
extra methods in CtbRawFile
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
|
||||
namespace aare{
|
||||
|
||||
|
||||
class CtbRawFile{
|
||||
RawMasterFile m_master;
|
||||
std::ifstream m_file;
|
||||
@ -24,8 +25,8 @@ public:
|
||||
|
||||
// in the specific class we can expose more functionality
|
||||
|
||||
size_t image_size_in_bytes() const { return m_master.image_size_in_bytes(); }
|
||||
|
||||
size_t image_size_in_bytes() const;
|
||||
size_t frames_in_file() const;
|
||||
private:
|
||||
void find_subfiles();
|
||||
size_t sub_file_index(size_t frame_index) const {
|
||||
|
@ -23,7 +23,7 @@ class RawFileNameComponents {
|
||||
fmt::format("{}_master_{}{}", m_base_name, m_file_index, m_ext);
|
||||
}
|
||||
|
||||
std::filesystem::path data_fname(size_t mod_id, size_t file_id) {
|
||||
std::filesystem::path data_fname(size_t mod_id, size_t file_id) const{
|
||||
return m_base_path / fmt::format("{}_d{}_f{}_{}.raw", m_base_name,
|
||||
mod_id, file_id, m_file_index);
|
||||
}
|
||||
@ -34,6 +34,10 @@ class RawFileNameComponents {
|
||||
int file_index() const { return m_file_index; }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Class for parsing a master file either in our .json format or the old .raw format
|
||||
*/
|
||||
class RawMasterFile {
|
||||
RawFileNameComponents m_fnc;
|
||||
std::string m_version;
|
||||
@ -55,39 +59,26 @@ class RawMasterFile {
|
||||
std::optional<size_t> m_digital_samples;
|
||||
|
||||
public:
|
||||
RawMasterFile(const std::filesystem::path &fpath) : m_fnc(fpath) {
|
||||
if (!std::filesystem::exists(fpath)) {
|
||||
throw std::runtime_error(LOCATION + " File does not exist");
|
||||
}
|
||||
if (m_fnc.ext() == ".json") {
|
||||
parse_json(fpath);
|
||||
} else if (m_fnc.ext() == ".raw") {
|
||||
parse_raw(fpath);
|
||||
} else {
|
||||
throw std::runtime_error(LOCATION + "Unsupported file type");
|
||||
}
|
||||
}
|
||||
RawMasterFile(const std::filesystem::path &fpath);
|
||||
|
||||
const std::string &version() const { return m_version; }
|
||||
const DetectorType &detector_type() const { return m_type; }
|
||||
const TimingMode &timing_mode() const { return m_timing_mode; }
|
||||
size_t image_size_in_bytes() const { return m_image_size_in_bytes; }
|
||||
size_t frames_in_file() const { return m_frames_in_file; }
|
||||
size_t pixels_y() const { return m_pixels_y; }
|
||||
size_t pixels_x() const { return m_pixels_x; }
|
||||
size_t max_frames_per_file() const { return m_max_frames_per_file; }
|
||||
size_t bitdepth() const { return m_bitdepth; }
|
||||
size_t frame_padding() const { return m_frame_padding; }
|
||||
const FrameDiscardPolicy &frame_discard_policy() const {
|
||||
return m_frame_discard_policy;
|
||||
}
|
||||
std::filesystem::path data_fname(size_t mod_id, size_t file_id) const;
|
||||
|
||||
std::optional<size_t> analog_samples() const { return m_analog_samples; }
|
||||
std::optional<size_t> digital_samples() const { return m_digital_samples; }
|
||||
const std::string &version() const; //!< For example "7.2"
|
||||
const DetectorType &detector_type() const;
|
||||
const TimingMode &timing_mode() const;
|
||||
size_t image_size_in_bytes() const;
|
||||
size_t frames_in_file() const;
|
||||
size_t pixels_y() const;
|
||||
size_t pixels_x() const;
|
||||
size_t max_frames_per_file() const;
|
||||
size_t bitdepth() const;
|
||||
size_t frame_padding() const;
|
||||
const FrameDiscardPolicy &frame_discard_policy() const;
|
||||
|
||||
std::filesystem::path data_fname(size_t mod_id, size_t file_id) {
|
||||
return m_fnc.data_fname(mod_id, file_id);
|
||||
}
|
||||
std::optional<size_t> analog_samples() const;
|
||||
std::optional<size_t> digital_samples() const;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void parse_json(const std::filesystem::path &fpath);
|
||||
|
Reference in New Issue
Block a user