📄 demo_movedlg.cpp
字号:
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;
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_moveDlg::OnRadioAlternation()
{
// TODO: Add your control notification handler code here
m_bEqualityVelocity=FALSE;
EnableCheckWnd(m_bEqualityVelocity);
}
void CDemo_moveDlg::OnRadioUnchange()
{
// TODO: Add your control notification handler code here
m_bEqualityVelocity=TRUE;
EnableCheckWnd(m_bEqualityVelocity);
}
void CDemo_moveDlg::OnCheckEnableDemoW()
{
// TODO: Add your control notification handler code here
m_bEnableDemo_w=!m_bEnableDemo_w;
CEdit* pEdit=NULL;
pEdit=(CEdit*)GetDlgItem(IDC_EDIT_COUNT_PULSE_W);
pEdit->EnableWindow(m_bEnableDemo_w);
if(m_bEnableDemo_w){
OnSetfocusEditCountPulseW();
}
else
sudden_stop(cardno,4);
}
void CDemo_moveDlg::OnCheckEnableDemoX()
{
// TODO: Add your control notification handler code here
m_bEnableDemo_x=!m_bEnableDemo_x;
CEdit* pEdit=NULL;
pEdit=(CEdit*)GetDlgItem(IDC_EDIT_COUNT_PULSE_X);
pEdit->EnableWindow(m_bEnableDemo_x);
if(m_bEnableDemo_x){
OnSetfocusEditCountPulseX();
}
else
sudden_stop(cardno,1);
}
void CDemo_moveDlg::OnCheckEnableDemoY()
{
// TODO: Add your control notification handler code here
m_bEnableDemo_y=!m_bEnableDemo_y;
CEdit* pEdit=NULL;
pEdit=(CEdit*)GetDlgItem(IDC_EDIT_COUNT_PULSE_Y);
pEdit->EnableWindow(m_bEnableDemo_y);
if(m_bEnableDemo_y){
OnSetfocusEditCountPulseY();
}
else
sudden_stop(cardno,2);
}
void CDemo_moveDlg::OnCheckEnableDemoZ()
{
// TODO: Add your control notification handler code here
m_bEnableDemo_z=!m_bEnableDemo_z;
CEdit* pEdit=NULL;
pEdit=(CEdit*)GetDlgItem(IDC_EDIT_COUNT_PULSE_Z);
pEdit->EnableWindow(m_bEnableDemo_z);
if(m_bEnableDemo_z){
OnSetfocusEditCountPulseZ();
}
else
sudden_stop(cardno,3);
}
void CDemo_moveDlg::OnCheckAccModeW()
{
// TODO: Add your control notification handler code here
m_bEnableSymmetry_Acc_w=!m_bEnableSymmetry_Acc_w;
}
void CDemo_moveDlg::OnCheckAccModeX()
{
// TODO: Add your control notification handler code here
m_bEnableSymmetry_Acc_x=!m_bEnableSymmetry_Acc_x;
}
void CDemo_moveDlg::OnCheckAccModeY()
{
// TODO: Add your control notification handler code here
m_bEnableSymmetry_Acc_y=!m_bEnableSymmetry_Acc_y;
}
void CDemo_moveDlg::OnCheckAccModeZ()
{
// TODO: Add your control notification handler code here
m_bEnableSymmetry_Acc_z=!m_bEnableSymmetry_Acc_z;
}
void CDemo_moveDlg::OnCheckMoveType()
{
// TODO: Add your control notification handler code here
m_bEnableCurve_Move=!m_bEnableCurve_Move;
}
void CDemo_moveDlg::OnOK()
{
// TODO: Add extra validation here
if(!m_bEnableDemo_x&&!m_bEnableDemo_y&&!m_bEnableDemo_z&&!m_bEnableDemo_w)
{
MessageBox("请选择驱动轴!");
return;
}
UpdateData();
set_range(0,1,8000000/m_nRatio_x);
set_range(0,2,8000000/m_nRatio_y);
set_range(0,3,8000000/m_nRatio_z);
set_range(0,4,8000000/m_nRatio_w);
//--------------------速度设置------------------------
if(m_bEqualityVelocity){ //匀速运动
set_startv(0,1,m_nDriveSpeed_x/m_nRatio_x);
set_startv(0,2,m_nDriveSpeed_y/m_nRatio_y);
set_startv(0,3,m_nDriveSpeed_z/m_nRatio_z);
set_startv(0,4,m_nDriveSpeed_w/m_nRatio_w);
set_speed(0,1,m_nDriveSpeed_x/m_nRatio_x);
set_speed(0,2,m_nDriveSpeed_y/m_nRatio_y);
set_speed(0,3,m_nDriveSpeed_z/m_nRatio_z);
set_speed(0,4,m_nDriveSpeed_w/m_nRatio_w);
}
else{ //加/减速运动
set_startv(0,1,m_nStartV_x/m_nRatio_x);
set_startv(0,2,m_nStartV_y/m_nRatio_y);
set_startv(0,3,m_nStartV_z/m_nRatio_z);
set_startv(0,4,m_nStartV_w/m_nRatio_w);
set_speed(0,1,m_nDriveSpeed_x/m_nRatio_x);
set_speed(0,2,m_nDriveSpeed_y/m_nRatio_y);
set_speed(0,3,m_nDriveSpeed_z/m_nRatio_z);
set_speed(0,4,m_nDriveSpeed_w/m_nRatio_w);
}
if(!m_bEqualityVelocity)SetAddSpeed();
if(m_bEnableDemo_x) pmove(0,1,m_nCountPulse_x);
if(m_bEnableDemo_y) pmove(0,2,m_nCountPulse_y);
if(m_bEnableDemo_z) pmove(0,3,m_nCountPulse_z);
if(m_bEnableDemo_w) pmove(0,4,m_nCountPulse_w);
//CDialog::OnOK();
}
void CDemo_moveDlg::OnSetfocusEditCountPulseW()
{
// TODO: Add your control notification handler code here
CEdit* pEdit=NULL;
pEdit=(CEdit*)GetDlgItem(IDC_EDIT_COUNT_PULSE_W);
pEdit->SetSel(0,-1);
pEdit->SetFocus();
}
void CDemo_moveDlg::OnSetfocusEditCountPulseX()
{
// TODO: Add your control notification handler code here
CEdit* pEdit=NULL;
pEdit=(CEdit*)GetDlgItem(IDC_EDIT_COUNT_PULSE_X);
pEdit->SetSel(0,-1);
pEdit->SetFocus();
}
void CDemo_moveDlg::OnSetfocusEditCountPulseY()
{
// TODO: Add your control notification handler code here
CEdit* pEdit=NULL;
pEdit=(CEdit*)GetDlgItem(IDC_EDIT_COUNT_PULSE_Y);
pEdit->SetSel(0,-1);
pEdit->SetFocus();
}
void CDemo_moveDlg::OnSetfocusEditCountPulseZ()
{
// TODO: Add your control notification handler code here
CEdit* pEdit=NULL;
pEdit=(CEdit*)GetDlgItem(IDC_EDIT_COUNT_PULSE_Z);
pEdit->SetSel(0,-1);
pEdit->SetFocus();
}
void CDemo_moveDlg::EnableCheckWnd(BOOL bEnable)
{
CWnd* pWnd=NULL;
pWnd=GetDlgItem(IDC_STATIC_MOVE_TYPE);
pWnd->EnableWindow(!bEnable);
pWnd=GetDlgItem(IDC_CHECK_MOVE_TYPE);
pWnd->EnableWindow(!bEnable);
pWnd=GetDlgItem(IDC_CHECK_ACC_MODE_X);
pWnd->EnableWindow(!bEnable);
pWnd=GetDlgItem(IDC_CHECK_ACC_MODE_Y);
pWnd->EnableWindow(!bEnable);
pWnd=GetDlgItem(IDC_CHECK_ACC_MODE_Z);
pWnd->EnableWindow(!bEnable);
pWnd=GetDlgItem(IDC_CHECK_ACC_MODE_W);
pWnd->EnableWindow(!bEnable);
}
void CDemo_moveDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
long pos_x=0,pos_y=0,pos_z=0,pos_w=0;
get_command_pos(0,1,&pos_x);
m_nLogicPos_x=pos_x;
get_speed(0,1,&m_nCurrentSpeed_x);
get_command_pos(0,2,&pos_y);
m_nLogicPos_y=pos_y;
get_speed(0,2,&m_nCurrentSpeed_y);
get_command_pos(0,3,&pos_z);
m_nLogicPos_z=pos_z;
get_speed(0,3,&m_nCurrentSpeed_z);
get_command_pos(0,4,&pos_w);
m_nLogicPos_w=pos_w;
get_speed(0,4,&m_nCurrentSpeed_w);
char szValue[11];
::wsprintf(szValue,"%d",m_nLogicPos_x);
SetDlgItemText(IDC_EDIT_POS_X,szValue);
//---------------从卡里获取的速度值再乘上倍率,等于实际的速度值.-----------------------------
::wsprintf(szValue,"%d",m_nCurrentSpeed_x*m_nRatio_x);
SetDlgItemText(IDC_EDIT_SPEED_X,szValue);
::wsprintf(szValue,"%d",m_nLogicPos_y);
SetDlgItemText(IDC_EDIT_POS_Y,szValue);
//---------------从卡里获取的速度值再乘上倍率,等于实际的速度值.-----------------------------
::wsprintf(szValue,"%d",m_nCurrentSpeed_y*m_nRatio_y);
SetDlgItemText(IDC_EDIT_SPEED_Y,szValue);
::wsprintf(szValue,"%d",m_nLogicPos_z);
SetDlgItemText(IDC_EDIT_POS_Z,szValue);
//---------------从卡里获取的速度值再乘上倍率,等于实际的速度值.-----------------------------
::wsprintf(szValue,"%d",m_nCurrentSpeed_z*m_nRatio_z);
SetDlgItemText(IDC_EDIT_SPEED_Z,szValue);
::wsprintf(szValue,"%d",m_nLogicPos_w);
SetDlgItemText(IDC_EDIT_POS_W,szValue);
//---------------从卡里获取的速度值再乘上倍率,等于实际的速度值.-----------------------------
::wsprintf(szValue,"%d",m_nCurrentSpeed_w*m_nRatio_w);
SetDlgItemText(IDC_EDIT_SPEED_W,szValue);
//UpdateData(FALSE);
CButton* pButton=NULL;
int nstate_x=-1,nstate_y=-1,nstate_z=-1,nstate_w=-1;
get_status(0,1,&nstate_x);
get_status(0,2,&nstate_y);
get_status(0,3,&nstate_z);
get_status(0,4,&nstate_w);
if(nstate_x==0&&nstate_y==0&&nstate_z==0&&nstate_w==0)
{
(CButton*)GetDlgItem(IDOK)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_BTN_SETTING)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDCANCEL)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_BTN_CONTINUE)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_RADIO_UNCHANGE)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_RADIO_ALTERNATION)->EnableWindow(TRUE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -