📄 cservicearea.cpp
字号:
n1=n-1;
else n1=n; break;
case 2: m1=m+1;
if( (m%2==1)||((-m)%2==1) )
n1=n;
else n1=n+1; break;
case 3: m1=m;
n1=n+1; break;
case 4: m1=m-1;
if( (m%2==1)||((-m)%2==1) )
n1=n;
else n1=n+1; break;
case 5: m1=m-1;
if( (m%2==1)||((-m)%2==1) )
n1=n-1;
else n1=n; break;
default:
m1=-100;
n1=-100;
} //end switch
CELLID_TYPE id;
id.m=m1;
id.n=n1;
return id;
}
//分组数据信道功率计算函数
//completed in 3.23
void CServiceArea::PacketChannelPower() //依次调用每一小区中每一扇区的分组功率计算函数
{
// for(int m=0;m<MM;m++)
// for(int n=0;n<NN;n++)
int m=2,n=2; //operation only in sector (3,3),other sectors transmit full power! zdy
//Index in the arrray is [2][2]
for(int i=0;i<SectorNumber;i++)
m_aCellArray[m][n].m_aSectorInCell[i].PacketPowerCalculte();
}
//实际发射功率计算函数
//completed in 5.11
//应oyh要求新增
void CServiceArea::TxPower() //依次调用每一小区中每一扇区的实际发射功率计算函数
{
// for(int m=0;m<MM;m++)
// for(int n=0;n<NN;n++)
int m=2,n=2; //operation only in sector (3,3),other sectors transmit full power! zdy
//Index in the arrray is [2][2]
for(int i=0;i<SectorNumber;i++)
m_aCellArray[m][n].m_aSectorInCell[i].TxPowerCalculte();
}
//completed in 5.14
//Added by oyh
void CServiceArea::UpdatePacketPower()
//根据各扇区内是否有用户在传输,更新各扇区数据用户功率
{
// for(int m=0;m<MM;m++)
// for(int n=0;n<NN;n++)
int m=2,n=2; //operation only in sector (3,3),other sectors transmit full power! zdy
//Index in the arrray is [2][2]
for(int i=0;i<SectorNumber;i++)
{
//假如扇区内没有用户在传输或用户不满足传输条件
if (m_aCellArray[m][n].m_aSectorInCell[i].GetCurrentDataMs()==NULL)
{
m_aCellArray[m][n].m_aSectorInCell[i].SetPacketPower(0);
}
else if ((m_aCellArray[m][n].m_aSectorInCell[i].GetCurrentDataMs())->GetstRatePrediction()==NULL)
m_aCellArray[m][n].m_aSectorInCell[i].SetPacketPower(0);
}
}
//数据传输控制函数
//completed by ms in 3.23
//reviced by ms in 5.15
void CServiceArea::DataTransmission(int iCurrentSlotNum)
//viewed by zdy on 2001/07/23 and added some comments
{
CDataMs* pCurrentDataMs=NULL;
RATE2CI_TYPE* pRate2CI=NULL;
int j;
int GoodBitNum=0;
//循环各扇区的最佳数据用户
for(int i=0;i<SectorNumber;i++)
{
pCurrentDataMs=m_aCellArray[2][2].m_aSectorInCell[i].GetCurrentDataMs();//得到当前的数据业务用户
if(pCurrentDataMs!=NULL)
{
pRate2CI=pCurrentDataMs->GetstRatePrediction();//得到速率预测的结果
if(!pCurrentDataMs->IsTransmitingNow()) //当前最佳用户是否是第一次传输
{
if(pRate2CI==NULL) //由于C/I过低可能会引起指针为空,所以要先判断
{
m_aCellArray[2][2].m_aSectorInCell[i].SetPriorityFactor(0); //将本扇区的优先级指标置零
m_aCellArray[2][2].m_aSectorInCell[i].SetCurrentDataMs(NULL); //将最佳数据用户指针置空
m_aCellArray[2][2].m_aSectorInCell[i].SetIsExistHighestPriority(false); //将是否存在最高优先级用户指标置假
//wgt
m_aCellArray[2][2].m_aSectorInCell[i].SetIsTransmiting(false);
//扇区传输标志设为false
m_aCellArray[2][2].m_aSectorInCell[i].SetTxPower1(m_aCellArray[2][2].m_aSectorInCell[i].GetTxPower()-m_aCellArray[2][2].m_aSectorInCell[i].GetPacketPower());
//将PacketPower从m_fTxPower1中减去
continue;
}
if(pCurrentDataMs->GetTransmissionNum()==0)
pCurrentDataMs->SGGenerator();
//如果当前的数据用户的Ep的传输次数为0,则要调用一次Sg的生成函数,一个symbol group对应着一个Ep的传输情况
j=pRate2CI->iSlotNumPerSubPacket;
pCurrentDataMs->SetSlotNumRemained(j); //初始化sub-packet传输的剩余时隙数
pCurrentDataMs->SetIsTransmitingNow(true); //将正在传输标志置真
m_aCellArray[2][2].m_aSectorInCell[i].SetIsExistHighestPriority(true);
}
pCurrentDataMs->PacketTransmission(); //调用最佳数据用户的数据传输函数
//wgt
m_aCellArray[2][2].m_aSectorInCell[i].SetIsTransmiting(true);
//正在传输,扇区传输标志设为true
//zx20010813 更新传输了数据的用户的平均速率
//兼顾公平时,要将平均速率增大,则在不传数据时,其相应优先权指标降低
pCurrentDataMs->m_fAverageRate += (float)(pRate2CI->fDataRate / fConstTc);
if(pCurrentDataMs->IsSubPacketEnd()) //判断sub-packet是否传输完毕
{
pCurrentDataMs->m_iRealTotalSP++;
pCurrentDataMs->InsertEffectiveCodeRate(); //当每个sub-packet传输完毕后,
//将该sub-packet的等效编码速率插入等效编码速率链表
//added in 5.15
pCurrentDataMs->PERPrediction(); //调用质量估计函数
pCurrentDataMs->SPDCCHTransmission();
if(pCurrentDataMs->m_bIsSPDCCHSuccess)
{
if(pCurrentDataMs->IsPacketGood()) //判断分组质量是否正确
{
///////////////////////////// 统计本扇区到目前为止成功传输的bit数 ///////////////////////
GoodBitNum=m_aCellArray[2][2].m_aSectorInCell[i].GetGoodBitNum();
GoodBitNum+=pCurrentDataMs->GetCurrentPacketSize();
m_aCellArray[2][2].m_aSectorInCell[i].SetGoodBitNum(GoodBitNum);
/////////////////////////////////////////////////////////////////////////////////////////////////////
pCurrentDataMs->NewPacketSetup(); //若正确,设置新的传输分组
//zdy
//加入用于统计扇区所传分组的时延和个数的语句
//在CSector.h中要新加一些属性
if(pCurrentDataMs->IsCurrentPacketOver())
{
int iPacketNum;
float fTotalDelay;
fTotalDelay=m_aCellArray[2][2].m_aSectorInCell[i].GetTotalPacketDelay();
fTotalDelay+=pCurrentDataMs->GetCurrentPacketDelay();
m_aCellArray[2][2].m_aSectorInCell[i].SetTotalPacketDelay(fTotalDelay);
pCurrentDataMs->SetCurrentPacketDelay(0);
iPacketNum=m_aCellArray[2][2].m_aSectorInCell[i].GetTotalSuccessfulPacketNum();
iPacketNum++;
m_aCellArray[2][2].m_aSectorInCell[i].SetTotalSuccessfulPacketNum(iPacketNum);
pCurrentDataMs->SetIsCurrentPacketOver(false);
}
}
else
{
pCurrentDataMs->m_iRealErrorSP++;
pCurrentDataMs->ReTransmissionControl(); //若错误,调用重传控制函数
}
}
else if(pCurrentDataMs->GetTransmissionNum()!=0)
{
pCurrentDataMs->ReTransmissionControl();
pCurrentDataMs->m_iErrorSPDCCH++;
}
else
{
//cout<<"The Packet is discarded"<<endl;
pCurrentDataMs->m_bIsEPGood=false;
pCurrentDataMs->DiscardedProcess();
pCurrentDataMs->m_iErrorSPDCCH++;
pCurrentDataMs->m_iDiscardedPacket++;
}
m_aCellArray[2][2].m_aSectorInCell[i].SetPriorityFactor(0); //将本扇区的优先级指标置零
m_aCellArray[2][2].m_aSectorInCell[i].SetCurrentDataMs(NULL); //将最佳数据用户指针置空
m_aCellArray[2][2].m_aSectorInCell[i].SetIsExistHighestPriority(false); //将是否存在最高优先级用户指标置假
//wgt
m_aCellArray[2][2].m_aSectorInCell[i].SetIsTransmiting(false);
//SubPacket传输完毕,扇区传输标志设为false
m_aCellArray[2][2].m_aSectorInCell[i].SetTxPower1(m_aCellArray[2][2].m_aSectorInCell[i].GetTxPower()-m_aCellArray[2][2].m_aSectorInCell[i].GetPacketPower());
//SubPacket传输完毕,将PacketPower从m_fTxPower1中减去
}
}
}
}
/////////////////////////////////
//系统复位函数
//completed in 3.23
void CServiceArea::SystemReset() //依次调用每一小区中每一扇区的功率复位函数
{
// for(int m=0;m<MM;m++)
// for(int n=0;n<NN;n++)
int m=2,n=2; //operation only in sector (3,3),other sectors transmit full power! zdy
//Index in the arrray is [2][2]
for(int i=0;i<SectorNumber;i++)
m_aCellArray[m][n].m_aSectorInCell[i].ResetPower();
}
//累积功率超标基站数
//completed in 3.23
void CServiceArea::TotalBsOutrageCalcute()
{
for(int m=0;m<MM;m++)
for(int n=0;n<NN;n++)
for(int i=0;i<SectorNumber;i++)//基站实际发射功率>基站最大发射功率,即为基站功率超标
if(m_aCellArray[m][n].m_aSectorInCell[i].GetTxPower()>m_aCellArray[m][n].m_aSectorInCell[i].GetMaxPower())
m_iTotalBsOutrage++;
}
//计算功率超标基站比例
//completed in 3.23
void CServiceArea::PortionOfBsOutrage(int CurrentDropNum)
{
float PortionOfBsOutrage;
CStdioFile f;
char buf[50];
PortionOfBsOutrage=(float)m_iTotalBsOutrage/(MM*NN*SectorNumber)/m_iNumOfSlotInDrop; //功率超标基站比例=功率超标基站数/总扇区数/一个DROP内的时隙数
if(!f.Open(m_sBsOutrageDataFileName,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite))
{
#ifdef _DEBUG
afxDump<<"Unable to open file"<<"\n"; //异常处理
#endif
}
f.SeekToEnd(); //使文件指针指向文件尾部,输出数据可以在文件尾部接着写
_gcvt(CurrentDropNum,4,buf);
f.WriteString(buf);
f.WriteString(": ");
_gcvt(PortionOfBsOutrage,8,buf);
f.WriteString(buf);
f.WriteString("\n");
f.Close();
}
void CServiceArea::SectorStatics()
{
CStdioFile f;
char buf[50];
/* 打开数据文件准备写*/
if(!f.Open("Sector.txt",
CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite))
{
#ifdef _DEBUG
afxDump<<"Unable to open file"<<"\n"; //异常处理
#endif
}
f.SeekToEnd();
//使文件指针指向文件尾部,输出数据可以在文件尾部接着写
f.WriteString("扇区吞吐量统计\n");
f.WriteString("扇区标号,本扇区的分组用户数,本扇区成功传输的bit数,扇区平均分组时延_s\n");
for(int i=0;i<SectorNumber;i++)
{
CSector* pSector
=&(m_aCellArray[2][2].m_aSectorInCell[i]);
float fAveragePacketDelay=pSector->GetTotalPacketDelay()/pSector->GetTotalSuccessfulPacketNum();
fAveragePacketDelay=float(fAveragePacketDelay*SlotSize*pow(double(10.0),double(-3.0)));
_gcvt(3,8,buf);
f.WriteString(buf);
f.WriteString("\t");
_gcvt(3,8,buf); //将浮点数转换成字符串
f.WriteString(buf);
f.WriteString("\t");
_gcvt(i+1,8,buf);
f.WriteString(buf);
f.WriteString("\t");
_gcvt(pSector->m_iNumOfSector,8,buf);
f.WriteString(buf);
f.WriteString("\t");
_gcvt(pSector->GetGoodBitNum(),8,buf);
f.WriteString(buf);
f.WriteString("\t");
_gcvt(fAveragePacketDelay,8,buf);
f.WriteString(buf);
f.WriteString("\n");
}
f.Close();
}
/////////////////////////////////////////////////////////////////////////////////////
// 以下为接口函数
/////////////////////////////////////////////////////////////////////////////////////
//返回当前扇区号
SECTORID_TYPE CServiceArea::GetCurrentSector()
{
return m_stCurrentSector;
}
//设置数据输出文件路径
//revised in 3.21,according to oyh
void CServiceArea::SetBsOutrageDataFileName(char* FileName)
{
strcpy(m_sBsOutrageDataFileName,FileName);
}
//设置基站间隔(小区半径)
void CServiceArea::SetSiteDistance(float dist)
{
m_fSiteDistance=dist;
}
//返回基站间隔(小区半径)
float CServiceArea::GetSiteDistance()
{
return m_fSiteDistance;
}
//设置正交因子
void CServiceArea::SetOrthogonalFactor(float factor)
{
m_fOrthogonalFactor=factor;
}
//返回正交因子
float CServiceArea::GetOrthogonalFactor()
{
return m_fOrthogonalFactor;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -