www.pudn.com > QQandSample.rar > Sample.cpp
// Sample.cpp : implementation file
//
#include "stdafx.h"
#include "Rotation.h"
#include "Sample.h"
#include "RotationDoc.h"
#include "RotationView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BOOL samFlag=false;
/////////////////////////////////////////////////////////////////////////////
// CSample dialog
CSample::CSample(CWnd* pParent /*=NULL*/)
: CDialog(CSample::IDD, pParent)
{
//{{AFX_DATA_INIT(CSample)
m_channel = 1;
m_trigger = 1;
m_A = 1;
m_HZ = 30;
m_PH = .0f;
m_long = 1;
m_sample = 1000.0f;
//}}AFX_DATA_INIT
}
void CSample::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSample)
DDX_Text(pDX, IDC_CHANNEL, m_channel);
DDV_MinMaxInt(pDX, m_channel, 1, 10);
DDX_Radio(pDX, IDC_TRIGGER, m_trigger);
DDX_Text(pDX, IDC_EDIT_A, m_A);
DDX_Text(pDX, IDC_EDIT_HZ, m_HZ);
DDX_Text(pDX, IDC_EDIT_PH, m_PH);
DDX_Text(pDX, IDC_LONG, m_long);
DDX_Text(pDX, IDC_SAMPLE, m_sample);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSample, CDialog)
//{{AFX_MSG_MAP(CSample)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSample message handlers
void CSample::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
void CSample::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);
CDialog::OnOK();
}
BOOL CSample::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DestroyWindow();
}
void CSample::BeganSample(SignalType *signal)
{
signal->a=m_A;
signal->f=m_HZ;
signal->fs=m_sample;
signal->ph=m_PH;
signal->n=m_long*1024;
if(signal->data!=NULL)
delete [] signal->data;
signal->data= new double [signal->n];
}
void CSample::TransData(SignalType *signal)
{
signal->n=m_long*1024;
}
UINT SampleData(LPVOID pParam)
{
SignalType *ma=(SignalType*) pParam;
HWND hWnd=ma->hWnd;
float ff=ma->fs;
long tt=long(1000/ff);
CCaculate m_caculate;
m_caculate.SinTest(ma,0);
int num=0;
while(samFlag)
{
::Sleep(tt);
num=num+1;
m_caculate.AddPoint(ma,num);
::PostMessage(hWnd,WM_SAMPLEFINISHED,0,0);
}
num=0;
//::SendMessage((HWND)pParam,WM_SAMPLEFINISHED,0,0);
return 0;
}