11,6 → 11,7 |
#endif /* _CVI_DEBUG_ */ |
#include "wavejet_ui.h" |
|
int ctrl_c=0; |
//#define SCOPE_IP "192.168.1.11" |
#define MAX_TCP_CONNECT 5 /* time in secs to get a connection */ |
#define MAX_TCP_READ 3 /* time in secs to wait for the DSO |
38,6 → 39,69 |
} |
*/ |
|
int CVICALLBACK acquire_waveforms(void *functionData) { |
struct HDR { |
int id; |
int length; |
int event; |
}; |
|
struct HDR hdr; |
int p1_tra[5]={P1_TRA_1,P1_TRA_2,P1_TRA_3,P1_TRA_4,0}; |
char outbuf[MAX_ST],inbuf[MAX_ST], tmpstr[100]; |
static char databuf[1000000]; |
int status, byte_count; |
char filename[0xFF]; |
|
GetCtrlVal (p1h, P1_FNAME, filename); |
ctrl_c=0; |
|
LECROY_TCP_write(sockfd, "DTFORM BYTE\n"); |
LECROY_TCP_write(sockfd, "DTSTART 0\n"); |
LECROY_TCP_write(sockfd, "MLEN 1M\n"); |
LECROY_TCP_write(sockfd, "DTPOINTS 5000\n"); |
//LECROY_TCP_write(sockfd, "DTPOINTS 0\n"); |
FILE *fp = fopen (filename, "wb"); |
|
int maxeve; |
GetCtrlVal (p1h, P1_NEVE, &maxeve); |
for (int neve=0;neve<maxeve;neve++){ |
SetCtrlVal (p1h, P1_CEVE, neve+1); |
sprintf(outbuf,"WSGL?\n"); |
LECROY_TCP_write(sockfd, outbuf); |
LECROY_TCP_read(sockfd, inbuf, sizeof(inbuf), MAX_TCP_READ); |
sscanf(inbuf,"%s",tmpstr); |
|
hdr.event=neve; |
for (int ch=0;ch<4;ch++){ |
int on; |
GetCtrlVal (p1h, p1_tra[ch], &on); |
|
if (on){ |
hdr.id=ch; |
sprintf(outbuf,"WAVESRC CH%d\n",ch+1); |
LECROY_TCP_write(sockfd, outbuf); |
|
sprintf(outbuf,"DTWAVE?\n"); |
LECROY_TCP_write(sockfd, outbuf); |
LECROY_TCP_read(sockfd, databuf, sizeof(databuf), MAX_TCP_READ); |
sscanf(databuf,"# %1d %8d",&status,&byte_count); |
printf("[%d] wfmid=%d bytes=%d\n", neve,status, byte_count); |
if (byte_count<=0) continue; |
hdr.length = byte_count+sizeof(hdr); |
status = fwrite (&hdr, 1, sizeof(hdr), fp); |
status = fwrite (&databuf[10], 1, byte_count, fp); |
|
} |
} |
if (ctrl_c) break; |
} |
ctrl_c=0; |
status = fclose (fp); |
SetCtrlVal(p1h, P1_DTWFM, 0); |
return 0; |
} |
|
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
LPSTR lpszCmdLine, int nCmdShow) |
{ |
44,7 → 108,7 |
int i; |
int status,connected,displen; |
int refon; |
int tmpindex,tmpint; |
int tmpindex,tmpint, dummy; |
int p1_tra[5]={P1_TRA_1,P1_TRA_2,P1_TRA_3,P1_TRA_4,0}; |
int p1_vdiv[5]={P1_VDIV_1,P1_VDIV_2,P1_VDIV_3,P1_VDIV_4,0}; |
int p1_bwl[5]={P1_BWL_1,P1_BWL_2,P1_BWL_3,P1_BWL_4,0}; |
52,6 → 116,7 |
char ip_address[50],tmpstr[100]; |
char outbuf[MAX_ST],inbuf[MAX_ST]; |
char display[500000],imgfn[300],ftyp[10]; |
int daqon=0; |
|
FILE *imgfp; |
|
289,8 → 354,23 |
strcpy(outbuf,"GTL\n"); |
LECROY_TCP_write(sockfd, outbuf); |
break; |
//case P1_GET_SETUP: |
// break; |
case P1_DTWFM: |
if (!connected) break; |
GetCtrlVal(p1h, P1_DTWFM, &daqon); |
if (daqon) { |
CmtScheduleThreadPoolFunction (poolHandle, acquire_waveforms, (void *)&dummy, &tfID); |
} else { |
ctrl_c=1; |
|
//CmtWaitForThreadPoolFunctionCompletion (poolHandle, tfID, |
// OPT_TP_PROCESS_EVENTS_WHILE_WAITING); |
//CmtReleaseThreadPoolFunctionID (poolHandle, tfID) |
|
} |
|
|
|
break; |
default: |
break; |
} |