mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
Commandline (#66)
* WIP * WIP * removed status to string from defs * WIP * WIP * WIP removed unused functions in multi * WIP * print hex in a terrible way * WIP, loadconfig error * WIP, type to string * WIP * fix to conversion * WIP, hostname doesnt work * WIP * WIP * WIP * WIP, threshold * WIP, threshold * WIP * WIP, triggers * WIP, cycles to triggers * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * rx_udsocksize fx, WIP * WIP * WIP * WIP * file index (64 bit), WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * merge * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * New python mod
This commit is contained in:
@ -1,54 +1,22 @@
|
||||
#include "CmdProxy.h"
|
||||
|
||||
|
||||
#include "TimeHelper.h"
|
||||
#include "ToString.h"
|
||||
#include "logger.h"
|
||||
#include "slsDetectorCommand.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "ToString.h"
|
||||
#include "TimeHelper.h"
|
||||
#include "container_utils.h"
|
||||
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#define TIME_COMMAND(GETFCN, SETFCN, HLPSTR) \
|
||||
std::ostringstream os; \
|
||||
os << cmd << ' '; \
|
||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||
os << HLPSTR << '\n'; \
|
||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||
auto t = det->GETFCN({det_id}); \
|
||||
if (args.size() == 0) { \
|
||||
os << OutString(t) << '\n'; \
|
||||
} else if (args.size() == 1) { \
|
||||
os << OutString(t, args[0]) << '\n'; \
|
||||
} else { \
|
||||
WrongNumberOfParameters(2); \
|
||||
} \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() == 1) { \
|
||||
std::string time_str(args[0]); \
|
||||
std::string unit = RemoveUnit(time_str); \
|
||||
auto t = StringTo<time::ns>(time_str, unit); \
|
||||
det->SETFCN(t, {det_id}); \
|
||||
} else if (args.size() == 2) { \
|
||||
auto t = StringTo<time::ns>(args[0], args[1]); \
|
||||
det->SETFCN(t, {det_id}); \
|
||||
} else { \
|
||||
WrongNumberOfParameters(2); \
|
||||
} \
|
||||
os << args << '\n'; \
|
||||
} else { \
|
||||
throw sls::RuntimeError("Unknown action"); \
|
||||
} \
|
||||
return os.str();
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
namespace sls {
|
||||
|
||||
using defs = slsDetectorDefs;
|
||||
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const std::vector<std::string> &vec) {
|
||||
if (!vec.empty()) {
|
||||
@ -121,26 +89,8 @@ void CmdProxy::WrongNumberOfParameters(size_t expected) {
|
||||
* *
|
||||
************************************************/
|
||||
|
||||
std::string CmdProxy::Period(int action) {
|
||||
TIME_COMMAND(getPeriod, setPeriod,
|
||||
"[duration] [(optional unit) ns|us|ms|s]\n\tSet the period");
|
||||
}
|
||||
std::string CmdProxy::Exptime(int action) {
|
||||
TIME_COMMAND(
|
||||
getExptime, setExptime,
|
||||
"[duration] [(optional unit) ns|us|ms|s]\n\tSet the exposure time");
|
||||
}
|
||||
std::string CmdProxy::SubExptime(int action) {
|
||||
TIME_COMMAND(getSubExptime, setSubExptime,
|
||||
"[duration] [(optional unit) ns|us|ms|s]\n\tSet the "
|
||||
"exposure time of EIGER subframes");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
std::string CmdProxy::ListCommands(int action) {
|
||||
if (action == slsDetectorDefs::HELP_ACTION)
|
||||
if (action == defs::HELP_ACTION)
|
||||
return "list\n\tlists all available commands, list deprecated - "
|
||||
"list deprecated commands\n";
|
||||
|
||||
@ -181,7 +131,243 @@ std::string CmdProxy::ListCommands(int action) {
|
||||
}
|
||||
}
|
||||
|
||||
/* configuration */
|
||||
|
||||
std::string CmdProxy::Hostname(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "\n\tFrees shared memory and sets hostname (or IP address) of all modules concatenated by +." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getHostname({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() < 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot execute this at module level");
|
||||
}
|
||||
// only args[0], but many hostames concatenated with +
|
||||
if (args[0].find('+') != std::string::npos) {
|
||||
auto t = sls::split(args[0], '+');
|
||||
det->setHostname(t);
|
||||
os << ToString(t) << '\n';
|
||||
}
|
||||
// either hostnames separated by space, or single hostname
|
||||
else {
|
||||
det->setHostname(args);
|
||||
os << ToString(args) << '\n';
|
||||
}
|
||||
auto t = det->getHostname({det_id});
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::FirmwareVersion(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "\n\tFimware version of detector in format [0xYYMMDD] or integer for Eiger." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getFirmwareVersion({det_id});
|
||||
if (det->getDetectorType().squash() == defs::EIGER) {
|
||||
os << OutString(t) << '\n';
|
||||
} else {
|
||||
os << OutStringHex(t) << '\n';
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("cannot put");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::Versions(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "\n\tPrint all versions and detector type" << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getFirmwareVersion();
|
||||
os << "\nDetector Type: " << OutString(det->getDetectorType())
|
||||
<< "\nPackage Version: " << det->getPackageVersion()
|
||||
<< std::hex
|
||||
<< "\nClient Version: 0x" << det->getClientVersion();
|
||||
if (det->getDetectorType().squash() == defs::EIGER) {
|
||||
os << "\nFirmware Version: " << OutString(t);
|
||||
} else {
|
||||
os << "\nFirmware Version: " << OutStringHex(t);
|
||||
}
|
||||
os << "\nDetector Server Version: " << OutStringHex(det->getDetectorServerVersion());
|
||||
if (det->getUseReceiverFlag().squash(true)) {
|
||||
os << "\nReceiver Version: " << OutStringHex(det->getReceiverVersion());
|
||||
}
|
||||
os << std::dec << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("cannot put");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::PackageVersion(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "\n\tPackage version (git branch)." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
os << det->getPackageVersion() << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("cannot put");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::ClientVersion(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "\n\tClient software version in format [0xYYMMDD]." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
os << ToStringHex(det->getClientVersion()) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("cannot put");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::DetectorSize(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[nx] [ny]\n\tDetector size, ie. Number of channels in x and y dim. If 0, then hostname adds all modules in y dim. This is used to calculate module coordinates included in UDP data packet header." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getDetectorSize();
|
||||
os << "[" << t.x << "," << t.y << "]\n";
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
defs::xy t;
|
||||
t.x = std::stoi(args[0]);
|
||||
t.y = std::stoi(args[1]);
|
||||
det->setDetectorSize(t);
|
||||
os << ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
/* acquisition parameters */
|
||||
|
||||
std::string CmdProxy::Speed(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[0 or full_speed|1 or half_speed|2 or quarter_speed]\n\t[Eiger][Jungfrau] Readout speed of chip.\n\tJungfrau also overwrites adcphase to recommended default. " << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getSpeed({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
defs::speedLevel t;
|
||||
try{
|
||||
int ival = std::stoi(args[0]);
|
||||
switch (ival) {
|
||||
case 0:
|
||||
t = defs::FULL_SPEED;
|
||||
break;
|
||||
case 1:
|
||||
t = defs::HALF_SPEED;
|
||||
break;
|
||||
case 2:
|
||||
t = defs::QUARTER_SPEED;
|
||||
break;
|
||||
default:
|
||||
throw sls::RuntimeError("Unknown speed " + args[0]);
|
||||
}
|
||||
} catch (...) {
|
||||
t = sls::StringTo<defs::speedLevel>(args[0]);
|
||||
}
|
||||
det->setSpeed(t, {det_id});
|
||||
os << sls::ToString(t) << '\n'; // no args to convert 0,1,2 as well
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
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][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] 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 if (action == defs::GET_ACTION) {
|
||||
Result<int> t;
|
||||
if (args.size() == 0) {
|
||||
t = det->getADCPhase({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (args.size() == 1) {
|
||||
if (args[0] != "deg") {
|
||||
throw sls::RuntimeError("Unknown adcphase argument " + args[0] + ". Did you mean deg?");
|
||||
}
|
||||
t = det->getADCPhaseInDegrees({det_id});
|
||||
os << OutString(t) << " deg\n";
|
||||
} else {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setADCPhase(std::stoi(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(std::stoi(args[0]), {det_id});
|
||||
os << args[0] << args[1] << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::ClockFrequency(int action) {
|
||||
std::ostringstream os;
|
||||
@ -199,7 +385,6 @@ std::string CmdProxy::ClockFrequency(int action) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setClockFrequency(std::stoi(args[0]), std::stoi(args[1]));
|
||||
//TODO print args
|
||||
os << std::stoi(args[1]) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -280,11 +465,593 @@ std::string CmdProxy::ClockDivider(int action) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setClockDivider(std::stoi(args[0]), std::stoi(args[1]));
|
||||
//TODO print args
|
||||
os << std::stoi(args[1]) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* acquisition */
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
/* Receiver Config */
|
||||
/* File */
|
||||
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
||||
/* Eiger Specific */
|
||||
|
||||
std::string CmdProxy::DynamicRange(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[4|8|16|32]\n\t[Eiger] Dynamic Range or number of bits per pixel in detector." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getDynamicRange({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot execute dynamic range at module level");
|
||||
}
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setDynamicRange(std::stoi(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::Threshold(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[eV] [(optinal settings) standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2]\n\t[Eiger] Threshold in eV" << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getThresholdEnergy();
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setThresholdEnergy(std::stoi(args[0]), slsDetectorDefs::GET_SETTINGS, true, {det_id});
|
||||
} else if (args.size() == 2) {
|
||||
det->setThresholdEnergy(std::stoi(args[0]), sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]), true, {det_id});
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
os << ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::ThresholdNoTb(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[eV] [(optional settings) standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2]\n\t[Eiger] Threshold in eV set without setting trimbits" << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setThresholdEnergy(std::stoi(args[0]), slsDetectorDefs::GET_SETTINGS, false, {det_id});
|
||||
} else if (args.size() == 2) {
|
||||
det->setThresholdEnergy(std::stoi(args[0]), sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]), false, {det_id});
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
os << ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::GapPixels(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[0, 1]\n\t[Eiger] Include Gap pixels in data file or data call back. 4 bit mode gap pixels only ind ata call back." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getRxAddGapPixels({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot execute dynamic range at module level");
|
||||
}
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setRxAddGapPixels(std::stoi(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::TrimEnergies(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[trim_ev1] [trim_Ev2 (optional)] [trim_ev3 (optional)] ...\n\t[Eiger] Number of trim energies and list of trim energies, where corresponding default trim files exist in corresponding trim folders." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getTrimEnergies({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() < 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
unsigned int ntrim = args.size();
|
||||
std::vector<int> t(ntrim);
|
||||
for (unsigned int i = 0; i < ntrim; ++i) {
|
||||
t[i] = std::stoi(args[i]);
|
||||
}
|
||||
det->setTrimEnergies(t, {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::RateCorrection(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_rate (in ns)]\n\t[Eiger] Dead time correction constant in ns. -1 will set to default tau of settings. 0 will unset rate correction." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getRateCorrection({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
int tau = std::stoi(args[0]);
|
||||
if (tau == -1) {
|
||||
det->setDefaultRateCorrection({det_id});
|
||||
auto t = det->getRateCorrection({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else {
|
||||
auto t = StringTo<time::ns>(args[0], "ns");
|
||||
det->setRateCorrection(t, {det_id});
|
||||
os << args.front() << "ns\n";
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::Activate(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[0, 1] [(optional) padding|nopadding]\n\t[Eiger] 1 is default. 0 deactivates readout and does not send data. \n\tPadding will pad data files for deactivates readouts." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getActive({det_id});
|
||||
auto p = det->getRxPadDeactivatedMode({det_id});
|
||||
Result<std::string> pResult(p.size());
|
||||
for (unsigned int i = 0; i < p.size(); ++i) {
|
||||
pResult[i] = p[i] ? "padding" : "nopadding";
|
||||
}
|
||||
os << OutString(t) << ' ' << OutString(pResult) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() < 1 || args.size() > 2 ) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
int t = std::stoi(args[0]);
|
||||
det->setActive(t, {det_id});
|
||||
os << args[0];
|
||||
if (args.size() == 2) {
|
||||
bool p = true;
|
||||
if (args[1] == "nopadding") {
|
||||
p = false;
|
||||
} else if (args[1] != "padding") {
|
||||
throw sls::RuntimeError("Unknown argument for deactivated padding.");
|
||||
}
|
||||
det->setRxPadDeactivatedMode(p, {det_id});
|
||||
os << ' ' << args[1];
|
||||
}
|
||||
os << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::PulsePixel(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_times] [x] [y]\n\t[Eiger] Pulse pixel n number of times at coordinates (x, y)." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 3) {
|
||||
WrongNumberOfParameters(3);
|
||||
}
|
||||
int n = std::stoi(args[0]);
|
||||
defs::xy c;
|
||||
c.x = std::stoi(args[1]);
|
||||
c.y = std::stoi(args[2]);
|
||||
det->pulsePixel(n, c, {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::PulsePixelAndMove(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_times] [x] [y]\n\t[Eiger] Pulse pixel n number of times and moves relatively by (x, y)." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 3) {
|
||||
WrongNumberOfParameters(3);
|
||||
}
|
||||
int n = std::stoi(args[0]);
|
||||
defs::xy c;
|
||||
c.x = std::stoi(args[1]);
|
||||
c.y = std::stoi(args[2]);
|
||||
det->pulsePixelNMove(n, c, {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::PulseChip(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_times] \n\t[Eiger] Pulse chip n times. If n is -1, resets to normal mode (reset chip completely at start of acquisition, where partialreset = 0)." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->pulseChip(std::stoi(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::Quad(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[0, 1]\n\t[Eiger] 0 is default. 1 sets detector size to a quad (Specific hardware required)." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getQuad({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot execute dynamic range at module level");
|
||||
}
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setQuad(std::stoi(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
/* Jungfrau Specific */
|
||||
|
||||
std::string CmdProxy::TemperatureEvent(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[0]\n\t[Jungfrau] 1, if a temperature event occured. To clear this event, set it to 0.\n\tIf temperature crosses threshold temperature and temperature control is enabled, power to chip will be switched off and temperature event occurs. To power on chip again, temperature has to be less than threshold temperature and temperature event has to be cleared." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getTemperatureEvent({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (std::stoi(args[1]) != 0) {
|
||||
throw sls::RuntimeError("Unknown argument for temp event. Did you mean 0 to reset event?");
|
||||
}
|
||||
det->resetTemperatureEvent();
|
||||
os << "cleared" << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
/* Gotthard Specific */
|
||||
|
||||
std::string CmdProxy::ROI(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[xmin] [xmax] \n\t[Gotthard] Region of interest in detector. Either all channels or a single adc or 2 chips (256 channels). Default is all channels enabled (-1 -1). " << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getROI({det_id});
|
||||
for (auto &it : t) {
|
||||
os << '[' << it.xmin << ", " << it.xmax << "] \n";
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id == -1) {
|
||||
throw sls::RuntimeError("Cannot execute ROI at multi module level");
|
||||
}
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
defs::ROI t;
|
||||
t.xmin = std::stoi(args[0]);
|
||||
t.xmax = std::stoi(args[1]);
|
||||
det->setROI(t, det_id);
|
||||
os << '[' << t.xmin << ", " << t.xmax << "] \n";
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::ClearROI(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "\n\t[Gotthard] Resets Region of interest in detector. All channels enabled. Default is all channels." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("Cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
det->clearROI({det_id});
|
||||
os << "[-1, -1] \n";
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
/* Gotthard2 Specific */
|
||||
/* CTB Specific */
|
||||
|
||||
std::string CmdProxy::Samples(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_samples]\n\t[CTB] Number of samples (both analog and digitial) expected." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto a = det->getNumberOfAnalogSamples({det_id});
|
||||
auto d = det->getNumberOfDigitalSamples({det_id});
|
||||
int as = a.squash(-1);
|
||||
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.");
|
||||
}
|
||||
os << OutString(a) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setNumberOfAnalogSamples(std::stoi(args[0]));
|
||||
det->setNumberOfDigitalSamples(std::stoi(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::Dbitphase(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_value] [(optional)deg]\n\t[Ctb] Phase shift of clock to latch digital bits. Absolute phase shift. If deg used, then shift in degrees. Changing dbitclk also resets dbitphase and sets to previous values." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
Result<int> t;
|
||||
if (args.size() == 0) {
|
||||
t = det->getDBITPhase({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (args.size() == 1) {
|
||||
if (args[0] != "deg") {
|
||||
throw sls::RuntimeError("Unknown dbitphase argument " + args[0] + ". Did you mean deg?");
|
||||
}
|
||||
t = det->getDBITPhaseInDegrees({det_id});
|
||||
os << OutString(t) << " deg\n";
|
||||
} else {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setDBITPhase(std::stoi(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else if (args.size() == 2) {
|
||||
if (args[1] != "deg") {
|
||||
throw sls::RuntimeError("Unknown dbitphase 2nd argument " + args[1] + ". Did you mean deg?");
|
||||
}
|
||||
det->setDBITPhaseInDegrees(std::stoi(args[0]), {det_id});
|
||||
os << args[0] << args[1] << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::SlowAdc(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_channel (0-7 for channel|8 for temperature)]\n\t[Ctb] Slow ADC channel." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
int nchan = std::stoi(args[0]);
|
||||
if (nchan < 0 || nchan > defs::SLOW_ADC_TEMP - defs::SLOW_ADC0) {
|
||||
throw sls::RuntimeError("Unknown adc argument " + args[0]);
|
||||
}
|
||||
if (nchan == 8) {
|
||||
auto t = det->getTemperature(defs::SLOW_ADC_TEMP, {det_id});
|
||||
os << OutString(t) << " °C\n";
|
||||
} else {
|
||||
auto t = det->getSlowADC(static_cast<defs::dacIndex>(nchan + defs::SLOW_ADC0));
|
||||
os << OutString(t) << '\n';
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("cannot put");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
std::string CmdProxy::ReceiverDbitList(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[all] or [i0] [i1] [i2]... \n\t[Ctb] List of digital signal bits read out. If all is used instead of a list, all digital bits (64) enabled. Each element in list can be 0 - 63 and non repetitive." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getRxDbitList({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() < 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
std::vector<int> t;
|
||||
if (args[0] == "all") {
|
||||
t.resize(64);
|
||||
for (unsigned int i = 0; i < 64; ++i) {
|
||||
t[i] = i;
|
||||
}
|
||||
} else {
|
||||
unsigned int ntrim = args.size();
|
||||
t.resize(ntrim);
|
||||
for (unsigned int i = 0; i < ntrim; ++i) {
|
||||
t[i] = std::stoi(args[i]);
|
||||
}
|
||||
}
|
||||
det->setRxDbitList(t, {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::DigitalIODelay(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[64 bit bitmask] [0-775]\n\t[Ctb] Delay for digital IO pins selected by the bitmask. Delay is in ps and max of 775 ps. Resolution is 25 ps." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("Cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setDigitalIODelay(std::stoul(args[0]), std::stoi(args[2]));
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
/* Pattern */
|
||||
|
||||
std::string CmdProxy::Pattern(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[fname]\n\t[Ctb] Loads binary pattern file with only pattern words" << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("Cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setPattern(args[0]);
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
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] 64 bit pattern at address of pattern memory." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getPatternWord(std::stoi(args[0]), {det_id});
|
||||
os << OutStringHex(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setPatternWord(std::stoi(args[0]), std::stoul(args[1]));
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
} // namespace sls
|
@ -22,11 +22,7 @@ void Detector::loadConfig(const std::string &fname) {
|
||||
}
|
||||
|
||||
void Detector::loadParameters(const std::string &fname) {
|
||||
pimpl->retrieveDetectorSetup(fname, 0);
|
||||
}
|
||||
|
||||
void Detector::savePattern(const std::string &fname) {
|
||||
pimpl->savePattern(fname);
|
||||
pimpl->loadParameters(fname);
|
||||
}
|
||||
|
||||
Result<std::string> Detector::getHostname(Positions pos) const {
|
||||
@ -39,6 +35,14 @@ void Detector::setHostname(const std::vector<std::string> &value) {
|
||||
|
||||
int Detector::getShmId() const { return pimpl->getMultiId(); }
|
||||
|
||||
std::string Detector::getPackageVersion() const {
|
||||
return pimpl->getPackageVersion();
|
||||
}
|
||||
|
||||
int64_t Detector::getClientVersion() const {
|
||||
return pimpl->getClientSoftwareVersion();
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getFirmwareVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getId, pos,
|
||||
defs::DETECTOR_FIRMWARE_VERSION);
|
||||
@ -54,10 +58,6 @@ Result<int64_t> Detector::getSerialNumber(Positions pos) const {
|
||||
defs::DETECTOR_SERIAL_NUMBER);
|
||||
}
|
||||
|
||||
int64_t Detector::getClientVersion() const {
|
||||
return pimpl->getClientSoftwareVersion();
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getReceiverVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getReceiverSoftwareVersion, pos);
|
||||
}
|
||||
@ -117,11 +117,11 @@ void Detector::setNumberOfFrames(int64_t value) {
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getNumberOfTriggers() const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, {}, defs::CYCLES_NUMBER, -1);
|
||||
return pimpl->Parallel(&slsDetector::setTimer, {}, defs::TRIGGER_NUMBER, -1);
|
||||
}
|
||||
|
||||
void Detector::setNumberOfTriggers(int64_t value) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, {}, defs::CYCLES_NUMBER, value);
|
||||
pimpl->Parallel(&slsDetector::setTimer, {}, defs::TRIGGER_NUMBER, value);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getExptime(Positions pos) const {
|
||||
@ -157,7 +157,7 @@ Result<int64_t> Detector::getNumberOfFramesLeft(Positions pos) const {
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getNumberOfTriggersLeft(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::CYCLES_NUMBER);
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::TRIGGER_NUMBER);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getDelayAfterTriggerLeft(Positions pos) const {
|
||||
@ -246,7 +246,7 @@ Result<int> Detector::getDAC(defs::dacIndex index, bool mV,
|
||||
return pimpl->Parallel(&slsDetector::setDAC, pos, -1, index, mV);
|
||||
}
|
||||
|
||||
void Detector::setDAC(int value, defs::dacIndex index, bool mV, Positions pos) {
|
||||
void Detector::setDAC(defs::dacIndex index, int value, bool mV, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setDAC, pos, value, index, mV);
|
||||
}
|
||||
|
||||
@ -263,20 +263,27 @@ void Detector::setTimingMode(defs::timingMode value, Positions pos) {
|
||||
|
||||
void Detector::acquire() { pimpl->acquire(); }
|
||||
|
||||
void Detector::startAcquisition() {
|
||||
if (getUseReceiverFlag().squash(true))
|
||||
pimpl->Parallel(&slsDetector::startReceiver, {});
|
||||
void Detector::clearAcquiringFlag() { pimpl->setAcquiringFlag(0); }
|
||||
|
||||
void Detector::startReceiver() {
|
||||
pimpl->Parallel(&slsDetector::startReceiver, {});
|
||||
}
|
||||
|
||||
void Detector::stopReceiver() {
|
||||
pimpl->Parallel(&slsDetector::stopReceiver, {});
|
||||
}
|
||||
|
||||
void Detector::startDetector() {
|
||||
if (getDetectorType({}).squash() == defs::EIGER) {
|
||||
pimpl->Parallel(&slsDetector::prepareAcquisition, {});
|
||||
}
|
||||
pimpl->Parallel(&slsDetector::startAcquisition, {});
|
||||
}
|
||||
|
||||
void Detector::stopAcquisition() {
|
||||
void Detector::stopDetector() {
|
||||
pimpl->Parallel(&slsDetector::stopAcquisition, {});
|
||||
if (getUseReceiverFlag().squash(true))
|
||||
pimpl->Parallel(&slsDetector::stopReceiver, {});
|
||||
}
|
||||
|
||||
void Detector::clearAcquiringFlag() { pimpl->setAcquiringFlag(0); }
|
||||
|
||||
Result<defs::runStatus> Detector::getDetectorStatus(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getRunStatus, pos);
|
||||
}
|
||||
@ -497,8 +504,19 @@ Result<int> Detector::getRxPort(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getReceiverPort, pos);
|
||||
}
|
||||
|
||||
void Detector::setRxPort(int value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setReceiverPort, pos, value);
|
||||
void Detector::setRxPort(int port, int module_id) {
|
||||
if (module_id == -1) {
|
||||
std::vector<int> port_list(size());
|
||||
for (auto &it: port_list) {
|
||||
it = port++;
|
||||
}
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&slsDetector::setReceiverPort, {idet},
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
pimpl->Parallel(&slsDetector::setReceiverPort, {module_id}, port);
|
||||
}
|
||||
}
|
||||
|
||||
Result<int> Detector::getRxFifoDepth(Positions pos) const {
|
||||
@ -559,7 +577,7 @@ void Detector::setRxLock(bool value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::lockReceiver, pos, static_cast<int>(value));
|
||||
}
|
||||
|
||||
Result<std::string> Detector::getRxLastClientIP(Positions pos) const {
|
||||
Result<sls::IpAddr> Detector::getRxLastClientIP(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getReceiverLastClientIP, pos);
|
||||
}
|
||||
|
||||
@ -589,11 +607,11 @@ void Detector::setFileNamePrefix(const std::string &fname, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setFileName, pos, fname);
|
||||
}
|
||||
|
||||
Result<int> Detector::getAcquisitionIndex(Positions pos) const {
|
||||
Result<int64_t> Detector::getAcquisitionIndex(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getFileIndex, pos);
|
||||
}
|
||||
|
||||
void Detector::setAcquisitionIndex(int i, Positions pos) {
|
||||
void Detector::setAcquisitionIndex(int64_t i, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setFileIndex, pos, i);
|
||||
}
|
||||
|
||||
@ -675,11 +693,11 @@ void Detector::setRxZmqPort(int port, int module_id) {
|
||||
}
|
||||
}
|
||||
|
||||
Result<std::string> Detector::getRxZmqIP(Positions pos) const {
|
||||
Result<IpAddr> Detector::getRxZmqIP(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getReceiverStreamingIP, pos);
|
||||
}
|
||||
|
||||
void Detector::setRxZmqIP(const std::string &ip, Positions pos) {
|
||||
void Detector::setRxZmqIP(const IpAddr ip, Positions pos) {
|
||||
bool previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(false);
|
||||
pimpl->Parallel(&slsDetector::setReceiverStreamingIP, pos, ip);
|
||||
if (previouslyReceiverStreaming) {
|
||||
@ -705,11 +723,11 @@ void Detector::setClientZmqPort(int port, int module_id) {
|
||||
}
|
||||
}
|
||||
|
||||
Result<std::string> Detector::getClientZmqIp(Positions pos) const {
|
||||
Result<IpAddr> Detector::getClientZmqIp(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getClientStreamingIP, pos);
|
||||
}
|
||||
|
||||
void Detector::setClientZmqIp(const std::string &ip, Positions pos) {
|
||||
void Detector::setClientZmqIp(const IpAddr ip, Positions pos) {
|
||||
int previouslyClientStreaming = pimpl->enableDataStreamingToClient(-1);
|
||||
pimpl->Parallel(&slsDetector::setClientStreamingIP, pos, ip);
|
||||
if (previouslyClientStreaming != 0) {
|
||||
@ -757,11 +775,11 @@ void Detector::setThresholdEnergy(int threshold_ev,
|
||||
settings, static_cast<int>(trimbits));
|
||||
}
|
||||
|
||||
Result<std::string> Detector::getSettingsDir(Positions pos) const {
|
||||
Result<std::string> Detector::getSettingsPath(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getSettingsDir, pos);
|
||||
}
|
||||
|
||||
void Detector::setSettingsDir(const std::string &value, Positions pos) {
|
||||
void Detector::setSettingsPath(const std::string &value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setSettingsDir, pos, value);
|
||||
}
|
||||
|
||||
@ -882,7 +900,12 @@ void Detector::setRxPadDeactivatedMode(bool pad, Positions pos) {
|
||||
}
|
||||
|
||||
Result<bool> Detector::getPartialReset(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setCounterBit, pos, -1);
|
||||
auto res = pimpl->Parallel(&slsDetector::setCounterBit, pos, -1);
|
||||
Result<bool> t(res.size());
|
||||
for (unsigned int i = 0; i < res.size(); ++i) {
|
||||
t[i] = !res[i];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
void Detector::setPartialReset(bool value, Positions pos) {
|
||||
@ -943,7 +966,7 @@ Result<bool> Detector::getPowerChip(Positions pos) const {
|
||||
}
|
||||
|
||||
void Detector::setPowerChip(bool on, Positions pos) {
|
||||
if (on && pimpl->size() > 3) {
|
||||
if ((pos.empty() || pos[0] == -1) && on && pimpl->size() > 3) {
|
||||
for (unsigned int i = 0; i != pimpl->size(); ++i) {
|
||||
pimpl->powerChip(static_cast<int>(on), i);
|
||||
usleep(1000 * 1000);
|
||||
@ -996,11 +1019,15 @@ Result<defs::ROI> Detector::getROI(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getROI, pos);
|
||||
}
|
||||
|
||||
void Detector::setROI(defs::ROI value, int moduleId) {
|
||||
if (moduleId < 0 && size() > 1) {
|
||||
void Detector::setROI(defs::ROI value, int module_id) {
|
||||
if (module_id < 0 && size() > 1) {
|
||||
throw RuntimeError("Cannot set ROI for all modules simultaneously");
|
||||
}
|
||||
pimpl->Parallel(&slsDetector::setROI, {moduleId}, value);
|
||||
pimpl->Parallel(&slsDetector::setROI, {module_id}, value);
|
||||
}
|
||||
|
||||
void Detector::clearROI(Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::clearROI, pos);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getExptimeLeft(Positions pos) const {
|
||||
@ -1136,14 +1163,6 @@ void Detector::setDBITPipeline(int value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PIPELINE, value, 0);
|
||||
}
|
||||
|
||||
Result<int> Detector::getVrefVoltage(bool mV, Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setDAC, pos, -1, defs::ADC_VPP, mV);
|
||||
}
|
||||
|
||||
void Detector::setVrefVoltage(int value, bool mV, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setDAC, pos, value, defs::ADC_VPP, mV);
|
||||
}
|
||||
|
||||
Result<int> Detector::getVoltage(defs::dacIndex index, Positions pos) const {
|
||||
switch (index) {
|
||||
case defs::V_LIMIT:
|
||||
@ -1160,7 +1179,7 @@ Result<int> Detector::getVoltage(defs::dacIndex index, Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setDAC, pos, -1, index, 1);
|
||||
}
|
||||
|
||||
void Detector::setVoltage(int value, defs::dacIndex index, Positions pos) {
|
||||
void Detector::setVoltage(defs::dacIndex index, int value, Positions pos) {
|
||||
switch (index) {
|
||||
case defs::V_LIMIT:
|
||||
case defs::V_POWER_A:
|
||||
@ -1276,6 +1295,10 @@ void Detector::setLEDEnable(bool enable, Positions pos) {
|
||||
|
||||
// Pattern
|
||||
|
||||
void Detector::savePattern(const std::string &fname) {
|
||||
pimpl->savePattern(fname);
|
||||
}
|
||||
|
||||
void Detector::setPattern(const std::string &fname, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setPattern, pos, fname);
|
||||
}
|
||||
@ -1296,6 +1319,10 @@ void Detector::setPatternClockControl(uint64_t word, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setPatternClockControl, pos, word);
|
||||
}
|
||||
|
||||
Result<uint64_t> Detector::getPatternWord(int addr, Positions pos) {
|
||||
return pimpl->Parallel(&slsDetector::setPatternWord, pos, addr, -1);
|
||||
}
|
||||
|
||||
void Detector::setPatternWord(int addr, uint64_t word, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setPatternWord, pos, addr, word);
|
||||
}
|
||||
@ -1369,7 +1396,7 @@ Result<int> Detector::getDetectorMinMaxEnergyThreshold(const bool isEmax,
|
||||
Positions pos) const {
|
||||
auto res = pimpl->Parallel(&slsDetector::getAdditionalJsonParameter, pos,
|
||||
isEmax ? "emax" : "emin");
|
||||
Result<int> intResult;
|
||||
Result<int> intResult(res.size());
|
||||
try {
|
||||
for (unsigned int i = 0; i < res.size(); ++i) {
|
||||
intResult[i] = stoi(res[i]);
|
||||
@ -1391,7 +1418,7 @@ void Detector::setDetectorMinMaxEnergyThreshold(const bool isEmax,
|
||||
Result<int> Detector::getFrameMode(Positions pos) const {
|
||||
auto res = pimpl->Parallel(&slsDetector::getAdditionalJsonParameter, pos,
|
||||
"frameMode");
|
||||
Result<int> intResult;
|
||||
Result<int> intResult(res.size());
|
||||
try {
|
||||
for (unsigned int i = 0; i < res.size(); ++i) {
|
||||
intResult[i] = defs::getFrameModeType(res[i]);
|
||||
@ -1411,7 +1438,7 @@ void Detector::setFrameMode(defs::frameModeType value, Positions pos) {
|
||||
Result<int> Detector::getDetectorMode(Positions pos) const {
|
||||
auto res = pimpl->Parallel(&slsDetector::getAdditionalJsonParameter, pos,
|
||||
"detectorMode");
|
||||
Result<int> intResult;
|
||||
Result<int> intResult(res.size());
|
||||
try {
|
||||
for (unsigned int i = 0; i < res.size(); ++i) {
|
||||
intResult[i] = defs::getDetectorModeType(res[i]);
|
||||
@ -1516,7 +1543,7 @@ void Detector::setDetectorLock(bool lock, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::lockServer, pos, static_cast<int>(lock));
|
||||
}
|
||||
|
||||
Result<std::string> Detector::getLastClientIP(Positions pos) const {
|
||||
Result<sls::IpAddr> Detector::getLastClientIP(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getLastClientIP, pos);
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "container_utils.h"
|
||||
#include "network_utils.h"
|
||||
#include "string_utils.h"
|
||||
#include "ToString.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
@ -164,6 +165,8 @@ int64_t multiSlsDetector::getId(idMode mode, int detPos) {
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
std::string multiSlsDetector::getPackageVersion() const { return GITBRANCH; }
|
||||
|
||||
int64_t multiSlsDetector::getClientSoftwareVersion() const { return APILIB; }
|
||||
|
||||
int64_t multiSlsDetector::getReceiverSoftwareVersion(int detPos) {
|
||||
@ -240,8 +243,7 @@ std::string multiSlsDetector::getUserDetails() {
|
||||
sstream << "\nType: ";
|
||||
// get type from multi shm
|
||||
if (multi_shm()->shmversion >= MULTI_SHMAPIVERSION) {
|
||||
sstream << slsDetectorDefs::detectorTypeToString(
|
||||
getDetectorTypeAsEnum());
|
||||
sstream << ToString(getDetectorTypeAsEnum());
|
||||
}
|
||||
// get type from slsdet shm
|
||||
else {
|
||||
@ -396,7 +398,10 @@ void multiSlsDetector::setHostname(const char *name, int detPos) {
|
||||
freeSharedMemory();
|
||||
setupMultiDetector();
|
||||
}
|
||||
addMultipleDetectors(name);
|
||||
for (const auto &hostname : sls::split(name, '+')) {
|
||||
addSlsDetector(hostname);
|
||||
}
|
||||
updateDetectorSize();
|
||||
}
|
||||
|
||||
std::string multiSlsDetector::getHostname(int detPos) const {
|
||||
@ -410,15 +415,9 @@ std::string multiSlsDetector::getHostname(int detPos) const {
|
||||
return sls::concatenateNonEmptyStrings(r);
|
||||
}
|
||||
|
||||
void multiSlsDetector::addMultipleDetectors(const char *name) {
|
||||
for (const auto &hostname : sls::split(name, '+')) {
|
||||
addSlsDetector(hostname);
|
||||
}
|
||||
updateDetectorSize();
|
||||
}
|
||||
|
||||
void multiSlsDetector::addSlsDetector(const std::string &hostname) {
|
||||
FILE_LOG(logDEBUG1) << "Adding detector " << hostname;
|
||||
FILE_LOG(logINFO) << "Adding detector " << hostname;
|
||||
|
||||
int port = DEFAULT_PORTNO;
|
||||
std::string host = hostname;
|
||||
@ -622,13 +621,6 @@ int multiSlsDetector::lockServer(int p, int detPos) {
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
std::string multiSlsDetector::getLastClientIP(int detPos) {
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getLastClientIP();
|
||||
}
|
||||
auto r = parallelCall(&slsDetector::getLastClientIP);
|
||||
return sls::concatenateIfDifferent(r);
|
||||
}
|
||||
|
||||
void multiSlsDetector::exitServer(int detPos) {
|
||||
if (detPos >= 0) {
|
||||
@ -650,7 +642,7 @@ void multiSlsDetector::readConfigurationFile(const std::string &fname) {
|
||||
FILE_LOG(logINFO) << "Loading configuration file: " << fname;
|
||||
|
||||
std::ifstream input_file;
|
||||
input_file.open(fname, std::ios_base::in);
|
||||
input_file.open(fname.c_str(), std::ios_base::in);
|
||||
if (!input_file.is_open()) {
|
||||
throw RuntimeError("Could not open configuration file " + fname +
|
||||
" for reading");
|
||||
@ -664,7 +656,7 @@ void multiSlsDetector::readConfigurationFile(const std::string &fname) {
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "current_line after removing comments:\n\t" << current_line;
|
||||
if (current_line.length() > 1) {
|
||||
multiSlsDetectorClient(current_line, PUT_ACTION, this);
|
||||
multiSlsDetectorClient(current_line, PUT_ACTION, nullptr);
|
||||
}
|
||||
}
|
||||
input_file.close();
|
||||
@ -787,118 +779,6 @@ void multiSlsDetector::saveSettingsFile(const std::string &fname, int detPos) {
|
||||
parallelCall(&slsDetector::saveSettingsFile, fname);
|
||||
}
|
||||
|
||||
slsDetectorDefs::runStatus multiSlsDetector::getRunStatus(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getRunStatus();
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::getRunStatus);
|
||||
if (sls::allEqual(r)) {
|
||||
return r.front();
|
||||
}
|
||||
if (sls::anyEqualTo(r, ERROR)) {
|
||||
return ERROR;
|
||||
}
|
||||
for (const auto &value : r) {
|
||||
if (value != IDLE) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return IDLE;
|
||||
}
|
||||
|
||||
void multiSlsDetector::prepareAcquisition(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->prepareAcquisition();
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::prepareAcquisition);
|
||||
}
|
||||
|
||||
void multiSlsDetector::startAcquisition(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
if (detectors[detPos]->getDetectorTypeAsEnum() == EIGER) {
|
||||
detectors[detPos]->prepareAcquisition();
|
||||
}
|
||||
detectors[detPos]->startAcquisition();
|
||||
}
|
||||
|
||||
// multi
|
||||
if (getDetectorTypeAsEnum() == EIGER) {
|
||||
prepareAcquisition();
|
||||
}
|
||||
parallelCall(&slsDetector::startAcquisition);
|
||||
}
|
||||
|
||||
void multiSlsDetector::stopAcquisition(int detPos) {
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->stopAcquisition();
|
||||
} else {
|
||||
parallelCall(&slsDetector::stopAcquisition);
|
||||
}
|
||||
}
|
||||
|
||||
void multiSlsDetector::sendSoftwareTrigger(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->sendSoftwareTrigger();
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::sendSoftwareTrigger);
|
||||
}
|
||||
|
||||
void multiSlsDetector::startAndReadAll(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
if (detectors[detPos]->getDetectorTypeAsEnum() == EIGER) {
|
||||
detectors[detPos]->prepareAcquisition();
|
||||
}
|
||||
detectors[detPos]->startAndReadAll();
|
||||
}
|
||||
|
||||
// multi
|
||||
if (getDetectorTypeAsEnum() == EIGER) {
|
||||
prepareAcquisition();
|
||||
}
|
||||
parallelCall(&slsDetector::startAndReadAll);
|
||||
}
|
||||
|
||||
void multiSlsDetector::startReadOut(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->startReadOut();
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::startReadOut);
|
||||
}
|
||||
|
||||
void multiSlsDetector::readAll(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->readAll();
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::readAll);
|
||||
}
|
||||
/*
|
||||
void multiSlsDetector::configureMAC(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->configureMAC();
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::configureMAC);
|
||||
}
|
||||
*/
|
||||
|
||||
void multiSlsDetector::setStartingFrameNumber(const uint64_t value,
|
||||
int detPos) {
|
||||
@ -994,8 +874,8 @@ int64_t multiSlsDetector::setNumberOfFrames(int64_t t, int detPos) {
|
||||
return setTimer(FRAME_NUMBER, t, detPos);
|
||||
}
|
||||
|
||||
int64_t multiSlsDetector::setNumberOfCycles(int64_t t, int detPos) {
|
||||
return setTimer(CYCLES_NUMBER, t, detPos);
|
||||
int64_t multiSlsDetector::setNumberOfTriggers(int64_t t, int detPos) {
|
||||
return setTimer(TRIGGER_NUMBER, t, detPos);
|
||||
}
|
||||
|
||||
int64_t multiSlsDetector::setNumberOfStorageCells(int64_t t, int detPos) {
|
||||
@ -1436,74 +1316,6 @@ int multiSlsDetector::getReceiverStreamingPort(int detPos) {
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
void multiSlsDetector::setClientDataStreamingInIP(const std::string &ip,
|
||||
int detPos) {
|
||||
if (ip.length() != 0u) {
|
||||
bool prev_streaming = enableDataStreamingToClient(-1);
|
||||
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->setClientStreamingIP(ip);
|
||||
}
|
||||
// multi
|
||||
else {
|
||||
for (auto &d : detectors) {
|
||||
d->setClientStreamingIP(ip);
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_streaming) {
|
||||
enableDataStreamingToClient(0);
|
||||
enableDataStreamingToClient(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string multiSlsDetector::getClientStreamingIP(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getClientStreamingIP();
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = serialCall(&slsDetector::getClientStreamingIP);
|
||||
return sls::concatenateIfDifferent(r);
|
||||
}
|
||||
|
||||
void multiSlsDetector::setReceiverDataStreamingOutIP(const std::string &ip,
|
||||
int detPos) {
|
||||
if (ip.length() != 0u) {
|
||||
int prev_streaming = enableDataStreamingFromReceiver(-1, detPos);
|
||||
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->setReceiverStreamingIP(ip);
|
||||
}
|
||||
// multi
|
||||
else {
|
||||
for (auto &d : detectors) {
|
||||
d->setReceiverStreamingIP(ip);
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_streaming != 0) {
|
||||
enableDataStreamingFromReceiver(0, detPos);
|
||||
enableDataStreamingFromReceiver(1, detPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string multiSlsDetector::getReceiverStreamingIP(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getReceiverStreamingIP();
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = serialCall(&slsDetector::getReceiverStreamingIP);
|
||||
return sls::concatenateIfDifferent(r);
|
||||
}
|
||||
|
||||
int multiSlsDetector::setDetectorNetworkParameter(networkParameter index,
|
||||
int value, int detPos) {
|
||||
// single
|
||||
@ -2209,16 +2021,7 @@ int multiSlsDetector::lockReceiver(int lock, int detPos) {
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
std::string multiSlsDetector::getReceiverLastClientIP(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getReceiverLastClientIP();
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::getReceiverLastClientIP);
|
||||
return sls::concatenateIfDifferent(r);
|
||||
}
|
||||
|
||||
void multiSlsDetector::exitReceiver(int detPos) {
|
||||
// single
|
||||
@ -2360,7 +2163,7 @@ slsDetectorDefs::fileFormat multiSlsDetector::setFileFormat(fileFormat f,
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
int multiSlsDetector::incrementFileIndex(int detPos) {
|
||||
int64_t multiSlsDetector::incrementFileIndex(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->incrementFileIndex();
|
||||
@ -2371,7 +2174,7 @@ int multiSlsDetector::incrementFileIndex(int detPos) {
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
int multiSlsDetector::setFileIndex(int i, int detPos) {
|
||||
int64_t multiSlsDetector::setFileIndex(int64_t i, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->setFileIndex(i);
|
||||
@ -2382,54 +2185,13 @@ int multiSlsDetector::setFileIndex(int i, int detPos) {
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
int multiSlsDetector::getFileIndex(int detPos) const {
|
||||
int64_t multiSlsDetector::getFileIndex(int detPos) const {
|
||||
if (detPos >= 0)
|
||||
return detectors[detPos]->getFileIndex();
|
||||
auto r = parallelCall(&slsDetector::getFileIndex);
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
void multiSlsDetector::startReceiver(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->startReceiver();
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::startReceiver);
|
||||
}
|
||||
|
||||
void multiSlsDetector::stopReceiver(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->stopReceiver();
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::stopReceiver);
|
||||
}
|
||||
|
||||
slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getReceiverStatus();
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::getReceiverStatus);
|
||||
if (sls::allEqual(r)) {
|
||||
return r.front();
|
||||
}
|
||||
if (sls::anyEqualTo(r, ERROR)) {
|
||||
return ERROR;
|
||||
}
|
||||
for (const auto &value : r) {
|
||||
if (value != IDLE) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return IDLE;
|
||||
}
|
||||
|
||||
int multiSlsDetector::getFramesCaughtByReceiver(int detPos) {
|
||||
// single
|
||||
@ -2508,7 +2270,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) {
|
||||
try {
|
||||
zmqSocket.push_back(sls::make_unique<ZmqSocket>(
|
||||
detectors[iSocket / numSocketsPerDetector]
|
||||
->getClientStreamingIP()
|
||||
->getClientStreamingIP().str()
|
||||
.c_str(),
|
||||
portnum));
|
||||
FILE_LOG(logINFO) << "Zmq Client[" << iSocket << "] at "
|
||||
@ -3245,190 +3007,28 @@ void multiSlsDetector::setDigitalIODelay(uint64_t pinMask, int delay,
|
||||
parallelCall(&slsDetector::setDigitalIODelay, pinMask, delay);
|
||||
}
|
||||
|
||||
int multiSlsDetector::retrieveDetectorSetup(const std::string &fname1,
|
||||
int level) {
|
||||
|
||||
int skip = 0;
|
||||
std::string fname;
|
||||
std::string str;
|
||||
std::ifstream infile;
|
||||
int iargval;
|
||||
int interrupt = 0;
|
||||
char *args[10];
|
||||
|
||||
char myargs[10][1000];
|
||||
|
||||
std::string sargname, sargval;
|
||||
int iline = 0;
|
||||
|
||||
if (level == 2) {
|
||||
FILE_LOG(logDEBUG1) << "config file read";
|
||||
fname = fname1 + std::string(".det");
|
||||
} else {
|
||||
fname = fname1;
|
||||
void multiSlsDetector::loadParameters(const std::string &fname) {
|
||||
std::ifstream input_file;
|
||||
input_file.open(fname.c_str(), std::ios_base::in);
|
||||
if (!input_file.is_open()) {
|
||||
throw RuntimeError("Could not open parameter file " + fname +
|
||||
" for reading");
|
||||
}
|
||||
|
||||
infile.open(fname.c_str(), std::ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
auto cmd = slsDetectorCommand(this);
|
||||
while (infile.good() and interrupt == 0) {
|
||||
sargname = "none";
|
||||
sargval = "0";
|
||||
getline(infile, str);
|
||||
iline++;
|
||||
FILE_LOG(logDEBUG1) << str;
|
||||
if (str.find('#') != std::string::npos) {
|
||||
FILE_LOG(logDEBUG1) << "Line is a comment \n" << str;
|
||||
continue;
|
||||
} else {
|
||||
std::istringstream ssstr(str);
|
||||
iargval = 0;
|
||||
while (ssstr.good()) {
|
||||
ssstr >> sargname;
|
||||
// if (ssstr.good()) {
|
||||
sls::strcpy_safe(myargs[iargval], sargname.c_str());
|
||||
args[iargval] = myargs[iargval];
|
||||
FILE_LOG(logDEBUG1) << args[iargval];
|
||||
iargval++;
|
||||
// }
|
||||
skip = 0;
|
||||
}
|
||||
if (level != 2) {
|
||||
if (std::string(args[0]) == std::string("trimbits")) {
|
||||
skip = 1;
|
||||
}
|
||||
}
|
||||
if (skip == 0) {
|
||||
cmd.executeLine(iargval, args, PUT_ACTION);
|
||||
}
|
||||
}
|
||||
iline++;
|
||||
std::string current_line;
|
||||
while (input_file.good()) {
|
||||
getline(input_file, current_line);
|
||||
if (current_line.find('#') != std::string::npos) {
|
||||
current_line.erase(current_line.find('#'));
|
||||
}
|
||||
infile.close();
|
||||
|
||||
} else {
|
||||
throw RuntimeError("Error opening " + fname + " for reading");
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "current_line after removing comments:\n\t" << current_line;
|
||||
if (current_line.length() > 1) {
|
||||
multiSlsDetectorClient(current_line, PUT_ACTION, this);
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Read " << iline << " lines";
|
||||
return OK;
|
||||
input_file.close();
|
||||
}
|
||||
|
||||
int multiSlsDetector::dumpDetectorSetup(const std::string &fname, int level) {
|
||||
detectorType type = getDetectorTypeAsEnum();
|
||||
std::vector<std::string> names;
|
||||
// common config
|
||||
names.emplace_back("fname");
|
||||
names.emplace_back("index");
|
||||
names.emplace_back("enablefwrite");
|
||||
names.emplace_back("overwrite");
|
||||
names.emplace_back("dr");
|
||||
names.emplace_back("settings");
|
||||
names.emplace_back("exptime");
|
||||
names.emplace_back("period");
|
||||
names.emplace_back("frames");
|
||||
names.emplace_back("cycles");
|
||||
names.emplace_back("timing");
|
||||
|
||||
switch (type) {
|
||||
case EIGER:
|
||||
names.emplace_back("flags");
|
||||
names.emplace_back("clkdivider");
|
||||
names.emplace_back("threshold");
|
||||
names.emplace_back("ratecorr");
|
||||
names.emplace_back("trimbits");
|
||||
break;
|
||||
case GOTTHARD:
|
||||
names.emplace_back("delay");
|
||||
break;
|
||||
case JUNGFRAU:
|
||||
names.emplace_back("delay");
|
||||
names.emplace_back("clkdivider");
|
||||
break;
|
||||
case CHIPTESTBOARD:
|
||||
names.emplace_back("dac:0");
|
||||
names.emplace_back("dac:1");
|
||||
names.emplace_back("dac:2");
|
||||
names.emplace_back("dac:3");
|
||||
names.emplace_back("dac:4");
|
||||
names.emplace_back("dac:5");
|
||||
names.emplace_back("dac:6");
|
||||
names.emplace_back("dac:7");
|
||||
names.emplace_back("dac:8");
|
||||
names.emplace_back("dac:9");
|
||||
names.emplace_back("dac:10");
|
||||
names.emplace_back("dac:11");
|
||||
names.emplace_back("dac:12");
|
||||
names.emplace_back("dac:13");
|
||||
names.emplace_back("dac:14");
|
||||
names.emplace_back("dac:15");
|
||||
names.emplace_back("dac:16");
|
||||
names.emplace_back("dac:17");
|
||||
names.emplace_back("dac:18");
|
||||
names.emplace_back("dac:19");
|
||||
names.emplace_back("dac:20");
|
||||
names.emplace_back("dac:21");
|
||||
names.emplace_back("dac:22");
|
||||
names.emplace_back("dac:23");
|
||||
names.emplace_back("adcvpp");
|
||||
names.emplace_back("adcclk");
|
||||
names.emplace_back("clkdivider");
|
||||
names.emplace_back("adcphase");
|
||||
names.emplace_back("adcpipeline");
|
||||
names.emplace_back("adcinvert"); //
|
||||
names.emplace_back("adcdisable");
|
||||
names.emplace_back("patioctrl");
|
||||
names.emplace_back("patclkctrl");
|
||||
names.emplace_back("patlimits");
|
||||
names.emplace_back("patloop0");
|
||||
names.emplace_back("patnloop0");
|
||||
names.emplace_back("patwait0");
|
||||
names.emplace_back("patwaittime0");
|
||||
names.emplace_back("patloop1");
|
||||
names.emplace_back("patnloop1");
|
||||
names.emplace_back("patwait1");
|
||||
names.emplace_back("patwaittime1");
|
||||
names.emplace_back("patloop2");
|
||||
names.emplace_back("patnloop2");
|
||||
names.emplace_back("patwait2");
|
||||
names.emplace_back("patwaittime2");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Workaround to bo able to suplly ecexuteLine with char**
|
||||
const int n_arguments = 1;
|
||||
char buffer[1000]; // TODO! this should not be hardcoded!
|
||||
char *args[n_arguments] = {buffer};
|
||||
|
||||
std::string outfname;
|
||||
if (level == 2) {
|
||||
writeConfigurationFile(fname + ".config");
|
||||
outfname = fname + ".det";
|
||||
} else {
|
||||
outfname = fname;
|
||||
}
|
||||
|
||||
std::ofstream outfile;
|
||||
outfile.open(outfname.c_str(), std::ios_base::out);
|
||||
if (outfile.is_open()) {
|
||||
auto cmd = slsDetectorCommand(this);
|
||||
for (auto &name : names) {
|
||||
sls::strcpy_safe(buffer, name.c_str()); // this is...
|
||||
outfile << name << " "
|
||||
<< cmd.executeLine(n_arguments, args, GET_ACTION)
|
||||
<< std::endl;
|
||||
}
|
||||
outfile.close();
|
||||
} else {
|
||||
throw RuntimeError("Error opening parameters file " + fname +
|
||||
" for writing");
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1) << "wrote " << names.size() << " lines to "
|
||||
<< outfname;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void multiSlsDetector::registerAcquisitionFinishedCallback(
|
||||
void (*func)(double, int, void *), void *pArg) {
|
||||
@ -3455,10 +3055,10 @@ void multiSlsDetector::registerDataCallback(
|
||||
int multiSlsDetector::setTotalProgress() {
|
||||
int nf = Parallel(&slsDetector::setTimer, {}, FRAME_NUMBER, -1)
|
||||
.tsquash("Inconsistent number of frames");
|
||||
int nc = Parallel(&slsDetector::setTimer, {}, CYCLES_NUMBER, -1)
|
||||
.tsquash("Inconsistent number of cycles");
|
||||
int nc = Parallel(&slsDetector::setTimer, {}, TRIGGER_NUMBER, -1)
|
||||
.tsquash("Inconsistent number of triggers");
|
||||
if (nf == 0 || nc == 0) {
|
||||
throw RuntimeError("Number of frames or cycles is 0");
|
||||
throw RuntimeError("Number of frames or triggers is 0");
|
||||
}
|
||||
|
||||
int ns = 1;
|
||||
@ -3520,8 +3120,8 @@ int multiSlsDetector::acquire() {
|
||||
|
||||
// verify receiver is idle
|
||||
if (receiver) {
|
||||
if (getReceiverStatus() != IDLE) {
|
||||
stopReceiver();
|
||||
if (Parallel(&slsDetector::getReceiverStatus, {}).squash(ERROR) != IDLE) {
|
||||
Parallel(&slsDetector::stopReceiver, {});
|
||||
}
|
||||
}
|
||||
setTotalProgress();
|
||||
@ -3535,16 +3135,20 @@ int multiSlsDetector::acquire() {
|
||||
|
||||
// start receiver
|
||||
if (receiver) {
|
||||
startReceiver();
|
||||
Parallel(&slsDetector::startReceiver, {});
|
||||
// let processing thread listen to these packets
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
}
|
||||
|
||||
startAndReadAll();
|
||||
// start and read all
|
||||
if (getDetectorTypeAsEnum() == EIGER) {
|
||||
Parallel(&slsDetector::prepareAcquisition, {});
|
||||
}
|
||||
Parallel(&slsDetector::startAndReadAll, {});
|
||||
|
||||
// stop receiver
|
||||
if (receiver) {
|
||||
stopReceiver();
|
||||
Parallel(&slsDetector::stopReceiver, {});
|
||||
if (dataReady != nullptr) {
|
||||
sem_wait(&sem_endRTAcquisition); // waits for receiver's
|
||||
}
|
||||
@ -3560,7 +3164,12 @@ int multiSlsDetector::acquire() {
|
||||
dataProcessingThread.join();
|
||||
|
||||
if (acquisition_finished != nullptr) {
|
||||
acquisition_finished(getCurrentProgress(), getRunStatus(),
|
||||
// same status for all, else error
|
||||
int status = static_cast<int>(ERROR);
|
||||
auto t = Parallel(&slsDetector::getRunStatus, {});
|
||||
if (t.equal())
|
||||
status = t.front();
|
||||
acquisition_finished(getCurrentProgress(), status,
|
||||
acqFinished_p);
|
||||
}
|
||||
|
||||
@ -3597,7 +3206,7 @@ void multiSlsDetector::processData() {
|
||||
if (fgetc(stdin) == 'q') {
|
||||
FILE_LOG(logINFO)
|
||||
<< "Caught the command to stop acquisition";
|
||||
stopAcquisition();
|
||||
Parallel(&slsDetector::stopAcquisition, {});
|
||||
}
|
||||
}
|
||||
// get progress
|
||||
|
@ -30,7 +30,7 @@ void multiSlsDetectorClient::runCommand() {
|
||||
action_ = slsDetectorDefs::HELP_ACTION;
|
||||
bool verify = true;
|
||||
bool update = true;
|
||||
if (action_ == slsDetectorDefs::PUT_ACTION && parser.n_arguments() == 0) {
|
||||
if (action_ == slsDetectorDefs::PUT_ACTION && parser.command().empty()) {
|
||||
os << "Wrong usage - should be: " << parser.executable()
|
||||
<< "[id-][pos:]channel arg" << std::endl;
|
||||
os << std::endl;
|
||||
@ -77,8 +77,9 @@ void multiSlsDetectorClient::runCommand() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (parser.detector_id() >= static_cast<int>(detPtr->size())) {
|
||||
os << "position is out of bounds.\n";
|
||||
os << "position " << parser.detector_id() << " is out of bounds (max " << detPtr->size() << ").\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "string_utils.h"
|
||||
#include "versionAPI.h"
|
||||
#include "ToString.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
@ -324,7 +326,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
shm()->timerValue[ACQUISITION_TIME] = 0;
|
||||
shm()->timerValue[FRAME_PERIOD] = 0;
|
||||
shm()->timerValue[DELAY_AFTER_TRIGGER] = 0;
|
||||
shm()->timerValue[CYCLES_NUMBER] = 1;
|
||||
shm()->timerValue[TRIGGER_NUMBER] = 1;
|
||||
shm()->timerValue[ACTUAL_TIME] = 0;
|
||||
shm()->timerValue[MEASUREMENT_TIME] = 0;
|
||||
shm()->timerValue[PROGRESS] = 0;
|
||||
@ -419,34 +421,34 @@ int slsDetector::sendModule(sls_detector_module *myMod,
|
||||
n = client.Send(&(myMod->nchan), sizeof(myMod->nchan));
|
||||
ts += n;
|
||||
FILE_LOG(level) << "nchan sent. " << n
|
||||
<< " bytes. serialno: " << myMod->nchan;
|
||||
<< " bytes. nchan: " << myMod->nchan;
|
||||
|
||||
n = client.Send(&(myMod->nchip), sizeof(myMod->nchip));
|
||||
ts += n;
|
||||
FILE_LOG(level) << "nchip sent. " << n
|
||||
<< " bytes. serialno: " << myMod->nchip;
|
||||
<< " bytes. nchip: " << myMod->nchip;
|
||||
|
||||
n = client.Send(&(myMod->ndac), sizeof(myMod->ndac));
|
||||
ts += n;
|
||||
FILE_LOG(level) << "ndac sent. " << n
|
||||
<< " bytes. serialno: " << myMod->ndac;
|
||||
<< " bytes. ndac: " << myMod->ndac;
|
||||
|
||||
n = client.Send(&(myMod->reg), sizeof(myMod->reg));
|
||||
ts += n;
|
||||
FILE_LOG(level) << "reg sent. " << n << " bytes. serialno: " << myMod->reg;
|
||||
FILE_LOG(level) << "reg sent. " << n << " bytes. reg: " << myMod->reg;
|
||||
|
||||
n = client.Send(&(myMod->iodelay), sizeof(myMod->iodelay));
|
||||
ts += n;
|
||||
FILE_LOG(level) << "iodelay sent. " << n
|
||||
<< " bytes. serialno: " << myMod->iodelay;
|
||||
<< " bytes. iodelay: " << myMod->iodelay;
|
||||
|
||||
n = client.Send(&(myMod->tau), sizeof(myMod->tau));
|
||||
ts += n;
|
||||
FILE_LOG(level) << "tau sent. " << n << " bytes. serialno: " << myMod->tau;
|
||||
FILE_LOG(level) << "tau sent. " << n << " bytes. tau: " << myMod->tau;
|
||||
|
||||
n = client.Send(&(myMod->eV), sizeof(myMod->eV));
|
||||
ts += n;
|
||||
FILE_LOG(level) << "ev sent. " << n << " bytes. serialno: " << myMod->eV;
|
||||
FILE_LOG(level) << "ev sent. " << n << " bytes. ev: " << myMod->eV;
|
||||
|
||||
n = client.Send(myMod->dacs, sizeof(int) * (myMod->ndac));
|
||||
ts += n;
|
||||
@ -548,7 +550,7 @@ slsDetectorDefs::detectorType slsDetector::getDetectorTypeAsEnum() const {
|
||||
}
|
||||
|
||||
std::string slsDetector::getDetectorTypeAsString() const {
|
||||
return slsDetectorDefs::detectorTypeToString(getDetectorTypeAsEnum());
|
||||
return ToString(getDetectorTypeAsEnum());
|
||||
}
|
||||
|
||||
void slsDetector::updateNumberOfChannels() {
|
||||
@ -695,8 +697,8 @@ bool slsDetector::lockServer(int lock) {
|
||||
return (retval == 1 ? true : false);
|
||||
}
|
||||
|
||||
std::string slsDetector::getLastClientIP() {
|
||||
char retval[INET_ADDRSTRLEN]{};
|
||||
sls::IpAddr slsDetector::getLastClientIP() {
|
||||
sls::IpAddr retval = 0u;
|
||||
FILE_LOG(logDEBUG1) << "Getting last client ip to detector server";
|
||||
sendToDetector(F_GET_LAST_CLIENT_IP, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "Last client IP to detector: " << retval;
|
||||
@ -728,8 +730,8 @@ void slsDetector::updateCachedDetectorVariables() {
|
||||
FORCE_UPDATE) {
|
||||
int n = 0, i32 = 0;
|
||||
int64_t i64 = 0;
|
||||
char lastClientIP[INET_ADDRSTRLEN] = {0};
|
||||
n += client.Receive(lastClientIP, sizeof(lastClientIP));
|
||||
sls::IpAddr lastClientIP = 0u;
|
||||
n += client.Receive(&lastClientIP, sizeof(lastClientIP));
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "Updating detector last modified by " << lastClientIP;
|
||||
|
||||
@ -787,9 +789,9 @@ void slsDetector::updateCachedDetectorVariables() {
|
||||
shm()->timerValue[STORAGE_CELL_DELAY] = i64;
|
||||
}
|
||||
|
||||
// cycles
|
||||
// triggers
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->timerValue[CYCLES_NUMBER] = i64;
|
||||
shm()->timerValue[TRIGGER_NUMBER] = i64;
|
||||
|
||||
// readout mode
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD) {
|
||||
@ -934,7 +936,7 @@ slsDetector::setSettings(detectorSettings isettings) {
|
||||
return shm()->currentSettings;
|
||||
default:
|
||||
std::ostringstream ss;
|
||||
ss << "Unknown settings " << getDetectorSettings(isettings)
|
||||
ss << "Unknown settings " << ToString(isettings)
|
||||
<< " for this detector!";
|
||||
throw RuntimeError(ss.str());
|
||||
}
|
||||
@ -1088,7 +1090,7 @@ std::string slsDetector::getTrimbitFilename(detectorSettings s, int e_eV) {
|
||||
break;
|
||||
default:
|
||||
std::ostringstream ss;
|
||||
ss << "Unknown settings " << getDetectorSettings(s)
|
||||
ss << "Unknown settings " << ToString(s)
|
||||
<< " for this detector!";
|
||||
throw RuntimeError(ss.str());
|
||||
}
|
||||
@ -1146,7 +1148,7 @@ slsDetectorDefs::runStatus slsDetector::getRunStatus() const {
|
||||
runStatus retval = ERROR;
|
||||
FILE_LOG(logDEBUG1) << "Getting status";
|
||||
sendToDetectorStop(F_GET_RUN_STATUS, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "Detector status: " << runStatusType(retval);
|
||||
FILE_LOG(logDEBUG1) << "Detector status: " << ToString(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -1202,116 +1204,6 @@ void slsDetector::readAll() {
|
||||
FILE_LOG(logDEBUG1) << "Detector successfully finished reading all frames";
|
||||
}
|
||||
|
||||
/*
|
||||
void slsDetector::configureMAC() {
|
||||
int fnum = F_CONFIGURE_MAC;
|
||||
const size_t array_size = 50;
|
||||
const size_t n_args = 14;
|
||||
const size_t n_retvals = 2;
|
||||
char args[n_args][array_size]{};
|
||||
char retvals[n_retvals][array_size]{};
|
||||
FILE_LOG(logDEBUG1) << "Configuring MAC";
|
||||
if (shm()->rxUDPIP == 0) {
|
||||
// If hostname is valid ip use that, oterwise lookup hostname
|
||||
shm()->rxUDPIP = shm()->rxHostname;
|
||||
if (shm()->rxUDPIP == 0) {
|
||||
shm()->rxUDPIP = HostnameToIp(shm()->rxHostname);
|
||||
}
|
||||
}
|
||||
|
||||
if (shm()->rxUDPMAC == 0) {
|
||||
throw RuntimeError(
|
||||
"configureMAC: Error. Receiver UDP MAC Addresses not set");
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "rx_hostname and rx_udpmac are valid ";
|
||||
|
||||
// Jungfrau second interface
|
||||
if (shm()->numUDPInterfaces == 2) {
|
||||
if (shm()->rxUDPIP2 == 0) {
|
||||
shm()->rxUDPIP2 = shm()->rxUDPIP;
|
||||
}
|
||||
if (shm()->rxUDPMAC2 == 0) {
|
||||
throw RuntimeError(
|
||||
"configureMAC: Error. Receiver UDP MAC Addresses 2 not set");
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "rx_udpmac2 is valid ";
|
||||
}
|
||||
|
||||
// copy to args and convert to hex
|
||||
snprintf(args[0], array_size, "%x", shm()->rxUDPPort);
|
||||
sls::strcpy_safe(args[1], getReceiverUDPIP().hex());
|
||||
sls::strcpy_safe(args[2], getReceiverUDPMAC().hex());
|
||||
sls::strcpy_safe(args[3], getDetectorIP().hex());
|
||||
sls::strcpy_safe(args[4], getDetectorMAC().hex());
|
||||
snprintf(args[5], array_size, "%x", shm()->rxUDPPort2);
|
||||
sls::strcpy_safe(args[6], getReceiverUDPIP2().hex());
|
||||
sls::strcpy_safe(args[7], getReceiverUDPMAC2().hex());
|
||||
sls::strcpy_safe(args[8], getDetectorIP2().hex());
|
||||
sls::strcpy_safe(args[9], getDetectorMAC2().hex());
|
||||
snprintf(args[10], array_size, "%x", shm()->numUDPInterfaces);
|
||||
snprintf(args[11], array_size, "%x", shm()->selectedUDPInterface);
|
||||
|
||||
// 2d positions to detector to put into udp header
|
||||
{
|
||||
int pos[2] = {0, 0};
|
||||
int max = shm()->multiSize.y * (shm()->numUDPInterfaces);
|
||||
// row
|
||||
pos[0] = (detId % max);
|
||||
// col for horiz. udp ports
|
||||
pos[1] = (detId / max) * ((shm()->myDetectorType == EIGER) ? 2 : 1);
|
||||
// pos[2] (z is reserved)
|
||||
FILE_LOG(logDEBUG) << "Detector [" << detId << "] - (" << pos[0] << ","
|
||||
<< pos[1] << ")";
|
||||
snprintf(args[12], array_size, "%x", pos[0]);
|
||||
snprintf(args[13], array_size, "%x", pos[1]);
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1) << "receiver udp port:" << std::dec << args[0] << "-";
|
||||
FILE_LOG(logDEBUG1) << "receiver udp ip:" << args[1] << "-";
|
||||
FILE_LOG(logDEBUG1) << "receiver udp mac:" << args[2] << "-";
|
||||
FILE_LOG(logDEBUG1) << "detecotor udp ip:" << args[3] << "-";
|
||||
FILE_LOG(logDEBUG1) << "detector udp mac:" << args[4] << "-";
|
||||
FILE_LOG(logDEBUG1) << "receiver udp port2:" << std::dec << args[5] << "-";
|
||||
FILE_LOG(logDEBUG1) << "receiver udp ip2:" << args[6] << "-";
|
||||
FILE_LOG(logDEBUG1) << "receiver udp mac2:" << args[7] << "-";
|
||||
FILE_LOG(logDEBUG1) << "detecotor udp ip2:" << args[8] << "-";
|
||||
FILE_LOG(logDEBUG1) << "detector udp mac2:" << args[9] << "-";
|
||||
FILE_LOG(logDEBUG1) << "number of udp interfaces:" << std::dec << args[10]
|
||||
<< "-";
|
||||
FILE_LOG(logDEBUG1) << "selected udp interface:" << std::dec << args[11]
|
||||
<< "-";
|
||||
FILE_LOG(logDEBUG1) << "row:" << args[12] << "-";
|
||||
FILE_LOG(logDEBUG1) << "col:" << args[13] << "-";
|
||||
|
||||
// send to server
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
int ret = client.sendCommandThenRead(fnum, args, sizeof(args), retvals,
|
||||
sizeof(retvals));
|
||||
|
||||
// TODO!(Erik) Send as int already from detector
|
||||
uint64_t detector_mac = 0;
|
||||
uint32_t detector_ip = 0;
|
||||
sscanf(retvals[0], "%lx", &detector_mac);
|
||||
sscanf(retvals[1], "%x", &detector_ip);
|
||||
detector_ip = __builtin_bswap32(detector_ip);
|
||||
|
||||
if (shm()->detectorMAC != detector_mac) {
|
||||
shm()->detectorMAC = detector_mac;
|
||||
FILE_LOG(logINFO) << detId << ": Detector MAC updated to "
|
||||
<< getDetectorMAC();
|
||||
}
|
||||
|
||||
if (shm()->detectorIP != detector_ip) {
|
||||
shm()->detectorIP = detector_ip;
|
||||
FILE_LOG(logINFO) << detId << ": Detector IP updated to "
|
||||
<< getDetectorIP();
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
updateCachedDetectorVariables();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void slsDetector::setStartingFrameNumber(uint64_t value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting starting frame number to " << value;
|
||||
sendToDetector(F_SET_STARTING_FRAME_NUMBER, value, nullptr);
|
||||
@ -1361,7 +1253,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
if (shm()->useReceiverFlag) {
|
||||
timerIndex rt[]{FRAME_NUMBER,
|
||||
FRAME_PERIOD,
|
||||
CYCLES_NUMBER,
|
||||
TRIGGER_NUMBER,
|
||||
ACQUISITION_TIME,
|
||||
SUBFRAME_ACQUISITION_TIME,
|
||||
SUBFRAME_DEADTIME,
|
||||
@ -1376,11 +1268,11 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
retval = -1;
|
||||
|
||||
// rewrite args
|
||||
if ((index == FRAME_NUMBER) || (index == CYCLES_NUMBER) ||
|
||||
if ((index == FRAME_NUMBER) || (index == TRIGGER_NUMBER) ||
|
||||
(index == STORAGE_CELL_NUMBER)) {
|
||||
args[1] = shm()->timerValue[FRAME_NUMBER] *
|
||||
((shm()->timerValue[CYCLES_NUMBER] > 0)
|
||||
? (shm()->timerValue[CYCLES_NUMBER])
|
||||
((shm()->timerValue[TRIGGER_NUMBER] > 0)
|
||||
? (shm()->timerValue[TRIGGER_NUMBER])
|
||||
: 1) *
|
||||
((shm()->timerValue[STORAGE_CELL_NUMBER] > 0)
|
||||
? (shm()->timerValue[STORAGE_CELL_NUMBER]) + 1
|
||||
@ -1388,9 +1280,9 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
}
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "Sending "
|
||||
<< (((index == FRAME_NUMBER) || (index == CYCLES_NUMBER) ||
|
||||
<< (((index == FRAME_NUMBER) || (index == TRIGGER_NUMBER) ||
|
||||
(index == STORAGE_CELL_NUMBER))
|
||||
? "(#Frames) * (#cycles) * (#storage cells)"
|
||||
? "(#Frames) * (#triggers) * (#storage cells)"
|
||||
: getTimerType(index))
|
||||
<< " to receiver: " << args[1];
|
||||
|
||||
@ -1630,7 +1522,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
|
||||
FILE_LOG(logDEBUG)
|
||||
<< "detector type:"
|
||||
<< (slsDetectorDefs::detectorTypeToString(shm()->myDetectorType))
|
||||
<< (ToString(shm()->myDetectorType))
|
||||
<< "\ndetector id:" << detId
|
||||
<< "\ndetector hostname:" << shm()->hostname
|
||||
<< "\nfile path:" << shm()->rxFilePath
|
||||
@ -1645,7 +1537,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
<< "\noverwrite enable:" << shm()->rxFileOverWrite
|
||||
<< "\nframe index needed:"
|
||||
<< ((shm()->timerValue[FRAME_NUMBER] *
|
||||
shm()->timerValue[CYCLES_NUMBER]) > 1)
|
||||
shm()->timerValue[TRIGGER_NUMBER]) > 1)
|
||||
<< "\nframe period:" << (shm()->timerValue[FRAME_PERIOD])
|
||||
<< "\nframe number:" << (shm()->timerValue[FRAME_NUMBER])
|
||||
<< "\nsub exp time:" << (shm()->timerValue[SUBFRAME_ACQUISITION_TIME])
|
||||
@ -1745,7 +1637,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
// data streaming
|
||||
setReceiverStreamingFrequency(shm()->rxReadFreq);
|
||||
setReceiverStreamingPort(getReceiverStreamingPort());
|
||||
setReceiverStreamingIP(getReceiverStreamingIP());
|
||||
updateReceiverStreamingIP();
|
||||
setAdditionalJsonHeader(shm()->rxAdditionalJsonHeader);
|
||||
enableDataStreamingFromReceiver(
|
||||
static_cast<int>(enableDataStreamingFromReceiver(-1)));
|
||||
@ -1826,7 +1718,7 @@ sls::IpAddr slsDetector::getSourceUDPIP2() {
|
||||
|
||||
void slsDetector::setDestinationUDPIP(const IpAddr ip) {
|
||||
FILE_LOG(logDEBUG1) << "Setting destination udp ip to " << ip;
|
||||
if (ip == 0) {
|
||||
if (ip == 0) {
|
||||
throw RuntimeError("Invalid destination udp ip address");
|
||||
}
|
||||
sendToDetector(F_SET_DEST_UDP_IP, ip, nullptr);
|
||||
@ -2011,31 +1903,23 @@ void slsDetector::setReceiverStreamingPort(int port) {
|
||||
|
||||
int slsDetector::getReceiverStreamingPort() { return shm()->rxZmqport; }
|
||||
|
||||
void slsDetector::setClientStreamingIP(const std::string &sourceIP) {
|
||||
auto ip = HostnameToIp(sourceIP.c_str());
|
||||
if (ip != 0) {
|
||||
shm()->zmqip = ip;
|
||||
} else {
|
||||
throw sls::RuntimeError("Could not set zmqip");
|
||||
}
|
||||
void slsDetector::setClientStreamingIP(const sls::IpAddr ip) {
|
||||
FILE_LOG(logDEBUG1) << "Setting client zmq ip to " << ip;
|
||||
if (ip == 0) {
|
||||
throw RuntimeError("Invalid client zmq ip address");
|
||||
}
|
||||
shm()->zmqip = ip;
|
||||
}
|
||||
|
||||
std::string slsDetector::getClientStreamingIP() { return shm()->zmqip.str(); }
|
||||
sls::IpAddr slsDetector::getClientStreamingIP() { return shm()->zmqip; }
|
||||
|
||||
void slsDetector::setReceiverStreamingIP(std::string sourceIP) {
|
||||
// if empty, give rx_hostname
|
||||
if (sourceIP.empty() || sourceIP == "0.0.0.0") {
|
||||
if (strcmp(shm()->rxHostname, "none") == 0) {
|
||||
throw RuntimeError("Receiver hostname not set yet. Cannot create "
|
||||
"rx_zmqip from none");
|
||||
}
|
||||
sourceIP = shm()->rxHostname;
|
||||
void slsDetector::setReceiverStreamingIP(const sls::IpAddr ip) {
|
||||
FILE_LOG(logDEBUG1) << "Setting rx zmq ip to " << ip;
|
||||
if (ip == 0) {
|
||||
throw RuntimeError("Invalid receiver zmq ip address");
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1) << "Sending receiver streaming IP to receiver: "
|
||||
<< sourceIP;
|
||||
shm()->rxZmqip = HostnameToIp(sourceIP.c_str());
|
||||
|
||||
shm()->rxZmqip = ip;
|
||||
|
||||
// if zmqip is empty, update it
|
||||
if (shm()->zmqip == 0) {
|
||||
shm()->zmqip = shm()->rxZmqip;
|
||||
@ -2043,19 +1927,27 @@ void slsDetector::setReceiverStreamingIP(std::string sourceIP) {
|
||||
|
||||
// send to receiver
|
||||
if (shm()->useReceiverFlag) {
|
||||
char retvals[MAX_STR_LENGTH]{};
|
||||
char args[MAX_STR_LENGTH]{};
|
||||
sls::strcpy_safe(args, shm()->rxZmqip.str()); // TODO send int
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "Sending receiver streaming IP to receiver: " << args;
|
||||
sendToReceiver(F_RECEIVER_STREAMING_SRC_IP, args, retvals);
|
||||
FILE_LOG(logDEBUG1) << "Receiver streaming ip: " << retvals;
|
||||
shm()->rxZmqip = retvals;
|
||||
<< "Sending receiver streaming IP to receiver: " << ip;
|
||||
sendToReceiver(F_RECEIVER_STREAMING_SRC_IP, ip, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
std::string slsDetector::getReceiverStreamingIP() {
|
||||
return shm()->rxZmqip.str();
|
||||
sls::IpAddr slsDetector::getReceiverStreamingIP() {
|
||||
return shm()->rxZmqip;
|
||||
}
|
||||
|
||||
void slsDetector::updateReceiverStreamingIP() {
|
||||
auto ip = getReceiverStreamingIP();
|
||||
if (ip == 0) {
|
||||
// Hostname could be ip try to decode otherwise look up the hostname
|
||||
ip = shm()->rxHostname;
|
||||
if (ip == 0) {
|
||||
ip = HostnameToIp(shm()->rxHostname);
|
||||
}
|
||||
FILE_LOG(logINFO) << "Setting default receiver streaming zmq ip to " << ip;
|
||||
}
|
||||
setReceiverStreamingIP(ip);
|
||||
}
|
||||
|
||||
int slsDetector::setDetectorNetworkParameter(networkParameter index,
|
||||
@ -2834,8 +2726,8 @@ int slsDetector::lockReceiver(int lock) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::string slsDetector::getReceiverLastClientIP() const {
|
||||
char retval[INET_ADDRSTRLEN]{};
|
||||
sls::IpAddr slsDetector::getReceiverLastClientIP() const {
|
||||
sls::IpAddr retval = 0u;
|
||||
FILE_LOG(logDEBUG1) << "Getting last client ip to receiver server";
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(F_GET_LAST_RECEIVER_CLIENT_IP, nullptr, retval);
|
||||
@ -2871,12 +2763,13 @@ void slsDetector::updateCachedReceiverVariables() const {
|
||||
sls::ClientSocket("Receiver", shm()->rxHostname, shm()->rxTCPPort);
|
||||
receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
|
||||
int n = 0, i32 = 0;
|
||||
int64_t i64 = 0;
|
||||
char cstring[MAX_STR_LENGTH]{};
|
||||
char lastClientIP[INET_ADDRSTRLEN]{};
|
||||
IpAddr ip = 0u;
|
||||
|
||||
n += receiver.Receive(lastClientIP, sizeof(lastClientIP));
|
||||
n += receiver.Receive(&ip, sizeof(ip));
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "Updating receiver last modified by " << lastClientIP;
|
||||
<< "Updating receiver last modified by " << ip;
|
||||
|
||||
// filepath
|
||||
n += receiver.Receive(cstring, sizeof(cstring));
|
||||
@ -2887,8 +2780,8 @@ void slsDetector::updateCachedReceiverVariables() const {
|
||||
sls::strcpy_safe(shm()->rxFileName, cstring);
|
||||
|
||||
// index
|
||||
n += receiver.Receive(&i32, sizeof(i32));
|
||||
shm()->rxFileIndex = i32;
|
||||
n += receiver.Receive(&i64, sizeof(i64));
|
||||
shm()->rxFileIndex = i64;
|
||||
|
||||
// file format
|
||||
n += receiver.Receive(&i32, sizeof(i32));
|
||||
@ -2931,8 +2824,8 @@ void slsDetector::updateCachedReceiverVariables() const {
|
||||
shm()->rxZmqport = i32;
|
||||
|
||||
// streaming source ip
|
||||
n += receiver.Receive(cstring, sizeof(cstring));
|
||||
shm()->rxZmqip = cstring;
|
||||
n += receiver.Receive(&ip, sizeof(ip));
|
||||
shm()->rxZmqip = ip;
|
||||
|
||||
// additional json header
|
||||
n += receiver.Receive(cstring, sizeof(cstring));
|
||||
@ -3102,9 +2995,9 @@ slsDetectorDefs::fileFormat slsDetector::getFileFormat() const {
|
||||
return shm()->rxFileFormat;
|
||||
}
|
||||
|
||||
int slsDetector::setFileIndex(int file_index) {
|
||||
int64_t slsDetector::setFileIndex(int64_t file_index) {
|
||||
if (F_SET_RECEIVER_FILE_INDEX >= 0) {
|
||||
int retval = -1;
|
||||
int64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Setting file index to " << file_index;
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(F_SET_RECEIVER_FILE_INDEX, file_index, retval);
|
||||
@ -3115,9 +3008,9 @@ int slsDetector::setFileIndex(int file_index) {
|
||||
return getFileIndex();
|
||||
}
|
||||
|
||||
int slsDetector::getFileIndex() const { return shm()->rxFileIndex; }
|
||||
int64_t slsDetector::getFileIndex() const { return shm()->rxFileIndex; }
|
||||
|
||||
int slsDetector::incrementFileIndex() {
|
||||
int64_t slsDetector::incrementFileIndex() {
|
||||
if (shm()->rxFileWrite) {
|
||||
return setFileIndex(shm()->rxFileIndex + 1);
|
||||
}
|
||||
@ -3143,7 +3036,7 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus() const {
|
||||
FILE_LOG(logDEBUG1) << "Getting Receiver Status";
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(F_GET_RECEIVER_STATUS, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "Receiver Status: " << runStatusType(retval);
|
||||
FILE_LOG(logDEBUG1) << "Receiver Status: " << ToString(retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -143,8 +143,8 @@ int64_t slsDetectorUsers::setNumberOfFrames(int64_t t, int detPos){
|
||||
return detector.setNumberOfFrames(t, detPos);
|
||||
}
|
||||
|
||||
int64_t slsDetectorUsers::setNumberOfCycles(int64_t t, int detPos){
|
||||
return detector.setNumberOfCycles(t, detPos);
|
||||
int64_t slsDetectorUsers::setNumberOfTriggers(int64_t t, int detPos){
|
||||
return detector.setNumberOfTriggers(t, detPos);
|
||||
}
|
||||
|
||||
int64_t slsDetectorUsers::setNumberOfStorageCells(int64_t t, int detPos) {
|
||||
|
Reference in New Issue
Block a user