Rev 137 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 137 | Rev 323 | ||
---|---|---|---|
Line 9... | Line 9... | ||
9 | #ifndef _CVI_DEBUG_ |
9 | #ifndef _CVI_DEBUG_ |
10 | # include "wavejet_uic.h" |
10 | # include "wavejet_uic.h" |
11 | #endif /* _CVI_DEBUG_ */ |
11 | #endif /* _CVI_DEBUG_ */ |
12 | #include "wavejet_ui.h" |
12 | #include "wavejet_ui.h" |
13 | 13 | ||
- | 14 | int ctrl_c=0; |
|
14 | //#define SCOPE_IP "192.168.1.11" |
15 | //#define SCOPE_IP "192.168.1.11" |
15 | #define MAX_TCP_CONNECT 5 /* time in secs to get a connection */ |
16 | #define MAX_TCP_CONNECT 5 /* time in secs to get a connection */ |
16 | #define MAX_TCP_READ 3 /* time in secs to wait for the DSO |
17 | #define MAX_TCP_READ 3 /* time in secs to wait for the DSO |
17 | to respond to a read request */ |
18 | to respond to a read request */ |
18 | #define MAX_ST 512 /* maximum message string. no picked from thin air */ |
19 | #define MAX_ST 512 /* maximum message string. no picked from thin air */ |
Line 36... | Line 37... | ||
36 | { |
37 | { |
37 | return (0); |
38 | return (0); |
38 | } |
39 | } |
39 | */ |
40 | */ |
40 | 41 | ||
- | 42 | int CVICALLBACK acquire_waveforms(void *functionData) { |
|
- | 43 | struct HDR { |
|
- | 44 | int id; |
|
- | 45 | int length; |
|
- | 46 | int event; |
|
- | 47 | }; |
|
- | 48 | ||
- | 49 | struct HDR hdr; |
|
- | 50 | int p1_tra[5]={P1_TRA_1,P1_TRA_2,P1_TRA_3,P1_TRA_4,0}; |
|
- | 51 | char outbuf[MAX_ST],inbuf[MAX_ST], tmpstr[100]; |
|
- | 52 | static char databuf[1000000]; |
|
- | 53 | int status, byte_count; |
|
- | 54 | char filename[0xFF]; |
|
- | 55 | ||
- | 56 | GetCtrlVal (p1h, P1_FNAME, filename); |
|
- | 57 | ctrl_c=0; |
|
- | 58 | ||
- | 59 | LECROY_TCP_write(sockfd, "DTFORM BYTE\n"); |
|
- | 60 | LECROY_TCP_write(sockfd, "DTSTART 0\n"); |
|
- | 61 | LECROY_TCP_write(sockfd, "MLEN 1M\n"); |
|
- | 62 | LECROY_TCP_write(sockfd, "DTPOINTS 5000\n"); |
|
- | 63 | //LECROY_TCP_write(sockfd, "DTPOINTS 0\n"); |
|
- | 64 | FILE *fp = fopen (filename, "wb"); |
|
- | 65 | ||
- | 66 | int maxeve; |
|
- | 67 | GetCtrlVal (p1h, P1_NEVE, &maxeve); |
|
- | 68 | for (int neve=0;neve<maxeve;neve++){ |
|
- | 69 | SetCtrlVal (p1h, P1_CEVE, neve+1); |
|
- | 70 | sprintf(outbuf,"WSGL?\n"); |
|
- | 71 | LECROY_TCP_write(sockfd, outbuf); |
|
- | 72 | LECROY_TCP_read(sockfd, inbuf, sizeof(inbuf), MAX_TCP_READ); |
|
- | 73 | sscanf(inbuf,"%s",tmpstr); |
|
- | 74 | ||
- | 75 | hdr.event=neve; |
|
- | 76 | for (int ch=0;ch<4;ch++){ |
|
- | 77 | int on; |
|
- | 78 | GetCtrlVal (p1h, p1_tra[ch], &on); |
|
- | 79 | ||
- | 80 | if (on){ |
|
- | 81 | hdr.id=ch; |
|
- | 82 | sprintf(outbuf,"WAVESRC CH%d\n",ch+1); |
|
- | 83 | LECROY_TCP_write(sockfd, outbuf); |
|
- | 84 | ||
- | 85 | sprintf(outbuf,"DTWAVE?\n"); |
|
- | 86 | LECROY_TCP_write(sockfd, outbuf); |
|
- | 87 | LECROY_TCP_read(sockfd, databuf, sizeof(databuf), MAX_TCP_READ); |
|
- | 88 | sscanf(databuf,"# %1d %8d",&status,&byte_count); |
|
- | 89 | printf("[%d] wfmid=%d bytes=%d\n", neve,status, byte_count); |
|
- | 90 | if (byte_count<=0) continue; |
|
- | 91 | hdr.length = byte_count+sizeof(hdr); |
|
- | 92 | status = fwrite (&hdr, 1, sizeof(hdr), fp); |
|
- | 93 | status = fwrite (&databuf[10], 1, byte_count, fp); |
|
- | 94 | ||
- | 95 | } |
|
- | 96 | } |
|
- | 97 | if (ctrl_c) break; |
|
- | 98 | } |
|
- | 99 | ctrl_c=0; |
|
- | 100 | status = fclose (fp); |
|
- | 101 | SetCtrlVal(p1h, P1_DTWFM, 0); |
|
- | 102 | return 0; |
|
- | 103 | } |
|
- | 104 | ||
41 | int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
105 | int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
42 | LPSTR lpszCmdLine, int nCmdShow) |
106 | LPSTR lpszCmdLine, int nCmdShow) |
43 | { |
107 | { |
44 | int i; |
108 | int i; |
45 | int status,connected,displen; |
109 | int status,connected,displen; |
46 | int refon; |
110 | int refon; |
47 | int tmpindex,tmpint; |
111 | int tmpindex,tmpint, dummy; |
48 | int p1_tra[5]={P1_TRA_1,P1_TRA_2,P1_TRA_3,P1_TRA_4,0}; |
112 | int p1_tra[5]={P1_TRA_1,P1_TRA_2,P1_TRA_3,P1_TRA_4,0}; |
49 | int p1_vdiv[5]={P1_VDIV_1,P1_VDIV_2,P1_VDIV_3,P1_VDIV_4,0}; |
113 | int p1_vdiv[5]={P1_VDIV_1,P1_VDIV_2,P1_VDIV_3,P1_VDIV_4,0}; |
50 | int p1_bwl[5]={P1_BWL_1,P1_BWL_2,P1_BWL_3,P1_BWL_4,0}; |
114 | int p1_bwl[5]={P1_BWL_1,P1_BWL_2,P1_BWL_3,P1_BWL_4,0}; |
51 | float tmpfloat; |
115 | float tmpfloat; |
52 | char ip_address[50],tmpstr[100]; |
116 | char ip_address[50],tmpstr[100]; |
53 | char outbuf[MAX_ST],inbuf[MAX_ST]; |
117 | char outbuf[MAX_ST],inbuf[MAX_ST]; |
54 | char display[500000],imgfn[300],ftyp[10]; |
118 | char display[500000],imgfn[300],ftyp[10]; |
- | 119 | int daqon=0; |
|
55 | 120 | ||
56 | FILE *imgfp; |
121 | FILE *imgfp; |
57 | 122 | ||
58 | connected=0; |
123 | connected=0; |
59 | 124 | ||
Line 287... | Line 352... | ||
287 | case P1_TEST: |
352 | case P1_TEST: |
288 | if (!connected) break; |
353 | if (!connected) break; |
289 | strcpy(outbuf,"GTL\n"); |
354 | strcpy(outbuf,"GTL\n"); |
290 | LECROY_TCP_write(sockfd, outbuf); |
355 | LECROY_TCP_write(sockfd, outbuf); |
291 | break; |
356 | break; |
292 |
|
357 | case P1_DTWFM: |
- | 358 | if (!connected) break; |
|
- | 359 | GetCtrlVal(p1h, P1_DTWFM, &daqon); |
|
- | 360 | if (daqon) { |
|
- | 361 | CmtScheduleThreadPoolFunction (poolHandle, acquire_waveforms, (void *)&dummy, &tfID); |
|
- | 362 | } else { |
|
- | 363 | ctrl_c=1; |
|
- | 364 | ||
- | 365 | //CmtWaitForThreadPoolFunctionCompletion (poolHandle, tfID, |
|
- | 366 | // OPT_TP_PROCESS_EVENTS_WHILE_WAITING); |
|
- | 367 | //CmtReleaseThreadPoolFunctionID (poolHandle, tfID) |
|
- | 368 | ||
- | 369 | } |
|
- | 370 | ||
- | 371 | ||
- | 372 | ||
293 |
|
373 | break; |
294 | default: |
374 | default: |
295 | break; |
375 | break; |
296 | } |
376 | } |
297 | 377 | ||
298 | } while ((rID != P1_EXIT)); |
378 | } while ((rID != P1_EXIT)); |