diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 80dde397d..940119bcd 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -7395,6 +7395,11 @@ int set_pattern(int file_des) { LOG(logINFO, ("Setting Pattern\n")); LOG(logINFO, ("Setting Pattern Word\n")); for (int i = 0; i < MAX_PATTERN_LENGTH; ++i) { + if (patwords[i] != 0) { + LOG(logDEBUG1, + ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", i, + (long long int)patwords[i])); + } writePatternWord(i, patwords[i]); } int numLoops = -1, retval0 = -1, retval1 = -1; diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 35ce144be..968c8098b 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1970,7 +1970,7 @@ std::string CmdProxy::PatternWord(int action) { WrongNumberOfParameters(1); } auto t = det->getPatternWord(StringTo(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); diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index caadfef47..28ec6208e 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -434,6 +434,12 @@ class CmdProxy { return ToStringHex(value); } + template std::string OutStringHex(const V &value, int width) { + if (value.equal()) + return ToStringHex(value.front(), width); + return ToStringHex(value, width); + } + template std::string OutString(const V &value) { if (value.equal()) return ToString(value.front()); diff --git a/slsSupportLib/include/ToString.h b/slsSupportLib/include/ToString.h index 23c533bda..61b4e47ab 100644 --- a/slsSupportLib/include/ToString.h +++ b/slsSupportLib/include/ToString.h @@ -111,6 +111,16 @@ ToStringHex(const T &value) { return os.str(); } +/** Conversion of integer types, do not remove trailing zeros */ +template +typename std::enable_if::value, std::string>::type +ToStringHex(const T &value, int width) { + std::ostringstream os; + os << "0x" << std::hex << std::setfill('0') << std::setw(width) << value + << std::dec; + return os.str(); +} + /** * hex * For a container loop over all elements and call ToString on the element diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index c78a4b1d0..e206bb42d 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -66,32 +66,34 @@ std::ostream &operator<<(std::ostream &os, std::string ToString(const slsDetectorDefs::patternParameters &r) { std::ostringstream oss; - oss << '[' << std::endl; + oss << '[' << std::setfill('0') << std::endl; + int addr_width = 4; + int word_width = 16; for (int i = 0; i < MAX_PATTERN_LENGTH; ++i) { if (r.word[i] != 0) { - oss << "patword 0x" << std::hex << i << " 0x" << std::hex - << r.word[i] << std::endl; + oss << "patword " << ToStringHex(i, addr_width) << " " + << ToStringHex(r.word[i], word_width) << std::endl; } } - oss << "patioctrl 0x" << std::hex << r.patioctrl << std::endl - << "patclkctrl 0x" << r.patclkctrl << std::endl - << "patlimits 0x" << r.patlimits[0] << " 0x" << r.patlimits[1] - << std::endl - << "patloop0 0x" << r.patloop[0] << " 0x" << r.patloop[1] << std::endl - << "patnloop0 " << std::dec << r.patnloop[0] << std::hex << std::endl - << "patloop1 0x" << r.patloop[2] << " 0x" << r.patloop[3] << std::endl - << "patnloop1 " << std::dec << r.patnloop[1] << std::hex << std::endl - << "patloop2 0x" << r.patloop[4] << " 0x" << r.patloop[5] << std::endl - << "patnloop2 " << std::dec << r.patnloop[2] << std::hex << std::endl - << "patwait0 0x" << r.patwait[0] << std::endl - << "patwaittime0 " << std::dec << r.patwaittime[0] << std::hex - << std::endl - << "patwait1 0x" << r.patwait[1] << std::endl - << "patwaittime1 " << std::dec << r.patwaittime[1] << std::hex - << std::endl - << "patwait2 0x" << r.patwait[1] << std::endl - << "patwaittime2 " << std::dec << r.patwaittime[2] << std::hex - << std::endl + oss << "patioctrl " << ToStringHex(r.patioctrl, word_width) << std::endl + << "patclkctrl " << ToStringHex(r.patclkctrl, word_width) << std::endl + << "patlimits " << ToStringHex(r.patlimits[0], addr_width) << " " + << ToStringHex(r.patlimits[1], addr_width) << std::endl + << "patloop0 " << ToStringHex(r.patloop[0], addr_width) << " " + << ToStringHex(r.patloop[1], addr_width) << std::endl + << "patnloop0 " << r.patnloop[0] << std::endl + << "patloop1 " << ToStringHex(r.patloop[2], addr_width) << " " + << ToStringHex(r.patloop[3], addr_width) << std::endl + << "patnloop1 " << r.patnloop[1] << std::endl + << "patloop2 " << ToStringHex(r.patloop[4], addr_width) << " " + << ToStringHex(r.patloop[5], addr_width) << std::endl + << "patnloop2 " << r.patnloop[2] << std::endl + << "patwait0 " << ToStringHex(r.patwait[0], addr_width) << std::endl + << "patwaittime0 " << r.patwaittime[0] << std::endl + << "patwait1 " << ToStringHex(r.patwait[1], addr_width) << std::endl + << "patwaittime1 " << r.patwaittime[1] << std::endl + << "patwait2 " << ToStringHex(r.patwait[2], addr_width) << std::endl + << "patwaittime2 " << r.patwaittime[2] << std::endl << ']'; return oss.str(); }