mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-02-14 02:28:41 +01:00
can get individual rois, but not connected to command yet
This commit is contained in:
@@ -739,14 +739,7 @@ std::string Caller::rx_roi(int action) {
|
||||
throw RuntimeError("Cannot execute receiver ROI at module level");
|
||||
} else {
|
||||
auto t = det->getRxROI();
|
||||
// os << ToString(t) << '\n';
|
||||
for (const auto &r : t) {
|
||||
os << r << ';';
|
||||
}
|
||||
if (!t.empty()) {
|
||||
os.seekp(-1, std::ios_base::end); // remove trailing ;
|
||||
}
|
||||
os << '\n';
|
||||
os << ToString(t) << '\n';
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
std::vector<defs::ROI> rois;
|
||||
@@ -789,14 +782,7 @@ std::string Caller::rx_roi(int action) {
|
||||
}
|
||||
|
||||
det->setRxROI(rois);
|
||||
// os << ToString(rois) << '\n';
|
||||
for (const auto &r : rois) {
|
||||
os << r << ';';
|
||||
}
|
||||
//if (!rois.empty()) {
|
||||
// os.seekp(-1, std::ios_base::end); // remove trailing ;
|
||||
//}
|
||||
os << '\n';
|
||||
os << ToString(rois) << '\n';
|
||||
} else {
|
||||
throw RuntimeError("Unknown action");
|
||||
}
|
||||
|
||||
@@ -1383,7 +1383,13 @@ 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();
|
||||
}
|
||||
|
||||
Result<std::array<defs::ROI, 2>> Detector::getRxROI(int module_id) const {
|
||||
return pimpl->Parallel(&Module::getRxROI, {module_id});
|
||||
}
|
||||
|
||||
// RxROIs can be set for all types except CTB. At multi level without gap pixels
|
||||
void Detector::setRxROI(const std::vector<defs::ROI> &args) {
|
||||
@@ -1392,9 +1398,6 @@ void Detector::setRxROI(const std::vector<defs::ROI> &args) {
|
||||
|
||||
void Detector::clearRxROI() { pimpl->clearRxROI(); }
|
||||
|
||||
int Detector::getNumberOfUdpPortsInRxROI() const {
|
||||
return pimpl->getNumberOfUdpPortsInRxROI();
|
||||
}
|
||||
|
||||
// File
|
||||
|
||||
|
||||
@@ -1791,7 +1791,7 @@ defs::ROI DetectorImpl::getModuleROI(int moduleIndex) const {
|
||||
|
||||
void DetectorImpl::convertGlobalRoiToPortLevel(
|
||||
const defs::ROI &userRoi, const defs::ROI &moduleRoi,
|
||||
std::vector<std::map<int, defs::ROI>> &portRois) const {
|
||||
std::array<defs::ROI, 2> &portRois) const {
|
||||
const defs::xy modSize = modules[0]->getNumberOfChannels();
|
||||
const defs::xy geometry = getPortGeometry();
|
||||
const int numPorts = geometry.x * geometry.y;
|
||||
@@ -1827,16 +1827,13 @@ void DetectorImpl::convertGlobalRoiToPortLevel(
|
||||
}
|
||||
|
||||
// Check if port ROI already exists for this port
|
||||
for (const auto &m : portRois) {
|
||||
if (m.find(port) != m.end()) {
|
||||
throw RuntimeError(
|
||||
"Multiple ROIs specified for the same port " +
|
||||
std::to_string(port) +
|
||||
" with ROI: " + ToString(userRoi));
|
||||
}
|
||||
if (!portRois[port].completeRoi()) {
|
||||
throw RuntimeError(
|
||||
"Multiple ROIs specified for the same port " +
|
||||
std::to_string(port) +
|
||||
" with ROI: " + ToString(userRoi));
|
||||
}
|
||||
|
||||
portRois.push_back({{port, clipped}});
|
||||
portRois[port] = clipped;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1856,7 +1853,7 @@ void DetectorImpl::setRxROI(const std::vector<defs::ROI> &args) {
|
||||
auto moduleGlobalRoi = getModuleROI(iModule);
|
||||
|
||||
// at most 2 rois per module (for each port)
|
||||
std::vector<std::map<int, defs::ROI>> portRois;
|
||||
std::array<defs::ROI, 2> portRois{};
|
||||
|
||||
for (const auto &arg : args) {
|
||||
if (roisOverlap(arg, moduleGlobalRoi)) {
|
||||
@@ -1865,18 +1862,23 @@ void DetectorImpl::setRxROI(const std::vector<defs::ROI> &args) {
|
||||
}
|
||||
// print the rois for debugging
|
||||
LOG(logINFOBLUE) << "Module " << iModule << " RxROIs:";
|
||||
for (const auto &portRoi : portRois) {
|
||||
for (const auto &roi : portRoi) {
|
||||
LOG(logINFOBLUE)
|
||||
<< " Port " << roi.first << ": " << ToString(roi.second);
|
||||
}
|
||||
for (size_t iPort = 0; iPort != 2; iPort++) {
|
||||
LOG(logINFOBLUE)
|
||||
<< " Port " << iPort << ": " << ToString(portRois[iPort]);
|
||||
}
|
||||
// modules[iModule]->setRxROIs(portRois); TODO
|
||||
modules[iModule]->setRxROI(portRois);
|
||||
}
|
||||
rxRoiTemp = args;
|
||||
// metadata
|
||||
modules[0]->setRxROIMetadata(args);
|
||||
}
|
||||
|
||||
void DetectorImpl::clearRxROI() { rxRoiTemp.clear(); }
|
||||
void DetectorImpl::clearRxROI() {
|
||||
rxRoiTemp.clear();
|
||||
for (size_t iModule = 0; iModule < modules.size(); ++iModule) {
|
||||
modules[iModule]->setRxROI(std::array<defs::ROI, 2>{});
|
||||
}
|
||||
}
|
||||
|
||||
int DetectorImpl::getNumberOfUdpPortsInRxROI() const {
|
||||
return 0; // TODO
|
||||
|
||||
@@ -433,7 +433,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
defs::ROI getModuleROI(int moduleIndex) const;
|
||||
void convertGlobalRoiToPortLevel(
|
||||
const defs::ROI &userRoi, const defs::ROI &moduleRoi,
|
||||
std::vector<std::map<int, defs::ROI>> &portRois) const;
|
||||
std::array<defs::ROI, 2> &portRois) const;
|
||||
|
||||
const int detectorIndex{0};
|
||||
SharedMemory<sharedDetector> shm{0, -1};
|
||||
|
||||
@@ -1520,20 +1520,29 @@ bool Module::getRxArping() const {
|
||||
void Module::setRxArping(bool enable) {
|
||||
sendToReceiver(F_SET_RECEIVER_ARPING, static_cast<int>(enable), nullptr);
|
||||
}
|
||||
/*
|
||||
defs::ROI Module::getRxROI() const {
|
||||
return sendToReceiver<slsDetectorDefs::ROI>(F_RECEIVER_GET_RECEIVER_ROI);
|
||||
|
||||
std::array<defs::ROI, 2> Module::getRxROI() const {
|
||||
return sendToReceiver<std::array<slsDetectorDefs::ROI, 2>>(F_RECEIVER_GET_RECEIVER_ROI);
|
||||
}
|
||||
|
||||
void Module::setRxROI(const slsDetectorDefs::ROI arg) {
|
||||
LOG(logDEBUG) << moduleIndex << ": " << arg;
|
||||
sendToReceiver(F_RECEIVER_SET_RECEIVER_ROI, arg, nullptr);
|
||||
void Module::setRxROI(std::array<defs::ROI, 2> portRois) {
|
||||
/*LOG(logDEBUG) << "Sending to receiver " << moduleIndex << " [rx roi: " << ToString(portRois)
|
||||
<< ']';
|
||||
auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
receiver.Send(F_RECEIVER_SET_RECEIVER_ROI);
|
||||
receiver.setFnum(F_RECEIVER_SET_RECEIVER_ROI);
|
||||
receiver.Send(portRois);
|
||||
if (receiver.Receive<int>() == FAIL) {
|
||||
throw ReceiverError("Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + receiver.readErrorMessage());
|
||||
}*/
|
||||
sendToReceiver(F_RECEIVER_SET_RECEIVER_ROI, portRois, nullptr);
|
||||
}
|
||||
|
||||
void Module::setRxROIMetadata(const slsDetectorDefs::ROI arg) {
|
||||
void Module::setRxROIMetadata(const std::vector<slsDetectorDefs::ROI> &arg) {
|
||||
sendToReceiver(F_RECEIVER_SET_RECEIVER_ROI_METADATA, arg, nullptr);
|
||||
}
|
||||
*/
|
||||
|
||||
// File
|
||||
slsDetectorDefs::fileFormat Module::getFileFormat() const {
|
||||
return sendToReceiver<fileFormat>(F_GET_RECEIVER_FILE_FORMAT);
|
||||
|
||||
@@ -301,9 +301,9 @@ class Module : public virtual slsDetectorDefs {
|
||||
std::array<pid_t, NUM_RX_THREAD_IDS> getReceiverThreadIds() const;
|
||||
bool getRxArping() const;
|
||||
void setRxArping(bool enable);
|
||||
// defs::ROI getRxROI() const;
|
||||
// void setRxROI(const slsDetectorDefs::ROI arg);
|
||||
// void setRxROIMetadata(const slsDetectorDefs::ROI arg);
|
||||
std::array<defs::ROI, 2> getRxROI() const;
|
||||
void setRxROI(const std::array<slsDetectorDefs::ROI, 2> portRois);
|
||||
void setRxROIMetadata(const std::vector<slsDetectorDefs::ROI> &args);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
|
||||
Reference in New Issue
Block a user