Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
59 | f9daq | 1 | #define USE_DAQ |
2 | |||
3 | // Izberi ustrezni interface v meniju projektnega okna |
||
4 | // Options->CompilerDefines (dodaj /DSISVME ali /DWIENVME) |
||
5 | #ifdef USE_DAQ |
||
6 | # ifdef SISVME |
||
7 | # include "sisvme_dll.h" |
||
8 | # endif |
||
9 | # ifdef WIENVME |
||
10 | # include "wienvme_dll.h" |
||
11 | # endif |
||
12 | # ifdef WUSBVME |
||
13 | # include "wusbvme_dll.h" |
||
14 | # endif |
||
15 | # include "CAENV673A.h" |
||
16 | #endif |
||
17 | |||
18 | #include <utility.h> |
||
19 | #include <userint.h> |
||
20 | #include <cvirte.h> /* Needed if linking in external compiler; harmless otherwise */ |
||
21 | #include "rich_ui.h" |
||
22 | |||
23 | #define V673A_BASE_A24 0x130000 |
||
24 | #define USBVME_NAME "VM0120" |
||
25 | |||
26 | #define MAPFILE "icfa2013.txt" |
||
27 | |||
28 | #define MAXDATA 2000 |
||
29 | unsigned long dataa[3078]; |
||
30 | unsigned long data0[MAXDATA]; |
||
31 | unsigned long datac[1000]; |
||
32 | |||
33 | |||
34 | int p1h, p2h, p3h ; |
||
35 | int p1h,rph,rID; |
||
36 | |||
37 | |||
38 | int pmtmaparr[8][8] ; |
||
39 | int pmtmap_i[64] ; |
||
40 | int pmtmap_j[64] ; |
||
41 | int data[64][64] ; |
||
42 | int nndata[64] ; |
||
43 | unsigned short acum_allch[65536] ; |
||
44 | unsigned short acum_snglch[64][512] ; |
||
45 | //int offset=512 ; |
||
46 | int offset=0 ; |
||
47 | int min_tdc, max_tdc ; |
||
48 | int min_tdcR, max_tdcR ; |
||
49 | |||
50 | int single_event ; |
||
51 | |||
52 | unsigned long pmtbitmap[2] ; |
||
53 | unsigned long pmtbitmap_win[2] ; |
||
54 | |||
55 | int minhit ; |
||
56 | |||
57 | //***************************************************************************** |
||
58 | |||
59 | int read_pmtmap ( ) { |
||
60 | FILE *fp=fopen(MAPFILE,"r"); |
||
61 | int ch, i, j ; |
||
62 | |||
63 | while ( EOF != fscanf(fp,"%d %d %d\n",&ch,&i,&j) ) { |
||
64 | if ( i>7 || j>7 ) { |
||
65 | printf ( "Index out of range!!!! (%d,%d,%d)\n",ch,i,j ) ; |
||
66 | continue ; |
||
67 | } |
||
68 | pmtmaparr[i][j]=ch ; |
||
69 | pmtmap_i[ch] = i ; |
||
70 | pmtmap_j[ch] = j ; |
||
71 | } |
||
72 | |||
73 | return 0 ; |
||
74 | } |
||
75 | |||
76 | //***************************************************************************** |
||
77 | |||
78 | int draw_histos ( ) { |
||
79 | int i, ch ; |
||
80 | int harr[4]={HISTOS_H_1,HISTOS_H_2,HISTOS_H_3,HISTOS_H_4} ; |
||
81 | |||
82 | for ( ch=0; ch<4; ch++ ) { |
||
83 | DeleteGraphPlot (p2h, harr[ch], -1, VAL_IMMEDIATE_DRAW); |
||
84 | |||
85 | for ( i=0 ; i<nndata[ch] ; i++ ) { |
||
86 | if ( (data[ch][i]>>16)&(0x1) ) { |
||
87 | //printf ( "falling\n" ) ; |
||
88 | PlotPoint (p2h, harr[ch], data[ch][i]&0xFFFF, 1.0, VAL_SOLID_SQUARE, VAL_RED); |
||
89 | PlotLine (p2h, harr[ch], data[ch][i]&0xFFFF, 1.0, data[ch][i]&0xFFFF, 0.0, VAL_RED); |
||
90 | } else { |
||
91 | //printf ( "rising %d %X\n", ch, data[ch][i]&0xFFFF ) ; |
||
92 | PlotPoint (p2h, harr[ch], data[ch][i]&0xFFFF, 1.0, VAL_EMPTY_SQUARE, VAL_BLUE); |
||
93 | PlotLine (p2h, harr[ch], data[ch][i]&0xFFFF, 1.0, data[ch][i]&0xFFFF, 0.0, VAL_BLUE); |
||
94 | } |
||
95 | } |
||
96 | |||
97 | } |
||
98 | |||
99 | |||
100 | return 0 ; |
||
101 | } |
||
102 | |||
103 | //***************************************************************************** |
||
104 | |||
105 | int draw_acum_histos() { |
||
106 | int hsts[64]={P3_ACUM_1,P3_ACUM_2,P3_ACUM_3,P3_ACUM_4,P3_ACUM_5,P3_ACUM_6,P3_ACUM_7,P3_ACUM_8,P3_ACUM_9,P3_ACUM_10, |
||
107 | P3_ACUM_11,P3_ACUM_12,P3_ACUM_13,P3_ACUM_14,P3_ACUM_15,P3_ACUM_16,P3_ACUM_17,P3_ACUM_18,P3_ACUM_19,P3_ACUM_20, |
||
108 | P3_ACUM_21,P3_ACUM_22,P3_ACUM_23,P3_ACUM_24,P3_ACUM_25,P3_ACUM_26,P3_ACUM_27,P3_ACUM_28,P3_ACUM_29,P3_ACUM_30, |
||
109 | P3_ACUM_31,P3_ACUM_32,P3_ACUM_33,P3_ACUM_34,P3_ACUM_35,P3_ACUM_36,P3_ACUM_37,P3_ACUM_38,P3_ACUM_39,P3_ACUM_40, |
||
110 | P3_ACUM_41,P3_ACUM_42,P3_ACUM_43,P3_ACUM_44,P3_ACUM_45,P3_ACUM_46,P3_ACUM_47,P3_ACUM_48,P3_ACUM_49,P3_ACUM_50, |
||
111 | P3_ACUM_51,P3_ACUM_52,P3_ACUM_53,P3_ACUM_54,P3_ACUM_55,P3_ACUM_56,P3_ACUM_57,P3_ACUM_58,P3_ACUM_59,P3_ACUM_60, |
||
112 | P3_ACUM_61,P3_ACUM_62,P3_ACUM_63,P3_ACUM_64} ; |
||
113 | int i; |
||
114 | double grmin,grmax; |
||
115 | |||
116 | GetCtrlVal (p1h, P1_TDC_MAX, &max_tdc ) ; |
||
117 | GetCtrlVal (p1h, P1_TDC_MIN, &min_tdc ) ; |
||
118 | GetCtrlVal (p1h, P1_TDC_MAX_2, &max_tdcR ) ; |
||
119 | GetCtrlVal (p1h, P1_TDC_MIN_2, &min_tdcR ) ; |
||
120 | //SetAxisScalingMode (p1h, P1_ACUM_WIN, VAL_XAXIS, VAL_MANUAL, min_tdc, max_tdc); |
||
121 | |||
122 | DeleteGraphPlot (p1h, P1_ACUM, -1, VAL_IMMEDIATE_DRAW); |
||
123 | DeleteGraphPlot (p1h, P1_ACUM_WIN, -1, VAL_IMMEDIATE_DRAW); |
||
124 | |||
125 | PlotY (p1h, P1_ACUM, acum_allch, /*65536*/ 65536, VAL_UNSIGNED_SHORT_INTEGER, |
||
126 | VAL_VERTICAL_BAR, VAL_NO_POINT, VAL_SOLID, 1, VAL_DK_BLUE); |
||
127 | PlotY (p1h, P1_ACUM_WIN, acum_allch, /*65536*/ 65536, VAL_UNSIGNED_SHORT_INTEGER, |
||
128 | VAL_VERTICAL_BAR, VAL_NO_POINT, VAL_SOLID, 1, VAL_DK_BLUE); |
||
129 | |||
130 | GetAxisScalingMode (p1h, P1_ACUM_WIN, VAL_LEFT_YAXIS, 0, &grmin, &grmax ); |
||
131 | |||
132 | PlotLine (p1h, P1_ACUM_WIN, min_tdcR, 0, min_tdcR, grmax, VAL_RED); |
||
133 | PlotLine (p1h, P1_ACUM_WIN, max_tdcR, 0, max_tdcR, grmax, VAL_RED); |
||
134 | PlotLine (p1h, P1_ACUM_WIN, min_tdc, 0, min_tdc, grmax, VAL_GREEN); |
||
135 | PlotLine (p1h, P1_ACUM_WIN, max_tdc, 0, max_tdc, grmax, VAL_GREEN); |
||
136 | |||
137 | for ( i=0; i<64; i++ ) { |
||
138 | DeleteGraphPlot (p3h, hsts[i], -1, VAL_IMMEDIATE_DRAW); |
||
139 | |||
140 | PlotY (p3h, hsts[i], acum_snglch[i], 256, VAL_UNSIGNED_SHORT_INTEGER, |
||
141 | VAL_VERTICAL_BAR, VAL_NO_POINT, VAL_SOLID, 1, VAL_DK_BLUE); |
||
142 | |||
143 | } |
||
144 | |||
145 | return 0 ; |
||
146 | } |
||
147 | |||
148 | //***************************************************************************** |
||
149 | |||
150 | int draw_evnt() { |
||
151 | int i,j,color,frame; |
||
152 | int iijj[8]={1,3, 7,9, 13,15, 19,21} ; |
||
153 | // int iijj[8]={1,3, 7,9, 13,15, 19,21} ; |
||
154 | |||
155 | DeleteGraphPlot (p1h, P1_EV_DI, -1, VAL_IMMEDIATE_DRAW); |
||
156 | for ( i=1; i<20; i+=6 ) { |
||
157 | for ( j=1; j<20; j+=6 ) { |
||
158 | PlotRectangle (p1h,P1_EV_DI,i,j,i+4,j+4,VAL_DK_GRAY,VAL_TRANSPARENT); |
||
159 | } |
||
160 | } |
||
161 | for ( i=0; i<64; i++ ) { |
||
162 | if ( (pmtbitmap_win[i>>5]>>(i&0x1F))&0x1 ) { |
||
163 | color = VAL_DK_GREEN; |
||
164 | frame = VAL_DK_GREEN; |
||
165 | } else if ( (pmtbitmap[i>>5]>>(i&0x1F))&0x1 ) { |
||
166 | color = VAL_TRANSPARENT; |
||
167 | frame = VAL_RED; |
||
168 | } else { |
||
169 | color = -1 ; |
||
170 | } |
||
171 | |||
172 | if ( color!=-1 ) { |
||
173 | PlotRectangle (p1h, P1_EV_DI, |
||
174 | iijj[pmtmap_i[i]]+0.1,iijj[pmtmap_j[i]]+0.1, |
||
175 | iijj[pmtmap_i[i]]+1.9,iijj[pmtmap_j[i]]+1.9, |
||
176 | frame,color); |
||
177 | } |
||
178 | } |
||
179 | return 0 ; |
||
180 | } |
||
181 | |||
182 | //***************************************************************************** |
||
183 | |||
184 | int num_gr_photons() { |
||
185 | |||
186 | int rc=0; |
||
187 | long bitmap[2]; |
||
188 | int i; |
||
189 | |||
190 | bitmap[0]=pmtbitmap_win[0]; |
||
191 | bitmap[1]=pmtbitmap_win[1]; |
||
192 | for (i=0;i<32;i++) { |
||
193 | if (bitmap[0]&0x1) rc++; |
||
194 | if (bitmap[1]&0x1) rc++; |
||
195 | bitmap[0]>>=1; |
||
196 | bitmap[1]>>=1; |
||
197 | } |
||
198 | printf("%08X\t%08X\n",pmtbitmap_win[0],pmtbitmap_win[1]); |
||
199 | printf("num_gr_photons %d\n",rc); |
||
200 | return rc; |
||
201 | } |
||
202 | |||
203 | //***************************************************************************** |
||
204 | |||
205 | int initvar(unsigned long xxx[],int n) { |
||
206 | for (;--n>=0;xxx[n]=0); |
||
207 | return 0; |
||
208 | } |
||
209 | |||
210 | //***************************************************************************** |
||
211 | |||
212 | int daq(){ |
||
213 | |||
214 | static int cdaq=0; |
||
215 | int dum; |
||
216 | int error,i,j,fcount,fcountold=-1,nauto,fauto; |
||
217 | int nfirst[3],ntrig[3],ndata[3],ndatac,neve,ntrold; |
||
218 | unsigned short *j16=(unsigned short *) &j; |
||
219 | |||
220 | unsigned long ext_c; |
||
221 | |||
222 | char filename[256],path[256], fname[256]; |
||
223 | int maxeve,print,neve_sel=0,nueve=0; |
||
224 | |||
225 | unsigned int bsr ; |
||
226 | unsigned short dataxxx ; |
||
227 | unsigned short edge_type, overflow, channel, ev_dat, tdc_num, last_dat, nval_dat; |
||
228 | unsigned short gerror ; |
||
229 | int hits=0 ; |
||
230 | //int last[2] ; |
||
231 | int last_ev_no = -1 ; |
||
232 | |||
233 | |||
234 | if (cdaq==1) return -1; |
||
235 | else cdaq=1; |
||
236 | |||
237 | // initialize VME interface |
||
238 | #ifdef USE_DAQ |
||
239 | error = V673A_map (0,V673A_BASE_A24, 1); |
||
240 | error = V673A_init(0); |
||
241 | V673A_setreg(0,0x1a,0x003e); |
||
242 | V673A_setreg(0,0x1e,0x003e); |
||
243 | error = V673A_clallb(0); |
||
244 | #endif |
||
245 | |||
246 | |||
247 | SetCtrlVal (p1h, P1_LED_DAQ,1); |
||
248 | SetCtrlVal (p1h, P1_TRIG, 0 ) ; |
||
249 | GetCtrlVal (p1h, P1_DEBUG, &print ) ; |
||
250 | GetCtrlVal (p1h, P1_NAUTO, &nauto ) ; |
||
251 | GetCtrlVal (p1h, P1_AUTOSAVE, &fauto ) ; |
||
252 | GetCtrlVal (p1h, P1_NEVNT, &maxeve ) ; |
||
253 | GetCtrlVal (p1h, P1_FNAME, fname ); |
||
254 | GetCtrlVal (p1h, P1_PATH, path ); |
||
255 | GetCtrlVal (p1h, P1_TDC_MAX, &max_tdc ) ; |
||
256 | GetCtrlVal (p1h, P1_TDC_MIN, &min_tdc ) ; |
||
257 | GetCtrlVal (p1h, P1_TDC_MAX_2, &max_tdcR ) ; |
||
258 | GetCtrlVal (p1h, P1_TDC_MIN_2, &min_tdcR ) ; |
||
259 | GetCtrlVal (p1h, P1_SINGLE, &single_event ) ; |
||
260 | //PlotLine (p1h, P1_ACUM_WIN, min_tdcR, 0, min_tdcR, 1000, VAL_RED); |
||
261 | //PlotLine (p1h, P1_ACUM_WIN, max_tdcR, 0, max_tdcR, 1000, VAL_RED); |
||
262 | //PlotLine (p1h, P1_ACUM_WIN, min_tdc, 0, min_tdc, 1000, VAL_GREEN); |
||
263 | //PlotLine (p1h, P1_ACUM_WIN, max_tdc, 0, max_tdc, 1000, VAL_GREEN); |
||
264 | //SetAxisScalingMode (p1h, P1_ACUM_WIN, VAL_XAXIS, VAL_MANUAL, min_tdc, max_tdc); |
||
265 | // start measurement |
||
266 | neve=0; |
||
267 | neve_sel=0; |
||
268 | ntrold=0; |
||
269 | rID=0; |
||
270 | |||
271 | do { |
||
272 | /* |
||
273 | if (( neve%nauto==0 && fauto==1 ) || (neve==0 && fauto==1)){ |
||
274 | fcount=neve/nauto; |
||
275 | if ( fcountold < fcount ) { |
||
276 | sprintf(filename,"%s\\%s_file%d.dat",path,fname,fcount); |
||
277 | printf("%s\n",filename); |
||
278 | fcountold=fcount ; |
||
279 | } |
||
280 | } |
||
281 | */ |
||
282 | |||
283 | if ( rID == P1_STOP ) break ; |
||
284 | #ifdef USE_DAQ |
||
285 | ntrig[0] = V673A_ntrig (0); |
||
286 | #endif |
||
287 | //printf ( "%d\t", ntrig[0] ) ; |
||
288 | //if (ntrig[0]!=-1) { |
||
289 | if (ntrig[0]>ntrold) { |
||
290 | ntrold=ntrig[0]-1; |
||
291 | initvar ( data0, 1024 ) ; |
||
292 | |||
293 | #ifdef USE_DAQ |
||
294 | ndata[0] = V673A_getevnt (0,ntrold,data0,MAXDATA); |
||
295 | #endif |
||
296 | //printf ( "%d\t", ndata[0] ) ; |
||
297 | |||
298 | for ( i=0;i<ndata[0];i++ ) { |
||
299 | dataa[i]=0xc3ffffff & data0[i]; |
||
300 | // printf ( "%d\t", data0[i] ) ; |
||
301 | } |
||
302 | ntrold=(ntrold+1)&0xffff; |
||
303 | |||
304 | if ( ndata[0] >0 ) { |
||
305 | pmtbitmap[0] = 0 ; |
||
306 | pmtbitmap[1] = 0 ; |
||
307 | pmtbitmap_win[0] = 0 ; |
||
308 | pmtbitmap_win[1] = 0 ; |
||
309 | |||
310 | for (i=0;i<ndata[0];i++) { |
||
311 | dataxxx = data0[i] & 0xFFFF ; |
||
312 | edge_type = (data0[i]>>16)&0x1 ; |
||
313 | overflow = (data0[i]>>17)&0x1 ; |
||
314 | tdc_num = (data0[i]>>25)&0x1 ; |
||
315 | channel = (data0[i]>>18)&0x1F|tdc_num<<5 ; |
||
316 | ev_dat = (data0[i]>>23)&0x1 ; |
||
317 | last_dat = (data0[i]>>30)&0x1 ; |
||
318 | nval_dat = (data0[i]>>31)&0x1 ; |
||
319 | if (ev_dat == 0) { // event data |
||
320 | hits++ ; |
||
321 | if ( nndata[channel] < 63 ) { |
||
322 | data[channel][nndata[channel]++] = dataxxx|edge_type<<16 ; |
||
323 | |||
324 | } |
||
325 | if ((edge_type & 0x1)==0 ) { // rising edge |
||
326 | acum_allch[dataxxx]++ ; |
||
327 | if ((0<=(dataxxx-offset))&&((dataxxx-offset)<512) ) { // siroko okno |
||
328 | acum_snglch[channel][dataxxx-offset]++ ; |
||
329 | } |
||
330 | if ((min_tdcR<=(dataxxx-offset)) && ((dataxxx-offset)<max_tdcR)) { // rdece okno |
||
331 | if ( channel>31 ) |
||
332 | pmtbitmap[1] |= 1<<(channel-32) ; |
||
333 | else |
||
334 | pmtbitmap[0] |= 1<<(channel) ; |
||
335 | } |
||
336 | if ( (min_tdc<=(dataxxx-offset)) && ((dataxxx-offset)<max_tdc) ) { // zeleno okno |
||
337 | if ( channel>31 ) |
||
338 | pmtbitmap_win[1] |= 1<<(channel-32); |
||
339 | else |
||
340 | pmtbitmap_win[0] |= 1<<(channel); |
||
341 | } |
||
342 | } |
||
343 | } else if (last_dat==0) { //not last datum |
||
344 | //pmtbitmap[0] = 0; |
||
345 | //pmtbitmap[1] = 0; |
||
346 | last_ev_no = dataxxx; |
||
347 | } |
||
348 | } |
||
349 | |||
350 | if (num_gr_photons() >= minhit) { |
||
351 | draw_evnt(); |
||
352 | //draw_histos(); |
||
353 | draw_acum_histos(); |
||
354 | neve_sel++; |
||
355 | } |
||
356 | |||
357 | } |
||
358 | neve++; |
||
359 | } else { |
||
360 | error = V673A_clallb(0); |
||
361 | ntrold=0; |
||
362 | } |
||
363 | SetCtrlVal (p1h, P1_PROC, (neve*100)/maxeve ) ; |
||
364 | SetCtrlVal (p1h, P1_TRIG, neve ) ; |
||
365 | do { |
||
366 | nueve=GetUserEvent (0, &rph, &rID); |
||
367 | } while ( rID != P1_STOP && nueve>0 ); |
||
368 | if ( rID == P1_STOP ) break ; |
||
369 | } while ( (neve < maxeve) && (neve_sel<1 || !single_event) ) ; |
||
370 | |||
371 | SetCtrlVal (p1h, P1_LED_DAQ,0); |
||
372 | cdaq=0; |
||
373 | return 0; |
||
374 | } |
||
375 | |||
376 | //***************************************************************************** |
||
377 | //*************************** MAIN ******************************************** |
||
378 | //***************************************************************************** |
||
379 | |||
380 | int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
||
381 | LPSTR lpszCmdLine, int nCmdShow) |
||
382 | { |
||
383 | int error; |
||
384 | int i,j; |
||
385 | int nevnt,cnt; |
||
386 | int pmtmap[32][32] ; |
||
387 | int gray[16] = {0x000000, 0x111111, 0x222222, 0x333333, 0x444444, 0x555555, 0x666666, |
||
388 | 0x777777, 0x888888, 0x999999, 0xAAAAAA, 0xBBBBBB, 0xCCCCCC, 0xDDDDDD, |
||
389 | 0xEEEEEE, 0xFFFFFF } ; |
||
390 | double x, y, min_r, max_r, r1, r2 ; |
||
391 | |||
392 | ColorMapEntry grCol[16] ; |
||
393 | |||
394 | grCol[0].dataValue.valInt = 0 ; |
||
395 | grCol[0].color = gray[0] ; |
||
396 | grCol[1].dataValue.valInt = 100000 ; |
||
397 | grCol[1].color = gray[15] ; |
||
398 | |||
399 | |||
400 | read_pmtmap ( ) ; |
||
401 | |||
402 | for ( i=0 ; i<32; i++ ) { |
||
403 | for ( j=0 ; j<32; j++ ) { |
||
404 | if ( ( (((i+2)/4)%2) != 0 ) && ( (((j+2)/4)%2) != 0 ) ) |
||
405 | pmtmap[i][j]=1000000 ; |
||
406 | else pmtmap[i][j]=0 ; |
||
407 | //pmtmap[i][j]=(i+1)*(i+1)*(i+1)*(j+1) ; |
||
408 | } |
||
409 | } |
||
410 | |||
411 | p1h = LoadPanel (0, "rich_ui.uir", P1); |
||
412 | // p2h = LoadPanel (0, "laprich.uir", HISTOS); |
||
413 | p3h = LoadPanel (0, "rich_ui.uir", P3); |
||
414 | DisplayPanel (p1h); |
||
415 | // DisplayPanel (p2h); |
||
416 | DisplayPanel (p3h); |
||
417 | for ( i=1; i<20; i+=6 ) { |
||
418 | for ( j=1; j<20; j+=6 ) { |
||
419 | PlotRectangle (p1h,P1_EV_DI,i,j,i+4,j+4,VAL_DK_GRAY,VAL_TRANSPARENT); |
||
420 | } |
||
421 | } |
||
422 | |||
423 | #ifdef USE_DAQ |
||
424 | # ifdef WUSBVME |
||
425 | VME_START(USBVME_NAME); |
||
426 | # else |
||
427 | VME_START(NULL); |
||
428 | # endif |
||
429 | #endif |
||
430 | |||
431 | do { |
||
432 | GetUserEvent (1, &rph, &rID); |
||
433 | switch (rID){ |
||
434 | case P1_EV_PL: |
||
435 | // PlotScaledIntensity (p1h, P1_EV_DI, pmtmap, 32, 32, VAL_INTEGER, |
||
436 | // 1.0, 0.0, 1.0, 0.0, grCol, 0xff0000, 2, 1, 0); |
||
437 | draw_evnt(); |
||
438 | break; |
||
439 | case P1_READ_TDC: |
||
440 | daq(); //read_tdc ( ) ; |
||
441 | break; |
||
442 | case P1_DRAWH: |
||
443 | // draw_histos ( ) ; |
||
444 | draw_acum_histos ( ) ; |
||
445 | break; |
||
446 | case P1_SINGLE: |
||
447 | GetCtrlVal (p1h, P1_SINGLE, &single_event ) ; |
||
448 | break; |
||
449 | case P1_CONT_DAQ: |
||
450 | nevnt=0; |
||
451 | cnt=0; |
||
452 | minhit=0; |
||
453 | GetCtrlVal (p1h, P1_NEVNT, &nevnt ); |
||
454 | GetCtrlVal (p1h, P1_MINHIT, &minhit ); |
||
455 | // printf("%d %d\n", nevnt, minhit); |
||
456 | // while((read_tdc()<minhit)&&(cnt++<nevnt)) ; |
||
457 | daq(); |
||
458 | // draw_evnt(); |
||
459 | break; |
||
460 | case P1_EV_DI: |
||
461 | GetCtrlVal (p1h, P1_R_MIN, &min_r ) ; |
||
462 | GetCtrlVal (p1h, P1_R_MAX, &max_r ) ; |
||
463 | r1=min_r*2.0 ; |
||
464 | r2=max_r*2.0 ; |
||
465 | GetGraphCursor (p1h, P1_EV_DI, 1, &x, &y); |
||
466 | printf ( "x:%5.2f\ty:%5.2f\n", x, y ) ; |
||
467 | draw_evnt(); |
||
468 | PlotOval (p1h, P1_EV_DI, x-r1, y-r1, x+r1, y+r1, VAL_RED, VAL_TRANSPARENT); |
||
469 | PlotOval (p1h, P1_EV_DI, x-r2, y-r2, x+r2, y+r2, VAL_RED, VAL_TRANSPARENT); |
||
470 | break; |
||
471 | case P1_PRINT: |
||
472 | SetCtrlVal (p1h, P1_PL,1); |
||
473 | PrintCtrl (p1h, P1_EV_DI, "event.tif", 1, VAL_FULL_PANEL); |
||
474 | SetCtrlVal (p1h, P1_PL,0); |
||
475 | break; |
||
476 | case P1_RESET: |
||
477 | break; |
||
478 | // case P1_PRINT: |
||
479 | // break; |
||
480 | default: |
||
481 | break; |
||
482 | } |
||
483 | // if ( rID==P1_I_GATE ) init_gate ( ) ; |
||
484 | } while ( (rID!=P1_EXIT) || (rph!=p1h) ) ; |
||
485 | |||
486 | // CloseHandle(nHandle); |
||
487 | #ifdef USE_DAQ |
||
488 | VME_STOP(); |
||
489 | #endif |
||
490 | // printf ( "XXXX\n" ) ; |
||
491 | return 0; |
||
492 | } |