ģ

来自「用于模拟交通的排队」· 代码 · 共 121 行

TXT
121
字号
// 模拟View.h : interface of the CMyView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_VIEW_H__D5190E6B_AAD8_42AB_8F70_217DA40DA33B__INCLUDED_)
#define AFX_VIEW_H__D5190E6B_AAD8_42AB_8F70_217DA40DA33B__INCLUDED_

#include "ParaDlg.h"
#include <stdlib.h>
#include <time.h>
#include "模拟doc.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define Tinterval 0.1   //时间间隔(用于始终)
#define MAXLEN 4    //最大队长
#define TEL 2   //窗口数
#define ServerPara 0.09    //正态分布的模拟参数

class CMyView : public CHtmlView
{
protected: // create from serialization only
	CMyView();
	DECLARE_DYNCREATE(CMyView)

// Attributes
public:
	CMyDoc* GetDocument();
private:
	//以下3个在SetParameter中设置
	float ArrivePara;    //指数分布的模拟参数
	BOOL hasBegain;    //模拟是否已经开始
	BOOL hasEnd;    //模拟是否已经结束
	int Length;    //窗口服务总时间
	float Marrvt;    //顾客平均到达间隔时间
	float Mservt;    //顾客平均服务时间
	//以下参数需要在Init中设置
	long Tnum;    //当前模拟时间
	int ChangeQueue_num;    //换队的顾客数目
	int LeaveQueue_num;    //因为排满而离开的顾客数目
	int noWait_num;    //没有等待就可以服务的顾客数
	int wait_num;    //需要等待才可以接受服务的顾客数目
	int leaveServer_num;    //完成服务的顾客数目
	long TotalWaitT;    //享受完服务的顾客总共等待时间
	long TotalServerT;    //享受完服务的顾客总共接受服务的时间
	//服务台
	struct SERVER{
		BOOL status;    //服务状态
		long sumBusyT;    //处于忙态的时间总和
		long begainBusyT;    //如果status为TRUE(忙)指当前开始忙的时间
	};
	SERVER server[TEL];
	//顾客
	struct CLIENT{
		int arriveT;    //到达时间
		int serverT;    //开始服务时间
		int leaveT;    //离开时间
	};
	//队列
	struct QUEUE{
		int length;  //对长
		CLIENT client[MAXLEN];
	};
	QUEUE queue[TEL];
// Operations
public:
	void Init();    //初始化子程序
	void Stop();    //结束模拟
	void Arrive();    //顾客到达
	void Epart(int nQueu);    //顾客离去
	void Jockey(int formQueu,int toQueu);    //顾客换队
	void ShowPic(CString id,BOOL isShow=TRUE);
// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMyView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	virtual void OnInitialUpdate(); // called first time after construct
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CMyView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CMyView)
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnSetParameter();
	afx_msg void OnButBegain();
	afx_msg void OnFileBegain();
	afx_msg void OnFileStop();
	afx_msg void OnButtonEnd();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in 模拟View.cpp
inline CMyDoc* CMyView::GetDocument()
   { return (CMyDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_VIEW_H__D5190E6B_AAD8_42AB_8F70_217DA40DA33B__INCLUDED_)

⌨️ 快捷键说明

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