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

📄 2leveldlg.cpp

📁 连轧过程控制仿真程序
💻 CPP
字号:
// 2levelDlg.cpp : implementation file
//

#include "stdafx.h"
#include "2level.h"
#include "2levelDlg.h"
#include "iostream.h"
#include "afx.h"
#include "distribution.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

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

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMy2levelDlg dialog

CMy2levelDlg::CMy2levelDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMy2levelDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMy2levelDlg)
	m_Power1 = 0.0;
	m_Power2 = 0.0;
	m_Power3 = 0.0;
	m_Power4 = 0.0;
	m_Power5 = 0.0;
	m_Press1 = 0.0;
	m_Press2 = 0.0;
	m_Press3 = 0.0;
	m_Press4 = 0.0;
	m_Press5 = 0.0;
	m_Speed1 = 0.0;
	m_Speed2 = 0.0;
	m_Speed3 = 0.0;
	m_Speed4 = 0.0;
	m_Speed5 = 0.0;
	m_Torque1 = 0.0;
	m_Torque2 = 0.0;
	m_Torque3 = 0.0;
	m_Torque4 = 0.0;
	m_Torque5 = 0.0;
	m_h1 = 0.0;
	m_h2 = 0.0;
	m_h3 = 0.0;
	m_h4 = 0.0;
	m_h5 = 0.0;
	m_Yield1 = 0.0;
	m_Yield2 = 0.0;
	m_Yield3 = 0.0;
	m_Yield4 = 0.0;
	m_Yield5 = 0.0;
	m_Time = 0;
	m_Slip1 = 0.0;
	m_Slip2 = 0.0;
	m_Slip3 = 0.0;
	m_Slip4 = 0.0;
	m_Slip5 = 0.0;
	m_value = 0.0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMy2levelDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMy2levelDlg)
	DDX_Text(pDX, IDC_Power1, m_Power1);
	DDX_Text(pDX, IDC_Power2, m_Power2);
	DDX_Text(pDX, IDC_Power3, m_Power3);
	DDX_Text(pDX, IDC_Power4, m_Power4);
	DDX_Text(pDX, IDC_Power5, m_Power5);
	DDX_Text(pDX, IDC_PRESS1, m_Press1);
	DDX_Text(pDX, IDC_PRESS2, m_Press2);
	DDX_Text(pDX, IDC_PRESS3, m_Press3);
	DDX_Text(pDX, IDC_PRESS4, m_Press4);
	DDX_Text(pDX, IDC_PRESS5, m_Press5);
	DDX_Text(pDX, IDC_Speed1, m_Speed1);
	DDX_Text(pDX, IDC_Speed2, m_Speed2);
	DDX_Text(pDX, IDC_Speed3, m_Speed3);
	DDX_Text(pDX, IDC_Speed4, m_Speed4);
	DDX_Text(pDX, IDC_Speed5, m_Speed5);
	DDX_Text(pDX, IDC_Torque1, m_Torque1);
	DDX_Text(pDX, IDC_Torque2, m_Torque2);
	DDX_Text(pDX, IDC_Torque3, m_Torque3);
	DDX_Text(pDX, IDC_Torque4, m_Torque4);
	DDX_Text(pDX, IDC_Torque5, m_Torque5);
	DDX_Text(pDX, IDC_Trickness1, m_h1);
	DDX_Text(pDX, IDC_Trickness2, m_h2);
	DDX_Text(pDX, IDC_Trickness3, m_h3);
	DDX_Text(pDX, IDC_Trickness4, m_h4);
	DDX_Text(pDX, IDC_Trickness5, m_h5);
	DDX_Text(pDX, IDC_Yield1, m_Yield1);
	DDX_Text(pDX, IDC_Yield2, m_Yield2);
	DDX_Text(pDX, IDC_Yield3, m_Yield3);
	DDX_Text(pDX, IDC_Yield4, m_Yield4);
	DDX_Text(pDX, IDC_Yield5, m_Yield5);
	DDX_Text(pDX, IDC_Time, m_Time);
	DDX_Text(pDX, IDC_Slip1, m_Slip1);
	DDX_Text(pDX, IDC_Slip2, m_Slip2);
	DDX_Text(pDX, IDC_Slip3, m_Slip3);
	DDX_Text(pDX, IDC_Slip4, m_Slip4);
	DDX_Text(pDX, IDC_Slip5, m_Slip5);
	DDX_Text(pDX, IDC_lable, m_value);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMy2levelDlg, CDialog)
	//{{AFX_MSG_MAP(CMy2levelDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_START, OnStart)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMy2levelDlg message handlers

BOOL CMy2levelDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMy2levelDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMy2levelDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMy2levelDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}


void CMy2levelDlg::OnStart()    //启动按钮
{
	
	global x;
	
	distribution dis;
	double H1=4.25;
	double h5=1.5;
	int i=1;
	//x=dis.distribute(H1,h5,500,1);
	x=dis.distribute(4.25,1.5,2,1);
	m_Power1 = x.W[0];
	m_Power2 = x.W[1];
	m_Power3 = x.W[2];
	m_Power4 = x.W[3];
	m_Power5 = x.W[4];
	m_Press1 = x.P[0];
	m_Press2 = x.P[1];
	m_Press3 = x.P[2];
	m_Press4 = x.P[3];
	m_Press5 = x.P[4];
	m_Speed1 = x.v[0];
	m_Speed2 = x.v[1];
	m_Speed3 = x.v[2];
	m_Speed4 = x.v[3];
	m_Speed5 = x.v[4];
	m_Torque1 = x.MM[0];
	m_Torque2 = x.MM[1];
	m_Torque3 = x.MM[2];
	m_Torque4 = x.MM[3];
	m_Torque5 = x.MM[4];
	m_h1 = x.h[0];
	m_h2 = x.h[1];
	m_h3 = x.h[2];
	m_h4 = x.h[3];
	m_h5 = x.h[4];
	m_Yield1 = x.de_drag[0];
	m_Yield2 = x.de_drag[1];
	m_Yield3 = x.de_drag[2];
	m_Yield4 = x.de_drag[3];
	m_Yield5 = x.de_drag[4];
	m_Slip1 = (x.v[0]-x.vr[0])/x.vr[0];
	m_Slip2 = (x.v[1]-x.vr[1])/x.vr[1];
	m_Slip3 = (x.v[2]-x.vr[2])/x.vr[2];
	m_Slip4 = (x.v[3]-x.vr[3])/x.vr[3];
	m_Slip5 = (x.v[4]-x.vr[4])/x.vr[4];
	m_Time=x.time;
	m_value = x.n[0];
	UpdateData(FALSE);

		
}

⌨️ 快捷键说明

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