ctb, moench, eiger, gotthard: get number of channels for moench and ctb, others removed unnecessary variables in shm, added moench virtual sever (#86)

This commit is contained in:
Dhanya Thattil
2020-03-10 09:08:08 +01:00
committed by GitHub
parent 013836bea5
commit 758afad02c
16 changed files with 156 additions and 304 deletions

View File

@ -4,4 +4,5 @@ add_subdirectory(gotthardDetectorServer)
add_subdirectory(jungfrauDetectorServer)
#add_subdirectory(moenchDetectorServer)
add_subdirectory(mythen3DetectorServer)
add_subdirectory(gotthard2DetectorServer)
add_subdirectory(gotthard2DetectorServer)
add_subdirectory(moenchDetectorServer)

View File

@ -2552,9 +2552,39 @@ int calculateDataBytes(){
return dataBytes;
}
int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}
int getTotalNumberOfChannels() {
int nchanx = 0, nchany = 0;
getTotalNumberOfChannels(&nchanx, &nchany);
return nchanx * nchany;
}
int getNumberOfChannels(int* nchanx, int* nchany) {
int nachans = 0, ndchans = 0;
// analog channels (normal, analog/digital readout)
if (analogEnable) {
uint32_t mask = enableTenGigabitEthernet(-1) ? adcEnableMask_10g : adcEnableMask_1g;
if (mask == BIT32_MASK) {
nachans = NCHAN_ANALOG;
} else {
int ich = 0;
for (ich = 0; ich < NCHAN_ANALOG; ++ich) {
if ((mask & (1 << ich)) != 0U)
++nachans;
}
}
FILE_LOG(logDEBUG1, ("Analog Channels: %d\n", nachans));
}
// digital channels (digital, analog/digital readout)
if (digitalEnable) {
ndchans = 64;
FILE_LOG(logDEBUG, ("Digital Channels: %d\n", ndchans));
}
*nchanx = nachans + ndchans;
FILE_LOG(logDEBUG, ("Total #Channels: %d\n", *nchanx));
*nchany = 1;
}
int getNumberOfChips(){return NCHIP;}
int getNumberOfDACs(){return NDAC;}
int getNumberOfChannelsPerChip(){return NCHAN;}

View File

@ -2177,9 +2177,26 @@ int calculateDataBytes(){
return dataBytes;
}
int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}
int getTotalNumberOfChannels() {
int nchanx = 0, nchany = 0;
getTotalNumberOfChannels(&nchanx, &nchany);
return nchanx * nchany;
}
int getNumberOfChannels(int* nchanx, int* nchany) {
uint32_t mask = enableTenGigabitEthernet(-1) ? adcEnableMask_10g : adcEnableMask_1g;
// count number of channels in x, each adc has 25 channels each
int nchanTop = __builtin_popcount(mask & 0xF0F0F0F0) * NCHANS_PER_ADC;
int nchanBot = __builtin_popcount(mask & 0x0F0F0F0F) * NCHANS_PER_ADC;
*nchanx = nchanTop > 0 ? nchanTop : nchanBot;
// if both top and bottom adcs enabled, rows = 2
int nrows = 1;
if (nchanTop > 0 && nchanBot > 0) {
nrows = 2;
}
*nchany = nSamples / NSAMPLES_PER_ROW * nrows;
}
int getNumberOfChips(){return NCHIP;}
int getNumberOfDACs(){return NDAC;}
int getNumberOfChannelsPerChip(){return NCHAN;}

View File

@ -59,6 +59,7 @@ enum CLKINDEX {RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS};
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
#define CLK_FREQ (156.25) /* MHz */
#define NSAMPLES_PER_ROW (25)
#define NCHANS_PER_ADC (25)
/** Default Parameters */
#define DEFAULT_PATTERN_FILE ("DefaultPattern.txt")

View File

@ -574,8 +574,12 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);
#endif
int calculateDataBytes();
int getTotalNumberOfChannels();
#if defined(MOENCHD) || defined(CHIPTESTBOARDD)
int getNumberOfChannels(int* nchanx, int* nchany);
#endif
int getNumberOfChips();
int getNumberOfDACs();
int getNumberOfChannelsPerChip();

View File

@ -216,3 +216,4 @@ int get_current_source(int);
int set_current_source(int);
int get_timing_source(int);
int set_timing_source(int);
int get_num_channels(int);

View File

@ -316,6 +316,7 @@ const char* getFunctionName(enum detFuncs func) {
case F_SET_CURRENT_SOURCE: return "F_SET_CURRENT_SOURCE";
case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE";
case F_SET_TIMING_SOURCE: return "F_SET_TIMING_SOURCE";
case F_GET_NUM_CHANNELS: return "F_GET_NUM_CHANNELS";
default: return "Unknown Function";
}
@ -508,6 +509,7 @@ void function_table() {
flist[F_SET_CURRENT_SOURCE] = &set_current_source;
flist[F_GET_TIMING_SOURCE] = &get_timing_source;
flist[F_SET_TIMING_SOURCE] = &set_timing_source;
flist[F_GET_NUM_CHANNELS] = &get_num_channels;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -2833,19 +2835,12 @@ int send_update(int file_des) {
if (n < 0) return printSocketReadError();
#endif
// threshold energy
#ifdef EIGERD
i32 = getThresholdEnergy(GET_FLAG);
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
#endif
// #frames
i64 = getNumFrames();
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
// #storage cell, storage_cell_delay
// #storage cell
#ifdef JUNGFRAUD
i64 = getNumAdditionalStorageCells();
n = sendData(file_des,&i64,sizeof(i64),INT64);
@ -2876,42 +2871,18 @@ int send_update(int file_des) {
if (n < 0) return printSocketReadError();
#endif
// readout mode
#ifdef CHIPTESTBOARDD
i32 = getReadoutMode();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
#endif
// roi
#if defined(GOTTHARDD)
ROI retval = getROI();
sendData(file_des, &retval.xmin, sizeof(int), INT32);
sendData(file_des, &retval.xmax, sizeof(int), INT32);
#endif
// tengiga
#if defined(EIGERD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
i32 = enableTenGigabitEthernet(-1);
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
#endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
// analog samples
i32 = getNumAnalogSamples();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
// 1g adcmask
i32 = getADCEnableMask();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
// 10g adc mask
i32 = getADCEnableMask_10G();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
// number of channels
#if defined(MOENCHD) || defined(CHIPTESTBOARDD)
{
int nx = 0, ny = 0;
getNumberOfChannels(&nx, &ny);
i32 = nx;
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
i32 = ny;
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
}
#endif
// num udp interfaces
@ -6887,4 +6858,22 @@ int get_timing_source(int file_des) {
FILE_LOG(logDEBUG1, ("Get timing source retval:%d\n", retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}
int get_num_channels(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retvals[2] = {-1, -1};
FILE_LOG(logDEBUG1, ("Getting number of channels\n"));
#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
// get only
getNumberOfChannels(&retvals[0], &retvals[1]);
FILE_LOG(logDEBUG1, ("Get number of channels sretval:[%d, %d]\n", retvals[0], retvals[1]));
#endif
return Server_SendResult(file_des, INT32, UPDATE, retvals, sizeof(retvals));
}