Rev 111 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 111 | Rev 118 | ||
---|---|---|---|
Line 11... | Line 11... | ||
11 | #include <sys/time.h> |
11 | #include <sys/time.h> |
12 | 12 | ||
13 | #include "wusbxx_dll.h" /* the header of the shared library */ |
13 | #include "wusbxx_dll.h" /* the header of the shared library */ |
14 | #include "daq.h" |
14 | #include "daq.h" |
15 | 15 | ||
16 | #define DEVICE_NAME "/dev/cc32_1" |
- | |
17 | #define PRRES(X) printf(">>> %s -> %d\n",#X,(X)) |
16 | #define PRRES(X) printf(">>> %s -> %d\n",#X,(X)) |
18 | 17 | ||
19 | 18 | ||
20 | 19 | ||
21 | /* definiram lokacije enot*/ |
20 | /* definiram lokacije enot*/ |
Line 102... | Line 101... | ||
102 | 101 | ||
103 | 102 | ||
104 | long cres; |
103 | long cres; |
105 | int q,x; |
104 | int q,x; |
106 | 105 | ||
107 | CSSA_RQX(0,0,0,&cres,&q,&x); |
106 | short retval = CSSA_RQX(0,0,0,&cres,&q,&x); |
108 | dum = cres; |
107 | dum = cres; |
109 | id = (dum & 0xF000) >> 12; |
108 | id = (dum & 0xF000) >> 12; |
110 | fpga = (dum & 0x0F00) >> 8; |
109 | fpga = (dum & 0x0F00) >> 8; |
111 | modid = (dum & 0x00F0) >> 4; |
110 | modid = (dum & 0x00F0) >> 4; |
112 | q = (dum & 0x0008) >> 3; |
111 | q = (dum & 0x0008) >> 3; |
113 | x = (dum & 0x0004) >> 2; |
112 | x = (dum & 0x0004) >> 2; |
114 | inhibit= (dum & 0x0002) >> 1; |
113 | inhibit= (dum & 0x0002) >> 1; |
115 | lam = (dum & 0x0001); |
114 | lam = (dum & 0x0001); |
116 | printf ("CCUSB CSR |
115 | 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); |
117 | } |
116 | } |
118 | 117 | ||
119 | int daq::connect(){ |
118 | int daq::connect(){ |
120 | /*xxusb_device_type devices[100]; |
- | |
121 | struct usb_device *dev; |
- | |
122 | dev = devices[0].usbdev; |
- | |
123 | udev = xxusb_device_open(dev);*/ |
- | |
124 | WUSBXX_load (NULL); |
119 | WUSBXX_load (NULL); |
125 | // WUSBXX_open ((char *)"CC0126"); |
120 | // WUSBXX_open ((char *)"CC0126"); |
126 | WUSBXX_open ((char *)"CC0130"); |
121 | WUSBXX_open ((char *)"CC0130"); |
127 | printf("daq::connect()\n"); |
122 | printf("daq::connect()\n"); |
128 | return 0; |
123 | return 0; |
129 | } |
124 | } |
130 | 125 | ||
131 | int daq::disconnect(){ |
126 | int daq::disconnect(){ |
132 | /* zakljuci */ |
127 | /* zakljuci */ |
133 | - | ||
- | 128 | if (udev == NULL) ; WUSBXX_close (); |
|
134 | printf("daq::disconnect()\n"); |
129 | printf("daq::disconnect()\n"); |
135 | return 0; |
130 | return 0; |
136 | } |
131 | } |
137 | 132 | ||
138 | int daq::start(int thr_set,int time_set){ |
133 | int daq::start(int thr_set,int time_set){ |
139 | int q,x; |
134 | int q,x; |
140 | // printf("Nastavljam threshold na %d in cas meritve na %d ms\n",thr_set,time_set); |
135 | // printf("Nastavljam threshold na %d in cas meritve na %d ms\n",thr_set,time_set); |
141 | long dum; |
136 | long dum; |
- | 137 | short retval; |
|
142 | /* postavimo zeljeni prag prozenja */ |
138 | /* postavimo zeljeni prag prozenja */ |
143 | CSSA_WQX(NDIS,0,17,thr_set,&q,&x); |
139 | retval = CSSA_WQX(NDIS,0,17,thr_set,&q,&x); |
- | 140 | if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
- | 141 | ||
144 | CSSA_WQX(NDIS,1,17,0,&q,&x); |
142 | retval = CSSA_WQX(NDIS,1,17,0,&q,&x); |
- | 143 | if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
145 | 144 | ||
146 | /* stevec postavim na nic */ |
145 | /* stevec postavim na nic */ |
147 | CSSA_RQX ( NSCA, 0, 9,&dum, &q,&x); |
146 | retval = CSSA_RQX ( NSCA, 0, 9,&dum, &q,&x); |
- | 147 | if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
148 | 148 | ||
149 | /* nastavim dolzino signala */ |
149 | /* nastavim dolzino signala */ |
150 | CSSA_WQX(NTGG,0,16,time_set,&q,&x); |
150 | retval = CSSA_WQX(NTGG,0,16,time_set,&q,&x); |
- | 151 | if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
- | 152 | ||
151 | CSSA_RQX(NTGG,0,15,&dum,&q,&x); |
153 | retval = CSSA_RQX(NTGG,0,15,&dum,&q,&x); |
- | 154 | if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
152 | 155 | ||
153 | usleep( |
156 | usleep(time_set); |
154 | return 0; |
157 | return 0; |
155 | } |
158 | } |
156 | 159 | ||
157 | 160 | ||
158 | int daq::count(){ |
161 | int daq::count(){ |
159 | int q,x; |
162 | int q,x; |
- | 163 | short retval=0; |
|
160 | /* prestejem sunke na posameznem kanalu */ |
164 | /* prestejem sunke na posameznem kanalu */ |
161 | for ( int ch=0 ; ch<16 ; ch ++ ) { |
165 | for ( int ch=0 ; ch<16 ; ch ++ ) { |
162 | long data=0; |
166 | long data=0; |
163 | CSSA_RQX( NSCA, ch, 0, &data, &q,&x); |
167 | retval = CSSA_RQX( NSCA, ch, 0, &data, &q,&x); |
164 | CSSA_RQX( NSCA, ch, 0, &data, &q,&x); |
168 | retval = CSSA_RQX( NSCA, ch, 0, &data, &q,&x); |
- | 169 | if (retval<0) printf ("USB error %d line %d\n",retval,__LINE__); |
|
- | 170 | ||
- | 171 | ||
165 | // CC USB ne precita v redu CAEN C257 scalerja, |
172 | // CC USB ne precita v redu CAEN C257 scalerja, |
166 | // kanali so zamaknjeni za 1, ce je klic samo en |
173 | // kanali so zamaknjeni za 1, ce je klic samo en |
167 | // vrednost kanala 0 se pristeje h kanalom 8..16, zato ga ne uporabljamo. |
174 | // vrednost kanala 0 se pristeje h kanalom 8..16, zato ga ne uporabljamo. |
168 | // vajo izvedemo le s kanali 1..15. |
175 | // vajo izvedemo le s kanali 1..15. |
169 | gData[ch]=data; |
176 | gData[ch]=data; |
170 |
|
177 | printf("[%d] Kanal:%d Stevilo sunkov: %ld \n",retval,ch,data ); |
171 | } |
178 | } |
172 | for ( int ch=0 ; ch<16 ; ch ++ ) if (gData[ch]>0) gData[ch]--; |
179 | for ( int ch=0 ; ch<16 ; ch ++ ) if (gData[ch]>0) gData[ch]--; |
173 | 180 | ||
174 | return 0; |
181 | return 0; |
175 | } |
182 | } |
Line 211... | Line 218... | ||
211 | CAMAC_status(); |
218 | CAMAC_status(); |
212 | CCCZ; |
219 | CCCZ; |
213 | CCCC; |
220 | CCCC; |
214 | 221 | ||
215 | CSET_I; |
222 | CSET_I; |
216 | 223 | ||
217 | int q,x; |
224 | int q,x; |
218 | long dum; |
225 | long dum; |
219 | printf("Pazi na cas meritve. Kaksen je obseg stevca?\n"); |
226 | printf("Pazi na cas meritve. Kaksen je obseg stevca?\n"); |
220 | CSSA_RQX( NTGG, 0, 9, &dum,&q, &x); /* init TGG */ |
227 | CSSA_RQX( NTGG, 0, 9, &dum,&q, &x); /* init TGG */ |
221 | CSSA_WQX( NTGG, 0,16, 1000,&q, &x); /* Set preset counting value */ |
228 | CSSA_WQX( NTGG, 0,16, 1000,&q, &x); /* Set preset counting value */ |
222 | CSSA_WQX( NTGG, 0,17, 0x2 ,&q, &x ); /* Set Load&Clock Modes */ |
229 | CSSA_WQX( NTGG, 0,17, 0x2 ,&q, &x ); /* Set Load&Clock Modes */ |
223 | CSSA_WQX( NDIS, 0,16, 0xffff,&q, &x);/* enable all ch. */ |
230 | CSSA_WQX( NDIS, 0,16, 0xffff,&q, &x);/* enable all ch. */ |
224 | CSSA_RQX( NDIS, 0,26, &dum,&q, &x); |
231 | CSSA_RQX( NDIS, 0,26, &dum,&q, &x); |
225 | 232 | ||
226 | CREM_I; |
233 | CREM_I; |
- | 234 | printf("Initialized\n"); |
|
227 | 235 | ||
228 | return 0; |
236 | return 0; |
229 | } |
237 | } |
230 | 238 | ||
231 | 239 | ||
232 | 240 | ||
233 | daq::daq(){ |
241 | daq::daq(){ |
234 | // intercept routine |
242 | // intercept routine |
235 | if (signal (SIGINT, SigInt) == SIG_ERR) perror ("sigignore"); |
243 | if (signal (SIGINT, SigInt) == SIG_ERR) perror ("sigignore"); |
Line 254... | Line 262... | ||
254 | if (argc>2) sprintf(filename ,"%s",argv[2]); |
262 | if (argc>2) sprintf(filename ,"%s",argv[2]); |
255 | if (argc>3) time_set = atoi(argv[3]); |
263 | if (argc>3) time_set = atoi(argv[3]); |
256 | daq *d= new daq(); |
264 | daq *d= new daq(); |
257 | d->init(); |
265 | d->init(); |
258 | d->start(threshold, time_set); // threshold |
266 | d->start(threshold, time_set); // threshold |
259 | 267 | usleep(time_set*.1); |
|
260 | d->count(); |
268 | d->count(); |
261 | d->append(filename); |
269 | d->append(filename); |
262 | delete d; |
270 | delete d; |
263 | 271 | ||
264 | return 0; |
272 | return 0; |