/********************************************************
* 
* 文 件 名： DeviceDataManage.h   
* 版权说明： 北京交控科技有限公司 
* 创建时间： 2012-09-21
* 作    者： 联锁组
* 功能描述： 设备间数据管理 
* 函数包括： 
* 使用注意：
* 修改记录：   
*
********************************************************/ 


#include "DeviceDataManage.h"
#include "../AutoRoute/AutoRouteDefine.h"
#include "../ParsePack/CiInterfaceDefine.h"
#include "LogicSectionDataManage.h"
#include "../LogicManage/InterlockLogicManage.h"
#include "LogicSectionConfigDataManage.h"
#include "dquCIInterFace.h"
#include "LogicalRouteDataManage.h"
#include "../LogicProcess/LogicalRouteLogicCheck.h"
#include "InterlockLogicCheck.h"

UINT8 AllSignalBrightFlag = CI_ALL_SIGNAL_BRIGHT_NO;					                  /*全站亮灯标志*/

UINT8 AllSwitchYLockFlag = CI_ALL_SWITCH_YLOCK_NO;						                  /*全站引导总锁标志*/

UINT8 StartFLockFlag = CI_START_FLOCK_YES;								                  /*全站封锁标志*/

UINT8 StartLockFlag = CI_START_LOCK_YES;								                  /*上电锁闭标志*/

UINT8 LSXianSuCancelBtnIsValidFlag = CI_LINSHIXIANSU_CANCEL_BUTTON_VALID;          /*临时限速人工解除标志*/
 
UINT8 LabourCancelLinShiXianState = LINSHIXIANSU_COMM_BAD_STATE;                          /*人工取消临时限速迁移状态*/

UINT8 StopCheckState = ROUTE_STOPCHECK_SET_NO;							                  /*停止检查未设置*/

UINT16 JkjRelayId = 0u;													                  /*应急盘继电器ID*/

UINT8 PlatOverFlag = CI_OVER_NO;										                  /*平台宕机标志*/

UINT8 ciMode = CI_MODE_CI_LOCAL;										                  /* 联锁控模式 */

UINT8 g_AllTsrFlag = CI_ALL_TSR_UNVALID;												  /* 临时限速标志 */

UINT8 g_AllSnowModel = CI_ALL_SNOW_UNVALID;                                                 /*全线雨雪模式命令：0x55-有效；0xAA-无效*/

UINT8 g_AllSnowLevel = CI_SNOW_LEVEL_DEFAULT;                                                 /*全线湿轨级别：0-默认值；1-一级；2-二级*/

UINT8 g_IteLineCutState = CI_ITE_LINE_CUT_DEFAULT;                                          /*ITE全线切除状态：0x55：切除ITE；0xAA：使用ITE；0xFF：默认值*/

UINT8 g_AllLineTsrState = CI_ALL_LINE_TSR_UNVALID;                                          /*全线临时限速状态*/

UINT8 g_AllLineTsrSpeed = 0u;																/*全线临时限速速度*/

UINT8 JkjRelayValid = JKJ_REYLAY_INVALID;                                                 /*JKJ应急盘继电器无效*/

UINT32 JkjRelayValidCycNum = 0u;                                                              /*JKJ应急盘继电器有效周期*/

UINT8 ciTrainTestStatus = CI_TRAIN_TEST_OFF;                                              /*试车线联锁状态非试车中*/

UINT8 psdPangluFlag = PSD_BUTTON_PANGLU_STATE_INVALID;                            /*站台安全门按钮旁路状态*/

UINT8 generalResetFlag = CI_PHYSEC_GENERAL_RESET_NO;                        /*计轴总复位标志无效*/

UINT32 ZFWValidCycNum = 0u;                                                              /*ZFW总复位继电器有效周期*/

UINT32 ZFWCmdStartCycNum = 0u;                                                            /*ZFW命令收到周期*/

UINT8 g_cTsrSureFlag = CI_TSR_SURE_NO;													/* 临时限速确认标志 */

UINT8 comm_Train_Test_SQAJ_SCX_State = COMM_TRAIN_TEST_DEV_STATE_INVALID;				/*试车线与车辆段采用通信接口时试车线SQAJ状态*/
UINT8 comm_Train_Test_YSKJ_SCX_State = COMM_TRAIN_TEST_DEV_STATE_INVALID;				/*试车线与车辆段采用通信接口时试车线YSKJ状态*/
UINT8 comm_Train_Test_SQJ_CLD_State = COMM_TRAIN_TEST_DEV_STATE_INVALID;				/*试车线与车辆段采用通信接口时车辆段SQJ状态*/
UINT8 comm_Train_Test_TYSJ_CLD_State = COMM_TRAIN_TEST_DEV_STATE_INVALID;				/*试车线与车辆段采用通信接口时车辆段TYSJ状态*/

UINT8 AutoTriggerFlag = AUTO_TRIGGER_SET_NO;                                             /*自动触发标志初始化为未设置*/

UINT8 CiCiRelayInterfaceConfirmFlag = CICI_RELAY_INTERFACE_CONFIRM_NO;/*继电接口确认标志*/
UINT8 ZFWJRelayHunXianFlag = ZFWJ_HUN_XIAN_NO; /*计轴总复位混线标志*/
UINT8 SwitchBlockLinkState = RECOVER_SWITCH_BLOCK_LINK; /*初始值为恢复封连报警状态：此时报警有效*/

CtrlPowerStruct ctrlpowerFlag[VIRTUAL_CI_MAX] = { 0u };

UINT8 LocalAreaSnowNum = 0U;  /*本地区间雨雪站台数量*/
AreaSnowInfoStruct szLocalAreaSnow[LOCAL_AREA_SNOW_SUM_MAX] = { 0U };  /*本地区间雨雪数组*/

LineCommTrainStruct gStrLineCommTrain = { 0U };  /*全线通信车结构体*/

UINT32 gFlyProtectOverCyc = 0U;										                  /*飞车宕机报警起始周期*/

UINT8 g_LocalSnowModel = CI_LOCAL_SNOW_UNVALID;   /*本地雨雪模式命令*/

UINT8 gLocalAreaIteCutNum = 0U;  /*本地区间ITE切除数量*/
UINT16 gSzLocalAreaIteCutId[ALL_AREA_SNOW_SUM_MAX] = { 0U };  /*本地区间ITE切除ID数组——需要存储ZC发送的所有区间ID*/

/******************************联锁标志数据管理****************************/


/******************************点式临时限速数据计算****************************/
/*
* 功能描述： 进路包含的逻辑区段是否被设置了临时限速
* 参数说明： const UINT16 routeId, 进路Id
* 返回值  ：
           LOGSEC_LSXS_SET_STATE_NO 		 0x55 未设置临时限速（大于等于1条被设置）
           LOGSEC_LSXS_SET_STATE_YES 		 0xAA 设置了临时限速（全未设置）
*/
static UINT8  RouteIncludeLogSecLSXSSetCheck(const UINT16 routeId);


/*
* 功能描述： 进路保护区段是否被设置了临时限速
* 参数说明： const UINT16 routeId, 进路Id
* 返回值  ：
           LOGSEC_LSXS_SET_STATE_NO 		 0x55 未设置临时限速（大于等于1条被设置）
           LOGSEC_LSXS_SET_STATE_YES 		 0xAA 设置了临时限速（全未设置）
*/
static UINT8  RouteOvlpLogSecLSXianSuSetCheck(const UINT16 routeId);

/*
* 功能描述： 获取上电解封标志
* 参数说明： void
* 返回值  ：CI_START_FLOCK_YES    
			CI_START_FLOCK_NO
            CI_START_FLOCK_ERROR
*/
UINT8 GetStartFLockFlag(void)
{
	return StartFLockFlag;
}

/*
* 功能描述： 设置上电解封标志
* 参数说明： void
* 返回值  ：CI_START_FLOCK_YES    
			CI_START_FLOCK_NO
            CI_START_FLOCK_ERROR
*/
void SetStartFLockFlag(UINT8 setFlag)
{
    if (CI_START_FLOCK_YES == setFlag)
    {
        StartFLockFlag = setFlag;
    }
    else if (CI_START_FLOCK_NO == setFlag)
    {
        StartFLockFlag = setFlag;
    }
    else if (CI_START_FLOCK_ERROR == setFlag)
    {
        StartFLockFlag = setFlag;
    }
    else
    {
        /*不处理*/
    }
}

/*
* 功能描述： 获取上电解锁标志
* 参数说明： void
* 返回值  ：CI_START_LOCK_NO    
			CI_START_LOCK_YES
            CI_START_LOCK_ERROR
*/
UINT8 GetStartLockFlag(void)
{
	return StartLockFlag;
}

/*
* 功能描述： 设置上电解锁标志
* 参数说明： void
* 返回值  ：CI_START_LOCK_NO    
			CI_START_LOCK_YES
            CI_START_LOCK_ERROR
*/
void SetStartLockFlag(UINT8 setFlag)
{
    if (CI_START_LOCK_YES == setFlag)
    {
        StartLockFlag = setFlag;
    }
    else if (CI_START_LOCK_NO == setFlag)
    {
        StartLockFlag = setFlag;
    }
    else if (CI_START_LOCK_ERROR == setFlag)
    {
        StartLockFlag = setFlag;
    }
    else
    {
        /*不处理*/
    }
}



/*
* 功能描述： 获取人工取消临时限速的状态
* 参数说明： void
* 返回值  ：LINSHIXIANSU_COMM_GOOD_STATE     
			LINSHIXIANSU_COMM_BAD_NO_LABOURCANCLE_STATE
			LINSHIXIANSU_COMM_BAD_YES_LABOURCANCLE_STATE
*/
UINT8 GetLabourCancelLinShiXianState(void)
{
	return LabourCancelLinShiXianState;
}


/*
	功能描述：人工取消临时限速状态迁移处理
	参数说明：setFlag  状态
	返回值：无
*/
void LabourCancelLSXianStaMoveProc(UINT8 setFlag)
{
	UINT8 linShiXianState = 0u;
	UINT8 wholelinShiXianState = 0u;
	linShiXianState = GetLabourCancelLinShiXianState();
	wholelinShiXianState = GetWholeLineLinShiXianSuFlag();
	switch(setFlag)
	{
		case LINSHIXIANSU_COMM_GOOD_STATE:/*与ZC通信正常状态*/
			if((LINSHIXIANSU_COMM_BAD_STATE == linShiXianState) || 
			   (LINSHIXIANSU_LABOURCANCLE_YES_STATE == linShiXianState))
			{/*前一状态为： 通信故障且未进行人工取消  ||  通信故障且进行了人工取消   则进行状态迁移*/
				LabourCancelLinShiXianState = setFlag;
			}
			break;
		case LINSHIXIANSU_COMM_BAD_STATE:/*与ZC通信故障状态*/
			if((LINSHIXIANSU_COMM_GOOD_STATE == linShiXianState) && (WHOLE_LINE_LINSHIXIANSUSET_YES == wholelinShiXianState))
			{/*前一状态为：通信正常状态且临时限速标志为设置  则进行状态迁移*/
				LabourCancelLinShiXianState = setFlag;
			}
			break;
		case LINSHIXIANSU_LABOURCANCLE_YES_STATE:/*已经进行了人工取消临时限速*/
			if(LINSHIXIANSU_COMM_BAD_STATE == linShiXianState)
			{/*前一状态为：通信故障状态  则进行状态迁移*/
				LabourCancelLinShiXianState = setFlag;
			}
			break;
		default:
			/*不可达分支*/
			break;

			
	}
}
/*
	功能描述：人工取消临时限速状态迁移处理
	参数说明：setFlag  状态,UINT8 virCIid 虚拟联锁ID
	返回值：无
*/
void LaborCancelLSXSXStaMoveProc_Vir(UINT8 setFlag,UINT8 virCIid)
{
	UINT8 linShiXianState = 0u;
	UINT8 wholelinShiXianState = 0u;
	linShiXianState = GetVirCILabourCancelLSXianSta(virCIid);
	wholelinShiXianState = GetWholeLineLinShiXianSuFlag();
	switch(setFlag)
	{
		case LINSHIXIANSU_COMM_GOOD_STATE:/*与ZC通信正常状态*/
			if((LINSHIXIANSU_COMM_BAD_STATE == linShiXianState) || 
			   (LINSHIXIANSU_LABOURCANCLE_YES_STATE == linShiXianState))
			{/*前一状态为： 通信故障且未进行人工取消  ||  通信故障且进行了人工取消   则进行状态迁移*/
				SetVirCILabourCancelLSXianSta(virCIid,setFlag);
			}
			break;
		case LINSHIXIANSU_COMM_BAD_STATE:/*与ZC通信故障状态*/
			if((LINSHIXIANSU_COMM_GOOD_STATE == linShiXianState) && (WHOLE_LINE_LINSHIXIANSUSET_YES == wholelinShiXianState))
			{/*前一状态为：通信正常状态且临时限速标志为设置  则进行状态迁移*/
				SetVirCILabourCancelLSXianSta(virCIid,setFlag);
			}
			break;
		case LINSHIXIANSU_LABOURCANCLE_YES_STATE:/*已经进行了人工取消临时限速*/
			if(LINSHIXIANSU_COMM_BAD_STATE == linShiXianState)
			{/*前一状态为：通信故障状态  则进行状态迁移*/
				SetVirCILabourCancelLSXianSta(virCIid,setFlag);
			}
			break;
		default:
			/*不可达分支*/
			break;

			
	}
}



/*
* 功能描述： 获取全站引导总锁标志
* 参数说明： void
* 返回值  ：CI_ALL_SWITCH_YLOCK_NO  
			CI_ALL_SWITCH_YLOCK_YES 
*/
UINT8 GetAllSwitchYLockFlag(void)
{
	return AllSwitchYLockFlag;
}


/*
* 功能描述： 设置全站引导总锁标志
* 参数说明： void
* 返回值   ：CI_ALL_SWITCH_YLOCK_NO  
			CI_ALL_SWITCH_YLOCK_YES 
*/
void SetAllSwitchYLockFlag(UINT8 setFlag)
{
    UINT16 switchCurSum = 0u;     /*道岔总数目*/
    UINT16 signalCurSum = 0u;     /*信号机总数目*/
    UINT8 localCiId = 0u;         /*本地联锁ID*/

    UINT16 switchId = 0u;
    UINT16 signalId = 0u;
    UINT8 belongCiId = 0u;
    
    UINT16 ii = 0u;               /*循环索引*/

	UINT8 checkRetVal = CI_FALSE; /*检查设备是否不属于其他线路设备返回值*/
	
    switchCurSum = GetSwitchCurSum();           /*获取道岔总数*/
    signalCurSum = GetSignalCurSum();           /*获取信号机总数*/
    localCiId = GetSystemParaLocalCiId();       /*获取本机联锁ID*/

    if (setFlag == CI_ALL_SWITCH_YLOCK_NO)
    {
        /*处理道岔*/
        for (ii = 0u; ii < switchCurSum; ii++)
        {
            switchId = 0u;	         /*道岔ID*/
            belongCiId = 0u;          /*进路所属联锁ID*/
            
            switchId = GetSwitchId(ii);                          /*获取道岔ID*/
            belongCiId = GetSwitchBelongCiId(switchId);           /*获取进路所属联锁ID*/
            
            if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX))
            {
                continue;
            }
            
            if ((belongCiId != localCiId) || (localCiId == 0u))
            {
                continue;
            }

			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, switchId);

			if(CI_TRUE == checkRetVal)
			{
				/*设置道岔未引导总锁*/
				SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_NO);
			}
        }

        /*处理信号机*/
        for (ii = 0u; ii < signalCurSum; ii++)
        {
            signalId = 0u;	         /*道岔ID*/
            belongCiId = 0u;          /*进路所属联锁ID*/
            
            signalId = GetSignalId(ii);                         /*获取信号机ID*/
            belongCiId = GetSignalBelongCiId(signalId);           /*获取进路所属联锁ID*/
            
            if ((0u == signalId) || (signalId > SIGNAL_SUM_MAX))
            {
                continue;
            }
 
            if ((belongCiId != localCiId) || (localCiId == 0u))
            {
                continue;
            }

			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, signalId);

			if(CI_TRUE == checkRetVal)
			{
				/*设置引导总锁信号机开放状态为关闭*/
				SetSignalYLockOpenState(signalId, SIGNAL_CLOSE);
			}
        }
        
        /*取消引导总锁标志*/
        AllSwitchYLockFlag = setFlag;
    }
    else if (setFlag == CI_ALL_SWITCH_YLOCK_YES)
    {
	    /*处理道岔*/
	    for (ii = 0u; ii < switchCurSum; ii++)
	    {
            switchId = 0u;	         /*道岔ID*/
            belongCiId = 0u;          /*进路所属联锁ID*/
            
            switchId = GetSwitchId(ii);                          /*获取道岔ID*/
		    belongCiId = GetSwitchBelongCiId(switchId);           /*获取进路所属联锁ID*/

            if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX))
            {
                continue;
            }
            
            if ((belongCiId != localCiId) || (0u == localCiId))
            {
                continue;
		    }

			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, switchId);

			if(CI_TRUE == checkRetVal)
			{
            	/*设置道岔引导总锁*/
            	SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_YES);
			}
        }
        
        /*设置引导总锁标志*/
        AllSwitchYLockFlag = setFlag;
    }
    else
    {
        /*不处理*/
    }
}

/*
* 功能描述： 设置指定虚拟联锁全站引导总锁标志
* 参数说明： void
* 返回值   ：CI_ALL_SWITCH_YLOCK_NO  
			CI_ALL_SWITCH_YLOCK_YES 
*/
void AllSwitchYLock_UseVirCI(UINT8 virCIid,UINT8 setFlag)
{
    UINT16 switchCurSum = 0u;     /*道岔总数目*/
    UINT16 signalCurSum = 0u;     /*信号机总数目*/
    UINT8 localCiId = 0u;         /*本地联锁ID*/

    UINT16 switchId = 0u;
    UINT16 signalId = 0u;
    UINT8 belongCiId = 0u;
	UINT8 flag = 0u;
	UINT8 belongVirCI = 0u;
    
    UINT16 ii = 0u;               /*循环索引*/

	UINT8 checkRetVal = CI_FALSE; /*检查设备是否不属于其他线路设备返回值*/
	
    switchCurSum = GetSwitchCurSum();           /*获取道岔总数*/
    signalCurSum = GetSignalCurSum();           /*获取信号机总数*/
    localCiId = GetSystemParaLocalCiId();       /*获取本机联锁ID*/

    if (CI_ALL_SWITCH_YLOCK_NO == setFlag)
    {
        /*处理道岔*/
        for (ii = 0u; ii < switchCurSum; ii++)
        {
			flag = 0u;
            switchId = 0u;	         /*道岔ID*/
            belongCiId = 0u;          /*进路所属联锁ID*/
            
            switchId = GetSwitchId(ii);                          /*获取道岔ID*/
            belongCiId = GetSwitchBelongCiId(switchId);           /*获取进路所属联锁ID*/
            belongVirCI = GetSwitchBelongVirCiId(switchId);
            if ((0u == switchId) || (SWITCH_SUM_MAX <= switchId))
            {
                flag = 1u;
            }
            
            if ((belongCiId != localCiId) || (0u == localCiId))
            {
               flag = 1u;
            }

			if ((belongVirCI != virCIid) || (0u == virCIid))
			{
				flag = 1u;
			}

			if(0u == flag)
			{
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, switchId);

				if(CI_TRUE == checkRetVal)
				{
					/*设置道岔未引导总锁*/
					SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_NO);
				}
			}
			
        }

        /*处理信号机*/
        for (ii = 0u; ii < signalCurSum; ii++)
        {
			flag = 0u;
            signalId = 0u;	         /*道岔ID*/
            belongCiId = 0u;          /*进路所属联锁ID*/
            
            signalId = GetSignalId(ii);                         /*获取信号机ID*/
            belongCiId = GetSignalBelongCiId(signalId);           /*获取进路所属联锁ID*/
            belongVirCI = GetSignalBelongVirCiId(signalId);
            if ((0u == signalId) || (signalId > SIGNAL_SUM_MAX))
            {
                flag = 1u;
            }
 
            if ((belongCiId != localCiId) || (0u == localCiId))
            {
                flag = 1u;
            }

			if ((belongVirCI != virCIid) || (0u == virCIid))
			{
				flag = 1u;
			}

			if(0u == flag)
			{
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, signalId);

				if(CI_TRUE == checkRetVal)
				{
					/*设置引导总锁信号机开放状态为关闭*/
					SetSignalYLockOpenState(signalId, SIGNAL_CLOSE);
				}
			}
			
        }
        
        /*取消引导总锁标志*/
        SetVirCIAllSwitchYLockState(virCIid,setFlag);
    }
    else if (setFlag == CI_ALL_SWITCH_YLOCK_YES)
    {
	    /*处理道岔*/
	    for (ii = 0u; ii < switchCurSum; ii++)
	    {
			flag = 0u;
            switchId = 0u;	         /*道岔ID*/
            belongCiId = 0u;          /*进路所属联锁ID*/
            
            switchId = GetSwitchId(ii);                          /*获取道岔ID*/
		    belongCiId = GetSwitchBelongCiId(switchId);           /*获取进路所属联锁ID*/
		    belongVirCI = GetSwitchBelongVirCiId(switchId);

            if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX))
            {
               flag =1u;
            }
            
            if ((belongCiId != localCiId) || (0u == localCiId))
            {
              flag =1u;
		    }

			if ((belongVirCI != virCIid) || (0u == virCIid))
			{
				flag = 1u;
			}

			if(0u == flag)
			{
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, switchId);

				if(CI_TRUE == checkRetVal)
				{
            		/*设置道岔引导总锁*/
            		SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_YES);
				}
			}
        }
        
        /*设置引导总锁标志*/
        SetVirCIAllSwitchYLockState(virCIid,setFlag);
    }
    else
    {
        /*不处理*/
    }
}
/*
* 功能描述： 获取全站亮灯标志
* 参数说明： void
* 返回值  ：CI_ALL_SIGNAL_BRIGHT_NO   
			CI_ALL_SIGNAL_BRIGHT_YES 
*/
UINT8 GetAllSignalBrightFlag(void)
{
	return AllSignalBrightFlag;
}


/*
* 功能描述： 设置全站亮灯标志
* 参数说明： void
* 返回值  ：CI_ALL_SIGNAL_BRIGHT_NO   
			CI_ALL_SIGNAL_BRIGHT_YES 
*/
void SetAllSignalBrightFlag(UINT8 setFlag)
{
	UINT16 j = 0u;
	UINT16 signalNum = GetTotalSignalCurNum(); /*本联锁和相邻联锁的信号机数目*/
	UINT16 signalId = 0u;
	UINT8 belongCIid = 0u;
	UINT8 localCIid = GetSystemParaLocalCiId();

    if (setFlag == CI_ALL_SIGNAL_BRIGHT_YES)
    {
        AllSignalBrightFlag = setFlag;
    }
    else if (setFlag == CI_ALL_SIGNAL_BRIGHT_NO)
    {
        AllSignalBrightFlag = setFlag;
    }
    else
    {
        /*不处理*/
    }
	/*设置全站维修点灯时，将单个信号机维修点灯状态同时更新*/
	for(j =0u;j <signalNum;j++)
	{
		signalId = GetSignalId(j);
		belongCIid = GetSignalBelongCiId(signalId);
		if(localCIid == belongCIid)
		{
			if(CI_ALL_SIGNAL_BRIGHT_YES == setFlag)
			{
				SetSignalMaintainState(signalId,MAINTAIN_STATE_YES);
			}
			else
			{
				SetSignalMaintainState(signalId,MAINTAIN_STATE_NO);
			}
		}
	}
}


/*
* 功能描述： 获取计轴总复位标志
* 参数说明： void
* 返回值  ：CI_PHYSEC_GENERAL_RESET_NO   
			CI_PHYSEC_GENERAL_RESET_YES 
*/
UINT8 GetPhySecGeneralResetFlag(void)
{
	return generalResetFlag;
}


/*
* 功能描述： 设置计轴总复位标志
* 参数说明： void
* 返回值  ：CI_PHYSEC_GENERAL_RESET_NO   
CI_PHYSEC_GENERAL_RESET_YES 
*/
void SetPhySecGeneralResetFlag(UINT8 setFlag)
{
	UINT32 curCycNum = 0u;
	curCycNum = Get2oo2CurCycleNum();
    if (CI_PHYSEC_GENERAL_RESET_YES == setFlag)
    {
        generalResetFlag = setFlag;
		SetZFWcmdStartCycNum(curCycNum);
    }
    else if (CI_PHYSEC_GENERAL_RESET_NO == setFlag)
    {
        generalResetFlag = setFlag;
		SetZFWcmdStartCycNum(0u);
    }
    else
    {
        /*不处理*/
    }
}




/******************************进路数据交叉管理****************************/


/* 找到进路内第一个正常锁闭区段 */
/*
* 功能描述： 找到进路内第一个正常锁闭区段
* 参数说明： UINT16 routeId,    检查数据数组

* 返回值  ： UINT16 区段ID
*            = 0 无效
*            > 0 区段ID
*/
UINT16 GetRouteFirstNormalLockSection(UINT16 RouteId)
{
/* 局部变量定义初始化 */
    UINT16 i = 0u;           /* 循环变量 */
    UINT16 sectionId = 0u;
    UINT16 belongRouteId = 0u;
    UINT8  sectionLockState = 0u;
	UINT16 reVal = 0u;     /*特殊处理有continue*/
	UINT16 flag = 0u;/*查找成功标志*/
/*进路区段数据*/
    UINT8 const routeSecNum = GetRoutePhysicalSectionSum(RouteId);
    RoutePhysicalSectionStruct* const pRouteSecBuf = GetRouteSectionData(RouteId);

/*查找属于当前进路的正常锁闭区段*/
    if (0u == routeSecNum) 
    {
        /*无检查项*/
        reVal = 0u;
    }
    else
    {
        /*开始检查*/
		for (i = 0u; i < routeSecNum; i++)
		{
			sectionId = pRouteSecBuf[i].PhysicalSectionId;
			belongRouteId = GetPhySecRLockBelongRouteId(sectionId);
			if (belongRouteId == RouteId)
			{
				/*区段锁闭为当前进路*/
				sectionLockState = GetPhySecLockState(sectionId);
				if (PHYSICAL_SECTION_LOCK_NORMAL == sectionLockState)
				{
					/*区段为【正常锁闭】*/
					reVal = sectionId;
					flag = 1u;
				}
				else if (PHYSICAL_SECTION_LOCK_DELAY == sectionLockState)
				{
					/* 【延时锁闭】继续找 */

				}
				else
				{
					/* 【故障锁闭】返回失败 */
					reVal = 0u;
					flag = 1u;
				}
				if (1u == flag)
				{
					break;
				}
				else
				{
				    /*无操作*/
				}
			}
		}
    }

    /*未找到*/
    return reVal;
}


/* 找到进路内第一个延时锁闭区段 */
/*
* 功能描述： 找到进路内第一个延时锁闭区段
* 参数说明： UINT16 routeId,    检查数据数组

* 返回值  ： UINT16 区段ID
*            = 0 无效
*            > 0 区段ID
*/
UINT16 GetRouteFirstDelayLockSection(UINT16 RouteId)
{
    /* 局部变量定义初始化 */
    UINT16 i = 0u;           /* 循环变量 */
    UINT16 sectionId = 0u;
    UINT16 belongRouteId = 0u;
    UINT8  sectionLockState = 0u;
	UINT16 reVal = 0u;
    /*进路区段数据*/
    UINT8 const routeSecNum = GetRoutePhysicalSectionSum(RouteId);
    RoutePhysicalSectionStruct* const pRouteSecBuf = GetRouteSectionData(RouteId);

    /*查找属于当前进路的正常锁闭区段*/
    if (0u == routeSecNum) 
    {
        /*无检查项*/
        reVal = 0u;
    }
    else
    {
        /*开始检查*/
		for (i = 0u; i < routeSecNum; i++)
		{
			sectionId = pRouteSecBuf[i].PhysicalSectionId;
			belongRouteId = GetPhySecRLockBelongRouteId(sectionId);
			if (belongRouteId == RouteId)
			{
				/*区段锁闭为当前进路*/
				sectionLockState = GetPhySecLockState(sectionId);
				if (PHYSICAL_SECTION_LOCK_DELAY == sectionLockState)
				{
					/*区段为【延时锁闭】*/
					reVal = sectionId;
					break;
				}
				else
				{
					/* 其他状态跳过 */
				}
			}
			else
			{
				/*不属于当前进路*/
			}
		}
    }

    /*未找到*/
    return reVal;
}


/*
* 功能描述： 检查进路物理区段已解锁
* 参数说明： UINT16 routeId 进路号
*	返回值：1：是
*         0: 否
*/	
UINT8 CheckRoutePhySecHaveUnLock(const UINT16 routeId)
{
	UINT8 sectionSum = 0u; /*区段总数*/
	RoutePhysicalSectionStruct *RouteSecStru = NULL; /*区段数据*/
	UINT16 phySecId = 0u; /*物理区段ID*/
	UINT8 ii= 0u;
	UINT8 reVal = CI_SUCCESS;
	UINT16 rLockId = 0u;
	UINT8 lockState = 0u;

	sectionSum = GetRoutePhysicalSectionSum(routeId); /*获得进路包含的区段数目*/
	RouteSecStru = GetRouteSectionData(routeId); /*进路区段数据*/
	
	if (0u == sectionSum) 
	{
	    reVal = CI_ERROR;
	}
	else
	{
		for(ii = 0u; ii < sectionSum; ii++)
		{
			phySecId = RouteSecStru[ii].PhysicalSectionId;
			rLockId = GetPhySecRLockBelongRouteId(phySecId);
			lockState = GetPhySecLockState(phySecId);
			if ((PHYSICAL_SECTION_LOCK_NO == lockState) ||
				((PHYSICAL_SECTION_LOCK_NO != lockState) && (routeId != rLockId)))
			{ /*未锁闭或非本进路锁闭*/
			}
			else
			{
				reVal = CI_ERROR;
				break;
			}
		}	
	}
	
	return reVal;
}


/*
* 功能描述： 进路区段封锁无效检查
* 参数说明：
*            UINT16 routeId,    进路号
* 返回值  ： CI_ERROR    区段封锁有效
*            CI_SUCCESS  区段封锁无效
*/
UINT8 RouteSecFlockVainCheck(const UINT16 routeId)
{
    /*进路区段*/
    UINT8 const routeSecSum = GetRoutePhysicalSectionSum(routeId);
    RoutePhysicalSectionStruct* const pRouteSecDataBuf = GetRouteSectionData(routeId);
	UINT8 reVal = CI_SUCCESS;
    UINT16 ii = 0u;
	UINT8 fLockState= 0u;

    for (ii = 0u; ii < routeSecSum; ii++)
    {
		fLockState = GetPhySecFLockState(pRouteSecDataBuf[ii].PhysicalSectionId);
        if (PHYSICAL_SECTION_FLOCK_YES == fLockState)
        {
            /*有区段封锁*/

            /* 记录故障码 */
            SetErrorData(EFUNC_CHECK_ROUTE_SEC_FLOCK,CI_DEVICE_TYPE_PHYSEC,
                        pRouteSecDataBuf[ii].PhysicalSectionId,
                        ETYPE_PS_FLOCK_STATE,
                        PHYSICAL_SECTION_FLOCK_YES,
                        ESEND_LEVEL_ATS);

            reVal = CI_ERROR;
			break;
        }
    }

    return reVal;
}

/*
* 功能描述： 进路保护区段封锁无效检查
* 参数说明：
*            UINT16 routeId,    进路号
* 返回值  ： CI_ERROR    区段封锁有效
*            CI_SUCCESS  区段封锁无效
*/
UINT8 RouteOverlapSecFlockVainCheck(const UINT16 routeId)
{
    /*保护区段*/
    UINT16 const overlapLockId = GetRouteOverlapLockedId(routeId);
    UINT8 const overlapSecSum = GetOverlapPhySecSum(overlapLockId);
    UINT16* const pOverlapSecBuf = GetOverlapPhySecIdBuf(overlapLockId);
	UINT8 reVal = CI_SUCCESS;
    UINT16 ii = 0u;
	UINT8 fLockState= 0u;
	UINT8 routeLevel = 0u;
	routeLevel = GetRouteLevel(routeId);

    if ((overlapLockId > 0u) && (ROUTE_LEVEL_BLOC == routeLevel))
    {
        /*有保护区段锁闭的点式进路*/
        for (ii = 0u; ii < overlapSecSum; ii++)
        {
			fLockState = GetPhySecFLockState(pOverlapSecBuf[ii]);
            if (PHYSICAL_SECTION_FLOCK_YES == fLockState)
            {
                /*有区段封锁*/

                /* 记录故障码 */
                SetErrorData(EFUNC_CHECK_OLAP_SEC_FLOCK,CI_DEVICE_TYPE_PHYSEC,
                            pOverlapSecBuf[ii],
                            ETYPE_PS_FLOCK_STATE,
                            PHYSICAL_SECTION_FLOCK_YES,
                            ESEND_LEVEL_ATS);

                reVal = CI_ERROR;
				break;
            }
        }
    }
	return reVal;
}

/*
* 功能描述：进路有车接近处理
* 参数说明： const UINT16 routeId, 进路ID
* 返回值  ： SUCCESS：接近
*            ERROR：  不接近   
* by cgh 20231014 修改接近区段判断元素为逻辑区段
*/
UINT8 RouteHaveTrainNear(const UINT16 routeId)
{
    UINT8 routeLevel = 0U;        /*进路监督级别*/
	UINT8 secOccupyState = 0U;    /*区段占用状态*/
	UINT16 switchId = 0U;	/*道岔ID*/
	UINT8 switchPos = 0U;	/*道岔位置*/
	UINT8 ii = 0U;  /*遍历下标*/
	UINT8 jj = 0U;
    UINT8 kk = 0U;
	UINT8 isSwitchPosRight = 1U;	/*道岔位置是否正确 默认1为正确，0为错误*/
    UINT8 isSecOccupied = 1U;    /*区段是否有占用标志 默认1为未占用，0为占用*/
	UINT8 switchCurPosition = 0U;
	UINT8 nearCbtcSecConditionSum = 0U;	/*CBTC接近区段条件数量*/
	RouteNearLogicSectionStruct* nearLogicSecStru = NULL;	/*接近逻辑区段结构数组*/
	UINT8 nearBlocSecConditionSum = 0u;	/*点式接近区段条件数量*/
	RouteNearPhySectionStruct* nearPhySecStru=NULL;	/*接近物理区段结构数组*/
	UINT8 chReval = CI_SUCCESS;
	UINT8 chLogicSecSwitchSum = 0U;/*逻辑区段道岔数目*/
	LogsecSwitchStruct* pLogicSecSwitchIdData = NULL;/*逻辑区段道岔ID数据*/

	if ((0U == routeId) || (ROUTE_SUM_MAX <=routeId))
	{
		chReval = CI_SUCCESS;
	}
	else
	{
		chReval = CI_ERROR;
		routeLevel = GetRouteLevel(routeId);    /*获取进路监督级别*/

		if (ROUTE_LEVEL_CBTC == routeLevel)
		{ /*CBTC*/
			nearCbtcSecConditionSum = GetRouteCbtcNearSecConditionSum(routeId);	/*获取CBTC进路接近逻辑区段条件数目*/
			nearLogicSecStru = GetRouteCbtcNearLogSectionStru(routeId);	/*获取CBTC进路接近逻辑区段结构体*/

			if ((0U < nearCbtcSecConditionSum) && (ROUTE_NEARSEC_CONDITION_SUM_MAX >= nearCbtcSecConditionSum))
			{/*具有多组接近区段*/

				for (ii = 0U; ii < nearCbtcSecConditionSum; ii++)
				{/*分组遍历区段*/

					isSecOccupied = 1U;/*重置占用标志为未占用*/
					isSwitchPosRight = 1U;/*重置道岔位置标志为正确*/

					for (jj = 0U; jj < nearLogicSecStru[ii].NearLogicSecSum; jj++)
					{
						secOccupyState = GetLogSecCurOccupyState(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]);/*获取逻辑区段当前占用状态*/

						if (SECTION_OCCUPY_NO != secOccupyState)
						{/*遍历到区段非空闲，包含占用和接近区段在其他联锁*/
							isSecOccupied = 0U;/*设置该组接近存在区段占用*/
						}
						else
						{
							; /*不设置继续查找*/
						}

						chLogicSecSwitchSum = GetLogicSecSwitchSum(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]);
						pLogicSecSwitchIdData = GetLogicSecSwitchIdStru(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]);

						for (kk = 0U; kk < chLogicSecSwitchSum; kk++)
						{
							switchId = pLogicSecSwitchIdData[kk].SwitchId;
							switchPos = pLogicSecSwitchIdData[kk].SwitchPosition;
							switchCurPosition = GetSwitchCurPosition(switchId);

							if (SWITCH_POSITION_DINGWEI == switchPos)
							{
								/*规定定位*/
								if (SWITCH_POSITION_FANWEI == switchCurPosition)
								{/*道岔位置在反位*/

									isSwitchPosRight = 0U;/*设置道岔位置错误*/
								}
								else
								{/*道岔位置不在反位*/

									; /*位置正确 不设置标志*/
								}

							}
							else
							{
								if (SWITCH_POSITION_DINGWEI == switchCurPosition)
								{/*道岔位置在定位*/
									isSwitchPosRight = 0U;/*设置道岔位置错误*/
								}
								else
								{/*道岔位置不在定位*/

									; /*位置正确 不设置标志*/
								}
							}

						}
						if ((0U == isSecOccupied) || (0U == isSwitchPosRight))
						{/*如果满足占用条件或道岔位置错误，就中断该组循环*/
							break;
						}
					}/*该组接近遍历完成*/

					/*判断该组接近是否满足接近条件*/
					if ((0U == isSecOccupied) && (0U != isSwitchPosRight))
					{/*有区段占用 且占用区段之前的道岔位置均正确*/

						chReval = CI_SUCCESS;/*返回接近*/
						break;
					}
				}/*所有接近条件遍历*/
			}
			else
			{
				/*条件数目错误*/
				chReval = CI_SUCCESS;/*返回接近*/
			}
		}/*CBTC模式分支*/
		else
		{/*Bloc模式*/

			nearBlocSecConditionSum = GetRouteBlocNearSecConditionSum(routeId);	/*获取Bloc进路接近物理区段条件数目*/
			nearPhySecStru = GetRouteBlocNearPhySectionStru(routeId);	/*获取Bloc进路接近物理区段结构体*/

			if ((0U < nearBlocSecConditionSum) && (ROUTE_NEARSEC_CONDITION_SUM_MAX >= nearBlocSecConditionSum))
			{/*具有多组接近区段*/

				for (ii = 0U; ii < nearBlocSecConditionSum; ii++)
				{/*分组遍历区段*/

					isSecOccupied = 1U;/*重置占用标志为未占用*/
					isSwitchPosRight = 1U;/*重置道岔位置标志为正确*/

					for (jj = 0U; jj < nearPhySecStru[ii].BlocNearLogSecSum; jj++)
					{
						secOccupyState = GetLogSecCurOccupyState(nearPhySecStru[ii].BlocNearLogSecIdBuf[jj]);/*获取逻辑区段当前占用状态*/

						if (SECTION_OCCUPY_NO != secOccupyState)
						{/*遍历到区段非空闲，包含占用和接近区段在其他联锁*/

							isSecOccupied = 0U;/*设置该组接近存在区段占用*/
						}
						else
						{
							; /*不设置继续查找*/
						}

						chLogicSecSwitchSum = GetLogicSecSwitchSum(nearPhySecStru[ii].BlocNearLogSecIdBuf[jj]);
						pLogicSecSwitchIdData = GetLogicSecSwitchIdStru(nearPhySecStru[ii].BlocNearLogSecIdBuf[jj]);

						for (kk = 0U; kk < chLogicSecSwitchSum; kk++)
						{
							switchId = pLogicSecSwitchIdData[kk].SwitchId;
							switchPos = pLogicSecSwitchIdData[kk].SwitchPosition;
							switchCurPosition = GetSwitchCurPosition(switchId);

							if (SWITCH_POSITION_DINGWEI == switchPos)
							{
								/*规定定位*/
								if (SWITCH_POSITION_FANWEI == switchCurPosition)
								{/*道岔位置在反位*/

									isSwitchPosRight = 0U;/*设置道岔位置错误*/
								}
								else
								{/*道岔位置不在反位*/

									; /*位置正确 不设置标志*/
								}

							}
							else
							{
								if (SWITCH_POSITION_DINGWEI == switchCurPosition)
								{/*道岔位置在定位*/
									isSwitchPosRight = 0U;/*设置道岔位置错误*/
								}
								else
								{/*道岔位置不在定位*/

									; /*位置正确 不设置标志*/
								}
							}

						}

						if ((0U == isSecOccupied) || (0U == isSwitchPosRight))
						{/*如果满足占用条件或道岔位置错误，就中断该组循环*/
							break;
						}

					}/*该组接近遍历完成*/

					/*判断该组接近是否满足接近条件*/
					if ((0U == isSecOccupied) && (0U != isSwitchPosRight))
					{/*有区段占用 且占用区段之前的道岔位置均正确*/

						chReval = CI_SUCCESS;/*返回接近*/
						break;
					}

				}/*所有接近条件遍历*/
			}
			else
			{
				/*条件数目错误*/
				chReval = CI_SUCCESS;/*返回接近*/
			}
		}/*Bloc模式分支*/
	}
	return chReval;
}


/* 找到进路有效折返信号机 */
/*
* 功能描述： 找到进路有效折返信号机
* 参数说明： UINT16 const routeId 进路ID
* 返回值  ： UINT16 const setionId 区段ID
*            = 0 无效
*            > 0 信号机ID
*/
UINT16 GetValidReturnSinalId(UINT16 const routeId,UINT16 const setionId)
{
/* 局部变量定义初始化 */
    UINT16 i = 0u;           /* 循环变量 */
    UINT16 signalId = 0u;
    UINT16 signalOutSectionId = 0u;
    
/*进路区段数据*/
    UINT8 const returnSignalSum = GetRouteReturnSignalSum(routeId);
    UINT16* const pReturnSignalIdBuf = GetRouteReturnSignalIdBuf(routeId);
	UINT16 reVal = 0u;

    if (0u == returnSignalSum) 
    {
        /*无检查项*/
        reVal = 0u;
    }
    else
    {
        /*开始检查*/
		for (i = 0u; i < returnSignalSum; i++)
		{
			signalId = pReturnSignalIdBuf[i];
			signalOutSectionId = GetSignalOutFirstPhySecId(signalId);
			if ((0u < signalOutSectionId) && (signalOutSectionId == setionId))
			{
				/*折返信号机与折返区段匹配*/
				reVal = signalId;
				break;
			}
			else
			{
			    /*无操作*/
			}
		}
    }

    return reVal;
}

/*
功能描述: 	驱动进路内本地道岔处理
输入参数:	const UINT16 routeId 进路ID
输出参数:	const UINT8 DrivFlag 道岔驱动标志
返回值:		无
edit cgh 20241203
*/
void RouteDrvInnerSwitch(const UINT16 routeId, const UINT8 DrivFlag)
{
	UINT8 switchSum = 0u; 									/*道岔数目*/
	UINT16 switchId = 0u; 									/*道岔ID*/
	UINT8 switchExpPos = 0u; 								/*道岔期望位置*/
	RouteSwitchStruct* routeSwitchStru = NULL; 				/*道岔数据*/
    UINT8 ii = 0u;											/*循环变量*/
	UINT8 routeProtectSwitchSum = 0u; 							/*防护道岔数目*/
	UINT8 funRtn = CI_ERROR;
	RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL;    /*防护道岔数据*/
	UINT8 chLocalCiId = 0U;/*本地联锁ID*/
	UINT8 chSwitchBelCiId = 0U;/*道岔所属联锁*/

	switchSum = GetRouteSwitchSum(routeId); /*获取进路道岔数目*/
	routeSwitchStru = GetRouteSwitchData(routeId); /*获取进路内道岔数据*/
	routeProtectSwitchSum = GetRouteRelatedProtectSwitchSum(routeId);/*获取防护道岔数目*/
	pRouteProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId);/*获取防护道岔数据*/

	if(SWITCH_NEED_DRIV_TRUE == DrivFlag)
	{/*需要驱动进路内道岔*/
		chLocalCiId = GetSystemParaLocalCiId();       /*获取本机联锁ID*/
		for(ii = 0u; ii < switchSum; ii++)
		{
			switchId = routeSwitchStru[ii].SwitchId;
			chSwitchBelCiId = GetSwitchBelongCiId(switchId);
			if ((chLocalCiId == chSwitchBelCiId) && (0U != chLocalCiId))
			{
				switchExpPos = routeSwitchStru[ii].SwitchPosition;
				(void)SwitchDriveProcess(switchId, switchExpPos); /*设置进路内道岔的驱动状态为驱动中*/
			}
			else
			{
				;
			}
			
		}

		for(ii = 0u; ii < routeProtectSwitchSum; ii++)
		{
			switchId = pRouteProtectSwitchStru[ii].ProtectSwitchId;
			chSwitchBelCiId = GetSwitchBelongCiId(switchId);
			if ((chLocalCiId == chSwitchBelCiId) && (0U != chLocalCiId))
			{
				switchExpPos = pRouteProtectSwitchStru[ii].ProtectPosition;
				(void)SwitchDriveProcess(switchId, switchExpPos); /*设置进路关联防护道岔的驱动状态为驱动中*/
			}
			else
			{
				;
			}
		}
	}
}

/*
功能描述: 	驱动进路带动道岔处理
输入参数:	const UINT16 routeId 进路ID
	        		UINT8 DrivFlag 道岔驱动标志
输出参数:	无
返回值:		无
*/
void RouteDrvAssocSwitch(const UINT16 routeId, const UINT8 DrivFlag)
{
	UINT16 switchId = 0u; 									/*道岔ID*/
	UINT8 switchExpPos = 0u; 								/*道岔期望位置*/
	UINT8 switchSum = 0u; 									/*道岔数目*/
    UINT8 ii = 0u;											/*循环变量*/
	UINT8 funRtn = CI_ERROR;
	RouteAssocSwitchStruct routeAssocSwitchStru = {0,0}; 			/*带动道岔数据*/

	switchSum = GetRouteAssocSwitchSum(routeId); /*获取进路带动道岔数目*/

	if(SWITCH_NEED_DRIV_TRUE == DrivFlag)
	{/*需要驱动带动道岔*/
		for(ii = 0u; ii < switchSum; ii++)
		{
			GetRouteAssocSwitchData(routeId, ii, &routeAssocSwitchStru);/*获取带动道岔数据*/

			switchId = routeAssocSwitchStru.SwitchId;
			switchExpPos = routeAssocSwitchStru.SwitchPosition;

			funRtn = SwitchDriveProcess(switchId, switchExpPos); /*设置道岔期望驱动位置*/
		}
	}
}

/*
功能描述: 	进路锁闭驱动本联锁道岔处理
输入参数:	const UINT16 routeId 进路ID
	         		const UINT8 NeedForDrvRoutAssoSwit 是否需要驱动带动道岔
输出参数:	无
返回值:		CI_SUCCESS,如果道岔锁闭处理成功
			CI_ERROR,如果道岔锁闭处理失败
edit cgh 20241203
*/
UINT8 RouteLockDriveSwitch(const UINT16 routeId, const UINT8 NeedForDrvRoutAssoSwit)
{
    UINT8 ii = 0u;
	UINT8 switchSum = 0u;
	UINT16 switchId = 0u;
	UINT8 switchExpPosition = SWITCH_POSITION_INVALID;			/*道岔期望位置*/
    UINT8 switchDancaoPosition = SWITCH_POSITION_INVALID; 		/*单操有效位置*/
	RouteSwitchStruct* pRouteSwitchStru = NULL;					/*道岔数据结构指针*/
	UINT8 innerSwitchRetVal = CI_ERROR;							/*检查进路内道岔是否可被驱动的结果*/
	UINT8 assocSwitchRetVal = CI_ERROR; 						/*检查带动道岔是否可被驱动的结果*/
	UINT8 assocSwitchSum = 0u; 									/*道岔数目*/
	RouteAssocSwitchStruct routeAssocSwitchStru = {0,0}; 		        /*道岔数据*/
	UINT8 routeProtectSwitchSum = 0u; 							/*防护道岔数目*/
	RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL;    /*防护道岔数据*/
	UINT8 chAutoCheck = 0U;
	UINT8 chSendLevel = 0U;
	chAutoCheck = AutoSignalOrRouteValid(routeId);
	if (chAutoCheck == CI_SUCCESS)
	{
		/*自动进路或自动信号不发送ATS*/
		chSendLevel = ESEND_LEVEL_ZERO;
	}
	else
	{
		chSendLevel = ESEND_LEVEL_ATS;
	}

	if((0u == routeId) || (routeId >= ROUTE_SUM_MAX))
	{
		innerSwitchRetVal = CI_ERROR;
	}
	else
	{
		innerSwitchRetVal = RouteLockSwitchDanCaoCheck(routeId);

		if(SWITCH_NEED_DRIV_TRUE == NeedForDrvRoutAssoSwit)
		{/*进路带动道岔需要被驱动*/
			assocSwitchRetVal = CI_SUCCESS;

			assocSwitchSum = GetRouteAssocSwitchSum(routeId); /*获取进路带动道岔数目*/

			for (ii = 0u; ii < assocSwitchSum; ii++)
			{
				/*获取带动道岔数据*/
				GetRouteAssocSwitchData(routeId, ii, &routeAssocSwitchStru);

				switchId = routeAssocSwitchStru.SwitchId;
				switchExpPosition = routeAssocSwitchStru.SwitchPosition;

				switchDancaoPosition = GetSwitchDanCaoPostition(switchId);

				if(	(SWITCH_POSITION_INVALID == switchDancaoPosition)
					||
					(switchDancaoPosition == switchExpPosition))
				{
					/*单操无效 或者 单操位置与动作位置一样*/
					assocSwitchRetVal = CI_SUCCESS;
				}
				else
				{
					/*单操到相反位置*/
					assocSwitchRetVal = CI_ERROR;
					/*设置本进路带动道岔已被单操过*/
					SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_TRUE);
					/*如果有一个带动道岔不可驱动,则无需再遍历*/					
					break;
				}

			}
		}

		if(CI_SUCCESS == innerSwitchRetVal)
		{
			/*驱动进路道岔*/
			RouteDrvInnerSwitch(routeId, SWITCH_NEED_DRIV_TRUE);
		}
		else
		{
			RouteDrvInnerSwitch(routeId, SWITCH_NEED_DRIV_FALSE);
			/*增加道岔单操位置不同报警*/
			SetErrorData(EFUNC_ROUTE_LOCK_DRIVE_SWITCH,CI_DEVICE_TYPE_ROUTE,routeId, ETYPE_ROUTE_APPLY_SWITCH_MOVE,0U, chSendLevel);
		}

		if((CI_SUCCESS == assocSwitchRetVal) && (CI_SUCCESS == innerSwitchRetVal))
		{
			/*驱动带动道岔*/
			RouteDrvAssocSwitch(routeId, SWITCH_NEED_DRIV_TRUE);
		}
		else
		{
			RouteDrvAssocSwitch(routeId, SWITCH_NEED_DRIV_FALSE);
		}

	}

    return innerSwitchRetVal;
}


/*
* 功能描述： 列车驶入进路状态
* 参数说明： const UINT16 routeId, 进路ID
* 返回值  ： CI_ERROR; CI_SUCCESS  
* edit cgh 20250113
*/
UINT8 GetTrainEnteringRouteState(const UINT16 routeId)
{
	RoutePhysicalSectionStruct* routePhySecData = NULL;
	UINT8 reVal = CI_ERROR;
	UINT8 chInPhySecCurMergeState = 0U;
	UINT8 chRouteState = 0U;

	if ((0U < routeId) && (ROUTE_SUM_MAX > routeId))
	{	
		chRouteState = GetRouteState(routeId);

		if (ROUTE_STATE_NEAR_OPEN != chRouteState)
		{
			;
		}
		else
		{
			routePhySecData = GetRouteSectionData(routeId);

			if (NULL != routePhySecData)
			{
				chInPhySecCurMergeState = GetPhySecCurMergeState(routePhySecData[0].PhysicalSectionId);
				if (SECTION_OCCUPY_YES == chInPhySecCurMergeState)
				{
					/*只检查内方第一区段，无需检查内外方区段，适配高速跨压场景，内方占压，等码位*/
					reVal = CI_SUCCESS;
				}
				else
				{
					reVal = CI_ERROR;
				}
			}
			else
			{
				;
			}
		}
	}
	else
	{
		; 
	}
	
	return reVal;
}

/*
* 功能描述： 检查进路逻辑区段已全部解锁
* 参数说明： UINT16 routeId 进路号
*	返回值：1：是
*         0: 否
*/	
UINT8 CheckRouteLogSecHaveUnLock(const UINT16 routeId)
{
	/* 局部变量定义初始化 */
	UINT16 i = 0u;           /* 循环变量 */
	UINT16 belongRouteId = 0u;
	UINT8  logLockState = 0u;
	UINT8 reVal = CI_ERROR;
	UINT16 routeLogNum = 0u;
	UINT16* routeLogIdBuf = NULL;

	/*获取进路逻辑区段数据*/
	routeLogNum = GetRouteLogSectionSum(routeId);
	routeLogIdBuf = GetRouteLogSectionIdBuf(routeId);

	/*进路的逻辑区段数据合法*/
	if(0u < routeLogNum)
	{
		for(i = 0u; i < routeLogNum; i++)
		{
			belongRouteId = GetLogSecLockBelongRoute(routeLogIdBuf[i]);
			/*获取锁闭状态*/
			logLockState = GetLogSecLockState(routeLogIdBuf[i]);
			/*未正常锁闭、或锁闭所属进路不为本进路*/
			if((LOG_SECTION_LOCK_NO == logLockState) || ((LOG_SECTION_LOCK_NO != logLockState) &&
				(belongRouteId != routeId)))
			{
				/*返回成功*/
				reVal = CI_SUCCESS;
			}
			else
			{
				/*返回失败*/
				reVal = CI_ERROR;
				break;
			}
		}
	}
	else
	{
		reVal = CI_ERROR;
	}
	return(reVal);
}


/*
* 功能描述： 设置物理区段包含的逻辑区段锁闭状态
* 参数说明： UINT16 routeId 进路
*	返回值：1：是
*         0: 否
*/
void SetPhyIncludeLogLockState(const UINT16 phyId, const UINT8 lockState,const UINT16 routeId)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 alexSum = 0u; 
	UINT16* axisIdBuf = NULL;
	UINT8 logSectionSum = 0u;
	UINT16* logIdBuf = NULL;
	UINT16 logBelongRoute = 0u;
	UINT8 routeDir = 0u;

	/*获取物理区段信息*/
	alexSum = GetPAxisSectionSum(phyId);
	axisIdBuf = GetPAxisSectionIdBuf(phyId);

	/*计轴区段信息正确*/
	if(0u < alexSum) 
	{
		for(i = 0u; i < alexSum; i++)
		{
			/*获取逻辑区段信息*/
			logSectionSum = GetAxisSecLogSectionSum(axisIdBuf[i]);
			logIdBuf = GetAxisSecLogSectionIdBuf(axisIdBuf[i]);
			/*逻辑区段信息正确*/
			if((0u < logSectionSum) && (NULL != logIdBuf))
			{
				for(j = 0u; j < logSectionSum; j++)
				{
					/*获取逻辑区段锁闭所属进路*/
					logBelongRoute = GetLogSecLockBelongRoute(logIdBuf[j]);
					routeDir = GetRouteDirection(logBelongRoute);
					/*锁闭所属进路相等*/
					if(logBelongRoute == routeId)
					{
						/*设置对应的逻辑区段锁闭状态*/
						SetLogSecLockState(logIdBuf[j],lockState,routeId,routeDir);
					}
					else
					{
						/*不做处理*/
					}
				}
			}
			else
			{
			    /*无操作*/
			}
		}
	}
	else
	{
	}
}

/*
* 功能描述： 检查物理区段内的逻辑区段已全部解锁
* 参数说明： UINT16 routeId 进路号
*	返回值：CI_SUCCESS：全部解锁
*           CI_ERROR: 存在本进路的锁闭逻辑区段
*/	
UINT8 CheckPhyInLogUlock(const UINT16 phyId, const UINT16 routeId, UINT16* belongRoute)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 alexSum = 0u; 
	UINT16* axisIdBuf = NULL;
	UINT8 logSectionSum = 0u;
	UINT16* logIdBuf = NULL;
	UINT16 logBelongRoute = 0u;
	UINT8 logLockState = 0u;
	UINT8 reVal = CI_ERROR;

	/*获取计轴区段数据*/
	alexSum = GetPAxisSectionSum(phyId);
	axisIdBuf = GetPAxisSectionIdBuf(phyId);

	/*计轴区段信息正确*/
	if(0u < alexSum) 
	{
		for(i = 0u; i < alexSum; i++)
		{
			/*获取逻辑区段信息*/
			logSectionSum = GetAxisSecLogSectionSum(axisIdBuf[i]);
			logIdBuf = GetAxisSecLogSectionIdBuf(axisIdBuf[i]);
			/*逻辑区段信息正确*/
			if((0u < logSectionSum) && (NULL != logIdBuf))
			{
				for(j = 0u; j < logSectionSum; j++)
				{
					/*获取逻辑区段锁闭所属进路、 锁闭状态*/
					logBelongRoute = GetLogSecLockBelongRoute(logIdBuf[j]);
					logLockState = GetLogSecLockState(logIdBuf[j]);

					/*未锁闭，或锁闭不属于进路*/
					if(LOG_SECTION_LOCK_NO == logLockState) 
					{
						/*返回成功*/
						reVal = CI_SUCCESS;
					}
					/*存在锁闭状态*/
					else
					{
						/*锁闭不是本进路*/
						if(logBelongRoute != routeId)
						{
							*belongRoute = logBelongRoute;
							reVal = CI_SUCCESS;
						}
						else
						{
							/*返回失败*/
							reVal = CI_ERROR;
							break;
						}
					}
				}
			}
			else
			{
			    /*无操作*/
			}
			if(CI_ERROR == reVal)
			{
				/*不再循环*/
				break;
			}
			else
			{
			    /*无操作*/
			}
		}
	}
	return(reVal);
}
/******************************信号机数据交叉管理****************************/

/*
* 功能描述： 驱动信号机开放
* 参数说明： const UINT16 signalId , 信号机ID
*			 const UINT16 routeId , 进路ID
* 返回值  ： 0:失败
*			 1:成功 
*/
void DriveSignalOpen(const UINT16 signalId, const UINT16 routeId)
{
    UINT8 lightExtinctState = 0u;/*信号机亮灭信息*/
	UINT8 driveColor = 0u;		/*驱动信号开放颜色*/
	UINT8 oriDriveColor = 0u;    /*进路本应驱动信号开放颜色*/
	UINT8 routeLeadProperty = 0u;	/*进路引导属性*/
	UINT8 routeState = 0u;			/*进路状态*/
    UINT8 allSignalBrightFlag = 0u;  /*全站亮灯标志*/
	UINT16 routeEndSignalId = 0u;		/*进路终端信号机ID*/
	UINT8 routeEndSignalShowColour = 0u;	/*进路终端信号机显示颜色*/
	UINT8 routeLevel = 0u;

	/*by hanxiao 20170308*/
	/*进路相关需开放信号机*/
	UINT8 needOpenSigSum = 0u;
	UINT16* pNeedOpenBuf = NULL;

	UINT16 devId = 0u;/*开放需开放信号机设备ID*/
	UINT8  sigColor = 0u;/*信号机当前颜色*/
	UINT16 ii = 0u;
	UINT16 statrSigRtSum = 0u;
	UINT16 *startSigRouteBuf = NULL;
	UINT16 tmpRtId = 0u;
	UINT8 tmpRtState = 0u;
	UINT8 sigOpen = 0u;

	UINT8 bCiSwitchShowGreenYellow = FUNC_SWITCH_OFF;/*ci显示绿黄开关,默认是关闭的*/
	UINT8 belongVirCI= 0u;
	UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 sigalMaintainState = 0u;
	UINT8 signalIsfushiFlag = 0u;
	UINT8 signalCurDriveColor = 0u;

	routeLevel = GetRouteLevel(routeId);  /*获取进路级别*/
	if(ROUTE_LEVEL_BLOC == routeLevel)
	{
		needOpenSigSum = GetRouteOpenNeedOpenSigSum(routeId);
        pNeedOpenBuf = GetRouteOpenNeedOpenSigIdBuf(routeId);
	}
	else if(ROUTE_LEVEL_CBTC == routeLevel)
	{
		needOpenSigSum = GetRouteCbtcNeedOpenSigSum(routeId);
		pNeedOpenBuf = GetRouteCbtcNeedOpenSigIdBuf(routeId);
	}
	else
	{
		/*异常值，不处理*/
	}

	if(1u == needOpenSigSum)
	{
		devId = pNeedOpenBuf[0];
	}
	else
	{
		/*开放需开放信号机配置最多只有1个*/
	}

	if ((0u < devId) && ( SIGNAL_SUM_MAX > devId))
	{/*开放需开放信号机ID有效则获取当前颜色*/
		sigColor = GetSignalCurColor(devId);
	}
	else
	{
		/*无操作*/
	}
	oriDriveColor = GetRouteSignalOpenColor(routeId);
    if ((0u == signalId) || (SIGNAL_SUM_MAX <= signalId))
    {
        /*不做处理*/
    }
	else
	{
		routeLeadProperty = GetRouteLeadProperty(routeId);/*获取进路引导属性*/
		routeState = GetRouteState(routeId);/*获取进路状态*/

		if (((ROUTE_LEAD_PROPERTY_YES == routeLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == routeLeadProperty))
			&& ((ROUTE_STATE_LEAD_LOCK == routeState)
				|| (ROUTE_STATE_LEAD_LOCKERR == routeState)
				|| (ROUTE_STATE_LEAD_OPEN == routeState)))
		{/*进路为可引导，且进路状态为<引导锁闭>或<引导锁闭异常>或<引导开放>*/

			driveColor = GetRouteLeadSignalOpenColor(routeId);/*引导进路开放颜色*/
		}
		else
		{
			if ((0u != devId)&&(SIGNAL_VIRTUAL_YES == GetSignalVirtualAttr(devId)) && (SIGNAL_OPEN == GetSignalOpenCloseState(sigColor)))
			{/*如果信号机是虚拟信号机 并且 开放需开放信号机颜色为信号开放颜色*/
				/*查找以该信号机为始端的进路，获取进路开放颜色*/
				statrSigRtSum = GetStartSignalRouteSum(devId);/*获取以该信号机为始端信号机的进路数目*/
				startSigRouteBuf = GetStartSignalRouteBuf(devId);/*获取以该信号机为始端信号机的进路数组*/
				if ((0u != statrSigRtSum) && (NULL != startSigRouteBuf))
				{
					for (ii = 0u;ii < statrSigRtSum;ii++)
					{/*查找以信号机为始端信号机的开放的进路ID*/
						tmpRtId = startSigRouteBuf[ii];
						tmpRtState = GetRouteState(tmpRtId);/*获取进路状态*/
						if ((ROUTE_STATE_YUXIAN_OPEN == tmpRtState) || (ROUTE_STATE_NEAR_OPEN == tmpRtState))
						{/*找到开放的进路则退出*/
							driveColor = GetRouteSignalOpenColor(tmpRtId);
							break;
						}
						else
		            	{
			                /*无操作*/
			            }
					}
				}
				else
			    {
			        /*无操作*/
			    }
				
			}
			else
			{
				driveColor = GetRouteSignalOpenColor(routeId);/*非引导进路开放颜色*/
			}
		}

	    /*虚拟联锁兼容*/
		if(FUNC_SWITCH_ON == includeVirFlag)
		{
			belongVirCI = GetSignalBelongVirCiId(signalId);
			allSignalBrightFlag = GetVirCIAllSignalBrightState(belongVirCI);/*本虚拟联锁全站亮灯标志*/
		}
		else
		{
			allSignalBrightFlag = GetAllSignalBrightFlag();  /*全站亮灯标志*/
		}
		
		lightExtinctState = GetSignalLightExtinctState(signalId);/*信号机亮灭状态*/
		sigalMaintainState = GetSignalMaintainState(signalId);/*信号机维修点灯状态*/
		
		signalIsfushiFlag = GetSignalIsfushiFlag(signalId);
		signalCurDriveColor = GetSignalCurDriveColor(signalId);
		if ((SIGNAL_DRIVECOLOUR_NULL == signalCurDriveColor)&&(SIGNALTYPE_FUSHI_YES != signalIsfushiFlag))/*驱开放增加是否复示防护逻辑，避免数据配错导致的异常情况*/
		{
			/*未驱动过信号机可开放*/

			switch (driveColor)
			{
				case SIGNAL_SHOWCOLOUR_GREEN:/*绿灯*/
					{
						/*绿灯*/
						if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) ||
							(SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState)||
							(MAINTAIN_STATE_YES == sigalMaintainState)
							)
						{/*亮灯信息*/
							if (SIGNAL_SHOWCOLOUR_GREEN == oriDriveColor)
							{
								SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_GREEN);
							} 
							else if (SIGNAL_SHOWCOLOUR_YELLOW == oriDriveColor)
							{
								SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_YELLOW);
							}
							else
							{
								SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);
							}
						}
						else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState)
						{/*灭灯信息*/
							if (SIGNAL_SHOWCOLOUR_GREEN == oriDriveColor)
							{
								SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_GREENCLOSE);
							} 
							else if (SIGNAL_SHOWCOLOUR_YELLOW == oriDriveColor)
							{
								SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_YELLOWCLOSE);
							}
							else
							{
								SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE);
							}
						}

						else
						{/*未收到或收到错误的亮灭信息*/

							SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);
						}	
					}
					break;

				case SIGNAL_SHOWCOLOUR_YELLOW:/*黄灯*/
					{
						/*黄灯*/
						if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) ||
							(SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState)||
							(MAINTAIN_STATE_YES == sigalMaintainState)
							)
						{/*亮灯信息*/

							SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_YELLOW);
						}
						else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState)
						{/*灭灯信息*/

							SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_YELLOWCLOSE);
						}
						else
						{/*未收到或收到到错误的亮灭信息*/

							SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);
						}		
					}
					break;

				case SIGNAL_SHOWCOLOUR_REDYELLOW:/*红黄灯*/
					/*红黄灯*/
					SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDYELLOW);	
					break;
					
				case SIGNAL_SHOWCOLOUR_WHITE:/*白灯*/
					/*白灯*/
					SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_WHITE);
					break;
				case SIGNAL_SHOWCOLOUR_RED_WHITE:/*红白灯*/
					/*红白灯*/
					SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED_WHITE);
					break;

				case SIGNAL_SHOWCOLOUR_GREEN_OR_GREENYELLOW:/*绿或者绿黄 for武汉*/
					{
						/*在此做特殊处理，需要根据终端信号机颜色确定进路开放驱动颜色(绿还是绿黄)*/
						routeEndSignalId = GetRouteEndSignalId(routeId);/*获取进路终端信号机ID*/
						routeEndSignalShowColour = GetSignalCurColor(routeEndSignalId);/*获取进路终端信号机显示颜色*/
						bCiSwitchShowGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*显示绿黄功能开关是否打开*/
						if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) ||
							(SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState)||
							(MAINTAIN_STATE_YES == sigalMaintainState)
							)
						{/*亮灯信息 后备模式*/
							if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)
							{/*功能打开*/
								if ( (SIGNAL_SHOWCOLOUR_GREEN == routeEndSignalShowColour) || 
									 (SIGNAL_SHOWCOLOUR_GREENYELLOW == routeEndSignalShowColour)||
									 (SIGNAL_SHOWCOLOUR_YELLOW == routeEndSignalShowColour)
									)/*进路终端信号机颜色为绿灯或者绿黄或黄灯，则始端为绿灯*/
								{
									SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREEN);/*驱绿灯*/
								}
								else if (SIGNAL_SHOWCOLOUR_RED == routeEndSignalShowColour)/*进路终端信号机颜色为红灯，则始端为绿黄*/
								{
									SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREENYELLOW);/*驱绿黄*/
								}
								else
								{
									SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREENYELLOW);/*非法值按照红灯处理驱绿黄*/
								}
							}
							else
							{
								/*功能未打开什么都不做*/
							}
						}
						else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState)
						{/*灭灯信息 CBTC模式*/
							if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)
							{/*功能打开*/
								sigOpen = GetSignalOpenCloseState(routeEndSignalShowColour);
								if (SIGNAL_OPEN == sigOpen)
								{/*如终端信号机显示颜色为开放*/
									SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREENCLOSE);/*驱绿灭*/
								}
								else	
								{
									SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE);/*驱绿黄灭*/
								}								
							}
							else
							{
								/*功能未打开什么都不做*/
							}
						}
						else
						{/*未收到或收到错误的亮灭信息*/

							SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);
						}	
						break;
					}

				case SIGNAL_SHOWCOLOUR_GREEN_OR_YELLOW:/*绿或者黄 for武汉*/
					{
						/*在此做特殊处理，需要根据终端信号机颜色确定进路开放驱动颜色(绿还是黄)*/
						routeEndSignalId = GetRouteEndSignalId(routeId);/*获取进路终端信号机ID*/
						routeEndSignalShowColour = GetSignalCurColor(routeEndSignalId);/*获取进路终端信号机显示颜色*/
						
						sigOpen = GetSignalOpenCloseState(routeEndSignalShowColour);/*获取进路终端信号机开放关闭状态*/

						bCiSwitchShowGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*显示绿黄功能开关是否打开*/

						if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) ||
							(SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState)||
							(MAINTAIN_STATE_YES == sigalMaintainState)
							)
						{/*亮灯信息 后备模式*/
							if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)
							{/*功能打开*/
								if (SIGNAL_OPEN != sigOpen)/*进路终端信号机不为开放*/
								{
									SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_YELLOW);/*驱黄灯*/
								}
								else 
								{
									SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREEN);/*驱绿灯*/
								}
							}
							else
							{
								/*功能未打开什么都不做*/
							}
						}
						else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState)
						{/*灭灯信息 CBTC模式*/
							if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)
							{/*功能打开*/
								sigOpen = GetSignalOpenCloseState(routeEndSignalShowColour);
								if (SIGNAL_OPEN != sigOpen)
								{/*如终端信号机显示颜色不为开放*/
									SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_YELLOWCLOSE);/*驱黄灭*/
								}
								else	
								{
									SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREENCLOSE);/*驱绿灭*/
								}								
							}
							else
							{
								/*功能未打开什么都不做*/
							}
						}
						else
						{/*未收到或收到错误的亮灭信息*/

							SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);
						}	
					}
					break;
				case SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW:/*双黄 for武汉*/
					{
						SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW);/*驱动双黄*/
						break;
					}

				case SIGNAL_SHOWCOLOUR_DOUBLE_GREEN:/*双绿 for武汉*/
					{
						SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_DOUBLE_GREEN);/*驱动双绿*/
						break;
					}

				default:
					/*非定义的驱动颜色*/
					if ((CI_ALL_SIGNAL_BRIGHT_NO == allSignalBrightFlag) &&
						(SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState)&&
						(MAINTAIN_STATE_NO == sigalMaintainState)
						)
					{/*信号机不处于全站点灯且处于灭灯状态且不处于单个维修点灯状态*/
						SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE);		
					}
					else
					{
						SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);
					}
					break;
			}
			
		}
		else
		{	
			/*不做处理*/
		}
	}
}

/*
* 功能描述： 驱动信号机关闭
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0:失败
*			 1:成功   
*/
UINT8 DriveSignalClose(const UINT16 signalId)
{
	UINT8 lightExtinctState = 0u;
    UINT8 allSignalBrightFlag = 0u;  /*全站亮灯标志*/
	UINT8 reVal = CI_SUCCESS;
	UINT8 belongVirCIid = 0u;
	UINT8 detainOpenRedBright = 0u;        
	UINT8 signalDetainFlag = 0u;
	UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 sigalMaintainState = 0u;
	UINT8 signalIsfushiFlag = 0u;
	UINT16 wSigInFirstPhyId = 0U;
	UINT16 routeId = 0U;
	UINT8 routeLeadProperty = 0U;
	UINT8 routeState = 0U;
	UINT16 wStartSignalId = 0u;
    if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX))
    {
		reVal = CI_ERROR;
    }
	else
	{
	    /*虚拟联锁兼容*/
		if(FUNC_SWITCH_ON == includeVirFlag)
		{
			belongVirCIid = GetSignalBelongVirCiId(signalId);
			allSignalBrightFlag = GetVirCIAllSignalBrightState(belongVirCIid); /*全站亮灯标志*/	
		}
		else
		{
			allSignalBrightFlag = GetAllSignalBrightFlag();  /*全站亮灯标志*/
		}
		/*无论什么时候，复示信号机关闭都驱动红灭*/
		signalIsfushiFlag = GetSignalIsfushiFlag(signalId);
		if (SIGNALTYPE_FUSHI_YES == signalIsfushiFlag)
		{
			/*是复视信号机则驱动红灭*/
			SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE);
		}
		else
		{
			/*否则按照亮灭灯和扣车功能开关判断驱动信号机关闭颜色*/
			lightExtinctState = GetSignalLightExtinctState(signalId);
			sigalMaintainState = GetSignalMaintainState(signalId);/*信号机维修点灯状态*/
			wSigInFirstPhyId = GetSignalInFirstPhySecId(signalId, routeId);
			routeId = GetPhySecRLockBelongRouteId(wSigInFirstPhyId);
			routeLeadProperty = GetRouteLeadProperty(routeId);/*获取进路引导属性*/
			routeState = GetRouteState(routeId);/*获取进路状态*/
			wStartSignalId = GetRouteStartSignalId(routeId);

			if (((ROUTE_LEAD_PROPERTY_YES == routeLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == routeLeadProperty))
				&& ((ROUTE_STATE_LEAD_LOCK == routeState)
					|| (ROUTE_STATE_LEAD_LOCKERR == routeState)
					|| (ROUTE_STATE_LEAD_OPEN == routeState))
				&& (wStartSignalId == signalId))
			{/*进路为可引导，且进路状态为<引导锁闭>或<引导锁闭异常>或<引导开放>*/

				SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);/*引导进路关闭颜色*/
			}
			else if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) ||
				(SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState) ||
				(MAINTAIN_STATE_YES == sigalMaintainState)
				)
			{/*亮灯信息*/

				SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);
			}
			else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState)
			{/*灭灯信息*/
				detainOpenRedBright = GetCiFunctionSwitchConfig(FUNC_DETAIN_OPEN_RED);
				if (FUNC_SWITCH_ON == detainOpenRedBright)
				{  /*配置了扣车后开放红灯*/
					signalDetainFlag = GetSignalDetainFlag(signalId);
					if (SIGNAL_DETAIN_NO == signalDetainFlag)
					{
						SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE);
					}
					else
					{
						SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);
					}

				}
				else
				{
					SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE);
				}
			}
			else
			{/*未收到或受到错误的信号机亮灭信息*/

				SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);
			}
		}
	}

	
	return reVal;
}

/******************************道岔数据交叉管理****************************/


/*
* 功能描述： 道岔可提前动作有效性检查
* 参数说明： UINT16 switchId，道岔Id
*			 UINT8	oper_src,操作来源
*			 UINT8 sendLevel，发送级别
* 返回值  ： CI_SUCCESS: 更新失败
*			 CI_ERROR: 更新成功
* add 20221009 适配进路可提前扳动道岔功能
*/
UINT8 GetSwitchMoveEarlyValidState(UINT16 switchId, UINT8	oper_src, UINT8 sendLevel)
{
	UINT8	reVal = CI_ERROR;
#if 0
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CHECK_SWITCH_MOVE;

	/*局部变量*/
	/*本联锁类型*/
	UINT8 ciType = 0u;
	/*道岔属性*/
	UINT8   switchType = 0u;
	/*道岔1*/
	UINT16  switch1stSecId = 0u;
	UINT8   switch1stLockStatus = 0u;
	UINT8   switch1stYLockState = 0u;
	UINT8   switch1stSecOccuState = 0u;
	UINT8   switch1stSecLockState = 0u;
	UINT8   switch1stSecMerOccuState = 0u;
	UINT8   arbState = 0u;
	UINT8   switch1stSecJumpLockState = 0u;
	UINT8	switch1stSecFLockState = 0u;/*道岔1道岔区段封锁状态*/
										/*道岔2*/
	UINT16  switch2ndId = 0u;
	UINT16  switch2ndSecId = 0u;
	UINT8   switch2ndLockStatus = 0u;
	UINT8   switch2ndYLockState = 0u;
	UINT8   switch2ndSecOccuState = 0u;
	UINT8   switch2ndSecLockState = 0u;
	UINT8   switch2ndSecMerOccuState = 0u;
	UINT8	ARBMoveSwitchFlag = 0u;
	UINT8   switch2ndSecJumpLockState = 0u;
	UINT8	switch2ndSecFLockState = 0u;/*道岔2道岔区段封锁状态*/
	UINT8	vobcInterface = 0u;/*vobc接口标识*/
	UINT8	localCiType = 0u;	/*ci类型*/
	UINT8	vobcInerface = 0u;/*vobc接口*/
	UINT8   gdDLline = 0u; /*轨道电路标识*/
	UINT8   logLockState = 0u; /*逻辑区段锁闭*/
	UINT8   logOccState = 0u;  /*逻辑区段占用检查*/
	UINT16  logOccOrLockId = 0u;
	UINT8 logState = 0u;

	/* 道岔检查 */
	switch1stSecId = GetSwitchPhySectionId(switchId);
	switch1stLockStatus = GetSwitchLockStatus(switchId);
	switch1stYLockState = GetSwitchYLockState(switchId);
	switch1stSecMerOccuState = GetPhySecCurMergeState(switch1stSecId);
	switch1stSecFLockState = GetPhySecFLockState(switch1stSecId);/*获取道岔1道岔区段封锁状态*/
	ciType = GetLocalCiType();
	/*判断是否采用轨道电路*/
	gdDLline = GetCiFunctionSwitchConfig(FUNC_CLD_GD_DIANLU_LINE);

	if ((JkjRelayId > 0u) && (JKJ_REYLAY_VALID == JkjRelayValid) && (CI_TYPE_CLD == ciType))
	{/*应急盘继电器有效状态*/
		SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, JkjRelayId, ETYPE_JKJ_WORK, RELAY_STATE_DOWN, ESEND_LEVEL_ATS);
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
	}
	vobcInerface = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);

	if (((LINE_FAO == vobcInerface) || (LINE_HLHT == vobcInerface) || (LINE_FAOHLHT == vobcInerface) || (LINE_FAOHLHT_ONESELF == vobcInerface)|| (LINE_FAOHLHT_ONESELFSECOND == vobcInerface))
		&& (CI_TYPE_CLD == ciType) && (FUNC_SWITCH_ON == gdDLline))
	{/*如果是FAO线路或FALHLHT线路 车辆段 使用轨道电路，直接使用与占用原则融合后状态来处理道岔*/
		switch1stSecOccuState = GetPhySecCurAndMergeState(switch1stSecId);
	}
	else
	{/*其他场景：正线、或者是使用计轴设备均使用GJ处理*/
		switch1stSecOccuState = GetPhySecCurOccupyState(switch1stSecId);
	}
	/*获取ARB状态*/
	arbState = GetArbState(switch1stSecId);
	switch1stSecLockState = GetPhySecLockState(switch1stSecId);
	switch1stSecJumpLockState = GetPhySecJumpLockState(switch1stSecId);	/*获取物理区段跳跃锁闭状态*/
	if (CI_SUCCESS == reVal)
	{
		if (SWITCH_LOCK_STATUS_NO != switch1stLockStatus)
		{ /*道岔锁闭*/

		  /* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId,
				ETYPE_SWT_LOCK_STATUS, switch1stLockStatus, sendLevel);
			reVal = CI_ERROR;
		}
	}
	if (CI_SUCCESS == reVal)
	{
		if (SWITCH_LOCK_YINZONG_NO != switch1stYLockState)
		{ /*道岔引导总锁*/

		  /* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId,
				ETYPE_SWT_YLOCK_STATE, switch1stYLockState, sendLevel);
			reVal = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reVal)
	{
		/*获取逻辑区段锁闭状态*/
		logLockState = GetSwitchLogSecLockState(switchId, &logOccOrLockId, &logState);
		/*物理区段防护锁闭、上电锁闭*/
		if ((PHYSICAL_SECTION_LOCK_START == switch1stSecLockState) || (PHYSICAL_SECTION_LOCK_PROTECT == switch1stSecLockState))
		{ /*区段锁闭*/

		  /* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
				ETYPE_PS_LOCK_STATE, switch1stSecLockState, sendLevel);
			reVal = CI_ERROR;
		}
		else
		{   /*逻辑区段锁闭*/
			if (CI_ERROR == logLockState)
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId,
					ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel);
				reVal = CI_ERROR;
			}
		}
	}
	if (CI_SUCCESS == reVal)
	{
		if (PHYSICAL_SECTION_JUMP_LOCK_NO != switch1stSecJumpLockState)
		{ /*区段跳跃锁闭*/

		  /* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
				ETYPE_PS_JUMP_LOCK, switch1stSecJumpLockState, sendLevel);
			reVal = CI_ERROR;
		}
	}
	if (CI_SUCCESS == reVal)
	{
		/*获取道岔所属物理区段关联的逻辑区段的占用状态*/
		logOccState = GetSwitchSecOccState(switchId, &logOccOrLockId, &logState);
		if (CI_ERROR == logOccState)
		{
			/*道岔关联的逻辑区段有占用*/
			/*记录故障码*/
			SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId,
				ETYPE_LOGSEC_OCC_STATE, logState, sendLevel);
			reVal = CI_ERROR;
		}
	}

	if (CI_SUCCESS == reVal)
	{
		ARBMoveSwitchFlag = GetCiFunctionSwitchConfig(ARB_MOVE_SWITCH_CONF);
		if (FUNC_SWITCH_ON == ARBMoveSwitchFlag)
		{/*ARB可动作道岔功能开关打开*/
		 /*当采集为占用且计轴区段ARB状态为ARB故障且融合后为空闲也可以动作道岔*/
			if (SECTION_OCCUPY_NO != switch1stSecOccuState)
			{
				if ((AXIS_SECTION_ARB_YES == arbState) && (SECTION_OCCUPY_NO == switch1stSecMerOccuState))
				{    /*计轴ARB且融合后状态为空闲，则允许动作道岔*/

				}
				else
				{
					/* 记录故障码 */
					SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
						ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel);
					reVal = CI_ERROR;
				}
			}

		}
		else if (FUNC_SWITCH_OFF == ARBMoveSwitchFlag)
		{
			
			if (AXIS_SECTION_ARB_NO != arbState)
			{ /*物理区段占用*/

				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
					ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel);
				reVal = CI_ERROR;
			}
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
				ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel);
			reVal = CI_ERROR;
		}

	}

	if (CI_SUCCESS == reVal)
	{/*检查道岔区段封锁，如道岔区段封锁，当前道岔单操有效，可动；否则，不可动*/
		if (PHYSICAL_SECTION_FLOCK_NO != switch1stSecFLockState)
		{
			if (SWITCH_OPER_DANCAO == oper_src)
			{
				reVal = CI_SUCCESS;
			}
			else
			{
				reVal = CI_ERROR;
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
					ETYPE_PS_FLOCK_STATE, switch1stSecFLockState, sendLevel);
			}
		}
	}
	if (CI_SUCCESS == reVal)
	{
		/*双动道岔检查*/
		switchType = GetSwitchType(switchId);
		if (SWITCH_TYPE_DOUBLE == switchType)
		{
			switch2ndId = GetDSwitchOtherId(switchId);
			switch2ndSecId = GetSwitchPhySectionId(switch2ndId);
			switch2ndLockStatus = GetSwitchLockStatus(switch2ndId);
			switch2ndYLockState = GetSwitchYLockState(switch2ndId);
			switch2ndSecLockState = GetPhySecLockState(switch2ndSecId);
			switch2ndSecMerOccuState = GetPhySecCurMergeState(switch2ndSecId);
			switch2ndSecJumpLockState = GetPhySecJumpLockState(switch2ndSecId);	/*获取物理区段跳跃锁闭状态*/
			switch2ndSecFLockState = GetPhySecFLockState(switch2ndSecId);/*获取双动道岔2道岔区段封锁状态*/
																		 /*获取ARB状态*/
			arbState = GetArbState(switch2ndSecId);
			vobcInterface = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);
			localCiType = GetLocalCiType();
			if (((LINE_FAO == vobcInterface) || (LINE_HLHT == vobcInerface) || (LINE_FAOHLHT == vobcInerface) || (LINE_FAOHLHT_ONESELF == vobcInerface) || (LINE_FAOHLHT_ONESELFSECOND == vobcInerface))
				&& (CI_TYPE_CLD == localCiType) && (FUNC_SWITCH_ON == gdDLline))
			{/*如果是FAO线路或FAOHLHT线路 车辆段，直接使用与占用原则融合后状态来处理道岔*/
				switch2ndSecOccuState = GetPhySecCurAndMergeState(switch2ndSecId);
			}
			else
			{/*其他场景：正线、或者是使用计轴设备均使用GJ处理*/
				switch2ndSecOccuState = GetPhySecCurOccupyState(switch2ndSecId);
			}

			if (SWITCH_LOCK_STATUS_NO != switch2ndLockStatus)
			{ /*道岔锁闭*/

			  /* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switch2ndId,
					ETYPE_SWT_LOCK_STATUS, switch2ndLockStatus, sendLevel);
				reVal = CI_ERROR;
			}

			if (CI_SUCCESS == reVal)
			{
				if (SWITCH_LOCK_YINZONG_NO != switch2ndYLockState)
				{ /*道岔引导总锁*/

				  /* 记录故障码 */
					SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switch2ndId,
						ETYPE_SWT_YLOCK_STATE, switch2ndYLockState, sendLevel);
					reVal = CI_ERROR;
				}
			}
			if (CI_SUCCESS == reVal)
			{
				/*获取逻辑区段锁闭状态*/
				logLockState = GetSwitchLogSecLockState(switch2ndId, &logOccOrLockId, &logState);
				/*物理区段防护锁闭、上电锁闭*/
				if ((PHYSICAL_SECTION_LOCK_START == switch2ndSecLockState) || (PHYSICAL_SECTION_LOCK_PROTECT == switch2ndSecLockState))
				{ /*区段锁闭*/

				  /* 记录故障码 */
					SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
						ETYPE_PS_LOCK_STATE, switch2ndSecLockState, sendLevel);
					reVal = CI_ERROR;
				}
				else
				{   /*逻辑区段锁闭*/
					if (CI_ERROR == logLockState)
					{
						/* 记录故障码 */
						SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId,
							ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel);
						reVal = CI_ERROR;
					}
				}
			}
			if (CI_SUCCESS == reVal)
			{
				if (switch2ndSecJumpLockState != PHYSICAL_SECTION_JUMP_LOCK_NO)
				{ /*区段跳跃锁闭*/

				  /* 记录故障码 */
					SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
						ETYPE_PS_JUMP_LOCK, switch2ndSecJumpLockState, sendLevel);
					reVal = CI_ERROR;
				}
			}
			if (CI_SUCCESS == reVal)
			{
				/*获取道岔所属物理区段关联的逻辑区段的占用状态*/
				logOccState = GetSwitchSecOccState(switch2ndId, &logOccOrLockId, &logState);
				if (CI_ERROR == logOccState)
				{
					/*道岔关联的逻辑区段有占用*/
					/*记录故障码*/
					SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId,
						ETYPE_LOGSEC_OCC_STATE, logState, sendLevel);
					reVal = CI_ERROR;
				}
			}

			if (CI_SUCCESS == reVal)
			{
				ARBMoveSwitchFlag = GetCiFunctionSwitchConfig(ARB_MOVE_SWITCH_CONF);
				if (FUNC_SWITCH_ON == ARBMoveSwitchFlag)
				{/*ARB可动作道岔功能开关打开*/
				 /*当采集为占用且计轴区段ARB状态为ARB故障且融合后为空闲也可以动作道岔*/
					if (SECTION_OCCUPY_NO != switch2ndSecOccuState)
					{
						if ((AXIS_SECTION_ARB_YES == arbState) && (SECTION_OCCUPY_NO == switch2ndSecMerOccuState))
						{    /*计轴ARB且融合后状态为空闲，则允许动作道岔*/

						}
						else
						{
							/* 记录故障码 */
							SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
								ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel);
							reVal = CI_ERROR;
						}
					}

				}
				else if (FUNC_SWITCH_OFF == ARBMoveSwitchFlag)
				{
					if (AXIS_SECTION_ARB_NO != arbState)
					{
						/*道岔关联的逻辑区段有占用*/
						/*记录故障码*/
						SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
							ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel);
						reVal = CI_ERROR;
					}
				}
				else
				{
					SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
						ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel);
					reVal = CI_ERROR;
				}
			}

			if (CI_SUCCESS == reVal)
			{/*检查道岔区段封锁，如道岔区段封锁，当前道岔单操有效，可动；否则，不可动*/

				if (PHYSICAL_SECTION_FLOCK_NO != switch2ndSecFLockState)
				{
					if (SWITCH_OPER_DANCAO == oper_src)
					{
						reVal = CI_SUCCESS;
					}
					else
					{
						reVal = CI_ERROR;
						/* 记录故障码 */
						SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
							ETYPE_PS_FLOCK_STATE, switch2ndSecFLockState, sendLevel);
					}
				}

			}
		}
	}
	/*道岔可动*/
#endif
	
	return reVal;
}

/*
* 功能描述： 道岔可动作有效性检查
* 参数说明： UINT16 switchId，道岔Id
*			 UINT8	oper_src,操作来源
*			 UINT8 sendLevel，发送级别
* 返回值  ： CI_SUCCESS: 更新成功
*			 CI_ERROR: 更新失败
* modify 20221009 适配新逻辑区段划分规则
*/
UINT8 GetSwitchMoveValidState(UINT16 switchId,UINT8	oper_src,UINT8 sendLevel)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_CHECK_SWITCH_MOVE;

	/*局部变量*/
	/*本联锁类型*/
	UINT8 ciType = 0u;
	/*道岔属性*/
	UINT8   switchType = 0u;
	/*道岔1*/
	UINT16  switch1stSecId = 0u;
	UINT8   switch1stLockStatus = 0u;
	UINT8   switch1stYLockState = 0u;
	UINT8   switch1stSecOccuState = 0u;
	UINT8   switch1stSecLockState = 0u;
	UINT8   switch1stSecMerOccuState = 0u;
	UINT8   arbState = 0u;
	UINT8   switch1stSecJumpLockState = 0u;
	UINT8	switch1stSecFLockState = 0u;/*道岔1道岔区段封锁状态*/
										/*道岔2*/
	UINT16  switch2ndId = 0u;
	UINT16  switch2ndSecId = 0u;
	UINT8   switch2ndLockStatus = 0u;
	UINT8   switch2ndYLockState = 0u;
	UINT8   switch2ndSecOccuState = 0u;
	UINT8   switch2ndSecLockState = 0u;
	UINT8   switch2ndSecMerOccuState = 0u;
	UINT8	reVal = CI_ERROR;
	UINT8	ARBMoveSwitchFlag = 0u;
	UINT8   switch2ndSecJumpLockState = 0u;
	UINT8	switch2ndSecFLockState = 0u;/*道岔2道岔区段封锁状态*/
	UINT8	vobcInterface = 0u;/*vobc接口标识*/
	UINT8	localCiType = 0u;	/*ci类型*/
	UINT8	vobcInerface = 0u;/*vobc接口*/
	UINT8   gdDLline = 0u; /*轨道电路标识*/
	UINT8   cLogSecLockFlag = 0u; /*逻辑区段锁闭标志*/
	UINT16  logOccOrLockId = 0u;
	UINT8 logState = 0U;

	/* 道岔检查 */
	switch1stSecId = GetSwitchPhySectionId(switchId);
	switch1stLockStatus = GetSwitchLockStatus(switchId);
	switch1stYLockState = GetSwitchYLockState(switchId);
	switch1stSecMerOccuState = GetPhySecCurMergeState(switch1stSecId);
	switch1stSecFLockState = GetPhySecFLockState(switch1stSecId);/*获取道岔1道岔区段封锁状态*/
	ciType = GetLocalCiType();
	/*判断是否采用轨道电路*/
	gdDLline = GetCiFunctionSwitchConfig(FUNC_CLD_GD_DIANLU_LINE);

	if ((JKJ_REYLAY_VALID == JkjRelayValid) && (CI_TYPE_CLD == ciType))
	{/*应急盘继电器有效状态*/
		SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, 0u, ETYPE_JKJ_WORK, RELAY_STATE_DOWN, ESEND_LEVEL_ATS);/*增加OC应急控功能，继电器ID填0*/
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
	}
	vobcInerface = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);

	if (((LINE_FAO == vobcInerface) || (LINE_HLHT == vobcInerface) || (LINE_FAOHLHT == vobcInerface))
		&& (CI_TYPE_CLD == ciType) && (FUNC_SWITCH_ON == gdDLline))
	{/*如果是FAO线路或FALHLHT线路 车辆段 使用轨道电路，直接使用与占用原则融合后状态来处理道岔*/
		switch1stSecOccuState = GetPhySecCurAndMergeState(switch1stSecId);
	}
	else
	{/*其他场景：正线、或者是使用计轴设备均使用GJ处理*/
		switch1stSecOccuState = GetPhySecCurOccupyState(switch1stSecId);
	}
	/*获取ARB状态*/
	arbState = GetArbState(switch1stSecId);
	switch1stSecLockState = GetPhySecLockState(switch1stSecId);
	switch1stSecJumpLockState = GetPhySecJumpLockState(switch1stSecId);	/*获取物理区段跳跃锁闭状态*/
	if (CI_SUCCESS == reVal)
	{
		if (SWITCH_LOCK_STATUS_NO != switch1stLockStatus)
		{ /*道岔锁闭*/

		  /* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId,
				ETYPE_SWT_LOCK_STATUS, switch1stLockStatus, sendLevel);
			reVal = CI_ERROR;
		}
		else
		{
			; /*无操作*/
		}
	}
	else
	{
		; /*不执行*/
	}

	if (CI_SUCCESS == reVal)
	{
		if (SWITCH_LOCK_YINZONG_NO != switch1stYLockState)
		{ /*道岔引导总锁*/

		  /* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId,
				ETYPE_SWT_YLOCK_STATE, switch1stYLockState, sendLevel);
			reVal = CI_ERROR;
		}
		else
		{
			; /*无操作*/
		}
	}
	else
	{
		; /*不执行*/
	}

	if (CI_SUCCESS == reVal)
	{
		if (PHYSICAL_SECTION_LOCK_NO != switch1stSecLockState)
		{/*道岔关联物理区段锁闭*/

		 /* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
				ETYPE_PS_LOCK_STATE, switch1stSecLockState, sendLevel);
			reVal = CI_ERROR;
		}
		else
		{
			/*物理区段未锁闭，检查物理区段包含的逻辑区段进路锁闭状态*/
			cLogSecLockFlag = CheckPSecIncLSecLockState(switch1stSecId, &logOccOrLockId, &logState);
			if (CI_ERROR == cLogSecLockFlag)
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel);
				reVal = CI_ERROR;
			}
			else
			{
				/*物理区段未锁闭，逻辑区段未进路锁闭，检查物理区段包含的逻辑区段逻辑锁闭状态*/
				cLogSecLockFlag = CheckPSecIncLSecLogicLockState(switch1stSecId, &logOccOrLockId, &logState);
				if (CI_ERROR == cLogSecLockFlag)
				{
					/* 记录故障码 */
					SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel);
					reVal = CI_ERROR;
				}
				else
				{
					; /*不处理*/
				}
			}
		}
	}
	else
	{
		; /*不执行*/
	}

	if (CI_SUCCESS == reVal)
	{
		if (PHYSICAL_SECTION_JUMP_LOCK_NO != switch1stSecJumpLockState)
		{ /*区段跳跃锁闭*/

		  /* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
				ETYPE_PS_JUMP_LOCK, switch1stSecJumpLockState, sendLevel);
			reVal = CI_ERROR;
		}
		else
		{
			; /*无操作*/
		}
	}
	else
	{
		; /*不执行*/
	}

	if (CI_SUCCESS == reVal)
	{

		ARBMoveSwitchFlag = GetCiFunctionSwitchConfig(ARB_MOVE_SWITCH_CONF);
		if (FUNC_SWITCH_ON == ARBMoveSwitchFlag)
		{/*ARB可动作道岔功能开关打开*/
		 /*当采集为占用且计轴区段ARB状态为ARB故障且融合后为空闲也可以动作道岔*/
			if (SECTION_OCCUPY_NO != switch1stSecOccuState)
			{
				if ((AXIS_SECTION_ARB_YES == arbState) && (SECTION_OCCUPY_NO == switch1stSecMerOccuState))
				{    /*计轴ARB且融合后状态为空闲，则允许动作道岔*/

				}
				else
				{
					/* 记录故障码 */
					SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
						ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel);
					reVal = CI_ERROR;
				}
			}
			else
			{
				; /*不处理*/
			}
		}
		else if (FUNC_SWITCH_OFF == ARBMoveSwitchFlag)
		{
			if (AXIS_SECTION_ARB_NO != arbState)
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
					ETYPE_PS_MERGY_OCU_STATE, SECTION_OCCUPY_YES, sendLevel);
				reVal = CI_ERROR;
			}
			else
			{
				if (SECTION_OCCUPY_NO != switch1stSecOccuState)
				{ /*道岔关联物理区段占用*/

				  /* 记录故障码 */
					SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
						ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel);
					reVal = CI_ERROR;
				}
				else
				{
					; /*不处理*/
				}
			}
		}
		else
		{
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
				ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel);
			reVal = CI_ERROR;
		}
	}
	else
	{
		; /*不执行*/
	}

	if (CI_SUCCESS == reVal)
	{/*检查道岔区段封锁，如道岔区段封锁，当前道岔单操有效，可动；否则，不可动*/
		if (PHYSICAL_SECTION_FLOCK_NO != switch1stSecFLockState)
		{
			if (SWITCH_OPER_DANCAO == oper_src)
			{
				reVal = CI_SUCCESS;
			}
			else
			{
				reVal = CI_ERROR;
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId,
					ETYPE_PS_FLOCK_STATE, switch1stSecFLockState, sendLevel);
			}
		}
		else
		{
			; /*不处理*/
		}
	}
	else
	{
		; /*不执行*/
	}

	if (CI_SUCCESS == reVal)
	{
		/*双动道岔检查*/
		switchType = GetSwitchType(switchId);
		if (SWITCH_TYPE_DOUBLE == switchType)
		{
			switch2ndId = GetDSwitchOtherId(switchId);
			switch2ndSecId = GetSwitchPhySectionId(switch2ndId);
			switch2ndLockStatus = GetSwitchLockStatus(switch2ndId);
			switch2ndYLockState = GetSwitchYLockState(switch2ndId);
			switch2ndSecLockState = GetPhySecLockState(switch2ndSecId);
			switch2ndSecMerOccuState = GetPhySecCurMergeState(switch2ndSecId);
			switch2ndSecJumpLockState = GetPhySecJumpLockState(switch2ndSecId);	/*获取物理区段跳跃锁闭状态*/
			switch2ndSecFLockState = GetPhySecFLockState(switch2ndSecId);/*获取双动道岔2道岔区段封锁状态*/
																		 /*获取ARB状态*/
			arbState = GetArbState(switch2ndSecId);
			vobcInterface = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);
			localCiType = GetLocalCiType();
			if (((LINE_FAO == vobcInterface) || (LINE_HLHT == vobcInerface) || (LINE_FAOHLHT == vobcInerface))
				&& (CI_TYPE_CLD == localCiType) && (FUNC_SWITCH_ON == gdDLline))
			{/*如果是FAO线路或FAOHLHT线路 车辆段，直接使用与占用原则融合后状态来处理道岔*/
				switch2ndSecOccuState = GetPhySecCurAndMergeState(switch2ndSecId);
			}
			else
			{/*其他场景：正线、或者是使用计轴设备均使用GJ处理*/
				switch2ndSecOccuState = GetPhySecCurOccupyState(switch2ndSecId);
			}

			if (SWITCH_LOCK_STATUS_NO != switch2ndLockStatus)
			{ /*道岔锁闭*/

			  /* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switch2ndId,
					ETYPE_SWT_LOCK_STATUS, switch2ndLockStatus, sendLevel);
				reVal = CI_ERROR;
			}
			else
			{
				;  /*不处理*/
			}

			if (CI_SUCCESS == reVal)
			{
				if (SWITCH_LOCK_YINZONG_NO != switch2ndYLockState)
				{ /*道岔引导总锁*/

				  /* 记录故障码 */
					SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switch2ndId,
						ETYPE_SWT_YLOCK_STATE, switch2ndYLockState, sendLevel);
					reVal = CI_ERROR;
				}
				else
				{
					;  /*不处理*/
				}
			}
			if (CI_SUCCESS == reVal)
			{
				if (PHYSICAL_SECTION_LOCK_NO != switch2ndSecLockState)
				{/*道岔关联物理区段锁闭*/

				 /* 记录故障码 */
					SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
						ETYPE_PS_LOCK_STATE, switch2ndSecLockState, sendLevel);
					reVal = CI_ERROR;
				}
				else
				{
					/*物理区段未锁闭，检查物理区段包含的逻辑区段进路锁闭状态*/
					cLogSecLockFlag = CheckPSecIncLSecLockState(switch2ndSecId, &logOccOrLockId, &logState);
					if (CI_ERROR == cLogSecLockFlag)
					{
						/* 记录故障码 */
						SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel);
						reVal = CI_ERROR;
					}
					else
					{
						/*物理区段未锁闭，检查物理区段包含的逻辑区段未被进路锁闭，检查逻辑锁闭状态*/
						cLogSecLockFlag = CheckPSecIncLSecLogicLockState(switch2ndSecId, &logOccOrLockId, &logState);
						if (CI_ERROR == cLogSecLockFlag)
						{
							/* 记录故障码 */
							SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel);
							reVal = CI_ERROR;
						}
						else
						{
							; /*不处理*/
						}
					}
				}
			}
			else
			{
				; /*不处理*/
			}

			if (CI_SUCCESS == reVal)
			{
				if (switch2ndSecJumpLockState != PHYSICAL_SECTION_JUMP_LOCK_NO)
				{ /*区段跳跃锁闭*/

				  /* 记录故障码 */
					SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
						ETYPE_PS_JUMP_LOCK, switch2ndSecJumpLockState, sendLevel);
					reVal = CI_ERROR;
				}
				else
				{
					; /*不处理*/
				}
			}
			else
			{
				; /*不处理*/
			}

			if (CI_SUCCESS == reVal)
			{

				ARBMoveSwitchFlag = GetCiFunctionSwitchConfig(ARB_MOVE_SWITCH_CONF);
				if (FUNC_SWITCH_ON == ARBMoveSwitchFlag)
				{/*ARB可动作道岔功能开关打开*/
				 /*当采集为占用且计轴区段ARB状态为ARB故障且融合后为空闲也可以动作道岔*/
					if (SECTION_OCCUPY_NO != switch2ndSecOccuState)
					{
						if ((AXIS_SECTION_ARB_YES == arbState) && (SECTION_OCCUPY_NO == switch2ndSecMerOccuState))
						{    
							; /*计轴ARB且融合后状态为空闲，则允许动作道岔*/

						}
						else
						{
							/* 记录故障码 */
							SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
								ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel);
							reVal = CI_ERROR;
						}
					}
					else
					{
						; /*不处理*/
					}
				}
				else if (FUNC_SWITCH_OFF == ARBMoveSwitchFlag)
				{
					if (AXIS_SECTION_ARB_NO != arbState)
					{
						/* 记录故障码 */
						SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
							ETYPE_PS_MERGY_OCU_STATE, SECTION_OCCUPY_YES, sendLevel);
						reVal = CI_ERROR;
					}
					else
					{
						if (SECTION_OCCUPY_NO != switch2ndSecOccuState)
						{ /*道岔关联物理区段占用*/

						  /* 记录故障码 */
							SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
								ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel);
							reVal = CI_ERROR;
						}
						else
						{
							; /*不处理*/
						}
					}
				}
				else
				{
					SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
						ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel);
					reVal = CI_ERROR;
				}

			}
			else
			{
				; /*不处理*/
			}
			
			if (CI_SUCCESS == reVal)
			{/*检查道岔区段封锁，如道岔区段封锁，当前道岔单操有效，可动；否则，不可动*/

				if (PHYSICAL_SECTION_FLOCK_NO != switch2ndSecFLockState)
				{
					if (SWITCH_OPER_DANCAO == oper_src)
					{
						reVal = CI_SUCCESS;
					}
					else
					{
						reVal = CI_ERROR;
						/* 记录故障码 */
						SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId,
							ETYPE_PS_FLOCK_STATE, switch2ndSecFLockState, sendLevel);
					}
				}
				else
				{
					; /*不处理*/
				}

			}
			else
			{
				; /*不处理*/
			}
		}
		else
		{
			; /*无操作*/
		}
	}
	else
	{
		; /*不执行*/
	}

	/*道岔可动*/
	return reVal;
}

/* zt 删除单轨相关代码 2022-02-15 */
/*
* 功能描述： 道岔强扳可动作有效性检查
* 参数说明： UINT16 switchId 道岔ID
*            UINT8 sendLevel 给ATS和现地发送级别
* 返回值  ： CI_SUCCESS: 更新失败
*			 CI_ERROR: 更新成功      
*/
UINT8 GetSwitchForceMoveValidState(UINT16 switchId,UINT8 sendLevel)
{
    /*函数故障码*/
    UINT8 const functionId = EFUNC_CHECK_FORCE_SWITCH_MOVE;  

/*局部变量*/
    /*道岔属性*/
    UINT8   switchType = 0u;
    /*道岔1*/
    UINT16  switch1stSecId = 0u;
    UINT8   switch1stLockStatus = 0u;
    UINT8   switch1stYLockState = 0u;
    UINT8   switch1stSecOccuState = 0u;
    UINT8   switch1stSecLockState = 0u;
	UINT8   switch1stSecJumpLockState = 0u;

    /*道岔2*/
    UINT16  switch2ndId = 0u;
    UINT16  switch2ndSecId = 0u;
    UINT8   switch2ndLockStatus = 0u;
    UINT8   switch2ndYLockState = 0u;
    UINT8   switch2ndSecLockState = 0u;
	UINT8   switch2ndSecJumpLockState = 0u;
	UINT8 reVal = CI_SUCCESS;
	UINT8 cLogSecLockFlag = 0U;  /*逻辑区段锁闭标志*/
	UINT16  logOccOrLockId = 0U;
	UINT8 logState = 0U;

 /* 道岔检查 */
    switch1stSecId = GetSwitchPhySectionId(switchId);
    switch1stLockStatus = GetSwitchLockStatus(switchId);
    switch1stYLockState = GetSwitchYLockState(switchId);
    switch1stSecOccuState = GetPhySecCurOccupyState(switch1stSecId);
    switch1stSecLockState = GetPhySecLockState(switch1stSecId);
	switch1stSecJumpLockState = GetPhySecJumpLockState(switch1stSecId);	/*获取物理区段跳跃锁闭状态*/

	if ((SWITCH_LOCK_STATUS_DANSUO == switch1stLockStatus) || (SWITCH_LOCK_STATUS_PROTECT == switch1stLockStatus)
		|| (SWITCH_LOCK_STATUS_DAP == switch1stLockStatus))
    { /*道岔锁闭*/

        /* 记录故障码 */
        SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,
                     ETYPE_SWT_LOCK_STATUS,switch1stLockStatus,sendLevel);
        reVal = CI_ERROR;
    }

	if (reVal == CI_SUCCESS)
	{
	   if (SWITCH_LOCK_YINZONG_YES == switch1stYLockState)
		{ /*道岔引导总锁*/

			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,
						 ETYPE_SWT_YLOCK_STATE,switch1stYLockState,sendLevel);
			reVal = CI_ERROR;
		}
	}
	if (reVal == CI_SUCCESS)
	{
		if (PHYSICAL_SECTION_LOCK_NO != switch1stSecLockState)
		{ /*区段锁闭*/

			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch1stSecId,
						 ETYPE_PS_LOCK_STATE,switch1stSecLockState,sendLevel);
			reVal = CI_ERROR;
		}
		else
		{
			/*物理区段未锁闭，检查物理区段包含的逻辑区段进路锁闭状态*/
			cLogSecLockFlag = CheckPSecIncLSecLockState(switch1stSecId, &logOccOrLockId, &logState);
			if (CI_ERROR == cLogSecLockFlag)
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel);
				reVal = CI_ERROR;
			}

			/*物理区段未锁闭，检查物理区段包含的逻辑区段逻辑锁闭状态*/
			cLogSecLockFlag = CheckPSecIncLSecLogicLockState(switch1stSecId, &logOccOrLockId, &logState);
			if (CI_ERROR == cLogSecLockFlag)
			{
				/* 记录故障码 */
				SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel);
				reVal = CI_ERROR;
			}
		}
	}
	if (reVal == CI_SUCCESS)
	{
		if (PHYSICAL_SECTION_JUMP_LOCK_NO != switch1stSecJumpLockState  )
		{ /*区段跳跃锁闭*/

			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch1stSecId,
				ETYPE_PS_JUMP_LOCK,switch1stSecJumpLockState,sendLevel);
			reVal = CI_ERROR;
		}
	}
	if (reVal == CI_SUCCESS)
	{
		if (SECTION_OCCUPY_YES != switch1stSecOccuState)
		{ /*区段未占用*/

			/* 记录故障码 */
			SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch1stSecId,
						 ETYPE_PS_MERGY_OCU_STATE,switch1stSecOccuState,sendLevel);
			reVal = CI_ERROR;
		}	
	}
	if (CI_SUCCESS == reVal)
	{
		/*双动道岔检查*/
		switchType = GetSwitchType(switchId);
		if (SWITCH_TYPE_DOUBLE == switchType  )
		{
			switch2ndId = GetDSwitchOtherId(switchId);
			switch2ndSecId = GetSwitchPhySectionId(switch2ndId);
			switch2ndLockStatus = GetSwitchLockStatus(switch2ndId);
			switch2ndYLockState = GetSwitchYLockState(switch2ndId);
			switch2ndSecLockState = GetPhySecLockState(switch2ndSecId);
			switch2ndSecJumpLockState = GetPhySecJumpLockState(switch2ndSecId);	/*获取物理区段跳跃锁闭状态*/

			if ((SWITCH_LOCK_STATUS_DANSUO == switch2ndLockStatus) || (SWITCH_LOCK_STATUS_PROTECT == switch2ndLockStatus)
				|| (SWITCH_LOCK_STATUS_DAP == switch2ndLockStatus))
			{ /*道岔锁闭*/

				/* 记录故障码 */
				SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switch2ndId,
							 ETYPE_SWT_LOCK_STATUS,switch2ndLockStatus,sendLevel);
				reVal = CI_ERROR;
			}

			if (reVal == CI_SUCCESS)
			{
				if (SWITCH_LOCK_YINZONG_YES == switch2ndYLockState)
				{ /*道岔引导总锁*/

					/* 记录故障码 */
					SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switch2ndId,
								 ETYPE_SWT_YLOCK_STATE,switch2ndYLockState,sendLevel);
					reVal = CI_ERROR;
				}
			}
			if (reVal == CI_SUCCESS)
			{
				if (PHYSICAL_SECTION_LOCK_NO != switch2ndSecLockState  )
				{ /*区段锁闭*/

					/* 记录故障码 */
					SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch2ndSecId,
								 ETYPE_PS_LOCK_STATE,switch2ndSecLockState,sendLevel);
					reVal = CI_ERROR;
				}
				else
				{
					/*物理区段未锁闭，检查物理区段包含的逻辑区段进路锁闭状态*/
					cLogSecLockFlag = CheckPSecIncLSecLockState(switch2ndSecId, &logOccOrLockId, &logState);
					if (CI_ERROR == cLogSecLockFlag)
					{
						/* 记录故障码 */
						SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel);
						reVal = CI_ERROR;
					}

					/*物理区段未锁闭，检查物理区段包含的逻辑区段逻辑锁闭状态*/
					cLogSecLockFlag = CheckPSecIncLSecLogicLockState(switch2ndSecId, &logOccOrLockId, &logState);
					if (CI_ERROR == cLogSecLockFlag)
					{
						/* 记录故障码 */
						SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel);
						reVal = CI_ERROR;
					}
				}
			}
			if (reVal == CI_SUCCESS)
			{
				if (PHYSICAL_SECTION_JUMP_LOCK_NO != switch2ndSecJumpLockState  )
				{ /*区段跳跃锁闭*/

					/* 记录故障码 */
					SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch2ndSecId,
						ETYPE_PS_JUMP_LOCK,switch2ndSecJumpLockState,sendLevel);
					reVal = CI_ERROR;
				}			
			}

		}
	}

    /*道岔可动*/
    return reVal;
}
/* zt 删除单轨相关代码 2022-02-15 */


/*
* 功能描述： 获取道岔锁闭状态
* 参数说明： void
* 返回值  ： 0: 获取失败
*			 >0: 道岔锁闭状态      
*/
UINT8 GetSwitchRouteLockState(UINT16 switchId)
{
	UINT16 bufIndex = 0u;		/*数组下标*/
	UINT16 belongSecId = 0u;		/*所属区段ID*/
    UINT16 doubleSwitchId = 0u;  /*双动道岔ID*/
	UINT8 belongPhySecState = 0u;	/*所属物理区段的进路状态*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSwitchConfigBufIndex(switchId);  /*获取道岔数组下标*/
	
	if (bufIndex < SWITCH_SUM_MAX)
	{
		belongSecId = GetSwitchPhySectionId(switchId);
		belongPhySecState = GetPhySecLockState(belongSecId);

		if ((PHYSICAL_SECTION_LOCK_NORMAL == belongPhySecState) || 
            (PHYSICAL_SECTION_LOCK_PROTECT == belongPhySecState)||
			(PHYSICAL_SECTION_LOCK_DELAY == belongPhySecState) ||
			(PHYSICAL_SECTION_LOCK_FAULTDELAY == belongPhySecState))
		{  
			/* 正常锁闭、防护锁闭、延时解锁、区故解延时解锁，都为锁闭状态，
			   防止区段延时解锁且为防护锁闭ZC车紧急*/
			reVal = CI_SUCCESS;
		}
        else
        {
            doubleSwitchId = GetDSwitchOtherId(switchId);/*获取双动道岔ID*/
            if (doubleSwitchId != 0u)
            {/*双动道岔非空*/

                belongSecId = GetSwitchPhySectionId(doubleSwitchId);
                belongPhySecState = GetPhySecLockState(belongSecId);
                
                if ((PHYSICAL_SECTION_LOCK_NORMAL == belongPhySecState) || 
                    (PHYSICAL_SECTION_LOCK_PROTECT == belongPhySecState) ||
					(PHYSICAL_SECTION_LOCK_DELAY == belongPhySecState) ||
					(PHYSICAL_SECTION_LOCK_FAULTDELAY == belongPhySecState))
                {
                    reVal = CI_SUCCESS;
                }
            }            
        }
    }
	return reVal;
}

/*
* 功能描述： 道岔驱动处理
* 参数说明： const UINT16 switchId, 道岔ID
*			 const UINT8 switchPos, 道岔位置
* 返回值  ： void      
*/
UINT8 SwitchDriveProcess(const UINT16 switchId, const UINT8 switchPos)
{
    UINT8 reValue = CI_ERROR;
	UINT8 switchPreExpDrvPos = SWITCH_DRIVE_POS_INVALID;
	UINT8 switchCurExpDrvPos = SWITCH_DRIVE_POS_INVALID;
	UINT8 switchExpDrvPos = SWITCH_DRIVE_POS_INVALID;

	/*获取当前周期期望驱动位置*/
	switchCurExpDrvPos = GetSwitchExpDrvPosition(switchId);

	if(SWITCH_DRIVE_POS_INVALID != switchCurExpDrvPos)
	{/*当前期望驱动位置有效*/
		/*这意味着本周期已存在其他业务要求驱动本道岔,所以这时什么也不做*/
		/*注意，因为双动道岔比较特殊，虽然驱动已经存在，有可能是设置双动道岔的其中一个道岔时把另一个设置上的，此时需要检查如果
		期望驱动的与当前周期一致，则设置返回值为CI_SUCCESS*/
		if (
			((SWITCH_DRIVE_POS_FANWEI == switchCurExpDrvPos)&&(SWITCH_POSITION_FANWEI == switchPos)) ||
			((SWITCH_DRIVE_POS_DINGWEI == switchCurExpDrvPos)&&(SWITCH_POSITION_DINGWEI == switchPos)) 
			)
		{/* zt 删除单轨相关代码 2022-02-15 */
			reValue = CI_SUCCESS;
		}
	}
	else
	{
		if ((0u < switchId) && (switchId < SWITCH_SUM_MAX))
		{
			if (SWITCH_POSITION_DINGWEI == switchPos)
			{/*要求道岔驱动到定位*/
				/*位置DINGWEI转为期望驱动位置*/
				switchExpDrvPos = SWITCH_DRIVE_POS_DINGWEI;
			}
			else if (SWITCH_POSITION_FANWEI == switchPos)
			{/*要求道岔驱动到反位*/
				/*位置FANWEI转为期望驱动位置*/
				switchExpDrvPos = SWITCH_DRIVE_POS_FANWEI;
			}/* zt 删除单轨相关代码 2022-02-15 */
			else 
			{/*要求道岔驱动到无效位置*/
				/*位置INVALID转为期望驱动位置*/
				switchExpDrvPos = SWITCH_DRIVE_POS_INVALID;
			}
		}

		if(SWITCH_DRIVE_POS_INVALID != switchExpDrvPos)
		{/*期望驱动位置有效*/
			/*获取上周期期望驱动位置*/
			switchPreExpDrvPos = GetSwitchPreExpDrvPosition(switchId);

			if(SWITCH_DRIVE_POS_INVALID != switchPreExpDrvPos)
			{/*上周期期望驱动位置有效*/
				if(switchPreExpDrvPos == switchExpDrvPos)
				{/*期望驱动位置与上周期相同*/
					/*设置本周期期望驱动位置*/
					reValue = SetSwitchExpDrvPosition(switchId, switchExpDrvPos);
				}
				else
				{/*期望驱动位置与上周期不同*/
					/*这意味着之前若干个周期包括本周期很有可能已存在其他业务要求驱动道岔,所以这时什么也不做*/
				}
			}
			else
			{/*上周期期望驱动位置无效*/
				/*设置本周期期望驱动位置*/
				reValue = SetSwitchExpDrvPosition(switchId, switchExpDrvPos);
			}
		}
		else
		{/*期望驱动位置无效*/
			/*什么也不做*/
		}
	}

	return reValue;
}


/*
功能描述:
	清除进路关联道岔期望驱动位置
输入参数:
	const UINT16 routeId 进路ID 
输出参数:	
	无.
返回值:
	无
*/
void ClearRouteSwitchDrivePos(const UINT16 routeId)
{
	UINT8 	retValOfSetSwiExpDrvPos = CI_ERROR;				/*设置道岔期望驱动位置的返回值*/
	UINT8 	switchSum = 0u; 									/*道岔数目*/
	UINT16 	switchId = 0u; 									/*道岔ID*/
    UINT8 	ii = 0u;											/*循环变量*/
	RouteSwitchStruct* pRouteSwitchStru = NULL; 				/*道岔数据*/
	UINT8 routeProtectSwitchSum = 0u; 							/*防护道岔数目*/
	RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL;    /*防护道岔数据*/

	switchSum = GetRouteSwitchSum(routeId); /*获取进路道岔数目*/
	pRouteSwitchStru = GetRouteSwitchData(routeId); /*获取进路内道岔数据*/
	routeProtectSwitchSum = GetRouteRelatedProtectSwitchSum(routeId);     /*获取进路关联防护道岔数目*/
	pRouteProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId);   /*获取进路关联防护道岔数据*/

	if(NULL != pRouteSwitchStru)
	{
		for(ii = 0u; ii < switchSum; ii++)
		{
			switchId = pRouteSwitchStru[ii].SwitchId;
			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);

			if(CI_SUCCESS == retValOfSetSwiExpDrvPos)
			{
				
			}
			else
			{/*设置失败*/
				/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
			}
		}
	}
	
	if(NULL != pRouteProtectSwitchStru)
	{
		for(ii = 0u; ii < routeProtectSwitchSum; ii++)
		{
			switchId = pRouteProtectSwitchStru[ii].ProtectSwitchId;
			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);

			if(CI_SUCCESS == retValOfSetSwiExpDrvPos)
			{

			}
			else
			{/*设置失败*/
				/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
			}
		}
	}

}

/*
功能描述:
	清除保护区段关联道岔期望驱动位置
输入参数:
	const UINT16 routeId 进路ID 
输出参数:	
	无.
返回值:
	无
*/
void ClearOverlapSwitchDrivePos(const UINT16 overlapId)
{	
	UINT8 	retValOfSetSwiExpDrvPos = CI_ERROR;				/*设置道岔期望驱动位置的返回值*/
	UINT8 	ii;
	UINT8 	switchSum = 0u;
	UINT16 	switchId = 0u;
	OverlapConditionSwitchStruct* conditionSwitchStru = NULL;
	UINT8 protectSwitchSum = 0u;
	OverlapProtectSwitchStruct* protectSwitchStru = NULL;
	
	if ((0u < overlapId) && (OVERLAP_SUM_MAX > overlapId))
	{
		switchSum = GetOverlapSwitchSum(overlapId);
		protectSwitchSum = GetOverlapRelatedProtSwitSum(overlapId);
		conditionSwitchStru = GetOverlapCondSwitchStruct(overlapId);
		protectSwitchStru = GetOverlapRelatedProtSwitStru(overlapId);

	    if (NULL != conditionSwitchStru)
	    {
			for (ii = 0u; ii < switchSum; ii++)
			{
				switchId = conditionSwitchStru[ii].SwitchId;
				
				/*设置该道岔期望驱动位置为无效*/
				retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);

				if(CI_SUCCESS == retValOfSetSwiExpDrvPos)
				{
					
				}
				else
				{/*设置失败*/
					/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
				}
			}
	    }
		
		if (NULL != protectSwitchStru)
		{
			for (ii = 0u; ii < protectSwitchSum; ii++)
			{
				switchId = protectSwitchStru[ii].ProtectSwitchId;
				
				/*设置该道岔期望驱动位置为无效*/
				retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);

				if(CI_SUCCESS == retValOfSetSwiExpDrvPos)
				{
					
				}
				else
				{/*设置失败*/
					/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
				}
			}
		}
	}
	else
	{
		/*不做处理*/
	}

}

/*
功能描述:
	清除进路关联道岔单操位置
输入参数:
	const UINT16 routeId 进路ID 
输出参数:	
	无.
返回值:
	无
*/
void ClearRouteSwitchDanCaoPos(const UINT16 routeId)
{
	UINT8 	retValOfSetSwiDanCaoPos = CI_ERROR;				/*设置道岔期望驱动位置的返回值*/
	UINT8 	switchSum = 0u; 									/*道岔数目*/
	UINT16 	switchId = 0u; 									/*道岔ID*/
    UINT8 	ii = 0u;											/*循环变量*/
	RouteSwitchStruct* routeSwitchStru = NULL; 				/*道岔数据*/
	UINT8 routeProtectSwitchSum = 0u; 							/*防护道岔数目*/
	RouteProtectSwitchStruct* routeProtectSwitchStru = NULL;    /*防护道岔数据*/

	switchSum = GetRouteSwitchSum(routeId); /*获取进路道岔数目*/
	routeSwitchStru = GetRouteSwitchData(routeId); /*获取进路内道岔数据*/
	routeProtectSwitchSum = GetRouteRelatedProtectSwitchSum(routeId);      /*获取进路关联防滑道岔数目*/
	routeProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId);    /*获取进路关联防滑道岔数据*/

	if(NULL != routeSwitchStru)
	{
		for(ii = 0u; ii < switchSum; ii++)
		{
			switchId = routeSwitchStru[ii].SwitchId;
			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID);
			if(CI_SUCCESS == retValOfSetSwiDanCaoPos)
			{
				
			}
			else
			{/*设置失败*/
				/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
			}
		}
	}

	if (NULL != routeProtectSwitchStru)
	{
		for(ii = 0u; ii < routeProtectSwitchSum; ii++)
		{
			switchId = routeProtectSwitchStru[ii].ProtectSwitchId;
			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID);
			if(CI_SUCCESS == retValOfSetSwiDanCaoPos)
			{

			}
			else
			{/*设置失败*/
				/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
			}
		}
	}
}

/*
功能描述:
	清除保护区段关联道岔单操位置
输入参数:
	const UINT16 routeId 进路ID 
输出参数:	
	无.
返回值:
	无
*/
void ClearOverlapSwitchDanCaoPos(const UINT16 overlapId)
{
	UINT8 	retValOfSetSwiDanCaoPos = CI_ERROR;				/*设置道岔期望驱动位置的返回值*/
	UINT8 	switchSum = 0u; 									/*道岔数目*/
	UINT16 	switchId = 0u; 									/*道岔ID*/
    UINT8 	ii = 0u;											/*循环变量*/
	OverlapConditionSwitchStruct* conditionSwitchStru = NULL;
	UINT8 protectSwitchSum = 0u;
	OverlapProtectSwitchStruct* protectSwitchStru = NULL;

	if ((0u < overlapId) && (OVERLAP_SUM_MAX > overlapId))
	{
		switchSum = GetOverlapSwitchSum(overlapId);
		protectSwitchSum = GetOverlapRelatedProtSwitSum(overlapId);
		conditionSwitchStru = GetOverlapCondSwitchStruct(overlapId);
		protectSwitchStru = GetOverlapRelatedProtSwitStru(overlapId);

	    if (NULL != conditionSwitchStru)
	    {
			for(ii = 0u; ii < switchSum; ii++)
			{
				switchId = conditionSwitchStru[ii].SwitchId;

				/*设置该道岔期望驱动位置为无效*/
				retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID);

				if(CI_SUCCESS == retValOfSetSwiDanCaoPos)
				{
					/*不做处理*/
				}
				else
				{/*设置失败*/
					/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
				}
			}
		}
		
		if (NULL != protectSwitchStru)
		{
			for(ii = 0u; ii < protectSwitchSum; ii++)
			{
				switchId = protectSwitchStru[ii].ProtectSwitchId;

				/*设置该道岔期望驱动位置为无效*/
				retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID);

				if(CI_SUCCESS == retValOfSetSwiDanCaoPos)
				{
					/*不做处理*/
				}
				else
				{/*设置失败*/
					/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
				}
			}
		}
	}
	else
	{
		/*不做处理*/
	}
}


/*
功能描述:
	清除非进路关联道岔期望驱动位置
输入参数:
	无
输出参数:	
	无.
返回值:
	CI_SUCCESS 成功
	CI_ERROR 失败
*/
UINT8 ClearNonRouteSwitchDrivePos(UINT8 nonRouteId)
{								/*本函数的返回值*/
	UINT8 	retValOfSetSwiExpDrvPos = CI_ERROR;				/*设置道岔期望驱动位置的返回值*/
	UINT8 	switchSum = 0u; 									/*道岔数目*/
	UINT16 	switchId = 0u; 									/*道岔ID*/
	UINT8 	ii = 0u;											/*循环变量*/
	NonRouteSwitchStruct* pNonRouteSwitchStru = NULL;
	UINT8 	retVal = CI_SUCCESS;
	UINT8 protectSwitchSum = 0u; /*防护道岔总数*/
	NonRouteProtectSwitchStruct* pNonRouteProtectSwitchStru = NULL; /*防护道岔数据*/
	/*获取非进路道岔数目*/
	switchSum = GetNonRouteSwitchSumById(nonRouteId);
	/*获取非进路关联道岔数据结构指针*/
	pNonRouteSwitchStru = GetNonRouteSwitchStructBufById(nonRouteId);
	protectSwitchSum = GetNonRouteRelatedProtSwitSum(nonRouteId); /*非进路防护道岔总数*/
	pNonRouteProtectSwitchStru = GetNonRouteRelatedProtSwitStru(nonRouteId); /*非进路防护道岔数据*/

	if (pNonRouteSwitchStru !=NULL)
	{
		for(ii = 0u; ii < switchSum; ii++)
		{
			switchId = pNonRouteSwitchStru[ii].SwitchId;

			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);

			if(CI_SUCCESS == retValOfSetSwiExpDrvPos)
			{

			}
			else
			{/*设置失败*/
				/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
				retVal = CI_ERROR;
			}
		}
	}
	else
	{
		retVal = CI_ERROR;
	}

	if (pNonRouteProtectSwitchStru !=NULL)
	{
		for(ii = 0u; ii < protectSwitchSum; ii++)
		{
			switchId = pNonRouteProtectSwitchStru[ii].ProtectSwitchId;

			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);

			if(CI_SUCCESS == retValOfSetSwiExpDrvPos)
			{

			}
			else
			{/*设置失败*/
				/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
				retVal = CI_ERROR;
			}
		}
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}


/*
功能描述:
	清除非进路关联道岔单操位置
输入参数:
	const UINT16 routeId 进路ID 
输出参数:	
	无.
返回值:
	CI_SUCCESS 成功
	CI_ERROR 失败
*/
UINT8 ClearNonRouteSwitchDanCaoPos(UINT8 nonRouteId)
{
	UINT8 	retVal = CI_SUCCESS;							/*本函数的返回值*/
	UINT8 	retValOfSetSwiDanCaoPos = CI_ERROR;				/*设置道岔期望驱动位置的返回值*/
	UINT8 	switchSum = 0u; 									/*道岔数目*/
	UINT16 	switchId = 0u; 									/*道岔ID*/
	UINT8 	ii = 0u;											/*循环变量*/
	NonRouteSwitchStruct* pNonRouteSwitchStru = NULL;
	UINT8 protectSwitchSum = 0u; /*防护道岔总数*/
	NonRouteProtectSwitchStruct* pNonRouteProtectSwitchStru = NULL; /*防护道岔数据*/

	/*获取非进路道岔数目*/
	switchSum = GetNonRouteSwitchSumById(nonRouteId);
	/*获取非进路关联道岔数据结构指针*/
	pNonRouteSwitchStru = GetNonRouteSwitchStructBufById(nonRouteId);
	protectSwitchSum = GetNonRouteRelatedProtSwitSum(nonRouteId); /*非进路防护道岔总数*/
	pNonRouteProtectSwitchStru = GetNonRouteRelatedProtSwitStru(nonRouteId); /*非进路防护道岔数据*/

	if(NULL != pNonRouteSwitchStru)
	{
		for(ii = 0u; ii < switchSum; ii++)
		{
			switchId = pNonRouteSwitchStru[ii].SwitchId;

			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID);

			if(CI_SUCCESS == retValOfSetSwiDanCaoPos)
			{

			}
			else
			{/*设置失败*/
				/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
				retVal = CI_ERROR;
			}
		}
	}
	else
	{
		retVal = CI_ERROR;
	}

	if(NULL != pNonRouteProtectSwitchStru)
	{
		for(ii = 0u; ii < protectSwitchSum; ii++)
		{
			switchId = pNonRouteProtectSwitchStru[ii].ProtectSwitchId;

			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID);

			if(CI_SUCCESS == retValOfSetSwiDanCaoPos)
			{

			}
			else
			{/*设置失败*/
				/*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
				retVal = CI_ERROR;
			}
		}
	}
	else
	{
		retVal = CI_ERROR;
	}


	return retVal;
}


/******************************区段数据交叉管理****************************/

/*
* 功能描述： 获取物理区段ARB信息
* 参数说明： void
* 返回值  ： AXIS_SECTION_ARB_NO  未ARB
*			 AXIS_SECTION_ARB_YES ARB
*/
UINT8 GetArbState(UINT16 phySectionId)
{
	UINT16* axisSectionIds = NULL;		/*计轴ID数组*/
	UINT8 axisSectionSum = 0u; /*包含的计轴总数*/
	UINT8 ii = 0u; /*游标*/
	UINT8 reValue = AXIS_SECTION_ARB_NO;
	UINT8 chArbState = 0U;

	axisSectionSum = GetPAxisSectionSum(phySectionId);
	axisSectionIds = GetPAxisSectionIdBuf(phySectionId);

    if ((NULL == axisSectionIds))
    {
        reValue = AXIS_SECTION_ARB_NO;
    }
	else
	{
		for (ii = 0u; ii < axisSectionSum; ii++)
		{
			chArbState = GetAxisSecArbState(axisSectionIds[ii]);
			if (AXIS_SECTION_ARB_YES == chArbState)
			{
				reValue = AXIS_SECTION_ARB_YES;
				break;
			}
			else
			{
			    /*无操作*/
			}
		}
	}
    return reValue;
}

/*
* 功能描述： 获取物理区段内逻辑区段占用融合信息
* 参数说明： void
* 返回值  ： 
*			 SECTION_OCCUPY_NO
*			 SECTION_OCCUPY_YES    
*/

/*暂时不用，做预留*/
#if 0
UINT8 GetLogicSecMergyOccuState(UINT16 phySectionId)
{
    UINT8 const axisSecSum = GetPAxisSectionSum(phySectionId);
    UINT16* const pAxisSecIdBuf = GetPAxisSectionIdBuf(phySectionId);

    UINT16 axisSecId = 0u;
    UINT8 logicSecSum = 0u;
    UINT16* pLogicSecIdBuf = NULL;

    UINT8 ii = 0u;
    UINT8 jj = 0u;
    UINT8 logicOccupyState = 0u;
	UINT8 reValue = SECTION_OCCUPY_NO;

    if ((0u == axisSecSum) || (NULL == pAxisSecIdBuf))
    {
        reValue = SECTION_OCCUPY_YES;
    }
	else
	{
		for (ii = 0u; ii < axisSecSum; ii++)
		{
			axisSecId = pAxisSecIdBuf[ii];
			logicSecSum = GetAxisSecLogSectionSum(axisSecId);
			pLogicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId);
			for (jj = 0u; jj < logicSecSum; jj++)
			{
				logicOccupyState = GetLogSecCurOccupyState(pLogicSecIdBuf[jj]);
				if (logicOccupyState == SECTION_OCCUPY_YES)
				{
					/*任一逻辑区段占用*/
					reValue = SECTION_OCCUPY_YES;
					break;
				}
			}
			if (reValue == SECTION_OCCUPY_YES)
			{
				break;
			}
		}
	}
    return reValue;
}
#endif

/*
* 功能描述： 获取物理区段内逻辑区段占用信息
* 参数说明： void
* 返回值  ： 
*			 SECTION_OCCUPY_NO
*			 SECTION_OCCUPY_YES    
*/
UINT8 GetLogicSecOccuState(UINT16 phySectionId)
{
    UINT8 const axisSecSum = GetPAxisSectionSum(phySectionId);
    UINT16* const pAxisSecIdBuf = GetPAxisSectionIdBuf(phySectionId);

    UINT16 axisSecId = 0u;
    UINT8 logicSecSum = 0u;
    UINT16* pLogicSecIdBuf = NULL;

    UINT8 ii = 0u;
    UINT8 jj = 0u;
    UINT8 logicOccupyState = 0u;
    UINT8 reValue = SECTION_OCCUPY_NO;

    if (0u == axisSecSum) 
    {
        reValue = SECTION_OCCUPY_YES;
    }
    else
    {
        for (ii = 0u; ii < axisSecSum; ii++)
        {
            axisSecId = pAxisSecIdBuf[ii];
            logicSecSum = GetAxisSecLogSectionSum(axisSecId);
            pLogicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId);
            for (jj = 0u; jj < logicSecSum; jj++)
            {
                logicOccupyState = GetLogSecOccupyState(pLogicSecIdBuf[jj]);
                if ((LOGICSECTION_OCCUPY_UT == logicOccupyState) || (LOGICSECTION_OCCUPY_CT == logicOccupyState))
                {
                    /*任一逻辑区段占用*/
                    reValue = SECTION_OCCUPY_YES;
                    break;
                }
				else
			    {
			        /*无操作*/
			    }
            }
            if (reValue == SECTION_OCCUPY_YES)
            {
                break;
            }
			else
			{
			    /*无操作*/
			}
        }
    }
    return reValue;
}

/******************************屏蔽门数据交叉管理****************************/

#if 0

/*
* 功能描述：计算指定屏蔽门开放导致其关联出站进路信号关闭的出站进路
* 参数说明： const UINT16 doorId  屏蔽门ID
*            const UINT8 PsdOpenedBeforeFlag 屏蔽门开之前标志  1:屏蔽门开之前统计  0:屏蔽门开之后统计
* 返回值  ： 无    
*/
void CalculatePsdOpenedLeadToSignalCloseRoute(const UINT16 doorId,const UINT8 PsdOpenedBeforeFlag)
{
	UINT8 outStationRouteSum = 0u;               /*屏蔽门关联的出站进路数目*/
	UINT16 * outStationRouteIdBuf = NULL;       /*屏蔽门关联的出站进路Id数组*/
	UINT8 signedCloseRouteSum = 0u;              /*屏蔽门开导致信号关闭的出站进路数目*/
	UINT16 * signedCloseRouteIdBuf = NULL;      /*屏蔽门开导致信号关闭的出站进路的Id数组*/
	UINT8 *psdOpenBeforeRouteIsBuildedFlagBuf =NULL;
	UINT8 routeState = 0u;                       /*进路状态*/
	UINT8 ii;
	UINT8 jj;

	outStationRouteSum = GetPsdRalatedOutStationRouteSum(doorId);           /*获取屏蔽门关联出站进路数目*/
	outStationRouteIdBuf = GetPsdRalatedOutStationRouteIdBuf(doorId);       /*获取屏蔽门关联出站进路ID数组*/


	for(ii = 0u;ii < outStationRouteSum;ii++)
	{/*遍历所有关联出站进路*/

		if(CI_ERROR == AutoSignalOrRouteValid(outStationRouteIdBuf[ii]))
		{/*不具有自动属性*/
			routeState = GetRouteState(outStationRouteIdBuf[ii]); /*获取出站进路状态*/
			if((ROUTE_STATE_FIRST_LOCKERR == routeState) ||
				(ROUTE_STATE_YUXIAN_LOCK == routeState) ||
				(ROUTE_STATE_NEAR_LOCKERR == routeState)
				)
			{/*进路状态为(进路初锁异常 ) || (进路预先锁闭) || (进路接近锁闭异常)，说明屏蔽门打开导致此进路信号关闭*/

				signedCloseRouteSum = GetBuildedOutStationRouteSum(doorId);    /*获取屏蔽门开放导致出站进路信号关闭的出站进路数目*/
				signedCloseRouteIdBuf = GetBuildedOutStationRouteIdBuf(doorId);/*获取屏蔽门开放导致出站进路信号关闭的出站进路ID数组*/	
				psdOpenBeforeRouteIsBuildedFlagBuf = GetPsdOpenBeforeOutStationRouteIsBuildedFlagBuf(doorId);
				for(jj = 0u;jj < signedCloseRouteSum;jj++)
				{/*遍历屏蔽门开导致信号关闭的出站进路数组，进行重复性检查*/
					if(outStationRouteIdBuf[ii] == signedCloseRouteIdBuf[jj])
					{/*之前已经保存*/
						break;
					}
				}
				if(jj == signedCloseRouteSum)
				{/*未保存过,进行保存*/

					signedCloseRouteIdBuf[signedCloseRouteSum] = outStationRouteIdBuf[ii];
					if(0u == PsdOpenedBeforeFlag)
					{/*开门之后统计*/
						psdOpenBeforeRouteIsBuildedFlagBuf[signedCloseRouteSum] = PSD_OPEN_BEFORE_SIG_CLOSE_NO;
					}
					else
					{/*开门之前统计*/
						psdOpenBeforeRouteIsBuildedFlagBuf[signedCloseRouteSum] = PSD_OPEN_BEFORE_SIG_CLOSE_YES;
					}

					signedCloseRouteSum++;
					SetBuildedOutStationRouteSum(doorId, signedCloseRouteSum);

				}
			}
		}

	}

}

#endif

/******************************自动折返进路数据交叉管理****************************/
/*
* 功能描述： 自动折返进路的折出进路是否可以办理有效性检查
* 参数说明： const UINT16 routeId, 进路Id
* 返回值  ： CI_ERROR: 数据无效
*			 CI_SUCCESS: 数据有效
*/
UINT8 GetAutoReturnRebackRouteValid(const UINT16 routeId)
{
    UINT8 autoRouteType = 0u;                /*自动进路类型*/
    UINT16 rebackRouteId = 0u;               /*自动折出进路Id*/
    UINT16 rebackRouteStartSignalId = 0u;    /*自动折出进路始端信号机Id*/
    UINT16 returnSectionId = 0u;             /*自动折返进路折返轨Id*/
    UINT8 returnSectionOccuState = 0u;       /*自动折返进路折返轨占用状态*/
    UINT8 returnSectionLockState = 0u;       /*自动折返进路折返轨锁闭状态*/
    UINT16 returnRouteId = 0u;               /*自动折返进路Id*/
    UINT8 returnRouteState = 0u;             /*自动折返进路状态*/
	UINT8 reValue = CI_ERROR;

    autoRouteType = GetRouteAutoRouteSetState(routeId);

    if (ROUTE_AUTOROUTE_RETURN == autoRouteType)
    {
        rebackRouteId = GetAutoReturnRebackRouteId(GetRouteAutoReturnId(routeId));
        if (rebackRouteId == routeId)
        {
            /*自动进路折出进路*/
            rebackRouteStartSignalId = GetRouteStartSignalId(routeId);
            returnSectionId = GetSignalOutFirstPhySecId(rebackRouteStartSignalId);
            returnSectionOccuState = GetPhySecCurMergeState(returnSectionId);
            returnSectionLockState = GetPhySecLockState(returnSectionId);
            returnRouteId = GetPhySecRLockBelongRouteId(returnSectionId);
            returnRouteState = GetRouteState(returnRouteId);

            if ((returnSectionOccuState == SECTION_OCCUPY_YES) &&
                (returnSectionLockState == PHYSICAL_SECTION_LOCK_NORMAL) &&
                (GetRouteAutoReturnId(returnRouteId) == GetRouteAutoReturnId(rebackRouteId)) &&
                ((returnRouteState == ROUTE_STATE_AUTO_UNLOCK) || (returnRouteState == ROUTE_STATE_NEAR_LOCK))
                )
            {
                /*折返轨【占用】且【正常锁闭】 且 折返进路所属自动折返Id与折出进路所属自动折返Id相等
                且 折返进路状态为【自动解锁正常】或【接近锁闭正常】*/
                /*自动折返进路的折出进路办理*/
                reValue = CI_SUCCESS;
            }
        }
        else
        {
            /*非自动折返进路的折出进路*/
            reValue = CI_ERROR;
        }
    }
    else
    {
        /*非自动折返进路*/
        reValue = CI_ERROR;
    }
	return reValue;
}


/*
* 功能描述： 自动折返进路的折出进路是否可以办理有效性检查
* 参数说明： const UINT16 routeId, 进路Id
* 返回值  ：
        AUTO_RETURN_ROUTE_TYPE_IN           0x55       折返
        AUTO_RETURN_ROUTE_TYPE_OUT          0xAA        折出
        AUTO_RETURN_ROUTE_TYPE_VAIN         0xFF        无效
*/
UINT8 GetAutoReturnRouteType(const UINT16 autoReturnId, const UINT16 routeId)
{
    UINT8 ii = 0u;
    UINT8 autoIncludeRouteSum = 0u;
    UINT16 *pAutoIncludeRouteIdbuf = NULL;
    
    UINT8 autoSetFlag = AUTO_RETURN_ROUTE_TYPE_VAIN;
    
    if ((autoReturnId >= 1u) && (autoReturnId < AUTO_RETURN_SUM_MAX))
    {            
        autoIncludeRouteSum = GetAutoReturnIncludeRouteSum(autoReturnId);
        pAutoIncludeRouteIdbuf = GetAutoReturnIncludeRouteBuf(autoReturnId);
        
        for (ii = 0u; ii < (autoIncludeRouteSum - 1u); ii++)
        {
            if (pAutoIncludeRouteIdbuf[ii] == routeId)
            {
                /*折返进路*/
                autoSetFlag = AUTO_RETURN_ROUTE_TYPE_IN;
				break;
            }
        }

        if (pAutoIncludeRouteIdbuf[autoIncludeRouteSum - 1u] == routeId)
        {
            /*折出进路*/
            autoSetFlag = AUTO_RETURN_ROUTE_TYPE_OUT;
        }
    }
	else
    {
        /*无效自动折返进路*/
        autoSetFlag = AUTO_RETURN_ROUTE_TYPE_VAIN;
    }

	return autoSetFlag;
}


/******************************overlap数据交叉管理****************************/
/*
* 功能描述： 获取指定ID保护区段组锁闭状态
* 参数说明： const UINT16 overlapId, 保护区段ID    
* 返回值  ： 0: 未锁闭
*			>0: 锁闭状态    
*/
UINT8 GetOverlapLockState(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u; /*数组下标*/
	UINT8 ContainSecSum = 0u; /*包含区段数目*/
	UINT16* ContainSecStru = NULL; /*包含区段ID数组*/
	UINT16 PhySecId = 0u; /*当前区段ID*/
	UINT8 ii = 0u;
	UINT8 tmpPhyState = 0u;  /*临时变量，物理区段状态*/
	UINT16 tmpRouteId = 0u;/*临时变量，进路id*/
	UINT8 reVal = CI_ERROR;
	
	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/
	
	if (OVERLAP_SUM_MAX > bufIndex)
	{
		ContainSecSum = GetOverlapPhySecSum(overlapId);
		ContainSecStru = GetOverlapPhySecIdBuf(overlapId);

		if (0u == ContainSecSum)
		{
			reVal = CI_ERROR;
		}
		else
		{
			reVal = CI_SUCCESS;
		}
		if(CI_SUCCESS == reVal)
		{
			for (ii = 0u; ii < ContainSecSum; ii++)
			{
				PhySecId = ContainSecStru[ii];
				tmpPhyState = GetPhySecLockState(PhySecId);
				tmpRouteId = GetOverlapBelongRouteId(overlapId);
				if ((PHYSICAL_SECTION_LOCK_PROTECT == tmpPhyState)
					|| (0u != tmpRouteId))
				{

				}
				else
				{
					reVal = CI_ERROR;
					break;
				}
			}
		}
		else
		{
		    /*无操作*/
		}
	}
	else
	{
		reVal = CI_ERROR;
	}
	return reVal;
}


/******************************自动进路数据交叉管理****************************/
/*
* 功能描述： 进路自动属性有效性检查
* 参数说明： const UINT16 routeId, 进路ID
* 返回值  ： UINT8 
*/
UINT8 AutoSignalOrRouteValid(const UINT16 routeId)
{
	UINT8 autoRouteProperty = 0u;    /*自动进路属性*/
	UINT8 autoSigRouteState = 0u;    /*自动信号进路状态*/
	UINT8 autoRouteState = 0u;       /*自动进路状态*/
    UINT8 retVal = CI_SUCCESS;      /*返回值*/
	
	
	/*获取进路动态字段*/
	autoRouteProperty = GetRouteAutoRouteProperty(routeId);    /*获取进路自动进路属性*/
	autoSigRouteState = GetRouteAutoSigSetState(routeId);        /*获取自动信号进路状态*/
	autoRouteState = GetRouteAutoRouteSetState(routeId);       /*获取进路自动进路状态*/

	
	
	/*自动进路或自动信号处理*/
    if ((ROUTE_AUTOSIGROUTE_YES == autoSigRouteState) || 
		((ROUTE_AUTOROUTE_PROPERTY_YES == autoRouteProperty) && 
        ((ROUTE_AUTOROUTE_NORMAL == autoRouteState) || (ROUTE_AUTOROUTE_RETURN == autoRouteState)||
		(ROUTE_ALLAUTOROUTE_RETURN == autoRouteState))
        )
       )
	{ /*自动信号或自动进路*/
	
		retVal = CI_SUCCESS; 
	}
	else
	{
		retVal = CI_ERROR; 
	}
	return retVal;
}



/******************************车辆段数据交叉管理****************************/
/*
* 功能描述： 获取停止检查标志
* 参数说明： void
* 返回值  ： UINT8 停止检查标志
*/
UINT8 GetStopCheckFlag(void)
{
    return StopCheckState;
}

/*
* 功能描述： 设置停止检查标志
* 参数说明： void
* 返回值  ：    
*/
void SetStopCheckFlag(void)
{
	StopCheckState = ROUTE_STOPCHECK_SET_YES; /*设置停止检查*/
}


/*
* 功能描述： 取消停止检查标志
* 参数说明： void
* 返回值  ：    
*/
void CancelStopCheckFlag(void)
{
	StopCheckState = ROUTE_STOPCHECK_SET_NO; /*取消停止检查*/
}


/*
* 功能描述： 获取应急盘继电器ID
* 参数说明： void
* 返回值  ：    
*/
UINT16 GetJkjRelayId(void)
{
	return JkjRelayId;
}


/*
* 功能描述： 获取宕机标志
* 参数说明： void
* 返回值  ： 
*/
UINT8 GetPlatOverFlag(void)
{
	return PlatOverFlag;
}


/*
* 功能描述： 获取宕机标志
* 参数说明： void
* 返回值  ： 
*/
void SetPlatOverFlag(void)
{
	PlatOverFlag = CI_OVER_YES;
}


/*
* 功能描述： 引导总锁开放引导信号机逻辑管理
* 参数说明： void
* 返回值  ： void   
*/
void YLockSignalOpenManage(void)
{
    UINT16 signalCurSum = GetSignalCurSum();     /*信号机总数目*/
    UINT8 localCiId = GetSystemParaLocalCiId();         /*本地联锁ID*/
    UINT16 signalId = 0u;
    UINT8 belongCiId = 0u;
    
    UINT16 ii = 0u;               /*循环索引*/
	UINT8 belongVirCI = 0u;
	UINT8 flag = 0u;
	UINT8 yLockState = 0u;
	UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);

	
    /*处理信号机*/
    for (ii = 0u; ii < signalCurSum; ii++)
    {
		flag = 0u;
        signalId = 0u;	         /*道岔ID*/
        belongCiId = 0u;          /*进路所属联锁ID*/
        
        signalId = GetSignalId(ii);                         /*获取信号机ID*/
        belongCiId = GetSignalBelongCiId(signalId);           /*获取进路所属联锁ID*/
		if(FUNC_SWITCH_ON == includeVirFlag)
		{
			belongVirCI = GetSignalBelongVirCiId(signalId); /*获取信号机所属虚拟联锁ID*/
			yLockState = GetVirCIAllSwitchYLockState(belongVirCI);
		}
		else
		{
			yLockState = GetAllSwitchYLockFlag();
		}
        
        if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX))
        {
            flag =1u;
        }
        
        if ((belongCiId != localCiId) || (localCiId == 0u))
        {
             flag =1u;
        }

		if (0u == flag)
		{
			/*引导总锁重开引导信号新逻辑*/
			LeadzLockNewOpenManage(signalId, yLockState);
		}
		else
		{
			;	/*不处理*/
		}
		
    }
}

/******************************全自动折返进路数据交叉管理****************************/

/*
* 功能描述： 全自动折返进路的折出进路是否可以办理有效性检查
* 参数说明： const UINT16 routeId, 进路Id
* 返回值  ： CI_ERROR: 数据无效
*			 CI_SUCCESS: 数据有效
*/
UINT8 GetAllAutoReturnOutRouteValid(const UINT16 routeId)
{
    UINT8 autoRouteType = 0u;                /*自动进路类型*/

    UINT16 rebackRouteStartSignalId = 0u;    /*全自动折出进路始端信号机Id*/
    UINT16 returnSectionId = 0u;             /*全自动折返进路折返轨Id*/
    UINT8 returnSectionOccuState = 0u;       /*全自动折返进路折返轨占用状态*/
    UINT8 returnSectionLockState = 0u;       /*全自动折返进路折返轨锁闭状态*/
    UINT8 returnRouteState = 0u;             /*全自动折返进路状态*/
	UINT16 returnRouteId = 0u;
	UINT8 ii = 0u;

	UINT16 allAutoReturnId = 0u;
	UINT8 allReturnRouteSum = 0u;
    UINT16 *pAllReturnRouteBuf = NULL;               /*全自动折返进路数组*/
	UINT16 otherRebackRouteStartSignalId = 0u;
	UINT16 otherReturnSectionId = 0u;
	UINT8 returnValue = CI_ERROR;
    autoRouteType = GetRouteAutoRouteSetState(routeId);
	allAutoReturnId = GetRouteAllAutoReturnId(routeId);
	/*是否需要判断全自动折返进路的有效性？*/
    if (autoRouteType == ROUTE_ALLAUTOROUTE_RETURN)
    {
        pAllReturnRouteBuf = GetAllAutoReturnRebackRouteBuf(allAutoReturnId);
        allReturnRouteSum = GetAllAutoReturnRebackRouteSum(allAutoReturnId);
		if ((ALL_AUTO_RETURN_REBACKROUTE_SUM_MAX < allReturnRouteSum)||(0u ==routeId)) 
		{
			returnValue = CI_ERROR;
		}
		else
		{
						/*全自动折返进路折出进路*/
			rebackRouteStartSignalId = GetRouteStartSignalId(routeId);
			returnSectionId = GetSignalOutFirstPhySecId(rebackRouteStartSignalId);    /*折返轨区段ID*/
			returnSectionOccuState = GetPhySecCurMergeState(returnSectionId);
			returnSectionLockState = GetPhySecLockState(returnSectionId);
			returnRouteId = GetPhySecRLockBelongRouteId(returnSectionId);
			returnRouteState = GetRouteState(returnRouteId);
			if ((returnSectionOccuState == SECTION_OCCUPY_YES) &&
				(returnSectionLockState == PHYSICAL_SECTION_LOCK_NORMAL) &&
				(GetRouteAllAutoReturnId(returnRouteId) == GetRouteAllAutoReturnId(routeId)) &&
				((returnRouteState == ROUTE_STATE_AUTO_UNLOCK) || (returnRouteState == ROUTE_STATE_NEAR_LOCK)))
			{
				/*折返轨【占用】且【正常锁闭】 且 折返进路所属自动折返Id与折出进路所属自动折返Id相等
				且 折返进路状态为【自动解锁正常】或【接近锁闭正常】*/
				/*自动折返进路的折出进路办理*/
				returnValue = CI_SUCCESS;
			}
			else
			{
				returnValue = CI_ERROR;
			}
			for (ii = 0u; ii < allReturnRouteSum; ii++)
			{
				if (pAllReturnRouteBuf[ii] != routeId)
				{

					otherRebackRouteStartSignalId = GetRouteStartSignalId(pAllReturnRouteBuf[ii]);
					otherReturnSectionId = GetSignalOutFirstPhySecId(otherRebackRouteStartSignalId);    /*折返轨区段ID*/

				}
			}
			if (CI_SUCCESS == returnValue)
			{
				
				if(CompareOccuTime(returnSectionId , otherReturnSectionId) > 0u)
 				{
 					/*本折出进路的触发时间比另一条折出进路的触发时间长，则办理本进路*/
					returnValue = CI_SUCCESS;
 				}
 				else
 				{
 					returnValue = CI_ERROR;
 				}
			} 
		}
    }
    else
    {
        /*非全自动折返进路*/
        returnValue = CI_ERROR;
    }
	return returnValue;
}

/*
* 功能描述： 全自动折返进路所包含进路的属性
* 参数说明： const UINT16 routeId, 进路Id
* 返回值  ：
        ALL_AUTO_RETURN_ROUTE_TYPE_IN           0x55       折返
        ALL_AUTO_RETURN_ROUTE_TYPE_OUT          0xAA        折出
        ALL_AUTO_RETURN_ROUTE_TYPE_VAIN         0xFF        无效
*/
UINT8 GetAllAutoReturnRouteType(const UINT16 allAutoReturnId, const UINT16 routeId)
{
    UINT8 ii = 0u;
	UINT8 autoIncludeRouteSum = 0u;
    UINT16 *pAutoIncludeRouteIdbuf = NULL;
    
    UINT8 autoSetFlag = CI_ERROR;
    
    if ((1u <= allAutoReturnId) && (ALL_AUTO_RETURN_SUM_MAX > allAutoReturnId))
    {            
        autoIncludeRouteSum = GetAllAutoReturnIncludeRouteSum(allAutoReturnId);
        pAutoIncludeRouteIdbuf = GetAllAutoReturnIncludeRouteBuf(allAutoReturnId);
        if(2u < autoIncludeRouteSum)
		{
			for (ii = 0u; ii < (autoIncludeRouteSum - 2u); ii++)
			{
				if (pAutoIncludeRouteIdbuf[ii] == routeId)
				{
					/*折返进路*/
					autoSetFlag = ALL_AUTO_RETURN_ROUTE_TYPE_IN;
					break;
				}
				else
	           {
	            	/*无操作*/
		       }
			}
		
			if(ALL_AUTO_RETURN_ROUTE_TYPE_IN != autoSetFlag)
			{
				if((pAutoIncludeRouteIdbuf[autoIncludeRouteSum - 1u] == routeId)||
					(pAutoIncludeRouteIdbuf[autoIncludeRouteSum - 2u] == routeId))
				{
					/*折出进路*/
					autoSetFlag = ALL_AUTO_RETURN_ROUTE_TYPE_OUT;
				}
				else
				{
					/*未找到相应进路*/
					autoSetFlag = ALL_AUTO_RETURN_ROUTE_TYPE_VAIN;
				}

			}
			else
	        {
	         	/*无操作*/
		    }
		}
		else
		{
			/*未找到相应进路*/
			autoSetFlag = ALL_AUTO_RETURN_ROUTE_TYPE_VAIN;
		}
    }

	else
    {
        /*无效全自动折返进路*/
        autoSetFlag = ALL_AUTO_RETURN_ROUTE_TYPE_VAIN;
    }
	return autoSetFlag;
}


/******************************点式临时限速数据计算****************************/

/*
* 功能描述： 进路包含的逻辑区段是否被设置了临时限速
* 参数说明： const UINT16 routeId, 进路Id
* 返回值  ：
           LOGSEC_LSXS_SET_STATE_NO 		 0x55 未设置临时限速（大于等于1条被设置）
           LOGSEC_LSXS_SET_STATE_YES 		 0xAA 设置了临时限速（全未设置）
*/
static UINT8  RouteIncludeLogSecLSXSSetCheck(const UINT16 routeId)
{
	UINT8 retVal = LOGSEC_LSXS_SET_STATE_NO;

	UINT16 jj = 0u;
	UINT16 kk = 0u;
	UINT16 mm = 0u;
	UINT16 phySecId = 0u;             /*物理区段ID*/
	UINT16 axisSecId = 0u;            /*计轴区段ID*/
	UINT16 logicSecId = 0u;           /*逻辑区段ID*/


	UINT16 physicalSectionSum = 0u;    /*进路包含物理区段数目*/
	UINT16 axisSectionSum = 0u;        /*物理区段包含计轴区段数目*/
	UINT16 secLogSectionSum = 0u;      /*计轴区段包含逻辑区段数目*/

	RoutePhysicalSectionStruct * routePhysicalSectionStru = NULL;  /*进路包含物理区段结构体数组指针*/
	UINT16 * axisSecIdBuf = NULL;                                  /*物理区段包含计轴区段ID数组指针*/
	UINT16 * logicSecIdBuf = NULL;                                 /*计轴区段包含逻辑区段ID数组指针*/

	routePhysicalSectionStru = GetRouteSectionData(routeId);   /*获取进路包含物理区段结构体数组指针*/
	physicalSectionSum = GetRoutePhysicalSectionSum(routeId);  /*获取进路包含物理区段数目*/
	for(jj = 0u;jj < physicalSectionSum;jj++)
	{
		phySecId = routePhysicalSectionStru[jj].PhysicalSectionId;

		if(GetPhySecRLockBelongRouteId(phySecId)  == routeId )
		{/*表示:本物理区段是为本进路锁闭，物理区段所包含的逻辑区段的临时限速对本进路才有效*/
			axisSecIdBuf = GetPAxisSectionIdBuf(phySecId);         /*获取物理区段包含计轴区段ID数组指针*/
			axisSectionSum = GetPAxisSectionSum(phySecId);         /*获取物理区段包含计轴区段数目*/
			for(kk = 0u; kk < axisSectionSum;kk++)
			{
				axisSecId = axisSecIdBuf[kk];
				logicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId);  /*获取计轴区段包含逻辑区段ID数组指针*/
				secLogSectionSum = GetAxisSecLogSectionSum(axisSecId); /*获取计轴区段包含逻辑区段数目*/
				for(mm = 0u;mm < secLogSectionSum;mm++ )
				{
					logicSecId = logicSecIdBuf[mm];
					if(LOGSEC_LSXS_SET_STATE_YES == GetLogSecLinShiXianSuSetState(logicSecId))
					{/*(此逻辑区段设置了临时限速) 并且 (此逻辑区段所属的物理区段被本进路锁闭) <==> 包含临时限速区段的进路成功办理*/
						break;
					}
				}
				if(mm < secLogSectionSum)
				{/*在此计轴区段内已经找到有一条逻辑区段设置了临时限速，无需再遍历其他计轴区段*/
					break;
				}
			}

			if(kk < axisSectionSum)
			{/*在此物理区段已经找到了一条计轴区段包括了设置临时限速的逻辑区段，无需再遍历其他物理区段*/
				retVal = LOGSEC_LSXS_SET_STATE_YES;
				break;
			}
		}/*if(GetPhySecRLockBelongRouteId(phySecId)  == routeId )*/	
	}/*for(jj = 0;jj < physicalSectionSum;jj++)*/
	return retVal;

}


/*
* 功能描述： 进路保护区段是否被设置了临时限速
* 参数说明： const UINT16 routeId, 进路Id
* 返回值  ：
           LOGSEC_LSXS_SET_STATE_NO 		 0x55 未设置临时限速（大于等于1条被设置）
           LOGSEC_LSXS_SET_STATE_YES 		 0xAA 设置了临时限速（全未设置）
*/
static UINT8  RouteOvlpLogSecLSXianSuSetCheck(const UINT16 routeId)
{
	UINT8 retVal = LOGSEC_LSXS_SET_STATE_NO;

	UINT16 jj = 0u;
	UINT16 kk = 0u;
	UINT16 mm = 0u;
	UINT16 phySecId = 0u;                          /*物理区段ID*/
	UINT16 axisSecId = 0u;                         /*计轴区段ID*/
	UINT16 logicSecId = 0u;                        /*逻辑区段ID*/


	UINT16 physicalSectionSum = 0u;                 /*进路包含物理区段数目*/
	UINT16 axisSectionSum = 0u;                     /*物理区段包含计轴区段数目*/
	UINT16 secLogSectionSum = 0u;				   /*计轴区段包含逻辑区段数目*/


	UINT16 * routePhysicalSectionIdBuf = NULL;     /*OVERLAP包含物理区段结构体数组指针*/
	UINT16 * axisSecIdBuf = NULL;                  /*物理区段包含计轴区段ID数组指针*/
	UINT16 * logicSecIdBuf = NULL;                 /*计轴区段包含逻辑区段ID数组指针*/

	UINT16 overlapLockedId = GetRouteOverlapLockedId(routeId);

	if(0u == overlapLockedId)
	{
		/*进路无保护区段时，保护区段临时限速检查默认通过，为未设置临时限速*/
		retVal = LOGSEC_LSXS_SET_STATE_NO;
	}
	else
	{
		physicalSectionSum = GetOverlapPhySecSum(overlapLockedId);
		routePhysicalSectionIdBuf = GetOverlapPhySecIdBuf(overlapLockedId);

		for(jj = 0u;jj < physicalSectionSum;jj++)
		{
			phySecId = routePhysicalSectionIdBuf[jj];

			if(GetPhySecPLockBelongRouteId(phySecId)  == routeId )
			{/*表示:本物理区段是为本进路防护锁闭，物理区段所包含的逻辑区段的临时限速对本进路才有效*/
				axisSecIdBuf = GetPAxisSectionIdBuf(phySecId);         /*获取物理区段包含计轴区段ID数组指针*/
				axisSectionSum = GetPAxisSectionSum(phySecId);         /*获取物理区段包含计轴区段数目*/
				for(kk = 0u; kk < axisSectionSum;kk++)
				{					
					axisSecId = axisSecIdBuf[kk];
					logicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId);  /*获取计轴区段包含逻辑区段ID数组指针*/
					secLogSectionSum = GetAxisSecLogSectionSum(axisSecId); /*获取计轴区段包含逻辑区段数目*/
					for(mm = 0u;mm < secLogSectionSum;mm++ )
					{
						logicSecId = logicSecIdBuf[mm];
						if(LOGSEC_LSXS_SET_STATE_YES == GetLogSecLinShiXianSuSetState(logicSecId))
						{/*(此逻辑区段设置了临时限速) 并且 (此逻辑区段所属的物理区段被本进路锁闭) <==> 包含临时限速区段的进路成功办理*/
							break;
						}
					}
					if(mm < secLogSectionSum)
					{/*在此计轴区段内已经找到有一条逻辑区段设置了临时限速，无需再遍历其他计轴区段*/
						break;
					}
				}

				if(kk < axisSectionSum)
				{/*在此物理区段已经找到了一条计轴区段包括了设置临时限速的逻辑区段，无需再遍历其他物理区段*/

					break;
				}
			}/*if(GetPhySecPLockBelongRouteId(phySecId)  == routeId )*/	
		}/*for(jj = 0;jj < physicalSectionSum;jj++)*/

		if(jj < physicalSectionSum)
		{
			retVal = LOGSEC_LSXS_SET_STATE_YES;
		}
	}

	return retVal;
}

/*
* 功能描述： 信号机临时限速计算(按照关联进路计算)
* 参数说明： void
* 返回值  ： void   
*/
void RouteSignalLSXianSuCalculate(void)
{
	UINT16 ii = 0u;
	UINT16 routeId = 0u;              /*进路ID*/

	UINT16 startSignalId = 0u;        /*进路始端信号机ID*/
	UINT16 signalId = 0u;             /*信号机ID*/      

	UINT16 routeSum = 0u;              /*进路数目*/
	UINT16 signalSum = 0u;             /*信号机数目*/
                 
	UINT8 routeState = 0u;                                          /*进路状态*/
	UINT8 chOvlpLSCheck = 0U;
	UINT8 chLogSecLSCheck = 0U;
	routeSum = GetRouteCurSum();                                   /*获取进路当前总数*/
	signalSum = GetSignalCurSum();                                 /*获取信号机当前总数*/

	/*将所有临时限速有效的信号机的临时限速初始化为未设置临时限速*/
	for (ii = 0u; ii < signalSum; ii++)
	{
		signalId = GetSignalId(ii);

		SetSignalLinShiXianSuSetFlag(signalId, SIGNAL_LINSHIXIANSUSET_STATE_NO);

	}

	/*以进路为对象，设置其始端信号机的临时限速标志位*/
	for (ii = 0u; ii < routeSum; ii++)
	{
		routeId = GetRouteId(ii);
		startSignalId = GetRouteStartSignalId(routeId);
		/*进路完整锁闭状态才会判断临时限速*/
		/*进路始端信号机：临时限速有效（即可以被设置临时限速）*/
		routeState = GetRouteState(routeId);                       /*获取进路当前状态*/
		if ((ROUTE_STATE_FIRST_LOCK == routeState) ||
			(ROUTE_STATE_FIRST_LOCKERR == routeState) ||
			(ROUTE_STATE_YUXIAN_LOCK == routeState) ||
			(ROUTE_STATE_YUXIAN_OPEN == routeState) ||
			(ROUTE_STATE_NEAR_OPEN == routeState) ||
			(ROUTE_STATE_NEAR_LOCKERR == routeState) ||
			(ROUTE_STATE_LEAD_LOCK == routeState) ||
			(ROUTE_STATE_LEAD_LOCKERR == routeState) ||
			(ROUTE_STATE_LEAD_OPEN == routeState) ||
			(ROUTE_STATE_DELAY_UNLOCK == routeState) ||
			(ROUTE_STATE_NEAR_LOCK == routeState))
		{ /*表示:进路完整锁闭,临时限速对其才有效*/
			chOvlpLSCheck = RouteOvlpLogSecLSXianSuSetCheck(routeId);
			if (LOGSEC_LSXS_SET_STATE_NO == chOvlpLSCheck)
			{/*保护区段未设置临时限速*/
				chLogSecLSCheck = RouteIncludeLogSecLSXSSetCheck(routeId);
				if (LOGSEC_LSXS_SET_STATE_YES == chLogSecLSCheck)
				{/*进路包含区段设置了临时限速*/
					SetSignalLinShiXianSuSetFlag(startSignalId, SIGNAL_LINSHIXIANSUSET_STATE_YES);
				}
			}
			else
			{/*保护区段设置了临时限速*/
				SetSignalLinShiXianSuSetFlag(startSignalId, SIGNAL_LINSHIXIANSUSET_STATE_YES);
			}

		}


	}
}


/*
* 功能描述： 信号机临时限速计算(按照信号机关联限速区段计算)
* 参数说明： void
* 返回值  ： void   
*/
void OutStationSignalLSXSCalculate(void)
{
	UINT16 ii = 0u;
	UINT16 jj = 0u;
	SignalDataStruct * pSignalDataStr = NULL;             
	UINT16 * pLogSecBuf = NULL;                 
	UINT16   logSecSum = 0u;
	UINT16   signalId = 0u;
	
	pSignalDataStr = GetSignalData();                          /*获取信号机动态数组首地址*/

	for(ii = 0u;ii < GetSignalCurSum();ii++)
	{/*遍历所有的信号机*/

		signalId = GetSignalId(ii);                            /*获取信号机ID*/


		logSecSum = GetSignalRelatedLogSecSum(signalId);   /*获取信号机临时限速关联逻辑区段数量*/
		pLogSecBuf = GetSignalRelatedLogSecIdBuf(signalId);/*获取信号机临时限速关联逻辑区段ID数组*/

		if(0u == logSecSum )
		{
			
			SetSignalLinShiXianSuSetFlag(signalId,SIGNAL_LINSHIXIANSUSET_STATE_YES);
		
		}
		else
		{
            SetSignalLinShiXianSuSetFlag(signalId,SIGNAL_LINSHIXIANSUSET_STATE_NO);
			for(jj = 0u;jj < logSecSum;jj++)
			{/*遍历所有的关联的逻辑区段*/

				if(LOGSEC_LSXS_SET_STATE_YES == GetLogSecLinShiXianSuSetState(pLogSecBuf[jj]))
				{/*有一条逻辑区段设置了临时限速，则此出站信号机就设置临时限速*/
					SetSignalLinShiXianSuSetFlag(signalId,SIGNAL_LINSHIXIANSUSET_STATE_YES);
					break;
				}
			}

		}

		
	}
}


/*
* 功能描述： 信号机临时限速计算
* 参数说明： void
* 返回值  ： void
*/
void SignalLinShiXianSuFlagCalculate(void)
{
	UINT8 functionSwitchFlag = 0U;   /*临时限速计算方式*/
	functionSwitchFlag = GetCiFunctionSwitchConfig(FUNC_SIGNAL_LSXS_TYPE);

	if (FUNC_SWITCH_ON == functionSwitchFlag)
	{
		/*按照以该信号机为始端的进路是否存在临时限速来计算*/
		RouteSignalLSXianSuCalculate();
	}
	else
	{
		/*按照配置数据中信号机关联的临时限速区段来计算*/
		OutStationSignalLSXSCalculate();
	}
}


/******************************反向进路相关计算****************************/
/*
* 功能描述： 设置指定ID反向进路包含自动信号进路自动属性失效标志
* 参数说明： const UINT16 routeId, 进路ID
*            const UINT8 autoSigPropertyLoseEfficacyFlag, 进路自动信号属性失效设置标志
* 返回值  ： 无
*            
*/
void SetRevrRouteAutoSigInvalidFlag(const UINT16 routeId, const UINT8 autoSigPropertyLoseEfficacyFlag)
{
	UINT8 i = 0u;
	UINT8 retVal = CI_SUCCESS;
	UINT8 localCiId = 0u;
	UINT8 autoSigRouteBelongCi = 0u;
	UINT8 reverseRouteAutoSigRouteSum = 0u;       /*反向进路包含自动信号进路数目*/
    UINT16 * reverseRouteAutoSigRouteBuf = NULL; /*反向进路包含自动信号进路Id数组*/
	reverseRouteAutoSigRouteSum = GetReverseRouteIncludeRouteSum(routeId);/*获取反向进路包含自动信号进路数目*/
	reverseRouteAutoSigRouteBuf = GetReverseRouteIncludeRouteBuf(routeId);/*或取反向进路包含自动信号进路ID数组*/

	localCiId = GetSystemParaLocalCiId();  /*获取本机联锁ID*/

	for(i = 0u;i < reverseRouteAutoSigRouteSum;i++)
	{
		/*获取自动信号所属联锁*/
		autoSigRouteBelongCi = GetRouteBelongCiId(reverseRouteAutoSigRouteBuf[i]);
		if(localCiId == autoSigRouteBelongCi)
		{
			retVal = SetRouteAutoSigLoseEfficacyFlag(reverseRouteAutoSigRouteBuf[i], autoSigPropertyLoseEfficacyFlag);
			if(CI_ERROR == retVal)
			{
				break;
			}
		}
		/*自动信号不是本联锁*/
		else
		{
			if(ROUTE_AUTOSIG_LOSE_SET_NO == autoSigPropertyLoseEfficacyFlag)
			{
				/*添加相邻联锁处理命令*/
				AddCiSendToCiCmdInfo(CI_CMD_SET_AUTO_SIG_ROUTE_VALID, reverseRouteAutoSigRouteBuf[i],0u,autoSigRouteBelongCi);
			}
		}
	}
}



/*
* 功能描述： 设置SPKS状态以及区段封锁
* 参数说明： spksId		SPKS ID
			 spksStatus SPKS状态
* 返回值  ： 无
* cgh-合并CID-2539-2\CID-2588-5：
*/
void SetPhySecSpksFLockBySpksId(UINT16 spksId,UINT8 spksStatus)
{	
	UINT16 phySecSumOfSpks = 0u;
	UINT16 tmpPhySecId = 0u;
	UINT16 spksIndex = 0u;
	UINT16 phySecIndex = 0u;
	UINT8 phySecFlockState = PHYSICAL_SECTION_FLOCK_YES;
	UINT8 tmpRet = CI_ERROR;
	UINT8 typeFlockType = 0u;
	UINT8 CheckPhySecFlock = CI_ERROR;
	UINT32 curCycNum = 0U; 
	UINT8 curSpksState = 0U;

	curSpksState = GetSpksState(spksId);
	curCycNum = Get2oo2CurCycleNum();
	spksIndex = GetSpksConfigBufIndex(spksId);
	

	if (SPKS_SUM_MAX > spksIndex)
	{
		/*设置SPKS按钮状态*/
		if ((SPKS_STATUS_YES == spksStatus) && (SPKS_STATUS_YES != curSpksState))
		{
			tmpRet = SetSpksState(spksId, spksStatus);
			phySecFlockState = PHYSICAL_SECTION_FLOCK_YES;
			SetSpksflockStartNum(spksId, curCycNum);
		}
		else if ((SPKS_STATUS_NO == spksStatus) && (SPKS_STATUS_NO != curSpksState))
		{
			tmpRet = SetSpksState(spksId, spksStatus);
			phySecFlockState = PHYSICAL_SECTION_FLOCK_NO;
			SetSpksflockStartNum(spksId, 0U);
		}
		else
		{
			spksIndex = SPKS_SUM_MAX;
		}


	}
	else
	{
		spksIndex = SPKS_SUM_MAX;
	}
	

	/* 从SPKS配置数据中获取对应的物理区段，将对应的物理区段设置成对应的状态 */
	if ((spksIndex > 0u) && (spksIndex < SPKS_SUM_MAX) && (CI_SUCCESS == tmpRet))
	{
		phySecSumOfSpks = GetSpksPhySecSumByIndex(spksId);
		for (phySecIndex = 0u; phySecIndex < phySecSumOfSpks; phySecIndex++)
		{
			tmpPhySecId = GetSpksPhySecId(spksId,phySecIndex);
			CheckPhySecFlock = CheckPhySecFlockBlongSpks(tmpPhySecId,spksId);
			if ((tmpPhySecId > 0u) && (tmpPhySecId < PHYSICAL_SECTION_SUM_MAX))
			{
				if(SPKS_STATUS_NO == spksStatus)
				{
					typeFlockType = GetPhySecFLockType(tmpPhySecId);
					
					if((PHY_SEC_FLOCK_TYPE_SPKS == typeFlockType)&&(CI_SUCCESS == CheckPhySecFlock))
					{
						tmpRet = SetPhySecFLockState(tmpPhySecId,phySecFlockState);
					}
				}
				else
				{
					tmpRet = SetPhySecFLockState(tmpPhySecId,phySecFlockState);
				}			
				if(CI_ERROR == tmpRet)
				{
					break;
				}
				/*cgh-合并CID-2539-2\CID-2588-5：,根据SPKS操作命令设置物理区段封锁类型*/
				typeFlockType = GetPhySecFLockType(tmpPhySecId);
				if ( SPKS_STATUS_YES == spksStatus )
				{
					if(PHY_SEC_FLOCK_TYPE_CMD == typeFlockType)
					{
						SetPhySecFLockType(tmpPhySecId, PHY_SEC_FLOCK_TYPE_SPKSCMD);/*封锁类型设置SPKS按下 且区段封锁命令 封锁*/
					}
					else if(PHY_SEC_FLOCK_TYPE_NONE == typeFlockType)
					{
						SetPhySecFLockType(tmpPhySecId, PHY_SEC_FLOCK_TYPE_SPKS);/*记录物理区段封锁是由于SPKS按下导致*/
					}
					else
					{
						/*已经设置SPKS封锁类型*/
					}
				} 
				else if (SPKS_STATUS_NO == spksStatus)
				{
					if((PHY_SEC_FLOCK_TYPE_SPKS == typeFlockType)&&(CI_SUCCESS == CheckPhySecFlock))
					{
						SetPhySecFLockType(tmpPhySecId, PHY_SEC_FLOCK_TYPE_NONE);/*之前只有SPKS封锁，取消后设置无封锁*/
					}
					else if((PHY_SEC_FLOCK_TYPE_SPKSCMD == typeFlockType)&&(CI_SUCCESS == CheckPhySecFlock))
					{
						SetPhySecFLockType(tmpPhySecId, PHY_SEC_FLOCK_TYPE_CMD);/*之前命令封锁且SPKS封锁，取消SPKS封锁后，只剩命令封锁*/
					}
					else
					{
						/*已经取消了SPKS封锁,或者有多个SPKS封锁此区段*/
					}
				}
				else
				{
					/*不做处理*/
				}
			}
			else
	        {
		        /*无操作*/
			}
		}
		
	}
}

/*
* 功能描述： 获取其他联锁条件设备状态,将状态转换为对应检查的条件
* 参数说明： UINT16 devType 设备类型
*            UINT16 devId 设备ID
*			 UINT16 const chkDevStatus 设备状态
* 返回值  ： 0   失败
*			 >0  设备状态 
*/
UINT8 GetOtherCiDevStatus(UINT16 const devType,UINT16 const devId,UINT16 const chkDevStatus)
{	
	UINT8 devState = 0u;
	UINT8 tmpDevState = 0u;
	UINT8 tmpPsdVobcCmd = 0u;
	UINT8 tmpColor = 0u;
	UINT8 ttmpDevState = 0u;
	UINT8 psdMutualLockState = 0u;
	UINT16 tempdevId = 0u;                   /*临时设备ID*/
	UINT8 tempdevState = 0u;                 /*临时设备状态*/

	switch(devType)
	{
	case CI_DEVICE_TYPE_SWITCH:           /*道岔*/
		tmpDevState = GetSwitchCurPosition(devId);
		if(SWITCH_POSITION_DINGWEI == tmpDevState)
		{
			devState = OTHER_CI_SWTICH_STATUS_DINGWEI;
		} 
		else if (SWITCH_POSITION_FANWEI == tmpDevState)
		{
			devState = OTHER_CI_SWTICH_STATUS_FANWEI;
		}
		else
		{
			devState = 0u;
		}
		break;
	case CI_DEVICE_TYPE_SIGNAL:          /*信号机*/
		tmpColor = GetSignalCurColor(devId);
		if (tmpColor > 0u)
		{
			tmpDevState = GetSignalOpenCloseState(tmpColor);
			if (SIGNAL_OPEN == tmpDevState)
			{
				devState = OTHER_CI_SIGNAL_STATUS_OPEN;
			}
			else
			{
				devState = OTHER_CI_SIGNAL_STATUS_CLOSE;
			}
		}
		else
		{
			devState = 0u;
		}
		break;
	case CI_DEVICE_TYPE_ROUTE:          /*进路*/
		tmpDevState = GetDiaoCheRouteOpenState(devId);
		if (CI_SUCCESS == tmpDevState)
		{
			devState = OTHER_CI_ROUTE_STATUS_OPEN_YES;
		}
		else
		{
			devState = OTHER_CI_ROUTE_STATUS_OPEN_NO;
		}
		break;
	case CI_DEVICE_TYPE_ESB:              /*站台紧急关闭按钮*/
		tmpDevState = GetEsbState(devId);
		ttmpDevState = GetEsbCutState(devId);
		if (ESB_STATE_VALID_NO == tmpDevState)
		{
			devState = OTHER_CI_ESB_STATUS_UNVALID;
		}
		else if (ESB_STATE_VALID_YES == tmpDevState)
		{
			if (ESB_CUT_YES == ttmpDevState)
			{
				devState = OTHER_CI_ESB_STATUS_UNVALID;
			}
			else
			{
				devState = OTHER_CI_ESB_STATUS_VALID;
			}
		}
		else
		{
			devState = 0u;
		}
		break;
	case CI_DEVICE_TYPE_PSD:              /*站台屏蔽门*/
		tmpDevState = GetPsdState(devId);
		tmpPsdVobcCmd = GetPsdVobcCmd(devId);
		psdMutualLockState = GetPsdMutualLockRemoveState(devId);
		if ((PSD_MUTUALLOCK_REMOVE_YES == psdMutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == psdMutualLockState)
			|| (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == psdMutualLockState))
		{
			/* 采集到互锁解除，则直接认为屏蔽门关闭 */
			devState = OTHER_CI_PSD_STATUS_CLOSE;
		}
		else if (PSD_STATE_OPEN == tmpDevState)
		{
			if (tmpPsdVobcCmd == VOBCTOCI_COMMAND_TYPE_PSDOPEN)
			{
				/* 收到VOBCToCI打开屏蔽门命令，则直接认为屏蔽门占用打开 */
				devState = OTHER_CI_PSD_STATUS_OCCUPY_OPEN;
			}
			else
			{
				/* 未收到VOBCToCI打开屏蔽门命令，则直接认为屏蔽门打开 */
				devState = OTHER_CI_PSD_STATUS_OPEN;
			}
		}
		else if (PSD_STATE_CLOSE == tmpDevState)
		{ 
			/* 未采集到互锁解除，则直接认为屏蔽门关闭 */
			devState = OTHER_CI_PSD_STATUS_CLOSE;
		}
		else
		{
			devState = 0u;
		}
		break;
	case CI_DEVICE_TYPE_PSD_EXCEPT_OPEN:  /*站台屏蔽门（异常打开）*/
		devState = GePsdExceptOpenState(devId);
		break;
	case CI_DEVICE_TYPE_GARAGEDOOR:       /*车库门*/
		tmpDevState = GetGaragedoorState(devId);
		if (GARAGE_DOOR_STATE_OPEN == tmpDevState)
		{
			devState = OTHER_CI_GARAGEDOOR_OPEN;
		}
		else if (GARAGE_DOOR_STATE_CLOSE == tmpDevState)
		{
			devState = OTHER_CI_GARAGEDOOR_CLOSE;
		}
		else
		{
			devState = 0u;
		}
		break;
	case CI_DEVICE_TYPE_WASHMACHINE:	/* 洗车机 */
		tmpDevState = GetTrainEmergencyStopState(devId);
		if (WASHMACHINE_COL_FALUT_NO_2 == tmpDevState)
		{
			devState = OTHER_CI_WASH_READ_NO;
		}
		else
		{
			devState = OTHER_CI_WASH_READ_YES;
		}
		break;
	case CI_DEVICE_TYPE_SPKS:	/* SPKS */
		tmpDevState = GetSpksState(devId);
		ttmpDevState = GetSpksCutState(devId);
		if (SPKS_STATUS_NO == tmpDevState)
		{
			devState = OTHER_CI_SPKS_NO;
		}
		else
		{
			if (ttmpDevState == SPKS_CUT_NO)
			{
				devState = OTHER_CI_SPKS_YES;
			}
			else
			{
				devState = OTHER_CI_SPKS_NO;
			}
		}
		break;
	case CI_DEVICE_TYPE_AXISSEC:           /*计轴区段*/
		tmpDevState = CheckLogContactOccState(devId, &tempdevId, &tempdevState);
		if (CI_SUCCESS == tmpDevState)
		{
			devState = OTHER_CI_PHYSICAL_OCCU_NO;
		}
		else
		{
			devState = OTHER_CI_PHYSICAL_OCCU_YES;
		}
		break;
	case CI_DEVICE_TYPE_WASH_LINE:	/* 洗车线 */
		tmpDevState = GetDownWashAllowState(devId);/*获取洗车机降级模式洗车同意状态*/
		if (WASH_COL_STATE_ALLOW_YES == tmpDevState)
		{
			devState = OTHER_CI_WASH_LINE_ALLOW_YES;
		}
		else
		{
			devState = OTHER_CI_WASH_LINE_ALLOW_NO;
		}
		break;
	case CI_DEVICE_TYPE_FLOODGATE:/*防淹门*/
		devState = GetFloodGateCurLogicCloseState(devId);
		break;
		/*联络线道岔*/
	case CI_DEVICE_TYPE_CONNECT_SWITCH:
		tmpDevState = CheckLogContactSwitchState(devId, (UINT8)chkDevStatus, &tempdevId, &tempdevState);
		if (CI_SUCCESS == tmpDevState)
		{
			devState = (UINT8)chkDevStatus;
		}
		else
		{
			devState = OTHER_CI_CONNECT_SWITCH_NO;
		}
		break;
	case CI_DEVICE_TYPE_PHYSEC:/* 物理区段封锁状态检查 其他联锁条件增加物理区段封锁检查 20220530-lyj  */
		tmpDevState = GetPhySecFLockType(devId);
		if (PHY_SEC_FLOCK_TYPE_NONE == tmpDevState)
		{
			devState = OTHER_CI_PHYSICAL_FENGSUO_NO;
		}
		else
		{
			devState = OTHER_CI_PHYSICAL_FENGSUO_YES;
		}

		break;
	case CI_DEVICE_TYPE_WASH_ALLOW_PASS:	/*洗车同意通过*/
		tmpDevState = GetDownWashAllowPassState(devId);
		if (WASH_COL_STATE_ALLOW_PASS_YES == tmpDevState)
		{
			devState = OTHER_CI_DOWNWASH_ALLOW_PASS_YES;
		}
		else
		{
			devState = OTHER_CI_DOWNWASH_ALLOW_PASS_NO;
		}
		break;
	default:
		/*不可达或错误分支 devState=0U */
		break;
	}

	return devState;
}

/*
* 功能描述： 根据设备类型获取其他联锁条件检查失败时错误类型
* 参数说明： UINT16 devType 设备类型
* 返回值  ： 0   设备状态类型
*/
UINT8 GetOtherCiCheckDevStateType(UINT16 const devType)
{
	UINT8 retType = 0u;
	switch(devType)
	{
	case CI_DEVICE_TYPE_SWITCH:           /*道岔*/
		retType = ETYPE_OTHER_SWITCH_POSITION_ERROR;
		break;
	case CI_DEVICE_TYPE_SIGNAL:          /*信号机*/
		retType = ETYPE_OTHER_SIGNAL_CHECK;
		break;
	case CI_DEVICE_TYPE_ROUTE:          /*进路*/
		retType = ETYPE_OTHER_ROUTE_CHECK;
		break;
	case CI_DEVICE_TYPE_ESB:              /*站台紧急关闭按钮*/
		retType = ETYPE_ESB_VALID;
		break;
	case CI_DEVICE_TYPE_PSD:              /*站台屏蔽门*/
	case CI_DEVICE_TYPE_PSD_EXCEPT_OPEN:              /*站台屏蔽门（异常打开）*/
		retType = ETYPE_PSD_CLOSE_NO;
		break;
	case CI_DEVICE_TYPE_GARAGEDOOR:       /*车库门*/
		retType = ETYPE_OTHER_GARAGEDOOR_OPEN_NO;
		break;
	case CI_DEVICE_TYPE_WASHMACHINE:	/* 洗车机 */
		retType = ETYPE_WASH_MACHINE_UNVALID;
		break;
	case CI_DEVICE_TYPE_SPKS:	/* SPKS */
		retType = ETYPE_SPKS_STATE_UP;
		break;
	case CI_DEVICE_TYPE_AXISSEC:   /*计轴区段*/
		retType = ETYPE_PS_MERGY_OCU_STATE;
		break;
	case CI_DEVICE_TYPE_WASH_LINE:   /*洗车线*/
		retType = ETYPE_OTHER_WASH_LINE_NOT_ALLOW;
		break;
	case CI_DEVICE_TYPE_FLOODGATE:/*防淹门*/
		retType = ETYPE_FLOODGATE_CLOSESTATE;
		break;
	case CI_DEVICE_TYPE_PHYSEC:/*物理区段*/
		retType = ETYPE_PS_FLOCK_STATE;
		break;
	case CI_DEVICE_TYPE_WASH_ALLOW_PASS:   /*洗车同意通过*/
		retType = ETYPE_OTHER_DOWNWASH_NOT_ALLOW_PASS;
		break;
	default:
		/*不可达或错误*/
		break;
	}

	return retType;
}


/*
* 功能描述： 获取联锁模式标志
* 参数说明： void
* 返回值  ：联锁模式 0x55: 站控 0xAA:中控 0x71:控制台 0xFF:紧急站控
*/
UINT8 GetCiModeFlag(void)
{
	return ciMode;
}

/*
* 功能描述： 设置联锁模式标志
* 参数说明： 联锁模式 0x55: 强制站控 0xAA:中控 0x71:控制台 0xFF:联锁控 0xBB:申请站控
* 返回值  ：void
*/
void SetCiModeFlag(UINT8 setFlag)
{
	UINT8 localCi = 0U;
	localCi = GetSystemParaLocalCiId();	/*获取本地联锁ID*/
	if ((CI_MODE_ATS == setFlag) || (CI_MODE_CONSOLE == setFlag)
		||(CI_MODE_CI_LOCAL == setFlag) ||(CI_MODE_CONSTRA_LOCAL == setFlag) || ((CI_MODE_APPLAY_LOCAL == setFlag)))
	{
		if ((CI_MODE_ATS == ciMode) && (CI_MODE_ATS != setFlag))
		{
			ReleaseCtrlPower(localCi, CONTRAL_POWER_NO, 0U, 0U);
		} 
		else
		{
			; 
		}
		ciMode = setFlag;
	}
	else
	{
		/*不处理*/
	}

	if (CI_MODE_ATS == setFlag)
	{
		DefaultCtrlPowerDeal(localCi);
	}
	else
	{
		;
	}
}




/*
* 功能描述： 获取全站临时限速标志
* 参数说明： void
* 返回值  ：0x55: 有效 0xAA:无效
*/
UINT8 GetAllTsrFlag(void)
{
	return g_AllTsrFlag;
}

/*
* 功能描述： 设置全站临时限速标志
* 参数说明： 0x55: 有效 0xAA:无效
* 返回值  ：void
*/
void SetAllTsrFlag(UINT8 setFlag)
{
	if ((CI_ALL_TSR_VALID == setFlag) || (CI_ALL_TSR_UNVALID == setFlag))
	{
		g_AllTsrFlag = setFlag;
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述： 获取全线雨雪模式命令
* 参数说明： void
* 返回值  ：0x55: 有效 0xAA:无效
*/
UINT8 GetAllSnowModel(void)
{
	return g_AllSnowModel;
}

/*
* 功能描述： 获取全线雨雪模式命令
* 参数说明： 0x55: 有效 0xAA:无效
* 返回值  ：void
*/
void SetAllSnowModel(UINT8 setmodle)
{
	if ((CI_ALL_SNOW_VALID == setmodle) || (CI_ALL_SNOW_UNVALID == setmodle))
	{
		g_AllSnowModel = setmodle;
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：获取全线湿轨等级
* 参数说明：无
* 返 回 值：0 默认值
*           1 湿轨一级
*           2 湿轨二级
* Created By LQ 2025.05.28
*/
UINT8 GetAllSnowLevel(void)
{
	return g_AllSnowLevel;
}

/*
* 功能描述：设置全线湿轨等级
* 参数说明：UINT8 cLevel 湿轨级别
* 返 回 值：无
* Created By LQ 2025.05.28
*/
void SetAllSnowLevel(UINT8 cLevel)
{
	if ((CI_SNOW_LEVEL_DEFAULT == cLevel) || (CI_SNOW_LEVEL_ONE == cLevel) || (CI_SNOW_LEVEL_TWO == cLevel))
	{
		g_AllSnowLevel = cLevel;
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：获取ITE全线切除状态
* 参数说明：void
* 返 回 值：0x55 切除ITE
*           0xAA 使用ITE
*           0xFF 默认值
* Created By LQ 2024.07.12
*/
UINT8 GetIteLineCutState(void)
{
	return g_IteLineCutState;
}

/*
* 功能描述：设置ITE全线切除状态
* 参数说明：UINT8 cSetState 待设置的ITE全线切除状态
* 返 回 值：无
* Created By LQ 2024.07.12
*/
void SetIteLineCutState(UINT8 cSetState)
{
	if ((CI_ITE_LINE_CUT_VALID == cSetState) || (CI_ITE_LINE_CUT_INVALID == cSetState) || (CI_ITE_LINE_CUT_DEFAULT == cSetState))
	{
		g_IteLineCutState = cSetState;
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述： 获取全线临时限速状态
* 参数说明： void
* 返回值  ：0x55: 有效 0xAA:无效
*/

UINT8 GetAllLineTsrState(void)
{
	return g_AllLineTsrState;
}

/*
* 功能描述： 设置全线临时限速状态
* 参数说明： 0x55: 有效 0xAA:无效
* 返回值  ：void
*/
void SetAllLineTsrState(UINT8 cSetState)
{
	if ((CI_ALL_LINE_TSR_VALID == cSetState) || (CI_ALL_LINE_TSR_UNVALID == cSetState))
	{
		g_AllLineTsrState = cSetState;
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述： 获取全线临时限速速度
* 参数说明： void
* 返回值  ：全线临时限速速值
*/

UINT8 GetAllLineTsrSpeed(void)
{
	return g_AllLineTsrSpeed;
}

/*
* 功能描述： 设置全线临时限速速度
* 参数说明： UINT8 cSpeed 速度值
* 返回值  ： void
*/
void SetAllLineTsrSpeed(UINT8 cSpeed)
{
	g_AllLineTsrSpeed = cSpeed;
}

/*
* 功能描述： 获取试车线联锁状态
* 参数说明： void
* 返回值  ：试车线联锁状态
            CI_TRAIN_TEST_OFF		0xFF	非试车中
            CI_TRAIN_TEST_START		0x01	按下试车请求按钮
            CI_TRAIN_TEST_ON		0x02	试车中
            CI_TRAIN_TEST_STOP		0x03	结束试车

*/
UINT8 GetCiTrainTestStatus(void)
{
	return ciTrainTestStatus;
}

/*
* 功能描述： 设置试车线联锁状态
* 参数说明： 试车线联锁状态
                CI_TRAIN_TEST_OFF		0xFF	非试车中
                CI_TRAIN_TEST_START		0x01	按下试车请求按钮
                CI_TRAIN_TEST_ON		0x02	试车中
                CI_TRAIN_TEST_STOP		0x03	结束试车
* 返回值  ：void
*/
void SetCiTrainTestStatus(UINT8 flag)
{
	if ((CI_TRAIN_TEST_OFF == flag) || (CI_TRAIN_TEST_START == flag)
		|| (CI_TRAIN_TEST_ON == flag) || (CI_TRAIN_TEST_STOP == flag))
	{
		ciTrainTestStatus = flag;
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述： 车辆段联锁获取SQJ状态
* 参数说明： void
* 返回值  ：SQJ状态
*			0x55 设备状态有效
*			0xAA 设备状态无效
*/
UINT8 GetCommTrainTestCLDSQJStatus(void)
{
	return comm_Train_Test_SQJ_CLD_State;
}

/*
* 功能描述： 试车线联锁获取YSKJ状态
* 参数说明： void
* 返回值  ：YSKJ状态
*			0x55 设备状态有效
*			0xAA 设备状态无效
*/
UINT8 GetCommTrainTestSCXYSKJStatus(void)
{
	return comm_Train_Test_YSKJ_SCX_State;
}

/*
* 功能描述： 车辆段联锁获取TYSJ状态
* 参数说明： void
* 返回值  ：TYSJ状态
*			0x55 设备状态有效
*			0xAA 设备状态无效
*/
UINT8 GetCommTrainTestCLDTYSJStatus(void)
{
	return comm_Train_Test_TYSJ_CLD_State;
}

/*
* 功能描述： 试车线联锁获取SQAJ状态
* 参数说明： void
* 返回值  ：SQAJ状态
*			0x55 设备状态有效
*			0xAA 设备状态无效
*/
UINT8 GetCommTrainTestSCXSQAJStatus(void)
{
	return comm_Train_Test_SQAJ_SCX_State;
}

/*
* 功能描述： 设置通信接口的试车线SQAJ状态
* 参数说明： 试车线SQAJ状态
*               COMM_TRAIN_TEST_DEV_STATE_INVALID		0xAA	无效状态
*               COMM_TRAIN_TEST_DEV_STATE_INVALID		0x55	有效状态
* 返回值  ：void
*/
void SetCommTrainTestSCXSQAJStatus(UINT8 flag)
{
	if ((COMM_TRAIN_TEST_DEV_STATE_VALID == flag) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == flag))
	{
		comm_Train_Test_SQAJ_SCX_State = flag;
	}
}

/*
* 功能描述： 设置通信接口的试车线YSKJ状态
* 参数说明： 试车线YSKJ状态
*               COMM_TRAIN_TEST_DEV_STATE_INVALID		0xAA	无效状态
*               COMM_TRAIN_TEST_DEV_STATE_INVALID		0x55	有效状态
* 返回值  ：void
*/
void SetCommTrainTestSCXYSKJStatus(UINT8 flag)
{
	if ((COMM_TRAIN_TEST_DEV_STATE_VALID == flag) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == flag))
	{
		comm_Train_Test_YSKJ_SCX_State = flag;
	}
}

/*
* 功能描述： 设置通信接口的车辆段TYSJ状态
* 参数说明： 车辆段TYSJ状态
*               COMM_TRAIN_TEST_DEV_STATE_INVALID		0xAA	无效状态
*               COMM_TRAIN_TEST_DEV_STATE_INVALID		0x55	有效状态
* 返回值  ：void
*/
void SetCommTrainTestCLDTYSJStatus(UINT8 flag)
{
	if ((COMM_TRAIN_TEST_DEV_STATE_VALID == flag) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == flag))
	{
		comm_Train_Test_TYSJ_CLD_State = flag;
	}
}

/*
* 功能描述： 设置通信接口的车辆段SQJ状态
* 参数说明： 车辆段SQJ状态
*               COMM_TRAIN_TEST_DEV_STATE_INVALID		0xAA	无效状态
*               COMM_TRAIN_TEST_DEV_STATE_INVALID		0x55	有效状态
* 返回值  ：void
*/
void SetCommTrainTestCLDSQJStatus(UINT8 flag)
{
	if ((COMM_TRAIN_TEST_DEV_STATE_VALID == flag) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == flag))
	{
		comm_Train_Test_SQJ_CLD_State = flag;
	}
}

/*
* 功能描述： 设置自动触发标志管理
* 参数说明：UINT8 virCIid  虚拟联锁ID
*           UINT8 setFlag  需设置的自动触发标志
* 返回值  ：无
*cgh-合并ECI11.0:
*/
void SetAutoTriggerLogicManage(UINT8 virCIid, UINT8 setFlag)
{
	UINT16 ii = 0u;
	UINT16 routeCurSum = 0;	     /*进路总数目*/
	UINT16 routeId = 0;	         /*进路ID*/

	routeCurSum = GetRouteCurSum();		        /*获取进路总数*/
	/*处理进路*/
	for (ii = 0u; ii < routeCurSum; ii++)
	{
		routeId = GetRouteId(ii);                           /*获取进路ID*/
		SetSigleRouteAutoTriggerManage(virCIid, routeId, setFlag); /*设置满足自动触发条件的每一条自动触进路的自动触发标志*/
	}
}

/*
* 功能描述： 设置自动触发标志
* 参数说明： UINT8 setFlag  需设置的自动触发标志  
* 返回值  ：无
*/
void SetAutoTriggerFlag(UINT8 setFlag)
{

	if ((AUTO_TRIGGER_SET_YES == setFlag) || (AUTO_TRIGGER_SET_NO == setFlag))
	{
		AutoTriggerFlag = setFlag;   /*设置自动触发标志*/
	} 

}

/*
* 功能描述： 获取自动触发标志
* 参数说明： 无
* 返回值  ：自动触发标志
*/
UINT8 GetAutoTriggerFlag(void)
{
	return AutoTriggerFlag;  /*取消自动触发标志*/
}

/*
* 功能描述： 列车是否已占压触发区段
* 参数说明： const UINT16 routeId  进路ID
* 返回值  ：CI_SUCCESS: 未占压
*			 CI_ERROR: 占压 
*/
UINT8 RouteTriggerOccu(const UINT16 routeId)
{
	/*由于目前基础查询函数不支持CBTC触发区段包含的道岔信息，故此版本CBTC进路也按点式触发进行处理，后期会优化*/
	/*进路触发区段由远及近填写，与接近区段顺序相反*/
	UINT8 secOccupyState = 0u;    /*区段占用状态*/
	UINT16 switchId = 0u;	/*道岔ID*/
	UINT8 switchPos = 0u;	/*道岔位置*/
	UINT8 ii = 0u;  /*遍历下标*/
	UINT8 kk = 0u;
	UINT8 isSwitchPosRight = 1u;	/*道岔位置是否正确 默认1为正确，0为错误*/
	UINT8 isSecOccupied = 1u;    /*区段是否有占用标志 默认1为未占用，0为占用*/
	RouteTriggerPhySectionStruct* pTriggerPhySecStru = NULL;
	UINT8 retVal = CI_ERROR;
	UINT8 SwitchCurPosition = SWITCH_POSITION_INVALID;
	UINT8 PhySecType = 0u;		/*指定ID物理区段类型*/
	UINT16 SwitchPhySectionId = 0u;		/*指定ID道岔相关物理区段ID*/
	UINT8 jj = 0U;

	if ((0u == routeId) || (ROUTE_SUM_MAX <= routeId))
	{
		retVal = CI_ERROR;
	}
	else
	{
		pTriggerPhySecStru = GetRouteBlocTrigLogSecStru(routeId);
		if (NULL != pTriggerPhySecStru)
		{
			/*当区段占用，当前道岔位置正确，则检查后续的区段道岔位置均正确则触发；
			  当前道岔位置不正确，则认为当前区段占用的标志无效，继续检查后续区段是否有占用，均无占用则不触发，
			  有区段占用，则循环检查以上两个条件*/
			for (jj = 0U; jj < ROUTE_BLOC_TRIGGERPHY_NUM; jj++)
			{
				isSecOccupied = 1U;
				for (ii = 0u; ii < pTriggerPhySecStru[jj].TriggerPhySecSum; ii++)
				{
					secOccupyState = GetPhySecCurMergeState(pTriggerPhySecStru[jj].TriggerPhySecIdBuf[ii]);

					if (SECTION_OCCUPY_NO != secOccupyState)
					{/*遍历到区段非空闲，包含占用和接近区段在其他联锁*/

						isSecOccupied = 0u;/*设置该组接近存在区段占用*/
					}
					else
					{
						/*无操作*/
					}
					if (0u == isSecOccupied)
					{  /*当存在占用区段则后面的区段无论占用与否都需检查道岔位置，有一个道岔位置不满足则不触发*/
						/*检查区段涉及的道岔位置是否正确*/
						isSwitchPosRight = 1u;/*重置道岔位置标志为正确*/
						PhySecType = GetPhySecType(pTriggerPhySecStru[jj].TriggerPhySecIdBuf[ii]);
						if (PHYSICAL_SEC_TYPE_NOSWITCH == PhySecType)
						{/*无岔区段*/

							/*不设置标志*/
						}
						else
						{/*有岔区段*/

							/*判断道岔位置是否在相反的位置*/
							for (kk = 0u; kk < pTriggerPhySecStru[jj].SwitchSum; kk++)
							{
								switchId = pTriggerPhySecStru[jj].ConditionSwitchStru[kk].SwitchId;
								switchPos = pTriggerPhySecStru[jj].ConditionSwitchStru[kk].SwitchPosition;
								SwitchPhySectionId = GetSwitchPhySectionId(switchId);
								if (SwitchPhySectionId == pTriggerPhySecStru[jj].TriggerPhySecIdBuf[ii])
								{/*道岔关联区段为该区段*/

									SwitchCurPosition = GetSwitchCurPosition(switchId);
									if (SWITCH_POSITION_DINGWEI == switchPos)
									{/*规定定位*/

										if (SWITCH_POSITION_FANWEI == SwitchCurPosition)
										{/*道岔位置在反位*/

											isSwitchPosRight = 0u;/*设置道岔位置错误，不满足触发条件*/
										}
										else
										{
											/*无操作*/
										}

									}
									else
									{/*规定反位*/

										if (SWITCH_POSITION_DINGWEI == SwitchCurPosition)
										{/*道岔位置在定位*/

											isSwitchPosRight = 0u;/*设置道岔位置错误*/
										}
										else
										{
											/*无操作*/
										}

									}
									if (0u == isSwitchPosRight)
									{
										isSecOccupied = 1u;/*重置占用标志为未占用*/
										break; /*当有一个道岔位置错误，则认为不满足触发条件*/
									}
									else
									{
										/*无操作*/
									}
								}
								else
								{
									/*无操作*/
								}

							}/*遍历道岔数据*/

						}/*有岔区段*/
					}
					else
					{
						/*无操作*/
					}


				}/*该组接近遍历完成*/

				/*判断该组接近是否满足接近条件*/
				if ((0u == isSecOccupied) && (0u != isSwitchPosRight))
				{/*有区段占用 且占用区段之前的道岔位置均正确*/

					retVal = CI_SUCCESS;/*返回接近*/
				}
				else
				{
					/*无操作*/
				}
			}
		}
		else
		{
			retVal = CI_ERROR;
		}

			
			
	}
	return retVal;
}
/*
* 功能描述： 判断是否满足取消属性条件
*            满足取消标志，则反馈报警，不取消则不报警
* 参数说明： UINT16 routeId  进路ID
* 返回值  ：CI_SUCCESS: 未取消
*			 CI_ERROR: 已取消
*/
UINT8 CancleAutoFlag(UINT16 routeId)
{
	UINT8 allAutoReturnSetFlag = ALL_AUTO_RETURN_SET_NO;
	UINT8 autoReturnSetFlag = AUTO_RETURN_SET_NO;
	UINT8 autoRouteSetFlag = AUTO_ROUTE_SET_NO;
	UINT8 autoTriggerSetFlag = AUTO_TRIGGER_SET_NO;
	UINT8 reVal = CI_SUCCESS;

	allAutoReturnSetFlag = GetAllAutoReturnSetFlag(GetRouteAllAutoReturnId(routeId));
	autoReturnSetFlag = GetAutoReturnSetFlag(GetRouteAutoReturnId(routeId));
	autoRouteSetFlag = GetAutoRouteSetFlag(GetRouteAutoRouteId(routeId));
    autoTriggerSetFlag = GetRouteAutoTriggerFlag(routeId);
	if ((ALL_AUTO_RETURN_SET_YES == allAutoReturnSetFlag) ||(AUTO_RETURN_SET_YES == autoReturnSetFlag)
		|| (AUTO_ROUTE_SET_YES == autoRouteSetFlag))
	{/*当进路所属的自动进路有自动标志，则取消该自动标志 ，2018.10.24*/
		SetAutoRouteSetFlag(GetRouteAutoRouteId(routeId),AUTO_ROUTE_SET_NO);
		SetAutoReturnSetFlag(GetRouteAutoReturnId(routeId),AUTO_RETURN_SET_NO);
		SetAllAutoReturnSetFlag(GetRouteAllAutoReturnId(routeId),ALL_AUTO_RETURN_SET_NO);
		
		reVal = CI_ERROR;
	}
	if (AUTO_TRIGGER_SET_YES == autoTriggerSetFlag)
	{  /*当进路属性为自动触发且自动触发标志已设置，则取消自动触发标志*/
		SetRouteAutoTriggerFlag(routeId, AUTO_TRIGGER_SET_NO);
		reVal = CI_ERROR;
	}
	return reVal;
}
/*
* 功能描述： 判断是否满足设置跳跃锁闭条件
*            满足设置跳跃锁闭，否则不设置跳跃锁闭
* 参数说明： UINT16 axisSectionId  计轴区段ID
* 返回值  ：CI_SUCCESS: 满足条件
*			 CI_ERROR: 不满足条件
*/
UINT8 CheckJumpLockApply(UINT16 axisSectionId)
{
	UINT16 routeRlockId = 0u;   /*物理区段正常锁闭所属进路ID*/
	UINT16 routePlockId = 0u;   /*物理区段防护锁闭所属进路ID*/
	UINT8 routeType = 0u;/*进路类型*/
	UINT8 phySecFLockState = 0u;	/*物理区段封锁状态,对应SPKS按下*/
	UINT8 reVal = CI_ERROR;
	AxisSwitchStruct* axisSwitchStru = NULL;
	UINT8 axisSwitchSum = 0u;
	UINT8 ii = 0u;
	UINT8 switchCurPosition = 0u;  /*道岔当前位置*/
	UINT8 routeState = 0u;  /*设置跳跃锁闭的区段所属的进路状态*/
	UINT16 physicalSecId = 0u;
	UINT8 retFlag = 0u;	/*临时变量*/
	UINT16 curSwitchId = 0u;	/*临时变量*/
	UINT8 switchFLockState = 0u;	/*临时变量*/
	UINT16 jj = 0U;
	UINT16 floodGateSum = 0U;		/*防淹门数量*/
	UINT16* floodGateIdBuf = NULL;/*临时变量*/
	UINT8 floodState = 0u;/*防淹门状态*/
	UINT8 routeLevel = 0u;
	UINT8 routeTrainNear = 0u;
	UINT8 physicalCheck = 0u;
	UINT8 phyPLockRouteState = 0u;
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/

	physicalSecId = GetAxisSecRelativePhySecId(axisSectionId);
	routeRlockId = GetPhySecRLockBelongRouteId(physicalSecId);/*物理区段进路锁闭所属进路ID*/
	routePlockId = GetPhySecPLockBelongRouteId(physicalSecId);/*物理区段防护锁闭所属进路ID*/
	routeType = GetRouteType(routeRlockId);/*进路类型*/
	phySecFLockState = GetPhySecFLockState(physicalSecId);/*获取物理区段封锁状态，即SPKS是否实施*/
	axisSwitchSum = GetAxisSwitchSum(axisSectionId);
	axisSwitchStru = GetAxisSwitchIdStru(axisSectionId);
	routeState = GetRouteState(routeRlockId);  /*获取进路状态*/
	physicalCheck = PhysicalIntruSecVainCheck(physicalSecId); /*侵限区段检查*/

	if (NULL == axisSwitchStru)
	{
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
	}
	/*调车进路锁闭，检查不通过*/
	if (CI_SUCCESS == reVal)
	{
		if ((0u < routeRlockId) && ( ROUTE_TYPE_DIAOCHE == routeType)) 
		{
			reVal = CI_ERROR;
		}
	}
	
	if ((0u < routePlockId) && (CI_SUCCESS == reVal))
	{  
		routeLevel = GetRouteLevel(routePlockId);  /*获取防护锁闭所属进路监督级别*/
		phyPLockRouteState = GetRouteState(routePlockId);  /*获取进路状态*/
		/*CBTC*/
		if(ROUTE_LEVEL_CBTC == routeLevel)
		{
			reVal = CI_SUCCESS; /*返回成功*/
		}
		else
		{
			routeTrainNear = RouteHaveTrainNear(routePlockId);
			/*进路有车接近且进路状态为接近开放或预先开放*/
			if ((CI_SUCCESS == routeTrainNear) && 
				((ROUTE_STATE_YUXIAN_OPEN == phyPLockRouteState)||(ROUTE_STATE_NEAR_OPEN == phyPLockRouteState)))
			{     
				/*返回失败*/
				reVal = CI_ERROR;
			}	
		}
	} 
	if ((CI_SUCCESS == reVal) &&(PHYSICAL_SECTION_FLOCK_YES == phySecFLockState))
	{
		/*物理区段处于封锁状态(SPKS实施)*/

		reVal = CI_ERROR;
	}
	if ((CI_SUCCESS == reVal)&&( CI_ERROR == physicalCheck))
	{
		/*侵限区段被占用*/

		reVal = CI_ERROR;
	}
	if ((CI_SUCCESS == reVal)&&(0u < routeRlockId))
	{    
		routeLevel = GetRouteLevel(routeRlockId);  /*获取锁闭所属进路监督级别*/
		/*点式*/
		if(ROUTE_LEVEL_BLOC == routeLevel)
		{
			routeTrainNear = RouteHaveTrainNear(routeRlockId);
			/*进路有车接近且进路状态为接近开放或预先开放*/
			if ((CI_SUCCESS == routeTrainNear) && 
				((ROUTE_STATE_YUXIAN_OPEN == routeState)||(ROUTE_STATE_NEAR_OPEN == routeState)))
			{     

				reVal = CI_ERROR;
			}	
		}
		else
		{
			reVal = CI_SUCCESS;
		}

	}
	if (CI_SUCCESS == reVal)
	{
		/*(道岔位置正确）且（道岔没有在动作）且（道岔未被封锁）*/

		if ((0u !=axisSwitchSum) && (NULL != axisSwitchStru))
		{
			for (ii = 0u;ii< axisSwitchSum;ii++)
			{
				curSwitchId = axisSwitchStru[ii].SwitchId;
				if ((0u != curSwitchId) && (UINT16_MAX != curSwitchId))
				{/*道岔ID有效*/
					switchCurPosition = GetSwitchCurPosition(curSwitchId);	/*获取道岔当前位置*/
					retFlag = checkSwtLastValDrvPosStayorNot(curSwitchId,switchCurPosition);	/*检查道岔上一次驱动是否还在有效期*/
					switchFLockState = GetSwitchFLockState(curSwitchId);	/*获取道岔封锁状态*/
					if ((axisSwitchStru[ii].SwitchPosition != switchCurPosition) || (CI_ERROR == retFlag) || (SWITCH_LOCK_FENGSUO_YES == switchFLockState))
					{/*（判断当前计轴包含的道岔位置与道岔当前的位置有一个不同）或（某个道岔上一次驱动仍然有效）或（道岔封锁）*/
						reVal = CI_ERROR;
						break;
					}
					else
					{
						reVal = CI_SUCCESS;
					}
				}
				
			}
		} 

	}

	if (CI_SUCCESS == reVal)
	{
		if (0u < physicalSecId)
		{
			floodGateSum = GetPhySecLocatedFloodSum(physicalSecId);
			if (0U < floodGateSum)
			{
				floodGateIdBuf = GetPhySecLocatedFloodId(physicalSecId);
				if (NULL != floodGateIdBuf)
				{
					for (jj = 0U; jj < floodGateSum; jj++)
					{
						/*如果物理区段所在有防淹门，则检查防淹门状态*/
						floodState = GetFloodGateCurLogicCloseState(floodGateIdBuf[jj]);
						if (FLOOD_GATE_OPEN != floodState)
						{
							reVal = CI_ERROR;
							break;
						}
						else
						{
							reVal = CI_SUCCESS;
						}
					}
				}
				else
				{
					reVal = CI_ERROR;		/*获取数据失败，反馈失败*/
				}
			}
		}
	}

	/*计轴区段内所有道岔未引导总锁*/
	if (CI_SUCCESS == reVal)
	{
		devId = 0u;
		devState = 0u;
		reVal = AxisSecSwitchYZLockCheck(axisSectionId, &devId, &devState);
	}

	/*计轴区段的防护道岔未引导总锁*/
	if (CI_SUCCESS == reVal)
	{
		devId = 0u;
		devState = 0u;
		reVal = AxisSecProtSwtYLockCheck(axisSectionId, &devId, &devState);
	}

	if (CI_SUCCESS == reVal)
	{/*检查防护道岔位置*/
		devId = 0u;
		devState = 0u;
		reVal = AxisSecAllProtSwitchPosCheck(axisSectionId, &devId, &devState);
	}

	if (CI_SUCCESS == reVal)
	{/*检查防护道岔封锁状态*/
		devId = 0u;
		devState = 0u;
		reVal = AxisSecProtSwitchFLockCheck(axisSectionId, &devId, &devState);
	}

	return reVal;
}


/*
* 功能描述： 检查指定进路内的指定逻辑区段ID前（包含指定逻辑区段ID）的区段无UT占用
* 参数说明： UINT16 routeId, 进路ID
*            UINT16 physicalId,  逻辑区段ID
* 返回值  ： CI_ERROR   有UT占用
*            CI_SUCCESS 无UT占用
*/
UINT8 CheckBeforLogSecinRouteHaveNoUT(UINT16 routeId, UINT16 logSectionId)
{
	UINT8 retVal = CI_ERROR;
	UINT16 logSecNum = 0u;
	UINT16* logSecIdBuf = NULL;
	UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT8 logSecOccState = LOGICSECTION_OCCUPY_UT;
	UINT16 checkLogSecNum = 0u;
	UINT8 checkSulicTrain = CI_ERROR;
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetlogSectionBufIndex(logSectionId);  /*获取区段数组下标*/

	/** 入参合法*/
	if ((routeId >= 1u) && (routeId < ROUTE_SUM_MAX)
		&& (LOGIC_SECTION_SUM_MAX > bufIndex))
	{
		/**获取进路内逻辑区段数量和ID*/
		logSecNum = GetRouteLogSectionSum(routeId);
		logSecIdBuf = GetRouteLogSectionIdBuf(routeId);
		if (NULL != logSecIdBuf)
		{
			for (ii = 0u; ii < logSecNum; ii++)
			{
				if (logSecIdBuf[ii] == logSectionId)
				{
					break;
				}
			}

			if (ii == logSecNum)
			{
				/** 进路中不包含该逻辑区段*/
				retVal = CI_ERROR;
			}
			else
			{
				checkLogSecNum = ii + 1U;
				for (jj = 0u; jj < checkLogSecNum; jj++)
				{
					logSecOccState = GetLogSecOccupyState(logSecIdBuf[jj]);
					checkSulicTrain = IsLogicHaveNoSupicTrain(logSecIdBuf[jj]);
					/** 逻辑区段没有CT占用且没有空闲（即UT占用或获取占用状态失败），或逻辑区段CT占用且有隐藏车*/
					if (((LOGICSECTION_OCCUPY_CT != logSecOccState) && (LOGICSECTION_OCCUPY_NO != logSecOccState))
						|| ((LOGICSECTION_OCCUPY_CT == logSecOccState) && (CI_ERROR == checkSulicTrain)))
					{
						break;
					}
				}

				if (jj == checkLogSecNum)
				{
					/** 进路内第一逻辑区段至本区段均无UT占用 */
					retVal = CI_SUCCESS;
				}
				else
				{
					/** 进路内第一逻辑区段至本区段有UT占用 */
					retVal = CI_ERROR;
				}
			}
		}
		else 
		{
			/** 返回失败*/
			retVal = CI_ERROR;
		}
	}
	else
	{
		/**返回失败*/
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 判断是否满足设置逻辑区段跳跃锁闭条件
*            满足设置逻辑区段跳跃锁闭，否则不设置跳跃锁闭
* 参数说明： UINT16 logSectionId  逻辑区段ID
* 返回值  ：CI_SUCCESS: 满足条件
*			 CI_ERROR: 不满足条件
*/
UINT8 CheckLogJumpLockApply(UINT16 logSectionId)
{
	UINT16 routeRlockId = 0u;   /*逻辑区段正常锁闭所属进路ID*/
	UINT16 routePlockId = 0u;   /*逻辑区段防护锁闭所属进路ID*/
	UINT8 routeType = 0u;/*进路类型*/
	UINT8 phySecFLockState = 0u;	/*物理区段封锁状态,对应SPKS按下*/
	UINT8 reVal = CI_ERROR;
	LogsecSwitchStruct* pLgcSecSwitchStru = NULL;
	UINT8 chLgcSecSwitchSum = 0u;
	UINT8 ii = 0u;
	UINT8 switchCurPosition = 0u;  /*道岔当前位置*/
	UINT8 routeState = 0u;  /*设置跳跃锁闭的区段所属的进路状态*/
	UINT16 physicalSecId = 0u;
	UINT8 retFlag = 0u;	/*临时变量*/
	UINT16 curSwitchId = 0u;	/*临时变量*/
	UINT8 switchFLockState = 0u;	/*临时变量*/
	UINT16 jj = 0U;
	UINT16 floodGateSum = 0U;		/*防淹门数量*/
	UINT16* floodGateIdBuf = NULL;/*临时变量*/
	UINT8 floodState = 0u;/*防淹门状态*/
	UINT8 routeLevel = 0u;
	UINT8 routeTrainNear = 0u;
	UINT8 phyPLockRouteState = 0u;
	UINT8 checkResult = CI_ERROR;
	UINT16 logSecNum = 0u;
	UINT16* plogSecIdPBuf = NULL;
	UINT8 curLogSecOccState = LOGICSECTION_OCCUPY_UT;
	UINT8 checkSulicTrain = CI_ERROR;
	UINT8 logicCheck = CI_ERROR;
	UINT16 devId = 0u;                   /*设备ID*/
	UINT8 devState = 0u;                 /*设备状态*/
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 logSecLockState = 0U;
	UINT8 logSecLockRouteNum = 0U;
	UINT8 chFailStep = 0U;
	UINT8 cYLockAlarmFlag = FLAG_UNSET;  /*引导总锁报警标志*/
	UINT8 cYLockState = 0U;  /*引导总锁状态*/

	bufIndex = GetlogSectionBufIndex(logSectionId);  /*获取区段数组下标*/
	/**区段下标合法*/
	if (LOGIC_SECTION_SUM_MAX > bufIndex)
	{
		physicalSecId = GetLgcSecRelativePhySecId(logSectionId);
		routeRlockId = GetLogSecLockBelongRoute(logSectionId);/*逻辑区段进路锁闭所属进路ID*/
		routePlockId = GetLogSecPLockRouteId(logSectionId);/*逻辑区段防护锁闭所属进路ID*/
		routeType = GetRouteType(routeRlockId);/*进路类型*/
		phySecFLockState = GetPhySecFLockState(physicalSecId);/*获取物理区段封锁状态，即SPKS是否实施*/
		chLgcSecSwitchSum = GetLogicSecSwitchSum(logSectionId);
		pLgcSecSwitchStru = GetLogicSecSwitchIdStru(logSectionId);
		routeState = GetRouteState(routeRlockId);  /*获取进路状态*/
		logicCheck = LogicIntruSecVainCheck(logSectionId, &devId, &devState); /*逻辑区段侵限检查*/
		logSecLockState = GetLogSecLogLockState(logSectionId);
		logSecLockRouteNum = GetLogSecLockBelLogRouteSum(logSectionId);

		if (NULL == pLgcSecSwitchStru)
		{
			reVal = CI_ERROR;
		}
		else
		{
			reVal = CI_SUCCESS;
		}
		if (CI_SUCCESS == reVal)
		{
			if ((0u < routeRlockId) && (ROUTE_TYPE_DIAOCHE == routeType))
			{
				/*调车进路锁闭*/
				reVal = CI_ERROR;
				chFailStep = 1U;
			}
		}
		if (CI_SUCCESS == reVal)
		{
			if ((0u < logSecLockRouteNum) || (LOG_SECTION_LOGLOCK_NO != logSecLockState))
			{
				/*逻辑区段存在逻辑进路锁闭锁闭*/
				reVal = CI_ERROR;
				chFailStep = 2U;
			}
		}

		if ((0u < routePlockId) && (CI_SUCCESS == reVal))
		{
			/** 防护锁闭所属进路内有UT占压，不允许跳跃锁闭 */
			logSecNum = GetRouteLogSectionSum(routePlockId);
			plogSecIdPBuf = GetRouteLogSectionIdBuf(routePlockId);
			if (NULL != plogSecIdPBuf)
			{
				for (ii = 0u; ii < logSecNum; ii++)
				{
					curLogSecOccState = GetLogSecOccupyState(plogSecIdPBuf[ii]);
					checkSulicTrain = IsLogicHaveNoSupicTrain(plogSecIdPBuf[ii]);
					/** 逻辑区段没有CT占用且没有空闲（即UT占用或获取占用状态失败），或逻辑区段CT占用且有隐藏车*/
					if (((LOGICSECTION_OCCUPY_CT != curLogSecOccState) && (LOGICSECTION_OCCUPY_NO != curLogSecOccState))
						|| ((LOGICSECTION_OCCUPY_CT == curLogSecOccState) && (CI_ERROR == checkSulicTrain)))
					{
						reVal = CI_ERROR;
						chFailStep = 3U;
						break;
					}
					else
					{
						/** 继续执行 */
					}
				}
			}
			else
			{
				/** 不做处理 */
			}

			if (CI_SUCCESS == reVal)
			{
				routeLevel = GetRouteLevel(routePlockId);  /*获取防护锁闭所属进路监督级别*/
				phyPLockRouteState = GetRouteState(routePlockId);  /*获取进路状态*/

				/** VBTC进路 */
				if (ROUTE_LEVEL_CBTC == routeLevel)
				{
					reVal = CI_SUCCESS; /*返回成功*/
				}
				/** 点式进路 */
				else
				{
					routeTrainNear = RouteHaveTrainNear(routePlockId);
					/** 进路有车接近且进路状态为接近开放或预先开放 */
					if ((CI_SUCCESS == routeTrainNear) &&
						((ROUTE_STATE_YUXIAN_OPEN == phyPLockRouteState) || (ROUTE_STATE_NEAR_OPEN == phyPLockRouteState)))
					{
						/*返回失败*/
						reVal = CI_ERROR;
						chFailStep = 4U;
					}
					else
					{

					}
				}
			}
			else
			{
				/** 不做处理 */
			}

		}
		if ((CI_SUCCESS == reVal) && (PHYSICAL_SECTION_FLOCK_YES == phySecFLockState))
		{
			/*物理区段处于封锁状态(SPKS实施)*/

			reVal = CI_ERROR;
			chFailStep = 5U;
		}
		if ((CI_SUCCESS == reVal) && (CI_ERROR == logicCheck))
		{
			/*逻辑区段侵限检查不通过*/

			reVal = CI_ERROR;
			chFailStep = 6U;
		}

		if ((CI_SUCCESS == reVal) && (0u < routeRlockId))
		{
			routeLevel = GetRouteLevel(routeRlockId);  /*获取锁闭所属进路监督级别*/
			/*点式*/
			if (ROUTE_LEVEL_BLOC == routeLevel)
			{
				routeTrainNear = RouteHaveTrainNear(routeRlockId);
				/*进路有车接近且进路状态为接近开放或预先开放*/
				if ((CI_SUCCESS == routeTrainNear) &&
					((ROUTE_STATE_YUXIAN_OPEN == routeState) || (ROUTE_STATE_NEAR_OPEN == routeState)))
				{
					reVal = CI_ERROR;
					chFailStep = 7U;
				}
			}
			else
			{
				reVal = CI_SUCCESS;
			}

		}
		if (CI_SUCCESS == reVal)
		{
			/*(道岔位置正确）且（道岔没有在动作）且（道岔未被封锁）*/

			if ((0u != chLgcSecSwitchSum) && (NULL != pLgcSecSwitchStru))
			{
				for (ii = 0u; ii < chLgcSecSwitchSum; ii++)
				{
					curSwitchId = pLgcSecSwitchStru[ii].SwitchId;
					if ((0u != curSwitchId) && (UINT16_MAX != curSwitchId))
					{/*道岔ID有效*/
						switchCurPosition = GetSwitchCurPosition(curSwitchId);	/*获取道岔当前位置*/
						retFlag = checkSwtLastValDrvPosStayorNot(curSwitchId, switchCurPosition);	/*检查道岔上一次驱动是否还在有效期*/
						switchFLockState = GetSwitchFLockState(curSwitchId);	/*获取道岔封锁状态*/
						cYLockState = GetSwitchYLockState(curSwitchId);
						
						if ((pLgcSecSwitchStru[ii].SwitchPosition != switchCurPosition) || (CI_ERROR == retFlag) || (SWITCH_LOCK_FENGSUO_YES == switchFLockState)
							|| (SWITCH_LOCK_YINZONG_NO != cYLockState))
						{/*（判断当前计轴包含的道岔位置与道岔当前的位置有一个不同）或（某个道岔上一次驱动仍然有效）或（道岔封锁）或（道岔引导总锁）*/
							reVal = CI_ERROR;
							chFailStep = 8U;
							break;
						}
						else
						{
							reVal = CI_SUCCESS;
						}
					}

				}
			}

		}

		if (CI_SUCCESS == reVal)
		{
			if (0u < physicalSecId)
			{
				floodGateSum = GetPhySecLocatedFloodSum(physicalSecId);		/*数量为0说明没有防淹门，无需检查，依旧返回成功*/
				if (0U < floodGateSum)
				{
					floodGateIdBuf = GetPhySecLocatedFloodId(physicalSecId);
					if (NULL != floodGateIdBuf)
					{
						for (jj = 0U; jj < floodGateSum; jj++)
						{
							/*如果物理区段所在有防淹门，则检查防淹门状态*/
							floodState = GetFloodGateCurLogicCloseState(floodGateIdBuf[jj]);
							if (FLOOD_GATE_OPEN != floodState)
							{
								reVal = CI_ERROR;
								chFailStep = 9U;
								break;
							}
							else
							{
								reVal = CI_SUCCESS;
							}
						}
					}
					else
					{
						reVal = CI_ERROR;		/*获取数据失败，反馈失败*/
					}
				}
			}
		}

		if (CI_SUCCESS == reVal)
		{
			/** 逻辑区段没有CT占用且没有空闲（即UT占用或获取占用状态失败），或逻辑区段CT占用且有隐藏车*/
			curLogSecOccState = GetLogSecOccupyState(logSectionId);
			checkSulicTrain = IsLogicHaveNoSupicTrain(logSectionId);
			if (((LOGICSECTION_OCCUPY_CT != curLogSecOccState) && (LOGICSECTION_OCCUPY_NO != curLogSecOccState))
				|| ((LOGICSECTION_OCCUPY_CT == curLogSecOccState) && (CI_ERROR == checkSulicTrain)))
			{
				reVal = CI_ERROR;
				chFailStep = 10U;
			}
			else
			{
				/** 继续执行 */
				reVal = CI_SUCCESS;
			}
		}

		if (CI_SUCCESS == reVal)
		{
			/** 区段被进路锁闭*/
			if (0u < routeRlockId)
			{
				/** 检查指定进路内的指定逻辑区段ID前（包含指定逻辑区段ID）的区段无UT占用*/
				checkResult = CheckBeforLogSecinRouteHaveNoUT(routeRlockId, logSectionId);
				/** 有UT占用*/
				if (CI_ERROR == checkResult)
				{
					reVal = CI_ERROR;
					chFailStep = 11U;
				}
				else
				{
					reVal = CI_SUCCESS;
				}
			}
			else
			{
				/** 不做处理*/
			}
		}

		if (CI_SUCCESS == reVal)
		{
			/* 区段无休眠车检查*/
			checkResult = LogSecRelateNoSleepTrainCheck(logSectionId);
			if (CI_ERROR == checkResult)
			{
				reVal = CI_ERROR;
				chFailStep = 12U;
			}
			else
			{
				reVal = CI_SUCCESS;
			}
		}

		if (CI_SUCCESS == reVal)
		{/*防护道岔封锁状态检查*/
			devId = 0u;                   /*设备ID*/
			devState = 0u;                 /*设备状态*/
			reVal = LogicSecRltvPrtctSwFLockCheck(logSectionId, &devId, &devState, &cYLockAlarmFlag);/*封锁检查*/
			if (CI_SUCCESS != reVal)
			{
				chFailStep = 13U;
			}
		}

		if (CI_SUCCESS == reVal)
		{/*防护道岔位置检查*/
			devId = 0u;                   /*设备ID*/
			devState = 0u;                 /*设备状态*/
			reVal = LogicSecRltvPrtctSwPosCheck(logSectionId, &devId, &devState);/*位置检查*/
			if (CI_SUCCESS != reVal)
			{
				chFailStep = 14U;
			}
		}

	}
	else
	{
		reVal = CI_ERROR;
	}
	if (CI_ERROR == reVal)
	{
		debug_infor_printf((const)"\nCheckLogJumpLockApply ! LogSecID: %d__Error Position Is [%d]\n", logSectionId, chFailStep);
	}
	return reVal;
}

/*
* 功能描述： 物理区段侵限无效检查
* 参数说明： 
*            UINT16 const physicalId,    物理区段ID
* 返回值  ： CI_ERROR   侵限
*            CI_SUCCESS 侵限不满足
*/
UINT8 PhysicalIntruSecVainCheck(UINT16 const physicalId)
{
	/* 侵限区段 */
	UINT8 const checkSum = GetSecIntrudePhySectionSum(physicalId);
	UINT16* const dataIdBuf = GetSecIntrudePhySectionData(physicalId);

	/* 局部变量定义初始化 */
	UINT16 i = 0U;           /* 循环变量 */
	UINT16  j = 0U;           /* 循环变量 */
	UINT16 intruSwitchSum = 0U;
	UINT16 intruSwitchId = 0U;
	UINT16 intruSwitchPos = 0U;
	UINT16 devId = 0U;
	UINT8 devState = 0U;
	UINT8 devFengSuoState = 0U;
	UINT8 intruSwitchPosValid = CI_ERROR;
	UINT8 reVal = CI_ERROR;
	UINT8 flag = 0U;
	UINT8 devLockState = 0U;
	UINT8 devJumpLockState = 0U;
	UINT8 curSwitchPos = SWITCH_POSITION_SIKAI;
	UINT8 checkFlockFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_CHECKFLOCK_FLAG);
	UINT8 chPhySecLogLockState = 0U;/*物理区段逻辑锁闭状态*/

	/* 检查侵限状态 */
	if (NULL == dataIdBuf)
	{
		/*无检查项*/
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
		/*开始检查*/
		for (i = 0u; i < checkSum; i++)
		{
			devId = GetInvaSectId(dataIdBuf[i]);
			devState = GetPhySecCurMergeState(devId);
			devFengSuoState = GetPhySecFLockState(devId);
			devLockState = GetPhySecLockState(devId);
			devJumpLockState = GetPhySecJumpLockState(devId);
			chPhySecLogLockState = PhySecLogLockStateCheck(devId);

			/* 检查侵限区段是否占用或封锁或（非未锁闭）或跳跃锁闭*/
			if ((SECTION_OCCUPY_YES == devState)
				|| ((PHYSICAL_SECTION_FLOCK_YES == devFengSuoState) && (FUNC_SWITCH_ON != checkFlockFlag))
				|| (PHYSICAL_SECTION_LOCK_NO != devLockState)
				|| (PHYSICAL_SECTION_JUMP_LOCK_YES == devJumpLockState)
				|| (LOG_SECTION_LOGLOCK_NO != chPhySecLogLockState))
			{
				/*侵限区段占用或封锁*/
				intruSwitchSum = GetInvaSectsCondSwitSum(dataIdBuf[i]);
				if (intruSwitchSum > 0u)
				{
					/*侵限道岔位置检查*/
					intruSwitchPosValid = CI_ERROR;
					for (j = 0u; j < intruSwitchSum; j++)
					{
						intruSwitchId = GetInvaSectsCondSwitId(dataIdBuf[i], (INT16)j);
						intruSwitchPos = GetInvaSectsCondSwitStat(dataIdBuf[i], (INT16)j);
						curSwitchPos = GetSwitchCurPosition(intruSwitchId);

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

					if (intruSwitchPosValid == CI_ERROR)
					{
						/*有岔侵限条件成立*/
						reVal = CI_ERROR;
					}
				}
				else
				{
					/*无岔侵限条件条件成立*/
					reVal = CI_ERROR;
				}
				if (CI_ERROR == reVal)
				{
					flag = 1U;
				}
			}
			/* 检查侵限区段未占用且(未封锁或不检查封锁)且未锁闭且未跳跃锁闭*/
			else if ((SECTION_OCCUPY_NO == devState)
				&& ((PHYSICAL_SECTION_FLOCK_NO == devFengSuoState) || (FUNC_SWITCH_ON == checkFlockFlag))
				&& (PHYSICAL_SECTION_LOCK_NO == devLockState)
				&& (PHYSICAL_SECTION_JUMP_LOCK_NO == devJumpLockState)
				&& (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState))
			{
				/* 未检测到侵限条件 */
			}
			else
			{
				/*侵限区段占用状态异常导向安全*/
				flag = 1U;
				reVal = CI_ERROR;
			}

			if (1U == flag)
			{
				break;
			}
		}
	}

	/* 未检测到侵限条件 */
	return reVal;
}

/* 功能描述： 判断保护区段ID是否属于进路的保护区段
* 参数说明： const UINT16 routeId, 进路ID
*            const UINT16 expLkOverlapId, 期望保护区段ID
* 返回值  ： 0: 指定保护区段不属于进路的保护区段
*            1: 指定保护区段属于进路的保护区段
*/
UINT8 checkExpOverlapBelongToRtOrNot(const UINT16 routeId, const UINT16 expLkOverlapId)
{
	UINT8 ii = 0u;
	UINT8 checkResult = 0u;
	UINT8 overlapSum = 0u;
	UINT16* overlapIdBuf = NULL;

	overlapSum = GetRouteOverlapSum(routeId);  /*获取Overlap总数*/
	overlapIdBuf = GetRouteOverlapIdBuf(routeId);  /*获取Overlap ID BUF*/


	if ((0u == overlapSum)||(0u == expLkOverlapId))
	{
		/*没有保护区段或期望锁闭保护区段ID无效*/
	}
	else
	{
		for (ii = 0u; ii < overlapSum; ii++)
		{/*遍历进路包含的保护区段*/
			if (expLkOverlapId == overlapIdBuf[ii])
			{/*查找到*/
				checkResult = 1u;
				break;
			}
			else
	        {
		       /*无操作*/
	        }
			if (ii == (overlapSum-1u))
			{/*遍历完毕，未查找到*/
				checkResult = 0u;
			}
			else
	        {
		       /*无操作*/
	        }
		}
	}

	return checkResult;
}

/*
* 功能描述： JKJ应急盘状态有效标志
* 参数说明： void
* 返回值  ：JKJ_REYLAY_INVALID              0x55      JKJ应急盘无效
*           JKJ_REYLAY_VALID                0xaa      JKJ应急盘有效
*/
UINT8 GetCiJkjFlag(void)
{
	return JkjRelayValid;
}

/*
* 功能描述： 设置JKJ应急盘状态有效标志
* 参数说明： JKJ_REYLAY_INVALID              0x55      JKJ应急盘无效
*            JKJ_REYLAY_VALID                0xaa      JKJ应急盘有效
* 返回值  ：void
*/
void SetCiJkjFlag(UINT8 setFlag)
{
	if ((JKJ_REYLAY_INVALID == setFlag) || (JKJ_REYLAY_VALID == setFlag))
	{
		JkjRelayValid = setFlag;
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述： 获取JKJ有效状态有效周期号
* 参数说明： 
* 返回值  ： JkjRelayValidCycNum     
*/
UINT32 GetJkjRelayValidCycNum(void)
{
	return JkjRelayValidCycNum;
}


/*
* 功能描述： 设置JKJ应急盘状态有效周期号
* 参数说明： const UINT32 updateCycNum, 应急盘有效更新周期号
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
void SetJkjRelayValidCycNum(const UINT32 updateCycNum)
{
	JkjRelayValidCycNum = updateCycNum;  /*指定ID应急盘有效状态更新周期号*/
}

/*
* 功能描述： 获取ZFW有效状态有效周期号
* 参数说明： 
* 返回值  ： ZFWValidCycNum    
*/
UINT32 GetZFWValidCycNum(void)
{
	return ZFWValidCycNum;
}


/*
* 功能描述： 设置ZFW总复位状态有效周期号
* 参数说明： const UINT32 updateCycNum, 总复位有效更新周期号
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
void SetZFWValidCycNum(const UINT32 updateCycNum)
{
	ZFWValidCycNum = updateCycNum;  /*指定ID总复位有效状态更新周期号*/
}

/*
* 功能描述： 获取ZFW收到命令周期号
* 参数说明： 
* 返回值  ： ZFWCmdStartCycNum    
*/
UINT32 GetZFWcmdStartCycNum(void)	
{
	return ZFWCmdStartCycNum;
}


/*
* 功能描述： 设置ZFW总复位命令开始周期号
* 参数说明： const UINT32 updateCycNum, 总复位命令更新周期号
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
void SetZFWcmdStartCycNum(const UINT32 updateCycNum)
{
	ZFWCmdStartCycNum = updateCycNum;  /*指定ID总复位命令开始更新周期号*/
}


/*
功能描述: 	计轴区段跳跃锁闭驱动道岔处理
输入参数:	const UINT16 axisSecId 计轴区段ID
输出参数:	无
返回值:		CI_SUCCESS,如果道岔锁闭处理成功
				CI_ERROR,如果道岔锁闭处理失败
*/
UINT8 JumpLockDriveSwitch(const UINT16 axisSecId)
{
	UINT8 ii = 0u;
	UINT8 switchSum = 0u;
	UINT16 switchId = 0u;
	UINT8 switchExpPosition = SWITCH_POSITION_INVALID;			/*道岔期望位置*/
	UINT8 switchDancaoPosition = SWITCH_POSITION_INVALID; 		/*单操有效位置*/
	AxisSwitchStruct* pRouteSwitchStru = NULL;					/*道岔数据结构指针*/
	UINT8 innerSwitchRetVal = CI_ERROR;							/*检查计轴区段内道岔是否可被驱动的结果*/


	AxisSwitchStruct* pProtectSwitchStru = NULL;					/*防护道岔数据结构指针*/
	UINT8 protectSwitchSum = 0u;

	switchSum = GetAxisSwitchSum(axisSecId);
	pRouteSwitchStru = GetAxisSwitchIdStru(axisSecId);

	protectSwitchSum = GetAxisSecRelateProSwSum(axisSecId);
	pProtectSwitchStru = GetAxisSecRelateProSwStru(axisSecId);

	if ((0u == axisSecId) || (axisSecId >= AXIS_SECTION_SUM_MAX) || (NULL == pRouteSwitchStru) || (NULL == pProtectSwitchStru))
	{
		innerSwitchRetVal = CI_ERROR;
	}
	else
	{
		innerSwitchRetVal = CI_SUCCESS;

		/* 单操相反位置取消驱动检查 */
		for (ii = 0u; ii < switchSum; ii++)
		{
			switchId = pRouteSwitchStru[ii].SwitchId;
			switchExpPosition = pRouteSwitchStru[ii].SwitchPosition;
			switchDancaoPosition = GetSwitchDanCaoPostition(switchId);

			if ((SWITCH_POSITION_INVALID == switchDancaoPosition)
				||
				(switchDancaoPosition == switchExpPosition))
			{/*单操无效 或者 单操位置与动作位置一样*/
				innerSwitchRetVal = CI_SUCCESS;
			}
			else
			{
				/*单操到相反位置取消道岔的驱动*/
				innerSwitchRetVal = CI_ERROR;
				break;
			}
		}

		if (innerSwitchRetVal == CI_SUCCESS)
		{
			/* 单操相反位置取消驱动检查 */
			for (ii = 0u; ii < protectSwitchSum; ii++)
			{
				switchId = pProtectSwitchStru[ii].SwitchId;
				switchExpPosition = pProtectSwitchStru[ii].SwitchPosition;
				switchDancaoPosition = GetSwitchDanCaoPostition(switchId);

				if ((SWITCH_POSITION_INVALID == switchDancaoPosition)
					||
					(switchDancaoPosition == switchExpPosition))
				{/*单操无效 或者 单操位置与动作位置一样*/
					innerSwitchRetVal = CI_SUCCESS;
				}
				else
				{
					/*单操到相反位置取消道岔的驱动*/
					innerSwitchRetVal = CI_ERROR;
					break;
				}
			}
		}



		if (innerSwitchRetVal == CI_SUCCESS)
		{
			/*驱动计轴区段道岔*/
			AxisSecDrvInnerSwitch(axisSecId, SWITCH_NEED_DRIV_TRUE);
		}
		else
		{
			AxisSecDrvInnerSwitch(axisSecId, SWITCH_NEED_DRIV_FALSE);
		}

	}

	return innerSwitchRetVal;

}


/*
功能描述: 	驱动计轴区段内道岔，计轴区段关联防护道岔处理
输入参数:	const UINT16 axisSecId 计轴区段ID
输出参数:	const UINT8 DrivFlag 道岔驱动标志
返回值:		无
*/
void AxisSecDrvInnerSwitch(const UINT16 axisSecId, const UINT8 DrivFlag)
{
	UINT8 switchSum = 0u; 									/*道岔数目*/
	UINT16 switchId = 0u; 									/*道岔ID*/
	UINT8 switchExpPos = 0u; 								/*道岔期望位置*/
	AxisSwitchStruct* pAxisSecSwitchStru = NULL; 				/*道岔数据*/
	UINT8 ii = 0u;											/*循环变量*/

	AxisSwitchStruct* pProtectSwitchStru = NULL;					/*防护道岔数据结构指针*/
	UINT8 protectSwitchSum = 0u;

	switchSum = GetAxisSwitchSum(axisSecId); /*获取计轴区段道岔数目*/
	pAxisSecSwitchStru = GetAxisSwitchIdStru(axisSecId); /*获取计轴区段内道岔数据*/

	protectSwitchSum = GetAxisSecRelateProSwSum(axisSecId);
	pProtectSwitchStru = GetAxisSecRelateProSwStru(axisSecId);

	if ((NULL != pAxisSecSwitchStru) && (NULL != pProtectSwitchStru))
	{
		if (SWITCH_NEED_DRIV_TRUE == DrivFlag)
		{/*需要驱动计轴区段内道岔*/

			for (ii = 0u; ii < switchSum; ii++)
			{
				switchId = pAxisSecSwitchStru[ii].SwitchId;
				switchExpPos = pAxisSecSwitchStru[ii].SwitchPosition;
				(void)SwitchDriveProcess(switchId, switchExpPos); /*设置计轴区段内道岔的驱动状态为驱动中*/
			}

			for (ii = 0u; ii < protectSwitchSum; ii++)
			{
				switchId = pProtectSwitchStru[ii].SwitchId;
				switchExpPos = pProtectSwitchStru[ii].SwitchPosition;
				(void)SwitchDriveProcess(switchId, switchExpPos); /*设置计轴区段防护道岔的驱动状态为驱动中*/
			}

		}
	}
}






/*
* 功能描述： 继电接口下检查非本联锁的进路内，属于本联锁的物理区段是否都已解锁
* 参数说明： UINT16 routeId 进路号
*	返回值：1：是
*         0: 否
*/	
UINT8 CheckNoLocalCiRoutePhySecUnLock(const UINT16 routeId)
{
	UINT8 sectionSum = 0u; /*区段总数*/
	RoutePhysicalSectionStruct *RouteSecStru = NULL; /*区段数据*/
	UINT16 phySecId = 0u; /*物理区段ID*/
	UINT8 ii= 0u;
	UINT8 reVal = CI_ERROR;

	UINT8 routeBelongCi = 0u;
	UINT8 localCi = 0u;
	UINT8 phyBelongCi = 0u;/*物理区段所属联锁*/
	UINT8 phyLockState = 0u;/*物理区段锁闭状态*/

	UINT8 commState = 0u;/*通信状态*/
	/*相邻联锁是否支持继电接口*/
	UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI);
	UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*继电接口确认状态*/
	UINT32 curCycle = 0u;

	sectionSum = GetRoutePhysicalSectionSum(routeId); /*获得进路包含的区段数目*/
	RouteSecStru = GetRouteSectionData(routeId); /*进路区段数据*/

	routeBelongCi = GetRouteBelongCiId(routeId);/*进路所属联锁ID*/
	localCi = GetSystemParaLocalCiId();/*本机联锁ID*/


	if (NULL == RouteSecStru)
	{
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
		commState = GetLocalCiAndOtherCiTransSta(routeBelongCi);/*本联锁与其它联锁通信通信状态*/
		/*进路不属于本联锁，但进路属于本联锁的区段都已解锁*/
		if ((routeBelongCi != localCi) && (TRANSMIT_STATE_BAD == commState) && 
			(CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&&
			(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface))
		{
			for(ii = 0u; ii < sectionSum; ii++)
			{
				phySecId = RouteSecStru[ii].PhysicalSectionId;
				phyBelongCi = GetPhySecBelongCiId(phySecId);

				phyLockState = GetPhySecLockState(phySecId);
				curCycle = Get2oo2CurCycleNum();
				if ( phyBelongCi==localCi)
				{ /*物理区段属于本联锁，且物理区段未锁闭*/
					if (PHYSICAL_SECTION_LOCK_NO == phyLockState)
					{
					}
					else
					{
						debug_infor_printf((const)"CheckNo, phySecId:%d phyLockState:%d   curCycle:%d\n",
							phySecId,phyLockState,curCycle);
						reVal = CI_ERROR;
						break;
					}
				}
			}
		}
		
	}

	return reVal;
}


/*
* 功能描述： 进路是否有物理区段属于其它联锁
* 参数说明： UINT16 routeId 进路号
*			 , UINT8 *pOtherCiId 其它联锁ID
*	返回值：1：执行成功
*         0: 执行失败
*/	
UINT8 RouteHavePhySecBelongOtherCi(const UINT16 routeId, UINT8 *pOtherCiId)
{
	UINT8 sectionSum = 0u; /*区段总数*/
	RoutePhysicalSectionStruct *pRouteSecStru = NULL; /*区段数据*/
	UINT16 phySecId = 0u; /*物理区段ID*/
	UINT8 ii= 0u;
	UINT8 routeBelongCi = 0u;
	UINT8 phyBelongCi = 0u;
	UINT8 reVal = CI_ERROR;

	sectionSum = GetRoutePhysicalSectionSum(routeId); /*获得进路包含的区段数目*/
	pRouteSecStru = GetRouteSectionData(routeId);/*获取进路物理区段数据*/

	routeBelongCi = GetRouteBelongCiId(routeId);

	if ((NULL==pRouteSecStru ) || (NULL == pOtherCiId))
	{
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;

		for(ii = 0u; ii < sectionSum; ii++)
		{
			phySecId = pRouteSecStru[ii].PhysicalSectionId;
			phyBelongCi = GetPhySecBelongCiId(phySecId);
			if (routeBelongCi != phyBelongCi)
			{
				*pOtherCiId = phyBelongCi;
				break;
			}
		}	
	}

	return reVal;
}

/*
* 功能描述： 检查进路属于本联锁的物理区段已解锁
* 参数说明： UINT16 routeId 进路号
*	返回值：1：是
*         0: 否
*/	
UINT8 CheckLocalCiRoutePhySecUnLock(const UINT16 routeId)
{
	UINT8 sectionSum = 0u; /*区段总数*/
	RoutePhysicalSectionStruct *pRouteSecStru = NULL; /*区段数据*/
	UINT16 phySecId = 0u; /*物理区段ID*/
	UINT8 ii= 0u;
	UINT8 localCi = 0u;
	UINT8 reVal = CI_ERROR;

	UINT8 phySecLockState = 0u;/*物理区段锁闭状态*/
	UINT8 phyBelongCi = 0u;/*物理区段所属联锁*/
	UINT8 routeBelongCi = 0u;/*进路所属联锁*/
	UINT16 phyLockBelongRoute = 0u;

	localCi = GetSystemParaLocalCiId();
	sectionSum = GetRoutePhysicalSectionSum(routeId); /*获得进路包含的区段数目*/
	pRouteSecStru = GetRouteSectionData(routeId); /*进路区段数据*/

	if (NULL ==pRouteSecStru)
	{
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
		for(ii = 0u; ii < sectionSum; ii++)
		{
			phySecId = pRouteSecStru[ii].PhysicalSectionId;
			phySecLockState = GetPhySecLockState(phySecId);
			phyLockBelongRoute = GetPhySecRLockBelongRouteId(phySecId);

			phyBelongCi = GetPhySecBelongCiId(phySecId);
			routeBelongCi = GetRouteBelongCiId(routeId);
			if ((routeBelongCi == phyBelongCi) && (phyBelongCi == localCi))
			{/*属于本联锁的才作检查,未锁闭或被锁闭的不是本进路*/
				if (((PHYSICAL_SECTION_LOCK_NO == phySecLockState) ||
					((PHYSICAL_SECTION_LOCK_NO !=phySecLockState ) && (routeId != phyLockBelongRoute))) )
				{ /*未锁闭或非本进路锁闭*/
				}
				else
				{
					reVal = CI_ERROR;
					break;
				}
			}						
		}	
	}

	return reVal;
}


/*
* 功能描述： 设置计轴总复位是否混线状态
* 参数说明： void    
* 返回值  ： 无
*
*/
void SetZfwjHunXianFLag(UINT8 setFlag)
{
	ZFWJRelayHunXianFlag = setFlag;
}

/*
* 功能描述： 获取计轴总复位是否混线状态
* 参数说明： void    
* 返回值  ： 无
*
*/
UINT8 GetZfwjHunXianFLag(void)
{
	return ZFWJRelayHunXianFlag;
}


/*
* 功能描述： 设置转辙机封连报警取消和恢复状态
* 参数说明： UINT8 blockLinkState 封连报警状态
* 返回值  ： 无
*			          
*/
void SetCancelOrRcvrBlockLinkSta(UINT8 blockLinkState)
{
	/*状态有效*/
	if((CANCEL_SWITCH_BLOCK_LINK == blockLinkState) || (RECOVER_SWITCH_BLOCK_LINK == blockLinkState))
	{
		SwitchBlockLinkState = blockLinkState;
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取转辙机封连报警状态
* 参数说明： void
* 返回值  ： SwitchBlockLinkState 转辙机封连报警状态
*			          
*/
UINT8 GetCancelOrRcvrBlockLinkSta(void)
{
	return(SwitchBlockLinkState);
}

/*
* 功能描述： 找到进路内第一个延时锁闭逻辑区段
* 参数说明： UINT16 routeId,    检查数据数组

* 返回值  ： UINT16 区段ID
*            = 0 无效
*            > 0 区段ID
*/
UINT16 GetRouteFirstDelayLockLogId(UINT16 routeId)
{
	/* 局部变量定义初始化 */
	UINT16 i = 0u;           /* 循环变量 */
	UINT16 belongRouteId = 0u;
	UINT8  logLockState = 0u;
	UINT16 reVal = 0u;
	UINT16 routeLogNum = 0u;
	UINT16* routeLogIdBuf = NULL;

	/*获取进路逻辑区段数据*/
	routeLogNum = GetRouteLogSectionSum(routeId);
	routeLogIdBuf = GetRouteLogSectionIdBuf(routeId);
	if(0u < routeLogNum) 
	{
		for(i = 0u; i < routeLogNum; i++)
		{
			belongRouteId = GetLogSecLockBelongRoute(routeLogIdBuf[i]);
			/*锁闭所属进路等于本进路*/
			if(belongRouteId == routeId)
			{
				/*获取锁闭状态*/
				logLockState = GetLogSecLockState(routeLogIdBuf[i]);
				/*延时解锁状态*/
				if(LOG_SECTION_LOCK_DELAY == logLockState)
				{
					/*返回逻辑区段*/
					reVal = routeLogIdBuf[i];
					break;
				}
				else
				{
					/*不做处理*/
				}
			}
			else
	        {
		        /*无操作*/
	        }
		}
	}
	else
	{
		/*无操作*/
	}
	return(reVal);


}


/*
* 功能描述： 检查道岔关联的逻辑区段的占用状态
* 参数说明： UINT16 switchId，道岔Id
*            UINT16* logOccOrLockId 逻辑区段ID
*			 UINT8* pState 逻辑区段状态 
* 返回值  ： CI_SUCCESS: 关联逻辑区段都空闲
*			 CI_ERROR: 关联逻辑区段存在占用      
* modify 20221009 增加输出参数pState
*/
UINT8 GetSwitchLogSecOccState(UINT16 switchId, UINT16* logOccOrLockId, UINT8* pState)
{
	/*初始化变量*/
	UINT16 i = 0u;
	UINT16 logSecSum = 0u;
	UINT8 logOccState = 0u;
	UINT16* logSecBuf = NULL;
	UINT8 retValue = CI_ERROR;

	/*获取道岔关联逻辑区段信息*/
	logSecSum = GetSwitchLogSecSum(switchId);
	logSecBuf = GetSwitchLogSecBuf(switchId);

	/*逻辑区段数据正常*/
	if(0u != logSecSum) 
	{
		/*检查逻辑区段占用状态*/
		for(i = 0u; i < logSecSum; i++)
		{
			logOccState = GetLogSecCurOccupyState(logSecBuf[i]);
			/*找到占用区段*/
			if(SECTION_OCCUPY_NO != logOccState)
			{
				*logOccOrLockId = logSecBuf[i];
				*pState = logOccState;
				retValue = CI_ERROR;
				break;
			}
			else
			{
				retValue = CI_SUCCESS;
			}
		}
	}
	else
	{
		/*无操作*/
	}
	return(retValue);
}

/*
* 功能描述： 检查道岔所属物理区段关联的逻辑区段的占用状态
* 参数说明： UINT16 switchId，道岔Id
*            UINT16* logOccOrLockId 逻辑区段ID
*			 UINT8* pState 逻辑区段状态
* 返回值  ： CI_SUCCESS: 检查通过
*			 CI_ERROR: 检查不通过
* add 20221009 适配进路提前驱动道岔功能
*/
UINT8 GetSwitchSecOccState(UINT16 switchId, UINT16* logOccOrLockId, UINT8* pState)
{
	/*初始化变量*/
	UINT8 i = 0u;
	UINT8 logOccState = 0u;
	UINT8 retValue = CI_ERROR;
	UINT16 logId = 0u;
	UINT16 switch1stSecId = 0u;
	UINT8 checkLogSecSum = 0u;
	UINT16* logSecIdBuf = NULL;
	UINT8 logSecOccState = 0u;
	UINT8 logSecLockState = 0u;


	/*获取道岔关联的逻辑区段占用状态*/
	switch1stSecId = GetSwitchPhySectionId(switchId);
	logOccState = GetSwitchLogSecOccState(switchId, &logId, &logSecOccState);
	if (CI_ERROR == logOccState)
	{
		/*道岔关联的逻辑区段有占用*/
		*logOccOrLockId = logId;
		*pState = logSecOccState;
		retValue = CI_ERROR;
	}
	else
	{   /*道岔关联的逻辑区段空闲,检查道岔所属物理区段的逻辑区段只有CT占用或空闲*/
		checkLogSecSum = GetPhySecIncLogSecSum(switch1stSecId);
		logSecIdBuf = GetPhySecIncLogSecIdBuf(switch1stSecId);
		if (NULL != logSecIdBuf)
		{
			retValue = CI_SUCCESS;
			for (i = 0u; i < checkLogSecSum; i++)
			{
				logSecOccState = GetLogSecCurCtOrUtOccupyState(logSecIdBuf[i]);
				if (LOGICSECTION_OCCUPY_NO == logSecOccState)
				{

				}
				else if (LOGICSECTION_OCCUPY_CT == logSecOccState)
				{
					logSecLockState = GetLogSecLockState(logSecIdBuf[i]);
					if (LOG_SECTION_LOCK_NORMAL != logSecLockState)
					{
						retValue = CI_ERROR;
					}
					else
					{
						/*逻辑区段是CT占用且被正常锁闭*/
					}
				}
				else
				{
					/*有逻辑区段既不是CT占用也不是空闲*/
					retValue = CI_ERROR;
				}

				if (CI_ERROR == retValue)
				{
					*logOccOrLockId = logSecIdBuf[i];
					*pState = logSecOccState;
					break;
				}
				else
				{

				}
			}
		}
		else
		{
			/*数据错误*/
			retValue = CI_ERROR;
		}

	}
	return retValue;
}

/*
* 功能描述： 检查道岔关联的逻辑区段的锁闭状态
* 参数说明： UINT16 switchId，道岔Id
*            UINT16* logOccOrLockId 逻辑区段ID
*			 UINT8* pState 逻辑区段状态
* 返回值  ： CI_SUCCESS: 关联逻辑区段都未锁闭
*			 CI_ERROR: 关联逻辑区段有占用
* modify 20221009 增加输出参数pState
*/
UINT8 GetSwitchLogSecLockState(UINT16 switchId, UINT16* logOccOrLockId, UINT8* pState)
{
	/*初始化变量*/
	UINT16 i = 0u;
	UINT16 logSecSum = 0u;
	UINT8 logLockState = 0u;
	UINT16* logSecBuf = NULL;
	UINT8 retValue = CI_ERROR;
	UINT8 chLogSecLogLockState = 0U;  /*逻辑区段逻辑锁闭状态*/
	UINT8 cLockBelongLogicRouteNum = 0U;  /*逻辑区段逻辑锁闭所属逻辑进路数量*/
	UINT8 chLogSecJumpLockState = 0U;
	/*获取道岔关联逻辑区段信息*/
	logSecSum = GetSwitchLogSecSum(switchId);
	logSecBuf = GetSwitchLogSecBuf(switchId);

	/*逻辑区段数据正常*/
	if (0u != logSecSum)
	{
		/*检查逻辑区段锁闭状态*/
		for (i = 0u; i < logSecSum; i++)
		{
			logLockState = GetLogSecLockState(logSecBuf[i]);
			/*找到锁闭区段*/
			if (LOG_SECTION_LOCK_NO != logLockState)
			{
				*logOccOrLockId = logSecBuf[i];
				*pState = logLockState;
				retValue = CI_ERROR;
			}
			else
			{
				/*检查逻辑区段逻辑锁闭状态*/
				chLogSecLogLockState = GetLogSecLogLockState(logSecBuf[i]);
				cLockBelongLogicRouteNum = GetLogSecLockBelLogRouteSum(logSecBuf[i]);
				chLogSecJumpLockState = GetLogSecJumpLockState(logSecBuf[i]);

				if ((LOG_SECTION_LOGLOCK_NO == chLogSecLogLockState) && (0U == cLockBelongLogicRouteNum) && (LOGIC_SECTION_JUMP_LOCK_NO == chLogSecJumpLockState))
				{
					retValue = CI_SUCCESS;
				}
				else
				{
					*logOccOrLockId = logSecBuf[i];
					*pState = chLogSecLogLockState;
					retValue = CI_ERROR;
				}
			}

			if (CI_ERROR == retValue)
			{
				break; /*有条件检查不通过，跳出*/
			}
		}
	}
	else
	{
		/*无操作*/
	}
	return(retValue);
}

/*
* 功能描述： 找到进路内第一个正常锁闭逻辑区段
* 参数说明： UINT16 routeId,    检查数据数组

* 返回值  ： UINT16 区段ID
*            = 0 无效
*            > 0 逻辑区段ID
*/
UINT16 GetRouteFirstNormalLockLogId(UINT16 RouteId)
{
	/*变量初始化*/
	UINT16 i = 0u;           /* 循环变量 */
	UINT16 belongRouteId = 0u;
	UINT8  logLockState = 0u;
	UINT8 flag = 0u;/*查找成功标志*/
	UINT16 routeLogNum = 0u;
	UINT16 reVal = CI_ERROR; 
	UINT16* routeLogIdBuf = NULL;

	/*获取进路逻辑区段数据*/
	routeLogNum = GetRouteLogSectionSum(RouteId);
	routeLogIdBuf = GetRouteLogSectionIdBuf(RouteId);

	if(0u < routeLogNum) 
	{
		for(i = 0u; i < routeLogNum; i++)
		{
			belongRouteId = GetLogSecLockBelongRoute(routeLogIdBuf[i]);
			/*锁闭所属进路等于本进路*/
			if(belongRouteId == RouteId)
			{
				/*获取锁闭状态*/
				logLockState = GetLogSecLockState(routeLogIdBuf[i]);
				/*正常锁闭*/
				if(LOG_SECTION_LOCK_NORMAL == logLockState)
				{
					/*返回逻辑区段*/
					reVal = routeLogIdBuf[i];
					flag = 1u;
				}
				/*延时锁闭*/
				else if(LOG_SECTION_LOCK_DELAY == logLockState)
				{
					/*不做处理*/
				}
				else
				{
					/*返回错误*/
					reVal = CI_ERROR;
					flag = 1u;
				}
				if(1u == flag)
				{
					break;
				}
				else
				{
					/*无操作*/
				}
			}
			else
			{
			}
			
		}
	}
	else
	{
	}
	return(reVal);

}

/*
* 功能描述： 设置进路逻辑区段资源的列车ID
* 参数说明： const UINT16 routeId, 进路ID
*            const UINT16 wTrainId 列车编号
* 返回值  ： 无
* 创  建  ： qw.liu 2022-03-03
* @note 集成 bug 20220420 编码规范：删除冗余变量，空语句增加注释
*/
void SetRouteLogicSecResTrainId(const UINT16 routeId, const UINT16 wTrainId)
{
	UINT8  chRouteType = 0U;
	UINT8  chLogicSecResTrainSum = 0U;
	UINT16 wLogicSum = 0U;
	UINT16 wLogicSecId = 0U;
	UINT16 ii = 0U;
	UINT16 wRouteLastPhySecId = 0U;
	UINT16 wLogicSecRelativePhySecId = 0U;
	UINT16 wGroupOtherTrainId = 0U;
	LogicTrainResStruct *pstLgcTrnResInfo = NULL;
	UINT8 cLocalCiId = 0u;
	UINT8 cRouteCiId = 0u;
	UINT8 chReturnLogAddFlag = CI_ERROR;
	UINT16 wLogicPLockRouteId = 0U;
	const UINT16 *wszLogicSecId = GetRouteLogSectionIdBuf(routeId);
	UINT8 chLocalCiType = 0U;/*本地联锁类型*/
	UINT8 chHitSoftWallSwitch = 0U;/*撞软墙开关*/
	UINT16 wRLockStartSignalId = 0U;  /*始端信号机ID*/
	UINT16 wRLockLightUpTrainId = 0U; /*点灯区段接近列车*/
	cLocalCiId = GetSystemParaLocalCiId();
	wLogicSum = GetRouteLogSectionSum(routeId);
	chLocalCiType = GetLocalCiType();
	chHitSoftWallSwitch = GetHitSoftWallSwitch();

	if ((CI_TYPE_TCC == chLocalCiType) || (CI_TYPE_CLD == chLocalCiType))
	{
		/* 获取进路类型*/
		chRouteType = GetConfigRouteType(routeId);
	}
	else
	{
		/* 获取进路类型*/
		chRouteType = GetRouteType(routeId);
	}


	/* 获取进路所属联锁ID */
	cRouteCiId = GetRouteBelongCiId(routeId);
	if ((MAX_ROUTE_IN_LT_NUM > wLogicSum)&&(NULL!=wszLogicSecId)&&(0u != cLocalCiId))
	{
		if (cRouteCiId == cLocalCiId)
		{
			if (ROUTE_TYPE_RETURN == chRouteType)
			{
				for (ii = 0U; ii < wLogicSum; ii++)
				{
					wLogicSecId = wszLogicSecId[ii];
					wLogicPLockRouteId = GetLogSecPLockRouteId(wLogicSecId);
					chLogicSecResTrainSum = GetLogSecTrainInfoSum(wLogicSecId);
					if (0U < chLogicSecResTrainSum)
					{
						if (0U == wLogicPLockRouteId)
						{
							break;
						}
						else
						{

						}
					}
				}

				if (ii == wLogicSum)
				{
					chReturnLogAddFlag = CI_SUCCESS;
				}
				else
				{
					/*判断前车与本车为同一编组运行列车--加资源*/
					wGroupOtherTrainId = GetGroupTrainOtherId(wTrainId);
					pstLgcTrnResInfo = GetLogSecTrainInfoById(wLogicSecId, wGroupOtherTrainId);
					if (NULL != pstLgcTrnResInfo)
					{
						chReturnLogAddFlag = CI_SUCCESS;
					}
					else
					{
						chReturnLogAddFlag = CI_ERROR;
					}
				}

				if (CI_SUCCESS == chReturnLogAddFlag)
				{
					/*进路添加资源*/
					wRouteLastPhySecId = GetRouteLastPhySectionId(routeId);
					for (ii = 0U; ii < wLogicSum; ii++)
					{
						wLogicSecId = wszLogicSecId[ii];

						/*添加逻辑区段列车资源信息*/
						AddLogSecTrainRes(wLogicSecId, wTrainId);
						wLogicSecRelativePhySecId = GetLgcSecRelativePhySecId(wLogicSecId);
						if ((wRouteLastPhySecId == wLogicSecRelativePhySecId)
							&& (0U != wLogicSecRelativePhySecId))
						{
							SetLogSecTrainReturnState(wLogicSecId, wTrainId, LOGIC_SECTION_TRAIN_RETURN_YES);
						}
						else
						{
							/*继续执行*/
						}
					}
				}
				else
				{

				}
			}
			else if (ROUTE_TYPE_LIECHE == chRouteType)
			{
				/*判断撞软墙开关，开关打开，资源可分配给多个列车*/
				if (FUNC_HITSOFTWALL_ON == chHitSoftWallSwitch)
				{
					for (ii = 0U; ii < wLogicSum; ii++)
					{
						wLogicSecId = wszLogicSecId[ii];

						/*添加逻辑区段列车资源信息*/
						AddLogSecTrainRes(wLogicSecId, wTrainId);
					}
				}
				/*开关关闭，资源只允许分配给最接近进路的列车*/
				else
				{
					/*查找最接近进路的列车*/
					wRLockStartSignalId = GetRouteStartSignalId(routeId);
					wRLockLightUpTrainId = GetSignalLightUpTrainId(wRLockStartSignalId);

					/*指定列车为进路最接近列车*/
					if ((wTrainId & 0x00ffU) == wRLockLightUpTrainId)
					{
						for (ii = 0U; ii < wLogicSum; ii++)
						{
							wLogicSecId = wszLogicSecId[ii];

							/*添加逻辑区段列车资源信息*/
							AddLogSecTrainRes(wLogicSecId, wTrainId);
						}
					}
					else
					{
						/*非最近列车，不处理*/
					}
				}
			}
			else
			{
				/* 不处理 */
			}
		}
		else
		{
			;/* 非本联锁进路不处理 */
		}
	}
	else
	{
		/* 不处理 */
	}
}

/*
* 功能描述：获取进路有车接近处理时占压逻辑区段ID
* 参数说明： const UINT16 routeId, 进路ID
* 返回值  ： 物理区段编号
*/
UINT16 GetRouteHaveTrainNearLogSecId(const UINT16 routeId)
{
	UINT8 secOccupyState = 0U;    /*区段占用状态*/
	UINT16 switchId = 0U;	/*道岔ID*/
	UINT8 switchPos = 0U;	/*道岔位置*/
	UINT8 ii = 0U;  /*遍历下标*/
	UINT8 jj = 0U;
	UINT8 kk = 0U;
	UINT8 isSwitchPosRight = 1U;	/*道岔位置是否正确 默认1为正确，0为错误*/
	UINT8 isSecOccupied = 1U;    /*区段是否有占用标志 默认1为未占用，0为占用*/
	UINT8 switchCurPosition = 0U;
	UINT8 ckeepWorkFlag = CI_ERROR;
	UINT16 wRetVal = 0U;
	UINT8 nearSecConditionSum = 0U;	/*接近区段条件数量*/
	RouteNearLogicSectionStruct* nearLogicSecStru = NULL;	/*接近逻辑区段结构数组*/
	UINT8 chLogicSecSwitchSum = 0U;/*逻辑区段道岔数目*/
	LogsecSwitchStruct* pLogicSecSwitchIdData = NULL;/*逻辑区段道岔ID数据*/


	if ((0u == routeId) || (ROUTE_SUM_MAX <= routeId))
	{
		ckeepWorkFlag = CI_ERROR;
	}
	else
	{
		ckeepWorkFlag = CI_SUCCESS;
	}


	if (CI_SUCCESS == ckeepWorkFlag)
	{
		nearSecConditionSum = GetRouteCbtcNearSecConditionSum(routeId);	/*获取CBTC进路接近逻辑区段条件数目*/
		nearLogicSecStru = GetRouteCbtcNearLogSectionStru(routeId);	/*获取CBTC进路接近逻辑区段结构体*/

		if ((0U < nearSecConditionSum)
			&& (ROUTE_NEARSEC_CONDITION_SUM_MAX >= nearSecConditionSum)
			&& (NULL != nearLogicSecStru))
		{/*具有多组接近区段*/

			for (ii = 0U; ii < nearSecConditionSum; ii++)
			{/*分组遍历区段*/

				isSecOccupied = 1U;/*重置占用标志为未占用*/
				isSwitchPosRight = 1U;/*重置道岔位置标志为正确*/

				for (jj = 0U; jj < nearLogicSecStru[ii].NearLogicSecSum; jj++)
				{
					secOccupyState = GetLogSecCurOccupyState(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]);/*获取逻辑区段当前占用状态*/

					if (SECTION_OCCUPY_NO != secOccupyState)
					{/*遍历到区段非空闲，包含占用和接近区段在其他联锁*/

						isSecOccupied = 0U;/*设置该组接近存在区段占用*/
					}
					else
					{
						; /*不设置继续查找*/
					}

					chLogicSecSwitchSum = GetLogicSecSwitchSum(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]);
					pLogicSecSwitchIdData = GetLogicSecSwitchIdStru(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]);

					for (kk = 0U; kk < chLogicSecSwitchSum; kk++)
					{
						switchId = pLogicSecSwitchIdData[kk].SwitchId;
						switchPos = pLogicSecSwitchIdData[kk].SwitchPosition;
						switchCurPosition = GetSwitchCurPosition(switchId);

						if (SWITCH_POSITION_DINGWEI == switchPos)
						{
							/*规定定位*/
							if (SWITCH_POSITION_FANWEI == switchCurPosition)
							{/*道岔位置在反位*/

								isSwitchPosRight = 0U;/*设置道岔位置错误*/
							}
							else
							{/*道岔位置不在反位*/

								; /*位置正确 不设置标志*/
							}

						}
						else
						{
							if (SWITCH_POSITION_DINGWEI == switchCurPosition)
							{/*道岔位置在定位*/
								isSwitchPosRight = 0U;/*设置道岔位置错误*/
							}
							else
							{/*道岔位置不在定位*/

								; /*位置正确 不设置标志*/
							}
						}
					}

					if ((0U == isSecOccupied) || (0U == isSwitchPosRight))
					{/*如果满足占用条件或道岔位置错误，就中断该组循环*/
						break;
					}

				}/*该组接近遍历完成*/

				 /*判断该组接近是否满足接近条件*/
				if ((0U == isSecOccupied) && (0U != isSwitchPosRight))
				{/*有区段占用 且占用区段之前的道岔位置均正确*/

					wRetVal = nearLogicSecStru[ii].NearLogicSecIdBuf[jj];
					break;
				}

			}/*所有接近条件遍历*/
		}
		else
		{
			/*条件数目错误*/
			;
		}
	}
	else
	{
		;
	}
	return wRetVal;
}
/*
* 功能描述： 检查进路锁闭且未处于引导锁闭状态
* 参数说明： UINT16 routeId, 进路ID
*
* 返回值  ： CI_ERROR	：ID有误或未锁闭或引导锁闭
*		  ： CI_SUCCESS ：非引导锁闭
*/
UINT8 CheckRouteStateNotYinDaoLock(UINT16 routeId)
{
	UINT8 chRetVal = 0U;
	UINT8 chRouteState = 0U;
	chRouteState = GetRouteState(routeId);
	if (CI_ERROR == chRouteState)
	{
		chRetVal = CI_ERROR;
	}
	else if ((ROUTE_STATE_FIRST_LOCK == chRouteState)
		|| (ROUTE_STATE_FIRST_LOCKERR == chRouteState)
		|| (ROUTE_STATE_YUXIAN_LOCK == chRouteState)
		|| (ROUTE_STATE_YUXIAN_OPEN == chRouteState)
		|| (ROUTE_STATE_NEAR_LOCK == chRouteState)
		|| (ROUTE_STATE_NEAR_LOCKERR == chRouteState)
		|| (ROUTE_STATE_NEAR_OPEN == chRouteState)
		|| (ROUTE_STATE_DELAY_UNLOCK == chRouteState)
		|| (ROUTE_STATE_AUTO_UNLOCK == chRouteState)
		|| (ROUTE_STATE_AUTO_UNLOCKERR == chRouteState)
		|| (ROUTE_STATE_HALF_LOCK == chRouteState)
		|| (ROUTE_STATE_HALF_UNLOCKDELAY == chRouteState)
		|| (ROUTE_STATE_HALF_UNLOCK == chRouteState))
	{
		chRetVal = CI_SUCCESS;
	}
	else
	{

		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述：获取进路准备进入进路列车信息
* 参数说明： const UINT16 routeId, 进路ID pTrainNum预进入数量 wszTrainId 预进入ID
* 返回值  ： CI_ERROR :获取失败
*			 CI_SUCCESS:获取成功
*/
UINT8 GetRouteReadyEnterTrainInfo(const UINT16 wRouteId,UINT8 * pTrainNum,UINT16 wszTrainId[])
{
	
	UINT8 ii = 0u;  /*遍历下标*/
	UINT8 jj = 0u;
	UINT16 wRouteFirstLgcId = 0u;
	UINT16 wRouteLastLgcId = 0u;
	UINT8 chSameIdTrainSum = 0U;
	UINT16 wszSameIdTrainSum[LOGIC_SECTION_RES_SUM_MAX] = {0U};
	UINT16 wRouteFirstLgcTrainId = 0U;
	UINT16 wRouteLastLgcTrainId = 0U;
	UINT8 chRouteFirstLgcTrainSum = 0U;
	UINT8 chRouteLastLgcTrainSum = 0U;
	UINT8 ckeepWorkFlag = CI_ERROR;
	UINT8 wRetVal = CI_ERROR;
	
	if ((NULL == pTrainNum) || (NULL == wszTrainId))
	{
		ckeepWorkFlag = CI_ERROR;
	}
	else
	{
		ckeepWorkFlag = CI_SUCCESS;
	}

	if (CI_SUCCESS == ckeepWorkFlag)
	{
		wRouteFirstLgcId = GetRouteInFirstLogSecId(wRouteId);
		wRouteLastLgcId = GetRouteInLastLogSecId(wRouteId);
		if ((CI_ERROR == wRouteFirstLgcId)
			|| (CI_ERROR == wRouteLastLgcId))
		{
			ckeepWorkFlag = CI_ERROR;
		}
		else
		{
			chRouteFirstLgcTrainSum = GetLogSecTrainInfoSum(wRouteFirstLgcId);
			chRouteLastLgcTrainSum = GetLogSecTrainInfoSum(wRouteLastLgcId);
		}
	}

	if (CI_SUCCESS == ckeepWorkFlag)
	{
		for (ii = 0; ii < chRouteFirstLgcTrainSum; ii++)
		{
			wRouteFirstLgcTrainId = GetLogSecTrainIdByIndex(wRouteFirstLgcId, ii);
			for (jj = 0U; jj < chRouteLastLgcTrainSum; jj++)
			{
				wRouteLastLgcTrainId = GetLogSecTrainIdByIndex(wRouteLastLgcId, jj);
				if ((wRouteFirstLgcTrainId == wRouteLastLgcTrainId)
					&&(0U!=wRouteFirstLgcTrainId))
				{
					wszSameIdTrainSum[chSameIdTrainSum] = wRouteFirstLgcTrainId;
					chSameIdTrainSum += 1U;
					break;
				}
			}
		}
	}
	if (CI_SUCCESS == ckeepWorkFlag)
	{
		*pTrainNum = chSameIdTrainSum;
		for (ii = 0U; ii < chSameIdTrainSum; ii++)
		{
			wszTrainId[ii] = wszSameIdTrainSum[ii];
		}
		wRetVal = CI_SUCCESS;
	}
	else
	{
		wRetVal = CI_ERROR;
	}

	
	return wRetVal;
}

/*
* 功能描述：获取进路内外方第一逻辑区段均具有资源的列车信息
* 参数说明：const UINT16 routeId 进路ID 
*           UINT8* pTrainNum 预进入数量 
*           UINT16 szTrainId[LOGIC_SECTION_RES_SUM_MAX] 预进入ID
* 返 回 值：0 获取失败
*			1 获取成功
* Created By LQ 2024.12.02
*/
UINT8 GetRouteInOutFstLgcTrainInfo(const UINT16 wRouteId, UINT8* pTrainNum, UINT16 szTrainId[LOGIC_SECTION_RES_SUM_MAX])
{
	UINT8 cRetVal = CI_ERROR;
	UINT8 ii = 0U;
	UINT8 jj = 0U;
	UINT16 wRouteInFstLgcId = 0U;  /*进路内方第一逻辑区段ID*/
	UINT16 wRouteOutFstLgcId = 0U;  /*进路外方第一逻辑区段ID*/
	UINT16 wRouteStartSignalId = 0U;  /*进路始端信号机ID*/
	UINT8 cRouteInFstLgcTrainSum = 0U;  /*进路内方第一逻辑区段资源列车信息*/
	UINT16 wRouteInFstLgcTrainId = 0U;  
	UINT8 cRouteOutFstLgcTrainSum = 0U;  /*进路外方第一逻辑区段资源列车信息*/
	UINT16 wRouteOutFstLgcTrainId = 0U;
	UINT8 cSameIdTrainSum = 0U;
	UINT16 szSameIdTrainId[LOGIC_SECTION_RES_SUM_MAX] = { 0U };

	if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId) && (NULL != pTrainNum) && (NULL != szTrainId))
	{
		wRouteInFstLgcId = GetRouteInFirstLogSecId(wRouteId);  /*获取进路内方第一逻辑区段ID*/
		wRouteStartSignalId = GetRouteStartSignalId(wRouteId);  /*获取进路始端信号机ID*/
		wRouteOutFstLgcId = GetSignalOutFirstLogSec(wRouteStartSignalId);  /*获取进路外方第一逻辑区段ID*/

		if ((CI_ERROR != wRouteInFstLgcId) && (CI_ERROR != wRouteOutFstLgcId))
		{
			cRetVal = CI_SUCCESS;
			cRouteInFstLgcTrainSum = GetLogSecTrainInfoSum(wRouteInFstLgcId);  /*获取进路内方第一逻辑区段资源列车数量*/
			cRouteOutFstLgcTrainSum = GetLogSecTrainInfoSum(wRouteOutFstLgcId);  /*获取进路外方第一逻辑区段资源列车数量*/
			if ((0U != cRouteInFstLgcTrainSum) && (0U != cRouteOutFstLgcTrainSum))
			{
				for (ii = 0U; ii < cRouteInFstLgcTrainSum; ii++)
				{
					wRouteInFstLgcTrainId = GetLogSecTrainIdByIndex(wRouteInFstLgcId, ii);  /*获取进路内方第一逻辑区段资源列车ID*/
					if (0U != wRouteInFstLgcTrainId)
					{
						for (jj = 0U; jj < cRouteOutFstLgcTrainSum; jj++)
						{
							wRouteOutFstLgcTrainId = GetLogSecTrainIdByIndex(wRouteOutFstLgcId, jj);  /*获取进路外方第一逻辑区段资源列车ID*/
							if (wRouteInFstLgcTrainId == wRouteOutFstLgcTrainId)
							{
								if (LOGIC_SECTION_RES_SUM_MAX > cSameIdTrainSum)
								{
									szSameIdTrainId[cSameIdTrainSum] = wRouteInFstLgcTrainId;  /*进路内外方第一逻辑区段资源列车ID相同，存储列车ID，相同列车数量加1*/
									cSameIdTrainSum++;
								}
								else
								{
									cRetVal = CI_ERROR;  /*资源列车数量超限，不再添加，返回失败*/
								}
								break;
							}
							else
							{
								/*继续遍历查找*/
							}
						}
					}
					else
					{
						/*跳过，查找下一个*/
					}

					if (CI_SUCCESS != cRetVal)
					{
						
						break;  /*查找失败，停止遍历*/
					}
					else
					{
						/*继续遍历比较*/
					}
				}
			}
			else
			{
				/*进路内/外方第一逻辑区段无资源列车，不处理*/
			}

			if (CI_SUCCESS == cRetVal)
			{
				*pTrainNum = cSameIdTrainSum;
				for (ii = 0U; ii < cSameIdTrainSum; ii++)
				{
					szTrainId[ii] = szSameIdTrainId[ii];
				}
			}
			else
			{
				/*返回失败*/
			}
		}
		else
		{			
			/*获取进路数据失败，返回失败*/
		}
	}
	else
	{
		/*入参检查失败，返回失败*/
	}

	return cRetVal;
}

/*
* 功能描述： 设置其他联锁进路逻辑区段资源ID
* 参数说明： const UINT16 routeId, 进路ID
*            const UINT16 wTrainId 列车编号
* 返回值  ： 无
* 创  建  ： qw.liu 2022-03-03
*/
void SetLgcSecResTrnIdOtherTiocRt(const UINT16 routeId, const UINT16 wTrainId)
{
	UINT8  chRouteType = 0U;
	UINT8  chLogicSecResTrainSum = 0U;
	UINT16 wLogicSum = 0U;
	UINT16 wLogicSecId = 0U;
	UINT16 ii = 0U;
	UINT8 cLocalCiId = 0u;
	UINT8 cRouteCiId = 0u;
	UINT8 cLogicSecCiId = 0u;
	UINT16 wOverlapId = 0u;
	UINT8 cOverlapCiId = 0u;
	UINT8 cRouteState = 0u;
	UINT16 wLastLgcTrainId = 0U;
	UINT8 cOverLapAddFlag = 0U;
	const UINT16 *wszLogicSecId = GetRouteLogSectionIdBuf(routeId);

	cLocalCiId = GetSystemParaLocalCiId();
	chRouteType = GetRouteType(routeId);
	wLogicSum = GetRouteLogSectionSum(routeId);
	cRouteState = GetRouteState(routeId);

	/* 获取进路所属联锁ID */
	cRouteCiId = GetRouteBelongCiId(routeId);
	cOverLapAddFlag = CI_ERROR;
	if ((MAX_ROUTE_IN_LT_NUM > wLogicSum) && (NULL != wszLogicSecId) && (0u != cLocalCiId))
	{

		/* 获取进路锁闭保护区段ID */
		wOverlapId = GetRouteOverlapLockedId(routeId);
		/* 获取保护区段所属联锁ID */
		cOverlapCiId = GetOverlapBelongCiId(wOverlapId);

		if (cRouteCiId != cLocalCiId)
		{
			if (ROUTE_TYPE_RETURN == chRouteType)
			{
				for (ii = 0U; ii < wLogicSum; ii++)
				{
					wLogicSecId = wszLogicSecId[ii];
					chLogicSecResTrainSum = GetLogSecTrainInfoSum(wLogicSecId);
					if (1U != chLogicSecResTrainSum)
					{
						break;
					}
				}

				if (ii == wLogicSum)
				{
					wLastLgcTrainId = GetLogSecTrainIdByIndex(wszLogicSecId[ii-1U],0U);
					if (wLastLgcTrainId == wTrainId)
					{
						cOverLapAddFlag = CI_SUCCESS;
					}
				}
				else
				{

				}
			}
			else if (ROUTE_TYPE_LIECHE == chRouteType)
			{
				cOverLapAddFlag = CI_SUCCESS;
			}
			else
			{
				/*无操作*/
			}
		}
		else
		{
			;/* 非本联锁进路，只处理保护区段 */
		}

		/* 保护区段处理 */
		if ((0u != wOverlapId)&&(CI_SUCCESS==cOverLapAddFlag))
		{
			/* 存在进路锁闭的保护区段，添加保护区段资源 */
			wLogicSum = GetOverlapLogicSectionSum(wOverlapId);
			wszLogicSecId = GetOverlapLogicSectionBuf(wOverlapId);

			if ((NULL != wszLogicSecId)
				&& (OVLP_LOGICSECTION_SUM_MAX>wLogicSum))
			{
				for (ii = 0U; ii < wLogicSum; ii++)
				{
					wLogicSecId = wszLogicSecId[ii];
					cLogicSecCiId = GetLogSecBelongCiId(wLogicSecId);

					if (cLogicSecCiId == cLocalCiId)
					{
						/*添加逻辑区段列车资源信息*/
						AddLogSecTrainRes(wLogicSecId, wTrainId);
					}
				}
			}
		}

	}
	else
	{

	}
}

/*
* 功能描述： 释放保护区段资源
* 参数说明： const UINT16 wOverlapId, 保护区段ID
* 返回值  ： 无
* 创  建  ： qw.liu 2022-06-10
*/
void ReleaseOverlapRes(const UINT16 wOverlapId)
{
	/* 侵限区段 */
	UINT8 chRetVal = CI_ERROR;
	UINT8 chFunRet = CI_ERROR;
	UINT8 chOverlapLgcSecSum = 0U;
	UINT16 *wpOverlapLgcSecIdBuf = NULL;
	UINT16 wRouteId = 0U;
	UINT8 ii = 0U;
	UINT8 jj = 0U;
	/* 进路内设备数据 */
	/*信号机*/
	UINT8  chNotEnterRouteTrainSum = 0U;
	UINT16 wszNotEtRouteTrainId[LOGIC_SECTION_RES_SUM_MAX] = { 0U };

	chOverlapLgcSecSum = GetOverlapLogicSectionSum(wOverlapId);
	wpOverlapLgcSecIdBuf = GetOverlapLogicSectionBuf(wOverlapId);
	if (CI_ERROR != chOverlapLgcSecSum)
	{
		chRetVal = CI_SUCCESS;
	}
	else
	{
		chRetVal = CI_ERROR;
	}
	/* 联锁逻辑检查 */


	/* 进路始端信号机【未跨压】且 非（进路外方区段【空闲】且内方第一逻辑区段【占用】）*/
	if (CI_SUCCESS == chRetVal)
	{
		wRouteId = GetLogSecLockBelongRoute(wpOverlapLgcSecIdBuf[0]);
		/* 通过检查 CBTC进路在第一逻辑区段有多个列车资源时，不关信号*/
		if (0U < wRouteId)
		{
			chFunRet = GetRouteNotEnterTrainInfo(wRouteId, &chNotEnterRouteTrainSum, wszNotEtRouteTrainId);
			if (CI_SUCCESS == chFunRet)
			{
				if ((0U < chNotEnterRouteTrainSum)
					&&(LOGIC_SECTION_RES_SUM_MAX>chNotEnterRouteTrainSum))
				{
					chRetVal = CI_SUCCESS;
					for (jj = 0U; jj < chOverlapLgcSecSum; jj++)
					{
						for (ii = 0U; ii < chNotEnterRouteTrainSum; ii++)
						{
							RemoveLgcSecResTrain(wpOverlapLgcSecIdBuf[jj],wszNotEtRouteTrainId[ii]);
						}
					}
				}
				else
				{

				}
			}
			else {
				chRetVal = CI_ERROR;
			}

		}
		else
		{

		}

	}
	else
	{

	}

}

/*
* 功能描述：获取进路不为进路资源的列车信息
* 参数说明： const UINT16 routeId, 进路ID pTrainNum 列车数量 wszTrainId 列车IDBuf
* 返回值  ： CI_ERROR :获取失败
*			 CI_SUCCESS:获取成功
*/
UINT8 GetRouteNotEnterTrainInfo(const UINT16 wRouteId, UINT8 * pTrainNum, UINT16 wszTrainId[])
{

	UINT8 ii = 0u;  /*遍历下标*/
	UINT8 jj = 0u;
	UINT16 wRouteFirstLgcId = 0u;
	UINT16 wRouteLastLgcId = 0u;
	UINT8 chNotSameIdTrainSum = 0U;
	UINT16 wszNotSameIdTrainSum[LOGIC_SECTION_RES_SUM_MAX] = { 0U };
	UINT16 wRouteFirstLgcTrainId = 0U;
	UINT16 wRouteLastLgcTrainId = 0U;
	UINT8 chRouteFirstLgcTrainSum = 0U;
	UINT8 chRouteLastLgcTrainSum = 0U;
	UINT8 ckeepWorkFlag = CI_ERROR;
	UINT8 wRetVal = CI_ERROR;

	if ((NULL == pTrainNum) || (NULL == wszTrainId))
	{
		ckeepWorkFlag = CI_ERROR;
	}
	else
	{
		ckeepWorkFlag = CI_SUCCESS;
	}

	if (CI_SUCCESS == ckeepWorkFlag)
	{
		wRouteFirstLgcId = GetRouteInFirstLogSecId(wRouteId);
		wRouteLastLgcId = GetRouteInLastLogSecId(wRouteId);
		if ((CI_ERROR == wRouteFirstLgcId)
			|| (CI_ERROR == wRouteLastLgcId))
		{
			ckeepWorkFlag = CI_ERROR;
		}
		else
		{
			chRouteFirstLgcTrainSum = GetLogSecTrainInfoSum(wRouteFirstLgcId);
			chRouteLastLgcTrainSum = GetLogSecTrainInfoSum(wRouteLastLgcId);
		}
	}

	if (CI_SUCCESS == ckeepWorkFlag)
	{
		for (ii = 0; ii < chRouteFirstLgcTrainSum; ii++)
		{
			wRouteFirstLgcTrainId = GetLogSecTrainIdByIndex(wRouteFirstLgcId, ii);
			for (jj = 0U; jj < chRouteLastLgcTrainSum; jj++)
			{
				wRouteLastLgcTrainId = GetLogSecTrainIdByIndex(wRouteLastLgcId, jj);
				if ((wRouteFirstLgcTrainId == wRouteLastLgcTrainId)
					&& (0U != wRouteFirstLgcTrainId))
				{
					
					break;
				}
			}

			if (jj == chRouteLastLgcTrainSum)
			{
				wszNotSameIdTrainSum[chNotSameIdTrainSum] = wRouteFirstLgcTrainId;
				chNotSameIdTrainSum += 1U;
			}
		}
	}
	if (CI_SUCCESS == ckeepWorkFlag)
	{
		*pTrainNum = chNotSameIdTrainSum;
		for (ii = 0U; ii < chNotSameIdTrainSum; ii++)
		{
			wszTrainId[ii] = wszNotSameIdTrainSum[ii];
		}
		wRetVal = CI_SUCCESS;
	}
	else
	{
		wRetVal = CI_ERROR;
	}


	return wRetVal;
}

/*
* 功能描述：获取临时限速确认标志
* 参数说明：无
* 返回值  ： 限速确认标志
*/
UINT8 GetTsrSureFlag(void)
{
	return g_cTsrSureFlag;
}

/*
* 功能描述：设置临时限速确认标志
* 参数说明：cTsrSureFlag 限速确认标志
* 返回值  ： 无
*/
void SetTsrSureFlag(UINT8 cTsrSureFlag)
{
	if ((CI_TSR_SURE_YES == cTsrSureFlag) || (CI_TSR_SURE_NO == cTsrSureFlag))
	{
		g_cTsrSureFlag = cTsrSureFlag;
	}
}

/*
* 功能描述： 人工解锁故障占压时解锁进路
* 参数说明： UINT16 wPhySecId,    物理区段ID

* 返回值  ： CI_ERROR
*			 CI_SUCCESS
*/
UINT8 CancelOutFirstFaultOccUnlock(UINT16 wPhySecId)
{
	/*变量初始化*/
	UINT16 belongRouteId = 0u;
	UINT8 chRetVal = CI_ERROR;
	UINT8 chRouteState = 0U;
	UINT8 chFuncRet = 0U;
	UINT8 chAutoRouteSetState = 0U;
	UINT8 chAutoSigRouteType = 0U;
	UINT16 wRouteInFirstPhySecId = 0U;
	belongRouteId = GetPhySecRLockBelongRouteId(wPhySecId);
	chRouteState = GetRouteState(belongRouteId);
	chFuncRet = AutoSignalOrRouteValid(belongRouteId);
	wRouteInFirstPhySecId = GetSignalInFirstPhySecId(GetRouteStartSignalId(belongRouteId), belongRouteId);
	if ((wRouteInFirstPhySecId == wPhySecId) && (0U != wPhySecId))
	{
		if (ROUTE_STATE_NEAR_OPEN == chRouteState)
		{
			chRetVal = CI_SUCCESS;
			if (CI_SUCCESS == chFuncRet)
			{ /*自动进路或信号有效*/
				chAutoRouteSetState = GetRouteAutoRouteSetState(belongRouteId);
				chAutoSigRouteType = GetRouteAutoSigSetState(belongRouteId);/*获取进路当前是否为自动信号进路*/

				if ((chAutoRouteSetState == ROUTE_AUTOROUTE_RETURN)
					|| (chAutoRouteSetState == ROUTE_ALLAUTOROUTE_RETURN)
					|| (chAutoSigRouteType == ROUTE_AUTOSIGROUTE_YES))
				{
					/*自动折返进路可解锁*//*自动信号按正常转移状态走，在接近锁闭正常逻辑中处理解锁问题*/

					 SetRouteStateManage(belongRouteId, ROUTE_STATE_NEAR_LOCK);  /*-->设置接近锁闭正常*/
				}
				else
				{
					SetRouteStateManage(belongRouteId, ROUTE_STATE_NEAR_LOCKERR);  /*-->设置接近锁闭异常*/
				}
			}
			else
			{
				SetRouteStateManage(belongRouteId, ROUTE_STATE_NEAR_LOCK);  /*-->设置接近锁闭正常*/
			}			
		}
	}
			
	return (chRetVal);
}

/**
* @brief 计算列车前方逻辑区段序列
* @param wTrainId         列车ID
* @param pLogicSecSum     输出的逻辑区段数量
* @param szLogicSecIdBuf  输出的逻辑区段序列
* @return CI_SUCCESS成功；CI_ERROR失败
* @create 2022.8.23
*/
UINT8 CalTrainFrontLogicSecSeq(IN const UINT16 wTrainId, OUT UINT16 * pLogicSecSum, OUT UINT16 szLogicSecIdBuf[TRAIN_INCLUDE_RES_MAX_SUM])
{
	/*变量初始化*/
	UINT8 cRetVal = CI_ERROR;
	UINT8 cKeepWork = CI_ERROR;
	UINT16 wLogicSecSum = 0U;
	UINT16 wszTrainIncLogicSecIdBuf[TRAIN_INCLUDE_RES_MAX_SUM] = {0U};
	UINT16 tmpACCnt = 0U;
	UINT16 tmpAcIdBuf[AC_MAXCNT_IN_SWITCH] = {0U};
	struct_PathPoint stTrainTailPoint = { 0U };
	UINT16 wTrainMinTailLink = 0U;
	UINT32 dwTrainMinTailOff = 0U;
	UINT16 wAxisSecIncLogicSum = 0U;
	UINT16 *pAxisSecIncLogicSecIdBuf = NULL;
	UINT16 wCurrentAxisSecId = UINT16_MAX;
	UINT16 wNextAxisSecId = UINT16_MAX;
	UINT8 cSearchDir = UINT8_MAX;
	UINT8 chCycFlag = CI_ERROR;
	UINT16 wFuncRetVal = 0u;
	UINT8 cRetMem = 0U;
	UINT8 chStartAddFlag = CI_ERROR;
	UINT8 funRtn = CI_ERROR;
	UINT8 chLocalCiId = 0U;
	UINT8 chAxisSecBelongCiId = 0U;
	UINT16 wTmpLogicId = 0U;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT8 changeFlag = 0u;
	UINT8 cDirectionPointCnt = 0U;			/*方向变化点数量*/
	UINT8 cResUsableLogSecNum = 0U;  /*计轴区段内资源可用的逻辑区段数量*/
	UINT16 wMinTailBelongAxle = 0U;  /*小后所在计轴区段ID*/
	UINT16 wMinTailBelongLogSec = 0U;  /*小后所在逻辑区段ID*/
	UINT16 szPossibleLgcIdBuf[POINT_BELONG_LGC_MAX] = { 0U };  /*道岔四开时，列车小后可能存在的逻辑区段*/
	UINT8 cPossibleLgcNum = 0U;

	/*查询搜索方向*/
	cSearchDir = GetTrainDir(wTrainId);/*最小安全后端方向*/
	chLocalCiId = GetSystemParaLocalCiId();
	if ((DIR_SAME == cSearchDir)|| (DIR_CONVERT == cSearchDir))
	{
		cKeepWork = CI_SUCCESS;
	}
	else
	{
		cSearchDir = DIR_INVALID;
		cKeepWork = CI_ERROR;
	}

	if (CI_SUCCESS == cKeepWork)
	{
		/*入参检查*/
		if ((NULL != pLogicSecSum) && (NULL != szLogicSecIdBuf))
		{
			cKeepWork = CI_SUCCESS;
		}
		else
		{
			cKeepWork = CI_ERROR;
		}
	}
	else
	{
		/*返回0失败*/
	}

	if (CI_SUCCESS == cKeepWork)
	{
		wTrainMinTailLink = GetTrainMinTailLink(wTrainId);
		dwTrainMinTailOff = GetTrainMinTailOffset(wTrainId);
		stTrainTailPoint.wLinkId = wTrainMinTailLink;
		stTrainTailPoint.dwOffset = dwTrainMinTailOff;
		wMinTailBelongLogSec = GetPointBelongLogSec(stTrainTailPoint);
		/*获取最小安全后端点所处计轴区段ID*/
		funRtn =GetAxisSeqFromLinkSeq(&wTrainMinTailLink, 1u, tmpAcIdBuf, &tmpACCnt, AC_MAXCNT_IN_SWITCH);
		if ((CI_SUCCESS == funRtn) && (0u != tmpACCnt))
		{
			wCurrentAxisSecId = GetAxisIdFromAxisSeqSafeSw(tmpAcIdBuf, tmpACCnt);
			if (0U == wCurrentAxisSecId)
			{
				/*不符合则从列车车尾开始计算*/
				wCurrentAxisSecId = tmpAcIdBuf[0];
				wMinTailBelongAxle = wCurrentAxisSecId;
			}
			else
			{
				wMinTailBelongAxle = wCurrentAxisSecId;
				/*保持当前计轴区段ID*/
				chCycFlag = CI_SUCCESS;
				do
				{
					/*从车尾开始向后查询资源可用的区段*/
					tmpACCnt = FindAdjacentAC(wCurrentAxisSecId, (~cSearchDir), tmpAcIdBuf, &changeFlag);

					if ((UINT8_MAX != tmpACCnt) && (0U != tmpACCnt))
					{
						if (1U != tmpACCnt)
						{
							wNextAxisSecId = GetAxisIdFromAxisSeqSafeSw(tmpAcIdBuf, tmpACCnt);
						}
						else
						{
							wNextAxisSecId = tmpAcIdBuf[0];
						}

						if (0U != wNextAxisSecId)
						{
							wAxisSecIncLogicSum = GetAxisSecLogSectionSum(wNextAxisSecId);
							pAxisSecIncLogicSecIdBuf = GetAxisSecLogSectionIdBuf(wNextAxisSecId);
							chAxisSecBelongCiId = GetAxisSectionBelongCiId(wNextAxisSecId);
							if ((wAxisSecIncLogicSum != 0U) && (pAxisSecIncLogicSecIdBuf != NULL))
							{
								if ((chAxisSecBelongCiId == chLocalCiId) && (0U != chAxisSecBelongCiId))
								{
									if ((TRAIN_INCLUDE_RES_MAX_SUM > wLogicSecSum) && ((TRAIN_INCLUDE_RES_MAX_SUM - wLogicSecSum) > wAxisSecIncLogicSum))
									{
										cSearchDir = TransDirectionPointDir(changeFlag, cSearchDir, &cDirectionPointCnt);  /*根据方向变化点转换方向*/
										cResUsableLogSecNum = GetResUsableLogSecNumInAxis(wNextAxisSecId, wTrainId, cSearchDir, &wszTrainIncLogicSecIdBuf[wLogicSecSum]);  /*获取计轴区段内资源可用的逻辑区段数量*/

										if ((UINT8_MAX != cResUsableLogSecNum) && (0U != cResUsableLogSecNum))
										{
											wCurrentAxisSecId = wNextAxisSecId;  /*继续查找车尾后方区段*/
											ii += wAxisSecIncLogicSum;  /*使用计数，防止死循环或无限累加*/

											if (cResUsableLogSecNum != wAxisSecIncLogicSum)
											{
												chCycFlag = CI_ERROR;  /*该计轴区段存在逻辑区段资源不可用，停止查找车尾后方区段*/
											}
										}
										else
										{
											cSearchDir = TransDirectionPointDir(changeFlag, cSearchDir, &cDirectionPointCnt);  /*资源不可用，无需添加区段，将查询方向回撤至上一区段的方向*/
											chCycFlag = CI_ERROR;  /*资源不可用，停止查找车尾后方区段*/
										}
									}
									else
									{
										chCycFlag = CI_ERROR;  /*数量超限，停止查找车尾后方区段*/
									}
								}
								else
								{
									chCycFlag = CI_ERROR;  /*查询到非本控区计轴区段，停止查找车尾后方区段*/
								}
							}
							else
							{
								chCycFlag = CI_ERROR;  /*获取计轴区段包含的逻辑区段失败，停止查找车尾后方区段*/
							}
						}
						else
						{
							chCycFlag = CI_ERROR;  /*下一计轴区段ID为0，停止查找车尾后方区段*/
						}
					}
					else
					{
						chCycFlag = CI_ERROR;  /*查询失败，停止查找车尾后方区段*/
					}

				} while ((ii < TRAIN_INCLUDE_RES_MAX_SUM) && (CI_SUCCESS == chCycFlag));
			}

			(void)CommonMemSet(wszTrainIncLogicSecIdBuf, (UINT32)(TRAIN_INCLUDE_RES_MAX_SUM * sizeof(UINT16)), 0U, (UINT32)(TRAIN_INCLUDE_RES_MAX_SUM * sizeof(UINT16)));  /*开始向前查询，将存储的逻辑区段清空*/

			wAxisSecIncLogicSum = GetAxisSecLogSectionSum(wCurrentAxisSecId);
			pAxisSecIncLogicSecIdBuf = GetAxisSecLogSectionIdBuf(wCurrentAxisSecId);
			chAxisSecBelongCiId = GetAxisSectionBelongCiId(wCurrentAxisSecId);
			
			if ((wAxisSecIncLogicSum != 0U) && (pAxisSecIncLogicSecIdBuf != NULL))
			{
				/*查询所在计轴为本TIOC*/
				if ((chAxisSecBelongCiId == chLocalCiId) && (0U != chAxisSecBelongCiId))
				{
					/*判断不会产生越界*/
					if ((TRAIN_INCLUDE_RES_MAX_SUM > wLogicSecSum) && ((TRAIN_INCLUDE_RES_MAX_SUM - wLogicSecSum) > wAxisSecIncLogicSum))
					{
						cResUsableLogSecNum = GetResUsableLogSecNumInAxis(wCurrentAxisSecId, wTrainId, cSearchDir, &wszTrainIncLogicSecIdBuf[wLogicSecSum]);  /*获取计轴区段内资源可用的逻辑区段数量*/

						if ((UINT8_MAX != cResUsableLogSecNum) && (0U != cResUsableLogSecNum))
						{
							wLogicSecSum += cResUsableLogSecNum;
							chStartAddFlag = CI_SUCCESS;
						}
						else if (wMinTailBelongAxle == wCurrentAxisSecId)
						{
							/*若为小后所在计轴区段，且计轴区段内无可用资源，也应添加此区段，否则将影响车前方的资源回撤*/
							if (0U == wMinTailBelongLogSec)
							{
								/*列车小后道岔四开时，获取小后所在逻辑区段ID为0，需再获取小后点可能在的所有逻辑区段，结合计轴区段确定小后所在逻辑区段*/
								cPossibleLgcNum = GetPointBelongLogSecEx(stTrainTailPoint, szPossibleLgcIdBuf);
								for (ii = 0U; ii < wAxisSecIncLogicSum; ii++)
								{
									for (jj = 0U; jj < cPossibleLgcNum; jj++)
									{
										if (pAxisSecIncLogicSecIdBuf[ii] == szPossibleLgcIdBuf[jj])
										{
											wMinTailBelongLogSec = szPossibleLgcIdBuf[jj];
											break;
										}
										else
										{
											/*继续查找*/
										}
									}

									if (0U != wMinTailBelongLogSec)
									{
										break;
									}
									else
									{
										/*继续查找*/
									}
								}
							}
							else
							{
								/*不处理，使用当前逻辑区段作为列车小后所在区段*/
							}

							cResUsableLogSecNum = (UINT8)GetLgcSecSeqBelongAc(wMinTailBelongLogSec, wCurrentAxisSecId, cSearchDir, &wszTrainIncLogicSecIdBuf[wLogicSecSum]);
							wLogicSecSum += cResUsableLogSecNum;
							chStartAddFlag = CI_SUCCESS;
						}
						else
						{
							/*不处理*/
						}
					}
				}
				else
				{
					; /*非本控区计轴区段，不处理*/
				}
			}
			else
			{
				cKeepWork = CI_ERROR;  /*计轴区段无效，返回0失败*/
			}
		}
		else
		{
			/*存在道岔不在规定位置时，查询失败 ,后续修改逻辑区段划分后再细化处理*/
			cKeepWork = CI_ERROR;
		}
#if 0
		wTmpLogicId = GetPointBelongLogSec(stTrainTailPoint);
		/** 判断查询是否成功 */
		if (0U != wTmpLogicId)
		{
			/*获取列车所在计轴区段*/
			wCurrentAxisSecId = GetLgcSecRelativeAxleSecId(wTmpLogicId);
			wAxisSecIncLogicSum = GetAxisSecLogSectionSum(wCurrentAxisSecId);
			chAxisSecBelongCiId = GetAxisSectionBelongCiId(wCurrentAxisSecId);
			/*计轴区段有效*/
			if (0 != wAxisSecIncLogicSum)
			{
				/*查询所在计轴为本TIOC*/
				if ((chAxisSecBelongCiId == chLocalCiId)
					&&(0U!=chAxisSecBelongCiId))
				{	
					/*判断不会产生越界*/
					if ((TRAIN_INCLUDE_RES_MAX_SUM > wLogicSecSum)
						&& ((TRAIN_INCLUDE_RES_MAX_SUM - wLogicSecSum) > wAxisSecIncLogicSum))
					{
						wFuncRetVal = GetLgcSecSeqBelongAc(wTmpLogicId,cSearchDir,wszTrainIncLogicSecIdBuf);
						if (0U < wFuncRetVal)
						{
							wLogicSecSum += wFuncRetVal;
							chStartAddFlag = CI_SUCCESS;
						}
						else
						{
							cKeepWork = CI_ERROR;
						}
					}
					else
					{
						cKeepWork = CI_ERROR;
					}
				}
				else
				{
					chStartAddFlag = CI_ERROR; /*Set CI_ERROR*/
				}
			}
			else
			{
				cKeepWork = CI_ERROR;
			}
		}
		else
		{
			/**此处不处理，车尾道岔四开等场景 查询失败*/
		}
#endif
	}
	
	if (CI_SUCCESS == cKeepWork)
	{
		chCycFlag = CI_SUCCESS;
		do
		{
			/*获取下一linkID*/
			tmpACCnt = FindAdjacentAC(wCurrentAxisSecId, cSearchDir, tmpAcIdBuf, &changeFlag);

			/*若当前link与下一link之间存在方向变化点，查找方向反向*/
			cSearchDir = TransDirectionPointDir(changeFlag, cSearchDir, &cDirectionPointCnt);

			if ((UINT8_MAX != tmpACCnt)&&(0U!=tmpACCnt))
			{
				if (1U != tmpACCnt)
				{
					wNextAxisSecId = GetAxisIdFromAxisSeqSafeSw(tmpAcIdBuf, tmpACCnt);
				}
				else
				{
					wNextAxisSecId = tmpAcIdBuf[0];
				}
				if (0U != wNextAxisSecId)
				{
					wAxisSecIncLogicSum = GetAxisSecLogSectionSum(wNextAxisSecId);
					pAxisSecIncLogicSecIdBuf = GetAxisSecLogSectionIdBuf(wNextAxisSecId);
					chAxisSecBelongCiId = GetAxisSectionBelongCiId(wNextAxisSecId);
					/*计轴区段有效*/
					if ((wAxisSecIncLogicSum != 0U) && (pAxisSecIncLogicSecIdBuf != NULL))
					{
						/*查询所在计轴为本TIOC*/
						if ((chAxisSecBelongCiId == chLocalCiId) && (0U != chAxisSecBelongCiId))
						{
							/*判断不会产生越界*/
							if ((TRAIN_INCLUDE_RES_MAX_SUM > wLogicSecSum) && ((TRAIN_INCLUDE_RES_MAX_SUM - wLogicSecSum) > wAxisSecIncLogicSum))
							{
								if (DIR_SAME == cSearchDir)
								{
									wTmpLogicId = pAxisSecIncLogicSecIdBuf[0];
								}
								else
								{
									wTmpLogicId = pAxisSecIncLogicSecIdBuf[wAxisSecIncLogicSum - 1U];
								}
								wFuncRetVal = GetLgcSecSeqBelongAc(wTmpLogicId, wNextAxisSecId, cSearchDir, (UINT16*)&wszTrainIncLogicSecIdBuf[wLogicSecSum]);
								if (wAxisSecIncLogicSum == wFuncRetVal)
								{
									wLogicSecSum += wAxisSecIncLogicSum;
									chStartAddFlag = CI_SUCCESS;
								}
#if 0 
								cRetMem = CommonMemCpy(((void *)&wszTrainIncLogicSecIdBuf[wLogicSecSum]), (TRAIN_INCLUDE_RES_MAX_SUM - wLogicSecSum) * sizeof(UINT16), \
									(void *)pAxisSecIncLogicSecIdBuf, wAxisSecIncLogicSum * sizeof(UINT16));
								if (CI_SUCCESS == cRetMem)
								{
									/*将数量输出*/
									wLogicSecSum += wAxisSecIncLogicSum;
									cRetVal = CI_SUCCESS;
									chStartAddFlag = CI_SUCCESS;
								}
								else
								{
									; /*DO NOTHING*/
								}
#endif
							}
							else
							{
								chCycFlag = CI_ERROR;
							}
						}
						else
						{
							if (CI_SUCCESS == chStartAddFlag)
							{
								/*已经添加过，查询到不属于本控区时，退出*/
								chCycFlag = CI_ERROR;
							}
						}
					}
					else
					{
						cKeepWork = CI_ERROR;
						chCycFlag = CI_ERROR;
					}
				}
				else
				{
					/*道岔不在规定位置，退出查询*/
					chCycFlag = CI_ERROR;
				}
				
			}
			else
			{
				chCycFlag = CI_ERROR; /**查询失败*/
			}

			wCurrentAxisSecId = wNextAxisSecId;

			if (CI_ERROR == chCycFlag)
			{
				break;
			}
			else
			{
				; /*继续循环*/
			}
		} while (wLogicSecSum < TRAIN_INCLUDE_RES_MAX_SUM);

	}
	else
	{
		; /**不处理*/
	}

	if (CI_SUCCESS == cKeepWork)
	{
		debug_infor_printf((const)"ResRetreat TrainIncLogicSecId:[");
		for (ii = 0U; ii < wLogicSecSum; ii++)
		{
			debug_infor_printf((const)"%d,", wszTrainIncLogicSecIdBuf[ii]);
		}
		debug_infor_printf((const)"]\n");

		/*检查通过，将结果拷贝到输出数组*/
		cRetMem = CommonMemCpy(szLogicSecIdBuf, (UINT32)(TRAIN_INCLUDE_RES_MAX_SUM * sizeof(UINT16)), wszTrainIncLogicSecIdBuf, (UINT32)(wLogicSecSum * sizeof(UINT16)));
		if (CI_SUCCESS == cRetMem)
		{
			/*将数量输出*/
			*pLogicSecSum = wLogicSecSum;
			cRetVal = CI_SUCCESS;
		}
		else
		{
			cRetVal = CI_ERROR;
		}

	}
	else
	{
		cRetVal = CI_ERROR;
	}

	return cRetVal;
}

/**
* @brief 获取列车可用逻辑区段序列
* @param wTrainId         列车ID
* @param pLogicSecSum     输出的逻辑区段数量
* @param szLogicSecIdBuf  输出的逻辑区段序列
* @return CI_SUCCESS成功；CI_ERROR失败
* @create 2022.8.23
*/
UINT8 GetTrainUsableLogicSec(IN const UINT16 wTrainId, OUT UINT16 * pLogicSecSum, OUT UINT16 szLogicSecIdBuf[TRAIN_INCLUDE_RES_MAX_SUM])
{
	/*变量初始化*/
	UINT8 cRetVal = CI_ERROR;
	UINT8 cKeepWork = CI_ERROR;
	UINT16 wLogicCurSum = 0U;
	UINT16 wLogicSecId = 0U;
	UINT16 wTrainUsableLogicSum = 0U;
	UINT16 wszTrainIncLogicIdBuf[TRAIN_INCLUDE_RES_MAX_SUM] = { 0U };
	UINT16 ii = 0U;
	UINT8 chTrainUsableStt = 0U;
	UINT8 chFlagExec = CI_ERROR;
	UINT8 cRetMem = 0u;
	UINT8 chLocalCiId = 0U;
	UINT8 chLogicSecBelongCiId = 0U;

	/*获取本CI ID*/
	
	chLocalCiId = GetSystemParaLocalCiId();
	wLogicCurSum = GetLogicSecCurSum();
	

	
	/*入参检查*/
	if ((NULL != pLogicSecSum) && (NULL != szLogicSecIdBuf))
	{
		cKeepWork = CI_SUCCESS;
	}
	else
	{
		cKeepWork = CI_ERROR;
	}

	if (CI_SUCCESS == cKeepWork)
	{
		for (ii = 0u; ii < wLogicCurSum; ii++)
		{

			chFlagExec = CI_ERROR;
			chTrainUsableStt = LOGIC_SECTION_RES_UNUSABLE;
			wLogicSecId = GetLogicSecId(ii);
			chLogicSecBelongCiId = GetLogSecBelongCiId(wLogicSecId);           /*获取逻辑区段所属联锁ID*/
			chTrainUsableStt = GetLogSecTrainResUsableState(wLogicSecId, wTrainId);
			if ((0u == wLogicSecId) || (LOGIC_SECTION_SUM_MAX < wLogicSecId))
			{
				chFlagExec = CI_ERROR;
			}
			else
			{
				chFlagExec = CI_SUCCESS;
			}

			if (CI_SUCCESS == chFlagExec)
			{
				if (chLogicSecBelongCiId != chLocalCiId)
				{
					chFlagExec = CI_ERROR;
				}
				else
				{
					; /*继续执行*/
				}
			}
			if (CI_SUCCESS == chFlagExec)
			{
				if (LOGIC_SECTION_RES_USABLE == chTrainUsableStt)
				{
					if (TRAIN_INCLUDE_RES_MAX_SUM > wTrainUsableLogicSum)
					{
						wszTrainIncLogicIdBuf[wTrainUsableLogicSum++] = wLogicSecId;
					}
				}
			}
		}
	}
	else
	{
		; /* 不处理*/
	}


	if (CI_SUCCESS == cKeepWork)
	{
		/*检查通过，将结果拷贝到输出数组*/
		cRetMem = CommonMemCpy(szLogicSecIdBuf, (UINT32)(TRAIN_INCLUDE_RES_MAX_SUM * sizeof(UINT16)), wszTrainIncLogicIdBuf, (UINT32)(wTrainUsableLogicSum * sizeof(UINT16)));
		if (CI_SUCCESS == cRetMem)
		{
			/*将数量输出*/
			*pLogicSecSum = wTrainUsableLogicSum;
			cRetVal = CI_SUCCESS;
		}
		else
		{
			cRetVal = CI_ERROR;
		}

	}
	else
	{
		cRetVal = CI_ERROR;
	}

	return cRetVal;
}


/*
* 功能描述： 获取物理区段内逻辑区段占用信息
* 参数说明： void
* 返回值  ：
*			 LOGICSECTION_OCCUPY_UT
*			 LOGICSECTION_OCCUPY_CT
*			 LOGICSECTION_OCCUPY_NO
*/
UINT8 GetPhySecUtOrCtOccuState(UINT16 phySectionId)
{
	UINT8 const logicSecSum = GetPhySecIncLogSecSum(phySectionId);
	UINT16* const pLogicSecIdBuf = GetPhySecIncLogSecIdBuf(phySectionId);

	UINT8 jj = 0u;
	UINT8 logicOccupyState = 0u;
	UINT8 reValue = LOGICSECTION_OCCUPY_UT;

	if (0u == logicSecSum)
	{
		reValue = LOGICSECTION_OCCUPY_UT;
	}
	else
	{
		
		for (jj = 0u; jj < logicSecSum; jj++)
		{
			logicOccupyState = GetLogSecCurCtOrUtOccupyState(pLogicSecIdBuf[jj]);
			if(LOGICSECTION_OCCUPY_CT == logicOccupyState)
			{
				/*CT占用 ，继续执行*/
				reValue = LOGICSECTION_OCCUPY_CT;
			}else if(LOGICSECTION_OCCUPY_NO == logicOccupyState)
			{
				; /*无占压，继续执行*/
			}
			else
			{
				/*任一逻辑区段UT占用*/
				reValue = LOGICSECTION_OCCUPY_UT;
				break;
			}
		}
		
	}
	return reValue;
}


/*
* 功能描述： 设置指定ID联锁控制权标志
* 参数说明： const UINT8 virtualCiId     虚拟联锁ID
			 const UINT8 ctrlPowerFlag  控制状态
			 const UINT16 ctrlPowerId   控制设备编号
			 const UINT8 ctrlDeviceType 控制设备类型


* 返回值  ： viod
*
*/
void SetCtrlPower(const UINT8 virtualCiId, const UINT8 ctrlPowerFlag, const UINT16 ctrlPowerId, const UINT8 ctrlDeviceType)
{
	UINT8 i = 0u;
	UINT8 cimode = 0u;
	UINT8 virtualCiNum = 0u;
	cimode = GetCiModeFlag();
	virtualCiNum = GetVirtualCINum();
	if (CI_MODE_ATS != cimode)
	{
		if (virtualCiNum <= VIRTUAL_CI_MAX)
		{
			for (i = 0u; i < virtualCiNum; i++)
			{
				if ((CONTRAL_POWER_YES == ctrlpowerFlag[i].ctrlPowerState) && (virtualCiId == ctrlpowerFlag[i].virCiId))
				{/*清权，抢权时先清掉原来控制权所属信息*/
					ctrlpowerFlag[i].ctrlPowerState = CONTRAL_POWER_NO;
					ctrlpowerFlag[i].ctrlDeviceId = 0u;
					ctrlpowerFlag[i].ctrlDeviceType = 0u;
				}
			}
			for (i = 0u; i < virtualCiNum; i++)
			{
				if (virtualCiId == ctrlpowerFlag[i].virCiId)
				{	/*赋权，重新赋予控制设备控制权信息*/
					ctrlpowerFlag[i].ctrlPowerState = ctrlPowerFlag;
					ctrlpowerFlag[i].ctrlDeviceId = ctrlPowerId;
					ctrlpowerFlag[i].ctrlDeviceType = ctrlDeviceType;
				}
			}
		}
	}
	else
	{
		/*不执行*/
	}

}
/*
* 功能描述： 释放指定ID联锁控制权标志
* 参数说明： const UINT8 virtualCiId     虚拟联锁ID
			 const UINT8 ctrlPowerFlag  控制状态
			 const UINT16 ctrlPowerId   控制设备编号
			 const UINT8 ctrlDeviceType 控制设备类型


* 返回值  ： viod
*
*/
void ReleaseCtrlPower(const UINT8 virtualCiId, const UINT8 ctrlPowerFlag, const UINT16 ctrlPowerId, const UINT8 ctrlDeviceType)
{

	UINT8 ii = 0U;
	UINT8 virtualCiNum = 0U;
	UINT8 chXiandiHavePower = 0U;/*上电初始化现地是否具备联锁控制权*/

	chXiandiHavePower = GetCiFunctionSwitchConfig(FUNC_INIT_XIANDI_HAVE_POWER);
	virtualCiNum = GetVirtualCINum();

	if (virtualCiNum <= VIRTUAL_CI_MAX)
	{
		for (ii = 0U; ii < virtualCiNum; ii++)
		{
			if (virtualCiId == ctrlpowerFlag[ii].virCiId)
			{
				ctrlpowerFlag[ii].ctrlDeviceId = 0U;
				if (FUNC_SWITCH_ON == chXiandiHavePower)
				{
					ctrlpowerFlag[ii].ctrlDeviceType = CI_SYSTEM_TYPE_XIANDI;
					ctrlpowerFlag[ii].ctrlPowerState = CONTRAL_POWER_YES;
				}
				else
				{
					ctrlpowerFlag[ii].ctrlDeviceType = 0U;
					ctrlpowerFlag[ii].ctrlPowerState = CONTRAL_POWER_NO;
				}

			}
		}
	}
}
/*
* 功能描述： 取消自动触发标志管理
* 参数说明： UINT8 virCIid 虚拟联锁ID
*            UINT8 setFlag  需设置的自动触发标志
* 返回值  ：无
* cgh-合并CID-3037-4：
*/
void CancelAutoTriggerLogicManage(UINT8 virCIid, UINT8 setFlag)
{
	UINT16 ii = 0u;
	UINT16 routeCurSum = 0u;	     /*进路总数目*/
	UINT16 routeId = 0u;	         /*进路ID*/

	routeCurSum = GetRouteCurSum();		        /*获取进路总数*/
	/*处理进路*/
	for (ii = 0u; ii < routeCurSum; ii++)
	{
		routeId = GetRouteId(ii);                           /*获取进路ID*/
		CancelSigleRouteAutoTrigger(virCIid, routeId, setFlag); /*取消本集中区的已设置自动触发标志的进路的自动触发标志*/
	}
}
/*
* 功能描述： 设置指定进路自动触发标志管理
* 参数说明：UINT8 virCIid  虚拟联锁ID
			UINT16 routeId 进路ID
*           UINT8 setFlag  需设置的自动触发标志
* 返回值  ：无
*/
void SetSigleRouteAutoTriggerManage(UINT8 virCIid, UINT16 routeId, UINT8 setFlag)
{
	UINT8 chkFState = CI_ERROR;
	UINT8 chkFloodState = CI_ERROR;
	UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 belongCiId = 0u;        /*进路所属联锁ID*/
	UINT8 localCiId = 0u;         /*本地联锁ID*/
	UINT8 belongVirCI = 0u;
	UINT8 flag = 0u;
	UINT8 autoTriggerType = 0u;      /*自动触发进路属性*/

	autoTriggerType = GetAutoTriggerType(routeId);      /*获取进路自动触发进路属性*/
	localCiId = GetSystemParaLocalCiId();       /*获取本机联锁ID*/
	belongCiId = GetRouteBelongCiId(routeId);           /*获取进路所属联锁ID*/
	if (ROUTE_TYPE_AUTO_TRIGGER == autoTriggerType)
	{
		if (FUNC_SWITCH_ON == includeVirFlag)
		{
			belongVirCI = GetRouteBelongVirCiId(routeId);
			if (belongVirCI != virCIid)
			{
				flag = 1u;
			}
		}

		if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX) || (belongCiId != localCiId) || (1u == flag))
		{
			/*ID无效或非本联锁*/
		}
		else
		{
			/*检查自动触发进路封锁状态*/
			chkFState = ChekAutoTriggerRouteFlockState(routeId);

			if (CI_SUCCESS == chkFState)
			{
				/*检查自动触发进路防淹门状态*/
				chkFloodState = ChekAutoTrigRouteFloodGateState(routeId);

				if (CI_SUCCESS == chkFloodState)
				{
					if (AUTO_TRIGGER_SET_YES == setFlag)
					{
						SetRouteAutoTriggerFlag(routeId, setFlag);        /*设置本联锁指定自动触发进路自动触发属性*/
					}
				}
				else
				{
					/*报警此条进路自动触发属性设置失败*/
					SetCiSendCmdBackInfoData(CI_BACK_AUTO_TRIGGER_SET_ERR, CI_DEVICE_TYPE_ROUTE, routeId, 0u, 0u);/*反馈进路设置自动触发标志失败*/
				}
			}
			else
			{
				/*报警此条进路自动触发属性设置失败*/
				SetCiSendCmdBackInfoData(CI_BACK_AUTO_TRIGGER_SET_ERR, CI_DEVICE_TYPE_ROUTE, routeId, 0u, 0u);/*反馈进路设置自动触发标志失败*/
			}
		}
	}
}

/*
* 功能描述： 取消指定进路的自动触发标志管理
* 参数说明： UINT8 virCIid 虚拟联锁ID
*            UINT16 routeId 进路ID
*            UINT8 setFlag  需设置的自动触发标志
* 返回值  ：无
* cgh-合并CID-3037-4：
*/
void CancelSigleRouteAutoTrigger(UINT8 virCIid, UINT16 routeId, UINT8 setFlag)
{
	UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 belongCiId = 0u;        /*进路所属联锁ID*/
	UINT8 localCiId = 0u;         /*本地联锁ID*/
	UINT8 belongVirCI = 0u;
	UINT8 flag = 0u;
	UINT8 routeAutoTriggerFlag = 0u;      /*自动触发标志*/

	localCiId = GetSystemParaLocalCiId();       /*获取本机联锁ID*/
	belongCiId = GetRouteBelongCiId(routeId);           /*获取进路所属联锁ID*/
	flag = 0u;
	if (FUNC_SWITCH_ON == includeVirFlag)
	{
		belongVirCI = GetRouteBelongVirCiId(routeId);
		if (belongVirCI != virCIid)
		{
			flag = 1u;
		}
	}

	if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX) || (belongCiId != localCiId) || (1u == flag))
	{
		/*ID无效或非本联锁*/
	}
	else
	{
		routeAutoTriggerFlag = GetRouteAutoTriggerFlag(routeId); /*获取进路的自动触发标志*/
		if (AUTO_TRIGGER_SET_YES == routeAutoTriggerFlag)
		{
			SetRouteAutoTriggerFlag(routeId, setFlag);        /*设置本联锁指定自动触发进路自动触发属性*/
		}
	}
}
/*
* 功能描述： 设置站台轨关联的屏蔽门清客标志
* 参数说明：UINT16 phySecId  物理区段ID
*           UINT8 setFlag  需设置的清客标志
* 返回值  ：无
* cgh-合并CID-3037-7：
*/
void SetClearPassenagerManage(UINT16 phySecId, UINT8 setFlag)
{
	UINT16 psdSum = 0u;     /*屏蔽门数量*/
	UINT16 psdRelatPhySecId = 0u;  /*屏蔽门关联的物理区段ID*/
	UINT8 localCiId = 0u;    /*本地联锁ID*/
	UINT8 devBelongCiId = 0u; /*设备所属联锁*/
	UINT16 ii = 0u;          /*游标*/
	UINT16 psdId = 0u;

	localCiId = GetSystemParaLocalCiId();
	devBelongCiId = GetPhySecBelongCiId(phySecId);
	if (localCiId != devBelongCiId)
	{
		/*不做处理*/
	}
	else
	{
		psdSum = GetPsdSum();   /*获取屏蔽门数量*/
		for (ii = 0u; ii < psdSum; ii++)
		{
			psdId = GetPsdId(ii);
			psdRelatPhySecId = GetPsdRelatedPhySecId(psdId);  /*获取屏蔽门关联的物理区段ID*/
			if (phySecId == psdRelatPhySecId)
			{
				if (ATS_TO_CI_PLATFORM_QK_YES == setFlag)
				{
					SetClearPassenagerFlag(psdId, setFlag);   /*设置清客标志*/
				}
				break;
			}
		}
	}
}


/*
* 功能描述： 设置进路部分逻辑区段资源的列车ID
* 参数说明： const UINT16 routeId, 进路ID
*            const UINT16 wTrainId 列车编号
* 返回值  ： 无
* 创  建  ： qw.liu 2022-03-03
* @note 集成 bug 20220420 编码规范：删除冗余变量，空语句增加注释
*/
void SetRouteHalfLogSecResTrainId(const UINT16 routeId, const UINT16 wTrainId)
{
	UINT8  chRouteType = 0U;
	UINT8  chLogicSecResTrainSum = 0U;
	UINT16 wLogicSum = 0U;
	UINT16 wLogicSecId = 0U;
	UINT16 ii = 0U;
	UINT16 wRouteLastPhySecId = 0U;
	UINT16 wLogicSecRelativePhySecId = 0U;
	UINT16 wGroupOtherTrainId = 0U;
	LogicTrainResStruct *pstLgcTrnResInfo = NULL;
	UINT8 cLocalCiId = 0u;
	UINT8 cRouteCiId = 0u;
	UINT8 chReturnLogAddFlag = CI_ERROR;
	UINT16 wLogicPLockRouteId = 0U;
	UINT8 funcRet = CI_ERROR;
	const UINT16 *wszLogicSecId = GetHalfRouteLockLgcSecIdBuf(routeId);
	UINT8 chLocalCiType = 0U;/*本地联锁类型*/

	cLocalCiId = GetSystemParaLocalCiId();
	wLogicSum = GetHalfRouteLockLgcSecSum(routeId);
	chLocalCiType = GetLocalCiType();

	if ((CI_TYPE_TCC == chLocalCiType) || (CI_TYPE_CLD == chLocalCiType))
	{
		/* 获取进路类型*/
		chRouteType = GetConfigRouteType(routeId);
	}
	else
	{
		/* 获取进路类型*/
		chRouteType = GetRouteType(routeId);
	}

	/* 获取进路所属联锁ID */
	cRouteCiId = GetRouteBelongCiId(routeId);
	if ((MAX_ROUTE_IN_LT_NUM > wLogicSum) 
		&& (NULL != wszLogicSecId)
		&& (0u != cLocalCiId)
		&&(0U!=wTrainId))
	{
		if (cRouteCiId == cLocalCiId)
		{
			if (ROUTE_TYPE_RETURN == chRouteType)
			{
				for (ii = 0U; ii < wLogicSum; ii++)
				{
					wLogicSecId = wszLogicSecId[ii];
					funcRet = CheckLgcSecNotInTrainLoc(routeId, wLogicSecId);
					if (CI_SUCCESS == funcRet)
					{
						wLogicPLockRouteId = GetLogSecPLockRouteId(wLogicSecId);
						chLogicSecResTrainSum = GetLogSecTrainInfoSum(wLogicSecId);
						if (0U < chLogicSecResTrainSum)
						{
							if (0U == wLogicPLockRouteId)
							{
								break;
							}
							else
							{

							}
						}
					}
				}

				if (ii == wLogicSum)
				{
					chReturnLogAddFlag = CI_SUCCESS;
				}
				else
				{
					/*判断前车与本车为同一编组运行列车--加资源*/
					wGroupOtherTrainId = GetGroupTrainOtherId(wTrainId);
					pstLgcTrnResInfo = GetLogSecTrainInfoById(wLogicSecId, wGroupOtherTrainId);
					if (NULL != pstLgcTrnResInfo)
					{
						chReturnLogAddFlag = CI_SUCCESS;
					}
					else
					{
						chReturnLogAddFlag = CI_ERROR;
					}
				}

				if (CI_SUCCESS == chReturnLogAddFlag)
				{
					/*进路添加资源*/
					wRouteLastPhySecId = GetRouteLastPhySectionId(routeId);
					for (ii = 0U; ii < wLogicSum; ii++)
					{
						wLogicSecId = wszLogicSecId[ii];

						funcRet = CheckLgcSecNotInTrainLoc(routeId, wLogicSecId);
						if (CI_SUCCESS == funcRet)
						{
							/*添加逻辑区段列车资源信息*/
							AddLogSecTrainRes(wLogicSecId, wTrainId);
							wLogicSecRelativePhySecId = GetLgcSecRelativePhySecId(wLogicSecId);
							if ((wRouteLastPhySecId == wLogicSecRelativePhySecId)
								&& (0U != wLogicSecRelativePhySecId))
							{
								SetLogSecTrainReturnState(wLogicSecId, wTrainId, LOGIC_SECTION_TRAIN_RETURN_YES);
							}
							else
							{
								/*继续执行*/
							}
						}
					}
				}
				else
				{

				}
			}
			else if (ROUTE_TYPE_LIECHE == chRouteType)
			{
				for (ii = 0U; ii < wLogicSum; ii++)
				{
					wLogicSecId = wszLogicSecId[ii];
					funcRet = CheckLgcSecNotInTrainLoc(routeId, wLogicSecId);
					if (CI_SUCCESS == funcRet)
					{
						/*添加逻辑区段列车资源信息*/
						AddLogSecTrainRes(wLogicSecId, wTrainId);
					}
					else
					{
						SetLogSecTrainReturnState(wLogicSecId, wTrainId, LOGIC_SECTION_TRAIN_RETURN_NO);  /*清除折返标志*/
					}
				}
			}
			else
			{
				/* 不处理 */
			}
		}
		else
		{
			;/* 非本联锁进路，不处理*/
		}
	}
	else
	{
		/* 不处理 */
	}
}

/*
*功能描述:清除进路部分关联道岔期望驱动位置
*
*输入参数: const UINT16 routeId 进路ID
*
*输出参数:无.
*
*返回值:无
*
*/
void ClearRouteHalfSwitchDrivePos(const UINT16 routeId)
{
	UINT8 	retValOfSetSwiExpDrvPos = CI_ERROR;				/*设置道岔期望驱动位置的返回值*/
	UINT16 	switchId = 0u; 									/*道岔ID*/
	UINT8   lgcSecSwitchSum = 0U;							/*逻辑区段关联道岔数量*/
	LogsecSwitchStruct *pLgcSecSwitchData = NULL;
	UINT8 	ii = 0u;											/*循环变量*/
	UINT8  jj = 0U;

	UINT8 routeProtectSwitchSum = 0u; 							/*防护道岔数目*/
	RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U };  /*防护道岔数据*/

	UINT16 logSectionSum = 0u; /*逻辑区段数*/
	UINT16* pLogIdBuff = NULL;
	/*获取进路包含逻辑区段信息*/
	logSectionSum = GetHalfRouteLockLgcSecSum(routeId);
	pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(routeId);
	routeProtectSwitchSum = GetRouteHalfProSwData(routeId, routeProtectSwitchStru);      /*获取防护道岔数据*/

	if (NULL != pLogIdBuff)
	{
		for (ii = 0u; ii < logSectionSum; ii++)
		{
			lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]);
			pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]);
			if (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX)
			{
				for (jj = 0u; jj < lgcSecSwitchSum; jj++)
				{
					switchId = pLgcSecSwitchData[jj].SwitchId;
					/*设置该道岔期望驱动位置为无效*/
					retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);

					if (CI_SUCCESS == retValOfSetSwiExpDrvPos)
					{

					}
					else
					{/*设置失败*/
					 /*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
					}
				}
			}
		}
	}

	if (NULL != routeProtectSwitchStru)
	{
		for (ii = 0u; ii < routeProtectSwitchSum; ii++)
		{
			switchId = routeProtectSwitchStru[ii].ProtectSwitchId;
			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);

			if (CI_SUCCESS == retValOfSetSwiExpDrvPos)
			{

			}
			else
			{/*设置失败*/
			 /*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
			}
		}
	}

}

/*
*功能描述:清除进路部分关联道岔期望驱动位置
*
*输入参数: const UINT16 routeId 进路ID
*
*输出参数:无.
*
*返回值:无
*
*/
void ClearRouteHalfSwitchDanCaoPos(const UINT16 routeId)
{
	UINT8 	retValOfSetSwiDanCaoPos = CI_ERROR;				/*设置道岔单操位置的返回值*/
	UINT16 	switchId = 0u; 									/*道岔ID*/
	UINT8   lgcSecSwitchSum = 0U;							/*逻辑区段关联道岔数量*/
	LogsecSwitchStruct *pLgcSecSwitchData = NULL;
	UINT8 	ii = 0u;											/*循环变量*/
	UINT8  jj = 0U;

	UINT8 routeProtectSwitchSum = 0u; 							/*防护道岔数目*/
	RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U };  /*防护道岔数据*/

	UINT16 logSectionSum = 0u; /*逻辑区段数*/
	UINT16* pLogIdBuff = NULL;
	/*获取进路包含逻辑区段信息*/
	logSectionSum = GetHalfRouteLockLgcSecSum(routeId);
	pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(routeId);
	routeProtectSwitchSum = GetRouteHalfProSwData(routeId, routeProtectSwitchStru);      /*获取防护道岔数据*/

	if (NULL != pLogIdBuff)
	{
		/*遍历进路内道岔*/
		for (ii = 0u; ii < logSectionSum; ii++)
		{
			lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]);
			pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]);
			if ((NULL!= pLgcSecSwitchData)
				&&(lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX))
			{
				for (jj = 0u; jj < lgcSecSwitchSum; jj++)
				{
					switchId = pLgcSecSwitchData[jj].SwitchId;
					/*设置该道岔期望驱动位置为无效*/
					retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_DRIVE_POS_INVALID);

					if (CI_SUCCESS == retValOfSetSwiDanCaoPos)
					{

					}
					else
					{/*设置失败*/
					 /*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
					}
				}
			}
		}
	}

	if (NULL != routeProtectSwitchStru)
	{
		/*遍历进路防护道岔*/
		for (ii = 0u; ii < routeProtectSwitchSum; ii++)
		{
			switchId = routeProtectSwitchStru[ii].ProtectSwitchId;
			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_DRIVE_POS_INVALID);

			if (CI_SUCCESS == retValOfSetSwiDanCaoPos)
			{

			}
			else
			{/*设置失败*/
			 /*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
			}
		}
	}

}

/*
*功能描述:清除逻辑进路关联道岔期望驱动位置
*输入参数: const UINT16 routeId 进路ID
*输出参数:无.
*返回值:无
*/
void ClearLogRouteSwitchDrivePos(const UINT16 logRouteId)
{
	UINT8 	retValOfSetSwiExpDrvPos = CI_ERROR;				/*设置道岔期望驱动位置的返回值*/
	UINT16 	switchId = 0u; 									/*道岔ID*/
	UINT8   lgcSecSwitchSum = 0U;							/*逻辑区段关联道岔数量*/
	LogsecSwitchStruct* pLgcSecSwitchData = NULL;
	UINT8 	ii = 0u;											/*循环变量*/
	UINT8  jj = 0U;

	UINT8 routeProtectSwitchSum = 0u; 							/*防护道岔数目*/
	RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U };  /*防护道岔数据*/

	UINT16 logSectionSum = 0u; /*逻辑区段数*/
	UINT16* pLogIdBuff = NULL;
	/*获取进路包含逻辑区段信息*/
	logSectionSum = GetLogicalRouteInLogSecSum(logRouteId);
	pLogIdBuff = GetLogicalRouteInLogSecId(logRouteId);
	routeProtectSwitchSum = GetLogRouteProSwData(logRouteId, routeProtectSwitchStru);      /*获取防护道岔数据*/

	if (NULL != pLogIdBuff)
	{
		for (ii = 0u; ii < logSectionSum; ii++)
		{
			lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]);
			pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]);
			if (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX)
			{
				for (jj = 0u; jj < lgcSecSwitchSum; jj++)
				{
					switchId = pLgcSecSwitchData[jj].SwitchId;
					/*设置该道岔期望驱动位置为无效*/
					retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);

					if (CI_SUCCESS == retValOfSetSwiExpDrvPos)
					{

					}
					else
					{/*设置失败*/
					 /*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
					}
				}
			}
		}
	}

	if (NULL != routeProtectSwitchStru)
	{
		for (ii = 0u; ii < routeProtectSwitchSum; ii++)
		{
			switchId = routeProtectSwitchStru[ii].ProtectSwitchId;
			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);

			if (CI_SUCCESS == retValOfSetSwiExpDrvPos)
			{

			}
			else
			{/*设置失败*/
			 /*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
			}
		}
	}

}

/*
*功能描述:清除逻辑进路关联道岔单操驱动位置
*输入参数: const UINT16 routeId 进路ID
*输出参数:无.
*返回值:无
*/
void ClearLogRouteSwitchDanCaoPos(const UINT16 logRouteId)
{
	UINT8 	retValOfSetSwiDanCaoPos = CI_ERROR;				/*设置道岔单操位置的返回值*/
	UINT16 	switchId = 0u; 									/*道岔ID*/
	UINT8   lgcSecSwitchSum = 0U;							/*逻辑区段关联道岔数量*/
	LogsecSwitchStruct* pLgcSecSwitchData = NULL;
	UINT8 	ii = 0u;											/*循环变量*/
	UINT8  jj = 0U;

	UINT8 routeProtectSwitchSum = 0u; 							/*防护道岔数目*/
	RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U };  /*防护道岔数据*/

	UINT16 logSectionSum = 0u; /*逻辑区段数*/
	UINT16* pLogIdBuff = NULL;
	/*获取进路包含逻辑区段信息*/
	logSectionSum = GetLogicalRouteInLogSecSum(logRouteId);
	pLogIdBuff = GetLogicalRouteInLogSecId(logRouteId);
	routeProtectSwitchSum = GetLogRouteProSwData(logRouteId, routeProtectSwitchStru);      /*获取防护道岔数据*/

	if (NULL != pLogIdBuff)
	{
		/*遍历进路内道岔*/
		for (ii = 0u; ii < logSectionSum; ii++)
		{
			lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]);
			pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]);
			if ((NULL != pLgcSecSwitchData)
				&& (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX))
			{
				for (jj = 0u; jj < lgcSecSwitchSum; jj++)
				{
					switchId = pLgcSecSwitchData[jj].SwitchId;
					/*设置该道岔期望驱动位置为无效*/
					retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_DRIVE_POS_INVALID);

					if (CI_SUCCESS == retValOfSetSwiDanCaoPos)
					{

					}
					else
					{/*设置失败*/
					 /*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
					}
				}
			}
		}
	}

	if (NULL != routeProtectSwitchStru)
	{
		/*遍历进路防护道岔*/
		for (ii = 0u; ii < routeProtectSwitchSum; ii++)
		{
			switchId = routeProtectSwitchStru[ii].ProtectSwitchId;
			/*设置该道岔期望驱动位置为无效*/
			retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_DRIVE_POS_INVALID);

			if (CI_SUCCESS == retValOfSetSwiDanCaoPos)
			{

			}
			else
			{/*设置失败*/
			 /*某一个道岔清除期望驱动位置失败但仍然清除其他道岔的期望驱动位置*/
			}
		}
	}

}
/*
* 功能描述： 设置物理区段包含的全部逻辑区段锁闭状态
* 参数说明： const UINT16 phyId 物理区段ID, const UINT8 lockState  锁闭状态
*	返回值：1：是
*         0: 否
*/
void SetPhyIncAllLogLockState(const UINT16 phyId, const UINT8 lockState)
{
	/*变量初始化*/
	UINT16 i = 0U;
	UINT16 j = 0U;
	UINT8 chAlexSum = 0U;
	UINT16* pAxisIdBuf = NULL;
	UINT8 chLogSectionSum = 0U;
	UINT16* pLogIdBuf = NULL;
	UINT16 wLogBelongRoute = 0U;
	UINT8 chRouteDir = 0U;
	UINT16 logBelongRoute = 0U;

	/*获取物理区段信息*/
	chAlexSum = GetPAxisSectionSum(phyId);
	pAxisIdBuf = GetPAxisSectionIdBuf(phyId);

	/*计轴区段信息正确*/
	if (0u < chAlexSum)
	{
		for (i = 0u; i < chAlexSum; i++)
		{
			/*获取逻辑区段信息*/
			chLogSectionSum = GetAxisSecLogSectionSum(pAxisIdBuf[i]);
			pLogIdBuf = GetAxisSecLogSectionIdBuf(pAxisIdBuf[i]);
			/*逻辑区段信息正确*/
			if ((0u < chLogSectionSum) && (NULL != pLogIdBuf))
			{
				for (j = 0u; j < chLogSectionSum; j++)
				{
					/*获取逻辑区段锁闭所属进路*/
					logBelongRoute = GetLogSecLockBelongRoute(pLogIdBuf[j]);
					chRouteDir = GetRouteDirection(wLogBelongRoute);
					/*设置对应的逻辑区段锁闭状态*/
					SetLogSecLockState(pLogIdBuf[j], lockState, logBelongRoute, chRouteDir);
				}
			}
			else
			{
				/*无操作*/
			}
		}
	}
	else
	{
	}
}

/*
功能描述: 	进路部分锁闭驱动道岔处理
输入参数:	const UINT16 routeId 进路ID
输出参数:	无
返回值:		CI_SUCCESS,如果道岔锁闭处理成功
CI_ERROR,如果道岔锁闭处理失败
*/
UINT8 RouteLockHalfDriveSwitch(const UINT16 routeId)
{
	UINT8 ii = 0u;
	UINT8 jj = 0U;
	UINT16 switchId = 0u;
	UINT8 switchExpPosition = SWITCH_POSITION_INVALID;			/*道岔期望位置*/
	UINT8 switchDancaoPosition = SWITCH_POSITION_INVALID; 		/*单操有效位置*/
	UINT8 innerSwitchRetVal = CI_ERROR;							/*检查进路内道岔是否可被驱动的结果*/
	UINT8 routeProtectSwitchSum = 0u; 							/*防护道岔数目*/
	RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U };  /*防护道岔数据*/
	UINT8   lgcSecSwitchSum = 0U;							/*逻辑区段关联道岔数量*/
	LogsecSwitchStruct *pLgcSecSwitchData = NULL;
	UINT16 logSectionSum = 0u; /*逻辑区段数*/
	UINT16* pLogIdBuff = NULL;
	/*获取进路包含逻辑区段信息*/
	logSectionSum = GetHalfRouteLockLgcSecSum(routeId);
	pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(routeId);
	routeProtectSwitchSum = GetRouteHalfProSwData(routeId, routeProtectSwitchStru);      /*获取防护道岔数据*/
	if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)||(0U==logSectionSum))
	{
		innerSwitchRetVal = CI_ERROR;
	}
	else
	{
		innerSwitchRetVal = CI_SUCCESS;

		if (NULL != pLogIdBuff)
		{
			for (ii = 0u; ii < logSectionSum; ii++)
			{
				lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]);
				pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]);
				if ((NULL != pLgcSecSwitchData)
					&& (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX))
				{
					for (jj = 0u; jj < lgcSecSwitchSum; jj++)
					{
						switchId = pLgcSecSwitchData[jj].SwitchId;
						switchExpPosition = pLgcSecSwitchData[jj].SwitchPosition;
						switchDancaoPosition = GetSwitchDanCaoPostition(switchId);

						if ((SWITCH_POSITION_INVALID == switchDancaoPosition)
							||
							(switchDancaoPosition == switchExpPosition))
						{/*单操无效 或者 单操位置与动作位置一样*/
							innerSwitchRetVal = CI_SUCCESS;
						}
						else
						{
							/*单操到相反位置取消进路*/
							innerSwitchRetVal = CI_ERROR;
							break;
						}
					}
				}
				else
				{
					innerSwitchRetVal = CI_ERROR;
				}
				if (CI_SUCCESS != innerSwitchRetVal)
				{
					break;
				}
			}
		}
		else
		{
			innerSwitchRetVal = CI_ERROR;
		}
		if (CI_SUCCESS == innerSwitchRetVal)
		{
			
			/* 单操相反位置取消进路检查 */
			for (ii = 0u; ii < routeProtectSwitchSum; ii++)
			{
				switchId = routeProtectSwitchStru[ii].ProtectSwitchId;
				switchExpPosition = routeProtectSwitchStru[ii].ProtectPosition;
				switchDancaoPosition = GetSwitchDanCaoPostition(switchId);

				if ((SWITCH_POSITION_INVALID == switchDancaoPosition)
					||
					(switchDancaoPosition == switchExpPosition))
				{/*单操无效 或者 单操位置与动作位置一样*/
					innerSwitchRetVal = CI_SUCCESS;
				}
				else
				{
					/*单操到相反位置取消进路*/
					innerSwitchRetVal = CI_ERROR;
					break;
				}
			}
		}
		else
		{
			innerSwitchRetVal = CI_ERROR;
		}


		if (CI_SUCCESS == innerSwitchRetVal)
		{
			/*驱动进路道岔*/
			RouteHalfDrvInnerSwitch(routeId, SWITCH_NEED_DRIV_TRUE);
		}
		else
		{
			RouteHalfDrvInnerSwitch(routeId, SWITCH_NEED_DRIV_FALSE);
		}

	}

	return innerSwitchRetVal;
}

/*
功能描述: 	驱动进路部分锁闭道岔处理
输入参数 : const UINT16 routeId 进路ID
输出参数 : const UINT8 DrivFlag 道岔驱动标志
返回值 : 无
*/
void RouteHalfDrvInnerSwitch(const UINT16 routeId, const UINT8 DrivFlag)
{
	UINT8 ii = 0u;
	UINT8 jj = 0U;
	UINT8 funRtn = 0U;
	UINT16 switchId = 0u;
	UINT8 switchExpPos = SWITCH_POSITION_INVALID;			/*道岔期望位置*/
	UINT8 routeProtectSwitchSum = 0u; 							/*防护道岔数目*/
	RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U };  /*防护道岔数据*/
	UINT8   lgcSecSwitchSum = 0U;							/*逻辑区段关联道岔数量*/
	LogsecSwitchStruct *pLgcSecSwitchData = NULL;
	UINT16 logSectionSum = 0u; /*逻辑区段数*/
	UINT16* pLogIdBuff = NULL;
	/*获取进路包含逻辑区段信息*/
	logSectionSum = GetHalfRouteLockLgcSecSum(routeId);
	pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(routeId);
	routeProtectSwitchSum = GetRouteHalfProSwData(routeId, routeProtectSwitchStru);      /*获取防护道岔数据*/

	if (SWITCH_NEED_DRIV_TRUE == DrivFlag)
	{/*需要驱动进路内道岔*/
		if (NULL != pLogIdBuff)
		{
			for (ii = 0u; ii < logSectionSum; ii++)
			{
				lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]);
				pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]);
				if ((NULL != pLgcSecSwitchData)
					&& (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX))
				{
					for (jj = 0u; jj < lgcSecSwitchSum; jj++)
					{
						switchId = pLgcSecSwitchData[jj].SwitchId;
						switchExpPos = pLgcSecSwitchData[jj].SwitchPosition;
						funRtn = SwitchDriveProcess(switchId, switchExpPos); /*设置进路内道岔的驱动状态为驱动中*/
					}
				}
			}

			for (ii = 0u; ii < routeProtectSwitchSum; ii++)
			{
				switchId = routeProtectSwitchStru[ii].ProtectSwitchId;
				switchExpPos = routeProtectSwitchStru[ii].ProtectPosition;
				funRtn = SwitchDriveProcess(switchId, switchExpPos); /*设置进路关联防护道岔的驱动状态为驱动中*/
			}
		}
		
	}
}

/*
功能描述: 	引导总锁下重开引导信号处理
输入参数 : const UINT16 signalId 信号机ID
输出参数 : const UINT8 yLockState 引导总锁状态
返回值 : 无
*/
void LeadzLockOpenSignal(const UINT16 signalId, const UINT8 yLockState)
{
	UINT16 starSigRouteSum = 0u;    /*以相同信号机为始端的进路数目*/
	UINT16* starSigRouteBuf = NULL;  /*以相同信号机为始端的进路ID数组*/
	UINT8 signalYLockOpenState = 0u;
	UINT16 jj = 0u;               /*循环索引*/
	UINT16 routeId = 0u;/*进路ID临时变量*/
	UINT8 routeCiId = 0u;/*进路所属CI临时变量*/
	UINT8 driveColor = 0u;		/*驱动信号开放颜色*/
	UINT8 localCiId = GetSystemParaLocalCiId();         /*本地联锁ID*/
	UINT16 autoRouteState = 0U; /*进路自动进路状态*/
	UINT16 autoReturnState = 0U;/*自动折返状态*/
	UINT16 allAutoRoute =0U;/*全自动折返ID*/

	signalYLockOpenState = GetSignalYLockOpenState(signalId);
	if ((SIGNAL_OPEN == signalYLockOpenState) && (CI_ALL_SWITCH_YLOCK_YES == yLockState))
	{/*修改日期：2017年12月27日。修改原因：越南线车辆段引导信号开放红白灯*/
		if ((SIGNAL_SHOWCOLOUR_RED == GetSignalCurColor(signalId))
			|| (SIGNAL_SHOWCOLOUR_REDYELLOW == GetSignalCurColor(signalId))
			|| (SIGNAL_SHOWCOLOUR_RED_WHITE == GetSignalCurColor(signalId)))
		{
			starSigRouteSum = GetStartSignalRouteSum(signalId);
			starSigRouteBuf = GetStartSignalRouteBuf(signalId);

			if ((NULL != starSigRouteBuf) && (starSigRouteSum != 0u))
			{/*获取所有满足道岔条件的进路ID*/
				for (jj = 0u; jj < starSigRouteSum; jj++)
				{
					routeId = 0u;	     /*进路ID*/
					routeCiId = 0u;       /*进路所属联锁ID*/
					driveColor = 0u;	     /*驱动信号开放颜色*/
					routeId = starSigRouteBuf[jj];

					if ((0u < routeId) && (ROUTE_SUM_MAX > routeId))
					{
						routeCiId = GetRouteBelongCiId(routeId);   /*获取进路所属联锁ID*/

						if ((routeCiId == localCiId) && (0u != localCiId))
						{
							/*开放已设置开放的引导信号*/
							driveColor = GetRouteLeadSignalOpenColor(routeId);/*引导进路开放颜色*/
							if (SIGNAL_SHOWCOLOUR_RED_WHITE == driveColor)
							{/*若信号机类型为进段带引导调车信号机，则开放红白灯*/
								SetSignalCurDriveColor(signalId, SIGNAL_SHOWCOLOUR_RED_WHITE);
							}
							else if (SIGNAL_SHOWCOLOUR_REDYELLOW == driveColor)
							{/*红黄灯带引导功能的信号机开放红黄灯*/
								SetSignalCurDriveColor(signalId, SIGNAL_SHOWCOLOUR_REDYELLOW);
							}
							else
							{
								/*其他带引导功能的信号机或配置其他颜色的不驱*/
							}
							SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO);  /*设置进路信号重开标志无效*/
							/*设置进路自动进路无效*/
							autoRouteState =GetRouteAutoRouteId(routeId); /*获取进路自动进路状态*/
							autoReturnState = GetRouteAutoReturnId(routeId);/*获取自动折返状态*/
							allAutoRoute = GetRouteAllAutoReturnId(routeId);/*获取全自动折返ID*/
							SetAutoRouteSetFlag(autoRouteState , AUTO_ROUTE_SET_NO);
							SetAutoReturnSetFlag(autoReturnState, AUTO_RETURN_SET_NO);
							SetAllAutoReturnSetFlag(allAutoRoute , ALL_AUTO_RETURN_SET_NO);
							if (ROUTE_TYPE_AUTO_TRIGGER == GetAutoTriggerType(routeId))
							{/*虚拟联锁兼容*/
								SetRouteAutoTriggerFlag(routeId, AUTO_TRIGGER_SET_NO);
							}
						}
					}
				}
			}
		}
		else
		{
			SetSignalYLockOpenState(signalId, SIGNAL_CLOSE);
		}
	}
	else
	{
		/*不处理*/
	}
}

/*
功能描述: 	引导总锁下重开引导信号新功能处理
输入参数 : const UINT16 signalId 信号机ID
输出参数 : const UINT8 yLockState 引导总锁状态
返回值 : 无
*/
void LeadzLockNewOpenManage(const UINT16 signalId, const UINT8 yLockState)
{
	UINT8 wSignalLeadRouteCbtcFlag = 0U;		/*信号机包含的进路是否具有两种引导属性，CBTC和非CBTC*/
	UINT8 wLeadCheckFlag = 0U;		/*引导总锁检查标志*/
	UINT8 signalYLockOpenState = 0u;
	/*函数故障码*/
	UINT8 const functionId = EFUNC_SIGNAL_LEAD_OPEN_LOCK;
	/*故障发送级别*/
	UINT8 sendLevel = ESEND_LEVEL_ATS;


	/*需要区分CBTC场段区域的进路和非CBTC场段区域的进路，非成都区域，引导属性都配置为0xaa（不检查引导总锁），成都四线：正线和CBTC场段都配置为0xbb（需要检查引导总锁），非CBTC场段不检查引导总锁0xaa*/
	wSignalLeadRouteCbtcFlag = GetSignalLeadRouteCbtcFlag(signalId);
	switch (wSignalLeadRouteCbtcFlag)
	{
	case SIGNAL_LEADROUTE_ALLCBTC:
		/*非场段检查引导总锁，不重开引导信号，既有重开；逻辑不走了*/
		wLeadCheckFlag = 1U;
		break;
	case SIGNAL_LEADROUTE_ALL_NO_CBTC:
		LeadzLockOpenSignal(signalId, yLockState);			/*全部信号机所属的进路都在非CBTC区域，直接走原逻辑，重开引导信号*/
		break;
	case SIGNAL_LEADROUTE_CBTC_ANDNO:
		LeadzLockSignalOpenRouteCheck(signalId, yLockState);
		break;
	default:
		/*非引导进路无需处理*/
		break;
	}

	if (1U == wLeadCheckFlag)
	{
		/*出清重开引导信号标志*/
		signalYLockOpenState = GetSignalYLockOpenState(signalId);
		if ((SIGNAL_OPEN == signalYLockOpenState) && (CI_ALL_SWITCH_YLOCK_YES == yLockState))
		{
			SetSignalYLockOpenState(signalId, SIGNAL_CLOSE);
			/* 记录故障码 */
			SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, signalId, ETYPE_SIG_LEAD_ALL_LOCK, CI_ERROR, sendLevel);
		}
	}
	else
	{
		;	/*不处理*/
	}
}


/*
功能描述: 	场段，既有CBTC区域又有非CBTC区域，检查进路空闲，处理引导信号重开
输入参数 : const UINT16 signalId 信号机ID
输出参数 : const UINT8 yLockState 引导总锁状态
返回值 : 无
*/
void LeadzLockSignalOpenRouteCheck(const UINT16 signalId, const UINT8 yLockState)
{
	/*函数故障码*/
	UINT8 const functionId = EFUNC_LeadzLockSignalOpenRouteCheck;
	UINT16 starSigRouteSum = 0u;    /*以相同信号机为始端的进路数目*/
	UINT16* starSigRouteBuf = NULL;  /*以相同信号机为始端的进路ID数组*/
	UINT16 jj = 0u;               /*循环索引*/
	UINT16 routeId = 0u;/*进路ID临时变量*/
	UINT8 routeState = 0U;
	UINT8 signalYLockOpenState = 0u;


	signalYLockOpenState = GetSignalYLockOpenState(signalId);
	if ((SIGNAL_OPEN == signalYLockOpenState) && (CI_ALL_SWITCH_YLOCK_YES == yLockState))
	{
		starSigRouteSum = GetStartSignalRouteSum(signalId);
		starSigRouteBuf = GetStartSignalRouteBuf(signalId);
		if ((NULL != starSigRouteBuf) && (starSigRouteSum != 0u))
		{/*查所有进路是否都为空闲，空闲才能给重开，若出现信号机包含的进路有锁闭的，则不给重开，同时给ATS报警*/
			for (jj = 0u; jj < starSigRouteSum; jj++)
			{
				routeId = 0u;	     /*进路ID*/
				routeId = starSigRouteBuf[jj];
				routeState = GetRouteState(routeId);

				if (ROUTE_STATE_IDLE != routeState)
				{
					break;
				}
				else
				{
					;	/*继续查询下一进路的状态*/
				}
			}

			if (jj == starSigRouteSum)
			{
				LeadzLockOpenSignal(signalId, yLockState);			/*全部信号机所属的进路都空闲，则执行重开引导信号逻辑*/
			}
			else
			{
				SetSignalYLockOpenState(signalId, SIGNAL_CLOSE);
				/* 记录故障码,向ATS上报有进路不是空闲 */
				SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, routeState, ESEND_LEVEL_ATS);
			}
		}
	}
	else
	{
		;	/*不处理*/
	}
}

/*
* 功能描述： 进路是否有逻辑区段属于其它联锁
* 参数说明： UINT16 routeId 进路号
*			 , UINT8 *pOtherCiId 其它联锁ID
*	返回值：1：执行成功
*         0: 执行失败
* by cgh 20231007
*/
UINT8 RouteHaveLogSecBelongOtherCi(const UINT16 routeId, UINT8* pOtherCiId)
{
	UINT16 chRouteLogSecSum = 0U; /*进路逻辑区段总数*/
	UINT16* pRouteLogSecId = NULL; /*进路逻辑区段数据*/
	UINT16 ii = 0U;
	UINT8 chRouteBelongCi = 0U;/*进路所属联锁*/
	UINT8 chLogSecBelongCi = 0U;/*逻辑区段所属联锁*/
	UINT8 reVal = CI_ERROR;

	chRouteLogSecSum = GetRouteLogSectionSum(routeId); /*获得进路包含的区段数目*/
	pRouteLogSecId = GetRouteLogSectionIdBuf(routeId);/*获取进路逻辑区段数据*/
	chRouteBelongCi = GetRouteBelongCiId(routeId);

	if ((NULL == pRouteLogSecId) || (NULL == pOtherCiId))
	{
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;

		for (ii = 0u; ii < chRouteLogSecSum; ii++)
		{
			chLogSecBelongCi = GetLogSecBelongCiId(pRouteLogSecId[ii]);
			if (chRouteBelongCi != chLogSecBelongCi)
			{
				*pOtherCiId = chLogSecBelongCi;
				break;
			}
		}
	}
	return reVal;
}

/*
* 功能描述： 检查进路属于本联锁的逻辑区段已解锁
* 参数说明： UINT16 routeId 进路号
*	返回值：1：是
*         0: 否
* by cgh 20231007
*/
UINT8 CheckLocalCiRouteLogSecUnLock(const UINT16 routeId)
{
	UINT16 chRouteLogSecSum = 0U; /*进路逻辑区段总数*/
	UINT16* pRouteLogSecId = NULL; /*进路逻辑区段数据*/
	UINT16 ii = 0U;
	UINT8 chRouteBelongCi = 0U;/*进路所属联锁*/
	UINT8 chLogSecBelongCi = 0U;/*逻辑区段所属联锁*/
	UINT8 reVal = CI_ERROR;
	UINT8 chLocalCiId = 0U;/*本地联锁ID*/
	UINT8 chLogSecLockState = 0U;/*逻辑区段锁闭状态*/
	UINT16 wLogSecLockBelongRoute = 0U;/*逻辑区段锁闭所属进路*/

	chLocalCiId = GetSystemParaLocalCiId();
	chRouteLogSecSum = GetRouteLogSectionSum(routeId); /*获得进路包含的区段数目*/
	pRouteLogSecId = GetRouteLogSectionIdBuf(routeId);/*获取进路逻辑区段数据*/

	if (NULL == pRouteLogSecId)
	{
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
		for (ii = 0u; ii < chRouteLogSecSum; ii++)
		{
			chLogSecLockState = GetLogSecLockState(pRouteLogSecId[ii]);
			wLogSecLockBelongRoute = GetLogSecLockBelongRoute(pRouteLogSecId[ii]);
			chLogSecBelongCi = GetLogSecBelongCiId(pRouteLogSecId[ii]);
			chRouteBelongCi = GetRouteBelongCiId(routeId);

			if ((chLogSecBelongCi == chRouteBelongCi) && (chLocalCiId == chLogSecBelongCi))
			{/*属于本联锁的才作检查,未锁闭或被锁闭的不是本进路*/
				if (((LOG_SECTION_LOCK_NO == chLogSecLockState) ||
					((LOG_SECTION_LOCK_NO != chLogSecLockState) && (routeId != wLogSecLockBelongRoute))))
				{ /*未锁闭或非本进路锁闭*/
				}
				else
				{
					reVal = CI_ERROR;
					break;
				}
			}
		}
	}
	return reVal;
}

/*
* 功能描述： 继电接口下检查非本联锁的进路内，属于本联锁的逻辑区段是否都已解锁
* 参数说明： UINT16 routeId 进路号
*	返回值：1：是
*         0: 否
* by cgh 20231007
*/
UINT8 CheckRouteLogSecUnLock(const UINT16 routeId)
{
	UINT16 chRouteLogSecSum = 0U; /*逻辑区段总数*/
	UINT16* pRouteLogSecId = NULL; /*逻辑区段数据*/
	UINT16 ii = 0U;
	UINT8 reVal = CI_ERROR;
	UINT8 chRouteBelongCi = 0U;/*进路所属联锁*/
	UINT8 chLocalCi = 0U;/*本地联锁ID*/
	UINT8 chLogSecBelongCi = 0U;/*逻辑区段所属联锁*/
	UINT8 chLogLockState = 0u;/*逻辑区段锁闭状态*/
	UINT8 chCommState = 0u;/*通信状态*/
	UINT32 dwCurCycle = 0u;/*当前周期号*/
	UINT8 chFuncSwitch = 0U;/*相邻联锁是否支持继电接口*/
	UINT8 chConfirmRelayInterfaceFlag = 0U;/*继电接口确认状态*/

	chFuncSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI);
	chConfirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*继电接口确认状态*/
	chRouteLogSecSum = GetRouteLogSectionSum(routeId); /*获得进路包含的区段数目*/
	pRouteLogSecId = GetRouteLogSectionIdBuf(routeId);/*获取进路逻辑区段数据*/
	chRouteBelongCi = GetRouteBelongCiId(routeId);/*进路所属联锁ID*/
	chLocalCi = GetSystemParaLocalCiId();/*本机联锁ID*/

	if (NULL == pRouteLogSecId)
	{
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
		chCommState = GetLocalCiAndOtherCiTransSta(chRouteBelongCi);/*本联锁与其它联锁通信通信状态*/
		/*进路不属于本联锁，但进路属于本联锁的区段都已解锁*/
		if ((chLocalCi != chRouteBelongCi) && (TRANSMIT_STATE_BAD == chCommState) &&
			(CICI_RELAY_INTERFACE_CONFIRM_YES == chConfirmRelayInterfaceFlag) &&
			(FUNC_SWITCH_ON == chFuncSwitch))
		{
			for (ii = 0u; ii < chRouteLogSecSum; ii++)
			{
				chLogSecBelongCi = GetLogSecBelongCiId(pRouteLogSecId[ii]);
				chLogLockState = GetLogSecLockState(pRouteLogSecId[ii]);
				dwCurCycle = Get2oo2CurCycleNum();
				if (chLocalCi == chLogSecBelongCi)
				{ /*物理区段属于本联锁，且物理区段未锁闭*/
					if (LOG_SECTION_LOCK_NO == chLogLockState)
					{
					}
					else
					{
						debug_infor_printf((const)"CheckNo, pRouteLogSecId:%d chLogLockState:%d   curCycle:%d\n",
							pRouteLogSecId[ii], chLogLockState, dwCurCycle);
						reVal = CI_ERROR;
						break;
					}
				}
			}
		}
	}
	return reVal;
}

/*
* 功能描述： 找到逻辑进路内第一个正常逻辑锁闭的逻辑区段
* 参数说明： const UINT16 wLogRouteId 逻辑进路ID
* 返回值  ： = 0 无效
*            > 0 逻辑区段ID
* by cgh 20231012
*/
UINT16 GetLogRouteFirNormalLockLogId(const UINT16 wLogRouteId)
{
	UINT16 wLogRouteLogSecNum = 0U;/*逻辑进路包含的逻辑区段数量*/
	UINT16* pLogRouteLogSecIdBuf = NULL;/*逻辑进路包含的逻辑区段ID*/
	UINT16 ii = 0U;
	UINT16 wReVal = CI_ERROR;
	UINT8 chCheckFlag = 0U;/*检查标志*/
	UINT8 chLogSecLogLockSta = 0U;/*逻辑区段逻辑锁闭状态*/

	if (ROUTE_LOGICAL_SUM_MAX > wLogRouteId)
	{
		/*获取逻辑进路逻辑区段数据*/
		wLogRouteLogSecNum = GetLogicalRouteInLogSecSum(wLogRouteId);
		pLogRouteLogSecIdBuf = GetLogicalRouteInLogSecId(wLogRouteId);

		if (NULL != pLogRouteLogSecIdBuf)
		{
			for (ii = 0U; ii < wLogRouteLogSecNum; ii++)
			{
				chCheckFlag = CheckLogSecLockBelLogRoute(pLogRouteLogSecIdBuf[ii], wLogRouteId);
				if (CI_SUCCESS == chCheckFlag)
				{
					chLogSecLogLockSta = GetLogSecLogLockState(pLogRouteLogSecIdBuf[ii]);

					if (LOG_SECTION_LOGLOCK_NORMAL == chLogSecLogLockSta)
					{
						wReVal = pLogRouteLogSecIdBuf[ii];
						break;
					}
					else
					{
						; /*继续查找*/
					}
				}
				else
				{
					;/*继续查找下一个*/
				}
			}
		}
		else
		{
			; /*不执行*/
		}
	}
	else
	{
		; /*不执行*/
	}


	return wReVal;

}

/*
* 功能描述： 检查逻辑区段是否被指定逻辑进路锁闭
* 参数说明： const UINT16 wLogSection 逻辑区段ID
			 const UINT16 wLogRouteId 逻辑进路ID
* 返回值  ： CI_ERROR  否
*			 CI_SUCCESS 是
* by cgh 20231012
*/
UINT8 CheckLogSecLockBelLogRoute(const UINT16 wLogSection,const UINT16 wLogRouteId)
{
	UINT8 chLogSecLockBelLogRouteSum = 0U;/*逻辑区段锁闭所属逻辑进路数量*/
	LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*逻辑区段锁闭所属逻辑进路数据*/
	UINT16 wLogSecLockBelLogRouteId = 0U;/*逻辑区段锁闭所属逻辑进路ID*/
	UINT8 ii = 0U;
	UINT8 wReVal = CI_ERROR;

	if ((ROUTE_LOGICAL_SUM_MAX > wLogRouteId) && (LOGIC_SECTION_SUM_MAX > wLogSection))
	{
		/*获取逻辑区段锁闭所属逻辑进路数据*/
		chLogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogSection);
		szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogSection);

		if (NULL != szLogSecLockBelLogRouteData)
		{
			for (ii = 0U; ii < chLogSecLockBelLogRouteSum; ii++)
			{
				wLogSecLockBelLogRouteId = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId;
				if (wLogRouteId == wLogSecLockBelLogRouteId)
				{
					wReVal = CI_SUCCESS;
					break;
				}
			}
		}
		else
		{
			; /*不执行*/
		}
	}
	else
	{
		; /*不执行*/
	}
	return wReVal;
}

/*
* 功能描述： 设置物理区段包含的逻辑区段逻辑锁闭状态
* 参数说明： const UINT16 wPhySecId, 物理区段ID
			 const UINT8 chLockState, 逻辑锁闭状态
			 const UINT16 wLogRouteId  逻辑进路ID
*	返回值：无
* by cgh 20231013
*/
void SetPhyIncLogSecLogLockState(const UINT16 wPhySecId, const UINT8 chLockState, const UINT16 wLogRouteId)
{
	/*变量初始化*/
	UINT8 ii = 0U;
	UINT16 jj = 0U;
	UINT8 chAxisSum = 0U;/*计轴区段数目*/
	UINT16* pAxisIdBuf = NULL;/*计轴区段ID*/
	UINT8 chLogSectionSum = 0U;/*逻辑区段数目*/
	UINT16* pLogSecIdBuf = NULL;/*逻辑区段ID*/
	UINT8 chCheckFlag = 0U;/*检查标志*/
	UINT8 chLogLockDir = 0U;/*逻辑锁闭方向*/
	
	/*获取物理区段信息*/
	chAxisSum = GetPAxisSectionSum(wPhySecId);
	pAxisIdBuf = GetPAxisSectionIdBuf(wPhySecId);

	/*计轴区段信息正确*/
	if (0U < chAxisSum)
	{
		for (ii = 0U; ii < chAxisSum; ii++)
		{
			/*获取逻辑区段信息*/
			chLogSectionSum = GetAxisSecLogSectionSum(pAxisIdBuf[ii]);
			pLogSecIdBuf = GetAxisSecLogSectionIdBuf(pAxisIdBuf[ii]);
			/*逻辑区段信息正确*/
			if ((0U < chLogSectionSum) && (NULL != pLogSecIdBuf))
			{
				for (jj = 0U; jj < chLogSectionSum; jj++)
				{
					chCheckFlag = CheckLogSecLockBelLogRoute(pLogSecIdBuf[jj], wLogRouteId);

					if (CI_SUCCESS == chCheckFlag)
					{
						chLogLockDir = GetLogSecLogLockDir(pLogSecIdBuf[jj]);
						SetLogSecLogLockState(pLogSecIdBuf[jj], chLockState, chLogLockDir);
					}
				}
			}
			else
			{
				/*无操作*/
			}
		}
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述： 获取逻辑区段被逻辑进路锁闭的逻辑进路方向
* 参数说明： const UINT16 wLogSection 逻辑区段ID
			 const UINT16 wLogRouteId 逻辑进路ID
* 返回值  ： 逻辑进路方向
* by cgh 20231013
*/
UINT8 GetLogSecLogLockBelRouteDir(const UINT16 wLogSection, const UINT16 wLogRouteId)
{
	UINT8 chLogSecLockBelLogRouteSum = 0U;/*逻辑区段锁闭所属逻辑进路数量*/
	LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*逻辑区段锁闭所属逻辑进路数据*/
	UINT16 wLogSecLockBelLogRouteId = 0U;/*逻辑区段锁闭所属逻辑进路ID*/
	UINT8 ii = 0U;
	UINT8 wReVal = CI_ERROR;

	if ((ROUTE_LOGICAL_SUM_MAX > wLogRouteId) && (LOGIC_SECTION_SUM_MAX > wLogSection))
	{
		/*获取逻辑区段锁闭所属逻辑进路数据*/
		chLogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogRouteId);
		szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogRouteId);

		if (NULL != szLogSecLockBelLogRouteData)
		{
			for (ii = 0U; ii < chLogSecLockBelLogRouteSum; ii++)
			{
				wLogSecLockBelLogRouteId = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId;
				if (wLogRouteId == wLogSecLockBelLogRouteId)
				{
					wReVal = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteDir;
					break;
				}
			}
		}
		else
		{
			; /*不执行*/
		}
	}
	else
	{
		; /*不执行*/
	}
	return wReVal;
}

/*
* 功能描述： 检查逻辑进路逻辑区段已全部解锁
* 参数说明： UINT16 wLogRouteId 逻辑进路号
* 返回值：CI_SUCCESS：是
*           CI_ERROR: 否
* by cgh 20231013
*/
UINT8 CheckLogRouteLogSecHaveUnLock(const UINT16 wLogRouteId)
{
	UINT8 chReVal = CI_ERROR;
	UINT16 wLogRouteInLogSecSum = 0U;/*逻辑进路包含逻辑区段数目*/
	UINT16* szLogRouteInLogSecIdBuf = NULL;/*逻辑进路包含逻辑区段ID数组*/
	UINT16 ii = 0U;
	UINT8 chLogSecLogLockState = 0U;/*逻辑区段逻辑锁闭状态*/

	if ((0U < wLogRouteId) && (ROUTE_LOGICAL_SUM_MAX > wLogRouteId))
	{
		wLogRouteInLogSecSum = GetLogicalRouteInLogSecSum(wLogRouteId);
		szLogRouteInLogSecIdBuf = GetLogicalRouteInLogSecId(wLogRouteId);

		if (NULL != szLogRouteInLogSecIdBuf)
		{
			for (ii = 0U; ii < wLogRouteInLogSecSum; ii++)
			{
				chReVal = CheckLogSecLockBelLogRoute(szLogRouteInLogSecIdBuf[ii], wLogRouteId);

				if (CI_SUCCESS == chReVal)
				{
					chLogSecLogLockState = GetLogSecLogLockState(szLogRouteInLogSecIdBuf[ii]);

					if (LOG_SECTION_LOGLOCK_NO != chLogSecLogLockState)
					{
						/*属于本逻辑进路的逻辑区段但不是未锁闭状态，返回失败*/
						break;
					}
					else
					{
						; /*检查通过，继续判断*/
					}
				}
				else
				{
					; /*不处理*/
				}
			}
			if (wLogRouteInLogSecSum == ii)
			{
				chReVal = CI_SUCCESS;
			}
			else
			{
				chReVal = CI_ERROR;
			}
		}
		else
		{
			; /*不处理*/
		}
	}
	else
	{
		; /*不处理*/
	}

	return chReVal;
}

/*
* 功能描述： 检查物理区段包含的逻辑区段的进路锁闭状态
* 参数说明： const UINT16 wPhySecId 物理区段ID
*            UINT16* pLogSecLockId 锁闭的逻辑区段ID
*			 UINT8* pState 逻辑区段锁闭状态
* 返回值  ： CI_SUCCESS 关联逻辑区段都未锁闭
*			 CI_ERROR 关联逻辑区段存在锁闭
* Created By LQ 2023/10/17
*/
UINT8 CheckPSecIncLSecLockState(const UINT16 wPhySecId, UINT16* pLogSecLockId, UINT8* pState)
{
	UINT8 retVal = CI_ERROR;
	UINT8 i = 0U;
	UINT8 cPhySecIncLogSecSum = 0U;  /*物理区段包含的逻辑区段数量*/
	UINT16* pPhySecIncLogSecId = NULL;  /*物理区段包含的逻辑区段ID*/
	UINT8 cLogSecLockState = 0U;  /*逻辑区段锁闭状态*/	

	if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId) && (NULL != pLogSecLockId) && (NULL != pState))
	{
		/*获取物理区段关联逻辑区段信息*/
		cPhySecIncLogSecSum = GetPhySecIncLogSecSum(wPhySecId);
		pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(wPhySecId);

		if ((0U != cPhySecIncLogSecSum) && (NULL != pPhySecIncLogSecId))
		{
			/*检查逻辑区段锁闭状态*/
			for (i = 0U; i < cPhySecIncLogSecSum; i++)
			{
				cLogSecLockState = GetLogSecLockState(pPhySecIncLogSecId[i]);
				if (LOG_SECTION_LOCK_NO == cLogSecLockState)
				{
					retVal = CI_SUCCESS;  /*逻辑区段未锁闭，返回成功*/
				}
				else
				{					
					*pLogSecLockId = pPhySecIncLogSecId[i];
					*pState = cLogSecLockState;
					retVal = CI_ERROR;  /*存在逻辑区段被进路锁闭，返回失败*/
					break;
				}
			}
		}
		else
		{
			/*获取物理区段包含的逻辑区段失败，返回失败*/
		}
	}
	else
	{
		/*入参非法，返回失败*/
	}
	return(retVal);
}

/*
* 功能描述： 检查物理区段包含的逻辑区段的逻辑进路锁闭状态
* 参数说明： const UINT16 wPhySecId 物理区段ID
*            UINT16* pLogSecLockId 锁闭的逻辑区段ID
*			 UINT8* pState 逻辑区段逻辑锁闭状态
* 返回值  ： CI_SUCCESS 关联逻辑区段都未锁闭
*			 CI_ERROR 关联逻辑区段存在锁闭
* Created By LQ 2023/10/17
*/
UINT8 CheckPSecIncLSecLogicLockState(const UINT16 wPhySecId, UINT16* pLogSecLockId, UINT8* pState)
{
	UINT8 retVal = CI_ERROR;
	UINT8 i = 0U;
	UINT8 cPhySecIncLogSecSum = 0U;  /*物理区段包含的逻辑区段数量*/
	UINT16* pPhySecIncLogSecId = NULL;  /*物理区段包含的逻辑区段ID*/
	UINT8 cLogSecLockState = 0U;  /*逻辑区段逻辑锁闭状态*/
	UINT8 cLockBelongLogicRouteNum = 0U;  /*逻辑区段逻辑锁闭所属逻辑进路数量*/

	if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId) && (NULL != pLogSecLockId) && (NULL != pState))
	{
		/*获取物理区段关联逻辑区段信息*/
		cPhySecIncLogSecSum = GetPhySecIncLogSecSum(wPhySecId);
		pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(wPhySecId);

		if ((0U != cPhySecIncLogSecSum) && (NULL != pPhySecIncLogSecId))
		{
			/*检查逻辑区段锁闭状态*/
			for (i = 0U; i < cPhySecIncLogSecSum; i++)
			{
				cLogSecLockState = GetLogSecLogLockState(pPhySecIncLogSecId[i]);
				cLockBelongLogicRouteNum = GetLogSecLockBelLogRouteSum(pPhySecIncLogSecId[i]);

				if ((LOG_SECTION_LOGLOCK_NO == cLogSecLockState) && (0U == cLockBelongLogicRouteNum))
				{
					retVal = CI_SUCCESS;  /*逻辑区段未逻辑锁闭，返回成功*/
				}
				else
				{					
					*pLogSecLockId = pPhySecIncLogSecId[i];
					*pState = cLogSecLockState;
					retVal = CI_ERROR;  /*存在逻辑区段被逻辑进路锁闭，返回失败*/
					break;
				}
			}
		}
		else
		{
			/*获取物理区段包含的逻辑区段失败，返回失败*/
		}
	}
	else
	{
		/*入参非法，返回失败*/
	}

	return retVal;
}

/*
* 功能描述： 获取指定调车进路开放状态
* 参数说明： const UINT16 wRouteId, 进路ID
* 返回值  ： 0: 获取数据失败
*            1: 进路开放
* by cgh 20231113
*/
UINT8 GetDiaoCheRouteOpenState(const UINT16 wRouteId)
{
	UINT8 retVal = CI_ERROR;
	UINT8 chRouteType = 0U;/*进路类型*/
	UINT8 chRouteState = 0U;/*进路状态*/

	if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId))
	{
		chRouteType = GetRouteType(wRouteId);
		if (ROUTE_TYPE_DIAOCHE == chRouteType)
		{
			chRouteState = GetRouteState(wRouteId);
			if ((ROUTE_STATE_YUXIAN_OPEN == chRouteState)
				|| (ROUTE_STATE_NEAR_OPEN == chRouteState))
			{
				retVal = CI_SUCCESS;
			}
			else
			{
				; /*进路不开放，返回失败*/
			}
		}
		else
		{
			; /*非调车进路返回失败*/
		}
	}
	else
	{
		; /*返回失败*/
	}
	return retVal;
}

/*
* 功能描述：设置本地区间雨雪站台信息
* 参数说明：const UINT8 cAreaSnowNum 区间雨雪数量
*			const AreaSnowInfoStruct pAreaSnowBuf[LOCAL_AREA_SNOW_SUM_MAX] 区间雨雪数组
* 返回值  ：无
*/
void SetLocalAreaSnowInfo(const UINT8 cAreaSnowNum, const AreaSnowInfoStruct pAreaSnowBuf[LOCAL_AREA_SNOW_SUM_MAX])
{
	UINT8 ii = 0U;
	UINT8 jj = 0U;
	UINT16 kk = 0U;
	UINT8 cPlatFormRelSpksNum = 0U;  /*站台关联的SPKS数量*/
	UINT16 szPlatFormRelSpksId[PLATFORM_REL_SPKS_NUM_MAX] = { 0U };  /*站台关联的SPKS ID数组*/
	UINT16 wSpksIndex = 0U;
	UINT16 wSpksRelPhySecNum = 0U;  /*SPKS关联物理区段数量*/
	UINT16 wSpksRelPhySecId = 0U;  /*SPKS关联物理区段ID*/
	UINT8 cPhySecBelongCiId = 0U;  /*SPKS关联物理区段的所属控区*/
	UINT8 cLocalCiId = 0U;  /*本地CI ID*/

	if ((LOCAL_AREA_SNOW_SUM_MAX >= cAreaSnowNum) && (NULL != pAreaSnowBuf))
	{
		/*清除本地区间雨雪站台信息和发送给相邻联锁的区间雨雪信息*/
		ClearCiSendAreaSnowInfo();
		(void)CommonMemSet(szLocalAreaSnow, (UINT32)(sizeof(AreaSnowInfoStruct) * LOCAL_AREA_SNOW_SUM_MAX), 0U, (UINT32)(sizeof(AreaSnowInfoStruct) * LOCAL_AREA_SNOW_SUM_MAX));

		LocalAreaSnowNum = cAreaSnowNum;
		for (ii = 0U; ii < cAreaSnowNum; ii++)
		{
			szLocalAreaSnow[ii] = pAreaSnowBuf[ii];  /*存储本控区的区间雨雪状态信息*/

			/*判断是否需要向相邻联锁发送本控区的区间雨雪信息*/
			cLocalCiId = GetSystemParaLocalCiId();
			cPlatFormRelSpksNum = GetPlatFormRelSpksNum(pAreaSnowBuf[ii].wAreaId, szPlatFormRelSpksId);  /*获取站台关联的SPKS*/

			if (CI_ERROR != cPlatFormRelSpksNum)
			{
				/*遍历所有站台关联的SPKS，判断SPKS是否关联有非本控区的物理区段*/
				for (jj = 0U; jj < cPlatFormRelSpksNum; jj++)
				{
					wSpksIndex = GetSpksConfigBufIndex(szPlatFormRelSpksId[jj]);
					if (SPKS_SUM_MAX > wSpksIndex)
					{
						wSpksRelPhySecNum = GetSpksPhySecSumByIndex(wSpksIndex);

						for (kk = 0U; kk < wSpksRelPhySecNum; kk++)
						{
							wSpksRelPhySecId = GetSpksPhySecId(szPlatFormRelSpksId[jj], kk);
							cPhySecBelongCiId = GetPhySecBelongCiId(wSpksRelPhySecId);

							if ((cLocalCiId != cPhySecBelongCiId) && (0U != cLocalCiId) && (0U != cPhySecBelongCiId))
							{
								AddCiSendAreaSnowInfo(cLocalCiId, cPhySecBelongCiId, pAreaSnowBuf[ii].wAreaId, pAreaSnowBuf[ii].cAreaSnowLevel);  /*站台关联有非本控区的区段，向区段所属CI发送站台ID*/
							}
							else
							{
								/*继续遍历*/
							}
						}
					}
					else
					{
						/*不更新该区间雨雪，继续遍历*/
					}
				}
			}
			else
			{
			/*获取站台关联SPKS失败，不处理*/
			}
		}
	}
	else
	{
	/*入参非法，不处理*/
	}
}

/*
* 功能描述：获取本地区间雨雪站台数量
* 参数说明：无
* 返回值  ：区间雨雪站台数量
*/
UINT8 GetLocalAreaSnowNum(void)
{
	return LocalAreaSnowNum;
}

/*
* 功能描述：获取本地区间雨雪信息
* 参数说明：无
* 返回值  ：区间雨雪信息
*/
AreaSnowInfoStruct* GetLocalAreaSnow(void)
{
	return szLocalAreaSnow;
}


/*
* 功能描述： 检查进路内第一个锁闭的区段是不是故障锁闭
* 参数说明： UINT16 routeId,    进路ID
*           UINT16 区段ID    第一个锁闭的区段ID（出参）
* 返回值  ：  0 第一个锁闭的区段不是故障锁闭
*            1 第一个锁闭的区段是故障锁闭
*/
UINT8 RouteFirstLockErrCheck(UINT16 routeId)
{
	UINT8 sectionSum = 0u; /*区段总数*/
	RoutePhysicalSectionStruct* pRouteSecStru = NULL; /*区段数据*/
	UINT8 ii = 0U;
	UINT8 wPhySecState = 0U;
	UINT16 phyRlockrouteId = 0U; /*锁闭所属进路*/
	UINT8 retVal = CI_ERROR;

	if ((0U != routeId) && (ROUTE_SUM_MAX > routeId))
	{
		sectionSum = GetRoutePhysicalSectionSum(routeId); /*获得进路包含的区段数目*/
		pRouteSecStru = GetRouteSectionData(routeId); /*进路区段数据*/

		if (NULL != pRouteSecStru)
		{
			for (ii = 0u; ii < sectionSum; ii++)
			{
				wPhySecState = GetPhySecLockState(pRouteSecStru[ii].PhysicalSectionId);
				phyRlockrouteId = GetPhySecRLockBelongRouteId(pRouteSecStru[ii].PhysicalSectionId);/*物理区段进路锁闭所属进路ID*/

				/*找到第一个被本进路锁闭的区段*/
				if ((PHYSICAL_SECTION_LOCK_NO != wPhySecState) && (phyRlockrouteId == routeId))
				{
					/*异常锁闭*/
					if (PHYSICAL_SECTION_LOCK_EXCEPT == wPhySecState)
					{
						retVal = CI_SUCCESS;
					}
					else
					{
						/*返回失败*/
						retVal = CI_ERROR;
					}
					break;
				}
				else
				{
					/*继续查找*/
				}

			}
		}
		else
		{
			/*检查失败*/
		}
	}
	return retVal;
}

/*
* 功能描述：获取全线通信车数据
* 参数说明：无
* 返 回 值：全线通信车结构体
* Created By LQ 2024.07.14
*/
LineCommTrainStruct GetLineCommTrainData(void)
{
	return gStrLineCommTrain;
}

/*
* 功能描述：处理全线通信车数据
* 参数说明：UINT8 cLineCtNum 全线通信车数量
*           UINT16 szLineCtId[TRAIN_SUM_MAX] 全线通信ID数组
* 返 回 值：无
* Created By LQ 2024.07.14
*/
void ProcessLineCommTrainData(UINT8 cLineCtNum, UINT16 szLineCtId[TRAIN_SUM_MAX])
{
	if ((TRAIN_SUM_MAX > cLineCtNum) && (NULL != szLineCtId))
	{
		gStrLineCommTrain.cCommTrainNum = cLineCtNum;

		(void)CommonMemSet(gStrLineCommTrain.szCommTrainNumID, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX), 0U, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX));  /*先清后存*/
		(void)CommonMemCpy(gStrLineCommTrain.szCommTrainNumID, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX), szLineCtId, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX));
	}
	else
	{
		/*入参非法，不处理*/
	}
}

/*
* 功能描述：清除全线通信车数据
* 参数说明：无
* 返 回 值：无
* Created By LQ 2024.07.14
*/
void ClearLineCommTrainData(void)
{
	/*清除全线通信车数据*/
	gStrLineCommTrain.cCommTrainNum = 0U;
	(void)CommonMemSet(gStrLineCommTrain.szCommTrainNumID, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX), 0U, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX));
}

/*
* 功能描述： 设置飞车宕机报警开始周期
* 参数说明： UINT32 dwFlyProtectOverCyc 宕机结束冗余周期号
* 返回值  ：
*/
void SetFlyProtectOverCyc(UINT32 dwFlyProtectOverCyc)
{
	if ((0U == gFlyProtectOverCyc) && (0U != dwFlyProtectOverCyc))
	{
		gFlyProtectOverCyc = dwFlyProtectOverCyc;
	}
	else
	{
		; /*已设置不再修改  不能清零*/
	}
}

/*
* 功能描述： 获取飞车宕机起始周期,未设置返回0
* 参数说明： void
* 返回值  ：
*/
UINT32 GetFlyProtectOverCyc(void)
{
	return gFlyProtectOverCyc;
}

/*
* 功能描述： 获取本地雨雪模式命令
* 参数说明： void
* 返回值  ：0x55: 无效 0xAA:有效
* by cgh 20241030
*/

UINT8 GetLocalSnowModel(void)
{
	return g_LocalSnowModel;
}

/*
* 功能描述： 设置本地雨雪模式命令
* 参数说明：UINT8 setmodle 本地雨雪模式
* 返回值  ：void
* by cgh 20241030
*/
void SetLocalSnowModel(UINT8 setmodle)
{
	if ((CI_LOCAL_SNOW_UNVALID == setmodle) || (CI_LOCAL_SNOW_VALID == setmodle))
	{
		g_LocalSnowModel = setmodle;
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述:进路锁闭道岔单操检查
* 输入参数:	const UINT16 routeId 进路ID
* 输出参数:	无
* 返回值:		CI_SUCCESS :成功
* 			    CI_ERROR: 失败
* by cgh 20241203
*/
UINT8 RouteLockSwitchDanCaoCheck(const UINT16 routeId)
{
	UINT8 ii = 0U;
	UINT8 chLocalCiId = 0U;/*本地联锁ID*/
	UINT8 chSwitchBelCiId = 0U;/*道岔所属联锁*/
	UINT8 chRouteSwitchSum = 0U; /*进路道岔数目*/
	UINT16 wSwitchId = 0U; /*进路道岔ID*/
	UINT8 chSwitchExpPosition = SWITCH_POSITION_INVALID;			/*道岔期望位置*/
	UINT8 chSwitchDancaoPosition = SWITCH_POSITION_INVALID; 		/*单操有效位置*/
	RouteSwitchStruct* pRouteSwitchStru = NULL;					/*进路道岔数据结构指针*/
	UINT8 chReval = CI_ERROR;							
	UINT8 chRouteProtectSwitchSum = 0U;  /*防护道岔数目*/
	RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL;    /*防护道岔数据*/

	if ((0U < routeId) && (ROUTE_SUM_MAX > routeId))
	{
		chLocalCiId = GetSystemParaLocalCiId();
		chRouteSwitchSum = GetRouteSwitchSum(routeId);
		pRouteSwitchStru = GetRouteSwitchData(routeId);
		chReval = CI_SUCCESS;

		/* 单操相反位置取消进路检查 */
		for (ii = 0u; ii < chRouteSwitchSum; ii++)
		{
			wSwitchId = pRouteSwitchStru[ii].SwitchId;
			chSwitchBelCiId = GetSwitchBelongCiId(wSwitchId);
			if ((chLocalCiId == chSwitchBelCiId) && (0U != chLocalCiId))
			{
				chSwitchExpPosition = pRouteSwitchStru[ii].SwitchPosition;
				chSwitchDancaoPosition = GetSwitchDanCaoPostition(wSwitchId);

				if ((SWITCH_POSITION_INVALID == chSwitchDancaoPosition)
					||
					(chSwitchDancaoPosition == chSwitchExpPosition))
				{/*单操无效 或者 单操位置与动作位置一样*/
					chReval = CI_SUCCESS;
				}
				else
				{
					/*单操到相反位置取消进路*/
					chReval = CI_ERROR;
					break;
				}
			}
			else
			{
				; /*道岔不是本联锁不处理*/
			}
		}

		if (CI_SUCCESS == chReval)
		{
			chRouteProtectSwitchSum = GetRouteRelatedProtectSwitchSum(routeId);
			pRouteProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId);

			/* 单操相反位置取消进路检查 */
			for (ii = 0u; ii < chRouteProtectSwitchSum; ii++)
			{
				wSwitchId = pRouteProtectSwitchStru[ii].ProtectSwitchId;
				chSwitchBelCiId = GetSwitchBelongCiId(wSwitchId);
				if ((chLocalCiId == chSwitchBelCiId) && (0U != chLocalCiId))
				{
					chSwitchExpPosition = pRouteProtectSwitchStru[ii].ProtectPosition;
					chSwitchDancaoPosition = GetSwitchDanCaoPostition(wSwitchId);

					if ((SWITCH_POSITION_INVALID == chSwitchDancaoPosition)
						||
						(chSwitchDancaoPosition == chSwitchExpPosition))
					{/*单操无效 或者 单操位置与动作位置一样*/
						chReval = CI_SUCCESS;
					}
					else
					{
						/*单操到相反位置取消进路*/
						chReval = CI_ERROR;
						break;
					}
				}
				else
				{
					; /*道岔不是本联锁不处理*/
				}
			}
		}
		else
		{
			chReval = CI_ERROR;
		}
	}
	else
	{
		; 
	}
	return chReval;
}

/*
* 功能描述： 道岔征用有效性检查
* 参数说明： const UINT16 wSwitchId，道岔Id
*	         const UINT8 functionId, 函数ID
*	         const UINT8 chSendLevel，发送等级
* 返回值  ： CI_SUCCESS: 检查成功
*			 CI_ERROR: 检查失败
* by cgh 20241205
*/
UINT8 GetSwitchUsingValidState(const UINT16 wSwitchId,const UINT8 chFunctionId,const UINT8 chSendLevel)
{
	UINT8 chReval = CI_ERROR;
	UINT8 chSwitchUsingState = 0U;/*道岔征用状态*/
	UINT16 wSwitchSecId = 0U;/*道岔物理区段ID*/
	UINT8 chSwitchSecUsingState = 0U;/*道岔区段征用状态*/
	UINT8 chSwitchType = 0U;/*道岔类型*/
	UINT16 wDSwitchOtherId = 0U;/*双动道岔另一道岔ID*/

	if ((0U < wSwitchId) && (SWITCH_SUM_MAX > wSwitchId))
	{
		chSwitchUsingState = GetSwitchUsingState(wSwitchId);
		if (SWITCH_USING_NO == chSwitchUsingState)
		{
			chReval = CI_SUCCESS;
		}
		else
		{
			chReval = CI_ERROR;
			SetErrorData(chFunctionId, CI_DEVICE_TYPE_SWITCH, wSwitchId, ETYPE_SWT_USE_STATE, chSwitchUsingState, chSendLevel);
		}

		if (CI_SUCCESS == chReval)
		{
			wSwitchSecId = GetSwitchPhySectionId(wSwitchId);
			chSwitchSecUsingState = GetPhySecUseState(wSwitchSecId);
			if (PHYSICAL_SECTION_USING_NO == chSwitchSecUsingState)
			{
				chReval = CI_SUCCESS;
			}
			else
			{
				chReval = CI_ERROR;
				SetErrorData(chFunctionId, CI_DEVICE_TYPE_PHYSEC, wSwitchSecId, ETYPE_PS_USE_STATE, chSwitchSecUsingState, chSendLevel);
			}
		}
		else
		{
			;
		}

		if (CI_SUCCESS == chReval)
		{
			chSwitchType = GetSwitchType(wSwitchId);
			if (SWITCH_TYPE_DOUBLE == chSwitchType)
			{
				wDSwitchOtherId = GetDSwitchOtherId(wSwitchId);
				chSwitchUsingState = GetSwitchUsingState(wDSwitchOtherId);
				if (SWITCH_USING_NO == chSwitchUsingState)
				{
					chReval = CI_SUCCESS;
				}
				else
				{
					chReval = CI_ERROR;
					SetErrorData(chFunctionId, CI_DEVICE_TYPE_SWITCH, wDSwitchOtherId, ETYPE_SWT_USE_STATE, chSwitchUsingState, chSendLevel);
				}

				if (CI_SUCCESS == chReval)
				{
					wSwitchSecId = GetSwitchPhySectionId(wDSwitchOtherId);
					chSwitchSecUsingState = GetPhySecUseState(wSwitchSecId);
					if (PHYSICAL_SECTION_USING_NO == chSwitchSecUsingState)
					{
						chReval = CI_SUCCESS;
					}
					else
					{
						chReval = CI_ERROR;
						SetErrorData(chFunctionId, CI_DEVICE_TYPE_PHYSEC, wSwitchSecId, ETYPE_PS_USE_STATE, chSwitchSecUsingState, chSendLevel);
					}
				}
				else
				{
					;
				}
			}
			else
			{
				; /*检查完毕*/
			}
		}
		else
		{
			; /*检查完毕*/
		}
	}
	else
	{
		;
	}

	return chReval;
}

/*
* 功能描述： 指定ID联锁控制权默认状态处理
* 参数说明： const UINT8 virtualCiId     虚拟联锁ID
* 返回值  ： viod
* by cgh 20250305
*/
void DefaultCtrlPowerDeal(const UINT8 virtualCiId)
{

	UINT8 ii = 0U;
	UINT8 chVirtualCiNum = 0U;

	chVirtualCiNum = GetVirtualCINum();

	if (chVirtualCiNum <= VIRTUAL_CI_MAX)
	{
		for (ii = 0U; ii < chVirtualCiNum; ii++)
		{
			if (virtualCiId == ctrlpowerFlag[ii].virCiId)
			{
				ctrlpowerFlag[ii].ctrlPowerState = CONTRAL_POWER_NO;
				ctrlpowerFlag[ii].ctrlDeviceId = 0U;
				ctrlpowerFlag[ii].ctrlDeviceType = 0U;
			}
			else
			{
				; /*继续查找*/
			}
		}
	}
	else
	{
		; 
	}
}

/*
* 功能描述：获取本地区间ITE切除数量
* 参数说明：无
* 返 回 值：本地区间ITE切除数量
* Created By LQ 2025.04.15
*/
UINT8 GetLocalAreaIteCutNum(void)
{
	return gLocalAreaIteCutNum;
}

/*
* 功能描述：获取本地区间ITE切除ID数组
* 参数说明：无
* 返 回 值：本地区间ITE切除ID数组
* Created By LQ 2025.04.15
*/
UINT16* GetLocalAreaIteCutId(void)
{
	return gSzLocalAreaIteCutId;
}

/*
* 功能描述：清除本地区间ITE切除信息
* 参数说明：无
* 返 回 值：无
* Created By LQ 2025.04.15
*/
void ClearLocalAreaIteCutInfo(void)
{
	gLocalAreaIteCutNum = 0U;
	(void)CommonMemSet(gSzLocalAreaIteCutId, (UINT32)(sizeof(UINT16) * ALL_AREA_SNOW_SUM_MAX), 0U, (UINT32)(sizeof(UINT16) * ALL_AREA_SNOW_SUM_MAX));
}

/*
* 功能描述：设置本地区间ITE切除信息
* 参数说明：const UINT8 cAreaIteCutNum 区间ITE切除数量
*			const UINT16 pAreaIteCutIdBuf[ALL_AREA_SNOW_SUM_MAX] 区间ID数组
* 返 回 值：无
* Created By LQ 2025.04.15
*/
void SetLocalAreaIteCutInfo(const UINT8 cAreaIteCutNum, const UINT16 pAreaIteCutIdBuf[ALL_AREA_SNOW_SUM_MAX])
{
	UINT8 ii = 0U;
	UINT8 jj = 0U;
	UINT16 kk = 0U;
	UINT8 cPlatFormRelSpksNum = 0U;  /*站台关联的SPKS数量*/
	UINT16 szPlatFormRelSpksId[PLATFORM_REL_SPKS_NUM_MAX] = { 0U };  /*站台关联的SPKS ID数组*/
	UINT16 wSpksIndex = 0U;
	UINT16 wSpksRelPhySecNum = 0U;  /*SPKS关联物理区段数量*/
	UINT16 wSpksRelPhySecId = 0U;  /*SPKS关联物理区段ID*/
	UINT8 cPhySecBelongCiId = 0U;  /*SPKS关联物理区段的所属控区*/
	UINT8 cLocalCiId = 0U;  /*本地CI ID*/
	UINT8 cPlatFormBelongCiId = 0U;  /*站台关联Link所属CI*/

	if ((ALL_AREA_SNOW_SUM_MAX >= cAreaIteCutNum) && (NULL != pAreaIteCutIdBuf))
	{
		/*先清除本地区间ITE切除信息及发送给相邻联锁的区间ITE切除信息*/
		ClearLocalAreaIteCutInfo();
		ClearCiSendAreaIteCutInfo();		

		/*开始刷新本地区间ITE切除信息*/
		gLocalAreaIteCutNum = cAreaIteCutNum;
		for (ii = 0U; ii < cAreaIteCutNum; ii++)
		{
			gSzLocalAreaIteCutId[ii] = pAreaIteCutIdBuf[ii];  /*存储本控区区间ID*/

			/*判断是否需要向相邻联锁发送本控区的区间ITE切除信息*/
			cLocalCiId = GetSystemParaLocalCiId();
			cPlatFormBelongCiId = GetAreaSnowPlatFormBelongCiId(pAreaIteCutIdBuf[ii]);  /*获取区间所属控区*/
			if ((cLocalCiId == cPlatFormBelongCiId) && (0U != cLocalCiId))
			{
				cPlatFormRelSpksNum = GetPlatFormRelSpksNum(pAreaIteCutIdBuf[ii], szPlatFormRelSpksId);  /*获取站台关联的SPKS*/

				if (CI_ERROR != cPlatFormRelSpksNum)
				{
					/*遍历所有站台关联的SPKS，判断SPKS是否关联有非本控区的物理区段*/
					for (jj = 0U; jj < cPlatFormRelSpksNum; jj++)
					{
						wSpksIndex = GetSpksConfigBufIndex(szPlatFormRelSpksId[jj]);
						if (SPKS_SUM_MAX > wSpksIndex)
						{
							wSpksRelPhySecNum = GetSpksPhySecSumByIndex(wSpksIndex);

							for (kk = 0U; kk < wSpksRelPhySecNum; kk++)
							{
								wSpksRelPhySecId = GetSpksPhySecId(szPlatFormRelSpksId[jj], kk);
								cPhySecBelongCiId = GetPhySecBelongCiId(wSpksRelPhySecId);

								if ((cLocalCiId != cPhySecBelongCiId) && (0U != cLocalCiId) && (0U != cPhySecBelongCiId))
								{
									AddCiSendAreaIteCutInfo(cLocalCiId, cPhySecBelongCiId, pAreaIteCutIdBuf[ii]);  /*站台关联有非本控区的区段，向区段所属CI发送区间站台ID*/
								}
								else
								{
									/*继续遍历*/
								}
							}
						}
						else
						{
							/*不更新该区间雨雪，继续遍历*/
						}
					}
				}
				else
				{
					/*获取站台关联SPKS失败，不处理*/
				}
			}
			else
			{
				/*非本控区区间，不对相邻RC/CI组包*/
			}
		}
	}
	else
	{
		/*入参非法，不处理*/
	}
}

/*
* 功能描述：获取进路内第一个锁闭的逻辑区段ID
* 参数说明：UINT16 wRouteId 进路ID
* 返 回 值：0 无锁闭的逻辑区段
*          >0 第一个锁闭的逻辑区段ID
* Created By LQ 2025.05.08
*/
UINT16 GetRouteFirstLockedLogSecId(UINT16 wRouteId)
{
	UINT16 wRetVal = 0U;	
	UINT16 wRouteLogSecNum = 0U;  /*进路包含的逻辑区段数量*/
	UINT16* pRouteLogSecIdBuf = NULL;  /*进路包含的逻辑区段ID*/
	UINT16 i = 0U;
	UINT16 wLockBelongRouteId = 0U;  /*锁闭所属进路ID*/

	/*获取进路逻辑区段数据*/
	wRouteLogSecNum = GetRouteLogSectionSum(wRouteId);
	pRouteLogSecIdBuf = GetRouteLogSectionIdBuf(wRouteId);

	if ((0U < wRouteLogSecNum) && (NULL != pRouteLogSecIdBuf))
	{
		for (i = 0U; i < wRouteLogSecNum; i++)
		{
			wLockBelongRouteId = GetLogSecLockBelongRoute(pRouteLogSecIdBuf[i]);  /*获取逻辑区段锁闭所属进路*/
			
			if (wLockBelongRouteId == wRouteId)
			{
				/*逻辑区段被本进路锁闭，传出此逻辑区段*/
				wRetVal = pRouteLogSecIdBuf[i];
				break;
			}
			else
			{
				/*继续遍历查找*/
			}
		}
	}
	else
	{
		/*返回0*/
	}

	return wRetVal;
}

/*
功能描述:
	清除逻辑区段关联道岔单操位置
输入参数:
	const UINT16 逻辑区段ID
输出参数:
	无.
返回值:
	无
add by mpt 20260403
*/
void ClearLogSeceSwitchDanCaoPos(const UINT16 logicSecId)
{
	UINT8 	switchSum = 0u; 									/*道岔数目*/
	UINT16 	switchId = 0u; 									/*道岔ID*/
	UINT8 	ii = 0u;											/*循环变量*/
	UINT8  checkSum = 0u;
	LogsecSwitchStruct* dataIdBuf = NULL;

	UINT8 chLogicSecSwitchSum = 0U;/*逻辑区段道岔数目*/
	LogsecSwitchStruct* pLogicSecSwitchIdData = NULL;/*逻辑区段道岔ID数据*/

	chLogicSecSwitchSum = GetLogicSecSwitchSum(logicSecId);/*逻辑区段道岔数目*/
	pLogicSecSwitchIdData = GetLogicSecSwitchIdStru(logicSecId);/*逻辑区段道岔ID数据*/

	checkSum = GetLgcRelateProSwSum(logicSecId);/*获取指定ID逻辑区段关联防护道岔数目*/
	dataIdBuf = GetLgcRelateProSwStru(logicSecId);



	if (NULL != pLogicSecSwitchIdData)
	{
		for (ii = 0u; ii < chLogicSecSwitchSum; ii++)
		{
			switchId = pLogicSecSwitchIdData[ii].SwitchId;
			/*设置该道岔期望驱动位置为无效*/
			(void)SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID);
		}
	}

	if (NULL != dataIdBuf)
	{
		for (ii = 0u; ii < checkSum; ii++)
		{
			switchId = dataIdBuf[ii].SwitchId;
			/*设置该道岔期望驱动位置为无效*/
			(void)SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID);
		}
	}
}

/*
功能描述:
	清除计轴区段关联道岔单操位置
输入参数:
	const UINT16 计轴区段ID
输出参数:
	无.
返回值:
	无
add by mpt 20260403
*/
void ClearAxisSeceSwitchDanCaoPos(const UINT16 axisSecId)
{
	UINT16* pLogSectionIdBuf = NULL;
	UINT8 chLogSectionSum = 0U;
	UINT8 ii = 0U;

	pLogSectionIdBuf = GetAxisSecLogSectionIdBuf(axisSecId);
	chLogSectionSum = GetAxisSecLogSectionSum(axisSecId);

	if (NULL != pLogSectionIdBuf)
	{
		for (ii = 0U; ii < chLogSectionSum; ii++)
		{
			/*清除逻辑区段道岔道岔标志*/
			ClearLogSeceSwitchDanCaoPos(pLogSectionIdBuf[ii]);
		}
	}
}
