This commit is contained in:
Erik Frojdh
2021-03-31 16:26:36 +02:00
parent fa25340e5c
commit 01c785271f
9 changed files with 71 additions and 74 deletions

View File

@ -35,32 +35,6 @@ int getChipStatusRegister(){
return chipStatusRegister;
}
// int setGainCaps(int caps){
// int csr = getChipStatusRegister();
// int gain_mask = 0;
// gain_mask |= 1 << CSR_C10pre;
// gain_mask |= 1 << CSR_C15sh;
// gain_mask |= 1 << CSR_C30sh;
// gain_mask |= 1 << CSR_C50sh;
// gain_mask |= 1 << CSR_C225ACsh;
// gain_mask |= 1 << CSR_C15pre;
// LOG(logINFO, ("gain_mask: 0x%x\n", gain_mask));
// LOG(logINFO, ("csr: 0x%x\n", csr));
// csr &= ~gain_mask; //zero out the bits in the gain mask
// LOG(logINFO, ("csr: 0x%x\n", csr));
// caps &= gain_mask;
// csr |= caps;
// LOG(logINFO, ("csr: 0x%x\n", csr));
// //now comes the actual setting
// return 0;
// }
patternParameters *setChipStatusRegister(int csr) {
int iaddr=0;
int nbits=18;

View File

@ -1061,30 +1061,13 @@ int64_t getMeasurementTime() {
/* parameters - module, speed, readout */
int setModule(sls_detector_module myMod, char *mess) {
LOG(logINFO, ("Setting module\n"));
// settings
if (myMod.reg >= 0) {
setSettings((enum detectorSettings)myMod.reg);
if (getSettings() != (enum detectorSettings)myMod.reg) {
sprintf(
mess,
"Could not set module. Could not set settings to %d, read %d\n",
myMod.reg, (int)getSettings());
LOG(logERROR, (mess));
return FAIL;
}
detectorModules->reg = myMod.reg;
}
// custom trimbit file
else {
// changed for setsettings (direct),
// custom trimbit file (setmodule with myMod.reg as -1),
// change of dac (direct)
for (int i = 0; i < NCOUNTERS; ++i) {
setThresholdEnergy(i, -1);
}
if (setGainCaps(myMod.reg)){
sprintf(mess, "Could not set module gain caps\n");
LOG(logERROR, (mess));
return FAIL;
}
// dacs
@ -1108,24 +1091,12 @@ int setModule(sls_detector_module myMod, char *mess) {
}
}
// if settings given and cannot be validated (after setting dacs), return
// error
if (myMod.reg >= 0) {
if (getSettings() != (enum detectorSettings)myMod.reg) {
sprintf(
mess,
"Could not set module. The dacs in file do not correspond to "
"settings %d\n",
myMod.reg);
LOG(logERROR, (mess));
return FAIL;
}
}
// threshold
for (int i = 0; i < NCOUNTERS; ++i) {
if (myMod.eV[i] >= 0) {
setThresholdEnergy(i, myMod.eV[i]);
}else{
setThresholdEnergy(i, -1);
}
}

View File

@ -1549,18 +1549,11 @@ int set_module(int file_des) {
// only set
else if (Server_VerifyLock() == OK) {
// check index
#if !(defined(EIGERD) || defined(MYTHEN3D))
//TODO! Check if this is used for any detector
switch (module.reg) {
#ifdef EIGERD
case STANDARD:
case HIGHGAIN:
case LOWGAIN:
case VERYHIGHGAIN:
case VERYLOWGAIN:
#elif MYTHEN3D
case STANDARD:
case FAST:
case HIGHGAIN:
#elif JUNGFRAUD
#ifdef JUNGFRAUD
case DYNAMICGAIN:
case DYNAMICHG0:
case FIXGAIN1:
@ -1579,10 +1572,12 @@ int set_module(int file_des) {
modeNotImplemented("Settings", (int)module.reg);
break;
}
#endif
ret = setModule(module, mess);
enum detectorSettings retval = getSettings();
#if !(defined(EIGERD) || defined(MYTHEN3D))
validate(module.reg, (int)retval, "set module (settings)", DEC);
#endif
LOG(logDEBUG1, ("Settings: %d\n", retval));
}
free(myChan);