📄 dsomaindlg.cpp
字号:
SendCommandToComPort();
#else
bResult=SendDataToUSB(order);
#endif
return bResult;
}
void CDSOMainDlg::OnDownload()
{
rec_flag=!rec_flag;
m_displayWnd.RecordWave(rec_flag);
/* BYTE *pbuf=NULL;
CFile file;
CString m_libpath;
m_libpath="d:\\FPGA\\FPGA&USB\\fifo_FPGA\\";
char filter[]="BIX data (*.bix)|*.bix";
CFileDialog fileDlg(true ,NULL,"*.bix",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,filter);
fileDlg.m_ofn .lpstrInitialDir=m_libpath;
fileDlg.m_ofn .lpstrFilter=filter;
if(fileDlg.DoModal ()!=IDOK)return;
CString filename=fileDlg.GetPathName ();
if(!file.Open(filename,CFile::modeRead,NULL))
{ MessageBox("Can't open this file!");return;}
DWORD filesize=file.GetLength();
pbuf=new BYTE[filesize];
if(pbuf!=NULL)
{ file.ReadHuge(pbuf,filesize);
Download8051File(pbuf,filesize);
}
file.Close(); */
}
BOOL CDSOMainDlg::Download8051File(LPBYTE pbuff, WORD lenght)
{
HANDLE hDevice=NULL;
VENDOR_REQUEST_IN myRequest;
BOOL bResult = FALSE;
ULONG nBytes;
ANCHOR_DOWNLOAD_CONTROL downloadControl;
char DeviceName[20] = "Ezusb-0";
downloadControl.Offset=lenght;
if (m_displayWnd.UsbOpenDriver (&hDevice, DeviceName) != TRUE) {
MessageBox("无效设备,请重试!","错误",MB_ICONERROR);
return false;
}
myRequest.bRequest = 0xA0;
myRequest.wValue = 0xE600; // using CPUCS.0 in FX2
myRequest.wIndex = 0x00;
myRequest.wLength = 0x01;
myRequest.bData = 1;
myRequest.direction = 0x00;
if (hDevice != NULL)
{// Perform the Get-Descriptor IOCTL
bResult = DeviceIoControl (hDevice,
IOCTL_Ezusb_VENDOR_REQUEST,
&myRequest,
sizeof(VENDOR_REQUEST_IN),
NULL,
0,
(unsigned long *)&nBytes,
NULL);
}/* if valid driver handle */
if (bResult!=TRUE){ CloseHandle(hDevice);
MessageBox(" 复位错误!");
return false;
}
bResult = DeviceIoControl (hDevice,
IOCTL_EZUSB_ANCHOR_DOWNLOAD,
&downloadControl,
sizeof(ANCHOR_DOWNLOAD_CONTROL),
pbuff,
lenght,
(unsigned long *)&nBytes,
NULL);
CloseHandle(hDevice);
if (bResult!=TRUE)
{MessageBox("下载8051程序失败!","错误",MB_ICONERROR);
return false;
}
myRequest.bData = 0;
if (hDevice != NULL)
{// Perform the Get-Descriptor IOCTL
bResult = DeviceIoControl (hDevice,
IOCTL_Ezusb_VENDOR_REQUEST,
&myRequest,
sizeof(VENDOR_REQUEST_IN),
NULL,
0,
(unsigned long *)&nBytes,
NULL);
}/* if valid driver handle */
if (bResult!=TRUE){ CloseHandle(hDevice);
MessageBox(" 复位错误!");
return false;
}
return true;
}
BOOL CDSOMainDlg::SendDataToUSB(BYTE order)
{
VENDOR_OR_CLASS_REQUEST_CONTROL myRequest;
HANDLE hInDevice = NULL;
ULONG bufferSize = 8;
BOOL bResult=false;
char DeviceName[20] = "Ezusb-0";
if (m_displayWnd.UsbOpenDriver (&hInDevice, DeviceName) != TRUE)
{
// MessageBox( "无效设备,请重试!","错误",MB_ICONERROR);
return false;
}
else
{ DWORD dwReturned;
myRequest.request = order;
myRequest.value = 8;
myRequest.index = 0xBEEF;
myRequest.direction = 0;
myRequest.requestType=2; // vendor specific request type (2)
myRequest.recepient=0; // recepient is device (0)
bResult = DeviceIoControl(hInDevice,
IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST,
&myRequest,
sizeof(VENDOR_OR_CLASS_REQUEST_CONTROL),
ord,8,
(unsigned long *)&dwReturned,
NULL);
if (bResult!=TRUE)
MessageBox("命令失败!","错误",MB_ICONERROR);
CloseHandle (hInDevice);
}
return bResult;
}
void CDSOMainDlg::OnPlay()
{
m_displayWnd.Recall();
}
void CDSOMainDlg::OnBack()
{
m_displayWnd.Play_Back();
}
void CDSOMainDlg::OnNext()
{
m_displayWnd.Play_Next();
}
void CDSOMainDlg::OnCancel()
{
m_displayWnd.Caiyang=false;
m_displayWnd.Kill_Theard=false;
CDialog::OnCancel();
}
void CDSOMainDlg::OnSlopeSel()
{
int i =m_slope_ctl.GetSelectSite();
ord[0]='C';
if(trigger.method==0)
{
if(i==0)
{ trigger.slope =0;
ord[1]=TRIGGER_EGDE_N;
}
else
{ trigger.slope =1;
ord[1]=TRIGGER_EGDE_P;
}
}
else
if(trigger.method==2) //脉宽触发
{
if(i==0)
ord[1]=PLUSE_SLOPE_P;
else
ord[1]=PLUSE_SLOPE_N;
}
SendCommandToUSB(VR_USRCMD);
m_displayWnd.ReDrawSCreen();
}
void CDSOMainDlg::OnTvMode()
{
WORD i=m_tvmode_ctl.GetSelectSite();
if(i==0||i==2){//PAL
// m_linesSel_ctl.SetBuddy(&m_lines_ctl);
m_linesSel_ctl.SetRange(1,625);
m_linesSel_ctl.SetPos(video_lines);
}
else
if(i==1)
{ //NTSC
// m_linesSel_ctl.SetBuddy(&m_lines_ctl);
if(video_lines>525)
video_lines=1;
m_linesSel_ctl.SetRange(1,525);
m_linesSel_ctl.SetPos(video_lines);
}
i=1024-video_lines;
ord[0]=CMD_VIDEO_TRG;
ord[1]=BYTE((i>>8)&0x03);
ord[2]=(BYTE)(i&0x00ff);
SendCommandToUSB(VR_USRCMD);
}
BYTE video_trg_ctl_code[4]={VIDEO_TRG_FIELD1,VIDEO_TRG_FIELD2,VIDEO_TRG_LINE_NR,VIDEO_TRG_ALL_LINE};
BYTE pluse_trg_ctl_code[4]={PLUSE_TRG_ALB,PLUSE_TRG_AGB,PLUSE_TRG_ANEB,PLUSE_TRG_AEB};
void CDSOMainDlg::OnVideoSel()
{
int i=m_video_trg_ctl.GetSelectSite();
ord[0]='C';
if(trigger.method==1){
ord[1]=video_trg_ctl_code[i];
}else
if(trigger.method==2)
{
ord[1]=pluse_trg_ctl_code[i];
}
SendCommandToUSB(VR_USRCMD);
m_displayWnd.ReDrawSCreen();
// TODO: Add your control notification handler code here
}
void CDSOMainDlg::OnPluseTimeUp()
{ double time;
DWORD t;
if(time_uint==0)
pluse_time+=10*1000;//10ms
else
if(time_uint==1)
pluse_time+=20;//10ms
else
if(time_uint==2)
pluse_time+=20;
if((pluse_time/1000000)>0)
{time=(double)pluse_time;
time=time/1000000.0;
time_uint=0;
m_pluse_mes.Format("%0.2fms",time);
}else
if((pluse_time/1000)>0)
{
time=(double)pluse_time;
time=time/1000.0;
time_uint=1;
m_pluse_mes.Format("%0.2fus",time);
}else{time_uint=2;
m_pluse_mes.Format("%dns",pluse_time);
}
ord[0]=CMD_PLUSE_TRG;
t=pluse_time/20;
ord[1]=(BYTE)((t>>24)&0x000000ff);
ord[2]=(BYTE)((t>>16)&0x000000ff);
ord[3]=(BYTE)((t>>8)&0x000000ff);
ord[4]=(BYTE)(t&0x000000ff);
SendCommandToUSB(VR_USRCMD);
UpdateData(0);
}
void CDSOMainDlg::OnPluseTimeDown()
{
double time;
DWORD t;
if(time_uint==0)
pluse_time-=10*1000;//10ms
else
if(time_uint==1)
pluse_time-=20;//10ms
else
if(time_uint==2)
pluse_time-=20;
if(pluse_time<20)
pluse_time=20;
if((pluse_time/1000000)>0)
{time=(double)pluse_time;
time=time/1000000.0;
time_uint=0;
m_pluse_mes.Format("%0.2fms",time);
}else
if((pluse_time/1000)>0)
{
time=(double)pluse_time;
time=time/1000.0;
time_uint=1;
m_pluse_mes.Format("%0.2fus",time);
}else{time_uint=2;
m_pluse_mes.Format("%dns",pluse_time);
}
ord[0]=CMD_PLUSE_TRG;
t=pluse_time/20;
ord[1]=(BYTE)((t>>24)&0x000000ff);
ord[2]=(BYTE)((t>>16)&0x000000ff);
ord[3]=(BYTE)((t>>8)&0x000000ff);
ord[4]=(BYTE)(t&0x000000ff);
SendCommandToUSB(VR_USRCMD);
UpdateData(0);
}
#include "TimeDialog.h"
void CDSOMainDlg::OnPluseTimeSetup()
{
CTimeDialog timedlg;
double time;
DWORD t;
int ID;
if((ID=timedlg.DoModal ())!=IDOK) return;
time_uint=timedlg.time_uint;
time=timedlg.m_time ;
if(time_uint==0)
{
pluse_time=(DWORD)(time*1000000.0);
}else
if(time_uint==1)
{
pluse_time=(DWORD)(time*1000.0); //ns
}
else
if(time_uint==2)
{
time=(int)(timedlg.m_time) ;
if((int)(time/20)==0)
time+=20;
time=(int)(time/20)*20;
pluse_time=(DWORD)time;
}
if((pluse_time/1000000)>0)
{time=(double)pluse_time;
time=time/1000000.0;
time_uint=0;
m_pluse_mes.Format("%0.2fms",time);
}else
if((pluse_time/1000)>0)
{
time=(double)pluse_time;
time=time/1000.0;
time_uint=1;
m_pluse_mes.Format("%0.2fus",time);
}else{
time_uint=2;
m_pluse_mes.Format("%dns",pluse_time);
}
ord[0]=CMD_PLUSE_TRG;
t=pluse_time/20;
ord[1]=(BYTE)((t>>24)&0x000000ff);
ord[2]=(BYTE)((t>>16)&0x000000ff);
ord[3]=(BYTE)((t>>8)&0x000000ff);
ord[4]=(BYTE)(t&0x000000ff);
SendCommandToUSB(VR_USRCMD);
UpdateData(0);
}
void CDSOMainDlg::OnSingle()
{
display.freq_on_ch1 =!display.freq_on_ch1;
if(display.freq_on_ch1)
m_single_but.SetTextColor(RGB(0,255,0));
else
m_single_but.SetTextColor(RGB(0,0,0));
m_displayWnd.ReDrawSCreen();
}
void CDSOMainDlg::OnXy()
{
time_base.format =!time_base.format ;
if(time_base.format)
{ chb_param.display =1;
cha_param.display =1;
m_cha_on_but.SetIcon(IDI_CHA_ON_G);
m_chb_on_but.SetIcon(IDI_CHB_ON_Y);
m_xy_but.SetWindowText("X-Y");
}
else
m_xy_but.SetWindowText("Y-T");
m_displayWnd.ReDrawSCreen();
}
void CDSOMainDlg::OnNoraml()
{
// TODO: Add your control notification handler code here
}
void CDSOMainDlg::OnShiliangDisp()
{
display.type=!display.type;
/* if(display.type==1)
display.type=0;
else
display.type=1;*/
m_displayWnd.ReDrawSCreen();
}
void CDSOMainDlg::OnUpdateShiliangDisp(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (0);
}
void CDSOMainDlg::OnNormalCaiji()
{
acquire.acquisition=0;
OnTimeCtrl();
}
void CDSOMainDlg::OnUpdateNormalCaiji(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CDSOMainDlg::OnAvergeCaiji()
{
acquire.acquisition=1;
OnTimeCtrl();
}
void CDSOMainDlg::OnUpdateAvergeCaiji(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CDSOMainDlg::OnGlitchesDetect()
{
acquire.acquisition=2;
OnTimeCtrl();
}
void CDSOMainDlg::OnUpdateGlitchesDetect(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CDSOMainDlg::OnGrapBaochi()
{
// TODO: Add your command handler code here
}
void CDSOMainDlg::OnUpdateGrapBaochi(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CDSOMainDlg::OnFft()
{
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -