mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
still updating slsdetector.cpp
This commit is contained in:
@ -24,7 +24,6 @@ const char* dac_names[16] = {"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","V
|
||||
int default_tau_from_file= -1;
|
||||
enum detectorSettings thisSettings;
|
||||
sls_detector_module *detectorModules=NULL;
|
||||
int *detectorChips=NULL;
|
||||
int *detectorChans=NULL;
|
||||
int *detectorDacs=NULL;
|
||||
int *detectorAdcs=NULL;
|
||||
@ -383,26 +382,24 @@ void allocateDetectorStructureMemory() {
|
||||
|
||||
//Allocation of memory
|
||||
detectorModules=malloc(sizeof(sls_detector_module));
|
||||
detectorChips=malloc(NCHIP*sizeof(int));
|
||||
detectorChans=malloc(NCHIP*NCHAN*sizeof(int));
|
||||
detectorDacs=malloc(NDAC*sizeof(int));
|
||||
detectorAdcs=malloc(NADC*sizeof(int));
|
||||
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, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs));
|
||||
FILE_LOG(logDEBUG5, ("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs));
|
||||
(detectorModules)->dacs=detectorDacs;
|
||||
(detectorModules)->adcs=detectorAdcs;
|
||||
(detectorModules)->chipregs=detectorChips;
|
||||
(detectorModules)->chanregs=detectorChans;
|
||||
(detectorModules)->ndac=NDAC;
|
||||
(detectorModules)->nadc=NADC;
|
||||
(detectorModules)->nchip=NCHIP;
|
||||
(detectorModules)->nchan=NCHIP*NCHAN;
|
||||
(detectorModules)->gain=0;
|
||||
(detectorModules)->offset=0;
|
||||
(detectorModules)->reg=0;
|
||||
(detectorModules)->iodelay=0;
|
||||
(detectorModules)->tau=0;
|
||||
(detectorModules)->eV=0;
|
||||
thisSettings = UNINITIALIZED;
|
||||
|
||||
// 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 retval[2];
|
||||
int i;
|
||||
int setModule(sls_detector_module myMod, char* mess) {
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
if (setIODelay(delay)!= delay) {
|
||||
FILE_LOG(logERROR, ("Could not set iodelay %d\n", delay));
|
||||
if (setIODelay(myMod.iodelay)!= myMod.iodelay) {
|
||||
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;
|
||||
}
|
||||
|
||||
// dacs
|
||||
for(i=0;i<myMod.ndac;i++)
|
||||
setDAC((enum DACINDEX)i,myMod.dacs[i],0,retval);
|
||||
// threshold
|
||||
if (myMod.eV >= 0)
|
||||
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
|
||||
#ifndef VIRTUAL
|
||||
if (myMod.nchan==0 && myMod.nchip == 0) {
|
||||
if (myMod.nchan == 0) {
|
||||
FILE_LOG(logINFO, ("Setting module without trimbits\n"));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Setting module with trimbits\n"));
|
||||
//includ gap pixels
|
||||
unsigned int tt[263680];
|
||||
int iy,ichip,ix,ip=0,ich=0;
|
||||
for(iy=0;iy<256;iy++) {
|
||||
for (ichip=0; ichip<4; ichip++) {
|
||||
for(ix=0;ix<256;ix++) {
|
||||
tt[ip++]=myMod.chanregs[ich++];
|
||||
int iy, ichip, ix, ip = 0, ich = 0;
|
||||
for (iy = 0; iy < 256; ++iy) {
|
||||
for (ichip = 0; ichip < 4; ++ichip) {
|
||||
for (ix = 0; ix < 256; ++ix) {
|
||||
tt[ip++] = myMod.chanregs[ich++];
|
||||
}
|
||||
if (ichip<3) {
|
||||
tt[ip++]=0;
|
||||
tt[ip++]=0;
|
||||
if (ichip < 3) {
|
||||
tt[ip++] = 0;
|
||||
tt[ip++] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//set trimbits
|
||||
if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt)) {
|
||||
FILE_LOG(logERROR, ("Could not set trimbits\n"));
|
||||
if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(), tt)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//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
|
||||
return thisSettings;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@ -882,13 +939,13 @@ int getModule(sls_detector_module *myMod) {
|
||||
tt = Feb_Control_GetTrimbits();
|
||||
|
||||
//exclude gap pixels
|
||||
int iy,ichip,ix,ip=0,ich=0;
|
||||
for(iy=0;iy<256;iy++) {
|
||||
for (ichip=0; ichip<4; ichip++) {
|
||||
for(ix=0;ix<256;ix++) {
|
||||
myMod->chanregs[ich++]=tt[ip++];
|
||||
int iy, ichip, ix, ip = 0, ich = 0;
|
||||
for (iy = 0; iy < 256; ++iy) {
|
||||
for (ichip = 0; ichip < 4; ++ichip) {
|
||||
for (ix = 0; ix < 256; ++iy) {
|
||||
myMod->chanregs[ich++] = tt[ip++];
|
||||
}
|
||||
if (ichip<3) {
|
||||
if (ichip < 3) {
|
||||
ip++;
|
||||
ip++;
|
||||
}
|
||||
@ -1728,7 +1785,7 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
|
||||
int ichip, idac, ichan, iadc;
|
||||
int idac, ichan, iadc;
|
||||
int ret=OK;
|
||||
|
||||
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;
|
||||
}
|
||||
//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))) {
|
||||
FILE_LOG(logINFO, ("Number of channels of source is larger than number of channels of destination\n"));
|
||||
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, ("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));
|
||||
destMod->ndac=srcMod->ndac;
|
||||
destMod->nadc=srcMod->nadc;
|
||||
@ -1766,23 +1817,22 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
destMod->nchan=srcMod->nchan;
|
||||
if (srcMod->reg>=0)
|
||||
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 ));
|
||||
if (srcMod->gain>=0)
|
||||
destMod->gain=srcMod->gain;
|
||||
if (srcMod->offset>=0)
|
||||
destMod->offset=srcMod->offset;
|
||||
|
||||
if ((destMod->nchip!=0) || (destMod->nchan!=0)) {
|
||||
for (ichip=0; ichip<(srcMod->nchip); ichip++) {
|
||||
if (*((srcMod->chipregs)+ichip)>=0)
|
||||
*((destMod->chipregs)+ichip)=*((srcMod->chipregs)+ichip);
|
||||
}
|
||||
if (destMod->nchan!=0) {
|
||||
for (ichan=0; ichan<(srcMod->nchan); ichan++) {
|
||||
if (*((srcMod->chanregs)+ichan)>=0)
|
||||
*((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan);
|
||||
}
|
||||
}
|
||||
else FILE_LOG(logINFO, ("Not Copying trimbits\n"));
|
||||
|
||||
for (idac=0; idac<(srcMod->ndac); idac++) {
|
||||
if (*((srcMod->dacs)+idac)>=0) {
|
||||
*((destMod->dacs)+idac)=*((srcMod->dacs)+idac);
|
||||
@ -1811,8 +1861,6 @@ int getNumberOfChips() {return NCHIP;}
|
||||
int getNumberOfDACs() {return NDAC;}
|
||||
int getNumberOfADCs() {return NADC;}
|
||||
int getNumberOfChannelsPerChip() {return NCHAN;}
|
||||
int getNumberOfGains() {return NGAIN;}
|
||||
int getNumberOfOffsets() {return NOFFSET;}
|
||||
|
||||
|
||||
|
||||
|
@ -49,8 +49,6 @@ enum {E_PARALLEL, E_NON_PARALLEL, E_SAFE};
|
||||
#define NCHIP (4)
|
||||
#define NADC (0)
|
||||
#define NDAC (16)
|
||||
#define NGAIN (0)
|
||||
#define NOFFSET (0)
|
||||
|
||||
|
||||
#define TEN_GIGA_BUFFER_SIZE (4112)
|
||||
|
@ -351,64 +351,36 @@ int receiveDataOnly(int file_des, void* buf,int length) {
|
||||
|
||||
|
||||
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 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);
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
FILE_LOG(logDEBUG5, ("module of size %d sent\n",ts));
|
||||
|
||||
// send dac
|
||||
n = sendData(file_des,myMod->dacs,sizeof(int)*nDacs,INT32);
|
||||
n = sendData(file_des,&(myMod->eV), sizeof(myMod->eV), INT32);
|
||||
if (!n) return -1; ts += n;
|
||||
FILE_LOG(logDEBUG5, ("dacs of size %d sent\n",ts));
|
||||
{
|
||||
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);
|
||||
// dacs
|
||||
n = sendData(file_des,myMod->dacs, sizeof(int)*(myMod->ndac), INT32);
|
||||
if (!n) return -1; ts += n;
|
||||
FILE_LOG(logDEBUG5, ("adcs of size %d sent\n", ts));
|
||||
|
||||
// some detectors dont require sending all trimbits etc.
|
||||
if(sendAll) {
|
||||
// chips
|
||||
n = sendData(file_des,myMod->chipregs,sizeof(int)*nChips,INT32);
|
||||
if (!n) return -1; ts += n;
|
||||
FILE_LOG(logDEBUG5, ("chips of size %d sent\n", ts));
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// adcs
|
||||
n = sendData(file_des,myMod->adcs, sizeof(int)*(myMod->nadc), INT32);
|
||||
if (!n) return -1; ts += n;
|
||||
// channels
|
||||
#ifdef EIGERD
|
||||
n = sendData(file_des,myMod->chanregs, sizeof(int) * (myMod->nchan), INT32);
|
||||
if (!n) return -1; ts += n;
|
||||
#endif
|
||||
FILE_LOG(logDEBUG5, ("module of size %d sent register %x\n", ts, myMod->reg));
|
||||
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) {
|
||||
return receiveModuleGeneral(file_des,myMod,1);
|
||||
}
|
||||
|
||||
int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll) {
|
||||
int ts = 0, n = 0;
|
||||
int *dacptr = myMod->dacs;
|
||||
int *adcptr = myMod->adcs;
|
||||
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;
|
||||
|
||||
int nDacs = myMod->ndac;
|
||||
int nAdcs = myMod->nadc;
|
||||
#ifdef EIGERD
|
||||
//exclude sending of trimbtis, nchips = 0,nchans = 0 in that case
|
||||
if(myMod->nchip == 0 && myMod->nchan == 0) {
|
||||
receiveAll = 0;
|
||||
nchipold = 0;
|
||||
nchanold = 0;
|
||||
}
|
||||
int nChans = myMod->nchan; // can be zero for no trimbits
|
||||
#endif
|
||||
|
||||
|
||||
nChips = myMod->nchip;
|
||||
nchipdiff = nChips-nchipold;
|
||||
if (nchipold != nChips) {
|
||||
FILE_LOG(logERROR, ("received wrong number of chips\n"));
|
||||
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->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
|
||||
FILE_LOG(logDEBUG5, ("received %d chips\n",nChips));
|
||||
|
||||
nChans = myMod->nchan;
|
||||
nchandiff = nChans-nchanold;
|
||||
if (nchanold != nChans) {
|
||||
FILE_LOG(logERROR, ("received wrong number of channels\n"));
|
||||
n = receiveData(file_des,&(myMod->dacs), sizeof(int) * (myMod->ndac), INT32);
|
||||
if (!n) return -1; ts += n;
|
||||
// adcs
|
||||
if (nAdcs != (myMod->nadc)) {
|
||||
FILE_LOG(logERROR, ("received wrong number of adcs. "
|
||||
"Expected %d, got %d\n", nAdcs, myMod->nadc));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
FILE_LOG(logDEBUG5, ("received %d chans\n",nChans));
|
||||
|
||||
|
||||
nDacs = myMod->ndac;
|
||||
ndacdiff = nDacs-ndold;
|
||||
if (ndold != nDacs) {
|
||||
FILE_LOG(logERROR, ("received wrong number of dacs\n"));
|
||||
}
|
||||
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->adcs), sizeof(int) * (myMod->nadc), INT32);
|
||||
if (!n) return -1; ts += n;
|
||||
// channels
|
||||
#ifdef EIGERD
|
||||
if (((myMod->nchan) != 0 ) || // no trimbits
|
||||
(nChans != (myMod->nchan))) { // with trimbits
|
||||
FILE_LOG(logERROR, ("received wrong number of channels. "
|
||||
"Expected %d, got %d\n", nChans, (myMod->nchan)));
|
||||
return 0;
|
||||
}
|
||||
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));
|
||||
return ts;
|
||||
}
|
||||
|
@ -38,9 +38,7 @@ int sendDataOnly(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 sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll);
|
||||
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
|
||||
|
@ -102,12 +102,7 @@ int64_t getTimeLeft(enum timerIndex ind);
|
||||
|
||||
|
||||
// parameters - module, settings
|
||||
|
||||
#ifdef EIGERD
|
||||
int setModule(sls_detector_module myMod, int delay);
|
||||
#else
|
||||
int setModule(sls_detector_module myMod);
|
||||
#endif
|
||||
int setModule(sls_detector_module myMod, char* mess);
|
||||
int getModule(sls_detector_module *myMod);
|
||||
enum detectorSettings setSettings(enum detectorSettings sett);
|
||||
enum detectorSettings getSettings();
|
||||
@ -233,10 +228,6 @@ int getTotalNumberOfChannels();
|
||||
int getNumberOfChips();
|
||||
int getNumberOfDACs();
|
||||
int getNumberOfADCs();
|
||||
#ifdef EIGERD
|
||||
int getNumberOfGains();
|
||||
int getNumberOfOffsets();
|
||||
#endif
|
||||
int getNumberOfChannelsPerChip();
|
||||
|
||||
|
||||
|
@ -156,7 +156,6 @@ const char* getFunctionName(enum detFuncs func) {
|
||||
case F_LOAD_IMAGE: return "F_LOAD_IMAGE";
|
||||
case F_READ_COUNTER_BLOCK: return "F_READ_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_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
|
||||
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_READ_COUNTER_BLOCK] = &read_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_SET_ALL_TRIMBITS] = &set_all_trimbits;
|
||||
flist[F_SET_CTB_PATTERN] = &set_ctb_pattern;
|
||||
@ -304,7 +302,7 @@ int M_nofunc(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
// to receive any arguments
|
||||
int n = 0;
|
||||
int n = 1;
|
||||
while (n > 0)
|
||||
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
|
||||
|
||||
@ -320,7 +318,7 @@ int M_nofuncMode(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
// to receive any arguments
|
||||
int n = 0;
|
||||
int n = 1;
|
||||
while (n > 0)
|
||||
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) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
enum detectorSettings retval = -1;
|
||||
|
||||
sls_detector_module module;
|
||||
int *myDac = NULL;
|
||||
int *myAdc = NULL;
|
||||
int *myChip = NULL;
|
||||
int *myChan = NULL;
|
||||
#ifdef EIGERD
|
||||
int ioDelay = -1;
|
||||
int tau = -1;
|
||||
int eV = -1;
|
||||
#endif
|
||||
module.dacs = NULL;
|
||||
module.adcs = NULL;
|
||||
module.chanregs = NULL;
|
||||
|
||||
// allocate to receive arguments
|
||||
// infinite loop to break out when FAIL or a final OK
|
||||
while(1) {
|
||||
// allocate dacs
|
||||
myDac = (int*)malloc(getNumberOfDACs() * sizeof(int));
|
||||
// error
|
||||
if (getNumberOfDACs() > 0 && myDac == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not allocate dacs\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
break;
|
||||
}
|
||||
// allocate dacs
|
||||
myDac = (int*)malloc(getNumberOfDACs() * sizeof(int));
|
||||
// error
|
||||
if (getNumberOfDACs() > 0 && myDac == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not allocate dacs\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else
|
||||
module.dacs = myDac;
|
||||
|
||||
// allocate adcs
|
||||
// allocate adcs
|
||||
if (ret == OK) {
|
||||
myAdc = (int*)malloc(getNumberOfADCs() * sizeof(int));
|
||||
// error
|
||||
if (getNumberOfADCs() > 0 && myAdc == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not allocate adcs\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
break;
|
||||
}
|
||||
module.adcs=myAdc;
|
||||
} else
|
||||
module.adcs = myAdc;
|
||||
}
|
||||
|
||||
// no need to allocate chips and chans for jungfrau, too much memory
|
||||
#ifdef JUNGFRAUD
|
||||
module.chipregs = NULL;
|
||||
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
|
||||
// allocate chans
|
||||
#ifdef EIGERD
|
||||
if (ret == OK) {
|
||||
myChan = (int*)malloc(getTotalNumberOfChannels() * sizeof(int));
|
||||
if (getTotalNumberOfChannels() > 0 && myChan == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not allocate chans\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
break;
|
||||
}
|
||||
module.chanregs=myChan;
|
||||
} else
|
||||
module.chanregs = myChan;
|
||||
}
|
||||
#endif
|
||||
// receive arguments
|
||||
if (ret == OK) {
|
||||
module.nchip = getNumberOfChips();
|
||||
module.nchan = getTotalNumberOfChannels();
|
||||
module.ndac = getNumberOfDACs();
|
||||
module.nadc = getNumberOfADCs();
|
||||
|
||||
// receive arguments (0 to partially receive module without trimbits
|
||||
if (receiveModuleGeneral(file_des, &module, (myDetectorType == JUNGFRAU) ? 0 : 1) < 0) {
|
||||
if (myChip != NULL) free(myChip);
|
||||
if (myChan != NULL) free(myChan);
|
||||
int ts = receiveModule(file_des, &module);
|
||||
if (ts < 0) {
|
||||
if (myChan != NULL) free(myChan);
|
||||
if (myDac != NULL) free(myDac);
|
||||
if (myAdc != NULL) free(myAdc);
|
||||
return printSocketReadError();
|
||||
}
|
||||
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.ndac, module.nadc, module.gain,module.offset));
|
||||
|
||||
#ifdef EIGERD
|
||||
int args[3] = {-1, -1};
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0) {
|
||||
if (myChip != NULL) free(myChip);
|
||||
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
|
||||
module.ndac, module.nadc, module.iodelay, module.tau, module.eV));
|
||||
// should at least have a dac
|
||||
if (ts <= sizeof(sls_detector_module)) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Cannot set module. Received incorrect number of dacs or adcs or channels\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// receive all arguments
|
||||
if (ret == FAIL) {
|
||||
int n = 0;
|
||||
int n = 1;
|
||||
while (n > 0)
|
||||
n = receiveData(file_des, mess, MAX_STR_LENGTH, OTHER);
|
||||
}
|
||||
|
||||
|
||||
// only set
|
||||
else if (Server_VerifyLock() != FAIL) {
|
||||
// check index
|
||||
@ -972,52 +941,12 @@ int set_module(int file_des) {
|
||||
break;
|
||||
}
|
||||
|
||||
// set
|
||||
#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));
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = setModule(module, mess);
|
||||
retval = getSettings();
|
||||
#endif
|
||||
validate(module.reg, (int)retval, "set module (settings)", 0);
|
||||
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 (myAdc != NULL) free(myAdc);
|
||||
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) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
sls_detector_module module;
|
||||
int *myDac = NULL;
|
||||
int *myAdc = NULL;
|
||||
int *myChip = NULL;
|
||||
int *myChan = NULL;
|
||||
module.dacs = NULL;
|
||||
module.adcs = NULL;
|
||||
module.chanregs = NULL;
|
||||
|
||||
// allocate to send arguments
|
||||
// infinite loop to break out when FAIL or a final OK
|
||||
while(1) {
|
||||
|
||||
// allocate dacs
|
||||
myDac = (int*)malloc(getNumberOfDACs() * sizeof(int));
|
||||
// error
|
||||
if (getNumberOfDACs() > 0 && myDac == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not allocate dacs\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
break;
|
||||
}
|
||||
// allocate dacs
|
||||
myDac = (int*)malloc(getNumberOfDACs() * sizeof(int));
|
||||
// error
|
||||
if (getNumberOfDACs() > 0 && myDac == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not allocate dacs\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else
|
||||
module.dacs = myDac;
|
||||
|
||||
// allocate adcs
|
||||
// allocate adcs
|
||||
if (ret == OK) {
|
||||
myAdc = (int*)malloc(getNumberOfADCs() * sizeof(int));
|
||||
// error
|
||||
if (getNumberOfADCs() > 0 && myAdc == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not allocate adcs\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
break;
|
||||
}
|
||||
module.adcs=myAdc;
|
||||
} else
|
||||
module.adcs=myAdc;
|
||||
}
|
||||
|
||||
// no need to allocate chips and chans for jungfrau, too much memory
|
||||
#ifdef JUNGFRAUD
|
||||
module.chipregs = NULL;
|
||||
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
|
||||
// allocate chans
|
||||
#ifdef EIGERD
|
||||
if (ret == OK) {
|
||||
myChan = (int*)malloc(getTotalNumberOfChannels() * sizeof(int));
|
||||
if (getTotalNumberOfChannels() > 0 && myChan == NULL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not allocate chans\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
break;
|
||||
}
|
||||
module.chanregs=myChan;
|
||||
} else
|
||||
module.chanregs=myChan;
|
||||
}
|
||||
#endif
|
||||
|
||||
// get module
|
||||
if (ret == OK) {
|
||||
module.nchip = getNumberOfChips();
|
||||
module.nchan = getTotalNumberOfChannels();
|
||||
module.ndac = getNumberOfDACs();
|
||||
@ -1105,10 +1019,9 @@ int get_module(int file_des) {
|
||||
|
||||
// send module, 0 is to receive partially (without trimbits etc)
|
||||
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 (myAdc != NULL) free(myAdc);
|
||||
return ret;
|
||||
@ -2014,7 +1927,6 @@ int load_image(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int args[2] = {-1, -1};
|
||||
int retval = -1;
|
||||
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
@ -2039,10 +1951,9 @@ int load_image(int file_des) {
|
||||
switch (index) {
|
||||
case DARK_IMAGE :
|
||||
case GAIN_IMAGE :
|
||||
retval = loadImage(index, ImageVals);
|
||||
FILE_LOG(logDEBUG5, ("Loading image retval: %d\n", retval));
|
||||
if (retval == -1) {
|
||||
ret = FAIL;
|
||||
ret = loadImage(index, ImageVals);
|
||||
FILE_LOG(logDEBUG5, ("Loading image ret: %d\n", ret));
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not load image\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
@ -2053,7 +1964,7 @@ int load_image(int file_des) {
|
||||
}
|
||||
}
|
||||
#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;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int startACQ = -1;
|
||||
char retval[dataBytes];
|
||||
memset(retval, 0, dataBytes);
|
||||
|
||||
if (receiveData(file_des, &startACQ, sizeof(startACQ), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
@ -2109,7 +2018,7 @@ int reset_counter_block(int file_des) {
|
||||
|
||||
// only set
|
||||
if (Server_VerifyLock() != FAIL) {
|
||||
ret = resetCounterBlock(startACQ, retval);
|
||||
ret = resetCounterBlock(startACQ);
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not reset counter block\n");
|
||||
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) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -2215,12 +2103,12 @@ int set_ctb_pattern(int file_des) {
|
||||
int write_adc_register(int file_des) {
|
||||
ret = OK;
|
||||
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)
|
||||
return printSocketReadError();
|
||||
int addr = args[0];
|
||||
int val = args[1];
|
||||
uint32_t addr = args[0];
|
||||
uint32_t val = args[1];
|
||||
FILE_LOG(logDEBUG5, ("Writing 0x%x to ADC Register 0x%x\n", val, addr));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
@ -2484,7 +2372,7 @@ int program_fpga(int file_des) {
|
||||
FILE_LOG(logDEBUG5, ("Programming FPGA\n"));
|
||||
#ifndef JUNGFRAUD
|
||||
//to receive any arguments
|
||||
int n = 0;
|
||||
int n = 1;
|
||||
while (n > 0)
|
||||
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
|
||||
functionNotImplemented();
|
||||
@ -2708,7 +2596,7 @@ int prepare_acquisition(int file_des) {
|
||||
|
||||
|
||||
|
||||
|
||||
// stop server
|
||||
int threshold_temp(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -2738,11 +2626,11 @@ int threshold_temp(int file_des) {
|
||||
}
|
||||
}
|
||||
#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) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -2763,12 +2651,12 @@ int temp_control(int file_des) {
|
||||
validate(arg, retval, "set temperature control", 0);
|
||||
}
|
||||
#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) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -2789,7 +2677,7 @@ int temp_event(int file_des) {
|
||||
validate(arg, retval, "set temperature event", 0);
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval));
|
||||
return Server_SendResult(file_des, INT32, 0, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user