added getPatternLoop

This commit is contained in:
Erik Frojdh
2019-04-18 09:33:14 +02:00
parent 849d3ba049
commit f591adccb8
8 changed files with 127 additions and 50 deletions

View File

@ -3602,7 +3602,7 @@ uint64_t multiSlsDetector::setPatternWord(int addr, uint64_t word, int detPos) {
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::setPatternLoops(int level, int &start, int &stop, int &n, int detPos) {
int multiSlsDetector::setPatternLoops(uint64_t level, uint64_t start, uint64_t stop, uint64_t n, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setPatternLoops(level, start, stop, n);
@ -3616,6 +3616,14 @@ int multiSlsDetector::setPatternLoops(int level, int &start, int &stop, int &n,
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
std::array<uint64_t, 3> multiSlsDetector::getPatternLoops(uint64_t level, int detPos){
if (detPos >= 0)
return detectors[detPos]->getPatternLoops(level);
auto r = parallelCall(&slsDetector::getPatternLoops, level);
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::setPatternWaitAddr(int level, int addr, int detPos) {
// single
if (detPos >= 0) {

View File

@ -4498,14 +4498,12 @@ uint64_t slsDetector::setPatternWord(uint64_t addr, uint64_t word) {
return retval;
}
int slsDetector::setPatternLoops(int level, int &start, int &stop, int &n) {
// TODO!(Erik) Should we change function signature to accept uint64_t?
int slsDetector::setPatternLoops(uint64_t level, uint64_t start, uint64_t stop,
uint64_t n) {
int fnum = F_SET_PATTERN;
int ret = FAIL;
uint64_t mode = 1; // sets loop
uint64_t args[5]{mode, static_cast<uint64_t>(level),
static_cast<uint64_t>(start), static_cast<uint64_t>(stop),
static_cast<uint64_t>(n)};
uint64_t args[]{mode, level, start, stop, n};
int retvals[3]{};
FILE_LOG(logDEBUG1) << "Setting Pat Loops, level: " << level
<< ", start: " << start << ", stop: " << stop
@ -4518,9 +4516,9 @@ int slsDetector::setPatternLoops(int level, int &start, int &stop, int &n) {
sizeof(retvals));
FILE_LOG(logDEBUG1) << "Set Pat Loops: " << retvals[0] << ", "
<< retvals[1] << ", " << retvals[2];
start = retvals[0];
stop = retvals[1];
n = retvals[2];
assert(start == retvals[0]);
assert(stop == retvals[1]);
assert(n == retvals[2]);
}
if (ret == FORCE_UPDATE) {
updateDetector();
@ -4528,6 +4526,35 @@ int slsDetector::setPatternLoops(int level, int &start, int &stop, int &n) {
return ret;
}
std::array<uint64_t, 3> slsDetector::getPatternLoops(uint64_t level) {
int fnum = F_SET_PATTERN;
int ret = FAIL;
uint64_t mode = 1; // sets loop
uint64_t args[]{mode, level, static_cast<uint64_t>(-1),
static_cast<uint64_t>(-1), static_cast<uint64_t>(-1)};
int retvals[3]{};
FILE_LOG(logDEBUG1) << "Setting Pat Loops, level: " << level
<< ", start: " << -1 << ", stop: " << -1
<< ", n: " << -1;
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname,
detector_shm()->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), retvals,
sizeof(retvals));
FILE_LOG(logDEBUG1) << "Get Pat Loops: " << retvals[0] << ", "
<< retvals[1] << ", " << retvals[2];
}
if (ret == FORCE_UPDATE) {
updateDetector();
}
std::array<uint64_t, 3> r{};
r[0] = retvals[0];
r[1] = retvals[1];
r[2] = retvals[2];
return r;
}
int slsDetector::setPatternWaitAddr(uint64_t level, uint64_t addr) {
int fnum = F_SET_PATTERN;
int ret = FAIL;

View File

@ -5295,11 +5295,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
myDet->setPatternLoops(-1, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setPatternLoops(-1, start, stop, n, detPos);
os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
// start = -1;
// stop = -1;
// n = -1;
// myDet->setPatternLoops(-1, start, stop, n, detPos);
auto r = myDet->getPatternLoops(-1, detPos);
os << std::hex << r[0] << " " << r[1];
// os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
} else if (cmd == "patloop0") {
//get start, stop from stdin
@ -5321,11 +5323,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
myDet->setPatternLoops(0, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setPatternLoops(0, start, stop, n, detPos);
os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
// start = -1;
// stop = -1;
// n = -1;
// myDet->setPatternLoops(0, start, stop, n, detPos);
// os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
auto r = myDet->getPatternLoops(0, detPos);
os << std::hex << r[0] << " " << r[1];
} else if (cmd == "patloop1") {
@ -5347,11 +5351,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
myDet->setPatternLoops(1, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setPatternLoops(1, start, stop, n, detPos);
os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
// start = -1;
// stop = -1;
// n = -1;
// myDet->setPatternLoops(1, start, stop, n, detPos);
// os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
auto r = myDet->getPatternLoops(1, detPos);
os << std::hex << r[0] << " " << r[1];
} else if (cmd == "patloop2") {
@ -5373,12 +5379,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
myDet->setPatternLoops(2, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setPatternLoops(2, start, stop, n, detPos);
os << std::hex << start << " " << stop << std::dec; // << " "<< std::dec << n ;
// start = -1;
// stop = -1;
// n = -1;
// myDet->setPatternLoops(2, start, stop, n, detPos);
// os << std::hex << start << " " << stop << std::dec; // << " "<< std::dec << n ;
auto r = myDet->getPatternLoops(2, detPos);
os << std::hex << r[0] << " " << r[1];
} else if (cmd == "patnloop0") {
start = -1;
stop = -1;
@ -5393,11 +5400,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
myDet->setPatternLoops(0, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setPatternLoops(0, start, stop, n, detPos);
os << n;
// start = -1;
// stop = -1;
// n = -1;
// myDet->setPatternLoops(0, start, stop, n, detPos);
// os << n;
auto r = myDet->getPatternLoops(0, detPos);
os << std::hex << r[2];
} else if (cmd == "patnloop1") {
start = -1;
@ -5413,11 +5422,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
myDet->setPatternLoops(1, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setPatternLoops(1, start, stop, n, detPos);
os << n;
// start = -1;
// stop = -1;
// n = -1;
// myDet->setPatternLoops(1, start, stop, n, detPos);
// os << n;
auto r = myDet->getPatternLoops(1, detPos);
os << std::hex << r[2];
} else if (cmd == "patnloop2") {
@ -5434,11 +5445,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
myDet->setPatternLoops(2, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setPatternLoops(2, start, stop, n, detPos);
os << n;
// start = -1;
// stop = -1;
// n = -1;
// myDet->setPatternLoops(2, start, stop, n, detPos);
// os << n;
auto r = myDet->getPatternLoops(2, detPos);
os << std::hex << r[2];
} else if (cmd == "patwait0") {