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

📄 850para.cpp

📁 850运动控制卡的详细开发资料
💻 CPP
字号:
// 850Para.cpp : implementation file
//

#include "stdafx.h"
#include "demo_move.h"
#include "850Para.h"

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

/////////////////////////////////////////////////////////////////////////////
// C850Para dialog


C850Para::C850Para(CWnd* pParent /*=NULL*/)
	: CDialog(C850Para::IDD, pParent)
{
	//{{AFX_DATA_INIT(C850Para)
	m_nStartV_w = 1000;
	m_nStartV_x = 1000;
	m_nStartV_y = 1000;
	m_nStartV_z = 1000;
	m_nDriveSpeed_w = 1000;
	m_nDriveSpeed_x = 1000;
	m_nDriveSpeed_y = 1000;
	m_nDriveSpeed_z = 1000;
	m_nRatio_w = 10;
	m_nRatio_x = 10;
	m_nRatio_y = 10;
	m_nRatio_z = 10;
	m_nAccVelocity_w = 8;
	m_nAccVelocity_x = 8;
	m_nAccVelocity_y = 8;
	m_nAccVelocity_z = 8;

	m_nDecVelocity_w=8;
	m_nDecVelocity_x=8;
	m_nDecVelocity_y=8;
	m_nDecVelocity_z=8;

	m_fAccTime_w=0.1f;
	m_fAccTime_x=0.1f;
	m_fAccTime_y=0.1f;
	m_fAccTime_z=0.1f;

	//}}AFX_DATA_INIT

	m_bEnable=FALSE;
}


C850Para::C850Para(BOOL bEnable,BOOL bEnableCurve,CWnd* pParent /*=NULL*/)
	: CDialog(C850Para::IDD, pParent)
{
	//{{AFX_DATA_INIT(C850Para)
	m_nStartV_w = 400;
	m_nStartV_x = 400;
	m_nStartV_y = 400;
	m_nStartV_z = 400;
	m_nDriveSpeed_w = 4000;
	m_nDriveSpeed_x = 4000;
	m_nDriveSpeed_y = 4000;
	m_nDriveSpeed_z = 4000;
	m_nRatio_w = 5;
	m_nRatio_x = 5;
	m_nRatio_y = 5;
	m_nRatio_z = 5;
	m_nAccVelocity_w = 64;
	m_nAccVelocity_x = 64;
	m_nAccVelocity_y = 64;
	m_nAccVelocity_z = 64;

	m_nDecVelocity_w=64;
	m_nDecVelocity_x=64;
	m_nDecVelocity_y=64;
	m_nDecVelocity_z=64;

	m_fAccTime_w=0.45f;
	m_fAccTime_x=0.45f;
	m_fAccTime_y=0.45f;
	m_fAccTime_z=0.45f;


	//}}AFX_DATA_INIT

	m_bEnable=!bEnable;
	m_bEnableCurve=bEnableCurve;
}

void C850Para::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(C850Para)
	DDX_Text(pDX, IDC_EDIT_SETTING_START_V_W, m_nStartV_w);
	DDX_Text(pDX, IDC_EDIT_SETTING_START_V_X, m_nStartV_x);
	DDX_Text(pDX, IDC_EDIT_SETTING_START_V_Y, m_nStartV_y);
	DDX_Text(pDX, IDC_EDIT_SETTING_START_V_Z, m_nStartV_z);
	DDX_Text(pDX, IDC_EDIT_SETTING_DRIVE_SPEED_W, m_nDriveSpeed_w);
	DDX_Text(pDX, IDC_EDIT_SETTING_DRIVE_SPEED_X, m_nDriveSpeed_x);
	DDX_Text(pDX, IDC_EDIT_SETTING_DRIVE_SPEED_Y, m_nDriveSpeed_y);
	DDX_Text(pDX, IDC_EDIT_SETTING_DRIVE_SPEED_Z, m_nDriveSpeed_z);
	DDX_Text(pDX, IDC_EDIT_SETTING_RATIO_W, m_nRatio_w);
	DDX_Text(pDX, IDC_EDIT_SETTING_RATIO_X, m_nRatio_x);
	DDX_Text(pDX, IDC_EDIT_SETTING_RATIO_Y, m_nRatio_y);
	DDX_Text(pDX, IDC_EDIT_SETTING_RATIO_Z, m_nRatio_z);
	DDX_Text(pDX, IDC_EDIT_SETTING_ACC_V_W, m_nAccVelocity_w);
	DDX_Text(pDX, IDC_EDIT_SETTING_ACC_V_X, m_nAccVelocity_x);
	DDX_Text(pDX, IDC_EDIT_SETTING_ACC_V_Y, m_nAccVelocity_y);
	DDX_Text(pDX, IDC_EDIT_SETTING_ACC_V_Z, m_nAccVelocity_z);

	DDX_Text(pDX, IDC_EDIT_SETTING_DEC_V_W, m_nDecVelocity_w);
	DDX_Text(pDX, IDC_EDIT_SETTING_DEC_V_X, m_nDecVelocity_x);
	DDX_Text(pDX, IDC_EDIT_SETTING_DEC_V_Y, m_nDecVelocity_y);
	DDX_Text(pDX, IDC_EDIT_SETTING_DEC_V_Z, m_nDecVelocity_z);

	DDX_Text(pDX, IDC_EDIT_ACC_TIME_W, m_fAccTime_w);
	DDX_Text(pDX, IDC_EDIT_ACC_TIME_X, m_fAccTime_x);
	DDX_Text(pDX, IDC_EDIT_ACC_TIME_Y, m_fAccTime_y);
	DDX_Text(pDX, IDC_EDIT_ACC_TIME_Z, m_fAccTime_z);


	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(C850Para, CDialog)
	//{{AFX_MSG_MAP(C850Para)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// C850Para message handlers

long C850Para::GetStartV_x() const
{
	return m_nStartV_x;

}

long C850Para::GetStartV_y() const
{
	return m_nStartV_y;

}

long C850Para::GetStartV_z() const
{
	return m_nStartV_z;

}

long C850Para::GetStartV_w() const
{
	return m_nStartV_w;

}

void C850Para::OnOK() 
{
	// TODO: Add extra validation here

	if(m_bEnable) CalAccTime();

	UpdateData();
	if(m_pToolTip) delete m_pToolTip;
	
	CDialog::OnOK();
}

BOOL C850Para::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here

	EnableAccVelocityWnd(m_bEnable);
	m_pToolTip=new CToolTipCtrl;

	m_pToolTip->Create(this);
	RECT rc;
	CEdit* pEdit=NULL;

	for(int i=IDC_EDIT_SETTING_START_V_X;i<IDC_EDIT_SETTING_DEC_V_W+1;i++){
		pEdit=(CEdit*)GetDlgItem(i);
		pEdit->GetClientRect(&rc);
	 if((i<=IDC_EDIT_SETTING_RATIO_W) && (i>=IDC_EDIT_SETTING_RATIO_X))
			m_pToolTip->AddTool(pEdit,"值的输入范围是:1----500",&rc,i);
	 else
			m_pToolTip->AddTool(pEdit,"值的输入范围是:1----8000×倍率",&rc,i);

	}
	m_pToolTip->SetDelayTime(500);
	m_pToolTip->Activate(TRUE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void C850Para::EnableAccVelocityWnd(BOOL bEnable)
{
	CEdit* pEdit=NULL;

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_SETTING_ACC_V_W);
	pEdit->EnableWindow(bEnable);

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_SETTING_ACC_V_X);
	pEdit->EnableWindow(bEnable);

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_SETTING_ACC_V_Y);
	pEdit->EnableWindow(bEnable);

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_SETTING_ACC_V_Z);
	pEdit->EnableWindow(bEnable);


	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_SETTING_DEC_V_W);
	pEdit->EnableWindow(bEnable);

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_SETTING_DEC_V_X);
	pEdit->EnableWindow(bEnable);

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_SETTING_DEC_V_Y);
	pEdit->EnableWindow(bEnable);

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_SETTING_DEC_V_Z);
	pEdit->EnableWindow(bEnable);

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_ACC_TIME_X);
	pEdit->EnableWindow(m_bEnableCurve);

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_ACC_TIME_Y);
	pEdit->EnableWindow(m_bEnableCurve);

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_ACC_TIME_Z);
	pEdit->EnableWindow(m_bEnableCurve);

	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_ACC_TIME_W);
	pEdit->EnableWindow(m_bEnableCurve);


}

BOOL C850Para::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (NULL != m_pToolTip)            
      m_pToolTip->RelayEvent(pMsg);
	
	return CDialog::PreTranslateMessage(pMsg);
}

void C850Para::CalAccTime()
{
	m_fAccTime_w=float((m_nDriveSpeed_w-m_nStartV_w)/m_nAccVelocity_w);

	m_fAccTime_x=float((m_nDriveSpeed_x-m_nStartV_x)/m_nAccVelocity_x);

	m_fAccTime_y=float((m_nDriveSpeed_y-m_nStartV_y)/m_nAccVelocity_y);

	m_fAccTime_z=float((m_nDriveSpeed_z-m_nStartV_z)/m_nAccVelocity_z);

}

⌨️ 快捷键说明

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