📄 freoutdlg.cpp
字号:
// FreOutDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Fileter.h"
#include "FreOutDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "time.h"
#include "conio.h"
#include "math.h"
/////////////////////////////////////////////////////////////////////////////
// CFreOutDlg dialog
#define PORT_SPARALL 0X378
//#define MaxNum 12500
const int TestNum=30000;
int MaxNum=1010;
int FreTimes=10;// The Count Add times per 50Hz
int *AmpData;
//typedef int DataType;
DWORD FreOut(LPVOID hWnd);
CFreOutDlg::CFreOutDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFreOutDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFreOutDlg)
m_FreValue = 500;
//}}AFX_DATA_INIT
m_CountPS=0;
bOuting=FALSE;
}
void CFreOutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFreOutDlg)
DDX_Text(pDX, IDC_EDIT1, m_FreValue);
DDV_MinMaxUInt(pDX, m_FreValue, 50, 50000);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFreOutDlg, CDialog)
//{{AFX_MSG_MAP(CFreOutDlg)
ON_BN_CLICKED(IDC_OUT_BUTTON, OnOutButton)
ON_BN_CLICKED(IDC_STOP_BUTTON, OnStopButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFreOutDlg message handlers
DWORD FreOut(LPVOID hwnd)
{
int i;
int Step=FreTimes;
while(1)
// for(i=0;i<MaxNum;i+=Step)
// _outp(PORT_SPARALL,AmpData[i]);
_outp(0x3f8,0xaa);
}
void CFreOutDlg::OnOutButton()
{
// TODO: Add your control notification handler code here/
if(bOuting)
{
DWORD ExitCode1;
GetExitCodeThread(hThread1,&ExitCode1);
TerminateThread(hThread1,ExitCode1);
bOuting=FALSE;
}
if(!bOuting)
{
UpdateData();
FreTimes=int(m_FreValue/50.0);//Get the times of 50Hz
bOuting=TRUE;
hThread1 = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)FreOut,
(LPVOID)(this->m_hWnd),0,&Tid);
// goto the edit frequence
((CDialog *)this)->GotoDlgCtrl(GetDlgItem(IDC_EDIT1));
// (CWnd *)GetDlgItem(IDC_STOP_BUTTON)->SetFocus();
}
}
void CFreOutDlg::OnStopButton()
{
// TODO: Add your control notification handler code here
if(bOuting)
{
DWORD ExitCode1;
GetExitCodeThread(hThread1,&ExitCode1);
TerminateThread(hThread1,ExitCode1);
bOuting=FALSE;
}
}
BOOL CFreOutDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
if(bOuting)
{
DWORD ExitCode1;
GetExitCodeThread(hThread1,&ExitCode1);
TerminateThread(hThread1,ExitCode1);
bOuting=FALSE;
}
delete AmpData;
return CDialog::DestroyWindow();
}
void CFreOutDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
BOOL CFreOutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
int i;
//////////////////////////////////////////
//iniation the MaxNum
//Begin the Test depart
clock_t BeginT,EndT;
long Time1,Time2,Time3;
AmpData = new int[TestNum];
for(i=0;i<TestNum;i++)
AmpData[i]=i;
///test the time of run TestNum times
int times=3;
BeginT=clock();
while(times--)
for(i=0;i<TestNum;i++)
_outp(0x378,AmpData[i]);
EndT=clock();
Time1=EndT-BeginT;
//the 2nd
times=3;
BeginT=clock();
while(times--)
for(i=0;i<TestNum;i++)
_outp(0x378,AmpData[i]);
EndT=clock();
Time2=EndT-BeginT;
//the 3th
times=3;
BeginT=clock();
while(times--)
for(i=0;i<TestNum;i++)
_outp(0x378,AmpData[i]);
EndT=clock();
Time3=EndT-BeginT;
//when the Min frequence is 50Hz
MaxNum=int(1.0/50.0*float(TestNum*3*3)/float(Time1+Time2+Time3)*CLOCKS_PER_SEC);
/* CString str;
str.Format("The MaxNum is: %d",MaxNum);
pDC->TextOut(100,100,str);
*/
///////////////////////////////////////////
//generate the data
AmpData = new int[MaxNum];
for(i=0;i<MaxNum;i++)
AmpData[i]=(int)(127+128*cos(2.0*3.14159*i/MaxNum));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -