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

📄 system.cpp

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

#include "stdafx.h"
#include "alfa.h"
#include "System.h"
#include "ExitSystem.h"
#include "SystemPara.h"
#include "Main.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

/////////////////////////////////////////////////////////////////////////////
// CSystem dialog


CSystem::CSystem(CWnd* pParent /*=NULL*/)
	: CDialog(CSystem::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSystem)
	m_static1 = _T("");
	m_static2 = _T("");
	//}}AFX_DATA_INIT
}


void CSystem::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSystem)
	DDX_Control(pDX, IDC_RADIO2, m_radio2);
	DDX_Control(pDX, IDC_RADIO1, m_radio1);
	DDX_Text(pDX, IDC_STATIC1, m_static1);
	DDX_Text(pDX, IDC_STATIC2, m_static2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSystem, CDialog)
	//{{AFX_MSG_MAP(CSystem)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_WM_SHOWWINDOW()
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSystem message handlers

void CSystem::OnButton1() 
{
	// TODO: Add your control notification handler code here
    CMain * main=(CMain *)GetParent();
	ShowWindow(FALSE);
	main->dlgexitsystem->ShowWindow(TRUE);
}

void CSystem::OnButton3() 
{
	// TODO: Add your control notification handler code here
	CMain * main=(CMain *)GetParent();
	ShowWindow(FALSE);
	main->dlgsystempwd->ShowWindow(TRUE);
}

void CSystem::OnRadio1() 
{
	// TODO: Add your control notification handler code here
	m_radio1.SetCheck(1);
	m_radio2.SetCheck(0);
    glb.m_num=FileNameSys;
    glb.m_Valid=ModeSys;
    glb.m_MoldCount=MoldCountCur;
    glb.m_MoldTotal=MoldCountSet;
    glb.m_MoldSet=MoldSet;                
    glb.m_MoldStack1=MoldStack1;          
    glb.m_MoldStack2=MoldStack2;          
    glb.m_Reserved1=MoldReserv1;          
    glb.m_Reserved2=MoldReserv2; 
	MoldReserv3=1;
    glb.m_Reserved3=MoldReserv3; 
    glb.m_LogIndex=AlmLogIndex;  
    for(int i=0; i<50; i++) {
        glb.m_LogTime[i]=AlmLogTime[i];
        glb.m_LogID[i]=AlmLogID[i];
	} 
	SaveRecords();
}

void CSystem::OnRadio2() 
{
	// TODO: Add your control notification handler code here
	m_radio1.SetCheck(0);
	m_radio2.SetCheck(1);
	    glb.m_num=FileNameSys;
    glb.m_Valid=ModeSys;
    glb.m_MoldCount=MoldCountCur;
    glb.m_MoldTotal=MoldCountSet;
    glb.m_MoldSet=MoldSet;                
    glb.m_MoldStack1=MoldStack1;          
    glb.m_MoldStack2=MoldStack2;          
    glb.m_Reserved1=MoldReserv1;          
    glb.m_Reserved2=MoldReserv2;  
	MoldReserv3=0;
    glb.m_Reserved3=MoldReserv3; 
    glb.m_LogIndex=AlmLogIndex;  
    for(int i=0; i<50; i++) {
        glb.m_LogTime[i]=AlmLogTime[i];
        glb.m_LogID[i]=AlmLogID[i];
	} 
	SaveRecords();
}

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

void CSystem::OnButton2() 
{
	// TODO: Add your control notification handler code here
	ShowWindow(FALSE);
	CMain * main=(CMain *)GetParent();
	main->dlgfault->ShowWindow(TRUE);
}

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

		if(MoldReserv3==1) {
	        m_radio1.SetCheck(1);
	        m_radio2.SetCheck(0);
		}
		else {
	        m_radio1.SetCheck(0);
	        m_radio2.SetCheck(1);
		}

		m_static1.Format("%ld", MoldCountSet);
		m_static2=MakerDate;
		UpdateData(FALSE);
	}
}

void CSystem::OnButton4() 
{
	// TODO: Add your control notification handler code here
	CMain * main=(CMain *)GetParent();
	ShowWindow(FALSE);
	if(HomeOKflg==1) 
	  main->dlgmainfrm->ShowWindow(TRUE);
	else 
      main->dlghome->ShowWindow(TRUE);

//	main->dlgmainfrm->ShowWindow(TRUE);
}


BOOL CSystem::CanSerialize()
{
//  return(0==_access(SYSTEM_FILE,10));
 	return(0==_access(DATAGLB_FILE, 6));
}


void CSystem::Serialize(CArchive& ar) 
{
	glb.Serialize(ar);
}


void CSystem::SaveRecords()
{
    BOOL bCansave;
    int flag=CFile::typeBinary|CFile::modeWrite;

    if(_access(DATAGLB_FILE, 0)) {
       flag|=CFile::modeCreate;
       bCansave=TRUE;
	}
    else {
        bCansave=CanSerialize();
	}
    if(bCansave) {
        CFile file;
        CFileException fe;
        if(file.Open(DATAGLB_FILE, flag, &fe)) {
	        CArchive ar(&file, CArchive::store);
	        Serialize(ar);
		}
	}
}

⌨️ 快捷键说明

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