📄 demodlg.cpp
字号:
int chan, err_code, iFL, iFH, iACC;
char temp[20];
UpdateData(true);
chan = m_sChannel_config.GetCurSel() + 1;
iFL = atoi(m_cFL);
iFH = atoi(m_cFH);
iACC = atoi(m_cACC);
err_code = set_speed(chan, iFL, iFH, iACC);
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::OnBUTTONstatus()
{
// TODO: Add your control notification handler code here
int chan, err_code;
char temp[20];
chan = m_cmb_chanop.GetCurSel() + 1;
err_code = status(chan);
if ((err_code == -2) || (err_code == -1))
{
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
}
else
{
sprintf(temp, "%X(HEX)",err_code);
m_editReturnSts.SetWindowText(_T(temp));
}
UpdateData(true);
}
void CDemoDlg::OnBUTTONstop()
{
// TODO: Add your control notification handler code here
int chan, err_code;
char temp[20];
chan = m_cmb_chanop.GetCurSel() + 1;
err_code = m_stop(chan);
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::OnBUTTONwaitrdy()
{
// TODO: Add your control notification handler code here
int chan, err_code;
char temp[20];
chan = m_cmb_chanop.GetCurSel() + 1;
err_code = waitrdy(chan);
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::OnBUTTONcheckbusy()
{
// TODO: Add your control notification handler code here
int err_code;
char temp[20];
err_code = chkbusy();
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::OnBUTTONslwdwn()
{
// TODO: Add your control notification handler code here
int chan, err_code;
char temp[20];
chan = m_cmb_chanop.GetCurSel() + 1;
err_code = slowdown(chan);
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::OnBUTTONsldnstop()
{
// TODO: Add your control notification handler code here
int chan, err_code;
char temp[20];
chan = m_cmb_chanop.GetCurSel() + 1;
err_code = sldn_stop(chan);
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::OnButtonOrg()
{
// TODO: Add your control notification handler code here
int chan, err_code;
int dir1,dir2,dir3,spd1,spd2,spd3;
char temp[20];
UpdateData(true);
chan = m_cmbChanMov.GetCurSel()+1;
dir1 = m_cmbDir1.GetCurSel();
dir2 = m_cmbDir2.GetCurSel();
dir3 = m_cmbDir3.GetCurSel();
spd1 = m_cmbSpd1.GetCurSel();
spd2 = m_cmbSpd2.GetCurSel();
spd3 = m_cmbSpd3.GetCurSel();
err_code = org(chan, dir1, spd1, dir2, spd2, dir3, spd3);
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::OnButtonCmove()
{
// TODO: Add your control notification handler code here
int chan, err_code;
int dir1,dir2,dir3,spd1,spd2,spd3;
char temp[20];
UpdateData(true);
chan = m_cmbChanMov.GetCurSel()+1;
dir1 = m_cmbDir1.GetCurSel();
dir2 = m_cmbDir2.GetCurSel();
dir3 = m_cmbDir3.GetCurSel();
spd1 = m_cmbSpd1.GetCurSel();
spd2 = m_cmbSpd2.GetCurSel();
spd3 = m_cmbSpd3.GetCurSel();
err_code = cmove(chan, dir1, spd1, dir2, spd2, dir3, spd3);
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::OnButtonPmove()
{
// TODO: Add your control notification handler code here
int chan, err_code;
int dir1,dir2,dir3,spd1,spd2,spd3,step1,step2,step3;
char temp[20];
UpdateData(true);
chan = m_cmbChanMov.GetCurSel()+1;
dir1 = m_cmbDir1.GetCurSel();
dir2 = m_cmbDir2.GetCurSel();
dir3 = m_cmbDir3.GetCurSel();
spd1 = m_cmbSpd1.GetCurSel();
spd2 = m_cmbSpd2.GetCurSel();
spd3 = m_cmbSpd3.GetCurSel();
step1 = atoi(m_cStep1);
step2 = atoi(m_cStep2);
step3 = atoi(m_cStep3);
err_code = pmove(chan, dir1, spd1,step1, dir2, spd2, step2, dir3, spd3, step3);
//err_code = line( chan, step1, step1 );
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::OnButtonInput()
{
// TODO: Add your control notification handler code here
int port, err_code;
char temp[20];
port = m_cmbIOPort.GetCurSel();
err_code = in_port(port);
if (err_code == -2)
{
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
}
else
{
sprintf(temp, "%X(HEX)",err_code);
m_editReturnSts.SetWindowText(_T(temp));
}
UpdateData(true);
}
void CDemoDlg::OnButtonOutput()
{
// TODO: Add your control notification handler code here
int port, err_code;
char temp[20];
UpdateData(true);
port = m_cmbIOPort.GetCurSel();
err_code = out_port(port, m_iIOvalue);
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
int cnt1, cnt2, cnt3;
int statu;
char temp[20];
//Get channel 1,2,3 current counter(R0) value
cnt1 = cnt2 = cnt3 = 0;
statu = Out_byte(0, 0x80);
cnt1 = In_byte(1) & 0xFF;
cnt1 = (In_byte(2) & 0xFF) * 256 + cnt1;
cnt1 = (In_byte(3) & 0x3) * 65536 + cnt1;
sprintf(temp, "%d",cnt1);
SetDlgItemText(IDC_CH1_COUNTER,temp);
statu = Out_byte(4, 0x80);
cnt2 = In_byte(5) & 0xFF;
cnt2 = (In_byte(6) & 0xFF) * 256 + cnt2;
cnt2 = (In_byte(7) & 0x3) * 65536 + cnt2;
sprintf(temp, "%d",cnt2);
SetDlgItemText(IDC_CH2_COUNTER,temp);
statu = Out_byte(8, 0x80);
cnt3 = In_byte(9) & 0xFF;
cnt3 = (In_byte(10) & 0xFF) * 256 + cnt3;
cnt3 = (In_byte(11) & 3) * 65536 + cnt3;
sprintf(temp, "%d",cnt3);
SetDlgItemText(IDC_CH3_COUNTER,temp);
UpdateData(true);
CDialog::OnTimer(nIDEvent);
}
void CDemoDlg::OnOK()
{
// TODO: Add extra validation here
KillTimer(Timer_ON);
CDialog::OnOK();
}
void CDemoDlg::OnButtonLine()
{
UpdateData(true);
int chan, err_code;
int linex, liney, linez;
char temp[20];
chan = m_cmbChanMov.GetCurSel()+1;
linex = atoi(m_cLine1);
liney = atoi(m_cLine2);
linez = atoi(m_cLine3);
if( chan == 7 )
err_code = line3D( chan, linex, liney ,linez);
else
err_code = line( chan, linex, liney );
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
void CDemoDlg::Line()
{
}
void CDemoDlg::OnButtonArc()
{
int chan, err_code;
int dir_arc, arc_x1, arc_y1, arc_x2, arc_y2;
char temp[20];
UpdateData(true);
arc_x1 = atoi( m_cArcX1 );
arc_y1 = atoi( m_cArcY1 );
arc_x2 = atoi( m_cArcX2 );
arc_y2 = atoi( m_cArcY2 );
chan = m_cmbChanMov.GetCurSel()+1;
dir_arc = m_cmbDirArc.GetCurSel();
err_code = arc( chan, dir_arc, arc_x1, arc_y1, arc_x2, arc_y2 );
sprintf(temp, "%d",err_code);
m_editReturnSts.SetWindowText(_T(temp));
UpdateData(true);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -