?? linedlg.cpp
字號(hào):
// LineDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CSU.h"
#include "LineDlg.h"
#include "DotDlg.h"
#include "GT400SV.h"
#include "CSUDlg.h"
#include <math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLineDlg dialog
CLineDlg::CLineDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLineDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLineDlg)
m_step = 0.0;
m_synacc = 0.0;
m_synvel = 0.0;
m_xendpos = 0.0;
m_yendpos = 0.0;
m_zscope = 0.0;
m_zspeed = 0.0;
m_linen = 0;
m_ymove = 0.0;
m_motoroff = 0;
m_motoron = 0;
m_ymspeed = 0.0;
m_wettime = 0;
//}}AFX_DATA_INIT
}
void CLineDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLineDlg)
DDX_Text(pDX, IDC_EDIT_step, m_step);
DDX_Text(pDX, IDC_EDIT_SynAcc, m_synacc);
DDX_Text(pDX, IDC_EDIT_SynVel, m_synvel);
DDX_Text(pDX, IDC_EDIT_xendpos, m_xendpos);
DDX_Text(pDX, IDC_EDIT_yendpos, m_yendpos);
DDX_Text(pDX, IDC_EDIT_Zscope, m_zscope);
DDX_Text(pDX, IDC_EDIT_Zspeed, m_zspeed);
DDX_Text(pDX, IDC_EDIT_LineN, m_linen);
DDX_Text(pDX, IDC_EDIT_Ymove, m_ymove);
DDX_Text(pDX, IDC_EDIT_motoroff, m_motoroff);
DDX_Text(pDX, IDC_EDIT_motoron, m_motoron);
DDX_Text(pDX, IDC_EDIT_ymspeed, m_ymspeed);
DDX_Text(pDX, IDC_EDIT_wettime, m_wettime);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLineDlg, CDialog)
//{{AFX_MSG_MAP(CLineDlg)
ON_BN_CLICKED(IDC_Linerun_BUTTON, OnLinerunBUTTON)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLineDlg message handlers
void CLineDlg::OnLinerunBUTTON()
{
UpdateData(TRUE);
unsigned short sts;
double cnt1[5]={2000,0,0,0,0};
double cnt2[5]={0,2000,0,0,0};
GT_MapAxis(1,cnt1);
GT_MapAxis(2,cnt2);
GT_SetSynAcc(0.00000004*m_synacc);
GT_SetSynVel(0.0002*m_synvel);
GT_Axis(3);
long actl_pos;
GT_GetAtlPos(&actl_pos);
GT_ZeroPos(); //把當(dāng)前位置置為零位
ZTmotion(m_zscope, m_zspeed); //Z軸先向上移動(dòng)一段距離
int n=(int)(sqrt(m_xendpos*m_xendpos+m_yendpos*m_yendpos)/m_step);
double xendpos=m_step*(m_xendpos/sqrt(m_xendpos*m_xendpos+m_yendpos*m_yendpos)); //x方向上的進(jìn)給量
double yendpos=m_step*(m_yendpos/sqrt(m_xendpos*m_xendpos+m_yendpos*m_yendpos)); //y方向上的進(jìn)給量
Nflag=1;
for(int j=0;j<m_linen;j++)
{
double ymove=m_ymove*j;
for(int i=0;i<=n;i++)
{
if(Nflag==-1) //反向走
GT_LnXY((n-i)*xendpos,ymove);
else
GT_LnXY(i*xendpos,ymove);
GT_GetCrdSts(&sts);
// GT_ExOpt(0x1); //滴膠
// Sleep(m_motoron); //電機(jī)轉(zhuǎn)動(dòng)時(shí)間
// GT_ExOpt(0x2);
// Sleep(m_motoroff);
while((sts&0x01)!=0x01)
{
GT_GetCrdSts(&sts);
} //XY平面定位
GT_Axis(3);
GT_ClrSts();
ZTmotion(0, m_zspeed); //Z軸移動(dòng)到滴膠位置
Sleep(m_wettime); //潤(rùn)濕時(shí)間
GT_ExOpt(0x1); //滴膠
Sleep(m_motoron); //電機(jī)轉(zhuǎn)動(dòng)時(shí)間
GT_ExOpt(0x2);
Sleep(m_motoroff);
ZTmotion(m_zscope, m_zspeed); //滴完膠后Z軸上移
}
Nflag=-Nflag;
}
ZTmotion(0, m_zspeed); //Z軸回原位
MessageBox("運(yùn)動(dòng)完成","",MB_OK);
}
void CLineDlg::ZTmotion(double Pos, double speed)
{
long d1=(long)(Pos*Pmm);//位置
double d2=speed*Vmms;//速度
if(d2>=16384||d2<=0)
{
MessageBox("速度超出范圍","error",MB_OK);
}
if(d1>=1073741823||d2<=-1073741824)
{
MessageBox("增量值超出范圍","error",MB_OK);
}
GT_PrflT();
GT_SetAcc(0.4);
GT_SetVel(d2);
GT_SetPos(d1);
GT_Update();
unsigned short sts;
GT_GetSts(&sts);
DWORD oldtime = GetTickCount();
while((sts&0x01)!=0x01)
{
/* Sleep( 5 );
DWORD nowtime = GetTickCount();
DWORD s = nowtime - oldtime;
if(Pos==0&&s>=(DWORD)m_motoron )
GT_ExOpt(0x1);
if(Pos==0&&s>=(DWORD)m_motoroff)
GT_ExOpt(0x2); */
GT_GetSts(&sts);
}
GT_ClrSts();
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -