mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-04 00:50:42 +02:00
WIP
This commit is contained in:
parent
f6911c4238
commit
159b0a0367
@ -1970,7 +1970,7 @@ std::string CmdProxy::PatternWord(int action) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getPatternWord(StringTo<uint64_t>(args[0]), {det_id});
|
||||
os << OutStringHex(t) << '\n';
|
||||
os << OutStringHex(t, 16) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
|
@ -433,12 +433,13 @@ class CmdProxy {
|
||||
return ToStringHex(value.front());
|
||||
return ToStringHex(value);
|
||||
}
|
||||
/*
|
||||
template <typename V> std::string OutStringHex(const V &value, int
|
||||
width) { if (value.equal()) return ToStringHex(value.front(), width);
|
||||
return ToStringHex(value, width);
|
||||
}
|
||||
*/
|
||||
|
||||
template <typename V> std::string OutStringHex(const V &value, int width) {
|
||||
if (value.equal())
|
||||
return ToStringHex(value.front(), width);
|
||||
return ToStringHex(value, width);
|
||||
}
|
||||
|
||||
template <typename V> std::string OutString(const V &value) {
|
||||
if (value.equal())
|
||||
return ToString(value.front());
|
||||
|
@ -144,6 +144,24 @@ ToStringHex(const T &container) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<
|
||||
is_container<T>::value &&
|
||||
!std::is_same<typename T::value_type, std::string>::value,
|
||||
std::string>::type
|
||||
ToStringHex(const T &container, int width) {
|
||||
std::ostringstream os;
|
||||
os << '[';
|
||||
if (!container.empty()) {
|
||||
auto it = container.cbegin();
|
||||
os << ToStringHex(*it++, width);
|
||||
while (it != container.cend())
|
||||
os << ", " << ToStringHex(*it++, width);
|
||||
}
|
||||
os << ']';
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <typename KeyType, typename ValueType>
|
||||
std::string ToString(const std::map<KeyType, ValueType> &m) {
|
||||
std::ostringstream os;
|
||||
|
@ -12,6 +12,7 @@
|
||||
using sls::defs;
|
||||
using sls::StringTo;
|
||||
using sls::ToString;
|
||||
using sls::ToStringHex;
|
||||
using namespace sls::time;
|
||||
|
||||
TEST_CASE("Integer conversions", "[support]") {
|
||||
@ -260,4 +261,16 @@ TEST_CASE("vector of dac index to string") {
|
||||
std::vector<defs::dacIndex> daci{defs::VCASSH, defs::VTH2, defs::VRSHAPER};
|
||||
auto r = ToString(daci);
|
||||
REQUIRE(r == "[vcassh, vth2, vrshaper]");
|
||||
}
|
||||
|
||||
TEST_CASE("int or uin64_t to a string in hex") {
|
||||
REQUIRE(ToStringHex(65535) == "0xffff");
|
||||
REQUIRE(ToStringHex(65535, 8) == "0x0000ffff");
|
||||
REQUIRE(ToStringHex(8927748192) == "0x21422a060");
|
||||
REQUIRE(ToStringHex(8927748192, 16) == "0x000000021422a060");
|
||||
std::vector<int> temp{244, 65535, 1638582};
|
||||
auto r = ToStringHex(temp);
|
||||
REQUIRE(r == "[0xf4, 0xffff, 0x1900b6]");
|
||||
r = ToStringHex(temp, 8);
|
||||
REQUIRE(r == "[0x000000f4, 0x0000ffff, 0x001900b6]");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user