mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-04 20:00:04 +02:00
commit
cd677e4d97
@ -974,14 +974,6 @@ class Detector(CppDetectorApi):
|
|||||||
print("Set only")
|
print("Set only")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@property
|
|
||||||
def patclkctrl(self):
|
|
||||||
return element_if_equal(self.getPatternClockControl())
|
|
||||||
|
|
||||||
@patclkctrl.setter
|
|
||||||
def patclkctrl(self, mask):
|
|
||||||
self.setPatternClockControl(mask)
|
|
||||||
|
|
||||||
# patioctrl
|
# patioctrl
|
||||||
@property
|
@property
|
||||||
def patioctrl(self):
|
def patioctrl(self):
|
||||||
|
@ -1187,14 +1187,6 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(uint64_t, sls::Positions)) &
|
(void (Detector::*)(uint64_t, sls::Positions)) &
|
||||||
Detector::setPatternIOControl,
|
Detector::setPatternIOControl,
|
||||||
py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("getPatternClockControl",
|
|
||||||
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
|
|
||||||
Detector::getPatternClockControl,
|
|
||||||
py::arg() = Positions{})
|
|
||||||
.def("setPatternClockControl",
|
|
||||||
(void (Detector::*)(uint64_t, sls::Positions)) &
|
|
||||||
Detector::setPatternClockControl,
|
|
||||||
py::arg(), py::arg() = Positions{})
|
|
||||||
.def("getPatternWord",
|
.def("getPatternWord",
|
||||||
(Result<uint64_t>(Detector::*)(int, sls::Positions)) &
|
(Result<uint64_t>(Detector::*)(int, sls::Positions)) &
|
||||||
Detector::getPatternWord,
|
Detector::getPatternWord,
|
||||||
|
Binary file not shown.
@ -45,6 +45,7 @@ char initErrorMessage[MAX_STR_LENGTH];
|
|||||||
pthread_t pthread_virtual_tid;
|
pthread_t pthread_virtual_tid;
|
||||||
int virtual_status = 0;
|
int virtual_status = 0;
|
||||||
int virtual_stop = 0;
|
int virtual_stop = 0;
|
||||||
|
uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 1g readout
|
// 1g readout
|
||||||
@ -484,6 +485,7 @@ void setupDetector() {
|
|||||||
if (isControlServer) {
|
if (isControlServer) {
|
||||||
ComVirtual_setStatus(virtual_status);
|
ComVirtual_setStatus(virtual_status);
|
||||||
}
|
}
|
||||||
|
memset(virtual_pattern, 0, sizeof(virtual_pattern));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ALTERA_PLL_ResetPLLAndReconfiguration();
|
ALTERA_PLL_ResetPLLAndReconfiguration();
|
||||||
@ -1900,19 +1902,6 @@ uint64_t writePatternIOControl(uint64_t word) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t writePatternClkControl(uint64_t word) {
|
|
||||||
if ((int64_t)word != -1) {
|
|
||||||
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);
|
|
||||||
LOG(logDEBUG1, (" Clock Control retval: 0x%llx\n", (long long int)retval));
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t readPatternWord(int addr) {
|
uint64_t readPatternWord(int addr) {
|
||||||
// error (handled in tcp)
|
// error (handled in tcp)
|
||||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||||
@ -1939,7 +1928,9 @@ uint64_t readPatternWord(int addr) {
|
|||||||
uint64_t retval = get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG);
|
uint64_t retval = get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG);
|
||||||
LOG(logDEBUG1,
|
LOG(logDEBUG1,
|
||||||
(" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int)retval));
|
(" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int)retval));
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
retval = virtual_pattern[addr];
|
||||||
|
#endif
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1956,7 +1947,7 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
LOG(logDEBUG1, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
||||||
(long long int)word));
|
(long long int)word));
|
||||||
uint32_t reg = PATTERN_CNTRL_REG;
|
uint32_t reg = PATTERN_CNTRL_REG;
|
||||||
|
|
||||||
@ -1973,6 +1964,9 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
|||||||
|
|
||||||
// unset write strobe
|
// unset write strobe
|
||||||
bus_w(reg, bus_r(reg) & (~PATTERN_CNTRL_WR_MSK));
|
bus_w(reg, bus_r(reg) & (~PATTERN_CNTRL_WR_MSK));
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
virtual_pattern[addr] = word;
|
||||||
|
#endif
|
||||||
|
|
||||||
return word;
|
return word;
|
||||||
// return readPatternWord(addr); // will start executing the pattern
|
// return readPatternWord(addr); // will start executing the pattern
|
||||||
@ -2150,8 +2144,6 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
|||||||
LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
|
LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get
|
|
||||||
else {
|
|
||||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
||||||
"startAddr:0x%x)\n",
|
"startAddr:0x%x)\n",
|
||||||
@ -2162,7 +2154,6 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
|||||||
"stopAddr:0x%x)\n",
|
"stopAddr:0x%x)\n",
|
||||||
level, *stopAddr));
|
level, *stopAddr));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int setLEDEnable(int enable) {
|
int setLEDEnable(int enable) {
|
||||||
uint32_t addr = CONFIG_REG;
|
uint32_t addr = CONFIG_REG;
|
||||||
|
@ -133,7 +133,6 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
|
|||||||
#define VIO_MIN_MV (1200) // for fpga to function
|
#define VIO_MIN_MV (1200) // for fpga to function
|
||||||
|
|
||||||
/* Defines in the Firmware */
|
/* Defines in the Firmware */
|
||||||
#define MAX_PATTERN_LENGTH (0x2000)
|
|
||||||
#define DIGITAL_IO_DELAY_MAXIMUM_PS \
|
#define DIGITAL_IO_DELAY_MAXIMUM_PS \
|
||||||
((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
|
((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
|
||||||
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
|
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -273,7 +273,6 @@ patword 0x010f 0x0008599f0008503a
|
|||||||
patword 0x0110 0x0008599f0008503a
|
patword 0x0110 0x0008599f0008503a
|
||||||
patword 0x0111 0x0008599f0008503a
|
patword 0x0111 0x0008599f0008503a
|
||||||
patioctrl 0x8f0effff6dbffdbf
|
patioctrl 0x8f0effff6dbffdbf
|
||||||
patclkctrl 0x0000000000000000
|
|
||||||
patlimits 0x0000 0x0110
|
patlimits 0x0000 0x0110
|
||||||
patloop0 0x00be 0x00ef
|
patloop0 0x00be 0x00ef
|
||||||
patnloop0 199
|
patnloop0 199
|
||||||
|
Binary file not shown.
@ -43,6 +43,7 @@ char initErrorMessage[MAX_STR_LENGTH];
|
|||||||
pthread_t pthread_virtual_tid;
|
pthread_t pthread_virtual_tid;
|
||||||
int virtual_status = 0;
|
int virtual_status = 0;
|
||||||
int virtual_stop = 0;
|
int virtual_stop = 0;
|
||||||
|
uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 1g readout
|
// 1g readout
|
||||||
@ -490,6 +491,7 @@ void setupDetector() {
|
|||||||
if (isControlServer) {
|
if (isControlServer) {
|
||||||
ComVirtual_setStatus(virtual_status);
|
ComVirtual_setStatus(virtual_status);
|
||||||
}
|
}
|
||||||
|
memset(virtual_pattern, 0, sizeof(virtual_pattern));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ALTERA_PLL_ResetPLLAndReconfiguration();
|
ALTERA_PLL_ResetPLLAndReconfiguration();
|
||||||
@ -1574,19 +1576,6 @@ uint64_t writePatternIOControl(uint64_t word) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t writePatternClkControl(uint64_t word) {
|
|
||||||
if ((int64_t)word != -1) {
|
|
||||||
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);
|
|
||||||
LOG(logDEBUG1, (" Clock Control retval: 0x%llx\n", (long long int)retval));
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t readPatternWord(int addr) {
|
uint64_t readPatternWord(int addr) {
|
||||||
// error (handled in tcp)
|
// error (handled in tcp)
|
||||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||||
@ -1613,7 +1602,9 @@ uint64_t readPatternWord(int addr) {
|
|||||||
uint64_t retval = get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG);
|
uint64_t retval = get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG);
|
||||||
LOG(logDEBUG1,
|
LOG(logDEBUG1,
|
||||||
(" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int)retval));
|
(" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int)retval));
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
retval = virtual_pattern[addr];
|
||||||
|
#endif
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1630,7 +1621,7 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
LOG(logDEBUG1, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
||||||
(long long int)word));
|
(long long int)word));
|
||||||
uint32_t reg = PATTERN_CNTRL_REG;
|
uint32_t reg = PATTERN_CNTRL_REG;
|
||||||
|
|
||||||
@ -1647,7 +1638,9 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
|||||||
|
|
||||||
// unset write strobe
|
// unset write strobe
|
||||||
bus_w(reg, bus_r(reg) & (~PATTERN_CNTRL_WR_MSK));
|
bus_w(reg, bus_r(reg) & (~PATTERN_CNTRL_WR_MSK));
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
virtual_pattern[addr] = word;
|
||||||
|
#endif
|
||||||
return word;
|
return word;
|
||||||
// return readPatternWord(addr); // will start executing the pattern
|
// return readPatternWord(addr); // will start executing the pattern
|
||||||
}
|
}
|
||||||
@ -1824,8 +1817,6 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
|||||||
LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
|
LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get
|
|
||||||
else {
|
|
||||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
||||||
"startAddr:0x%x)\n",
|
"startAddr:0x%x)\n",
|
||||||
@ -1836,7 +1827,6 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
|||||||
"stopAddr:0x%x)\n",
|
"stopAddr:0x%x)\n",
|
||||||
level, *stopAddr));
|
level, *stopAddr));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void setPatternMask(uint64_t mask) {
|
void setPatternMask(uint64_t mask) {
|
||||||
LOG(logINFO, ("Setting pattern mask to 0x%llx\n", mask));
|
LOG(logINFO, ("Setting pattern mask to 0x%llx\n", mask));
|
||||||
|
@ -117,7 +117,6 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
|
|||||||
#define DAC_MAX_MV (2500)
|
#define DAC_MAX_MV (2500)
|
||||||
|
|
||||||
/* Defines in the Firmware */
|
/* Defines in the Firmware */
|
||||||
#define MAX_PATTERN_LENGTH (0x2000)
|
|
||||||
#define DIGITAL_IO_DELAY_MAXIMUM_PS \
|
#define DIGITAL_IO_DELAY_MAXIMUM_PS \
|
||||||
((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
|
((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
|
||||||
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
|
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
|
||||||
|
Binary file not shown.
@ -1491,7 +1491,7 @@ uint64_t readPatternWord(int addr) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(trimmingPrint, (" Reading Pattern Word (addr:0x%x)\n", addr));
|
LOG(logDEBUG1, (" Reading Pattern Word (addr:0x%x)\n", addr));
|
||||||
uint32_t reg_lsb =
|
uint32_t reg_lsb =
|
||||||
PATTERN_STEP0_LSB_REG +
|
PATTERN_STEP0_LSB_REG +
|
||||||
addr * REG_OFFSET * 2; // the first word in RAM as base plus the offset
|
addr * REG_OFFSET * 2; // the first word in RAM as base plus the offset
|
||||||
@ -1519,7 +1519,7 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
|||||||
addr, MAX_PATTERN_LENGTH));
|
addr, MAX_PATTERN_LENGTH));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
LOG(trimmingPrint, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
LOG(logDEBUG1, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr,
|
||||||
(long long int)word));
|
(long long int)word));
|
||||||
|
|
||||||
// write word
|
// write word
|
||||||
@ -1710,8 +1710,6 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
|||||||
((*stopAddr << stopOffset) & stopMask));
|
((*stopAddr << stopOffset) & stopMask));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get
|
|
||||||
else {
|
|
||||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read "
|
||||||
"startAddr:0x%x)\n",
|
"startAddr:0x%x)\n",
|
||||||
@ -1722,7 +1720,6 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
|||||||
"stopAddr:0x%x)\n",
|
"stopAddr:0x%x)\n",
|
||||||
level, *stopAddr));
|
level, *stopAddr));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void setPatternMask(uint64_t mask) {
|
void setPatternMask(uint64_t mask) {
|
||||||
set64BitReg(mask, PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
|
set64BitReg(mask, PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
#define FIXED_PLL_FREQUENCY (020000000) // 20MHz
|
#define FIXED_PLL_FREQUENCY (020000000) // 20MHz
|
||||||
#define READOUT_PLL_VCO_FREQ_HZ (1250000000) // 1.25GHz
|
#define READOUT_PLL_VCO_FREQ_HZ (1250000000) // 1.25GHz
|
||||||
#define SYSTEM_PLL_VCO_FREQ_HZ (1000000000) // 1GHz
|
#define SYSTEM_PLL_VCO_FREQ_HZ (1000000000) // 1GHz
|
||||||
#define MAX_PATTERN_LENGTH (0x2000) // maximum number of words (64bit)
|
|
||||||
|
|
||||||
/** Other Definitions */
|
/** Other Definitions */
|
||||||
#define BIT16_MASK (0xFFFF)
|
#define BIT16_MASK (0xFFFF)
|
||||||
|
@ -9,8 +9,6 @@ int default_writePatternWord(char *line, uint32_t addr, uint64_t word);
|
|||||||
|
|
||||||
int default_writePatternIOControl(char *line, uint64_t arg);
|
int default_writePatternIOControl(char *line, uint64_t arg);
|
||||||
|
|
||||||
int default_writePatternClkControl(char *line, uint64_t arg);
|
|
||||||
|
|
||||||
int default_setPatternLoopLimits(char *line, uint32_t startAddr,
|
int default_setPatternLoopLimits(char *line, uint32_t startAddr,
|
||||||
uint32_t stopAddr);
|
uint32_t stopAddr);
|
||||||
|
|
||||||
|
@ -403,7 +403,6 @@ void setPipeline(enum CLKINDEX ind, int val);
|
|||||||
int getPipeline(enum CLKINDEX ind);
|
int getPipeline(enum CLKINDEX ind);
|
||||||
// patterns
|
// patterns
|
||||||
uint64_t writePatternIOControl(uint64_t word);
|
uint64_t writePatternIOControl(uint64_t word);
|
||||||
uint64_t writePatternClkControl(uint64_t word);
|
|
||||||
uint64_t readPatternWord(int addr);
|
uint64_t readPatternWord(int addr);
|
||||||
uint64_t writePatternWord(int addr, uint64_t word);
|
uint64_t writePatternWord(int addr, uint64_t word);
|
||||||
int setPatternWaitAddress(int level, int addr);
|
int setPatternWaitAddress(int level, int addr);
|
||||||
|
@ -90,7 +90,6 @@ int calibrate_pedestal(int);
|
|||||||
int enable_ten_giga(int);
|
int enable_ten_giga(int);
|
||||||
int set_all_trimbits(int);
|
int set_all_trimbits(int);
|
||||||
int set_pattern_io_control(int);
|
int set_pattern_io_control(int);
|
||||||
int set_pattern_clock_control(int);
|
|
||||||
int set_pattern_word(int);
|
int set_pattern_word(int);
|
||||||
int set_pattern_loop_addresses(int);
|
int set_pattern_loop_addresses(int);
|
||||||
int set_pattern_loop_cycles(int);
|
int set_pattern_loop_cycles(int);
|
||||||
@ -222,3 +221,4 @@ int get_exptime_all_gates(int);
|
|||||||
int get_gate_delay_all_gates(int);
|
int get_gate_delay_all_gates(int);
|
||||||
int get_veto(int);
|
int get_veto(int);
|
||||||
int set_veto(int);
|
int set_veto(int);
|
||||||
|
int set_pattern(int);
|
@ -10,7 +10,6 @@ extern char initErrorMessage[MAX_STR_LENGTH];
|
|||||||
extern int initError;
|
extern int initError;
|
||||||
|
|
||||||
extern uint64_t writePatternIOControl(uint64_t word);
|
extern uint64_t writePatternIOControl(uint64_t word);
|
||||||
extern uint64_t writePatternClkControl(uint64_t word);
|
|
||||||
extern uint64_t writePatternWord(int addr, uint64_t word);
|
extern uint64_t writePatternWord(int addr, uint64_t word);
|
||||||
extern int setPatternWaitAddress(int level, int addr);
|
extern int setPatternWaitAddress(int level, int addr);
|
||||||
extern uint64_t setPatternWaitTime(int level, uint64_t t);
|
extern uint64_t setPatternWaitTime(int level, uint64_t t);
|
||||||
@ -125,28 +124,6 @@ int loadDefaultPattern(char *fname) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// patclkctrl
|
|
||||||
if (!strncmp(line, "patclkctrl", strlen("patclkctrl"))) {
|
|
||||||
uint64_t arg = 0;
|
|
||||||
|
|
||||||
// cannot scan values
|
|
||||||
#ifdef VIRTUAL
|
|
||||||
if (sscanf(line, "%s 0x%lx", command, &arg) != 2) {
|
|
||||||
#else
|
|
||||||
if (sscanf(line, "%s 0x%llx", command, &arg) != 2) {
|
|
||||||
#endif
|
|
||||||
sprintf(initErrorMessage,
|
|
||||||
"Could not scan patclkctrl arguments from default "
|
|
||||||
"pattern file. Line:[%s].\n",
|
|
||||||
line);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (default_writePatternClkControl(line, arg) == FAIL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// patlimits
|
// patlimits
|
||||||
if (!strncmp(line, "patlimits", strlen("patlimits"))) {
|
if (!strncmp(line, "patlimits", strlen("patlimits"))) {
|
||||||
uint32_t startAddr = 0;
|
uint32_t startAddr = 0;
|
||||||
@ -342,25 +319,6 @@ int default_writePatternIOControl(char *line, uint64_t arg) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int default_writePatternClkControl(char *line, uint64_t arg) {
|
|
||||||
uint64_t retval = writePatternClkControl(arg);
|
|
||||||
if (retval != arg) {
|
|
||||||
#ifdef VIRTUAL
|
|
||||||
sprintf(initErrorMessage,
|
|
||||||
"Could not set patclkctrl from default pattern "
|
|
||||||
"file. Set 0x%lx, read 0x%lx. Line:[%s]\n",
|
|
||||||
arg, retval, line);
|
|
||||||
#else
|
|
||||||
sprintf(initErrorMessage,
|
|
||||||
"Could not set patclkctrl from default pattern "
|
|
||||||
"file. Set 0x%llx, read 0x%llx. Line:[%s]\n",
|
|
||||||
arg, retval, line);
|
|
||||||
#endif
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int default_setPatternLoopLimits(char *line, uint32_t startAddr,
|
int default_setPatternLoopLimits(char *line, uint32_t startAddr,
|
||||||
uint32_t stopAddr) {
|
uint32_t stopAddr) {
|
||||||
// validations
|
// validations
|
||||||
|
@ -204,7 +204,6 @@ void function_table() {
|
|||||||
flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga;
|
flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga;
|
||||||
flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits;
|
flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits;
|
||||||
flist[F_SET_PATTERN_IO_CONTROL] = &set_pattern_io_control;
|
flist[F_SET_PATTERN_IO_CONTROL] = &set_pattern_io_control;
|
||||||
flist[F_SET_PATTERN_CLOCK_CONTROL] = &set_pattern_clock_control;
|
|
||||||
flist[F_SET_PATTERN_WORD] = &set_pattern_word;
|
flist[F_SET_PATTERN_WORD] = &set_pattern_word;
|
||||||
flist[F_SET_PATTERN_LOOP_ADDRESSES] = &set_pattern_loop_addresses;
|
flist[F_SET_PATTERN_LOOP_ADDRESSES] = &set_pattern_loop_addresses;
|
||||||
flist[F_SET_PATTERN_LOOP_CYCLES] = &set_pattern_loop_cycles;
|
flist[F_SET_PATTERN_LOOP_CYCLES] = &set_pattern_loop_cycles;
|
||||||
@ -332,6 +331,7 @@ void function_table() {
|
|||||||
flist[F_GET_GATE_DELAY_ALL_GATES] = &get_gate_delay_all_gates;
|
flist[F_GET_GATE_DELAY_ALL_GATES] = &get_gate_delay_all_gates;
|
||||||
flist[F_GET_VETO] = &get_veto;
|
flist[F_GET_VETO] = &get_veto;
|
||||||
flist[F_SET_VETO] = &set_veto;
|
flist[F_SET_VETO] = &set_veto;
|
||||||
|
flist[F_SET_PATTERN] = &set_pattern;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||||
@ -2881,29 +2881,6 @@ int set_pattern_io_control(int file_des) {
|
|||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_pattern_clock_control(int file_des) {
|
|
||||||
ret = OK;
|
|
||||||
memset(mess, 0, sizeof(mess));
|
|
||||||
uint64_t arg = -1;
|
|
||||||
uint64_t retval = -1;
|
|
||||||
|
|
||||||
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
|
|
||||||
return printSocketReadError();
|
|
||||||
#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
|
|
||||||
functionNotImplemented();
|
|
||||||
#else
|
|
||||||
LOG(logDEBUG1,
|
|
||||||
("Setting Pattern Clock Control to 0x%llx\n", (long long int)arg));
|
|
||||||
if (((int64_t)arg == GET_FLAG) || (Server_VerifyLock() == OK)) {
|
|
||||||
retval = writePatternClkControl(arg);
|
|
||||||
LOG(logDEBUG1,
|
|
||||||
("Pattern Clock Control retval: 0x%llx\n", (long long int)retval));
|
|
||||||
validate64(arg, retval, "Pattern Clock Control", HEX);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
|
||||||
}
|
|
||||||
|
|
||||||
int set_pattern_word(int file_des) {
|
int set_pattern_word(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
@ -2917,8 +2894,10 @@ int set_pattern_word(int file_des) {
|
|||||||
#else
|
#else
|
||||||
int addr = (int)args[0];
|
int addr = (int)args[0];
|
||||||
uint64_t word = args[1];
|
uint64_t word = args[1];
|
||||||
LOG(logDEBUG1, ("Setting Pattern Word (addr:0x%x, word:0x%llx\n", addr,
|
if (word != (uint64_t)-1) {
|
||||||
|
LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx\n", addr,
|
||||||
(long long int)word));
|
(long long int)word));
|
||||||
|
}
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
// valid address
|
// valid address
|
||||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||||
@ -7357,3 +7336,121 @@ int set_veto(int file_des) {
|
|||||||
#endif
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int set_pattern(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
uint64_t *patwords = malloc(sizeof(uint64_t) * MAX_PATTERN_LENGTH);
|
||||||
|
memset(patwords, 0, sizeof(uint64_t) * MAX_PATTERN_LENGTH);
|
||||||
|
uint64_t patioctrl = 0;
|
||||||
|
int patlimits[2] = {0, 0};
|
||||||
|
int patloop[6] = {0, 0, 0, 0, 0, 0};
|
||||||
|
int patnloop[3] = {0, 0, 0};
|
||||||
|
int patwait[3] = {0, 0, 0};
|
||||||
|
uint64_t patwaittime[3] = {0, 0, 0};
|
||||||
|
if (receiveData(file_des, patwords, sizeof(uint64_t) * MAX_PATTERN_LENGTH,
|
||||||
|
INT64) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
if (receiveData(file_des, &patioctrl, sizeof(patioctrl), INT64) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
if (receiveData(file_des, patlimits, sizeof(patlimits), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
if (receiveData(file_des, patloop, sizeof(patloop), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
if (receiveData(file_des, patnloop, sizeof(patnloop), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
if (receiveData(file_des, patwait, sizeof(patwait), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
if (receiveData(file_des, patwaittime, sizeof(patwaittime), INT64) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
|
||||||
|
#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
LOG(logINFO, ("Setting Pattern from file\n"));
|
||||||
|
LOG(logINFO,
|
||||||
|
("Setting Pattern Word (printing every 10 words that are not 0\n"));
|
||||||
|
for (int i = 0; i < MAX_PATTERN_LENGTH; ++i) {
|
||||||
|
if ((i % 10 == 0) && patwords[i] != 0) {
|
||||||
|
LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n",
|
||||||
|
i, (long long int)patwords[i]));
|
||||||
|
}
|
||||||
|
writePatternWord(i, patwords[i]);
|
||||||
|
}
|
||||||
|
int numLoops = -1, retval0 = -1, retval1 = -1;
|
||||||
|
uint64_t retval64 = -1;
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
if (ret == OK) {
|
||||||
|
retval64 = writePatternIOControl(patioctrl);
|
||||||
|
validate64(patioctrl, retval64, "Pattern IO Control", HEX);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (ret == OK) {
|
||||||
|
numLoops = -1;
|
||||||
|
retval0 = patlimits[0];
|
||||||
|
retval1 = patlimits[1];
|
||||||
|
setPatternLoop(-1, &retval0, &retval1, &numLoops);
|
||||||
|
validate(patlimits[0], retval0, "Pattern Limits start address",
|
||||||
|
HEX);
|
||||||
|
validate(patlimits[1], retval1, "Pattern Limits start address",
|
||||||
|
HEX);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
retval0 = patloop[0];
|
||||||
|
retval1 = patloop[1];
|
||||||
|
numLoops = patnloop[0];
|
||||||
|
setPatternLoop(0, &patloop[0], &patloop[1], &numLoops);
|
||||||
|
validate(patloop[0], retval0, "Pattern Loop 0 start address", HEX);
|
||||||
|
validate(patloop[1], retval1, "Pattern Loop 0 stop address", HEX);
|
||||||
|
validate(patnloop[0], numLoops, "Pattern Loop 0 num loops", HEX);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
retval0 = patloop[2];
|
||||||
|
retval1 = patloop[3];
|
||||||
|
numLoops = patnloop[1];
|
||||||
|
setPatternLoop(1, &patloop[2], &patloop[3], &numLoops);
|
||||||
|
validate(patloop[2], retval0, "Pattern Loop 1 start address", HEX);
|
||||||
|
validate(patloop[3], retval1, "Pattern Loop 1 stop address", HEX);
|
||||||
|
validate(patnloop[1], numLoops, "Pattern Loop 1 num loops", HEX);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
retval0 = patloop[4];
|
||||||
|
retval1 = patloop[5];
|
||||||
|
numLoops = patnloop[2];
|
||||||
|
setPatternLoop(2, &patloop[4], &patloop[5], &numLoops);
|
||||||
|
validate(patloop[4], retval0, "Pattern Loop 2 start address", HEX);
|
||||||
|
validate(patloop[5], retval1, "Pattern Loop 2 stop address", HEX);
|
||||||
|
validate(patnloop[2], numLoops, "Pattern Loop 2 num loops", HEX);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
retval0 = setPatternWaitAddress(0, patwait[0]);
|
||||||
|
validate(patwait[0], retval0, "Pattern Loop 0 wait address", HEX);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
retval0 = setPatternWaitAddress(1, patwait[1]);
|
||||||
|
validate(patwait[1], retval0, "Pattern Loop 1 wait address", HEX);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
retval0 = setPatternWaitAddress(2, patwait[2]);
|
||||||
|
validate(patwait[2], retval0, "Pattern Loop 2 wait address", HEX);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
uint64_t retval64 = setPatternWaitTime(0, patwaittime[0]);
|
||||||
|
validate64(patwaittime[0], retval64, "Pattern Loop 0 wait time",
|
||||||
|
HEX);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
retval64 = setPatternWaitTime(1, patwaittime[1]);
|
||||||
|
validate64(patwaittime[1], retval64, "Pattern Loop 1 wait time",
|
||||||
|
HEX);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
retval64 = setPatternWaitTime(2, patwaittime[2]);
|
||||||
|
validate64(patwaittime[1], retval64, "Pattern Loop 2 wait time",
|
||||||
|
HEX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
@ -1195,12 +1195,6 @@ class Detector {
|
|||||||
/** [CTB][Moench] */
|
/** [CTB][Moench] */
|
||||||
void setPatternIOControl(uint64_t word, Positions pos = {});
|
void setPatternIOControl(uint64_t word, Positions pos = {});
|
||||||
|
|
||||||
/** [CTB][Moench] */
|
|
||||||
Result<uint64_t> getPatternClockControl(Positions pos = {}) const;
|
|
||||||
|
|
||||||
/** [CTB][Moench] */
|
|
||||||
void setPatternClockControl(uint64_t word, Positions pos = {});
|
|
||||||
|
|
||||||
/** [CTB][Moench][Mythen3] same as executing for ctb and moench */
|
/** [CTB][Moench][Mythen3] same as executing for ctb and moench */
|
||||||
Result<uint64_t> getPatternWord(int addr, Positions pos = {});
|
Result<uint64_t> getPatternWord(int addr, Positions pos = {});
|
||||||
|
|
||||||
|
@ -1940,9 +1940,8 @@ std::string CmdProxy::Pattern(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[fname]\n\t[Mythen3][Moench][Ctb] Loads binary pattern "
|
os << "[fname]\n\t[Mythen3][Moench][Ctb] Loads ASCII pattern file "
|
||||||
"file with only pattern "
|
"directly to server (instead of executing line by line)"
|
||||||
"words"
|
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
throw sls::RuntimeError("Cannot get");
|
throw sls::RuntimeError("Cannot get");
|
||||||
@ -1970,15 +1969,19 @@ std::string CmdProxy::PatternWord(int action) {
|
|||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
auto t = det->getPatternWord(StringTo<uint64_t>(args[0]), {det_id});
|
int addr = StringTo<int>(args[0]);
|
||||||
os << OutStringHex(t) << '\n';
|
auto t = det->getPatternWord(addr, {det_id});
|
||||||
|
os << '[' << ToStringHex(addr, 4) << ", " << OutStringHex(t, 16)
|
||||||
|
<< "]\n";
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
}
|
}
|
||||||
det->setPatternWord(StringTo<int>(args[0]), StringTo<uint64_t>(args[1]),
|
int addr = StringTo<int>(args[0]);
|
||||||
{det_id});
|
uint64_t word = StringTo<uint64_t>(args[1]);
|
||||||
os << sls::ToString(args) << '\n';
|
det->setPatternWord(addr, word, {det_id});
|
||||||
|
os << '[' << ToStringHex(addr, 4) << ", " << ToStringHex(word, 16)
|
||||||
|
<< "]\n";
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
}
|
}
|
||||||
@ -2029,14 +2032,16 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
|
|||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
}
|
}
|
||||||
auto t = det->getPatternLoopAddresses(level, {det_id});
|
auto t = det->getPatternLoopAddresses(level, {det_id});
|
||||||
os << OutStringHex(t) << '\n';
|
os << OutStringHex(t, 4) << '\n';
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
}
|
}
|
||||||
det->setPatternLoopAddresses(level, StringTo<int>(args[0]),
|
int start = StringTo<int>(args[0]);
|
||||||
StringTo<int>(args[1]), {det_id});
|
int stop = StringTo<int>(args[1]);
|
||||||
os << sls::ToString(args) << '\n';
|
det->setPatternLoopAddresses(level, start, stop, {det_id});
|
||||||
|
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
|
||||||
|
<< "]\n";
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
}
|
}
|
||||||
@ -2126,13 +2131,14 @@ std::string CmdProxy::PatternWaitAddress(int action) {
|
|||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
}
|
}
|
||||||
auto t = det->getPatternWaitAddr(level, {det_id});
|
auto t = det->getPatternWaitAddr(level, {det_id});
|
||||||
os << OutStringHex(t) << '\n';
|
os << OutStringHex(t, 4) << '\n';
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
det->setPatternWaitAddr(level, StringTo<int>(args[0]), {det_id});
|
int addr = StringTo<int>(args[0]);
|
||||||
os << args.front() << '\n';
|
det->setPatternWaitAddr(level, addr, {det_id});
|
||||||
|
os << ToStringHex(addr, 4) << '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,33 @@
|
|||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** int or enum */
|
/** int or enum hex with 16 bit width (64 bit)*/
|
||||||
|
#define INTEGER_COMMAND_HEX_WIDTH16(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
||||||
|
std::string CMDNAME(const int action) { \
|
||||||
|
std::ostringstream os; \
|
||||||
|
os << cmd << ' '; \
|
||||||
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
|
os << HLPSTR << '\n'; \
|
||||||
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
|
if (args.size() != 0) { \
|
||||||
|
WrongNumberOfParameters(0); \
|
||||||
|
} \
|
||||||
|
auto t = det->GETFCN({det_id}); \
|
||||||
|
os << OutStringHex(t, 16) << '\n'; \
|
||||||
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
|
if (args.size() != 1) { \
|
||||||
|
WrongNumberOfParameters(1); \
|
||||||
|
} \
|
||||||
|
auto val = CONV(args[0]); \
|
||||||
|
det->SETFCN(val, {det_id}); \
|
||||||
|
os << ToStringHex(val, 16) << '\n'; \
|
||||||
|
} else { \
|
||||||
|
throw sls::RuntimeError("Unknown action"); \
|
||||||
|
} \
|
||||||
|
return os.str(); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/** int or enum hex */
|
||||||
#define INTEGER_COMMAND_HEX(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
#define INTEGER_COMMAND_HEX(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
||||||
std::string CMDNAME(const int action) { \
|
std::string CMDNAME(const int action) { \
|
||||||
std::ostringstream os; \
|
std::ostringstream os; \
|
||||||
@ -131,7 +157,7 @@
|
|||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** int or enum hex val */
|
/** int or enum */
|
||||||
#define INTEGER_COMMAND(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
#define INTEGER_COMMAND(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
||||||
std::string CMDNAME(const int action) { \
|
std::string CMDNAME(const int action) { \
|
||||||
std::ostringstream os; \
|
std::ostringstream os; \
|
||||||
@ -434,6 +460,12 @@ class CmdProxy {
|
|||||||
return ToStringHex(value);
|
return ToStringHex(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename V> std::string OutStringHex(const V &value, int width) {
|
||||||
|
if (value.equal())
|
||||||
|
return ToStringHex(value.front(), width);
|
||||||
|
return ToStringHex(value, width);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename V> std::string OutString(const V &value) {
|
template <typename V> std::string OutString(const V &value) {
|
||||||
if (value.equal())
|
if (value.equal())
|
||||||
return ToString(value.front());
|
return ToString(value.front());
|
||||||
@ -860,7 +892,6 @@ class CmdProxy {
|
|||||||
{"pattern", &CmdProxy::Pattern},
|
{"pattern", &CmdProxy::Pattern},
|
||||||
{"savepattern", &CmdProxy::savepattern},
|
{"savepattern", &CmdProxy::savepattern},
|
||||||
{"patioctrl", &CmdProxy::patioctrl},
|
{"patioctrl", &CmdProxy::patioctrl},
|
||||||
{"patclkctrl", &CmdProxy::patclkctrl},
|
|
||||||
{"patword", &CmdProxy::PatternWord},
|
{"patword", &CmdProxy::PatternWord},
|
||||||
{"patlimits", &CmdProxy::PatternLoopAddresses},
|
{"patlimits", &CmdProxy::PatternLoopAddresses},
|
||||||
{"patloop0", &CmdProxy::PatternLoopAddresses},
|
{"patloop0", &CmdProxy::PatternLoopAddresses},
|
||||||
@ -2026,23 +2057,18 @@ class CmdProxy {
|
|||||||
"[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). Also "
|
"[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). Also "
|
||||||
"executes pattern.");
|
"executes pattern.");
|
||||||
|
|
||||||
INTEGER_COMMAND_HEX(patioctrl, getPatternIOControl, setPatternIOControl,
|
INTEGER_COMMAND_HEX_WIDTH16(patioctrl, getPatternIOControl,
|
||||||
StringTo<uint64_t>,
|
setPatternIOControl, StringTo<uint64_t>,
|
||||||
"[64 bit mask]\n\t[Ctb][Moench] 64 bit mask "
|
"[64 bit mask]\n\t[Ctb][Moench] 64 bit mask "
|
||||||
"defining input (0) and output (1) signals.");
|
"defining input (0) and output (1) signals.");
|
||||||
|
|
||||||
INTEGER_COMMAND_HEX(patclkctrl, getPatternClockControl,
|
INTEGER_COMMAND_HEX_WIDTH16(
|
||||||
setPatternClockControl, StringTo<uint64_t>,
|
|
||||||
"[64 bit mask]\n\t[Ctb][Moench] 64 bit mask "
|
|
||||||
"defining output clock enable.");
|
|
||||||
|
|
||||||
INTEGER_COMMAND_HEX(
|
|
||||||
patmask, getPatternMask, setPatternMask, StringTo<uint64_t>,
|
patmask, getPatternMask, setPatternMask, StringTo<uint64_t>,
|
||||||
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask applied to every "
|
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask applied to every "
|
||||||
"pattern. Only these bits for each pattern will be masked against.");
|
"pattern. Only these bits for each pattern will be masked against.");
|
||||||
|
|
||||||
INTEGER_COMMAND_HEX(patsetbit, getPatternBitMask, setPatternBitMask,
|
INTEGER_COMMAND_HEX_WIDTH16(
|
||||||
StringTo<uint64_t>,
|
patsetbit, getPatternBitMask, setPatternBitMask, StringTo<uint64_t>,
|
||||||
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit values "
|
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit values "
|
||||||
"applied to the selected patmask for every pattern.");
|
"applied to the selected patmask for every pattern.");
|
||||||
|
|
||||||
|
@ -1590,11 +1590,10 @@ void Detector::savePattern(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
// rest of pattern file
|
// rest of pattern file
|
||||||
std::vector<std::string> commands{
|
std::vector<std::string> commands{
|
||||||
"patioctrl", "patclkctrl", "patlimits", "patloop0",
|
"patioctrl", "patlimits", "patloop0", "patnloop0",
|
||||||
"patnloop0", "patloop1", "patnloop1", "patloop2",
|
"patloop1", "patnloop1", "patloop2", "patnloop2",
|
||||||
"patnloop2", "patwait0", "patwaittime0", "patwait1",
|
"patwait0", "patwaittime0", "patwait1", "patwaittime1",
|
||||||
"patwaittime1", "patwait2", "patwaittime2", "patmask",
|
"patwait2", "patwaittime2", "patmask", "patsetbit",
|
||||||
"patsetbit",
|
|
||||||
};
|
};
|
||||||
auto det_type = getDetectorType().squash();
|
auto det_type = getDetectorType().squash();
|
||||||
if (det_type == defs::MYTHEN3) {
|
if (det_type == defs::MYTHEN3) {
|
||||||
@ -1616,14 +1615,6 @@ void Detector::setPatternIOControl(uint64_t word, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setPatternIOControl, pos, word);
|
pimpl->Parallel(&Module::setPatternIOControl, pos, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<uint64_t> Detector::getPatternClockControl(Positions pos) const {
|
|
||||||
return pimpl->Parallel(&Module::getPatternClockControl, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Detector::setPatternClockControl(uint64_t word, Positions pos) {
|
|
||||||
pimpl->Parallel(&Module::setPatternClockControl, pos, word);
|
|
||||||
}
|
|
||||||
|
|
||||||
Result<uint64_t> Detector::getPatternWord(int addr, Positions pos) {
|
Result<uint64_t> Detector::getPatternWord(int addr, Positions pos) {
|
||||||
return pimpl->Parallel(&Module::getPatternWord, pos, addr);
|
return pimpl->Parallel(&Module::getPatternWord, pos, addr);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "ClientSocket.h"
|
#include "ClientSocket.h"
|
||||||
#include "SharedMemory.h"
|
#include "SharedMemory.h"
|
||||||
#include "ToString.h"
|
#include "ToString.h"
|
||||||
|
#include "container_utils.h"
|
||||||
#include "file_utils.h"
|
#include "file_utils.h"
|
||||||
#include "network_utils.h"
|
#include "network_utils.h"
|
||||||
#include "sls_detector_exceptions.h"
|
#include "sls_detector_exceptions.h"
|
||||||
@ -16,6 +17,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <iterator>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
@ -1746,20 +1748,106 @@ void Module::setLEDEnable(bool enable) {
|
|||||||
// Pattern
|
// Pattern
|
||||||
|
|
||||||
void Module::setPattern(const std::string &fname) {
|
void Module::setPattern(const std::string &fname) {
|
||||||
uint64_t word;
|
auto pat = sls::make_unique<patternParameters>();
|
||||||
uint64_t addr = 0;
|
std::ifstream input_file(fname);
|
||||||
FILE *fd = fopen(fname.c_str(), "r");
|
if (!input_file.is_open()) {
|
||||||
if (fd != nullptr) {
|
throw RuntimeError("Could not open pattern file " + fname +
|
||||||
while (fread(&word, sizeof(word), 1, fd) != 0U) {
|
" for reading");
|
||||||
setPatternWord(addr, word); // TODO! (Erik) do we need to send
|
|
||||||
// pattern in 64bit chunks?
|
|
||||||
++addr;
|
|
||||||
}
|
}
|
||||||
fclose(fd);
|
for (std::string line; std::getline(input_file, line);) {
|
||||||
|
if (line.find('#') != std::string::npos) {
|
||||||
|
line.erase(line.find('#'));
|
||||||
|
}
|
||||||
|
LOG(logDEBUG1) << "line after removing comments:\n\t" << line;
|
||||||
|
if (line.length() > 1) {
|
||||||
|
|
||||||
|
// convert command and string to a vector
|
||||||
|
std::istringstream iss(line);
|
||||||
|
auto it = std::istream_iterator<std::string>(iss);
|
||||||
|
std::vector<std::string> args = std::vector<std::string>(
|
||||||
|
it, std::istream_iterator<std::string>());
|
||||||
|
|
||||||
|
std::string cmd = args[0];
|
||||||
|
int nargs = args.size() - 1;
|
||||||
|
|
||||||
|
if (cmd == "patword") {
|
||||||
|
if (nargs != 2) {
|
||||||
|
throw RuntimeError("Invalid arguments for " +
|
||||||
|
ToString(args));
|
||||||
|
}
|
||||||
|
uint32_t addr = StringTo<uint32_t>(args[1]);
|
||||||
|
if (addr >= MAX_PATTERN_LENGTH) {
|
||||||
|
throw RuntimeError("Invalid address for " + ToString(args));
|
||||||
|
}
|
||||||
|
pat->word[addr] = StringTo<uint64_t>(args[2]);
|
||||||
|
} else if (cmd == "patioctrl") {
|
||||||
|
if (nargs != 1) {
|
||||||
|
throw RuntimeError("Invalid arguments for " +
|
||||||
|
ToString(args));
|
||||||
|
}
|
||||||
|
pat->patioctrl = StringTo<uint64_t>(args[1]);
|
||||||
|
} else if (cmd == "patlimits") {
|
||||||
|
if (nargs != 2) {
|
||||||
|
throw RuntimeError("Invalid arguments for " +
|
||||||
|
ToString(args));
|
||||||
|
}
|
||||||
|
pat->patlimits[0] = StringTo<uint32_t>(args[1]);
|
||||||
|
pat->patlimits[1] = StringTo<uint32_t>(args[2]);
|
||||||
|
if (pat->patlimits[0] >= MAX_PATTERN_LENGTH ||
|
||||||
|
pat->patlimits[1] >= MAX_PATTERN_LENGTH) {
|
||||||
|
throw RuntimeError("Invalid address for " + ToString(args));
|
||||||
|
}
|
||||||
|
} else if (cmd == "patloop0" || cmd == "patloop1" ||
|
||||||
|
cmd == "patloop2") {
|
||||||
|
if (nargs != 2) {
|
||||||
|
throw RuntimeError("Invalid arguments for " +
|
||||||
|
ToString(args));
|
||||||
|
}
|
||||||
|
int level = cmd[cmd.find_first_of("012")] - '0';
|
||||||
|
int patloop1 = StringTo<uint32_t>(args[1]);
|
||||||
|
int patloop2 = StringTo<uint32_t>(args[2]);
|
||||||
|
pat->patloop[level * 2 + 0] = patloop1;
|
||||||
|
pat->patloop[level * 2 + 1] = patloop2;
|
||||||
|
if (patloop1 >= MAX_PATTERN_LENGTH ||
|
||||||
|
patloop2 >= MAX_PATTERN_LENGTH) {
|
||||||
|
throw RuntimeError("Invalid address for " + ToString(args));
|
||||||
|
}
|
||||||
|
} else if (cmd == "patnloop0" || cmd == "patnloop1" ||
|
||||||
|
cmd == "patnloop2") {
|
||||||
|
if (nargs != 1) {
|
||||||
|
throw RuntimeError("Invalid arguments for " +
|
||||||
|
ToString(args));
|
||||||
|
}
|
||||||
|
int level = cmd[cmd.find_first_of("012")] - '0';
|
||||||
|
pat->patnloop[level] = StringTo<uint32_t>(args[1]);
|
||||||
|
} else if (cmd == "patwait0" || cmd == "patwait1" ||
|
||||||
|
cmd == "patwait2") {
|
||||||
|
if (nargs != 1) {
|
||||||
|
throw RuntimeError("Invalid arguments for " +
|
||||||
|
ToString(args));
|
||||||
|
}
|
||||||
|
int level = cmd[cmd.find_first_of("012")] - '0';
|
||||||
|
pat->patwait[level] = StringTo<uint32_t>(args[1]);
|
||||||
|
if (pat->patwait[level] >= MAX_PATTERN_LENGTH) {
|
||||||
|
throw RuntimeError("Invalid address for " + ToString(args));
|
||||||
|
}
|
||||||
|
} else if (cmd == "patwaittime0" || cmd == "patwaittime1" ||
|
||||||
|
cmd == "patwaittime2") {
|
||||||
|
if (nargs != 1) {
|
||||||
|
throw RuntimeError("Invalid arguments for " +
|
||||||
|
ToString(args));
|
||||||
|
}
|
||||||
|
int level = cmd[cmd.find_first_of("012")] - '0';
|
||||||
|
pat->patwaittime[level] = StringTo<uint64_t>(args[1]);
|
||||||
} else {
|
} else {
|
||||||
throw RuntimeError("Could not open file to set pattern");
|
throw RuntimeError("Unknown command in pattern file " + cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
LOG(logDEBUG1) << "Sending pattern from file to detector:" << *pat;
|
||||||
|
sendToDetector(F_SET_PATTERN, pat.get(), sizeof(patternParameters), nullptr,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t Module::getPatternIOControl() {
|
uint64_t Module::getPatternIOControl() {
|
||||||
int64_t arg = GET_FLAG;
|
int64_t arg = GET_FLAG;
|
||||||
@ -1770,15 +1858,6 @@ void Module::setPatternIOControl(uint64_t word) {
|
|||||||
sendToDetector<uint64_t>(F_SET_PATTERN_IO_CONTROL, word);
|
sendToDetector<uint64_t>(F_SET_PATTERN_IO_CONTROL, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Module::getPatternClockControl() {
|
|
||||||
int64_t arg = GET_FLAG;
|
|
||||||
return sendToDetector<uint64_t>(F_SET_PATTERN_CLOCK_CONTROL, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::setPatternClockControl(uint64_t word) {
|
|
||||||
sendToDetector<uint64_t>(F_SET_PATTERN_CLOCK_CONTROL, word);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t Module::getPatternWord(int addr) {
|
uint64_t Module::getPatternWord(int addr) {
|
||||||
uint64_t args[]{static_cast<uint64_t>(addr),
|
uint64_t args[]{static_cast<uint64_t>(addr),
|
||||||
static_cast<uint64_t>(GET_FLAG)};
|
static_cast<uint64_t>(GET_FLAG)};
|
||||||
|
@ -437,8 +437,6 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setPattern(const std::string &fname);
|
void setPattern(const std::string &fname);
|
||||||
uint64_t getPatternIOControl();
|
uint64_t getPatternIOControl();
|
||||||
void setPatternIOControl(uint64_t word);
|
void setPatternIOControl(uint64_t word);
|
||||||
uint64_t getPatternClockControl();
|
|
||||||
void setPatternClockControl(uint64_t word);
|
|
||||||
uint64_t getPatternWord(int addr);
|
uint64_t getPatternWord(int addr);
|
||||||
void setPatternWord(int addr, uint64_t word);
|
void setPatternWord(int addr, uint64_t word);
|
||||||
std::array<int, 2> getPatternLoopAddresses(int level);
|
std::array<int, 2> getPatternLoopAddresses(int level);
|
||||||
|
@ -60,13 +60,13 @@ TEST_CASE("patioctrl", "[.cmd][.new]") {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patioctrl", {"0x0"}, -1, PUT, oss);
|
proxy.Call("patioctrl", {"0xaadf0"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "patioctrl 0x0\n");
|
REQUIRE(oss.str() == "patioctrl 0x00000000000aadf0\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patioctrl", {}, -1, GET, oss);
|
proxy.Call("patioctrl", {}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "patioctrl 0x0\n");
|
REQUIRE(oss.str() == "patioctrl 0x00000000000aadf0\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setPatternIOControl(prev_val[i], {i});
|
det.setPatternIOControl(prev_val[i], {i});
|
||||||
@ -76,36 +76,6 @@ TEST_CASE("patioctrl", "[.cmd][.new]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("patclkctrl", "[.cmd][.new]") {
|
|
||||||
Detector det;
|
|
||||||
CmdProxy proxy(&det);
|
|
||||||
auto det_type = det.getDetectorType().squash();
|
|
||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
|
|
||||||
auto prev_val = det.getPatternClockControl();
|
|
||||||
{
|
|
||||||
std::ostringstream oss;
|
|
||||||
proxy.Call("patclkctrl", {"0xc15004808d0a21a4"}, -1, PUT, oss);
|
|
||||||
REQUIRE(oss.str() == "patclkctrl 0xc15004808d0a21a4\n");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
std::ostringstream oss;
|
|
||||||
proxy.Call("patclkctrl", {"0x0"}, -1, PUT, oss);
|
|
||||||
REQUIRE(oss.str() == "patclkctrl 0x0\n");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
std::ostringstream oss;
|
|
||||||
proxy.Call("patclkctrl", {}, -1, GET, oss);
|
|
||||||
REQUIRE(oss.str() == "patclkctrl 0x0\n");
|
|
||||||
}
|
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
|
||||||
det.setPatternClockControl(prev_val[i], {i});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
REQUIRE_THROWS(proxy.Call("patclkctrl", {}, -1, GET));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("patword", "[.cmd][.new]") {
|
TEST_CASE("patword", "[.cmd][.new]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -114,7 +84,7 @@ TEST_CASE("patword", "[.cmd][.new]") {
|
|||||||
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
|
if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH ||
|
||||||
det_type == defs::MYTHEN3) {
|
det_type == defs::MYTHEN3) {
|
||||||
int addr = 0x23;
|
int addr = 0x23;
|
||||||
std::string saddr = sls::ToStringHex(addr);
|
std::string saddr = sls::ToStringHex(addr, 4);
|
||||||
auto prev_val = det.getPatternWord(addr);
|
auto prev_val = det.getPatternWord(addr);
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -124,13 +94,15 @@ TEST_CASE("patword", "[.cmd][.new]") {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patword", {saddr, "0x0"}, -1, PUT, oss);
|
proxy.Call("patword", {saddr, "0xaadf0"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "patword [" + saddr + ", 0x0]\n");
|
REQUIRE(oss.str() ==
|
||||||
|
"patword [" + saddr + ", 0x00000000000aadf0]\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patword", {saddr}, -1, GET, oss);
|
proxy.Call("patword", {saddr}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "patword 0x0\n");
|
REQUIRE(oss.str() ==
|
||||||
|
"patword [" + saddr + ", 0x00000000000aadf0]\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setPatternWord(addr, prev_val[i], {i});
|
det.setPatternWord(addr, prev_val[i], {i});
|
||||||
@ -151,12 +123,12 @@ TEST_CASE("patlimits", "[.cmd][.new]") {
|
|||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patlimits", {"0x20", "0x5c"}, -1, PUT, oss);
|
proxy.Call("patlimits", {"0x20", "0x5c"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "patlimits [0x20, 0x5c]\n");
|
REQUIRE(oss.str() == "patlimits [0x0020, 0x005c]\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patlimits", {}, -1, GET, oss);
|
proxy.Call("patlimits", {}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "patlimits [0x20, 0x5c]\n");
|
REQUIRE(oss.str() == "patlimits [0x0020, 0x005c]\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setPatternLoopAddresses(-1, prev_val[i][0], prev_val[i][1],
|
det.setPatternLoopAddresses(-1, prev_val[i][0], prev_val[i][1],
|
||||||
@ -178,12 +150,12 @@ TEST_CASE("patloop0", "[.cmd][.new]") {
|
|||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patloop0", {"0x20", "0x5c"}, -1, PUT, oss);
|
proxy.Call("patloop0", {"0x20", "0x5c"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "patloop0 [0x20, 0x5c]\n");
|
REQUIRE(oss.str() == "patloop0 [0x0020, 0x005c]\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patloop0", {}, -1, GET, oss);
|
proxy.Call("patloop0", {}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "patloop0 [0x20, 0x5c]\n");
|
REQUIRE(oss.str() == "patloop0 [0x0020, 0x005c]\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setPatternLoopAddresses(0, prev_val[i][0], prev_val[i][1], {i});
|
det.setPatternLoopAddresses(0, prev_val[i][0], prev_val[i][1], {i});
|
||||||
@ -204,12 +176,12 @@ TEST_CASE("patloop1", "[.cmd][.new]") {
|
|||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patloop1", {"0x20", "0x5c"}, -1, PUT, oss);
|
proxy.Call("patloop1", {"0x20", "0x5c"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "patloop1 [0x20, 0x5c]\n");
|
REQUIRE(oss.str() == "patloop1 [0x0020, 0x005c]\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patloop1", {}, -1, GET, oss);
|
proxy.Call("patloop1", {}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "patloop1 [0x20, 0x5c]\n");
|
REQUIRE(oss.str() == "patloop1 [0x0020, 0x005c]\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setPatternLoopAddresses(1, prev_val[i][0], prev_val[i][1], {i});
|
det.setPatternLoopAddresses(1, prev_val[i][0], prev_val[i][1], {i});
|
||||||
@ -230,12 +202,12 @@ TEST_CASE("patloop2", "[.cmd][.new]") {
|
|||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patloop2", {"0x20", "0x5c"}, -1, PUT, oss);
|
proxy.Call("patloop2", {"0x20", "0x5c"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "patloop2 [0x20, 0x5c]\n");
|
REQUIRE(oss.str() == "patloop2 [0x0020, 0x005c]\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patloop2", {}, -1, GET, oss);
|
proxy.Call("patloop2", {}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "patloop2 [0x20, 0x5c]\n");
|
REQUIRE(oss.str() == "patloop2 [0x0020, 0x005c]\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setPatternLoopAddresses(2, prev_val[i][0], prev_val[i][1], {i});
|
det.setPatternLoopAddresses(2, prev_val[i][0], prev_val[i][1], {i});
|
||||||
@ -334,12 +306,12 @@ TEST_CASE("patwait0", "[.cmd][.new]") {
|
|||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patwait0", {"0x5c"}, -1, PUT, oss);
|
proxy.Call("patwait0", {"0x5c"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "patwait0 0x5c\n");
|
REQUIRE(oss.str() == "patwait0 0x005c\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patwait0", {}, -1, GET, oss);
|
proxy.Call("patwait0", {}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "patwait0 0x5c\n");
|
REQUIRE(oss.str() == "patwait0 0x005c\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setPatternWaitAddr(0, prev_val[i], {i});
|
det.setPatternWaitAddr(0, prev_val[i], {i});
|
||||||
@ -360,12 +332,12 @@ TEST_CASE("patwait1", "[.cmd][.new]") {
|
|||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patwait1", {"0x5c"}, -1, PUT, oss);
|
proxy.Call("patwait1", {"0x5c"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "patwait1 0x5c\n");
|
REQUIRE(oss.str() == "patwait1 0x005c\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patwait1", {}, -1, GET, oss);
|
proxy.Call("patwait1", {}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "patwait1 0x5c\n");
|
REQUIRE(oss.str() == "patwait1 0x005c\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setPatternWaitAddr(1, prev_val[i], {i});
|
det.setPatternWaitAddr(1, prev_val[i], {i});
|
||||||
@ -386,12 +358,12 @@ TEST_CASE("patwait2", "[.cmd][.new]") {
|
|||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patwait2", {"0x5c"}, -1, PUT, oss);
|
proxy.Call("patwait2", {"0x5c"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "patwait2 0x5c\n");
|
REQUIRE(oss.str() == "patwait2 0x005c\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("patwait2", {}, -1, GET, oss);
|
proxy.Call("patwait2", {}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "patwait2 0x5c\n");
|
REQUIRE(oss.str() == "patwait2 0x005c\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setPatternWaitAddr(2, prev_val[i], {i});
|
det.setPatternWaitAddr(2, prev_val[i], {i});
|
||||||
|
@ -44,6 +44,9 @@ std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::ROI &roi);
|
|||||||
std::string ToString(const slsDetectorDefs::rxParameters &r);
|
std::string ToString(const slsDetectorDefs::rxParameters &r);
|
||||||
std::ostream &operator<<(std::ostream &os,
|
std::ostream &operator<<(std::ostream &os,
|
||||||
const slsDetectorDefs::rxParameters &r);
|
const slsDetectorDefs::rxParameters &r);
|
||||||
|
std::string ToString(const slsDetectorDefs::patternParameters &r);
|
||||||
|
std::ostream &operator<<(std::ostream &os,
|
||||||
|
const slsDetectorDefs::patternParameters &r);
|
||||||
const std::string &ToString(const std::string &s);
|
const std::string &ToString(const std::string &s);
|
||||||
|
|
||||||
/** Convert std::chrono::duration with specified output unit */
|
/** Convert std::chrono::duration with specified output unit */
|
||||||
@ -108,6 +111,16 @@ ToStringHex(const T &value) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Conversion of integer types, do not remove trailing zeros */
|
||||||
|
template <typename T>
|
||||||
|
typename std::enable_if<std::is_integral<T>::value, std::string>::type
|
||||||
|
ToStringHex(const T &value, int width) {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << "0x" << std::hex << std::setfill('0') << std::setw(width) << value
|
||||||
|
<< std::dec;
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hex
|
* hex
|
||||||
* For a container loop over all elements and call ToString on the element
|
* For a container loop over all elements and call ToString on the element
|
||||||
@ -131,6 +144,24 @@ ToStringHex(const T &container) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
typename std::enable_if<
|
||||||
|
is_container<T>::value &&
|
||||||
|
!std::is_same<typename T::value_type, std::string>::value,
|
||||||
|
std::string>::type
|
||||||
|
ToStringHex(const T &container, int width) {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << '[';
|
||||||
|
if (!container.empty()) {
|
||||||
|
auto it = container.cbegin();
|
||||||
|
os << ToStringHex(*it++, width);
|
||||||
|
while (it != container.cend())
|
||||||
|
os << ", " << ToStringHex(*it++, width);
|
||||||
|
}
|
||||||
|
os << ']';
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename KeyType, typename ValueType>
|
template <typename KeyType, typename ValueType>
|
||||||
std::string ToString(const std::map<KeyType, ValueType> &m) {
|
std::string ToString(const std::map<KeyType, ValueType> &m) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
@ -61,6 +61,8 @@
|
|||||||
#define MAX_STR_LENGTH 1000
|
#define MAX_STR_LENGTH 1000
|
||||||
#define SHORT_STR_LENGTH 20
|
#define SHORT_STR_LENGTH 20
|
||||||
|
|
||||||
|
#define MAX_PATTERN_LENGTH 0x2000
|
||||||
|
|
||||||
#define DEFAULT_STREAMING_TIMER_IN_MS 200
|
#define DEFAULT_STREAMING_TIMER_IN_MS 200
|
||||||
|
|
||||||
#define NUM_RX_THREAD_IDS 8
|
#define NUM_RX_THREAD_IDS 8
|
||||||
@ -437,6 +439,17 @@ typedef struct {
|
|||||||
int64_t gateDelay3Ns{0};
|
int64_t gateDelay3Ns{0};
|
||||||
int gates{0};
|
int gates{0};
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
/** pattern structure */
|
||||||
|
struct patternParameters {
|
||||||
|
uint64_t word[MAX_PATTERN_LENGTH]{};
|
||||||
|
uint64_t patioctrl{0};
|
||||||
|
uint32_t patlimits[2]{};
|
||||||
|
uint32_t patloop[6]{};
|
||||||
|
uint32_t patnloop[3]{};
|
||||||
|
uint32_t patwait[3]{};
|
||||||
|
uint64_t patwaittime[3]{};
|
||||||
|
} __attribute__((packed));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -73,7 +73,6 @@ enum detFuncs {
|
|||||||
F_ENABLE_TEN_GIGA,
|
F_ENABLE_TEN_GIGA,
|
||||||
F_SET_ALL_TRIMBITS,
|
F_SET_ALL_TRIMBITS,
|
||||||
F_SET_PATTERN_IO_CONTROL,
|
F_SET_PATTERN_IO_CONTROL,
|
||||||
F_SET_PATTERN_CLOCK_CONTROL,
|
|
||||||
F_SET_PATTERN_WORD,
|
F_SET_PATTERN_WORD,
|
||||||
F_SET_PATTERN_LOOP_ADDRESSES,
|
F_SET_PATTERN_LOOP_ADDRESSES,
|
||||||
F_SET_PATTERN_LOOP_CYCLES,
|
F_SET_PATTERN_LOOP_CYCLES,
|
||||||
@ -201,6 +200,7 @@ enum detFuncs {
|
|||||||
F_GET_GATE_DELAY_ALL_GATES,
|
F_GET_GATE_DELAY_ALL_GATES,
|
||||||
F_GET_VETO,
|
F_GET_VETO,
|
||||||
F_SET_VETO,
|
F_SET_VETO,
|
||||||
|
F_SET_PATTERN,
|
||||||
|
|
||||||
NUM_DET_FUNCTIONS,
|
NUM_DET_FUNCTIONS,
|
||||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||||
@ -372,7 +372,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
|
case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
|
||||||
case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
|
case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
|
||||||
case F_SET_PATTERN_IO_CONTROL: return "F_SET_PATTERN_IO_CONTROL";
|
case F_SET_PATTERN_IO_CONTROL: return "F_SET_PATTERN_IO_CONTROL";
|
||||||
case F_SET_PATTERN_CLOCK_CONTROL: return "F_SET_PATTERN_CLOCK_CONTROL";
|
|
||||||
case F_SET_PATTERN_WORD: return "F_SET_PATTERN_WORD";
|
case F_SET_PATTERN_WORD: return "F_SET_PATTERN_WORD";
|
||||||
case F_SET_PATTERN_LOOP_ADDRESSES: return "F_SET_PATTERN_LOOP_ADDRESSES";
|
case F_SET_PATTERN_LOOP_ADDRESSES: return "F_SET_PATTERN_LOOP_ADDRESSES";
|
||||||
case F_SET_PATTERN_LOOP_CYCLES: return "F_SET_PATTERN_LOOP_CYCLES";
|
case F_SET_PATTERN_LOOP_CYCLES: return "F_SET_PATTERN_LOOP_CYCLES";
|
||||||
@ -500,6 +499,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_GET_GATE_DELAY_ALL_GATES: return "F_GET_GATE_DELAY_ALL_GATES";
|
case F_GET_GATE_DELAY_ALL_GATES: return "F_GET_GATE_DELAY_ALL_GATES";
|
||||||
case F_GET_VETO: return "F_GET_VETO";
|
case F_GET_VETO: return "F_GET_VETO";
|
||||||
case F_SET_VETO: return "F_SET_VETO";
|
case F_SET_VETO: return "F_SET_VETO";
|
||||||
|
case F_SET_PATTERN: return "F_SET_PATTERN";
|
||||||
|
|
||||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
#define APILIB 0x200409
|
#define APILIB 0x200409
|
||||||
#define APIRECEIVER 0x200409
|
#define APIRECEIVER 0x200409
|
||||||
#define APIGUI 0x200409
|
#define APIGUI 0x200409
|
||||||
#define APIEIGER 0x200618
|
#define APIEIGER 0x200623
|
||||||
#define APICTB 0x200618
|
#define APICTB 0x200623
|
||||||
#define APIGOTTHARD 0x200618
|
#define APIGOTTHARD 0x200623
|
||||||
#define APIGOTTHARD2 0x200618
|
#define APIGOTTHARD2 0x200623
|
||||||
#define APIJUNGFRAU 0x200618
|
#define APIJUNGFRAU 0x200623
|
||||||
#define APIMYTHEN3 0x200618
|
#define APIMYTHEN3 0x200623
|
||||||
#define APIMOENCH 0x200618
|
#define APIMOENCH 0x200623
|
||||||
|
@ -64,6 +64,44 @@ std::ostream &operator<<(std::ostream &os,
|
|||||||
return os << ToString(r);
|
return os << ToString(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ToString(const slsDetectorDefs::patternParameters &r) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << '[' << std::setfill('0') << std::endl;
|
||||||
|
int addr_width = 4;
|
||||||
|
int word_width = 16;
|
||||||
|
for (int i = 0; i < MAX_PATTERN_LENGTH; ++i) {
|
||||||
|
if (r.word[i] != 0) {
|
||||||
|
oss << "patword " << ToStringHex(i, addr_width) << " "
|
||||||
|
<< ToStringHex(r.word[i], word_width) << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oss << "patioctrl " << ToStringHex(r.patioctrl, word_width) << std::endl
|
||||||
|
<< "patlimits " << ToStringHex(r.patlimits[0], addr_width) << " "
|
||||||
|
<< ToStringHex(r.patlimits[1], addr_width) << std::endl
|
||||||
|
<< "patloop0 " << ToStringHex(r.patloop[0], addr_width) << " "
|
||||||
|
<< ToStringHex(r.patloop[1], addr_width) << std::endl
|
||||||
|
<< "patnloop0 " << r.patnloop[0] << std::endl
|
||||||
|
<< "patloop1 " << ToStringHex(r.patloop[2], addr_width) << " "
|
||||||
|
<< ToStringHex(r.patloop[3], addr_width) << std::endl
|
||||||
|
<< "patnloop1 " << r.patnloop[1] << std::endl
|
||||||
|
<< "patloop2 " << ToStringHex(r.patloop[4], addr_width) << " "
|
||||||
|
<< ToStringHex(r.patloop[5], addr_width) << std::endl
|
||||||
|
<< "patnloop2 " << r.patnloop[2] << std::endl
|
||||||
|
<< "patwait0 " << ToStringHex(r.patwait[0], addr_width) << std::endl
|
||||||
|
<< "patwaittime0 " << r.patwaittime[0] << std::endl
|
||||||
|
<< "patwait1 " << ToStringHex(r.patwait[1], addr_width) << std::endl
|
||||||
|
<< "patwaittime1 " << r.patwaittime[1] << std::endl
|
||||||
|
<< "patwait2 " << ToStringHex(r.patwait[2], addr_width) << std::endl
|
||||||
|
<< "patwaittime2 " << r.patwaittime[2] << std::endl
|
||||||
|
<< ']';
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &os,
|
||||||
|
const slsDetectorDefs::patternParameters &r) {
|
||||||
|
return os << ToString(r);
|
||||||
|
}
|
||||||
|
|
||||||
std::string ToString(const defs::runStatus s) {
|
std::string ToString(const defs::runStatus s) {
|
||||||
switch (s) {
|
switch (s) {
|
||||||
case defs::ERROR:
|
case defs::ERROR:
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
using sls::defs;
|
using sls::defs;
|
||||||
using sls::StringTo;
|
using sls::StringTo;
|
||||||
using sls::ToString;
|
using sls::ToString;
|
||||||
|
using sls::ToStringHex;
|
||||||
using namespace sls::time;
|
using namespace sls::time;
|
||||||
|
|
||||||
TEST_CASE("Integer conversions", "[support]") {
|
TEST_CASE("Integer conversions", "[support]") {
|
||||||
@ -261,3 +262,15 @@ TEST_CASE("vector of dac index to string") {
|
|||||||
auto r = ToString(daci);
|
auto r = ToString(daci);
|
||||||
REQUIRE(r == "[vcassh, vth2, vrshaper]");
|
REQUIRE(r == "[vcassh, vth2, vrshaper]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("int or uin64_t to a string in hex") {
|
||||||
|
REQUIRE(ToStringHex(65535) == "0xffff");
|
||||||
|
REQUIRE(ToStringHex(65535, 8) == "0x0000ffff");
|
||||||
|
REQUIRE(ToStringHex(8927748192) == "0x21422a060");
|
||||||
|
REQUIRE(ToStringHex(8927748192, 16) == "0x000000021422a060");
|
||||||
|
std::vector<int> temp{244, 65535, 1638582};
|
||||||
|
auto r = ToStringHex(temp);
|
||||||
|
REQUIRE(r == "[0xf4, 0xffff, 0x1900b6]");
|
||||||
|
r = ToStringHex(temp, 8);
|
||||||
|
REQUIRE(r == "[0x000000f4, 0x0000ffff, 0x001900b6]");
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user