mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-08-10 10:10:29 +02:00
fixed disabled ports meta data as well
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
|
||||
Reference in New Issue
Block a user