Subversion Repositories f9daq

Rev

Rev 33 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33 Rev 34
Line 12... Line 12...
12
#  ifdef WIENVME
12
#  ifdef WIENVME
13
#    include "wienvme_dll.h"
13
#    include "wienvme_dll.h"
14
#  endif
14
#  endif
15
# include "CAENV673A.h" 
15
# include "CAENV673A.h" 
16
# include "CAENV462.h" 
16
# include "CAENV462.h"
-
 
17
 
17
#endif
18
#endif
18
 
19
 
19
#ifdef USE_MIKRO
20
#ifdef USE_MIKRO
20
#  include "MIKRO.h"
21
#  include "MIKRO.h"
21
#endif
22
#endif
22
 
23
 
23
#include <userint.h>
24
#include <userint.h>
24
#include <ansi_c.h>
25
#include <ansi_c.h>
25
#include <utility.h>
26
#include <utility.h>
26
#include <analysis.h>
27
#include <analysis.h>
27
 
28
 
28
#include "c:\HOME\dino\sipmScan\include\sipmBias_ui.h"
29
#include "c:\HOME\dino\sipmScan\include\sipmBias_ui.h"
29
 
30
 
30
#ifdef USE_DAQ
31
#ifdef USE_DAQ
31
#  define USE_CAMAC
32
#  define USE_CAMAC
32
#  include "camac.h"
33
#  include "camac.h"
-
 
34
#  define NDAC 1 // CAEN C221
-
 
35
#    define ASD8 0 // channels
-
 
36
#    define AMPDISSH 1
33
#  define NDAC 1
37
#    define SIPM 2
34
 
-
 
35
#  define CAEN_V673A   0x22220000 // IJS
38
#  define CAEN_V673A   0x22220000 // IJS
36
//#define CAEN_V673A   0x10110000 // FMF
39
//#define CAEN_V673A   0x10110000 // FMF
37
#  define CAEN_V462    0x100300
40
#  define CAEN_V462    0x100300
38
#endif
41
#endif
39
 
42
 
Line 51... Line 54...
51
#define MAX_THREADS 10
54
#define MAX_THREADS 10
52
 
55
 
53
#define IWAIT 200
56
#define IWAIT 200
54
 
57
 
55
#define NCH 64
58
#define NCH 64
-
 
59
#define POWERSUPPLY 66 // Power supply voltage for SiPM bias
56
 
60
 
57
static int p1h, pID, rID, tfID;
61
static int p1h, pID, rID, tfID;
58
static int ph_tdc, ph_adc;
62
static int ph_tdc, ph_adc;
59
static int dtdc[NCH][2][MAXCH];
63
static int dtdc[NCH][2][MAXCH];
60
static int something[NCH][2][MAXCH];
64
static int something[NCH][2][MAXCH];
Line 141... Line 145...
141
  #define RUNREC_ID 1
145
  #define  RUNREC_ID 1
142
  #define ENDREC_ID 2
146
  #define  ENDREC_ID 2
143
  #define POSREC_ID 3
147
  #define  POSREC_ID 3
144
  #define EVTREC_ID 4
148
  #define  EVTREC_ID 4
145
  #define THRREC_ID 5
149
  #define  THRREC_ID 5
-
 
150
  #define BIASREC_ID 6
146
 
151
 
147
  typedef struct {
152
  typedef struct {
148
    unsigned long id,len;
153
    unsigned long id,len;
149
    unsigned long fver,time;
154
    unsigned long fver,time;
-
 
155
    unsigned long thLow, thUp, thStep;
-
 
156
    unsigned long biasLow, biasUp, biasStep;
150
    unsigned long nev,nch,ped,xy;
157
    unsigned long nev,nch,ped,xy;
151
    long nx,x0,dx,ny,y0,dy;
158
    long nx,x0,dx,ny,y0,dy;
152
    } RUNREC;
159
    } RUNREC;
