📄 cmobile.cpp
字号:
///////////////////////////////////////////////////////////////////
// WCDMA TEAM //
// BUPT Radio Research Center //
///////////////////////////////////////////////////////////////////
//
// CMobile.cpp
//
//////////////////////////////////////////////////////////////////////
// //
// 移动台基类CMobile的成员函数的声明 //
// //
// Written by: 李晶 //
// Date: 200405 //
// //
// What's NEW:与原先2000平台相比,增加了一些参数,并将一些原先在话音//
// 移动台和数据移动台中的类似的属性或方法都移至基类中实现//
// ,增强了代码的重用性并使程序较清晰。 //
// //
//////////////////////////////////////////////////////////////////////
#include "CMobile.h"
#include "iostream.h"
#include "Newran.h"
#include "sys_random.h"
#include "CMsManager.h"
#include <stdio.h>
#include <string.h>
//////////////////////////////////////////////////////////////////////////
// 构造函数 //
//////////////////////////////////////////////////////////////////////////
CMobile::CMobile()
{
}
//////////////////////////////////////////////////////////////////////////
// 析构函数 //
//////////////////////////////////////////////////////////////////////////
CMobile::~CMobile()
{
}
//////////////////////////////////////////////////////////////////////////
//TITLE: MobileInitialization(初始化函数)
//
//PARAMETERS:移动台ID,MsManager和ServiceArea的指针,信道类型,慢衰标准差
//
//PURPOSE AND ALGORITHMS:
// 调用其它函数,完成对MS的位置坐标,归属扇区标号,信道模型数据
// 的初始化,并根据MS的归属扇区对监测扇区数组成员数据进行初始化
//
//AUTHOR: Li Jing
//
//CALLING FUNCTIONS:
// CMobile::LocationGenerator()
// CMobile::LocationSector()
// CMobile::InitChannelModel()
// CMobile::InitMonitorSet()
//
//NOTES: 虽然ObtainBestSector(),InitActiveSet(),ObtainC2I()三个函数的
// 定义及实现都是放在移动台基类中,但是初始化移动台时还是把它们放
// 在话音移动台类中的初始化函数VoiceInitialization()中,而不是放在
// 基类中的初始化函数MobileInitialization()中。因为在初始化DSCH移
// 动台时就根本不需要初始化激活集InitActiveSet(),ObtainC2I()等
//
//Modified by zl 04/05(MM/YY)
//////////////////////////////////////////////////////////////////////////
void CMobile::MobileInitialization(
int i_inputMsID,
CMsManager* p_inputCMsManager,
CServiceArea* p_inputCServiceArea,
float f_inputMsVelocity,
int i_inputChannelType,
float f_inputStdSlowFading,
TotalUserType e_inputTotalUserType )
{
m_iSHOMsgNum=0; //当前软切换消息队列长度初始化为0
m_fC2I=0.0;
m_fMeanC2I=0.0; //将每帧(话音移动台)的平均的C/I初始为0
m_fTTIMeanC2I=0.0;
m_fIor2Ioc=0.0; //by zl 20050511
m_iAdmitTimer=0;
m_bIsAdmitted=false; //将是否接纳成功标识初始化为false,即还没有接纳成功
m_iNumOfErrorBlock=0; //初始化一个窗口时间内的误块数
m_iNumOfTotalBlock=0; //初始化一个窗口时间内的总块数
m_fWindowBLER=0.0; //初始化一个窗口时间内的误块率
//软切换下误块率相关统计量初始化add by slj 20041020
m_iNumOfSHOBlock = 0; //初始化处于软切换的总的传输块
m_iNumOfSHOFailedBlock = 0; //初始化处于软切换下传错的块数
m_fTotalPowerInSHO = 0.0; //初始化软切换下总的发射功率
for(int i=0;i<30;i++)
m_fTTIC2I[i]=0.0;
for( i=0;i<3;i++)
m_fHSTTIC2I[i]=0.0;
m_fTTIBLER=0.0;
m_iMsID=i_inputMsID; //对MS的ID进行初始化
m_pMsManager=p_inputCMsManager; //MsManager指针初始化
m_pServiceArea=p_inputCServiceArea; //ServiceArea指针初始化
m_iChannelType=i_inputChannelType; //对信道类型进行初始化
m_fMsVelocity=f_inputMsVelocity; //对移动台速率进行初始化
m_iSlotCount=1; //Slot记数器,设为1是因为VoiceProcess()从slot 1开始运行的
m_fStdSlowFading=f_inputStdSlowFading;//慢衰标准差
bool bFlag=false; //先将越界标记置为越界,当判断不越界后再将其置为不越界
while (!bFlag)
{
LocationGenerator(); //初始化移动台的位置坐标,产生方式为随机。没有考虑“热点”等非均匀方式
LocationSector(); //根据刚刚产生的归属坐标确定它的归属扇区标号
//by zl 20050512
float d=m_pMsManager->DistanceCaculte(m_stMsLocation,m_stLocationSector);
/*扩展至整个服务区 5×5个小区 by huangfan 20060405
//if ((m_stLocationSector.stCellID.m==3)&&(m_stLocationSector.stCellID.n==3))
if (((m_stLocationSector.stCellID.m==2)&&(m_stLocationSector.stCellID.n==2))|
((m_stLocationSector.stCellID.m==2)&&(m_stLocationSector.stCellID.n==3))|
((m_stLocationSector.stCellID.m==3)&&(m_stLocationSector.stCellID.n==2))|
((m_stLocationSector.stCellID.m==3)&&(m_stLocationSector.stCellID.n==3))|
((m_stLocationSector.stCellID.m==3)&&(m_stLocationSector.stCellID.n==4))|
((m_stLocationSector.stCellID.m==4)&&(m_stLocationSector.stCellID.n==2))|
((m_stLocationSector.stCellID.m==4)&&(m_stLocationSector.stCellID.n==3)))
//由中心一个小区扩展至七个 revised by HuangFan 20060404
{ //没有越界
*/
if ((m_stLocationSector.stCellID.m>=1)&&(m_stLocationSector.stCellID.m<=MM)&&
(m_stLocationSector.stCellID.n>=1)&&(m_stLocationSector.stCellID.n<=NN))
//小区行列数均为1~5
{
CSector* pSector=(m_pServiceArea->GetSector(m_stLocationSector));
switch( e_inputTotalUserType )
{
case T_voice:
if(pSector->m_iVoiceNum<m_pMsManager->GetVoiceNumPerSector())
{
pSector->m_iVoiceNum++;
bFlag=true;
} break;
case T_data:
if(pSector->m_iDCHNum<m_pMsManager->GetDCHDataNumPerSector())
{
pSector->m_iDCHNum++;
bFlag=true;
m_eUsertype=DCHData;
}
else if(pSector->m_iHSDSCHNum<m_pMsManager->GetHSDSCHDataNumPerSector())
{
/* //20051205
if(d<=0.25)
{
if(pSector->m_iSectorLocationNum[0]<4)
{
pSector->m_iHSDSCHNum++;
pSector->m_iSectorLocationNum[0] +=1;
m_iSectorLocationIndex=1;
bFlag=true;
m_eUsertype=HSDSCHData;
for(int i=0;i<4;i++)
{
if(!pSector->m_bSectorClassIndex[0][i])
{
pSector->m_bSectorClassIndex[0][i]=true;
m_iClassIndex=i+1;
break;
}
}
}
else{bFlag=false;}
break;
}
else if(d>0.25 && d<=0.5)
{
if(pSector->m_iSectorLocationNum[1]<4)
{
pSector->m_iHSDSCHNum++;
pSector->m_iSectorLocationNum[1]+=1;
m_iSectorLocationIndex=2;
bFlag=true;
m_eUsertype=HSDSCHData;
for(i=0;i<4;i++)
{
if(!pSector->m_bSectorClassIndex[1][i])
{
pSector->m_bSectorClassIndex[1][i]=true;
m_iClassIndex=i+1;
break;
}
}
}
else{bFlag=false;}
break;
}
else if(d>0.5 && d<=0.75)
{
if(pSector->m_iSectorLocationNum[2]<4)
{
pSector->m_iHSDSCHNum++;
pSector->m_iSectorLocationNum[2]+=1;
m_iSectorLocationIndex=3;
bFlag=true;
m_eUsertype=HSDSCHData;
for(i=0;i<4;i++)
{
if(!pSector->m_bSectorClassIndex[2][i])
{
pSector->m_bSectorClassIndex[2][i]=true;
m_iClassIndex=i+1;
break;
}
}
}
else{bFlag=false;}
break;
}
else
{bFlag=false;} */
bFlag=true;
m_eUsertype=HSDSCHData;
//20060112
m_iClassIndex=pSector->m_iSectorGradeIndex;
pSector->m_iSectorGradeIndex++;
if(pSector->m_iSectorGradeIndex==5)
{
pSector->m_iSectorGradeIndex=1;
}
//zl 20060308
if(m_enTrafficType==FTP)
{
if(d>0&&d<=0.7)
{
pSector->m_iFtpNum++;
if(pSector->m_iFtpNum>m_pMsManager->m_iFtpNuminSector)
{
bFlag=false;
}
}
else{bFlag=false;}
}
else if(m_enTrafficType==VIDEO)
{
if(d>0&&d<=0.7)
{
pSector->m_iVideoNum++;
if(pSector->m_iVideoNum>m_pMsManager->m_iVideoNuminSector)
{
bFlag=false;
}
}
else{bFlag=false;}
}
if(bFlag==true)
{
pSector->m_iHSDSCHNum++;
}
}
break;
default: break;
}
}
else{bFlag=false;}
}
//by HuangFan
cout<<m_stMsLocation.x<<","<<m_stMsLocation.y<<" ("
<<m_stLocationSector.stCellID.m<<","
<<m_stLocationSector.stCellID.n<<")"<<endl;
InitChannelModel(f_inputStdSlowFading,i_inputChannelType); //对MS的信道模型数据进行初始化,参数为慢衰标准差和信道类型
InitMonitorSet(); //根据MS的归属扇区所属的小区,对它的监测扇区数组成员数据进行初始化
}
//////////////////////////////////////////////////////////////////////////
//TITLE: LocationGenerator(坐标生成函数)
//
//PARAMETERS:NULL
//
//PURPOSE AND ALGORITHMS:
// 在移动台初始化时调用,随机产生移动台的坐标 ,考虑的是移动台均匀分布的情况
//
//AUTHOR: Li Jing
//
//CALLING FUNCTIONS:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -