mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
parent
2c5ff0e9bf
commit
9a48d9b832
@ -1,12 +1,78 @@
|
||||
#pragma once
|
||||
|
||||
#include "Detector.h"
|
||||
#include "Result.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/** Macro to make an integer command.
|
||||
* CMDNAME name of the function that does the command
|
||||
* GETFCN Detector function to get
|
||||
* SETFCN Detector function to set
|
||||
* CONV Function to convert from string to the correct integer type
|
||||
* HLPSTR Help string for --help and docs
|
||||
*/
|
||||
|
||||
#define INTEGER_COMMAND(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
||||
std::string CMDNAME(const int action) { \
|
||||
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 { \
|
||||
WrongNumberOfParameters(2); \
|
||||
} \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() == 1) { \
|
||||
auto val = CONV(args[0]); \
|
||||
det->SETFCN(val, {det_id}); \
|
||||
os << args.front() << '\n'; \
|
||||
} else { \
|
||||
WrongNumberOfParameters(1); \
|
||||
} \
|
||||
\
|
||||
} else { \
|
||||
throw sls::RuntimeError("Unknown action"); \
|
||||
} \
|
||||
return os.str(); \
|
||||
}
|
||||
|
||||
#define INTEGER_COMMAND_NOID(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
||||
std::string CMDNAME(const int action) { \
|
||||
std::ostringstream os; \
|
||||
os << cmd << ' '; \
|
||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||
os << HLPSTR << '\n'; \
|
||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||
auto t = det->GETFCN(); \
|
||||
if (args.size() == 0) { \
|
||||
os << OutString(t) << '\n'; \
|
||||
} else { \
|
||||
WrongNumberOfParameters(2); \
|
||||
} \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() == 1) { \
|
||||
auto val = CONV(args[0]); \
|
||||
det->SETFCN(val); \
|
||||
os << args.front() << '\n'; \
|
||||
} else { \
|
||||
WrongNumberOfParameters(1); \
|
||||
} \
|
||||
\
|
||||
} else { \
|
||||
throw sls::RuntimeError("Unknown action"); \
|
||||
} \
|
||||
return os.str(); \
|
||||
}
|
||||
|
||||
namespace sls {
|
||||
class Detector;
|
||||
|
||||
class CmdProxy {
|
||||
public:
|
||||
@ -27,9 +93,17 @@ class CmdProxy {
|
||||
std::vector<std::string> args;
|
||||
int det_id{-1};
|
||||
|
||||
template <typename V> std::string OutString(const V &value);
|
||||
template <typename V> std::string OutString(const V &value) {
|
||||
if (value.equal())
|
||||
return ToString(value.front());
|
||||
return ToString(value);
|
||||
}
|
||||
template <typename V>
|
||||
std::string OutString(const V &value, const std::string &unit);
|
||||
std::string OutString(const V &value, const std::string &unit) {
|
||||
if (value.equal())
|
||||
return ToString(value.front(), unit);
|
||||
return ToString(value, unit);
|
||||
}
|
||||
|
||||
using FunctionMap = std::map<std::string, std::string (CmdProxy::*)(int)>;
|
||||
using StringMap = std::map<std::string, std::string>;
|
||||
@ -39,8 +113,18 @@ class CmdProxy {
|
||||
{"exptime", &CmdProxy::Exptime},
|
||||
{"period", &CmdProxy::Period},
|
||||
{"subexptime", &CmdProxy::SubExptime},
|
||||
{"rx_fifodepth", &CmdProxy::RxFifoDepth},
|
||||
{"rx_silent", &CmdProxy::RxSilent}};
|
||||
{"frames", &CmdProxy::frames},
|
||||
{"fwrite", &CmdProxy::fwrite},
|
||||
{"fmaster", &CmdProxy::fmaster},
|
||||
{"foverwrite", &CmdProxy::foverwrite},
|
||||
{"findex", &CmdProxy::findex},
|
||||
{"rx_fifodepth", &CmdProxy::rx_fifodepth},
|
||||
{"rx_silent", &CmdProxy::rx_silent},
|
||||
{"rx_lock", &CmdProxy::rx_lock},
|
||||
{"lock", &CmdProxy::lock},
|
||||
{"rx_readfreq", &CmdProxy::rx_readfreq},
|
||||
{"rx_padding", &CmdProxy::rx_padding},
|
||||
{"rx_framesperfile", &CmdProxy::rx_framesperfile}};
|
||||
|
||||
StringMap depreciated_functions{{"r_readfreq", "rx_readfreq"},
|
||||
{"r_padding", "rx_padding"},
|
||||
@ -69,8 +153,46 @@ class CmdProxy {
|
||||
std::string Period(int action);
|
||||
std::string Exptime(int action);
|
||||
std::string SubExptime(int action);
|
||||
std::string RxFifoDepth(const int action);
|
||||
std::string RxSilent(const int action);
|
||||
|
||||
INTEGER_COMMAND(
|
||||
rx_fifodepth, getRxFifoDepth, setRxFifoDepth, std::stoi,
|
||||
"[n_frames]\n\tSet the number of frames in the receiver fifo");
|
||||
|
||||
INTEGER_COMMAND(rx_silent, getRxSilentMode, setRxSilentMode, std::stoi,
|
||||
"[0, 1]\n\tSwitch on or off receiver text output");
|
||||
|
||||
INTEGER_COMMAND(rx_lock, getRxLock, setRxLock, std::stoi,
|
||||
"[0, 1]\n\tLock receiver to one IP, 1: locks");
|
||||
|
||||
INTEGER_COMMAND(lock, getDetectorLock, setDetectorLock, std::stoi,
|
||||
"[0, 1]\n\tLock detector to one IP, 1: locks");
|
||||
|
||||
INTEGER_COMMAND(rx_readfreq, getRxZmqFrequency, setRxZmqFrequency,
|
||||
std::stoi, "[nth frame]\n\tStream out every nth frame");
|
||||
|
||||
INTEGER_COMMAND(rx_padding, getPartialFramesPadding,
|
||||
setPartialFramesPadding, std::stoi,
|
||||
"[0, 1]\n\tgets partial frames padding enable in the "
|
||||
"receiver. 0 does not pad partial frames(fastest), 1 "
|
||||
"(default) pads partial frames");
|
||||
INTEGER_COMMAND(rx_framesperfile, getFramesPerFile, setFramesPerFile,
|
||||
std::stoi, "[n_frames]\n\tNumber of frames per file");
|
||||
|
||||
INTEGER_COMMAND_NOID(frames, getNumberOfFrames, setNumberOfFrames,
|
||||
std::stol,
|
||||
"[n_frames]\n\tNumber of frames per aquire");
|
||||
|
||||
INTEGER_COMMAND(fwrite, getFileWrite, setFileWrite, std::stoi,
|
||||
"[0, 1]\n\tEnable or disable receiver file write");
|
||||
|
||||
INTEGER_COMMAND(fmaster, getMasterFileWrite, setMasterFileWrite, std::stoi,
|
||||
"[0, 1]\n\tEnable or disable receiver master file");
|
||||
|
||||
INTEGER_COMMAND(foverwrite, getFileOverWrite, setFileOverWrite, std::stoi,
|
||||
"[0, 1]\n\tEnable or disable file overwriting");
|
||||
|
||||
INTEGER_COMMAND(findex, getAcquisitionIndex, setAcquisitionIndex, std::stoi,
|
||||
"[0, 1]\n\tFile index");
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
@ -488,7 +488,7 @@ class Detector {
|
||||
*/
|
||||
void setFileNamePrefix(const std::string &fname, Positions pos = {});
|
||||
|
||||
Result<int> getAcquisitonIndex(Positions pos = {}) const;
|
||||
Result<int> getAcquisitionIndex(Positions pos = {}) const;
|
||||
|
||||
void setAcquisitionIndex(int i, Positions pos = {});
|
||||
|
||||
|
@ -52,12 +52,10 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
static std::string helpTrimEn(int action);
|
||||
static std::string helpOutDir(int action);
|
||||
static std::string helpFileName(int action);
|
||||
static std::string helpFileIndex(int action);
|
||||
static std::string helpRateCorr(int action);
|
||||
static std::string helpThreaded(int action);
|
||||
static std::string helpNetworkParameter(int action);
|
||||
static std::string helpPort(int action);
|
||||
static std::string helpLock(int action);
|
||||
static std::string helpLastClient(int action);
|
||||
static std::string helpOnline(int action);
|
||||
static std::string helpConfigureMac(int action);
|
||||
@ -76,26 +74,12 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
static std::string helpCounter(int action);
|
||||
static std::string helpADC(int action);
|
||||
static std::string helpTempControl(int action);
|
||||
static std::string helpEnablefwrite(int action);
|
||||
static std::string helpOverwrite(int action);
|
||||
static std::string helpReceiver(int action);
|
||||
static std::string helpPattern(int action);
|
||||
static std::string helpPulse(int action);
|
||||
static std::string helpProcessor(int action);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
multiSlsDetector *myDet;
|
||||
|
||||
std::string cmdUnderDevelopment(int narg, const char * const args[], int action, int detPos = -1);
|
||||
@ -113,11 +97,9 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
std::string cmdTrimEn(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdOutDir(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdFileName(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdFileIndex(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdRateCorr(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdNetworkParameter(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdPort(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdLock(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdLastClient(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdOnline(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdConfigureMac(int narg, const char * const args[], int action, int detPos = -1);
|
||||
@ -136,8 +118,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
std::string cmdCounter(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdADC(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdTempControl(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdEnablefwrite(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdOverwrite(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdReceiver(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdPattern(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdPulse(int narg, const char * const args[], int action, int detPos = -1);
|
||||
|
@ -1,20 +1,18 @@
|
||||
#include "CmdProxy.h"
|
||||
#include "Detector.h"
|
||||
#include "Result.h"
|
||||
|
||||
|
||||
#include "TimeHelper.h"
|
||||
#include "ToString.h"
|
||||
#include "logger.h"
|
||||
#include "slsDetectorCommand.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
#define TIME_COMMAND(GETFCN, SETFCN, HLPSTR) \
|
||||
std::ostringstream os; \
|
||||
os << cmd << ' '; \
|
||||
@ -47,31 +45,7 @@
|
||||
} \
|
||||
return os.str();
|
||||
|
||||
#define INTEGER_COMMAND(GETFCN, SETFCN, CONV, 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 { \
|
||||
WrongNumberOfParameters(2); \
|
||||
} \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() == 1) { \
|
||||
auto val = CONV(args[0]); \
|
||||
det->SETFCN(val, {det_id}); \
|
||||
os << args.front() << '\n'; \
|
||||
} else { \
|
||||
WrongNumberOfParameters(1); \
|
||||
} \
|
||||
\
|
||||
} else { \
|
||||
throw sls::RuntimeError("Unknown action"); \
|
||||
} \
|
||||
return os.str();
|
||||
|
||||
|
||||
namespace sls {
|
||||
|
||||
@ -139,17 +113,7 @@ void CmdProxy::WrongNumberOfParameters(size_t expected) {
|
||||
" parameter/s but got " + std::to_string(args.size()) + "\n");
|
||||
}
|
||||
|
||||
template <typename V> std::string CmdProxy::OutString(const V &value) {
|
||||
if (value.equal())
|
||||
return ToString(value.front());
|
||||
return ToString(value);
|
||||
}
|
||||
template <typename V>
|
||||
std::string CmdProxy::OutString(const V &value, const std::string &unit) {
|
||||
if (value.equal())
|
||||
return ToString(value.front(), unit);
|
||||
return ToString(value, unit);
|
||||
}
|
||||
|
||||
|
||||
/************************************************
|
||||
* *
|
||||
@ -172,16 +136,8 @@ std::string CmdProxy::SubExptime(int action) {
|
||||
"exposure time of EIGER subframes");
|
||||
}
|
||||
|
||||
std::string CmdProxy::RxFifoDepth(const int action) {
|
||||
INTEGER_COMMAND(
|
||||
getRxFifoDepth, setRxFifoDepth, std::stoi,
|
||||
"[n_frames]\n\tSet the number of frames in the receiver fifo");
|
||||
}
|
||||
|
||||
std::string CmdProxy::RxSilent(const int action) {
|
||||
INTEGER_COMMAND(getRxSilentMode, setRxSilentMode, std::stoi,
|
||||
"[0, 1]\n\tSwitch on or off receiver text output");
|
||||
}
|
||||
|
||||
|
||||
std::string CmdProxy::ListCommands(int action) {
|
||||
if (action == slsDetectorDefs::HELP_ACTION)
|
||||
|
@ -578,7 +578,7 @@ void Detector::setFileNamePrefix(const std::string &fname, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setFileName, pos, fname);
|
||||
}
|
||||
|
||||
Result<int> Detector::getAcquisitonIndex(Positions pos) const {
|
||||
Result<int> Detector::getAcquisitionIndex(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getFileIndex, pos);
|
||||
}
|
||||
|
||||
@ -631,7 +631,7 @@ void Detector::setRxZmqDataStream(bool enable, Positions pos) {
|
||||
}
|
||||
|
||||
Result<int> Detector::getRxZmqFrequency(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setReceiverStreamingTimer, pos, -1);
|
||||
return pimpl->Parallel(&slsDetector::setReceiverStreamingFrequency, pos, -1);
|
||||
}
|
||||
|
||||
void Detector::setRxZmqFrequency(int freq, Positions pos) {
|
||||
|
@ -548,12 +548,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
|
||||
++i;
|
||||
|
||||
/*! \page timing
|
||||
- <b>frames [i]</b> sets/gets number of frames. If \c timing is not \c auto, then it is the number of frames per cycle/trigger. \c Returns \c (long long int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "frames";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
|
||||
++i;
|
||||
|
||||
/*! \page timing
|
||||
- <b>startingfnum [i]</b> sets/gets starting frame number for the next acquisition. Only for Jungfrau and Eiger. \c Returns \c (long long int)
|
||||
@ -1481,27 +1475,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdFileName;
|
||||
++i;
|
||||
|
||||
/*! \page output
|
||||
- <b>findex [i]</b> Sets/gets the current file index. \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "findex";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdFileIndex;
|
||||
++i;
|
||||
|
||||
/*! \page output
|
||||
- <b>fwrite [i]</b> Enables/disables file writing. 1 enables, 0 disables. \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "fwrite";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdEnablefwrite;
|
||||
++i;
|
||||
|
||||
/*! \page output
|
||||
- <b>foverwrite [i]</b> enables(1) /disables(0) file overwriting. \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "foverwrite";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdOverwrite;
|
||||
++i;
|
||||
|
||||
/*! \page output
|
||||
- <b>fformat [i]</b> sets/gets the file format for data in receiver. Options: [binary, hdf5]. \c Returns \c (string)
|
||||
*/
|
||||
@ -1509,13 +1482,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdFileName;
|
||||
++i;
|
||||
|
||||
/*! \page output
|
||||
- <b>fmaster [i]</b> sets/gets the master file write enable in receiver. \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "fmaster";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdEnablefwrite;
|
||||
++i;
|
||||
|
||||
/* communication configuration */
|
||||
|
||||
/*! \page network Network
|
||||
@ -1715,13 +1681,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPort;
|
||||
++i;
|
||||
|
||||
/*! \page network
|
||||
- <b>lock [i]</b> Locks/Unlocks the detector to communicate with this client. 1 locks, 0 unlocks. \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "lock";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdLock;
|
||||
++i;
|
||||
|
||||
/*! \page network
|
||||
- <b>lastclient </b> Gets the last client communicating with the detector. Cannot put!. \c Returns \c (string)
|
||||
*/
|
||||
@ -1763,13 +1722,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
|
||||
++i;
|
||||
|
||||
/*! \page receiver
|
||||
- <b>rx_lock [i]</b> locks/unlocks the receiver to communicate with only this client. 1 locks, 0 unlocks. \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "rx_lock";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdLock;
|
||||
++i;
|
||||
|
||||
/*! \page receiver
|
||||
- <b>rx_lastclient</b> gets the last client communicating with the receiver. Only get! \c Returns \c (int)
|
||||
*/
|
||||
@ -1777,14 +1729,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdLastClient;
|
||||
++i;
|
||||
|
||||
/*! \page receiver
|
||||
- <b>rx_readfreq [i]</b> sets/gets the stream frequency of data from receiver to client. i > 0 is the nth frame being streamed. 0 sets frequency to a default timer (200ms). Default: sends every frame \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "rx_readfreq";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
|
||||
++i;
|
||||
|
||||
|
||||
/*! \page receiver
|
||||
- <b>rx_framesperfile [i]</b> sets/gets the frames per file in receiver to i. 0 means infinite or all frames in a single file. \c Returns \c (int)
|
||||
*/
|
||||
@ -1799,13 +1743,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
|
||||
++i;
|
||||
|
||||
/*! \page receiver
|
||||
- <b>rx_padding</b> sets/gets the frame padding in the receiver. 0 does not pad partial frames(fastest), 1 (default) pads partial frames. \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "rx_padding";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
|
||||
++i;
|
||||
|
||||
/*! \page receiver
|
||||
- <b>rx_jsonaddheader [t]</b> sets/gets additional json header to be streamed out with the zmq from receiver. Default is empty. \c t must be in the format "\"label1\":\"value1\",\"label2\":\"value2\"" etc. Use only if it needs to be processed by an intermediate process. \c Returns \c (string)
|
||||
*/
|
||||
@ -2531,94 +2468,6 @@ std::string slsDetectorCommand::helpFileName(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdEnablefwrite(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
int i;
|
||||
char ans[100];
|
||||
if (action == HELP_ACTION) {
|
||||
return helpEnablefwrite(action);
|
||||
}
|
||||
if (cmd == "fwrite") {
|
||||
if (action == PUT_ACTION) {
|
||||
if (sscanf(args[1], "%d", &i))
|
||||
myDet->setFileWrite(i, detPos);
|
||||
else
|
||||
return std::string("could not decode enable file write");
|
||||
}
|
||||
sprintf(ans, "%d", myDet->getFileWrite(detPos));
|
||||
return std::string(ans);
|
||||
}
|
||||
|
||||
else if (cmd == "fmaster") {
|
||||
if (action == PUT_ACTION) {
|
||||
if (sscanf(args[1], "%d", &i))
|
||||
myDet->setMasterFileWrite(i, detPos);
|
||||
else
|
||||
return std::string("could not decode master file enable");
|
||||
}
|
||||
sprintf(ans, "%d", myDet->getMasterFileWrite(detPos));
|
||||
return std::string(ans);
|
||||
}
|
||||
|
||||
else return std::string("unknown command " + cmd);
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::helpEnablefwrite(int action) {
|
||||
std::ostringstream os;
|
||||
if (action == GET_ACTION || action == HELP_ACTION) {
|
||||
os << std::string("fwrite \t When Enabled writes the data into the file\n");
|
||||
os << std::string("fmaster \t When Enabled writes the master file\n");
|
||||
}
|
||||
if (action == PUT_ACTION || action == HELP_ACTION) {
|
||||
os << std::string("fwrite i \t should be 1 or 0\n");
|
||||
os << std::string("fmaster i \t sets the master file write enable. should be 1 or 0\n");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdOverwrite(int narg, const char * const args[], int action, int detPos) {
|
||||
int i;
|
||||
char ans[100];
|
||||
if (action == HELP_ACTION) {
|
||||
return helpOverwrite(action);
|
||||
}
|
||||
if (action == PUT_ACTION) {
|
||||
if (sscanf(args[1], "%d", &i))
|
||||
myDet->setFileOverWrite(i, detPos);
|
||||
else
|
||||
return std::string("could not decode foverwrite");
|
||||
}
|
||||
sprintf(ans, "%d", myDet->getFileOverWrite(detPos));
|
||||
return std::string(ans);
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::helpOverwrite(int action) {
|
||||
std::ostringstream os;
|
||||
if (action == GET_ACTION || action == HELP_ACTION)
|
||||
os << std::string("foverwrite \t When Enabled overwrites files\n");
|
||||
if (action == PUT_ACTION || action == HELP_ACTION)
|
||||
os << std::string("foverwrite i \t should be 1 or 0 or -1\n");
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdFileIndex(int narg, const char * const args[], int action, int detPos) {
|
||||
if (action == HELP_ACTION) {
|
||||
return helpFileName(action);
|
||||
} else if (action == PUT_ACTION) {
|
||||
int i = std::stoi(args[1]);
|
||||
myDet->setFileIndex(i, detPos);
|
||||
}
|
||||
return std::to_string(myDet->getFileIndex(detPos));
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::helpFileIndex(int action) {
|
||||
std::ostringstream os;
|
||||
if (action == GET_ACTION || action == HELP_ACTION)
|
||||
os << std::string("findex \t gets the file index for the next the data file\n");
|
||||
if (action == PUT_ACTION || action == HELP_ACTION)
|
||||
os << std::string("findex i \t sets the fileindex for the next data file\n");
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdRateCorr(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
@ -3006,55 +2855,6 @@ std::string slsDetectorCommand::helpPort(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdLock(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpLock(action);
|
||||
|
||||
int val; //, ret;
|
||||
char ans[1000];
|
||||
|
||||
if (cmd == "lock") {
|
||||
if (action == PUT_ACTION) {
|
||||
if (sscanf(args[1], "%d", &val))
|
||||
myDet->lockServer(val, detPos);
|
||||
else
|
||||
return std::string("could not lock status") + std::string(args[1]);
|
||||
}
|
||||
|
||||
sprintf(ans, "%d", myDet->lockServer(-1, detPos));
|
||||
}
|
||||
|
||||
else if (cmd == "rx_lock") {
|
||||
if (action == PUT_ACTION) {
|
||||
if (sscanf(args[1], "%d", &val))
|
||||
myDet->lockReceiver(val, detPos);
|
||||
else
|
||||
return std::string("could not decode lock status") + std::string(args[1]);
|
||||
}
|
||||
sprintf(ans, "%d", myDet->lockReceiver(-1, detPos));
|
||||
}
|
||||
|
||||
else
|
||||
return std::string("could not decode command");
|
||||
|
||||
return std::string(ans);
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::helpLock(int action) {
|
||||
|
||||
std::ostringstream os;
|
||||
if (action == PUT_ACTION || action == HELP_ACTION) {
|
||||
os << "lock i \n locks (1) or unlocks (0) the detector to communicate to this client" << std::endl;
|
||||
os << "rx_lock i \n locks (1) or unlocks (0) the receiver to communicate to this client" << std::endl;
|
||||
}
|
||||
if (action == GET_ACTION || action == HELP_ACTION) {
|
||||
os << "lock \n returns the detector lock status" << std::endl;
|
||||
os << "rx_lock \n returns the receiver lock status" << std::endl;
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdLastClient(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
@ -4232,8 +4032,6 @@ std::string slsDetectorCommand::cmdTimer(int narg, const char * const args[], in
|
||||
index = SUBFRAME_DEADTIME;
|
||||
else if (cmd == "delay")
|
||||
index = DELAY_AFTER_TRIGGER;
|
||||
else if (cmd == "frames")
|
||||
index = FRAME_NUMBER;
|
||||
else if (cmd == "cycles")
|
||||
index = CYCLES_NUMBER;
|
||||
// also does digital sample
|
||||
@ -4860,18 +4658,7 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
|
||||
sprintf(answer, "%lu", myDet->getReceiverCurrentFrameIndex(detPos));
|
||||
return std::string(answer);
|
||||
}
|
||||
} else if (cmd == "rx_readfreq") {
|
||||
if (action == PUT_ACTION) {
|
||||
if (!sscanf(args[1], "%d", &ival))
|
||||
return std::string("Could not scan read frequency mode ") + std::string(args[1]);
|
||||
if (ival >= 0)
|
||||
myDet->setReceiverStreamingFrequency(ival, detPos);
|
||||
}
|
||||
sprintf(answer, "%d", myDet->setReceiverStreamingFrequency(-1, detPos));
|
||||
return std::string(answer);
|
||||
|
||||
}
|
||||
|
||||
else if (cmd == "tengiga") {
|
||||
if (action == PUT_ACTION) {
|
||||
if (!sscanf(args[1], "%d", &ival))
|
||||
@ -4906,18 +4693,6 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
|
||||
return myDet->getReceiverFrameDiscardPolicy(myDet->setReceiverFramesDiscardPolicy(GET_FRAME_DISCARD_POLICY, detPos));
|
||||
}
|
||||
|
||||
else if (cmd == "rx_padding") {
|
||||
if (action == PUT_ACTION) {
|
||||
if (sscanf(args[1], "%d", &ival)) {
|
||||
myDet->setPartialFramesPadding(ival, detPos);
|
||||
} else
|
||||
return std::string("could not scan receiver padding enable\n");
|
||||
}
|
||||
memset(answer, 0, 100);
|
||||
sprintf(answer, "%d", myDet->getPartialFramesPadding(detPos));
|
||||
return std::string(answer);
|
||||
}
|
||||
|
||||
else if (cmd == "rx_jsonaddheader") {
|
||||
if (action == PUT_ACTION) {
|
||||
myDet->setAdditionalJsonHeader(args[1], detPos);
|
||||
|
@ -376,6 +376,25 @@ TEST_CASE("rx_lock", "[.cmd]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("lock", "[.cmd]") {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
multiSlsDetectorClient("lock 1", PUT, nullptr, oss);
|
||||
REQUIRE(oss.str() == "lock 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
multiSlsDetectorClient("lock", GET, nullptr, oss);
|
||||
REQUIRE(oss.str() == "lock 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
multiSlsDetectorClient("lock 0", PUT, nullptr, oss);
|
||||
REQUIRE(oss.str() == "lock 0\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("rx_lastclient", "[.cmd]") {
|
||||
|
||||
std::ostringstream oss;
|
||||
|
Loading…
x
Reference in New Issue
Block a user