Subversion Repositories f9daq

Rev

Rev 265 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 265 Rev 317
Line -... Line 1...
-
 
1
#include <tcpsupp.h>
1
2
#include "H1D.h"
2
3
#include "H2D.h"
3
4
#include <formatio.h>
4
5
#include <utility.h>
5
6
#include <ansi_c.h>
6
7
#include <cvirte.h>
7
8
#include <userint.h>
8
9
#include "drs4.h"
-
 
10
#include "scaler.h"
9
11
#include "drsread.h"
-
 
12
#include "K6517.h"
10
13
 
-
 
14
K6517STATUS K6517Stat;
-
 
15
static int K6517_Interface,K6517_Port,K6517_Gdev;
11
16
//#define MIKRO 
12
17
 
13
18
#ifdef MIKRO
14
19
#include "MIKRO.h"
15
20
#endif
16
21
 
-
 
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
 
17
32
int daq_on;
-
 
33
int ph, p2,p3,p4, plothandle[4]= {0,0,0,0};
18
34
static int qdcplothandle[4]= {0,0,0,0};
19
35
static int scanplothandle;
20
36
static int tfID;
-
 
37
static int rID;
21
38
static int controlID;
22
39
 
23
40
#define MAX_THREADS 10
24
41
 
25
42
static CmtThreadPoolHandle poolHandle = 0;
26
43
 
27
44
static float gSum[4]={0,0,0,0};
-
 
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
 
28
52
int main (int argc, char *argv[]) {
29
53
        short port;
30
54
        if (InitCVIRTE (0, argv, 0) == 0)
31
55
                return -1;  /* out of memory */
32
56
        if ((ph = LoadPanel (0, "drs4.uir", PANEL)) < 0)
33
57
                return -1;
34
58
        if ((p2 = LoadPanel (0, "drs4.uir", SCAN)) < 0)
35
59
                return -1;
-
 
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();
36
66
        SetStdioPort (CVI_STDIO_WINDOW);
37
67
        SetSleepPolicy(VAL_SLEEP_MORE);
38
68
        CmtNewThreadPool (MAX_THREADS,  &poolHandle);
39
69
 
40
70
        DisplayPanel (ph);
41
71
        DisplayPanel (p2);
-
 
72
        DisplayPanel (p3);
42
73
        DisplayPanel (p4);
43
74
#ifdef MIKRO
44
75
        GetCtrlVal(p2, SCAN_PORT, &port);
45
76
        if (MIKRO_Open (port)) MessagePopup ("Error", "Mikro Port Not found !\n Change in the GUI") ;
46
77
        MIKRO_Init(1,0);
47
78
        MIKRO_Init(2,0);
48
79
#endif
-
 
80
       
-
 
81
        K6517_open (1,4,3,0,13);
49
82
       
50
83
        RunUserInterface ();
51
84
        DiscardPanel (ph);
52
85
        DiscardPanel (p2);
-
 
86
        DiscardPanel (p3);
-
 
87
        DiscardPanel (p4);
53
88
        CmtDiscardThreadPool (poolHandle);
-
 
89
#ifdef MIKRO    
54
90
        MIKRO_Close ();
-
 
91
#endif  
55
92
        return 0;
56
93
}
57
94
 
58
95
 
59
96
char strbuf[0xFF];
Line 90... Line 127...
90
127
        DRSSetTimeout();
91
128
}
92
129
 
93
130
 
94
131
 
-
 
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 ;
-
 
137
 
-
 
138
}
95
139
 
96
140
void CVICALLBACK EndOfThread ( CmtThreadPoolHandle poolhandle,
97
141
                                                                                                                         CmtThreadFunctionID functionID, unsigned int event,
98
142
                                                                                                                         int value, void *callbackData  ) {
99
143
 
Line 104... Line 148...
104
148
 
105
149
}
106
150
 
107
151
 
108
152
static float xs[4][1024];      
-
 
153
 
109
154
int CVICALLBACK daq(void *functionData) {
110
155
 
111
156
 
112
157
        int neve;
113
158
        char filename[0xff];
114
159
        int imask[4];
Line 124... Line 169...
124
169
        int pfreq;
125
170
        int enabledoutput;
126
171
        int neveold = 0;
127
172
        double rate;
128
173
        int *args =  (int *) functionData;
129
-
 
130
174
 
131
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 };
132
179
 
133
180
        GetCtrlVal(ph, PANEL_CH0, &imask[0] );
134
181
        GetCtrlVal(ph, PANEL_CH1, &imask[1]  );
135
182
        GetCtrlVal(ph, PANEL_CH2, &imask[2]  );
136
183
        GetCtrlVal(ph, PANEL_CH3, &imask[3]  );
-
 
184
        GetCtrlVal(p3, QDC_WFM, &wfm  );  
137
185
        mask = 0;
138
186
        for (int i=0; i<4; i++) {
-
 
187
                if (imask[i]) {
139
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
                }      
140
193
        }
141
-
 
-
 
194
        LogScaleCB(p3, QDC_LOGY,EVENT_COMMIT,NULL, 0,0);      
142
195
 
143
196
               
144
197
        GetCtrlVal(ph,PANEL_NEVE, &neve);
145
198
        GetCtrlVal(ph,PANEL_DEBUG, &verbose);
146
199
        GetCtrlVal(ph,PANEL_PFREQ, &pfreq);
147
200
        GetCtrlVal(ph,PANEL_ENABLEDOUTPUT, &enabledoutput);
148
201
 
149
202
        GetCtrlVal(ph,PANEL_FREQUENCY, &frequency);
150
203
        GetCtrlVal(ph,PANEL_TRGDELAY, &trgdelay);
151
204
        GetCtrlVal(ph,PANEL_TRGCHANNEL, &trgchannel);
152
205
 
153
206
       
154
207
        GetCtrlVal(ph,PANEL_TRGTYPE, &trgtype);
155
208
        GetCtrlVal(ph,PANEL_TRGLEVEL, &trglevel);
156
209
        GetCtrlVal(ph,PANEL_TRGPOLARITY, &trgpolarity);
157
210
        GetCtrlVal(ph,PANEL_RANGE, &range);
158
211
 
159
-
 
160
-
 
-
 
212
       
161
213
        //printf("mask=0x%x\n",mask);
162
214
 
163
215
        DRSSetMask( (unsigned char)( mask & 0xF ) );
164
216
 
165
217
        DRSSetFrequency( frequency  );
166
218
        DRSSetTriggerDelay(trgdelay );
167
219
        DRSSetTriggerChannel(trgchannel );
168
220
        DRSSetTriggerType( trgtype );
169
221
        DRSSetTriggerLevel(trglevel);
170
222
        DRSSetTriggerPolarity(trgpolarity);
171
223
 
172
224
        DRSSetRange (  range );
173
225
 
174
226
 
175
227
 
176
228
        FILE *fp= NULL;
177
229
 
178
230
        if (enabledoutput) {
179
231
                if (1==1) {
180
232
                        GetCtrlVal(ph, PANEL_FILENAME, filename );  
-
 
233
                        printf("%s\n", filename);
181
234
                        fp =  fopen(filename,"wb");
182
235
          } else {
183
236
                        GetCtrlVal(p2, SCAN_FILENAME, filename );  
184
237
                        fp =  fopen(filename,"ab");
-
 
238
                        printf("%s\n", filename);
185
239
                }      
186
240
        }
187
241
 
188
242
        static unsigned char *buffer;
189
243
 
190
244
        int buffer_size = 0;
191
245
        const int nBoards=1;
192
246
        const int waveDepth=1024;
193
247
 
194
248
        if (buffer_size == 0) {
Line 217... Line 271...
217
271
                        if (retval) i--;
218
272
                        nev++;
219
273
                        if (!daq_on) break;
220
274
                        time(&t);
221
275
                        if (t!=told ) {
-
 
276
                                PlotQdcHistogramCB(0,0,EVENT_COMMIT,NULL, 0,0);
222
277
                                rate =  (i-neveold);
223
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));
224
279
                                GetCtrlVal(ph,PANEL_PFREQ, &pfreq);
225
280
                                neveold = i;
226
281
                        }
227
282
                        told=t;
228
283
// Save data
-
 
284
                       
229
285
                        if (nb>0 && fp) fwrite(buffer, 1,nb ,fp);
230
286
// Plot Data
-
 
287
                       
231
288
                         for (int k=0; k<4; k++) {
232
289
                                        if ( (mask & ( 0x1<<k ))  ){
-
 
290
                                                double fSum= 0;
233
291
                                          float *t=DRSGetTime(k);
234
292
                                          float *x=DRSGetWave(k);
235
293
                                                                 ;
236
294
                                          for (int j=0 ; j<1024 ; j++) {
237
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;
238
313
                                               
239
-
 
240
-
 
241
-
 
242
-
 
243
-
 
244
314
                                          if (i % pfreq == 0) {
245
-
 
246
315
                                            const int col[4]= {VAL_WHITE,VAL_RED,VAL_GREEN,VAL_BLUE};
247
316
                                          if (plothandle[k])    DeleteGraphPlot (ph, PANEL_GRAPH, plothandle[k], VAL_IMMEDIATE_DRAW);
248
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]);
249
318
                                          }    
250
319
                                        }
251
320
                                       
252
321
                                }
253
322
 
254
323
 
255
324
                }
256
325
                time(&t);
257
326
                printf("%d events in %2.2f min (%d s) %s",nev, (double)(t-tstart)/60.,t-tstart, ctime(&t));
258
327
                DRSEnd();
259
328
        }
260
329
 
261
330
        if (fp) fclose(fp);
262
331
 
263
332
        free(buffer);
-
 
333
 
-
 
334
        return 0;
-
 
335
 
-
 
336
}
-
 
337
 
-
 
338
 
-
 
339
void CVICALLBACK EndOfThrScan ( CmtThreadPoolHandle poolhandle,
-
 
340
                                                                                                                         CmtThreadFunctionID functionID, unsigned int event,
-
 
341
                                                                                                                         int value, void *callbackData  ) {
-
 
342
 
-
 
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
        }                                                                                                      
264
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];
-
 
579
                        if (fp) {
-
 
580
                                int k=0;
-
 
581
                                while (fgets(line,ndim,fp)!=NULL) {
-
 
582
                                        k++;
-
 
583
                                        sscanf(line,"%*s%d%f%f",&temp,&I,&V);
-
 
584
                                        printf("%d %f %f\n", temp, I, V);
-
 
585
                                  SetTableCellVal (ph, PANEL_TABLE, MakePoint (1,k), (double)temp);
-
 
586
                                        SetTableCellVal (ph, PANEL_TABLE, MakePoint (2,k), V);  
-
 
587
                               
-
 
588
                                }
-
 
589
 
-
 
590
                                SetTableCellVal (ph, PANEL_TABLE, MakePoint (1,k+1), 1000.0);
-
 
591
                                fclose(fp);
-
 
592
 
-
 
593
 
-
 
594
                        }
-
 
595
                        break;
-
 
596
                }
-
 
597
        }
265
598
        return 0;
266
-
 
267
599
}
-
 
600
 
268
601
 
269
602
 
270
603
 
271
604
int CVICALLBACK scan(void *functionData) {
272
605
 
Line 368... Line 701...
368
701
                if (!daq_on) break;
369
702
        }
370
703
 
371
704
        return 0;
372
705
}
-
 
706
 
-
 
707
 
373
708
 
374
709
 
375
710
int CVICALLBACK StartCB (int panel, int control, int event,
376
711
                                                                                                 void *callbackData, int eventData1, int eventData2) {
377
712
        ThreadFunctionPtr mythread = NULL;
Line 383... Line 718...
383
718
                        if (panel == ph && control == PANEL_START) {
384
719
                                mythread = daq;
385
720
                                controlID= control;
386
721
                        }
387
722
                        if (panel == p2 && control == SCAN_SCAN)   mythread = scan;
-
 
723
                        if (panel == p4 && control == SCALER_START)   mythread = thrscan;
-
 
724
                        if (panel == ph && control == PANEL_ACQUIRE)   {
-
 
725
                                mythread = acquire_data;
-
 
726
                                controlID=50;
-
 
727
                        }      
-
 
728
                       
388
729
                        if (mythread!=NULL) {
389
730
                                printf("New Thread panel=%d button=%d\n", panel, control);
390
731
 
391
732
                                // SetDimming(1);
392
733
 
Line 531... Line 872...
531
872
532
873
533
874
534
875
535
876
-
 
877
-
 
878
-
 
879
-
 
880
-
 
881
-
 
882
-
 
883
-
 
884
-
 
885
-
 
886
-
 
887
-
 
888
-
 
889
-
 
890
-
 
891
-
 
892
-
 
893
-
 
894
-
 
895
-
 
896
-
 
897
-
 
898
-
 
899
-
 
900
-
 
901
-
 
902
-
 
903
-
 
904
-
 
905
-
 
906
-
 
907
-
 
908
-
 
909
-
 
910
-
 
911
-
 
912
-
 
913
-
 
914
-
 
915
-
 
916
-
 
917
-
 
918
-
 
919
-
 
920
-
 
921
-
 
922
-
 
923
-
 
924
-
 
925
-
 
926
-
 
927
-
 
928
-
 
929
-
 
930
-
 
931
536
932
537
933
538
934
539
935
540
936
541
937
542
938
543
939
544
940
545
941
546
942
547
943
548
944
Line 555... Line 951...
555
951
556
952
557
953
558
954
559
955
560
956
-
 
957
-
 
958
-
 
959
-
 
960
-
 
961
-
 
962
-
 
963
-
 
964
-
 
965
-
 
966
-
 
967
561
968
562
969
563
970
564
971
-
 
972
565
973
566
974
567
975
568
976
569
977
570
978
571
979
572
980
573
981
574
982
-
 
983
575
984
576
985
577
986
578
987
579
988
580
989
581
990
582
991
583
992
584
993
585
994
-
 
995
-
 
996
-
 
997
-
 
998
-
 
999
-
 
1000
-
 
1001
-
 
1002
-
 
1003
-
 
1004
-
 
1005
-
 
1006
-
 
1007
-
 
1008
-
 
1009
-
 
1010
-
 
1011
-
 
1012
-
 
1013
-
 
1014
-
 
1015
-
 
1016
-
 
1017
-
 
1018
-
 
1019
-
 
1020
-
 
1021
-
 
1022
-
 
1023
-
 
1024
-
 
1025
-
 
1026
-
 
1027
-
 
1028
-
 
1029
-
 
1030
-
 
1031
-
 
1032
-
 
1033
-
 
1034
-
 
1035
-
 
1036
-
 
1037
-
 
1038
-
 
1039
-
 
1040
-
 
1041
-
 
1042
-
 
1043
-
 
1044
-
 
1045
-
 
1046
-
 
1047
-
 
1048
-
 
1049
-
 
1050
-
 
1051
-
 
1052
-
 
1053
-
 
1054
-
 
1055
-
 
1056
-
 
1057
-
 
1058
-
 
1059
-
 
1060
-
 
1061
-
 
1062
-
 
1063
-
 
1064
-
 
1065
-
 
1066
-
 
1067
-
 
1068
-
 
1069
-
 
1070
-
 
1071
-
 
1072
-
 
1073
-
 
1074
-
 
1075
-
 
1076
-
 
1077
-
 
1078
-
 
1079
-
 
1080
-
 
1081
-
 
1082
-
 
1083
-
 
1084
-
 
1085
-
 
1086
-
 
1087
-
 
1088
-
 
1089
-
 
1090
-
 
1091
-
 
1092
-
 
1093
-
 
1094
-
 
1095
-
 
1096
-
 
1097
-
 
1098
-
 
1099
-
 
1100
-
 
1101
-
 
1102
-
 
1103
-
 
1104
-
 
1105
-
 
1106
-
 
1107
-
 
1108
-
 
1109
-
 
1110
-
 
1111
-
 
1112
-
 
1113
-
 
1114
-
 
1115
-
 
1116
-
 
1117
-
 
1118
-
 
1119
-
 
1120
-
 
1121
-
 
1122
-
 
1123
-
 
1124
-
 
1125
-
 
1126
-
 
1127
-
 
1128
-
 
1129
-
 
1130
-
 
1131
-
 
1132
-
 
1133
-
 
1134
-
 
1135
-
 
1136
-
 
1137
-
 
1138
-
 
1139
-
 
1140
-
 
1141
-
 
1142
-
 
1143
-
 
1144
-
 
1145
-
 
1146
-
 
1147
-
 
1148
-
 
1149
-
 
1150
-
 
1151
-
 
1152
-
 
1153
586
1154