mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-27 03:51:09 +02:00
switched to vector instead of std::array<ROI, 2>>, which prints extra [-1, -1] when theres only 1 udp interface
This commit is contained in:
@ -1695,11 +1695,24 @@ int ClientInterface::set_arping(Interface &socket) {
|
||||
int ClientInterface::get_receiver_roi(Interface &socket) {
|
||||
auto retvals = impl()->getPortROIs();
|
||||
LOG(logDEBUG1) << "Receiver roi retval:" << ToString(retvals);
|
||||
return socket.sendResult(retvals);
|
||||
auto size = static_cast<int>(retvals.size());
|
||||
socket.Send(size);
|
||||
if (size > 0)
|
||||
socket.Send(retvals);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ClientInterface::set_receiver_roi(Interface &socket) {
|
||||
auto args = socket.Receive<std::array<ROI, 2>>();
|
||||
auto roiSize = socket.Receive<int>();
|
||||
std::vector<ROI> args(roiSize);
|
||||
if (roiSize > 0) {
|
||||
socket.Receive(args);
|
||||
}
|
||||
if (roiSize > impl()->getNumberofUDPInterfaces()) {
|
||||
throw RuntimeError("Invalid number of ROIs received: " +
|
||||
std::to_string(roiSize) + ". Max: " +
|
||||
std::to_string(impl()->getNumberofUDPInterfaces()));
|
||||
}
|
||||
if (detType == CHIPTESTBOARD || detType == XILINX_CHIPTESTBOARD)
|
||||
functionNotImplemented();
|
||||
LOG(logDEBUG1) << "Set Receiver ROI: " << ToString(args);
|
||||
@ -1716,7 +1729,7 @@ int ClientInterface::set_receiver_roi(Interface &socket) {
|
||||
|
||||
int ClientInterface::set_receiver_roi_metadata(Interface &socket) {
|
||||
auto roiSize = socket.Receive<int>();
|
||||
LOG(logDEBUG) << "Number of ReceiverROI metadata: " << roiSize;
|
||||
LOG(logDEBUG1) << "Number of ReceiverROI metadata: " << roiSize;
|
||||
std::vector<ROI> rois(roiSize);
|
||||
if (roiSize > 0) {
|
||||
socket.Receive(rois);
|
||||
|
@ -54,7 +54,7 @@ void DataStreamer::SetAdditionalJsonHeader(
|
||||
}
|
||||
|
||||
void DataStreamer::SetPortROI(ROI roi) {
|
||||
if (roi.completeRoi()) {
|
||||
if (roi.completeRoi()) {//TODO: just not send zmq if not in roi?
|
||||
portRoi =
|
||||
ROI(0, generalData->nPixelsX - 1, 0, generalData->nPixelsY - 1);
|
||||
} else {
|
||||
|
@ -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(portRois[i].noRoi());
|
||||
listener[i]->SetIsOutsideRoi(i >= (int)portRois.size());
|
||||
listener[i]->SetDetectorDatastream(detectorDataStream[i]);
|
||||
listener[i]->SetSilentMode(silentMode);
|
||||
}
|
||||
@ -194,7 +194,12 @@ void Implementation::SetupDataProcessor(int i) {
|
||||
dataProcessor[i]->SetGeneralData(generalData);
|
||||
dataProcessor[i]->SetUdpPortNumber(udpPortNum[i]);
|
||||
dataProcessor[i]->SetActivate(activated);
|
||||
dataProcessor[i]->SetPortROI(portRois[i]);
|
||||
if (i >= (int)portRois.size()) {
|
||||
ROI roi{0, 0, 0, 0};
|
||||
dataProcessor[i]->SetPortROI(roi);
|
||||
} else {
|
||||
dataProcessor[i]->SetPortROI(portRois[i]);
|
||||
}
|
||||
dataProcessor[i]->SetDataStreamEnable(dataStreamEnable);
|
||||
dataProcessor[i]->SetStreamingFrequency(streamingFrequency);
|
||||
dataProcessor[i]->SetStreamingTimerInMs(streamingTimerInMs);
|
||||
@ -216,7 +221,12 @@ void Implementation::SetupDataStreamer(int i) {
|
||||
dataStreamer[i]->SetFlipRows(flipRows);
|
||||
dataStreamer[i]->SetNumberofPorts(numPorts);
|
||||
dataStreamer[i]->SetNumberofTotalFrames(numberOfTotalFrames);
|
||||
dataStreamer[i]->SetPortROI(portRois[i]);
|
||||
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 {
|
||||
@ -395,19 +405,29 @@ void Implementation::setArping(const bool i,
|
||||
}
|
||||
}
|
||||
|
||||
std::array<slsDetectorDefs::ROI, 2> Implementation::getPortROIs() const {
|
||||
std::vector<slsDetectorDefs::ROI> Implementation::getPortROIs() const {
|
||||
return portRois;
|
||||
}
|
||||
|
||||
void Implementation::setPortROIs(const std::array<defs::ROI, 2> &args) {
|
||||
void Implementation::setPortROIs(const std::vector<defs::ROI> &args) {
|
||||
portRois = args;
|
||||
|
||||
for (size_t i = 0; i != listener.size(); ++i)
|
||||
listener[i]->SetIsOutsideRoi(portRois[i].noRoi());
|
||||
listener[i]->SetIsOutsideRoi(i >= portRois.size());
|
||||
for (size_t i = 0; i != dataProcessor.size(); ++i)
|
||||
dataProcessor[i]->SetPortROI(portRois[i]);
|
||||
if (i >= portRois.size()) {
|
||||
ROI roi{0, 0, 0, 0};
|
||||
dataProcessor[i]->SetPortROI(roi);
|
||||
} else {
|
||||
dataProcessor[i]->SetPortROI(portRois[i]);
|
||||
}
|
||||
for (size_t i = 0; i != dataStreamer.size(); ++i) {
|
||||
dataStreamer[i]->SetPortROI(portRois[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);
|
||||
}
|
||||
@ -710,7 +730,7 @@ void Implementation::stopReceiver() {
|
||||
} else if (!detectorDataStream[i]) {
|
||||
summary = (i == 0 ? "\n\tDeactivated Left Port"
|
||||
: "\n\tDeactivated Right Port");
|
||||
} else if (portRois[i].noRoi()) {
|
||||
} else if (i >= (int)portRois.size()) {
|
||||
summary = "\n\tNo Roi on Port[" + std::to_string(i) + ']';
|
||||
} else {
|
||||
std::ostringstream os;
|
||||
@ -881,7 +901,7 @@ void Implementation::StartMasterWriter() {
|
||||
masterAttributes.framePadding = framePadding;
|
||||
masterAttributes.scanParams = scanParams;
|
||||
masterAttributes.totalFrames = numberOfTotalFrames;
|
||||
// complete ROI
|
||||
// complete ROI (for each port TODO?)
|
||||
if (multiRoiMetadata.empty()) {
|
||||
int nTotalPixelsX = (generalData->nPixelsX * numPorts.x);
|
||||
int nTotalPixelsY = (generalData->nPixelsY * numPorts.y);
|
||||
|
@ -58,8 +58,8 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
bool getArping() const;
|
||||
pid_t getArpingProcessId() const;
|
||||
void setArping(const bool i, const std::vector<std::string> ips);
|
||||
std::array<defs::ROI, 2> getPortROIs() const;
|
||||
void setPortROIs(const std::array<defs::ROI, 2> &args);
|
||||
std::vector<defs::ROI> getPortROIs() const;
|
||||
void setPortROIs(const std::vector<defs::ROI> &args);
|
||||
void setMultiROIMetadata(const std::vector<slsDetectorDefs::ROI> &args);
|
||||
|
||||
/**************************************************
|
||||
@ -307,7 +307,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
bool framePadding{true};
|
||||
pid_t parentThreadId;
|
||||
pid_t tcpThreadId;
|
||||
std::array<ROI, 2> portRois{};
|
||||
std::vector<ROI> portRois{};
|
||||
std::vector<ROI> multiRoiMetadata{};
|
||||
|
||||
// file parameters
|
||||
|
Reference in New Issue
Block a user