mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00
added getPatternLoop
This commit is contained in:
parent
849d3ba049
commit
f591adccb8
@ -1824,9 +1824,13 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
|||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
* @returns OK/FAIL
|
* @returns OK/FAIL
|
||||||
*/
|
*/
|
||||||
int setPatternLoops(int level, int &start, int &stop, int &n,
|
int setPatternLoops(uint64_t level, uint64_t start, uint64_t stop, uint64_t n,
|
||||||
int detPos = -1);
|
int detPos = -1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::array<uint64_t, 3> getPatternLoops(uint64_t level, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the wait address in the CTB
|
* Sets the wait address in the CTB
|
||||||
* @param level 0,1,2, wait level
|
* @param level 0,1,2, wait level
|
||||||
|
@ -10,6 +10,7 @@ class ClientInterface;
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
class multiSlsDetector;
|
class multiSlsDetector;
|
||||||
class ServerInterface;
|
class ServerInterface;
|
||||||
@ -1657,7 +1658,9 @@ class slsDetector : public virtual slsDetectorDefs{
|
|||||||
* @param n number of loops (if level >=0)
|
* @param n number of loops (if level >=0)
|
||||||
* @returns OK/FAIL
|
* @returns OK/FAIL
|
||||||
*/
|
*/
|
||||||
int setPatternLoops(int level, int &start, int &stop, int &n);
|
int setPatternLoops(uint64_t level, uint64_t start, uint64_t stop, uint64_t n);
|
||||||
|
|
||||||
|
std::array<uint64_t, 3> getPatternLoops(uint64_t level);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the wait address in the CTB
|
* Sets the wait address in the CTB
|
||||||
|
@ -3602,7 +3602,7 @@ uint64_t multiSlsDetector::setPatternWord(int addr, uint64_t word, int detPos) {
|
|||||||
return sls::minusOneIfDifferent(r);
|
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
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
return detectors[detPos]->setPatternLoops(level, start, stop, n);
|
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;
|
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) {
|
int multiSlsDetector::setPatternWaitAddr(int level, int addr, int detPos) {
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
|
@ -4498,14 +4498,12 @@ uint64_t slsDetector::setPatternWord(uint64_t addr, uint64_t word) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsDetector::setPatternLoops(int level, int &start, int &stop, int &n) {
|
int slsDetector::setPatternLoops(uint64_t level, uint64_t start, uint64_t stop,
|
||||||
// TODO!(Erik) Should we change function signature to accept uint64_t?
|
uint64_t n) {
|
||||||
int fnum = F_SET_PATTERN;
|
int fnum = F_SET_PATTERN;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
uint64_t mode = 1; // sets loop
|
uint64_t mode = 1; // sets loop
|
||||||
uint64_t args[5]{mode, static_cast<uint64_t>(level),
|
uint64_t args[]{mode, level, start, stop, n};
|
||||||
static_cast<uint64_t>(start), static_cast<uint64_t>(stop),
|
|
||||||
static_cast<uint64_t>(n)};
|
|
||||||
int retvals[3]{};
|
int retvals[3]{};
|
||||||
FILE_LOG(logDEBUG1) << "Setting Pat Loops, level: " << level
|
FILE_LOG(logDEBUG1) << "Setting Pat Loops, level: " << level
|
||||||
<< ", start: " << start << ", stop: " << stop
|
<< ", start: " << start << ", stop: " << stop
|
||||||
@ -4518,9 +4516,9 @@ int slsDetector::setPatternLoops(int level, int &start, int &stop, int &n) {
|
|||||||
sizeof(retvals));
|
sizeof(retvals));
|
||||||
FILE_LOG(logDEBUG1) << "Set Pat Loops: " << retvals[0] << ", "
|
FILE_LOG(logDEBUG1) << "Set Pat Loops: " << retvals[0] << ", "
|
||||||
<< retvals[1] << ", " << retvals[2];
|
<< retvals[1] << ", " << retvals[2];
|
||||||
start = retvals[0];
|
assert(start == retvals[0]);
|
||||||
stop = retvals[1];
|
assert(stop == retvals[1]);
|
||||||
n = retvals[2];
|
assert(n == retvals[2]);
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
if (ret == FORCE_UPDATE) {
|
||||||
updateDetector();
|
updateDetector();
|
||||||
@ -4528,6 +4526,35 @@ int slsDetector::setPatternLoops(int level, int &start, int &stop, int &n) {
|
|||||||
return ret;
|
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 slsDetector::setPatternWaitAddr(uint64_t level, uint64_t addr) {
|
||||||
int fnum = F_SET_PATTERN;
|
int fnum = F_SET_PATTERN;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
|
@ -5295,11 +5295,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
|
|||||||
myDet->setPatternLoops(-1, start, stop, n, detPos);
|
myDet->setPatternLoops(-1, start, stop, n, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
start = -1;
|
// start = -1;
|
||||||
stop = -1;
|
// stop = -1;
|
||||||
n = -1;
|
// n = -1;
|
||||||
myDet->setPatternLoops(-1, start, stop, n, detPos);
|
// 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];
|
||||||
|
// os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
|
||||||
} else if (cmd == "patloop0") {
|
} else if (cmd == "patloop0") {
|
||||||
//get start, stop from stdin
|
//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);
|
myDet->setPatternLoops(0, start, stop, n, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
start = -1;
|
// start = -1;
|
||||||
stop = -1;
|
// stop = -1;
|
||||||
n = -1;
|
// n = -1;
|
||||||
myDet->setPatternLoops(0, start, stop, n, detPos);
|
// myDet->setPatternLoops(0, start, stop, n, detPos);
|
||||||
os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
|
// 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") {
|
} 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);
|
myDet->setPatternLoops(1, start, stop, n, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
start = -1;
|
// start = -1;
|
||||||
stop = -1;
|
// stop = -1;
|
||||||
n = -1;
|
// n = -1;
|
||||||
myDet->setPatternLoops(1, start, stop, n, detPos);
|
// myDet->setPatternLoops(1, start, stop, n, detPos);
|
||||||
os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
|
// 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") {
|
} 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);
|
myDet->setPatternLoops(2, start, stop, n, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
start = -1;
|
// start = -1;
|
||||||
stop = -1;
|
// stop = -1;
|
||||||
n = -1;
|
// n = -1;
|
||||||
myDet->setPatternLoops(2, start, stop, n, detPos);
|
// myDet->setPatternLoops(2, start, stop, n, detPos);
|
||||||
os << std::hex << start << " " << stop << std::dec; // << " "<< std::dec << n ;
|
// 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") {
|
} else if (cmd == "patnloop0") {
|
||||||
start = -1;
|
start = -1;
|
||||||
stop = -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);
|
myDet->setPatternLoops(0, start, stop, n, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
start = -1;
|
// start = -1;
|
||||||
stop = -1;
|
// stop = -1;
|
||||||
n = -1;
|
// n = -1;
|
||||||
myDet->setPatternLoops(0, start, stop, n, detPos);
|
// myDet->setPatternLoops(0, start, stop, n, detPos);
|
||||||
os << n;
|
// os << n;
|
||||||
|
auto r = myDet->getPatternLoops(0, detPos);
|
||||||
|
os << std::hex << r[2];
|
||||||
} else if (cmd == "patnloop1") {
|
} else if (cmd == "patnloop1") {
|
||||||
|
|
||||||
start = -1;
|
start = -1;
|
||||||
@ -5413,11 +5422,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
|
|||||||
myDet->setPatternLoops(1, start, stop, n, detPos);
|
myDet->setPatternLoops(1, start, stop, n, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
start = -1;
|
// start = -1;
|
||||||
stop = -1;
|
// stop = -1;
|
||||||
n = -1;
|
// n = -1;
|
||||||
myDet->setPatternLoops(1, start, stop, n, detPos);
|
// myDet->setPatternLoops(1, start, stop, n, detPos);
|
||||||
os << n;
|
// os << n;
|
||||||
|
auto r = myDet->getPatternLoops(1, detPos);
|
||||||
|
os << std::hex << r[2];
|
||||||
|
|
||||||
} else if (cmd == "patnloop2") {
|
} 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);
|
myDet->setPatternLoops(2, start, stop, n, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
start = -1;
|
// start = -1;
|
||||||
stop = -1;
|
// stop = -1;
|
||||||
n = -1;
|
// n = -1;
|
||||||
myDet->setPatternLoops(2, start, stop, n, detPos);
|
// myDet->setPatternLoops(2, start, stop, n, detPos);
|
||||||
os << n;
|
// os << n;
|
||||||
|
auto r = myDet->getPatternLoops(2, detPos);
|
||||||
|
os << std::hex << r[2];
|
||||||
|
|
||||||
} else if (cmd == "patwait0") {
|
} else if (cmd == "patwait0") {
|
||||||
|
|
||||||
|
@ -109,6 +109,19 @@ minusOneIfDifferent(const std::vector<std::vector<T>> &container) {
|
|||||||
return std::vector<T>{-1};
|
return std::vector<T>{-1};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t size>
|
||||||
|
std::array<T, size>
|
||||||
|
minusOneIfDifferent(const std::vector<std::array<T,size>> &container) {
|
||||||
|
if (allEqual(container))
|
||||||
|
return container.front();
|
||||||
|
|
||||||
|
std::array<T,size> arr;
|
||||||
|
arr.fill(static_cast<T>(-1));
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
|
||||||
#endif // CONTAINER_UTILS_H
|
#endif // CONTAINER_UTILS_H
|
||||||
|
@ -1040,7 +1040,6 @@ typedef struct {
|
|||||||
int *chanregs; /**< is the pointer to the array of the channel registers */
|
int *chanregs; /**< is the pointer to the array of the channel registers */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
sls_detector_module()
|
sls_detector_module()
|
||||||
: serialnumber(0), nchan(0), nchip(0), ndac(0), reg(0), iodelay(0),
|
: serialnumber(0), nchan(0), nchip(0), ndac(0), reg(0), iodelay(0),
|
||||||
tau(0), eV(0), dacs(nullptr), chanregs(nullptr) {}
|
tau(0), eV(0), dacs(nullptr), chanregs(nullptr) {}
|
||||||
@ -1049,8 +1048,6 @@ typedef struct {
|
|||||||
detParameters parameters{type};
|
detParameters parameters{type};
|
||||||
int nch = parameters.nChanX * parameters.nChanY;
|
int nch = parameters.nChanX * parameters.nChanY;
|
||||||
int nc = parameters.nChipX * parameters.nChipY;
|
int nc = parameters.nChipX * parameters.nChipY;
|
||||||
// int nd = parameters.nDacs;
|
|
||||||
|
|
||||||
ndac = parameters.nDacs;
|
ndac = parameters.nDacs;
|
||||||
nchip = nc;
|
nchip = nc;
|
||||||
nchan = nch * nc;
|
nchan = nch * nc;
|
||||||
|
@ -123,3 +123,15 @@ TEST_CASE("vector of bool", "[support]"){
|
|||||||
CHECK(minusOneIfDifferent(b) == 0);
|
CHECK(minusOneIfDifferent(b) == 0);
|
||||||
CHECK(minusOneIfDifferent(c) == -1);
|
CHECK(minusOneIfDifferent(c) == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("compare a vector of arrays", "[support]"){
|
||||||
|
|
||||||
|
std::vector<std::array<uint64_t, 3>> vec0{{5,6,8},{5,6,8},{5,6,8}};
|
||||||
|
CHECK(minusOneIfDifferent(vec0) == std::array<uint64_t, 3>{5,6,8});
|
||||||
|
|
||||||
|
std::array<uint64_t, 3> arr;
|
||||||
|
arr.fill(-1);
|
||||||
|
std::vector<std::array<uint64_t, 3>> vec1{{5,90,8},{5,6,8},{5,6,8}};
|
||||||
|
CHECK(minusOneIfDifferent(vec1) == arr);
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user