📄 cbcfunction.c
字号:
for(i=0;i<MAX_BSC_CONNECT;i++)
{
if (s_BSCCellInfo[i].bFlag==EXIST)
{
//BSC
if(memcmp(BSCidentifier,&s_BSCCellInfo[i].cBSCIdentifer[0],BSC_INDENTIFIER_LEN)==0)
{
//BTS
for(j=0;j<s_BSCCellInfo[i].cNumberOfBTS;j++)
{
//将BTS中的小区加入列表
for(m=0;m<s_BSCCellInfo[i].s_BTSCellInfo[j].cNumberOfCell;m++)
{
Process_Add_CellId_To_DivideCellListBuf
(&s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[m].cCellId[0],&s_BSCCellInfo[i].cBSCIdentifer[0],s_DivideCellListBuf);
}
}
}
}
}
//判断BSC是否识别
if (s_DivideCellListBuf->cNumberOfCellList==0)
{
return UNRECOGNIZED_BSC;
}
return SUCCESS;
}
/* 根据LAC加一个列表 */
int Process_Add_CellList_According_LAC(unsigned char *LACidentifier,DIVIDE_CELLLIST_BUF_t *s_DivideCellListBuf)
{
int i;
int j;
int m;
for(i=0;i<MAX_BSC_CONNECT;i++)
{
if (s_BSCCellInfo[i].bFlag==EXIST)
{
//LAC
if(memcmp(LACidentifier,&s_BSCCellInfo[i].cLacId[0],LAC_INDENTIFIER_LEN)==0)
{
//BTS
for(j=0;j<s_BSCCellInfo[i].cNumberOfBTS;j++)
{
//将BTS中的小区加入列表
for(m=0;m<s_BSCCellInfo[i].s_BTSCellInfo[j].cNumberOfCell;m++)
{
Process_Add_CellId_To_DivideCellListBuf
(&s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[m].cCellId[0],&s_BSCCellInfo[i].cBSCIdentifer[0],s_DivideCellListBuf);
}
}
}
}
}
//判断BSC是否识别
if (s_DivideCellListBuf->cNumberOfCellList==0)
{
return UNRECOGNIZED_BSC;
}
return SUCCESS;
}
/*--------------------------------
//拆分小区列表
//匹配不上放入失败列表
//out: s_DivideCellListBuf 拆分结果
//out: s_CellId失败时返回不识别的小区编码
//int: s_CellList
//返回: 1成功;
//------------------------------*/
int Process_Divide_CellList_EX(CELLLIST_t *s_CellList,DIVIDE_CELLLIST_BUF_t *s_DivideCellListBuf)
{
int iReturnValue;
unsigned char cBSCID[BSC_INDENTIFIER_LEN];
int i;
iReturnValue=SUCCESS;
switch (s_CellList->cCellIdDisc)
{
//2字节区域码加2字节小区识别号
case 1:
{
//对所有收到的小区列表
for(i=0;i<s_CellList->iLength;i++)
{
iReturnValue=Process_Search_BscId_AccordingTo_CellId(&s_CellList->s_CellList[i].cCellId[0],cBSCID);
if (iReturnValue<=0)
{
//加到失败列表
Process_Add_Failure_CellId_To_DivideCellListBuf(&s_CellList->s_CellList[i].cCellId[0],s_DivideCellListBuf);
}
if (iReturnValue>0)
{
//已做了CellId和BSC对应的合法性检查,该函数不会返回错误
Process_Add_CellId_To_DivideCellListBuf(&s_CellList->s_CellList[i].cCellId[0],cBSCID,s_DivideCellListBuf);
}
}
}
break;
//只填小区码
case 2:
{
printf("Not suport this CellIdDisc: %d\n",s_CellList->cCellIdDisc);
iReturnValue=CELLIDDISC_OUTOFRANG;
}
break;
//lac
case 5:
{
for(i=0;i<s_CellList->iLength;i++)
{
//根据LAC加一个列表
iReturnValue=Process_Add_CellList_According_LAC(&s_CellList->s_CellList[i].cCellId[0],s_DivideCellListBuf);
if (iReturnValue<0)
return iReturnValue;
}
}
break;
//Bss
case 6:
{
for(i=0;i<s_CellList->iLength;i++)
{
//根据BSCID加一个列表
iReturnValue=Process_Add_CellList_According_Bsc(&s_CellList->s_CellList[i].cCellId[0],s_DivideCellListBuf);
if (iReturnValue<0)
return iReturnValue;
}
}
break;
default:
printf("CellIdDisc Error!\n");
iReturnValue=CELLIDDISC_OUTOFRANG;
break;
}
return iReturnValue;
}
/*
* 加一个小区到拆分小区列表缓冲区
* 1:返回成功
* <0 没有该BSC
*/
int Process_Add_CellId_To_DivideCellListBuf(unsigned char *CellId,unsigned char *BscId,DIVIDE_CELLLIST_BUF_t *s_DivideCellListBuf)
{
int i;
//已有该BSC小区列表
for(i=0;i<s_DivideCellListBuf->cNumberOfCellList;i++)
{
if(memcmp(&s_DivideCellListBuf->s_CellListOfBSC[i].BSCIdentifier[0],BscId,BSC_INDENTIFIER_LEN)==0)
{
memcpy(&s_DivideCellListBuf->s_CellListOfBSC[i].s_CellList.s_CellList[s_DivideCellListBuf->s_CellListOfBSC[i].s_CellList.iLength].cCellId[0],
CellId,4);
s_DivideCellListBuf->s_CellListOfBSC[i].s_CellList.iLength++;
return SUCCESS;
}
}
//没有该BSC小区列表
if (s_DivideCellListBuf->cNumberOfCellList<MAX_BSC_CONNECT)
{
memcpy(&s_DivideCellListBuf->s_CellListOfBSC[s_DivideCellListBuf->cNumberOfCellList].BSCIdentifier[0],BscId,BSC_INDENTIFIER_LEN);
s_DivideCellListBuf->s_CellListOfBSC[s_DivideCellListBuf->cNumberOfCellList].s_CellList.cCellIdDisc=LAC_AND_CI;
s_DivideCellListBuf->s_CellListOfBSC[s_DivideCellListBuf->cNumberOfCellList].s_CellList.bFlag=1;
//为小区ID赋值
memcpy(&s_DivideCellListBuf->s_CellListOfBSC[s_DivideCellListBuf->cNumberOfCellList].s_CellList.s_CellList[0].cCellId[0],CellId,4);
//小区个数加1
s_DivideCellListBuf->s_CellListOfBSC[s_DivideCellListBuf->cNumberOfCellList].s_CellList.iLength++;
//小区列表计数器加1
s_DivideCellListBuf->cNumberOfCellList++;
return SUCCESS;
}
return FAILURE;
}
/*---------------------------------------
//遍历系统所有小区
//in: CellId
//out: BSCIdentifer
//返回: 1:成功;
<0没有该小区;
0:小区不可用;
当开启小区信道负荷控制
8:该小区负荷>80%;
9:该小区负荷>90%;
//未写完
----------------------------------------*/
int Process_Search_BscId_AccordingTo_CellId(unsigned char *CellId,unsigned char *BSCIdentifier)
{
int j,m,n;
//遍历系统所有小区
for(j=0;j<MAX_BSC_CONNECT;j++)
{
//BSC小区存在
if (s_BSCCellInfo[j].bFlag==EXIST)
{
//比较小区列表的Lac部分
if (memcmp(CellId,s_BSCCellInfo[j].cLacId,2)==0)
{
//遍历BTS的小区
for(m=0;m<s_BSCCellInfo[j].cNumberOfBTS;m++)
{
//比较BTS的小区
for (n=0;n<s_BSCCellInfo[j].s_BTSCellInfo[m].cNumberOfCell;n++)
{
//比较2字节小区识别号
if (memcmp((CellId+2),&s_BSCCellInfo[j].s_BTSCellInfo[m].s_CellId[n].cCellId[2],2)==0)
{
//如果开启小区信道负荷控制
if (s_RuntimeInfo.bCellLoadingControl==1)
{
if (s_BSCCellInfo[j].s_BTSCellInfo[m].s_CellId[n].cCellLoading>917)/* 917=1019x90% */
{
//小区信道过负荷
memcpy(BSCIdentifier,&s_BSCCellInfo[j].cBSCIdentifer[0],BSC_INDENTIFIER_LEN);
return 9;
}
if (s_BSCCellInfo[j].s_BTSCellInfo[m].s_CellId[n].cCellLoading>815)/* 815=1019x80% */
{
//小区信道过负荷
memcpy(BSCIdentifier,&s_BSCCellInfo[j].cBSCIdentifer[0],BSC_INDENTIFIER_LEN);
return 8;
}
}
if (s_BSCCellInfo[j].s_BTSCellInfo[m].s_CellId[n].cCellStatus==CELL_OK)
{
//小区可用
memcpy(BSCIdentifier,&s_BSCCellInfo[j].cBSCIdentifer[0],BSC_INDENTIFIER_LEN);
return SUCCESS;
}
else
{
//小区不能用
memcpy(BSCIdentifier,&s_BSCCellInfo[j].cBSCIdentifer[0],BSC_INDENTIFIER_LEN);
return 0;
}
}
}
}
}
}
}
return FAILURE;
}
/*
* 修改小区状态
* in:CellStatus
* CELL_OK:可用
* CELL_ERROR:不可用
* in: CellId小区指针
*/
void Process_Set_CellId_Status(unsigned char *CellId,int CellStatus)
{
int j,m,n;
/* 遍历系统所有小区 */
for(j=0;j<MAX_BSC_CONNECT;j++)
{
/* BSC小区存在 */
if (s_BSCCellInfo[j].bFlag==EXIST)
{
/* 比较小区列表的Lac部分 */
if (memcmp(CellId,s_BSCCellInfo[j].cLacId,2)==0)
{
/* 遍历BTS的小区 */
for(m=0;m<s_BSCCellInfo[j].cNumberOfBTS;m++)
{
/* 比较BTS的小区 */
for (n=0;n<s_BSCCellInfo[j].s_BTSCellInfo[m].cNumberOfCell;n++)
{
/* 比较2字节小区识别号 */
if (memcmp((CellId+2),&s_BSCCellInfo[j].s_BTSCellInfo[m].s_CellId[n].cCellId[2],2)==0)
{
s_BSCCellInfo[j].s_BTSCellInfo[m].s_CellId[n].cCellStatus=CellStatus;
/* 重启次数加一 */
if(CellStatus==CELL_OK)
{
s_BSCCellInfo[j].s_BTSCellInfo[m].s_CellId[n].icResetCount++;
}
/* 失败次数加一 */
if(CellStatus==CELL_ERROR)
{
s_BSCCellInfo[j].s_BTSCellInfo[m].s_CellId[n].icResetCount++;
}
return;
}
}
}
}
}
}
}
/* 分配序列号
//in: s_MessageIdentifier消息证实号
//out: s_SerialNumber消息序列号
*/
void Alloc_SerialNumber(SERIALNUMBER_t *s_SerialNumber,MESSAGEIDENTIFIER_t *s_MessageIdentifier)
{
// int i;
s_SerialNumber->bFlag=EXIST;
if (s_RuntimeInfo.ChannelCount[s_MessageIdentifier->iMessageIdentifier]==65535)
{
s_RuntimeInfo.ChannelCount[s_MessageIdentifier->iMessageIdentifier]=0;
s_RuntimeInfo.ifChannelSerialNumberLoop[s_MessageIdentifier->iMessageIdentifier]=1;
/* 序列号分配完,全部重启 */
/* for (i=0;i<MAX_BSC_CONNECT;i++)
{
if(s_BscConnectInfo[i].DownlinkStatus==ON)
{
Reset_When_Connect(i);
}
}
*/
}
else
{
s_RuntimeInfo.ChannelCount[s_MessageIdentifier->iMessageIdentifier]++;
}
s_SerialNumber->iSerialNumber=s_RuntimeInfo.ChannelCount[s_MessageIdentifier->iMessageIdentifier];
}
/* 将不可用小区加到失败小区列表 */
int Process_Add_Failure_CellId_To_DivideCellListBuf(unsigned char *CellId,DIVIDE_CELLLIST_BUF_t *s_DivideCellListBuf)
{
if (s_DivideCellListBuf->s_FailureList.iLength>=MAXCELLCOUNT)
return ERROR;
s_DivideCellListBuf->s_FailureList.bFlag=EXIST;
memcpy(&s_DivideCellListBuf->s_FailureList.s_FailureReason[s_DivideCellListBuf->s_FailureList.iLength].s_Cellid.cCellId[0],
CellId,sizeof(CELLID_t));
s_DivideCellListBuf->s_FailureList.s_FailureReason[s_DivideCellListBuf->s_FailureList.iLength].s_Cellid.cCellIdDisc=1;
//小区故障
s_DivideCellListBuf->s_FailureList.s_FailureReason[s_DivideCellListBuf->s_FailureList.iLength].cCause=PERMANENT_FAILURE;
s_DivideCellListBuf->s_FailureList.iLength++;
return SUCCESS;
}
/* 将小区加到响应小区列表
初始状态为未知
初始完成次数为预定次数
in:
LpCellId 小区ID
LPBSCID BSCIDENTIFIER
NoOfBroadcastReq 请求完成的次数
out:
LPs_ResponseCellList 响应列表
*/
int Process_Add_CellId_To_ResponseCellListBuf(unsigned char *LpCellId,unsigned char *LPBSCID,unsigned short NoOfBroadcastReq,CELLLIST_i *LPs_ResponseCellList)
{
int i;
for(i=0;i<LPs_ResponseCellList->cNumberOfBSC;i++)
{
/* 比较BSCID */
if(memcmp(&LPs_ResponseCellList->s_BSCCellList[i].BSCIdentifier[0],LPBSCID,BSC_INDENTIFIER_LEN)==0)
{
/* 列表是否满了 */
if (LPs_ResponseCellList->s_BSCCellList[i].ilength>=MAX_BSC_CELL_COUNT)
{
return FAILURE;
}
memcpy(&LPs_ResponseCellList->s_BSCCellList[i].s_CellReport[LPs_ResponseCellList->s_BSCCellList[i].ilength].s_CellId.cCellId[0],
LpCellId,CELLID_LEN);
/* 初始状态为未知 */
LPs_ResponseCellList->s_BSCCellList[i].s_CellReport[LPs_ResponseCellList->s_BSCCellList[i].ilength].cCellStatus=UNKNOW_STATUS;
/* 初始完成次数为预定次数 */
LPs_ResponseCellList->s_BSCCellList[i].s_CellReport[LPs_ResponseCellList->s_BSCCellList[i].ilength].iNoOfBroadcastsCompl=NoOfBroadcastReq;
LPs_ResponseCellList->s_BSCCellList[i].ilength++;
return SUCCESS;
}
}
/* 没有该BSC小区列表 */
if (LPs_ResponseCellList->cNumberOfBSC<MAX_BSC_CONNECT)
{
memcpy(&LPs_ResponseCellList->s_BSCCellList[LPs_ResponseCellList->cNumberOfBSC].BSCIdentifier[0],LPBSCID,BSC_INDENTIFIER_LEN);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -