mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +02:00
txdelay for all modules (#584)
* setting txdelay for all modules for eiger, jungfrau and m3 * added txdelay in python and renamed txndelay_ to txdelay_ * call in parallel
This commit is contained in:
@ -1705,6 +1705,42 @@ std::string CmdProxy::UDPDestinationIP2(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::TransmissionDelay(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_delay]\n\t[Eiger][Jungfrau][Mythen3] Set transmission delay "
|
||||
"for all modules in the detector using the step size "
|
||||
"provided.Sets up \n\t\t[Eiger] txdelay_left to (2 * mod_index * "
|
||||
"n_delay), \n\t\t[Eiger] txdelay_right to ((2 * mod_index + 1) * "
|
||||
"n_delay) and \n\t\t[Eiger] txdelay_frame to (2 *num_modules * "
|
||||
"n_delay) \n\t\t[Jungfrau][Mythen3] txdelay_frame to "
|
||||
"(num_modules * n_delay) \nfor every module."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw RuntimeError("Cannot execute this at module level");
|
||||
}
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getTransmissionDelay();
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw RuntimeError("Cannot execute this at module level");
|
||||
}
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setTransmissionDelay(StringTo<int>(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
/* Receiver Config */
|
||||
std::string CmdProxy::ReceiverHostname(int action) {
|
||||
std::ostringstream os;
|
||||
|
@ -697,6 +697,9 @@ class CmdProxy {
|
||||
{"rx_udpport", "udp_dstport"},
|
||||
{"rx_udpport2", "udp_dstport2"},
|
||||
{"flowcontrol_10g", "flowcontrol10g"},
|
||||
{"txndelay_frame", "txdelay_frame"},
|
||||
{"txndelay_left", "txdelay_left"},
|
||||
{"txndelay_right", "txdelay_right"},
|
||||
|
||||
/* Receiver Config */
|
||||
{"r_silent", "rx_silent"},
|
||||
@ -893,9 +896,10 @@ class CmdProxy {
|
||||
{"rx_printconfig", &CmdProxy::rx_printconfig},
|
||||
{"tengiga", &CmdProxy::tengiga},
|
||||
{"flowcontrol10g", &CmdProxy::flowcontrol10g},
|
||||
{"txndelay_frame", &CmdProxy::txndelay_frame},
|
||||
{"txndelay_left", &CmdProxy::txndelay_left},
|
||||
{"txndelay_right", &CmdProxy::txndelay_right},
|
||||
{"txdelay_frame", &CmdProxy::txdelay_frame},
|
||||
{"txdelay_left", &CmdProxy::txdelay_left},
|
||||
{"txdelay_right", &CmdProxy::txdelay_right},
|
||||
{"txdelay", &CmdProxy::TransmissionDelay},
|
||||
|
||||
/* Receiver Config */
|
||||
{"rx_hostname", &CmdProxy::ReceiverHostname},
|
||||
@ -1158,6 +1162,7 @@ class CmdProxy {
|
||||
std::string UDPSourceIP2(int action);
|
||||
std::string UDPDestinationIP(int action);
|
||||
std::string UDPDestinationIP2(int action);
|
||||
std::string TransmissionDelay(int action);
|
||||
/* Receiver Config */
|
||||
std::string ReceiverHostname(int action);
|
||||
std::string Rx_ROI(int action);
|
||||
@ -1689,24 +1694,24 @@ class CmdProxy {
|
||||
"[0, 1]\n\t[Eiger][Jungfrau] 10GbE Flow Control.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
txndelay_frame, getTransmissionDelayFrame, setTransmissionDelayFrame,
|
||||
txdelay_frame, getTransmissionDelayFrame, setTransmissionDelayFrame,
|
||||
StringTo<int>,
|
||||
"[n_delay]\n\t[Eiger][Jungfrau][Mythen3] Transmission delay of first "
|
||||
"udp packet being streamed out of the module.\n\t[Jungfrau] [0-31] "
|
||||
"Each value represents 1 ms\n\t[Eiger] Additional delay to "
|
||||
"txndelay_left and txndelay_right. Each value represents 10ns. Typical "
|
||||
"txdelay_left and txdelay_right. Each value represents 10ns. Typical "
|
||||
"value is 50000.\n\t[Mythen3] [0-16777215] Each value represents 8 ns "
|
||||
"(125 MHz clock), max is 134 ms.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
txndelay_left, getTransmissionDelayLeft, setTransmissionDelayLeft,
|
||||
txdelay_left, getTransmissionDelayLeft, setTransmissionDelayLeft,
|
||||
StringTo<int>,
|
||||
"[n_delay]\n\t[Eiger] Transmission delay of first packet in an image "
|
||||
"being streamed out of the module's left UDP port. Each value "
|
||||
"represents 10ns. Typical value is 50000.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
txndelay_right, getTransmissionDelayRight, setTransmissionDelayRight,
|
||||
txdelay_right, getTransmissionDelayRight, setTransmissionDelayRight,
|
||||
StringTo<int>,
|
||||
"[n_delay]\n\t[Eiger] Transmission delay of first packet in an image "
|
||||
"being streamed out of the module's right UDP port. Each value "
|
||||
|
@ -1120,6 +1120,14 @@ void Detector::setTransmissionDelayRight(int value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setTransmissionDelayRight, pos, value);
|
||||
}
|
||||
|
||||
int Detector::getTransmissionDelay() const {
|
||||
return pimpl->getTransmissionDelay();
|
||||
}
|
||||
|
||||
void Detector::setTransmissionDelay(int step) {
|
||||
pimpl->setTransmissionDelay(step);
|
||||
}
|
||||
|
||||
// Receiver
|
||||
|
||||
Result<bool> Detector::getUseReceiverFlag(Positions pos) const {
|
||||
|
@ -431,6 +431,89 @@ void DetectorImpl::setGapPixelsinCallback(const bool enable) {
|
||||
shm()->gapPixels = enable;
|
||||
}
|
||||
|
||||
int DetectorImpl::getTransmissionDelay() const {
|
||||
bool eiger = false;
|
||||
switch (shm()->detType) {
|
||||
case JUNGFRAU:
|
||||
case MYTHEN3:
|
||||
break;
|
||||
case EIGER:
|
||||
eiger = true;
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError(
|
||||
"Transmission delay is not implemented for the this detector.");
|
||||
}
|
||||
if (!eiger && size() <= 1) {
|
||||
throw RuntimeError(
|
||||
"Cannot get intermodule transmission delays with just one module");
|
||||
}
|
||||
int step = 0;
|
||||
if (eiger) {
|
||||
// between left and right
|
||||
step = modules[0]->getTransmissionDelayRight();
|
||||
} else {
|
||||
// between first and second
|
||||
step = modules[1]->getTransmissionDelayFrame();
|
||||
}
|
||||
for (int i = 0; i != size(); ++i) {
|
||||
if (eiger) {
|
||||
if ((modules[i]->getTransmissionDelayLeft() != (2 * i * step)) ||
|
||||
(modules[i]->getTransmissionDelayRight() !=
|
||||
((2 * i + 1) * step)) ||
|
||||
(modules[i]->getTransmissionDelayFrame() !=
|
||||
(2 * size() * step))) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (modules[i]->getTransmissionDelayFrame() != (i * step)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return step;
|
||||
}
|
||||
|
||||
void DetectorImpl::setTransmissionDelay(int step) {
|
||||
bool eiger = false;
|
||||
switch (shm()->detType) {
|
||||
case JUNGFRAU:
|
||||
case MYTHEN3:
|
||||
break;
|
||||
case EIGER:
|
||||
eiger = true;
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError(
|
||||
"Transmission delay is not implemented for the this detector.");
|
||||
}
|
||||
|
||||
//using a asyc+future directly (instead of Parallel) to pass different values
|
||||
std::vector<std::future<void>> futures;
|
||||
for (int i = 0; i != size(); ++i) {
|
||||
if (eiger) {
|
||||
futures.push_back(std::async(std::launch::async,
|
||||
&Module::setTransmissionDelayLeft,
|
||||
modules[i].get(), 2 * i * step));
|
||||
futures.push_back(std::async(std::launch::async,
|
||||
&Module::setTransmissionDelayRight,
|
||||
modules[i].get(), (2 * i + 1) * step));
|
||||
futures.push_back(std::async(std::launch::async,
|
||||
&Module::setTransmissionDelayFrame,
|
||||
modules[i].get(), 2 * size() * step));
|
||||
|
||||
} else {
|
||||
futures.push_back(std::async(std::launch::async,
|
||||
&Module::setTransmissionDelayFrame,
|
||||
modules[i].get(), i * step));
|
||||
}
|
||||
}
|
||||
|
||||
//wait for calls to complete
|
||||
for (auto &f : futures)
|
||||
f.get();
|
||||
}
|
||||
|
||||
int DetectorImpl::destroyReceivingDataSockets() {
|
||||
LOG(logINFO) << "Going to destroy data sockets";
|
||||
// close socket
|
||||
|
@ -237,11 +237,10 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
* Sets maximum number of channels of all sls modules */
|
||||
void setNumberOfChannels(const slsDetectorDefs::xy c);
|
||||
|
||||
/** [Eiger][Jungfrau] */
|
||||
bool getGapPixelsinCallback() const;
|
||||
/** [Eiger][Jungfrau] */
|
||||
void setGapPixelsinCallback(const bool enable);
|
||||
|
||||
int getTransmissionDelay() const;
|
||||
void setTransmissionDelay(int step);
|
||||
bool getDataStreamingToClient();
|
||||
void setDataStreamingToClient(bool enable);
|
||||
int getClientStreamingHwm() const;
|
||||
|
Reference in New Issue
Block a user