mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-05 17:40:40 +02:00
using .empty() on stl containers
This commit is contained in:
parent
05ef55b258
commit
19e40cf0e6
@ -74,7 +74,7 @@ But lets start looking at the at the manual way:
|
|||||||
::
|
::
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from sls_detector import Eiger
|
from slsdet import Eiger
|
||||||
d = Eiger()
|
d = Eiger()
|
||||||
|
|
||||||
n = 10
|
n = 10
|
||||||
@ -114,7 +114,7 @@ hang around until the main process exits.
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
from sls_detector import Eiger
|
from slsdet import Eiger
|
||||||
|
|
||||||
def acquire():
|
def acquire():
|
||||||
"""
|
"""
|
||||||
|
@ -434,7 +434,7 @@ std::string CmdProxy::Exptime(int action) {
|
|||||||
if (gateIndex == -1 &&
|
if (gateIndex == -1 &&
|
||||||
det->getDetectorType().squash() == defs::MYTHEN3) {
|
det->getDetectorType().squash() == defs::MYTHEN3) {
|
||||||
auto t = det->getExptimeForAllGates({det_id});
|
auto t = det->getExptimeForAllGates({det_id});
|
||||||
if (args.size() == 0) {
|
if (args.empty()) {
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (args.size() == 1) {
|
} else if (args.size() == 1) {
|
||||||
os << OutString(t, args[0]) << '\n';
|
os << OutString(t, args[0]) << '\n';
|
||||||
@ -448,7 +448,7 @@ std::string CmdProxy::Exptime(int action) {
|
|||||||
} else {
|
} else {
|
||||||
t = det->getExptime(gateIndex, {det_id});
|
t = det->getExptime(gateIndex, {det_id});
|
||||||
}
|
}
|
||||||
if (args.size() == 0) {
|
if (args.empty()) {
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (args.size() == 1) {
|
} else if (args.size() == 1) {
|
||||||
os << OutString(t, args[0]) << '\n';
|
os << OutString(t, args[0]) << '\n';
|
||||||
@ -932,11 +932,11 @@ std::string CmdProxy::DacValues(int action) {
|
|||||||
auto it = t.cbegin();
|
auto it = t.cbegin();
|
||||||
os << ToString(*it) << ' '
|
os << ToString(*it) << ' '
|
||||||
<< OutString(det->getDAC(*it++, mv, {det_id}))
|
<< OutString(det->getDAC(*it++, mv, {det_id}))
|
||||||
<< (args.size() > 0 ? " mv" : "");
|
<< (!args.empty() ? " mv" : "");
|
||||||
while (it != t.cend()) {
|
while (it != t.cend()) {
|
||||||
os << ", " << ToString(*it) << ' '
|
os << ", " << ToString(*it) << ' '
|
||||||
<< OutString(det->getDAC(*it++, mv, {det_id}))
|
<< OutString(det->getDAC(*it++, mv, {det_id}))
|
||||||
<< (args.size() > 0 ? " mv" : "");
|
<< (!args.empty() ? " mv" : "");
|
||||||
}
|
}
|
||||||
os << "]\n";
|
os << "]\n";
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
@ -955,7 +955,7 @@ std::string CmdProxy::ReceiverStatus(int action) {
|
|||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "running, idle]\n\tReceiver listener status." << '\n';
|
os << "running, idle]\n\tReceiver listener status." << '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 0) {
|
if (!args.empty()) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
}
|
}
|
||||||
auto t = det->getReceiverStatus({det_id});
|
auto t = det->getReceiverStatus({det_id});
|
||||||
@ -977,7 +977,7 @@ std::string CmdProxy::DetectorStatus(int action) {
|
|||||||
"idle]\n\tDetector status."
|
"idle]\n\tDetector status."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 0) {
|
if (!args.empty()) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
}
|
}
|
||||||
auto t = det->getDetectorStatus({det_id});
|
auto t = det->getDetectorStatus({det_id});
|
||||||
@ -1003,7 +1003,7 @@ std::string CmdProxy::UDPDestinationIP(int action) {
|
|||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
auto t = det->getDestinationUDPIP({det_id});
|
auto t = det->getDestinationUDPIP({det_id});
|
||||||
if (args.size() != 0) {
|
if (!args.empty()) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
}
|
}
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
@ -1045,7 +1045,7 @@ std::string CmdProxy::UDPDestinationIP2(int action) {
|
|||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
auto t = det->getDestinationUDPIP2({det_id});
|
auto t = det->getDestinationUDPIP2({det_id});
|
||||||
if (args.size() != 0) {
|
if (!args.empty()) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
}
|
}
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
@ -1753,7 +1753,7 @@ std::string CmdProxy::GateDelay(int action) {
|
|||||||
// vector of gate delays
|
// vector of gate delays
|
||||||
if (gateIndex == -1) {
|
if (gateIndex == -1) {
|
||||||
auto t = det->getGateDelayForAllGates({det_id});
|
auto t = det->getGateDelayForAllGates({det_id});
|
||||||
if (args.size() == 0) {
|
if (args.empty()) {
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (args.size() == 1) {
|
} else if (args.size() == 1) {
|
||||||
os << OutString(t, args[0]) << '\n';
|
os << OutString(t, args[0]) << '\n';
|
||||||
@ -1762,7 +1762,7 @@ std::string CmdProxy::GateDelay(int action) {
|
|||||||
// single gate delay
|
// single gate delay
|
||||||
else {
|
else {
|
||||||
auto t = det->getGateDelay(gateIndex, {det_id});
|
auto t = det->getGateDelay(gateIndex, {det_id});
|
||||||
if (args.size() == 0) {
|
if (args.empty()) {
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (args.size() == 1) {
|
} else if (args.size() == 1) {
|
||||||
os << OutString(t, args[0]) << '\n';
|
os << OutString(t, args[0]) << '\n';
|
||||||
@ -2212,7 +2212,7 @@ std::string CmdProxy::AdditionalJsonHeader(int action) {
|
|||||||
"listening to receiver zmq packets. Empty value deletes header. "
|
"listening to receiver zmq packets. Empty value deletes header. "
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 0) {
|
if (!args.empty()) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
}
|
}
|
||||||
auto t = det->getAdditionalJsonHeader({det_id});
|
auto t = det->getAdditionalJsonHeader({det_id});
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
auto t = det->GETFCN({det_id}); \
|
auto t = det->GETFCN({det_id}); \
|
||||||
if (args.size() == 0) { \
|
if (args.empty()) { \
|
||||||
os << OutString(t) << '\n'; \
|
os << OutString(t) << '\n'; \
|
||||||
} else if (args.size() == 1) { \
|
} else if (args.size() == 1) { \
|
||||||
os << OutString(t, args[0]) << '\n'; \
|
os << OutString(t, args[0]) << '\n'; \
|
||||||
@ -65,7 +65,7 @@
|
|||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
auto t = det->GETFCN({det_id}); \
|
auto t = det->GETFCN({det_id}); \
|
||||||
if (args.size() == 0) { \
|
if (args.empty()) { \
|
||||||
os << OutString(t) << '\n'; \
|
os << OutString(t) << '\n'; \
|
||||||
} else if (args.size() == 1) { \
|
} else if (args.size() == 1) { \
|
||||||
os << OutString(t, args[0]) << '\n'; \
|
os << OutString(t, args[0]) << '\n'; \
|
||||||
@ -88,7 +88,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN({det_id}); \
|
auto t = det->GETFCN({det_id}); \
|
||||||
@ -113,7 +113,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN({det_id}); \
|
auto t = det->GETFCN({det_id}); \
|
||||||
@ -139,7 +139,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN({det_id}); \
|
auto t = det->GETFCN({det_id}); \
|
||||||
@ -165,7 +165,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN({det_id}); \
|
auto t = det->GETFCN({det_id}); \
|
||||||
@ -194,7 +194,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN(); \
|
auto t = det->GETFCN(); \
|
||||||
@ -220,7 +220,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN(INDEX, {det_id}); \
|
auto t = det->GETFCN(INDEX, {det_id}); \
|
||||||
@ -316,7 +316,7 @@
|
|||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
throw sls::RuntimeError("Cannot get"); \
|
throw sls::RuntimeError("Cannot get"); \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
det->SETFCN(); \
|
det->SETFCN(); \
|
||||||
@ -337,7 +337,7 @@
|
|||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
throw sls::RuntimeError("Cannot get"); \
|
throw sls::RuntimeError("Cannot get"); \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
det->SETFCN({det_id}); \
|
det->SETFCN({det_id}); \
|
||||||
@ -380,7 +380,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN({det_id}); \
|
auto t = det->GETFCN({det_id}); \
|
||||||
@ -401,7 +401,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN({det_id}); \
|
auto t = det->GETFCN({det_id}); \
|
||||||
@ -421,7 +421,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
if (args.size() != 0) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN(VAL, {det_id}); \
|
auto t = det->GETFCN(VAL, {det_id}); \
|
||||||
|
@ -87,7 +87,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
std::vector<int> positions,
|
std::vector<int> positions,
|
||||||
typename NonDeduced<CT>::type... Args) {
|
typename NonDeduced<CT>::type... Args) {
|
||||||
|
|
||||||
if (detectors.size() == 0)
|
if (detectors.empty())
|
||||||
throw sls::RuntimeError("No detectors added");
|
throw sls::RuntimeError("No detectors added");
|
||||||
if (positions.empty() ||
|
if (positions.empty() ||
|
||||||
(positions.size() == 1 && positions[0] == -1)) {
|
(positions.size() == 1 && positions[0] == -1)) {
|
||||||
@ -115,7 +115,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
std::vector<int> positions,
|
std::vector<int> positions,
|
||||||
typename NonDeduced<CT>::type... Args) const {
|
typename NonDeduced<CT>::type... Args) const {
|
||||||
|
|
||||||
if (detectors.size() == 0)
|
if (detectors.empty())
|
||||||
throw sls::RuntimeError("No detectors added");
|
throw sls::RuntimeError("No detectors added");
|
||||||
if (positions.empty() ||
|
if (positions.empty() ||
|
||||||
(positions.size() == 1 && positions[0] == -1)) {
|
(positions.size() == 1 && positions[0] == -1)) {
|
||||||
@ -143,7 +143,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
std::vector<int> positions,
|
std::vector<int> positions,
|
||||||
typename NonDeduced<CT>::type... Args) {
|
typename NonDeduced<CT>::type... Args) {
|
||||||
|
|
||||||
if (detectors.size() == 0)
|
if (detectors.empty())
|
||||||
throw sls::RuntimeError("No detectors added");
|
throw sls::RuntimeError("No detectors added");
|
||||||
if (positions.empty() ||
|
if (positions.empty() ||
|
||||||
(positions.size() == 1 && positions[0] == -1)) {
|
(positions.size() == 1 && positions[0] == -1)) {
|
||||||
@ -168,7 +168,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
std::vector<int> positions,
|
std::vector<int> positions,
|
||||||
typename NonDeduced<CT>::type... Args) const {
|
typename NonDeduced<CT>::type... Args) const {
|
||||||
|
|
||||||
if (detectors.size() == 0)
|
if (detectors.empty())
|
||||||
throw sls::RuntimeError("No detectors added");
|
throw sls::RuntimeError("No detectors added");
|
||||||
if (positions.empty() ||
|
if (positions.empty() ||
|
||||||
(positions.size() == 1 && positions[0] == -1)) {
|
(positions.size() == 1 && positions[0] == -1)) {
|
||||||
|
@ -407,7 +407,7 @@ TEST_CASE("threshold", "[.cmd][.new]") {
|
|||||||
auto prev_threshold = det.getThresholdEnergy();
|
auto prev_threshold = det.getThresholdEnergy();
|
||||||
auto prev_energies =
|
auto prev_energies =
|
||||||
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
||||||
if (prev_energies.size() != 0) {
|
if (!prev_energies.empty()) {
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
proxy.Call("threshold", {"4500", "standard"}, -1, PUT, oss1);
|
proxy.Call("threshold", {"4500", "standard"}, -1, PUT, oss1);
|
||||||
REQUIRE(oss1.str() == "threshold [4500, standard]\n");
|
REQUIRE(oss1.str() == "threshold [4500, standard]\n");
|
||||||
@ -436,7 +436,7 @@ TEST_CASE("thresholdnotb", "[.cmd][.new]") {
|
|||||||
auto prev_threshold = det.getThresholdEnergy();
|
auto prev_threshold = det.getThresholdEnergy();
|
||||||
auto prev_energies =
|
auto prev_energies =
|
||||||
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
det.getTrimEnergies().tsquash("inconsistent trim energies to test");
|
||||||
if (prev_energies.size() != 0) {
|
if (!prev_energies.empty()) {
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
proxy.Call("thresholdnotb", {"4500 standard"}, -1, PUT, oss1);
|
proxy.Call("thresholdnotb", {"4500 standard"}, -1, PUT, oss1);
|
||||||
REQUIRE(oss1.str() == "thresholdnotb [4500 standard]\n");
|
REQUIRE(oss1.str() == "thresholdnotb [4500 standard]\n");
|
||||||
|
@ -57,7 +57,7 @@ TEST_CASE("Remove char from string") {
|
|||||||
TEST_CASE("Remove char from empty string") {
|
TEST_CASE("Remove char from empty string") {
|
||||||
char str[50] = {};
|
char str[50] = {};
|
||||||
sls::removeChar(str, 'e');
|
sls::removeChar(str, 'e');
|
||||||
REQUIRE(std::string(str) == "");
|
REQUIRE(std::string(str).empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Many characters in a row") {
|
TEST_CASE("Many characters in a row") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user