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

📄 manul.cpp

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

#include "stdafx.h"
#include "alfa.h"
#include "Manul.h"
#include "Main.h"
#include "sys.h"
#include "mccl.h"
#include "Math.h"
#include "io.h"
#define DATAGLB_FILE _T("dataglb.bkp")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define TimerID 10
/////////////////////////////////////////////////////////////////////////////
// CManul dialog
long m_curmx, m_curmz, m_curmsy, m_cursx, m_cursz;

/*int nErrorCount = 0;
void _stdcall RIO_ISR_Function(RIOINT_EX *pstINTSource);*/

CManul::CManul(CWnd* pParent /*=NULL*/)
	: CDialog(CManul::IDD, pParent)
{
	//{{AFX_DATA_INIT(CManul)
	m_speed = 0;
	m_mnusz = 0.0;
	m_mnumx = 0.0;
	m_mnumz = 0.0;
	m_mnumsy = 0.0;
	m_mnusx = 0.0;
	m_mnumx_str = _T("");

	//}}AFX_DATA_INIT
	f1=TRUE;
	f2=TRUE;
	f3=TRUE;
	f4=TRUE;
	f5=TRUE;
	f6=TRUE;
	f7=TRUE;
	f8=TRUE;
//	bitmap.LoadBitmap(IDB_BITMAP7);
//	CDC MemDC,* pDC;
//	pDC=GetDC();
//	MemDC.CreateCompatibleDC(pDC);
//	MemDC.SelectObject(bitmap);
//	BITMAP bm;
//	bitmap.GetObject(sizeof(BITMAP),&bm);
//	pDC->BitBlt(10,10,bm.bmWidth,bm.bmHeight ,&MemDC,0,0,SRCCOPY);
//	bitmap.DeleteObject();
//	pDC->DeleteDC();
//	MemDC.DeleteDC();
}


void CManul::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CManul)
	DDX_Control(pDX, IDC_CK, m_ck);
	DDX_Control(pDX, IDC_AUTO, m_auto);
	DDX_Control(pDX, IDC_VAC, m_vac);
	DDX_Control(pDX, IDC_SDM, m_sdm);
	DDX_Control(pDX, IDC_MOP, m_mop);
	DDX_Control(pDX, IDC_EMC, m_emc);
	DDX_Control(pDX, IDC_EFP, m_efp);
	DDX_Control(pDX, IDC_MOP1, m_mop1);
	DDX_Control(pDX, IDC_HOLD1, m_hold1);
	DDX_Control(pDX, IDC_HOLD2, m_hold2);
	DDX_Control(pDX, IDC_EDIT1, m_edt1); // Call MyEdit
//	DDX_Text(pDX, IDC_EDIT1, m_speed_str);
	DDX_Text(pDX, IDC_EDIT1, m_speed);
	DDX_Control(pDX, IDC_BUTTON5, m_btn5);
	DDX_Control(pDX, IDC_BUTTON6, m_btn6);
	DDX_Control(pDX, IDC_BUTTON7, m_btn7);
	DDX_Control(pDX, IDC_BUTTON8, m_btn8);
	DDX_Control(pDX, IDC_BUTTON11, m_btn11);
	DDX_Control(pDX, IDC_BUTTON12, m_btn12);
	DDX_Control(pDX, IDC_BUTTON13, m_btn13);
	DDX_Control(pDX, IDC_BUTTON14, m_btn14);
	DDX_Control(pDX, IDC_BUTTON15, m_btn15);
	DDX_Control(pDX, IDC_BUTTON16, m_btn16);
	DDX_Control(pDX, IDC_LIST14, m_list1);
	DDX_Text(pDX, IDC_EDIT2, m_mnumx_str);
	DDX_Text(pDX, IDC_EDIT3, m_mnumz_str);
	DDX_Text(pDX, IDC_EDIT4, m_mnumsy_str);
	DDX_Text(pDX, IDC_EDIT6, m_mnusx_str);
	DDX_Text(pDX, IDC_EDIT16, m_mnusz_str);

	DDX_Text(pDX, IDC_EDIT30, m_curmx_str);
	DDX_Text(pDX, IDC_EDIT31, m_curmz_str);
	DDX_Text(pDX, IDC_EDIT32, m_curmsy_str);
	DDX_Text(pDX, IDC_EDIT33, m_cursx_str);
	DDX_Text(pDX, IDC_EDIT34, m_cursz_str);

	DDX_Text(pDX, IDC_EDIT35, m_lagmx_str);
	DDX_Text(pDX, IDC_EDIT36, m_lagmz_str);
	DDX_Text(pDX, IDC_EDIT37, m_lagmsy_str);
	DDX_Text(pDX, IDC_EDIT38, m_lagsx_str);
	DDX_Text(pDX, IDC_EDIT39, m_lagsz_str);


//	DDX_Text(pDX, IDC_STATICALM, m_alarm);

	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CManul, CDialog)
	//{{AFX_MSG_MAP(CManul)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON17, OnButton17)
	ON_BN_CLICKED(IDC_BUTTON18, OnButton18)
	ON_BN_CLICKED(IDC_BUTTON19, OnButton19)
	ON_BN_CLICKED(IDC_BUTTON20, OnButton20)
	ON_BN_CLICKED(IDC_BUTTON23, OnButton23)
	ON_BN_CLICKED(IDC_BUTTON24, OnButton24)
	ON_WM_SHOWWINDOW()
	ON_BN_CLICKED(IDC_BUTTON21, OnButton21)
	ON_BN_CLICKED(IDC_BUTTON22, OnButton22)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON41, OnButton41)
	ON_BN_CLICKED(IDC_BUTTON26, OnButton26)

	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CManul message handlers
