This commit is contained in:
maliakal_d 2019-10-28 11:17:27 +01:00
parent f9d832bf34
commit 93bb0c9aed
4 changed files with 77 additions and 21 deletions

View File

@ -732,6 +732,8 @@ class CmdProxy {
{"patsetbit", &CmdProxy::patsetbit},
/* Moench */
{"rx_jsonaddheader", &CmdProxy::rx_jsonaddheader},
{"rx_jsonpara", &CmdProxy::JsonParameter},
@ -798,6 +800,7 @@ class CmdProxy {
std::string PatternWaitAddress(int action);
std::string PatternWaitTime(int action);
/* Moench */
std::string JsonParameter(int action);
@ -1265,9 +1268,12 @@ class CmdProxy {
INTEGER_COMMAND_HEX(patsetbit, getPatternBitMask, setPatternBitMask, std::stoull,
"[64 bit mask]\n\t[Ctb] 64 bit values applied to the selected patmask for every pattern.");
/* Moench */
STRING_COMMAND(rx_jsonaddheader, getAdditionalJsonHeader, setAdditionalJsonHeader,
"[\"label1\":\"value1\"], [\"label2\":\"value2\"]\n\t[Moench] Additional json header to be streamd out from receiver via zmq. Default is empty. Use only if to be processed by an intermediate user process listening to receiver zmq packets.");

View File

@ -1242,7 +1242,28 @@ std::string CmdProxy::PatternWaitTime(int action) {
/* Moench */
std::string CmdProxy::JsonParameter(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[key1] [value1]\n\t[Moench] Additional json header parameter streamed out from receiver. This is same as calling rx_jsonaddheader \"key\":\"value1\"" << '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
auto t = det->getAdditionalJsonParameter(args[0], {det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
det->setAdditionalJsonParameter(args[0], args[1], {det_id});
os << sls::ToString(args) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
} // namespace sls

View File

@ -929,13 +929,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
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)
*/
descrToFuncMap[i].m_pFuncName = "rx_jsonaddheader";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
i++;
/*! \page receiver
- <b>rx_jsonpara [k] [v]</b> sets/gets value v for additional json header parameter k to be streamed out with the zmq from receiver. If empty, then no parameter found Use only if it needs to be processed by an intermediate process. \c Returns \c (string)
*/
@ -2073,13 +2066,6 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
}
}
else if (cmd == "rx_jsonaddheader") {
if (action == PUT_ACTION) {
myDet->setAdditionalJsonHeader(args[1], detPos);
}
return myDet->getAdditionalJsonHeader(detPos);
}
else if (cmd == "rx_jsonpara") {
if (action == PUT_ACTION) {
myDet->setAdditionalJsonParameter(args[1], args[2], detPos);
@ -2095,16 +2081,11 @@ std::string slsDetectorCommand::helpReceiver(int action) {
std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) {
os << "resetframescaught [any value] \t resets frames caught by receiver" << std::endl;
os << "rx_jsonaddheader [t]\n sets additional json header to be streamed "
"out with the zmq from receiver. Default is empty. t must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
"Use only if it needs to be processed by an intermediate process." << std::endl;
os << "rx_jsonpara [k] [v]\n sets value to v for additional json header parameter k to be streamed out with the zmq from receiver." << std::endl;
}
if (action == GET_ACTION || action == HELP_ACTION) {
os << "frameindex \t returns the current frame index of receiver(average for multi)" << std::endl;
os << "rx_jsonaddheader \n gets additional json header to be streamed "
"out with the zmq from receiver." << std::endl;
os << "rx_jsonpara [k] \n gets value of additional json header parameter k to be streamed out with the zmq from receiver. If empty, then no parameter found." << std::endl;
}

View File

@ -9,6 +9,54 @@
auto GET = slsDetectorDefs::GET_ACTION;
auto PUT = slsDetectorDefs::PUT_ACTION;
TEST_CASE("rx_jsonpara", "[.cmd][.moench]") {
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"key1\":\"value1\"", PUT));
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonpara key1", GET, nullptr, oss));
REQUIRE(oss.str() == "rx_jsonpara value1\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonpara key1 value2", PUT, nullptr, oss));
REQUIRE(oss.str() == "rx_jsonpara [key1, value2]\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonpara key2 98", PUT, nullptr, oss));
REQUIRE(oss.str() == "rx_jsonpara [key2, 98]\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader", GET, nullptr, oss));
REQUIRE(oss.str() == "rx_jsonaddheader \"key1\":\"value2\",\"key2\":98\n");
}
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"\"", PUT));
}
TEST_CASE("rx_jsonaddheader", "[.cmd]") {
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"\"", PUT, nullptr, oss));
REQUIRE(oss.str() == "rx_jsonaddheader \"\"\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"what\":\"bla\"", PUT, nullptr, oss));
REQUIRE(oss.str() == "rx_jsonaddheader \"what\":\"bla\"\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"what2\":\"bla2\"", PUT, nullptr, oss));
REQUIRE(oss.str() == "rx_jsonaddheader \"what2\":\"bla2\"\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"\"", PUT, nullptr, oss));
REQUIRE(oss.str() == "rx_jsonaddheader \"\"\n");
}
}
TEST_CASE("patsetbit", "[.cmd][.ctb]") {
if (test::type == slsDetectorDefs::CHIPTESTBOARD) {