www.pudn.com > roll.rar > DYNPARA.CPP


// DynPara.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "roll.h" 
#include "bbroll.h" 
#include "DynPara.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CDynPara dialog 
 
CDynPara::CDynPara(CWnd* pParent /*=NULL*/) 
	: CDialog(CDynPara::IDD, pParent) 
{ 
	m_numteeth = 3; 
	char pFileName[] = "rolldyn.dat"; 
	CStdioFile f; 
	if( !f.Open( pFileName, CFile::modeRead | CFile::typeBinary ) ) { 
		m_hole1 = theRoll.m_thick; 
		m_hole2 = m_hole1; 
		m_teethnum1 = theRoll.m_teethnum; 
		m_teethnum2 = m_teethnum1; 
		m_zmoment=1.0e6; 
		m_moment=1.0e7; 
		m_force=1.0e5; 
		m_friction=0.4; 
		m_L1=22; 
		m_L2=22; 
		m_xp=345; 
		m_yp=140; 
	} 
	else { 
		f.Read(&m_teethnum1,sizeof(int)); 
		f.Read(&m_teethnum2,sizeof(int)); 
		f.Read(&m_hole1,sizeof(double)); 
		f.Read(&m_hole2,sizeof(double)); 
		f.Read(&m_zmoment,sizeof(double)); 
		f.Read(&m_moment,sizeof(double)); 
		f.Read(&m_force,sizeof(double)); 
		f.Read(&m_friction,sizeof(double)); 
		f.Read(&m_L1,sizeof(double)); 
		f.Read(&m_L2,sizeof(double)); 
		f.Read(&m_xp,sizeof(double)); 
		f.Read(&m_yp,sizeof(double)); 
		f.Close(); 
	} 
} 
 
 
void CDynPara::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CDynPara) 
	DDX_Text(pDX, IDC_HL1, m_hole1); 
	DDX_Text(pDX, IDC_HL2, m_hole2); 
	DDX_Text(pDX, IDC_Z1, m_teethnum1); 
	DDV_MinMaxInt(pDX, m_teethnum1, 3, 3000); 
	DDX_Text(pDX, IDC_Z2, m_teethnum2); 
	DDV_MinMaxInt(pDX, m_teethnum2, 3, 3000); 
	DDX_Text(pDX, IDC_NUMTEETH, m_numteeth); 
	DDX_Text(pDX, IDC_MOMENT, m_moment); 
	DDX_Text(pDX, IDC_FORCE, m_force); 
	DDX_Text(pDX, IDC_L1, m_L1); 
	DDX_Text(pDX, IDC_L2, m_L2); 
	DDX_Text(pDX, IDC_XP, m_xp); 
	DDX_Text(pDX, IDC_YP, m_yp); 
	DDX_Text(pDX, IDC_COEFF, m_friction); 
	DDX_Text(pDX, IDC_ZMOMENT, m_zmoment); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CDynPara, CDialog) 
	//{{AFX_MSG_MAP(CDynPara) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CDynPara message handlers 
 
void CDynPara::OnOK()  
{ 
	CDialog::OnOK(); 
 
	char pFileName[] = "rolldyn.dat"; 
	CStdioFile f; 
	if(f.Open(pFileName, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary)) { 
		f.Write(&m_teethnum1,sizeof(int)); 
		f.Write(&m_teethnum2,sizeof(int)); 
		f.Write(&m_hole1,sizeof(double)); 
		f.Write(&m_hole2,sizeof(double)); 
		f.Write(&m_zmoment,sizeof(double)); 
		f.Write(&m_moment,sizeof(double)); 
		f.Write(&m_force,sizeof(double)); 
		f.Write(&m_friction,sizeof(double)); 
		f.Write(&m_L1,sizeof(double)); 
		f.Write(&m_L2,sizeof(double)); 
		f.Write(&m_xp,sizeof(double)); 
		f.Write(&m_yp,sizeof(double)); 
		f.Close(); 
	}	 
}