mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-02-15 01:38:43 +01:00
format
This commit is contained in:
@@ -1383,9 +1383,7 @@ void Detector::setRxArping(bool value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setRxArping, pos, value);
|
||||
}
|
||||
|
||||
std::vector<defs::ROI> Detector::getRxROI() const {
|
||||
return pimpl->getRxROI();
|
||||
}
|
||||
std::vector<defs::ROI> Detector::getRxROI() const { return pimpl->getRxROI(); }
|
||||
|
||||
std::vector<defs::ROI> Detector::getRxROI(int module_id) const {
|
||||
return pimpl->getRxROI(module_id);
|
||||
@@ -1398,7 +1396,6 @@ void Detector::setRxROI(const std::vector<defs::ROI> &args) {
|
||||
|
||||
void Detector::clearRxROI() { pimpl->clearRxROI(); }
|
||||
|
||||
|
||||
// File
|
||||
|
||||
Result<defs::fileFormat> Detector::getFileFormat(Positions pos) const {
|
||||
|
||||
@@ -1676,7 +1676,7 @@ std::vector<defs::ROI> DetectorImpl::getRxROI(int module_id) const {
|
||||
}
|
||||
if (module_id >= (int)modules.size()) {
|
||||
throw RuntimeError("Invalid module id: " + std::to_string(module_id));
|
||||
}
|
||||
}
|
||||
if (module_id >= 0) {
|
||||
return modules[module_id]->getRxROI();
|
||||
}
|
||||
@@ -1783,9 +1783,10 @@ void DetectorImpl::convertGlobalRoiToPortLevel(
|
||||
throw RuntimeError("Only up to 2 ports per module supported.");
|
||||
}
|
||||
if (numPorts != (int)portRois.size()) {
|
||||
throw RuntimeError("Number of port ROIs does not match number of ports in module. Expected: " +
|
||||
std::to_string(numPorts) + ", got: " +
|
||||
std::to_string(portRois.size()));
|
||||
throw RuntimeError("Number of port ROIs does not match number of ports "
|
||||
"in module. Expected: " +
|
||||
std::to_string(numPorts) +
|
||||
", got: " + std::to_string(portRois.size()));
|
||||
}
|
||||
|
||||
for (int port = 0; port < numPorts; ++port) {
|
||||
@@ -1812,20 +1813,22 @@ void DetectorImpl::convertGlobalRoiToPortLevel(
|
||||
clipped.xmin = std::max(userRoi.xmin, portRoi.xmin) - portRoi.xmin;
|
||||
clipped.xmax = std::min(userRoi.xmax, portRoi.xmax) - portRoi.xmin;
|
||||
LOG(logDEBUG1) << "User ROI: " << ToString(userRoi)
|
||||
<< ", Port ROI: " << ToString(portRoi) << " clipped roi:"<< ToString(clipped);
|
||||
<< ", Port ROI: " << ToString(portRoi)
|
||||
<< " clipped roi:" << ToString(clipped);
|
||||
if (modSize.y > 1) {
|
||||
clipped.ymin = std::max(userRoi.ymin, portRoi.ymin) - portRoi.ymin;
|
||||
clipped.ymax = std::min(userRoi.ymax, portRoi.ymax) - portRoi.ymin;
|
||||
clipped.ymin =
|
||||
std::max(userRoi.ymin, portRoi.ymin) - portRoi.ymin;
|
||||
clipped.ymax =
|
||||
std::min(userRoi.ymax, portRoi.ymax) - portRoi.ymin;
|
||||
}
|
||||
LOG(logDEBUG1) << "Clipped ROI for port " << port
|
||||
<< ": " << ToString(clipped);
|
||||
LOG(logDEBUG1) << "Clipped ROI for port " << port << ": "
|
||||
<< ToString(clipped);
|
||||
|
||||
// Check if port ROI already exists for this port
|
||||
if (!portRois[port].completeRoi() && !portRois[port].noRoi()) {
|
||||
throw RuntimeError(
|
||||
"Multiple ROIs specified for the same port " +
|
||||
std::to_string(port) +
|
||||
" with ROI: " + ToString(userRoi));
|
||||
std::to_string(port) + " with ROI: " + ToString(userRoi));
|
||||
}
|
||||
portRois[port] = clipped;
|
||||
}
|
||||
@@ -1846,12 +1849,14 @@ void DetectorImpl::setRxROI(const std::vector<defs::ROI> &args) {
|
||||
}
|
||||
|
||||
validateROIs(args);
|
||||
int nPortsPerModule = Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).tsquash("Inconsistent number of udp ports set up per module");
|
||||
int nPortsPerModule =
|
||||
Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
||||
.tsquash("Inconsistent number of udp ports set up per module");
|
||||
|
||||
for (size_t iModule = 0; iModule < modules.size(); ++iModule) {
|
||||
auto moduleGlobalRoi = getModuleROI(iModule);
|
||||
LOG(logDEBUG1) << "Module " << iModule
|
||||
<< " Global ROI: " << ToString(moduleGlobalRoi);
|
||||
<< " Global ROI: " << ToString(moduleGlobalRoi);
|
||||
|
||||
// at most 2 rois per module (for each port)
|
||||
std::vector<defs::ROI> portRois(nPortsPerModule);
|
||||
@@ -1865,8 +1870,8 @@ void DetectorImpl::setRxROI(const std::vector<defs::ROI> &args) {
|
||||
// print the rois for debugging
|
||||
LOG(logDEBUG1) << "Module " << iModule << " RxROIs:";
|
||||
for (size_t iPort = 0; iPort != portRois.size(); iPort++) {
|
||||
LOG(logDEBUG1)
|
||||
<< " Port " << iPort << ": " << ToString(portRois[iPort]);
|
||||
LOG(logDEBUG1) << " Port " << iPort << ": "
|
||||
<< ToString(portRois[iPort]);
|
||||
}
|
||||
modules[iModule]->setRxROI(portRois);
|
||||
}
|
||||
@@ -1874,10 +1879,12 @@ void DetectorImpl::setRxROI(const std::vector<defs::ROI> &args) {
|
||||
modules[0]->setRxROIMetadata(args);
|
||||
}
|
||||
|
||||
void DetectorImpl::clearRxROI() {
|
||||
int nPortsPerModule = Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).tsquash("Inconsistent number of udp ports set up per module");
|
||||
void DetectorImpl::clearRxROI() {
|
||||
int nPortsPerModule =
|
||||
Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
||||
.tsquash("Inconsistent number of udp ports set up per module");
|
||||
for (size_t iModule = 0; iModule < modules.size(); ++iModule) {
|
||||
modules[iModule]->setRxROI(std::vector<defs::ROI>(nPortsPerModule));
|
||||
modules[iModule]->setRxROI(std::vector<defs::ROI>(nPortsPerModule));
|
||||
}
|
||||
modules[0]->setRxROIMetadata(std::vector<defs::ROI>(1));
|
||||
}
|
||||
|
||||
@@ -428,9 +428,9 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
void validateROIs(const std::vector<defs::ROI> &rois);
|
||||
defs::xy calculatePosition(int moduleIndex) const;
|
||||
defs::ROI getModuleROI(int moduleIndex) const;
|
||||
void convertGlobalRoiToPortLevel(
|
||||
const defs::ROI &userRoi, const defs::ROI &moduleRoi,
|
||||
std::vector<defs::ROI> &portRois) const;
|
||||
void convertGlobalRoiToPortLevel(const defs::ROI &userRoi,
|
||||
const defs::ROI &moduleRoi,
|
||||
std::vector<defs::ROI> &portRois) const;
|
||||
|
||||
const int detectorIndex{0};
|
||||
SharedMemory<sharedDetector> shm{0, -1};
|
||||
|
||||
@@ -1526,7 +1526,7 @@ std::vector<defs::ROI> Module::getRxROI() const {
|
||||
// check number of ports
|
||||
if (!shm()->useReceiverFlag) {
|
||||
throw RuntimeError("No receiver to get ROI.");
|
||||
}
|
||||
}
|
||||
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
client.Send(F_RECEIVER_GET_RECEIVER_ROI);
|
||||
client.setFnum(F_RECEIVER_GET_RECEIVER_ROI);
|
||||
@@ -1561,12 +1561,12 @@ void Module::setRxROI(const std::vector<defs::ROI> &portRois) {
|
||||
client.setFnum(F_RECEIVER_SET_RECEIVER_ROI);
|
||||
int size = static_cast<int>(portRois.size());
|
||||
client.Send(size);
|
||||
if (size > 0)
|
||||
if (size > 0)
|
||||
client.Send(portRois);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw ReceiverError("Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<slsDetectorDefs::ROI> Module::getRxROIMetadata() const {
|
||||
@@ -1587,8 +1587,7 @@ std::vector<slsDetectorDefs::ROI> Module::getRxROIMetadata() const {
|
||||
throw RuntimeError("Invalid number of ROI metadata: " +
|
||||
std::to_string(size) + ". Min: 1.");
|
||||
}
|
||||
LOG(logDEBUG1) << "ROI metadata of Receiver: "
|
||||
<< ToString(retval);
|
||||
LOG(logDEBUG1) << "ROI metadata of Receiver: " << ToString(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user