#include "DynamicRouteDataManage.h"
#include "PhysicalSectionDataManage.h"
#include "InterlockCommonManage.h"

DynamicRouteDataStruct gDynamicRouteDataSt[ROUTE_DYNAMIC_SUM_MAX];
UINT16 gDynamicRouteSum = 0U;
UINT16 gSzDanamicRouteIdBuff[ROUTE_DYNAMIC_SUM_MAX] = {0U};

/**
* @brief 设置动态进路状态
* @param const UINT16 dynamicRouteId 动态进路ID
* @param const UINT8 dyRouteState 动态进路状态
* @return CI_ERROR:失败；CI:SUCCESS:成功
* @note：
*/
static UINT8 SetDynamicRouteState(const UINT16 dynamicRouteId, const UINT8 dyRouteState);

/**
* @brief 动态进路初选处理
* @param const UINT16 wDrId
* @return 无
* @note：
*/
static void DrFirstXuanPaiProc(const UINT16 wDrId);

/**
* @brief 动态进路选排处理
* @param const UINT16 wDrId
* @return 无
* @note：
*/
static void DrXuanPaiProc(const UINT16 wDrId);

/**
* @brief 动态进路锁闭处理
* @param const UINT16 wDrId
* @return 无
* @note：
*/
static void DrLockProc(const UINT16 wDrId);

/**
* @brief 锁闭动态进路条件判断
* @param const UINT16 wDrId 动态进路ID
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockDynamicRouteProc(const UINT16 wDrId);

#if 1
/**
* @brief 锁闭动态进路子进路判断
* @param const UINT16 routeId 进路ID
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockDrSubRouteProc(const UINT16 wSubRouteId);

/**
* @brief 锁闭CBTC级别动态进路子进路条件检查
* @param UINT16 wSubRouteId 子进路ID
* @param UINT8 functionId
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockCbtcDrSubRouteCheck(UINT16 const wSubRouteId);

/**
* @brief 锁闭点式动态进路子进路条件检查
* @param UINT16 wSubRouteId 子进路ID
* @param UINT8 functionId
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockBlocDrSubRouteCheck(UINT16 const wSubRouteId);

/**
* @brief 锁闭VBTC级别动态进路子进路（折返）条件检查
* @param UINT16 wSubRouteId 子进路ID
* @param UINT8 functionId
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockCbtcDrSubReturnRouteCheck(UINT16 const wSubRouteId);

/**
* @brief 锁闭后备动态进路子进路（折返）条件检查
* @param UINT16 wSubRouteId 子进路ID
* @param UINT8 functionId
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockBlocDrSubReturnRouteCkeck(UINT16 const wSubRouteId);

/**
* @brief 锁闭动态进路子进路道岔状态判断
* @param UINT16 wSubRouteId 子进路ID
* @param UINT8 functionId
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockDrSubRouteSwitchCheck(UINT16 wSubRouteId, UINT8 functionId, UINT8 sendLevel);

/**
* @brief 锁闭动态进路子进路道岔位置及可动性检查
* @param UINT16 const routeId
* @param UINT16 *pDevId
* @param UINT8 *pDevState
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 DrSubRouteSwiPosAndMoveValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState, UINT8 sendLevel);

/**
* @brief 锁闭动态进路子进路防护道岔位置及可动性检查
* @param UINT16 const routeId
* @param UINT16 *pDevId
* @param UINT8 *pDevState
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 DrSubRouteProtSwiPosMovValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState, UINT8 sendLevel);
#endif

/**
* @brief 办理动态进路子进路条件检查
* @param const UINT16 wDrId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetDynamicRouteProc(const UINT16 wDrId);

/**
* @brief 办理动态进路子进路条件检查
* @param const UINT16 wDrId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetDrSubRouteProc(const UINT16 routeId);

/**
* @brief 办理动态进路子进路(反向列车进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetDrSubRlTrainRouteCheck(UINT16 const routeId);

/**
* @brief 办理动态进路CBTC子进路(CBTC列车进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetCbtcDrSubRouteCheck(UINT16 const routeId);

/**
* @brief 办理动态进路后备子进路(后备列车进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetBlocDrSubRouteCheck(UINT16 const routeId);

/**
* @brief 办理动态进路子进路(反向折返进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetDrSubRrRouteCheck(UINT16 const routeId);

/**
* @brief 办理动态进路CBTC折返子进路(CBTC折返进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetCbtcDrSubReturnRouteCheck(UINT16 const routeId);

/**
* @brief 办理动态进路后备折返子进路(后备折返进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetBlocDrSubReturnRouteCheck(UINT16 const routeId);

/**
* @brief 办理动态进路子进路道岔条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetDrSubRouteSwitchCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel);

/**
* @brief 获取动态进路总数
* @param 无
* @return 动态进路总数
* @note：
*/
UINT16 GetDynamicRouteSum(void)
{
	UINT16 wRetVal = 0u;
	if (ROUTE_DYNAMIC_SUM_MAX <= gDynamicRouteSum)
	{
		wRetVal = ROUTE_DYNAMIC_SUM_MAX;
	}
	else
	{
		wRetVal = gDynamicRouteSum;
	}
	return wRetVal;
}

/**
* @brief 获取动态进路ID
* @param 无
* @return 动态进路ID
* @note：
*/
UINT16 GetDynamicRouteId(const UINT16 wIndex)
{
	UINT16 wRetVal = 0u;
	UINT16 wDynamicRouteSum = GetDynamicRouteSum();

	if (wIndex < wDynamicRouteSum)
	{
		wRetVal = gSzDanamicRouteIdBuff[wIndex];
	}
	else
	{
		/* 不处理 */
	}
	return wRetVal;
}

/**
* @brief 获取动态进路索引
* @param 无
* @return 动态进路索引
* @note：
*/
UINT16 GetDrBufIndex(const UINT16 wDrId)
{
	UINT16 wRetVal = ROUTE_DYNAMIC_SUM_MAX;
	if (ROUTE_DYNAMIC_SUM_MAX > wDrId)
	{
		wRetVal = wDrId;
	}
	else
	{
		/* 不处理 */
	}
	return wRetVal;
}

/**
* @brief 获取最小可用动态进路（ID最小，状态空闲）
* @param 无
* @return 动态进路ID
* @note：
*/
UINT16 GetUsableDrId(void)
{
	UINT16 ii = 0u;								/*游标*/
	UINT16 wDrId = 0u;

	for (ii = 1u; ii < ROUTE_DYNAMIC_SUM_MAX; ii++)
	{
		if (ROUTE_DYNAMIC_STATE_IDLE == gDynamicRouteDataSt[ii].dynamicRouteState)
		{
			wDrId = gDynamicRouteDataSt[ii].dynamicRouteId;
			break;
		}
	}
	return wDrId;
}

/**
* @brief 获取动态进路状态
* @param 无
* @return 动态进路状态
* @note：
*/
UINT8 GetDynamicRouteState(const UINT16 wDrId)
{
	UINT8 chRetVal = ROUTE_DYNAMIC_STATE_IDLE;
	UINT16 wBufIndex = 0u;
	wBufIndex = GetDrBufIndex(wDrId);
	if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex)
	{
		chRetVal = gDynamicRouteDataSt[wBufIndex].dynamicRouteState;
	}
	else
	{
		; /* 不处理 */
	}
	return chRetVal;
}

/**
* @brief 获取动态进路包含子进路数目
* @param 无
* @return 动态进路包含子进路数目
* @note：
*/
UINT8 GetDrSubRouteSum(const UINT16 wDrId)
{
	UINT8 chRetVal = 0u;
	UINT16 wBufIndex = 0u;
	wBufIndex = GetDrBufIndex(wDrId);
	if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex)
	{
		chRetVal = gDynamicRouteDataSt[wBufIndex].subRouteSum;
	}
	else
	{
		; /* 不处理 */
	}
	return chRetVal;
}

/**
* @brief 设置动态进路包含子进路
* @param 无
* @return 无
* @note：
*/
void SetDrSubRoute(const UINT16 wDrId, const UINT8 chSubSum, UINT16 szSubId[ROUTE_SUBROUTE_SUM_MAX])
{
	UINT16 wBufIndex = 0u;
	UINT8 ii = 0u;
	wBufIndex = GetDrBufIndex(wDrId);
	if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex)
	{
		gDynamicRouteDataSt[wBufIndex].subRouteSum = chSubSum;
		for (ii = 0u; ii < chSubSum; ii++)
		{
			gDynamicRouteDataSt[wBufIndex].subRouteIdBuf[ii] = szSubId[ii];
		}
		SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_FIRST_XUANPAI, 0u);
	}
	else
	{
		; /* 不处理 */
	}
}

/**
* @brief 获取动态进路包含子进路ID
* @param 无
* @return 动态进路包含子进路ID
* @note：
*/
UINT16 * GetDrSubRouteIdBuf(const UINT16 wDrId)
{
	UINT16 * pRetVal = NULL;
	UINT16 wBufIndex = 0u;
	wBufIndex = GetDrBufIndex(wDrId);
	if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex)
	{
		pRetVal = gDynamicRouteDataSt[wBufIndex].subRouteIdBuf;
	}
	else
	{
		; /* 不处理 */
	}
	return pRetVal;
}

