📄 cnetworkdrive.cpp
字号:
// 0.10 (Pedestrian A, 1 Finger, 120 kmph)
// 0.10 (Single path, 1 Finger, 0)
// SNR与PER的关系表格文件 = snr-per_table1.txt
// snr-per_table2.txt
// snr-per_table3.txt
// snr-per_table4.txt
// snr-per_table5.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 "SNR与PER的关系表格文件", 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 "SNR与PER的关系表格文件" and
// "每种信道类型所占的比例" should be the same as "信道类型的数量".
//
// AUTHOR: Ouyang Hui
//
// DATE: 01/04/06
//
// MODIFICTIONS SINCE 01/04/06
// 01/05/21 m_MsManager.Set...=>m_MsManager.m_...
//
/////////////////////////////////////////////////////////////////////////
void CNetworkDrive::ReadData_ChannelModel()
{
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]="SNR与PER的关系表格文件";
i=0;NUM_VALUE=4;
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 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)&&(i<2))
continue;
if (i<2)
s2=s1.Left(iEqualPos);
s3=s1.Right(s1.GetLength()-iEqualPos-1);
if (i<2)
{
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)
{
j=0;
x=strtod(s3,&q);
}
if (i<2)
pval[i]=x;
int m;
if (i==2)
{
m_MsManager.m_fFractionOfChannel[0]=(float)x;
for (j=1;j<(int)pval[1];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')) k--;
s3=s3.Mid(k,m-k+1);
m_MsManager.m_fFractionOfChannel[j]=(float)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);
m_LinkPrediction.SetRate_BLERPredictionFileName(
s3.GetBuffer(s3.GetLength()));
// for (j=1;j<pval[1];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);
// m_LinkPrediction[j].SetRate_BLERPredictionFileName(
// s3.GetBuffer(s3.GetLength()));
// }
}
i++;
}
m_MsManager.m_fStdSlowFading=(float)pval[0];
m_MsManager.m_iChannelNumber=(int)pval[1];
f1.Close();
}
/////////////////////////////////////////////////////////////////////////
//
// TITLE: Function of Reading Parameters
//
// PURPOSE:Reading Voice Mobiles' parameters from the data file.
//
// CALLED BY FUNCTIONS:
// CNetworkDrive::ReadData()
//
// COMMENTS:
// The format of this part of data in the file is:
// <begin>
// 4.话音移动台参数
// 话音业务速率 = 9.6e3 (bps)
// 话音业务扩频增益 = 21.1 (dB)
// 话音业务门限Eb/No = 6 (dB)
// 话音业务门限C/I = -15.5 (dB)
// 话音业务功率控制的目标C/I = -15 (dB)
// 话音业务信道的最大功率比例 = 0.05
// 话音业务信道功率的动态范围 = 25 (dB)
// 功率控制的步长 = 1 (dB)
// 话音激活因子 = 0.4
// 话音静默系数 = 0
// 功率控制差错概率 = 0.04
// <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_VoiceMs()
{
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]="话音业务门限Eb/No";
pname[3]="话音业务门限C/I";
pname[4]="话音业务功率控制的目标C/I";
pname[5]="话音业务信道的最大功率比例";
pname[6]="话音业务信道功率的动态范围";
pname[7]="功率控制的步长";
pname[8]="话音激活因子";
pname[9]="话音静默系数";
pname[10]="功率控制差错概率";
i=0;NUM_VALUE=11;
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_fC2IThreshold=(float)pval[3];
m_MsManager.m_fC2ITarget=(float)pval[4];
m_MsManager.m_fMaxFractionOfTrafficPower=(float)pval[5];
m_MsManager.m_fDynamicRangeOfTrafficPower=(float)pval[6];
m_MsManager.m_fPowerControlStep=(float)pval[7];
m_MsManager.m_fVoiceActiveFactor=(float)pval[8];
m_MsManager.m_fBEROfPC=(float)pval[10];
f1.Close();
}
/////////////////////////////////////////////////////////////////////////
//
// TITLE: Function of Reading Parameters
//
// PURPOSE:Reading 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>
// 5.数据业务移动台参数
// 子包的最大重传次数 = 4
// ACK/NAK的差错概率 = 0
// 8PSK高阶调制的修正参数 = -2.4 (dB)
// 16QAM高阶调制的修正参数 = -3.2 (dB)
// <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_DataMs()
{
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]="ACK/NAK的差错概率";
pname[2]="8PSK高阶调制的修正参数";
pname[3]="16QAM高阶调制的修正参数";
i=0;NUM_VALUE=4;
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_iMaxTransmissionNum=(int)pval[0];
m_MsManager.m_fErrorRateOfFeedBack=(float)pval[1];
m_MsManager.m_fFudgetFactorOf8PSK=(float)pval[2];
m_MsManager.m_fFudgetFactorOf16QAM=(float)pval[3];
f1.Close();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -