Rev 212 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 212 | Rev 292 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | 10 | ||
11 | #include "H1D.h" |
11 | #include "H1D.h" |
12 | #include "H2D.h" |
12 | #include "H2D.h" |
13 | #include "H3D.h" |
13 | #include "H3D.h" |
14 | 14 | ||
15 | - | ||
- | 15 | static int node[3]; |
|
16 | typedef unsigned short ushort; |
16 | typedef unsigned short ushort; |
17 | typedef unsigned int uint; |
17 | typedef unsigned int uint; |
18 | 18 | ||
19 | static int ait; |
19 | static int ait; |
20 | static int xyscan; |
20 | static int xyscan; |
21 | //#define MIKRO |
21 | //#define MIKRO |
22 | 22 | ||
23 | #ifdef MIKRO |
23 | #ifdef MIKRO |
24 | #include "MIKRO.h" |
24 | #include "MIKRO.h" |
25 | #endif |
25 | #endif |
26 | 26 | ||
- | 27 | #define uSMC_USB |
|
- | 28 | #ifdef uSMC_USB |
|
- | 29 | # include "uSMC.h" |
|
- | 30 | # define uSMC_SERIAL_X "0000000000004925" |
|
- | 31 | # define uSMC_SERIAL_Y "0000000000006030" |
|
- | 32 | # define uSMC_SERIAL_Z "0000000000002894" |
|
- | 33 | const char serials[3][16]= {uSMC_SERIAL_X,uSMC_SERIAL_Y,uSMC_SERIAL_Z}; |
|
- | 34 | #endif /* uSMC_USB */ |
|
- | 35 | ||
27 | static int daq_on; |
36 | static int daq_on; |
28 | static int plothandle[4]= {0,0,0, 0}; |
37 | static int plothandle[4]= {0,0,0, 0}; |
29 | static int tfID; |
38 | static int tfID; |
30 | static int controlID; |
39 | static int controlID; |
31 | static int verbose; |
40 | static int verbose; |
Line 104... | Line 113... | ||
104 | 113 | ||
105 | } |
114 | } |
106 | 115 | ||
107 | int AitInit() { |
116 | int AitInit() { |
108 | InitializeConnection(); |
117 | InitializeConnection(); |
109 | return 0; |
118 | return 0; |
110 | } |
119 | } |
111 | 120 | ||
112 | 121 | ||
113 | int AitValidEvent() { |
122 | int AitValidEvent() { |
114 | 123 | ||
115 | return 1; |
124 | return 1; |
116 | }; |
125 | }; |
117 | 126 | ||
118 | int AitToFile(FILE *fp, int n) { |
127 | int AitToFile(FILE *fp, int n) { |
119 | const int bsize=10000 ; |
128 | const int bsize=10000 ; |
120 | unsigned short a[bsize] ; |
129 | unsigned short a[bsize] ; |
121 | unsigned short buffer[2]={0x1}; |
130 | unsigned short buffer[2]={0x1}; |
122 | buffer[1] = (unsigned short)(n*CHANNELS*2); |
131 | buffer[1] = (unsigned short)(n*CHANNELS*2); |
123 | for (int eventNum = 0; eventNum < n; eventNum++) { |
132 | for (int eventNum = 0; eventNum < n; eventNum++) { |
124 | 133 | ||
125 | for (int channel = 0; channel < CHANNELS; channel++) { |
134 | for (int channel = 0; channel < CHANNELS; channel++) { |
126 | int index = channel+ CHANNELS * eventNum; |
135 | int index = channel+ CHANNELS * eventNum; |
127 | if (index<bsize) |
136 | if (index<bsize) |
128 | a[index] = ExtractAdcData(eventNum, channel); |
137 | a[index] = ExtractAdcData(eventNum, channel); |
129 | } |
138 | } |
130 | } |
139 | } |
Line 144... | Line 153... | ||
144 | int total[CHANNELS]; |
153 | int total[CHANNELS]; |
145 | for (int i = 0; i < CHANNELS; i++) { |
154 | for (int i = 0; i < CHANNELS; i++) { |
146 | min[i] = 0xFFFF; |
155 | min[i] = 0xFFFF; |
147 | max[i] = 0; |
156 | max[i] = 0; |
148 | total[i] = 0; |
157 | total[i] = 0; |
149 | } |
158 | } |
150 | 159 | ||
151 | double threshold, xysumcut; |
160 | double threshold, xysumcut; |
152 | GetCtrlVal (ait, AIT_ADCTHRESHOLD, &threshold); |
161 | GetCtrlVal (ait, AIT_ADCTHRESHOLD, &threshold); |
153 | GetCtrlVal (ait, AIT_XYCUT, &xysumcut); |
162 | GetCtrlVal (ait, AIT_XYCUT, &xysumcut); |
154 | 163 | ||
Line 180... | Line 189... | ||
180 | max[channel] = adcData; |
189 | max[channel] = adcData; |
181 | else if (adcData < min[channel]) |
190 | else if (adcData < min[channel]) |
182 | min[channel] = adcData; |
191 | min[channel] = adcData; |
183 | 192 | ||
184 | sum += adcData; |
193 | sum += adcData; |
185 | } |
194 | } |
186 | if (sum>threshold) { |
195 | if (sum>threshold) { |
187 | H1D_Fill(10, sum, 1 ); |
196 | H1D_Fill(10, sum, 1 ); |
188 | double x = a[0]/(a[0]+a[1]); |
197 | double x = a[0]/(a[0]+a[1]); |
189 | double y = a[2]/(a[2]+a[3]); |
198 | double y = a[2]/(a[2]+a[3]); |
190 | if (sum>xysumcut) H2D_Fill(0, x, y , 1 ); |
199 | if (sum>xysumcut) H2D_Fill(0, x, y , 1 ); |
191 | } |
200 | } |
192 | histogramTotalEvents++; |
201 | histogramTotalEvents++; |
193 | } |
202 | } |
194 | //tbAdcStatistics.Clear(); |
203 | //tbAdcStatistics.Clear(); |
195 | for (int channel = 0; channel < CHANNELS; channel++) { |
204 | for (int channel = 0; channel < CHANNELS; channel++) { |
196 | average[channel] = (ushort)(total[channel] / events); |
205 | average[channel] = (ushort)(total[channel] / events); |
197 | 206 | ||
198 | if (verbose) AddMessage(" {channel:%d} : {min:0x%d} {max:0x%d} {max-min:%d} {average:%d}\n", channel + 1, min[channel], max[channel], max[channel] - min[channel], average[channel]); |
207 | if (verbose) AddMessage(" {channel:%d} : {min:0x%d} {max:0x%d} {max-min:%d} {average:%d}\n", channel + 1, min[channel], max[channel], max[channel] - min[channel], average[channel]); |
199 | //if (channel < (CHANNELS - 1)) |
208 | //if (channel < (CHANNELS - 1)) |
200 | // tbAdcStatistics.AppendText(Environment.NewLine); |
209 | // tbAdcStatistics.AppendText(Environment.NewLine); |
201 | 210 | ||
202 | } |
211 | } |
203 | //SetTextboxToTop(tbAdcStatistics); |
212 | //SetTextboxToTop(tbAdcStatistics); |
204 | return 1; |
213 | return 1; |
205 | }; |
214 | }; |
206 | 215 | ||
207 | 216 | ||
208 | int CVICALLBACK RefreshGraphs (int panel, int control, int event, |
217 | int CVICALLBACK RefreshGraphs (int panel, int control, int event, |
209 | void *callbackData, int eventData1, int eventData2) { |
218 | void *callbackData, int eventData1, int eventData2) { |
210 | switch (event) { |
219 | switch (event) { |
211 | case EVENT_TIMER_TICK: |
220 | case EVENT_TIMER_TICK: |
212 | // if (!daq_on ) return 0; |
221 | // if (!daq_on ) return 0; |
213 | case EVENT_COMMIT: { |
222 | case EVENT_COMMIT: { |
214 | 223 | ||
Line 238... | Line 247... | ||
238 | 247 | ||
239 | break; |
248 | break; |
240 | 249 | ||
241 | } |
250 | } |
242 | return 0; |
251 | return 0; |
243 | } |
252 | } |
244 | 253 | ||
245 | 254 | ||
246 | 255 | ||
247 | int CVICALLBACK daq(void *functionData) { |
256 | int CVICALLBACK daq(void *functionData) { |
248 | 257 | ||
249 | 258 | ||
250 | int neve; |
259 | int neve; |
251 | char filename[0xff]; |
260 | char filename[0xff]; |
252 | char fname[0xff]; |
261 | char fname[0xff]; |
253 | char pname[0xff]; |
262 | char pname[0xff]; |
254 | 263 | ||
255 | 264 | ||
256 | 265 | ||
257 | int pfreq; |
266 | int pfreq; |
258 | int enabledoutput; |
267 | int enabledoutput; |
259 | int neveold = 0; |
268 | int neveold = 0; |
260 | double rate; |
269 | double rate; |
Line 272... | Line 281... | ||
272 | 281 | ||
273 | int range=0; |
282 | int range=0; |
274 | int nch = range; |
283 | int nch = range; |
275 | GetCtrlVal(ait,AIT_MAX, &range); |
284 | GetCtrlVal(ait,AIT_MAX, &range); |
276 | if (range>512) nch = 512; |
285 | if (range>512) nch = 512; |
277 | 286 | ||
278 | 287 | ||
279 | for (int i=0; i<4; i++) { |
288 | for (int i=0; i<4; i++) { |
280 | char name[0xFF]; |
289 | char name[0xFF]; |
281 | sprintf(name,"adc%d", i); |
290 | sprintf(name,"adc%d", i); |
282 | 291 | ||
283 | H1D_Init(i, name,name, range, 0 , range); |
292 | H1D_Init(i, name,name, range, 0 , range); |
284 | H1D_SetTitleX(0,"ADC"); |
293 | H1D_SetTitleX(0,"ADC"); |
285 | H1D_SetTitleY(0,"N"); |
294 | H1D_SetTitleY(0,"N"); |
286 | } |
295 | } |
287 | H1D_Init(10, "adcsum","adcsum", range, 0 , 4*range); |
296 | H1D_Init(10, "adcsum","adcsum", range, 0 , 4*range); |
288 | H1D_SetTitleX(0,"ADC"); |
297 | H1D_SetTitleX(0,"ADC"); |
289 | H1D_SetTitleY(0,"N"); |
298 | H1D_SetTitleY(0,"N"); |
290 | 299 | ||
291 | H2D_Init(0, "cog","Center of gravity", 256, 0 ,1, 256, 0 ,1); |
300 | H2D_Init(0, "cog","Center of gravity", 256, 0 ,1, 256, 0 ,1); |
292 | H2D_SetTitleX(0,"x"); |
301 | H2D_SetTitleX(0,"x"); |
293 | H2D_SetTitleY(0,"y"); |
302 | H2D_SetTitleY(0,"y"); |
294 | 303 | ||
295 | 304 | ||
296 | 305 | ||
297 | FILE *fp= NULL; |
306 | FILE *fp= NULL; |
298 | 307 | ||
299 | if (enabledoutput) { |
308 | if (enabledoutput) { |
300 | if (args[0]) fp = fopen(filename,"wb"); |
309 | if (args[0]) fp = fopen(filename,"wb"); |
301 | else fp = fopen(filename,"ab"); |
310 | else fp = fopen(filename,"ab"); |
302 | } |
311 | } |
303 | 312 | ||
304 | 313 | ||
305 | 314 | ||
306 | 315 | ||
307 | 316 | ||
308 | time_t t=0,told=0, tstart=0; |
317 | time_t t=0,told=0, tstart=0; |
309 | 318 | ||
310 | if (!AitInit()) { |
319 | if (!AitInit()) { |
311 | 320 | ||
312 | 321 | ||
Line 387... | Line 396... | ||
387 | 396 | ||
388 | 397 | ||
389 | } |
398 | } |
390 | time(&t); |
399 | time(&t); |
391 | printf("%d events in %2.2f min (%d s) %s",i+1, (double)(t-tstart)/60.,t-tstart, ctime(&t)); |
400 | printf("%d events in %2.2f min (%d s) %s",i+1, (double)(t-tstart)/60.,t-tstart, ctime(&t)); |
392 | 401 | ||
393 | } |
402 | } |
394 | 403 | ||
395 | if (fp) fclose(fp); |
404 | if (fp) fclose(fp); |
396 | - | ||
397 | - | ||
398 | RefreshGraphs (ait, 0 , EVENT_TIMER_TICK ,NULL, 0, 0 ); |
- | |
399 | return 0; |
- | |
400 | - | ||
401 | } |
- | |
402 | 405 | ||
403 | 406 | ||
- | 407 | RefreshGraphs (ait, 0 , EVENT_TIMER_TICK ,NULL, 0, 0 ); |
|
- | 408 | return 0; |
|
- | 409 | ||
- | 410 | } |
|
- | 411 | ||
- | 412 | ||
404 | int CVICALLBACK scan(void *functionData) { |
413 | int CVICALLBACK scan(void *functionData) { |
405 | 414 | ||
406 | int dx[3]={0,0,0}; |
415 | int dx[3]={0,0,0}; |
407 | int nx[3]={0,0,0}; |
416 | int nx[3]={0,0,0}; |
408 | int x0[3]={0,0,0}; |
417 | int x0[3]={0,0,0}; |
409 | int ix[3]={0,0,0}; |
418 | int ix[3]={0,0,0}; |
Line 457... | Line 466... | ||
457 | #ifdef MIKRO |
466 | #ifdef MIKRO |
458 | MIKRO_MoveTo(2,ix[1]); |
467 | MIKRO_MoveTo(2,ix[1]); |
459 | MIKRO_GetPosition(2,&n[1]); |
468 | MIKRO_GetPosition(2,&n[1]); |
460 | SetCtrlVal (xyscan, SCAN_YP, n[1]); |
469 | SetCtrlVal (xyscan, SCAN_YP, n[1]); |
461 | #endif |
470 | #endif |
- | 471 | #ifdef uSMC_USB |
|
- | 472 | uSMC_MoveTo(node[1],ix[1]); |
|
- | 473 | uSMC_GetPosition(node[1],&n[1]); |
|
- | 474 | SetCtrlVal (xyscan, SCAN_YP, n[1]); |
|
- | 475 | #endif |
|
- | 476 | ||
- | 477 | ||
462 | 478 | ||
463 | for (int i=0; i<nx[0]; i++) { |
479 | for (int i=0; i<nx[0]; i++) { |
464 | SetCtrlVal (xyscan, SCAN_IX, i); |
480 | SetCtrlVal (xyscan, SCAN_IX, i); |
465 | ix[0]= x0[0]+i*dx[0]; |
481 | ix[0]= x0[0]+i*dx[0]; |
466 | #ifdef MIKRO |
482 | #ifdef MIKRO |
467 | MIKRO_MoveTo(1,ix[0]); |
483 | MIKRO_MoveTo(1,ix[0]); |
468 | MIKRO_GetPosition(1,&n[0]); |
484 | MIKRO_GetPosition(1,&n[0]); |
469 | SetCtrlVal (xyscan, SCAN_XP, n[0]); |
485 | SetCtrlVal (xyscan, SCAN_XP, n[0]); |
- | 486 | #endif |
|
- | 487 | #ifdef uSMC_USB |
|
- | 488 | uSMC_MoveTo(node[0],ix[0]); |
|
- | 489 | uSMC_GetPosition(node[0],&n[0]); |
|
- | 490 | SetCtrlVal (xyscan, SCAN_XP, n[0]); |
|
470 | 491 | #endif |
|
471 | 492 | ||
472 | if (enabledoutput) { |
493 | if (enabledoutput) { |
473 | fp = fopen(filename,"ab"); |
494 | fp = fopen(filename,"ab"); |
474 | if (fp) { |
495 | if (fp) { |
475 | time_t mtime; |
496 | time_t mtime; |
Line 484... | Line 505... | ||
484 | fwrite(&mtime , sizeof(time_t),1 ,fp); |
505 | fwrite(&mtime , sizeof(time_t),1 ,fp); |
485 | fclose(fp); |
506 | fclose(fp); |
486 | } |
507 | } |
487 | } |
508 | } |
488 | 509 | ||
489 | #endif |
510 | |
490 | int newfile=0; |
511 | int newfile=0; |
491 | daq(&newfile); |
512 | daq(&newfile); |
492 | if (!daq_on) break; |
513 | if (!daq_on) break; |
493 | } |
514 | } |
494 | if (!daq_on) break; |
515 | if (!daq_on) break; |
Line 497... | Line 518... | ||
497 | return 0; |
518 | return 0; |
498 | } |
519 | } |
499 | 520 | ||
500 | 521 | ||
501 | int main (int argc, char *argv[]) { |
522 | int main (int argc, char *argv[]) { |
502 | short port; |
523 | |
503 | if (InitCVIRTE (0, argv, 0) == 0) |
524 | if (InitCVIRTE (0, argv, 0) == 0) |
504 | return -1; /* out of memory */ |
525 | return -1; /* out of memory */ |
505 | if ((ait = LoadPanel (0, "AitGui.uir", AIT)) < 0) |
526 | if ((ait = LoadPanel (0, "AitGui.uir", AIT)) < 0) |
506 | return -1; |
527 | return -1; |
507 | if ((xyscan = LoadPanel (0, "XYSCAN.uir", SCAN)) < 0) |
528 | if ((xyscan = LoadPanel (0, "XYSCAN.uir", SCAN)) < 0) |
Line 513... | Line 534... | ||
513 | DisplayPanel (xyscan); |
534 | DisplayPanel (xyscan); |
514 | AitInit(); |
535 | AitInit(); |
515 | 536 | ||
516 | 537 | ||
517 | #ifdef MIKRO |
538 | #ifdef MIKRO |
- | 539 | short port; |
|
518 | GetCtrlVal(xyscan, SCAN_PORT, &port); |
540 | GetCtrlVal(xyscan, SCAN_PORT, &port); |
519 | if (MIKRO_Open (port)) MessagePopup ("Error", "Mikro Port Not found !\n Change in the GUI") ; |
541 | if (MIKRO_Open (port)) MessagePopup ("Error", "Mikro Port Not found !\n Change in the GUI") ; |
520 | MIKRO_Init(1,0); |
542 | MIKRO_Init(1,0); |
521 | MIKRO_Init(2,0); |
543 | MIKRO_Init(2,0); |
522 | #endif |
544 | #endif |
- | 545 | #ifdef uSMC_USB |
|
- | 546 | uSMC_Open(); |
|
- | 547 | for (int i=0; i<3; i++) { |
|
- | 548 | node[i]=uSMC_FindSerial(serials[i])+1; |
|
- | 549 | uSMC_Init(node[i],1); |
|
- | 550 | } |
|
- | 551 | #endif /* uSMC_USB */ |
|
523 | 552 | ||
524 | 553 | ||
525 | RunUserInterface (); |
554 | RunUserInterface (); |
526 | 555 | ||
527 | #ifdef MIKRO |
556 | #ifdef MIKRO |
528 | MIKRO_Close (); |
557 | MIKRO_Close (); |
529 | #endif |
558 | #endif |
- | 559 | #ifdef uSMC_USB |
|
- | 560 | for (int i=0; i<3; i++) uSMC_PowerOff(node[i]); |
|
- | 561 | uSMC_Close(); |
|
- | 562 | #endif /* uSMC_USB */ |
|
530 | DiscardPanel (ait); |
563 | DiscardPanel (ait); |
531 | DiscardPanel (xyscan); |
564 | DiscardPanel (xyscan); |
532 | return 0; |
565 | return 0; |
533 | } |
566 | } |
534 | 567 | ||
535 | int CVICALLBACK StopCB (int panel, int control, int event, |
568 | int CVICALLBACK StopCB (int panel, int control, int event, |
536 | void *callbackData, int eventData1, int eventData2) { |
569 | void *callbackData, int eventData1, int eventData2) { |
537 | switch (event) { |
570 | switch (event) { |
538 | case EVENT_COMMIT: |
571 | case EVENT_COMMIT: |
539 | daq_on=0; |
572 | daq_on=0; |
540 | break; |
573 | break; |
541 | } |
574 | } |
Line 566... | Line 599... | ||
566 | DEFAULT_THREAD_PRIORITY, |
599 | DEFAULT_THREAD_PRIORITY, |
567 | EndOfThread, |
600 | EndOfThread, |
568 | EVENT_TP_THREAD_FUNCTION_END, |
601 | EVENT_TP_THREAD_FUNCTION_END, |
569 | NULL, RUN_IN_SCHEDULED_THREAD, |
602 | NULL, RUN_IN_SCHEDULED_THREAD, |
570 | &tfID); |
603 | &tfID); |
571 | } |
604 | } |
572 | break; |
605 | break; |
573 | } |
606 | } |
574 | return 0; |
607 | return 0; |
575 | } |
608 | } |
576 | 609 | ||
577 | 610 | ||
578 | 611 | ||
579 | int CVICALLBACK ExitCB (int panel, int control, int event, |
612 | int CVICALLBACK ExitCB (int panel, int control, int event, |
580 | void *callbackData, int eventData1, int eventData2) { |
613 | void *callbackData, int eventData1, int eventData2) { |
581 | switch (event) { |
614 | switch (event) { |
582 | case EVENT_COMMIT: |
615 | case EVENT_COMMIT: |
583 | QuitUserInterface (0); |
616 | QuitUserInterface (0); |
584 | break; |
617 | break; |
585 | } |
618 | } |
586 | return 0; |
619 | return 0; |
587 | } |
620 | } |
588 | 621 | ||
589 | int CVICALLBACK ReadCB (int panel, int control, int event, |
622 | int CVICALLBACK ReadCB (int panel, int control, int event, |
590 | void *callbackData, int eventData1, int eventData2) { |
623 | void *callbackData, int eventData1, int eventData2) { |
591 | switch (event) { |
624 | switch (event) { |
592 | case EVENT_COMMIT: |
625 | case EVENT_COMMIT: |
593 | 626 | ||
594 | 627 | ||
595 | 628 | ||
596 | ReadRegisters(); |
629 | ReadRegisters(); |
597 | break; |
630 | break; |
598 | } |
631 | } |
599 | return 0; |
632 | return 0; |
600 | } |
633 | } |
601 | 634 | ||
602 | int CVICALLBACK ChangeChannelCB (int panel, int control, int event, |
635 | int CVICALLBACK ChangeChannelCB (int panel, int control, int event, |
603 | void *callbackData, int eventData1, int eventData2) { |
636 | void *callbackData, int eventData1, int eventData2) { |
604 | int ch=0; |
637 | int ch=0; |
Line 716... | Line 749... | ||
716 | MIKRO_GetPosition(axis,&n); |
749 | MIKRO_GetPosition(axis,&n); |
717 | if (axis == 1) SetCtrlVal (panel, SCAN_XP, n); |
750 | if (axis == 1) SetCtrlVal (panel, SCAN_XP, n); |
718 | if (axis == 2) SetCtrlVal (panel, SCAN_YP, n); |
751 | if (axis == 2) SetCtrlVal (panel, SCAN_YP, n); |
719 | } |
752 | } |
720 | #endif // MIKRO |
753 | #endif // MIKRO |
- | 754 | ||
- | 755 | #ifdef uSMC_USB |
|
- | 756 | { |
|
- | 757 | int n=0; |
|
- | 758 | uSMC_MoveFor(node[axis-1], direction*step ); |
|
- | 759 | uSMC_GetPosition(node[axis-1],&n); |
|
- | 760 | if (axis == 1) SetCtrlVal (panel, SCAN_XP, n); |
|
- | 761 | if (axis == 2) SetCtrlVal (panel, SCAN_YP, n); |
|
- | 762 | } |
|
- | 763 | #endif // MIKRO |
|
721 | } |
764 | } |
722 | 765 | ||
723 | break; |
766 | break; |
724 | } |
767 | } |
725 | return 0; |
768 | return 0; |
726 | } |
769 | } |
727 | 770 | ||
728 | 771 | ||
729 | 772 | ||
730 | 773 | ||
731 | 774 | ||
732 | int CVICALLBACK GoXCB (int panel, int control, int event, |
775 | int CVICALLBACK GoXCB (int panel, int control, int event, |
733 | void *callbackData, int eventData1, int eventData2) { |
776 | void *callbackData, int eventData1, int eventData2) { |
734 | int n2; |
777 | int n2; |
735 | switch (event) { |
778 | switch (event) { |
736 | case EVENT_COMMIT: |
779 | case EVENT_COMMIT: |
737 | GetCtrlVal (panel, SCAN_XG, &n2); |
780 | GetCtrlVal (panel, SCAN_XG, &n2); |
738 | #ifdef MIKRO |
781 | #ifdef MIKRO |
739 | MIKRO_MoveTo(1,n2); |
782 | MIKRO_MoveTo(1,n2); |
740 | MIKRO_GetPosition(1,&n2); |
783 | MIKRO_GetPosition(1,&n2); |
741 | - | ||
742 | #endif |
784 | #endif |
- | 785 | #ifdef uSMC_USB |
|
- | 786 | uSMC_MoveTo(node[0],n2); |
|
- | 787 | uSMC_GetPosition(node[0],&n2); |
|
- | 788 | #endif |
|
- | 789 | ||
743 | SetCtrlVal (panel, SCAN_XP, n2); |
790 | SetCtrlVal (panel, SCAN_XP, n2); |
744 | break; |
791 | break; |
745 | } |
792 | } |
746 | return 0; |
793 | return 0; |
747 | } |
794 | } |
748 | 795 | ||
749 | int CVICALLBACK GoYCB (int panel, int control, int event, |
796 | int CVICALLBACK GoYCB (int panel, int control, int event, |
750 | void *callbackData, int eventData1, int eventData2) { |
797 | void *callbackData, int eventData1, int eventData2) { |
751 | int n2; |
798 | int n2; |
752 | switch (event) { |
799 | switch (event) { |
753 | case EVENT_COMMIT: |
800 | case EVENT_COMMIT: |
754 | GetCtrlVal (panel, SCAN_YG, &n2); |
801 | GetCtrlVal (panel, SCAN_YG, &n2); |
755 | #ifdef MIKRO |
802 | #ifdef MIKRO |
756 | MIKRO_MoveTo(2,n2); |
803 | MIKRO_MoveTo(2,n2); |
757 | MIKRO_GetPosition(2,&n2); |
804 | MIKRO_GetPosition(2,&n2); |
758 | 805 | ||
- | 806 | #endif |
|
- | 807 | #ifdef uSMC_USB |
|
- | 808 | uSMC_MoveTo(node[1],n2); |
|
- | 809 | uSMC_GetPosition(node[1],&n2); |
|
759 | #endif |
810 | #endif |
760 | SetCtrlVal (panel, SCAN_YP, n2); |
811 | SetCtrlVal (panel, SCAN_YP, n2); |
761 | break; |
812 | break; |
762 | } |
813 | } |
763 | return 0; |
814 | return 0; |
764 | } |
815 | } |
765 | 816 | ||
766 | int CVICALLBACK GetCurrentPositionCB (int panel, int control, int event, |
817 | int CVICALLBACK GetCurrentPositionCB (int panel, int control, int event, |
767 | void *callbackData, int eventData1, int eventData2) { |
818 | void *callbackData, int eventData1, int eventData2) { |
768 | 819 | ||
769 | 820 | int n[2]; |
|
770 | switch (event) { |
821 | switch (event) { |
771 | case EVENT_COMMIT: { |
822 | case EVENT_COMMIT: { |
772 | #ifdef MIKRO |
823 | #ifdef MIKRO |
773 | int n[2]; |
- | |
774 | MIKRO_GetPosition(1,&n[0]); |
824 | MIKRO_GetPosition(1,&n[0]); |
775 | SetCtrlVal (panel, SCAN_XP, n[0]); |
825 | SetCtrlVal (panel, SCAN_XP, n[0]); |
776 | MIKRO_GetPosition(2,&n[1]); |
826 | MIKRO_GetPosition(2,&n[1]); |
- | 827 | SetCtrlVal (panel, SCAN_YP, n[1]); |
|
- | 828 | #endif |
|
- | 829 | #ifdef uSMC_USB |
|
- | 830 | uSMC_GetPosition(node[0],&n[0]); |
|
- | 831 | SetCtrlVal (panel, SCAN_XP, n[0]); |
|
- | 832 | uSMC_GetPosition(node[1],&n[1]); |
|
777 | SetCtrlVal (panel, SCAN_YP, n[1]); |
833 | SetCtrlVal (panel, SCAN_YP, n[1]); |
778 | #endif |
834 | #endif |
779 | break; |
835 | break; |
780 | } |
836 | } |
781 | } |
837 | } |
Line 789... | Line 845... | ||
789 | #ifdef MIKRO |
845 | #ifdef MIKRO |
790 | MIKRO_ReferenceMove(1); |
846 | MIKRO_ReferenceMove(1); |
791 | MIKRO_ReferenceMove(2); |
847 | MIKRO_ReferenceMove(2); |
792 | GetCurrentPositionCB(panel, control, event, NULL, 0, 0); |
848 | GetCurrentPositionCB(panel, control, event, NULL, 0, 0); |
793 | #endif |
849 | #endif |
- | 850 | #ifdef uSMC_USB |
|
- | 851 | //SetCtrlVal(panel,P1_STAGELED,1); |
|
- | 852 | for (int i=0; i<3; i++) uSMC_ReferenceMove(node[i]); |
|
- | 853 | GetCurrentPositionCB(panel, control, event, NULL, 0, 0); |
|
- | 854 | //SetCtrlVal(panel,P1_STAGELED,0); |
|
- | 855 | #endif /* uSMC_USB */ |
|
794 | break; |
856 | break; |
795 | } |
857 | } |
796 | return 0; |
858 | return 0; |
797 | } |
859 | } |
798 | 860 |