Merge pull request #111 from slsdetectorgroup/shm

Shm
This commit is contained in:
Dhanya Thattil
2020-07-07 13:35:52 +02:00
committed by GitHub
50 changed files with 1646 additions and 1170 deletions

View File

@ -178,7 +178,7 @@ std::string CmdProxy::VirtualServer(int action) {
return os.str();
}
std::string CmdProxy::acquire(int action) {
std::string CmdProxy::Acquire(int action) {
std::ostringstream os;
if (action == defs::HELP_ACTION) {
os << cmd << " - Acquire the number of frames set up.\n";
@ -991,6 +991,60 @@ std::string CmdProxy::DetectorStatus(int action) {
return os.str();
}
std::string CmdProxy::Scan(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[dac_name|0|trimbit_scan] [start_val] [stop_val] "
"[step_size] [dac settling time ns|us|ms|s]\n\tConfigures to "
"scan dac and sets number of frames to number of steps. Must "
"acquire after this. To cancel the scan configuration "
"set dac to '0' without further arguments. This also sets number "
"of frames back to 1."
"\n\t[Eiger]Use trimbit_scan as dac name for a trimbit scan."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
auto t = det->getScan();
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError(
"Cannot configure scan at module level");
}
// disable
if (args.size() == 1) {
if (StringTo<int>(args[0]) != 0) {
throw sls::RuntimeError("Did you mean '0' to disable?");
}
det->setScan(defs::scanParameters());
}
// enable without settling time
else if (args.size() == 4) {
det->setScan(defs::scanParameters(
StringTo<defs::dacIndex>(args[0]), StringTo<int>(args[1]),
StringTo<int>(args[2]), StringTo<int>(args[3])));
}
// enable with all parameters
else if (args.size() == 5) {
std::string time_str(args[4]);
std::string unit = RemoveUnit(time_str);
auto t = StringTo<time::ns>(time_str, unit);
det->setScan(defs::scanParameters(
StringTo<defs::dacIndex>(args[0]), StringTo<int>(args[1]),
StringTo<int>(args[2]), StringTo<int>(args[3]), t));
} else {
WrongNumberOfParameters(4);
}
os << ToString(args) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* Network Configuration (Detector<->Receiver) */
std::string CmdProxy::UDPDestinationIP(int action) {

View File

@ -612,7 +612,7 @@ class CmdProxy {
{"gappixels", &CmdProxy::GapPixels},
/* acquisition parameters */
{"acquire", &CmdProxy::acquire},
{"acquire", &CmdProxy::Acquire},
{"frames", &CmdProxy::frames},
{"triggers", &CmdProxy::triggers},
{"exptime", &CmdProxy::Exptime},
@ -737,6 +737,8 @@ class CmdProxy {
{"rx_missingpackets", &CmdProxy::rx_missingpackets},
{"startingfnum", &CmdProxy::startingfnum},
{"trigger", &CmdProxy::trigger},
{"scan", &CmdProxy::Scan},
{"scanerrmsg", &CmdProxy::scanerrmsg},
/* Network Configuration (Detector<->Receiver) */
{"numinterfaces", &CmdProxy::numinterfaces},
@ -965,7 +967,7 @@ class CmdProxy {
std::string SettingsList(int action);
std::string GapPixels(int action);
/* acquisition parameters */
std::string acquire(int action);
std::string Acquire(int action);
std::string Exptime(int action);
std::string Speed(int action);
std::string Adcphase(int action);
@ -983,6 +985,7 @@ class CmdProxy {
/* acquisition */
std::string ReceiverStatus(int action);
std::string DetectorStatus(int action);
std::string Scan(int action);
/* Network Configuration (Detector<->Receiver) */
std::string UDPDestinationIP(int action);
std::string UDPDestinationIP2(int action);
@ -1552,6 +1555,10 @@ class CmdProxy {
trigger, sendSoftwareTrigger,
"\n\t[Eiger] Sends software trigger signal to detector.");
GET_COMMAND(scanerrmsg, getScanErrorMessage,
"\n\tGets Scan error message if scan ended in error for non "
"blocking acquisitions.");
/* Network Configuration (Detector<->Receiver) */
INTEGER_COMMAND(

View File

@ -525,9 +525,6 @@ void Detector::startReceiver() { pimpl->Parallel(&Module::startReceiver, {}); }
void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); }
void Detector::startDetector() {
if (getDetectorType().squash() == defs::EIGER) {
pimpl->Parallel(&Module::prepareAcquisition, {});
}
pimpl->Parallel(&Module::startAcquisition, {});
}
@ -562,6 +559,18 @@ void Detector::sendSoftwareTrigger(Positions pos) {
pimpl->Parallel(&Module::sendSoftwareTrigger, pos);
}
Result<defs::scanParameters> Detector::getScan(Positions pos) const {
return pimpl->Parallel(&Module::getScan, pos);
}
void Detector::setScan(const defs::scanParameters t) {
pimpl->Parallel(&Module::setScan, {}, t);
}
Result<std::string> Detector::getScanErrorMessage(Positions pos) const {
return pimpl->Parallel(&Module::getScanErrorMessage, pos);
}
// Network Configuration (Detector<->Receiver)
Result<int> Detector::getNumberofUDPInterfaces(Positions pos) const {

View File

@ -1046,9 +1046,6 @@ int DetectorImpl::acquire() {
// start and read all
try {
if (multi_shm()->multiDetectorType == EIGER) {
Parallel(&Module::prepareAcquisition, {});
}
Parallel(&Module::startAndReadAll, {});
} catch (...) {
if (receiver)

View File

@ -367,8 +367,6 @@ void Module::stopReceiver() {
sendToReceiver(F_STOP_RECEIVER, arg, nullptr);
}
void Module::prepareAcquisition() { sendToDetector(F_PREPARE_ACQUISITION); }
void Module::startAcquisition() {
shm()->stoppedFlag = false;
sendToDetector(F_START_ACQUISITION);
@ -451,6 +449,22 @@ void Module::setStartingFrameNumber(uint64_t value) {
void Module::sendSoftwareTrigger() { sendToDetectorStop(F_SOFTWARE_TRIGGER); }
defs::scanParameters Module::getScan() {
return sendToDetector<defs::scanParameters>(F_GET_SCAN);
}
void Module::setScan(const defs::scanParameters t) {
auto retval = sendToDetector<int64_t>(F_SET_SCAN, t);
// if disabled, retval is 1, else its number of steps
setNumberOfFrames(retval);
}
std::string Module::getScanErrorMessage() {
char retval[MAX_STR_LENGTH]{};
sendToDetector(F_GET_SCAN_ERROR_MESSAGE, nullptr, retval);
return retval;
}
// Network Configuration (Detector<->Receiver)
int Module::getNumberofUDPInterfacesFromShm() {

View File

@ -155,7 +155,6 @@ class Module : public virtual slsDetectorDefs {
* ************************************************/
void startReceiver();
void stopReceiver();
void prepareAcquisition();
void startAcquisition();
void stopAcquisition();
void startAndReadAll();
@ -167,6 +166,9 @@ class Module : public virtual slsDetectorDefs {
uint64_t getStartingFrameNumber();
void setStartingFrameNumber(uint64_t value);
void sendSoftwareTrigger();
defs::scanParameters getScan();
void setScan(const defs::scanParameters t);
std::string getScanErrorMessage();
/**************************************************
* *