/**
* @brief 获取动态进路选排起始周期号
* @param 无
* @return 动态进路包含子进路选排起始周期号
* @note：
*/
UINT32 GetDrXuanPaiStartCyc(const UINT16 wDrId)
{
	UINT32 dwRetVal = 0u;
	UINT16 wBufIndex = 0u;
	wBufIndex = GetDrBufIndex(wDrId);
	if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex)
	{
		dwRetVal = gDynamicRouteDataSt[wBufIndex].xuanpaiStartCycleNum;
	}
	else
	{
		; /* 不处理 */
	}
	return dwRetVal;
}

/**
* @brief 获取动态进路锁闭起始周期号
* @param 无
* @return 动态进路包含子进路锁闭起始周期号
* @note：
*/
UINT32 GetDrLockStartCyc(const UINT16 wDrId)
{
	UINT32 dwRetVal = 0u;
	UINT16 wBufIndex = 0u;
	wBufIndex = GetDrBufIndex(wDrId);
	if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex)
	{
		dwRetVal = gDynamicRouteDataSt[wBufIndex].lockStartCycleNum;
	}
	else
	{
		; /* 不处理 */
	}
	return dwRetVal;
}

/**
* @brief 设置动态进路状态
* @param const UINT16 dynamicRouteId 动态进路ID
* @param const UINT8 dyRouteState 动态进路状态
* @return CI_ERROR:失败；CI:SUCCESS:成功
* @note：
*/
static UINT8 SetDynamicRouteState(const UINT16 dynamicRouteId, const UINT8 dyRouteState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetDrBufIndex(dynamicRouteId);  /*获取道岔数组下标*/

	if (ROUTE_DYNAMIC_SUM_MAX > bufIndex)
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		; /* 不处理 */
	}

	if (CI_SUCCESS == retVal)
	{
		if (ROUTE_DYNAMIC_STATE_IDLE == dyRouteState)
		{/* 动态进路空闲 */

			gDynamicRouteDataSt[bufIndex].xuanpaiStartCycleNum = 0u;  /*清除进路选排起始周期*/
			gDynamicRouteDataSt[bufIndex].lockStartCycleNum = 0u;
		}
		else if(ROUTE_DYNAMIC_STATE_FIRST_XUANPAI == dyRouteState)
		{/* 动态进路初选 */
			gDynamicRouteDataSt[bufIndex].xuanpaiStartCycleNum = Get2oo2CurCycleNum();  /*设置进路选排起始周期*/
			gDynamicRouteDataSt[bufIndex].lockStartCycleNum = 0u;
		}
		else if (ROUTE_DYNAMIC_STATE_XUANPAI == dyRouteState)
		{/* 动态进路选排 */

			gDynamicRouteDataSt[bufIndex].xuanpaiStartCycleNum = 0u;  /*设置进路选排起始周期*/
			gDynamicRouteDataSt[bufIndex].lockStartCycleNum = Get2oo2CurCycleNum();
		}
		else if (ROUTE_DYNAMIC_STATE_LOCK == dyRouteState)
		{/* 动态进路锁闭 */
			gDynamicRouteDataSt[bufIndex].xuanpaiStartCycleNum = 0u;
			gDynamicRouteDataSt[bufIndex].lockStartCycleNum = 0u;
		}
		else
		{
			retVal = CI_ERROR;
		}
	}

	if (CI_SUCCESS == retVal)
	{
		gDynamicRouteDataSt[bufIndex].dynamicRouteState = dyRouteState; /*进路状态*/
	}

	return retVal;
}

/**
* @brief 设置动态进路状态处理(设置动态进路状态，必须通过此函数）
* @param const UINT16 dynamicRouteId 动态进路ID
* @param const UINT8 dyRouteState 动态进路状态
* @return 无
* @note：
*/
void SetDynamicRouteStateProcess(const UINT16 dynamicRouteId, const UINT8 dyRouteState, const UINT8 chFlag)
{
	UINT8 subRouteSum = 0u; /*子进路数目*/
	UINT16* pSubRouteIdBuf = NULL; /*子进路ID数组*/
	UINT8 ii = 0u;
	UINT8 halfRouteLgcNum = 0u;

	subRouteSum = GetDrSubRouteSum(dynamicRouteId); /*子进路数量*/
	pSubRouteIdBuf = GetDrSubRouteIdBuf(dynamicRouteId); /*子进路号*/

	debug_infor_printf((const)"Dynamic route:%d set state:%d cause:%x\n", dynamicRouteId, dyRouteState, chFlag);

	if (subRouteSum == 0u)
	{/* 组合动态进路包含子进路数目不可为0 */
		if ((ROUTE_DYNAMIC_STATE_IDLE == dyRouteState)
			|| (ROUTE_DYNAMIC_STATE_XUANPAI == dyRouteState)
			|| (ROUTE_DYNAMIC_STATE_LOCK == dyRouteState))
		{/* 设置组合动态进路空闲/选排/锁闭时，若组合动态进路子进路数量为0，说明组合动态进路内存被意外改写，
		 风险不可评估 */
			SetPlatOverFlag();
		}
		else
		{
			; /*  */
		}
	}
	else
	{
		if (ROUTE_DYNAMIC_STATE_IDLE == dyRouteState)
		{ /*设置动态进路空闲*/
			for (ii = 0u; ii < subRouteSum; ii++)
			{
				halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]);
				if (0u != halfRouteLgcNum)
				{/* 此进路为部分进路，部分进路包含的逻辑区段数量，仅在是部分进路时才不为零 */
					SetRouteHalfPhySecUsingState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO);
					if (SET_DR_IDLE_CAUSE_FINISHED == chFlag)
					{
						; /* 不处理 */
					}
					else
					{
						/*设置进路部分锁闭区段0*/
						SetHalfRouteLockLgcSec(pSubRouteIdBuf[ii], 0U, NULL);
						/*设置列车脚下资源0*/
						SetHalfRouteTrainLocLgcSec(pSubRouteIdBuf[ii], 0U, NULL);
						/*设置道岔不可动标志*/
						SetHalfRouteSwitchMoveValid(pSubRouteIdBuf[ii], ROUTE_HALF_SWITCH_MOVE_INVALID);
						/*设置资源请求列车ID为0*/
						SetHalfRouteResReqTrainId(pSubRouteIdBuf[ii], 0U);
					}
				}
				else
				{
					SetRoutePhySectionOccupyState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO); /*清除子进路征用*/
				}
			}
		}
		else if (ROUTE_DYNAMIC_STATE_FIRST_XUANPAI == dyRouteState)
		{/*设置动态进路初选*/

			for (ii = 0u; ii < subRouteSum; ii++)
			{
				halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]);
				if (0u != halfRouteLgcNum)
				{/* 此进路为部分进路，部分进路包含的逻辑区段数量，仅在是部分进路时才不为零 */
					SetRouteHalfPhySecUsingState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_YES);
				}
				else
				{
					SetRoutePhySectionOccupyState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_YES); /*设置子进路征用*/
				}
			}
		}
		else if (ROUTE_DYNAMIC_STATE_XUANPAI == dyRouteState)
		{ /*设置动态进路选排*/
			; /* 不处理 */
		}
		else if (ROUTE_DYNAMIC_STATE_LOCK == dyRouteState)
		{ /*设置动态进路锁闭*/

			for (ii = 0u; ii < subRouteSum; ii++)
			{
				halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]);
				if (0u != halfRouteLgcNum)
				{/* 此进路为部分进路，部分进路包含的逻辑区段数量，仅在是部分进路时才不为零 */
					SetRouteHalfPhySecUsingState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO);
				}
				else
				{
					SetRoutePhySectionOccupyState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO); /*清除子进路征用*/
				}
			}
		}
		else
		{
			/* 状态错误不可设置 */
			return;
		}

		/*设置动态进路状态*/
		(void)SetDynamicRouteState(dynamicRouteId, dyRouteState);
	}
}

/*
* 功能描述： 初始化动态进路数据
* 参数说明： void
* 返回值  ： 无
*			 
*/
void InitialDynamicRouteData(void)
{
	UINT16 ii = 0u;								/*游标*/
	UINT16 dynamicRouteId = 0u;

	for (ii = 1u; ii < ROUTE_DYNAMIC_SUM_MAX; ii++)
	{
		gDynamicRouteDataSt[ii].dynamicRouteId = ii;
		gDynamicRouteDataSt[ii].dynamicRouteState =ROUTE_DYNAMIC_STATE_IDLE;
		gSzDanamicRouteIdBuff[gDynamicRouteSum++] = gDynamicRouteDataSt[ii].dynamicRouteId;
	}

}

/**
* @brief 动态进路状态主处理函数
* @param 无
* @return 无
* @note：
*/
void DynamicRouteLogicProcess(void)
{
	UINT8 chDrState = 0u; /*动态进路状态*/
	UINT16 wDrId = 0u; /*动态进路ID*/
	UINT16 ii = 0u; /*循环索引*/
	UINT16 dynamicRouteSum = 0U;
	UINT8 chStartLockFlag = CI_START_LOCK_YES;

	chStartLockFlag = GetStartLockFlag();
	if (CI_START_LOCK_NO != chStartLockFlag)
	{ /*未上电解锁*/
		; /* 不处理 */
	}
	else
	{
		dynamicRouteSum = GetDynamicRouteSum();
		/*处理动态进路*/
		for (ii = 0u; ii < dynamicRouteSum; ii++)
		{
			wDrId = GetDynamicRouteId(ii);
			chDrState = GetDynamicRouteState(wDrId);

			if (ROUTE_DYNAMIC_STATE_IDLE == chDrState)
			{/* 进路空闲 */
				; /* 不处理 */
			}
			else if (ROUTE_DYNAMIC_STATE_FIRST_XUANPAI == chDrState)
			{/* 动态进路初选 */
				DrFirstXuanPaiProc(wDrId);
			}
			else if (ROUTE_DYNAMIC_STATE_XUANPAI == chDrState)
			{/* 动态进路选排 */
				DrXuanPaiProc(wDrId);
			}
			else if (ROUTE_DYNAMIC_STATE_LOCK == chDrState)
			{/* 动态进路锁闭 */
				DrLockProc(wDrId);
			}
			else
			{
				/* 状态异常 */
				SetPlatOverFlag();
			}
		}
	}
}

/**
* @brief 动态进路初选处理
* @param const UINT16 wDrId 动态进路ID
* @return 无
* @note：
*/
static void DrFirstXuanPaiProc(const UINT16 wDrId)
{
	UINT8 chDrSubRouteSum = 0u; /*子进路数目*/
	UINT16* pDrSubRouteIdBuf = NULL; /*子进路ID数组*/
	UINT8 ii = 0u;
	UINT8 chFunRtn = CI_ERROR;
	UINT8 chCount = 0u;
	UINT8 halfRouteLgcNum = 0u;

	chDrSubRouteSum = GetDrSubRouteSum(wDrId); /*子进路数量*/
	pDrSubRouteIdBuf = GetDrSubRouteIdBuf(wDrId); /*子进路号*/

	chFunRtn = SetDynamicRouteProc(wDrId);
	if (CI_SUCCESS == chFunRtn)
	{
		for (ii = 0u; ii < chDrSubRouteSum; ii++)
		{
			halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pDrSubRouteIdBuf[ii]);
			if (0u != halfRouteLgcNum)
			{/* 获取部分征用状态 *//* 此进路为部分进路，部分进路包含的逻辑区段数量，仅在是部分进路时才不为零 */
				chFunRtn = RouteHalfFirstXuanProc(pDrSubRouteIdBuf[ii]);
			}
			else
			{/* 获取进路征用状态 */
				chFunRtn = RouteFirstXuanProc(pDrSubRouteIdBuf[ii]);
			}
			if (CI_SUCCESS == chFunRtn)
			{/* 征用成功 */
				chCount++;
			}
			else if (RETURN_FIRSTXUANPAI_ERR_WAIT == chFunRtn)
			{/* 征用等待 */
				;
			}
			else
			{/* 征用失败 */
				break;
			}
		}

		if (chCount == chDrSubRouteSum)
		{
			/* 所有进路征用成功，设置动态进路选排 */
			SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_XUANPAI, 0u);
			DrXuanPaiProc(wDrId);
		}
		else if (ii == chDrSubRouteSum)
		{
			; /* 征用等待，不处理 */
		}
		else
		{
			/* 征用失败，设置动态进路空闲 */
			SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT);
		}
	}
	else
	{
		/* 征用失败，设置动态进路空闲 */
		SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT);
	}
}

/**
* @brief 动态进路选排处理
* @param const UINT16 wDrId 动态进路ID
* @return 无
* @note：
*/
static void DrXuanPaiProc(const UINT16 wDrId)
{
	UINT8 chDrSubRouteSum = 0u; /*子进路数目*/
	UINT16* pDrSubRouteIdBuf = NULL; /*子进路ID数组*/
	UINT8 ii = 0u;
	UINT8 chFunRtn = CI_ERROR;
	UINT8 halfRouteLgcNum = 0u;
	UINT8 chkSwitchPos = CI_ERROR;
	UINT8 RtnTemp = CI_ERROR;

	chDrSubRouteSum = GetDrSubRouteSum(wDrId); /*子进路数量*/
	pDrSubRouteIdBuf = GetDrSubRouteIdBuf(wDrId); /*子进路号*/

	if (NULL != pDrSubRouteIdBuf)
	{
		chFunRtn = LockDynamicRouteProc(wDrId);
		if (RETURN_LOCK_ERR_SWITPOS == chFunRtn)
		{
			/*锁闭条件检查失败，道岔位置错误*/

			for (ii = 0u; ii < chDrSubRouteSum; ii++)
			{
				halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pDrSubRouteIdBuf[ii]);
				if (0u != halfRouteLgcNum)
				{/* 此进路为部分进路，部分进路包含的逻辑区段数量，仅在是部分进路时才不为零 */
					chkSwitchPos = ChekRouteHalfSwPosRight(pDrSubRouteIdBuf[ii]);/*检查道岔位置是否正确*/
					if (CI_SUCCESS == chkSwitchPos)
					{
						; /* 本进路道岔位置正确，继续遍历 */
					}
					else
					{
						RtnTemp = RouteLockHalfDriveSwitch(pDrSubRouteIdBuf[ii]);
						if (CI_ERROR == RtnTemp)
						{
							SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT);  /*-->设置动态进路空闲*/
						}
						else
						{
							; /* 不处理 */
						}
					}
				}
				else
				{
					chkSwitchPos = CheckRouteSwitchPosRight(pDrSubRouteIdBuf[ii]);

					if (CI_SUCCESS == chkSwitchPos)
					{ /*进路道岔位置正确*/
					}
					else
					{ /*道岔未动作到位*/
						RtnTemp = RouteLockDriveSwitch(pDrSubRouteIdBuf[ii], SWITCH_NEED_DRIV_FALSE);
						if (CI_ERROR == RtnTemp)
						{
							/*道岔驱动失败*/
							SetRoutAssoSwitSingOperStat(pDrSubRouteIdBuf[ii], SWITCH_SINGLE_OPERATED_FALSE);/*清除进路带动道岔组被单操过的历史*/

							SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT);  /*-->设置动态进路空闲*/
						}
						else
						{
							; /* 不处理 */
						}
					}
				}

				if (CI_SUCCESS != chkSwitchPos)
				{/* 处理失败 */
					break;
				}
				else
				{
					; /* 不处理 */
				}
			}

		}
		else if (CI_SUCCESS == chFunRtn)
		{
			for (ii = 0u; ii < chDrSubRouteSum; ii++)
			{
				SetRoutAssoSwitSingOperStat(pDrSubRouteIdBuf[ii], SWITCH_SINGLE_OPERATED_FALSE);/*清除进路带动道岔组被单操过的历史*/

				SetRouteBelongDrId(pDrSubRouteIdBuf[ii], wDrId);	/*-->设置进路所属动态进路*/

				halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pDrSubRouteIdBuf[ii]);
				if (0u != halfRouteLgcNum)
				{/* 此进路为部分进路，部分进路包含的逻辑区段数量，仅在是部分进路时才不为零 */
					SetRouteStateManage(pDrSubRouteIdBuf[ii], ROUTE_STATE_HALF_LOCK); /* 设置进路部分锁闭 */
					RouteHalfLockManage(pDrSubRouteIdBuf[ii]);
				}
				else
				{
					/* 完整进路需先设置初锁，然后设置初锁异常，区段锁闭状态、资源状态、防护道岔状态等仅在设置进路初锁中设置 */
					SetRouteStateManage(pDrSubRouteIdBuf[ii], ROUTE_STATE_FIRST_LOCK); /*-->设置进路初锁*/

					/* 设置完整进路初锁异常，后续动态进路锁闭中由远及近依次设置初锁，达到由远及近开放的效果 */
					SetRouteStateManage(pDrSubRouteIdBuf[ii], ROUTE_STATE_FIRST_LOCKERR); /*-->设置进路初锁异常*/

					SetRouteGroupRouteCmdFlag(pDrSubRouteIdBuf[ii], ROUTE_GROUPROUTE_CMD_YES);/*设置进路存在组合进路命令标志*/
				}
			}

			SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_LOCK, 0u); /*-->设置动态进路锁闭*/
		}
		else
		{ /*进路锁闭失败*/

			SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT);  /*-->设置动态进路空闲*/
		}
	}
}

