merge from developer (mythen3 branch)

This commit is contained in:
2020-05-27 14:19:33 +02:00
52 changed files with 3684 additions and 1201 deletions

View File

@ -203,7 +203,9 @@ class Detector {
Result<defs::timingMode> getTimingMode(Positions pos = {}) const;
/**
* [Gotthard][Jungfrau][CTB][Moench] Options: AUTO_TIMING, TRIGGER_EXPOSURE
* [Gotthard][Jungfrau][CTB][Moench][Mythen3] Options:
* AUTO_TIMING, TRIGGER_EXPOSURE
* [Gotthard2] Options: AUTO_TIMING, TRIGGER_EXPOSURE, GATED, TRIGGER_GATED
* [Eiger] Options: AUTO_TIMING, TRIGGER_EXPOSURE, GATED, BURST_TRIGGER
*/
void setTimingMode(defs::timingMode value, Positions pos = {});
@ -914,12 +916,17 @@ class Detector {
/** [Gotthard] */
Result<ns> getExptimeLeft(Positions pos = {}) const;
/** [Gotthard] */
/** [Gotthard] signal index is 0
* [Mythen3] signal index 0-3 for master input, 4-7 master output signals */
Result<defs::externalSignalFlag>
getExternalSignalFlags(Positions pos = {}) const;
getExternalSignalFlags(int signalIndex, Positions pos = {}) const;
/** [Gotthard] Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE */
void setExternalSignalFlags(defs::externalSignalFlag value,
/** [Gotthard] signal index is 0
* Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE
* [Mythen3] signal index 0-3 for master input, 4-7 master output signals
* Options: TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE (for master
* input trigger only), INVERSION_ON, INVERSION_OFF */
void setExternalSignalFlags(int signalIndex, defs::externalSignalFlag value,
Positions pos = {});
/**************************************************
@ -997,6 +1004,36 @@ class Detector {
/** [Mythen3] countermask bit set for each counter enabled */
void setCounterMask(uint32_t countermask, Positions pos = {});
Result<int> getNumberOfGates(Positions pos = {}) const;
/** [Mythen3] external gates in gating or trigger_gating mode (external
* gating) */
void setNumberOfGates(int value, Positions pos = {});
/** [Mythen3] exptime for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2 */
Result<ns> getExptime(int gateIndex, Positions pos = {}) const;
/** [Mythen3] exptime for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2, -1 for all */
void setExptime(int gateIndex, ns t, Positions pos = {});
/** [Mythen3] exptime for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2, -1 for all */
Result<std::array<ns, 3>> getExptimeForAllGates(Positions pos = {}) const;
/** [Mythen3] gate delay for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2 */
Result<ns> getGateDelay(int gateIndex, Positions pos = {}) const;
/** [Mythen3] gate delay for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2, -1 for all */
void setGateDelay(int gateIndex, ns t, Positions pos = {});
/** [Mythen3] gate delay for each gate signal in auto or trigger timing mode
* (internal gating). Gate index: 0-2, -1 for all */
Result<std::array<ns, 3>> getGateDelayForAllGates(Positions pos = {}) const;
/**************************************************
* *
* CTB / Moench Specific *
@ -1216,6 +1253,9 @@ class Detector {
*/
void setPatternBitMask(uint64_t mask, Positions pos = {});
/** [Mythen3] */
void startPattern(Positions pos = {});
/**************************************************
* *
* Moench *

View File

@ -333,6 +333,110 @@ std::string CmdProxy::DetectorSize(int action) {
/* acquisition parameters */
std::string CmdProxy::Exptime(int action) {
int gateIndex = -1;
if (cmd == "exptime") {
gateIndex = -1;
} else if (cmd == "exptime1") {
gateIndex = 0;
} else if (cmd == "exptime2") {
gateIndex = 1;
} else if (cmd == "exptime3") {
gateIndex = 2;
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "exptime") {
os << "[duration] [(optional unit) "
"ns|us|ms|s]\n\t[Eiger][Jungfrau][Gotthard][Gotthard2]["
"Moench][Ctb] Exposure time"
"\n\t[Gotthard2] Uploaded to detector just before "
"acquisition starts"
"\n\t[Mythen3] Exposure time of all gate signals in auto and "
"trigger mode (internal gating)."
<< '\n';
} else if (cmd == "exptime1") {
os << "[n_value]\n\t[Mythen3] Exposure time of gate signal 1 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
} else if (cmd == "exptime2") {
os << "[n_value]\n\t[Mythen3] Exposure time of gate signal 2 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
} else {
os << "[n_value]\n\t[Mythen3] Exposure time of gate signal 3 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
}
} else if (action == defs::GET_ACTION) {
if (args.size() > 1) {
WrongNumberOfParameters(1);
}
// vector of exptimes
if (gateIndex == -1 &&
det->getDetectorType().squash() == defs::MYTHEN3) {
auto t = det->getExptimeForAllGates({det_id});
if (args.size() == 0) {
os << OutString(t) << '\n';
} else if (args.size() == 1) {
os << OutString(t, args[0]) << '\n';
}
}
// single exptime
else {
Result<ns> t;
if (gateIndex == -1) {
t = det->getExptime({det_id});
} else {
t = det->getExptime(gateIndex, {det_id});
}
if (args.size() == 0) {
os << OutString(t) << '\n';
} else if (args.size() == 1) {
os << OutString(t, args[0]) << '\n';
}
}
} else if (action == defs::PUT_ACTION) {
defs::detectorType type = det->getDetectorType().squash();
if (args.size() == 1) {
std::string time_str(args[0]);
std::string unit = RemoveUnit(time_str);
auto t = StringTo<time::ns>(time_str, unit);
if (type == defs::MYTHEN3) {
det->setExptime(gateIndex, t, {det_id});
} else {
det->setExptime(t, {det_id});
}
} else if (args.size() == 2) {
auto t = StringTo<time::ns>(args[0], args[1]);
if (type == defs::MYTHEN3) {
det->setExptime(gateIndex, t, {det_id});
} else {
det->setExptime(t, {det_id});
}
} else {
WrongNumberOfParameters(2);
}
/* TODO: os << args << '\n'; (doesnt work for vectors in .h)*/
if (args.size() > 1) {
os << args[0] << args[1] << '\n';
} else {
os << args[0] << '\n';
}
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::Speed(int action) {
std::ostringstream os;
os << cmd << ' ';
@ -652,6 +756,39 @@ std::string CmdProxy::ClockDivider(int action) {
return os.str();
}
std::string CmdProxy::ExternalSignal(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[n_signal] [signal_type] External signal mode for trigger "
"timing mode."
"\n\t[Gotthard] [0] "
"[trigger_in_rising_edge|trigger_in_falling_edge]"
"\n\t[Mythen3] [0-7] "
"[trigger_in_rising_edge|trigger_in_falling_edge|inversion_on|"
"inversion_off]\n\t where 0-3 is master input signals and 4-7 is "
"master output signals"
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
auto t = det->getExternalSignalFlags(StringTo<int>(args[0]), {det_id});
os << args[0] << " " << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
det->setExternalSignalFlags(
StringTo<int>(args[0]),
StringTo<slsDetectorDefs::externalSignalFlag>(args[1]), {det_id});
os << args[0] << " " << args[1] << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/** temperature */
/* dacs */
std::string CmdProxy::Dac(int action) {
@ -1591,6 +1728,92 @@ std::string CmdProxy::Counters(int action) {
return os.str();
}
std::string CmdProxy::GateDelay(int action) {
int gateIndex = -1;
if (cmd == "gatedelay") {
gateIndex = -1;
} else if (cmd == "gatedelay1") {
gateIndex = 0;
} else if (cmd == "gatedelay2") {
gateIndex = 1;
} else if (cmd == "gatedelay3") {
gateIndex = 2;
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "gatedelay") {
os << "[duration] [(optional unit) "
"ns|us|ms|s]\n\t[Mythen3] Gate Delay of all gate signals in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
} else if (cmd == "gatedelay1") {
os << "[n_value]\n\t[Mythen3] Gate Delay of gate signal 1 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
} else if (cmd == "gatedelay2") {
os << "[n_value]\n\t[Mythen3] Gate Delay of gate signal 2 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
} else {
os << "[n_value]\n\t[Mythen3] Gate Delay of gate signal 3 in "
"auto and "
"trigger mode (internal gating)."
<< '\n';
}
} else if (action == defs::GET_ACTION) {
if (args.size() > 1) {
WrongNumberOfParameters(1);
}
// vector of gate delays
if (gateIndex == -1) {
auto t = det->getGateDelayForAllGates({det_id});
if (args.size() == 0) {
os << OutString(t) << '\n';
} else if (args.size() == 1) {
os << OutString(t, args[0]) << '\n';
}
}
// single gate delay
else {
auto t = det->getGateDelay(gateIndex, {det_id});
if (args.size() == 0) {
os << OutString(t) << '\n';
} else if (args.size() == 1) {
os << OutString(t, args[0]) << '\n';
}
}
} else if (action == defs::PUT_ACTION) {
if (args.size() == 1) {
std::string time_str(args[0]);
std::string unit = RemoveUnit(time_str);
auto t = StringTo<time::ns>(time_str, unit);
det->setGateDelay(gateIndex, t, {det_id});
} else if (args.size() == 2) {
auto t = StringTo<time::ns>(args[0], args[1]);
det->setGateDelay(gateIndex, t, {det_id});
} else {
WrongNumberOfParameters(2);
}
/* TODO: os << args << '\n'; (doesnt work for vectors in .h)*/
if (args.size() > 1) {
os << args[0] << args[1] << '\n';
} else {
os << args[0] << '\n';
}
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* CTB / Moench Specific */
std::string CmdProxy::Samples(int action) {

View File

@ -570,7 +570,7 @@ class CmdProxy {
{"acquire", &CmdProxy::acquire},
{"frames", &CmdProxy::frames},
{"triggers", &CmdProxy::triggers},
{"exptime", &CmdProxy::exptime},
{"exptime", &CmdProxy::Exptime},
{"period", &CmdProxy::period},
{"delay", &CmdProxy::delay},
{"framesl", &CmdProxy::framesl},
@ -590,6 +590,7 @@ class CmdProxy {
{"vhighvoltage", &CmdProxy::vhighvoltage},
{"powerchip", &CmdProxy::powerchip},
{"imagetest", &CmdProxy::imagetest},
{"extsig", &CmdProxy::ExternalSignal},
/** temperature */
{"temp_adc", &CmdProxy::temp_adc},
@ -784,7 +785,6 @@ class CmdProxy {
{"roi", &CmdProxy::ROI},
{"clearroi", &CmdProxy::ClearROI},
{"exptimel", &CmdProxy::exptimel},
{"extsig", &CmdProxy::extsig},
/* Gotthard2 Specific */
{"bursts", &CmdProxy::bursts},
@ -799,6 +799,14 @@ class CmdProxy {
/* Mythen3 Specific */
{"counters", &CmdProxy::Counters},
{"gates", &CmdProxy::gates},
{"exptime1", &CmdProxy::Exptime},
{"exptime2", &CmdProxy::Exptime},
{"exptime3", &CmdProxy::Exptime},
{"gatedelay", &CmdProxy::GateDelay},
{"gatedelay1", &CmdProxy::GateDelay},
{"gatedelay2", &CmdProxy::GateDelay},
{"gatedelay3", &CmdProxy::GateDelay},
/* CTB/ Moench Specific */
{"samples", &CmdProxy::Samples},
@ -861,6 +869,7 @@ class CmdProxy {
{"patwaittime2", &CmdProxy::PatternWaitTime},
{"patmask", &CmdProxy::patmask},
{"patsetbit", &CmdProxy::patsetbit},
{"patternstart", &CmdProxy::patternstart},
/* Moench */
{"rx_jsonaddheader", &CmdProxy::AdditionalJsonHeader},
@ -916,6 +925,7 @@ class CmdProxy {
std::string DetectorSize(int action);
/* acquisition parameters */
std::string acquire(int action);
std::string Exptime(int action);
std::string Speed(int action);
std::string Adcphase(int action);
std::string Dbitphase(int action);
@ -923,6 +933,7 @@ class CmdProxy {
std::string ClockPhase(int action);
std::string MaxClockPhaseShift(int action);
std::string ClockDivider(int action);
std::string ExternalSignal(int action);
/** temperature */
/* dacs */
std::string Dac(int action);
@ -963,6 +974,7 @@ class CmdProxy {
std::string BurstMode(int action);
/* Mythen3 Specific */
std::string Counters(int action);
std::string GateDelay(int action);
/* CTB/ Moench Specific */
std::string Samples(int action);
/* CTB Specific */
@ -1055,11 +1067,6 @@ class CmdProxy {
"[n_triggers]\n\tNumber of triggers per aquire. Use "
"timing command to set timing mode.");
TIME_COMMAND(
exptime, getExptime, setExptime,
"[duration] [(optional unit) ns|us|ms|s]\n\tExposure time"
"\n\t[Gotthard2] Uploaded to detector just before acquisition starts");
TIME_COMMAND(
period, getPeriod, setPeriod,
"[duration] [(optional unit) ns|us|ms|s]\n\tPeriod between frames"
@ -1094,12 +1101,13 @@ class CmdProxy {
" Period left for current frame."
"\n\t[Gotthard2] only in continuous mode.");
INTEGER_COMMAND(
timing, getTimingMode, setTimingMode,
sls::StringTo<slsDetectorDefs::timingMode>,
"[auto|trigger|gating|burst_trigger]\n\tTiming Mode of "
"detector.\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] "
"[auto|trigger]\n\t[Eiger] [auto|trigger|gating|burst_trigger]");
INTEGER_COMMAND(timing, getTimingMode, setTimingMode,
sls::StringTo<slsDetectorDefs::timingMode>,
"[auto|trigger|gating|burst_trigger]\n\tTiming Mode of "
"detector.\n\t[Jungfrau][Gotthard][Mythen3][Ctb][Moench] "
"[auto|trigger]\n\t[Gotthard2] "
"[auto|trigger|gating|trigger_gating]\n\t[Eiger] "
"[auto|trigger|gating|burst_trigger]");
GET_COMMAND(maxadcphaseshift, getMaxADCPhaseShift,
"\n\t[Jungfrau][CTB][Moench] Absolute maximum Phase shift of "
@ -1852,11 +1860,6 @@ class CmdProxy {
"[(optional unit) ns|us|ms|s]\n\t[Gotthard] Exposure time "
"left for current frame. ");
INTEGER_COMMAND(extsig, getExternalSignalFlags, setExternalSignalFlags,
sls::StringTo<slsDetectorDefs::externalSignalFlag>,
"[trigger_in_rising_edge|trigger_in_falling_edge]\n\t["
"Gotthard] External signal mode for trigger timing mode.");
/* Gotthard2 Specific */
INTEGER_COMMAND_NOID(
bursts, getNumberOfBursts, setNumberOfBursts, StringTo<int64_t>,
@ -1881,6 +1884,10 @@ class CmdProxy {
/* Mythen3 Specific */
INTEGER_COMMAND(gates, getNumberOfGates, setNumberOfGates, StringTo<int>,
"[n_gates]\n\t[Mythen3] Number of external gates in gating "
"or trigger_gating mode (external gating).");
/* CTB/ Moench Specific */
INTEGER_COMMAND(
@ -2038,6 +2045,9 @@ class CmdProxy {
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit values "
"applied to the selected patmask for every pattern.");
EXECUTE_SET_COMMAND(patternstart, startPattern,
"\n\t[Mythen3] Starts Pattern");
/* Moench */
INTEGER_COMMAND(framemode, getFrameMode, setFrameMode,

View File

@ -202,11 +202,11 @@ void Detector::setNumberOfTriggers(int64_t value) {
}
Result<ns> Detector::getExptime(Positions pos) const {
return pimpl->Parallel(&Module::getExptime, pos);
return pimpl->Parallel(&Module::getExptime, pos, -1);
}
void Detector::setExptime(ns t, Positions pos) {
pimpl->Parallel(&Module::setExptime, pos, t.count());
pimpl->Parallel(&Module::setExptime, pos, -1, t.count());
}
Result<ns> Detector::getPeriod(Positions pos) const {
@ -1169,14 +1169,14 @@ Result<ns> Detector::getExptimeLeft(Positions pos) const {
}
Result<defs::externalSignalFlag>
Detector::getExternalSignalFlags(Positions pos) const {
return pimpl->Parallel(&Module::setExternalSignalFlags, pos,
defs::GET_EXTERNAL_SIGNAL_FLAG);
Detector::getExternalSignalFlags(int signalIndex, Positions pos) const {
return pimpl->Parallel(&Module::getExternalSignalFlags, pos, signalIndex);
}
void Detector::setExternalSignalFlags(defs::externalSignalFlag value,
void Detector::setExternalSignalFlags(int signalIndex,
defs::externalSignalFlag value,
Positions pos) {
pimpl->Parallel(&Module::setExternalSignalFlags, pos, value);
pimpl->Parallel(&Module::setExternalSignalFlags, pos, signalIndex, value);
}
// Gotthard2 Specific
@ -1266,6 +1266,39 @@ void Detector::setCounterMask(uint32_t countermask, Positions pos) {
pimpl->Parallel(&Module::setCounterMask, pos, countermask);
}
Result<int> Detector::getNumberOfGates(Positions pos) const {
return pimpl->Parallel(&Module::getNumberOfGates, pos);
}
void Detector::setNumberOfGates(int value, Positions pos) {
pimpl->Parallel(&Module::setNumberOfGates, pos, value);
}
Result<ns> Detector::getExptime(int gateIndex, Positions pos) const {
return pimpl->Parallel(&Module::getExptime, pos, gateIndex);
}
void Detector::setExptime(int gateIndex, ns t, Positions pos) {
pimpl->Parallel(&Module::setExptime, pos, gateIndex, t.count());
}
Result<std::array<ns, 3>> Detector::getExptimeForAllGates(Positions pos) const {
return pimpl->Parallel(&Module::getExptimeForAllGates, pos);
}
Result<ns> Detector::getGateDelay(int gateIndex, Positions pos) const {
return pimpl->Parallel(&Module::getGateDelay, pos, gateIndex);
}
void Detector::setGateDelay(int gateIndex, ns t, Positions pos) {
pimpl->Parallel(&Module::setGateDelay, pos, gateIndex, t.count());
}
Result<std::array<ns, 3>>
Detector::getGateDelayForAllGates(Positions pos) const {
return pimpl->Parallel(&Module::getGateDelayForAllGates, pos);
}
// CTB/ Moench Specific
Result<int> Detector::getNumberOfAnalogSamples(Positions pos) const {
@ -1582,6 +1615,10 @@ void Detector::setPatternBitMask(uint64_t mask, Positions pos) {
pimpl->Parallel(&Module::setPatternBitMask, pos, mask);
}
void Detector::startPattern(Positions pos) {
pimpl->Parallel(&Module::startPattern, pos);
}
// Moench
Result<std::map<std::string, std::string>>

View File

@ -151,7 +151,7 @@ template <typename Ret> Ret Module::sendToDetector(int fnum) {
<< sizeof(Ret) << "]";
Ret retval{};
sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
LOG(logDEBUG1) << "Got back: " << retval;
LOG(logDEBUG1) << "Got back: " << ToString(retval);
return retval;
}
@ -163,7 +163,7 @@ Ret Module::sendToDetector(int fnum, const Arg &args) {
<< typeid(Ret).name() << ", " << sizeof(Ret) << "]";
Ret retval{};
sendToDetector(fnum, &args, sizeof(args), &retval, sizeof(retval));
LOG(logDEBUG1) << "Got back: " << retval;
LOG(logDEBUG1) << "Got back: " << ToString(retval);
return retval;
}
@ -1027,24 +1027,64 @@ void Module::setNumberOfDigitalSamples(int value) {
}
}
int64_t Module::getExptime() { return sendToDetector<int64_t>(F_GET_EXPTIME); }
int Module::getNumberOfGates() { return sendToDetector<int>(F_GET_NUM_GATES); }
void Module::setExptime(int64_t value) {
void Module::setNumberOfGates(int value) {
LOG(logDEBUG1) << "Setting number of gates to " << value;
sendToDetector(F_SET_NUM_GATES, value, nullptr);
if (shm()->useReceiverFlag) {
LOG(logDEBUG1) << "Sending number of gates to Receiver: " << value;
sendToReceiver(F_SET_RECEIVER_NUM_GATES, value, nullptr);
}
}
int64_t Module::getExptime(int gateIndex) {
return sendToDetector<int64_t>(F_GET_EXPTIME, gateIndex);
}
void Module::setExptime(int gateIndex, int64_t value) {
int64_t prevVal = value;
if (shm()->myDetectorType == EIGER) {
prevVal = getExptime();
prevVal = getExptime(-1);
}
LOG(logDEBUG1) << "Setting exptime to " << value << "ns";
sendToDetector(F_SET_EXPTIME, value, nullptr);
LOG(logDEBUG1) << "Setting exptime to " << value
<< "ns (gateindex: " << gateIndex << ")";
int64_t args[]{static_cast<int64_t>(gateIndex), value};
sendToDetector(F_SET_EXPTIME, args, nullptr);
if (shm()->useReceiverFlag) {
LOG(logDEBUG1) << "Sending exptime to Receiver: " << value;
sendToReceiver(F_RECEIVER_SET_EXPTIME, value, nullptr);
sendToReceiver(F_RECEIVER_SET_EXPTIME, args, nullptr);
}
if (prevVal != value) {
updateRateCorrection();
}
}
std::array<time::ns, 3> Module::getExptimeForAllGates() {
static_assert(sizeof(time::ns) == 8, "ns needs to be 64bit");
return sendToDetector<std::array<time::ns, 3>>(F_GET_EXPTIME_ALL_GATES);
}
int64_t Module::getGateDelay(int gateIndex) {
return sendToDetector<int64_t>(F_GET_GATE_DELAY, gateIndex);
}
void Module::setGateDelay(int gateIndex, int64_t value) {
LOG(logDEBUG1) << "Setting gate delay to " << value
<< "ns (gateindex: " << gateIndex << ")";
int64_t args[]{static_cast<int64_t>(gateIndex), value};
sendToDetector(F_SET_GATE_DELAY, args, nullptr);
if (shm()->useReceiverFlag) {
LOG(logDEBUG1) << "Sending gate delay to Receiver: " << value;
sendToReceiver(F_SET_RECEIVER_GATE_DELAY, args, nullptr);
}
}
std::array<time::ns, 3> Module::getGateDelayForAllGates() {
static_assert(sizeof(time::ns) == 8, "ns needs to be 64bit");
return sendToDetector<std::array<time::ns, 3>>(F_GET_GATE_DELAY_ALL_GATES);
}
int64_t Module::getPeriod() { return sendToDetector<int64_t>(F_GET_PERIOD); }
void Module::setPeriod(int64_t value) {
@ -1272,10 +1312,15 @@ int Module::getADC(dacIndex index) {
}
slsDetectorDefs::externalSignalFlag
Module::setExternalSignalFlags(externalSignalFlag pol) {
LOG(logDEBUG1) << "Setting signal flag to " << pol;
Module::getExternalSignalFlags(int signalIndex) {
return sendToDetector<slsDetectorDefs::externalSignalFlag>(
F_SET_EXTERNAL_SIGNAL_FLAG, pol);
F_GET_EXTERNAL_SIGNAL_FLAG, signalIndex);
}
void Module::setExternalSignalFlags(int signalIndex, externalSignalFlag type) {
LOG(logDEBUG1) << "Setting signal flag (" << signalIndex << ") to " << type;
int args[]{signalIndex, static_cast<int>(type)};
sendToDetector(F_SET_EXTERNAL_SIGNAL_FLAG, args, nullptr);
}
void Module::setParallelMode(const bool enable) {
@ -1439,7 +1484,14 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
<< "roi.xmin:" << retval.roi.xmin << std::endl
<< "roi.xmax:" << retval.roi.xmax << std::endl
<< "countermask:" << retval.countermask << std::endl
<< "burstType:" << retval.burstType << std::endl;
<< "burstType:" << retval.burstType << std::endl
<< "exptime1:" << retval.expTime1Ns << std::endl
<< "exptime2:" << retval.expTime2Ns << std::endl
<< "exptime3:" << retval.expTime3Ns << std::endl
<< "gateDelay1:" << retval.gateDelay1Ns << std::endl
<< "gateDelay2:" << retval.gateDelay2Ns << std::endl
<< "gateDelay3:" << retval.gateDelay3Ns << std::endl
<< "gates:" << retval.gates << std::endl;
sls::MacAddr retvals[2];
sendToReceiver(F_SETUP_RECEIVER, retval, retvals);
@ -2874,6 +2926,8 @@ uint64_t Module::getPatternBitMask() {
return sendToDetector<uint64_t>(F_GET_PATTERN_BIT_MASK);
}
void Module::startPattern() { sendToDetector(F_START_PATTERN); }
int Module::setLEDEnable(int enable) {
return sendToDetector<int>(F_LED, enable);
}

View File

@ -419,9 +419,29 @@ class Module : public virtual slsDetectorDefs {
/** [CTB] */
void setNumberOfDigitalSamples(int value);
int64_t getExptime();
/** [Mythen3] */
int getNumberOfGates();
void setExptime(int64_t value);
/** [Mythen3] */
void setNumberOfGates(int value);
/** [Mythen3] gatIndex: 0-2, [Others]: -1 always */
int64_t getExptime(int gateIndex);
/** [Mythen3] gatIndex: -1 for all, 0-2, [Others]: -1 always */
void setExptime(int gateIndex, int64_t value);
/** [Mythen3] for all gates */
std::array<time::ns, 3> getExptimeForAllGates();
/** [Mythen3] gatIndex: 0-2 */
int64_t getGateDelay(int gateIndex);
/** [Mythen3] gatIndex: -1 for all, 0-2 */
void setGateDelay(int gateIndex, int64_t value);
/** [Mythen3] for all gates */
std::array<time::ns, 3> getGateDelayForAllGates();
int64_t getPeriod();
@ -529,14 +549,8 @@ class Module : public virtual slsDetectorDefs {
*/
int getADC(dacIndex index);
/**
* Set/get external signal flags (to specify triggerinrising edge etc)
* (Gotthard, Mythen)
* @param pol external signal flag (-1 gets)
* @returns current timing mode
*/
externalSignalFlag
setExternalSignalFlags(externalSignalFlag pol = GET_EXTERNAL_SIGNAL_FLAG);
externalSignalFlag getExternalSignalFlags(int signalIndex);
void setExternalSignalFlags(int signalIndex, externalSignalFlag type);
/**
* Set Parallel readout mode (Only for Eiger)
@ -1506,6 +1520,9 @@ class Module : public virtual slsDetectorDefs {
*/
uint64_t getPatternBitMask();
/** [Mythen3] */
void startPattern();
/**
* Set LED Enable (Moench, CTB only)
* @param enable 1 to switch on, 0 to switch off, -1 gets

View File

@ -228,6 +228,41 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd][.dacs][.new]") {
}
}
/* acquisition */
TEST_CASE("trigger", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_THROWS(proxy.Call("trigger", {}, -1, GET));
auto det_type = det.getDetectorType().squash();
if (det_type != defs::EIGER) {
REQUIRE_THROWS(proxy.Call("trigger", {}, -1, PUT));
} else {
auto prev_timing =
det.getTimingMode().tsquash("inconsistent timing mode in test");
auto prev_frames =
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
det.setTimingMode(defs::TRIGGER_EXPOSURE);
det.setNumberOfFrames(1);
auto startingfnum = det.getStartingFrameNumber().tsquash(
"inconsistent frame nr in test");
det.startDetector();
{
std::ostringstream oss;
proxy.Call("trigger", {}, -1, PUT, oss);
REQUIRE(oss.str() == "trigger successful\n");
}
auto currentfnum = det.getStartingFrameNumber().tsquash(
"inconsistent frame nr in test");
REQUIRE(startingfnum + 1 == currentfnum);
det.stopDetector();
det.setTimingMode(prev_timing);
det.setNumberOfFrames(prev_frames);
}
}
/* Network Configuration (Detector<->Receiver) */
TEST_CASE("Eiger transmission delay", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
@ -493,84 +528,3 @@ TEST_CASE("quad", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("quad", {}, -1, GET));
}
}
// TEST_CASE("trigger", "[.cmd]") {
// Detector det;
// CmdProxy proxy(&det);
// auto det_type = det.getDetectorType().squash();
// if (det_type != defs::EIGER) {
// proxy.Call("trigger", {}, -1, PUT);
// } else {
// {
// std::ostringstream oss;
// proxy.Call("timing", {"trigger"}, -1, PUT, oss);
// REQUIRE(oss.str() == "timing trigger\n");
// }
// auto startingfnum = det.getStartingFrameNumber().tsquash(
// "inconsistent frame nr in test");
// det.startDetector();
// {
// std::ostringstream oss;
// proxy.Call("trigger", {}, -1, PUT, oss);
// REQUIRE(oss.str() == "trigger successful\n");
// }
// auto currentfnum = det.getStartingFrameNumber().tsquash(
// "inconsistent frame nr in test");
// REQUIRE(startingfnum +1 == currentfnum);
// det.stopDetector();
// {
// std::ostringstream oss;
// proxy.Call("timing", {"auto"}, -1, PUT, oss);
// REQUIRE(oss.str() == "timing auto\n");
// }
// }
// if(test::type != slsDetectorDefs::EIGER) {
// REQUIRE_THROWS(multiSlsDetectorClient("trigger", PUT));
// } else {
// // trigger
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing trigger", PUT,
// nullptr, oss)); REQUIRE(oss.str() == "timing trigger\n");
// }
// int startingfnum = 0;
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
// nullptr, oss)); std::string s = (oss.str()).erase (0,
// strlen("startingfnum ")); startingfnum = std::stoi(s);
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT, nullptr,
// oss)); REQUIRE(oss.str() == "start successful\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("status", GET,
// nullptr, oss)); REQUIRE(oss.str() != "status idle\n");
// REQUIRE(oss.str()
// != "status stopped\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("trigger", PUT,
// nullptr, oss)); REQUIRE(oss.str() == "trigger successful\n");
// }
// REQUIRE_NOTHROW(multiSlsDetectorClient("stop", PUT));
// int currentfnum = 0;
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
// nullptr, oss)); std::string s = (oss.str()).erase (0,
// strlen("startingfnum ")); currentfnum = std::stoi(s);
// }
// REQUIRE((startingfnum + 1) == currentfnum);
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing auto", PUT));
// }
// }

View File

@ -190,6 +190,46 @@ TEST_CASE("settings", "[.cmd][.new]") {
}
}
TEST_CASE("trimbits", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_NOTHROW(proxy.Call("trimbits", {}, -1, GET));
}
TEST_CASE("trimval", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3 || det_type == defs::EIGER) {
auto prev_val = det.getAllTrimbits();
{
std::ostringstream oss;
proxy.Call("trimval", {"63"}, -1, PUT, oss);
REQUIRE(oss.str() == "trimval 63\n");
}
{
std::ostringstream oss;
proxy.Call("trimval", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "trimval 0\n");
}
{
std::ostringstream oss;
proxy.Call("trimval", {}, -1, GET, oss);
REQUIRE(oss.str() == "trimval 0\n");
}
REQUIRE_THROWS(proxy.Call("trimval", {"64"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("trimval", {"-1"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
if (prev_val[i] != -1) {
det.setAllTrimbits(prev_val[i], {i});
}
}
} else {
REQUIRE_THROWS(proxy.Call("trimval", {}, -1, GET));
}
}
/* acquisition parameters */
// acquire: not testing
@ -407,9 +447,27 @@ TEST_CASE("timing", "[.cmd][.new]") {
proxy.Call("timing", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "timing burst_trigger\n");
}
REQUIRE_THROWS(proxy.Call("timing", {"trigger_gating"}, -1, PUT));
} else if (det_type == defs::MYTHEN3) {
{
std::ostringstream oss1, oss2;
proxy.Call("timing", {"gating"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "timing gating\n");
proxy.Call("timing", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "timing gating\n");
}
{
std::ostringstream oss1, oss2;
proxy.Call("timing", {"trigger_gating"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "timing trigger_gating\n");
proxy.Call("timing", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "timing trigger_gating\n");
}
REQUIRE_THROWS(proxy.Call("timing", {"burst_trigger"}, -1, PUT));
} else {
REQUIRE_THROWS(proxy.Call("timing", {"gating"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("timing", {"burst_trigger"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("timing", {"trigger_gating"}, -1, PUT));
}
for (int i = 0; i != det.size(); ++i) {
det.setTimingMode(prev_val[i], {i});
@ -812,6 +870,85 @@ TEST_CASE("imagetest", "[.cmd][.new]") {
}
}
TEST_CASE("extsig", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD) {
auto prev_val = det.getExternalSignalFlags(0);
REQUIRE_THROWS(proxy.Call("extsig", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("extsig", {"1"}, -1, GET));
REQUIRE_THROWS(proxy.Call("extsig", {"0", "inversion_on"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("extsig", {"0", "inversion_off"}, -1, PUT));
{
std::ostringstream oss1, oss2;
proxy.Call("extsig", {"0", "trigger_in_rising_edge"}, -1, PUT,
oss1);
REQUIRE(oss1.str() == "extsig 0 trigger_in_rising_edge\n");
proxy.Call("extsig", {"0"}, -1, GET, oss2);
REQUIRE(oss2.str() == "extsig trigger_in_rising_edge\n");
}
{
std::ostringstream oss1, oss2;
proxy.Call("extsig", {"0", "trigger_in_falling_edge"}, -1, PUT,
oss1);
REQUIRE(oss1.str() == "extsig 0 trigger_in_falling_edge\n");
proxy.Call("extsig", {"0"}, -1, GET, oss2);
REQUIRE(oss2.str() == "extsig 0 trigger_in_falling_edge\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setExternalSignalFlags(0, prev_val[i], {i});
}
} else if (det_type == defs::MYTHEN3) {
auto prev_val_0 = det.getExternalSignalFlags(0);
auto prev_val_1 = det.getExternalSignalFlags(1);
REQUIRE_THROWS(proxy.Call("extsig", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("extsig", {"8"}, -1, GET));
REQUIRE_THROWS(proxy.Call("extsig", {"0", "inversion_on"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("extsig", {"0", "inversion_off"}, -1, PUT));
REQUIRE_THROWS(
proxy.Call("extsig", {"1", "trigger_in_rising_edge"}, -1, PUT));
REQUIRE_THROWS(
proxy.Call("extsig", {"1", "trigger_in_falling_edge"}, -1, PUT));
{
std::ostringstream oss1, oss2;
proxy.Call("extsig", {"0", "trigger_in_rising_edge"}, -1, PUT,
oss1);
REQUIRE(oss1.str() == "extsig 0 trigger_in_rising_edge\n");
proxy.Call("extsig", {"0"}, -1, GET, oss2);
REQUIRE(oss2.str() == "extsig trigger_in_rising_edge\n");
}
{
std::ostringstream oss1, oss2;
proxy.Call("extsig", {"0", "trigger_in_falling_edge"}, -1, PUT,
oss1);
REQUIRE(oss1.str() == "extsig 0 trigger_in_falling_edge\n");
proxy.Call("extsig", {"0"}, -1, GET, oss2);
REQUIRE(oss2.str() == "extsig 0 trigger_in_falling_edge\n");
}
{
std::ostringstream oss1, oss2;
proxy.Call("extsig", {"1", "inversion_off"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "extsig 1 inversion_off\n");
proxy.Call("extsig", {"1"}, -1, GET, oss2);
REQUIRE(oss2.str() == "extsig inversion_off\n");
}
{
std::ostringstream oss1, oss2;
proxy.Call("extsig", {"1", "inversion_on"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "extsig 1 inversion_on\n");
proxy.Call("extsig", {"1"}, -1, GET, oss2);
REQUIRE(oss2.str() == "extsig 1 inversion_on\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setExternalSignalFlags(0, prev_val_0[i], {i});
det.setExternalSignalFlags(1, prev_val_1[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("extsig", {}, -1, GET));
}
}
/** temperature */
TEST_CASE("temp_adc", "[.cmd][.new]") {
@ -958,6 +1095,43 @@ TEST_CASE("startingfnum", "[.cmd][.new]") {
}
}
/* Network Configuration (Detector<->Receiver) */
TEST_CASE("numinterfaces", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD2) {
auto prev_val = det.getNumberofUDPInterfaces().tsquash(
"inconsistent numinterfaces to test");
{
std::ostringstream oss;
proxy.Call("numinterfaces", {"2"}, -1, PUT, oss);
REQUIRE(oss.str() == "numinterfaces 2\n");
}
{
std::ostringstream oss;
proxy.Call("numinterfaces", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "numinterfaces 1\n");
}
{
std::ostringstream oss;
proxy.Call("numinterfaces", {}, -1, GET, oss);
REQUIRE(oss.str() == "numinterfaces 1\n");
}
det.setNumberofUDPInterfaces(prev_val);
} else {
std::ostringstream oss;
proxy.Call("numinterfaces", {}, -1, GET, oss);
REQUIRE(oss.str() == "numinterfaces 1\n");
REQUIRE_THROWS(proxy.Call("numinterfaces", {"1"}, -1, PUT));
}
REQUIRE_THROWS(proxy.Call("numinterfaces", {"3"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("numinterfaces", {"0"}, -1, PUT));
}
/* Advanced */
TEST_CASE("initialchecks", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
@ -987,18 +1161,7 @@ TEST_CASE("initialchecks", "[.cmd]") {
det.setInitialChecks(check);
}
TEST_CASE("user", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
proxy.Call("user", {}, -1, GET);
// This is a get only command
REQUIRE_THROWS(proxy.Call("user", {}, -1, PUT));
}
// TEST_CASE("execcommand", "[.cmd]") {
// REQUIRE_NOTHROW(multiSlsDetectorClient("execcommand ls", PUT));
// }
/* Insignificant */
TEST_CASE("port", "[.cmd]") {
Detector det;
@ -1034,6 +1197,19 @@ TEST_CASE("stopport", "[.cmd]") {
REQUIRE(port == 1953);
}
// TEST_CASE("execcommand", "[.cmd]") {
// REQUIRE_NOTHROW(multiSlsDetectorClient("execcommand ls", PUT));
// }
TEST_CASE("user", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
proxy.Call("user", {}, -1, GET);
// This is a get only command
REQUIRE_THROWS(proxy.Call("user", {}, -1, PUT));
}
// TEST_CASE("reg", "[.cmd]") {
// if (test::type == defs::JUNGFRAU) {
// {
@ -2366,29 +2542,6 @@ TEST_CASE("stopport", "[.cmd]") {
// }
// }
// TEST_CASE("trimval", "[.cmd][.eiger]") {
// if (test::type == defs::EIGER) {
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("trimval 63", PUT,
// nullptr, oss)); REQUIRE(oss.str() == "trimval 63\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("trimval", GET, nullptr,
// oss)); REQUIRE(oss.str() == "trimval 63\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("trimval 31", PUT,
// nullptr, oss)); REQUIRE(oss.str() == "trimval 31\n");
// }
// REQUIRE_NOTHROW(multiSlsDetectorClient("trimval 0", PUT));
// } else {
// REQUIRE_THROWS(multiSlsDetectorClient("trimval", GET));
// }
// }
// TEST_CASE("flippeddatax", "[.cmd][.eiger]") {
// if (test::type == defs::EIGER) {
// {
@ -2746,29 +2899,6 @@ TEST_CASE("zmqport", "[.cmd]") {
// }
// }
// TEST_CASE("numinterfaces", "[.cmd][.jungfrau]") {
// if (test::type == defs::JUNGFRAU) {
// {
// REQUIRE_NOTHROW(multiSlsDetectorClient("numinterfaces 2", PUT));
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:numinterfaces", GET,
// nullptr, oss)); REQUIRE(oss.str() == "numinterfaces 2\n");
// }
// {
// REQUIRE_NOTHROW(multiSlsDetectorClient("numinterfaces 1", PUT));
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:numinterfaces", GET,
// nullptr, oss)); REQUIRE(oss.str() == "numinterfaces 1\n");
// }
// } else {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:numinterfaces", GET,
// nullptr, oss)); REQUIRE(oss.str() == "numinterfaces 1\n");
// }
// REQUIRE_THROWS(multiSlsDetectorClient("numinterfaces 3", PUT));
// REQUIRE_THROWS(multiSlsDetectorClient("numinterfaces 0", PUT));
// }
// TEST_CASE("adc", "[.cmd][.ctb]") {
// if (test::type != defs::CHIPTESTBOARD) {
// REQUIRE_THROWS(multiSlsDetectorClient("adc 8", GET));