mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 04:47:14 +02:00
ctb, moench: implemented led enable feature
This commit is contained in:
@ -505,14 +505,15 @@
|
|||||||
#define DBIT_EXT_TRG_OPRTN_MD_MSK (0x00000001 << DBIT_EXT_TRG_OPRTN_MD_OFST)
|
#define DBIT_EXT_TRG_OPRTN_MD_MSK (0x00000001 << DBIT_EXT_TRG_OPRTN_MD_OFST)
|
||||||
|
|
||||||
/* Pin Delay 0 RW register */
|
/* 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 OUTPUT_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 OUTPUT_DELAY_0_OTPT_STTNG_MSK (0x0000001F << OUTPUT_DELAY_0_OFST)
|
||||||
#define PIN_DELAY_0_OTPT_TRGGR_OFST (31)
|
// 1: load dynamic output settings, 0: trigger start of dynamic output delay configuration pn falling edge of ODT (output delay trigger) bit
|
||||||
#define PIN_DELAY_0_OTPT_TRGGR_MSK (0x00000001 << PIN_DELAY_0_OFST)
|
#define OUTPUT_DELAY_0_OTPT_TRGGR_OFST (31)
|
||||||
#define PIN_DELAY_0_OTPT_TRGGR_LD_VAL (1)
|
#define OUTPUT_DELAY_0_OTPT_TRGGR_MSK (0x00000001 << OUTPUT_DELAY_0_OFST)
|
||||||
#define PIN_DELAY_0_OTPT_TRGGR_STRT_VAL (0)
|
#define OUTPUT_DELAY_0_OTPT_TRGGR_LD_VAL (1)
|
||||||
|
#define OUTPUT_DELAY_0_OTPT_TRGGR_STRT_VAL (0)
|
||||||
|
|
||||||
/* Pin Delay 1 RW register
|
/* Pin Delay 1 RW register
|
||||||
* Each bit configured as enable for dynamic output delay configuration */
|
* Each bit configured as enable for dynamic output delay configuration */
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
Path: slsDetectorPackage/slsDetectorServers/ctbDetectorServer
|
Path: slsDetectorPackage/slsDetectorServers/ctbDetectorServer
|
||||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repsitory UUID: 1fe473e830b937b05052fe69cb7bfccde451055a
|
Repsitory UUID: ebee9e308e98f518775d42685602febda9b763ea
|
||||||
Revision: 25
|
Revision: 29
|
||||||
Branch: refactor
|
Branch: refactor
|
||||||
Last Changed Author: Dhanya_Thattil
|
Last Changed Author: Dhanya_Thattil
|
||||||
Last Changed Rev: 4359
|
Last Changed Rev: 4365
|
||||||
Last Changed Date: 2019-02-26 16:09:45.000000002 +0100 ./Makefile
|
Last Changed Date: 2019-03-01 08:13:34.000000002 +0100 ./RegisterDefs.h
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||||
#define GITREPUUID "1fe473e830b937b05052fe69cb7bfccde451055a"
|
#define GITREPUUID "ebee9e308e98f518775d42685602febda9b763ea"
|
||||||
#define GITAUTH "Dhanya_Thattil"
|
#define GITAUTH "Dhanya_Thattil"
|
||||||
#define GITREV 0x4359
|
#define GITREV 0x4365
|
||||||
#define GITDATE 0x20190226
|
#define GITDATE 0x20190301
|
||||||
#define GITBRANCH "refactor"
|
#define GITBRANCH "refactor"
|
||||||
|
@ -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 */
|
/* aquisition */
|
||||||
|
|
||||||
int startStateMachine(){
|
int startStateMachine(){
|
||||||
|
@ -253,6 +253,7 @@ uint64_t writePatternWord(int addr, uint64_t word);
|
|||||||
int setPatternWaitAddress(int level, int addr);
|
int setPatternWaitAddress(int level, int addr);
|
||||||
uint64_t setPatternWaitTime(int level, uint64_t t);
|
uint64_t setPatternWaitTime(int level, uint64_t t);
|
||||||
void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop);
|
void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop);
|
||||||
|
int setLEDEnable(int enable);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// gotthard specific - image, pedestal
|
// gotthard specific - image, pedestal
|
||||||
|
@ -211,6 +211,7 @@ const char* getFunctionName(enum detFuncs func) {
|
|||||||
case F_STORAGE_CELL_START: return "F_STORAGE_CELL_START";
|
case F_STORAGE_CELL_START: return "F_STORAGE_CELL_START";
|
||||||
case F_CHECK_VERSION: return "F_CHECK_VERSION";
|
case F_CHECK_VERSION: return "F_CHECK_VERSION";
|
||||||
case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
|
case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
|
||||||
|
case F_LED: return "F_LED";
|
||||||
|
|
||||||
default: return "Unknown Function";
|
default: return "Unknown Function";
|
||||||
}
|
}
|
||||||
@ -275,6 +276,7 @@ void function_table() {
|
|||||||
flist[F_STORAGE_CELL_START] = &storage_cell_start;
|
flist[F_STORAGE_CELL_START] = &storage_cell_start;
|
||||||
flist[F_CHECK_VERSION] = &check_version;
|
flist[F_CHECK_VERSION] = &check_version;
|
||||||
flist[F_SOFTWARE_TRIGGER] = &software_trigger;
|
flist[F_SOFTWARE_TRIGGER] = &software_trigger;
|
||||||
|
flist[F_LED] = &led;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
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);
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,4 +79,4 @@ int auto_comp_disable(int);
|
|||||||
int storage_cell_start(int);
|
int storage_cell_start(int);
|
||||||
int check_version(int);
|
int check_version(int);
|
||||||
int software_trigger(int);
|
int software_trigger(int);
|
||||||
|
int led(int);
|
||||||
|
@ -3595,6 +3595,17 @@ uint64_t multiSlsDetector::setCTBPatWaitTime(int level, uint64_t t, int detPos)
|
|||||||
return sls::minusOneIfDifferent(r);
|
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 multiSlsDetector::retrieveDetectorSetup(const std::string &fname1,
|
||||||
int level) {
|
int level) {
|
||||||
|
|
||||||
|
@ -1735,6 +1735,14 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
|||||||
*/
|
*/
|
||||||
uint64_t setCTBPatWaitTime(int level, uint64_t t = -1, int detPos = -1);
|
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
|
* Loads the detector setup from file
|
||||||
* @param fname file to read from
|
* @param fname file to read from
|
||||||
|
@ -5084,6 +5084,30 @@ uint64_t slsDetector::setCTBPatWaitTime(uint64_t level, uint64_t t) {
|
|||||||
return retval;
|
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(
|
slsDetectorDefs::sls_detector_module *slsDetector::interpolateTrim(
|
||||||
sls_detector_module *a, sls_detector_module *b,
|
sls_detector_module *a, sls_detector_module *b,
|
||||||
const int energy, const int e1, const int e2, int tb) {
|
const int energy, const int e1, const int e2, int tb) {
|
||||||
|
@ -1596,6 +1596,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
uint64_t setCTBPatWaitTime(uint64_t level, uint64_t t=-1);
|
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:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4621,18 +4621,14 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd == "led") {
|
else if (cmd == "led") {
|
||||||
char ans[100];
|
|
||||||
int val = 0;
|
|
||||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||||
if (action == PUT_ACTION) {
|
if (action == PUT_ACTION) {
|
||||||
int ival = -1;
|
int ival = -1;
|
||||||
if (!sscanf(args[1], "%d", &ival))
|
if (!sscanf(args[1], "%d", &ival))
|
||||||
return std::string("could not scan powerchip parameter " + std::string(args[1]));
|
return std::string("could not scan led parameter " + std::string(args[1]));
|
||||||
val = myDet->readRegister(0x4d, detPos);
|
myDet->setLEDEnable(ival, detPos);
|
||||||
myDet->writeRegister(0x4d, (val & (~1)) | ((~ival) & 1), detPos); //config register
|
|
||||||
}
|
}
|
||||||
sprintf(ans, "%d", ~(myDet->readRegister(0x4d, detPos)) & 1);
|
return std::to_string(myDet->setLEDEnable(-1, detPos));
|
||||||
return std::string(ans);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd == "auto_comp_disable") {
|
else if (cmd == "auto_comp_disable") {
|
||||||
|
@ -68,6 +68,7 @@ enum detFuncs{
|
|||||||
F_STORAGE_CELL_START, /** < storage cell start */
|
F_STORAGE_CELL_START, /** < storage cell start */
|
||||||
F_CHECK_VERSION,/** < check version compatibility */
|
F_CHECK_VERSION,/** < check version compatibility */
|
||||||
F_SOFTWARE_TRIGGER,/** < software trigger */
|
F_SOFTWARE_TRIGGER,/** < software trigger */
|
||||||
|
F_LED, /** < switch on/off led */
|
||||||
NUM_DET_FUNCTIONS,
|
NUM_DET_FUNCTIONS,
|
||||||
|
|
||||||
RECEIVER_ENUM_START = 128, /**< detector function should not exceed this (detector server should not compile anyway) */
|
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_STORAGE_CELL_START: return "F_STORAGE_CELL_START";
|
||||||
case F_CHECK_VERSION: return "F_CHECK_VERSION";
|
case F_CHECK_VERSION: return "F_CHECK_VERSION";
|
||||||
case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
|
case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
|
||||||
|
case F_LED: return "F_LED";
|
||||||
|
|
||||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||||
|
Reference in New Issue
Block a user