📄 demo_inp_movedlg.cpp
字号:
pWnd->ShowWindow(FALSE);
pWnd=GetDlgItem(IDC_STATIC_END_POS);
pWnd->ShowWindow(TRUE);
((CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_TWO))->SetCheck(TRUE);
((CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_THREE))->SetCheck(FALSE);
((CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_FOUR))->SetCheck(FALSE);
((CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_TWO))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_THREE))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_FOUR))->EnableWindow(FALSE);
OnRadioInpAxisTwo();
}
void CDemo_Inp_MoveDlg::OnRadioInpLine()
{
// TODO: Add your control notification handler code here
m_bIsInpLine=TRUE;
CButton* pButton=NULL;
int nState=-1;
pButton=(CButton*) GetDlgItem(IDC_CHECK_DISABLE_EQUALITY);
nState=pButton->GetState();
if((nState & 0x0003)==1){
pButton=(CButton*) GetDlgItem(IDC_CHECK_MOVE_TYPE_S);
pButton->EnableWindow(TRUE);
}
CWnd* pWnd=NULL;
pWnd=GetDlgItem(IDC_STATIC_PULSE_COUNT);
pWnd->ShowWindow(TRUE);
pWnd=GetDlgItem(IDC_STATIC_END_POS);
pWnd->ShowWindow(FALSE);
((CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_TWO))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_THREE))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_FOUR))->EnableWindow(TRUE);
}
void CDemo_Inp_MoveDlg::Init850Card()
{
int count;
const int nCoefficient=8000000;
cardno=0;
count=adt850_initial();
if(count<1) {
MessageBox("未安装850卡!");
// CDialog::OnCancel();
}
long nValue;
set_command_pos(cardno,1,0);
set_command_pos(cardno,2,0);
set_command_pos(cardno,3,0);
set_command_pos(cardno,4,0);
//------------------倍率=8000000/R-----------------------------------------
//函数set_range()中的最后一个参数 由R=8000000/倍率来确定.
//------------------设置倍率参数-------------------------------------------
nValue = nCoefficient/m_nRatio_x ;
set_range(cardno,1,nValue);
nValue = nCoefficient/m_nRatio_y ;
set_range(cardno,2,nValue);
nValue = nCoefficient/m_nRatio_z ;
set_range(cardno,3,nValue);
nValue = nCoefficient/m_nRatio_w ;
set_range(cardno,4,nValue);
}
void CDemo_Inp_MoveDlg::OnCheckDemoW()
{
// TODO: Add your control notification handler code here
int nstate=-1;
CButton* pButton=NULL;
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_W);
nstate=pButton->GetCheck();
m_bChkDemo_w=nstate==1?1:0;
GetDlgItem(IDC_EDIT_PULSE_COUNT_W)->EnableWindow(m_bChkDemo_w);
}
void CDemo_Inp_MoveDlg::OnCheckDemoX()
{
// TODO: Add your control notification handler code here
int nstate=-1;
CButton* pButton=NULL;
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_X);
nstate=pButton->GetCheck();
m_bChkDemo_x=(nstate==1?1:0);
GetDlgItem(IDC_EDIT_PULSE_COUNT_X)->EnableWindow(m_bChkDemo_x);
if(m_bIsTwoAxisInp){
if(m_bChkDemo_x)
{
m_bChkDemo_y=m_bChkDemo_x;
OnCheckDemoY();
GetDlgItem(IDC_CHECK_DEMO_Z)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT_PULSE_COUNT_Z)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT_PULSE_COUNT_W)->EnableWindow(FALSE);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_W);
pButton->EnableWindow(TRUE);
pButton->SetCheck(0);
m_bChkDemo_w=FALSE;
pButton->EnableWindow(FALSE);
}
else OnRadioInpAxisTwo();
}
}
void CDemo_Inp_MoveDlg::OnCheckDemoY()
{
// TODO: Add your control notification handler code here
int nstate=-1;
CButton* pButton=NULL;
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_Y);
nstate=pButton->GetCheck();
m_bChkDemo_y=nstate==1?1:0;
GetDlgItem(IDC_EDIT_PULSE_COUNT_Y)->EnableWindow(m_bChkDemo_y);
}
void CDemo_Inp_MoveDlg::OnCheckDemoZ()
{
// TODO: Add your control notification handler code here
int nstate=-1;
CButton* pButton=NULL;
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_Z);
nstate=pButton->GetCheck();
m_bChkDemo_z=nstate==1?1:0;
GetDlgItem(IDC_EDIT_PULSE_COUNT_Z)->EnableWindow(m_bChkDemo_z);
if(m_bIsTwoAxisInp){
if(m_bChkDemo_z){
m_bChkDemo_w=m_bChkDemo_z;
OnCheckDemoW();
GetDlgItem(IDC_CHECK_DEMO_X)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT_PULSE_COUNT_X)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT_PULSE_COUNT_Y)->EnableWindow(FALSE);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_Y);
pButton->EnableWindow(TRUE);
pButton->SetCheck(0);
m_bChkDemo_y=FALSE;
pButton->EnableWindow(FALSE);
}
else OnRadioInpAxisTwo();
}
}
void CDemo_Inp_MoveDlg::OnRadioInpAxisFour()
{
int nState=-1;
m_bIsFourAxisInp=TRUE;
m_bIsTwoAxisInp=FALSE;
m_bIsThreeAxisInp=FALSE;
CButton* pButton=NULL;
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_X);
pButton->SetCheck(1);
pButton->EnableWindow(FALSE);
m_bChkDemo_x=true;
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_X)->EnableWindow(m_bChkDemo_x);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_Y);
pButton->SetCheck(1);
pButton->EnableWindow(FALSE);
m_bChkDemo_y=true;
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_Y)->EnableWindow(m_bChkDemo_y);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_Z);
pButton->SetCheck(1);
pButton->EnableWindow(FALSE);
m_bChkDemo_z=true;
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_Z)->EnableWindow(m_bChkDemo_z);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_W);
pButton->SetCheck(1);
pButton->EnableWindow(FALSE);
m_bChkDemo_w=true;
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_W)->EnableWindow(m_bChkDemo_w);
}
void CDemo_Inp_MoveDlg::OnRadioInpAxisThree()
{
// TODO: Add your control notification handler code here
int nState=-1;
m_bIsTwoAxisInp=FALSE;
m_bIsThreeAxisInp=TRUE;
m_bIsFourAxisInp=FALSE;
CButton* pButton=NULL;
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_X);
pButton->SetCheck(1);
pButton->EnableWindow(FALSE);
m_bChkDemo_x=true;
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_X)->EnableWindow(m_bChkDemo_x);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_Y);
pButton->SetCheck(1);
pButton->EnableWindow(FALSE);
m_bChkDemo_y=true;
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_Y)->EnableWindow(m_bChkDemo_y);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_Z);
pButton->SetCheck(1);
pButton->EnableWindow(FALSE);
m_bChkDemo_z=true;
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_Z)->EnableWindow(m_bChkDemo_z);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_W);
pButton->EnableWindow(TRUE);
pButton->SetCheck (0);
pButton->EnableWindow(FALSE);
m_bChkDemo_w=false;
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_W)->EnableWindow(m_bChkDemo_w);
}
void CDemo_Inp_MoveDlg::OnRadioInpAxisTwo()
{
// TODO: Add your control notification handler code here
m_bIsTwoAxisInp=TRUE;
m_bIsThreeAxisInp=FALSE;
m_bIsFourAxisInp=FALSE;
CButton* pButton=NULL;
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_X);
pButton->EnableWindow(TRUE);
pButton->SetCheck(0);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_Y);
pButton->SetCheck(1);
pButton->EnableWindow(FALSE);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_Z);
pButton->EnableWindow(TRUE);
pButton->SetCheck(0);
pButton=(CButton*)GetDlgItem(IDC_CHECK_DEMO_W);
pButton->SetCheck(1);
pButton->EnableWindow(FALSE);
m_bChkDemo_x=FALSE;
m_bChkDemo_y=FALSE;
m_bChkDemo_z=FALSE;
m_bChkDemo_w=FALSE;
GetDlgItem(IDC_EDIT_PULSE_COUNT_X)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT_PULSE_COUNT_Y)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT_PULSE_COUNT_Z)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT_PULSE_COUNT_W)->EnableWindow(FALSE);
}
void CDemo_Inp_MoveDlg::OnCancel()
{
// TODO: Add extra cleanup here
if(m_pToolTip) delete m_pToolTip;
KillTimer(1);
sudden_stop(cardno,1);
sudden_stop(cardno,2);
sudden_stop(cardno,3);
sudden_stop(cardno,4);
CDialog::OnCancel();
}
BOOL CDemo_Inp_MoveDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(m_pToolTip){
m_pToolTip->RelayEvent(pMsg);
}
return CDialog::PreTranslateMessage(pMsg);
}
void CDemo_Inp_MoveDlg::OnCheckMoveTypeS()
{
// TODO: Add your control notification handler code here
m_bEnable_S_Move=!m_bEnable_S_Move;
}
void CDemo_Inp_MoveDlg::OnCheckSymmetryVelocityW()
{
// TODO: Add your control notification handler code here
m_bEnableSymmetry_Acc_w=!m_bEnableSymmetry_Acc_w;
}
void CDemo_Inp_MoveDlg::OnCheckSymmetryVelocityX()
{
// TODO: Add your control notification handler code here
m_bEnableSymmetry_Acc_x=!m_bEnableSymmetry_Acc_x;
}
void CDemo_Inp_MoveDlg::OnCheckSymmetryVelocityY()
{
// TODO: Add your control notification handler code here
m_bEnableSymmetry_Acc_y=!m_bEnableSymmetry_Acc_y;
}
void CDemo_Inp_MoveDlg::OnCheckSymmetryVelocityZ()
{
// TODO: Add your control notification handler code here
m_bEnableSymmetry_Acc_z=!m_bEnableSymmetry_Acc_z;
}
void CDemo_Inp_MoveDlg::OnBtnInpSingle()
{
// TODO: Add your control notification handler code here
if(!m_bChkDemo_x&&!m_bChkDemo_z&&m_bIsTwoAxisInp)
{
MessageBox("请选择插补轴!");
return;
}
UpdateData();
CButton* pButton=NULL;
pButton=(CButton*)GetDlgItem(IDC_BTN_INP_SINGLE);
pButton->EnableWindow(FALSE);
pButton=(CButton*)GetDlgItem(IDC_BTN_INP_STOP);
pButton->EnableWindow(TRUE);
m_bIsContinueInp=FALSE; //单个插补
//范围设定更新
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);
//三轴插补和四轴插补时Z轴的倍率设置成与X轴一样
if(!m_bIsTwoAxisInp)set_range(0,3,8000000/m_nRatio_x);
SetSpeed();
if(m_bDisableEquality_V)SetAddSpeed();
DemoInpMove();
}
void CDemo_Inp_MoveDlg::OnTimer(UINT nIDEvent)
{
int state=-1;
ShowInfo();//显示速度和逻辑位置
if(m_bIsTwoAxisInp){ //两轴插补
if(m_bChkDemo_x){
get_inp_status(cardno,1,&state);
// int s;
// get_stopdata(0,1,&s);
// if(s!=0)MessageBox("error");
}
if(m_bChkDemo_z){
get_inp_status(cardno,2,&state);
// int s;
// get_stopdata(0,3,&s);
// if(s!=0)MessageBox("error!");
}
}
if(m_bIsThreeAxisInp){ //三轴插补
get_inp_status(cardno,1,&state);
}
if(m_bIsFourAxisInp){ // 四轴插补
get_inp_status(cardno,1,&state);
}
if(state==1) //插补进行中
{
(CButton*)GetDlgItem(IDC_BTN_DETAIL_SETTING)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_BTN_INP_CONTINUE)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_BTN_INP_SINGLE)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_RADIO_INP_LINE)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_RADIO_INP_ARC)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_CHECK_DISABLE_EQUALITY)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_CHECK_DEMO_X)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_CHECK_DEMO_Y)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_CHECK_DEMO_Z)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_CHECK_DEMO_W)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_TWO)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_THREE)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_FOUR)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_X)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_Y)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_Z)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_EDIT_PULSE_COUNT_W)->EnableWindow(FALSE);
EnableCheckWnd(FALSE);
}
if(state==0) //插补完成
{
(CButton*)GetDlgItem(IDC_BTN_INP_SINGLE)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_BTN_DETAIL_SETTING)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDCANCEL)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_BTN_INP_CONTINUE)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_RADIO_INP_LINE)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_RADIO_INP_ARC)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_CHECK_DISABLE_EQUALITY)->EnableWindow(TRUE);
if(m_bIsInpLine)
{
(CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_TWO)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_THREE)->EnableWindow(TRUE);
(CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_FOUR)->EnableWindow(TRUE);
}
else
{
(CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_TWO)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_THREE)->EnableWindow(FALSE);
(CButton*)GetDlgItem(IDC_RADIO_INP_AXIS_FOUR)->EnableWindow(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -