Jf: Electron collection mode (#983)

* electron collection mode for jungfrau. also removing the config chip when using register command
* collectionMode: HOLE/ELECTRON (enum)
This commit is contained in:
2024-09-30 17:15:22 +02:00
committed by GitHub
parent 7fa5b5d70a
commit 5b832cb6aa
30 changed files with 32158 additions and 21441 deletions

View File

@ -607,6 +607,8 @@ uint64_t getSelectCurrentSource();
int getPedestalMode();
void getPedestalParameters(uint8_t *frames, uint16_t *loops);
void setPedestalMode(int enable, uint8_t frames, uint16_t loops);
int getElectronCollectionMode();
void setElectronCollectionMode(int enable);
#endif
// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter

View File

@ -330,3 +330,5 @@ int setColumn(int);
int get_pedestal_mode(int);
int set_pedestal_mode(int);
int config_transceiver(int);
int get_collection_mode(int);
int set_collection_mode(int);

View File

@ -85,21 +85,7 @@ u_int32_t readRegister(u_int32_t offset) {
}
void writeRegister(u_int32_t offset, u_int32_t data) {
// if electron mode bit touched
#ifdef JUNGFRAUD
int electronCollectionModeChange = 0;
if ((offset << MEM_MAP_SHIFT) == DAQ_REG) {
if ((readRegister(offset) ^ data) & DAQ_ELCTRN_CLLCTN_MDE_MSK) {
electronCollectionModeChange = 1;
}
}
#endif
bus_w(offset << MEM_MAP_SHIFT, data);
#ifdef JUNGFRAUD
if (electronCollectionModeChange) {
configureChip();
}
#endif
}
u_int32_t readRegister16(u_int32_t offset) {

View File

@ -492,6 +492,8 @@ void function_table() {
flist[F_GET_PEDESTAL_MODE] = &get_pedestal_mode;
flist[F_SET_PEDESTAL_MODE] = &set_pedestal_mode;
flist[F_CONFIG_TRANSCEIVER] = &config_transceiver;
flist[F_GET_COLLECTION_MODE] = &get_collection_mode;
flist[F_SET_COLLECTION_MODE] = &set_collection_mode;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -11086,3 +11088,62 @@ int config_transceiver(int file_des) {
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_collection_mode(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum collectionMode retval = HOLE;
LOG(logDEBUG1, ("Getting collection mode\n"));
#ifndef JUNGFRAUD
functionNotImplemented();
#else
// get only
retval = getElectronCollectionMode() ? ELECTRON : HOLE;
LOG(logDEBUG1, ("collection mode retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_collection_mode(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum collectionMode arg = HOLE;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logDEBUG1, ("Setting collection mode: %u\n", (int)arg));
#ifndef JUNGFRAUD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (getChipVersion() == 11) {
ret = FAIL;
sprintf(mess,
"Cannot set addl. number of storage cells for chip v1.1\n");
LOG(logERROR, (mess));
} else {
switch (arg) {
case HOLE:
setElectronCollectionMode(0);
break;
case ELECTRON:
setElectronCollectionMode(1);
break;
default:
modeNotImplemented("Collection mode index", (int)arg);
break;
}
enum collectionMode retval =
getElectronCollectionMode() ? ELECTRON : HOLE;
validate(&ret, mess, (int)arg, (int)retval, "set collection mode",
DEC);
LOG(logDEBUG1, ("collection mode retval: %u\n", retval));
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}