still updating slsdetector.cpp

This commit is contained in:
2018-10-26 17:40:18 +02:00
parent cf87b6ca83
commit 33ac63d14a
16 changed files with 1501 additions and 2523 deletions

View File

@ -24,7 +24,6 @@ const char* dac_names[16] = {"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","V
int default_tau_from_file= -1; int default_tau_from_file= -1;
enum detectorSettings thisSettings; enum detectorSettings thisSettings;
sls_detector_module *detectorModules=NULL; sls_detector_module *detectorModules=NULL;
int *detectorChips=NULL;
int *detectorChans=NULL; int *detectorChans=NULL;
int *detectorDacs=NULL; int *detectorDacs=NULL;
int *detectorAdcs=NULL; int *detectorAdcs=NULL;
@ -383,26 +382,24 @@ void allocateDetectorStructureMemory() {
//Allocation of memory //Allocation of memory
detectorModules=malloc(sizeof(sls_detector_module)); detectorModules=malloc(sizeof(sls_detector_module));
detectorChips=malloc(NCHIP*sizeof(int));
detectorChans=malloc(NCHIP*NCHAN*sizeof(int)); detectorChans=malloc(NCHIP*NCHAN*sizeof(int));
detectorDacs=malloc(NDAC*sizeof(int)); detectorDacs=malloc(NDAC*sizeof(int));
detectorAdcs=malloc(NADC*sizeof(int)); detectorAdcs=malloc(NADC*sizeof(int));
FILE_LOG(logDEBUG5, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules)); FILE_LOG(logDEBUG5, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules));
FILE_LOG(logDEBUG5, ("chips from 0x%x to 0x%x\n",detectorChips, detectorChips));
FILE_LOG(logDEBUG5, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans)); FILE_LOG(logDEBUG5, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans));
FILE_LOG(logDEBUG5, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs)); FILE_LOG(logDEBUG5, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs));
FILE_LOG(logDEBUG5, ("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs)); FILE_LOG(logDEBUG5, ("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs));
(detectorModules)->dacs=detectorDacs; (detectorModules)->dacs=detectorDacs;
(detectorModules)->adcs=detectorAdcs; (detectorModules)->adcs=detectorAdcs;
(detectorModules)->chipregs=detectorChips;
(detectorModules)->chanregs=detectorChans; (detectorModules)->chanregs=detectorChans;
(detectorModules)->ndac=NDAC; (detectorModules)->ndac=NDAC;
(detectorModules)->nadc=NADC; (detectorModules)->nadc=NADC;
(detectorModules)->nchip=NCHIP; (detectorModules)->nchip=NCHIP;
(detectorModules)->nchan=NCHIP*NCHAN; (detectorModules)->nchan=NCHIP*NCHAN;
(detectorModules)->gain=0;
(detectorModules)->offset=0;
(detectorModules)->reg=0; (detectorModules)->reg=0;
(detectorModules)->iodelay=0;
(detectorModules)->tau=0;
(detectorModules)->eV=0;
thisSettings = UNINITIALIZED; thisSettings = UNINITIALIZED;
// if trimval requested, should return -1 to acknowledge unknown // if trimval requested, should return -1 to acknowledge unknown
@ -805,63 +802,123 @@ int64_t getTimeLeft(enum timerIndex ind) {
/* parameters - channel, chip, module, settings */ /* parameters - channel, module, settings */
int setModule(sls_detector_module myMod, int delay) { int setModule(sls_detector_module myMod, char* mess) {
int retval[2];
int i;
FILE_LOG(logINFO, ("Setting module with settings %d\n",myMod.reg)); FILE_LOG(logINFO, ("Setting module with settings %d\n",myMod.reg));
//copy module locally (module number, serial number, gain offset,
//dacs (pointless), trimbit values(if needed)
if (detectorModules)
if (copyModule(detectorModules,&myMod) == FAIL)
return FAIL;
// settings // settings
setSettings( (enum detectorSettings)myMod.reg); setSettings( (enum detectorSettings)myMod.reg);
//copy module locally (module number, serial number
//dacs (pointless), trimbit values(if needed)
if (detectorModules) {
if (copyModule(detectorModules,&myMod) == FAIL) {
sprintf(mess, "Could not copy module\n");
FILE_LOG(logERROR, (mess));
setSettings(UNDEFINED);
FILE_LOG(logERROR, ("Settings has been changed to undefined\n"));
return FAIL;
}
}
// iodelay // iodelay
if (setIODelay(delay)!= delay) { if (setIODelay(myMod.iodelay)!= myMod.iodelay) {
FILE_LOG(logERROR, ("Could not set iodelay %d\n", delay)); sprintf(mess, "Could not set module. Could not set iodelay %d\n", myMod.iodelay);
FILE_LOG(logERROR, (mess));
setSettings(UNDEFINED);
FILE_LOG(logERROR, ("Settings has been changed to undefined\n"));
return FAIL; return FAIL;
} }
// dacs // threshold
for(i=0;i<myMod.ndac;i++) if (myMod.eV >= 0)
setDAC((enum DACINDEX)i,myMod.dacs[i],0,retval); setThresholdEnergy(myMod.eV);
else {
// (loading a random trim file) (dont return fail)
setSettings(UNDEFINED);
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
}
// dacs
{
int i = 0;
int retval[2] = {0, 0};
for(i = 0; i < myMod.ndac; ++i) {
setDAC((enum DACINDEX)i, myMod.dacs[i] , 0, retval);
if (myMod.dacs[i] != retval[0]) {
sprintf(mess, "Could not set module. Could not set dac %d\n", i);
FILE_LOG(logERROR, (mess));
setSettings(UNDEFINED);
FILE_LOG(logERROR, ("Settings has been changed to undefined\n"));
return FAIL;
}
}
}
// trimbits // trimbits
#ifndef VIRTUAL #ifndef VIRTUAL
if (myMod.nchan==0 && myMod.nchip == 0) { if (myMod.nchan == 0) {
FILE_LOG(logINFO, ("Setting module without trimbits\n")); FILE_LOG(logINFO, ("Setting module without trimbits\n"));
} else { } else {
FILE_LOG(logINFO, ("Setting module with trimbits\n")); FILE_LOG(logINFO, ("Setting module with trimbits\n"));
//includ gap pixels //includ gap pixels
unsigned int tt[263680]; unsigned int tt[263680];
int iy,ichip,ix,ip=0,ich=0; int iy, ichip, ix, ip = 0, ich = 0;
for(iy=0;iy<256;iy++) { for (iy = 0; iy < 256; ++iy) {
for (ichip=0; ichip<4; ichip++) { for (ichip = 0; ichip < 4; ++ichip) {
for(ix=0;ix<256;ix++) { for (ix = 0; ix < 256; ++ix) {
tt[ip++]=myMod.chanregs[ich++]; tt[ip++] = myMod.chanregs[ich++];
} }
if (ichip<3) { if (ichip < 3) {
tt[ip++]=0; tt[ip++] = 0;
tt[ip++]=0; tt[ip++] = 0;
} }
} }
} }
//set trimbits //set trimbits
if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt)) { if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(), tt)) {
FILE_LOG(logERROR, ("Could not set trimbits\n")); sprintf(mess, "Could not set module. Could not set trimbits\n");
FILE_LOG(logERROR, (mess));
setSettings(UNDEFINED);
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
return FAIL; return FAIL;
} }
} }
//rate correction
//switch off rate correction: no value read from load settings)
if (myMod.tau == -1) {
if (getRateCorrectionEnable()) {
setRateCorrection(0);
sprintf(mess,"Cannot set module. Cannot set Rate correction. "
"No default tau provided. Deactivating Rate Correction\n");
FILE_LOG(logERROR, (mess));
setSettings(UNDEFINED);
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
return FAIL;
}
}
//normal tau value (only if enabled)
else {
setDefaultSettingsTau_in_nsec(myMod.tau);
if (getRateCorrectionEnable()) {
int64_t retvalTau = setRateCorrection(myMod.tau);
if (myMod.tau != retvalTau) {
sprintf(mess, "Cannot set module. Could not set rate correction\n");
FILE_LOG(logERROR, (mess));
setSettings(UNDEFINED);
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
return FAIL;
}
}
}
#endif #endif
return thisSettings; return OK;
} }
@ -882,13 +939,13 @@ int getModule(sls_detector_module *myMod) {
tt = Feb_Control_GetTrimbits(); tt = Feb_Control_GetTrimbits();
//exclude gap pixels //exclude gap pixels
int iy,ichip,ix,ip=0,ich=0; int iy, ichip, ix, ip = 0, ich = 0;
for(iy=0;iy<256;iy++) { for (iy = 0; iy < 256; ++iy) {
for (ichip=0; ichip<4; ichip++) { for (ichip = 0; ichip < 4; ++ichip) {
for(ix=0;ix<256;ix++) { for (ix = 0; ix < 256; ++iy) {
myMod->chanregs[ich++]=tt[ip++]; myMod->chanregs[ich++] = tt[ip++];
} }
if (ichip<3) { if (ichip < 3) {
ip++; ip++;
ip++; ip++;
} }
@ -1728,7 +1785,7 @@ void readFrame(int *ret, char *mess) {
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
int ichip, idac, ichan, iadc; int idac, ichan, iadc;
int ret=OK; int ret=OK;
FILE_LOG(logDEBUG5, ("Copying module %x to module %x\n",srcMod,destMod)); FILE_LOG(logDEBUG5, ("Copying module %x to module %x\n",srcMod,destMod));
@ -1738,11 +1795,6 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
destMod->serialnumber=srcMod->serialnumber; destMod->serialnumber=srcMod->serialnumber;
} }
//no trimbit feature //no trimbit feature
if (destMod->nchip && ((srcMod->nchip)>(destMod->nchip))) {
FILE_LOG(logINFO, ("Number of chip of source is larger than number of chips of destination\n"));
return FAIL;
}
//no trimbit feature
if (destMod->nchan && ((srcMod->nchan)>(destMod->nchan))) { if (destMod->nchan && ((srcMod->nchan)>(destMod->nchan))) {
FILE_LOG(logINFO, ("Number of channels of source is larger than number of channels of destination\n")); FILE_LOG(logINFO, ("Number of channels of source is larger than number of channels of destination\n"));
return FAIL; return FAIL;
@ -1758,7 +1810,6 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
FILE_LOG(logDEBUG5, ("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac)); FILE_LOG(logDEBUG5, ("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac));
FILE_LOG(logDEBUG5, ("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc)); FILE_LOG(logDEBUG5, ("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc));
FILE_LOG(logDEBUG5, ("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip));
FILE_LOG(logDEBUG5, ("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan)); FILE_LOG(logDEBUG5, ("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan));
destMod->ndac=srcMod->ndac; destMod->ndac=srcMod->ndac;
destMod->nadc=srcMod->nadc; destMod->nadc=srcMod->nadc;
@ -1766,23 +1817,22 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
destMod->nchan=srcMod->nchan; destMod->nchan=srcMod->nchan;
if (srcMod->reg>=0) if (srcMod->reg>=0)
destMod->reg=srcMod->reg; destMod->reg=srcMod->reg;
if (srcMod->iodelay>=0)
destMod->iodelay=srcMod->iodelay;
if (srcMod->tau>=0)
destMod->tau=srcMod->tau;
if (srcMod->eV>=0)
destMod->eV=srcMod->eV;
FILE_LOG(logDEBUG5, ("Copying register %x (%x)\n",destMod->reg,srcMod->reg )); FILE_LOG(logDEBUG5, ("Copying register %x (%x)\n",destMod->reg,srcMod->reg ));
if (srcMod->gain>=0)
destMod->gain=srcMod->gain;
if (srcMod->offset>=0)
destMod->offset=srcMod->offset;
if ((destMod->nchip!=0) || (destMod->nchan!=0)) { if (destMod->nchan!=0) {
for (ichip=0; ichip<(srcMod->nchip); ichip++) {
if (*((srcMod->chipregs)+ichip)>=0)
*((destMod->chipregs)+ichip)=*((srcMod->chipregs)+ichip);
}
for (ichan=0; ichan<(srcMod->nchan); ichan++) { for (ichan=0; ichan<(srcMod->nchan); ichan++) {
if (*((srcMod->chanregs)+ichan)>=0) if (*((srcMod->chanregs)+ichan)>=0)
*((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan); *((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan);
} }
} }
else FILE_LOG(logINFO, ("Not Copying trimbits\n")); else FILE_LOG(logINFO, ("Not Copying trimbits\n"));
for (idac=0; idac<(srcMod->ndac); idac++) { for (idac=0; idac<(srcMod->ndac); idac++) {
if (*((srcMod->dacs)+idac)>=0) { if (*((srcMod->dacs)+idac)>=0) {
*((destMod->dacs)+idac)=*((srcMod->dacs)+idac); *((destMod->dacs)+idac)=*((srcMod->dacs)+idac);
@ -1811,8 +1861,6 @@ int getNumberOfChips() {return NCHIP;}
int getNumberOfDACs() {return NDAC;} int getNumberOfDACs() {return NDAC;}
int getNumberOfADCs() {return NADC;} int getNumberOfADCs() {return NADC;}
int getNumberOfChannelsPerChip() {return NCHAN;} int getNumberOfChannelsPerChip() {return NCHAN;}
int getNumberOfGains() {return NGAIN;}
int getNumberOfOffsets() {return NOFFSET;}

View File

@ -49,8 +49,6 @@ enum {E_PARALLEL, E_NON_PARALLEL, E_SAFE};
#define NCHIP (4) #define NCHIP (4)
#define NADC (0) #define NADC (0)
#define NDAC (16) #define NDAC (16)
#define NGAIN (0)
#define NOFFSET (0)
#define TEN_GIGA_BUFFER_SIZE (4112) #define TEN_GIGA_BUFFER_SIZE (4112)

View File

@ -351,64 +351,36 @@ int receiveDataOnly(int file_des, void* buf,int length) {
int sendModule(int file_des, sls_detector_module *myMod) { int sendModule(int file_des, sls_detector_module *myMod) {
return sendModuleGeneral(file_des, myMod, 1);
}
int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) {
int ts = 0, n = 0; int ts = 0, n = 0;
int nChips = myMod->nchip;
int nChans = myMod->nchan;
int nAdcs = myMod->nadc;
int nDacs = myMod->ndac;
// send module structure
n = sendData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); n = sendData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
n = sendData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); n = sendData(file_des,&(myMod->nchan), sizeof(myMod->nchan), INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
n = sendData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); n = sendData(file_des,&(myMod->nchip), sizeof(myMod->nchip), INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
n = sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); n = sendData(file_des,&(myMod->ndac), sizeof(myMod->ndac), INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
n = sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); n = sendData(file_des,&(myMod->nadc), sizeof(myMod->nadc), INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
n = sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); n = sendData(file_des,&(myMod->reg), sizeof(myMod->reg), INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
n = sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); n = sendData(file_des,&(myMod->iodelay), sizeof(myMod->iodelay), INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
n = sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); n = sendData(file_des,&(myMod->tau), sizeof(myMod->tau), INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
FILE_LOG(logDEBUG5, ("module of size %d sent\n",ts)); n = sendData(file_des,&(myMod->eV), sizeof(myMod->eV), INT32);
// send dac
n = sendData(file_des,myMod->dacs,sizeof(int)*nDacs,INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
FILE_LOG(logDEBUG5, ("dacs of size %d sent\n",ts)); // dacs
{ n = sendData(file_des,myMod->dacs, sizeof(int)*(myMod->ndac), INT32);
int idac;
for (idac = 0; idac < nDacs; idac++)
FILE_LOG(logDEBUG5, ("dac %d is %d\n",idac,(int)myMod->dacs[idac]));
}
// send adc
n = sendData(file_des,myMod->adcs,sizeof(int)*nAdcs,INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
FILE_LOG(logDEBUG5, ("adcs of size %d sent\n", ts)); // adcs
n = sendData(file_des,myMod->adcs, sizeof(int)*(myMod->nadc), INT32);
// some detectors dont require sending all trimbits etc. if (!n) return -1; ts += n;
if(sendAll) { // channels
// chips #ifdef EIGERD
n = sendData(file_des,myMod->chipregs,sizeof(int)*nChips,INT32); n = sendData(file_des,myMod->chanregs, sizeof(int) * (myMod->nchan), INT32);
if (!n) return -1; ts += n; if (!n) return -1; ts += n;
FILE_LOG(logDEBUG5, ("chips of size %d sent\n", ts)); #endif
// channels
n = sendData(file_des,myMod->chanregs,sizeof(int)*nChans,INT32);
FILE_LOG(logDEBUG5, ("chans of size %d sent - %d\n", ts, myMod->nchan));
if (!n) return -1; ts += n;
}
FILE_LOG(logDEBUG5, ("module of size %d sent register %x\n", ts, myMod->reg)); FILE_LOG(logDEBUG5, ("module of size %d sent register %x\n", ts, myMod->reg));
return ts; return ts;
} }
@ -416,149 +388,57 @@ int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) {
int receiveModule(int file_des, sls_detector_module* myMod) { int receiveModule(int file_des, sls_detector_module* myMod) {
return receiveModuleGeneral(file_des,myMod,1);
}
int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll) {
int ts = 0, n = 0; int ts = 0, n = 0;
int *dacptr = myMod->dacs; int nDacs = myMod->ndac;
int *adcptr = myMod->adcs; int nAdcs = myMod->nadc;
int *chipptr = myMod->chipregs, *chanptr = myMod->chanregs;
int nChips, nchipold = myMod->nchip, nchipdiff;
int nChans, nchanold = myMod->nchan, nchandiff;
int nDacs, ndold = myMod->ndac, ndacdiff;
int nAdcs, naold = myMod->nadc, nadcdiff;
n = receiveData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER);
if (!n) return -1; ts += n;
myMod->dacs = dacptr;
myMod->adcs = adcptr;
myMod->chipregs = chipptr;
myMod->chanregs = chanptr;
#ifdef EIGERD #ifdef EIGERD
//exclude sending of trimbtis, nchips = 0,nchans = 0 in that case int nChans = myMod->nchan; // can be zero for no trimbits
if(myMod->nchip == 0 && myMod->nchan == 0) {
receiveAll = 0;
nchipold = 0;
nchanold = 0;
}
#endif #endif
n = receiveData(file_des,&(myMod->serialnumber), sizeof(myMod->serialnumber), INT32);
if (!n) return -1; ts += n;
nChips = myMod->nchip; n = receiveData(file_des,&(myMod->nchan), sizeof(myMod->nchan), INT32);
nchipdiff = nChips-nchipold; if (!n) return -1; ts += n;
if (nchipold != nChips) { n = receiveData(file_des,&(myMod->nchip), sizeof(myMod->nchip), INT32);
FILE_LOG(logERROR, ("received wrong number of chips\n")); if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->ndac), sizeof(myMod->ndac), INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->nadc), sizeof(myMod->nadc), INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->reg), sizeof(myMod->reg), INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->iodelay), sizeof(myMod->iodelay), INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->tau), sizeof(myMod->tau), INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,&(myMod->eV), sizeof(myMod->eV), INT32);
if (!n) return -1; ts += n;
// dacs
if (nDacs != (myMod->ndac)) {
FILE_LOG(logERROR, ("received wrong number of dacs. "
"Expected %d, got %d\n", nDacs, myMod->ndac));
return 0;
} }
else n = receiveData(file_des,&(myMod->dacs), sizeof(int) * (myMod->ndac), INT32);
FILE_LOG(logDEBUG5, ("received %d chips\n",nChips)); if (!n) return -1; ts += n;
// adcs
nChans = myMod->nchan; if (nAdcs != (myMod->nadc)) {
nchandiff = nChans-nchanold; FILE_LOG(logERROR, ("received wrong number of adcs. "
if (nchanold != nChans) { "Expected %d, got %d\n", nAdcs, myMod->nadc));
FILE_LOG(logERROR, ("received wrong number of channels\n")); return 0;
} }
else n = receiveData(file_des,&(myMod->adcs), sizeof(int) * (myMod->nadc), INT32);
FILE_LOG(logDEBUG5, ("received %d chans\n",nChans)); if (!n) return -1; ts += n;
// channels
#ifdef EIGERD
nDacs = myMod->ndac; if (((myMod->nchan) != 0 ) || // no trimbits
ndacdiff = nDacs-ndold; (nChans != (myMod->nchan))) { // with trimbits
if (ndold != nDacs) { FILE_LOG(logERROR, ("received wrong number of channels. "
FILE_LOG(logERROR, ("received wrong number of dacs\n")); "Expected %d, got %d\n", nChans, (myMod->nchan)));
} return 0;
else
FILE_LOG(logDEBUG5, ("received %d dacs\n",nDacs));
nAdcs = myMod->nadc;
nadcdiff = nAdcs-naold;
if (naold != nAdcs) {
FILE_LOG(logERROR, ("received wrong number of adcs\n"));
}
else
FILE_LOG(logDEBUG5, ("received %d adcs\n",nAdcs));
if (ndacdiff <= 0) {
n = receiveData(file_des,myMod->dacs, sizeof(int)*nDacs,INT32);
if (!n) return -1; ts += n;
FILE_LOG(logDEBUG5, ("dacs received\n"));
int id;
for (id = 0; id<nDacs; id++)
FILE_LOG(logDEBUG5, ("dac %d val %d\n",id, (int)myMod->dacs[id]));
} else {
dacptr = (int*)malloc(ndacdiff*sizeof(int));
myMod->ndac = ndold;
n = receiveData(file_des,myMod->dacs, sizeof(int)*ndold,INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,dacptr, sizeof(int)*ndacdiff,INT32);
if (!n) return -1; ts += n;
free(dacptr);
return FAIL;
}
if (nadcdiff <= 0) {
n = receiveData(file_des,myMod->adcs, sizeof(int)*nAdcs,INT32);
if (!n) return -1; ts += n;
FILE_LOG(logDEBUG5, ("adcs received\n"));
} else {
adcptr = (int*)malloc(nadcdiff*sizeof(int));
myMod->nadc = naold;
n = receiveData(file_des,myMod->adcs, sizeof(int)*naold,INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,adcptr, sizeof(int)*nadcdiff,INT32);
if (!n) return -1; ts += n;
free(adcptr);
return FAIL;
}
// some detectors dont require sending all trimbits etc.
if(receiveAll){
if (nchipdiff <= 0) {
n = receiveData(file_des,myMod->chipregs, sizeof(int)*nChips,INT32);
if (!n) return -1; ts += n;
FILE_LOG(logDEBUG5, ("chips received\n"));
} else {
chipptr = (int*)malloc(nchipdiff*sizeof(int));
myMod->nchip = nchipold;
n = receiveData(file_des,myMod->chipregs, sizeof(int)*nchipold,INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,chipptr, sizeof(int)*nchipdiff,INT32);
if (!n) return -1; ts += n;
free(chipptr);
return FAIL;
}
if (nchandiff <= 0) {
n = receiveData(file_des,myMod->chanregs, sizeof(int)*nChans,INT32);
if (!n) return -1; ts += n;
FILE_LOG(logDEBUG5, ("chans received\n"));
} else {
chanptr = (int*)malloc(nchandiff*sizeof(int));
myMod->nchan = nchanold;
n = receiveData(file_des,myMod->chanregs, sizeof(int)*nchanold,INT32);
if (!n) return -1; ts += n;
n = receiveData(file_des,chanptr, sizeof(int)*nchandiff,INT32);
if (!n) return -1; ts += n;
free(chanptr);
return FAIL;
}
} }
n = receiveData(file_des,&(myMod->chanregs), sizeof(int) * (myMod->nchan), INT32);
if (!n) return -1; ts += n;
#endif
FILE_LOG(logDEBUG5, ("received module of size %d register %x\n",ts,myMod->reg)); FILE_LOG(logDEBUG5, ("received module of size %d register %x\n",ts,myMod->reg));
return ts; return ts;
} }

View File

@ -38,9 +38,7 @@ int sendDataOnly(int file_des, void* buf,int length);
int receiveDataOnly(int file_des, void* buf,int length); int receiveDataOnly(int file_des, void* buf,int length);
int sendModule(int file_des, sls_detector_module *myMod); int sendModule(int file_des, sls_detector_module *myMod);
int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll);
int receiveModule(int file_des, sls_detector_module* myMod); int receiveModule(int file_des, sls_detector_module* myMod);
int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll);
/** /**
* Servers sets and prints error message for locked server * Servers sets and prints error message for locked server

View File

@ -102,12 +102,7 @@ int64_t getTimeLeft(enum timerIndex ind);
// parameters - module, settings // parameters - module, settings
int setModule(sls_detector_module myMod, char* mess);
#ifdef EIGERD
int setModule(sls_detector_module myMod, int delay);
#else
int setModule(sls_detector_module myMod);
#endif
int getModule(sls_detector_module *myMod); int getModule(sls_detector_module *myMod);
enum detectorSettings setSettings(enum detectorSettings sett); enum detectorSettings setSettings(enum detectorSettings sett);
enum detectorSettings getSettings(); enum detectorSettings getSettings();
@ -233,10 +228,6 @@ int getTotalNumberOfChannels();
int getNumberOfChips(); int getNumberOfChips();
int getNumberOfDACs(); int getNumberOfDACs();
int getNumberOfADCs(); int getNumberOfADCs();
#ifdef EIGERD
int getNumberOfGains();
int getNumberOfOffsets();
#endif
int getNumberOfChannelsPerChip(); int getNumberOfChannelsPerChip();

View File

@ -156,7 +156,6 @@ const char* getFunctionName(enum detFuncs func) {
case F_LOAD_IMAGE: return "F_LOAD_IMAGE"; case F_LOAD_IMAGE: return "F_LOAD_IMAGE";
case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK"; case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK";
case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK"; case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK";
case F_CALIBRATE_PEDESTAL: return "F_CALIBRATE_PEDESTAL";
case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA"; case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS"; case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN"; case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN";
@ -221,7 +220,6 @@ void function_table() {
flist[F_LOAD_IMAGE] = &load_image; flist[F_LOAD_IMAGE] = &load_image;
flist[F_READ_COUNTER_BLOCK] = &read_counter_block; flist[F_READ_COUNTER_BLOCK] = &read_counter_block;
flist[F_RESET_COUNTER_BLOCK] = &reset_counter_block; flist[F_RESET_COUNTER_BLOCK] = &reset_counter_block;
flist[F_CALIBRATE_PEDESTAL] = &calibrate_pedestal;
flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga; flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga;
flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits; flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits;
flist[F_SET_CTB_PATTERN] = &set_ctb_pattern; flist[F_SET_CTB_PATTERN] = &set_ctb_pattern;
@ -304,7 +302,7 @@ int M_nofunc(int file_des) {
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
// to receive any arguments // to receive any arguments
int n = 0; int n = 1;
while (n > 0) while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
@ -320,7 +318,7 @@ int M_nofuncMode(int file_des) {
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
// to receive any arguments // to receive any arguments
int n = 0; int n = 1;
while (n > 0) while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
@ -836,112 +834,83 @@ int read_register(int file_des) {
int set_module(int file_des) { int set_module(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int retval = -1; enum detectorSettings retval = -1;
sls_detector_module module; sls_detector_module module;
int *myDac = NULL; int *myDac = NULL;
int *myAdc = NULL; int *myAdc = NULL;
int *myChip = NULL;
int *myChan = NULL; int *myChan = NULL;
#ifdef EIGERD module.dacs = NULL;
int ioDelay = -1; module.adcs = NULL;
int tau = -1; module.chanregs = NULL;
int eV = -1;
#endif
// allocate to receive arguments // allocate to receive arguments
// infinite loop to break out when FAIL or a final OK // allocate dacs
while(1) { myDac = (int*)malloc(getNumberOfDACs() * sizeof(int));
// allocate dacs // error
myDac = (int*)malloc(getNumberOfDACs() * sizeof(int)); if (getNumberOfDACs() > 0 && myDac == NULL) {
// error ret = FAIL;
if (getNumberOfDACs() > 0 && myDac == NULL) { sprintf(mess, "Could not allocate dacs\n");
ret = FAIL; FILE_LOG(logERROR,(mess));
sprintf(mess, "Could not allocate dacs\n"); } else
FILE_LOG(logERROR,(mess));
break;
}
module.dacs = myDac; module.dacs = myDac;
// allocate adcs // allocate adcs
if (ret == OK) {
myAdc = (int*)malloc(getNumberOfADCs() * sizeof(int)); myAdc = (int*)malloc(getNumberOfADCs() * sizeof(int));
// error // error
if (getNumberOfADCs() > 0 && myAdc == NULL) { if (getNumberOfADCs() > 0 && myAdc == NULL) {
ret = FAIL; ret = FAIL;
sprintf(mess,"Could not allocate adcs\n"); sprintf(mess,"Could not allocate adcs\n");
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));
break; } else
} module.adcs = myAdc;
module.adcs=myAdc; }
// no need to allocate chips and chans for jungfrau, too much memory // allocate chans
#ifdef JUNGFRAUD #ifdef EIGERD
module.chipregs = NULL; if (ret == OK) {
module.chanregs = NULL;
#else
// allocate chips
myChip = (int*)malloc(getNumberOfChips() * sizeof(int));
if (getNumberOfChips() > 0 && myChip == NULL) {
ret = FAIL;
sprintf(mess,"Could not allocate chips\n");
FILE_LOG(logERROR,(mess));
break;
}
module.chipregs = myChip;
// allocate chans
myChan = (int*)malloc(getTotalNumberOfChannels() * sizeof(int)); myChan = (int*)malloc(getTotalNumberOfChannels() * sizeof(int));
if (getTotalNumberOfChannels() > 0 && myChan == NULL) { if (getTotalNumberOfChannels() > 0 && myChan == NULL) {
ret = FAIL; ret = FAIL;
sprintf(mess,"Could not allocate chans\n"); sprintf(mess,"Could not allocate chans\n");
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));
break; } else
} module.chanregs = myChan;
module.chanregs=myChan; }
#endif #endif
// receive arguments
if (ret == OK) {
module.nchip = getNumberOfChips(); module.nchip = getNumberOfChips();
module.nchan = getTotalNumberOfChannels(); module.nchan = getTotalNumberOfChannels();
module.ndac = getNumberOfDACs(); module.ndac = getNumberOfDACs();
module.nadc = getNumberOfADCs(); module.nadc = getNumberOfADCs();
int ts = receiveModule(file_des, &module);
// receive arguments (0 to partially receive module without trimbits if (ts < 0) {
if (receiveModuleGeneral(file_des, &module, (myDetectorType == JUNGFRAU) ? 0 : 1) < 0) { if (myChan != NULL) free(myChan);
if (myChip != NULL) free(myChip);
if (myChan != NULL) free(myChan);
if (myDac != NULL) free(myDac); if (myDac != NULL) free(myDac);
if (myAdc != NULL) free(myAdc); if (myAdc != NULL) free(myAdc);
return printSocketReadError(); return printSocketReadError();
} }
FILE_LOG(logDEBUG5, ("module register is %d, nchan %d, nchip %d, " FILE_LOG(logDEBUG5, ("module register is %d, nchan %d, nchip %d, "
"ndac %d, nadc %d, gain %f, offset %f\n", "ndac %d, nadc %d, iodelay %d, tau %d, eV %d\n",
module.reg, module.nchan, module.nchip, module.reg, module.nchan, module.nchip,
module.ndac, module.nadc, module.gain,module.offset)); module.ndac, module.nadc, module.iodelay, module.tau, module.eV));
// should at least have a dac
#ifdef EIGERD if (ts <= sizeof(sls_detector_module)) {
int args[3] = {-1, -1}; ret = FAIL;
if (receiveData(file_des, args, sizeof(args), INT32) < 0) { sprintf(mess, "Cannot set module. Received incorrect number of dacs or adcs or channels\n");
if (myChip != NULL) free(myChip); FILE_LOG(logERROR,(mess));
if (myChan != NULL) free(myChan); }
if (myDac != NULL) free(myDac);
if (myAdc != NULL) free(myAdc);
return printSocketReadError();
}
ioDelay = args[0];
tau = args[1];
eV = args[2];
FILE_LOG(logDEBUG5, ("ioDelay: %d, tau: d, ev:%d\n", ioDelay, tau, eV));
#endif
} }
// receive all arguments // receive all arguments
if (ret == FAIL) { if (ret == FAIL) {
int n = 0; int n = 1;
while (n > 0) while (n > 0)
n = receiveData(file_des, mess, MAX_STR_LENGTH, OTHER); n = receiveData(file_des, mess, MAX_STR_LENGTH, OTHER);
} }
// only set // only set
else if (Server_VerifyLock() != FAIL) { else if (Server_VerifyLock() != FAIL) {
// check index // check index
@ -972,52 +941,12 @@ int set_module(int file_des) {
break; break;
} }
// set ret = setModule(module, mess);
#ifndef EIGERD
retval = setModule(module);
validate(module.reg, retval, "set module (settings)", 0);
// eiger
#else
//set dacs, trimbits and iodelay
ret = setModule(module, ioDelay);
//set threshhold
if (eV >= 0)
setThresholdEnergy(eV);
else {
//changes settings to undefined (loading a random trim file)
setSettings(UNDEFINED);
FILE_LOG(logERROR, ("Settings has been changed to undefined "
"(random trim file)\n"));
}
//rate correction
//switch off rate correction: no value read from load calib/load settings)
if (tau == -1) {
if (getRateCorrectionEnable()) {
setRateCorrection(0);
ret = FAIL;
sprintf(mess,"Cannot set module. Cannot set Rate correction. "
"No default tau provided. Deactivating Rate Correction\n");
FILE_LOG(logERROR, (mess));
}
}
//normal tau value (only if enabled)
else {
setDefaultSettingsTau_in_nsec(tau);
if (getRateCorrectionEnable()) {
int64_t retvalTau = setRateCorrection(tau);
if (tau != retvalTau) {
ret = FAIL;
sprintf(mess, "Cannot set module. Could not set rate correction\n");
FILE_LOG(logERROR, (mess));
}
}
}
retval = getSettings(); retval = getSettings();
#endif validate(module.reg, (int)retval, "set module (settings)", 0);
FILE_LOG(logDEBUG5, ("Settings: %d\n", retval)); FILE_LOG(logDEBUG5, ("Settings: %d\n", retval));
} }
if (myChip != NULL) free(myChip); if (myChan != NULL) free(myChan);
if (myChan != NULL) free(myChan);
if (myDac != NULL) free(myDac); if (myDac != NULL) free(myDac);
if (myAdc != NULL) free(myAdc); if (myAdc != NULL) free(myAdc);
return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval));
@ -1026,70 +955,55 @@ int set_module(int file_des) {
int get_module(int file_des) { int get_module(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
sls_detector_module module; sls_detector_module module;
int *myDac = NULL; int *myDac = NULL;
int *myAdc = NULL; int *myAdc = NULL;
int *myChip = NULL;
int *myChan = NULL; int *myChan = NULL;
module.dacs = NULL;
module.adcs = NULL;
module.chanregs = NULL;
// allocate to send arguments // allocate to send arguments
// infinite loop to break out when FAIL or a final OK // allocate dacs
while(1) { myDac = (int*)malloc(getNumberOfDACs() * sizeof(int));
// error
// allocate dacs if (getNumberOfDACs() > 0 && myDac == NULL) {
myDac = (int*)malloc(getNumberOfDACs() * sizeof(int)); ret = FAIL;
// error sprintf(mess, "Could not allocate dacs\n");
if (getNumberOfDACs() > 0 && myDac == NULL) { FILE_LOG(logERROR,(mess));
ret = FAIL; } else
sprintf(mess, "Could not allocate dacs\n");
FILE_LOG(logERROR,(mess));
break;
}
module.dacs = myDac; module.dacs = myDac;
// allocate adcs // allocate adcs
if (ret == OK) {
myAdc = (int*)malloc(getNumberOfADCs() * sizeof(int)); myAdc = (int*)malloc(getNumberOfADCs() * sizeof(int));
// error // error
if (getNumberOfADCs() > 0 && myAdc == NULL) { if (getNumberOfADCs() > 0 && myAdc == NULL) {
ret = FAIL; ret = FAIL;
sprintf(mess,"Could not allocate adcs\n"); sprintf(mess,"Could not allocate adcs\n");
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));
break; } else
} module.adcs=myAdc;
module.adcs=myAdc; }
// no need to allocate chips and chans for jungfrau, too much memory // allocate chans
#ifdef JUNGFRAUD #ifdef EIGERD
module.chipregs = NULL; if (ret == OK) {
module.chanregs = NULL;
#else
// allocate chips
myChip = (int*)malloc(getNumberOfChips() * sizeof(int));
if (getNumberOfChips() > 0 && myChip == NULL) {
ret = FAIL;
sprintf(mess,"Could not allocate chips\n");
FILE_LOG(logERROR,(mess));
break;
}
module.chipregs = myChip;
// allocate chans
myChan = (int*)malloc(getTotalNumberOfChannels() * sizeof(int)); myChan = (int*)malloc(getTotalNumberOfChannels() * sizeof(int));
if (getTotalNumberOfChannels() > 0 && myChan == NULL) { if (getTotalNumberOfChannels() > 0 && myChan == NULL) {
ret = FAIL; ret = FAIL;
sprintf(mess,"Could not allocate chans\n"); sprintf(mess,"Could not allocate chans\n");
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));
break; } else
} module.chanregs=myChan;
module.chanregs=myChan; }
#endif #endif
// get module
if (ret == OK) {
module.nchip = getNumberOfChips(); module.nchip = getNumberOfChips();
module.nchan = getTotalNumberOfChannels(); module.nchan = getTotalNumberOfChannels();
module.ndac = getNumberOfDACs(); module.ndac = getNumberOfDACs();
@ -1105,10 +1019,9 @@ int get_module(int file_des) {
// send module, 0 is to receive partially (without trimbits etc) // send module, 0 is to receive partially (without trimbits etc)
if (ret != FAIL) { if (ret != FAIL) {
ret = sendModuleGeneral(file_des, &module, (myDetectorType == JUNGFRAU) ? 0 : 1); ret = sendModule(file_des, &module);
} }
if (myChip != NULL) free(myChip); if (myChan != NULL) free(myChan);
if (myChan != NULL) free(myChan);
if (myDac != NULL) free(myDac); if (myDac != NULL) free(myDac);
if (myAdc != NULL) free(myAdc); if (myAdc != NULL) free(myAdc);
return ret; return ret;
@ -2014,7 +1927,6 @@ int load_image(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int args[2] = {-1, -1}; int args[2] = {-1, -1};
int retval = -1;
if (receiveData(file_des, args, sizeof(args), INT32) < 0) if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError(); return printSocketReadError();
@ -2039,10 +1951,9 @@ int load_image(int file_des) {
switch (index) { switch (index) {
case DARK_IMAGE : case DARK_IMAGE :
case GAIN_IMAGE : case GAIN_IMAGE :
retval = loadImage(index, ImageVals); ret = loadImage(index, ImageVals);
FILE_LOG(logDEBUG5, ("Loading image retval: %d\n", retval)); FILE_LOG(logDEBUG5, ("Loading image ret: %d\n", ret));
if (retval == -1) { if (ret == FAIL) {
ret = FAIL;
sprintf(mess, "Could not load image\n"); sprintf(mess, "Could not load image\n");
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));
} }
@ -2053,7 +1964,7 @@ int load_image(int file_des) {
} }
} }
#endif #endif
return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); return Server_SendResult(file_des, INT32, 1, NULL, 0);
} }
@ -2096,8 +2007,6 @@ int reset_counter_block(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int startACQ = -1; int startACQ = -1;
char retval[dataBytes];
memset(retval, 0, dataBytes);
if (receiveData(file_des, &startACQ, sizeof(startACQ), INT32) < 0) if (receiveData(file_des, &startACQ, sizeof(startACQ), INT32) < 0)
return printSocketReadError(); return printSocketReadError();
@ -2109,7 +2018,7 @@ int reset_counter_block(int file_des) {
// only set // only set
if (Server_VerifyLock() != FAIL) { if (Server_VerifyLock() != FAIL) {
ret = resetCounterBlock(startACQ, retval); ret = resetCounterBlock(startACQ);
if (ret == FAIL) { if (ret == FAIL) {
strcpy(mess, "Could not reset counter block\n"); strcpy(mess, "Could not reset counter block\n");
FILE_LOG(logERROR, (mess)); FILE_LOG(logERROR, (mess));
@ -2123,27 +2032,6 @@ int reset_counter_block(int file_des) {
int calibrate_pedestal(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int frames = -1;
int retval = -1;
if (receiveData(file_des, &frames, sizeof(frames), INT32) < 0)
return printSocketReadError();
FILE_LOG(logDEBUG5, ("Calibrate pedestal, frames: %d\n", frames));
functionNotImplemented();
return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval));
}
int enable_ten_giga(int file_des) { int enable_ten_giga(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
@ -2215,12 +2103,12 @@ int set_ctb_pattern(int file_des) {
int write_adc_register(int file_des) { int write_adc_register(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int args[2] = {-1, -1}; uint32_t args[2] = {-1, -1};
if (receiveData(file_des, args, sizeof(args), INT32) < 0) if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError(); return printSocketReadError();
int addr = args[0]; uint32_t addr = args[0];
int val = args[1]; uint32_t val = args[1];
FILE_LOG(logDEBUG5, ("Writing 0x%x to ADC Register 0x%x\n", val, addr)); FILE_LOG(logDEBUG5, ("Writing 0x%x to ADC Register 0x%x\n", val, addr));
#ifndef JUNGFRAUD #ifndef JUNGFRAUD
@ -2484,7 +2372,7 @@ int program_fpga(int file_des) {
FILE_LOG(logDEBUG5, ("Programming FPGA\n")); FILE_LOG(logDEBUG5, ("Programming FPGA\n"));
#ifndef JUNGFRAUD #ifndef JUNGFRAUD
//to receive any arguments //to receive any arguments
int n = 0; int n = 1;
while (n > 0) while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
functionNotImplemented(); functionNotImplemented();
@ -2708,7 +2596,7 @@ int prepare_acquisition(int file_des) {
// stop server
int threshold_temp(int file_des) { int threshold_temp(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
@ -2738,11 +2626,11 @@ int threshold_temp(int file_des) {
} }
} }
#endif #endif
return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); return Server_SendResult(file_des, INT32, 0, &retval, sizeof(retval));
} }
// stop server
int temp_control(int file_des) { int temp_control(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
@ -2763,12 +2651,12 @@ int temp_control(int file_des) {
validate(arg, retval, "set temperature control", 0); validate(arg, retval, "set temperature control", 0);
} }
#endif #endif
return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); return Server_SendResult(file_des, INT32, 0, &retval, sizeof(retval));
} }
// stop server
int temp_event(int file_des) { int temp_event(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
@ -2789,7 +2677,7 @@ int temp_event(int file_des) {
validate(arg, retval, "set temperature event", 0); validate(arg, retval, "set temperature event", 0);
} }
#endif #endif
return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); return Server_SendResult(file_des, INT32, 0, &retval, sizeof(retval));
} }

View File

@ -2196,14 +2196,7 @@ int multiSlsDetector::writeAdcRegister(int addr, int val, int detPos) {
// multi // multi
auto r = parallelCall(&slsDetector::writeAdcRegister, addr, val); auto r = parallelCall(&slsDetector::writeAdcRegister, addr, val);
if (sls::allEqual(r)) return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
return r.front();
// can't have different values
FILE_LOG(logERROR) << "Error: Different Values for function writeAdcRegister "
"(write 0x" << std::hex << val << " to addr 0x" << std::hex << addr << std::dec << ")";
setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES);
return -1;
} }
@ -2458,33 +2451,22 @@ int multiSlsDetector::setAutoComparatorDisableMode(int ival, int detPos) {
} }
int multiSlsDetector::getChanRegs(double* retval, bool fromDetector, int detPos) { int multiSlsDetector::getChanRegs(double* retval, int detPos) {
int offset = 0; int offset = 0;
std::vector<int> r; std::vector<int> r;
for (auto& d : detectors) { for (auto& d : detectors) {
int nch = d->getTotalNumberOfChannels(); int nch = d->getTotalNumberOfChannels();
double result[nch]; double result[nch];
r.push_back(d->getChanRegs(result, fromDetector)); r.push_back(d->getChanRegs(result));
memcpy(retval + offset, result, nch * sizeof(double)); memcpy(retval + offset, result, nch * sizeof(double));
} }
return sls::minusOneIfDifferent(r); return sls::minusOneIfDifferent(r);
} }
int multiSlsDetector::calibratePedestal(int frames, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->calibratePedestal(frames);
}
// multi int multiSlsDetector::setRateCorrection(int64_t t, int detPos) {
auto r = parallelCall(&slsDetector::calibratePedestal, frames);
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::setRateCorrection(int t, int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
return detectors[detPos]->setRateCorrection(t); return detectors[detPos]->setRateCorrection(t);
@ -2496,7 +2478,7 @@ int multiSlsDetector::setRateCorrection(int t, int detPos) {
} }
int multiSlsDetector::getRateCorrection(int detPos) { int64_t multiSlsDetector::getRateCorrection(int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
return detectors[detPos]->getRateCorrection(); return detectors[detPos]->getRateCorrection();
@ -2508,15 +2490,14 @@ int multiSlsDetector::getRateCorrection(int detPos) {
} }
int multiSlsDetector::printReceiverConfiguration(int detPos) { void multiSlsDetector::printReceiverConfiguration(int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
return detectors[detPos]->printReceiverConfiguration(); return detectors[detPos]->printReceiverConfiguration();
} }
// multi // multi
auto r = parallelCall(&slsDetector::printReceiverConfiguration); parallelCall(&slsDetector::printReceiverConfiguration);
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
} }

View File

@ -1153,21 +1153,10 @@ public:
/** /**
* Returns the trimbits from the detector's shared memmory (Mythen, Eiger) * Returns the trimbits from the detector's shared memmory (Mythen, Eiger)
* @param retval is the array with the trimbits * @param retval is the array with the trimbits
* @param fromDetector is true if the trimbits shared memory have to be
* uploaded from detector
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns total number of channels for the detector * @returns total number of channels for the detector
*/ */
int getChanRegs(double* retval,bool fromDetector, int detPos = -1); int getChanRegs(double* retval, int detPos = -1);
/**
* Calibrate Pedestal (ChipTestBoard)
* Starts acquisition, calibrates pedestal and writes to fpga
* @param frames number of frames
* @param detPos -1 for all detectors in list or specific detector position
* @returns number of frames
*/
int calibratePedestal(int frames = 0, int detPos = -1);
/** /**
* Set Rate correction ( Eiger) * Set Rate correction ( Eiger)
@ -1177,21 +1166,20 @@ public:
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns 0 if rate correction disabled, >0 otherwise * @returns 0 if rate correction disabled, >0 otherwise
*/ */
int setRateCorrection(int t=0, int detPos = -1); int setRateCorrection(int64_t t = 0, int detPos = -1);
/** /**
* Get rate correction ( Eiger) * Get rate correction ( Eiger)
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns 0 if rate correction disabled, > 0 otherwise (ns) * @returns 0 if rate correction disabled, > 0 otherwise (ns)
*/ */
int getRateCorrection(int detPos = -1); int64_t getRateCorrection(int detPos = -1);
/** /**
* Prints receiver configuration * Prints receiver configuration
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL
*/ */
int printReceiverConfiguration(int detPos = -1); void printReceiverConfiguration(int detPos = -1);
/** /**
* Sets up receiver socket if online and sets the flag * Sets up receiver socket if online and sets the flag

File diff suppressed because it is too large Load Diff

View File

@ -32,8 +32,6 @@ typedef struct detParameterList {
int nChipY; int nChipY;
int nDacs; int nDacs;
int nAdcs; int nAdcs;
int nGain;
int nOffset;
int dynamicRange; int dynamicRange;
int nGappixelsX; int nGappixelsX;
int nGappixelsY; int nGappixelsY;
@ -112,12 +110,6 @@ private:
/** number of adcs per module */ /** number of adcs per module */
int nAdcs; int nAdcs;
/** number of extra gain values*/
int nGain;
/** number of extra offset values */
int nOffset;
/** dynamic range of the detector data */ /** dynamic range of the detector data */
int dynamicRange; int dynamicRange;
@ -158,18 +150,9 @@ private:
/** memory offsets for the adc arrays */ /** memory offsets for the adc arrays */
int adcoff; int adcoff;
/** memory offsets for the chip register arrays */
int chipoff;
/** memory offsets for the channel register arrays -trimbits*/ /** memory offsets for the channel register arrays -trimbits*/
int chanoff; int chanoff;
/** memory offsets for the gain register arrays */
int gainoff;
/** memory offsets for the offset register arrays -trimbits*/
int offsetoff;
/** ip address/hostname of the receiver for client control via TCP */ /** ip address/hostname of the receiver for client control via TCP */
char receiver_hostname[MAX_STR_LENGTH]; char receiver_hostname[MAX_STR_LENGTH];
@ -622,12 +605,10 @@ public:
* Writes a trim/settings file for module number * Writes a trim/settings file for module number
* the values will be read from the current detector structure * the values will be read from the current detector structure
* @param fname name of the file to be written * @param fname name of the file to be written
* @param iodelay io delay (detector specific)
* @param tau tau (detector specific)
* @returns OK or FAIL if the file could not be written * @returns OK or FAIL if the file could not be written
* \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int) * \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
*/ */
int writeSettingsFile(std::string fname, int iodelay, int tau); int writeSettingsFile(std::string fname);
/** /**
* Get detector settings * Get detector settings
@ -1073,11 +1054,11 @@ public:
/** /**
* Gets counter memory block in detector (Gotthard) * Gets counter memory block in detector (Gotthard)
* @param arg counter memory block from detector * @param image counter memory block from detector
* @param startACQ 1 to start acquisition afterwards, else 0 * @param startACQ 1 to start acquisition afterwards, else 0
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int getCounterBlock(short int arg[],int startACQ=0); int getCounterBlock(short int image[],int startACQ=0);
/** /**
* Resets counter in detector * Resets counter in detector
@ -1276,10 +1257,8 @@ public:
/** /**
* Returns the trimbits from the detector's shared memmory (Mythen, Eiger) * Returns the trimbits from the detector's shared memmory (Eiger)
* @param retval is the array with the trimbits * @param retval is the array with the trimbits
* @param fromDetector is true if the trimbits shared memory have to be
* uploaded from detector
* @returns total number of channels for the detector * @returns total number of channels for the detector
*/ */
int getChanRegs(double* retval,bool fromDetector); int getChanRegs(double* retval,bool fromDetector);
@ -1289,17 +1268,11 @@ public:
* Called for loading trimbits and settings settings to the detector * Called for loading trimbits and settings settings to the detector
* @param module module to be set - must contain correct module number and * @param module module to be set - must contain correct module number and
* also channel and chip registers * also channel and chip registers
* @param iodelay iodelay (detector specific)
* @param tau tau (detector specific)
* @param e_eV threashold in eV (detector specific)
* @param gainval pointer to extra gain values
* @param offsetval pointer to extra offset values
* @param tb 1 to include trimbits, 0 to exclude (used for eiger) * @param tb 1 to include trimbits, 0 to exclude (used for eiger)
* @returns ok or fail * @returns ok or fail
* \sa ::sls_detector_module * \sa ::sls_detector_module
*/ */
int setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int setModule(sls_detector_module module, int tb = 1);
int* gainval=0, int* offsetval=0, int tb=1);
/** /**
@ -1308,14 +1281,6 @@ public:
*/ */
sls_detector_module *getModule(); sls_detector_module *getModule();
/**
* Calibrate Pedestal (ChipTestBoard)
* Starts acquisition, calibrates pedestal and writes to fpga
* @param frames number of frames
* @returns number of frames
*/
int calibratePedestal(int frames = 0);
/** /**
* Set Rate correction (Mythen, Eiger) * Set Rate correction (Mythen, Eiger)
* @param t dead time in ns - if 0 disable correction, * @param t dead time in ns - if 0 disable correction,
@ -1323,19 +1288,19 @@ public:
* for current settings * for current settings
* @returns 0 if rate correction disabled, >0 otherwise * @returns 0 if rate correction disabled, >0 otherwise
*/ */
int setRateCorrection(int t=0); int setRateCorrection(int64_t t = 0);
/** /**
* Get rate correction Eiger) * Get rate correction Eiger)
* @returns 0 if rate correction disabled, > 0 otherwise * @returns 0 if rate correction disabled, > 0 otherwise
*/ */
int getRateCorrection(); int64_t getRateCorrection();
/** /**
* Prints receiver configuration * Prints receiver configuration
* @returns OK or FAIL * #param level print level
*/ */
int printReceiverConfiguration(); void printReceiverConfiguration(int level = logINFO);
/** /**
* Checks if receiver is online and set flag * Checks if receiver is online and set flag
@ -1824,28 +1789,21 @@ private:
/** /**
* reads a trim/settings file * reads a trim/settings file
* @param fname name of the file to be read * @param fname name of the file to be read
* @param iodelay io delay (detector specific)
* @param tau tau (detector specific)
* @param myMod pointer to the module structure which has to be set. <BR> * @param myMod pointer to the module structure which has to be set. <BR>
* If it is NULL a new module structure will be created * If it is NULL a new module structure will be created
* @param tb 1 to include trimbits, 0 to exclude (used for eiger) * @param tb 1 to include trimbits, 0 to exclude (used for eiger)
* @returns the pointer to myMod or NULL if reading the file failed * @returns the pointer to myMod or NULL if reading the file failed
*/ */
sls_detector_module* readSettingsFile(std::string fname, sls_detector_module* readSettingsFile(std::string fname, sls_detector_module* myMod=NULL, int tb=1);
int& iodelay, int& tau,
sls_detector_module* myMod=NULL, int tb=1);
/** /**
* writes a trim/settings file * writes a trim/settings file
* @param fname name of the file to be written * @param fname name of the file to be written
* @param mod module structure which has to be written to file * @param mod module structure which has to be written to file
* @param iodelay io delay (detector specific)
* @param tau tau (detector specific)
* @returns OK or FAIL if the file could not be written * @returns OK or FAIL if the file could not be written
*/ */
int writeSettingsFile(std::string fname, int writeSettingsFile(std::string fname, sls_detector_module mod);
sls_detector_module mod, int iodelay, int tau);
/** slsDetector Id or position in the detectors list */ /** slsDetector Id or position in the detectors list */
@ -1884,17 +1842,8 @@ private:
/** pointer to adc valuse in shared memory */ /** pointer to adc valuse in shared memory */
int *adcs; int *adcs;
/** pointer to chip registers in shared memory */
int *chipregs;
/** pointer to channal registers in shared memory */ /** pointer to channal registers in shared memory */
int *chanregs; int *chanregs;
/** pointer to gain values in shared memory */
int *gain;
/** pointer to offset values in shared memory */
int *offset;
}; };
#endif #endif

View File

@ -924,14 +924,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
++i; ++i;
/*! \page settings
- <b>pedestal [i]</b> starts acquisition for i frames, calculates pedestal and writes back to fpga. Used in GOTTHARD only. Only put! \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="pedestal"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
++i;
/* pots */ /* pots */
/*! \page settings /*! \page settings
@ -2725,16 +2717,16 @@ string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action, int d
if (action==HELP_ACTION) { if (action==HELP_ACTION) {
return helpRateCorr(action); return helpRateCorr(action);
} }
int fval; int64_t ival;
char answer[1000]; char answer[1000];
myDet->setOnline(ONLINE_FLAG, detPos); myDet->setOnline(ONLINE_FLAG, detPos);
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
sscanf(args[1],"%d",&fval); sscanf(args[1],"%lld",&ival);
myDet->setRateCorrection(fval, detPos); myDet->setRateCorrection(ival, detPos);
} }
sprintf(answer,"%d",myDet->getRateCorrection(detPos)); sprintf(answer,"%lld",myDet->getRateCorrection(detPos));
return string(answer); return string(answer);
} }
@ -3549,15 +3541,6 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action, int d
} }
sprintf(ans,"%d",myDet->setAllTrimbits(-1, detPos)); sprintf(ans,"%d",myDet->setAllTrimbits(-1, detPos));
return ans; return ans;
} else if (cmd=="pedestal") {
if (action==GET_ACTION)
return string("cannot get");
if (sscanf(args[1],"%d",&val)){
sprintf(ans,"%d",myDet->calibratePedestal(val, detPos));
return string(ans);
}else
return string("cannot parse frame number")+cmd;
} }
return string("unknown settings command ")+cmd; return string("unknown settings command ")+cmd;
@ -3574,8 +3557,6 @@ string slsDetectorCommand::helpSettings(int action) {
os << "thresholdnotb eV [sett]\n sets the detector threshold in eV without loading trimbits. If sett is provided for eiger, uses settings sett"<< std::endl; os << "thresholdnotb eV [sett]\n sets the detector threshold in eV without loading trimbits. If sett is provided for eiger, uses settings sett"<< std::endl;
os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl; os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl;
os << "trimval i \n sets all the trimbits to i" << std::endl; os << "trimval i \n sets all the trimbits to i" << std::endl;
os << "pedestal i \n starts acquisition for i frames, calculates pedestal and writes back to fpga."<< std::endl;
} }
if (action==GET_ACTION || action==HELP_ACTION) { if (action==GET_ACTION || action==HELP_ACTION) {
os << "settings \n gets the settings of the detector"<< std::endl; os << "settings \n gets the settings of the detector"<< std::endl;

View File

@ -55,7 +55,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
/* /*
* Get detector hostname * Get detector hostname
* @return NULL or hostname or NULL if uninitialized (max of 1000 characters) * @return hostname (max of 1000 characters)
*/ */
char *getDetectorHostname() const; char *getDetectorHostname() const;
@ -80,13 +80,13 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
fileFormat getFileFormat() const; fileFormat getFileFormat() const;
/** /**
* Get File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw)) * Get File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw))
* @return NULL or file name prefix (max of 1000 characters) * @return file name prefix
*/ */
char *getFileName() const; char *getFileName() const;
/** /**
* Get File Path * Get File Path
* @return NULL or file path (max of 1000 characters) * @return file path
*/ */
char *getFilePath() const; char *getFilePath() const;
@ -162,7 +162,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
/** /**
* Get Ehernet Interface * Get Ehernet Interface
* @ethernet interface. eg. eth0 or "" if listening to all (max of 1000 characters) * @ethernet interface. eg. eth0 or "" if listening to all
*/ */
char *getEthernetInterface() const; char *getEthernetInterface() const;

View File

@ -146,15 +146,7 @@ int slsReceiverImplementation::getDetectorPositionId() const{
char *slsReceiverImplementation::getDetectorHostname() const{ char *slsReceiverImplementation::getDetectorHostname() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return detHostname;
//not initialized
if(!strlen(detHostname))
return NULL;
char* output = new char[MAX_STR_LENGTH]();
strcpy(output,detHostname);
//freed by calling function
return output;
} }
int slsReceiverImplementation::getFlippedData(int axis) const{ int slsReceiverImplementation::getFlippedData(int axis) const{
@ -177,28 +169,12 @@ slsDetectorDefs::fileFormat slsReceiverImplementation::getFileFormat() const{
char *slsReceiverImplementation::getFileName() const{ char *slsReceiverImplementation::getFileName() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return fileName;
//not initialized
if(!strlen(fileName))
return NULL;
char* output = new char[MAX_STR_LENGTH]();
strcpy(output,fileName);
//freed by calling function
return output;
} }
char *slsReceiverImplementation::getFilePath() const{ char *slsReceiverImplementation::getFilePath() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return filePath;
//not initialized
if(!strlen(filePath))
return NULL;
char* output = new char[MAX_STR_LENGTH]();
strcpy(output,filePath);
//freed by calling function
return output;
} }
uint64_t slsReceiverImplementation::getFileIndex() const{ uint64_t slsReceiverImplementation::getFileIndex() const{
@ -296,11 +272,7 @@ uint32_t slsReceiverImplementation::getUDPPortNumber2() const{
char *slsReceiverImplementation::getEthernetInterface() const{ char *slsReceiverImplementation::getEthernetInterface() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return eth;
char* output = new char[MAX_STR_LENGTH]();
strcpy(output,eth);
//freed by calling function
return output;
} }
@ -397,21 +369,12 @@ uint32_t slsReceiverImplementation::getStreamingPort() const{
char *slsReceiverImplementation::getStreamingSourceIP() const{ char *slsReceiverImplementation::getStreamingSourceIP() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return streamingSrcIP;
char* output = new char[MAX_STR_LENGTH]();
strcpy(output,streamingSrcIP);
//freed by calling function
return output;
} }
char *slsReceiverImplementation::getAdditionalJsonHeader() const{ char *slsReceiverImplementation::getAdditionalJsonHeader() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return additionalJsonHeader;
char* output = new char[MAX_STR_LENGTH]();
memset(output, 0, MAX_STR_LENGTH);
strcpy(output,additionalJsonHeader);
//freed by calling function
return output;
} }
uint32_t slsReceiverImplementation::getUDPSocketBufferSize() const { uint32_t slsReceiverImplementation::getUDPSocketBufferSize() const {

View File

@ -370,6 +370,7 @@ int slsReceiverTCPIPInterface::lock_receiver() {
int slsReceiverTCPIPInterface::get_last_client_ip() { int slsReceiverTCPIPInterface::get_last_client_ip() {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess));
return interface->Server_SendResult(true, ret,mySock->lastClientIP, sizeof(mySock->lastClientIP)); return interface->Server_SendResult(true, ret,mySock->lastClientIP, sizeof(mySock->lastClientIP));
} }
@ -446,97 +447,82 @@ int slsReceiverTCPIPInterface::update_client() {
int slsReceiverTCPIPInterface::send_update() { int slsReceiverTCPIPInterface::send_update() {
int ind = -1; int ind = -1;
char defaultVal[MAX_STR_LENGTH] = {0}; char path[MAX_STR_LENGTH] = {0};
char* path = NULL;
int n = 0; int n = 0;
n += mySock->SendDataOnly(mySock->lastClientIP,sizeof(mySock->lastClientIP)); n += mySock->SendDataOnly(mySock->lastClientIP,sizeof(mySock->lastClientIP));
// filepath // filepath
path = receiver->getFilePath(); path = receiver->getFilePath();
if (path == NULL) n += mySock->SendDataOnly(path, sizeof(path));
n += mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH);
else {
n += mySock->SendDataOnly(path,MAX_STR_LENGTH);
delete[] path;
}
// filename // filename
path = receiver->getFileName(); path = receiver->getFileName();
if(path == NULL) n += mySock->SendDataOnly(path, sizeof(path));
n += mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH);
else {
n += mySock->SendDataOnly(path,MAX_STR_LENGTH);
delete[] path;
}
// index // index
ind=receiver->getFileIndex(); ind=receiver->getFileIndex();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
//file format //file format
ind=(int)receiver->getFileFormat(); ind=(int)receiver->getFileFormat();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
//frames per file //frames per file
ind=(int)receiver->getFramesPerFile(); ind=(int)receiver->getFramesPerFile();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
//frame discard policy //frame discard policy
ind=(int)receiver->getFrameDiscardPolicy(); ind=(int)receiver->getFrameDiscardPolicy();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
//frame padding //frame padding
ind=(int)receiver->getFramePaddingEnable(); ind=(int)receiver->getFramePaddingEnable();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
// file write enable // file write enable
ind=(int)receiver->getFileWriteEnable(); ind=(int)receiver->getFileWriteEnable();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
// file overwrite enable // file overwrite enable
ind=(int)receiver->getOverwriteEnable(); ind=(int)receiver->getOverwriteEnable();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
// gap pixels // gap pixels
ind=(int)receiver->getGapPixelsEnable(); ind=(int)receiver->getGapPixelsEnable();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
// streaming frequency // streaming frequency
ind=(int)receiver->getStreamingFrequency(); ind=(int)receiver->getStreamingFrequency();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
// streaming port // streaming port
ind=(int)receiver->getStreamingPort(); ind=(int)receiver->getStreamingPort();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
// streaming source ip // streaming source ip
path = receiver->getStreamingSourceIP(); path = receiver->getStreamingSourceIP();
mySock->SendDataOnly(path,MAX_STR_LENGTH); n += mySock->SendDataOnly(path, sizeof(path));
if (path != NULL)
delete[] path;
// additional json header // additional json header
path = receiver->getAdditionalJsonHeader(); path = receiver->getAdditionalJsonHeader();
mySock->SendDataOnly(path,MAX_STR_LENGTH); n += mySock->SendDataOnly(path, sizeof(path));
if (path != NULL)
delete[] path;
// data streaming enable // data streaming enable
ind=(int)receiver->getDataStreamEnable(); ind=(int)receiver->getDataStreamEnable();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
// activate // activate
ind=(int)receiver->getActivate(); ind=(int)receiver->getActivate();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
// deactivated padding enable // deactivated padding enable
ind=(int)receiver->getDeactivatedPadding(); ind=(int)receiver->getDeactivatedPadding();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
// silent mode // silent mode
ind=(int)receiver->getSilentMode(); ind=(int)receiver->getSilentMode();
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind, sizeof(ind));
if (!lockStatus) if (!lockStatus)
strcpy(mySock->lastClientIP,mySock->thisClientIP); strcpy(mySock->lastClientIP,mySock->thisClientIP);
@ -617,7 +603,7 @@ int slsReceiverTCPIPInterface::set_detector_type(){
int slsReceiverTCPIPInterface::set_detector_hostname() { int slsReceiverTCPIPInterface::set_detector_hostname() {
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
char hostname[MAX_STR_LENGTH] = {0}; char hostname[MAX_STR_LENGTH] = {0};
char* retval = NULL; char retval[MAX_STR_LENGTH] = {0};
// get args, return if socket crashed, ret is fail if receiver is not null // get args, return if socket crashed, ret is fail if receiver is not null
if (interface->Server_ReceiveArg(ret, mess, hostname,MAX_STR_LENGTH, true, receiver) == FAIL) if (interface->Server_ReceiveArg(ret, mess, hostname,MAX_STR_LENGTH, true, receiver) == FAIL)
@ -633,20 +619,14 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
} }
// get // get
retval = receiver->getDetectorHostname(); retval = receiver->getDetectorHostname();
if(retval == NULL) { if (strlen(retval)) {
ret = FAIL; ret = FAIL;
cprintf(RED, "Could not set hostname to %s\n", hostname); sprintf(mess, "hostname not set\n");
FILE_LOG(logERROR) << mess; FILE_LOG(logERROR) << mess;
} }
} }
interface->Server_SendResult(true, ret, return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess);
retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess);
if(retval != NULL)
delete[] retval;
return ret;
} }
@ -1048,7 +1028,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){
int slsReceiverTCPIPInterface::set_file_dir() { int slsReceiverTCPIPInterface::set_file_dir() {
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
char fPath[MAX_STR_LENGTH] = {0}; char fPath[MAX_STR_LENGTH] = {0};
char* retval=NULL; char retval[MAX_STR_LENGTH] = {0};
// get args, return if socket crashed, ret is fail if receiver is not null // get args, return if socket crashed, ret is fail if receiver is not null
if (interface->Server_ReceiveArg(ret, mess, fPath, sizeof(fPath), true, receiver) == FAIL) if (interface->Server_ReceiveArg(ret, mess, fPath, sizeof(fPath), true, receiver) == FAIL)
@ -1062,22 +1042,15 @@ int slsReceiverTCPIPInterface::set_file_dir() {
} }
// get // get
retval = receiver->getFilePath(); retval = receiver->getFilePath();
if (retval == NULL || (strlen(fPath) && strcasecmp(fPath, retval))) { if ((!strlen(retval)) || (strlen(fPath) && strcasecmp(fPath, retval))) {
ret = FAIL; ret = FAIL;
strcpy(mess,"receiver file path does not exist\n"); strcpy(mess,"receiver file path does not exist\n");
FILE_LOG(logERROR) << mess; FILE_LOG(logERROR) << mess;
} } else
if (retval != NULL) {
FILE_LOG(logDEBUG1) << "file path:" << retval; FILE_LOG(logDEBUG1) << "file path:" << retval;
}
} }
interface->Server_SendResult(true, ret, retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess); return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess);
if(retval != NULL)
delete[] retval;
return ret;
} }
@ -1085,7 +1058,7 @@ int slsReceiverTCPIPInterface::set_file_dir() {
int slsReceiverTCPIPInterface::set_file_name() { int slsReceiverTCPIPInterface::set_file_name() {
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
char fName[MAX_STR_LENGTH] = {0}; char fName[MAX_STR_LENGTH] = {0};
char* retval = NULL; char retval[MAX_STR_LENGTH] = {0};
// get args, return if socket crashed, ret is fail if receiver is not null // get args, return if socket crashed, ret is fail if receiver is not null
if (interface->Server_ReceiveArg(ret, mess, fName, sizeof(fName), true, receiver) == FAIL) if (interface->Server_ReceiveArg(ret, mess, fName, sizeof(fName), true, receiver) == FAIL)
@ -1099,22 +1072,15 @@ int slsReceiverTCPIPInterface::set_file_name() {
} }
// get // get
retval = receiver->getFileName(); retval = receiver->getFileName();
if(retval == NULL) { if (strlen(retval)) {
ret = FAIL; ret = FAIL;
strcpy(mess, "file name is empty\n"); strcpy(mess, "file name is empty\n");
FILE_LOG(logERROR) << mess; FILE_LOG(logERROR) << mess;
} } else
if (retval != NULL) {
FILE_LOG(logDEBUG1) << "file name:" << retval; FILE_LOG(logDEBUG1) << "file name:" << retval;
}
} }
interface->Server_SendResult(true, ret, retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess); return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess);
if(retval != NULL)
delete[] retval;
return ret;
} }
@ -1624,7 +1590,7 @@ int slsReceiverTCPIPInterface::set_streaming_port() {
int slsReceiverTCPIPInterface::set_streaming_source_ip() { int slsReceiverTCPIPInterface::set_streaming_source_ip() {
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
char arg[MAX_STR_LENGTH] = {0}; char arg[MAX_STR_LENGTH] = {0};
char* retval=NULL; char retval[MAX_STR_LENGTH] = {0};
// get args, return if socket crashed, ret is fail if receiver is not null // get args, return if socket crashed, ret is fail if receiver is not null
if (interface->Server_ReceiveArg(ret, mess, arg, MAX_STR_LENGTH, true, receiver) == FAIL) if (interface->Server_ReceiveArg(ret, mess, arg, MAX_STR_LENGTH, true, receiver) == FAIL)
@ -1642,13 +1608,7 @@ int slsReceiverTCPIPInterface::set_streaming_source_ip() {
FILE_LOG(logDEBUG1) << "streaming source ip:" << retval; FILE_LOG(logDEBUG1) << "streaming source ip:" << retval;
} }
interface->Server_SendResult(true, return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess);
ret, retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess);
if(retval != NULL)
delete[] retval;
return ret;
} }
@ -1758,7 +1718,7 @@ int slsReceiverTCPIPInterface::restream_stop(){
int slsReceiverTCPIPInterface::set_additional_json_header() { int slsReceiverTCPIPInterface::set_additional_json_header() {
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
char arg[MAX_STR_LENGTH] = {0}; char arg[MAX_STR_LENGTH] = {0};
char* retval=NULL; char retval[MAX_STR_LENGTH] = {0};
// get args, return if socket crashed, ret is fail if receiver is not null // get args, return if socket crashed, ret is fail if receiver is not null
if (interface->Server_ReceiveArg(ret, mess, arg, sizeof(arg), true, receiver) == FAIL) if (interface->Server_ReceiveArg(ret, mess, arg, sizeof(arg), true, receiver) == FAIL)
@ -1776,12 +1736,7 @@ int slsReceiverTCPIPInterface::set_additional_json_header() {
FILE_LOG(logDEBUG1) << "additional json header:" << retval; FILE_LOG(logDEBUG1) << "additional json header:" << retval;
} }
interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess);
if (retval != NULL)
delete[] retval;
return ret;
} }

View File

@ -240,16 +240,13 @@ public:
int nchip; /**< is the number of chips on the module */ int nchip; /**< is the number of chips on the module */
int ndac; /**< is the number of dacs on the module */ int ndac; /**< is the number of dacs on the module */
int nadc; /**< is the number of adcs on the module */ int nadc; /**< is the number of adcs on the module */
int reg; /**< is the module register (e.g. dynamic range?) int reg; /**< is the module register settings (gain level) */
\see moduleRegisterBit */ int iodelay; /**< iodelay */
int tau; /**< tau */
int eV; /**< threshold energy */
int *dacs; /**< is the pointer to the array of the dac values (in V) */ int *dacs; /**< is the pointer to the array of the dac values (in V) */
int *adcs; /**< is the pointer to the array of the adc values (in V) FLAT_FIELD_CORRECTION*/ int *adcs; /**< is the pointer to the array of the adc values (in V) */
int *chipregs; /**< is the pointer to the array of the chip registers int *chanregs; /**< is the pointer to the array of the channel registers */
\see ::chipRegisterBit */
int *chanregs; /**< is the pointer to the array of the channel registers
\see ::channelRegisterBit */
double gain; /**< is the module gain (V/keV) */
double offset; /**< is the module offset (V) */
} sls_detector_module; } sls_detector_module;

