📄 compress.cpp
字号:
// Compress.cpp : implementation file
//
#include "stdafx.h"
#include "cardtest.h"
#include "Compress.h"
#include "ddutil.h"
#include "data.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define WM_STEP WM_USER+0x50
/////////////////////////////////////////////////////////////////////////////
// CCompress dialog
CCompress::CCompress(CWnd* pParent, CCard* pCard)
: CDialog(CCompress::IDD, pParent)
{
//{{AFX_DATA_INIT(CCompress)
m_nChannel = 0;
m_bLoop = FALSE;
//}}AFX_DATA_INIT
m_pParent=(CCardtestDlg*)pParent;
m_pCard=pCard;
m_bRun=FALSE;
m_bStop=FALSE;
}
void CCompress::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCompress)
DDX_Radio(pDX, IDC_CH1, m_nChannel);
DDX_Check(pDX, IDC_DSPLOOP, m_bLoop);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCompress, CDialog)
//{{AFX_MSG_MAP(CCompress)
ON_BN_CLICKED(IDC_DSPLOOP, OnDsploop)
ON_BN_CLICKED(IDC_STOP, OnStop)
ON_MESSAGE(WM_STEP, OnStep)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCompress message handlers
BOOL CCompress::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
ULONG PhyAddress;
m_pCard->TransAddress(g_ParaPrimary.VirtualAddress, &PhyAddress);
m_pCard->SetDisplayPara(&g_ParaPrimary, PhyAddress);
if(!m_pCard->CheckDouble()){
GetDlgItem(IDC_CHANNEL)->EnableWindow(FALSE);
GetDlgItem(IDC_CH1)->EnableWindow(FALSE);
GetDlgItem(IDC_CH2)->EnableWindow(FALSE);
}
GetDlgItem(IDC_STOP)->EnableWindow(FALSE);
m_pDataWindow=new CData(this, m_pCard);
m_pDataWindow->Create();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCompress::OnDsploop()
{
// TODO: Add your control notification handler code here
UpdateData();
}
void CCompress::OnOK()
{
// TODO: Add extra validation here
UpdateData();
GetDlgItem(IDOK)->EnableWindow(FALSE);
GetDlgItem(IDC_CH1)->EnableWindow(FALSE);
GetDlgItem(IDC_CH2)->EnableWindow(FALSE);
GetDlgItem(IDC_CHANNEL)->EnableWindow(FALSE);
GetDlgItem(IDC_STOP)->EnableWindow(TRUE);
m_pCard->InitDebi(m_nChannel);
PostMessage(WM_STEP, 0, 0);
}
void CCompress::OnStop()
{
// TODO: Add your control notification handler code here
m_pCard->StopAudio();
m_pDataWindow->StopReceive();
if(m_bRun){
m_pCard->StopCompress(m_nChannel);
GetDlgItem(IDC_STOP)->EnableWindow(FALSE);
m_bStop=FALSE;
}
else
m_bStop=TRUE;
m_bRun=FALSE;
GetDlgItem(IDOK)->EnableWindow(TRUE);
if(m_pCard->CheckDouble()){
GetDlgItem(IDC_CH1)->EnableWindow(TRUE);
GetDlgItem(IDC_CH2)->EnableWindow(TRUE);
GetDlgItem(IDC_CHANNEL)->EnableWindow(TRUE);
}
}
void CCompress::OnCancel()
{
// TODO: Add extra cleanup here
if(m_bRun)
OnStop();
delete m_pDataWindow;
CDialog::OnCancel();
}
void CCompress::OnStep(ULONG wParam, ULONG lParam)
{
int nStep=wParam;
if(m_bStop){
m_bStop=FALSE;
GetDlgItem(IDC_STOP)->EnableWindow(FALSE);
return;
}
switch(nStep){
case 0:
m_pCard->LoadDSPCode(m_nChannel);
SetTimer(0, 10, NULL);
return;
case 1:
if(!m_pCard->VerifyDSPCode(m_nChannel)){
GetDlgItem(IDOK)->EnableWindow(TRUE);
if(m_pCard->CheckDouble()){
GetDlgItem(IDC_CH1)->EnableWindow(TRUE);
GetDlgItem(IDC_CH2)->EnableWindow(TRUE);
GetDlgItem(IDC_CHANNEL)->EnableWindow(TRUE);
}
m_bRun=FALSE;
return;
}
nStep++;
break;
case 2:
m_pCard->StartAudio(m_nChannel);
m_pDataWindow->StartReceive();
m_pCard->StartDSP(m_nChannel);
m_bRun=TRUE;
return;
}
PostMessage(WM_STEP, nStep, 0);
}
void CCompress::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
KillTimer(0);
if(!m_bLoop)
PostMessage(WM_STEP, 1, 0);
else
PostMessage(WM_STEP, 0, 0);
CDialog::OnTimer(nIDEvent);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -