VOS_VOID TAF_SPM_InitEntityFsm(VOS_VOID) { VOS_UINT8 i; /* for 循环,初始化所有实体状态机上下文 */ for (i = 0; i < TAF_SPM_MAX_CLIENT_ID_ENTITY_FSM_ID_NUM; i++) { /* 根据设置当前的实体状态机 */ TAF_SPM_SetCurrEntityFsmAddr(i); /* 初始化实体上下文 */ TAF_SPM_InitEntityFsmCtx(TAF_SPM_GetCurrEntityFsmCtxAddr()); TAF_SPM_SetCurrEntityFsmRunFlg(VOS_FALSE); TAF_SPM_SetCurrEntityFsmClientId(TAF_SPM_INVALID_CLIENT_ID); } }
VOS_UINT32 TAF_SPM_RcvAppReqMsg_Main( VOS_UINT32 ulEventType, struct MsgCB *pstMsg ) { VOS_UINT16 usClientId; VOS_UINT8 ucOpId; VOS_UINT8 ucIdleFsmIndex; TAF_SPM_GetClientIdWithAppMsg(pstMsg, &usClientId); TAF_SPM_GetOpIdWithAppMsg(pstMsg, &ucOpId); /* 判断是否有存在空闲状态机 */ ucIdleFsmIndex = TAF_SPM_GetIdleEntityFsmIndex(); if (TAF_SPM_INVALID_CLIENT_ID_ENTITY_FSM_INDEX == ucIdleFsmIndex) { TAF_WARNING_LOG(WUEPS_PID_TAF, "TAF_SPM_RcvAppReqMsg_Main():WARNING: No Idle Entiy Fsm Exist!"); /* 临时响应改为正式响应 */ TAF_SPM_SendServiceRequetFail_Main(ulEventType, pstMsg, MN_ERR_CLASS_SPM_BEYOND_CONCURRENCY_CAPABILITY); #if (FEATURE_ON == FEATURE_IMS) TAF_SPM_SetEconfPreRslt(TAF_CS_CAUSE_UNKNOWN); TAF_SPM_ReportEconfCheckRslt(); #endif } else { /* 设置当前状态机的索引 */ TAF_SPM_SetCurrEntityFsmAddr(ucIdleFsmIndex); /* 设置当前client ID实体状态机的client ID */ TAF_SPM_SetCurrEntityFsmClientId(usClientId); /* 启动service ctrl状态机,进行fdn&CALL control检查 */ TAF_SPM_FSM_InitEntityFsm(TAF_SPM_FSM_SERVICE_CTRL, TAF_SPM_GetServiceCtrlFsmDescAddr(), TAF_SPM_SERVICE_CTRL_STA_INIT); } return VOS_TRUE; }
VOS_UINT32 TAF_SPM_ProcessMsgInFsm( VOS_UINT32 ulEventType, struct MsgCB *pstMsg ) { VOS_UINT32 ulRet; VOS_UINT8 ucFsmIndex; VOS_UINT8 ucNewFsmIndex; VOS_UINT16 usClientId; ulRet = VOS_FALSE; usClientId = TAF_SPM_INVALID_CLIENT_ID; ucFsmIndex = TAF_SPM_INVALID_CLIENT_ID_ENTITY_FSM_INDEX; /* 获取到client ID后才在实体状态机中进行查找相同 client ID,否则直接在main状态机中进行处理 */ if (VOS_TRUE == TAF_SPM_GetClientId(pstMsg, &usClientId)) { ucFsmIndex = TAF_SPM_GetEntityFsmIndexByClientId(usClientId); } /* 状态机索引有效,说明有相同client ID的实体状态机在运行 */ if (TAF_SPM_INVALID_CLIENT_ID_ENTITY_FSM_INDEX != ucFsmIndex) { /* 设置当前client ID实体状态机的client ID */ TAF_SPM_SetCurrEntityFsmClientId(usClientId); /* 设置当前client ID实体状态机的数组索引 */ TAF_SPM_SetCurrEntityFsmAddr(ucFsmIndex); /* 消息进入client ID实体状态机处理 */ ulRet = TAF_SPM_ProcessMsgInEntityFsm(ucFsmIndex, ulEventType, pstMsg); return ulRet; } /* 索引无效说明未找到相同client id的状态机,需要在main中继续查找 */ ulRet = TAF_SPM_FSM_ProcessEvent(TAF_SPM_MAIN_STA_IDLE, ulEventType, pstMsg, TAF_SPM_GetMainFsmDescAddr()); /* 已经处理完成返回 */ if (VOS_FALSE == ulRet) { return VOS_FALSE; } /* 说明有可能启动了状态机,需要获取新的空闲client ID实体状态机索引 */ ucNewFsmIndex = TAF_SPM_GetEntityFsmIndexByClientId(usClientId); /* 索引有效则取出指定的状态机ID */ if (TAF_SPM_INVALID_CLIENT_ID_ENTITY_FSM_INDEX != ucNewFsmIndex) { /* 设置当前client ID实体状态机的client ID */ TAF_SPM_SetCurrEntityFsmClientId(usClientId); /* 设置当前client ID实体状态机的数组索引 */ TAF_SPM_SetCurrEntityFsmAddr(ucNewFsmIndex); /* 主状态机有可能启动状态机,如果启动状态机,消息还需要进子状态机处理 */ ulRet = TAF_SPM_ProcessMsgInEntityFsm(ucNewFsmIndex, ulEventType, pstMsg); } return ulRet; }