13,7 → 13,6 |
#include "wusbxx_dll.h" /* the header of the shared library */ |
#include "daq.h" |
|
#define DEVICE_NAME "/dev/cc32_1" |
#define PRRES(X) printf(">>> %s -> %d\n",#X,(X)) |
|
|
104,7 → 103,7 |
long cres; |
int q,x; |
|
CSSA_RQX(0,0,0,&cres,&q,&x); |
short retval = CSSA_RQX(0,0,0,&cres,&q,&x); |
dum = cres; |
id = (dum & 0xF000) >> 12; |
fpga = (dum & 0x0F00) >> 8; |
113,14 → 112,10 |
x = (dum & 0x0004) >> 2; |
inhibit= (dum & 0x0002) >> 1; |
lam = (dum & 0x0001); |
printf ("CCUSB CSR ID=%x FPGA=%x modID=%x Q=%d X=%d INHIBIT=%d LAM=%d \n",id,fpga,modid, q,x,inhibit,lam); |
printf ("[%d] CCUSB CSR ID=%x FPGA=%x modID=%x Q=%d X=%d INHIBIT=%d LAM=%d \n",retval, id,fpga,modid, q,x,inhibit,lam); |
} |
|
int daq::connect(){ |
/*xxusb_device_type devices[100]; |
struct usb_device *dev; |
dev = devices[0].usbdev; |
udev = xxusb_device_open(dev);*/ |
WUSBXX_load (NULL); |
// WUSBXX_open ((char *)"CC0126"); |
WUSBXX_open ((char *)"CC0130"); |
129,8 → 124,8 |
} |
|
int daq::disconnect(){ |
/* zakljuci */ |
|
/* zakljuci */ |
if (udev == NULL) ; WUSBXX_close (); |
printf("daq::disconnect()\n"); |
return 0; |
} |
139,35 → 134,47 |
int q,x; |
// printf("Nastavljam threshold na %d in cas meritve na %d ms\n",thr_set,time_set); |
long dum; |
short retval; |
/* postavimo zeljeni prag prozenja */ |
CSSA_WQX(NDIS,0,17,thr_set,&q,&x); |
CSSA_WQX(NDIS,1,17,0,&q,&x); |
retval = CSSA_WQX(NDIS,0,17,thr_set,&q,&x); |
if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
retval = CSSA_WQX(NDIS,1,17,0,&q,&x); |
if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
/* stevec postavim na nic */ |
CSSA_RQX ( NSCA, 0, 9,&dum, &q,&x); |
retval = CSSA_RQX ( NSCA, 0, 9,&dum, &q,&x); |
if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
/* nastavim dolzino signala */ |
CSSA_WQX(NTGG,0,16,time_set,&q,&x); |
CSSA_RQX(NTGG,0,15,&dum,&q,&x); |
retval = CSSA_WQX(NTGG,0,16,time_set,&q,&x); |
if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
retval = CSSA_RQX(NTGG,0,15,&dum,&q,&x); |
if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
usleep(1000*time_set); |
usleep(time_set); |
return 0; |
} |
|
|
int daq::count(){ |
int q,x; |
int q,x; |
short retval=0; |
/* prestejem sunke na posameznem kanalu */ |
for ( int ch=0 ; ch<16 ; ch ++ ) { |
long data=0; |
CSSA_RQX( NSCA, ch, 0, &data, &q,&x); |
CSSA_RQX( NSCA, ch, 0, &data, &q,&x); |
retval = CSSA_RQX( NSCA, ch, 0, &data, &q,&x); |
retval = CSSA_RQX( NSCA, ch, 0, &data, &q,&x); |
if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
|
// CC USB ne precita v redu CAEN C257 scalerja, |
// kanali so zamaknjeni za 1, ce je klic samo en |
// vrednost kanala 0 se pristeje h kanalom 8..16, zato ga ne uporabljamo. |
// vajo izvedemo le s kanali 1..15. |
gData[ch]=data; |
// printf("Kanal:%d Stevilo sunkov: %d \n",ch,data ); |
printf("[%d] Kanal:%d Stevilo sunkov: %ld \n",retval,ch,data ); |
} |
for ( int ch=0 ; ch<16 ; ch ++ ) if (gData[ch]>0) gData[ch]--; |
|
224,6 → 231,7 |
CSSA_RQX( NDIS, 0,26, &dum,&q, &x); |
|
CREM_I; |
printf("Initialized\n"); |
|
return 0; |
} |
256,7 → 264,7 |
daq *d= new daq(); |
d->init(); |
d->start(threshold, time_set); // threshold |
|
usleep(time_set*.1); |
d->count(); |
d->append(filename); |
delete d; |