153
        RUNREC runrec;
160
        RUNREC runrec;
154
       
161
       
155
  typedef struct {
162
  typedef struct {
156
    unsigned long id,len;
163
    unsigned long id,len;
157
    unsigned long time;
164
    unsigned long time;
158
    } ENDREC;
165
    } ENDREC;
159
        ENDREC endrec;
166
        ENDREC endrec;
160
       
167
       
161
  typedef struct {
168
  typedef struct {
162
    unsigned long id,len;
169
    unsigned long id,len;
163
    unsigned long time;
170
    unsigned long time;
164
    long ix,x,xset,iy,y,yset;
171
    long ix,x,xset,iy,y,yset;
165
    } POSREC;
172
    } POSREC;
166
        POSREC posrec;
173
        POSREC posrec;
167
 
174
 
168
  typedef struct {
175
  typedef struct {
169
    unsigned long id,len;
176
    unsigned long id,len;
170
    unsigned long nev;
177
    unsigned long nev;
171
    //unsigned short data[NCH];
178
    //unsigned short data[NCH];
172
    } EVTREC;
179
    } EVTREC;
173
        EVTREC evtrec;
180
        EVTREC evtrec;
174
       
181
       
175
  typedef struct {
182
  typedef struct {
176
        unsigned long id;
183
        unsigned long id;
177
        unsigned long len;
184
        unsigned long len;
178
        unsigned long thLow, thUp, thStep;
-
 
179
        unsigned long threshold;
185
        unsigned long threshold;
180
        } THRREC;
186
        } THRREC;
181
  THRREC thrrec;
187
  THRREC thrrec;
-
 
188
 
-
 
189
  typedef struct {
-
 
190
        unsigned long id;
-
 
191
        unsigned long len;
-
 
192
        unsigned long bias;
-
 
193
        } BIASREC;
-
 
194
  BIASREC biasrec;
182
       
195
       
183
        double thresholdLow;
196
        double thresholdLow;
184
        double thresholdUp;
197
        double thresholdUp;
185
        double thresholdStep;
198
        double thresholdStep;
-
 
199
        double biasLow;
-
 
200
        double biasUp;
-
 
201
        double biasStep;
186
 
202
 
187
#define BSIZE 20000
203
#define BSIZE 20000
188
       
204
       
189
        int maxn = BSIZE-4; // 2 words x 2 headers
205
        int maxn = BSIZE-4; // 2 words x 2 headers
190
        int tdcdata, edge_type, overflow, tdc_num, channel, ev_dat, last_dat, nval_dat;
206
        int tdcdata, edge_type, overflow, tdc_num, channel, ev_dat, last_dat, nval_dat;
Line 203... Line 219...
203
        posrec.len = sizeof(posrec);
219
        posrec.len = sizeof(posrec);
204
        evtrec.id = EVTREC_ID;
220
        evtrec.id = EVTREC_ID;
205
        evtrec.len = sizeof(evtrec);
221
        evtrec.len = sizeof(evtrec);
206
        thrrec.id = THRREC_ID;
222
        thrrec.id = THRREC_ID;
207
        thrrec.len = sizeof(thrrec);
223
        thrrec.len = sizeof(thrrec);
-
 
224
        biasrec.id = BIASREC_ID;
-
 
225
        biasrec.len = sizeof(biasrec);
208
       
226
       
209
       
227
       
210
        cres = 0;
228
        cres = 0;
211
       
229
       
212
        GetCtrlVal (p1h, P1_NEVE, &runrec.nev);
230
        GetCtrlVal (p1h, P1_NEVE, &runrec.nev);
Line 239... Line 257...
239
        if (supr0) {
257
        if (supr0) {
240
          GetCtrlVal (p1h, P1_TDCMIN, &tdcmin);
258
          GetCtrlVal (p1h, P1_TDCMIN, &tdcmin);
241
          GetCtrlVal (p1h, P1_FRAC, &frac);
259
          GetCtrlVal (p1h, P1_FRAC, &frac);
242
        }
260
        }
243
       
261
       
244
        GetCtrlVal (p1h, P1_STHRLOW, &thresholdLow);
262
        GetCtrlVal (p1h, P1_SASD8THR, &thresholdLow);
245
        runrec.thLow = thresholdLow*1000; // mV
263
        runrec.thLow = thresholdLow*1000; // mV
246
        GetCtrlVal (p1h, P1_STHRUP, &thresholdUp);
264
        GetCtrlVal (p1h, P1_STHRUP, &thresholdUp);
247
        runrec.thUp = thresholdUp*1000; // mV
265
        runrec.thUp = thresholdUp*1000; // mV
248
        GetCtrlVal (p1h, P1_STEP, &thresholdStep);
266
        GetCtrlVal (p1h, P1_STEP, &thresholdStep);
249
        runrec.thStep = thresholdStep*1000; // mV
267
        runrec.thStep = thresholdStep*1000; // mV
250
       
268
       
-
 
269
        GetCtrlVal (p1h, P1_SBIAS, &biasLow);
-
 
270
        GetCtrlVal (p1h, P1_SBIASUP, &biasUp);
-
 
271
        GetCtrlVal (p1h, P1_SBIASSTEP, &biasStep);
-
 
272
        runrec.biasLow  = biasLow*1000;
-
 
273
        runrec.biasUp   = biasUp*1000;
-
 
274
        runrec.biasStep = biasStep*1000;
251
 
275
 
252
#ifdef USE_DAQ
276
#ifdef USE_DAQ
253
        V673A_map(0,CAEN_V673A,0);
277
        V673A_map(0,CAEN_V673A,0);
254
        V673A_init(0);
278
        V673A_init(0);
255
 
279
 
Line 267... Line 291...
267
        if (supr0) {
291
        if (supr0) {
268
          fseed = runrec.time & 0x7fffffff;
292
          fseed = runrec.time & 0x7fffffff;
269
          Uniform (1, fseed, &fracg);
293
          Uniform (1, fseed, &fracg);
270
        }
294
        }
271
       
295
 
-
 
296
  // Set SiPM bias voltage
-
 
297
  //SetDac(SIPM, 1.0);
-
 
298
  biasrec.bias = runrec.biasLow;
-
 
