mserial.cpp

来自「三容水箱的模糊控制设计」· C++ 代码 · 共 73 行

CPP
73
字号
// Mserial.cpp : implementation file
//

#include "stdafx.h"
#include "Watertank.h"
#include "Mserial.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMserial

IMPLEMENT_DYNCREATE(CMserial, CCmdTarget)

CMserial::CMserial()
{
 
	x[0]=0;
	x[1]=1;
	x[2]=1;
	x[3]=1;
	x[4]=1;
	x[5]=0;
	x[6]=1;
	x[7]=1;
	x[8]=1;
	x[9]=1;
	x[10]=1;
	OutData=0;
	Number=1;

}

CMserial::~CMserial()
{
}

double CMserial::Produce_Mserial()
{   int i;
    if(Number%1==0)
	{
		for(i=0;i<11;i++)
		y[i]=x[i];

	    for(i=1;i<11;i++)
		x[i]=y[i-1];

	    if(x[1]==x[10])
		x[0]=0;
    	else
		x[0]=1;
	}

	if(y[10]==0)
		OutData=-1.0;
	else
		OutData=1.0;
	Number++;
	return OutData;
}
BEGIN_MESSAGE_MAP(CMserial, CCmdTarget)
	//{{AFX_MSG_MAP(CMserial)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMserial message handlers

⌨️ 快捷键说明

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