/********************************************************
*                                                                                                            
* 文 件 名： TradInterlockLogicProcess.c   
* 版权说明： 北京交控科技有限公司 
* 创建时间： 2011-05-06
* 作    者： 联锁组
* 功能描述： 联锁逻辑处理函数
* 修改记录：  2015.5.20 删除引导进路开放保持中其他联锁条件检查   引导进路不检查车库门等相关信息  张叶红 
*
********************************************************/ 


#include "TradInterlockLogicProcess.h"

/* C81 故障编码: EFUNC_CLD_SET_L_TRAIN_ROUTE */ 
/*
* 功能描述： 选排列车进路逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*/
UINT8 SetLTrainRouteP(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CLD_SET_L_TRAIN_ROUTE;
	/*故障发送级别*/
	UINT8 const sendLevel = ESEND_LEVEL_ATS;    /*发送ATS*/
/* 局部变量定义初始化 */
	UINT8 devState = 0U;                 /*设备状态*/
	UINT8 reResult = CI_ERROR;          /*返回值*/

/* 联锁条件检查 */

	devState = GetRouteState(routeId);
	/*进路状态空闲或初选或自动解锁异常（ARB且故障锁闭）*/
	if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_FIRST_XUANPAI == devState) || (ROUTE_STATE_AUTO_UNLOCKERR == devState))
	{
		/* 返回成功 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel);
		/* 失败返回 */
		reResult = CI_ERROR;
	}

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

	/*照查联锁条件检查*/
	if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel)))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

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

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

	return reResult;
}

/* C82 故障编码: EFUNC_CLD_SET_D_TRAIN_ROUTE */ 
/*
* 功能描述： 选排调车进路逻辑处理
* 参数说明： const UINT16 routeId, 进路ID
* 返回值  ：    
*/
UINT8 SetDTrainRouteP(const UINT16 routeId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_SET_D_TRAIN_ROUTE;

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

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

	UINT8 reVal = 0u;

/* 联锁条件检查 */
    devId = routeId;
    devState = GetRouteState(routeId);
	if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_FIRST_XUANPAI == devState))
	{ /*进路状态空闲或者选排*/
		reResult = CI_SUCCESS;
	}
	else
	{
        /* 记录故障码 */
        SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_STATE,devState,sendLevel);
        /* 失败返回 */
        reResult = CI_ERROR;
	}

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

    /*照查联锁条件检查*/
    if (CI_SUCCESS == reResult)
    { 
		reVal = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if(CI_SUCCESS != reVal)
		{
			 /* 失败返回 */
			 reResult = CI_ERROR;
		}   
    }

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

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

    return reResult;
}

/* C83 故障编码: EFUNC_CLD_SET_LEAD_ROUTE */ 
/*
* 功能描述： 选排引导进路逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ：    
*/
UINT8 SetLeadRouteP(const UINT16 routeId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_SET_LEAD_ROUTE;

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

        
/* 局部变量定义初始化 */
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT8 reResult = CI_SUCCESS;          /*返回值*/
	UINT8 cFuncSwitch = FUNC_SWITCH_ON;  /*引导进路是否检查防淹门开关*/

/* 联锁条件检查 */
    devId = routeId;
    devState = GetRouteState(routeId);
	if (devState != ROUTE_STATE_IDLE)
	{ /*进路状态不空闲*/

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

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

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

    /*照查联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }

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

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

	if (CI_SUCCESS == reResult)
	{
		/*防淹门联锁条件检查*/
		cFuncSwitch = GetCiFunctionSwitchConfig(FUNC_LEADROUTE_FLOODGATE_CHECK);

		if (FUNC_SWITCH_OFF == cFuncSwitch)
		{
			/*引导进路办理不检查防淹门状态*/
		}
		else
		{
			/*引导进路办理检查防淹门状态*/
			reResult = BlocRouteFloodGateCheck(routeId, functionId, sendLevel);
		}
	}

    return reResult;
}

/* C84 故障编码: EFUNC_CLD_SET_D_LONG_ROUTE */
/*
* 功能描述： 选排长调车进路逻辑处理
* 参数说明： UINT16 longRouteId, 进路ID
* 返回值  ：
*/
UINT8 SetLongDTrainRouteP(const UINT16 longRouteId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_SET_D_LONG_ROUTE;
    
/*故障发送级别*/
    UINT8 const sendLevel = ESEND_LEVEL_ATS;    /*发送ATS*/
    UINT8 reResult = CI_SUCCESS;          /*返回值*/
    
/* 局部变量定义初始化 */
    UINT16 devId = 0u; /*设备ID*/
    UINT8 devState = 0u; /*设备状态*/
    UINT8 subRouteSum = 0u; /*子进路数目*/
    UINT16* pSubRouteIdBuf = NULL; /*子进路ID数组*/
    UINT8 ii = 0u;
    UINT8 routeType = 0u;
/* 联锁条件检查 */
    subRouteSum = GetLongRouteSubRouteSum(longRouteId); /*子进路数量*/
	pSubRouteIdBuf = GetLongRouteSubRouteIdBuf(longRouteId); /*子进路号*/

    devId = longRouteId;
    devState = GetLongRouteState(longRouteId);
	if (devState != ROUTE_LONG_STATE_IDLE)
	{ /*进路不空闲*/

		/* 记录故障码 */
        SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_STATE,devState,sendLevel);
		reResult = CI_ERROR;
	}
	if (CI_SUCCESS == reResult)
	{
        for (ii = 0u; ii < subRouteSum; ii++)
        {
            if (ii == 0u)
            {
                routeType = GetRouteType(pSubRouteIdBuf[ii]);
                if(ROUTE_TYPE_DIAOCHE == routeType)     /*组合调车进路*/
                {
                    /*最后一条进路按照调车进路检查条件办理*/
                    if (CI_ERROR == SetDTrainRouteP(pSubRouteIdBuf[ii]))
                    { /*长调进路选排检查失败*/

                        reResult = CI_ERROR;
                    }
                }
                else      /*组合列车进路*/
                {
                    /*按照列车进路检查条件办理*/
                    if (CI_ERROR == SetLTrainRouteP(pSubRouteIdBuf[ii]))
                    { /*长调进路选排检查失败*/

                        reResult = CI_ERROR;
                    }
                }

            }
            else
            {
                /*其他进路按照列车进路检查条件办理*/
                if (CI_ERROR == SetLTrainRouteP(pSubRouteIdBuf[ii]))
                { /*长调进路选排检查失败*/

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

	return reResult;
}


/* C85 故障编码: EFUNC_CLD_LOCK_L_TRAIN_ROUTE */
/*
* 功能描述： 锁闭列车进路逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ：    
*/
UINT8 LockLTrainRouteP(const UINT16 routeId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_LOCK_L_TRAIN_ROUTE;
    
/*故障发送级别*/
    UINT8 sendLevel = ESEND_LEVEL_ZERO;    /*不发送ATS*/
    
	UINT32 routeXuanPaiStartCycNum = 0u;
	UINT32 dwSystemParaRouteXuanPaiCyc = 0u;
    
/* 局部变量定义初始化 */
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT8 reResult = CI_SUCCESS;          /*返回值*/    
	UINT8 reVal = 0u;
	UINT8 cAutoStateFlag = CI_ERROR;

	cAutoStateFlag = AutoSignalOrRouteValid(routeId);  /*获取自动属性*/
	if (cAutoStateFlag == CI_SUCCESS)
	{
		/*自动进路或自动信号不发送ATS*/
		sendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		sendLevel = ESEND_LEVEL_ATS;
	}
    
/* 联锁条件检查 */
	devId = routeId;
	routeXuanPaiStartCycNum = GetRouteXuanPaiStartCycNum(routeId);
	dwSystemParaRouteXuanPaiCyc = GetSystemParaRouteXuanPaiCyc();
	devState = SystemOverTimeCheck(routeXuanPaiStartCycNum,dwSystemParaRouteXuanPaiCyc);
	if(CI_TIME_OUT == devState)
	{ /*选排超时*/
    
		/* 记录故障码 */
		SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_XUANPAI_OVERTIME,devState,sendLevel); 
    
		reResult = CI_ERROR;
	}

    /*信号联锁条件检查*/
    if (CI_SUCCESS == reResult)
    {
		reVal =  /*SetLTrainRouteSignalCheck*/SetBlocRouteSignalCheck(routeId,functionId,sendLevel);
		if(CI_ERROR ==reVal)
		{ 
			/* 失败返回 */
           reResult = CI_ERROR;
		}
       
    }
    
    /*照查联锁条件检查*/
    if (CI_SUCCESS == reResult)
    {
		reVal =  RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if(CI_SUCCESS != reVal)
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
       
    }
    
    /*区段联锁条件检查*/
    if (CI_SUCCESS == reResult)
    { 
		reVal = LockLTrainRouteSectionCheck(routeId,functionId,sendLevel);
		if(CI_ERROR == reVal)
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
    }
    
    /*道岔联锁条件检查*/
    if (CI_SUCCESS == reResult)
    {
		reVal = SetLTrainRouteSwitchCheck(routeId,functionId,sendLevel);
		if(CI_SUCCESS == reVal)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = reVal;
		}
    }
	if (CI_SUCCESS == reResult)
	{
		/*侵限区段侵限条件不满足检查*/
		devId = 0u;
		devState = 0u;
		reVal = RouteIntruSecVainCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == reVal)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 选排之前不再检查侵限*/
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}  
	return reResult;
}

/* C86 故障编码: EFUNC_CLD_LOCK_D_TRAIN_ROUTE */
/*
* 功能描述： 锁闭调车进路逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ：    
*/
UINT8 LockDTrainRouteP(const UINT16 routeId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_LOCK_D_TRAIN_ROUTE;
/*故障发送级别*/
    UINT8 sendLevel = ESEND_LEVEL_ZERO;    /*不发送ATS*/
/* 局部变量定义初始化 */
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT8 reResult = CI_SUCCESS;          /*返回值*/ 
	UINT32 routeXuanPaiStartCycNum = 0u;
	UINT32 dwSystemParaRouteXuanPaiCyc = 0u;
	UINT8 checkResult = CI_ERROR;       /*检查结果*/
	UINT8 cAutoStateFlag = CI_ERROR;

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

/* 联锁条件检查 */
	devId = routeId;
	routeXuanPaiStartCycNum = GetRouteXuanPaiStartCycNum(routeId);
	dwSystemParaRouteXuanPaiCyc = GetSystemParaRouteXuanPaiCyc();
	devState = SystemOverTimeCheck(routeXuanPaiStartCycNum, dwSystemParaRouteXuanPaiCyc);

	if(CI_TIME_OUT == devState)
	{ /*选排超时*/
    
		/* 记录故障码 */
		SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_XUANPAI_OVERTIME,devState,sendLevel); 
    
		reResult = CI_ERROR;
	}
    
    
    /*信号联锁条件检查*/
    if (CI_SUCCESS == reResult)
	{
		checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
    }
    
    /*照查联锁条件检查*/
    if (CI_SUCCESS == reResult)
    {
		checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
    }
    
    /*区段联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = LockDTrainRouteSectionCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    
    /*道岔联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		/* 道岔联锁条件检查 */
		checkResult = SetLTrainRouteSwitchCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = checkResult;

		}
	}
	if (CI_SUCCESS == reResult)
	{
		/*侵限区段侵限条件不满足检查*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 选排之前不再检查侵限*/
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	return reResult;
}

/* C87 故障编码: EFUNC_CLD_LOCK_LEAD_ROUTE */
/*
* 功能描述： 锁闭引导进路逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ：    
*/
UINT8 LockLeadTrainRouteP(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CLD_LOCK_LEAD_ROUTE;
	/*故障发送级别*/
	UINT8 sendLevel = ESEND_LEVEL_ZERO;    /*不发送ATS*/
/* 局部变量定义初始化 */
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 reResult = CI_SUCCESS;
	UINT8 cAutoStateFlag = CI_ERROR;
	UINT8 chCheckResult = CI_ERROR;
	UINT32 dwXuanPaiStartCycNum = 0U;/*进路选排起始周期*/
	UINT32 dwParaRouteXuanPaiCyc = 0U;/*进路选排超限周期数*/

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

	/* 联锁条件检查 */
	devId = routeId;
	dwXuanPaiStartCycNum = GetRouteXuanPaiStartCycNum(routeId);
	dwParaRouteXuanPaiCyc = GetSystemParaRouteXuanPaiCyc();

	devState = SystemOverTimeCheck(dwXuanPaiStartCycNum, dwParaRouteXuanPaiCyc);
	if (CI_TIME_OUT == devState)
	{ /*选排超时*/

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

		reResult = CI_ERROR;
	}

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

	/*照查联锁条件检查*/
	chCheckResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
	if ((CI_SUCCESS == reResult) && (CI_SUCCESS != chCheckResult))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

	/*区段联锁条件检查*/
	chCheckResult = LockLeadRouteSectionC(routeId, functionId, sendLevel);
	if ((CI_SUCCESS == reResult) && (CI_ERROR == chCheckResult))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

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

	/*道岔联锁条件检查*/

	if (CI_SUCCESS == reResult)
	{
		chCheckResult = SetLTrainRouteSwitchCheck(routeId, functionId, sendLevel);
		if (CI_ERROR == chCheckResult)
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
		else
		{
			reResult = chCheckResult;
		}
	}
	return reResult;
}

/* C88 故障编码: EFUNC_CLD_LEAD_TRAIN_ROUTE */
/*
* 功能描述： 锁闭长调车进路逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ：
*/
UINT8 LockLongDTrainRouteP(const UINT16 longRouteId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_SET_D_LONG_ROUTE;
    
/*故障发送级别*/
    UINT8 const sendLevel = ESEND_LEVEL_ZERO;    /*不发送ATS*/
    
    
/* 局部变量定义初始化 */
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT8 subRouteSum = 0u; /*子进路数目*/
    UINT16* pSubRouteIdBuf = NULL; /*子进路ID数组*/
    UINT8 ii = 0u;
    UINT8 reResult = CI_SUCCESS;
    UINT8 routeType = 0u;       /*进路类型*/
/* 联锁条件检查 */
    subRouteSum = GetLongRouteSubRouteSum(longRouteId); /*子进路数量*/
	pSubRouteIdBuf = GetLongRouteSubRouteIdBuf(longRouteId); /*子进路号*/

    devId = longRouteId;
    devState = GetLongRouteState(longRouteId);
	if (devState != ROUTE_LONG_STATE_XUANPAI)
	{ /*进路不为选排*/

        /* 记录故障码 */
        SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_STATE,devState,sendLevel);
	    reResult = CI_ERROR;
	}
	if (CI_SUCCESS == reResult)
	{
		devState = SystemOverTimeCheck(GetLongRouteXuanPaiStartCycNum(longRouteId),GetSystemParaZuheRXuanPaiCnt());
		if(CI_TIME_OUT == devState)
		{ /*选排超时*/
	        
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_XUANPAI_OVERTIME,devState,sendLevel); 
	        
			reResult = CI_ERROR;
		}
	}

    if (CI_SUCCESS == reResult)
    {

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

            if (ii == 0u)
            {
                routeType = GetRouteType(pSubRouteIdBuf[ii]);    /*判断该组合进路为组合列车还是组合调车*/
                if (ROUTE_TYPE_LIECHE == routeType)
                {
                    /*按照列车进路检查条件办理*/
                    if (CI_ERROR == LockLTrainRouteP(pSubRouteIdBuf[ii]))
                    { /*长调进路选排检查失败*/

                        reResult = CI_ERROR;
                    }
                }
                else
                {
                    /*最后一条进路按照调车进路检查条件办理*/
                    if (CI_ERROR == LockDTrainRouteP(pSubRouteIdBuf[ii]))
                    { /*长调进路选排检查失败*/

                        reResult = CI_ERROR;
                    }
                }

            }
            else
            {
                /*其他进路按照列车进路检查条件办理*/
                if (CI_ERROR == LockLTrainRouteP(pSubRouteIdBuf[ii]))
                { /*长调进路选排检查失败*/

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

    return reResult;
}


/* C89 故障编码: EFUNC_CLD_OPEN_L_TRAIN_ROUTE */
/*
* 功能描述： 开放列车进路信号逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ：    
*/
UINT8 OpenLTrainRouteP(const UINT16 routeId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_OPEN_L_TRAIN_ROUTE;
    
/*故障发送级别*/
    UINT8 const sendLevel = ESEND_LEVEL_ATS;    /*发送ATS*/
    
    
/* 局部变量定义初始化 */
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT8 checkResult = CI_ERROR;
	UINT8 reResult = CI_ERROR;
    
/* 联锁条件检查 */
/*有总取消或总人解*/
	

		if ((ROUTE_ZONGQUXIAO_SET_YES == GetRouteZongQuXiaoFlag(routeId)) ||
			(ROUTE_ZONGRENJIE_SET_YES == GetRouteZongRenJieFlag(routeId)))
		{ 

			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel);

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

	if(CI_SUCCESS == reResult)
	{
		devId = routeId;
		devState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId),GetSystemParaRouteOpenSigCyc());
		if(CI_TIME_OUT == devState)
		{ /*开放超时*/
			devId = GetRouteStartSignalId(routeId);/*获取进路始端信号机ID*/
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_OPEN_OVERTIME,devState,ESEND_LEVEL_ATS); 

			reResult = CI_ERROR;
		}
		else
		{
		}
	}
	else
	{
	}
    
    /*信号联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenLTrainRouteSignalCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
	else
	{
	}
    
    /*照查联锁条件检查*/
#if 0
    if ((reResult == CI_SUCCESS) &&(CI_ERROR == RouteRelayZhaoChaCheck(routeId, functionId, sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
#endif
	if (CI_SUCCESS == reResult)
	{
		checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{/*等待驱动将照查驱落和检查成功*/
			reResult = checkResult;
		}
	}
	else
	{
	}
    
    /*区段联锁条件检查*/
    if ((CI_SUCCESS == reResult) &&(CI_ERROR == OpenLTrainRouteSectionCheck(routeId,functionId,sendLevel)))
    { 
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    else
	{
	}
    /*道岔联锁条件检查*/
    if ((CI_SUCCESS == reResult) &&(CI_ERROR == OpenLTrainRouteSwitchCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    else
	{
	}
	/* 防护进路联锁条件检查 */
	if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel)))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}
	/*其他信号机联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = checkResult;
		}
	}
	else
	{
	}
	/* 其他联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		checkResult = OtherCiValidCheck(routeId, functionId, sendLevel);
		if (checkResult == CI_SUCCESS)
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}
	return reResult;
}

/* C90 故障编码: EFUNC_CLD_OPEN_D_TRAIN_ROUTE */
/*
* 功能描述： 开放调车进路信号逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ：    
*/
UINT8 OpenDTrainRouteP(const UINT16 routeId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_OPEN_D_TRAIN_ROUTE;
    
/*故障发送级别*/
    UINT8 const sendLevel = ESEND_LEVEL_ATS;    /*发送ATS*/
    
    
/* 局部变量定义初始化 */
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT8 reResult = CI_SUCCESS;
	UINT8 checkResult = CI_ERROR;		/*进路照查满足条件检查结果，20150616*/
    
/* 联锁条件检查 */
    /*有总取消或总人解*/
    if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) ||
        (GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES))
    { 
        
        /* 记录故障码 */
        SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel);

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

	if(CI_SUCCESS == reResult)
	{
		devId = routeId;
		devState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId),GetSystemParaRouteOpenSigCyc());
		if(CI_TIME_OUT == devState)
		{ /*开放超时*/
			devId = GetRouteStartSignalId(routeId);/*获取进路始端信号机ID*/
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_OPEN_OVERTIME,devState,ESEND_LEVEL_ATS); 

			reResult = CI_ERROR;
		}
	}
    
    /*信号联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenLTrainRouteSignalCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
    /*照查联锁条件检查*/
#if 0
    if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
#endif
	if (CI_SUCCESS == reResult)
	{
		checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/*等待驱动将照查驱落和检查成功*/
			reResult = checkResult;
		}
	}
    
    /*区段联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenDTrainRouteSectionCheck(routeId,functionId,sendLevel)))
    { 
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
    /*道岔联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenLTrainRouteSwitchCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
	/* 其他联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{		
		if (CI_SUCCESS == OtherCiValidCheck(routeId,functionId,sendLevel))
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}
    /*其他信号机联锁条件检查*/
    if (CI_SUCCESS == reResult)
    {
		checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = checkResult;
		}
    }

	if (CI_SUCCESS == reResult)
	{/*只有前面条件都满足，才检查调车同意联锁条件*/
		/*这个reResult为CI_SUCCESS、RETURN_DCTY_NOT_SATISIFY*/
		reResult = DRouteDCTYCheck(routeId, functionId, sendLevel);
	}
    return reResult;
}

/* C91 故障编码: EFUNC_CLD_OPEN_LEAD_ROUTE */
/*
* 功能描述： 开放引导进路信号逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ：    
*/
UINT8 OpenLeadRouteP(const UINT16 routeId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_OPEN_LEAD_ROUTE;
    
/*故障发送级别*/
    UINT8 const sendLevel = ESEND_LEVEL_ATS;    /*发送ATS*/
    
    
/* 局部变量定义初始化 */
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT8 reResult = CI_SUCCESS;
    
/* 联锁条件检查 */
    /*有总取消或总人解*/
    if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) ||
        (GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES))
    { 
        
        /* 记录故障码 */
        SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel);

        /* 失败返回 */
        reResult = CI_ERROR;
    }
	if(reResult == CI_SUCCESS)
	{
		devId = routeId;
		devState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId),GetSystemParaRouteOpenSigCyc());
		if(CI_TIME_OUT == devState)
		{ /*开放超时*/
			devId = GetRouteStartSignalId(routeId);/*获取进路始端信号机ID*/
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_OPEN_OVERTIME,devState,ESEND_LEVEL_ATS); 

			reResult = CI_ERROR;
		}
	}
    
    /*信号联锁条件检查*/
    if ((reResult == CI_SUCCESS) &&(CI_ERROR == OpenLTrainRouteSignalCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
    /*照查联锁条件检查*/
    if (reResult == CI_SUCCESS) 
    {
        /* 失败返回 */
        reResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
    }
	    
    /*区段联锁条件检查*/
    if ((reResult == CI_SUCCESS) &&(CI_ERROR == OpenLeadRouteSectionC(routeId,functionId,sendLevel)))
    { 
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
    /*道岔联锁条件检查*/
    if ((reResult == CI_SUCCESS) && (CI_ERROR == OpenLTrainRouteSwitchCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
	/*其他信号机联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		reResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel);

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

	}
    return reResult;
}


/* C92 故障编码: EFUNC_CLD_KEEP_L_TRAIN_ROUTE */
/*
* 功能描述： 保持开放列车进路信号逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ：    
*/
UINT8 KeepLTrainRouteP(const UINT16 routeId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_KEEP_L_TRAIN_ROUTE;
    
/*故障发送级别*/
    UINT8 const sendLevel = ESEND_LEVEL_ATS;    /*发送ATS*/
    
    
/* 局部变量定义初始化 */
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT8 reResult = CI_SUCCESS;
    
/* 联锁条件检查 */
    /*有总取消或总人解*/
    if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) ||
        (GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES))
    { 
        
        /* 记录故障码 */
        SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel);

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

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

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

			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    
    /*信号联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepLTrainRouteSignalCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
    /*照查联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
    /*区段联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepOpenLTrainRouteSectionCheck(routeId,functionId,sendLevel)))
    { 
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
    /*道岔联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepRouteSwitchCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
	/* 其他联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{		
		if (CI_SUCCESS == OtherCiValidCheck(routeId,functionId,sendLevel))
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}
    /*其他信号机联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepBlocRouteOtherSignalCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult =  CI_ERROR;
    }
	/* 防护进路联锁条件检查 */

	if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel)))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}
	return reResult;
}

/* C93 故障编码: EFUNC_CLD_KEEP_D_TRAIN_ROUTE */
/*
* 功能描述： 保持开放调车进路信号逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ：    
*/
UINT8 KeepDTrainRouteP(const UINT16 routeId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_KEEP_D_TRAIN_ROUTE;
    
/*故障发送级别*/
    UINT8 const sendLevel = ESEND_LEVEL_ATS;    /*发送ATS*/
    
    
/* 局部变量定义初始化 */
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT8 reResult = CI_SUCCESS;
    
/* 联锁条件检查 */
    /*有总取消或总人解*/
    if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) ||
        (GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES))
    { 
        
        /* 记录故障码 */
        SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel);

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

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

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

			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    
    /*信号联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepLTrainRouteSignalCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
    /*照查联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel)))
    {
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
    /*区段联锁条件检查*/
    if ((CI_SUCCESS == reResult) &&(CI_ERROR == KeepDTrainRouteSectionCheck(routeId,functionId,sendLevel)))
    { 
        /* 失败返回 */
        reResult = CI_ERROR;
    }
    
    /*道岔联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepRouteSwitchCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult =  CI_ERROR;
    }
    
	/* 其他联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{		
		if (CI_SUCCESS == OtherCiValidCheck(routeId,functionId,sendLevel))
		{
			reResult = CI_SUCCESS;
		}
		else
		{
			reResult = CI_ERROR;
		}
	}
    /*其他信号机联锁条件检查*/
    if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepBlocRouteOtherSignalCheck(routeId,functionId,sendLevel)))
    {
        /* 失败返回 */
        reResult =  CI_ERROR;
    }

	if (CI_SUCCESS == reResult)
	{/*只有前面条件都满足，才检查调车同意联锁条件*/
		/*这个reResult为CI_SUCCESS、RETURN_DCTY_NOT_SATISIFY*/
		reResult = DRouteDCTYCheck(routeId, functionId, sendLevel);
	}

    return reResult;
}

/* C94 故障编码: EFUNC_CLD_KEEP_LEAD_ROUTE */
/*
* 功能描述： 保持引导进路逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ： CI_ERROR 失败   
*            CI_SUCCESS 成功
*/
UINT8 KeepLeadRouteP(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CLD_KEEP_LEAD_ROUTE;

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


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

	/* 联锁条件检查 */
	/*有总取消或总人解*/
	if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) ||
		(GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES))
	{ 

		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel);

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

	/*进路状态【引导开放】*/
	if(CI_SUCCESS == reResult)
	{
		devId = routeId;
		devState = GetRouteState(devId);
		if (devState != ROUTE_STATE_LEAD_OPEN)
		{ 

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

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

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

	/*照查联锁条件检查*/
	if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel)))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}

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

	/*道岔联锁条件检查*/
	if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepRouteSwitchCheck(routeId,functionId,sendLevel)))
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}
	/*保持引导进路信号区段占用联锁条件检查*/
	if(CI_SUCCESS == reResult) 
	{
		reResult = KeepLeadSecOccCheck(routeId);
	}
	/*其他信号机联锁条件检查*/
	if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepBlocRouteOtherSignalCheck(routeId,functionId,sendLevel)))
	{
		/* 失败返回 */
		reResult =  CI_ERROR;
	}
	/* 其他联锁条件检查 */
	if (CI_SUCCESS == reResult)
	{
		reResult = OtherCiValidCheck(routeId,functionId,sendLevel);

	}
	return reResult;
}


