⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 advass.cpp

📁 机械手IPC控制器伺服运动程序
💻 CPP
字号:
// AdvAss.cpp : implementation file
//

#include "stdafx.h"
#include "alfa.h"
#include "AdvAss.h"
#include "Main.h"
#include "mccl.h"
#include "sys.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAdvAss dialog


CAdvAss::CAdvAss(CWnd* pParent /*=NULL*/)
	: CDialog(CAdvAss::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAdvAss)
	m_edt1 = 0.0;
	m_edt2 = 10;
	//}}AFX_DATA_INIT
}


void CAdvAss::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAdvAss)
	DDX_Control(pDX, IDC_EDIT2, m_edit2);
	DDX_Control(pDX, IDC_EDIT1, m_edit1);
	DDX_Text(pDX, IDC_EDIT1, m_edt1);
	DDX_Text(pDX, IDC_EDIT2, m_edt2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAdvAss, CDialog)
	//{{AFX_MSG_MAP(CAdvAss)
	ON_WM_SHOWWINDOW()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAdvAss message handlers

void CAdvAss::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
    CString m_Dist_str, m_Speed_str;
	if(bShow==1) {
		CMain * main=(CMain *)GetParent();
		m_edt1=main->dlgfixedmode->moveparam.distance_x_ass;
		m_edt2=main->dlgfixedmode->moveparam.speed_adv_ass;
	    m_Dist_str.Format("%6.2f", m_edt1);
	    m_Speed_str.Format("%3d", m_edt2);
        GetDlgItem(IDC_EDIT1)->SetWindowText(m_Dist_str);      
        GetDlgItem(IDC_EDIT2)->SetWindowText(m_Speed_str);  
		m_Kill_Flag=0;
//		UpdateData(FALSE);
		main->dlgcur =this;
	}
	// TODO: Add your message handler code here
}

void CAdvAss::OnOK() 
{
	// TODO: Add extra validation here
	CMain * main=(CMain *)GetParent();
	UpdateData();
	main->dlgfixedmode->moveparam.distance_x_ass=m_edt1;
	main->dlgfixedmode->moveparam.speed_adv_ass=m_edt2;
	JogDir=0;  KillTimer(46);
	ShowWindow(FALSE);
	main->dlgfixedmode->ShowWindow(TRUE);
}

void CAdvAss::OnCancel() 
{
	// TODO: Add extra cleanup here
	CMain * main=(CMain *)GetParent();
	JogDir=0;  KillTimer(46);
	ShowWindow(FALSE);
	main->dlgfixedmode->ShowWindow(TRUE);
}


BOOL CAdvAss::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	h_SkinDialog.SubClassDialog(m_hWnd);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CAdvAss::OnLButtonDown(UINT nFlags, CPoint point) 
{
	long m_curmx;
	double m_x;
	WORD wInput0;
	WORD OTStatus;

    MCC_GetRIOInputValue(&wInput0, RIO_SET1, RIO_PORT0, CARD_INDEX);
	MCC_GetENCValue(&m_curmx, 3, 0);
    m_curmx=m_curmx*unit3a;
    m_x=(m_curmx/2500.0)*unit3;

	if((OUTPUT0 & 0x2000)>0 || (wInput0 & 0x0080)>0) return;

	if(PtInRect(CRect(214, 36, 264, 66), point)) {
        if(MCC_GetLimitSwitchStatus(&OTStatus, 1, 3, 0)==0) { // SX+, HOT
            if(OTStatus==1) ;
			else if(m_x>SXSOT_Plus) ;     // SX+, SOT
			else {
                JogDir=7;  m_Kill_Flag=-1;    
                KillTimer(46);
		        MCC_JogConti(1, JogSpeed, 0, 1); //  SX+
                SetTimer(46, 10, NULL);
            }
		}
	}
	else if(PtInRect(CRect(154, 36, 204, 66), point)) {
        if(MCC_GetLimitSwitchStatus(&OTStatus, 0, 3, 0)==0) { // SX-, HOT
            if(OTStatus==1) ;
			else if(m_x<SXSOT_Minus) ;    // SX-, SOT
			else {
                JogDir=8;  m_Kill_Flag=-1; 
                KillTimer(46);
		        MCC_JogConti(-1, JogSpeed, 0, 1);  //  SX-
                SetTimer(46, 10, NULL);
            }
		}
	}

	CDialog::OnLButtonDown(nFlags, point); 
}


void CAdvAss::OnLButtonUp(UINT nFlags, CPoint point) 
{
    CString s_x_str; 
	long m_cursx;
	double s_x;
    if(JogDir==7 || JogDir==8) {
//        JogDir=0;
	    MCC_GetENCValue(&m_cursx, 3, 0);
        m_cursx=m_cursx*unit3a;
	    s_x=(m_cursx/2500.0)*unit3;
	    s_x_str.Format("%6.2f", s_x);
        GetDlgItem(IDC_EDIT1)->SetWindowText(s_x_str);
        m_Kill_Flag=100; 
// 	    KillTimer(41);     
    }

	MCC_AbortMotion(0);//  stop current motion and discard all motion commands in a command queue
	MCC_AbortMotion(1);//  stop current motion and discard all motion commands in a command queue
	MCC_AbortMotion(2);//  stop current motion and discard all motion commands in a command queue

//    MCC_AbortMotionEx(MX_DecTime*JogSpeed/100.0, GROUP_INDEX0);
//    MCC_AbortMotionEx(SX_DecTime*JogSpeed/100.0, GROUP_INDEX1);
//    MCC_AbortMotionEx(Y_DecTime*JogSpeed/100.0, GROUP_INDEX2);

	CDialog ::OnLButtonUp(nFlags, point); 
}


void CAdvAss::OnTimer(UINT nIDEvent) 
{
	int TempAlarm;
    CString m_x_str; 
	long m_curmx;
	double m_x;
	WORD wInput0;
	WORD OTStatus;

    TempAlarm=0;

    MCC_GetRIOInputValue(&wInput0, RIO_SET1, RIO_PORT0, CARD_INDEX);
	MCC_GetENCValue(&m_curmx, 3, 0);
    m_curmx=m_curmx*unit3a;
	m_x=(m_curmx/2500.0)*unit3;
	m_x_str.Format("%6.2f", m_x);
    GetDlgItem(IDC_EDIT1)->SetWindowText(m_x_str);

	if(m_Kill_Flag>0) { m_Kill_Flag--;  return; }
	if(m_Kill_Flag==0) { JogDir=0;  m_Kill_Flag=-1;  KillTimer(46);  return; }

	if((OUTPUT0 & 0x2000)>0 || (wInput0 & 0x0080)>0) TempAlarm=1;
	if(JogDir==7) {
        if(MCC_GetLimitSwitchStatus(&OTStatus, 1, 3, 0)==0) { // SX+, HOT
            if(OTStatus==1) TempAlarm=1;
			else if(m_x>SXSOT_Plus) TempAlarm=1; // SX+, SOT
        }
		else TempAlarm=1;
	}
	else if(JogDir==8) {
        if(MCC_GetLimitSwitchStatus(&OTStatus, 0, 3, 0)==0) { // SX-, HOT
            if(OTStatus==1) TempAlarm=1;
			else if(m_x<SXSOT_Minus) TempAlarm=1; // SX-, SOT
		}
		else TempAlarm=1;
	}
	if(TempAlarm>0) {
        JogDir=0; 
	    MCC_AbortMotion(0);
	    MCC_AbortMotion(1);
	    MCC_AbortMotion(2);
//        MCC_AbortMotionEx(MX_DecTime*JogSpeed/100.0, GROUP_INDEX0);
//        MCC_AbortMotionEx(SX_DecTime*JogSpeed/100.0, GROUP_INDEX1);
//        MCC_AbortMotionEx(Y_DecTime*JogSpeed/100.0, GROUP_INDEX2);
        m_Kill_Flag=100; 
//		KillTimer(42);	
    }

	CDialog::OnTimer(nIDEvent);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -