This commit is contained in:
2021-07-01 15:11:22 +02:00
30 changed files with 372 additions and 110 deletions

View File

@@ -488,12 +488,14 @@ class Detector {
void stopReceiver();
/** Non blocking: start detector acquisition. Status changes to RUNNING or
* WAITING and automatically returns to idle at the end of acquisition. */
* WAITING and automatically returns to idle at the end of acquisition.
[Mythen3] Master starts acquisition first */
void startDetector();
/** [Mythen3] Non blocking: start detector readout of counters in chip.
* Status changes to TRANSMITTING and automatically returns to idle at the
* end of readout. */
* end of readout.
[Eiger] Master stops acquisition last */
void startDetectorReadout();
/** Non blocking: Abort detector acquisition. Status changes to IDLE or
@@ -520,8 +522,10 @@ class Detector {
* numbers for different modules.*/
void setNextFrameNumber(uint64_t value, Positions pos = {});
/** [Eiger][Mythen3] Sends an internal software trigger to the detector */
void sendSoftwareTrigger(Positions pos = {});
/** [Eiger][Mythen3] Sends an internal software trigger to the detector
* block true if command blocks till frames are sent out from that trigger
*/
void sendSoftwareTrigger(const bool block = false, Positions pos = {});
Result<defs::scanParameters> getScan(Positions pos = {}) const;
@@ -1316,6 +1320,7 @@ class Detector {
* (internal gating). Gate index: 0-2, -1 for all */
Result<std::array<ns, 3>> getGateDelayForAllGates(Positions pos = {}) const;
/** [Eiger][Mythen3][Gotthard1] via stop server **/
Result<bool> getMaster(Positions pos = {}) const;
// TODO! check if we really want to expose this !!!!!

View File

@@ -1193,6 +1193,41 @@ std::string CmdProxy::Scan(int action) {
return os.str();
}
std::string CmdProxy::Trigger(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "trigger") {
os << "[Eiger][Mythen3] Sends software trigger signal to detector";
} else if (cmd == "blockingtrigger") {
os << "[Eiger] Sends software trigger signal to detector and "
"blocks till "
"the frames are sent out for that trigger.";
} else {
throw sls::RuntimeError("unknown command " + cmd);
}
os << '\n';
} else if (action == slsDetectorDefs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == slsDetectorDefs::PUT_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError("Cannot execute this at module level");
}
if (!args.empty()) {
WrongNumberOfParameters(0);
}
bool block = false;
if (cmd == "blockingtrigger") {
block = true;
}
det->sendSoftwareTrigger(block);
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* Network Configuration (Detector<->Receiver) */
std::string CmdProxy::UDPDestinationIP(int action) {

View File

@@ -838,7 +838,7 @@ class CmdProxy {
{"rx_framescaught", &CmdProxy::rx_framescaught},
{"rx_missingpackets", &CmdProxy::rx_missingpackets},
{"nextframenumber", &CmdProxy::nextframenumber},
{"trigger", &CmdProxy::trigger},
{"trigger", &CmdProxy::Trigger},
{"scan", &CmdProxy::Scan},
{"scanerrmsg", &CmdProxy::scanerrmsg},
@@ -899,6 +899,7 @@ class CmdProxy {
{"rx_zmqhwm", &CmdProxy::rx_zmqhwm},
/* Eiger Specific */
{"blockingtrigger", &CmdProxy::Trigger},
{"subexptime", &CmdProxy::subexptime},
{"subdeadtime", &CmdProxy::subdeadtime},
{"overflow", &CmdProxy::overflow},
@@ -1094,6 +1095,7 @@ class CmdProxy {
std::string ReceiverStatus(int action);
std::string DetectorStatus(int action);
std::string Scan(int action);
std::string Trigger(int action);
/* Network Configuration (Detector<->Receiver) */
std::string UDPDestinationIP(int action);
std::string UDPDestinationIP2(int action);
@@ -1461,10 +1463,6 @@ class CmdProxy {
"Stopping acquisition might result in "
"different frame numbers for different modules.");
EXECUTE_SET_COMMAND(
trigger, sendSoftwareTrigger,
"\n\t[Eiger][Mythen3] Sends software trigger signal to detector.");
GET_COMMAND(scanerrmsg, getScanErrorMessage,
"\n\tGets Scan error message if scan ended in error for non "
"blocking acquisitions.");

View File

@@ -677,16 +677,16 @@ void Detector::startDetector() {
auto detector_type = getDetectorType().squash();
if (detector_type == defs::MYTHEN3 && size() > 1) {
auto is_master = getMaster();
std::vector<int> master;
int masterPosition = 0;
std::vector<int> slaves;
for (int i = 0; i < size(); ++i) {
if (is_master[i])
master.push_back(i);
masterPosition = i;
else
slaves.push_back(i);
}
pimpl->Parallel(&Module::startAcquisition, slaves);
pimpl->Parallel(&Module::startAcquisition, master);
pimpl->Parallel(&Module::startAcquisition, {masterPosition});
} else {
pimpl->Parallel(&Module::startAcquisition, {});
}
@@ -725,8 +725,8 @@ void Detector::setNextFrameNumber(uint64_t value, Positions pos) {
pimpl->Parallel(&Module::setNextFrameNumber, pos, value);
}
void Detector::sendSoftwareTrigger(Positions pos) {
pimpl->Parallel(&Module::sendSoftwareTrigger, pos);
void Detector::sendSoftwareTrigger(const bool block, Positions pos) {
pimpl->Parallel(&Module::sendSoftwareTrigger, pos, block);
}
Result<defs::scanParameters> Detector::getScan(Positions pos) const {

View File

@@ -776,7 +776,9 @@ void Module::setNextFrameNumber(uint64_t value) {
sendToDetector(F_SET_NEXT_FRAME_NUMBER, value, nullptr);
}
void Module::sendSoftwareTrigger() { sendToDetectorStop(F_SOFTWARE_TRIGGER); }
void Module::sendSoftwareTrigger(const bool block) {
sendToDetectorStop(F_SOFTWARE_TRIGGER, static_cast<int>(block), nullptr);
}
defs::scanParameters Module::getScan() const {
return sendToDetector<defs::scanParameters>(F_GET_SCAN);
@@ -2006,7 +2008,7 @@ std::array<time::ns, 3> Module::getGateDelayForAllGates() const {
return sendToDetector<std::array<time::ns, 3>>(F_GET_GATE_DELAY_ALL_GATES);
}
bool Module::isMaster() const { return sendToDetector<int>(F_GET_MASTER); }
bool Module::isMaster() const { return sendToDetectorStop<int>(F_GET_MASTER); }
int Module::getChipStatusRegister() const {
return sendToDetector<int>(F_GET_CSR);

View File

@@ -185,7 +185,7 @@ class Module : public virtual slsDetectorDefs {
std::vector<uint64_t> getNumMissingPackets() const;
uint64_t getNextFrameNumber() const;
void setNextFrameNumber(uint64_t value);
void sendSoftwareTrigger();
void sendSoftwareTrigger(const bool block);
defs::scanParameters getScan() const;
void setScan(const defs::scanParameters t);
std::string getScanErrorMessage() const;

View File

@@ -1446,6 +1446,45 @@ TEST_CASE("trigger", "[.cmd]") {
}
}
TEST_CASE("blockingtrigger", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_THROWS(proxy.Call("blockingtrigger", {}, -1, GET));
auto det_type = det.getDetectorType().squash();
if (det_type != defs::EIGER) {
REQUIRE_THROWS(proxy.Call("blockingtrigger", {}, -1, PUT));
} else if (det_type == defs::EIGER) {
auto prev_timing =
det.getTimingMode().tsquash("inconsistent timing mode in test");
auto prev_frames =
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
auto prev_exptime =
det.getExptime().tsquash("inconsistent exptime in test");
auto prev_period =
det.getPeriod().tsquash("inconsistent period in test");
det.setTimingMode(defs::TRIGGER_EXPOSURE);
det.setNumberOfFrames(1);
det.setExptime(std::chrono::microseconds(200));
det.setPeriod(std::chrono::milliseconds(1));
auto nextframenumber =
det.getNextFrameNumber().tsquash("inconsistent frame nr in test");
det.startDetector();
{
std::ostringstream oss;
proxy.Call("blockingtrigger", {}, -1, PUT, oss);
REQUIRE(oss.str() == "blockingtrigger successful\n");
}
auto currentfnum =
det.getNextFrameNumber().tsquash("inconsistent frame nr in test");
REQUIRE(nextframenumber + 1 == currentfnum);
det.stopDetector();
det.setTimingMode(prev_timing);
det.setNumberOfFrames(prev_frames);
det.setExptime(prev_exptime);
det.setPeriod(prev_period);
}
}
TEST_CASE("clearbusy", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);