mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 08:17:13 +02:00
clang-format
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
|
||||
/*
|
||||
This file is used to generate the command line binaries
|
||||
(sls_detector_get/put/acquire/help). By defines in CMake
|
||||
we get the different files.
|
||||
(sls_detector_get/put/acquire/help). By defines in CMake
|
||||
we get the different files.
|
||||
|
||||
*/
|
||||
#include "CmdParser.h"
|
||||
|
10
slsDetectorSoftware/src/CmdParser.cpp
Executable file → Normal file
10
slsDetectorSoftware/src/CmdParser.cpp
Executable file → Normal file
@ -45,7 +45,8 @@ void CmdParser::Parse(const std::string &s) {
|
||||
auto old_size = arguments_.size();
|
||||
arguments_.erase(std::remove_if(begin(arguments_), end(arguments_),
|
||||
[](const std::string &item) {
|
||||
return (item == "-h" || item == "--help");
|
||||
return (item == "-h" ||
|
||||
item == "--help");
|
||||
}),
|
||||
end(arguments_));
|
||||
if (old_size - arguments_.size() > 0)
|
||||
@ -100,16 +101,15 @@ std::vector<const char *> CmdParser::argv() const {
|
||||
return vec;
|
||||
}
|
||||
|
||||
|
||||
std::string CmdParser::cli_line() const{
|
||||
std::string CmdParser::cli_line() const {
|
||||
std::ostringstream os;
|
||||
os << command_;
|
||||
for (const auto & arg : arguments_)
|
||||
for (const auto &arg : arguments_)
|
||||
os << " " << arg;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
void CmdParser::Reset(){
|
||||
void CmdParser::Reset() {
|
||||
multi_id_ = 0;
|
||||
detector_id_ = -1;
|
||||
help_ = false;
|
||||
|
8
slsDetectorSoftware/src/CmdParser.h
Executable file → Normal file
8
slsDetectorSoftware/src/CmdParser.h
Executable file → Normal file
@ -28,12 +28,14 @@ class CmdParser {
|
||||
int multi_id() const noexcept { return multi_id_; };
|
||||
int detector_id() const noexcept { return detector_id_; };
|
||||
int n_arguments() const noexcept { return arguments_.size(); }
|
||||
const std::string &command() const noexcept{ return command_; }
|
||||
const std::string &command() const noexcept { return command_; }
|
||||
void setCommand(std::string cmd) { command_ = cmd; }
|
||||
bool isHelp() const noexcept { return help_; }
|
||||
|
||||
const std::string &executable() const noexcept{ return executable_; }
|
||||
const std::vector<std::string> &arguments() const noexcept{ return arguments_; };
|
||||
const std::string &executable() const noexcept { return executable_; }
|
||||
const std::vector<std::string> &arguments() const noexcept {
|
||||
return arguments_;
|
||||
};
|
||||
std::vector<const char *> argv() const;
|
||||
std::string cli_line() const;
|
||||
|
||||
|
@ -169,7 +169,8 @@ std::string CmdProxy::VirtualServer(int action) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot execute this at module level");
|
||||
}
|
||||
det->setVirtualDetectorServers(StringTo<int>(args[0]), StringTo<int>(args[1]));
|
||||
det->setVirtualDetectorServers(StringTo<int>(args[0]),
|
||||
StringTo<int>(args[1]));
|
||||
os << sls::ToString(args);
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -394,21 +395,24 @@ std::string CmdProxy::Adcphase(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_value] [(optional)deg]\n\t[Jungfrau][Ctb][Moench][Moench][Gotthard] Phase "
|
||||
os << "[n_value] "
|
||||
"[(optional)deg]\n\t[Jungfrau][Ctb][Moench][Moench][Gotthard] "
|
||||
"Phase "
|
||||
"shift of ADC clock. \n\t[Jungfrau] Absolute phase shift. If deg "
|
||||
"used, then shift in degrees. Changing Speed also resets "
|
||||
"adcphase to recommended defaults.\n\t[Ctb][Moench] Absolute phase "
|
||||
"adcphase to recommended defaults.\n\t[Ctb][Moench] Absolute "
|
||||
"phase "
|
||||
"shift. If deg used, then shift in degrees. Changing adcclk also "
|
||||
"resets adcphase and sets it to previous values.\n\t[Gotthard] "
|
||||
"Relative phase shift"
|
||||
<< '\n';
|
||||
} else {
|
||||
} else {
|
||||
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (det_type == defs::EIGER ||
|
||||
det_type == defs::MYTHEN3 ||
|
||||
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
||||
det_type == defs::GOTTHARD2) {
|
||||
throw sls::RuntimeError("adcphase not implemented for this detector");
|
||||
}
|
||||
throw sls::RuntimeError(
|
||||
"adcphase not implemented for this detector");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
Result<int> t;
|
||||
if (args.empty()) {
|
||||
@ -416,7 +420,8 @@ std::string CmdProxy::Adcphase(int action) {
|
||||
os << OutString(t) << '\n';
|
||||
} else if (args.size() == 1) {
|
||||
if (args[0] != "deg") {
|
||||
throw sls::RuntimeError("Unknown adcphase argument " + args[0] +
|
||||
throw sls::RuntimeError("Unknown adcphase argument " +
|
||||
args[0] +
|
||||
". Did you mean deg? ");
|
||||
}
|
||||
t = det->getADCPhaseInDegrees({det_id});
|
||||
@ -426,14 +431,14 @@ std::string CmdProxy::Adcphase(int action) {
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setADCPhase(StringTo<int>(args[0]), {det_id} );
|
||||
det->setADCPhase(StringTo<int>(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else if (args.size() == 2) {
|
||||
if (args[1] != "deg") {
|
||||
throw sls::RuntimeError("Unknown adcphase 2nd argument " +
|
||||
args[1] + ". Did you mean deg?");
|
||||
}
|
||||
det->setADCPhaseInDegrees(StringTo<int>(args[0]) , {det_id});
|
||||
det->setADCPhaseInDegrees(StringTo<int>(args[0]), {det_id});
|
||||
os << args[0] << " " << args[1] << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
@ -449,17 +454,19 @@ std::string CmdProxy::Dbitphase(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_value] [(optional)deg]\n\t[Ctb][Jungfrau] Phase shift of clock to "
|
||||
os << "[n_value] [(optional)deg]\n\t[Ctb][Jungfrau] Phase shift of "
|
||||
"clock to "
|
||||
"latch digital bits. Absolute phase shift. If deg used, then "
|
||||
"shift in degrees. \n\t[Ctb]Changing dbitclk also resets dbitphase and "
|
||||
"shift in degrees. \n\t[Ctb]Changing dbitclk also resets "
|
||||
"dbitphase and "
|
||||
"sets to previous values."
|
||||
<< '\n';
|
||||
} else {
|
||||
} else {
|
||||
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (det_type == defs::EIGER ||
|
||||
det_type == defs::MYTHEN3 ||
|
||||
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
||||
det_type == defs::GOTTHARD2) {
|
||||
throw sls::RuntimeError("dbitphase not implemented for this detector");
|
||||
throw sls::RuntimeError(
|
||||
"dbitphase not implemented for this detector");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
Result<int> t;
|
||||
@ -485,7 +492,7 @@ std::string CmdProxy::Dbitphase(int action) {
|
||||
throw sls::RuntimeError("Unknown dbitphase 2nd argument " +
|
||||
args[1] + ". Did you mean deg? ");
|
||||
}
|
||||
det->setDBITPhaseInDegrees(StringTo<int>(args[0]), {det_id} );
|
||||
det->setDBITPhaseInDegrees(StringTo<int>(args[0]), {det_id});
|
||||
os << args[0] << " " << args[1] << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
@ -507,7 +514,8 @@ std::string CmdProxy::ClockFrequency(int action) {
|
||||
} else {
|
||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||
throw sls::RuntimeError("clkfreq not implemented for this detector.");
|
||||
throw sls::RuntimeError(
|
||||
"clkfreq not implemented for this detector.");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
@ -519,8 +527,8 @@ std::string CmdProxy::ClockFrequency(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setClockFrequency(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
||||
{det_id});
|
||||
det->setClockFrequency(StringTo<int>(args[0]),
|
||||
StringTo<int>(args[1]), {det_id});
|
||||
os << StringTo<int>(args[1]) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -541,7 +549,8 @@ std::string CmdProxy::ClockPhase(int action) {
|
||||
} else {
|
||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||
throw sls::RuntimeError("clkphase not implemented for this detector.");
|
||||
throw sls::RuntimeError(
|
||||
"clkphase not implemented for this detector.");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
@ -552,16 +561,16 @@ std::string CmdProxy::ClockPhase(int action) {
|
||||
throw sls::RuntimeError("Cannot scan argument" + args[1] +
|
||||
". Did you mean deg?");
|
||||
}
|
||||
auto t =
|
||||
det->getClockPhaseinDegrees(StringTo<int>(args[0]), {det_id});
|
||||
auto t = det->getClockPhaseinDegrees(StringTo<int>(args[0]),
|
||||
{det_id});
|
||||
os << OutString(t) << " deg\n";
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 2) {
|
||||
det->setClockPhase(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
||||
{det_id});
|
||||
det->setClockPhase(StringTo<int>(args[0]),
|
||||
StringTo<int>(args[1]), {det_id});
|
||||
os << args[1] << '\n';
|
||||
} else if (args.size() == 3) {
|
||||
if (args[2] != "deg") {
|
||||
@ -591,13 +600,15 @@ std::string CmdProxy::MaxClockPhaseShift(int action) {
|
||||
} else {
|
||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||
throw sls::RuntimeError("maxclkphaseshift not implemented for this detector.");
|
||||
throw sls::RuntimeError(
|
||||
"maxclkphaseshift not implemented for this detector.");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getMaxClockPhaseShift(StringTo<int>(args[0]), {det_id});
|
||||
auto t =
|
||||
det->getMaxClockPhaseShift(StringTo<int>(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("Cannot put");
|
||||
@ -618,7 +629,8 @@ std::string CmdProxy::ClockDivider(int action) {
|
||||
} else {
|
||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||
throw sls::RuntimeError("clkdiv not implemented for this detector.");
|
||||
throw sls::RuntimeError(
|
||||
"clkdiv not implemented for this detector.");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
@ -649,8 +661,11 @@ std::string CmdProxy::Dac(int action) {
|
||||
os << "[dac index] [dac or mv value] [(optional unit) mv] "
|
||||
"\n\t[Ctb] Dac."
|
||||
<< '\n';
|
||||
} else if (det->getDetectorType().squash(defs::GENERIC) != defs::CHIPTESTBOARD) {
|
||||
throw sls::RuntimeError("Dac command can only be used for chip test board. Use daclist to get list of dac commands for current detector.");
|
||||
} else if (det->getDetectorType().squash(defs::GENERIC) !=
|
||||
defs::CHIPTESTBOARD) {
|
||||
throw sls::RuntimeError(
|
||||
"Dac command can only be used for chip test board. Use daclist to "
|
||||
"get list of dac commands for current detector.");
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
bool mv = false;
|
||||
if (args.size() == 2) {
|
||||
@ -662,8 +677,8 @@ std::string CmdProxy::Dac(int action) {
|
||||
} else if (args.size() > 2) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getDAC(static_cast<defs::dacIndex>(StringTo<int>(args[0])),
|
||||
mv, {det_id});
|
||||
auto t = det->getDAC(
|
||||
static_cast<defs::dacIndex>(StringTo<int>(args[0])), mv, {det_id});
|
||||
os << args[0] << ' ' << OutString(t)
|
||||
<< (args.size() > 1 ? " mv\n" : "\n");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
@ -757,10 +772,10 @@ std::vector<std::string> CmdProxy::DacCommands() {
|
||||
break;
|
||||
case defs::GOTTHARD2:
|
||||
return std::vector<std::string>{
|
||||
"vref_h_adc", "vb_comp_fe", "vb_comp_adc", "vcom_cds",
|
||||
"vref_h_adc", "vb_comp_fe", "vb_comp_adc", "vcom_cds",
|
||||
"vref_rstore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1",
|
||||
"vref_prech", "vref_l_adc", "vref_cds", "vb_cs",
|
||||
"vb_opa_fd", "vcom_adc2"};
|
||||
"vref_prech", "vref_l_adc", "vref_cds", "vb_cs",
|
||||
"vb_opa_fd", "vcom_adc2"};
|
||||
break;
|
||||
case defs::MYTHEN3:
|
||||
return std::vector<std::string>{
|
||||
@ -769,9 +784,9 @@ std::vector<std::string> CmdProxy::DacCommands() {
|
||||
"viinsh", "vph", "vtrim", "vdcsh"};
|
||||
break;
|
||||
case defs::MOENCH:
|
||||
return std::vector<std::string>{"vbp_colbuf", "vipre", "vin_cm",
|
||||
"vb_sda", "vcasc_sfp", "vout_cm",
|
||||
"vipre_cds", "ibias_sfp"};
|
||||
return std::vector<std::string>{"vbp_colbuf", "vipre", "vin_cm",
|
||||
"vb_sda", "vcasc_sfp", "vout_cm",
|
||||
"vipre_cds", "ibias_sfp"};
|
||||
break;
|
||||
case defs::CHIPTESTBOARD:
|
||||
return std::vector<std::string>{
|
||||
@ -790,16 +805,16 @@ std::string CmdProxy::ReceiverStatus(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "running, idle]\n\tReceiver listener status."
|
||||
<< '\n';
|
||||
os << "running, idle]\n\tReceiver listener status." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getReceiverStatus({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("Cannot put. Did you mean to use command 'rx_start' or 'rx_stop'?");
|
||||
throw sls::RuntimeError(
|
||||
"Cannot put. Did you mean to use command 'rx_start' or 'rx_stop'?");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
@ -810,16 +825,18 @@ std::string CmdProxy::DetectorStatus(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[running, error, transmitting, finished, waiting, idle]\n\tDetector status."
|
||||
<< '\n';
|
||||
os << "[running, error, transmitting, finished, waiting, "
|
||||
"idle]\n\tDetector status."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getDetectorStatus({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("Cannot put. Did you mean to use command 'start' or 'stop'?");
|
||||
throw sls::RuntimeError(
|
||||
"Cannot put. Did you mean to use command 'start' or 'stop'?");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
@ -832,33 +849,36 @@ std::string CmdProxy::UDPDestinationIP(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[x.x.x.x] or auto\n\tIp address of the receiver (destination) udp interface. If 'auto' used, then ip is set to ip of rx_hostname."
|
||||
<< '\n';
|
||||
os << "[x.x.x.x] or auto\n\tIp address of the receiver (destination) "
|
||||
"udp interface. If 'auto' used, then ip is set to ip of "
|
||||
"rx_hostname."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
auto t = det->getDestinationUDPIP({det_id});
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
os << OutString(t) << '\n';
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (args[0] == "auto") {
|
||||
std::string rxHostname = det->getRxHostname({det_id}).squash("none");
|
||||
std::string rxHostname =
|
||||
det->getRxHostname({det_id}).squash("none");
|
||||
// Hostname could be ip try to decode otherwise look up the hostname
|
||||
auto val = sls::IpAddr{rxHostname};
|
||||
if (val == 0) {
|
||||
val = HostnameToIp(rxHostname.c_str());
|
||||
}
|
||||
LOG(logINFO) << "Setting udp_dstip of detector " <<
|
||||
det_id << " to " << val;
|
||||
LOG(logINFO) << "Setting udp_dstip of detector " << det_id << " to "
|
||||
<< val;
|
||||
det->setDestinationUDPIP(val, {det_id});
|
||||
os << val << '\n';
|
||||
os << val << '\n';
|
||||
} else {
|
||||
auto val = IpAddr(args[0]);
|
||||
det->setDestinationUDPIP(val, {det_id});
|
||||
os << args.front() << '\n';
|
||||
os << args.front() << '\n';
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -870,33 +890,37 @@ std::string CmdProxy::UDPDestinationIP2(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[x.x.x.x] or auto\n\t[Jungfrau] Ip address of the receiver (destination) udp interface where the second half of detector data is sent to. If 'auto' used, then ip is set to ip of rx_hostname."
|
||||
<< '\n';
|
||||
os << "[x.x.x.x] or auto\n\t[Jungfrau] Ip address of the receiver "
|
||||
"(destination) udp interface where the second half of detector "
|
||||
"data is sent to. If 'auto' used, then ip is set to ip of "
|
||||
"rx_hostname."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
auto t = det->getDestinationUDPIP2({det_id});
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
os << OutString(t) << '\n';
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (args[0] == "auto") {
|
||||
std::string rxHostname = det->getRxHostname({det_id}).squash("none");
|
||||
std::string rxHostname =
|
||||
det->getRxHostname({det_id}).squash("none");
|
||||
// Hostname could be ip try to decode otherwise look up the hostname
|
||||
auto val = sls::IpAddr{rxHostname};
|
||||
if (val == 0) {
|
||||
val = HostnameToIp(rxHostname.c_str());
|
||||
}
|
||||
LOG(logINFO) << "Setting udp_dstip2 of detector " <<
|
||||
det_id << " to " << val;
|
||||
LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id
|
||||
<< " to " << val;
|
||||
det->setDestinationUDPIP2(val, {det_id});
|
||||
os << val << '\n';
|
||||
os << val << '\n';
|
||||
} else {
|
||||
auto val = IpAddr(args[0]);
|
||||
det->setDestinationUDPIP2(val, {det_id});
|
||||
os << args.front() << '\n';
|
||||
os << args.front() << '\n';
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -910,11 +934,13 @@ std::string CmdProxy::ReceiveHostname(int action) {
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[hostname or ip address]\n\t"
|
||||
"[hostname or ip address]:[tcp port]\n\t"
|
||||
"[hostname1]:[tcp_port1]+[hostname2]:[tcp_port2]+\n\t"
|
||||
"Receiver hostname or IP. If port included, then the receiver tcp port.\n\t"
|
||||
"Used for TCP control communication between client and receiver "
|
||||
"to configure receiver. Also updates receiver with detector parameters."
|
||||
"[hostname or ip address]:[tcp port]\n\t"
|
||||
"[hostname1]:[tcp_port1]+[hostname2]:[tcp_port2]+\n\t"
|
||||
"Receiver hostname or IP. If port included, then the receiver "
|
||||
"tcp port.\n\t"
|
||||
"Used for TCP control communication between client and receiver "
|
||||
"to configure receiver. Also updates receiver with detector "
|
||||
"parameters."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (!args.empty()) {
|
||||
@ -930,10 +956,12 @@ std::string CmdProxy::ReceiveHostname(int action) {
|
||||
if (args.size() > 1) {
|
||||
// multiple in mulitple
|
||||
if (args[0].find('+') != std::string::npos) {
|
||||
throw sls::RuntimeError("Cannot add multiple receivers at module level");
|
||||
throw sls::RuntimeError(
|
||||
"Cannot add multiple receivers at module level");
|
||||
}
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot add multiple receivers at module level");
|
||||
throw sls::RuntimeError(
|
||||
"Cannot add multiple receivers at module level");
|
||||
}
|
||||
det->setRxHostname(args);
|
||||
os << ToString(args) << '\n';
|
||||
@ -943,8 +971,9 @@ std::string CmdProxy::ReceiveHostname(int action) {
|
||||
// multiple receivers concatenated with +
|
||||
if (args[0].find('+') != std::string::npos) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot add multiple receivers at module level");
|
||||
}
|
||||
throw sls::RuntimeError(
|
||||
"Cannot add multiple receivers at module level");
|
||||
}
|
||||
auto t = sls::split(args[0], '+');
|
||||
det->setRxHostname(t);
|
||||
os << ToString(t) << '\n';
|
||||
@ -997,8 +1026,10 @@ std::string CmdProxy::Threshold(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[eV] [(optinal settings) standard, lowgain, veryhighgain, verylowgain]"
|
||||
"\n\t[Eiger] Threshold in eV" << '\n';
|
||||
os << "[eV] [(optinal settings) standard, lowgain, veryhighgain, "
|
||||
"verylowgain]"
|
||||
"\n\t[Eiger] Threshold in eV"
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
@ -1029,8 +1060,9 @@ std::string CmdProxy::ThresholdNoTb(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[eV] [(optional settings) standard, lowgain, veryhighgain, verylowgain]"
|
||||
"\n\t[Eiger] Threshold in eV set without setting trimbits"
|
||||
os << "[eV] [(optional settings) standard, lowgain, veryhighgain, "
|
||||
"verylowgain]"
|
||||
"\n\t[Eiger] Threshold in eV set without setting trimbits"
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("cannot get");
|
||||
@ -1058,12 +1090,12 @@ std::string CmdProxy::GapPixels(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[0, 1]\n\t[Eiger][Jungfrau] Include Gap pixels only in data call back."
|
||||
os << "[0, 1]\n\t[Eiger][Jungfrau] Include Gap pixels only in data "
|
||||
"call back."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError(
|
||||
"Cannot get gap pixels at module level");
|
||||
throw sls::RuntimeError("Cannot get gap pixels at module level");
|
||||
}
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
@ -1072,8 +1104,7 @@ std::string CmdProxy::GapPixels(int action) {
|
||||
os << t << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError(
|
||||
"Cannot add gap pixels at module level");
|
||||
throw sls::RuntimeError("Cannot add gap pixels at module level");
|
||||
}
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
@ -1283,8 +1314,7 @@ std::string CmdProxy::Quad(int action) {
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError(
|
||||
"Cannot execute quad at module level");
|
||||
throw sls::RuntimeError("Cannot execute quad at module level");
|
||||
}
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
@ -1410,7 +1440,8 @@ std::string CmdProxy::InjectChannel(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setInjectChannel(StringTo<int>(args[0]), StringTo<int>(args[1]), {det_id});
|
||||
det->setInjectChannel(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
||||
{det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1459,7 +1490,8 @@ std::string CmdProxy::VetoReference(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setVetoReference(StringTo<int>(args[0]), StringTo<int>(args[1]), {det_id});
|
||||
det->setVetoReference(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
||||
{det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1471,7 +1503,8 @@ std::string CmdProxy::BurstMode(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[off or 0, internal or 1, external or 2]\n\t[Gotthard2] Default is burst internal type"
|
||||
os << "[off or 0, internal or 1, external or 2]\n\t[Gotthard2] Default "
|
||||
"is burst internal type"
|
||||
<< '\n';
|
||||
} else {
|
||||
if (action == defs::GET_ACTION) {
|
||||
@ -1527,7 +1560,7 @@ std::string CmdProxy::Counters(int action) {
|
||||
}
|
||||
auto mask = det->getCounterMask({det_id}).squash(-1);
|
||||
// scan counter enable mask to get vector
|
||||
std::vector <int> result;
|
||||
std::vector<int> result;
|
||||
for (size_t i = 0; i < 32; ++i) {
|
||||
if (mask & (1 << i)) {
|
||||
result.push_back(static_cast<int>(i));
|
||||
@ -1579,8 +1612,8 @@ std::string CmdProxy::Samples(int action) {
|
||||
int ds = d.squash(-1);
|
||||
if (as == -1 || ds == -1 || as != ds) { // check if a == d?
|
||||
throw sls::RuntimeError(
|
||||
"Different samples. Use asamples or dsamples.");
|
||||
}
|
||||
"Different samples. Use asamples or dsamples.");
|
||||
}
|
||||
}
|
||||
os << OutString(a) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
@ -1625,7 +1658,7 @@ std::string CmdProxy::SlowAdc(int action) {
|
||||
Result<double> result(t.size());
|
||||
for (unsigned int i = 0; i < t.size(); ++i) {
|
||||
result[i] = t[i] / 1000.00;
|
||||
}
|
||||
}
|
||||
os << OutString(result) << " mV\n";
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
@ -1691,7 +1724,8 @@ std::string CmdProxy::DigitalIODelay(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setDigitalIODelay(StringTo<uint64_t>(args[0]), StringTo<int>(args[1]), {det_id});
|
||||
det->setDigitalIODelay(StringTo<uint64_t>(args[0]),
|
||||
StringTo<int>(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1705,7 +1739,8 @@ std::string CmdProxy::Pattern(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[fname]\n\t[Mythen3][Moench][Ctb][Moench] Loads binary pattern file with only pattern "
|
||||
os << "[fname]\n\t[Mythen3][Moench][Ctb][Moench] Loads binary pattern "
|
||||
"file with only pattern "
|
||||
"words"
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
@ -1726,7 +1761,8 @@ std::string CmdProxy::PatternWord(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[step or address] [64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit pattern at "
|
||||
os << "[step or address] [64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 "
|
||||
"bit pattern at "
|
||||
"address of pattern memory."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
@ -1739,7 +1775,8 @@ std::string CmdProxy::PatternWord(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setPatternWord(StringTo<int>(args[0]), StringTo<uint64_t>(args[1]), {det_id});
|
||||
det->setPatternWord(StringTo<int>(args[0]), StringTo<uint64_t>(args[1]),
|
||||
{det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1752,17 +1789,21 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
if (cmd == "patlimits") {
|
||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of complete "
|
||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
|
||||
"of complete "
|
||||
"pattern."
|
||||
<< '\n';
|
||||
} else if (cmd == "patloop0") {
|
||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of loop 0."
|
||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
|
||||
"of loop 0."
|
||||
<< '\n';
|
||||
} else if (cmd == "patloop1") {
|
||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of loop 1."
|
||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
|
||||
"of loop 1."
|
||||
<< '\n';
|
||||
} else if (cmd == "patloop2") {
|
||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of loop 2."
|
||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
|
||||
"of loop 2."
|
||||
<< '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError(
|
||||
@ -1807,11 +1848,17 @@ std::string CmdProxy::PatternLoopCycles(int action) {
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
if (cmd == "patnloop0") {
|
||||
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of loop 0." << '\n';
|
||||
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
|
||||
"loop 0."
|
||||
<< '\n';
|
||||
} else if (cmd == "patnloop1") {
|
||||
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of loop 1." << '\n';
|
||||
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
|
||||
"loop 1."
|
||||
<< '\n';
|
||||
} else if (cmd == "patnloop2") {
|
||||
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of loop 2." << '\n';
|
||||
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
|
||||
"loop 2."
|
||||
<< '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError(
|
||||
"Unknown command, use list to list all commands");
|
||||
@ -1897,11 +1944,17 @@ std::string CmdProxy::PatternWaitTime(int action) {
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
if (cmd == "patwaittime0") {
|
||||
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 0 time in clock cycles." << '\n';
|
||||
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 0 time in clock "
|
||||
"cycles."
|
||||
<< '\n';
|
||||
} else if (cmd == "patwaittime1") {
|
||||
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 1 time in clock cycles." << '\n';
|
||||
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 1 time in clock "
|
||||
"cycles."
|
||||
<< '\n';
|
||||
} else if (cmd == "patwaittime2") {
|
||||
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 2 time in clock cycles." << '\n';
|
||||
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 2 time in clock "
|
||||
"cycles."
|
||||
<< '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError(
|
||||
"Unknown command, use list to list all commands");
|
||||
@ -1928,7 +1981,8 @@ std::string CmdProxy::PatternWaitTime(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setPatternWaitTime(level, StringTo<uint64_t>(args[0]), {det_id});
|
||||
det->setPatternWaitTime(level, StringTo<uint64_t>(args[0]),
|
||||
{det_id});
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1944,9 +1998,11 @@ std::string CmdProxy::AdditionalJsonHeader(int action) {
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[key1] [value1] [key2] [value2]...[keyn] [valuen]"
|
||||
"\n\tAdditional json header to be streamed out from receiver via zmq. "
|
||||
"Default is empty. Use only if to be processed by an intermediate user process "
|
||||
"listening to receiver zmq packets. Empty value deletes header. "
|
||||
"\n\tAdditional json header to be streamed out from receiver via "
|
||||
"zmq. "
|
||||
"Default is empty. Use only if to be processed by an "
|
||||
"intermediate user process "
|
||||
"listening to receiver zmq packets. Empty value deletes header. "
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
@ -1970,7 +2026,7 @@ std::string CmdProxy::AdditionalJsonHeader(int action) {
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::JsonParameter(int action) {
|
||||
@ -1978,7 +2034,8 @@ std::string CmdProxy::JsonParameter(int action) {
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[key1] [value1]\n\tAdditional json header parameter streamed "
|
||||
"out from receiver. If not found in header, the pair is appended. "
|
||||
"out from receiver. If not found in header, the pair is "
|
||||
"appended. "
|
||||
"An empty values deletes parameter."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
@ -1989,14 +2046,14 @@ std::string CmdProxy::JsonParameter(int action) {
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
switch (args.size()) {
|
||||
case 1:
|
||||
det->setAdditionalJsonParameter(args[0], "", {det_id});
|
||||
break;
|
||||
case 2:
|
||||
det->setAdditionalJsonParameter(args[0], args[1], {det_id});
|
||||
break;
|
||||
default:
|
||||
WrongNumberOfParameters(1);
|
||||
case 1:
|
||||
det->setAdditionalJsonParameter(args[0], "", {det_id});
|
||||
break;
|
||||
case 2:
|
||||
det->setAdditionalJsonParameter(args[0], args[1], {det_id});
|
||||
break;
|
||||
default:
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (args.size() == 1) {
|
||||
os << args[0] << " deleted" << '\n';
|
||||
@ -2061,9 +2118,9 @@ std::string CmdProxy::ProgramFpga(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[fname.pof | fname.rbf]\n\t[Jungfrau][Ctb][Moench] Programs FPGA from pof file."
|
||||
<< "\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file."
|
||||
<< '\n';
|
||||
os << "[fname.pof | fname.rbf]\n\t[Jungfrau][Ctb][Moench] Programs "
|
||||
"FPGA from pof file."
|
||||
<< "\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("Cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
@ -2082,7 +2139,8 @@ std::string CmdProxy::CopyDetectorServer(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[server_name] [pc_host_name]\n\t[Jungfrau][Ctb][Moench] Copies detector "
|
||||
os << "[server_name] [pc_host_name]\n\t[Jungfrau][Ctb][Moench] Copies "
|
||||
"detector "
|
||||
"server via tftp from pc and changes respawn server name in "
|
||||
"/etc/inittab of detector."
|
||||
<< '\n';
|
||||
@ -2104,7 +2162,8 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[server_name] [pc_host_name] [fname.pof]\n\t[Jungfrau][Ctb][Moench] "
|
||||
os << "[server_name] [pc_host_name] "
|
||||
"[fname.pof]\n\t[Jungfrau][Ctb][Moench] "
|
||||
"Updates detector server via tftp from pc, updates firmware to "
|
||||
"pof file and then reboots controller (blackfin)."
|
||||
<< '\n';
|
||||
@ -2142,7 +2201,8 @@ std::string CmdProxy::Register(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->writeRegister(StringTo<uint32_t>(args[0]), StringTo<uint32_t>(args[1]), {det_id});
|
||||
det->writeRegister(StringTo<uint32_t>(args[0]),
|
||||
StringTo<uint32_t>(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -2154,7 +2214,8 @@ std::string CmdProxy::AdcRegister(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[address] [value]\n\t[Jungfrau][Ctb][Moench][Gotthard] Writes to an adc "
|
||||
os << "[address] [value]\n\t[Jungfrau][Ctb][Moench][Gotthard] Writes "
|
||||
"to an adc "
|
||||
"register in hex."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
@ -2163,7 +2224,8 @@ std::string CmdProxy::AdcRegister(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->writeAdcRegister(StringTo<uint32_t>(args[0]), StringTo<uint32_t>(args[1]), {det_id});
|
||||
det->writeAdcRegister(StringTo<uint32_t>(args[0]),
|
||||
StringTo<uint32_t>(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -2236,7 +2298,10 @@ std::string CmdProxy::InitialChecks(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[0, 1]\n\tEnable or disable intial compatibility and other checks at detector start up. It is enabled by default. Must come before 'hostname' command to take effect. Can be used to reprogram fpga when current firmware is incompatible."
|
||||
os << "[0, 1]\n\tEnable or disable intial compatibility and other "
|
||||
"checks at detector start up. It is enabled by default. Must "
|
||||
"come before 'hostname' command to take effect. Can be used to "
|
||||
"reprogram fpga when current firmware is incompatible."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (det_id != -1) {
|
||||
@ -2264,7 +2329,6 @@ std::string CmdProxy::InitialChecks(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
/* Insignificant */
|
||||
|
||||
std::string CmdProxy::ExecuteCommand(int action) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,11 @@
|
||||
#include "Detector.h"
|
||||
#include "CmdParser.h"
|
||||
#include "CmdProxy.h"
|
||||
#include "DetectorImpl.h"
|
||||
#include "Module.h"
|
||||
#include "container_utils.h"
|
||||
#include "detectorData.h"
|
||||
#include "logger.h"
|
||||
#include "DetectorImpl.h"
|
||||
#include "Module.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
@ -72,8 +72,8 @@ void Detector::loadParameters(const std::string &fname) {
|
||||
if (current_line.find('#') != std::string::npos) {
|
||||
current_line.erase(current_line.find('#'));
|
||||
}
|
||||
LOG(logDEBUG1)
|
||||
<< "current_line after removing comments:\n\t" << current_line;
|
||||
LOG(logDEBUG1) << "current_line after removing comments:\n\t"
|
||||
<< current_line;
|
||||
if (current_line.length() > 1) {
|
||||
parser.Parse(current_line);
|
||||
proxy.Call(parser.command(), parser.arguments(),
|
||||
@ -97,13 +97,9 @@ void Detector::setVirtualDetectorServers(int numServers, int startingPort) {
|
||||
|
||||
int Detector::getShmId() const { return pimpl->getMultiId(); }
|
||||
|
||||
std::string Detector::getPackageVersion() const {
|
||||
return GITBRANCH;
|
||||
}
|
||||
std::string Detector::getPackageVersion() const { return GITBRANCH; }
|
||||
|
||||
int64_t Detector::getClientVersion() const {
|
||||
return APILIB;
|
||||
}
|
||||
int64_t Detector::getClientVersion() const { return APILIB; }
|
||||
|
||||
Result<int64_t> Detector::getFirmwareVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getFirmwareVersion, pos);
|
||||
@ -242,8 +238,7 @@ void Detector::setTimingMode(defs::timingMode value, Positions pos) {
|
||||
}
|
||||
|
||||
Result<defs::speedLevel> Detector::getSpeed(Positions pos) const {
|
||||
auto res =
|
||||
pimpl->Parallel(&Module::getClockDivider, pos, defs::RUN_CLOCK);
|
||||
auto res = pimpl->Parallel(&Module::getClockDivider, pos, defs::RUN_CLOCK);
|
||||
Result<defs::speedLevel> speedResult(res.size());
|
||||
for (unsigned int i = 0; i < res.size(); ++i) {
|
||||
speedResult[i] = static_cast<defs::speedLevel>(res[i]);
|
||||
@ -257,13 +252,11 @@ void Detector::setSpeed(defs::speedLevel value, Positions pos) {
|
||||
}
|
||||
|
||||
Result<int> Detector::getADCPhase(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK,
|
||||
false);
|
||||
return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK, false);
|
||||
}
|
||||
|
||||
void Detector::setADCPhase(int value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setClockPhase, pos, defs::ADC_CLOCK, value,
|
||||
false);
|
||||
pimpl->Parallel(&Module::setClockPhase, pos, defs::ADC_CLOCK, value, false);
|
||||
}
|
||||
|
||||
Result<int> Detector::getMaxADCPhaseShift(Positions pos) const {
|
||||
@ -272,13 +265,11 @@ Result<int> Detector::getMaxADCPhaseShift(Positions pos) const {
|
||||
}
|
||||
|
||||
Result<int> Detector::getADCPhaseInDegrees(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK,
|
||||
true);
|
||||
return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK, true);
|
||||
}
|
||||
|
||||
void Detector::setADCPhaseInDegrees(int value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setClockPhase, pos, defs::ADC_CLOCK, value,
|
||||
true);
|
||||
pimpl->Parallel(&Module::setClockPhase, pos, defs::ADC_CLOCK, value, true);
|
||||
}
|
||||
|
||||
Result<int> Detector::getDBITPhase(Positions pos) const {
|
||||
@ -297,13 +288,11 @@ Result<int> Detector::getMaxDBITPhaseShift(Positions pos) const {
|
||||
}
|
||||
|
||||
Result<int> Detector::getDBITPhaseInDegrees(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getClockPhase, pos, defs::DBIT_CLOCK,
|
||||
true);
|
||||
return pimpl->Parallel(&Module::getClockPhase, pos, defs::DBIT_CLOCK, true);
|
||||
}
|
||||
|
||||
void Detector::setDBITPhaseInDegrees(int value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setClockPhase, pos, defs::DBIT_CLOCK, value,
|
||||
true);
|
||||
pimpl->Parallel(&Module::setClockPhase, pos, defs::DBIT_CLOCK, value, true);
|
||||
}
|
||||
|
||||
Result<int> Detector::getClockFrequency(int clkIndex, Positions pos) {
|
||||
@ -343,8 +332,7 @@ void Detector::setClockDivider(int clkIndex, int value, Positions pos) {
|
||||
}
|
||||
|
||||
Result<int> Detector::getHighVoltage(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::setDAC, pos, -1, defs::HIGH_VOLTAGE,
|
||||
0);
|
||||
return pimpl->Parallel(&Module::setDAC, pos, -1, defs::HIGH_VOLTAGE, 0);
|
||||
}
|
||||
|
||||
void Detector::setHighVoltage(int value, Positions pos) {
|
||||
@ -430,13 +418,9 @@ void Detector::acquire() { pimpl->acquire(); }
|
||||
|
||||
void Detector::clearAcquiringFlag() { pimpl->setAcquiringFlag(0); }
|
||||
|
||||
void Detector::startReceiver() {
|
||||
pimpl->Parallel(&Module::startReceiver, {});
|
||||
}
|
||||
void Detector::startReceiver() { pimpl->Parallel(&Module::startReceiver, {}); }
|
||||
|
||||
void Detector::stopReceiver() {
|
||||
pimpl->Parallel(&Module::stopReceiver, {});
|
||||
}
|
||||
void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); }
|
||||
|
||||
void Detector::startDetector() {
|
||||
if (getDetectorType().squash() == defs::EIGER) {
|
||||
@ -445,9 +429,7 @@ void Detector::startDetector() {
|
||||
pimpl->Parallel(&Module::startAcquisition, {});
|
||||
}
|
||||
|
||||
void Detector::stopDetector() {
|
||||
pimpl->Parallel(&Module::stopAcquisition, {});
|
||||
}
|
||||
void Detector::stopDetector() { pimpl->Parallel(&Module::stopAcquisition, {}); }
|
||||
|
||||
Result<defs::runStatus> Detector::getDetectorStatus(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getRunStatus, pos);
|
||||
@ -461,7 +443,8 @@ Result<int64_t> Detector::getFramesCaught(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getFramesCaughtByReceiver, pos);
|
||||
}
|
||||
|
||||
Result<std::vector<uint64_t>> Detector::getNumMissingPackets(Positions pos) const {
|
||||
Result<std::vector<uint64_t>>
|
||||
Detector::getNumMissingPackets(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getNumMissingPackets, pos);
|
||||
}
|
||||
|
||||
@ -607,8 +590,7 @@ void Detector::setDestinationUDPPort2(int port, int module_id) {
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
pimpl->Parallel(&Module::setDestinationUDPPort2, {module_id},
|
||||
port);
|
||||
pimpl->Parallel(&Module::setDestinationUDPPort2, {module_id}, port);
|
||||
}
|
||||
}
|
||||
|
||||
@ -677,9 +659,9 @@ void Detector::setRxHostname(const std::vector<std::string> &name) {
|
||||
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]);
|
||||
} else {
|
||||
if ((int)name.size() != size()) {
|
||||
throw RuntimeError("Receiver hostnames size " +
|
||||
std::to_string(name.size()) + " does not match detector size " +
|
||||
std::to_string(size()));
|
||||
throw RuntimeError(
|
||||
"Receiver hostnames size " + std::to_string(name.size()) +
|
||||
" does not match detector size " + std::to_string(size()));
|
||||
}
|
||||
// set each rx_hostname
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
@ -699,8 +681,7 @@ void Detector::setRxPort(int port, int module_id) {
|
||||
it = port++;
|
||||
}
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setReceiverPort, {idet},
|
||||
port_list[idet]);
|
||||
pimpl->Parallel(&Module::setReceiverPort, {idet}, port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
pimpl->Parallel(&Module::setReceiverPort, {module_id}, port);
|
||||
@ -751,8 +732,7 @@ void Detector::setRxUDPSocketBufferSize(int64_t udpsockbufsize, Positions pos) {
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getRxRealUDPSocketBufferSize(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverRealUDPSocketBufferSize,
|
||||
pos);
|
||||
return pimpl->Parallel(&Module::getReceiverRealUDPSocketBufferSize, pos);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getRxLock(Positions pos) {
|
||||
@ -871,8 +851,7 @@ void Detector::setRxZmqPort(int port, int module_id) {
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
pimpl->Parallel(&Module::setReceiverStreamingPort, {module_id},
|
||||
port);
|
||||
pimpl->Parallel(&Module::setReceiverStreamingPort, {module_id}, port);
|
||||
}
|
||||
}
|
||||
|
||||
@ -901,8 +880,7 @@ void Detector::setClientZmqPort(int port, int module_id) {
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
pimpl->Parallel(&Module::setClientStreamingPort, {module_id},
|
||||
port);
|
||||
pimpl->Parallel(&Module::setClientStreamingPort, {module_id}, port);
|
||||
}
|
||||
}
|
||||
|
||||
@ -952,8 +930,8 @@ Result<int> Detector::getThresholdEnergy(Positions pos) const {
|
||||
void Detector::setThresholdEnergy(int threshold_ev,
|
||||
defs::detectorSettings settings,
|
||||
bool trimbits, Positions pos) {
|
||||
pimpl->Parallel(&Module::setThresholdEnergy, pos, threshold_ev,
|
||||
settings, static_cast<int>(trimbits));
|
||||
pimpl->Parallel(&Module::setThresholdEnergy, pos, threshold_ev, settings,
|
||||
static_cast<int>(trimbits));
|
||||
}
|
||||
|
||||
Result<std::string> Detector::getSettingsPath(Positions pos) const {
|
||||
@ -1146,8 +1124,7 @@ void Detector::setAutoCompDisable(bool value, Positions pos) {
|
||||
}
|
||||
|
||||
Result<int> Detector::getNumberOfAdditionalStorageCells(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getNumberOfAdditionalStorageCells,
|
||||
pos);
|
||||
return pimpl->Parallel(&Module::getNumberOfAdditionalStorageCells, pos);
|
||||
}
|
||||
|
||||
void Detector::setNumberOfAdditionalStorageCells(int value) {
|
||||
@ -1224,21 +1201,28 @@ Result<std::array<int, 2>> Detector::getInjectChannel(Positions pos) {
|
||||
return pimpl->Parallel(&Module::getInjectChannel, pos);
|
||||
}
|
||||
|
||||
void Detector::setInjectChannel(const int offsetChannel, const int incrementChannel, Positions pos) {
|
||||
pimpl->Parallel(&Module::setInjectChannel, pos, offsetChannel, incrementChannel);
|
||||
void Detector::setInjectChannel(const int offsetChannel,
|
||||
const int incrementChannel, Positions pos) {
|
||||
pimpl->Parallel(&Module::setInjectChannel, pos, offsetChannel,
|
||||
incrementChannel);
|
||||
}
|
||||
|
||||
Result<std::vector<int>> Detector::getVetoPhoton(const int chipIndex, Positions pos) {
|
||||
Result<std::vector<int>> Detector::getVetoPhoton(const int chipIndex,
|
||||
Positions pos) {
|
||||
return pimpl->Parallel(&Module::getVetoPhoton, pos, chipIndex);
|
||||
}
|
||||
|
||||
void Detector::setVetoPhoton(const int chipIndex, const int numPhotons, const int energy, const std::string& fname, Positions pos) {
|
||||
pimpl->Parallel(&Module::setVetoPhoton, pos, chipIndex, numPhotons, energy, fname);
|
||||
}
|
||||
void Detector::setVetoPhoton(const int chipIndex, const int numPhotons,
|
||||
const int energy, const std::string &fname,
|
||||
Positions pos) {
|
||||
pimpl->Parallel(&Module::setVetoPhoton, pos, chipIndex, numPhotons, energy,
|
||||
fname);
|
||||
}
|
||||
|
||||
void Detector::setVetoReference(const int gainIndex, const int value, Positions pos) {
|
||||
void Detector::setVetoReference(const int gainIndex, const int value,
|
||||
Positions pos) {
|
||||
pimpl->Parallel(&Module::setVetoReference, pos, gainIndex, value);
|
||||
}
|
||||
}
|
||||
|
||||
Result<defs::burstMode> Detector::getBurstMode(Positions pos) {
|
||||
return pimpl->Parallel(&Module::getBurstMode, pos);
|
||||
@ -1284,10 +1268,8 @@ void Detector::setNumberOfAnalogSamples(int value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setNumberOfAnalogSamples, pos, value);
|
||||
}
|
||||
|
||||
|
||||
Result<int> Detector::getADCClock(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getClockFrequency, pos,
|
||||
defs::ADC_CLOCK);
|
||||
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::ADC_CLOCK);
|
||||
}
|
||||
|
||||
void Detector::setADCClock(int value_in_MHz, Positions pos) {
|
||||
@ -1296,8 +1278,7 @@ void Detector::setADCClock(int value_in_MHz, Positions pos) {
|
||||
}
|
||||
|
||||
Result<int> Detector::getRUNClock(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getClockFrequency, pos,
|
||||
defs::RUN_CLOCK);
|
||||
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::RUN_CLOCK);
|
||||
}
|
||||
|
||||
void Detector::setRUNClock(int value_in_MHz, Positions pos) {
|
||||
@ -1306,8 +1287,7 @@ void Detector::setRUNClock(int value_in_MHz, Positions pos) {
|
||||
}
|
||||
|
||||
Result<int> Detector::getSYNCClock(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getClockFrequency, pos,
|
||||
defs::SYNC_CLOCK);
|
||||
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::SYNC_CLOCK);
|
||||
}
|
||||
|
||||
Result<int> Detector::getADCPipeline(Positions pos) const {
|
||||
@ -1372,7 +1352,6 @@ void Detector::setTenGigaADCEnableMask(uint32_t mask, Positions pos) {
|
||||
|
||||
// CTB Specific
|
||||
|
||||
|
||||
Result<int> Detector::getNumberOfDigitalSamples(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getNumberOfDigitalSamples, pos);
|
||||
}
|
||||
@ -1390,8 +1369,7 @@ void Detector::setReadoutMode(defs::readoutMode value, Positions pos) {
|
||||
}
|
||||
|
||||
Result<int> Detector::getDBITClock(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getClockFrequency, pos,
|
||||
defs::DBIT_CLOCK);
|
||||
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::DBIT_CLOCK);
|
||||
}
|
||||
|
||||
void Detector::setDBITClock(int value_in_MHz, Positions pos) {
|
||||
@ -1461,7 +1439,7 @@ Result<std::vector<int>> Detector::getRxDbitList(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverDbitList, pos);
|
||||
}
|
||||
|
||||
void Detector::setRxDbitList(const std::vector<int>& list, Positions pos) {
|
||||
void Detector::setRxDbitList(const std::vector<int> &list, Positions pos) {
|
||||
pimpl->Parallel(&Module::setReceiverDbitList, pos, list);
|
||||
}
|
||||
|
||||
@ -1507,22 +1485,10 @@ void Detector::savePattern(const std::string &fname) {
|
||||
}
|
||||
// rest of pattern file
|
||||
const std::vector<std::string> commands{
|
||||
"patioctrl",
|
||||
"patclkctrl",
|
||||
"patlimits",
|
||||
"patloop0",
|
||||
"patnloop0",
|
||||
"patloop1",
|
||||
"patnloop1",
|
||||
"patloop2",
|
||||
"patnloop2",
|
||||
"patwait0",
|
||||
"patwaittime0",
|
||||
"patwait1",
|
||||
"patwaittime1",
|
||||
"patwait2",
|
||||
"patwaittime2",
|
||||
"patmask",
|
||||
"patioctrl", "patclkctrl", "patlimits", "patloop0",
|
||||
"patnloop0", "patloop1", "patnloop1", "patloop2",
|
||||
"patnloop2", "patwait0", "patwaittime0", "patwait1",
|
||||
"patwaittime1", "patwait2", "patwaittime2", "patmask",
|
||||
"patsetbit",
|
||||
};
|
||||
for (const auto &cmd : commands)
|
||||
@ -1559,14 +1525,13 @@ void Detector::setPatternWord(int addr, uint64_t word, Positions pos) {
|
||||
|
||||
Result<std::array<int, 2>>
|
||||
Detector::getPatternLoopAddresses(int level, Positions pos) const {
|
||||
return pimpl->Parallel(&Module::setPatternLoopAddresses, pos, level,
|
||||
-1, -1);
|
||||
return pimpl->Parallel(&Module::setPatternLoopAddresses, pos, level, -1,
|
||||
-1);
|
||||
}
|
||||
|
||||
void Detector::setPatternLoopAddresses(int level, int start, int stop,
|
||||
Positions pos) {
|
||||
pimpl->Parallel(&Module::setPatternLoopAddresses, pos, level, start,
|
||||
stop);
|
||||
pimpl->Parallel(&Module::setPatternLoopAddresses, pos, level, start, stop);
|
||||
}
|
||||
|
||||
Result<int> Detector::getPatternLoopCycles(int level, Positions pos) const {
|
||||
@ -1611,12 +1576,13 @@ void Detector::setPatternBitMask(uint64_t mask, Positions pos) {
|
||||
|
||||
// Moench
|
||||
|
||||
Result<std::map<std::string, std::string>> Detector::getAdditionalJsonHeader(Positions pos) const {
|
||||
Result<std::map<std::string, std::string>>
|
||||
Detector::getAdditionalJsonHeader(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getAdditionalJsonHeader, pos);
|
||||
}
|
||||
|
||||
void Detector::setAdditionalJsonHeader(const std::map<std::string, std::string> &jsonHeader,
|
||||
Positions pos) {
|
||||
void Detector::setAdditionalJsonHeader(
|
||||
const std::map<std::string, std::string> &jsonHeader, Positions pos) {
|
||||
pimpl->Parallel(&Module::setAdditionalJsonHeader, pos, jsonHeader);
|
||||
}
|
||||
|
||||
@ -1625,7 +1591,8 @@ Result<std::string> Detector::getAdditionalJsonParameter(const std::string &key,
|
||||
return pimpl->Parallel(&Module::getAdditionalJsonParameter, pos, key);
|
||||
}
|
||||
|
||||
void Detector::setAdditionalJsonParameter(const std::string &key, const std::string &value,
|
||||
void Detector::setAdditionalJsonParameter(const std::string &key,
|
||||
const std::string &value,
|
||||
Positions pos) {
|
||||
pimpl->Parallel(&Module::setAdditionalJsonParameter, pos, key, value);
|
||||
}
|
||||
@ -1654,8 +1621,8 @@ void Detector::setDetectorMinMaxEnergyThreshold(const bool isEmax,
|
||||
}
|
||||
|
||||
Result<defs::frameModeType> Detector::getFrameMode(Positions pos) const {
|
||||
auto res = pimpl->Parallel(&Module::getAdditionalJsonParameter, pos,
|
||||
"frameMode");
|
||||
auto res =
|
||||
pimpl->Parallel(&Module::getAdditionalJsonParameter, pos, "frameMode");
|
||||
Result<defs::frameModeType> intResult(res.size());
|
||||
try {
|
||||
for (unsigned int i = 0; i < res.size(); ++i) {
|
||||
@ -1691,8 +1658,8 @@ Result<defs::detectorModeType> Detector::getDetectorMode(Positions pos) const {
|
||||
}
|
||||
|
||||
void Detector::setDetectorMode(defs::detectorModeType value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setAdditionalJsonParameter, pos,
|
||||
"detectorMode", sls::ToString(value));
|
||||
pimpl->Parallel(&Module::setAdditionalJsonParameter, pos, "detectorMode",
|
||||
sls::ToString(value));
|
||||
}
|
||||
|
||||
// Advanced
|
||||
@ -1753,9 +1720,7 @@ void Detector::writeAdcRegister(uint32_t addr, uint32_t value, Positions pos) {
|
||||
pimpl->Parallel(&Module::writeAdcRegister, pos, addr, value);
|
||||
}
|
||||
|
||||
bool Detector::getInitialChecks() const {
|
||||
return pimpl->getInitialChecks();
|
||||
}
|
||||
bool Detector::getInitialChecks() const { return pimpl->getInitialChecks(); }
|
||||
|
||||
void Detector::setInitialChecks(const bool value) {
|
||||
pimpl->setInitialChecks(value);
|
||||
|
341
slsDetectorSoftware/src/DetectorImpl.cpp
Executable file → Normal file
341
slsDetectorSoftware/src/DetectorImpl.cpp
Executable file → Normal file
@ -1,10 +1,10 @@
|
||||
#include "DetectorImpl.h"
|
||||
#include "Module.h"
|
||||
#include "SharedMemory.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "detectorData.h"
|
||||
#include "file_utils.h"
|
||||
#include "logger.h"
|
||||
#include "Module.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
#include <future>
|
||||
#include <vector>
|
||||
|
||||
namespace sls{
|
||||
namespace sls {
|
||||
|
||||
DetectorImpl::DetectorImpl(int multi_id, bool verify, bool update)
|
||||
: multiId(multi_id), multi_shm(multi_id, -1) {
|
||||
@ -137,11 +137,11 @@ void DetectorImpl::initSharedMemory(bool verify) {
|
||||
multi_shm.OpenSharedMemory();
|
||||
if (verify && multi_shm()->shmversion != MULTI_SHMVERSION) {
|
||||
LOG(logERROR) << "Multi shared memory (" << multiId
|
||||
<< ") version mismatch "
|
||||
"(expected 0x"
|
||||
<< std::hex << MULTI_SHMVERSION << " but got 0x"
|
||||
<< multi_shm()->shmversion << std::dec
|
||||
<< ". Clear Shared memory to continue.";
|
||||
<< ") version mismatch "
|
||||
"(expected 0x"
|
||||
<< std::hex << MULTI_SHMVERSION << " but got 0x"
|
||||
<< multi_shm()->shmversion << std::dec
|
||||
<< ". Clear Shared memory to continue.";
|
||||
throw SharedMemoryError("Shared memory version mismatch!");
|
||||
}
|
||||
}
|
||||
@ -167,8 +167,7 @@ void DetectorImpl::initializeMembers(bool verify) {
|
||||
// get objects from single det shared memory (open)
|
||||
for (int i = 0; i < multi_shm()->numberOfDetectors; i++) {
|
||||
try {
|
||||
detectors.push_back(
|
||||
sls::make_unique<Module>(multiId, i, verify));
|
||||
detectors.push_back(sls::make_unique<Module>(multiId, i, verify));
|
||||
} catch (...) {
|
||||
detectors.clear();
|
||||
throw;
|
||||
@ -233,9 +232,8 @@ void DetectorImpl::setVirtualDetectorServers(const int numdet, const int port) {
|
||||
void DetectorImpl::setHostname(const std::vector<std::string> &name) {
|
||||
// this check is there only to allow the previous detsizechan command
|
||||
if (multi_shm()->numberOfDetectors != 0) {
|
||||
LOG(logWARNING)
|
||||
<< "There are already detector(s) in shared memory."
|
||||
"Freeing Shared memory now.";
|
||||
LOG(logWARNING) << "There are already detector(s) in shared memory."
|
||||
"Freeing Shared memory now.";
|
||||
bool initialChecks = multi_shm()->initialChecks;
|
||||
freeSharedMemory();
|
||||
setupMultiDetector();
|
||||
@ -273,8 +271,7 @@ void DetectorImpl::addSlsDetector(const std::string &hostname) {
|
||||
// get type by connecting
|
||||
detectorType type = Module::getTypeFromDetector(host, port);
|
||||
auto pos = detectors.size();
|
||||
detectors.emplace_back(
|
||||
sls::make_unique<Module>(type, multiId, pos, false));
|
||||
detectors.emplace_back(sls::make_unique<Module>(type, multiId, pos, false));
|
||||
multi_shm()->numberOfDetectors = detectors.size();
|
||||
detectors[pos]->setControlPort(port);
|
||||
detectors[pos]->setStopPort(port + 1);
|
||||
@ -284,7 +281,7 @@ void DetectorImpl::addSlsDetector(const std::string &hostname) {
|
||||
Parallel(&Module::getDetectorType, {})
|
||||
.tsquash("Inconsistent detector types.");
|
||||
// for moench and ctb
|
||||
detectors[pos]->updateNumberOfChannels();
|
||||
detectors[pos]->updateNumberOfChannels();
|
||||
}
|
||||
|
||||
void DetectorImpl::updateDetectorSize() {
|
||||
@ -309,13 +306,13 @@ void DetectorImpl::updateDetectorSize() {
|
||||
multi_shm()->numberOfChannels.y = det_size.y * ndety;
|
||||
|
||||
LOG(logDEBUG) << "\n\tNumber of Detectors in X direction:"
|
||||
<< multi_shm()->numberOfDetector.x
|
||||
<< "\n\tNumber of Detectors in Y direction:"
|
||||
<< multi_shm()->numberOfDetector.y
|
||||
<< "\n\tNumber of Channels in X direction:"
|
||||
<< multi_shm()->numberOfChannels.x
|
||||
<< "\n\tNumber of Channels in Y direction:"
|
||||
<< multi_shm()->numberOfChannels.y;
|
||||
<< multi_shm()->numberOfDetector.x
|
||||
<< "\n\tNumber of Detectors in Y direction:"
|
||||
<< multi_shm()->numberOfDetector.y
|
||||
<< "\n\tNumber of Channels in X direction:"
|
||||
<< multi_shm()->numberOfChannels.x
|
||||
<< "\n\tNumber of Channels in Y direction:"
|
||||
<< multi_shm()->numberOfChannels.y;
|
||||
|
||||
for (auto &d : detectors) {
|
||||
d->updateMultiSize(multi_shm()->numberOfDetector);
|
||||
@ -347,20 +344,20 @@ bool DetectorImpl::getGapPixelsinCallback() const {
|
||||
void DetectorImpl::setGapPixelsinCallback(const bool enable) {
|
||||
if (enable) {
|
||||
switch (multi_shm()->multiDetectorType) {
|
||||
case JUNGFRAU:
|
||||
case JUNGFRAU:
|
||||
break;
|
||||
case EIGER:
|
||||
if (size() && detectors[0]->getQuad()) {
|
||||
break;
|
||||
case EIGER:
|
||||
if (size() && detectors[0]->getQuad()) {
|
||||
break;
|
||||
}
|
||||
if (multi_shm()->numberOfDetector.y % 2 != 0) {
|
||||
throw RuntimeError("Gap pixels can only be used "
|
||||
"for full modules.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Gap Pixels is not implemented for "
|
||||
+ multi_shm()->multiDetectorType);
|
||||
}
|
||||
if (multi_shm()->numberOfDetector.y % 2 != 0) {
|
||||
throw RuntimeError("Gap pixels can only be used "
|
||||
"for full modules.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Gap Pixels is not implemented for " +
|
||||
multi_shm()->multiDetectorType);
|
||||
}
|
||||
}
|
||||
multi_shm()->gapPixels = enable;
|
||||
@ -380,14 +377,13 @@ int DetectorImpl::createReceivingDataSockets(const bool destroy) {
|
||||
return OK;
|
||||
}
|
||||
LOG(logINFO) << "Going to create data sockets";
|
||||
|
||||
|
||||
size_t numSockets = detectors.size();
|
||||
size_t numSocketsPerDetector = 1;
|
||||
if (multi_shm()->multiDetectorType == EIGER) {
|
||||
numSocketsPerDetector = 2;
|
||||
}
|
||||
if (Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash() ==
|
||||
2) {
|
||||
if (Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash() == 2) {
|
||||
numSocketsPerDetector = 2;
|
||||
}
|
||||
numSockets *= numSocketsPerDetector;
|
||||
@ -404,10 +400,9 @@ int DetectorImpl::createReceivingDataSockets(const bool destroy) {
|
||||
.c_str(),
|
||||
portnum));
|
||||
LOG(logINFO) << "Zmq Client[" << iSocket << "] at "
|
||||
<< zmqSocket.back()->GetZmqServerAddress();
|
||||
<< zmqSocket.back()->GetZmqServerAddress();
|
||||
} catch (...) {
|
||||
LOG(logERROR)
|
||||
<< "Could not create Zmq socket on port " << portnum;
|
||||
LOG(logERROR) << "Could not create Zmq socket on port " << portnum;
|
||||
createReceivingDataSockets(true);
|
||||
return FAIL;
|
||||
}
|
||||
@ -429,9 +424,8 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
int nDetPixelsY = 0;
|
||||
bool quadEnable = false;
|
||||
bool eiger = false;
|
||||
bool numInterfaces =
|
||||
Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
||||
.squash(); // cannot pick up from zmq
|
||||
bool numInterfaces = Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
||||
.squash(); // cannot pick up from zmq
|
||||
|
||||
bool runningList[zmqSocket.size()], connectList[zmqSocket.size()];
|
||||
int numRunning = 0;
|
||||
@ -444,7 +438,7 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
// to remember the list it connected to, to disconnect later
|
||||
connectList[i] = false;
|
||||
LOG(logERROR) << "Could not connect to socket "
|
||||
<< zmqSocket[i]->GetZmqServerAddress();
|
||||
<< zmqSocket[i]->GetZmqServerAddress();
|
||||
runningList[i] = false;
|
||||
}
|
||||
}
|
||||
@ -491,8 +485,8 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
{
|
||||
zmqHeader zHeader;
|
||||
if (zmqSocket[isocket]->ReceiveHeader(
|
||||
isocket, zHeader, SLS_DETECTOR_JSON_HEADER_VERSION) ==
|
||||
0) {
|
||||
isocket, zHeader,
|
||||
SLS_DETECTOR_JSON_HEADER_VERSION) == 0) {
|
||||
// parse error, version error or end of acquisition for
|
||||
// socket
|
||||
runningList[isocket] = false;
|
||||
@ -509,7 +503,7 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
multiframe = new char[multisize];
|
||||
memset(multiframe, 0xFF, multisize);
|
||||
// dynamic range
|
||||
dynamicRange = zHeader.dynamicRange;
|
||||
dynamicRange = zHeader.dynamicRange;
|
||||
bytesPerPixel = (float)dynamicRange / 8;
|
||||
// shape
|
||||
nPixelsX = zHeader.npixelsx;
|
||||
@ -522,13 +516,13 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
nDetPixelsY = nY * nPixelsY;
|
||||
// det type
|
||||
eiger = (zHeader.detType == static_cast<int>(3))
|
||||
? true
|
||||
: false; // to be changed to EIGER when firmware
|
||||
// updates its header data
|
||||
? true
|
||||
: false; // to be changed to EIGER when
|
||||
// firmware updates its header data
|
||||
quadEnable = (zHeader.quad == 0) ? false : true;
|
||||
LOG(logDEBUG1)
|
||||
<< "One Time Header Info:"
|
||||
"\n\tsize: "
|
||||
"\n\tsize: "
|
||||
<< size << "\n\tmultisize: " << multisize
|
||||
<< "\n\tdynamicRange: " << dynamicRange
|
||||
<< "\n\tbytesPerPixel: " << bytesPerPixel
|
||||
@ -553,9 +547,9 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
if (zHeader.completeImage == 0) {
|
||||
completeImage = false;
|
||||
}
|
||||
LOG(logDEBUG1)
|
||||
<< "Header Info:"
|
||||
"\n\tcurrentFileName: "
|
||||
LOG(logDEBUG1)
|
||||
<< "Header Info:"
|
||||
"\n\tcurrentFileName: "
|
||||
<< currentFileName << "\n\tcurrentAcquisitionIndex: "
|
||||
<< currentAcquisitionIndex
|
||||
<< "\n\tcurrentFrameIndex: " << currentFrameIndex
|
||||
@ -579,10 +573,10 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
uint32_t rowoffset = nX * singledetrowoffset;
|
||||
if (multi_shm()->multiDetectorType == CHIPTESTBOARD) {
|
||||
singledetrowoffset = size;
|
||||
}
|
||||
}
|
||||
LOG(logDEBUG1)
|
||||
<< "Multi Image Info:"
|
||||
"\n\txoffset: "
|
||||
<< "Multi Image Info:"
|
||||
"\n\txoffset: "
|
||||
<< xoffset << "\n\tyoffset: " << yoffset
|
||||
<< "\n\tsingledetrowoffset: " << singledetrowoffset
|
||||
<< "\n\trowoffset: " << rowoffset;
|
||||
@ -608,33 +602,33 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
}
|
||||
}
|
||||
|
||||
LOG(logDEBUG)<< "Call Back Info:"
|
||||
<< "\n\t nDetPixelsX: " << nDetPixelsX
|
||||
<< "\n\t nDetPixelsY: " << nDetPixelsY
|
||||
<< "\n\t databytes: " << multisize
|
||||
<< "\n\t dynamicRange: " << dynamicRange;
|
||||
LOG(logDEBUG) << "Call Back Info:"
|
||||
<< "\n\t nDetPixelsX: " << nDetPixelsX
|
||||
<< "\n\t nDetPixelsY: " << nDetPixelsY
|
||||
<< "\n\t databytes: " << multisize
|
||||
<< "\n\t dynamicRange: " << dynamicRange;
|
||||
|
||||
// send data to callback
|
||||
if (data) {
|
||||
char* image = multiframe;
|
||||
char *image = multiframe;
|
||||
int imagesize = multisize;
|
||||
|
||||
if (gapPixels) {
|
||||
int n = InsertGapPixels(multiframe, multigappixels,
|
||||
quadEnable, dynamicRange, nDetPixelsX, nDetPixelsY);
|
||||
int n = InsertGapPixels(multiframe, multigappixels, quadEnable,
|
||||
dynamicRange, nDetPixelsX, nDetPixelsY);
|
||||
image = multigappixels;
|
||||
imagesize = n;
|
||||
}
|
||||
LOG(logDEBUG)
|
||||
<< "Image Info:"
|
||||
<< "\n\tnDetPixelsX: " << nDetPixelsX
|
||||
<< "\n\tnDetPixelsY: " << nDetPixelsY
|
||||
<< "\n\timagesize: " << imagesize
|
||||
<< "\n\tdynamicRange: " << dynamicRange;
|
||||
LOG(logDEBUG) << "Image Info:"
|
||||
<< "\n\tnDetPixelsX: " << nDetPixelsX
|
||||
<< "\n\tnDetPixelsY: " << nDetPixelsY
|
||||
<< "\n\timagesize: " << imagesize
|
||||
<< "\n\tdynamicRange: " << dynamicRange;
|
||||
|
||||
thisData = new detectorData(currentProgress,
|
||||
currentFileName, nDetPixelsX, nDetPixelsY, image,
|
||||
imagesize, dynamicRange, currentFileIndex, completeImage);
|
||||
thisData =
|
||||
new detectorData(currentProgress, currentFileName, nDetPixelsX,
|
||||
nDetPixelsY, image, imagesize, dynamicRange,
|
||||
currentFileIndex, completeImage);
|
||||
|
||||
dataReady(
|
||||
thisData, currentFrameIndex,
|
||||
@ -642,7 +636,7 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
pCallbackArg);
|
||||
delete thisData;
|
||||
}
|
||||
|
||||
|
||||
// all done
|
||||
if (numRunning == 0) {
|
||||
// let main thread know that all dummy packets have been received
|
||||
@ -680,117 +674,119 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
delete[] multigappixels;
|
||||
}
|
||||
|
||||
int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
||||
bool quadEnable, int dr, int &nPixelsx, int &nPixelsy) {
|
||||
|
||||
LOG(logDEBUG)<< "Insert Gap pixels:"
|
||||
<< "\n\t nPixelsx: " << nPixelsx
|
||||
<< "\n\t nPixelsy: " << nPixelsy
|
||||
<< "\n\t quadEnable: " << quadEnable
|
||||
<< "\n\t dr: " << dr;
|
||||
int DetectorImpl::InsertGapPixels(char *image, char *&gpImage, bool quadEnable,
|
||||
int dr, int &nPixelsx, int &nPixelsy) {
|
||||
|
||||
LOG(logDEBUG) << "Insert Gap pixels:"
|
||||
<< "\n\t nPixelsx: " << nPixelsx
|
||||
<< "\n\t nPixelsy: " << nPixelsy
|
||||
<< "\n\t quadEnable: " << quadEnable << "\n\t dr: " << dr;
|
||||
|
||||
// inter module gap pixels
|
||||
int modGapPixelsx = 8;
|
||||
int modGapPixelsx = 8;
|
||||
int modGapPixelsy = 36;
|
||||
// inter chip gap pixels
|
||||
int chipGapPixelsx = 2;
|
||||
int chipGapPixelsy = 2;
|
||||
int chipGapPixelsx = 2;
|
||||
int chipGapPixelsy = 2;
|
||||
// number of pixels in a chip
|
||||
int nChipPixelsx = 256;
|
||||
int nChipPixelsy = 256;
|
||||
int nChipPixelsx = 256;
|
||||
int nChipPixelsy = 256;
|
||||
// 1 module
|
||||
// number of chips in a module
|
||||
int nMod1Chipx = 4;
|
||||
int nMod1Chipy = 2;
|
||||
// number of chips in a module
|
||||
int nMod1Chipx = 4;
|
||||
int nMod1Chipy = 2;
|
||||
if (quadEnable) {
|
||||
nMod1Chipx = 2;
|
||||
}
|
||||
// number of pixels in a module
|
||||
int nMod1Pixelsx = nChipPixelsx * nMod1Chipx;
|
||||
int nMod1Pixelsy = nChipPixelsy * nMod1Chipy;
|
||||
int nMod1Pixelsx = nChipPixelsx * nMod1Chipx;
|
||||
int nMod1Pixelsy = nChipPixelsy * nMod1Chipy;
|
||||
// number of gap pixels in a module
|
||||
int nMod1GapPixelsx = (nMod1Chipx - 1) * chipGapPixelsx;
|
||||
int nMod1GapPixelsx = (nMod1Chipx - 1) * chipGapPixelsx;
|
||||
int nMod1GapPixelsy = (nMod1Chipy - 1) * chipGapPixelsy;
|
||||
// total number of modules
|
||||
int nModx = nPixelsx / nMod1Pixelsx;
|
||||
int nMody = nPixelsy / nMod1Pixelsy;
|
||||
int nModx = nPixelsx / nMod1Pixelsx;
|
||||
int nMody = nPixelsy / nMod1Pixelsy;
|
||||
|
||||
// check if not full modules
|
||||
// check if not full modules
|
||||
// (setting gap pixels and then adding half module or disabling quad)
|
||||
if (nPixelsy / nMod1Pixelsy == 0) {
|
||||
LOG(logERROR) << "Gap pixels can only be enabled with full modules. "
|
||||
"Sending dummy data without gap pixels.\n";
|
||||
"Sending dummy data without gap pixels.\n";
|
||||
double bytesPerPixel = (double)dr / 8.00;
|
||||
int imagesize = nPixelsy * nPixelsx * bytesPerPixel;
|
||||
if (gpImage == NULL) {
|
||||
gpImage = new char[imagesize];
|
||||
}
|
||||
memset(gpImage, 0xFF, imagesize);
|
||||
return imagesize;
|
||||
return imagesize;
|
||||
}
|
||||
|
||||
// total number of pixels
|
||||
int nTotx = nPixelsx + (nMod1GapPixelsx * nModx) + (modGapPixelsx * (nModx - 1));
|
||||
int nToty = nPixelsy + (nMod1GapPixelsy * nMody) + (modGapPixelsy * (nMody - 1));
|
||||
int nTotx =
|
||||
nPixelsx + (nMod1GapPixelsx * nModx) + (modGapPixelsx * (nModx - 1));
|
||||
int nToty =
|
||||
nPixelsy + (nMod1GapPixelsy * nMody) + (modGapPixelsy * (nMody - 1));
|
||||
// total number of chips
|
||||
int nChipx = nPixelsx / nChipPixelsx;
|
||||
int nChipy = nPixelsy / nChipPixelsy;
|
||||
int nChipy = nPixelsy / nChipPixelsy;
|
||||
|
||||
double bytesPerPixel = (double)dr / 8.00;
|
||||
int imagesize = nTotx * nToty * bytesPerPixel;
|
||||
|
||||
int nChipBytesx = nChipPixelsx * bytesPerPixel; // 1 chip bytes in x
|
||||
int nChipGapBytesx = chipGapPixelsx * bytesPerPixel; // 2 pixel bytes
|
||||
int nModGapBytesx = modGapPixelsx * bytesPerPixel; // 8 pixel bytes
|
||||
int nChipBytesy = nChipPixelsy * nTotx * bytesPerPixel; // 1 chip bytes in y
|
||||
int nChipGapBytesy = chipGapPixelsy * nTotx * bytesPerPixel; // 2 lines
|
||||
int nModGapBytesy = modGapPixelsy * nTotx * bytesPerPixel; // 36 lines
|
||||
// 4 bit mode, its 1 byte (because for 4 bit mode, we handle 1 byte at a time)
|
||||
int pixel1 = (int)(ceil(bytesPerPixel));
|
||||
int nChipBytesx = nChipPixelsx * bytesPerPixel; // 1 chip bytes in x
|
||||
int nChipGapBytesx = chipGapPixelsx * bytesPerPixel; // 2 pixel bytes
|
||||
int nModGapBytesx = modGapPixelsx * bytesPerPixel; // 8 pixel bytes
|
||||
int nChipBytesy = nChipPixelsy * nTotx * bytesPerPixel; // 1 chip bytes in y
|
||||
int nChipGapBytesy = chipGapPixelsy * nTotx * bytesPerPixel; // 2 lines
|
||||
int nModGapBytesy = modGapPixelsy * nTotx *
|
||||
bytesPerPixel; // 36 lines
|
||||
// 4 bit mode, its 1 byte (because for 4
|
||||
// bit mode, we handle 1 byte at a time)
|
||||
int pixel1 = (int)(ceil(bytesPerPixel));
|
||||
int row1Bytes = nTotx * bytesPerPixel;
|
||||
int nMod1TotPixelsx = nMod1Pixelsx + nMod1GapPixelsx;
|
||||
if (dr == 4) {
|
||||
nMod1TotPixelsx /= 2;
|
||||
}
|
||||
// eiger requires inter chip gap pixels are halved
|
||||
// eiger requires inter chip gap pixels are halved
|
||||
// jungfrau prefers same inter chip gap pixels as the boundary pixels
|
||||
int divisionValue = 2;
|
||||
slsDetectorDefs::detectorType detType = multi_shm()->multiDetectorType;
|
||||
if (detType == JUNGFRAU) {
|
||||
divisionValue = 1;
|
||||
}
|
||||
LOG(logDEBUG)
|
||||
<< "Insert Gap pixels Calculations:\n\t"
|
||||
<< "nPixelsx: " << nPixelsx << "\n\t"
|
||||
<< "nPixelsy: " << nPixelsy << "\n\t"
|
||||
<< "nMod1Pixelsx: " << nMod1Pixelsx << "\n\t"
|
||||
<< "nMod1Pixelsy: " << nMod1Pixelsy << "\n\t"
|
||||
<< "nMod1GapPixelsx: " << nMod1GapPixelsx << "\n\t"
|
||||
<< "nMod1GapPixelsy: " << nMod1GapPixelsy << "\n\t"
|
||||
<< "nChipy: " << nChipy << "\n\t"
|
||||
<< "nChipx: " << nChipx << "\n\t"
|
||||
<< "nModx: " << nModx << "\n\t"
|
||||
<< "nMody: " << nMody << "\n\t"
|
||||
<< "nTotx: " << nTotx << "\n\t"
|
||||
<< "nToty: " << nToty << "\n\t"
|
||||
<< "bytesPerPixel: " << bytesPerPixel << "\n\t"
|
||||
<< "imagesize: " << imagesize << "\n\t"
|
||||
<< "nChipBytesx: " << nChipBytesx << "\n\t"
|
||||
<< "nChipGapBytesx: " << nChipGapBytesx << "\n\t"
|
||||
<< "nModGapBytesx: " << nModGapBytesx << "\n\t"
|
||||
<< "nChipBytesy: " << nChipBytesy << "\n\t"
|
||||
<< "nChipGapBytesy: " << nChipGapBytesy << "\n\t"
|
||||
<< "nModGapBytesy: " << nModGapBytesy << "\n\t"
|
||||
<< "pixel1: " << pixel1 << "\n\t"
|
||||
<< "row1Bytes: " << row1Bytes << "\n\t"
|
||||
<< "nMod1TotPixelsx: " << nMod1TotPixelsx << "\n\t"
|
||||
<< "divisionValue: " << divisionValue << "\n\n";
|
||||
LOG(logDEBUG) << "Insert Gap pixels Calculations:\n\t"
|
||||
<< "nPixelsx: " << nPixelsx << "\n\t"
|
||||
<< "nPixelsy: " << nPixelsy << "\n\t"
|
||||
<< "nMod1Pixelsx: " << nMod1Pixelsx << "\n\t"
|
||||
<< "nMod1Pixelsy: " << nMod1Pixelsy << "\n\t"
|
||||
<< "nMod1GapPixelsx: " << nMod1GapPixelsx << "\n\t"
|
||||
<< "nMod1GapPixelsy: " << nMod1GapPixelsy << "\n\t"
|
||||
<< "nChipy: " << nChipy << "\n\t"
|
||||
<< "nChipx: " << nChipx << "\n\t"
|
||||
<< "nModx: " << nModx << "\n\t"
|
||||
<< "nMody: " << nMody << "\n\t"
|
||||
<< "nTotx: " << nTotx << "\n\t"
|
||||
<< "nToty: " << nToty << "\n\t"
|
||||
<< "bytesPerPixel: " << bytesPerPixel << "\n\t"
|
||||
<< "imagesize: " << imagesize << "\n\t"
|
||||
<< "nChipBytesx: " << nChipBytesx << "\n\t"
|
||||
<< "nChipGapBytesx: " << nChipGapBytesx << "\n\t"
|
||||
<< "nModGapBytesx: " << nModGapBytesx << "\n\t"
|
||||
<< "nChipBytesy: " << nChipBytesy << "\n\t"
|
||||
<< "nChipGapBytesy: " << nChipGapBytesy << "\n\t"
|
||||
<< "nModGapBytesy: " << nModGapBytesy << "\n\t"
|
||||
<< "pixel1: " << pixel1 << "\n\t"
|
||||
<< "row1Bytes: " << row1Bytes << "\n\t"
|
||||
<< "nMod1TotPixelsx: " << nMod1TotPixelsx << "\n\t"
|
||||
<< "divisionValue: " << divisionValue << "\n\n";
|
||||
|
||||
if (gpImage == NULL) {
|
||||
gpImage = new char[imagesize];
|
||||
}
|
||||
memset(gpImage, 0xFF, imagesize);
|
||||
//memcpy(gpImage, image, imagesize);
|
||||
// memcpy(gpImage, image, imagesize);
|
||||
char *src = nullptr;
|
||||
char *dst = nullptr;
|
||||
|
||||
@ -804,13 +800,13 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
||||
// in each row, for every chip
|
||||
for (int iChipx = 0; iChipx < nChipx; ++iChipx) {
|
||||
// copy 1 chip line
|
||||
memcpy(dst, src, nChipBytesx);
|
||||
memcpy(dst, src, nChipBytesx);
|
||||
src += nChipBytesx;
|
||||
dst += nChipBytesx;
|
||||
// skip inter chip gap pixels in x
|
||||
if (((iChipx + 1) % nMod1Chipx) != 0) {
|
||||
dst += nChipGapBytesx;
|
||||
}
|
||||
}
|
||||
// skip inter module gap pixels in x
|
||||
else if (iChipx + 1 != nChipx) {
|
||||
dst += nModGapBytesx;
|
||||
@ -820,17 +816,17 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
||||
// skip inter chip gap pixels in y
|
||||
if (((iChipy + 1) % nMod1Chipy) != 0) {
|
||||
dst += nChipGapBytesy;
|
||||
}
|
||||
}
|
||||
// skip inter module gap pixels in y
|
||||
else if (iChipy + 1 != nChipy) {
|
||||
dst += nModGapBytesy;
|
||||
}
|
||||
}
|
||||
|
||||
// iner chip gap pixel values is half of neighboring one
|
||||
// iner chip gap pixel values is half of neighboring one
|
||||
// (corners becomes divide by 4 automatically after horizontal filling)
|
||||
|
||||
// vertical filling of inter chip gap pixels
|
||||
// vertical filling of inter chip gap pixels
|
||||
dst = gpImage;
|
||||
// for each chip row in y
|
||||
for (int iChipy = 0; iChipy < nChipy; ++iChipy) {
|
||||
@ -858,7 +854,7 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
||||
g2 = ((temp8 >> 4) / 2);
|
||||
(*((uint8_t *)(dst + 1))) = (g2 << 4) + (temp8 & 0x0F);
|
||||
// gap pixels
|
||||
(*((uint8_t *)dst)) = (g1 << 4) + g2;
|
||||
(*((uint8_t *)dst)) = (g1 << 4) + g2;
|
||||
break;
|
||||
case 8:
|
||||
// neighbouring gap pixels to left
|
||||
@ -872,11 +868,13 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
||||
break;
|
||||
case 16:
|
||||
// neighbouring gap pixels to left
|
||||
temp16 = (*((uint16_t *)(dst - pixel1))) / divisionValue;
|
||||
temp16 =
|
||||
(*((uint16_t *)(dst - pixel1))) / divisionValue;
|
||||
(*((uint16_t *)dst)) = temp16;
|
||||
(*((uint16_t *)(dst - pixel1))) = temp16;
|
||||
// neighbouring gap pixels to right
|
||||
temp16 = (*((uint16_t *)(dst + 2 * pixel1))) / divisionValue;
|
||||
temp16 =
|
||||
(*((uint16_t *)(dst + 2 * pixel1))) / divisionValue;
|
||||
(*((uint16_t *)(dst + pixel1))) = temp16;
|
||||
(*((uint16_t *)(dst + 2 * pixel1))) = temp16;
|
||||
break;
|
||||
@ -890,9 +888,9 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
||||
(*((uint32_t *)(dst + pixel1))) = temp32;
|
||||
(*((uint32_t *)(dst + 2 * pixel1))) = temp32;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dst += nChipGapBytesx;
|
||||
}
|
||||
}
|
||||
// skip inter module gap pixels in x
|
||||
else if (iChipx + 1 != nChipx) {
|
||||
dst += nModGapBytesx;
|
||||
@ -902,16 +900,16 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
||||
// skip inter chip gap pixels in y
|
||||
if (((iChipy + 1) % nMod1Chipy) != 0) {
|
||||
dst += nChipGapBytesy;
|
||||
}
|
||||
}
|
||||
// skip inter module gap pixels in y
|
||||
else if (iChipy + 1 != nChipy) {
|
||||
dst += nModGapBytesy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// horizontal filling of inter chip gap pixels
|
||||
// starting at bottom part (1 line below to copy from)
|
||||
src = gpImage + (nChipBytesy - row1Bytes);
|
||||
src = gpImage + (nChipBytesy - row1Bytes);
|
||||
dst = gpImage + nChipBytesy;
|
||||
// for each chip row in y
|
||||
for (int iChipy = 0; iChipy < nChipy; ++iChipy) {
|
||||
@ -945,10 +943,10 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
||||
temp32 = (*((uint32_t *)src)) / 2;
|
||||
(*((uint32_t *)dst)) = temp32;
|
||||
(*((uint32_t *)src)) = temp32;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
// every pixel (but 4 bit mode, every byte)
|
||||
src += pixel1;
|
||||
src += pixel1;
|
||||
dst += pixel1;
|
||||
}
|
||||
// skip inter module gap pixels in x
|
||||
@ -970,11 +968,9 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
||||
|
||||
nPixelsx = nTotx;
|
||||
nPixelsy = nToty;
|
||||
return imagesize;
|
||||
return imagesize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DetectorImpl::enableDataStreamingToClient(int enable) {
|
||||
if (enable >= 0) {
|
||||
// destroy data threads
|
||||
@ -1024,9 +1020,8 @@ int DetectorImpl::acquire() {
|
||||
// receiver/ext process)
|
||||
sem_init(&sem_endRTAcquisition, 1, 0);
|
||||
|
||||
bool receiver =
|
||||
Parallel(&Module::getUseReceiverFlag, {}).squash(false);
|
||||
|
||||
bool receiver = Parallel(&Module::getUseReceiverFlag, {}).squash(false);
|
||||
|
||||
setJoinThreadFlag(false);
|
||||
|
||||
// verify receiver is idle
|
||||
@ -1077,7 +1072,7 @@ int DetectorImpl::acquire() {
|
||||
if (acquisition_finished != nullptr) {
|
||||
int status = Parallel(&Module::getRunStatus, {}).squash(ERROR);
|
||||
auto a = Parallel(&Module::getReceiverProgress, {});
|
||||
int progress = (*std::min_element (a.begin(), a.end()));
|
||||
int progress = (*std::min_element(a.begin(), a.end()));
|
||||
acquisition_finished((double)progress, status, acqFinished_p);
|
||||
}
|
||||
|
||||
@ -1086,9 +1081,9 @@ int DetectorImpl::acquire() {
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
LOG(logDEBUG1) << "Elapsed time for acquisition:"
|
||||
<< ((end.tv_sec - begin.tv_sec) +
|
||||
(end.tv_nsec - begin.tv_nsec) / 1000000000.0)
|
||||
<< " seconds";
|
||||
<< ((end.tv_sec - begin.tv_sec) +
|
||||
(end.tv_nsec - begin.tv_nsec) / 1000000000.0)
|
||||
<< " seconds";
|
||||
} catch (...) {
|
||||
setAcquiringFlag(false);
|
||||
throw;
|
||||
@ -1098,12 +1093,11 @@ int DetectorImpl::acquire() {
|
||||
}
|
||||
|
||||
void DetectorImpl::printProgress(double progress) {
|
||||
std::cout << std::fixed << std::setprecision(2) << std::setw(6)
|
||||
<< progress << " \%";
|
||||
std::cout << std::fixed << std::setprecision(2) << std::setw(6) << progress
|
||||
<< " \%";
|
||||
std::cout << '\r' << std::flush;
|
||||
}
|
||||
|
||||
|
||||
void DetectorImpl::startProcessingThread() {
|
||||
dataProcessingThread = std::thread(&DetectorImpl::processData, this);
|
||||
}
|
||||
@ -1128,7 +1122,9 @@ void DetectorImpl::processData() {
|
||||
}
|
||||
}
|
||||
// get and print progress
|
||||
double temp = (double)Parallel(&Module::getReceiverProgress, {0}).squash();
|
||||
double temp =
|
||||
(double)Parallel(&Module::getReceiverProgress, {0})
|
||||
.squash();
|
||||
if (temp != progress) {
|
||||
printProgress(progress);
|
||||
progress = temp;
|
||||
@ -1137,7 +1133,9 @@ void DetectorImpl::processData() {
|
||||
// exiting loop
|
||||
if (getJoinThreadFlag()) {
|
||||
// print progress one final time before exiting
|
||||
progress = (double)Parallel(&Module::getReceiverProgress, {0}).squash();
|
||||
progress =
|
||||
(double)Parallel(&Module::getReceiverProgress, {0})
|
||||
.squash();
|
||||
printProgress(progress);
|
||||
break;
|
||||
}
|
||||
@ -1297,10 +1295,9 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
||||
"Program FPGA: Could not close destination file after converting");
|
||||
}
|
||||
unlink(destfname); // delete temporary file
|
||||
LOG(logDEBUG1)
|
||||
<< "Successfully loaded the rawbin file to program memory";
|
||||
LOG(logDEBUG1) << "Successfully loaded the rawbin file to program memory";
|
||||
LOG(logINFO) << "Read file into memory";
|
||||
return buffer;
|
||||
}
|
||||
|
||||
}//namespace sls
|
||||
} // namespace sls
|
54
slsDetectorSoftware/src/DetectorImpl.h
Executable file → Normal file
54
slsDetectorSoftware/src/DetectorImpl.h
Executable file → Normal file
@ -22,7 +22,7 @@ class detectorData;
|
||||
#include <future>
|
||||
#include <numeric>
|
||||
|
||||
namespace sls{
|
||||
namespace sls {
|
||||
|
||||
class Module;
|
||||
|
||||
@ -74,7 +74,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
* @param update true to update last user pid, date etc
|
||||
*/
|
||||
explicit DetectorImpl(int multi_id = 0, bool verify = true,
|
||||
bool update = true);
|
||||
bool update = true);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -87,8 +87,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
std::vector<int> positions,
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
if (detectors.size() == 0)
|
||||
throw sls::RuntimeError("No detectors added");
|
||||
if (detectors.size() == 0)
|
||||
throw sls::RuntimeError("No detectors added");
|
||||
if (positions.empty() ||
|
||||
(positions.size() == 1 && positions[0] == -1)) {
|
||||
positions.resize(detectors.size());
|
||||
@ -115,8 +115,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
std::vector<int> positions,
|
||||
typename NonDeduced<CT>::type... Args) const {
|
||||
|
||||
if (detectors.size() == 0)
|
||||
throw sls::RuntimeError("No detectors added");
|
||||
if (detectors.size() == 0)
|
||||
throw sls::RuntimeError("No detectors added");
|
||||
if (positions.empty() ||
|
||||
(positions.size() == 1 && positions[0] == -1)) {
|
||||
positions.resize(detectors.size());
|
||||
@ -143,8 +143,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
std::vector<int> positions,
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
if (detectors.size() == 0)
|
||||
throw sls::RuntimeError("No detectors added");
|
||||
if (detectors.size() == 0)
|
||||
throw sls::RuntimeError("No detectors added");
|
||||
if (positions.empty() ||
|
||||
(positions.size() == 1 && positions[0] == -1)) {
|
||||
positions.resize(detectors.size());
|
||||
@ -168,8 +168,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
std::vector<int> positions,
|
||||
typename NonDeduced<CT>::type... Args) const {
|
||||
|
||||
if (detectors.size() == 0)
|
||||
throw sls::RuntimeError("No detectors added");
|
||||
if (detectors.size() == 0)
|
||||
throw sls::RuntimeError("No detectors added");
|
||||
if (positions.empty() ||
|
||||
(positions.size() == 1 && positions[0] == -1)) {
|
||||
positions.resize(detectors.size());
|
||||
@ -188,21 +188,22 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** set acquiring flag in shared memory */
|
||||
void setAcquiringFlag(bool flag);
|
||||
void setAcquiringFlag(bool flag);
|
||||
|
||||
/** return multi detector shared memory ID */
|
||||
int getMultiId() const;
|
||||
|
||||
/** Free specific shared memory from the command line without creating object */
|
||||
/** Free specific shared memory from the command line without creating
|
||||
* object */
|
||||
static void freeSharedMemory(int multiId, int detPos = -1);
|
||||
|
||||
/** Free all modules from current multi Id shared memory and delete members */
|
||||
void freeSharedMemory();
|
||||
/** Free all modules from current multi Id shared memory and delete members
|
||||
*/
|
||||
void freeSharedMemory();
|
||||
|
||||
/** Get user details of shared memory */
|
||||
std::string getUserDetails();
|
||||
std::string getUserDetails();
|
||||
|
||||
bool getInitialChecks() const;
|
||||
|
||||
@ -217,19 +218,20 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
*/
|
||||
void setVirtualDetectorServers(const int numdet, const int port);
|
||||
|
||||
/** Sets the hostname of all sls detectors in shared memory and updates local cache */
|
||||
void setHostname(const std::vector<std::string> &name);
|
||||
/** Sets the hostname of all sls detectors in shared memory and updates
|
||||
* local cache */
|
||||
void setHostname(const std::vector<std::string> &name);
|
||||
|
||||
/** Gets the total number of detectors */
|
||||
int size() const;
|
||||
|
||||
slsDetectorDefs::xy getNumberOfDetectors() const;
|
||||
slsDetectorDefs::xy getNumberOfDetectors() const;
|
||||
|
||||
slsDetectorDefs::xy getNumberOfChannels() const;
|
||||
slsDetectorDefs::xy getNumberOfChannels() const;
|
||||
|
||||
/** Must be set before setting hostname
|
||||
* Sets maximum number of channels of all sls detectors */
|
||||
void setNumberOfChannels(const slsDetectorDefs::xy c);
|
||||
void setNumberOfChannels(const slsDetectorDefs::xy c);
|
||||
|
||||
/** [Eiger][Jungfrau] */
|
||||
bool getGapPixelsinCallback() const;
|
||||
@ -272,7 +274,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
* index, loops for measurements, calls required call backs.
|
||||
* @returns OK or FAIL depending on if it already started
|
||||
*/
|
||||
int acquire();
|
||||
int acquire();
|
||||
|
||||
/**
|
||||
* Combines data from all readouts and gives it to the gui
|
||||
@ -284,7 +286,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
* Convert raw file
|
||||
* [Jungfrau][Ctb] from pof file
|
||||
* [Mythen3][Gotthard2] from rbf file
|
||||
* @param fname name of pof/rbf file
|
||||
* @param fname name of pof/rbf file
|
||||
* @param fpgasrc pointer in memory to read programming file to
|
||||
* @returns file size
|
||||
*/
|
||||
@ -351,8 +353,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
* @param nPixelsy number of pixels in Y axis (updated)
|
||||
* @returns total data bytes for updated image
|
||||
*/
|
||||
int InsertGapPixels(char *image, char *&gpImage, bool quadEnable, int dr,
|
||||
int &nPixelsx, int &nPixelsy);
|
||||
int InsertGapPixels(char *image, char *&gpImage, bool quadEnable, int dr,
|
||||
int &nPixelsx, int &nPixelsy);
|
||||
|
||||
void printProgress(double progress);
|
||||
|
||||
@ -418,4 +420,4 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
void *pCallbackArg{nullptr};
|
||||
};
|
||||
|
||||
}//namespace sls
|
||||
} // namespace sls
|
1044
slsDetectorSoftware/src/Module.cpp
Executable file → Normal file
1044
slsDetectorSoftware/src/Module.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
133
slsDetectorSoftware/src/Module.h
Executable file → Normal file
133
slsDetectorSoftware/src/Module.h
Executable file → Normal file
@ -8,15 +8,15 @@
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class ServerInterface;
|
||||
|
||||
#define SLS_SHMAPIVERSION 0x190726
|
||||
#define SLS_SHMVERSION 0x200402
|
||||
|
||||
namespace sls{
|
||||
namespace sls {
|
||||
|
||||
/**
|
||||
* @short structure allocated in shared memory to store detector settings for
|
||||
@ -96,7 +96,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
* one
|
||||
*/
|
||||
explicit Module(detectorType type, int multi_id = 0, int det_id = 0,
|
||||
bool verify = true);
|
||||
bool verify = true);
|
||||
|
||||
/**
|
||||
* Constructor called when opening existing shared memory
|
||||
@ -151,7 +151,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
/**
|
||||
* Sets the hostname, if online flag is set connects to update the detector
|
||||
* @param name hostname
|
||||
* @param initialChecks enable or disable initial compatibility checks
|
||||
* @param initialChecks enable or disable initial compatibility checks
|
||||
* and other server start up checks. Enabled by default. Disable only
|
||||
* for advanced users!
|
||||
*/
|
||||
@ -182,7 +182,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
*/
|
||||
void updateNumberOfChannels();
|
||||
|
||||
|
||||
slsDetectorDefs::xy getNumberOfChannels() const;
|
||||
|
||||
/**
|
||||
@ -272,11 +271,12 @@ class Module : public virtual slsDetectorDefs {
|
||||
|
||||
detectorSettings getSettings();
|
||||
|
||||
/** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2
|
||||
* [Gotthard] Options: DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN
|
||||
* [Gotthard2] Options: DYNAMICGAIN, FIXGAIN1, FIXGAIN2
|
||||
* [Moench] Options: G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN,
|
||||
* G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN
|
||||
/** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2,
|
||||
* FORCESWITCHG1, FORCESWITCHG2 [Gotthard] Options: DYNAMICGAIN, HIGHGAIN,
|
||||
* LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN [Gotthard2] Options: DYNAMICGAIN,
|
||||
* FIXGAIN1, FIXGAIN2 [Moench] Options: G1_HIGHGAIN, G1_LOWGAIN,
|
||||
* G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, G2_LOWCAP_HIGHGAIN,
|
||||
* G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN
|
||||
*/
|
||||
void setSettings(detectorSettings isettings);
|
||||
|
||||
@ -294,7 +294,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
* @param tb 1 to include trimbits, 0 to exclude
|
||||
*/
|
||||
void setThresholdEnergy(int e_eV, detectorSettings isettings = GET_SETTINGS,
|
||||
int tb = 1);
|
||||
int tb = 1);
|
||||
|
||||
/**
|
||||
* Set threshold energy and settings (Eiger only)
|
||||
@ -405,7 +405,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
|
||||
/** [Gotthard2] only in burst mode and in auto timing mode */
|
||||
void setNumberOfBursts(int64_t value);
|
||||
|
||||
|
||||
/** [Jungfrau] Advanced */
|
||||
int getNumberOfAdditionalStorageCells();
|
||||
|
||||
@ -442,7 +442,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
int64_t getBurstPeriod();
|
||||
|
||||
/** [Gotthard2] only in burst mode and in auto timing mode */
|
||||
void setBurstPeriod(int64_t value);
|
||||
void setBurstPeriod(int64_t value);
|
||||
|
||||
/** [Eiger] in 32 bit mode */
|
||||
int64_t getSubExptime();
|
||||
@ -463,15 +463,15 @@ class Module : public virtual slsDetectorDefs {
|
||||
* Options: (0-1638375 ns (resolution of 25ns) */
|
||||
void setStorageCellDelay(int64_t value);
|
||||
|
||||
/** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
|
||||
/** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
|
||||
* [Gotthard2] only in continuous mode */
|
||||
int64_t getNumberOfFramesLeft() const;
|
||||
|
||||
/** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
|
||||
/** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
|
||||
* [Gotthard2] only in continuous mode */
|
||||
int64_t getNumberOfTriggersLeft() const;
|
||||
|
||||
/** [Gotthard][Jungfrau][CTB][Moench]
|
||||
/** [Gotthard][Jungfrau][CTB][Moench]
|
||||
* [Gotthard2] only in continuous mode */
|
||||
int64_t getDelayAfterTriggerLeft() const;
|
||||
|
||||
@ -487,19 +487,18 @@ class Module : public virtual slsDetectorDefs {
|
||||
/** [Eiger] */
|
||||
int64_t getMeasuredSubFramePeriod() const;
|
||||
|
||||
/** [Jungfrau][CTB][Moench][Mythen3]
|
||||
/** [Jungfrau][CTB][Moench][Mythen3]
|
||||
* [Gotthard2] only in continuous mode */
|
||||
int64_t getNumberOfFramesFromStart() const;
|
||||
|
||||
/** [Jungfrau][CTB][Moench][Mythen3] Get time from detector start
|
||||
/** [Jungfrau][CTB][Moench][Mythen3] Get time from detector start
|
||||
* [Gotthard2] only in continuous mode */
|
||||
int64_t getActualTime() const;
|
||||
|
||||
/** [Jungfrau][CTB][Moench][Mythen3] Get timestamp at a frame start
|
||||
/** [Jungfrau][CTB][Moench][Mythen3] Get timestamp at a frame start
|
||||
* [Gotthard2] only in continuous mode */
|
||||
int64_t getMeasurementTime() const;
|
||||
|
||||
|
||||
timingMode getTimingMode();
|
||||
void setTimingMode(timingMode value);
|
||||
|
||||
@ -522,9 +521,10 @@ class Module : public virtual slsDetectorDefs {
|
||||
|
||||
/* [Gotthard2] */
|
||||
int getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex);
|
||||
|
||||
|
||||
/* [Gotthard2] */
|
||||
void setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex, int value);
|
||||
void setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex,
|
||||
int value);
|
||||
|
||||
/**
|
||||
* Get adc value
|
||||
@ -560,7 +560,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
* @param enable true if overflow, else false
|
||||
*/
|
||||
void setOverFlowMode(const bool enable);
|
||||
|
||||
|
||||
/**
|
||||
* Get overflow mode in 32 bit mode (Only for Eiger)
|
||||
* @returns overflow mode
|
||||
@ -581,7 +581,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* [Ctb]
|
||||
* @param mode readout mode Options: ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL
|
||||
* @param mode readout mode Options: ANALOG_ONLY, DIGITAL_ONLY,
|
||||
* ANALOG_AND_DIGITAL
|
||||
*/
|
||||
void setReadoutMode(const readoutMode mode);
|
||||
|
||||
@ -634,7 +635,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
*/
|
||||
uint32_t clearBit(uint32_t addr, int n);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Validates and sets the receiver.
|
||||
* Also updates the receiver with all the shared memory parameters
|
||||
* significant for the receiver Also configures the detector to the receiver
|
||||
@ -650,8 +651,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
*/
|
||||
std::string getReceiverHostname() const;
|
||||
|
||||
/**
|
||||
* Validates the format of the detector MAC address and sets it
|
||||
/**
|
||||
* Validates the format of the detector MAC address and sets it
|
||||
* @param mac detector MAC address
|
||||
*/
|
||||
void setSourceUDPMAC(const sls::MacAddr mac);
|
||||
@ -702,14 +703,16 @@ class Module : public virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Validates the format of the receiver UDP IP address and sets it
|
||||
* If slsReceiver used, Gets receiver udp mac address and sends it to the detector
|
||||
* If slsReceiver used, Gets receiver udp mac address and sends it to the
|
||||
* detector
|
||||
* @param ip receiver UDP IP address
|
||||
*/
|
||||
void setDestinationUDPIP(const sls::IpAddr ip);
|
||||
|
||||
/**
|
||||
* Returns the receiver UDP IP address
|
||||
* If slsReceiver used, Gets receiver udp mac address and sends it to the detector
|
||||
* If slsReceiver used, Gets receiver udp mac address and sends it to the
|
||||
* detector
|
||||
* @returns the receiver UDP IP address
|
||||
*/
|
||||
sls::IpAddr getDestinationUDPIP();
|
||||
@ -717,20 +720,22 @@ class Module : public virtual slsDetectorDefs {
|
||||
/**
|
||||
* Validates the format of the receiver UDP IP address (bottom half) and
|
||||
* sets it(Jungfrau only)
|
||||
* If slsReceiver used, Gets receiver udp mac address2 and sends it to the detector
|
||||
* If slsReceiver used, Gets receiver udp mac address2 and sends it to the
|
||||
* detector
|
||||
* @param ip receiver UDP IP address (bottom half)
|
||||
*/
|
||||
void setDestinationUDPIP2(const sls::IpAddr ip);
|
||||
|
||||
/**
|
||||
* Returns the receiver UDP IP address (bottom half) Jungfrau only
|
||||
* If slsReceiver used, Gets receiver udp mac address2 and sends it to the detector
|
||||
* If slsReceiver used, Gets receiver udp mac address2 and sends it to the
|
||||
* detector
|
||||
* @returns the receiver UDP IP address (bottom half)
|
||||
*/
|
||||
sls::IpAddr getDestinationUDPIP2();
|
||||
|
||||
|
||||
/**
|
||||
* Validates the format of the receiver UDP MAC address and sets it
|
||||
* Validates the format of the receiver UDP MAC address and sets it
|
||||
* @param mac receiver UDP MAC address
|
||||
*/
|
||||
void setDestinationUDPMAC(const sls::MacAddr mac);
|
||||
@ -790,7 +795,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
|
||||
/** Returns the number of udp interfaces from shared memory */
|
||||
int getNumberofUDPInterfacesFromShm();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of UDP interfaces to stream data from detector
|
||||
* (Jungfrau only)
|
||||
@ -904,13 +909,15 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setTransmissionDelayRight(int value);
|
||||
|
||||
/** empty vector deletes entire additional json header */
|
||||
void setAdditionalJsonHeader(const std::map<std::string, std::string> &jsonHeader);
|
||||
void setAdditionalJsonHeader(
|
||||
const std::map<std::string, std::string> &jsonHeader);
|
||||
std::map<std::string, std::string> getAdditionalJsonHeader();
|
||||
|
||||
/**
|
||||
* Sets the value for the additional json header parameter key if found, else
|
||||
* append it. If value empty, then deletes parameter */
|
||||
void setAdditionalJsonParameter(const std::string &key, const std::string &value);
|
||||
* Sets the value for the additional json header parameter key if found,
|
||||
* else append it. If value empty, then deletes parameter */
|
||||
void setAdditionalJsonParameter(const std::string &key,
|
||||
const std::string &value);
|
||||
std::string getAdditionalJsonParameter(const std::string &key);
|
||||
|
||||
/**
|
||||
@ -942,16 +949,15 @@ class Module : public virtual slsDetectorDefs {
|
||||
int getImageTestMode();
|
||||
|
||||
/** [Gotthard] If 1, adds channel intensity with precalculated values.
|
||||
* Default is 0
|
||||
* Default is 0
|
||||
* [Eiger virtual] If 1, pixels are saturated. If 0, increasing intensity
|
||||
* Only for virtual servers */
|
||||
void setImageTestMode(const int value);
|
||||
|
||||
|
||||
/** [Gotthard2] */
|
||||
std::array<int, 2> getInjectChannel();
|
||||
|
||||
/** [Gotthard2]
|
||||
/** [Gotthard2]
|
||||
* @param offsetChannel starting channel to be injected
|
||||
* @param incrementChannel determines succeeding channels to be injected */
|
||||
void setInjectChannel(const int offsetChannel, const int incrementChannel);
|
||||
@ -960,9 +966,10 @@ class Module : public virtual slsDetectorDefs {
|
||||
std::vector<int> getVetoPhoton(const int chipIndex);
|
||||
|
||||
/** [Gotthard2] energy in keV */
|
||||
void setVetoPhoton(const int chipIndex, const int numPhotons, const int energy, const std::string& fname);
|
||||
void setVetoPhoton(const int chipIndex, const int numPhotons,
|
||||
const int energy, const std::string &fname);
|
||||
|
||||
void setVetoReference(const int gainIndex, const int value);
|
||||
void setVetoReference(const int gainIndex, const int value);
|
||||
|
||||
/** [Gotthard2] */
|
||||
burstMode getBurstMode();
|
||||
@ -981,7 +988,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
|
||||
/** [Gotthard2] Options: TIMING_INTERNAL, TIMING_EXTERNAL */
|
||||
void setTimingSource(slsDetectorDefs::timingSourceType value);
|
||||
|
||||
|
||||
/**
|
||||
* Set/get counter bit in detector (Gotthard)
|
||||
* @param i is -1 to get, 0 to reset and any other value to set the counter
|
||||
@ -1021,7 +1028,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
*/
|
||||
uint32_t getADCEnableMask();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set 10Gb ADC Enable Mask (CTB, Moench)
|
||||
* @param mask ADC Enable mask
|
||||
*/
|
||||
@ -1031,7 +1038,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
* Get 10Gb ADC Enable Mask (CTB, Moench)
|
||||
* @returns ADC Enable mask
|
||||
*/
|
||||
uint32_t getTenGigaADCEnableMask();
|
||||
uint32_t getTenGigaADCEnableMask();
|
||||
|
||||
/**
|
||||
* Set ADC invert register (CTB, Moench, Jungfrau)
|
||||
@ -1078,7 +1085,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
int getExternalSampling();
|
||||
|
||||
/** digital data bits enable (CTB only) */
|
||||
void setReceiverDbitList(const std::vector<int>& list);
|
||||
void setReceiverDbitList(const std::vector<int> &list);
|
||||
std::vector<int> getReceiverDbitList() const;
|
||||
|
||||
/** Set digital data offset in bytes (CTB only) */
|
||||
@ -1116,7 +1123,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
/**
|
||||
* Sets the enable which determines if
|
||||
* data will be flipped across x axis (Eiger)
|
||||
* @param value 0 or 1 to reset/set
|
||||
* @param value 0 or 1 to reset/set
|
||||
*/
|
||||
void setFlippedDataX(bool value);
|
||||
|
||||
@ -1134,7 +1141,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
* @param vector os trimmed energies
|
||||
* @returns number of trim energies
|
||||
*/
|
||||
int setTrimEn(const std::vector<int>& energies = {});
|
||||
int setTrimEn(const std::vector<int> &energies = {});
|
||||
|
||||
/**
|
||||
* Returns a vector with the trimmed energies (Eiger)
|
||||
@ -1199,12 +1206,12 @@ class Module : public virtual slsDetectorDefs {
|
||||
* @param buffer programming file in memory
|
||||
*/
|
||||
void programFPGA(std::vector<char> buffer);
|
||||
|
||||
|
||||
/** [Jungfau][Ctb] */
|
||||
void programFPGAviaBlackfin(std::vector<char> buffer);
|
||||
void programFPGAviaBlackfin(std::vector<char> buffer);
|
||||
|
||||
/** [Mythen3][Gotthard2] */
|
||||
void programFPGAviaNios(std::vector<char> buffer);
|
||||
void programFPGAviaNios(std::vector<char> buffer);
|
||||
/**
|
||||
* Resets FPGA (Jungfrau)
|
||||
*/
|
||||
@ -1330,7 +1337,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
int64_t getFileIndex();
|
||||
void setFileIndex(int64_t file_index);
|
||||
void incrementFileIndex();
|
||||
fileFormat getFileFormat() ;
|
||||
fileFormat getFileFormat();
|
||||
void setFileFormat(fileFormat f);
|
||||
int getFramesPerFile();
|
||||
/** 0 will set frames per file to unlimited */
|
||||
@ -1340,7 +1347,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
bool getPartialFramesPadding();
|
||||
void setPartialFramesPadding(bool padding);
|
||||
|
||||
|
||||
/**
|
||||
* Receiver starts listening to packets
|
||||
*/
|
||||
@ -1373,7 +1379,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
uint64_t getReceiverCurrentFrameIndex() const;
|
||||
int getReceiverProgress() const;
|
||||
|
||||
|
||||
void setFileWrite(bool value);
|
||||
bool getFileWrite();
|
||||
void setMasterFileWrite(bool value);
|
||||
@ -1468,7 +1473,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
* @returns array of start addr and stop addr
|
||||
*/
|
||||
std::array<int, 2> setPatternLoopAddresses(int level = -1, int start = -1,
|
||||
int stop = -1);
|
||||
int stop = -1);
|
||||
|
||||
/**
|
||||
* Sets the pattern or loop limits (CTB/ Moench/ Mythen3)
|
||||
@ -1478,7 +1483,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
*/
|
||||
int setPatternLoopCycles(int level = -1, int n = -1);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the wait address (CTB/ Moench/ Mythen3)
|
||||
* @param level 0,1,2, wait level
|
||||
@ -1567,7 +1571,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
|
||||
/** [Mythen3] */
|
||||
uint32_t getCounterMask();
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Send function parameters to detector (control server)
|
||||
@ -1581,15 +1585,14 @@ class Module : public virtual slsDetectorDefs {
|
||||
void *retval, size_t retval_size);
|
||||
|
||||
template <typename Arg, typename Ret>
|
||||
void sendToDetector(int fnum, const Arg &args, Ret &retval);
|
||||
void sendToDetector(int fnum, const Arg &args, Ret &retval);
|
||||
template <typename Arg>
|
||||
void sendToDetector(int fnum, const Arg &args, std::nullptr_t);
|
||||
template <typename Ret>
|
||||
void sendToDetector(int fnum, std::nullptr_t, Ret &retval);
|
||||
void sendToDetector(int fnum);
|
||||
|
||||
template <typename Ret>
|
||||
Ret sendToDetector(int fnum);
|
||||
template <typename Ret> Ret sendToDetector(int fnum);
|
||||
|
||||
template <typename Ret, typename Arg>
|
||||
Ret sendToDetector(int fnum, const Arg &args);
|
||||
@ -1662,11 +1665,9 @@ class Module : public virtual slsDetectorDefs {
|
||||
template <typename Ret>
|
||||
void sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const;
|
||||
|
||||
template <typename Ret>
|
||||
Ret sendToReceiver(int fnum);
|
||||
template <typename Ret> Ret sendToReceiver(int fnum);
|
||||
|
||||
template <typename Ret>
|
||||
Ret sendToReceiver(int fnum) const;
|
||||
template <typename Ret> Ret sendToReceiver(int fnum) const;
|
||||
|
||||
template <typename Ret, typename Arg>
|
||||
Ret sendToReceiver(int fnum, const Arg &args);
|
||||
@ -1779,4 +1780,4 @@ class Module : public virtual slsDetectorDefs {
|
||||
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
|
||||
};
|
||||
|
||||
}// sls
|
||||
} // namespace sls
|
112
slsDetectorSoftware/src/SharedMemory.h
Executable file → Normal file
112
slsDetectorSoftware/src/SharedMemory.h
Executable file → Normal file
@ -31,39 +31,37 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
template <typename T>
|
||||
class SharedMemory {
|
||||
template <typename T> class SharedMemory {
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* creates the single/multi detector shared memory name
|
||||
* @param multiId multi detector id
|
||||
* Constructor
|
||||
* creates the single/multi detector shared memory name
|
||||
* @param multiId multi detector id
|
||||
* @param slsId sls detector id, -1 if a multi detector shared memory
|
||||
*/
|
||||
*/
|
||||
SharedMemory(int multiId, int slsId) {
|
||||
name = ConstructSharedMemoryName(multiId, slsId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the copy constructor and copy assignment since we don't want two
|
||||
/**
|
||||
* Delete the copy constructor and copy assignment since we don't want two
|
||||
* objects managing the same resource
|
||||
*/
|
||||
SharedMemory(const SharedMemory &) = delete;
|
||||
SharedMemory &operator=(const SharedMemory &other) = delete;
|
||||
|
||||
//Move constructor
|
||||
SharedMemory(SharedMemory &&other) : name(other.name),
|
||||
fd(other.fd),
|
||||
shmSize(other.shmSize),
|
||||
shared_struct(other.shared_struct) {
|
||||
// Move constructor
|
||||
SharedMemory(SharedMemory &&other)
|
||||
: name(other.name), fd(other.fd), shmSize(other.shmSize),
|
||||
shared_struct(other.shared_struct) {
|
||||
|
||||
other.fd = -1;
|
||||
other.shared_struct = nullptr;
|
||||
other.shmSize = 0;
|
||||
}
|
||||
|
||||
//Move assignment
|
||||
// Move assignment
|
||||
SharedMemory &operator=(SharedMemory &&other) {
|
||||
name = other.name;
|
||||
if (fd) {
|
||||
@ -108,31 +106,31 @@ class SharedMemory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shared memory name
|
||||
*/
|
||||
std::string GetName() const {
|
||||
return name;
|
||||
}
|
||||
* Get shared memory name
|
||||
*/
|
||||
std::string GetName() const { return name; }
|
||||
|
||||
size_t size() const {
|
||||
return shmSize;
|
||||
}
|
||||
size_t size() const { return shmSize; }
|
||||
|
||||
/**
|
||||
* Create Shared memory and call MapSharedMemory to map it to an address
|
||||
* throws a SharedMemoryError exception on failure to create, ftruncate or map
|
||||
* throws a SharedMemoryError exception on failure to create, ftruncate or
|
||||
* map
|
||||
* @param sz of shared memory
|
||||
*/
|
||||
void CreateSharedMemory() {
|
||||
fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR,
|
||||
S_IRUSR | S_IWUSR);
|
||||
if (fd < 0) {
|
||||
std::string msg = "Create shared memory " + name + " failed: " + strerror(errno);
|
||||
std::string msg =
|
||||
"Create shared memory " + name + " failed: " + strerror(errno);
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
|
||||
if (ftruncate(fd, sizeof(T)) < 0) {
|
||||
std::string msg = "Create shared memory " + name + " failed at ftruncate: " + strerror(errno);
|
||||
std::string msg = "Create shared memory " + name +
|
||||
" failed at ftruncate: " + strerror(errno);
|
||||
LOG(logERROR) << msg;
|
||||
close(fd);
|
||||
RemoveSharedMemory();
|
||||
@ -144,14 +142,15 @@ class SharedMemory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Open existing Shared memory and call MapSharedMemory to map it to an address
|
||||
* throws a SharedMemoryError exception on failure to open or map
|
||||
* Open existing Shared memory and call MapSharedMemory to map it to an
|
||||
* address throws a SharedMemoryError exception on failure to open or map
|
||||
* @param sz of shared memory
|
||||
*/
|
||||
void OpenSharedMemory() {
|
||||
fd = shm_open(name.c_str(), O_RDWR, 0);
|
||||
if (fd < 0) {
|
||||
std::string msg = "Open existing shared memory " + name + " failed: " + strerror(errno);
|
||||
std::string msg = "Open existing shared memory " + name +
|
||||
" failed: " + strerror(errno);
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
@ -166,7 +165,8 @@ class SharedMemory {
|
||||
void UnmapSharedMemory() {
|
||||
if (shared_struct != nullptr) {
|
||||
if (munmap(shared_struct, shmSize) < 0) {
|
||||
std::string msg = "Unmapping shared memory " + name + " failed: " + strerror(errno);
|
||||
std::string msg = "Unmapping shared memory " + name +
|
||||
" failed: " + strerror(errno);
|
||||
LOG(logERROR) << msg;
|
||||
close(fd);
|
||||
throw SharedMemoryError(msg);
|
||||
@ -176,15 +176,16 @@ class SharedMemory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove existing Shared memory
|
||||
*/
|
||||
* Remove existing Shared memory
|
||||
*/
|
||||
void RemoveSharedMemory() {
|
||||
UnmapSharedMemory();
|
||||
if (shm_unlink(name.c_str()) < 0) {
|
||||
// silent exit if shm did not exist anyway
|
||||
if (errno == ENOENT)
|
||||
return;
|
||||
std::string msg = "Free Shared Memory " + name + " Failed: " + strerror(errno);
|
||||
std::string msg =
|
||||
"Free Shared Memory " + name + " Failed: " + strerror(errno);
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
@ -197,18 +198,14 @@ class SharedMemory {
|
||||
static const int NAME_MAX_LENGTH = 255;
|
||||
|
||||
/**
|
||||
*Using the call operator to access the pointer
|
||||
*/
|
||||
T *operator()() {
|
||||
return shared_struct;
|
||||
}
|
||||
*Using the call operator to access the pointer
|
||||
*/
|
||||
T *operator()() { return shared_struct; }
|
||||
|
||||
/**
|
||||
*Using the call operator to access the pointer, const overload
|
||||
*/
|
||||
const T *operator()() const {
|
||||
return shared_struct;
|
||||
}
|
||||
*Using the call operator to access the pointer, const overload
|
||||
*/
|
||||
const T *operator()() const { return shared_struct; }
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -232,11 +229,16 @@ class SharedMemory {
|
||||
if (slsId < 0)
|
||||
ss << SHM_MULTI_PREFIX << multiId << sEnvPath;
|
||||
else
|
||||
ss << SHM_MULTI_PREFIX << multiId << SHM_SLS_PREFIX << slsId << sEnvPath;
|
||||
ss << SHM_MULTI_PREFIX << multiId << SHM_SLS_PREFIX << slsId
|
||||
<< sEnvPath;
|
||||
|
||||
std::string temp = ss.str();
|
||||
if (temp.length() > NAME_MAX_LENGTH) {
|
||||
std::string msg = "Shared memory initialization failed. " + temp + " has " + std::to_string(temp.length()) + " characters. \n" + "Maximum is " + std::to_string(NAME_MAX_LENGTH) + ". Change the environment variable " + SHM_ENV_NAME;
|
||||
std::string msg =
|
||||
"Shared memory initialization failed. " + temp + " has " +
|
||||
std::to_string(temp.length()) + " characters. \n" +
|
||||
"Maximum is " + std::to_string(NAME_MAX_LENGTH) +
|
||||
". Change the environment variable " + SHM_ENV_NAME;
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
@ -250,9 +252,11 @@ class SharedMemory {
|
||||
*/
|
||||
|
||||
T *MapSharedMemory() {
|
||||
void *addr = mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
void *addr =
|
||||
mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
std::string msg = "Mapping shared memory " + name + " failed: " + strerror(errno);
|
||||
std::string msg =
|
||||
"Mapping shared memory " + name + " failed: " + strerror(errno);
|
||||
LOG(logERROR) << msg;
|
||||
close(fd);
|
||||
throw SharedMemoryError(msg);
|
||||
@ -264,23 +268,29 @@ class SharedMemory {
|
||||
|
||||
/**
|
||||
* Verify if existing shared memory size matches expected size
|
||||
* @param expectedSize expected size of shared memory, replaced with smaller size if size does not match
|
||||
* @param expectedSize expected size of shared memory, replaced with smaller
|
||||
* size if size does not match
|
||||
* @return 0 for success, 1 for fail
|
||||
*/
|
||||
int VerifySizeMatch(size_t expectedSize) {
|
||||
struct stat sb;
|
||||
// could not fstat
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
std::string msg = "Could not verify existing shared memory " + name + " size match " + "(could not fstat): " + strerror(errno);
|
||||
std::string msg = "Could not verify existing shared memory " +
|
||||
name + " size match " +
|
||||
"(could not fstat): " + strerror(errno);
|
||||
LOG(logERROR) << msg;
|
||||
close(fd);
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
|
||||
//size does not match
|
||||
// size does not match
|
||||
auto sz = static_cast<size_t>(sb.st_size);
|
||||
if (sz != expectedSize) {
|
||||
std::string msg = "Existing shared memory " + name + " size does not match" + "Expected " + std::to_string(expectedSize) + ", found " + std::to_string(sz);
|
||||
std::string msg = "Existing shared memory " + name +
|
||||
" size does not match" + "Expected " +
|
||||
std::to_string(expectedSize) + ", found " +
|
||||
std::to_string(sz);
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
return 1;
|
||||
|
111
slsDetectorSoftware/src/slsDetectorUsers.cpp
Executable file → Normal file
111
slsDetectorSoftware/src/slsDetectorUsers.cpp
Executable file → Normal file
@ -1,18 +1,18 @@
|
||||
#include "slsDetectorUsers.h"
|
||||
//#include "detectorData.h"
|
||||
//#include "multiSlsDetectorClient.h" TODO: do we need this put and get in users api
|
||||
//#include "multiSlsDetectorClient.h" TODO: do we need this put and get in users
|
||||
// api
|
||||
#include "Detector.h"
|
||||
|
||||
slsDetectorUsers::slsDetectorUsers(int shm_id) : detector(sls::make_unique<sls::Detector>(shm_id)){}
|
||||
slsDetectorUsers::slsDetectorUsers(int shm_id)
|
||||
: detector(sls::make_unique<sls::Detector>(shm_id)) {}
|
||||
slsDetectorUsers::~slsDetectorUsers() = default;
|
||||
|
||||
void slsDetectorUsers::readConfigurationFile(const std::string& fname){
|
||||
detector->loadConfig(fname);
|
||||
void slsDetectorUsers::readConfigurationFile(const std::string &fname) {
|
||||
detector->loadConfig(fname);
|
||||
}
|
||||
|
||||
int slsDetectorUsers::size() const {
|
||||
return detector->size();
|
||||
}
|
||||
int slsDetectorUsers::size() const { return detector->size(); }
|
||||
|
||||
// int slsDetectorUsers::getDetectorSize(int &nx, int &ny, int detPos){
|
||||
// slsDetectorDefs::xy res = detector.getNumberOfChannels();
|
||||
@ -38,7 +38,8 @@ int slsDetectorUsers::size() const {
|
||||
// }
|
||||
|
||||
// int64_t slsDetectorUsers::getDetectorFirmwareVersion(int detPos){
|
||||
// return detector.getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION, detPos);
|
||||
// return detector.getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION,
|
||||
// detPos);
|
||||
// }
|
||||
|
||||
// int64_t slsDetectorUsers::getDetectorSerialNumber(int detPos){
|
||||
@ -46,7 +47,8 @@ int slsDetectorUsers::size() const {
|
||||
// }
|
||||
|
||||
// int64_t slsDetectorUsers::getDetectorSoftwareVersion(int detPos){
|
||||
// return detector.getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, detPos);
|
||||
// return detector.getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION,
|
||||
// detPos);
|
||||
// }
|
||||
|
||||
// int64_t slsDetectorUsers::getClientSoftwareVersion(){
|
||||
@ -103,37 +105,40 @@ int slsDetectorUsers::size() const {
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::setSettings(int isettings, int detPos){
|
||||
// return detector.setSettings((slsDetectorDefs::detectorSettings)isettings, detPos);
|
||||
// return
|
||||
// detector.setSettings((slsDetectorDefs::detectorSettings)isettings, detPos);
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::getThresholdEnergy(int detPos){
|
||||
// return detector.getThresholdEnergy(detPos);
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::setThresholdEnergy(int e_ev, int tb, int isettings, int detPos) {
|
||||
// return detector.setThresholdEnergy(e_ev,
|
||||
// (isettings == -1) ? slsDetectorDefs::GET_SETTINGS : (slsDetectorDefs::detectorSettings)isettings,
|
||||
// tb, detPos);
|
||||
// }
|
||||
|
||||
// double slsDetectorUsers::setExposureTime(double t, bool inseconds, int detPos){
|
||||
// return detector.setExposureTime(t, inseconds, detPos);
|
||||
// int slsDetectorUsers::setThresholdEnergy(int e_ev, int tb, int isettings, int
|
||||
// detPos) { return detector.setThresholdEnergy(e_ev,
|
||||
// (isettings == -1) ? slsDetectorDefs::GET_SETTINGS :
|
||||
// (slsDetectorDefs::detectorSettings)isettings, tb, detPos);
|
||||
// }
|
||||
|
||||
// double slsDetectorUsers::setExposurePeriod(double t, bool inseconds, int detPos){
|
||||
// return detector.setExposurePeriod(t, inseconds, detPos);
|
||||
// double slsDetectorUsers::setExposureTime(double t, bool inseconds, int
|
||||
// detPos){ return detector.setExposureTime(t, inseconds, detPos);
|
||||
// }
|
||||
|
||||
// double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds, int detPos){
|
||||
// return detector.setDelayAfterTrigger(t, inseconds, detPos);
|
||||
// double slsDetectorUsers::setExposurePeriod(double t, bool inseconds, int
|
||||
// detPos){ return detector.setExposurePeriod(t, inseconds, detPos);
|
||||
// }
|
||||
|
||||
// double slsDetectorUsers::setSubFrameExposureTime(double t, bool inseconds, int detPos){
|
||||
// return detector.setSubFrameExposureTime(t, inseconds, detPos);
|
||||
// double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds, int
|
||||
// detPos){ return detector.setDelayAfterTrigger(t, inseconds, detPos);
|
||||
// }
|
||||
|
||||
// double slsDetectorUsers::setSubFrameExposureDeadTime(double t, bool inseconds, int detPos){
|
||||
// return detector.setSubFrameExposureDeadTime(t, inseconds, detPos);
|
||||
// double slsDetectorUsers::setSubFrameExposureTime(double t, bool inseconds,
|
||||
// int detPos){ return detector.setSubFrameExposureTime(t, inseconds,
|
||||
// detPos);
|
||||
// }
|
||||
|
||||
// double slsDetectorUsers::setSubFrameExposureDeadTime(double t, bool
|
||||
// inseconds, int detPos){ return detector.setSubFrameExposureDeadTime(t,
|
||||
// inseconds, detPos);
|
||||
// }
|
||||
|
||||
// int64_t slsDetectorUsers::setNumberOfFrames(int64_t t, int detPos){
|
||||
@ -152,8 +157,8 @@ int slsDetectorUsers::size() const {
|
||||
// return detector.getMeasuredPeriod(inseconds, detPos);
|
||||
// }
|
||||
|
||||
// double slsDetectorUsers::getMeasuredSubFramePeriod(bool inseconds, int detPos) {
|
||||
// return detector.getMeasuredSubFramePeriod(inseconds, detPos);
|
||||
// double slsDetectorUsers::getMeasuredSubFramePeriod(bool inseconds, int
|
||||
// detPos) { return detector.getMeasuredSubFramePeriod(inseconds, detPos);
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::setTimingMode(int pol, int detPos){
|
||||
@ -179,7 +184,7 @@ int slsDetectorUsers::size() const {
|
||||
// auto res = detector.getOverFlowMode({detPos});
|
||||
// if (res.equal())
|
||||
// return res.front();*/
|
||||
// return -1;
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::setAllTrimbits(int val, int detPos) {
|
||||
@ -187,7 +192,8 @@ int slsDetectorUsers::size() const {
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::setDAC(int val, int index , int detPos) {
|
||||
// return detector.setDAC(val, slsDetectorDefs::dacIndex(index), 0, detPos);
|
||||
// return detector.setDAC(val, slsDetectorDefs::dacIndex(index), 0,
|
||||
// detPos);
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::getADC(int index, int detPos) {
|
||||
@ -224,7 +230,6 @@ int slsDetectorUsers::size() const {
|
||||
|
||||
// *********************************************************************/
|
||||
|
||||
|
||||
// void slsDetectorUsers::startReceiver(int detPos) {
|
||||
// detector.startReceiver(detPos);
|
||||
// }
|
||||
@ -274,7 +279,7 @@ int slsDetectorUsers::size() const {
|
||||
// return detector.setFileWrite(enable, detPos);
|
||||
// else
|
||||
// return detector.getFileWrite(detPos);
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::enableOverwriteFile(int enable, int detPos) {
|
||||
@ -314,16 +319,16 @@ int slsDetectorUsers::size() const {
|
||||
// return detector.getClientStreamingPort(detPos);
|
||||
// }
|
||||
|
||||
// std::string slsDetectorUsers::setReceiverDataStreamingOutIP(const std::string& ip, int detPos){
|
||||
// if (ip.length()) {
|
||||
// std::string slsDetectorUsers::setReceiverDataStreamingOutIP(const
|
||||
// std::string& ip, int detPos){ if (ip.length()) {
|
||||
// detector.setReceiverDataStreamingOutIP(ip, detPos);
|
||||
// }
|
||||
// return detector.getReceiverStreamingIP(detPos);
|
||||
// }
|
||||
|
||||
// std::string slsDetectorUsers::setClientDataStreamingInIP(const std::string& ip, int detPos){
|
||||
// if (ip.length()) {
|
||||
// detector.setClientDataStreamingInIP(ip, detPos);
|
||||
// std::string slsDetectorUsers::setClientDataStreamingInIP(const std::string&
|
||||
// ip, int detPos){ if (ip.length()) {
|
||||
// detector.setClientDataStreamingInIP(ip, detPos);
|
||||
// }
|
||||
// return detector.getClientStreamingIP(detPos);
|
||||
// }
|
||||
@ -333,7 +338,9 @@ int slsDetectorUsers::size() const {
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::setReceiverFramesDiscardPolicy(int f, int detPos) {
|
||||
// return detector.setReceiverFramesDiscardPolicy(slsDetectorDefs::frameDiscardPolicy(f), detPos);
|
||||
// return
|
||||
// detector.setReceiverFramesDiscardPolicy(slsDetectorDefs::frameDiscardPolicy(f),
|
||||
// detPos);
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::setReceiverPartialFramesPadding(int f, int detPos) {
|
||||
@ -352,45 +359,37 @@ int slsDetectorUsers::size() const {
|
||||
// }
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::setDetectorMinMaxEnergyThreshold(const int index, int v, int detPos) {
|
||||
// int slsDetectorUsers::setDetectorMinMaxEnergyThreshold(const int index, int
|
||||
// v, int detPos) {
|
||||
// return detector.setDetectorMinMaxEnergyThreshold(index, v, detPos);
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::setFrameMode(int value, int detPos) {
|
||||
// return detector.setFrameMode(slsDetectorDefs::frameModeType(value), detPos);
|
||||
// return detector.setFrameMode(slsDetectorDefs::frameModeType(value),
|
||||
// detPos);
|
||||
// }
|
||||
|
||||
// int slsDetectorUsers::setDetectorMode(int value, int detPos) {
|
||||
// return detector.setDetectorMode(slsDetectorDefs::detectorModeType(value), detPos);
|
||||
// return detector.setDetectorMode(slsDetectorDefs::detectorModeType(value),
|
||||
// detPos);
|
||||
// }
|
||||
|
||||
|
||||
// /************************************************************************
|
||||
|
||||
// CALLBACKS & COMMAND LINE PARSING
|
||||
|
||||
// *********************************************************************/
|
||||
|
||||
// void slsDetectorUsers::registerDataCallback(void( *userCallback)(detectorData*, uint64_t, uint32_t, void*), void *pArg) {
|
||||
// void slsDetectorUsers::registerDataCallback(void(
|
||||
// *userCallback)(detectorData*, uint64_t, uint32_t, void*), void *pArg) {
|
||||
// detector.registerDataCallback(userCallback,pArg);
|
||||
// }
|
||||
|
||||
// void slsDetectorUsers::registerAcquisitionFinishedCallback(void( *func)(double,int, void*), void *pArg) {
|
||||
// void slsDetectorUsers::registerAcquisitionFinishedCallback(void(
|
||||
// *func)(double,int, void*), void *pArg) {
|
||||
// detector.registerAcquisitionFinishedCallback(func,pArg);
|
||||
// }
|
||||
|
||||
// void slsDetectorUsers::putCommand(const std::string& command){
|
||||
// multiSlsDetectorClient(command, slsDetectorDefs::PUT_ACTION, &detector);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user