📄 mybutton.cpp
字号:
// MyButton.cpp : implementation file
//
#include "stdafx.h"
//#include "beihang.h"
#include "beihangDlg.h"
#include "MyButton.h"
//#include "GT400.h"
#include "func.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern double arrSpeed[8];
/////////////////////////////////////////////////////////////////////////////
// CMyButton
#ifndef dllfundef
#define dllfundef extern "C" __declspec(dllimport)
#endif
extern CString info;
dllfundef bool DLL_Full_Initial(int Googol_Period, int ISR_Status,unsigned short LmtVolt
,unsigned int EncSense, int Total_Axes, int Pulse_Mode);
dllfundef DLL_Axis_OnOff(int Current_Axis, bool Axis_Status);
dllfundef bool DLL_Z_Run(double Z_Speed, double Z_Accel, double Z_ObjectPos,
double Z_Distance, double Z_Pulse, double Z_Period );
dllfundef bool DLL_SngAxis_Stop(unsigned short Curren_Axis);
dllfundef bool DLL_SngAxis_eStop(unsigned short Curren_Axis);
dllfundef bool DLL_R_Run(double R_Speed, double R_Accel, double R_ObjectPos,
double R_N, double R_Pulse, double R_Period );
dllfundef bool DLL_SelAxis(unsigned short Current_Axis);
dllfundef bool DLL_SetZero(unsigned short Current_Axis);
dllfundef bool DLL_Motion_Finish(unsigned short Current_Axis);
dllfundef bool DLL_GetSngPos(unsigned short Current_Axis,long * lpCurPos);
dllfundef bool DLL_SetMotionMode(int m_nMotionSerial, unsigned short Master_Axis,
unsigned short Slave_Axis, double Ratio_Axis);
dllfundef bool DLL_SngVelRun(unsigned short Current_Axis,double dblMaxVel, double MaxAcc);
#pragma comment(lib,"debug/Googol.lib")
SYSTEMTIME t1,t2;
CMyButton::CMyButton()
{
parent=NULL;
}
CMyButton::~CMyButton()
{
}
BEGIN_MESSAGE_MAP(CMyButton, CButton)
//{{AFX_MSG_MAP(CMyButton)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyButton message handlers
void CMyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CButton::OnLButtonDown(nFlags, point);
parent=(CBeihangDlg*)this->GetParent();
parent->bBreak=0;
switch(index)
{
case 1:
RBack();
break;
case 2:
RFor();
break;
case 3:
ZBack();
break;
case 4:
ZFor();
break;
default:
break;
}
}
void CMyButton::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CButton::OnLButtonUp(nFlags, point);
double ltime=0;
unsigned short Curren_Axis=1;
switch(index)
{
case 1:
case 2:
Curren_Axis=2;
//time(&time_end);
GetSystemTime(&t2);
case 3:
case 4:
Curren_Axis=1;
// time(&time_end);
GetSystemTime(&t2);
break;
default:
break;
}
if(!GT_AbptStp())
{
ltime=(t2.wDay-t1.wDay)*3600*24+(t2.wHour-t1.wHour)*3600+\
(t2.wMinute-t1.wMinute)*60+t2.wSecond-t1.wSecond\
+(t2.wMilliseconds-t1.wMilliseconds)/1000.0;
CBeihangDlg *pdlg=(CBeihangDlg*)this->GetParent();
switch(index)
{
case 1:
case 2:
pdlg->m_dblRCurPos+=((int)(m_dblAxisSpeed*ltime));
break;
case 3:
case 4:
//ppp=((int)m_dblAxisSpeed*ltime*100)/100.;
pdlg->m_dblZCurPos+=((int)(m_dblAxisSpeed*ltime));
break;
default:
break;
}
pdlg->UpdateData(0);
}
else
{AfxMessageBox("停车失败");
}
}
void CMyButton::RBack()
{
// TODO: Add your control notification handler code here
short rtn;
int period=200;
int ISR_Sta=0;
unsigned short lmtvolt=255;
unsigned int sense=0xF;
int total_axes=2;
int Pulse_mode=2;
int cur_axis=2;
bool axis_sta=true;
int c=(int)(parent->m_hWnd);
if(c!=0)
{
rtn=DLL_Full_Initial(period, ISR_Sta, lmtvolt, sense, total_axes, Pulse_mode);
DLL_SetMotionMode(3,0,0,0);
int m_nSpeedNo=parent->m_ctlCM_R_SPEED.GetCurSel();
m_dblAxisSpeed=-arrSpeed[m_nSpeedNo] *90 ;
parent->curspeed=m_dblAxisSpeed;
DLL_SngVelRun(cur_axis,0,0.01);
//rtn=DLL_R_Run(m_dblAxisSpeed,10,0,/*m_ZObjPos*50/56.2*/1,5000,200);
// GetSystemTime(&t1);GetSystemTime(&t1);
// time=t1.wSecond+t1.wMilliseconds/1000.0;
parent->params.axisRVrun(m_dblAxisSpeed);
/* GTInitial();
InputCfg();
AxisInitial();
rtn=GT_Axis(1);
SMotion(-80000);*/
}
}
void CMyButton::RFor()
{
short rtn;
int period=200;
int ISR_Sta=0;
unsigned short lmtvolt=255;
unsigned int sense=0xF;
int total_axes=2;
int Pulse_mode=2;
int cur_axis=2;
bool axis_sta=true;
if(parent->m_hWnd!=0)
{rtn=DLL_Full_Initial(period, ISR_Sta, lmtvolt, sense, total_axes, Pulse_mode);
DLL_SetMotionMode(3,0,0,0);
int m_nSpeedNo=parent->m_ctlCM_R_SPEED.GetCurSel();
m_dblAxisSpeed=arrSpeed[m_nSpeedNo] *90 ;
parent->curspeed=m_dblAxisSpeed;
// rtn=DLL_R_Run(m_dblAxisSpeed,10,0,/*m_ZObjPos*50/56.2*/1,5000,200);
DLL_SngVelRun(cur_axis,0,0.01);
//GetSystemTime(&t1);
parent->params.axisRVrun(m_dblAxisSpeed);
/*GTInitial();
InputCfg();
AxisInitial();
rtn=GT_Axis(1);
SMotion();*/
}
}
void CMyButton::ZBack()
{
short rtn;
int period=200;
int ISR_Sta=0;
unsigned short lmtvolt=3;
unsigned int sense=0xF;
int total_axes=1;
int Pulse_mode=2;
int cur_axis=1;
bool axis_sta=true;
if(parent->m_hWnd!=0)
{rtn=DLL_Full_Initial(period, ISR_Sta, lmtvolt, sense, total_axes, Pulse_mode);
DLL_SetMotionMode(3,0,0,0);
int m_nSpeedNo=parent->m_ctlCM_Z_SPEED.GetCurSel();
m_dblAxisSpeed=-arrSpeed[m_nSpeedNo] * 16;
parent->curspeed=m_dblAxisSpeed;
DLL_SngVelRun(cur_axis,0,0.01);
// time(&time_start);
parent->params.axisZVrun(m_dblAxisSpeed);
}
}
void CMyButton::ZFor()
{
short rtn;
int period=200;
int ISR_Sta=0;
unsigned short lmtvolt=3;
unsigned int sense=0xF;
int total_axes=1;
int Pulse_mode=2;
int cur_axis=1;
bool axis_sta=true;
if(parent->m_hWnd!=0)
{rtn=DLL_Full_Initial(period, ISR_Sta, lmtvolt, sense, total_axes, Pulse_mode);
DLL_SetMotionMode(3,0,0,0);
int m_nSpeedNo=parent->m_ctlCM_Z_SPEED.GetCurSel();
m_dblAxisSpeed=arrSpeed[m_nSpeedNo] * 16;
parent->curspeed=m_dblAxisSpeed;
DLL_SngVelRun(cur_axis,0,0.01);
//time(&time_start);
parent->params.axisZVrun(m_dblAxisSpeed);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -