Rev 265 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
317 | f9daq | 1 | #include <tcpsupp.h> |
217 | f9daq | 2 | #include "H1D.h" |
3 | #include "H2D.h" |
||
203 | f9daq | 4 | #include <formatio.h> |
195 | f9daq | 5 | #include <utility.h> |
6 | #include <ansi_c.h> |
||
203 | f9daq | 7 | #include <cvirte.h> |
195 | f9daq | 8 | #include <userint.h> |
9 | #include "drs4.h" |
||
317 | f9daq | 10 | #include "scaler.h" |
203 | f9daq | 11 | #include "drsread.h" |
317 | f9daq | 12 | #include "K6517.h" |
195 | f9daq | 13 | |
317 | f9daq | 14 | K6517STATUS K6517Stat; |
15 | static int K6517_Interface,K6517_Port,K6517_Gdev; |
||
16 | //#define MIKRO |
||
203 | f9daq | 17 | |
18 | #ifdef MIKRO |
||
19 | #include "MIKRO.h" |
||
20 | #endif |
||
21 | |||
317 | f9daq | 22 | |
23 | /*---------------------------------------------------------------------------*/ |
||
24 | /* Module-globals */ |
||
25 | /*---------------------------------------------------------------------------*/ |
||
26 | static unsigned int g_hconversation; |
||
27 | static int g_hmainPanel; |
||
28 | static int g_connected = 0; |
||
29 | static int g_TCPError = 0; |
||
30 | |||
31 | |||
32 | int daq_on; |
||
33 | int ph, p2,p3,p4, plothandle[4]= {0,0,0,0}; |
||
34 | static int qdcplothandle[4]= {0,0,0,0}; |
||
217 | f9daq | 35 | static int scanplothandle; |
195 | f9daq | 36 | static int tfID; |
317 | f9daq | 37 | static int rID; |
195 | f9daq | 38 | static int controlID; |
39 | |||
203 | f9daq | 40 | #define MAX_THREADS 10 |
195 | f9daq | 41 | |
203 | f9daq | 42 | static CmtThreadPoolHandle poolHandle = 0; |
195 | f9daq | 43 | |
217 | f9daq | 44 | static float gSum[4]={0,0,0,0}; |
317 | f9daq | 45 | |
46 | |||
47 | int gActive[4]= {0,0,0,0}; |
||
48 | double gTwinMin[4]= {0,0,0,0}; |
||
49 | double gTwinMax[4]= {0,0,0,0}; |
||
50 | double gFx[4]= {0,0,0,0}; |
||
51 | |||
195 | f9daq | 52 | int main (int argc, char *argv[]) { |
203 | f9daq | 53 | short port; |
54 | if (InitCVIRTE (0, argv, 0) == 0) |
||
55 | return -1; /* out of memory */ |
||
56 | if ((ph = LoadPanel (0, "drs4.uir", PANEL)) < 0) |
||
57 | return -1; |
||
58 | if ((p2 = LoadPanel (0, "drs4.uir", SCAN)) < 0) |
||
59 | return -1; |
||
317 | f9daq | 60 | if ((p3 = LoadPanel (0, "drs4.uir", QDC)) < 0) |
61 | return -1; |
||
62 | if ((p4 = LoadPanel (0, "scaler.uir", SCALER)) < 0) |
||
63 | return -1; |
||
64 | |||
65 | DisableBreakOnLibraryErrors(); |
||
203 | f9daq | 66 | SetStdioPort (CVI_STDIO_WINDOW); |
67 | SetSleepPolicy(VAL_SLEEP_MORE); |
||
68 | CmtNewThreadPool (MAX_THREADS, &poolHandle); |
||
69 | |||
70 | DisplayPanel (ph); |
||
71 | DisplayPanel (p2); |
||
317 | f9daq | 72 | DisplayPanel (p3); |
73 | DisplayPanel (p4); |
||
203 | f9daq | 74 | #ifdef MIKRO |
75 | GetCtrlVal(p2, SCAN_PORT, &port); |
||
76 | if (MIKRO_Open (port)) MessagePopup ("Error", "Mikro Port Not found !\n Change in the GUI") ; |
||
77 | MIKRO_Init(1,0); |
||
78 | MIKRO_Init(2,0); |
||
79 | #endif |
||
80 | |||
317 | f9daq | 81 | K6517_open (1,4,3,0,13); |
82 | |||
203 | f9daq | 83 | RunUserInterface (); |
84 | DiscardPanel (ph); |
||
85 | DiscardPanel (p2); |
||
317 | f9daq | 86 | DiscardPanel (p3); |
87 | DiscardPanel (p4); |
||
203 | f9daq | 88 | CmtDiscardThreadPool (poolHandle); |
317 | f9daq | 89 | #ifdef MIKRO |
90 | MIKRO_Close (); |
||
91 | #endif |
||
203 | f9daq | 92 | return 0; |
195 | f9daq | 93 | } |
94 | |||
95 | |||
210 | f9daq | 96 | char strbuf[0xFF]; |
195 | f9daq | 97 | |
210 | f9daq | 98 | int gLog=0; |
195 | f9daq | 99 | |
210 | f9daq | 100 | int printf(const char *format, ...) { |
101 | va_list aptr; |
||
102 | int ret; |
||
103 | FILE *flog; |
||
195 | f9daq | 104 | |
210 | f9daq | 105 | va_start(aptr, format); |
106 | ret = vsprintf(strbuf, format, aptr); |
||
107 | va_end(aptr); |
||
108 | SetCtrlVal(ph,PANEL_STDIO,strbuf); |
||
109 | |||
110 | if (gLog) { |
||
111 | flog = fopen ("stdio.log", "a"); |
||
112 | fprintf (flog, "%s", strbuf); |
||
113 | fclose (flog); |
||
114 | } |
||
115 | return(ret); |
||
116 | } |
||
117 | |||
118 | |||
119 | |||
195 | f9daq | 120 | static void start_timer (double tout) { |
203 | f9daq | 121 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_INTERVAL, tout); |
122 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_ENABLED, 1); |
||
195 | f9daq | 123 | } |
124 | |||
125 | static void stop_timer ( void ) { |
||
203 | f9daq | 126 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_ENABLED, 0); |
127 | DRSSetTimeout(); |
||
195 | f9daq | 128 | } |
129 | |||
130 | |||
131 | |||
317 | f9daq | 132 | void CVICALLBACK EndOfThresholdScanThread ( CmtThreadPoolHandle poolhandle, |
133 | CmtThreadFunctionID functionID, unsigned int event, |
||
134 | int value, void *callbackData ) { |
||
135 | printf("End of Threshold Scan Thread \n"); |
||
136 | return ; |
||
195 | f9daq | 137 | |
317 | f9daq | 138 | } |
139 | |||
195 | f9daq | 140 | void CVICALLBACK EndOfThread ( CmtThreadPoolHandle poolhandle, |
203 | f9daq | 141 | CmtThreadFunctionID functionID, unsigned int event, |
142 | int value, void *callbackData ) { |
||
195 | f9daq | 143 | |
203 | f9daq | 144 | daq_on=0; |
145 | //SetDimming(0); |
||
146 | printf("End of Thread \n"); |
||
147 | return ; |
||
195 | f9daq | 148 | |
149 | } |
||
150 | |||
151 | |||
217 | f9daq | 152 | static float xs[4][1024]; |
317 | f9daq | 153 | |
203 | f9daq | 154 | int CVICALLBACK daq(void *functionData) { |
195 | f9daq | 155 | |
156 | |||
203 | f9daq | 157 | int neve; |
158 | char filename[0xff]; |
||
159 | int imask[4]; |
||
160 | unsigned long mask; |
||
161 | int frequency; |
||
162 | double trgdelay; |
||
163 | double trglevel; |
||
164 | int trgtype; |
||
165 | int trgchannel; |
||
166 | int trgpolarity; |
||
167 | int verbose; |
||
168 | double range; |
||
169 | int pfreq; |
||
170 | int enabledoutput; |
||
171 | int neveold = 0; |
||
172 | double rate; |
||
173 | int *args = (int *) functionData; |
||
265 | f9daq | 174 | |
317 | f9daq | 175 | int wfm=0; |
176 | const int init[4] = { QDC_INIT_1 ,QDC_INIT_2 ,QDC_INIT_3 ,QDC_INIT_4 }; |
||
177 | const int fx[4] = { PANEL_SCALE_1 ,PANEL_SCALE_2 ,PANEL_SCALE_3 ,PANEL_SCALE_4 }; |
||
178 | const int active[4] = { QDC_ACTIVE_1 ,QDC_ACTIVE_2 ,QDC_ACTIVE_3 ,QDC_ACTIVE_4 }; |
||
217 | f9daq | 179 | |
203 | f9daq | 180 | GetCtrlVal(ph, PANEL_CH0, &imask[0] ); |
181 | GetCtrlVal(ph, PANEL_CH1, &imask[1] ); |
||
182 | GetCtrlVal(ph, PANEL_CH2, &imask[2] ); |
||
183 | GetCtrlVal(ph, PANEL_CH3, &imask[3] ); |
||
317 | f9daq | 184 | GetCtrlVal(p3, QDC_WFM, &wfm ); |
203 | f9daq | 185 | mask = 0; |
186 | for (int i=0; i<4; i++) { |
||
317 | f9daq | 187 | if (imask[i]) { |
188 | mask |= (1<<i); |
||
189 | ScaleCB(ph,fx[i],EVENT_COMMIT,NULL, 0,0); |
||
190 | SetActiveCB(p3,active[i],EVENT_COMMIT,NULL, 0,0); |
||
191 | InitQdcHistogramCB(p3, init[i],EVENT_COMMIT,NULL, 0,0); |
||
192 | } |
||
201 | f9daq | 193 | } |
317 | f9daq | 194 | LogScaleCB(p3, QDC_LOGY,EVENT_COMMIT,NULL, 0,0); |
203 | f9daq | 195 | |
265 | f9daq | 196 | |
203 | f9daq | 197 | GetCtrlVal(ph,PANEL_NEVE, &neve); |
198 | GetCtrlVal(ph,PANEL_DEBUG, &verbose); |
||
199 | GetCtrlVal(ph,PANEL_PFREQ, &pfreq); |
||
200 | GetCtrlVal(ph,PANEL_ENABLEDOUTPUT, &enabledoutput); |
||
201 | |||
202 | GetCtrlVal(ph,PANEL_FREQUENCY, &frequency); |
||
203 | GetCtrlVal(ph,PANEL_TRGDELAY, &trgdelay); |
||
204 | GetCtrlVal(ph,PANEL_TRGCHANNEL, &trgchannel); |
||
205 | |||
265 | f9daq | 206 | |
203 | f9daq | 207 | GetCtrlVal(ph,PANEL_TRGTYPE, &trgtype); |
208 | GetCtrlVal(ph,PANEL_TRGLEVEL, &trglevel); |
||
209 | GetCtrlVal(ph,PANEL_TRGPOLARITY, &trgpolarity); |
||
210 | GetCtrlVal(ph,PANEL_RANGE, &range); |
||
211 | |||
317 | f9daq | 212 | |
203 | f9daq | 213 | //printf("mask=0x%x\n",mask); |
214 | |||
215 | DRSSetMask( (unsigned char)( mask & 0xF ) ); |
||
216 | |||
217 | DRSSetFrequency( frequency ); |
||
218 | DRSSetTriggerDelay(trgdelay ); |
||
219 | DRSSetTriggerChannel(trgchannel ); |
||
220 | DRSSetTriggerType( trgtype ); |
||
221 | DRSSetTriggerLevel(trglevel); |
||
222 | DRSSetTriggerPolarity(trgpolarity); |
||
223 | |||
224 | DRSSetRange ( range ); |
||
225 | |||
226 | |||
227 | |||
228 | FILE *fp= NULL; |
||
229 | |||
230 | if (enabledoutput) { |
||
317 | f9daq | 231 | if (1==1) { |
217 | f9daq | 232 | GetCtrlVal(ph, PANEL_FILENAME, filename ); |
317 | f9daq | 233 | printf("%s\n", filename); |
217 | f9daq | 234 | fp = fopen(filename,"wb"); |
235 | } else { |
||
236 | GetCtrlVal(p2, SCAN_FILENAME, filename ); |
||
237 | fp = fopen(filename,"ab"); |
||
317 | f9daq | 238 | printf("%s\n", filename); |
217 | f9daq | 239 | } |
203 | f9daq | 240 | } |
241 | |||
242 | static unsigned char *buffer; |
||
243 | |||
244 | int buffer_size = 0; |
||
245 | const int nBoards=1; |
||
246 | const int waveDepth=1024; |
||
207 | f9daq | 247 | |
203 | f9daq | 248 | if (buffer_size == 0) { |
207 | f9daq | 249 | buffer_size = 8; // file header + time header |
250 | buffer_size += nBoards * (4 + 4*(4+waveDepth*4)); // bin widths |
||
251 | buffer_size += 24 + nBoards * (8 + 4*(8+waveDepth*2)); |
||
252 | buffer = (unsigned char *)malloc(buffer_size); |
||
253 | } |
||
254 | |||
203 | f9daq | 255 | time_t t=0,told=0, tstart=0; |
256 | |||
257 | if (!DRSInit()) { |
||
265 | f9daq | 258 | |
203 | f9daq | 259 | time(&tstart); |
260 | told=tstart; |
||
217 | f9daq | 261 | int nev=0; |
262 | for (int k = 0;k<4;k++){ |
||
263 | gSum[k]=0; |
||
264 | } |
||
265 | for (int i=0; i<neve; i++) { |
||
203 | f9daq | 266 | start_timer(1);// 1 s timeout |
267 | int retval = DRSRead(0); |
||
268 | stop_timer(); |
||
269 | int nb = ( retval == 0 && fp ) ? DRSToBuffer( buffer , i ) : 0; |
||
270 | SetCtrlVal(ph,PANEL_CEVE,i); |
||
271 | if (retval) i--; |
||
217 | f9daq | 272 | nev++; |
203 | f9daq | 273 | if (!daq_on) break; |
274 | time(&t); |
||
275 | if (t!=told ) { |
||
317 | f9daq | 276 | PlotQdcHistogramCB(0,0,EVENT_COMMIT,NULL, 0,0); |
203 | f9daq | 277 | rate = (i-neveold); |
278 | printf("%d events in %2.2f min (%d s) Rate %f Hz %s ",i+1, (double)(t-tstart)/60.,(t-tstart), rate , ctime(&t)); |
||
279 | GetCtrlVal(ph,PANEL_PFREQ, &pfreq); |
||
280 | neveold = i; |
||
281 | } |
||
282 | told=t; |
||
283 | // Save data |
||
317 | f9daq | 284 | |
203 | f9daq | 285 | if (nb>0 && fp) fwrite(buffer, 1,nb ,fp); |
286 | // Plot Data |
||
317 | f9daq | 287 | |
217 | f9daq | 288 | for (int k=0; k<4; k++) { |
289 | if ( (mask & ( 0x1<<k )) ){ |
||
317 | f9daq | 290 | double fSum= 0; |
217 | f9daq | 291 | float *t=DRSGetTime(k); |
292 | float *x=DRSGetWave(k); |
||
293 | ; |
||
294 | for (int j=0 ; j<1024 ; j++) { |
||
317 | f9daq | 295 | xs[k][j]= x[j]*1e-3*gFx[k]; |
296 | if (gActive[k]){ |
||
297 | if (t[j]> gTwinMin[k] && t[j] < gTwinMax[k]) { |
||
298 | fSum+= fabs(xs[k][j]); |
||
299 | } |
||
300 | if (wfm){ |
||
301 | H2D_Fill(200+k,t[j], xs[k][j],1); |
||
302 | } |
||
303 | //if (verbose) printf("[%d] %d. x= %3.2f y=%3.2f\n", k, i, t[j], x[j] ); |
||
304 | } |
||
305 | } |
||
306 | if (verbose) printf("qdc[%d] %3.2f active=%d\n", k, fSum ,gActive[k]); |
||
307 | if (gActive[k]) { |
||
308 | if (!wfm) { |
||
309 | H1D_Fill(200+k,fSum,1.); |
||
310 | } |
||
311 | } |
||
312 | gSum[k]+=fSum; |
||
217 | f9daq | 313 | |
314 | if (i % pfreq == 0) { |
||
315 | const int col[4]= {VAL_WHITE,VAL_RED,VAL_GREEN,VAL_BLUE}; |
||
316 | if (plothandle[k]) DeleteGraphPlot (ph, PANEL_GRAPH, plothandle[k], VAL_IMMEDIATE_DRAW); |
||
317 | plothandle[k] = PlotXY (ph, PANEL_GRAPH, t, xs[k], 1024, VAL_FLOAT, VAL_FLOAT, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, col[k]); |
||
318 | } |
||
203 | f9daq | 319 | } |
217 | f9daq | 320 | |
203 | f9daq | 321 | } |
322 | |||
323 | |||
324 | } |
||
325 | time(&t); |
||
217 | f9daq | 326 | printf("%d events in %2.2f min (%d s) %s",nev, (double)(t-tstart)/60.,t-tstart, ctime(&t)); |
203 | f9daq | 327 | DRSEnd(); |
328 | } |
||
329 | |||
330 | if (fp) fclose(fp); |
||
331 | |||
332 | free(buffer); |
||
333 | |||
334 | return 0; |
||
335 | |||
195 | f9daq | 336 | } |
337 | |||
338 | |||
317 | f9daq | 339 | void CVICALLBACK EndOfThrScan ( CmtThreadPoolHandle poolhandle, |
340 | CmtThreadFunctionID functionID, unsigned int event, |
||
341 | int value, void *callbackData ) { |
||
195 | f9daq | 342 | |
317 | f9daq | 343 | |
344 | //SetDimming(0); |
||
345 | printf("End of thrscan \n"); |
||
346 | return ; |
||
347 | |||
348 | } |
||
349 | |||
350 | |||
351 | |||
352 | int scaler(int min, int max, int dx, int time_set, char *filename); |
||
353 | |||
354 | int CVICALLBACK thrscan(void *functionData) { |
||
355 | char str[0xFF]; |
||
356 | char path[0xFF]; |
||
357 | |||
358 | int step,min,max, mtime; |
||
359 | GetCtrlVal(p4, SCALER_STEP,&step); |
||
360 | GetCtrlVal(p4, SCALER_TIME,&mtime); |
||
361 | GetCtrlVal(p4, SCALER_MAX,&max); |
||
362 | GetCtrlVal(p4, SCALER_MIN,&min); |
||
363 | GetCtrlVal(ph, PANEL_FILENAME,path); |
||
364 | |||
365 | sprintf(str, "%s.thr", path); |
||
366 | scaler(min,max,step,mtime,str); |
||
367 | return 0; |
||
368 | |||
369 | |||
370 | } |
||
371 | |||
372 | |||
373 | int CVICALLBACK acquire_data (void *arg) { |
||
374 | |||
375 | |||
376 | char *sarg = (char *) arg; |
||
377 | printf("sarg %s\n", sarg); |
||
378 | char str[0xFF]; |
||
379 | char path[0xFF]; |
||
380 | GetCtrlVal(ph,PANEL_PATH,path); |
||
381 | sprintf(str, "%s%s.dat", path, sarg); |
||
382 | SetCtrlVal(ph, PANEL_FILENAME,str); |
||
383 | |||
384 | int flag=0; |
||
385 | ThreadFunctionPtr mythread = thrscan; |
||
386 | int data; |
||
387 | int threadhandle; |
||
388 | CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &data, |
||
389 | DEFAULT_THREAD_PRIORITY, |
||
390 | EndOfThresholdScanThread, |
||
391 | EVENT_TP_THREAD_FUNCTION_END, |
||
392 | NULL, RUN_IN_SCHEDULED_THREAD, |
||
393 | &threadhandle); |
||
394 | daq(&flag); |
||
395 | CmtWaitForThreadPoolFunctionCompletionEx (poolHandle, threadhandle, OPT_TP_PROCESS_EVENTS_WHILE_WAITING, CMT_WAIT_FOREVER); |
||
396 | return 0; |
||
397 | } |
||
398 | |||
399 | int CVICALLBACK SwitchOnOffCB (int panel, int control, int event, |
||
400 | void *callbackData, int eventData1, int eventData2) |
||
401 | { |
||
402 | unsigned char state; |
||
403 | switch (event) |
||
404 | { |
||
405 | case EVENT_COMMIT: |
||
406 | GetCtrlVal(panel, control, &state); |
||
407 | K6517_vsource_operate (state); |
||
408 | break; |
||
409 | } |
||
410 | return 0; |
||
411 | } |
||
412 | |||
413 | |||
414 | int CVICALLBACK SetVoltageCB (int panel, int control, int event, |
||
415 | void *callbackData, int eventData1, int eventData2) { |
||
416 | double vbr; |
||
417 | switch (event) { |
||
418 | case EVENT_COMMIT: |
||
419 | GetCtrlVal (ph, PANEL_VBR, &vbr ); |
||
420 | K6517_vsource_set (vbr+2); |
||
421 | break; |
||
422 | } |
||
423 | return 0; |
||
424 | } |
||
425 | |||
426 | |||
427 | |||
428 | int TScan () { |
||
429 | |||
430 | double temp; |
||
431 | double volt,vbr; |
||
432 | int n=0; |
||
433 | int led; |
||
434 | GetNumTableRows (ph, PANEL_TABLE, &n ); |
||
435 | daq_on = 1; |
||
436 | for(int i=0; i<n; i++) { |
||
437 | if (!daq_on) break; |
||
438 | GetTableCellVal (ph, PANEL_TABLE, MakePoint (1,i+1), &temp); |
||
439 | GetTableCellVal (ph, PANEL_TABLE, MakePoint (2,i+1), &vbr); |
||
440 | if (temp>100) break; |
||
441 | char transmitBuf[512]= {0}; |
||
442 | sprintf(transmitBuf, "1 %f\n", temp); |
||
443 | |||
444 | |||
445 | if (g_connected) |
||
446 | if ( ClientTCPWrite (g_hconversation, transmitBuf, strlen (transmitBuf), 1000) < 0) printf("Transmit Error\n"); else printf("%s\n", transmitBuf); |
||
447 | SetCtrlVal(ph,PANEL_LED, 0); |
||
448 | do { |
||
449 | time_t t0 = time(NULL); |
||
450 | SetCtrlVal(ph,PANEL_TIME, ctime(&t0)); |
||
451 | Delay(1); |
||
452 | GetCtrlVal(ph,PANEL_LED, &led); |
||
453 | if (led) { |
||
454 | for (int k=0;k<10;k++){ |
||
455 | Delay(1); |
||
456 | if (!daq_on) break; |
||
457 | } |
||
458 | GetCtrlVal(ph,PANEL_LED, &led); |
||
459 | } |
||
460 | if (!daq_on) break; |
||
461 | } while (!led); |
||
462 | if (!daq_on) break; |
||
463 | |||
464 | int itemp = (int) temp; |
||
465 | int n1=0; |
||
466 | GetNumTableRows (ph, PANEL_VTABLE, &n1 ); |
||
467 | |||
468 | for(int k=0; k<n1; k++) { |
||
469 | if (!daq_on) break; |
||
470 | GetTableCellVal (ph, PANEL_VTABLE, MakePoint (1,k+1), &volt); |
||
471 | if (volt<-100) break; |
||
472 | double voltage = vbr + volt; |
||
473 | int ivolt=(int)(volt*100); |
||
474 | K6517_vsource_set (voltage); |
||
475 | K6517_vsource_operate (1); |
||
476 | char str[0xFF]; |
||
477 | sprintf(str,"%d_%d", itemp, ivolt); |
||
478 | printf("%d %d %s\n",i,k, str); |
||
479 | acquire_data(str); |
||
480 | K6517_vsource_operate (0); |
||
481 | } |
||
482 | } |
||
483 | |||
484 | return 0; |
||
485 | } |
||
486 | |||
487 | int CVICALLBACK TScanCB (int panel, int control, int event, |
||
488 | void *callbackData, int eventData1, int eventData2) { |
||
489 | |||
490 | switch (event) { |
||
491 | case EVENT_COMMIT:{ |
||
492 | ThreadFunctionPtr mythread = TScan; |
||
493 | CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &rID, |
||
494 | DEFAULT_THREAD_PRIORITY, |
||
495 | EndOfThread, |
||
496 | EVENT_TP_THREAD_FUNCTION_END, |
||
497 | NULL, RUN_IN_SCHEDULED_THREAD, |
||
498 | &tfID); |
||
499 | } |
||
500 | break; |
||
501 | } |
||
502 | return 0; |
||
503 | } |
||
504 | |||
505 | int CVICALLBACK LogScaleCB (int panel, int control, int event, |
||
506 | void *callbackData, int eventData1, int eventData2) { |
||
507 | |||
508 | |||
509 | const unsigned int gr[4] = { QDC_GRAPH_1 ,QDC_GRAPH_2 ,QDC_GRAPH_3 ,QDC_GRAPH_4 }; |
||
510 | int wfm=0; |
||
511 | int attr, logy, selected; |
||
512 | switch (event) { |
||
513 | case EVENT_COMMIT: |
||
514 | GetCtrlVal(p3,QDC_WFM,&wfm); |
||
515 | GetCtrlVal(panel, control, &selected); |
||
516 | |||
517 | attr= ATTR_YMAP_MODE; |
||
518 | if(selected) logy=VAL_LOG; else logy=VAL_LINEAR; |
||
519 | if (wfm) logy=VAL_LINEAR; |
||
520 | for (int i=0;i<4;i++) SetCtrlAttribute (panel, gr[i],attr, logy); |
||
521 | break; |
||
522 | } |
||
523 | |||
524 | return 0; |
||
525 | } |
||
526 | |||
527 | int CVICALLBACK ExecRootCB (int panel, int control, int event, |
||
528 | void *callbackData, int eventData1, int eventData2) { |
||
529 | switch (event) { |
||
530 | case EVENT_COMMIT:{ |
||
531 | char fileName[100]; |
||
532 | char fname[100]; |
||
533 | char path[100]; |
||
534 | int trgchannel; |
||
535 | GetCtrlVal(panel, PANEL_FILENAME, fileName); |
||
536 | GetCtrlVal(panel,PANEL_TRGCHANNEL, &trgchannel); |
||
537 | GetCtrlVal(panel, PANEL_PATH, path); |
||
538 | sprintf(fname, "%s/%s", path, fileName); |
||
539 | //sprintf(fname, "%s", fileName); |
||
540 | int status; |
||
541 | char name[MAX_PATHNAME_LEN]; |
||
542 | // char dfile[MAX_PATHNAME_LEN]; |
||
543 | // char efile[MAX_PATHNAME_LEN]; |
||
544 | // status = FileSelectPopup ("dat", "*.dat", ".dat", |
||
545 | // "Izberi datoteko s podatki", |
||
546 | // VAL_LOAD_BUTTON, 0, 0, 1, 0, efile); |
||
547 | // EscapeString(efile,dfile); |
||
548 | sprintf(name ,"C:/home/dominik/runroot.bat \"C:/home/dominik/AnalyseWaveForms.cxx(-1,1000,\\\"%s\\\",%d)\" ", fname, trgchannel); |
||
549 | |||
550 | printf("%s\n",name); |
||
551 | LaunchExecutable(name); |
||
552 | break; |
||
553 | } |
||
554 | } |
||
555 | return 0; |
||
556 | } |
||
557 | |||
558 | |||
559 | int CVICALLBACK TempTableCB (int panel, int control, int event, |
||
560 | void *callbackData, int eventData1, int eventData2) { |
||
561 | switch (event) { |
||
562 | case EVENT_COMMIT: { |
||
563 | int status; |
||
564 | char name[MAX_PATHNAME_LEN]; |
||
565 | char dfile[MAX_PATHNAME_LEN]; |
||
566 | char efile[MAX_PATHNAME_LEN]; |
||
567 | status = FileSelectPopup ("dat", "*.dat", ".dat", |
||
568 | "Izberi datoteko s podatki", |
||
569 | VAL_LOAD_BUTTON, 0, 0, 1, 0, efile); |
||
570 | printf("%s", efile); |
||
571 | |||
572 | |||
573 | FILE *fp=fopen(efile,"r"); |
||
574 | float I; |
||
575 | float V; |
||
576 | int temp; |
||
577 | int ndim=400; |
||
578 | char line[400] |