DetectorSetup: Configure UDP interface count

This commit is contained in:
2023-09-20 14:00:10 +02:00
parent aa3d9e5edb
commit 6cbd577824
9 changed files with 137 additions and 103 deletions
+1
View File
@@ -197,6 +197,7 @@ DetectorSetup ParseDetectorSetup(const nlohmann::json &j) {
if (!gain_files.empty())
setup.LoadGain(gain_files);
setup.UDPInterfaceCount(GET_I64(j, "udp_interface_count", 2));
return setup;
}
+9 -1
View File
@@ -47,6 +47,14 @@ void DetectorSetup::LoadGain(const std::vector<std::string> &filenames) {
gain_calibration.emplace_back(i);
}
DetectorSetup &DetectorSetup::UDPInterfaceCount(int64_t input) {
if ((input != 1) && (input != 2))
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Only 1 and 2 are supported as UDP interface count");
udp_interface_count = input;
return *this;
}
const std::vector<JFModuleGainCalibration> &DetectorSetup::GetGainCalibration() const {
return gain_calibration;
}
@@ -56,7 +64,7 @@ DetectorSetup::operator JFJochProtoBuf::Detector() const {
ret.set_nmodules(GetModulesNum());
ret.set_description(GetDescription());
ret.set_pixel_size_mm(GetPixelSize_mm());
ret.set_udp_interface_count(udp_interface_count);
for (const auto& iter: det_modules_hostname)
ret.add_module_hostname(iter);
+2
View File
@@ -11,6 +11,7 @@ class DetectorSetup {
DetectorGeometry geometry;
std::vector<std::string> det_modules_hostname;
std::vector<JFModuleGainCalibration> gain_calibration;
int64_t udp_interface_count = 2;
public:
DetectorSetup(const DetectorGeometry& geom);
DetectorSetup(const DetectorGeometry& geom,
@@ -19,6 +20,7 @@ public:
void LoadGain(const std::vector<std::string> &filenames);
DetectorSetup& UDPInterfaceCount(int64_t input);
[[nodiscard]] const DetectorGeometry& GetGeometry() const;
[[nodiscard]] const std::vector<std::string>& GetDetectorModuleHostname() const;
[[nodiscard]] uint64_t GetModulesNum() const;
+2
View File
@@ -858,6 +858,8 @@ JFJochProtoBuf::DetectorConfig DiffractionExperiment::DetectorConfig(const JFJoc
if (!internal.detector().module_hostname().empty())
*ret.mutable_module_hostname() = internal.detector().module_hostname();
ret.set_udp_interface_count(internal.detector().udp_interface_count());
for (int d = 0; d < GetDataStreamsNum(); d++) {
for (int m = 0; m < GetModulesNum(d); m++) {
auto mod_cfg = ret.add_modules();
+11 -6
View File
@@ -33,7 +33,10 @@ void DetectorWrapper::Configure(const JFJochProtoBuf::DetectorConfig &request) {
"Discrepancy in module number between DAQ and detector");
}
det.setNumberofUDPInterfaces(2);
if ((request.udp_interface_count() != 1) && (request.udp_interface_count() != 2))
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Only 1 and 2 are supported as UDP interface count");
det.setNumberofUDPInterfaces(request.udp_interface_count());
for (int i = 0; i < request.modules_size(); i++) {
logger.Info("Configure network for module {}", i);
@@ -41,17 +44,19 @@ void DetectorWrapper::Configure(const JFJochProtoBuf::DetectorConfig &request) {
auto &cfg = request.modules(i);
det.setSourceUDPIP(sls::IpAddr(cfg.ipv4_src_addr_1()), {i});
det.setSourceUDPIP2(sls::IpAddr(cfg.ipv4_src_addr_2()), {i});
det.setSourceUDPMAC(sls::MacAddr(BASE_DETECTOR_MAC + i * 2), {i});
det.setSourceUDPMAC2(sls::MacAddr(BASE_DETECTOR_MAC + i * 2 + 1), {i});
det.setDestinationUDPPort (cfg.udp_dest_port_1(), i);
det.setDestinationUDPPort2(cfg.udp_dest_port_2(), i);
det.setDestinationUDPIP( sls::IpAddr(cfg.ipv4_dest_addr_1()), {i});
det.setDestinationUDPIP2( sls::IpAddr(cfg.ipv4_dest_addr_2()), {i});
det.setDestinationUDPMAC( sls::MacAddr(cfg.mac_addr_dest_1()), {i});
det.setDestinationUDPMAC2(sls::MacAddr(cfg.mac_addr_dest_2()), {i});
if (request.udp_interface_count() == 2) {
det.setSourceUDPIP2(sls::IpAddr(cfg.ipv4_src_addr_2()), {i});
det.setSourceUDPMAC2(sls::MacAddr(BASE_DETECTOR_MAC + i * 2 + 1), {i});
det.setDestinationUDPPort2(cfg.udp_dest_port_2(), i);
det.setDestinationUDPIP2( sls::IpAddr(cfg.ipv4_dest_addr_2()), {i});
det.setDestinationUDPMAC2(sls::MacAddr(cfg.mac_addr_dest_2()), {i});
}
uint32_t tmp = (cfg.module_id_in_data_stream() * 2) % UINT16_MAX;
uint32_t column_id_register = ((tmp + 1) << 16) | tmp;
+2
View File
@@ -147,6 +147,7 @@ message Detector {
repeated string module_hostname = 4;
DetectorGeometry geometry = 5;
DetectorType type = 6;
int64 udp_interface_count = 7;
}
message InternalSettings {
@@ -335,6 +336,7 @@ message DetectorModuleConfig {
message DetectorConfig {
repeated DetectorModuleConfig modules = 1;
repeated string module_hostname = 2;
int64 udp_interface_count = 3;
}
message DetectorInput {
+96 -96
View File
File diff suppressed because one or more lines are too long
+12
View File
@@ -21,6 +21,18 @@ TEST_CASE("DetectorSetup_ProtoBuf") {
REQUIRE(detector.geometry().module_geometry_size() == 4);
}
TEST_CASE("DetectorSetup_ProtoBuf_FullSpeed") {
DetectorSetup setup(DetectorGeometry(4), "JF", {"mx1","mx2","mx3","mx4"});
JFJochProtoBuf::Detector detector = setup;
REQUIRE(detector.udp_interface_count() == 2);
REQUIRE_NOTHROW(setup.UDPInterfaceCount(1));
REQUIRE_THROWS(setup.UDPInterfaceCount(0));
REQUIRE_THROWS(setup.UDPInterfaceCount(5));
REQUIRE_THROWS(setup.UDPInterfaceCount(-56));
detector = setup;
REQUIRE(detector.udp_interface_count() == 1);
}
TEST_CASE("DetectorSetup_LoadGainFile") {
DetectorSetup setup(DetectorGeometry(4), "JF", {"mx1","mx2","mx3","mx4"});
REQUIRE_THROWS(setup.LoadGain({}));
+2
View File
@@ -73,6 +73,7 @@ TEST_CASE("JFJochBrokerParser_DetectorSetup") {
"mirror_y": false
},
"description": "PSI JUNGFRAU 2M",
"udp_interface_count": 1,
"module_hostname": ["mx1", "mx2", "mx3", "mx4"],
"gain_files": [
"../../tests/test_data/gainMaps_M049.bin",
@@ -93,6 +94,7 @@ TEST_CASE("JFJochBrokerParser_DetectorSetup") {
REQUIRE(detector_pbuf.module_hostname_size() == 4);
REQUIRE(detector_pbuf.module_hostname(2) == "mx3");
REQUIRE(detector.GetGainCalibration().size() == 4);
REQUIRE(detector_pbuf.udp_interface_count() == 1);
}
TEST_CASE("JFJochBrokerParser_ParseFacilityConfiguration") {