/********************************************************
*
* 文 件 名： RouteRecoverManage.c
* 版权说明： 北京交控科技有限公司
* 创建时间： 2017-01-04
* 作    者： 联锁组
* 功能描述： 实现PSD、SPKS、扣车恢复重开信号的功能。该模块主要完成开信号以及信号保持阶段的相关联锁条件检查，与已有的联锁逻辑检查非常相似。
* 函数包括：
* 使用注意：
* 修改记录：
*		2017-01-04 新建
*
********************************************************/
#include "RouteRecoverManage.h"
#include "../LogicProcess/InterlockLogicCheck.h"
#include "../System/SystemConfigDefine.h"
#include "../LogicProcess/InterlockLogicProcess.h"
#include "../LogicProcess/TradInterlockLogicProcess.h"
#include "../LogicProcess/LogicalRouteLogicCheck.h"

/*
* 功能描述： 进路区段封锁检查
* 参数说明： UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 RouteSecFLockErrCheck(UINT16 const routeId);

/*
* 功能描述： 保护区段封锁状态有效性检查
* 参数说明： UINT16 const overlapId,  OverlapID
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OverlapAllSecFLockValidErrCheck(UINT16 const overlapId);

/*
* 功能描述： Cbtc进路信号保持区段联锁条件检查
* 参数说明：
*           const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 KeepCbtcRouteSectionErrCheck(const UINT16 routeId);

/*
* 功能描述： 开放调车进路区段联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 KeepDTrainRouteSectionErrCheck(const UINT16 routeId);

/*
* 功能描述： 点式进路开放信号保护区段联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OpenBlocRouteOverlapErrCheck(const UINT16 routeId);

/*
* 功能描述： 点式进路开放信号区段联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OpenBlocRouteSectionErrCheck(const UINT16 routeId);

/*
* 功能描述： Cbtc进路信号开放区段联锁条件检查
* 参数说明：
*           const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OpenCbtcRouteSectionErrCheck(const UINT16 routeId);

/*
* 功能描述： 开放调车进路区段联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OpenDTrainRouteSectionErrCheck(const UINT16 routeId);

/*
* 功能描述： 开放列车进路区段联锁条件检查，车辆段
* 参数说明：
*            const UINT16 routeId,    进路ID
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OpenLTrainRouteSectionErrCheck(const UINT16 routeId);

/*
* 功能描述： 其他联锁条件检查
* 参数说明： UINT16 routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OtherCiValidErrCheck(UINT16 const routeId);

/*
* 功能描述： 恢复列车进路，信号机联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*/
static UINT8 RecoverLTrainRouteSignalCheck(const UINT16 routeId);

/* 恢复点式办理进路信号机联锁条件检查 */
/*
* 功能描述： 点式进路信号机联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*/
static UINT8 RecoverBlocRouteSignalCheck(const UINT16 routeId);

/* 恢复办理进路侵限区段SPKS条件检查 */
/*
* 功能描述： 进路侵限无效检查
* 参数说明： 
*            UINT16 const routeId,    进路号
*            UINT16 *pDevId,    设备Id（返回）
*            UINT8 *pDevState,  设备状态（返回）
* 返回值  ： CI_ERROR   侵限
*            CI_SUCCESS 侵限不满足
			 CI_ROUTE_RECOVER_ERR:SPKS按下导致侵限，但是当SPKS恢复后可以重开信号
*/
static UINT8 RouteIntruSecVainSPKSErrCheck(const UINT16 routeId);

/*
* 功能描述： 恢复办理进路照查条件满足检查
* 参数说明： UINT16 const routeId,  进路号
*            UINT8 functionId,      调用函数编号
*            UINT8 sendLevel,       故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*			 RELAY_STATE_WAITE
*/
static UINT8 RouteRelayZhaoChaErrCheck(UINT16 const routeId);

/*
* 功能描述： 开放CBTC进路逻辑检查
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 OpenCbtcLTrainRouteErrProcess(const UINT16 routeId, const UINT8 checkStep)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CHECK_OPEN_CT_ROUTE_ERR_ZX;

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

	UINT8 devState = 0u;                 /*设备状态*/
	UINT16 devId = 0u;                    /*设备ID*/
	/* 进路内设备数据 */
	/* 取消标志 */
	UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId);
	UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId);

	/*故障发送级别*/
	UINT8 sendLevel = ESEND_LEVEL_ZERO;
	UINT8 routeReverseProperty = 0u;
	UINT8 airShaftRouteType = 0u;

	/* 联锁逻辑检查 */
	/* 进路监督模式为【CBTC】*/
	
	devState = GetRouteLevel(routeId);
	if (ROUTE_LEVEL_CBTC == devState)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}
	

	/* 进路类型是列车进路*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteType(routeId);
		if (ROUTE_TYPE_LIECHE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

	/* 进路状态为
	【进路初锁】
	【进路初锁异常】
	【预先锁闭】
	【接近锁闭异常】
	【接近锁闭正常】
	*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteState(routeId);
		if ((ROUTE_STATE_FIRST_LOCK == devState) ||
			(ROUTE_STATE_FIRST_LOCKERR == devState) ||
			(ROUTE_STATE_YUXIAN_LOCK == devState) ||
			(ROUTE_STATE_NEAR_LOCKERR == devState) ||
			(ROUTE_STATE_NEAR_LOCK == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

	/*进路未设置【总取消】且未设置【总人解】*/
	if (CI_SUCCESS == reResult)
	{
		if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) &&
			(ROUTE_ZONGRENJIE_SET_NO == zrjFlag))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

	/* 信号机联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		if (OPEN_CHECK_STEP_OPEN == checkStep)
		{
			checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel);
		}
		else if (OPEN_CHECK_STEP_RECOVER == checkStep)
		{
			checkResult = RecoverBlocRouteSignalCheck(routeId);
		}
		else
		{
			checkResult = CI_ERROR;
		}

		if (CI_ERROR == checkResult)
		{
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

	/* 道岔联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}
	if (CI_SUCCESS == reResult)
	{
		routeReverseProperty = GetRouteReverseProperty(routeId);
		airShaftRouteType =  GetAirShaftRouteType(routeId);
		if ((ROUTE_REVERSE_PROPERTY_YES == routeReverseProperty) || (ROUTE_TYPE_AIRSHAFT == airShaftRouteType))
		{  /*反向进路需检查所有区段的占用状态，之前由于不检查占用状态导致信号出清进路内方第一区段，信号机重开的问题*/
			/*风井进路不允许追踪办理，故开放条件需增加对进路内方所有区段的占用状态检查*/
			devId = 0u;
			devState = 0u;
			checkResult = RouteAllSecOccuClearCheck(routeId,&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 = OpenBlocRouteOverlapErrCheck(routeId);
				if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
				{
					reResult = checkResult;
				}
				else
				{
				    ;
				}
			}
			else
			{
		 	   ;
			}
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}
	
	/* 其他信号联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenCbtcRouteOtherSignalCheck(routeId, functionId, sendLevel);
		/*失败 或 进路需开放未开放,返回失败;否则reResult值保留不更新*/
		if ((CI_ERROR == checkResult) || (RETURN_OPEN_ERR_NEEDOPEN == checkResult))
		{
			reResult = CI_ERROR;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

	/* 接发车联锁条件检查(检查扣车)*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel);
		if (CI_ERROR == checkResult)
		{
			/*失败返回可重开*/
			reResult = CI_ROUTE_RECOVER_ERR;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

	/* 区段联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenCbtcRouteSectionErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}
	/*风井占用检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAirShaftSecOccuCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
		/*不处理*/
	}
	
	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

	/*照查联锁条件正确*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

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

/*
* 功能描述： 开放点式进路逻辑检查
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 OpenBlocLTrainRouteErrProcess(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CHECK_OPEN_UT_ROUTE_ERR_ZX;

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

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


										/* 进路内设备数据 */
										/* 取消标志 */
	UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId);
	UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId);

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

	/* 联锁逻辑检查 */
	/* 进路监督模式为【点式】*/
	devState = GetRouteLevel(routeId);
	if (ROUTE_LEVEL_BLOC == devState)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	/* 进路类型是列车进路*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteType(routeId);
		if (ROUTE_TYPE_LIECHE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 进路状态为
	【进路初锁】
	【进路初锁异常】
	【预先锁闭】
	【接近锁闭异常】
	【接近锁闭正常】
	*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteState(routeId);
		if ((ROUTE_STATE_FIRST_LOCK == devState) ||
			(ROUTE_STATE_FIRST_LOCKERR == devState) ||
			(ROUTE_STATE_YUXIAN_LOCK == devState) ||
			(ROUTE_STATE_NEAR_LOCKERR == devState) ||
			(ROUTE_STATE_NEAR_LOCK == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*进路未设置【总取消】且未设置【总人解】*/
	if (CI_SUCCESS == reResult)
	{
		if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) &&
			(ROUTE_ZONGRENJIE_SET_NO == zrjFlag))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 信号机联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenBlocRouteSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

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

	/* 其他信号联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else if (RETURN_OPEN_ERR_SIGOPEN == checkResult)
		{/*开放需关闭也认为合法*/
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/* 接发车联锁条件检查(检查扣车)*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ROUTE_RECOVER_ERR;
		}
	}

	/* 区段联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenBlocRouteSectionErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/* 防护进路联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenBlocRouteOverlapErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*照查联锁条件正确*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		/*防淹门联锁条件检查*/
		checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel);
		if (CI_ERROR == checkResult)
		{
			reResult = checkResult;
		}
	}
	/* 返回 */
	return reResult;
}

/*
* 功能描述： 开放CBTC折返进路逻辑检查
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 OpenCbtcReturnRouteErrProcess(const UINT16 routeId, const UINT8 checkStep)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CHECK_OPEN_CT_RETURN_ERR_ZX;

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

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

										/* 进路内设备数据 */
										/* 取消标志 */
	UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId);
	UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId);

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

	/* 联锁逻辑检查 */
	/* 进路监督模式为【CBTC】*/
		devState = GetRouteLevel(routeId);
		if ((ROUTE_LEVEL_CBTC == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	

	/* 进路类型是【折返进路】*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteType(routeId);
		if (ROUTE_TYPE_RETURN == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

	/* 进路状态为
	【进路初锁】
	【进路初锁异常】
	【预先锁闭】
	【接近锁闭异常】
	*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteState(routeId);
		if ((ROUTE_STATE_FIRST_LOCK == devState) ||
			(ROUTE_STATE_FIRST_LOCKERR == devState) ||
			(ROUTE_STATE_YUXIAN_LOCK == devState) ||
			(ROUTE_STATE_NEAR_LOCKERR == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

	/*进路未设置【总取消】且未设置【总人解】*/
	if (CI_SUCCESS == reResult)
	{
		if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) &&
			(ROUTE_ZONGRENJIE_SET_NO == zrjFlag))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

	/* 信号机联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		if (OPEN_CHECK_STEP_OPEN == checkStep)
		{
			checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel);
		}
		else if (OPEN_CHECK_STEP_RECOVER == checkStep)
		{
			checkResult = RecoverBlocRouteSignalCheck(routeId);
		}
		else
		{
			checkResult = CI_ERROR;
		}

		if (CI_ERROR == checkResult)
		{
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

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

	/* 进路内所有区段占用状态【空闲】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

	/* 其他信号联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else if (RETURN_OPEN_ERR_SIGOPEN == checkResult)
		{/*开放需关闭也认为合法*/
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

	/* 接发车联锁条件检查(检查扣车)*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ROUTE_RECOVER_ERR;
		}
	}
	else
	{
	    ;
	}

	/* 区段联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenCbtcRouteSectionErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			/* 通过检查 */
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}
	
	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

	/* 防护进路联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenBlocRouteOverlapErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			/* 通过检查 */
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}
	

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			/* 通过检查 */
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

	/*照查联锁条件正确*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

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

	/* 返回 */
	return reResult;
}

/*
* 功能描述： 开放点式级别折返进路信号
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 OpenBlocReturnRouteErrProcess(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CHECK_OPEN_UT_RETURN_ERR_ZX;

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

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

										/* 进路内设备数据 */
										/* 取消标志 */
	UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId);
	UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId);

	/*故障发送级别*/
	UINT8 sendLevel = ESEND_LEVEL_ZERO;
	UINT16 endSigId = 0u;				/*获取中途折返信号机ID*/
	UINT8 endSigState = SIGNAL_OPEN;

	/* 联锁逻辑检查 */

	/* 进路监督模式为【点式】*/
	devState = GetRouteLevel(routeId);
	if (ROUTE_LEVEL_BLOC == devState)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	/* 进路类型是【折返进路】*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteType(routeId);
		if (ROUTE_TYPE_RETURN == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 进路状态为
	【进路初锁】
	【进路初锁异常】
	【预先锁闭】
	【接近锁闭异常】
	*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteState(routeId);
		if ((ROUTE_STATE_FIRST_LOCK == devState) ||
			(ROUTE_STATE_FIRST_LOCKERR == devState) ||
			(ROUTE_STATE_YUXIAN_LOCK == devState) ||
			(ROUTE_STATE_NEAR_LOCKERR == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*进路未设置【总取消】且未设置【总人解】*/
	if (CI_SUCCESS == reResult)
	{
		if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) &&
			(ROUTE_ZONGRENJIE_SET_NO == zrjFlag))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

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

	/* 道岔联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 其他信号联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else if (RETURN_OPEN_ERR_SIGOPEN == checkResult)
		{/*开放需关闭也认为合法*/
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/* 接发车联锁条件检查(检查扣车)*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ROUTE_RECOVER_ERR;
		}
	}

	/* 区段联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenBlocRouteSectionErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			/* 通过检查 */
			reResult = checkResult;
		}
	}
	
	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/* 防护进路联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenBlocRouteOverlapErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			/* 通过检查 */
			reResult = checkResult;
		}
	}

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			/* 通过检查 */
			reResult = checkResult;
		}
	}

	/*照查联锁条件正确*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

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

	/* 返回 */
	return reResult;
}

/*
* 功能描述： CBTC列车信号保持
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 KeepCbtcLTrainRouteErrProcess(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_KEEP_CT_SIGNAL_ERR_ZX;

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

	UINT8 devState = 0u;                 /*设备状态*/
	UINT16 devId = 0u;                    /*设备ID*/
										/* 进路内设备数据 */
										/* 取消标志 */
	UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId);
	UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId);

	/*故障发送级别*/
	UINT8 sendLevel = ESEND_LEVEL_ZERO;
	UINT8 routeReverseProperty = 0u;
	UINT8 airShaftRouteType = 0u;
	UINT16 routeFirstPhySectionId = 0u;
	UINT16 trainEnteringRouteState = 0u;
	UINT8 signalCrossState = 0u;
	UINT8 rcWorkMode = 0U; /*rc工作模式*/
	rcWorkMode = GetLocalRcWorkMode();
	/* 联锁逻辑检查 */

	/* 进路监督模式为【CBTC】*/
	devState = GetRouteLevel(routeId);
	if ((ROUTE_LEVEL_CBTC == devState))
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	/* 进路类型是列车进路*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteType(routeId);
		if (ROUTE_TYPE_LIECHE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

	/* 进路状态为
	【预先开放】或
	【接近开放】
	*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteState(routeId);
		if ((ROUTE_STATE_YUXIAN_OPEN == devState) ||
			(ROUTE_STATE_NEAR_OPEN == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*进路未设置【总取消】且未设置【总人解】*/
	if (CI_SUCCESS == reResult)
	{
		if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) &&
			(ROUTE_ZONGRENJIE_SET_NO == zrjFlag))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

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

	/* 其他信号联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = KeepCBTCRouteOtherSignalCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 进路内所有区段占用状态【空闲】*/
	if(CI_SUCCESS == reResult)
	{
		routeReverseProperty =  GetRouteReverseProperty(routeId);
		airShaftRouteType = GetAirShaftRouteType(routeId);
		if ((ROUTE_REVERSE_PROPERTY_YES == routeReverseProperty) || (ROUTE_TYPE_AIRSHAFT == airShaftRouteType))
		{  /*反向进路或风井进路需对进路内方所有区段的占压状态进行检查*/
			devId = 0u;
			devState = 0u;
			checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				routeFirstPhySectionId = GetRouteFirstPhySectionId(routeId);
				trainEnteringRouteState = GetTrainEnteringRouteState(routeId);
				signalCrossState = GetSignalCrossState(GetRouteStartSignalId(routeId));
				if((devId == routeFirstPhySectionId) && ((CI_SUCCESS ==trainEnteringRouteState) &&
					(SIGNAL_CROSS_STATE_NO == signalCrossState)))
				{
					/*CBTC反向进路列车正驶入时跨压信息未到,此时不关信号*/
					reResult = CI_SUCCESS;
				}
				else
				{
					if (RC_WORK_MODE_CI == rcWorkMode)
					{
						if (devId == routeFirstPhySectionId)
						{
							reResult = CheckEngineerVehicleNear(routeId); /*检查是否是工程车接近的跨压*/
						}
						else
						{
							reResult = CI_ERROR;
						}


						if (CI_SUCCESS != reResult)
						{
							/* 记录故障码 */
							SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel);
							/* 失败返回 */
							reResult = CI_ERROR;
						}
					}
					else if (RC_WORK_MODE_TIOC == rcWorkMode)
					{
						/* 记录故障码 */
						SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel);
						/* 失败返回 */
						reResult = CI_ERROR;
					}
					else
					{
						/*不做处理*/
					}
				}

			}
			/* 防护进路联锁条件检查 */
			if (CI_SUCCESS == reResult)
			{
				checkResult = OpenBlocRouteOverlapErrCheck(routeId);
				if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
				{
					reResult = checkResult;
				}
			}
		}
	}
	/* 接发车联锁条件检查(检查扣车)*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel);
		if (CI_ERROR == checkResult)
		{
			/*失败返回可重开*/
			reResult = CI_ROUTE_RECOVER_ERR;
		}
	}

	/* 区段联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = KeepCbtcRouteSectionErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}
	
	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*照查联锁条件正确*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

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

	/* 返回 */
	return reResult;
}

/*
* 功能描述： 点式信号保持
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 KeepBlocLTrainRouteErrProcess(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_KEEP_UT_SIGNAL_ERR_ZX;

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

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

										/* 进路内设备数据 */
										/* 取消标志 */
	UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId);
	UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId);

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

	/* 联锁逻辑检查 */

	/* 进路监督模式为【点式】*/
	devState = GetRouteLevel(routeId);
	if ((ROUTE_LEVEL_BLOC == devState))
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	/* 进路类型是列车进路*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteType(routeId);
		if (ROUTE_TYPE_LIECHE == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 进路状态为
	【预先开放】或
	【接近开放】
	*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteState(routeId);
		if ((ROUTE_STATE_YUXIAN_OPEN == devState) ||
			(ROUTE_STATE_NEAR_OPEN == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*进路未设置【总取消】且未设置【总人解】*/
	if (CI_SUCCESS == reResult)
	{
		if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) &&
			(ROUTE_ZONGRENJIE_SET_NO == zrjFlag))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

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

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

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

	/* 接发车联锁条件检查(检查扣车)*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ROUTE_RECOVER_ERR;
		}
	}

	/* 区段联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenBlocRouteSectionErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}
	
	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/* 防护进路联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenBlocRouteOverlapErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*照查联锁条件正确*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

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

	/* 返回 */
	return reResult;
}

/*
* 功能描述： CBTC折返进路信号保持
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 KeepCbtcReturnRouteErrProcess(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_KEEP_CT_RETURN_SIG_ERR_ZX;

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

	UINT8 devState = 0u;                 /*设备状态*/
	UINT16 devId = 0u;               /*设备ID*/
	/*故障发送级别*/
	UINT8 sendLevel = ESEND_LEVEL_ZERO;									
									
	UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId);
	UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId);
	UINT16 routeFirstPhySectionId = 0u;
	UINT8 trainEnteringRouteState =0u;
	UINT8 signalCrossState = 0u;
	UINT8 rcWorkMode = 0U; /*rc工作模式*/
	rcWorkMode = GetLocalRcWorkMode();
	devState = GetRouteLevel(routeId);
	if (ROUTE_LEVEL_CBTC == devState)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	/* 进路类型是【折返进路】*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteType(routeId);
		if (ROUTE_TYPE_RETURN == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 进路状态为
	【预先开放】或
	【接近开放】
	*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteState(routeId);
		if ((ROUTE_STATE_YUXIAN_OPEN == devState) ||
			(ROUTE_STATE_NEAR_OPEN == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*进路未设置【总取消】且未设置【总人解】*/
	if (CI_SUCCESS == reResult)
	{
		if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) &&
			(ROUTE_ZONGRENJIE_SET_NO == zrjFlag))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}


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

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

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

	/* 进路内所有区段占用状态【空闲】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		if (RC_WORK_MODE_TIOC == rcWorkMode)
		{
			checkResult = KeepCbtcReturnRouteSecOccCheck(routeId, functionId, sendLevel);
			if (CI_SUCCESS == checkResult)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
		else if(RC_WORK_MODE_CI == rcWorkMode)
		{
			checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState);
			if (CI_SUCCESS == checkResult)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				routeFirstPhySectionId = GetRouteFirstPhySectionId(routeId);
				trainEnteringRouteState = GetTrainEnteringRouteState(routeId);
				signalCrossState = GetSignalCrossState(GetRouteStartSignalId(routeId));
				if ((devId == routeFirstPhySectionId) && ((CI_SUCCESS == trainEnteringRouteState) &&
					(SIGNAL_CROSS_STATE_NO == signalCrossState)))
				{
					/*CBTC折返进路列车正驶入时跨压信息未到,此时不关信号*/
					reResult = CI_SUCCESS;
				}
				else
				{
					if (devId == routeFirstPhySectionId)
					{
						reResult = CheckEngineerVehicleNear(routeId); /*检查是否是工程车接近的跨压*/
					}
					else
					{
						reResult = CI_ERROR;
					}

					if (CI_SUCCESS != reResult)
					{
						/* 记录故障码 */
						SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel);
					}
					else
					{
						;
					}

				}

			}
		}
		else
		{
			reResult = CI_ERROR;/*模式错误返回失败*/
		}

	}

	/* 接发车联锁条件检查(检查扣车)*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ROUTE_RECOVER_ERR;
		}
	}

	/* 区段联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = KeepCbtcRouteSectionErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}
	
	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/* 防护进路联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenBlocRouteOverlapErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			/* 通过检查 */
			reResult = checkResult;
		}
	}

	/*照查联锁条件正确*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

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

	/* 返回 */
	return reResult;
}

/*
* 功能描述： 点式折返进路信号保持
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 KeepBlocReturnRouteErrProcess(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_KEEP_UT_RETURN_SIG_ERR_ZX;

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

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

										/* 进路内设备数据 */
										/* 取消标志 */
	UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId);
	UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId);

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

	/* 联锁逻辑检查 */

	/* 进路监督模式为【点式】*/

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


	/* 进路类型是【折返进路】*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteType(routeId);
		if (ROUTE_TYPE_RETURN == devState)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 进路状态为
	【预先开放】或
	【接近开放】
	*/
	if (CI_SUCCESS == reResult)
	{
		devState = GetRouteState(routeId);
		if ((ROUTE_STATE_YUXIAN_OPEN == devState) ||
			(ROUTE_STATE_NEAR_OPEN == devState))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*进路未设置【总取消】且未设置【总人解】*/
	if (CI_SUCCESS == reResult)
	{
		if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) &&
			(ROUTE_ZONGRENJIE_SET_NO == zrjFlag))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

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

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

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

	/* 接发车联锁条件检查(检查扣车)*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ROUTE_RECOVER_ERR;
		}
	}

	/* 区段联锁条件检查 */
	if ((CI_ROUTE_RECOVER_ERR == reResult) || (CI_SUCCESS == reResult))
	{
		checkResult = OpenBlocRouteSectionErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}
	
	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/* 防护进路联锁条件检查 */
	if ((CI_ROUTE_RECOVER_ERR == reResult) || (CI_SUCCESS == reResult))
	{
		checkResult = OpenBlocRouteOverlapErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			/* 通过检查 */
			reResult = checkResult;
		}
	}

	/*照查联锁条件正确*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

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

	/* 返回 */
	return reResult;
}

/*
* 功能描述： 开放列车进路信号逻辑处理，车辆段
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 OpenLTrainRouteErrP(const UINT16 routeId, const UINT8 checkStep)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CHECK_OPEN_L_ERR_CLD;

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

												 /* 局部变量定义初始化 */
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 checkResult = CI_ERROR;
	UINT8 reResult = CI_ERROR;

	/* 联锁条件检查 */
	/*有总取消或总人解*/
	if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) ||
		(GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}
	else
	{
		reResult = CI_SUCCESS;
	}



	

	if (CI_SUCCESS == reResult)
	{
		devId = routeId;
		devState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId), GetSystemParaRouteOpenSigCyc());
		if (CI_TIME_OUT == devState)
		{ /*选排超时*/
			reResult = CI_ERROR;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}
	

	/*信号联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		if (OPEN_CHECK_STEP_OPEN == checkStep)
		{
			checkResult = OpenLTrainRouteSignalCheck(routeId, functionId, sendLevel);
		}
		else if (OPEN_CHECK_STEP_RECOVER == checkStep)
		{
			checkResult = RecoverLTrainRouteSignalCheck(routeId);
		}
		else
		{
			/* 失败返回 */
			checkResult = CI_ERROR;
		}

		if (CI_ERROR == checkResult)
		{
			reResult = CI_ERROR;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

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

	/* 其他信号联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else if (RETURN_OPEN_ERR_SIGOPEN == checkResult)
		{/*开放需关闭也认为合法*/
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}

	/*区段联锁条件检查*/
	if (reResult == CI_SUCCESS)
	{
		checkResult = OpenLTrainRouteSectionErrCheck(routeId);
		if ((checkResult == CI_ERROR) || (checkResult == CI_ROUTE_RECOVER_ERR))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

	/* 防护进路联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenBlocRouteOverlapErrCheck(routeId);
		if ((checkResult == CI_ERROR) || (checkResult == CI_ROUTE_RECOVER_ERR))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);

		if ((checkResult == CI_ERROR) || (checkResult == CI_ROUTE_RECOVER_ERR))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

	/*照查联锁条件正确*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

	return reResult;
}

/*
* 功能描述： 开放调车进路信号逻辑处理，车辆段
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 OpenDTrainRouteErrP(const UINT16 routeId, const UINT8 checkStep)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CHECK_OPEN_D_ERR_CLD;

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

												 /* 局部变量定义初始化 */
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 reResult = CI_ERROR;
	UINT8 checkResult = CI_ERROR;		/*进路照查满足条件检查结果，20150616*/

										/* 联锁条件检查 */
										/*有总取消或总人解*/
	UINT8 zqxflag = 0u;
	UINT8 zrjflag = 0u;
	zqxflag = GetRouteZongQuXiaoFlag(routeId);
	zrjflag = GetRouteZongRenJieFlag(routeId); 

	if ((ROUTE_ZONGQUXIAO_SET_YES == zqxflag) ||
		(ROUTE_ZONGRENJIE_SET_YES == zrjflag))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}
	else
	{
		reResult = CI_SUCCESS;
	}

	if (CI_SUCCESS == reResult)
	{
		devId = routeId;
		devState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId), GetSystemParaRouteOpenSigCyc());
		if (CI_TIME_OUT == devState)
		{ /*选排超时*/
			reResult = CI_ERROR;
		}
	}

	/*信号联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		if (OPEN_CHECK_STEP_OPEN == checkStep)
		{
			checkResult = OpenLTrainRouteSignalCheck(routeId, functionId, sendLevel);
		}
		else if (OPEN_CHECK_STEP_RECOVER == checkStep)
		{
			checkResult = RecoverLTrainRouteSignalCheck(routeId);
		}
		else
		{
			/* 失败返回 */
			checkResult = CI_ERROR;
		}

		if (CI_ERROR == checkResult)
		{
			reResult = CI_ERROR;
		}
	}

	/*道岔联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		/* 检查道岔条件是否满足 */
		reResult = OpenLTrainRouteSwitchCheck(routeId, functionId, sendLevel);
	}

	/* 其他信号联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{/*等待照查落下也认为是合法*/
		checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else if (RETURN_OPEN_ERR_SIGOPEN == checkResult)
		{/*开放需关闭也认为合法*/
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

	/*区段联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenDTrainRouteSectionErrCheck(routeId);
		if ((checkResult == CI_ERROR) || (checkResult == CI_ROUTE_RECOVER_ERR))
		{
			/* 通过检查 */
			reResult = checkResult;
		}
	}
	
	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);

		if ((checkResult == CI_ERROR) || (checkResult == CI_ROUTE_RECOVER_ERR))
		{
			/* 通过检查 */
			reResult = checkResult;
		}
	}

	/*照查联锁条件正确*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	return reResult;
}

/*
* 功能描述： 保持列车进路信号逻辑处理，车辆段
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 KeepLTrainRouteErrP(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_KEEP_L_ERR_CLD;

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

												 /* 局部变量定义初始化 */
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 reResult = CI_ERROR;
	UINT8 checkResult = CI_ERROR;		/*临时检查结果变量*/
	UINT8 zqxflag = 0u;
	UINT8 zrjflag = 0u;

										/* 联锁条件检查 */
										/*有总取消或总人解*/
	zqxflag = GetRouteZongQuXiaoFlag(routeId);
	zrjflag = GetRouteZongRenJieFlag(routeId);
	if ((ROUTE_ZONGQUXIAO_SET_YES == zqxflag) ||
		(ROUTE_ZONGRENJIE_SET_YES == zrjflag))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}
	else
	{
		reResult = CI_SUCCESS;
	}

	/*进路状态【预先开放】或【接近开放】*/
	if (CI_SUCCESS == reResult)
	{
		devId = routeId;
		devState = GetRouteState(devId);
		if ((ROUTE_STATE_YUXIAN_OPEN != devState) &&
			(ROUTE_STATE_NEAR_OPEN != devState))
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*信号联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		/*  检查信号联锁条件*/
		reResult = KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel);
	}

	/*道岔联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		/* 检查道岔联锁条件 */
		reResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel);
	}

	/*其他信号机联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		/* 检查其他信号机联锁条件 */
		reResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel);
	}

	/*区段联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenLTrainRouteSectionErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}
	
	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/* 防护进路联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OpenBlocRouteOverlapErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*其它联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = OtherCiValidErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*照查联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}
	return reResult;
}

/*
* 功能描述： 保持调车进路信号逻辑处理，车辆段
* 参数说明：
UINT16 const routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
UINT8 KeepDTrainRouteErrP(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_KEEP_D_ERR_CLD;

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

												 /* 局部变量定义初始化 */
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 reResult = CI_SUCCESS;
	UINT8 checkResult = CI_ERROR;		/*临时检查结果变量*/
	UINT8 zrjflag = 0u;
	UINT8 zqxflag = 0u;
										/* 联锁条件检查 */
										/*有总取消或总人解*/
	zqxflag = GetRouteZongQuXiaoFlag(routeId);
	zrjflag = GetRouteZongRenJieFlag(routeId); 
	if ((ROUTE_ZONGQUXIAO_SET_YES == zqxflag) ||
		(ROUTE_ZONGRENJIE_SET_YES == zrjflag))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	/*进路状态【预先开放】或【接近开放】*/
	if (CI_SUCCESS == reResult)
	{
		devId = routeId;
		devState = GetRouteState(devId);
		if ((ROUTE_STATE_YUXIAN_OPEN != devState) &&
			(ROUTE_STATE_NEAR_OPEN != devState))
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*信号联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		/* 失败返回 */
		reResult =  KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel);
	}

	/*道岔联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		/* 失败返回 */
		reResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel);
	}

	/*其他信号机联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		/* 失败返回 */
		reResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel);
	}

	/*其它联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = OtherCiValidErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*进路内区段检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = KeepDTrainRouteSectionErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}
	
	/* 侵限区段SPKS联锁条件检查 */
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteIntruSecVainSPKSErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

	/*照查联锁条件检查*/
	if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
	{
		checkResult = RouteRelayZhaoChaErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}
	return reResult;
}

/*
* 功能描述： SPKS、PSD、扣车恢复检查
* 参数说明： const UINT16 routeId, 进路ID
* 返回值  ： UINT8
*/
UINT8 RecoverOpenRouteCheck(const UINT16 routeId)
{
	UINT8 routeType = 0u;          /*进路类型*/
	UINT8 routeLevel = 0u;         /*进路监督级别*/
	UINT8 errType = CI_ERROR;/*定义检查失败时的错误类型*/

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

	if (ROUTE_TYPE_LIECHE == routeType)
	{ /*列车进路*/
		if (ROUTE_LEVEL_CBTC == routeLevel)
		{ /*CBTC*/
			errType = OpenCbtcLTrainRouteErrProcess(routeId, OPEN_CHECK_STEP_RECOVER);
		}
		else
		{ /*点式*/
			errType = OpenBlocLTrainRouteErrProcess(routeId);
		}
	}
	else if (ROUTE_TYPE_RETURN == routeType)
	{ /*折返进路*/
		if (ROUTE_LEVEL_CBTC == routeLevel)
		{ /*CBTC*/
			errType = OpenCbtcReturnRouteErrProcess(routeId, OPEN_CHECK_STEP_RECOVER);
		}
		else
		{ /*点式*/
			errType = OpenBlocReturnRouteErrProcess(routeId);
		}
	}
	else
	{/*不处理*/
		errType = CI_ERROR;
	}

	return errType;
}

/*
* 功能描述： SPKS、PSD、扣车恢复检查，车辆段
* 参数说明： const UINT16 routeId, 进路ID
* 返回值  ： UINT8
*/
UINT8 RecoverOpenRouteCheckCLD(const UINT16 routeId)
{
	UINT8 routeType = 0u;          /*进路类型*/
	UINT8 errType = CI_ERROR;/*定义检查失败时的错误类型*/
	UINT8 jkjRelayValidFlag = 0u; /*初始化应急盘继电器有效状态*/
	jkjRelayValidFlag = GetCiJkjFlag();	
	routeType = GetRouteType(routeId);                /*获取进路类型*/
	if (JKJ_REYLAY_VALID == jkjRelayValidFlag)
	{/*应急盘继电器有效状态,不允许信号重开*/
		errType = CI_ERROR;
	}
	else if (ROUTE_TYPE_LIECHE == routeType)
	{ /*列车进路*/

		errType = OpenLTrainRouteErrP(routeId, OPEN_CHECK_STEP_RECOVER); /*开放列车进路*/
	}
	else if (ROUTE_TYPE_DIAOCHE == routeType)
	{ /*调车进路*/

		errType = OpenDTrainRouteErrP(routeId, OPEN_CHECK_STEP_RECOVER); /*开放调车进路*/
	}
	else
	{ /*进路类型错误*/
		errType = CI_ERROR;
	}
	return errType;
}


/*
* 功能描述： 其他联锁条件检查
* 参数说明： UINT16 routeId 进路ID
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OtherCiValidErrCheck(UINT16 const routeId)
{
	/*进路等级*/
	UINT8 const routeLevel = GetRouteLevel(routeId);

	/*ESB数据*/
	UINT8 checkSum = 0u;
	RouteOtherCheckStruct *dataOtherCiDevBuf = NULL;
	RouteOtherCheckStruct *tmpOtherCiDevInfo = NULL;

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

	/*进路始端信号机关联的PSD*/
	UINT16 rtStartSigId = 0u;/*进路始端信号机ID*/
	UINT8 psdSum = 0u;/*进路始端信号机关联的PSD数量*/
	UINT16 *psdIdBuf = NULL;/*进路始端信号机关联的PSD ID数组*/
	UINT16 j = 0u;/*遍历进路始端信号机关联的PSD ID数组的下标*/
	UINT8 toOpenCheckFlag = 0u;/*恢复可重开信号的条件标志*/
	UINT8 otherResult = 0u;/*其他联锁检查条件返回值*/
	UINT8 cFuncSwitchSpks = 0U;  /*SPKS信号重开检查进路级别开关*/

	if (routeLevel == ROUTE_LEVEL_BLOC)
	{
		checkSum = GetRouteBlocOtherCiSum(routeId);
		dataOtherCiDevBuf = GetRouteBlocOtherCiBuf(routeId);
	}
	else if (routeLevel == ROUTE_LEVEL_CBTC)
	{
		checkSum = GetRouteCbtcOtherCiSum(routeId);
		dataOtherCiDevBuf = GetRouteCbtcOtherCiBuf(routeId);
	}
	else
	{
		checkSum = 0u;
		dataOtherCiDevBuf = NULL;

	}

	/* 开始检查 */
	if ((0u != checkSum) && (NULL != dataOtherCiDevBuf))
	{
		rtStartSigId = GetRouteStartSignalId(routeId);/*获得进路始端信号机*/
		psdSum = GetSignalRelatedPsdSum(rtStartSigId);/*获得进路始端信号机关联的PSD数量*/
		psdIdBuf = GetSignalRelatedPsdBuf(rtStartSigId);/*获得进路始端信号机关联的PSD ID数组*/

														/*开始检查*/
		for (i = 0u; i < checkSum; i++)
		{
			tmpOtherCiDevInfo = &dataOtherCiDevBuf[i];

			toOpenCheckFlag = 0u;/*默认为恢复不可重开*/
								/*判断检查条件为SPKS或是本信号机关联的PSD*/
			if (CI_DEVICE_TYPE_SPKS == tmpOtherCiDevInfo->DevType)
			{
				cFuncSwitchSpks = GetCiFunctionSwitchConfig(FUNC_REPEATE_OPEN_CHECK_SPKS);
				if ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == routeLevel)))
				{
					/*SPKS信号重开检查进路级别开关打开或（关闭且进路级别为CBTC）*/
					toOpenCheckFlag = 1U;
				}
				else
				{
					toOpenCheckFlag = 0U;
				}
			}
			else if (CI_DEVICE_TYPE_PSD == tmpOtherCiDevInfo->DevType)
			{
				if ((NULL != psdIdBuf) && (0u < psdSum))
				{
					for (j = 0u;j < psdSum;j++)
					{
						if (psdIdBuf[j] == tmpOtherCiDevInfo->DevId)
						{
							toOpenCheckFlag = 1u;
							break;
						}
					}
				}
			}
			else
			{
				toOpenCheckFlag = 0u;
			}

			/*对指定条件进行检查*/
			otherResult = OtherCiDevStatusCheck(routeId, tmpOtherCiDevInfo, &devId, &devState);
			if ((otherResult == CI_ERROR) || (otherResult == CI_ROUTE_RECOVER_ERR))
			{
				if (1u == toOpenCheckFlag)
				{
					if (CI_SUCCESS == ret)
					{
						ret = CI_ROUTE_RECOVER_ERR;
					}
				}
				else
				{
					ret = CI_ERROR;
					debug_infor_printf((const)"\n OtherCiValidErrCheck failed, CurCycle:%d, routeId:%d, DevType:%d, DevId:%d, DevStatus:%d\n",
						Get2oo2CurCycleNum(),routeId,
						tmpOtherCiDevInfo->DevType,tmpOtherCiDevInfo->DevId,tmpOtherCiDevInfo->DevStatus);
					break;
				}
			}
		}
	}

	return ret;
}

/*
* 功能描述： 进路区段封锁检查
* 参数说明： UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 RouteSecFLockErrCheck(UINT16 const routeId)
{
	/* 进路区段*/
	UINT8 const checkSum = GetRoutePhysicalSectionSum(routeId);
	RoutePhysicalSectionStruct* const dataIdBuf = GetRouteSectionData(routeId);

	/* 局部变量定义初始化 */
	UINT16 i = 0u;           /* 循环变量 */
	UINT16 devId = 0u;
	UINT8  devState = 0u;
	UINT8 ret = CI_SUCCESS;
	UINT8 fLockType = PHY_SEC_FLOCK_TYPE_NONE;/*物理区段封锁类型变量*/
	UINT8 cRouteLevel = ROUTE_LEVEL_BLOC;  /*进路级别*/
	UINT8 cFuncSwitchSpks = 0U;  /*SPKS信号重开检查进路级别开关*/

	if (0u == checkSum) 
	{
		/*区段数据错误*/
		ret = CI_ERROR;
	}
	else
	{
		/*开始检查*/
		for (i = 0u; ((i < checkSum) && (CI_ERROR != ret)); i++)
		{
			devId = dataIdBuf[i].PhysicalSectionId;
			devState = GetPhySecFLockState(devId);

			/* 状态如果不是未封锁状态，则认为检查失败 */
			if (PHYSICAL_SECTION_FLOCK_NO == devState)
			{
				/*不处理*/
			}
			else if (PHYSICAL_SECTION_FLOCK_YES ==devState )
			{
				fLockType = GetPhySecFLockType(devId);/*获得物理区段封锁类型*/

				if (PHY_SEC_FLOCK_TYPE_SPKS == fLockType)
				{
					if (CI_ERROR != ret)
					{
						cFuncSwitchSpks = GetCiFunctionSwitchConfig(FUNC_REPEATE_OPEN_CHECK_SPKS);
						cRouteLevel = GetRouteLevel(routeId);
						if ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == cRouteLevel)))
						{
							/*SPKS信号重开检查进路级别开关打开或（关闭且进路级别为CBTC）*/
							ret = CI_ROUTE_RECOVER_ERR;
						}
						else
						{
							ret = CI_ERROR;
						}
					}
					else
					{
					    ;
					}
				}
				else
				{
					ret = CI_ERROR;
				}
			}
			else
			{
				ret = CI_ERROR;
			}
		}
	}

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

/*
* 功能描述： 保护区段封锁状态有效性检查
* 参数说明： UINT16 const overlapId,  OverlapID
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OverlapAllSecFLockValidErrCheck(UINT16 const overlapId)
{
	/* overlap区段 */
	UINT8 const checkSum = GetOverlapPhySecSum(overlapId);
	UINT16* const dataIdBuf = GetOverlapPhySecIdBuf(overlapId);

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

	UINT8 fLockType = PHY_SEC_FLOCK_TYPE_NONE;/*物理区段封锁类型变量*/
	UINT8 cRouteLevel = ROUTE_LEVEL_BLOC;  /*进路级别*/
	UINT8 cFuncSwitchSpks = 0U;  /*SPKS信号重开检查进路级别开关*/
	UINT16 wBelongRouteId = 0U;  /*保护区段锁闭所属进路*/

	if ((0U != overlapId) && (OVERLAP_SUM_MAX != overlapId))
	{
		if (0u != checkSum)
		{
			/*开始检查*/

			/* 保护区段内所有区【未封锁】*/
			for (i = 0u; ((i < checkSum) && (CI_ERROR != ret)); i++)
			{
				devId = dataIdBuf[i];
				devState = GetPhySecFLockState(devId);

				/* 状态如果不是未封锁状态，则认为检查失败 */
				if (PHYSICAL_SECTION_FLOCK_NO == devState)
				{
					/*不处理*/
				}
				else if (PHYSICAL_SECTION_FLOCK_YES == devState)
				{
					fLockType = GetPhySecFLockType(devId);/*获得物理区段封锁类型*/

					if (PHY_SEC_FLOCK_TYPE_SPKS == fLockType)
					{
						wBelongRouteId = GetOverlapBelongRouteId(overlapId);
						if ((CI_ERROR != ret) && (CI_ERROR != wBelongRouteId))
						{							
							cFuncSwitchSpks = GetCiFunctionSwitchConfig(FUNC_REPEATE_OPEN_CHECK_SPKS);
							cRouteLevel = GetRouteLevel(wBelongRouteId);
							if ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == cRouteLevel)))
							{
								/*SPKS信号重开检查进路级别开关打开或（关闭且进路级别为CBTC）*/
								ret = CI_ROUTE_RECOVER_ERR;
							}
							else
							{
								ret = CI_ERROR;
							}
						}
						else
						{
							;
						}
					}
					else
					{
						ret = CI_ERROR;
					}
				}
				else
				{
					ret = CI_ERROR;
				}
			}
		}
		else
		{
			;
		}
	}
	else
	{
		ret = CI_ERROR;  /*入参错误*/
	}

	return ret;
}

/*
* 功能描述： 开放调车进路区段联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 KeepDTrainRouteSectionErrCheck(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_KEEP_D_SEC_ERR_CHECK_CLD;

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

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

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

												 /* 联锁逻辑检查 */

	                                             /* 进路内所有区段占用状态【空闲】 或 停止检查列检查库区段不检查 */
	devId = 0u;
	devState = 0u;
	checkResult = CheckDTrainKeepSigPhySecOccupy(routeId, functionId, sendLevel);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}
	


	/* 进路内所有区段锁闭状态【正常锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
		 ;
	}

/*使用新增的函数RouteIntruSecVainSPKSErrCheck*/
#if 0
	/*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#endif

	/* 进路内所有区段【未设置跳跃锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecJumpLockStateCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
		 ;
	}


	/* 进路内所有区段未被封锁 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = RouteSecFLockErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

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

/*
* 功能描述： 开放列车进路区段联锁条件检查，车辆段
* 参数说明：
*            const UINT16 routeId,    进路ID
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OpenLTrainRouteSectionErrCheck(const UINT16 routeId)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

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

										/* 联锁逻辑检查 */

	devId = 0u;
	devState = 0u;
	checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState);
	/* 进路内所有区段占用状态【空闲】*/
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	/* 进路内所有区段锁闭状态【正常锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}

/*使用新增的函数RouteIntruSecVainSPKSErrCheck*/
#if 0
	/*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#endif

	/* 进路内所有区段【未设置跳跃锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecJumpLockStateCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 进路内所有区段未被封锁 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = RouteSecFLockErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

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

/*
* 功能描述： 点式进路开放信号保护区段联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OpenBlocRouteOverlapErrCheck(const UINT16 routeId)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

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

	/*进路内设备数据 */
	/*防护进路*/
	UINT8 const overlapSum = GetRouteOverlapSum(routeId);
	UINT16 const overlapId = GetRouteOverlapLockedId(routeId);

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

	/* 联锁逻辑检查 */

	/*防护进路检查*/
	if (overlapSum > 0u)
	{
		/*有防护进路*/
		/*进路【保护区段锁闭Id】>0 且 保护区段【防护锁闭所属进路ID】等于当前进路*/
		devId = GetOverlapFirstPhySecId(overlapId);
		devState = GetPhySecLockState(devId);
		if ((overlapId > 0u) && (routeId == GetPhySecPLockBelongRouteId(devId)))
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}

		/*所有防护区段【空闲】*/
		if (CI_SUCCESS == reResult)
		{
			devId = 0u;
			devState = 0u;
			checkResult = OpenBlockOvlpAllSecOccuClrCheck(overlapId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}

		if(CI_TRADITION_RAILWAY == lineIdentity)
		{
			/*保护区段道岔【位置正确】*/
			if (CI_SUCCESS == reResult)
			{
				devId = 0u;
				devState = 0u;
				checkResult = OverlapSwitchPosCheck(overlapId, &devId, &devState);
				if (checkResult == CI_SUCCESS)
				{
					/* 通过检查 */
					reResult = CI_SUCCESS;
				}
				else
				{
					/* 失败返回 */
					reResult = CI_ERROR;
				}
			}


		}
		else
		{
			/* zt 删除单轨相关代码 2022-02-15 */
		}

		/*保护区段 内所有道岔【未封锁】*/
		if (CI_SUCCESS == reResult)
		{
			devId = 0u;
			devState = 0u;
			checkResult = OverlapSwitchFLockStateCheck(overlapId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}

		/*保护区段 防护道岔【未封锁】*/
		if (CI_SUCCESS == reResult)
		{
			devId = 0u;
			devState = 0u;
			checkResult = OvlpRelProtSwiFLockStaCheck(overlapId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}

		/*保护区段关联防护道岔【位置正确】*/
		if(CI_SUCCESS == reResult)
		{
			devId = 0u;
			devState = 0u;
			checkResult = OvlpRelatedProtSwitchPosCheck(overlapId,&devId,&devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}	
			else
			{ 
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}

		/*保护区段关联防护道岔【防护锁闭】或【单锁且防护锁闭】*/
		if (CI_SUCCESS == reResult)
		{
			devId = 0u;
			devState = 0u;
			checkResult = OvlpRelatedProtSwitchLockCheck(overlapId,&devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}


		if (CI_SUCCESS == reResult)
		{
			/*检查进路侵限条件状态*/
			devId = 0u;
			devState = 0u;
			checkResult = OverlapInvSecAndConSwiCheckup(overlapId, &devId, &devState);
			if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
			{
				reResult = checkResult;
			}
		}

		/*保护区段侧防条件检查*/
		if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
		{
			/*检查保护区段侧防道岔区段状态*/
			devId = 0u;
			devState = 0u;
			checkResult = OverlapLateralDfnCheck(overlapId, &devId, &devState);
			if (CI_ERROR == checkResult)
			{
				reResult = checkResult;
			}
		}

		/*检查保护区段有效性*/
		if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
		{
			devId = 0u;
			devState = 0u;
			checkResult = SignalOverlapValidCheck(routeId, &devId, &devState);
			if (CI_ERROR == checkResult)
			{
				reResult = checkResult;
			}
		}
		/* 进路内所有区段【未设置跳跃锁闭】*/
		if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
		{
			devId = 0u;
			devState = 0u;
			checkResult = OverlapAllSecJumpLockStateCheck(overlapId,&devId,&devState);
			if (CI_ERROR == checkResult)
			{
				reResult = checkResult;
			}
		}
		/*所有防护区段【未封锁】*/
		if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
		{
			checkResult = OverlapAllSecFLockValidErrCheck(overlapId);
			if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
			{
				reResult = checkResult;
			}
		}

		/*保护区段内所有防淹门状态检查*/
		if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
		{
			devId = 0u;
			devState = 0u;
			checkResult = OverlapFloodGateStateCheck(overlapId,&devId,&devStateType,&devState);
			if (CI_ERROR == checkResult)
			{
				reResult = checkResult;
			}
		}


		/*检查照查继电器状态*/
		if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult))
		{
			checkResult = OverlapZhaoChaRelayCheck(overlapId, ESEND_LEVEL_ZERO);

			if (CI_ERROR == checkResult)
			{
				reResult = checkResult;
			}
			else
			{
				
				;
			}
		}
		
	}
	else
	{
		/*无防护进路不检查*/
		reResult = CI_SUCCESS;
	}

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

/*
* 功能描述： 开放调车进路区段联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OpenDTrainRouteSectionErrCheck(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_OPEN_D_SEC_ERR_CHECK_CLD;

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

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

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

										/* 联锁逻辑检查 */
										/* 进路内所有区段占用状态【空闲】 或 停止检查列检查库区段不检查 */
	checkResult = CheckDTrainRoutePhySecOccupy(routeId, functionId, sendLevel);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	/* 进路内所有区段锁闭状态【正常锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

/*使用新增的函数RouteIntruSecVainSPKSErrCheck*/
#if 0
	/*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#endif

	/* 进路内所有区段【未设置跳跃锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecJumpLockStateCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 进路内所有区段未被封锁 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = RouteSecFLockErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
	}

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

/*
* 功能描述： 点式进路开放信号区段联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ：
CI_ERROR:失败
CI_SUCCESS:成功
CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OpenBlocRouteSectionErrCheck(const UINT16 routeId)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 chDsnFuncSwitch = 0U;		/* 无直轨计轴占用功能开关 */
	UINT8 chXianSuFuncSwitch = 0U; /*后备模式信号开放是否检查区段临时限速开关*/

	chDsnFuncSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH);
	chXianSuFuncSwitch = GetCiFunctionSwitchConfig(FUNC_XIANSU_SWITCH);

	devId = 0u;
	devState = 0u;
	checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		if (FUNC_SWITCH_ON != chDsnFuncSwitch)
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
		else
		{
			checkResult = RouteAllSecColOccuClearCheck(routeId, &devId, &devState);

			if (CI_SUCCESS == checkResult)
			{
				checkResult = RouteFaultOccuCheck(routeId, &devId, &devState);
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}

			if (CI_SUCCESS == checkResult)
			{
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
	}
	/* 进路内所有区段锁闭状态【正常锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*使用新增的函数RouteIntruSecVainSPKSErrCheck*/
#if 0
	/*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#endif
	/* 进路内所有区段【未设置跳跃锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 进路内所有区段未被封锁 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = RouteSecFLockErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
			/*无处理*/
		}
	}

	/* 进路内所有区段未设置临时限速 */
	if (CI_SUCCESS == reResult)
	{
		if (FUNC_SWITCH_ON == chXianSuFuncSwitch)
		{/*后备模式信号开放是否检查区段临时限速开关打开*/
			checkResult = RouteAllLgcSecXianSuCheck(routeId, &devId, &devState);

			if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
			{
				reResult = checkResult;
			}
			else
			{
				/*无处理*/
			}
		}
		else
		{
			/* 功能开关关闭,不检查 */
		}
	}

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

/*
* 功能描述： Cbtc进路信号保持区段联锁条件检查
* 参数说明：
*           const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 KeepCbtcRouteSectionErrCheck(const UINT16 routeId)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT16 startSignalId = 0u;
	UINT8 functionId = EFUNC_KEEPROUTESECTIONERRCHECK;
	UINT8 rcWorkMode = 0U; /*rc工作模式*/
	UINT8 signalCrossState = 0u;
	UINT8 preLogDevState = 0u;			/*之前逻辑区段占用状态*/
	UINT8 LogSecCurCtOrUtOcc = 0U;		/*逻辑区段当前占用状态*/
	UINT8 cLocalCiType = 0U;  /*本控区类型*/

	rcWorkMode = GetLocalRcWorkMode();

	/* 联锁逻辑检查 */
	reResult = CI_SUCCESS;
	cLocalCiType = GetLocalCiType();
	if (CI_TYPE_CLD != cLocalCiType)
	{
		/*非车辆段，按CBTC既有逻辑处理*/
		if (RC_WORK_MODE_TIOC == rcWorkMode)
		{
			/*CBTC进路内方第一逻辑区段条件检查*/
			reResult = RouteCbtcFirstLgcSecCheck(routeId, &devId, &devState);
			if (CI_SUCCESS == reResult)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
		else if (RC_WORK_MODE_CI == rcWorkMode)
		{/*CI*/

			/* 进路始端信号机【未跨压】且 非（进路外方区段【空闲】且内方第一逻辑区段【占用】）*/
			startSignalId = GetRouteStartSignalId(routeId);
			devId = GetRouteInFirstLogSecId(routeId);
			devState = GetLogSecCurOccupyState(devId);
			signalCrossState = GetSignalCrossState(startSignalId);
			LogSecCurCtOrUtOcc = GetLogSecCurCtOrUtOccupyState(devId);
			preLogDevState = GetLogSecPreCtOrUtOccupyState(devId);
			if ((SIGNAL_CROSS_STATE_NO == signalCrossState)
				&& (!((SECTION_OCCUPY_NO == devState) && (LOGICSECTION_OCCUPY_CT == preLogDevState)))
				)
			{
				/*无跨压时，非（内方第一逻辑区段区段当前【空闲】且之前【CT占用】，说明已经出清第一逻辑区段），只要未出清第一逻辑区段，则继续等跨压*/

				if (LOGICSECTION_OCCUPY_UT != LogSecCurCtOrUtOcc)
				{
					/*只有当为CT占压和空闲时，防止UT异常占压 通过检查 */
					reResult = CI_SUCCESS;
				}
				else
				{
					reResult = CI_ERROR;	/*UT占压异常*/
				}
			}
			else
			{
				reResult = CheckEngineerVehicleNear(routeId);/*检查是否是工程车接近的跨压以及列车的真实跨压*/
			}
		}
		else
		{
			reResult = CI_ERROR;/*模式错误返回失败*/
		}
	}
	else
	{
		/*车辆段，进路不可追踪，需检查进路内方区段空闲*/
		reResult = CLDKeepOpenSecCheck(routeId, functionId, ESEND_LEVEL_ZERO);
	}

	/* 进路内所有区段锁闭状态【正常锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState);
		if (CI_SUCCESS ==checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}
/*使用新增的函数RouteIntruSecVainSPKSErrCheck*/	
#if 0
	/*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	
#endif

	/* 进路内所有区段未被封锁 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = RouteSecFLockErrCheck(routeId);

		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

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

/*
* 功能描述： Cbtc进路信号开放区段联锁条件检查
* 参数说明：
*           const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*			 CI_ROUTE_RECOVER_ERR:失败，但是当条件满足时可以重开信号
*/
static UINT8 OpenCbtcRouteSectionErrCheck(const UINT16 routeId)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT16 startSignalId = 0u;
	UINT8 functionId = EFUNC_OPENROUTESECTIONERRCHECK;
	UINT8 rcWorkMode = 0U;
	UINT8 cLocalCiType = 0U;  /*本控区类型*/

	rcWorkMode = GetLocalRcWorkMode();

	/* 联锁逻辑检查 */
	cLocalCiType = GetLocalCiType();
	if (CI_TYPE_CLD != cLocalCiType)
	{
		/*非车辆段，按CBTC既有逻辑处理*/
		if (RC_WORK_MODE_TIOC == rcWorkMode)
		{
			/* 进路始端信号机【未跨压】且内方第一逻辑区段【空闲】*/
			/*CBTC进路内方第一逻辑区段条件检查*/

			reResult = RouteCbtcFirstLgcSecCheck(routeId, &devId, &devState);
			if (CI_SUCCESS == reResult)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
		else if (RC_WORK_MODE_CI == rcWorkMode)
		{/*CI*/

			/* 进路始端信号机【未跨压】且内方第一逻辑区段【空闲】*/
			startSignalId = GetRouteStartSignalId(routeId);
			devId = GetRouteInFirstLogSecId(routeId);
			devState = GetLogSecCurOccupyState(devId);
			if ((GetSignalCrossState(startSignalId) == SIGNAL_CROSS_STATE_NO) &&
				(devState == SECTION_OCCUPY_NO))
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				reResult = CheckEngineerVehicleNear(routeId);/*检查是否是工程车接近的跨压*/
			}
		}
		else
		{
			reResult = CI_ERROR;/*模式错误返回失败*/
		}
	}
	else
	{
		/*车辆段，进路不可追踪，需检查进路内方区段空闲*/
		reResult = CLDKeepOpenSecCheck(routeId, functionId, ESEND_LEVEL_ZERO);
	}

	/* 进路内所有区段锁闭状态【正常锁闭】*/
	if (CI_SUCCESS == reResult)
	{

		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
	    ;
	}
/*使用新增的函数RouteIntruSecVainSPKSErrCheck*/
#if 0
	/*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#endif

#if 0
	/* 进路内所有区段【未设置跳跃锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#endif
	/* 进路内所有区段未被封锁 */
	if (checkResult == CI_SUCCESS)
	{
		checkResult = RouteSecFLockErrCheck(routeId);
		if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult))
		{
			reResult = checkResult;
		}
		else
		{
		    ;
		}
	}
	else
	{
	    ;
	}

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

/*
* 功能描述： 恢复列车进路，信号机联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*/
static UINT8 RecoverLTrainRouteSignalCheck(const UINT16 routeId)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

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

	/*进路内所有信号机【未封锁】*/
	checkResult = RouteSignalFLockCheck(routeId, &devId, &devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;

	}

	if (CI_SUCCESS == reResult)
	{
		/*进路的敌对条件不成立*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

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

/* 恢复点式办理进路信号机联锁条件检查 */
/*
* 功能描述： 点式进路信号机联锁条件检查
* 参数说明：
*            const UINT16 routeId,    进路号
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*/
static UINT8 RecoverBlocRouteSignalCheck(const UINT16 routeId)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

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

	checkResult = RouteSignalFLockCheck(routeId, &devId, &devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	if (CI_SUCCESS == reResult)
	{
		/*进路的敌对条件不成立*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;

		}
	}

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

/* 恢复办理进路侵限区段SPKS条件检查 */
/*
* 功能描述： 进路侵限无效检查
* 参数说明： 
*            UINT16 const routeId,    进路号
*            UINT16 *pDevId,    设备Id（返回）
*            UINT8 *pDevState,  设备状态（返回）
* 返回值  ： CI_ERROR   侵限
*            CI_SUCCESS 侵限不满足
			 CI_ROUTE_RECOVER_ERR:SPKS按下导致侵限，但是当SPKS恢复后可以重开信号
*/
static UINT8 RouteIntruSecVainSPKSErrCheck(const UINT16 routeId)
{
	/* 侵限区段 */
	UINT8 const checkSum = GetRouteIntrudePhySectionSum(routeId);
	RouteIntrudePhySectionStruct* const dataIdBuf = GetRouteIntrudePhySectionData(routeId);
	/* 局部变量定义初始化 */
	UINT16 i = 0U, j = 0U;           /* 循环变量 */
	UINT16 devId = 0U;
	UINT8 devState = 0U;
	UINT8 devFLockState = 0U;
	UINT8 intruSwitchSum = 0U;
	RouteConditionSwitchStruct* intruSwitchConStru = NULL;
	UINT16 intruSwitchId = 0U;
	UINT8 intruSwitchPos = 0U;
	UINT8 devLockState = 0U;
	UINT8 devJumpLockState = 0U;
	UINT8 intruSwitchPosValid = CI_ERROR;
	UINT8 reVal = CI_ERROR;
	UINT8 fLockType = PHY_SEC_FLOCK_TYPE_NONE;/*物理区段封锁类型变量*/
	UINT8 checkFlockFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_CHECKFLOCK_FLAG);
	UINT8 cFuncSwitchSpks = 0U; /*SPKS自动信号重开是否检查进路级别开关*/
	UINT8 cRouteLevel = 0U;
	UINT8 chPhySecLogLockState = 0U;/*物理区段逻辑锁闭状态*/

	/* 检查侵限状态 */
	if (NULL == dataIdBuf)
	{
		/*指针为空*/
		reVal = CI_ERROR;
	}
	else
	{
		/*开始检查*/
		reVal = CI_SUCCESS;/*先将返回值设置成功，若侵限成立则会修改函数返回值为CI_ERROR或CI_ROUTE_RECOVER_ERR*/
		cFuncSwitchSpks = GetCiFunctionSwitchConfig(FUNC_REPEATE_OPEN_CHECK_SPKS);
		cRouteLevel = GetRouteLevel(routeId);

		for (i = 0u; i < checkSum; i++)
		{
			devId = dataIdBuf[i].SectionId;
			devState = GetPhySecCurMergeState(devId);/*获取物理区段占用状态*/
			devFLockState = GetPhySecFLockState(devId);/*获取物理区段封锁状态*/
			fLockType = GetPhySecFLockType(devId);/*获取物理区段封锁类型*/
			devLockState = GetPhySecLockState(devId);
			devJumpLockState = GetPhySecJumpLockState(devId);
			chPhySecLogLockState = PhySecLogLockStateCheck(devId);



			/* 检查侵限区段是否占用或封锁*/
			if ((SECTION_OCCUPY_YES == devState)
				|| ((PHYSICAL_SECTION_FLOCK_YES == devFLockState) && (FUNC_SWITCH_ON != checkFlockFlag))
				|| (PHYSICAL_SECTION_LOCK_NO != devLockState)
				|| (PHYSICAL_SECTION_JUMP_LOCK_YES == devJumpLockState)
				|| (LOG_SECTION_LOGLOCK_NO != chPhySecLogLockState))
			{
				/*侵限区段占用或封锁*/
				intruSwitchSum = dataIdBuf[i].SwitchSum;
				if (intruSwitchSum > 0u)
				{
					/*侵限道岔位置检查*/
					intruSwitchPosValid = CI_ERROR;
					for (j = 0u; j < intruSwitchSum; j++)
					{
						intruSwitchConStru = &dataIdBuf[i].ConditionSwitchStru[j];
						intruSwitchId = intruSwitchConStru->SwitchId;
						intruSwitchPos = GetSwitchCurPosition(intruSwitchId);

						if ((intruSwitchPos == intruSwitchConStru->SwitchPosition) ||
							(SWITCH_POSITION_SIKAI == intruSwitchPos) || (SWITCH_POSITION_MOVE == intruSwitchPos)
							|| (SWITCH_POSITION_JICHA == intruSwitchPos))
						{
							intruSwitchPosValid = CI_ERROR;
						}
						else
						{
							/*道岔未侵限*/
							intruSwitchPosValid = CI_SUCCESS;
							break;
						}
					}

					if (CI_ERROR == intruSwitchPosValid)
					{
						/*有岔侵限条件成立*/
						if ((PHYSICAL_SECTION_JUMP_LOCK_YES != devJumpLockState) && (PHYSICAL_SECTION_LOCK_NO == devLockState) && (SECTION_OCCUPY_YES != devState)
							&& (PHYSICAL_SECTION_FLOCK_YES == devFLockState) && (PHY_SEC_FLOCK_TYPE_SPKS == fLockType) && (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState)
							&& ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == cRouteLevel))))
						{/*侵限区段未占用且封锁且是由于SPKS按下导致的封锁且(SPKS自动重开开关打开或关闭但进路为CBTC)，在SPKS恢复后可自动重开*/
							reVal = CI_ROUTE_RECOVER_ERR;
						}
						else
						{/*除区段SPKS按下侵限成立外的其他条件导致的侵限成立的场景，不可重开*/
							reVal = CI_ERROR;
						}
					}
				}
				else
				{
					if ((PHYSICAL_SECTION_JUMP_LOCK_YES != devJumpLockState) && (PHYSICAL_SECTION_LOCK_NO == devLockState) && (SECTION_OCCUPY_YES != devState)
						&& (PHYSICAL_SECTION_FLOCK_YES == devFLockState) && (PHY_SEC_FLOCK_TYPE_SPKS == fLockType) && (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState)
						&& ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == cRouteLevel))))
					{/*侵限区段未占用且封锁且是由于SPKS按下导致的封锁且(SPKS自动重开开关打开或关闭但进路为CBTC)，在SPKS恢复后可自动重开*/
						reVal = CI_ROUTE_RECOVER_ERR;
					}
					else
					{/*除区段SPKS按下侵限成立外的其他条件导致的侵限成立的场景，不可重开*/
						reVal = CI_ERROR;
					}
				}
				if (CI_ERROR == reVal)
				{/*除区段SPKS按下侵限成立外的其他条件导致的侵限成立的场景，不可重开，直接退出，不再判断其他侵限条件是否成立；
				 当reVal = CI_ROUTE_RECOVER_ERR;时，需继续判断其他侵限条件是否成立*/
					break;
				}
			}

		}
	}

	/*检查完毕*/
	return reVal;
}