299
  while (biasrec.bias <= runrec.biasUp) {
-
 
300
        SetDac(SIPM, biasrec.bias/1000.0 - POWERSUPPLY);
-
 
301
        SetCtrlVal(p1h, P1_SBIAS, biasrec.bias/1000.0);
-
 
302
        status = fwrite(&biasrec, 1, biasrec.len, fp);
-
 
303
        if (print) printf("BIASREC status %d len %d bias %d\n", status, biasrec.len, biasrec.bias);
-
 
304
 
-
 
305
  // Set ASD threshold voltage
272
  thrrec.threshold = (unsigned long) ceil(thresholdLow*1000); // threshold in mV
306
  thrrec.threshold = (unsigned long) ceil(thresholdLow*1000); // threshold in mV
273
  while (thrrec.threshold <= thresholdUp*1000) {
307
  while (thrrec.threshold <= thresholdUp*1000) {
274
    SetDac(0, thrrec.threshold/1000.0);
308
    SetDac(ASD8, thrrec.threshold/1000.0);
275
        SetCtrlVal(p1h, P1_STHRLOW, thrrec.threshold/1000.0);
309
        SetCtrlVal(p1h, P1_SASD8THR, thrrec.threshold/1000.0);
276
    //wait_loop(100000);
-
 
277
    status = fwrite(&thrrec, 1, thrrec.len, fp);
310
    status = fwrite(&thrrec, 1, thrrec.len, fp);
278
    if (print) printf("THRREC status %d len %d threshold %d\n", status, thrrec.len, thrrec.threshold);
311
    if (print) printf("THRREC status %d len %d threshold %d\n", status, thrrec.len, thrrec.threshold);
279
   
312
   
280
  for (posrec.ix=0; posrec.ix<runrec.nx; posrec.ix++) {
313
  for (posrec.ix=0; posrec.ix<runrec.nx; posrec.ix++) {
281
                posrec.xset = runrec.x0 + posrec.ix*runrec.dx;
314
                posrec.xset = runrec.x0 + posrec.ix*runrec.dx;
Line 309... Line 342...
309
      if (fmax && (ftell(fp) > fmax)) {
342
      if (fmax && (ftell(fp) > fmax)) {
310
        fcount+=1;
343
        fcount+=1;
311
        sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
344
        sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
312
        fclose(fp);
345
        fclose(fp);
313
        fp = fopen (dfile, "wb");
346
        fp = fopen (dfile, "wb");
314
      }
347
      }
315
         
348
         
316
      time (&posrec.time);
349
      time (&posrec.time);
317
            status = fwrite (&posrec, 1, posrec.len, fp);
350
            status = fwrite (&posrec, 1, posrec.len, fp);
318
            if (print) printf("POSREC status %d len %d\n", status, posrec.len);
351
            if (print) printf("POSREC status %d len %d\n", status, posrec.len);
319
                  //}
352
                  //}
320
                 
353
                 
Line 334... Line 367...
334
      do {
367
      do {
335
        unsigned long word[BSIZE];
368
        unsigned long word[BSIZE];
336
            count=0;
369
            count=0;
337
            ntics=0;
370
            ntics=0;
338
            if (print) printf("Event counter: %d\n", evtrec.nev);
371
            if (print) printf("Event counter: %d\n", evtrec.nev);
339
           
372
           
340
                //if (t!=told ) printf("%d in %2.2f min daq::event() %s\n",i, (double)(t-tstart)/60., ctime(&t)); 
373
                //if (t!=told ) printf("%d in %2.2f min daq::event() %s\n",i, (double)(t-tstart)/60., ctime(&t)); 
341
             
374
             
342
#ifdef USE_DAQ
375
#ifdef USE_DAQ
343
#ifdef CAEN_V673A
376
#ifdef CAEN_V673A
344
 
377
 
Line 352... Line 385...
352
        //if (timer_out) {
385
        //if (timer_out) {
353
        //   fprintf(stderr,"-----------------> V673a timeout !!!\n");
386
        //   fprintf(stderr,"-----------------> V673a timeout !!!\n");
354
        //   V673A_clallb(0); 
387
        //   V673A_clallb(0); 
355
        //   continue;
388
        //   continue;
356
        //}
389
        //}
357
     
390
     
358
        if (ntics>=2) {
391
        if (ntics>=2) {
359
           fprintf(stderr,"-----------------> V673a timeout !!!\n");
392
           fprintf(stderr,"-----------------> V673a timeout !!!\n");
360
           printf("Timer tics %d\n", ntics);
393
           printf("Timer tics %d\n", ntics);
361
           ntics = 0;
394
           ntics = 0;
362
           evtrec.nev--;
395
           evtrec.nev--;
Line 371... Line 404...
371
            else          len = V673A_read0 (0, &word[count+2],maxn-count-2);
404
            else          len = V673A_read0 (0, &word[count+2],maxn-count-2);
372
         
405
         
373
            if (len>16*32*4){
406
            if (len>16*32*4){
374
              if (print) printf("Length > 2048 per chip!\n");
407
              if (print) printf("Length > 2048 per chip!\n");
375
              chip=2;
408
              chip=2;
376
              V673A_clallb(0);
409
              V673A_clallb(0);
377
              evtrec.nev--;
410
              evtrec.nev--;
378
              continue;
411
              continue;
379
            }
412
            }
380
            pdata=&word[count+2];
413
            pdata=&word[count+2];
381
            for(i=0;i< len;i++){
414
            for(i=0;i< len;i++){
Line 410... Line 443...
410
          evtrec.nev--;
443
          evtrec.nev--;
411
          continue;
444
          continue;
412
        }
445
        }
413
       
446
       
414
        V673A_clallb(0);
447
        V673A_clallb(0);
415
#endif
448
#endif
416
#endif
449
#endif
417
       
450
       
418
 
451
 
419
        GetCtrlVal(p1h, P1_ADCHLSAVE, &runrec.xy);
452
        GetCtrlVal(p1h, P1_ADCHLSAVE, &runrec.xy);
420
        evtrec.len = count*sizeof(unsigned long) + sizeof(evtrec);
453
        evtrec.len = count*sizeof(unsigned long) + sizeof(evtrec);
421
        if (print) printf("EVTREC.len = %d bytes.\n", evtrec.len);
454
        if (print) printf("EVTREC.len = %d bytes.\n", evtrec.len);
422
       
455
       
423
        status = fwrite (&evtrec, 1, sizeof(evtrec), fp);
456
        status = fwrite (&evtrec, 1, sizeof(evtrec), fp);
424
        status = fwrite (&word, 1, count*sizeof(unsigned long), fp);
457
        status = fwrite (&word, 1, count*sizeof(unsigned long), fp);
Line 432... Line 465...
432
                      status = fwrite (&endrec, 1, endrec.len, fp);
465
                      status = fwrite (&endrec, 1, endrec.len, fp);
433
              fcount+=1;
466
              fcount+=1;
434
                  sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
467
                  sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
435
                  fclose(fp);
468
                  fclose(fp);
436
                  fp = fopen (dfile, "wb");
469
                  fp = fopen (dfile, "wb");
437
            }
470
            }
438
        }
471
        }
439
         
472
         
440
        if(step_minutes > 0) {
473
        if(step_minutes > 0) {
441
                                  GetSystemTime(&start_hours, &start_minutes, &start_seconds);
474
                                  GetSystemTime(&start_hours, &start_minutes, &start_seconds);
442
                                  //cur_time_s = start_hours*3600 + start_minutes*60 + start_seconds;
475
                                  //cur_time_s = start_hours*3600 + start_minutes*60 + start_seconds;
443
                                  time(&cur_time_s);
476
                                  time(&cur_time_s);
444
                                  if(cur_time_s >= end_time_s) {
477
                                  if(cur_time_s >= end_time_s) {
445
                                          end_time_s = cur_time_s + step_minutes*60;
478
                                          end_time_s = cur_time_s + step_minutes*60;
446
                                          printf("STEP (nev):%2d-%2d-%2d @ %d\n", start_hours, start_minutes, start_seconds, posrec.xset);
479
                                          printf("STEP (nev):%2d-%2d-%2d @ %d\n", start_hours, start_minutes, start_seconds, posrec.xset);
447
                        break;
480
                        break;
448
                }
481
                }
449
        }
482
        }
450
        //told=t;
483
        //told=t;
451
       
484
       
452
        GetCtrlVal(p1h, P1_DAQ, &daq_on);
485
        GetCtrlVal(p1h, P1_DAQ, &daq_on);
453
         
486
         
454
            } while (evtrec.nev++<runrec.nev && daq_on);
487
            } while (evtrec.nev++<runrec.nev && daq_on);
455
            if (!daq_on) break;
488
            if (!daq_on) break;
456
          } // x loop
489
          } // x loop
457
          if (!daq_on) break;
490
          if (!daq_on) break;
458
        } // y loop
491
        } // y loop
459
        if (!daq_on) break;
492
        if (!daq_on) break;
460
        thrrec.threshold += thresholdStep*1000;
493
        thrrec.threshold += thresholdStep*1000;
461
        } // threhsold loop
494
        } // threhsold loop
-
 
495
        if (!daq_on) break;
-
 
496
        biasrec.bias += runrec.biasStep;
-
 
497
        } // bias loop
-
 
498
       
-
 
499
        SetDac(SIPM, 0); // safety
462
       
500
       
463
  //if (dsave) {
501
  //if (dsave) {
464
    time (&endrec.time);
502
    time (&endrec.time);
465
    status = fwrite (&endrec, 1, endrec.len, fp);
503
    status = fwrite (&endrec, 1, endrec.len, fp);
466
    if (print) printf("ENDREC status %d len %d\n", status, endrec.len);
504
    if (print) printf("ENDREC status %d len %d\n", status, endrec.len);
Line 473... Line 511...
473
    daq_on=0;  
511
    daq_on=0;  
474
        SetCtrlVal (p1h, P1_DAQ, daq_on);
512
        SetCtrlVal (p1h, P1_DAQ, daq_on);
475
        SetCtrlVal (p1h, P1_CEVE, evtrec.nev);
513
        SetCtrlVal (p1h, P1_CEVE, evtrec.nev);
