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

📄 statistic.c

📁 CBS(小区广播)程序实现手稿
💻 C
📖 第 1 页 / 共 5 页
字号:

	return iReturnValue;
}


/* 处理服务元素的统计 
 * <0:返回错误, >=0:返回Pid
 */
int Process_Statistic_Cbse(CBEMESSAGE_t *LpCBEMessage)
{
	MESSAGE_STATISTIC_t            *LpMessageStatistic;
	int                            iReturnValue;
	PID_t                          s_Pid;
	CBSE_STATISTIC_RESULT_t        s_CBSEStatisticResult;
	int                            Tid;
	int                            i,j,k;
	CELL_CBSE_STATISTIC_RESULT_t   s_CellCBSEStatisticResult;
	unsigned char                  bIfCellExist;

	LpMessageStatistic=(MESSAGE_STATISTIC_t *)LpCBEMessage;

	s_Pid.cFunctionId=MODULEID;
    s_Pid.cFunctionId=FUNCTIONID;

	switch(LpMessageStatistic->ParaId)
	{
	case CBCPROXY_CBSE_CNT:  /* CBCProxy业务请求次数 */
		{
			/* 分配一个统计进程 */
			s_Pid.cFunctionId=FUNCTIONID;
			s_Pid.cModuleId=MODULEID;
			s_Pid.iProcessId=alloc_pid((char *)&s_Pid);
			if ( s_Pid.iProcessId < 0 )
			{
				printf("Creat Process Error\n");
				return FAILURE;
			}
			
			memcpy(&LpMessageStatistic->s_StatMessageHead.s_ReceiverPid,
				&s_Pid,sizeof(PID_t));

			memset(&ProcessData[s_Pid.iProcessId][0],0,LPCB_DATA_SIZE);
			memset(&s_CBSEStatisticResult,0,sizeof(CBSE_STATISTIC_RESULT_t));

			memcpy(&ProcessData[s_Pid.iProcessId][0],LpCBEMessage,LpCBEMessage->iLen+2);
			LpMessageStatistic=(MESSAGE_STATISTIC_t *)&ProcessData[s_Pid.iProcessId][0];			

			/* 有6种业务的统计 */
			s_CBSEStatisticResult.cNumber=6;
    
			i=0;
	        /* 写入 */
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=WRITE_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount=
				s_CBSECount.s_CbcProxyReqCnt.iCBCProxyWriteReqCnt ;
			i++;

            /* 替换 */
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=REPLACE_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount=
				s_CBSECount.s_CbcProxyReqCnt.iCBCProxyReplaceReqCnt ;
			i++;
			/* 删除 */
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=KILL_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount= 
				s_CBSECount.s_CbcProxyReqCnt.iCBCProxyKillReqCnt;
			i++;
            /* 消息状态查询查询 */
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=QUERY_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount= 
				s_CBSECount.s_CbcProxyReqCnt.iCBCProxyMsgQueryCnt;
			i++;
            /* 小区信道负荷查询 */ 
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=CBCH_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount= 
				s_CBSECount.s_CbcProxyReqCnt.iCBCProxyCBCHReqCnt;
			i++;

            /* 小区重启 */ 
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=RESET_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount= 
				s_CBSECount.s_CbcProxyReqCnt.iCBCProxyResetCnt;
			i++;

			memcpy(&ProcessData[s_Pid.iProcessId][sizeof(MESSAGE_STATISTIC_t)],&s_CBSEStatisticResult,s_CBSEStatisticResult.cNumber*sizeof(STATTYPE_COUNT_t)+1);

			/* 创建统计定时器 */
			iReturnValue=create_timer(LpMessageStatistic->StatTimeLength*1000,
				STATISTIC_TIMER,(char *)&s_Pid,NULL);
			/* 创建定时器失败 */
			if (iReturnValue<0)
			{
				printf("Create timer Error!\n");
				/* 结束统计进程 */
				free_pid((char *)&s_Pid);

				return iReturnValue;
			}

			/* 保存统计定时器在进程区尾部 */
			memcpy(&ProcessData[s_Pid.iProcessId][LPCB_DATA_SIZE-sizeof(int)],&iReturnValue,sizeof(int));
						
		}
    	break;

	case BSC_CBSE_CNT: /* 对各个BSC业务请求次数 */
		{
			/* 分配一个统计进程 */
			s_Pid.cFunctionId=FUNCTIONID;
			s_Pid.cModuleId=MODULEID;
			s_Pid.iProcessId=alloc_pid((char *)&s_Pid);
			if ( s_Pid.iProcessId < 0 )
			{
				printf("Creat Process Error\n");
				return FAILURE;
			}

			memcpy(&LpMessageStatistic->s_StatMessageHead.s_ReceiverPid,
				&s_Pid,sizeof(PID_t));

			memset(&ProcessData[s_Pid.iProcessId][0],0,LPCB_DATA_SIZE);
			memset(&s_CBSEStatisticResult,0,sizeof(CBSE_STATISTIC_RESULT_t));

			memcpy(&ProcessData[s_Pid.iProcessId][0],LpCBEMessage,LpCBEMessage->iLen+2);
			LpMessageStatistic=(MESSAGE_STATISTIC_t *)&ProcessData[s_Pid.iProcessId][0];			

			Tid=GetTid(&LpMessageStatistic->BSCIdentifier[0]);
			if (Tid<0)
			{
				return UNRECOGNIZED_BSC;
			}

			/* 有6种业务的统计 */
			s_CBSEStatisticResult.cNumber=6;
    
			i=0;

	        /* 写入 */
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=WRITE_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount=
				s_CBSECount.s_ReqBSCCnt[Tid].iCBCProxyWriteReqCnt ;
			i++;
            /* 替换 */
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=REPLACE_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount=
				s_CBSECount.s_ReqBSCCnt[Tid].iCBCProxyReplaceReqCnt ;
			i++;
			/* 删除 */
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=KILL_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount= 
				s_CBSECount.s_ReqBSCCnt[Tid].iCBCProxyKillReqCnt;
			i++;
            /* 消息状态查询查询 */
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=QUERY_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount= 
				s_CBSECount.s_ReqBSCCnt[Tid].iCBCProxyMsgQueryCnt;
			i++;
            /* 小区信道负荷查询 */ 
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=CBCH_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount= 
				s_CBSECount.s_ReqBSCCnt[Tid].iCBCProxyCBCHReqCnt;
			i++;

            /* 小区重启 */ 
			s_CBSEStatisticResult.s_StattypeCount[i].cStatisticType=RESET_STATISTIC;
			s_CBSEStatisticResult.s_StattypeCount[i].iCount= 
				s_CBSECount.s_ReqBSCCnt[Tid].iCBCProxyResetCnt;

			memcpy(&ProcessData[s_Pid.iProcessId][sizeof(MESSAGE_STATISTIC_t)],&s_CBSEStatisticResult,s_CBSEStatisticResult.cNumber*sizeof(STATTYPE_COUNT_t)+1);

			/* 创建统计定时器 */
			iReturnValue=create_timer(LpMessageStatistic->StatTimeLength*1000,
				STATISTIC_TIMER,(char *)&s_Pid,NULL);
			/* 创建定时器失败 */
			if (iReturnValue<0)
			{
				printf("Create timer Error!\n");
				/* 释放进程 */
				free_pid((char *)&s_Pid);
				return iReturnValue;
			}
			/* 保存统计定时器在进程区尾部 */
			memcpy(&ProcessData[s_Pid.iProcessId][LPCB_DATA_SIZE-sizeof(int)],&iReturnValue,sizeof(int));

		}
		break;

    case CELL_CBSE_CNT: /* 小区服务元素的统计,包括成功和失败 */
		{
			/* 分配一个统计进程 */
		    s_Pid.cFunctionId=FUNCTIONID;
            s_Pid.cModuleId=MODULEID;
			s_Pid.iProcessId=alloc_pid((char *)&s_Pid);
			if ( s_Pid.iProcessId < 0 )
			{
				printf("Creat Process Error\n");
				return FAILURE;
			}

			memcpy(&LpMessageStatistic->s_StatMessageHead.s_ReceiverPid,
				&s_Pid,sizeof(PID_t));

			memset(&ProcessData[s_Pid.iProcessId][0],0,LPCB_DATA_SIZE);
			memset(&s_CBSEStatisticResult,0,sizeof(CBSE_STATISTIC_RESULT_t));

			memcpy(&ProcessData[s_Pid.iProcessId][0],LpCBEMessage,LpCBEMessage->iLen+2);
			LpMessageStatistic=(MESSAGE_STATISTIC_t *)&ProcessData[s_Pid.iProcessId][0];			

			/* 初始为不存在 */
			bIfCellExist=0;

			for(i=0;i<MAX_BSC_CONNECT;i++)
			{
				if (s_BSCCellInfo[i].bFlag==1)
				{
  					for(j=0;j<s_BSCCellInfo[i].cNumberOfBTS;j++)
					{
						for(k=0;k<s_BSCCellInfo[i].s_BTSCellInfo[j].cNumberOfCell;k++)
						{
							if(memcmp(&LpMessageStatistic->cCellId[0],
								&s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].cCellId[0],4)==0)
							{
								/* 记下小区在系统中的位置,记在进程尾部 */
								memcpy(&ProcessData[s_Pid.iProcessId][LPCB_DATA_SIZE-16],&i,4);
								memcpy(&ProcessData[s_Pid.iProcessId][LPCB_DATA_SIZE-12],&j,4);
								memcpy(&ProcessData[s_Pid.iProcessId][LPCB_DATA_SIZE-8],&k,4);
								bIfCellExist=EXIST;
								/* 跳出循环 */
								goto L_out;
							}
						}
					}
				}
			}

L_out:
			if(bIfCellExist==0)
			{
				return NO_RECOGNIZEABLE_CELL;
			}

			memset(&s_CellCBSEStatisticResult,0,sizeof(CELL_CBSE_STATISTIC_RESULT_t));   

			s_CellCBSEStatisticResult.cNumber=0;

			/* 写入 */
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].cStatisticType=WRITE_STATISTIC;
			/* 发送总数 */
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].iSendCount=
				s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].s_WriteCount.iSendCount;
			/* 成功总数 */
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].iSuccessCount=
				s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].s_WriteCount.iSuccessCount;
			/* 基站系统负荷超载 */
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].ibsscapErr=
				s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].s_WriteCount.ibsscapErr;
			/* 小区内存溢出	 */
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].icellmemErr=
				s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].s_WriteCount.icellmemErr;
			/* 基站系统内存溢出	 */
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].ibssmemErr=
				s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].s_WriteCount.ibssmemErr;
			/* 其他错误 */
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].iotherErr=
				s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].s_WriteCount.iotherErr;
	
			s_CellCBSEStatisticResult.cNumber++;
    
            /* 替换 */
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].cStatisticType=REPLACE_STATISTIC;
			memcpy(&s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].iSuccessCount
			,&s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].s_ReplaceCount,sizeof(CELL_STAT_t));

			s_CellCBSEStatisticResult.cNumber++;
			
			/* 删除 */
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].cStatisticType=KILL_STATISTIC;
			memcpy(&s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].iSuccessCount
			,&s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].s_KillCount,sizeof(CELL_STAT_t));

			s_CellCBSEStatisticResult.cNumber++;

			
            /* 消息状态查询查询 */
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].cStatisticType=QUERY_STATISTIC;
			memcpy(&s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].iSuccessCount
			,&s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].s_QueryCount,sizeof(CELL_STAT_t));

			s_CellCBSEStatisticResult.cNumber++;

			
            /* 小区信道负荷查询 */ 
			s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].cStatisticType=CBCH_STATISTIC;
			memcpy(&s_CellCBSEStatisticResult.s_StattypeCount[s_CellCBSEStatisticResult.cNumber].iSuccessCount
			,&s_BSCCellInfo[i].s_BTSCellInfo[j].s_CellId[k].s_CBCHCount,sizeof(CELL_STAT_t));

			s_CellCBSEStatisticResult.cNumber++;

			
			memcpy(&ProcessData[s_Pid.iProcessId][sizeof(MESSAGE_STATISTIC_t)],&s_CellCBSEStatisticResult,s_CellCBSEStatisticResult.cNumber*sizeof(CELL_STATTYPE_COUNT_t)+1);

			/* 创建统计定时器 */
			iReturnValue=create_timer(LpMessageStatistic->StatTimeLength*1000,
				STATISTIC_TIMER,(char *)&s_Pid,NULL);
			/* 创建定时器失败 */
			if (iReturnValue<0)
			{
				printf("Create timer Error!\n");
				/* 结束统计进程 */
				free_pid((char *)&s_Pid);

				return iReturnValue;
			}
			/* 保存统计定时器在进程区尾部 */
			memcpy(&ProcessData[s_Pid.iProcessId][LPCB_DATA_SIZE-sizeof(int)],&iReturnValue,sizeof(int));

		}
		break;

	default:
		{
			/* 无法识别的统计类型 */
			return UNRECOGNIZED_STATISTIC_TYPE;
		}
		break;

	}

	return s_Pid.iProcessId;
}


/* 处理小区广播失败和重新复位的次数的统计 
 * <0:返回错误, >=0:返回Pid
 */
int Process_Statistic_FailAndReset(CBEMESSAGE_t *LpCBEMessage)
{
	MESSAGE_STATISTIC_t            *LpMessageStatistic;
	int                            iReturnValue;
	PID_t                          s_Pid;
	int                            Tid;
	int                            i,j,k;
//    CELL_RESET_AND_FAIL_STAT_RESULT_t  s_CellResetAndFailStatResult;
	CELL_RESETFAIL_COUNT_t         s_Cell_ResetFail_Count; 
	unsigned char                  bIfCellExist; 

⌨️ 快捷键说明

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