/**
* @brief 动态进路锁闭处理
* @param const UINT16 wDrId 动态进路ID
* @return 无
* @note：本函数执行由远及近开放逻辑，组合动态进路子进路由近及远存储，倒序遍历，
*		直到遍历到部分进路表示已经全部完成开放，组合动态进路生命周期结束。
*/
static void DrLockProc(const UINT16 wDrId)
{
	UINT8 chSubRouteSum = 0u; /*子进路数目*/
	UINT16* pSubRouteIdBuf = NULL; /*子进路ID数组*/
	UINT8 ii = 0u;
	UINT16 wBelongDrId = 0u;
	UINT8 chRouteState = 0u;
	UINT8 chFlag = FLAG_UNSET;
	UINT8 halfRouteLgcNum = 0u;

	chSubRouteSum = GetDrSubRouteSum(wDrId); /*子进路数量*/
	pSubRouteIdBuf = GetDrSubRouteIdBuf(wDrId); /*子进路号*/

	for (ii = 0u; ii < chSubRouteSum; ii++)
	{
		chRouteState = GetRouteState(pSubRouteIdBuf[ii]);
		wBelongDrId = GetRouteBelongDrId(pSubRouteIdBuf[ii]);
		halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]);
		if (0u != halfRouteLgcNum)
		{/* 此进路为部分进路，部分进路包含的逻辑区段数量，仅在是部分进路时才不为零 */
			if (((ROUTE_STATE_HALF_LOCK == chRouteState) || (ROUTE_STATE_HALF_UNLOCKDELAY == chRouteState) || (ROUTE_STATE_HALF_UNLOCK == chRouteState))
				&& (wBelongDrId == wDrId))
			{
				; /* 状态满足，继续遍历 */
			}
			else
			{
				chFlag = FLAG_SET;
			}
		}
		else
		{
			if ((ROUTE_STATE_FIRST_LOCKERR == chRouteState)
				&& (wBelongDrId != wDrId))
			{ /*子进路状态不为初锁异常*/
				chFlag = FLAG_SET;
			}
			else
			{
				; /* 继续遍历 */
			}
		}
		if (FLAG_SET == chFlag)
		{
			break;
		}
		else
		{
			; /* 继续遍历 */
		}
	}

	chFlag = FLAG_UNSET;
	if ((0u != ii) && (ii == chSubRouteSum))
	{
		for (ii = chSubRouteSum - 1u; 0u <= ii; ii--)/*退出条件判断在中间break*/
		{
			chRouteState = GetRouteState(pSubRouteIdBuf[ii]);
			wBelongDrId = GetRouteBelongDrId(pSubRouteIdBuf[ii]);
			if ((ROUTE_STATE_YUXIAN_OPEN == chRouteState) ||
				(ROUTE_STATE_NEAR_OPEN == chRouteState))
			{ /*子进路状态为预先开放||接近开放*/

				; /* 跳过已开放进路,继续遍历 */
			}
			else if (ROUTE_STATE_FIRST_LOCK == chRouteState)
			{ /*进路初锁*/
				chFlag = FLAG_SET;
			}
			else if ((ROUTE_STATE_HALF_LOCK == chRouteState) || (ROUTE_STATE_HALF_UNLOCKDELAY == chRouteState) || (ROUTE_STATE_HALF_UNLOCK == chRouteState))
			{/*部分锁闭，已完成所有进路开放*/
				SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FINISHED);  /*设置动态进路空闲*/
				chFlag = FLAG_SET;
			}
			else
			{
				if ((ROUTE_STATE_FIRST_LOCKERR != chRouteState) ||
					(wBelongDrId != wDrId))
				{ /*子进路状态不为初锁异常||所属动态进路不为本进路*/

					SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT);  /*设置动态进路空闲*/
				}
				else
				{
					SetRouteStateManage(pSubRouteIdBuf[ii], ROUTE_STATE_FIRST_LOCK);  /*设置进路初锁*/
				}

				chFlag = FLAG_SET;
			}
			if ((0u == ii) || (FLAG_SET == chFlag))
			{
				break;
			}
			else
			{
				; /* 继续遍历 */
			}
		}
	}
	else
	{
		SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT);  /*设置动态进路空闲*/
	}
}

/**
* @brief 锁闭动态进路条件判断
* @param const UINT16 wDrId 动态进路ID
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockDynamicRouteProc(const UINT16 wDrId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_LOCK_DYNAMIC_ROUTE_LOGIC;

	/*故障发送级别*/
	UINT8 const sendLevel = ESEND_LEVEL_ATS;    /*不发送ATS*/
	UINT8 halfRouteLgcNum = 0u;


												 /* 局部变量定义初始化 */
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 chSubRouteSum = 0u; /*子进路数目*/
	UINT16* pSubRouteIdBuf = NULL; /*子进路ID数组*/
	UINT8 ii = 0u;
	UINT8 reResult = CI_ERROR;
	UINT8 chFlag = FLAG_UNSET;

	chSubRouteSum = GetDrSubRouteSum(wDrId); /*子进路数量*/
	pSubRouteIdBuf = GetDrSubRouteIdBuf(wDrId); /*子进路号*/

	devId = wDrId;
	devState = GetDynamicRouteState(wDrId);
	if (devState != ROUTE_DYNAMIC_STATE_XUANPAI)
	{ /*动态进路不为选排*/

	  /* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_ROUTE_STATE, devState, sendLevel);
		reResult = CI_ERROR;
	}
	else
	{
		reResult = CI_SUCCESS;
	}

	if (CI_SUCCESS == reResult)
	{
		devState = SystemOverTimeCheck(GetDrLockStartCyc(wDrId), GetSystemParaZuheRXuanPaiCnt());
		if (CI_TIME_OUT == devState)
		{ /*选排超时*/

		  /* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_ROUTE_XUANPAI_OVERTIME, devState, sendLevel);

			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{

		for (ii = 0u; ii < chSubRouteSum; ii++)
		{

			halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]);
			if (0u != halfRouteLgcNum)
			{/* 此进路为部分进路，部分进路包含的逻辑区段数量，仅在是部分进路时才不为零 */
				/* 不为整条进路 */
				reResult = LockRouteHalfProc(pSubRouteIdBuf[ii]);
			}
			else
			{
				reResult = LockDrSubRouteProc(pSubRouteIdBuf[ii]);
			}

			if (RETURN_LOCK_ERR_SWITPOS == reResult)
			{
				chFlag = FLAG_SET;
			}
			else
			{
				; /* 不处理 */
			}

			if (CI_ERROR == reResult)
			{
				break;
			}
			else
			{
				; /* 继续遍历 */
			}
		}
	}

	if ((FLAG_SET == chFlag) && (CI_SUCCESS == reResult))
	{
		/* 计算成功且需要驱动道岔 */
		reResult = RETURN_LOCK_ERR_SWITPOS;
	}
	else
	{
		; /* 不处理 */
	}

	return reResult;
}

#if 1
/**
* @brief 锁闭动态进路子进路判断
* @param const UINT16 routeId 进路ID
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockDrSubRouteProc(const UINT16 wSubRouteId)
{
	UINT8 chRouteType = 0u;      /*进路类型*/
	UINT8 chRouteLevel = 0u;     /*进路监督级别*/
	UINT8 chRtn = CI_ERROR;    /*返回值定义*/
	UINT8 retval = 0u;

	chRouteType = GetRouteType(wSubRouteId);      /*获取进路类型*/
	chRouteLevel = GetRouteLevel(wSubRouteId);    /*获取进路监督级别*/

	if (ROUTE_TYPE_LIECHE == chRouteType)
	{ /*列车进路*/
		if (ROUTE_LEVEL_CBTC == chRouteLevel)
		{ /*VBTC*/
		  /*锁闭VBTC列车进路逻辑处理*/
			chRtn = LockCbtcDrSubRouteCheck(wSubRouteId);
		}
		else
		{
			/*锁闭点式列车进路逻辑处理*/
			chRtn = LockBlocDrSubRouteCheck(wSubRouteId);
		}
	}
	else if(ROUTE_TYPE_RETURN == chRouteType)
	{
		/*折返进路*/
		if (ROUTE_LEVEL_CBTC == chRouteLevel)
		{ /*CBTC*/

		  /*锁闭CBTC折返进路逻辑处理*/
			chRtn = LockCbtcDrSubReturnRouteCheck(wSubRouteId);
		}
		else
		{
			/*锁闭点式折返进路逻辑处理*/
			chRtn = LockBlocDrSubReturnRouteCkeck(wSubRouteId);
		}
	}
	else
	{
		/*非法进路类型*/
	}

	/*根据锁闭返回值处理*/
	if (CI_SUCCESS == chRtn)
	{
		/*锁闭成功*/

		retval= CI_SUCCESS;
	}
	else if (RETURN_LOCK_ERR_SWITPOS == chRtn)
	{ /*道岔位置不正确*/

		retval= RETURN_LOCK_ERR_SWITPOS;
	}
	else
	{ /*锁闭失败*/

		retval= CI_ERROR;
	}
	return retval;
}

/**
* @brief 锁闭CBTC级别动态进路子进路条件检查
* @param UINT16 wSubRouteId 子进路ID
* @param UINT8 functionId
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockCbtcDrSubRouteCheck(UINT16 const wSubRouteId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_LOCK_CBTC_T_ROUTE;

	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/
	UINT8 devState = 0u;                 /*设备状态*/										 /*故障发送级别*/
	UINT8 sendLevel = ESEND_LEVEL_ZERO;		/*不发送ATS*/
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 routeStateFlag = ROUTE_STATE_FLAG_NO;   /*进路状态转移标志*/
	UINT8 cAutoStateFlag = CI_ERROR;

	cAutoStateFlag = AutoSignalOrRouteValid(wSubRouteId);  /*获取自动属性*/
	if (cAutoStateFlag == CI_SUCCESS)
	{
		/*自动进路或自动信号不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}

	routeStateFlag = GetRouteStateFlag(wSubRouteId);			   /* 获取进路状态转移标志*/

	/* 联锁逻辑检查 */

	/* 进路监督模式为【CBTC】*/
	devState = GetRouteLevel(wSubRouteId);
	if (ROUTE_LEVEL_CBTC == devState)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_LEVEL, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;

	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路类型是【列车进路】*/
		devState = GetRouteType(wSubRouteId);
		if (ROUTE_TYPE_LIECHE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_TYPE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路状态为【空闲】/【部分锁闭解锁】 */
		devState = GetRouteState(wSubRouteId);
		if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_HALF_UNLOCK == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 信号机联锁条件检查 */
		checkResult = SetBlocRouteSignalCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*照查联锁条件正确*/

		checkResult = RouteRelayZhaoChaCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 区段联锁条件检查 */
		checkResult = SetCbtcRouteSectionCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 道岔联锁条件检查 */
		checkResult = LockBlocRouteSwitchCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = checkResult;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*侵限区段侵限条件不满足检查*/
		checkResult = RouteIntruSecVainCheck(wSubRouteId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 选排之前不再检查侵限，检查失败后直接发送给ATS*/
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, ESEND_LEVEL_ATS);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		if ((ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(wSubRouteId)) || (ROUTE_TYPE_AIRSHAFT == GetAirShaftRouteType(wSubRouteId)))
		{  /*反向进路需检查所有区段的占用状态，之前由于不检查占用状态导致信号出清进路内方第一逻辑区段，信号机重开的问题*/
		   /*风井进路不允许追踪办进路*/
			devId = 0u;
			devState = 0u;
			checkResult = RouteAllSecOccuClearCheck(wSubRouteId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel);
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		checkResult = CBTCRouteFloodGateCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*进路包含的物理区段的非进路内且非道岔关联的逻辑区段有效性检查*/
		checkResult = LockCBTCRouteSectionCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*分段进路联锁条件检查*/
		checkResult = RouteFenDuanConditionCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}
	/* 返回成功 */
	return reResult;
}

/**
* @brief 锁闭点式动态进路子进路条件检查
* @param UINT16 wSubRouteId 子进路ID
* @param UINT8 functionId
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockBlocDrSubRouteCheck(UINT16 const wSubRouteId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_LOCK_BLOC_T_ROUTE;

	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT16 devId = 0u;					 /*设备ID*/
	UINT8 sendLevel = ESEND_LEVEL_ZERO;    /*故障发送级别*/
	UINT8 cAutoStateFlag = CI_ERROR;

	cAutoStateFlag = AutoSignalOrRouteValid(wSubRouteId);  /*获取自动属性*/
	if (cAutoStateFlag == CI_SUCCESS)
	{
		/*自动进路或自动信号不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}

	/* 进路监督模式为【点式】*/
	devState = GetRouteLevel(wSubRouteId);
	if ((devState == ROUTE_LEVEL_BLOC))
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_LEVEL, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;

	}
	if (CI_SUCCESS == reResult)
	{
		/* 进路类型是【列车进路】*/
		devState = GetRouteType(wSubRouteId);
		if (devState == ROUTE_TYPE_LIECHE)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_TYPE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路状态为【空闲】*/
		devState = GetRouteState(wSubRouteId);
		if (ROUTE_STATE_IDLE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 信号机联锁条件检查 */
		checkResult = SetBlocRouteSignalCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*照查联锁条件正确*/

		checkResult = RouteRelayZhaoChaCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 区段联锁条件检查 */
		checkResult = SetBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 道岔联锁条件检查 */
		checkResult = LockBlocRouteSwitchCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = checkResult;

		}
	}
	if (CI_SUCCESS == reResult)
	{
		/*侵限区段侵限条件不满足检查*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(wSubRouteId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 选排之前不再检查侵限，检查失败后直接发送给ATS*/
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, ESEND_LEVEL_ATS);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		checkResult = BlocRouteFloodGateCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*进路包含的物理区段的非进路内且非道岔关联的逻辑区段检查*/
		checkResult = LockBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/* 返回成功 */
	return reResult;
}

/**
* @brief 锁闭VBTC级别动态进路子进路（折返）条件检查
* @param UINT16 wSubRouteId 子进路ID
* @param UINT8 functionId
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockCbtcDrSubReturnRouteCheck(UINT16 const wSubRouteId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_LOCK_CBTC_R_ROUTE;

	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT16 devId = 0u;					/*设备ID*/
	UINT8 sendLevel = ESEND_LEVEL_ZERO;	 /*故障发送级别*/
	UINT8 cAutoStateFlag = CI_ERROR;

	cAutoStateFlag = AutoSignalOrRouteValid(wSubRouteId);  /*获取自动属性*/
	if (cAutoStateFlag == CI_SUCCESS)
	{
		/*自动进路或自动信号不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}

	/* 联锁逻辑检查 */

	/* 进路监督模式为【CBTC】*/
	devState = GetRouteLevel(wSubRouteId);
	if ((devState == ROUTE_LEVEL_CBTC))
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_LEVEL, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;

	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路类型是【折返进路】*/
		devState = GetRouteType(wSubRouteId);
		if (devState == ROUTE_TYPE_RETURN)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_TYPE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路状态为【空闲】*/
		devState = GetRouteState(wSubRouteId);
		if (ROUTE_STATE_IDLE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 信号机联锁条件检查 */
		checkResult = SetBlocRouteSignalCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*照查联锁条件正确*/

		checkResult = RouteRelayZhaoChaCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 区段联锁条件检查 */
		checkResult = SetBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 道岔联锁条件检查 */
		checkResult = LockBlocRouteSwitchCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = checkResult;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*侵限区段侵限条件不满足检查*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(wSubRouteId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 选排之前不再检查侵限，检查失败后直接发送给ATS*/
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, ESEND_LEVEL_ATS);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		checkResult = CBTCRouteFloodGateCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*进路包含的物理区段的非进路内且非道岔关联的逻辑区段检查*/
		checkResult = LockBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*分段进路联锁条件检查*/
		checkResult = RouteFenDuanConditionCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/* 返回成功 */
	return reResult;
}

/**
* @brief 锁闭后备动态进路子进路（折返）条件检查
* @param UINT16 wSubRouteId 子进路ID
* @param UINT8 functionId
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockBlocDrSubReturnRouteCkeck(UINT16 const wSubRouteId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_LOCK_BLOC_R_ROUTE;

	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT16 devId = 0u;					/*设备ID*/
	UINT8 sendLevel = ESEND_LEVEL_ZERO;  /*故障发送级别*/
	UINT8 cAutoStateFlag = CI_ERROR;

	cAutoStateFlag = AutoSignalOrRouteValid(wSubRouteId);  /*获取自动属性*/
	if (cAutoStateFlag == CI_SUCCESS)
	{
		/*自动进路或自动信号不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}

	/* 联锁逻辑检查 */

	/* 进路监督模式为【点式】*/
	devState = GetRouteLevel(wSubRouteId);
	if ((devState == ROUTE_LEVEL_BLOC))
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_LEVEL, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;

	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路类型是【折返进路】*/
		devState = GetRouteType(wSubRouteId);
		if (devState == ROUTE_TYPE_RETURN)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_TYPE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路状态为【空闲】*/
		devState = GetRouteState(wSubRouteId);
		if (ROUTE_STATE_IDLE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 信号机联锁条件检查 */
		checkResult = SetBlocRouteSignalCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*照查联锁条件正确*/

		checkResult = RouteRelayZhaoChaCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 区段联锁条件检查 */
		checkResult = SetBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 道岔联锁条件检查 */
		checkResult = LockBlocRouteSwitchCheck(wSubRouteId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = checkResult;

		}
	}

	/*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(wSubRouteId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 选排之前不再检查侵限，检查失败后直接发送给ATS*/
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, ESEND_LEVEL_ATS);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		checkResult = BlocRouteFloodGateCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*进路包含的物理区段的非进路内且非道岔关联的逻辑区段检查*/
		checkResult = LockBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/* 返回成功 */
	return reResult;
}

/**
* @brief 锁闭动态进路子进路道岔状态判断
* @param UINT16 wSubRouteId 子进路ID
* @param UINT8 functionId 
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功；RETURN_LOCK_ERR_SWITPOS:道岔位置不正确
* @note：
*/
static UINT8 LockDrSubRouteSwitchCheck(UINT16 wSubRouteId, UINT8 functionId, UINT8 sendLevel)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT8 reResultP = CI_ERROR;          /*保护区段局部检查返回值*/

	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/

	UINT8 lineIdentity = CI_TRADITION_RAILWAY;

	lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*获取线路标识*/

	/*进路内所有道岔【未引导总锁】*/
	devId = 0u;
	devState = 0u;
	checkResult = RouteSwitchYLockCheck(wSubRouteId, &devId, &devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;

	}

	if (CI_SUCCESS == reResult)
	{
		/*进路内所有道岔【未封锁】*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteSwitchFLockCheck(wSubRouteId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*进路防护道岔【未封锁】*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteReltProtSwitchFLockCheck(wSubRouteId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		if (CI_TRADITION_RAILWAY == lineIdentity)
		{
			/*进路内所有道岔位置正确或位置不正确但可动作*/
			devId = 0u;
			devState = 0u;

			checkResult = DrSubRouteSwiPosAndMoveValCheck(wSubRouteId, &devId, &devState, sendLevel);

			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*进路侧防道岔条件检查*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = RouteAllLtrlDfncSwitchCheck(wSubRouteId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	if (CI_SUCCESS == reResult)
	{
		if (CI_TRADITION_RAILWAY == lineIdentity)
		{
			/*
			进路内所有道岔位置正确
			不正确：RETURN_LOCK_ERR_SWITPOS
			正确：CI_SUCCESS
			*/
			devId = 0u;
			devState = 0u;
			checkResult = RouteAllSwitchPosCheck(wSubRouteId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = RETURN_LOCK_ERR_SWITPOS;

			}
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	if ((CI_SUCCESS == reResult) || (RETURN_LOCK_ERR_SWITPOS == reResult))
	{/*进路锁闭防护道岔检查*/
	 /*进路关联防护道岔【未引导总锁】*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteRelatedProSwitchYLockCheck(wSubRouteId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResultP = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel);
			/* 失败返回 */
			reResultP = CI_ERROR;
		}

		if (CI_SUCCESS == reResultP)
		{
			/*进路关联防护道岔位置正确或位置不正确但可动作*/
			devId = 0u;
			devState = 0u;
			checkResult = DrSubRouteProtSwiPosMovValCheck(wSubRouteId, &devId, &devState, sendLevel);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResultP = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResultP = CI_ERROR;
			}
		}
		else
		{
			reResultP = CI_ERROR;
		}

		if (CI_SUCCESS == reResultP)
		{
			/*进路关联防护道岔位置正确*/
			devId = 0u;
			devState = 0u;
			checkResult = RouteRelatedProSwitchPosCheck(wSubRouteId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResultP = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResultP = RETURN_LOCK_ERR_SWITPOS;
			}
		}
		else
		{
			reResultP = CI_ERROR;
		}

		if (CI_ERROR == reResultP)
		{/*如果防护道岔的检查结果为错误，则总的检查结果为错误*/
			reResult = CI_ERROR;
		}
		else if (CI_SUCCESS == reResultP)
		{
			/*如果防护道岔的检查结果为成功，则总的检查结果保持不变*/
		}
		else if (RETURN_LOCK_ERR_SWITPOS == reResultP)
		{/*如果防护道岔的检查结果为锁闭位置错误，则总的检查结果为锁闭位置错误*/
			reResult = RETURN_LOCK_ERR_SWITPOS;
		}
		else
		{/*其它不存在的情况，置总的结果为错误*/
			reResult = CI_ERROR;
		}

	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}



	/* 返回结果 */
	return reResult;
}

/**
* @brief 锁闭动态进路子进路道岔位置及可动性检查
* @param UINT16 const routeId
* @param UINT16 *pDevId
* @param UINT8 *pDevState
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 DrSubRouteSwiPosAndMoveValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState, UINT8 sendLevel)
{
	/* 进路道岔 */
	UINT8 const checkSum = GetRouteSwitchSum(routeId);
	RouteSwitchStruct* const dataIdBuf = GetRouteSwitchData(routeId);

	/* 局部变量定义初始化 */
	UINT16 i = 0u;           /* 循环变量 */
	UINT16 devId = 0u;
	UINT8 devState = 0u;
	UINT8 switchPos = 0u;

	UINT8 switchMoveState = 0u;
	UINT8 reVal = CI_ERROR;
	UINT8 checkResult = 0u;
	UINT8 routeType = 0u;
	UINT8 funcSwitch = 0u;               /*功能开关*/
	UINT8 cLocalCiId = 0u;
	UINT8 chDrMoveValid = 0u;

	funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY);
	cLocalCiId = GetSystemParaLocalCiId();
	chDrMoveValid = GetHalfRouteSwitchMoveValid(routeId);

	routeType = GetRouteType(routeId);

	/*联锁检查*/
	if (checkSum == 0u)
	{
		/*无检查项*/
		reVal = CI_SUCCESS;
	}
	else if (NULL == dataIdBuf)
	{
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
		/*开始检查*/
		/* 进路内所有道岔位置正确 且不为【挤岔】 或位置不正确道岔可动作*/
		for (i = 0u; i<checkSum; i++)
		{
			devId = dataIdBuf[i].SwitchId;
			devState = GetSwitchCurPosition(devId);
			switchPos = dataIdBuf[i].SwitchPosition;
			if (devState == switchPos)
			{
				/* 道岔位置正确 */
				/*如果最近一次产生的有效驱动仍在延续，则返回失败*/
				checkResult = checkSwtLastValDrvPosStayorNot(devId, switchPos);
				if (CI_SUCCESS == checkResult)
				{
				}
				else
				{
					reVal = CI_ERROR;
				}
			}
			else if (SWITCH_POSITION_SIKAI == devState)
			{
				/*四开*/
				*pDevId = devId;
				*pDevState = devState;
				/* 记录故障码 */
				SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel);
				reVal = CI_ERROR;
			}
			else if (SWITCH_POSITION_JICHA == devState)
			{
				/*挤岔*/
				*pDevId = devId;
				*pDevState = devState;
				/* 记录故障码 */
				SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel);
				reVal = CI_ERROR;
			}
			else
			{
				/* 道岔位置不正确 */
				if (ROUTE_HALF_SWITCH_MOVE_VALID == chDrMoveValid)
				{
					if (FUNC_SWITCH_ON == funcSwitch)
					{
						/*适配进路提前驱动道岔功能*/
						switchMoveState = GetSwitchMoveEarlyValidState(devId, SWITCH_OPER_NO_DANCAO, sendLevel);
					}
					else
					{
						switchMoveState = GetSwitchMoveValidState(devId, SWITCH_OPER_NO_DANCAO, sendLevel);
					}
				}
				else
				{/* 动态进路不可驱动道岔 */
					switchMoveState = CI_ERROR;
				}

				if (switchMoveState == CI_SUCCESS)
				{
					/*道岔可动*/
				}
				else
				{
					/*道岔位置不正确 且 道岔不可动作*/
					*pDevId = devId;
					*pDevState = devState;
					reVal = CI_ERROR;
				}
			}
			if (CI_ERROR == reVal)
			{/* 失败，跳出 */
				break;
			}
			else
			{
				; /* 不处理 */
			}
		}
	}

	/*全部通过检查*/
	return reVal;
}

/**
* @brief 锁闭动态进路子进路防护道岔位置及可动性检查
* @param UINT16 const routeId
* @param UINT16 *pDevId
* @param UINT8 *pDevState
* @param UINT8 sendLevel
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 DrSubRouteProtSwiPosMovValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState, UINT8 sendLevel)
{
	/* 进路关联防护道岔 */
	UINT8 const checkSum = GetRouteRelatedProtectSwitchSum(routeId);
	RouteProtectSwitchStruct* const dataIdBuf = GetRouteRelatedProtSwitchData(routeId);

	/* 局部变量定义初始化 */
	UINT16 i = 0u;           /* 循环变量 */
	UINT16 devId = 0u;
	UINT8 devState = 0u;
	UINT8 switchPos = 0u;

	UINT8 switchMoveState = 0u;
	UINT8 reVal = CI_ERROR;
	UINT8 checkResult = 0u;
	UINT8 routeType = 0u;
	UINT8 funcSwitch = 0u;               /*功能开关*/
	UINT8 cLocalCiId = 0u;
	UINT8 chDrMoveValid = 0u;

	funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY);
	cLocalCiId = GetSystemParaLocalCiId();

	routeType = GetRouteType(routeId);
	chDrMoveValid = GetHalfRouteSwitchMoveValid(routeId);

	if ((NULL == dataIdBuf) || (NULL == pDevId) || (NULL == pDevState))
	{
		/*指针为空*/
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
	}

	if (CI_SUCCESS == reVal)
	{
		/*开始检查*/
		/* 进路关联防护道岔位置正确且不为【挤岔】或位置不正确但道岔可动作*/
		for (i = 0u; i<checkSum; i++)
		{
			devId = dataIdBuf[i].ProtectSwitchId;
			devState = GetSwitchCurPosition(devId);
			switchPos = dataIdBuf[i].ProtectPosition;
			if (devState == switchPos)
			{
				/* 道岔位置正确 */
				/*如果最近一次产生的有效驱动仍在延续，则返回失败*/
				checkResult = checkSwtLastValDrvPosStayorNot(devId, switchPos);
				if (CI_SUCCESS == checkResult)
				{
				}
				else
				{
					reVal = CI_ERROR;
				}
			}
			else if (SWITCH_POSITION_SIKAI == devState)
			{
				/*四开*/
				*pDevId = devId;
				*pDevState = devState;
				/* 记录故障码 */
				SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel);
				reVal = CI_ERROR;
			}
			else if (SWITCH_POSITION_JICHA == devState)
			{
				/*挤岔*/
				*pDevId = devId;
				*pDevState = devState;
				/* 记录故障码 */
				SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel);
				reVal = CI_ERROR;
			}
			else
			{
				/* 道岔位置不正确 */
				if (ROUTE_HALF_SWITCH_MOVE_VALID == chDrMoveValid)
				{
					if (FUNC_SWITCH_ON == funcSwitch)
					{
						/*适配进路提前驱动道岔功能*/
						switchMoveState = GetSwitchMoveEarlyValidState(devId, SWITCH_OPER_NO_DANCAO, sendLevel);
					}
					else
					{
						switchMoveState = GetSwitchMoveValidState(devId, SWITCH_OPER_NO_DANCAO, sendLevel);
					}
				}
				else
				{/* 动态进路不可驱动道岔 */
					switchMoveState = CI_ERROR;
				}

				if (CI_SUCCESS == switchMoveState)
				{
					/*道岔可动*/
				}
				else
				{
					/*道岔位置不正确 且 道岔不可动作*/
					*pDevId = devId;
					*pDevState = devState;
					reVal = CI_ERROR;
				}
			}
			if (CI_ERROR == reVal)
			{/* 失败，跳出 */
				break;
			}
			else
			{
				; /* 不处理 */
			}
		}
	}

	/*全部通过检查*/
	return reVal;
}
#endif

