📄 demo_inp_movedlg.cpp
字号:
// Demo_Inp_MoveDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Demo_Inp_Move.h"
#include "Demo_Inp_MoveDlg.h"
#include "850Para.h"
#include "adt850.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDemo_Inp_MoveDlg dialog
CDemo_Inp_MoveDlg::CDemo_Inp_MoveDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDemo_Inp_MoveDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDemo_Inp_MoveDlg)
m_nPulseCount_w = 0;
m_nPulseCount_x = 0;
m_nPulseCount_z = 0;
m_nPulseCount_y = 0;
m_bChkDemo_w = FALSE;
m_bChkDemo_x = FALSE;
m_bChkDemo_y = FALSE;
m_bChkDemo_z = FALSE;
m_bEnableSymmetry_Acc_w = FALSE;
m_bEnableSymmetry_Acc_x = FALSE;
m_bEnableSymmetry_Acc_y = FALSE;
m_bEnableSymmetry_Acc_z = FALSE;
m_bDisableEquality_V = FALSE;
m_bEnable_S_Move = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bIsInpLine=TRUE;
m_bIsTwoAxisInp=TRUE;
m_bIsThreeAxisInp=FALSE;
m_bIsFourAxisInp=FALSE;
m_bIsContinueInp=FALSE; //单个插补
}
void CDemo_Inp_MoveDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDemo_Inp_MoveDlg)
DDX_Text(pDX, IDC_EDIT_PULSE_COUNT_W, m_nPulseCount_w);
DDX_Text(pDX, IDC_EDIT_PULSE_COUNT_X, m_nPulseCount_x);
DDX_Text(pDX, IDC_EDIT_PULSE_COUNT_Z, m_nPulseCount_z);
DDX_Text(pDX, IDC_EDIT_PULSE_COUNT_Y, m_nPulseCount_y);
DDX_Check(pDX, IDC_CHECK_DEMO_W, m_bChkDemo_w);
DDX_Check(pDX, IDC_CHECK_DEMO_X, m_bChkDemo_x);
DDX_Check(pDX, IDC_CHECK_DEMO_Y, m_bChkDemo_y);
DDX_Check(pDX, IDC_CHECK_DEMO_Z, m_bChkDemo_z);
DDX_Check(pDX, IDC_CHECK_SYMMETRY_VELOCITY_W, m_bEnableSymmetry_Acc_w);
DDX_Check(pDX, IDC_CHECK_SYMMETRY_VELOCITY_X, m_bEnableSymmetry_Acc_x);
DDX_Check(pDX, IDC_CHECK_SYMMETRY_VELOCITY_Y, m_bEnableSymmetry_Acc_y);
DDX_Check(pDX, IDC_CHECK_SYMMETRY_VELOCITY_Z, m_bEnableSymmetry_Acc_z);
DDX_Check(pDX, IDC_CHECK_DISABLE_EQUALITY, m_bDisableEquality_V);
DDX_Check(pDX, IDC_CHECK_MOVE_TYPE_S, m_bEnable_S_Move);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDemo_Inp_MoveDlg, CDialog)
//{{AFX_MSG_MAP(CDemo_Inp_MoveDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BTN_DETAIL_SETTING, OnBtnDetailSetting)
ON_BN_CLICKED(IDC_CHECK_DISABLE_EQUALITY, OnCheckDisableEquality)
ON_BN_CLICKED(IDC_RADIO_INP_ARC, OnRadioInpArc)
ON_BN_CLICKED(IDC_RADIO_INP_LINE, OnRadioInpLine)
ON_BN_CLICKED(IDC_CHECK_DEMO_W, OnCheckDemoW)
ON_BN_CLICKED(IDC_CHECK_DEMO_X, OnCheckDemoX)
ON_BN_CLICKED(IDC_CHECK_DEMO_Y, OnCheckDemoY)
ON_BN_CLICKED(IDC_CHECK_DEMO_Z, OnCheckDemoZ)
ON_BN_CLICKED(IDC_RADIO_INP_AXIS_FOUR, OnRadioInpAxisFour)
ON_BN_CLICKED(IDC_RADIO_INP_AXIS_THREE, OnRadioInpAxisThree)
ON_BN_CLICKED(IDC_RADIO_INP_AXIS_TWO, OnRadioInpAxisTwo)
ON_BN_CLICKED(IDC_CHECK_MOVE_TYPE_S, OnCheckMoveTypeS)
ON_BN_CLICKED(IDC_CHECK_SYMMETRY_VELOCITY_W, OnCheckSymmetryVelocityW)
ON_BN_CLICKED(IDC_CHECK_SYMMETRY_VELOCITY_X, OnCheckSymmetryVelocityX)
ON_BN_CLICKED(IDC_CHECK_SYMMETRY_VELOCITY_Y, OnCheckSymmetryVelocityY)
ON_BN_CLICKED(IDC_CHECK_SYMMETRY_VELOCITY_Z, OnCheckSymmetryVelocityZ)
ON_BN_CLICKED(IDC_BTN_INP_SINGLE, OnBtnInpSingle)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BTN_INP_CONTINUE, OnBtnInpContinue)
ON_BN_CLICKED(IDC_BTN_INP_STOP, OnBtnInpStop)
ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnButtonClear)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDemo_Inp_MoveDlg message handlers
BOOL CDemo_Inp_MoveDlg::OnInitDialog()
{
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)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
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
((CButton*)GetDlgItem(IDC_RADIO_INP_LINE))->SetCheck(TRUE);
((CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_TWO))->SetCheck(TRUE);
OnRadioInpAxisTwo();
CEdit* pEdit=NULL;
RECT rc;
m_pToolTip=new CToolTipCtrl;
m_pToolTip->Create(this);
for(int i=IDC_EDIT_PULSE_COUNT_X;i<=IDC_EDIT_PULSE_COUNT_W;i++){
pEdit=(CEdit*)GetDlgItem(i);
if(pEdit){
pEdit->GetClientRect(&rc);
m_pToolTip->AddTool(pEdit,"输入范围:-8388608--- +8388607",&rc,i);
}
}
m_pToolTip->SetDelayTime(500);
m_pToolTip->Activate(TRUE);
//-------------------初始化参数------------------------------
C850Para dlgSetPara(m_bDisableEquality_V,this);
m_nRatio_w=dlgSetPara.m_nRatio_w;
m_nRatio_x=dlgSetPara.m_nRatio_x;
m_nRatio_y=dlgSetPara.m_nRatio_y;
m_nRatio_z=dlgSetPara.m_nRatio_z;
m_nStartV_x=dlgSetPara.m_nStartV_x;
m_nStartV_y=dlgSetPara.m_nStartV_y;
m_nStartV_z=dlgSetPara.m_nStartV_z;
m_nStartV_w=dlgSetPara.m_nStartV_w;
m_nDriveSpeed_x=dlgSetPara.m_nDriveSpeed_x;
m_nDriveSpeed_y=dlgSetPara.m_nDriveSpeed_y;
m_nDriveSpeed_z=dlgSetPara.m_nDriveSpeed_z;
m_nDriveSpeed_w=dlgSetPara.m_nDriveSpeed_w;
m_nVelocityAcc_w=dlgSetPara.m_nAccVelocity_w;
m_nVelocityAcc_x=dlgSetPara.m_nAccVelocity_x;
m_nVelocityAcc_y=dlgSetPara.m_nAccVelocity_y;
m_nVelocityAcc_z=dlgSetPara.m_nAccVelocity_z;
m_nVelocityDec_w=dlgSetPara.m_nDecVelocity_w;
m_nVelocityDec_x=dlgSetPara.m_nDecVelocity_x;
m_nVelocityDec_y=dlgSetPara.m_nDecVelocity_y;
m_nVelocityDec_z=dlgSetPara.m_nDecVelocity_z;
m_fAccTime_w=dlgSetPara.m_fAccTime_w;
m_fAccTime_x=dlgSetPara.m_fAccTime_x;
m_fAccTime_y=dlgSetPara.m_fAccTime_y;
m_fAccTime_z=dlgSetPara.m_fAccTime_z;
//--------------------------------------------------------------
Init850Card();
SetTimer(1,100,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CDemo_Inp_MoveDlg::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 CDemo_Inp_MoveDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (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 to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CDemo_Inp_MoveDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CDemo_Inp_MoveDlg::OnBtnDetailSetting()
{
// TODO: Add your control notification handler code here
C850Para dlgSetPara(m_bDisableEquality_V,this);
dlgSetPara.m_nRatio_w=m_nRatio_w;
dlgSetPara.m_nRatio_x=m_nRatio_x;
dlgSetPara.m_nRatio_y=m_nRatio_y;
dlgSetPara.m_nRatio_z=m_nRatio_z;
dlgSetPara.m_nStartV_x=m_nStartV_x;
dlgSetPara.m_nStartV_y=m_nStartV_y;
dlgSetPara.m_nStartV_z=m_nStartV_z;
dlgSetPara.m_nStartV_w=m_nStartV_w;
dlgSetPara.m_nDriveSpeed_x=m_nDriveSpeed_x;
dlgSetPara.m_nDriveSpeed_y=m_nDriveSpeed_y;
dlgSetPara.m_nDriveSpeed_z=m_nDriveSpeed_z;
dlgSetPara.m_nDriveSpeed_w=m_nDriveSpeed_w;
dlgSetPara.m_nAccVelocity_x=m_nVelocityAcc_x;
dlgSetPara.m_nAccVelocity_y=m_nVelocityAcc_y;
dlgSetPara.m_nAccVelocity_z=m_nVelocityAcc_z;
dlgSetPara.m_nAccVelocity_w=m_nVelocityAcc_w;
dlgSetPara.m_nDecVelocity_x=m_nVelocityDec_x;
dlgSetPara.m_nDecVelocity_y=m_nVelocityDec_y;
dlgSetPara.m_nDecVelocity_z=m_nVelocityDec_z;
dlgSetPara.m_nDecVelocity_w=m_nVelocityDec_w;
dlgSetPara.m_fAccTime_x=m_fAccTime_x;
dlgSetPara.m_fAccTime_y=m_fAccTime_y;
dlgSetPara.m_fAccTime_z=m_fAccTime_z;
dlgSetPara.m_fAccTime_w=m_fAccTime_w;
dlgSetPara.m_bEnableAcc=m_bDisableEquality_V;
if(dlgSetPara.DoModal()==IDOK){
m_nRatio_w=dlgSetPara.m_nRatio_w;
m_nRatio_x=dlgSetPara.m_nRatio_x;
m_nRatio_y=dlgSetPara.m_nRatio_y;
m_nRatio_z=dlgSetPara.m_nRatio_z;
m_nStartV_x=dlgSetPara.m_nStartV_x;
m_nStartV_y=dlgSetPara.m_nStartV_y;
m_nStartV_z=dlgSetPara.m_nStartV_z;
m_nStartV_w=dlgSetPara.m_nStartV_w;
m_nDriveSpeed_x=dlgSetPara.m_nDriveSpeed_x;
m_nDriveSpeed_y=dlgSetPara.m_nDriveSpeed_y;
m_nDriveSpeed_z=dlgSetPara.m_nDriveSpeed_z;
m_nDriveSpeed_w=dlgSetPara.m_nDriveSpeed_w;
m_nVelocityAcc_w=dlgSetPara.m_nAccVelocity_w;
m_nVelocityAcc_x=dlgSetPara.m_nAccVelocity_x;
m_nVelocityAcc_y=dlgSetPara.m_nAccVelocity_y;
m_nVelocityAcc_z=dlgSetPara.m_nAccVelocity_z;
m_nVelocityDec_w=dlgSetPara.m_nDecVelocity_w;
m_nVelocityDec_x=dlgSetPara.m_nDecVelocity_x;
m_nVelocityDec_y=dlgSetPara.m_nDecVelocity_y;
m_nVelocityDec_z=dlgSetPara.m_nDecVelocity_z;
if(m_nStartV_x>=m_nDriveSpeed_x)m_nDriveSpeed_x=m_nStartV_x;
if(m_nStartV_y>=m_nDriveSpeed_y)m_nDriveSpeed_y=m_nStartV_y;
if(m_nStartV_z>=m_nDriveSpeed_z)m_nDriveSpeed_z=m_nStartV_z;
if(m_nStartV_w>=m_nDriveSpeed_w)m_nDriveSpeed_w=m_nStartV_w;
CheckNum(m_nRatio_x,1,500);
CheckNum(m_nRatio_y,1,500);
CheckNum(m_nRatio_z,1,500);
CheckNum(m_nRatio_w,1,500);
CheckNum(m_nStartV_x,1*m_nRatio_x,8000*m_nRatio_x);
CheckNum(m_nStartV_y,1*m_nRatio_y,8000*m_nRatio_y);
CheckNum(m_nStartV_z,1*m_nRatio_z,8000*m_nRatio_z);
CheckNum(m_nStartV_w,1*m_nRatio_w,8000*m_nRatio_w);
CheckNum(m_nDriveSpeed_x,1*m_nRatio_x,8000*m_nRatio_x);
CheckNum(m_nDriveSpeed_y,1*m_nRatio_y,8000*m_nRatio_y);
CheckNum(m_nDriveSpeed_z,1*m_nRatio_z,8000*m_nRatio_z);
CheckNum(m_nDriveSpeed_w,1*m_nRatio_w,8000*m_nRatio_w);
CheckNum(m_nVelocityAcc_x,125*m_nRatio_x,1000000*m_nRatio_x);
CheckNum(m_nVelocityAcc_y,125*m_nRatio_y,1000000*m_nRatio_y);
CheckNum(m_nVelocityAcc_z,125*m_nRatio_z,1000000*m_nRatio_z);
CheckNum(m_nVelocityAcc_w,125*m_nRatio_w,1000000*m_nRatio_w);
CheckNum(m_nVelocityDec_x,125*m_nRatio_x,1000000*m_nRatio_x);
CheckNum(m_nVelocityDec_y,125*m_nRatio_y,1000000*m_nRatio_y);
CheckNum(m_nVelocityDec_z,125*m_nRatio_z,1000000*m_nRatio_z);
CheckNum(m_nVelocityDec_w,125*m_nRatio_w,1000000*m_nRatio_w);
CalAccTime();
}
}
void CDemo_Inp_MoveDlg::OnCheckDisableEquality()
{
// TODO: Add your control notification handler code here
m_bDisableEquality_V=!m_bDisableEquality_V;
EnableCheckWnd(m_bDisableEquality_V);
}
void CDemo_Inp_MoveDlg::EnableCheckWnd(BOOL bEnable)
{
CWnd* pWnd=NULL;
pWnd=GetDlgItem(IDC_STATIC_MOVE_TYPE);
pWnd->EnableWindow(bEnable);
if(m_bIsInpLine){
pWnd=GetDlgItem(IDC_CHECK_MOVE_TYPE_S);
pWnd->EnableWindow(bEnable);
pWnd=GetDlgItem(IDC_CHECK_SYMMETRY_VELOCITY_X);
pWnd->EnableWindow(bEnable);
pWnd=GetDlgItem(IDC_CHECK_SYMMETRY_VELOCITY_Y);
pWnd->EnableWindow(bEnable);
pWnd=GetDlgItem(IDC_CHECK_SYMMETRY_VELOCITY_Z);
pWnd->EnableWindow(bEnable);
pWnd=GetDlgItem(IDC_CHECK_SYMMETRY_VELOCITY_W);
pWnd->EnableWindow(bEnable);
}
else
{
pWnd=GetDlgItem(IDC_CHECK_MOVE_TYPE_S);
pWnd->EnableWindow(FALSE);
pWnd=GetDlgItem(IDC_CHECK_SYMMETRY_VELOCITY_X);
pWnd->EnableWindow(FALSE);
pWnd=GetDlgItem(IDC_CHECK_SYMMETRY_VELOCITY_Y);
pWnd->EnableWindow(FALSE);
pWnd=GetDlgItem(IDC_CHECK_SYMMETRY_VELOCITY_Z);
pWnd->EnableWindow(FALSE);
pWnd=GetDlgItem(IDC_CHECK_SYMMETRY_VELOCITY_W);
pWnd->EnableWindow(FALSE);
}
}
void CDemo_Inp_MoveDlg::OnRadioInpArc()
{
// TODO: Add your control notification handler code here
m_bIsInpLine=FALSE;
CButton* pButton=NULL;
int nState=-1;
pButton=(CButton*) GetDlgItem(IDC_CHECK_MOVE_TYPE_S);
nState=pButton->GetState();
if((nState & 0x0003)==1){
pButton->SetCheck(0);
m_bDisableEquality_V=FALSE;
}
pButton->EnableWindow(FALSE);
CWnd* pWnd=NULL;
pWnd=GetDlgItem(IDC_STATIC_PULSE_COUNT);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -