📄 dlgpci1713.cpp
字号:
// DlgPci1713.cpp : implementation file
//
#include "stdafx.h"
#include "CardTest.h"
#include "DlgPci1713.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgPci1713 dialog
CDlgPci1713::CDlgPci1713(CWnd* pParent /*=NULL*/)
: CDialog(CDlgPci1713::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgPci1713)
m_strChannel0 = _T("磁吸力1");
m_strChannel1 = _T("磁吸力2");
m_strChannel2 = _T("磁吸力3");
m_strChannel3 = _T("磁吸力4");
m_strChannel5 = _T("磁吸力6");
m_strChannel4 = _T("磁吸力5");
m_strChannel6 = _T("磁吸力7");
m_strChannel7 = _T("磁吸力8");
m_fValue0 = 0.0f;
m_fValue1 = 0.0f;
m_fValue2 = 0.0f;
m_fValue3 = 0.0f;
m_fValue4 = 0.0f;
m_fValue6 = 0.0f;
m_strPeriod = _T("1000");
m_fValue7 = 0.0f;
m_fValue5 = 0.0f;
m_strV1 = _T("V");
m_strV2 = _T("V");
m_strV3 = _T("V");
m_strV4 = _T("V");
m_strV5 = _T("V");
m_strV6 = _T("V");
m_strV7 = _T("V");
m_strV8 = _T("V");
m_strChannel8 = _T("磁吸力9");
m_strChannel9 = _T("磁吸力10");
m_strV9 = _T("V");
m_strV10 = _T("V");
m_fValue8 = 0.0f;
m_fValue9 = 0.0f;
m_nV = 0;
m_nD = -1;
m_strV11 = _T("V");
m_strT1 = _T("内侧和");
m_strT2 = _T("外侧和");
m_fValue10 = 0.0f;
m_fValue11 = 0.0f;
m_strV12 = _T("V");
//}}AFX_DATA_INIT
m_bPci1713On = FALSE;
m_bTimerOn = FALSE;
m_nPage = 0;
for(int i=0; i<32; i++)
VoltageIn[i] = 0.0;
}
void CDlgPci1713::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgPci1713)
DDX_Control(pDX, IDC_VALUE11, m_Text11);
DDX_Control(pDX, IDC_VALUE10, m_Text10);
DDX_Control(pDX, IDC_RADIO2, m_ctlD);
DDX_Control(pDX, IDC_RADIO1, m_ctlV);
DDX_Control(pDX, IDC_VALUE9, m_Text9);
DDX_Control(pDX, IDC_VALUE8, m_Text8);
DDX_Control(pDX, IDC_NEXT, m_btnNext);
DDX_Control(pDX, IDC_PRE, m_btnPre);
DDX_Control(pDX, IDC_VALUE7, m_Text7);
DDX_Control(pDX, IDC_VALUE6, m_Text6);
DDX_Control(pDX, IDC_VALUE5, m_Text5);
DDX_Control(pDX, IDC_VALUE4, m_Text4);
DDX_Control(pDX, IDC_VALUE3, m_Text3);
DDX_Control(pDX, IDC_VALUE2, m_Text2);
DDX_Control(pDX, IDC_VALUE1, m_Text1);
DDX_Control(pDX, IDC_VALUE0, m_Text0);
DDX_Text(pDX, IDC_ST0, m_strChannel0);
DDX_Text(pDX, IDC_ST1, m_strChannel1);
DDX_Text(pDX, IDC_ST2, m_strChannel2);
DDX_Text(pDX, IDC_ST3, m_strChannel3);
DDX_Text(pDX, IDC_ST5, m_strChannel5);
DDX_Text(pDX, IDC_ST4, m_strChannel4);
DDX_Text(pDX, IDC_ST6, m_strChannel6);
DDX_Text(pDX, IDC_ST7, m_strChannel7);
DDX_Text(pDX, IDC_VALUE0, m_fValue0);
DDX_Text(pDX, IDC_VALUE1, m_fValue1);
DDX_Text(pDX, IDC_VALUE2, m_fValue2);
DDX_Text(pDX, IDC_VALUE3, m_fValue3);
DDX_Text(pDX, IDC_VALUE4, m_fValue4);
DDX_Text(pDX, IDC_VALUE6, m_fValue6);
DDX_CBString(pDX, IDC_PERIOD, m_strPeriod);
DDX_Text(pDX, IDC_VALUE7, m_fValue7);
DDX_Text(pDX, IDC_VALUE5, m_fValue5);
DDX_Text(pDX, IDC_V1, m_strV1);
DDX_Text(pDX, IDC_V2, m_strV2);
DDX_Text(pDX, IDC_V3, m_strV3);
DDX_Text(pDX, IDC_V4, m_strV4);
DDX_Text(pDX, IDC_V5, m_strV5);
DDX_Text(pDX, IDC_V6, m_strV6);
DDX_Text(pDX, IDC_V7, m_strV7);
DDX_Text(pDX, IDC_V8, m_strV8);
DDX_Text(pDX, IDC_ST8, m_strChannel8);
DDX_Text(pDX, IDC_ST9, m_strChannel9);
DDX_Text(pDX, IDC_V9, m_strV9);
DDX_Text(pDX, IDC_V10, m_strV10);
DDX_Text(pDX, IDC_VALUE8, m_fValue8);
DDX_Text(pDX, IDC_VALUE9, m_fValue9);
DDX_Radio(pDX, IDC_RADIO1, m_nV);
DDX_Radio(pDX, IDC_RADIO2, m_nD);
DDX_Text(pDX, IDC_V11, m_strV11);
DDX_Text(pDX, IDC_TOTAL1, m_strT1);
DDX_Text(pDX, IDC_TOTAL2, m_strT2);
DDX_Text(pDX, IDC_VALUE10, m_fValue10);
DDX_Text(pDX, IDC_VALUE11, m_fValue11);
DDX_Text(pDX, IDC_V12, m_strV12);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgPci1713, CDialog)
//{{AFX_MSG_MAP(CDlgPci1713)
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_START, OnStart)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_STOP, OnStop)
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_BN_CLICKED(IDC_PRE, OnPre)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgPci1713 message handlers
BOOL CDlgPci1713::OnInitDialog()
{
CDialog::OnInitDialog();
m_btnNext.SetIcon(IDI_RIGHT);
m_btnPre.SetIcon(IDI_LEFT);
m_Text0.SetBackColor(RGB( 255, 255, 255));
m_Text1.SetBackColor(RGB( 255, 255, 255));
m_Text2.SetBackColor(RGB( 255, 255, 255));
m_Text3.SetBackColor(RGB( 255, 255, 255));
m_Text4.SetBackColor(RGB( 255, 255, 255));
m_Text5.SetBackColor(RGB( 255, 255, 255));
m_Text6.SetBackColor(RGB( 255, 255, 255));
m_Text7.SetBackColor(RGB( 255, 255, 255));
m_Text8.SetBackColor(RGB( 255, 255, 255));
m_Text9.SetBackColor(RGB( 255, 255, 255));
m_Text10.SetBackColor(RGB( 255, 255, 255));
m_Text11.SetBackColor(RGB( 255, 255, 255));
m_Text0.SetTextColor(RGB( 0, 0, 0));
m_Text1.SetTextColor(RGB( 0, 0, 0));
m_Text2.SetTextColor(RGB( 0, 0, 0));
m_Text3.SetTextColor(RGB( 0, 0, 0));
m_Text4.SetTextColor(RGB( 0, 0, 0));
m_Text5.SetTextColor(RGB( 0, 0, 0));
m_Text6.SetTextColor(RGB( 0, 0, 0));
m_Text7.SetTextColor(RGB( 0, 0, 0));
m_Text8.SetTextColor(RGB( 0, 0, 0));
m_Text9.SetTextColor(RGB( 0, 0, 0));
m_Text10.SetTextColor(RGB( 0, 0, 0));
m_Text11.SetTextColor(RGB( 0, 0, 0));
OpenPci1713(); // 打开PCI1713
SetInputRange(); // 设置PCI1713模拟量输入范围
MAIConfig(); // 配置PCI1713
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgPci1713::OpenPci1713()
{
if(Pci1713.ErrCde=Pci1713.OpenDevice(PCI1713,
(LONG *)&Pci1713.PCI1713Handle)!=SUCCESS)
{
Pci1713.ErrMessage(Pci1713.ErrCde,(LPSTR)Pci1713.szErrMsg);
m_bPci1713On = FALSE;
MessageBox(Pci1713.szErrMsg);
}
else m_bPci1713On = TRUE;//设置PCI1713打开标志位
}
void CDlgPci1713::ClosePci1713()
{
if(m_bPci1713On == TRUE)
{
Pci1713.CloseDevice((LONG *)&Pci1713.PCI1713Handle);
m_bPci1713On = FALSE;
}
else m_bPci1713On = FALSE;
}
void CDlgPci1713::MAIConfig()
{
Pci1713.ptMAIConfig.NumChan = 32;
Pci1713.ptMAIConfig.StartChan = 0;
Pci1713.ptMAIConfig.GainArray = &Pci1713.GainList[0];
if((Pci1713.ErrCde=Pci1713.MAIConfig(Pci1713.PCI1713Handle,
(LPT_MAIConfig)&Pci1713.ptMAIConfig))!=SUCCESS)
{
Pci1713.ErrMessage(Pci1713.ErrCde,(LPSTR)Pci1713.szErrMsg);
Pci1713.CloseDevice((LONG *)&Pci1713.PCI1713Handle);
MessageBox(Pci1713.szErrMsg);
}
}
void CDlgPci1713::SetInputRange()
{
Pci1713.ptDevFeatures.buffer=(LPDEVFEATURES)&Pci1713.DevFeatures;//查一下函数具体用法
Pci1713.ptDevFeatures.size=sizeof(DEVFEATURES);
if((Pci1713.ErrCde=Pci1713.GetFeatures(Pci1713.PCI1713Handle,
(LPT_DeviceGetFeatures)&Pci1713.ptDevFeatures))!=SUCCESS)
{
Pci1713.ErrMessage(Pci1713.ErrCde,(LPSTR)Pci1713.szErrMsg);
ClosePci1713();
MessageBox(Pci1713.szErrMsg);
}
//////////////////////////////////////////////////
// glGainList usGainCde 范围 //
// 0 16 0--10V //
// 1 17 0--5V //
// 2 18 0--2.5V //
// 3 19 0--1.25V //
// 4 4 -10--+10V //
// 5 0 -5--+5V //
// 6 1 -2.5--+2.5 //
// 7 2 -1.25--+1.25V //
// 8 3 -0.625--+0.625V //
//////////////////////////////////////////////////
for(int i=0;i<32;i++)
Pci1713.GainList[i]=Pci1713.DevFeatures.glGainList[0].usGainCde;
}
void CDlgPci1713::MAIVoltageIn()
{
Pci1713.ptMAIVoltageIn.NumChan = 32;
Pci1713.ptMAIVoltageIn.StartChan = 0;
Pci1713.ptMAIVoltageIn.GainArray = &Pci1713.GainList[0];
Pci1713.ptMAIVoltageIn.TrigMode = 0;
Pci1713.ptMAIVoltageIn.VoltageArray = VoltageIn;
if((Pci1713.ErrCde=Pci1713.MAIVoltageIn(Pci1713.PCI1713Handle,
(LPT_MAIVoltageIn)&Pci1713.ptMAIVoltageIn))!=SUCCESS)
{
Pci1713.ErrMessage(Pci1713.ErrCde,(LPSTR)Pci1713.szErrMsg);
ClosePci1713();
MessageBox(Pci1713.szErrMsg);
}
}
void CDlgPci1713::OnDestroy()
{
CDialog::OnDestroy();
if(m_bPci1713On == TRUE)
ClosePci1713();
if(m_bTimerOn)
{
KillTimer(2);
m_bTimerOn = FALSE;
}
}
void CDlgPci1713::OnStart()
{
UpdateData(TRUE);
int SamplePeriod;
SamplePeriod = atoi(m_strPeriod);
if(SetTimer(2, SamplePeriod, NULL) == 2)
m_bTimerOn = TRUE;
else
m_bTimerOn = FALSE;
}
void CDlgPci1713::OnTimer(UINT nIDEvent)
{
MAIVoltageIn();
if(m_ctlV.GetCheck() == 1)
{
if(m_nPage ==0)
{
m_fValue0 = VoltageIn[9];
m_fValue1 = VoltageIn[2];
m_fValue2 = VoltageIn[4];
m_fValue3 = VoltageIn[6];
m_fValue4 = VoltageIn[8];
m_fValue5 = VoltageIn[10];
m_fValue6 = VoltageIn[12];
m_fValue7 = VoltageIn[14];
m_fValue8 = VoltageIn[16];
m_fValue9 = VoltageIn[18];
m_fValue10 = m_fValue2+m_fValue6+m_fValue8+m_fValue0+m_fValue7;
m_fValue11 = m_fValue4+m_fValue9+m_fValue3+m_fValue5+m_fValue1;
m_strChannel0 = _T("磁吸力1");
m_strChannel1 = _T("磁吸力2");
m_strChannel2 = _T("磁吸力3");
m_strChannel3 = _T("磁吸力4");
m_strChannel5 = _T("磁吸力6");
m_strChannel4 = _T("磁吸力5");
m_strChannel6 = _T("磁吸力7");
m_strChannel7 = _T("磁吸力8");
m_strChannel8 = _T("磁吸力9");
m_strChannel9 = _T("磁吸力10");
m_strT1 = _T("内侧和");
m_strT2 = _T("外侧和");
m_strV1 = _T("V");
m_strV2 = _T("V");
m_strV3 = _T("V");
m_strV4 = _T("V");
m_strV5 = _T("V");
m_strV6 = _T("V");
m_strV7 = _T("V");
m_strV8 = _T("V");
m_strV9 = _T("V");
m_strV10 = _T("V");
m_strV11 = _T("V");
m_strV12 = _T("V");
m_Text0.ShowWindow(SW_SHOW);
m_Text1.ShowWindow(SW_SHOW);
m_Text2.ShowWindow(SW_SHOW);
m_Text3.ShowWindow(SW_SHOW);
m_Text4.ShowWindow(SW_SHOW);
m_Text5.ShowWindow(SW_SHOW);
m_Text6.ShowWindow(SW_SHOW);
m_Text7.ShowWindow(SW_SHOW);
m_Text8.ShowWindow(SW_SHOW);
m_Text9.ShowWindow(SW_SHOW);
m_Text10.ShowWindow(SW_SHOW);
m_Text11.ShowWindow(SW_SHOW);
}
if(m_nPage == 1)
{
m_fValue2 = VoltageIn[22];
m_fValue4 = VoltageIn[1];
m_fValue6 = VoltageIn[24];
m_fValue9 = VoltageIn[3];
m_fValue3 = VoltageIn[5];
m_fValue5 = VoltageIn[7];
m_fValue8 = VoltageIn[26];
m_fValue0 = VoltageIn[28];
m_fValue7 = VoltageIn[30];
m_strChannel2 = _T("转速");
m_strChannel4 = _T("励磁电流1");
m_strChannel6 = _T("制动力1");
m_strChannel9 = _T("励磁电流2");
m_strChannel3 = _T("励磁电流3");
m_strChannel5 = _T("励磁电流4");
m_strChannel8 = _T("制动力2");
m_strChannel0 = _T("制动力3");
m_strChannel7 = _T("制动力4");
m_strChannel1 = _T("");
m_strT1 = _T("");
m_strT2 = _T("");
m_strV1 = _T("V");
m_strV2 = _T("");
m_strV3 = _T("V");
m_strV4 = _T("V");
m_strV5 = _T("V");
m_strV6 = _T("V");
m_strV7 = _T("V");
m_strV8 = _T("V");
m_strV9 = _T("V");
m_strV10 = _T("V");
m_strV11 = _T("");
m_strV12 = _T("");
m_Text0.ShowWindow(SW_SHOW);
m_Text1.ShowWindow(SW_HIDE);
m_Text2.ShowWindow(SW_SHOW);
m_Text3.ShowWindow(SW_SHOW);
m_Text4.ShowWindow(SW_SHOW);
m_Text5.ShowWindow(SW_SHOW);
m_Text6.ShowWindow(SW_SHOW);
m_Text7.ShowWindow(SW_SHOW);
m_Text8.ShowWindow(SW_SHOW);
m_Text9.ShowWindow(SW_SHOW);
m_Text10.ShowWindow(SW_HIDE);
m_Text11.ShowWindow(SW_HIDE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -