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

📄 auto.cpp

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


#include "stdafx.h"
#include "alfa.h"
#include "Auto.h"
#include "Main.h"
#include "mccl.h"
#include "Math.h"
#include "io.h"
#include "sys.h"
//#include "loginmode.h"
#define DATA_FILE _T("mode.bkp")
#define DATAGLB_FILE _T("dataglb.bkp")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define TimerID 2
//    int FixStatus;
//    int DataType;
//int QC_MoldSet, NG_QC_Flag;
	
/*void _stdcall RIO_ISR_Function(RIOINT_EX *pstINTSource);*/

CAuto::CAuto(CWnd* pParent /*=NULL*/)
	: CDialog(CAuto::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAuto)
	m_num = _T("");
	m_run_main = _T("");
	m_mode_main = _T("");
	m_put_main = _T("");
	m_run_ass = _T("");
	m_mode_ass = _T("");
	m_pos_ass = _T("");
	m_stoppos = _T("");
	m_warn = _T("");
	m_stopmode = _T("");
	m_in = _T("");
	m_lift = _T("");
	m_shake = _T("");
	m_ays = _T("");
	m_detect = _T("");
	m_put_ass = _T("");
	m_vac1 = _T("");
	m_vac2 = _T("");
	m_vac3 = _T("");
	m_vac4 = _T("");
	m_vac5 = _T("");
//	m_hold1 = _T("");
	//}}AFX_DATA_INIT
	autokk=0;
	moprun=0;
	mldinrun=0;
	travrun=0;
	mldoutrun=0;
	travinrun=0;
	vac1start=0;
	vac2start=0;
	vac1over=0;
	vac1tim=1;
	vac2tim=1;
	vac1tim_n=1;
	hold1start=0;
	hold1over=0;
	hold1tim=1;
	hold1tim_n=1;
    conveyact=0;
    conveytime=1;
	mafrun=0;
	waitrun=0;
	progovrun=0;
	autorunflg=0;
	automopflg=0;
	mactindex=0;
	sactindex=0;
//	codposmx=0;
//	codposmy=0;
//	codposmz=0;
//	codpossx=0;
//	codpossz=0;
	gdrunflg=0;
	gmopflg=0;
	posxwaitm=0;
	poszwaitm=0;
	posywait=0;
	posxwaits=0;
	poszwaits=0;
	dnzminm=0;
	dnzmins=0;
	putpartm=0;
	putzpartm=0;
	putparts=0;
	putzparts=0;
	fwdxminm=0;
	fwdxmins=0;
	spd_downminm=0;
	spd_downmins=0;
	spd_upminm=0;
	spd_upmins=0;
	spd_fwdminm=0;
	spd_fwdmins=0;
	spd_backminm=0;
	spd_backmins=0;
	spd_acrossin=0;
	spd_acrossout=0;
	spd_downmoutm=0;
	spd_downmout2m=0;
	spd_downmouts=0;
	spd_upmoutm=0;
	spd_upmouts=0;
	t_fwdminm=10;
	t_backminm=10;
	t_upminm=10;
	t_downminm=10;
	t_holdm=10;
	t_vacsp=10;
	t_vac=10;
	t_fwdmins=10;
	t_backmins=10;
	t_upmins=10;
	t_downmins=10;
	t_nips=10;
	t_nipoffs=10;
	t_rej=10;
	t_place=10;
	t_cutfwd=10;
	t_cutback=10;
	t_cut=10;
	t_downmoutm=10;
	t_upmoutm=10;
	mopflg=0;
	rmcflg=0;
	mopflg2=0;
	out0=0;
	statasact=0;
	statastrav=0;
	stataswait=0;
	actflg=0;
	rotflg=0;
	acttim=1;
	rottim=1;
//	LatchedAlm=0;  
	almclr=0;
	startrun=0;
	FixStep=0;
	autorunflg=SYS_STATUS_READY;
    autoovflg=0;
//	DataType=0;
//    Pause_Flag=0;
}

