You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
262 lines
5.3 KiB
262 lines
5.3 KiB
|
|
// 7300bDbFDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "7300bDbF.h"
|
|
#include "7300bDbFDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
I16 ghCard;
|
|
U16 channel=0;
|
|
U32 out_count=10000;
|
|
U16 ao_buf[10000];
|
|
U16 ao_buf2[10000];
|
|
U32 cb=0, t=0;
|
|
U16 viewidx[10000];
|
|
|
|
C7300bDbFApp* pMyApp;
|
|
C7300bDbFDlg* pMyDlg;
|
|
|
|
void cbAddr()
|
|
{
|
|
BOOLEAN halfReady = 0;
|
|
U16 sts=0;
|
|
|
|
DI_AsyncMultiBufferNextReady(ghCard, &halfReady, &viewidx[(cb%10000)]);
|
|
//TODO: here to handle data
|
|
DI_AsyncDblBufferTransfer(ghCard, NULL); //notify driver the data have been handled
|
|
DI_AsyncDblBufferOverrun(ghCard, 0, &sts);
|
|
|
|
if(sts)
|
|
{
|
|
t++;
|
|
DI_AsyncDblBufferOverrun(ghCard, 1, &sts);
|
|
}
|
|
|
|
pMyDlg->SetDlgItemInt(IDC_EDIT_CALLBACK, cb);
|
|
pMyDlg->SetDlgItemInt(IDC_EDIT_OVERRUN, t);
|
|
|
|
cb++;
|
|
}
|
|
|
|
void cbAddr0()
|
|
{
|
|
pMyDlg->SetWindowText( TEXT("PCI-7300b DI Double Buffer Overrun - Completed!!!") );
|
|
}
|
|
|
|
|
|
// CAboutDlg dialog used for App About
|
|
|
|
class CAboutDlg : public CDialog
|
|
{
|
|
public:
|
|
CAboutDlg();
|
|
|
|
// Dialog Data
|
|
enum { IDD = IDD_ABOUTBOX };
|
|
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
|
|
// Implementation
|
|
protected:
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
|
{
|
|
}
|
|
|
|
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// C7300bDbFDlg dialog
|
|
|
|
|
|
|
|
|
|
C7300bDbFDlg::C7300bDbFDlg(I16 hCard, CWnd* pParent /*=NULL*/)
|
|
: CDialog(C7300bDbFDlg::IDD, pParent)
|
|
{
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
|
|
ghCard = hCard;
|
|
}
|
|
|
|
void C7300bDbFDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(C7300bDbFDlg, CDialog)
|
|
ON_WM_SYSCOMMAND()
|
|
ON_WM_PAINT()
|
|
ON_WM_QUERYDRAGICON()
|
|
//}}AFX_MSG_MAP
|
|
ON_BN_CLICKED(IDC_BT_START, &C7300bDbFDlg::OnStart)
|
|
ON_WM_DESTROY()
|
|
ON_BN_CLICKED(IDC_BT_STOP, &C7300bDbFDlg::OnStop)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// C7300bDbFDlg message handlers
|
|
|
|
BOOL C7300bDbFDlg::OnInitDialog()
|
|
{
|
|
I16 err;
|
|
CString strTemp;
|
|
|
|
CDialog::OnInitDialog();
|
|
|
|
// Add "About..." menu item to system menu.
|
|
|
|
// IDM_ABOUTBOX must be in the system command range.
|
|
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
|
ASSERT(IDM_ABOUTBOX < 0xF000);
|
|
|
|
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
|
if (pSysMenu != NULL)
|
|
{
|
|
BOOL bNameValid;
|
|
CString strAboutMenu;
|
|
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
|
|
ASSERT(bNameValid);
|
|
if (!strAboutMenu.IsEmpty())
|
|
{
|
|
pSysMenu->AppendMenu(MF_SEPARATOR);
|
|
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
|
}
|
|
}
|
|
|
|
// Set the icon for this dialog. The framework does this automatically
|
|
// when the application's main window is not a dialog
|
|
SetIcon(m_hIcon, TRUE); // Set big icon
|
|
SetIcon(m_hIcon, FALSE); // Set small icon
|
|
|
|
// TODO: Add extra initialization here
|
|
pMyApp = (C7300bDbFApp*)AfxGetApp();
|
|
pMyDlg = (C7300bDbFDlg*)(pMyApp->m_pMainWnd);
|
|
|
|
err = DI_7300B_Config(ghCard, 16, TRIG_CLK_10MHZ, P7300_WAIT_NO, P7300_TERM_ON, 0, 1, 1);
|
|
if (err != 0)
|
|
{
|
|
strTemp.Format( TEXT("DI_7300B_Config Error = %d, card=%d"), err, ghCard);
|
|
AfxMessageBox( strTemp );
|
|
return TRUE;
|
|
}
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
}
|
|
|
|
void C7300bDbFDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
|
{
|
|
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
|
{
|
|
CAboutDlg dlgAbout;
|
|
dlgAbout.DoModal();
|
|
}
|
|
else
|
|
{
|
|
CDialog::OnSysCommand(nID, lParam);
|
|
}
|
|
}
|
|
|
|
// If you add a minimize button to your dialog, you will need the code below
|
|
// to draw the icon. For MFC applications using the document/view model,
|
|
// this is automatically done for you by the framework.
|
|
|
|
void C7300bDbFDlg::OnPaint()
|
|
{
|
|
if (IsIconic())
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
|
|
|
// Center icon in client rectangle
|
|
int cxIcon = GetSystemMetrics(SM_CXICON);
|
|
int cyIcon = GetSystemMetrics(SM_CYICON);
|
|
CRect rect;
|
|
GetClientRect(&rect);
|
|
int x = (rect.Width() - cxIcon + 1) / 2;
|
|
int y = (rect.Height() - cyIcon + 1) / 2;
|
|
|
|
// Draw the icon
|
|
dc.DrawIcon(x, y, m_hIcon);
|
|
}
|
|
else
|
|
{
|
|
CDialog::OnPaint();
|
|
}
|
|
}
|
|
|
|
// The system calls this function to obtain the cursor to display while the user drags
|
|
// the minimized window.
|
|
HCURSOR C7300bDbFDlg::OnQueryDragIcon()
|
|
{
|
|
return static_cast<HCURSOR>(m_hIcon);
|
|
}
|
|
|
|
|
|
void C7300bDbFDlg::OnStart()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
U16 BufferId;
|
|
I16 err;
|
|
U32 out_count=10000;
|
|
CString strMsg;
|
|
|
|
err = DI_ContMultiBufferSetup (ghCard, ao_buf, out_count, &BufferId);
|
|
if (err < 0)
|
|
{
|
|
strMsg.Format(TEXT("DI_ContMultiBufferSetup Error = %d"), err);
|
|
AfxMessageBox( strMsg );
|
|
return;
|
|
}
|
|
|
|
err = DI_ContMultiBufferSetup (ghCard, ao_buf2, out_count, &BufferId);
|
|
if (err < 0)
|
|
{
|
|
strMsg.Format(TEXT("DI_ContMultiBufferSetup Error = %d"), err);
|
|
AfxMessageBox( strMsg );
|
|
return;
|
|
}
|
|
|
|
DI_EventCallBack_x64 (ghCard, 1, 1, (ULONG_PTR) cbAddr );
|
|
DI_EventCallBack_x64 (ghCard, 1, 0, (ULONG_PTR) cbAddr0 );
|
|
|
|
err = DI_ContMultiBufferStart (ghCard, 0, 1);
|
|
if (err < 0)
|
|
{
|
|
strMsg.Format(TEXT("DI_ContMultiBufferStart Error = %d"), err);
|
|
AfxMessageBox( strMsg );
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
void C7300bDbFDlg::OnDestroy()
|
|
{
|
|
|
|
CDialog::OnDestroy();
|
|
// TODO: Add your message handler code here
|
|
|
|
}
|
|
|
|
void C7300bDbFDlg::OnStop()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
U32 count;
|
|
|
|
DI_AsyncClear(ghCard, &count);
|
|
}
|
|
|