mythenDetectorServer compiles in visrtual mode

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@28 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
bergamaschi 2011-02-15 16:20:06 +00:00
parent fbe78acbfe
commit ea62caee31
4 changed files with 41 additions and 24 deletions

View File

@ -1119,15 +1119,19 @@ int getDynamicRange() {
} }
int testBus() { int testBus() {
u_int32_t j, i; u_int32_t j;
u_int64_t i, n, nt;
char cmd[100]; char cmd[100];
u_int32_t val=0x0; u_int32_t val=0x0;
int ifail=OK; int ifail=OK;
// printf("%s\n",cmd); // printf("%s\n",cmd);
// system(cmd); // system(cmd);
i=0; i=0;
printf("testing bus\n");
while (i<10000000) { n=1000000;
nt=n/100;
printf("testing bus %d times\n",n);
while (i<n) {
// val=bus_r(FIX_PATT_REG); // val=bus_r(FIX_PATT_REG);
bus_w(DUMMY_REG,val); bus_w(DUMMY_REG,val);
bus_w(FIX_PATT_REG,0); bus_w(FIX_PATT_REG,0);
@ -1139,7 +1143,8 @@ int testBus() {
//return FAIL; //return FAIL;
}// else }// else
// printf("%d : value OK 0x%08x\n",i,j); // printf("%d : value OK 0x%08x\n",i,j);
if ((i%nt)==0)
printf("%lld cycles OK\n",i);
val+=0xbbbbb; val+=0xbbbbb;
i++; i++;
} }

View File

@ -480,7 +480,7 @@ int program_one_dac(int addr, int value, int imod) {
if (imod==ALLMOD) if (imod==ALLMOD)
sMod=allSelected; sMod=allSelected;
if (imod>=0 && imod<getNModBoard()) { if (imod>=0 && imod<nModX) {
// myMod=detectorModules+imod; // myMod=detectorModules+imod;
//(detectorModules+imod)->dacs[idac]=v; //(detectorModules+imod)->dacs[idac]=v;
detectorDacs[idac+NDAC*imod]=v; detectorDacs[idac+NDAC*imod]=v;
@ -536,7 +536,7 @@ int program_one_dac(int addr, int value, int imod) {
*/ */
//#endif //#endif
} else if (imod==ALLMOD) { } else if (imod==ALLMOD) {
for (im=0; im<getNModBoard(); im++) { for (im=0; im<nModX; im++) {
detectorDacs[idac+NDAC*im]=v; detectorDacs[idac+NDAC*im]=v;
/* /*
@ -771,7 +771,7 @@ int setThresholdEnergy(int ethr) {
myg=g[thisSettings]; myg=g[thisSettings];
myo=o[thisSettings]; myo=o[thisSettings];
} }
for (imod=0; imod<getNModBoard(); imod++) { for (imod=0; imod<nModX; imod++) {
if (detectorModules) { if (detectorModules) {
if ((detectorModules+imod)->gain>0) if ((detectorModules+imod)->gain>0)
myg=(detectorModules+imod)->gain; myg=(detectorModules+imod)->gain;
@ -1012,7 +1012,7 @@ int getChannelbyNumber(sls_detector_channel* myChan) {
ichan=myChan->chan; ichan=myChan->chan;
if (detectorChans) { if (detectorChans) {
if (imod<getNModBoard()) { 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*NCHAN*NCHIP+ichip*NCHAN+ichan];
return OK; return OK;
@ -1024,7 +1024,7 @@ int getChannelbyNumber(sls_detector_channel* myChan) {
int getTrimbit(int imod, int ichip, int ichan) { int getTrimbit(int imod, int ichip, int ichan) {
if (detectorChans) { if (detectorChans) {
if (imod<getNModBoard()) 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*NCHAN*NCHIP+ichip*NCHAN+ichan] & TRIM_DR);
} else } else
@ -1077,8 +1077,8 @@ int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod)
if (sMod==allSelected) { if (sMod==allSelected) {
modmi=0; modmi=0;
modma=getNModBoard(); modma=nModX;//getNModBoard();
} else if (sMod==noneSelected || sMod>getNModBoard() || sMod<0) { } else if (sMod==noneSelected || sMod>nModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
modmi=0; modmi=0;
modma=-1; modma=-1;
return 1; return 1;
@ -1295,7 +1295,7 @@ int getChipbyNumber(sls_detector_chip* myChip){
ichip=myChip->chip; ichip=myChip->chip;
if (detectorChips) { if (detectorChips) {
if (imod<getNModBoard()) if (imod<nModX)
if (ichip<(detectorModules+imod)->nchip) { if (ichip<(detectorModules+imod)->nchip) {
myChip->reg=detectorChips[ichip+imod*NCHIP]; myChip->reg=detectorChips[ichip+imod*NCHIP];
myChip->nchan=NCHAN; myChip->nchan=NCHAN;
@ -1417,8 +1417,8 @@ int initChip(int obe, int ow,int imod){
if (sMod==allSelected) { if (sMod==allSelected) {
modmi=0; modmi=0;
modma=getNModBoard(); modma=nModX;//getNModBoard();
} else if (sMod==noneSelected || sMod>getNModBoard() || sMod<0) { } else if (sMod==noneSelected || sMod>nModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
modmi=0; modmi=0;
modma=-1; modma=-1;
} else { } else {
@ -1517,8 +1517,8 @@ int initChipWithProbes(int obe, int ow,int nprobes, int imod){
if (sMod==allSelected) { if (sMod==allSelected) {
modmi=0; modmi=0;
modma=getNModBoard(); modma=nModX;//getNModBoard();
} else if (sMod==noneSelected || sMod>getNModBoard() || sMod<0) { } else if (sMod==noneSelected || sMod>nModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
modmi=0; modmi=0;
modma=-1; modma=-1;
} else { } else {
@ -1583,8 +1583,8 @@ int initMCBregisters(int cm, int imod){
if (sMod==allSelected) { if (sMod==allSelected) {
modmi=0; modmi=0;
modma=getNModBoard(); modma=nModX;
} else if (sMod==noneSelected || sMod>getNModBoard() || sMod<0) { } else if (sMod==noneSelected || sMod>nModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
modmi=0; modmi=0;
modma=-1; modma=-1;
} else { } else {
@ -1626,8 +1626,8 @@ int initModulebyNumber(sls_detector_module myMod) {
if (sMod==allSelected) { if (sMod==allSelected) {
modmi=0; modmi=0;
modma=getNModBoard(); modma=nModX;//getNModBoard();
} else if (sMod==noneSelected || sMod>getNModBoard() || sMod<0) { } else if (sMod==noneSelected || sMod>nModX || sMod<0) {// (sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
modmi=0; modmi=0;
modma=-1; modma=-1;
} else { } else {

View File

@ -59,8 +59,17 @@ int main(int argc, char *argv[])
printf("Waiting for client call\n"); printf("Waiting for client call\n");
#endif #endif
acceptConnection(); acceptConnection();
#ifdef VERY_VERBOSE
printf("Conenction accepted\n");
#endif
retval=decode_function(); retval=decode_function();
#ifdef VERY_VERBOSE
printf("function executed\n");
#endif
closeConnection(); closeConnection();
#ifdef VERY_VERBOSE
printf("connection closed\n");
#endif
} }
exitServer(); exitServer();

View File

@ -68,13 +68,16 @@ int init_detector( int b) {
int decode_function() { int decode_function() {
int fnum,n; int fnum,n;
int retval; int retval=FAIL;
#ifdef VERBOSE
printf( "receive data\n");
#endif
n = receiveDataOnly(&fnum,sizeof(fnum)); n = receiveDataOnly(&fnum,sizeof(fnum));
if (n < 0) { if (n <= 0) {
printf("ERROR reading from socket %d", n); printf("ERROR reading from socket %d", n);
return GOODBYE; return FAIL;
} }
#ifdef VERY_VERBOSE #ifdef VERBOSE
else else
printf("size of data received %d\n",n); printf("size of data received %d\n",n);
#endif #endif