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

📄 cnetworkdrive.cpp

📁 这是cdma2000的一个分组调度算法实例
💻 CPP
📖 第 1 页 / 共 4 页
字号:
}

/////////////////////////////////////////////////////////////////////////
//
//	TITLE:	Function of reading parameters
//
//	PURPOSE:Reading HTTP data mobiles' parameters from the data file
//
//	CALLED BY FUNCTIONS:
//			CNetworkDrive::ReadData()
//
//	COMMENTS:
//			The format of this part of data in the file is:
//			<begin>
//			6.HTTP移动台参数
//			HTTP用户的平均数据速率 = 40000 (bps)
//			alpha = 1.1
//			k = 4.5e3
//			m = 2e6
//			Packet call的平均间隔时间 = 5 (s)
//			Packet size = 1500 (octets)
//			<end>
//
//			Notes:
//			1.The first line should contain the specific string, (Here is
//			"").
//			2.On the left of '=' there must be the parameter name, which
//			should be typed exactly regardless of blank and tab.
//			3.On the right of '=' there must be the value of the parameter.
//			And between '=' and the figure there should be no other characters
//			than blank and tab.
//			4.The order of parameters should not be changed. And none of
//			them can be omitted.
//			5.You can insert some lines without '=' for comments. You can
//			also add strings after the figures which indicate some information
//			like unit.
//
//	AUTHOR:	Ouyang Hui
//
//	DATE:	01/04/06
//
//	MODIFICTIONS SINCE 01/04/06
//			01/05/21	m_MsManager.Set...=>m_MsManager.m_...
//
/////////////////////////////////////////////////////////////////////////

void CNetworkDrive::ReadData_HttpMs()
{
	int NUM_VALUE;
	const char* cSpecificString;
	bool bFlag;
	char* pname[15];
		
	double pval[15];
	CStdioFile f1;		//定义一个I/O文件对象
	CString s1,s2,s3;		//定义三个字符串对象
	double x;
	int i,j,k,iEqualPos;
	char* q;
	char buf[100];	//定义一个数据缓冲区,用于存放一行字符串

	/* 打开数据文件准备读*/
	if(!f1.Open(ParameterFile,CFile::modeRead))
	{
	#ifdef _DEBUG
		afxDump<<"Unable to open file"<<"\n";	//异常处理
	#endif
	}

	pname[0]="HTTP用户的平均数据速率";
	pname[1]="alpha";
	pname[2]="k";
	pname[3]="m";
	pname[4]="Packet call的平均间隔时间";
	pname[5]="Packet size";

	i=0;NUM_VALUE=6;
	cSpecificString="HTTP移动台参数";
	bFlag=FALSE;

	while(f1.ReadString(buf,100)!=NULL)
	{
		s1=buf; //把这一行字符串内容赋给对象s1
		if (s1.Find(cSpecificString)>=0) 
		{
			bFlag=TRUE;
			break;
		}
	}

	if (!bFlag)
	{
		cerr<<"Cannot find the specific string "<<cSpecificString<<endl;
		f1.Close();
		exit(0);
	}

	/*从数据文件依次读入每一行字符串,对每一行字符串进行处理*/
	while(f1.ReadString(buf,100)!=NULL)
	{
		if (i>=NUM_VALUE)
			break;

		s1=buf; //把这一行字符串内容赋给对象s1

		iEqualPos=s1.Find("=");
		if (iEqualPos<0)
			continue;

		s2=s1.Left(iEqualPos);
		s3=s1.Right(s1.GetLength()-iEqualPos-1);

		j=0;
		k=iEqualPos-1;
		while ((s2[j]==' ')||(s2[j]=='\t')) j++;
		while ((s2[k]==' ')||(s2[k]=='\t')) k--;
		s2=s2.Mid(j,k-j+1);

		if (s2!=pname[i]) 
		{
			cerr<<"Unexpected parameter name  "<<s2<<"."<<endl
				<<"Should be "<<pname[i]<<endl;
			f1.Close();
			exit(0);
		}

		x=strtod(s3,&q);

		pval[i]=x;
		i++;
	}

	m_MsManager.m_iHttpMeanPacketDataRate=(int)pval[0];
	m_MsManager.m_fAlpha=(float)pval[1];
	m_MsManager.m_fK=(float)pval[2];
	m_MsManager.m_iMaxDataBitsNum=(int)pval[3];
	m_MsManager.m_fMeanIntervalOfPacketCall=(float)pval[4];
	m_MsManager.m_iHttpPacketSize=(int)pval[5];
	

	f1.Close();//关闭参数文件
}

/////////////////////////////////////////////////////////////////////////
//
//	TITLE:	Funciton of reading parameters
//
//	PURPOSE:Reading soft handoff's and cell switch's parameters from the
//			data file.
//
//	CALLED BY FUNCTIONS:
//			CNetworkDrive::ReadData()
//
//	COMMENTS:
//			The format of this part of data in the file is:
//			<begin>
//			7.软切换与小区交换参数
//			激活集扇区个数 = 2
//			软切换加入的相对门限 = 3 (dB)
//			软切换去掉的相对门限 = 3 (dB)
//			软切换去掉定时器 = 0.1 (s)
//			软切换替换的相对门限 = 1 (dB)
//			软切换事件时延 = 0.2 (s)
//			小区交换事件时延 = 0.05 (s)
//			<end>
//
//			Notes:
//			1.The first line should contain the specific string, (Here is
//			"").
//			2.On the left of '=' there must be the parameter name, which
//			should be typed exactly regardless of blank and tab.
//			3.On the right of '=' there must be the value of the parameter.
//			And between '=' and the figure there should be no other characters
//			than blank and tab.
//			4.The order of parameters should not be changed. And none of
//			them can be omitted.
//			5.You can insert some lines without '=' for comments. You can
//			also add strings after the figures which indicate some information
//			like unit.
//
//	AUTHOR:	Ouyang Hui 
//
//	DATE:	01/04/06
//
//	MODIFICTIONS SINCE 01/04/06
//			01/05/21	m_MsManager.Set...=>m_MsManager.m_...
//
/////////////////////////////////////////////////////////////////////////

void CNetworkDrive::ReadData_Handoff()
{
	int NUM_VALUE;
	const char* cSpecificString;
	bool bFlag;
	char* pname[15];
		
	double pval[15];
	CStdioFile f1;		//定义一个I/O文件对象
	CString s1,s2,s3;		//定义三个字符串对象
	double x;
	int i,j,k,iEqualPos;
	char* q;
	char buf[100];	//定义一个数据缓冲区,用于存放一行字符串

	/* 打开数据文件准备读*/
	if(!f1.Open(ParameterFile,CFile::modeRead))
	{
	#ifdef _DEBUG
		afxDump<<"Unable to open file"<<"\n";	//异常处理
	#endif
	}

	pname[0]="激活集扇区个数";
	pname[1]="软切换加入的相对门限";
	pname[2]="软切换去掉的相对门限";
	pname[3]="软切换去掉定时器";
	pname[4]="软切换替换的相对门限";
	pname[5]="软切换事件时延";
	pname[6]="小区交换事件时延";

	i=0;NUM_VALUE=7;
	cSpecificString="软切换与小区交换参数";
	bFlag=FALSE;

	while(f1.ReadString(buf,100)!=NULL)
	{
		s1=buf; //把这一行字符串内容赋给对象s1
		if (s1.Find(cSpecificString)>=0) 
		{
			bFlag=TRUE;
			break;
		}
	}

	if (!bFlag)
	{
		cerr<<"Cannot find the specific string "<<cSpecificString<<endl;
		f1.Close();
		exit(0);
	}

	/*从数据文件依次读入每一行字符串,对每一行字符串进行处理*/
	while(f1.ReadString(buf,100)!=NULL)
	{
		if (i>=NUM_VALUE)
			break;

		s1=buf; //把这一行字符串内容赋给对象s1

		iEqualPos=s1.Find("=");
		if (iEqualPos<0)
			continue;

		s2=s1.Left(iEqualPos);
		s3=s1.Right(s1.GetLength()-iEqualPos-1);

		j=0;
		k=iEqualPos-1;
		while ((s2[j]==' ')||(s2[j]=='\t')) j++;
		while ((s2[k]==' ')||(s2[k]=='\t')) k--;
		s2=s2.Mid(j,k-j+1);

		if (s2!=pname[i]) 
		{
			cerr<<"Unexpected parameter name  "<<s2<<"."<<endl
				<<"Should be "<<pname[i]<<endl;
			f1.Close();
			exit(0);
		}

		x=strtod(s3,&q);

		pval[i]=x;
		i++;
	}

	m_MsManager.m_iActiveSetMaxSize=(int)pval[0];
	m_MsManager.m_fSHOAddThreshold=(float)pval[1];
	m_MsManager.m_fSHODeleteThreshold=(float)pval[2];
	m_MsManager.m_iSHODeleteTimer=(int)(pval[3]*1000/SlotSize);
	m_MsManager.m_fSHOSubstitutionThreshold=(float)pval[4];
	m_MsManager.m_iSoftHandoffDelay=(int)(pval[5]*1000/SlotSize);
	m_MsManager.m_iCellSwitchDelay=(int)(pval[6]*1000/SlotSize);

	f1.Close();//关闭参数文件
	
}

/////////////////////////////////////////////////////////////////////////
//
//	TITLE:
//
//	PURPOSE:
//
//	CALLED BY FUNCTIONS:
//			CNetworkDrive::ReadData()
//
//	COMMENTS:
//			The format of this part of data in the file is:
//			<begin>
//			8.数据统计参数
//			/数据采集的drop号 = 1
//			数据采集的时隙号 = 2
//			数据统计用文件个数 = 9
//			数据文件的路径与文件名 = linkpredictionresult.txt
//									meanthroughput.txt
//									meanper.txt
//									voicemsstfrate.txt
//									btspowersuperscale.txt
//									mobilec2i.txt
//									throughputservice.txt
//									throughputpacketcall.txt
//									voice.txt
//			<end>
//
//			Notes:
//			1.The first line should contain the specific string, (Here is
//			"").
//			2.On the left of '=' there must be the parameter name, which
//			should be typed exactly regardless of blank and tab.
//			3.On the right of '=' there must be the value of the parameter.
//			Here in the case of "数据文件的路径与文件名", that should be a
//			string. And between '=' and the figure or the string there should 
//			be no other characters than blank and tab.
//			4.The order of parameters should not be changed. And none of
//			them can be omitted.
//			5.You can insert some lines without '=' for comments. You can
//			also add strings after the figures which indicate some information
//			like unit.
//			6.The number of inputs of "数据文件的路径与文件名" should be equal
//			to "数据统计用文件个数".
//
//	AUTHOR:
//
//	DATE:	01/04/06
//
//	MODIFICTIONS SINCE 01/04/06
//
/////////////////////////////////////////////////////////////////////////

void CNetworkDrive::ReadData_Statics()
{
	int NUM_VALUE;
	const char* cSpecificString;
	bool bFlag;
	char* pname[15];
		
	double pval[15];
	CStdioFile f1;		//定义一个I/O文件对象
	CString s1,s2,s3;		//定义三个字符串对象
	double x;
	int i,j,k,iEqualPos;
	char* q;
	char buf[100];	//定义一个数据缓冲区,用于存放一行字符串

//	cout<<ParameterFile<<endl;

	pname[0]="数据采集的drop号";
	pname[1]="数据采集的时隙号";
	pname[2]="数据统计用文件个数";
	pname[3]="数据文件的路径与文件名";

	char datafilename[15][40];

	i=0;NUM_VALUE=4;
	cSpecificString="数据统计参数";
	bFlag=FALSE;

	/* 打开数据文件准备读*/
	if(!f1.Open(ParameterFile,CFile::modeRead))
	{
	#ifdef _DEBUG
		afxDump<<"Unable to open file"<<"\n";	//异常处理
	#endif
	}

	while(f1.ReadString(buf,100)!=NULL)
	{
		s1=buf; //把这一行字符串内容赋给对象s1
		if (s1.Find(cSpecificString)>=0) 
		{
			bFlag=TRUE;
			break;
		}
	}

	if (!bFlag)
	{
		cerr<<"Cannot find the specific string "<<cSpecificString<<endl;
		f1.Close();
		exit(1);
	}
	
	/*从数据文件依次读入每一行字符串,对每一行字符串进行处理*/
	while(f1.ReadString(buf,100)!=NULL)
	{
		if (i>=NUM_VALUE)
			break;

		s1=buf; //把这一行字符串内容赋给对象s1

		iEqualPos=s1.Find("=");
		if (iEqualPos<0)
			continue;

		s2=s1.Left(iEqualPos);
		s3=s1.Right(s1.GetLength()-iEqualPos-1);

		j=0;
		k=iEqualPos-1;
		while ((s2[j]==' ')||(s2[j]=='\t')) j++;
		while ((s2[k]==' ')||(s2[k]=='\t')) k--;
		s2=s2.Mid(j,k-j+1);

		if (s2!=pname[i]) 
		{
			cerr<<"Unexpected parameter name  "<<s2<<"."<<endl
				<<"Should be "<<pname[i]<<endl;
			f1.Close();
			exit(0);
		}

		if (i<3)
			x=strtod(s3,&q);
		int m;
		if (i==3)
		{
			k=0;
				m=s3.GetLength()-1;
				while ((s3[k]==' ')||(s3[k]=='\t')) k++;
				while ((s3[m]==' ')||(s3[m]=='\t')||(s3[m]=='\n')) m--;
				s3=s3.Mid(k,m-k+1);


			strcpy(datafilename[0],s3);
			for (j=1;j<pval[2];j++)
			{
				f1.ReadString(buf,100);
				s3=buf;
				k=0;
				m=s3.GetLength()-1;
				while ((s3[k]==' ')||(s3[k]=='\t')) k++;
				while ((s3[m]==' ')||(s3[m]=='\t')||(s3[m]=='\n')) m--;
				s3=s3.Mid(k,m-k+1);

				strcpy(datafilename[j],s3);
			}
		}

		pval[i]=x;
		i++;
	}


	m_iDataStaticsDropNum=(int)pval[0];

⌨️ 快捷键说明

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