Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
erikfrojdh committed Oct 31, 2024
1 parent ec61132 commit ae1166b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/aare/FileInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct FileConfig {
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) +
", 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) + " }";
}
Expand Down
4 changes: 2 additions & 2 deletions include/aare/defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ enum class TimingMode { Auto, Trigger };

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 <> std::string toString(DetectorType arg);
template <> std::string ToString(DetectorType arg);

template <> TimingMode StringTo(const std::string & /*mode*/);

Expand Down
4 changes: 3 additions & 1 deletion python/src/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ void define_file_io_bindings(py::module &m) {
.def_property_readonly("cols", &File::cols)
.def_property_readonly("bitdepth", &File::bitdepth)
.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) {
const uint8_t item_size = self.bytes_per_pixel();
py::array image;
Expand Down
4 changes: 1 addition & 3 deletions src/RawFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void RawFile::write_master_file() {
ss += "\n\t";
aare::write_digit(ss, "Total Frames", m_total_frames);
ss += "\n\t";
aare::write_str(ss, "Detector Type", toString(m_type));
aare::write_str(ss, "Detector Type", ToString(m_type));
ss += "\n\t";
aare::write_str(ss, "Geometry", m_geometry.to_string());
ss += "\n\t";
Expand Down Expand Up @@ -240,8 +240,6 @@ void RawFile::parse_json_metadata() {
m_type = DetectorType::Moench03;
}else if (m_type == DetectorType::Moench && m_rows == 400 && m_analog_samples == 5000) {
m_type = DetectorType::Moench03_old;
}else{
throw std::runtime_error(LOCATION + "Could not determine Moench detector type");
}


Expand Down
2 changes: 1 addition & 1 deletion src/defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace aare {
* @param type DetectorType
* @return string representation of the DetectorType
*/
template <> std::string toString(DetectorType arg) {
template <> std::string ToString(DetectorType arg) {
switch (arg) {
case DetectorType::Jungfrau:
return "Jungfrau";
Expand Down
2 changes: 1 addition & 1 deletion src/defs.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
TEST_CASE("Enum to string conversion") {
// 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
REQUIRE(toString(aare::DetectorType::Jungfrau) == "Jungfrau");
REQUIRE(ToString(aare::DetectorType::Jungfrau) == "Jungfrau");
}

TEST_CASE("Cluster creation") {
Expand Down

0 comments on commit ae1166b

Please sign in to comment.