⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cbse_status_cbch_queryrequest.c

📁 CBS(小区广播)程序实现手稿
💻 C
📖 第 1 页 / 共 2 页
字号:
/*/将列表转为标准格式,用于StatusCBCHQuery
//in:   s_CBEMessage Cbcproxy发送来的原始信息
//out:  s_ProxyMessage
//返回:
//  1: 成功,
//  -1:失败*/
int Convert_StatusCBCHQuery(CBEMESSAGE_t *s_CBEMessage,CBEMESSAGE_t *s_ProxyMessage)
{
	int               posi;
	unsigned short    iListLen;
	STATUSCBCH_REQ_t  *LPStatusCBCHReq;
	
//	memset(&s_StatusCBCHReq,0,sizeof(STATUSCBCH_REQ_t));

	LPStatusCBCHReq=(STATUSCBCH_REQ_t *)&s_ProxyMessage->cMessage[0];

	memcpy(&s_ProxyMessage->s_MessageHead,&s_CBEMessage->s_MessageHead,sizeof(MESSAGE_HEAD_t));
    
//	memcpy(&s_ProxyMessage->cMessage[0],&s_CBEMessage->cMessage[0],
//		(sizeof(STATUS_CBCH_REQ_i)-sizeof(MESSAGE_HEAD_t)));

//	s_ProxyMessage->SocketHandle=s_CBEMessage->SocketHandle;	

	posi=0;

	//得到CELLLIST的长度
	memcpy(&iListLen,&s_CBEMessage->cMessage[posi],sizeof(unsigned short));
	LPStatusCBCHReq->p_CellList.iLength=iListLen;

	iListLen=iListLen*sizeof(CELLID_t); 

	//长度溢出,返回错误
	if (iListLen>sizeof(CELLLIST_t))	
	{
		return FAILURE;
	}
	
	//没有该参数,返回成功
	if (iListLen==0)
	{
		return SUCCESS;
	}

	LPStatusCBCHReq->p_CellList.bFlag=1;
	LPStatusCBCHReq->p_CellList.cCellIdDisc=1;
	
//	posi=posi+sizeof(unsigned short);

	//复制小区列表
    memcpy(&LPStatusCBCHReq->p_CellList.s_CellList, &s_CBEMessage->cMessage[posi+sizeof(short)],iListLen);

	s_ProxyMessage->iLen=sizeof(STATUSCBCH_REQ_t)+sizeof(MESSAGE_HEAD_t);

	return SUCCESS;
}

