diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 62b1a1ac2..1e7d97486 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -1278,6 +1278,10 @@ void init_det(py::module &m) { .def("savePattern", (void (Detector::*)(const std::string &)) & Detector::savePattern, py::arg()) + .def("loadDefaultPattern", + (void (Detector::*)(sls::Positions)) & + Detector::loadDefaultPattern, + py::arg() = Positions{}) .def("getPatternIOControl", (Result(Detector::*)(sls::Positions) const) & Detector::getPatternIOControl, diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index cf768432a..7cf7fdb85 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 11d586284..21f7baca1 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -409,9 +409,9 @@ void setupDetector() { // pll defines ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, - PLL_RESET_REG, PLL_RESET_REG, - PLL_RESET_READOUT_MSK, PLL_RESET_SYSTEM_MSK, - READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ); + PLL_RESET_REG, PLL_RESET_READOUT_MSK, + PLL_RESET_SYSTEM_MSK, READOUT_PLL_VCO_FREQ_HZ, + SYSTEM_PLL_VCO_FREQ_HZ); ALTERA_PLL_C10_ResetPLL(READOUT_PLL); ALTERA_PLL_C10_ResetPLL(SYSTEM_PLL); // hv diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index a61c9c4ef..848edf248 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index a0c28c797..1ea6275ed 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -550,7 +550,9 @@ void setupDetector() { initError = FAIL; } setPipeline(ADC_CLK, DEFAULT_PIPELINE); - loadDefaultPattern(DEFAULT_PATTERN_FILE); + if (initError != FAIL) { + initError = loadDefaultPattern(DEFAULT_PATTERN_FILE, initErrorMessage); + } setSettings(DEFAULT_SETTINGS); setFrequency(RUN_CLK, DEFAULT_RUN_CLK); diff --git a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h index 847d396e6..a07a24a50 100644 --- a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h @@ -103,7 +103,12 @@ /* Look at me register, read only */ #define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL) // Not used in firmware or software, good to play with -#define SYSTEM_STATUS_REG (0x06 * REG_OFFSET + BASE_CONTROL) // Not used in software +#define SYSTEM_STATUS_REG (0x06 * REG_OFFSET + BASE_CONTROL) + +#define SYSTEM_STATUS_R_PLL_LCKD_OFST (1) +#define SYSTEM_STATUS_R_PLL_LCKD_MSK (0x00000001 << SYSTEM_STATUS_R_PLL_LCKD_OFST) +#define SYSTEM_STATUS_RDO_PLL_LCKD_OFST (2) +#define SYSTEM_STATUS_RDO_PLL_LCKD_MSK (0x00000001 << SYSTEM_STATUS_RDO_PLL_LCKD_OFST) /* Config RW regiseter */ #define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL) @@ -483,6 +488,14 @@ /* ASIC Readout Control registers * --------------------------------------------------*/ +/** ASIC Readout Status register */ +#define ASIC_RDO_STATUS_REG (0x00 * REG_OFFSET + BASE_ASIC_RDO) + +#define ASIC_RDO_STATUS_BUSY_OFST (1) +#define ASIC_RDO_STATUS_BUSY_MSK (0x00000001 << ASIC_RDO_STATUS_BUSY_OFST) + + +/** ASIC Readout Res Storage Counter register */ #define ASIC_RDO_CONFIG_REG (0x01 * REG_OFFSET + BASE_ASIC_RDO) #define ASICRDO_CNFG_RESSTRG_LNGTH_OFST (0) diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 88a1b2462..57a797219 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 44ac9ffbb..b4d7933b3 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -401,10 +401,11 @@ void setupDetector() { #endif // pll defines - ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, - PLL_RESET_REG, PLL_RESET_REG, - PLL_RESET_READOUT_MSK, PLL_RESET_SYSTEM_MSK, - READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ); + ALTERA_PLL_C10_SetDefines( + REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, PLL_RESET_REG, + PLL_RESET_READOUT_MSK, PLL_RESET_SYSTEM_MSK, SYSTEM_STATUS_REG, + SYSTEM_STATUS_RDO_PLL_LCKD_MSK, SYSTEM_STATUS_R_PLL_LCKD_MSK, + READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ); ALTERA_PLL_C10_ResetPLL(READOUT_PLL); ALTERA_PLL_C10_ResetPLL(SYSTEM_PLL); // hv @@ -482,7 +483,9 @@ void setupDetector() { } powerChip(1); - loadDefaultPattern(DEFAULT_PATTERN_FILE); + if (initError != FAIL) { + initError = loadDefaultPattern(DEFAULT_PATTERN_FILE, initErrorMessage); + } } int setDefaultDacs() { @@ -2420,8 +2423,12 @@ int startReadOut() { // start readout bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STRT_READOUT_MSK); - LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG))); + usleep(1); + while (bus_r(ASIC_RDO_STATUS_REG) & ASIC_RDO_STATUS_BUSY_MSK) { + usleep(1); + } + LOG(logINFOBLUE, ("Readout done\n")); return OK; } diff --git a/slsDetectorServers/slsDetectorServer/include/ALTERA_PLL_CYCLONE10.h b/slsDetectorServers/slsDetectorServer/include/ALTERA_PLL_CYCLONE10.h index 85cd9a992..8044323ee 100644 --- a/slsDetectorServers/slsDetectorServer/include/ALTERA_PLL_CYCLONE10.h +++ b/slsDetectorServers/slsDetectorServer/include/ALTERA_PLL_CYCLONE10.h @@ -15,9 +15,13 @@ * @param vcofreq1 vco frequency of pll 1 */ void ALTERA_PLL_C10_SetDefines(int regofst, uint32_t baseaddr0, - uint32_t baseaddr1, uint32_t resetreg0, - uint32_t resetreg1, uint32_t resetmsk0, - uint32_t resetmsk1, int vcofreq0, int vcofreq1); + uint32_t baseaddr1, uint32_t resetreg, + uint32_t resetmsk0, uint32_t resetmsk1, +#ifdef MYTHEN3D + uint32_t statusreg, uint32_t statusmsk0, + uint32_t statusmsk1, +#endif + int vcofreq0, int vcofreq1); /** * Get Max Clock Divider diff --git a/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h b/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h index b9ee36a17..a4b1d9c03 100644 --- a/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h +++ b/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h @@ -3,7 +3,7 @@ #include #include -int loadDefaultPattern(char *patFname); +int loadDefaultPattern(char *patFname, char *errMessage); int default_writePatternWord(char *line, uint32_t addr, uint64_t word); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 9994d255e..df44cd288 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -243,4 +243,5 @@ int get_bursts_left(int); int start_readout(int); int set_default_dacs(int); int is_virtual(int); -int get_pattern(int); \ No newline at end of file +int get_pattern(int); +int load_default_pattern(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c b/slsDetectorServers/slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c index be52b46b8..12849f106 100644 --- a/slsDetectorServers/slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c +++ b/slsDetectorServers/slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c @@ -56,21 +56,35 @@ int ALTERA_PLL_C10_Reg_offset = 0x0; const int ALTERA_PLL_C10_NUM = 2; uint32_t ALTERA_PLL_C10_BaseAddress[2] = {0x0, 0x0}; -uint32_t ALTERA_PLL_C10_Reset_Reg[2] = {0x0, 0x0}; +uint32_t ALTERA_PLL_C10_Reset_Reg = 0x0; uint32_t ALTERA_PLL_C10_Reset_Msk[2] = {0x0, 0x0}; +#ifdef MYTHEN3D +uint32_t ALTERA_PLL_C10_Locked_Status_Reg = 0x0; +uint32_t ALTERA_PLL_C10_Locked_Status_Msk[2] = {0x0, 0x0}; +#endif int ALTERA_PLL_C10_VCO_FREQ[2] = {0, 0}; void ALTERA_PLL_C10_SetDefines(int regofst, uint32_t baseaddr0, - uint32_t baseaddr1, uint32_t resetreg0, - uint32_t resetreg1, uint32_t resetmsk0, - uint32_t resetmsk1, int vcofreq0, int vcofreq1) { + uint32_t baseaddr1, uint32_t resetreg, + uint32_t resetmsk0, uint32_t resetmsk1, +#ifdef MYTHEN3D + uint32_t statusreg, uint32_t statusmsk0, + uint32_t statusmsk1, +#endif + int vcofreq0, int vcofreq1) { ALTERA_PLL_C10_Reg_offset = regofst; ALTERA_PLL_C10_BaseAddress[0] = baseaddr0; ALTERA_PLL_C10_BaseAddress[1] = baseaddr1; - ALTERA_PLL_C10_Reset_Reg[0] = resetreg0; - ALTERA_PLL_C10_Reset_Reg[1] = resetreg1; + ALTERA_PLL_C10_Reset_Reg = resetreg; ALTERA_PLL_C10_Reset_Msk[0] = resetmsk0; ALTERA_PLL_C10_Reset_Msk[1] = resetmsk1; + + // pll locked status reg and msk only used for m3 now +#ifdef MYTHEN3D + ALTERA_PLL_C10_Locked_Status_Reg = statusreg; + ALTERA_PLL_C10_Locked_Status_Msk[0] = statusmsk0; + ALTERA_PLL_C10_Locked_Status_Msk[1] = statusmsk1; +#endif ALTERA_PLL_C10_VCO_FREQ[0] = vcofreq0; ALTERA_PLL_C10_VCO_FREQ[1] = vcofreq1; } @@ -98,12 +112,24 @@ void ALTERA_PLL_C10_Reconfigure(int pllIndex) { } void ALTERA_PLL_C10_ResetPLL(int pllIndex) { - uint32_t resetreg = ALTERA_PLL_C10_Reset_Reg[pllIndex]; + uint32_t resetreg = ALTERA_PLL_C10_Reset_Reg; uint32_t resetmsk = ALTERA_PLL_C10_Reset_Msk[pllIndex]; LOG(logINFO, ("Resetting PLL %d\n", pllIndex)); bus_w_csp1(resetreg, bus_r_csp1(resetreg) | resetmsk); - usleep(ALTERA_PLL_C10_WAIT_TIME_US); + +#ifndef VIRTUAL +#ifdef MYTHEN3D + uint32_t statusreg = ALTERA_PLL_C10_Locked_Status_Reg; + uint32_t statusmsk = ALTERA_PLL_C10_Locked_Status_Msk[pllIndex]; + // wait for pll locked bit to go high + while (!(bus_r(statusreg) & statusmsk)) { + usleep(ALTERA_PLL_C10_WAIT_TIME_US); + LOG(logWARNING, ("Still waiting for PLL %d recovery\n", pllIndex)); + } + LOG(logINFO, ("Reset success for PLL %d\n", pllIndex)); +#endif +#endif } void ALTERA_PLL_C10_SetPhaseShift(int pllIndex, int clkIndex, int phase, diff --git a/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c b/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c index 63064fa7e..ab731062a 100644 --- a/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c +++ b/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c @@ -8,7 +8,6 @@ #include extern char initErrorMessage[MAX_STR_LENGTH]; -extern int initError; #ifndef MYTHEN3D extern uint64_t writePatternIOControl(uint64_t word); @@ -19,11 +18,7 @@ extern uint64_t setPatternWaitTime(int level, uint64_t t); extern void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop); -int loadDefaultPattern(char *patFname) { - if (initError == FAIL) { - return initError; - } - +int loadDefaultPattern(char *patFname, char *errMessage) { char fname[128]; if (getAbsPath(fname, 128, patFname) == FAIL) { return FAIL; @@ -32,10 +27,8 @@ int loadDefaultPattern(char *patFname) { // open config file FILE *fd = fopen(fname, "r"); if (fd == NULL) { - sprintf(initErrorMessage, "Could not open pattern file [%s].\n", - patFname); - initError = FAIL; - LOG(logERROR, ("%s\n\n", initErrorMessage)); + sprintf(errMessage, "Could not open pattern file [%s].\n", patFname); + LOG(logERROR, ("%s\n\n", errMessage)); return FAIL; } LOG(logINFOBLUE, ("Reading default pattern file %s\n", patFname)); @@ -100,7 +93,7 @@ int loadDefaultPattern(char *patFname) { #else if (sscanf(line, "%s 0x%x 0x%llx", command, &addr, &word) != 3) { #endif - sprintf(initErrorMessage, + sprintf(errMessage, "Could not scan patword arguments from default " "pattern file. Line:[%s].\n", line); @@ -123,7 +116,7 @@ int loadDefaultPattern(char *patFname) { #else if (sscanf(line, "%s 0x%llx", command, &arg) != 2) { #endif - sprintf(initErrorMessage, + sprintf(errMessage, "Could not scan patioctrl arguments from default " "pattern file. Line:[%s].\n", line); @@ -144,7 +137,7 @@ int loadDefaultPattern(char *patFname) { // cannot scan values if (sscanf(line, "%s 0x%x 0x%x", command, &startAddr, &stopAddr) != 3) { - sprintf(initErrorMessage, + sprintf(errMessage, "Could not scan patlimits arguments from default " "pattern file. Line:[%s].\n", line); @@ -177,7 +170,7 @@ int loadDefaultPattern(char *patFname) { // cannot scan values if (sscanf(line, "%s 0x%x 0x%x", command, &startAddr, &stopAddr) != 3) { - sprintf(initErrorMessage, + sprintf(errMessage, "Could not scan patloop%d arguments from default " "pattern file. Line:[%s].\n", level, line); @@ -208,7 +201,7 @@ int loadDefaultPattern(char *patFname) { int numLoops = -1; // cannot scan values if (sscanf(line, "%s %d", command, &numLoops) != 2) { - sprintf(initErrorMessage, + sprintf(errMessage, "Could not scan patnloop%d arguments from default " "pattern file. Line:[%s].\n", level, line); @@ -238,7 +231,7 @@ int loadDefaultPattern(char *patFname) { uint32_t addr = 0; // cannot scan values if (sscanf(line, "%s 0x%x", command, &addr) != 2) { - sprintf(initErrorMessage, + sprintf(errMessage, "Could not scan patwait%d arguments from default " "pattern file. Line:[%s].\n", level, line); @@ -273,7 +266,7 @@ int loadDefaultPattern(char *patFname) { #else if (sscanf(line, "%s %lld", command, &waittime) != 2) { #endif - sprintf(initErrorMessage, + sprintf(errMessage, "Could not scan patwaittime%d arguments from default " "pattern file. Line:[%s].\n", level, line); @@ -289,13 +282,12 @@ int loadDefaultPattern(char *patFname) { } fclose(fd); - if (strlen(initErrorMessage)) { - initError = FAIL; - LOG(logERROR, ("%s\n\n", initErrorMessage)); - } else { - LOG(logINFOBLUE, ("Successfully read default pattern file\n")); + if (strlen(errMessage)) { + LOG(logERROR, ("%s\n\n", errMessage)); + return FAIL; } - return initError; + LOG(logINFOBLUE, ("Successfully read default pattern file\n")); + return OK; } int default_writePatternWord(char *line, uint32_t addr, uint64_t word) { diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 0d9e7fa42..25c3e85c4 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -366,6 +366,7 @@ void function_table() { flist[F_SET_DEFAULT_DACS] = &set_default_dacs; flist[F_IS_VIRTUAL] = &is_virtual; flist[F_GET_PATTERN] = &get_pattern; + flist[F_LOAD_DEFAULT_PATTERN] = &load_default_pattern; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -8297,3 +8298,20 @@ int is_virtual(int file_des) { LOG(logDEBUG1, ("is virtual retval: %d\n", retval)); return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } + +int load_default_pattern(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + +#if !defined(MYTHEN3D) && !defined(MOENCHD) + functionNotImplemented(); +#else + if (Server_VerifyLock() == OK) { + ret = loadDefaultPattern(DEFAULT_PATTERN_FILE, mess); + if (ret == FAIL) { + LOG(logERROR, (mess)); + } + } +#endif + return Server_SendResult(file_des, INT32, NULL, 0); +} \ No newline at end of file diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 1cc1e173a..937fc1777 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1,8 +1,8 @@ #pragma once +#include "sls/Pattern.h" #include "sls/Result.h" #include "sls/network_utils.h" #include "sls/sls_detector_defs.h" -#include "sls/Pattern.h" #include #include #include @@ -16,7 +16,6 @@ class DetectorImpl; class MacAddr; class IpAddr; - // Free function to avoid dependence on class // and avoid the option to free another objects // shm by mistake @@ -1461,12 +1460,15 @@ class Detector { /** [CTB][Moench][Mythen3] Loads pattern parameters structure directly to * server */ - void setPattern(const Pattern& pat, Positions pos = {}); + void setPattern(const Pattern &pat, Positions pos = {}); /** [CTB][Moench][Mythen3] [Ctb][Moench][Mythen3] Saves pattern to file * (ascii). \n [Ctb][Moench] Also executes pattern.*/ void savePattern(const std::string &fname); + /** [Mythen3][Moench] Loads and runs default pattern */ + void loadDefaultPattern(Positions pos = {}); + /** [CTB][Moench] */ Result getPatternIOControl(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index f95a1b717..4629f64a6 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1014,6 +1014,7 @@ class CmdProxy { /* Pattern */ {"pattern", &CmdProxy::Pattern}, {"savepattern", &CmdProxy::savepattern}, + {"defaultpattern", &CmdProxy::defaultpattern}, {"patioctrl", &CmdProxy::patioctrl}, {"patword", &CmdProxy::PatternWord}, {"patlimits", &CmdProxy::PatternLoopAddresses}, @@ -2063,6 +2064,11 @@ class CmdProxy { "[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). " "\n\t[Ctb][Moench] Also executes pattern."); + EXECUTE_SET_COMMAND( + defaultpattern, loadDefaultPattern, + "\n\t[Mythen3][Moench] Loads and runs default pattern in pattern " + "generator. It is to go back to initial settings."); + INTEGER_COMMAND_HEX_WIDTH16(patioctrl, getPatternIOControl, setPatternIOControl, StringTo, "[64 bit mask]\n\t[Ctb][Moench] 64 bit mask " diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 04ae3aa6b..2e98dcfe2 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1754,13 +1754,6 @@ void Detector::setLEDEnable(bool enable, Positions pos) { // Pattern -void Detector::savePattern(const std::string &fname) { - auto t = pimpl->Parallel(&Module::getPattern, {}); - auto pat = t.tsquash("Inconsistent pattern parameters between modules"); - pat.validate(); - pat.save(fname); -} - void Detector::setPattern(const std::string &fname, Positions pos) { Pattern pat; pat.load(fname); @@ -1773,6 +1766,17 @@ void Detector::setPattern(const Pattern &pat, Positions pos) { pimpl->Parallel(&Module::setPattern, pos, pat); } +void Detector::savePattern(const std::string &fname) { + auto t = pimpl->Parallel(&Module::getPattern, {}); + auto pat = t.tsquash("Inconsistent pattern parameters between modules"); + pat.validate(); + pat.save(fname); +} + +void Detector::loadDefaultPattern(Positions pos) { + pimpl->Parallel(&Module::loadDefaultPattern, pos); +} + Result Detector::getPatternIOControl(Positions pos) const { return pimpl->Parallel(&Module::getPatternIOControl, pos); } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 5208e0a31..fbdf8d4f6 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -1923,6 +1923,8 @@ Pattern Module::getPattern() { return pat; } +void Module::loadDefaultPattern() { sendToDetector(F_LOAD_DEFAULT_PATTERN); } + uint64_t Module::getPatternIOControl() const { return sendToDetector(F_SET_PATTERN_IO_CONTROL, int64_t(GET_FLAG)); diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 6916b9329..ac8bab7c6 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -1,11 +1,11 @@ #pragma once #include "SharedMemory.h" #include "sls/ClientSocket.h" +#include "sls/Pattern.h" #include "sls/StaticVector.h" #include "sls/logger.h" #include "sls/network_utils.h" #include "sls/sls_detector_defs.h" -#include "sls/Pattern.h" #include #include @@ -463,8 +463,9 @@ class Module : public virtual slsDetectorDefs { * Pattern * * * * ************************************************/ - void setPattern(const Pattern& pat); + void setPattern(const Pattern &pat); Pattern getPattern(); + void loadDefaultPattern(); uint64_t getPatternIOControl() const; void setPatternIOControl(uint64_t word); uint64_t getPatternWord(int addr) const; diff --git a/slsDetectorSoftware/tests/test-CmdProxy-pattern.cpp b/slsDetectorSoftware/tests/test-CmdProxy-pattern.cpp index 7e504711c..1f7d4db45 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-pattern.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-pattern.cpp @@ -46,6 +46,19 @@ TEST_CASE("savepattern", "[.cmd]") { } } +TEST_CASE("defaultpattern", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MOENCH || det_type == defs::MYTHEN3) { + REQUIRE_THROWS(proxy.Call("defaultpattern", {}, -1, GET)); + REQUIRE_NOTHROW(proxy.Call("defaultpattern", {}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("defaultpattern", {}, -1, GET)); + REQUIRE_NOTHROW(proxy.Call("defaultpattern", {}, -1, PUT)); + } +} + TEST_CASE("patioctrl", "[.cmd]") { Detector det; CmdProxy proxy(&det); diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 693705d99..3adb889d8 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -218,6 +218,7 @@ enum detFuncs { F_SET_DEFAULT_DACS, F_IS_VIRTUAL, F_GET_PATTERN, + F_LOAD_DEFAULT_PATTERN, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -541,6 +542,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_DEFAULT_DACS: return "F_SET_DEFAULT_DACS"; case F_IS_VIRTUAL: return "F_IS_VIRTUAL"; case F_GET_PATTERN: return "F_GET_PATTERN"; + case F_LOAD_DEFAULT_PATTERN: return "F_LOAD_DEFAULT_PATTERN"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 86ca97011..0293a247a 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -5,8 +5,8 @@ #define APIGUI 0x201119 #define APICTB 0x201130 #define APIGOTTHARD 0x201130 -#define APIGOTTHARD2 0x201130 #define APIJUNGFRAU 0x201130 -#define APIMYTHEN3 0x201130 -#define APIMOENCH 0x201130 #define APIEIGER 0x201130 +#define APIGOTTHARD2 0x201208 +#define APIMOENCH 0x201207 +#define APIMYTHEN3 0x201209