mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
dr
This commit is contained in:
@ -203,6 +203,16 @@ class Detector {
|
||||
* [Gotthard2] only in continuous mode */
|
||||
Result<ns> getDelayAfterTriggerLeft(Positions pos = {}) const;
|
||||
|
||||
Result<int> getDynamicRange(Positions pos = {}) const;
|
||||
|
||||
/**
|
||||
* [Eiger] Options: 4, 8, 16, 32
|
||||
* [Mythen3] Options: 8, 16, 32
|
||||
* [Eiger] If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to
|
||||
* 1
|
||||
*/
|
||||
void setDynamicRange(int value);
|
||||
|
||||
Result<defs::timingMode> getTimingMode(Positions pos = {}) const;
|
||||
|
||||
/**
|
||||
@ -698,8 +708,8 @@ class Detector {
|
||||
Result<int> getRxZmqStartingFrame(Positions pos = {}) const;
|
||||
|
||||
/**
|
||||
* The starting frame index to stream out. 0 by default, which streams
|
||||
* the first frame in an acquisition, and then depending on the rx zmq
|
||||
* The starting frame index to stream out. 0 by default, which streams
|
||||
* the first frame in an acquisition, and then depending on the rx zmq
|
||||
* frequency/ timer.
|
||||
*/
|
||||
void setRxZmqStartingFrame(int fnum, Positions pos = {});
|
||||
@ -736,15 +746,6 @@ class Detector {
|
||||
* *
|
||||
* ************************************************/
|
||||
|
||||
Result<int> getDynamicRange(Positions pos = {}) const;
|
||||
|
||||
/**
|
||||
* [Eiger]
|
||||
* Options: 4, 8, 16, 32
|
||||
* If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to 1
|
||||
*/
|
||||
void setDynamicRange(int value);
|
||||
|
||||
/** [Eiger] in 32 bit mode */
|
||||
Result<ns> getSubExptime(Positions pos = {}) const;
|
||||
|
||||
|
@ -487,6 +487,37 @@ std::string CmdProxy::Exptime(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::DynamicRange(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[value]\n\tDynamic Range or number of bits per "
|
||||
"pixel in detector.\n\t"
|
||||
"[Eiger] Options: 4, 8, 16, 32\n\t"
|
||||
"[Mythen3] Options: 8, 16, 32"
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getDynamicRange({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError(
|
||||
"Cannot execute dynamic range at module level");
|
||||
}
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setDynamicRange(StringTo<int>(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::Speed(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
@ -1196,35 +1227,6 @@ std::string CmdProxy::ReceiveHostname(int action) {
|
||||
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
||||
/* Eiger Specific */
|
||||
|
||||
std::string CmdProxy::DynamicRange(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[4|8|16|32]\n\t[Eiger] Dynamic Range or number of bits per "
|
||||
"pixel in detector."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getDynamicRange({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError(
|
||||
"Cannot execute dynamic range at module level");
|
||||
}
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setDynamicRange(StringTo<int>(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::Threshold(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
|
@ -643,6 +643,7 @@ class CmdProxy {
|
||||
{"triggersl", &CmdProxy::triggersl},
|
||||
{"delayl", &CmdProxy::delayl},
|
||||
{"periodl", &CmdProxy::periodl},
|
||||
{"dr", &CmdProxy::DynamicRange},
|
||||
{"timing", &CmdProxy::timing},
|
||||
{"speed", &CmdProxy::Speed},
|
||||
{"adcphase", &CmdProxy::Adcphase},
|
||||
@ -814,7 +815,6 @@ class CmdProxy {
|
||||
{"zmqip", &CmdProxy::zmqip},
|
||||
|
||||
/* Eiger Specific */
|
||||
{"dr", &CmdProxy::DynamicRange},
|
||||
{"subexptime", &CmdProxy::subexptime},
|
||||
{"subdeadtime", &CmdProxy::subdeadtime},
|
||||
{"threshold", &CmdProxy::Threshold},
|
||||
@ -996,6 +996,7 @@ class CmdProxy {
|
||||
/* acquisition parameters */
|
||||
std::string Acquire(int action);
|
||||
std::string Exptime(int action);
|
||||
std::string DynamicRange(int action);
|
||||
std::string Speed(int action);
|
||||
std::string Adcphase(int action);
|
||||
std::string Dbitphase(int action);
|
||||
@ -1021,7 +1022,6 @@ class CmdProxy {
|
||||
/* File */
|
||||
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
||||
/* Eiger Specific */
|
||||
std::string DynamicRange(int action);
|
||||
std::string Threshold(int action);
|
||||
std::string ThresholdNoTb(int action);
|
||||
std::string TrimEnergies(int action);
|
||||
@ -1785,9 +1785,11 @@ class CmdProxy {
|
||||
"[nth frame]\n\tStream out every nth frame. Default is 1. 0 means "
|
||||
"streaming every 200 ms and discarding frames in this interval.");
|
||||
|
||||
INTEGER_COMMAND(
|
||||
rx_zmqstartfnum, getRxZmqStartingFrame, setRxZmqStartingFrame, StringTo<int>,
|
||||
"[fnum]\n\tThe starting frame index to stream out. 0 by default, which streams the first frame in an acquisition, and then depending on the rx zmq frequency/ timer");
|
||||
INTEGER_COMMAND(rx_zmqstartfnum, getRxZmqStartingFrame,
|
||||
setRxZmqStartingFrame, StringTo<int>,
|
||||
"[fnum]\n\tThe starting frame index to stream out. 0 by "
|
||||
"default, which streams the first frame in an acquisition, "
|
||||
"and then depending on the rx zmq frequency/ timer");
|
||||
|
||||
INTEGER_COMMAND(
|
||||
rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo<int>,
|
||||
|
@ -273,6 +273,14 @@ Result<ns> Detector::getPeriodLeft(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getPeriodLeft, pos);
|
||||
}
|
||||
|
||||
Result<int> Detector::getDynamicRange(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDynamicRange, pos);
|
||||
}
|
||||
|
||||
void Detector::setDynamicRange(int value) {
|
||||
pimpl->Parallel(&Module::setDynamicRange, {}, value);
|
||||
}
|
||||
|
||||
Result<defs::timingMode> Detector::getTimingMode(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getTimingMode, pos);
|
||||
}
|
||||
@ -1022,14 +1030,6 @@ void Detector::setClientZmqIp(const IpAddr ip, Positions pos) {
|
||||
|
||||
// Eiger Specific
|
||||
|
||||
Result<int> Detector::getDynamicRange(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDynamicRange, pos);
|
||||
}
|
||||
|
||||
void Detector::setDynamicRange(int value) {
|
||||
pimpl->Parallel(&Module::setDynamicRange, {}, value);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getSubExptime(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getSubExptime, pos);
|
||||
}
|
||||
|
@ -259,6 +259,38 @@ int64_t Module::getPeriodLeft() const {
|
||||
return sendToDetectorStop<int64_t>(F_GET_PERIOD_LEFT);
|
||||
}
|
||||
|
||||
int Module::getDynamicRange() {
|
||||
return sendToDetector<int>(F_SET_DYNAMIC_RANGE, GET_FLAG);
|
||||
}
|
||||
|
||||
void Module::setDynamicRange(int n) {
|
||||
int prev_val = n;
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
prev_val = getDynamicRange();
|
||||
}
|
||||
|
||||
auto retval = sendToDetector<int>(F_SET_DYNAMIC_RANGE, n);
|
||||
if (shm()->useReceiverFlag) {
|
||||
int arg = retval;
|
||||
sendToReceiver<int>(F_SET_RECEIVER_DYNAMIC_RANGE, arg);
|
||||
}
|
||||
|
||||
// changes in dr
|
||||
if (n != prev_val) {
|
||||
// update speed for usability
|
||||
if (n == 32) {
|
||||
LOG(logINFO) << "Setting Clock to Quarter Speed to cope with "
|
||||
"Dynamic Range of 32";
|
||||
setClockDivider(RUN_CLOCK, 2);
|
||||
} else if (prev_val == 32) {
|
||||
LOG(logINFO) << "Setting Clock to Full Speed for Dynamic Range of "
|
||||
<< n;
|
||||
setClockDivider(RUN_CLOCK, 0);
|
||||
}
|
||||
updateRateCorrection();
|
||||
}
|
||||
}
|
||||
|
||||
slsDetectorDefs::timingMode Module::getTimingMode() {
|
||||
return sendToDetector<timingMode>(F_SET_TIMING_MODE, GET_FLAG);
|
||||
}
|
||||
@ -1017,38 +1049,6 @@ void Module::setClientStreamingIP(const sls::IpAddr ip) {
|
||||
|
||||
// Eiger Specific
|
||||
|
||||
int Module::getDynamicRange() {
|
||||
return sendToDetector<int>(F_SET_DYNAMIC_RANGE, GET_FLAG);
|
||||
}
|
||||
|
||||
void Module::setDynamicRange(int n) {
|
||||
int prev_val = n;
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
prev_val = getDynamicRange();
|
||||
}
|
||||
|
||||
auto retval = sendToDetector<int>(F_SET_DYNAMIC_RANGE, n);
|
||||
if (shm()->useReceiverFlag) {
|
||||
int arg = retval;
|
||||
sendToReceiver<int>(F_SET_RECEIVER_DYNAMIC_RANGE, arg);
|
||||
}
|
||||
|
||||
// changes in dr
|
||||
if (n != prev_val) {
|
||||
// update speed for usability
|
||||
if (n == 32) {
|
||||
LOG(logINFO) << "Setting Clock to Quarter Speed to cope with "
|
||||
"Dynamic Range of 32";
|
||||
setClockDivider(RUN_CLOCK, 2);
|
||||
} else if (prev_val == 32) {
|
||||
LOG(logINFO) << "Setting Clock to Full Speed for Dynamic Range of "
|
||||
<< n;
|
||||
setClockDivider(RUN_CLOCK, 0);
|
||||
}
|
||||
updateRateCorrection();
|
||||
}
|
||||
}
|
||||
|
||||
int64_t Module::getSubExptime() {
|
||||
return sendToDetector<int64_t>(F_GET_SUB_EXPTIME);
|
||||
}
|
||||
|
@ -125,6 +125,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
int64_t getNumberOfTriggersLeft() const;
|
||||
int64_t getDelayAfterTriggerLeft() const;
|
||||
int64_t getPeriodLeft() const;
|
||||
int getDynamicRange();
|
||||
void setDynamicRange(int n);
|
||||
timingMode getTimingMode();
|
||||
void setTimingMode(timingMode value);
|
||||
int getClockDivider(int clkIndex);
|
||||
@ -290,8 +292,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
* Eiger Specific *
|
||||
* *
|
||||
* ************************************************/
|
||||
int getDynamicRange();
|
||||
void setDynamicRange(int n);
|
||||
int64_t getSubExptime();
|
||||
void setSubExptime(int64_t value);
|
||||
int64_t getSubDeadTime();
|
||||
|
@ -315,47 +315,6 @@ TEST_CASE("txndelay_right", "[.cmd][.new]") {
|
||||
|
||||
/* Eiger Specific */
|
||||
|
||||
TEST_CASE("dr", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
auto dr = det.getDynamicRange().squash();
|
||||
std::array<int, 4> vals{4, 8, 16, 32};
|
||||
for (const auto val : vals) {
|
||||
std::ostringstream oss1, oss2;
|
||||
proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n');
|
||||
proxy.Call("dr", {}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n');
|
||||
}
|
||||
det.setDynamicRange(dr);
|
||||
} else if (det_type == defs::MYTHEN3) {
|
||||
// not updated in firmware to support anything other than 32 at the
|
||||
// moment
|
||||
std::ostringstream oss1, oss2;
|
||||
proxy.Call("dr", {"32"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dr 32\n");
|
||||
proxy.Call("dr", {"32"}, -1, PUT, oss2);
|
||||
REQUIRE(oss2.str() == "dr 32\n");
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"16"}, -1, PUT));
|
||||
} else {
|
||||
// For the other detectors we should get an error message
|
||||
// except for dr 16
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"32"}, -1, PUT));
|
||||
|
||||
std::ostringstream oss1, oss2;
|
||||
proxy.Call("dr", {"16"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dr 16\n");
|
||||
proxy.Call("dr", {"16"}, -1, PUT, oss2);
|
||||
REQUIRE(oss2.str() == "dr 16\n");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("subexptime", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
|
@ -451,6 +451,48 @@ TEST_CASE("periodl", "[.cmd][.new]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("dr", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
auto dr = det.getDynamicRange().squash();
|
||||
std::array<int, 4> vals{4, 8, 16, 32};
|
||||
for (const auto val : vals) {
|
||||
std::ostringstream oss1, oss2;
|
||||
proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n');
|
||||
proxy.Call("dr", {}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n');
|
||||
}
|
||||
det.setDynamicRange(dr);
|
||||
} else if (det_type == defs::MYTHEN3) {
|
||||
auto dr = det.getDynamicRange().squash();
|
||||
// not updated in firmware to support dr 1
|
||||
std::array<int, 3> vals{8, 16, 32};
|
||||
for (const auto val : vals) {
|
||||
std::ostringstream oss1, oss2;
|
||||
proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n');
|
||||
proxy.Call("dr", {}, -1, GET, oss2);
|
||||
REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n');
|
||||
}
|
||||
det.setDynamicRange(dr);
|
||||
} else {
|
||||
// For the other detectors we should get an error message
|
||||
// except for dr 16
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("dr", {"32"}, -1, PUT));
|
||||
|
||||
std::ostringstream oss1, oss2;
|
||||
proxy.Call("dr", {"16"}, -1, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "dr 16\n");
|
||||
proxy.Call("dr", {"16"}, -1, PUT, oss2);
|
||||
REQUIRE(oss2.str() == "dr 16\n");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("timing", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
|
Reference in New Issue
Block a user