diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 0389e28a7..2e08e740b 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index 55d73d6b4..fb03bc42d 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index b1ddbb69c..f135ab12f 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index 502a8ef6e..93e176859 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index dbf4172f5..5e2a3ec15 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index f83c186c7..37277043f 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 786505472..7802f6453 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/slsDetectorServer/include/arm64.h b/slsDetectorServers/slsDetectorServer/include/arm64.h index f095790e0..06e8f7b26 100644 --- a/slsDetectorServers/slsDetectorServer/include/arm64.h +++ b/slsDetectorServers/slsDetectorServer/include/arm64.h @@ -5,6 +5,8 @@ #include #include -int mapCSP0(void); void bus_w(u_int32_t offset, u_int32_t data); -u_int32_t bus_r(u_int32_t offset); \ No newline at end of file +u_int32_t bus_r(u_int32_t offset); +uint64_t getU64BitReg(int aLSB, int aMSB); +void setU64BitReg(uint64_t value, int aLSB, int aMSB); +int mapCSP0(void); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 6b3b43cb3..6c0a8fad5 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -65,10 +65,8 @@ typedef struct udpStruct_s { int isInitCheckDone(); int getInitResult(char **mess); void basictests(); +#if !defined(EIGERD) int checkType(); - -#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \ - defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D) int testFpga(); int testBus(); #endif @@ -251,11 +249,11 @@ int getMaxStoragecellStart(); int setNextFrameNumber(uint64_t value); int getNextFrameNumber(uint64_t *value); #endif -#ifndef XILINX_CHIPTESTBOARDD void setNumFrames(int64_t val); int64_t getNumFrames(); void setNumTriggers(int64_t val); int64_t getNumTriggers(); +#ifndef XILINX_CHIPTESTBOARDD #ifndef MYTHEN3D int setExpTime(int64_t val); int64_t getExpTime(); @@ -501,9 +499,7 @@ void calcChecksum(udp_header *udp); int getAdcConfigured(); #endif -#ifndef XILINX_CHIPTESTBOARDD int configureMAC(); -#endif int setDetectorPosition(int pos[]); int *getDetectorPosition(); @@ -715,9 +711,7 @@ int softwareTrigger(int block); #if defined(EIGERD) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD) int startReadOut(); #endif -#ifndef XILINX_CHIPTESTBOARDD enum runStatus getRunStatus(); -#endif #ifdef EIGERD void waitForAcquisitionEnd(int *ret, char *mess); #else @@ -748,9 +742,11 @@ u_int32_t runState(enum TLogLevel lev); #ifndef XILINX_CHIPTESTBOARDD int calculateDataBytes(); int getTotalNumberOfChannels(); -#if defined(CHIPTESTBOARDD) +#endif +#if defined(CHIPTESTBOARDD) || defined (XILINX_CHIPTESTBOARDD) void getNumberOfChannels(int *nchanx, int *nchany); #endif +#ifndef XILINX_CHIPTESTBOARDD int getNumberOfChips(); int getNumberOfDACs(); int getNumberOfChannelsPerChip(); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 80520a0ca..5256a3490 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -2219,9 +2219,6 @@ int get_num_frames(int file_des) { memset(mess, 0, sizeof(mess)); int64_t retval = -1; -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // get only if (!scan) { retval = getNumFrames(); @@ -2231,7 +2228,6 @@ int get_num_frames(int file_des) { LOG(logDEBUG1, ("retval num frames (num scan steps) %lld\n", (long long int)retval)); } -#endif return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); } @@ -2244,9 +2240,6 @@ int set_num_frames(int file_des) { return printSocketReadError(); LOG(logDEBUG1, ("Setting number of frames %lld\n", (long long int)arg)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { // only set number of frames if normal mode (not scan) @@ -2292,7 +2285,6 @@ int set_num_frames(int file_des) { } } } -#endif return Server_SendResult(file_des, INT64, NULL, 0); } @@ -2301,13 +2293,9 @@ int get_num_triggers(int file_des) { memset(mess, 0, sizeof(mess)); int64_t retval = -1; -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // get only retval = getNumTriggers(); LOG(logDEBUG1, ("retval num triggers %lld\n", (long long int)retval)); -#endif return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); } @@ -2320,9 +2308,6 @@ int set_num_triggers(int file_des) { return printSocketReadError(); LOG(logDEBUG1, ("Setting number of triggers %lld\n", (long long int)arg)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { #if JUNGFRAUD @@ -2342,7 +2327,6 @@ int set_num_triggers(int file_des) { validate64(&ret, mess, arg, retval, "set number of triggers", DEC); } } -#endif return Server_SendResult(file_des, INT64, NULL, 0); } @@ -3622,7 +3606,7 @@ int write_adc_register(int file_des) { uint32_t val = args[1]; LOG(logDEBUG1, ("Writing 0x%x to ADC Register 0x%x\n", val, addr)); -#if defined(EIGERD) || defined(GOTTHARD2D) || defined(MYTHEN3D) +#if defined(EIGERD) || defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else #ifndef VIRTUAL @@ -4017,7 +4001,7 @@ int reset_fpga(int file_des) { LOG(logDEBUG1, ("Reset FPGA\n")); #if defined(EIGERD) || defined(GOTTHARDD) || defined(GOTTHARD2D) || \ - defined(MYTHEN3D) + defined(MYTHEN3D) || defined (XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // only set @@ -5026,9 +5010,6 @@ int set_detector_position(int file_des) { LOG(logDEBUG, ("Setting detector positions: [maxy:%u, modIndex:%u]\n", args[0], args[1])); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { // if in update mode, there is no need to do this (also detector not set @@ -5039,14 +5020,10 @@ int set_detector_position(int file_des) { calculate_and_set_position(); } } -#endif return Server_SendResult(file_des, INT32, NULL, 0); } int check_detector_idle(const char *s) { -#ifdef XILINX_CHIPTESTBOARDD - return FAIL; -#else enum runStatus status = getRunStatus(); if (status != IDLE && status != RUN_FINISHED && status != STOPPED && status != ERROR) { @@ -5058,7 +5035,6 @@ int check_detector_idle(const char *s) { LOG(logERROR, (mess)); } return ret; -#endif } int is_udp_configured() { @@ -5125,7 +5101,6 @@ int is_udp_configured() { } void configure_mac() { -#ifndef XILINX_CHIPTESTBOARDD if (isControlServer) { if (is_udp_configured() == OK) { ret = configureMAC(); @@ -5152,7 +5127,6 @@ void configure_mac() { } configured = FAIL; LOG(logWARNING, ("Configure FAIL, not all parameters configured yet\n")); -#endif } int set_source_udp_ip(int file_des) { @@ -7105,7 +7079,7 @@ int get_num_channels(int file_des) { LOG(logDEBUG1, ("Getting number of channels\n")); -#if !defined(CHIPTESTBOARDD) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer index cdf9b7c45..c50684e34 100755 Binary files a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer and b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer differ diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c index 3faeb53ea..0f8494767 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c @@ -51,14 +51,10 @@ void basictests() { } #ifndef VIRTUAL - /*if ((!debugflag) && (!updateFlag) && - ((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) || - (checkType() == FAIL) || (testFpga() == FAIL) || - (testBus() == FAIL))) {*/ if ((!debugflag) && (!updateFlag) && ((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) || - (checkType() == FAIL) /*|| (testFpga() == FAIL) || - (testBus() == FAIL)*/)) { + (checkType() == FAIL) || (testFpga() == FAIL) || + (testBus() == FAIL))) { sprintf(initErrorMessage, "Could not pass basic tests of FPGA and bus. Cannot proceed. " "Check Firmware. (Firmware version:0x%lx) \n", @@ -103,6 +99,123 @@ int checkType() { return OK; } + +int testFpga() { +#ifdef VIRTUAL + return OK; +#endif + LOG(logINFO, ("Testing FPGA:\n")); + + // fixed pattern + int ret = OK; + + /* TODO: FIX PATTERN not defined in firmware + uint32_t val = bus_r(FIX_PATT_REG); + if (val == FIX_PATT_VAL) { + LOG(logINFO, ("\tFixed pattern: successful match (0x%08x)\n", val)); + } else { + LOG(logERROR, + ("Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n", + val, FIX_PATT_VAL)); + ret = FAIL; + } + */ + + if (ret == OK) { + // Delay LSB reg + LOG(logINFO, ("\tTesting Delay LSB Register:\n")); + uint32_t addr = DELAYINREG1; + + // store previous delay value + uint32_t previousValue = bus_r(addr); + + volatile uint32_t val = 0, readval = 0; + int times = 1000 * 1000; + for (int i = 0; i < times; ++i) { + val = 0x5A5A5A5A - i; + bus_w(addr, val); + readval = bus_r(addr); + if (readval != val) { + LOG(logERROR, ("1:Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n", + i, val, readval)); + ret = FAIL; + break; + } + val = (i + (i << 10) + (i << 20)); + bus_w(addr, val); + readval = bus_r(addr); + if (readval != val) { + LOG(logERROR, ("2:Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n", + i, val, readval)); + ret = FAIL; + break; + } + val = 0x0F0F0F0F; + bus_w(addr, val); + readval = bus_r(addr); + if (readval != val) { + LOG(logERROR, ("3:Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n", + i, val, readval)); + ret = FAIL; + break; + } + val = 0xF0F0F0F0; + bus_w(addr, val); + readval = bus_r(addr); + if (readval != val) { + LOG(logERROR, ("4:Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n", + i, val, readval)); + ret = FAIL; + break; + } + } + // write back previous value + bus_w(addr, previousValue); + if (ret == OK) { + LOG(logINFO, + ("\tSuccessfully tested FPGA Delay LSB Register %d times\n", + times)); + } + } + + return ret; +} + +int testBus() { +#ifdef VIRTUAL + return OK; +#endif + LOG(logINFO, ("Testing Bus:\n")); + + int ret = OK; + uint32_t addr = DELAYINREG1; + + // store previous delay value + uint32_t previousValue = bus_r(addr); + + volatile uint32_t val = 0, readval = 0; + int times = 1000 * 1000; + + for (int i = 0; i < times; ++i) { + val += 0xbbbbb; + bus_w(addr, val); + readval = bus_r(addr); + if (readval != val) { + LOG(logERROR, ("Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n", i, + val, readval)); + ret = FAIL; + } + } + + // write back previous value + bus_w(addr, previousValue); + + if (ret == OK) { + LOG(logINFO, ("\tSuccessfully tested bus %d times\n", times)); + } + return ret; +} + /* Ids */ void getServerVersion(char *version) { strcpy(version, APIXILINXCTB); } @@ -194,18 +307,81 @@ void initStopServer() { /* set up detector */ void setupDetector() { - LOG(logINFO, ("This Server is for 1 Xilinx Chip Test Board\n")); + LOG(logINFO, ("Setting up Server for 1 Xilinx Chip Test Board\n")); #ifdef VIRTUAL sharedMemory_setStatus(IDLE); #endif - LOG(logINFO, ("Goodbye...\n")); + + LOG(logINFOBLUE, ("Setting Default parameters\n")); + + setNumFrames(DEFAULT_NUM_FRAMES); + setNumTriggers(DEFAULT_NUM_CYCLES); } +/* parameters - timer */ + +void setNumFrames(int64_t val) { + if (val > 0) { + LOG(logINFO, ("Setting number of frames %ld\n", val)); + setU64BitReg(val, FRAMESINREG1, FRAMESINREG2); + } +} + +int64_t getNumFrames() { return getU64BitReg(FRAMESINREG1, FRAMESINREG2); } + +void setNumTriggers(int64_t val) { + if (val > 0) { + LOG(logINFO, ("Setting number of triggers %ld\n", val)); + setU64BitReg(val, CYCLESINREG1, CYCLESINREG2); + } +} + +int64_t getNumTriggers() { return getU64BitReg(CYCLESINREG1, CYCLESINREG2); } + int setDetectorPosition(int pos[]) { memcpy(detPos, pos, sizeof(detPos)); + // TODO + return OK; +} + +int configureMAC() { + // TODO + LOG(logINFO, ("Configuring MAC\n")); return OK; } int *getDetectorPosition() { return detPos; } -int getNumberofUDPInterfaces() { return 1; } \ No newline at end of file +int getNumberofUDPInterfaces() { return 1; } + +/* aquisition */ + +enum runStatus getRunStatus() { + LOG(logDEBUG1, ("Getting status\n")); + // scan error or running + if (sharedMemory_getScanStatus() == ERROR) { + LOG(logINFOBLUE, ("Status: scan ERROR\n")); + return ERROR; + } + if (sharedMemory_getScanStatus() == RUNNING) { + LOG(logINFOBLUE, ("Status: scan RUNNING\n")); + return RUNNING; + } +#ifdef VIRTUAL + if (sharedMemory_getStatus() == RUNNING) { + LOG(logINFOBLUE, ("Status: RUNNING\n")); + return RUNNING; + } + LOG(logINFOBLUE, ("Status: IDLE\n")); + return IDLE; +#endif + //TODO: get status + LOG(logINFOBLUE, ("Status: IDLE\n")); + return IDLE; +} + +void getNumberOfChannels(int *nchanx, int *nchany) { + // TODO + *nchanx = NCHAN; + *nchany = 1; +} \ No newline at end of file diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h index edb3c32b9..391a4b327 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h @@ -16,3 +16,8 @@ enum ADCINDEX { V_PWR_IO }; enum DACINDEX { D0 }; + + +/** Default Parameters */ +#define DEFAULT_NUM_FRAMES (1) +#define DEFAULT_NUM_CYCLES (1) diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index bc7d138cb..0473c3c9a 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -653,7 +653,6 @@ std::vector Detector::getTemperatureList() const { std::vector retval; switch (getDetectorType().squash()) { case defs::CHIPTESTBOARD: - case defs::XILINX_CHIPTESTBOARD: return std::vector{defs::SLOW_ADC_TEMP}; case defs::JUNGFRAU: case defs::MOENCH: diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp index bcdc91af4..fa4c278f6 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp @@ -24,7 +24,7 @@ TEST_CASE("CALLER::dacname", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { defs::dacIndex ind = static_cast(2); std::string str_dac_index = "2"; auto prev = det.getDacName(ind); @@ -58,7 +58,7 @@ TEST_CASE("CALLER::dacindex", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { defs::dacIndex ind = static_cast(2); std::string str_dac_index = "2"; @@ -83,7 +83,7 @@ TEST_CASE("CALLER::adclist", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { auto prev = det.getAdcNames(); REQUIRE_THROWS(caller.call("adclist", {"a", "s", "d"}, -1, PUT)); @@ -115,7 +115,7 @@ TEST_CASE("CALLER::adcname", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { int ind = 2; std::string str_adc_index = "2"; auto prev = det.getAdcName(ind); @@ -149,7 +149,7 @@ TEST_CASE("CALLER::adcindex", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { int ind = 2; std::string str_adc_index = "2"; @@ -174,7 +174,7 @@ TEST_CASE("CALLER::signallist", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { auto prev = det.getSignalNames(); REQUIRE_THROWS(caller.call("signallist", {"a", "s", "d"}, -1, PUT)); @@ -206,7 +206,7 @@ TEST_CASE("CALLER::signalname", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { int ind = 2; std::string str_signal_index = "2"; auto prev = det.getSignalName(ind); @@ -240,7 +240,7 @@ TEST_CASE("CALLER::signalindex", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { int ind = 2; std::string str_signal_index = "2"; @@ -266,7 +266,7 @@ TEST_CASE("CALLER::powerlist", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { auto prev = det.getPowerNames(); REQUIRE_THROWS(caller.call("powerlist", {"a", "s", "d"}, -1, PUT)); @@ -298,7 +298,7 @@ TEST_CASE("CALLER::powername", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { defs::dacIndex ind = static_cast(2 + defs::V_POWER_A); std::string str_power_index = "2"; auto prev = det.getPowerName(ind); @@ -332,7 +332,7 @@ TEST_CASE("CALLER::powerindex", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { defs::dacIndex ind = static_cast(2 + defs::V_POWER_A); std::string str_power_index = "2"; @@ -382,7 +382,7 @@ TEST_CASE("CALLER::slowadclist", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { auto prev = det.getSlowADCNames(); REQUIRE_THROWS(caller.call("slowadclist", {"a", "s", "d"}, -1, PUT)); @@ -414,7 +414,7 @@ TEST_CASE("CALLER::slowadcname", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { defs::dacIndex ind = static_cast(2 + defs::SLOW_ADC0); std::string str_slowadc_index = "2"; auto prev = det.getSlowADCName(ind); @@ -449,7 +449,7 @@ TEST_CASE("CALLER::slowadcindex", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { defs::dacIndex ind = static_cast(2 + defs::SLOW_ADC0); std::string str_slowadc_index = "2"; @@ -478,12 +478,17 @@ TEST_CASE("CALLER::dac", "[.cmdcall][.dacs]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { for (int i = 0; i < 18; ++i) { SECTION("dac " + std::to_string(i)) { - test_dac_caller(static_cast(i), "dac", 0); + if (det_type == defs::CHIPTESTBOARD) { + test_dac_caller(static_cast(i), "dac", 0); + } else { + REQUIRE_THROWS(caller.call("dac", {std::to_string(i)}, -1, GET)); + } } } + // eiger // REQUIRE_THROWS(caller.call("dac", {"vthreshold"}, -1, GET)); // REQUIRE_THROWS(caller.call("dac", {"vsvp"}, -1, GET)); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp index 195c884d9..e3429dfc2 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp @@ -27,155 +27,191 @@ python/scripts/list_tested_cmd.py to check if all commands are covered TEST_CASE("Caller::rx_version", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - std::ostringstream oss; - caller.call("rx_version", {}, -1, GET, oss); - sls::Version v(APIRECEIVER); - std::ostringstream vs; - vs << "rx_version " << v.concise() << '\n'; - REQUIRE(oss.str() == vs.str()); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + std::ostringstream oss; + caller.call("rx_version", {}, -1, GET, oss); + sls::Version v(APIRECEIVER); + std::ostringstream vs; + vs << "rx_version " << v.concise() << '\n'; + REQUIRE(oss.str() == vs.str()); - REQUIRE_THROWS(caller.call("rx_version", {"0"}, -1, PUT)); + REQUIRE_THROWS(caller.call("rx_version", {"0"}, -1, PUT)); + } else { + REQUIRE_THROWS(caller.call("rx_version", {}, -1, GET)); + } } /* acquisition */ TEST_CASE("Caller::rx_start", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - det.setFileWrite(false); // avoid writing or error on file creation - // PUT only command - REQUIRE_THROWS(caller.call("rx_start", {}, -1, GET)); - { - std::ostringstream oss; - caller.call("rx_start", {}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_start successful\n"); - } - { - std::ostringstream oss; - caller.call("rx_status", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_status running\n"); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + det.setFileWrite(false); // avoid writing or error on file creation + // PUT only command + REQUIRE_THROWS(caller.call("rx_start", {}, -1, GET)); + { + std::ostringstream oss; + caller.call("rx_start", {}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_start successful\n"); + } + { + std::ostringstream oss; + caller.call("rx_status", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_status running\n"); + } + } else { + REQUIRE_THROWS(caller.call("rx_start", {}, -1, GET)); } } TEST_CASE("Caller::rx_stop", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - // PUT only command - REQUIRE_THROWS(caller.call("rx_stop", {}, -1, GET)); - { - std::ostringstream oss; - caller.call("rx_stop", {}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_stop successful\n"); - } - { - std::ostringstream oss; - caller.call("rx_status", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_status idle\n"); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + // PUT only command + REQUIRE_THROWS(caller.call("rx_stop", {}, -1, GET)); + { + std::ostringstream oss; + caller.call("rx_stop", {}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_stop successful\n"); + } + { + std::ostringstream oss; + caller.call("rx_status", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_status idle\n"); + } + } else { + REQUIRE_THROWS(caller.call("rx_stop", {}, -1, GET)); } } TEST_CASE("Caller::rx_status", "[.cmdcall][.rx]") { Detector det; - det.setFileWrite(false); // avoid writing or error on file creation Caller caller(&det); - det.startReceiver(); - { - std::ostringstream oss; - caller.call("rx_status", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_status running\n"); - } - det.stopReceiver(); - { - std::ostringstream oss; - caller.call("rx_status", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_status idle\n"); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + det.setFileWrite(false); // avoid writing or error on file creation + Caller caller(&det); + det.startReceiver(); + { + std::ostringstream oss; + caller.call("rx_status", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_status running\n"); + } + det.stopReceiver(); + { + std::ostringstream oss; + caller.call("rx_status", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_status idle\n"); + } + } else { + REQUIRE_THROWS(caller.call("rx_status", {}, -1, GET)); } } TEST_CASE("Caller::rx_framescaught", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - - // This ensures 0 caught frames - auto prev_val = det.getFileWrite(); - det.setFileWrite(false); // avoid writing or error on file creation - det.startReceiver(); - det.stopReceiver(); - { - std::ostringstream oss; - caller.call("rx_framescaught", {}, -1, GET, oss); - if (det.getNumberofUDPInterfaces().tsquash( - "inconsistent number of interfaces") == 1) { - REQUIRE(oss.str() == "rx_framescaught [0]\n"); - } else { - REQUIRE(oss.str() == "rx_framescaught [0, 0]\n"); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + // This ensures 0 caught frames + auto prev_val = det.getFileWrite(); + det.setFileWrite(false); // avoid writing or error on file creation + det.startReceiver(); + det.stopReceiver(); + { + std::ostringstream oss; + caller.call("rx_framescaught", {}, -1, GET, oss); + if (det.getNumberofUDPInterfaces().tsquash( + "inconsistent number of interfaces") == 1) { + REQUIRE(oss.str() == "rx_framescaught [0]\n"); + } else { + REQUIRE(oss.str() == "rx_framescaught [0, 0]\n"); + } } - } - // Currently disabled may activate if we have a stable env - // Now take one frame and see that we caught it - // det.setNumberOfFrames(1); - // det.acquire(); - // { - // std::ostringstream oss; - // caller.call("rx_framescaught", {}, -1, GET, oss); - // REQUIRE(oss.str() == "rx_framescaught 1\n"); - // } + // Currently disabled may activate if we have a stable env + // Now take one frame and see that we caught it + // det.setNumberOfFrames(1); + // det.acquire(); + // { + // std::ostringstream oss; + // caller.call("rx_framescaught", {}, -1, GET, oss); + // REQUIRE(oss.str() == "rx_framescaught 1\n"); + // } - for (int i = 0; i != det.size(); ++i) { - det.setFileWrite(prev_val[i], {i}); + for (int i = 0; i != det.size(); ++i) { + det.setFileWrite(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_framescaught", {}, -1, GET)); } } TEST_CASE("Caller::rx_missingpackets", "[.cmdcall][.rx]") { Detector det; - auto prev_val = det.getFileWrite(); - det.setFileWrite(false); // avoid writing or error on file creation Caller caller(&det); - auto prev_frames = - det.getNumberOfFrames().tsquash("inconsistent #frames in test"); - det.setNumberOfFrames(100); - { - // some missing packets - det.startReceiver(); - det.stopReceiver(); - std::ostringstream oss; - caller.call("rx_missingpackets", {}, -1, GET, oss); - if (det.getNumberofUDPInterfaces().tsquash( - "inconsistent number of interfaces") == 1) { - REQUIRE(oss.str() != "rx_missingpackets [0]\n"); - } else { - REQUIRE(oss.str() != "rx_missingpackets [0, 0]\n"); - } - } auto det_type = det.getDetectorType().squash(); - if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { - // 0 missing packets (takes into account that acquisition is stopped) - det.startReceiver(); - det.startDetector(); - det.stopDetector(); - det.stopReceiver(); - std::ostringstream oss; - caller.call("rx_missingpackets", {}, -1, GET, oss); - if (det.getNumberofUDPInterfaces().tsquash( - "inconsistent number of interfaces") == 1) { - REQUIRE(oss.str() == "rx_missingpackets [0]\n"); - } else { - REQUIRE(oss.str() == "rx_missingpackets [0, 0]\n"); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getFileWrite(); + det.setFileWrite(false); // avoid writing or error on file creation + Caller caller(&det); + auto prev_frames = + det.getNumberOfFrames().tsquash("inconsistent #frames in test"); + det.setNumberOfFrames(100); + { + // some missing packets + det.startReceiver(); + det.stopReceiver(); + std::ostringstream oss; + caller.call("rx_missingpackets", {}, -1, GET, oss); + if (det.getNumberofUDPInterfaces().tsquash( + "inconsistent number of interfaces") == 1) { + REQUIRE(oss.str() != "rx_missingpackets [0]\n"); + } else { + REQUIRE(oss.str() != "rx_missingpackets [0, 0]\n"); + } } + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { + // 0 missing packets (takes into account that acquisition is stopped) + det.startReceiver(); + det.startDetector(); + det.stopDetector(); + det.stopReceiver(); + std::ostringstream oss; + caller.call("rx_missingpackets", {}, -1, GET, oss); + if (det.getNumberofUDPInterfaces().tsquash( + "inconsistent number of interfaces") == 1) { + REQUIRE(oss.str() == "rx_missingpackets [0]\n"); + } else { + REQUIRE(oss.str() == "rx_missingpackets [0, 0]\n"); + } + } + for (int i = 0; i != det.size(); ++i) { + det.setFileWrite(prev_val[i], {i}); + } + det.setNumberOfFrames(prev_frames); + } else { + REQUIRE_THROWS(caller.call("rx_missingpackets", {}, -1, GET)); } - for (int i = 0; i != det.size(); ++i) { - det.setFileWrite(prev_val[i], {i}); - } - det.setNumberOfFrames(prev_frames); } TEST_CASE("Caller::rx_frameindex", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - caller.call("rx_frameindex", {}, -1, GET); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + caller.call("rx_frameindex", {}, -1, GET); - // This is a get only command - REQUIRE_THROWS(caller.call("rx_frameindex", {"2"}, -1, PUT)); + // This is a get only command + REQUIRE_THROWS(caller.call("rx_frameindex", {"2"}, -1, PUT)); + } else { + REQUIRE_THROWS(caller.call("rx_frameindex", {}, -1, GET)); + } } /* Network Configuration (Detector<->Receiver) */ @@ -183,7 +219,12 @@ TEST_CASE("Caller::rx_frameindex", "[.cmdcall][.rx]") { TEST_CASE("Caller::rx_printconfig", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - REQUIRE_NOTHROW(caller.call("rx_printconfig", {}, -1, GET)); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + REQUIRE_NOTHROW(caller.call("rx_printconfig", {}, -1, GET)); + } else { + REQUIRE_THROWS(caller.call("rx_printconfig", {}, -1, GET)); + } } /* Receiver Config */ @@ -191,32 +232,37 @@ TEST_CASE("Caller::rx_printconfig", "[.cmdcall][.rx]") { TEST_CASE("Caller::rx_hostname", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getRxHostname(); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getRxHostname(); - // Cannot set rx_hostname (will reset parameters in rxr and no shm variables - // to update) - // { - // // disable receiver - // std::ostringstream oss; - // caller.call("rx_hostname", {"none"}, -1, PUT, oss); - // REQUIRE(oss.str() == "rx_hostname [none]\n"); - // } - // { - // std::ostringstream oss; - // caller.call("rx_hostname", {}, -1, GET, oss); - // REQUIRE(oss.str() == "rx_hostname none\n"); - // // receiver should be disabled - // REQUIRE(det.getUseReceiverFlag().tsquash( - // "different values of flag in test") == false); - // } - // put back old values (not necessary when we dont set it to none) - // for (int i = 0; i != det.size(); ++i) { - // det.setRxHostname(prev_val[i], {i}); - // } - { - std::ostringstream oss; - caller.call("rx_hostname", {}, 0, GET, oss); - REQUIRE(oss.str() == "rx_hostname " + prev_val[0] + "\n"); + // Cannot set rx_hostname (will reset parameters in rxr and no shm variables + // to update) + // { + // // disable receiver + // std::ostringstream oss; + // caller.call("rx_hostname", {"none"}, -1, PUT, oss); + // REQUIRE(oss.str() == "rx_hostname [none]\n"); + // } + // { + // std::ostringstream oss; + // caller.call("rx_hostname", {}, -1, GET, oss); + // REQUIRE(oss.str() == "rx_hostname none\n"); + // // receiver should be disabled + // REQUIRE(det.getUseReceiverFlag().tsquash( + // "different values of flag in test") == false); + // } + // put back old values (not necessary when we dont set it to none) + // for (int i = 0; i != det.size(); ++i) { + // det.setRxHostname(prev_val[i], {i}); + // } + { + std::ostringstream oss; + caller.call("rx_hostname", {}, 0, GET, oss); + REQUIRE(oss.str() == "rx_hostname " + prev_val[0] + "\n"); + } + } else { + REQUIRE_THROWS(caller.call("rx_hostname", {"localhost"}, -1, PUT)); } } @@ -262,205 +308,255 @@ TEST_CASE("Caller::rx_tcpport", "[.cmdcall][.rx]") { TEST_CASE("Caller::rx_fifodepth", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getRxFifoDepth(); - { - std::ostringstream oss; - caller.call("rx_fifodepth", {"10"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_fifodepth 10\n"); - } - { - std::ostringstream oss; - caller.call("rx_fifodepth", {"100"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_fifodepth 100\n"); - } - { - std::ostringstream oss; - caller.call("rx_fifodepth", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_fifodepth 100\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxFifoDepth(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getRxFifoDepth(); + { + std::ostringstream oss; + caller.call("rx_fifodepth", {"10"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_fifodepth 10\n"); + } + { + std::ostringstream oss; + caller.call("rx_fifodepth", {"100"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_fifodepth 100\n"); + } + { + std::ostringstream oss; + caller.call("rx_fifodepth", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_fifodepth 100\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxFifoDepth(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_fifodepth", {}, -1, GET)); } } TEST_CASE("Caller::rx_silent", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getRxSilentMode(); - { - std::ostringstream oss; - caller.call("rx_silent", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_silent 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_silent", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_silent 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_silent", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_silent 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxSilentMode(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getRxSilentMode(); + { + std::ostringstream oss; + caller.call("rx_silent", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_silent 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_silent", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_silent 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_silent", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_silent 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxSilentMode(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_silent", {}, -1, GET)); } } TEST_CASE("Caller::rx_discardpolicy", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getRxFrameDiscardPolicy(); - { - std::ostringstream oss; - caller.call("rx_discardpolicy", {"discardempty"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_discardpolicy discardempty\n"); - } - { - std::ostringstream oss; - caller.call("rx_discardpolicy", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_discardpolicy discardempty\n"); - } - { - std::ostringstream oss; - caller.call("rx_discardpolicy", {"discardpartial"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_discardpolicy discardpartial\n"); - } - { - std::ostringstream oss; - caller.call("rx_discardpolicy", {"nodiscard"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_discardpolicy nodiscard\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxFrameDiscardPolicy(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getRxFrameDiscardPolicy(); + { + std::ostringstream oss; + caller.call("rx_discardpolicy", {"discardempty"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_discardpolicy discardempty\n"); + } + { + std::ostringstream oss; + caller.call("rx_discardpolicy", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_discardpolicy discardempty\n"); + } + { + std::ostringstream oss; + caller.call("rx_discardpolicy", {"discardpartial"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_discardpolicy discardpartial\n"); + } + { + std::ostringstream oss; + caller.call("rx_discardpolicy", {"nodiscard"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_discardpolicy nodiscard\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxFrameDiscardPolicy(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_discardpolicy", {}, -1, GET)); } } TEST_CASE("Caller::rx_padding", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getPartialFramesPadding(); - { - std::ostringstream oss; - caller.call("rx_padding", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_padding 0\n"); - } - { - std::ostringstream oss; - caller.call("rx_padding", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_padding 0\n"); - } - { - std::ostringstream oss; - caller.call("rx_padding", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_padding 1\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setPartialFramesPadding(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getPartialFramesPadding(); + { + std::ostringstream oss; + caller.call("rx_padding", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_padding 0\n"); + } + { + std::ostringstream oss; + caller.call("rx_padding", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_padding 0\n"); + } + { + std::ostringstream oss; + caller.call("rx_padding", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_padding 1\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPartialFramesPadding(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_padding", {}, -1, GET)); } } TEST_CASE("Caller::rx_udpsocksize", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - int64_t prev_val = det.getRxUDPSocketBufferSize().tsquash( - "Need same udp socket buffer size to test"); - std::string s_new_val = std::to_string(prev_val); - /*std::string s_new_val = std::to_string(prev_val - 1000); - { Need permissions - std::ostringstream oss; - caller.call("rx_udpsocksize", {s_new_val}, -1, PUT, oss); - REQUIRE(oss.str() >= "rx_udpsocksize " + s_new_val + "\n"); - }*/ - { - std::ostringstream oss; - caller.call("rx_udpsocksize", {}, -1, GET, oss); - REQUIRE(oss.str() >= "rx_udpsocksize " + s_new_val + "\n"); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + int64_t prev_val = det.getRxUDPSocketBufferSize().tsquash( + "Need same udp socket buffer size to test"); + std::string s_new_val = std::to_string(prev_val); + /*std::string s_new_val = std::to_string(prev_val - 1000); + { Need permissions + std::ostringstream oss; + caller.call("rx_udpsocksize", {s_new_val}, -1, PUT, oss); + REQUIRE(oss.str() >= "rx_udpsocksize " + s_new_val + "\n"); + }*/ + { + std::ostringstream oss; + caller.call("rx_udpsocksize", {}, -1, GET, oss); + REQUIRE(oss.str() >= "rx_udpsocksize " + s_new_val + "\n"); + } + det.setRxUDPSocketBufferSize(prev_val); + } else { + REQUIRE_THROWS(caller.call("rx_udpsocksize", {}, -1, GET)); } - det.setRxUDPSocketBufferSize(prev_val); } TEST_CASE("Caller::rx_realudpsocksize", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - uint64_t val = 0; - { - std::ostringstream oss; - caller.call("rx_udpsocksize", {}, -1, GET, oss); - std::string s = (oss.str()).erase(0, strlen("rx_udpsocksize ")); - val = std::stol(s); - } - { - std::ostringstream oss; - caller.call("rx_realudpsocksize", {}, -1, GET, oss); - std::string s = (oss.str()).erase(0, strlen("rx_realudpsocksize ")); - uint64_t rval = std::stol(s); - REQUIRE(rval >= val * 2); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + uint64_t val = 0; + { + std::ostringstream oss; + caller.call("rx_udpsocksize", {}, -1, GET, oss); + std::string s = (oss.str()).erase(0, strlen("rx_udpsocksize ")); + val = std::stol(s); + } + { + std::ostringstream oss; + caller.call("rx_realudpsocksize", {}, -1, GET, oss); + std::string s = (oss.str()).erase(0, strlen("rx_realudpsocksize ")); + uint64_t rval = std::stol(s); + REQUIRE(rval >= val * 2); + } + } else { + REQUIRE_THROWS(caller.call("rx_realudpsocksize", {}, -1, GET)); } } TEST_CASE("Caller::rx_lock", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getRxLock(); - { - std::ostringstream oss; - caller.call("rx_lock", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_lock 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_lock", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_lock 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_lock", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_lock 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxLock(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getRxLock(); + { + std::ostringstream oss; + caller.call("rx_lock", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_lock 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_lock", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_lock 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_lock", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_lock 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxLock(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_lock", {}, -1, GET)); } } TEST_CASE("Caller::rx_lastclient", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - std::ostringstream oss; - REQUIRE_NOTHROW(caller.call("rx_lastclient", {}, -1, GET, oss)); - if (test::my_ip != "undefined") { - REQUIRE(oss.str() == "rx_lastclient " + test::my_ip + "\n"); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + std::ostringstream oss; + REQUIRE_NOTHROW(caller.call("rx_lastclient", {}, -1, GET, oss)); + if (test::my_ip != "undefined") { + REQUIRE(oss.str() == "rx_lastclient " + test::my_ip + "\n"); + } + } else { + REQUIRE_THROWS(caller.call("rx_lastclient", {}, -1, GET)); } } TEST_CASE("Caller::rx_threads", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - std::ostringstream oss; - REQUIRE_NOTHROW(caller.call("rx_threads", {}, -1, GET, oss)); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + std::ostringstream oss; + REQUIRE_NOTHROW(caller.call("rx_threads", {}, -1, GET, oss)); + } else { + REQUIRE_THROWS(caller.call("rx_threads", {}, -1, GET)); + } } TEST_CASE("Caller::rx_arping", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getRxArping(); - { - std::ostringstream oss; - caller.call("rx_arping", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_arping 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_arping", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_arping 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_arping", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_arping 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxArping(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getRxArping(); + { + std::ostringstream oss; + caller.call("rx_arping", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_arping 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_arping", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_arping 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_arping", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_arping 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxArping(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_arping", {}, -1, GET)); } } @@ -468,61 +564,64 @@ TEST_CASE("Caller::rx_roi", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_THROWS(caller.call("rx_roi", {"5", "10"}, -1, PUT)); + } else { + auto prev_val = det.getRxROI(); + defs::xy detsize = det.getDetectorSize(); - if (det_type == defs::CHIPTESTBOARD) { - REQUIRE_THROWS(caller.call("rx_roi", {"5", "10"}, -1, PUT)); + // 1d + if (det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2 || + det_type == defs::MYTHEN3) { + { + std::ostringstream oss; + caller.call("rx_roi", {"5", "10"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_roi [5, 10]\n"); + } + { + std::ostringstream oss; + caller.call("rx_roi", {"10", "15"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_roi [10, 15]\n"); + } + REQUIRE_THROWS(caller.call("rx_roi", {"-1", "-1"}, -1, PUT)); + REQUIRE_THROWS( + caller.call("rx_roi", {"10", "15", "25", "30"}, -1, PUT)); + } + // 2d + else { + { + std::ostringstream oss; + caller.call("rx_roi", {"10", "15", "1", "5"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_roi [10, 15, 1, 5]\n"); + } + { + std::ostringstream oss; + caller.call("rx_roi", {"10", "22", "18", "19"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_roi [10, 22, 18, 19]\n"); + } + { + std::ostringstream oss; + caller.call("rx_roi", + {"1", std::to_string(detsize.x - 5), "1", + std::to_string(detsize.y - 5)}, + -1, PUT, oss); + REQUIRE(oss.str() == std::string("rx_roi [1, ") + + std::to_string(detsize.x - 5) + + std::string(", 1, ") + + std::to_string(detsize.y - 5) + + std::string("]\n")); + } + REQUIRE_THROWS( + caller.call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT)); + } + + for (int i = 0; i != det.size(); ++i) { + det.setRxROI(prev_val); + } + } } else { - auto prev_val = det.getRxROI(); - defs::xy detsize = det.getDetectorSize(); - - // 1d - if (det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2 || - det_type == defs::MYTHEN3) { - { - std::ostringstream oss; - caller.call("rx_roi", {"5", "10"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_roi [5, 10]\n"); - } - { - std::ostringstream oss; - caller.call("rx_roi", {"10", "15"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_roi [10, 15]\n"); - } - REQUIRE_THROWS(caller.call("rx_roi", {"-1", "-1"}, -1, PUT)); - REQUIRE_THROWS( - caller.call("rx_roi", {"10", "15", "25", "30"}, -1, PUT)); - } - // 2d - else { - { - std::ostringstream oss; - caller.call("rx_roi", {"10", "15", "1", "5"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_roi [10, 15, 1, 5]\n"); - } - { - std::ostringstream oss; - caller.call("rx_roi", {"10", "22", "18", "19"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_roi [10, 22, 18, 19]\n"); - } - { - std::ostringstream oss; - caller.call("rx_roi", - {"1", std::to_string(detsize.x - 5), "1", - std::to_string(detsize.y - 5)}, - -1, PUT, oss); - REQUIRE(oss.str() == std::string("rx_roi [1, ") + - std::to_string(detsize.x - 5) + - std::string(", 1, ") + - std::to_string(detsize.y - 5) + - std::string("]\n")); - } - REQUIRE_THROWS( - caller.call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT)); - } - - for (int i = 0; i != det.size(); ++i) { - det.setRxROI(prev_val); - } + REQUIRE_THROWS(caller.call("rx_roi", {}, -1, GET)); } } @@ -530,19 +629,22 @@ TEST_CASE("Caller::rx_clearroi", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::CHIPTESTBOARD) { - REQUIRE_THROWS(caller.call("rx_clearroi", {}, -1, PUT)); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_THROWS(caller.call("rx_clearroi", {}, -1, PUT)); + } else { + auto prev_val = det.getRxROI(); + { + std::ostringstream oss; + caller.call("rx_clearroi", {}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_clearroi successful\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxROI(prev_val); + } + } } else { - auto prev_val = det.getRxROI(); - { - std::ostringstream oss; - caller.call("rx_clearroi", {}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_clearroi successful\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxROI(prev_val); - } + REQUIRE_THROWS(caller.call("rx_clearroi", {}, -1, PUT)); } } @@ -551,188 +653,228 @@ TEST_CASE("Caller::rx_clearroi", "[.cmdcall]") { TEST_CASE("Caller::fformat", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getFileFormat(); - { - std::ostringstream oss; - caller.call("fformat", {"binary"}, -1, PUT, oss); - REQUIRE(oss.str() == "fformat binary\n"); - } - { - std::ostringstream oss; - caller.call("fformat", {}, -1, GET, oss); - REQUIRE(oss.str() == "fformat binary\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFileFormat(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getFileFormat(); + { + std::ostringstream oss; + caller.call("fformat", {"binary"}, -1, PUT, oss); + REQUIRE(oss.str() == "fformat binary\n"); + } + { + std::ostringstream oss; + caller.call("fformat", {}, -1, GET, oss); + REQUIRE(oss.str() == "fformat binary\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setFileFormat(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("fformat", {}, -1, GET)); } } TEST_CASE("Caller::fpath", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getFilePath(); - { - std::ostringstream oss; - caller.call("fpath", {"/tmp"}, -1, PUT, oss); - REQUIRE(oss.str() == "fpath /tmp\n"); - } - { - std::ostringstream oss; - caller.call("fpath", {}, -1, GET, oss); - REQUIRE(oss.str() == "fpath /tmp\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFilePath(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getFilePath(); + { + std::ostringstream oss; + caller.call("fpath", {"/tmp"}, -1, PUT, oss); + REQUIRE(oss.str() == "fpath /tmp\n"); + } + { + std::ostringstream oss; + caller.call("fpath", {}, -1, GET, oss); + REQUIRE(oss.str() == "fpath /tmp\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setFilePath(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("fpath", {}, -1, GET)); } } TEST_CASE("Caller::fname", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getFileNamePrefix(); - { - std::ostringstream oss; - caller.call("fname", {"somename"}, -1, PUT, oss); - REQUIRE(oss.str() == "fname somename\n"); - } - { - std::ostringstream oss; - caller.call("fname", {}, -1, GET, oss); - REQUIRE(oss.str() == "fname somename\n"); - } - { - std::ostringstream oss; - caller.call("fname", {"run"}, -1, PUT, oss); - REQUIRE(oss.str() == "fname run\n"); - } - REQUIRE_THROWS(caller.call("fname", {"fdf/dfd"}, -1, PUT)); - REQUIRE_THROWS(caller.call("fname", {"fdf dfd"}, -1, PUT)); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getFileNamePrefix(); + { + std::ostringstream oss; + caller.call("fname", {"somename"}, -1, PUT, oss); + REQUIRE(oss.str() == "fname somename\n"); + } + { + std::ostringstream oss; + caller.call("fname", {}, -1, GET, oss); + REQUIRE(oss.str() == "fname somename\n"); + } + { + std::ostringstream oss; + caller.call("fname", {"run"}, -1, PUT, oss); + REQUIRE(oss.str() == "fname run\n"); + } + REQUIRE_THROWS(caller.call("fname", {"fdf/dfd"}, -1, PUT)); + REQUIRE_THROWS(caller.call("fname", {"fdf dfd"}, -1, PUT)); - for (int i = 0; i != det.size(); ++i) { - det.setFileNamePrefix(prev_val[i], {i}); + for (int i = 0; i != det.size(); ++i) { + det.setFileNamePrefix(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("fname", {}, -1, GET)); } } TEST_CASE("Caller::findex", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getAcquisitionIndex(); - { - std::ostringstream oss; - caller.call("findex", {"57"}, -1, PUT, oss); - REQUIRE(oss.str() == "findex 57\n"); - } - { - std::ostringstream oss; - caller.call("findex", {}, -1, GET, oss); - REQUIRE(oss.str() == "findex 57\n"); - } - { - std::ostringstream oss; - caller.call("findex", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "findex 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setAcquisitionIndex(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getAcquisitionIndex(); + { + std::ostringstream oss; + caller.call("findex", {"57"}, -1, PUT, oss); + REQUIRE(oss.str() == "findex 57\n"); + } + { + std::ostringstream oss; + caller.call("findex", {}, -1, GET, oss); + REQUIRE(oss.str() == "findex 57\n"); + } + { + std::ostringstream oss; + caller.call("findex", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "findex 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setAcquisitionIndex(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("findex", {}, -1, GET)); } } TEST_CASE("Caller::fwrite", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getFileWrite(); - { - std::ostringstream oss; - caller.call("fwrite", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "fwrite 1\n"); - } - { - std::ostringstream oss; - caller.call("fwrite", {}, -1, GET, oss); - REQUIRE(oss.str() == "fwrite 1\n"); - } - { - std::ostringstream oss; - caller.call("fwrite", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "fwrite 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFileWrite(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getFileWrite(); + { + std::ostringstream oss; + caller.call("fwrite", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "fwrite 1\n"); + } + { + std::ostringstream oss; + caller.call("fwrite", {}, -1, GET, oss); + REQUIRE(oss.str() == "fwrite 1\n"); + } + { + std::ostringstream oss; + caller.call("fwrite", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "fwrite 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setFileWrite(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("fwrite", {}, -1, GET)); } } TEST_CASE("Caller::fmaster", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getMasterFileWrite(); - { - std::ostringstream oss; - caller.call("fmaster", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "fmaster 0\n"); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getMasterFileWrite(); + { + std::ostringstream oss; + caller.call("fmaster", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "fmaster 0\n"); + } + { + std::ostringstream oss; + caller.call("fmaster", {}, -1, GET, oss); + REQUIRE(oss.str() == "fmaster 0\n"); + } + { + std::ostringstream oss; + caller.call("fmaster", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "fmaster 1\n"); + } + det.setMasterFileWrite(prev_val); + } else { + REQUIRE_THROWS(caller.call("fmaster", {}, -1, GET)); } - { - std::ostringstream oss; - caller.call("fmaster", {}, -1, GET, oss); - REQUIRE(oss.str() == "fmaster 0\n"); - } - { - std::ostringstream oss; - caller.call("fmaster", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "fmaster 1\n"); - } - det.setMasterFileWrite(prev_val); } TEST_CASE("Caller::foverwrite", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getFileOverWrite(); - { - std::ostringstream oss; - caller.call("foverwrite", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "foverwrite 1\n"); - } - { - std::ostringstream oss; - caller.call("foverwrite", {}, -1, GET, oss); - REQUIRE(oss.str() == "foverwrite 1\n"); - } - { - std::ostringstream oss; - caller.call("foverwrite", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "foverwrite 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFileOverWrite(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getFileOverWrite(); + { + std::ostringstream oss; + caller.call("foverwrite", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "foverwrite 1\n"); + } + { + std::ostringstream oss; + caller.call("foverwrite", {}, -1, GET, oss); + REQUIRE(oss.str() == "foverwrite 1\n"); + } + { + std::ostringstream oss; + caller.call("foverwrite", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "foverwrite 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setFileOverWrite(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("foverwrite", {}, -1, GET)); } } TEST_CASE("Caller::rx_framesperfile", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getFramesPerFile(); - { - std::ostringstream oss; - caller.call("rx_framesperfile", {"50"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_framesperfile 50\n"); - } - { - std::ostringstream oss; - caller.call("rx_framesperfile", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_framesperfile 50\n"); - } - { - std::ostringstream oss; - caller.call("rx_framesperfile", {"10000"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_framesperfile 10000\n"); - } - { - std::ostringstream oss; - caller.call("rx_framesperfile", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_framesperfile 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFramesPerFile(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getFramesPerFile(); + { + std::ostringstream oss; + caller.call("rx_framesperfile", {"50"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_framesperfile 50\n"); + } + { + std::ostringstream oss; + caller.call("rx_framesperfile", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_framesperfile 50\n"); + } + { + std::ostringstream oss; + caller.call("rx_framesperfile", {"10000"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_framesperfile 10000\n"); + } + { + std::ostringstream oss; + caller.call("rx_framesperfile", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_framesperfile 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setFramesPerFile(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_framesperfile", {}, -1, GET)); } } @@ -741,171 +883,202 @@ TEST_CASE("Caller::rx_framesperfile", "[.cmdcall][.rx]") { TEST_CASE("Caller::rx_zmqstream", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getRxZmqDataStream(); - { - std::ostringstream oss; - caller.call("rx_zmqstream", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqstream 1\n"); - REQUIRE(det.getRxZmqDataStream().squash() == true); - } - { - std::ostringstream oss; - caller.call("rx_zmqstream", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_zmqstream 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqstream", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqstream 0\n"); - REQUIRE(det.getRxZmqDataStream().squash() == false); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqDataStream(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getRxZmqDataStream(); + { + std::ostringstream oss; + caller.call("rx_zmqstream", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqstream 1\n"); + REQUIRE(det.getRxZmqDataStream().squash() == true); + } + { + std::ostringstream oss; + caller.call("rx_zmqstream", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_zmqstream 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqstream", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqstream 0\n"); + REQUIRE(det.getRxZmqDataStream().squash() == false); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqDataStream(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_zmqstream", {}, -1, GET)); } } TEST_CASE("Caller::rx_zmqfreq", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getRxZmqFrequency(); - { - std::ostringstream oss; - caller.call("rx_zmqfreq", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqfreq 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqfreq", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_zmqfreq 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqfreq", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqfreq 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqFrequency(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getRxZmqFrequency(); + { + std::ostringstream oss; + caller.call("rx_zmqfreq", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqfreq 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqfreq", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_zmqfreq 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqfreq", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqfreq 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqFrequency(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_zmqfreq", {}, -1, GET)); } } TEST_CASE("Caller::rx_zmqstartfnum", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getRxZmqStartingFrame(); - { - std::ostringstream oss; - caller.call("rx_zmqstartfnum", {"5"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqstartfnum 5\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqstartfnum", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_zmqstartfnum 5\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqstartfnum", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqstartfnum 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqStartingFrame(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getRxZmqStartingFrame(); + { + std::ostringstream oss; + caller.call("rx_zmqstartfnum", {"5"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqstartfnum 5\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqstartfnum", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_zmqstartfnum 5\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqstartfnum", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqstartfnum 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqStartingFrame(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_zmqstartfnum", {}, -1, GET)); + } } TEST_CASE("Caller::rx_zmqport", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val_zmqport = det.getRxZmqPort(); - auto prev_val_numinterfaces = det.getNumberofUDPInterfaces().tsquash( - "inconsistent number of udp interfaces to test"); - - int socketsperdetector = 1; auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { - socketsperdetector *= 2; - } else if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) { - caller.call("numinterfaces", {"2"}, -1, PUT); - socketsperdetector *= 2; - } - uint16_t port = 3500; - caller.call("rx_zmqport", {std::to_string(port)}, -1, PUT); - for (int i = 0; i != det.size(); ++i) { - std::ostringstream oss; - caller.call("rx_zmqport", {}, i, GET, oss); - REQUIRE(oss.str() == "rx_zmqport " + - std::to_string(port + i * socketsperdetector) + - '\n'); - } - port = 30001; - caller.call("rx_zmqport", {std::to_string(port)}, -1, PUT); - for (int i = 0; i != det.size(); ++i) { - std::ostringstream oss; - caller.call("rx_zmqport", {}, i, GET, oss); - REQUIRE(oss.str() == "rx_zmqport " + - std::to_string(port + i * socketsperdetector) + - '\n'); - } - test_valid_port_caller("rx_zmqport", {}, -1, PUT); - test_valid_port_caller("rx_zmqport", {}, 0, PUT); - // should fail for the second module - if (det.size() > 1) { - REQUIRE_THROWS(caller.call("rx_zmqport", {"65535"}, -1, PUT)); - } + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val_zmqport = det.getRxZmqPort(); + auto prev_val_numinterfaces = det.getNumberofUDPInterfaces().tsquash( + "inconsistent number of udp interfaces to test"); - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqPort(prev_val_zmqport[i], i); - } - if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) { - det.setNumberofUDPInterfaces(prev_val_numinterfaces); + int socketsperdetector = 1; + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + socketsperdetector *= 2; + } else if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) { + caller.call("numinterfaces", {"2"}, -1, PUT); + socketsperdetector *= 2; + } + uint16_t port = 3500; + caller.call("rx_zmqport", {std::to_string(port)}, -1, PUT); + for (int i = 0; i != det.size(); ++i) { + std::ostringstream oss; + caller.call("rx_zmqport", {}, i, GET, oss); + REQUIRE(oss.str() == "rx_zmqport " + + std::to_string(port + i * socketsperdetector) + + '\n'); + } + port = 30001; + caller.call("rx_zmqport", {std::to_string(port)}, -1, PUT); + for (int i = 0; i != det.size(); ++i) { + std::ostringstream oss; + caller.call("rx_zmqport", {}, i, GET, oss); + REQUIRE(oss.str() == "rx_zmqport " + + std::to_string(port + i * socketsperdetector) + + '\n'); + } + test_valid_port_caller("rx_zmqport", {}, -1, PUT); + test_valid_port_caller("rx_zmqport", {}, 0, PUT); + // should fail for the second module + if (det.size() > 1) { + REQUIRE_THROWS(caller.call("rx_zmqport", {"65535"}, -1, PUT)); + } + + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqPort(prev_val_zmqport[i], i); + } + if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) { + det.setNumberofUDPInterfaces(prev_val_numinterfaces); + } + } else { + REQUIRE_THROWS(caller.call("rx_zmqport", {}, -1, GET)); } } TEST_CASE("Caller::rx_zmqip", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getRxZmqIP(); - { - std::ostringstream oss; - caller.call("rx_zmqip", {"127.0.0.1"}, 0, PUT, oss); - REQUIRE(oss.str() == "rx_zmqip 127.0.0.1\n"); - std::cout << "ZMQIP: " << det.getRxZmqIP() << '\n'; - } - { - std::ostringstream oss; - caller.call("rx_zmqip", {}, 0, GET, oss); - REQUIRE(oss.str() == "rx_zmqip 127.0.0.1\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqIP(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getRxZmqIP(); + { + std::ostringstream oss; + caller.call("rx_zmqip", {"127.0.0.1"}, 0, PUT, oss); + REQUIRE(oss.str() == "rx_zmqip 127.0.0.1\n"); + std::cout << "ZMQIP: " << det.getRxZmqIP() << '\n'; + } + { + std::ostringstream oss; + caller.call("rx_zmqip", {}, 0, GET, oss); + REQUIRE(oss.str() == "rx_zmqip 127.0.0.1\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqIP(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_zmqip", {}, -1, GET)); } } TEST_CASE("Caller::rx_zmqhwm", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = - det.getRxZmqHwm().tsquash("Inconsistent values for rx_zmqhwm to test"); - { - std::ostringstream oss; - caller.call("rx_zmqhwm", {"50"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqhwm 50\n"); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = + det.getRxZmqHwm().tsquash("Inconsistent values for rx_zmqhwm to test"); + { + std::ostringstream oss; + caller.call("rx_zmqhwm", {"50"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqhwm 50\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqhwm", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_zmqhwm 50\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqhwm", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqhwm 0\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqhwm", {"-1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqhwm -1\n"); + } + det.setRxZmqHwm(prev_val); + } else { + REQUIRE_THROWS(caller.call("rx_zmqhwm", {}, -1, GET)); } - { - std::ostringstream oss; - caller.call("rx_zmqhwm", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_zmqhwm 50\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqhwm", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqhwm 0\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqhwm", {"-1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqhwm -1\n"); - } - det.setRxZmqHwm(prev_val); } /* CTB Specific */ @@ -976,56 +1149,66 @@ TEST_CASE("Caller::rx_dbitoffset", "[.cmdcall][.rx]") { TEST_CASE("Caller::rx_jsonaddheader", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getAdditionalJsonHeader(); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getAdditionalJsonHeader(); - { - std::ostringstream oss; - caller.call("rx_jsonaddheader", {"key1", "value1", "key2", "value2"}, - -1, PUT, oss); - REQUIRE(oss.str() == "rx_jsonaddheader {key1: value1, key2: value2}\n"); - } - { - std::ostringstream oss; - caller.call("rx_jsonaddheader", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_jsonaddheader {key1: value1, key2: value2}\n"); - } - { - std::ostringstream oss; - caller.call("rx_jsonaddheader", {}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_jsonaddheader {}\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setAdditionalJsonHeader(prev_val[i], {i}); + { + std::ostringstream oss; + caller.call("rx_jsonaddheader", {"key1", "value1", "key2", "value2"}, + -1, PUT, oss); + REQUIRE(oss.str() == "rx_jsonaddheader {key1: value1, key2: value2}\n"); + } + { + std::ostringstream oss; + caller.call("rx_jsonaddheader", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_jsonaddheader {key1: value1, key2: value2}\n"); + } + { + std::ostringstream oss; + caller.call("rx_jsonaddheader", {}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_jsonaddheader {}\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setAdditionalJsonHeader(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_jsonaddheader", {}, -1, GET)); } } TEST_CASE("Caller::rx_jsonpara", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto prev_val = det.getAdditionalJsonHeader(); - { - std::ostringstream oss; - caller.call("rx_jsonpara", {"key1", "value1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_jsonpara {key1: value1}\n"); - } - { - std::ostringstream oss; - caller.call("rx_jsonpara", {"key1", "value2"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_jsonpara {key1: value2}\n"); - } - { - std::ostringstream oss; - caller.call("rx_jsonpara", {"key1"}, -1, GET, oss); - REQUIRE(oss.str() == "rx_jsonpara value2\n"); - } - { - std::ostringstream oss; - caller.call("rx_jsonpara", {"key1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_jsonpara key1 deleted\n"); - } - REQUIRE_THROWS(caller.call("rx_jsonpara", {"key1"}, -1, GET)); - for (int i = 0; i != det.size(); ++i) { - det.setAdditionalJsonHeader(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getAdditionalJsonHeader(); + { + std::ostringstream oss; + caller.call("rx_jsonpara", {"key1", "value1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_jsonpara {key1: value1}\n"); + } + { + std::ostringstream oss; + caller.call("rx_jsonpara", {"key1", "value2"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_jsonpara {key1: value2}\n"); + } + { + std::ostringstream oss; + caller.call("rx_jsonpara", {"key1"}, -1, GET, oss); + REQUIRE(oss.str() == "rx_jsonpara value2\n"); + } + { + std::ostringstream oss; + caller.call("rx_jsonpara", {"key1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_jsonpara key1 deleted\n"); + } + REQUIRE_THROWS(caller.call("rx_jsonpara", {"key1"}, -1, GET)); + for (int i = 0; i != det.size(); ++i) { + det.setAdditionalJsonHeader(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("rx_jsonpara", {}, -1, GET)); } } diff --git a/slsDetectorSoftware/tests/Caller/test-Caller.cpp b/slsDetectorSoftware/tests/Caller/test-Caller.cpp index b764e7adb..e1a31e239 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller.cpp @@ -27,30 +27,6 @@ TEST_CASE("CALLER::Caller::Calling help doesn't throw or cause segfault") { caller.call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os)); } -TEST_CASE("CALLER::Caller::period", "[.cmdcall]") { - Detector det; - Caller caller(&det); - auto prev_val = det.getPeriod(); - { - std::ostringstream oss; - caller.call("period", {"1.25s"}, -1, PUT, oss); - REQUIRE(oss.str() == "period 1.25s\n"); - } - { - std::ostringstream oss; - caller.call("period", {}, -1, GET, oss); - REQUIRE(oss.str() == "period 1.25s\n"); - } - { - std::ostringstream oss; - caller.call("period", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "period 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setPeriod(prev_val[i], {i}); - } -} - TEST_CASE("CALLER::Unknown command", "[.cmdcall]") { Detector det; Caller caller(&det); @@ -111,8 +87,13 @@ TEST_CASE("CALLER::virtual", "[.cmdcall]") { TEST_CASE("CALLER::versions", "[.cmdcall]") { Detector det; Caller caller(&det); - REQUIRE_NOTHROW(caller.call("versions", {}, -1, GET)); - REQUIRE_THROWS(caller.call("versions", {"0"}, -1, PUT)); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + REQUIRE_NOTHROW(caller.call("versions", {}, -1, GET)); + REQUIRE_THROWS(caller.call("versions", {"0"}, -1, PUT)); + } else { + REQUIRE_THROWS(caller.call("versions", {}, -1, GET)); + } } TEST_CASE("CALLER::packageversion", "[.cmdcall]") { @@ -146,22 +127,32 @@ TEST_CASE("CALLER::detectorserverversion", "[.cmdcall]") { TEST_CASE("CALLER::hardwareversion", "[.cmdcall]") { Detector det; Caller caller(&det); - REQUIRE_NOTHROW(caller.call("hardwareversion", {}, -1, GET)); - REQUIRE_THROWS(caller.call("hardwareversion", {"0"}, -1, PUT)); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + REQUIRE_NOTHROW(caller.call("hardwareversion", {}, -1, GET)); + REQUIRE_THROWS(caller.call("hardwareversion", {"0"}, -1, PUT)); + } else { + REQUIRE_THROWS(caller.call("hardwareversion", {}, -1, GET)); + } } TEST_CASE("CALLER::kernelversion", "[.cmdcall]") { Detector det; Caller caller(&det); - REQUIRE_NOTHROW(caller.call("kernelversion", {}, -1, GET)); - REQUIRE_THROWS(caller.call("kernelversion", {"0"}, -1, PUT)); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + REQUIRE_NOTHROW(caller.call("kernelversion", {}, -1, GET)); + REQUIRE_THROWS(caller.call("kernelversion", {"0"}, -1, PUT)); + } else { + REQUIRE_THROWS(caller.call("kernelversion", {}, -1, GET)); + } } TEST_CASE("CALLER::serialnumber", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { + if (det_type == defs::EIGER || det_type == defs::XILINX_CHIPTESTBOARD) { REQUIRE_THROWS(caller.call("serialnumber", {}, -1, GET)); } else { REQUIRE_NOTHROW(caller.call("serialnumber", {}, -1, GET)); @@ -203,7 +194,7 @@ TEST_CASE("CALLER::settingslist", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { REQUIRE_THROWS(caller.call("settingslist", {}, -1, GET)); } else { REQUIRE_NOTHROW(caller.call("settingslist", {}, -1, GET)); @@ -848,73 +839,82 @@ TEST_CASE("CALLER::exptime", "[.cmdcall][.time]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - std::chrono::nanoseconds prev_val; - if (det_type != defs::MYTHEN3) { - prev_val = det.getExptime().tsquash("inconsistent exptime to test"); - } else { - auto t = - det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); - if (t[0] != t[1] || t[1] != t[2]) { - throw RuntimeError("inconsistent exptime for all gates"); - } - prev_val = t[0]; - } - { - std::ostringstream oss; - caller.call("exptime", {"0.05"}, -1, PUT, oss); - REQUIRE(oss.str() == "exptime 0.05\n"); - } - if (det_type != defs::MYTHEN3) { - std::ostringstream oss; - caller.call("exptime", {}, -1, GET, oss); - REQUIRE(oss.str() == "exptime 50ms\n"); - } - { - std::ostringstream oss; - caller.call("exptime", {"1s"}, -1, PUT, oss); - REQUIRE(oss.str() == "exptime 1s\n"); - } - if (det_type != defs::JUNGFRAU && det_type != defs::MOENCH) { - { - std::ostringstream oss; - caller.call("exptime", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "exptime 0\n"); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); + } else { + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; } { - // Get exptime of single module std::ostringstream oss; - caller.call("exptime", {}, 0, GET, oss); - if (det_type == defs::MYTHEN3) { - REQUIRE(oss.str() == "exptime [0ns, 0ns, 0ns]\n"); - } else { - REQUIRE(oss.str() == "exptime 0ns\n"); + caller.call("exptime", {"0.05"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime 0.05\n"); + } + if (det_type != defs::MYTHEN3) { + std::ostringstream oss; + caller.call("exptime", {}, -1, GET, oss); + REQUIRE(oss.str() == "exptime 50ms\n"); + } + { + std::ostringstream oss; + caller.call("exptime", {"1s"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime 1s\n"); + } + if (det_type != defs::JUNGFRAU && det_type != defs::MOENCH) { + { + std::ostringstream oss; + caller.call("exptime", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime 0\n"); + } + { + // Get exptime of single module + std::ostringstream oss; + caller.call("exptime", {}, 0, GET, oss); + if (det_type == defs::MYTHEN3) { + REQUIRE(oss.str() == "exptime [0ns, 0ns, 0ns]\n"); + } else { + REQUIRE(oss.str() == "exptime 0ns\n"); + } } } + det.setExptime(-1, prev_val); + } else { + REQUIRE_THROWS(caller.call("exptime", {}, -1, GET)); } - det.setExptime(-1, prev_val); } TEST_CASE("CALLER::period", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getPeriod(); - { - std::ostringstream oss; - caller.call("period", {"1.25s"}, -1, PUT, oss); - REQUIRE(oss.str() == "period 1.25s\n"); - } - { - std::ostringstream oss; - caller.call("period", {}, -1, GET, oss); - REQUIRE(oss.str() == "period 1.25s\n"); - } - { - std::ostringstream oss; - caller.call("period", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "period 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setPeriod(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getPeriod(); + { + std::ostringstream oss; + caller.call("period", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "period 1.25s\n"); + } + { + std::ostringstream oss; + caller.call("period", {}, -1, GET, oss); + REQUIRE(oss.str() == "period 1.25s\n"); + } + { + std::ostringstream oss; + caller.call("period", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "period 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPeriod(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("period", {}, -1, GET)); } } @@ -922,32 +922,36 @@ TEST_CASE("CALLER::delay", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { - REQUIRE_THROWS(caller.call("delay", {"1"}, -1, PUT)); - REQUIRE_THROWS(caller.call("delay", {}, -1, GET)); - } else if (det_type == defs::GOTTHARD) { - // extra delays for master (can throw when setting) - REQUIRE_NOTHROW(caller.call("delay", {}, -1, GET)); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + if (det_type == defs::EIGER) { + REQUIRE_THROWS(caller.call("delay", {"1"}, -1, PUT)); + REQUIRE_THROWS(caller.call("delay", {}, -1, GET)); + } else if (det_type == defs::GOTTHARD) { + // extra delays for master (can throw when setting) + REQUIRE_NOTHROW(caller.call("delay", {}, -1, GET)); + } else { + auto prev_val = det.getDelayAfterTrigger(); + { + std::ostringstream oss; + caller.call("delay", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "delay 1.25s\n"); + } + { + std::ostringstream oss; + caller.call("delay", {}, -1, GET, oss); + REQUIRE(oss.str() == "delay 1.25s\n"); + } + { + std::ostringstream oss; + caller.call("delay", {"0s"}, -1, PUT, oss); + REQUIRE(oss.str() == "delay 0s\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setDelayAfterTrigger(prev_val[i], {i}); + } + } } else { - auto prev_val = det.getDelayAfterTrigger(); - { - std::ostringstream oss; - caller.call("delay", {"1.25s"}, -1, PUT, oss); - REQUIRE(oss.str() == "delay 1.25s\n"); - } - { - std::ostringstream oss; - caller.call("delay", {}, -1, GET, oss); - REQUIRE(oss.str() == "delay 1.25s\n"); - } - { - std::ostringstream oss; - caller.call("delay", {"0s"}, -1, PUT, oss); - REQUIRE(oss.str() == "delay 0s\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setDelayAfterTrigger(prev_val[i], {i}); - } + REQUIRE_THROWS(caller.call("delay", {}, -1, GET)); } } @@ -955,7 +959,7 @@ TEST_CASE("CALLER::framesl", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { + if (det_type == defs::EIGER || det_type == defs::XILINX_CHIPTESTBOARD) { REQUIRE_THROWS(caller.call("framesl", {}, -1, GET)); } else { REQUIRE_NOTHROW(caller.call("framesl", {}, -1, GET)); @@ -966,7 +970,7 @@ TEST_CASE("CALLER::triggersl", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { + if (det_type == defs::EIGER || det_type == defs::XILINX_CHIPTESTBOARD) { REQUIRE_THROWS(caller.call("triggersl", {}, -1, GET)); } else { REQUIRE_NOTHROW(caller.call("triggersl", {}, -1, GET)); @@ -980,6 +984,7 @@ TEST_CASE("CALLER::delayl", "[.cmdcall]") { switch (det_type) { case defs::EIGER: case defs::CHIPTESTBOARD: + case defs::XILINX_CHIPTESTBOARD: case defs::GOTTHARD2: case defs::MYTHEN3: REQUIRE_THROWS(caller.call("delayl", {}, -1, GET)); @@ -997,6 +1002,7 @@ TEST_CASE("CALLER::periodl", "[.cmdcall]") { switch (det_type) { case defs::EIGER: case defs::CHIPTESTBOARD: + case defs::XILINX_CHIPTESTBOARD: case defs::GOTTHARD2: case defs::MYTHEN3: REQUIRE_THROWS(caller.call("periodl", {}, -1, GET)); @@ -1011,41 +1017,45 @@ TEST_CASE("CALLER::dr", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { - auto dr = det.getDynamicRange().squash(); - std::array vals{4, 8, 16, 32}; - for (const auto val : vals) { - std::ostringstream oss1, oss2; - caller.call("dr", {std::to_string(val)}, -1, PUT, oss1); - REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n'); - caller.call("dr", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n'); - } - det.setDynamicRange(dr); - } else if (det_type == defs::MYTHEN3) { - auto dr = det.getDynamicRange().squash(); - // not updated in firmware to support dr 1 - std::array vals{8, 16, 32}; - for (const auto val : vals) { - std::ostringstream oss1, oss2; - caller.call("dr", {std::to_string(val)}, -1, PUT, oss1); - REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n'); - caller.call("dr", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n'); - } - det.setDynamicRange(dr); - } else { - // For the other detectors we should get an error message - // except for dr 16 - REQUIRE_THROWS(caller.call("dr", {"4"}, -1, PUT)); - REQUIRE_THROWS(caller.call("dr", {"8"}, -1, PUT)); - REQUIRE_THROWS(caller.call("dr", {"32"}, -1, PUT)); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + if (det_type == defs::EIGER) { + auto dr = det.getDynamicRange().squash(); + std::array vals{4, 8, 16, 32}; + for (const auto val : vals) { + std::ostringstream oss1, oss2; + caller.call("dr", {std::to_string(val)}, -1, PUT, oss1); + REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n'); + caller.call("dr", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n'); + } + det.setDynamicRange(dr); + } else if (det_type == defs::MYTHEN3) { + auto dr = det.getDynamicRange().squash(); + // not updated in firmware to support dr 1 + std::array vals{8, 16, 32}; + for (const auto val : vals) { + std::ostringstream oss1, oss2; + caller.call("dr", {std::to_string(val)}, -1, PUT, oss1); + REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n'); + caller.call("dr", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n'); + } + det.setDynamicRange(dr); + } else { + // For the other detectors we should get an error message + // except for dr 16 + REQUIRE_THROWS(caller.call("dr", {"4"}, -1, PUT)); + REQUIRE_THROWS(caller.call("dr", {"8"}, -1, PUT)); + REQUIRE_THROWS(caller.call("dr", {"32"}, -1, PUT)); - std::ostringstream oss1, oss2; - caller.call("dr", {"16"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "dr 16\n"); - caller.call("dr", {"16"}, -1, PUT, oss2); - REQUIRE(oss2.str() == "dr 16\n"); + std::ostringstream oss1, oss2; + caller.call("dr", {"16"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "dr 16\n"); + caller.call("dr", {"16"}, -1, PUT, oss2); + REQUIRE(oss2.str() == "dr 16\n"); + } + } else { + REQUIRE_THROWS(caller.call("dr", {}, -1, GET)); } } @@ -1059,62 +1069,67 @@ TEST_CASE("CALLER::drlist", "[.cmdcall]") { TEST_CASE("CALLER::timing", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getTimingMode(); - det.setTimingMode(defs::AUTO_TIMING); - { - std::ostringstream oss1, oss2; - caller.call("timing", {"auto"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "timing auto\n"); - caller.call("timing", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "timing auto\n"); - } - { - std::ostringstream oss1, oss2; - caller.call("timing", {"trigger"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "timing trigger\n"); - caller.call("timing", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "timing trigger\n"); - } auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getTimingMode(); + det.setTimingMode(defs::AUTO_TIMING); { std::ostringstream oss1, oss2; - caller.call("timing", {"gating"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "timing gating\n"); + caller.call("timing", {"auto"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "timing auto\n"); caller.call("timing", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "timing gating\n"); + REQUIRE(oss2.str() == "timing auto\n"); } { std::ostringstream oss1, oss2; - caller.call("timing", {"burst_trigger"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "timing burst_trigger\n"); + caller.call("timing", {"trigger"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "timing trigger\n"); caller.call("timing", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "timing burst_trigger\n"); + REQUIRE(oss2.str() == "timing trigger\n"); } - REQUIRE_THROWS(caller.call("timing", {"trigger_gating"}, -1, PUT)); - } else if (det_type == defs::MYTHEN3) { - { - std::ostringstream oss1, oss2; - caller.call("timing", {"gating"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "timing gating\n"); - caller.call("timing", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "timing gating\n"); + if (det_type == defs::EIGER) { + { + std::ostringstream oss1, oss2; + caller.call("timing", {"gating"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "timing gating\n"); + caller.call("timing", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "timing gating\n"); + } + { + std::ostringstream oss1, oss2; + caller.call("timing", {"burst_trigger"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "timing burst_trigger\n"); + caller.call("timing", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "timing burst_trigger\n"); + } + REQUIRE_THROWS(caller.call("timing", {"trigger_gating"}, -1, PUT)); + } else if (det_type == defs::MYTHEN3) { + { + std::ostringstream oss1, oss2; + caller.call("timing", {"gating"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "timing gating\n"); + caller.call("timing", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "timing gating\n"); + } + { + std::ostringstream oss1, oss2; + caller.call("timing", {"trigger_gating"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "timing trigger_gating\n"); + caller.call("timing", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "timing trigger_gating\n"); + } + REQUIRE_THROWS(caller.call("timing", {"burst_trigger"}, -1, PUT)); + } else { + REQUIRE_THROWS(caller.call("timing", {"gating"}, -1, PUT)); + REQUIRE_THROWS(caller.call("timing", {"burst_trigger"}, -1, PUT)); + REQUIRE_THROWS(caller.call("timing", {"trigger_gating"}, -1, PUT)); } - { - std::ostringstream oss1, oss2; - caller.call("timing", {"trigger_gating"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "timing trigger_gating\n"); - caller.call("timing", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "timing trigger_gating\n"); + for (int i = 0; i != det.size(); ++i) { + det.setTimingMode(prev_val[i], {i}); } - REQUIRE_THROWS(caller.call("timing", {"burst_trigger"}, -1, PUT)); } else { - REQUIRE_THROWS(caller.call("timing", {"gating"}, -1, PUT)); - REQUIRE_THROWS(caller.call("timing", {"burst_trigger"}, -1, PUT)); - REQUIRE_THROWS(caller.call("timing", {"trigger_gating"}, -1, PUT)); - } - for (int i = 0; i != det.size(); ++i) { - det.setTimingMode(prev_val[i], {i}); + REQUIRE_THROWS(caller.call("timing", {}, -1, GET)); + } } @@ -1417,97 +1432,102 @@ TEST_CASE("CALLER::highvoltage", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - auto prev_val = det.getHighVoltage(); - // selected values - if (det_type == defs::GOTTHARD) { - REQUIRE_THROWS(caller.call("highvoltage", {"50"}, -1, PUT)); - { - std::ostringstream oss1, oss2; - caller.call("highvoltage", {"90"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "highvoltage 90\n"); - caller.call("highvoltage", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "highvoltage 90\n"); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getHighVoltage(); + // selected values + if (det_type == defs::GOTTHARD) { + REQUIRE_THROWS(caller.call("highvoltage", {"50"}, -1, PUT)); + { + std::ostringstream oss1, oss2; + caller.call("highvoltage", {"90"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "highvoltage 90\n"); + caller.call("highvoltage", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "highvoltage 90\n"); + } + { + std::ostringstream oss1, oss2; + caller.call("highvoltage", {"0"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "highvoltage 0\n"); + caller.call("highvoltage", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "highvoltage 0\n"); + } } - { - std::ostringstream oss1, oss2; - caller.call("highvoltage", {"0"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "highvoltage 0\n"); - caller.call("highvoltage", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "highvoltage 0\n"); + // range 0, 60 - 200 + else if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH || + det_type == defs::CHIPTESTBOARD) { + REQUIRE_THROWS(caller.call("highvoltage", {"50"}, -1, PUT)); + { + std::ostringstream oss1, oss2; + caller.call("highvoltage", {"90"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "highvoltage 90\n"); + caller.call("highvoltage", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "highvoltage 90\n"); + } + { + std::ostringstream oss1, oss2; + caller.call("highvoltage", {"0"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "highvoltage 0\n"); + caller.call("highvoltage", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "highvoltage 0\n"); + } } - } - // range 0, 60 - 200 - else if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH || - det_type == defs::CHIPTESTBOARD) { - REQUIRE_THROWS(caller.call("highvoltage", {"50"}, -1, PUT)); - { - std::ostringstream oss1, oss2; - caller.call("highvoltage", {"90"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "highvoltage 90\n"); - caller.call("highvoltage", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "highvoltage 90\n"); + // full range 0 - 200 (get needs to wait) + else if (det_type == defs::EIGER) { + { + std::ostringstream oss1, oss2; + caller.call("highvoltage", {"50"}, 0, PUT, oss1); + REQUIRE(oss1.str() == "highvoltage 50\n"); + std::this_thread::sleep_for(std::chrono::seconds(2)); + caller.call("highvoltage", {}, 0, GET, oss2); + REQUIRE(oss2.str() == "highvoltage 50\n"); + } + { + std::ostringstream oss1, oss2; + caller.call("highvoltage", {"120"}, 0, PUT, oss1); + REQUIRE(oss1.str() == "highvoltage 120\n"); + std::this_thread::sleep_for(std::chrono::seconds(2)); + caller.call("highvoltage", {}, 0, GET, oss2); + REQUIRE(oss2.str() == "highvoltage 120\n"); + } + { + std::ostringstream oss1, oss2; + caller.call("highvoltage", {"0"}, 0, PUT, oss1); + REQUIRE(oss1.str() == "highvoltage 0\n"); + std::this_thread::sleep_for(std::chrono::seconds(2)); + caller.call("highvoltage", {}, 0, GET, oss2); + REQUIRE(oss2.str() == "highvoltage 0\n"); + } } - { - std::ostringstream oss1, oss2; - caller.call("highvoltage", {"0"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "highvoltage 0\n"); - caller.call("highvoltage", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "highvoltage 0\n"); + // full range 0 - 200 + else { + { + std::ostringstream oss1, oss2; + caller.call("highvoltage", {"50"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "highvoltage 50\n"); + caller.call("highvoltage", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "highvoltage 50\n"); + } + { + std::ostringstream oss1, oss2; + caller.call("highvoltage", {"120"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "highvoltage 120\n"); + caller.call("highvoltage", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "highvoltage 120\n"); + } + { + std::ostringstream oss1, oss2; + caller.call("highvoltage", {"0"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "highvoltage 0\n"); + caller.call("highvoltage", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "highvoltage 0\n"); + } } - } - // full range 0 - 200 (get needs to wait) - else if (det_type == defs::EIGER) { - { - std::ostringstream oss1, oss2; - caller.call("highvoltage", {"50"}, 0, PUT, oss1); - REQUIRE(oss1.str() == "highvoltage 50\n"); - std::this_thread::sleep_for(std::chrono::seconds(2)); - caller.call("highvoltage", {}, 0, GET, oss2); - REQUIRE(oss2.str() == "highvoltage 50\n"); + for (int i = 0; i != det.size(); ++i) { + det.setHighVoltage(prev_val[i], {i}); } - { - std::ostringstream oss1, oss2; - caller.call("highvoltage", {"120"}, 0, PUT, oss1); - REQUIRE(oss1.str() == "highvoltage 120\n"); - std::this_thread::sleep_for(std::chrono::seconds(2)); - caller.call("highvoltage", {}, 0, GET, oss2); - REQUIRE(oss2.str() == "highvoltage 120\n"); - } - { - std::ostringstream oss1, oss2; - caller.call("highvoltage", {"0"}, 0, PUT, oss1); - REQUIRE(oss1.str() == "highvoltage 0\n"); - std::this_thread::sleep_for(std::chrono::seconds(2)); - caller.call("highvoltage", {}, 0, GET, oss2); - REQUIRE(oss2.str() == "highvoltage 0\n"); - } - } - // full range 0 - 200 - else { - { - std::ostringstream oss1, oss2; - caller.call("highvoltage", {"50"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "highvoltage 50\n"); - caller.call("highvoltage", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "highvoltage 50\n"); - } - { - std::ostringstream oss1, oss2; - caller.call("highvoltage", {"120"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "highvoltage 120\n"); - caller.call("highvoltage", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "highvoltage 120\n"); - } - { - std::ostringstream oss1, oss2; - caller.call("highvoltage", {"0"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "highvoltage 0\n"); - caller.call("highvoltage", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "highvoltage 0\n"); - } - } - for (int i = 0; i != det.size(); ++i) { - det.setHighVoltage(prev_val[i], {i}); + } else { + REQUIRE_THROWS(caller.call("highvoltage", {"0"}, -1, PUT)); + REQUIRE_THROWS(caller.call("highvoltage", {}, -1, GET)); } } @@ -2005,7 +2025,7 @@ TEST_CASE("CALLER::temp_fpga", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::CHIPTESTBOARD) { + if (det_type != defs::CHIPTESTBOARD && det_type != defs::XILINX_CHIPTESTBOARD) { REQUIRE_NOTHROW(caller.call("temp_fpga", {}, -1, GET)); std::ostringstream oss; REQUIRE_NOTHROW(caller.call("temp_fpga", {}, 0, GET, oss)); @@ -2056,15 +2076,21 @@ TEST_CASE("CALLER::daclist", "[.cmdcall]") { TEST_CASE("CALLER::dacvalues", "[.cmdcall]") { Detector det; Caller caller(&det); - REQUIRE_NOTHROW(caller.call("dacvalues", {}, -1, GET)); - REQUIRE_THROWS(caller.call("dacvalues", {}, -1, PUT)); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + REQUIRE_NOTHROW(caller.call("dacvalues", {}, -1, GET)); + REQUIRE_THROWS(caller.call("dacvalues", {}, -1, PUT)); + } else { + REQUIRE_THROWS(caller.call("dacvalues", {}, -1, GET)); + + } } TEST_CASE("CALLER::defaultdac", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::CHIPTESTBOARD) { + if (det_type != defs::CHIPTESTBOARD && det_type != defs::XILINX_CHIPTESTBOARD) { REQUIRE_THROWS(caller.call("defaultdac", {}, -1, GET)); REQUIRE_THROWS(caller.call("defaultdac", {"blabla"}, -1, PUT)); auto daclist = det.getDacList(); @@ -2123,7 +2149,7 @@ TEST_CASE("CALLER::resetdacs", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::CHIPTESTBOARD) { + if (det_type != defs::CHIPTESTBOARD && det_type != defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getSettings(); REQUIRE_THROWS(caller.call("resetdacs", {}, -1, GET)); @@ -2241,124 +2267,138 @@ TEST_CASE("CALLER::clearbusy", "[.cmdcall]") { TEST_CASE("CALLER::start", "[.cmdcall]") { Detector det; Caller caller(&det); - // PUT only command - REQUIRE_THROWS(caller.call("start", {}, -1, GET)); auto det_type = det.getDetectorType().squash(); - std::chrono::nanoseconds prev_val; - if (det_type != defs::MYTHEN3) { - prev_val = det.getExptime().tsquash("inconsistent exptime to test"); - } else { - auto t = - det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); - if (t[0] != t[1] || t[1] != t[2]) { - throw RuntimeError("inconsistent exptime for all gates"); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + // PUT only command + REQUIRE_THROWS(caller.call("start", {}, -1, GET)); + auto det_type = det.getDetectorType().squash(); + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); + } else { + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; } - prev_val = t[0]; + auto prev_frames = + det.getNumberOfFrames().tsquash("inconsistent #frames in test"); + auto prev_period = det.getPeriod().tsquash("inconsistent period in test"); + det.setExptime(-1, std::chrono::microseconds(200)); + det.setPeriod(std::chrono::milliseconds(1)); + det.setNumberOfFrames(2000); + { + std::ostringstream oss; + caller.call("start", {}, -1, PUT, oss); + REQUIRE(oss.str() == "start successful\n"); + } + if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { + std::ostringstream oss; + caller.call("status", {}, -1, GET, oss); + REQUIRE(oss.str() == "status running\n"); + } + det.stopDetector(); + det.setExptime(-1, prev_val); + det.setPeriod(prev_period); + det.setNumberOfFrames(prev_frames); + } else { + REQUIRE_THROWS(caller.call("start", {}, -1, GET)); } - auto prev_frames = - det.getNumberOfFrames().tsquash("inconsistent #frames in test"); - auto prev_period = det.getPeriod().tsquash("inconsistent period in test"); - det.setExptime(-1, std::chrono::microseconds(200)); - det.setPeriod(std::chrono::milliseconds(1)); - det.setNumberOfFrames(2000); - { - std::ostringstream oss; - caller.call("start", {}, -1, PUT, oss); - REQUIRE(oss.str() == "start successful\n"); - } - if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { - std::ostringstream oss; - caller.call("status", {}, -1, GET, oss); - REQUIRE(oss.str() == "status running\n"); - } - det.stopDetector(); - det.setExptime(-1, prev_val); - det.setPeriod(prev_period); - det.setNumberOfFrames(prev_frames); } TEST_CASE("CALLER::stop", "[.cmdcall]") { Detector det; Caller caller(&det); - // PUT only command - REQUIRE_THROWS(caller.call("stop", {}, -1, GET)); auto det_type = det.getDetectorType().squash(); - std::chrono::nanoseconds prev_val; - if (det_type != defs::MYTHEN3) { - prev_val = det.getExptime().tsquash("inconsistent exptime to test"); - } else { - auto t = - det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); - if (t[0] != t[1] || t[1] != t[2]) { - throw RuntimeError("inconsistent exptime for all gates"); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + // PUT only command + REQUIRE_THROWS(caller.call("stop", {}, -1, GET)); + auto det_type = det.getDetectorType().squash(); + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); + } else { + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; } - prev_val = t[0]; + auto prev_frames = + det.getNumberOfFrames().tsquash("inconsistent #frames in test"); + auto prev_period = det.getPeriod().tsquash("inconsistent period in test"); + det.setExptime(-1, std::chrono::microseconds(200)); + det.setPeriod(std::chrono::milliseconds(1)); + det.setNumberOfFrames(2000); + det.startDetector(); + if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { + std::ostringstream oss; + caller.call("status", {}, -1, GET, oss); + REQUIRE(oss.str() == "status running\n"); + } + { + std::ostringstream oss; + caller.call("stop", {}, -1, PUT, oss); + REQUIRE(oss.str() == "stop successful\n"); + } + { + std::ostringstream oss; + caller.call("status", {}, -1, GET, oss); + REQUIRE(((oss.str() == "status stopped\n") || + (oss.str() == "status idle\n"))); + } + det.setExptime(-1, prev_val); + det.setPeriod(prev_period); + det.setNumberOfFrames(prev_frames); + } else { + REQUIRE_THROWS(caller.call("stop", {}, -1, GET)); } - auto prev_frames = - det.getNumberOfFrames().tsquash("inconsistent #frames in test"); - auto prev_period = det.getPeriod().tsquash("inconsistent period in test"); - det.setExptime(-1, std::chrono::microseconds(200)); - det.setPeriod(std::chrono::milliseconds(1)); - det.setNumberOfFrames(2000); - det.startDetector(); - if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { - std::ostringstream oss; - caller.call("status", {}, -1, GET, oss); - REQUIRE(oss.str() == "status running\n"); - } - { - std::ostringstream oss; - caller.call("stop", {}, -1, PUT, oss); - REQUIRE(oss.str() == "stop successful\n"); - } - { - std::ostringstream oss; - caller.call("status", {}, -1, GET, oss); - REQUIRE(((oss.str() == "status stopped\n") || - (oss.str() == "status idle\n"))); - } - det.setExptime(-1, prev_val); - det.setPeriod(prev_period); - det.setNumberOfFrames(prev_frames); } TEST_CASE("CALLER::status", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - std::chrono::nanoseconds prev_val; - if (det_type != defs::MYTHEN3) { - prev_val = det.getExptime().tsquash("inconsistent exptime to test"); - } else { - auto t = - det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); - if (t[0] != t[1] || t[1] != t[2]) { - throw RuntimeError("inconsistent exptime for all gates"); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); + } else { + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; } - prev_val = t[0]; + auto prev_frames = + det.getNumberOfFrames().tsquash("inconsistent #frames in test"); + auto prev_period = det.getPeriod().tsquash("inconsistent period in test"); + det.setExptime(-1, std::chrono::microseconds(200)); + det.setPeriod(std::chrono::milliseconds(1)); + det.setNumberOfFrames(2000); + det.startDetector(); + if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { + std::ostringstream oss; + caller.call("status", {}, -1, GET, oss); + REQUIRE(oss.str() == "status running\n"); + } + det.stopDetector(); + { + std::ostringstream oss; + caller.call("status", {}, -1, GET, oss); + REQUIRE(((oss.str() == "status stopped\n") || + (oss.str() == "status idle\n"))); + } + det.setExptime(-1, prev_val); + det.setPeriod(prev_period); + det.setNumberOfFrames(prev_frames); + } else { + REQUIRE_THROWS(caller.call("status", {}, -1, GET)); } - auto prev_frames = - det.getNumberOfFrames().tsquash("inconsistent #frames in test"); - auto prev_period = det.getPeriod().tsquash("inconsistent period in test"); - det.setExptime(-1, std::chrono::microseconds(200)); - det.setPeriod(std::chrono::milliseconds(1)); - det.setNumberOfFrames(2000); - det.startDetector(); - if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { - std::ostringstream oss; - caller.call("status", {}, -1, GET, oss); - REQUIRE(oss.str() == "status running\n"); - } - det.stopDetector(); - { - std::ostringstream oss; - caller.call("status", {}, -1, GET, oss); - REQUIRE(((oss.str() == "status stopped\n") || - (oss.str() == "status idle\n"))); - } - det.setExptime(-1, prev_val); - det.setPeriod(prev_period); - det.setNumberOfFrames(prev_frames); } TEST_CASE("CALLER::nextframenumber", "[.cmdcall]") { @@ -2433,126 +2473,130 @@ TEST_CASE("CALLER::scan", "[.cmdcall]") { defs::dacIndex ind = defs::DAC_0; defs::dacIndex notImplementedInd = defs::DAC_0; auto det_type = det.getDetectorType().squash(); - switch (det_type) { - case defs::CHIPTESTBOARD: - ind = defs::DAC_0; - notImplementedInd = defs::VSVP; - break; - case defs::EIGER: - ind = defs::VCMP_LL; - notImplementedInd = defs::VCASCP_PB; - break; - case defs::JUNGFRAU: - ind = defs::VB_COMP; - notImplementedInd = defs::VSVP; - break; - case defs::MOENCH: - ind = defs::VIN_CM; - notImplementedInd = defs::VSVP; - break; - case defs::GOTTHARD: - ind = defs::VREF_DS; - notImplementedInd = defs::VSVP; - break; - case defs::GOTTHARD2: - ind = defs::VB_COMP_FE; - notImplementedInd = defs::VSVP; - break; - case defs::MYTHEN3: - ind = defs::VTH2; - notImplementedInd = defs::VSVP; - break; - default: - break; - } + if (det_type != defs::XILINX_CHIPTESTBOARD) { + switch (det_type) { + case defs::CHIPTESTBOARD: + ind = defs::DAC_0; + notImplementedInd = defs::VSVP; + break; + case defs::EIGER: + ind = defs::VCMP_LL; + notImplementedInd = defs::VCASCP_PB; + break; + case defs::JUNGFRAU: + ind = defs::VB_COMP; + notImplementedInd = defs::VSVP; + break; + case defs::MOENCH: + ind = defs::VIN_CM; + notImplementedInd = defs::VSVP; + break; + case defs::GOTTHARD: + ind = defs::VREF_DS; + notImplementedInd = defs::VSVP; + break; + case defs::GOTTHARD2: + ind = defs::VB_COMP_FE; + notImplementedInd = defs::VSVP; + break; + case defs::MYTHEN3: + ind = defs::VTH2; + notImplementedInd = defs::VSVP; + break; + default: + break; + } - // when taking acquisition - // auto previous = det.getDAC(ind, false); - // auto notImplementedPrevious = det.getDAC(notImplementedInd, false); + // when taking acquisition + // auto previous = det.getDAC(ind, false); + // auto notImplementedPrevious = det.getDAC(notImplementedInd, false); - if (det_type == defs::MYTHEN3 && det.size() > 1) { - ; // scan only allowed for single module due to sync - } else { - { - std::ostringstream oss; - caller.call("scan", {ToString(ind), "500", "1500", "500"}, -1, PUT, - oss); - CHECK(oss.str() == - "scan [" + ToString(ind) + ", 500, 1500, 500]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {}, -1, GET, oss); - CHECK(oss.str() == "scan [enabled\ndac " + ToString(ind) + - "\nstart 500\nstop 1500\nstep " - "500\nsettleTime 1ms\n]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {ToString(ind), "500", "1500", "500", "2s"}, -1, - PUT, oss); - CHECK(oss.str() == - "scan [" + ToString(ind) + ", 500, 1500, 500, 2s]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {}, -1, GET, oss); - CHECK(oss.str() == "scan [enabled\ndac " + ToString(ind) + - "\nstart 500\nstop 1500\nstep " - "500\nsettleTime 2s\n]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {"0"}, -1, PUT, oss); - CHECK(oss.str() == "scan [0]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {}, -1, GET, oss); - CHECK(oss.str() == "scan [disabled]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {ToString(ind), "1500", "500", "-500"}, -1, PUT, - oss); - CHECK(oss.str() == - "scan [" + ToString(ind) + ", 1500, 500, -500]\n"); - } - CHECK_THROWS(caller.call( - "scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1, - PUT)); - CHECK_THROWS(caller.call("scan", {ToString(ind), "500", "1500", "-500"}, - -1, PUT)); - CHECK_THROWS(caller.call("scan", {ToString(ind), "1500", "500", "500"}, - -1, PUT)); - - if (det_type == defs::MYTHEN3 || defs::EIGER) { + if (det_type == defs::MYTHEN3 && det.size() > 1) { + ; // scan only allowed for single module due to sync + } else { { std::ostringstream oss; - caller.call("scan", {"trimbits", "0", "63", "16", "2s"}, -1, - PUT, oss); - CHECK(oss.str() == "scan [trimbits, 0, 63, 16, 2s]\n"); + caller.call("scan", {ToString(ind), "500", "1500", "500"}, -1, PUT, + oss); + CHECK(oss.str() == + "scan [" + ToString(ind) + ", 500, 1500, 500]\n"); } { std::ostringstream oss; caller.call("scan", {}, -1, GET, oss); - CHECK(oss.str() == - "scan [enabled\ndac trimbits\nstart 0\nstop 48\nstep " - "16\nsettleTime 2s\n]\n"); + CHECK(oss.str() == "scan [enabled\ndac " + ToString(ind) + + "\nstart 500\nstop 1500\nstep " + "500\nsettleTime 1ms\n]\n"); } + { + std::ostringstream oss; + caller.call("scan", {ToString(ind), "500", "1500", "500", "2s"}, -1, + PUT, oss); + CHECK(oss.str() == + "scan [" + ToString(ind) + ", 500, 1500, 500, 2s]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {}, -1, GET, oss); + CHECK(oss.str() == "scan [enabled\ndac " + ToString(ind) + + "\nstart 500\nstop 1500\nstep " + "500\nsettleTime 2s\n]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {"0"}, -1, PUT, oss); + CHECK(oss.str() == "scan [0]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {}, -1, GET, oss); + CHECK(oss.str() == "scan [disabled]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {ToString(ind), "1500", "500", "-500"}, -1, PUT, + oss); + CHECK(oss.str() == + "scan [" + ToString(ind) + ", 1500, 500, -500]\n"); + } + CHECK_THROWS(caller.call( + "scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1, + PUT)); + CHECK_THROWS(caller.call("scan", {ToString(ind), "500", "1500", "-500"}, + -1, PUT)); + CHECK_THROWS(caller.call("scan", {ToString(ind), "1500", "500", "500"}, + -1, PUT)); + + if (det_type == defs::MYTHEN3 || defs::EIGER) { + { + std::ostringstream oss; + caller.call("scan", {"trimbits", "0", "63", "16", "2s"}, -1, + PUT, oss); + CHECK(oss.str() == "scan [trimbits, 0, 63, 16, 2s]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {}, -1, GET, oss); + CHECK(oss.str() == + "scan [enabled\ndac trimbits\nstart 0\nstop 48\nstep " + "16\nsettleTime 2s\n]\n"); + } + } + + // Switch off scan for future tests + det.setScan(defs::scanParameters()); + // acquire for each? + + // when taking acquisition + // Reset all dacs to previous value + // for (int i = 0; i != det.size(); ++i) { + // det.setDAC(ind, previous[i], false, {i}); + // det.setDAC(notImplementedInd, notImplementedPrevious[i], false, + // {i}); + // } } - - // Switch off scan for future tests - det.setScan(defs::scanParameters()); - // acquire for each? - - // when taking acquisition - // Reset all dacs to previous value - // for (int i = 0; i != det.size(); ++i) { - // det.setDAC(ind, previous[i], false, {i}); - // det.setDAC(notImplementedInd, notImplementedPrevious[i], false, - // {i}); - // } + } else { + REQUIRE_THROWS(caller.call("scan", {ToString(defs::DAC_0), "500", "1500", "500"}, -1, PUT)); } } @@ -2608,15 +2652,20 @@ TEST_CASE("CALLER::numinterfaces", "[.cmdcall]") { TEST_CASE("CALLER::udp_srcip", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getSourceUDPIP(); - REQUIRE_THROWS(caller.call("udp_srcip", {"0.0.0.0"}, -1, PUT)); - { - std::ostringstream oss; - caller.call("udp_srcip", {"129.129.205.12"}, -1, PUT, oss); - REQUIRE(oss.str() == "udp_srcip 129.129.205.12\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setSourceUDPIP(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getSourceUDPIP(); + REQUIRE_THROWS(caller.call("udp_srcip", {"0.0.0.0"}, -1, PUT)); + { + std::ostringstream oss; + caller.call("udp_srcip", {"129.129.205.12"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_srcip 129.129.205.12\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setSourceUDPIP(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("udp_srcip", {}, -1, GET)); } } @@ -2652,9 +2701,15 @@ TEST_CASE("CALLER::udp_numdst", "[.cmdcall]") { TEST_CASE("CALLER::udp_cleardst", "[.cmdcall]") { Detector det; Caller caller(&det); - REQUIRE_THROWS(caller.call("udp_cleardst", {}, -1, GET)); - /* dont clear all udp destinations */ - /*REQUIRE_NOTHROW(caller.call("udp_cleardst", {}, -1, PUT));*/ + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + REQUIRE_THROWS(caller.call("udp_cleardst", {}, -1, GET)); + /* dont clear all udp destinations */ + /*REQUIRE_NOTHROW(caller.call("udp_cleardst", {}, -1, PUT));*/ + } else { + REQUIRE_THROWS(caller.call("udp_cleardst", {}, -1, PUT)); + + } } TEST_CASE("CALLER::udp_firstdst", "[.cmdcall]") { @@ -2700,17 +2755,22 @@ TEST_CASE("CALLER::udp_dstip", "[.cmdcall]") { TEST_CASE("CALLER::udp_srcmac", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getSourceUDPMAC(); - REQUIRE_THROWS(caller.call("udp_srcmac", {"00:00:00:00:00:00"}, -1, PUT)); - { - std::ostringstream oss; - caller.call("udp_srcmac", {"00:50:c2:42:34:12"}, -1, PUT, oss); - REQUIRE(oss.str() == "udp_srcmac 00:50:c2:42:34:12\n"); - } - for (int i = 0; i != det.size(); ++i) { - if (prev_val[i].str() != "00:00:00:00:00:00") { - det.setSourceUDPMAC(prev_val[i], {i}); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getSourceUDPMAC(); + REQUIRE_THROWS(caller.call("udp_srcmac", {"00:00:00:00:00:00"}, -1, PUT)); + { + std::ostringstream oss; + caller.call("udp_srcmac", {"00:50:c2:42:34:12"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_srcmac 00:50:c2:42:34:12\n"); } + for (int i = 0; i != det.size(); ++i) { + if (prev_val[i].str() != "00:00:00:00:00:00") { + det.setSourceUDPMAC(prev_val[i], {i}); + } + } + } else { + REQUIRE_THROWS(caller.call("udp_srcmac", {}, -1, GET)); } } @@ -2723,21 +2783,26 @@ TEST_CASE("CALLER::udp_dstmac", "[.cmdcall]") { TEST_CASE("CALLER::udp_dstport", "[.cmdcall]") { Detector det; Caller caller(&det); - auto prev_val = det.getDestinationUDPPort(); - { - std::ostringstream oss; - caller.call("udp_dstport", {"50084"}, -1, PUT, oss); - REQUIRE(oss.str() == "udp_dstport 50084\n"); - } - test_valid_port_caller("udp_dstport", {}, -1, PUT); - test_valid_port_caller("udp_dstport", {}, 0, PUT); - // should fail for the second module - if (det.size() > 1) { - REQUIRE_THROWS(caller.call("udp_dstport", {"65535"}, -1, PUT)); - } + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getDestinationUDPPort(); + { + std::ostringstream oss; + caller.call("udp_dstport", {"50084"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_dstport 50084\n"); + } + test_valid_port_caller("udp_dstport", {}, -1, PUT); + test_valid_port_caller("udp_dstport", {}, 0, PUT); + // should fail for the second module + if (det.size() > 1) { + REQUIRE_THROWS(caller.call("udp_dstport", {"65535"}, -1, PUT)); + } - for (int i = 0; i != det.size(); ++i) { - det.setDestinationUDPPort(prev_val[i], {i}); + for (int i = 0; i != det.size(); ++i) { + det.setDestinationUDPPort(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(caller.call("udp_dstport", {}, -1, GET)); } } @@ -2844,15 +2909,26 @@ TEST_CASE("CALLER::udp_dstport2", "[.cmdcall]") { TEST_CASE("CALLER::udp_reconfigure", "[.cmdcall]") { Detector det; Caller caller(&det); - REQUIRE_THROWS(caller.call("udp_reconfigure", {}, -1, GET)); - REQUIRE_NOTHROW(caller.call("udp_reconfigure", {}, -1, PUT)); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + REQUIRE_THROWS(caller.call("udp_reconfigure", {}, -1, GET)); + REQUIRE_NOTHROW(caller.call("udp_reconfigure", {}, -1, PUT)); + } else { + REQUIRE_THROWS(caller.call("udp_reconfigure", {}, -1, PUT)); + } } TEST_CASE("CALLER::udp_validate", "[.cmdcall]") { Detector det; Caller caller(&det); - REQUIRE_THROWS(caller.call("udp_validate", {}, -1, GET)); - REQUIRE_NOTHROW(caller.call("udp_validate", {}, -1, PUT)); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + REQUIRE_THROWS(caller.call("udp_validate", {}, -1, GET)); + REQUIRE_NOTHROW(caller.call("udp_validate", {}, -1, PUT)); + } else { + REQUIRE_THROWS(caller.call("udp_validate", {}, -1, PUT)); + + } } TEST_CASE("CALLER::tengiga", "[.cmdcall]") { @@ -3072,16 +3148,19 @@ TEST_CASE("CALLER::zmqport", "[.cmdcall]") { TEST_CASE("CALLER::zmqip", "[.cmdcall]") { Detector det; Caller caller(&det); - std::ostringstream oss1, oss2; - auto zmqip = det.getClientZmqIp(); - caller.call("zmqip", {}, 0, GET, oss1); - REQUIRE(oss1.str() == "zmqip " + zmqip[0].str() + '\n'); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + std::ostringstream oss1, oss2; + auto zmqip = det.getClientZmqIp(); + caller.call("zmqip", {}, 0, GET, oss1); + REQUIRE(oss1.str() == "zmqip " + zmqip[0].str() + '\n'); - caller.call("zmqip", {zmqip[0].str()}, 0, PUT, oss2); - REQUIRE(oss2.str() == "zmqip " + zmqip[0].str() + '\n'); + caller.call("zmqip", {zmqip[0].str()}, 0, PUT, oss2); + REQUIRE(oss2.str() == "zmqip " + zmqip[0].str() + '\n'); - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqIP(zmqip[i], {i}); + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqIP(zmqip[i], {i}); + } } } @@ -3238,24 +3317,28 @@ TEST_CASE("CALLER::reg", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::EIGER) { - uint32_t addr = 0x64; - std::string saddr = ToStringHex(addr); - auto prev_val = det.readRegister(addr); - { - std::ostringstream oss1, oss2; - caller.call("reg", {saddr, "0x5"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "reg [" + saddr + ", 0x5]\n"); - caller.call("reg", {saddr}, -1, GET, oss2); - REQUIRE(oss2.str() == "reg 0x5\n"); + if (det_type != defs::XILINX_CHIPTESTBOARD) { + if (det_type != defs::EIGER) { + uint32_t addr = 0x64; + std::string saddr = ToStringHex(addr); + auto prev_val = det.readRegister(addr); + { + std::ostringstream oss1, oss2; + caller.call("reg", {saddr, "0x5"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "reg [" + saddr + ", 0x5]\n"); + caller.call("reg", {saddr}, -1, GET, oss2); + REQUIRE(oss2.str() == "reg 0x5\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.writeRegister(addr, prev_val[i], {i}); + } } - for (int i = 0; i != det.size(); ++i) { - det.writeRegister(addr, prev_val[i], {i}); + // cannot check for eiger virtual server + else { + REQUIRE_NOTHROW(caller.call("reg", {"0x64"}, -1, GET)); } - } - // cannot check for eiger virtual server - else { - REQUIRE_NOTHROW(caller.call("reg", {"0x64"}, -1, GET)); + } else { + REQUIRE_THROWS(caller.call("reg", {}, -1, GET)); } } @@ -3281,7 +3364,7 @@ TEST_CASE("CALLER::setbit", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::EIGER) { + if (det_type != defs::EIGER && det_type != defs::XILINX_CHIPTESTBOARD) { uint32_t addr = 0x64; std::string saddr = ToStringHex(addr); auto prev_val = det.readRegister(addr); @@ -3303,7 +3386,7 @@ TEST_CASE("CALLER::clearbit", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::EIGER) { + if (det_type != defs::EIGER && det_type != defs::XILINX_CHIPTESTBOARD) { uint32_t addr = 0x64; std::string saddr = ToStringHex(addr); auto prev_val = det.readRegister(addr); @@ -3325,7 +3408,9 @@ TEST_CASE("CALLER::getbit", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::EIGER) { + if (det_type == defs::XILINX_CHIPTESTBOARD) { + REQUIRE_THROWS(caller.call("getbit", {"0x64", "1"}, -1, GET)); + } else if (det_type != defs::EIGER) { uint32_t addr = 0x64; std::string saddr = ToStringHex(addr); auto prev_val = det.readRegister(addr); diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index fbb726e37..f14a99937 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -4,11 +4,11 @@ #define RELEASE "developer" #define APILIB "developer 0x230224" #define APIRECEIVER "developer 0x230224" -#define APIXILINXCTB "developer 0x240104" -#define APICTB "developer 0x240104" -#define APIGOTTHARD "developer 0x240104" -#define APIGOTTHARD2 "developer 0x240104" -#define APIJUNGFRAU "developer 0x240104" -#define APIMYTHEN3 "developer 0x240104" -#define APIMOENCH "developer 0x240104" -#define APIEIGER "developer 0x240104" +#define APIXILINXCTB "developer 0x240109" +#define APICTB "developer 0x240109" +#define APIGOTTHARD "developer 0x240109" +#define APIGOTTHARD2 "developer 0x240109" +#define APIJUNGFRAU "developer 0x240109" +#define APIMYTHEN3 "developer 0x240109" +#define APIMOENCH "developer 0x240109" +#define APIEIGER "developer 0x240109" diff --git a/tests/scripts/test_simulators.py b/tests/scripts/test_simulators.py index 2a40ba1a3..1d26c96e7 100644 --- a/tests/scripts/test_simulators.py +++ b/tests/scripts/test_simulators.py @@ -99,7 +99,9 @@ def loadConfig(name, rx_hostname, settingsdir): Log(Fore.GREEN, 'Loading config') try: d = Detector() - if name == 'eiger': + if name == 'xilinx_ctb': + d.hostname = 'localhost' + elif name == 'eiger': d.hostname = 'localhost:' + str(DEFAULT_TCP_CNTRL_PORTNO) + '+localhost:' + str(HALFMOD2_TCP_CNTRL_PORTNO) #d.udp_dstport = {2: 50003} # will set up for every module @@ -174,6 +176,7 @@ if args.servers is None: 'gotthard', 'ctb', 'moench', + 'xilinx_ctb' ] else: servers = args.servers