/*
* 功能描述： 恢复办理进路照查条件满足检查
* 参数说明： UINT16 const routeId,  进路号
*            UINT8 functionId,      调用函数编号
*            UINT8 sendLevel,       故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*			 RELAY_STATE_WAITE
*/
static UINT8 RouteRelayZhaoChaErrCheck(UINT16 const routeId)
{
	/* 局部变量定义初始化 */
	UINT16 relayId = 0U;
	UINT8 relayState = 0U;
	UINT8 zcPhySecSum = 0U;                          /*照查物理区段数目*/
	UINT16* pZcPhySecIdBuf = NULL;                   /*照查物理区段ID数组*/
	UINT8 ii = 0U;
	UINT16 thisRealyId = 0U;
	UINT8 thisRelayState = 0U;
	UINT8 routeState = 0U;
	UINT8 retVal = CI_ERROR;                      /*函数返回值*/
	UINT16 pDevId = 0U;
	UINT8 pDevState = 0U;
	UINT8 chErrTemp = 0U;

	/* 对端照查检查 */
	zcPhySecSum = GetRouteThatZhaoChaPhySecSum(routeId);              /*获取照查物理区段数目*/
	pZcPhySecIdBuf = GetRouteThatZhaoChaPhySecIdBuf(routeId);       /*获取照查物理区段ID数组*/

	if (NULL == pZcPhySecIdBuf)
	{
		retVal = CI_ERROR;
	}
	else
	{
		retVal = CI_SUCCESS;

		for (ii = 0u; ii < zcPhySecSum; ii++)
		{
			retVal = RoutePhySecZhaoChaErrCheck(routeId, pZcPhySecIdBuf[ii]);
			if (CI_ERROR == retVal)
			{
				break;
			}
			else if (CI_ROUTE_RECOVER_ERR == retVal)		/*YF00083-1013,出现一个封锁即跳出，防止两个物理区段，一个封锁在前检查，一个未封锁在后检查覆盖掉retVal的值*/
			{
				chErrTemp++;		/*有一个SPKS封锁就计数一次*/
			}
			else
			{
				; /*不处理*/
			}

			if (0U < chErrTemp)
			{
				retVal = CI_ROUTE_RECOVER_ERR;			/*出现过一个SPKS封锁，就赋值返回值为SPKS封锁*/
			}
		}
	}

	if ((CI_SUCCESS == retVal) || (CI_ROUTE_RECOVER_ERR == retVal))
	{/*照查物理区段检查通过,检查本端照查继电器*/

		thisRealyId = GetRouteThisZhaoChaRelayId(routeId); /*本端照查继电器ID*/
		thisRelayState = GetRelayCollState(thisRealyId);   /*获取指定ID继电器的状态*/
		routeState = GetRouteState(routeId);               /*获取进路状态*/

		if (thisRealyId > 0u)
		{/*存在本端照查继电器*/
			if ((ROUTE_STATE_FIRST_LOCKERR == routeState) ||
				(ROUTE_STATE_YUXIAN_LOCK == routeState) ||
				(ROUTE_STATE_YUXIAN_OPEN == routeState) ||
				(ROUTE_STATE_NEAR_OPEN == routeState) ||
				(ROUTE_STATE_NEAR_LOCK == routeState) ||
				(ROUTE_STATE_NEAR_LOCKERR == routeState) ||
				(ROUTE_STATE_DELAY_UNLOCK == routeState) ||
				(ROUTE_STATE_AUTO_UNLOCK == routeState) ||
				(ROUTE_STATE_AUTO_UNLOCKERR == routeState) ||
				(ROUTE_STATE_HALF_UNLOCKDELAY == routeState) ||
				(ROUTE_STATE_LEAD_LOCKERR == routeState) ||
				(ROUTE_STATE_LEAD_OPEN == routeState))
			{
				/*需判断本端照查的状态*/
				if (RELAY_STATE_UP == thisRelayState)
				{
					retVal = CI_ERROR;
				}
			}
			else if ((ROUTE_STATE_FIRST_LOCK == routeState) ||
				(ROUTE_STATE_LEAD_LOCK == routeState))
			{
				if (RELAY_STATE_UP == thisRelayState)
				{
					/*等待，返回等待标志*/
					retVal = RELAY_STATE_WAITE;
				}
			}
			else
			{
				/*进路状态为其它值，此时不处理*/
			}
		}

	}

	if ((CI_SUCCESS == retVal) || (CI_ROUTE_RECOVER_ERR == retVal))
	{/*本端照查继电器检查通过，检查对端照查继电器*/

		relayId = GetRouteThatZhaoChaRelayId(routeId); /*对端照查继电器ID*/

		if (0u != relayId)
		{/*存在对端照查继电器*/

			relayState = GetRelayCollState(relayId);

			/* 照查吸起检查*/
			if (RELAY_STATE_UP == relayState)
			{
				/*检查通过*/
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
	}

	return retVal;
}

/*
* 功能描述： 恢复进路照查物理区段条件满足检查
* 参数说明： UINT16 const routeId   进路段号
*            UINT16 const phySecId  物理区段号
*            UINT16 *pDevId,    设备Id（返回）
*            UINT8 *pDevState,  设备状态（返回）
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 RoutePhySecZhaoChaErrCheck(UINT16 const routeId ,UINT16 const phySecId)
{
	UINT8 secFlockState = 0u;                         /*区段封锁状态*/
	UINT8 secLockState = 0u;                          /*区段锁闭状态*/
	UINT8 secLockedDirection = 0u;                    /*区段锁闭方向*/
	UINT8 routeDirection = 0u;                        /*进路方向*/
	UINT8 retVal = CI_ERROR;                         /*函数返回值*/
	UINT8 fLockType = PHY_SEC_FLOCK_TYPE_NONE;       /*物理区段封锁类型变量*/
	UINT8 phyBelongCi = 0u;                          /*物理区段所属联锁*/
	UINT8 commState = 0u;                            /*通信状态*/
	                                                 /*相邻联锁是否支持继电接口*/
	UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI);
	UINT8 localCi = GetSystemParaLocalCiId();        /*本机联锁*/
	UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*继电接口确认状态*/
	UINT8 cFuncSwitchSpks = 0U;  /*SPKS信号自动重开开关，0x55检查进路级别，0xaa不检查*/
	UINT8 cRouteLevel = 0U;

	if ((0U == routeId ) || (0U == phySecId))
	{
		retVal = CI_ERROR;
	}
	else
	{
		retVal = CI_SUCCESS;
		
		phyBelongCi = GetPhySecBelongCiId(phySecId);/*获取物理区段所属联锁*/

		routeDirection = GetRouteDirection(routeId);     /*获取进路方向*/

		commState = GetLocalCiAndOtherCiTransSta(phyBelongCi);/*本联锁与其它联锁通信通信状态*/

		if ((localCi!=phyBelongCi) && (TRANSMIT_STATE_BAD == commState) && 
			(CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&&
			(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface))
		{
			/*如果信号机所属联锁与本联锁不同，且本联锁与该联锁通信中断，且运营人员已下发确认继电接口命令，
				且已配置支持继电接口，则可以不检查该信号机封锁状态*/
			retVal = CI_SUCCESS;
		}
		else
		{ 
			secFlockState = GetPhySecFLockState(phySecId);    /*获取物理区段封锁状态*/
			if(PHYSICAL_SECTION_FLOCK_NO == secFlockState)
			{/*区段封锁状态:未封锁*/

				secLockState = GetPhySecLockState(phySecId);  /*获取物理区段锁闭状态*/

				if(PHYSICAL_SECTION_LOCK_NO == secLockState)
				{
					/*区段锁闭状态:未锁闭  本照查区段检查通过*/
				}
				else if((PHYSICAL_SECTION_LOCK_PROTECT  == secLockState)   || (PHYSICAL_SECTION_LOCK_NORMAL == secLockState) 
					|| (PHYSICAL_SECTION_LOCK_EXCEPT == secLockState)     || (PHYSICAL_SECTION_LOCK_DELAY == secLockState) 
					|| (PHYSICAL_SECTION_LOCK_FAULTDELAY == secLockState))
				{/*区段锁闭状态:防护锁闭 或 正常锁闭 或 异常锁闭 或 延时解锁 或 故障延时解锁，解决进路在延时解锁时照查指示灯突然亮灯的情况*/
					secLockedDirection = GetPhySecLockDirection(phySecId); /*获取锁闭方向*/
					if(routeDirection == secLockedDirection)
					{
						/*锁闭方向和进路方向一致，通过检查*/
					}
					else
					{
						/*锁闭方向和进路方向不一致，检查失败*/
						retVal = CI_ERROR;
					}
				}
				else
				{   /*区段锁闭状态:非法锁闭状态 检查失败*/
					retVal = CI_ERROR;
				}
			}
			else if (PHYSICAL_SECTION_FLOCK_YES == secFlockState)
			{
				fLockType = GetPhySecFLockType(phySecId);/*获得物理区段封锁类型*/
				cFuncSwitchSpks = GetCiFunctionSwitchConfig(FUNC_REPEATE_OPEN_CHECK_SPKS);
				cRouteLevel = GetRouteLevel(routeId);
				if ((PHY_SEC_FLOCK_TYPE_SPKS == fLockType) && ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == cRouteLevel))))
				{
					retVal = CI_ROUTE_RECOVER_ERR;  /* 状态如果SPKS导致的封锁且SPKS自动重开开关打开或关闭但进路为CBTC，则可以恢复重开*/
				}
				else
				{
					retVal = CI_ERROR;
				}
			}
			else
			{/*区段封锁状态:封锁  检查失败*/
				retVal = CI_ERROR;
			}
		}
	}

	return retVal;
}
