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

📄 main.cpp

📁 机械手IPC控制器伺服运动程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// Main.cpp : implementation file
//

#include "stdafx.h"
#include "alfa.h"
#include "Main.h"
#include "io.h"
#include "Math.h"
#include "sys.h"
#include "mccl.h"
#define SYSTEM_FILE _T("system.bkp")
#define DATA_FILE   _T("channel.bkp")
#define DATAGLB_FILE   _T("dataglb.bkp")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMain dialog
    int	 nRet, nCommandMode, nFlag, Read_Flag;//,nCommandFinfish;
	double dfCurPosX, dfCurPosY, dfCurPosZ;
//	BYTE   byInPos0, byInPos1, byInPos2, byInPos3, byInPos4, byInPos5;
	WORD wCardType;
	SYS_MAC_PARAM      stMacParam;
	SYS_ENCODER_CONFIG stENCConfig;
	SYS_GROUP_CONFIG   stGroupConfig;
	SYS_CARD_CONFIG    stCardConfig[MAX_CARD_NUM];
	SYS_HOME_CONFIG    stHomeConfig;
//void _stdcall RIO_ISR_Function(RIOINT_EX *pstINTSource);
//void _stdcall System_ISR_Function( );

CMain::CMain(CWnd* pParent /*=NULL*/)
	: CDialog(CMain::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMain)
	//}}AFX_DATA_INIT
	dlgcur=NULL;
	m_num=_T("");
	codposmx=0;
	codposmy=0;
	codposmz=0;
	codpossx=0;
	codpossz=0;
	codtmx=0;
	codtmy=0;
	codtmz=0;
	codtsx=0;
	codtsy=0;
	codtsz=0;
	dataflg=0;
	msgalm=0;
	unit0=8.8;
	unit1=20;
	unit2=10.0;
	unit3=8.8;
	unit4=20.0;
	unit0a=1;
	unit1a=1;
	unit2a=1;
	unit3a=1;
	unit4a=1;
	gr0=1.0;
	gr1=1.0;
	gr2=1.0;
	gr3=1.0;
	gr4=1.0;	
	actsel=0;
	zactsel=0;
	yactsel=0;
	teatovflg=0;
	autoovflg=0;


}


void CMain::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMain)
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMain, CDialog)
	//{{AFX_MSG_MAP(CMain)
	ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_WM_TIMER()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMain message handlers
