📄 freoutdlg1.cpp
字号:
// FreOutDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Fileter.h"
#include "FreOutDlg.h"
#include "conio.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFreOutDlg dialog
#define PORT_SPARALL 0X378
//#define MAX_NUM 12500
#define MAX_NUM 10100
int FreTimes=10;// The Count Add times per 50Hz
int *AmpData;
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<MAX_NUM;i+=Step)
_outp(PORT_SPARALL,AmpData[i]);
}
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();
///////////////////////////////////////////
//generate the data
AmpData = new int[MAX_NUM];
for(int i=0;i<MAX_NUM;i++)
AmpData[i]=(int)(127+128*cos(2.0*3.14159*i/MAX_NUM));
//////////////////////////////////////////
// TODO: Add extra initialization here
// double Seconds=1;
// double AllCount=0;
// clock_t Begin;
// for(Begin=clock();Begin+Seconds*CLOCKS_PER_SEC > clock();)
// AllCount++;
// m_CountPS=AllCount/Seconds;
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 + -