mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 16:27:13 +02:00
wip
This commit is contained in:
@ -924,17 +924,6 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(bool, sls::Positions)) &
|
(void (Detector::*)(bool, sls::Positions)) &
|
||||||
Detector::setRxArping,
|
Detector::setRxArping,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def("getIndividualRxROIs",
|
|
||||||
(Result<defs::ROI>(Detector::*)(sls::Positions) const) &
|
|
||||||
Detector::getIndividualRxROIs,
|
|
||||||
py::arg());
|
|
||||||
CppDetectorApi.def("getRxROI",
|
|
||||||
(defs::ROI(Detector::*)() const) & Detector::getRxROI);
|
|
||||||
CppDetectorApi.def(
|
|
||||||
"setRxROI", (void (Detector::*)(const defs::ROI)) & Detector::setRxROI,
|
|
||||||
py::arg());
|
|
||||||
CppDetectorApi.def("clearRxROI",
|
|
||||||
(void (Detector::*)()) & Detector::clearRxROI);
|
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
"getFileFormat",
|
"getFileFormat",
|
||||||
(Result<defs::fileFormat>(Detector::*)(sls::Positions) const) &
|
(Result<defs::fileFormat>(Detector::*)(sls::Positions) const) &
|
||||||
|
@ -1739,12 +1739,13 @@ readout:
|
|||||||
PUT:
|
PUT:
|
||||||
function: startDetectorReadout
|
function: startDetectorReadout
|
||||||
|
|
||||||
rx_clearroi:
|
# TODO
|
||||||
inherit_actions: EXECUTE_SET_COMMAND_NOID
|
#rx_clearroi:
|
||||||
help: "\n\tResets Region of interest in receiver. Default is all channels/pixels enabled."
|
# inherit_actions: EXECUTE_SET_COMMAND_NOID
|
||||||
actions:
|
# help: "\n\tResets Region of interest in receiver. Default is all channels/pixels enabled."
|
||||||
PUT:
|
# actions:
|
||||||
function: clearRxROI
|
# PUT:
|
||||||
|
# function: clearRxROI
|
||||||
|
|
||||||
################# EXECUTE_SET_COMMAND ########################
|
################# EXECUTE_SET_COMMAND ########################
|
||||||
start:
|
start:
|
||||||
@ -2592,17 +2593,18 @@ rx_zmqip:
|
|||||||
PUT:
|
PUT:
|
||||||
argc: -1
|
argc: -1
|
||||||
|
|
||||||
rx_roi:
|
#TODO
|
||||||
is_description: true
|
#rx_roi:
|
||||||
actions:
|
# is_description: true
|
||||||
GET:
|
# actions:
|
||||||
argc: 0
|
# GET:
|
||||||
PUT:
|
# argc: 0
|
||||||
args:
|
# PUT:
|
||||||
- argc: 2
|
# args:
|
||||||
arg_types: [ int, int ]
|
# - argc: 2
|
||||||
- argc: 4
|
# arg_types: [ int, int ]
|
||||||
arg_types: [ int, int, int, int ]
|
# - argc: 4
|
||||||
|
# arg_types: [ int, int, int, int ]
|
||||||
|
|
||||||
ratecorr:
|
ratecorr:
|
||||||
is_description: true
|
is_description: true
|
||||||
|
@ -985,16 +985,16 @@ class Detector {
|
|||||||
* every minute. Useful in 10G mode. */
|
* every minute. Useful in 10G mode. */
|
||||||
void setRxArping(bool value, Positions pos = {});
|
void setRxArping(bool value, Positions pos = {});
|
||||||
|
|
||||||
/** at module level */
|
std::vector<defs::ROI> getRxROI() const;
|
||||||
Result<defs::ROI> getIndividualRxROIs(Positions pos) const;
|
|
||||||
|
|
||||||
defs::ROI getRxROI() const;
|
|
||||||
|
|
||||||
/** only at multi module level without gap pixels */
|
/** only at multi module level without gap pixels */
|
||||||
void setRxROI(const defs::ROI value);
|
void setRxROI(const std::vector<defs::ROI>& args);
|
||||||
|
|
||||||
void clearRxROI();
|
void clearRxROI();
|
||||||
|
|
||||||
|
int getNumberOfUdpPortsInRxROI() const;
|
||||||
|
|
||||||
|
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
/** @name File */
|
/** @name File */
|
||||||
|
@ -10594,7 +10594,7 @@ std::string Caller::rx_arping(int action) {
|
|||||||
|
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
std::string Caller::rx_clearroi(int action) {
|
std::string Caller::rx_clearroi(int action) {
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
@ -10637,7 +10637,7 @@ std::string Caller::rx_clearroi(int action) {
|
|||||||
|
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
std::string Caller::rx_dbitoffset(int action) {
|
std::string Caller::rx_dbitoffset(int action) {
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
@ -233,7 +233,7 @@ class Caller {
|
|||||||
std::string runclk(int action);
|
std::string runclk(int action);
|
||||||
std::string runtime(int action);
|
std::string runtime(int action);
|
||||||
std::string rx_arping(int action);
|
std::string rx_arping(int action);
|
||||||
std::string rx_clearroi(int action);
|
//std::string rx_clearroi(int action);
|
||||||
std::string rx_dbitlist(int action);
|
std::string rx_dbitlist(int action);
|
||||||
std::string rx_dbitoffset(int action);
|
std::string rx_dbitoffset(int action);
|
||||||
std::string rx_dbitreorder(int action);
|
std::string rx_dbitreorder(int action);
|
||||||
@ -251,7 +251,7 @@ class Caller {
|
|||||||
std::string rx_padding(int action);
|
std::string rx_padding(int action);
|
||||||
std::string rx_printconfig(int action);
|
std::string rx_printconfig(int action);
|
||||||
std::string rx_realudpsocksize(int action);
|
std::string rx_realudpsocksize(int action);
|
||||||
std::string rx_roi(int action);
|
//std::string rx_roi(int action);
|
||||||
std::string rx_silent(int action);
|
std::string rx_silent(int action);
|
||||||
std::string rx_start(int action);
|
std::string rx_start(int action);
|
||||||
std::string rx_status(int action);
|
std::string rx_status(int action);
|
||||||
@ -580,7 +580,7 @@ class Caller {
|
|||||||
{"runclk", &Caller::runclk},
|
{"runclk", &Caller::runclk},
|
||||||
{"runtime", &Caller::runtime},
|
{"runtime", &Caller::runtime},
|
||||||
{"rx_arping", &Caller::rx_arping},
|
{"rx_arping", &Caller::rx_arping},
|
||||||
{"rx_clearroi", &Caller::rx_clearroi},
|
//{"rx_clearroi", &Caller::rx_clearroi},
|
||||||
{"rx_dbitlist", &Caller::rx_dbitlist},
|
{"rx_dbitlist", &Caller::rx_dbitlist},
|
||||||
{"rx_dbitoffset", &Caller::rx_dbitoffset},
|
{"rx_dbitoffset", &Caller::rx_dbitoffset},
|
||||||
{"rx_dbitreorder", &Caller::rx_dbitreorder},
|
{"rx_dbitreorder", &Caller::rx_dbitreorder},
|
||||||
@ -598,7 +598,7 @@ class Caller {
|
|||||||
{"rx_padding", &Caller::rx_padding},
|
{"rx_padding", &Caller::rx_padding},
|
||||||
{"rx_printconfig", &Caller::rx_printconfig},
|
{"rx_printconfig", &Caller::rx_printconfig},
|
||||||
{"rx_realudpsocksize", &Caller::rx_realudpsocksize},
|
{"rx_realudpsocksize", &Caller::rx_realudpsocksize},
|
||||||
{"rx_roi", &Caller::rx_roi},
|
//{"rx_roi", &Caller::rx_roi},
|
||||||
{"rx_silent", &Caller::rx_silent},
|
{"rx_silent", &Caller::rx_silent},
|
||||||
{"rx_start", &Caller::rx_start},
|
{"rx_start", &Caller::rx_start},
|
||||||
{"rx_status", &Caller::rx_status},
|
{"rx_status", &Caller::rx_status},
|
||||||
|
@ -719,6 +719,7 @@ std::string Caller::rx_zmqip(int action) {
|
|||||||
}
|
}
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
/* TODO
|
||||||
std::string Caller::rx_roi(int action) {
|
std::string Caller::rx_roi(int action) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
@ -761,7 +762,7 @@ std::string Caller::rx_roi(int action) {
|
|||||||
throw RuntimeError("Unknown action");
|
throw RuntimeError("Unknown action");
|
||||||
}
|
}
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}*/
|
||||||
std::string Caller::ratecorr(int action) {
|
std::string Caller::ratecorr(int action) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
|
@ -1367,16 +1367,22 @@ void Detector::setRxArping(bool value, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setRxArping, pos, value);
|
pimpl->Parallel(&Module::setRxArping, pos, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<defs::ROI> Detector::getIndividualRxROIs(Positions pos) const {
|
std::vector<defs::ROI> Detector::getRxROI() const {
|
||||||
return pimpl->Parallel(&Module::getRxROI, pos);
|
return pimpl->getRxROI();
|
||||||
}
|
}
|
||||||
|
|
||||||
defs::ROI Detector::getRxROI() const { return pimpl->getRxROI(); }
|
// RxROIs can be set for all types except CTB. At multi level without gap pixels
|
||||||
|
void Detector::setRxROI(const std::vector<defs::ROI>& args) {
|
||||||
void Detector::setRxROI(const defs::ROI value) { pimpl->setRxROI(value); }
|
pimpl->setRxROI(args);
|
||||||
|
}
|
||||||
|
|
||||||
void Detector::clearRxROI() { pimpl->clearRxROI(); }
|
void Detector::clearRxROI() { pimpl->clearRxROI(); }
|
||||||
|
|
||||||
|
int Detector::getNumberOfUdpPortsInRxROI() const {
|
||||||
|
return pimpl->getNumberOfUdpPortsInRxROI();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// File
|
// File
|
||||||
|
|
||||||
Result<defs::fileFormat> Detector::getFileFormat(Positions pos) const {
|
Result<defs::fileFormat> Detector::getFileFormat(Positions pos) const {
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
|
||||||
DetectorImpl::DetectorImpl(int detector_index, bool verify, bool update)
|
DetectorImpl::DetectorImpl(int detector_index, bool verify, bool update)
|
||||||
: detectorIndex(detector_index), shm(detector_index, -1),
|
: detectorIndex(detector_index), shm(detector_index, -1),
|
||||||
ctb_shm(detector_index, -1, CtbConfig::shm_tag()) {
|
ctb_shm(detector_index, -1, CtbConfig::shm_tag()) {
|
||||||
@ -130,10 +131,6 @@ void DetectorImpl::initializeDetectorStructure() {
|
|||||||
shm()->gapPixels = false;
|
shm()->gapPixels = false;
|
||||||
// zmqlib default
|
// zmqlib default
|
||||||
shm()->zmqHwm = -1;
|
shm()->zmqHwm = -1;
|
||||||
shm()->rx_roi.xmin = -1;
|
|
||||||
shm()->rx_roi.xmax = -1;
|
|
||||||
shm()->rx_roi.ymin = -1;
|
|
||||||
shm()->rx_roi.ymax = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::initializeMembers(bool verify) {
|
void DetectorImpl::initializeMembers(bool verify) {
|
||||||
@ -539,7 +536,7 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
bool quadEnable = false;
|
bool quadEnable = false;
|
||||||
// to flip image
|
// to flip image
|
||||||
bool eiger = false;
|
bool eiger = false;
|
||||||
std::array<int, 4> rxRoi = shm()->rx_roi.getIntArray();
|
std::array<int, 4> rxRoi {};//TODO: get roi from json header
|
||||||
|
|
||||||
std::vector<bool> runningList(zmqSocket.size());
|
std::vector<bool> runningList(zmqSocket.size());
|
||||||
std::vector<bool> connectList(zmqSocket.size());
|
std::vector<bool> connectList(zmqSocket.size());
|
||||||
@ -1696,7 +1693,8 @@ void DetectorImpl::verifyUniqueHost(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defs::ROI DetectorImpl::getRxROI() const {
|
std::vector<defs::ROI> DetectorImpl::getRxROI() const {
|
||||||
|
|
||||||
if (shm()->detType == CHIPTESTBOARD ||
|
if (shm()->detType == CHIPTESTBOARD ||
|
||||||
shm()->detType == defs::XILINX_CHIPTESTBOARD) {
|
shm()->detType == defs::XILINX_CHIPTESTBOARD) {
|
||||||
throw RuntimeError("RxRoi not implemented for this Detector");
|
throw RuntimeError("RxRoi not implemented for this Detector");
|
||||||
@ -1704,6 +1702,9 @@ defs::ROI DetectorImpl::getRxROI() const {
|
|||||||
if (modules.size() == 0) {
|
if (modules.size() == 0) {
|
||||||
throw RuntimeError("No Modules added");
|
throw RuntimeError("No Modules added");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return std::vector<defs::ROI>{};
|
||||||
|
/*
|
||||||
// complete detector in roi
|
// complete detector in roi
|
||||||
auto t = Parallel(&Module::getRxROI, {});
|
auto t = Parallel(&Module::getRxROI, {});
|
||||||
if (t.equal() && t.front().completeRoi()) {
|
if (t.equal() && t.front().completeRoi()) {
|
||||||
@ -1770,9 +1771,56 @@ defs::ROI DetectorImpl::getRxROI() const {
|
|||||||
retval.ymax = 0;
|
retval.ymax = 0;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::setRxROI(const defs::ROI arg) {
|
bool DetectorImpl::roisOverlap(const defs::ROI& a, const defs::ROI& b) {
|
||||||
|
return !(a.xmax < b.xmin || a.xmin > b.xmax ||
|
||||||
|
a.ymax < b.ymin || a.ymin > b.ymax);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DetectorImpl::validateROIs(const std::vector<defs::ROI>& rois) {
|
||||||
|
for (size_t i = 0; i < rois.size(); ++i) {
|
||||||
|
const auto& roi = rois[i];
|
||||||
|
|
||||||
|
if (roi.noRoi()) {
|
||||||
|
throw RuntimeError("Invalid Roi of size 0. Roi: " + ToString(roi));
|
||||||
|
}
|
||||||
|
if (roi.completeRoi()) {
|
||||||
|
throw RuntimeError("Did you mean the clear roi command (API: "
|
||||||
|
"clearRxROI, cmd: rx_clearroi) Roi: " + ToString(roi) + "?");
|
||||||
|
}
|
||||||
|
if (roi.xmin > roi.xmax || roi.ymin > roi.ymax) {
|
||||||
|
throw RuntimeError(
|
||||||
|
"Invalid Roi. xmin/ymin exceeds xmax/ymax. Roi: " + ToString(roi));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (roi.xmin < 0 || roi.xmax >= shm()->numberOfChannels.x) {
|
||||||
|
throw RuntimeError("ROI x-dimension outside detector bounds. Roi: " + ToString(roi));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is2D = (modules[0]->getNumberOfChannels().y > 1 ? true : false);
|
||||||
|
if (is2D) {
|
||||||
|
if (roi.ymin < 0 || roi.ymax >= shm()->numberOfChannels.y) {
|
||||||
|
throw RuntimeError("ROI y-dimension outside detector bounds. Roi: " + ToString(roi));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((roi.ymin != -1 && roi.ymin != 0) || (roi.ymax != -1 && roi.ymax != 0)) {
|
||||||
|
throw RuntimeError("Invalid Y range for 1D detector: should be -1. Roi: " + ToString(roi));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t j = i + 1; j < rois.size(); ++j) {
|
||||||
|
if (roisOverlap(rois[i], rois[j])) {
|
||||||
|
clearRxROI();
|
||||||
|
throw RuntimeError("Overlapping ROIs detected — all cleared.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DetectorImpl::setRxROI(const std::vector<defs::ROI>& args) {
|
||||||
if (shm()->detType == CHIPTESTBOARD ||
|
if (shm()->detType == CHIPTESTBOARD ||
|
||||||
shm()->detType == defs::XILINX_CHIPTESTBOARD) {
|
shm()->detType == defs::XILINX_CHIPTESTBOARD) {
|
||||||
throw RuntimeError("RxRoi not implemented for this Detector");
|
throw RuntimeError("RxRoi not implemented for this Detector");
|
||||||
@ -1780,32 +1828,14 @@ void DetectorImpl::setRxROI(const defs::ROI arg) {
|
|||||||
if (modules.size() == 0) {
|
if (modules.size() == 0) {
|
||||||
throw RuntimeError("No Modules added");
|
throw RuntimeError("No Modules added");
|
||||||
}
|
}
|
||||||
if (arg.noRoi()) {
|
|
||||||
throw RuntimeError("Invalid Roi of size 0.");
|
validateROIs(args);
|
||||||
}
|
|
||||||
if (arg.completeRoi()) {
|
|
||||||
throw RuntimeError("Did you mean the clear roi command (API: "
|
|
||||||
"clearRxROI, cmd: rx_clearroi)?");
|
|
||||||
}
|
|
||||||
if (arg.xmin > arg.xmax || arg.ymin > arg.ymax) {
|
|
||||||
throw RuntimeError(
|
|
||||||
"Invalid Receiver Roi. xmin/ymin exceeds xmax/ymax.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/*
|
||||||
defs::xy numChansPerMod = modules[0]->getNumberOfChannels();
|
defs::xy numChansPerMod = modules[0]->getNumberOfChannels();
|
||||||
bool is2D = (numChansPerMod.y > 1 ? true : false);
|
bool is2D = (numChansPerMod.y > 1 ? true : false);
|
||||||
defs::xy geometry = getPortGeometry();
|
defs::xy geometry = getPortGeometry();
|
||||||
|
|
||||||
if (!is2D && ((arg.ymin != -1 && arg.ymin != 0) ||
|
|
||||||
(arg.ymax != -1 && arg.ymax != 0))) {
|
|
||||||
throw RuntimeError(
|
|
||||||
"Invalid Receiver roi. Cannot set 2d roi for a 1d detector.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg.xmin < 0 || arg.xmax >= shm()->numberOfChannels.x ||
|
|
||||||
(is2D && (arg.ymin < 0 || arg.ymax >= shm()->numberOfChannels.y))) {
|
|
||||||
throw RuntimeError("Invalid Receiver Roi. Outside detector range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t iModule = 0; iModule != modules.size(); ++iModule) {
|
for (size_t iModule = 0; iModule != modules.size(); ++iModule) {
|
||||||
// default init = complete roi
|
// default init = complete roi
|
||||||
@ -1884,14 +1914,15 @@ void DetectorImpl::setRxROI(const defs::ROI arg) {
|
|||||||
} else {
|
} else {
|
||||||
modules[0]->setRxROIMetadata(arg);
|
modules[0]->setRxROIMetadata(arg);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::clearRxROI() {
|
void DetectorImpl::clearRxROI() {
|
||||||
Parallel(&Module::setRxROI, {}, defs::ROI{});
|
;//Parallel(&Module::setRxROI, {}, defs::ROI{}); TODO: clear roi
|
||||||
shm()->rx_roi.xmin = -1;
|
}
|
||||||
shm()->rx_roi.ymin = -1;
|
|
||||||
shm()->rx_roi.xmax = -1;
|
int DetectorImpl::getNumberOfUdpPortsInRxROI() const {
|
||||||
shm()->rx_roi.ymax = -1;
|
return 0;// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::getBadChannels(const std::string &fname,
|
void DetectorImpl::getBadChannels(const std::string &fname,
|
||||||
|
@ -24,7 +24,7 @@ class detectorData;
|
|||||||
class Module;
|
class Module;
|
||||||
|
|
||||||
#define DETECTOR_SHMAPIVERSION 0x190809
|
#define DETECTOR_SHMAPIVERSION 0x190809
|
||||||
#define DETECTOR_SHMVERSION 0x220505
|
#define DETECTOR_SHMVERSION 0x250616
|
||||||
#define SHORT_STRING_LENGTH 50
|
#define SHORT_STRING_LENGTH 50
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,8 +65,6 @@ struct sharedDetector {
|
|||||||
bool gapPixels;
|
bool gapPixels;
|
||||||
/** high water mark of listening tcp port (only data) */
|
/** high water mark of listening tcp port (only data) */
|
||||||
int zmqHwm;
|
int zmqHwm;
|
||||||
/** in shm for gui purposes */
|
|
||||||
defs::ROI rx_roi{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DetectorImpl : public virtual slsDetectorDefs {
|
class DetectorImpl : public virtual slsDetectorDefs {
|
||||||
@ -303,9 +301,10 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
std::vector<std::pair<std::string, uint16_t>>
|
std::vector<std::pair<std::string, uint16_t>>
|
||||||
verifyUniqueRxHost(const std::vector<std::string> &names) const;
|
verifyUniqueRxHost(const std::vector<std::string> &names) const;
|
||||||
|
|
||||||
defs::ROI getRxROI() const;
|
std::vector<defs::ROI> getRxROI() const;
|
||||||
void setRxROI(const defs::ROI arg);
|
void setRxROI(const std::vector<defs::ROI>& args);
|
||||||
void clearRxROI();
|
void clearRxROI();
|
||||||
|
int getNumberOfUdpPortsInRxROI() const;
|
||||||
|
|
||||||
void getBadChannels(const std::string &fname, Positions pos) const;
|
void getBadChannels(const std::string &fname, Positions pos) const;
|
||||||
void setBadChannels(const std::string &fname, Positions pos);
|
void setBadChannels(const std::string &fname, Positions pos);
|
||||||
@ -428,6 +427,9 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
void verifyUniqueHost(
|
void verifyUniqueHost(
|
||||||
bool isDet, std::vector<std::pair<std::string, uint16_t>> &hosts) const;
|
bool isDet, std::vector<std::pair<std::string, uint16_t>> &hosts) const;
|
||||||
|
|
||||||
|
bool roisOverlap(const defs::ROI& a, const defs::ROI& b);
|
||||||
|
void validateROIs(const std::vector<defs::ROI>& rois);
|
||||||
|
|
||||||
const int detectorIndex{0};
|
const int detectorIndex{0};
|
||||||
SharedMemory<sharedDetector> shm{0, -1};
|
SharedMemory<sharedDetector> shm{0, -1};
|
||||||
SharedMemory<CtbConfig> ctb_shm{0, -1, CtbConfig::shm_tag()};
|
SharedMemory<CtbConfig> ctb_shm{0, -1, CtbConfig::shm_tag()};
|
||||||
|
@ -1520,7 +1520,7 @@ bool Module::getRxArping() const {
|
|||||||
void Module::setRxArping(bool enable) {
|
void Module::setRxArping(bool enable) {
|
||||||
sendToReceiver(F_SET_RECEIVER_ARPING, static_cast<int>(enable), nullptr);
|
sendToReceiver(F_SET_RECEIVER_ARPING, static_cast<int>(enable), nullptr);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
defs::ROI Module::getRxROI() const {
|
defs::ROI Module::getRxROI() const {
|
||||||
return sendToReceiver<slsDetectorDefs::ROI>(F_RECEIVER_GET_RECEIVER_ROI);
|
return sendToReceiver<slsDetectorDefs::ROI>(F_RECEIVER_GET_RECEIVER_ROI);
|
||||||
}
|
}
|
||||||
@ -1533,7 +1533,7 @@ void Module::setRxROI(const slsDetectorDefs::ROI arg) {
|
|||||||
void Module::setRxROIMetadata(const slsDetectorDefs::ROI arg) {
|
void Module::setRxROIMetadata(const slsDetectorDefs::ROI arg) {
|
||||||
sendToReceiver(F_RECEIVER_SET_RECEIVER_ROI_METADATA, arg, nullptr);
|
sendToReceiver(F_RECEIVER_SET_RECEIVER_ROI_METADATA, arg, nullptr);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// File
|
// File
|
||||||
slsDetectorDefs::fileFormat Module::getFileFormat() const {
|
slsDetectorDefs::fileFormat Module::getFileFormat() const {
|
||||||
return sendToReceiver<fileFormat>(F_GET_RECEIVER_FILE_FORMAT);
|
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;
|
std::array<pid_t, NUM_RX_THREAD_IDS> getReceiverThreadIds() const;
|
||||||
bool getRxArping() const;
|
bool getRxArping() const;
|
||||||
void setRxArping(bool enable);
|
void setRxArping(bool enable);
|
||||||
defs::ROI getRxROI() const;
|
//defs::ROI getRxROI() const;
|
||||||
void setRxROI(const slsDetectorDefs::ROI arg);
|
//void setRxROI(const slsDetectorDefs::ROI arg);
|
||||||
void setRxROIMetadata(const slsDetectorDefs::ROI arg);
|
//void setRxROIMetadata(const slsDetectorDefs::ROI arg);
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
target_sources(tests PRIVATE
|
target_sources(tests PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-SharedMemory.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-SharedMemory.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-slsDetector.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-slsDetector.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/test-Roi.cpp
|
||||||
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-rx.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-rx.cpp
|
||||||
|
84
slsDetectorSoftware/tests/test-Roi.cpp
Normal file
84
slsDetectorSoftware/tests/test-Roi.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#include "catch.hpp"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "DetectorImpl.h"
|
||||||
|
#include "sls/Detector.h"
|
||||||
|
#include "Module.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
TEST_CASE("ROI validation") {
|
||||||
|
DetectorImpl det(0, false, false);
|
||||||
|
det.addTestModule(slsDetectorDefs::JUNGFRAU);
|
||||||
|
std::cout << "size:"<< det.size() << std::endl;
|
||||||
|
DetectorImpl detector(0, false, false);
|
||||||
|
|
||||||
|
SECTION("Valid non-overlapping ROIs") {
|
||||||
|
std::vector<slsDetectorDefs::ROI> rois = {
|
||||||
|
{0, 10, 0, 10},
|
||||||
|
{20, 30, 0, 10},
|
||||||
|
{0, 10, 20, 30},
|
||||||
|
{40, 50, 0, 10}
|
||||||
|
};
|
||||||
|
REQUIRE_NOTHROW(DetectorImplTestHelper::testValidateRois(detector, rois));
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Overlapping ROIs should throw") {
|
||||||
|
std::vector<slsDetectorDefs::ROI> rois = {
|
||||||
|
{0, 10, 0, 10},
|
||||||
|
{5, 15, 0, 10}
|
||||||
|
};
|
||||||
|
REQUIRE_THROWS_AS(DetectorImplTestHelper::testValidateRois(detector, rois),
|
||||||
|
sls::RuntimeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Invalid ROI (xmin > xmax)") {
|
||||||
|
std::vector<slsDetectorDefs::ROI> rois = {
|
||||||
|
{12, 8, 0, 10}
|
||||||
|
};
|
||||||
|
REQUIRE_THROWS_AS(DetectorImplTestHelper::testValidateRois(detector, rois),
|
||||||
|
sls::RuntimeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Invalid ROI (ymin > ymax)") {
|
||||||
|
std::vector<slsDetectorDefs::ROI> rois = {
|
||||||
|
{0, 10, 20, 5}
|
||||||
|
};
|
||||||
|
REQUIRE_THROWS_AS(DetectorImplTestHelper::testValidateRois(detector, rois),
|
||||||
|
sls::RuntimeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Invalid ROI (outside detector bounds)") {
|
||||||
|
// Assuming detector has 100x100 dimensions
|
||||||
|
detector.setNumberOfChannels({100, 100});
|
||||||
|
std::vector<slsDetectorDefs::ROI> rois = {
|
||||||
|
{95, 105, 0, 10} // xmax out of bounds
|
||||||
|
};
|
||||||
|
REQUIRE_THROWS_AS(DetectorImplTestHelper::testValidateRois(detector, rois),
|
||||||
|
sls::RuntimeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Valid ROI for 1D detector") {
|
||||||
|
detector.setNumberOfChannels({100, 1});
|
||||||
|
std::vector<slsDetectorDefs::ROI> rois = {
|
||||||
|
{10, 20, -1, -1}
|
||||||
|
};
|
||||||
|
REQUIRE_NOTHROW(DetectorImplTestHelper::testValidateRois(detector, rois));
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Invalid Y for 1D detector") {
|
||||||
|
detector.setNumberOfChannels({100, 1});
|
||||||
|
std::vector<slsDetectorDefs::ROI> rois = {
|
||||||
|
{10, 20, 0, 10} // Y should be -1 for 1D
|
||||||
|
};
|
||||||
|
REQUIRE_THROWS_AS(DetectorImplTestHelper::testValidateRois(detector, rois),
|
||||||
|
sls::RuntimeError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace sls
|
Reference in New Issue
Block a user