mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
jungfrau done but not merged
This commit is contained in:
@ -421,9 +421,11 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
ts+=sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32);
|
||||
ts+=sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32);
|
||||
ts+=sendData(file_des,myMod->dacs,sizeof(myMod->ndac),OTHER);
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
ts+=sendData(file_des,myMod->adcs,sizeof(myMod->nadc),OTHER);
|
||||
ts+=sendData(file_des,myMod->chipregs,sizeof(myMod->nchip),OTHER);
|
||||
ts+=sendData(file_des,myMod->chanregs,sizeof(myMod->nchan),OTHER);
|
||||
#endif
|
||||
ts+=sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER);
|
||||
ts+=sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER);
|
||||
|
||||
@ -436,6 +438,8 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
for (idac=0; idac< nDacs; idac++)
|
||||
printf("dac %d is %d\n",idac,(int)myMod->dacs[idac]);
|
||||
#endif
|
||||
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
ts+= sendData(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs,INT32);
|
||||
#ifdef VERBOSE
|
||||
printf("adcs %d of size %d sent\n",myMod->module, ts);
|
||||
@ -448,6 +452,8 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
#ifdef VERBOSE
|
||||
printf("chans %d of size %d sent - %d\n",myMod->module, ts, myMod->nchan);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("module %d of size %d sent register %x\n",myMod->module, ts, myMod->reg);
|
||||
#endif
|
||||
@ -508,12 +514,10 @@ int receiveChip(int file_des, sls_detector_chip* myChip) {
|
||||
}
|
||||
|
||||
int receiveModule(int file_des, sls_detector_module* myMod) {
|
||||
|
||||
|
||||
int ts=0;
|
||||
dacs_t *dacptr=myMod->dacs;
|
||||
dacs_t *adcptr=myMod->adcs;
|
||||
int *chipptr=myMod->chipregs, *chanptr=myMod->chanregs;
|
||||
int ts=0;
|
||||
int nChips, nchipold=myMod->nchip, nchipdiff;
|
||||
int nChans, nchanold=myMod->nchan, nchandiff;
|
||||
int nDacs, ndold=myMod->ndac, ndacdiff;
|
||||
@ -530,17 +534,19 @@ int receiveModule(int file_des, sls_detector_module* myMod) {
|
||||
ts+=receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32);
|
||||
ts+=receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32);
|
||||
ts+=receiveData(file_des,myMod->dacs,sizeof(myMod->ndac),INT32);
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
ts+=receiveData(file_des,myMod->adcs,sizeof(myMod->nadc),INT32);
|
||||
ts+=receiveData(file_des,myMod->chipregs,sizeof(myMod->nchip),INT32);
|
||||
ts+=receiveData(file_des,myMod->chanregs,sizeof(myMod->nchan),INT32);
|
||||
#endif
|
||||
ts+=receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER);
|
||||
ts+=receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER);
|
||||
printf(RED,"ts:%d\n",ts);
|
||||
|
||||
myMod->dacs=dacptr;
|
||||
myMod->adcs=adcptr;
|
||||
myMod->chipregs=chipptr;
|
||||
myMod->chanregs=chanptr;
|
||||
|
||||
|
||||
nChips=myMod->nchip;
|
||||
nchipdiff=nChips-nchipold;
|
||||
if (nchipold!=nChips) {
|
||||
@ -585,6 +591,7 @@ printf(RED,"ts:%d\n",ts);
|
||||
ts+=receiveData(file_des,myMod->dacs, sizeof(dacs_t)*nDacs,INT32);
|
||||
#ifdef VERBOSE
|
||||
printf("dacs received\n");
|
||||
int id;
|
||||
for (id=0; id<nDacs; id++)
|
||||
printf("dac %d val %d\n",id, (int)myMod->dacs[id]);
|
||||
|
||||
@ -599,9 +606,10 @@ printf(RED,"ts:%d\n",ts);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
if (nadcdiff<=0) {
|
||||
ts+=receiveData(file_des,myMod->adcs, sizeof(dacs_t)*nAdcs,INT32);
|
||||
#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
printf("adcs received\n");
|
||||
#endif
|
||||
} else {
|
||||
@ -615,7 +623,7 @@ printf(RED,"ts:%d\n",ts);
|
||||
|
||||
if (nchipdiff<=0) {
|
||||
ts+=receiveData(file_des,myMod->chipregs, sizeof(int)*nChips,INT32);
|
||||
#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
printf("chips received\n");
|
||||
#endif
|
||||
} else {
|
||||
@ -629,7 +637,7 @@ printf(RED,"ts:%d\n",ts);
|
||||
|
||||
if (nchandiff<=0) {
|
||||
ts+=receiveData(file_des,myMod->chanregs, sizeof(int)*nChans,INT32);
|
||||
#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
printf("chans received\n");
|
||||
#endif
|
||||
} else {
|
||||
@ -640,8 +648,10 @@ printf(RED,"ts:%d\n",ts);
|
||||
free(chanptr);
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
printf("received module %d of size %d register %x\n",myMod->module,ts,myMod->reg);
|
||||
#endif
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
@ -64,7 +64,11 @@ struct timeval tss,tse,tsss; //for timing
|
||||
|
||||
|
||||
//for memory mapping
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
u_int32_t CSP0BASE;
|
||||
#else
|
||||
u_int64_t CSP0BASE;
|
||||
#endif
|
||||
|
||||
FILE *debugfp, *datafp;
|
||||
|
||||
@ -155,8 +159,8 @@ int mapCSP0(void) {
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
printf("CSPObase is 0x%x \n",CSP0BASE);
|
||||
printf("CSPOBASE=from %08x to %x\n",CSP0BASE,CSP0BASE+MEM_SIZE);
|
||||
printf("CSPObase is 0x%08x \n",CSP0BASE);
|
||||
printf("CSPOBASE=from %08x to %08x\n",CSP0BASE,CSP0BASE+MEM_SIZE);
|
||||
|
||||
u_int32_t address;
|
||||
address = FIFO_DATA_REG;//_OFF;
|
||||
@ -383,7 +387,6 @@ u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val, int trig) {
|
||||
|
||||
u_int32_t getPllReconfigReg(u_int32_t reg, int trig) {
|
||||
|
||||
int i;
|
||||
u_int32_t val=reg<<PLL_CNTR_ADDR_OFF;
|
||||
u_int32_t vv;
|
||||
|
||||
@ -431,7 +434,7 @@ void configurePll(int i) {
|
||||
u_int32_t l=0x0c;
|
||||
u_int32_t h=0x0d;
|
||||
u_int32_t val;
|
||||
int32_t phase=0, inv=0, ic=0;
|
||||
int32_t phase=0, inv=0;
|
||||
|
||||
u_int32_t tot;
|
||||
u_int32_t odd=1;//0;
|
||||
@ -543,13 +546,10 @@ void configurePll(int i) {
|
||||
u_int32_t setClockDivider(int d, int ic) {
|
||||
|
||||
|
||||
u_int32_t l=0x0c;
|
||||
u_int32_t h=0x0d;
|
||||
u_int32_t val;
|
||||
int i;
|
||||
//u_int32_t l=0x0c;
|
||||
//u_int32_t h=0x0d;
|
||||
|
||||
u_int32_t tot= PLL_VCO_FREQ_MHZ/d;
|
||||
u_int32_t odd=0;
|
||||
|
||||
// int ic=0 is run clk; ic=1 is adc clk
|
||||
printf("set clk divider %d to %d\n", ic, d);
|
||||
@ -581,7 +581,6 @@ u_int32_t setClockDivider(int d, int ic) {
|
||||
|
||||
int phaseStep(int st){
|
||||
|
||||
int i;
|
||||
if (st>65535 || st<-65535)
|
||||
return clkPhase[0];
|
||||
|
||||
@ -1128,15 +1127,20 @@ u_int32_t testFpga(void) {
|
||||
// for fpga test
|
||||
u_int32_t testRAM(void) {
|
||||
int result=OK;
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
cprintf(RED,"TestRAM not implemented for Jungfrau\n");
|
||||
#else
|
||||
int i=0;
|
||||
allocateRAM();
|
||||
// while(i<100000) {
|
||||
memcpy(ram_values, values, dataBytes);
|
||||
printf ("Testing RAM:\t%d: copied fifo %x to memory %x size %d\n",i++, (unsigned int)(values), (unsigned int)(ram_values), dataBytes);
|
||||
// }
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int getNModBoard() {
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
return 1;
|
||||
@ -1341,11 +1345,15 @@ int64_t getFramesFromStart(){
|
||||
|
||||
|
||||
ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret) {
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
cprintf(RED,"ROI Not implemented for Jungfrau yet\n");
|
||||
return NULL;
|
||||
#else
|
||||
|
||||
ROI retval[MAX_ROIS];
|
||||
int i, ich;
|
||||
adcDisableMask=0xfffffffff; /**has one f too many?, dhanya*/
|
||||
|
||||
adcDisableMask=0xfffffffff;
|
||||
|
||||
printf("Setting ROI\n");
|
||||
if (nroi>=0) {
|
||||
if (nroi==0) {
|
||||
@ -1398,10 +1406,14 @@ ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret) {
|
||||
}
|
||||
getDynamicRange();
|
||||
return retval;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int loadImage(int index, short int ImageVals[]){
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
cprintf(RED,"loadImage Not implemented for Jungfrau yet\n"); //compiler warnings on 1st argument of memcpy(ptr,ImageVals ,dataBytes);
|
||||
#else
|
||||
u_int32_t address;
|
||||
switch (index) {
|
||||
case DARK_IMAGE :
|
||||
@ -1421,6 +1433,7 @@ int loadImage(int index, short int ImageVals[]){
|
||||
memcpy(ptr,ImageVals ,dataBytes);
|
||||
#ifdef VERBOSE
|
||||
printf("\nLoaded x%08x address with image of index %d\n",(unsigned int)(ptr),index);
|
||||
#endif
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
@ -1694,7 +1707,7 @@ ip.ip_destip = destip;
|
||||
while (sum>>16) sum = (sum & 0xffff) + (sum >> 16);// Fold 32-bit sum to 16 bits
|
||||
checksum = (~sum)&0xffff;
|
||||
|
||||
printf("IP checksum is 0x%x\n",checksum);
|
||||
printf("IP checksum is 0x%lx\n",checksum);
|
||||
|
||||
|
||||
bus_w(DETECTORIP_AREG,sourceip);//detectorip_AReg_c
|
||||
@ -1718,7 +1731,7 @@ ip.ip_destip = destip;
|
||||
bus_w(CONFIG_REG,conf | GB10_NOT_CPU_BIT);
|
||||
printf("System status register is %08x\n",bus_r(SYSTEM_STATUS_REG));
|
||||
|
||||
return;
|
||||
return 0; //any value doesnt matter - dhanya
|
||||
/* } */
|
||||
|
||||
/* #ifdef DDEBUG */
|
||||
@ -2094,7 +2107,7 @@ u_int16_t* fifo_read_event(int ns)
|
||||
int i=0;//, j=0;
|
||||
/* volatile u_int16_t volatile *dum; */
|
||||
volatile u_int16_t a;
|
||||
volatile u_int32_t val;
|
||||
/*volatile u_int32_t val;*/
|
||||
// volatile u_int32_t volatile *dum;
|
||||
// volatile u_int32_t a;
|
||||
|
||||
@ -2337,12 +2350,15 @@ int setDynamicRange(int dr) {
|
||||
|
||||
|
||||
int getDynamicRange() {
|
||||
// dynamicRange=16;
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
dynamicRange=16;
|
||||
return dynamicRange;
|
||||
#else
|
||||
nSamples=bus_r(NSAMPLES_REG);
|
||||
getChannels();
|
||||
dataBytes=nModX*NCHIP*getChannels()*2;
|
||||
return dynamicRange*bus_r(NSAMPLES_REG);//nSamples;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
int testBus() {
|
||||
@ -2418,7 +2434,7 @@ int allocateRAM() {
|
||||
|
||||
|
||||
//#ifdef VERBOSE
|
||||
printf("reallocating ram %x, size %d\n",(unsigned int)ram_values, size);
|
||||
printf("reallocating ram %x, size %d\n",(unsigned int)ram_values, (int)size);
|
||||
//#endif
|
||||
//+2 was added since dma_memcpy would switch the 16 bit values and the mem is 32 bit
|
||||
|
||||
@ -2456,7 +2472,7 @@ int writeADC(int addr, int val) {
|
||||
|
||||
|
||||
u_int32_t valw,codata,csmask;
|
||||
int i,cdx,ddx,j;
|
||||
int i,cdx,ddx;
|
||||
cdx=0; ddx=1;
|
||||
csmask=0xfc; // 1111100
|
||||
|
||||
@ -2503,8 +2519,8 @@ int writeADC(int addr, int val) {
|
||||
|
||||
int prepareADC(){
|
||||
printf("Preparing ADC\n");
|
||||
u_int32_t valw,codata,csmask;
|
||||
int i,cdx,ddx,j;
|
||||
u_int32_t codata,csmask;
|
||||
int cdx,ddx;
|
||||
cdx=0; ddx=1;
|
||||
csmask=0x7c; // 1111100
|
||||
|
||||
@ -2563,8 +2579,11 @@ int prepareADC(){
|
||||
|
||||
bus_w(ADC_OFFSET_REG,0xbbbbbbbb);
|
||||
// bus_w(ADC_INVERSION_REG,0x1f6170c6);
|
||||
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
return;
|
||||
#else
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -2993,7 +3012,7 @@ int calibratePedestal(int frames){
|
||||
|
||||
int a;
|
||||
for (a=0;a<1280; a++){
|
||||
unsigned short v = (frame[a] << 8) + (frame[a] >> 8);
|
||||
//unsigned short v = (frame[a] << 8) + (frame[a] >> 8);
|
||||
// printf("%i: %i %i\n",a, frame[a],v);
|
||||
avg[a] += ((double)frame[a])/(double)frames;
|
||||
//if(frame[a] == 8191)
|
||||
@ -3020,7 +3039,7 @@ int calibratePedestal(int frames){
|
||||
|
||||
|
||||
|
||||
double nf = (double)numberFrames;
|
||||
//double nf = (double)numberFrames;
|
||||
for(i =0; i < 1280; i++){
|
||||
adc = i / 256;
|
||||
adcCh = (i - adc * 256) / 32;
|
||||
@ -3193,7 +3212,6 @@ int setPatternLoop(int level, int *start, int *stop, int *n) {
|
||||
|
||||
|
||||
int setPatternWaitAddress(int level, int addr) {
|
||||
int ret=-1;
|
||||
int reg;
|
||||
|
||||
switch (level) {
|
||||
@ -3222,7 +3240,6 @@ int setPatternWaitAddress(int level, int addr) {
|
||||
|
||||
|
||||
uint64_t setPatternWaitTime(int level, uint64_t t) {
|
||||
uint64_t ret=-1;
|
||||
int reglsb;
|
||||
int regmsb;
|
||||
|
||||
@ -3256,7 +3273,7 @@ void initDac(int dacnum) {
|
||||
|
||||
u_int32_t offw,codata;
|
||||
u_int16_t valw;
|
||||
int iru,i,ddx,csdx,cdx;
|
||||
int i,ddx,csdx,cdx;
|
||||
|
||||
|
||||
|
||||
@ -3343,8 +3360,7 @@ int setDac(int dacnum,int dacvalue){
|
||||
|
||||
u_int32_t offw,codata;
|
||||
u_int16_t valw;
|
||||
int iru,i,ddx,csdx,cdx;
|
||||
int retval;
|
||||
int i,ddx,csdx,cdx;
|
||||
|
||||
int dacch=0;
|
||||
|
||||
|
@ -69,6 +69,9 @@ int setContinousReadOut(int d);
|
||||
int startReceiver(int d);
|
||||
|
||||
int setDACRegister(int idac, int val, int imod);
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
int getDacRegister(int dacnum);
|
||||
#endif
|
||||
|
||||
int getTemperature(int tempSensor,int imod);
|
||||
int initHighVoltage(int val,int imod);
|
||||
@ -82,6 +85,9 @@ int getAdcConfigured();
|
||||
|
||||
u_int64_t getDetectorNumber();
|
||||
u_int32_t getFirmwareVersion();
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
u_int32_t getFirmwareSVNVersion();
|
||||
#endif
|
||||
int testFifos(void);
|
||||
u_int32_t testFpga(void);
|
||||
u_int32_t testRAM(void);
|
||||
@ -144,8 +150,17 @@ int setDynamicRange(int dr);
|
||||
int getDynamicRange();
|
||||
int getNModBoard();
|
||||
int setNMod(int n);
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
int getNMod();
|
||||
#endif
|
||||
int setStoreInRAM(int b);
|
||||
int allocateRAM();
|
||||
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
int writeADC(int addr, int val);
|
||||
int prepareADC();
|
||||
#endif
|
||||
|
||||
int clearRAM();
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -55,25 +55,33 @@ int initDetector() {
|
||||
#ifdef VERBOSE
|
||||
printf("Board is for %d modules\n",n);
|
||||
#endif
|
||||
|
||||
detectorModules=malloc(n*sizeof(sls_detector_module));
|
||||
detectorDacs=malloc(n*NDAC*sizeof(int));
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
detectorChips=malloc(n*NCHIP*sizeof(int));
|
||||
detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int));
|
||||
detectorDacs=malloc(n*NDAC*sizeof(int));
|
||||
detectorAdcs=malloc(n*NADC*sizeof(int));
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n));
|
||||
printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*NDAC));
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*NCHIP));
|
||||
printf("chans from 0x%x to 0x%x\n",(unsigned int)(detectorChans), (unsigned int)(detectorChans+n*NCHIP*NCHAN));
|
||||
printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*NDAC));
|
||||
printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*NADC));
|
||||
#endif
|
||||
for (imod=0; imod<n; imod++) {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
for (imod=0; imod<n; imod++) {
|
||||
(detectorModules+imod)->dacs=detectorDacs+imod*NDAC;
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
(detectorModules+imod)->adcs=detectorAdcs+imod*NADC;
|
||||
(detectorModules+imod)->chipregs=detectorChips+imod*NCHIP;
|
||||
(detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN;
|
||||
#endif
|
||||
(detectorModules+imod)->ndac=NDAC;
|
||||
(detectorModules+imod)->nadc=NADC;
|
||||
(detectorModules+imod)->nchip=NCHIP;
|
||||
@ -209,6 +217,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
|
||||
// printf("copying gain and offset %f %f to %f %f\n",srcMod->gain,srcMod->offset,destMod->gain,destMod->offset);
|
||||
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
for (ichip=0; ichip<(srcMod->nchip); ichip++) {
|
||||
if (*((srcMod->chipregs)+ichip)>=0)
|
||||
*((destMod->chipregs)+ichip)=*((srcMod->chipregs)+ichip);
|
||||
@ -217,14 +226,19 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
if (*((srcMod->chanregs)+ichan)>=0)
|
||||
*((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (idac=0; idac<(srcMod->ndac); idac++) {
|
||||
if (*((srcMod->dacs)+idac)>=0)
|
||||
*((destMod->dacs)+idac)=*((srcMod->dacs)+idac);
|
||||
}
|
||||
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
for (iadc=0; iadc<(srcMod->nadc); iadc++) {
|
||||
if (*((srcMod->adcs)+iadc)>=0)
|
||||
*((destMod->adcs)+iadc)=*((srcMod->adcs)+iadc);
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1543,7 +1557,7 @@ int initModulebyNumber(sls_detector_module myMod) {
|
||||
// int ow;
|
||||
/* int v[NDAC];*/
|
||||
int retval =-1, idac;
|
||||
printf("111\n");
|
||||
|
||||
|
||||
nchip=myMod.nchip;
|
||||
nchan=(myMod.nchan)/nchip;
|
||||
@ -1597,11 +1611,11 @@ printf("111\n");
|
||||
for (idac=0; idac<NDAC; idac++){
|
||||
retval = setDac(idac,(myMod.dacs)[idac]);
|
||||
if(retval ==(myMod.dacs)[idac])
|
||||
cprintf(BLUE,"Setting dac %d to %d\n",idac,retval);
|
||||
printf("Setting dac %d to %d\n",idac,retval);
|
||||
else
|
||||
printf("Error: Could not set dac %d, wrote %d but read %d\n",idac,(myMod.dacs)[idac],retval);
|
||||
}
|
||||
printf("before copy\n");
|
||||
|
||||
if (detectorModules) {
|
||||
for (im=modmi; im<modma; im++) {
|
||||
#ifdef VERBOSE
|
||||
@ -1610,10 +1624,8 @@ printf("111\n");
|
||||
copyModule(detectorModules+im,&myMod);
|
||||
}
|
||||
}
|
||||
printf("after copy\n");
|
||||
//setting the conf gain and the settings register
|
||||
setSettings(myMod.reg,imod);
|
||||
printf("after settings\n");
|
||||
return thisSettings;
|
||||
}
|
||||
|
||||
|
@ -104,13 +104,16 @@ int selMod(int mod,int imod );
|
||||
/* int set_one_dac(int imod); */
|
||||
/* int initDAC(int dac_addr, int value,int imod ); */
|
||||
/* int initDACs(int* v,int imod ); */
|
||||
/* int setSettings(int i,int imod); */
|
||||
/* int initDACbyIndex(int ind,int val, int imod); */
|
||||
/* int initDACbyIndexDACU(int ind,int val, int imod); */
|
||||
/* int getDACbyIndexDACU(int ind, int imod); */
|
||||
/* int getThresholdEnergy(); */
|
||||
/* int setThresholdEnergy(int ethr); */
|
||||
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
int setSettings(int i,int imod);
|
||||
#endif
|
||||
|
||||
/* Other DAC index routines*/
|
||||
int getTemperatureByModule(int tempSensor, int imod);
|
||||
int initHighVoltageByModule(int val, int imod);
|
||||
|
@ -31,7 +31,8 @@
|
||||
#define DBIT_PIPELINE_REG 0x59<<11
|
||||
#define MEM_MACHINE_FIFOS_REG 0x4f<<11
|
||||
#define CONFGAIN_REG 0x5d<<11 /** was actually GAIN_REG which seems to be set to 0 later in this file*/
|
||||
|
||||
#else
|
||||
#define ADC_INVERSION_REG 67<<11 /** picked up from after ADC_OFFSET_REG*/
|
||||
#endif
|
||||
|
||||
|
||||
@ -130,7 +131,7 @@
|
||||
//#define HV_REG 67<<11//0x20<<11
|
||||
|
||||
#define ADC_OFFSET_REG 66<<11
|
||||
#define ADC_INVERSION_REG 67<<11
|
||||
|
||||
|
||||
//#define MUTIME_REG 0x1a<<11
|
||||
//temperature
|
||||
|
@ -3,9 +3,11 @@
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "communication_funcs.h"
|
||||
#include "server_funcs.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
extern int sockfd;
|
||||
|
@ -59,7 +59,9 @@ int adcvpp=0x4;
|
||||
int init_detector(int b, int checkType) {
|
||||
|
||||
int i;
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
int retvalsize,ret;
|
||||
#endif
|
||||
if (mapCSP0()==FAIL) { printf("Could not map memory\n");
|
||||
exit(1);
|
||||
}
|
||||
@ -112,8 +114,7 @@ int init_detector(int b, int checkType) {
|
||||
if (b) {
|
||||
|
||||
|
||||
resetPLL();
|
||||
|
||||
resetPLL();
|
||||
bus_w16(CONTROL_REG, SYNC_RESET);
|
||||
bus_w16(CONTROL_REG, 0);
|
||||
bus_w16(CONTROL_REG, GB10_RESET_BIT);
|
||||
@ -142,6 +143,71 @@ int init_detector(int b, int checkType) {
|
||||
|
||||
initDac(0); initDac(8); //initializes the two dacs
|
||||
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
|
||||
if(myDetectorType==JUNGFRAU){
|
||||
//set dacs
|
||||
int retval = -1;
|
||||
int dacvalues[14][2]={
|
||||
{0, 1250}, //vout_cm
|
||||
{10, 1053}, //vin_com
|
||||
{1, 600}, //vb_sda
|
||||
{11, 1000}, //vb_colbuf
|
||||
{2, 3000}, //vb_test_cur
|
||||
{3, 830}, //vcascp_pixbuf
|
||||
{4, 1630}, //vcascn_pixbuf
|
||||
{12, 750}, //vb_pixbuf
|
||||
{6, 480}, //vref_ds
|
||||
{5, 1000}, //vb_ds
|
||||
{7, 400}, //vref_comp
|
||||
{13, 1220}, //vb_comp
|
||||
{8, 1500}, //vref_prech
|
||||
{9, 3000}, //vdd_prot
|
||||
};
|
||||
for(i=0;i<14;++i){
|
||||
retval=setDac(dacvalues[i][0], dacvalues[i][1]);
|
||||
if(retval!=dacvalues[i][1])
|
||||
printf("Error: Setting dac %d failed, wrote %d, read %d\n",dacvalues[i][0],dacvalues[i][1],retval);
|
||||
}
|
||||
|
||||
//power on the chips
|
||||
bus_w(POWER_ON_REG,0x1);
|
||||
|
||||
//reset adc
|
||||
writeADC(ADCREG1,0x3); writeADC(ADCREG1,0x0);
|
||||
writeADC(ADCREG2,0x40);
|
||||
writeADC(ADCREG3,0xf);
|
||||
writeADC(ADCREG4,0x3f);
|
||||
//vrefs - configurable?
|
||||
writeADC(ADCREG_VREFS,0x2);
|
||||
|
||||
|
||||
//set ADCINVERSionreg (by trial and error)
|
||||
bus_w(ADC_INVERSION_REG,0x453b2a9c);
|
||||
|
||||
//set adc_pipeline
|
||||
bus_w(ADC_PIPELINE_REG,0x20);
|
||||
|
||||
//set dbit_pipeline
|
||||
bus_w(DBIT_PIPELINE_REG,0x100e);
|
||||
usleep(1000000);//1s
|
||||
|
||||
//reset mem machine fifos fifos
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x4000);
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x0);
|
||||
|
||||
//reset run control
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x0400);
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x0);
|
||||
|
||||
//set default setting
|
||||
setSettings(DYNAMICGAIN,-1);
|
||||
cprintf(BLUE,"set to dynamic gain\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//Initialization
|
||||
setFrames(-1);
|
||||
setTrains(-1);
|
||||
@ -155,75 +221,20 @@ int init_detector(int b, int checkType) {
|
||||
setSynchronization(GET_SYNCHRONIZATION_MODE);
|
||||
startReceiver(0); //firmware
|
||||
}
|
||||
else printf("\n\n");
|
||||
|
||||
strcpy(mess,"dummy message");
|
||||
strcpy(lastClientIP,"none");
|
||||
strcpy(thisClientIP,"none1");
|
||||
lockStatus=0;
|
||||
// getDynamicRange();
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
setROI(-1,NULL,&retvalsize,&ret);
|
||||
allocateRAM();
|
||||
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
if(myDetectorType==JUNGFRAU){
|
||||
//set dacs
|
||||
int retval = -1;
|
||||
int dacvalues[14][2]={
|
||||
{0, 1250}, //vout_cm
|
||||
{10, 1053}, //vin_com
|
||||
{1, 600}, //vb_sda
|
||||
{11, 1000}, //vb_colbuf
|
||||
{2, 3000}, //vb_test_cur
|
||||
{3, 830}, //vcascp_pixbuf
|
||||
{4, 1630}, //vcascn_pixbuf
|
||||
{12, 750}, //vb_pixbuf
|
||||
{6, 480}, //vref_ds
|
||||
{5, 1000}, //vb_ds
|
||||
{7, 400}, //vref_comp
|
||||
{13, 1220}, //vb_comp
|
||||
{8, 1500}, //vref_prech
|
||||
{9, 3000}, //vdd_prot
|
||||
};
|
||||
for(i=0;i<14;++i){
|
||||
retval=setDac(dacvalues[i][0], dacvalues[i][1]);
|
||||
if(retval!=dacvalues[i][1])
|
||||
printf("Error: Setting dac %d failed, wrote %d, read %d\n",dacvalues[i][0],dacvalues[i][1],retval);
|
||||
}
|
||||
|
||||
//power on the chips
|
||||
bus_w(POWER_ON_REG,0x1);
|
||||
|
||||
//reset adc
|
||||
writeADC(ADCREG1,0x3); writeADC(ADCREG1,0x0);
|
||||
writeADC(ADCREG2,0x40);
|
||||
writeADC(ADCREG3,0xf);
|
||||
writeADC(ADCREG4,0x3f);
|
||||
//vrefs - configurable?
|
||||
writeADC(ADCREG_VREFS,0x2);
|
||||
|
||||
|
||||
//set ADCINVERSionreg (by trial and error)
|
||||
bus_w(ADC_INVERSION_REG,0x453b2a9c);
|
||||
|
||||
//set adc_pipeline
|
||||
bus_w(ADC_PIPELINE_REG,0x20);
|
||||
|
||||
//set dbit_pipeline
|
||||
bus_w(DBIT_PIPELINE_REG,0x100e);
|
||||
usleep(1000000);//1s
|
||||
|
||||
//reset mem machine fifos fifos
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x4000);
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x0);
|
||||
|
||||
//reset run control
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x0400);
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x0);
|
||||
|
||||
//set default setting
|
||||
setSettings(DYNAMICGAIN,-1);
|
||||
}
|
||||
allocateRAM(); //dhanya - already being done.. and all this should be inside if (b){} ??
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -231,9 +242,9 @@ int init_detector(int b, int checkType) {
|
||||
int decode_function(int file_des) {
|
||||
int fnum,n;
|
||||
int retval=FAIL;
|
||||
//#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
printf( "receive data\n");
|
||||
//#endif
|
||||
#endif
|
||||
n = receiveDataOnly(file_des,&fnum,sizeof(fnum));
|
||||
if (n <= 0) {
|
||||
#ifdef VERBOSE
|
||||
@ -246,15 +257,14 @@ int decode_function(int file_des) {
|
||||
printf("size of data received %d\n",n);
|
||||
#endif
|
||||
|
||||
//#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
printf( "calling function fnum = %d %x %x %x\n",fnum,(unsigned int)(flist[fnum]), (unsigned int)(flist[F_READ_REGISTER]),(unsigned int)(&read_register));
|
||||
//#endif
|
||||
#endif
|
||||
if (fnum<0 || fnum>255)
|
||||
fnum=255;
|
||||
retval=(*flist[fnum])(file_des);
|
||||
if (retval==FAIL)
|
||||
printf( "Error executing the function = %d \n",fnum);
|
||||
printf("retval:%d\n",retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -1027,7 +1037,6 @@ int set_dac(int file_des) {
|
||||
int imod;
|
||||
int n;
|
||||
int val;
|
||||
int idac=0;
|
||||
int mV=0;
|
||||
sprintf(mess,"Can't set DAC\n");
|
||||
|
||||
@ -1497,15 +1506,17 @@ int get_chip(int file_des) {
|
||||
}
|
||||
int set_module(int file_des) {
|
||||
sls_detector_module myModule;
|
||||
int *myDac=malloc(NDAC*sizeof(int));
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
int *myChip=malloc(NCHIP*sizeof(int));
|
||||
int *myChan=malloc(NCHIP*NCHAN*sizeof(int));
|
||||
int *myDac=malloc(NDAC*sizeof(int));
|
||||
int *myAdc=malloc(NADC*sizeof(int));
|
||||
#endif
|
||||
int retval, n;
|
||||
int ret=OK;
|
||||
int dr;// ow;
|
||||
|
||||
dr=setDynamicRange(-1); cprintf(BLUE,"drr:%d\n",dr);
|
||||
dr=setDynamicRange(-1);
|
||||
|
||||
if (myDac)
|
||||
myModule.dacs=myDac;
|
||||
@ -1513,6 +1524,8 @@ int set_module(int file_des) {
|
||||
sprintf(mess,"could not allocate dacs\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
if (myAdc)
|
||||
myModule.adcs=myAdc;
|
||||
else {
|
||||
@ -1531,6 +1544,12 @@ int set_module(int file_des) {
|
||||
sprintf(mess,"could not allocate chans\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
#else
|
||||
myModule.adcs=NULL;
|
||||
myModule.chipregs=NULL;
|
||||
myModule.chanregs=NULL;
|
||||
#endif
|
||||
|
||||
myModule.ndac=NDAC;
|
||||
myModule.nchip=NCHIP;
|
||||
myModule.nchan=NCHAN*NCHIP;
|
||||
@ -1588,10 +1607,16 @@ int set_module(int file_des) {
|
||||
} else {
|
||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||
}
|
||||
|
||||
free(myDac);
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
free(myChip);
|
||||
free(myChan);
|
||||
free(myDac);
|
||||
free(myAdc);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// setDynamicRange(dr); always 16 commented out
|
||||
printf("freed\n");
|
||||
@ -1615,11 +1640,12 @@ int get_module(int file_des) {
|
||||
|
||||
|
||||
sls_detector_module myModule;
|
||||
int *myDac=malloc(NDAC*sizeof(int));
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
int *myChip=malloc(NCHIP*sizeof(int));
|
||||
int *myChan=malloc(NCHIP*NCHAN*sizeof(int));
|
||||
int *myDac=malloc(NDAC*sizeof(int));/**dhanya*/
|
||||
int *myAdc=malloc(NADC*sizeof(int));/**dhanya*/
|
||||
|
||||
int *myAdc=malloc(NADC*sizeof(int));
|
||||
#endif
|
||||
|
||||
if (myDac)
|
||||
myModule.dacs=myDac;
|
||||
@ -1627,6 +1653,8 @@ int get_module(int file_des) {
|
||||
sprintf(mess,"could not allocate dacs\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
if (myAdc)
|
||||
myModule.adcs=myAdc;
|
||||
else {
|
||||
@ -1645,7 +1673,11 @@ int get_module(int file_des) {
|
||||
sprintf(mess,"could not allocate chans\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
#else
|
||||
myModule.adcs=NULL;
|
||||
myModule.chipregs=NULL;
|
||||
myModule.chanregs=NULL;
|
||||
#endif
|
||||
myModule.ndac=NDAC;
|
||||
myModule.nchip=NCHIP;
|
||||
myModule.nchan=NCHAN*NCHIP;
|
||||
@ -1690,13 +1722,12 @@ int get_module(int file_des) {
|
||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||
}
|
||||
|
||||
|
||||
|
||||
free(myDac);
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
free(myChip);
|
||||
free(myChan);
|
||||
free(myDac);
|
||||
free(myAdc);
|
||||
|
||||
#endif
|
||||
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
@ -2019,7 +2050,6 @@ int get_run_status(int file_des) {
|
||||
int read_frame(int file_des) {
|
||||
|
||||
|
||||
int ns=0;
|
||||
u_int16_t* p=NULL;
|
||||
|
||||
|
||||
@ -2410,7 +2440,6 @@ int set_roi(int file_des) {
|
||||
int retvalsize=0;
|
||||
ROI arg[MAX_ROIS];
|
||||
ROI* retval=0;
|
||||
int iroi;
|
||||
strcpy(mess,"Could not set/get roi\n");
|
||||
|
||||
|
||||
@ -2423,12 +2452,20 @@ int set_roi(int file_des) {
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
ret = FAIL;
|
||||
strcpy(mess,"Not applicable/implemented for this detector\n");
|
||||
printf("Error:Set ROI-%s",mess);
|
||||
#else
|
||||
|
||||
|
||||
if(nroi>=0){
|
||||
n = receiveDataOnly(file_des,arg,nroi*sizeof(ROI));
|
||||
if (n != (nroi*sizeof(ROI))) {
|
||||
sprintf(mess,"Received wrong number of bytes for ROI\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
//#ifdef VERBOSE
|
||||
|
||||
printf("Setting ROI to:");
|
||||
@ -2459,7 +2496,7 @@ int set_roi(int file_des) {
|
||||
sprintf(mess,"Could not set all roi, should have set %d rois, but only set %d rois\n",nroi,retvalsize);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if(ret==OK && differentClients){
|
||||
printf("Force update\n");
|
||||
@ -2612,7 +2649,6 @@ int set_speed(int file_des) {
|
||||
int set_readout_flags(int file_des) {
|
||||
|
||||
enum readOutFlags arg;
|
||||
int n;
|
||||
int ret=FAIL;
|
||||
|
||||
|
||||
@ -3441,7 +3477,6 @@ int write_adc_register(int file_des) {
|
||||
int arg[2];
|
||||
int addr, val;
|
||||
int n;
|
||||
u_int32_t address;
|
||||
|
||||
sprintf(mess,"Can't write to register\n");
|
||||
|
||||
|
@ -69,7 +69,9 @@ int set_dynamic_range(int);
|
||||
int set_roi(int);
|
||||
int get_roi(int);
|
||||
int set_speed(int);
|
||||
#ifndef JUNGFRAU_DHANYA
|
||||
void prepareADC(void);
|
||||
#endif
|
||||
int set_readout_flags(int);
|
||||
int execute_trimming(int);
|
||||
int lock_server(int);
|
||||
|
@ -155,6 +155,10 @@ int calccal_from_vthr(int vthr) {
|
||||
|
||||
int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
||||
int retval=OK;
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
cprintf(RED,"choose_vthresh_and_vtrim Not implemented for JungFrau\n");//did not want to fix warnings
|
||||
#else
|
||||
|
||||
#ifdef MCB_FUNCS
|
||||
int modma, modmi, nm;
|
||||
int thr, thrstep=5, nthr=31;
|
||||
@ -315,6 +319,7 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
||||
free(thrmi);
|
||||
free(thrma);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
@ -324,11 +329,14 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
||||
|
||||
|
||||
int trim_with_level(int countlim, int im) {
|
||||
int retval=OK;
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
cprintf(RED,"trim_with_level Not implemented for JungFrau\n"); //did not want to fix warnings
|
||||
#else
|
||||
int ich, itrim, ichan, ichip, imod;
|
||||
u_int32_t *scan;
|
||||
int *inttrim;
|
||||
int modma, modmi, nm;
|
||||
int retval=OK;
|
||||
int *fifodata;
|
||||
sls_detector_channel myChan;
|
||||
printf("trimming module number %d", im);
|
||||
@ -427,6 +435,7 @@ int trim_with_level(int countlim, int im) {
|
||||
}
|
||||
free(inttrim);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
@ -474,6 +483,9 @@ int ave(int *a, int n)
|
||||
int choose_vthresh() {
|
||||
|
||||
int retval=OK;
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
cprintf(RED,"choose_vthresh Not implemented for JungFrau\n"); //did not want to fix warnings
|
||||
#else
|
||||
#ifdef MCB_FUNCS
|
||||
int imod, ichan;
|
||||
u_int32_t *scan, *scan1;
|
||||
@ -599,6 +611,7 @@ int choose_vthresh() {
|
||||
free(scan);
|
||||
free(scan1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
@ -611,7 +624,9 @@ int trim_with_median(int stop, int im) {
|
||||
|
||||
|
||||
int retval=OK;
|
||||
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
cprintf(RED,"trim_with_median Not implemented for JungFrau\n"); //did not want to fix warnings
|
||||
#else
|
||||
#ifdef MCB_FUNCS
|
||||
int ichan, imod, ichip, ich;
|
||||
u_int32_t *scan, *scan1;
|
||||
@ -744,6 +759,7 @@ int trim_with_median(int stop, int im) {
|
||||
}
|
||||
free(olddiff);
|
||||
free(direction);
|
||||
#endif
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
@ -1075,25 +1075,29 @@ int slsDetector::sendChip(sls_detector_chip *myChip) {
|
||||
int slsDetector::sendModule(sls_detector_module *myMod) {
|
||||
int ts=0;
|
||||
//send module structure
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->module),sizeof(myMod->module));cout<<"module:"<<(myMod->module)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->serialnumber),sizeof(myMod->serialnumber));cout<<"serial number:"<<(myMod->serialnumber)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->nchan),sizeof(myMod->nchan));cout<<"nchan :"<<(myMod->nchan)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->nchip),sizeof(myMod->nchip));cout<<"nchip :"<<(myMod->nchip)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->ndac),sizeof(myMod->ndac));cout<<"ndac :"<<(myMod->ndac)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->nadc),sizeof(myMod->nadc));cout<<"nadc :"<<(myMod->nadc)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->reg),sizeof(myMod->reg));cout<<"reg :"<<(myMod->reg)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(myMod->ndac));cout<<"dacs :"<<(myMod->dacs[0])<<endl;
|
||||
ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(myMod->nadc));cout<<"adcs :none"<<endl;
|
||||
ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(myMod->nchip));cout<<"chipregs :"<<(myMod->serialnumber)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(myMod->nchan));cout<<"chanregs :"<<(myMod->serialnumber)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->gain), sizeof(myMod->gain));cout<<"gain :"<<(myMod->gain)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->offset), sizeof(myMod->offset));cout<<"offset :"<<(myMod->offset)<<endl;
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->module),sizeof(myMod->module));
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->serialnumber),sizeof(myMod->serialnumber));
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->nchan),sizeof(myMod->nchan));
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->nchip),sizeof(myMod->nchip));
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->ndac),sizeof(myMod->ndac));
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->nadc),sizeof(myMod->nadc));
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->reg),sizeof(myMod->reg));
|
||||
ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(myMod->ndac));
|
||||
|
||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
||||
ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(myMod->nadc));
|
||||
ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(myMod->nchip));
|
||||
ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(myMod->nchan));
|
||||
}
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->gain),sizeof(myMod->gain));
|
||||
ts+=controlSocket->SendDataOnly(&(myMod->offset), sizeof(myMod->offset));
|
||||
ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(dacs_t)*(myMod->ndac));
|
||||
ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc));
|
||||
ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip));
|
||||
ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan));
|
||||
|
||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
||||
ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc));
|
||||
ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip));
|
||||
ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan));
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
@ -1147,17 +1151,19 @@ int slsDetector::receiveModule(sls_detector_module* myMod) {
|
||||
ts+=controlSocket->ReceiveDataOnly(&(myMod->nadc),sizeof(myMod->nadc));
|
||||
ts+=controlSocket->ReceiveDataOnly(&(myMod->reg),sizeof(myMod->reg));
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(myMod->ndac));
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(myMod->nadc));
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(myMod->nchip));
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(myMod->nchan));
|
||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(myMod->nadc));
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(myMod->nchip));
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(myMod->nchan));
|
||||
}
|
||||
ts+=controlSocket->ReceiveDataOnly(&(myMod->gain), sizeof(myMod->gain));
|
||||
ts+=controlSocket->ReceiveDataOnly(&(myMod->offset), sizeof(myMod->offset));
|
||||
|
||||
|
||||
myMod->dacs=dacptr;
|
||||
myMod->adcs=adcptr;
|
||||
myMod->chipregs=chipptr;
|
||||
myMod->chanregs=chanptr;
|
||||
myMod->dacs=dacptr;
|
||||
myMod->adcs=adcptr;
|
||||
myMod->chipregs=chipptr;
|
||||
myMod->chanregs=chanptr;
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "received module " << myMod->module << " of size "<< ts << " register " << myMod->reg << std::endl;
|
||||
@ -1166,21 +1172,24 @@ int slsDetector::receiveModule(sls_detector_module* myMod) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "received dacs " << myMod->module << " of size "<< ts << std::endl;
|
||||
#endif
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc));
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "received adcs " << myMod->module << " of size "<< ts << std::endl;
|
||||
#endif
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip));
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "received chips " << myMod->module << " of size "<< ts << std::endl;
|
||||
#endif
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan));
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "nchans= " << thisDetector->nChans << " nchips= " << thisDetector->nChips;
|
||||
std::cout<< "mod - nchans= " << myMod->nchan << " nchips= " <<myMod->nchip;
|
||||
|
||||
std::cout<< "received chans " << myMod->module << " of size "<< ts << std::endl;
|
||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc));
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "received adcs " << myMod->module << " of size "<< ts << std::endl;
|
||||
#endif
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip));
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "received chips " << myMod->module << " of size "<< ts << std::endl;
|
||||
#endif
|
||||
ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan));
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "nchans= " << thisDetector->nChans << " nchips= " << thisDetector->nChips;
|
||||
std::cout<< "mod - nchans= " << myMod->nchan << " nchips= " <<myMod->nchip;
|
||||
std::cout<< "received chans " << myMod->module << " of size "<< ts << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "received module " << myMod->module << " of size "<< ts << " register " << myMod->reg << std::endl;
|
||||
#endif
|
||||
@ -2774,24 +2783,27 @@ int slsDetector::setModule(sls_detector_module module, int* gainval, int* offset
|
||||
thisDetector->nDacs=module.ndac;
|
||||
thisDetector->nAdcs=module.nadc;
|
||||
|
||||
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
|
||||
if (chipregs)
|
||||
chipregs[ichip+thisDetector->nChips*imod]=module.chipregs[ichip];
|
||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
||||
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
|
||||
if (chipregs)
|
||||
chipregs[ichip+thisDetector->nChips*imod]=module.chipregs[ichip];
|
||||
|
||||
if (chanregs) {
|
||||
for (int i=0; i<thisDetector->nChans; i++) {
|
||||
chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=module.chanregs[ichip*thisDetector->nChans+i];
|
||||
}
|
||||
}
|
||||
if (chanregs) {
|
||||
for (int i=0; i<thisDetector->nChans; i++) {
|
||||
chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=module.chanregs[ichip*thisDetector->nChans+i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adcs) {
|
||||
for (int i=0; i<thisDetector->nAdcs; i++)
|
||||
adcs[i+imod*thisDetector->nAdcs]=module.adcs[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (dacs) {
|
||||
for (int i=0; i<thisDetector->nDacs; i++)
|
||||
dacs[i+imod*thisDetector->nDacs]=module.dacs[i];
|
||||
}
|
||||
if (adcs) {
|
||||
for (int i=0; i<thisDetector->nAdcs; i++)
|
||||
adcs[i+imod*thisDetector->nAdcs]=module.adcs[i];
|
||||
}
|
||||
|
||||
(detectorModules+imod)->gain=module.gain;
|
||||
(detectorModules+imod)->offset=module.offset;
|
||||
@ -2899,25 +2911,28 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod){
|
||||
thisDetector->nDacs=myMod->ndac;
|
||||
thisDetector->nAdcs=myMod->nadc;
|
||||
|
||||
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
|
||||
if (chipregs)
|
||||
chipregs[ichip+thisDetector->nChips*imod]=myMod->chipregs[ichip];
|
||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
||||
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
|
||||
if (chipregs)
|
||||
chipregs[ichip+thisDetector->nChips*imod]=myMod->chipregs[ichip];
|
||||
|
||||
if (chanregs) {
|
||||
for (int i=0; i<thisDetector->nChans; i++) {
|
||||
chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=myMod->chanregs[ichip*thisDetector->nChans+i];
|
||||
if (chanregs) {
|
||||
for (int i=0; i<thisDetector->nChans; i++) {
|
||||
chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=myMod->chanregs[ichip*thisDetector->nChans+i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (adcs) {
|
||||
for (int i=0; i<thisDetector->nAdcs; i++)
|
||||
adcs[i+imod*thisDetector->nAdcs]=myMod->adcs[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (dacs) {
|
||||
for (int i=0; i<thisDetector->nDacs; i++)
|
||||
dacs[i+imod*thisDetector->nDacs]=myMod->dacs[i];
|
||||
}
|
||||
if (adcs) {
|
||||
for (int i=0; i<thisDetector->nAdcs; i++)
|
||||
adcs[i+imod*thisDetector->nAdcs]=myMod->adcs[i];
|
||||
}
|
||||
|
||||
(detectorModules+imod)->gain=myMod->gain;
|
||||
(detectorModules+imod)->offset=myMod->offset;
|
||||
(detectorModules+imod)->serialnumber=myMod->serialnumber;
|
||||
|
@ -15,10 +15,17 @@
|
||||
|
||||
|
||||
/* examples*/
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
#define NCHAN (256*256)
|
||||
#define NCHIP 8
|
||||
#define NADC 0
|
||||
#else
|
||||
#define NCHAN 1
|
||||
#define NCHIP 1
|
||||
#define NDAC 1
|
||||
#define NADC 1
|
||||
#endif
|
||||
|
||||
#define NMAXMODX 1
|
||||
#define NMAXMODY 1
|
||||
#define NMAXMOD NMAXMODX*NMAXMODY
|
||||
@ -27,5 +34,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* SLSDETECTORSERVER_DEFS_H_ */
|
||||
|
Reference in New Issue
Block a user