mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-26 11:31:08 +02:00
fix for empty roi vectors (which shouldnt be) as you cant know if its all or not in roi
This commit is contained in:
@ -714,7 +714,7 @@ class Detector {
|
||||
* restarts client and receiver zmq sockets if zmq streaming enabled. \n
|
||||
* [Gotthard2] second interface enabled to send veto information via 10Gbps
|
||||
* for debugging. By default, if veto enabled, it is sent via 2.5 gbps
|
||||
* interface. */
|
||||
* interface. \nSetting this resets the receiver roi */
|
||||
void setNumberofUDPInterfaces(int n, Positions pos = {});
|
||||
|
||||
/** [Jungfrau][Moench] */
|
||||
@ -995,7 +995,8 @@ class Detector {
|
||||
/** Returns port level ROIs. Max 2 ports and hence max 2 elements per readout */
|
||||
std::vector<defs::ROI> getRxROI(int module_id) const;
|
||||
|
||||
/** only at multi module level without gap pixels. At most, 1 ROI per UDP port */
|
||||
/** only at multi module level without gap pixels. At most, 1 ROI per UDP
|
||||
* port. Setting number of udp interfaces will clear the roi */
|
||||
void setRxROI(const std::vector<defs::ROI> &args);
|
||||
|
||||
void clearRxROI();
|
||||
|
@ -734,7 +734,8 @@ std::string Caller::rx_roi(int action) {
|
||||
"Only allowed to set at multi module level and without gap "
|
||||
"ixels.\n\n\t" +
|
||||
"One can get rx_roi also at port level, by specifying the module id "
|
||||
"and it will return the roi for each port.\n";
|
||||
"and it will return the roi for each port.\n"
|
||||
"Setting number of udp interfaces will clear the rx_roi\n";
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << helpMessage;
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
|
@ -1534,8 +1534,10 @@ std::vector<defs::ROI> Module::getRxROI() const {
|
||||
std::vector<ROI> retval(nPorts);
|
||||
if (nPorts > 0)
|
||||
client.Receive(retval);
|
||||
if (nPorts > shm()->numUDPInterfaces) {
|
||||
throw RuntimeError("Invalid number of rois: " + std::to_string(nPorts) + ". Max: " + std::to_string(shm()->numUDPInterfaces));
|
||||
if (nPorts != shm()->numUDPInterfaces) {
|
||||
throw RuntimeError(
|
||||
"Invalid number of rois: " + std::to_string(nPorts) +
|
||||
". Expected: " + std::to_string(shm()->numUDPInterfaces));
|
||||
}
|
||||
LOG(logDEBUG1) << "ROI of Receiver" << moduleIndex << ": "
|
||||
<< ToString(retval);
|
||||
@ -1548,10 +1550,10 @@ void Module::setRxROI(const std::vector<defs::ROI> &portRois) {
|
||||
if (!shm()->useReceiverFlag) {
|
||||
throw RuntimeError("No receiver to set ROI.");
|
||||
}
|
||||
if ((int)portRois.size() > shm()->numUDPInterfaces) {
|
||||
throw RuntimeError("Invalid number of ROIs: " +
|
||||
std::to_string(portRois.size()) +
|
||||
". Max: " + std::to_string(shm()->numUDPInterfaces));
|
||||
if ((int)portRois.size() != shm()->numUDPInterfaces) {
|
||||
throw RuntimeError(
|
||||
"Invalid number of ROIs: " + std::to_string(portRois.size()) +
|
||||
". Expected: " + std::to_string(shm()->numUDPInterfaces));
|
||||
}
|
||||
// check number of ports
|
||||
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
@ -1577,6 +1579,10 @@ void Module::setRxROIMetadata(const std::vector<slsDetectorDefs::ROI> &args) {
|
||||
receiver.Send(size);
|
||||
if (size > 0)
|
||||
receiver.Send(args);
|
||||
if (size < 1) {
|
||||
throw RuntimeError("Invalid number of ROI metadata: " +
|
||||
std::to_string(size) + ". Min: 1.");
|
||||
}
|
||||
if (receiver.Receive<int>() == FAIL) {
|
||||
throw ReceiverError("Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + receiver.readErrorMessage());
|
||||
|
@ -1696,6 +1696,11 @@ int ClientInterface::get_receiver_roi(Interface &socket) {
|
||||
auto retvals = impl()->getPortROIs();
|
||||
LOG(logDEBUG1) << "Receiver roi retval:" << ToString(retvals);
|
||||
auto size = static_cast<int>(retvals.size());
|
||||
if (size != impl()->getNumberofUDPInterfaces()) {
|
||||
throw RuntimeError("Invalid number of ROIs received: " +
|
||||
std::to_string(size) + ". Expected: " +
|
||||
std::to_string(impl()->getNumberofUDPInterfaces()));
|
||||
}
|
||||
socket.Send(size);
|
||||
if (size > 0)
|
||||
socket.Send(retvals);
|
||||
@ -1708,9 +1713,9 @@ int ClientInterface::set_receiver_roi(Interface &socket) {
|
||||
if (roiSize > 0) {
|
||||
socket.Receive(args);
|
||||
}
|
||||
if (roiSize > impl()->getNumberofUDPInterfaces()) {
|
||||
if (roiSize != impl()->getNumberofUDPInterfaces()) {
|
||||
throw RuntimeError("Invalid number of ROIs received: " +
|
||||
std::to_string(roiSize) + ". Max: " +
|
||||
std::to_string(roiSize) + ". Expected: " +
|
||||
std::to_string(impl()->getNumberofUDPInterfaces()));
|
||||
}
|
||||
if (detType == CHIPTESTBOARD || detType == XILINX_CHIPTESTBOARD)
|
||||
@ -1730,6 +1735,10 @@ int ClientInterface::set_receiver_roi(Interface &socket) {
|
||||
int ClientInterface::set_receiver_roi_metadata(Interface &socket) {
|
||||
auto roiSize = socket.Receive<int>();
|
||||
LOG(logDEBUG1) << "Number of ReceiverROI metadata: " << roiSize;
|
||||
if (roiSize < 1) {
|
||||
throw RuntimeError("Invalid number of ROIs received: " +
|
||||
std::to_string(roiSize) + ". Min: 1.");
|
||||
}
|
||||
std::vector<ROI> rois(roiSize);
|
||||
if (roiSize > 0) {
|
||||
socket.Receive(rois);
|
||||
|
@ -208,10 +208,10 @@ std::string DataProcessor::CreateVirtualFile(
|
||||
const int modulePos, const int numModX, const int numModY,
|
||||
std::mutex *hdf5LibMutex) {
|
||||
|
||||
if (!multiRoiMetadata.empty() && generalData->dynamicRange == 4) {
|
||||
/*if (!multiRoiMetadata.empty() && generalData->dynamicRange == 4) {
|
||||
throw std::runtime_error("Skipping virtual hdf5 file since rx_roi is "
|
||||
"enabled in 4 bit mode.");
|
||||
}
|
||||
}*/
|
||||
|
||||
bool gotthard25um = ((generalData->detType == GOTTHARD ||
|
||||
generalData->detType == GOTTHARD2) &&
|
||||
@ -240,10 +240,10 @@ void DataProcessor::LinkFileInMaster(const std::string &masterFileName,
|
||||
const bool silentMode,
|
||||
std::mutex *hdf5LibMutex) {
|
||||
|
||||
if (!multiRoiMetadata.empty()) {
|
||||
/*if (!multiRoiMetadata.empty()) {
|
||||
throw std::runtime_error(
|
||||
"Should not be here, roi with hdf5 virtual should throw.");
|
||||
}
|
||||
}*/
|
||||
std::string fname{virtualFileName}, masterfname{masterFileName};
|
||||
// if no virtual file, link data file
|
||||
if (virtualFileName.empty()) {
|
||||
|
@ -184,7 +184,7 @@ void Implementation::SetupListener(int i) {
|
||||
listener[i]->SetUdpPortNumber(udpPortNum[i]);
|
||||
listener[i]->SetEthernetInterface(eth[i]);
|
||||
listener[i]->SetActivate(activated);
|
||||
listener[i]->SetIsOutsideRoi(i >= (int)portRois.size());
|
||||
listener[i]->SetIsOutsideRoi(portRois[i].noRoi());
|
||||
listener[i]->SetDetectorDatastream(detectorDataStream[i]);
|
||||
listener[i]->SetSilentMode(silentMode);
|
||||
}
|
||||
@ -194,12 +194,7 @@ void Implementation::SetupDataProcessor(int i) {
|
||||
dataProcessor[i]->SetGeneralData(generalData);
|
||||
dataProcessor[i]->SetUdpPortNumber(udpPortNum[i]);
|
||||
dataProcessor[i]->SetActivate(activated);
|
||||
if (i >= (int)portRois.size()) {
|
||||
ROI roi{0, 0, 0, 0};
|
||||
dataProcessor[i]->SetPortROI(roi);
|
||||
} else {
|
||||
dataProcessor[i]->SetPortROI(portRois[i]);
|
||||
}
|
||||
if (i == 0)
|
||||
dataProcessor[0]->setMultiROIMetadata(multiRoiMetadata);
|
||||
dataProcessor[i]->SetDataStreamEnable(dataStreamEnable);
|
||||
@ -223,12 +218,7 @@ void Implementation::SetupDataStreamer(int i) {
|
||||
dataStreamer[i]->SetFlipRows(flipRows);
|
||||
dataStreamer[i]->SetNumberofPorts(numPorts);
|
||||
dataStreamer[i]->SetNumberofTotalFrames(numberOfTotalFrames);
|
||||
if (i >= (int)portRois.size()) {
|
||||
ROI roi{0, 0, 0, 0};
|
||||
dataStreamer[i]->SetPortROI(roi);
|
||||
} else {
|
||||
dataStreamer[i]->SetPortROI(portRois[i]);
|
||||
}
|
||||
}
|
||||
|
||||
slsDetectorDefs::xy Implementation::getDetectorSize() const {
|
||||
@ -415,25 +405,15 @@ void Implementation::setPortROIs(const std::vector<defs::ROI> &args) {
|
||||
portRois = args;
|
||||
|
||||
for (size_t i = 0; i != listener.size(); ++i)
|
||||
listener[i]->SetIsOutsideRoi(i >= portRois.size());
|
||||
listener[i]->SetIsOutsideRoi(portRois[i].noRoi());
|
||||
for (size_t i = 0; i != dataProcessor.size(); ++i) {
|
||||
if (i >= portRois.size()) {
|
||||
ROI roi{0, 0, 0, 0};
|
||||
dataProcessor[i]->SetPortROI(roi);
|
||||
} else {
|
||||
dataProcessor[i]->SetPortROI(portRois[i]);
|
||||
}
|
||||
}
|
||||
if (dataProcessor.size() > 0)
|
||||
dataProcessor[0]->setMultiROIMetadata(multiRoiMetadata);
|
||||
for (size_t i = 0; i != dataStreamer.size(); ++i) {
|
||||
if (i >= portRois.size()) {
|
||||
ROI roi{0, 0, 0, 0};
|
||||
dataStreamer[i]->SetPortROI(roi);
|
||||
} else {
|
||||
dataStreamer[i]->SetPortROI(portRois[i]);
|
||||
}
|
||||
}
|
||||
LOG(logINFO) << "Rois (per port): " << ToString(portRois);
|
||||
}
|
||||
|
||||
@ -737,7 +717,7 @@ void Implementation::stopReceiver() {
|
||||
} else if (!detectorDataStream[i]) {
|
||||
summary = (i == 0 ? "\n\tDeactivated Left Port"
|
||||
: "\n\tDeactivated Right Port");
|
||||
} else if (i >= (int)portRois.size()) {
|
||||
} else if (portRois[i].noRoi()) {
|
||||
summary = "\n\tNo Roi on Port[" + std::to_string(i) + ']';
|
||||
} else {
|
||||
std::ostringstream os;
|
||||
@ -909,7 +889,8 @@ void Implementation::StartMasterWriter() {
|
||||
masterAttributes.scanParams = scanParams;
|
||||
masterAttributes.totalFrames = numberOfTotalFrames;
|
||||
// complete ROI (for each port TODO?)
|
||||
if (multiRoiMetadata.empty()) {
|
||||
if (multiRoiMetadata.size() == 1 &&
|
||||
multiRoiMetadata[0].completeRoi()) {
|
||||
int nTotalPixelsX = (generalData->nPixelsX * numPorts.x);
|
||||
int nTotalPixelsY = (generalData->nPixelsY * numPorts.y);
|
||||
if (nTotalPixelsY == 1) {
|
||||
@ -1049,8 +1030,13 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
|
||||
// fifo
|
||||
SetupFifoStructure();
|
||||
|
||||
// roi cleared - complete detector
|
||||
std::vector<ROI> rois(n);
|
||||
std::vector<ROI> multiRoi(1);
|
||||
// recalculate port rois booleans for listener, processor and streamer
|
||||
setPortROIs(portRois);
|
||||
setPortROIs(rois);
|
||||
setMultiROIMetadata(multiRoi);
|
||||
|
||||
// create threads
|
||||
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
|
||||
|
@ -307,8 +307,8 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
bool framePadding{true};
|
||||
pid_t parentThreadId;
|
||||
pid_t tcpThreadId;
|
||||
std::vector<ROI> portRois{};
|
||||
std::vector<ROI> multiRoiMetadata{};
|
||||
std::vector<slsDetectorDefs::ROI> portRois{1};
|
||||
std::vector<slsDetectorDefs::ROI> multiRoiMetadata{1};
|
||||
|
||||
// file parameters
|
||||
fileFormat fileFormatType{BINARY};
|
||||
|
@ -208,7 +208,7 @@ std::string CreateVirtualHDF5File(
|
||||
attribute.write(H5::PredType::NATIVE_DOUBLE, &dValue);
|
||||
|
||||
// complete detector in roi
|
||||
if (multiRoi.empty()) {
|
||||
/*if (multiRoi.empty()) {
|
||||
int ny = nPixelsY * numModY;
|
||||
int nx = nPixelsX * numModX;
|
||||
if (nPixelsY == 1) {
|
||||
@ -216,9 +216,9 @@ std::string CreateVirtualHDF5File(
|
||||
} else {
|
||||
multiRoi.push_back(defs::ROI{0, nx - 1, 0, ny - 1});
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
for (size_t iRoi = 0; iRoi != multiRoi.size(); ++iRoi) {
|
||||
// for (size_t iRoi = 0; iRoi != multiRoi.size(); ++iRoi) {
|
||||
|
||||
// dataspace
|
||||
hsize_t vdsDims[DATA_RANK] = {numImagesCaught, numModY * nDimy,
|
||||
@ -273,9 +273,9 @@ std::string CreateVirtualHDF5File(
|
||||
startLocation[2] = iReadout;
|
||||
}
|
||||
|
||||
vdsDataSpace.selectHyperslab(
|
||||
H5S_SELECT_SET, numBlocks, startLocation,
|
||||
strideBetweenBlocks, blockSize);
|
||||
vdsDataSpace.selectHyperslab(H5S_SELECT_SET, numBlocks,
|
||||
startLocation, strideBetweenBlocks,
|
||||
blockSize);
|
||||
|
||||
vdsDataSpacePara.selectHyperslab(
|
||||
H5S_SELECT_SET, numBlocksPara, startLocationPara,
|
||||
@ -300,8 +300,7 @@ std::string CreateVirtualHDF5File(
|
||||
|
||||
// source dataspace
|
||||
hsize_t srcDims[DATA_RANK] = {nDimx, nDimy, nDimz};
|
||||
hsize_t srcDimsMax[DATA_RANK] = {H5S_UNLIMITED, nDimy,
|
||||
nDimz};
|
||||
hsize_t srcDimsMax[DATA_RANK] = {H5S_UNLIMITED, nDimy, nDimz};
|
||||
H5::DataSpace srcDataSpace(DATA_RANK, srcDims, srcDimsMax);
|
||||
hsize_t srcDimsPara[PARA_RANK] = {nDimx};
|
||||
hsize_t srcDimsMaxPara[PARA_RANK] = {H5S_UNLIMITED};
|
||||
@ -315,8 +314,8 @@ std::string CreateVirtualHDF5File(
|
||||
hsize_t count[1] = {nDimx};
|
||||
hsize_t start[1] = {0};
|
||||
srcDataSpacePara.selectHyperslab(
|
||||
H5S_SELECT_SET, count, start,
|
||||
strideBetweenBlocksPara, blockSizePara);
|
||||
H5S_SELECT_SET, count, start, strideBetweenBlocksPara,
|
||||
blockSizePara);
|
||||
}
|
||||
|
||||
// mapping of property list
|
||||
@ -351,7 +350,7 @@ std::string CreateVirtualHDF5File(
|
||||
parameterNames[p].c_str(), parameterDataTypes[p],
|
||||
vdsDataSpacePara, plistPara[p]));
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
fd->close();
|
||||
} catch (const H5::Exception &error) {
|
||||
|
Reference in New Issue
Block a user