diff --git a/slsDetectorSoftware/include/CmdProxy.h b/slsDetectorSoftware/include/CmdProxy.h index 149d0cd4c..17a7124b3 100644 --- a/slsDetectorSoftware/include/CmdProxy.h +++ b/slsDetectorSoftware/include/CmdProxy.h @@ -727,6 +727,8 @@ class CmdProxy { {"patwaittime0", &CmdProxy::PatternWaitTime}, {"patwaittime1", &CmdProxy::PatternWaitTime}, {"patwaittime2", &CmdProxy::PatternWaitTime}, + {"patmask", &CmdProxy::patmask}, + {"patsetbit", &CmdProxy::patsetbit}, @@ -1253,6 +1255,12 @@ class CmdProxy { INTEGER_COMMAND_HEX(patclkctrl, getPatternClockControl, setPatternClockControl, std::stoull, "[64 bit mask]\n\t[Ctb] 64 bit mask defining output clock enable."); + INTEGER_COMMAND_HEX(patmask, getPatternMask, setPatternMask, std::stoull, + "[64 bit mask]\n\t[Ctb] 64 bit mask applied to every pattern. Only these bits for each pattern will be masked against."); + + 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."); + diff --git a/slsDetectorSoftware/include/slsDetectorCommand.h b/slsDetectorSoftware/include/slsDetectorCommand.h index a4d6cc9bc..0feb441ef 100755 --- a/slsDetectorSoftware/include/slsDetectorCommand.h +++ b/slsDetectorSoftware/include/slsDetectorCommand.h @@ -57,7 +57,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs { static std::string helpAdvanced(int action); static std::string helpConfiguration(int action); static std::string helpReceiver(int action); - static std::string helpPattern(int action); static std::string helpProcessor(int action); private: @@ -82,7 +81,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs { std::string cmdAdvanced(int narg, const char * const args[], int action, int detPos = -1); std::string cmdConfiguration(int narg, const char * const args[], int action, int detPos = -1); std::string cmdReceiver(int narg, const char * const args[], int action, int detPos = -1); - std::string cmdPattern(int narg, const char * const args[], int action, int detPos = -1); std::string cmdProcessor(int narg, const char * const args[], int action, int detPos = -1); int numberOfCommands; diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index 40a6bed4c..67ecb56be 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -978,20 +978,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor; ++i; - /*! \page prototype - - patmask [m] sets/gets the 64 bit mask (hex) applied to every pattern. Only the bits from \c patsetbit are selected to mask for the corresponding bit value from \c m mask. Returns \c (uint64_t). - */ - descrToFuncMap[i].m_pFuncName = "patmask"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; - ++i; - - /*! \page prototype - - patsetbit [m] selects/gets the 64 bits (hex) that the patmask will be applied to every pattern. Only the bits from \c m mask are selected to mask for the corresponding bit value from \c patmask. Returns \c (uint64_t). - */ - descrToFuncMap[i].m_pFuncName = "patsetbit"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; - ++i; - numberOfCommands = i; // #ifdef VERBOSE @@ -2125,68 +2111,6 @@ std::string slsDetectorCommand::helpReceiver(int action) { return os.str(); } -std::string slsDetectorCommand::helpPattern(int action) { - - std::ostringstream os; - if (action == PUT_ACTION || action == HELP_ACTION) { - os << "patmask m \t sets the 64 bit mask (hex) applied to every pattern. Only the bits from patsetbit are selected to mask for the corresponding bit value from m mask" << std::endl; - os << "patsetbit m \t selects bits (hex) of the 64 bits that the patmask will be applied to every pattern. Only the bits from m mask are selected to mask for the corresponding bit value from patmask." << std::endl; - } - if (action == GET_ACTION || action == HELP_ACTION) { - os << "patmask \t gets the 64 bit mask (hex) applied to every pattern." << std::endl; - os << "patsetbit \t gets 64 bit mask (hex) of the selected bits that the patmask will be applied to every pattern. " << std::endl; - - } - return os.str(); -} - -std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[], int action, int detPos) { - - if (action == HELP_ACTION) - return helpPattern(action); - /******** - - Must implement set ctb functions in slsDetector and multiSlsDetector - - **********/ - std::string fname; - uint64_t word; - - - std::ostringstream os; - if (cmd == "patmask") { - if (action == PUT_ACTION) { - - if (sscanf(args[1], "%lx", &word)) - ; - else - return std::string("Could not scan patmask argument (should be in hex) ") + std::string(args[1]); - - myDet->setPatternMask(word, detPos); - } - - os << "0x" << std::setw(16) << std::setfill('0') << std::hex << myDet->getPatternMask(detPos) << std::dec; - - } else if (cmd == "patsetbit") { - if (action == PUT_ACTION) { - - if (sscanf(args[1], "%lx", &word)) - ; - else - return std::string("Could not scan patsetbit argument (should be in hex) ") + std::string(args[1]); - - myDet->setPatternBitMask(word, detPos); - } - - os << "0x" << std::setw(16) << std::setfill('0') << std::hex << myDet->getPatternBitMask(detPos) << std::dec; - - } - - else - return helpPattern(action); - - return os.str(); -} std::string slsDetectorCommand::helpProcessor(int action) { diff --git a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp index dc102b6f0..057d216f4 100644 --- a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp +++ b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp @@ -9,6 +9,49 @@ auto GET = slsDetectorDefs::GET_ACTION; auto PUT = slsDetectorDefs::PUT_ACTION; + +TEST_CASE("patsetbit", "[.cmd][.ctb]") { + if (test::type == slsDetectorDefs::CHIPTESTBOARD) { + uint64_t val = 0; + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("patsetbit", GET, nullptr, oss)); + std::string s = (oss.str()).erase (0, strlen("patsetbit ")); + val = stoul(s, 0, 16); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("patsetbit 0x842f020204200dc0", PUT, nullptr, oss)); + REQUIRE(oss.str() == "patsetbit 0x842f020204200dc0\n"); + } + REQUIRE_NOTHROW(multiSlsDetectorClient("patsetbit " + sls::ToStringHex(val), PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("patsetbit", GET)); + } +} + + +TEST_CASE("patmask", "[.cmd][.ctb]") { + if (test::type == slsDetectorDefs::CHIPTESTBOARD) { + uint64_t val = 0; + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("patmask", GET, nullptr, oss)); + std::string s = (oss.str()).erase (0, strlen("patmask ")); + val = stoul(s, 0, 16); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("patmask 0x842f020204200dc0", PUT, nullptr, oss)); + REQUIRE(oss.str() == "patmask 0x842f020204200dc0\n"); + } + REQUIRE_NOTHROW(multiSlsDetectorClient("patmask " + sls::ToStringHex(val), PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("patmask", GET)); + } +} + + TEST_CASE("patwaittime", "[.cmd][.ctb]") { for (int loop = 0; loop < 3; ++loop) { if (test::type == slsDetectorDefs::CHIPTESTBOARD) {