⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlgpci1720.cpp

📁 研华数据采集卡PCI1713,PCI1720,PCL730测试程序
💻 CPP
字号:
// DlgPci1720.cpp : implementation file
//

#include "stdafx.h"
#include "CardTest.h"
#include "DlgPci1720.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgPci1720 dialog


CDlgPci1720::CDlgPci1720(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgPci1720::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgPci1720)
	m_fV1 = 0.0f;
	m_fV2 = 0.0f;
	m_fV3 = 0.0f;
	//}}AFX_DATA_INIT
	m_bPci1720On = FALSE;
}


void CDlgPci1720::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgPci1720)
	DDX_Text(pDX, IDC_V1, m_fV1);
	DDX_Text(pDX, IDC_V2, m_fV2);
	DDX_Text(pDX, IDC_V3, m_fV3);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgPci1720, CDialog)
	//{{AFX_MSG_MAP(CDlgPci1720)
	ON_BN_CLICKED(IDC_OK, OnOk)
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgPci1720 message handlers

void CDlgPci1720::OnOk() 
{
	UpdateData(TRUE);
	OpenPci1720();
	if(m_bPci1720On == TRUE)
	{
		SetSynOutput();
		AIVOut(0,m_fV1);
		AIVOut(1,m_fV2);
		AIVOut(2,m_fV3);
		WriteSyncAO();
	}
}

int CDlgPci1720::AIVOut(USHORT chan, float OutputValue)
{
	Pci1720.ptAOVoltageOut.chan = chan;
	Pci1720.ptAOVoltageOut.OutputValue = OutputValue;
	Pci1720.ErrCde=Pci1720.AOVoltageOut(Pci1720.PCI1720Handle,(LPT_AOVoltageOut)&Pci1720.ptAOVoltageOut);
	if(Pci1720.ErrCde!=SUCCESS)
	{
		Pci1720.ErrMessage(Pci1720.ErrCde,(LPSTR)Pci1720.szErrMsg);
	    Pci1720.CloseDevice((LONG *)&Pci1720.PCI1720Handle);
		MessageBox((LPCSTR)Pci1720.szErrMsg, "停止实验", MB_OK);
		return 0;
	}
	else
		return 1;
}

void CDlgPci1720::OpenPci1720()
{
	if((Pci1720.ErrCde=Pci1720.OpenDevice(PCI1720,
		(LONG *)&Pci1720.PCI1720Handle)!=SUCCESS))
	{
		strcpy(Pci1720.szErrMsg,"PCI1720 open error !");
		AfxMessageBox((LPCSTR)Pci1720.szErrMsg,MB_OK,0);
	}
	else
		m_bPci1720On = TRUE;
}

void CDlgPci1720::SetSynOutput()
{
	if((Pci1720.ErrCde = Pci1720.EnableSyncAO(Pci1720.PCI1720Handle,
		TRUE) != SUCCESS))
	{
		strcpy(Pci1720.szErrMsg,"Enable Sync Error !");
		AfxMessageBox((LPCSTR)Pci1720.szErrMsg,MB_OK,0);
		Pci1720.CloseDevice((LONG *)&Pci1720.PCI1720Handle);
	}
}

void CDlgPci1720::WriteSyncAO()
{
	Pci1720.ErrCde = Pci1720.WriteSyncAO(Pci1720.PCI1720Handle);
	if(Pci1720.ErrCde != SUCCESS)
	{
		Pci1720.ErrMessage(Pci1720.ErrCde,(LPSTR)Pci1720.szErrMsg);
		MessageBox((LPCSTR)Pci1720.szErrMsg, "Driver Message", MB_OK);
		Pci1720.CloseDevice((LONG *)&Pci1720.PCI1720Handle);
	}
}



void CDlgPci1720::ClosePci1720()
{
	if(m_bPci1720On == TRUE)
	{
		InitPci1720();
		Pci1720.CloseDevice((LONG *)&Pci1720.PCI1720Handle);
		m_bPci1720On = FALSE;
	}
	else m_bPci1720On = FALSE;
}

void CDlgPci1720::InitPci1720()
{
	SetSynOutput();
	AIVOut(0,0.0);
	AIVOut(1,0.0);
	AIVOut(2,0.0);
	AIVOut(3,0.0);
	WriteSyncAO();	
}

void CDlgPci1720::OnDestroy() 
{
	CDialog::OnDestroy();
	ClosePci1720();	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -