diff --git a/common/DiffractionExperiment.cpp b/common/DiffractionExperiment.cpp index 59cdb322..c31b9e0a 100644 --- a/common/DiffractionExperiment.cpp +++ b/common/DiffractionExperiment.cpp @@ -52,7 +52,6 @@ DiffractionExperiment::DiffractionExperiment(const DetectorGeometry& geom) { dataset.set_compression(JFJochProtoBuf::BSHUF_LZ4); internal.set_ndatastreams(1); - internal.set_nmodules(geom.GetModulesNum()); internal.set_frame_time_us(MIN_FRAME_TIME_HALF_SPEED_IN_US); internal.set_count_time_us(MIN_FRAME_TIME_HALF_SPEED_IN_US - READOUT_TIME_IN_US); @@ -86,7 +85,7 @@ DiffractionExperiment::DiffractionExperiment(const DetectorGeometry& geom) { DiffractionExperiment &DiffractionExperiment::Geometry(const DetectorGeometry &input) { check_min("Number of modules", input.GetModulesNum(), 1); check_max("Number of modules", input.GetModulesNum(), 64); // if operating > 32M, would need to check the code anyway - + internal.set_nmodules(input.GetModulesNum()); *internal.mutable_conv_geometry() = input; return *this; } diff --git a/tests/DiffractionExperimentTest.cpp b/tests/DiffractionExperimentTest.cpp index 0590044b..086a8a1d 100644 --- a/tests/DiffractionExperimentTest.cpp +++ b/tests/DiffractionExperimentTest.cpp @@ -1035,4 +1035,26 @@ TEST_CASE("DiffractionExperiment_Binning","[DiffractionExperiment]") { REQUIRE(!x.GetBinning2x2()); REQUIRE(x.GetXPixelsNum() == RAW_MODULE_COLS); REQUIRE(x.GetYPixelsNum() == 8 * RAW_MODULE_LINES); +} + +TEST_CASE("DiffractionExperiment_DetectorModuleHostname","[DiffractionExperiment]") { + std::vector h = {"mx1", "mx2", "mx3"}; + DiffractionExperiment x(DetectorGeometry(8)); + JFJochProtoBuf::DetectorConfig det_cfg; + + JFJochProtoBuf::ReceiverNetworkConfig net_cfg; + net_cfg.add_fpga_mac_addr("AA:BB:CC:DD:EE:FF"); + net_cfg.add_fpga_mac_addr("AA:BB:CC:DD:EE:FE"); + + // Before setting module hostname + REQUIRE_NOTHROW(det_cfg = x.DetectorConfig(net_cfg)); + + REQUIRE_NOTHROW(x.DetectorModuleHostname(h)); + std::vector h_out; + REQUIRE_NOTHROW(x.GetDetectorModuleHostname(h_out)); + REQUIRE(h == h_out); + + REQUIRE_THROWS(det_cfg = x.DetectorConfig(net_cfg)); + x.Geometry(DetectorGeometry(3)); + REQUIRE_NOTHROW(det_cfg = x.DetectorConfig(net_cfg)); } \ No newline at end of file