diff --git a/slsDetectorServers/ctbDetectorServer/RegisterDefs.h b/slsDetectorServers/ctbDetectorServer/RegisterDefs.h index ce7459b84..8494bf96f 100644 --- a/slsDetectorServers/ctbDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/ctbDetectorServer/RegisterDefs.h @@ -505,14 +505,15 @@ #define DBIT_EXT_TRG_OPRTN_MD_MSK (0x00000001 << DBIT_EXT_TRG_OPRTN_MD_OFST) /* Pin Delay 0 RW register */ -#define PIN_DELAY_0_REG (0x7C << MEM_MAP_SHIFT) +#define OUTPUT_DELAY_0_REG (0x7C << MEM_MAP_SHIFT) -#define PIN_DELAY_0_OTPT_STTNG_OFST (0) //t = OTPT_STTNG * 25 ps, max for Cyclone V = 775 ps -#define PIN_DELAY_0_OTPT_STTNG_MSK (0x0000001F << PIN_DELAY_0_OFST) -#define PIN_DELAY_0_OTPT_TRGGR_OFST (31) -#define PIN_DELAY_0_OTPT_TRGGR_MSK (0x00000001 << PIN_DELAY_0_OFST) -#define PIN_DELAY_0_OTPT_TRGGR_LD_VAL (1) -#define PIN_DELAY_0_OTPT_TRGGR_STRT_VAL (0) +#define OUTPUT_DELAY_0_OTPT_STTNG_OFST (0) //t = OTPT_STTNG * 25 ps, max for Cyclone V = 775 ps +#define OUTPUT_DELAY_0_OTPT_STTNG_MSK (0x0000001F << OUTPUT_DELAY_0_OFST) +// 1: load dynamic output settings, 0: trigger start of dynamic output delay configuration pn falling edge of ODT (output delay trigger) bit +#define OUTPUT_DELAY_0_OTPT_TRGGR_OFST (31) +#define OUTPUT_DELAY_0_OTPT_TRGGR_MSK (0x00000001 << OUTPUT_DELAY_0_OFST) +#define OUTPUT_DELAY_0_OTPT_TRGGR_LD_VAL (1) +#define OUTPUT_DELAY_0_OTPT_TRGGR_STRT_VAL (0) /* Pin Delay 1 RW register * Each bit configured as enable for dynamic output delay configuration */ diff --git a/slsDetectorServers/ctbDetectorServer/gitInfo.txt b/slsDetectorServers/ctbDetectorServer/gitInfo.txt index eb1c39724..add73c0d2 100644 --- a/slsDetectorServers/ctbDetectorServer/gitInfo.txt +++ b/slsDetectorServers/ctbDetectorServer/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorPackage/slsDetectorServers/ctbDetectorServer URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: 1fe473e830b937b05052fe69cb7bfccde451055a -Revision: 25 +Repsitory UUID: ebee9e308e98f518775d42685602febda9b763ea +Revision: 29 Branch: refactor Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4359 -Last Changed Date: 2019-02-26 16:09:45.000000002 +0100 ./Makefile +Last Changed Rev: 4365 +Last Changed Date: 2019-03-01 08:13:34.000000002 +0100 ./RegisterDefs.h diff --git a/slsDetectorServers/ctbDetectorServer/gitInfoCtb.h b/slsDetectorServers/ctbDetectorServer/gitInfoCtb.h index d4d705d9d..dd7e2b458 100644 --- a/slsDetectorServers/ctbDetectorServer/gitInfoCtb.h +++ b/slsDetectorServers/ctbDetectorServer/gitInfoCtb.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "1fe473e830b937b05052fe69cb7bfccde451055a" +#define GITREPUUID "ebee9e308e98f518775d42685602febda9b763ea" #define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4359 -#define GITDATE 0x20190226 +#define GITREV 0x4365 +#define GITDATE 0x20190301 #define GITBRANCH "refactor" diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index 2cbc75afd..c4868a166 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -2000,6 +2000,26 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) { } +int setLEDEnable(int enable) { + uint32_t addr = CONFIG_REG; + + // set + if (enable >= 0) { + FILE_LOG(logINFO, ("Switching LED %s\n", (enable > 0) ? "ON" : "OFF")); + // disable + if (enable == 0) { + bus_w(addr, bus_r(addr) | CONFIG_LED_DSBL_MSK); + } + // enable + else { + bus_w(addr, bus_r(addr) & (~CONFIG_LED_DSBL_MSK)); + } + } + // ~ to get the opposite + return (((~bus_r(addr)) & CONFIG_LED_DSBL_MSK) >> CONFIG_LED_DSBL_OFST); +} + + /* aquisition */ int startStateMachine(){ diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h index fbe6c6a36..b1bdf4c93 100644 --- a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h @@ -253,6 +253,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 setLEDEnable(int enable); #endif // gotthard specific - image, pedestal diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index 6335c8666..3da1f3913 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -211,6 +211,7 @@ const char* getFunctionName(enum detFuncs func) { case F_STORAGE_CELL_START: return "F_STORAGE_CELL_START"; case F_CHECK_VERSION: return "F_CHECK_VERSION"; case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER"; + case F_LED: return "F_LED"; default: return "Unknown Function"; } @@ -275,6 +276,7 @@ void function_table() { flist[F_STORAGE_CELL_START] = &storage_cell_start; flist[F_CHECK_VERSION] = &check_version; flist[F_SOFTWARE_TRIGGER] = &software_trigger; + flist[F_LED] = &led; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -3447,3 +3449,29 @@ int software_trigger(int file_des) { return Server_SendResult(file_des, INT32, UPDATE, NULL, 0); } + +int led(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG1, ("Setting led enable to %d\n", arg)); + +#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) + functionNotImplemented(); +#else + // set & get + if ((arg == -1) || (Server_VerifyLock() == OK)) { + retval = setLEDEnable(arg); + FILE_LOG(logDEBUG1, ("LED Enable: %d\n", retval)); + validate(arg, retval, "LED Enable", DEC); + } +#endif + return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval)); +} + + + diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h index dcf6a8b99..1ff099a26 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h @@ -79,4 +79,4 @@ int auto_comp_disable(int); int storage_cell_start(int); int check_version(int); int software_trigger(int); - +int led(int); diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 0b88fc87a..183fa148b 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -3595,6 +3595,17 @@ uint64_t multiSlsDetector::setCTBPatWaitTime(int level, uint64_t t, int detPos) return sls::minusOneIfDifferent(r); } +int multiSlsDetector::setLEDEnable(int enable, int detPos) { + // single + if (detPos >= 0) { + return detectors[detPos]->setLEDEnable(enable); + } + + // multi + auto r = parallelCall(&slsDetector::setLEDEnable, enable); + return sls::minusOneIfDifferent(r); +} + int multiSlsDetector::retrieveDetectorSetup(const std::string &fname1, int level) { diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 2c62a579b..5606ba6d9 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1735,6 +1735,14 @@ class multiSlsDetector : public virtual slsDetectorDefs, */ uint64_t setCTBPatWaitTime(int level, uint64_t t = -1, int detPos = -1); + /** + * Set LED Enable (Moench, CTB only) + * @param enable 1 to switch on, 0 to switch off, -1 gets + * @param detPos -1 for all detectors in list or specific detector position + * @returns LED enable + */ + int setLEDEnable(int enable = -1, int detPos = -1); + /** * Loads the detector setup from file * @param fname file to read from diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index e61b8d97e..700206bf5 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -5084,6 +5084,30 @@ uint64_t slsDetector::setCTBPatWaitTime(uint64_t level, uint64_t t) { return retval; } +int slsDetector::setLEDEnable(int enable) { + int fnum = F_LED; + int ret = FAIL; + int arg = enable; + int retval = -1; + FILE_LOG(logDEBUG1) << "Sending LED Enable: " << arg; + + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) { + auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort); + ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG1) << "LED Enable: " << retval; + } + } + if (ret == FORCE_UPDATE) { + ret = updateDetector(); + } + return retval; +} + slsDetectorDefs::sls_detector_module *slsDetector::interpolateTrim( sls_detector_module *a, sls_detector_module *b, const int energy, const int e1, const int e2, int tb) { diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 0ba9c9562..c8cf36e4b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1596,6 +1596,13 @@ public: */ uint64_t setCTBPatWaitTime(uint64_t level, uint64_t t=-1); + /** + * Set LED Enable (Moench, CTB only) + * @param enable 1 to switch on, 0 to switch off, -1 gets + * @returns LED enable + */ + int setLEDEnable(int enable = -1); + private: /** diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 2537f3028..4b66d8ce0 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -4621,18 +4621,14 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action, } else if (cmd == "led") { - char ans[100]; - int val = 0; myDet->setOnline(ONLINE_FLAG, detPos); if (action == PUT_ACTION) { int ival = -1; if (!sscanf(args[1], "%d", &ival)) - return std::string("could not scan powerchip parameter " + std::string(args[1])); - val = myDet->readRegister(0x4d, detPos); - myDet->writeRegister(0x4d, (val & (~1)) | ((~ival) & 1), detPos); //config register + return std::string("could not scan led parameter " + std::string(args[1])); + myDet->setLEDEnable(ival, detPos); } - sprintf(ans, "%d", ~(myDet->readRegister(0x4d, detPos)) & 1); - return std::string(ans); + return std::to_string(myDet->setLEDEnable(-1, detPos)); } else if (cmd == "auto_comp_disable") { diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h index 5b88f7fbc..2df68ef83 100644 --- a/slsSupportLib/include/sls_detector_funcs.h +++ b/slsSupportLib/include/sls_detector_funcs.h @@ -68,6 +68,7 @@ enum detFuncs{ F_STORAGE_CELL_START, /** < storage cell start */ F_CHECK_VERSION,/** < check version compatibility */ F_SOFTWARE_TRIGGER,/** < software trigger */ + F_LED, /** < switch on/off led */ NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 128, /**< detector function should not exceed this (detector server should not compile anyway) */ @@ -184,6 +185,7 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) { case F_STORAGE_CELL_START: return "F_STORAGE_CELL_START"; case F_CHECK_VERSION: return "F_CHECK_VERSION"; case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER"; + case F_LED: return "F_LED"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";