/cvi/apps/petdaq/daq_cvi.c |
---|
0,0 → 1,581 |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
// Izberi ustrezni interface v meniju projektnega okna |
// Options->CompilerDefines (dodaj /DSISVME ali /DWIENVME) |
#ifdef USE_DAQ |
# ifdef SISVME |
# include "sisvme_dll.h" |
# endif |
# ifdef WIENVME |
# include "wienvme_dll.h" |
# endif |
# ifdef WUSBVME |
# include "wusbvme_dll.h" |
# endif |
#endif |
#include "wusbvme_dll.h" |
#include <formatio.h> |
#include "daq_cvi.h" |
#include "CAENV965_DEF.h" |
#define USBVME_NAME "VM0120" |
#define VERSION 1.0 |
#define TIMEOUT 3 |
/* VME modules */ |
#define CAEN_V792 0x340000 // IJS V792 |
#define CAEN_V792_1 0x530000 // FMF1 V792 |
#define CAEN_V792_2 0x630000 // FMF2 V792 |
#define CAEN_V965 0x350000 // IJS V965 |
int addr[3]={CAEN_V792,CAEN_V792_1,CAEN_V965 }; |
int nadc=2; |
#define BUFF_L 2048 |
static int stackwrite[10000]; |
static int stackdata[10000],stackdump[27000]; |
/************************************************/ |
int weight_while(int num) |
{ |
int i, tmp; |
for ( i =0; i <num; i++ ) tmp = 0; |
return 0; |
} |
#define WWHILE weight_while(0) |
#define TRUE 1 |
#define FALSE 0 |
int timer_out; |
//struct sigaction oact; |
void timerast (int signumber) |
{ |
timer_out = TRUE; |
fprintf(stderr,"TIMEOUT !!!\n"); |
} |
void tmlnk (int tout) |
{ |
/* |
timer_out = FALSE; |
struct sigaction act; |
struct itimerval tdelay; |
act.sa_handler = timerast; |
sigemptyset (&act.sa_mask); |
act.sa_flags = 0; |
tdelay.it_value.tv_sec = tout / 100; |
tdelay.it_value.tv_usec = 10000 * (tout % 100); |
tdelay.it_interval.tv_sec = 0; |
tdelay.it_interval.tv_usec = 0; |
if (sigaction (SIGALRM, &act, &oact) < 0) |
{ |
perror ("sigaction(tmlnk)"); |
exit (EXIT_FAILURE); |
} |
if (setitimer (ITIMER_REAL, &tdelay, NULL) < 0) |
{ |
perror ("setitimer(tmlnk)"); |
exit (EXIT_FAILURE); |
} |
*/ |
} |
void tmulk () |
{ |
/* |
struct itimerval tdelay; |
tdelay.it_value.tv_sec = 0; |
tdelay.it_value.tv_usec = 0; |
tdelay.it_interval.tv_sec = 0; |
tdelay.it_interval.tv_usec = 0; |
if (setitimer (ITIMER_REAL, &tdelay, NULL) < 0) |
{ |
perror ("setitimer(tmulk)"); |
exit (EXIT_FAILURE); |
} |
if (sigaction (SIGALRM, &oact, NULL) < 0) |
{ |
perror ("sigaction(tmulk)"); |
exit (EXIT_FAILURE); |
} |
*/ |
} |
int fexist( char * path){ |
int size=0; |
return GetFileInfo(path,&size); |
} |
uint32_t fInit[MAXSTACKSIZE]; |
uint32_t fRun[MAXSTACKSIZE]; |
int init(){ |
if (WUSB_udev == NULL) return -1; |
int retval = xxusb_register_write(WUSB_udev,1,0x0); // Stop DAQ mode |
if (retval<0) return retval; |
while (xxusb_usbfifo_read(WUSB_udev,(int *) stackdump,BUFF_L,100)>0); |
int rate=1000; |
int ii=80000000/rate-40; // 80 MHz |
if (ii<72) ii=72; |
// Set DGG channel A as a pulser, output on O1, |
// with delay =500 x 12.5ns, |
// and width = 500 x 12.5ns, |
// not latching or inverting |
// VME_DGG(udev,0,6,0,24000,6000,0,0); |
VME_DGG(WUSB_udev,0,6,0,ii,40,0,0); |
// Set DGG channel B to trigger on NIM1, output on O2, |
// with delay =200 x 12.5ns, |
// and width = 200 x 12.5ns, |
// not latching or inverting |
VME_DGG(WUSB_udev,1,1,1,0,10,0,1); |
printf("CAEN V965 Pedestal set to %d\n", fPedestal); |
// INIT stackdata |
int fPedestal=255; |
WIENER_VMUSB_StackInit(); |
for (int i=0;i<nadc;i++){ |
WIENER_VMUSB_StackWriteA24D16( addr[i] + CAENV965_CRN , 0x0); |
WIENER_VMUSB_StackWriteA24D16( addr[i] + CAENV965_GEO , i); |
WIENER_VMUSB_StackReadA24D16(addr[i] + CAENV965_GEO); |
for (int j=0;j<32;j++){ |
WIENER_VMUSB_StackWriteA24D16(addr[i] + CAENV965_THM + 0x02*j, fThreshold[j+i*32]); // threshold/kill for 32 channels |
} |
WIENER_VMUSB_StackWriteA24D16( addr[i] + CAENV965_BS1, 0x80 ); // soft reset |
WIENER_VMUSB_StackWriteA24D16( addr[i] + CAENV965_BC1, 0x80 ); // soft reset |
WIENER_VMUSB_StackWriteA24D16( addr[i] + CAENV965_PED, fPedestal ); // pedestal |
WIENER_VMUSB_StackWriteA24D16( addr[i] + CAENV965_BS2,0x5000); |
WIENER_VMUSB_StackWriteA24D16( addr[i] + CAENV965_BS2,0x4); // clear module |
WIENER_VMUSB_StackWriteA24D16( addr[i] + CAENV965_BC2,0x4); |
} |
WIENER_VMUSB_StackMarker(0xFAFC); |
WIENER_VMUSB_StackGetUInt32(MAXSTACKSIZE, fInit); |
// fInit->Print(); |
// READOUT stackdata |
WIENER_VMUSB_StackInit(); |
WIENER_VMUSB_StackMarker(0xFFAB); |
//fStack->ConditionalRead(addr[i] + CAENV965_SR1,0x1); // TRG wait : loop until bit 0 is on |
// fStack->RepeatRead( CMD_A24, CMD_D32, addr[i] + CAENV965_OB,34,0); // repead read |
//fStack->ConditionalRead(addr[i] + CAENV965_OB ,0x4000000) ; // loop until bit 26 is on, read data |
for (int j=0;j<36;j++) WIENER_VMUSB_StackReadA24D32(addr[0] + CAENV965_OB); |
//for (int j=0;j<36;j++) fStack->ReadA24D32(addr[1] + CAENV965_OB); |
//for (int j=0;j<8;j++) fStack->ReadA24D32(addr[2] + CAENV965_OB);// 4 channels connected |
WIENER_VMUSB_StackMarker(0xFAFB); |
for (int k=0;k<nadc;k++){ |
WIENER_VMUSB_StackWriteA24D16(addr[k] + CAENV965_BS2,0x4); // clear module |
WIENER_VMUSB_StackWriteA24D16(addr[k] + CAENV965_BC2,0x4); |
} |
//fStack->Print(); |
VME_LED_settings(WUSB_udev, 0,0,0,0); // Set Yellow LED to light with with USB out buffer not empty |
VME_LED_settings(WUSB_udev, 1,1,0,0); // Set Red LED to light with NIM1 |
VME_LED_settings(WUSB_udev,2,0,0,0); // Set Green LED to light when stack is not empty |
uint32_t vmereg; |
VME_register_read(WUSB_udev,0x00,&vmereg); |
printf("VMUSB Firmware ID -> 0x%08X\n",vmereg); |
VME_register_read(WUSB_udev,0x04,&vmereg); |
printf("VMUSB Global Mode -> 0x%08X\n",vmereg); |
vmereg=(vmereg&0xF000)|0x0004; |
VME_register_write(WUSB_udev,0x04,vmereg); |
VME_register_write(WUSB_udev,0x08,0x00000080); |
VME_register_write(WUSB_udev,0x28,0x0); |
VME_register_write(WUSB_udev,0x2C,0x0); |
VME_register_write(WUSB_udev,0x30,0x0); |
VME_register_write(WUSB_udev,0x34,0x0); |
VME_register_write(WUSB_udev,0x3C,0x000); |
int nb = 0; |
int ret= xxusb_stack_execute(WUSB_udev,(uint32_t *)fInit); |
printf("Init::%d ret=%d\n",nb,ret); |
if (ret>0) for (int ki=0;ki<ret/2;ki++) printf ("stackdata=0x%08X\n",stackdata[ki]); |
int nb0= 0; //fStack->Get(10000,&stackwrite[0]); |
if (nb0>768) { |
fprintf(stderr,"nb0=%d > 768 error xxusb_stack_write\n", nb0); |
exit(-1); |
} |
nb =xxusb_stack_write(WUSB_udev,0x2,(uint32_t *) fRun); |
nb0=xxusb_stack_read(WUSB_udev,0x2,(uint32_t *) stackdata); |
for (int li=0;li<fRun[0]+1;li++){ |
if (stackdata[li]!=fRun[li]) printf("%d %d init err %x %x\n",nb,nb0,fRun[li], stackdata[li]); |
} |
if (fMode==2) xxusb_register_write(WUSB_udev,1,0x1); // Start DAQ mode |
printf("daq::init() \n"); |
return 0; |
} |
int connect(){ |
WIENER_VMUSB_VME_START(USBVME_NAME); |
if (WUSB_udev == NULL) printf("daq::connect() not initialized"); |
printf("daq::connect()\n"); |
return 0; |
} |
int disconnect(){ |
/* zakljuci */ |
WIENER_VMUSB_VME_STOP(); |
printf("daq::disconnect()\n"); |
return 0; |
} |
int clear(){ |
return 0; |
} |
int module_header(int recid,uint32_t *data,int len){ |
data[0] = recid; |
data[1] = (len >0)? len : 0 ; |
return data[1]+2; |
} |
int event(unsigned int *data, int maxn, int *ctr, int print){ |
int tout=200; /* 1/100 of a second */ |
const int lsize=sizeof(uint32_t); |
if (WUSB_udev==NULL) return -222; |
ctr[0]++; |
ctr[1]++; |
int count=0; |
switch (fMode){ |
case 0:// normal calls |
{ |
unsigned short clr= 0x4; |
unsigned int status=0; |
int32_t mdata; |
for (int i=0;i<nadc;i++){ |
// wait for trg |
tmlnk (tout); |
do WIENER_VMUSB_VME_A24D16_R( addr[i] + CAENV965_SR1, &status); while ( (status&0x1)==0 && timer_out==0 ); |
tmulk(); |
// readout data |
if (timer_out) return 0; |
int len=0; |
do { |
WIENER_VMUSB_VME_A24D32_R(addr[i] + CAENV965_OB, &mdata); |
mdata=data[count++]; |
len++; |
} while ( (mdata & 0x4000000)==0 && timer_out==0) ; // bit 26 EOB or not valid datum |
// clear |
WIENER_VMUSB_VME_A24D16_W( addr[i] + CAENV965_BS2, &clr); |
WIENER_VMUSB_VME_A24D16_W( addr[i] + CAENV965_BC2, &clr); |
if (count+2<maxn) { |
if (print) printf("V965 %3d\n",len); |
count+=module_header(0x130+i,&data[count],len); |
ctr[2]++; |
ctr[3]+=len; |
} |
timer_out=0; |
} |
} |
break; |
case 1:// stack execute |
{ |
for (int k=0;k<10000;k++) data[k]=fRun[k]; |
int ret=xxusb_stack_execute(WUSB_udev,(uint32_t *) data); //The first element of the array is the number of bytes. |
if (ret< 0 ) { |
printf ("xxusb_stack_execute error err=%d\n",ret); \ |
count = 0; |
} else count= ret/lsize; |
} |
break; |
case 2:// stack load |
{ |
int ret=xxusb_usbfifo_read(WUSB_udev,(int *) data,BUFF_L,100); |
if (ret< 0 ) { |
if (ret!=-110) { |
printf ("xxusb_usbfifo_read error err=%d\n",ret); |
end(); |
init(); |
} |
count = 0; |
} else { |
if (0 && print && ret>0) { |
for (int i=0;i<100;i++) { |
printf ("%4d fifodata=0x%08X\n",i, data[i]); |
if (data[i]==0xFAFB) break; |
} |
/* |
0 fifodata=0x0000000D |
1 fifodata=0x00000049 |
2 fifodata=0x0000FFAB |
3 fifodata=0x00002000 |
4 fifodata=0x00000200 |
5 fifodata=0x00004141 |
6 fifodata=0x00000000 |
7 fifodata=0x00004057 |
8 fifodata=0x00000010 |
9 fifodata=0x00004052 |
10 fifodata=0x00000001 |
11 fifodata=0x0000405C |
12 fifodata=0x00000011 |
13 fifodata=0x0000405D |
14 fifodata=0x00000002 |
15 fifodata=0x0000405E |
16 fifodata=0x00000012 |
17 fifodata=0x0000401C |
18 fifodata=0x00000003 |
19 fifodata=0x0000402F |
20 fifodata=0x00000013 |
21 fifodata=0x00004024 |
22 fifodata=0x00000004 |
23 fifodata=0x00004076 |
24 fifodata=0x00000014 |
25 fifodata=0x0000412F |
26 fifodata=0x00000005 |
27 fifodata=0x0000404C |
28 fifodata=0x00000015 |
29 fifodata=0x00004132 |
30 fifodata=0x00000006 |
31 fifodata=0x00004044 |
32 fifodata=0x00000016 |
33 fifodata=0x0000404A |
34 fifodata=0x00000007 |
35 fifodata=0x0000409B |
36 fifodata=0x00000017 |
37 fifodata=0x000040F1 |
38 fifodata=0x00000008 |
39 fifodata=0x00004087 |
40 fifodata=0x00000018 |
41 fifodata=0x00004173 |
42 fifodata=0x00000009 |
43 fifodata=0x0000404C |
44 fifodata=0x00000019 |
45 fifodata=0x0000406C |
46 fifodata=0x0000000A |
47 fifodata=0x00004070 |
48 fifodata=0x0000001A |
49 fifodata=0x0000406E |
50 fifodata=0x0000000B |
51 fifodata=0x00004014 |
52 fifodata=0x0000001B |
53 fifodata=0x000040B7 |
54 fifodata=0x0000000C |
55 fifodata=0x000040A9 |
56 fifodata=0x0000001C |
57 fifodata=0x00004048 |
58 fifodata=0x0000000D |
59 fifodata=0x00004118 |
60 fifodata=0x0000001D |
61 fifodata=0x0000409D |
62 fifodata=0x0000000E |
63 fifodata=0x0000405B |
64 fifodata=0x0000001E |
65 fifodata=0x00004285 |
66 fifodata=0x0000000F |
67 fifodata=0x00004159 |
68 fifodata=0x0000001F |
69 fifodata=0x00000035 |
70 fifodata=0x00000400 |
71 fifodata=0x00000035 |
72 fifodata=0x00000600 |
73 fifodata=0x00000035 |
74 fifodata=0x0000FAFB |
*/ |
} |
if (print) printf("------------------ret=%d data[0]=%d\n",ret,(int)data[0]); |
count= ret/lsize; |
ctr[2]+=data[0]; |
ctr[3]+=count; |
} |
} |
break; |
} |
return count*lsize; |
} |
int end(){ |
if (WUSB_udev!=NULL) { |
xxusb_register_write(WUSB_udev,1,0x0); // Stop DAQ mode |
while (xxusb_usbfifo_read(WUSB_udev,(int *) stackdata,BUFF_L,30)>0); |
} |
printf("daq::end()\n"); |
return 0; |
} |
int daq_init(){ |
fMode = 2; |
fPedestal=255; |
for (int i=0;i<128;i++){ |
if (i<72) fThreshold[i]= 0; |
else fThreshold[i]= 0x1<<8; // samo 4 kanali na zadnjem modulu so enablani |
} |
fThresholdEnable=0; |
fStop=0; |
//fInit=NULL; |
//fStack=NULL; |
connect(); |
return 0; |
} |
/* ------------------- CatchSig ----------------- */ |
int ctrlcflag=0; |
void SigInt (int sig) |
{ |
ctrlcflag = 1; |
timer_out=1; |
} |
int read_pedestals(char *fpedname) { |
FILE *fped=fopen(fpedname,"r"); |
if(fped==NULL) return -1; |
int j=0; |
int ndim=400; |
char line[ndim]; |
int val=0; |
while (fgets(line,ndim,fped)!=NULL) { |
sscanf(line,"%d",&val); |
fThreshold[j++]=val; |
} |
fThresholdEnable=1; |
//fclose(fped); |
fclose(fped); |
return 0; |
} |
int main (int argc, char **argv){ |
// intercept routine |
if (signal (SIGINT, SigInt) == SIG_ERR) { |
perror ("sigignore"); |
} |
// print welcome message |
time_t t,told=0, tstart, tstop; |
time(&t); |
fprintf(stdout,"#############################################\n"); |
fprintf(stdout,"Program %s version %2.1f\n",argv[0], VERSION); |
fprintf(stdout,"Compiled on %s %s\n",__DATE__, __TIME__); |
fprintf(stdout,"Runtime %s \n",ctime(&t)); |
fprintf(stdout,"#############################################\n"); |
int neve=-1; |
char cfname[100]="test.dat"; |
char *fname=cfname; |
char *fpedname=NULL; |
#define BSIZE 10000 |
uint32_t data[10000]; |
daq_init(); |
if (argc>3) { |
fpedname = argv[3]; |
read_pedestals(fpedname); |
} |
if (argc>2) neve = atoi(argv[2]); // negative argument time ( in s )limited event loop |
if (argc>1) { |
fname = argv[1]; |
if (fexist(fname)==1){ |
fprintf(stdout,"Error !\n"); |
fprintf(stdout,"File %s already exist. Appending ....\n",fname); |
//fprintf(stdout,"Remove the file and restart !!!\n"); |
//exit(0); |
} |
} |
FILE *fp=fopen(fname,"a"); |
//gzFile fp=gzopen(fname,"a"); |
init(); |
clear(); |
int hdr[4]={2}; // recid od run 11 naprej |
int i=0; |
int ntotal=0; |
int counters[30]={0,0,0,0,0, 0,0,0,0,0,0,0}; |
char names[10][20]={"TRG","CAEN V965"}; |
time(&t); |
tstart=t; |
tstop=tstart+360000; |
if (neve<-1) { |
tstop=tstart-neve; |
neve=-1; |
} |
for (i=0;i!=neve && !ctrlcflag && t<tstop;i++){ |
time(&t); |
if (t!=told ) printf("%d in %2.2f min daq::event() %s\n",i, (double)(t-tstart)/60., ctime(&t)); |
int nb=event(data,BSIZE, counters,t!=told); |
if (nb>0){ |
// zapis v datoteko |
hdr[1]=nb+4*sizeof(int); |
hdr[2]=time(NULL); |
hdr[3]=i; |
fwrite(hdr, sizeof(int),4 , fp); |
//gzwrite(fp, hdr, sizeof(int)*4); //gzip |
// recid=1 do runa 10. ntotal += fwrite(data, sizeof(int),nb, fp); |
ntotal += fwrite(data, 1,nb, fp); |
//ntotal += gzwrite(fp, data, nb); |
told=t; |
} else i--; |
} |
end(); |
printf("Number of Events: %d\n",i); |
if (ctrlcflag) printf("User Program termination CTRL-C\n"); |
if (t>tstop ) printf("Timeout termination tstart# t>tstop: %d# %d >%d\n",(int)t, (int)tstart, (int) tstop); |
fclose(fp); |
//gzclose(fp); |
fprintf(stdout,"%d bytes written to %s\nCounts:\n", (int) (ntotal*sizeof(int)),fname); |
for (i=0;i<2;i++) fprintf(stdout,"%s\t%d\t%d\n",names[i],counters[2*i],counters[2*i+1]) ; |
if (argc==1) { |
fprintf(stdout,"Usage: %s [filename] [number of events] [thresholdfile]\n negative number of events = acq time in seconds\n",argv[0]); |
} |
disconnect(); |
return 0; |
} |
/cvi/apps/petdaq/daq_cvi.h |
---|
0,0 → 1,26 |
#ifndef _daq_h_ |
#define _daq_h_ |
//#include <vector> |
//class VmUsbStack; |
//class daq { |
//public: |
// VmUsbStack * fStack; |
// VmUsbStack * fInit; |
int fPedestal; |
int fThresholdEnable; |
int fThreshold[0xFF]; |
int fStop; |
int fMode; |
int clear(); |
int end(); |
int event(unsigned int *, int,int*, int ); |
int init(); |
int daq_init(); |
int connect(); |
int disconnect(); |
int read_pedestals(char *fpedname); |
// daq(); |
// ~daq(); |
//}; |
#endif |
/cvi/apps/petdaq/vmusb.cws |
---|
0,0 → 1,196 |
[Workspace Header] |
Version = 1302 |
Pathname = "/c/home/cvi/apps/petdaq/vmusb.cws" |
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" |
CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI" |
IVI Standard Root Dir = "/C/Program Files (x86)/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 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64" |
Number of Projects = 1 |
Active Project = 1 |
Project 0001 = "vmusb.prj" |
Drag Bar Left = 202 |
Window Top = 144 |
Window Left = 1 |
Window Bottom = 996 |
Window Right = 1536 |
Maximized = False |
Maximized Children = True |
Max32 Number Of Errors = 20 |
Track Include File Dependencies = True |
Prompt For Missing Includes = True |
Stop On First Error File = False |
Bring Up Err Win At Start = True |
Bring Up Err Win For Errors = False |
Save Changes Before Running = "Always" |
Save Changes Before Compiling = "Always" |
Hide Windows = False |
Break At First Statement = False |
Sort Type = "File Name" |
Number of Opened Files = 0 |
Window Confinement Region Enabled = True |
MainColumnWidth = 185 |
FileDateColumnWidth = 70 |
FileSizeColumnWidth = 70 |
[Project Header 0001] |
Version = 1302 |
Don't Update DistKit = False |
Platform Code = 4 |
Build Configuration = "Debug" |
Warn User If Debugging Release = 1 |
Batch Build Release = False |
Batch Build Debug = False |
[File 0001] |
Path = "/c/home/cvi/instr/HISTO/H1D.fp" |
File Type = "Function Panel" |
Disk Date = 3574750011 |
In Projects = "1," |
[File 0002] |
Path = "/c/home/cvi/instr/HISTO/H2D.fp" |
File Type = "Function Panel" |
Disk Date = 3574750011 |
In Projects = "1," |
[File 0003] |
Path = "/c/home/cvi/instr/WUSBVME_DLL/wusbvme_dll.fp" |
File Type = "Function Panel" |
Disk Date = 3574750014 |
In Projects = "1," |
[File 0004] |
Path = "/c/home/cvi/apps/petdaq/daq_cvi.c" |
File Type = "CSource" |
Disk Date = 3608123860 |
In Projects = "1," |
Window Top = 33 |
Window Left = 10 |
Source Window State = "1,23,23,23,0,24,24,0,0,0,0,1,0,1,0,0,11,0,21,24,193,683,1,0," |
[File 0005] |
Path = "/c/home/cvi/apps/petdaq/vmusb_ctrl.c" |
File Type = "CSource" |
Disk Date = 3608123777 |
In Projects = "1," |
Window Top = 33 |
Window Left = 10 |
Source Window State = "1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,17,349,683,1,0," |
[File 0006] |
Path = "/c/home/cvi/instr/vme/msvc/libusb.lib" |
File Type = "Library" |
Disk Date = 3574750013 |
In Projects = "1," |
[File 0007] |
Path = "/c/home/cvi/instr/vme/msvc/vme.lib" |
File Type = "Library" |
Disk Date = 3608101166 |
In Projects = "1," |
[File 0008] |
Path = "/c/home/cvi/apps/petdaq/vmusb_ctrl.uir" |
File Type = "User Interface Resource" |
Disk Date = 3608122151 |
In Projects = "1," |
[File 0009] |
Path = "/c/home/cvi/apps/petdaq/daq_cvi.h" |
File Type = "Include" |
Disk Date = 3608097203 |
In Projects = "1," |
Source Window State = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0," |
[Default Build Config 0001 Debug] |
Generate Browse Info = False |
Enable Uninitialized Locals Runtime Warning = True |
Batch Build = False |
Profile = "Disabled" |
Debugging Level = "Standard" |
Execution Trace = "Disabled" |
Command Line Args = "" |
Working Directory = "" |
Environment Options = "" |
External Process Path = "" |
[Default Build Config 0001 Release] |
Generate Browse Info = False |
Enable Uninitialized Locals Runtime Warning = True |
Batch Build = False |
Profile = "Disabled" |
Debugging Level = "Standard" |
Execution Trace = "Disabled" |
Command Line Args = "" |
Working Directory = "" |
Environment Options = "" |
External Process Path = "" |
[Default Build Config 0001 Debug64] |
Generate Browse Info = False |
Enable Uninitialized Locals Runtime Warning = True |
Batch Build = False |
Profile = "Disabled" |
Debugging Level = "Standard" |
Execution Trace = "Disabled" |
Command Line Args = "" |
Working Directory = "" |
Environment Options = "" |
External Process Path = "" |
[Default Build Config 0001 Release64] |
Generate Browse Info = False |
Enable Uninitialized Locals Runtime Warning = True |
Batch Build = False |
Profile = "Disabled" |
Debugging Level = "Standard" |
Execution Trace = "Disabled" |
Command Line Args = "" |
Working Directory = "" |
Environment Options = "" |
External Process Path = "" |
[Build Dependencies 0001] |
Number of Dependencies = 0 |
[Build Options 0001] |
Generate Browse Info = False |
Enable Uninitialized Locals Runtime Warning = True |
Execution Trace = "Disabled" |
Profile = "Disabled" |
Debugging Level = "Standard" |
Break On Library Errors = True |
Break On First Chance Exceptions = False |
[Execution Target 0001] |
Execution Target Address = "Local desktop computer" |
Execution Target Port = 0 |
Execution Target Type = 0 |
[SCC Options 0001] |
Use global settings = True |
SCC Provider = "" |
SCC Project = "" |
Local Path = "" |
Auxiliary Path = "" |
Perform Same Action For .h File As For .uir File = "Ask" |
Perform Same Action For .cds File As For .prj File = "Ask" |
Username = "" |
Comment = "" |
Use Default Username = False |
Use Default Comment = False |
Suppress CVI Error Messages = False |
Always show confirmation dialog = True |
[DLL Debugging Support 0001] |
External Process Path = "" |
[Command Line Args 0001] |
Command Line Args = "" |
Working Directory = "" |
Environment Options = "" |
/cvi/apps/petdaq/vmusb.prj |
---|
0,0 → 1,513 |
[Project Header] |
Version = 1302 |
Pathname = "/c/home/cvi/apps/petdemo/vmusb.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" |
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 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 = 9 |
Target Type = "Executable" |
Flags = 2064 |
Copied From Locked InstrDrv Directory = False |
Copied from VXIPNP Directory = False |
Locked InstrDrv Name = "" |
Don't Display Deploy InstrDrv Dialog = False |
[Folders] |
Folder 0 = "Source Files" |
FolderEx 0 = "Source Files" |
Folder 1 = "Instrument Files" |
FolderEx 1 = "Instrument Files" |
Folder 2 = "Library Files" |
FolderEx 2 = "Library Files" |
Folder 3 = "User Interface Files" |
FolderEx 3 = "User Interface Files" |
Folder 4 = "Include Files" |
FolderEx 4 = "Include Files" |
[File 0001] |
File Type = "CSource" |
Res Id = 1 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "daq_cvi.c" |
Path = "/c/home/cvi/apps/petdemo/daq_cvi.c" |
Exclude = False |
Compile Into Object File = False |
Project Flags = 0 |
Folder = "Source Files" |
Folder Id = 0 |
[File 0002] |
File Type = "CSource" |
Res Id = 2 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "vmusb_ctrl.c" |
Path = "/c/home/cvi/apps/petdemo/vmusb_ctrl.c" |
Exclude = False |
Compile Into Object File = False |
Project Flags = 0 |
Folder = "Source Files" |
Folder Id = 0 |
[File 0003] |
File Type = "Function Panel" |
Res Id = 3 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "../../instr/HISTO/H1D.fp" |
Path = "/c/home/cvi/instr/HISTO/H1D.fp" |
Exclude = False |
Project Flags = 0 |
Folder = "Instrument Files" |
Folder Id = 1 |
[File 0004] |
File Type = "Function Panel" |
Res Id = 4 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "../../instr/HISTO/H2D.fp" |
Path = "/c/home/cvi/instr/HISTO/H2D.fp" |
Exclude = False |
Project Flags = 0 |
Folder = "Instrument Files" |
Folder Id = 1 |
[File 0005] |
File Type = "Function Panel" |
Res Id = 5 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "../../instr/WUSBVME_DLL/wusbvme_dll.fp" |
Path = "/c/home/cvi/instr/WUSBVME_DLL/wusbvme_dll.fp" |
Exclude = False |
Project Flags = 0 |
Folder = "Instrument Files" |
Folder Id = 1 |
[File 0006] |
File Type = "Library" |
Res Id = 6 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "../../instr/vme/msvc/libusb.lib" |
Path = "/c/home/cvi/instr/vme/msvc/libusb.lib" |
Exclude = False |
Project Flags = 0 |
Folder = "Library Files" |
Folder Id = 2 |
[File 0007] |
File Type = "Library" |
Res Id = 7 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "../../instr/vme/msvc/vme.lib" |
Path = "/c/home/cvi/instr/vme/msvc/vme.lib" |
Exclude = False |
Project Flags = 0 |
Folder = "Library Files" |
Folder Id = 2 |
[File 0008] |
File Type = "User Interface Resource" |
Res Id = 8 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "vmusb_ctrl.uir" |
Path = "/c/home/cvi/apps/petdemo/vmusb_ctrl.uir" |
Exclude = False |
Project Flags = 0 |
Folder = "User Interface Files" |
Folder Id = 3 |
[File 0009] |
File Type = "Include" |
Res Id = 9 |
Path Is Rel = True |
Path Rel To = "Project" |
Path Rel Path = "daq_cvi.h" |
Path = "/c/home/cvi/apps/petdemo/daq_cvi.h" |
Exclude = False |
Project Flags = 0 |
Folder = "Include Files" |
Folder Id = 4 |
[Custom Build Configs] |
Num Custom Build Configs = 0 |
[Default Build Config Debug] |
Config Name = "Debug" |
Is 64-Bit = False |
Is Release = False |
Default Calling Convention = "cdecl" |
Optimization Level = "Optimize for speed (level 2)" |
Require Prototypes = True |
Show Warning IDs in Build Output = False |
Selected Warning Level = "None" |
Warning List None = "4,9,84,105,106,107,108,109,110,111" |
Warning List Common = "" |
Warning List Extended = "" |
Warning List All = "" |
Warning Mode = 0 |
Enable Unreferenced Identifiers Warning = False |
Enable Pointer Mismatch Warning = False |
Enable Unreachable Code Warning = False |
Enable Assignment In Conditional Warning = False |
Uninitialized Locals Compile Warning = "Aggressive" |
Require Return Values = True |
Enable C99 Extensions = False |
Enable OpenMP Extensions = False |
Stack Size = 250000 |
Stack Reserve = 1048576 |
Stack Commit = 4096 |
Image Base Address = 4194304 |
Image Base Address x64 = 4194304 |
Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DWUSBVME" |
Sign = False |
Sign Store = "" |
Sign Certificate = "" |
Sign Timestamp URL = "" |
Sign URL = "" |
Manifest Embed = False |
Icon File Is Rel = False |
Icon File = "" |
Application Title = "" |
Use IVI Subdirectories for Import Libraries = False |
Use VXIPNP Subdirectories for Import Libraries = False |
Use Dflt Import Lib Base Name = True |
Where to Copy DLL = "Do not copy" |
Custom Directory to Copy DLL Is Rel = False |
Custom Directory to Copy DLL = "" |
Generate Source Documentation = "None" |
Runtime Support = "Full Runtime Support" |
Runtime Binding = "Shared" |
Embed Project .UIRs = False |
Generate Map File = False |
Embed Timestamp = True |
Create Console Application = False |
Using LoadExternalModule = False |
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 = "vmusb (Debug x86)" |
File Description Ex = "%application (%rel_dbg %arch)" |
File Version = "1.0" |
File Version Ex = "%f1.%f2" |
Internal Name = "vmusb" |
Internal Name Ex = "%basename" |
Legal Copyright = "Copyright © 2018" |
Legal Copyright Ex = "Copyright © %company %Y" |
Legal Trademarks = "" |
Legal Trademarks Ex = "" |
Original Filename = "vmusb.exe" |
Original Filename Ex = "%filename" |
Private Build = "" |
Private Build Ex = "" |
Product Name = " vmusb" |
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" |
Type Lib FP File Is Rel = False |
Type Lib FP File = "" |
[Default Build Config Release] |
Config Name = "Release" |
Is 64-Bit = False |
Is Release = True |
Default Calling Convention = "cdecl" |
Optimization Level = "Optimize for speed (level 2)" |
Require Prototypes = True |
Show Warning IDs in Build Output = False |
Selected Warning Level = "None" |
Warning List None = "4,9,84,105,106,107,108,109,110,111" |
Warning List Common = "" |
Warning List Extended = "" |
Warning List All = "" |
Warning Mode = 0 |
Enable Unreferenced Identifiers Warning = False |
Enable Pointer Mismatch Warning = False |
Enable Unreachable Code Warning = False |
Enable Assignment In Conditional Warning = False |
Uninitialized Locals Compile Warning = "Aggressive" |
Require Return Values = True |
Enable C99 Extensions = False |
Enable OpenMP Extensions = False |
Stack Size = 250000 |
Stack Reserve = 1048576 |
Stack Commit = 4096 |
Image Base Address = 4194304 |
Image Base Address x64 = 4194304 |
Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DWIENVME" |
Sign = False |
Sign Store = "" |
Sign Certificate = "" |
Sign Timestamp URL = "" |
Sign URL = "" |
Manifest Embed = False |
Icon File Is Rel = False |
Icon File = "" |
Application Title = "" |
Use IVI Subdirectories for Import Libraries = False |
Use VXIPNP Subdirectories for Import Libraries = False |
Use Dflt Import Lib Base Name = True |
Where to Copy DLL = "Do not copy" |
Custom Directory to Copy DLL Is Rel = False |
Custom Directory to Copy DLL = "" |
Generate Source Documentation = "None" |
Runtime Support = "Full Runtime Support" |
Runtime Binding = "Shared" |
Embed Project .UIRs = False |
Generate Map File = False |
Embed Timestamp = True |
Create Console Application = False |
Using LoadExternalModule = False |
DLL Exports = "Include File Symbols" |
Register ActiveX Server = False |
Add Type Lib To DLL = False |
Include Type Lib Help Links = False |
TLB Help Style = "HLP" |
Type Lib FP File Is Rel = False |
Type Lib FP File = "" |
[Default Build Config Debug64] |
Config Name = "Debug64" |
Is 64-Bit = True |
Is Release = False |
Default Calling Convention = "cdecl" |
Optimization Level = "Optimize for speed (level 2)" |
Require Prototypes = True |
Show Warning IDs in Build Output = False |
Selected Warning Level = "None" |
Warning List None = "4,9,84,105,106,107,108,109,110,111" |
Warning List Common = "" |
Warning List Extended = "" |
Warning List All = "" |
Warning Mode = 0 |
Enable Unreferenced Identifiers Warning = False |
Enable Pointer Mismatch Warning = False |
Enable Unreachable Code Warning = False |
Enable Assignment In Conditional Warning = False |
Uninitialized Locals Compile Warning = "Aggressive" |
Require Return Values = True |
Enable C99 Extensions = False |
Enable OpenMP Extensions = False |
Stack Size = 250000 |
Stack Reserve = 1048576 |
Stack Commit = 4096 |
Image Base Address = 4194304 |
Image Base Address x64 = 4194304 |
Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DWIENVME" |
Sign = False |
Sign Store = "" |
Sign Certificate = "" |
Sign Timestamp URL = "" |
Sign URL = "" |
Manifest Embed = False |
Icon File Is Rel = False |
Icon File = "" |
Application Title = "" |
Use IVI Subdirectories for Import Libraries = False |
Use VXIPNP Subdirectories for Import Libraries = False |
Use Dflt Import Lib Base Name = True |
Where to Copy DLL = "Do not copy" |
Custom Directory to Copy DLL Is Rel = False |
Custom Directory to Copy DLL = "" |
Generate Source Documentation = "None" |
Runtime Support = "Full Runtime Support" |
Runtime Binding = "Shared" |
Embed Project .UIRs = False |
Generate Map File = False |
Embed Timestamp = True |
Create Console Application = False |
Using LoadExternalModule = False |
DLL Exports = "Include File Symbols" |
Register ActiveX Server = False |
Add Type Lib To DLL = False |
Include Type Lib Help Links = False |
TLB Help Style = "HLP" |
Type Lib FP File Is Rel = False |
Type Lib FP File = "" |
[Default Build Config Release64] |
Config Name = "Release64" |
Is 64-Bit = True |
Is Release = True |
Default Calling Convention = "cdecl" |
Optimization Level = "Optimize for speed (level 2)" |
Require Prototypes = True |
Show Warning IDs in Build Output = False |
Selected Warning Level = "None" |
Warning List None = "4,9,84,105,106,107,108,109,110,111" |
Warning List Common = "" |
Warning List Extended = "" |
Warning List All = "" |
Warning Mode = 0 |
Enable Unreferenced Identifiers Warning = False |
Enable Pointer Mismatch Warning = False |
Enable Unreachable Code Warning = False |
Enable Assignment In Conditional Warning = False |
Uninitialized Locals Compile Warning = "Aggressive" |
Require Return Values = True |
Enable C99 Extensions = False |
Enable OpenMP Extensions = False |
Stack Size = 250000 |
Stack Reserve = 1048576 |
Stack Commit = 4096 |
Image Base Address = 4194304 |
Image Base Address x64 = 4194304 |
Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DWIENVME" |
Sign = False |
Sign Store = "" |
Sign Certificate = "" |
Sign Timestamp URL = "" |
Sign URL = "" |
Manifest Embed = False |
Icon File Is Rel = False |
Icon File = "" |
Application Title = "" |
Use IVI Subdirectories for Import Libraries = False |
Use VXIPNP Subdirectories for Import Libraries = False |
Use Dflt Import Lib Base Name = True |
Where to Copy DLL = "Do not copy" |
Custom Directory to Copy DLL Is Rel = False |
Custom Directory to Copy DLL = "" |
Generate Source Documentation = "None" |
Runtime Support = "Full Runtime Support" |
Runtime Binding = "Shared" |
Embed Project .UIRs = False |
Generate Map File = False |
Embed Timestamp = True |
Create Console Application = False |
Using LoadExternalModule = False |
DLL Exports = "Include File Symbols" |
Register ActiveX Server = False |
Add Type Lib To DLL = False |
Include Type Lib Help Links = False |
TLB Help Style = "HLP" |
Type Lib FP File Is Rel = False |
Type Lib FP File = "" |
[Compiler Options] |
Default Calling Convention = "cdecl" |
Require Prototypes = True |
Require Return Values = True |
Enable Pointer Mismatch Warning = False |
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 = "Aggressive" |
Precompile Prefix Header = False |
Prefix Header File = "" |
[Run Options] |
Stack Size = 250000 |
Stack Commit = 4096 |
Image Base Address = 4194304 |
Image Base Address x64 = 4194304 |
[Compiler Defines] |
Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DWIENVME" |
[Include Paths] |
Include Path 1 Is Rel = True |
Include Path 1 Rel To = "Project" |
Include Path 1 Rel Path = "../../instr/CAENV965" |
Include Path 1 = "/c/home/cvi/instr/CAENV965" |
[Create Executable] |
Executable File_Debug Is Rel = True |
Executable File_Debug Rel To = "Project" |
Executable File_Debug Rel Path = "vmusb.exe" |
Executable File_Debug = "/c/home/cvi/apps/petdemo/vmusb.exe" |
Executable File_Release Is Rel = True |
Executable File_Release Rel To = "Project" |
Executable File_Release Rel Path = "vmusb.exe" |
Executable File_Release = "/c/home/cvi/apps/petdemo/vmusb.exe" |
Executable File_Debug64 Is Rel = True |
Executable File_Debug64 Rel To = "Project" |
Executable File_Debug64 Rel Path = "vmusb.exe" |
Executable File_Debug64 = "/c/home/cvi/apps/petdemo/vmusb.exe" |
Executable File_Release64 Is Rel = True |
Executable File_Release64 Rel To = "Project" |
Executable File_Release64 Rel Path = "vmusb.exe" |
Executable File_Release64 = "/c/home/cvi/apps/petdemo/vmusb.exe" |
Icon File Is Rel = False |
Icon File = "" |
Application Title = "" |
DLL Exports = "Include File Symbols" |
Use IVI Subdirectories for Import Libraries = False |
Use VXIPNP Subdirectories for Import Libraries = False |
Use Dflt Import Lib Base Name = True |
Where to Copy DLL = "Do not copy" |
Custom Directory to Copy DLL Is Rel = False |
Custom Directory to Copy DLL = "" |
Generate Source Documentation = "None" |
Add Type Lib To DLL = False |
Include Type Lib Help Links = False |
TLB Help Style = "HLP" |
Type Lib FP File Is Rel = False |
Type Lib FP File = "" |
Type Lib Guid = "" |
Runtime Support = "Full Runtime Support" |
Instrument Driver Support Only = False |
Embed Project .UIRs = False |
Generate Map File = False |
[External Compiler Support] |
UIR Callbacks File Option = 0 |
Using LoadExternalModule = False |
Create Project Symbols File = True |
UIR Callbacks Obj File Is Rel = False |
UIR Callbacks Obj File = "" |
Project Symbols H File Is Rel = False |
Project Symbols H File = "" |
Project Symbols Obj File Is Rel = False |
Project Symbols Obj File = "" |
[ActiveX Server Options] |
Specification File Is Rel = False |
Specification File = "" |
Source File Is Rel = False |
Source File = "" |
Include File Is Rel = False |
Include File = "" |
IDL File Is Rel = False |
IDL File = "" |
Register ActiveX Server = False |
[Signing Info] |
Sign = False |
Sign Debug Build = False |
Store = "" |
Certificate = "" |
Timestamp URL = "" |
URL = "" |
[Manifest Info] |
Embed = False |
[tpcSection] |
tpcEnabled = 0 |
tpcOverrideEnvironment = 0 |
tpcEnabled x64 = 0 |
tpcOverrideEnvironment x64 = 0 |
/cvi/apps/petdaq/vmusb_ctrl.c |
---|
0,0 → 1,558 |
#include <formatio.h> |
#include "H1D.h" |
#include "H2D.h" |
#include <utility.h> |
#include <ansi_c.h> |
#include <cvirte.h> |
#include <userint.h> |
#include "vmusb_ctrl.h" |
#include "daq_cvi.h" |
static int p1, p2, p3; |
static int daq_on; |
static int plothandle[4]= {0,0,0, 0}; |
static int tfID; |
static int controlID; |
static int verbose; |
static int timeout; |
extern int ctrlcflag; |
#define MAX_THREADS 10 |
static CmtThreadPoolHandle poolHandle = 0; |
#define MAXCH 72 |
float gSum[6]; |
float gRawSum[6]; |
float gMax[6]; |
float gSumCluster[6]; |
float gNtdata[MAXCH*3]; |
int gNabove[5]; |
double gData[MAXCH]; // korigirani ADC ji |
double gAdc[MAXCH]; // raw ADC ji |
double gPedestals[MAXCH]; |
double gPeak[MAXCH]; |
double gPeakScaling; |
double gThreshold; |
typedef struct Channel { |
int ix; |
int iy; |
int idx; |
}; |
struct Channel m_geo_ch[16]; |
char strbuf[0xFF]; |
int gLog=0; |
int printf(const char *format, ...) { |
va_list aptr; |
int ret; |
FILE *flog; |
va_start(aptr, format); |
ret = vsprintf(strbuf, format, aptr); |
va_end(aptr); |
SetCtrlVal(p1,P1_IO,strbuf); |
if (gLog) { |
flog = fopen ("stdio.log", "a"); |
fprintf (flog, "%s", strbuf); |
fclose (flog); |
} |
return(ret); |
} |
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
LPSTR lpszCmdLine, int nCmdShow) { |
if (InitCVIRTE (hInstance, 0, 0) == 0) |
return -1; /* out of memory */ |
if ((p1 = LoadPanel (0, "vmusb_ctrl.uir", P1)) < 0) |
return -1; |
if ((p2 = LoadPanel (0, "vmusb_ctrl.uir", P2)) < 0) |
return -1; |
if ((p3 = LoadPanel (0, "vmusb_ctrl.uir", P3)) < 0) |
return -1; |
SetStdioPort (CVI_STDIO_WINDOW); |
SetSleepPolicy(VAL_SLEEP_MORE); |
CmtNewThreadPool (MAX_THREADS, &poolHandle); |
DisplayPanel (p1); |
RunUserInterface (); |
DiscardPanel (p1); |
DiscardPanel (p2); |
DiscardPanel (p3); |
return 0; |
} |
static void start_timer (double tout) { |
timeout = 0; |
SetCtrlAttribute (p1, P1_TIMER, ATTR_INTERVAL, tout); |
SetCtrlAttribute (p1, P1_TIMER, ATTR_ENABLED, 1); |
} |
static void stop_timer ( void ) { |
SetCtrlAttribute (p1, P1_TIMER, ATTR_ENABLED, 0); |
//DRSSetTimeout(); |
} |
int georead(){ |
int i; |
for (i=0; i<64; i++) { |
int row=i+1; |
double val; |
unsigned short sval; |
GetTableCellVal (p3, P3_CGEO, MakePoint (3,row), &sval); |
fThreshold[i]=sval; |
GetTableCellVal (p3, P3_CGEO, MakePoint (4,row), &val); |
gPeak[i]=val; |
GetTableCellVal (p3, P3_CGEO, MakePoint (5,row), &val); |
gPedestals[i]=val; |
} |
GetCtrlVal(p3, P3_PEAKSCALING, &gPeakScaling ); |
GetCtrlVal(p3, P3_GTHRESHOLD, &gThreshold ); |
for (i=0; i<16; i++) { |
int row=i+1; |
double val; |
unsigned short sval, id; |
GetTableCellVal (p3, P3_CGEO, MakePoint (1,row), &id); |
GetTableCellVal (p3, P3_CGEO, MakePoint (2,row), &sval); |
m_geo_ch[id].ix=sval; |
GetTableCellVal (p3, P3_CGEO, MakePoint (3,row), &sval); |
m_geo_ch[id].iy=sval; |
m_geo_ch[id].idx=id; |
} |
return 0; |
} |
void CVICALLBACK EndOfThread ( CmtThreadPoolHandle poolhandle, |
CmtThreadFunctionID functionID, unsigned int event, |
int value, void *callbackData ) { |
daq_on=0; |
//SetDimming(0); |
printf("End of Thread \n"); |
return ; |
} |
int CVICALLBACK RefreshGraphs (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_TIMER_TICK: |
// if (!daq_on ) return 0; |
case EVENT_COMMIT: { |
int ch=0; |
int logy=0; |
int pmt =0; |
int updateplots=0; |
GetCtrlVal(p1,P1_RECO, &updateplots); |
if (!updateplots) return 0; |
GetCtrlVal(p2,P2_PMT, &pmt); |
GetCtrlVal(p2,P2_ADC, &ch); |
H1D_Draw(10,p2,P2_GRAPHADC,&plothandle[1]); |
H2D_Draw(0,p2,P2_GRAPH2D,&plothandle[2]); |
} |
break; |
} |
return 0; |
} |
int vmusb_init(){ |
int range = 2056; |
for (int i=0; i<MAXCH; i++) { |
char name[0xFF]; |
sprintf(name,"adc%d", i); |
H1D_Init(i, name,name, range, 0 , range); |
H1D_SetTitleX(0,"ADC"); |
H1D_SetTitleY(0,"N"); |
sprintf(name,"adc%d", i); |
sprintf(name,"energy%d", i); |
H1D_Init(100+i, name,name, range, 0 , range); |
H1D_SetTitleX(0,"Energy"); |
H1D_SetTitleY(0,"N"); |
} |
H2D_Init(0, "cog","Center of grg_peakscalingavity", 256, 0 ,1, 256, 0 ,1); |
H2D_SetTitleX(0,"x"); |
H2D_SetTitleY(0,"y"); |
return 0; |
} |
double GetEnergy(int ch, int adc){ |
return (adc-gPedestals[ch])/(gPeak[ch]-gPedestals[ch])*gPeakScaling; |
} |
int FillHistograms() { |
int npmts = 4; |
for (int ipmt=0; ipmt<npmts; ipmt++) { // zanka preko pmtjev |
int j2= (ipmt/2)*2+1-ipmt%2; // sosednja fotopomnozevalka |
float posx[2]= {0,0}; |
float posy[2]= {0,0}; |
float sum[2]= {0,0}; |
float m_threshold =100; |
for (int ich=0; ich<16; ich++) { // zanka preko elektronskih kanalov na fotopomnozevalki |
int ch= ich+ipmt*16; |
if (gMax[ipmt]>m_threshold) { |
posx[0]+= gData[ch]*m_geo_ch[ich].ix; |
posy[0]+= gData[ch]*m_geo_ch[ich].iy; |
sum[0] += gData[ch]; |
if (gData[ch]> 0.2*gMax[ipmt]) { // pri racunanju pozicije upostevaj le kanale, ki imajo vrednost vecjo od ratio*maksimalna na tisti fotopomnozevalki |
posx[1]+= gData[ch]*m_geo_ch[ich].ix; |
posy[1]+= gData[ch]*m_geo_ch[ich].iy; |
sum[1] += gData[ch]; |
} |
} |
} |
if ( sum[0] > 0 ) { |
float px=posx[0]/sum[0]; |
float py=posy[0]/sum[0]; |
H2D_Fill(0, px,py,1); |
} |
} |
return 0; |
}; |
int DecodeData(int n, unsigned int *buf){ |
int idx=1; |
int neve=buf[0]/2; |
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
for (int nev=0;nev<neve;nev++){ |
int len=buf[idx]; |
int sb =buf[idx+1]; |
unsigned int *pbuf=&buf[idx+2]; |
if (sb!=0xffab) { |
printf("0x%04x!0xffab len=%d\n",sb,len); |
break; |
} |
// postavi na nic |
#define InitArrayWithAValue(arr,n,x) {for (int i=0;i<n;i++) arr[i]=x;} |
InitArrayWithAValue( gSum , 4 , 0); |
InitArrayWithAValue( gRawSum , 4 , 0); |
InitArrayWithAValue( gMax , 4 , 0); |
InitArrayWithAValue( gSumCluster, 4 , 0); |
InitArrayWithAValue( gNabove , 4 , 0); |
InitArrayWithAValue( gData , MAXCH, 0); |
InitArrayWithAValue( gAdc , MAXCH, 0); |
//------------------------------------------------------------ |
for (int i0=0;i0<len-2;i0+=2) { |
int data0 = pbuf[i0]; |
int data1 = pbuf[i0+1]; |
int geo = (data1 >> 11) & 0x1f; |
int ch = (data1&0x1f) | (geo<<5); |
int dtype = (data1>>9)&0x3; |
int adc = data0&0xfff; |
switch (dtype) { |
case 0x0: |
if (ch<MAXCH) { |
H1D_Fill(ch,adc,1); |
int ipmt = ch/16; |
gAdc[ch]=adc; |
gRawSum[ipmt]+=adc; |
if (ch<64) gData[ch]= GetEnergy(ch,adc); else gData[ch]=adc; |
H1D_Fill(1+ch,gData[ch],1); |
gSum[ipmt]+=gData[ch]; |
if (gData[ch] >gMax[ipmt] ) gMax[ipmt]= gData[ch]; |
if (gData[ch] >gThreshold ) gNabove[ipmt]++; |
} |
break; |
case 0x10: |
case 0x11: |
case 0x01: |
break; |
} |
};// for (int i0=0;i0<len-2;i0+=2) |
//------------------------------------------------------------ |
idx+=len+1; |
FillHistograms(); |
} // for (int nev=0;nev<neve;nev++) |
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
return 0; |
} |
int vmusb_daq(){ |
vmusb_init(); |
// print welcome message |
time_t t,told=0, tstart, tstop; |
time(&t); |
printf("#############################################\n"); |
printf("Program vmusb version\n"); |
printf("Compiled on %s %s\n",__DATE__, __TIME__); |
printf("Runtime %s \n",ctime(&t)); |
printf("#############################################\n"); |
int neve=-1; |
char cfname[100]="test.dat"; |
char fname[0xff]; |
char fpedname[0xff]; |
#define BSIZE 10000 |
uint32_t data[10000]; |
int oldValue; |
//oldValue = SetBreakOnLibraryErrors (0); |
daq_init(); /* Function calls that may legitimately return errors. */ |
//SetBreakOnLibraryErrors (oldValue); |
int output=0; |
GetCtrlVal(p1,P1_OUTPUT, &output); |
GetCtrlVal(p1,P1_FMASK, fpedname); |
int fsize=0; |
georead(); |
GetCtrlVal(p1,P1_NEVE, &neve); |
// negative argument time ( in s )limited event loop |
GetCtrlVal(p1,P1_FNAME, fname); |
if (GetFileInfo(fname,&fsize)==1) { |
printf("Error !\n"); |
printf( "File %s already exist. Appending ....\n",fname); |
//fprintf(stdout,"Remove the file and restart !!!\n"); |
//exit(0); |
} |
FILE *fp=NULL; |
if (output) fp = fopen(fname,"a"); |
//gzFile fp=gzopen(fname,"a"); |
init(); |
clear(); |
int hdr[4]={2}; // recid od run 11 naprej |
int i=0; |
int ntotal=0; |
int counters[30]={0,0,0,0,0, 0,0,0,0,0,0,0}; |
char names[10][20]={"TRG","CAEN V965"}; |
time(&t); |
tstart=t; |
tstop=tstart+360000; |
int evetype=0; |
GetCtrlVal(p1,P1_EVE, &evetype); |
if (evetype) { |
double ntime=0; |
GetCtrlVal(p1,P1_NTIME, &ntime); |
tstop=tstart+ntime; |
neve=-1; |
} |
int reco=0; |
GetCtrlVal(p1,P1_RECO, &reco); |
for (i=0;i!=neve && !ctrlcflag && t<tstop;i++){ |
time(&t); |
if (t!=told ) { |
printf("%d in %2.2f min daq::event() %s\n",i, (double)(t-tstart)/60., ctime(&t)); |
GetCtrlVal(p1,P1_RECO, &reco); |
RefreshGraphs(p2,P2_PMT,EVENT_COMMIT,NULL,0,0); |
} |
int nb=event(data,BSIZE, counters,t!=told); |
SetCtrlVal(p1,P1_CEVE,i); |
if (nb>0){ |
if (reco) DecodeData(nb, data); |
// zapis v datoteko |
hdr[1]=nb+4*sizeof(int); |
hdr[2]=time(NULL); |
hdr[3]=i; |
if (fp) fwrite(hdr, sizeof(int),4 , fp); |
if (fp) ntotal += fwrite(data, 1,nb, fp); |
} else i--; |
told=t; |
} |
end(); |
printf("Number of Events: %d\n",i); |
if (ctrlcflag) printf("User Program termination CTRL-C\n"); |
if (t>tstop ) printf("Timeout termination tstart# t>tstop: %d# %d >%d\n",(int)t, (int)tstart, (int) tstop); |
if (fp) fclose(fp); |
//gzclose(fp); |
printf("%d bytes written to %s\nCounts:\n", (int) (ntotal*sizeof(int)),fname); |
for (i=0;i<2;i++) printf("%s\t%d\t%d\n",names[i],counters[2*i],counters[2*i+1]) ; |
printf("Usage: vmusb [filename] [number of events] [thresholdfile]\n negative number of events = acq time in seconds\n"); |
disconnect(); |
return 0; |
} |
int CVICALLBACK StartCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
ThreadFunctionPtr mythread = NULL; |
switch (event) { |
case EVENT_COMMIT: |
controlID= control; |
if (panel == p1 && control == P1_START) { |
mythread = vmusb_daq; |
} |
//if (panel == xyscan && control == SCAN_SCAN) mythread = scan; |
if (mythread!=NULL) { |
printf("New Thread panel=%d button=%d\n", panel, control); |
// SetDimming(1); |
CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &controlID, |
DEFAULT_THREAD_PRIORITY, |
EndOfThread, |
EVENT_TP_THREAD_FUNCTION_END, |
NULL, RUN_IN_SCHEDULED_THREAD, |
&tfID); |
} |
break; |
} |
return 0; |
} |
int CVICALLBACK StopCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT: |
ctrlcflag=1; |
break; |
} |
return 0; |
} |
int CVICALLBACK ExitCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT: |
QuitUserInterface (0); |
break; |
} |
return 0; |
} |
int CVICALLBACK ShowHistoCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT: |
DisplayPanel (p2); |
break; |
} |
return 0; |
} |
int CVICALLBACK SetLogZCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT: |
GetCtrlVal(panel,control, &log); |
if (log) { |
SetCtrlAttribute (p2, P2_GRAPH2D, ATTR_YMAP_MODE, VAL_LOG); |
} else { |
SetCtrlAttribute (p2, P2_GRAPH2D, ATTR_YMAP_MODE, VAL_LINEAR); |
} |
break; |
} |
return 0; |
} |
int CVICALLBACK SetLogYCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT:{ |
int log=0; |
GetCtrlVal(panel,control, &log); |
if (log) { |
SetCtrlAttribute (p2, P2_GRAPHADC, ATTR_YMAP_MODE, VAL_LOG); |
} else { |
SetCtrlAttribute (p2, P2_GRAPHADC, ATTR_YMAP_MODE, VAL_LINEAR); |
} |
} |
break; |
} |
return 0; |
} |
int CVICALLBACK ShowMainCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT: |
DisplayPanel (p1); |
break; |
} |
return 0; |
} |
int CVICALLBACK ShowSettingsCB (int panel, int control, int event, |
void *callbackData, int eventData1, int eventData2) { |
switch (event) { |
case EVENT_COMMIT: |
DisplayPanel (p3); |
break; |
} |
return 0; |
} |
/cvi/apps/petdaq/vmusb_ctrl.h |
---|
0,0 → 1,78 |
/**************************************************************************/ |
/* LabWindows/CVI User Interface Resource (UIR) Include File */ |
/* */ |
/* WARNING: Do not add to, delete from, or otherwise modify the contents */ |
/* of this include file. */ |
/**************************************************************************/ |
#include <userint.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* Panels and Controls: */ |
#define P1 1 |
#define P1_EXIT 2 /* control type: command, callback function: ExitCB */ |
#define P1_SHOWSETTINGS 3 /* control type: command, callback function: ShowSettingsCB */ |
#define P1_STOP 4 /* control type: command, callback function: StopCB */ |
#define P1_START 5 /* control type: command, callback function: StartCB */ |
#define P1_DX 6 /* control type: numeric, callback function: (none) */ |
#define P1_X0 7 /* control type: numeric, callback function: (none) */ |
#define P1_NX 8 /* control type: numeric, callback function: (none) */ |
#define P1_NTIME 9 /* control type: numeric, callback function: (none) */ |
#define P1_NEVE 10 /* control type: numeric, callback function: (none) */ |
#define P1_EVE 11 /* control type: binary, callback function: (none) */ |
#define P1_SHOWHISTO 12 /* control type: command, callback function: ShowHistoCB */ |
#define P1_FMASK 13 /* control type: string, callback function: (none) */ |
#define P1_FNAME 14 /* control type: string, callback function: (none) */ |
#define P1_OUTPUT 15 /* control type: radioButton, callback function: (none) */ |
#define P1_RECO 16 /* control type: radioButton, callback function: (none) */ |
#define P1_CEVE 17 /* control type: numeric, callback function: (none) */ |
#define P1_IO 18 /* control type: textBox, callback function: (none) */ |
#define P1_TIMER 19 /* control type: timer, callback function: (none) */ |
#define P2 2 |
#define P2_GRAPHADC 2 /* control type: graph, callback function: (none) */ |
#define P2_GRAPH2D 3 /* control type: graph, callback function: (none) */ |
#define P2_ADC 4 /* control type: numeric, callback function: RefreshGraphs */ |
#define P2_PMT 5 /* control type: numeric, callback function: RefreshGraphs */ |
#define P2_LOGZ 6 /* control type: radioButton, callback function: SetLogZCB */ |
#define P2_LOGY 7 /* control type: radioButton, callback function: SetLogYCB */ |
#define P2_SHOWMAIN 8 /* control type: command, callback function: ShowMainCB */ |
#define P3 3 |
#define P3_CGEO_2 2 /* control type: table, callback function: (none) */ |
#define P3_CGEO 3 /* control type: table, callback function: (none) */ |
#define P3_SHOWMAIN 4 /* control type: command, callback function: ShowMainCB */ |
#define P3_GTHRESHOLD 5 /* control type: numeric, callback function: (none) */ |
#define P3_PEAKSCALING 6 /* control type: numeric, callback function: (none) */ |
/* Control Arrays: */ |
/* (no control arrays in the resource file) */ |
/* Menu Bars, Menus, and Menu Items: */ |
/* (no menu bars in the resource file) */ |
/* Callback Prototypes: */ |
int CVICALLBACK ExitCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK RefreshGraphs(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK SetLogYCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK SetLogZCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK ShowHistoCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK ShowMainCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK ShowSettingsCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK StartCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
int CVICALLBACK StopCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); |
#ifdef __cplusplus |
} |
#endif |
/cvi/apps/petdaq/vmusb_ctrl.uir |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |