Subversion Repositories f9daq

Compare Revisions

No changes between revisions

Ignore whitespace Rev 58 → Rev 59

/ICFA/rich/rich.prj
0,0 → 1,215
[Project Header]
Version = 551
Platform Code = 4
Pathname = "/c/ICFA/2014/rich/rich.prj"
CVI Dir = "/c/measurementstudio/cvi"
VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
Number of Files = 4
Sort Type = "No Sort"
Target Type = "Executable"
Build Configuration = "Debug"
Warn User If Debugging Release = 1
Flags = 16
Drag Bar Left = 158
Window Top = 102
Window Left = 324
Window Bottom = 500
Window Right = 1000
 
[File 0001]
File Type = "CSource"
Path = "/c/ICFA/2014/rich/rich.c"
Res Id = 1
Exclude = False
Disk Date = 3493032330
Project Flags = 0
Compile Into Object File = False
Object Format = "Win32-MSVC"
ForceCompile_Debug = False
ForceCompile_Release = True
Window Top = 296
Window Left = 244
Window Height = 0
Window Width = 0
Source Window State = "1,23,23,23,20,20,20,0,0,110,0,0,0,0,0,38,0,0,28,45,"
Header Dependencies Line0001 = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,25,26,27,28,29,30,31"
Header Dependencies Line0002 = ",32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,"
 
[File 0002]
File Type = "User Interface Resource"
Path = "/c/ICFA/2014/rich/rich_ui.uir"
Res Id = 2
Exclude = False
Disk Date = 3493023287
Project Flags = 0
Window Top = 12
Window Left = 9
Window Height = 882
Window Width = 1420
 
[File 0003]
File Type = "Function Panel"
Path = "/c/MeasurementStudio/cvi/instr/WUSBVME_DLL/wusbvme_dll.fp"
Res Id = 3
Exclude = False
Disk Date = 3292542496
Project Flags = 0
Window Top = 0
Window Left = 0
Window Height = 0
Window Width = 0
 
[File 0004]
File Type = "Function Panel"
Path = "/c/MeasurementStudio/cvi/instr/CAENV673A/CAENV673A.fp"
Res Id = 4
Exclude = False
Disk Date = 3244094710
Project Flags = 0
Window Top = 0
Window Left = 0
Window Height = 0
Window Width = 0
 
[SCC Options]
Use global settings = True
SCC Provider = ""
SCC Project = ""
Local Path = ""
Auxiliary Path = ""
Perform Same Action For .h File As For .uir File = "Ask"
Comment = ""
Username = ""
Use Default Comment = False
Use Default Username = False
Do Not Include PRJ File in Actions = True
Suppress CVI Error Messages = False
 
[Compiler Options]
Default Calling Convention = "cdecl"
Max Number Of Errors = 10
Require Prototypes = True
Require Return Values = True
Enable Pointer Mismatch Warning = False
Enable Unreachable Code Warning = False
Track Include File Dependencies = True
Prompt For Missing Includes = True
Stop On First Error File = False
Bring Up Err Win For Warnings = True
Show Build Dialog = False
O Option Compatible With 5.0 = False
 
[Run Options]
Stack Size = 250000
Debugging Level = "Standard"
Save Changes Before Running = "Ask"
Break On Library Errors = True
Break On First Chance Exceptions = False
Hide Windows = False
Break At First Statement = False
 
[Compiler Defines]
Compiler Defines = "/DWIN32_LEAN_AND_MEAN /DWUSBVME"
 
[Command Line Args]
Command Line Args = ""
 
[Watch Point 1]
Watch Expression = "ndata[channel]"
Update Display Continuously = False
Break When Value Changes = False
Scope = "Local"
File = "lr_tdc.c"
Function = "read_tdc_gate"
DllName = ""
 
[Included Headers]
Header 0001 = "/c/MeasurementStudio/cvi/include/ansi_c.h"
Header 0002 = "/c/MeasurementStudio/cvi/include/ansi/assert.h"
Header 0003 = "/c/MeasurementStudio/cvi/include/cvidef.h"
Header 0004 = "/c/MeasurementStudio/cvi/include/cvirte.h"
Header 0005 = "/c/MeasurementStudio/cvi/include/ansi/ctype.h"
Header 0006 = "/c/MeasurementStudio/cvi/include/ansi/errno.h"
Header 0007 = "/c/MeasurementStudio/cvi/include/ansi/float.h"
Header 0008 = "/c/MeasurementStudio/cvi/include/ansi/limits.h"
Header 0009 = "/c/MeasurementStudio/cvi/include/ansi/locale.h"
Header 0010 = "/c/MeasurementStudio/cvi/include/ansi/math.h"
Header 0011 = "/c/MeasurementStudio/cvi/include/ansi/setjmp.h"
Header 0012 = "/c/MeasurementStudio/cvi/include/ansi/signal.h"
Header 0013 = "/c/MeasurementStudio/cvi/include/ansi/stdarg.h"
Header 0014 = "/c/MeasurementStudio/cvi/include/ansi/stddef.h"
Header 0015 = "/c/MeasurementStudio/cvi/include/ansi/stdio.h"
Header 0016 = "/c/MeasurementStudio/cvi/include/ansi/stdlib.h"
Header 0017 = "/c/MeasurementStudio/cvi/include/ansi/string.h"
Header 0018 = "/c/MeasurementStudio/cvi/include/ansi/time.h"
Header 0020 = "/c/MeasurementStudio/cvi/sdk/include/windows.h"
Header 0021 = "/c/MeasurementStudio/cvi/sdk/include/windef.h"
Header 0022 = "/c/MeasurementStudio/cvi/sdk/include/winnt.h"
Header 0023 = "/c/MeasurementStudio/cvi/sdk/include/basetsd.h"
Header 0024 = "/c/MeasurementStudio/cvi/sdk/include/Guiddef.h"
Header 0025 = "/c/MeasurementStudio/cvi/sdk/include/pshpack4.h"
Header 0026 = "/c/MeasurementStudio/cvi/sdk/include/poppack.h"
Header 0027 = "/c/MeasurementStudio/cvi/sdk/include/pshpack2.h"
Header 0028 = "/c/MeasurementStudio/cvi/sdk/include/pshpack8.h"
Header 0029 = "/c/MeasurementStudio/cvi/sdk/include/winbase.h"
Header 0030 = "/c/MeasurementStudio/cvi/sdk/include/winerror.h"
Header 0031 = "/c/MeasurementStudio/cvi/sdk/include/wingdi.h"
Header 0032 = "/c/MeasurementStudio/cvi/sdk/include/pshpack1.h"
Header 0033 = "/c/MeasurementStudio/cvi/sdk/include/winuser.h"
Header 0034 = "/c/MeasurementStudio/cvi/sdk/include/tvout.h"
Header 0035 = "/c/MeasurementStudio/cvi/sdk/include/winnls.h"
Header 0036 = "/c/MeasurementStudio/cvi/sdk/include/wincon.h"
Header 0037 = "/c/MeasurementStudio/cvi/sdk/include/winver.h"
Header 0038 = "/c/MeasurementStudio/cvi/sdk/include/winreg.h"
Header 0039 = "/c/MeasurementStudio/cvi/sdk/include/winnetwk.h"
Header 0040 = "/c/MeasurementStudio/cvi/sdk/include/winsvc.h"
Header 0041 = "/c/MeasurementStudio/cvi/sdk/include/mcx.h"
Header 0042 = "/c/MeasurementStudio/cvi/sdk/include/imm.h"
Header 0043 = "/c/MeasurementStudio/cvi/include/utility.h"
Header 0044 = "/c/MeasurementStudio/cvi/instr/CAENV673A/CAENV673A.h"
Header 0045 = "/c/MeasurementStudio/cvi/include/userint.h"
Header 0046 = "/c/ICFA/2014/rich/rich_ui.h"
Header 0047 = "/c/MeasurementStudio/cvi/instr/WUSBVME_DLL/wusbvme_dll.h"
Header 0048 = "/c/MeasurementStudio/cvi/include/ivi.h"
Header 0049 = "/c/MeasurementStudio/cvi/include/visa.h"
Header 0050 = "/c/MeasurementStudio/cvi/include/visatype.h"
Header 0051 = "/c/MeasurementStudio/cvi/include/vpptype.h"
Header 0052 = "/c/MeasurementStudio/cvi/instr/WUSBVME_DLL/usb.h"
Header 0053 = "/c/MeasurementStudio/cvi/instr/WUSBVME_DLL/xxusb_dll.h"
Header 0019 = "/c/MeasurementStudio/cvi/instr/CAENV673A/CAENV673A_DEF.h"
Max Header Number = 53
 
[Create Executable]
Executable File_Debug = "/c/ICFA/2014/rich/rich_dbg.exe"
Target Creation Date_Debug = 3493382801
Force Creation of Target_Debug = False
Executable File_Release = "/c/ICFA/2014/rich/rich.exe"
Target Creation Date_Release = 3152012344
Force Creation of Target_Release = True
Icon File = ""
Application Title = ""
DLL Exports = "Include File Symbols"
DLL Import Library Choice = "Gen Lib For Current Mode"
Use VXIPNP Subdirectories for Import Libraries = False
Use Dflt Import Lib Base Name = True
Where to Copy DLL = "Do not copy"
Add Type Lib To DLL = False
Include Type Lib Help Links = False
Type Lib FP File = ""
Type Lib Guid = ""
Uses DataSocket = 0
Uses NIReports = 0
Uses DCom95 = 0
Instrument Driver Support Only = False
 
[External Compiler Support]
UIR Callbacks File Option = 0
Using LoadExternalModule = False
Create Project Symbols File = True
UIR Callbacks Obj File = ""
Project Symbols H File = ""
Project Symbols Obj File = ""
 
[DLL Debugging Support]
External Process Path = ""
 
/ICFA/rich/rich_ui.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
/ICFA/rich/icfa2013.txt
0,0 → 1,64
0 3 4
1 3 5
2 3 6
3 3 7
4 2 4
5 2 5
6 2 6
7 2 7
8 1 4
9 1 5
10 1 6
11 1 7
12 0 4
13 0 5
14 0 6
15 0 7
16 7 4
17 7 5
18 7 6
19 7 7
20 6 4
21 6 5
22 6 6
23 6 7
24 5 4
25 5 5
26 5 6
27 5 7
28 4 4
29 4 5
30 4 6
31 4 7
32 3 0
33 3 1
34 3 2
35 3 3
36 2 0
37 2 1
38 2 2
39 2 3
40 1 0
41 1 1
42 1 2
43 1 3
44 0 0
45 0 1
46 0 2
47 0 3
48 7 0
49 7 1
50 7 2
51 7 3
52 6 0
53 6 1
54 6 2
55 6 3
56 5 0
57 5 1
58 5 2
59 5 3
60 4 0
61 4 1
62 4 2
63 4 3
/ICFA/rich/rich.c
0,0 → 1,492
#define USE_DAQ
 
// 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
# include "CAENV673A.h"
#endif
 
#include <utility.h>
#include <userint.h>
#include <cvirte.h> /* Needed if linking in external compiler; harmless otherwise */
#include "rich_ui.h"
 
#define V673A_BASE_A24 0x130000
#define USBVME_NAME "VM0120"
 
#define MAPFILE "icfa2013.txt"
 
#define MAXDATA 2000
unsigned long dataa[3078];
unsigned long data0[MAXDATA];
unsigned long datac[1000];
 
 
int p1h, p2h, p3h ;
int p1h,rph,rID;
 
 
int pmtmaparr[8][8] ;
int pmtmap_i[64] ;
int pmtmap_j[64] ;
int data[64][64] ;
int nndata[64] ;
unsigned short acum_allch[65536] ;
unsigned short acum_snglch[64][512] ;
//int offset=512 ;
int offset=0 ;
int min_tdc, max_tdc ;
int min_tdcR, max_tdcR ;
 
int single_event ;
 
unsigned long pmtbitmap[2] ;
unsigned long pmtbitmap_win[2] ;
 
int minhit ;
 
//*****************************************************************************
 
int read_pmtmap ( ) {
FILE *fp=fopen(MAPFILE,"r");
int ch, i, j ;
while ( EOF != fscanf(fp,"%d %d %d\n",&ch,&i,&j) ) {
if ( i>7 || j>7 ) {
printf ( "Index out of range!!!! (%d,%d,%d)\n",ch,i,j ) ;
continue ;
}
pmtmaparr[i][j]=ch ;
pmtmap_i[ch] = i ;
pmtmap_j[ch] = j ;
}
 
return 0 ;
}
 
//*****************************************************************************
 
int draw_histos ( ) {
int i, ch ;
int harr[4]={HISTOS_H_1,HISTOS_H_2,HISTOS_H_3,HISTOS_H_4} ;
for ( ch=0; ch<4; ch++ ) {
DeleteGraphPlot (p2h, harr[ch], -1, VAL_IMMEDIATE_DRAW);
for ( i=0 ; i<nndata[ch] ; i++ ) {
if ( (data[ch][i]>>16)&(0x1) ) {
//printf ( "falling\n" ) ;
PlotPoint (p2h, harr[ch], data[ch][i]&0xFFFF, 1.0, VAL_SOLID_SQUARE, VAL_RED);
PlotLine (p2h, harr[ch], data[ch][i]&0xFFFF, 1.0, data[ch][i]&0xFFFF, 0.0, VAL_RED);
} else {
//printf ( "rising %d %X\n", ch, data[ch][i]&0xFFFF ) ;
PlotPoint (p2h, harr[ch], data[ch][i]&0xFFFF, 1.0, VAL_EMPTY_SQUARE, VAL_BLUE);
PlotLine (p2h, harr[ch], data[ch][i]&0xFFFF, 1.0, data[ch][i]&0xFFFF, 0.0, VAL_BLUE);
}
}
}
 
return 0 ;
}
 
//*****************************************************************************
 
int draw_acum_histos() {
int hsts[64]={P3_ACUM_1,P3_ACUM_2,P3_ACUM_3,P3_ACUM_4,P3_ACUM_5,P3_ACUM_6,P3_ACUM_7,P3_ACUM_8,P3_ACUM_9,P3_ACUM_10,
P3_ACUM_11,P3_ACUM_12,P3_ACUM_13,P3_ACUM_14,P3_ACUM_15,P3_ACUM_16,P3_ACUM_17,P3_ACUM_18,P3_ACUM_19,P3_ACUM_20,
P3_ACUM_21,P3_ACUM_22,P3_ACUM_23,P3_ACUM_24,P3_ACUM_25,P3_ACUM_26,P3_ACUM_27,P3_ACUM_28,P3_ACUM_29,P3_ACUM_30,
P3_ACUM_31,P3_ACUM_32,P3_ACUM_33,P3_ACUM_34,P3_ACUM_35,P3_ACUM_36,P3_ACUM_37,P3_ACUM_38,P3_ACUM_39,P3_ACUM_40,
P3_ACUM_41,P3_ACUM_42,P3_ACUM_43,P3_ACUM_44,P3_ACUM_45,P3_ACUM_46,P3_ACUM_47,P3_ACUM_48,P3_ACUM_49,P3_ACUM_50,
P3_ACUM_51,P3_ACUM_52,P3_ACUM_53,P3_ACUM_54,P3_ACUM_55,P3_ACUM_56,P3_ACUM_57,P3_ACUM_58,P3_ACUM_59,P3_ACUM_60,
P3_ACUM_61,P3_ACUM_62,P3_ACUM_63,P3_ACUM_64} ;
int i;
double grmin,grmax;
 
GetCtrlVal (p1h, P1_TDC_MAX, &max_tdc ) ;
GetCtrlVal (p1h, P1_TDC_MIN, &min_tdc ) ;
GetCtrlVal (p1h, P1_TDC_MAX_2, &max_tdcR ) ;
GetCtrlVal (p1h, P1_TDC_MIN_2, &min_tdcR ) ;
//SetAxisScalingMode (p1h, P1_ACUM_WIN, VAL_XAXIS, VAL_MANUAL, min_tdc, max_tdc);
 
DeleteGraphPlot (p1h, P1_ACUM, -1, VAL_IMMEDIATE_DRAW);
DeleteGraphPlot (p1h, P1_ACUM_WIN, -1, VAL_IMMEDIATE_DRAW);
PlotY (p1h, P1_ACUM, acum_allch, /*65536*/ 65536, VAL_UNSIGNED_SHORT_INTEGER,
VAL_VERTICAL_BAR, VAL_NO_POINT, VAL_SOLID, 1, VAL_DK_BLUE);
PlotY (p1h, P1_ACUM_WIN, acum_allch, /*65536*/ 65536, VAL_UNSIGNED_SHORT_INTEGER,
VAL_VERTICAL_BAR, VAL_NO_POINT, VAL_SOLID, 1, VAL_DK_BLUE);
GetAxisScalingMode (p1h, P1_ACUM_WIN, VAL_LEFT_YAXIS, 0, &grmin, &grmax );
PlotLine (p1h, P1_ACUM_WIN, min_tdcR, 0, min_tdcR, grmax, VAL_RED);
PlotLine (p1h, P1_ACUM_WIN, max_tdcR, 0, max_tdcR, grmax, VAL_RED);
PlotLine (p1h, P1_ACUM_WIN, min_tdc, 0, min_tdc, grmax, VAL_GREEN);
PlotLine (p1h, P1_ACUM_WIN, max_tdc, 0, max_tdc, grmax, VAL_GREEN);
 
for ( i=0; i<64; i++ ) {
DeleteGraphPlot (p3h, hsts[i], -1, VAL_IMMEDIATE_DRAW);
PlotY (p3h, hsts[i], acum_snglch[i], 256, VAL_UNSIGNED_SHORT_INTEGER,
VAL_VERTICAL_BAR, VAL_NO_POINT, VAL_SOLID, 1, VAL_DK_BLUE);
}
 
return 0 ;
}
 
//*****************************************************************************
 
int draw_evnt() {
int i,j,color,frame;
int iijj[8]={1,3, 7,9, 13,15, 19,21} ;
// int iijj[8]={1,3, 7,9, 13,15, 19,21} ;
 
DeleteGraphPlot (p1h, P1_EV_DI, -1, VAL_IMMEDIATE_DRAW);
for ( i=1; i<20; i+=6 ) {
for ( j=1; j<20; j+=6 ) {
PlotRectangle (p1h,P1_EV_DI,i,j,i+4,j+4,VAL_DK_GRAY,VAL_TRANSPARENT);
}
}
for ( i=0; i<64; i++ ) {
if ( (pmtbitmap_win[i>>5]>>(i&0x1F))&0x1 ) {
color = VAL_DK_GREEN;
frame = VAL_DK_GREEN;
} else if ( (pmtbitmap[i>>5]>>(i&0x1F))&0x1 ) {
color = VAL_TRANSPARENT;
frame = VAL_RED;
} else {
color = -1 ;
}
if ( color!=-1 ) {
PlotRectangle (p1h, P1_EV_DI,
iijj[pmtmap_i[i]]+0.1,iijj[pmtmap_j[i]]+0.1,
iijj[pmtmap_i[i]]+1.9,iijj[pmtmap_j[i]]+1.9,
frame,color);
}
}
return 0 ;
}
 
//*****************************************************************************
 
int num_gr_photons() {
 
int rc=0;
long bitmap[2];
int i;
bitmap[0]=pmtbitmap_win[0];
bitmap[1]=pmtbitmap_win[1];
for (i=0;i<32;i++) {
if (bitmap[0]&0x1) rc++;
if (bitmap[1]&0x1) rc++;
bitmap[0]>>=1;
bitmap[1]>>=1;
}
printf("%08X\t%08X\n",pmtbitmap_win[0],pmtbitmap_win[1]);
printf("num_gr_photons %d\n",rc);
return rc;
}
 
//*****************************************************************************
 
int initvar(unsigned long xxx[],int n) {
for (;--n>=0;xxx[n]=0);
return 0;
}
 
//*****************************************************************************
 
int daq(){
 
static int cdaq=0;
int dum;
int error,i,j,fcount,fcountold=-1,nauto,fauto;
int nfirst[3],ntrig[3],ndata[3],ndatac,neve,ntrold;
unsigned short *j16=(unsigned short *) &j;
 
unsigned long ext_c;
char filename[256],path[256], fname[256];
int maxeve,print,neve_sel=0,nueve=0;
unsigned int bsr ;
unsigned short dataxxx ;
unsigned short edge_type, overflow, channel, ev_dat, tdc_num, last_dat, nval_dat;
unsigned short gerror ;
int hits=0 ;
//int last[2] ;
int last_ev_no = -1 ;
 
 
if (cdaq==1) return -1;
else cdaq=1;
 
// initialize VME interface
#ifdef USE_DAQ
error = V673A_map (0,V673A_BASE_A24, 1);
error = V673A_init(0);
V673A_setreg(0,0x1a,0x003e);
V673A_setreg(0,0x1e,0x003e);
error = V673A_clallb(0);
#endif
 
 
SetCtrlVal (p1h, P1_LED_DAQ,1);
SetCtrlVal (p1h, P1_TRIG, 0 ) ;
GetCtrlVal (p1h, P1_DEBUG, &print ) ;
GetCtrlVal (p1h, P1_NAUTO, &nauto ) ;
GetCtrlVal (p1h, P1_AUTOSAVE, &fauto ) ;
GetCtrlVal (p1h, P1_NEVNT, &maxeve ) ;
GetCtrlVal (p1h, P1_FNAME, fname );
GetCtrlVal (p1h, P1_PATH, path );
GetCtrlVal (p1h, P1_TDC_MAX, &max_tdc ) ;
GetCtrlVal (p1h, P1_TDC_MIN, &min_tdc ) ;
GetCtrlVal (p1h, P1_TDC_MAX_2, &max_tdcR ) ;
GetCtrlVal (p1h, P1_TDC_MIN_2, &min_tdcR ) ;
GetCtrlVal (p1h, P1_SINGLE, &single_event ) ;
//PlotLine (p1h, P1_ACUM_WIN, min_tdcR, 0, min_tdcR, 1000, VAL_RED);
//PlotLine (p1h, P1_ACUM_WIN, max_tdcR, 0, max_tdcR, 1000, VAL_RED);
//PlotLine (p1h, P1_ACUM_WIN, min_tdc, 0, min_tdc, 1000, VAL_GREEN);
//PlotLine (p1h, P1_ACUM_WIN, max_tdc, 0, max_tdc, 1000, VAL_GREEN);
//SetAxisScalingMode (p1h, P1_ACUM_WIN, VAL_XAXIS, VAL_MANUAL, min_tdc, max_tdc);
// start measurement
neve=0;
neve_sel=0;
ntrold=0;
rID=0;
 
do {
/*
if (( neve%nauto==0 && fauto==1 ) || (neve==0 && fauto==1)){
fcount=neve/nauto;
if ( fcountold < fcount ) {
sprintf(filename,"%s\\%s_file%d.dat",path,fname,fcount);
printf("%s\n",filename);
fcountold=fcount ;
}
}
*/
if ( rID == P1_STOP ) break ;
#ifdef USE_DAQ
ntrig[0] = V673A_ntrig (0);
#endif
//printf ( "%d\t", ntrig[0] ) ;
//if (ntrig[0]!=-1) {
if (ntrig[0]>ntrold) {
ntrold=ntrig[0]-1;
initvar ( data0, 1024 ) ;
#ifdef USE_DAQ
ndata[0] = V673A_getevnt (0,ntrold,data0,MAXDATA);
#endif
//printf ( "%d\t", ndata[0] ) ;
for ( i=0;i<ndata[0];i++ ) {
dataa[i]=0xc3ffffff & data0[i];
// printf ( "%d\t", data0[i] ) ;
}
ntrold=(ntrold+1)&0xffff;
 
if ( ndata[0] >0 ) {
pmtbitmap[0] = 0 ;
pmtbitmap[1] = 0 ;
pmtbitmap_win[0] = 0 ;
pmtbitmap_win[1] = 0 ;
for (i=0;i<ndata[0];i++) {
dataxxx = data0[i] & 0xFFFF ;
edge_type = (data0[i]>>16)&0x1 ;
overflow = (data0[i]>>17)&0x1 ;
tdc_num = (data0[i]>>25)&0x1 ;
channel = (data0[i]>>18)&0x1F|tdc_num<<5 ;
ev_dat = (data0[i]>>23)&0x1 ;
last_dat = (data0[i]>>30)&0x1 ;
nval_dat = (data0[i]>>31)&0x1 ;
if (ev_dat == 0) { // event data
hits++ ;
if ( nndata[channel] < 63 ) {
data[channel][nndata[channel]++] = dataxxx|edge_type<<16 ;
}
if ((edge_type & 0x1)==0 ) { // rising edge
acum_allch[dataxxx]++ ;
if ((0<=(dataxxx-offset))&&((dataxxx-offset)<512) ) { // siroko okno
acum_snglch[channel][dataxxx-offset]++ ;
}
if ((min_tdcR<=(dataxxx-offset)) && ((dataxxx-offset)<max_tdcR)) { // rdece okno
if ( channel>31 )
pmtbitmap[1] |= 1<<(channel-32) ;
else
pmtbitmap[0] |= 1<<(channel) ;
}
if ( (min_tdc<=(dataxxx-offset)) && ((dataxxx-offset)<max_tdc) ) { // zeleno okno
if ( channel>31 )
pmtbitmap_win[1] |= 1<<(channel-32);
else
pmtbitmap_win[0] |= 1<<(channel);
}
}
} else if (last_dat==0) { //not last datum
//pmtbitmap[0] = 0;
//pmtbitmap[1] = 0;
last_ev_no = dataxxx;
}
}
 
if (num_gr_photons() >= minhit) {
draw_evnt();
//draw_histos();
draw_acum_histos();
neve_sel++;
}
 
}
neve++;
} else {
error = V673A_clallb(0);
ntrold=0;
}
SetCtrlVal (p1h, P1_PROC, (neve*100)/maxeve ) ;
SetCtrlVal (p1h, P1_TRIG, neve ) ;
do {
nueve=GetUserEvent (0, &rph, &rID);
} while ( rID != P1_STOP && nueve>0 );
if ( rID == P1_STOP ) break ;
} while ( (neve < maxeve) && (neve_sel<1 || !single_event) ) ;
 
SetCtrlVal (p1h, P1_LED_DAQ,0);
cdaq=0;
return 0;
}
 
//*****************************************************************************
//*************************** MAIN ********************************************
//*****************************************************************************
 
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
int error;
int i,j;
int nevnt,cnt;
int pmtmap[32][32] ;
int gray[16] = {0x000000, 0x111111, 0x222222, 0x333333, 0x444444, 0x555555, 0x666666,
0x777777, 0x888888, 0x999999, 0xAAAAAA, 0xBBBBBB, 0xCCCCCC, 0xDDDDDD,
0xEEEEEE, 0xFFFFFF } ;
double x, y, min_r, max_r, r1, r2 ;
 
ColorMapEntry grCol[16] ;
 
grCol[0].dataValue.valInt = 0 ;
grCol[0].color = gray[0] ;
grCol[1].dataValue.valInt = 100000 ;
grCol[1].color = gray[15] ;
 
read_pmtmap ( ) ;
for ( i=0 ; i<32; i++ ) {
for ( j=0 ; j<32; j++ ) {
if ( ( (((i+2)/4)%2) != 0 ) && ( (((j+2)/4)%2) != 0 ) )
pmtmap[i][j]=1000000 ;
else pmtmap[i][j]=0 ;
//pmtmap[i][j]=(i+1)*(i+1)*(i+1)*(j+1) ;
}
}
 
p1h = LoadPanel (0, "rich_ui.uir", P1);
// p2h = LoadPanel (0, "laprich.uir", HISTOS);
p3h = LoadPanel (0, "rich_ui.uir", P3);
DisplayPanel (p1h);
// DisplayPanel (p2h);
DisplayPanel (p3h);
for ( i=1; i<20; i+=6 ) {
for ( j=1; j<20; j+=6 ) {
PlotRectangle (p1h,P1_EV_DI,i,j,i+4,j+4,VAL_DK_GRAY,VAL_TRANSPARENT);
}
}
 
#ifdef USE_DAQ
# ifdef WUSBVME
VME_START(USBVME_NAME);
# else
VME_START(NULL);
# endif
#endif
do {
GetUserEvent (1, &rph, &rID);
switch (rID){
case P1_EV_PL:
// PlotScaledIntensity (p1h, P1_EV_DI, pmtmap, 32, 32, VAL_INTEGER,
// 1.0, 0.0, 1.0, 0.0, grCol, 0xff0000, 2, 1, 0);
draw_evnt();
break;
case P1_READ_TDC:
daq(); //read_tdc ( ) ;
break;
case P1_DRAWH:
// draw_histos ( ) ;
draw_acum_histos ( ) ;
break;
case P1_SINGLE:
GetCtrlVal (p1h, P1_SINGLE, &single_event ) ;
break;
case P1_CONT_DAQ:
nevnt=0;
cnt=0;
minhit=0;
GetCtrlVal (p1h, P1_NEVNT, &nevnt );
GetCtrlVal (p1h, P1_MINHIT, &minhit );
// printf("%d %d\n", nevnt, minhit);
// while((read_tdc()<minhit)&&(cnt++<nevnt)) ;
daq();
// draw_evnt();
break;
case P1_EV_DI:
GetCtrlVal (p1h, P1_R_MIN, &min_r ) ;
GetCtrlVal (p1h, P1_R_MAX, &max_r ) ;
r1=min_r*2.0 ;
r2=max_r*2.0 ;
GetGraphCursor (p1h, P1_EV_DI, 1, &x, &y);
printf ( "x:%5.2f\ty:%5.2f\n", x, y ) ;
draw_evnt();
PlotOval (p1h, P1_EV_DI, x-r1, y-r1, x+r1, y+r1, VAL_RED, VAL_TRANSPARENT);
PlotOval (p1h, P1_EV_DI, x-r2, y-r2, x+r2, y+r2, VAL_RED, VAL_TRANSPARENT);
break;
case P1_PRINT:
SetCtrlVal (p1h, P1_PL,1);
PrintCtrl (p1h, P1_EV_DI, "event.tif", 1, VAL_FULL_PANEL);
SetCtrlVal (p1h, P1_PL,0);
break;
case P1_RESET:
break;
// case P1_PRINT:
// break;
default:
break;
}
// if ( rID==P1_I_GATE ) init_gate ( ) ;
} while ( (rID!=P1_EXIT) || (rph!=p1h) ) ;
 
// CloseHandle(nHandle);
#ifdef USE_DAQ
VME_STOP();
#endif
// printf ( "XXXX\n" ) ;
return 0;
}
/ICFA/rich/rich_ui.h
0,0 → 1,162
/**************************************************************************/
/* LabWindows/CVI User Interface Resource (UIR) Include File */
/* Copyright (c) National Instruments 2014. All Rights Reserved. */
/* */
/* 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 HISTOS 1
#define HISTOS_H_13 2
#define HISTOS_H_14 3
#define HISTOS_H_15 4
#define HISTOS_H_16 5
#define HISTOS_H_9 6
#define HISTOS_H_10 7
#define HISTOS_H_11 8
#define HISTOS_H_12 9
#define HISTOS_H_5 10
#define HISTOS_H_6 11
#define HISTOS_H_7 12
#define HISTOS_H_8 13
#define HISTOS_H_1 14
#define HISTOS_H_2 15
#define HISTOS_H_3 16
#define HISTOS_H_4 17
 
#define P1 2
#define P1_LED_13 2
#define P1_LED_14 3
#define P1_LED_15 4
#define P1_NAUTO 5
#define P1_LED_16 6
#define P1_LED_9 7
#define P1_LED_10 8
#define P1_FNAME 9
#define P1_LED_11 10
#define P1_PATH 11
#define P1_LED_12 12
#define P1_PROC 13
#define P1_LED_5 14
#define P1_A0A1 15
#define P1_REFIND 16
#define P1_AUTOSAVE 17
#define P1_LED_6 18
#define P1_LED_7 19
#define P1_LED_8 20
#define P1_SINGLE 21
#define P1_DEBUG 22
#define P1_LED_4 23
#define P1_LED_3 24
#define P1_LED_2 25
#define P1_LED 26
#define P1_EV_DI 27
#define P1_RESET 28
#define P1_STOP 29
#define P1_PRINT 30
#define P1_CONT_DAQ 31
#define P1_DRAWH 32
#define P1_READ_TDC 33
#define P1_EV_PL 34
#define P1_EXIT 35
#define P1_ACUM_WIN 36
#define P1_ACUM 37
#define P1_TRIG 38
#define P1_NEVNT 39
#define P1_TDC_MIN_2 40
#define P1_R_MAX 41
#define P1_R_MIN 42
#define P1_TDC_MAX_2 43
#define P1_TDC_MIN 44
#define P1_TDC_MAX 45
#define P1_PL 46
#define P1_MINHIT 47
#define P1_LED_DAQ 48
#define P1_DECORATION_2 49
 
#define P3 3
#define P3_ACUM_49 2
#define P3_ACUM_50 3
#define P3_ACUM_51 4
#define P3_ACUM_52 5
#define P3_ACUM_53 6
#define P3_ACUM_54 7
#define P3_ACUM_55 8
#define P3_ACUM_56 9
#define P3_ACUM_57 10
#define P3_ACUM_58 11
#define P3_ACUM_59 12
#define P3_ACUM_60 13
#define P3_ACUM_61 14
#define P3_ACUM_62 15
#define P3_ACUM_63 16
#define P3_ACUM_64 17
#define P3_ACUM_33 18
#define P3_ACUM_34 19
#define P3_ACUM_35 20
#define P3_ACUM_36 21
#define P3_ACUM_37 22
#define P3_ACUM_38 23
#define P3_ACUM_39 24
#define P3_ACUM_40 25
#define P3_ACUM_41 26
#define P3_ACUM_42 27
#define P3_ACUM_43 28
#define P3_ACUM_44 29
#define P3_ACUM_45 30
#define P3_ACUM_46 31
#define P3_ACUM_47 32
#define P3_ACUM_48 33
#define P3_ACUM_17 34
#define P3_ACUM_18 35
#define P3_ACUM_19 36
#define P3_ACUM_20 37
#define P3_ACUM_21 38
#define P3_ACUM_22 39
#define P3_ACUM_23 40
#define P3_ACUM_24 41
#define P3_ACUM_25 42
#define P3_ACUM_26 43
#define P3_ACUM_27 44
#define P3_ACUM_28 45
#define P3_ACUM_29 46
#define P3_ACUM_30 47
#define P3_ACUM_31 48
#define P3_ACUM_32 49
#define P3_ACUM_1 50
#define P3_ACUM_2 51
#define P3_ACUM_3 52
#define P3_ACUM_4 53
#define P3_ACUM_5 54
#define P3_ACUM_6 55
#define P3_ACUM_7 56
#define P3_ACUM_8 57
#define P3_ACUM_9 58
#define P3_ACUM_10 59
#define P3_ACUM_11 60
#define P3_ACUM_12 61
#define P3_ACUM_13 62
#define P3_ACUM_14 63
#define P3_ACUM_15 64
#define P3_ACUM_16 65
 
 
/* Menu Bars, Menus, and Menu Items: */
 
/* (no menu bars in the resource file) */
 
 
/* (no callbacks specified in the resource file) */
 
 
#ifdef __cplusplus
}
#endif