diff --git a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h index 51f889b67..c2c87312f 100644 --- a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h @@ -82,7 +82,6 @@ /* Config RW regiseter */ #define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL) - #define CONFIG_COUNTER_ENA_OFST (0) #define CONFIG_COUNTER_ENA_MSK (0x00000003 << CONFIG_COUNTER_ENA_OFST) #define CONFIG_COUNTER_ENA_DEFAULT_VAL ((0x0 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK) @@ -119,6 +118,8 @@ #define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL) + + /* Pattern Control registers --------------------------------------------------*/ /* Pattern status Register*/ diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index aa2ed623f..bf2226b28 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 62189ca14..e2f44656e 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -38,6 +38,7 @@ uint32_t clkFrequency[NUM_CLOCKS] = {0, 0, 0, 0, 0}; int highvoltage = 0; int dacValues[NDAC] = {0}; int detPos[2] = {0, 0}; +uint32_t countermask = 0; // will be removed later when in firmware converted to mask int isInitCheckDone() { return initCheckDone; @@ -364,8 +365,7 @@ void setupDetector() { // dynamic range setDynamicRange(DEFAULT_DYNAMIC_RANGE); // enable all counters - bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_COUNTER_ENA_MSK); - bus_w(CONFIG_REG, bus_r(CONFIG_REG) | CONFIG_COUNTER_ENA_ALL_VAL); + setCounterMask(MAX_COUNTER_MSK); // Initialization of acquistion parameters @@ -529,6 +529,66 @@ int64_t getPeriod() { return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/ (1E-9 * FIXED_PLL_FREQUENCY); } +void setCounterMask(uint32_t arg) { + if (arg == 0 || arg > MAX_COUNTER_MSK) { + return; + } + countermask = arg; + // convert mask into number of counters (until firmware converts to mask) + int ncounters = __builtin_popcount(countermask); + FILE_LOG(logINFO, ("Setting number of counters to %d\n", ncounters)); + uint32_t val = 0; + switch (ncounters) { + case 1: + val = CONFIG_COUNTER_ENA_1_VAL; + break; + case 2: + val = CONFIG_COUNTER_ENA_2_VAL; + break; + default: + val = CONFIG_COUNTER_ENA_ALL_VAL; + break; + } + uint32_t addr = CONFIG_REG; + bus_w(addr, bus_r(addr) &~ CONFIG_COUNTER_ENA_MSK); + bus_w(addr, bus_r(addr) | val); + FILE_LOG(logDEBUG, ("Config Reg: 0x%x\n", bus_r(addr))); +} + +uint32_t getCounterMask() { + uint32_t addr = CONFIG_REG; + uint32_t regval = (bus_r(addr) & CONFIG_COUNTER_ENA_MSK); + int ncounters = 0; + switch (regval) { + case CONFIG_COUNTER_ENA_1_VAL: + ncounters = 1; + break; + case CONFIG_COUNTER_ENA_2_VAL: + ncounters = 2; + break; + default: + ncounters = 3; + break; + } + // confirm ncounters work with mask saved in server (until firmware converts to mask) + int nc = __builtin_popcount(countermask); + // if not equal, make a mask of what is in register (will change once firmware changes) + if (nc != ncounters) { + switch (ncounters) { + case 1: + countermask = 0x1; + break; + case 2: + countermask = 0x3; + break; + default: + countermask = 0x7; + break; + } + } + return countermask; +} + int setDelayAfterTrigger(int64_t val) { if (val < 0) { FILE_LOG(logERROR, ("Invalid delay after trigger: %lld ns\n", (long long int)val)); @@ -992,6 +1052,33 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) { } } +int checkDetectorType() { + FILE_LOG(logINFO, ("Checking type of module\n")); + FILE* fd = fopen(TYPE_FILE_NAME, "r"); + if (fd == NULL) { + FILE_LOG(logERROR, ("Could not open file %s to get type of the module attached\n", TYPE_FILE_NAME)); + return -1; + } + char buffer[MAX_STR_LENGTH]; + memset(buffer, 0, sizeof(buffer)); + fread (buffer, MAX_STR_LENGTH, sizeof(char), fd); + if (strlen(buffer) == 0) { + FILE_LOG(logERROR, ("Could not read file %s to get type of the module attached\n", TYPE_FILE_NAME)); + return -1; + } + int type = atoi(buffer); + if (type > TYPE_TOLERANCE) { + FILE_LOG(logERROR, ("No Module attached! Expected %d for Mythen, got %d\n", TYPE_MYTHEN3_MODULE_VAL, type)); + return -2; + } + + if (abs(type - TYPE_MYTHEN3_MODULE_VAL) > TYPE_TOLERANCE) { + FILE_LOG(logERROR, ("Wrong Module attached! Expected %d for Mythen, got %d\n", TYPE_MYTHEN3_MODULE_VAL, type)); + return FAIL; + } + return OK; +} + int powerChip (int on){ if(on != -1){ if(on){ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h index 9eb0f64c8..4ec09e64f 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h @@ -7,14 +7,21 @@ #define CTRL_SRVR_INIT_TIME_US (300 * 1000) /* Hardware Definitions */ -#define NCHAN (128 * 3) +#define NCOUNTERS (3) +#define MAX_COUNTER_MSK (0x7) +#define NCHAN (128 * NCOUNTERS) #define NCHIP (10) #define NDAC (16) #define HV_SOFT_MAX_VOLTAGE (200) #define HV_HARD_MAX_VOLTAGE (530) #define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac") -#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac") +#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac") +#define TYPE_FILE_NAME ("/etc/devlinks/type") #define DAC_MAX_MV (2048) +#define TYPE_MYTHEN3_MODULE_VAL (93) +#define TYPE_TOLERANCE (10) +#define TYPE_NO_MODULE_STARTING_VAL (800) + /** Default Parameters */ #define DEFAULT_DYNAMIC_RANGE (24) diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 331d91373..1932dbe03 100755 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -198,6 +198,10 @@ int getNumAnalogSamples(); int setNumDigitalSamples(int val); int getNumDigitalSamples(); #endif +#ifdef MYTHEN3D +void setCounterMask(uint32_t arg); +uint32_t getCounterMask(); +#endif #if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) int setDelayAfterTrigger(int64_t val); @@ -221,6 +225,7 @@ int64_t getMeasurementTime(); #endif + // parameters - module, settings #if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(MYTHEN3D)) && (!defined(GOTTHARD2D)) int setModule(sls_detector_module myMod, char* mess); @@ -424,6 +429,7 @@ uint64_t writePatternWord(int addr, uint64_t word); int setPatternWaitAddress(int level, int addr); uint64_t setPatternWaitTime(int level, uint64_t t); void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop); +int checkDetectorType(); int powerChip (int on); int setPhase(enum CLKINDEX ind, int val, int degrees); int getPhase(enum CLKINDEX ind, int degrees); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index bd2e1bee0..0b21ceabf 100755 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -203,4 +203,6 @@ int set_veto_refernce(int); int get_burst_mode(int); int set_burst_mode(int); int set_adc_enable_mask_10g(int); -int get_adc_enable_mask_10g(int); \ No newline at end of file +int get_adc_enable_mask_10g(int); +int set_counter_mask(int); +int get_counter_mask(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 9c15707da..d494ffbb9 100755 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -305,6 +305,8 @@ const char* getFunctionName(enum detFuncs func) { case F_SET_BURST_MODE: return "F_SET_BURST_MODE"; case F_SET_ADC_ENABLE_MASK_10G: return "F_SET_ADC_ENABLE_MASK_10G"; case F_GET_ADC_ENABLE_MASK_10G: return "F_GET_ADC_ENABLE_MASK_10G"; + case F_SET_COUNTER_MASK: return "F_SET_COUNTER_MASK"; + case F_GET_COUNTER_MASK: return "F_GET_COUNTER_MASK"; default: return "Unknown Function"; } @@ -487,6 +489,8 @@ void function_table() { flist[F_SET_BURST_MODE] = &set_burst_mode; flist[F_SET_ADC_ENABLE_MASK_10G] = &set_adc_enable_mask_10g; flist[F_GET_ADC_ENABLE_MASK_10G] = &get_adc_enable_mask_10g; + flist[F_SET_COUNTER_MASK] = &set_counter_mask; + flist[F_GET_COUNTER_MASK] = &get_counter_mask; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -3837,8 +3841,29 @@ int power_chip(int file_des) { #else // set & get if ((arg == -1) || (Server_VerifyLock() == OK)) { - retval = powerChip(arg); - FILE_LOG(logDEBUG1, ("Power chip: %d\n", retval)); +#ifdef MYTHEN3D + // check only when powering on + if (arg != -1 && arg != 0) { + int type_ret = checkDetectorType(); + if (type_ret == -1) { + ret = FAIL; + sprintf(mess, "Could not power on chip. Could not open file to get type of module attached.\n"); + FILE_LOG(logERROR,(mess)); + } else if (type_ret == -2) { + ret = FAIL; + sprintf(mess, "Could not power on chip. No module attached!\n"); + FILE_LOG(logERROR,(mess)); + } else if (type_ret == FAIL) { + ret = FAIL; + sprintf(mess, "Could not power on chip. Wrong module attached!\n"); + FILE_LOG(logERROR,(mess)); + } + } +#endif + if (ret == OK) { + retval = powerChip(arg); + FILE_LOG(logDEBUG1, ("Power chip: %d\n", retval)); + } validate(arg, retval, "power on/off chip", DEC); #ifdef JUNGFRAUD // narrow down error when powering on @@ -5715,7 +5740,7 @@ int get_clock_frequency(int file_des) { #endif default: #if defined(GOTTHARD2D) || defined(MYTHEN3D) - if (c < NUM_CLOCKS) { + if (arg < NUM_CLOCKS) { c = (enum CLKINDEX)arg; break; } @@ -6499,4 +6524,60 @@ int get_burst_mode(int file_des) { FILE_LOG(logDEBUG1, ("Get burst mode:%d\n", retval)); #endif return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval)); +} + + +int set_counter_mask(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + uint32_t arg = 0; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + + FILE_LOG(logINFO, ("Setting Counter mask:0x%x\n", arg)); + +#ifndef MYTHEN3D + functionNotImplemented(); +#else + // only set + if (Server_VerifyLock() == OK) { + if (arg == 0) { + ret = FAIL; + sprintf(mess, "Could not set counter mask. Cannot set it to 0.\n"); + FILE_LOG(logERROR, (mess)); + } else if (arg > MAX_COUNTER_MSK) { + ret = FAIL; + sprintf(mess, "Could not set counter mask. Invalid counter bit enabled. Max number of counters: %d\n", NCOUNTERS); + FILE_LOG(logERROR, (mess)); + } else { + setCounterMask(arg); + uint32_t retval = getCounterMask(); + FILE_LOG(logDEBUG, ("counter mask retval: 0x%x\n", retval)); + if (retval != arg) { + ret = FAIL; + sprintf(mess, "Could not set counter mask. Set 0x%x mask, got 0x%x mask\n", arg, retval); + FILE_LOG(logERROR, (mess)); + } + } + } +#endif + return Server_SendResult(file_des, INT32, UPDATE, NULL, 0); +} + + +int get_counter_mask(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + uint32_t retval = -1; + FILE_LOG(logDEBUG1, ("Getting counter mask\n")); + +#ifndef MYTHEN3D + functionNotImplemented(); +#else + // get only + retval = getCounterMask(); + FILE_LOG(logDEBUG, ("counter mask retval: 0x%x\n", retval)); +#endif + return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval)); } \ No newline at end of file diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 7ff422517..da6863319 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -910,7 +910,18 @@ class Detector { void setBurstMode(bool enable, Positions pos = {}); /** [Gotthard2] */ - Result getBurstMode(Positions pos = {}); + Result getBurstMode(Positions pos = {}); + + /************************************************** + * * + * Mythen3 Specific * + * * + * ************************************************/ + /** [Mythen3] */ + Result getCounterMask(Positions pos = {}) const; + + /** [Mythen3] countermask bit set for each counter enabled */ + void setCounterMask(uint32_t countermask, Positions pos = {}); /************************************************** * * diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 6c49eecd1..452b66609 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -26,8 +26,8 @@ std::ostream &operator<<(std::ostream &os, } void CmdProxy::Call(const std::string &command, - const std::vector &arguments, - int detector_id, int action, std::ostream &os) { + const std::vector &arguments, int detector_id, + int action, std::ostream &os) { cmd = command; args = arguments; det_id = detector_id; @@ -38,7 +38,8 @@ void CmdProxy::Call(const std::string &command, if (it != functions.end()) { os << ((*this).*(it->second))(action); } else { - throw sls::RuntimeError(cmd + " Unknown command, use list to list all commands"); + throw sls::RuntimeError( + cmd + " Unknown command, use list to list all commands"); } } @@ -55,7 +56,6 @@ bool CmdProxy::ReplaceIfDepreciated(std::string &command) { return false; } - std::vector CmdProxy::GetProxyCommands() { std::vector commands; for (const auto &it : functions) @@ -703,8 +703,8 @@ std::vector CmdProxy::DacCommands() { case defs::MYTHEN3: return std::vector{ "vcassh", "vth2", "vshaper", "vshaperneg", "vipre_out", "vth3", - "vth1", "vicin", "vcas", "vpreamp", "vph", "vipre", - "viinsh", "vpl", "vtrim", "vdcsh"}; + "vth1", "vicin", "vcas", "vpreamp", "vpl", "vipre", + "viinsh", "vph", "vtrim", "vdcsh"}; break; case defs::CHIPTESTBOARD: return std::vector{ @@ -1151,69 +1151,125 @@ std::string CmdProxy::ClearROI(int action) { return os.str(); } - /* Gotthard2 Specific */ std::string CmdProxy::InjectChannel(int action) { - std::ostringstream os; + std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { - os << "[offset] [increment]\n\t[Gotthard2] Inject channels with current source for calibration. Offset is starting channel that is injected, increment determines succeeding channels to be injected." << '\n'; + os << "[offset] [increment]\n\t[Gotthard2] Inject channels with " + "current source for calibration. Offset is starting channel that " + "is injected, increment determines succeeding channels to be " + "injected." + << '\n'; } else if (action == defs::GET_ACTION) { - if (!args.empty()) { - WrongNumberOfParameters(0); - } - auto t = det->getInjectChannel({det_id}); - os << OutString(t) << '\n'; - } else if (action == defs::PUT_ACTION) { + if (!args.empty()) { + WrongNumberOfParameters(0); + } + auto t = det->getInjectChannel({det_id}); + os << OutString(t) << '\n'; + } else if (action == defs::PUT_ACTION) { if (args.size() != 2) { - WrongNumberOfParameters(2); - } - det->setInjectChannel(std::stoi(args[0]), std::stoi(args[1]), {det_id}); + WrongNumberOfParameters(2); + } + det->setInjectChannel(std::stoi(args[0]), std::stoi(args[1]), {det_id}); os << sls::ToString(args) << '\n'; - } else { + } else { throw sls::RuntimeError("Unknown action"); } return os.str(); } std::string CmdProxy::VetoPhoton(int action) { - std::ostringstream os; + std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { - os << "[n_chip] [#photons] [energy in keV] [reference file]\n\t[Gotthard2] Set veto reference for 128 channels for chip n_chip according to referenc file and #photons and energy in keV." << '\n'; + os << "[n_chip] [#photons] [energy in keV] [reference " + "file]\n\t[Gotthard2] Set veto reference for 128 channels for " + "chip n_chip according to referenc file and #photons and energy " + "in keV." + << '\n'; } else if (action == defs::GET_ACTION) { - if (args.size() != 1) { - WrongNumberOfParameters(1); - } - auto t = det->getVetoPhoton(std::stoi(args[0]), {det_id}); - os << args[0] << ' ' << OutStringHex(t) << '\n'; - } else if (action == defs::PUT_ACTION) { + if (args.size() != 1) { + WrongNumberOfParameters(1); + } + auto t = det->getVetoPhoton(std::stoi(args[0]), {det_id}); + os << args[0] << ' ' << OutStringHex(t) << '\n'; + } else if (action == defs::PUT_ACTION) { if (args.size() != 4) { - WrongNumberOfParameters(4); - } - det->setVetoPhoton(std::stoi(args[0]), std::stoi(args[1]), std::stoi(args[2]), args[3], {det_id}); + WrongNumberOfParameters(4); + } + det->setVetoPhoton(std::stoi(args[0]), std::stoi(args[1]), + std::stoi(args[2]), args[3], {det_id}); os << sls::ToString(args) << '\n'; - } else { + } else { throw sls::RuntimeError("Unknown action"); } return os.str(); } std::string CmdProxy::VetoReference(int action) { - std::ostringstream os; + std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { - os << "[gain index] [12 bit value in hex] \n\t[Gotthard2] Set veto reference for all 128 channels for all chips." << '\n'; + os << "[gain index] [12 bit value in hex] \n\t[Gotthard2] Set veto " + "reference for all 128 channels for all chips." + << '\n'; } else if (action == defs::GET_ACTION) { throw sls::RuntimeError("cannot get vetoref. Did you mean vetophoton?"); - } else if (action == defs::PUT_ACTION) { + } else if (action == defs::PUT_ACTION) { if (args.size() != 2) { - WrongNumberOfParameters(2); - } - det->setVetoReference(std::stoi(args[0]), stoiHex(args[1]), {det_id}); + WrongNumberOfParameters(2); + } + det->setVetoReference(std::stoi(args[0]), stoiHex(args[1]), {det_id}); os << sls::ToString(args) << '\n'; - } else { + } else { + throw sls::RuntimeError("Unknown action"); + } + return os.str(); +} + +/* Mythen3 Specific */ + +std::string CmdProxy::Counters(int action) { + std::ostringstream os; + os << cmd << ' '; + if (action == defs::HELP_ACTION) { + os << "[i0] [i1] [i2]... \n\t[Mythen3] List of counters enabled. Each " + "element in list can be 0 - 2 and must be non repetitive." + << '\n'; + } else if (action == defs::GET_ACTION) { + if (!args.empty()) { + WrongNumberOfParameters(0); + } + auto mask = det->getCounterMask({det_id}).squash(-1); + // scan counter enable mask to get vector + std::vector result; + for (size_t i = 0; i < 32; ++i) { + if (mask & (1 << i)) { + result.push_back((int)i); + } + } + os << sls::ToString(result) << '\n'; + } else if (action == defs::PUT_ACTION) { + if (args.empty()) { + WrongNumberOfParameters(1); + } + // convert vector to counter enable mask + uint32_t mask = 0; + for (size_t i = 0; i < args.size(); ++i) { + int val = std::stoi(args[i]); + // already enabled earlier + if (mask & (1 << val)) { + std::ostringstream oss; + oss << "Duplicate counter values (" << val << ") in arguments"; + throw sls::RuntimeError(oss.str()); + } + mask |= (1 << val); + } + det->setCounterMask(mask, {det_id}); + os << sls::ToString(args) << '\n'; + } else { throw sls::RuntimeError("Unknown action"); } return os.str(); @@ -1335,7 +1391,8 @@ std::string CmdProxy::ReceiverDbitList(int action) { if (action == defs::HELP_ACTION) { os << "[all] or [i0] [i1] [i2]... \n\t[Ctb] List of digital signal " "bits read out. If all is used instead of a list, all digital " - "bits (64) enabled. Each element in list can be 0 - 63 and non " + "bits (64) enabled. Each element in list can be 0 - 63 and must " + "be non " "repetitive." << '\n'; } else if (action == defs::GET_ACTION) { diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index bc1c51496..4e4a3e0f7 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -529,6 +529,7 @@ class CmdProxy { {"digitest", "imagetest"}, /* Gotthard2 Specific */ + /* Mythen3 Specific */ /* CTB Specific */ {"flags", "romode"}, {"i_a", "im_a"}, @@ -785,6 +786,9 @@ class CmdProxy { {"vetoref", &CmdProxy::VetoReference}, {"burstmode", &CmdProxy::burstmode}, + /* Mythen3 Specific */ + {"counters", &CmdProxy::Counters}, + /* CTB Specific */ {"samples", &CmdProxy::Samples}, {"asamples", &CmdProxy::asamples}, @@ -938,7 +942,9 @@ class CmdProxy { /* Gotthard2 Specific */ std::string InjectChannel(int action); std::string VetoPhoton(int action); - std::string VetoReference(int action); + std::string VetoReference(int action); + /* Mythen3 Specific */ + std::string Counters(int action); /* CTB Specific */ std::string Samples(int action); std::string Dbitphase(int action); @@ -1526,6 +1532,8 @@ class CmdProxy { INTEGER_COMMAND(burstmode, getBurstMode, setBurstMode, std::stoi, "[0, 1]\n\t[Gotthard2] 1 sets to burst mode. 0 sets to continuous mode. Default is burst mode."); + /* Mythen3 Specific */ + /* CTB Specific */ INTEGER_COMMAND(asamples, getNumberOfAnalogSamples, setNumberOfAnalogSamples, std::stoi, diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 8d8525afe..ef292712c 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1188,6 +1188,16 @@ Result Detector::getBurstMode(Positions pos) { return pimpl->Parallel(&slsDetector::getBurstMode, pos); } +// Mythen3 Specific + +Result Detector::getCounterMask(Positions pos) const { + return pimpl->Parallel(&slsDetector::getCounterMask, pos); +} + +void Detector::setCounterMask(uint32_t countermask, Positions pos) { + pimpl->Parallel(&slsDetector::setCounterMask, pos, countermask); +} + // CTB Specific Result Detector::getNumberOfAnalogSamples(Positions pos) const { diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index e50065973..fcaacdfbf 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -1720,36 +1720,6 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) { shm()->useReceiverFlag = true; checkReceiverVersionCompatibility(); - FILE_LOG(logDEBUG) - << "detector type:" - << (ToString(shm()->myDetectorType)) - << "\ndetector id:" << detId - << "\ndetector hostname:" << shm()->hostname - << "\nfile path:" << shm()->rxFilePath - << "\nfile name:" << shm()->rxFileName - << "\nfile index:" << shm()->rxFileIndex - << "\nfile format:" << shm()->rxFileFormat - << "\nr_framesperfile:" << shm()->rxFramesPerFile - << "\nr_discardpolicy:" << shm()->rxFrameDiscardMode - << "\nr_padding:" << shm()->rxFramePadding - << "\nwrite enable:" << shm()->rxFileWrite - << "\nmaster write enable:" << shm()->rxMasterFileWrite - << "\noverwrite enable:" << shm()->rxFileOverWrite - << "\ndynamic range:" << shm()->dynamicRange - << "\nflippeddatax:" << (shm()->flippedDataX) - << "\nactivated: " << shm()->activated - << "\nreceiver deactivated padding: " << shm()->rxPadDeactivatedModules - << "\nsilent Mode:" << shm()->rxSilentMode - << "\n10GbE:" << shm()->tenGigaEnable - << "\nGap pixels: " << shm()->gappixels - << "\nr_readfreq:" << shm()->rxReadFreq - << "\nrx streaming port:" << shm()->rxZmqport - << "\nrx streaming source ip:" << shm()->rxZmqip - << "\nrx additional json header:" << shm()->rxAdditionalJsonHeader - << "\nrx_datastream:" << enableDataStreamingFromReceiver(-1) - << "\nrx_dbitlistsize:" << shm()->rxDbitList.size() - << "\nrx_DbitOffset:" << shm()->rxDbitOffset << std::endl; - if (setDetectorType(shm()->myDetectorType) != GENERIC) { sendMultiDetectorSize(); setDetectorId(); @@ -1821,6 +1791,10 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) { sendROItoReceiver(); break; + case MYTHEN3: + sendNumberofCounterstoReceiver(getCounterMask()); + break; + default: break; } @@ -3531,6 +3505,9 @@ std::vector slsDetector::getNumMissingPackets() const { throw RuntimeError("Receiver " + std::to_string(detId) + " returned error: " + std::string(mess)); } else { + if (ret == FORCE_UPDATE) { + updateCachedReceiverVariables(); + } int nports = -1; client.Receive(&nports, sizeof(nports)); uint64_t mp[nports]; @@ -3888,6 +3865,27 @@ void slsDetector::setPipeline(int clkIndex, int value) { sendToDetector(F_SET_PIPELINE, args, nullptr); } +void slsDetector::setCounterMask(uint32_t countermask) { + FILE_LOG(logDEBUG1) << "Setting Counter mask to " << countermask; + sendToDetector(F_SET_COUNTER_MASK, countermask, nullptr); + sendNumberofCounterstoReceiver(countermask); +} + +void slsDetector::sendNumberofCounterstoReceiver(uint32_t countermask) { + if (shm()->useReceiverFlag) { + int ncounters = __builtin_popcount(countermask); + FILE_LOG(logDEBUG1) << "Sending Reciver #counters: " << ncounters; + sendToReceiver(F_RECEIVER_SET_NUM_COUNTERS, ncounters, nullptr); + } +} + +uint32_t slsDetector::getCounterMask() { + uint32_t retval = 0; + sendToDetector(F_GET_COUNTER_MASK, nullptr, retval); + FILE_LOG(logDEBUG1) << "Received counter mask: " << retval; + return retval; +} + sls_detector_module slsDetector::interpolateTrim(sls_detector_module *a, sls_detector_module *b, diff --git a/slsDetectorSoftware/src/slsDetector.h b/slsDetectorSoftware/src/slsDetector.h index 82a55f1dd..5edcdae2e 100755 --- a/slsDetectorSoftware/src/slsDetector.h +++ b/slsDetectorSoftware/src/slsDetector.h @@ -1862,6 +1862,15 @@ class slsDetector : public virtual slsDetectorDefs { /** [Ctb][Moench] */ void setPipeline(int clkIndex, int value); + + /** [Mythen3] */ + void setCounterMask(uint32_t countermask); + + /** [Mythen3] */ + void sendNumberofCounterstoReceiver(uint32_t countermask); + + /** [Mythen3] */ + uint32_t getCounterMask(); private: /** diff --git a/slsDetectorSoftware/tests/CMakeLists.txt b/slsDetectorSoftware/tests/CMakeLists.txt index 3a5c0b501..82ae54b8d 100755 --- a/slsDetectorSoftware/tests/CMakeLists.txt +++ b/slsDetectorSoftware/tests/CMakeLists.txt @@ -5,6 +5,8 @@ target_sources(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-rx.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-eiger.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-jungfrau.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-mythen3.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-global.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-Result.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdParser.cpp ) diff --git a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp index 63789d09d..e4366b8b4 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp @@ -5,6 +5,7 @@ #include #include +#include "test-CmdProxy-global.h" #include "tests/globals.h" #include "versionAPI.h" @@ -42,13 +43,13 @@ TEST_CASE("Eiger transmission delay", "[.cmd]") { proxy.Call("txndelay_right", {}, -1, GET, oss2); REQUIRE(oss2.str() == "txndelay_right 5000\n"); } - } - // Reset to previous values - for (int i = 0; i != det.size(); ++i) { - det.setTransmissionDelayFrame(frame[i]); - det.setTransmissionDelayLeft(left[i]); - det.setTransmissionDelayRight(right[i]); + // Reset to previous values + for (int i = 0; i != det.size(); ++i) { + det.setTransmissionDelayFrame(frame[i]); + det.setTransmissionDelayLeft(left[i]); + det.setTransmissionDelayRight(right[i]); + } } } @@ -134,7 +135,7 @@ TEST_CASE("overflow", "[.cmd]") { } TEST_CASE("trimen", "[.cmd][.this]") { - //TODO! Also Mythen? + // TODO! Also Mythen? Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -147,7 +148,7 @@ TEST_CASE("trimen", "[.cmd][.this]") { proxy.Call("trimen", {}, -1, GET, oss2); REQUIRE(oss2.str() == "trimen [4500, 5400, 6400]\n"); - for (int i = 0; i!=det.size(); ++i){ + for (int i = 0; i != det.size(); ++i) { det.setTrimEnergies(previous[i], {i}); } } else { @@ -279,22 +280,6 @@ TEST_CASE("quad", "[.cmd]") { } } -void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) { - Detector det; - CmdProxy proxy(&det); - std::ostringstream oss_set, oss_get; - auto dacstr = std::to_string(dacvalue); - auto previous = det.getDAC(index, false); - proxy.Call(dacname, {dacstr}, -1, PUT, oss_set); - REQUIRE(oss_set.str() == dacname + " " + dacstr + "\n"); - proxy.Call(dacname, {}, -1, GET, oss_get); - REQUIRE(oss_set.str() == dacname + " " + dacstr + "\n"); - // Reset all dacs to previous value - for (int i = 0; i != det.size(); ++i) { - det.setDAC(index, previous[i], false, {i}); - } -} - TEST_CASE("Setting and reading back EIGER dacs", "[.cmd]") { // vsvp, vtr, vrf, vrs, vsvn, vtgstv, vcmp_ll, vcmp_lr, vcal, vcmp_rl, // rxb_rb, rxb_lb, vcmp_rr, vcp, vcn, vis, vthreshold @@ -348,6 +333,48 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd]") { det.setDAC(defs::VCP, vcp[i], false, {i}); } } + REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vpreamp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vshaper", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vshaperneg", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vipre", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("viinsh", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vdcsh", {}, -1, GET)); + // REQUIRE_THROWS(proxy.Call("vth1", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vth2", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vth3", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vpl", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vph", {}, -1, GET)); + // REQUIRE_THROWS(proxy.Call("vtrim", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcassh", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcas", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vicin", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vipre_out", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_h_adc", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_comp_fe", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_comp_adc", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcom_cds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_restore", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_opa_1st", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_comp_fe", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcom_adc1", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_l_adc", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_cds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_cs", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_opa_fd", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_ds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_comp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_pixbuf", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vin_com", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vdd_prot", {}, -1, GET)); } } diff --git a/slsDetectorSoftware/tests/test-CmdProxy-global.cpp b/slsDetectorSoftware/tests/test-CmdProxy-global.cpp new file mode 100644 index 000000000..c0104b85d --- /dev/null +++ b/slsDetectorSoftware/tests/test-CmdProxy-global.cpp @@ -0,0 +1,27 @@ +#include "test-CmdProxy-global.h" +#include "CmdProxy.h" +#include "Detector.h" +#include "catch.hpp" +#include "tests/globals.h" + +using sls::CmdProxy; +using sls::Detector; +using test::GET; +using test::PUT; + + +void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) { + Detector det; + CmdProxy proxy(&det); + std::ostringstream oss_set, oss_get; + auto dacstr = std::to_string(dacvalue); + auto previous = det.getDAC(index, false); + proxy.Call(dacname, {dacstr}, -1, PUT, oss_set); + REQUIRE(oss_set.str() == dacname + " " + dacstr + "\n"); + proxy.Call(dacname, {}, -1, GET, oss_get); + REQUIRE(oss_get.str() == dacname + " " + dacstr + "\n"); + // Reset all dacs to previous value + for (int i = 0; i != det.size(); ++i) { + det.setDAC(index, previous[i], false, {i}); + } +} diff --git a/slsDetectorSoftware/tests/test-CmdProxy-global.h b/slsDetectorSoftware/tests/test-CmdProxy-global.h new file mode 100644 index 000000000..32a56f42a --- /dev/null +++ b/slsDetectorSoftware/tests/test-CmdProxy-global.h @@ -0,0 +1,4 @@ +#pragma once +#include "sls_detector_defs.h" + +void test_dac(slsDetectorDefs::dacIndex index, const std::string &dacname, int dacvalue); \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp b/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp new file mode 100644 index 000000000..18511ed60 --- /dev/null +++ b/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp @@ -0,0 +1,203 @@ +#include "CmdProxy.h" +#include "Detector.h" +#include "catch.hpp" +#include "sls_detector_defs.h" +#include + +#include "Result.h" +#include "ToString.h" +#include "test-CmdProxy-global.h" +#include "tests/globals.h" +#include "versionAPI.h" + +using sls::CmdProxy; +using sls::Detector; +using test::GET; +using test::PUT; + +TEST_CASE("Setting and reading back MYTHEN3 dacs", "[.cmd][.dacs]") { + // vcassh, vth2, vshaper, vshaperneg, vipre_out, vth3, vth1, + // vicin, vcas, vpreamp, vpl, vipre, viinsh, vph, vtrim, vdcsh, + + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + SECTION("vcassh") { test_dac(defs::CASSH, "vcassh", 1200); } + SECTION("vth2") { test_dac(defs::VTH2, "vth2", 2800); } + SECTION("vshaper") { test_dac(defs::SHAPER1, "vshaper", 1280); } + SECTION("vshaperneg") { test_dac(defs::SHAPER2, "vshaperneg", 2800); } + SECTION("vipre_out") { test_dac(defs::VIPRE_OUT, "vipre_out", 1220); } + SECTION("vth3") { test_dac(defs::VTH3, "vth3", 2800); } + SECTION("vth1") { test_dac(defs::THRESHOLD, "vth1", 2880); } + SECTION("vicin") { test_dac(defs::VICIN, "vicin", 1708); } + SECTION("vcas") { test_dac(defs::CAS, "vcas", 1800); } + SECTION("vpreamp") { test_dac(defs::PREAMP, "vpreamp", 1100); } + SECTION("vpl") { test_dac(defs::VPL, "vpl", 1100); } + SECTION("vipre") { test_dac(defs::VIPRE, "vipre", 2624); } + SECTION("viinsh") { test_dac(defs::VIINSH, "viinsh", 1708); } + SECTION("vph") { test_dac(defs::CALIBRATION_PULSE, "vph", 1712); } + SECTION("vtrim") { test_dac(defs::TRIMBIT_SIZE, "vtrim", 2800); } + SECTION("vdcsh") { test_dac(defs::VDCSH, "vdcsh", 800); } + + REQUIRE_THROWS(proxy.Call("vsvp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vsvn", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vtr", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vrf", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vrs", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vtgstv", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcmp_ll", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcmp_lr", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcal", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcmp_rl", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcmp_rr", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("rxb_rb", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("rxb_lb", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcn", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vis", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("iodelay", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_h_adc", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_comp_fe", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_comp_adc", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcom_cds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_restore", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_opa_1st", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_comp_fe", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcom_adc1", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_prech", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_l_adc", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_cds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_cs", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_opa_fd", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_ds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_comp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_pixbuf", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vin_com", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vdd_prot", {}, -1, GET)); + } +} + +TEST_CASE("clkfreq", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) { + REQUIRE_THROWS(proxy.Call("clkfreq", {"0", "2"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("clkfreq", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("clkfreq", {"7"}, -1, GET)); + + auto value = det.getClockFrequency(0).squash(-1); + std::ostringstream oss_set, oss_get; + proxy.Call("clkfreq", {"0"}, -1, GET, oss_get); + REQUIRE(oss_get.str() == "clkfreq " + std::to_string(value) + "\n"); + } else { + REQUIRE_THROWS(proxy.Call("clkfreq", {"0"}, -1, GET)); + } +} + +TEST_CASE("clkphase", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) { + REQUIRE_THROWS(proxy.Call("clkphase", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("clkphase", {"7"}, -1, GET)); + REQUIRE_THROWS(proxy.Call("clkphase", {"4"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("clkphase", {"7", "4"}, -1, PUT)); + + auto previous = det.getClockFrequency(0).squash(-1); + auto previous_string = std::to_string(previous); + std::ostringstream oss_set, oss_get, oss_get2; + proxy.Call("clkfreq", {"0", previous_string}, -1, PUT, oss_set); + REQUIRE(oss_set.str() == "clkfreq" + previous_string + "\n"); + proxy.Call("clkfreq", {"0"}, -1, GET, oss_get); + REQUIRE(oss_get.str() == "clkfreq " + previous_string + "\n"); + REQUIRE_NOTHROW(proxy.Call("clkphase", {"0", "deg"}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("clkphase", {"0"}, -1, GET)); + } +} + +TEST_CASE("clkdiv", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) { + REQUIRE_THROWS(proxy.Call("clkdiv", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("clkdiv", {"7"}, -1, GET)); + REQUIRE_THROWS(proxy.Call("clkdiv", {"7", "4"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("clkdiv", {"7", "4"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("clkdiv", {"0", "1"}, -1, PUT)); + + auto previous = det.getClockDivider(0).squash(-1); + auto previous_string = std::to_string(previous); + std::ostringstream oss_set, oss_get; + proxy.Call("clkdiv", {"0", previous_string}, -1, PUT, oss_set); + REQUIRE(oss_set.str() == "clkdiv" + previous_string + "\n"); + proxy.Call("clkdiv", {"0"}, -1, GET, oss_get); + REQUIRE(oss_get.str() == "clkdiv " + previous_string + "\n"); + } else { + REQUIRE_THROWS(proxy.Call("clkdiv", {"0"}, -1, GET)); + } +} + +TEST_CASE("maxclkphaseshift", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) { + REQUIRE_THROWS(proxy.Call("maxclkphaseshift", {"0", "2"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("maxclkphaseshift", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("maxclkphaseshift", {"7"}, -1, GET)); + + auto value = det.getMaxClockPhaseShift(0).squash(-1); + std::ostringstream oss_set, oss_get; + proxy.Call("maxclkphaseshift", {"0"}, -1, GET, oss_get); + REQUIRE(oss_get.str() == + "maxclkphaseshift " + std::to_string(value) + "\n"); + } else { + REQUIRE_THROWS(proxy.Call("maxclkphaseshift", {"0"}, -1, GET)); + } +} + +TEST_CASE("counters", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + REQUIRE_THROWS(proxy.Call("counters", {}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("counters", {"3"}, -1, GET)); + REQUIRE_THROWS(proxy.Call("counters", {"0", "-1"}, -1, GET)); + REQUIRE_THROWS(proxy.Call("counters", {"0", "1", "1"}, -1, GET)); + + auto mask = det.getCounterMask({0}).squash(-1); + std::vector list_str; + for (int i = 0; i < 32; ++i) { + if (mask & (1 << i)) { + list_str.push_back(std::to_string(i)); + } + } + std::ostringstream oss_set, oss_set2, oss_set3, oss_get; + proxy.Call("counters", {"0", "2", "1"}, -1, PUT, oss_set); + REQUIRE(oss_set.str() == "counters [0, 2, 1]\n"); + proxy.Call("counters", {"0", "2"}, -1, PUT, oss_set2); + REQUIRE(oss_set2.str() == "counters [0, 2]\n"); + // put back old value + proxy.Call("counters", list_str, -1, PUT, oss_set3); + REQUIRE(oss_set3.str() == "counters " + sls::ToString(list_str) + "\n"); + proxy.Call("counters", {}, -1, GET, oss_get); + REQUIRE(oss_get.str() == "counters " + sls::ToString(list_str) + "\n"); + } else { + REQUIRE_THROWS(proxy.Call("counters", {}, -1, GET)); + } +} diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 862272ea1..83dd8f1ce 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -153,311 +153,7 @@ TEST_CASE("type", "[.cmd]"){ // REQUIRE_NOTHROW(multiSlsDetectorClient("daclist", GET)); // REQUIRE_NOTHROW(multiSlsDetectorClient("dacvalues", GET)); // int prev_val = 0; -// if (test::type == slsDetectorDefs::EIGER) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vthreshold", GET, -// nullptr, oss)); std::string s = (oss.str()).erase (0, -// strlen("vthreshold ")); prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vthreshold 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vthreshold", GET, -// nullptr, oss)); REQUIRE(oss.str() == "vthreshold 1000\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_ll", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vcmp_ll 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vthreshold " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vsvp", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vsvp ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vsvp 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vsvp", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vsvp 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vsvp " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vsvn", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vsvn ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vsvn 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vsvn", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vsvn 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vsvn " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtr", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vtr ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtr 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtr", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vtr 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtr " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vrf", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vrf ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vrf 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vrf", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vrf 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vrf " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vrs", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vrs ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vrs 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vrs", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vrs 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vrs " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtgstv", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vtgstv ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtgstv 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtgstv", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vtgstv 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtgstv " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_ll", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vcmp_ll ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_ll 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_ll", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vcmp_ll 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_ll " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_lr", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vcmp_lr ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_lr 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_lr", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vcmp_lr 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_lr " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcal", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vcal ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcal 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcal", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vcal 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcal " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_rl", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vcmp_rl ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_rl 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_rl", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vcmp_rl 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_rl " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_rr", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vcmp_rr ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_rr 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_rr", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vcmp_rr 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcmp_rr " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("rxb_rb", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("rxb_rb ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("rxb_rb 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("rxb_rb", GET, nullptr, -// oss)); REQUIRE(oss.str() == "rxb_rb 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("rxb_rb " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("rxb_lb", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("rxb_lb ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("rxb_lb 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("rxb_lb", GET, nullptr, -// oss)); REQUIRE(oss.str() == "rxb_lb 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("rxb_lb " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcp", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vcp ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcp 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcp", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vcp 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcp " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcn", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vcn ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcn 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcn", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vcn 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcn " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vis", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vis ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vis 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vis", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vis 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vis " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("iodelay", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("iodelay ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("iodelay 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("iodelay", GET, nullptr, -// oss)); REQUIRE(oss.str() == "iodelay 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("iodelay " + -// std::to_string(prev_val), PUT)); - -// REQUIRE_THROWS(multiSlsDetectorClient("vref_ds", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcascn_pb", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcascp_pb", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vout_cm", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcasc_out", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vin_cm", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_comp", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("ib_test_c", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vpreamp", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vshaper", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vshaperneg", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vipre", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("viinsh", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vdcsh", GET)); -// // REQUIRE_THROWS(multiSlsDetectorClient("vth1", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vth2", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vth3", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vpl", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vph", GET)); -// //REQUIRE_THROWS(multiSlsDetectorClient("vtrim", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcassh", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcas", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vicin", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vipre_out", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_h_adc", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp_fe", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp_adc", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcom_cds", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_restore", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_opa_1st", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_comp_fe", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcom_adc1", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_l_adc", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_cds", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_cs", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_opa_fd", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcom_adc2", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_ds", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_pixbuf", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vin_com", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vdd_prot", GET)); - -// } - -// else if (test::type == slsDetectorDefs::JUNGFRAU) { +// if (test::type == slsDetectorDefs::JUNGFRAU) { // { // std::ostringstream oss; // REQUIRE_NOTHROW(multiSlsDetectorClient("vb_ds", GET, nullptr, @@ -878,291 +574,6 @@ TEST_CASE("type", "[.cmd]"){ // REQUIRE_THROWS(multiSlsDetectorClient("vdd_prot", GET)); // } -// else if (test::type == slsDetectorDefs::MYTHEN3) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vthreshold", GET, -// nullptr, oss)); std::string s = (oss.str()).erase (0, -// strlen("vthreshold ")); prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vthreshold 1000 mv", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vthreshold mv", GET, -// nullptr, oss)); REQUIRE(oss.str() == "vthreshold 1000 mv\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vthreshold " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vpreamp", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vpreamp ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vpreamp 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vpreamp", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vpreamp 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vpreamp " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vshaper", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vshaper ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vshaper 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vshaper", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vshaper 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vshaper " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vshaperneg", GET, -// nullptr, oss)); std::string s = (oss.str()).erase (0, -// strlen("vshaperneg ")); prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vshaperneg 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vshaperneg", GET, -// nullptr, oss)); REQUIRE(oss.str() == "vshaperneg 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vshaperneg " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vipre", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vipre ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vipre 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vipre", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vipre 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vipre " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("viinsh", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("viinsh ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("viinsh 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("viinsh", GET, nullptr, -// oss)); REQUIRE(oss.str() == "viinsh 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("viinsh " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vdcsh", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vdcsh ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vdcsh 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vdcsh", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vdcsh 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vdcsh " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth1", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vth1 ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth1 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth1", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vth1 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth1 " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth2", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vth2 ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth2 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth2", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vth2 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth2 " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth3", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vth3 ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth3 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth3", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vth3 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vth3 " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vpl", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vpl ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vpl 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vpl", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vpl 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vpl " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vph", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vph ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vph 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vph", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vph 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vph " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtrim", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vtrim ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtrim 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtrim", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vtrim 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vtrim " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcassh", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vcassh ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcassh 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcassh", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vcassh 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcassh " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcas", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vcas ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcas 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcas", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vcas 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vcas " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vicin", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vicin ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vicin 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vicin", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vicin 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vicin " + -// std::to_string(prev_val), PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vipre_out", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("vipre_out -// ")); prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vipre_out 1000", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("vipre_out", GET, nullptr, -// oss)); REQUIRE(oss.str() == "vipre_out 1000\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("vipre_out " + -// std::to_string(prev_val), PUT)); - -// REQUIRE_THROWS(multiSlsDetectorClient("vsvp", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vsvn", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vtr", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vrf", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vrs", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vtgstv", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcmp_ll", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcmp_lr", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcal", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcmp_rl", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcmp_rr", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("rxb_rb", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("rxb_lb", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcp", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcn", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vis", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("iodelay", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_ds", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcascn_pb", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcascp_pb", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vout_cm", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcasc_out", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vin_cm", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_comp", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("ib_test_c", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_h_adc", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp_fe", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp_adc", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcom_cds", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_restore", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_opa_1st", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_comp_fe", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcom_adc1", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_prech", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_l_adc", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vref_cds", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_cs", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_opa_fd", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vcom_adc2", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_ds", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vb_pixbuf", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vin_com", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vdd_prot", GET)); -// } // else if (test::type == slsDetectorDefs::GOTTHARD2) { // { @@ -3896,63 +3307,7 @@ TEST_CASE("firmwareversion", "[.cmd]") { // REQUIRE_NOTHROW(multiSlsDetectorClient("delay 0", PUT)); // } // } -// TEST_CASE("clk", "[.cmd][.gotthard2][.mythen3]") { -// if(test::type == slsDetectorDefs::GOTTHARD2 || test::type == -// slsDetectorDefs::MYTHEN3) { -// REQUIRE_THROWS(multiSlsDetectorClient("clkfreq 0 2", PUT)); // cannot -// get REQUIRE_THROWS(multiSlsDetectorClient("clkfreq", GET)); // -// requires clk index REQUIRE_THROWS(multiSlsDetectorClient("clkfreq 7", -// GET)); // 7 doesnt exist -// REQUIRE_THROWS(multiSlsDetectorClient("clkfreq 4", PUT)); // requires -// clk index and val REQUIRE_THROWS(multiSlsDetectorClient("clkfreq 7 -// 4", PUT)); // 7 doesnt exist -// REQUIRE_THROWS(multiSlsDetectorClient("clkphase", GET)); // requires -// clk index REQUIRE_THROWS(multiSlsDetectorClient("clkphase 7", GET)); -// // 7 doesnt exist REQUIRE_THROWS(multiSlsDetectorClient("clkphase 4", -// PUT)); // requires clk index and val -// REQUIRE_THROWS(multiSlsDetectorClient("clkphase 7 4", PUT)); // 7 -// doesnt exist REQUIRE_THROWS(multiSlsDetectorClient("clkdiv", GET)); -// // requires clk index REQUIRE_THROWS(multiSlsDetectorClient("clkdiv -// 7", GET)); // 7 doesnt exist -// REQUIRE_THROWS(multiSlsDetectorClient("clkdiv 4", PUT)); // requires -// clk index and val REQUIRE_THROWS(multiSlsDetectorClient("clkdiv 7 4", -// PUT)); // 7 doesnt exist -// REQUIRE_THROWS(multiSlsDetectorClient("maxclkphaseshift 7", GET)); // -// 7 doesnt exist -// REQUIRE_THROWS(multiSlsDetectorClient("maxclkphaseshift 7 4", PUT)); -// // cannot put -// REQUIRE_NOTHROW(multiSlsDetectorClient("maxclkphaseshift 0", GET)); -// int t = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("clkdiv 0", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("clkdiv ")); -// t = std::stoi(s); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("clkdiv 0 " + -// std::to_string(t), PUT, nullptr, oss)); REQUIRE(oss.str() == -// "clkdiv " + std::to_string(t) + '\n'); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("clkfreq 0", GET)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("clkphase 1 20", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "clkphase 20\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("clkphase 1", GET, -// nullptr, oss)); REQUIRE(oss.str() == "clkphase 20\n"); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("clkfreq 0", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("clkphase 0", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("clkdiv 0", GET)); -// } -// } TEST_CASE("frames", "[.cmd]") { Detector det; diff --git a/slsReceiverSoftware/include/ClientInterface.h b/slsReceiverSoftware/include/ClientInterface.h index 2df26832f..96e117e13 100755 --- a/slsReceiverSoftware/include/ClientInterface.h +++ b/slsReceiverSoftware/include/ClientInterface.h @@ -119,6 +119,7 @@ class ClientInterface : private virtual slsDetectorDefs { int set_udp_port2(sls::ServerInterface2 &socket); int set_num_interfaces(sls::ServerInterface2 &socket); int set_adc_mask_10g(sls::ServerInterface2 &socket); + int set_num_counters(sls::ServerInterface2 &socket); Implementation *impl() { if (receiver != nullptr) { diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h index 2ceecc4bc..427b2c790 100755 --- a/slsReceiverSoftware/include/GeneralData.h +++ b/slsReceiverSoftware/include/GeneralData.h @@ -208,12 +208,21 @@ public: /** * set number of interfaces (jungfrau) - * @param number of interfaces + * @param n number of interfaces */ virtual void SetNumberofInterfaces(const int n) { FILE_LOG(logERROR) << "SetNumberofInterfaces is a generic function that should be overloaded by a derived class"; } + /** + * set number of counters (mythen3) + * @param n number of counters + * @param dr dynamic range + */ + virtual void SetNumberofCounters(const int n, const int dr) { + FILE_LOG(logERROR) << "SetNumberofCounters is a generic function that should be overloaded by a derived class"; + } + /** * Print all variables */ @@ -528,16 +537,19 @@ class JungfrauData : public GeneralData { }; class Mythen3Data : public GeneralData { - - public: +private: + int ncounters; + const int NCHAN = 1280; +public: /** Constructor */ Mythen3Data(){ myDetectorType = slsDetectorDefs::MYTHEN3; - nPixelsX = (1280 * 3); // 1280 channels, 3 counters + ncounters = 3; + nPixelsX = (NCHAN * ncounters); // max 1280 channels x 3 counters nPixelsY = 1; headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header); - dataSize = 7680;//8192; + dataSize = 7680; packetSize = headerSizeinPacket + dataSize; packetsPerFrame = 2; imageSize = dataSize * packetsPerFrame; @@ -547,6 +559,39 @@ class Mythen3Data : public GeneralData { standardheader = true; defaultUdpSocketBufferSize = (1000 * 1024 * 1024); }; + + /** + * set number of counters (mythen3) + * @param n number of counters + * @param dr dynamic range + */ + virtual void SetNumberofCounters(const int n, const int dr) { + if (n < 1 || n > 3) { + throw sls::RuntimeError("Invalid number of counters " + std::to_string(n)); + } + ncounters = n; + nPixelsX = NCHAN * ncounters; + imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit + ((dr > 8) ? 2 : // 16 bit + ((dr > 4) ? 0.5 : // 4 bit + 0.125))); // 1 bit + dataSize = imageSize / packetsPerFrame; + packetSize = headerSizeinPacket + dataSize; + } + + /** + * Setting dynamic range changes member variables + * @param dr dynamic range + * @param tgEnable (discarded, of no value to mythen3) + */ + void SetDynamicRange(int dr, bool tgEnable) { + imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit + ((dr > 8) ? 2 : // 16 bit + ((dr > 4) ? 0.5 : // 4 bit + 0.125))); // 1 bit + dataSize = imageSize / packetsPerFrame; + packetSize = headerSizeinPacket + dataSize; + } }; diff --git a/slsReceiverSoftware/include/Implementation.h b/slsReceiverSoftware/include/Implementation.h index b2fc2863b..a5206593e 100755 --- a/slsReceiverSoftware/include/Implementation.h +++ b/slsReceiverSoftware/include/Implementation.h @@ -149,6 +149,8 @@ class Implementation : private virtual slsDetectorDefs { uint32_t getNumberofDigitalSamples() const; /**[Ctb] */ void setNumberofDigitalSamples(const uint32_t i); + int getNumberofCounters() const; + void setNumberofCounters(const int i); uint32_t getDynamicRange() const; void setDynamicRange(const uint32_t i); ROI getROI() const; @@ -271,6 +273,7 @@ class Implementation : private virtual slsDetectorDefs { uint64_t subPeriod; uint64_t numberOfAnalogSamples; uint64_t numberOfDigitalSamples; + int numberOfCounters; uint32_t dynamicRange; ROI roi; bool tengigaEnable; diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index c56e7ec0a..15e0bbb18 100755 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -174,7 +174,7 @@ int ClientInterface::functionTable(){ flist[F_SET_RECEIVER_UDP_PORT2] = &ClientInterface::set_udp_port2; flist[F_SET_RECEIVER_NUM_INTERFACES] = &ClientInterface::set_num_interfaces; flist[F_RECEIVER_SET_ADC_MASK_10G] = &ClientInterface::set_adc_mask_10g; - + flist[F_RECEIVER_SET_NUM_COUNTERS] = &ClientInterface::set_num_counters; for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) { FILE_LOG(logDEBUG1) << "function fnum: " << i << " (" << @@ -1319,4 +1319,12 @@ int ClientInterface::set_adc_mask_10g(Interface &socket) { } FILE_LOG(logDEBUG1) << "10Gb ADC enable mask retval: " << retval; return socket.sendResult(retval); +} + +int ClientInterface::set_num_counters(Interface &socket) { + auto arg = socket.Receive(); + verifyIdle(socket); + FILE_LOG(logDEBUG1) << "Setting counters: " << arg; + impl()->setNumberofCounters(arg); + return socket.Send(OK); } \ No newline at end of file diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index e8dd2d98d..55e0c4fb4 100755 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -101,6 +101,7 @@ void Implementation::InitializeMembers() { subPeriod = 0; numberOfAnalogSamples = 0; numberOfDigitalSamples = 0; + numberOfCounters = 0; dynamicRange = 16; roi.xmin = -1; roi.xmax = -1; @@ -1287,6 +1288,26 @@ void Implementation::setNumberofDigitalSamples(const uint32_t i) { << (generalData->packetsPerFrame); } +int Implementation::getNumberofCounters() const { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return numberOfCounters; +} + +void Implementation::setNumberofCounters(const int i) { + if (numberOfCounters != i) { + numberOfCounters = i; + + if (myDetectorType == MYTHEN3) { + generalData->SetDynamicRange(i, tengigaEnable); + // to update npixelsx, npixelsy in file writer + for (const auto &it : dataProcessor) + it->SetPixelDimension(); + SetupFifoStructure(); + } + } + FILE_LOG(logINFO) << "Number of Counters: " << numberOfCounters; +} + uint32_t Implementation::getDynamicRange() const { FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; return dynamicRange; @@ -1297,9 +1318,11 @@ void Implementation::setDynamicRange(const uint32_t i) { if (dynamicRange != i) { dynamicRange = i; - if (myDetectorType == EIGER) { + if (myDetectorType == EIGER || myDetectorType == MYTHEN3) { generalData->SetDynamicRange(i, tengigaEnable); - generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, quadEnable); + if (myDetectorType == EIGER) { + generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, quadEnable); + } // to update npixelsx, npixelsy in file writer for (const auto &it : dataProcessor) it->SetPixelDimension(); diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h index c814599c1..d2e2504e1 100755 --- a/slsSupportLib/include/sls_detector_funcs.h +++ b/slsSupportLib/include/sls_detector_funcs.h @@ -186,6 +186,8 @@ enum detFuncs{ F_SET_BURST_MODE, F_SET_ADC_ENABLE_MASK_10G, F_GET_ADC_ENABLE_MASK_10G, + F_SET_COUNTER_MASK, + F_GET_COUNTER_MASK, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */ @@ -256,6 +258,7 @@ enum detFuncs{ F_SET_RECEIVER_UDP_PORT2, F_SET_RECEIVER_NUM_INTERFACES, F_RECEIVER_SET_ADC_MASK_10G, + F_RECEIVER_SET_NUM_COUNTERS, NUM_REC_FUNCTIONS }; @@ -438,6 +441,9 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_BURST_MODE: return "F_SET_BURST_MODE"; case F_SET_ADC_ENABLE_MASK_10G: return "F_SET_ADC_ENABLE_MASK_10G"; case F_GET_ADC_ENABLE_MASK_10G: return "F_GET_ADC_ENABLE_MASK_10G"; + case F_SET_COUNTER_MASK: return "F_SET_COUNTER_MASK"; + case F_GET_COUNTER_MASK: return "F_GET_COUNTER_MASK"; + case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; @@ -509,6 +515,8 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_RECEIVER_UDP_PORT2: return "F_SET_RECEIVER_UDP_PORT2"; case F_SET_RECEIVER_NUM_INTERFACES: return "F_SET_RECEIVER_NUM_INTERFACES"; case F_RECEIVER_SET_ADC_MASK_10G: return "F_RECEIVER_SET_ADC_MASK_10G"; + case F_RECEIVER_SET_NUM_COUNTERS: return "F_RECEIVER_SET_NUM_COUNTERS"; + case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS"; default: return "Unknown Function"; diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index fc525b4c8..cef067710 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -8,5 +8,5 @@ #define APIGOTTHARD 0x191127 #define APIJUNGFRAU 0x191127 #define APICTB 0x191210 -#define APIMYTHEN3 0x191210 #define APIEIGER 0x200110 +#define APIMYTHEN3 0x200114