BOOL CMain::OnInitDialog() 
{
    char Acc_DecType;
//    double MX_AccTime, MX_DecTime, MZ_AccTime, MZ_DecTime, Y_AccTime, Y_DecTime, 
//           SX_AccTime, SX_DecTime, SZ_AccTime, SZ_DecTime;

	CDialog::OnInitDialog();
	h_SkinDialog.SubClassDialog(m_hWnd);
	// TODO: Add extra initialization here
	CRect rts, rt;
    GetWindowRect(rt);
	dlghome=new CHome;
	dlghome->Create(IDD_HOME, this);
	dlghome->ShowWindow(TRUE);
	dlghomeset=new CHomeSet;
	dlghomeset->Create(IDD_HOMESET, this);
	dlgmainfrm=new CMainFrm;
	dlgmainfrm->Create(IDD_MAIN, this);
	dlgauto=new CAuto;
	dlgauto->Create(IDD_DIALOGAUTO, this);
	dlgautofull=new CAutoFull;
	dlgautofull->Create(IDD_DIALOGAUTOFULL, this);
	dlgautocount=new CCount;
	dlgautocount->Create(IDD_AUTOCOUNT, this);
	dlgautotimer=new CTimer;
	dlgautotimer->Create(IDD_AUTOTIMER, this);
	dlgautospay=new CSpray;
	dlgautospay->Create(IDD_AUTOSPRAY, this);
	dlgautofixpos=new CAutoFixPos;
	dlgautofixpos->Create(IDD_AUTOFIXPOS, this);
	dlgautofixspeed=new CAutoFixSpeed;
	dlgautofixspeed->Create(IDD_AUTOFIXSPEED, this);
	dlgmanul=new CManul;
	dlgmanul->Create(IDD_DIALOGMANUL, this);
	dlgmanuio=new CManuIO;
	dlgmanuio->Create(IDD_DIALOGIO, this);
	dlgmanualioo=new Cmanualioo;
	dlgmanualioo->Create(IDD_DIALOGIO_O, this);
	dlgmodeselect=new CModeSelect;
	dlgmodeselect->Create(IDD_DIALOGMODESELECT, this);
	dlgmodespeed=new CModeSpeed;
	dlgmodespeed->Create(IDD_MODESPEED, this);
	dlgfmstackup=new CFMStackUp;
	dlgfmstackup->Create(IDD_FM_STACK_UP, this);
    dlgfmstackup->GetWindowRect(rts);
	dlgfmstackup->MoveWindow(rt.Width()/2-rts.Width()/2,
		                     rt.Height()/2-rts.Height()/2,
		                     rts.Width(),
							 rts.Height());
	dlgfmstackdown=new CFMStackDown;
	dlgfmstackdown->Create(IDD_FM_STACK_DOWN, this);
	dlgfmstackdown->GetWindowRect(rts);
	dlgfmstackdown->MoveWindow(rt.Width()/2-rts.Width()/2,
		                       rt.Height()/2-rts.Height()/2,
		                       rts.Width(),
							   rts.Height());
	dlgmode=new CMode;
	dlgmode->Create(IDD_DIALOGMODE, this);
	dlgmodetimer=new CModeTimer;
	dlgmodetimer->Create(IDD_MODETIMER, this);
	dlgmodecount=new CModeCount;
	dlgmodecount->Create(IDD_MODECOUNT, this);
	dlgmodespay=new CModeSpay;
	dlgmodespay->Create(IDD_MODESPAY, this);
	dlgfixedmode=new CFixedMode;
	dlgfixedmode->Create(IDD_DIALOGFIXEDMODE, this);
	dlgsysparpos=new CSysParPos;
	dlgsysparpos->Create(IDD_SYSPARPOS, this);
	dlgsystemparam=new CSystemParam;
	dlgsystemparam->Create(IDD_SYSTEMPARA, this);
	dlgsystem=new CSystem;
	dlgsystem->Create(IDD_SYSTEM, this);
	dlgsystempwd=new CSystemPara;
	dlgsystempwd->Create(IDD_SYSTEMPWD, this);
	dlgsystempwd->GetWindowRect(rts);
	dlgsystempwd->MoveWindow(rt.Width()/2-rts.Width()/2,
		                     rt.Height()/2-rts.Height()/2,
		                     rts.Width(),
							 rts.Height());
 	dlgfault=new CFault;
	dlgfault->Create(IDD_MALFUNCTION, this);
	dlgexitsystem=new CExitSystem;
	dlgexitsystem->Create(IDD_EXITSYSTEM, this);
	dlgexitsystem->GetWindowRect(rts);
    dlgexitsystem->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
	dlgadv=new CAdv;
	dlgadv->Create(IDD_DIALOGADV, this);
	dlgadv->GetWindowRect(rts);
    dlgadv->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
	dlgadvs=new CAdvs;
	dlgadvs->Create(IDD_DIALOGADVS, this);
	dlgadvs->GetWindowRect(rts);
    dlgadvs->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
	dlgback=new CBack;
	dlgback->Create(IDD_DIALOGBACK, this);
	dlgback->GetWindowRect(rts);
    dlgback->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
    dlgbacks=new CBacks;
	dlgbacks->Create(IDD_DIALOGBACKS, this);
	dlgbacks->GetWindowRect(rts);
    dlgbacks->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
	dlgdown=new CDown;
	dlgdown->Create(IDD_DIALOGDOWN, this);
	dlgdown->GetWindowRect(rts);
    dlgdown->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
    dlgups=new CUps;
	dlgups->Create(IDD_DIALOGUPS, this);
	dlgups->GetWindowRect(rts);
    dlgups->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
	dlgadvass=new CAdvAss;
	dlgadvass->Create(IDD_ADVASS, this);
	dlgadvass->GetWindowRect(rts);
    dlgadvass->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
	dlgadvsass=new CAdvsAss;
	dlgadvsass->Create(IDD_AVSASS, this);
	dlgadvsass->GetWindowRect(rts);
    dlgadvsass->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
	dlgbackass=new CBackAss;
	dlgbackass->Create(IDD_BACKASS, this);
	dlgbackass->GetWindowRect(rts);
    dlgbackass->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
    dlgbacksass=new CBacksAss;
	dlgbacksass->Create(IDD_BACKSASS, this);
	dlgbacksass->GetWindowRect(rts);
    dlgbacksass->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
	dlgdownass=new CDownAss;
	dlgdownass->Create(IDD_DOWNASS, this);
	dlgdownass->GetWindowRect(rts);
    dlgdownass->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
    dlgupsass=new CUpsAss;
	dlgupsass->Create(IDD_UPSASS, this);
	dlgupsass->GetWindowRect(rts);
    dlgupsass->MoveWindow(rt.Width()/2-rts.Width()/2,
		rt.Height()/2-rts.Height()/2,
		rts.Width(),rts.Height());
	dlgautoteach=new CAutoTeach;
	dlgautoteach->Create(IDD_AUTOTEACH, this);
	dlgautoteach->ShowWindow(FALSE);
	dlgestop=new Cestop;
	dlgestop->Create(IDD_DIALOGESTOP, this);
	dlgestop->ShowWindow(FALSE);
	dlgmodeteach=new CTeachMode;
	dlgmodeteach->Create(IDD_TEACHMODE, this);
	dlgmodeteachset=new CModeTeachSet;
	dlgmodeteachset->Create(IDD_TEACHSET, this);
	dlgmodeteachset->GetWindowRect(rts);
	dlgmodeteachset->MoveWindow((rt.Width()-rts.Width())/2,
		(rt.Height()-rts.Height())/2,rts.Width(),rts.Height());
	dlgmodeteachsave=new CModeTeachSave;
	dlgmodeteachsave->Create(IDD_MODETEACHSAVE, this);
	dlgmodeteachsave->GetWindowRect(rts);
	dlgmodeteachsave->MoveWindow((rt.Width()-rts.Width())/2,
		(rt.Height()-rts.Height())/2,rts.Width(),rts.Height());
	dlgmodeteachsel=new CModeTeachSel;
	dlgmodeteachsel->Create(IDD_MODETEACHSEL, this);
	dlgmodeteachsel->GetWindowRect(rts);
	dlgmodeteachsel->MoveWindow((rt.Width()-rts.Width())/2,
		(rt.Height()-rts.Height())/2,rts.Width(),rts.Height());
	dlgsysparamsel=new CSysParamSel;
	dlgsysparamsel->Create(IDD_SYSPARAMSEL, this);
	dlgsysparamsel->GetWindowRect(rts);
	dlgsysparamsel->MoveWindow((rt.Width()-rts.Width())/2,
		(rt.Height()-rts.Height())/2,rts.Width(),rts.Height());
	dlgmotion=new CMotionParam;
	dlgmotion->Create(IDD_MOTIONPARAM, this);
	dlgcard=new CcardConfig;
	dlgcard->Create(IDD_CARDCONFIG, this);
	dlghomeconfig=new CHomeConfig;
	dlghomeconfig->Create(IDD_HOMECONFIG, this);
	dlgmac=new CMacParam;
	dlgmac->Create(IDD_MACPARAM, this);
	dlgencoder=new CEncoderConfig;
	dlgencoder->Create(IDD_ENCODERCONFIG, this);
	dlgcur=(CDialog *)dlghome;
	dlghomeret=(CDialog *)dlgmainfrm;
	OUTPUT0=0;
	OUTPUT1=0;
	OUTPUT2=0;
	OUTPUT3=0;
	DiagID=0;
	JogSpeed=10;
	MCC_SetSysMaxSpeed(300);//  set max. feed rate
//	MCC_SetSysMaxSpeed(100);//  set max. feed rate
//    Read_Flag=0;
    FileDataType=0;
    LoadRecords();
    Cchannel * pchannel=NULL;
    if(m_channels.Lookup(0, pchannel)) {
      if(pchannel) {    
// MX 
// Set Mechanism Parameters
    stMacParam.wPosToEncoderDir          = pchannel->m_pos;
	stMacParam.wRPM                      = pchannel->m_rpm;

⌨️ 快捷键说明

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