mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
veto file in
This commit is contained in:
@ -1803,29 +1803,31 @@ int setVetoPhoton(int chipIndex, int gainIndex, int *values) {
|
||||
("Setting veto photon [chip:%d, G%d]\n", chipIndex, gainIndex));
|
||||
|
||||
// add gain bits
|
||||
{
|
||||
int gainValue = 0;
|
||||
switch (gainIndex) {
|
||||
case 0:
|
||||
gainValue = ASIC_G0_VAL;
|
||||
break;
|
||||
case 1:
|
||||
gainValue = ASIC_G1_VAL;
|
||||
break;
|
||||
case 2:
|
||||
gainValue = ASIC_G2_VAL;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Unknown gain index %d\n", gainIndex));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG2, ("Adding gain bits\n"));
|
||||
for (int i = 0; i < NCHAN; ++i) {
|
||||
values[i] |= gainValue;
|
||||
LOG(logDEBUG2, ("Value %d: 0x%x\n", i, values[i]));
|
||||
}
|
||||
int gainValue = 0;
|
||||
switch (gainIndex) {
|
||||
case 0:
|
||||
gainValue = ASIC_G0_VAL;
|
||||
break;
|
||||
case 1:
|
||||
gainValue = ASIC_G1_VAL;
|
||||
break;
|
||||
case 2:
|
||||
gainValue = ASIC_G2_VAL;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Unknown gain index %d\n", gainIndex));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG2, ("Adding gain bits\n"));
|
||||
for (int i = 0; i < NCHAN; ++i) {
|
||||
values[i] |= gainValue;
|
||||
LOG(logDEBUG2, ("Value %d: 0x%x\n", i, values[i]));
|
||||
}
|
||||
|
||||
return configureASICVetoReference(chipIndex, values);
|
||||
}
|
||||
|
||||
int configureASICVetoReference(int chipIndex, int *values) {
|
||||
const int lenDataBitsPerchannel = ASIC_GAIN_MAX_BITS + ADU_MAX_BITS; // 14
|
||||
const int lenBits = lenDataBitsPerchannel * NCHAN; // 1792
|
||||
const int padding = 4; // due to address (4) to make it byte aligned
|
||||
@ -1906,6 +1908,32 @@ int getVetoPhoton(int chipIndex, int *retvals) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setVetoFile(int chipIndex, int *gainIndices, int *values) {
|
||||
LOG(logINFO, ("Setting veto file [chip:%d]\n", chipIndex));
|
||||
|
||||
// correct gain bits and integrate into values
|
||||
for (int i = 0; i < NCHAN; ++i) {
|
||||
switch (gainIndices[i]) {
|
||||
case 0:
|
||||
gainIndices[i] = ASIC_G0_VAL;
|
||||
break;
|
||||
case 1:
|
||||
gainIndices[i] = ASIC_G1_VAL;
|
||||
break;
|
||||
case 2:
|
||||
gainIndices[i] = ASIC_G2_VAL;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("Unknown gain index %d for channel %d\n", gainIndices[i], i));
|
||||
return FAIL;
|
||||
}
|
||||
values[i] |= gainIndices[i];
|
||||
LOG(logDEBUG2, ("Values[%d]: 0x%x\n", i, values[i]));
|
||||
}
|
||||
return configureASICVetoReference(chipIndex, values);
|
||||
}
|
||||
|
||||
int configureSingleADCDriver(int chipIndex) {
|
||||
LOG(logINFO, ("Configuring ADC for %s chips [chipIndex:%d Burst Mode:%d]\n",
|
||||
chipIndex == -1 ? "All" : "Single", chipIndex, burstMode));
|
||||
|
@ -504,7 +504,9 @@ int setInjectChannel(int offset, int increment);
|
||||
void getInjectedChannels(int *offset, int *increment);
|
||||
int setVetoReference(int gainIndex, int value);
|
||||
int setVetoPhoton(int chipIndex, int gainIndex, int *values);
|
||||
int configureASICVetoReference(int chipIndex, int *values);
|
||||
int getVetoPhoton(int chipIndex, int *retvals);
|
||||
int setVetoFile(int chipIndex, int *gainIndices, int *values);
|
||||
int configureSingleADCDriver(int chipIndex);
|
||||
int configureADC();
|
||||
int setBurstModeinFPGA(enum burstMode value);
|
||||
|
@ -233,3 +233,4 @@ int get_cds_gain(int);
|
||||
int set_cds_gain(int);
|
||||
int get_filter(int);
|
||||
int set_filter(int);
|
||||
int set_veto_file(int);
|
@ -350,6 +350,7 @@ void function_table() {
|
||||
flist[F_SET_CDS_GAIN] = &set_cds_gain;
|
||||
flist[F_GET_FILTER] = &get_filter;
|
||||
flist[F_SET_FILTER] = &set_filter;
|
||||
flist[F_SET_VETO_FILE] = &set_veto_file;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -6319,6 +6320,7 @@ int set_veto_photon(int file_des) {
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
int values[args[2]];
|
||||
memset(values, 0, sizeof(values));
|
||||
if (receiveData(file_des, values, sizeof(values), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting Veto Photon: [chipIndex:%d, G%d, nch:%d]\n", args[0],
|
||||
@ -6356,7 +6358,7 @@ int set_veto_photon(int file_des) {
|
||||
sprintf(mess,
|
||||
"Could not set veto photon. Invalid ADU value 0x%x "
|
||||
"for channel %d, must be 12 bit.\n",
|
||||
i, values[i]);
|
||||
values[i], i);
|
||||
LOG(logERROR, (mess));
|
||||
break;
|
||||
}
|
||||
@ -7746,3 +7748,75 @@ int set_filter(int file_des) {
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int set_veto_file(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int args[2] = {-1, -1};
|
||||
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
int chipIndex = args[0];
|
||||
int nch = args[1];
|
||||
int gainIndices[nch];
|
||||
memset(gainIndices, 0, sizeof(gainIndices));
|
||||
int values[nch];
|
||||
memset(values, 0, sizeof(values));
|
||||
if (receiveData(file_des, gainIndices, sizeof(gainIndices), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
if (receiveData(file_des, values, sizeof(values), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO,
|
||||
("Setting Veto file: [chipIndex:%d, nch:%d]\n", chipIndex, nch));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (chipIndex < -1 || chipIndex >= NCHIP) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set veto file. Invalid chip index %d\n",
|
||||
chipIndex);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (nch != NCHAN) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set veto file. Invalid number of channels %d. "
|
||||
"Expected %d\n",
|
||||
nch, NCHAN);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
for (int i = 0; i < NCHAN; ++i) {
|
||||
if (values[i] < 0 || values[i] > ADU_MAX_VAL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set veto file. Invalid ADU value 0x%x "
|
||||
"for channel %d, must be 12 bit.\n",
|
||||
values[i], i);
|
||||
LOG(logERROR, (mess));
|
||||
break;
|
||||
}
|
||||
if (gainIndices[i] < 0 || gainIndices[i] > 2) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set veto file. Invalid gain index %d "
|
||||
"for channel %d\n",
|
||||
gainIndices[i], i);
|
||||
LOG(logERROR, (mess));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ret == OK) {
|
||||
ret = setVetoFile(chipIndex, gainIndices, values);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set veto file for chip index %d\n",
|
||||
chipIndex);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
Reference in New Issue
Block a user