/* 全部回复StatusCBCHQuery的响应 */
void Process_StatusCBCHQuery_Return_To_CBCProxy(PID_t s_Pid)
{
	unsigned short               iLen;
	int                          i,j;
	char                         ResponseBuf[3096];
	SCQ_PROCESS_DATA_STRUCT      *LPs_SCQProcessDataStruct;
	int                          iPosi;
	CELLLIST_i                   s_CellListi;

	STATUS_CBCH_RESP_i           *LPs_StatusCBCHQueryResponse;

	STATUSCBCH_REQ_t             *LPs_StatusCBCHQuery;
	int                          iNumberofLoadingCell;
    
	memset(&s_CellListi,0,sizeof(CELLLIST_i));
	memset(&ResponseBuf[0],0,3096);
	
	LPs_SCQProcessDataStruct=(SCQ_PROCESS_DATA_STRUCT *)&ProcessData[s_Pid.iProcessId][0];
	LPs_StatusCBCHQuery=(STATUSCBCH_REQ_t *)&LPs_SCQProcessDataStruct->s_CBCMessage.cMessage[0];

	iPosi=sizeof(short);
	
	LPs_StatusCBCHQueryResponse=(STATUS_CBCH_RESP_i *)&ResponseBuf[iPosi];

//	memcpy(&LPs_StatusCBCHQueryResponse->p_ChannelIndicator,
//		&LPs_StatusCBCHQuery->p_ChannelIndicator,sizeof(CHANNELINDICATOR_t));

//	LPs_StatusCBCHQueryResponse->bReportListFlag=1;
	LPs_StatusCBCHQueryResponse->cReportListNumberOfBSC=
		LPs_SCQProcessDataStruct->s_ResponseCellList.cNumberOfBSC;
	LPs_StatusCBCHQueryResponse->iReturnValue=SUCCESS;

    LPs_StatusCBCHQueryResponse->s_MessageHead.iMessageAreaId=A;
	LPs_StatusCBCHQueryResponse->s_MessageHead.iMessageType=CBCPROXY_STATUS_CBCH_QUERY_RESP;	

	memcpy(&LPs_StatusCBCHQueryResponse->s_MessageHead.s_SenderPid,&s_Pid,sizeof(PID_t));
	memcpy(&LPs_StatusCBCHQueryResponse->s_MessageHead.s_ReceiverPid,
		&LPs_SCQProcessDataStruct->s_CBCMessage.s_MessageHead.s_SenderPid,sizeof(PID_t));


	iPosi=iPosi+sizeof(STATUS_CBCH_RESP_i);
/*	
	for(i=0;i<LPs_SCQProcessDataStruct->s_ResponseCellList.cNumberOfBSC;i++)
	{
		memcpy(&ResponseBuf[iPosi],&LPs_SCQProcessDataStruct->s_ResponseCellList.s_BSCCellList[i],
			(LPs_SCQProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].ilength*sizeof(CELLREPORT_i)+BSC_INDENTIFIER_LEN+sizeof(short)));
		iPosi=iPosi+LPs_SCQProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].ilength*sizeof(CELLREPORT_i)+BSC_INDENTIFIER_LEN+sizeof(short);
	}

*/
	iPosi=iPosi+sizeof(short);
	iNumberofLoadingCell=0;
	/* 抽出负荷响应成功小区返回 */
	for(i=0;i<LPs_SCQProcessDataStruct->s_ResponseCellList.cNumberOfBSC;i++)
	{
		for(j=0;j<LPs_SCQProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].ilength;j++)
		{
		
//			if(LPs_SCQProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].s_CellReport[j].cCellStatus==CELL_SUCCESS)
//			{
	 			memcpy(&ResponseBuf[iPosi],
					&LPs_SCQProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].s_CellReport[j],
					sizeof(CELLREPORT_i));
				iPosi=iPosi+sizeof(CELLREPORT_i);
				iNumberofLoadingCell++;
//			}
		}
	}

	memcpy(&ResponseBuf[sizeof(STATUS_CBCH_RESP_i)+sizeof(short)],&iNumberofLoadingCell,sizeof(short));

	iLen=iPosi-sizeof(short);

	memcpy(&ResponseBuf[0],&iLen,sizeof(short));
	LPs_StatusCBCHQueryResponse->s_MessageHead.iMessageLength=iLen-sizeof(MESSAGE_HEAD_t);

    AppendCBESendMessage((CBEMESSAGE_t *)&ResponseBuf[0]);


}

/*
   根据一个小区的信道负荷状态和BSC,
   修改系统中的小区负荷记录
*/
void Set_SysCell_Load_Record(CBCLOADINGSTATUS_t *LPs_CellLoadingStatus,unsigned char *LpBSCID)
{
	int i;
	int j;
	int iBscPosi;

	iBscPosi=FindOffsetAccordingBSC(LpBSCID);
	if(iBscPosi<0)
	{
		return;
	}

	/* 遍历BSC的小区,置负荷 */
	for(i=0;i<s_BSCCellInfo[iBscPosi].cNumberOfBTS;i++)
	{
		for(j=0;j<s_BSCCellInfo[iBscPosi].s_BTSCellInfo[i].cNumberOfCell;j++) 
		{
			/* 考虑到只填小区码,故只比较2字节 */
			if(memcmp(&s_BSCCellInfo[iBscPosi].s_BTSCellInfo[i].s_CellId[j].cCellId[2],
				&LPs_CellLoadingStatus->s_Cellid.cCellId[2],2)==0)
			{
				s_BSCCellInfo[iBscPosi].s_BTSCellInfo[i].s_CellId[j].cCellLoading=
					LPs_CellLoadingStatus->cCbcLoading;
				break;		
			}
		}
	}
	
}

/*
   对系统所有可用小区进行负荷查询
   对应的进程号,功能块号,模块号全为0
*/
void Process_Query_All_StatusCBCH()
{
	PID_t               s_Pid;
	BSCMESSAGE_t        s_BSCMessage;
	STATUSCBCH_REQ_t    s_StatusCBCReq;
	int                 i,j,x,y;
	int                 len;
	int                 Tid;

	memset(&s_Pid,0,sizeof(PID_t));
	
	for(i=0;i<MAX_BSC_CONNECT;i++) 
	{
		memset(&s_BSCMessage,0,sizeof(BSCMESSAGE_t));
		memset(&s_StatusCBCReq,0,sizeof(STATUSCBCH_REQ_t));
		
		/* 将系统可用小区加到信道查询列表 */
		s_StatusCBCReq.p_CellList.bFlag=1;
		s_StatusCBCReq.p_CellList.cCellIdDisc=LAC_AND_CI;
		
		if(s_BscConnectInfo[i].DownlinkStatus==ON)
		{
			for(j=0;j<s_BSCCellInfo[i].cNumberOfBTS;j++)
			{
				for(x=0;x<s_BSCCellInfo[i].s_BTSCellInfo[j].cNumberOfCell;x++)
				{
					if (s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[x].cCellStatus==CELL_OK)
					{
						memcpy(&s_StatusCBCReq.p_CellList.s_CellList[s_StatusCBCReq.p_CellList.iLength].cCellId[0],&s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[x].cCellId[0],4);
						s_StatusCBCReq.p_CellList.iLength++;
					}
				}
			}
		}

		/* 有小区列表 */
		if (s_StatusCBCReq.p_CellList.iLength>0)
		{
			len=Pack_STATUS_CBCH_QUERY(&s_StatusCBCReq,&s_BSCMessage.cMessage[0]);
			if (len>0)
			{
				s_BSCMessage.iLen=len;

				Tid=i;

				/* 小区CBCH操作次数加 1 */
				for(y=0;y<s_StatusCBCReq.p_CellList.iLength;y++)
				{
#ifdef  OPEN_STATISTIC
					Update_Cell_Statistic_Count(&s_StatusCBCReq.p_CellList.s_CellList[y].cCellId[0],Tid,CBCH_STATISTIC,0,0);
#endif
				}

				/* 对应的进程号,功能块号,模块号全为0 */
    			memcpy(&s_BSCMessage.s_Pid,&s_Pid,sizeof(PID_t));
#ifdef  OPEN_STATISTIC			
    			s_CBSECount.s_ReqBSCCnt[Tid].iCBCProxyCBCHReqCnt++;
#endif
				/* 发送给BSC */
				X25AppendCBESendMessage(&s_BSCMessage, Tid);
			}
		}

	}	

}

/* 处理StatusCBCHQuery定时器到时 */
void Process_StatusCBCHQuery_Timer_Expired()
{
	PID_t  s_Pid;
	int    iReturnValue;

	/* 对系统所有可用小区进行负荷查询 */
    Process_Query_All_StatusCBCH();

	memset(&s_Pid,0,sizeof(PID_t));

	/* 小区负荷控制标志 开*/
	if (s_RuntimeInfo.bCellLoadingControl==1)
	{
		iReturnValue=create_timer((SCHEDULED_STATUS_CBCH_QUERY_TIME),SCHEDULED_STATUS_CBCH_QUERY,(char *)&s_Pid,NULL);
		if (iReturnValue<0)
		{
			printf("Create SCHEDULED_STATUS_CBCH_QUERY timer Error!\n");
			return ;
		}		
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -