ctb moench: added feature set pattern mask and set pattern bit mask, removed CTB prefix for all the patern functions

This commit is contained in:
maliakal_d 2019-03-01 12:28:11 +01:00
parent 35b1ad39f7
commit 8c067437e6
10 changed files with 455 additions and 83 deletions

View File

@ -2041,6 +2041,22 @@ void setDigitalIODelay(uint64_t pinMask, int delay) {
bus_w(addr, bus_r(addr) & (~OUTPUT_DELAY_0_OTPT_TRGGR_MSK));
}
void setPatternMask(uint64_t mask) {
set64BitReg(mask, PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
}
uint64_t getPatternMask() {
return get64BitReg(PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
}
void setPatternBitMask(uint64_t mask) {
set64BitReg(mask, PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
}
uint64_t getPatternBitMask() {
return get64BitReg(PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
}
/* aquisition */

View File

@ -252,9 +252,13 @@ uint64_t readPatternWord(int addr);
uint64_t writePatternWord(int addr, uint64_t word);
int setPatternWaitAddress(int level, int addr);
uint64_t setPatternWaitTime(int level, uint64_t t);
void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop);
void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop);
int setLEDEnable(int enable);
void setDigitalIODelay(uint64_t pinMask, int delay);
void setDigitalIODelay(uint64_t pinMask, int delay);
void setPatternMask(uint64_t mask);
uint64_t getPatternMask();
void setPatternBitMask(uint64_t mask);
uint64_t getPatternBitMask();
#endif
// gotthard specific - image, pedestal

View File

@ -190,7 +190,11 @@ const char* getFunctionName(enum detFuncs func) {
case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK";
case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN";
case F_SET_PATTERN: return "F_SET_PATTERN";
case F_SET_PATTERN_MASK: return "F_SET_PATTERN_MASK";
case F_GET_PATTERN_MASK: return "F_GET_PATTERN_MASK";
case F_SET_PATTERN_BIT_MASK: return "F_SET_PATTERN_BIT_MASK";
case F_GET_PATTERN_BIT_MASK: return "F_GET_PATTERN_BIT_MASK";
case F_WRITE_ADC_REG: return "F_WRITE_ADC_REG";
case F_SET_COUNTER_BIT: return "F_SET_COUNTER_BIT";
case F_PULSE_PIXEL: return "F_PULSE_PIXEL";
@ -256,7 +260,11 @@ void function_table() {
flist[F_RESET_COUNTER_BLOCK] = &reset_counter_block;
flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga;
flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits;
flist[F_SET_CTB_PATTERN] = &set_ctb_pattern;
flist[F_SET_PATTERN] = &set_pattern;
flist[F_SET_PATTERN_MASK] = &set_pattern_mask;
flist[F_GET_PATTERN_MASK] = &get_pattern_mask;
flist[F_SET_PATTERN_BIT_MASK] = &set_pattern_bit_mask;
flist[F_GET_PATTERN_BIT_MASK] = &get_pattern_bit_mask;
flist[F_WRITE_ADC_REG] = &write_adc_register;
flist[F_SET_COUNTER_BIT] = &set_counter_bit;
flist[F_PULSE_PIXEL] = &pulse_pixel;
@ -2498,7 +2506,7 @@ int set_all_trimbits(int file_des) {
int set_ctb_pattern(int file_des) {
int set_pattern(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
@ -2709,6 +2717,88 @@ int set_ctb_pattern(int file_des) {
}
}
int set_pattern_mask(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint64_t arg = -1;
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Set Pattern Mask to %d\n", arg));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
setPatternMask(arg);
uint64_t retval64 = getPatternMask();
FILE_LOG(logDEBUG1, ("Pattern mask: 0x%llx\n", (long long unsigned int) retval64));
validate64(arg, retval64, "Set Pattern Mask", HEX);
}
#endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
}
int get_pattern_mask(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint64_t retval64 = -1;
FILE_LOG(logDEBUG1, ("Get Pattern Mask\n"));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
functionNotImplemented();
#else
// only get
retval64 = getPatternMask();
FILE_LOG(logDEBUG1, ("Get Pattern mask: 0x%llx\n", (long long unsigned int) retval64));
#endif
return Server_SendResult(file_des, INT64, UPDATE, &retval64, sizeof(retval64));
}
int set_pattern_bit_mask(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint64_t arg = -1;
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Set Pattern Bit Mask to %d\n", arg));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
setPatternBitMask(arg);
uint64_t retval64 = getPatternBitMask();
FILE_LOG(logDEBUG1, ("Pattern bit mask: 0x%llx\n", (long long unsigned int) retval64));
validate64(arg, retval64, "Set Pattern Bit Mask", HEX);
}
#endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
}
int get_pattern_bit_mask(int file_des){
ret = OK;
memset(mess, 0, sizeof(mess));
uint64_t retval64 = -1;
FILE_LOG(logDEBUG1, ("Get Pattern Bit Mask\n"));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
functionNotImplemented();
#else
// only get
retval64 = getPatternBitMask();
FILE_LOG(logDEBUG1, ("Get Pattern Bitmask: 0x%llx\n", (long long unsigned int) retval64));
#endif
return Server_SendResult(file_des, INT64, UPDATE, &retval64, sizeof(retval64));
}
int write_adc_register(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));

View File

@ -58,7 +58,11 @@ int reset_counter_block(int);
int calibrate_pedestal(int);
int enable_ten_giga(int);
int set_all_trimbits(int);
int set_ctb_pattern(int);
int set_pattern(int);
int set_pattern_mask(int);
int get_pattern_mask(int);
int set_pattern_bit_mask(int);
int get_pattern_bit_mask(int);
int write_adc_register(int);
int set_counter_bit(int);
int pulse_pixel(int);

View File

@ -3521,10 +3521,10 @@ int multiSlsDetector::setReceiverSilentMode(int i, int detPos) {
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::setCTBPattern(const std::string &fname, int detPos) {
int multiSlsDetector::setPattern(const std::string &fname, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setCTBPattern(fname);
return detectors[detPos]->setPattern(fname);
}
// multi
@ -3539,7 +3539,7 @@ int multiSlsDetector::setCTBPattern(const std::string &fname, int detPos) {
uint64_t word;
while (fread(&word, sizeof(word), 1, fd)) {
serialCall(&slsDetector::setCTBWord, addr, word);
serialCall(&slsDetector::setPatternWord, addr, word);
++addr;
}
@ -3547,54 +3547,112 @@ int multiSlsDetector::setCTBPattern(const std::string &fname, int detPos) {
return addr;
}
uint64_t multiSlsDetector::setCTBWord(int addr, uint64_t word, int detPos) {
uint64_t multiSlsDetector::setPatternWord(int addr, uint64_t word, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setCTBWord(addr, word);
return detectors[detPos]->setPatternWord(addr, word);
}
// multi
auto r = parallelCall(&slsDetector::setCTBWord, addr, word);
auto r = parallelCall(&slsDetector::setPatternWord, addr, word);
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::setCTBPatLoops(int level, int &start, int &stop, int &n,
int multiSlsDetector::setPatternLoops(int level, int &start, int &stop, int &n,
int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setCTBPatLoops(level, start, stop, n);
return detectors[detPos]->setPatternLoops(level, start, stop, n);
}
// multi
std::vector<int> r;
for (auto &d : detectors) {
r.push_back(d->setCTBPatLoops(level, start, stop, n));
r.push_back(d->setPatternLoops(level, start, stop, n));
}
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
int multiSlsDetector::setCTBPatWaitAddr(int level, int addr, int detPos) {
int multiSlsDetector::setPatternWaitAddr(int level, int addr, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setCTBPatWaitAddr(level, addr);
return detectors[detPos]->setPatternWaitAddr(level, addr);
}
// multi
auto r = parallelCall(&slsDetector::setCTBPatWaitAddr, level, addr);
auto r = parallelCall(&slsDetector::setPatternWaitAddr, level, addr);
return sls::minusOneIfDifferent(r);
}
uint64_t multiSlsDetector::setCTBPatWaitTime(int level, uint64_t t, int detPos) {
uint64_t multiSlsDetector::setPatternWaitTime(int level, uint64_t t, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setCTBPatWaitTime(level, t);
return detectors[detPos]->setPatternWaitTime(level, t);
}
// multi
auto r = parallelCall(&slsDetector::setCTBPatWaitTime, level, t);
auto r = parallelCall(&slsDetector::setPatternWaitTime, level, t);
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::setPatternMask(uint64_t mask, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setPatternMask(mask);
}
// multi
auto r = parallelCall(&slsDetector::setPatternMask, mask);
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
uint64_t multiSlsDetector::getPatternMask(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getPatternMask();
}
// multi
auto r = parallelCall(&slsDetector::getPatternMask);
if (sls::allEqual(r)) {
return r.front();
}
// can't have different values
FILE_LOG(logERROR) << "Error: Different Values returned)";
setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES);
return -1;
}
int multiSlsDetector::setPatternBitMask(uint64_t mask, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setPatternBitMask(mask);
}
// multi
auto r = parallelCall(&slsDetector::setPatternBitMask, mask);
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
uint64_t multiSlsDetector::getPatternBitMask(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getPatternBitMask();
}
// multi
auto r = parallelCall(&slsDetector::getPatternBitMask);
if (sls::allEqual(r)) {
return r.front();
}
// can't have different values
FILE_LOG(logERROR) << "Error: Different Values returned)";
setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES);
return -1;
}
int multiSlsDetector::setLEDEnable(int enable, int detPos) {
// single
if (detPos >= 0) {

View File

@ -1693,7 +1693,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK/FAIL
*/
int setCTBPattern(const std::string& fname, int detPos = -1);
int setPattern(const std::string& fname, int detPos = -1);
/**
* Writes a pattern word to the CTB
@ -1703,7 +1703,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
uint64_t setCTBWord(int addr, uint64_t word = -1, int detPos = -1);
uint64_t setPatternWord(int addr, uint64_t word = -1, int detPos = -1);
/**
* Sets the pattern or loop limits in the CTB
@ -1714,7 +1714,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK/FAIL
*/
int setCTBPatLoops(int level, int &start, int &stop, int &n,
int setPatternLoops(int level, int &start, int &stop, int &n,
int detPos = -1);
/**
@ -1724,7 +1724,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
int setCTBPatWaitAddr(int level, int addr = -1, int detPos = -1);
int setPatternWaitAddr(int level, int addr = -1, int detPos = -1);
/**
* Sets the wait time in the CTB
@ -1733,7 +1733,37 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
uint64_t setCTBPatWaitTime(int level, uint64_t t = -1, int detPos = -1);
uint64_t setPatternWaitTime(int level, uint64_t t = -1, int detPos = -1);
/**
* Sets the mask applied to every pattern
* @param mask mask to be applied
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL
*/
int setPatternMask(uint64_t mask, int detPos = -1);
/**
* Gets the mask applied to every pattern
* @param detPos -1 for all detectors in list or specific detector position
* @returns mask set
*/
uint64_t getPatternMask(int detPos = -1);
/**
* Selects the bits that the mask will be applied to for every pattern
* @param mask mask to select bits
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL
*/
int setPatternBitMask(uint64_t mask, int detPos = -1);
/**
* Gets the bits that the mask will be applied to for every pattern
* @param detPos -1 for all detectors in list or specific detector position
* @returns mask of bits selected
*/
uint64_t getPatternBitMask(int detPos = -1);
/**
* Set LED Enable (Moench, CTB only)

View File

@ -4963,13 +4963,13 @@ int slsDetector::restreamStopFromReceiver() {
return ret;
}
int slsDetector::setCTBPattern(const std::string &fname) {
int slsDetector::setPattern(const std::string &fname) {
uint64_t word;
int addr = 0;
FILE *fd = fopen(fname.c_str(), "r");
if (fd != nullptr) {
while (fread(&word, sizeof(word), 1, fd)) {
setCTBWord(addr, word); //TODO! (Erik) do we need to send pattern in 64bit chunks?
setPatternWord(addr, word); //TODO! (Erik) do we need to send pattern in 64bit chunks?
++addr;
}
fclose(fd);
@ -4979,13 +4979,13 @@ int slsDetector::setCTBPattern(const std::string &fname) {
return addr;
}
uint64_t slsDetector::setCTBWord(int addr, uint64_t word) {
int fnum = F_SET_CTB_PATTERN;
uint64_t slsDetector::setPatternWord(int addr, uint64_t word) {
int fnum = F_SET_PATTERN;
int ret = FAIL;
int mode = 0; // sets word
uint64_t args[3] = {(uint64_t)mode, (uint64_t)addr, word};
uint64_t retval = -1;
FILE_LOG(logDEBUG1) << "Setting CTB word, addr: 0x" << std::hex << addr << ", word: 0x" << word << std::dec;
FILE_LOG(logDEBUG1) << "Setting Pattern word, addr: 0x" << std::hex << addr << ", word: 0x" << word << std::dec;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
@ -4993,7 +4993,7 @@ uint64_t slsDetector::setCTBWord(int addr, uint64_t word) {
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
} else {
FILE_LOG(logDEBUG1) << "Set CTB word: " << retval;
FILE_LOG(logDEBUG1) << "Set Pattern word: " << retval;
}
}
if (ret == FORCE_UPDATE) {
@ -5002,13 +5002,13 @@ uint64_t slsDetector::setCTBWord(int addr, uint64_t word) {
return retval;
}
int slsDetector::setCTBPatLoops(int level, int &start, int &stop, int &n) {
int fnum = F_SET_CTB_PATTERN;
int slsDetector::setPatternLoops(int level, int &start, int &stop, int &n) {
int fnum = F_SET_PATTERN;
int ret = FAIL;
int mode = 1; // sets loop
uint64_t args[5] = {(uint64_t)mode, (uint64_t)level, (uint64_t)start, (uint64_t)stop, (uint64_t)n};
int retvals[3] = {0, 0, 0};
FILE_LOG(logDEBUG1) << "Setting CTB Pat Loops, "
FILE_LOG(logDEBUG1) << "Setting Pat Loops, "
"level: "
<< level << ", start: " << start << ", stop: " << stop << ", n: " << n;
@ -5020,7 +5020,7 @@ int slsDetector::setCTBPatLoops(int level, int &start, int &stop, int &n) {
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
} else {
FILE_LOG(logDEBUG1) << "Set CTB Pat Loops: " << retvals[0] << ", " << retvals[1] << ", " << retvals[2];
FILE_LOG(logDEBUG1) << "Set Pat Loops: " << retvals[0] << ", " << retvals[1] << ", " << retvals[2];
start = retvals[0];
stop = retvals[1];
n = retvals[2];
@ -5032,13 +5032,13 @@ int slsDetector::setCTBPatLoops(int level, int &start, int &stop, int &n) {
return ret;
}
int slsDetector::setCTBPatWaitAddr(uint64_t level, uint64_t addr) {
int fnum = F_SET_CTB_PATTERN;
int slsDetector::setPatternWaitAddr(uint64_t level, uint64_t addr) {
int fnum = F_SET_PATTERN;
int ret = FAIL;
uint64_t mode = 2; // sets loop
int retval = -1;
std::array<uint64_t, 3> args{mode, level, addr};
FILE_LOG(logDEBUG1) << "Setting CTB Wait Addr, "
FILE_LOG(logDEBUG1) << "Setting Pat Wait Addr, "
"level: "
<< level << ", addr: 0x" << std::hex << addr << std::dec;
@ -5050,7 +5050,7 @@ int slsDetector::setCTBPatWaitAddr(uint64_t level, uint64_t addr) {
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
} else {
FILE_LOG(logDEBUG1) << "Set CTB Wait Addr: " << retval;
FILE_LOG(logDEBUG1) << "Set Pat Wait Addr: " << retval;
}
}
if (ret == FORCE_UPDATE) {
@ -5059,13 +5059,13 @@ int slsDetector::setCTBPatWaitAddr(uint64_t level, uint64_t addr) {
return retval;
}
uint64_t slsDetector::setCTBPatWaitTime(uint64_t level, uint64_t t) {
int fnum = F_SET_CTB_PATTERN;
uint64_t slsDetector::setPatternWaitTime(uint64_t level, uint64_t t) {
int fnum = F_SET_PATTERN;
int ret = FAIL;
uint64_t mode = 3; // sets loop
uint64_t retval = -1; //TODO! is this what we want?
std::array<uint64_t, 3> args{mode, level, t};
FILE_LOG(logDEBUG1) << "Setting CTB Wait Time, level: " << level << ", t: " << t;
FILE_LOG(logDEBUG1) << "Setting Pat Wait Time, level: " << level << ", t: " << t;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
@ -5075,7 +5075,7 @@ uint64_t slsDetector::setCTBPatWaitTime(uint64_t level, uint64_t t) {
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
} else {
FILE_LOG(logDEBUG1) << "Set CTB Wait Time: " << retval;
FILE_LOG(logDEBUG1) << "Set Pat Wait Time: " << retval;
}
}
if (ret == FORCE_UPDATE) {
@ -5084,6 +5084,98 @@ uint64_t slsDetector::setCTBPatWaitTime(uint64_t level, uint64_t t) {
return retval;
}
int slsDetector::setPatternMask(uint64_t mask) {
int fnum = F_SET_PATTERN_MASK;
int ret = FAIL;
uint64_t arg = mask;
FILE_LOG(logDEBUG1) << "Setting Pattern Mask " << std::hex << mask << std::dec;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
// handle ret
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
} else {
FILE_LOG(logDEBUG1) << "Pattern Mask successful";
}
}
if (ret == FORCE_UPDATE) {
ret = updateDetector();
}
return ret;
}
uint64_t slsDetector::getPatternMask() {
int fnum = F_GET_PATTERN_MASK;
int ret = FAIL;
uint64_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting Pattern Mask " ;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
// handle ret
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
} else {
FILE_LOG(logDEBUG1) << "Pattern Mask:" << retval;
}
}
if (ret == FORCE_UPDATE) {
ret = updateDetector();
}
return retval;
}
int slsDetector::setPatternBitMask(uint64_t mask) {
int fnum = F_SET_PATTERN_BIT_MASK;
int ret = FAIL;
uint64_t arg = mask;
FILE_LOG(logDEBUG1) << "Setting Pattern Bit Mask " << std::hex << mask << std::dec;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
// handle ret
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
} else {
FILE_LOG(logDEBUG1) << "Pattern Bit Mask successful";
}
}
if (ret == FORCE_UPDATE) {
ret = updateDetector();
}
return ret;
}
uint64_t slsDetector::getPatternBitMask() {
int fnum = F_GET_PATTERN_BIT_MASK;
int ret = FAIL;
uint64_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting Pattern Bit Mask " ;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
// handle ret
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
} else {
FILE_LOG(logDEBUG1) << "Pattern Bit Mask:" << retval;
}
}
if (ret == FORCE_UPDATE) {
ret = updateDetector();
}
return retval;
}
int slsDetector::setLEDEnable(int enable) {
int fnum = F_LED;
int ret = FAIL;

View File

@ -1560,7 +1560,7 @@ public:
* @param fname pattern file to open
* @returns OK/FAIL
*/
int setCTBPattern(const std::string& fname);
int setPattern(const std::string& fname);
/**
* Writes a pattern word to the CTB
@ -1568,7 +1568,7 @@ public:
* @param word 64bit word to be written, -1 gets
* @returns actual value
*/
uint64_t setCTBWord(int addr,uint64_t word=-1);
uint64_t setPatternWord(int addr,uint64_t word=-1);
/**
* Sets the pattern or loop limits in the CTB
@ -1578,7 +1578,7 @@ public:
* @param n number of loops (if level >=0)
* @returns OK/FAIL
*/
int setCTBPatLoops(int level,int &start, int &stop, int &n);
int setPatternLoops(int level,int &start, int &stop, int &n);
/**
* Sets the wait address in the CTB
@ -1586,7 +1586,7 @@ public:
* @param addr wait address, -1 gets
* @returns actual value
*/
int setCTBPatWaitAddr(uint64_t level, uint64_t addr=-1);
int setPatternWaitAddr(uint64_t level, uint64_t addr=-1);
/**
* Sets the wait time in the CTB
@ -1594,7 +1594,33 @@ public:
* @param t wait time, -1 gets
* @returns actual value
*/
uint64_t setCTBPatWaitTime(uint64_t level, uint64_t t=-1);
uint64_t setPatternWaitTime(uint64_t level, uint64_t t=-1);
/**
* Sets the mask applied to every pattern
* @param mask mask to be applied
* @returns OK or FAIL
*/
int setPatternMask(uint64_t mask);
/**
* Gets the mask applied to every pattern
* @returns mask set
*/
uint64_t getPatternMask();
/**
* Selects the bits that the mask will be applied to for every pattern
* @param mask mask to select bits
* @returns OK or FAIL
*/
int setPatternBitMask(uint64_t mask);
/**
* Gets the bits that the mask will be applied to for every pattern
* @returns mask of bits selected
*/
uint64_t getPatternBitMask();
/**
* Set LED Enable (Moench, CTB only)

View File

@ -1968,6 +1968,20 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
++i;
/*! \page prototype
- <b>patmask [m]</b> 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
- <b>patsetbit [m]</b> 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;
/*! \page prototype
- <b>dut_clk [i]</b> sets/gets the signal to be used as a clock for the digital data coming from the device under test. Advanced!
*/
@ -4980,6 +4994,8 @@ std::string slsDetectorCommand::helpPattern(int action) {
os << "patwaittime0 nclk \t sets wait 0 waiting time in clock number " << std::endl;
os << "patwaittime1 nclk \t sets wait 1 waiting time in clock number " << std::endl;
os << "patwaittime2 nclk \t sets wait 2 waiting time in clock number " << std::endl;
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;
os << "adcinvert mask\t sets the adcinversion mask (hex)" << std::endl;
os << "adcdisable mask\t sets the adcdisable mask (hex)" << std::endl;
}
@ -5001,6 +5017,8 @@ std::string slsDetectorCommand::helpPattern(int action) {
os << "patwaittime0 \t returns the wait 0 waiting time in clock number " << std::endl;
os << "patwaittime1 \t returns the wait 1 waiting time in clock number " << std::endl;
os << "patwaittime2 \t returns the wait 2 waiting time in clock number " << std::endl;
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;
os << "adcinvert \t returns the adcinversion mask " << std::endl;
os << "adcdisable \t returns the adcdisable mask " << std::endl;
@ -5029,7 +5047,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
if (action == PUT_ACTION) {
fname = std::string(args[1]);
os << myDet->setCTBPattern(fname, detPos);
os << myDet->setPattern(fname, detPos);
} else if (action == GET_ACTION)
os << "Cannot get";
} else if (cmd == "patword") {
@ -5050,7 +5068,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan value (hexadecimal fomat) ") + std::string(args[2]);
os << std::hex << myDet->setCTBWord(addr, word, detPos) << std::dec;
os << std::hex << myDet->setPatternWord(addr, word, detPos) << std::dec;
} else if (action == GET_ACTION)
os << "Cannot get";
@ -5064,10 +5082,10 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan value (hexadecimal fomat) ") + std::string(args[1]);
myDet->setCTBWord(-1, word, detPos);
myDet->setPatternWord(-1, word, detPos);
}
os << std::hex << myDet->setCTBWord(-1, -1, detPos) << std::dec;
os << std::hex << myDet->setPatternWord(-1, -1, detPos) << std::dec;
} else if (cmd == "patclkctrl") {
//get word from stdin
@ -5078,10 +5096,10 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan value (hexadecimal fomat) ") + std::string(args[1]);
myDet->setCTBWord(-2, word, detPos);
myDet->setPatternWord(-2, word, detPos);
}
os << std::hex << myDet->setCTBWord(-2, -1, detPos) << std::dec;
os << std::hex << myDet->setPatternWord(-2, -1, detPos) << std::dec;
} else if (cmd == "patlimits") {
//get start, stop from stdin
@ -5099,13 +5117,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan stop address (hexadecimal fomat) ") + std::string(args[2]);
myDet->setCTBPatLoops(-1, start, stop, n, detPos);
myDet->setPatternLoops(-1, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setCTBPatLoops(-1, start, stop, n, detPos);
myDet->setPatternLoops(-1, start, stop, n, detPos);
os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
} else if (cmd == "patloop0") {
//get start, stop from stdin
@ -5125,13 +5143,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan stop address (hexadecimal fomat) ") + std::string(args[2]);
myDet->setCTBPatLoops(0, start, stop, n, detPos);
myDet->setPatternLoops(0, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setCTBPatLoops(0, start, stop, n, detPos);
myDet->setPatternLoops(0, start, stop, n, detPos);
os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
} else if (cmd == "patloop1") {
@ -5151,13 +5169,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan stop address (hexadecimal fomat) ") + std::string(args[2]);
myDet->setCTBPatLoops(1, start, stop, n, detPos);
myDet->setPatternLoops(1, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setCTBPatLoops(1, start, stop, n, detPos);
myDet->setPatternLoops(1, start, stop, n, detPos);
os << std::hex << start << " " << stop; // << " "<< std::dec << n ;
} else if (cmd == "patloop2") {
@ -5177,13 +5195,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan stop address (hexadecimal fomat) ") + std::string(args[2]);
myDet->setCTBPatLoops(2, start, stop, n, detPos);
myDet->setPatternLoops(2, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setCTBPatLoops(2, start, stop, n, detPos);
myDet->setPatternLoops(2, start, stop, n, detPos);
os << std::hex << start << " " << stop << std::dec; // << " "<< std::dec << n ;
} else if (cmd == "patnloop0") {
@ -5197,13 +5215,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan number of loops ") + std::string(args[1]);
myDet->setCTBPatLoops(0, start, stop, n, detPos);
myDet->setPatternLoops(0, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setCTBPatLoops(0, start, stop, n, detPos);
myDet->setPatternLoops(0, start, stop, n, detPos);
os << n;
} else if (cmd == "patnloop1") {
@ -5217,13 +5235,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan number of loops ") + std::string(args[1]);
myDet->setCTBPatLoops(1, start, stop, n, detPos);
myDet->setPatternLoops(1, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setCTBPatLoops(1, start, stop, n, detPos);
myDet->setPatternLoops(1, start, stop, n, detPos);
os << n;
} else if (cmd == "patnloop2") {
@ -5238,13 +5256,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan number of loops ") + std::string(args[1]);
myDet->setCTBPatLoops(2, start, stop, n, detPos);
myDet->setPatternLoops(2, start, stop, n, detPos);
}
start = -1;
stop = -1;
n = -1;
myDet->setCTBPatLoops(2, start, stop, n, detPos);
myDet->setPatternLoops(2, start, stop, n, detPos);
os << n;
} else if (cmd == "patwait0") {
@ -5256,10 +5274,10 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan wait address (hex format)") + std::string(args[1]);
myDet->setCTBPatWaitAddr(0, addr, detPos);
myDet->setPatternWaitAddr(0, addr, detPos);
}
os << std::hex << myDet->setCTBPatWaitAddr(0, -1, detPos) << std::dec ;
os << std::hex << myDet->setPatternWaitAddr(0, -1, detPos) << std::dec ;
} else if (cmd == "patwait1") {
@ -5270,10 +5288,10 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan wait address (hex format)") + std::string(args[1]);
myDet->setCTBPatWaitAddr(1, addr, detPos);
myDet->setPatternWaitAddr(1, addr, detPos);
}
os << std::hex << myDet->setCTBPatWaitAddr(1, -1, detPos) << std::dec ;
os << std::hex << myDet->setPatternWaitAddr(1, -1, detPos) << std::dec ;
} else if (cmd == "patwait2") {
@ -5284,10 +5302,10 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan wait address (hex format)") + std::string(args[1]);
myDet->setCTBPatWaitAddr(2, addr, detPos);
myDet->setPatternWaitAddr(2, addr, detPos);
}
os << std::hex << myDet->setCTBPatWaitAddr(2, -1, detPos) << std::dec ;
os << std::hex << myDet->setPatternWaitAddr(2, -1, detPos) << std::dec ;
} else if (cmd == "patwaittime0") {
@ -5298,10 +5316,10 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan wait time") + std::string(args[1]);
myDet->setCTBPatWaitTime(0, t, detPos);
myDet->setPatternWaitTime(0, t, detPos);
}
os << myDet->setCTBPatWaitTime(0, -1, detPos);
os << myDet->setPatternWaitTime(0, -1, detPos);
} else if (cmd == "patwaittime1") {
@ -5312,10 +5330,10 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan wait time ") + std::string(args[1]);
myDet->setCTBPatWaitTime(1, t, detPos);
myDet->setPatternWaitTime(1, t, detPos);
}
os << myDet->setCTBPatWaitTime(1, -1, detPos);
os << myDet->setPatternWaitTime(1, -1, detPos);
} else if (cmd == "patwaittime2") {
if (action == PUT_ACTION) {
@ -5325,10 +5343,36 @@ std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, i
else
return std::string("Could not scan wait time ") + std::string(args[1]);
myDet->setCTBPatWaitTime(2, t, detPos);
myDet->setPatternWaitTime(2, t, detPos);
}
os << myDet->setCTBPatWaitTime(2, -1, detPos);
os << myDet->setPatternWaitTime(2, -1, detPos);
} else 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::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::hex << myDet->getPatternBitMask(detPos) << std::dec;
} else if (cmd == "adcinvert") {
if (action == PUT_ACTION) {

View File

@ -47,7 +47,11 @@ enum detFuncs{
F_RESET_COUNTER_BLOCK, /**< resets the counter block memory for gotthard */
F_ENABLE_TEN_GIGA, /**< enable 10Gbe */
F_SET_ALL_TRIMBITS, /** < set all trimbits to this value */
F_SET_CTB_PATTERN, /** < loads a pattern in the CTB */
F_SET_PATTERN, /** < loads a pattern */
F_SET_PATTERN_MASK, /** < loads a pattern mask */
F_GET_PATTERN_MASK, /** < retrieves pattern mask */
F_SET_PATTERN_BIT_MASK, /** < loads bitmask for the pattern */
F_GET_PATTERN_BIT_MASK, /** < retrieves bitmask for the pattern */
F_WRITE_ADC_REG, /** < writes an ADC register */
F_SET_COUNTER_BIT, /** < set/reset counter bit in detector for eiger */
F_PULSE_PIXEL,/** < pulse pixel n number of times in eiger at (x,y) */
@ -165,7 +169,11 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK";
case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN";
case F_SET_PATTERN: return "F_SET_PATTERN";
case F_SET_PATTERN_MASK: return "F_SET_PATTERN_MASK";
case F_GET_PATTERN_MASK: return "F_GET_PATTERN_MASK";
case F_SET_PATTERN_BIT_MASK: return "F_SET_PATTERN_BIT_MASK";
case F_GET_PATTERN_BIT_MASK: return "F_GET_PATTERN_BIT_MASK";
case F_WRITE_ADC_REG: return "F_WRITE_ADC_REG";
case F_SET_COUNTER_BIT: return "F_SET_COUNTER_BIT";
case F_PULSE_PIXEL: return "F_PULSE_PIXEL";