patloops done

This commit is contained in:
2019-10-24 18:59:23 +02:00
parent f73a15e786
commit f4a0780b51
21 changed files with 301 additions and 311 deletions

View File

@ -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

View File

@ -1327,15 +1327,20 @@ void Detector::setPatternWord(int addr, uint64_t word, Positions pos) {
pimpl->Parallel(&slsDetector::setPatternWord, pos, addr, word);
}
Result<std::array<int, 3>> Detector::getPatternLoops(int level,
Positions pos) const {
return pimpl->Parallel(&slsDetector::setPatternLoops, pos, level, -1, -1,
-1);
Result<std::array<int, 2>> 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<int> 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<int> Detector::getPatternWaitAddr(int level, Positions pos) const {

View File

@ -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<int, 3> 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) {

View File

@ -3243,19 +3243,26 @@ uint64_t slsDetector::setPatternWord(int addr, uint64_t word) {
return retval;
}
std::array<int, 3> slsDetector::setPatternLoops(int level, int start, int stop,
int n) {
int args[]{level, start, stop, n};
std::array<int, 3> 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<int, 2> slsDetector::setPatternLoopAddresses(int level, int start, int stop) {
int args[]{level, start, stop};
std::array<int, 2> 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};

View File

@ -978,27 +978,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdProcessor;
++i;
/*! \page prototype
- <b>patlimits [addr1 addr2]</b> 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
- <b>patloop0 [addr1 addr2]</b> 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
- <b>patnloop0 [n]</b> 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
- <b>patwait0 [addr]</b> 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
- <b>patloop1 [addr1 addr2]</b> 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
- <b>patnloop1 [n]</b> 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
- <b>patwait1 [addr]</b> 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
- <b>patloop2 [addr1 addr2]</b> 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
- <b>patnloop2 [n]</b> 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
- <b>patwait2 [addr]</b> 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) {