Merge branch 'developer' into g225gui

This commit is contained in:
2022-03-17 11:52:30 +01:00
54 changed files with 2505 additions and 1312 deletions

View File

@ -784,6 +784,7 @@ class CmdProxy {
{"trimen", &CmdProxy::TrimEnergies},
{"gappixels", &CmdProxy::GapPixels},
{"fliprows", &CmdProxy::fliprows},
{"master", &CmdProxy::master},
/* acquisition parameters */
{"acquire", &CmdProxy::Acquire},
@ -942,6 +943,7 @@ class CmdProxy {
{"pulsechip", &CmdProxy::PulseChip},
{"quad", &CmdProxy::Quad},
{"datastream", &CmdProxy::DataStream},
{"top", &CmdProxy::top},
/* Jungfrau Specific */
{"chipversion", &CmdProxy::chipversion},
@ -1109,7 +1111,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);
@ -1281,6 +1282,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(
@ -1328,7 +1335,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");
@ -1516,7 +1523,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 "
@ -1536,7 +1543,8 @@ 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,
@ -1900,6 +1908,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,

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);
}
@ -1486,6 +1524,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);
@ -1561,7 +1607,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.");
}
@ -1806,10 +1851,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);
}

View File

@ -509,6 +509,13 @@ void Module::setFlipRows(bool value) {
}
}
bool Module::isMaster() const { return sendToDetectorStop<int>(F_GET_MASTER); }
void Module::setMaster(const bool master) {
sendToDetector(F_SET_MASTER, static_cast<int>(master), nullptr);
sendToDetectorStop(F_SET_MASTER, static_cast<int>(master), nullptr);
}
bool Module::isVirtualDetectorServer() const {
return sendToDetector<int>(F_IS_VIRTUAL);
}
@ -870,7 +877,7 @@ int64_t Module::getFramesCaughtByReceiver() const {
return sendToReceiver<int64_t>(F_GET_RECEIVER_FRAMES_CAUGHT);
}
std::vector<uint64_t> Module::getNumMissingPackets() const {
std::vector<int64_t> Module::getNumMissingPackets() const {
// TODO!(Erik) Refactor
LOG(logDEBUG1) << "Getting num missing packets";
if (shm()->useReceiverFlag) {
@ -882,7 +889,7 @@ std::vector<uint64_t> Module::getNumMissingPackets() const {
" returned error: " + client.readErrorMessage());
} else {
auto nports = client.Receive<int>();
std::vector<uint64_t> retval(nports);
std::vector<int64_t> retval(nports);
client.Receive(retval);
LOG(logDEBUG1) << "Missing packets of Receiver" << moduleIndex
<< ": " << sls::ToString(retval);
@ -1046,6 +1053,10 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
if (ip == 0) {
throw RuntimeError("Invalid destination udp ip address");
}
if (ip.str() == LOCALHOST_IP && !isVirtualDetectorServer()) {
throw RuntimeError("Invalid destination udp ip. Change rx_hostname "
"from localhost or change udp_dstip from auto?");
}
sendToDetector(F_SET_DEST_UDP_IP, ip, nullptr);
if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU);
@ -1065,7 +1076,10 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
if (ip == 0) {
throw RuntimeError("Invalid destination udp ip address2");
}
if (ip.str() == LOCALHOST_IP && !isVirtualDetectorServer()) {
throw RuntimeError("Invalid destination udp ip2. Change rx_hostname "
"from localhost or change udp_dstip from auto?");
}
sendToDetector(F_SET_DEST_UDP_IP2, ip, nullptr);
if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU);
@ -1666,6 +1680,14 @@ void Module::setDataStream(const portPosition port, const bool enable) {
}
}
bool Module::getTop() const {
return (static_cast<bool>(sendToDetector<int>(F_GET_TOP)));
}
void Module::setTop(bool value) {
sendToDetector(F_SET_TOP, static_cast<int>(value), nullptr);
}
// Jungfrau Specific
double Module::getChipVersion() const {
return (sendToDetector<int>(F_GET_CHIP_VERSION)) / 10.00;
@ -2190,8 +2212,6 @@ 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 sendToDetectorStop<int>(F_GET_MASTER); }
int Module::getChipStatusRegister() const {
return sendToDetector<int>(F_GET_CSR);
}

View File

@ -120,6 +120,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;
/**************************************************
@ -184,6 +187,7 @@ class Module : public virtual slsDetectorDefs {
void setDBITPipeline(int value);
int getReadNRows() const;
void setReadNRows(const int value);
/**************************************************
* *
* Acquisition *
@ -200,7 +204,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);
@ -365,6 +369,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);
/**************************************************
* *
@ -456,7 +462,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();