mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
other replacements for string
This commit is contained in:
parent
dee0aea378
commit
9a6f521f6a
@ -1814,7 +1814,7 @@ std::string CmdProxy::PatternWaitTime(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setPatternWaitTime(level, std::stoul(args[0]), {det_id});
|
||||
det->setPatternWaitTime(level, StringTo<uint64_t>(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
|
@ -1027,16 +1027,16 @@ class CmdProxy {
|
||||
/* acquisition parameters */
|
||||
|
||||
INTEGER_COMMAND_NOID(frames, getNumberOfFrames, setNumberOfFrames,
|
||||
std::stol,
|
||||
StringTo<int64_t>,
|
||||
"[n_frames]\n\tNumber of frames per aquire. In trigger mode, number of frames per trigger."
|
||||
"\n\t[Gotthard2] Burst mode has a maximum of 2720 frames.");
|
||||
|
||||
INTEGER_COMMAND_NOID(triggers, getNumberOfTriggers, setNumberOfTriggers,
|
||||
std::stol,
|
||||
StringTo<int64_t>,
|
||||
"[n_triggers]\n\tNumber of triggers per aquire. Use timing command to set timing mode.");
|
||||
|
||||
INTEGER_COMMAND_NOID(bursts, getNumberOfBursts, setNumberOfBursts,
|
||||
std::stol,
|
||||
StringTo<int64_t>,
|
||||
"[n_bursts]\n\t[Gotthard2] Number of bursts per aquire. Only in auto timing mode and burst mode. Use timing command to set timing mode and burstmode command to set burst mode.");
|
||||
|
||||
TIME_COMMAND(exptime, getExptime, setExptime,
|
||||
@ -1374,7 +1374,7 @@ class CmdProxy {
|
||||
GET_COMMAND(rx_missingpackets, getNumMissingPackets,
|
||||
"\n\tNumber of missing packets for each port in receiver.");
|
||||
|
||||
INTEGER_COMMAND(startingfnum, getStartingFrameNumber, setStartingFrameNumber, std::stoull,
|
||||
INTEGER_COMMAND(startingfnum, getStartingFrameNumber, setStartingFrameNumber, StringTo<uint64_t>,
|
||||
"[n_value]\n\t[Eiger[Jungfrau] Starting frame number for next acquisition.");
|
||||
|
||||
EXECUTE_SET_COMMAND(trigger, sendSoftwareTrigger,
|
||||
@ -1454,7 +1454,7 @@ class CmdProxy {
|
||||
"receiver. 0 does not pad partial frames(fastest), 1 "
|
||||
"(default) pads partial frames");
|
||||
|
||||
INTEGER_COMMAND(rx_udpsocksize, getRxUDPSocketBufferSize, setRxUDPSocketBufferSize, std::stol,
|
||||
INTEGER_COMMAND(rx_udpsocksize, getRxUDPSocketBufferSize, setRxUDPSocketBufferSize, StringTo<int64_t>,
|
||||
"[n_size]\n\tUDP socket buffer size in receiver. Tune rmem_default and rmem_max accordingly. rx_hostname sets it to defaults.");
|
||||
|
||||
GET_COMMAND(rx_realudpsocksize, getRxRealUDPSocketBufferSize,
|
||||
@ -1478,7 +1478,7 @@ class CmdProxy {
|
||||
STRING_COMMAND(fname, getFileNamePrefix, setFileNamePrefix,
|
||||
"[path]\n\tFile name prefix for output data file. Default is run. File name: [file name prefix]_d[detector index]_f[sub file index]_[acquisition/file index].raw.");
|
||||
|
||||
INTEGER_COMMAND(findex, getAcquisitionIndex, setAcquisitionIndex, std::stol,
|
||||
INTEGER_COMMAND(findex, getAcquisitionIndex, setAcquisitionIndex, StringTo<int64_t>,
|
||||
"[0, 1]\n\tFile or Acquisition index.");
|
||||
|
||||
INTEGER_COMMAND(fwrite, getFileWrite, setFileWrite, StringTo<int>,
|
||||
|
@ -628,6 +628,12 @@ inline int StringTo(const std::string &s) {
|
||||
return std::stoi(s, nullptr, base);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline int64_t StringTo(const std::string &s) {
|
||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||
return std::stol(s, nullptr, base);
|
||||
}
|
||||
|
||||
/** For types with a .str() method use this for conversion */
|
||||
template <typename T>
|
||||
typename std::enable_if<has_str<T>::value, std::string>::type
|
||||
|
@ -179,3 +179,18 @@ TEST_CASE("int from string"){
|
||||
REQUIRE(StringTo<int>("0xffffff") == 0xffffff);
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("int64_t from string"){
|
||||
REQUIRE(StringTo<int64_t>("-1") == -1);
|
||||
REQUIRE(StringTo<int64_t>("-0x1") == -0x1);
|
||||
REQUIRE(StringTo<int64_t>("-0x1") == -1);
|
||||
REQUIRE(StringTo<int64_t>("0") == 0);
|
||||
REQUIRE(StringTo<int64_t>("5") == 5);
|
||||
REQUIRE(StringTo<int64_t>("16") == 16);
|
||||
REQUIRE(StringTo<int64_t>("20") == 20);
|
||||
REQUIRE(StringTo<int64_t>("0x14") == 20);
|
||||
REQUIRE(StringTo<int64_t>("0x15") == 21);
|
||||
REQUIRE(StringTo<int64_t>("0xffffff") == 0xffffff);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user