476
        if (print) printf("RUN END. \n\n");
514
        if (print) printf("RUN END. \n\n");
477
 
515
 
478
        return 0;
516
        return 0;
479
}
517
}
480
 
518
 
481
 
519
 
482
int SetDac(int ch, double val){
520
int SetDac(int ch, double val){
483
       
521
       
484
        const unsigned int maxdac=0xFFF;
522
        const unsigned int maxdac=0xFFF;
485
        const double RANGE = +9.9976; //V
523
        const double RANGE = +9.9976; //V
Line 492... Line 530...
492
       
530
       
493
        dac = (val/RANGE)*maxdac;
531
        dac = (val/RANGE)*maxdac;
494
        CSSA_W(NDAC,ch,16,&dac);
532
        CSSA_W(NDAC,ch,16,&dac);
495
        printf("DAC ch %d set to %f V dac=%d\n", ch, val, dac);
533
        printf("DAC ch %d set to %f V dac=%d\n", ch, val, dac);
496
        return 0;
534
        return 0;
497
}
535
}
498
 
536
 
499
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
537
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
500
                       LPSTR lpszCmdLine, int nCmdShow)
538
                       LPSTR lpszCmdLine, int nCmdShow)
501
{
539
{
502
  int i,j,status,refon;
540
  int i,j,status,refon;
503
  long int xpos, ypos, zpos;
541
  long int xpos, ypos, zpos;
Line 522... Line 560...
522
  SetStdioWindowSize (200, 560);
560
  SetStdioWindowSize (200, 560);
523
  SetStdioWindowPosition (825, 250);
561
  SetStdioWindowPosition (825, 250);
524
 
562
 
525
#ifdef USE_DAQ
563
#ifdef USE_DAQ
526
  VME_START(NULL);
564
  VME_START(NULL);
527
#endif
565
#endif
528
 
566
 
529
#ifdef USE_MIKRO
567
#ifdef USE_MIKRO
530
  MIKRO_Open (MIKRO_COM);
568
  MIKRO_Open (MIKRO_COM);
531
  MIKRO_Init (MIKRO_X,0);
569
  MIKRO_Init (MIKRO_X,0);
532
#ifdef USE_MIKRO_Y
570
#ifdef USE_MIKRO_Y
533
  MIKRO_Init (MIKRO_Y,0);
571
  MIKRO_Init (MIKRO_Y,0);
534
#endif
572
#endif
535
#ifdef USE_MIKRO_Z
573
#ifdef USE_MIKRO_Z
536
  MIKRO_Init (MIKRO_Z,0);
574
  MIKRO_Init (MIKRO_Z,0);
537
#endif
575
#endif
538
#endif
576
#endif
539
 
577
 
540
  if ((p1h = LoadPanel (0, "include/sipmBias_ui.uir", P1)) < 0) return -1;
578
  if ((p1h = LoadPanel (0, "include/sipmBias_ui.uir", P1)) < 0) return -1;
541
  DisplayPanel (p1h);
579
  DisplayPanel (p1h);
542
  SetCtrlAttribute (p1h, P1_PLCH, ATTR_MAX_VALUE, NCH-1);
580
  SetCtrlAttribute (p1h, P1_PLCH, ATTR_MAX_VALUE, NCH-1);
543
 
581
 
Line 545... Line 583...
545
  SetCtrlVal(p1h, P1_ADCHL, runrec.xy-2);
583
  SetCtrlVal(p1h, P1_ADCHL, runrec.xy-2);
546
 
584
 
547
  QueueUserEvent (1000, p1h, P1_RESET);
585
  QueueUserEvent (1000, p1h, P1_RESET);
548
  //QueueUserEvent (1000, p1h, P1_ASD8THR);
586
  //QueueUserEvent (1000, p1h, P1_ASD8THR);
549
  QueueUserEvent (1000, p1h, P1_AMPDISSHTHR);
587
  QueueUserEvent (1000, p1h, P1_AMPDISSHTHR);
-
 
588
  QueueUserEvent (1000, p1h, P1_BIAS);
550
  do {
589
  do {
551
    GetUserEvent (1, &pID, &rID);
590
    GetUserEvent (1, &pID, &rID);
552
        switch (rID) {
591
        switch (rID) {
553
      case P1_TIMER:
592
      case P1_TIMER:
554
        ntics+=1;
593
        ntics+=1;
Line 572... Line 611...
572
          case P1_ZSET:
611
          case P1_ZSET:
573
            if (!daq_on) {
612
            if (!daq_on) {
574
              GetCtrlVal (p1h, P1_ZSET, &zpos);
613
              GetCtrlVal (p1h, P1_ZSET, &zpos);
575
#ifdef USE_MIKRO_Z
614
#ifdef USE_MIKRO_Z
576
          MIKRO_MoveTo (MIKRO_Z, zpos);
615
          MIKRO_MoveTo (MIKRO_Z, zpos);
577
#endif
616
#endif
578
        }
617
        }
579
            break;
618
            break;
580
          case P1_REREAD:
619
          case P1_REREAD:
581
            if (!daq_on) {
620
            if (!daq_on) {
582
          status = FileSelectPopup ("", "*.dat", ".dat",
621
          status = FileSelectPopup ("", "*.dat", ".dat",
583
                                    "Choose the previous file",
622
                                    "Choose the previous file",
Line 593... Line 632...
593
                          SetCtrlVal (p1h, P1_NY, runrec.ny);
632
                          SetCtrlVal (p1h, P1_NY, runrec.ny);
594
                          SetCtrlVal (p1h, P1_YSTEP, runrec.dy);
633
                          SetCtrlVal (p1h, P1_YSTEP, runrec.dy);
595
                          SetCtrlVal (p1h, P1_YMIN, runrec.y0);
634
                          SetCtrlVal (p1h, P1_YMIN, runrec.y0);
596
                          SetCtrlVal (p1h, P1_NEVE, runrec.nev);
635
                          SetCtrlVal (p1h, P1_NEVE, runrec.nev);
597
            }
636
            }
598
              }
637
              }
599
        }
638
        }
600
            break;
639
            break;
601
          case P1_MGET:
640
          case P1_MGET:
602
          #ifdef USE_MIKRO
641
          #ifdef USE_MIKRO
603
                MIKRO_GetPosition(MIKRO_X,&xpos);
642
                MIKRO_GetPosition(MIKRO_X,&xpos);
604
                Delay(0.01);
643
                Delay(0.01);
605
                SetCtrlVal (p1h, P1_X, xpos);  
644
                SetCtrlVal (p1h, P1_X, xpos);  
606
          #ifdef USE_MIKRO_Y    
645
          #ifdef USE_MIKRO_Y    
607
                MIKRO_GetPosition(MIKRO_Y,&ypos);
646
                MIKRO_GetPosition(MIKRO_Y,&ypos);
608
                Delay(0.01);
647
                Delay(0.01);
609
                SetCtrlVal (p1h, P1_Y, ypos);
648
                SetCtrlVal (p1h, P1_Y, ypos);
610
          #endif
649
          #endif
611
          #ifdef USE_MIKRO_Z    
650
          #ifdef USE_MIKRO_Z    
612
                MIKRO_GetPosition(MIKRO_Z,&zpos);
651
                MIKRO_GetPosition(MIKRO_Z,&zpos);
613
                Delay(0.01);
652
                Delay(0.01);
Line 624... Line 663...
624
                  MIKRO_ReferenceMove (MIKRO_Y);
663
                  MIKRO_ReferenceMove (MIKRO_Y);
625
                #endif
664
                #endif
626
                #ifdef USE_MIKRO_Z
665
                #ifdef USE_MIKRO_Z
627
                  MIKRO_ReferenceMove (MIKRO_Z);
666
                  MIKRO_ReferenceMove (MIKRO_Z);
628
                #endif
667
                #endif
629
#endif
668
#endif
630
                  SetWaitCursor (0);
669
                  SetWaitCursor (0);
631
            }
670
            }
632
            break;
671
            break;
633
          case P1_RESET:
672
          case P1_RESET:
634
        for (j=0;j<NCH;j++) {
673
        for (j=0;j<NCH;j++) {
635
          for (i=0;i<MAXCH;i++){
674
          for (i=0;i<MAXCH;i++){
636
            dtdc[j][0][i]=0;
675
            dtdc[j][0][i]=0;
637
            dtdc[j][1][i]=0;
676
            dtdc[j][1][i]=0;
638
           
677
           
639
          }
678
          }
640
        }
679
        }
641
                update_plots();
680
                update_plots();
642
            break;
681
            break;
643
          case P1_TDCLOG:
682
          case P1_TDCLOG:
Line 648... Line 687...
648
          case P1_ADCLOG:
687
          case P1_ADCLOG:
649
            GetCtrlVal (p1h, P1_ADCLOG, &status);
688
            GetCtrlVal (p1h, P1_ADCLOG, &status);
650
        SetCtrlAttribute (p1h, P1_ADC, ATTR_YMAP_MODE, status);
689
        SetCtrlAttribute (p1h, P1_ADC, ATTR_YMAP_MODE, status);
651
                update_plots();
690
                update_plots();
652
            break;
691
            break;
653
          /*case P1_ASD8THR:
692
          case P1_ASD8THR:
654
            {
693
            {
655
              double value;
694
              double value;
656
              GetCtrlVal (p1h, P1_SASD8THR, &value);
695
              GetCtrlVal (p1h, P1_SASD8THR, &value);
657
              SetDac(0, value);
696
              SetDac(ASD8, value);
658
             
697
             
659
            }
698
            }
660
            break;*/
699
            break;
-
 
700
          case P1_BIAS:
-
 
701
                {
-
 
702
                  double value;
-
 
703
                  GetCtrlVal (p1h, P1_SBIAS, &value);
-
 
704
                  value -= POWERSUPPLY;
-
 
705
                  SetDac(SIPM, value);
-
 
706
                }
-
 
707
                break;
661
          case P1_AMPDISSHTHR:
708
          case P1_AMPDISSHTHR:
662
            {
709
            {
663
              double value;
710
              double value;
664
              GetCtrlVal (p1h, P1_SAMPDISSHTHR, &value);
711
              GetCtrlVal (p1h, P1_SAMPDISSHTHR, &value);
665
              SetDac(1, value);
712
              SetDac(AMPDISSH, value);
666
 
713
 
667
            }  
714
            }  
668
            break;
715
            break;
669
             
716
             
670
        }
717
        }