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

📄 cbcfunction.c

📁 CBS(小区广播)程序实现手稿
💻 C
📖 第 1 页 / 共 5 页
字号:
	    				LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].bResendFlag=1;

						return CONTINUANCE;

					}
					else/* 重发次数>=3 */
					{
						/* 暂时失败置为永久失败 */
						for(i=0;i<LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].ilength;i++)
						{
							if((LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].s_CellReport[i].cCellStatus)==TEMP_FAILURE)
							{
								LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].s_CellReport[i].cCellStatus=PERMANENT_FAILURE;
							}
						}
						return CONTINUANCE;
					}

				}
				else/* 不重发 */
				{
					return CONTINUANCE;
				}

			}
			/* 不是重发消息的响应 */
			else
			{
				/* 初始状态为成功 */
//				for (j=0;j<LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].ilength;j++)
//				{
//					LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].s_CellReport->cCellStatus=CELL_SUCCESS;
//				}



				/* 要重发 */
				if(cNeedResend==1)
				{
					/* 重发定时器 */
					iReturnValue=create_timer(RESEND_PERIOD,SCHEDULED_RESEND,(char *)&s_Pid,&s_BscConnectInfo[Tid].BscIdentifier[0]);
   					if (iReturnValue<0)
					{
        				printf("Create Resend timer Error!\n");
						return END;
					}

					/* 生命定时器 */
					if (LPs_WriteReplaceProcessDataStruct->iLifeTimerId>=0)
					{
						kill_timer(LPs_WriteReplaceProcessDataStruct->iLifeTimerId,(char *)&s_Pid);						
					}
						
					iReturnValue=create_timer((RESEND_PERIOD+WAIT_RESPONSE_TIME),LIFE_PERIOD,(char *)&s_Pid,NULL);
   					if (iReturnValue<0)
					{
        				printf("Create Resend timer Error!\n");
						return END;
					}
					LPs_WriteReplaceProcessDataStruct->iLifeTimerId=iReturnValue;
						
					/* 重发标志置1 */
    				LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].bResendFlag=1;
						
					/* 处于回复定时器阶段 */
					if (LPs_WriteReplaceProcessDataStruct->iTimerId>=0)
					{
						return CONTINUANCE;
					}
					else
					{
						/* 返回单条响应 */
						Process_WriteReturnSingleResponseToCBCProxy(&s_Pid,iBscPosi);
						return CONTINUANCE;
					}
			

				}
				else
				/* 不重发 */
				{
					/* 是否可结束 */
					if(IfReturnImmediately(&LPs_WriteReplaceProcessDataStruct->s_ResponseCellList)>0)
					{
						/* 是否处于回复定时阶段 */
						if (LPs_WriteReplaceProcessDataStruct->iTimerId>=0)
						{							
							/* 全返回 */
                            Process_WriteReplace_Return_To_CBCProxy(s_Pid);

							kill_timer(LPs_WriteReplaceProcessDataStruct->iTimerId, (char *)&s_Pid);

							return END;
						}
						/* 不是回复定时阶段 */
						else
						{
							//返回单条消息
							Process_WriteReturnSingleResponseToCBCProxy(&s_Pid,iBscPosi);
							return CONTINUANCE;
						}						

					}
					/* 不可结束 */
					else
					{
						/* 是否处于回复定时阶段 */
						if (LPs_WriteReplaceProcessDataStruct->iTimerId>=0)
						{
							return CONTINUANCE;
						}
						else/* 不是回复定时阶段 */
						{
							//返回单条消息
							Process_WriteReturnSingleResponseToCBCProxy(&s_Pid,iBscPosi);

							return CONTINUANCE;
						}
					}


				}
		


			}

		}
		break;
	case CBCPROXY_REPORT_REPLACE :        /* 替换操作的报告 */  
		{
			if(m_Report.p_NoofBroadcastComlList.bFlag==EXIST)
			{
				/* 小区REPLACE成功次数加一 */
				for(i=0;i<m_Report.p_NoofBroadcastComlList.ilength;i++)
				{
#ifdef  OPEN_STATISTIC
					Update_Cell_Statistic_Count(&m_Report.p_NoofBroadcastComlList.s_NoOfBroadcastComl[i].s_Cellid.cCellId[0],Tid,REPLACE_STATISTIC,1,0);
#endif
				}
			}

			LPs_WriteReplaceProcessDataStruct=(WRITEREPLACE_PROCESS_DATA_STRUCT  *)&ProcessData[s_Pid.iProcessId][0];


			/* 找到对应的BSC */
			for(i=0;i<LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.cNumberOfBSC;i++)
			{

				if (memcmp(&s_BscConnectInfo[Tid].BscIdentifier[0],
					&LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].BSCIdentifier[0],
					BSC_INDENTIFIER_LEN)==0)
				{
					break;
				}
			}	
				
			iBscPosi=i;

			if (iBscPosi=LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.cNumberOfBSC)
			{/* 非法响应 */
				return FAILURE;
			}

			/* 收到响应置1 */
			LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].bReceiveRespons=1;

			/* 置相应的小区状态 */
			if (m_Report.p_FailureReportList.bFlag==1)
			{
				/* 小区匹配,考虑小区识别器为1或2,只匹配小区识别码 */
				for (i=0;i<m_Report.p_FailureReportList.iLength;i++)
				{
					for(j=0;j<LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].ilength;j++)
					{
						if(memcmp(&m_Report.p_FailureReportList.s_FailureReason[i].s_Cellid.cCellId[2],
							&LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].s_CellReport[j].s_CellId.cCellId[2]
							,2)==0)
						{
							LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].s_CellReport[j].cCellStatus=
								m_Report.p_FailureReportList.s_FailureReason[i].cCause;

							/* 是否要重发 
					  			基站系统负荷超载	(7),
					   			小区内存溢出		(8),
					   			基站系统内存溢出	(9),
							*/
							if ((m_Report.p_FailureReportList.s_FailureReason[i].cCause==BSS_CAPACITY_EXCEEDED)||
								(m_Report.p_FailureReportList.s_FailureReason[i].cCause==CELL_MEMORY_EXCEEDED)||
								(m_Report.p_FailureReportList.s_FailureReason[i].cCause==BSS_MEMORY_EXCEEDED))
							{
								LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].s_CellReport[j].cCellStatus=TEMP_FAILURE;
								cNeedResend=1;
#ifdef  OPEN_STATISTIC	
								/* 失败次数加一 */
								Update_Cell_Statistic_Count(&m_Report.p_FailureReportList.s_FailureReason[i].s_Cellid.cCellId[0],Tid
									,REPLACE_STATISTIC, 2,m_Report.p_FailureReportList.s_FailureReason[i].cCause);
#endif
							}
							else/* 置永久失败 */
							{
								LPs_WriteReplaceProcessDataStruct->s_ResponseCellList.s_BSCCellList[iBscPosi].s_CellReport[j].cCellStatus=PERMANENT_FAILURE;
							}
												
						}
					}
				}
						
			}




			
			/* 置ComlList */
			
			if(m_Report.p_NoofBroadcastComlList.bFlag==EXIST)
			{
				/* 加一个完成列表 */
				Process_Add_One_ComlList(&m_Report.p_NoofBroadcastComlList,
					&LPs_WriteReplaceProcessDataStruct->s_NoofBroadcastComlList,
					&s_BscConnectInfo[Tid].BscIdentifier[0],
					&s_BSCCellInfo[Tid].cLacId[0]					
					);
			}

			/* 处于回复定时器阶段 */
			if (LPs_WriteReplaceProcessDataStruct->iTimerId>=0)
			{
				/* 是否可结束 */
				if(IfReturnImmediately(&LPs_WriteReplaceProcessDataStruct->s_ResponseCellList)>0)
				{/* 全部响应 */
					
					/* 返回全部响应 */
                	Process_WriteReplace_Return_To_CBCProxy(s_Pid);
					/* 释放回复定时器 */
					kill_timer(LPs_WriteReplaceProcessDataStruct->iTimerId, (char *)&s_Pid);

					return END;

				}
				else
				{/* 部分响应 */
					return CONTINUANCE;
				}

			}
			else
			{
				/* 返回单条响应 */
				Process_ReplaceReturnSingleResponseToCBCProxy(&s_Pid,iBscPosi);

				return CONTINUANCE;
			}
			
		}
		break;
    case CBCPROXY_REPORT_KILL :           /* 删除操作的报告 */  
		{

			if(m_Report.p_NoofBroadcastComlList.bFlag==EXIST)
			{
				/* 小区KILL成功次数加一 */
				for(i=0;i<m_Report.p_NoofBroadcastComlList.ilength;i++)
				{
#ifdef  OPEN_STATISTIC
					Update_Cell_Statistic_Count(&m_Report.p_NoofBroadcastComlList.s_NoOfBroadcastComl[i].s_Cellid.cCellId[0],Tid,KILL_STATISTIC,1,0);
#endif
				}
			}

			LPs_KillProcessDataStruct=(KILL_PROCESS_DATA_STRUCT *)&ProcessData[s_Pid.iProcessId][0];

			/* 找到对应的BSC */
			for(i=0;i<LPs_KillProcessDataStruct->s_FailureList.cNumberOfBSC;i++)
			{

				if (memcmp(&s_BscConnectInfo[Tid].BscIdentifier[0],
					&LPs_KillProcessDataStruct->s_FailureList.s_BSCCellList[i].BSCIdentifier[0],
					BSC_INDENTIFIER_LEN)==0)
				{
					break;
				}
			}	
			iBscPosi=i;

			/* 收到响应 */
            LPs_KillProcessDataStruct->s_FailureList.s_BSCCellList[iBscPosi].bReceiveRespons=1;

			if (iBscPosi==LPs_KillProcessDataStruct->s_FailureList.cNumberOfBSC)
			{/* 非法响应 */
				return FAILURE;
			}
			
			/* 置ComlList */
	   		if(m_Report.p_NoofBroadcastComlList.bFlag==EXIST)
			{
				/* 加一个完成列表 */
				Process_Add_One_ComlList(&m_Report.p_NoofBroadcastComlList,
					&LPs_KillProcessDataStruct->s_NoofBroadcastComlList,
					&s_BscConnectInfo[Tid].BscIdentifier[0],
					&s_BSCCellInfo[Tid].cLacId[0]					
					);
			}

			/* 置失败列表 */
			if(m_Report.p_FailureReportList.bFlag==EXIST)
			{
//				LPs_KillProcessDataStruct->s_FailureList.s_BSCCellList[iBscPosi].ilength=
//					m_Report.p_FailureReportList.iLength;

				for(i=0;i<m_Report.p_FailureReportList.iLength;i++)
				{
					for(j=0;j<LPs_KillProcessDataStruct->s_FailureList.s_BSCCellList[iBscPosi].ilength;j++)
					{
						if(memcmp(&LPs_KillProcessDataStruct->s_FailureList.s_BSCCellList[iBscPosi].s_CellReport[j].s_CellId.cCellId[2],
							&m_Report.p_FailureReportList.s_FailureReason[i].s_Cellid.cCellId[2],2)==0)
						{
/*------------------------------------------------------------------*/
							if ((m_Report.p_FailureReportList.s_FailureReason[i].cCause==BSS_CAPACITY_EXCEEDED)||
								(m_Report.p_FailureReportList.s_FailureReason[i].cCause==CELL_MEMORY_EXCEEDED)||
								(m_Report.p_FailureReportList.s_FailureReason[i].cCause==BSS_MEMORY_EXCEEDED))
							{
#ifdef  OPEN_STATISTIC	
								/* 失败次数加一 */
								Update_Cell_Statistic_Count(&m_Report.p_FailureReportList.s_FailureReason[i].s_Cellid.cCellId[0],Tid
									,KILL_STATISTIC, 2,m_Report.p_FailureReportList.s_FailureReason[i].cCause);
							}
#endif

/*------------------------------------------------------------------*/
							LPs_KillProcessDataStruct->s_FailureList.s_BSCCellList[iBscPosi].s_CellReport[j].cCellStatus=PERMANENT_FAILURE;
						}

					}
					/* 填LAC */
//					memcpy(&LPs_KillProcessDataStruct->s_FailureList.s_BSCCellList[iBscPosi].s_CellReport[i].s_CellId.cCellId[0],
//						&s_BSCCellInfo[Tid].cLacId[0],LAC_INDENTIFIER_LEN);
					
//					memcpy(&LPs_KillProcessDataStruct->s_FailureList.s_BSCCellList[iBscPosi].s_CellReport[i].s_CellId.cCellId[2],
//						&m_Report.p_FailureReportList.s_FailureReason[i].s_Cellid.cCellId[2],2);
//					LPs_KillProcessDataStruct->s_FailureList.s_BSCCellList[iBscPosi].s_CellReport[i].cCellStatus=
//						m_Report.p_FailureReportList.s_FailureReason[i].cCause;

				}
			}

			/* 处于回复定时器阶段 */
			if (LPs_KillProcessDataStruct->iTimerId>=0)
			{
				/* 是否可结束 */
				if(IfReturnImmediately(&LPs_KillProcessDataStruct->s_FailureList)>0)
				{/* 全部响应 */
					
					/* 返回全部响应 */
					Process_KillMessage_Return_To_CBCProxy(s_Pid);
					
					/* 释放回复定时器 */
					kill_timer(LPs_KillProcessDataStruct->iTimerId, (char *)&s_Pid);

					return END;

				}
				else
				{/* 部分响应 */
					return CONTINUANCE;
				}

			}
			else
			{
				/* 返回单条响应 */
                Process_KillReturnSingleResponseToCBCProxy(&s_Pid,iBscPosi);

				return CONTINUANCE;
			}
	

		}
		break;
	default:
		{
			printf("Response type Error\n");
			return FAILURE;  
		}

	}

}

/* 处理从BSC来的失败指示 */
int Process_Failure_IND(int Tid)
{
	FAILUREIND_t    s_FailureIND;
	CBEMESSAGE_t    s_CBEMessage;
	CBEMESSAGE_t    s_CBCProxyMessage;
	int             i;
	
	memset(&s_FailureIND,0,sizeof(FAILUREIND_t));
	memset(&s_CBEMessage,0,sizeof(CBEMESSAGE_t));

	memcpy(&s_FailureIND.p_CellList,&CBCBSC_Unpack.p_UplinkCellList,sizeof(CELLLIST_t));
	
	if (s_FailureIND.p_CellList.iLength>MAXCELLCOUNT)
	{
		return FAILURE;
	}

	s_CBEMessage.s_MessageHead.iMessageAreaId=A;
	/* CBSE_FAILURE_IND */
	s_CBEMessage.s_MessageHead.iMessageType=CBCPROXY_FAILURE_IND;

	s_CBEMessage.s_MessageHead.s_SenderPid.cFunctionId=FUNCTIONID;
	s_CBEMessage.s_MessageHead.s_SenderPid.cModuleId=MODULEID;

	/* 去掉小区列表的尾巴 */
	s_CBEMessage.s_MessageHead.iMessageLength=sizeof(CELLLIST_t)+
	    ((MAXCELLCOUNT-s_FailureIND.p_CellList.iLength)*sizeof(CELLID_t));

	s_CBEMessage.iLen=sizeof(MESSAGE_HEAD_t)+s_CBEMessage.s_MessageHead.iMessageLength;

	memcpy(&s_CBEMessage.cMessage[0],(char *)&s_FailureIND,s_CBEMessage.s_MessageHead.iMessageLength);


	for(i=0;i<s_FailureIND.p_CellList.iLength;i++)
	{
		Process_Set_CellId_Status(&s_FailureIND.p_CellList.s_CellList[i].cCellId[0],CELL_ERROR);
	}

	memset(&s_CBCProxyMessage,0,sizeof(CBEMESSAGE_t));
	//压缩列表参数

⌨️ 快捷键说明

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