merge fix

This commit is contained in:
2022-03-21 10:32:49 +01:00
177 changed files with 27006 additions and 22421 deletions

View File

@ -193,6 +193,12 @@ class Detector {
*/
void setFlipRows(bool value, Positions pos = {});
/** [Eiger][Mythen3][Gotthard1] via stop server **/
Result<bool> getMaster(Positions pos = {}) const;
/** [Eiger] Set half module to master and the others to slaves */
void setMaster(bool value, int pos);
Result<bool> isVirtualDetectorServer(Positions pos = {}) const;
///@}
@ -284,7 +290,7 @@ class Detector {
Result<int> getDynamicRange(Positions pos = {}) const;
/**
* [Eiger] Options: 4, 8, 16, 32. If i is 32, also sets clkdivider to 2,
* [Eiger] Options: 4, 8, 12, 16, 32. If i is 32, also sets clkdivider to 2,
* else sets clkdivider to 1 \n [Mythen3] Options: 8, 16, 32 \n
* [Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16
*/
@ -567,7 +573,7 @@ class Detector {
/** Non blocking: start detector acquisition. Status changes to RUNNING or
* WAITING and automatically returns to idle at the end of acquisition.
[Mythen3] Master starts acquisition first */
void startDetector();
void startDetector(Positions pos = {});
/** [Mythen3] Non blocking: start detector readout of counters in chip.
* Status changes to TRANSMITTING and automatically returns to idle at the
@ -588,15 +594,15 @@ class Detector {
Result<int64_t> getFramesCaught(Positions pos = {}) const;
/** Gets the number of missing packets for each port in receiver. */
Result<std::vector<uint64_t>>
getNumMissingPackets(Positions pos = {}) const;
/** Gets the number of missing packets for each port in receiver. Negative
* number denotes extra packets. */
Result<std::vector<int64_t>> getNumMissingPackets(Positions pos = {}) const;
/** [Eiger][Jungfrau] */
/** [Eiger][Jungfrau][Moench][CTB] */
Result<uint64_t> getNextFrameNumber(Positions pos = {}) const;
/** [Eiger][Jungfrau] Stopping acquisition might result in different frame
* numbers for different modules.*/
/** [Eiger][Jungfrau][Moench][CTB] Stopping acquisition might result in
* different frame numbers for different modules.*/
void setNextFrameNumber(uint64_t value, Positions pos = {});
/** [Eiger][Mythen3] Sends an internal software trigger to the detector
@ -894,10 +900,18 @@ class Detector {
Result<sls::IpAddr> getRxLastClientIP(Positions pos = {}) const;
/** Get thread ids from the receiver in order of [parent, tcp, listener 0,
* processor 0, streamer 0, listener 1, processor 1, streamer 1]. If no
* streamer yet or there is no second interface, it gives 0 in its place. */
* processor 0, streamer 0, listener 1, processor 1, streamer 1, arping]. If
* no streamer yet or there is no second interface, it gives 0 in its place.
*/
Result<std::array<pid_t, NUM_RX_THREAD_IDS>>
getRxThreadIds(Positions pos = {}) const;
Result<bool> getRxArping(Positions pos = {}) const;
/** Starts a thread in slsReceiver to arping the interface it is listening
* every minute. Useful in 10G mode. */
void setRxArping(bool value, Positions pos = {});
///@}
/** @name File */
@ -1157,12 +1171,18 @@ class Detector {
Result<bool> getDataStream(const defs::portPosition port,
Positions pos = {}) const;
/** [Eiger] enable or disable data streaming from left or right of detector.
* Default: enabled
/** [Eiger] enable or disable data streaming from left or right of detector
* for 10GbE. Default: enabled
*/
void setDataStream(const defs::portPosition port, const bool enable,
Positions pos = {});
/** [Eiger] Advanced */
Result<bool> getTop(Positions pos = {}) const;
/** [Eiger] Advanced. Default is hardware default */
void setTop(bool value, Positions pos = {});
///@}
/** @name Jungfrau Specific */
@ -1460,9 +1480,6 @@ 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 !!!!!
Result<int> getChipStatusRegister(Positions pos = {}) const;
@ -1685,15 +1702,15 @@ class Detector {
/** [CTB][Moench][Mythen3] */
Result<uint64_t> getPatternMask(Positions pos = {});
/** [CTB][Moench][Mythen3] Sets the mask applied to every pattern to the
* selected bits */
/** [CTB][Moench][Mythen3] Selects the bits that will have a pattern mask
* applied to the selected patmask for every pattern. */
void setPatternMask(uint64_t mask, Positions pos = {});
/** [CTB][Moench][Mythen3] */
Result<uint64_t> getPatternBitMask(Positions pos = {}) const;
/** [CTB][Moench][Mythen3] Selects the bits that will have a pattern mask
* applied to the selected patmask for every pattern. */
/** [CTB][Moench][Mythen3] Sets the mask applied to every pattern to the
* selected bits */
void setPatternBitMask(uint64_t mask, Positions pos = {});
/** [Mythen3] */

View File

@ -1,3 +1,4 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include "CmdProxy.h"
@ -1273,6 +1274,40 @@ std::string CmdProxy::DetectorStatus(int action) {
return os.str();
}
std::string CmdProxy::RxMissingPackets(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "Number of missing packets for each port in receiver. If "
"negative, they are packets in excess. "
<< '\n';
} else if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto mp = det->getNumMissingPackets(std::vector<int>{det_id});
/*
auto tmp = det->getNumMissingPackets(std::vector<int>{det_id});
// convert to signed missing packets (to get excess)
Result<std::vector<int64_t>> mp(tmp.size());
for (unsigned int i = 0; i < mp.size(); ++i) {
mp[i] = static_cast<int64_t>(tmp[i]);
}
OR
Result<std::vector<int64_t>> tmp;
for (auto val : tmp) {
mp.push_back(static_cast<int64_t>(val));
}
*/
os << OutString(mp) << '\n';
} else if (action == defs::PUT_ACTION) {
throw sls::RuntimeError("Cannot put");
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::Scan(int action) {
std::ostringstream os;
os << cmd << ' ';
@ -1790,7 +1825,9 @@ std::string CmdProxy::DataStream(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[left|right] [0, 1]\n\t[Eiger] Enables or disables data "
"streaming from left or/and right side of detector. 1 (enabled) "
"streaming from left or/and right side of detector for 10 GbE "
"mode. "
"1 (enabled) "
"by default."
<< '\n';
} else if (action == defs::GET_ACTION) {

View File

@ -854,6 +854,7 @@ class CmdProxy {
{"trimen", &CmdProxy::TrimEnergies},
{"gappixels", &CmdProxy::GapPixels},
{"fliprows", &CmdProxy::fliprows},
{"master", &CmdProxy::master},
/* acquisition parameters */
{"acquire", &CmdProxy::Acquire},
@ -929,7 +930,7 @@ class CmdProxy {
{"rx_status", &CmdProxy::ReceiverStatus},
{"status", &CmdProxy::DetectorStatus},
{"rx_framescaught", &CmdProxy::rx_framescaught},
{"rx_missingpackets", &CmdProxy::rx_missingpackets},
{"rx_missingpackets", &CmdProxy::RxMissingPackets},
{"nextframenumber", &CmdProxy::nextframenumber},
{"trigger", &CmdProxy::Trigger},
{"scan", &CmdProxy::Scan},
@ -973,6 +974,7 @@ class CmdProxy {
{"rx_lock", &CmdProxy::rx_lock},
{"rx_lastclient", &CmdProxy::rx_lastclient},
{"rx_threads", &CmdProxy::rx_threads},
{"rx_arping", &CmdProxy::rx_arping},
/* File */
{"fformat", &CmdProxy::fformat},
@ -1011,6 +1013,7 @@ class CmdProxy {
{"pulsechip", &CmdProxy::PulseChip},
{"quad", &CmdProxy::Quad},
{"datastream", &CmdProxy::DataStream},
{"top", &CmdProxy::top},
/* Jungfrau Specific */
{"chipversion", &CmdProxy::chipversion},
@ -1178,7 +1181,6 @@ class CmdProxy {
/* acquisition parameters */
std::string Acquire(int action);
std::string Exptime(int action);
std::string DynamicRange(int action);
std::string ReadoutSpeed(int action);
std::string Adcphase(int action);
std::string Dbitphase(int action);
@ -1198,6 +1200,7 @@ class CmdProxy {
/* acquisition */
std::string ReceiverStatus(int action);
std::string DetectorStatus(int action);
std::string RxMissingPackets(int action);
std::string Scan(int action);
std::string Trigger(int action);
/* Network Configuration (Detector<->Receiver) */
@ -1349,6 +1352,12 @@ class CmdProxy {
"interfaces must be set to 2. slsReceiver and slsDetectorGui "
"does not handle.");
INTEGER_COMMAND_VEC_ID_GET(
master, getMaster, setMaster, StringTo<int>,
"[0, 1]\n\t[Eiger] Sets half module to master and "
"others to slaves.\n\t[Gotthard][Gotthard2][Mythen3][Eiger] "
"Gets if the current module/ half module is master.");
/* acquisition parameters */
INTEGER_COMMAND_SET_NOID_GET_ID(
@ -1396,7 +1405,7 @@ class CmdProxy {
dr, getDynamicRange, setDynamicRange, StringTo<int>,
"[value]\n\tDynamic Range or number of bits per "
"pixel in detector.\n\t"
"[Eiger] Options: 4, 8, 16, 32. If set to 32, also sets "
"[Eiger] Options: 4, 8, 12, 16, 32. If set to 32, also sets "
"clkdivider to 2, else to 0.\n\t"
"[Mythen3] Options: 8, 16, 32\n\t"
"[Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16");
@ -1584,7 +1593,7 @@ class CmdProxy {
"\n\tStops receiver listener for detector data packets and closes "
"current data file (if file write enabled).");
EXECUTE_SET_COMMAND_NOID(
EXECUTE_SET_COMMAND(
start, startDetector,
"\n\tStarts detector acquisition. Status changes to RUNNING or WAITING "
"and automatically returns to idle at the end of acquisition. If the "
@ -1604,13 +1613,15 @@ class CmdProxy {
"\n\tNumber of frames caught by receiver.");
GET_COMMAND(rx_missingpackets, getNumMissingPackets,
"\n\tNumber of missing packets for each port in receiver.");
"\n\tNumber of missing packets for each port in receiver. "
"Negative number denotes extra packets.");
INTEGER_COMMAND_VEC_ID(nextframenumber, getNextFrameNumber,
setNextFrameNumber, StringTo<uint64_t>,
"[n_value]\n\t[Eiger][Jungfrau] Next frame number. "
"Stopping acquisition might result in "
"different frame numbers for different modules.");
INTEGER_COMMAND_VEC_ID(
nextframenumber, getNextFrameNumber, setNextFrameNumber,
StringTo<uint64_t>,
"[n_value]\n\t[Eiger][Jungfrau][Moench][CTB] Next frame number. "
"Stopping acquisition might result in different frame numbers for "
"different modules.");
GET_COMMAND(scanerrmsg, getScanErrorMessage,
"\n\tGets Scan error message if scan ended in error for non "
@ -1806,13 +1817,16 @@ class CmdProxy {
rx_lastclient, getRxLastClientIP,
"\n\tClient IP Address that last communicated with the receiver.");
GET_COMMAND(
rx_threads, getRxThreadIds,
"\n\tGet thread ids from the receiver in order of [parent, tcp, "
"listener 0, "
"processor 0, streamer 0, listener 1, processor 1, streamer 1]. If no "
"streamer yet or there is no second interface, it gives 0 in its "
"place.");
GET_COMMAND(rx_threads, getRxThreadIds,
"\n\tGet thread ids from the receiver in order of [parent, "
"tcp, listener 0, processor 0, streamer 0, listener 1, "
"processor 1, streamer 1, arping]. If no streamer yet or there "
"is no second interface, it gives 0 in its place.");
INTEGER_COMMAND_VEC_ID(rx_arping, getRxArping, setRxArping, StringTo<int>,
"[0, 1]\n\tStarts a thread in slsReceiver to arping "
"the interface it is "
"listening to every minute. Useful in 10G mode.");
/* File */
@ -1964,6 +1978,10 @@ class CmdProxy {
"start of acquisition. 0 complete reset, 1 partial reset. Default is "
"complete reset. Advanced function!");
INTEGER_COMMAND_VEC_ID(
top, getTop, setTop, StringTo<int>,
"[0, 1]\n\t[Eiger] Sets half module to top (1), else bottom.");
/* Jungfrau Specific */
GET_COMMAND(chipversion, getChipVersion,
@ -2233,15 +2251,15 @@ class CmdProxy {
INTEGER_COMMAND_HEX_WIDTH16(
patmask, getPatternMask, setPatternMask, StringTo<uint64_t>,
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] Sets the mask applied to "
"every pattern to the selected bits.");
INTEGER_COMMAND_HEX_WIDTH16(
patsetbit, getPatternBitMask, setPatternBitMask, StringTo<uint64_t>,
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] Selects the bits that will "
"have a pattern mask applied to the selected patmask for every "
"pattern.");
INTEGER_COMMAND_HEX_WIDTH16(
patsetbit, getPatternBitMask, setPatternBitMask, StringTo<uint64_t>,
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] Sets the mask applied to "
"every pattern to the selected bits.");
EXECUTE_SET_COMMAND(patternstart, startPattern,
"\n\t[Mythen3] Starts Pattern");

View File

@ -298,6 +298,23 @@ void Detector::setFlipRows(bool value, Positions pos) {
pimpl->Parallel(&Module::setFlipRows, pos, value);
}
Result<bool> Detector::getMaster(Positions pos) const {
return pimpl->Parallel(&Module::isMaster, pos);
}
void Detector::setMaster(bool master, int pos) {
// multi mod, set slaves first
if (master && size() > 1) {
if (pos == -1) {
throw RuntimeError("Master can be set only to a single module");
}
pimpl->Parallel(&Module::setMaster, {}, false);
pimpl->Parallel(&Module::setMaster, {pos}, master);
} else {
pimpl->Parallel(&Module::setMaster, {pos}, master);
}
}
Result<bool> Detector::isVirtualDetectorServer(Positions pos) const {
return pimpl->Parallel(&Module::isVirtualDetectorServer, pos);
}
@ -387,7 +404,7 @@ void Detector::setDynamicRange(int value) {
std::vector<int> Detector::getDynamicRangeList() const {
switch (getDetectorType().squash()) {
case defs::EIGER:
return std::vector<int>{4, 8, 16, 32};
return std::vector<int>{4, 8, 12, 16, 32};
case defs::MYTHEN3:
return std::vector<int>{8, 16, 32};
default:
@ -756,22 +773,24 @@ void Detector::startReceiver() { pimpl->Parallel(&Module::startReceiver, {}); }
void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); }
void Detector::startDetector() {
auto detector_type = getDetectorType().squash();
void Detector::startDetector(Positions pos) {
auto detector_type = getDetectorType(pos).squash();
if (detector_type == defs::MYTHEN3 && size() > 1) {
auto is_master = getMaster();
int masterPosition = 0;
std::vector<int> slaves;
for (int i = 0; i < size(); ++i) {
if (is_master[i])
std::vector<int> slaves(pos);
auto is_master = getMaster(pos);
int masterPosition = -1;
for (unsigned int i = 0; i < is_master.size(); ++i) {
if (is_master[i]) {
masterPosition = i;
else
slaves.push_back(i);
slaves.erase(slaves.begin() + i);
}
}
pimpl->Parallel(&Module::startAcquisition, pos);
if (masterPosition != -1) {
pimpl->Parallel(&Module::startAcquisition, {masterPosition});
}
pimpl->Parallel(&Module::startAcquisition, slaves);
pimpl->Parallel(&Module::startAcquisition, {masterPosition});
} else {
pimpl->Parallel(&Module::startAcquisition, {});
pimpl->Parallel(&Module::startAcquisition, pos);
}
}
@ -781,6 +800,25 @@ void Detector::startDetectorReadout() {
void Detector::stopDetector(Positions pos) {
pimpl->Parallel(&Module::stopAcquisition, pos);
// validate consistent frame numbers
switch (getDetectorType().squash()) {
case defs::EIGER:
case defs::JUNGFRAU:
case defs::MOENCH:
case defs::CHIPTESTBOARD: {
auto res = getNextFrameNumber(pos);
if (!res.equal()) {
uint64_t maxVal = 0;
for (auto it : res) {
maxVal = std::max(maxVal, it);
}
setNextFrameNumber(maxVal + 1);
}
} break;
default:
break;
}
}
Result<defs::runStatus> Detector::getDetectorStatus(Positions pos) const {
@ -795,7 +833,7 @@ Result<int64_t> Detector::getFramesCaught(Positions pos) const {
return pimpl->Parallel(&Module::getFramesCaughtByReceiver, pos);
}
Result<std::vector<uint64_t>>
Result<std::vector<int64_t>>
Detector::getNumMissingPackets(Positions pos) const {
return pimpl->Parallel(&Module::getNumMissingPackets, pos);
}
@ -1198,6 +1236,14 @@ Detector::getRxThreadIds(Positions pos) const {
return pimpl->Parallel(&Module::getReceiverThreadIds, pos);
}
Result<bool> Detector::getRxArping(Positions pos) const {
return pimpl->Parallel(&Module::getRxArping, pos);
}
void Detector::setRxArping(bool value, Positions pos) {
pimpl->Parallel(&Module::setRxArping, pos, value);
}
// File
Result<defs::fileFormat> Detector::getFileFormat(Positions pos) const {
@ -1506,6 +1552,14 @@ void Detector::setDataStream(const defs::portPosition port, const bool enable,
pimpl->Parallel(&Module::setDataStream, pos, port, enable);
}
Result<bool> Detector::getTop(Positions pos) const {
return pimpl->Parallel(&Module::getTop, pos);
}
void Detector::setTop(bool value, Positions pos) {
pimpl->Parallel(&Module::setTop, pos, value);
}
// Jungfrau Specific
Result<double> Detector::getChipVersion(Positions pos) const {
return pimpl->Parallel(&Module::getChipVersion, pos);
@ -1581,7 +1635,6 @@ std::vector<defs::gainMode> Detector::getGainModeList() const {
return std::vector<defs::gainMode>{
defs::DYNAMIC, defs::FORCE_SWITCH_G1, defs::FORCE_SWITCH_G2,
defs::FIX_G1, defs::FIX_G2, defs::FIX_G0};
break;
default:
throw RuntimeError("Gain mode is not implemented for this detector.");
}
@ -1826,10 +1879,6 @@ Detector::getGateDelayForAllGates(Positions pos) const {
return pimpl->Parallel(&Module::getGateDelayForAllGates, pos);
}
Result<bool> Detector::getMaster(Positions pos) const {
return pimpl->Parallel(&Module::isMaster, pos);
}
Result<int> Detector::getChipStatusRegister(Positions pos) const {
return pimpl->Parallel(&Module::getChipStatusRegister, pos);
}
@ -2334,20 +2383,8 @@ Result<uint64_t> Detector::getRxCurrentFrameIndex(Positions pos) const {
}
std::vector<int> Detector::getPortNumbers(int start_port) {
int num_sockets_per_detector = 1;
switch (getDetectorType().squash()) {
case defs::EIGER:
num_sockets_per_detector *= 2;
break;
case defs::JUNGFRAU:
case defs::GOTTHARD2:
if (pimpl->getNumberofUDPInterfaces({}).squash() == 2) {
num_sockets_per_detector *= 2;
}
break;
default:
break;
}
int num_sockets_per_detector = pimpl->getNumberofUDPInterfaces({}).tsquash(
"Number of UDP Interfaces is not consistent among modules");
std::vector<int> res;
res.reserve(size());
for (int idet = 0; idet < size(); ++idet) {

View File

@ -245,6 +245,15 @@ void DetectorImpl::setHostname(const std::vector<std::string> &name) {
addModule(hostname);
}
updateDetectorSize();
// update zmq port (especially for eiger)
int numInterfaces = modules[0]->getNumberofUDPInterfaces();
if (numInterfaces == 2) {
for (size_t i = 0; i < modules.size(); ++i) {
modules[i]->setClientStreamingPort(DEFAULT_ZMQ_CL_PORTNO +
i * numInterfaces);
}
}
}
void DetectorImpl::addModule(const std::string &hostname) {
@ -402,31 +411,25 @@ int DetectorImpl::createReceivingDataSockets() {
}
LOG(logINFO) << "Going to create data sockets";
size_t numSockets = modules.size();
size_t numSocketsPerModule = 1;
if (shm()->detType == EIGER) {
numSocketsPerModule = 2;
size_t numUDPInterfaces =
Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash(1);
// gotthard2 second interface is only for veto debugging (not in gui)
if (shm()->detType == GOTTHARD2) {
numUDPInterfaces = 1;
}
// gotthard2 second interface is only for veto debugging
else if (shm()->detType != GOTTHARD2) {
if (Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash() ==
2) {
numSocketsPerModule = 2;
}
}
numSockets *= numSocketsPerModule;
size_t numSockets = modules.size() * numUDPInterfaces;
for (size_t iSocket = 0; iSocket < numSockets; ++iSocket) {
uint32_t portnum =
(modules[iSocket / numSocketsPerModule]->getClientStreamingPort());
portnum += (iSocket % numSocketsPerModule);
(modules[iSocket / numUDPInterfaces]->getClientStreamingPort());
portnum += (iSocket % numUDPInterfaces);
try {
zmqSocket.push_back(sls::make_unique<ZmqSocket>(
modules[iSocket / numSocketsPerModule]
->getClientStreamingIP()
.str()
.c_str(),
portnum));
zmqSocket.push_back(
sls::make_unique<ZmqSocket>(modules[iSocket / numUDPInterfaces]
->getClientStreamingIP()
.str()
.c_str(),
portnum));
// set high water mark
int hwm = shm()->zmqHwm;
if (hwm >= 0) {
@ -460,13 +463,9 @@ void DetectorImpl::readFrameFromReceiver() {
int nDetPixelsX = 0;
int nDetPixelsY = 0;
bool quadEnable = false;
// to flip image
bool eiger = false;
bool numInterfaces = 1;
// gotthard2 second interface is veto debugging
if (shm()->detType != GOTTHARD2) {
numInterfaces = Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
.squash(); // cannot pick up from zmq
}
std::vector<bool> runningList(zmqSocket.size());
std::vector<bool> connectList(zmqSocket.size());
numZmqRunning = 0;
@ -542,10 +541,9 @@ void DetectorImpl::readFrameFromReceiver() {
// shape
nPixelsX = zHeader.npixelsx;
nPixelsY = zHeader.npixelsy;
// module shape
// module shape (port)
nX = zHeader.ndetx;
nY = zHeader.ndety;
nY *= numInterfaces;
nDetPixelsX = nX * nPixelsX;
nDetPixelsY = nY * nPixelsY;
// det type

File diff suppressed because it is too large Load Diff

View File

@ -128,6 +128,9 @@ class Module : public virtual slsDetectorDefs {
int setTrimEn(const std::vector<int> &energies = {});
bool getFlipRows() const;
void setFlipRows(bool value);
bool isMaster() const;
void setMaster(const bool master);
bool isVirtualDetectorServer() const;
/**************************************************
@ -192,6 +195,7 @@ class Module : public virtual slsDetectorDefs {
void setDBITPipeline(int value);
int getReadNRows() const;
void setReadNRows(const int value);
/**************************************************
* *
* Acquisition *
@ -208,7 +212,7 @@ class Module : public virtual slsDetectorDefs {
runStatus getReceiverStatus() const;
double getReceiverProgress() const;
int64_t getFramesCaughtByReceiver() const;
std::vector<uint64_t> getNumMissingPackets() const;
std::vector<int64_t> getNumMissingPackets() const;
uint64_t getNextFrameNumber() const;
void setNextFrameNumber(uint64_t value);
void sendSoftwareTrigger(const bool block);
@ -292,6 +296,8 @@ class Module : public virtual slsDetectorDefs {
void setReceiverLock(bool lock);
sls::IpAddr getReceiverLastClientIP() const;
std::array<pid_t, NUM_RX_THREAD_IDS> getReceiverThreadIds() const;
bool getRxArping() const;
void setRxArping(bool enable);
/**************************************************
* *
@ -372,6 +378,8 @@ class Module : public virtual slsDetectorDefs {
void setQuad(const bool enable);
bool getDataStream(const portPosition port) const;
void setDataStream(const portPosition port, const bool enable);
bool getTop() const;
void setTop(bool value);
/**************************************************
* *
@ -463,7 +471,6 @@ class Module : public virtual slsDetectorDefs {
int64_t getGateDelay(int gateIndex) const;
void setGateDelay(int gateIndex, int64_t value);
std::array<time::ns, 3> getGateDelayForAllGates() const;
bool isMaster() const;
int getChipStatusRegister() const;
void setGainCaps(int caps);
int getGainCaps();

View File

@ -629,4 +629,32 @@ TEST_CASE("datastream", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("datastream", {"1"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("datastream", {"left", "1"}, -1, PUT));
}
}
TEST_CASE("top", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_val = det.getTop();
int numModulesTested = 1;
if (det.size() > 1) {
numModulesTested = 2;
}
for (int i = 0; i != numModulesTested; ++i) {
std::ostringstream oss1, oss2, oss3;
proxy.Call("top", {"1"}, i, PUT, oss1);
REQUIRE(oss1.str() == "top 1\n");
proxy.Call("top", {}, i, GET, oss2);
REQUIRE(oss2.str() == "top 1\n");
proxy.Call("top", {"0"}, i, PUT, oss3);
REQUIRE(oss3.str() == "top 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setTop(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("top", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("top", {"1"}, -1, PUT));
}
}

View File

@ -385,6 +385,30 @@ TEST_CASE("rx_threads", "[.cmd][.rx]") {
REQUIRE_NOTHROW(proxy.Call("rx_threads", {}, -1, GET, oss));
}
TEST_CASE("rx_arping", "[.cmd][.rx]") {
Detector det;
CmdProxy proxy(&det);
auto prev_val = det.getRxArping();
{
std::ostringstream oss;
proxy.Call("rx_arping", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "rx_arping 1\n");
}
{
std::ostringstream oss;
proxy.Call("rx_arping", {}, -1, GET, oss);
REQUIRE(oss.str() == "rx_arping 1\n");
}
{
std::ostringstream oss;
proxy.Call("rx_arping", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "rx_arping 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setRxArping(prev_val[i], {i});
}
}
/* File */
TEST_CASE("fformat", "[.cmd]") {

View File

@ -570,6 +570,46 @@ TEST_CASE("fliprows", "[.cmd]") {
}
}
TEST_CASE("master", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2) {
REQUIRE_NOTHROW(proxy.Call("master", {}, -1, GET));
if (det_type == defs::EIGER) {
// get previous master
int prevMaster = 0;
{
auto previous = det.getMaster();
for (int i = 0; i != det.size(); ++i) {
if (previous[i] == 1) {
prevMaster = i;
break;
}
}
}
{
std::ostringstream oss1;
proxy.Call("master", {"0"}, 0, PUT, oss3);
REQUIRE(oss3.str() == "master 0\n");
}
{
std::ostringstream oss1;
proxy.Call("master", {"1"}, 0, PUT, oss3);
REQUIRE(oss3.str() == "master 1\n");
}
REQUIRE_THROWS(proxy.Call("master", {"1"}, -1, PUT));
// set all to slaves, and then master
for (int i = 0; i != det.size(); ++i) {
det.setMaster(0, {i});
}
det.setMaster(1, prevMaster);
}
} else {
REQUIRE_THROWS(proxy.Call("master", {}, -1, GET));
}
}
/* acquisition parameters */
// acquire: not testing
@ -2107,7 +2147,8 @@ TEST_CASE("nextframenumber", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) {
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU ||
det_type == defs::MOENCH || det_type == defs::CHIPTESTBOARD) {
auto prev_sfnum = det.getNextFrameNumber();
REQUIRE_THROWS(proxy.Call("nextframenumber", {"0"}, -1, PUT));
{
@ -2125,6 +2166,41 @@ TEST_CASE("nextframenumber", "[.cmd]") {
proxy.Call("nextframenumber", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "nextframenumber 1\n");
}
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::AUTO_TIMING);
det.setNumberOfFrames(1);
det.setExptime(std::chrono::microseconds(200));
det.setPeriod(std::chrono::milliseconds(1));
det.startDetector();
std::this_thread::sleep_for(std::chrono::seconds(2));
auto currentfnum =
det.getNextFrameNumber().tsquash("inconsistent frame nr in test");
REQUIRE(currentfnum == 2);
if (det_type == defs::EIGER) {
auto prev_tengiga =
det.getTenGiga().tsquash("inconsistent ten giga enable");
det.setTenGiga(true);
det.setNextFrameNumber(1);
det.startDetector();
std::this_thread::sleep_for(std::chrono::seconds(2));
auto currentfnum = det.getNextFrameNumber().tsquash(
"inconsistent frame nr in test");
REQUIRE(currentfnum == 2);
det.setTenGiga(prev_tengiga);
}
det.setTimingMode(prev_timing);
det.setNumberOfFrames(prev_frames);
det.setExptime(prev_exptime);
det.setPeriod(prev_period);
for (int i = 0; i != det.size(); ++i) {
det.setNextFrameNumber(prev_sfnum[i], {i});
}