udp ports type pass, disabled with api yet
Build on RHEL9 docker image / build (push) Successful in 4m31s
Build on RHEL8 docker image / build (push) Successful in 5m9s
Run Simulator Tests on local RHEL9 / build (push) Successful in 18m15s
Run Simulator Tests on local RHEL8 / build (push) Successful in 21m53s

This commit is contained in:
2026-05-18 10:50:32 +02:00
parent e39dcb13b8
commit 8bcbc3d594
3 changed files with 135 additions and 25 deletions
@@ -96,6 +96,35 @@ void read_from_h5_dataset(const H5::DataSet &dataset, const std::string &name,
}
#endif
/** std::vector<std::string> */
void read_from_json(const Document &doc, const std::string &name,
std::vector<std::string> &retval) {
for (const auto &item : doc[name.c_str()].GetArray()) {
retval.push_back(item.GetString());
}
}
#ifdef HDF5C
void read_from_h5_dataset(const H5::DataSet &dataset, const std::string &name,
std::vector<std::string> &retval) {
H5::DataSpace dataspace = dataset.getSpace();
hsize_t dims[1];
dataspace.getSimpleExtentDims(dims);
// read to raw c buffer
std::vector<char *> rdata(dims[0]);
auto strType = dataset.getStrType();
dataset.read(rdata.data(), strType);
retval.resize(dims[0]);
for (size_t i = 0; i != dims[0]; ++i) {
retval[i] = std::string(rdata[i]);
}
// free HDF5-allocated memory
H5Dvlen_reclaim(strType.getId(), dataspace.getId(), H5P_DEFAULT,
rdata.data());
}
#endif
/** std::vector<int64_t> */
void read_from_json(const Document &doc, const std::string &name,
std::vector<int64_t> &retval) {
@@ -598,6 +627,47 @@ void test_master_file_num_udp_interfaces(const Detector &det,
num_udp_interfaces));
}
void test_master_file_udp_interfaces_type(const Detector &det,
const std::optional<Document> &doc) {
auto num_udp_interfaces = det.getNumberofUDPInterfaces().tsquash(
"Inconsistent number of UDP interfaces");
if (num_udp_interfaces == 1)
return;
// expected values
auto det_type =
det.getDetectorType().tsquash("Inconsistent detector types to test");
std::vector<std::string> udpPortsType = {ToString(defs::BOTTOM),
ToString(defs::TOP)};
if (det_type == defs::EIGER) {
udpPortsType[0] = ToString(defs::LEFT);
udpPortsType[1] = ToString(defs::RIGHT);
}
REQUIRE_NOTHROW(check_master_file<std::vector<std::string>>(
doc, MasterAttributes::N_UDP_PORTS_TYPE.data(), udpPortsType));
}
void test_master_file_udp_interfaces_disable(
const Detector &det, const std::optional<Document> &doc) {
auto num_udp_interfaces = det.getNumberofUDPInterfaces().tsquash(
"Inconsistent number of UDP interfaces");
if (num_udp_interfaces == 1)
return;
// expected values
// auto disabled_udp_ports = det.getDisabled//
/*
REQUIRE_NOTHROW(check_master_file<int>(
doc, MasterAttributes::N_NUM_UDP_INTERFACES.data(),
num_udp_interfaces));
*/
}
void test_master_file_read_n_rows(const Detector &det,
const std::optional<Document> &doc) {
auto readnrows = det.getReadNRows().tsquash("Inconsistent number of rows");
@@ -888,6 +958,8 @@ void test_master_file_jungfrau_metadata(const Detector &det,
REQUIRE_NOTHROW(test_master_file_exptime(det, doc));
REQUIRE_NOTHROW(test_master_file_period(det, doc));
REQUIRE_NOTHROW(test_master_file_num_udp_interfaces(det, doc));
REQUIRE_NOTHROW(test_master_file_udp_interfaces_type(det, doc));
REQUIRE_NOTHROW(test_master_file_udp_interfaces_disable(det, doc));
REQUIRE_NOTHROW(test_master_file_read_n_rows(det, doc));
REQUIRE_NOTHROW(test_master_file_readout_speed(det, doc));
}
@@ -905,6 +977,8 @@ void test_master_file_eiger_metadata(const Detector &det,
REQUIRE_NOTHROW(test_master_file_sub_exptime(det, doc));
REQUIRE_NOTHROW(test_master_file_sub_period(det, doc));
REQUIRE_NOTHROW(test_master_file_quad(det, doc));
REQUIRE_NOTHROW(test_master_file_udp_interfaces_type(det, doc));
REQUIRE_NOTHROW(test_master_file_udp_interfaces_disable(det, doc));
REQUIRE_NOTHROW(test_master_file_read_n_rows(det, doc));
REQUIRE_NOTHROW(test_master_file_rate_corrections(det, doc));
REQUIRE_NOTHROW(test_master_file_readout_speed(det, doc));
@@ -918,6 +992,8 @@ void test_master_file_moench_metadata(const Detector &det,
REQUIRE_NOTHROW(test_master_file_exptime(det, doc));
REQUIRE_NOTHROW(test_master_file_period(det, doc));
REQUIRE_NOTHROW(test_master_file_num_udp_interfaces(det, doc));
REQUIRE_NOTHROW(test_master_file_udp_interfaces_type(det, doc));
REQUIRE_NOTHROW(test_master_file_udp_interfaces_disable(det, doc));
REQUIRE_NOTHROW(test_master_file_read_n_rows(det, doc));
REQUIRE_NOTHROW(test_master_file_readout_speed(det, doc));
}
+38 -16
View File
@@ -53,6 +53,10 @@ void MasterAttributes::GetJungfrauBinaryAttributes(writer *w) {
WriteBinaryExposureTme(w);
WriteBinaryAcquisitionPeriod(w);
WriteBinaryNumberOfUDPInterfaces(w);
if (numUDPInterfaces == 2) {
WriteBinaryUDPPortsType(w);
WriteBinaryUDPPortsDisabled(w);
}
WriteBinaryNumberOfRows(w);
WriteBinaryReadoutSpeed(w);
}
@@ -63,6 +67,10 @@ void MasterAttributes::WriteJungfrauHDF5Attributes(H5::Group *group) {
WriteHDF5ExposureTime(group);
WriteHDF5AcquisitionPeriod(group);
WriteHDF5NumberOfUDPInterfaces(group);
if (numUDPInterfaces == 2) {
WriteHDF5UDPPortsType(group);
WriteHDF5UDPPortsDisabled(group);
}
WriteHDF5NumberOfRows(group);
WriteHDF5ReadoutSpeed(group);
}
@@ -73,6 +81,10 @@ void MasterAttributes::GetMoenchBinaryAttributes(writer *w) {
WriteBinaryExposureTme(w);
WriteBinaryAcquisitionPeriod(w);
WriteBinaryNumberOfUDPInterfaces(w);
if (numUDPInterfaces == 2) {
WriteBinaryUDPPortsType(w);
WriteBinaryUDPPortsDisabled(w);
}
WriteBinaryNumberOfRows(w);
WriteBinaryReadoutSpeed(w);
}
@@ -83,6 +95,10 @@ void MasterAttributes::WriteMoenchHDF5Attributes(H5::Group *group) {
WriteHDF5ExposureTime(group);
WriteHDF5AcquisitionPeriod(group);
WriteHDF5NumberOfUDPInterfaces(group);
if (numUDPInterfaces == 2) {
WriteHDF5UDPPortsType(group);
WriteHDF5UDPPortsDisabled(group);
}
WriteHDF5NumberOfRows(group);
WriteHDF5ReadoutSpeed(group);
}
@@ -98,6 +114,8 @@ void MasterAttributes::GetEigerBinaryAttributes(writer *w) {
WriteBinarySubExposureTime(w);
WriteBinarySubAcquisitionPeriod(w);
WriteBinaryQuad(w);
WriteBinaryUDPPortsType(w);
WriteBinaryUDPPortsDisabled(w);
WriteBinaryNumberOfRows(w);
WriteBinaryRateCorrections(w);
WriteBinaryReadoutSpeed(w);
@@ -114,6 +132,8 @@ void MasterAttributes::WriteEigerHDF5Attributes(H5::Group *group) {
WriteHDF5SubExposureTime(group);
WriteHDF5SubAcquisitionPeriod(group);
WriteHDF5Quad(group);
WriteHDF5UDPPortsType(group);
WriteHDF5UDPPortsDisabled(group);
WriteHDF5NumberOfRows(group);
WriteHDF5RateCorrections(group);
WriteHDF5ReadoutSpeed(group);
@@ -413,19 +433,11 @@ void MasterAttributes::WriteHDF5AcquisitionPeriod(H5::Group *group) {
void MasterAttributes::WriteBinaryNumberOfUDPInterfaces(writer *w) {
WriteBinary(w, N_NUM_UDP_INTERFACES.data(), numUDPInterfaces);
if (numUDPInterfaces == 2 && detType != defs::GOTTHARD2) {
WriteBinaryUDPPortsType(w);
WriteBinaryUDPPortsDisabled(w);
}
}
#ifdef HDF5C
void MasterAttributes::WriteHDF5NumberOfUDPInterfaces(H5::Group *group) {
WriteHDF5Int(group, N_NUM_UDP_INTERFACES.data(), numUDPInterfaces);
if (numUDPInterfaces == 2 && detType != defs::GOTTHARD2) {
WriteHDF5UDPPortsType(group);
WriteHDF5UDPPortsDisabled(group);
}
}
#endif
@@ -732,15 +744,25 @@ void MasterAttributes::WriteHDF5String(H5::Group *group,
void MasterAttributes::WriteHDF5StringArray(
H5::Group *group, const std::string &name,
const std::vector<std::string> &value) {
std::vector<const char *> c;
for (auto &s : value) {
c.push_back(s.c_str());
try {
std::vector<const char *> c;
for (auto &s : value) {
c.push_back(s.c_str());
}
hsize_t dims[1] = {c.size()};
H5::DataSpace dataspace(1, dims);
H5::StrType strdatatype(H5::PredType::C_S1, H5T_VARIABLE);
H5::DataSet dataset =
group->createDataSet(name, strdatatype, dataspace);
dataset.write(c.data(), strdatatype);
} catch (H5::Exception &e) {
e.printErrorStack();
throw RuntimeError("Could not write attribute " + name +
" in HDf5 file");
} catch (std::exception &e) {
throw RuntimeError("Other excetion: Could not write attribute " + name +
" in HDf5 file. " + std::string(e.what()));
}
hsize_t dims[1] = {c.size()};
H5::DataSpace dataspace(1, dims);
H5::StrType strdatatype(H5::PredType::C_S1, H5T_VARIABLE);
H5::DataSet dataset = group->createDataSet(name, strdatatype, dataspace);
dataset.write(c.data(), strdatatype);
}
#endif
+21 -9
View File
@@ -414,10 +414,16 @@ class MasterAttributes {
template <typename T>
typename std::enable_if<!std::is_class<T>::value, void>::type
WriteHDF5Int(H5::Group *group, const std::string &name, const T &value) {
H5::DataSpace dataspace(H5S_SCALAR);
auto h5type = GetHDF5Type<T>();
H5::DataSet dataset = group->createDataSet(name, *h5type, dataspace);
dataset.write(&value, *h5type);
try {
H5::DataSpace dataspace(H5S_SCALAR);
auto h5type = GetHDF5Type<T>();
H5::DataSet dataset =
group->createDataSet(name, *h5type, dataspace);
dataset.write(&value, *h5type);
} catch (std::exception &e) {
throw RuntimeError("Could not write attribute " + name +
" in HDf5 file");
}
}
/** For arrays */
@@ -425,11 +431,17 @@ class MasterAttributes {
typename std::enable_if<std::is_class<T>::value, void>::type
WriteHDF5Int(H5::Group *group, const std::string &name, const T &value) {
using ElemT = typename T::value_type;
auto h5type = GetHDF5Type<ElemT>();
hsize_t dims[1] = {value.size()};
H5::DataSpace dataspace(1, dims);
H5::DataSet dataset = group->createDataSet(name, *h5type, dataspace);
dataset.write(value.data(), *h5type);
try {
auto h5type = GetHDF5Type<ElemT>();
hsize_t dims[1] = {value.size()};
H5::DataSpace dataspace(1, dims);
H5::DataSet dataset =
group->createDataSet(name, *h5type, dataspace);
dataset.write(value.data(), *h5type);
} catch (std::exception &e) {
throw RuntimeError("Could not write attribute " + name +
" in HDf5 file");
}
}
#endif