mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-04 09:00:41 +02:00
ctb address check, integration test added for ctb pattern
This commit is contained in:
parent
45884a72da
commit
3d40fb2d2c
@ -2,8 +2,8 @@
|
||||
#include <string>
|
||||
struct SingleDetectorConfig {
|
||||
slsDetectorDefs::detectorType type_enum =
|
||||
slsDetectorDefs::detectorType::EIGER;
|
||||
const std::string hostname = "beb031+beb032+";
|
||||
const std::string type_string = "Eiger";
|
||||
slsDetectorDefs::detectorType::CHIPTESTBOARD;
|
||||
const std::string hostname = "bchip173";
|
||||
const std::string type_string = "Chiptestboard";
|
||||
const std::string my_ip = "129.129.205.171";
|
||||
};
|
||||
|
@ -224,7 +224,7 @@ TEST_CASE("Excersise all possible set timer functions", "[.integration]") {
|
||||
// d.freeSharedMemory();
|
||||
// }
|
||||
|
||||
TEST_CASE("Eiger Dynamic Range with effect on rate correction and clock divider", "[.integration]") {
|
||||
TEST_CASE("Eiger Dynamic Range with effect on rate correction and clock divider", "[.eigerintegration]") {
|
||||
SingleDetectorConfig c;
|
||||
|
||||
int ratecorr = 125;
|
||||
@ -276,3 +276,84 @@ TEST_CASE("Eiger Dynamic Range with effect on rate correction and clock divider"
|
||||
CHECK_THROWS_AS(m.setDynamicRange(4), sls::NonCriticalError);
|
||||
CHECK(m.getRateCorrection()==0);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
|
||||
SingleDetectorConfig c;
|
||||
|
||||
// pick up multi detector from shm id 0
|
||||
multiSlsDetector m(0);
|
||||
|
||||
// ensure ctb detector type, hostname and online
|
||||
REQUIRE(m.getDetectorTypeAsEnum()==c.type_enum);
|
||||
REQUIRE(m.getHostname()==c.hostname);
|
||||
REQUIRE(m.setOnline(true)==slsDetectorDefs::ONLINE_FLAG);
|
||||
|
||||
uint64_t word = 0;
|
||||
int addr = 0;
|
||||
int level = 0;
|
||||
const int MAX_ADDR = 0x7fff;
|
||||
|
||||
word = 0xc000000000f47ff;
|
||||
CHECK(m.setPatternIOControl(word) == word);
|
||||
CHECK(m.setPatternIOControl(-1) == word);
|
||||
CHECK(m.setPatternIOControl(0) == 0);
|
||||
|
||||
CHECK(m.setPatternClockControl(word) == word);
|
||||
CHECK(m.setPatternClockControl(-1) == word);
|
||||
CHECK(m.setPatternClockControl(0) == 0);
|
||||
|
||||
// testing pattern word will execute the pattern as well
|
||||
addr = 0;
|
||||
m.setPatternWord(addr, word);
|
||||
CHECK(m.setPatternWord(addr, -1) == word);
|
||||
addr = MAX_ADDR - 1;
|
||||
m.setPatternWord(addr, word);
|
||||
CHECK(m.setPatternWord(addr, -1) == word);
|
||||
addr = 0x2FF;
|
||||
m.setPatternWord(addr, word);
|
||||
CHECK(m.setPatternWord(addr, -1) == word);
|
||||
addr = MAX_ADDR;
|
||||
CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::NonCriticalError);
|
||||
CHECK_THROWS_WITH(m.setPatternWord(addr, word), Catch::Matchers::Contains( "be between 0 and" ));
|
||||
addr = -1;
|
||||
CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::NonCriticalError);
|
||||
CHECK_THROWS_WITH(m.setPatternWord(addr, word), Catch::Matchers::Contains( "be between 0 and" ));
|
||||
|
||||
addr = 0x2FF;
|
||||
for (level = 0; level < 3; ++level) {
|
||||
CHECK(m.setPatternWaitAddr(level, addr) == addr);
|
||||
CHECK(m.setPatternWaitAddr(level, -1) == addr);
|
||||
}
|
||||
CHECK_THROWS_WITH(m.setPatternWaitAddr(-1, addr), Catch::Matchers::Contains( "be between 0 and" ));
|
||||
CHECK_THROWS_WITH(m.setPatternWaitAddr(0, MAX_ADDR), Catch::Matchers::Contains( "be between 0 and" ));
|
||||
|
||||
for (level = 0; level < 3; ++level) {
|
||||
CHECK(m.setPatternWaitTime(level, word) == word);
|
||||
CHECK(m.setPatternWaitTime(level, -1) == word);
|
||||
}
|
||||
CHECK_THROWS_WITH(m.setPatternWaitTime(-1, word), Catch::Matchers::Contains( "be between 0 and" ));
|
||||
|
||||
{
|
||||
int startaddr = addr;
|
||||
int stopaddr = addr + 5;
|
||||
int nloops = 2;
|
||||
for (level = 0; level < 3; ++level) {
|
||||
m.setPatternLoops(level, startaddr, stopaddr, nloops);
|
||||
auto r = m.getPatternLoops(level);
|
||||
CHECK(r[0] == startaddr);
|
||||
CHECK(r[1] == stopaddr);
|
||||
CHECK(r[2] == nloops);
|
||||
}
|
||||
m.setPatternLoops(-1, startaddr, stopaddr, nloops);
|
||||
auto r = m.getPatternLoops(-1);
|
||||
CHECK(r[0] == startaddr);
|
||||
CHECK(r[1] == stopaddr);
|
||||
CHECK(r[2] == -1);
|
||||
|
||||
CHECK_THROWS_WITH(m.setPatternLoops(-1, startaddr, MAX_ADDR, nloops),
|
||||
Catch::Matchers::Contains("be less than"));
|
||||
CHECK_THROWS_WITH(m.setPatternLoops(-1, MAX_ADDR, stopaddr, nloops),
|
||||
Catch::Matchers::Contains("be less than"));
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1833,33 +1833,33 @@ int getAdcOffsetRegister(int adc) {
|
||||
|
||||
uint64_t writePatternIOControl(uint64_t word) {
|
||||
if (word != -1) {
|
||||
FILE_LOG(logINFO, ("Setting Pattern - I/O Control: 0x%llx\n", (long long int) word));
|
||||
FILE_LOG(logINFO, ("Setting Pattern I/O Control: 0x%llx\n", (long long int) word));
|
||||
set64BitReg(word, PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
|
||||
}
|
||||
uint64_t retval = get64BitReg(PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
|
||||
FILE_LOG(logDEBUG1, (" I/O Control: 0x%llx\n", (long long int) retval));
|
||||
FILE_LOG(logDEBUG1, (" I/O Control retval: 0x%llx\n", (long long int) retval));
|
||||
return retval;
|
||||
}
|
||||
|
||||
uint64_t writePatternClkControl(uint64_t word) {
|
||||
if (word != -1) {
|
||||
FILE_LOG(logINFO, ("Setting Pattern - Clock Control: 0x%llx\n", (long long int) word));
|
||||
FILE_LOG(logINFO, ("Setting Pattern Clock Control: 0x%llx\n", (long long int) word));
|
||||
set64BitReg(word, PATTERN_IO_CLK_CNTRL_LSB_REG, PATTERN_IO_CLK_CNTRL_MSB_REG);
|
||||
}
|
||||
uint64_t retval = get64BitReg(PATTERN_IO_CLK_CNTRL_LSB_REG, PATTERN_IO_CLK_CNTRL_MSB_REG);
|
||||
FILE_LOG(logDEBUG1, (" Clock Control: 0x%llx\n", (long long int) retval));
|
||||
FILE_LOG(logDEBUG1, (" Clock Control retval: 0x%llx\n", (long long int) retval));
|
||||
return retval;
|
||||
}
|
||||
|
||||
uint64_t readPatternWord(int addr) {
|
||||
// error (handled in tcp)
|
||||
if (addr < 0 || addr > MAX_PATTERN_LENGTH) {
|
||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||
FILE_LOG(logERROR, ("Cannot get Pattern - Word. Invalid addr 0x%x. "
|
||||
"Should be <= 0x%x\n", addr, MAX_PATTERN_LENGTH));
|
||||
"Should be between 0 and 0x%x\n", addr, MAX_PATTERN_LENGTH));
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1, (" Reading Pattern - Word (addr:0x%x)\n", addr));
|
||||
FILE_LOG(logINFORED, (" Reading (Executing) Pattern Word (addr:0x%x)\n", addr));
|
||||
uint32_t reg = PATTERN_CNTRL_REG;
|
||||
|
||||
// overwrite with only addr
|
||||
@ -1874,7 +1874,7 @@ uint64_t readPatternWord(int addr) {
|
||||
|
||||
// read value
|
||||
uint64_t retval = get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG);
|
||||
FILE_LOG(logDEBUG1, (" Word(addr:0x%x): 0x%llx\n", addr, (long long int) retval));
|
||||
FILE_LOG(logDEBUG1, (" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int) retval));
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -1885,13 +1885,13 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
return readPatternWord(addr);
|
||||
|
||||
// error (handled in tcp)
|
||||
if (addr < 0 || addr > MAX_PATTERN_LENGTH) {
|
||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern - Word. Invalid addr 0x%x. "
|
||||
"Should be <= 0x%x\n", addr, MAX_PATTERN_LENGTH));
|
||||
"Should be between 0 and 0x%x\n", addr, MAX_PATTERN_LENGTH));
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("Setting Pattern - Word (addr:0x%x, word:0x%llx)\n", addr, (long long int) word));
|
||||
FILE_LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr, (long long int) word));
|
||||
uint32_t reg = PATTERN_CNTRL_REG;
|
||||
|
||||
// write word
|
||||
@ -1914,9 +1914,9 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
int setPatternWaitAddress(int level, int addr) {
|
||||
|
||||
// error (handled in tcp)
|
||||
if (addr > MAX_PATTERN_LENGTH) {
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern - Wait Address. Invalid addr 0x%x. "
|
||||
"Should be <= 0x%x\n", addr, MAX_PATTERN_LENGTH));
|
||||
if (addr >= MAX_PATTERN_LENGTH) {
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern Wait Address. Invalid addr 0x%x. "
|
||||
"Should be between 0 and 0x%x\n", addr, MAX_PATTERN_LENGTH));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1941,20 +1941,20 @@ int setPatternWaitAddress(int level, int addr) {
|
||||
mask = PATTERN_WAIT_2_ADDR_MSK;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern - Wait Address. Invalid level 0x%x. "
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern Wait Address. Invalid level 0x%x. "
|
||||
"Should be between 0 and 2.\n", level));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set
|
||||
if (addr >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting Pattern - Wait Address (level:%d, addr:0x%x)\n", level, addr));
|
||||
FILE_LOG(logINFO, ("Setting Pattern Wait Address (level:%d, addr:0x%x)\n", level, addr));
|
||||
bus_w(reg, ((addr << offset) & mask));
|
||||
}
|
||||
|
||||
// get
|
||||
uint32_t regval = bus_r((reg & mask) >> offset);
|
||||
FILE_LOG(logDEBUG1, (" Wait Address (level:%d, addr:0x%x)\n", level, regval));
|
||||
FILE_LOG(logDEBUG1, (" Wait Address retval (level:%d, addr:0x%x)\n", level, regval));
|
||||
return regval;
|
||||
}
|
||||
|
||||
@ -1976,38 +1976,29 @@ uint64_t setPatternWaitTime(int level, uint64_t t) {
|
||||
regm = PATTERN_WAIT_TIMER_2_MSB_REG;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern - Wait Time. Invalid level %d. "
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern Wait Time. Invalid level %d. "
|
||||
"Should be between 0 and 2.\n", level));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set
|
||||
if (t >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting Pattern - Wait Time (level:%d, t:%lld)\n", level, (long long int)t));
|
||||
FILE_LOG(logINFO, ("Setting Pattern Wait Time (level:%d, t:%lld)\n", level, (long long int)t));
|
||||
set64BitReg(t, regl, regm);
|
||||
}
|
||||
|
||||
// get
|
||||
uint64_t regval = get64BitReg(regl, regm);
|
||||
FILE_LOG(logDEBUG1, (" Wait Time (level:%d, t:%lld)\n", level, (long long int)regval));
|
||||
FILE_LOG(logDEBUG1, (" Wait Time retval (level:%d, t:%lld)\n", level, (long long int)regval));
|
||||
return regval;
|
||||
}
|
||||
|
||||
void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
|
||||
// level 0-2, addr upto patternlength + 1 (checked at tcp)
|
||||
if ((level != -1) &&
|
||||
(*startAddr > MAX_PATTERN_LENGTH || *stopAddr > MAX_PATTERN_LENGTH)) {
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern (Pattern Loop, level:%d, startaddr:0x%x, stopaddr:0x%x). "
|
||||
"Addr must be <= 0x%x\n",
|
||||
level, *startAddr, *stopAddr, MAX_PATTERN_LENGTH));
|
||||
}
|
||||
|
||||
//level -1, addr upto patternlength (checked at tcp)
|
||||
else if ((level == -1) &&
|
||||
(*startAddr > MAX_PATTERN_LENGTH || *stopAddr > MAX_PATTERN_LENGTH)) {
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern (Pattern Loop, complete pattern, startaddr:0x%x, stopaddr:0x%x). "
|
||||
"Addr must be <= 0x%x\n",
|
||||
// (checked at tcp)
|
||||
if (*startAddr >= MAX_PATTERN_LENGTH || *stopAddr >= MAX_PATTERN_LENGTH) {
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern Loop, Address (startaddr:0x%x, stopaddr:0x%x) must be "
|
||||
"less than 0x%x\n",
|
||||
*startAddr, *stopAddr, MAX_PATTERN_LENGTH));
|
||||
}
|
||||
|
||||
@ -2054,7 +2045,7 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
break;
|
||||
default:
|
||||
// already checked at tcp interface
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern - Pattern loop. Invalid level %d. "
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern loop. Invalid level %d. "
|
||||
"Should be between -1 and 2.\n", level));
|
||||
*startAddr = 0;
|
||||
*stopAddr = 0;
|
||||
@ -2065,7 +2056,7 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
if (level >= 0) {
|
||||
// set iteration
|
||||
if (*nLoop >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting Pattern - Pattern Loop (level:%d, nLoop:%d)\n",
|
||||
FILE_LOG(logINFO, ("Setting Pattern Loop (level:%d, nLoop:%d)\n",
|
||||
level, *nLoop));
|
||||
bus_w(nLoopReg, *nLoop);
|
||||
}
|
||||
@ -2073,9 +2064,9 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
}
|
||||
|
||||
// set
|
||||
if (*startAddr != -1 && *stopAddr != -1) {
|
||||
if (*startAddr >= 0 && *stopAddr >= 0) {
|
||||
// writing start and stop addr
|
||||
FILE_LOG(logINFO, ("Setting Pattern - Pattern Loop (level:%d, startaddr:0x%x, stopaddr:0x%x)\n",
|
||||
FILE_LOG(logINFO, ("Setting Pattern Loop (level:%d, startaddr:0x%x, stopaddr:0x%x)\n",
|
||||
level, *startAddr, *stopAddr));
|
||||
bus_w(addr, ((*startAddr << startOffset) & startMask) | ((*stopAddr << stopOffset) & stopMask));
|
||||
FILE_LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
|
||||
@ -2084,11 +2075,11 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
// get
|
||||
else {
|
||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||
FILE_LOG(logDEBUG1, ("Getting Pattern - Pattern Loop Start Address (level:%d, Read startAddr:0x%x)\n",
|
||||
FILE_LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read startAddr:0x%x)\n",
|
||||
level, *startAddr));
|
||||
|
||||
*stopAddr = ((bus_r(addr) & stopMask) >> stopOffset);
|
||||
FILE_LOG(logDEBUG1, ("Getting Pattern - Pattern Loop Stop Address (level:%d, Read stopAddr:0x%x)\n",
|
||||
FILE_LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read stopAddr:0x%x)\n",
|
||||
level, *stopAddr));
|
||||
}
|
||||
}
|
||||
|
@ -2753,9 +2753,9 @@ int set_pattern_word(int file_des) {
|
||||
FILE_LOG(logDEBUG1, ("Setting Pattern Word (addr:0x%x, word:0x%llx\n", addr, (long long int)word));
|
||||
if (Server_VerifyLock() == OK) {
|
||||
// valid address
|
||||
if (addr > MAX_PATTERN_LENGTH) {
|
||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Cannot set Pattern (Word, addr:0x%x). Addr must be <= 0x%x\n",
|
||||
sprintf(mess, "Cannot set Pattern (Word, addr:0x%x). Addr must be between 0 and 0x%x\n",
|
||||
addr, MAX_PATTERN_LENGTH);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
} else {
|
||||
@ -2797,7 +2797,7 @@ int set_pattern_loop(int file_des) {
|
||||
FILE_LOG(logERROR, (mess));
|
||||
}
|
||||
// valid addr for loop level 0-2
|
||||
else if (startAddr > MAX_PATTERN_LENGTH || stopAddr > MAX_PATTERN_LENGTH ) {
|
||||
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) "
|
||||
"should be less than 0x%x\n", startAddr, stopAddr, MAX_PATTERN_LENGTH);
|
||||
@ -2846,9 +2846,9 @@ int set_pattern_wait_addr(int file_des) {
|
||||
FILE_LOG(logERROR, (mess));
|
||||
}
|
||||
// valid addr
|
||||
else if (addr > MAX_PATTERN_LENGTH) {
|
||||
else if (addr >= MAX_PATTERN_LENGTH) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Cannot set Pattern wait address. Address (0x%x) should be less than 0x%x\n", addr, MAX_PATTERN_LENGTH);
|
||||
sprintf(mess, "Cannot set Pattern wait address. Address (0x%x) should be between 0 and 0x%x\n", addr, MAX_PATTERN_LENGTH);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
}
|
||||
else {
|
||||
|
@ -6,5 +6,5 @@
|
||||
#define APILIB 0x190405
|
||||
#define APIRECEIVER 0x190405
|
||||
#define APIGUI 0x190405
|
||||
#define APICTB 0x190418
|
||||
#define APIEIGER 0x190418
|
||||
#define APICTB 0x190418
|
||||
|
Loading…
x
Reference in New Issue
Block a user