diff --git a/ctbGui/ctbPattern.cpp b/ctbGui/ctbPattern.cpp index 0819f9eaa..dca01c6b8 100755 --- a/ctbGui/ctbPattern.cpp +++ b/ctbGui/ctbPattern.cpp @@ -118,7 +118,7 @@ ctbLoop::ctbLoop(TGGroupFrame *page, int i, sls::Detector *det) : TGHorizontalFr void ctbLoop::setNLoops() { try{ - myDet->setPatternLoops(id, -1, -1, eLoopNumber->GetNumber()); + myDet->setPatternLoopCycles(id, eLoopNumber->GetNumber()); } CATCH_DISPLAY ("Could not set number of pattern loops for level " + to_string(id) + ".", "ctbLoop::setNLoops") } @@ -127,10 +127,12 @@ void ctbLoop::setNLoops() { void ctbLoop::update() { try{ - auto loop = myDet->getPatternLoops(id).tsquash("Different values"); - eLoopStartAddr->SetHexNumber(loop[0]); - eLoopStopAddr->SetHexNumber(loop[1]); - eLoopNumber->SetNumber(loop[2]); + auto loop = myDet->getPatternLoopCycles(id).tsquash("Different values"); + eLoopNumber->SetNumber(loop); + auto loopaddr = myDet->getPatternLoopAddresses(id).tsquash("Different values"); + eLoopStartAddr->SetHexNumber(loopaddr[0]); + eLoopStopAddr->SetHexNumber(loopaddr[1]); + } CATCH_DISPLAY ("Could not get pattern loops for level " + to_string(id) + ".", "ctbLoop::update") } @@ -825,7 +827,7 @@ void ctbPattern::update() { } CATCH_DISPLAY ("Could not get number of triggers.", "ctbPattern::update") try{ - auto retval = myDet->getPatternLoops(-1).tsquash("Different values"); + auto retval = myDet->getPatternLoopAddresses(-1).tsquash("Different values"); eStartAddr->SetHexNumber(retval[0]); eStopAddr->SetHexNumber(retval[1]); } CATCH_DISPLAY ("Could not get dbit phase shift.", "ctbPattern::update") diff --git a/slsDetectorServers/ctbDetectorServer/Makefile b/slsDetectorServers/ctbDetectorServer/Makefile index c8ff0829e..1aad970d8 100755 --- a/slsDetectorServers/ctbDetectorServer/Makefile +++ b/slsDetectorServers/ctbDetectorServer/Makefile @@ -5,7 +5,7 @@ support_lib = ../../slsSupportLib/include/ CROSS = bfin-uclinux- CC = $(CROSS)gcc -CFLAGS += -Wall -DCHIPTESTBOARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE +CFLAGS += -Wall -DCHIPTESTBOARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE LDLIBS += -lm PROGS = ctbDetectorServer DESTDIR ?= bin diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 26777f4be..a89ab0b04 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index b657ac0df..02493ed69 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index 95c2c9186..5e55eecf5 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index d210e70ac..fd6b606c6 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 21a572c17..b76b48712 100755 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -62,7 +62,8 @@ int set_all_trimbits(int); int set_pattern_io_control(int); int set_pattern_clock_control(int); int set_pattern_word(int); -int set_pattern_loop(int); +int set_pattern_loop_addresses(int); +int set_pattern_loop_cycles(int); int set_pattern_wait_addr(int); int set_pattern_wait_time(int); int set_pattern_mask(int); diff --git a/slsDetectorServers/slsDetectorServer/src/communication_funcs.c b/slsDetectorServers/slsDetectorServer/src/communication_funcs.c index 39385e266..a49cb0765 100755 --- a/slsDetectorServers/slsDetectorServer/src/communication_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/communication_funcs.c @@ -388,7 +388,7 @@ int receiveDataOnly(int file_des, void* buf,int length) { if (total_received>0) thisClientIP = dummyClientIP; - if (lastClientIP == thisClientIP) { + if (lastClientIP != thisClientIP) { differentClients = 1; } else diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 73633297e..79424a6bf 100755 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -204,7 +204,8 @@ const char* getFunctionName(enum detFuncs func) { case F_SET_PATTERN_IO_CONTROL: return "F_SET_PATTERN_IO_CONTROL"; case F_SET_PATTERN_CLOCK_CONTROL: return "F_SET_PATTERN_CLOCK_CONTROL"; case F_SET_PATTERN_WORD: return "F_SET_PATTERN_WORD"; - case F_SET_PATTERN_LOOP: return "F_SET_PATTERN_LOOP"; + case F_SET_PATTERN_LOOP_ADDRESSES: return "F_SET_PATTERN_LOOP_ADDRESSES"; + case F_SET_PATTERN_LOOP_CYCLES: return "F_SET_PATTERN_LOOP_CYCLES"; case F_SET_PATTERN_WAIT_ADDR: return "F_SET_PATTERN_WAIT_ADDR"; case F_SET_PATTERN_WAIT_TIME: return "F_SET_PATTERN_WAIT_TIME"; case F_SET_PATTERN_MASK: return "F_SET_PATTERN_MASK"; @@ -332,7 +333,8 @@ void function_table() { flist[F_SET_PATTERN_IO_CONTROL] = &set_pattern_io_control; flist[F_SET_PATTERN_CLOCK_CONTROL] = &set_pattern_clock_control; flist[F_SET_PATTERN_WORD] = &set_pattern_word; - flist[F_SET_PATTERN_LOOP] = &set_pattern_loop; + flist[F_SET_PATTERN_LOOP_ADDRESSES] = &set_pattern_loop_addresses; + flist[F_SET_PATTERN_LOOP_CYCLES] = &set_pattern_loop_cycles; flist[F_SET_PATTERN_WAIT_ADDR] = &set_pattern_wait_addr; flist[F_SET_PATTERN_WAIT_TIME] = &set_pattern_wait_time; flist[F_SET_PATTERN_MASK] = &set_pattern_mask; @@ -2641,13 +2643,11 @@ int set_pattern_word(int file_des) { - - -int set_pattern_loop(int file_des) { +int set_pattern_loop_addresses(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - int args[4] = {-1, -1, -1, -1}; - int retvals[3] = {-1, -1, -1}; + int args[3] = {-1, -1, -1}; + int retvals[2] = {-1, -1}; if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); @@ -2657,32 +2657,28 @@ int set_pattern_loop(int file_des) { int loopLevel = args[0]; int startAddr = args[1]; int stopAddr = args[2]; - int numLoops = args[3]; - FILE_LOG(logDEBUG1, ("Setting Pattern loops (loopLevel:%d startAddr:0x%x stopAddr:0x%x numLoops:%d)\n", loopLevel, startAddr, stopAddr, numLoops)); - if ((startAddr == -1) || (stopAddr == -1) || (numLoops == -1) || (Server_VerifyLock() == OK)) { + FILE_LOG(logDEBUG1, ("Setting Pattern loop addresses(loopLevel:%d startAddr:0x%x stopAddr:0x%x)\n", loopLevel, startAddr, stopAddr)); + if ((startAddr == -1) || (stopAddr == -1) || (Server_VerifyLock() == OK)) { // valid loop level if (loopLevel < -1 || loopLevel > 2) { // loop level of -1 : complete pattern ret = FAIL; - sprintf(mess, "Cannot set Pattern loops. Level %d should be between -1 and 2\n",loopLevel); + sprintf(mess, "Cannot set Pattern loop addresses. Level %d should be between -1 and 2\n",loopLevel); FILE_LOG(logERROR, (mess)); } // valid addr for loop level 0-2 else if (startAddr >= MAX_PATTERN_LENGTH || stopAddr >= MAX_PATTERN_LENGTH ) { ret = FAIL; - sprintf(mess, "Cannot set Pattern loops. Address (start addr:0x%x and stop addr:0x%x) " + sprintf(mess, "Cannot set Pattern loop addresses. Address (start addr:0x%x and stop addr:0x%x) " "should be less than 0x%x\n", startAddr, stopAddr, MAX_PATTERN_LENGTH); FILE_LOG(logERROR, (mess)); - } - - else { + } else { + int numLoops = -1; setPatternLoop(loopLevel, &startAddr, &stopAddr, &numLoops); - FILE_LOG(logDEBUG1, ("Pattern Loops retval: (start:0x%x, stop:0x%x, nloop:%d)\n", startAddr, stopAddr, numLoops)); + FILE_LOG(logDEBUG1, ("Pattern loop addresses retval: (start:0x%x, stop:0x%x)\n", startAddr, stopAddr)); retvals[0] = startAddr; retvals[1] = stopAddr; - retvals[2] = numLoops; validate(args[1], startAddr, "Pattern loops' start address", HEX); validate(args[2], stopAddr, "Pattern loops' stop address", HEX); - validate(args[3], numLoops, "Pattern loops' number of loops", DEC); } } #endif @@ -2691,6 +2687,41 @@ int set_pattern_loop(int file_des) { +int set_pattern_loop_cycles(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int args[2] = {-1, -1}; + int retval = -1; + + if (receiveData(file_des, args, sizeof(args), INT32) < 0) + return printSocketReadError(); +#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D) + functionNotImplemented(); +#else + int loopLevel = args[0]; + int numLoops = args[1]; + FILE_LOG(logDEBUG1, ("Setting Pattern loop cycles (loopLevel:%d numLoops:%d)\n", loopLevel, numLoops)); + if ((numLoops == -1) || (Server_VerifyLock() == OK)) { + // valid loop level + if (loopLevel < 0 || loopLevel > 2) { + ret = FAIL; + sprintf(mess, "Cannot set Pattern loop cycles. Level %d should be between 0 and 2\n",loopLevel); + FILE_LOG(logERROR, (mess)); + } else { + int startAddr = -1; + int stopAddr = -1; + setPatternLoop(loopLevel, &startAddr, &stopAddr, &numLoops); + retval = numLoops; + FILE_LOG(logDEBUG1, ("Pattern loop cycles retval: (ncycles:%d)\n", retval)); + validate(args[1], retval, "Pattern loops' number of cycles", DEC); + } + } +#endif + return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval)); +} + + + diff --git a/slsDetectorSoftware/include/CmdProxy.h b/slsDetectorSoftware/include/CmdProxy.h index 0ea66c0a8..05a39bed8 100644 --- a/slsDetectorSoftware/include/CmdProxy.h +++ b/slsDetectorSoftware/include/CmdProxy.h @@ -714,10 +714,17 @@ class CmdProxy { {"patioctrl", &CmdProxy::patioctrl}, {"patclkctrl", &CmdProxy::patclkctrl}, {"patword", &CmdProxy::PatternWord}, + {"patlimits", &CmdProxy::PatternLoopAddresses}, + {"patloop0", &CmdProxy::PatternLoopAddresses}, + {"patloop1", &CmdProxy::PatternLoopAddresses}, + {"patloop2", &CmdProxy::PatternLoopAddresses}, + {"patnloop0", &CmdProxy::PatternLoopCycles}, + {"patnloop1", &CmdProxy::PatternLoopCycles}, + {"patnloop2", &CmdProxy::PatternLoopCycles}, - {"adcvpp", &CmdProxy::adcvpp}, + {"adcvpp", &CmdProxy::adcvpp},//dac {"lastclient", &CmdProxy::lastclient}, {"lock", &CmdProxy::lock} }; @@ -774,6 +781,10 @@ class CmdProxy { /* Pattern */ std::string Pattern(int action); std::string PatternWord(int action); + std::string PatternLoopAddresses(int action); + std::string PatternLoopCycles(int action); + + /* configuration */ EXECUTE_SET_COMMAND_NOID_1ARG(config, loadConfig, diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index d19a22bfb..3d8c367ec 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -1016,15 +1016,21 @@ class Detector { void setPatternWord(int addr, uint64_t word, Positions pos = {}); /**[CTB] Options: level: -1 (complete pattern) and 0-2 levels - * @returns array of start address, stop address and number of loops + * @returns array of start address and stop address */ - Result> getPatternLoops(int level, + Result> getPatternLoopAddresses(int level, Positions pos = {}) const; - /** [CTB] Options: start, stop, n : 0-2 - * level: -1 (complete pattern) and 0-2 levels */ - void setPatternLoops(int level, int start, int stop, int n, - Positions pos = {}); + /** [CTB] Options: level: -1 (complete pattern) and 0-2 levels */ + void setPatternLoopAddresses(int level, int start, int stop, Positions pos = {}); + + /**[CTB] Options: level: -1 (complete pattern) and 0-2 levels + * @returns number of loops + */ + Result getPatternLoopCycles(int level, Positions pos = {}) const; + + /** [CTB] n: 0-2, level: -1 (complete pattern) and 0-2 levels */ + void setPatternLoopCycles(int level, int n, Positions pos = {}); /* [CTB] */ Result getPatternWaitAddr(int level, Positions pos = {}) const; diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 13e61f4ce..40673b069 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -1644,25 +1644,6 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ uint64_t setPatternWord(int addr, uint64_t word, int detPos = -1); // - /** - * Sets the pattern or loop limits (CTB/ Moench) - * @param level -1 complete pattern, 0,1,2, loop level - * @param start start address for level 0-2, -1 gets - * @param stop stop address for level 0-2, -1 gets - * @param n number of loops for level 0-2, -1 gets - * @param detPos -1 for all detectors in list or specific detector position - */ - void setPatternLoops(int level, int start = -1, int stop = -1, int n = -1, - int detPos = -1); // - - /** - * Gets the pattern loop limits (CTB/ Moench) - * @param level -1 complete pattern, 0,1,2, loop level - * @param detPos -1 for all detectors in list or specific detector position - * @returns array of start address, stop address and number of loops - */ - std::array getPatternLoops(int level, int detPos = -1); // - /** * Sets the wait address (CTB/ Moench) * @param level 0,1,2, wait level diff --git a/slsDetectorSoftware/include/slsDetector.h b/slsDetectorSoftware/include/slsDetector.h index c7cf6b0b7..edf05b44d 100755 --- a/slsDetectorSoftware/include/slsDetector.h +++ b/slsDetectorSoftware/include/slsDetector.h @@ -1620,11 +1620,19 @@ class slsDetector : public virtual slsDetectorDefs { * @param level -1 complete pattern, 0,1,2, loop level * @param start start address for level 0-2, -1 gets * @param stop stop address for level 0-2, -1 gets - * @param n number of loops for level 0-2, -1 gets - * @returns array of start addr, stop addr and number of loops + * @returns array of start addr and stop addr */ - std::array setPatternLoops(int level = -1, int start = -1, - int stop = -1, int n = -1); + std::array setPatternLoopAddresses(int level = -1, int start = -1, + int stop = -1); + + /** + * Sets the pattern or loop limits (CTB/ Moench) + * @param level -1 complete pattern, 0,1,2, loop level + * @param n number of loops for level 0-2, -1 gets + * @returns number of loops + */ + int setPatternLoopCycles(int level = -1, int n = -1); + /** * Sets the wait address (CTB/ Moench) diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 67ffb2f0f..88e5c460b 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1063,4 +1063,94 @@ std::string CmdProxy::PatternWord(int action) { } +std::string CmdProxy::PatternLoopAddresses(int action) { + std::ostringstream os; + os << cmd << ' '; + if (action == defs::HELP_ACTION) { + if (cmd == "patlimits") { + os << "[start addr] [stop addr] \n\t[Ctb] Limits of complete pattern." << '\n'; + } else if (cmd == "patloop0") { + os << "[start addr] [stop addr] \n\t[Ctb] Limits of loop 0." << '\n'; + } else if (cmd == "patloop1") { + os << "[start addr] [stop addr] \n\t[Ctb] Limits of loop 1." << '\n'; + } else if (cmd == "patloop2") { + os << "[start addr] [stop addr] \n\t[Ctb] Limits of loop 2." << '\n'; + } else { + throw sls::RuntimeError("Unknown command, use list to list all commands"); + } + } else { + int level = -1; + if (cmd == "patlimits") { + level = -1; + } else if (cmd == "patloop0") { + level = 0; + } else if (cmd == "patloop1") { + level = 1; + } else if (cmd == "patloop2") { + level = 2; + } else{ + throw sls::RuntimeError("Unknown command, use list to list all commands"); + } + if (action == defs::GET_ACTION) { + if (args.size() != 0) { + WrongNumberOfParameters(0); + } + auto t = det->getPatternLoopAddresses(level, {det_id}); + os << OutStringHex(t) << '\n'; + } else if (action == defs::PUT_ACTION) { + if (args.size() != 2) { + WrongNumberOfParameters(2); + } + det->setPatternLoopAddresses(level, stoiHex(args[0]), stoiHex(args[1]), {det_id}); + os << sls::ToString(args) << '\n'; + } else { + throw sls::RuntimeError("Unknown action"); + } + } + return os.str(); +} + +std::string CmdProxy::PatternLoopCycles(int action) { + std::ostringstream os; + os << cmd << ' '; + if (action == defs::HELP_ACTION) { + if (cmd == "patnloop0") { + os << "[n_cycles] \n\t[Ctb] Number of cycles of loop 0." << '\n'; + } else if (cmd == "patnloop1") { + os << "[n_cycles] \n\t[Ctb] Number of cycles of loop 1." << '\n'; + } else if (cmd == "patnloop2") { + os << "[n_cycles] \n\t[Ctb] Number of cycles of loop 2." << '\n'; + } else { + throw sls::RuntimeError("Unknown command, use list to list all commands"); + } + } else { + int level = -1; + if (cmd == "patnloop0") { + level = 0; + } else if (cmd == "patnloop1") { + level = 1; + } else if (cmd == "patnloop2") { + level = 2; + } else{ + throw sls::RuntimeError("Unknown command, use list to list all commands"); + } + if (action == defs::GET_ACTION) { + if (args.size() != 0) { + WrongNumberOfParameters(0); + } + auto t = det->getPatternLoopCycles(level, {det_id}); + os << OutString(t) << '\n'; + } else if (action == defs::PUT_ACTION) { + if (args.size() != 1) { + WrongNumberOfParameters(1); + } + det->setPatternLoopCycles(level, std::stoi(args[0]), {det_id}); + os << args.front() << '\n'; + } else { + throw sls::RuntimeError("Unknown action"); + } + } + return os.str(); +} + } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 637ecd005..c00a03929 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1327,15 +1327,20 @@ void Detector::setPatternWord(int addr, uint64_t word, Positions pos) { pimpl->Parallel(&slsDetector::setPatternWord, pos, addr, word); } -Result> Detector::getPatternLoops(int level, - Positions pos) const { - return pimpl->Parallel(&slsDetector::setPatternLoops, pos, level, -1, -1, - -1); +Result> Detector::getPatternLoopAddresses(int level, Positions pos) const { + return pimpl->Parallel(&slsDetector::setPatternLoopAddresses, pos, level, -1, -1); } -void Detector::setPatternLoops(int level, int start, int stop, int n, - Positions pos) { - pimpl->Parallel(&slsDetector::setPatternLoops, pos, level, start, stop, n); +void Detector::setPatternLoopAddresses(int level, int start, int stop, Positions pos) { + pimpl->Parallel(&slsDetector::setPatternLoopAddresses, pos, level, start, stop); +} + +Result Detector::getPatternLoopCycles(int level, Positions pos) const { + return pimpl->Parallel(&slsDetector::setPatternLoopCycles, pos, level, -1); +} + +void Detector::setPatternLoopCycles(int level, int n, Positions pos) { + pimpl->Parallel(&slsDetector::setPatternLoopCycles, pos, level, n); } Result Detector::getPatternWaitAddr(int level, Positions pos) const { diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index 4dbe31a56..e6acb9e9b 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -2831,7 +2831,8 @@ void multiSlsDetector::savePattern(const std::string &fname) { throw RuntimeError("Could not create file to save pattern"); } // get pattern limits - auto r = getPatternLoops(-1); + auto r = Parallel(&slsDetector::setPatternLoopAddresses, {}, -1, -1, -1) + .tsquash("Inconsistent pattern limits"); // pattern words for (int i = r[0]; i <= r[1]; ++i) { std::ostringstream os; @@ -2896,28 +2897,6 @@ uint64_t multiSlsDetector::setPatternWord(int addr, uint64_t word, int detPos) { return sls::minusOneIfDifferent(r); } -void multiSlsDetector::setPatternLoops(int level, int start, int stop, int n, - int detPos) { - // single - if (detPos >= 0) { - detectors[detPos]->setPatternLoops(level, start, stop, n); - } - - // multi - parallelCall(&slsDetector::setPatternLoops, level, start, stop, n); -} - -std::array multiSlsDetector::getPatternLoops(int level, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->setPatternLoops(level, -1, -1, -1); - } - - // multi - auto r = parallelCall(&slsDetector::setPatternLoops, level, -1, -1, -1); - return sls::minusOneIfDifferent(r); -} - int multiSlsDetector::setPatternWaitAddr(int level, int addr, int detPos) { // single if (detPos >= 0) { diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index ab2bc2eef..0347a0750 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -3243,19 +3243,26 @@ uint64_t slsDetector::setPatternWord(int addr, uint64_t word) { return retval; } -std::array slsDetector::setPatternLoops(int level, int start, int stop, - int n) { - int args[]{level, start, stop, n}; - std::array retvals{}; - FILE_LOG(logDEBUG1) << "Setting Pat Loops, level: " << level - << ", start: " << start << ", stop: " << stop - << ", nloops: " << n; - sendToDetector(F_SET_PATTERN_LOOP, args, retvals); - FILE_LOG(logDEBUG1) << "Set Pat Loops: " << retvals[0] << ", " << retvals[1] - << ", " << retvals[2]; +std::array slsDetector::setPatternLoopAddresses(int level, int start, int stop) { + int args[]{level, start, stop}; + std::array retvals{}; + FILE_LOG(logDEBUG1) << "Setting Pat Loop Addresses, level: " << level + << ", start: " << start << ", stop: " << stop; + sendToDetector(F_SET_PATTERN_LOOP_ADDRESSES, args, retvals); + FILE_LOG(logDEBUG1) << "Set Pat Loop Addresses: " << retvals[0] << ", " << retvals[1]; return retvals; } +int slsDetector::setPatternLoopCycles(int level, int n) { + int args[]{level, n}; + int retval = -1; + FILE_LOG(logDEBUG1) << "Setting Pat Loop cycles, level: " << level + << ",nloops: " << n; + sendToDetector(F_SET_PATTERN_LOOP_CYCLES, args, retval); + FILE_LOG(logDEBUG1) << "Set Pat Loop Cycles: " << retval; + return retval; +} + int slsDetector::setPatternWaitAddr(int level, int addr) { int retval = -1; int args[]{level, addr}; diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index dcd161d50..2878f31c3 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -978,27 +978,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor; ++i; - /*! \page prototype - - patlimits [addr1 addr2] sets/gets the start and stop limits of the pattern to be executed. hex format. Advanced! - */ - descrToFuncMap[i].m_pFuncName = "patlimits"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; - ++i; - - /*! \page prototype - - patloop0 [addr1 addr2] sets/gets the start and stop limits of the level 0 loop. hex format. Advanced! - */ - descrToFuncMap[i].m_pFuncName = "patloop0"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; - ++i; - - /*! \page prototype - - patnloop0 [n] sets/gets the number of cyclesof the level 0 loop (int). - */ - descrToFuncMap[i].m_pFuncName = "patnloop0"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; - ++i; - /*! \page prototype - patwait0 [addr] sets/gets the address of the level 0 wait point. hex format. Advanced! */ @@ -1013,21 +992,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; ++i; - /*! \page prototype - - patloop1 [addr1 addr2] sets/gets the start and stop limits of the level 1 loop. hex format. Advanced! - */ - descrToFuncMap[i].m_pFuncName = "patloop1"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; - ++i; - - /*! \page prototype - - patnloop1 [n] sets/gets the number of cyclesof the level 1 loop (int). - */ - descrToFuncMap[i].m_pFuncName = "patnloop1"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; - ++i; - - /*! \page prototype + /*! \page prototype - patwait1 [addr] sets/gets the address of the level 1 wait point. hex format. Advanced! */ descrToFuncMap[i].m_pFuncName = "patwait1"; @@ -1041,21 +1006,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; ++i; - /*! \page prototype - - patloop2 [addr1 addr2] sets/gets the start and stop limits of the level 2 loop. hex format. Advanced! - */ - descrToFuncMap[i].m_pFuncName = "patloop2"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; - ++i; - - /*! \page prototype - - patnloop2 [n] sets/gets the number of cyclesof the level 2 loop (int). - */ - descrToFuncMap[i].m_pFuncName = "patnloop2"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern; - ++i; - - /*! \page prototype + /*! \page prototype - patwait2 [addr] sets/gets the address of the level 2 wait point. hex format. Advanced! */ descrToFuncMap[i].m_pFuncName = "patwait2"; @@ -2220,13 +2171,6 @@ std::string slsDetectorCommand::helpPattern(int action) { std::ostringstream os; if (action == PUT_ACTION || action == HELP_ACTION) { - os << "patlimits addr1 addr2\t defines pattern limits between addr1 and addr2" << std::endl; - os << "patloop0 addr1 adrr2 \t configures the limits of the 0 loop " << std::endl; - os << "patloop1 addr1 adrr2 \t configures the limits of the 1 loop " << std::endl; - os << "patloop2 addr1 adrr2 \t configures the limits of the 2 loop " << std::endl; - os << "patnloop0 n \t sets number of cycles of the 0 loop " << std::endl; - os << "patnloop1 n \t sets number of cycles of the 1 loop " << std::endl; - os << "patnloop2 n \t sets number of cycles of the 2 loop " << std::endl; os << "patwait0 addr \t configures pattern wait 0 address " << std::endl; os << "patwait1 addr \t configures pattern wait 1 address " << std::endl; os << "patwait2 addr \t configures pattern wait 2 address " << std::endl; @@ -2237,13 +2181,6 @@ std::string slsDetectorCommand::helpPattern(int action) { 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 << "patlimits \t returns pattern limits between addr1 and addr2" << std::endl; - os << "patloop0 \t returns the limits of the 0 loop " << std::endl; - os << "patloop1 \t returns the limits of the 1 loop " << std::endl; - os << "patloop2 \t returns the limits of the 2 loop " << std::endl; - os << "patnloop0 \t returns the number of cycles of the 0 loop " << std::endl; - os << "patnloop1 \t returns the number of cycles of the 1 loop " << std::endl; - os << "patnloop2 \t returns the number of cycles of the 2 loop " << std::endl; os << "patwait0 \t returns the pattern wait 0 address " << std::endl; os << "patwait1 \t returns the pattern wait 1 address " << std::endl; os << "patwait2 \t returns the pattern wait 2 address " << std::endl; @@ -2272,149 +2209,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[], std::ostringstream os; - if (cmd == "patlimits") { - //get start, stop from stdin - if (action == PUT_ACTION) { - if (narg < 3) - return std::string("wrong usage: should specify both start and stop address (hexadecimal fomat) "); - n = -1; - if (sscanf(args[1], "%x", &start)) - ; - else - return std::string("Could not scan start address (hexadecimal fomat) ") + std::string(args[1]); - - if (sscanf(args[2], "%x", &stop)) - ; - else - return std::string("Could not scan stop address (hexadecimal fomat) ") + std::string(args[2]); - - myDet->setPatternLoops(-1, start, stop, n, detPos); - } - - auto r = myDet->getPatternLoops(-1, detPos); - os << "0x" << std::setw(4) << std::setfill('0') << std::hex << r[0] << " 0x" << std::setw(4) << std::setfill('0') << r[1]; - } else if (cmd == "patloop0") { - //get start, stop from stdin - - //get start, stop from stdin - if (action == PUT_ACTION) { - if (narg < 3) - return std::string("wrong usage: should specify both start and stop address (hexadecimal fomat) "); - n = -1; - if (sscanf(args[1], "%x", &start)) - ; - else - return std::string("Could not scan start address (hexadecimal fomat) ") + std::string(args[1]); - - if (sscanf(args[2], "%x", &stop)) - ; - else - return std::string("Could not scan stop address (hexadecimal fomat) ") + std::string(args[2]); - - myDet->setPatternLoops(0, start, stop, n, detPos); - } - - auto r = myDet->getPatternLoops(0, detPos); - os << "0x" << std::setw(4) << std::setfill('0') << std::hex << r[0] << " 0x" << std::setw(4) << std::setfill('0') << r[1]; - - } else if (cmd == "patloop1") { - - //get start, stop from stdin - if (action == PUT_ACTION) { - if (narg < 3) - return std::string("wrong usage: should specify both start and stop address (hexadecimal fomat) "); - n = -1; - if (sscanf(args[1], "%x", &start)) - ; - else - return std::string("Could not scan start address (hexadecimal fomat) ") + std::string(args[1]); - - if (sscanf(args[2], "%x", &stop)) - ; - else - return std::string("Could not scan stop address (hexadecimal fomat) ") + std::string(args[2]); - - myDet->setPatternLoops(1, start, stop, n, detPos); - } - - auto r = myDet->getPatternLoops(1, detPos); - os << "0x" << std::setw(4) << std::setfill('0') << std::hex << r[0] << " 0x" << std::setw(4) << std::setfill('0') << r[1]; - - } else if (cmd == "patloop2") { - - //get start, stop from stdin - if (action == PUT_ACTION) { - if (narg < 3) - return std::string("wrong usage: should specify both start and stop address (hexadecimal fomat) "); - n = -1; - if (sscanf(args[1], "%x", &start)) - ; - else - return std::string("Could not scan start address (hexadecimal fomat) ") + std::string(args[1]); - - if (sscanf(args[2], "%x", &stop)) - ; - else - return std::string("Could not scan stop address (hexadecimal fomat) ") + std::string(args[2]); - - myDet->setPatternLoops(2, start, stop, n, detPos); - } - - auto r = myDet->getPatternLoops(2, detPos); - os << "0x" << std::setw(4) << std::setfill('0') << std::hex << r[0] << " 0x" << std::setw(4) << std::setfill('0') << r[1]; - } else if (cmd == "patnloop0") { - start = -1; - stop = -1; - - if (action == PUT_ACTION) { - - if (sscanf(args[1], "%d", &n)) - ; - else - return std::string("Could not scan number of loops ") + std::string(args[1]); - - myDet->setPatternLoops(0, start, stop, n, detPos); - } - - auto r = myDet->getPatternLoops(0, detPos); - os << std::dec << r[2]; - } else if (cmd == "patnloop1") { - - start = -1; - stop = -1; - - if (action == PUT_ACTION) { - - if (sscanf(args[1], "%d", &n)) - ; - else - return std::string("Could not scan number of loops ") + std::string(args[1]); - - myDet->setPatternLoops(1, start, stop, n, detPos); - } - - auto r = myDet->getPatternLoops(1, detPos); - os << std::dec << r[2]; - - } else if (cmd == "patnloop2") { - - start = -1; - stop = -1; - - if (action == PUT_ACTION) { - - if (sscanf(args[1], "%d", &n)) - ; - else - return std::string("Could not scan number of loops ") + std::string(args[1]); - - myDet->setPatternLoops(2, start, stop, n, detPos); - } - - auto r = myDet->getPatternLoops(2, detPos); - os << std::dec << r[2]; - - } else if (cmd == "patwait0") { + if (cmd == "patwait0") { if (action == PUT_ACTION) { diff --git a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp index fc927cb9a..6d8f2cf6d 100644 --- a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp +++ b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp @@ -9,6 +9,78 @@ auto GET = slsDetectorDefs::GET_ACTION; auto PUT = slsDetectorDefs::PUT_ACTION; +TEST_CASE("patnloop", "[.cmd][.ctb]") { + for (int loop = 0; loop < 3; ++loop) { + if (test::type == slsDetectorDefs::CHIPTESTBOARD) { + int val = 0; + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("patnloop" + std::to_string(loop), GET, nullptr, oss)); + std::string s = (oss.str()).erase (0, strlen("patnloop") + 2); + val = std::stoi(s); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("patnloop" + std::to_string(loop) + " 5", PUT, nullptr, oss)); + REQUIRE(oss.str() == "patnloop" + std::to_string(loop) + " 5\n"); + } + REQUIRE_NOTHROW(multiSlsDetectorClient("patnloop" + std::to_string(loop) + ' ' + std::to_string(val), PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("patnloop" + std::to_string(loop), GET)); + } + } +} + +TEST_CASE("patloop", "[.cmd][.ctb]") { + for (int loop = 0; loop < 3; ++loop) { + if (test::type == slsDetectorDefs::CHIPTESTBOARD) { + uint32_t limit1 = 0, limit2 = 0; + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("patloop" + std::to_string(loop), GET, nullptr, oss)); + std::string s = oss.str(); + auto t = sls::split(s, ' '); + s = t[1].erase (0, 1); + limit1 = stoul(s, 0, 16); + limit2 = stoul(t[2], 0, 16); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("patloop" + std::to_string(loop) + " 0x20 0x5c", PUT, nullptr, oss)); + REQUIRE(oss.str() == "patloop" + std::to_string(loop) + " [0x20, 0x5c]\n"); + } + REQUIRE_NOTHROW(multiSlsDetectorClient("patloop" + std::to_string(loop) + ' ' + sls::ToStringHex(limit1) + ' ' + sls::ToStringHex(limit2), PUT)); + REQUIRE_THROWS(multiSlsDetectorClient("patloop" + std::to_string(loop) + " 0x3", PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("patloop" + std::to_string(loop), GET)); + } + } +} + +TEST_CASE("patlimits", "[.cmd][.ctb]") { + if (test::type == slsDetectorDefs::CHIPTESTBOARD) { + uint32_t patlimit1 = 0, patlimit2 = 0; + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("patlimits", GET, nullptr, oss)); + std::string s = oss.str(); + auto t = sls::split(s, ' '); + s = t[1].erase (0, 1); + patlimit1 = stoul(s, 0, 16); + patlimit2 = stoul(t[2], 0, 16); + } + { + std::ostringstream oss; + REQUIRE_NOTHROW(multiSlsDetectorClient("patlimits 0x20 0x5c", PUT, nullptr, oss)); + REQUIRE(oss.str() == "patlimits [0x20, 0x5c]\n"); + } + REQUIRE_NOTHROW(multiSlsDetectorClient("patlimits " + sls::ToStringHex(patlimit1) + ' ' + sls::ToStringHex(patlimit2), PUT)); + } else { + REQUIRE_THROWS(multiSlsDetectorClient("patlimits", GET)); + } +} + + TEST_CASE("patword", "[.cmd][.ctb]") { if (test::type == slsDetectorDefs::CHIPTESTBOARD) { uint64_t prev_value = 0; diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h index bf0286f4d..49decc2a2 100755 --- a/slsSupportLib/include/sls_detector_funcs.h +++ b/slsSupportLib/include/sls_detector_funcs.h @@ -46,7 +46,8 @@ enum detFuncs{ F_SET_PATTERN_IO_CONTROL, /** < set pattern i/o control */ F_SET_PATTERN_CLOCK_CONTROL, /** < set pattern clock control */ F_SET_PATTERN_WORD, /** < sets pattern word */ - F_SET_PATTERN_LOOP, /** < sets pattern loop */ + F_SET_PATTERN_LOOP_ADDRESSES, /** < sets pattern loop */ + F_SET_PATTERN_LOOP_CYCLES, F_SET_PATTERN_WAIT_ADDR, /** < sets pattern wait addr */ F_SET_PATTERN_WAIT_TIME, /** < sets pattern wait time */ F_SET_PATTERN_MASK, /** < loads a pattern mask */ @@ -236,7 +237,8 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_PATTERN_IO_CONTROL: return "F_SET_PATTERN_IO_CONTROL"; case F_SET_PATTERN_CLOCK_CONTROL: return "F_SET_PATTERN_CLOCK_CONTROL"; case F_SET_PATTERN_WORD: return "F_SET_PATTERN_WORD"; - case F_SET_PATTERN_LOOP: return "F_SET_PATTERN_LOOP"; + case F_SET_PATTERN_LOOP_ADDRESSES: return "F_SET_PATTERN_LOOP_ADDRESSES"; + case F_SET_PATTERN_LOOP_CYCLES: return "F_SET_PATTERN_LOOP_CYCLES"; case F_SET_PATTERN_WAIT_ADDR: return "F_SET_PATTERN_WAIT_ADDR"; case F_SET_PATTERN_WAIT_TIME: return "F_SET_PATTERN_WAIT_TIME"; case F_SET_PATTERN_MASK: return "F_SET_PATTERN_MASK"; diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index b24830601..9794af6da 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -6,7 +6,7 @@ #define APIMOENCH 0x190820 #define APIMYTHEN3 0x191011 #define APIGOTTHARD2 0x191017 -#define APIEIGER 0x191021 -#define APIJUNGFRAU 0x191022 -#define APIGOTTHARD 0x191021 -#define APICTB 0x191021 +#define APIGOTTHARD 0x191024 +#define APIJUNGFRAU 0x191024 +#define APIEIGER 0x191024 +#define APICTB 0x191024