📄 cdatams.cpp
字号:
//c数据传输相关方法
/////////////////////////////////////////////////////////////////////////
//
// TITLE: TTI生成函数
//
// PURPOSE: 累记上一TTI内相应参数,设置新的TTI传输块集的属性;
// 对于HTTP业务还要统计分组和分组呼叫相关属性
//
// SAMPLE CALL: pHttpDataMs->NewTTIGenerate()
//
// CALLED BY FUNCTIONS: CMsManager::DCHMsListProcess()
//
// CALLING FUNCTIONS:
//
// AUTHOR: Chen Meiya
//
// DATE: 04/04(MM/YY)
//
////////////////////////////////////////////////////////////////////////////
void CDataMs::NewTTIGenerate(void)
{
if( IsDataQueueEmpty() == true && m_eUsertype == DCHData )
{
////数据队列为空,为DCH用户指定的特定TFI
// m_pstTFI = m_pMsManager->GetDCHTFIforEmptyDataQueue();
m_bIsTransNow = false;
}
else
{
if(m_eUsertype == DCHData)
{
//DCH用户数据队类不为空,设定TTI属性和传输标志,初始化新TTI的相关属性
m_iTTISucfulBLNum = 0;
m_iTTISucfulBitNum = 0;
m_iTTIFailedBLNum = 0;
m_iTTIFailedBitNum = 0;
m_iSlotNumRemained = m_pstTFI->iTTISlotNum;
for( int itemp = 0; itemp < MAXTTISLOTNUM; ++itemp )
{
m_fSlotC2IindB[itemp] = 0.0;
}
m_bIsTransNow =true;
//初始化TTI内服务扇区统计量
m_bIsCurrentPacketOver = false;
m_iCurrentPacketDelay = 0;
m_iTransPacketNum = 0;
m_bIsCurrentPCOver = false;
m_iCurrentPCDelay = 0;
m_iTransPCNum = 0;
m_lSucfulPCBitNum = 0;
//初始化分组业务移动台所需统计量
m_iTTISucfulPacketNum =0;
m_iTTIFailedPacketNum = 0;
}
else if(m_eUsertype == HSDSCHData)
{
//HSDSCH用户
m_fTTIMeanC2IindB =0.0;
m_iSlotNumRemained = HSDSCHTTISLOTNUM;
for( int itemp = 1; itemp < HSDSCHTTISLOTNUM; ++itemp )
{
m_fHSDSCHSlotC2IindB[itemp] = 0.0;
}
m_bIsTransNow =true;
m_bIsTTIGood = false;
//初始化TTI移动台统计量
m_iTTISucfulBLNum = 0;
m_iTTISucfulBitNum = 0;
m_iTTIFailedBLNum = 0;
m_iTTIFailedBitNum = 0;
//初始化TTI内服务扇区统计量
m_bIsCurrentPacketOver = false;
m_iCurrentPacketDelay = 0;
m_iTransPacketNum = 0;
m_bIsCurrentPCOver = false;
m_iCurrentPCDelay = 0;
m_iTransPCNum = 0;
m_lSucfulPCBitNum = 0;
//初始化分组业务移动台所需统计量
m_iTTISucfulPacketNum =0;
m_iTTIFailedPacketNum = 0;
}
}
}
/////////////////////////////////////////////////////////////////////////
//
// TITLE: 速率和TFI预测函数
//
// PURPOSE: 预测移动台速率和确定TFI结构
//
// SAMPLE CALL: pHttpDataMs->RATEandTFIPredict()
//
// CALLED BY FUNCTIONS: CDataMs::DCHInitialize()
//
// CALLING FUNCTIONS:
//
//
// AUTHOR: Chen Meiya
//
// DATE: 04/04(MM/YY)
//
// MODIFICATIONS SINCE 04/04(MM/YY)
//
////////////////////////////////////////////////////////////////////////////
void CDataMs::RATEandTFIPredict()
{
//Rewritten by Li Jing,20040713
//速率预测没有考虑快衰,是否应该考虑加上
float fDCHPower;
float fOtherChannelInterference;
float fOtherSectorInterference;
float fOrthogonalFactor;
float fC2ITarget;
float fC2ITargetNext;
CSector *pSector;
pSector = m_pServiceArea->GetSector(m_stBestSector); //获取最佳扇区
if(pSector->GetDCHAvailablePower()>=INITIALDCHPOWER)
fDCHPower =INITIALDCHPOWER;
else
fDCHPower =pSector->GetDCHAvailablePower();
if( m_pMsManager->m_iSlotCurrentNum == 0 )
fDCHPower = INITIALDCHPOWER;
fDCHPower *= m_aMonitorSector[m_iBestSectorIndex].fPropagationLoss;
fOtherSectorInterference=m_aMonitorSector[m_iBestSectorIndex].fInterferenceFromOtherSector;
//获得从其他扇区来的干扰
fOrthogonalFactor=m_pServiceArea->GetOrthogonalFactor();
//获得正交因子
fOtherChannelInterference=pSector->GetTxPower();
//获得从本扇区其它信道来的干扰
fOtherChannelInterference*=m_aMonitorSector[m_iBestSectorIndex].fPropagationLoss;
m_fRatePredictC2I = fDCHPower/(fOtherChannelInterference*fOrthogonalFactor
+fOtherSectorInterference+NoisePower);
m_fRatePredictC2I = (float)(10*log10(m_fRatePredictC2I));
//得到用作速率预测的C/I
POSITION pos;
pos=m_pLinkPrediction->m_pstRateTable.GetHeadPosition();
RATE2CI_TYPE *pRate = new RATE2CI_TYPE;
RATE2CI_TYPE *pRateNext = new RATE2CI_TYPE;
pRate=m_pLinkPrediction->m_pstRateTable.GetNext(pos);
while (pRate->iChannelType!=m_iChannelType||pRate->fDataRate==(float)12.2)
{
pRate=m_pLinkPrediction->m_pstRateTable.GetNext(pos);
}
fC2ITarget=pRate->fTargetC2I;
if(m_fRatePredictC2I<fC2ITarget)
{
m_pstRate=pRate;
m_fC2ITarget=m_pstRate->fTargetC2I;
m_pstTFI = m_pstRate->pTFI;
}
else
{
pRateNext=m_pLinkPrediction->m_pstRateTable.GetNext(pos);
fC2ITargetNext=pRateNext->fTargetC2I;
while(pRateNext->fDataRate!=(float)384 && m_fRatePredictC2I>fC2ITargetNext)
{
pRate=pRateNext;
fC2ITarget=pRate->fTargetC2I;
pRateNext=m_pLinkPrediction->m_pstRateTable.GetNext(pos);
fC2ITargetNext=pRateNext->fTargetC2I;
}
if(m_fRatePredictC2I>fC2ITargetNext)
{
m_pstRate=pRateNext;
m_fC2ITarget=m_pstRate->fTargetC2I;
m_pstTFI = m_pstRate->pTFI;
}
else
{
m_pstRate=pRate;
m_fC2ITarget=m_pstRate->fTargetC2I;
m_pstTFI = m_pstRate->pTFI;
}
}
}
/////////////////////////////////////////////////////////////////////////
//
// TITLE: 速率调整函数
//
// PURPOSE: 调整移动台的速率,使下行高速率不能满足服务质量的情况下调低速率
//
// SAMPLE CALL: pHttpDataMs->RateAdjustforPCFailed()
//
// CALLED BY FUNCTIONS:
//
// CALLING FUNCTIONS:
//
// AUTHOR: Chen Meiya
//
// DATE: 10/04(MM/YY)
//
// MODIFICATIONS SINCE 04/04(MM/YY)
//
////////////////////////////////////////////////////////////////////////////
void CDataMs::RateAdjustforPCFailed(void)
{
//在上一个功率控制计时周期内达到满功率发射的情况下,降低信道速率
if( m_iPowCrtlFailedTimer > POWCTRLFAILEDTIMER )
{
POSITION pos;
POSITION pos_current;
RATE2CI_TYPE *pRate;
pos = m_pLinkPrediction->m_pstRateTable.GetHeadPosition();
while( pos != NULL )
{
pRate = m_pLinkPrediction->m_pstRateTable.GetAt(pos);
if( pRate->iChannelType == m_pstRate->iChannelType )
break;
//指向速率表中下一个速率的位置
m_pLinkPrediction->m_pstRateTable.GetNext(pos);
}
////确定下一个更低的速率
/*在同一信道类型的速率表中,pos指向速率表当前速率的位置
//比较速率表当前速率和移动台的速率,
//在两者相等的时候,确定速率表中前一个较低的数据速率为调整后移动台的速率
*/
while ( pRate->iChannelType == m_pstRate->iChannelType )
{
pRate = m_pLinkPrediction->m_pstRateTable.GetAt(pos);
if( pRate == m_pstRate )
{
//将速率设置为前一个较低的速率
pos_current = m_pLinkPrediction->m_pstRateTable.Find(pRate);
m_pLinkPrediction->m_pstRateTable.GetPrev(pos_current);
pRate = m_pLinkPrediction->m_pstRateTable.GetAt(pos_current);
if( pRate->fDataRate >12.2 )
{
CStdioFile f;
f.Open("RateAdjust.txt",CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite);
f.SeekToEnd();
char buf[50];
_itoa(m_pMsManager->m_iSlotCurrentNum,buf,10);
f.WriteString(buf);
f.WriteString("\t");
_itoa(m_iMsID,buf,10);
f.WriteString(buf);
f.WriteString("\t");
_gcvt(m_pstRate->fDataRate,10,buf);
f.WriteString(buf);
f.WriteString("\t");
_gcvt(pRate->fDataRate,10,buf);
f.WriteString(buf);
f.WriteString("\n");
f.Close();
//调整当前速率
m_pstRate = pRate;
m_fC2ITarget = m_pstRate->fTargetC2I;
BLERInitialization();
m_iPowCrtlFailedTimer = 0 ;
break;
}
else break;
}
m_pLinkPrediction->m_pstRateTable.GetNext(pos);
}
}
}
//////////////////////////////////////////////////////////////////////////
//
// TITLE: TTI传输函数
//
// PURPOSE: 模拟TTI内传输块的传输,计算时隙内的C2I
// SAMPLE CALL: pHttpDataMs->TTITransmit()
//
// CALLED BY FUNCTIONS: CMsManager::DCHMsListProcess()
//
// CALLING FUNCTIONS:
//
// AUTHOR: Chen Meiya
//
// DATE: 04/04(MM/YY)
//
// MODIFICATIONS SINCE 04/04(MM/YY)
//
//////////////////////////////////////////////////////////////////////////
void CDataMs::TTITransmit(void)
{
if( m_iSlotNumRemained > 0 )
{
////设定用户正在传输,这个标志是给下个时隙用的
m_bIsTransNow = true;
//递减传输计时器
m_iSlotNumRemained -=1 ;
}
else
{
m_bIsTransNow = false;
}
}
/////////////////////////////////////////////////////////////////////////
//
// TITLE: TTI传输统计函数
//
// PURPOSE: 把当前TTI内传输统计量累加到服务扇区中;
//
// SAMPLE CALL: pHttpDataMs->TTIStatistics()
//
// CALLED BY FUNCTIONS: CMsManager::DCHMsListProcess()
// CServiceArea::SectorDSCHProcess()
//
// CALLING FUNCTIONS:
//
// AUTHOR: Chen Meiya
//
// DATE: 04/04(MM/YY)
//
// MODIFICATIONS SINCE 04/04(MM/YY)
//
////////////////////////////////////////////////////////////////////////////
void CDataMs::SectorStatistics(void)
{
////累加数据移动台相关统计量
m_iTotalSucfulBLNum += m_iTTISucfulBLNum;
m_iTotalFailedBLNum += m_iTTIFailedBLNum;
m_lTotalSucfulBitNum += m_iTTISucfulBitNum;
m_lTotalFailedBitNum += m_iTTIFailedBitNum; //20051206
m_iTotalSucfulPacketNum += m_iTTISucfulPacketNum;
m_iTotalFailedPacketNum += m_iTTIFailedPacketNum;
m_iTotalPacketDelay += m_iCurrentPacketDelay;
m_iPacketCallNum += m_iTransPCNum;
m_iPacketCallDelay += m_iCurrentPCDelay;
m_lTotalSucfulPCBitNum += m_lSucfulPCBitNum;
////累计数据移动台所在服务扇区中分组和分组呼叫相关统计量
if( m_eUsertype == DCHData )
{
////累加激活集中所有扇区的相应统计量
POSITION postemp = m_ActiveSetList.GetHeadPosition();
ACTIVESECTOR_TYPE *pActive = NULL;
CSector *pActiveSector = NULL;
while( postemp != NULL )
{
pActive = m_ActiveSetList.GetNext(postemp);
pActiveSector = m_pServiceArea->GetSector( pActive->stSectorID );
////累加激活集中每个服务扇区的相关统计量
//累加服务扇区成功传输比特数、分组数
long lSectorGoodBitNum = pActiveSector->GetGoodBitNum();
lSectorGoodBitNum += (long) m_iTTISucfulBitNum;
pActiveSector->SetGoodBitNum( lSectorGoodBitNum );
int iSectorSucfulBLNum = pActiveSector->GetSectorSucfulBLNum();
iSectorSucfulBLNum += m_iTTISucfulBLNum;
pActiveSector->SetSectorSucfulBLNum(iSectorSucfulBLNum);
int iSectorFailedBLNum = pActiveSector->GetSectorFailedBLNum();
iSectorFailedBLNum += m_iTTIFailedBLNum;
pActiveSector->SetSectorFailedBLNum(iSectorFailedBLNum);
if( m_enTrafficType == HTTP )
{
//统计分组和分组呼叫相关属性
if( m_bIsCurrentPacketOver == true )
{
//累加服务扇区分组数和分组时延
int iSectorPacketNum = pActiveSector->GetPacketNum();
iSectorPacketNum += m_iTransPacketNum;
pActiveSector->SetPacketNum(iSectorPacketNum);
int iSucfulPacketNum = pActiveSector->GetSectorSucfulPacketNum();
iSucfulPacketNum += m_iTotalSucfulPacketNum;
pActiveSector->SetSectorSucfulPacketNum(iSucfulPacketNum);
int iFailedPacketNum = pActiveSector->GetSectorFailedPacketNum();
iFailedPacketNum += m_iTotalFailedPacketNum;
pActiveSector->SetSectorSucfulPacketNum(iFailedPacketNum);
int iSectorPacketDelay = pActiveSector->GetPacketDelay();
iSectorPacketDelay += m_iCurrentPacketDelay;
pActiveSector->SetPacketDelay(iSectorPacketDelay);
if( m_bIsCurrentPCOver == true )
{
//累加服务扇区分组呼叫数、分组呼叫时延和分组呼叫比特数
int iSectorPCNum = pActiveSector->GetPacketCallNum();
iSectorPCNum += m_iTransPCNum;
pActiveSector->SetPacketCallNum(iSectorPCNum);
int iSectorPCDelay = pActiveSector->GetPacketCallDelay();
iSectorPCDelay += m_iCurrentPCDelay;
pActiveSector->SetPacketCallDelay(iSectorPCDelay);
long lSectorPCBitNum = pActiveSector->GetPacketCallBitNum();
lSectorPCBitNum += m_lSucfulPCBitNum;
pActiveSector->SetPacketCallBitNum(lSectorPCBitNum);
}
else
{
//分组呼叫尚未结束,不需要统计
}
}
else
{
//分组尚未结束,不需要统计
}
}
else if( m_enTrafficType == FTP )
{
//目前没有分组统计,没有操作
}
else
{
////notice 对其他业务类型的处理
}
}
}
else if( m_eUsertype == HSDSCHData )
{
//累加当前服务扇区中统计参量
CSector *pCurSector = m_pServiceArea->GetSector(m_stLocationSector);
//累加服务扇区成功传输比特数
long lSectorGoodBitNum = pCurSector->GetGoodBitNum();
lSectorGoodBitNum += (long) m_iTTISucfulBitNum;
pCurSector->SetGoodBitNum( lSectorGoodBitNum );
int iSectorSucfulBLNum = pCurSector->GetSectorSucfulBLNum();
iSectorSucfulBLNum += m_iTTISucfulBLNum;
pCurSector->SetSectorSucfulBLNum(iSectorSucfulBLNum);
int iSectorFailedBLNum = pCurSector->GetSectorFailedBLNum();
iSectorFailedBLNum += m_iTTIFailedBLNum;
pCurSector->SetSectorFailedBLNum(iSectorFailedBLNum);
/* //for compile by zl20050426
CStdioFile f;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -