📄 cmobile.cpp
字号:
!=m_aNeighborSector[j].stSectorID.s))//是本小区中的邻扇区
{
m_aCandidateSector[i].aiNeighborSet[k]=j; //记录下标
k++;
m_aCandidateSector[i].fInterferenceFromOtherSector+=
m_aNeighborSector[j].fPowerFromTheSector;
//计算从本扇区来的干扰功率
}
if((m_aCandidateSector[i].stSectorID.stCellID.m
==m_aNeighborSector[j].stSectorID.stCellID.m)
&&(m_aCandidateSector[i].stSectorID.stCellID.n
==m_aNeighborSector[j].stSectorID.stCellID.n)
&&(m_aCandidateSector[i].stSectorID.s
==m_aNeighborSector[j].stSectorID.s))//是候选扇区
{
fFastFading=(m_aNeighborSector[j].fFastFading[0]
+m_aNeighborSector[j].fFastFading[1]
+m_aNeighborSector[j].fFastFading[2]
+m_aNeighborSector[j].fFastFading[3])/(float)4;
m_aCandidateSector[i].fPilotPower
=m_pServiceArea
->GetSector(m_aCandidateSector[i].stSectorID)
->GetPilotPower()
*m_aNeighborSector[j].fPropagationLoss
*fFastFading;
//候选扇区到达MS的导频功率
fOtherChannelPower=m_pServiceArea
->GetSector(m_aCandidateSector[i].stSectorID)
->GetTxPower()*
m_aNeighborSector[j].fPropagationLoss*fFastFading
-m_aCandidateSector[i].fPilotPower;
//本候选扇区其他信道到达MS的功率
}
}
for(m=0;m<6;m++)
{
stTempCell
=m_pServiceArea
->GetNeighbor(m_aCandidateSector[i].stSectorID.stCellID,m);
for(j=0;j<19*SectorNumber;j++)
if((stTempCell.m
==m_aNeighborSector[j].stSectorID.stCellID.m)
&&(stTempCell.n
==m_aNeighborSector[j].stSectorID.stCellID.n))
//与候选扇区相邻的小区中的扇区
{
m_aCandidateSector[i].aiNeighborSet[k]=j; //记录下标
k++;
m_aCandidateSector[i].fInterferenceFromOtherSector+=
m_aNeighborSector[j].fPowerFromTheSector;
//计算从其他扇区来的干扰功率
}
}
fOrthogonalFactor=m_pServiceArea->GetOrthogonalFactor();
//本扇区的正交因子
m_aCandidateSector[i].fPilotSNR
=(float)(m_aCandidateSector[i].fPilotPower
/(fOtherChannelPower/**fOrthogonalFactor*/
+m_aCandidateSector[i].fInterferenceFromOtherSector
+NoisePower)); //本侯选扇区到达MS的SNR
m_aCandidateSector[i].fPilotSNR
=(float)(10*log10(m_aCandidateSector[i].fPilotSNR));//转化为dB值
m_aCandidateSector[i].bIsInActive=false;
//是否在激活集的标志初始化
m_aCandidateSector[i].iStatusTimer=0;
//状态改变记数器初始化
m_aCandidateSector[i].bIsBestSector=false;
//是否是最佳基站初始化
}
ObtainBestSector(); //得到最佳扇区
}
// end of InitCadidateSet()
//////////////////////////////////////////////////////////////////////////
// 相邻集信息更新函数 //
// 更新相邻集数组中各项的快衰、慢衰、总损耗和接收功率值。 //
//////////////////////////////////////////////////////////////////////////
void CMobile::UpdateNeighborSet()
{
int i,j,k;
m_iSlotCount++;
m_pFadingValuePointer=m_ChannelModel.GetFadingValues(m_iSlotCount);
//获得衰落数组(后续值)的首地址
for(i=0;i<19;i++) //循环19次(相邻集小区的个数)
{
for(j=0;j<SectorNumber;j++)
{
m_aNeighborSector[i*SectorNumber+j].fSlowFading
=m_pFadingValuePointer[i].fSlowFading;//将属性中慢衰值更新
for(k=0;k<SubslotNumber;k++)
m_aNeighborSector[i*SectorNumber+j].fFastFading[k]
=m_pFadingValuePointer[i].fFastFadingSet[j][k];
//将属性中快衰值更新
m_aNeighborSector[i*SectorNumber+j].fPropagationLoss
=m_aNeighborSector[i*SectorNumber+j].fPathLoss
*m_aNeighborSector[i*SectorNumber+j].fAntennaGain
*m_aNeighborSector[i*SectorNumber+j].fSlowFading
*(float)pow(10,(MsAntennaGain-OtherLosses)/10);
//总的损耗值更新
m_aNeighborSector[i*SectorNumber+j].fPowerFromTheSector
=m_pServiceArea
->GetSector(m_aNeighborSector[i*SectorNumber+j].stSectorID)
->GetTxPower()
*m_aNeighborSector[i*SectorNumber+j].fPropagationLoss
*(m_aNeighborSector[i*SectorNumber+j].fFastFading[0]
+m_aNeighborSector[i*SectorNumber+j].fFastFading[1]
+m_aNeighborSector[i*SectorNumber+j].fFastFading[2]
+m_aNeighborSector[i*SectorNumber+j].fFastFading[3])/(float)4;
//扇区到达移动台的总功率为=发射功率*总的损耗
}
}
}
// end of UpdateNeighborSet()
//////////////////////////////////////////////////////////////////////////
// 候选集更新函数 //
// 更新候选集数组中各项的干扰、功率与信噪比。 //
//////////////////////////////////////////////////////////////////////////
void CMobile::UpdateCandidateSet()
{
int i,j;
float fOtherChannelPower;
float fOrthogonalFactor;
float fFastFading;
SECTORID_TYPE tempSectorID;
tempSectorID.s=1;
tempSectorID.stCellID.m=3;
tempSectorID.stCellID.n=3;
for(i=0;i<6+SectorNumber;i++) //第i个候选扇区
{
m_aCandidateSector[i].fInterferenceFromOtherSector=0;
//其他扇区来的干扰累加前置0
for(j=0;j<7*SectorNumber-1;j++)//hoho
m_aCandidateSector[i].fInterferenceFromOtherSector+=
m_aNeighborSector[m_aCandidateSector[i].aiNeighborSet[j]].
fPowerFromTheSector; //累加其他扇区来的干扰
for(j=0;j<19*SectorNumber;j++)
{
if((m_aCandidateSector[i].stSectorID.stCellID.m
==m_aNeighborSector[j].stSectorID.stCellID.m)
&&(m_aCandidateSector[i].stSectorID.stCellID.n
==m_aNeighborSector[j].stSectorID.stCellID.n)
&&(m_aCandidateSector[i].stSectorID.s
==m_aNeighborSector[j].stSectorID.s))//是候选扇区
{
fFastFading=(m_aNeighborSector[j].fFastFading[0]
+m_aNeighborSector[j].fFastFading[1]
+m_aNeighborSector[j].fFastFading[2]
+m_aNeighborSector[j].fFastFading[3])/(float)4;
m_aCandidateSector[i].fPilotPower
=m_pServiceArea
->GetSector(m_aCandidateSector[i].stSectorID)
->GetPilotPower()
*m_aNeighborSector[j].fPropagationLoss*fFastFading;
//候选扇区到达MS的导频功率
fOtherChannelPower
=m_pServiceArea
->GetSector(m_aCandidateSector[i].stSectorID)
->GetTxPower()
*m_aNeighborSector[j].fPropagationLoss*fFastFading
-m_aCandidateSector[i].fPilotPower;
//本候选扇区其他信道到达MS的功率
break;
}
}
fOrthogonalFactor
=m_pServiceArea->GetOrthogonalFactor(); //本扇区的正交因子
m_aCandidateSector[i].fPilotSNR
=(float)(m_aCandidateSector[i].fPilotPower
/(fOtherChannelPower/**fOrthogonalFactor*/
+m_aCandidateSector[i].fInterferenceFromOtherSector+NoisePower));
//更新本侯选扇区到达MS的SNR
m_aCandidateSector[i].fPilotSNR
=(float)(10*log10(m_aCandidateSector[i].fPilotSNR));
//转化为dB
m_aCandidateSector[i].bIsBestSector=false;
//是否是最佳基站更新
}
ObtainBestSector(); //得到最佳扇区
}
// end of UpdateCandidateSet()
//////////////////////////////////////////////////////////////////////////
// 最佳扇区计算函数 //
// 根据候选集信息找出最佳扇区,确定标号和下标。 //
//////////////////////////////////////////////////////////////////////////
void CMobile::ObtainBestSector()
{
float fMaxPilotSNR=-1000.;
int iBestSectorIndex;
int i;
SECTORID_TYPE stBestSector;
for(i=0;i<6+SectorNumber;i++)
if(m_aCandidateSector[i].fPilotSNR>fMaxPilotSNR)
{
fMaxPilotSNR=m_aCandidateSector[i].fPilotSNR;
//记录循环到当前时刻的最大fPilotSNR
iBestSectorIndex=i;
//及扇区在侯选数组中的标号
stBestSector=m_aCandidateSector[i].stSectorID;
}
m_aCandidateSector[iBestSectorIndex].bIsBestSector=true;
//是最佳扇区
m_aCandidateSector[iBestSectorIndex].bIsInActive=false;
//在对激活激活集操作中在修改bIsInActive标志
m_iBestSectorIndex=iBestSectorIndex;
//最佳扇区在候选集中的下标
m_stBestSector=stBestSector;
//最佳扇区的扇区号
m_fBestPilotSNR=fMaxPilotSNR; //最佳扇区的PilotSNR
// if(fMaxPilotSNR<-16)
// cout<<fMaxPilotSNR<<endl;
}
// end of ObtainBestSector()
//////////////////////////////////////////////////////////////////////////
// get(), set() //
//////////////////////////////////////////////////////////////////////////
int CMobile::GetMsID()
{
return m_iMsID;
}
void CMobile::SetMsID(int i_inputMsID)
{
m_iMsID = i_inputMsID;
}
//-----------------------------------
LOCATION_TYPE CMobile::GetMsLocation()
{
return m_stMsLocation;
}
void CMobile::SetMsLocation(LOCATION_TYPE st_inputMsLoc)
{
m_stMsLocation = st_inputMsLoc;
}
//-----------------------------------
CMsManager* CMobile::GetMsManager()
{
return m_pMsManager;
}
void CMobile::SetMsManager(CMsManager* p_inputMsManager)
{
m_pMsManager = p_inputMsManager;
}
//-----------------------------------
CServiceArea* CMobile::GetServiceArea()
{
return m_pServiceArea;
}
void CMobile::SetServiceArea(CServiceArea* p_inputServiceArea)
{
m_pServiceArea = p_inputServiceArea;
}
//-----------------------------------
CChannelModel CMobile::GetChannelModel()
{
return m_ChannelModel;
}
void CMobile::SetChannelModel(CChannelModel inputChannelModel)
{
m_ChannelModel = inputChannelModel;
}
//-----------------------------------
FADINGVALUE_TYPE* CMobile::GetFadingValuePointer()
{
return m_pFadingValuePointer;
}
void CMobile::SetFadingValuePointer(FADINGVALUE_TYPE* p_inputFadingVal)
{
m_pFadingValuePointer = p_inputFadingVal;
}
//------------------------------------
NEIGHBORSECTOR_TYPE CMobile::GetNeighborSector()
{
return *m_aNeighborSector;
}
void CMobile::SetNeighborSector()
{
//to do...
}
//-----------------------------------
CANDIDATESECTOR_TYPE CMobile::GetCandidateSector()
{
return *m_aCandidateSector;
}
void CMobile::SetCandidateSector()
{
//to do...
}
//-----------------------------------
SECTORID_TYPE CMobile::GetLocationSector()
{
return m_stLocationSector;
}
void CMobile::SetLocationSector(SECTORID_TYPE st_inputLocSector)
{
m_stLocationSector = st_inputLocSector;
}
//-----------------------------------
SECTORID_TYPE CMobile::GetBestSector()
{
return m_stBestSector;
}
void CMobile::SetBestSector(SECTORID_TYPE st_inputBestSector)
{
m_stBestSector = st_inputBestSector;
}
//-----------------------------------
int CMobile::GetBestSectorIndex()
{
return m_iBestSectorIndex;
}
void CMobile::SetBestSectorIndex(int i_inputBestSectorIdx)
{
m_iBestSectorIndex = i_inputBestSectorIdx;
}
//-----------------------------------
float CMobile::GetBestPilotSNR()
{
return m_fBestPilotSNR;
}
void CMobile::SetBestPilotSNR(float f_inputBestPilotSNR)
{
m_fBestPilotSNR = f_inputBestPilotSNR;
}
//end of file CMobile.CPP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -