Rev 201 | Rev 207 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 201 | Rev 203 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | #include <formatio.h> |
|
1 | #include <utility.h> |
2 | #include <utility.h> |
2 | #include <ansi_c.h> |
3 | #include <ansi_c.h> |
3 | #include <cvirte.h> |
4 | #include <cvirte.h> |
4 | #include <userint.h> |
5 | #include <userint.h> |
5 | #include "drs4.h" |
6 | #include "drs4.h" |
6 | #include "drsread.h" |
7 | #include "drsread.h" |
- | 8 | ||
- | 9 | #define MIKRO |
|
- | 10 | ||
- | 11 | #ifdef MIKRO |
|
- | 12 | #include "MIKRO.h" |
|
- | 13 | #endif |
|
7 | 14 | ||
8 | static int daq_on; |
15 | static int daq_on; |
9 | static int ph, plothandle |
16 | static int ph, p2,plothandle[4]= {0,0,0,0}; |
10 | static int tfID; |
17 | static int tfID; |
11 | static int controlID; |
18 | static int controlID; |
12 | 19 | ||
13 | #define MAX_THREADS 10 |
20 | #define MAX_THREADS 10 |
14 | 21 | ||
15 | static CmtThreadPoolHandle poolHandle = 0; |
22 | static CmtThreadPoolHandle poolHandle = 0; |
16 | 23 | ||
17 | int main (int argc, char *argv[]) { |
24 | int main (int argc, char *argv[]) { |
- | 25 | short port; |
|
18 | if (InitCVIRTE (0, argv, 0) == 0) |
26 | if (InitCVIRTE (0, argv, 0) == 0) |
19 | return -1; /* out of memory */ |
27 | return -1; /* out of memory */ |
20 | if ((ph = LoadPanel (0, "drs4.uir", PANEL)) < 0) |
28 | if ((ph = LoadPanel (0, "drs4.uir", PANEL)) < 0) |
- | 29 | return -1; |
|
- | 30 | if ((p2 = LoadPanel (0, "drs4.uir", SCAN)) < 0) |
|
21 | return -1; |
31 | return -1; |
22 | SetStdioPort (CVI_STDIO_WINDOW); |
32 | SetStdioPort (CVI_STDIO_WINDOW); |
23 | SetSleepPolicy(VAL_SLEEP_MORE); |
33 | SetSleepPolicy(VAL_SLEEP_MORE); |
24 | CmtNewThreadPool (MAX_THREADS, &poolHandle); |
34 | CmtNewThreadPool (MAX_THREADS, &poolHandle); |
25 | 35 | ||
26 | DisplayPanel (ph); |
36 | DisplayPanel (ph); |
- | 37 | DisplayPanel (p2); |
|
- | 38 | ||
- | 39 | #ifdef MIKRO |
|
- | 40 | GetCtrlVal(p2, SCAN_PORT, &port); |
|
- | 41 | if (MIKRO_Open (port)) MessagePopup ("Error", "Mikro Port Not found !\n Change in the GUI") ; |
|
- | 42 | MIKRO_Init(1,0); |
|
- | 43 | MIKRO_Init(2,0); |
|
- | 44 | #endif |
|
- | 45 | ||
27 | RunUserInterface (); |
46 | RunUserInterface (); |
28 | DiscardPanel (ph); |
47 | DiscardPanel (ph); |
- | 48 | DiscardPanel (p2); |
|
29 | CmtDiscardThreadPool (poolHandle); |
49 | CmtDiscardThreadPool (poolHandle); |
- | 50 | MIKRO_Close (); |
|
30 | return 0; |
51 | return 0; |
31 | } |
52 | } |
32 | 53 | ||
33 | 54 | ||
34 | 55 | ||
35 | 56 | ||
36 | 57 | ||
37 | static void start_timer (double tout) { |
58 | static void start_timer (double tout) { |
38 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_INTERVAL, tout); |
59 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_INTERVAL, tout); |
39 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_ENABLED, 1); |
60 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_ENABLED, 1); |
40 | } |
61 | } |
41 | 62 | ||
42 | static void stop_timer ( void ) { |
63 | static void stop_timer ( void ) { |
43 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_ENABLED, 0); |
64 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_ENABLED, 0); |
44 | DRSSetTimeout() |
65 | DRSSetTimeout(); |
45 | } |
66 | } |
46 | 67 | ||
47 | 68 | ||
48 | 69 | ||
49 | 70 | ||
50 | void CVICALLBACK EndOfThread ( CmtThreadPoolHandle poolhandle, |
71 | void CVICALLBACK EndOfThread ( CmtThreadPoolHandle poolhandle, |
51 | CmtThreadFunctionID functionID, unsigned int event, |
72 | CmtThreadFunctionID functionID, unsigned int event, |
52 | int value, void *callbackData ) { |
73 | int value, void *callbackData ) { |
53 | 74 | ||
54 | daq_on=0; |
75 | daq_on=0; |
55 | //SetDimming(0); |
76 | //SetDimming(0); |
56 | printf("End of Thread \n"); |
77 | printf("End of Thread \n"); |
57 | return ; |
78 | return ; |
58 | 79 | ||
59 | } |
80 | } |
60 | 81 | ||
61 | 82 | ||
62 | int CVICALLBACK daq(void *functionData) { |
83 | int CVICALLBACK daq(void *functionData) { |
63 | 84 | ||
64 | 85 | ||
65 | int neve; |
86 | int neve; |
66 | char |
87 | char filename[0xff]; |
67 |
|
88 | int imask[4]; |
68 | unsigned long mask; |
89 | unsigned long mask; |
69 | int frequency; |
90 | int frequency; |
70 | double |
91 | double trgdelay; |
71 | double |
92 | double trglevel; |
72 | int trgtype; |
93 | int trgtype; |
73 | int trgchannel; |
94 | int trgchannel; |
74 | int |
95 | int trgpolarity; |
75 | int |
96 | int verbose; |
76 | double range; |
97 | double range; |
77 | 98 | int pfreq; |
|
78 | 99 | int enabledoutput; |
|
79 |
|
100 | int neveold = 0; |
80 |
|
101 | double rate; |
81 |
|
102 | int *args = (int *) functionData; |
82 |
|
103 | |
83 | 104 | GetCtrlVal(ph, PANEL_FILENAME, filename ); |
|
84 | GetCtrlVal |
105 | GetCtrlVal(ph, PANEL_CH0, &imask[0] ); |
85 | GetCtrlVal |
106 | GetCtrlVal(ph, PANEL_CH1, &imask[1] ); |
86 | GetCtrlVal |
107 | GetCtrlVal(ph, PANEL_CH2, &imask[2] ); |
87 | GetCtrlVal |
108 | GetCtrlVal(ph, PANEL_CH3, &imask[3] ); |
88 |
|
109 | mask = 0; |
89 |
|
110 | for (int i=0; i<4; i++) { |
90 |
|
111 | if (imask[i]) mask |= (1<<i); |
91 |
|
112 | } |
92 | 113 | ||
93 |
|
114 | GetCtrlVal(ph,PANEL_NEVE, &neve); |
94 | 115 | GetCtrlVal(ph,PANEL_DEBUG, &verbose); |
|
95 |
|
116 | GetCtrlVal(ph,PANEL_PFREQ, &pfreq); |
96 | 117 | GetCtrlVal(ph,PANEL_ENABLEDOUTPUT, &enabledoutput); |
|
97 | DRSSetFrequency( frequency ); |
118 | |
98 |
|
119 | GetCtrlVal(ph,PANEL_FREQUENCY, &frequency); |
99 |
|
120 | GetCtrlVal(ph,PANEL_TRGDELAY, &trgdelay); |
100 |
|
121 | GetCtrlVal(ph,PANEL_TRGCHANNEL, &trgchannel); |
101 | DRSSetTriggerType( trgtype ); |
122 | |
102 |
|
123 | GetCtrlVal(ph,PANEL_TRGTYPE, &trgtype); |
103 | 124 | GetCtrlVal(ph,PANEL_TRGLEVEL, &trglevel); |
|
104 |
|
125 | GetCtrlVal(ph,PANEL_TRGPOLARITY, &trgpolarity); |
105 | 126 | GetCtrlVal(ph,PANEL_RANGE, &range); |
|
106 | 127 | ||
107 | static unsigned char *buffer; |
128 | |
108 | 129 | //printf("mask=0x%x\n",mask); |
|
109 | int buffer_size = 0; |
130 | |
110 |
|
131 | DRSSetMask( (unsigned char)( mask & 0xF ) ); |
111 | const int waveDepth=1024; |
132 | |
112 |
|
133 | DRSSetFrequency( frequency ); |
113 |
|
134 | DRSSetTriggerDelay(trgdelay ); |
114 |
|
135 | DRSSetTriggerChannel(trgchannel ); |
115 |
|
136 | DRSSetTriggerType( trgtype ); |
116 |
|
137 | DRSSetTriggerLevel(trglevel); |
117 | 138 | DRSSetTriggerPolarity(trgpolarity); |
|
118 | time_t t=0,told=0, tstart=0; |
139 | |
119 | 140 | DRSSetRange ( range ); |
|
120 | if (!DRSInit()){ |
141 | |
121 | time(&tstart); |
142 | |
122 | told=tstart; |
143 | |
123 |
|
144 | FILE *fp= NULL; |
124 | for (i=0; i<neve; i++) { |
145 | |
125 |
|
146 | if (enabledoutput) { |
126 |
|
147 | if (args[0]) fp = fopen(filename,"wb"); |
127 |
|
148 | else fp = fopen(filename,"ab"); |
128 |
|
149 | } |
129 | SetCtrlVal(ph,PANEL_CEVE,i); |
150 | |
130 |
|
151 | static unsigned char *buffer; |
131 | if (!daq_on) break; |
152 | |
132 |
|
153 | int buffer_size = 0; |
133 |
|
154 | const int nBoards=1; |
134 |
|
155 | const int waveDepth=1024; |
135 |
|
156 | if (buffer_size == 0) { |
136 |
|
157 | buffer_size = 4 + nBoards * (4 + 4*(4+waveDepth*4)); |
137 |
|
158 | buffer_size += 24 + nBoards * (8 + 4*(4+waveDepth*2)); |
138 |
|
159 | buffer = (unsigned char *)malloc(buffer_size); |
- | 160 | } |
|
- | 161 | ||
- | 162 | time_t t=0,told=0, tstart=0; |
|
- | 163 | ||
- | 164 | if (!DRSInit()) { |
|
- | 165 | time(&tstart); |
|
- | 166 | told=tstart; |
|
- | 167 | int i=0; |
|
- | 168 | for (i=0; i<neve; i++) { |
|
- | 169 | start_timer(1);// 1 s timeout |
|
- | 170 | int retval = DRSRead(0); |
|
- | 171 | stop_timer(); |
|
- | 172 | int nb = ( retval == 0 && fp ) ? DRSToBuffer( buffer , i ) : 0; |
|
- | 173 | SetCtrlVal(ph,PANEL_CEVE,i); |
|
- | 174 | if (retval) i--; |
|
- | 175 | if (!daq_on) break; |
|
- | 176 | time(&t); |
|
- | 177 | if (t!=told ) { |
|
- | 178 | rate = (i-neveold); |
|
- | 179 | printf("%d events in %2.2f min (%d s) Rate %f Hz %s ",i+1, (double)(t-tstart)/60.,(t-tstart), rate , ctime(&t)); |
|
- | 180 | GetCtrlVal(ph,PANEL_PFREQ, &pfreq); |
|
- | 181 | neveold = i; |
|
- | 182 | } |
|
- | 183 | told=t; |
|
- | 184 | // Save data |
|
- | 185 | if (nb>0 && fp) fwrite(buffer, 1,nb ,fp); |
|
139 | // Plot Data |
186 | // Plot Data |
140 |
|
187 | if (i % pfreq == 0) for (int k=0; k<4; k++) { |
141 | if (! (mask & ( 0x1<<k )) ) continue; |
188 | if (! (mask & ( 0x1<<k )) ) continue; |
142 | float *t=DRSGetTime(k); |
189 | float *t=DRSGetTime(k); |
143 | float *x=DRSGetWave( |
190 | float *x=DRSGetWave(k); |
144 | 191 | ||
145 | const |
192 | const int col[4]= {VAL_WHITE,VAL_RED,VAL_GREEN,VAL_BLUE}; |
146 | if (plothandle[k]) DeleteGraphPlot (ph, PANEL_GRAPH, plothandle[k], VAL_IMMEDIATE_DRAW); |
193 | if (plothandle[k]) DeleteGraphPlot (ph, PANEL_GRAPH, plothandle[k], VAL_IMMEDIATE_DRAW); |
147 | plothandle[k] = PlotXY (ph, PANEL_GRAPH, t, x, 1024, VAL_FLOAT, VAL_FLOAT, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, col[k]); |
194 | plothandle[k] = PlotXY (ph, PANEL_GRAPH, t, x, 1024, VAL_FLOAT, VAL_FLOAT, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, col[k]); |
148 | 195 | ||
149 | for (int i=0 ; i<1024 ; i++) { |
196 | for (int i=0 ; i<1024 ; i++) { |
150 | if (verbose) printf("[%d] %d. x= %3.2f y=%3.2f\n", k, i, t[i], x[i] ); |
197 | if (verbose) printf("[%d] %d. x= %3.2f y=%3.2f\n", k, i, t[i], x[i] ); |
151 | //h[k]->Fill( t[i], x[i]*1e-3); |
198 | //h[k]->Fill( t[i], x[i]*1e-3); |
- | 199 | } |
|
- | 200 | } |
|
- | 201 | ||
- | 202 | ||
- | 203 | } |
|
- | 204 | time(&t); |
|
- | 205 | printf("%d events in %2.2f min (%d s) %s",i+1, (double)(t-tstart)/60.,t-tstart, ctime(&t)); |
|
- | 206 | DRSEnd(); |
|
- | 207 | } |
|
- | 208 | ||
- | 209 | if (fp) fclose(fp); |
|
- | 210 | ||
- | 211 | free(buffer); |
|
- | 212 | ||
- | 213 | return 0; |
|
- | 214 | ||
- | 215 | } |
|
- | 216 | ||
- | 217 | ||
- | 218 | ||
- | 219 | int CVICALLBACK scan(void *functionData) { |
|
- | 220 | ||
- | 221 | int dx[2]; |
|
- | 222 | int nx[2]; |
|
- | 223 | int x0[2]; |
|
- | 224 | int ix[2]; |
|
- | 225 | int size; |
|
- | 226 | ||
- | 227 | char buffer[12]="POSR"; |
|
- | 228 | int *n = (int *) &buffer[4]; |
|
- | 229 | char filename[0xFF]; |
|
- | 230 | int enabledoutput; |
|
- | 231 | ||
- | 232 | FILE *fp; |
|
- | 233 | GetCtrlVal(ph, PANEL_FILENAME, filename ); |
|
- | 234 | ||
- | 235 | GetCtrlVal(ph,PANEL_ENABLEDOUTPUT, &enabledoutput); |
|
- | 236 | ||
- | 237 | if ( GetFileInfo(filename,&size) ) { |
|
- | 238 | MessagePopup ("Warning", "File exist. Remove it first or choose another file"); |
|
- | 239 | return 0; |
|
- | 240 | } |
|
- | 241 | GetCtrlVal(p2, SCAN_STEPX, &dx[0]); |
|
- | 242 | GetCtrlVal(p2, SCAN_STEPY, &dx[1]); |
|
- | 243 | GetCtrlVal(p2, SCAN_NSTEPSX, &nx[0]); |
|
- | 244 | GetCtrlVal(p2, SCAN_NSTEPSY, &nx[1]); |
|
- | 245 | GetCtrlVal(p2, SCAN_STARTX, &x0[0]); |
|
- | 246 | GetCtrlVal(p2, SCAN_STARTY, &x0[1]); |
|
- | 247 | for (int i=0; i<nx[0]; i++) { |
|
- | 248 | ||
- | 249 | ix[0]= x0[0]+i*dx[0]; |
|
- | 250 | #ifdef MIKRO |
|
- | 251 | MIKRO_MoveTo(1,ix[0]); |
|
- | 252 | #endif |
|
- | 253 | SetCtrlVal (p2, SCAN_IX, i); |
|
- | 254 | for (int j=0; j<nx[1]; j++) { |
|
- | 255 | ||
- | 256 | SetCtrlVal (p2, SCAN_IY, j); |
|
- | 257 | ||
- | 258 | ix[1]= x0[1]+j*dx[1]; |
|
- | 259 | #ifdef MIKRO |
|
- | 260 | MIKRO_MoveTo(2,ix[1]); |
|
- | 261 | ||
- | 262 | MIKRO_GetPosition(1,&n[0]); |
|
- | 263 | SetCtrlVal (p2, SCAN_XP, n[0]); |
|
- | 264 | MIKRO_GetPosition(2,&n[1]); |
|
- | 265 | SetCtrlVal (p2, SCAN_YP, n[1]); |
|
- | 266 | if (enabledoutput) { |
|
- | 267 | fp = fopen(filename,"ab"); |
|
- | 268 | if (fp) { |
|
- | 269 | fwrite(buffer, 1,12 ,fp); |
|
- | 270 | fclose(fp); |
|
152 | } |
271 | } |
- | 272 | } |
|
- | 273 | ||
- | 274 | #endif |
|
- | 275 | daq(functionData); |
|
- | 276 | if (!daq_on) break; |
|
153 | } |
277 | } |
- | 278 | if (!daq_on) break; |
|
- | 279 | } |
|
- | 280 | ||
- | 281 | return 0; |
|
- | 282 | } |
|
- | 283 | ||
- | 284 | ||
- | 285 | int CVICALLBACK StartCB (int panel, int control, int event, |
|
- | 286 | void *callbackData, int eventData1, int eventData2) { |
|
- | 287 | ThreadFunctionPtr mythread = NULL; |
|
- | 288 | switch (event) { |
|
- | 289 | ||
- | 290 | case EVENT_COMMIT: |
|
- | 291 | ||
- | 292 | controlID=0; |
|
- | 293 | if (panel == ph && control == PANEL_START) { |
|
- | 294 | mythread = daq; |
|
- | 295 | controlID= control; |
|
- | 296 | } |
|
- | 297 | if (panel == p2 && control == SCAN_SCAN) mythread = scan; |
|
- | 298 | if (mythread!=NULL) { |
|
- | 299 | printf("New Thread panel=%d button=%d\n", panel, control); |
|
- | 300 | ||
- | 301 | // SetDimming(1); |
|
- | 302 | ||
- | 303 | daq_on=1; |
|
- | 304 | CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &controlID, |
|
- | 305 | DEFAULT_THREAD_PRIORITY, |
|
- | 306 | EndOfThread, |
|
- | 307 | EVENT_TP_THREAD_FUNCTION_END, |
|
- | 308 | NULL, RUN_IN_SCHEDULED_THREAD, |
|
- | 309 | &tfID); |
|
- | 310 | } |
|
- | 311 | break; |
|
- | 312 | } |
|
- | 313 | return 0; |
|
- | 314 | } |
|
- | 315 | ||
- | 316 | int CVICALLBACK StopCB (int panel, int control, int event, |
|
- | 317 | void *callbackData, int eventData1, int eventData2) { |
|
- | 318 | switch (event) { |
|
- | 319 | case EVENT_COMMIT: |
|
- | 320 | daq_on=0; |
|
- | 321 | break; |
|
- | 322 | } |
|
- | 323 | return 0; |
|
- | 324 | } |
|
- | 325 | ||
- | 326 | int CVICALLBACK ExitCB (int panel, int control, int event, |
|
- | 327 | void *callbackData, int eventData1, int eventData2) { |
|
- | 328 | switch (event) { |
|
- | 329 | case EVENT_COMMIT: |
|
- | 330 | QuitUserInterface (0); |
|
- | 331 | break; |
|
- | 332 | } |
|
- | 333 | return 0; |
|
- | 334 | } |
|
- | 335 | ||
- | 336 | int CVICALLBACK MoveStageCB (int panel, int control, int event, |
|
- | 337 | void *callbackData, int eventData1, int eventData2) { |
|
- | 338 | int axis=0, step=1000, direction=1, n; |
|
- | 339 | switch (event) { |
|
- | 340 | case EVENT_COMMIT: |
|
- | 341 | ||
- | 342 | if (panel == p2) { |
|
- | 343 | switch (control) { |
|
- | 344 | case SCAN_BR : |
|
- | 345 | axis = 1; |
|
- | 346 | direction = 1; |
|
- | 347 | GetCtrlVal(p2, SCAN_STEPX, &step); |
|
- | 348 | break; |
|
- | 349 | case SCAN_BL : |
|
- | 350 | axis = 1; |
|
- | 351 | direction = -1; |
|
- | 352 | GetCtrlVal(p2, SCAN_STEPX, &step); |
|
- | 353 | break; |
|
- | 354 | case SCAN_BU : |
|
- | 355 | axis = 2; |
|
- | 356 | direction = 1; |
|
- | 357 | GetCtrlVal(p2, SCAN_STEPY, &step); |
|
- | 358 | break; |
|
- | 359 | case SCAN_BD : |
|
- | 360 | axis = 2; |
|
- | 361 | direction = -1; |
|
- | 362 | GetCtrlVal(p2, SCAN_STEPY, &step); |
|
- | 363 | break; |
|
- | 364 | } |
|
- | 365 | #ifdef MIKRO |
|
- | 366 | MIKRO_MoveFor(axis, direction*step ); |
|
- | 367 | MIKRO_GetPosition(axis,&n); |
|
- | 368 | if (axis == 1) SetCtrlVal (p2, SCAN_XP, n); |
|
- | 369 | if (axis == 2) SetCtrlVal (p2, SCAN_YP, n); |
|
- | 370 | #endif // MIKRO |
|
- | 371 | } |
|
- | 372 | ||
- | 373 | break; |
|
- | 374 | } |
|
- | 375 | return 0; |
|
- | 376 | } |
|
- | 377 | ||
- | 378 | ||
- | 379 | ||
- | 380 | ||
- | 381 | ||
- | 382 | int CVICALLBACK GoXCB (int panel, int control, int event, |
|
- | 383 | void *callbackData, int eventData1, int eventData2) { |
|
- | 384 | int n2; |
|
- | 385 | switch (event) { |
|
- | 386 | case EVENT_COMMIT: |
|
- | 387 | GetCtrlVal (p2, SCAN_XG, &n2); |
|
- | 388 | #ifdef MIKRO |
|
- | 389 | MIKRO_MoveTo(1,n2); |
|
- | 390 | MIKRO_GetPosition(1,&n2); |
|
- | 391 | ||
- | 392 | #endif |
|
- | 393 | SetCtrlVal (p2, SCAN_XP, n2); |
|
- | 394 | break; |
|
- | 395 | } |
|
- | 396 | return 0; |
|
- | 397 | } |
|
- | 398 | ||
- | 399 | int CVICALLBACK GoYCB (int panel, int control, int event, |
|
- | 400 | void *callbackData, int eventData1, int eventData2) { |
|
- | 401 | int n2; |
|
- | 402 | switch (event) { |
|
- | 403 | case EVENT_COMMIT: |
|
- | 404 | GetCtrlVal (p2, SCAN_YG, &n2); |
|
- | 405 | #ifdef MIKRO |
|
- | 406 | MIKRO_MoveTo(2,n2); |
|
- | 407 | MIKRO_GetPosition(2,&n2); |
|
- | 408 | ||
- | 409 | #endif |
|
- | 410 | SetCtrlVal (p2, SCAN_YP, n2); |
|
- | 411 | break; |
|
- | 412 | } |
|
- | 413 | return 0; |
|
- | 414 | } |
|
- | 415 | ||
- | 416 | int CVICALLBACK GetCurrentPositionCB (int panel, int control, int event, |
|
- | 417 | void *callbackData, int eventData1, int eventData2) { |
|
154 | 418 | ||
155 | 419 | int n[2]; |
|
- | 420 | switch (event) { |
|
- | 421 | case EVENT_COMMIT: |
|
- | 422 | #ifdef MIKRO |
|
- | 423 | MIKRO_GetPosition(1,&n[0]); |
|
- | 424 | SetCtrlVal (p2, SCAN_XP, n[0]); |
|
- | 425 | MIKRO_GetPosition(2,&n[1]); |
|
- | 426 | SetCtrlVal (p2, SCAN_YP, n[1]); |
|
- | 427 | #endif |
|
- | 428 | break; |
|
156 | } |
429 | } |
157 | time(&t); |
- | |
158 | printf("%d events in %2.2f min (%d s) %s",i+1, (double)(t-tstart)/60.,t-tstart, ctime(&t)); |
- | |
159 | DRSEnd(); |
- | |
160 | } |
- | |
161 | - | ||
162 | if (fp) fclose(fp); |
- | |
163 | - | ||
164 | free(buffer); |
- | |
165 | - | ||
166 | return 0; |
- | |
167 | - | ||
168 | } |
- | |
169 | - | ||
170 | int CVICALLBACK StartCB (int panel, int control, int event, |
- | |
171 | void *callbackData, int eventData1, int eventData2) { |
- | |
172 | ThreadFunctionPtr mythread = NULL; |
- | |
173 | switch (event) { |
- | |
174 | - | ||
175 | case EVENT_COMMIT: |
- | |
176 | - | ||
177 | mythread = daq; |
- | |
178 | if (mythread!=NULL) { |
- | |
179 | printf("New Thread panel=%d button=%d\n", panel, control); |
- | |
180 | - | ||
181 | // SetDimming(1); |
- | |
182 | controlID= control; |
- | |
183 | daq_on=1; |
- | |
184 | CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &controlID, |
- | |
185 | DEFAULT_THREAD_PRIORITY, |
- | |
186 | EndOfThread, |
- | |
187 | EVENT_TP_THREAD_FUNCTION_END, |
- | |
188 | NULL, RUN_IN_SCHEDULED_THREAD, |
- | |
189 | &tfID); |
- | |
190 | } |
- | |
191 | break; |
- | |
192 | } |
- | |
193 | return 0; |
- | |
194 | } |
- | |
195 | - | ||
196 | int CVICALLBACK StopCB (int panel, int control, int event, |
- | |
197 | void *callbackData, int eventData1, int eventData2) { |
- | |
198 | switch (event) { |
- | |
199 | case EVENT_COMMIT: |
- | |
200 | daq_on=0; |
- | |
201 | break; |
- | |
202 | } |
- | |
203 | return 0; |
430 | return 0; |
204 | } |
431 | } |
205 | 432 | ||
206 | int CVICALLBACK |
433 | int CVICALLBACK HomeCB (int panel, int control, int event, |
207 | void *callbackData, int eventData1, int eventData2) { |
434 | void *callbackData, int eventData1, int eventData2) { |
208 | switch (event) { |
435 | switch (event) { |
209 | case EVENT_COMMIT: |
436 | case EVENT_COMMIT: |
- | 437 | #ifdef MIKRO |
|
- | 438 | MIKRO_ReferenceMove(1); |
|
210 |
|
439 | MIKRO_ReferenceMove(2); |
- | 440 | GetCurrentPositionCB(panel, control, event, NULL, 0, 0); |
|
- | 441 | #endif |
|
211 | break; |
442 | break; |
212 | } |
443 | } |
213 | return 0; |
444 | return 0; |
214 | } |
445 | } |