@•t˜^A: @‚`‚c‚b“Ç‚Ýž‚Ý‚É—p‚¢‚½ƒvƒƒOƒ‰ƒ€ @ @‚b‚`‚m‚l‚`‚bƒf[ƒ^ŽûWƒvƒƒOƒ‰ƒ€qdaq0t.crŽžŠÔ‘ª’è‚àŠÜ‚ÞB @ /***** daq0‚”.c ***** created 2002/Dec./25th Kenkichi Miya. ***** * Original version was written by S.Ono 2002/Jan./27th * This is simplified version having only CAMAC control/IO part. * LAM clear was moved to outside of "if(q!=0)". 2003/Jul./9th ***************************************************************/ /**** original title comment ***** Data taking test program 2000/ 1/27 S.Ono & A.Tango *********************************/ #include #include #include #include #include #include #include #include #include #include "camlib.h" #include #include FILE *fp; /* The file to save the taken data.*/ FILE *fp1; int main(){ int i_ev, n_ev, m, y; int naf,n,a,f,q,x,lam,data,adc,ia,ans; char fname[36]; char fname1[36]; time_t nowtime,tt; struct timeval tv; struct timezone tz; /*====== * Ask the user to answer the slot number and channel number * of the ADC/TDC module to set those integer numbers. *======*/ printf("Slot number of ADC/TDC?\n"); scanf("%d",&adc); printf("Channel number?\n"); scanf("%d",&ia); /*===== * Ask the file name to save the taken data. * Also open the data file. *=====*/ /* printf("File name to save data?\n"); scanf("%s",&fname); */ fp=fopen("test.dat", "w"); printf("TIMEFILE?\n"); scanf("%s",&fname1); fp1=fopen(fname1,"w"); /*===== * How many events do you take? *====*/ printf("Number of events?\n"); scanf("%d",&n_ev); fprintf(fp,"%d\n",n_ev); /*===== * Open CCP interface device file. * If it fails, exit. *=====*/ if(COPEN()){ printf("ccp open error\n"); exit(-1); } /*===== * Initialize CAMAC. *=====*/ CSETCR(0); CGENZ(); CGENC(); CREMI(); /*===== * Enable LAM and Clear it. *=====*/ CAMAC(NAF(adc,ia,26),&data,&q,&x); /* F=26 is enable. */ CAMAC(NAF(adc,ia, 9),&data,&q,&x); /* F=9 is clear. */ /*===== * Again send enable command to prepare the first event. *=====*/ CAMAC(NAF(adc,ia,26),&data,&q,&x); /*===== * send message to the user. *=====*/ printf("CAMAC initilize done.\n"); printf("Number of event = %d\n",n_ev); /*==== * Event loop. *====*/ nowtime=time(&tt); fprintf(fp1,"%s\n",asctime(localtime(&nowtime))); gettimeofday(&tv,&tz); fprintf(fp1,"%d %d\n", tv.tv_sec,tv.tv_usec); i_ev = 0; while( i_ev < n_ev ) { /*--------- * Test LAM. *---------*/ CAMAC(NAF(adc,ia,8),&data,&q,&x); /* F=8 is test LAM.*/ /*------ * If no event comes yet, q is set to be 0, * otherwise, the digitized event is there! *-----*/ if( q!=0 ) { /*----- * Read the digitized data from the register. *----*/ CAMAC(NAF(adc,ia,0),&data,&q,&x); printf("i_ev, data, q, x = %d %d %d %d\n", i_ev, data, q, x ); /*----- * The read data is written into the file. *-----*/ fprintf(fp,"%d\n",data); /*----- * Update the event counter(i_ev), and send mesage for * every 100 events. *-----*/ i_ev++; if( i_ev%100 == 0 ) { printf("Event= %d\t",i_ev); printf("data= %d\n",data); } /*----- * Clear LAM to wait for the next event. *-----*/ CAMAC(NAF(adc,ia,9),&data,&q,&x); } } nowtime=time(&tt); fprintf(fp1,"%s\n",asctime(localtime(&nowtime))); gettimeofday(&tv,&tz); fprintf(fp1,"%d %d\n", tv.tv_sec,tv.tv_usec); /*===== * Instructions for termination. *=====*/ CAMAC(NAF(adc,ia,24),&data,&q,&x); /* F=24 is desable.*/ CCLOSE(); /* CAMAC close. */ fclose(fp); /* Close data file.*/ fclose(fp1); }