📄 addialog.cpp
字号:
// ADDIALOG.cpp : implementation file
//
#include "stdafx.h"
#include "pc7423.h"
#include "ADDIALOG.h"
#include "iostream.h"
#include "iomanip.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CADDIALOG dialog
CADDIALOG::CADDIALOG(CWnd* pParent /*=NULL*/)
: CDialog(CADDIALOG::IDD, pParent)
{
//{{AFX_DATA_INIT(CADDIALOG)
m_ad1 = 0.0f;
m_ad10 = 0.0f;
m_ad11 = 0.0f;
m_ad12 = 0.0f;
m_ad13 = 0.0f;
m_ad14 = 0.0f;
m_ad15 = 0.0f;
m_ad16 = 0.0f;
m_ad2 = 0.0f;
m_ad3 = 0.0f;
m_ad4 = 0.0f;
m_ad5 = 0.0f;
m_ad6 = 0.0f;
m_ad7 = 0.0f;
m_ad8 = 0.0f;
m_ad9 = 0.0f;
m_nc = -1;
//}}AFX_DATA_INIT
}
void CADDIALOG::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CADDIALOG)
DDX_Text(pDX, IDC_EDIT1, m_ad1);
DDX_Text(pDX, IDC_EDIT10, m_ad10);
DDX_Text(pDX, IDC_EDIT11, m_ad11);
DDX_Text(pDX, IDC_EDIT12, m_ad12);
DDX_Text(pDX, IDC_EDIT13, m_ad13);
DDX_Text(pDX, IDC_EDIT14, m_ad14);
DDX_Text(pDX, IDC_EDIT15, m_ad15);
DDX_Text(pDX, IDC_EDIT16, m_ad16);
DDX_Text(pDX, IDC_EDIT2, m_ad2);
DDX_Text(pDX, IDC_EDIT3, m_ad3);
DDX_Text(pDX, IDC_EDIT4, m_ad4);
DDX_Text(pDX, IDC_EDIT5, m_ad5);
DDX_Text(pDX, IDC_EDIT6, m_ad6);
DDX_Text(pDX, IDC_EDIT7, m_ad7);
DDX_Text(pDX, IDC_EDIT8, m_ad8);
DDX_Text(pDX, IDC_EDIT9, m_ad9);
DDX_Radio(pDX, IDC_RADIO1, m_nc);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CADDIALOG, CDialog)
//{{AFX_MSG_MAP(CADDIALOG)
ON_BN_CLICKED(IDC_STOP_BUTTON, OnStopButton)
ON_BN_CLICKED(IDC_STARTS_BUTTON, OnStartsButton)
ON_BN_CLICKED(IDC_ADEXIT_BUTTON, OnAdexitButton)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CADDIALOG message handlers
void CADDIALOG::OnStopButton()
{
// TODO: Add your control notification handler code here
////////////////////////
//MY CODE STARTS HERE
////////////////////////
//if(delay>=4000) MessageBox("delay>4000");
// else MessageBox("delay<4000");
KillTimer(1);
////////////////////////
//MY CODE ENDS HERE
////////////////////////
}
void CADDIALOG::OnStartsButton()
{
// TODO: Add your control notification handler code here
////////////////////////
//MY CODE STARTS HERE
////////////////////////
reg();
int itime;
itime=SetTimer(1,
10,
NULL);
if(itime==0)
{
MessageBox("cannot install timer!");
}
////////////////////////
//MY CODE ENDS HERE
////////////////////////
}
void CADDIALOG::OnAdexitButton()
{
// TODO: Add your control notification handler code here
////////////////////////
//MY CODE STARTS HERE
////////////////////////
OnOK();
////////////////////////
//MY CODE ENDS HERE
////////////////////////
}
void CADDIALOG::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
////////////////////////
//MY CODE STARTS HERE
////////////////////////
//MessageBeep((WORD)-1);
float b=0,c=0;
int ad1,ad2;
switch (m_nc){
case 0:b=(float)10.0/4095.0;
c=0;
break;
case 1:b=10.0/4095.0;
c=5;
break;
case 2:b=20.0/4095.0;
c=10;
}
// out(0x300,0,dly);
// out(0x301,0,dly);
// ad1=in(0x302,dly);
// ad2=in(0x303,dly);
m_ad1=ad(0,dly)*b-c;
m_ad2=ad(1,dly)*b-c;
m_ad3=ad(2,dly)*b-c;
m_ad4=ad(3,dly)*b-c;
m_ad5=ad(4,dly)*b-c;
m_ad6=ad(5,dly)*b-c;
m_ad7=ad(6,dly)*b-c;
m_ad8=ad(7,dly)*b-c;
m_ad9=ad(8,dly)*b-c;
m_ad10=ad(9,dly)*b-c;
m_ad11=ad(10,dly)*b-c;
m_ad12=ad(11,dly)*b-c;
m_ad13=ad(12,dly)*b-c;
m_ad14=ad(13,dly)*b-c;
m_ad15=ad(14,dly)*b-c;
m_ad16=ad(15,dly)*b-c;
UpdateData(FALSE);
////////////////////////
//MY CODE ENDS HERE
////////////////////////
CDialog::OnTimer(nIDEvent);
}
void CADDIALOG::OnRadio1()
{
// TODO: Add your control notification handler code here
////////////////////////
//MY CODE STARTS HERE
////////////////////////
UpdateData(TRUE);
CString msg;
msg="(0--10V)";
xs_nc(msg);
////////////////////////
//MY CODE ENDS HERE
////////////////////////
}
void CADDIALOG::OnRadio2()
{
// TODO: Add your control notification handler code here
////////////////////////
//MY CODE STARTS HERE
////////////////////////
UpdateData(TRUE);
CString msg;
msg="(-5--+5V)";
xs_nc(msg);
////////////////////////
//MY CODE ENDS HERE
////////////////////////
}
void CADDIALOG::OnRadio3()
{
// TODO: Add your control notification handler code here
////////////////////////
//MY CODE STARTS HERE
////////////////////////
UpdateData(TRUE);
CString msg;
msg="(-10--+10V)";
xs_nc(msg);
////////////////////////
//MY CODE ENDS HERE
////////////////////////
}
BOOL CADDIALOG::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
////////////////////////
//MY CODE STARTS HERE
////////////////////////
CString msg;
m_nc=0;
cyxs="采样显示区";
msg="(0--10V)";
xs_nc(msg);
UpdateData(FALSE);
////////////////////////
//MY CODE ENDS HERE
////////////////////////
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CADDIALOG::xs_nc(CString msg)
{
msg=cyxs+msg;
SetDlgItemText(IDC_CYXS_STATIC,msg);
UpdateData(FALSE);
}
void CADDIALOG::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
int CADDIALOG::ad(int adch, int dly)
{
int ad1,ad2,addata;
out(0x300,adch,dly);
out(0x301,0,dly);
ad1=in(0x302,dly);
ad2=in(0x303,dly);
addata=(ad2&0xff)*16+(ad1&0xf0)/16;
return addata;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -