removed JUNGFRAU_DHANYA completely from Makefile, used N_CHAN instead of NCHAN macro since it isnot constant, and corrected registerdefs

This commit is contained in:
Dhanya Maliakal 2016-02-04 17:26:05 +01:00
parent 1fae912cb2
commit 03fc676b7e
6 changed files with 196 additions and 164 deletions

View File

@ -6,7 +6,7 @@
CROSS = bfin-uclinux- CROSS = bfin-uclinux-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 -DJUNGFRAU_DHANYA #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
PROGS= jungfrauDetectorServerTest PROGS= jungfrauDetectorServerTest

View File

@ -110,22 +110,20 @@ enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_
int withGotthard = 0; int withGotthard = 0;
#ifdef MCB_FUNCS /**is not const because this value will change after initDetector, is removed from mcb_funcs.c cuz its not used anywhere
extern const int nChans; * why is this used anywhere instead of macro*/
extern const int nChips; int nChans=NCHAN;
//extern const int nDacs; int nChips=NCHIP;
//extern const int nAdcs; int nDacs=NDAC;
#endif int nAdcs=NADC;
#ifndef MCB_FUNCS
const int nChans=NCHAN;
const int nChips=NCHIP;
const int nDacs=NDAC;
const int nAdcs=NADC;
#endif
extern enum detectorType myDetectorType; extern enum detectorType myDetectorType;
/** for jungfrau reinitializing macro later in server_funcs.c in initDetector*/
extern int N_CHAN;
extern int N_CHIP;
extern int N_DAC;
extern int N_ADC;
extern int N_CHANS;
int mapCSP0(void) { int mapCSP0(void) {
printf("Mapping memory\n"); printf("Mapping memory\n");
@ -1360,7 +1358,7 @@ ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret) {
for (i=0; i<nroi; i++) { for (i=0; i<nroi; i++) {
printf("iroi: %d - %d %d %d %d\n",i, arg[i].xmin, arg[i].xmax, arg[i].ymin, arg[i].ymax); printf("iroi: %d - %d %d %d %d\n",i, arg[i].xmin, arg[i].xmax, arg[i].ymin, arg[i].ymax);
for (ich=arg[i].xmin; ich<=arg[i].xmax; ich++) { for (ich=arg[i].xmin; ich<=arg[i].xmax; ich++) {
if (ich>=0 && ich<NCHAN) if (ich>=0 && ich<N_CHAN)
adcDisableMask&=~(1<<ich); adcDisableMask&=~(1<<ich);
else else
break; break;
@ -1379,7 +1377,7 @@ ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret) {
*retvalsize=0; *retvalsize=0;
retval[0].xmin=0; retval[0].xmin=0;
retval[0].xmax=0; retval[0].xmax=0;
for (ich=0 ; ich<NCHAN ; ich++) { for (ich=0 ; ich<N_CHAN ; ich++) {
if ((~adcDisableMask)&(1<<ich)) { if ((~adcDisableMask)&(1<<ich)) {
if (ich==0) { if (ich==0) {
*retvalsize+=1; *retvalsize+=1;
@ -1636,8 +1634,8 @@ int setADC(int adc){
ipPacketSize= DEFAULT_IP_PACKETSIZE; ipPacketSize= DEFAULT_IP_PACKETSIZE;
udpPacketSize=DEFAULT_UDP_PACKETSIZE; udpPacketSize=DEFAULT_UDP_PACKETSIZE;
//set channel mask //set channel mask
nchips = NCHIP; nchips = N_CHIP;
nchans = NCHANS; nchans = N_CHANS;
mask = ACTIVE_ADC_MASK; mask = ACTIVE_ADC_MASK;
}/* }/*
//with moench module 1 adc -- NOT IMPLEMENTED //with moench module 1 adc -- NOT IMPLEMENTED
@ -2353,7 +2351,7 @@ int getDynamicRange() {
nSamples=bus_r(NSAMPLES_REG); nSamples=bus_r(NSAMPLES_REG);
getChannels(); getChannels();
dataBytes=nModX*NCHIP*getChannels()*2; dataBytes=nModX*N_CHIP*getChannels()*2;
return dynamicRange*bus_r(NSAMPLES_REG);//nSamples; return dynamicRange*bus_r(NSAMPLES_REG);//nSamples;
} }
@ -2402,7 +2400,7 @@ int setStoreInRAM(int b) {
int getChannels() { int getChannels() {
int nch=32; int nch=32;
int i; int i;
for (i=0; i<NCHAN; i++) { for (i=0; i<N_CHAN; i++) {
if (adcDisableMask & (1<<i)) nch--; if (adcDisableMask & (1<<i)) nch--;
} }
return nch; return nch;

View File

@ -23,10 +23,6 @@
extern int nModX; extern int nModX;
//extern int dataBytes; //extern int dataBytes;
extern int dynamicRange; extern int dynamicRange;
const int nChans=NCHAN;
const int nChips=NCHIP;
const int nDacs=NDAC;
const int nAdcs=NADC;
enum detectorSettings thisSettings; enum detectorSettings thisSettings;
int sChan, sChip, sMod, sDac, sAdc; int sChan, sChip, sMod, sDac, sAdc;
@ -45,6 +41,17 @@ ROI rois[MAX_ROIS];
int nROI=0; int nROI=0;
extern enum detectorType myDetectorType; extern enum detectorType myDetectorType;
/** for jungfrau reinitializing macro later in server_funcs.c in initDetector*/
extern int N_CHAN;
extern int N_CHIP;
extern int N_DAC;
extern int N_ADC;
extern int N_CHANS;
extern int nChans;
extern int nChips;
extern int nDacs;
extern int nAdcs;
int initDetector() { int initDetector() {
@ -57,39 +64,52 @@ int initDetector() {
printf("Board is for %d modules\n",n); printf("Board is for %d modules\n",n);
#endif #endif
if(myDetectorType == JUNGFRAU){
N_CHAN=JUNGFRAU_NCHAN;
N_CHIP=JUNGFRAU_NCHIP;
N_DAC=JUNGFRAU_NDAC;
N_ADC=JUNGFRAU_NADC;
N_CHANS=JUNGFRAU_NCHANS;
nChans=N_CHAN;
nChips=N_CHIP;
nDacs=N_DAC;
nAdcs=N_ADC;
}
detectorModules=malloc(n*sizeof(sls_detector_module)); detectorModules=malloc(n*sizeof(sls_detector_module));
detectorDacs=malloc(n*NDAC*sizeof(int)); detectorDacs=malloc(n*N_DAC*sizeof(int));
detectorAdcs=malloc(n*NADC*sizeof(int)); detectorAdcs=malloc(n*N_ADC*sizeof(int));
detectorChips=NULL; detectorChips=NULL;
detectorChans=NULL; detectorChans=NULL;
detectorAdcs=NULL; detectorAdcs=NULL;
if(myDetectorType != JUNGFRAU){ if(myDetectorType != JUNGFRAU){
detectorChips=malloc(n*NCHIP*sizeof(int)); detectorChips=malloc(n*N_CHIP*sizeof(int));
detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int)); detectorChans=malloc(n*N_CHIP*N_CHAN*sizeof(int));
} }
#ifdef VERBOSE #ifdef VERBOSE
printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n)); 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)); printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*N_DAC));
printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*NADC)); printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*N_ADC));
if(myDetectorType != JUNGFRAU){ if(myDetectorType != JUNGFRAU){
printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*NCHIP)); printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*N_CHIP));
printf("chans from 0x%x to 0x%x\n",(unsigned int)(detectorChans), (unsigned int)(detectorChans+n*NCHIP*NCHAN)); printf("chans from 0x%x to 0x%x\n",(unsigned int)(detectorChans), (unsigned int)(detectorChans+n*N_CHIP*N_CHAN));
} }
#endif #endif
for (imod=0; imod<n; imod++) { for (imod=0; imod<n; imod++) {
(detectorModules+imod)->dacs=detectorDacs+imod*NDAC; (detectorModules+imod)->dacs=detectorDacs+imod*N_DAC;
(detectorModules+imod)->adcs=detectorAdcs+imod*NADC; (detectorModules+imod)->adcs=detectorAdcs+imod*N_ADC;
if(myDetectorType != JUNGFRAU){ if(myDetectorType != JUNGFRAU){
(detectorModules+imod)->chipregs=detectorChips+imod*NCHIP; (detectorModules+imod)->chipregs=detectorChips+imod*N_CHIP;
(detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN; (detectorModules+imod)->chanregs=detectorChans+imod*N_CHIP*N_CHAN;
} }
(detectorModules+imod)->ndac=NDAC; (detectorModules+imod)->ndac=N_DAC;
(detectorModules+imod)->nadc=NADC; (detectorModules+imod)->nadc=N_ADC;
(detectorModules+imod)->nchip=NCHIP; (detectorModules+imod)->nchip=N_CHIP;
(detectorModules+imod)->nchan=NCHIP*NCHAN; (detectorModules+imod)->nchan=N_CHIP*N_CHAN;
(detectorModules+imod)->module=imod; (detectorModules+imod)->module=imod;
(detectorModules+imod)->gain=0; (detectorModules+imod)->gain=0;
(detectorModules+imod)->offset=0; (detectorModules+imod)->offset=0;
@ -495,15 +515,15 @@ int selChip(const int chip,int imod) {
/* sMod=allSelected; */ /* sMod=allSelected; */
/* if (imod>=0 && imod<nModX) { */ /* if (imod>=0 && imod<nModX) { */
/* detectorDacs[idac+NDAC*imod]=v; */ /* detectorDacs[idac+N_DAC*imod]=v; */
/* #ifdef VERBOSE */ /* #ifdef VERBOSE */
/* printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, (unsigned int)(detectorDacs+idac+NDAC*imod)); */ /* printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, (unsigned int)(detectorDacs+idac+N_DAC*imod)); */
/* #endif */ /* #endif */
/* setDACRegister(idac,v,imod); */ /* setDACRegister(idac,v,imod); */
/* } else if (imod==ALLMOD) { */ /* } else if (imod==ALLMOD) { */
/* for (im=0; im<nModX; im++) { */ /* for (im=0; im<nModX; im++) { */
/* detectorDacs[idac+NDAC*im]=v; */ /* detectorDacs[idac+N_DAC*im]=v; */
/* setDACRegister(idac,v,im); */ /* setDACRegister(idac,v,im); */
/* } */ /* } */
/* } */ /* } */
@ -559,9 +579,9 @@ int selChip(const int chip,int imod) {
/* int initDACbyIndex(int ind,int val, int imod) { */ /* int initDACbyIndex(int ind,int val, int imod) { */
/* int v; */ /* int v; */
/* const int partref[NDAC]=PARTREF; */ /* const int partref[N_DAC]=PARTREF; */
/* const int partr1[NDAC]=PARTR1; */ /* const int partr1[N_DAC]=PARTR1; */
/* const int partr2[NDAC]=PARTR2; */ /* const int partr2[N_DAC]=PARTR2; */
/* int ref=partref[ind]; */ /* int ref=partref[ind]; */
/* int r1=partr1[ind]; */ /* int r1=partr1[ind]; */
@ -576,8 +596,8 @@ int selChip(const int chip,int imod) {
/* int initDACbyIndexDACU(int ind, int val, int imod) { */ /* int initDACbyIndexDACU(int ind, int val, int imod) { */
/* // const double daccs[NDAC]=DACCS; */ /* // const double daccs[N_DAC]=DACCS; */
/* // const double dacaddr[NDAC]=DACADDR; */ /* // const double dacaddr[N_DAC]=DACADDR; */
/* // int cs=daccs[ind]; */ /* // int cs=daccs[ind]; */
/* // int addr=dacaddr[ind]; */ /* // int addr=dacaddr[ind]; */
@ -588,7 +608,7 @@ int selChip(const int chip,int imod) {
/* initDAC(ind,val, imod); */ /* initDAC(ind,val, imod); */
/* if (imod>=0 && imod<nModX) { */ /* if (imod>=0 && imod<nModX) { */
/* // return detectorDacs[ind+imod*NDAC]; */ /* // return detectorDacs[ind+imod*N_DAC]; */
/* return setDACRegister(ind, -1, imod); */ /* return setDACRegister(ind, -1, imod); */
/* } */ /* } */
/* else { */ /* else { */
@ -600,7 +620,7 @@ int selChip(const int chip,int imod) {
/* #ifdef VERBOSE */ /* #ifdef VERBOSE */
/* printf("mod %d dac %d val %d\n",im,ind,setDACRegister(ind, -1, im)); */ /* printf("mod %d dac %d val %d\n",im,ind,setDACRegister(ind, -1, im)); */
/* #endif */ /* #endif */
/* //if (detectorDacs[ind+im*NDAC]!=detectorDacs[ind]) { */ /* //if (detectorDacs[ind+im*N_DAC]!=detectorDacs[ind]) { */
/* if (setDACRegister(ind, -1, im)!=setDACRegister(ind, -1, 0)) { */ /* if (setDACRegister(ind, -1, im)!=setDACRegister(ind, -1, 0)) { */
/* #ifdef VERBOSE */ /* #ifdef VERBOSE */
@ -651,7 +671,7 @@ int selChip(const int chip,int imod) {
/* } */ /* } */
/* if (myg>0 && myo>0) { */ /* if (myg>0 && myo>0) { */
/* //ethr=(myo-detectorDacs[VTHRESH+imod*NDAC])*1000/myg; */ /* //ethr=(myo-detectorDacs[VTHRESH+imod*N_DAC])*1000/myg; */
/* ethr=(myo-setDACRegister(VDAC0,-1,imod))*1000/myg;//edited by dhanya */ /* ethr=(myo-setDACRegister(VDAC0,-1,imod))*1000/myg;//edited by dhanya */
/* // else */ /* // else */
@ -659,7 +679,7 @@ int selChip(const int chip,int imod) {
/* } */ /* } */
/* #ifdef VERBOSE */ /* #ifdef VERBOSE */
/* //printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo, detectorDacs[VTHRESH+imod*NDAC]); */ /* //printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo, detectorDacs[VTHRESH+imod*N_DAC]); */
/* printf("module=%d gain=%f, offset=%f, dacu=%d\n",imod, myg, myo,(int)(setDACRegister(VDAC0,-1,imod)));//edited by dhanya */ /* printf("module=%d gain=%f, offset=%f, dacu=%d\n",imod, myg, myo,(int)(setDACRegister(VDAC0,-1,imod)));//edited by dhanya */
/* printf("Threshold energy of module %d is %d eV\n", imod, ethr); */ /* printf("Threshold energy of module %d is %d eV\n", imod, ethr); */
/* #endif */ /* #endif */
@ -737,7 +757,7 @@ int selChip(const int chip,int imod) {
/* if (detectorDacs) { */ /* if (detectorDacs) { */
/* if (imod<getNModBoard()) */ /* if (imod<getNModBoard()) */
/* if (ind<(detectorModules+imod)->ndac) */ /* if (ind<(detectorModules+imod)->ndac) */
/* return (detectorDacs[ind+imod*NDAC]); */ /* return (detectorDacs[ind+imod*N_DAC]); */
/* } */ /* } */
/* return FAIL; */ /* return FAIL; */
/* *\/ */ /* *\/ */
@ -958,7 +978,7 @@ int getChannelbyNumber(sls_detector_channel* myChan) {
if (detectorChans) { if (detectorChans) {
if (imod<nModX && imod>=0) { if (imod<nModX && imod>=0) {
if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip) if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip)
myChan->reg=detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan]; myChan->reg=detectorChans[imod*N_CHAN*N_CHIP+ichip*N_CHAN+ichan];
return OK; return OK;
} }
} }
@ -970,7 +990,7 @@ int getTrimbit(int imod, int ichip, int ichan) {
if (detectorChans) { if (detectorChans) {
if (imod<getNModBoard() && imod>=0) if (imod<getNModBoard() && imod>=0)
if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip) if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip)
return (detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan] & TRIM_DR); return (detectorChans[imod*N_CHAN*N_CHIP+ichip*N_CHAN+ichan] & TRIM_DR);
} }
return -1; return -1;
@ -994,8 +1014,8 @@ int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod)
if (sChan==allSelected) { if (sChan==allSelected) {
// printf("initializing all channels ft=%d coe=%d\n",ft,coe); // printf("initializing all channels ft=%d coe=%d\n",ft,coe);
chanmi=0; chanmi=0;
chanma=NCHAN; chanma=N_CHAN;
} else if (sChan==noneSelected || sChan>NCHAN || sChan<0) { } else if (sChan==noneSelected || sChan>N_CHAN || sChan<0) {
// printf("initializing no channels ft=%d coe=%d\n",ft,coe); // printf("initializing no channels ft=%d coe=%d\n",ft,coe);
chanmi=0; chanmi=0;
chanma=-1; chanma=-1;
@ -1008,8 +1028,8 @@ int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod)
if (sChip==allSelected) { if (sChip==allSelected) {
// printf("initializing all chips\n"); // printf("initializing all chips\n");
chipmi=0; chipmi=0;
chipma=NCHIP; chipma=N_CHIP;
} else if (sChip==noneSelected || sChip>NCHIP || sChip<0) { } else if (sChip==noneSelected || sChip>N_CHIP || sChip<0) {
// printf("initializing no chips\n"); // printf("initializing no chips\n");
chipmi=0; chipmi=0;
chipma=-1; chipma=-1;
@ -1037,12 +1057,12 @@ int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod)
for (ichip=chipmi; ichip<chipma; ichip++) { for (ichip=chipmi; ichip<chipma; ichip++) {
for (ichan=chanmi; ichan<chanma; ichan++) { for (ichan=chanmi; ichan<chanma; ichan++) {
#ifdef VERBOSE #ifdef VERBOSE
// printf("im=%d ichi=%d icha=%d tot=%d reg=%x\n",im,ichip, ichan, im*NCHAN*NCHIP+ichip*NCHAN+ichan,detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]); // printf("im=%d ichi=%d icha=%d tot=%d reg=%x\n",im,ichip, ichan, im*N_CHAN*N_CHIP+ichip*N_CHAN+ichan,detectorChans[im*N_CHAN*N_CHIP+ichip*N_CHAN+ichan]);
#endif #endif
detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]= ft | (cae<<(NTRIMBITS+1)) | (ae<<(NTRIMBITS+2)) | (coe<<(NTRIMBITS+3)) | (ocoe<<(NTRIMBITS+4)) | (counts<<(NTRIMBITS+5)); detectorChans[im*N_CHAN*N_CHIP+ichip*N_CHAN+ichan]= ft | (cae<<(NTRIMBITS+1)) | (ae<<(NTRIMBITS+2)) | (coe<<(NTRIMBITS+3)) | (ocoe<<(NTRIMBITS+4)) | (counts<<(NTRIMBITS+5));
#ifdef VERBOSE #ifdef VERBOSE
//printf("imod=%d ichip=%d ichan=%d addr=%x reg=%x\n",im,ichip,ichan,detectorChans+im*NCHAN*NCHIP+ichip*NCHAN+ichan, detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]); //printf("imod=%d ichip=%d ichan=%d addr=%x reg=%x\n",im,ichip,ichan,detectorChans+im*N_CHAN*N_CHIP+ichip*N_CHAN+ichan, detectorChans[im*N_CHAN*N_CHIP+ichip*N_CHAN+ichan]);
// printf("imod=%d ichip=%d ichan=%d addr=%x reg=%x\n",im,ichip,ichan,detectorChans+im*NCHAN*NCHIP+ichip*NCHAN+ichan, detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]); // printf("imod=%d ichip=%d ichan=%d addr=%x reg=%x\n",im,ichip,ichan,detectorChans+im*N_CHAN*N_CHIP+ichip*N_CHAN+ichan, detectorChans[im*N_CHAN*N_CHIP+ichip*N_CHAN+ichan]);
#endif #endif
} }
} }
@ -1242,9 +1262,9 @@ int getChipbyNumber(sls_detector_chip* myChip){
if (detectorChips) { if (detectorChips) {
if (imod<nModX) if (imod<nModX)
if (ichip<(detectorModules+imod)->nchip) { if (ichip<(detectorModules+imod)->nchip) {
myChip->reg=detectorChips[ichip+imod*NCHIP]; myChip->reg=detectorChips[ichip+imod*N_CHIP];
myChip->nchan=NCHAN; myChip->nchan=N_CHAN;
myChip->chanregs=detectorChans+imod*NCHAN*NCHIP+ichip*NCHIP; myChip->chanregs=detectorChans+imod*N_CHAN*N_CHIP+ichip*N_CHIP;
return OK; return OK;
} }
} }
@ -1350,8 +1370,8 @@ int initChip(int obe, int ow,int imod){
if (sChip==allSelected) { if (sChip==allSelected) {
chipmi=0; chipmi=0;
chipma=NCHIP; chipma=N_CHIP;
} else if (sChip==noneSelected || sChip>NCHIP || sChip<0) { } else if (sChip==noneSelected || sChip>N_CHIP || sChip<0) {
chipmi=0; chipmi=0;
chipma=-1; chipma=-1;
} else { } else {
@ -1375,9 +1395,9 @@ int initChip(int obe, int ow,int imod){
for (im=modmi; im<modma; im++) { for (im=modmi; im<modma; im++) {
for (ichip=chipmi; ichip<chipma; ichip++) { for (ichip=chipmi; ichip<chipma; ichip++) {
// printf("imod %d ichip %d\n",im,ichip); // printf("imod %d ichip %d\n",im,ichip);
detectorChips[im*NCHIP+ichip]=obe | (ow<<1); detectorChips[im*N_CHIP+ichip]=obe | (ow<<1);
#ifdef VERBOSE #ifdef VERBOSE
//printf("imod=%d ichip=%d reg=%d (%x)\n",im,ichip,detectorChips[im*NCHIP+ichip],detectorChips+im*NCHIP+ichip); //printf("imod=%d ichip=%d reg=%d (%x)\n",im,ichip,detectorChips[im*N_CHIP+ichip],detectorChips+im*N_CHIP+ichip);
#endif #endif
} }
} }
@ -1450,8 +1470,8 @@ int initChipWithProbes(int obe, int ow,int nprobes, int imod){
if (sChip==allSelected) { if (sChip==allSelected) {
chipmi=0; chipmi=0;
chipma=NCHIP; chipma=N_CHIP;
} else if (sChip==noneSelected || sChip>NCHIP || sChip<0) { } else if (sChip==noneSelected || sChip>N_CHIP || sChip<0) {
chipmi=0; chipmi=0;
chipma=-1; chipma=-1;
} else { } else {
@ -1475,9 +1495,9 @@ int initChipWithProbes(int obe, int ow,int nprobes, int imod){
for (im=modmi; im<modma; im++) { for (im=modmi; im<modma; im++) {
for (ichip=chipmi; ichip<chipma; ichip++) { for (ichip=chipmi; ichip<chipma; ichip++) {
// printf("imod %d ichip %d\n",im,ichip); // printf("imod %d ichip %d\n",im,ichip);
detectorChips[im*NCHIP+ichip]=obe | (ow<<1); detectorChips[im*N_CHIP+ichip]=obe | (ow<<1);
#ifdef VERBOSE #ifdef VERBOSE
//printf("imod=%d ichip=%d reg=%d (%x)\n",im,ichip,detectorChips[im*NCHIP+ichip],detectorChips+im*NCHIP+ichip); //printf("imod=%d ichip=%d reg=%d (%x)\n",im,ichip,detectorChips[im*N_CHIP+ichip],detectorChips+im*N_CHIP+ichip);
#endif #endif
} }
} }
@ -1558,7 +1578,7 @@ int initModulebyNumber(sls_detector_module myMod) {
int imod; int imod;
// int obe; // int obe;
// int ow; // int ow;
/* int v[NDAC];*/ /* int v[N_DAC];*/
int retval =-1, idac; int retval =-1, idac;
@ -1584,7 +1604,7 @@ int initModulebyNumber(sls_detector_module myMod) {
printf("222\n"); printf("222\n");
/* /*
for (idac=0; idac<NDAC; idac++) for (idac=0; idac<N_DAC; idac++)
v[idac]=(myMod.dacs)[idac]; v[idac]=(myMod.dacs)[idac];
v[VDAC0]=(myMod.dacs)[0]; v[VDAC0]=(myMod.dacs)[0];
@ -1608,10 +1628,10 @@ int initModulebyNumber(sls_detector_module myMod) {
printf("vdac7=%d\n",v[VDAC7]); printf("vdac7=%d\n",v[VDAC7]);
#endif #endif
*/ */
printf("ndac:%d\n",NDAC); printf("ndac:%d\n",N_DAC);
// initDACs(v,imod); // initDACs(v,imod);
// initMCBregisters(myMod.reg,imod); // initMCBregisters(myMod.reg,imod);
for (idac=0; idac<NDAC; idac++){ for (idac=0; idac<N_DAC; idac++){
retval = setDac(idac,(myMod.dacs)[idac]); retval = setDac(idac,(myMod.dacs)[idac]);
if(retval ==(myMod.dacs)[idac]) if(retval ==(myMod.dacs)[idac])
printf("Setting dac %d to %d\n",idac,retval); printf("Setting dac %d to %d\n",idac,retval);
@ -1771,11 +1791,11 @@ int readOutChan(int *val) {
for (k=0; k<nModX; k++) { for (k=0; k<nModX; k++) {
v=readin(k); v=readin(k);
//v=bus_r(MCB_DOUT_REG_OFF+(k<<SHIFTMOD)) & 0x3ff; //v=bus_r(MCB_DOUT_REG_OFF+(k<<SHIFTMOD)) & 0x3ff;
for (j=0; j<NCHIP; j++) { for (j=0; j<N_CHIP; j++) {
if (i==0) if (i==0)
*(val+j+k*NCHIP)=0; *(val+j+k*N_CHIP)=0;
if (v & (1<<j)) { if (v & (1<<j)) {
*(val+j+k*NCHIP)= *(val+j+k*NCHIP) | (1 << i); *(val+j+k*N_CHIP)= *(val+j+k*N_CHIP) | (1 << i);
} }
} }
} }
@ -1909,7 +1929,7 @@ int testShiftStSel(int imod) {
int val,i,j,k; int val,i,j,k;
printf("testing shift stsel for module %d\n", imod); printf("testing shift stsel for module %d\n", imod);
setCSregister(ALLMOD); setCSregister(ALLMOD);
for (i=0; i<NCHAN; i++) { for (i=0; i<N_CHAN; i++) {
if (i%2) { if (i%2) {
putout("0100011000000000",ALLMOD); putout("0100011000000000",ALLMOD);
putout("0110011000000000",ALLMOD); putout("0110011000000000",ALLMOD);
@ -1921,7 +1941,7 @@ int testShiftStSel(int imod) {
} }
} }
putout("0010011000000000",ALLMOD); putout("0010011000000000",ALLMOD);
for (i=0; i<NCHAN; i++) { for (i=0; i<N_CHAN; i++) {
putout("0000011000000000",ALLMOD); putout("0000011000000000",ALLMOD);
@ -1929,7 +1949,7 @@ int testShiftStSel(int imod) {
//for (k=0; k<nModX; k++) { //for (k=0; k<nModX; k++) {
val=readin(k); val=readin(k);
//val=bus_r(MCB_DOUT_REG_OFF+(k<<SHIFTMOD)) & 0x3ff; //val=bus_r(MCB_DOUT_REG_OFF+(k<<SHIFTMOD)) & 0x3ff;
for (j=0; j<NCHIP; j++) { for (j=0; j<N_CHIP; j++) {
if ( (val & 1<<j)>0 && i%2==0) { if ( (val & 1<<j)>0 && i%2==0) {
printf("Shift stsel: module %d chip %i bit %d read %d instead of %d \n",k,j,i,val & 1<< j, i%2); printf("Shift stsel: module %d chip %i bit %d read %d instead of %d \n",k,j,i,val & 1<< j, i%2);
result++; result++;
@ -1958,7 +1978,7 @@ int testShiftStSel(int imod) {
int testDataInOut(int num, int imod) { int testDataInOut(int num, int imod) {
int val[NCHIP*nModX], result=OK; int val[N_CHIP*nModX], result=OK;
int ich, ichip; int ich, ichip;
setCSregister(ALLMOD); setCSregister(ALLMOD);
printf("Testing data in out for module %d pattern 0x%x\n", imod, num); printf("Testing data in out for module %d pattern 0x%x\n", imod, num);
@ -1968,14 +1988,14 @@ int testDataInOut(int num, int imod) {
setCSregister(ALLMOD); setCSregister(ALLMOD);
initChip(0, 0,ALLMOD); initChip(0, 0,ALLMOD);
clearSSregister(ALLMOD); clearSSregister(ALLMOD);
for (ich=0; ich<NCHAN; ich++) { for (ich=0; ich<N_CHAN; ich++) {
nextStrip(ALLMOD); nextStrip(ALLMOD);
readOutChan(val); readOutChan(val);
//imod=0; //imod=0;
//for (imod=0; imod<nModX; imod++) { //for (imod=0; imod<nModX; imod++) {
for (ichip=0; ichip<NCHIP; ichip++) { for (ichip=0; ichip<N_CHIP; ichip++) {
if (val[ichip+imod*NCHIP]!=num) { if (val[ichip+imod*N_CHIP]!=num) {
printf("Test datain out: Channel %d read %x instead of %x\n", (imod*NCHIP+ichip)*NCHAN+ich, val[ichip+NCHIP*imod], num); printf("Test datain out: Channel %d read %x instead of %x\n", (imod*N_CHIP+ichip)*N_CHAN+ich, val[ichip+N_CHIP*imod], num);
result++; result++;
} }
} }
@ -2002,7 +2022,7 @@ int testExtPulse(int imod) {
putout("0000000000000000",ALLMOD); putout("0000000000000000",ALLMOD);
putout("0000100000000000",ALLMOD); putout("0000100000000000",ALLMOD);
putout("0000000000000000",ALLMOD); putout("0000000000000000",ALLMOD);
for (i=0; i<NCHAN; i++) { for (i=0; i<N_CHAN; i++) {
putout("0000000000000000",ALLMOD); putout("0000000000000000",ALLMOD);
putout("0000000000001000",ALLMOD); putout("0000000000001000",ALLMOD);
putout("0000000000000000",ALLMOD); putout("0000000000000000",ALLMOD);
@ -2021,11 +2041,11 @@ int testExtPulse(int imod) {
// val1=fifo_read_event(); // val1=fifo_read_event();
//imod=0; //imod=0;
//for (imod=0; imod<nModX; imod++) { //for (imod=0; imod<nModX; imod++) {
for (ichip=0; ichip<NCHIP; ichip++) { for (ichip=0; ichip<N_CHIP; ichip++) {
for (ichan=0; ichan<NCHAN; ichan++) {// for (ichan=0; ichan<N_CHAN; ichan++) {//
if ((*(val1+ichan+(ichip+imod*NCHIP)*NCHAN))!=ichan) { if ((*(val1+ichan+(ichip+imod*N_CHIP)*N_CHAN))!=ichan) {
result++; result++;
printf("Counter test: channel %d read %d instead of %d\n",ichan+(ichip+imod*NCHIP)*NCHAN, val1[ichan+(ichip+imod*NCHIP)*NCHAN], ichan); printf("Counter test: channel %d read %d instead of %d\n",ichan+(ichip+imod*N_CHIP)*N_CHAN, val1[ichan+(ichip+imod*N_CHIP)*N_CHAN], ichan);
} }
} }
} }
@ -2067,9 +2087,9 @@ int testExtPulseMux(int imod, int ow) {
counterClear(ALLMOD); counterClear(ALLMOD);
initChipWithProbes(0, ow,0,ALLMOD); initChipWithProbes(0, ow,0,ALLMOD);
// initChip(0, ow,ALLMOD); // initChip(0, ow,ALLMOD);
for (ichip=0; ichip<NCHIP; ichip++) { for (ichip=0; ichip<N_CHIP; ichip++) {
setSSregister(ALLMOD); setSSregister(ALLMOD);
for (i=0; i<NCHAN; i++) { for (i=0; i<N_CHAN; i++) {
putout("0000000000000000",ALLMOD); putout("0000000000000000",ALLMOD);
putout("0000000000001000",ALLMOD); putout("0000000000001000",ALLMOD);
putout("0000000000000000",ALLMOD); putout("0000000000000000",ALLMOD);
@ -2093,16 +2113,16 @@ int testExtPulseMux(int imod, int ow) {
printf("no data found in fifos\n"); printf("no data found in fifos\n");
return 1; return 1;
} }
for (ichip=0; ichip<NCHIP; ichip++) { for (ichip=0; ichip<N_CHIP; ichip++) {
chipr=0; chipr=0;
for (ichan=0; ichan<NCHAN; ichan++) { for (ichan=0; ichan<N_CHAN; ichan++) {
ind=ichan+(ichip+imod*NCHIP)*NCHAN; ind=ichan+(ichip+imod*N_CHIP)*N_CHAN;
v=values[ind]; v=values[ind];
vright=(ichan*(ichip+1))&nbit_mask; vright=(ichan*(ichip+1))&nbit_mask;
if (v!=vright) { if (v!=vright) {
result++; result++;
chipr++; chipr++;
printf("Counter test mux %d mode: channel %d chip %d read %d instead of %d\n",ow, ichan+(ichip+imod*NCHIP)*NCHAN, ichip, v, vright); printf("Counter test mux %d mode: channel %d chip %d read %d instead of %d\n",ow, ichan+(ichip+imod*N_CHIP)*N_CHAN, ichip, v, vright);
//break; //break;
} }
//printf("\n"); //printf("\n");
@ -2168,15 +2188,15 @@ int testDataInOutMux(int imod, int ow, int num) {
printf("no data found in fifos\n"); printf("no data found in fifos\n");
return 1; return 1;
} }
for (ichip=0; ichip<NCHIP; ichip++) { for (ichip=0; ichip<N_CHIP; ichip++) {
chipr=0; chipr=0;
for (ichan=0; ichan<NCHAN; ichan++) { for (ichan=0; ichan<N_CHAN; ichan++) {
ind=ichan+(ichip+imod*NCHIP)*NCHAN; ind=ichan+(ichip+imod*N_CHIP)*N_CHAN;
v=values[ind]; v=values[ind];
if (v!=vright) { if (v!=vright) {
result++; result++;
chipr++; chipr++;
printf("DataInOut test mux %d mode: channel %d chip %d read %d instead of %d\n",ow, ichan+(ichip+imod*NCHIP)*NCHAN, ichip, v, vright); printf("DataInOut test mux %d mode: channel %d chip %d read %d instead of %d\n",ow, ichan+(ichip+imod*N_CHIP)*N_CHAN, ichip, v, vright);
//break; //break;
} }
//printf("\n"); //printf("\n");
@ -2263,7 +2283,7 @@ int testOutMux(int imod) {
#ifdef DEBUGOUT #ifdef DEBUGOUT
printf("%d %x\n",i*dist,val); printf("%d %x\n",i*dist,val);
#endif #endif
for (j=0; j<NCHIP; j++) { for (j=0; j<N_CHIP; j++) {
v=val & 1<< j; v=val & 1<< j;
if (pat & (1<<(i*dist))) { if (pat & (1<<(i*dist))) {
if (v==0) { if (v==0) {
@ -2291,7 +2311,7 @@ int testOutMux(int imod) {
#ifdef DEBUGOUT #ifdef DEBUGOUT
printf("%d %x\n",i*dist, val); printf("%d %x\n",i*dist, val);
#endif #endif
for (j=0; j<NCHIP; j++) { for (j=0; j<N_CHIP; j++) {
v=val & 1<< j; v=val & 1<< j;
if (pat & (1<<(i*dist))) { if (pat & (1<<(i*dist))) {
if (v==0) { if (v==0) {
@ -2324,7 +2344,7 @@ int testOutMux(int imod) {
#ifdef DEBUGOUT #ifdef DEBUGOUT
printf("%d %x\n",i*dist, val); printf("%d %x\n",i*dist, val);
#endif #endif
for (j=0; j<NCHIP; j++) { for (j=0; j<N_CHIP; j++) {
v=val & 1<< j; v=val & 1<< j;
if (pat & (1<<(i*dist))) { if (pat & (1<<(i*dist))) {
if (v==0) { if (v==0) {
@ -2352,7 +2372,7 @@ int testOutMux(int imod) {
#ifdef DEBUGOUT #ifdef DEBUGOUT
printf("%d %x\n",i*dist, val); printf("%d %x\n",i*dist, val);
#endif #endif
for (j=0; j<NCHIP; j++) { for (j=0; j<N_CHIP; j++) {
v=val & 1<< j; v=val & 1<< j;
if (pat & (1<<(i*dist))) { if (pat & (1<<(i*dist))) {
if (v==0) { if (v==0) {
@ -2520,9 +2540,9 @@ int calibration_sensor(int num, int *v, int *dacs) {
selChip(ichip,imod); selChip(ichip,imod);
for (ich=0; ich<128; ich++){ for (ich=0; ich<128; ich++){
selChannel(ich,imod); selChannel(ich,imod);
initChannel(*(dacs+ichip*NCHAN+ich),0,0,0,0,0,imod); //disable channel; initChannel(*(dacs+ichip*N_CHAN+ich),0,0,0,0,0,imod); //disable channel;
clearCounter(imod); clearCounter(imod);
//initChannel(*(dacs+ichip*NCHAN+ich),FALSE,FALSE,TRUE,FALSE,0); //disable channel; //initChannel(*(dacs+ichip*N_CHAN+ich),FALSE,FALSE,TRUE,FALSE,0); //disable channel;
} }
} }
} }
@ -2530,11 +2550,11 @@ int calibration_sensor(int num, int *v, int *dacs) {
for (imod=0; imod<nModX; imod++) { for (imod=0; imod<nModX; imod++) {
//selMod(imod); //selMod(imod);
initMCBregisters(1,imod); initMCBregisters(1,imod);
for (ich=0; ich<NCHAN; ich++){ for (ich=0; ich<N_CHAN; ich++){
for (ichip=0; ichip<NCHIP; ichip++) { for (ichip=0; ichip<N_CHIP; ichip++) {
selChip(ichip,imod); // select channel selChip(ichip,imod); // select channel
selChannel(ich,imod); // select channel selChannel(ich,imod); // select channel
initChannel(*(dacs+imod*NCHAN*NCHIP+ichip*NCHAN+ich),0,0,1,0,0,imod); // enable channel initChannel(*(dacs+imod*N_CHAN*N_CHIP+ichip*N_CHAN+ich),0,0,1,0,0,imod); // enable channel
clearCounter(imod); clearCounter(imod);
} }
setCSregister(imod); setCSregister(imod);
@ -2548,11 +2568,11 @@ int calibration_sensor(int num, int *v, int *dacs) {
} }
readOutChan(val); // readout channel readOutChan(val); // readout channel
for (imod=0; imod<nModX; imod++) { for (imod=0; imod<nModX; imod++) {
for (ichip=0; ichip<NCHIP; ichip++) { for (ichip=0; ichip<N_CHIP; ichip++) {
*(v+(ichip+imod*NCHIP)*NCHAN+ich)=val[ichip+imod*NCHIP]; *(v+(ichip+imod*N_CHIP)*N_CHAN+ich)=val[ichip+imod*N_CHIP];
selChip(ichip,imod); // select channel selChip(ichip,imod); // select channel
selChannel(ich,imod); // select channel selChannel(ich,imod); // select channel
initChannel(*(dacs+ichip*NCHAN+ich),0,0,0,0,0,imod); //disable channel; initChannel(*(dacs+ichip*N_CHAN+ich),0,0,0,0,0,imod); //disable channel;
} }
} }
} }
@ -2574,17 +2594,17 @@ int calibration_chip(int num, int *v, int *dacs) {
for (ich=0; ich<128; ich++){ for (ich=0; ich<128; ich++){
selChannel(ich,imod); selChannel(ich,imod);
clearCounter(imod); clearCounter(imod);
initChannel(*(dacs+ichip*NCHAN+ich),0,0,0,0,0,imod); //disable channel; initChannel(*(dacs+ichip*N_CHAN+ich),0,0,0,0,0,imod); //disable channel;
} }
} }
} }
for (ich=0; ich<NCHAN; ich++){ for (ich=0; ich<N_CHAN; ich++){
for (imod=0; imod<nModX; imod++) { for (imod=0; imod<nModX; imod++) {
//selMod(imod); //selMod(imod);
for (ichip=0; ichip<NCHIP; ichip++) { for (ichip=0; ichip<N_CHIP; ichip++) {
selChip(ichip,imod); // select channel selChip(ichip,imod); // select channel
selChannel(ich,imod); // select channel selChannel(ich,imod); // select channel
initChannel(*(dacs+imod*NCHAN*NCHIP+ichip*NCHAN+ich),1,0,1,0,0,imod); // enable channel initChannel(*(dacs+imod*N_CHAN*N_CHIP+ichip*N_CHAN+ich),1,0,1,0,0,imod); // enable channel
clearCounter(imod); clearCounter(imod);
} }
} }
@ -2600,10 +2620,10 @@ int calibration_chip(int num, int *v, int *dacs) {
for (imod=0; imod<nModX; imod++) { for (imod=0; imod<nModX; imod++) {
//selMod(imod); //selMod(imod);
for (ichip=0; ichip<10; ichip++) { for (ichip=0; ichip<10; ichip++) {
*(v+(ichip+imod*NCHIP)*NCHAN+ich)=val[ichip+imod*NCHIP]; *(v+(ichip+imod*N_CHIP)*N_CHAN+ich)=val[ichip+imod*N_CHIP];
selChip(ichip,imod); // select chip selChip(ichip,imod); // select chip
selChannel(ich,imod); // select channel selChannel(ich,imod); // select channel
initChannel(*(dacs+imod*NCHAN*NCHIP+ichip*NCHAN+ich),0,0,0,0,0,imod); //disable channel; initChannel(*(dacs+imod*N_CHAN*N_CHIP+ichip*N_CHAN+ich),0,0,0,0,0,imod); //disable channel;
} }
} }
} }

View File

@ -7,20 +7,22 @@
// Hardware definitions // Hardware definitions
#ifdef JUNGFRAU_DHANYA #define NMAXMODY 1
#define NCHAN (256*256) #define NMAXMOD (NMAXMODX*NMAXMODY)
#define NCHIP 8
#define NADC 0
#else
#define NCHAN 32 #define NCHAN 32
#define NCHIP 1 #define NCHIP 1
#define NADC 1 #define NADC 1
#endif
#define NDAC 16 #define NDAC 16
#define NMAXMODX 1 #define NMAXMODX 1
#define NMAXMODY 1 #define NCHANS (NCHAN*NCHIP*NMAXMOD)
#define NMAXMOD (NMAXMODX*NMAXMODY) #define NDACS (NDAC*NMAXMOD)
#define JUNGFRAU_NCHAN (256*256)
#define JUNGFRAU_NCHIP 8
#define JUNGFRAU_NADC 0
#define JUNGFRAU_NDAC 16
#define JUNGFRAU_NCHANS (JUNGFRAU_NCHAN*JUNGFRAU_NCHIP*NMAXMOD)
@ -29,11 +31,6 @@
#define GOTTHARDNCHIP 10 #define GOTTHARDNCHIP 10
#define NCHANS (NCHAN*NCHIP*NMAXMOD)
#define NDACS (NDAC*NMAXMOD)
#define NTRIMBITS 6 #define NTRIMBITS 6
#define NCOUNTBITS 24 #define NCOUNTBITS 24

View File

@ -55,6 +55,14 @@ extern int withGotthard;
int adcvpp=0x4; int adcvpp=0x4;
/** for jungfrau reinitializing macro later */
int N_CHAN=NCHAN;
int N_CHIP=NCHIP;
int N_DAC=NDAC;
int N_ADC=NADC;
int N_CHANS=NCHANS;
int init_detector(int b, int checkType) { int init_detector(int b, int checkType) {
int i; int i;
@ -118,6 +126,7 @@ int init_detector(int b, int checkType) {
printf("\nBoard Revision:0x%x\n",(bus_r(PCB_REV_REG)&BOARD_REVISION_MASK)); printf("\nBoard Revision:0x%x\n",(bus_r(PCB_REV_REG)&BOARD_REVISION_MASK));
if(myDetectorType == JUNGFRAU) if(myDetectorType == JUNGFRAU)
initDetector(); /*allocating detectorModules, detectorsDacs etc for "settings", also does allocate RAM*/ initDetector(); /*allocating detectorModules, detectorsDacs etc for "settings", also does allocate RAM*/
dataBytes=NMAXMOD*N_CHIP*N_CHAN*2; /**Nchip and Nchan real values get assigned in initDetector()*/
printf("Initializing Detector\n"); printf("Initializing Detector\n");
//bus_w16(CONTROL_REG, SYNC_RESET); // reset registers //bus_w16(CONTROL_REG, SYNC_RESET); // reset registers
#endif #endif
@ -135,6 +144,14 @@ int init_detector(int b, int checkType) {
initDac(0); initDac(8); //initializes the two dacs initDac(0); initDac(8); //initializes the two dacs
if(myDetectorType==JUNGFRAU){ if(myDetectorType==JUNGFRAU){
/** for jungfrau reinitializing macro */
N_CHAN=JUNGFRAU_NCHAN;
N_CHIP=JUNGFRAU_NCHIP;
N_DAC=JUNGFRAU_NDAC;
N_ADC=JUNGFRAU_NADC;
N_CHANS=JUNGFRAU_NCHANS;
//set dacs //set dacs
int retval = -1; int retval = -1;
int dacvalues[14][2]={ int dacvalues[14][2]={
@ -1242,13 +1259,13 @@ int set_channel(int file_des) {
#ifdef VERBOSE #ifdef VERBOSE
printf("channel number is %d, chip number is %d, module number is %d, register is %lld\n", myChan.chan,myChan.chip, myChan.module, myChan.reg); printf("channel number is %d, chip number is %d, module number is %d, register is %lld\n", myChan.chan,myChan.chip, myChan.module, myChan.reg);
#endif #endif
if (ret==OK) { if (ret==OK) {
if (myChan.module>=getNModBoard()) if (myChan.module>=getNModBoard())
ret=FAIL; ret=FAIL;
if (myChan.chip>=NCHIP) if (myChan.chip>=N_CHIP)
ret=FAIL; ret=FAIL;
if (myChan.chan>=NCHAN) if (myChan.chan>=N_CHAN)
ret=FAIL; ret=FAIL;
if (myChan.module<0) if (myChan.module<0)
myChan.module=ALLMOD; myChan.module=ALLMOD;
@ -1322,13 +1339,13 @@ int get_channel(int file_des) {
} }
if (ret==OK) { if (ret==OK) {
ret=FAIL; ret=FAIL;
if (ichip>=0 && ichip<NCHIP) { if (ichip>=0 && ichip<N_CHIP) {
ret=OK; ret=OK;
} }
} }
if (ret==OK) { if (ret==OK) {
ret=FAIL; ret=FAIL;
if (ichan>=0 && ichan<NCHAN) { if (ichan>=0 && ichan<N_CHAN) {
ret=OK; ret=OK;
} }
} }
@ -1368,12 +1385,12 @@ int get_channel(int file_des) {
int set_chip(int file_des) { int set_chip(int file_des) {
sls_detector_chip myChip; sls_detector_chip myChip;
int ch[NCHAN]; int ch[N_CHAN];
int n, retval; int n, retval;
int ret=OK; int ret=OK;
myChip.nchan=NCHAN; myChip.nchan=N_CHAN;
myChip.chanregs=ch; myChip.chanregs=ch;
@ -1400,7 +1417,7 @@ int set_chip(int file_des) {
ret=FAIL; ret=FAIL;
if (myChip.module<0) if (myChip.module<0)
myChip.module=ALLMOD; myChip.module=ALLMOD;
if (myChip.chip>=NCHIP) if (myChip.chip>=N_CHIP)
ret=FAIL; ret=FAIL;
} }
if (differentClients==1 && lockStatus==1) { if (differentClients==1 && lockStatus==1) {
@ -1456,7 +1473,7 @@ int get_chip(int file_des) {
} }
if (ret==OK) { if (ret==OK) {
ret=FAIL; ret=FAIL;
if (ichip>=0 && ichip<NCHIP) { if (ichip>=0 && ichip<N_CHIP) {
ret=OK; ret=OK;
} }
} }
@ -1499,14 +1516,14 @@ int set_module(int file_des) {
int ret=OK; int ret=OK;
int dr; int dr;
sls_detector_module myModule; sls_detector_module myModule;
int *myDac=malloc(NDAC*sizeof(int)); int *myDac=malloc(N_DAC*sizeof(int));
int *myAdc=malloc(NADC*sizeof(int)); int *myAdc=malloc(N_ADC*sizeof(int));
int *myChip=NULL; int *myChip=NULL;
int *myChan=NULL; int *myChan=NULL;
/*not required for jungfrau. so save memory*/ /*not required for jungfrau. so save memory*/
if(myDetectorType != JUNGFRAU){ if(myDetectorType != JUNGFRAU){
myChip=malloc(NCHIP*sizeof(int)); myChip=malloc(N_CHIP*sizeof(int));
myChan=malloc(NCHIP*NCHAN*sizeof(int)); myChan=malloc(N_CHIP*N_CHAN*sizeof(int));
} }
dr=setDynamicRange(-1); /* move this down to after initialization?*/ dr=setDynamicRange(-1); /* move this down to after initialization?*/
@ -1543,10 +1560,10 @@ int set_module(int file_des) {
} }
} }
myModule.ndac=NDAC; myModule.ndac=N_DAC;
myModule.nchip=NCHIP; myModule.nchip=N_CHIP;
myModule.nchan=NCHAN*NCHIP; myModule.nchan=N_CHAN*N_CHIP;
myModule.nadc=NADC; myModule.nadc=N_ADC;
#ifdef VERBOSE #ifdef VERBOSE
printf("Setting module\n"); printf("Setting module\n");
@ -1626,16 +1643,16 @@ int get_module(int file_des) {
int imod; int imod;
int n; int n;
sls_detector_module myModule; sls_detector_module myModule;
int *myDac=malloc(NDAC*sizeof(int)); int *myDac=malloc(N_DAC*sizeof(int));
int *myChip=NULL; int *myChip=NULL;
int *myChan=NULL; int *myChan=NULL;
int *myAdc=NULL; int *myAdc=NULL;
/*not required for jungfrau. so save memory*/ /*not required for jungfrau. so save memory*/
if(myDetectorType != JUNGFRAU){ if(myDetectorType != JUNGFRAU){
myChip=malloc(NCHIP*sizeof(int)); myChip=malloc(N_CHIP*sizeof(int));
myChan=malloc(NCHIP*NCHAN*sizeof(int)); myChan=malloc(N_CHIP*N_CHAN*sizeof(int));
myAdc=malloc(NADC*sizeof(int)); myAdc=malloc(N_ADC*sizeof(int));
} }
@ -1672,10 +1689,10 @@ int get_module(int file_des) {
} }
} }
myModule.ndac=NDAC; myModule.ndac=N_DAC;
myModule.nchip=NCHIP; myModule.nchip=N_CHIP;
myModule.nchan=NCHAN*NCHIP; myModule.nchan=N_CHAN*N_CHIP;
myModule.nadc=NADC; myModule.nadc=N_ADC;
@ -2901,7 +2918,7 @@ int load_image(int file_des) {
int ret=OK; int ret=OK;
int n; int n;
enum imageType index; enum imageType index;
short int ImageVals[NCHAN*NCHIP]; short int ImageVals[N_CHAN*N_CHIP];
sprintf(mess,"Loading image failed\n"); sprintf(mess,"Loading image failed\n");
@ -3066,7 +3083,7 @@ int read_counter_block(int file_des) {
int n; int n;
int startACQ; int startACQ;
//char *retval=NULL; //char *retval=NULL;
short int CounterVals[NCHAN*NCHIP]; short int CounterVals[N_CHAN*N_CHIP];
sprintf(mess,"Read counter block failed\n"); sprintf(mess,"Read counter block failed\n");