/**
* @brief 办理动态进路条件检查
* @param const UINT16 wDrId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetDynamicRouteProc(const UINT16 wDrId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_DynamicRouteProc;

	/*故障发送级别*/
	UINT8 const sendLevel = ESEND_LEVEL_ZERO;    /*不发送ATS*/


												 /* 局部变量定义初始化 */
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 chSubRouteSum = 0u; /*子进路数目*/
	UINT16* pSubRouteIdBuf = NULL; /*子进路ID数组*/
	UINT8 ii = 0u;
	UINT8 reResult = CI_ERROR;
	UINT8 halfRouteLgcNum = 0u;

	chSubRouteSum = GetDrSubRouteSum(wDrId); /*子进路数量*/
	pSubRouteIdBuf = GetDrSubRouteIdBuf(wDrId); /*子进路号*/

	devId = wDrId;
	devState = GetDynamicRouteState(wDrId);
	if (devState != ROUTE_DYNAMIC_STATE_FIRST_XUANPAI)
	{ /*动态进路不为选排*/

	  /* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_ROUTE_STATE, devState, sendLevel);
		reResult = CI_ERROR;
	}
	else
	{
		reResult = CI_SUCCESS;
	}

	if (CI_SUCCESS == reResult)
	{
		devState = SystemOverTimeCheck(GetDrXuanPaiStartCyc(wDrId), ROUTE_CHUXUAN_OVERTIME_CYCLE_NUM);
		if (CI_TIME_OUT == devState)
		{ /*选排超时*/

		  /* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_ROUTE_XUANPAI_OVERTIME, devState, sendLevel);

			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{

		for (ii = 0u; ii < chSubRouteSum; ii++)
		{

			halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]);
			if (0u != halfRouteLgcNum)
			{/* 此进路为部分进路，部分进路包含的逻辑区段数量，仅在是部分进路时才不为零 */
				/* 第一条，不为整条进路 */
				reResult = SetRouteHalfProc(pSubRouteIdBuf[ii]);
			}
			else
			{
				reResult = SetDrSubRouteProc(pSubRouteIdBuf[ii]);
			}
			if (CI_ERROR == reResult)
			{
				break;
			}
			else
			{
				; /* 继续遍历 */
			}
		}
	}

	return reResult;
}

/**
* @brief 办理动态进路子进路条件检查
* @param const UINT16 wDrId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetDrSubRouteProc(const UINT16 routeId)
{
	UINT8 routeType = 0u;      /*进路类型*/
	UINT8 routeLevel = 0u;     /*进路监督级别*/
	UINT8 returnValue = CI_ERROR;    /*返回值定义*/
	UINT8 reverseProperty = 0u; /*反向属性*/


	routeType = GetRouteType(routeId);      /*获取进路类型*/
	routeLevel = GetRouteLevel(routeId);    /*获取进路监督级别*/
	reverseProperty = GetRouteReverseProperty(routeId);

	if (ROUTE_TYPE_LIECHE == routeType)
	{ /*列车进路*/
		if (ROUTE_REVERSE_PROPERTY_YES == reverseProperty)
		{
			/*办理反向列车进路逻辑处理*/
			returnValue = SetDrSubRlTrainRouteCheck(routeId);
		}
		else
		{
			if (ROUTE_LEVEL_CBTC == routeLevel)
			{ /*CBTC*/

			  /*办理CBTC列车进路逻辑处理*/
				returnValue = SetCbtcDrSubRouteCheck(routeId);
			}
			else
			{
				/*办理点式列车进路逻辑处理*/
				returnValue = SetBlocDrSubRouteCheck(routeId);
			}
		}


	}
	else if (ROUTE_TYPE_RETURN == routeType)
	{ /*折返进路*/

		if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId))
		{
			/*办理反向折返进路逻辑处理*/
			returnValue = SetDrSubRrRouteCheck(routeId);
		}
		else
		{
			if (ROUTE_LEVEL_CBTC == routeLevel)
			{ /*CBTC*/

			  /*办理CBTC折返进路逻辑处理*/
				returnValue = SetCbtcDrSubReturnRouteCheck(routeId);
			}
			else
			{
				/*办理点式折返进路逻辑处理*/
				returnValue = SetBlocDrSubReturnRouteCheck(routeId);
			}
		}

	}
	else
	{/*不处理*/
	}


	/*根据办理返回值处理*/
	if (CI_SUCCESS == returnValue)
	{ /*办理成功*/
		;
	}
	else
	{ /*办理失败*/
		returnValue = CI_ERROR;
	}

	return returnValue;
}

/**
* @brief 办理动态进路子进路(反向列车进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetDrSubRlTrainRouteCheck(UINT16 const routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_SET_REVERSE_T_ROUTE;

	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT8 devState = 0u;                 /*设备状态*/

										 /*故障发送级别*/
	UINT8 sendLevel = 0u;
	UINT8 isAutoSigRoute = CI_ERROR;

	isAutoSigRoute = AutoSignalOrRouteValid(routeId);
	if (CI_SUCCESS == isAutoSigRoute)
	{
		/*自动进路不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}


	/* 联锁逻辑检查 */

	/* 进路类型是【列车进路】*/

	devState = GetRouteType(routeId);
	if (devState == ROUTE_TYPE_LIECHE)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;

	}


	/* 进路状态为【进路空闲】 */
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteState(routeId);
		if (ROUTE_STATE_IDLE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}
	/* 信号机联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = SetReverseRouteSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*照查联锁条件正确*/
	if (CI_SUCCESS == reResult)
	{

		checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}
#if 0
	/*反向进路包含的自动信号进路状态检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = SetRevrRouteAutoSigStaCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#endif	

	/* 区段联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = SetReverseRouteSectionCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 道岔联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		checkResult = BlocRouteFloodGateCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/* 返回成功 */
	return reResult;
}

/**
* @brief 办理动态进路CBTC子进路(CBTC列车进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetCbtcDrSubRouteCheck(UINT16 const routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_SET_CBTC_T_ROUTE;

	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT8 devState = 0u;                 /*设备状态*/

										 /*虚拟联锁兼容*/
	UINT8 triggerFlag = 0u;
	/*故障发送级别*/
	UINT8 sendLevel = 0u;
	UINT8 chAutoValid = CI_ERROR;

	chAutoValid = AutoSignalOrRouteValid(routeId);
	triggerFlag = GetRouteAutoTriggerFlag(routeId); /*获取进路的自动触发标志*/
	if ((CI_SUCCESS == chAutoValid) ||
		(AUTO_TRIGGER_SET_YES == triggerFlag))
	{
		/*自动进路不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}

	/* 联锁逻辑检查 */

	/* 进路监督模式为【CBTC】*/
	devState = GetRouteLevel(routeId);
	if ((devState == ROUTE_LEVEL_CBTC))
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_LEVEL, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;

	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路类型是【列车进路】*/
		devState = GetRouteType(routeId);
		if (devState == ROUTE_TYPE_LIECHE)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路状态为【进路空闲】或【部分锁闭解锁】*/
		devState = GetRouteState(routeId);
		if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_HALF_UNLOCK == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 信号机联锁条件检查 */
		checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*照查联锁条件正确*/

		checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 区段联锁条件检查 */
		checkResult = SetCbtcRouteSectionCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 道岔联锁条件检查 */
		checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		checkResult = CBTCRouteFloodGateCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}


	if (CI_SUCCESS == reResult)
	{
		/*分段进路联锁条件检查*/
		checkResult = RouteFenDuanConditionCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/* 返回成功 */
	return reResult;
}

/**
* @brief 办理动态进路后备子进路(后备列车进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetBlocDrSubRouteCheck(UINT16 const routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_SET_BLOC_T_ROUTE;

	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT8 devState = 0u;                 /*设备状态*/

										 /*故障发送级别*/
	UINT8 sendLevel = 0u;
	UINT8 triggerFlag = 0u;
	UINT8 chAutoValid = CI_ERROR;

	chAutoValid = AutoSignalOrRouteValid(routeId);
	triggerFlag = GetRouteAutoTriggerFlag(routeId); /*获取进路的自动触发标志*/
	if ((CI_SUCCESS == chAutoValid) ||
		(AUTO_TRIGGER_SET_YES == triggerFlag))
	{
		/*自动进路或自动触发进路不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}


	/* 联锁逻辑检查 */

	/* 进路监督模式为【点式】*/
	devState = GetRouteLevel(routeId);
	if ((devState == ROUTE_LEVEL_BLOC))
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_LEVEL, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路类型是【列车进路】*/
		devState = GetRouteType(routeId);
		if (devState == ROUTE_TYPE_LIECHE)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路状态为【进路空闲】 */
		devState = GetRouteState(routeId);
		if (ROUTE_STATE_IDLE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 信号机联锁条件检查 */
		checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}


	if (CI_SUCCESS == reResult)
	{
		/*照查联锁条件正确*/

		checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 区段联锁条件检查 */
		checkResult = SetBlocRouteSectionCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 道岔联锁条件检查 */
		checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		checkResult = BlocRouteFloodGateCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/* 返回成功 */
	return reResult;
}

/**
* @brief 办理动态进路子进路(反向折返进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetDrSubRrRouteCheck(UINT16 const routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_SET_REVERSE_R_ROUTE;

	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT8 devState = 0u;                 /*设备状态*/

	/*故障发送级别*/
	UINT8 sendLevel = 0u;
	UINT8 chAutoValid = CI_ERROR;
	
	chAutoValid = AutoSignalOrRouteValid(routeId);
	if (CI_SUCCESS == chAutoValid)
	{
		/*自动进路不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}

	/* 联锁逻辑检查 */

	/* 进路类型是【折返进路】*/
	devState = GetRouteType(routeId);
	if (devState == ROUTE_TYPE_RETURN)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	/* 进路状态为【进路空闲】 */
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteState(routeId);
		if (ROUTE_STATE_IDLE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 信号机联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = SetReverseRouteSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/*照查联锁条件正确*/
	if (CI_SUCCESS == reResult)
	{

		checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#if 0
	/*反向进路包含的自动信号进路状态检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = SetRevrRouteAutoSigStaCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#endif

	/* 区段联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = SetReverseRouteSectionCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 道岔联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		checkResult = BlocRouteFloodGateCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}
	/* 返回成功 */
	return reResult;
}

/**
* @brief 办理动态进路CBTC折返子进路(CBTC折返进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetCbtcDrSubReturnRouteCheck(UINT16 const routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_SET_CBTC_R_ROUTE;

	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT8 devState = 0u;                 /*设备状态*/

	/*故障发送级别*/
	UINT8 sendLevel = 0u;
	UINT8 chAutoValid = CI_ERROR;

	chAutoValid = AutoSignalOrRouteValid(routeId);
	if (CI_SUCCESS == chAutoValid)
	{
		/*自动进路不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}

	/* 联锁逻辑检查 */

	/* 进路监督模式为【CBTC】*/
	devState = GetRouteLevel(routeId);
	if ((devState == ROUTE_LEVEL_CBTC))
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_LEVEL, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;

	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路类型是【折返进路】*/
		devState = GetRouteType(routeId);
		if (devState == ROUTE_TYPE_RETURN)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路状态为【进路空闲】 */
		devState = GetRouteState(routeId);
		if (ROUTE_STATE_IDLE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_RETURN_ROUTE_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 信号机联锁条件检查 */
		checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*照查联锁条件正确*/

		checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 区段联锁条件检查 */
		checkResult = SetBlocRouteSectionCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 道岔联锁条件检查 */
		checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		checkResult = CBTCRouteFloodGateCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*分段进路联锁条件检查*/
		checkResult = RouteFenDuanConditionCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/* 返回成功 */
	return reResult;
}

/**
* @brief 办理动态进路后备折返子进路(后备折返进路)条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetBlocDrSubReturnRouteCheck(UINT16 const routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_SET_BLOC_R_ROUTE;

	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT8 devState = 0u;                 /*设备状态*/

	UINT8 autoSignalOrRouteValid = 0u;

	/*故障发送级别*/
	UINT8 sendLevel = 0u;
	autoSignalOrRouteValid = AutoSignalOrRouteValid(routeId);
	if (CI_SUCCESS == autoSignalOrRouteValid)
	{
		/*自动进路不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}

	/* 联锁逻辑检查 */

	/* 进路监督模式为【点式】*/
	devState = GetRouteLevel(routeId);
	if ((ROUTE_LEVEL_BLOC == devState))
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_LEVEL, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;

	}

	if (CI_SUCCESS == reResult)
	{
		/* 进路类型是【折返进路】*/
		devState = GetRouteType(routeId);
		if (ROUTE_TYPE_RETURN == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}
	if (CI_SUCCESS == reResult)
	{
		/* 进路状态为【进路空闲】 */
		devState = GetRouteState(routeId);
		if (ROUTE_STATE_IDLE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_RETURN_ROUTE_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 信号机联锁条件检查 */
		checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*照查联锁条件正确*/

		checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 区段联锁条件检查 */
		checkResult = SetBlocRouteSectionCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/* 道岔联锁条件检查 */
		checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		checkResult = BlocRouteFloodGateCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/* 返回成功 */
	return reResult;
}

/**
* @brief 办理动态进路子进路道岔条件检查
* @param const UINT16 routeId
* @return CI_ERROR:失败；CI_SUCCESS:成功
* @note：
*/
static UINT8 SetDrSubRouteSwitchCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/

	UINT8 lineIdentity = CI_TRADITION_RAILWAY;

	lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*获取线路标识*/

	/* 联锁逻辑检查 */
	/*进路内所有道岔【未引导总锁】*/
	devId = 0u;
	devState = 0u;
	checkResult = RouteSwitchYLockCheck(routeId, &devId, &devState);
	if (CI_SUCCESS == checkResult)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	if (CI_SUCCESS == reResult)
	{
		/*进路内所有道岔【未封锁】*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteSwitchFLockCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*进路防护道岔【未封锁】*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteReltProtSwitchFLockCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*进路侧防道岔条件检查*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = RouteAllLtrlDfncSwitchCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	if (CI_SUCCESS == reResult)
	{
		if (CI_TRADITION_RAILWAY == lineIdentity)
		{
			/*进路内所有道岔位置正确或位置不正确但可动作*/
			devId = 0u;
			devState = 0u;

			checkResult = DrSubRouteSwiPosAndMoveValCheck(routeId, &devId, &devState, sendLevel);

			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
		else
		{
			/* 失败返回 *//* zt 删除单轨相关代码 2022-02-15 */
			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{
		if (CI_TRADITION_RAILWAY == lineIdentity)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 *//* zt 删除单轨相关代码 2022-02-15 */
			reResult = CI_ERROR;
		}
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	if (CI_SUCCESS == reResult)
	{/*进路办理防护道岔检查*/
		if (CI_TRADITION_RAILWAY == lineIdentity)
		{
			/*进路关联防护道岔【未引导总锁】*/
			devId = 0u;
			devState = 0u;
			checkResult = RouteRelatedProSwitchYLockCheck(routeId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel);
				/* 失败返回 */
				reResult = CI_ERROR;
			}

			if (CI_SUCCESS == reResult)
			{
				/*进路关联防护道岔位置正确或位置不正确但可动作*/
				devId = 0u;
				devState = 0u;
				checkResult = DrSubRouteProtSwiPosMovValCheck(routeId, &devId, &devState, sendLevel);
				if (checkResult == CI_SUCCESS)
				{
					/* 通过检查 */
					reResult = CI_SUCCESS;
				}
				else
				{
					/* 失败返回 */
					reResult = CI_ERROR;
				}
			}
			else
			{
				reResult = CI_ERROR;
			}
		}
		else
		{
			/* 失败返回 *//* zt 删除单轨相关代码 2022-02-15 */
			reResult = CI_ERROR;
		}
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}


	/* 返回结果 */
	return reResult;
}

/**
* @brief 获取组合动态进路跟随数据
* @param UINT8 *pDataBuff 跟随数据存储缓冲区
* @param UINT32 curIndex 当前索引
* @return 计算后的索引
*/
UINT32 GetDrTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex)
{
	UINT32 ret = curIndex;
	UINT32 copyIndex = curIndex + 1u;
	UINT16 chIndex = 0u;
	UINT16 wDrId = 0u;
	UINT8 chDrState = 0u;
	UINT16 wDrIndex = 0u;
	UINT8 chDrTransNum = 0u;
	UINT16 chDrSum = GetDynamicRouteSum();
	if (NULL != pDataBuff)
	{
		for (chIndex = 0u; chIndex < chDrSum; chIndex++)
		{
			wDrId = GetDynamicRouteId(chIndex);
			chDrState = GetDynamicRouteState(wDrId);
			if (ROUTE_DYNAMIC_STATE_IDLE != chDrState)
			{
				wDrIndex = GetDrBufIndex(wDrId);
				(void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(DynamicRouteDataStruct), &gDynamicRouteDataSt[wDrIndex], (UINT32)sizeof(DynamicRouteDataStruct));
				copyIndex += (UINT32)sizeof(DynamicRouteDataStruct);
				chDrTransNum++;
			}
		}
		pDataBuff[curIndex] = chDrTransNum;
		ret = copyIndex;
	}
	return ret;
}

/**
* @brief 设置组合动态进路跟随数据
* @param UINT8 *pDataBuff 跟随数据存储缓冲区
* @param UINT32 curIndex 当前索引
* @return 计算后的索引
*/
UINT32 SetDrTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex)
{
	UINT32 ret = curIndex;
	UINT32 copyIndex = curIndex;
	UINT8 chIndex = 0u;
	UINT16 wDrId = 0u;
	UINT16 wDrIndex = 0u;
	UINT8 chDrNum = 0u;
	if (NULL != pDataBuff)
	{
		chDrNum = pDataBuff[copyIndex++];
		for (chIndex = 0u; chIndex < chDrNum; chIndex++)
		{
			wDrId = ShortFromCharLE(&pDataBuff[copyIndex]);
			wDrIndex = GetDrBufIndex(wDrId);

			if (ROUTE_DYNAMIC_SUM_MAX > wDrIndex)
			{
				(void)CommonMemCpy(&gDynamicRouteDataSt[wDrIndex], (UINT32)sizeof(DynamicRouteDataStruct), &pDataBuff[copyIndex], (UINT32)sizeof(DynamicRouteDataStruct));
				copyIndex += (UINT32)sizeof(DynamicRouteDataStruct);
			}
		}
		ret = copyIndex;
	}
	return ret;
}