Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 341 → Rev 342

/Samo/l2d/camac.h
2,6 → 2,9
#define NAF(N,A,F) 0x810002+(N)*0x800+(A)*0x80+(F)*0x4
#define BRF(F) 0x80E802+(F)*0x4
 
#define VME_A24D16_R(VME,DATA) WIENVME_VME_A24D16_R((VME),(DATA))
#define VME_A24D16_W(VME,DATA) WIENVME_VME_A24D16_W((VME),(DATA))
 
#define CSSA_R(N,A,F,DATA) VME_A24D16_R((NAF((N),(A),(F))),(DATA))
#define CSSA_W(N,A,F,DATA) VME_A24D16_W((NAF((N),(A),(F))),(DATA))
 
/Samo/l2d/l2d.c
6,20 → 6,23
-
*/
 
//#define USE_DAQ
//#define USE_MIKRO
#define USE_DAQ
#define USE_MIKRO
 
// Izberi ustrezni interface v meniju projektnega okna
// Options->CompilerDefines (dodaj /DSISVME ali /DWIENVME)
 
#ifdef USE_DAQ
# define USE_CAMAC
# include "camac.h"
# ifdef SISVME
# include "sisvme_dll.h"
# endif
//# ifdef SISVME
//# include "sisvme_dll.h"
//# endif
# ifdef WIENVME
# include "wienvme_dll.h"
# endif
# define VME_START(NODE) WIENVME_VME_START((NODE))
# define VME_STOP() WIENVME_VME_STOP()
# include "CAENV965.h"
#endif
 
36,12 → 39,12
 
#ifdef USE_DAQ
//# define VTDC_ADDR 0x330000
# define VADC_ADDR 0x340000
# define VADC_ADDR 0x350000
//# define VTDC 0
# define VADC 1
//# define IO1_ADDR 0x100200
//# define NTDCP 20
# define NTDCJ 18
# define NTDCJ 20
# define NGL 23
#endif
 
52,9 → 55,9
#define MAXCH 0x1000
#define MAX_THREADS 10
 
#define IWAIT 200
#define IWAIT 2000
 
# define NCH 8
# define NCH 2
static int p1h, pID, rID, tfID;
static int ph_tdc, ph_adc;
static int dtdc[NCH][2][MAXCH];
62,10 → 65,10
static int daq_on;
static int poolHandle = 0;
static int ntics,dummy;
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
static int tdcmap[16]={ 0, 1, 2, 3, 4, 5, 6, 7,99,99,99,99,99,99,99,99};
static int adcmap[16]={99,99,99,99,99,99,99,99, 0, 1, 2, 3, 4, 5, 6, 7};
static int ctdcmap[16]={ 0, 1, 2, 3, 4, 5, 6, 7,99,99,99,99,99,99,99,99};
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
static int tdcmap[16]= { 0, 1, 2, 3, 4, 5, 6, 7,99,99,99,99,99,99,99,99};
static int adcmap[16]= {99,99,99,99,99,99,99,99, 0, 1, 2, 3, 4, 5, 6, 7};
static int ctdcmap[16]= { 0, 1, 2, 3, 4, 5, 6, 7,99,99,99,99,99,99,99,99};
 
/************************************************************/
void wait_loop(unsigned long iloop)
72,24 → 75,22
 
{
int i;
for (i=0;i<iloop;i++);
 
for (i=0; i<iloop; i++);
return;
}
 
int CVICALLBACK cb_timer (int panel, int control, int event, void *callbackData,
int eventData1, int eventData2)
{
int eventData1, int eventData2) {
QueueUserEvent (9000, p1h, P1_TIMER);
return (0);
}
 
int update_plots (void)
{
int update_plots (void) {
int irange, ch;
 
GetCtrlVal (p1h, P1_PLCH, &ch);
 
if (ph_tdc>0) DeleteGraphPlot (p1h, P1_TDC, ph_tdc, VAL_DELAYED_DRAW);
GetCtrlVal (p1h, P1_TDCHL, &irange);
ph_tdc = PlotY (p1h, P1_TDC, &dtdc[ch][irange], MAXCH, VAL_INTEGER,
102,285 → 103,305
return (0);
}
 
int CVICALLBACK daq_run(void *functionData)
{
int i,j;
int ndat,dtype,ch,rg,adc,cres;
unsigned long a,b,ec1,ec2;
unsigned long data[100];
unsigned short aa[NCH][4];
int CVICALLBACK daq_run(void *functionData) {
int i,j;
int ndat,dtype,ch,rg,adc,cres;
unsigned long a,b,ec1,ec2;
unsigned long data[100];
unsigned short aa[NCH][4];
 
int dsave,status,fmax,fcount,fev;
char dfile[MAX_PATHNAME_LEN],dfile0[MAX_PATHNAME_LEN];
int supr0,tdcmin,fseed,esave;
float frac;
double fracg;
int dsave,status,fmax,fcount,fev;
char dfile[MAX_PATHNAME_LEN],dfile0[MAX_PATHNAME_LEN];
int supr0,tdcmin,fseed,esave;
float frac;
double fracg;
 
FILE *fp;
FILE *fp=NULL;
#define RUNREC_ID 1
#define ENDREC_ID 2
#define POSREC_ID 3
#define EVTREC_ID 4
 
typedef struct {
typedef struct {
unsigned long id,len;
unsigned long fver,time;
unsigned long nev,nch,ped,xy;
long nx,x0,dx,ny,y0,dy;
} RUNREC;
RUNREC runrec;
typedef struct {
} RUNREC;
RUNREC runrec;
 
typedef struct {
unsigned long id,len;
unsigned long time;
} ENDREC;
ENDREC endrec;
typedef struct {
} ENDREC;
ENDREC endrec;
 
typedef struct {
unsigned long id,len;
unsigned long time;
long ix,x,xset,iy,y,yset;
} POSREC;
POSREC posrec;
} POSREC;
POSREC posrec;
 
typedef struct {
typedef struct {
unsigned long id,len;
unsigned long nev;
unsigned short data[NCH*2];
} EVTREC;
EVTREC evtrec;
runrec.id = RUNREC_ID;
runrec.len = sizeof(runrec);
runrec.fver = 0x10000;
runrec.nch = NCH;
runrec.xy = 1;
endrec.id = ENDREC_ID;
endrec.len = sizeof(endrec);
posrec.id = POSREC_ID;
posrec.len = sizeof(posrec);
evtrec.id = EVTREC_ID;
evtrec.len = sizeof(evtrec);
cres = 0;
GetCtrlVal (p1h, P1_NEVE, &runrec.nev);
GetCtrlVal (p1h, P1_PEDESTAL, &runrec.ped);
GetCtrlVal (p1h, P1_NX, &runrec.nx);
GetCtrlVal (p1h, P1_XSTEP, &runrec.dx);
GetCtrlVal (p1h, P1_XMIN, &runrec.x0);
GetCtrlVal (p1h, P1_NY, &runrec.ny);
GetCtrlVal (p1h, P1_YSTEP, &runrec.dy);
GetCtrlVal (p1h, P1_YMIN, &runrec.y0);
} EVTREC;
EVTREC evtrec;
 
GetCtrlVal (p1h, P1_DSAVE, &dsave);
if (dsave) {
GetCtrlVal (p1h, P1_DFILE, dfile0);
fev=0;
fcount=1;
GetCtrlVal (p1h, P1_NEWF, &fmax);
}
GetCtrlVal (p1h, P1_SUPR, &supr0);
if (supr0) {
GetCtrlVal (p1h, P1_TDCMIN, &tdcmin);
GetCtrlVal (p1h, P1_FRAC, &frac);
}
runrec.id = RUNREC_ID;
runrec.len = sizeof(runrec);
runrec.fver = 0x10000;
runrec.nch = NCH;
runrec.xy = 1;
endrec.id = ENDREC_ID;
endrec.len = sizeof(endrec);
posrec.id = POSREC_ID;
posrec.len = sizeof(posrec);
evtrec.id = EVTREC_ID;
evtrec.len = sizeof(evtrec);
 
cres = 0;
 
GetCtrlVal (p1h, P1_NEVE, &runrec.nev);
GetCtrlVal (p1h, P1_PEDESTAL, &runrec.ped);
 
GetCtrlVal (p1h, P1_NX, &runrec.nx);
GetCtrlVal (p1h, P1_XSTEP, &runrec.dx);
GetCtrlVal (p1h, P1_XMIN, &runrec.x0);
GetCtrlVal (p1h, P1_NY, &runrec.ny);
GetCtrlVal (p1h, P1_YSTEP, &runrec.dy);
GetCtrlVal (p1h, P1_YMIN, &runrec.y0);
 
GetCtrlVal (p1h, P1_DSAVE, &dsave);
if (dsave) {
GetCtrlVal (p1h, P1_DFILE, dfile0);
 
fev=0;
fcount=1;
GetCtrlVal (p1h, P1_NEWF, &fmax);
}
GetCtrlVal (p1h, P1_SUPR, &supr0);
if (supr0) {
GetCtrlVal (p1h, P1_TDCMIN, &tdcmin);
GetCtrlVal (p1h, P1_FRAC, &frac);
}
 
#ifdef USE_DAQ
// V965_map (VTDC, VTDC_ADDR, 1);
// V965_init (VTDC, pedestal);
// V965_map (VTDC, VTDC_ADDR, 1);
// V965_init (VTDC, pedestal);
 
V965_map (VADC, VADC_ADDR, 1);
V965_init (VADC, runrec.ped);
V965_map (VADC, VADC_ADDR, 1);
V965_init (VADC, runrec.ped);
 
# ifdef USE_CAMAC
BZ(&cres);
CCCZ(&cres);
CCCC(&cres);
CREM_I(&cres);
CSSA_R(NGL,0,25,&cres);
Delay(0.01);
BZ(&cres);
CCCZ(&cres);
CCCC(&cres);
CREM_I(&cres);
CSSA_R(NGL,0,25,&cres);
Delay(0.01);
# ifdef NTDCJ
CSSA_R(NTDCJ,0,9,&cres);
printf("CSSA_R(NTDCJ,0,9,&cres)=0x%0x\n", cres);
CSSA_R(NTDCJ,0,26,&cres);
printf("CSSA_R(NTDCJ,0,26,&cres)=0x%0x\n", cres);
CSSA_R(NTDCJ,0,9,&cres);
printf("CSSA_R(NTDCJ,0,9,&cres)=0x%0x\n", cres);
CSSA_R(NTDCJ,0,26,&cres);
printf("CSSA_R(NTDCJ,0,26,&cres)=0x%0x\n", cres);
# endif
# ifdef NTDCP
CSSA_R(NTDCP,0,9,&cres);
CSSA_R(NTDCP,0,11,&cres);
CSSA_R(NTDCP,0,26,&cres);
printf("CSSA_R(NTDCP,0,26,&cres)=0x%0x\n", cres);
CSSA_R(NTDCP,0,9,&cres);
CSSA_R(NTDCP,0,11,&cres);
CSSA_R(NTDCP,0,26,&cres);
printf("CSSA_R(NTDCP,0,26,&cres)=0x%0x\n", cres);
# endif
# endif
#endif
 
if (dsave) {
sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
fp = fopen (dfile, "wb");
time (&runrec.time);
status = fwrite (&runrec, 1, runrec.len, fp);
}
if (supr0) {
fseed = runrec.time & 0x7fffffff;
Uniform (1, fseed, &fracg);
}
if (dsave) {
sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
fp = fopen (dfile, "wb");
time (&runrec.time);
status = fwrite (&runrec, 1, runrec.len, fp);
if (supr0) {
fseed = runrec.time & 0x7fffffff;
Uniform (1, fseed, &fracg);
}
}
 
for (posrec.ix=0;posrec.ix<runrec.nx;posrec.ix++) {
posrec.xset=runrec.x0+posrec.ix*runrec.dx;
for (posrec.ix=0; posrec.ix<runrec.nx; posrec.ix++) {
posrec.xset=runrec.x0+posrec.ix*runrec.dx;
#ifdef USE_MIKRO
// printf("MIKRO_MoveTo (1, x);%d\n",x);
MIKRO_MoveTo (1, posrec.xset);
// printf("->MIKRO_MoveTo (1, x);%d\n",x);
// printf("MIKRO_MoveTo (1, x);%d\n",x);
MIKRO_MoveTo (1, posrec.xset);
// printf("->MIKRO_MoveTo (1, x);%d\n",x);
#endif
 
SetCtrlVal (p1h, P1_X, posrec.xset);
SetCtrlVal (p1h, P1_IX, posrec.ix);
for (posrec.iy=0;posrec.iy<runrec.ny;posrec.iy++) {
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;
posrec.yset=runrec.y0+posrec.iy*runrec.dy;
#ifdef USE_MIKRO
// printf("MIKRO_MoveTo (2, y);%d\n",y);
MIKRO_MoveTo (2, posrec.yset);
// printf("->MIKRO_MoveTo (2, y);%d\n",y);
// printf("MIKRO_MoveTo (2, y);%d\n",y);
MIKRO_MoveTo (2, posrec.yset);
// printf("->MIKRO_MoveTo (2, y);%d\n",y);
#endif
 
SetCtrlVal (p1h, P1_Y, posrec.yset);
SetCtrlVal (p1h, P1_IY, posrec.iy);
SetCtrlVal (p1h, P1_Y, posrec.yset);
SetCtrlVal (p1h, P1_IY, posrec.iy);
 
if (dsave) {
time (&posrec.time);
status = fwrite (&posrec, 1, posrec.len, fp);
}
if (dsave) {
time (&posrec.time);
status = fwrite (&posrec, 1, posrec.len, fp);
}
 
// clear the plots
for (j=0;j<NCH;j++) {
for (i=0;i<MAXCH;i++){
dtdc[j][0][i]=0;
dtdc[j][1][i]=0;
dadc[j][0][i]=0;
dadc[j][1][i]=0;
}
for (j=0; j<NCH; j++) {
for (i=0; i<MAXCH; i++) {
dtdc[j][0][i]=0;
dtdc[j][1][i]=0;
dadc[j][0][i]=0;
dadc[j][1][i]=0;
}
}
 
evtrec.nev=1;
do {
for (j=0;j<NCH;j++)
for (i=0;i<4;i++)
aa[j][i]=0;
// if((neve%1000)==0) printf("Events %ld\n",neve);
evtrec.nev=1;
do {
for (j=0; j<NCH; j++)
for (i=0; i<4; i++)
aa[j][i]=0;
// if((neve%1000)==0) printf("Events %ld\n",neve);
 
#ifdef USE_DAQ
ndat = 0;
ndat = 0;
// a = 0x0001;
// VME_A24D16_W(IO1_ADDR + 0x000008, &a); //poslje laserski sunek
 
ntics=0;
ntics=0;
# ifdef USE_CAMAC
CSSA_R(NGL,0,10,&cres);
CSSA_R(NGL,0,10,&cres);
// do {
// wait_loop(IWAIT);
// Delay(0.1);
# ifdef NTDCJ
// CSSA_R(NTDCJ,0,8,&cres);
// CSSA_R(NTDCJ,0,8,&cres);
# endif
# ifdef NTDCP
// CSSA_R(NTDCP,0,8,&cres);
// CSSA_R(NTDCP,0,8,&cres);
# endif
// if (!(cres&0x8000)) printf("CSSA_R(NTDCJ,0,8,&cres)=0x%0x\n", cres) ;
// if (!(cres&0x8000)) printf("CSSA_R(NTDCJ,0,8,&cres)=0x%0x\n", cres) ;
// } while ((!(cres&0x8000))&&(ntics<2)&&daq_on);
# endif
// wait_loop(2000);
while((!(V965_status(VADC)&0x1))&&(ntics<2)&&daq_on);
if (!daq_on) break;
if (ntics>=2) {
while((!(V965_status(VADC)&0x1))&&(ntics<2)&&daq_on);
if (!daq_on) break;
if (ntics>=2) {
ndat=V965_read (VADC, &data[0]);
continue;
} else {
# ifdef USE_CAMAC
# ifdef NTDCJ
wait_loop(20000);
// ntics=0;
// do {
// wait_loop(IWAIT);
CSSA_R(NTDCJ,0,8,&cres);
// if (!(cres&0x8000)) printf("CSSA_R(NTDCJ,0,8,&cres)=0x%0x\n", cres) ;
// } while ((!(cres&0x8000))&&(ntics<2)&&daq_on);
// if (!daq_on) break;
// if (ntics>=2) {
if (!(cres&0x8000)) {
CSSA_R(NGL,0,25,&cres);
ndat=V965_read (VADC, &data[0]);
CSSA_R(NTDCJ,0,9,&cres);
CSSA_R(NTDCJ,0,26,&cres);
continue;
}
wait_loop(2000);
/*
ndat=V965_read (VTDC, &data[0]);
for (i=0; i<ndat; i++) {
dtype=(data[i]>>25)&0x3;
if (dtype==0) {
ch=tdcmap[(data[i]>>17)&0xf];
if (ch<NCH) {
rg=(data[i]>>16)&0x1;
adc=data[i]&0xfff;
aa[ch][rg]=adc;
dtdc[ch][rg][adc]+=1;
}
}
}
*/
for (i=0; i<NCH; i++) {
# endif
# endif
}
/*
ndat=V965_read (VTDC, &data[0]);
for (i=0; i<ndat; i++) {
dtype=(data[i]>>25)&0x3;
if (dtype==0) {
ch=tdcmap[(data[i]>>17)&0xf];
if (ch<NCH) {
rg=(data[i]>>16)&0x1;
adc=data[i]&0xfff;
aa[ch][rg]=adc;
dtdc[ch][rg][adc]+=1;
}
}
}
*/
for (i=0; i<NCH; i++) {
wait_loop(IWAIT);
# ifdef USE_CAMAC
# ifdef NTDCJ
CSSA_R(NTDCJ,ctdcmap[i],0,&adc);
CSSA_R(NTDCJ,ctdcmap[i],0,&adc);
# endif
# ifdef NTDCP
CSSA_R(NTDCP,ctdcmap[i],0,&adc);
CSSA_R(NTDCP,ctdcmap[i],0,&adc);
# endif
# endif
// printf("TDC=0x%04X\n",adc);
adc=adc&0xfff;
aa[i][0]=adc;
dtdc[i][0][adc]+=1;
// printf("TDC=0x%04X\n",adc);
// adc=adc&0xfff;
if (adc&0x1000) adc=0xfff; else adc&=0xfff;
aa[i][0]=adc;
dtdc[i][0][adc]+=1;
}
 
ndat=V965_read (VADC, &data[0]);
for (i=0; i<ndat; i++) {
dtype=(data[i]>>25)&0x3;
if (dtype==0) {
ch=adcmap[(data[i]>>17)&0xf];
if (ch<NCH) {
rg=(data[i]>>16)&0x1;
adc=data[i]&0xfff;
aa[ch][rg+2]=adc;
dadc[ch][rg][adc]+=1;
}
}
}
 
ndat=V965_read (VADC, &data[0]);
for (i=0; i<ndat; i++) {
dtype=(data[i]>>25)&0x3;
if (dtype==0) {
ch=adcmap[(data[i]>>17)&0xf];
if (ch<NCH) {
rg=(data[i]>>16)&0x1;
adc=data[i]&0xfff;
aa[ch][rg+2]=adc;
dadc[ch][rg][adc]+=1;
}
}
}
 
# ifdef USE_CAMAC
wait_loop(IWAIT);
wait_loop(IWAIT);
# ifdef NTDCJ
CSSA_R(NTDCJ,0,9,&cres);
CSSA_R(NTDCJ,0,9,&cres);
# endif
# ifdef NTDCP
CSSA_R(NTDCP,0,9,&cres);
CSSA_R(NTDCP,0,26,&cres);
// printf("2 CSSA_R(NTDCP,0,26,&cres)=0x%0x\n", cres);
# endif
CSSA_R(NTDCP,0,9,&cres);
CSSA_R(NTDCP,0,26,&cres);
// printf("2 CSSA_R(NTDCP,0,26,&cres)=0x%0x\n", cres);
# endif
// Delay(0.001);
// wait_loop(IWAIT);
// CSSA_R(NGL,0,10,&cres);
# endif
 
#else /* generate test data */
if (!daq_on) break;
for (i=0;i<NCH;i++) {
adc=100+evtrec.nev%200;
dtdc[i][1][adc]+=1;
dadc[i][1][adc]+=1;
aa[i][0]=adc;
aa[i][2]=adc;
adc=200+evtrec.nev%400;
dtdc[i][0][adc]+=1;
dadc[i][0][adc]+=1;
aa[i][1]=adc;
aa[i][3]=adc;
}
if (!daq_on) break;
for (i=0; i<NCH; i++) {
adc=100+evtrec.nev%200;
dtdc[i][1][adc]+=1;
dadc[i][1][adc]+=1;
aa[i][0]=adc;
aa[i][2]=adc;
adc=200+evtrec.nev%400;
dtdc[i][0][adc]+=1;
dadc[i][0][adc]+=1;
aa[i][1]=adc;
aa[i][3]=adc;
}
#endif
esave=dsave;
if (supr0 && esave) {
if (supr0 && esave) {
Uniform (1, -1, &fracg);
if (fracg > frac) {
esave=0;
for (i=0;i<NCH;i++) {
for (i=0; i<NCH; i++) {
if ((aa[i][0] >= tdcmin) && (aa[i][0] < 4000)) esave=1;
}
}
387,51 → 408,50
}
if (esave) {
// time (&evtrec.time);
for (i=0;i<NCH;i++) {
for (i=0; i<NCH; i++) {
evtrec.data[i] = aa[i][0];
evtrec.data[i+NCH] = aa[i][2];
}
status = fwrite (&evtrec, 1, evtrec.len, fp);
}
if (!(evtrec.nev%1000)) SetCtrlVal (p1h, P1_CEVE, evtrec.nev);
} while (evtrec.nev++<runrec.nev);
if (!daq_on) break;
}
if (!daq_on) break;
}
if (dsave) {
time (&endrec.time);
status = fwrite (&endrec, 1, endrec.len, fp);
fclose(fp);
}
daq_on=0;
SetCtrlVal (p1h, P1_DAQ, daq_on);
SetCtrlVal (p1h, P1_CEVE, evtrec.nev);
status = fwrite (&evtrec, 1, evtrec.len, fp);
}
 
return 0;
if (!(evtrec.nev%1000)) SetCtrlVal (p1h, P1_CEVE, evtrec.nev);
} while (evtrec.nev++<runrec.nev);
if (!daq_on) break;
}
if (!daq_on) break;
}
 
if (dsave) {
time (&endrec.time);
status = fwrite (&endrec, 1, endrec.len, fp);
fclose(fp);
}
 
daq_on=0;
SetCtrlVal (p1h, P1_DAQ, daq_on);
SetCtrlVal (p1h, P1_CEVE, evtrec.nev);
 
return 0;
}
 
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
LPSTR lpszCmdLine, int nCmdShow) {
int i,j,status,refon;
long int zpos;
char dfile[300];
FILE *fp;
 
typedef struct {
unsigned long id,len;
unsigned long fver,time;
unsigned long nev,nch,ped,xy;
long nx,x0,dx,ny,y0,dy;
unsigned long id,len;
unsigned long fver,time;
unsigned long nev,nch,ped,xy;
long nx,x0,dx,ny,y0,dy;
} RUNREC;
RUNREC runrec;
 
if (InitCVIRTE (hInstance, 0, 0) == 0)
return -1; /* out of memory */
return -1; /* out of memory */
 
SetSleepPolicy(VAL_SLEEP_MORE);
CmtNewThreadPool (MAX_THREADS, &poolHandle);
450,77 → 470,77
MIKRO_Init (2,0);
MIKRO_Init (3,0);
#endif
 
if ((p1h = LoadPanel (0, "l2d_ui.uir", P1)) < 0) return -1;
DisplayPanel (p1h);
SetCtrlAttribute (p1h, P1_PLCH, ATTR_MAX_VALUE, NCH-1);
 
QueueUserEvent (1000, p1h, P1_RESET);
 
do {
GetUserEvent (1, &pID, &rID);
switch (rID) {
switch (rID) {
case P1_TIMER:
ntics+=1;
GetCtrlVal (p1h, P1_REFON, &refon);
if (refon) update_plots();
break;
if (refon) update_plots();
break;
case P1_REFRESH:
update_plots();
break;
case P1_DAQ:
GetCtrlVal (p1h, P1_DAQ, &daq_on);
if (daq_on) {
CmtScheduleThreadPoolFunction (poolHandle, daq_run, (void *)&dummy, &tfID);
} else {
update_plots();
break;
case P1_DAQ:
GetCtrlVal (p1h, P1_DAQ, &daq_on);
if (daq_on) {
CmtScheduleThreadPoolFunction (poolHandle, daq_run, (void *)&dummy, &tfID);
} else {
CmtWaitForThreadPoolFunctionCompletion (poolHandle, tfID,
OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
CmtReleaseThreadPoolFunctionID (poolHandle, tfID);
}
break;
case P1_ZSET:
if (!daq_on) {
GetCtrlVal (p1h, P1_ZSET, &zpos);
OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
CmtReleaseThreadPoolFunctionID (poolHandle, tfID);
}
break;
case P1_ZSET:
if (!daq_on) {
GetCtrlVal (p1h, P1_ZSET, &zpos);
#ifdef USE_MIKRO
MIKRO_MoveTo (3, zpos);
#endif
}
break;
case P1_REREAD:
if (!daq_on) {
break;
case P1_REREAD:
if (!daq_on) {
status = FileSelectPopup ("", "*.dat", ".dat",
"Izberi datoteko s podatki",
VAL_LOAD_BUTTON, 0, 0, 1, 0, dfile);
if (status==1) {
fp = fopen (dfile, "rb");
status = fread (&runrec, 1, sizeof(runrec), fp);
fclose(fp);
if (runrec.id==1) {
SetCtrlVal (p1h, P1_NX, runrec.nx);
SetCtrlVal (p1h, P1_XSTEP, runrec.dx);
SetCtrlVal (p1h, P1_XMIN, runrec.x0);
SetCtrlVal (p1h, P1_NY, runrec.ny);
SetCtrlVal (p1h, P1_YSTEP, runrec.dy);
SetCtrlVal (p1h, P1_YMIN, runrec.y0);
SetCtrlVal (p1h, P1_NEVE, runrec.nev);
status = fread (&runrec, 1, sizeof(runrec), fp);
fclose(fp);
if (runrec.id==1) {
SetCtrlVal (p1h, P1_NX, runrec.nx);
SetCtrlVal (p1h, P1_XSTEP, runrec.dx);
SetCtrlVal (p1h, P1_XMIN, runrec.x0);
SetCtrlVal (p1h, P1_NY, runrec.ny);
SetCtrlVal (p1h, P1_YSTEP, runrec.dy);
SetCtrlVal (p1h, P1_YMIN, runrec.y0);
SetCtrlVal (p1h, P1_NEVE, runrec.nev);
}
}
}
}
break;
case P1_HO:
if (!daq_on) {
SetWaitCursor (1);
break;
case P1_HO:
if (!daq_on) {
SetWaitCursor (1);
#ifdef USE_MIKRO
MIKRO_ReferenceMove (1);
MIKRO_ReferenceMove (2);
MIKRO_ReferenceMove (3);
MIKRO_ReferenceMove (1);
MIKRO_ReferenceMove (2);
MIKRO_ReferenceMove (3);
#endif
SetWaitCursor (0);
}
break;
case P1_RESET:
for (j=0;j<NCH;j++) {
for (i=0;i<MAXCH;i++){
SetWaitCursor (0);
}
break;
case P1_RESET:
for (j=0; j<NCH; j++) {
for (i=0; i<MAXCH; i++) {
dtdc[j][0][i]=0;
dtdc[j][1][i]=0;
dadc[j][0][i]=0;
527,22 → 547,22
dadc[j][1][i]=0;
}
}
update_plots();
break;
case P1_TDCLOG:
GetCtrlVal (p1h, P1_TDCLOG, &status);
update_plots();
break;
case P1_TDCLOG:
GetCtrlVal (p1h, P1_TDCLOG, &status);
SetCtrlAttribute (p1h, P1_TDC, ATTR_YMAP_MODE, status);
update_plots();
break;
case P1_ADCLOG:
GetCtrlVal (p1h, P1_ADCLOG, &status);
update_plots();
break;
case P1_ADCLOG:
GetCtrlVal (p1h, P1_ADCLOG, &status);
SetCtrlAttribute (p1h, P1_ADC, ATTR_YMAP_MODE, status);
update_plots();
break;
}
update_plots();
break;
}
 
} while ((rID != P1_EXIT)||daq_on);
 
CmtDiscardThreadPool (poolHandle);
DiscardPanel (p1h);
 
552,7 → 572,7
 
#ifdef USE_DAQ
VME_STOP();
#endif
#endif
return 0;
 
}
/Samo/l2d/l2d.cws
1,22 → 1,22
[Workspace Header]
Version = 1700
Pathname = "/c/SAMO/Programi/NI/cvi/l2d/l2d.cws"
CVI Dir = "/c/program files (x86)/national instruments/cvi2017"
CVI Shared Dir = "/C/Program Files (x86)/National Instruments/Shared/CVI"
Pathname = "/c/home/samo/l2d/l2d.cws"
CVI Dir = "/c/program files/national instruments/cvi2017"
CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2017"
CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI"
IVI Standard Root Dir = "/C/Program Files (x86)/IVI Foundation/IVI"
IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
VXIplug&play Framework Dir = "/C/Program Files (x86)/IVI Foundation/VISA/winnt"
VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
Number of Projects = 1
Active Project = 1
Project 0001 = "l2d.prj"
Drag Bar Left = 250
Window Top = 149
Window Left = -1599
Window Bottom = 1007
Window Right = -196
Drag Bar Left = 201
Window Top = 31
Window Left = 291
Window Bottom = 1079
Window Right = 1811
Maximized = False
Maximized Children = True
Max32 Number Of Errors = 20
30,9 → 30,9
Hide Windows = False
Break At First Statement = False
Sort Type = "File Name"
Number of Opened Files = 3
Number of Opened Files = 8
Window Confinement Region Enabled = True
MainColumnWidth = 233
MainColumnWidth = 184
FileDateColumnWidth = 70
FileSizeColumnWidth = 70
 
46,68 → 46,129
Batch Build Debug = False
 
[File 0001]
Path = "/c/SAMO/Programi/NI/cvi/instr/CAENV965/CAENV965.fp"
Path = "/c/home/cvi/instr/CAENV965/CAENV965.fp"
File Type = "Function Panel"
Disk Date = 3657094434
Disk Date = 3568264729
In Projects = "1,"
 
[File 0002]
Path = "/c/SAMO/Programi/NI/cvi/instr/MIKRO/MIKRO.fp"
Path = "/c/home/cvi/instr/MIKRO/MIKRO.fp"
File Type = "Function Panel"
Disk Date = 3336986594
Disk Date = 3555480934
In Projects = "1,"
 
[File 0003]
Path = "/c/SAMO/Programi/NI/cvi/instr/WIENVME_DLL/wienvme_dll.fp"
Path = "/c/home/cvi/instr/WIENVME_DLL/wienvme_dll.fp"
File Type = "Function Panel"
Disk Date = 3509989482
Disk Date = 3555480934
In Projects = "1,"
 
[File 0004]
Path = "/c/SAMO/Programi/NI/cvi/l2d/l2d.c"
Path = "/c/home/samo/l2d/l2d.c"
File Type = "CSource"
Disk Date = 3557037737
Disk Date = 3657462591
In Projects = "1,"
Window Top = 64
Window Left = 26
Window Height = -16281
Window Z-Order = 3
Source Window State = "1,184,184,184,29,34,34,0,0,80,0,0,0,0,0,20,0,0,441,195,349,683,1,0,"
Window Z-Order = 1
Source Window State = "1,404,404,404,90,91,90,0,0,160,0,0,0,0,0,51,318,0,349,36,349,683,1,0,"
 
[File 0005]
Path = "/c/SAMO/Programi/NI/cvi/l2d/l2d_ui.uir"
Path = "/c/home/samo/l2d/l2d_ui.uir"
File Type = "User Interface Resource"
Disk Date = 3279851198
Disk Date = 3657102569
In Projects = "1,"
Window Top = 33
Window Left = 10
Window Height = 297
Window Width = 683
Window Z-Order = 1
Window Z-Order = 6
 
[File 0006]
Path = "/c/SAMO/Programi/NI/cvi/l2d/camac.h"
Path = "/c/home/samo/l2d/camac.h"
File Type = "Include"
Disk Date = 3279845963
Disk Date = 3657109961
In Projects = "1,"
Window Top = 95
Window Left = 42
Window Z-Order = 2
Source Window State = "1,0,0,0,0,0,0,0,0,80,0,0,0,0,0,20,0,0,0,0,349,683,1,0,"
Window Z-Order = 4
Source Window State = "1,4,5,4,0,0,0,0,0,80,0,0,0,0,0,25,0,0,5,51,349,683,1,0,"
 
[File 0007]
Path = "/c/SAMO/Programi/NI/cvi/l2d/l2d_ui.h"
Path = "/c/home/cvi/instr/CAENV965/CAENV965.c"
File Type = "CSource"
Disk Date = 3657107165
In Projects = ""
Window Top = 188
Window Left = 90
Window Z-Order = 7
Source Window State = "1,4,4,4,22,26,22,0,0,80,0,0,0,0,0,25,0,0,7,24,349,683,1,0,"
 
[File 0008]
Path = "/c/home/cvi/instr/CAENV965/CAENV965.h"
File Type = "Include"
Disk Date = 3279851198
Disk Date = 3568264729
In Projects = ""
Window Top = 219
Window Left = 106
Window Z-Order = 8
Source Window State = "1,0,0,0,0,0,0,0,0,80,0,0,0,0,0,25,0,0,0,0,349,683,1,0,"
 
[File 0009]
Path = "/c/home/cvi/instr/CAENV965/CAENV965_DEF.h"
File Type = "Include"
Disk Date = 3568264729
In Projects = ""
Window Top = 250
Window Left = 122
Window Z-Order = 5
Source Window State = "1,0,0,0,0,0,0,0,0,80,0,0,0,0,0,25,0,0,0,0,349,683,1,0,"
 
[File 0010]
Path = "/c/home/cvi/instr/WIENVME_DLL/wienvme_dll.h"
File Type = "Include"
Disk Date = 3568264730
In Projects = ""
Window Top = 312
Window Left = 154
Window Z-Order = 3
Source Window State = "1,31,31,31,32,53,32,0,0,80,0,0,0,0,0,25,23,0,59,24,349,683,1,0,"
 
[File 0011]
Path = "/c/home/samo/l2d/l2d_ui.h"
File Type = "Include"
Disk Date = 3657102569
In Projects = "1,"
Window Top = 126
Window Left = 58
Source Window State = "1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,349,683,1,0,"
 
[File 0012]
Path = "/c/home/cvi/instr/WIENVME_DLL/wienvme_dll.c"
File Type = "CSource"
Disk Date = 3657111603
In Projects = ""
Window Top = 343
Window Left = 170
Window Z-Order = 2
Source Window State = "1,87,87,87,12,33,33,0,0,80,0,0,0,0,0,25,25,0,63,58,349,683,1,0,"
 
[File 0013]
Path = "/c/home/cvi/instr/WIENVME_DLL/pcivme_ni.lib"
File Type = "Library"
Disk Date = 3556788687
In Projects = "1,"
 
[Tab Order]
Tab 0001 = "/c/SAMO/Programi/NI/cvi/l2d/l2d_ui.uir"
Tab 0002 = "/c/SAMO/Programi/NI/cvi/l2d/l2d.c"
Tab 0003 = "/c/SAMO/Programi/NI/cvi/l2d/camac.h"
Tab 0001 = "/c/home/samo/l2d/l2d.c"
Tab 0002 = "/c/home/samo/l2d/l2d_ui.uir"
Tab 0003 = "/c/home/cvi/instr/CAENV965/CAENV965.c"
Tab 0004 = "/c/home/cvi/instr/CAENV965/CAENV965.h"
Tab 0005 = "/c/home/cvi/instr/CAENV965/CAENV965_DEF.h"
Tab 0006 = "/c/home/cvi/instr/WIENVME_DLL/wienvme_dll.h"
Tab 0007 = "/c/home/cvi/instr/WIENVME_DLL/wienvme_dll.c"
Tab 0008 = "/c/home/samo/l2d/camac.h"
 
[Default Build Config 0001 Debug]
Generate Browse Info = True
/Samo/l2d/l2d.prj
1,15 → 1,15
[Project Header]
Version = 1302
Pathname = "/c/SAMO/Programi/NI/cvi/l2d/l2d.prj"
CVI Dir = "/c/program files (x86)/national instruments/cvi2013"
CVI Shared Dir = "/C/Program Files (x86)/National Instruments/Shared/CVI"
CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2013"
Version = 1700
Pathname = "/c/home/samo/l2d/l2d.prj"
CVI Dir = "/c/program files/national instruments/cvi2017"
CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2017"
CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI"
IVI Standard Root Dir = "/C/Program Files (x86)/IVI Foundation/IVI"
VXIplug&play Framework Dir = "/C/Program Files (x86)/IVI Foundation/VISA/winnt"
IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
Number of Files = 7
Number of Files = 8
Target Type = "Executable"
Flags = 16
Copied From Locked InstrDrv Directory = False
18,7 → 18,6
Don't Display Deploy InstrDrv Dialog = False
 
[Folders]
Library Files Folder Not Added Yet = True
Folder 0 = "Source Files"
FolderEx 0 = "Source Files"
Folder 1 = "User Interface Files"
27,6 → 26,8
FolderEx 2 = "Include Files"
Folder 3 = "Instrument Files"
FolderEx 3 = "Instrument Files"
Folder 4 = "Library Files"
FolderEx 4 = "Library Files"
 
[File 0001]
File Type = "CSource"
34,7 → 35,7
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "l2d.c"
Path = "/c/SAMO/Programi/NI/cvi/l2d/l2d.c"
Path = "/c/home/samo/l2d/l2d.c"
Exclude = False
Compile Into Object File = False
Project Flags = 0
47,7 → 48,7
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "l2d_ui.uir"
Path = "/c/SAMO/Programi/NI/cvi/l2d/l2d_ui.uir"
Path = "/c/home/samo/l2d/l2d_ui.uir"
Exclude = False
Project Flags = 0
Folder = "User Interface Files"
59,7 → 60,7
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "camac.h"
Path = "/c/SAMO/Programi/NI/cvi/l2d/camac.h"
Path = "/c/home/samo/l2d/camac.h"
Exclude = False
Project Flags = 0
Folder = "Include Files"
71,7 → 72,7
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "l2d_ui.h"
Path = "/c/SAMO/Programi/NI/cvi/l2d/l2d_ui.h"
Path = "/c/home/samo/l2d/l2d_ui.h"
Exclude = False
Project Flags = 0
Folder = "Include Files"
82,8 → 83,8
Res Id = 5
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "../instr/CAENV965/CAENV965.fp"
Path = "/c/SAMO/Programi/NI/cvi/instr/CAENV965/CAENV965.fp"
Path Rel Path = "../../cvi/instr/CAENV965/CAENV965.fp"
Path = "/c/home/cvi/instr/CAENV965/CAENV965.fp"
Exclude = False
Project Flags = 0
Folder = "Instrument Files"
94,8 → 95,8
Res Id = 6
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "../instr/MIKRO/MIKRO.fp"
Path = "/c/SAMO/Programi/NI/cvi/instr/MIKRO/MIKRO.fp"
Path Rel Path = "../../cvi/instr/MIKRO/MIKRO.fp"
Path = "/c/home/cvi/instr/MIKRO/MIKRO.fp"
Exclude = False
Project Flags = 0
Folder = "Instrument Files"
106,13 → 107,25
Res Id = 7
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "../instr/WIENVME_DLL/wienvme_dll.fp"
Path = "/c/SAMO/Programi/NI/cvi/instr/WIENVME_DLL/wienvme_dll.fp"
Path Rel Path = "../../cvi/instr/WIENVME_DLL/wienvme_dll.fp"
Path = "/c/home/cvi/instr/WIENVME_DLL/wienvme_dll.fp"
Exclude = False
Project Flags = 0
Folder = "Instrument Files"
Folder Id = 3
 
[File 0008]
File Type = "Library"
Res Id = 8
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "../../cvi/instr/WIENVME_DLL/pcivme_ni.lib"
Path = "/c/home/cvi/instr/WIENVME_DLL/pcivme_ni.lib"
Exclude = False
Project Flags = 0
Folder = "Library Files"
Folder Id = 4
 
[Custom Build Configs]
Num Custom Build Configs = 0
 
169,6 → 182,32
Using LoadExternalModule = True
DLL Exports = "Include File Symbols"
Register ActiveX Server = False
Numeric File Version = "1,0,0,0"
Numeric Prod Version = "1,0,0,0"
Comments = ""
Comments Ex = ""
Company Name = ""
Company Name Ex = "%company"
File Description = "l2d_dbg (Debug x86)"
File Description Ex = "%application (%rel_dbg %arch)"
File Version = "1.0"
File Version Ex = "%f1.%f2"
Internal Name = "l2d_dbg"
Internal Name Ex = "%basename"
Legal Copyright = "Copyright 2019"
Legal Copyright Ex = "Copyright %company %Y"
Legal Trademarks = ""
Legal Trademarks Ex = ""
Original Filename = "l2d_dbg.exe"
Original Filename Ex = "%filename"
Private Build = ""
Private Build Ex = ""
Product Name = " l2d_dbg"
Product Name Ex = "%company %application"
Product Version = "1.0"
Product Version Ex = "%p1.%p2"
Special Build = ""
Special Build Ex = ""
Add Type Lib To DLL = False
Include Type Lib Help Links = False
TLB Help Style = "HLP"
360,9 → 399,8
Enable Unreachable Code Warning = False
Enable Unreferenced Identifiers Warning = False
Enable Assignment In Conditional Warning = False
O Option Compatible With 5.0 = False
Enable C99 Extensions = False
Uninitialized Locals Compile Warning = "Conservative"
Uninitialized Locals Compile Warning = "Aggressive"
Precompile Prefix Header = False
Prefix Header File = ""
 
380,25 → 418,25
Include Path 1 Rel To = "CVI"
Include Path 1 Rel To Override = "CVI"
Include Path 1 Rel Path = "instr/PCIVME_DLL"
Include Path 1 = "/c/Program Files (x86)/National Instruments/CVI2013/instr/PCIVME_DLL"
Include Path 1 = "/c/program files/national instruments/cvi2017/instr/PCIVME_DLL"
 
[Create Executable]
Executable File_Debug Is Rel = True
Executable File_Debug Rel To = "Project"
Executable File_Debug Rel Path = "l2d_dbg.exe"
Executable File_Debug = "/c/SAMO/Programi/NI/cvi/l2d/l2d_dbg.exe"
Executable File_Debug = "/c/home/samo/l2d/l2d_dbg.exe"
Executable File_Release Is Rel = True
Executable File_Release Rel To = "Project"
Executable File_Release Rel Path = "l2d.exe"
Executable File_Release = "/c/SAMO/Programi/NI/cvi/l2d/l2d.exe"
Executable File_Release = "/c/home/samo/l2d/l2d.exe"
Executable File_Debug64 Is Rel = True
Executable File_Debug64 Rel To = "Project"
Executable File_Debug64 Rel Path = "l2d.exe"
Executable File_Debug64 = "/c/SAMO/Programi/NI/cvi/l2d/l2d.exe"
Executable File_Debug64 = "/c/home/samo/l2d/l2d.exe"
Executable File_Release64 Is Rel = True
Executable File_Release64 Rel To = "Project"
Executable File_Release64 Rel Path = "l2d.exe"
Executable File_Release64 = "/c/SAMO/Programi/NI/cvi/l2d/l2d.exe"
Executable File_Release64 = "/c/home/samo/l2d/l2d.exe"
Icon File Is Rel = False
Icon File = ""
Application Title = ""