void CAuto::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAuto)
//	DDX_Control(pDX, IDC_EDIT1, m_edt);
	DDX_Control(pDX, IDC_VAC1, m_vac);
	DDX_Control(pDX, IDC_SDM1, m_sdm);
	DDX_Control(pDX, IDC_MOP1, m_mop);
	DDX_Control(pDX, IDC_EMC1, m_emc);
	DDX_Control(pDX, IDC_EFP1, m_efp);
	DDX_Control(pDX, IDC_CK1, m_ck);
	DDX_Control(pDX, IDC_AUTO1, m_auto);
	DDX_Control(pDX, IDC_MOP2, m_mop2);
	DDX_Control(pDX, IDC_HOLD1, m_hold1);
	DDX_Control(pDX, IDC_HOLD2, m_hold2);

//	DDX_Control(pDX, IDC_STATICSTATUS, m_status);
	DDX_Text(pDX, IDC_STATICSTATUS, m_status);

	DDX_Text(pDX, IDC_EDIT1, m_num);
	DDX_Text(pDX, IDC_STATIC1, m_run_main);
	DDX_Text(pDX, IDC_STATIC3, m_put_main);
	DDX_Text(pDX, IDC_STATIC4, m_run_ass);
	DDX_Text(pDX, IDC_STATIC5, m_mode_ass);
	DDX_Text(pDX, IDC_STATIC6, m_pos_ass);
	DDX_Text(pDX, IDC_STATIC7, m_stoppos);
	DDX_Text(pDX, IDC_STATIC8, m_warn);
	DDX_Text(pDX, IDC_STATIC9, m_stopmode);
	DDX_Text(pDX, IDC_STATIC11, m_lift);
	DDX_Text(pDX, IDC_STATIC13, m_ays);
	DDX_Text(pDX, IDC_STATIC14, m_detect);
	DDX_Text(pDX, IDC_STATIC15, m_put_ass);
	DDX_Text(pDX, IDC_STATIC16, m_vac1);
	DDX_Text(pDX, IDC_STATIC17, m_vac2);
	DDX_Text(pDX, IDC_STATIC18, m_vac3);
	DDX_Text(pDX, IDC_STATIC19, m_vac4);
	DDX_Text(pDX, IDC_STATIC22, m_vac5);

	DDX_Text(pDX, IDC_EDITMX, m_mdmx_str);
	DDX_Text(pDX, IDC_EDITMZ, m_mdmz_str);
	DDX_Text(pDX, IDC_EDITY, m_mdmsy_str);
	DDX_Text(pDX, IDC_EDITSX, m_mdsx_str);
	DDX_Text(pDX, IDC_EDITSZ, m_mdsz_str);
	DDX_Text(pDX, IDC_EDITMOLD, m_moldcount);
	DDX_Text(pDX, IDC_EDITMOLD2, m_moldset);
	DDX_Text(pDX, IDC_EDITMOLD3, m_moldtotal);
	DDX_Text(pDX, IDC_EDITMOLDS1, m_Stack1_Num);
	DDX_Text(pDX, IDC_EDITMOLDS2, m_Stack2_Num);
//    DDX_Text(pDX, IDC_EDITMOLDS2, PutStep);
	DDX_Text(pDX, IDC_EDITMOLDNG, m_NG_Num);
	DDX_Text(pDX, IDC_EDITMOLDQC, m_QC_Num);

//	DDX_Text(pDX, IDC_EDITTEST1, m_fixstep);
//	DDX_Text(pDX, IDC_EDITTEST2, m_sysalarm);
//	DDX_Text(pDX, IDC_EDITTEST3, m_inputdata);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAuto, CDialog)
	//{{AFX_MSG_MAP(CAuto)
//	ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
//	ON_MESSAGE(WM_LISTADD, OnListAdd)
	ON_WM_SHOWWINDOW()
	ON_WM_TIMER()
	ON_WM_DESTROY()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTONTIMER, OnButtonTimer)
	ON_BN_CLICKED(IDC_BUTTONCOUNTER, OnButtonCounter)
	ON_BN_CLICKED(IDC_BUTTONSPEED, OnButtonSpeed)
	ON_BN_CLICKED(IDC_BUTTONPOS, OnButtonPos)
	ON_BN_CLICKED(IDC_BUTTONRESET, OnButtonReset)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAuto message handlers
// Timer Parameter
void CAuto::OnButtonTimer() 
{
	// TODO: Add your control notification handler code here
	ShowWindow(FALSE);
	CMain * main=(CMain *)GetParent();
	main->dlgautotimer->ShowWindow(TRUE);
//	KillTimer(TimerID);
}

// Counter Parameter
void CAuto::OnButtonCounter() 
{
	// TODO: Add your control notification handler code here
	ShowWindow(FALSE);
	CMain * main=(CMain *)GetParent();
	main->dlgautocount->ShowWindow(TRUE);
//	KillTimer(TimerID);
}
// Speed Parameter
void CAuto::OnButtonSpeed() 
{
	// TODO: Add your control notification handler code here
    ShowWindow(FALSE);
	CMain * main=(CMain *)GetParent();
	main->dlgautofixspeed->ShowWindow(TRUE);
//	KillTimer(TimerID);
}

// Position Parameter
void CAuto::OnButtonPos() 
{
	ShowWindow(FALSE);
	CMain * main=(CMain *)GetParent();
	main->dlgautofixpos->ShowWindow(TRUE);
//	KillTimer(TimerID);
}

void CAuto::OnButtonReset() 
{
//	MCC_AbortMotionEx(0);
//	MCC_AbortMotionEx(1);
//	MCC_AbortMotionEx(2);

    MCC_AbortMotionEx(MX_DecTime, GROUP_INDEX0);
    MCC_AbortMotionEx(SX_DecTime, GROUP_INDEX1);
    MCC_AbortMotionEx(Y_DecTime, GROUP_INDEX2);

	if((wInput0 & 0x0001)>0)      OUTPUT0=OUTPUT0 & ~0xD100; // Y16, Y15, Y13, Y9
    else if((wInput0 & 0x4000)>0) OUTPUT0=OUTPUT0 & ~0x4000; // Y15
	MCC_SetRIOOutputValue(OUTPUT0, RIO_SET1, RIO_PORT0, CARD_INDEX);

	AlarmDisplayOFF();
	UpdateData(FALSE);
	
	autorunflg=SYS_STATUS_READY;
	m_Stack1_Full=0;
	m_Stack2_Full=0;
    autoovflg=0;
	Mold_Close=0;
	startrun=0;
    RobotRun_Flag=0;
	msgalm=0;
	JogAlarm=0;
    OTAlarm=0;
	IOAlarm=0;
	ACTAlarm=0;
	WarnAlarm=0;
//	LatchedAlm=0;
	vac1start=0;
	vac1tim=1;
	vac2start=0;
	vac2tim=1;
	vac1over=0;
	vac1tim_n=1;
	hold1start=0;
	hold1tim=1;
	hold1over=0;
	hold1tim_n=1;
	pinstart=1;
    pintim=1;
    conveyact=0;
    conveytime=1;
	Get_Flag=0;
	Get_Flag1=0;

	SaveGlobal();
}


void CAuto::Serialize(CArchive& ar) 
{
	if(FileDataType==1) glb.Serialize(ar);
	else m_Contacts.Serialize(ar);
}


void CAuto::LoadRecords()
{
    if(CanSerialize()) {
	    CFile file;
	    CFileException fe;
        if(FileDataType==1) {
	        if(file.Open(DATAGLB_FILE, CFile::typeBinary|CFile::modeRead, &fe)) {
		        CArchive ar(&file,CArchive::load);
		        Serialize(ar);
			}
		}
		else {
	        if(file.Open(DATA_FILE, CFile::typeBinary|CFile::modeRead, &fe)) {
		        CArchive ar(&file,CArchive::load);
		        Serialize(ar);
			}
        }
	}
}


BOOL CAuto::CanSerialize()
{
//    return (0==_access(DATA_FILE,10));
    if(FileDataType==1) return (0==_access(DATAGLB_FILE, 6));
	else return (0==_access(DATA_FILE, 6));
}


void CAuto::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
    int i;	
	// TODO: Add your message handler code here
	if(bShow==1) {
		CMain * main=(CMain *)GetParent();
		main->dlgcur=this;

		if(DiagID==11) return;
		else DiagID=11;

		FileDataType=0;
		LoadRecords();
		CModes * pmode;
		if(m_Contacts.Lookup(main->m_num, pmode)) {
			m_num=pmode->m_num;

			m_run_main.Format("%d", pmode->m_run_main);
			m_run_main.Insert(0, "0");
			m_run_ass.Format("%d", pmode->m_run_ass);
			if(m_run_ass.GetLength()<2)
				m_run_ass.Insert(0, "0");
// Master Data Display
	        if(pmode->m_radio37==0) {
				m_vac1="浪

⌨️ 快捷键说明

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