24,6 → 24,8 |
#include <ansi_c.h> |
#include <utility.h> |
#include <analysis.h> |
#include <time.h> |
//#include <zlib.h> |
|
#include "c:\HOME\dino\sipmScan\include\sipmScan_ui.h" |
|
33,7 → 35,7 |
# define NDAC 1 |
# define ASD8 0 // channels |
# define AMPDISSH 1 |
# define SIPM 2 |
# define SIPM 15 |
//# define CAEN_V673A 0x10110000 // FMF |
# define CAEN_V673A 0x22220000 // IJS |
# define CAEN_V462 0x100300 |
40,7 → 42,7 |
#endif |
|
#ifdef USE_MIKRO |
# define MIKRO_COM 5 |
# define MIKRO_COM 3 |
# define MIKRO_X 1 |
# define USE_MIKRO_Y |
# define MIKRO_Y 2 |
49,7 → 51,7 |
# define STEP_TOLERANCE 1 |
#endif |
|
#define MAXCH 512 |
#define MAXCH 128 |
#define MAX_THREADS 10 |
|
#define IWAIT 200 |
66,6 → 68,9 |
static int poolHandle = 0; |
static int ntics,dummy; |
|
static int offsetX = 5600; |
static int offsetY = 5400; |
|
/************************************************************/ |
void wait_loop(unsigned long iloop) |
|
208,8 → 213,10 |
GetSystemTime(&start_hours, &start_minutes, &start_seconds); |
//cur_time_s = start_hours*3600 + start_minutes*60 + start_seconds; |
time(&cur_time_s); |
end_time_s = cur_time_s + step_minutes*60; |
printf("START:%2d-%2d-%2d (cur_time = %u s, end_time = %u s)\n", start_hours, start_minutes, start_seconds, cur_time_s, end_time_s); |
end_time_s = cur_time_s + (int) (runrec.nx * runrec.ny * runrec.nev/10000.0 * 4.5); // expected seconds |
printf("START:%2d-%2d-%2d (cur_time = %u s, end_time = %u s)\n", start_hours, start_minutes, start_seconds, cur_time_s, end_time_s); |
SetCtrlAttribute(p1h, P1_EXPTIME, ATTR_DIMMED, 0); |
SetCtrlVal(p1h, P1_EXPTIME, ctime(&end_time_s)); |
|
//GetCtrlVal (p1h, P1_DSAVE, &dsave); |
//if (dsave) { |
236,6 → 243,7 |
|
//if (dsave) { |
sprintf(dfile,"%s_file%02d.dat",dfile0,fcount); |
SetCtrlVal(p1h, P1_FCOUNT,fcount); |
|
fp = fopen (dfile, "wb"); |
time (&runrec.time); |
245,36 → 253,42 |
fseed = runrec.time & 0x7fffffff; |
Uniform (1, fseed, &fracg); |
} |
// vertical moving stage loop |
for (posrec.iy=0; posrec.iy<runrec.ny; posrec.iy++) { |
posrec.yset = runrec.y0 + posrec.iy*runrec.dy; |
#ifdef USE_MIKRO_Y |
if (print) printf("MIKRO_MoveTo (2, y);%d\n",posrec.yset); |
do { |
MIKRO_MoveTo (MIKRO_Y, offsetY + posrec.yset); |
MIKRO_GetPosition(MIKRO_Y, &mikroY); |
mikroY -= offsetY; |
if (print) printf("%d\n", abs(posrec.yset - mikroY)); |
} while (abs(posrec.yset - mikroY) > STEP_TOLERANCE); |
if (print) printf("->MIKRO_MoveTo (2, y);%d\n",posrec.yset); |
#endif |
posrec.yset = mikroY; |
SetCtrlVal (p1h, P1_Y, posrec.yset); |
SetCtrlVal (p1h, P1_IY, posrec.iy); |
|
for (posrec.ix=0; posrec.ix<runrec.nx; posrec.ix++) { |
posrec.xset = runrec.x0 + posrec.ix*runrec.dx; |
// horizontal moving stage loop |
for (posrec.ix=0; posrec.ix<runrec.nx; posrec.ix++) { |
posrec.xset = runrec.x0 + posrec.ix*runrec.dx; |
#ifdef USE_MIKRO |
do { |
if (print) printf("MIKRO_MoveTo (1, x);%d\n",posrec.xset); |
MIKRO_MoveTo (MIKRO_X, posrec.xset); |
MIKRO_MoveTo (MIKRO_X, offsetX + posrec.xset); |
MIKRO_GetPosition(MIKRO_X, &mikroX); |
mikroX -= offsetX; |
if (print) printf("%d\n", abs(posrec.xset - mikroX)); |
} while (abs(posrec.xset - mikroX) > STEP_TOLERANCE); |
#endif |
posrec.xset = mikroX; // true value |
posrec.xset = mikroX; // true value |
SetCtrlVal (p1h, P1_X, posrec.xset); |
SetCtrlVal (p1h, P1_IX, posrec.ix); |
for (posrec.iy=0; posrec.iy<runrec.ny; posrec.iy++) { |
posrec.yset = runrec.y0 + posrec.iy*runrec.dy; |
#ifdef USE_MIKRO_Y |
if (print) printf("MIKRO_MoveTo (2, y);%d\n",posrec.yset); |
do { |
MIKRO_MoveTo (MIKRO_Y, posrec.yset); |
MIKRO_GetPosition(MIKRO_Y, &mikroY); |
if (print) printf("%d\n", abs(posrec.yset - mikroY)); |
} while (abs(posrec.yset - mikroY) > STEP_TOLERANCE); |
if (print) printf("->MIKRO_MoveTo (2, y);%d\n",posrec.yset); |
#endif |
posrec.yset = mikroY; |
SetCtrlVal (p1h, P1_Y, posrec.yset); |
SetCtrlVal (p1h, P1_IY, posrec.iy); |
//if (dsave) { |
if (fmax && (ftell(fp) > fmax)) { |
|
|
//if (dsave) { |
if (fmax && (ftell(fp) > fmax)) { |
fcount+=1; |
sprintf(dfile,"%s_file%02d.dat",dfile0,fcount); |
fclose(fp); |
370,7 → 384,7 |
} else { |
if (ntrig==0) { |
fprintf(stderr,"-----------------> no trigger"); |
break; |
//break; |
} else { |
if (print) fprintf(stderr,"-----------------> wrong number of triggers in chips V673a !!!\n"); |
} |
398,6 → 412,7 |
status = fwrite (&endrec, 1, endrec.len, fp); |
fcount+=1; |
sprintf(dfile,"%s_file%02d.dat",dfile0,fcount); |
SetCtrlVal(p1h, P1_FCOUNT,fcount); |
fclose(fp); |
fp = fopen (dfile, "wb"); |
} |
419,9 → 434,9 |
|
} while (evtrec.nev++<runrec.nev && daq_on); |
if (!daq_on) break; |
} // x loop |
} // y loop |
if (!daq_on) break; |
} // y loop |
} // x loop |
|
//if (dsave) { |
time (&endrec.time); |
464,7 → 479,8 |
{ |
int i,j,status,refon; |
long int xpos, ypos, zpos; |
char dfile[300]; |
char dfile[512]; |
char message[256]; |
FILE *fp; |
|
typedef struct { |
504,6 → 520,9 |
DisplayPanel (p1h); |
SetCtrlAttribute (p1h, P1_PLCH, ATTR_MAX_VALUE, NCH-1); |
|
SetCtrlVal (p1h, P1_OFFSETX, offsetX); |
SetCtrlVal (p1h, P1_OFFSETY, offsetY); |
|
GetCtrlVal(p1h, P1_ADCHLSAVE, &runrec.xy); |
SetCtrlVal(p1h, P1_ADCHL, runrec.xy-2); |
|
511,6 → 530,8 |
QueueUserEvent (1000, p1h, P1_ASD8THR); |
QueueUserEvent (1000, p1h, P1_AMPDISSHTHR); |
QueueUserEvent (1000, p1h, P1_BIAS); |
QueueUserEvent (1000, p1h, P1_OFFSETX); |
QueueUserEvent (1000, p1h, P1_OFFSETY); |
|
printf("BIAS offset set to: %d\n", POWERSUPPLY); |
|
530,12 → 551,27 |
if (daq_on) { |
CmtScheduleThreadPoolFunction (poolHandle, daq_run, (void *)&dummy, &tfID); |
} else { |
CmtWaitForThreadPoolFunctionCompletion (poolHandle, tfID, |
OPT_TP_PROCESS_EVENTS_WHILE_WAITING); |
CmtWaitForThreadPoolFunctionCompletion (poolHandle, tfID, OPT_TP_PROCESS_EVENTS_WHILE_WAITING); |
CmtReleaseThreadPoolFunctionID (poolHandle, tfID); |
} |
break; |
|
case P1_XMIN: |
if (!daq_on) { |
GetCtrlVal (p1h, P1_XMIN, &xpos); |
//backlash |
MIKRO_MoveTo(MIKRO_X, xpos+offsetX-1000); |
Delay(0.01); |
MIKRO_MoveTo(MIKRO_X, xpos+offsetX); |
} |
break; |
case P1_YMIN: |
if (!daq_on) { |
GetCtrlVal(p1h, P1_YMIN, &ypos); |
MIKRO_MoveTo(MIKRO_Y, ypos+offsetY-1000); |
Delay(0.01); |
MIKRO_MoveTo(MIKRO_Y, ypos+offsetY); |
} |
break; |
case P1_ZSET: |
if (!daq_on) { |
GetCtrlVal (p1h, P1_ZSET, &zpos); |
569,11 → 605,11 |
#ifdef USE_MIKRO |
MIKRO_GetPosition(MIKRO_X,&xpos); |
Delay(0.01); |
SetCtrlVal (p1h, P1_X, xpos); |
SetCtrlVal (p1h, P1_X, xpos-offsetX); |
#ifdef USE_MIKRO_Y |
MIKRO_GetPosition(MIKRO_Y,&ypos); |
Delay(0.01); |
SetCtrlVal (p1h, P1_Y, ypos); |
SetCtrlVal (p1h, P1_Y, ypos-offsetY); |
#endif |
#ifdef USE_MIKRO_Z |
MIKRO_GetPosition(MIKRO_Z,&zpos); |
641,6 → 677,20 |
SetDac(SIPM, value); |
} |
break; |
// reset SiPM bias to initial power supply voltage |
case P1_BIASOFF: |
{ |
SetDac(SIPM, 0); |
SetCtrlVal(p1h, P1_SBIAS, (double) POWERSUPPLY); |
} |
case P1_OFFSETX: |
{ |
GetCtrlVal(p1h, P1_OFFSETX, &offsetX); |
} |
case P1_OFFSETY: |
{ |
GetCtrlVal(p1h, P1_OFFSETY, &offsetY); |
} |
|
} |
|