View File

@ -45,7 +45,6 @@ enum detFuncs{
F_LOAD_IMAGE, /**< Loads Dark/Gain image to the Gotthard detector */ F_LOAD_IMAGE, /**< Loads Dark/Gain image to the Gotthard detector */
F_READ_COUNTER_BLOCK, /**< reads the counter block memory for gotthard */ F_READ_COUNTER_BLOCK, /**< reads the counter block memory for gotthard */
F_RESET_COUNTER_BLOCK, /**< resets the counter block memory for gotthard */ F_RESET_COUNTER_BLOCK, /**< resets the counter block memory for gotthard */
F_CALIBRATE_PEDESTAL, /**< starts acquistion, calibrates pedestal and write back to fpga */
F_ENABLE_TEN_GIGA, /**< enable 10Gbe */ F_ENABLE_TEN_GIGA, /**< enable 10Gbe */
F_SET_ALL_TRIMBITS, /** < set all trimbits to this value */ F_SET_ALL_TRIMBITS, /** < set all trimbits to this value */
F_SET_CTB_PATTERN, /** < loads a pattern in the CTB */ F_SET_CTB_PATTERN, /** < loads a pattern in the CTB */
@ -160,7 +159,6 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_LOAD_IMAGE: return "F_LOAD_IMAGE"; case F_LOAD_IMAGE: return "F_LOAD_IMAGE";
case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK"; case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK";
case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK"; case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK";
case F_CALIBRATE_PEDESTAL: return "F_CALIBRATE_PEDESTAL";
case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA"; case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS"; case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN"; case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN";