fixed disabled ports meta data as well
Build on RHEL9 docker image / build (push) Successful in 4m13s
Build on RHEL8 docker image / build (push) Successful in 5m42s
Run Simulator Tests on local RHEL9 / build (push) Successful in 18m14s
Run Simulator Tests on local RHEL8 / build (push) Successful in 21m48s

This commit is contained in:
2026-05-18 12:35:00 +02:00
parent 8bcbc3d594
commit fdff143082
12 changed files with 141 additions and 46 deletions
+12 -1
View File
@@ -914,7 +914,18 @@ class Detector {
void setDataStream(const defs::portPosition port, const bool enable,
Positions pos = {});
/* list of possible port positions */
/** List of disabled udp ports with index (moduleIndex * 2 + portIndex),
* where portIndex is 0 for BOTTOM/LEFT port, and 1 for TOP/RIGHT port
* [Eiger] LEFT, RIGHT
* [Jungfrau][Moench] throws for single UDP interface. Otherwise, TOP,
* BOTTOM
*/
std::vector<int> getRxDisabledUDPPortIndices() const;
/* list of possible port positions.
* [Eiger] TOP, BOTTOM
* [Jungfrau][Moench] LEFT, RIGHT
*/
std::vector<defs::portPosition> getPortPositionList() const;
///@}
+6 -12
View File
@@ -1319,22 +1319,16 @@ void Detector::setTransmissionDelay(int step) {
Result<bool> Detector::getDataStream(const defs::portPosition port,
Positions pos) const {
return pimpl->Parallel(&Module::getDataStream, pos, port);
return pimpl->getDataStream(port, pos);
}
void Detector::setDataStream(const defs::portPosition port, const bool enable,
Positions pos) {
// check num interfaces
auto numInterfaces =
pimpl->Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
.tsquash("Inconsistent number of UDP interfaces among modules");
if (numInterfaces != 2) {
throw RuntimeError(
"Cannot enable/disable individual udp ports. Change number of udp "
"interfaces to 2 (cmd = numinterfaces).");
}
pimpl->Parallel(&Module::setDataStream, pos, port, enable);
pimpl->updateRxUDPDatastreamMetadata();
pimpl->setDataStream(port, enable, pos);
}
std::vector<int> Detector::getRxDisabledUDPPortIndices() const {
return pimpl->getRxDisabledUDPPortIndices();
}
std::vector<defs::portPosition> Detector::getPortPositionList() const {
+39 -15
View File
@@ -1644,26 +1644,33 @@ void DetectorImpl::verifyUniqueHost(
}
}
std::vector<defs::portPosition> DetectorImpl::getPortPositionList() const {
switch (shm()->detType) {
case defs::JUNGFRAU:
case defs::MOENCH:
return std::vector<defs::portPosition>{defs::BOTTOM, defs::TOP};
case defs::EIGER:
return std::vector<defs::portPosition>{defs::LEFT, defs::RIGHT};
default:
throw RuntimeError("port Position does not exist for this detector");
}
}
void DetectorImpl::updateRxUDPDatastreamMetadata() {
// check num interfaces
void DetectorImpl::assertTwoUDPInterfaces(const std::string &cmd) const {
// assert globally
auto numInterfaces =
Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
.tsquash("Inconsistent number of UDP interfaces among modules");
if (numInterfaces != 2) {
throw RuntimeError("Invalid number of UDP interfaces. Expected 2.");
throw RuntimeError(
"Cannot " + cmd +
". Change number of udp interfaces to 2 (cmd = numinterfaces).");
}
}
Result<bool> DetectorImpl::getDataStream(const defs::portPosition port,
Positions pos) const {
assertTwoUDPInterfaces("get enable/disable UDP ports");
return Parallel(&Module::getDataStream, pos, port);
}
void DetectorImpl::setDataStream(const defs::portPosition port,
const bool enable, Positions pos) {
assertTwoUDPInterfaces("set enable/disable UDP ports");
Parallel(&Module::setDataStream, pos, port, enable);
updateRxUDPDatastreamMetadata();
}
void DetectorImpl::updateRxUDPDatastreamMetadata() {
assertTwoUDPInterfaces("update Disbaled UDP ports metadata in receiver");
std::vector<int> disable;
auto portList = getPortPositionList();
@@ -1690,6 +1697,23 @@ void DetectorImpl::updateRxUDPDatastreamMetadata() {
modules[0]->updateRxUDPPortDisableMetadata(disable);
}
std::vector<int> DetectorImpl::getRxDisabledUDPPortIndices() const {
assertTwoUDPInterfaces("get Disbaled UDP ports metadata from receiver");
return modules[0]->getRxUDPPortDisableMetadata();
}
std::vector<defs::portPosition> DetectorImpl::getPortPositionList() const {
switch (shm()->detType) {
case defs::JUNGFRAU:
case defs::MOENCH:
return std::vector<defs::portPosition>{defs::BOTTOM, defs::TOP};
case defs::EIGER:
return std::vector<defs::portPosition>{defs::LEFT, defs::RIGHT};
default:
throw RuntimeError("port Position does not exist for this detector");
}
}
std::vector<defs::ROI> DetectorImpl::getRxROI(int module_id) const {
if (shm()->detType == CHIPTESTBOARD ||
shm()->detType == defs::XILINX_CHIPTESTBOARD) {
+7 -1
View File
@@ -310,8 +310,14 @@ class DetectorImpl : public virtual slsDetectorDefs {
std::vector<std::pair<std::string, uint16_t>>
verifyUniqueRxHost(const std::vector<std::string> &names) const;
std::vector<defs::portPosition> getPortPositionList() const;
void assertTwoUDPInterfaces(const std::string &cmd) const;
Result<bool> getDataStream(const defs::portPosition port,
Positions pos) const;
void setDataStream(const defs::portPosition port, const bool enable,
Positions pos);
void updateRxUDPDatastreamMetadata();
std::vector<int> getRxDisabledUDPPortIndices() const;
std::vector<defs::portPosition> getPortPositionList() const;
defs::xy getPortGeometry() const;
std::vector<defs::ROI> getRxROI(int module_id = -1) const;
+25 -2
View File
@@ -1441,8 +1441,8 @@ void Module::updateRxUDPPortDisableMetadata(const std::vector<int> &disable) {
LOG(logDEBUG) << "Updating UDP port disable metadata in Receiver 0";
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
client.Send(F_RECEIVER_UDP_PORT_DISABLE_META);
client.setFnum(F_RECEIVER_UDP_PORT_DISABLE_META);
client.Send(F_RECEIVER_SET_UDP_PORT_DISABLE_META);
client.setFnum(F_RECEIVER_SET_UDP_PORT_DISABLE_META);
auto nports = static_cast<int>(disable.size());
client.Send(nports);
@@ -1455,6 +1455,29 @@ void Module::updateRxUDPPortDisableMetadata(const std::vector<int> &disable) {
}
}
std::vector<int> Module::getRxUDPPortDisableMetadata() const {
if (!shm()->useReceiverFlag) {
throw RuntimeError("No receiver to get disabled udp port indices.");
}
LOG(logDEBUG) << "Getting UDP port disable metadata in Receiver 0";
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
client.Send(F_RECEIVER_GET_UDP_PORT_DISABLE_META);
client.setFnum(F_RECEIVER_GET_UDP_PORT_DISABLE_META);
if (client.Receive<int>() == FAIL) {
throw ReceiverError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
auto nports = client.Receive<int>();
std::vector<int> retval(nports);
client.Send(nports);
if (nports > 0) {
client.Receive(retval);
}
return retval;
}
// Receiver Config
bool Module::getUseReceiverFlag() const { return shm()->useReceiverFlag; }
+1
View File
@@ -282,6 +282,7 @@ class Module : public virtual slsDetectorDefs {
bool getDataStream(const portPosition port) const;
void setDataStream(const portPosition port, const bool enable);
void updateRxUDPPortDisableMetadata(const std::vector<int> &disable);
std::vector<int> getRxUDPPortDisableMetadata() const;
/**************************************************
* *
@@ -125,6 +125,24 @@ void read_from_h5_dataset(const H5::DataSet &dataset, const std::string &name,
}
#endif
/** std::vector<int> */
void read_from_json(const Document &doc, const std::string &name,
std::vector<int> &retval) {
for (const auto &item : doc[name.c_str()].GetArray()) {
retval.push_back(item.GetInt());
}
}
#ifdef HDF5C
void read_from_h5_dataset(const H5::DataSet &dataset, const std::string &name,
std::vector<int> &retval) {
H5::DataSpace dataspace = dataset.getSpace();
hsize_t dims[1];
dataspace.getSimpleExtentDims(dims);
retval.resize(dims[0]);
dataset.read(retval.data(), H5::PredType::STD_I32LE);
}
#endif
/** std::vector<int64_t> */
void read_from_json(const Document &doc, const std::string &name,
std::vector<int64_t> &retval) {
@@ -658,14 +676,10 @@ void test_master_file_udp_interfaces_disable(
if (num_udp_interfaces == 1)
return;
// expected values
// auto disabled_udp_ports = det.getDisabled//
auto disabled_udp_ports = det.getRxDisabledUDPPortIndices();
/*
REQUIRE_NOTHROW(check_master_file<int>(
doc, MasterAttributes::N_NUM_UDP_INTERFACES.data(),
num_udp_interfaces));
*/
REQUIRE_NOTHROW(check_master_file<std::vector<int>>(
doc, MasterAttributes::N_UDP_PORTS_DISBLED.data(), disabled_udp_ports));
}
void test_master_file_read_n_rows(const Detector &det,
+17 -3
View File
@@ -222,7 +222,8 @@ int ClientInterface::functionTable(){
flist[F_RECEIVER_GET_ROI_METADATA] = &ClientInterface::get_roi_metadata;
flist[F_SET_RECEIVER_READOUT_SPEED] = &ClientInterface::set_readout_speed;
flist[F_RECEIVER_GET_UDP_DATASTREAM] = &ClientInterface::get_port_udp_datastream;
flist[F_RECEIVER_UDP_PORT_DISABLE_META] = &ClientInterface::update_udp_port_disable_meta;
flist[F_RECEIVER_SET_UDP_PORT_DISABLE_META] = &ClientInterface::set_udp_port_disable_meta;
flist[F_RECEIVER_GET_UDP_PORT_DISABLE_META] = &ClientInterface::get_udp_port_disable_meta;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
@@ -1918,7 +1919,7 @@ int ClientInterface::set_readout_speed(Interface &socket) {
return socket.Send(OK);
}
int ClientInterface::update_udp_port_disable_meta(Interface &socket) {
int ClientInterface::set_udp_port_disable_meta(Interface &socket) {
auto nports = socket.Receive<int>();
std::vector<int> portsDisabled;
if (nports > 0) {
@@ -1928,7 +1929,8 @@ int ClientInterface::update_udp_port_disable_meta(Interface &socket) {
}
verifyIdle(socket);
try {
impl()->updateUDPPortsDisabledMetadata(portsDisabled);
impl()->setUDPPortsDisabledMetadata(portsDisabled);
} catch (const std::exception &e) {
throw RuntimeError("Could not update UDP ports disabled metadata [" +
std::string(e.what()) + ']');
@@ -1936,4 +1938,16 @@ int ClientInterface::update_udp_port_disable_meta(Interface &socket) {
return socket.Send(OK);
}
int ClientInterface::get_udp_port_disable_meta(Interface &socket) {
auto retvals = impl()->getUDPPortsDisabledMetadata();
LOG(logDEBUG1) << "Receiver disabled udp ports retval:"
<< ToString(retvals);
socket.Send(OK);
auto size = static_cast<int>(retvals.size());
socket.Send(size);
if (size > 0)
socket.Send(retvals);
return OK;
}
} // namespace sls
+2 -1
View File
@@ -170,7 +170,8 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_dbit_reorder(ServerInterface &socket);
int get_roi_metadata(ServerInterface &socket);
int set_readout_speed(ServerInterface &socket);
int update_udp_port_disable_meta(ServerInterface &socket);
int set_udp_port_disable_meta(ServerInterface &socket);
int get_udp_port_disable_meta(ServerInterface &socket);
Implementation *impl() {
if (receiver != nullptr) {
+5 -1
View File
@@ -1715,11 +1715,15 @@ void Implementation::setUDPDataStream(const portPosition port,
listener[i]->SetUDPDatastream(udpDataStream[i]);
}
void Implementation::updateUDPPortsDisabledMetadata(
void Implementation::setUDPPortsDisabledMetadata(
const std::vector<int> &portsDisabled) {
udpPortsDisabledMetadata = portsDisabled;
}
std::vector<int> Implementation::getUDPPortsDisabledMetadata() const {
return udpPortsDisabledMetadata;
}
int Implementation::getReadNRows() const { return readNRows; }
void Implementation::setReadNRows(const int value) {
+2 -1
View File
@@ -230,7 +230,8 @@ class Implementation : private virtual slsDetectorDefs {
* [Eiger] deactivated at module level
*/
void setUDPDataStream(const portPosition port, const bool enable);
void updateUDPPortsDisabledMetadata(const std::vector<int> &portsDisabled);
void setUDPPortsDisabledMetadata(const std::vector<int> &portsDisabled);
std::vector<int> getUDPPortsDisabledMetadata() const;
int getReadNRows() const;
/* [Eiger][Jungfrau][Moench] */
void setReadNRows(const int value);
@@ -424,7 +424,8 @@ enum detFuncs {
F_RECEIVER_GET_ROI_METADATA,
F_SET_RECEIVER_READOUT_SPEED,
F_RECEIVER_GET_UDP_DATASTREAM,
F_RECEIVER_UDP_PORT_DISABLE_META,
F_RECEIVER_SET_UDP_PORT_DISABLE_META,
F_RECEIVER_GET_UDP_PORT_DISABLE_META,
NUM_REC_FUNCTIONS
};
@@ -845,7 +846,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_RECEIVER_GET_ROI_METADATA: return "F_RECEIVER_GET_ROI_METADATA";
case F_SET_RECEIVER_READOUT_SPEED: return "F_SET_RECEIVER_READOUT_SPEED";
case F_RECEIVER_GET_UDP_DATASTREAM: return "F_RECEIVER_GET_UDP_DATASTREAM";
case F_RECEIVER_UDP_PORT_DISABLE_META: return "F_RECEIVER_UDP_PORT_DISABLE_META";
case F_RECEIVER_SET_UDP_PORT_DISABLE_META: return "F_RECEIVER_SET_UDP_PORT_DISABLE_META";
case F_RECEIVER_GET_UDP_PORT_DISABLE_META: return "F_RECEIVER_GET_UDP_PORT_DISABLE_META";
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";