// Exit
void CManul::OnButton4() 
{
	// TODO: Add your control notification handler code here
	CMain * main=(CMain *)GetParent();
	ShowWindow(FALSE);
	if(DiagID==31) 
	  main->dlgfixedmode->ShowWindow(TRUE);
	else if(DiagID==32) 
	  main->dlgmodeteach->ShowWindow(TRUE);
	else if(DiagID==11) {
      DiagID=0;
	  main->dlgauto->ShowWindow(TRUE);
	}
	else if(DiagID==12) {
      DiagID=0;
	  main->dlgautoteach->ShowWindow(TRUE);
	}
	else if(HomeOKflg==1) 
	  main->dlgmainfrm->ShowWindow(TRUE);
	else 
      main->dlghome->ShowWindow(TRUE);

	MCC_GetENCValue(&m_curmx, 0, 0);
	MCC_GetENCValue(&m_curmz, 1, 0);
	MCC_GetENCValue(&m_curmsy,2, 0);
	MCC_GetENCValue(&m_cursx, 3, 0);
	MCC_GetENCValue(&m_cursz, 4, 0);
    m_curmx=m_curmx*unit0a;
    m_curmz=m_curmz*unit1a;
    m_curmsy=m_curmsy*unit2a;
    m_cursx=m_cursx*unit3a;
    m_cursz=m_cursz*unit4a;
	codposmx=(m_curmx/2500.0)*unit0;
	codposmz=(m_curmz/2500.0)*unit1;
	codposmy=(m_curmsy/2500.0)*unit2;
	codpossx=(m_cursx/2500.0)*unit3;
	codpossz=(m_cursz/2500.0)*unit4;
	codtmx=codposmx;
	codtmy=codposmy;
	codtmz=codposmz;
	codtsx=codpossx;
	codtsy=codposmy;
	codtsz=codpossz;
//    JogAlarm=0;
	KillTimer(TimerID);
}


void CManul::OnButton2() 
{
	// TODO: Add your control notification handler code here
	if(f7==TRUE) {
		OUTPUT0=OUTPUT0 & ~0x0020;
		GetDlgItem(IDC_BUTTON2)->SetWindowText("Ж/OFF");
		f7=FALSE;
	}
	else {
		OUTPUT0=OUTPUT0 | 0x0020;
		GetDlgItem(IDC_BUTTON2)->SetWindowText("Ж/ON");
		f7=TRUE;
	}	
	MCC_SetRIOOutputValue(OUTPUT0, RIO_SET1, RIO_PORT0, CARD_INDEX);	
}

// Input
void CManul::OnButton3() 
{
	// TODO: Add your control notification handler code here
	CMain * main=(CMain *)GetParent();
	ShowWindow(FALSE);
	main->dlgmanuio->ShowWindow(TRUE);
	KillTimer(TimerID);
}

// Output
void CManul::OnButton41() 
{
	// TODO: Add your control notification handler code here
	CMain * main=(CMain *)GetParent();
	ShowWindow(FALSE);
	main->dlgmanualioo->ShowWindow(TRUE);
	KillTimer(TimerID);
}

// Reset
void CManul::OnButton26() 
{
	// TODO: Add your control notification handler code here
  	teatovflg=0;
	autoovflg=0;
    MCC_AbortMotionEx(MX_DecTime, GROUP_INDEX0);
    MCC_AbortMotionEx(SX_DecTime, GROUP_INDEX1);
    MCC_AbortMotionEx(Y_DecTime, GROUP_INDEX2);

    Side_Correct=0;
    msgalm=0;
    JogAlarm=0;
    OTAlarm=0;
	IOAlarm=0;

	OnAtmsgAlm();
}

void CManul::OnButton17() 
{
	// TODO: Add your control notification handler code here
	if(f1==TRUE) {
		OUTPUT0=OUTPUT0 & ~0x0010;
		GetDlgItem(IDC_BUTTON17)->SetWindowText("╆4/OFF");
		f1=FALSE;
	}
	else {
		OUTPUT0=OUTPUT0 | 0x0010;
		GetDlgItem(IDC_BUTTON17)->SetWindowText("╆4/ON");
		f1=TRUE;
	}
	MCC_SetRIOOutputValue(OUTPUT0, RIO_SET1, RIO_PORT0, CARD_INDEX);	
}


void CManul::OnButton18() 
{
	// TODO: Add your control notification handler code here
	if(f2==TRUE) {
		OUTPUT0=OUTPUT0 & ~0x0040;
		GetDlgItem(IDC_BUTTON18)->SetWindowText("秅娩1/OFF");
		f2=FALSE;
	}
	else {
		OUTPUT0=OUTPUT0 | 0x0040;
		GetDlgItem(IDC_BUTTON18)->SetWindowText("秅娩1/ON");
		f2=TRUE;
	}
	MCC_SetRIOOutputValue(OUTPUT0, RIO_SET1, RIO_PORT0, CARD_INDEX); //  write remote I/O set 0's DO0  ~ DO15 signals	
}


void CManul::OnButton19() 
{
	// TODO: Add your control notification handler code here
	if(f3==TRUE) {
		OUTPUT0=OUTPUT0 & ~0x0001;
		GetDlgItem(IDC_BUTTON19)->SetWindowText("

⌨️ 快捷键说明

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