/* C95 故障编码: EFUNC_CLD_SET_NONROUTE */
/*
* 功能描述： 选排非进路调车逻辑处理
* 参数说明： UINT8 nonRouteId，非进路ID
* 返回值  ：0 办理失败
*			1 办理成功
*/
UINT8 SetNonRouteP(UINT8 nonRouteId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CLD_SET_NONROUTE;

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


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

	/* 联锁条件检查 */
	devState = GetNonRouteStateById(nonRouteId);
	if (devState != NONROUTE_STATE_IDLE)
	{ /*非进路状态不空闲*/

		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_NONROUTE, nonRouteId, ETYPE_ROUTE_STATE, devState,sendLevel);

		reResult = CI_ERROR;
	}
	else
	{
		reResult = CI_SUCCESS;
	}
	
	if (CI_SUCCESS == reResult)
	{ /*信号机断丝*/

		reResult = CheckNonRouteSignalNoBreak(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*信号机封锁*/

		reResult = CheckNonRouteSignalFengSuo(nonRouteId,functionId,sendLevel);
	}

	if(CI_SUCCESS == reResult)
	{ /*敌对信号成立*/

		reResult = CheckNonRouteEnemySignal(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路区段征用*/

		reResult = CheckNonRoutePhySecUsing(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路区段占用空闲错误*/

		reResult = CheckNonRoutePhySectionOccupy(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路区段锁闭*/

		reResult = CheckNonRoutePhySectionUnLock(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路道岔引导总锁*/

		reResult = CheckNonRouteSwitchYinSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{/*检查非进路内所有区段【未封锁】*/
		reResult = CheckNonRoutePhysecFengSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路道岔封锁*/

		reResult = CheckNonRouteSwitchFengSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路防护道岔封锁*/

		reResult = CheckNonRouteRelProSwiFengSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路道岔【位置正确】或【不正确但可动作】*/

		reResult = NonRouteSwitchPosMovValCheck(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路关联防护道岔引导总锁*/

		reResult = CheckNonRouteRelProSwiYinSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路关联防护道岔位置不正确且不可动作*/

		reResult = NonRouteRelProSwiPosMovValCheck(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{/*侵限区段侵限条件不满足检查*/
		reResult = NonRouteIntruSecVainCheck(nonRouteId,functionId,sendLevel);
	}

	

	return reResult;
}

/* C96 故障编码: EFUNC_CLD_LOCK_NONROUTE */
/*
* 功能描述： 锁闭非进路调车逻辑处理
* 参数说明： UINT8 nonRouteId，非进路ID
* 返回值  ：    
*/
UINT8 LockNonRouteP(UINT8 nonRouteId)
{	
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CLD_LOCK_NONROUTE;

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

	/* 局部变量定义初始化 */
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 reResult = CI_SUCCESS;

	/* 联锁条件检查 */
	devState = GetNonRouteStateById(nonRouteId);
	if (devState != NONROUTE_STATE_XUANPAI)
	{ /*非进路状态不选排*/

	/* 记录故障码 */
	SetErrorData(functionId, CI_DEVICE_TYPE_NONROUTE, nonRouteId, ETYPE_ROUTE_STATE, devState,sendLevel);

	reResult = CI_ERROR;
	}
	if (CI_SUCCESS == reResult)
	{    
		devState = SystemOverTimeCheck(GetNonRouteXuanPaiStartCycById(nonRouteId),GetSystemParaNonRouteXuanPaiCnt());
		if(CI_TIME_OUT == devState)
		{ /*选排超时*/

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

			reResult = CI_ERROR;
		}
	}


	if (CI_SUCCESS == reResult)
	{ /*信号机断丝*/

		reResult = CheckNonRouteSignalNoBreak(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*信号机封锁*/

		reResult = CheckNonRouteSignalFengSuo(nonRouteId,functionId,sendLevel);
	}

	if(CI_SUCCESS == reResult)
	{ /*敌对信号成立*/

		reResult = CheckNonRouteEnemySignal(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路区段占用空闲错误*/

		reResult = CheckNonRoutePhySectionOccupy(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路区段锁闭*/

		reResult = CheckNonRoutePhySectionUnLock(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路道岔引导总锁*/

		reResult = CheckNonRouteSwitchYinSuo(nonRouteId,functionId,sendLevel);
	}

	
	if (CI_SUCCESS == reResult)
	{/*检查非进路内所有区段【未封锁】*/
		reResult = CheckNonRoutePhysecFengSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路道岔封锁*/

		reResult = CheckNonRouteSwitchFengSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路防护道岔封锁*/

		reResult = CheckNonRouteRelProSwiFengSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路道岔位置不正确且不可动作*/

		reResult = NonRouteSwitchPosMovValCheck(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路关联防护道岔引导总锁*/

		reResult = CheckNonRouteRelProSwiYinSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路关联防护道岔位置不正确且不可动作*/

		reResult = NonRouteRelProSwiPosMovValCheck(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{/*侵限区段侵限条件不满足检查*/
		reResult = NonRouteIntruSecVainCheck(nonRouteId,functionId,sendLevel);
	}

	

	return reResult;
}

/* C97 故障编码: EFUNC_CLD_OPEN_NONROUTE */
/*
* 功能描述： 开放非进路调车逻辑处理
* 参数说明： UINT8 nonRouteId，非进路ID
* 返回值  ：    0 返回失败
*			   1 返回成功
*/
UINT8 OpenNonRouteP(UINT8 nonRouteId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CLD_OPEN_NONROUTE;

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


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

	/* 联锁条件检查 */

	devState = GetNonRouteCancelFlagById(nonRouteId);
	if (NONROUTE_CANCEL_FLAG_YES == devState)
	{ /*取消标志有效*/

		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_NONROUTE, nonRouteId, ETYPE_ROUTE_CANCEL, devState,sendLevel);

		reResult = CI_ERROR;
	}
	else
	{
		reResult = CI_SUCCESS;
	}

	if (CI_SUCCESS == reResult) 
	{
		devState = SystemOverTimeCheck(GetNonRouteSigOpenStartCycById(nonRouteId),GetSystemParaRouteOpenSigCyc());
		if(CI_TIME_OUT == devState)
		{ /*开放超时*/

			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_NONROUTE,nonRouteId,ETYPE_SIG_OPEN_OVERTIME,devState,ESEND_LEVEL_ATS); 

			reResult = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reResult)
	{ /*信号机断丝*/

		reResult = CheckNonRouteSignalNoBreak(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*信号机封锁*/

		reResult = CheckNonRouteSignalFengSuo(nonRouteId,functionId,sendLevel);
	}

	if(CI_SUCCESS == reResult)
	{ /*敌对信号成立*/

		reResult = CheckNonRouteEnemySignal(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路区段占用空闲错误*/

		reResult = CheckNonRoutePhySectionOccupy(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路区段未锁闭*/

		reResult = CheckNonRoutePhySectionLock(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{/*检查非进路内所有区段【未封锁】*/
		reResult = CheckNonRoutePhysecFengSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路道岔封锁*/

		reResult =  CheckNonRouteSwitchFengSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路防护道岔封锁*/

		reResult =  CheckNonRouteRelProSwiFengSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路道岔、防护道岔位置*/

		reResult =  CheckNonRouteSwitchPosRight(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{ /*非进路关联道岔防护锁闭*/

		reResult =  CheckNonRouteRelProSwiLockSta(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == reResult)
	{/*侵限区段侵限条件不满足检查*/
		reResult = NonRouteIntruSecVainCheck(nonRouteId,functionId,sendLevel);
	}

	
	return reResult;
}

/* C98 故障编码: EFUNC_CLD_KEEP_NONROUTE */
/*
* 功能描述： 保持开放非进路调车逻辑处理
* 参数说明： UINT8 nonRouteId，非进路ID
* 返回值  ：  0 失败
*			  1 成功
*/
UINT8 KeepOpenNonRouteP(UINT8 nonRouteId)
{	
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CLD_KEEP_NONROUTE;

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

	/* 局部变量定义初始化 */
	UINT8 flagCancelNonRoute = 0u;/*取消标志*/
	UINT8 chkResult = CI_ERROR;/*检查结果*/

	/* 联锁条件检查 */
	flagCancelNonRoute = GetNonRouteCancelFlagById(nonRouteId);
	if (NONROUTE_CANCEL_FLAG_YES == flagCancelNonRoute)
	{ /*取消标志有效*/

		/* 记录故障码 */
		SetErrorData(functionId, CI_DEVICE_TYPE_NONROUTE, nonRouteId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel);

		chkResult = CI_ERROR;
	}
	else
	{/*取消标志无效，检查通过*/
		chkResult = CI_SUCCESS;
	}

	
	if (CI_SUCCESS == chkResult)
	{ /*有信号机之前周期驱动关闭*/

		chkResult = CheckNonRouteSignalPreDrvOpen(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == chkResult)
	{ /*信号机封锁*/

		chkResult = CheckNonRouteSignalFengSuo(nonRouteId,functionId,sendLevel);
	}

	if(CI_SUCCESS == chkResult)
	{ /*敌对信号成立*/

		chkResult = CheckNonRouteEnemySignal(nonRouteId,functionId,sendLevel);
	}

	
	if (CI_SUCCESS == chkResult)
	{ /*非进路区段未锁闭*/

		chkResult = CheckNonRoutePhySectionLock(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == chkResult)
	{/*检查非进路内所有区段【未封锁】*/
		chkResult = CheckNonRoutePhysecFengSuo(nonRouteId,functionId,sendLevel);
	}
	
	if (CI_SUCCESS == chkResult)
	{ /*非进路道岔封锁*/

		chkResult = CheckNonRouteSwitchFengSuo(nonRouteId,functionId,sendLevel);
	}

	if (CI_SUCCESS == chkResult)
	{ /*非进路防护道岔封锁*/

		chkResult = CheckNonRouteRelProSwiFengSuo(nonRouteId,functionId,sendLevel);
	}

	
	if (CI_SUCCESS == chkResult)
	{ /*非进路道岔、防护道岔位置*/

		chkResult = CheckNonRouteSwitchPosRight(nonRouteId,functionId,sendLevel);
	}

	
	if (CI_SUCCESS == chkResult)
	{ /*非进路关联道岔防护锁闭*/

		chkResult = CheckNonRouteRelProSwiLockSta(nonRouteId,functionId,sendLevel);
	}

	
	if (CI_SUCCESS == chkResult)
	{/*侵限区段侵限条件不满足检查*/
		chkResult = NonRouteIntruSecVainCheck(nonRouteId,functionId,sendLevel);
	}

	
	return chkResult;
}


/* C100 故障编码: EFUNC_CLD_CANCEL_NONROUTE */
/*
* 功能描述： 取消非进路处理
* 参数说明： UINT8 nonRouteId，非进路ID
* 返回值  ：    
*/
UINT8 CancelNonRouteP(UINT8 nonRouteId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CLD_CANCEL_NONROUTE;

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

	UINT8 reVal = CI_ERROR;

	/* 联锁条件检查 */
	/*非进路区段占用空闲*/
	reVal =  CheckNonRoutePhySectionOccupy(nonRouteId,functionId,sendLevel);

	if(CI_SUCCESS == reVal)
	{ /*非进路区段锁闭检查*/
		reVal = CheckNonRoutePhySectionLock(nonRouteId,functionId,sendLevel);
	}

	return reVal;
}

/* C101 故障编码: EFUNC_CLD_FAULT_CANCEL_NONROUTE */
/*
* 功能描述： 故障取消非进路处理
* 参数说明： UINT8 nonRouteId，非进路ID
* 返回值  ：    
*/
UINT8 FaultCancelNonRouteP(UINT8 nonRouteId)
{
/*函数故障码*/
UINT8 const functionId = EFUNC_CLD_FAULT_CANCEL_NONROUTE;

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

/* 联锁条件检查 */

	if (CI_ERROR == CheckNonRoutePhySectionLock(nonRouteId,functionId,sendLevel))
	{ /*非进路区段锁闭正确*/

		return CI_ERROR;
	}

	return CI_SUCCESS;
}


/* C102 故障编码: EFUNC_CLD_CANCEL_D_TRAIN_ROUTE */
/*
* 功能描述： 取消调车进路逻辑处理
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ： CI_ERROR
*            CI_SUCCESS
*故障编码：EFUNC_CLD_CANCEL_D_TRAIN_ROUTE
*/
UINT8 CancelDTrainRouteP(const UINT16 routeId)
{
/*函数故障码*/
    UINT8 const functionId = EFUNC_CLD_CANCEL_D_TRAIN_ROUTE;
    
/*故障发送级别*/
    UINT8 const sendLevel = ESEND_LEVEL_ATS;    /*发送ATS*/
    
    
/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;        /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
	UINT16 cancleZhaoChaRelayId = 0u;    /*取消照查继电器ID*/
	UINT8  relayState = 0u;              /*继电器采集状态*/
       
/* 联锁条件检查 */
/*进路内所有区段正常锁闭*/
		checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	

	if (CI_SUCCESS == reResult)
	{/*检查进路中除列检库外的其他区段都空闲*/
		checkResult = CheckDTrainRoutePhySecOccupy(routeId,functionId,sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/*通过检查*/
			reResult = CI_SUCCESS;
		} 
		else
		{
			/*失败返回*/
			reResult = CI_ERROR;
		}
	}
    else
	{
	}
	if (CI_SUCCESS == reResult)
	{/*检查取消照查继电器状态是否吸起*/
		cancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(routeId); /*取消照查继电器ID*/
		
		if((0u != cancleZhaoChaRelayId) && (0xFFFFu != cancleZhaoChaRelayId))
		{
			/*取消继电器有效：取消继电器采集状态为：吸起*/
			relayState = GetRelayCollState(cancleZhaoChaRelayId);/*获取取消继电器采集状态*/
			devId = cancleZhaoChaRelayId;
			devState = relayState;
			if(RELAY_STATE_UP == relayState)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;

			}
			else
			{
				/* 记录故障码 */
				SetErrorData(functionId,CI_DEVICE_TYPE_RELAY,devId,ETYPE_CANCLE_ZHAOCHA,devState,sendLevel); 
				/* 失败返回 */
				reResult = CI_ERROR;
			}

		}
		else
		{
		}

	} 
	else
	{
	}
	return reResult;
}






/*************************************************************************************************/


/*
* 功能描述： 办理列车进路信号机联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 SetLTrainRouteSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    
    
/* 进路内设备数据 */
    /* 始端信号机Id */
    UINT16 const startSignalId = GetRouteStartSignalId(routeId);

 /* 联锁逻辑检查 */

    /* 进路始端信号机未开放*/
    devState = GetSignalOpenCloseState(GetSignalCurColor(startSignalId));
    if (devState == SIGNAL_CLOSE)
    {
        /* 通过检查 */
        reResult = CI_SUCCESS;
    }
    else
    {
        /* 记录故障码 */
        SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,startSignalId,ETYPE_SIG_START_OPEN_STATE,devState,sendLevel);
        /* 失败返回 */
        reResult = CI_ERROR;
        return reResult;
    }
    
    /*进路内所有信号机【未封锁】*/
    devId = 0u;
    devState = 0u;
    checkResult = RouteSignalFLockCheck(routeId,&devId,&devState);
    if (checkResult == CI_SUCCESS)
    {
        /* 通过检查 */
        reResult = CI_SUCCESS;
    }
    else
    {
        /* 记录故障码 */
        SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_FLOCK_STATE,devState,sendLevel);
        /* 失败返回 */
        reResult = CI_ERROR;
        return reResult;
    }
    
    /*进路的敌对条件不成立*/
    devId = 0u;
    devState = 0u;
    checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState);
    if (checkResult == CI_SUCCESS)
    {
        /* 通过检查 */
        reResult = CI_SUCCESS;
    }
    else
    {
        /* 记录故障码 */
        SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ENEMY_STATE,devState,sendLevel);        
        /* 失败返回 */
        reResult = CI_ERROR;
        return reResult;
    }
    
    /* 返回结果 */
    return reResult;
}


/*
* 功能描述： 办理列车进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 SetLTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    
    
/* 联锁逻辑检查 */  
	/* 进路内所有区段未被封锁 */
	devId = 0u;
	devState = 0u;
	checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
		AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
		/* 失败返回 */
		reResult = CI_ERROR;		
	}

    /* 进路内所有区段占用状态【空闲】*/
	if(CI_SUCCESS == reResult)
	{
		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)
	{
		devId = 0u;
		devState = 0u;
		checkResult = TradLTrainRouteSecLockValCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#if 0 
    /*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); 
			/* 失败返回 */
			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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    /* 返回结果 */
    return reResult;
}

/*
* 功能描述： 办理点式进路道岔联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 SetLTrainRouteSwitchCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 reResultP = CI_ERROR;          /*道岔位置局部检查返回值*/
	UINT8 chConnetCheckFunc = 0U;

	chConnetCheckFunc = GetCiFunctionSwitchConfig(FUNC_SETROUTE_CONNECT_CHECK);		/*获取是否要检查联络线条件的开关*/

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

	}

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

		}
	}
	else
	{
		; /*继续执行*/
	}

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

		}
	}

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

	if (CI_SUCCESS == reResult)
	{
		if (FUNC_SWITCH_ON == chConnetCheckFunc)
		{
			;	/*开关打开，不检查联络线条件*/
		}
		else
		{
			/*进路联络线设备条件检查*/
			checkResult = RouteContactLineDevSwitchCheck(routeId, functionId, sendLevel);
			if (CI_SUCCESS == checkResult)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
	}

	if (CI_SUCCESS == reResult)
	{
		/*进路内所有道岔位置正确或位置不正确但可动作*/
		devId = 0u;
		devState = 0u;
		checkResult = RouteSwitchPosAndMoveValidCheck(routeId, sendLevel);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 失败返回 */
			reResult = checkResult;
		}
	}
	else
	{
		; /*继续执行*/
	}

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

		}
	}
	else
	{
		/*如果是进路内道岔等待相邻联锁反馈道岔检查状态,先不检查道岔是否全在位置，继续等待*/
	}

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

		if (CI_SUCCESS == reResultP)
		{
			/*进路关联防护道岔位置正确或位置不正确但可动作*/
			devId = 0u;
			devState = 0u;
			checkResult = RouteRelProSwiPosAndMovValCheck(routeId,sendLevel);
			if (CI_SUCCESS == checkResult)
			{
				/* 能检查到防护道岔是否可动作，说明道岔全在本控区或相邻控区已反馈道岔检查状态 */
				/* 通过检查 */
				reResultP = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResultP = checkResult;
			}
		}
		else
		{
			reResultP = CI_ERROR;
		}

		if (CI_SUCCESS == reResultP)
		{
			/*进路关联防护道岔位置正确*/
			devId = 0u;
			devState = 0u;
			checkResult = RouteRelatedProSwitchPosCheck(routeId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResultP = CI_SUCCESS;
			}
			else
			{
				/* 失败返回 */
				reResultP = RETURN_LOCK_ERR_SWITPOS;
			}
		}
		else
		{
			/*如果是进路防护道岔等待相邻联锁反馈道岔检查状态,先不检查防护道岔是否全在位置，继续等待*/
		}

		if (CI_ERROR == reResultP)
		{/*如果防护道岔的检查结果为错误，则总的检查结果为错误*/
			reResult = CI_ERROR;
		}
		else if (CI_SUCCESS == reResultP)
		{
			/*如果防护道岔的检查结果为成功，则总的检查结果保持不变*/
		}
		else if (RETURN_LOCK_ERR_WAIT_SWCHECK == reResultP)
		{
			/*如果防护道岔的检查结果等待检查，则总的检查结果等待检查*/
			reResult = RETURN_LOCK_ERR_WAIT_SWCHECK;
		}
		else if (RETURN_LOCK_ERR_SWITPOS == reResultP)
		{/*如果防护道岔的检查结果为锁闭位置错误，则总的检查结果为锁闭位置错误*/
			reResult = RETURN_LOCK_ERR_SWITPOS;
		}
		else
		{/*其它不存在的情况，置总的结果为错误*/
			reResult = CI_ERROR;
		}
	}
	else if (RETURN_LOCK_ERR_WAIT_SWCHECK == reResult)
	{
		/*进路内道岔等待相邻联锁反馈道岔检查状态,先不检查防护道岔状态，继续等待*/
		;
	}
	else
	{
		/* 失败返回 */
		reResult = CI_ERROR;
	}
	/* 返回结果 */
	return reResult;
}

/*
* 功能描述： 办理调车进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 SetDTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    
    
/* 联锁逻辑检查 */  
	/* 进路内所有区段未被封锁 */
	devId = 0u;
	devState = 0u;
	checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
		AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
		/* 失败返回 */
		reResult = CI_ERROR;		
	}

    /* 进路内所有区段占用状态【空闲】 或 停止检查列检查库区段不检查 */
	if(CI_SUCCESS == reResult)
	{
		devId = 0u;
		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 = DTrainRouteSecLockValidCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#if 0
    /*侵限区段侵限条件不满足检查*/
	if(CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); 
			/* 失败返回 */
			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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    /* 返回结果 */
    return reResult;
}

/*
* 功能描述： 办理引导进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 SetLeadRouteSectionC(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT8 checkSecFlockFlag = 0u;     /*是否检查区段封锁*/
	UINT8 funcSwitch = 0u;               /*功能开关*/

	funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY);
    checkSecFlockFlag = GetCiFunctionSwitchConfig(FUNC_YDROUTE_SEC_FLOCK_CHECK_FLAG);
    /* 联锁逻辑检查 */  
	if(NON_CHECK_SECFLOCK == checkSecFlockFlag)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 进路内所有区段未被封锁 */
		checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
			AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
			/* 失败返回 */
			reResult = CI_ERROR;		
		}
	}

    /* 进路内所有区段征用状态【未征用】*/
	if(CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecUseVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_USE_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

    
    /* 进路内所有区段锁闭状态【未锁闭】*/
	if(CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		if (FUNC_SWITCH_ON == funcSwitch) 
		{
			/*modify 20221008 适配进路驱动道岔提前扳动功能*/
			checkResult = BlockRouteLogSecLockValidCheck(routeId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
		else
		{
			checkResult = BlockRouteSecLockValidCheck(routeId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
	}
    /*引导进路办理不检查侵限区段*/

	/* 进路包含的所有逻辑区段【未逻辑锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIncLogSecLogicLockCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

#if 0    
    /*侵限区段侵限条件不满足检查*/
	if(CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); 
			/* 失败返回 */
			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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 进路内道岔另一位置逻辑区段未锁闭*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteSwOtherLogLockValidCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    /* 返回结果 */
    return reResult;
}

/*
* 功能描述： 锁闭列车进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 LockLTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    
    
/* 联锁逻辑检查 */  
	/* 进路内所有区段未被封锁 */
	devId = 0u;
	devState = 0u;
	checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
		AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
		/* 失败返回 */
		reResult = CI_ERROR;		
	}

    /* 进路内所有区段占用状态【空闲】*/
    if (CI_SUCCESS == reResult)
	{
		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)
	{
		devId = 0u;
		devState = 0u;
		checkResult = TradLTrainRouteSecLockValCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
#if 0
    /*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); 
			/* 失败返回 */
			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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    /* 返回结果 */
    return reResult;
}

/*
* 功能描述： 锁闭调车进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 LockDTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    
    
/* 联锁逻辑检查 */  
	/* 进路内所有区段未被封锁 */
	devId = 0u;
	devState = 0u;
	checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
		AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
		/* 失败返回 */
		reResult = CI_ERROR;		
	}

    /* 进路内所有区段占用状态【空闲】 或 停止检查列检查库区段不检查 */
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		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 = DTrainRouteSecLockValidCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
			
		}
	}
#if 0
    /*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState, ESEND_LEVEL_ATS);
			/* 失败返回 */
			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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    /* 返回结果 */
    return reResult;
}

/*
* 功能描述： 锁闭引导进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 LockLeadRouteSectionC(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    
	UINT8 checkSecFlockFlag = 0u;     /*是否检查区段封锁*/
	UINT8 funcSwitch = 0u;               /*功能开关*/

	funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY);
	checkSecFlockFlag = GetCiFunctionSwitchConfig(FUNC_YDROUTE_SEC_FLOCK_CHECK_FLAG);
    /* 联锁逻辑检查 */  
	if(NON_CHECK_SECFLOCK == checkSecFlockFlag)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 进路内所有区段未被封锁 */
		checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
			AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
			/* 失败返回 */
			reResult = CI_ERROR;		
		}
	}

    /* 进路内所有区段锁闭状态【未锁闭】*/
	if(CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		if (FUNC_SWITCH_ON == funcSwitch)
		{
			/*modify 20221010 适配进路驱动道岔提前扳动功能*/
			checkResult = BlockRouteLogSecLockValidCheck(routeId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
		else
		{
			checkResult = BlockRouteSecLockValidCheck(routeId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
	}
   /*引导进路不检查侵限区段*/
#if 0
    /*侵限区段侵限条件不满足检查*/
	if(CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); 
			/* 失败返回 */
			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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 进路内道岔另一位置逻辑区段未锁闭*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteSwOtherLogLockValidCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    /* 返回结果 */
    return reResult;
}

/*
* 功能描述： 开放列车进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 OpenLTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    UINT16 startSignalId = 0u;			/*进路始端信号机ID*/
    
/* 联锁逻辑检查 */  
	/* 进路内所有区段未被封锁 */
	devId = 0u;
	devState = 0u;
	checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
		AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
		/* 失败返回 */
		reResult = CI_ERROR;		
	}
	
    /* 进路始端信号机【未跨压】且进路内所有区段占用状态【空闲】*/
	if(CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		startSignalId = GetRouteStartSignalId(routeId);/*获取进路始端信号机ID*/
		checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState);
		if ((SIGNAL_CROSS_STATE_NO == GetSignalCrossState(startSignalId)) && (CI_SUCCESS == checkResult))
		{
			/* 通过检查 */
			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)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    
    /*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 进路内所有区段【未设置跳跃锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    /* 返回结果 */
    return reResult;
}

/*
* 功能描述： 开放调车进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 OpenDTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    
    
/* 联锁逻辑检查 */  
	/* 进路内所有区段未被封锁 */
	devId = 0u;
	devState = 0u;
	checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
		AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
		/* 失败返回 */
		reResult = CI_ERROR;		
	}
    /* 进路内所有区段占用状态【空闲】 或 停止检查列检查库区段不检查 */
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    
    /*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 进路内所有区段【未设置跳跃锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    /* 返回结果 */
    return reResult;
}

/*
* 功能描述： 开放引导进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 OpenLeadRouteSectionC(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    
	UINT8 checkSecFlockFlag = 0u;     /*是否检查区段封锁*/
	checkSecFlockFlag = GetCiFunctionSwitchConfig(FUNC_YDROUTE_SEC_FLOCK_CHECK_FLAG);
    
/* 联锁逻辑检查 */  
	if(NON_CHECK_SECFLOCK == checkSecFlockFlag)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{   /* 进路内所有区段未被封锁 */
		checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
			AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
			/* 失败返回 */
			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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		} 
	}
    /*引导进路不检查侵限区段*/
#if 0
    /*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); 
			/* 失败返回 */
			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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    /* 返回结果 */
    return reResult;
}



/*
* 功能描述： 保持引导进路信号区段占用联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
* 返回值  ： CI_ERROR 失败   
*            CI_SUCCESS 成功
*/
UINT8 KeepLeadSecOccCheck(UINT16 routeId)
{
    /*始端信号机*/
    UINT16 startSignalId = GetRouteStartSignalId(routeId);

    /*引导信号开放时间状态*/
    UINT8 const leadSinalOpenState = SystemOverTimeCheck(GetRouteLeadFaultOpenStartCyc(routeId),
                                                         GetSystemParaLeadFaultOpenCyc());
    
    /*进路始端信号机内方第一区段*/
    UINT16 const routeInFirstSecId = GetSignalInFirstPhySecId(startSignalId, routeId);
    UINT8 const inSecCurOccupyState = GetPhySecCurMergeState(routeInFirstSecId);
    /*进路始端信号机外方第一区段*/
    UINT16 const routeOutFirstSecId = GetSignalOutFirstPhySecId(startSignalId);
    UINT8 const outSecPreOccupyState = GetPhySecPreMergeState(routeOutFirstSecId);
    UINT8 const outSecCurOccupyState = GetPhySecCurMergeState(routeOutFirstSecId);
	UINT8 reResult = CI_ERROR;          /*返回值*/

    if (leadSinalOpenState == CI_TIME_NO)
    {
        /*1.未设置延时*/
        if (inSecCurOccupyState != SECTION_OCCUPY_NO)
        {
			/*信号机内方区段【当前占用】或【故障】，引导信号立即关闭*/
			reResult = CI_ERROR;
                       
        }
        else
        {
            /*1.3 内方区段【当前空闲】*/
            reResult = CI_SUCCESS;
        }
    }
    else if (leadSinalOpenState == CI_TIME_IN)
    {
        /*2.延时中*/
		if(0u < routeOutFirstSecId)
		{
			/*2.1 内方区段【当前占用】，外方区段【当前空闲】且【之前占用】（列车完全驶入）*/
			if ((inSecCurOccupyState != SECTION_OCCUPY_NO) && 
				(outSecCurOccupyState != SECTION_OCCUPY_YES) && (outSecPreOccupyState != SECTION_OCCUPY_NO))
			{
            
				/*立即关闭信号机*/
				reResult = CI_ERROR;
			}
			else
			{
				/*延时未到*/
				reResult = CI_SUCCESS;
			}
		}
		else
		{
			/*延时未到*/
			reResult = CI_SUCCESS;
		}
    }
    else 
    {
        /* 3.超时*/
        /*3.1信号开放时间超时*/
        reResult = CI_ERROR;
    }
	return reResult;
}


/*
* 功能描述： 开放调车进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 KeepDTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
/* 局部变量定义初始化 */
    UINT8 reResult = CI_ERROR;          /*返回值*/
    UINT8 checkResult = CI_ERROR;       /*检查结果*/
    
    UINT16 devId = 0u;                   /*设备ID*/
    UINT8 devState = 0u;                 /*设备状态*/
    
    
/* 联锁逻辑检查 */ 
	/* 进路内所有区段未被封锁 */
	devId = 0u;
	devState = 0u;
	checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
	if (checkResult == CI_SUCCESS)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
		AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
		/* 失败返回 */
		reResult = CI_ERROR;		
	}

    /* 进路内所有区段占用状态【空闲】 或 停止检查列检查库区段不检查 */
    if (CI_SUCCESS == reResult)
	{
		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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    
    /*侵限区段侵限条件不满足检查*/
	if(CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 进路内所有区段【未设置跳跃锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
    /* 返回结果 */
    return reResult;
}


/*
* 功能描述： 车辆段：保持开放列车进路区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR   
*            CI_SUCCESS 
*/
UINT8 KeepOpenLTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT16 startSignalId = 0u;			/*进路始端信号机ID*/

	UINT16 outPhySecId = 0u;/*信号机外方物理区段*/
	UINT16 inPhySecId = 0u;/*信号机内方第一物理区段*/
	
	UINT16 routeInFirstLogSecId = 0u;/*进路内方第一逻辑区段Id*/
	UINT8 routeInFirstLogSecState = 0u;/*进路内方第一逻辑区段占用状态*/
	
	UINT16 routeOutLastLogSecId = 0u;/*进路外方最后一逻辑区段Id*/
	UINT8 routeOutLastLogSecState = 0u;/*进路外方最后一逻辑区段占用状态*/

	UINT16 outRouteId = 0u;/*信号机外方进路ID*/

	UINT8 crossState = 0u;/*跨压状态*/

	RoutePhysicalSectionStruct* pRoutePhySecData = NULL;/*进路物理区段*/
	UINT16 routePhyNum = 0u;
	

	UINT16 ii = 0u;/*索引*/
	UINT16 phyId = 0u;/*物理区段ID*/
	UINT16 phyOccupyFlag = 0u;/*物理区段占用标志*/
	UINT8 hasUtFlag = 0u;/*有UT占用*/
	UINT8 hasCtFlag = 0u;/*有CT占用*/

	UINT8 sigConfigCross = 0u;/*是否配置了跨压码位*/

	UINT32 curCycle = 0u;/*当前周期号*/
	UINT8 rcWorkMode = 0U;/*RC工作模式*/
	rcWorkMode = GetLocalRcWorkMode();

	pRoutePhySecData = GetRouteSectionData(routeId);
	routePhyNum = GetRoutePhysicalSectionSum(routeId);

	curCycle = Get2oo2CurCycleNum();

	if ((NULL == pRoutePhySecData)|| (0u == routePhyNum))
	{/*进路没有配置区段，或者进路区段数据为空*/
		reResult = CI_ERROR;
	}
	else
	{
		reResult = CI_SUCCESS;
	}

	/* 联锁逻辑检查 */  
	/* 进路内所有区段未被封锁 */
	devId = 0u;
	devState = 0u;
	if (CI_SUCCESS == reResult)
	{
		checkResult = RouteSecFLockCheck(routeId,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}		
		else
		{
			/*cgh-合并CID-2539-1：根据物理区段封锁类型设置errorcode*/
			AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
			/* 失败返回 */
			reResult = CI_ERROR;		
		}
	}
	

	/* 进路始端信号机【未跨压】且进路内所有区段占用状态【空闲】*/
	if(CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		
		startSignalId = GetRouteStartSignalId(routeId);/*获取进路始端信号机ID*/

		inPhySecId = GetSignalInFirstPhySecId(startSignalId,routeId);/*获取信号机内方第一物理区段*/
		
		sigConfigCross = GetSigConfZcCiSignalCrossMask(startSignalId);/*是否配置了信号机跨压码位*/
		
		routeInFirstLogSecId = GetRouteInFirstLogSecId(routeId);/*获取进路内方第一逻辑区段Id*/
		routeInFirstLogSecState = GetLogSecCurCtOrUtOccupyState(routeInFirstLogSecId);/*获取进路内方第一逻辑区段占用状态*/
		
		
		crossState =  GetSignalCrossState(startSignalId);

		if (SIGNAL_CROSS_STATE_NO == crossState)
		{
			/*未跨压*/
			checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState);

			if (CI_SUCCESS == checkResult)
			{
				/*全部出清,通过检查，保持信号*/
				reResult = CI_SUCCESS;
			}
			else
			{
				routeOutLastLogSecState = CheckRouteIdOutFirstLogSecState(routeId,&routeOutLastLogSecId);
				/*进路内区段，有UT占用，信号保持失败*/
				/*进路内区段，有CT，且第一逻辑区段和外方第一物理区段最后一个逻辑区段CT占用，信号保持成功，其它失败*/				
				hasUtFlag = 0u;
				hasCtFlag = 0u;
				for (ii = 0u;ii<routePhyNum;ii++)
				{
					phyId = pRoutePhySecData[ii].PhysicalSectionId;
					phyOccupyFlag = GetPhySecPreOccState(phyId);
					if (LOGICSECTION_OCCUPY_UT == phyOccupyFlag)
					{
						hasUtFlag = 1u;
					}
					else if (LOGICSECTION_OCCUPY_CT == phyOccupyFlag)
					{
						hasCtFlag = 1u;
					}
					else
					{
						/*没有CT UT占用*/
					}
				}
				
				debug_infor_printf((const)"\r\ncurCycle:%d, RouteId:%d, hasUtFlag:%d, hasCtFlag:%d,startSignalId:%d, sigConfigCross:%d \r\n",curCycle,routeId,hasUtFlag,hasCtFlag,startSignalId,sigConfigCross);

				debug_infor_printf((const)"\r\ncurCycle:%d, RouteId:%d, routeInFirstLogSecId:%d, routeInFirstLogSecState:%d,routeOutLastLogSecId:%d, routeOutLastLogSecState:%d \r\n",
					curCycle,routeId,routeInFirstLogSecId,routeInFirstLogSecState,
					routeOutLastLogSecId,routeOutLastLogSecState);

				if (1u == hasUtFlag)
				{
					/*信号保持失败*/
					reResult = CI_ERROR;
					SetErrorData(functionId,
						CI_DEVICE_TYPE_PHYSEC,		devId,
						ETYPE_PS_MERGY_OCU_STATE,	devState,
						sendLevel);  
				}
				else if((0u == hasUtFlag) && (1u == hasCtFlag))
				{
					/*有CT占用，第一逻辑区段CT占用，外方第一物理区段最后一个逻辑区段CT占用，且配置了跨压码位，则保持成功，其它失败*/

					if (SIGNAL_CONFIG_CROSS_MASK_YES == sigConfigCross)
					{/*配置了跨压码位，等跨压才关灯*/
						if ((LOGICSECTION_OCCUPY_CT == routeInFirstLogSecState)&&
							(LOGICSECTION_OCCUPY_CT == routeOutLastLogSecState))
						{
							reResult = CI_SUCCESS;
						}
						else
						{
							reResult = CI_ERROR;
							SetErrorData(functionId,
								CI_DEVICE_TYPE_LOGICSEC,		routeInFirstLogSecId,
								ETYPE_PS_MERGY_OCU_STATE,	routeInFirstLogSecState,
								sendLevel); 
						}
					}
					else
					{/*没有配置跨压码位*/
						/*进路物理区段有CT占用就关灯*/
						reResult = CI_ERROR;
						SetErrorData(functionId,
							CI_DEVICE_TYPE_LOGICSEC,		routeInFirstLogSecId,
							ETYPE_PS_MERGY_OCU_STATE,	routeInFirstLogSecState,
							sendLevel); 
					}

					
				}
				else
				{
					/*都没有占用，信号保持成功*/
					reResult = CI_SUCCESS;
				}
			}
		}
		else
		{
			if (RC_WORK_MODE_TIOC == rcWorkMode)
			{
				/*跨压，信号保持失败*/
				reResult = CI_ERROR;
				SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, startSignalId, ETYPE_SIG_CROSS, crossState, sendLevel);
			}
			else if (RC_WORK_MODE_CI == rcWorkMode)
			{
				reResult = CheckEngineerVehicleNear(routeId);/*检查是否是工程车接近的跨压*/
				checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState);/*检查所有区段空闲*/
				if ((CI_SUCCESS == reResult) && (CI_SUCCESS == checkResult))
				{

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

		}
				
	}

	/* 进路内所有区段锁闭状态【正常锁闭】*/
	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
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/*侵限区段侵限条件不满足检查*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState);
		if (checkResult == CI_SUCCESS)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 进路内所有区段【未设置跳跃锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); 
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	/* 返回结果 */
	return reResult;
}

/*
* 功能描述： 办理引导进路检查
* 参数说明： UINT16 routeId, 进路ID
* 返回值  ： CI_ERROR 失败
*            CI_SUCCESS 成功
* by cgh 20250224
*/
UINT8 SetLeadRouteCheck(const UINT16 routeId)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_SET_LEAD_ROUTE_CHECK;
	/*故障发送级别*/
	UINT8 const sendLevel = ESEND_LEVEL_ATS;    /*发送ATS*/
	/* 局部变量定义初始化 */
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 cFuncSwitch = FUNC_SWITCH_ON;  /*引导进路是否检查防淹门开关*/

/* 联锁条件检查 */
	devId = routeId;
	devState = GetRouteState(routeId);

	if (ROUTE_STATE_LEAD_FIRST_XUANPAI != devState)
	{ /*进路状态不为引导预选*/

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

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

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

	/*照查联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		reResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel);
		if (CI_SUCCESS != reResult)
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
		else
		{
			reResult = CI_SUCCESS;
		}
	}
	else
	{
		; /*返回失败*/
	}
	

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

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

	/*防淹门联锁条件检查*/
	if (CI_SUCCESS == reResult)
	{
		cFuncSwitch = GetCiFunctionSwitchConfig(FUNC_LEADROUTE_FLOODGATE_CHECK);

		if (FUNC_SWITCH_OFF == cFuncSwitch)
		{
			/*引导进路锁闭不检查防淹门状态*/
		}
		else
		{
			/*引导进路锁闭检查防淹门状态*/
			reResult = BlocRouteFloodGateCheck(routeId, functionId, sendLevel);
		}

		if (CI_ERROR == reResult)
		{
			/* 失败返回 */
			reResult = CI_ERROR;
		}
		else
		{
			reResult = CI_SUCCESS;
		}
	}
	else
	{
		; /*返回失败*/
	}

	return reResult;
}

/*
* 功能描述： 引导进路办理区段联锁条件检查
* 参数说明：
*            UINT16 RouteId,    进路号
*            UINT8 functionId,  调用函数编号
*            UINT8 sendLevel,   故障码发送级别
* 返回值  ： CI_ERROR 失败
*            CI_SUCCESS 成功
* by cgh 20250224
*/
UINT8 LeadRouteSetSectionCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel)
{
	/* 局部变量定义初始化 */
	UINT8 reResult = CI_ERROR;          /*返回值*/
	UINT8 checkResult = CI_ERROR;       /*检查结果*/

	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT8 checkSecFlockFlag = 0u;     /*是否检查区段封锁*/
	UINT8 funcSwitch = 0u;               /*功能开关*/

	funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY);
	checkSecFlockFlag = GetCiFunctionSwitchConfig(FUNC_YDROUTE_SEC_FLOCK_CHECK_FLAG);
	/* 联锁逻辑检查 */
	if (NON_CHECK_SECFLOCK == checkSecFlockFlag)
	{
		/* 通过检查 */
		reResult = CI_SUCCESS;
	}
	else
	{
		/* 进路内所有区段未被封锁 */
		checkResult = RouteSecFLockCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}

	/* 进路内所有区段锁闭状态【未锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		if (FUNC_SWITCH_ON == funcSwitch)
		{
			/*modify 20221008 适配进路驱动道岔提前扳动功能*/
			checkResult = BlockRouteLogSecLockValidCheck(routeId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
		else
		{
			checkResult = BlockRouteSecLockValidCheck(routeId, &devId, &devState);
			if (checkResult == CI_SUCCESS)
			{
				/* 通过检查 */
				reResult = CI_SUCCESS;
			}
			else
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
				/* 失败返回 */
				reResult = CI_ERROR;
			}
		}
	}
	else
	{
		; 
	}
	/* 进路包含的所有逻辑区段【未逻辑锁闭】*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteIncLogSecLogicLockCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
		;
	}

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

	/* 进路内道岔另一位置逻辑区段未锁闭*/
	if (CI_SUCCESS == reResult)
	{
		devId = 0u;
		devState = 0u;
		checkResult = RouteSwOtherLogLockValidCheck(routeId, &devId, &devState);
		if (CI_SUCCESS == checkResult)
		{
			/* 通过检查 */
			reResult = CI_SUCCESS;
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel);
			/* 失败返回 */
			reResult = CI_ERROR;
		}
	}
	else
	{
		;
	}

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


