📄 demo_movedlg.cpp
字号:
// demo_moveDlg.cpp : implementation file
//
#include "stdafx.h"
#include "demo_move.h"
#include "demo_moveDlg.h"
#include "850Para.h"
#include "adt850.h"
#include "data.h"
#include <afxcmn.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_moveDlg dialog
Info arrInfo[4];
CDemo_moveDlg::CDemo_moveDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDemo_moveDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDemo_moveDlg)
m_nLogicPos_w = 0;
m_nLogicPos_x = 0;
m_nLogicPos_y = 0;
m_nLogicPos_z = 0;
m_nCurrentSpeed_w = 0;
m_nCurrentSpeed_x = 0;
m_nCurrentSpeed_y = 0;
m_nCurrentSpeed_z = 0;
m_nCountPulse_w = 0;
m_nCountPulse_x = 0;
m_nCountPulse_y = 0;
m_nCountPulse_z = 0;
m_bEnableDemo_w = FALSE;
m_bEnableDemo_x = FALSE;
m_bEnableDemo_y = FALSE;
m_bEnableDemo_z = FALSE;
m_bEnableSymmetry_Acc_w = FALSE;
m_bEnableSymmetry_Acc_x = FALSE;
m_bEnableSymmetry_Acc_y = FALSE;
m_bEnableSymmetry_Acc_z = FALSE;
m_bEnableCurve_Move = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bEqualityVelocity=TRUE;
m_nStartV_x=1000;
m_nStartV_y=1000;
m_nStartV_z=1000;
m_nStartV_w=1000;
m_nRatio_x=5;
m_nRatio_y=5;
m_nRatio_z=5;
m_nRatio_w=5;
m_nVelocityAcc_x=8;
m_nVelocityAcc_y=8;
m_nVelocityAcc_z=8;
m_nVelocityAcc_w=8;
m_nVelocityDec_x=8;
m_nVelocityDec_y=8;
m_nVelocityDec_z=8;
m_nVelocityDec_w=8;
m_nDriveSpeed_x=10000;
m_nDriveSpeed_y=10000;
m_nDriveSpeed_z=10000;
m_nDriveSpeed_w=10000;
m_fAccTime_w=0.1f;
m_fAccTime_x=0.1f;
m_fAccTime_y=0.1f;
m_fAccTime_z=0.1f;
}
void CDemo_moveDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDemo_moveDlg)
DDX_Text(pDX, IDC_EDIT_POS_W, m_nLogicPos_w);
DDX_Text(pDX, IDC_EDIT_POS_X, m_nLogicPos_x);
DDX_Text(pDX, IDC_EDIT_POS_Y, m_nLogicPos_y);
DDX_Text(pDX, IDC_EDIT_POS_Z, m_nLogicPos_z);
DDX_Text(pDX, IDC_EDIT_SPEED_W, m_nCurrentSpeed_w);
DDX_Text(pDX, IDC_EDIT_SPEED_X, m_nCurrentSpeed_x);
DDX_Text(pDX, IDC_EDIT_SPEED_Y, m_nCurrentSpeed_y);
DDX_Text(pDX, IDC_EDIT_SPEED_Z, m_nCurrentSpeed_z);
DDX_Text(pDX, IDC_EDIT_COUNT_PULSE_W, m_nCountPulse_w);
DDX_Text(pDX, IDC_EDIT_COUNT_PULSE_X, m_nCountPulse_x);
DDX_Text(pDX, IDC_EDIT_COUNT_PULSE_Y, m_nCountPulse_y);
DDX_Text(pDX, IDC_EDIT_COUNT_PULSE_Z, m_nCountPulse_z);
DDX_Check(pDX, IDC_CHECK_W, m_bEnableDemo_w);
DDX_Check(pDX, IDC_CHECK_X, m_bEnableDemo_x);
DDX_Check(pDX, IDC_CHECK_Y, m_bEnableDemo_y);
DDX_Check(pDX, IDC_CHECK_Z, m_bEnableDemo_z);
DDX_Check(pDX, IDC_CHECK_ACC_MODE_W, m_bEnableSymmetry_Acc_w);
DDX_Check(pDX, IDC_CHECK_ACC_MODE_X, m_bEnableSymmetry_Acc_x);
DDX_Check(pDX, IDC_CHECK_ACC_MODE_Y, m_bEnableSymmetry_Acc_y);
DDX_Check(pDX, IDC_CHECK_ACC_MODE_Z, m_bEnableSymmetry_Acc_z);
DDX_Check(pDX, IDC_CHECK_MOVE_TYPE, m_bEnableCurve_Move);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDemo_moveDlg, CDialog)
//{{AFX_MSG_MAP(CDemo_moveDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BTN_SETTING, OnBtnSetting)
ON_BN_CLICKED(IDC_RADIO_ALTERNATION, OnRadioAlternation)
ON_BN_CLICKED(IDC_RADIO_UNCHANGE, OnRadioUnchange)
ON_BN_CLICKED(IDC_CHECK_W, OnCheckEnableDemoW)
ON_BN_CLICKED(IDC_CHECK_X, OnCheckEnableDemoX)
ON_BN_CLICKED(IDC_CHECK_Y, OnCheckEnableDemoY)
ON_BN_CLICKED(IDC_CHECK_Z, OnCheckEnableDemoZ)
ON_BN_CLICKED(IDC_CHECK_ACC_MODE_W, OnCheckAccModeW)
ON_BN_CLICKED(IDC_CHECK_ACC_MODE_X, OnCheckAccModeX)
ON_BN_CLICKED(IDC_CHECK_ACC_MODE_Y, OnCheckAccModeY)
ON_BN_CLICKED(IDC_CHECK_ACC_MODE_Z, OnCheckAccModeZ)
ON_BN_CLICKED(IDC_CHECK_MOVE_TYPE, OnCheckMoveType)
ON_EN_SETFOCUS(IDC_EDIT_COUNT_PULSE_W, OnSetfocusEditCountPulseW)
ON_EN_SETFOCUS(IDC_EDIT_COUNT_PULSE_X, OnSetfocusEditCountPulseX)
ON_EN_SETFOCUS(IDC_EDIT_COUNT_PULSE_Y, OnSetfocusEditCountPulseY)
ON_EN_SETFOCUS(IDC_EDIT_COUNT_PULSE_Z, OnSetfocusEditCountPulseZ)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BTN_CONTINUE, OnBtnContinue)
ON_EN_CHANGE(IDC_EDIT_COUNT_PULSE_X, OnChangeEditCountPulseX)
ON_WM_MOUSEMOVE()
ON_BN_CLICKED(IDC_BUTTON_ONSTOP, OnButtonOnstop)
ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnButtonClear)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDemo_moveDlg message handlers
BOOL CDemo_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
//if(m_bEqualityVelocity)
((CButton*)GetDlgItem(IDC_RADIO_UNCHANGE))->SetCheck(TRUE);
CEdit* pEdit=NULL;
RECT rc;
m_pToolTip=new CToolTipCtrl;
m_pToolTip->Create(this);
for(int i=IDC_EDIT_COUNT_PULSE_X,j=0; i<IDC_EDIT_COUNT_PULSE_W+1;i++,j++){
pEdit=(CEdit*)GetDlgItem(i);
pEdit->GetClientRect(&rc);
m_pToolTip->AddTool(pEdit,"输入范围:-268435455--- +268435455",&rc,i);
}
m_pToolTip->SetDelayTime(500);
m_pToolTip->Activate(TRUE);
C850Para dlgSetPara(m_bEqualityVelocity,m_bEnableCurve_Move,this);
m_nRatio_x=dlgSetPara.m_nRatio_x;
m_nRatio_y=dlgSetPara.m_nRatio_y;
m_nRatio_z=dlgSetPara.m_nRatio_z;
m_nRatio_w=dlgSetPara.m_nRatio_w;
m_nStartV_x=dlgSetPara.GetStartV_x();
m_nStartV_y=dlgSetPara.GetStartV_y();
m_nStartV_z=dlgSetPara.GetStartV_z();
m_nStartV_w=dlgSetPara.GetStartV_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_x=dlgSetPara.m_nAccVelocity_x;
m_nVelocityAcc_y=dlgSetPara.m_nAccVelocity_y;
m_nVelocityAcc_z=dlgSetPara.m_nAccVelocity_z;
m_nVelocityAcc_w=dlgSetPara.m_nAccVelocity_w;
m_nVelocityDec_x=dlgSetPara.m_nDecVelocity_x;
m_nVelocityDec_y=dlgSetPara.m_nDecVelocity_y;
m_nVelocityDec_z=dlgSetPara.m_nDecVelocity_z;
m_nVelocityDec_w=dlgSetPara.m_nDecVelocity_w;
m_fAccTime_x =dlgSetPara.m_fAccTime_x;
m_fAccTime_y =dlgSetPara.m_fAccTime_y;
m_fAccTime_z =dlgSetPara.m_fAccTime_z;
m_fAccTime_w =dlgSetPara.m_fAccTime_w;
Init850Card();
SetTimer(1,100,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CDemo_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_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_moveDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CDemo_moveDlg::OnBtnSetting()
{
// TODO: Add your control notification handler code here
C850Para dlgSetPara(m_bEqualityVelocity,m_bEnableCurve_Move,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;
if(dlgSetPara.DoModal()==IDOK){
m_nRatio_x=dlgSetPara.m_nRatio_x;
m_nRatio_y=dlgSetPara.m_nRatio_y;
m_nRatio_z=dlgSetPara.m_nRatio_z;
m_nRatio_w=dlgSetPara.m_nRatio_w;
m_nStartV_x=dlgSetPara.GetStartV_x();
m_nStartV_y=dlgSetPara.GetStartV_y();
m_nStartV_z=dlgSetPara.GetStartV_z();
m_nStartV_w=dlgSetPara.GetStartV_w();
m_nDriveSpeed_x=dlgSetPara.m_nDriveSpeed_x;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -