This commit is contained in:
Erik Fröjdh 2024-10-31 10:39:52 +01:00
parent ec61132296
commit ae1166b908
6 changed files with 9 additions and 9 deletions

View File

@ -33,7 +33,7 @@ struct FileConfig {
size_t total_frames{}; size_t total_frames{};
std::string to_string() const { std::string to_string() const {
return "{ dtype: " + dtype.to_string() + ", rows: " + std::to_string(rows) + ", cols: " + std::to_string(cols) + return "{ dtype: " + dtype.to_string() + ", rows: " + std::to_string(rows) + ", cols: " + std::to_string(cols) +
", geometry: " + geometry.to_string() + ", detector_type: " + toString(detector_type) + ", geometry: " + geometry.to_string() + ", detector_type: " + ToString(detector_type) +
", max_frames_per_file: " + std::to_string(max_frames_per_file) + ", max_frames_per_file: " + std::to_string(max_frames_per_file) +
", total_frames: " + std::to_string(total_frames) + " }"; ", total_frames: " + std::to_string(total_frames) + " }";
} }

View File

@ -181,10 +181,10 @@ enum class TimingMode { Auto, Trigger };
template <class T> T StringTo(const std::string &arg) { return T(arg); } template <class T> T StringTo(const std::string &arg) { return T(arg); }
template <class T> std::string toString(T arg) { return T(arg); } template <class T> std::string ToString(T arg) { return T(arg); }
template <> DetectorType StringTo(const std::string & /*name*/); template <> DetectorType StringTo(const std::string & /*name*/);
template <> std::string toString(DetectorType arg); template <> std::string ToString(DetectorType arg);
template <> TimingMode StringTo(const std::string & /*mode*/); template <> TimingMode StringTo(const std::string & /*mode*/);

View File

@ -32,7 +32,9 @@ void define_file_io_bindings(py::module &m) {
.def_property_readonly("cols", &File::cols) .def_property_readonly("cols", &File::cols)
.def_property_readonly("bitdepth", &File::bitdepth) .def_property_readonly("bitdepth", &File::bitdepth)
.def_property_readonly("bytes_per_pixel", &File::bytes_per_pixel) .def_property_readonly("bytes_per_pixel", &File::bytes_per_pixel)
.def_property_readonly("detector_type", &File::detector_type) .def_property_readonly("detector_type", [](File &self){
return ToString(self.detector_type());
})
.def("read_frame", [](File &self) { .def("read_frame", [](File &self) {
const uint8_t item_size = self.bytes_per_pixel(); const uint8_t item_size = self.bytes_per_pixel();
py::array image; py::array image;

View File

@ -72,7 +72,7 @@ void RawFile::write_master_file() {
ss += "\n\t"; ss += "\n\t";
aare::write_digit(ss, "Total Frames", m_total_frames); aare::write_digit(ss, "Total Frames", m_total_frames);
ss += "\n\t"; ss += "\n\t";
aare::write_str(ss, "Detector Type", toString(m_type)); aare::write_str(ss, "Detector Type", ToString(m_type));
ss += "\n\t"; ss += "\n\t";
aare::write_str(ss, "Geometry", m_geometry.to_string()); aare::write_str(ss, "Geometry", m_geometry.to_string());
ss += "\n\t"; ss += "\n\t";
@ -240,8 +240,6 @@ void RawFile::parse_json_metadata() {
m_type = DetectorType::Moench03; m_type = DetectorType::Moench03;
}else if (m_type == DetectorType::Moench && m_rows == 400 && m_analog_samples == 5000) { }else if (m_type == DetectorType::Moench && m_rows == 400 && m_analog_samples == 5000) {
m_type = DetectorType::Moench03_old; m_type = DetectorType::Moench03_old;
}else{
throw std::runtime_error(LOCATION + "Could not determine Moench detector type");
} }

View File

@ -9,7 +9,7 @@ namespace aare {
* @param type DetectorType * @param type DetectorType
* @return string representation of the DetectorType * @return string representation of the DetectorType
*/ */
template <> std::string toString(DetectorType arg) { template <> std::string ToString(DetectorType arg) {
switch (arg) { switch (arg) {
case DetectorType::Jungfrau: case DetectorType::Jungfrau:
return "Jungfrau"; return "Jungfrau";

View File

@ -6,7 +6,7 @@
TEST_CASE("Enum to string conversion") { TEST_CASE("Enum to string conversion") {
// By the way I don't think the enum string conversions should be in the defs.hpp file // By the way I don't think the enum string conversions should be in the defs.hpp file
// but let's use this to show a test // but let's use this to show a test
REQUIRE(toString(aare::DetectorType::Jungfrau) == "Jungfrau"); REQUIRE(ToString(aare::DetectorType::Jungfrau) == "Jungfrau");
} }
TEST_CASE("Cluster creation") { TEST_CASE("Cluster creation") {