/********************************************************
*                                                                                                            
* 文 件 名： InputDataProcess.c   
* 版权说明： 北京交控科技有限公司 
* 创建时间： 2012-04-07
* 作    者： 联锁组
* 功能描述： 输入数据处理
* 修改记录：   
*
********************************************************/ 


#include "InputDataProcess.h"
#include "../HLHTMsgHead/HLHTHeadContexManage.h"
#include "../Initial/InitialProcess.h"
#include "../ParsePack/ParsePackPSCData.h"
#include "../ParsePack/ParsePackTmcData.h"
#include "../ParsePack/ParsePackVobcData.h"
#include "EnvelopeManageAPI.h"
#include "OutputDataProcess.h"
#include "RRMManageAPI.h"
#include "WLBrakeDataManage.h"
#include "NonAutoReturnDataManage.h"
#include "../IO/DeviceRelayDataProcess.h"
#include "MSCP_APP_API.h"

extern PlatformToCiDataStruct platformToCiDataStru[PLATFORM_TO_CI_SUM_MAX];	/*引用站台门与CI通信数据结构体*/
extern unsigned long TimeStamp = 0u;

/*
* 功能描述： 处理互联互通VOBC数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void      
*/
static void HLHTVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru);

/*
* 功能描述： 处理FAOVOBC数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void      
*/
static void FAOVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru);

/*
* 功能描述： 屏蔽门关闭重开信号
* 参数说明： const UINT16 routeId,需要重开信号的进路
			 const UINT16 psdID，导致进路重开信号的PSD
* 返回值  ： void
*/
static void PsdOpenSignal(const UINT16 routeId, const UINT16 psdId);

/*
* 功能描述： 处理输入数据
* 参数说明： void
* 返回值  ： void      
*/
static void ProcessPsdData(void);

/*
* 功能描述： 发送给相邻联锁信号特开申请命令条件检查
* 参数说明： const UINT16 signalId 信号机ID
*            UINT8* toCiId 目标联锁ID
* 返回值  ： CI_SUCCESS: 条件检查通过
*			 CI_ERROR: 条件检查失败      
*/
static UINT8 RouteReturnToThroughCondCheck(const UINT16 signalId,UINT8* toCiId);

/*
* 功能描述： 相邻联锁信号特开申请命令处理
* 参数说明： const UINT16 signalId 信号机ID
*            const UINT8 fromCiId 源联锁ID
* 返回值  ： CI_SUCCESS: 处理成功
*			 CI_ERROR: 处理失败      
*/
static UINT8 RouteReturnToThroughCmdProc(const UINT16 signalId,const UINT8 fromCiId);

/*
* 功能描述： 处理试车线特殊命令数据
* 参数说明： const UINT16 devId：设备ID
*			 const UINT8 CMDType:命令类型
* 返回值  ： CI_SUCCESS: 处理成功
*			 CI_ERROR: 处理失败
* cgh-合并CID-2341-6：
*/
static UINT8 VirtualDevCmdProc(const UINT16 devId,const UINT8 CMDType);

/*
* 功能描述： 校验试车线特殊命令设备所属控区
* 参数说明： const UINT16 devId：设备ID
*			 const UINT8 CMDType:命令类型
* 返回值  ： CI_SUCCESS: 校验成功
*			 CI_ERROR: 校验失败
* cgh-合并CID-2341-6、cgh-合并CID-2539-2：
*/
static UINT8 VirtualDevCmdCiIdCheck(const UINT16 devId, const UINT8 CMDType);

/*
* 功能描述：重置车辆段与试车线相关设备动态数据
* 参数说明：无
* 返回值  ： void
*/
static void ResetTrainTestDevState(const UINT8 ciId);

/*
* 功能描述：互联互通时，清除本联锁发给互联互通邻线联锁的保护区段锁闭命令
* 参数说明：无
* 返回值  ： void
*/
static void ClearSignalOvlpCmdHlht(void);

/*
* 功能描述：处理交控联锁间接口命令
* 参数说明：无
* 返回值  ： void
*/
static void ProcessTctCiCmd(void);

/*
* 功能描述：处理互联互通联锁间接口命令
* 参数说明：无
* 返回值  ： void
*/
static void ProcessHlhtCiCmd(void);

/*
* 功能描述：重置互联互通相邻联锁的设备状态
* 参数说明：UINT8 const ciId,互联互通相邻CI编号
* 返回值  ： void
*/
static void ResetCiDevStateHlht(UINT8 const ciId);

/*
* 功能描述： 处理HLHT+FAOVOBC数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void      
*/
static void HLHTFAOVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru);
/*
* 功能描述： 处理VOBC停稳信息数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void      
*/
static void StopSteadyDataProc(VobcToCiDataStruct* vobcToCiDataStru);

/*
* 功能描述： 处理VOBC停车保证信息
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
*/
static void StopensureDataProc(VobcToCiDataStruct* vobcToCiDataStru);


/*
* 功能描述： 处理VOBC取消资源信息
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
*/
static void ResourceCancelDataProc(VobcToCiDataStruct* vobcToCiDataStru);

/*
* 功能描述： 处理车车IVOC数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
*/
static void IvocInputDataProcCC(VobcToCiDataStruct* pstIvocToCiData);


/*
* 功能描述： 刷新列车数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* 创建	  ： qw.liu 2022-02-26
*/
static void IvocInputRefreshTrain(const VobcToCiDataStruct stIvocToCiData);

/*
* 功能描述： 处理列车命令
* 参数说明： vobcToCiDataStru：VOBC数据结构体
* 返回值  ： void
* 创建	  ： qw.liu 2022-02-26
*/
static void IvocInputCmdProc(const VobcToCiDataStruct stIvocToCiData);

/*
* @func： 处理列车丢失通信
* @param： vobcToCiDataStru：VOBC数据结构体
* @retrun  ： void
* @create	  ： qw.liu 2022-08-13
*/
static void ProcessIvocLoseCom(const VobcToCiDataStruct stIvocToCiData);

/*
* 功能描述： 处理IVOC无人折返初始值
* 参数说明： trainId：列车ID
* 返回值  ：
*/
static void IvocNonAutoRtnProcess(const UINT16 trainId);

/*
* 功能描述：IVOC防淹门关闭允许确认处理
* 参数说明：vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ：void
* BY LC
*/
static void IvocFloodGateCloseProc(VobcToCiDataStruct* vobcToCiDataStru);

/*
* 功能描述： Vobc列车接口信息处理
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* by cgh 20240614
*/
static void VobcConnectDataProc(VobcToCiDataStruct* vobcToCiDataStru);

/*
* 功能描述： Vobc列车信息清除
* 参数说明：  UINT16 wTrainId：VOBCid
* 返回值  ： void
* by cgh 20240614
*/
static void VobcConnectDataClear(const UINT16 wTrainId);

/*
* 功能描述： Vobc后备接口信息处理
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* by cgh 20240710
*/
static void VobcBackUpConnectDataProc(VobcBackUpToCiDataStruct* vobcToCiDataStru);

/*
* 功能描述： 处理VOBC后备停稳信息数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* fan 20240815
*/
static void BackupStopSteadyDataProc(VobcBackUpToCiDataStruct* vobcToCiDataStru);
/*
* 功能描述： 处理输入数据
* 参数说明： void
* 返回值  ： void      
*/
void InputDataProcess(void)
{
	UINT8 localCiType = GetLocalCiType();
	UINT8 localCiPattern = GetLocalCiPattern();
	UINT8 chSwitch = 0u;
	UINT8 cRcWorkMode = 0U;

	signed long long cost[20] = {0U};
	chSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH);
	cRcWorkMode = GetLocalRcWorkMode();

	cost[0] = MSCP_GetTick();
#if (kPLATFORM==kVXWORKS)
	 (void)ProcessPlatformNetData();
#endif
	if (CI_PATTERN_TRADITIONAL == localCiPattern)
	{
		/*处理IO数据*/
		(void)ProcessIoToCiData();
	}
	else if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern)/*全电子联锁*/
	{
		/*处理OC数据*/
		(void)ProcessOcToCiRelayData();
		/*处理采集不一致的点位*/
		ProcessOcToCiRelayDiffData();
		debug_infor_printf((const)"\nprocess oc_relay end\n");
	}
	else
	{
		/*不做处理*/
	}
    
#ifdef PLATFORM_2OO2

	if (CI_PATTERN_TRADITIONAL== localCiPattern)
	{/*传统联锁*/
		/*重置IO到CI数据帧*/
		ResetIoToCiData();
	}
	else
	{/*全电子联锁*/
		/*处理OC到CI数据*/
		ProcessOcToCiData();
	}

#endif
	cost[1] = MSCP_GetTick();
	/*处理计轴到CI数据*/
	ProcessAxleToCiData();

#if 0
	/*置物理区段停稳信息为未停稳,防止设置过UT车占压的停稳信息，和ZC之间又无停稳码位信息，导致停稳信息一直在，保护区段无法建立*/
	ResetPhySecStopSteadyInfo();
#endif

	/*处理互联互通通用报文头*/
	ProcHlhtHeadCtxTimeOut();

	/*互联互通时，清除本联锁发给互联互通邻线联锁的保护区段锁闭命令*/
	ClearSignalOvlpCmdHlht();

    /*处理CI数据命令*/
    ProcessCiToCiData();

	if (RC_WORK_MODE_CI == cRcWorkMode)
	{
		/*处理ZC数据*/
		ProcessZcToCiData();
	}
	else
	{
		/*处理TMC到TIOC数据*/
		ProcessTmcToTiocData();
	}
	cost[2] = MSCP_GetTick();
	/*处理ITE数据*/
	ProcessIteToCiData();
	cost[3] = MSCP_GetTick();
    /*处理VOBC数据*/
    ProcessVobcToCiData();
	cost[4] = MSCP_GetTick();
	/*处理后备通道VOBC数据*/
	ProcessVobcBackupToCiData();

	/*列车物理区段ABL占用标志更新*/
	TrainPhyAblTagUpdate();

	/*处理PSD系统数据*/
    ProcessPlatformToCiData();

	/*处理PSC系统数据*/
	ProcessPscToCiData();

	/*处理OC-PSC一体化数据*/
	ProcessOCToCiPsdData();

	/*处理设备状态*/
	ProcessDeviceLogicState();	

	/*处理屏蔽门数据*/
	ProcessPsdData();
	
	/*处理LEU数据*/
	ProcessLeuToCiData();

	if (RC_WORK_MODE_TIOC == cRcWorkMode)
	{

		/*处理物理区段上的占用落到计轴区段 */
		ProcessPhyOCcStateToAxisSection();
		
		/* 全线紧急制动处理 */
		WlbAtsCmdProc();

		/* 列车处理 */
		TrainMainProc();
		cost[5] = MSCP_GetTick();
		/*回收列车资源*/
		(void)TrainResRecycle();
		if (FUNC_SWITCH_ON == chSwitch)
		{
			/* 列车占压计轴区段计算 */
			ToaMainProc();
		}
		else
		{
			;
		}		
		/** 包络管理*/
		elm_MainProcess();

		cost[6] = MSCP_GetTick();
		/** 远程RM处理 */
		rrm_MainProcess();

		/* 设置本控区物理区段ARB状态 */
		SetPhySecArbStateProc();

		/*排序*/
		as_MainProcess();

		/*计轴坏车占用状态更新*/
		AxisSecUtOccpyUpdate();

		/*区段状态判断*/
		ssp_MainProcess();
		cost[7] = MSCP_GetTick();
	}
	/* 设置逻辑区段ARB状态 */
	SetLgcArbStateProc();
	/*更新物理区段融合状态*/
	UpdatePhySectionMergeLogicState();

	/*融合逻辑区段CT占用信息*/
	UpdateLogSectionCTOccupyState();

	if (RC_WORK_MODE_TIOC == cRcWorkMode)
	{
		/* 信号机亮灭处理 */
		(void)SignalLightUpProc();
	}
	else
	{
		/*不处理*/
	}

	/*刷新物理区段与信号机的湿轨标志*/
	UpdateHumidRailFlag();

	/*PSD异常打开处理（需要先更新物理区段融合状态，再进行PSD异常打开判断）*/
	PsdExceptOpenProc();

	/*处理ATS数据*/
    if ((CI_TYPE_ZX == localCiType) || (CI_TYPE_SCX == localCiType))
    {
        /*正线处理*/
		(void)ProcessAtsOrXianDiToCiData();
    }
    else
    {
        /*车辆段处理*/
		(void)ProcessAtsOrXianDiToCiDataCld();
    }

	(void)UpdataAtsDeviceCommState();

	(void)ProcessAtsOrXDToCiReturnToTRCmd();/*处理涉及相邻联锁的信号特开命令*/
	/*cgh-合并CID-3037-1 处理虚拟ESB相关状态*/
	VirtualEsbLogicProcess();
	cost[8] = MSCP_GetTick();
	debug_infor_printf((const)"\n OutnetProcess :%dms  ProcessAxleToCiData:%dms ProcessVobcBackupToCiData :%dms  ProcessDeviceLogicState:%dms TrainMainProc:%dms as_MainProcess:%dms ssp_MainProcess:%dms VirtualEsbLogicProcess:%dms  \n",(cost[1]-cost[0])/1000,(cost[2]-cost[1])/1000,(cost[3]-cost[2])/1000,(cost[4]-cost[3])/1000,(cost[5]-cost[4])/1000,(cost[6]-cost[5])/1000, (cost[7] - cost[6]) / 1000, (cost[8] - cost[7]) / 1000);
}


/*
* 功能描述： 处理IO到CI数据
* 参数说明： void
* 返回值  ： 0u:处理失败
*			 1:处理成功      
*/
UINT8 ProcessIoToCiData(void)
{
	IoDataStruct* CollBoardDataStru_ForProcess = NULL;					/*采集继电器数据*/
	UINT8 CollBroadStruCurSum_ForProcess = 0u;						/*采集继电器结构总数*/
	UINT8 BoardAddress_ForProcess = 0u;								/*采集继电器当前地址*/
	UINT8 PosValue_ForProcess = 0u;									/*采集继电器当前地址的采集点数值*/
	UINT8 ColRelayInfo = 0u;											/*采集描述信息 确认是A系还是B系，是前采集还是后采集*/
	UINT16 RelayId = 0u;											/*当前采集地址和采集点位置对应的继电器ID*/
	UINT8 ii = 0u;												/*遍历采集继电器地址*/
	UINT8 jj = 0u;												/*遍历当前地址的继电器位置*/
	UINT16 kk = 0u;												/*游标*/
	UINT16 relaySum = 0u;										/*继电器总数*/
    UINT8 returnValue = CI_SUCCESS;                             /*返回值默认成功*/
	UINT8 SystemParaLocalCiId = 0u;								/*本机联锁ID*/
	UINT8 RelayBelongCiId = 0u;									/*指定ID继电器所属联锁ID*/
	UINT8 ProcessRelayCollState_ret = 0u;
	UINT8 funValue = 0u;

	debug_infor_printf((const)"ProcessIoToCiData start at %d",TimeStamp);

	CollBroadStruCurSum_ForProcess = GetCollBroadStruCurSum();
	if (0u == CollBroadStruCurSum_ForProcess)
	{
        returnValue = CI_ERROR;
	}
	else
	{
		CollBoardDataStru_ForProcess = GetCollBoardDataStruct();
		for (ii = 0u; ii < CollBroadStruCurSum_ForProcess; ii++)
		{
			BoardAddress_ForProcess = CollBoardDataStru_ForProcess[ii].BoardAddress;

			for (jj = 0u; jj < BOARD_POS_MAX; jj++)
			{
				PosValue_ForProcess = CollBoardDataStru_ForProcess[ii].PosValueBuf[jj];
				RelayId = GetColRelayID(0,BoardAddress_ForProcess, (UINT8)(jj));
				ColRelayInfo = GetColRelayInfo(0,BoardAddress_ForProcess, (UINT8)(jj));

				if (0u != RelayId)
				{
					/*无继电器数据的采集点跳过*/
					if ((RELAY_STATE_UP == PosValue_ForProcess) || (RELAY_STATE_DOWN == PosValue_ForProcess))
					{
						switch (ColRelayInfo)
						{
						case RELAY_COLL_FORENODE_A:
							funValue = SetForeNodeACollState(RelayId, PosValue_ForProcess);
							if (CI_ERROR == funValue)
							{
								returnValue = CI_ERROR;
							}
							break;
						case RELAY_COLL_FORENODE_B:
							funValue = SetForeNodeBCollState(RelayId, PosValue_ForProcess);
							if (CI_ERROR == funValue)
							{
								returnValue = CI_ERROR;
							}
							break;
						case RELAY_COLL_BACKNODE_A:
							funValue = SetBackNodeACollState(RelayId, PosValue_ForProcess);
							if (CI_ERROR == funValue)
							{
								returnValue = CI_ERROR;
							}
							break;
						case RELAY_COLL_BACKNODE_B:
							funValue = SetBackNodeBCollState(RelayId, PosValue_ForProcess);
							if (CI_ERROR == funValue)
							{
								returnValue = CI_ERROR;
							}
							break;
						default:
							/*不可达分支*/
							break;
						}						
					}
					else
					{
						returnValue = CI_ERROR;
					}
				}


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

		debug_infor_printf((const)"ColRelayInfo at %d",TimeStamp);

		if (CI_SUCCESS == returnValue)
		{
			relaySum = GetRelayCurSum();
			SystemParaLocalCiId = GetSystemParaLocalCiId();
			for (kk = 0u; kk < relaySum; kk++)
			{
				RelayId = GetRelayId(kk);
				RelayBelongCiId = GetRelayBelongCiId(RelayId);
				if (SystemParaLocalCiId == RelayBelongCiId)
				{
					ProcessRelayCollState_ret = ProcessRelayCollState(RelayId);
					/*非本联锁跳过*/
					if (CI_ERROR == ProcessRelayCollState_ret)
					{
#if 0
						/*记录系统故障*/
						SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM,CI_DEVICE_TYPE_RELAY,RelayId, ETYPE_SYSTEM_REL_UPDATA_ERROR,CI_ERROR,ESEND_LEVEL_ZERO);
#endif
					}
					else
					{
						/*赋值下一个*/
					}	
				}
			}

		}
	}
	

	debug_infor_printf((const)"ProcessIoToCiData end at %d",TimeStamp);

	return returnValue;
}

/*
* 功能描述： 处理Axle到CI数据
* 参数说明： void
* 返回值  ： void
*/
void ProcessAxleToCiData(void)
{
	UINT8 returnValue = CI_ERROR; /*返回值默认成功*/
	AxisToCiDataStruct* CollAxisDataStru = NULL; /*计轴通信采集数据*/
	UINT8 axisCommSum = 0u; /*通信计轴数量*/
	UINT8* pAxisSysIdBuf = NULL; /*通信计轴*/
	UINT16 ii = 0u; /*用于循环*/
	UINT16 jj = 0u; /*用于循环*/
	UINT8 localCiId = 0u; /*本CI ID*/
	UINT8 axisSysId = 0u;/*计轴子系统id*/
	UINT8 tranAxisCommState = TRANSMIT_STATE_BAD;/*通信状态*/
	UINT16 secId = 0u; /*物理区段ID*/
	UINT8 colAxisRelaySta = RELAY_STATE_DOWN; /*计轴状态*/
	UINT8 secOccupySta = SECTION_OCCUPY_YES; /*区段占用状态*/
	UINT8 acFty = 0u; /*计轴系统厂家*/
	UINT32 dwCurCycNum = 0U;
	UINT32 dwLastRecvAxisDataCycNum = 0U;  /*最后接收到计轴数据的周期*/
	UINT32 dwCommBadEnsureCount = 0U;  /*判断计轴通信中断确认周期*/

	CollAxisDataStru = GetCollAxisDataStruct();
	axisCommSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS);
	pAxisSysIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS);

	if ((NULL != CollAxisDataStru) && (NULL != pAxisSysIdBuf))
	{
		returnValue = CI_SUCCESS;
	}

	if (CI_SUCCESS == returnValue)
	{
		localCiId = GetSystemParaLocalCiId();
		for (ii = 0u; ii < axisCommSum; ii++)
		{
			axisSysId = pAxisSysIdBuf[ii];
			(void)UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_AXIS, axisSysId);

			tranAxisCommState = GetCiTransmitState(CI_SYSTEM_TYPE_AXIS, axisSysId);
			if (TRANSMIT_STATE_GOOD == tranAxisCommState)
			{
				if(axisSysId <AXIS_TO_CI_SUM_MAX)
				{
				/*CI与AXIS通信良好*/
					for (jj = 0u; jj < CollAxisDataStru[axisSysId].SectionSum; jj++)
					{
						secId = CollAxisDataStru[axisSysId].axisDataStr[jj].PhySecId;
						colAxisRelaySta = CollAxisDataStru[axisSysId].axisDataStr[jj].gdRelayState;

						if (RELAY_STATE_UP == colAxisRelaySta)
						{
							secOccupySta = SECTION_OCCUPY_NO;
						}
						else if (RELAY_STATE_DOWN == colAxisRelaySta)
						{
							secOccupySta = SECTION_OCCUPY_YES;
						}
						else
						{
							secOccupySta = SECTION_OCCUPY_YES;
						}
						(void)SetPhySecCurAxisGdOccupyState(secId, secOccupySta);

						/*计轴预复位*/
						acFty = GetCiFunctionSwitchConfig(FUNC_SWITCH_AC_FACTORY);
						if (AXIS_TYPE_KEANDA == acFty)
						{
							if (RELAY_STATE_UP == axisToCiDataStru[axisSysId].axisDataStr[jj].PreResetRst)
							{
								/*计轴预复位继电器吸起*/
								SetPhySecPreResetState(secId, PHYSICAL_SECTION_PRE_RESET_YES);	/*设置计轴预复位状态有效*/
							}
							else if (RELAY_STATE_DOWN == axisToCiDataStru[axisSysId].axisDataStr[jj].PreResetRst)
							{
								/*计轴预复位继电器落下*/
								SetPhySecPreResetState(secId, PHYSICAL_SECTION_PRE_RESET_NO);	/*设置计轴预复位状态无效*/
							}
							else
							{
								/*异常值*/
								SetPhySecPreResetState(secId, PHYSICAL_SECTION_PRE_RESET_NO);	/*设置计轴预复位状态无效*/
							}

							/*科安达无直接复位状态接口，但后面为了计轴复位统一处理，这里设置成无效*/
							SetPhySecDirectResetState(secId, PHYSICAL_DIRECT_RESET_NO);	/*设置计轴直接复位状态无效*/
						}
						else if (AXIS_TYPE_FUHAOSHENG == acFty)
						{
							if ((RELAY_STATE_UP == axisToCiDataStru[axisSysId].axisDataStr[jj].PreResetRst)
								&& (RELAY_STATE_UP == axisToCiDataStru[axisSysId].axisDataStr[jj].chDirectResetRst))
							{
								/*预复位和立即复位同时有效，导向异常*/
								SetPhySecPreResetState(secId, PHYSICAL_SECTION_PRE_RESET_NO);	/*设置计轴预复位状态无效*/
								SetPhySecDirectResetState(secId, PHYSICAL_DIRECT_RESET_NO);	/*设置计轴直接复位状态无效*/
								SetPhySecPreResetBack(secId, PHY_RESET_BACK_RECIVE_YES);
								SetPhySecDirectResetBack(secId, PHY_RESET_BACK_RECIVE_YES);
							}
							else
							{
								if (RELAY_STATE_UP == axisToCiDataStru[axisSysId].axisDataStr[jj].PreResetRst)
								{
									/*计轴预复位继电器吸起*/
									SetPhySecPreResetState(secId, PHYSICAL_SECTION_PRE_RESET_YES);	/*设置计轴预复位状态有效*/
								}
								else if (RELAY_STATE_DOWN == axisToCiDataStru[axisSysId].axisDataStr[jj].PreResetRst)
								{
									/*计轴预复位继电器落下*/
									SetPhySecPreResetState(secId, PHYSICAL_SECTION_PRE_RESET_NO);	/*设置计轴预复位状态无效*/
								}
								else
								{
									/*异常值*/
									SetPhySecPreResetState(secId, PHYSICAL_SECTION_PRE_RESET_NO);	/*设置计轴预复位状态无效*/
								}

								if (RELAY_STATE_UP == axisToCiDataStru[axisSysId].axisDataStr[jj].chPreResetBack)
								{
									/*计轴预复位反馈-接收到*/
									SetPhySecPreResetBack(secId, PHY_RESET_BACK_RECIVE_YES);	
								}
								else if (RELAY_STATE_DOWN == axisToCiDataStru[axisSysId].axisDataStr[jj].chPreResetBack)
								{
									/**计轴预复位反馈-未接收到*/
									SetPhySecPreResetBack(secId, PHY_RESET_BACK_RECIVE_NO);	
								}
								else
								{
									/*异常值*/
									SetPhySecPreResetBack(secId, PHY_RESET_BACK_RECIVE_YES);
								}

								if (RELAY_STATE_UP == axisToCiDataStru[axisSysId].axisDataStr[jj].chDirectResetRst)
								{
									/*计轴直接复位继电器吸起*/
									SetPhySecDirectResetState(secId, PHYSICAL_DIRECT_RESET_YES);	/*设置计轴直接复位状态有效*/
								}
								else if (RELAY_STATE_DOWN == axisToCiDataStru[axisSysId].axisDataStr[jj].chDirectResetRst)
								{
									/*计轴直接复位继电器落下*/
									SetPhySecDirectResetState(secId, PHYSICAL_DIRECT_RESET_NO);	/*设置计轴直接复位状态无效*/
								}
								else
								{
									/*异常值*/
									SetPhySecDirectResetState(secId, PHYSICAL_DIRECT_RESET_NO);	/*设置计轴直接复位状态无效*/
								}

								if (RELAY_STATE_UP == axisToCiDataStru[axisSysId].axisDataStr[jj].chDirectResetBack)
								{
									/*计轴直接复位反馈-接收到*/
									SetPhySecDirectResetBack(secId, PHY_RESET_BACK_RECIVE_YES);
								}
								else if (RELAY_STATE_DOWN == axisToCiDataStru[axisSysId].axisDataStr[jj].chDirectResetBack)
								{
									/**计轴直接复位反馈-未接收到*/
									SetPhySecDirectResetBack(secId, PHY_RESET_BACK_RECIVE_NO);
								}
								else
								{
									/*异常值*/
									SetPhySecDirectResetBack(secId, PHY_RESET_BACK_RECIVE_YES);
								}
							}
							
						}
						else
						{
							; /*其他接口不处理*/
						}
					}
				}
			}
			else
			{
				/*CI与AXIS通信中断，把AXIS设备状态导向安全侧*/
				dwCurCycNum = Get2oo2CurCycleNum();
				dwLastRecvAxisDataCycNum = GetCiTransmitRecvDataCycNum(localCiId, CI_SYSTEM_TYPE_AXIS, axisSysId);
				dwCommBadEnsureCount = GetCiAndAxleTransBadEnsureCnt();
				for (jj = 0u; jj < CollAxisDataStru[axisSysId].SectionSum; jj++)
				{
					secId = CollAxisDataStru[axisSysId].axisDataStr[jj].PhySecId;

					(void)SetPhySecCurAxisGdOccupyState(secId, SECTION_OCCUPY_FAULT);
					SetPhySecPreResetState(secId, PHYSICAL_SECTION_PRE_RESET_NO);	/*设置计轴预复位状态无效*/
					SetPhySecDirectResetState(secId, PHYSICAL_DIRECT_RESET_NO);	    /*设置计轴直接复位状态无效*/
					SetPhySecPreResetBack(secId, PHY_RESET_BACK_RECIVE_YES);
					SetPhySecDirectResetBack(secId, PHY_RESET_BACK_RECIVE_YES);
					
					if (dwCurCycNum == (dwLastRecvAxisDataCycNum + dwCommBadEnsureCount + 1U))
					{
						SetSecColOccupyStartCycNum(secId, dwCurCycNum);
					}
					else
					{
						/*仅通信中断当周期更新一次物理区段采集占用起始周期*/
					}
				}
			}

		}
	}
}

/*
* 功能描述： 处理OC到CI数据帧
* 参数说明： void
* 返回值  ： void
*/
void ProcessOcToCiData(void)
{
	UINT8 localCiId = 0u;					/*本地联锁ID*/

	UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT16 j = 0u;
	UINT16 ind = 0u;
	UINT16 kk = 0U;

	OcToCiOriginDataStruct * pTempOc = NULL;

	CollBoardData* pTempCollBoardData_ForProcess = NULL;

	UINT32 ciocBadComCycle = 0u;

	UINT32 curCycle = 0u;

	UINT8 deviceSum =0u;/*通信设备总数*/
	UINT8* deviceIdBuf = NULL;/*通信设备ID数组*/
	UINT8 transmitReval = 0U;
	UINT16 curSwapBoardNum = 0U; /*OC切系板卡数量*/
	UINT8  swapBoardId = 0U;/*OC切系板卡ID*/
	UINT16 deviceOCAndBoardId = 0U;/*切系板卡所属OC和板卡ID 高字节:OC ID 低字节:板卡ID*/
	UINT8 chSwitchZzjIndex = 0U;

	localCiId = GetSystemParaLocalCiId();

	ciocBadComCycle = GetCiAndOcTransmitBadEnsureCnt();

	curCycle = Get2oo2CurCycleNum();

	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_OC);     /*获取通信OC设备总数*/
	deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC); /*获取通信OC设备ID数组*/

	if ((deviceSum > 0u) && (deviceIdBuf != NULL))
	{/*参数有效性判断*/
		for (ii = 0u; ii < deviceSum; ii++)
		{/*遍历与本CI通信的OC系统*/
			/*更新与CI通信状态*/
			transmitReval = UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_OC, deviceIdBuf[ii]);
			if (CI_ERROR == transmitReval)
			{
				/*更新联锁通信状态失败*/
			}
		}
	}

	for (ii = 0u; ii < m_OcToCiOrginDataNum; ii++)
	{
		pTempOc = &m_OcToCiOrginDataArr[ii];

		if (GetCiIdByOcId(pTempOc->OcId) == localCiId)
		{
			if ((curCycle - pTempOc->ComStartCycle > ciocBadComCycle) ||
				(pTempOc->RecvErrorDevTypeCycle > ciocBadComCycle)
				)/*CI与OC通信超时，或者收到错误设备类型数据超过10个周期*/
			{
				debug_infor_printf((const)"OC_COM:break, com_cycle:%d  startCycle:%d RecvErrorDevTypeCycle:%d\n", Get2oo2CurCycleNum(), pTempOc->ComStartCycle, pTempOc->RecvErrorDevTypeCycle);
				/*1.把信号机采集置成红断 2.把道岔置成四开 3.把轨道区段融合状态置为占用 4.把继电器采集状态置为落下 */
				for (jj = 0u; jj < pTempOc->OcDeviceNum; jj++)
				{
					if (pTempOc->OcDevices[jj].DeviceType == OC_DEVICE_TYPE_SIGNAL)/*信号机*/
					{
						pTempOc->OcDevices[jj].DeviceState = OC_SIGNAL_SHOWCOLOR_RED_BREAK;/*红断*/
					}
					else if (pTempOc->OcDevices[jj].DeviceType == OC_DEVICE_TYPE_SWITCH)/*道岔*/
					{
						pTempOc->OcDevices[jj].DeviceState = OC_SWITCH_POSITION_SIKAI;/*四开*/
						for (chSwitchZzjIndex = 0U; chSwitchZzjIndex < pTempOc->OcDevices[jj].chSwitchIncldeZzjNum; chSwitchZzjIndex++)
						{
							pTempOc->OcDevices[jj].szSwitchIncldeZzjState[chSwitchZzjIndex] = OC_SWITCH_POSITION_SIKAI;
						}
					}
					else
					{
						/*不做处理*/
					}

				}

				/*把转换后的信号机数据重置状态*/
				for (jj = 0u; jj < CI_SIGNAL_MAX; jj++)
				{
					if (m_Signals[jj].OcId == pTempOc->OcId)
					{
						m_Signals[jj].DeviceState = OC_SIGNAL_SHOWCOLOR_RED_BREAK;/*红断*/
						  /*设置信号机板卡为故障*/
						for (j = 0U; j < 2U; j++)
						{
							m_Signals[jj].BoardState[j] = 0xffU;
						}
					}
				}
				/*把转换后的道岔数据重置状态*/
				for (jj = 0u; jj < CI_SWITCH_MAX; jj++)
				{
					if (m_Switches[jj].OcId == pTempOc->OcId)
					{
						m_Switches[jj].DeviceState = OC_SWITCH_POSITION_SIKAI;/*四开*/
						/*设置道岔板卡为故障*/
						for (j = 0U; j < MAX_OC_SWITCH_INCLUDE_BOARD_NUM; j++)
						{
							m_Switches[jj].BoardState[j] = 0xffU;
						}
					}
				}

				/*把轨道区段状态重置为占用*/
				for (jj = 0u; jj < m_GdNum; jj++)
				{
					if (m_Gds[jj].OcId == pTempOc->OcId)
					{/*通信超时，把AB两系和融合的状态置为区段故障*/
						m_Gds[jj].GdState1 = OC_GD_STATE_FAULT;
						m_Gds[jj].GdState2 = OC_GD_STATE_FAULT;
						m_Gds[jj].BoardState1 = (UINT8)0xff;
						m_Gds[jj].BoardState2 = (UINT8)0xff;
						m_Gds[jj].GdMergeState = OC_GD_STATE_FAULT;
					}
				}

				pTempCollBoardData_ForProcess = m_OcConvertedPtDataArr[pTempOc->OcId].BoardDatas;/*取转换后点位数据*/

				for (j = 0u; j < m_OcConvertedPtDataArr[pTempOc->OcId].OcBoardNum; j++)/*遍历所有的板卡*/
				{
					for (ind = 0u; ind < OC_COLL_BOARD_POS_NUM; ind++)
					{
						pTempCollBoardData_ForProcess[j].PosValueBuf[ind] = RELAY_STATE_DOWN;/*所有继电器落下OC_RELAY_DOWN*/
					}

				}

				pTempOc->PowerAState = (UINT8)0xff;
				pTempOc->PowerBState = (UINT8)0xff;
				pTempOc->OCDevFaultState = (UINT8)0xff;
				pTempOc->FanState = (UINT8)0xff;
				
				curSwapBoardNum = pTempOc->OCBoardSwapSysNum;
				pTempOc->OCBoardSwapSysNum = 0U;  /*OC切系板卡数初始化为零*/
				for (j = 0U; j < curSwapBoardNum; j++)
				{
					pTempOc->SwapSysBoardId[j] = 0U;
				}
				/*与OC通信中断，需清除屏蔽门清客确认箱PCB按钮记忆状态*/
				SetAllCleFarePCBButKeepSta(pTempOc->OcId,QK_PSD_BUTTON_STATE_UP);

				/*与OC通信中断，清除屏蔽门信息*/

				SetOcToCiDefaultDataStru(ii);

			}
			else
			{
				/*联锁与OC通信正常时，需要将OC的切系板卡相关信息报给ATS，报警提示切系的板卡*/
				curSwapBoardNum = pTempOc->OCBoardSwapSysNum;
				for (kk = 0U; kk < curSwapBoardNum; kk++)
				{
					swapBoardId = pTempOc->SwapSysBoardId[kk];
					deviceOCAndBoardId = (UINT16)((pTempOc->OcId << 8U)) + swapBoardId;
					if (0U != swapBoardId)
					{
						SetCiSendCmdBackInfoData(CI_BACK_OC_BOARD_SWAPSYS, CI_DEVICE_TYPE_OC_BOARD, deviceOCAndBoardId, 0U, 0U);/*反馈OC板卡切系*/
					}
				}
			}
		}
	}
}

/*
* 功能描述： 处理OC到CI的继电器数据
* 参数说明： void
* 返回值  ： 0:处理失败
*			 1:处理成功
*/
UINT8 ProcessOcToCiRelayData(void)
{
	UINT8 returnValue =CI_ERROR;
	CollBoardData* pTempCollBoardData_ForProcess = NULL;
	UINT8 BoardAddress_ForProcess = 0u;								/*板卡地址*/
	UINT8 cBoardState = RELAY_BOARD_FAULT_YES;  /*板卡状态初始化为故障*/
	UINT8 PosValue_ForProcess = 0u;									/*采集继电器当前地址的采集点数值:吸起、落下*/
	UINT16 RelayId = 0u;											/*当前采集地址和采集点位置对应的继电器ID*/
	UINT8 ColRelayInfo = 0u;											/*采集描述信息 确认是A系还是B系，是前采集还是后采集*/
	UINT8 i = 0u;
	UINT8 j = 0u;
	UINT16 ocId = 0u;
	UINT8 k = 0u;
	UINT16 kk = 0u;
	UINT16 relaySum = 0u;
	UINT8 SystemParaLocalCiId = 0u;                          /*本机联锁ID*/
	UINT8 RelayBelongCiId = 0u;
	UINT8 ProcessRelayCollState_ret = 0u;
	UINT8 funValue = 0u;

	for (i = 0u; i < OC_SUM_MAX; i++)                        /*指定ID继电器所属联锁ID*/
	{
		if (LocalOcIds[i] > 0u)/*oc id 有效*/
		{
			ocId = LocalOcIds[i];
			if (OC_SUM_MAX> ocId )
			{
				returnValue = CI_SUCCESS;
				pTempCollBoardData_ForProcess = m_OcConvertedPtDataArr[ocId].BoardDatas;
				for (j = 0u; j < m_OcConvertedPtDataArr[ocId].OcBoardNum; j++)/*遍历所有的OC板卡*/
				{
					BoardAddress_ForProcess = pTempCollBoardData_ForProcess[j].BoardAddress;/*板卡地址*/
					cBoardState = pTempCollBoardData_ForProcess[j].BoardState;  /*板卡状态*/

					for (k = 0u; k < BOARD_POS_MAX; k++)
					{
						PosValue_ForProcess = pTempCollBoardData_ForProcess[j].PosValueBuf[k];/*点值：吸起、落下*/
						RelayId = GetColRelayID((UINT8)ocId,BoardAddress_ForProcess, k);
						ColRelayInfo = GetColRelayInfo((UINT8)ocId,BoardAddress_ForProcess, k);/*采集信息：前节点A/前节点B/后节点A/后节点B*/
						if (0u != RelayId )/*继电器id不为0*/
						{
							if ((RELAY_STATE_UP == PosValue_ForProcess) || (RELAY_STATE_DOWN == PosValue_ForProcess))
							{
								switch (ColRelayInfo)
								{
								case RELAY_COLL_FORENODE_A:/*前节点A系*/
									SetRelayACollBoardState(RelayId, cBoardState);  /*设置A系板卡状态*/
									funValue = SetForeNodeACollState(RelayId, PosValue_ForProcess);
									if (CI_ERROR == funValue)
									{
										returnValue = CI_ERROR;
									}
									else
									{
									    ;
									}
									break;
								case RELAY_COLL_FORENODE_B:/*前节点B系*/
									SetRelayBCollBoardState(RelayId, cBoardState);  /*设置B系板卡状态*/
									funValue = SetForeNodeBCollState(RelayId, PosValue_ForProcess);
									if (CI_ERROR == funValue)
									{
										returnValue = CI_ERROR;
									}
									else
									{
									    ;
									}
									break;
								case RELAY_COLL_BACKNODE_A:/*后节点A系*/
									SetRelayACollBoardState(RelayId, cBoardState);  /*设置A系板卡状态*/
									funValue = SetBackNodeACollState(RelayId, PosValue_ForProcess);
									if (CI_ERROR == funValue)
									{
										returnValue = CI_ERROR;
									}
									else
									{
									    ;
									}
									break;
								case RELAY_COLL_BACKNODE_B:/*后节点B系*/
									SetRelayBCollBoardState(RelayId, cBoardState);  /*设置B系板卡状态*/
									funValue = SetBackNodeBCollState(RelayId, PosValue_ForProcess);
									if (CI_ERROR == funValue)
									{
										returnValue = CI_ERROR;
									}
									else
									{
									    ;
									}
									break;
								default:
									/*不可达分支*/
									break;
								}
							}
							else
							{
								returnValue = CI_ERROR;
							}
						}
						else
						{
							 ;
						}
						if (CI_ERROR == returnValue)
						{
							break;
						}
						else
						{
							 ;
						}
					}/*for (k=0;k<BOARD_POS_MAX;k++) 遍历pos*/

				}/*for (j=0;j<m_OcConvertedPtDataArr[ocId].OcBoardNum;j++) 遍历板卡*/

				if (CI_SUCCESS == returnValue)
				{
					relaySum = GetRelayCurSum();
					SystemParaLocalCiId = GetSystemParaLocalCiId();
					for (kk = 0u; kk < relaySum; kk++)
					{
						RelayId = GetRelayId(kk);
						RelayBelongCiId = GetRelayBelongCiId(RelayId);
						if (SystemParaLocalCiId == RelayBelongCiId)
						{
							ProcessRelayCollState_ret = ProcessRelayCollState(RelayId);
							/*非本联锁跳过*/
							if (CI_ERROR == ProcessRelayCollState_ret)
							{
								/*记录系统故障*/
#if 0 
								SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM,
									CI_DEVICE_TYPE_RELAY,
									RelayId,
									ETYPE_SYSTEM_REL_UPDATA_ERROR,
									CI_ERROR,
									ESEND_LEVEL_ZERO);
#endif
								debug_infor_printf((const)"Rleay %d ForeAndBackNode Coll Same \n",RelayId);
							}
							else
							{
								/*赋值下一个*/
							}
						}
						else
						{
							 ;
						}
					}
				}
				else
				{
				    ;
				}
			}
		}/*if (LocalOcIds[i]>0)oc id 有效*/
		else
		{
			;
		}
	}/*for (i=0;i<OC_SUM_MAX;i++) 遍历OC*/



	return returnValue;
}
#if 1
/*
* 功能描述： 处理ZC到CI数据
* 参数说明： void
* 返回值  ： void   
*/
void ProcessZcToCiData(void)
{
	UINT8* pZcMaskValueBuf = NULL;	/*zc发送过来的码位值数组*/
	UINT16 zcMaskValueLen = 0u;	/*zc发过来的码位数量*/
	UINT8 localCiId = 0u;					/*本地联锁ID*/
	UINT16 ii = 0u;
	UINT16 deviceId = 0u;
	UINT16 tmpPhyId = 0u;
	UINT8 reVal = CI_ERROR;	
	UINT32 secJumpLockDelayUnlockCount = 0u;/*区段跳跃锁闭延时解锁周期数*/
	UINT32 startTimeCycle = 0u;/*物理区段跳跃锁闭延时解锁起始周期数*/
	UINT8 dataValidFlag = 0u;	/*数据有效性标识：0u无效，1有效*/
	UINT8* sourceIdBuf = NULL;		/*源IDBuf*/
	UINT16 floodCurSum = 0u;/*防淹门当前数量*/
	UINT16 floodId = 0u;
	UINT8 dianshiLinshixiansuFlag = 0u;
	UINT8 jizhongqulsxsFlag = 0u;/*ZC通信中断后是否设置集中区临时限速开关 0x55设置 0xaa不设置*/
    UINT8 labourCancelLinShiXian = 0u;
	UINT16 signalCurSum = 0u;
	UINT16 logicSecCurSum = 0u;
	UINT16 axisSecCurSum = 0u;
	UINT16 phySecCurSum = 0u;
	UINT16 routeCurSum = 0u;
	UINT8 logSecLinShiXianSuSetState = 0u;
	UINT8 signalLinShiXianSuSetFlag = 0u;
	UINT8 phySecJumpDelayUnlockFlag = 0u;
	UINT8 belongCiId = 0u;
	UINT16 garagedoorSum = 0u;
	UINT8 hLHTHeadCtxValid =0u;
	UINT8 overTimeCheck = 0u;
	UINT32 curCycle = 0u;
	UINT8 virCINum = 0u;
	UINT8 virCIid = 0u;
	UINT8 kk = 0u;
	UINT8 jj = 0u;
	UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 signalLightExtinctRet = 0U;
	UINT8 axisSectionSum = 0U;/*物理区段对应计轴区段数目*/
	UINT16* pAxisSectionIdBuf = NULL;/*物理区段对应计轴区段ID*/
	UINT8 cTsrSureFlag = CI_TSR_SURE_NO;
	ZcToCiDataStruct* pZcToCiDataStru = NULL;  /*ZC信息数据结构体*/
	UINT8 indIcatorDevId = 0U; /*指示灯设备ID*/
	UINT16 wNonAutoReturnCurSum = 0U;/*无人折返当前总数*/

	localCiId = GetSystemParaLocalCiId();
	dianshiLinshixiansuFlag = GetCiFunctionSwitchConfig(FUNC_DIANSHI_LINSHIXIANSU_FLAG);
	jizhongqulsxsFlag = GetCiFunctionSwitchConfig(FUNC_JIZHONGQU_LINSHIXIASNSU_FLAG);
	curCycle = Get2oo2CurCycleNum();

	sourceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC);/*获取与本联锁通信的ZC的ID，目前一个联锁最多只与一个ZC通信*/

	if (sourceIdBuf != NULL)
	{
		/*更新与ZC通信状态*/
		(void)UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_ZC, sourceIdBuf[0]);

		reVal = CI_SUCCESS;
		hLHTHeadCtxValid = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_ZC, sourceIdBuf[0]); 
		if (CI_ERROR == hLHTHeadCtxValid)	/*不使用GetZcMaskZcId()来获取ZC ID，因为组包完给ZC数据就清空了*/
		{
			dataValidFlag = 0u;
		}
		else
		{/*消息有效*/
			dataValidFlag = 1u;
		}
		debug_infor_printf((const)"\n CurCycle:%d  ZcCiValidFlag:%d \n",curCycle,dataValidFlag);
		
		/*解析ZC码位信息*/
		zcMaskValueLen = GetZcMaskValueBufLen();
		pZcMaskValueBuf = GetZcMaskValueBuf();

		secJumpLockDelayUnlockCount = GetSysParaSecJLokDelayUnlockCyc();/*获取区段跳跃延时解锁周期数*/

		if ((0u == zcMaskValueLen) || (NULL == pZcMaskValueBuf))
		{/*未收到zc发送过来的码位数据*/

			/*if (GetCiTransmitState(CI_SYSTEM_TYPE_ZC, 0u) != TRANSMIT_STATE_GOOD)*/
			if (0u == dataValidFlag)
			{/*和ZC通信中断*/

				debug_infor_printf((const)"\n CurCycle:%d  ZcCiValidFlag:%d zcMaskValueLen:%d\n",curCycle,dataValidFlag,zcMaskValueLen);
				/*没有数据的码位处理*/
				signalCurSum =  GetSignalCurSum();
				for (ii = 0u; ii < signalCurSum; ii++)
				{
					deviceId = GetSignalId(ii);
					signalLightExtinctRet = SetSignalLightExtinctState(deviceId, SIGNAL_LIGHT_EXTICT_STATE_ALL_YES);/*设置信号机亮灯*/
					if (CI_ERROR == signalLightExtinctRet)
					{
						/*信号机设置亮灯失败*/
					}
					(void)SetSignalCrossState(deviceId, SIGNAL_CROSS_STATE_NO);/*设置信号机未跨压*/
					/*cgh-合并CID-2341-5：*/
					SetSigEngineerVehicleNearSte(deviceId, SIG_ENGINEERVEHICNEAR_STE_NO);/*信号机未跨压接近*/
				}
				logicSecCurSum = GetLogicSecCurSum();
				for (ii = 0u; ii <logicSecCurSum; ii++)
				{
					deviceId = GetLogicSecId(ii);
					SetLogSecOccupyState(deviceId, LOGICSECTION_OCCUPY_UT);/*设置逻辑区段UT占用*/
					SetLogSecTXOccupyState(deviceId, LOGICSECTION_OCCUPY_NO_TX);/*设置逻辑区段非通信车占用，m by yt 2022年5月19日*/
				}
				/*设置本联锁包含虚拟联锁人工取消临时限速状态*/
				if(FUNC_SWITCH_ON == includeVirFlag)
				{
					/*虚拟联锁兼容*/
					SetComBadLinShiXianSuState_Vir();
				}
				else
				{
					LabourCancelLSXianStaMoveProc(LINSHIXIANSU_COMM_BAD_STATE);  /*人工取消临时限速状态迁移处理*/
					/*取消支持点式临时限速时，对所有区段临时限速的设置*/

					labourCancelLinShiXian = GetLabourCancelLinShiXianState();
					if ((LINSHIXIANSU_COMM_BAD_STATE == labourCancelLinShiXian) && (HAVE_DIANSHILINSHIXIANSU == dianshiLinshixiansuFlag) && (HAVE_JZQ_LINSHIXIANSU == jizhongqulsxsFlag))
					{/*通信中断且未进行过人工取消  且支持点式临时限速  且设置集中区临时限速开关打开*/
						logicSecCurSum = GetLogicSecCurSum();
						for (ii = 0u; ii < logicSecCurSum; ii++)
						{
							deviceId = GetLogicSecId(ii);
							logSecLinShiXianSuSetState = GetLogSecLinShiXianSuSetState(deviceId);
							if (LOGSEC_LSXS_SET_STATE_INVALID != logSecLinShiXianSuSetState)
							{
								SetLogSecLinShiXianSuState(deviceId, LOGSEC_LSXS_SET_STATE_YES);/*设置逻辑区段有临时限速*/

								if (LOGSEC_LSXS_SET_STATE_YES != logSecLinShiXianSuSetState)
								{
									/* 之前没有限速，但现在有了，需要情况限速确认状态 */
									ClearLgcSecBelongRtXsCfm(deviceId);
								}
							}
						}
						signalCurSum = GetSignalCurSum();
						for (ii = 0u; ii < signalCurSum; ii++)
						{
							deviceId = GetSignalId(ii);
							signalLinShiXianSuSetFlag = GetSignalLinShiXianSuSetFlag(deviceId);

							SetSignalLinShiXianSuSetFlag(deviceId, SIGNAL_LINSHIXIANSUSET_STATE_YES);/*设置信号机有临时限速*/


						}
					}
					else
					{
						/*条件不满足，不设置集中区所有有效区段的临时限速*/
					}



				}
				axisSecCurSum = GetAxisSecCurSum();
				for (ii = 0u; ii < axisSecCurSum; ii++)
				{
					deviceId = GetAxisSecId(ii);
					SetAxisSecArbState(deviceId, AXIS_SECTION_ARB_NO);/*设置计轴区段未ARB*/

					SetAxisSecJumpLockApplyFlag(deviceId, AXIS_SECTION_JUMPLOCK_APPLY_NO);/*通信中断后设置计轴区段无跳跃锁闭申请*/
					(void)SetAxisSecJLockCancelApplyFlag(deviceId, AXSEC_CANCEL_JUMPLOCK_APPLY_NO);/*通信中断设置计轴区段无取消跳跃锁闭申请*/

					tmpPhyId = GetAxisSecRelativePhySecId(deviceId);
					SetPhySecArbState(tmpPhyId,AXIS_SECTION_ARB_NO);
				}
				phySecCurSum = GetPhySecCurSum();
				for (ii = 0u; ii < phySecCurSum; ii++)
				{
					deviceId = GetPhySecId(ii);
					SetPhySecStopSteadyFlag(deviceId, PHYSICAL_SECTION_STOPSTEADY_NO);/*设置物理区段未停稳*/

					phySecJumpDelayUnlockFlag =  GetPhySecJumpDelayUnlockFlag(deviceId);
					if (PHYSICAL_JUMPUNLOCK_DELAY_SET_NO == phySecJumpDelayUnlockFlag)/*如果未设置延时解锁起始周期号则设置*/
					{
						(void)SetPhySecJumpDelayUnlocStartCyc(deviceId,Get2oo2CurCycleNum());/*设置区段跳跃延时解锁起始周期号*/
						(void)SetPhySecJumpDelayUnlockFlag(deviceId,PHYSICAL_JUMPUNLOCK_DELAY_SET_YES);/*延时解锁标志置为已设置*/
					}			
				}
				routeCurSum = GetRouteCurSum();
				for (ii = 0u; ii < routeCurSum; ii++)
				{
					deviceId = GetRouteId(ii);
					belongCiId = GetRouteBelongCiId(deviceId);
					if(belongCiId == localCiId)
					{/*对本联锁进路进行处理*/
						SetRouteStopensureFlag(deviceId, ROUTE_STOPENSURE_NO);/*设置进路未收到保证停车*/

					}
				}
				garagedoorSum = GetGaragedoorSum();
				for (ii = 0u; ii < garagedoorSum; ii++)
				{
					deviceId = GetGaragedoorId(ii);
					SetGaragedoorAllowCloseFlag(deviceId, GARAGE_DOOR_ALLOW_CLOSE_NO);/*设置车库门未收到允许关闭*/
				}

				/*修改原因：联锁收到ZC的稳灯和闪灯命令时，需要保持该输出状态至通信中断或者新的命令，未收到新的稳灯和闪灯命令时，维持之前的输出状态*/
				/*设置本联锁包含虚拟联锁人工取消临时限速状态*/
				if(FUNC_SWITCH_ON == includeVirFlag)
				{/*	虚拟联锁兼容*/
					virCINum = GetVirtualCINum();
					for(kk = 0u;kk<virCINum;kk++)
					{
						virCIid = GetVirtualCIid(kk);
						for (jj = 0u; jj < RTNINDICATOR_SUM_MAX; jj++)
						{
							indIcatorDevId = GetVirCiRtnIndictDeviceId(virCIid, jj);
							/*设备ID对应且指示灯类型为无人折返灯*/
							/*清除闪灯和稳灯状态*/
							SetVirCIautoRtnIndictFlashState(indIcatorDevId,virCIid, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*闪灯状态置为无效*/
							SetVirCIautoRtnIndictSteadyState(indIcatorDevId,virCIid, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*稳灯状态置为无效*/
						}
					}
				}
				else
				{
					wNonAutoReturnCurSum = GetNonAutoReturnCurSum();
					for (ii = 0u; ii < wNonAutoReturnCurSum; ii++)
					{
						indIcatorDevId = GetNonReturnId(ii);
						/*清除闪灯和稳灯状态*/
						SetAutoRtnIndictFlashState(indIcatorDevId, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*闪灯状态置为无效*/
						SetAutoRtnIndictSteadyState(indIcatorDevId, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*稳灯状态置为无效*/
					}
				}

				floodCurSum = GetFloodGateCurSum();
				/*与zc通信中断*/
				for (ii=0u;ii<floodCurSum;ii++)
				{
					floodId = GetFloodGateId(ii);
					if (0u <floodId)
					{
						(void)SetFloodGateCurZCAgrCloseAck(floodId,FLOOD_GATE_NOT_ALLOWCLOSE_ZC);
					}
					
				}
			}
			/*else if( TRANSMIT_STATE_GOOD == GetCiTransmitState(CI_SYSTEM_TYPE_ZC, 0u))*/
			else if(1U == dataValidFlag)
			{/*和ZC通信良好*/

				/*与ZC通信恢复后，倒计时立即结束，维持动态测试防护锁闭状态*/
				phySecCurSum = GetPhySecCurSum();
				for (ii = 0u; ii < phySecCurSum; ii++)
				{
					deviceId = GetPhySecId(ii);
					(void)SetPhySecJumpDelayUnlocStartCyc(deviceId,0u);/*清除区段跳跃锁闭延时解锁起始周期号*/
					(void)SetPhySecJumpDelayUnlockFlag(deviceId,PHYSICAL_JUMPUNLOCK_DELAY_SET_NO);/*清除跳跃锁闭延时解锁设置标志*/
				}
				if(FUNC_SWITCH_ON == includeVirFlag)
				{
					 /*虚拟联锁兼容*/ 
					virCINum = GetVirtualCINum();
					for(kk = 0u;kk< virCINum;kk++)
					{
						virCIid = GetVirtualCIid((UINT8)ii);
						if(0u < virCIid)
						{
							LaborCancelLSXSXStaMoveProc_Vir(LINSHIXIANSU_COMM_GOOD_STATE,virCIid);  /*人工取消临时限速状态迁移处理*/
						}	
					}
				}
                else
				{
					LabourCancelLSXianStaMoveProc(LINSHIXIANSU_COMM_GOOD_STATE);/*人工取消临时限速状态迁移处理*/
				}
			}
			else
			{
				/*不处理*/
				;
			}

			reVal = CI_ERROR;
		}


		/*处理与ZC通信中断后解除物理区段跳跃锁闭状态*/
		phySecCurSum = GetPhySecCurSum();
		for (ii = 0u;ii < phySecCurSum;ii++)
		{
			deviceId = GetPhySecId(ii);
			startTimeCycle = GetPhySecJumpDelayUnlocStartCyc(deviceId);/*获取区段跳跃延时解锁起始周期号*/
			phySecJumpDelayUnlockFlag = GetPhySecJumpDelayUnlockFlag(deviceId);
			overTimeCheck = SystemOverTimeCheck(startTimeCycle,secJumpLockDelayUnlockCount);
			if((PHYSICAL_JUMPUNLOCK_DELAY_SET_YES == phySecJumpDelayUnlockFlag) && 
				(CI_TIME_OUT == overTimeCheck))
			{/*与ZC通信中断后，倒计时15s解锁全集中区的跳跃锁闭区段*/
				SetPhySecJumpLockState(deviceId,PHYSICAL_SECTION_JUMP_LOCK_NO);/*设置区段未跳跃锁闭*/
				SetPhySecJumpLockStateToZC(deviceId, PHYSICAL_SECTION_JUMP_LOCK_NO); /*设置给ZC的区段未锁闭*/

				axisSectionSum = GetPAxisSectionSum(deviceId);
				pAxisSectionIdBuf = GetPAxisSectionIdBuf(deviceId);
				if ((0U !=axisSectionSum) && (NULL != pAxisSectionIdBuf))
				{
					for (jj = 0; jj < axisSectionSum; jj++)
					{
						SetAxisJumpLockState(pAxisSectionIdBuf[jj], AXIS_SECTION_JUMPLOCK_STATE_IDLE);/*通信中断设置计轴区段跳跃锁闭状态为空闲*/
						(void)SetAxisSecJumpLockApplyCylce(pAxisSectionIdBuf[jj], 0U);/*清零计轴区段跳跃锁闭申请周期号*/
						SetAxisRelProSwitchLockSta(pAxisSectionIdBuf[jj], SWITCH_LOCK_PROTECT_CANCEL);/*取消防护锁闭*/
					}
				}
			}
		}

		if (reVal == CI_SUCCESS)
		{
			/*与ZC通信恢复后，倒计时立即结束，维持动态测试防护锁闭状态*/
			phySecCurSum = GetPhySecCurSum();
			for (ii = 0u; ii < phySecCurSum; ii++)
			{
				deviceId = GetPhySecId(ii);
				(void)SetPhySecJumpDelayUnlocStartCyc(deviceId,0u);/*清除区段跳跃锁闭延时解锁起始周期号*/
				(void)SetPhySecJumpDelayUnlockFlag(deviceId,PHYSICAL_JUMPUNLOCK_DELAY_SET_NO);/*清除跳跃锁闭延时解锁设置标志*/
			}
          /*虚拟联锁兼容*/ 
		  	if(FUNC_SWITCH_ON == includeVirFlag)
			{
				virCINum = GetVirtualCINum();
				for(ii = 0u;ii< virCINum;ii++)
				{
					virCIid = GetVirtualCIid((UINT8)ii);
					if(0u < virCIid)
					{
						LaborCancelLSXSXStaMoveProc_Vir(LINSHIXIANSU_COMM_GOOD_STATE,virCIid);  /*人工取消临时限速状态迁移处理*/
					}
				}
			}
			else
			{
				LabourCancelLSXianStaMoveProc(LINSHIXIANSU_COMM_GOOD_STATE);/*人工取消临时限速状态迁移处理*/
			}
			if (CI_ERROR == MaskDataProcess(CI_SYSTEM_TYPE_ZC, pZcMaskValueBuf, zcMaskValueLen))
			{/*解析码位数据错误*/
			}

		}

		/*处理ZC发送的临时限速信息*/
		if (reVal == CI_SUCCESS)
		{
			cTsrSureFlag = GetTsrSureFlag();
			pZcToCiDataStru = GetZcToCiDataStru();
			if (NULL != pZcToCiDataStru)
			{
				if ((1u == dataValidFlag) && (ZC_TSR_VALID == pZcToCiDataStru->tsrInputInfoStru.cTsrValidFlag))
				{
					/*临时限速确认标志*/
					if (CI_TSR_SURE_YES != cTsrSureFlag)
					{
						SetTsrSureFlag(CI_TSR_SURE_YES);
					}
					reVal = SetLocalTsrData(pZcToCiDataStru->tsrInputInfoStru.cTsrSum, pZcToCiDataStru->tsrInputInfoStru.szTsrInfo,
						pZcToCiDataStru->tsrInputInfoStru.cAllLineTsrState, pZcToCiDataStru->tsrInputInfoStru.cAllLineTsrSpeed);
				}
			}
			else
			{
				reVal = CI_ERROR;
			}
		}

		/*处理ZC发送的紧急制动信息*/
		if (reVal == CI_SUCCESS)
		{
			if (NULL != pZcToCiDataStru)
			{
				if ((1u == dataValidFlag) &&
					((0x55U == pZcToCiDataStru->esbInputInfoStruct.cWlbValidFlag) || (0xAAU == pZcToCiDataStru->esbInputInfoStruct.cWlbValidFlag)))
				{
					WlbZcCmdProc(pZcToCiDataStru->esbInputInfoStruct.cWlbValidFlag, pZcToCiDataStru->esbInputInfoStruct.cSecEbSum, pZcToCiDataStru->esbInputInfoStruct.wEbPhySecId);
				}
				else
				{
					; /*数据无效*/
				}
			}
			else
			{
				reVal = CI_ERROR;
			}
		}

		/*处理ZC发送的雨雪模式信息*/
		if (reVal == CI_SUCCESS)
		{
			if ((1u == dataValidFlag)&&(ZC_TSR_VALID == pZcToCiDataStru->tsrInputInfoStru.cTsrValidFlag))
			{
				if ((CI_ALL_SNOW_VALID == pZcToCiDataStru->cSnowValidFlag) || (CI_ALL_SNOW_UNVALID == pZcToCiDataStru->cSnowValidFlag))
				{
					/* 设置雨雪模式 */
					SetAllSnowModel(pZcToCiDataStru->cSnowValidFlag);
					SetLocalAreaSnowInfo(pZcToCiDataStru->cAreaSnowPlatFormNum, pZcToCiDataStru->szAreaSnowInfo);  /*更新本地区间雨雪状态信息*/
					SetLocalSnowModel(pZcToCiDataStru->chLocalSnowValidFlag);
				}
			}
			else
			{
				reVal = CI_ERROR;
			}
		}
		else
		{
			;
		}

		/*处理ZC发送的ITE全线切除信息*/
		if (reVal == CI_SUCCESS)
		{
			if ((1u == dataValidFlag) && (ZC_TSR_VALID == pZcToCiDataStru->tsrInputInfoStru.cTsrValidFlag) && ((CI_ITE_LINE_CUT_VALID == pZcToCiDataStru->cIteLineCutState)
				|| (CI_ITE_LINE_CUT_INVALID == pZcToCiDataStru->cIteLineCutState) || (CI_ITE_LINE_CUT_DEFAULT == pZcToCiDataStru->cIteLineCutState)))
			{
				/* 设置ITE全线切除状态 */
				SetIteLineCutState(pZcToCiDataStru->cIteLineCutState);
				/* 设置区间ITE切除信息 */
				SetLocalAreaIteCutInfo(pZcToCiDataStru->cAreaIteCutNum, pZcToCiDataStru->szAreaIteCutId);
			}
			else
			{
				reVal = CI_ERROR;
			}
		}
		else
		{
			/*不处理*/
		}
	}
}
#endif

/*
* 功能描述： 处理TMC到TIOC数据
* 参数说明： void
* 返回值  ： void
*/
void ProcessTmcToTiocData(void)
{
	UINT8 cRetVal = CI_ERROR;
	UINT8 cLocalTiocId = 0u;
	UINT8 cTsrSureFlag = CI_TSR_SURE_NO;
	TmcToTiocDataStruct* pTmcInputData = NULL;
	UINT8 deviceSum = 0u;
	UINT8* deviceIdBuf = NULL;
	UINT8 ii = 0u;
	UINT8 cTransState = 0U;  /*与TMC通信状态*/

	/*手动更新TMC通信状态*/
	cLocalTiocId = GetSystemParaLocalCiId();
	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_TMC); /*获取通信TMC设备总数*/
	deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_TMC); /*获取通信TMC设备ID数组*/
	if ((0u != cLocalTiocId) && (0u != deviceSum) && (TRANSMIT_OBJECT_DEVICE_SUM_MAX >= deviceSum) && (NULL != deviceIdBuf))
	{
		for (ii = 0u; ii < deviceSum; ii++)
		{
			cRetVal = UpdateCiTransmitState(cLocalTiocId, CI_SYSTEM_TYPE_TMC, deviceIdBuf[ii]);
		}
		/* 通信状态不影响处理，该分支为成功 */
		cRetVal = CI_SUCCESS;

		cTransState = GetCiTransmitState(CI_SYSTEM_TYPE_TMC, deviceIdBuf[0]);  /*RC仅与一个TMC通信*/

		if (TRANSMIT_STATE_GOOD == cTransState)
		{
			/*与TMC通信正常，不处理*/
		}
		else
		{
			ClearLineCommTrainData();  /*与TMC通信中断，清除本地存储的全线通信车信息*/
		}
	}
	else
	{
		cRetVal = CI_ERROR;
	}


	if (CI_SUCCESS == cRetVal)
	{

		/* 判断是否收需要更新TMC发送的临时限速信息 */
		pTmcInputData = GetTmcToTiocData();
		cTsrSureFlag = GetTsrSureFlag();

		if (NULL != pTmcInputData)
		{
			if (0x55u == pTmcInputData->tsrInputInfoStru.cTsrValidFlag)
			{
				/* 取消限速确认 */
				if (CI_TSR_SURE_YES != cTsrSureFlag)
				{
					SetTsrSureFlag(CI_TSR_SURE_YES);
				}
				/* 收到TMC发送的临时限速有效信息,更新临时限速 */
				cRetVal = SetLocalTsrData(pTmcInputData->tsrInputInfoStru.cTsrSum, pTmcInputData->tsrInputInfoStru.szTsrInfo, pTmcInputData->tsrInputInfoStru.cAllLineTsrState, pTmcInputData->tsrInputInfoStru.cAllLineTsrSpeed);
			}
			else
			{
				/* 未收到有效信息，保持之前的限速 */
			}
		}
		else
		{
			cRetVal = CI_ERROR;
		}
	}

	/* 处理雨雪模式 */
	if (CI_SUCCESS == cRetVal)
	{
		if (0x55u == pTmcInputData->tsrInputInfoStru.cTsrValidFlag)
		{
			if ((CI_ALL_SNOW_VALID == pTmcInputData->cSnowValidFlag) || (CI_ALL_SNOW_UNVALID == pTmcInputData->cSnowValidFlag))
			{
				/* 设置雨雪模式 */
				SetAllSnowModel(pTmcInputData->cSnowValidFlag);
				SetAllSnowLevel(pTmcInputData->cSnowLevel);
				SetLocalAreaSnowInfo(pTmcInputData->cAreaSnowPlatFormNum, pTmcInputData->szAreaSnowInfo);  /*更新本地区间雨雪状态信息*/
			}
		}		
	}

	/* 处理ITE全线切除状态 */
	if (CI_SUCCESS == cRetVal)
	{
		if ((0x55U == pTmcInputData->tsrInputInfoStru.cTsrValidFlag) && ((CI_ITE_LINE_CUT_VALID == pTmcInputData->cIteLineCutState) || (CI_ITE_LINE_CUT_INVALID == pTmcInputData->cIteLineCutState)))
		{
			/* 设置ITE全线切除状态 */
			SetIteLineCutState(pTmcInputData->cIteLineCutState);
			/* 设置区间ITE切除信息 */
			SetLocalAreaIteCutInfo(pTmcInputData->cAreaIteCutNum, pTmcInputData->szAreaIteCutId);
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		/*不处理*/
	}

	/*处理全线通信车信息*/
	if (CI_SUCCESS == cRetVal)
	{
		if (0x55U == pTmcInputData->tsrInputInfoStru.cTsrValidFlag)
		{
			/*更新全线通信车信息*/
			ProcessLineCommTrainData(pTmcInputData->cLineCtNum, pTmcInputData->szLineCtId);
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		/*不处理*/
	}

	/* 处理结束，清除输入数据 */
	ClearTmcToTiocData();
}
/*
* 功能描述： 处理VOBC到CI数据
* 参数说明： void
* 返回值  ： void    
* 修复bug YF0083-100、219
*/
void ProcessVobcToCiData(void)
{
	UINT8 ii = 0u;
	UINT8 jj = 0u;
	UINT8 kk = 0u;
	UINT16 wRouteIndex = 0u;
	UINT16 wRouteSum = 0u;
	UINT8 vobcToCiDataSum = GetVobcToCiSum();
	VobcToCiDataStruct* vobcToCiDataStru = GetVobcToCiDataStru();
	UINT8 chLineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*获取线路标识*/
	UINT8 dataValid = 0u;
	UINT8 bufIndex = 0u;
	UINT16 psdId = 0u;
	UINT8 localCiId = 0u;
	UINT8 belongCiId = 0u;
	UINT8 deviceSum =0u;/*通信设备总数*/
	UINT8* deviceIdBuf = NULL;/*通信设备ID数组*/
	UINT8 platformId = 0u;
	UINT16 platformPsdId = 0u;
	UINT16 wRouteId = 0u;
	UINT16 wTrainId = 0u;
	UINT32 dwDelayTime = 0u;
	UINT32 dwVobcBrkTime = 0u;
	UINT16 phySecCurSum = 0u;
	UINT16 deviceId = 0u;
	UINT8 funRet = CI_ERROR;
	UINT8 getResult = CI_ERROR;
	UINT8 chRCMode = GetLocalRcWorkMode();
	UINT32 dwCurCycNum = 0U;
	UINT32 dwTransmitBadEnsureCount = 0U;  /*CI与VOBC通信中断判断时间*/
	UINT8 cTrainReportState = 0U;
	UINT8 cCheckFlag = CI_ERROR;

	localCiId = GetSystemParaLocalCiId();
	dwCurCycNum = Get2oo2CurCycleNum();
	dwTransmitBadEnsureCount = GetCiAndVobcTransBadEnsureCnt();

	if (LINE_CC == chLineIdentity)
	{
		ClearTrainCanUctFlag();
	}
	else
	{
		; /* 非车车线路不处理包络 */
	}
	/*VOBC故障隔离PSD请求信息处理*/
	for(bufIndex = 0u;bufIndex < PSD_SUM_MAX;bufIndex++)
	{/*遍历PSD结构体*/
		psdId = PsdDataStru[bufIndex].PsdId;

		if (GetPsdBelongCiId(psdId) == localCiId)
		{/*属于本联锁的PSD才处理*/
			if ((dwCurCycNum - PsdDataStru[bufIndex].CmdSetCycle) > dwTransmitBadEnsureCount)
			{/*当前PSD超过GetCiAndVobcTransBadEnsureCnt()未收到的任何VOBC关于该PSD的控制信息（含打开、关闭和查询），则清除该PSD的故障隔离请求*/
				PsdDataStru[bufIndex].SrcVobcId = 0u;
				PsdDataStru[bufIndex].PsdCmd = PSD_DEFAULT_CONTROL_CMD;
				PsdDataStru[bufIndex].CmdSetCycle = 0u;
				PsdDataStru[bufIndex].psdEditGroupInfo = 0u;/*清除编组信息*/
				PsdDataStru[bufIndex].VOBCDoorState = PSD_DOOR_CLOSEDANDLOCKED_INVALID;
				deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PLATFORM);     /*获取通信PSD设备总数*/
				deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PLATFORM); /*获取通信PSD设备ID数组*/
				if ((deviceSum > 0u) && (deviceIdBuf != NULL))
				{/*参数有效性判断*/
					for (ii = 0u;ii < deviceSum;ii++)
					{/*遍历与本CI通信的站台门系统*/
						platformId = deviceIdBuf[ii];
						for (jj = 0u;jj < platformToCiDataStru[platformId].psdSum;jj++)
						{/*遍历站台门系统包含的PSD数目*/
							platformPsdId = platformToCiDataStru[platformId].psdDataStr[jj].PsdId;
							if (psdId == platformPsdId)
							{/*查找到相应的站台门系统，清除车门信息和VOBC发送的故障隔离请求信息*/
								platformToCiDataStru[platformId].psdDataStr[jj].doorHaveOrNot = PSD_HAVE_TRAIN_DOOR_NO;/*与VOBC通信中断后，把有无车门信息置为无车门*/
								platformToCiDataStru[platformId].psdDataStr[jj].faultIsolationRequestInfo = 0u;/*与VOBC通信中断后，将VOBC隔离PSD的请求设为无隔离*/
								platformToCiDataStru[platformId].psdDataStr[jj].doorEditGroupInfo = 0u;  /*清除编组信息*/
							}
						}
					}
				}
			}
		}
	}

	if (RC_WORK_MODE_TIOC == chRCMode)
	{/*TIOC*/
		
	 /* 清除之前的停车保证信息和资源取消申请信息 */
		phySecCurSum = GetPhySecCurSum();
		for (ii = 0u; ii < phySecCurSum; ii++)
		{
			deviceId = GetPhySecId(ii);
			SetPhySecStopSteadyFlag(deviceId, PHYSICAL_SECTION_STOPSTEADY_NO);/*设置物理区段未停稳*/			
		}
		wRouteSum = GetRouteCurSum();
		for (wRouteIndex = 0u; wRouteIndex < wRouteSum; wRouteIndex++)
		{
			wRouteId = GetRouteId(ii);
			belongCiId = GetRouteBelongCiId(wRouteId);
			if (belongCiId == localCiId)
			{
				/*设置进路未收到保证停车*/
				SetRouteStopensureFlag(wRouteId, ROUTE_STOPENSURE_NO);

				/*设置进路不允许资源取消*/
				SetRouteResourceCancelFlag(wRouteId, ROUTE_RESOURCECANCEL_NO);
			}
			else
			{
				/*不处理*/
			}
		}
	}
	else if (RC_WORK_MODE_CI == chRCMode)
	{/*CI*/
		/*停车保证信息来自ZC码位*/
	}
	else
	{
		/*无处理*/
	}
	

	for (ii = 0u; ii < vobcToCiDataSum; ii++)
	{
		wTrainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + vobcToCiDataStru[ii].VobcId;
		if (LINE_FAO == chLineIdentity)/*FAO线路*/
		{/*判断VOBC与CI通信中断*/
			if((dwCurCycNum - vobcToCiDataStru[ii].ComStartCycle) > dwTransmitBadEnsureCount)
			{
				dataValid = 0u;
			}
			else
			{
				dataValid = 1u;
			}


		} 
		else if ((LINE_HLHT == chLineIdentity) || (LINE_FAOHLHT == chLineIdentity) || (LINE_FAOHLHT_ONESELF == chLineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == chLineIdentity))/*互联互通线路或（互联互通+FAO）线路*/
		{
			/*互联互通线路使用消息剩余有效期来判断CI与VOBC通信是否中断*/
			getResult = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru[ii].VobcId));
			if (CI_ERROR == getResult)
			{
				dataValid = 0u;
			}
			else
			{/*消息有效*/
				dataValid = 1u;
			}
		}
		else if (LINE_CC == chLineIdentity)
		{
			/* 车车线路 */
			dwDelayTime = GetVobcMsgDelayTime(wTrainId);
			dwVobcBrkTime = GetCiAndVobcTransBadEnsureTime();
			if (dwDelayTime > dwVobcBrkTime)
			{
				dwDelayTime = dwVobcBrkTime;
			}
			funRet = SetTrainMsgDelayTime(wTrainId, dwDelayTime);
			/*互联互通线路使用消息剩余有效期来判断CI与VOBC通信是否中断*/
			getResult = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru[ii].VobcId));
			if ((CI_ERROR == getResult) || (CI_ERROR == funRet))
			{
				dataValid = 0u;
			}
			else
			{/*消息有效*/
				dataValid = 1u;
			}
		}
		else
		{
			/*线路类型错误*/
		}

		if (1u == dataValid)
		{
			if (dwCurCycNum == vobcToCiDataStru[ii].ComStartCycle)
			{
				/*处理PSD命令*/
				for (jj = 0u; ((jj < vobcToCiDataStru[ii].PsdSum) && (jj < VOBC_TO_CI_TRAIN_PSD_MAX)); jj++)
				{
					/*之前本段代码是实现现地站台门显示绿点的需求，目前暂无此需求，所以注释掉本段代码*/
#if 0
				/*添加给现地反馈*/
					SetCiSendCmdBackInfoData(CI_BACK_TRAIN_DOOR_STATE, CI_DEVICE_TYPE_PSD, vobcToCiDataStru[ii].PsdData[jj].PsdId, 0u, 0u);
#endif
					/*由于新机场线VOBC和CI一直通信，导致故障隔离信息无法清除，故在此检查收到最后一次VOBC的控制命令是否超时*/
					if ((dwCurCycNum - vobcToCiDataStru[ii].PsdData[kk].CmdStartCycNum) > dwTransmitBadEnsureCount)
					{
						ClearPsdVobcContext(vobcToCiDataStru[ii].VobcId);
						break;
					}
					if (vobcToCiDataStru[ii].PsdData[jj].PsdId != PSD_INVALID_ID)
					{/*PSD ID有效*/
						if ((LINE_FAOHLHT == chLineIdentity) || (LINE_FAOHLHT_ONESELF == chLineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == chLineIdentity))
						{
							switch (vobcToCiDataStru[ii].PsdData[jj].CmdType)
							{
							case VOBCTOCI_COMMAND_TYPE_PSDOPEN:/*开门命令*/
								SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDOPEN);
								if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u)
								{
									if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX)
									{
										PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo;
									}
								}
								break;
							case VOBCTOCI_COMMAND_TYPE_PSDCLOSE:/*关门命令*/
								SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDCLOSE);
								if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u)
								{
									if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX)
									{
										PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo;
									}
								}
								break;
							case VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT:/*查询命令*/
								SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT);
								if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u)
								{
									if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX)
									{
										PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo;
									}
								}
								break;
							default:
								/*查询命令或错误命令*/
								break;
							}

							/*间隙探测处理：停止间隙探测；记录间隙探测开始时间*/
							if (VOBC_CI_GAP_DETECT_CMD_START == vobcToCiDataStru[ii].PsdData[jj].gapDetectCmd)
							{/*启动间隙探测*/
								/*设置启动探测有效，停止探测无效*/
								SetStartDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_START_DETECTION_YES);
								SetStopDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_STOP_DETECTION_NO);
							}
							else if (VOBC_CI_GAP_DETECT_CMD_STOP == vobcToCiDataStru[ii].PsdData[jj].gapDetectCmd)
							{/*停止间隙探测*/
								/*设置停止探测有效，启动探测无效*/
								SetStartDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_START_DETECTION_NO);
								SetStopDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_STOP_DETECTION_YES);
							}
							else
							{
								/*do nothing*/
							}

							/*间隙探测处理：CI收到VOBC车门关闭且锁闭车门状态，驱动车门关门继电器*/
							if (VOBC_CI_DOOR_CLOSEDANDLOCKED == vobcToCiDataStru[ii].PsdData[jj].VOBCDoorState)
							{/*车门关闭且锁闭设置屏蔽门的VOBC车门状态关闭且锁闭*/
								SetVOBCDoorState(vobcToCiDataStru[ii].PsdData[jj].PsdId, PSD_DOOR_CLOSEDANDLOCKED_VALID);
							}
							else if (VOBC_CI_DOOR_NOTCLOSEDANDLOCKED == vobcToCiDataStru[ii].PsdData[jj].VOBCDoorState)
							{/*车门关闭且锁闭设置屏蔽门的VOBC车门状态未关闭且锁闭*/
								SetVOBCDoorState(vobcToCiDataStru[ii].PsdData[jj].PsdId, PSD_DOOR_CLOSEDANDLOCKED_INVALID);
							}
							else
							{
								/*do nothing*/
							}
						}
						else if ((LINE_HLHT == chLineIdentity) || (LINE_FAO == chLineIdentity))
						{
							switch (vobcToCiDataStru[ii].PsdData[jj].CmdType)
							{
							case VOBCTOCI_COMMAND_TYPE_PSDOPEN:
								SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDOPEN);
								if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u)
								{
									if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX)
									{
										PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo;
									}
								}
								break;
							case VOBCTOCI_COMMAND_TYPE_PSDCLOSE:
								SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDCLOSE);
								if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u)
								{
									if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX)
									{
										PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo;
									}
								}
								break;
							case VOBCTOCI_COMMAND_TYPE_PSDCHECK:
								SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDCHECK);
								if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u)
								{
									if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX)
									{
										PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo;
									}
								}
								break;
							default:
								/*查询命令或错误命令*/
								break;
							}
						}
						else
						{
							/*线路类型错误*/
						}
#if 0
						if ((VOBCTOCI_COMMAND_TYPE_PSDCLOSE == vobcToCiDataStru[ii].PsdData[jj].CmdType) &&
							(PSD_STATE_OPEN == GetPsdState(vobcToCiDataStru[ii].PsdData[jj].PsdId)) &&
							(0u == GetStartDetectionCycNum(vobcToCiDataStru[ii].PsdData[jj].PsdId)))
						{   /*屏蔽门状态为打开，此时收到车发送的关门命令且还没开始倒计时*/
							/*满足启动探测条件，则设置启动探测有效，停止探测无效*/
							SetStartDetectionCycNum(vobcToCiDataStru[ii].PsdData[jj].PsdId, Get2oo2CurCycleNum());
							SetStartDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_START_DETECTION_YES);
							SetStopDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_STOP_DETECTION_NO);
						}
#endif

					}
				}
			}
			else
			{
				/*当周期未收到车数据，不处理*/
			}

			if((LINE_FAO == chLineIdentity) && (dwCurCycNum == vobcToCiDataStru[ii].ComStartCycle))/*FAO线路*/
			{
				FAOVOBCDataProc(&(vobcToCiDataStru[ii]));/*仅当周期处理FAOVOBC（洗车机）数据*/
			}
			else if (LINE_HLHT == chLineIdentity)/*互联互通线路*/
			{
				HLHTVOBCDataProc(&(vobcToCiDataStru[ii]));
			}
			else if ((LINE_FAOHLHT == chLineIdentity) || (LINE_FAOHLHT_ONESELF == chLineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == chLineIdentity))/*互联互通+FAO线路*/
			{
				HLHTFAOVOBCDataProc(&(vobcToCiDataStru[ii]));
			}
			else if (LINE_CC == chLineIdentity)
			{
				IvocInputDataProcCC(&(vobcToCiDataStru[ii])); /*处理（车车） IVOC数据*/
				cTrainReportState = GetTrainReportState(vobcToCiDataStru[ii].VobcId);
				if (BIT_VAL_00000001B == ((cTrainReportState >> 3U) & BIT_VAL_00000001B))
				{
					cCheckFlag = CI_SUCCESS;  /*处于MMI本地湿轨，标志置成功*/
				}
				else
				{
					/*不处于MMI本地湿轨，不处理*/
				}
			}
			else
			{
				/*目前支持三种接口：FAO接口、HLHT接口、（FAO+HLHT）接口，在dataValid有效的前提下，该分支无意义*/
			}
		}
		else
		{	
			if ((LINE_FAO == chLineIdentity) || (LINE_HLHT == chLineIdentity) || (LINE_FAOHLHT == chLineIdentity) || (LINE_FAOHLHT_ONESELF == chLineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == chLineIdentity))
			{
				/*从PSD数据中删除该VOBC产生的上下文信息*/
				ClearPsdVobcContext(vobcToCiDataStru[ii].VobcId);

				/*出清列车发送的停稳信息*/
				ClearVobcStopSteadyData(vobcToCiDataStru[ii].VobcId);

				/*清除洗车机VOBC的驱动状态*/
				ClearWashVobcDriveState(&(vobcToCiDataStru[ii]));

				/*清除列车接口信息*/
				VobcConnectDataClear(vobcToCiDataStru[ii].VobcId);
			}
			else if (LINE_CC == chLineIdentity)
			{
				/*从PSD数据中删除该VOBC产生的上下文信息*/
				ClearPsdVobcContext(vobcToCiDataStru[ii].VobcId);
				ProcessIvocLoseCom(vobcToCiDataStru[ii]);

				/*清除洗车机VOBC的驱动状态*/
				ClearWashVobcDriveState(&(vobcToCiDataStru[ii]));

				/*清除列车接口信息*/
				VobcConnectDataClear(vobcToCiDataStru[ii].VobcId);
			}
			else
			{
				; /*其他线路号暂不处理*/
			}
			/*删除该VOBC到CI的数据*/
			(void)RemoveVobcToCiMsgAt((UINT8)ii);
			ii--;
			vobcToCiDataSum = GetVobcToCiSum();
		}
	}

	if (CI_SUCCESS == cCheckFlag)
	{
		/*存在列车处于MMI本地湿轨状态，设置本地湿轨有效*/
		SetLocalSnowModel(CI_LOCAL_SNOW_VALID);
	}
	else
	{
		/*无列车处于MMI本地湿轨状态，设置本地湿轨无效*/
		SetLocalSnowModel(CI_LOCAL_SNOW_UNVALID);
	}
}

/*
* 功能描述： 处理后备模式VOBC到CI数据
* 参数说明： void
* 返回值  ： void
* 修复bug YF0083-100、219
*/
void ProcessVobcBackupToCiData(void)
{
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT8 backUpValid = CI_ERROR;
	UINT8 mainValid = CI_ERROR;
	UINT16 psdId = 0U;      /*psd ID*/
	UINT8 psdCmdType = 0U;  /*psd 控制命令*/
	UINT16 wBufIndex = 0u;   /*屏蔽门索引*/
	UINT16 trainId = 0U;   /*获取列车ID*/
	UINT32 curCycNum = 0U;
	UINT32 dwRcvCycNum = 0U;
	UINT8 headCheck = CI_ERROR;
	UINT8 psdCmdCode = 0U;	

	curCycNum = Get2oo2CurCycleNum();
	for (ii = 0U; ii < VOBC_BACKUP_TO_CI_SUM_MAX; ii++)
	{
		if (0U != VobcBackUpToCiDataStru[ii].VobcId)
		{
			/*使用互联互通头来判断CI与VOBC后备通信是否有效*/
			backUpValid = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(VobcBackUpToCiDataStru[ii].VobcId));
			/*使用互联互通头来判断CI与VOBC主用通信是否有效*/
			mainValid = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC, (UINT8)(VobcBackUpToCiDataStru[ii].VobcId));
			trainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC_BACKUP * 256U)) + VobcBackUpToCiDataStru[ii].VobcId;
			dwRcvCycNum = VobcBackUpToCiDataStru[ii].ComStartCycle;

			/*主用通信失效且后备通信有效的时候才设置后备通道数据*/
			if((CI_SUCCESS != mainValid) && ( CI_SUCCESS == backUpValid))
			{
				/*	vobdid有效 通信有效 设置屏蔽门控制命令*/
				if (dwRcvCycNum == curCycNum)
				{
					/*站台门开门码 做列车编组信息分析*/
					psdCmdCode = VobcBackUpToCiDataStru[ii].psdCmdCode;

					for (jj = 0U; jj < VobcBackUpToCiDataStru[ii].PsdSum; jj++)
					{
						psdId = VobcBackUpToCiDataStru[ii].PsdData[jj].PsdId;
						psdCmdType = VobcBackUpToCiDataStru[ii].PsdData[jj].CmdType;
						wBufIndex = GetPsdConfigBufIndex(psdId);  /*获取指定ID屏蔽门索引*/
						if ((0u < wBufIndex) && (PSD_SUM_MAX > wBufIndex))
						{
							if ((VOBCTOCI_COMMAND_TYPE_PSDOPEN == psdCmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == psdCmdType))
							{
								SetPsdVobcCmd(psdId, trainId, psdCmdType);
								PsdDataStru[wBufIndex].psdEditGroupInfo = psdCmdCode;
							}
							else
							{
								;  /*不处理*/
							}
						}
						else
						{
							;  /*不处理*/
						}
					}

					/*后备通道接口数据处理*/
					VobcBackUpConnectDataProc(&VobcBackUpToCiDataStru[ii]);

					/*后备车停稳信息处理*/
					BackupStopSteadyDataProc(&VobcBackUpToCiDataStru[ii]);

				}
			}
			else
			{			
				/*从PSD数据中删除该后备通道vobc产生的上下文信息*/
				ClearPsdVobcContext(trainId);

				/*判断是否初始通信帧*/
				headCheck = BackupHeadCheckValid(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(VobcBackUpToCiDataStru[ii].VobcId));

				if ((CI_SUCCESS != backUpValid) && (CI_SUCCESS != mainValid))
				{
					/*主备都故障清除前车后备接口信息*/
					VobcConnectDataClear(VobcBackUpToCiDataStru[ii].VobcId);
				}
				else
				{
					;  /*不处理*/
				}

				if ((CI_SUCCESS != headCheck)&& (CI_SUCCESS != backUpValid))
				/*非初始帧且后备通信校验失败*/
				{
					(void)memset(&(VobcBackUpToCiDataStru[ii]), 0, sizeof(VobcBackUpToCiDataStruct));/*清内存，防止脏数据*/
				}
			}
		}
		else
		{
			; /*不处理*/
		}
	}
}

/*
* 功能描述： 处理PSD到CI数据
* 参数说明： void
* 返回值  ： void    
*/
void ProcessPlatformToCiData(void)
{
	UINT8 stationSum = 0u;
	UINT8 * idBuf = NULL;
	UINT8 ii;
	UINT8 transmitState = 0u;
	stationSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PLATFORM);  /*获取和CI系统通信的站台屏蔽门系统个数*/
	idBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PLATFORM);     /*获取和CI系统通信的站台屏蔽门系统的ID数组*/
	for(ii = 0u;ii < stationSum;ii++)
	{
		transmitState = GetCiTransmitState(CI_SYSTEM_TYPE_PLATFORM,idBuf[ii]);/*获取与当前PSD的通信状态*/
		if(TRANSMIT_STATE_GOOD != transmitState)
		{/*若当前通信故障，则将数据导向安全*/
			(void)SetPlatformToCiDefaultDataStru(idBuf[ii]);
		}
	}
}


/*
* 功能描述：处理PSC系统数据
* 参数说明： void
* 返回值  ： void    
*/
void ProcessPscToCiData(void)
{
	UINT8 ii = 0u;
	UINT8 jj = 0u;
	UINT8 localCiId = 0u;
	UINT8 deviceSum =0u;/*通信设备总数*/
	UINT8* deviceIdBuf = NULL;/*通信设备ID数组*/
	UINT8 pscId = 0u;
	UINT8 psdCiId = 0u;
	UINT16 pscPsdId = 0u;
	UINT8 psdUpdateType = GetCiFunctionSwitchConfig(FUCN_IF_PSC);   /*获取是否与PSC通信方式 0x55：VOBC更新屏蔽门状态 0xaa：PSC更新屏蔽门状态*/
	UINT8 transmitState = 0u;
	UINT8 transmitReval = CI_ERROR;
	PSCToCiDataStruct* pscToCiDataStru = GetPscToCiDataStru();
	localCiId = GetSystemParaLocalCiId();

	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PSC);     /*获取通信PSC设备总数*/
	deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PSC); /*获取通信PSC设备ID数组*/

	if ((deviceSum > 0u) && (deviceIdBuf != NULL))
	{/*参数有效性判断*/
		for (ii = 0u; ii < deviceSum; ii++)
		{/*遍历与本CI通信的站台门系统*/
		    pscId = deviceIdBuf[ii];
			/*更新与CI通信状态*/
			transmitReval = UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_PSC, deviceIdBuf[ii]);

			if(CI_SUCCESS == transmitReval)
			{
				transmitState = GetCiTransmitState(CI_SYSTEM_TYPE_PSC, deviceIdBuf[ii]);
			}
			if(TRANSMIT_STATE_GOOD != transmitState)
			{/*若当前通信故障，则将数据导向安全*/
				(void)SetPscToCiDefaultDataStru(deviceIdBuf[ii]);
			}
			/*根据ATS确认命令更新对应的互锁解除状态*/
			UpdateAtsPscPlFlagData(deviceIdBuf[ii]);
			/*PSC系统ID合法*/
			if(PSC_TO_CI_SUM_MAX > pscId)
			{
				for (jj = 0u; jj < pscToCiDataStru[pscId].psdSum; jj++)		
				{/*遍历站台门系统包含的PSD数目*/
					pscPsdId = pscToCiDataStru[pscId].psdDataStr[jj].psdId;
					psdCiId = GetPsdBelongCiId(pscPsdId);
					/*查找到相应的站台门系统，更新屏蔽门信息*/ 
					if((0u!=pscPsdId) && (PSD_STATE_FROM_PSC == psdUpdateType) && (psdCiId == localCiId))
					{/*存在PSC收到状态控制该屏蔽门，当前数据配置为PSC更新屏蔽门状态*/
						if (PSD_VIRTUAL_ATTR_YES == GetPsdVirtualAttribute(pscPsdId))
						{/*虚拟屏蔽门开关状态更新采用PSC状态*/
							/*什么都不做*/
						} 
						else
						{/*真实屏蔽门采用PSC状态更新互锁解除、开关状态*/
							if((PSD_MUTUALLOCK_REMOVE_YES == pscToCiDataStru[pscId].psdDataStr[jj].psdMLockState) 
								&& (PSD_MUTUALLOCK_REMOVE_YES == pscToCiDataStru[pscId].psdDataStr[jj].psdAtsMlockState))
							{
								/*两种状态都有*/
								(void)SetPsdMutualLockRemoveState(pscPsdId, PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES);
							}
							else if((PSD_MUTUALLOCK_REMOVE_YES == pscToCiDataStru[pscId].psdDataStr[jj].psdMLockState) 
								&& (PSD_MUTUALLOCK_REMOVE_NO == pscToCiDataStru[pscId].psdDataStr[jj].psdAtsMlockState))
							{
								/*继电器采集*/
								(void)SetPsdMutualLockRemoveState(pscPsdId, PSD_MUTUALLOCK_REMOVE_YES);
							}
							else if(((PSD_MUTUALLOCK_REMOVE_NO == pscToCiDataStru[pscId].psdDataStr[jj].psdMLockState)
								|| (PSD_MUTUALLOCK_REMOVE_DEFAULT == pscToCiDataStru[pscId].psdDataStr[jj].psdMLockState)) 
								&& (PSD_MUTUALLOCK_REMOVE_YES == pscToCiDataStru[pscId].psdDataStr[jj].psdAtsMlockState))
							{
								/*ATS确认*/
								(void)SetPsdMutualLockRemoveState(pscPsdId, PSD_ATS_MUTUALLOCK_REMOVE_YES);
							}
							else
							{
								(void)SetPsdMutualLockRemoveState(pscPsdId, PSD_MUTUALLOCK_REMOVE_NO);
							}
							/*屏蔽门开关状态更新*/
							if (PSD_STATE_CLOSE_VIETNAM == pscToCiDataStru[pscId].psdDataStr[jj].psdState)
							{
								(void)SetPsdState(pscPsdId, PSD_STATE_CLOSE);
							}
							else if (PSD_STATE_OPEN_VIETNAM == pscToCiDataStru[pscId].psdDataStr[jj].psdState)
							{
								(void)SetPsdState(pscPsdId, PSD_STATE_OPEN);
							}
							else
							{/*屏蔽门开关状态默认开门*/
								(void)SetPsdState(pscPsdId, PSD_STATE_OPEN);
							}				
						}
					}
				}
			}
			pscId = 0u;/*清空pscId*/
        }		
	}
}


/*
* 功能描述：处理存在ATS确认PSC旁路系统屏蔽门状态数据
* 参数说明： UINT8 pscId ：PSC系统ID
* 返回值  ： void    
*/

void UpdateAtsPscPlFlagData(UINT8 pscId)
{
	/*变量初始化*/
	UINT8 i = 0u;
	UINT8 getPscPlFlag = 0u;
	UINT8 psdVirArr = 0u;
	PSCToCiDataStruct* pscToCiDataStru = GetPscToCiDataStru();/*不会返回NULL*/

	/*参数防护*/
	if(PSC_TO_CI_SUM_MAX > pscId)
	{
		for(i = 0u; i < pscToCiDataStru[pscId].psdSum; i++)
		{
			/*获取屏蔽门确认标志*/
			getPscPlFlag = GetPsdPlFlag(pscToCiDataStru[pscId].psdDataStr[i].psdId);
			psdVirArr = GetPsdVirtualAttribute(pscToCiDataStru[pscId].psdDataStr[i].psdId);
			if(CI_PSC_PL_CONFIRM_YES == getPscPlFlag)
			{
				/*设置ATS确认旁路，关门状态*/
				if (PSD_VIRTUAL_ATTR_YES != psdVirArr)
				{/*非虚拟屏蔽门才设置*/
					pscToCiDataStru[pscId].psdDataStr[i].psdState = PSD_STATE_CLOSE_VIETNAM;/*门状态要不要设置？*/
					pscToCiDataStru[pscId].psdDataStr[i].psdAtsMlockState = PSD_MUTUALLOCK_REMOVE_YES;
				}
			}
			else 
			{
				if (PSD_VIRTUAL_ATTR_YES != psdVirArr)
				{/*非虚拟屏蔽门才设置*/
					pscToCiDataStru[pscId].psdDataStr[i].psdAtsMlockState = PSD_MUTUALLOCK_REMOVE_NO;
				}
			}
		}
	}
}

/*
* 功能描述： 处理ATS或现地到CI数据
* 参数说明： void
* 返回值  ： 0u:处理失败
*			 1:处理成功         
*/
UINT8 ProcessAtsOrXianDiToCiData(void)
{
	CommandDataStruct* AtsOrXianDiToCiCmdStru = NULL;		/*ats或现地到联锁命令数据*/
	UINT16 AtsOrXianDiToCiCmdSum = 0u;						/*ats或现地到联锁命令总数*/
    UINT16 CmdDeviceId = 0u;						    /*ats或现地到联锁命令涉及到的设备ID*/
	UINT8 cmdDevType = 0u;						    /*ats或现地到联锁命令涉及到的设备类型*/
	UINT8 cmdType = 0u;						    /*ats或现地到联锁命令类型*/
	UINT32 commandId = 0u;                           /*命令id*/
	UINT16 terminalId = 0u;                           /*终端id*/
	UINT16 ii = 0u;									/*游标*/
	UINT8 localCiType = GetLocalCiType();
	UINT8 checkRetVal = CI_FALSE;
	UINT16 cmd_idx = 0u;
	UINT16 wATSToCiCmdReturnToTRCurSum = 0u;/*信号特开命令数目*/
	UINT8 flag = 0u;/*信号特开命令是否已存储标志*/
	CommandDataStruct* pATSToCiCmdReturnToTRData = NULL;/*信号特开命令存储结构体*/
	UINT8 localCiId = 0u;        /*本地联锁ID*/
	UINT16 signalOutSecId = 0u;  /*信号机外方区段*/
	UINT16 returnRouteId = 0u;   /*折返进路*/
	UINT16 throughRouteId = 0u;  /*通过进路*/
	UINT8 returnRouteIdBelongCiId = 0u;/*折返进路所属联锁ID*/
	UINT8 throughRouteIdBelongCiId = 0u;/*通过进路所属联锁ID*/
	UINT8 signalBelongCi = 0u;
	UINT8 functionId = EFUNC_ZX_ProcessAtsOrXianDiToCiData;

	UINT8 commState = 0u;/*通信状态*/
	/*相邻联锁是否支持继电接口*/
	UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI);
	UINT16 sigDetainDriveRelayId = 0u;/*信号机扣车驱动继电器*/
	UINT8 detainDriveRelayBelongCi = 0u;/*扣车驱动继电器所属联锁*/

	UINT8 startFLockFlag =0u;
	UINT8 startLockFlag = 0u;
	UINT8 ciTrainTestState =0u;
	UINT8 allSwitchYLockFlag = 0u;
	UINT8 OrderCheckReVal = 0u;
	UINT8 belongVirCIid = 0u;
	UINT8 virCiID = 0u;
    UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT16 routeCmdSum = 0u;  /*一周期收到的进路命令办理数*/
	UINT16 saveRouteCmdSum = 0u;        /*存储进路办理命令计数*/
	UINT16 j = 0u;
	CommandDataStruct SaveAtsRouteSetCmdStru[ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX] = {0};		/*存储ats或现地到联锁大于三条进路办理命令数据*/
	UINT8 allSignalBrightState = 0u;
	UINT16 trainId = 0U; /*命令相关的列车ID*/
	UINT8 cDsnLineSwitch = FUNC_SWITCH_OFF;/* 支持迪士尼线路标志位 */
	UINT8 cShadowMainMode = REVERSE_MODE_SHADOW;/* 影子模式状态 */
	UINT8 cLogSecSeqDir = CI_SYSTEM_DIRECTION_NONE;	/* 逻辑区段序列方向 */
	UINT8 cFunRetVal = CI_ERROR; /* 接收函数返回值用于判断报警 */
	UINT16 recordErrorNum = 0u;
	UINT8 cSectionSum = 0U;          /*区段数量*/
	UINT16* pSectionIdBuff = NULL;   /*区段ID数组*/
	UINT16 OverlapRouteId = 0U;

	localCiId = GetSystemParaLocalCiId();          /*获取本机联锁ID*/
	/*解析ATS或联锁命令*/
	AtsOrXianDiToCiCmdSum = GetCiRevCmdStruCurSum();
	AtsOrXianDiToCiCmdStru = GetCiRevCmdDataStruct();

	if ((NULL == AtsOrXianDiToCiCmdStru) || (0u == AtsOrXianDiToCiCmdSum))
	{
		/*CI未收到到ATS或联锁命令数据*/
		return CI_ERROR;
	}
	cDsnLineSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH);
	cShadowMainMode = GetTiocSystemMode();

	if ((FUNC_SWITCH_ON == cDsnLineSwitch) && (REVERSE_MODE_SHADOW == cShadowMainMode))
	{
		/* 当前为影子模式，只处理扣车相相关命令 */
		for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++)
		{
			CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam >> 16);
			cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam >> 8);
			commandId = AtsOrXianDiToCiCmdStru[ii].CommandId;
			terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id;
			virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid;
			cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType;
			/*判断是否为扣车相关命令*/

			switch (cmdType)
			{
			case ATS_CMD_KOUCHE_SET_ATS:
				/*ATS扣车关灯命令*/
				signalBelongCi = GetSignalBelongCiId(CmdDeviceId);

				if (signalBelongCi == localCiId)
				{/*如果信号机所属联锁与本联锁id相同*/
					DetainLogicManage(CmdDeviceId, SIGNAL_DETAIN_ATS);
				}
				else
				{
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE, CmdDeviceId, SIGNAL_DETAIN_ATS, signalBelongCi);

					sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*获取信号机扣车驱动继电器ID*/
					if (0u < sigDetainDriveRelayId)
					{
						detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId);
					}
					commState = GetLocalCiAndOtherCiTransSta(signalBelongCi);/*本联锁与其它联锁通信通信状态*/
					if ((TRANSMIT_STATE_BAD == commState) && (detainDriveRelayBelongCi == localCiId) &&
						(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface))
					{/*通信状态中断 且信号机扣车驱动继电器属于本联锁，且支持继电接口功能开关已打开*/
						SetSignalNeighbourDetainDrive(CmdDeviceId, NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES);/*设置扣车驱动*/
					}
				}
				break;

			case ATS_CMD_KOUCHE_CANCEL_ATS:
				/*取消ATS扣车重开信号命令*/
				signalBelongCi = GetSignalBelongCiId(CmdDeviceId);
				localCiId = GetSystemParaLocalCiId();          /*获取本机联锁ID*/
				if (signalBelongCi == localCiId)
				{/*如果信号机所属联锁与本联锁id相同*/
					DetainLogicManage(CmdDeviceId, SIGNAL_DETAIN_ATS_NO);
				}
				else
				{
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE, CmdDeviceId, SIGNAL_DETAIN_ATS_NO, signalBelongCi);
					sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*获取信号机扣车驱动继电器ID*/
					if (0u < sigDetainDriveRelayId)
					{
						detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId);
					}
					if ((detainDriveRelayBelongCi == localCiId))
					{/*信号机扣车驱动继电器属于本联锁*/
						SetSignalNeighbourDetainDrive(CmdDeviceId, NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO);/*取消扣车驱动*/
					}
				}
				break;

			case ATS_CMD_KOUCHE_SET_XIANDI:
				/*现地扣车关灯命令*/
				signalBelongCi = GetSignalBelongCiId(CmdDeviceId);

				if (signalBelongCi == localCiId)
				{/*如果信号机所属联锁与本联锁id相同,或者信号机扣车驱动继电器ID属于本联锁*/
					DetainLogicManage(CmdDeviceId, SIGNAL_DETAIN_XIANDI);
				}
				else
				{/*增加逻辑，如果配置了继电接口，且本联锁与信号机所在联锁通信中断，则驱动扣车继电器，否则网络传递扣车命令*/
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE, CmdDeviceId, SIGNAL_DETAIN_XIANDI, signalBelongCi);

					sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*获取信号机扣车驱动继电器ID*/
					if (0u < sigDetainDriveRelayId)
					{
						detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId);
					}
					commState = GetLocalCiAndOtherCiTransSta(signalBelongCi);/*本联锁与其它联锁通信通信状态*/
					if ((TRANSMIT_STATE_BAD == commState) && (detainDriveRelayBelongCi == localCiId) &&
						(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface))
					{/*通信状态中断 且信号机扣车驱动继电器属于本联锁，且支持继电接口功能开关已打开*/
						SetSignalNeighbourDetainDrive(CmdDeviceId, NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES);/*设置扣车驱动*/
					}

				}
				break;

			case ATS_CMD_KOUCHE_CANCEL_XIANDI:
				/*取消现地扣车重开信号命令*/
				signalBelongCi = GetSignalBelongCiId(CmdDeviceId);
				localCiId = GetSystemParaLocalCiId();          /*获取本机联锁ID*/
				if (signalBelongCi == localCiId)
				{/*如果信号机所属联锁与本联锁id相同*/
					DetainLogicManage(CmdDeviceId, SIGNAL_DETAIN_XIANDI_NO);
				}
				else
				{
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE, CmdDeviceId, SIGNAL_DETAIN_XIANDI_NO, signalBelongCi);
					sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*获取信号机扣车驱动继电器ID*/
					if (0u < sigDetainDriveRelayId)
					{
						detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId);
					}
					if ((detainDriveRelayBelongCi == localCiId))
					{/*信号机扣车驱动继电器属于本联锁*/
						SetSignalNeighbourDetainDrive(CmdDeviceId, NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO);/*取消扣车驱动*/
					}
				}
				break;
			default:
				/* 无处理 */
				break;
			}

		}

		/*清除所有命令*/
		ClearCiRevCmdData();/*清空CI接收命令数据队列*/
	}
	else
	{
		startFLockFlag = GetStartFLockFlag();
		if ((CI_START_FLOCK_YES == startFLockFlag))
		{
		    for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++)
		    {
				CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16);
				cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8);
				commandId = AtsOrXianDiToCiCmdStru[ii].CommandId;
				terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id;
				virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid;
				cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType;
		        /*判断全站解封*/
		        if (ATS_CMD_STARTFLOCK_UNLOCK_ONE == cmdType)
		        {
		            

		            /*反馈命令收到信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);
		            
		            ClearCiRevCmdData();/*清空CI接收命令数据队列*/
		            
		            return CI_SUCCESS;
		        }
		        else if (ATS_CMD_STARTFLOCK_UNLOCK_TWO == cmdType)
		        {
					checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID);
					if(CI_SUCCESS == checkRetVal)
		            {
		                /*全站解封*/
		                SetStartFLockUnLockLogicManage();

						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
		            }
		            else
		            {
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
		            }


		            ClearCiRevCmdData();/*清空CI接收命令数据队列*/
		            
			        return CI_SUCCESS;
				}
				else if (ATS_CMD_GET_CTRL_POWER == cmdType)
				{
					SetCtrlPower(virCiID, CONTRAL_POWER_YES, CmdDeviceId, cmdDevType);
					/*未解封之前，也可以获取联锁控制权；由于ATS一次需要获取多个RTU的控制权，所以这里不清队列*/
					SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, 0u, 0u, virCiID);
				}
				else if (ATS_CMD_RELEASE_CTRL_POWER == cmdType)
				{
					ReleaseCtrlPower(virCiID, CONTRAL_POWER_NO, CmdDeviceId, cmdDevType);/*未解封之前，也可以释放联锁控制权*/
					SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, 0u, 0u, virCiID);
				}
				else
				{
					continue;
				}
			}

		    /*未上电解封*/
		    ClearCiRevCmdData();/*清空CI接收命令数据队列*/
		        
			return CI_ERROR;
		}
		else if (CI_START_FLOCK_ERROR == startFLockFlag)
		{

		    /*解封失败*/
		    /*清空CI接收命令数据队列*/
		    ClearCiRevCmdData();
		    
		    return CI_ERROR;
		}
		else
		{
		    /*已上电解封*/
		}

		/*判断上电解锁*/
		startLockFlag = GetStartLockFlag();
		if (CI_START_LOCK_YES == startLockFlag)
		{
		    for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++)
		    {
				CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16);
				cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8);
				commandId = AtsOrXianDiToCiCmdStru[ii].CommandId;
				terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id;
				virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid;
				cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType;
			    if (ATS_CMD_BUTTON_STARTUP_UNLOCK == cmdType)
			    {
		            /*反馈命令收到信息*/
		            SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID);

				    /*上电解锁*/
				    SetStartupUnLockLogicManage();

		            /*清空CI接收命令数据队列*/
		            ClearCiRevCmdData();
		            
		            return CI_SUCCESS;
		        }
		        else
		        {
		            /*继续*/
		        }
		    }

		    
		    /*未上电解锁*/
		    ClearCiRevCmdData();/*清空CI接收命令数据队列*/
		    
			return CI_ERROR;
		}
		else if (CI_START_LOCK_ERROR == startLockFlag)
		{
		    /*解锁失败*/
		    /*清空CI接收命令数据队列*/
		    ClearCiRevCmdData();
		    
		    return CI_ERROR;
		}
		else
		{
		    /*已上电解锁*/
		}

		/* 判断试车线联锁是否已经进入试车模式，如果未进入试车模式则不做任何处理 */
		ciTrainTestState = GetCiTrainTestStatus();
		if ((localCiType == CI_TYPE_SCX) && (CI_TRAIN_TEST_ON != ciTrainTestState))
		{
			for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++)
			{
				CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16);
				cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8);
				commandId = AtsOrXianDiToCiCmdStru[ii].CommandId;
				terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id;
				virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid;
				cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType;
				/* 判断试车请求命令 */
				if (ATS_CMD_APPLY_TRY_TRAIN == cmdType)
				{
					/*反馈命令收到信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID);

					/* 开始试车模式 */
					StartTrianTestManage();

					ClearCiRevCmdData();/*清空CI接收命令数据队列*/

					return CI_SUCCESS;
				}
				else if (ATS_CMD_CANCEL_TRY_TRAIN == cmdType)
				{/*功能优化：试车线现地申请试车后，停车场联锁办理出非进路前，试车线现地可以取消试车请求*/
					/*反馈命令收到信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID);

					/* 取消试车 */
					StopTrianTestManage();

					ClearCiRevCmdData();/*清空CI接收命令数据队列*/

					return CI_SUCCESS;
				}
				else if (ATS_CMD_CI_MODE_CHANGE == cmdType)
				{
				/*功能优化：未进入试车模式之前，允许切换控制权*/
					if (FUNC_SWITCH_ON == includeVirFlag)
					{
						SetVirCImode(virCiID, (UINT8)CmdDeviceId);
						ClearCiRevCmdData();/*清空CI接收命令数据队列*/
						return CI_SUCCESS;
					}
					else
					{
						SetCiModeFlag((UINT8)CmdDeviceId);
						ClearCiRevCmdData();/*清空CI接收命令数据队列*/
						return CI_SUCCESS;
					}
				}
				else
				{
					/*未进入试车模式，命令无效*/
					SetErrorData(functionId,CI_DEVICE_TYPE_CMD,cmdType,ETYPE_TRAIN_TEST_OFF,0,ESEND_LEVEL_ATS);
				}
			}

			/*未上电解封*/
			ClearCiRevCmdData();/*清空CI接收命令数据队列*/

			return CI_ERROR;
		}
		else
		{
			/*不做处理*/
		}

		/*判断全站引导总锁*/
		/*虚拟联锁兼容*/
		if(FUNC_SWITCH_ON == includeVirFlag)
		{
			DealallSwitchYLockOrder_Vir();
		}
		else
		{
			allSwitchYLockFlag = GetAllSwitchYLockFlag();
			if (CI_ALL_SWITCH_YLOCK_YES == allSwitchYLockFlag)
			{/*取消引导总锁*/
				for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++)
				{
					CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16);
					cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8);
					commandId = AtsOrXianDiToCiCmdStru[ii].CommandId;
					terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id;
					virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid;
					cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType;
					if (ATS_CMD_SWIT_ZONGSUO_CANCEL_ONE == cmdType)
					{
						/*反馈命令收到信息*/
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);                
					}
					else if (ATS_CMD_SWIT_ZONGSUO_CANCEL_TWO == cmdType)
					{
						checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID);
						if(CI_SUCCESS == checkRetVal)
						{
							/*取消引导总锁*/
							SetCiYLockManage(CI_ALL_SWITCH_YLOCK_NO);
							SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
						}
						else
						{
							/*什么都不做*/   
							SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
						}
					}
					else if (ATS_CMD_SIGNAL_YINDAO_OPEN == cmdType)
					{
						/*反馈命令收到信息*/
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID);
						/*设置引导总锁引导信号开放*/
						SetYLockSignalOpenStateManage(virCiID,CmdDeviceId);
					}
					else if (ATS_CMD_CI_MODE_CHANGE == cmdType)
					{/*引导总锁下允许站控和紧急站控切换，新增需求20161103*/

						/*反馈命令收到信息*/
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID);

						if ((CI_MODE_CI_LOCAL == CmdDeviceId) || (CI_MODE_CONSTRA_LOCAL == CmdDeviceId) || ((CI_MODE_APPLAY_LOCAL == CmdDeviceId)))
						{/*强制站控和申请站控、联锁控切换*/
							SetCiModeFlag((UINT8)CmdDeviceId);
						}
					}
					else
					{
						SetCiSendCmdBackInfoData(CI_BACK_INVALID_CMD, cmdDevType, CmdDeviceId, 0U, (UINT32)AtsOrXianDiToCiCmdStru[ii].CommandType);/*无效命令反馈*/
					}
		    
					 /*未取消引导总锁*/
					ClearCiRevCmdData();/*CI接收命令数据队列*/
				}
			}
			else
			{/*设置引导总锁*/
				for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++)
				{
					CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16);
					cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8);
					commandId = AtsOrXianDiToCiCmdStru[ii].CommandId;
					terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id;
					cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType;
					virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid;
					if (ATS_CMD_SWITCH_ZONGSUO_SET_ONE == cmdType)
					{
		          
						/*反馈命令收到信息*/
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);

						/*清空CI接收命令数据队列*/
						ClearCiRevCmdData();
		            
					}
					else if (cmdType == ATS_CMD_SWITCH_ZONGSUO_SET_TWO)
					{
						checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID);
						if(CI_SUCCESS == checkRetVal)
						{
							/*设置引导总锁*/
							SetCiYLockManage(CI_ALL_SWITCH_YLOCK_YES);

							SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
						}
						else
						{
							SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
						}

		           

						/*清空CI接收命令数据队列*/
						ClearCiRevCmdData();
					}
					else
					{
						/*遍历缓存，确认是否有引导总锁命令*/
					}
				}
			}
			/*没有特殊命令继续处理正常命令*/
		}
		
		
		/*******************正常联锁命令****************/
		AtsOrXianDiToCiCmdSum = GetCiRevCmdStruCurSum();
		for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++)
		{
		    /*前两个字节代表设备ID，后两个字节代表设备类型*/
		    CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16u);
			cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8u);  /*命令对应的设备类型*/
			cLogSecSeqDir = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam & 0xFFu);
			commandId = AtsOrXianDiToCiCmdStru[ii].CommandId;
			terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id;
			virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid;
			cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType;
			trainId = AtsOrXianDiToCiCmdStru[ii].wTrainIdParam; /*命令相关的列车ID*/
			cSectionSum = AtsOrXianDiToCiCmdStru[ii].chSectionSum;
			pSectionIdBuff = AtsOrXianDiToCiCmdStru[ii].wSectionData;
			recordErrorNum = GetErrorDataCurSum();
		    /*反馈命令收到信息，根据输入命令类型判断*/
			OrderCheckReVal = CheckIsGeneralOrder(AtsOrXianDiToCiCmdStru[ii].CommandType);

			if(CI_SUCCESS == OrderCheckReVal)
			{
			   SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType,0u,0u,virCiID);
			}
			switch (AtsOrXianDiToCiCmdStru[ii].CommandType)
			{

			case ATS_CMD_ROUTE_PUTONG_SET: 
				/*进路命令计数*/
				routeCmdSum++;
				/*小于4，则办理进路*/
				if(ATS_ROUTE_SET_PROCESS_MAX >= routeCmdSum)
				{
					/*办理普通进路*/
					belongVirCIid = GetRouteBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						SetCommonRouteLogicManage(CmdDeviceId, ESEND_LEVEL_ATS);
					}			
				}
				else
				{
					if(ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX > saveRouteCmdSum)
					{
						/*存储命令，待下一周期执行*/
						SaveAtsRouteSetCmdStru[saveRouteCmdSum++] = AtsOrXianDiToCiCmdStru[ii];
					}
				}
				break;

			case ATS_CMD_ROUTE_YINDAO_SET:
		        /*办理引导进路*/
				belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
				if(CI_SUCCESS == OrderCheckReVal)
				{
					SetLeadRouteLogicManage(CmdDeviceId);
				}		
				break;

			case ATS_CMD_ROUTE_ZONGQUXIAO: 
		        /*总取消*/
				belongVirCIid = GetRouteBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
				if(CI_SUCCESS == OrderCheckReVal)
				{
					RouteZongQuXiaoLogicManage(CmdDeviceId);
				}		
				break;

			case ATS_CMD_ROUTE_ZONGRENJIE: 
		        /*总人解*/
				belongVirCIid = GetRouteBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
				if(CI_SUCCESS == OrderCheckReVal)
				{
					RouteZongRenJieLogicManage(CmdDeviceId);
				}	
				break;

			case ATS_CMD_SECTION_FAULT_UNLOCK: 
		        /*区段故障解锁*/
			    PhySecFaultUnlockLogicManage(CmdDeviceId,virCiID);
				break;

			case ATS_CMD_SIGNAL_REPEAT_OPEN: 
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);

				if(CI_TRUE == checkRetVal)
				{
					belongVirCIid =GetSignalBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						/*信号重开*/
						RepeatOpenSignalLogicManage(CmdDeviceId);		
					}	  
				}
				break;

			case ATS_CMD_SIGNAL_YINDAO_OPEN:
		        /*开放引导信号*/
				belongVirCIid =GetSignalBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
				if(CI_SUCCESS == OrderCheckReVal)
				{
					OpenLeadSignalLogicManage(CmdDeviceId);
				}		
				break;

			case ATS_CMD_SIGNAL_FENGSUO_SET: 
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);

				if(CI_TRUE == checkRetVal)
				{    /*信号封锁*/
					belongVirCIid =GetSignalBelongVirCiId(CmdDeviceId);  
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						/*信号封锁*/
						SetSignalFLockLogicManage(CmdDeviceId);
					}	
				}
				break;

			case ATS_CMD_SIGNAL_FENGSUO_CANCEL: 
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);

				if(CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						/*信号解封*/
						CancelSignalFLockLogicManage(CmdDeviceId);
					}
				}
				break;

			case ATS_CMD_SWITCH_FENGSUO_SET: 
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

				if(CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						/*道岔封锁*/
						SetSwitchFLockLogicManage(CmdDeviceId);
					}
				}
				break;

			case ATS_CMD_SWITCH_FENGSUO_CANCEL: 
		    	checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

				if(CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						/*道岔解封*/
						CancelSwitchFLockLogicManage(CmdDeviceId);
					}
				}
				break;

			case ATS_CMD_SWITCH_DINGWEI_SET: 
 				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

				if(CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						/*道岔总定位*/
						SetSwitchPositionLogicManage(CmdDeviceId, SWITCH_POSITION_DINGWEI);
					}
				}
				break;

			case ATS_CMD_SWITCH_FANWEI_SET: 

				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

				if(CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						/*道岔总反位*/
						SetSwitchPositionLogicManage(CmdDeviceId, SWITCH_POSITION_FANWEI);
					}
				}
				break;

			case ATS_CMD_SWITCH_DANSUO_SET: 
		    	checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

				if(CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						/*道岔单锁*/
						SetSwitchDLockLogicManage(CmdDeviceId);
					}
				}
				break;

			case ATS_CMD_SWITCH_DANSUO_CANCEL:
		    	checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

				if(CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						/*道岔单解*/
						CancelSwitchDLockLogicManage(CmdDeviceId);
					}
				}
				break;

		    case ATS_CMD_AUTO_ROUTE_SET: 
		        /*设置自动进路*/
				SetAutoRouteLogicManage(CmdDeviceId,virCiID);
				break;

		    case ATS_CMD_AUTO_ROUTE_CANCEL: 
		        /*取消自动进路*/
				 CancelAutoRouteLogicManage(CmdDeviceId,virCiID);
				break;

		    case ATS_CMD_AUTO_RETURN_SET: 
		        /*设置自动折返*/	
				SetAutoReturnLogicManage(CmdDeviceId,virCiID);
				break;

		    case ATS_CMD_AUTO_RETURN_CANCEL: 
		        /*取消自动折返*/	
				CancelAutoReturnLogicManage(CmdDeviceId,virCiID);
				break;
			case ATS_CMD_ALL_AUTO_RETURN_SET: 
				/*设置全自动折返*/
				SetAllAutoReturnLogicManage(CmdDeviceId,virCiID);
				break;

			case ATS_CMD_ALL_AUTO_RETURN_CANCEL: 
				/*取消全自动折返*/
				CancelAllAutoReturnLogicManage(CmdDeviceId,virCiID);
				break;
		        
		    case ATS_CMD_SWIT_QIANG_DINGWEI_ONE:
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);
				if(CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						checkRetVal = AFFIRM_SUCCESS;
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,checkRetVal,virCiID);          
		        break;

		    case ATS_CMD_SWIT_QIANG_DINGWEI_TWO:
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID);
				if(CI_SUCCESS  == checkRetVal)
		        {
		            checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

					if(CI_TRUE == checkRetVal)
					{
						belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
						OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
						if(CI_SUCCESS == OrderCheckReVal)
						{
							checkRetVal = AFFIRM_SUCCESS;
							/*道岔强扳定位命令*/
							(void)ForceSetSwitchPositionManage(CmdDeviceId,SWITCH_POSITION_DINGWEI);
						}
						else
						{
							checkRetVal = AFFIRM_FAIL;
						}
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
		        }
				else
				{
					checkRetVal = AFFIRM_FAIL;   
				}
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID);  
		        break;

		    case ATS_CMD_SWIT_QIANG_FANWEI_ONE:

		    	checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);
				if(CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
					if(CI_SUCCESS == OrderCheckReVal)
					{
						checkRetVal = AFFIRM_SUCCESS;
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,checkRetVal,virCiID);                                         
		        break;

		    case ATS_CMD_SWIT_QIANG_FANWEI_TWO:
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID);
				if(CI_SUCCESS  == checkRetVal)
		        {
		        	checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

					if(CI_TRUE == checkRetVal)
					{
						belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
						OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);
						if(CI_SUCCESS == OrderCheckReVal)
						{
							checkRetVal = AFFIRM_SUCCESS;
							/*道岔强扳反位命令*/
							(void)ForceSetSwitchPositionManage(CmdDeviceId,SWITCH_POSITION_FANWEI);
						}
						else
						{
							checkRetVal = AFFIRM_FAIL;
						}
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;   
		        }
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID);  
  
		        break;

		    case ATS_CMD_ALL_SIG_BRIGHT_SET_ONE:
				/*反馈命令收到信息*/
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);            
		        

		        break;

		    case ATS_CMD_ALL_SIG_BRIGHT_SET_TWO:
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID);
				if(CI_SUCCESS == checkRetVal)
		        {
		            /*全场点灯设置命令*/
					if(FUNC_SWITCH_ON == includeVirFlag)
					{
						SetVirCIAllSignalBrightState(virCiID,CI_ALL_SIGNAL_BRIGHT_YES);		
					}
					else
					{
						 SetAllSignalBrightFlag(CI_ALL_SIGNAL_BRIGHT_YES);
					}		
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);

		        }
		        else
		        {
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
				}            
		        
		        break;

		    case ATS_CMD_ALLSIGBRIGHT_CANCEL_ONE:
				/*反馈命令收到信息*/
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);                       
		        

		        break;

		    case ATS_CMD_ALLSIGBRIGHT_CANCEL_TWO:
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID);
				if(CI_SUCCESS == checkRetVal)
		        {
		            /*全场点灯取消命令*/
					if(FUNC_SWITCH_ON == includeVirFlag)
					{
						SetVirCIAllSignalBrightState(virCiID,CI_ALL_SIGNAL_BRIGHT_NO);		
					}
					else
					{
						SetAllSignalBrightFlag(CI_ALL_SIGNAL_BRIGHT_NO);
					}
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
		        }
		        else
		        {
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
				}        
		        
		        break;
		        
		    case ATS_CMD_RETURN_TO_LIECHE:
		        /*折返转通过*/
				localCiId = GetSystemParaLocalCiId();          /*获取本机联锁ID*/
				signalOutSecId = GetSignalOutFirstPhySecId(CmdDeviceId);
				returnRouteId = GetPhySecRLockBelongRouteId(signalOutSecId);
				if (0u != returnRouteId)
				{
					if (ROUTE_TYPE_RETURN == GetConfigRouteType(returnRouteId))
					{
						throughRouteId = GetRouteThroughRouteId(returnRouteId);/*获取折返进路对应的通过进路ID*/
						returnRouteIdBelongCiId = GetRouteBelongCiId(returnRouteId);/*获取折返进路所属联锁ID*/
						throughRouteIdBelongCiId = GetRouteBelongCiId(throughRouteId);/*获取通过进路所属联锁ID*/

						if (0u != throughRouteId)
						{
							if ((throughRouteIdBelongCiId != localCiId) || (returnRouteIdBelongCiId != localCiId))
							{/*折返进路或通过进路不属于本联锁*/
								/*记录ATS或现地发送的信号特开命令，用于本联锁给相邻联锁发送信号特开申请*/
								wATSToCiCmdReturnToTRCurSum = GetATSToCiCmdRtnToTRCurSum();
								pATSToCiCmdReturnToTRData = GetATSorXDToCiCmdRtnToTRData();
								for (cmd_idx = 0u;cmd_idx < wATSToCiCmdReturnToTRCurSum;cmd_idx++)
								{
									if ((ATS_CMD_RETURN_TO_LIECHE == pATSToCiCmdReturnToTRData[cmd_idx].CommandType)
										&& (pATSToCiCmdReturnToTRData[cmd_idx].CommandParam == AtsOrXianDiToCiCmdStru[ii].CommandParam))
									{/*若信号特开命令已存在则不再添加*/
										flag = 1;
										break;
									}
								}
								if (0u == flag)
								{/*信号特开命令不存在则添加到命令结构体*/
									ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandType = ATS_CMD_RETURN_TO_LIECHE;
									ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandId = AtsOrXianDiToCiCmdStru[ii].CommandId;
									ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandParam = AtsOrXianDiToCiCmdStru[ii].CommandParam;
									ATSorXDToCiCmdReturnToTRCurSum++;
								}
							} 
							else
							{
								SetThroughRouteManage(CmdDeviceId);
							}
						}	
					}
				}
		        break;
 
		    case ATS_CMD_KOUCHE_SET_ATS:
		        /*ATS扣车关灯命令*/
				signalBelongCi = GetSignalBelongCiId(CmdDeviceId);
				
				if (signalBelongCi == localCiId)
				{/*如果信号机所属联锁与本联锁id相同*/
					DetainLogicManage(CmdDeviceId,SIGNAL_DETAIN_ATS);
				}
				else
				{
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE,CmdDeviceId,SIGNAL_DETAIN_ATS,signalBelongCi);

					sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*获取信号机扣车驱动继电器ID*/
					if (0u < sigDetainDriveRelayId)
					{
						detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId);
					}
					commState = GetLocalCiAndOtherCiTransSta(signalBelongCi);/*本联锁与其它联锁通信通信状态*/
					if ((TRANSMIT_STATE_BAD == commState) && (detainDriveRelayBelongCi == localCiId) &&
						(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface))
					{/*通信状态中断 且信号机扣车驱动继电器属于本联锁，且支持继电接口功能开关已打开*/
						SetSignalNeighbourDetainDrive(CmdDeviceId,NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES);/*设置扣车驱动*/	
					}
				}
		        break;

		    case ATS_CMD_KOUCHE_CANCEL_ATS:
		        /*取消ATS扣车重开信号命令*/
				signalBelongCi = GetSignalBelongCiId(CmdDeviceId);
				localCiId = GetSystemParaLocalCiId();          /*获取本机联锁ID*/
				if (signalBelongCi == localCiId)
				{/*如果信号机所属联锁与本联锁id相同*/
					DetainLogicManage(CmdDeviceId,SIGNAL_DETAIN_ATS_NO);
				}
				else
				{
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE,CmdDeviceId,SIGNAL_DETAIN_ATS_NO,signalBelongCi);
					sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*获取信号机扣车驱动继电器ID*/
					if (0u < sigDetainDriveRelayId)
					{
						detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId);
					}
					if ((detainDriveRelayBelongCi == localCiId))
					{/*信号机扣车驱动继电器属于本联锁*/
						SetSignalNeighbourDetainDrive(CmdDeviceId,NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO);/*取消扣车驱动*/	
					}
				}
		        break;

		    case ATS_CMD_KOUCHE_SET_XIANDI:
		        /*现地扣车关灯命令*/
				signalBelongCi = GetSignalBelongCiId(CmdDeviceId);
							
				if (signalBelongCi == localCiId)
				{/*如果信号机所属联锁与本联锁id相同,或者信号机扣车驱动继电器ID属于本联锁*/
					DetainLogicManage(CmdDeviceId,SIGNAL_DETAIN_XIANDI);
				}
		        else
				{/*增加逻辑，如果配置了继电接口，且本联锁与信号机所在联锁通信中断，则驱动扣车继电器，否则网络传递扣车命令*/
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE,CmdDeviceId,SIGNAL_DETAIN_XIANDI,signalBelongCi);

					sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*获取信号机扣车驱动继电器ID*/
					if (0u < sigDetainDriveRelayId)
					{
						detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId);
					}
					commState = GetLocalCiAndOtherCiTransSta(signalBelongCi);/*本联锁与其它联锁通信通信状态*/
					if ((TRANSMIT_STATE_BAD == commState) && (detainDriveRelayBelongCi == localCiId) &&
						(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface))
					{/*通信状态中断 且信号机扣车驱动继电器属于本联锁，且支持继电接口功能开关已打开*/
						SetSignalNeighbourDetainDrive(CmdDeviceId,NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES);/*设置扣车驱动*/	
					}
					
				}
		        break;
		        
		    case ATS_CMD_KOUCHE_CANCEL_XIANDI:
		        /*取消现地扣车重开信号命令*/
				signalBelongCi = GetSignalBelongCiId(CmdDeviceId);
				localCiId = GetSystemParaLocalCiId();          /*获取本机联锁ID*/
				if (signalBelongCi == localCiId)
				{/*如果信号机所属联锁与本联锁id相同*/
					DetainLogicManage(CmdDeviceId,SIGNAL_DETAIN_XIANDI_NO);
				}
				else
				{
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE,CmdDeviceId,SIGNAL_DETAIN_XIANDI_NO,signalBelongCi);
					sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*获取信号机扣车驱动继电器ID*/
					if (0u < sigDetainDriveRelayId)
					{
						detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId);
					}
					if ((detainDriveRelayBelongCi == localCiId))
					{/*信号机扣车驱动继电器属于本联锁*/
						SetSignalNeighbourDetainDrive(CmdDeviceId,NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO);/*取消扣车驱动*/	
					}
				}
		        break;
		       
		    case ATS_CMD_PHYSEC_RESET_ONE:
				cFunRetVal = CheckAxisResetCmd(virCiID, cmdType, cSectionSum, pSectionIdBuff);	/*检查命令是否能执行*/
				if(CI_SUCCESS == cFunRetVal)
				{/*检查通过*/
					checkRetVal = AFFIRM_SUCCESS;
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetAixsResetCiSendCmdBackData(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID, cSectionSum, pSectionIdBuff);
		        break;

		    case ATS_CMD_PHYSEC_RESET_TWO:
				checkRetVal = CheckAxisResetSndOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID, cSectionSum, pSectionIdBuff);
				if(CI_SUCCESS  == checkRetVal)
		        {
					cFunRetVal = CheckAxisResetCmd(virCiID, cmdType, cSectionSum, pSectionIdBuff);	 /*检查命令是否能执行*/	        	
					if(CI_SUCCESS == cFunRetVal)
					{
						checkRetVal = AFFIRM_SUCCESS;
		                /*批量计轴复位命令*/
						BatchAixsResetLogicManage(cSectionSum, pSectionIdBuff, PHYSICAL_SECTION_PRE_RESET_NO);
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
		        }
		        else
		        {
					checkRetVal = AFFIRM_FAIL;   
		        }
				SetAixsResetCiSendCmdBackData(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID, cSectionSum, pSectionIdBuff);
		        break;

		    case ATS_CMD_BUTTON_SET_STOPCHECK:/*设置停止检查*/

		        /*设置停止检查*/
		        SetStopCheckM();
		        break;

		    case ATS_CMD_BUTTON_CANCEL_STOPCHECK:/*取消停止检查*/

		        /*取消停止检查*/
		        CancelStopCheckM();
		        break;

		    case ATS_CMD_BUTTON_NONROUTE_SET:/*非进路调车办理*/

		        /*办理非进路调车选排*/
		        SetNonRouteM((UINT8)CmdDeviceId);
		        break;

		    case ATS_CMD_BUTTON_NONROUTE_CANCEL:/*非进路调车取消*/
		        
		        /*取消非进路调车*/
		        CancelNonRouteM((UINT8)CmdDeviceId);
		        break;

		    case ATS_CMD_BUTTON_NONROUTE_FAULT:/*非进路调车故障取消*/

		        /*非进路故障取消*/
		        FaultCancelNonRouteM((UINT8)CmdDeviceId);
		        break; 
#if 0

			/*长调进路仅是场段的功能*/
		    case ATS_CMD_ROUTE_CHANGDIAO_SET:/*办理长调进路*/

		        /*办理长调进路*/
		        SetZuHeRouteLogicM(CmdDeviceId);            
		        break;
#endif

			case ATS_CMD_APPLY_TRY_TRAIN:/* 试车请求按钮 */

				/* 试车请求按钮,不会进入该分支 */
				          
				break;
			case ATS_CMD_CANCEL_TRY_TRAIN:/* 试车结束按钮 */

				/* 试车结束按钮  */
				StopTrianTestManage();
				break;
			case ATS_CMD_LINSHIXIANSU_CLEAR:/*清除临时限速*/
				if(FUNC_SWITCH_ON == includeVirFlag)
				{
					/*指定虚拟联锁取消临时限速处理*/
					CancleLinShiXianSuManage_Vir(virCiID);
				}
				else
				{   /*取消临时限速处理*/
					(void)CancleLinShiXianSuManage();
				}
				 break;
			case ATS_CMD_CI_MODE_CHANGE:
				/* 设置联锁模式 */
				if(FUNC_SWITCH_ON == includeVirFlag)
				{
					SetVirCImode(virCiID,(UINT8)CmdDeviceId);
				}
				else
				{
					SetCiModeFlag((UINT8)CmdDeviceId);
				}
				break;
				/* zt 删除单轨相关代码 2022-02-15 */
			case ATS_CMD_AUTO_TRIGGER_SET:
				SetAutoTriggerLogicManage(virCiID,AUTO_TRIGGER_SET_YES);
				break;
			case ATS_CMD_CANCLE_AUTO_TRIGGER_SET:
				CancelAutoTriggerLogicManage(virCiID, AUTO_TRIGGER_SET_NO);
				break;
			case ATS_CMD_SET_UP_OVERLAP:	/*保护区段建立命令*/
				OverlapRouteId = AtsOrXianDiToCiCmdStru[ii].OverLapRouteID;
				if (0U < OverlapRouteId)
				{
					SetAtsLockOverlapHaveRouteId(CmdDeviceId, OverlapRouteId);
				}
				else
				{
					SetAtsExpectLockOverlapIdProc(CmdDeviceId, ATS_LOCK_OVERLAP);
				}
				break;
			case LABOR_CMD_SET_UP_OVERLAP:	/*人工保护区段建立命令*/
				SetAtsExpectLockOverlapIdProc(CmdDeviceId,LABOR_LOCK_OVERLAP);
				break;
			case LABOR_CMD_CANCEL_OVERLAP_ONE:	/*人工解锁保护区段一次命令*/

				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); 

				break;
			case LABOR_CMD_CANCEL_OVERLAP_TWO:	/*人工解锁保护区段二次命令*/
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID);
				if(CI_SUCCESS  == checkRetVal)
				{
					checkRetVal = AFFIRM_SUCCESS;
					/*设置人工解锁保护区段*/
					(void)LaborUnlockOverlapProc(CmdDeviceId);
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;   
				}
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID);

				break;
			case ATS_CMD_SWITCH_DINGWEI_TEST_ONE:	/*道岔定位测试一次命令*/

				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, AFFIRM_SUCCESS, virCiID);

				break;
			case ATS_CMD_SWITCH_DINGWEI_TEST_TWO:	/*道岔定位测试二次命令*/
				checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID);
				if (CI_SUCCESS == checkRetVal)
				{
					checkRetVal = AFFIRM_SUCCESS;
					/*道岔定位测试*/
					SetSwitchTestLogicManage(ATS_CMD_SWITCH_DINGWEI_TEST_TWO);
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID);
				break;
			case ATS_CMD_SWITCH_FANWEI_TEST_ONE:	/*道岔反位测试一次命令*/

				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, AFFIRM_SUCCESS, virCiID);

				break;
			case ATS_CMD_SWITCH_FANWEI_TEST_TWO:	/*道岔反位测试二次命令*/
				checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID);
				if (CI_SUCCESS == checkRetVal)
				{
					checkRetVal = AFFIRM_SUCCESS;
					/*道岔反位测试*/
					SetSwitchTestLogicManage(ATS_CMD_SWITCH_FANWEI_TEST_TWO);
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID);
				break;
			case ATS_CMD_SET_PSD_BUTTON_PANGLU:     /* 打开站台安全门按钮旁路开关命令 */
				belongVirCIid = GetPsdbelongVirCIid(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				if(CI_SUCCESS == OrderCheckReVal)
				{
					(void)SetPsdButtonPangluState(CmdDeviceId,PSD_BUTTON_PANGLU_STATE_VALID);
				}
				break;
			case ATS_CMD_CANCEL_PSD_BUTTON_PANGLU:     /* 关闭站台安全门按钮旁路开关命令 */
				belongVirCIid = GetPsdbelongVirCIid(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				if(CI_SUCCESS == OrderCheckReVal)
				{
					(void)SetPsdButtonPangluState(CmdDeviceId,PSD_BUTTON_PANGLU_STATE_INVALID);
				}
				break;
#if 0
			case ATS_CMD_ONEKEY_OPEN_ALL_GARAGE_DOORS:/*一键开所有库门*/
				SetAllGrgdoorCmdProcessState(GARAGE_DOOR_CMD_OPEN);
				break;
			case ATS_CMD_ONEKEY_CLOSE_ALL_GARAGE_DOORS:/*一键关所有库门*/
				SetAllGrgdoorCmdProcessState(GARAGE_DOOR_CMD_CLOSE);
				break;
#endif
			case ATS_CMD_SECTION_FENGSUO_SET:        /*区段封锁*/
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId);
				belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				if((CI_TRUE == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal))
				{
					/*区段封锁*/
					(void)SetSectionFLockLogicManage(CmdDeviceId);

				}
				break;

			case ATS_CMD_SECTION_FENGSUO_CANCEL:     /*区段解封*/
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId);
				belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				if((CI_TRUE == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal))
				{
					/*区段解封*/
					(void)CancelSectionFLockLogicManage(CmdDeviceId);
				}
				break;

			case ATS_CMD_PHYSEC_PRE_RESET_ONE:	/*计轴预复位一次*/
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId);
				belongVirCIid =  GetPhySecBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				if((CI_TRUE == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal))
				{
					checkRetVal = AFFIRM_SUCCESS;
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,checkRetVal,virCiID); 
				break;

			case ATS_CMD_PHYSEC_PRE_RESET_TWO:	/*计轴预复位二次*/
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID);
				if(CI_SUCCESS  == checkRetVal)
				{
					checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId);
					belongVirCIid =  GetPhySecBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
					if((CI_TRUE == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal))
					{
						checkRetVal = AFFIRM_SUCCESS;
						/*区段计轴预复位命令*/
						SetSectionResetLogicManage(CmdDeviceId, PHYSICAL_SECTION_PRE_RESET_YES);
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;   
				}
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID);
				break;

			case ATS_CMD_PHYSEC_GENERAL_RESET_SET:		             /*计轴总复位命令*/
				/*计轴总复位命令*/
				if(FUNC_SWITCH_ON == includeVirFlag)
				{
					SetPhySecZfwManage(virCiID,CI_PHYSEC_GENERAL_RESET_YES);    /*计轴总复位命令有效*/
				}
				else
				{
					SetPhySecGeneralResetFlag(CI_PHYSEC_GENERAL_RESET_YES);
				}
				break;
			case ATS_CMD_PHYSEC_GENERAL_RESET_CANCEL:		             /*取消计轴总复位命令*/
				/*取消计轴总复位命令*/
				if(FUNC_SWITCH_ON == includeVirFlag)
				{
					SetPhySecZfwManage(virCiID,CI_PHYSEC_GENERAL_RESET_NO);    /*计轴总复位命令无效*/
				}
				else
				{
					SetPhySecGeneralResetFlag(CI_PHYSEC_GENERAL_RESET_NO);
				}
				break;
			case ATS_CMD_CICI_NET_TO_RELAY_ONE:/*联锁与联锁网络接口转继电接口一次命令*/
				{
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); 
				}
				break;
			case ATS_CMD_CICI_NET_TO_RELAY_TWO:/*联锁与联锁网络接口转继电接口二次命令*/
				{
					checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID);
					if(CI_SUCCESS == checkRetVal)
					{
						/*设置继电接口的确认状态*/
						SetCiCiRelayInterfConfirmFlag(CICI_RELAY_INTERFACE_CONFIRM_YES);

						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
					}
					else
					{
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
					}
				}
				break;
			case ATS_CMD_PSC_PL_ONE: /*PSC旁路状态一次确认命令*/
				/*添加一次确认命令ID*/
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); 
				break;
			case ATS_CMD_PSC_PL_TWO: /*PSC旁路状态二次确认命令*/
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID);
				if(CI_SUCCESS == checkRetVal)
				{
					/*设置PSC旁路确认标志*/
					SetCiPscPlConfirmFlag(CI_PSC_PL_CONFIRM_YES,CmdDeviceId);
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
				}
				else
				{
					/*清空一次确认命令ID*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
				}
				break;
			case ATS_CMD_QUXIAO_PSC_PL_ONE:/*取消ATS旁路一次确认命令*/
				/*添加一次确认命令ID*/
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); 
				break;
			case ATS_CMD_QUXIAO_PSC_PL_TWO: /*取消ATS旁路二次确认命令*/
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID);
				if(CI_SUCCESS == checkRetVal)
				{
					/*设置PSC旁路取消标志*/
					SetCiPscPlConfirmFlag(CI_PSC_PL_CONFIRM_NO,CmdDeviceId);
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
				}
				else
				{
					/*清空一次确认命令ID*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
				}
				break;
				/*组合自动进路办理命令*/
			case ATS_CMD_ROUTE_GROUP_AUTO_SET:
				/*办理组合自动进路处理*/
				belongVirCIid =  GetGroupAutoRouteBelongVirCIid(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				if(CI_SUCCESS == OrderCheckReVal)
				{
					SetGroupAutoRouteLogicManage(CmdDeviceId);
				}
				break;
				/*组合自动进路取消命令*/
			case ATS_CMD_ROUTE_GROUP_AUTO_CANCLE:
				/*取消组合自动进路处理*/
				belongVirCIid =  GetGroupAutoRouteBelongVirCIid(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				if(CI_SUCCESS == OrderCheckReVal)
				{
					CancleGroupAutoRouteLogicManage(CmdDeviceId);
				}
				break;



			case ATS_CMD_SIGNALMAINTAINSTATE_ONE: /*信号机维修点灯一次命令*/
				/*添加一次确认命令ID*/
				belongVirCIid =  GetSignalBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				if(CI_SUCCESS == OrderCheckReVal)
				{
					checkRetVal = AFFIRM_SUCCESS;
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,checkRetVal,virCiID); 
				break;
			case ATS_CMD_SIGNALMAINTAINSTATE_TWO: /*信号机维修点灯二次命令*/
				belongVirCIid =  GetSignalBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID);
				if((CI_SUCCESS == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal))
				{
					SetSignalMaintainState(CmdDeviceId,MAINTAIN_STATE_YES);/*设置信号机维修点灯*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
				}
				else
				{
					/*反馈失败信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
				}
				break;		

			

			case ATS_CMD_CANCEL_SIG_MAINTAIN_ONE: /*取消信号机维修点灯一次命令*/
				/*添加一次确认命令ID*/
				belongVirCIid =  GetSignalBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				allSignalBrightState = GetALLSignalMaintainState(belongVirCIid);/*检查不处于全站维修点灯信号机状态*/
				if((CI_SUCCESS == OrderCheckReVal)&&(CI_ALL_SIGNAL_BRIGHT_NO == allSignalBrightState))
				{
					checkRetVal = AFFIRM_SUCCESS;
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,checkRetVal,virCiID); 
				break;
			case ATS_CMD_CANCEL_SIG_MAINTAIN_TWO: /*取消信号机维修点灯二次命令*/
				belongVirCIid =  GetSignalBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*检查命令能否被执行*/
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID);
				allSignalBrightState = GetALLSignalMaintainState(belongVirCIid);/*检查不处于全站维修点灯信号机状态*/
				if((CI_SUCCESS == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal)&&(CI_ALL_SIGNAL_BRIGHT_NO == allSignalBrightState))
				{
					SetSignalMaintainState(CmdDeviceId,MAINTAIN_STATE_NO);/*设置取消信号机维修点灯*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
				}
				else
				{
					/*反馈失败信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
				}
				break;		
				/*取消转辙机封连报警一次命令*/
			case ATS_CMD_CANCEL_SW_ALARM_ONE:
				/*添加一次命令反馈*/
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); 
				break;
				/*取消转辙机封连报警二次命令*/
			case ATS_CMD_CANCEL_SW_ALARM_TWO:
				/*一次二次命令检查*/
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID);
				if(CI_SUCCESS == checkRetVal)
				{
					/*设置取消转辙机封连报警状态*/
					SetCancelOrRcvrBlockLinkSta(CANCEL_SWITCH_BLOCK_LINK);
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);

				}
				else
				{
					/*反馈失败信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
				}
				break;
				/*恢复转辙机封连报警一次命令*/
			case ATS_CMD_RECOVER_SW_ALARM_ONE:
				/*添加一次命令反馈*/
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); 
				break;
				/*恢复转辙机封连报警二次命令*/
			case ATS_CMD_RECOVER_SW_ALARM_TWO:
				/*一次二次命令检查*/
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID);
				if(CI_SUCCESS == checkRetVal)
				{
					/*设置恢复转辙机封连报警状态*/
					SetCancelOrRcvrBlockLinkSta(RECOVER_SWITCH_BLOCK_LINK);
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
				}
				else
				{
					/*反馈失败信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
				}
				break;
			case ATS_CMD_ROUTE_AUTO_TRIGGER_SET:
				SetSigleRouteAutoTriggerManage(virCiID, CmdDeviceId, AUTO_TRIGGER_SET_YES); /*设置指定进路的自动触发标志*/
				break;
			case ATS_CMD_ROUTE_CANCLE_AUTO_TRIGGER:
				CancelSigleRouteAutoTrigger(virCiID, CmdDeviceId, AUTO_TRIGGER_SET_NO); /*取消指定进路的自动触发标志*/
				break;
			case ATS_CMD_STATION_QK_SET:
				SetClearPassenagerManage(CmdDeviceId, ATS_TO_CI_PLATFORM_QK_YES);      /*根据请客命令设置清客标志*/
				break;
			/*车车新加 WQM 20220303*/
			case ATS_CMD_ROUTE_APPLY:
				/*进路命令计数*/
				routeCmdSum++;
				/*小于4，则办理进路*/
				if (ATS_ROUTE_SET_PROCESS_MAX >= routeCmdSum)
				{
					/*办理申请路径*/
					belongVirCIid = GetRouteBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId);
					if (CI_SUCCESS == OrderCheckReVal)
					{
						RouteApplyLogicManage(CmdDeviceId, trainId);
					}
				}
				else
				{
					if (ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX > saveRouteCmdSum)
					{
						/*存储命令，待下一周期执行*/
						SaveAtsRouteSetCmdStru[saveRouteCmdSum++] = AtsOrXianDiToCiCmdStru[ii];
					}
				}
				break;
			case ATS_CMD_GET_CTRL_POWER: /*lc-20221208合并*/
				SetCtrlPower(virCiID, CONTRAL_POWER_YES, CmdDeviceId, cmdDevType);/*获取联锁控制权*/
				break;
			case ATS_CMD_RELEASE_CTRL_POWER: /*lc-20221208合并*/
				ReleaseCtrlPower(virCiID, CONTRAL_POWER_NO, CmdDeviceId, cmdDevType);/*释放联锁控制权*/
				break;

#if 0
			case ATS_CMD_SET_PHYSEC_ERR:
				/* 设置故障列车 */
				SetBreakPhySecWithTrainInfo(CmdDeviceId, trainId, cTrainDir);
				break;
			case ATS_CMD_CANCEL_PHYSEC_FIRST:
				/* 取消故障列车一次*/
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId);
				if (CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId);
					if (CI_SUCCESS == OrderCheckReVal)
					{
						checkRetVal = AFFIRM_SUCCESS;
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID);
				break;
			case ATS_CMD_CANCEL_PHYSEC_SECOND:
				/* TODO: 取消物理区段故障占用二次命令*/
				checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID);
				if (CI_SUCCESS == checkRetVal)
				{
					checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId);

					if (CI_TRUE == checkRetVal)
					{
						belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId);
						OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId);
						if (CI_SUCCESS == OrderCheckReVal)
						{
							checkRetVal = AFFIRM_SUCCESS;
							/* 取消故障列车处理 */
							UnLockBreakPhySecWithTrainInfo(CmdDeviceId, trainId, cTrainDir);
						}
						else
						{
							checkRetVal = AFFIRM_FAIL;
						}
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID);
				break;
#endif
			case ATS_CMD_ROUTE_APPLY_CANCLE:
				/*取消资源*/
				belongVirCIid = GetRouteBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId);
				if (CI_SUCCESS == OrderCheckReVal)
				{
					RouteCancelResLogicManage(CmdDeviceId,trainId);
				}
				break;
			case ATS_CMD_ROUTE_PART_APPLY:
				/*申请部分路径*/
				RoutePartApplyLogicManage(cLogSecSeqDir, trainId, cSectionSum, pSectionIdBuff);
				break;
			case ATS_CMD_OPEN_XIANSU_SIGNAL_FIRST:
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);
				if (CI_TRUE == checkRetVal)
				{
					belongVirCIid =GetSignalBelongVirCiId (CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId);
					if (CI_SUCCESS == OrderCheckReVal)
					{
						checkRetVal = AFFIRM_SUCCESS;
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID);
				break;

			case ATS_CMD_OPEN_XIANSU_SIGNAL_SECOND:
				checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID);
				if (CI_SUCCESS == checkRetVal)
				{
					checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);

					if (CI_TRUE == checkRetVal)
					{
						belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId);
						OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId);
						if (CI_SUCCESS == OrderCheckReVal)
						{
							checkRetVal = AFFIRM_SUCCESS;
							/*开放限速信号*/
							OpenXianSuSignalLogicManage(CmdDeviceId);
						}
						else
						{
							checkRetVal = AFFIRM_FAIL;
						}
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID);
				break;
				/*限速特开*/
			case ATS_CMD_OPEN_XIANSU_SIGNAL_SPECIAL:
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);
				if (CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId);
					if (CI_SUCCESS == OrderCheckReVal)
					{
						checkRetVal = AFFIRM_SUCCESS;
						/*开放限速信号*/
						OpenXianSuSignalLogicManage(CmdDeviceId);
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
				break;
				/*ATS中心自动扣车*/
			case ATS_CMD_KOUCHE_SET_ATS_AUTO:
			{
				signalBelongCi = GetSignalBelongCiId(CmdDeviceId);

				if (signalBelongCi == localCiId)
				{/*如果信号机所属本联锁*/
					/*设置ATS自动扣车*/
					DetainLogicManage(CmdDeviceId, SIGNAL_DETAIN_ATS_AUTO);
				}
				else
				{
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE, CmdDeviceId, SIGNAL_DETAIN_ATS_AUTO, signalBelongCi);
				}
				break;
			}
				/*OC-P旁路一次命令*/
			case ATS_CMD_OC_P_PL_ONE:
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, AFFIRM_SUCCESS, virCiID);
				break;
				/*OC-P旁路二次命令*/
			case ATS_CMD_OC_P_PL_TWO:
				checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID);
				if (CI_SUCCESS == checkRetVal)
				{
					/*设置OC-P旁路确认标志*/
					SetOcPscPlConfirmFlag(OC_PSC_PL_CONFIRM_YES, CmdDeviceId);
					SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_SUCCESS, virCiID);
				}
				else
				{
					/*清空一次确认命令ID*/
					SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_FAIL, virCiID);
				}
				break;

				/*取消OC-P旁路一次命令*/
			case ATS_CMD_QUXIAO_OC_P_PL_ONE:
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, AFFIRM_SUCCESS, virCiID);
				break;
				/*取消OC-P旁路二次命令*/
			case ATS_CMD_QUXIAO_OC_P_PL_TWO:
				checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID);
				if (CI_SUCCESS == checkRetVal)
				{
					/*设置PSC旁路取消标志*/
					SetOcPscPlConfirmFlag(OC_PSC_PL_CONFIRM_NO, CmdDeviceId);
					SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_SUCCESS, virCiID);
				}
				else
				{
					/*清空一次确认命令ID*/
					SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_FAIL, virCiID);
				}
				break;

			default:
				cFunRetVal = VirtualDevCmdProc(CmdDeviceId, AtsOrXianDiToCiCmdStru[ii].CommandType);/*试车线虚拟设备状态处理*/
				if (CI_ERROR == cFunRetVal)
				{
					SetCiSendCmdBackInfoData(CI_BACK_INVALID_CMD, cmdDevType, CmdDeviceId, 0u, (UINT32)AtsOrXianDiToCiCmdStru[ii].CommandType);/*无效命令反馈*/
				}
				break;
			}
			/*cgh-合并CID-2349-5：*/
			SetErrorDataBelongVirCiId(recordErrorNum, virCiID);
		}

		ClearCiRevCmdData();/*清空CI接收命令数据队列*/
		/*存遗留的进路办理数据*/
		if(0u < saveRouteCmdSum)
		{
			for(j = 0u; j < saveRouteCmdSum; j++)
			{
				/*拷贝数据*/
				CiRevCmdDataStru[j] = SaveAtsRouteSetCmdStru[j];
			}
			/*记录存储下一周期进路办理的命令数*/
			CiRevCmdStruCurSum = saveRouteCmdSum;
		}
	}
	return CI_SUCCESS;
}

/*
* 功能描述： 处理车辆段的ATS或现地到CI数据
* 参数说明： void
* 返回值  ： 0u:处理失败
*			 1:处理成功         
*/
UINT8 ProcessAtsOrXianDiToCiDataCld(void)
{
	CommandDataStruct* AtsToCiCmdStru = NULL;		/*ats到联锁命令数据*/
	UINT16 AtsToCiCmdSum = 0u;						/*ats到联锁命令总数*/
    UINT16 CmdDeviceId = 0u;						    /*ats到联锁命令涉及到的设备ID*/
	UINT8 cmdDevType = 0u;						    /*ats到联锁命令涉及到的设备类型*/
	UINT32 commandId = 0u;                           /*命令id*/
	UINT16 terminalId = 0u;                           /*终端id*/
	UINT16 ii = 0u;									/*游标*/
	UINT8 checkRetVal = CI_FALSE;
	UINT8 jkjRelayValidFlag = 0u;

	UINT8 localCiId = 0u;        /*本地联锁ID*/
	UINT16 signalOutSecId = 0u;  /*信号机外方区段*/
	UINT16 returnRouteId = 0u;   /*折返进路*/
	UINT16 throughRouteId = 0u;  /*通过进路*/
	UINT8 returnRouteIdBelongCiId = 0u;/*折返进路所属联锁ID*/
	UINT8 throughRouteIdBelongCiId = 0u;/*通过进路所属联锁ID*/
	UINT16 cmd_idx = 0u;
	UINT16 wATSToCiCmdReturnToTRCurSum = 0u;/*信号特开命令数目*/
	UINT8 flag = 0u;/*信号特开命令是否已存储标志*/
	CommandDataStruct* pATSToCiCmdReturnToTRData = NULL;/*信号特开命令存储结构体*/
	UINT8 startFLockFlag = 0u;
	UINT8 startLockFlag = 0u;
	UINT8 allSwitchYLockFlag = 0u;
	UINT8 checkReVal = 0u;
	UINT16 routeCmdSum = 0u;  /*一周期收到的进路命令办理数*/
 	UINT8 virCiID= 0u;
	UINT16 saveRouteCmdSum = 0u;        /*存储进路办理命令计数*/
	UINT16 j = 0u;
	CommandDataStruct SaveAtsRouteSetCmdStru[ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX] = {0};		/*存储ats或现地到联锁大于三条进路办理命令数据*/
	UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT16 recordErrorNum = 0u;
	UINT8 OrderCheckReVal = 0u;
	UINT8 belongVirCIid = 0u;
	UINT16 trainId = 0U;
	UINT16 OverlapRouteId = 0U;
	UINT8 cLogSecSeqDir = CI_SYSTEM_DIRECTION_NONE;	 /* 逻辑区段序列方向 */
	UINT8 cSectionSum = 0U;          /*区段数量*/
	UINT16* pSectionIdBuff = NULL;   /*区段ID数组*/

	/*解析ATS命令*/
	AtsToCiCmdSum = GetCiRevCmdStruCurSum();
	AtsToCiCmdStru = GetCiRevCmdDataStruct();

	if (NULL == AtsToCiCmdStru) 
	{
		/*CI未收到到ATS命令数据*/
		return CI_ERROR;
	}

	jkjRelayValidFlag = GetCiJkjFlag();
	/*应急盘继电器有效状态*/
	if (JKJ_REYLAY_VALID == jkjRelayValidFlag)
	{
		for (ii = 0u; ii < AtsToCiCmdSum; ii++)
		{
			CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16);
			cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8);
			commandId = AtsToCiCmdStru[ii].CommandId;
			terminalId = AtsToCiCmdStru[ii].termial_id;
			virCiID = AtsToCiCmdStru[ii].VirCIid;
			trainId = AtsToCiCmdStru[ii].wTrainIdParam;
			recordErrorNum = GetErrorDataCurSum();
			if (0u != AtsToCiCmdStru[ii].CommandType)
			{
				/*反馈命令收到信息*/
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,0u,0u,virCiID);

				/*记录故障码*/
				SetErrorData(EFUNC_PARSE_ATS2CI_DATA, CI_DEVICE_TYPE_RELAY, 0u, ETYPE_JKJ_WORK, RELAY_STATE_DOWN, ESEND_LEVEL_ATS);/*增加OC应急控功能，继电器ID填0*/

				/*清空CI接收命令数据队列*/
				ClearCiRevCmdData();

				/*cgh-合并CID-2349-5：*/
				SetErrorDataBelongVirCiId(recordErrorNum, virCiID);
				return CI_ERROR;
			}
			else
			{
				/*继续*/
			}
		}
	}
	else
	{
	    ;
	}
	
	startFLockFlag = GetStartFLockFlag();
    if (CI_START_FLOCK_YES == startFLockFlag)
    {
        for (ii = 0u; ii < AtsToCiCmdSum; ii++)
        {
			CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16);
			cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8);
			commandId = AtsToCiCmdStru[ii].CommandId;
			terminalId = AtsToCiCmdStru[ii].termial_id;
			virCiID = AtsToCiCmdStru[ii].VirCIid;
            /*判断全站解封*/
            if (ATS_CMD_STARTFLOCK_UNLOCK_ONE == AtsToCiCmdStru[ii].CommandType)
            {
                /*保存一次命令ID*/

                /*反馈命令收到信息*/
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);
                
                ClearCiRevCmdData();/*清空CI接收命令数据队列*/
                
                return CI_SUCCESS;
            }
            else if (ATS_CMD_STARTFLOCK_UNLOCK_TWO == AtsToCiCmdStru[ii].CommandType)
            {
				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID);
				if(CI_SUCCESS == checkRetVal)
                {
                    /*全站解封*/
                    SetStartFLockUnLockLogicManage();

					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
                }
                else
                {
                    /*没有收到二次确认*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
                }

                /*反馈命令收到信息*/

                ClearCiRevCmdData();/*清空CI接收命令数据队列*/
                
		        return CI_SUCCESS;
            }
			else if (ATS_CMD_GET_CTRL_POWER == AtsToCiCmdStru[ii].CommandType)
			{
				SetCtrlPower(virCiID, CONTRAL_POWER_YES, CmdDeviceId, cmdDevType);
				/*未解封之前，也可以获取联锁控制权；由于ATS一次需要获取多个RTU的控制权，所以这里不清队列*/
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, 0u, 0u, virCiID);
			}
			else if (ATS_CMD_RELEASE_CTRL_POWER == AtsToCiCmdStru[ii].CommandType)
			{
				ReleaseCtrlPower(virCiID, CONTRAL_POWER_NO, CmdDeviceId, cmdDevType);/*未解封之前，也可以释放联锁控制权*/
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, 0u, 0u, virCiID);
			}
            else
            {
                continue;
            }
        }

        /*未上电解封*/
        ClearCiRevCmdData();/*清空CI接收命令数据队列*/
            
		return CI_ERROR;
    }
    else if (CI_START_FLOCK_ERROR == startFLockFlag)
    {

        /*解封失败*/
        /*清空CI接收命令数据队列*/
        ClearCiRevCmdData();
        
        return CI_ERROR;
    }
    else
    {
        /*已上电解封*/
    }

    /*判断上电解锁*/
	startLockFlag = GetStartLockFlag();
    if (CI_START_LOCK_YES == startLockFlag)
    {
        for (ii = 0u; ii < AtsToCiCmdSum; ii++)
        {
			CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16);
			cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8);
			commandId = AtsToCiCmdStru[ii].CommandId;
			terminalId = AtsToCiCmdStru[ii].termial_id;
			virCiID = AtsToCiCmdStru[ii].VirCIid;
		    if (ATS_CMD_BUTTON_STARTUP_UNLOCK == AtsToCiCmdStru[ii].CommandType)
		    {
                /*反馈命令收到信息*/
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,0u,0u,virCiID);

			    /*上电解锁*/
#if 0
			    StartupUnlockM();
#endif
				SetStartupUnLockLogicManage();

                /*清空CI接收命令数据队列*/
                ClearCiRevCmdData();
                
                return CI_SUCCESS;
            }
            else
            {
                continue;
            }
        }

        
        /*未上电解锁*/
        ClearCiRevCmdData();/*清空CI接收命令数据队列*/
        
		return CI_ERROR;
    }
    else if (CI_START_LOCK_ERROR == startLockFlag)
    {
        /*解锁失败*/
        /*清空CI接收命令数据队列*/
        ClearCiRevCmdData();
        
        return CI_ERROR;
    }
    else
    {
        /*已上电解锁*/
    }

	if(FUNC_SWITCH_ON == includeVirFlag)
	{
		DealallSwitchYLockOrder_Vir();
	}
	else
	{
		/*判断全站引导总锁*/
		allSwitchYLockFlag = GetAllSwitchYLockFlag();
		if (CI_ALL_SWITCH_YLOCK_YES == allSwitchYLockFlag)
		{/*取消引导总锁*/
			for (ii = 0u; ii < AtsToCiCmdSum; ii++)
			{
				CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16);
				cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8);
				commandId = AtsToCiCmdStru[ii].CommandId;
				terminalId = AtsToCiCmdStru[ii].termial_id;
				virCiID = AtsToCiCmdStru[ii].VirCIid;
				if (AtsToCiCmdStru[ii].CommandType == ATS_CMD_SWIT_ZONGSUO_CANCEL_ONE)
				{

					/*反馈命令收到信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);                

					/*清空CI接收命令数据队列*/
					ClearCiRevCmdData();

					return CI_SUCCESS;
				}
				else if (ATS_CMD_SWIT_ZONGSUO_CANCEL_TWO == AtsToCiCmdStru[ii].CommandType)
				{
					checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID);
					if(CI_SUCCESS == checkRetVal)
					{
						/*取消引导总锁*/
						SetCiYLockManage(CI_ALL_SWITCH_YLOCK_NO);
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
						/*取消一次确认命令ID*/
					}
					else
					{
						/*什么都不做*/    
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
					}

					/*反馈命令收到信息*/

					/*清空CI接收命令数据队列*/
					ClearCiRevCmdData();

					return CI_SUCCESS;
				}
				else if (ATS_CMD_SIGNAL_YINDAO_OPEN == AtsToCiCmdStru[ii].CommandType)
				{
					/*反馈命令收到信息*/

					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,0u,0u,virCiID);


					/*设置引导总锁引导信号开放*/
					SetYLockSignalOpenStateManage(virCiID,CmdDeviceId);
				}
				else if (ATS_CMD_CI_MODE_CHANGE == AtsToCiCmdStru[ii].CommandType)
				{/*引导总锁下允许站控和紧急站控切换，新增需求20161103*/
					/*前两个字节代表设备ID，后两个字节代表设备类型*/


					/*反馈命令收到信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,0u,0u,virCiID);

					if ((CI_MODE_CI_LOCAL == CmdDeviceId) || (CI_MODE_CONSTRA_LOCAL == CmdDeviceId) ||(CI_MODE_APPLAY_LOCAL == CmdDeviceId))
					{/*强制站控和申请站控、联锁控切换*/
						/*虚拟联锁兼容*/
						SetCiModeFlag((UINT8)CmdDeviceId);
					}
				}
				else
				{
					SetCiSendCmdBackInfoData(CI_BACK_INVALID_CMD, cmdDevType, CmdDeviceId, 0U, (UINT32)AtsToCiCmdStru[ii].CommandType);/*无效命令反馈*/
				}
			}

			/*未取消引导总锁*/
			ClearCiRevCmdData();/*CI接收命令数据队列*/

			return CI_ERROR;
		}
		else
		{/*设置引导总锁*/
			for (ii = 0u; ii < AtsToCiCmdSum; ii++)
			{
				CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16);
				cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8);
				commandId = AtsToCiCmdStru[ii].CommandId;
				terminalId = AtsToCiCmdStru[ii].termial_id;
				virCiID = AtsToCiCmdStru[ii].VirCIid;
				if (ATS_CMD_SWITCH_ZONGSUO_SET_ONE == AtsToCiCmdStru[ii].CommandType)
				{

					/*反馈命令收到信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);

					/*清空CI接收命令数据队列*/
					ClearCiRevCmdData();

					return CI_SUCCESS;
				}
				else if (ATS_CMD_SWITCH_ZONGSUO_SET_TWO == AtsToCiCmdStru[ii].CommandType)
				{
					checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID);
					if(CI_SUCCESS == checkRetVal)
					{
						/*设置引导总锁*/
						SetCiYLockManage(CI_ALL_SWITCH_YLOCK_YES);

						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
					}
					else
					{
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
					}

					/*反馈命令收到信息*/

					/*清空CI接收命令数据队列*/
					ClearCiRevCmdData();

					return CI_SUCCESS;
				}
				else
				{
					continue;
				}
			}

			/*没有特殊命令继续处理正常命令*/
		}
	}
   
    

/*******************正常联锁命令****************/
	AtsToCiCmdSum = GetCiRevCmdStruCurSum();
	for (ii = 0u; ii < AtsToCiCmdSum; ii++)
	{
        /*前两个字节代表设备ID，后两个字节代表设备类型*/
        CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16);
		cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8);
		commandId = AtsToCiCmdStru[ii].CommandId;
		terminalId = AtsToCiCmdStru[ii].termial_id;
		virCiID = AtsToCiCmdStru[ii].VirCIid;
		trainId = AtsToCiCmdStru[ii].wTrainIdParam;
		cLogSecSeqDir = (UINT8)(AtsToCiCmdStru[ii].CommandParam & 0xFFu);
		cSectionSum = AtsToCiCmdStru[ii].chSectionSum;
		pSectionIdBuff = AtsToCiCmdStru[ii].wSectionData;

		/*反馈命令收到信息*/
		checkReVal = CheckIsGeneralOrder(AtsToCiCmdStru[ii].CommandType);
		if(CI_SUCCESS == checkReVal)
		{
	    	SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,0u,0u,virCiID);
		}

		switch (AtsToCiCmdStru[ii].CommandType)
		{
		case ATS_CMD_CI_MODE_CHANGE:
			if(FUNC_SWITCH_ON == includeVirFlag)
			{
				/* 设置联锁模式，虚拟联锁兼容 */
			    SetVirCImode(virCiID,(UINT8)CmdDeviceId);	
			}
			else
			{
				/* 设置联锁模式 */
				SetCiModeFlag((UINT8)CmdDeviceId);
			}
			break;

		case ATS_CMD_ROUTE_PUTONG_SET: 
			/*进路命令计数*/
			routeCmdSum++;
			/*小于4，则办理进路*/
			if(ATS_ROUTE_SET_PROCESS_MAX >= routeCmdSum)
			{
				/*办理普通进路*/
				SetCommonRouteLogicManage(CmdDeviceId, ESEND_LEVEL_ATS);
			}
			else
			{
				if(ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX > saveRouteCmdSum)
				{
					/*存储命令，待下一周期执行*/
					SaveAtsRouteSetCmdStru[saveRouteCmdSum++] = AtsToCiCmdStru[ii];
				}
			}
			break;

		case ATS_CMD_ROUTE_YINDAO_SET: 
            /*办理引导进路*/
			SetLeadRouteM(CmdDeviceId);
			break;

		case ATS_CMD_ROUTE_ZONGQUXIAO: 
            /*总取消*/
		    ZongQuXiaoRouteM(CmdDeviceId);
			break;

		case ATS_CMD_ROUTE_APPLY_CANCLE:
			/*场段收到0x093命令执行总取消 GC0081-849*/
			ZongQuXiaoRouteM(CmdDeviceId);
			break;

		case ATS_CMD_ROUTE_ZONGRENJIE: 
            /*总人解*/
			ZongRenJieRouteM(CmdDeviceId);
			break;

		case ATS_CMD_SECTION_FAULT_UNLOCK:
			/*区段故障解锁*/
#if 0
			SectionFaultUnlockM(CmdDeviceId);
#endif
			PhySecFaultUnlockLogicManage(CmdDeviceId,virCiID);
			break;

		case ATS_CMD_SIGNAL_REPEAT_OPEN: 

			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
            	/*信号重开*/
				RepeatOpenSignalM(CmdDeviceId);
			}
			else
			{
			/*什么都不做*/
			}
			break;

		case ATS_CMD_SIGNAL_YINDAO_OPEN:
            /*开放引导信号*/
		    OpenLeadSignalLogicManage(CmdDeviceId);
			break;

		case ATS_CMD_SIGNAL_FENGSUO_SET: 
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
	            /*信号封锁*/
			    SetSignalFengSuoM(CmdDeviceId);
			}
			else
			{
			/*什么都不做*/
			}
			break;

		case ATS_CMD_SIGNAL_FENGSUO_CANCEL: 
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
	            /*信号解封*/
				CancelSignalFengSuoM(CmdDeviceId);
			}
			else
			{
			/*什么都不做*/
			}
			break;

		case ATS_CMD_SWITCH_FENGSUO_SET: 
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
	            /*道岔封锁*/
				SetSwitchFengSuoM(CmdDeviceId);
			}
			else
			{
			/*什么都不做*/
			}
			break;

		case ATS_CMD_SWITCH_FENGSUO_CANCEL: 
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
	            /*道岔解封*/
				CancelSwitchFengSuoM(CmdDeviceId);
			}
			else
			{
			/*什么都不做*/
			}
			break;

		case ATS_CMD_SWITCH_DINGWEI_SET: 
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
				/*道岔总定位*/
				SetSwitchPositionM(CmdDeviceId, SWITCH_POSITION_DINGWEI);
			}
			else
			{
			/*什么都不做*/
			}
			break;

		case ATS_CMD_SWITCH_FANWEI_SET:
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
				/*道岔总反位*/
				SetSwitchPositionM(CmdDeviceId, SWITCH_POSITION_FANWEI);
			}
			else
			{
			/*什么都不做*/
			}
			break;

		case ATS_CMD_SWITCH_DANSUO_SET: 
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
				/*道岔单锁*/
				SetSwitchDanSuoM(CmdDeviceId);
			}
			else
			{
			/*什么都不做*/
			}            
			break;

		case ATS_CMD_SWITCH_DANSUO_CANCEL: 
 			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
				/*道岔单解*/
				CancelSwitchDanSuoM(CmdDeviceId);
			}
			else
			{
			/*什么都不做*/
			}
			break;

		case ATS_CMD_RETURN_TO_LIECHE:
			/*折返转通过*/
			localCiId = GetSystemParaLocalCiId();          /*获取本机联锁ID*/
			signalOutSecId = GetSignalOutFirstPhySecId(CmdDeviceId);
			returnRouteId = GetPhySecRLockBelongRouteId(signalOutSecId);
			if (0u != returnRouteId)
			{
				if (ROUTE_TYPE_RETURN == GetConfigRouteType(returnRouteId))
				{
					throughRouteId = GetRouteThroughRouteId(returnRouteId);/*获取折返进路对应的通过进路ID*/
					returnRouteIdBelongCiId = GetRouteBelongCiId(returnRouteId);/*获取折返进路所属联锁ID*/
					throughRouteIdBelongCiId = GetRouteBelongCiId(throughRouteId);/*获取通过进路所属联锁ID*/

					if (0u != throughRouteId)
					{
						if ((throughRouteIdBelongCiId != localCiId) || (returnRouteIdBelongCiId != localCiId))
						{/*折返进路或通过进路不属于本联锁*/
							/*记录ATS或现地发送的信号特开命令，用于本联锁给相邻联锁发送信号特开申请*/
							wATSToCiCmdReturnToTRCurSum = GetATSToCiCmdRtnToTRCurSum();
							pATSToCiCmdReturnToTRData = GetATSorXDToCiCmdRtnToTRData();
							for (cmd_idx = 0u; cmd_idx < wATSToCiCmdReturnToTRCurSum; cmd_idx++)
							{
								if ((ATS_CMD_RETURN_TO_LIECHE == pATSToCiCmdReturnToTRData[cmd_idx].CommandType)
									&& (pATSToCiCmdReturnToTRData[cmd_idx].CommandParam == AtsToCiCmdStru[ii].CommandParam))
								{/*若信号特开命令已存在则不再添加*/
									flag = 1u;
									break;
								}
							}
							if (0u == flag)
							{/*信号特开命令不存在则添加到命令结构体*/
								ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandType = ATS_CMD_RETURN_TO_LIECHE;
								ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandId = AtsToCiCmdStru[ii].CommandId;
								ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandParam = AtsToCiCmdStru[ii].CommandParam;
								ATSorXDToCiCmdReturnToTRCurSum++;
							}
						}
						else
						{
							SetThroughRouteManage(CmdDeviceId);
						}
					}
				}
			}
			break;

        case ATS_CMD_BUTTON_SET_STOPCHECK:/*设置停止检查*/

            /*设置停止检查*/
            SetStopCheckFlag();
            break;

        case ATS_CMD_BUTTON_CANCEL_STOPCHECK:/*取消停止检查*/

            /*取消停止检查*/
            CancelStopCheckFlag();
            break;

        case ATS_CMD_BUTTON_NONROUTE_SET:/*非进路调车办理*/
#if 0
			if (CmdDeviceId == 0u)
			{
				CmdDeviceId = 1;
			}
#endif
            /*办理非进路调车选排*/
            SetNonRouteM((UINT8)CmdDeviceId);
            break;

        case ATS_CMD_BUTTON_NONROUTE_CANCEL:/*非进路调车取消*/
#if 0
			if (CmdDeviceId == 0u)
			{
				CmdDeviceId = 1;
			}
#endif
            /*取消非进路调车*/
            CancelNonRouteM((UINT8)CmdDeviceId);
            break;

        case ATS_CMD_BUTTON_NONROUTE_FAULT:/*非进路调车故障取消*/
#if 0
			if (CmdDeviceId == 0u)
			{
				CmdDeviceId = 1;
			}
#endif
            /*非进路故障取消*/
            FaultCancelNonRouteM((UINT8)CmdDeviceId);
            break; 

		case ATS_CMD_PHYSEC_RESET_ONE:
			checkRetVal = CheckAxisResetCmd(virCiID, cmdDevType, cSectionSum, pSectionIdBuff);	/*检查命令是否能执行*/
			if(CI_TRUE == checkRetVal)
			{
				checkRetVal = AFFIRM_SUCCESS;
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;
			}
			SetAixsResetCiSendCmdBackData(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID, cSectionSum, pSectionIdBuff);
			break;

		case ATS_CMD_PHYSEC_RESET_TWO:
			checkRetVal = CheckAxisResetSndOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID, cSectionSum, pSectionIdBuff);
			if(CI_SUCCESS  == checkRetVal)
			{
				checkRetVal = CheckAxisResetCmd(virCiID, cmdDevType, cSectionSum, pSectionIdBuff);	/*检查命令是否能执行*/
				if(CI_TRUE == checkRetVal)
				{
					checkRetVal = AFFIRM_SUCCESS;
					/*批量计轴复位命令*/
					BatchAixsResetLogicManage(cSectionSum, pSectionIdBuff, PHYSICAL_SECTION_PRE_RESET_NO);
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;   
			}
			SetAixsResetCiSendCmdBackData(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID, cSectionSum, pSectionIdBuff);
			break;

        case ATS_CMD_ROUTE_CHANGDIAO_SET:/*办理长调进路*/

            /*办理长调进路*/
            SetZuHeRouteLogicM(CmdDeviceId);            
            break;

		case ATS_CMD_ROUTE_CHANGDIAO_CANCEL:/*取消长调进路*/

			/*取消长调进路*/
			CancelZuHeRouteLogicM(CmdDeviceId);
			break;
		case ATS_CMD_GARAGE_DOOR_OPEN:/*车库门开门*/

			/*车库门开门*/
			SetGarageDoorOpenLogicM(CmdDeviceId);
			break;

		case ATS_CMD_GARAGE_DOOR_CLOSE:/*车库门关门*/

			/*车库门关门*/   
			SetGarageDoorCloseLogicM(CmdDeviceId);
			break;
        case ATS_CMD_ROUTE_ZUHELIECHE_SET: /*办理组合列车进路*/
           
            /*办理组合列车进路*/
            SetZuHeRouteLogicM(CmdDeviceId);
            break;
		case ATS_CMD_ROUTE_ZUHELIECHE_CANCEL: /*取消组合列车进路*/
			/*取消组合列车进路*/
			CancelZuHeLieCheRouteLogicM(CmdDeviceId);
			break;
			/* zt 删除单轨相关代码 2022-02-15 */
		case ATS_CMD_SET_UP_OVERLAP:	/*保护区段建立命令*/
			OverlapRouteId = AtsToCiCmdStru[ii].OverLapRouteID;
			if (0U < OverlapRouteId)
			{
				SetAtsLockOverlapHaveRouteId(CmdDeviceId, OverlapRouteId);
			}
			else
			{
				SetAtsExpectLockOverlapIdProc(CmdDeviceId, ATS_LOCK_OVERLAP);
			}
			break;
		case LABOR_CMD_SET_UP_OVERLAP:	/*人工保护区段建立命令*/
			SetAtsExpectLockOverlapIdProc(CmdDeviceId,LABOR_LOCK_OVERLAP);
			break;
		case LABOR_CMD_CANCEL_OVERLAP_ONE:	/*人工解锁保护区段一次命令*/

			SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); 

			break;
		case LABOR_CMD_CANCEL_OVERLAP_TWO:	/*人工解锁保护区段二次命令*/
			checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID);
			if(CI_SUCCESS  == checkRetVal)
			{
				checkRetVal = AFFIRM_SUCCESS;
				/*设置人工解锁保护区段*/
				(void)LaborUnlockOverlapProc(CmdDeviceId);
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;   
			}
			SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID);
			break;
#if 0
		case ATS_CMD_ONEKEY_OPEN_ALL_GARAGE_DOORS:/*一键开所有库门*/
			SetAllGrgdoorCmdProcessState(GARAGE_DOOR_CMD_OPEN);
			break;
		case ATS_CMD_ONEKEY_CLOSE_ALL_GARAGE_DOORS:/*一键关所有库门*/
			SetAllGrgdoorCmdProcessState(GARAGE_DOOR_CMD_CLOSE);
			break;
#endif
		case ATS_CMD_SECTION_FENGSUO_SET:        /*区段封锁*/
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
				/*区段封锁*/
				(void)SetSectionFLockLogicManage(CmdDeviceId);
			}
			break;

		case ATS_CMD_SECTION_FENGSUO_CANCEL:     /*区段解封*/
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId);

			if(CI_TRUE == checkRetVal)
			{
				/*区段解封*/
				(void)CancelSectionFLockLogicManage(CmdDeviceId);
			}
			break;

		case ATS_CMD_PHYSEC_PRE_RESET_ONE:	/*计轴预复位一次*/
			/*添加一次确认命令ID*/
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId);
			if(CI_TRUE == checkRetVal)
			{
				checkRetVal = AFFIRM_SUCCESS;
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;
			}
			SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,checkRetVal,virCiID); 
			break;

		case ATS_CMD_PHYSEC_PRE_RESET_TWO:	/*计轴预复位二次*/
			checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID);
			if(CI_SUCCESS  == checkRetVal)
			{
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId);

				if(CI_TRUE == checkRetVal)
				{
					checkRetVal = AFFIRM_SUCCESS;
					/*区段计轴预复位命令*/
					SetSectionResetLogicManage(CmdDeviceId, PHYSICAL_SECTION_PRE_RESET_YES);
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;   
			}
			SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID);
			break;

		case ATS_CMD_CANCEL_XICHE:	/*取消洗车命令*/
			CancelWashWorkLogicM();
			break;
		
		case ATS_CMD_PHYSEC_GENERAL_RESET_SET:		             /*计轴总复位命令*/
			/*计轴总复位命令*/
			if(FUNC_SWITCH_ON == includeVirFlag)
			{
				SetPhySecZfwManage(virCiID,CI_PHYSEC_GENERAL_RESET_YES);    /*计轴总复位命令有效*/
			}
			else
			{
				SetPhySecGeneralResetFlag(CI_PHYSEC_GENERAL_RESET_YES);    /*计轴总复位命令有效*/
			}
			break;

		case ATS_CMD_PHYSEC_GENERAL_RESET_CANCEL:		             /*取消计轴总复位命令*/
			/*取消计轴总复位命令*/
			if(FUNC_SWITCH_ON == includeVirFlag)
			{
				SetPhySecZfwManage(virCiID,CI_PHYSEC_GENERAL_RESET_NO); 
			}
			else
			{
				SetPhySecGeneralResetFlag(CI_PHYSEC_GENERAL_RESET_NO);    /*计轴总复位命令无效*/
			}
			break;
		case ATS_CMD_CICI_NET_TO_RELAY_ONE:/*联锁与联锁网络接口转继电接口一次命令*/
			{
		    	/*反馈命令收到信息*/
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);
			}
			break;
		case ATS_CMD_CICI_NET_TO_RELAY_TWO:/*联锁与联锁网络接口转继电接口二次命令*/
			{

				checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID);
				if(CI_SUCCESS == checkRetVal)
				{
					/*设置继电接口的确认状态*/
					SetCiCiRelayInterfConfirmFlag(CICI_RELAY_INTERFACE_CONFIRM_YES);

					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
				}
				else
				{
					/*什么都不做*/    
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
				}
			}
			break;
			/*取消转辙机封连报警一次命令*/
		case ATS_CMD_CANCEL_SW_ALARM_ONE:
			/*添加一次命令反馈*/
			SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); 
			break;
			/*取消转辙机封连报警二次命令*/
		case ATS_CMD_CANCEL_SW_ALARM_TWO:
			/*检查一次二次命令*/
			checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID);
			if(CI_SUCCESS == checkRetVal)
			{
				/*设置取消转辙机封连报警状态*/
				SetCancelOrRcvrBlockLinkSta(CANCEL_SWITCH_BLOCK_LINK);
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);

			}
			else
			{
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
			}
			break;
			/*恢复转辙机封连报警一次命令*/
		case ATS_CMD_RECOVER_SW_ALARM_ONE:
			/*添加一次命令反馈*/
			SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); 
			break;
			/*恢复转辙机封连报警二次命令*/
		case ATS_CMD_RECOVER_SW_ALARM_TWO:
			/*检查一次二次命令*/
			checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID);
			if(CI_SUCCESS == checkRetVal)
			{
				/*设置恢复转辙机封连报警状态*/
				SetCancelOrRcvrBlockLinkSta(RECOVER_SWITCH_BLOCK_LINK);
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
			}
			else
			{
				SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
			}
			break;
		case ATS_CMD_ROUTE_APPLY:
			/*进路命令计数*/
			routeCmdSum++;
			/*小于4，则办理进路*/
			if (ATS_ROUTE_SET_PROCESS_MAX >= routeCmdSum)
			{
				/*办理申请路径*/
				RouteApplyLogicManage(CmdDeviceId, trainId);
			}
			else
			{
				if (ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX > saveRouteCmdSum)
				{
					/*存储命令，待下一周期执行*/
					SaveAtsRouteSetCmdStru[saveRouteCmdSum++] = AtsToCiCmdStru[ii];
				}
			}
			break;
		case ATS_CMD_ALL_SIG_BRIGHT_SET_ONE:
			/*反馈命令收到信息*/
			SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, AFFIRM_SUCCESS, virCiID);
			break;

		case ATS_CMD_ALL_SIG_BRIGHT_SET_TWO:
			checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, virCiID);
			if (CI_SUCCESS == checkRetVal)
			{
				/*全场点灯设置命令*/
				if (FUNC_SWITCH_ON == includeVirFlag)
				{
					SetVirCIAllSignalBrightState(virCiID, CI_ALL_SIGNAL_BRIGHT_YES);
				}
				else
				{
					SetAllSignalBrightFlag(CI_ALL_SIGNAL_BRIGHT_YES);
				}
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_SUCCESS, virCiID);

			}
			else
			{
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_FAIL, virCiID);
			}

			break;

		case ATS_CMD_ALLSIGBRIGHT_CANCEL_ONE:
			/*反馈命令收到信息*/
			SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, AFFIRM_SUCCESS, virCiID);
			break;

		case ATS_CMD_ALLSIGBRIGHT_CANCEL_TWO:
			checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, virCiID);
			if (CI_SUCCESS == checkRetVal)
			{
				/*全场点灯取消命令*/
				if (FUNC_SWITCH_ON == includeVirFlag)
				{
					SetVirCIAllSignalBrightState(virCiID, CI_ALL_SIGNAL_BRIGHT_NO);
				}
				else
				{
					SetAllSignalBrightFlag(CI_ALL_SIGNAL_BRIGHT_NO);
				}
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_SUCCESS, virCiID);
			}
			else
			{
				SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_FAIL, virCiID);
			}
			break;
		case ATS_CMD_OPEN_XIANSU_SIGNAL_FIRST:
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);
			if (CI_TRUE == checkRetVal)
			{
				belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId);
				if (CI_SUCCESS == OrderCheckReVal)
				{
					checkRetVal = AFFIRM_SUCCESS;
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;
			}
			SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID);
			break;

		case ATS_CMD_OPEN_XIANSU_SIGNAL_SECOND:
			checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, virCiID);
			if (CI_SUCCESS == checkRetVal)
			{
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);

				if (CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId);
					if (CI_SUCCESS == OrderCheckReVal)
					{
						checkRetVal = AFFIRM_SUCCESS;
						/*开放限速信号*/
						OpenXianSuSignalLogicManage(CmdDeviceId);
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;
			}
			SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID);
			break;
			/*限速特开*/
		case ATS_CMD_OPEN_XIANSU_SIGNAL_SPECIAL:
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId);
			if (CI_TRUE == checkRetVal)
			{
				belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId);
				if (CI_SUCCESS == OrderCheckReVal)
				{
					checkRetVal = AFFIRM_SUCCESS;
					/*开放限速信号*/
					OpenXianSuSignalLogicManage(CmdDeviceId);
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;
			}
			break;
		case ATS_CMD_SWIT_QIANG_DINGWEI_ONE:
			/*道岔强扳定位一次*/
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);
			if (CI_TRUE == checkRetVal)
			{
				belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId);
				if (CI_SUCCESS == OrderCheckReVal)
				{
					checkRetVal = AFFIRM_SUCCESS;
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;
			}
			SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID);
			break;

		case ATS_CMD_SWIT_QIANG_DINGWEI_TWO:
			checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, virCiID);
			if (CI_SUCCESS == checkRetVal)
			{
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

				if (CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId);
					if (CI_SUCCESS == OrderCheckReVal)
					{
						checkRetVal = AFFIRM_SUCCESS;
						/*道岔强扳定位命令*/
						(void)ForceSetSwitchPositionManage(CmdDeviceId, SWITCH_POSITION_DINGWEI);
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;
			}
			SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID);
			break;

		case ATS_CMD_SWIT_QIANG_FANWEI_ONE:
			/*道岔强扳反位一次*/
			checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);
			if (CI_TRUE == checkRetVal)
			{
				belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
				OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId);
				if (CI_SUCCESS == OrderCheckReVal)
				{
					checkRetVal = AFFIRM_SUCCESS;
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;
			}
			SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID);
			break;

		case ATS_CMD_SWIT_QIANG_FANWEI_TWO:
			checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, virCiID);
			if (CI_SUCCESS == checkRetVal)
			{
				checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId);

				if (CI_TRUE == checkRetVal)
				{
					belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId);
					OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId);
					if (CI_SUCCESS == OrderCheckReVal)
					{
						checkRetVal = AFFIRM_SUCCESS;
						/*道岔强扳反位命令*/
						(void)ForceSetSwitchPositionManage(CmdDeviceId, SWITCH_POSITION_FANWEI);
					}
					else
					{
						checkRetVal = AFFIRM_FAIL;
					}
				}
				else
				{
					checkRetVal = AFFIRM_FAIL;
				}
			}
			else
			{
				checkRetVal = AFFIRM_FAIL;
			}
			SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID);

			break;
		case ATS_CMD_ROUTE_PART_APPLY:
			/*申请部分路径*/
			RoutePartApplyLogicManageCLD(cLogSecSeqDir, trainId, cSectionSum, pSectionIdBuff);
			break;
		case ATS_CMD_GET_CTRL_POWER: 
			/*获取联锁控制权*/
			SetCtrlPower(virCiID, CONTRAL_POWER_YES, CmdDeviceId, cmdDevType);
			break;
		case ATS_CMD_RELEASE_CTRL_POWER:
			/*释放联锁控制权*/
			ReleaseCtrlPower(virCiID, CONTRAL_POWER_NO, CmdDeviceId, cmdDevType);
			break;
		default:
			{
				SetCiSendCmdBackInfoData(CI_BACK_INVALID_CMD,0u,0u,0u,AtsToCiCmdStru[ii].CommandType);/*无效命令反馈*/
				break;
			}
			
		}
		/*cgh-合并CID-2349-5：*/
		SetErrorDataBelongVirCiId(recordErrorNum, virCiID);
	}

	ClearCiRevCmdData();/*清空CI接收命令数据队列*/
	/*存遗留的进路办理数据*/
	if(0u < saveRouteCmdSum)
	{
		for(j = 0u; j < saveRouteCmdSum; j++)
		{
			/*拷贝数据*/
			CiRevCmdDataStru[j] = SaveAtsRouteSetCmdStru[j];
		}
		/*记录存储下一周期进路办理的命令数*/
		CiRevCmdStruCurSum = saveRouteCmdSum;
	}

	return CI_SUCCESS;
}

/*
* 功能描述： 处理融合轨道区段状态
* 参数说明： void
* 返回值  ： void
*/
void OcProcessMergeABGdState(void)
{
	UINT16 ii = 0u;
	for (ii = 0u; ii < m_GdNum; ii++)
	{
		if ((OC_BOARD_STATE_NORMAL == m_Gds[ii].BoardState1) && (OC_BOARD_STATE_NORMAL == m_Gds[ii].BoardState2))
		{/*如果两系轨道板卡状态均正常，实施融合*/
			if ((OC_GD_STATE_OCCUPY == m_Gds[ii].GdState1) && (OC_GD_STATE_OCCUPY == m_Gds[ii].GdState2))
			{/*1系、2系都占用*/
				m_Gds[ii].GdMergeState = OC_GD_STATE_OCCUPY;
			}
			else if ((OC_GD_STATE_IDLE == m_Gds[ii].GdState1) && (OC_GD_STATE_OCCUPY == m_Gds[ii].GdState2))
			{/*1系出清，2系占用*/
				m_Gds[ii].GdMergeState = OC_GD_STATE_IDLE;
			}
			else if ((OC_GD_STATE_OCCUPY == m_Gds[ii].GdState1) && (OC_GD_STATE_IDLE == m_Gds[ii].GdState2))
			{/*1系占用,2系出清*/
				m_Gds[ii].GdMergeState = OC_GD_STATE_IDLE;
			}
			else if ((OC_GD_STATE_IDLE == m_Gds[ii].GdState1) && (OC_GD_STATE_IDLE == m_Gds[ii].GdState2))
			{/*1系出清,2系出清*/
				m_Gds[ii].GdMergeState = OC_GD_STATE_IDLE;
			}
			else
			{/*非法情况，导向占用*/
				m_Gds[ii].GdMergeState = OC_GD_STATE_OCCUPY;
			}
		}
		else if ((OC_BOARD_STATE_NORMAL != m_Gds[ii].BoardState1) && (OC_BOARD_STATE_NORMAL == m_Gds[ii].BoardState2))
		{/*1系故障，2系正常，采信2系*/
			if ((OC_GD_STATE_IDLE == m_Gds[ii].GdState2) || (OC_GD_STATE_OCCUPY == m_Gds[ii].GdState2) ||
				(OC_GD_STATE_FAULT == m_Gds[ii].GdState2))
			{
				m_Gds[ii].GdMergeState = m_Gds[ii].GdState2;
			}
			else
			{/*非法情况，导向占用*/
				m_Gds[ii].GdMergeState = OC_GD_STATE_OCCUPY;
			}
		}
		else if (OC_BOARD_STATE_NORMAL == m_Gds[ii].BoardState1) 
		{/*1系正常，2系故障，采信1系*/
			if ((OC_GD_STATE_IDLE == m_Gds[ii].GdState1) || (OC_GD_STATE_OCCUPY == m_Gds[ii].GdState1) ||
				(OC_GD_STATE_FAULT == m_Gds[ii].GdState1))
			{
				m_Gds[ii].GdMergeState = m_Gds[ii].GdState1;
			}
			else
			{/*非法情况，导向占用*/
				m_Gds[ii].GdMergeState = OC_GD_STATE_OCCUPY;
			}
		}
		else 
		{/*1系、2系均故障，导向安全*/
			m_Gds[ii].GdMergeState = OC_GD_STATE_FAULT;
		}
		
	}
}

/*
* 功能描述： 重置OC轨道板AB两系采集状态
* 参数说明： void
* 返回值  ： void
*/
void OcResetGdABCollState(void)
{
	UINT16 ii = 0u;
	for (ii = 0u; ii < m_GdNum; ii++)
	{
		m_Gds[ii].GdState1 = OC_GD_STATE_OCCUPY;
		m_Gds[ii].GdState2 = OC_GD_STATE_OCCUPY;
	}
}

/*
* 功能描述： 更新具体的OC轨道板采集状态
* 参数说明： void
* 返回值  ： void
*/
void OcUpdateSpecificGdCollState(void)
{
	UINT16 phySecCurSum = 0u;	 /*物理区段总数目*/
	UINT8 localCiId = 0u;         /*本地联锁ID*/

	UINT16 phySecId = 0u;	     /*物理区段ID*/
	UINT8 belongCiId = 0u;        /*物理区段所属联锁ID*/
	UINT16 jj = 0u;

	phySecCurSum = GetPhySecCurSum();		/*获取物理区段总数*/
	localCiId = GetSystemParaLocalCiId();       /*获取本机联锁ID*/

	for (jj = 0u; jj < m_GdNum; jj++)
	{
		phySecId = m_Gds[jj].GdDeviceId;
		belongCiId = GetPhySecBelongCiId(phySecId);
		if ((0u == phySecId) || (phySecId > PHYSICAL_SECTION_SUM_MAX))
		{
			continue;
		}

		if ((belongCiId != localCiId) || (localCiId == 0u))
		{
			continue;
		}
		if (OC_GD_STATE_OCCUPY == m_Gds[jj].GdMergeState)
		{
			SetPhySecCurOcGdOccupyState(phySecId, SECTION_OCCUPY_YES);/*占用*/
#ifdef USE_OC_GD_AS_PHY_COLL

			SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*占用*/
#endif
		}
		else if (OC_GD_STATE_IDLE == m_Gds[jj].GdMergeState)
		{
			SetPhySecCurOcGdOccupyState(phySecId, SECTION_OCCUPY_NO);/*空闲*/
#ifdef USE_OC_GD_AS_PHY_COLL
			SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_NO);/*空闲*/
#endif
		}
		else if (OC_GD_STATE_FAULT == m_Gds[jj].GdMergeState)
		{
			SetPhySecCurOcGdOccupyState(phySecId, SECTION_OCCUPY_FAULT);
		}
		else
		{
			/*无效值，赋占用*/
			SetPhySecCurOcGdOccupyState(phySecId, SECTION_OCCUPY_YES);/*占用*/
#ifdef USE_OC_GD_AS_PHY_COLL
			SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*占用*/
#endif
		}
	}

}


/*
* 功能描述： 融合计轴子系统和OC子系统轨道区段采集状态
* 参数说明： void
* 返回值  ： void
*/
void MergeAxleOcGdPhyState(void)
{
	UINT16 ii = 0u;
	UINT16 phyId = 0u;
	UINT8 belongCiId = 0u;
	UINT8 localCiId = 0u;
	UINT8 axisGdState = SECTION_OCCUPY_YES;
	UINT8 ocGdState = SECTION_OCCUPY_YES;
	for (ii = 0u; ii < GetPhySecCurSum(); ii++)
	{
		phyId = GetPhySecId(ii);
		belongCiId = GetPhySecBelongCiId(phyId);
		localCiId = GetSystemParaLocalCiId();
		if (belongCiId == localCiId)
		{
			axisGdState = GetPhySecCurAxisGdOccupyState(phyId);

			ocGdState = GetPhySecCurOcGdOccupyState(phyId);

			if ((SECTION_OCCUPY_FAULT != axisGdState) && (SECTION_OCCUPY_FAULT != ocGdState))
			{/*计轴采集的轨道状态和oc采集的轨道状态都不是故障态，做融合*/
				if (axisGdState == ocGdState)
				{
					SetPhySecCurOccupyState(phyId, ocGdState);
				}
				else
				{/*不一致，设占用*/
					SetPhySecCurOccupyState(phyId, SECTION_OCCUPY_YES);
				}
			}
			else if ((SECTION_OCCUPY_FAULT == axisGdState) && (SECTION_OCCUPY_FAULT != ocGdState))
			{/*计轴采集轨道状态故障，oc采集不故障，采信oc*/
				SetPhySecCurOccupyState(phyId, ocGdState);
			}
			else if ((SECTION_OCCUPY_FAULT != axisGdState) && (SECTION_OCCUPY_FAULT == ocGdState))
			{/*计轴采集轨道状态不故障，oc采集故障，采信计轴*/
				SetPhySecCurOccupyState(phyId, axisGdState);
			}
			else if ((SECTION_OCCUPY_FAULT == axisGdState) && (SECTION_OCCUPY_FAULT == ocGdState))
			{/*计轴采集轨道状态故障，oc采集故障，都不采信，设占用*/
				SetPhySecCurOccupyState(phyId, SECTION_OCCUPY_YES);
			}
			else
			{
				/*这种情况不存在*/
				SetPhySecCurOccupyState(phyId, SECTION_OCCUPY_YES);
			}
		}
	}
}

/*
* 功能描述： 更新OC轨道区段采集状态
* 参数说明： void
* 返回值  ： void
*/
void OcPhyStateToDeviceStatePro(void)
{
	/*先处理OC轨道区段的融合*/
	OcProcessMergeABGdState();

	/*重置OC轨道板AB两系采集状态*/
	OcResetGdABCollState();

	/*把从oc板卡采集到的oc轨道状态更新为OC轨道物理区段状态*/
	OcUpdateSpecificGdCollState();
}

/*
* 功能描述： 处理设备逻辑状态
* 参数说明： void
* 返回值  ： void      
*/
void ProcessDeviceLogicState(void)
{
	UINT8 chLineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*获取线路标识*/
	UINT8 acFty = GetCiFunctionSwitchConfig(FUNC_SWITCH_AC_FACTORY);
	UINT8 CiPattern = 0u;
	UINT8 chDsnLinSwitch = 0U;

	chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH);
	CiPattern = GetLocalCiPattern();

	if (CI_PATTERN_TRADITIONAL == CiPattern)/*传统联锁*/
	{
		/*更新信号机逻辑状态*/
		SignalRelayToDeviceStateProc();
	}
	else if (CI_PATTERN_FULL_ELECTRONIC == CiPattern)/*全电子联锁*/
	{
		if (FUNC_SWITCH_ON == chDsnLinSwitch)
		{
			SignalRelayToDeviceStateProc();
		}
		else
		{
			/*全电子联锁模式下，处理更新信号机逻辑状态*/
			/******************************************************************************/
			OcSignalDeviceInput();/*oc信号机设备状态处理*/
		}
	}
	else
	{
		/*不做处理*/
	}

	if ((m_GdNum > 0u)|| ((AXIS_TYPE_YONGLIE==acFty)|| (AXIS_TYPE_KEANDA == acFty) || (AXIS_TYPE_FUHAOSHENG == acFty))) /*有轨道板或计轴网络接口*/
	{
		/*更新轨道区段采集状态*/
		OcPhyStateToDeviceStatePro();

		/*融合计轴区段占用和OC轨道区段占用*/
		MergeAxleOcGdPhyState();
	}
	else /*无轨道板*/
	{
		/*更新物理区段占用状态*/
		PhySecRelayToDeviceStateProc();
	}

	/*更新道岔逻辑状态*/
	if (CI_TRADITION_RAILWAY == chLineIdentity)
	{/*城轨交通线路类型*/

		if (CI_PATTERN_TRADITIONAL == CiPattern)/*传统联锁*/
		{
			SwitchRelayToDeviceStateProc();
		}
		else if (CI_PATTERN_FULL_ELECTRONIC == CiPattern)/*全电子联锁*/
		{
			if (FUNC_SWITCH_ON == chDsnLinSwitch)
			{
				SwitchRelayToDeviceStateProc();
			}
			else
			{
				/*全电子联锁模式下，处理更新道岔逻辑状态*/
				/******************************************************************************/
				OcSwitchDeviceInput();
			}
		}
		else
		{
			/*不做处理*/
		}
	}/* zt 删除单轨相关代码 2022-02-15 */
	else
	{

	}
	/*全电子联锁*/
	if(CI_PATTERN_FULL_ELECTRONIC == CiPattern)
	{
		/*更新联络线逻辑状态*/
		ConnectLineRelayToDevStateProc();
	}

	/*更新屏蔽门逻辑状态*/
	PsdRelayToDeviceStateProc();
	
	/*更新紧急停车按钮逻辑状态*/
	(void)EsbRelayToDeviceStateProc();

#if 0
	/*屏蔽门状态转移处理*/
	PsdStateTransferProc();
#endif

	/* spks 处理 */
	(void)SpksRelayToDeviceStateProc();

    /*信号机临时限速处理*/
	SignalLinShiXianSuFlagCalculate();

	/*车库门处理*/
	(void)GaragedoorRelayToDevStaProc();

	/*洗车机处理*/
	(void)WashMachineToDeviceStateProc();

	/*防淹门处理*/
	FloodGateRelayToDeviceStateProc();

	/*调车同意处理*/
	RouteDCTYRelayToDeviceStateProc();

	if (FUNC_SWITCH_ON == chDsnLinSwitch)
	{
		/*倒切设备继电器处理*/
		RvrsCutRlyToDvicSttPrc();
	}
}


/*
* 功能描述： 处理码位逻辑
* 参数说明：
*			 const UINT8 systemType, 系统设备类型
*			 const UINT8* maskBuf, 码位数据
*			 const UINT16 maskSum, 码位总数
* 返回值  ： 0u: 处理失败
*			 1: 处理成功
*/
UINT8 MaskDataProcess(const UINT8 systemType,const UINT8* maskBuf, const UINT16 maskSum)
{
	UINT16 maskId = 0u;			/*码位ID*/
    UINT16 index = 0u;           /*数组下标*/
	UINT8 DeviceType = 0u;		/*联锁设备类型*/
	UINT8 MaskType = 0u;			/*码位类型*/
	UINT16 DeviceId = 0u;		/*联锁设备ID*/
	UINT16 ii = 0u;				/*游标*/
    UINT16 jj = 0u;
	UINT16 maskConfigSum = 0u;	/*码位配置中码位的总数*/
    UINT8 indicatorContainRelaySum = 0u;/*表示灯包含继电器数目*/
    UINT16* indicatorContainRelayIdBuf = NULL;/*表示灯包含继电器ID数组*/
    UINT8 returnValue = CI_SUCCESS;/*返回值默认成功*/

	UINT8 funcSwitchJumpLockDriveSwitch = 0u;/*功能开关：跳跃锁闭是否驱道岔*/
	UINT32 curCycle = 0u;/*当前周期*/

	UINT16 phyNum = 0u;
	UINT16 phyId = 0u;
	UINT16 axisSecId = 0u;/*计轴区段id*/
	UINT8 phyBelongCiId = 0u;
	UINT8 ciid = 0u;
	UINT16 phyAxisSecNum = 0u;
	UINT16 *pPhyAxisIDBuf = NULL;
	UINT16 numAxisHaveJumpLockApply = 0u;/*计轴区段有跳跃锁闭申请的数量*/
	UINT8  applyFlag = 0u;/*申请标志*/
	UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 signalLightExtinctRet = 0U;
	UINT8 cLogSecTsrState = LOGSEC_LSXS_SET_STATE_NO;
	UINT8 chRtnIndcDevId = 0U;/*无人折返指示灯设备ID*/

	ciid = GetSystemParaLocalCiId();/*获取本联锁ID*/
	phyNum = GetPhySecCurSum();

	funcSwitchJumpLockDriveSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_JUMPLOCK_DRIVE_SWITCH);
	curCycle = Get2oo2CurCycleNum();

	maskConfigSum = GetReceiveMaskSum(systemType);
	if (maskConfigSum > maskSum)
	{
        returnValue = CI_ERROR;
		return returnValue;
	}

	for (ii = 0u; ii < maskConfigSum; ii++)
	{
		maskId = (UINT16)(ii + 1U);/*码位ID*/
        index = GetMaskIndex(CI_SYSTEM_TYPE_ZC, CI_SYSTEM_TYPE_CI, maskId);
        if (index != 0u)
        {
            DeviceType = GetReceiveMaskDeviceType(systemType, index);
            DeviceId = GetReceiveMaskDeviceId(systemType, index);
            MaskType = GetReceiveMaskType(systemType, index);
        }
        else
        {
            continue;
        }
		

		switch (DeviceType)
		{
		case CI_DEVICE_TYPE_SWITCH:
			/*道岔设备类型*/
            
			break;
		case CI_DEVICE_TYPE_SIGNAL:
			/*信号机设备类型*/
			switch (MaskType)
			{
			case MASK_TYPE_SIGNAL_OPENSTATE:/*信号机开放状态码位*/
				break;
			case MASK_TYPE_SIGNAL_LIGHTSTATE:/*信号机亮灭状态码位*/
				if (1U == maskBuf[ii])
				{/*信号机强制灭灯*/

					signalLightExtinctRet = SetSignalLightExtinctState(DeviceId, SIGNAL_LIGHT_EXTICT_STATE_NO);
					if (CI_ERROR == signalLightExtinctRet)
					{
						/*信号机设置亮灯失败*/
					}
				}
				else
				{/*信号机亮灯*/

					signalLightExtinctRet = SetSignalLightExtinctState(DeviceId, SIGNAL_LIGHT_EXTICT_STATE_YES);
					if (CI_ERROR == signalLightExtinctRet)
					{
						/*信号机设置亮灯失败*/
					}
				}
				break;
			case MASK_ZC_CI_TYPE_SIGNAL_OCCUPYED:/*通信车跨压信号机码位*/
				if (1U == maskBuf[ii])
				{/*通信车跨压信号机*/
					
					(void)SetSignalCrossState(DeviceId, SIGNAL_CROSS_STATE_YES);/*设置通信车跨压信号机*/
				}
				else
				{
					
					(void)SetSignalCrossState(DeviceId, SIGNAL_CROSS_STATE_NO);/*设置通信车未跨压信号机*/
				}
				break;
			case MASK_ZC_CI_SIG_ENGINEERV_NEAR:/*信号机工程车接近码位*/
				if (1u == maskBuf[ii])
				{

					SetSigEngineerVehicleNearSte(DeviceId, SIG_ENGINEERVEHICNEAR_STE_YES);/*设置信号机工程车接近码位*/
				}
				else
				{

					SetSigEngineerVehicleNearSte(DeviceId, SIG_ENGINEERVEHICNEAR_STE_NO);
				}
				break;
			case MASK_CI_ZC_SIG_ENGINCROSS_STE:/*信号机工程车跨压关闭码位*/
				break;
			default:
                returnValue = CI_ERROR;
				break;
			}
			break;
		case CI_DEVICE_TYPE_PHYSEC:
			/*物理区段设备类型*/
			
			switch (MaskType)
			{
			case MASK_TYPE_LOGICSECTION_UTOCCUPY:/*非通信车占用码位*/
				break;
            case MASK_TYPE_LOGICSECTION_CTOCCUPY:/*通信车占用码位*/
				break;
			case MASK_TYPE_PHYSECTION_ROUTELOCK:/*区段进路锁闭码位*/
				break;
			case MASK_TYPE_AXISSECTION_ARB:/*区段ARB状态码位*/
				if (1U == maskBuf[ii])
				{
					SetAxisSecArbState(DeviceId, AXIS_SECTION_ARB_YES);/*设置计轴区段ARB*/
				}
				else
				{
					SetAxisSecArbState(DeviceId, AXIS_SECTION_ARB_NO);/*设置计轴区段未ARB*/
				}
				break;
			case MASK_TYPE_LIECHE_STOPSTATE:/*列车停稳信息状态码位*/
				if (maskBuf[ii] == 1u)
				{/*列车停稳*/
					
					SetPhySecStopSteadyFlag(DeviceId, PHYSICAL_SECTION_STOPSTEADY_YES);/*设置物理区段停稳*/
				}
				else
				{
					
					SetPhySecStopSteadyFlag(DeviceId, PHYSICAL_SECTION_STOPSTEADY_NO);/*设置物理区段未停稳*/
				}
				break;
			case MASK_TYPE_PHYSECTION_JUMPLOCK_APPLY:/*计轴区段跳跃锁闭申请码位*/
				if (1u == maskBuf[ii])
				{/*ZC申请跳跃锁闭*/
					SetAxisSecJumpLockApplyFlag(DeviceId,AXIS_SECTION_JUMPLOCK_APPLY_YES);/*设置计轴区段有跳跃锁闭申请*/
					(void)SetAxisSecJumpLockApplyCylce(DeviceId,curCycle);/*设置计轴区段跳跃锁闭申请周期号*/
				}
				else
				{
					SetAxisSecJumpLockApplyFlag(DeviceId,AXIS_SECTION_JUMPLOCK_APPLY_NO);/*设置计轴区段无跳跃锁闭申请*/
				}				
				break;
			case MASK_TYPE_PHYSECTION_JUMPLOCK_CANCEL:/*物理区段跳跃锁闭取消码位*/
				if (1u == maskBuf[ii])
				{/*ZC申请取消跳跃锁闭*/
					(void)SetAxisSecJLockCancelApplyFlag(DeviceId,AXSEC_CANCEL_JUMPLOCK_APPLY_YES);/*设置计轴区段有取消跳跃锁闭申请*/
					(void)SetAxisSecJumpLockApplyCylce(DeviceId, 0U);/*清零计轴区段跳跃锁闭申请周期号*/
				}
				else
				{
					(void)SetAxisSecJLockCancelApplyFlag(DeviceId,AXSEC_CANCEL_JUMPLOCK_APPLY_NO);/*设置计轴区段无取消跳跃锁闭申请*/
				}
				break;
            default:
                returnValue = CI_ERROR;
                break;
			}
			break;
		case CI_DEVICE_TYPE_LOGICSEC:
			/*逻辑区段设备类型*/
			switch (MaskType)
			{
			case MASK_TYPE_LOGICSECTION_UTOCCUPY:/*逻辑区段非通信车占用码位*/
				if (maskBuf[ii] == 1u)
				{/*逻辑区段状态为空闲*/

                    /*通信车占用码位已经设置空闲或通信车占用，不动作*/
					SetLogSecMask(DeviceId ,LOGIC_MASK_NO);
                }
				else
				{
					SetLogSecMask(DeviceId ,LOGIC_MASK_UT);
				}
				break;
            case MASK_TYPE_LOGICSECTION_CTOCCUPY:/*逻辑区段通信车占用码位*/
                if (maskBuf[ii] == 1u)
                {/*逻辑区段状态为空闲*/
					SetLogSecMask(DeviceId ,LOGIC_MASK_NO);
                    
                }
                else
                {
					SetLogSecMask(DeviceId ,LOGIC_MASK_CT);
                }
				break;

			case MASK_TYPE_LOGICSECTION_TXOCCUPY:/*逻辑区段通信车占用码位,A by yt 2022年5月19日*/   /*TSCI合并添加 20221208-lc*/
				if (1u == maskBuf[ii])
				{
					SetLogSecTXOccupyState(DeviceId, LOGICSECTION_OCCUPY_TX);

				}
				else
				{
					SetLogSecTXOccupyState(DeviceId, LOGICSECTION_OCCUPY_NO_TX);
				}
				break;

			case MASK_TYPE_LOGICSECTION_LINSHIXIANSU_SET:/*逻辑区段临时限速设置码位*/
				if(1u == maskBuf[ii])
				{/*逻辑区段未设置临时限速*/
					SetLogSecLinShiXianSuState(DeviceId, LOGSEC_LSXS_SET_STATE_NO);
				}
				else
				{/*逻辑区段设置了临时限速*/
					cLogSecTsrState = GetLogSecLinShiXianSuSetState(DeviceId);

					SetLogSecLinShiXianSuState(DeviceId, LOGSEC_LSXS_SET_STATE_YES);

					if (LOGSEC_LSXS_SET_STATE_YES != cLogSecTsrState)
					{
						ClearLgcSecBelongRtXsCfm(DeviceId);
					}
				}
				break;

			default:
                returnValue = CI_ERROR;
				break;
			}
			break;
		case CI_DEVICE_TYPE_OVERLAP:
			/*保护区段设备类型*/

			break;
		case CI_DEVICE_TYPE_PLATFORM:
			/*站台设备类型*/
			switch (MaskType)
			{
			case MASK_TYPE_PLAT_AUTORETURNSIG_FLASH:/*站台无人折返灯闪灯码位*/
			case MASK_TYPE_PLAT_AUTORETURNSIG_STEADY:/*站台无人折返灯稳灯码位*/
				if(FUNC_SWITCH_ON == includeVirFlag)
				{
					DealAutoReturnMask_UseVirCI(DeviceId,maskBuf,MaskType,ii);
				}
				else
				{
					for (jj = 0u; jj < GetIndicatorCurSum(); jj++ )
					{
						if ((DeviceId == GetIndicatorId(jj))
							&& (INDICATOR_TYPE_EXPRESS_RETURN == GetIndicatorType(DeviceId)))
						{/*设备ID对应且指示灯类型为无人折返灯*/
							indicatorContainRelaySum = GetIndicatorRelaySum(DeviceId);
							indicatorContainRelayIdBuf = GetIndicatorRelayIdBuf(DeviceId);
							if ((3u != indicatorContainRelaySum)||(NULL == indicatorContainRelayIdBuf))
							{/*继电器数据错误*/

								returnValue = CI_ERROR;
								break;
							}
							else
							{/*继电器数据正确*/	
								chRtnIndcDevId = GetIndicatorRelNonReturnId(DeviceId);
								if (MaskType == MASK_TYPE_PLAT_AUTORETURNSIG_FLASH)
								{/*闪灯码位第一个继电器位置*/

									if (maskBuf[ii] == 1u)
									{/*闪灯命令*/
										SetAutoRtnIndictFlashState(chRtnIndcDevId,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*闪灯状态有效*/
									}
									else
									{/*无闪灯命令*/
										SetAutoRtnIndictFlashState(chRtnIndcDevId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*闪灯状态无效*/
									}
								}
								else
								{/*稳灯码位第二个继电器位置*/

									if (maskBuf[ii] == 1u)
									{/*稳灯命令*/
										SetAutoRtnIndictSteadyState(chRtnIndcDevId,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*稳灯状态有效*/
									}
									else
									{/*无稳灯命令*/
										SetAutoRtnIndictSteadyState(chRtnIndcDevId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*稳灯状态无效*/
									}
								}
							}				                        
						}
					}
				}
				break;
			case MASK_TYPE_ESP_STATE:/*站台紧急关闭按钮状态码位*/
				break;
			case MASK_TYPE_PSD_STATE:/*站台屏蔽门状态码位-给ZC,LEU*/
				break;
			case MASK_TYPE_PSD_STATE_ATS:/*站台屏蔽门状态码位-给ATS*/
				break;
            case MASK_TYPE_MUTUALLOCK_STATE:
                break;
            default:
                returnValue = CI_ERROR;
                break;
			}
			break;
		case CI_DEVICE_TYPE_ROUTE:
			if (MASK_TYPE_ROUTE_STOPENABLEE_STATUS == MaskType)   /*停车保证码位处理*/
			{
				if (maskBuf[ii] == 1u)
				{
					SetRouteStopensureFlag(DeviceId,ROUTE_STOPENSURE_YES);
				} 
				else
				{
					SetRouteStopensureFlag(DeviceId,ROUTE_STOPENSURE_NO);

				}
			} 

			break;

		case CI_DEVICE_TYPE_GARAGEDOOR:
			if (MASK_TYPE_GARAGEDOOR_ALLOWCLOSE_STATE == MaskType)    /*车库门相关码位处理*/
			{
				if (maskBuf[ii] == 1u)
				{
					SetGaragedoorAllowCloseFlag(DeviceId,GARAGE_DOOR_ALLOW_CLOSE_YES);
				} 
				else
				{
					SetGaragedoorAllowCloseFlag(DeviceId,GARAGE_DOOR_ALLOW_CLOSE_NO);

				}
			} 

			break;

		case CI_DEVICE_TYPE_FLOODGATE:/*防淹门*/
			{
				if (MASK_TYPE_FLOODGATE_YXGM_FROMZC == MaskType)
				{
					if (1u == maskBuf[ii])
					{
						(void)SetFloodGateCurZCAgrCloseAck(DeviceId,FLOOD_GATE_ALLOWCLOSE_ZC);
					}
					else
					{
						(void)SetFloodGateCurZCAgrCloseAck(DeviceId,FLOOD_GATE_NOT_ALLOWCLOSE_ZC);
					}
				}
			}
			break;
		default:
            returnValue = CI_ERROR;
			break;
		}

	}


	if (FUNC_SWITCH_ON == funcSwitchJumpLockDriveSwitch)
	{/*跳跃锁闭驱道岔开关打开，才处理同一物理区段多计轴区段申请跳跃锁闭错误*/
		for (ii = 0u; ii < phyNum; ii++)
		{
			phyId = GetPhySecId(ii);
			phyBelongCiId = GetPhySecBelongCiId(phyId);
			phyAxisSecNum = GetPAxisSectionSum(phyId);/*获取物理区段关联计轴区段数量*/
			pPhyAxisIDBuf = GetPAxisSectionIdBuf(phyId);/*获取物理区段关联计轴区段ID数组*/
			numAxisHaveJumpLockApply = 0u;
			if (NULL != pPhyAxisIDBuf)
			{
				if (phyBelongCiId == ciid)
				{/*物理区段属于本联锁*/
					for (jj=0u;jj<phyAxisSecNum;jj++)
					{
						axisSecId = pPhyAxisIDBuf[jj];
						applyFlag = GetAxisSecJumpLockApplyFlag(axisSecId);
						if (AXIS_SECTION_JUMPLOCK_APPLY_YES == applyFlag)
						{
							numAxisHaveJumpLockApply++;
						}
					}
					if (numAxisHaveJumpLockApply > 1u)
					{/*一个物理区段多个计轴区段有跳跃锁闭申请*/
						/*把这个物理区段的所有的计轴区段锁闭申请都设置成未申请*/
						for (jj=0u;jj<phyAxisSecNum;jj++)
						{
							axisSecId = pPhyAxisIDBuf[jj];
							SetAxisSecJumpLockApplyFlag(axisSecId,AXIS_SECTION_JUMPLOCK_APPLY_NO);
							(void)SetAxisSecJumpLockApplyCylce(axisSecId,0u);
						}
						/*增加错误码记录*/
						SetErrorData(EFUNC_ZC_CI_MaskDataProcess,CI_DEVICE_TYPE_PHYSEC,phyId,
							ETYPE_PHY_MUTY_AXISSEC_JUMPLOCK_APPLY,AXIS_SECTION_JUMPLOCK_APPLY_YES,ESEND_LEVEL_ZERO);
					}
				}
			
			}
		
		}
	}
	return returnValue;
}

/*
* 功能描述： 处理CI到CI数据
* 参数说明： void
* 返回值  ： 无
*			      
*/
void ProcessCiToCiData(void)
{
	UINT8 localCiId = GetSystemParaLocalCiId();			/*本地联锁ID*/									
	UINT8 jj = 0u;
	UINT8 tranCiNum = 0u;
	UINT8* tranCiIdBuf = NULL;
	UINT8 tranCiState = 0u;
	UINT8 sameLineFlag = SAME_LINE_ERR;/*标记两个CI是否属于同一条线路*/

	/*如果相邻联锁通信中断则重置数据*/
	tranCiNum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_CI);
	tranCiIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_CI);

	for (jj = 0u;jj<tranCiNum;jj++)
	{
		sameLineFlag = IsSameLineCI(localCiId, tranCiIdBuf[jj]);

		if (SAME_LINE_YES == sameLineFlag)
		{
			/*更新与CI通信状态*/
			(void)UpdateCiTransmitState(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_CI, tranCiIdBuf[jj]);

			tranCiState = GetCiTransmitState(CI_SYSTEM_TYPE_CI, tranCiIdBuf[jj]);
			if (TRANSMIT_STATE_GOOD != tranCiState)
			{
				ResetDynamicState(tranCiIdBuf[jj]);/*其他联锁的动态数据*/
				NeighborOutTrainProc(tranCiIdBuf[jj]);
				ResetTrainTestDevState(tranCiIdBuf[jj]);
			}
			else
			{
				NeighborGoodTrainProc(tranCiIdBuf[jj]);
				NeighborGoodEaProc(tranCiIdBuf[jj]);
				NeighborGoodRrmProc(tranCiIdBuf[jj]);

			}
		}
		else if (SAME_LINE_NO == sameLineFlag)
		{
			if (CI_SUCCESS != GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_CI, tranCiIdBuf[jj]))
			{
				ResetCiDevStateHlht(tranCiIdBuf[jj]);
			}
		}
		else
		{
			/*不做处理*/
		}
	}

	/*更新本联锁继电接口确认状态*/
	UpdateRelayInterfaceConfirmFlag();

	/*处理TCT联锁间命令*/
	ProcessTctCiCmd();
	/*处理互联互通相邻线联锁命令*/
	ProcessHlhtCiCmd();
}


/*
* 功能描述： 更新物理区段融合逻辑状态
* 参数说明： void
* 返回值  ： void
* 修复bug YF0083-126
*/
void UpdatePhySectionMergeLogicState(void)
{
    UINT16 phySecCurSum = 0u;	 /*物理区段总数目*/
    UINT8 localCiId = 0u;         /*本地联锁ID*/
    
    UINT16 phySectionId = 0u;	 /*物理区段ID*/
    UINT8 belongCiId = 0u;        /*物理区段所属联锁ID*/
    UINT16 gdRelayId = 0u;        /*物理区段轨道继电器ID*/
	UINT16 ii = 0u;               /*循环索引*/

    /*设置区段占用起始周期计数使用变量*/
    UINT8 jj = 0u;
    UINT16 routeId = 0u;             /*物理区段所属进路ID*/
    UINT16 preSecId = 0u;            /*上一个物理区段ID*/
    UINT8 routePhySecSum = 0u;       /*进路包含物理区段数目*/
	UINT8 physecManagedByZcFlag = 0u;	/*物理区段是否属于ZC管辖区域标志*/
    RoutePhysicalSectionStruct *routePSSecStru = NULL; /*进路包含物理区段数据*/
    RouteNearPhySectionStruct *routeNearPSSecStru = NULL;/*进路接近物理区段数据*/

    /*ARB状态*/
    UINT8 arbState = 0u;
    /*物理区段当前采集占用状态*/
    UINT8 phySecCurCollOccuState = 0u;

    /*逻辑区段占用状态*/
    UINT8 allLogicSecOccustate = 0u;
    UINT8 comunicationState = 0u;

    /*区段占用状态状态*/
    UINT8 mergeOccuState = SECTION_OCCUPY_NO;
	/*区段与占用原则占用状态状态*/
	UINT8 andMergeOccuState = SECTION_OCCUPY_NO;
    /*区段占用之前状态*/
    UINT8 phySecPreOccuState = SECTION_OCCUPY_NO;
    /*空闲变占用时间状态*/ 
    UINT8 phySecOccuChangeTimeState = CI_TIME_OUT;
	/*物理区段CT或UT占用状态，设置为(UT)占用状态*/
	UINT8 curUtOrCtOccFlag = LOGICSECTION_OCCUPY_UT;	
	UINT8 chPreUtOrCtOccFlag = LOGICSECTION_OCCUPY_UT;

	UINT32 secOccupy2IdleTimeReal = 0u;
	UINT32 secOccupy2IdleTimeSysPara = 0u;
	

	UINT32 dwSystemCyc = 0u;
	UINT32 dwSecCurOccupyCyc = 0u;
	UINT8 cPhySecLjkFlag = PHYSICAL_SECTION_LJK_NO;
	UINT8 cPhySecStopCheckFlag = PHYSICAL_STOPCHECK_SET_NO;
	UINT8 phySecCurOccuState = SECTION_OCCUPY_NO;
	UINT32 dwSecUtOrCtOccuCyc = 0u;

	UINT8 goExec = CI_ERROR;
	UINT8 phySecBelongCi = 0u;/*物理区段所属联锁*/
	UINT8 commState = 0u;/*通信状态*/

	UINT8 chFunRtn = CI_ERROR;
	UINT8 chSwitch = 0u;
	UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI);
	UINT8 localCi = GetSystemParaLocalCiId();/*本机联锁*/
	UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*继电接口确认状态*/
	UINT8* pSourceIdBuf = NULL;		/*源IDBuf*/
	UINT8  zcCommState = 0u;
	UINT8 cRcWorkMode = 0u;
	UINT8 chPreAblFlag = 0U;
	UINT8 chCurAblFlag = 0U;
	cRcWorkMode = GetLocalRcWorkMode();

    /*CI区段信息获取*/
    phySecCurSum = GetTotalPhySecCurNum();		/*获取物理区段总数*/
	localCiId = GetSystemParaLocalCiId();       /*获取本机联锁ID*/
	secOccupy2IdleTimeSysPara = GetSystemParaOccuToIdleCyc();
	dwSystemCyc = Get2oo2CurCycleNum();			/* 获取当前周期号 */

    /*处理物理区段*/
    for (ii = 0u; ii < phySecCurSum; ii++)
    {
        phySectionId = 0u;	      /*物理区段ID*/
        belongCiId = 0u;       /*物理区段所属联锁ID*/
        gdRelayId = 0u;        /*物理区段轨道继电器ID*/
        
        
        phySectionId = GetPhySecId(ii);                      /*获取物理区段ID*/
        belongCiId = GetPhySecBelongCiId(phySectionId);      /*获取物理区段所属联锁ID*/
		physecManagedByZcFlag = GetPhySecManagedByZcFlag(phySectionId);		/*获取物理区段是否属于ZC管辖区域标志*/

        if ((0u == phySectionId) || (PHYSICAL_SECTION_SUM_MAX < phySectionId))
        {
			/* 跳过 */
        }
        else
		{
			goExec = CI_SUCCESS;
			phySecBelongCi = GetPhySecBelongCiId(phySectionId);/*获取物理区段所属联锁*/
			commState = GetLocalCiAndOtherCiTransSta(phySecBelongCi);/*本联锁与其它联锁通信通信状态*/


			if (((belongCiId == localCiId) && (localCiId > 0u))
				||(((belongCiId != localCiId) && (localCiId > 0u) 
					&&(TRANSMIT_STATE_BAD == commState) 
					&&(CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag) 
					&&(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface))))
			{
				/*初始化为占用*/
				mergeOccuState = SECTION_OCCUPY_NO;
				phySecOccuChangeTimeState = CI_TIME_OUT;

				/*获取状态，V2.0 版本上线ARB功能*/
				arbState = GetArbState(phySectionId); 

				allLogicSecOccustate = GetLogicSecOccuState(phySectionId);
				
				phySecCurCollOccuState = GetPhySecCurOccupyState(phySectionId);

				if (RC_WORK_MODE_TIOC == cRcWorkMode)
				{
					chSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH);
					if (FUNC_SWITCH_ON == chSwitch)
					{
						if (SECTION_OCCUPY_NO == phySecCurCollOccuState)
						{
							/* 采集状态融合列车占用序列 */
							chFunRtn = IsPhyFree(phySectionId);
							if (CI_ERROR == chFunRtn)
							{
								phySecCurCollOccuState = SECTION_OCCUPY_YES;
							}
							else
							{
								;
							}
						}
						else
						{
							;
						}
					}
					else
					{
						; /* 采集占用无需融合故障占用 */
					}
				}
				else
				{
					pSourceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC);/*获取与本联锁通信的ZC的ID，目前一个联锁最多只与一个ZC通信*/

					if (pSourceIdBuf != NULL)
					{
						/*更新与ZC通信状态*/
						(void)UpdateCiTransmitState(localCi, CI_SYSTEM_TYPE_ZC, pSourceIdBuf[0]);
						zcCommState = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_ZC, pSourceIdBuf[0]);
						/*通信异常*/
						if (CI_ERROR == zcCommState)
						{
							comunicationState = TRANSMIT_STATE_BAD;
						}
						else
						{
							comunicationState = TRANSMIT_STATE_GOOD;
						}
					}
				}

				phySecPreOccuState = GetPhySecCurMergeState(phySectionId);
        
				routeId = GetPhySecRLockBelongRouteId(phySectionId);

				routePhySecSum = GetRoutePhysicalSectionSum(routeId);
				routePSSecStru = GetRouteSectionData(routeId);

				preSecId = 0u;
				for (jj = 0u; jj < routePhySecSum; jj++)
				{
					if (routePSSecStru[jj].PhysicalSectionId == phySectionId)
					{/*找到进路中的该物理区段*/

						if (jj > 0u)
						{/*非第一个物理区段*/

							preSecId = routePSSecStru[jj - 1U].PhysicalSectionId;                            
						}
						else
						{
							routeNearPSSecStru = GetRouteBlocNearPhySectionStru(routeId);
							if (NULL != routeNearPSSecStru)
							{
								preSecId = routeNearPSSecStru[0].NearPhySecIdBuf[0];
							}
							else
							{
								preSecId = 0u;
							}

						}
						break;

					}
				}
  

				if (RC_WORK_MODE_TIOC == cRcWorkMode)
				{
					if (AXIS_SECTION_ARB_YES == arbState)
					{
						/*ARB有效 采用逻辑区段*/
						if (SECTION_OCCUPY_NO == allLogicSecOccustate)
						{
							/*逻辑区段空闲*/
							/*融合状态空闲*/
							mergeOccuState = SECTION_OCCUPY_NO;
							andMergeOccuState = SECTION_OCCUPY_NO;
						}
						else
						{
							/*融合状态占用*/
							mergeOccuState = SECTION_OCCUPY_YES;
							andMergeOccuState = SECTION_OCCUPY_YES;
						}
					}
					else
					{
						/*ARB无效 物理或逻辑空闲即认为空闲*/
						if ((SECTION_OCCUPY_NO == phySecCurCollOccuState) || (SECTION_OCCUPY_NO == allLogicSecOccustate))
						{
							/*融合状态空闲*/
							mergeOccuState = SECTION_OCCUPY_NO;
						}
						else
						{
							/*融合状态占用*/
							mergeOccuState = SECTION_OCCUPY_YES;
						}

						/*与占用原则处理*/
						/*ARB无效 物理或逻辑占用即认为占用*/
						if ((SECTION_OCCUPY_YES == phySecCurCollOccuState) || (SECTION_OCCUPY_YES == allLogicSecOccustate))
						{
							/*融合状态占用*/
							andMergeOccuState = SECTION_OCCUPY_YES;
						}
						else
						{
							/*融合状态空闲*/
							andMergeOccuState = SECTION_OCCUPY_NO;
						}


					}
				}
				else
				{
					/*ZC信息融合占用状态*/
					if (comunicationState == TRANSMIT_STATE_BAD)
					{
						/*通信失败*/
						if (phySecCurCollOccuState == SECTION_OCCUPY_NO)
						{
							/*当前物理区段采集状态空闲*/
							/*融合状态空闲*/
							mergeOccuState = SECTION_OCCUPY_NO;
							andMergeOccuState = SECTION_OCCUPY_NO;
						}
						else
						{
							/*融合状态占用*/
							mergeOccuState = SECTION_OCCUPY_YES;
							andMergeOccuState = SECTION_OCCUPY_YES;
						}
					}
					else if (comunicationState == TRANSMIT_STATE_GOOD)
					{
						/*通信正常*/
						if (arbState == AXIS_SECTION_ARB_YES)
						{
							/*ARB有效 采用逻辑区段*/
							if (allLogicSecOccustate == SECTION_OCCUPY_NO)
							{
								/*逻辑区段空闲*/
								/*融合状态空闲*/
								mergeOccuState = SECTION_OCCUPY_NO;
								andMergeOccuState = SECTION_OCCUPY_NO;
							}
							else
							{
								/*融合状态占用*/
								mergeOccuState = SECTION_OCCUPY_YES;
								andMergeOccuState = SECTION_OCCUPY_YES;
							}
						}
						else
						{
							/*ARB无效 物理或逻辑空闲即认为空闲*/
							if ((phySecCurCollOccuState == SECTION_OCCUPY_NO) || (allLogicSecOccustate == SECTION_OCCUPY_NO))
							{
								/*融合状态空闲*/
								mergeOccuState = SECTION_OCCUPY_NO;
							}
							else
							{
								/*融合状态占用*/
								mergeOccuState = SECTION_OCCUPY_YES;
							}

							/*与占用原则处理*/
							/*ARB无效 物理或逻辑占用即认为占用*/
							if (PHY_SEC_MANAGED_BY_ZC_YES == physecManagedByZcFlag)
							{/*物理区段属于ZC管辖区域*/
								if ((phySecCurCollOccuState == SECTION_OCCUPY_YES) || (allLogicSecOccustate == SECTION_OCCUPY_YES))
								{
									/*融合状态占用*/
									andMergeOccuState = SECTION_OCCUPY_YES;
								}
								else
								{
									/*融合状态空闲*/
									andMergeOccuState = SECTION_OCCUPY_NO;
								}
							}
							else if (PHY_SEC_MANAGED_BY_ZC_NO == physecManagedByZcFlag)
							{/*物理区段不属于属于ZC管辖区域，与占用采用物理采集状态*/
								andMergeOccuState = phySecCurCollOccuState;
							}
							else
							{/*其他情况，与占用采用物理采集状态*/
								andMergeOccuState = phySecCurCollOccuState;
							}

						}
					}
					else
					{
						/* 通信不正确 */
						/* 参数异常 */
						/*融合状态为采集状态*/
						mergeOccuState = phySecCurCollOccuState;
						andMergeOccuState = phySecCurCollOccuState;
					}
				}
        
				/* 获取占用到空闲计时周期 */
				secOccupy2IdleTimeReal = GetSecOccuToClearStartCycNum(phySectionId);
				/*占用到空闲融合*/
				if ((SECTION_OCCUPY_YES == phySecPreOccuState ) && (SECTION_OCCUPY_NO == mergeOccuState))
				{

					/*区段占用变空闲*/      
					phySecOccuChangeTimeState = SystemOverTimeCheck(secOccupy2IdleTimeReal, secOccupy2IdleTimeSysPara);

					if (CI_TIME_NO == phySecOccuChangeTimeState  )
					{
						/*变化时间未设置 设置计时*/
						SetSecOccuToClearStartCycNum(phySectionId, dwSystemCyc);

						/*保持占用*/
						mergeOccuState = SECTION_OCCUPY_YES;
					}
					else if (CI_TIME_IN == phySecOccuChangeTimeState  )
					{
						/*变化时间未到*/
						/*保持占用*/
						mergeOccuState = SECTION_OCCUPY_YES;
					}
					else if (CI_TIME_OUT == phySecOccuChangeTimeState)
					{
						/*变化时间到时*/  
						/*清除计时*/
						SetSecOccuToClearStartCycNum(phySectionId, 0u);

						/*区段空闲*/
						mergeOccuState = SECTION_OCCUPY_NO;

					}
					else
					{
						/*不做处理*/
					}
				}
				else if((SECTION_OCCUPY_YES == mergeOccuState) && (0u != secOccupy2IdleTimeReal))
				{
					/*保持融合状态，需要清除计时*/
					SetSecOccuToClearStartCycNum(phySectionId, 0u);
				}
				else
				{
					/*保持融合状态*/
				}


				/*设置融合占用状态*/
				SetPhySecCurMergeState(phySectionId,mergeOccuState);

				/*设置与占用原则占用状态 只有动道岔时才使用 不用在解锁 因此未延时*/
				SetPhySecCurAndMergeState(phySectionId,andMergeOccuState);

				/* 区段变占用计时 */
				if ((SECTION_OCCUPY_NO == phySecPreOccuState) && (SECTION_OCCUPY_YES == mergeOccuState))
				{
					/*空闲变占用*/
					/*区段由空闲变占用则清除区段停止检查标志，当区段再次被占压则停止检查为无效*/
					SetPhySectionStopCheckFlag(phySectionId, PHYSICAL_STOPCHECK_SET_NO);

					/*该区段的上一区段与该区段同时占用时设置占用开始时间*/
					if (routeId > 0u)
					{/*物理区段进路锁闭*/

						phySecCurOccuState = GetPhySecCurMergeState(preSecId);
						if ((0u != preSecId) &&
							(SECTION_OCCUPY_YES == phySecCurOccuState))
						{/*上一物理区段同时占用*/

							/*设置占用开始时间*/
							SetSecCurOccupyStartCycNum(phySectionId, dwSystemCyc);
							/*设置物理区段UT或CT占用开始时间*/
							SetSecUtOrCtOccuStartCycNum(phySectionId, dwSystemCyc);
						}

					}
           
				}
				else if ((SECTION_OCCUPY_YES == phySecPreOccuState) && (SECTION_OCCUPY_NO == mergeOccuState))
				{  
					 /*占用变空闲*/
					/*当信号机内方第一区段为列检库区段，占用出清不应关闭信号机，此处为特殊处理，将之前状态设为空闲,
					当区段前一区段为占用时则认为占用*/
					dwSecCurOccupyCyc = GetSecCurOccupyStartCycNum(phySectionId);
					cPhySecLjkFlag = GetPhySecLjkFlag(phySectionId);
					cPhySecStopCheckFlag = GetPhySectionStopCheckFlag(phySectionId);
					phySecCurOccuState = GetPhySecCurMergeState(preSecId);
					if((0u == dwSecCurOccupyCyc)
						&& (PHYSICAL_SECTION_LJK_YES == cPhySecLjkFlag) 
						&& (PHYSICAL_STOPCHECK_SET_YES == cPhySecStopCheckFlag) 
						&& (SECTION_OCCUPY_NO == phySecCurOccuState))
					{
						SetPhySecPreMergeState(phySectionId, SECTION_OCCUPY_NO);
					}
					/*取消占用开始时间*/
					SetSecCurOccupyStartCycNum(phySectionId, 0u);

					/*取消物理区段UT或CT占用开始时间*/
					SetSecUtOrCtOccuStartCycNum(phySectionId, 0u);
				}
				else
				{
					 /*继续计时*/
				}

				phySecCurOccuState = GetPhySecCurMergeState(phySectionId);
				if(SECTION_OCCUPY_YES == phySecCurOccuState)
				{
					curUtOrCtOccFlag = GetPhySecCurCtOrUtOccupyState(phySectionId);	/*获取物理区段当前CT或UT占用状态*/
					chPreUtOrCtOccFlag = GetPhySecPreOccState(phySectionId);				/*获取物理区段之前CT或UT占用状态*/
					dwSecUtOrCtOccuCyc = GetSecUtOrCtOccuStartCycNum(phySectionId);
					/*倒计时过程中，物理区段车占用状态发生变化，并且解锁已开始倒计时*/
					if((chPreUtOrCtOccFlag != curUtOrCtOccFlag) && (0u != dwSecUtOrCtOccuCyc))
					{
						if (LOGICSECTION_OCCUPY_NO != curUtOrCtOccFlag)
						{
							/*重新设置物理区段UT或CT占用开始时间*/
							SetSecUtOrCtOccuStartCycNum(phySectionId, dwSystemCyc);
						}
						else
						{
							/*逻辑区段均空闲，物理区段尚未融合空闲，暂不更新*/
						}
					}
					else if (LOGICSECTION_OCCUPY_UT == curUtOrCtOccFlag)
					{
						/*UT占压 ABL级别跳变 重新设置物理区段UT或CT占用开始时间*/
						chCurAblFlag = GetPhySecABLTrainFlag(phySectionId);
						chPreAblFlag = GetPhySecPreABLTrainFlag(phySectionId);
						if (chCurAblFlag != chPreAblFlag)
						{
							SetSecUtOrCtOccuStartCycNum(phySectionId, dwSystemCyc);
						}
					}
					else
					{
						/*解锁保护区段过程中，进路最后一个物理区段车占用未发生变化，正常倒计时*/
					}
					/*将物理区段上周期占用状态设置为之前占用状态*/
					SetPhySecPreOccState(phySectionId, curUtOrCtOccFlag);
				}
				else
				{
					SetPhySecPreOccState(phySectionId, LOGICSECTION_OCCUPY_NO);
				}

				if(SECTION_OCCUPY_NO == phySecCurOccuState)
				{
					/*取消物理区段UT或CT占用开始时间*/
					SetSecUtOrCtOccuStartCycNum(phySectionId, 0u);
				}
				
			}
#if 0
			else if ((belongCiId != localCiId) && (localCiId > 0u) &&
				(TRANSMIT_STATE_BAD == commState) && 
				(CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&&
				(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)
				)
			{
				/*初始化*/
				mergeOccuState = SECTION_OCCUPY_NO;
				phySecOccuChangeTimeState = CI_TIME_OUT;

				/*获取状态，预留ARB状态，暂时不做*/
				arbState = AXIS_SECTION_ARB_NO;
				allLogicSecOccustate = GetLogicSecOccuState(phySectionId);

				phySecCurCollOccuState = GetPhySecCurOccupyState(phySectionId);
				phySecPreOccuState = GetPhySecCurMergeState(phySectionId);
        
				routeId = GetPhySecRLockBelongRouteId(phySectionId);

				routePhySecSum = GetRoutePhysicalSectionSum(routeId);
				routePSSecStru = GetRouteSectionData(routeId);
				preSecId = 0u;
				for (jj = 0u; jj < routePhySecSum; jj++)
				{
					if (routePSSecStru[jj].PhysicalSectionId == phySectionId)
					{/*找到进路中的该物理区段*/

						if (jj > 0u)
						{/*非第一个物理区段*/

							preSecId = routePSSecStru[jj - 1].PhysicalSectionId;                            
						}
						else
						{
							routeNearPSSecStru = GetRouteBlocNearPhySectionStru(routeId);
							if (routeNearPSSecStru != NULL)
							{
								preSecId = routeNearPSSecStru[0u].NearPhySecIdBuf[0u];
							}
							else
							{
								preSecId = 0u;
							}

						}
						break;

					}
				}
  
				/*通信正常*/
				if (AXIS_SECTION_ARB_YES == arbState)
				{
					/*ARB有效 采用逻辑区段*/
					if (SECTION_OCCUPY_NO == allLogicSecOccustate)
					{
						/*逻辑区段空闲*/
						/*融合状态空闲*/
						mergeOccuState = SECTION_OCCUPY_NO;
					}
					else
					{
						/*融合状态占用*/
						mergeOccuState = SECTION_OCCUPY_YES;
					}
				}
				else
				{
					/*ARB无效 物理或逻辑空闲即认为空闲*/
					if ((SECTION_OCCUPY_NO == phySecCurCollOccuState) || (SECTION_OCCUPY_NO == allLogicSecOccustate))
					{
						/*融合状态空闲*/
						mergeOccuState = SECTION_OCCUPY_NO;
					}
					else
					{
						/*融合状态占用*/
						mergeOccuState = SECTION_OCCUPY_YES;
					}

					/*与占用原则处理*/
					/*ARB无效 物理或逻辑占用即认为占用*/
					if ((SECTION_OCCUPY_YES == phySecCurCollOccuState) || (SECTION_OCCUPY_YES == allLogicSecOccustate))
					{
						/*融合状态占用*/
						andMergeOccuState = SECTION_OCCUPY_YES;
					}
					else
					{
						/*融合状态空闲*/
						andMergeOccuState = SECTION_OCCUPY_NO;
					}

				}
        
				/* 获取占用到空闲周期号 */
				secOccupy2IdleTimeReal = GetSecOccuToClearStartCycNum(phySectionId);
				/*占用到空闲融合*/
				if ((SECTION_OCCUPY_YES == phySecPreOccuState) && (SECTION_OCCUPY_NO == mergeOccuState))
				{
					secOccupy2IdleTimeSysPara = GetSystemParaOccuToIdleCyc();
					/*区段占用变空闲*/      
					phySecOccuChangeTimeState = SystemOverTimeCheck(secOccupy2IdleTimeReal, secOccupy2IdleTimeSysPara);

					if (CI_TIME_NO == phySecOccuChangeTimeState  )
					{
						/*变化时间未设置 设置计时*/
						SetSecOccuToClearStartCycNum(phySectionId, dwSystemCyc);

						/*保持占用*/
						mergeOccuState = SECTION_OCCUPY_YES;
					}
					else if (CI_TIME_IN == phySecOccuChangeTimeState  )
					{
						/*变化时间未到*/
						/*保持占用*/
						mergeOccuState = SECTION_OCCUPY_YES;
					}
					else if (CI_TIME_OUT == phySecOccuChangeTimeState)
					{
						/*变化时间到时*/  
						/*清除计时*/
						SetSecOccuToClearStartCycNum(phySectionId, 0u);

						/*区段空闲*/
						mergeOccuState = SECTION_OCCUPY_NO;

					}
				}
				else if ((SECTION_OCCUPY_YES == mergeOccuState) && (0u != secOccupy2IdleTimeReal))
				{
					/*保持融合状态，需要清除计时*/
					SetSecOccuToClearStartCycNum(phySectionId, 0u);
				}
				else
				{
					/*保持融合状态*/
				}


				/*设置融合占用状态*/
				SetPhySecCurMergeState(phySectionId,mergeOccuState);

				/*设置与占用原则占用状态 只有动道岔时才使用 不用在解锁 因此未延时*/
				SetPhySecCurAndMergeState(phySectionId,andMergeOccuState);

				/* 区段变占用计时 */
				if ((SECTION_OCCUPY_NO == phySecPreOccuState) && (SECTION_OCCUPY_YES == mergeOccuState))
				{
					/*空闲变占用*/
					/*区段由空闲变占用则清除区段停止检查标志，当区段再次被占压则停止检查为无效*/
					SetPhySectionStopCheckFlag(phySectionId, PHYSICAL_STOPCHECK_SET_NO);

					/*该区段的上一区段与该区段同时占用时设置占用开始时间*/
					if (routeId > 0u)
					{/*物理区段进路锁闭*/
						phySecCurOccuState = GetPhySecCurMergeState(preSecId);
						if ((preSecId != 0u) &&
							(SECTION_OCCUPY_YES == phySecCurOccuState))
						{/*上一物理区段同时占用*/

							/*设置占用开始时间*/
							SetSecCurOccupyStartCycNum(phySectionId, dwSystemCyc);
							/*设置物理区段UT或CT占用开始时间*/
							SetSecUtOrCtOccuStartCycNum(phySectionId, dwSystemCyc);
					
						}

					}
           
				}
				else if ((SECTION_OCCUPY_YES == phySecPreOccuState) && (SECTION_OCCUPY_NO == mergeOccuState))
				{  
					 /*占用变空闲*/
					/*当信号机内方第一区段为列检库区段，占用出清不应关闭信号机，此处为特殊处理，将之前状态设为空闲,
					当区段前一区段为占用时则认为占用*/

					dwSecCurOccupyCyc = GetSecCurOccupyStartCycNum(phySectionId);
					cPhySecLjkFlag = GetPhySecLjkFlag(phySectionId);
					cPhySecStopCheckFlag = GetPhySectionStopCheckFlag(phySectionId);
					phySecCurOccuState = GetPhySecCurMergeState(preSecId);

					if ((0u == dwSecCurOccupyCyc)
						&& (PHYSICAL_SECTION_LJK_YES == cPhySecLjkFlag)
						&& (PHYSICAL_STOPCHECK_SET_YES == cPhySecStopCheckFlag)
						&& (SECTION_OCCUPY_NO == phySecCurOccuState))
					{
						SetPhySecPreMergeState(phySectionId, SECTION_OCCUPY_NO);
					}
					/*取消占用开始时间*/
					SetSecCurOccupyStartCycNum(phySectionId, 0u);

					/*取消物理区段UT或CT占用开始时间*/
					SetSecUtOrCtOccuStartCycNum(phySectionId, 0u);
				}
				else
				{
					 /*继续计时*/
				}

				phySecCurOccuState = GetPhySecCurMergeState(phySectionId);
				if(SECTION_OCCUPY_YES == phySecCurOccuState)
				{
					curUtOrCtOccFlag = GetPhySecCurCtOrUtOccupyState(phySectionId);	/*获取物理区段当前CT或UT占用状态*/
					chPreUtOrCtOccFlag = GetPhySecPreOccState(phySectionId);				/*获取物理区段之前CT或UT占用状态*/
					dwSecUtOrCtOccuCyc = GetSecUtOrCtOccuStartCycNum(phySectionId);
					/*倒计时过程中，物理区段车占用状态发生变化，并且解锁已开始倒计时*/
					if((chPreUtOrCtOccFlag != curUtOrCtOccFlag) && (0u != dwSecUtOrCtOccuCyc))
					{
						/*重新设置物理区段UT或CT占用开始时间*/
						SetSecUtOrCtOccuStartCycNum(phySectionId, dwSystemCyc);
					}
					else
					{
						/*解锁保护区段过程中，进路最后一个物理区段车占用未发生变化，正常倒计时*/
					}
					/*将物理区段上周期占用状态设置为之前占用状态*/
					SetPhySecPreOccState(phySectionId, curUtOrCtOccFlag);
				}
				else
				{
					SetPhySecPreOccState(phySectionId, LOGICSECTION_OCCUPY_NO);
				}

				phySecCurOccuState = GetPhySecCurMergeState(phySectionId);
				if(SECTION_OCCUPY_NO == phySecCurOccuState)
				{
					/*取消物理区段UT或CT占用开始时间*/
					SetSecUtOrCtOccuStartCycNum(phySectionId, 0u);
				}
			}
#endif
			else
			{
				/*不处理*/
			}

		}
    }                     
}


/*
* 功能描述： 融合逻辑区段CT占用信息
* 参数说明： void
* 返回值  ： void
* 修复bug YF0083-126
* 更新: 更新遍历为遍历所有物理区段
*/
void UpdateLogSectionCTOccupyState(void)
{
    UINT16 phySecId = 0u;/*物理区段ID*/
    UINT16 wPhySecSum = GetTotalPhySecCurNum();/*物理区段数目*/
    UINT16 logicSecSum = 0u;/*逻辑区段数目*/
    UINT16* logicSecIdBuf = NULL;/*计轴区段Id数组*/
    UINT16 ii = 0u;
    UINT16 jj = 0u;
    UINT8 localCiId = GetSystemParaLocalCiId();/*获取本机联锁ID*/

	UINT8 phyBelongCi = 0u;/*物理区段所属联锁*/
	UINT8 commState = 0u;/*通信状态*/
	/*相邻联锁是否支持继电接口*/
	UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI);
	UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*继电接口确认状态*/
	UINT8 phyMergeOccupyState = 0u;
	UINT8 logSecPreOccState = 0u;
	UINT8 LogSecOccupyState = 0u;			/*指定逻辑区段占用状态*/

    for (ii = 0u; ii < wPhySecSum; ii++)
    {
        phySecId =GetPhySecId (ii);/*获取计轴区段所属物理区段ID*/
		phyBelongCi = GetPhySecBelongCiId(phySecId);


		logicSecSum = GetPhySecIncLogSecSum(phySecId);/*获取逻辑区段数目*/
		logicSecIdBuf = GetPhySecIncLogSecIdBuf(phySecId);/*获取逻辑区段结构数据*/
		phyMergeOccupyState = GetPhySecCurMergeState(phySecId);
        if (phyBelongCi == localCiId)
        {
            if (SECTION_OCCUPY_NO == phyMergeOccupyState)
            {/*融合后的物理区段空闲*/


                for (jj = 0u; jj < logicSecSum; jj++)
                {
					logSecPreOccState = GetLogSecCurCtOrUtOccupyState(logicSecIdBuf[jj]);
					SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState);
                    /*融合逻辑区段的占用信息*/
                    SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_NO);/*设置逻辑区段空闲*/
                    
#if 0 
                    /*删除该逻辑区段的CT占用信息（将转发给现地的列车占用数据）*/
                    DeleteLogSecCTInfo(logicSecIdBuf[jj]);
#endif
                }
            }
            else
            {/*融合后物理区段占用*/


                for (jj = 0u; jj < logicSecSum; jj++)
                {
					logSecPreOccState = GetLogSecCurCtOrUtOccupyState(logicSecIdBuf[jj]);
					LogSecOccupyState = GetLogSecOccupyState(logicSecIdBuf[jj]);
                    if (LOGICSECTION_OCCUPY_CT == LogSecOccupyState)
                    {/*逻辑区段为CT占用*/
						SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState);
                        SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_CT);/*设置逻辑区段CT占用*/
                    }
                    else if (LOGICSECTION_OCCUPY_UT == LogSecOccupyState)
                    {/*逻辑区段为UT占用*/
                        SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState);
                        SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_UT);/*设置逻辑区段UT占用*/
                    }
                    else if (LOGICSECTION_OCCUPY_NO == LogSecOccupyState)
                    {/*逻辑区段空闲*/
						SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState);
                        SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_NO);/*设置逻辑区段空闲*/
                    }
                    else
                    {/*异常状态*/
                        SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState);
                        SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_UT);/*设置逻辑区段UT占用*/
                    }
                    
                }
            }
        }
        else
        {
			commState = GetLocalCiAndOtherCiTransSta(phyBelongCi);/*本联锁与其它联锁通信通信状态*/

			if ((localCiId !=phyBelongCi) && (TRANSMIT_STATE_BAD == commState) &&
				(CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&&
				(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface))
			{
				/*如果物理区段所属联锁与本联锁不同，且本联锁与该联锁通信中断，且运营人员已下发确认继电接口命令，
					且已配置支持继电接口，更新逻辑区段状态*/


				if (SECTION_OCCUPY_NO == phyMergeOccupyState)
				{
					for (jj = 0u; jj < logicSecSum; jj++)
					{
						logSecPreOccState = GetLogSecCurCtOrUtOccupyState(logicSecIdBuf[jj]);
						SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState);
						/*融合逻辑区段的占用信息*/
						SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_NO);/*设置逻辑区段空闲*/

#if 0
						/*删除该逻辑区段的CT占用信息（将转发给现地的列车占用数据）*/
						DeleteLogSecCTInfo(logicSecIdBuf[jj]);
#endif
					}
				}
				else
				{
					for (jj = 0u; jj < logicSecSum; jj++)
					{
						logSecPreOccState = GetLogSecCurCtOrUtOccupyState(logicSecIdBuf[jj]);
						SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState);
						/*融合逻辑区段的占用信息*/
						SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_UT);/*设置逻辑区段UT占用*/

					}
				}
			}
        }        
    }
}


/*
* 功能描述： 处理LEU到CI数据，获取LEU整机故障标志位
* 参数说明： void
* 返回值  ： void    
*/
void ProcessLeuToCiData(void)
{
	UINT8 leuFaultFlagArray[LEU_TO_CI_SUM_MAX];/*LEU故障标志数组*/
	UINT16 ii = 0u;/*游标*/
	LeuToCiDataStruct* LeuToCiData = NULL;
	UINT16 leuSum = GetLeuToCiSum();/*与CI通信的LEU数目*/
	UINT8 tranCiNum = 0u;
	UINT8* tranCiIdBuf = NULL;
	UINT8 jj = 0u;
	UINT16 wTempLeuSum = 0U;
	UINT8 localCiId = GetSystemParaLocalCiId();
	(void)memset(leuFaultFlagArray,1,LEU_TO_CI_SUM_MAX);
	LeuToCiData = GetLeuToCiDataStru();/*LEU-CI通信数据*/

	/*获取与CI通信的所有LEU配置*/
	tranCiNum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_LEU);
	tranCiIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_LEU);

	for (ii = 0u;ii < leuSum;ii++)
	{/*遍历与CI通信的LEU数据结构体中的故障标志*/
        /*allState bit0为整机状态，bit1为通道切换*/
		leuFaultFlagArray[ii] = ((LeuToCiData[ii].allState) & ((UINT8)0x01));

		if (1U == leuFaultFlagArray[ii])
		{
			wTempLeuSum++;
		}
		else
		{
			; /*不处理*/
		}

		/*LEU整机故障报警,当周期收到LEU才报警*/
		if ((0u == leuFaultFlagArray[ii]) && (LeuToCiData[ii].errorToAtsFlag == LEU_TO_ATS_ERRORFLAG_YES))
		{
			/*记录故障码*/
			SetErrorData(EFUNC_LEU_CI_COMM_FAULT, CI_DEVICE_TYPE_LEU, LeuToCiData[ii].idInfo[2],
				ETYPE_LEU_CI_COMM_ALL_STATE_FAULT, INDICATOR_TYPE_LEU_FAULT_YES, ESEND_LEVEL_ZERO);
		}
		else
		{
			/*LEU整机状态正常且锁定通道LEU-CI通信报警*/ 
			if ((1U == leuFaultFlagArray[ii]) && (0u == (LeuToCiData[ii].allState >> 1u & 0x01u))
				&& (LeuToCiData[ii].errorToAtsFlag == LEU_TO_ATS_ERRORFLAG_YES))
			{
				/* 记录故障码 */
				/*UINT8 SetErrorData(const UINT8 FunctionId, const UINT8 DeviceType, const UINT16 DeviceId,
				const UINT8 DeviceStateType, const UINT8 DeviceState,const UINT8 SendLevel)*/
				SetErrorData(EFUNC_LEU_CI_COMM_FAULT, CI_DEVICE_TYPE_LEU, LeuToCiData[ii].idInfo[2],
					ETYPE_LEU_CI_COMM_CHANNEL_SWITCH_FAULT, INDICATOR_TYPE_LEU_FAULT_YES, ESEND_LEVEL_ZERO);
			}
			else
			{
				; /*不处理*/
			}
		}
		/*出清所有通信的LEU的报警标志反馈*/
		ClearAllErrorFlag();
	}

	if (wTempLeuSum == leuSum)
	{
		leuFaultFlag = INDICATOR_TYPE_LEU_FAULT_NO;		/*所有通信的LEU都未整机故障*/
	}
	else
	{
		leuFaultFlag = INDICATOR_TYPE_LEU_FAULT_YES;	/*有一个LEU整机故障，则标志置为故障*/
	}

	for (jj = 0u; jj < tranCiNum; jj++)
	{
		(void)UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_LEU, tranCiIdBuf[jj]);
	}
}
/*
* 功能描述： 处理输入数据
* 参数说明： void
* 返回值  ： void      
*/
static void ProcessPsdData(void)
{
	UINT16 i = 0u;									/*屏蔽门索引*/
	UINT16 psdId = 0u;								/*屏蔽门ID*/
	UINT16 psdCnt=GetPsdSum();						/*获得PSD总数*/
	UINT16 vobcId = 0u;								/*VOBC ID*/
	UINT8 psdCmd = VOBCTOCI_COMMAND_TYPE_PSDCHECK;	/*PSD命令*/
	UINT16 psdRePhyId = 0u;							/*PSD关联的物理区段ID*/
	UINT8 localCi = GetSystemParaLocalCiId();		/*本地联锁ID*/
	UINT8 psdUpdateType = GetCiFunctionSwitchConfig(FUCN_IF_PSC);   /*获取是否与PSC通信方式 0x55：VOBC更新屏蔽门状态 0xaa：PSC更新屏蔽门状态*/
	UINT8 chLineIdentity = 0u;
	UINT8 belongCiId = 0u;
	UINT8 phySecCurMergeState = 0u;
	UINT8 curPsdDrvState = 0u;
	UINT8 psdVitual = 0U;
	UINT32 dwCurCycNum = 0U;
	UINT32 dwCmdSetCycNum = 0U;  /*PSD命令周期*/
	UINT32 dwTransmitBadEnsureCount = 0U;  /*CI与VOBC通信中断判断时间*/

	dwCurCycNum = Get2oo2CurCycleNum();
	dwTransmitBadEnsureCount = GetCiAndVobcTransBadEnsureCnt();
	chLineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*获取线路标识*/

	for (i = 0u;i < psdCnt;i++)
	{
		psdId = GetPsdId(i);
		belongCiId = GetPsdBelongCiId(psdId);
		if ((0u != psdId) && (PSD_INVALID_ID != psdId) && (belongCiId == localCi))
		{/*有效的PSD id*/
			psdRePhyId = GetPsdRelatedPhySecId(psdId);
			phySecCurMergeState =  GetPhySecCurMergeState(psdRePhyId);
			if (SECTION_OCCUPY_YES != phySecCurMergeState)
			{
				/*站台已经没有车，联锁不该继续动作屏蔽门*/
				ResetPsdData(psdId);
				if((LINE_FAOHLHT == chLineIdentity) || (LINE_CC == chLineIdentity) || (LINE_FAOHLHT_ONESELF == chLineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == chLineIdentity))
				{
				    SetStartDetectionCycNum(psdId,0u);	
                    /*设置停止探测有效，启动探测无效*/
			     	SetStartDetectionState(psdId,JXTC_START_DETECTION_NO);
			    	SetStopDetectionState(psdId,JXTC_STOP_DETECTION_YES);
				}
				else
				{
				    ;
				}
			}
			else
			{
#if 0
				if (PSD_MUTUALLOCK_REMOVE_YES == lockRmSta)
				{/*互锁解除*/
					if (PSD_STATE_OPEN == psdSta)
					{/*门开*/
						if (PSD_DRIVE_STATE_OPEN == lastDriSta)
						{

						}
						else if (PSD_DRIVE_STATE_CLOSE == lastDriSta)
						{
							closedRoute = GetPsdClosedRouteId(psdId);
							if (0u != closedRoute)
							{/*存在因该屏蔽门打开导致信号关闭的进路*/
								PsdOpenSignal(closedRoute, psdId);
							}

							SetPsdClosedRouteId(psdId, 0u);
						}
						else
						{
							SetPsdClosedRouteId(psdId, 0u);
						}
					}
					else
					{/*门关*/
						if (PSD_DRIVE_STATE_OPEN == lastDriSta)
						{

						}
						else if (PSD_DRIVE_STATE_CLOSE == lastDriSta)
						{
							closedRoute = GetPsdClosedRouteId(psdId);
							if (0u != closedRoute)
							{/*存在因该屏蔽门打开导致信号关闭的进路*/
								PsdOpenSignal(closedRoute, psdId);
							}

							SetPsdClosedRouteId(psdId, 0u);
						}
						else
						{
							SetPsdClosedRouteId(psdId, 0u);
						}
					}
				}
				else
				{
					if (PSD_STATE_OPEN == psdSta)
					{/*门开*/
						if (PSD_DRIVE_STATE_OPEN == lastDriSta)
						{
							groupPsdId = GetPsdGroupPsdId(psdId);
							closedRoute = GetPsdClosedRouteId(groupPsdId);
							if ((groupPsdId > 0u) && (closedRoute > 0u))
							{
								/* 同组PSD中已记录出站进路，则无条件添加到本PSD中*/
								SetPsdClosedRouteId(psdId, closedRoute);
							}
							else
							{
								/*该屏蔽门对应的出站进路的始端信号开放*/
								outStationRouteSum = GetPsdRalatedOutStationRouteSum(psdId);           /*获取屏蔽门关联出站进路数目*/
								outStationRouteIdBuf = GetPsdRalatedOutStationRouteIdBuf(psdId);       /*获取屏蔽门关联出站进路ID数组*/
								for (j = 0u; j < outStationRouteSum; j++)
								{
									if (CI_ERROR == AutoSignalOrRouteValid(outStationRouteIdBuf[j]))
									{/*不具有自动属性*/
										routeState = GetRouteState(outStationRouteIdBuf[j]); /*获取出站进路状态*/
										if ((ROUTE_STATE_YUXIAN_OPEN == routeState) || (ROUTE_STATE_NEAR_OPEN == routeState))
										{/*进路处于开放状态*/
											SetPsdClosedRouteId(psdId, outStationRouteIdBuf[j]);
										}
										else
										{
											if ((ROUTE_STATE_NEAR_LOCKERR == routeState) || (ROUTE_STATE_YUXIAN_LOCK == routeState))
											{
												/*查看相关的扣车导致重开标识是否有效*/

												if ((ROUTE_DETAIN_CLOSE_SIG_YES == GetRouteDetainToRouteCloseFlag(outStationRouteIdBuf[j]))
													|| (ROUTE_DETAIN_RE_OPEN_SIG_YES == GetRouteDetainReOpenSigFlag(outStationRouteIdBuf[j])))
												{
													SetPsdClosedRouteId(psdId, outStationRouteIdBuf[j]);
												}
												else
												{
													/*查看SPKS导致信号重开标识是否有效*/
													if ((ROUTE_CLOSE_SPKS_YES == GetSPKSToRouteCloseFlag(outStationRouteIdBuf[j]))
														|| (ROUTE_SPKS_RE_OPEN_SIG_YES == GetRouteSpksReOpenSigFlag(outStationRouteIdBuf[j])))
													{
														SetPsdClosedRouteId(psdId, outStationRouteIdBuf[j]);
													}
												}
											}
										}
									}
								}
							}
						}
						else if (PSD_DRIVE_STATE_CLOSE == lastDriSta)
						{

						}
						else
						{
							SetPsdClosedRouteId(psdId, 0u);
						}
					}
					else
					{
						if (PSD_DRIVE_STATE_OPEN == lastDriSta)
						{
							SetPsdClosedRouteId(psdId, 0u);
						}
						else if (PSD_DRIVE_STATE_CLOSE == lastDriSta)
						{
							closedRoute = GetPsdClosedRouteId(psdId);
							if (0u != closedRoute)
							{/*存在因该屏蔽门打开导致信号关闭的进路*/
								PsdOpenSignal(closedRoute, psdId);
							}

							SetPsdClosedRouteId(psdId, 0u);
						}
						else
						{
							SetPsdClosedRouteId(psdId, 0u);
						}
					}
				}
#endif
				curPsdDrvState = GetPsdDriveState(psdId);
				SetPsdPreDriveState(psdId,curPsdDrvState);
				/*生成本周期PSD的驱动状态*/
				SetPsdDriveState(psdId,PSD_DRIVE_STATE_INVALID);/*默认置无效，导向安全*/

				vobcId = GetPsdVobcId(psdId);
				psdVitual = GetPsdVirtualAttribute(psdId);
				if ((0u != vobcId) && ((PSD_STATE_FROM_VOBC == psdUpdateType) || (PSD_VIRTUAL_ATTR_YES == psdVitual)))
				{/*存在VOBC控制该屏蔽门或psd为虚拟的*/
					dwCmdSetCycNum = GetPsdCmdSetCycle(psdId);
					if ((0U != dwCmdSetCycNum) && ((dwCurCycNum - dwCmdSetCycNum) <= dwTransmitBadEnsureCount))
					{/*在处理VOBC的数据时，认为本周期仍然需要控制该屏蔽门*/
						psdCmd = GetPsdVobcCmd(psdId);
						if (VOBCTOCI_COMMAND_TYPE_PSDOPEN == psdCmd)
						{/*新需求：CI收到VOBC的打开PSD命令时不再判断PSD的开关状态*/
							SetPsdDriveState(psdId, PSD_DRIVE_STATE_OPEN);
						}
						else if (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == psdCmd)
						{/*新需求：CI收到VOBC的关闭PSD命令时不再判断PSD的开关状态*/
							SetPsdDriveState(psdId, PSD_DRIVE_STATE_CLOSE);
						}
						else
						{/*无效,不做任何处理*/
						}
					}
					else
					{
						/*不处理*/
					}
				}
				else
				{
					/*不处理*/
				}
			}
		}
		else
		{
			/*不处理*/
		}
	}
}

#if 0
/*
* 功能描述： 屏蔽门关闭重开信号
* 参数说明： const UINT16 routeId,需要重开信号的进路
* 返回值  ： void      
*/
static void PsdOpenSignal(const UINT16 routeId, const UINT16 psdId)
{
	UINT8 routeState;
	RouteNearPhySectionStruct * routeNearPhySectionStruct = NULL;
	UINT16 phySecId;
	routeState = GetRouteState(routeId);  /*获取进路状态*/
	if((ROUTE_STATE_YUXIAN_LOCK==routeState)||(ROUTE_STATE_NEAR_LOCKERR==routeState))
	{/*进路仍然处于完整锁闭*/
		routeNearPhySectionStruct = GetRouteBlocNearPhySectionStru(routeId);/*获取进路接近区段结构体*/
		if(NULL != routeNearPhySectionStruct)
		{/*存在接近区段*/
			phySecId = routeNearPhySectionStruct[0u].NearPhySecIdBuf[0u];/*获取接近区段第一个物理区段ID*/
			if(0u != phySecId)
			{/*第一个物理区段ID为0u*/
				if(0u != GetSecCurOccupyStartCycNum(phySecId))
				{/*列车顺序占压站台轨*/
#if 0
					SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_YES);  /*设置进路信号重开标志*/
					SetRouteOpenSigStartCycNum(routeId, Get2oo2CurCycleNum());  /*设置信号开放时间*/
#endif
					/*将重开标志记下，不立刻重开，在进路处理阶段统一处理*/
					SetPsdToBeOpenedRoute(psdId, routeId);
				}
			}	
		}
	}
}
#endif

/*
* 功能描述： 处理互联互通VOBC数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void      
*/
static void HLHTVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	if (NULL != vobcToCiDataStru)
	{
		ClearVobcStopSteadyData(vobcToCiDataStru->VobcId);
		StopSteadyDataProc(vobcToCiDataStru);  /*处理VOBC停稳信息数据*/
	}
}
/*
* 功能描述： 处理VOBC停稳信息数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* 修复bug YF0083-100
*/
static void StopSteadyDataProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT16 psdRelatedPhySecId = 0u;/*VOBC发送的轨道区段ID对应的物理区段ID*/
	UINT32 currCycleNum = 0u;
	UINT8 localCiId = GetSystemParaLocalCiId();/*本联锁ID*/
	/*物理区段CT或UT占用状态，设置为无车状态*/
	UINT8 utOrCtOccFlag = SECTION_OCCUPY_YES;
	UINT8 phyBelongCiId = 0u;
	UINT8 chRCMode = GetLocalRcWorkMode();
	if (NULL != vobcToCiDataStru)
	{
		if (VOBC_CI_STOP_TW == vobcToCiDataStru->trainStopSteadyState)
		{/*只有收到VOBC发送的停稳信息时才设置物理区段停稳信息*/
			currCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/
			/*根据VOBC发送的轨道区段ID获取对应的PSD关联物理区段ID*/
			/*查询编号对照表，根据轨道区段ID获取计轴区段ID*/
			psdRelatedPhySecId = GetTrackToPhySectionId(vobcToCiDataStru->trackSecID);
			if(currCycleNum==vobcToCiDataStru->stopSteadyStartCycNum)
			{/*本周期收到才有效*/
				phyBelongCiId = GetPhySecBelongCiId(psdRelatedPhySecId);
				if (localCiId == phyBelongCiId)
				{/*获取物理区段当前占用状态*/
				 /*在每个周期的初始化阶段，每个物理区段都会被置成未停稳。VOBC与ZC发来的停稳信息做或运算，即有一方告诉CI停稳，就认为停稳。*/
					utOrCtOccFlag = GetPhySecPreOccState(psdRelatedPhySecId);
					if (LOGICSECTION_OCCUPY_UT == utOrCtOccFlag)
					{
						SetPhySecStopSteadyFlag(psdRelatedPhySecId, PHYSICAL_SECTION_STOPSTEADY_YES);/*设置物理区段停稳*/
						SetPhyStopSteadyTrainId(psdRelatedPhySecId, vobcToCiDataStru->VobcId);		/*设置停稳物理区段关联的列车ID*/
					}
					else if (LOGICSECTION_OCCUPY_CT == utOrCtOccFlag)
					{
						if (RC_WORK_MODE_TIOC == chRCMode)
						{/*TIOC*/
							SetPhySecStopSteadyFlag(psdRelatedPhySecId, PHYSICAL_SECTION_STOPSTEADY_YES);/*设置物理区段停稳*/
						}
						else if (RC_WORK_MODE_CI == chRCMode)
						{/*CI*/
							 /*根据ZC信息设置物理区段停稳*/
						}
						else
						{
							; /*模式错误*/
						}

							
					}
					else
					{
						/*列车类型故障*/
					}
				}
				
			}
		}
	}
}

/*
* 功能描述： 处理VOBC停车保证信息
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
*/
static void StopensureDataProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT8 localCiId = GetSystemParaLocalCiId();/*本联锁ID*/
	UINT8 cRouteCiId = 0u;
	UINT16 wTrainId = 0u;
	UINT32 dwCyc = 0u;
	UINT8 ii = 0U;

	if (NULL != vobcToCiDataStru)
	{
		for (ii = 0U; ii < vobcToCiDataStru->chTrainStopAssureNum; ii++)
		{
			cRouteCiId = GetRouteBelongCiId(vobcToCiDataStru->szTrainStopRouteId[ii]);
			if ((0u != cRouteCiId)
				&& (0u != localCiId)
				&& (localCiId == cRouteCiId))
			{
				wTrainId = GetRouteStopEnassureTrainId(vobcToCiDataStru->szTrainStopRouteId[ii]);
				dwCyc = GetRouteStopEnassureCyc(vobcToCiDataStru->szTrainStopRouteId[ii]);

				if ((vobcToCiDataStru->VobcId == (wTrainId & 0xffu)) && (dwCyc == vobcToCiDataStru->szTrainStopRouteCyc[ii]) && (0u != wTrainId) && (0U != dwCyc))
				{
					/* 将停车保证写入进路数据中 */
					SetRouteStopensureFlag(vobcToCiDataStru->szTrainStopRouteId[ii], ROUTE_STOPENSURE_YES);
				}
				else
				{

				}
				debug_infor_printf((const)"StopensureInfo:VobcId:%x, wTrainId:%x, Cyc:%x, TrainStopRouteCyc =%x\n", vobcToCiDataStru->VobcId, wTrainId, dwCyc, vobcToCiDataStru->szTrainStopRouteCyc[ii]);
			}
		}
	}
}

/*
* 功能描述： 处理VOBC取消资源信息
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
*/
static void ResourceCancelDataProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT8 localCiId = GetSystemParaLocalCiId();/*本联锁ID*/
	UINT8 cRouteCiId = 0u;
	UINT16 wTrainId = 0u;
	UINT32 dwCyc = 0u;
	UINT8 ii = 0U;
	UINT8 jj = 0U;

	UINT16 wRouteInLgcSecSum = 0U;
	UINT16 *pRouteInLgcSecBuf = NULL;
	if (NULL != vobcToCiDataStru)
	{
		for (ii = 0U; ii < vobcToCiDataStru->chResourcesCancelNum; ii++)
		{
			cRouteCiId = GetRouteBelongCiId(vobcToCiDataStru->szResourcesCancelRouteId[ii]);
			wRouteInLgcSecSum = GetRouteLogSectionSum(vobcToCiDataStru->szResourcesCancelRouteId[ii]);
			pRouteInLgcSecBuf = GetRouteLogSectionIdBuf(vobcToCiDataStru->szResourcesCancelRouteId[ii]);
			if ((0u != cRouteCiId)
				&& (0u != localCiId) 
				&& (localCiId == cRouteCiId)
				&& (NULL != pRouteInLgcSecBuf))
			{
				wTrainId = GetRouteResourceCancelTrainId(vobcToCiDataStru->szResourcesCancelRouteId[ii]);		/*获取问询的ID是否和VOBC给的一样*/
				dwCyc = GetRouteResourceCancelCyc(vobcToCiDataStru->szResourcesCancelRouteId[ii]);				/*周期号是否一样*/

				if ((vobcToCiDataStru->VobcId == (wTrainId & 0xffU)) && (dwCyc == vobcToCiDataStru->szResourcesCancelRouteCyc[ii]) && (0u != wTrainId) && (0u != dwCyc))
				{
#if 0
					/* 将资源取消信息写入进路数据中 */
					SetRouteResourceCancelFlag(vobcToCiDataStru->szResourcesCancelRouteId[ii], ROUTE_RESOURCECANCEL_YES);
#endif
					SetRouteResourceCancelTrainId(vobcToCiDataStru->szResourcesCancelRouteId[ii], 0U);			/*清除询问*/
					SetRouteResourceCancelCyc(vobcToCiDataStru->szResourcesCancelRouteId[ii], 0U);
					SetRouteResCancelDelayFlag(vobcToCiDataStru->szResourcesCancelRouteId[ii], RUUTE_RESCANCEL_DELAY_NO);	/*清除延时标志*/
					/*删除列车资源*/
					for (jj = 0U; jj < wRouteInLgcSecSum; jj++)
					{
						RemoveLogSecTrainInfoById(pRouteInLgcSecBuf[jj], wTrainId);
					}
				}
				else
				{

				}
				debug_infor_printf((const)"ResourcecancelInfo:VobcId:%x, wTrainId:%x, Cyc:%x, TrainStopRouteCyc =%x\n", vobcToCiDataStru->VobcId, wTrainId, dwCyc, vobcToCiDataStru->szTrainStopRouteCyc[ii]);
			}
		}
	}
}
/*
* 功能描述： 处理FAOVOBC数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void      
*/
static void FAOVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	if (NULL != vobcToCiDataStru)
	{
		UINT16 washMachineCurSum = GetWashMachineSum();      /*获取当前联锁包含洗车机数量*/
		UINT16 washMachineId = 0u;
		UINT16 curVOBCId = 0u;

		/*当前认为一个联锁集中区最多有一个全自动洗车机*/
		if(1U == washMachineCurSum)
		{/*本联锁集中区有一台全自动洗车机*/
			washMachineId = GetWashMachineId(0u);            /*获取全自动洗车机ID*/
		}

		curVOBCId = GetWashMachineCurVobcID(washMachineId);/*获取洗车机当前洗车的VOBC ID*/

		if (0u == curVOBCId)
		{/*只有当前没有车进行洗车作业时，才设置当前洗车VOBC ID*/
			SetWashMachineCurVobcID(washMachineId,vobcToCiDataStru->VobcId);/*设置洗车机当前洗车的VOBC ID*/

			curVOBCId = GetWashMachineCurVobcID(washMachineId);/*再次获取洗车机当前洗车的VOBC ID*/
		}

		if ((0u != curVOBCId) && (curVOBCId == vobcToCiDataStru->VobcId))/*洗车机当前洗车的VOBC ID有效且当前处理的是该VOBC到联锁的命令*/
		{
			if((WASHMACHINE_DRVSTATE_REQ_FALSE == vobcToCiDataStru->washTrainRequest) 
				&& (WASHMACHINE_HEAD_STEADY_NO == vobcToCiDataStru->headWashStopSteadyInfo)
				&& (WASHMACHINE_TAIL_STEADY_NO == vobcToCiDataStru->tailWashStopSteadyInfo)
				&& (PASS_WASHMACHINE_REQUEST_INVALID == vobcToCiDataStru->passWashMachineRequest))
			{/*所有洗车命令均无效认为无洗车请求或洗车作业完毕*/
				SetWashMachineCurVobcID(washMachineId,0u);/*清除当前洗车的VOBC ID*/
				/*清除洗车机的相关驱动状态*/
				SetWashTrainRequestDrvState(washMachineId,WASHMACHINE_DRVSTATE_REQ_FALSE);
				SetTrainHeadStopSteadyDrvState(washMachineId,WASHMACHINE_HEAD_STEADY_NO);
				SetTrainTailStopSteadyDrvState(washMachineId,WASHMACHINE_TAIL_STEADY_NO);
				SetPassWashMachineReqtDrvSta(washMachineId,PASS_WASHMACHINE_DRVREQ_FALSE);
			}
			else
			{
				if(WASHMACHINE_DRVSTATE_REQ_TRUE == vobcToCiDataStru->washTrainRequest)
				{/*洗车请求有效*/
					if(1u == washMachineCurSum)
					{
						SetWashTrainRequestDrvState(washMachineId,WASHMACHINE_DRVSTATE_REQ_TRUE);
					}
				}
				else
				{
					if(1u == washMachineCurSum)
					{
						SetWashTrainRequestDrvState(washMachineId,WASHMACHINE_DRVSTATE_REQ_FALSE);
					}
				}

				if(WASHMACHINE_HEAD_STEADY_YES == vobcToCiDataStru->headWashStopSteadyInfo)
				{/*头端停稳请求有效*/
					if(1u == washMachineCurSum)
					{
						SetTrainHeadStopSteadyDrvState(washMachineId,WASHMACHINE_HEAD_STEADY_YES);
					}
				}
				else
				{
					if(1u == washMachineCurSum)
					{
						SetTrainHeadStopSteadyDrvState(washMachineId,WASHMACHINE_HEAD_STEADY_NO);
					}
				}

				if(WASHMACHINE_TAIL_STEADY_YES == vobcToCiDataStru->tailWashStopSteadyInfo)
				{/*尾端停稳请求有效*/
					if(1u == washMachineCurSum)
					{
						SetTrainTailStopSteadyDrvState(washMachineId,WASHMACHINE_TAIL_STEADY_YES);
					}
				}
				else
				{
					if(1u == washMachineCurSum)
					{
						SetTrainTailStopSteadyDrvState(washMachineId,WASHMACHINE_TAIL_STEADY_NO);
					}
				}

				if(PASS_WASHMACHINE_DRVREQ_TRUE == vobcToCiDataStru->passWashMachineRequest)
				{/*通过洗车机请求有效*/
					if (1u == washMachineCurSum)
					{
						SetPassWashMachineReqtDrvSta(washMachineId,PASS_WASHMACHINE_DRVREQ_TRUE);
					}
				}
				else
				{
					if (1u == washMachineCurSum)
					{
						SetPassWashMachineReqtDrvSta(washMachineId,PASS_WASHMACHINE_DRVREQ_FALSE);
					}
				}
			}
		}
		else
		{
			if (0u == curVOBCId)
			{/*如果当前没有VOBC正在洗车*/
				/*清除洗车机相关驱动状态*/
				if (1u == washMachineCurSum)
				{
					SetWashTrainRequestDrvState(washMachineId,WASHMACHINE_DRVSTATE_REQ_FALSE);
					SetTrainHeadStopSteadyDrvState(washMachineId,WASHMACHINE_HEAD_STEADY_NO);
					SetTrainTailStopSteadyDrvState(washMachineId,WASHMACHINE_TAIL_STEADY_NO);
					SetPassWashMachineReqtDrvSta(washMachineId,PASS_WASHMACHINE_DRVREQ_FALSE);
				}
			}
			else
			{
				/*当前vobcId与遍历的vobcId不相等，不做处理*/
			}
		}
	}
}

/*
* 功能描述： 处理ATS或现地到CI的信号特开命令
* 参数说明： void
* 返回值  ： 0u:处理失败
*			 1:处理成功         
*/
UINT8 ProcessAtsOrXDToCiReturnToTRCmd(void)
{
	/*判断是否满足信号特开条件，若满足则给相邻联锁发送信号特开申请命令*/
	UINT16 tmpCmdCurSum = 0u;
	CommandDataStruct* pATSToCiCmdReturnToTRData = NULL;
	UINT16 signalId = 0u;
	UINT8  retVal = CI_ERROR;
	UINT8 checkResult = CI_ERROR;
	UINT16 ii = 0u;
	UINT8 toCiId = 0u;

	tmpCmdCurSum = GetATSToCiCmdRtnToTRCurSum();/*获取信号特开命令数目*/
	pATSToCiCmdReturnToTRData = GetATSorXDToCiCmdRtnToTRData();/*获取信号特开命令结构体*/

	if (0u < tmpCmdCurSum)
	{/*存在信号特开命令*/
		for (ii = 0u; ii < tmpCmdCurSum;ii++)
		{
			signalId = (UINT16)(pATSToCiCmdReturnToTRData[ii].CommandParam>>16);

			/*发送相邻联锁信号特开申请命令条件检查*/
			checkResult = RouteReturnToThroughCondCheck(signalId,&toCiId);
			if (CI_SUCCESS == checkResult)
			{
				AddCiSendToCiCmdInfo((UINT8)CI_CMD_SIGNAL_SPEC_OPEN_APPLY, signalId, 0u, toCiId);/*添加信号特开申请命令*/
				retVal = CI_SUCCESS;
			}
			else
			{
				/*不满足信号特开条件则清除该命令*/ /*或已驱动信号重开*/
				(void)RemoveReturnToTRCmdAt(ii);
				retVal = CI_ERROR;
			}
		}
	}
	return retVal;
}
/*
* 功能描述： 发送给相邻联锁信号特开申请命令条件检查
* 参数说明： const UINT16 signalId 信号机ID
*            const UINT8* toCiId 目标联锁ID
* 返回值  ： CI_SUCCESS: 条件检查通过
*			 CI_ERROR: 条件检查失败      
*/
static UINT8 RouteReturnToThroughCondCheck(const UINT16 signalId,UINT8* toCiId)
{
	UINT8 localCiId = 0u;        /*本地联锁ID*/
	UINT8 belongCiId = 0u;       /*进路所属联锁ID*/
	UINT8 retVal = CI_SUCCESS;	/*返回值*/
	UINT16 signalOutSecId = 0u;  /*信号机外方区段*/
	UINT16 signalInSecId = 0u;   /*信号机内方区段*/
	UINT16 returnRouteId = 0u;   /*折返进路*/
	UINT16 throughRouteId = 0u;  /*通过进路*/
	UINT16 nextRouteId = 0u;     /*下一个进路*/
	UINT8 returnRouteIdBelongCiId = 0u;
	UINT8 throughRouteIdBelongCiId = 0u;
	UINT16 reRouteNormalLockPhy = 0u;
	UINT8 phyMergeState = 0u;
	UINT16 nextRouteLockPhy = 0u;
	UINT16 wEndSignalId = 0U;/*折返进路的终端信号机*/
	UINT16 wStartSignalId = 0U;/*待信号特开进路的始端信号机*/
	if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX))
	{
		retVal = CI_ERROR;
	}

	if (CI_SUCCESS == retVal)
	{
		localCiId = GetSystemParaLocalCiId();          /*获取本机联锁ID*/
		belongCiId = GetSignalBelongCiId(signalId);    /*获取信号机所属联锁ID*/

		if ((belongCiId != localCiId) || (localCiId == 0u))
		{
			retVal = CI_ERROR;
		}
	}

	if (CI_SUCCESS == retVal)
	{
		signalOutSecId = GetSignalOutFirstPhySecId(signalId);
		signalInSecId = GetSignalInFirstLockedPhySecId(signalId);

		returnRouteId = GetPhySecRLockBelongRouteId(signalOutSecId);
		nextRouteId = GetPhySecRLockBelongRouteId(signalInSecId);
		wEndSignalId = GetRouteEndSignalId(returnRouteId);/*获取终端信号机*/
		wStartSignalId = GetRouteStartSignalId(nextRouteId);/*待办理信号特开的进路始端信号机*/
		throughRouteId = GetRouteThroughRouteId(returnRouteId);
		returnRouteIdBelongCiId = GetRouteBelongCiId(returnRouteId);
		throughRouteIdBelongCiId = GetRouteBelongCiId(throughRouteId);

		*toCiId = returnRouteIdBelongCiId;

		if ((returnRouteId == 0u)||(nextRouteId == 0u) || (returnRouteIdBelongCiId == localCiId) ||(throughRouteIdBelongCiId==localCiId))
		{
			/*进路号无效 || 进路属于本联锁*/
			retVal = CI_ERROR;
		}
	}

	if (CI_SUCCESS == retVal)
	{
		/*获取进路相关信息*/
		reRouteNormalLockPhy = GetRouteFirstNormalLockSection(returnRouteId);
		phyMergeState = GetPhySecCurMergeState(signalOutSecId);
		nextRouteLockPhy = GetPhySecLockState(signalInSecId);

		/*折返进路最后一个【正常锁闭】且【区段占用】*/
		if ((reRouteNormalLockPhy == signalOutSecId) &&
			(SECTION_OCCUPY_YES == phyMergeState))
		{
			/*下一进路第一区段锁闭*/
			if (PHYSICAL_SECTION_LOCK_NORMAL == nextRouteLockPhy)
			{
				
				/*信号机正确*/
				if(wEndSignalId == wStartSignalId)
				{
					if(0u != throughRouteId)
					{/*returnRouteId和throughRouteId都不等于0u，说明returnRouteId确实是折返进路，throughRouteId是通过进路，且此时折返还未变成通过进路*/
						retVal = CI_SUCCESS;
					}
					else
					{
						/*已满足信号特开条件，重开信号,此时returnRouteId是通过进路ID*/
						/*尝试重开下一进路信号*/
						RepeatOpenSignalLogicManage(signalId);
						retVal = CI_ERROR;
					}
				}
				else
				{
					retVal = CI_ERROR;
				}
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
		else
		{
			retVal = CI_ERROR;
		}
	}

	return retVal;
}

/*
* 功能描述： 相邻联锁信号特开申请命令处理
* 参数说明： const UINT16 signalId 信号机ID
*            const UINT8 fromCiId 源联锁ID
* 返回值  ： CI_SUCCESS: 处理成功
*			 CI_ERROR: 处理失败    
*/
static UINT8 RouteReturnToThroughCmdProc(const UINT16 signalId,const UINT8 fromCiId)
{
	UINT8 localCiId = 0u;        /*本地联锁ID*/
	UINT8 belongCiId = 0u;       /*进路所属联锁ID*/
	UINT8 retVal = CI_ERROR;	/*返回值*/

	UINT16 signalOutSecId = 0u;  /*信号机外方区段*/
	UINT16 signalInSecId = 0u;   /*信号机内方区段*/
	UINT16 returnRouteId = 0u;   /*折返进路*/
	UINT16 throughRouteId = 0u;  /*通过进路*/
	UINT16 nextRouteId = 0u;     /*下一个进路*/
	UINT8 returnRouteState = 0u;
	UINT8 returnRouteIdBelongCiId = 0u;
	UINT8 throughRouteIdBelongCiId = 0u;
	UINT16 reRouteNormalLockPhy = 0u;
	UINT8 phyMergeState = 0u;
	UINT16 nextRouteLockPhy = 0u;
	UINT16 lockPhyBelongRoute = 0u;
	UINT8 saveReRouteDir = 0u;
	UINT8 throughRouteDir = 0u;
	UINT16 wLastLgcSecId = 0U;
	UINT8 chTrainSum = 0u;
	UINT16 wEndSignalId = 0U;/*折返进路的终端信号机*/
	UINT16 wStartSignalId = 0U;/*待信号特开进路的始端信号机*/
	LogicTrainResStruct * pstLgcResInfo = NULL;
	LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U };

	if ((0u < signalId) && (signalId < SIGNAL_SUM_MAX))
	{
		retVal = CI_SUCCESS;
	}

	if (CI_SUCCESS == retVal)
	{
		localCiId = GetSystemParaLocalCiId();			/*获取本机联锁ID*/
		belongCiId = GetSignalBelongCiId(signalId);    /*获取信号机所属联锁ID*/

		if ((belongCiId != fromCiId) || (0u == fromCiId))
		{
			retVal = CI_ERROR;
		}
	}
	if (CI_SUCCESS == retVal)
	{
		signalOutSecId = GetSignalOutFirstPhySecId(signalId);
		signalInSecId = GetSignalInFirstLockedPhySecId(signalId);

		returnRouteId = GetPhySecRLockBelongRouteId(signalOutSecId);
		nextRouteId = GetPhySecRLockBelongRouteId(signalInSecId);
		throughRouteId = GetRouteThroughRouteId(returnRouteId);
		wEndSignalId = GetRouteEndSignalId(returnRouteId);
		wStartSignalId = GetRouteStartSignalId(nextRouteId);
		returnRouteIdBelongCiId = GetRouteBelongCiId(returnRouteId);
		throughRouteIdBelongCiId = GetRouteBelongCiId(throughRouteId);

		if ((0u == returnRouteId) || (0u == nextRouteId) || (0u == throughRouteId)
			|| (returnRouteIdBelongCiId != localCiId) || (throughRouteIdBelongCiId != localCiId))
		{
			/*进路号无效 || 进路不属于本联锁 */
			retVal = CI_ERROR;
		}
	}

	if (CI_SUCCESS == retVal)
	{
		/*获取进路相关信息*/
		reRouteNormalLockPhy = GetRouteFirstNormalLockSection(returnRouteId);
		phyMergeState = GetPhySecCurMergeState(signalOutSecId);
		nextRouteLockPhy = GetPhySecLockState(signalInSecId);
		/*折返进路最后一个【正常锁闭】且【区段占用】*/
		if ((reRouteNormalLockPhy == signalOutSecId) &&
			(SECTION_OCCUPY_YES == phyMergeState))
		{

			/*下一进路第一区段锁闭*/
			if (PHYSICAL_SECTION_LOCK_NORMAL == nextRouteLockPhy)
			{
				/*获取锁闭进路*/
				lockPhyBelongRoute = GetPhySecRLockBelongRouteId(signalInSecId);
				saveReRouteDir = GetRouteDirection(returnRouteId);/*保存进路实际方向*/
				throughRouteDir = GetRouteDirection(throughRouteId); /*折返进路对应的通过进路方向*/

				/*检查信号机一致*/
				if(wEndSignalId == wStartSignalId)
				{
					/*清除折返进路*/
					returnRouteState = GetRouteState(returnRouteId);

					wLastLgcSecId = GetRouteInLastLogSecId(returnRouteId);
					chTrainSum = GetLogSecTrainInfoSum(wLastLgcSecId);
					pstLgcResInfo = GetLogSecTrainInfo(wLastLgcSecId);
					if (NULL != pstLgcResInfo)
					{
						(void)ComMemCopy(pstLgcResInfo, stTmpResInfo, (UINT16)(sizeof(LogicTrainResStruct)*LOGIC_SECTION_RES_SUM_MAX));
					}
					SetLogSecLockState(wLastLgcSecId, LOG_SECTION_LOCK_NO, returnRouteId, saveReRouteDir);

					SetPhySecLockState(signalOutSecId, PHYSICAL_SECTION_LOCK_NO, returnRouteId, saveReRouteDir);
					SetRouteStateManage(returnRouteId, ROUTE_STATE_IDLE);

					/*设置区段属于当前进路锁闭*/
					SetLogSecLockState(wLastLgcSecId, LOG_SECTION_LOCK_NORMAL, throughRouteId, throughRouteDir);

					if (NULL != pstLgcResInfo)
					{
						CpyLgcSecResTrain(wLastLgcSecId, chTrainSum, stTmpResInfo);
					}
					/* 将逻辑区段所有资源设置为非折返 */
					SetLogSecAllTrainReturnState(wLastLgcSecId, LOGIC_SECTION_TRAIN_RETURN_NO);

					/*设置通过进路*/
					SetPhySecLockState(signalOutSecId,PHYSICAL_SECTION_LOCK_NORMAL,throughRouteId,throughRouteDir);
					SetRouteStateManage(throughRouteId,returnRouteState);
					
					retVal = CI_SUCCESS;
				}
				else
				{
					retVal = CI_ERROR;
				}
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
		else
		{
			retVal = CI_ERROR;
		}
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 处理试车线特殊命令数据
* 参数说明： const UINT16 devId：设备ID
*			 const UINT8 CMDType:命令类型
* 返回值  ： CI_SUCCESS: 处理成功
*			 CI_ERROR: 处理失败
* cgh-合并CID-2341-6、cgh-合并CID-2539-2：
*/
static UINT8 VirtualDevCmdProc(const UINT16 devId,const UINT8 CMDType)
{
	UINT8 localCiType = GetLocalCiType();/*获取联锁类型*/
	UINT8 cRetVal = CI_ERROR;
	UINT8 psdVirtualAttribute = GetPsdVirtualAttribute(devId);
	UINT8 esbVirtualAttribute = GetEsbVirtualAttribute(devId);
	UINT8 spksVirtualAttribute = GetSpksVirtualAttribute(devId);
	
	if ((0u < devId) && (0u < CMDType))
	{
		if (CI_TYPE_SCX == localCiType)
		{/*试车线联锁*/
			cRetVal = VirtualDevCmdCiIdCheck(devId, CMDType);
			if (CI_SUCCESS == cRetVal)				/*检查成功，继续执行*/
			{
				switch (CMDType)
				{
				case SCX_ATS_CMD_PSD_OPEN:/*打开屏蔽门*/
					if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute)
					{
						cRetVal = SetPsdState(devId, PSD_STATE_OPEN);
					}
					break;
				case SCX_ATS_CMD_PSD_CLOSE:/*关闭屏蔽门*/
					if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute)
					{
						cRetVal = SetPsdState(devId, PSD_STATE_CLOSE);
					}
					break;
				case SCX_ATS_CMD_PSD_ISOLATE:/*屏蔽门故障隔离*/
					if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute)
					{
						SetPsdIsolateState(devId, PSD_FAULT_ISOLATION_SCX);
						cRetVal = CI_SUCCESS;
					}
					break;
				case SCX_ATS_CMD_PSD_ISOLATE_CANCEL:/*取消屏蔽门故障隔离*/
					if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute)
					{
						SetPsdIsolateState(devId, 0u);
						cRetVal = CI_SUCCESS;
					}
					break;
				case SCX_ATS_CMD_PSD_REMOVE:/*屏蔽门互锁解除*/
					if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute)
					{
						cRetVal = SetPsdMutualLockRemoveState(devId, PSD_MUTUALLOCK_REMOVE_YES);
					}
					break;
				case SCX_ATS_CMD_PSD_REMOVE_CANCEL:/*取消屏蔽门互锁解除*/
					if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute)
					{
						cRetVal = SetPsdMutualLockRemoveState(devId, PSD_MUTUALLOCK_REMOVE_NO);
					}
					break;
				case SCX_ATS_CMD_ESB_PRESS:/*ESB按下*/
					if (ESB_VIRTUAL_ATTR_YES == esbVirtualAttribute)
					{
						SetEsbAutualState(devId, ESB_STATE_VALID_YES);
						cRetVal = CI_SUCCESS;
					}
					break;
				case SCX_ATS_CMD_ESB_CANCEL:/*ESB取消*/
					if (ESB_VIRTUAL_ATTR_YES == esbVirtualAttribute)
					{
						/*7.1 修复，设置ESB虚拟状态*/
						SetEsbAutualState(devId, ESB_STATE_VALID_NO);
						cRetVal = CI_SUCCESS;
					}
					break;
				case SCX_ATS_CMD_ESS_GO_POSITION: /*ESS去位*/
					if (ESB_VIRTUAL_ATTR_YES == esbVirtualAttribute)
					{
						SetEssState(devId, ESB_STATE_GO_FLAG);
						cRetVal = CI_SUCCESS;
					}
					break;
				case SCX_ATS_CMD_ESS_STOP_POSITION: /*ESS停位*/
					if (ESB_VIRTUAL_ATTR_YES == esbVirtualAttribute)
					{
						SetEssState(devId, ESB_STATE_STOP_FLAG);
						cRetVal = CI_SUCCESS;
					}
					break;
				case SCX_ATS_CMD_AUTO_RETURN_SET:/*设置无人折返*/
					SetVirtualZDZFButtonState(VIRTUAL_ZDZFAJ_BUTTON_YES);
					cRetVal = CI_SUCCESS;
					break;
				case SCX_ATS_CMD_AUTO_RETURN_CANCEL:/*取消无人折返*/
					SetVirtualZDZFButtonState(VIRTUAL_ZDZFAJ_BUTTON_NO);
					cRetVal = CI_SUCCESS;
					break;
				case SCX_ATS_CMD_SPKS_PRESS:/*SPKS按下*/
					if (SPKS_VIRTUAL_ATTR_YES == spksVirtualAttribute)
					{
						SetPhySecSpksFLockBySpksId(devId, SPKS_STATUS_YES);
						cRetVal = CI_SUCCESS;
					}
					break;
				case SCX_ATS_CMD_SPKS_CANCEL:/*SPKS取消*/
					if (SPKS_VIRTUAL_ATTR_YES == spksVirtualAttribute)
					{
						SetPhySecSpksFLockBySpksId(devId, SPKS_STATUS_NO);
						cRetVal = CI_SUCCESS;
					}
					break;
				case SCX_ATS_CMD_PCB_BUTTON_PRESS:/*PCB按钮按下*/
					/*PCB ID为PSD ID;直接设置PCB按钮的状态*/
					if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute)
					{
						cRetVal = SetPsdButtonState(devId, PSD_BUTTON_STATE_DOWN);
					}
					break;
				case SCX_ATS_CMD_PCB_BUTTON_CANCEL:/*取消PCB按钮*/
					if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute)
					{
						cRetVal = SetPsdButtonState(devId, PSD_BUTTON_STATE_UP);
					}
					break;
				default:
					;/* 返回失败 */
					break;
				}
			}
		}
		else
		{
			;/* 其他，返回失败 */
		}
	}
	return cRetVal;
}

/*
* 功能描述： 校验试车线特殊命令设备所属控区
* 参数说明： const UINT16 devId：设备ID
*			 const UINT8 CMDType:命令类型
* 返回值  ： CI_SUCCESS: 校验成功
*			 CI_ERROR: 校验失败
*/
static UINT8 VirtualDevCmdCiIdCheck(const UINT16 devId, const UINT8 CMDType)
{
	UINT8 cRetVal = CI_ERROR;
	UINT8 localCi = 0u;
	UINT8 wDevBelongCiId = 0U;		/*设备所属联锁ID*/

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

	if ((0u < devId) && (0u < CMDType))
	{
		switch (CMDType)
		{
		case SCX_ATS_CMD_PSD_OPEN:/*打开屏蔽门*/
		case SCX_ATS_CMD_PSD_CLOSE:/*关闭屏蔽门*/
		case SCX_ATS_CMD_PSD_ISOLATE:/*屏蔽门故障隔离*/
		case SCX_ATS_CMD_PSD_ISOLATE_CANCEL:/*取消屏蔽门故障隔离*/
		case SCX_ATS_CMD_PSD_REMOVE:/*屏蔽门互锁解除*/
		case SCX_ATS_CMD_PSD_REMOVE_CANCEL:/*取消屏蔽门互锁解除*/
		case SCX_ATS_CMD_PCB_BUTTON_PRESS:/*PCB按钮按下*/
		case SCX_ATS_CMD_PCB_BUTTON_CANCEL:/*取消PCB按钮*/
			wDevBelongCiId = GetPsdBelongCiId(devId);
			break;
		case SCX_ATS_CMD_ESB_PRESS:/*ESB按下*/
		case SCX_ATS_CMD_ESB_CANCEL:/*ESB取消*/
		case SCX_ATS_CMD_ESS_GO_POSITION: /*ESS去位*/
		case SCX_ATS_CMD_ESS_STOP_POSITION: /*ESS停位*/
			wDevBelongCiId = GetEsbBelongCiId(devId);
			break;
		case SCX_ATS_CMD_AUTO_RETURN_SET:/*设置无人折返*/
		case SCX_ATS_CMD_AUTO_RETURN_CANCEL:/*取消无人折返*/
			cRetVal = CI_SUCCESS;  /*无设备ID，无需去检查控区*/
			break;
		case SCX_ATS_CMD_SPKS_PRESS:/*SPKS按下*/
		case SCX_ATS_CMD_SPKS_CANCEL:/*SPKS取消*/
			wDevBelongCiId = GetSpksBelongCiId(devId);
			break;
		default:
			;	/*返回失败*/
			break;
		}

		if ((0U != wDevBelongCiId) && (localCi == wDevBelongCiId))
		{
			cRetVal = CI_SUCCESS;		/*有设备ID，且设备所属联锁为本联锁，返回成功，其余情况反馈命令无效*/
		}
		else
		{
			;	/*不处理*/
		}
	}
	return cRetVal;
}
/*
* 功能描述：重置车辆段与试车线相关设备动态数据
* 参数说明：const UINT8 ciId 相邻联锁ID
* 返回值  ： void
*/
static void ResetTrainTestDevState(const UINT8 ciId)
{
	/*如果试车线与车辆段采用通信接口，且联锁类型为车辆段或试车线，则重置试车相关状态*/
	UINT8 localCiType = GetLocalCiType();
	UINT8 interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*获取试车线与车辆段接口方式*/

	if (0u != ciId)
	{/*相邻联锁ID有效*/
		if ((SCX_CLD_INTERFACE_COMM == interfaceType)||(SCX_CLD_SERIAL_PORT_COMM == interfaceType))
		{/*试车线与车辆段采用通信接口*/
			if ((CI_TYPE_SCX == localCiType) && (CI_TYPE_CLD == GetCiType(ciId)))
			{/*本联锁为试车线，与车辆段联锁通信中断*/
				SetCommTrainTestSCXYSKJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID);
			}
			else if ((CI_TYPE_CLD == localCiType) && (CI_TYPE_SCX == GetCiType(ciId)))
			{/*本联锁为车辆段，与试车线通信中断*/
				SetCommTrainTestCLDSQJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID);
			}
			else
			{
				/*什么都不做*/
			}
		}
	}
}

/*
* 功能描述：互联互通时，清除本联锁发给互联互通邻线联锁的保护区段锁闭命令
* 参数说明：无
* 返回值  ： void
*/
static void ClearSignalOvlpCmdHlht(void)
{
	UINT8 deviceSum = 0u;
	UINT8 *deviceIdBuf = NULL;
	UINT8 dstCiId = 0u;
	CiTransmitStruct *transStruPtr = NULL;
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT16 tempSigId = 0u;
	UINT8 localCi = GetSystemParaLocalCiId();

	deviceSum = GetCiTransmitSpecifySysDevSum(Get2oo2SheBeiType()); /*获取通信CI设备总数*/
	deviceIdBuf = GetCiTransmitSpecifySysDevBuf(Get2oo2SheBeiType()); /*获取通信CI设备ID数组*/

	if ((deviceIdBuf != NULL) && (deviceSum > 0u))
	{
		for (i = 0u;i < deviceSum;i++)
		{
			dstCiId = deviceIdBuf[i];
			transStruPtr = GetDstCiTransInfo(dstCiId);

			if (NULL != transStruPtr)
			{
				for (j = 0u;j < transStruPtr->signalNum;j++)
				{
					tempSigId = transStruPtr->signalIdBuf[j];

					if (GetSignalBelongCiId(tempSigId)!=localCi)
					{
						SetSignalPLockCommand(tempSigId, SIGNAL_PLOCK_CMD_NONE);
					}
				}
			}
		}
	}
}

/*
* 功能描述：处理交控联锁间接口命令
* 参数说明：无
* 返回值  ： void
*/
static void ProcessTctCiCmd(void)
{
	ToCiCommandDataStruct* CiRecvCiCmdStru = NULL;		/*联锁收到其他联锁命令结构体*/
	UINT16 CiRecvCiCmdSum = 0u;							/*联锁收到其他联锁命令总数*/
	UINT16 deviceId = 0u;								/*设备ID*/
	UINT16 deviceRelativeId = 0u;						/*设备相关ID*/
	UINT8 localCiId = GetSystemParaLocalCiId();			/*本地联锁ID*/
	UINT16 ii = 0u;										/*游标*/
	UINT8 jj = 0U;
	UINT8 neiborCiType = 0u;
	UINT8 devState = 0u;
	UINT8 retVal = CI_ERROR;
	UINT16 psdId = 0u;
	UINT8 psdVobcCmd = 0u;
	UINT16 wRouteId = 0u;
	UINT16 wRouteState = 0U;
	UINT16 wSwitchLockState = 0U;
	UINT16 wLogSecId = 0u;
	UINT16 wTrainId = 0u;
	/*故障发送级别*/
	UINT8 sendLevel = ESEND_LEVEL_ATS;/*发送ATS*/
	UINT8 belongCiId = 0u;
	UINT8 phySecUseState = 0u;
	UINT16 phySecUseRouteId = 0u;
	UINT8 switchMoveValidState = 0u;
	UINT8 localCiType = 0u;
	UINT16 lockBelongRouteId = 0u;
	UINT8 belongvirCI = 0u;
	UINT8 funRtn = CI_ERROR;
	UINT8 cmdType =0U;
	UINT8 cCiRecvCiDrCmdSum = 0U;
	ToCiDrCmdDataStruct* pCiRecvCiDrCmdStru = NULL;
	UINT32 dwCurCycNum = 0U;
	UINT16 deviceId2 = 0U;
	UINT16  routeCurSum = 0U;
	UINT16 wRouteLockedOverlapId = 0U;  /*进路锁闭过的保护区段*/
	UINT8 chRouteBelCiId = 0U;/*进路所属联锁*/
	UINT8 cOverlapBelongCiId = 0U;  /*保护区段所属联锁*/
	UINT8 chPhySecUseCheck = 0U;/*物理区段征用检查结果*/
	UINT16 wProPhySecUseRouteId = 0U;/*防护道岔区段征用所属进路*/
	UINT8 chPhySecType = 0U;/*物理区段类型*/

	/*解析CI接受到的命令*/
	CiRecvCiCmdSum = GetCiRecvCiCmdStruCurSum();
	CiRecvCiCmdStru = GetCiRecvCiCmdDataStruct();
	dwCurCycNum = Get2oo2CurCycleNum();

	if ((NULL == CiRecvCiCmdStru) || (0u == CiRecvCiCmdSum))
	{
		/*未收到命令数据*/
	}
	else
	{
		for (ii = 0u; ii < CiRecvCiCmdSum; ii++)
		{
			/*仅处理当周期收到的命令*/
			if (dwCurCycNum == CiRecvCiCmdStru[ii].CycleNo)
			{
				/*判断命令类型*/
				switch (CiRecvCiCmdStru[ii].CommandID)
				{
				case CI_CMD_PHYSEC_USING_APPLY:
					/*物理区段征用申请*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*物理区段ID*/
					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*物理区段征用所属进路ID*/
					belongCiId = GetPhySecBelongCiId(deviceId);
					if (localCiId == belongCiId)
					{/*本联锁区段*/
						phySecUseState = GetPhySecUseState(deviceId);
						phySecUseRouteId = GetPhySecUseRouteId(deviceId);
						chPhySecUseCheck = CheckPhysecUseState(deviceId, deviceRelativeId);
						wProPhySecUseRouteId = GetPhySecProtectUseRouteId(deviceId);
						chPhySecType = GetPhySecType(deviceId);

						if ((PHYSICAL_SECTION_USING_NO == phySecUseState)
							|| ((PHYSICAL_SECTION_USING_YES == phySecUseState) && ((deviceRelativeId == phySecUseRouteId)
								||((0U == phySecUseRouteId) && (0U < wProPhySecUseRouteId) && (PHYSICAL_SEC_TYPE_SWITCH == chPhySecType) && (CI_SUCCESS == chPhySecUseCheck)))))
						{
							/*物理区段未征用或被指定进路deviceRelativeId征用*/
							SetPhySecUseState(deviceId, PHYSICAL_SECTION_USING_YES, deviceRelativeId);/*设置物理区段征用*/
						}
						else
						{
							/*发送征用申请失败反馈*/
							AddCiSendToCiCmdInfo((UINT8)CI_CMD_PHYSEC_USING_REPLAY_FAILURE, deviceId, phySecUseRouteId, CiRecvCiCmdStru[ii].SourceCiId);/*添加征用失败反馈命令*/
						}
					}
					else
					{
						/*不属于本联锁*/
					}
					break;
				case CI_CMD_PHYSEC_USING_REPLAY_FAILURE:
					/*物理区段征用失败应答*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*物理区段ID*/
					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*物理区段被征用进路ID*/
					belongCiId = GetPhySecBelongCiId(deviceId);
					if (localCiId == belongCiId)
					{/*本联锁区段*/

					 /*不动作*/
					}
					else
					{
						/*非本联锁区段才可动作*/
						SetPhySecUseState(deviceId, PHYSICAL_SECTION_USING_NO, deviceRelativeId);
					}
					break;
				case CI_CMD_PHYSEC_USING_CANCEL:
					/*物理区段征用取消*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*物理区段ID*/
					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*物理区段被征用进路ID*/
					belongCiId = GetPhySecBelongCiId(deviceId);
					if (localCiId == belongCiId)
					{/*本联锁区段*/
						phySecUseState = GetPhySecUseState(deviceId);
						phySecUseRouteId = GetPhySecUseRouteId(deviceId);
						if ((PHYSICAL_SECTION_USING_YES == phySecUseState)
							&& (deviceRelativeId == phySecUseRouteId))
						{/*物理区段此时为征用状态，且征用进路为指定进路Param2*/

							SetPhySecUseState(deviceId, PHYSICAL_SECTION_USING_NO, deviceRelativeId);/*取消物理区段征用*/
						}
						else
						{
							/*取消征用反馈*/
							AddCiSendToCiCmdInfo((UINT8)CI_CMD_PHYSEC_USING_REPLAY_FAILURE, deviceId, phySecUseRouteId, CiRecvCiCmdStru[ii].SourceCiId);/*添加征用失败反馈命令*/
						}
					}
					else
					{
						/*非本联锁区段不动作*/
					}
					break;
				case CI_CMD_PROSW_SEC_USING_APPLY:
					/*防护道岔物理区段征用申请*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*物理区段ID*/
					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*防护道岔物理区段征用所属进路ID*/
					belongCiId = GetPhySecBelongCiId(deviceId);
					if (localCiId == belongCiId)
					{/*本联锁区段*/
						phySecUseState = GetPhySecUseState(deviceId);
						phySecUseRouteId = GetPhySecProtectUseRouteId(deviceId);
						chPhySecUseCheck = CheckPhysecUseState(deviceId, deviceRelativeId);
						if ((PHYSICAL_SECTION_USING_NO == phySecUseState)
							|| ((PHYSICAL_SECTION_USING_YES == phySecUseState) && (CI_SUCCESS == chPhySecUseCheck)))
						{
							SetPhySecProtectUseState(deviceId, PHYSICAL_SECTION_USING_YES, deviceRelativeId);/*设置物理区段征用*/
						}
						else
						{
							/*发送征用申请失败反馈*/
							AddCiSendToCiCmdInfo((UINT8)CI_CMD_PROSW_SEC_USING_FAIL, deviceId, phySecUseRouteId, CiRecvCiCmdStru[ii].SourceCiId);/*添加征用失败反馈命令*/
						}
					}
					else
					{
						/*不属于本联锁*/
					}
					break;
				case CI_CMD_PROSW_SEC_USING_FAIL:
					/*防护道岔物理区段征用失败*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*物理区段ID*/
					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*防护道岔物理区段征用所属进路ID*/
					belongCiId = GetPhySecBelongCiId(deviceId);
					if (localCiId == belongCiId)
					{/*本联锁区段*/

					 /*不动作*/
					}
					else
					{
						/*非本联锁区段才可动作*/
						SetPhySecProtectUseState(deviceId, PHYSICAL_SECTION_USING_NO, deviceRelativeId);
					}
					break;
				case CI_CMD_PROSW_SEC_USING_CANCEL:
					/*防护道岔物理区段征用取消*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*物理区段ID*/
					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*防护道岔物理区段征用所属进路ID*/
					belongCiId = GetPhySecBelongCiId(deviceId);
					if (localCiId == belongCiId)
					{/*本联锁区段*/
						phySecUseState = GetPhySecUseState(deviceId);
						phySecUseRouteId = GetPhySecProtectUseRouteId(deviceId);
						if ((PHYSICAL_SECTION_USING_YES == phySecUseState)
							&& (deviceRelativeId == phySecUseRouteId))
						{/*物理区段此时为征用状态，且征用进路为指定进路Param2*/

							SetPhySecProtectUseState(deviceId, PHYSICAL_SECTION_USING_NO, deviceRelativeId);/*取消物理区段征用*/
						}
						else
						{
							/*取消征用反馈*/
							AddCiSendToCiCmdInfo((UINT8)CI_CMD_PROSW_SEC_USING_FAIL, deviceId, phySecUseRouteId, CiRecvCiCmdStru[ii].SourceCiId);/*添加征用失败反馈命令*/
						}
					}
					else
					{
						/*非本联锁区段不动作*/
					}
					break;
				case CI_CMD_SWITCH_DRIVE:
					/*道岔驱动命令*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*道岔ID*/
					deviceRelativeId = GetSwitchPhySectionId(deviceId);/*道岔所属物理区段ID*/
					belongCiId = GetSwitchBelongCiId(deviceId);
					if (localCiId == belongCiId)
					{/*本联锁道岔*/

						switchMoveValidState = GetSwitchMoveValidState(deviceId, SWITCH_OPER_NO_DANCAO, sendLevel);
						if ((CI_SUCCESS == switchMoveValidState)
							&& ((SWITCH_POSITION_DINGWEI == CiRecvCiCmdStru[ii].Param2) || (SWITCH_POSITION_FANWEI == CiRecvCiCmdStru[ii].Param2)))
						{/*道岔可操作有效性检查通过且驱动位置param2为定位或反位*/
						 /*设置道岔驱动位置*/
							funRtn = SwitchDriveProcess(deviceId, (UINT8)CiRecvCiCmdStru[ii].Param2);
						}
						else
						{
							/*不动作*/
						}
					}
					else
					{
						/*非本联锁区段不动作*/
					}
					break;
				case CI_CMD_SIGNAL_SPEC_OPEN_APPLY:
					/*信号特开申请命令*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*信号机ID*/
														  /*检查是否满足信号特开条件，若满足设置相关进路的状态*/
					(void)RouteReturnToThroughCmdProc(deviceId, CiRecvCiCmdStru[ii].SourceCiId);
					break;
				case CI_CMD_KOUCHE:/*相邻联锁软扣车命令*/
				{
					deviceId = CiRecvCiCmdStru[ii].Param1;/*信号机ID*/
					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*扣车命令*/
					belongCiId = GetSignalBelongCiId(deviceId);

					if ((belongCiId == localCiId) && (0U != localCiId))
					{
						DetainLogicManage(deviceId, (UINT8)deviceRelativeId);
					}
					else
					{
						/*非本控区信号机，不处理*/
					}
				}
				break;
				case CI_CMD_KOUCHE_DETAIN:/*相邻联锁硬线扣车命令*/
				{
					deviceId = CiRecvCiCmdStru[ii].Param1;/*信号机ID*/

					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*扣车命令*/

					(void)SetSignalRelayDetainCmd(deviceId, (UINT8)deviceRelativeId);/*设置信号机硬线扣车命令：来自相邻联锁*/

					DetainLogicManage(deviceId, (UINT8)deviceRelativeId);
				}
				break;
				case CI_CMD_TRAIN_TEST_APPLY:
					/*车辆段联锁处理试车线联锁的试车请求*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*试车设备ID*/
					neiborCiType = (UINT8)(CiRecvCiCmdStru[ii].Param2 & ((UINT16)0x00FF));/*相邻联锁类型*/
					devState = (UINT8)(CiRecvCiCmdStru[ii].Param2 >> 8);/*设备状态*/
					localCiType = GetLocalCiType();
					if ((CI_TYPE_CLD == localCiType) && (CI_TYPE_SCX == neiborCiType))
					{/*本联锁为车辆段且命令来自试车线联锁*/
						if ((COMM_TRAIN_TEST_SQAJ_SCX == deviceId) && ((COMM_TRAIN_TEST_DEV_STATE_VALID == devState) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == devState)))
						{/*设备ID为SQAJ*/
							SetCommTrainTestCLDSQJStatus(devState);
						}
						else
						{/*设置设备无效*/
							SetCommTrainTestCLDSQJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID);
						}
					}
					break;
				case CI_CMD_TRAIN_TEST_ALLOW_STATUS:
					/*试车线联锁处理车辆段联锁发送的试车允许状态*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*试车设备ID*/
					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*试车设备状态*/
					if (CI_TYPE_SCX == GetLocalCiType())
					{/*本联锁为试车线*/
						if ((COMM_TRAIN_TEST_TYSJ_CLD == deviceId) && ((COMM_TRAIN_TEST_DEV_STATE_VALID == deviceRelativeId) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == deviceRelativeId)))
						{/*设备ID为TYSJ*/
							SetCommTrainTestSCXYSKJStatus((UINT8)(deviceRelativeId));
						}
						else
						{
							SetCommTrainTestSCXYSKJStatus((UINT8)(COMM_TRAIN_TEST_DEV_STATE_INVALID));
						}
					}
					break;
					/*相邻联锁PSC旁路命令*/
				case CI_CMD_SET_PSC_PL:
					deviceId = CiRecvCiCmdStru[ii].Param1;/*PSD ID*/
					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*PSC ID*/
					/*设置旁路处理*/
					SetNearCiPscPlFlag(deviceId, deviceRelativeId, CI_PSC_PL_CONFIRM_YES);
					break;
					/*相邻联锁取消PSC旁路命令*/
				case CI_CMD_QX_PSC_PL:
					deviceId = CiRecvCiCmdStru[ii].Param1;/*PSD ID*/
					deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*PSC ID*/
					/*取消旁路处理*/
					SetNearCiPscPlFlag(deviceId, deviceRelativeId, CI_PSC_PL_CONFIRM_NO);
					break;
				case CI_CMD_SECTION_FAULT_UNLOCK:
					deviceId = CiRecvCiCmdStru[ii].Param1;/*物理区段ID*/
					if (0u < deviceId)
					{
						lockBelongRouteId = GetPhySecRLockBelongRouteId(deviceId);  /*获取物理区段进路锁闭所属进路ID*/
						belongvirCI = GetRouteBelongVirCiId(lockBelongRouteId);
						/*处理相邻联锁发送的区段故障解锁命令*/
						PhySecFaultUnlockLogicManage(deviceId, belongvirCI);
					}
					break;
					/*自动信号取消命令*/
				case CI_CMD_AUTO_SIG_ROUTE_CANCLE:
					deviceId = CiRecvCiCmdStru[ii].Param1;/*进路ID*/
					/*设置命令有效*/
					SetCancleAutoSigCmdFlag(deviceId, AUTO_ROUTE_CANCLE_CMD_YES);
					/*设置自动信号属性失效*/
					retVal = SetRouteAutoSigLoseEfficacyFlag(deviceId, ROUTE_AUTOSIG_LOSE_REVSET_YES);
					if (CI_ERROR == retVal)
					{
						/*不做处理*/
					}
					break;
					/*自动信号进路设置自动属性*/
				case CI_CMD_SET_AUTO_SIG_ROUTE_VALID:
					deviceId = CiRecvCiCmdStru[ii].Param1;/*进路ID*/
					/*设置自动信号进路设置自动属性有效*/
					retVal = SetRouteAutoSigLoseEfficacyFlag(deviceId, ROUTE_AUTOSIG_LOSE_SET_NO);
					if (CI_ERROR == retVal)
					{
						/*不做处理*/
					}
					break;
				case  CI_CMD_PSD_VOBC_CMD_TO_CI:/*psd的vobc命令设置*/
					psdId = CiRecvCiCmdStru[ii].Param1;/*psd id*/
					psdVobcCmd = (UINT8)CiRecvCiCmdStru[ii].Param2;/*psd的vobc命令*/
					SetPsdVobcCmd(psdId, 0u, psdVobcCmd);
					break;
				case  CI_CMD_LOCK_OVERLAP_CMD:/*处理相邻联锁发送的办理保护区段命令*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*保护区段 id*/
					cmdType = (UINT8)CiRecvCiCmdStru[ii].Param2;/*保护区段锁闭类型*/
					routeCurSum = GetRouteCurSum();		        /*获取进路总数*/
					for (ii = 0u; ii < routeCurSum; ii++)
					{
						wRouteId = GetRouteId(ii);                           /*获取进路ID*/
						funRtn = checkExpOverlapBelongToRtOrNot(wRouteId, deviceId);
						if (CI_SUCCESS == funRtn)
						{
							break; /*保护区段属于某进路*/
						}
					}
					if (CI_SUCCESS == funRtn)
					{
						if ((ATS_LOCK_OVERLAP == cmdType) || (LABOR_LOCK_OVERLAP == cmdType))
						{
							SetAtsExpectLockOverlapIdProc(deviceId, cmdType);/*设置建立保护区段标志*/
						}
					}
					else
					{
						/*理论不可达 防护*/
					}
					break;
				case LOCK_OVERLAP_HAVE_ROUTE_CMD:	
					deviceId = CiRecvCiCmdStru[ii].Param1;/*保护区段 id*/
					deviceId2 = CiRecvCiCmdStru[ii].Param2;/*进路id*/
					if (0u < deviceId2)
					{
						funRtn =checkExpOverlapBelongToRtOrNot(deviceId2, deviceId);
						if (CI_SUCCESS == funRtn)
						{
							/*保护区段id属于进路保护区段*/
							SetAtsLockOverlapHaveRouteId(deviceId, deviceId2);/*保护区段带进路ID*/
						}
						else
						{
							debug_infor_printf((const)"LOCK_OVERLAP_HAVE_ROUTE_CMD Ovlp Not Belong to the Route, OvlpId: %d\n", deviceId);
						}
					}
					else
					{
						/*nothing do*/
					}
					break;

				case  CI_CMD_UNLOCK_OVERLAP_CMD:/*处理相邻联锁发送的解锁保护区段命令*/
					deviceId = CiRecvCiCmdStru[ii].Param1;/*保护区段 id*/
					/*设置人工解锁保护区段*/
					(void)LaborUnlockOverlapProc(deviceId);

					break;
#if 0
				case CI_CMD_ROUTE_OVERLAP_LOGSEC_LOCK:/*进路保护区段锁闭命令*/
					wRouteId = CiRecvCiCmdStru[ii].Param1;/*进路ID*/
					wTrainId = CiRecvCiCmdStru[ii].Param2;/*列车ID*/
					SetLgcSecResTrnIdOtherTiocRt(wRouteId, wTrainId);
					/*收到命令，添加回复*/
					AddCiSendToCiCmdInfo(CI_CMD_ROUTE_OVERLAP_LOCK_REPLAY, wRouteId, wTrainId, CiRecvCiCmdStru[ii].SourceCiId);
					break;

				case CI_CMD_ROUTE_OVERLAP_LOCK_REPLAY:
					wRouteId = CiRecvCiCmdStru[ii].Param1;/*进路ID*/
					wTrainId = CiRecvCiCmdStru[ii].Param2;/*列车ID*/
					cOtherCiId = GetRouteResReqOtherCIId(wRouteId);

					if (cOtherCiId == CiRecvCiCmdStru[ii].SourceCiId)
					{
						SetRouteOvlapShrCiId(wRouteId, 0U);
						RemoveRouteReqResTrain(wRouteId, wTrainId);

					}
					break;
#endif

				case CI_CMD_LOGSEC_LOCK:/*进路内逻辑区段锁闭命令*/
					wLogSecId = CiRecvCiCmdStru[ii].Param1;/*逻辑区段ID*/
					wTrainId = CiRecvCiCmdStru[ii].Param2;/*列车ID*/
					/*收到命令后，即可添加资源，由接收方负责判断*/
					AddLogSecTrainResFromCI(wLogSecId, wTrainId);

					/*收到命令，添加回复*/
#if 0
					AddCiSendToCiCmdInfo(CI_CMD_LOGSEC_LOCK_REPLAY, wLogSecId, wTrainId, CiRecvCiCmdStru[ii].SourceCiId);
#endif
					break;
#if 0 
				case CI_CMD_LOGSEC_LOCK_REPLAY:
					wLogSecId = CiRecvCiCmdStru[ii].Param1;/*逻辑区段ID*/
					wTrainId = CiRecvCiCmdStru[ii].Param2;/*列车ID*/
					cOtherCiId = GetLogSecResReqOtherCIId(wLogSecId);

					if (cOtherCiId == CiRecvCiCmdStru[ii].SourceCiId)
					{
						/* 停止发送资源申请 */
						SetLogSecResReqOtherCIId(wLogSecId, 0u);
						SetLogSecResReqTrainId(wLogSecId, 0u);
					}
					break;
#endif
				case CI_CMD_ROUTE_LOGIC_LOCK_CANCEL:/*逻辑区段解锁命令*/
					wLogSecId = CiRecvCiCmdStru[ii].Param1;/*逻辑区段ID*/
					wTrainId = CiRecvCiCmdStru[ii].Param2;/*列车ID*/
					SetLogSecTrainRelease(wLogSecId, wTrainId, TRAIN_LEVEL_VBTC);

					break;
				case CI_CMD_ROUTE_NOTVBTC_LOGIC_LOCK_CANCEL:/*非VBTC车：逻辑区段释放不解锁命令*/
					wLogSecId = CiRecvCiCmdStru[ii].Param1;/*逻辑区段ID*/
					wTrainId = CiRecvCiCmdStru[ii].Param2;/*列车ID*/
					SetLogSecTrainRelease(wLogSecId, wTrainId, TRAIN_LEVEL_UR);

					break;
#if 0
				case CI_CMD_RT_OVRLP_RES_SHR:/*资源共享标志命令*/
					wRouteId = CiRecvCiCmdStru[ii].Param1;/*逻辑区段ID*/
					wOverlapId = CiRecvCiCmdStru[ii].Param2;/*列车ID*/
					SetRouteOvlpOtherCiShrFlg(wRouteId, wOverlapId, LOGIC_SECTION_RES_SHARE_YES);
					AddCiSendToCiCmdInfo(CI_CMD_RT_OVRLP_SHR_REPLY, wRouteId, wOverlapId, CiRecvCiCmdStru[ii].SourceCiId);
					break;

				case CI_CMD_RT_OVRLP_SHR_REPLY:/*资源共享标志命令回复*/
					wRouteId = CiRecvCiCmdStru[ii].Param1;/*进路ID*/
					SetRouteOvlapShrCiId(wRouteId, 0U);
					break;
#endif
				case CI_CMD_DR_ROUTE_STATE:
					wRouteId = CiRecvCiCmdStru[ii].Param1;
					wRouteState = CiRecvCiCmdStru[ii].Param2;
					if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId) && ((ROUTE_STATE_IDLE == wRouteState) || (ROUTE_STATE_HALF_UNLOCK == wRouteState)))
					{
						SetRouteStateManage(wRouteId, (UINT8)wRouteState);
					}
					else
					{
						/*不处理*/
					}
					break;

				case CI_CMD_DR_SWITCH_PLOCK_CANCEL:
					wRouteId = CiRecvCiCmdStru[ii].Param1;
					wSwitchLockState = CiRecvCiCmdStru[ii].Param2;
					if ((0U != wRouteId) && (0U != wSwitchLockState))
					{
						SetRouteRelProSwitchLockSta(wRouteId, (UINT8)wSwitchLockState);
					}
					else
					{
						/*不处理*/
					}
					break;
				case CI_CMD_PHYSEC_PLOCK_ROUTE_CMD:
					deviceId = CiRecvCiCmdStru[ii].Param1;  /*物理区段ID*/
					deviceId2 = CiRecvCiCmdStru[ii].Param2;  /*防护锁闭所属进路ID*/
					belongCiId = GetPhySecBelongCiId(deviceId);
					if ((localCiId != belongCiId) && (0U != localCiId) && (0U != belongCiId))
					{
						SetPhySecPLockRouteId(deviceId, deviceId2);
					}
					else
					{
						/*本控区区段，不处理*/
					}
					break;
				case CI_CMD_LOGSEC_PLOCK_ROUTE_CMD:
					deviceId = CiRecvCiCmdStru[ii].Param1;  /*逻辑区段ID*/
					deviceId2 = CiRecvCiCmdStru[ii].Param2;  /*防护锁闭所属进路ID*/
					belongCiId = GetLogSecBelongCiId(deviceId);
					if ((localCiId != belongCiId) && (0U != localCiId) && (0U != belongCiId))
					{
						SetLogSecPLockRouteId(deviceId, deviceId2);
					}
					else
					{
						/*本控区区段，不处理*/
					}
					break;
				case CI_CMD_ROUTE_LOCKED_OVERLAP:
					deviceId = CiRecvCiCmdStru[ii].Param1;  /*进路ID*/
					deviceId2 = CiRecvCiCmdStru[ii].Param2;  /*保护区段ID*/
					belongCiId = GetRouteBelongCiId(deviceId);
					if ((localCiId == belongCiId) && (0U != localCiId))
					{
						wRouteLockedOverlapId = GetRouteOverlapLockedId(deviceId);
						if ((0U != wRouteLockedOverlapId) && (0U == deviceId2))
						{							
							SetOverlapUnlockApplyFlag(wRouteLockedOverlapId, UNLOCK_OVERLAP_APPLY_NO);  /*清除申请解锁保护区段标志*/
						}
						else
						{
							/*不处理*/
						}

						SetRouteOverlapLockedId(deviceId, deviceId2);  /*设置进路锁闭过的保护区段*/
					}
					else
					{
						/*非本控区进路，不处理*/
					}
					break;
				case CI_CMD_ROUTE_NEAR_STATE_SEARCH:
					/*进路接近区段状态查询*/
					deviceId = CiRecvCiCmdStru[ii].Param1;
					chRouteBelCiId = GetRouteBelongCiId(deviceId);
					retVal = GetRouteOtherCiNearSecState(deviceId);
					if (CI_SUCCESS == retVal)
					{
						AddCiSendToCiCmdInfo((UINT8)CI_CMD_ROUTE_NEAR_STATE_REPLAY, deviceId, ROUTE_NEAR_SEC_NOT_HAVE_UT, chRouteBelCiId);
					}
					else
					{
						AddCiSendToCiCmdInfo((UINT8)CI_CMD_ROUTE_NEAR_STATE_REPLAY, deviceId, ROUTE_NEAR_SEC_HAVE_UT, chRouteBelCiId);
					}		
					break;
				case CI_CMD_ROUTE_NEAR_STATE_REPLAY:
					/*进路接近区段状态回复*/
					deviceId = CiRecvCiCmdStru[ii].Param1;
					deviceId2 = CiRecvCiCmdStru[ii].Param2;
					SetRouteNearSecSearchState(deviceId, deviceId2);
					break;
				case CI_CMD_ROUTE_SEC_LOCK_APPLY:
					/*进路申请锁闭区段命令*/
					deviceId = CiRecvCiCmdStru[ii].Param1;
					deviceId2 = CiRecvCiCmdStru[ii].Param2;

					RouteSecLockApplyCmdProc(deviceId, deviceId2);
					break;
				case CI_CMD_OLP_PROSWT_USE_APPLY:
					/*保护区段防护道岔征用申请处理*/
					deviceId = CiRecvCiCmdStru[ii].Param1;  /*防护道岔ID*/
					deviceId2 = CiRecvCiCmdStru[ii].Param2;  /*保护区段ID*/
					OtherCiOlpProSwUseApplyPro(deviceId, deviceId2);
					break;
				case CI_CMD_OLP_PROSWT_USE_CANCEL:
					/*保护区段防护道岔征用取消处理*/
					deviceId = CiRecvCiCmdStru[ii].Param1;  /*防护道岔ID*/
					deviceId2 = CiRecvCiCmdStru[ii].Param2;  /*保护区段ID*/
					OtherCiOlpProSwUseCancelPro(deviceId, deviceId2);
					break;
				case CI_CMD_OLP_PROSWT_USE_FAILURE:
					/*保护区段防护道岔征用失败反馈处理*/
					deviceId = CiRecvCiCmdStru[ii].Param1;  /*防护道岔ID*/
					deviceId2 = CiRecvCiCmdStru[ii].Param2;  /*保护区段ID*/
					belongCiId = GetSwitchBelongCiId(deviceId);
					cOverlapBelongCiId = GetOverlapBelongCiId(deviceId2);
					if ((localCiId != belongCiId) && (localCiId == cOverlapBelongCiId))
					{
						SetSwitchUsingState(deviceId, SWITCH_USING_NO, deviceId2);  /*清除防护道岔征用信息*/
					}
					else
					{
						/*本控区道岔，不处理*/
					}
					break;
				default:
					/*不可达分支*/
					break;
				}
			}
			else
			{
				/*非当周期命令不处理*/
			}
		}
	}

	cCiRecvCiDrCmdSum = GetCiRecvCiDrCmdStruCurSum();
	pCiRecvCiDrCmdStru = GetCiRecvCiDrCmdDataStruct();

	if ((NULL == pCiRecvCiDrCmdStru) || (0u == cCiRecvCiDrCmdSum))
	{
		/*未收到动态进路命令数据*/
	}
	else
	{
		for (jj = 0u; jj < cCiRecvCiDrCmdSum; jj++)
		{
			/*仅处理当周期命令*/
			if (dwCurCycNum == pCiRecvCiDrCmdStru[jj].CycleNo)
			{
				SetRoutePartApplyFromCi(pCiRecvCiDrCmdStru + jj);  /*处理来自其它联锁的动态进路命令*/
			}
			else
			{
				/*非当周期命令不处理*/
			}
		}
	}

	/*清接收到的其他联锁命令数据*/
	ClearCiRevCiCmdData();
	ClearCiRevCiDrCmdData();
}

/*
* 功能描述：处理互联互通联锁间接口命令
* 参数说明：无
* 返回值  ： void
*/
static void ProcessHlhtCiCmd(void)
{
	UINT16 signalCurSum = 0u;
	UINT8 localCiId = 0u;
	UINT16 signalInd = 0u;/*遍历所有信号机时的索引*/
	UINT16 signalId = 0u;/*信号机ID变量*/
	UINT8 belongCiId = 0u;
	UINT8 SigPLockCmd = SIGNAL_PLOCK_CMD_NONE;
	UINT8 overlapIdSum = 0u;/*信号机关联的保护区段数量*/
	UINT16 *pOverlapIdBuf = NULL;/*信号机关联的保护区段ID数组*/
	UINT8 protectLockDirect = 0u;/*信号机的防护方向，统一成运营方向*/

	signalCurSum = GetSignalCurSum();			/*获取信号机总数*/
	localCiId = GetSystemParaLocalCiId();		/*获取本机联锁ID*/
										/*处理信号机*/
	for (signalInd = 0u; signalInd < signalCurSum; signalInd++)
	{
		signalId = GetSignalId(signalInd);						   /*获取信号机ID*/
		belongCiId = GetSignalBelongCiId(signalId); 		  /*获取进路所属联锁ID*/

		if (belongCiId == localCiId)
		{
			SigPLockCmd = GetSignalPLockCommand(signalId);

			overlapIdSum = GetSignalProSecIdSum(signalId);

			pOverlapIdBuf = GetSignalProSecIdBuf(signalId);
			protectLockDirect = GetSignalOperDirection(signalId);

			if (SIGNAL_PLOCK_CMD_CREATE == SigPLockCmd)
			{
				(void)LockLocalOvlpManageHlht(overlapIdSum, pOverlapIdBuf, protectLockDirect);
			}
			else if (SIGNAL_PLOCK_CMD_CANCEL == SigPLockCmd)
			{
				(void)UnLockLocalOvlpManageHlht(overlapIdSum, pOverlapIdBuf);
			}
			else if (SIGNAL_PLOCK_CMD_NONE == SigPLockCmd)
			{
				;
			}
			else
			{
				/*无操作*/
			}
		}
		else
		{
			; 	/*无操作*/
		}
	}
}

/*
* 功能描述：重置互联互通相邻联锁的设备状态
* 参数说明：UINT8 const ciId,互联互通相邻CI编号
* 返回值  ： void
*/
static void ResetCiDevStateHlht(UINT8 const ciId)
{
	CiTransmitStruct *transStruPtr = NULL;
	UINT16 ii = 0u;
	UINT16 bufInx = 0u;
	UINT16 zcjIdt = 0u;
	
	/*清除互联互通相邻CI发送给本联锁的保护区段锁闭命令*/
	transStruPtr = GetSrcCiTransInfo(ciId);
	if (NULL != transStruPtr)
	{
		for(ii = 0u; ii < transStruPtr->signalNum; ii++)
		{
			SetSignalPLockCommand(transStruPtr->signalIdBuf[ii], SIGNAL_PLOCK_CMD_NONE);
			/*设置保护区段无效*/
			SetSignalProSecValid(transStruPtr->signalIdBuf[ii], SIGNAL_PRO_SEC_INVALID);
		}

		for(ii = 0u; ii < transStruPtr->zcjNum; ii++)
		{
			zcjIdt = transStruPtr->zcjIdBuf[ii];

			bufInx = GetRelayConfigBufIndex(zcjIdt);	/*获取继电器数组下标*/

			RelayDataStru[bufInx].RelayId = zcjIdt;/*由于初始化时，没有初始化其它CI的继电器数据，所以RelayDataStru[bufInx].RelayId为无效值，此处动态赋值*/

			RelayDataStru[bufInx].RelayCollState = RELAY_STATE_DOWN;
		}
	}

	ResetDynamicStateHlht(ciId);
}

/*
* 功能描述： 从PSD数据中删除某个VOBC产生的上下文
* 参数说明： UINT16 vobcId VOBC结构体的VobcId
* 返回值  ： 无
*/
void ClearPsdVobcContext(const UINT16 vobcId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 psdId = 0u;
	UINT8 ii = 0u;
	UINT8 jj = 0u;
	UINT8 deviceSum =0u;/*通信设备总数*/
	UINT8* deviceIdBuf = NULL;/*通信设备ID数组*/
	UINT8 platformId = 0u;
	UINT8 psdSum = 0u;
	UINT16 platformPsdId = 0u;

	for(bufIndex=0u;bufIndex<PSD_SUM_MAX;bufIndex++)
	{
		if(PsdDataStru[bufIndex].SrcVobcId==vobcId)
		{
			PsdDataStru[bufIndex].PsdCmd=PSD_DEFAULT_CONTROL_CMD;
			psdId = PsdDataStru[bufIndex].PsdId;

			if ((0u != psdId) && (PSD_INVALID_ID != psdId))
			{/*PSD ID有效*/
				/*该函数调用前，已判断与VOBC通信中断，联锁立即清除当前VOBC对于此PSD的故障隔离请求信息*/

				PsdDataStru[bufIndex].SrcVobcId = 0u;
				PsdDataStru[bufIndex].CmdSetCycle = 0u;
				PsdDataStru[bufIndex].VOBCDoorState = PSD_DOOR_CLOSEDANDLOCKED_INVALID;
				deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PLATFORM);     /*获取通信PSD设备总数*/
				deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PLATFORM); /*获取通信PSD设备ID数组*/
				if ((deviceSum > 0u) && (deviceIdBuf != NULL))
				{/*参数有效性判断*/
					for (ii = 0u; ii < deviceSum; ii++)
					{/*遍历与本CI通信的站台门系统*/
						platformId = deviceIdBuf[ii];
						psdSum = platformToCiDataStru[platformId].psdSum;
						for (jj = 0u; jj < psdSum; jj++)
						{/*遍历站台门系统包含的PSD数目*/
							platformPsdId = platformToCiDataStru[platformId].psdDataStr[jj].PsdId;
							if (psdId == platformPsdId)
							{/*查找到相应的站台门系统，清除车门信息和VOBC发送的故障隔离请求信息*/
								platformToCiDataStru[platformId].psdDataStr[jj].doorHaveOrNot = PSD_HAVE_TRAIN_DOOR_NO;/*与VOBC通信中断后，把有无车门信息置为无车门*/
								platformToCiDataStru[platformId].psdDataStr[jj].faultIsolationRequestInfo = 0u;/*与VOBC通信中断后，将VOBC隔离PSD的请求设为无隔离*/
								platformToCiDataStru[platformId].psdDataStr[jj].doorEditGroupInfo = 0u;  /*清除编组信息*/
								break;
							}
							else
							{
								; /*不处理*/
							}
						}
					}
				}
				else
				{
					; /*不处理*/
				}
			}
			else
			{
				; /*不处理*/
			}
		}
		else
		{
			; /*不处理*/
		}

		if (PsdDataStru[bufIndex].wVideoQkRelateVobcId == vobcId)
		{
			/*清除视频清客驱动状态及列车ID*/
			PsdDataStru[bufIndex].chVideoQkDriveState = VIDEO_QK_DRIVE_STATE_INVALID;
			PsdDataStru[bufIndex].wVideoQkRelateVobcId = 0U;
		}
		else
		{
			; /*不处理*/
		}
	}
}

/*
* 功能描述： 处理HLHT+FAOVOBC数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void      
*/
static void HLHTFAOVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	if (NULL != vobcToCiDataStru)
	{
		UINT16 washMachineCurSum = GetWashMachineSum();      /*获取当前联锁包含洗车机数量*/
		UINT16 washMachineId = 0u;
		UINT16 curVOBCId = 0u;
		UINT32 dwCurCycNum = 0U;

		/*停稳信息周期更新*/
		ClearVobcStopSteadyData(vobcToCiDataStru->VobcId);/*先出清停稳信息*/
		StopSteadyDataProc(vobcToCiDataStru); /*处理VOBC停稳信息数据*/

		dwCurCycNum = Get2oo2CurCycleNum();
		if (dwCurCycNum == vobcToCiDataStru->ComStartCycle)
		{
			/*当前认为一个联锁集中区最多有一个全自动洗车机*/
			if (1U == washMachineCurSum)
			{/*本联锁集中区有一台全自动洗车机*/
				washMachineId = GetWashMachineId(0u);            /*获取全自动洗车机ID*/
			}

			curVOBCId = GetWashMachineCurVobcID(washMachineId);/*获取洗车机当前洗车的VOBC ID*/

			if (0u == curVOBCId)
			{/*只有当前没有车进行洗车作业时，才设置当前洗车VOBC ID，同时设置VOBC ID必须检查vobc发给CI的消息类型为全自动洗车，
			 防止VOBC给CI发心跳帧也设上VOBC ID*/
				if (VOBC_CI_INFO_TYPE_FAO_INFO == vobcToCiDataStru->appInfoType)
				{
					SetWashMachineCurVobcID(washMachineId, vobcToCiDataStru->VobcId);/*设置洗车机当前洗车的VOBC ID*/
				}


				curVOBCId = GetWashMachineCurVobcID(washMachineId);/*再次获取洗车机当前洗车的VOBC ID*/
			}

			if ((0u != curVOBCId) && (curVOBCId == vobcToCiDataStru->VobcId))/*洗车机当前洗车的VOBC ID有效且当前处理的是该VOBC到联锁的命令*/
			{
				if ((WASHMACHINE_DRVSTATE_REQ_FALSE == vobcToCiDataStru->washTrainRequest)
					&& (WASHMACHINE_HEAD_STEADY_NO == vobcToCiDataStru->headWashStopSteadyInfo)
					&& (WASHMACHINE_TAIL_STEADY_NO == vobcToCiDataStru->tailWashStopSteadyInfo)
					&& (PASS_WASHMACHINE_REQUEST_INVALID == vobcToCiDataStru->passWashMachineRequest)
					&& (PAUSE_TRAIN_WASH_REQUEST_INVALID == vobcToCiDataStru->washPauseRequest))
				{/*所有洗车命令均无效认为无洗车请求或洗车作业完毕*/
					SetWashMachineCurVobcID(washMachineId, 0u);/*清除当前洗车的VOBC ID*/
					/*清除洗车机的相关驱动状态*/
					SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_FALSE);
					SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_NO);
					SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_NO);
					SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_FALSE);
					SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_FALSE);
					SetWashMachineWorkModeDrvState(washMachineId, WASHMACHINE_WORKMODE_INVALID_DRV);
				}
				else
				{
					if (WASHMACHINE_DRVSTATE_REQ_TRUE == vobcToCiDataStru->washTrainRequest)
					{/*洗车请求有效*/
						if (1U == washMachineCurSum)
						{
							SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_TRUE);
							/*洗车请求有效，根据VOBC下发的洗车模式命令设置驱动状态*/
							SetWashMachineWorkModeDrvState(washMachineId, vobcToCiDataStru->chWashMachineWorkMode);
						}
						else
						{
							/*洗车机数量错误处理*/
						}
					}
					else
					{
						if (1U == washMachineCurSum)
						{
							SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_FALSE);
							/*洗车请求无效，设置洗车模式状态无效*/
							SetWashMachineWorkModeDrvState(washMachineId, WASHMACHINE_WORKMODE_INVALID_DRV);
						}
						else
						{
							/*洗车机数量错误处理*/
						}
					}

					if (WASHMACHINE_HEAD_STEADY_YES == vobcToCiDataStru->headWashStopSteadyInfo)
					{/*头端停稳请求有效*/
						if (1U == washMachineCurSum)
						{
							SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_YES);
						}
					}
					else
					{
						if (1U == washMachineCurSum)
						{
							SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_NO);
						}
					}

					if (WASHMACHINE_TAIL_STEADY_YES == vobcToCiDataStru->tailWashStopSteadyInfo)
					{/*尾端停稳请求有效*/
						if (1U == washMachineCurSum)
						{
							SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_YES);
						}
					}
					else
					{
						if (1U == washMachineCurSum)
						{
							SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_NO);
						}
					}

					if (WASHMACHINE_PAUSE_DRVREQ_TRUE == vobcToCiDataStru->washPauseRequest)
					{/*暂停洗车请求有效*/
						if (1U == washMachineCurSum)
						{
							SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_TRUE);
						}
					}
					else
					{
						if (1U == washMachineCurSum)
						{
							SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_FALSE);
						}
					}

					if (PASS_WASHMACHINE_DRVREQ_TRUE == vobcToCiDataStru->passWashMachineRequest)
					{/*通过洗车机请求有效*/
						if (1U == washMachineCurSum)
						{
							SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_TRUE);
						}
					}
					else
					{
						if (1U == washMachineCurSum)
						{
							SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_FALSE);
						}
					}
				}
			}
			else
			{
				if (0u == curVOBCId)
				{/*如果当前没有VOBC正在洗车*/
					/*清除洗车机相关驱动状态*/
					if (1u == washMachineCurSum)
					{
						SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_FALSE);
						SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_NO);
						SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_NO);
						SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_FALSE);
						SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_FALSE);
						SetWashMachineWorkModeDrvState(washMachineId, WASHMACHINE_WORKMODE_INVALID_DRV);
					}
				}
			}
			/*处理视频清客相关信息*/
			VobcVideoQkDataProc(vobcToCiDataStru);

			/*列车接口数据处理*/
			VobcConnectDataProc(vobcToCiDataStru);
		}
		else
		{
			/*当周期未收到列车数据，不处理*/
		}
	}
}

/*
* 功能描述： 更新本联锁继电接口确认状态
* 参数说明： void
* 返回值  ： void      
*/
void UpdateRelayInterfaceConfirmFlag(void)
{
	UINT8 localCi = 0u;/*本联锁ID*/
	UINT8 localCiType = 0u;/*本联锁类型*/

	UINT8 jj = 0u;
	UINT8 tranCiState = 0u;
	UINT8 sameLineFlag = SAME_LINE_ERR;/*标记两个CI是否属于同一条线路*/
	UINT8* pCiIdBuf = NULL;
	UINT8 ciSum = 0u;
	UINT8 dstCIType = 0u;/*目标联锁类型*/

	UINT8 allCommState = CI_ERROR;

	localCi = GetSystemParaLocalCiId();/*本联锁ID*/
	localCiType = GetLocalCiType();/*本联锁类型*/
	
	/*如果相邻联锁通信中断则重置数据*/

	ciSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_CI);     /*获取通信联锁设备总数*/
	pCiIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_CI);/*获取和本联锁通信的联锁ID组*/

	for (jj = 0u;jj<ciSum;jj++)
	{
		sameLineFlag = IsSameLineCI(localCi, pCiIdBuf[jj]);

		if (SAME_LINE_YES == sameLineFlag)
		{
			dstCIType = GetCiType(pCiIdBuf[jj]);
			if (CI_TYPE_SCX != dstCIType)
			{
				tranCiState = GetCiTransmitState(CI_SYSTEM_TYPE_CI, pCiIdBuf[jj]);

				if (TRANSMIT_STATE_GOOD == tranCiState)
				{
					allCommState = CI_SUCCESS;
				}
				else
				{
					/*有一个通信中断就打断循环*/
					allCommState = CI_ERROR;
					break;
				}
			}
		}
	}
	if (CI_SUCCESS == allCommState)
	{/*与相邻联锁都通信正常*/
		/*当与相邻联锁都恢复通信时，继电接口自动转网络接口，清除确认状态*/
		SetCiCiRelayInterfConfirmFlag(CICI_RELAY_INTERFACE_CONFIRM_NO);
	}

}
/*
* 功能描述： 检查是否为普通命令（不带二次确认）
* 参数说明： void
* 返回值  ： CI_SUCCESS 是普通命令  CI_ERROR  不是   
*/
UINT8 CheckIsGeneralOrder(UINT8 OrderType)
{
	UINT8 reVal =CI_ERROR;
	switch(OrderType)
	{
	case ATS_CMD_STARTFLOCK_UNLOCK_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_STARTFLOCK_UNLOCK_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_ALL_SIG_BRIGHT_SET_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_ALL_SIG_BRIGHT_SET_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_ALLSIGBRIGHT_CANCEL_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_ALLSIGBRIGHT_CANCEL_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWITCH_ZONGSUO_SET_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWITCH_ZONGSUO_SET_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWIT_ZONGSUO_CANCEL_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWIT_ZONGSUO_CANCEL_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_PHYSEC_RESET_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_PHYSEC_RESET_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWIT_QIANG_DINGWEI_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWIT_QIANG_DINGWEI_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWIT_QIANG_FANWEI_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWIT_QIANG_FANWEI_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_PHYSEC_PRE_RESET_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_PHYSEC_PRE_RESET_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_CICI_NET_TO_RELAY_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_CICI_NET_TO_RELAY_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_PSC_PL_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_PSC_PL_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_QUXIAO_PSC_PL_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_QUXIAO_PSC_PL_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SIGNALMAINTAINSTATE_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SIGNALMAINTAINSTATE_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_CANCEL_SIG_MAINTAIN_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_CANCEL_SIG_MAINTAIN_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_CANCEL_SW_ALARM_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_CANCEL_SW_ALARM_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_RECOVER_SW_ALARM_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_RECOVER_SW_ALARM_TWO:
		reVal = CI_ERROR;
		break;
	case LABOR_CMD_CANCEL_OVERLAP_ONE:
		reVal = CI_ERROR;
		break;
	case LABOR_CMD_CANCEL_OVERLAP_TWO:
		reVal = CI_ERROR;
		break;

	case ATS_CMD_OPEN_XIANSU_SIGNAL_FIRST:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_OPEN_XIANSU_SIGNAL_SECOND:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWITCH_DINGWEI_TEST_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWITCH_DINGWEI_TEST_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWITCH_FANWEI_TEST_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_SWITCH_FANWEI_TEST_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_OC_P_PL_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_OC_P_PL_TWO:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_QUXIAO_OC_P_PL_ONE:
		reVal = CI_ERROR;
		break;
	case ATS_CMD_QUXIAO_OC_P_PL_TWO:
		reVal = CI_ERROR;
		break;
	default:
		reVal = CI_SUCCESS;
		break;
	}
	return reVal;
}
/*
* 功能描述： 虚拟联锁设置临时限速
* 参数说明： void
* 返回值  ： 无
*/
void SetComBadLinShiXianSuState_Vir(void)
{
	UINT8 virCINum = 0u;
	UINT8 dianshiLinshixiansuFlag = 0u;
	UINT16 deviceId = 0u;
	UINT16 ii =0u;
	UINT8 jj =0u;
	UINT8 virCIid = 0u;
	UINT8 labourCancelLinShiXian = 0u;
	UINT8 logSecLinShiXianSuSetState = 0u;
	UINT16 signalCurSum = 0u;
	UINT16 logicSecCurSum = 0u;
	UINT8 signalLinShiXianSuSetFlag = 0u;
	UINT8 belongVirCI = 0u;
	UINT8 cLogSecTsrState = SIGNAL_LINSHIXIANSUSET_STATE_NO;
	UINT8 jizhongqulsxsFlag = 0u;

	jizhongqulsxsFlag = GetCiFunctionSwitchConfig(FUNC_JIZHONGQU_LINSHIXIASNSU_FLAG);
	dianshiLinshixiansuFlag = GetCiFunctionSwitchConfig(FUNC_DIANSHI_LINSHIXIANSU_FLAG);
	virCINum = GetVirtualCINum();
	for(jj = 0u;jj< virCINum;jj++)
	{
		virCIid = GetVirtualCIid(jj);
		if(0u < virCIid)
		{
			LaborCancelLSXSXStaMoveProc_Vir(LINSHIXIANSU_COMM_BAD_STATE,virCIid);  /*人工取消临时限速状态迁移处理*/
		}
	}
	
	
	for(jj = 0u;jj< virCINum;jj++)
	{
		virCIid = GetVirtualCIid(jj);
		labourCancelLinShiXian = GetVirCILabourCancelLSXianSta(virCIid);
		if((LINSHIXIANSU_COMM_BAD_STATE == labourCancelLinShiXian)&&(HAVE_DIANSHILINSHIXIANSU == dianshiLinshixiansuFlag)&& (HAVE_JZQ_LINSHIXIANSU == jizhongqulsxsFlag))
		{/*通信中断且未进行过人工取消  且支持点式临时限速  且设置集中区临时限速开关打开*/
			/*设置集中区所有有效区段临时限速*/
			logicSecCurSum =  GetLogicSecCurSum();
			for (ii = 0u; ii < logicSecCurSum; ii++)
			{
				deviceId = GetLogicSecId(ii);
				belongVirCI = GetLogSecBelongVirCiId(deviceId);
				if(belongVirCI == virCIid)
				{
					logSecLinShiXianSuSetState = GetLogSecLinShiXianSuSetState(deviceId);
					if(LOGSEC_LSXS_SET_STATE_INVALID != logSecLinShiXianSuSetState)
					{
						cLogSecTsrState = GetLogSecLinShiXianSuSetState(deviceId);

						SetLogSecLinShiXianSuState(deviceId,LOGSEC_LSXS_SET_STATE_YES);/*设置逻辑区段有临时限速*/

						if (LOGSEC_LSXS_SET_STATE_YES != cLogSecTsrState)
						{
							ClearLgcSecBelongRtXsCfm(deviceId);
						}
					}
				}
			}
			signalCurSum = GetSignalCurSum();
			for(ii = 0u; ii < signalCurSum; ii++)
			{
				deviceId = GetSignalId(ii);
				signalLinShiXianSuSetFlag = GetSignalLinShiXianSuSetFlag(deviceId);

				SetSignalLinShiXianSuSetFlag(deviceId, SIGNAL_LINSHIXIANSUSET_STATE_YES);/*设置信号机有临时限速*/
			}
		}
		else
		{
			/*条件不满足，不设置集中区所有有效区段的临时限速*/
		}
	}



}

/*
* 功能描述： 虚拟联锁处理引导总锁命令
* 参数说明： void
* 返回值  ： 无
*/
void DealallSwitchYLockOrder_Vir(void)
{
	UINT16 ii = 0u;
	CommandDataStruct* AtsOrXianDiToCiCmdStru = NULL;		/*ats或现地到联锁命令数据*/
	UINT16 AtsOrXianDiToCiCmdSum = 0u;						/*ats或现地到联锁命令总数*/
	UINT16 CmdDeviceId = 0u;
	UINT8 cmdDevType = 0u;
	UINT32 commandId = 0u;
	UINT16 terminalId = 0u;
	UINT8 cmdType = 0u;
	UINT8 virCiID = 0u;
	UINT8 allSwitchYLockFlag = 0u;
	UINT8 checkRetVal = CI_ERROR;
	AtsOrXianDiToCiCmdSum = GetCiRevCmdStruCurSum();
	AtsOrXianDiToCiCmdStru = GetCiRevCmdDataStruct();

	if (NULL == AtsOrXianDiToCiCmdStru) 
	{
		/*CI未收到到ATS或联锁命令数据*/
		checkRetVal = CI_ERROR;
	}
	else
	{
		for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++)
		{
			CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16);
			cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8);
			commandId = AtsOrXianDiToCiCmdStru[ii].CommandId;
			terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id;
			virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid;
			cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType;
			allSwitchYLockFlag = GetVirCIAllSwitchYLockState(virCiID);
			if (CI_ALL_SWITCH_YLOCK_YES == allSwitchYLockFlag)
			{
				if (ATS_CMD_SWIT_ZONGSUO_CANCEL_ONE == cmdType)
				{
					/*反馈命令收到信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);         
				}
				else if (ATS_CMD_SWIT_ZONGSUO_CANCEL_TWO == cmdType)
				{
					checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID);
					if(CI_SUCCESS == checkRetVal)
					{
						/*取消引导总锁*/
						SetCiYLockManage_UseVirCI(CI_ALL_SWITCH_YLOCK_NO,virCiID);
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
					}
					else
					{
						/*什么都不做*/   
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
					}
				}
				else if (ATS_CMD_SIGNAL_YINDAO_OPEN == cmdType)
				{
					/*反馈命令收到信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID);
					/*设置引导总锁引导信号开放*/
					SetYLockSignalOpenStateManage(virCiID,CmdDeviceId);
				}
				else if (ATS_CMD_CI_MODE_CHANGE == cmdType)
				{/*引导总锁下允许站控和紧急站控切换，新增需求20161103*/
					/*前两个字节代表设备ID，后两个字节代表设备类型*/
					/*反馈命令收到信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID);
					if ((CI_MODE_CI_LOCAL == CmdDeviceId) || (CI_MODE_CONSTRA_LOCAL == CmdDeviceId) || ((CI_MODE_APPLAY_LOCAL == CmdDeviceId)))
					{/*强制站控和申请站控、联锁控切换*/
						/*虚拟联锁兼容*/
						SetVirCImode(virCiID,(UINT8)CmdDeviceId);
					}
				}
				else
				{
					SetCiSendCmdBackInfoData(CI_BACK_INVALID_CMD, cmdDevType, CmdDeviceId, 0U, (UINT32)AtsOrXianDiToCiCmdStru[ii].CommandType);/*无效命令反馈*/
				}
				ClearCiRevCmdData();/*CI接收命令数据队列*/
			}
			else
			{
				if (ATS_CMD_SWITCH_ZONGSUO_SET_ONE == cmdType)
				{
					/*反馈命令收到信息*/
					SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID);
					/*清空CI接收命令数据队列*/
					ClearCiRevCmdData();
				}
				else if (ATS_CMD_SWITCH_ZONGSUO_SET_TWO == cmdType)
				{
					checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID);
					if(CI_SUCCESS == checkRetVal)
					{
						/*设置引导总锁*/
						SetCiYLockManage_UseVirCI(CI_ALL_SWITCH_YLOCK_YES,virCiID);

						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID);
					}
					else
					{
						SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID);
					}
					/*清空CI接收命令数据队列*/
					ClearCiRevCmdData();

				}
				else
				{
					/*不做处理*/
				}
			}
		}
	}	
}
/*
* 功能描述： 根据输入虚拟联锁ID和设备属于虚拟联锁ID，检查命令是否要被执行
* 参数说明： UINT8 virCIid 输入虚拟联锁ID
*            UINT8 belongVirCIid 设备属于虚拟联锁ID
*             UINT8 orderType  命令类型
*            UINT16 deiceID 命令ID
* 返回值  ： 检查结果：CI_ERROR 不执行，CI_SUCCESS 执行
*/
UINT8 CheckOrderWhetherDoing(UINT8 virCIid,UINT8 belongVirCIid,UINT8 orderType,UINT16 deiceID)
{
	UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 result = CI_ERROR;
	if(FUNC_SWITCH_ON == includeVirFlag)
	{
		if((virCIid == belongVirCIid)&&(0u < virCIid))
		{
			result = CI_SUCCESS;
		}
		else
		{
			SetErrorData(EFUNC_CHECKORDERWHETHERDO,orderType,deiceID,virCIid,belongVirCIid,ESEND_LEVEL_ZERO);/*若命令未执行，进路未执行原因*/
			result = CI_ERROR;
		}
	}
	else
	{
		result = CI_SUCCESS;
	}
	return result;
}

/*
* 功能描述： 处理自动折返闪灯，稳灯码位
* 参数说明： UINT16 DeviceId  指示灯行ID
*            UINT16*maskBuf  码位数组
*           UINT8 MaskType   码位类型
* 返回值  ： 无
*/
void DealAutoReturnMask_UseVirCI(UINT16 DeviceId,UINT16*maskBuf,UINT8 MaskType,UINT16 index)
{
	UINT16 LocalCIbaojingDengNum = 0u;/*本联锁表示灯配置数ID*/
	UINT16 LocalCIBaojingdengWId = 0u;/*表示灯配置表行ID*/
	UINT8 LocalCIBaojingdengType = 0u;
	UINT8 indicatorID = 0u;
	UINT8 belongVirCI = 0u;
	UINT16 jj= 0u;
	UINT8 indicatorContainRelaySum = 0u; 
	UINT8 indicatorDevId = 0U;

	LocalCIbaojingDengNum = GetLocalCIBaojingdengNum();
	for (jj = 0u; jj < LocalCIbaojingDengNum; jj++ )
	{
		LocalCIBaojingdengWId = GetLocalCIBaojingdengWId(jj);
		LocalCIBaojingdengType = GetLocalCIIndicatorIDOrType(jj);
		if ((DeviceId == LocalCIBaojingdengWId) && (INDICATOR_TYPE_EXPRESS_RETURN == LocalCIBaojingdengType))
		{/*设备ID对应且指示灯类型为无人折返灯*/
			indicatorID = GetLocalCIIndicatorIDOrType(jj);
			belongVirCI = (UINT8)GetLocalCIBaojingdengBelongVir(jj);
			indicatorDevId = GetIndicatorRelNonReturnId(DeviceId);

			indicatorContainRelaySum = GetVirCIIndicConfDataRelaySum(belongVirCI,indicatorID);
		

			if (3u != indicatorContainRelaySum)
			{/*继电器数据错误*/

			}
			else
			{/*继电器数据正确*/							
				if (MaskType == MASK_TYPE_PLAT_AUTORETURNSIG_FLASH)
				{/*闪灯码位第一个继电器位置*/

					if (1u == maskBuf[index])
					{/*闪灯命令*/
						SetVirCIautoRtnIndictFlashState(indicatorDevId,belongVirCI,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*闪灯状态有效*/
					}
					else
					{/*无闪灯命令*/
						SetVirCIautoRtnIndictFlashState(indicatorDevId,belongVirCI,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*闪灯状态无效*/
					}
				}
				else
				{/*稳灯码位第二个继电器位置*/

					if (1u == maskBuf[index])
					{/*稳灯命令*/
						SetVirCIautoRtnIndictSteadyState(indicatorDevId,belongVirCI,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*稳灯状态有效*/
					}
					else
					{/*无稳灯命令*/
						SetVirCIautoRtnIndictSteadyState(indicatorDevId,belongVirCI,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*稳灯状态无效*/
					}
				}
			}	

			break;
		}
	}
}



/*
* 功能描述： 获取全站维修点灯状态
* 参数说明：  UINT8 virCIid   虚拟联锁ID
* 返回值  ： 维修点灯状态
*/
UINT8 GetALLSignalMaintainState(UINT8 virCIid)
{
	UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 result = CI_ERROR;

	if(FUNC_SWITCH_ON  == includeVirFlag)
	{
		if(0u < virCIid)
		{
			result = GetVirCIAllSignalBrightState(virCIid);
		}
	}
	else
	{
		result = GetAllSignalBrightFlag();
	}
	return  result;
}


/*
* 功能描述： 处理车车IVOC数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
*/
static void IvocInputDataProcCC(VobcToCiDataStruct* pstIvocToCiData)
{
	UINT32 dwCurCycNum = 0U;
	UINT32 dwRcvCycNum = 0U;
	UINT8 chFunRtn = CI_ERROR;
	UINT8 chLevel = 0u;
	UINT16 trainId = 0U;
	const EnvelopeStruct* pElmTemp = NULL;
	UINT8 chTrainVirHeadScreenFlag = 0U;/*虚拟前筛通过标志*/
	UINT8 chTrainVirTailScreenFlag = 0U;/*虚拟后筛通过标志*/

	if (NULL != pstIvocToCiData)
	{
		
		dwRcvCycNum = pstIvocToCiData->ComStartCycle;
		dwCurCycNum = Get2oo2CurCycleNum();
		trainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + pstIvocToCiData->VobcId;
		if (IVOC_CI_INFO_TYPE_CONTROL == pstIvocToCiData->appInfoType)
		{  
			/*由于每周期有TIOC输入，每周期都需要刷新列车信息*/
			IvocInputRefreshTrain(*pstIvocToCiData);
		}
		if (dwRcvCycNum == dwCurCycNum)
		{
			if (IVOC_CI_INFO_TYPE_CONTROL == pstIvocToCiData->appInfoType)
			{
				IvocNonAutoRtnProcess(trainId);
				/*刷新列车信息 TODO：*/
				StopSteadyDataProc(pstIvocToCiData); /*处理VOBC停稳信息数据*/

				/*处理停车保证信息 */
				StopensureDataProc(pstIvocToCiData); /*处理VOBC停车保证数据*/

				/*处理取消资源信息*/
				ResourceCancelDataProc(pstIvocToCiData);	/*处理VOBC取消资源信息*/

				/*处理IVOC解锁保护区段信息*/
				IvocUnLockOverlapProc(pstIvocToCiData);

				/*处理IVOC防淹门关门请求确认信息*/
				IvocFloodGateCloseProc(pstIvocToCiData);

				/*处理车库门关闭确认信息*/
				IvocGarageDoorCloseProc(pstIvocToCiData);

				/*处理命令信息*/
				IvocInputCmdProc(*pstIvocToCiData);

				/*处理洗车相关信息*/
				IvocWashDataProc(pstIvocToCiData);

				/*处理视频清客相关信息*/
				VobcVideoQkDataProc(pstIvocToCiData);

				/*列车接口数据处理*/
				VobcConnectDataProc(pstIvocToCiData);
			}
			else if(IVOC_CI_INFO_TYPE_LOGOUT_ASK == pstIvocToCiData->appInfoType)
			{
				if (IVOC_CI_LOGOUT_NORMAL == pstIvocToCiData->chLogOutState)
				{
					chFunRtn = IsPointManaged(pstIvocToCiData->wTrainMaxSafeHeadLink, pstIvocToCiData->dwTrainMaxSafeHeadOffset);
					chFunRtn &= IsPointManaged(pstIvocToCiData->wTrainMinSafeTailLink, pstIvocToCiData->dwTrainMinSafeTailOffset);
					chFunRtn &= IsPointManaged(pstIvocToCiData->wTrainMinSafeHeadLink, pstIvocToCiData->dwTrainMinSafeHeadOffset);
					chFunRtn &= IsPointManaged(pstIvocToCiData->wTrainMaxSafeTailLink, pstIvocToCiData->dwTrainMaxSafeTailOffset);

					chFunRtn &= SetTrainMaxHeadLink(pstIvocToCiData->VobcId, pstIvocToCiData->wTrainMaxSafeHeadLink);
					chFunRtn &= SetTrainMaxTailLink(pstIvocToCiData->VobcId, pstIvocToCiData->wTrainMaxSafeTailLink);
					chFunRtn &= SetTrainMaxHeadOffset(pstIvocToCiData->VobcId, pstIvocToCiData->dwTrainMaxSafeHeadOffset);
					chFunRtn &= SetTrainMaxTailOffset(pstIvocToCiData->VobcId, pstIvocToCiData->dwTrainMaxSafeTailOffset);
					chFunRtn &= SetTrainMinHeadLink(pstIvocToCiData->VobcId, pstIvocToCiData->wTrainMinSafeHeadLink);
					chFunRtn &= SetTrainMinTailLink(pstIvocToCiData->VobcId, pstIvocToCiData->wTrainMinSafeTailLink);
					chFunRtn &= SetTrainMinHeadOffset(pstIvocToCiData->VobcId, pstIvocToCiData->dwTrainMinSafeHeadOffset);
					chFunRtn &= SetTrainMinTailOffset(pstIvocToCiData->VobcId, pstIvocToCiData->dwTrainMinSafeTailOffset);

					if (CI_SUCCESS == chFunRtn)
					{/* 列车已驶离本控区，可以注销 */
						elm_LogoutDel(pstIvocToCiData->VobcId);
						ClearTrainInfo(pstIvocToCiData->VobcId);
					}
					else
					{
						; /* 无操作 */
					}
				}
				else if(IVOC_CI_LOGOUT_SLEEP == pstIvocToCiData->chLogOutState)
				{
					chLevel = GetTrainLevel(pstIvocToCiData->VobcId);
					chFunRtn = IsLinkSwTrack(pstIvocToCiData->wTrainMaxSafeHeadLink);
					pElmTemp = elm_GetEnvelopeInfoByTrainID(pstIvocToCiData->VobcId);
					chTrainVirHeadScreenFlag = GetTrainVirHeadScreenPassFlag(pstIvocToCiData->VobcId);
					chTrainVirTailScreenFlag = GetTrainVirTailScreenPassFlag(pstIvocToCiData->VobcId);

					if ((TRAIN_LEVEL_VBTC == chLevel) && (CI_SUCCESS == chFunRtn)
						&& ((NULL != pElmTemp) && (((0u == pElmTemp->headTrainID) || (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chTrainVirHeadScreenFlag))
						&& ((0u == pElmTemp->tailTrainID) || (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chTrainVirTailScreenFlag))))
						&& ((pstIvocToCiData->wTrainMaxSafeHeadLink == pstIvocToCiData->wTrainMinSafeTailLink)
							&& (pstIvocToCiData->wTrainMinSafeTailLink == pstIvocToCiData->wTrainMinSafeHeadLink)
							&& (pstIvocToCiData->wTrainMinSafeHeadLink == pstIvocToCiData->wTrainMaxSafeTailLink)))
					{
						SetTrainSleepState(pstIvocToCiData->VobcId, TRAIN_SLEEP_YES);
						SetTrainSleepLink(pstIvocToCiData->VobcId, pstIvocToCiData->wTrainMaxSafeHeadLink);
						SetTrainSleepCancleFlag(pstIvocToCiData->VobcId, TRAIN_SLEEP_CANCLE_NO);
						debug_infor_printf((const)"Train:%x set sleep\n", pstIvocToCiData->VobcId);
					}
					else
					{
						debug_infor_printf((const)"Train:%x Sleep error level:%d sw:%d hl:%d hl:%d tl:%d tl:%d\n", pstIvocToCiData->VobcId,\
						chLevel, chFunRtn, pstIvocToCiData->wTrainMaxSafeHeadLink, pstIvocToCiData->wTrainMinSafeHeadLink, \
							pstIvocToCiData->wTrainMaxSafeTailLink, pstIvocToCiData->wTrainMinSafeTailLink);
					}
				}
				else
				{
					/* 无操作 */
					;
				}
			}
			else
			{
				; /*不做处理*/
			}
		}
	}
}

/*
* 功能描述： 刷新列车数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* 创建	  ： qw.liu 2022-02-26 
*/
static void IvocInputRefreshTrain(const VobcToCiDataStruct stIvocToCiData)
{
	UINT16 wTrainId = 0U;
	UINT32 dwCurCycle = 0U;
	UINT8 chIndex = 0U;
	TrainEaStru szTmp[EA_MAX_NUM] = { 0U };
	UINT8 chRet = 0U;

	dwCurCycle = Get2oo2CurCycleNum();

	wTrainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + stIvocToCiData.VobcId;
	chRet = SetTrainTransmitStat(wTrainId, TRAIN_COMM_STATE_GOOD);
	chRet &= SetTrainDir(wTrainId, stIvocToCiData.trainDirection);
	chRet &= SetTrainSpeed(wTrainId, stIvocToCiData.wTrainSpeed);
	chRet &= SetTrainSpeedDir(wTrainId, stIvocToCiData.chSpeedDir);
	chRet &= SetTrainLevel(wTrainId, stIvocToCiData.chTrainLevel);
	chRet &= SetTrainMaxHeadLink(wTrainId, stIvocToCiData.wTrainMaxSafeHeadLink);
	chRet &= SetTrainMaxTailLink(wTrainId, stIvocToCiData.wTrainMaxSafeTailLink);
	chRet &= SetTrainMaxHeadOffset(wTrainId, stIvocToCiData.dwTrainMaxSafeHeadOffset);
	chRet &= SetTrainMaxTailOffset(wTrainId, stIvocToCiData.dwTrainMaxSafeTailOffset);
	chRet &= SetTrainMinHeadLink(wTrainId, stIvocToCiData.wTrainMinSafeHeadLink);
	chRet &= SetTrainMinTailLink(wTrainId, stIvocToCiData.wTrainMinSafeTailLink);
	chRet &= SetTrainMinHeadOffset(wTrainId, stIvocToCiData.dwTrainMinSafeHeadOffset);
	chRet &= SetTrainMinTailOffset(wTrainId, stIvocToCiData.dwTrainMinSafeTailOffset);
	chRet &= SetTrainOtherPointDir(wTrainId, stIvocToCiData.trainDirection);  /*设置列车最大安全后端、最小安全前端、最大安全前端的运行方向*/
	SetTrainMsgFromTiocId(wTrainId, 0U);
	SetTrainSleepCancleFlag(wTrainId, TRAIN_SLEEP_CANCLE_YES);

#if 0
	chRet &= SetGroupTrainOtherId(wTrainId, stIvocToCiData.wGroupOtherTrainId);
	chRet &= SetGroupTrainRunState(wTrainId, stIvocToCiData.chGroupRunState);
	chRet &= SetGroupTrainRelation(wTrainId, stIvocToCiData.chGroupTrainReat);
#endif

	if (dwCurCycle == stIvocToCiData.ComStartCycle)
	{
		chRet &= SetTrainZeroState(wTrainId, stIvocToCiData.chTrainZeroState);
		SetTrainMode(wTrainId, stIvocToCiData.chTrainMode);
		SetTrainWakeState(wTrainId, stIvocToCiData.chTrainWakeState);
		SetTrainReportState(wTrainId, stIvocToCiData.chTrainReportState); /*更新列车汇报状态*/
		SetTrainHeadScreenConfirm(wTrainId, stIvocToCiData.chTrainHeadScreenConfirm);
		SetTrainTailScreenConfirm(wTrainId, stIvocToCiData.chTrainTailScreenConfirm);
		SetTrainEaNum(wTrainId, stIvocToCiData.chEaNum);

		for (chIndex = 0U; chIndex < stIvocToCiData.chEaNum; chIndex++)
		{
			szTmp[chIndex].wEaTrainId = stIvocToCiData.stEaInfo[chIndex].wDeviceId;
			szTmp[chIndex].chAgreeState = stIvocToCiData.stEaInfo[chIndex].chDeviceStatus;
			szTmp[chIndex].dwBuildCyc  = stIvocToCiData.stEaInfo[chIndex].dwBuildCyc;
		}
		SetTrainEaInfo(wTrainId, szTmp);

		if (VOBC_CI_STOP_TW == stIvocToCiData.trainStopSteadyState)
		{
			SetTrainStopSteadyState(wTrainId, TRAIN_SS_YES);
		}
		else
		{
			SetTrainStopSteadyState(wTrainId, TRAIN_SS_NO);
		}

		SetTrainActive(wTrainId, stIvocToCiData.chActive);
		SetTrainRrmRqst(wTrainId, stIvocToCiData.chRrmReq);
		SetTrainAtsLgcStation(wTrainId, stIvocToCiData.wNextStation);
		SetTrainDerailment(wTrainId, stIvocToCiData.chDerailment);
		SetHeadAxisId(wTrainId, stIvocToCiData.wHeadAxisId);
		SetHeadITEResult(wTrainId, stIvocToCiData.wHeadITEResult);
		SetTailAxisId(wTrainId, stIvocToCiData.wTailAxisId);
		SetTailITEResult(wTrainId, stIvocToCiData.wTailITEResult);
		SetTrainJumpBackApplyState(wTrainId, stIvocToCiData.chJumpBackApply);
		SetTrainJumpBackApplySN(wTrainId, stIvocToCiData.dwJumpBackSn);
	}	
	else
	{
		/*本周期未收到列车数据，不刷新列车信息*/
	}

	if (CI_ERROR == chRet)
	{
		debug_infor_printf((const)"IvocInputRefreshTrain ERROR TrainID:%d\n", wTrainId);
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述： 处理列车命令
* 参数说明： vobcToCiDataStru：VOBC数据结构体
* 返回值  ： void
* 创建	  ： qw.liu 2022-02-26
* 修复bug YF0083-100
*/
static void IvocInputCmdProc(const VobcToCiDataStruct stIvocToCiData)
{
	UINT16 wCmdSum = 0U;
	UINT8 chCmdType = 0U;
	UINT8 chCmdDevSum = 0U;
	UINT16 wCmdDevId = 0U;
	UINT16 wTrainId = 0U;
	UINT8 chTrainLevel = 0U;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT8 cLogSecBelongCiId = 0u;
	UINT16 wRouteId = 0u;
	UINT16 wBufIndex = 0U;
	UINT8 cRouteBelongCiId = 0u;
	UINT8 cLocalCiId = 0u;
	UINT8 funcSwitchJumpLockDriveSwitch = 0U;
	UINT8 sameTrnId = CI_ERROR;
	UINT8 logBelongCiId = 0u;
	UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 belongVirCiId = 0U;
	UINT8 devBelongCiId = 0U;
	UINT8 chVirCIBelLocCiCheck = CI_ERROR;/*虚拟联锁ID是否属于本真实联锁管辖检查结果*/
	UINT16 wLogRouteId = 0U;				/*动态进路ID*/
	UINT8 chExistEaCmd = CI_ERROR;  /*是否存在区间疏散命令*/

	wTrainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + stIvocToCiData.VobcId;
	cLocalCiId = GetSystemParaLocalCiId();

	funcSwitchJumpLockDriveSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_JUMPLOCK_DRIVE_SWITCH);
	
	wCmdSum = stIvocToCiData.wIvocCmdNum;
	
	if (IVOC_CI_CMD_MAX > wCmdSum)
	{
		for (ii = 0U; ii < wCmdSum; ii++)
		{
			chCmdType = stIvocToCiData.stCmdInfo[ii].chCmdType;
			chCmdDevSum = stIvocToCiData.stCmdInfo[ii].chCmdDevNum;
			if (IVOC_CI_CMD_DEVICE_MAX > chCmdDevSum)
			{
				switch(chCmdType)
				{
				case IVOC_CI_CMD_TYPE_RES_APPLY:
				{
					for (jj = 0U; jj < chCmdDevSum; jj++)
					{
						wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
						/*为对应逻辑区段添加 列车申请标志*/
						wLogRouteId = GetLogSecBelongLogRouteId(wCmdDevId, wTrainId);
						if (0U != wLogRouteId)
						{	/*动态进路锁闭逻辑区段*/
							SetLogRouteLogSecTrainLockApply(wCmdDevId, wTrainId);
						}
						else
						{
							/*当无动态进路列车申请资源时才进行普通进路资源申请的检查，若已进行动态进路列车资源申请处理，则无需再执行普通进路资源申请处理*/
							SetLogSecTrainLockApply(wCmdDevId, wTrainId);
						}
					}
					break;
				}
				case IVOC_CI_CMD_TYPE_RES_RELEASE:
				{
					for (jj = 0U; jj < chCmdDevSum; jj++)
					{
						wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];/*逻辑区段*/
						wLogRouteId = GetLogSecBelongLogRouteId(wCmdDevId, wTrainId);
						if (0U != wLogRouteId)
						{	/*动态进路锁闭逻辑区段*/
							SetLogSecTrainRelease(wCmdDevId, wTrainId, 0U);
						}
						else
						{
							/*无动态进路，处理正常进路*/
							wRouteId = GetLogSecLockBelongRoute(wCmdDevId);
							cRouteBelongCiId = GetRouteBelongCiId(wRouteId);
							cLogSecBelongCiId = GetLogSecBelongCiId(wCmdDevId);
							if ((cLocalCiId == cLogSecBelongCiId) && (cLocalCiId == cRouteBelongCiId) && (0U != cRouteBelongCiId))
							{
								/*为对应逻辑区段释放列车使用标志*/
								SetLogSecTrainRelease(wCmdDevId, wTrainId, 0U);
							}
							else if ((cLocalCiId == cLogSecBelongCiId) && (cLocalCiId != cRouteBelongCiId) && (0U != cRouteBelongCiId))
							{/*本联锁逻辑区段，VBTC车 且锁闭所属进路非本联锁-由相邻联锁处理*/
								chTrainLevel = GetTrainLevel(wTrainId);
								if (TRAIN_LEVEL_VBTC == chTrainLevel)
								{
									AddCiSendToCiCmdInfo(CI_CMD_ROUTE_LOGIC_LOCK_CANCEL, wCmdDevId, wTrainId, cRouteBelongCiId);
								}
								else
								{
									/*非VBTC车 不按照逻辑区段解锁*/
									AddCiSendToCiCmdInfo(CI_CMD_ROUTE_NOTVBTC_LOGIC_LOCK_CANCEL, wCmdDevId, wTrainId, cRouteBelongCiId);
								}
							}
							else
							{
								/*不处理*/
								;
							}
						}
					}
					break;
				}
				case IVOC_CI_CMD_TYPE_PSD_OPEN_FOUR:
				{
					for (jj = 0U; jj < chCmdDevSum; jj++)
					{
						wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
						
						wBufIndex = GetPsdConfigBufIndex(wCmdDevId);  /*获取屏蔽门数组下标*/
						if (0u < wBufIndex)
						{
							if (PSD_SUM_MAX > wBufIndex)
							{
								SetPsdVobcCmd(wCmdDevId, wTrainId, VOBCTOCI_COMMAND_TYPE_PSDOPEN);
								PsdDataStru[wBufIndex].psdEditGroupInfo = PSD_FOUR_EDIT_GROUP;
							}
						}
					}
					break;
				}
				case IVOC_CI_CMD_TYPE_PSD_OPEN_SIX:
				{
					for (jj = 0U; jj < chCmdDevSum; jj++)
					{
						wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];

						wBufIndex = GetPsdConfigBufIndex(wCmdDevId);  /*获取屏蔽门数组下标*/
						if (0u < wBufIndex)
						{
							if (PSD_SUM_MAX > wBufIndex)
							{
								SetPsdVobcCmd(wCmdDevId, wTrainId, VOBCTOCI_COMMAND_TYPE_PSDOPEN);
								PsdDataStru[wBufIndex].psdEditGroupInfo = PSD_SIX_EDIT_GROUP;
							}
						}
					}
					break;
				}
				case IVOC_CI_CMD_TYPE_PSD_OPEN_EIGHT:
				{
					for (jj = 0U; jj < chCmdDevSum; jj++)
					{
						wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];

						wBufIndex = GetPsdConfigBufIndex(wCmdDevId);  /*获取屏蔽门数组下标*/
						if (0u < wBufIndex)
						{
							if (PSD_SUM_MAX > wBufIndex)
							{
								SetPsdVobcCmd(wCmdDevId, wTrainId, VOBCTOCI_COMMAND_TYPE_PSDOPEN);
								PsdDataStru[wBufIndex].psdEditGroupInfo = PSD_EIGHT_EDIT_GROUP;
							}
						}
					}
					break;
				}
				case IVOC_CI_CMD_TYPE_PSD_CLOSE:
				{
					for (jj = 0U; jj < chCmdDevSum; jj++)
					{
						wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
						wBufIndex = GetPsdConfigBufIndex(wCmdDevId);  /*获取屏蔽门数组下标*/
						if (0u < wBufIndex)
						{
							if (PSD_SUM_MAX > wBufIndex)
							{
								SetPsdVobcCmd(wCmdDevId, wTrainId, VOBCTOCI_COMMAND_TYPE_PSDCLOSE);
								PsdDataStru[wBufIndex].psdEditGroupInfo = PSD_FOUR_EDIT_GROUP;
							}
						}
					}
					break;
				}
				/** 逻辑区段跳跃锁闭申请 */
				case IVOC_CI_CMD_TYPE_JUMP_LOCK_APPLY:
				{
					for (jj = 0U; jj < chCmdDevSum; jj++)
					{
						wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
						logBelongCiId = GetLogSecBelongCiId(wCmdDevId);
						/** 逻辑区段属于本TIOC控区 */
						if (logBelongCiId == cLocalCiId)
						{
							/** 设置跳跃锁闭命令列车ID */
							SetLogSecJumpLockTrainId(wCmdDevId, wTrainId);
#if 0
							/** 跳跃锁闭驱道岔功能开关打开 */
							if (FUNC_SWITCH_ON == funcSwitchJumpLockDriveSwitch)
							{
								axisSecId = GetLgcSecRelativeAxleSecId(wCmdDevId);
								switchSum = GetAxisSwitchSum(axisSecId);
								/** 逻辑区段关联道岔 */
								if (0u < switchSum)
								{
									/** 设置逻辑区段关联的计轴区段跳跃锁闭申请标志和申请周期号 */
									SetAxisSecJumpLockApplyFlag(axisSecId, AXIS_SECTION_JUMPLOCK_APPLY_YES);/*设置计轴区段有跳跃锁闭申请*/
									SetAxisSecJumpLockCancelApplyFlag(axisSecId, AXSEC_CANCEL_JUMPLOCK_APPLY_NO);/*设置计轴区段无跳跃锁闭释放申请*/
									SetAxisSecJumpLockApplyCylce(axisSecId, curCycle);/*设置计轴区段跳跃锁闭申请周期号*/
								}
								else
								{
									/** 逻辑区段跳跃锁闭逻辑处理 */
									LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_YES);
								}
							}
							else
							{/* 默认功能开关不打开 */
							 /** 逻辑区段跳跃锁闭逻辑处理 */
								LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_YES);
							}
#endif
							/** 判断跳跃锁闭申请命令列车ID与跳跃锁闭申请的列车ID是否相同 */
							sameTrnId = JudgeLogSecJumpLockRelTrainId(wCmdDevId, wTrainId);
							/** 相同 */
							if (CI_SUCCESS == sameTrnId)
							{
								/** 逻辑区段跳跃锁闭逻辑处理 */
								LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_YES);
							}
							else
							{
								/** 不处理 */
							}
						}
						else
						{
							/** 不处理非本TIOC控区的逻辑区段跳跃锁闭申请 */
						}
					}
					break;
				}
				/** 逻辑区段跳跃锁闭释放 */
				case IVOC_CI_CMD_TYPE_JUMP_LOCK_RELEASE:
				{
					for (jj = 0U; jj < chCmdDevSum; jj++)
					{
						wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
						logBelongCiId = GetLogSecBelongCiId(wCmdDevId);
						/** 逻辑区段属于本TIOC控区 */
						if (logBelongCiId == cLocalCiId)
						{
							/** 判断跳跃锁闭释放命令列车ID与跳跃锁闭申请的列车ID是否相同 */
							sameTrnId = JudgeLogSecJumpLockRelTrainId(wCmdDevId, wTrainId);
							/** 相同 */
							if (CI_SUCCESS == sameTrnId)
							{
								/** 清除跳跃锁闭命令列车ID */
								ClearLogSecJumpLockTrainId(wCmdDevId);
#if 0
								/** 跳跃锁闭驱道岔功能开关打开 */
								if (FUNC_SWITCH_ON == funcSwitchJumpLockDriveSwitch)
								{
									axisSecId = GetLgcSecRelativeAxleSecId(wCmdDevId);
									switchSum = GetAxisSwitchSum(axisSecId);
									if (0u < switchSum)
									{
										/** 设置逻辑区段关联的计轴区段跳跃锁闭释放标志 */
										SetAxisSecJumpLockApplyFlag(axisSecId, AXIS_SECTION_JUMPLOCK_APPLY_NO);/*设置计轴区段无跳跃锁闭申请*/
										SetAxisSecJumpLockCancelApplyFlag(axisSecId, AXSEC_CANCEL_JUMPLOCK_APPLY_YES);/*设置计轴区段有取消跳跃锁闭申请*/
									}
									else
									{
										/** 逻辑区段跳跃锁闭逻辑处理 */
										LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_NO);
									}
								}
								else
								{/* 默认功能开关不打开 */
								 /** 逻辑区段跳跃锁闭逻辑处理 */
									LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_NO);
								}
#endif
								/** 逻辑区段跳跃锁闭逻辑处理 */
								LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_NO);
							}
							else
							{
								/** 发送释放命令的列车未申请过跳跃锁闭，不做处理 */
							}
						}
						else
						{
							/** 逻辑区段属于本TIOC控区 */
						}
					}
					break;
				}
				/*动态测试申请*/
				case IVOC_CI_CMD_TYPE_DYTEST_REQ:
				{
					SetTrainDynCmd(wTrainId, TRAIN_CMD_DYM_YES);
					break;
				}
				/*动态测试取消*/
				case IVOC_CI_CMD_TYPE_DYTEST_CANCEL:
				{
					SetTrainDynCmd(wTrainId, TRAIN_CMD_DYM_NO);
					DelTrainDyTesting(wTrainId);
					break;
				}
				case IVOC_CI_CMD_GAP_DETECT_START:
				{
					for (jj = 0U; jj < chCmdDevSum; jj++)
					{
						wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];

						SetStartDetectionState(wCmdDevId, JXTC_START_DETECTION_YES);
						SetStopDetectionState(wCmdDevId, JXTC_STOP_DETECTION_NO);
					}
					break;
				}
				case IVOC_CI_CMD_GAP_DETECT_STOP:
				{
					for (jj = 0U; jj < chCmdDevSum; jj++)
					{
						wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];

						SetStartDetectionState(wCmdDevId, JXTC_START_DETECTION_NO);
						SetStopDetectionState(wCmdDevId, JXTC_STOP_DETECTION_YES);
					}
					break;
				}
				case IVOC_CI_CMD_TYPE_EA_BUILD:
				{
					SetTrainEaCmd(wTrainId, EA_PROTECT_BUILD);
					/*存在区间疏散命令*/
					chExistEaCmd = CI_SUCCESS;
					break;
				}
				case IVOC_CI_CMD_NON_RETURN_STEADY:
				{
					
					if (FUNC_SWITCH_ON == includeVirFlag)
					{
						for (jj = 0U; jj < chCmdDevSum; jj++)
						{
							wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
							belongVirCiId = GetNonAutoBelongVirCiId(wCmdDevId);
							chVirCIBelLocCiCheck = GetVirCIBelongLocalCI(belongVirCiId);
							if (CI_ERROR == chVirCIBelLocCiCheck)
							{
								break;
							}
							else
							{
								; /*属于本联锁管辖*/
							}
						}
						if (jj == chCmdDevSum)
						{
							for (jj = 0U; jj < chCmdDevSum; jj++)
							{
								wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
								SetNonRtnCmdSetTrainId(wCmdDevId, wTrainId);

								SetVirCIautoRtnIndictFlashState(wCmdDevId,belongVirCiId, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*闪灯状态置为无效*/
								SetVirCIautoRtnIndictSteadyState(wCmdDevId,belongVirCiId, VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*稳灯状态置为有效*/
							}

						}
						else
						{
							/*存在非本联锁设备，不处理*/
						}
					}
					else
					{
						for (jj = 0U; jj < chCmdDevSum; jj++)
						{
							wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
							devBelongCiId = GetNonAutoBelongCiId(wCmdDevId);
							if (cLocalCiId == devBelongCiId)
							{
								;
							}
							else
							{
								break;
							}
						}
						if (jj == chCmdDevSum)
						{
							for (jj = 0U; jj < chCmdDevSum; jj++)
							{
								wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
								SetNonRtnCmdSetTrainId(wCmdDevId, wTrainId);
								SetAutoRtnIndictFlashState(wCmdDevId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*闪灯状态无效*/
								SetAutoRtnIndictSteadyState(wCmdDevId,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*稳灯状态有效*/
							}
						}
						else
						{
							/*存在非本联锁设备，不处理*/
						}
					}
					break;
				}
				case IVOC_CI_CMD_NON_RETURN_FLASH:
				{
					if (FUNC_SWITCH_ON == includeVirFlag)
					{
						for (jj = 0U; jj < chCmdDevSum; jj++)
						{
							wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
							belongVirCiId = GetNonAutoBelongVirCiId(wCmdDevId);
							chVirCIBelLocCiCheck = GetVirCIBelongLocalCI(belongVirCiId);
							if (CI_ERROR == chVirCIBelLocCiCheck)
							{
								break;
							}
							else
							{
								; /*属于本联锁管辖*/
							}
						}
						if (jj == chCmdDevSum)
						{
							for (jj = 0U; jj < chCmdDevSum; jj++)
							{
								wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
								SetNonRtnCmdSetTrainId(wCmdDevId, wTrainId);

								SetVirCIautoRtnIndictFlashState(wCmdDevId,belongVirCiId, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*闪灯状态置为无效*/
								SetVirCIautoRtnIndictSteadyState(wCmdDevId,belongVirCiId, VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*稳灯状态置为有效*/
							}
						}
						else
						{
							/*存在非本联锁设备，不处理*/
						}
					}
					else
					{
						
						for (jj = 0U; jj < chCmdDevSum; jj++)
						{
							wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
							devBelongCiId = GetNonAutoBelongCiId(wCmdDevId);
							if (cLocalCiId == devBelongCiId)
							{
								;
							}
							else
							{
								break;
							}
						}
						if (jj == chCmdDevSum)
						{
							for (jj = 0U; jj < chCmdDevSum; jj++)
							{
								wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];
								SetNonRtnCmdSetTrainId(wCmdDevId, wTrainId);

								SetAutoRtnIndictFlashState(wCmdDevId,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*闪灯状态有效*/
								SetAutoRtnIndictSteadyState(wCmdDevId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*稳灯状态无效*/
							}
						}
						else
						{
							/*存在非本联锁设备，不处理*/
						}
					}
					break;
				}
				case IVOC_CI_CMD_TYPE_EMD_BUILD:
				{
					SetTrainEaCmd(wTrainId, EA_PROTECT_BUILD);
					/*存在区间疏散命令*/
					chExistEaCmd = CI_SUCCESS;
					break;
				}
				default:
					/*不可达分支*/
					break;
				}
			}
		}

		if (CI_SUCCESS == chExistEaCmd)
		{
			/*存在区间疏散命令*/
			SetTrainEaCmdState(wTrainId, TRAIN_EA_CMD_STATE_VALID);
		}
		else
		{
			/*不存在区间疏散命令*/
			SetTrainEaCmdState(wTrainId, TRAIN_EA_CMD_STATE_INVALID);
		}


#if 0
		/**跳跃锁闭驱动道岔功能开关打开，处理同一物理区段多逻辑区段申请跳跃锁闭错误*/
		if (FUNC_SWITCH_ON == funcSwitchJumpLockDriveSwitch)
		{
			for (ii = 0u; ii < phyNum; ii++)
			{
				phyId = GetPhySecId(ii);
				phyBelongCiId = GetPhySecBelongCiId(phyId);
				phyAxisSecNum = GetPAxisSectionSum(phyId);/*获取物理区段关联计轴区段数量*/
				pPhyAxisIDBuf = GetPAxisSectionIdBuf(phyId);/*获取物理区段关联计轴区段ID数组*/
				numAxisHaveJumpLockApply = 0u;
				if (NULL != pPhyAxisIDBuf)
				{
					if (phyBelongCiId == cLocalCiId)
					{/*物理区段属于本联锁*/
						for (jj = 0u; jj<phyAxisSecNum; jj++)
						{
							axisSecId = pPhyAxisIDBuf[jj];
							applyFlag = GetAxisSecJumpLockApplyFlag(axisSecId);
							if (AXIS_SECTION_JUMPLOCK_APPLY_YES == applyFlag)
							{
								numAxisHaveJumpLockApply++;
							}
						}
						if (numAxisHaveJumpLockApply > 1u)
						{/*一个物理区段多个计轴区段有跳跃锁闭申请*/
						 /*把这个物理区段的所有的计轴区段锁闭申请都设置成未申请*/
							for (jj = 0u; jj < phyAxisSecNum; jj++)
							{
								axisSecId = pPhyAxisIDBuf[jj];
								SetAxisSecJumpLockApplyFlag(axisSecId, AXIS_SECTION_JUMPLOCK_APPLY_NO);
								SetAxisSecJumpLockApplyCylce(axisSecId, 0u);
							}
						}
					}

				}

			}
		}
#endif
	}
}

/*
* @func： 处理列车丢失通信
* @param： vobcToCiDataStru：VOBC数据结构体
* @retrun  ： void
* @create	  ： qw.liu 2022-08-13
*/
static void ProcessIvocLoseCom(const VobcToCiDataStruct stIvocToCiData)
{
	/**变量初始化*/
	UINT16 wTrainId = 0U;
	UINT8 chTrainTransmitState = 0U;
	UINT8 trainMsgFromTiocId = 0u;
	UINT8 chLjkExistDBSwitch = 0U;
	UINT8 chVirHeadScreenPassFlag = 0U;/*虚拟前筛标志*/
	UINT8 chVirTailScreenPassFlag = 0U;/*虚拟后筛标志*/
	UINT8 chTrainPosMonitorState = 0U; /*列车位置监督标志*/

#if 0
	UINT32 dwRecvIvocCount = 0U;
	const UINT32 dwIvoc = GetCiAndVobcTransBadEnsureCnt();
	dwRecvIvocCount = stIvocToCiData.ComStartCycle;
	chTimeState = SystemOverTimeCheck(dwRecvIvocCount, dwIvoc);
#endif
	wTrainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + stIvocToCiData.VobcId;
	chTrainTransmitState = GetTrainTransitmitStat(wTrainId);
	if ((TRAIN_COMM_STATE_UNKNOWN != chTrainTransmitState)
		&& (TRAIN_COMM_STATE_BAD!= chTrainTransmitState))
	{
		trainMsgFromTiocId = GetTrainMsgFromTiocId(wTrainId);
		/**通信车信息不是来自TIOC*/
		if (0u == trainMsgFromTiocId)
		{
			(void)SetTrainTransmitStat(wTrainId, TRAIN_COMM_STATE_BAD);
			if ((IVOC_CI_INFO_TYPE_LOGOUT_ASK != stIvocToCiData.appInfoType)
				&& (IVOC_CI_LOGOUT_SLEEP != stIvocToCiData.chLogOutState))
			{
				SetTrainSleepState(wTrainId, TRAIN_SLEEP_NO);
				SetTrainSleepLink(wTrainId, 0u);
				debug_infor_printf((const)"Train%x delete sleep state because comm bad.\n", wTrainId);
			}
			else
			{
				; /*不处理*/
			}
		}
		else
		{

		}
		SetTrainDynCmd(wTrainId, TRAIN_CMD_DYM_NO);
		DelTrainDyTesting(wTrainId);

		/*无人折返该车设置为初始值*/
		IvocNonAutoRtnProcess(wTrainId);

		chLjkExistDBSwitch = GetCiFunctionSwitchConfig(FUNC_LJK_EXIST_DB);
		/*有DB的线路，断通信清除虚拟筛选标志，有可疑可以继续向车或ATS申请原地筛选*/
		chVirHeadScreenPassFlag = GetTrainVirHeadScreenPassFlag(wTrainId);
		chVirTailScreenPassFlag = GetTrainVirTailScreenPassFlag(wTrainId);
		chTrainPosMonitorState = GetTrainPosMonitorState(wTrainId);

		if ((FUNC_SWITCH_OFF == chLjkExistDBSwitch)
			|| (TRAIN_VIR_SCREEN_PASS_FLAG_INVALID == chVirHeadScreenPassFlag)
			|| (TRAIN_VIR_SCREEN_PASS_FLAG_INVALID == chVirTailScreenPassFlag)
			|| (TRAIN_POS_MONITOR_VALID != chTrainPosMonitorState))
		{
			/*有DB或有一端虚拟筛选标志是无效就清除两端的虚拟筛选*/
			SetTrainVirHeadScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID);
			SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID);
			SetTrainFullEnterLjkCycNum(wTrainId, 0U);
			SetTrainEnterLjkLinkId(wTrainId, 0U);
		}
		else
		{
			;
		}

		SetTrainReportState(wTrainId, 0U);  /*列车通信中断时，清除列车汇报状态为0*/

		SetTrainDerailment(wTrainId, TRAIN_DERAIL_NO);
		/*通信中断设置区间疏散命令状态为无效*/
		SetTrainEaCmdState(wTrainId, TRAIN_EA_CMD_STATE_INVALID);

		/*通信中断设置向后跳跃未申请和序列号为0*/
		SetTrainJumpBackApplyState(wTrainId, TRAIN_JUMP_BACK_STATE_INVALID);
		SetTrainJumpBackApplySN(wTrainId, 0U);

		SetTrainFlyProStartCycNum(wTrainId, 0U);  /*通信中断后，清除飞车起始周期号*/
	}
}

/*
* 功能描述： 处理IVOC无人折返初始值
* 参数说明： trainId：列车ID
* 返回值  ： 
*/
static void IvocNonAutoRtnProcess(const UINT16 trainId)
{
	UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT16 ii = 0U;
	UINT16 nonReturnSum = 0U;
	UINT16 nonAutoReturnId = 0U;
	UINT16 cmdSetTrainId = 0U;
	UINT8 virCiId = 0U;

	if (0U != trainId)
	{
		nonReturnSum = GetNonAutoReturnCurSum();
		for (ii = 0U; ii < nonReturnSum; ii++)
		{
			nonAutoReturnId = GetNonReturnId(ii);
			cmdSetTrainId = GetNonRtnCmdSetTrainId(nonAutoReturnId);
			if (cmdSetTrainId == trainId)

			{
				if (FUNC_SWITCH_ON == includeVirFlag)
				{
					virCiId = GetNonAutoBelongVirCiId(nonAutoReturnId);

					SetVirCIautoRtnIndictFlashState(nonAutoReturnId,virCiId, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*闪灯状态置为无效*/
					SetVirCIautoRtnIndictSteadyState(nonAutoReturnId,virCiId, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*稳灯状态置为无效*/
				}
				else
				{
					SetAutoRtnIndictFlashState(nonAutoReturnId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*闪灯状态无效*/
					SetAutoRtnIndictSteadyState(nonAutoReturnId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*稳灯状态无效*/
				}
				SetNonRtnCmdSetTrainId(nonAutoReturnId,0U);
			}
		}
	}
}

/*
* 功能描述：IVOC解锁保护区段处理
* 参数说明：vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ：void
*/
static void IvocUnLockOverlapProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT8 localCiId = 0U;  /*本联锁ID*/
	UINT8 cOverlapBelongCiId = 0U;  /*保护区段所属CI*/
	UINT16 wTrainId = 0U;
	UINT32 dwUnlockOverlapStartCyc = 0U;  /*向车申请解锁保护区段的起始周期号*/
	UINT8 ii = 0U;

	localCiId = GetSystemParaLocalCiId();

	if (NULL != vobcToCiDataStru)
	{
		for (ii = 0U; ii < vobcToCiDataStru->cAllowUnlockOverlapNum; ii++)
		{
			cOverlapBelongCiId = GetOverlapBelongCiId(vobcToCiDataStru->szAllowUnlockOverlapId[ii]);

			if ((0U != cOverlapBelongCiId) && (localCiId == cOverlapBelongCiId))  /*处理本控区的保护区段*/
			{
				wTrainId = GetOverlapUnlockApplyTrainId(vobcToCiDataStru->szAllowUnlockOverlapId[ii]);  /*获取保护区段申请解锁的列车ID*/
				dwUnlockOverlapStartCyc = GetReqIvocUnlockStartCycNum(vobcToCiDataStru->szAllowUnlockOverlapId[ii]);  /*获取保护区段申请解锁的起始周期号*/

				if ((0U != wTrainId) && (vobcToCiDataStru->VobcId == wTrainId)
					&& (0U != dwUnlockOverlapStartCyc) && (vobcToCiDataStru->szAllowUnlockOverlapStartCyc[ii] == dwUnlockOverlapStartCyc))
				{
					SetOverlapUnlockApplyTrainId(vobcToCiDataStru->szAllowUnlockOverlapId[ii], 0U);
					SetReqIvocUnlockStartCycNum(vobcToCiDataStru->szAllowUnlockOverlapId[ii], 0U);
					SetOverlapIvocAllowUnlockFlag(vobcToCiDataStru->szAllowUnlockOverlapId[ii], IVOC_ALLOW_UNLOCK_OVERLAP_YES);  /*设置保护区段列车同意解锁*/
				}
				else
				{
					/*条件不满足，不处理*/
				}
			}
			else
			{
				/*非本控区保护区段，不处理*/
			}
		}
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述： IVOC洗车相关信息处理
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* by cgh 20231109
*/
static void IvocWashDataProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT16 washMachineCurSum = 0U;/*当前集中区洗车机数量*/
	UINT16 washMachineId = 0U;/*洗车机ID*/
	UINT16 wCurVobcId = 0U;/*当前VOBC ID*/

	if (NULL != vobcToCiDataStru)
	{
		/*获取当前联锁包含洗车机数量*/
		washMachineCurSum = GetWashMachineSum();

		/*当前认为一个联锁集中区最多有一个全自动洗车机*/
		if (1U == washMachineCurSum)
		{/*本联锁集中区有一台全自动洗车机*/
			washMachineId = GetWashMachineId(0U);
			/*获取洗车机当前洗车的VOBC ID*/
			wCurVobcId = GetWashMachineCurVobcID(washMachineId);

			if (0U == wCurVobcId)
			{
				/*只有当前没有车进行洗车作业且洗车请求有效时，才设置当前洗车VOBC ID，同时设置VOBC ID必须检查vobc发给CI的消息类型正确，防止VOBC给CI发心跳帧也设上VOBC ID*/
				if (IVOC_CI_INFO_TYPE_CONTROL == vobcToCiDataStru->appInfoType)
				{
					SetWashMachineCurVobcID(washMachineId, vobcToCiDataStru->VobcId);/*设置洗车机当前洗车的VOBC ID*/
				}
				else
				{
					; /*消息类型不正确不设置*/
				}

				/*再次获取洗车机当前洗车的VOBC ID*/
				wCurVobcId = GetWashMachineCurVobcID(washMachineId);
			}
			else
			{
				; /*不设置*/
			}

			/*洗车机当前处理的是该VOBC到联锁的命令*/
			if (wCurVobcId == vobcToCiDataStru->VobcId)
			{
				/*设置洗车机驱动状态*/
				SetIvocWashDriveState(vobcToCiDataStru, washMachineId);
			}
			else
			{
				; /*其他车信息不处理*/
			}
		}
		else
		{
			; /*洗车机超限，洗车机ID不赋值*/
		}
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述： 设置IVOC洗车机驱动状态
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
*			 const UINT16 washMachineId  洗车机ID
* 返回值  ： void
* by cgh 20231110
*/
static void SetIvocWashDriveState(VobcToCiDataStruct* vobcToCiDataStru,const UINT16 washMachineId)
{
	if ((NULL != vobcToCiDataStru) && (0U < washMachineId) && (WASHMACHINE_SUM_MAX > washMachineId))
	{
		if ((WASHMACHINE_DRVSTATE_REQ_FALSE == vobcToCiDataStru->washTrainRequest)
			&& (WASHMACHINE_HEAD_STEADY_NO == vobcToCiDataStru->headWashStopSteadyInfo)
			&& (WASHMACHINE_TAIL_STEADY_NO == vobcToCiDataStru->tailWashStopSteadyInfo)
			&& (PASS_WASHMACHINE_REQUEST_INVALID == vobcToCiDataStru->passWashMachineRequest)
			&& (PAUSE_TRAIN_WASH_REQUEST_INVALID == vobcToCiDataStru->washPauseRequest))
		{
			ClearWashVobcDriveState(vobcToCiDataStru);
		}
		else
		{
			if (WASHMACHINE_DRVSTATE_REQ_TRUE == vobcToCiDataStru->washTrainRequest)
			{
				/*洗车请求有效*/
				SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_TRUE);
				/*洗车请求有效，根据VOBC下发的洗车模式命令设置驱动状态*/
				SetWashMachineWorkModeDrvState(washMachineId, vobcToCiDataStru->chWashMachineWorkMode);
			}
			else
			{
				SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_FALSE);
				/*洗车请求无效，设置洗车模式状态无效*/
				SetWashMachineWorkModeDrvState(washMachineId, WASHMACHINE_WORKMODE_INVALID_DRV);
			}

			if (WASHMACHINE_HEAD_STEADY_YES == vobcToCiDataStru->headWashStopSteadyInfo)
			{
				/*头端停稳请求有效*/
				SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_YES);
			}
			else
			{
				SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_NO);
			}

			if (WASHMACHINE_TAIL_STEADY_YES == vobcToCiDataStru->tailWashStopSteadyInfo)
			{
				/*尾端停稳请求有效*/
				SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_YES);
			}
			else
			{
				SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_NO);
			}

			if (WASHMACHINE_PAUSE_DRVREQ_TRUE == vobcToCiDataStru->washPauseRequest)
			{
				/*暂停洗车请求有效*/
				SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_TRUE);
			}
			else
			{
				SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_FALSE);
			}

			if (PASS_WASHMACHINE_DRVREQ_TRUE == vobcToCiDataStru->passWashMachineRequest)
			{
				/*通过洗车机请求有效*/
				SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_TRUE);
			}
			else
			{
				SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_FALSE);
			}
		}
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述： 清除洗车机VOBC的驱动状态
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* by cgh 20231110
*/
void ClearWashVobcDriveState(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT16 washMachineCurSum = 0U;/*当前集中区洗车机数量*/
	UINT16 washMachineId = 0U;/*洗车机ID*/
	UINT16 wCurVobcId = 0U;/*当前VOBC ID*/

	if (NULL != vobcToCiDataStru)
	{
		/*获取当前联锁包含洗车机数量*/
		washMachineCurSum = GetWashMachineSum();

		/*当前认为一个联锁集中区最多有一个全自动洗车机*/
		if (1U == washMachineCurSum)
		{/*本联锁集中区有一台全自动洗车机*/
			washMachineId = GetWashMachineId(0U);
			/*获取洗车机当前洗车的VOBC ID*/
			wCurVobcId = GetWashMachineCurVobcID(washMachineId);

			if (wCurVobcId == vobcToCiDataStru->VobcId)
			{
				SetWashMachineCurVobcID(washMachineId, 0U);/*清除当前洗车的VOBC ID*/
				/*清除洗车机的相关驱动状态*/
				SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_FALSE);
				SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_NO);
				SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_NO);
				SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_FALSE);
				SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_FALSE);
				SetWashMachineWorkModeDrvState(washMachineId, WASHMACHINE_WORKMODE_INVALID_DRV);
			}
			else
			{
				;/*其他车信息不处理*/
			}
		}
		else
		{
			; /*洗车机超限，洗车机ID不赋值*/
		}
	}
	else
	{
		; /*不处理*/
	}
}


/*
* 功能描述：IVOC车库门关闭确认处理
* 参数说明：vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ：void
* BY LC
*/
static void IvocGarageDoorCloseProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT8 localCiId = 0U;  /*本联锁ID*/
	UINT8 wBelongCiId = 0U;  /*车库门所属CI*/
	UINT16 wGarageDoorId = 0U;
	UINT32 dwGDCloseApplyStartCyc = 0U;  /*向车申请关闭车库门的起始周期号*/
	UINT8 ii = 0U;
	UINT16 wTrainId = 0U;   /*车库门A库轨上最接近的列车*/


	localCiId = GetSystemParaLocalCiId();

	if (NULL != vobcToCiDataStru)
	{
		for (ii = 0U; ii < vobcToCiDataStru->cAllowCloseGarageGateNum; ii++)
		{
			wBelongCiId = GetGaragedoorBelongCiId(vobcToCiDataStru->szAllowCloseGarageGateId[ii]);

			if ((0U != wBelongCiId) && (localCiId == wBelongCiId))  /*处理本控区的车库门*/
			{
				wGarageDoorId = vobcToCiDataStru->szAllowCloseGarageGateId[ii];  /*获取确认关闭的车库门ID*/
				dwGDCloseApplyStartCyc = GetWaiteIVOCResponseStartCycNum(wGarageDoorId);  /*获取车库门向IVOC申请关闭的起始周期号*/
				wTrainId = GetGaragedoorNearestTrainId(wGarageDoorId);
				if ((0U != wGarageDoorId) && (GARAGE_DOOR_SUM_MAX != wGarageDoorId)
					&& (0U != dwGDCloseApplyStartCyc) && (vobcToCiDataStru->szAllowCloseGarageGateCyc[ii] == dwGDCloseApplyStartCyc)
					&& (wTrainId == vobcToCiDataStru->VobcId) && (0U != wTrainId))
				{
					SetGaragedoorAllowCloseFlagIVOC(wGarageDoorId, GARAGE_DOOR_ALLOW_CLOSE_YES);
				}
				else
				{
					/*不处理*/
				}
			}
			else
			{
				/*非本控区保护区段，不处理*/
			}
		}
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：IVOC防淹门关闭允许确认处理
* 参数说明：vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ：void
* BY LC
*/
static void IvocFloodGateCloseProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT8 localCiId = 0U;  /*本联锁ID*/
	UINT8 cFloodGateBelongCiId = 0U;  /*防淹门所属CI*/
	UINT16 wFloodGateId = 0U;
	UINT32 dwFloodGateCloseApplyStartCyc = 0U;  /*向车申请防淹门关门请求的起始周期号(延时起始周期)*/
	UINT8 ii = 0U;

	localCiId = GetSystemParaLocalCiId();

	if (NULL != vobcToCiDataStru)
	{
		for (ii = 0U; ii < vobcToCiDataStru->cAllowCloseFloodGateNum; ii++)
		{
			cFloodGateBelongCiId = GetFloodGateBelongCiId(vobcToCiDataStru->szAllowCloseFloodGateId[ii]);

			if ((0U != cFloodGateBelongCiId) && (localCiId == cFloodGateBelongCiId))  /*处理本控区的防淹门*/
			{
				wFloodGateId = vobcToCiDataStru->szAllowCloseFloodGateId[ii];  /*获取确认关闭的防淹门ID*/
				dwFloodGateCloseApplyStartCyc = GetFloodGateDelayCloseStartCnt(wFloodGateId);  /*获取防淹门向IVOC申请关闭的起始周期号，延时起始周期号*/

				if ((0U != wFloodGateId) && (FLOOD_GATE_SUM_MAX != wFloodGateId)
					&& (0U != dwFloodGateCloseApplyStartCyc) && (vobcToCiDataStru->szAllowCloseFloodGateCyc[ii] == dwFloodGateCloseApplyStartCyc))
				{
					SetFloodGateAllowCloseFlagIVOC(wFloodGateId, vobcToCiDataStru->VobcId, FLOOD_GATE_ALLOWCLOSE_IVOC);
				}
				else
				{
					SetFloodGateAllowCloseFlagIVOC(wFloodGateId, vobcToCiDataStru->VobcId, FLOOD_GATE_NOT_ALLOWCLOSE_IVOC);
				}
			}
			else
			{
				/*非本控区保护区段，不处理*/
			}
		}
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述： Vobc视频清客相关信息处理
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* by cgh 20231214
*/
static void VobcVideoQkDataProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT16 wPsdSum = 0U;/*本集中区屏蔽门数量*/
	UINT16 ii = 0U;
	UINT16 wPsdId = 0U;/*屏蔽门ID*/
	UINT16 wPsdVideoQkRelateVobcId = 0U;/*屏蔽门视频清客关联VOBC ID*/

	if (NULL != vobcToCiDataStru)
	{
		if (VIDEO_QK_STATE_DEFAULT == vobcToCiDataStru->chVideoQkState)
		{
			/*视频清客状态为默认值需要设置屏蔽门视频清客驱动状态为无效*/
			wPsdSum = GetPsdSum();
			for (ii = 0U; ii < wPsdSum; ii++)
			{
				wPsdId = GetPsdId(ii);
				if ((0U < wPsdId) && (PSD_SUM_MAX > wPsdId))
				{
					wPsdVideoQkRelateVobcId = GePsdVideoQkRelateVobcId(wPsdId);

					if (wPsdVideoQkRelateVobcId == vobcToCiDataStru->VobcId)
					{
						/*设置对应列车屏蔽门视频清客驱动状态为无效*/
						SetPsdVideoQkDriveState(wPsdId,VIDEO_QK_DRIVE_STATE_INVALID);
						SetPsdVideoQkRelateVobcId(wPsdId, 0U);
					}
					else
					{
						; /*本车没有对此屏蔽门进行视频清客，不清除驱动状态*/
					}
				}
				else
				{
					; /*屏蔽门ID不合法，不处理*/
				}
			}	
		}
		else if(VIDEO_QK_STATE_TESTING == vobcToCiDataStru->chVideoQkState)
		{
			/*视频清客状态为检测中*/
			if (VIDEO_QK_RESULT_TESTDEFAULT == vobcToCiDataStru->chVideoQkResult)
			{
				/*视频清客结果为默认*/
				SetRelatePsdVideoQkDriveState(vobcToCiDataStru->wVideoQkRelatePsdId1, vobcToCiDataStru->wVideoQkRelatePsdId2, VIDEO_QK_DRIVE_STATE_TESTING, vobcToCiDataStru->VobcId);

			}
			else if (VIDEO_QK_RESULT_TESTNO == vobcToCiDataStru->chVideoQkResult)
			{
				/*视频清客结果为已检测无人*/
				SetRelatePsdVideoQkDriveState(vobcToCiDataStru->wVideoQkRelatePsdId1, vobcToCiDataStru->wVideoQkRelatePsdId2, VIDEO_QK_DRIVE_STATE_NO, vobcToCiDataStru->VobcId);
			}
			else if (VIDEO_QK_RESULT_TESTHAVE == vobcToCiDataStru->chVideoQkResult)
			{
				/*视频清客结果为已检测有人*/
				SetRelatePsdVideoQkDriveState(vobcToCiDataStru->wVideoQkRelatePsdId1, vobcToCiDataStru->wVideoQkRelatePsdId2, VIDEO_QK_DRIVE_STATE_HAVE, vobcToCiDataStru->VobcId);
			}
			else
			{
				; /*非法状态，不处理*/
			}
		}
		else
		{
			; /*非法状态，不处理*/
		}
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述： 设置关联PSD视频清客驱动状态
* 参数说明： const UINT16 wPsdId1 屏蔽门ID1
*			 const UINT16 wPsdId2 屏蔽门ID2
*            const UINT8 chSetState  视频清客驱动状态
*			 const UINT16 wRelateVobcId 视频清客关联VOBC ID
* 返回值  ： void
* by cgh 20231214
*/
void SetRelatePsdVideoQkDriveState(const UINT16 wPsdId1, const UINT16 wPsdId2,const UINT8 chSetState,const UINT16 wRelateVobcId)
{
	if ((PSD_SUM_MAX > wPsdId1) && (PSD_SUM_MAX > wPsdId2))
	{
		/*ID可能为0，只防护最大值*/
		if (0U != wPsdId1)
		{
			SetPsdVideoQkDriveState(wPsdId1,chSetState);
			SetPsdVideoQkRelateVobcId(wPsdId1, wRelateVobcId);
		}
		else
		{
			; /*视频清客屏蔽门ID为0，不设置驱动状态*/
		}

		if (0U != wPsdId2)
		{
			/*设置对应列车屏蔽门视频清客确认状态为已检测有人*/
			SetPsdVideoQkDriveState(wPsdId2,chSetState);
			SetPsdVideoQkRelateVobcId(wPsdId2, wRelateVobcId);
		}
		else
		{
			; /*视频清客屏蔽门ID为0，不设置驱动状态*/
		}
	}
	else
	{
		; /*ID不合法不进行处理*/
	}
}

/*
* 功能描述： 出清对应列车在对应物理区段上的停稳信息
* 参数说明： UINT16 wTrainId 列车ID
* 返回值  ： void
*/
void ClearVobcStopSteadyData(UINT16 wTrainId)
{
	UINT16 phySecCurSum = 0U;
	UINT16 ii = 0U;
	UINT16 deviceId = 0U;
	UINT16 PhyStopSteadyTrainId = 0U;
	phySecCurSum = GetPhySecCurSum();
	/* 清除物理区段对应列车停稳信息 */
	for (ii = 0U; ii < phySecCurSum; ii++)
	{
		deviceId = GetPhySecId(ii);
		PhyStopSteadyTrainId = GetPhyStopSteadyTrainId(deviceId);

		/*清除对应车的停稳信息*/
		if ((0U != PhyStopSteadyTrainId) && (wTrainId == PhyStopSteadyTrainId))
		{
			SetPhySecStopSteadyFlag(deviceId, PHYSICAL_SECTION_STOPSTEADY_NO);/*设置物理区段未停稳*/
			SetPhyStopSteadyTrainId(deviceId, 0U);		/*出清物理区段上的车ID*/
		}
		else
		{
			;	/*未有停稳的车ID，证明列车未在此物理区段上发过停稳*/
		}
	}
}

/*
* 功能描述： Vobc前车位置信息处理
* 参数说明： const UINT16 wTrainId 列车ID
* 返回值  ： void
* by cgh 20240606
*/
void VobcHeadTrainDataProc(const UINT16 wTrainId)
{
	UINT8 chReval = CI_ERROR;
	TrainIteDataStruct* strTrainIteData = NULL;
	UINT16 wHeadTrainId = 0U;/*前车ID*/
	HeadTrainLocStru strTempHeadTrainLocData = { 0U };/*临时前车位置数据*/
	UINT16 wTrainMaxHeadLink = 0U;/*大前LINK*/
	UINT32 dwTrainMaxHeadOffect = 0U;/*大前偏移量*/
	UINT16 wTrainMinTailLink = 0U;/*小后LINK*/
	UINT32 dwTrainMinTailOffect = 0U;/*小后偏移量*/
	UINT8 chTrainDir = 0U;/*列车方向*/
	UINT32 dwVobcHlhtId = 0U;/*列车互联互通ID*/
	UINT16 wTrainIndex = 0U;/*列车ID索引*/
	UINT16 wVobcDevName = 0U;
	UINT8 chDir = 0U;/*运营方向*/
	UINT8 chNvramPosFlag = TRAIN_NVRAM_POS_FLAG_YES;

	wTrainIndex = GetTrainBufIndex(wTrainId);
	if (TRAIN_SUM_MAX > wTrainIndex)
	{
		wVobcDevName = GetTrainHeadTrainId(wTrainId);
		wHeadTrainId = GetTrainBufIndex(wVobcDevName);
		if (TRAIN_SUM_MAX > wHeadTrainId)
		{
			chReval = dquDevName2HlhtId(wVobcDevName, 0U, &dwVobcHlhtId);
			if (CI_SUCCESS == chReval)
			{
				wTrainMaxHeadLink = GetAblTrainMaxHeadLink(wHeadTrainId);
				dwTrainMaxHeadOffect = GetAblTrainMaxHeadOffset(wHeadTrainId);
				wTrainMinTailLink = GetAblTrainMinTailLink(wHeadTrainId);
				dwTrainMinTailOffect = GetAblTrainMinTailOffset(wHeadTrainId);
				chTrainDir = GetAblTrainDir(wHeadTrainId);
				chDir = ConvertLogicDirToRun(chTrainDir);
				strTrainIteData = GetTrainIteData(wHeadTrainId);

				chNvramPosFlag = GetTrainNvramPosFlag(wHeadTrainId);
				if (TRAIN_NVRAM_POS_FLAG_NO == chNvramPosFlag)
				{
					/*NVRAM位置可信才计算位置，不可用发默认值*/
					if ((0U != wTrainMaxHeadLink) && (0U != wTrainMinTailLink))
					{
						/*最大无效值接口已经校验过*/
						strTempHeadTrainLocData.wHeadVobcId = dwVobcHlhtId;
						strTempHeadTrainLocData.chHeadTrainLocFlag = HEAD_TRAIN_LOC_ATP;
						strTempHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir = chDir;
						strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink = wTrainMaxHeadLink;
						strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset = dwTrainMaxHeadOffect;
						strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink = wTrainMinTailLink;
						strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset = dwTrainMinTailOffect;
						strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink = 0U;
						strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset = UINT32_MAX;
						strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink = 0U;
						strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset = UINT32_MAX;
						strTempHeadTrainLocData.strHeadTrainIteLoc.chTrainDir = TRAIN_DIR_DEF;
						strTempHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss = UINT16_MAX;
						strTempHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss = UINT16_MAX;
					}
					else if (NULL != strTrainIteData)
					{
						/*ITE数据获取成功查找哪段数据有效*/
						if (0U != strTrainIteData[0].wTrainHeadLinkId)
						{
							strTempHeadTrainLocData.wHeadVobcId = dwVobcHlhtId;
							strTempHeadTrainLocData.chHeadTrainLocFlag = HEAD_TRAIN_LOC_ITE;
							strTempHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir = TRAIN_DIR_DEF;
							strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink = 0U;
							strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset = UINT32_MAX;
							strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink = 0U;
							strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset = UINT32_MAX;
							strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink = strTrainIteData[0].wTrainHeadLinkId;
							strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset = strTrainIteData[0].dwTrainHeadLinkOffset;
							strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink = strTrainIteData[0].wTrainTailLinkId;
							strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset = strTrainIteData[0].dwTrainTailLinkOffset;
							strTempHeadTrainLocData.strHeadTrainIteLoc.chTrainDir = strTrainIteData[0].cTrainDir;
							strTempHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss = strTrainIteData[0].wForWardOffset;
							strTempHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss = strTrainIteData[0].wBackOffset;
						}
						else if (0U != strTrainIteData[1].wTrainHeadLinkId)
						{
							strTempHeadTrainLocData.wHeadVobcId = dwVobcHlhtId;
							strTempHeadTrainLocData.chHeadTrainLocFlag = HEAD_TRAIN_LOC_ITE;
							strTempHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir = TRAIN_DIR_DEF;
							strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink = 0U;
							strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset = UINT32_MAX;
							strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink = 0U;
							strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset = UINT32_MAX;
							strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink = strTrainIteData[1].wTrainHeadLinkId;
							strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset = strTrainIteData[1].dwTrainHeadLinkOffset;
							strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink = strTrainIteData[1].wTrainTailLinkId;
							strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset = strTrainIteData[1].dwTrainTailLinkOffset;
							strTempHeadTrainLocData.strHeadTrainIteLoc.chTrainDir = strTrainIteData[1].cTrainDir;
							strTempHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss = strTrainIteData[1].wForWardOffset;
							strTempHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss = strTrainIteData[1].wBackOffset;
						}
						else
						{
							chReval = CI_ERROR;
						}
					}
					else
					{
						chReval = CI_ERROR;
					}
				}
				else
				{
					chReval = CI_ERROR;
				}
			}
			else
			{
				chReval = CI_ERROR;
			}

		}
		else
		{
			chReval = CI_ERROR;
		}

		if (CI_ERROR == chReval)
		{
			/*发默认值*/
			ClearVobcHeadTrainData(wTrainId);
		}
		else
		{
			SetTrainHeadTrainLocData(wTrainId, strTempHeadTrainLocData); /*有效*/
		}
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述： 清除Vobc前车位置信息处理
* 参数说明： const UINT16 wTrainId 列车ID
* 返回值  ： void
* by cgh 20240606
*/
static void ClearVobcHeadTrainData(const UINT16 wTrainId)
{
	HeadTrainLocStru strTempHeadTrainLocData = { 0U };/*临时前车位置数据*/
	UINT16 wTrainIndex = 0U;/*列车ID索引*/

	wTrainIndex = GetTrainBufIndex(wTrainId);
	if (TRAIN_SUM_MAX > wTrainIndex)
	{
		strTempHeadTrainLocData.wHeadVobcId = UINT32_MAX;
		strTempHeadTrainLocData.chHeadTrainLocFlag = HEAD_TRAIN_LOC_DEFAULT;
		strTempHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir = TRAIN_DIR_DEF;
		strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink = 0U;
		strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset = UINT32_MAX;
		strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink = 0U;
		strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset = UINT32_MAX;
		strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink = 0U;
		strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset = UINT32_MAX;
		strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink = 0U;
		strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset = UINT32_MAX;
		strTempHeadTrainLocData.strHeadTrainIteLoc.chTrainDir = TRAIN_DIR_DEF;
		strTempHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss = UINT16_MAX;
		strTempHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss = UINT16_MAX;

		SetTrainHeadTrainLocData(wTrainId, strTempHeadTrainLocData);
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述：处理ITE到CI数据
* 参数说明：void
* 返回值  ：void
* Created By LQ 2024.06.06
*/
void ProcessIteToCiData(void)
{
	UINT8 ii = 0U;
	UINT8 cIteNum = 0U;  /*与CI通信的ITE数量*/
	IteToCiDataStruct* pstrIteToCiData = NULL;  /*与CI通信的ITE结构体指针*/
	UINT8 cFuncCheckFlag = CI_ERROR;
	UINT16 wTrainId = 0U;  /*ITE关联的列车ID*/
	UINT8 cNeedKeepIteNum = 0U;  /*保持正常通信的ITE数量*/
	UINT32 dwCurCycNum = 0U;

	cIteNum = GetIteToCiSum();
	pstrIteToCiData = GetIteToCiDataStru();

	if ((0U != cIteNum) && (NULL != pstrIteToCiData))
	{
		for (ii = 0U; ii < cIteNum; ii++)
		{
			wTrainId = pstrIteToCiData[ii].wIteId & 0x00FFU;
			cFuncCheckFlag = CheckIteHLHTHeadCtxValid((UINT8)pstrIteToCiData[ii].wIteId, pstrIteToCiData[ii].wIteLogId);  /*使用互联互通头来判断CI与ITE通信是否有效*/

			if (CI_SUCCESS == cFuncCheckFlag)
			{
				dwCurCycNum = Get2oo2CurCycleNum();
				if (dwCurCycNum == pstrIteToCiData[ii].dwComStartCycCount)
				{
					/*当周期收到ITE数据，将ITE数据存入列车ITE数据结构体*/
					SetIteTrainHeadLinkId(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].wTrainHeadLinkId);
					SetIteTrainHeadLinkOffset(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].dwTrainHeadLinkOffset);
					SetIteTrainTailLinkId(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].wTrainTailLinkId);
					SetIteTrainTailLinkOffset(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].dwTrainTailLinkOffset);
					SetIteTrainDir(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].cTrainDir);
					SetIteTrainForWardOffset(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].wForWardOffset);
					SetIteTrainBackOffset(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].wBackOffset);
				}
				else
				{
					/*不处理非当周期的ITE数据*/
				}

				(void)CommonMemCpy(&(pstrIteToCiData[cNeedKeepIteNum]), (UINT32)sizeof(IteToCiDataStruct), &(pstrIteToCiData[ii]), (UINT32)sizeof(IteToCiDataStruct));
				cNeedKeepIteNum++;
			}
			else
			{
				/*与ITE通信异常，清除对应列车ITE数据结构体，并清除ITE通信结构体*/
				ClearTrainIteInfo(wTrainId, pstrIteToCiData[ii].wIteLogId);
			}
		}

		if (cNeedKeepIteNum != cIteNum)
		{
			RemoveIteToCiMsgAt(cNeedKeepIteNum);  /*清除通信中断的ITE数据*/
		}
		else
		{
			/*无通信异常的ITE，不处理*/
		}
	}
	else
	{
		/*无通信正常的ITE，不处理*/
	}
}

/*
* 功能描述： 更新ATS设备通信状态
* 参数说明： void
* 返回值  ： 无
* by cgh 20240614
*/
void UpdataAtsDeviceCommState(void)
{
	/*变量初始化*/
	UINT8 chLocalCiId = 0U;
	UINT16 j = 0u;
	UINT8 deviceSum = 0u; /*通信设备数*/
	UINT8* pDeviceIdBuf = NULL;  /*设备ID数组*/

	chLocalCiId = GetSystemParaLocalCiId();
	/*现地系统通信状态*/
	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_XIANDI);
	pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_XIANDI);

	if ((NULL != pDeviceIdBuf) && (0U != deviceSum))
	{
		for (j = 0u; j < deviceSum; j++)
		{
			(void)UpdateCiTransmitState(chLocalCiId, CI_SYSTEM_TYPE_XIANDI, pDeviceIdBuf[j]);
		}
	}
	else
	{
		;
	}

	/*ATS系统通信状态*/
	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_ATS);
	pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ATS);

	if ((NULL != pDeviceIdBuf) && (0u != deviceSum))
	{
		for (j = 0u; j < deviceSum; j++)
		{
			(void)UpdateCiTransmitState(chLocalCiId, CI_SYSTEM_TYPE_ATS, pDeviceIdBuf[j]);
		}
	}
	else
	{
		;
	}
}

/*
* 功能描述： Vobc列车接口信息处理
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* by cgh 20240614
*/
static void VobcConnectDataProc(VobcToCiDataStruct* vobcToCiDataStru)
{
	if (NULL != vobcToCiDataStru)
	{
		SetAblTrainDir(vobcToCiDataStru->VobcId, vobcToCiDataStru->trainDirection);
		SetAblTrainMaxHeadLink(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainMaxSafeHeadLink);
		SetAblTrainMaxHeadOffset(vobcToCiDataStru->VobcId, vobcToCiDataStru->dwTrainMaxSafeHeadOffset);
		SetAblTrainMinTailLink(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainMinSafeTailLink);
		SetAblTrainMinTailOffset(vobcToCiDataStru->VobcId, vobcToCiDataStru->dwTrainMinSafeTailOffset);

		SetTrainHeadSigId(vobcToCiDataStru->VobcId, vobcToCiDataStru->wHeadSigId);
		SetTrainHeadTrainId(vobcToCiDataStru->VobcId, vobcToCiDataStru->wHeadVobcId);

		SetTrainNvramPosFlag(vobcToCiDataStru->VobcId, vobcToCiDataStru->chNvramPosFlag);

		SetTrainLevel(vobcToCiDataStru->VobcId, vobcToCiDataStru->chTrainLevel);
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述： Vobc列车信息清除
* 参数说明： UINT16 wTrainId：VOBCid
* 返回值  ： void
* by cgh 20240614
*/
static void VobcConnectDataClear(const UINT16 wTrainId)
{
	if ((TRAIN_SUM_MAX > wTrainId) && (0U < wTrainId))
	{
		SetAblTrainMaxHeadLink(wTrainId, 0U);
		SetAblTrainMaxHeadOffset(wTrainId, UINT32_MAX);
		SetAblTrainMinTailLink(wTrainId, 0U);
		SetAblTrainMinTailOffset(wTrainId, UINT32_MAX);

		SetTrainHeadSigId(wTrainId, 0U);
		SetTrainHeadTrainId(wTrainId, TRAIN_ID_MAX);
		/*清除前方列车位置信息*/
		ClearVobcHeadTrainData(wTrainId);

		/*清除FAOHLHT接口后备信息帧数据*/
		ClearBackUpTrainInfo(wTrainId);
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述： Vobc后备接口信息处理
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* by cgh 20240710
*/
static void VobcBackUpConnectDataProc(VobcBackUpToCiDataStruct* vobcToCiDataStru)
{
	if (NULL != vobcToCiDataStru)
	{
		SetAblTrainDir(vobcToCiDataStru->VobcId, vobcToCiDataStru->trainDirection);
		SetAblTrainMaxHeadLink(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainMaxSafeHeadLink);
		SetAblTrainMaxHeadOffset(vobcToCiDataStru->VobcId, vobcToCiDataStru->dwTrainMaxSafeHeadOffset);
		SetAblTrainMinTailLink(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainMinSafeTailLink);
		SetAblTrainMinTailOffset(vobcToCiDataStru->VobcId, vobcToCiDataStru->dwTrainMinSafeTailOffset);

		SetTrainHeadSigId(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainHeadCurSignalId);
		SetTrainHeadTrainId(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainHeadTrainId);

		SetTrainNvramPosFlag(vobcToCiDataStru->VobcId, vobcToCiDataStru->chNvramPosFlag);
		SetTrainLevel(vobcToCiDataStru->VobcId, vobcToCiDataStru->chTrainLevel);
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述： 处理VOBC后备停稳信息数据
* 参数说明： vobcToCiDataStru：VOBC数据结构体指针
* 返回值  ： void
* fan 20240815
*/
static void BackupStopSteadyDataProc(VobcBackUpToCiDataStruct* vobcToCiDataStru)
{
	UINT16 psdRelatedPhySecId = 0u;/*VOBC发送的轨道区段ID对应的物理区段ID*/
	UINT32 currCycleNum = 0u;
	UINT8 localCiId = GetSystemParaLocalCiId();/*本联锁ID*/
											   /*物理区段CT或UT占用状态，设置为无车状态*/
	UINT8 utOrCtOccFlag = SECTION_OCCUPY_YES;
	UINT8 phyBelongCiId = 0u;
	currCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/
	if (NULL != vobcToCiDataStru)
	{
		if (currCycleNum == vobcToCiDataStru->stopSteadyStartCycNum)
		{/*本周期收到才有效*/

			ClearVobcStopSteadyData(vobcToCiDataStru->VobcId);/*本车清除之前停稳信息*/

			/*整个物理区段停稳信息在VOBC输入处理里已清除*/
			if (VOBC_CI_STOP_TW == vobcToCiDataStru->chStopSteadyState)
			{/*只有收到V停稳信息时才设置物理区段停稳信息*/
				
				/*查询编号对照表，根据轨道区段ID获取计轴区段ID*/
				psdRelatedPhySecId = GetTrackToPhySectionId(vobcToCiDataStru->trackSecID);
							
				phyBelongCiId = GetPhySecBelongCiId(psdRelatedPhySecId);

				if (localCiId == phyBelongCiId)
				{/*获取物理区段当前占用状态*/
					 /*在每个周期的初始化阶段，每个物理区段都会被置成未停稳。VOBC与ZC发来的停稳信息做或运算，即有一方告诉CI停稳，就认为停稳。*/
					utOrCtOccFlag = GetPhySecPreOccState(psdRelatedPhySecId);
					if (LOGICSECTION_OCCUPY_UT == utOrCtOccFlag)
					{
						SetPhySecStopSteadyFlag(psdRelatedPhySecId, PHYSICAL_SECTION_STOPSTEADY_YES);/*设置物理区段停稳*/
						SetPhyStopSteadyTrainId(psdRelatedPhySecId, vobcToCiDataStru->VobcId);		/*设置停稳物理区段关联的列车ID*/
					}
					else if (LOGICSECTION_OCCUPY_CT == utOrCtOccFlag)
					{
						;/*异常场景同一物理区段有CT车 不根据后备通道设置停稳*/
					}
					else
					{
						/*列车类型故障*/
					}
				}

			}
		}
	}
}

/*
* 功能描述：刷新湿轨标志
* 参数说明：无
* 返回值  ：无
* edit By cgh 2024.10.30
*/
void UpdateHumidRailFlag(void)
{
	UINT8 cFuncSwitch = FUNC_SWITCH_OFF;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT16 wCurPhySecNum = 0U;
	UINT16 wPhySecId = 0U;
	UINT8 cAllHumidRailState = CI_ALL_SNOW_UNVALID;  /*集中区湿轨状态*/
	UINT8 cAreaHumidRailNum = 0U;  /*区间湿轨数量*/
	AreaSnowInfoStruct* pAreaHumidRailData = NULL;
	ToCiAreaSnowStruct* pRecvCiAreaHumidRail = NULL;  /*相邻联锁发送的区间湿轨信息*/
	UINT16 wCurSignalNum = 0U;
	UINT16 wSignalId = 0U;
	UINT16 wInFstPhySecId = 0U;  /*信号内方第一物理区段ID*/
	UINT8 cInFstPSInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO;
	UINT16 wOutFstPhySecId = 0U;  /*信号外方第一物理区段ID*/
	UINT8 cOutFstPSInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO;
	UINT8 cLocalHumidRailState = CI_LOCAL_SNOW_UNVALID;  /*本地湿轨状态*/
	UINT8 chLocalCiType = 0U; /*本联锁属性*/

	chLocalCiType = GetLocalCiType();
	cFuncSwitch = GetCiFunctionSwitchConfig(FUNC_ZQX_CHECK_HUMID_RAIL);

	if ((FUNC_SWITCH_ON == cFuncSwitch) &&((CI_TYPE_SCX == chLocalCiType) || (CI_TYPE_ZX == chLocalCiType)))
	{
		/****** 更新物理区段的湿轨标志 ******/
		wCurPhySecNum = GetPhySecCurSum();
		for (ii = 0U; ii < wCurPhySecNum; ii++)
		{
			wPhySecId = GetPhySecId(ii);
			SetPhySecInHumidRailFlag(wPhySecId, PHYSEC_IN_HUMID_RAIL_NO);  /*先周期清除标志，再根据湿轨范围确定物理区段湿轨标志*/
		}

		cAllHumidRailState = GetAllSnowModel();
		cLocalHumidRailState = GetLocalSnowModel();

		if ((CI_ALL_SNOW_VALID == cAllHumidRailState) || (CI_LOCAL_SNOW_VALID == cLocalHumidRailState))
		{
			/*** 全线湿轨模式状态有效或本地湿轨状态有效，将控区内所有物理区段的湿轨标志置为有效 ***/
			for (ii = 0U; ii < wCurPhySecNum; ii++)
			{
				wPhySecId = GetPhySecId(ii);
				SetPhySecInHumidRailFlag(wPhySecId, PHYSEC_IN_HUMID_RAIL_YES);
			}
		}
		else
		{
			/*** 处理本集中区的区间湿轨 ***/
			cAreaHumidRailNum = GetLocalAreaSnowNum();
			pAreaHumidRailData = GetLocalAreaSnow();
			if ((0U != cAreaHumidRailNum) && (LOCAL_AREA_SNOW_SUM_MAX >= cAreaHumidRailNum) && (NULL != pAreaHumidRailData))
			{
				/*本集中区存在区间湿轨，将其中属于本控区的物理区段湿轨标志置为有效*/
				for (jj = 0U; jj < cAreaHumidRailNum; jj++)
				{
					SetPlatFormRelPSHumidRailFlag(pAreaHumidRailData[jj].wAreaId);
				}
			}
			else
			{
				/*无区间湿轨，不处理*/
			}

			/*** 处理相邻集中区发送的区间湿轨 ***/
			pRecvCiAreaHumidRail = GetCiRecvAreaSnowInfo();
			if (NULL != pRecvCiAreaHumidRail)
			{
				for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++)
				{
					/*相邻控区的区间湿轨覆盖有本控区的物理区段，将其中属于本控区的物理区段湿轨标志置为有效*/
					for (jj = 0U; jj < pRecvCiAreaHumidRail[ii].cPlatFormNum; jj++)
					{
						SetPlatFormRelPSHumidRailFlag(pRecvCiAreaHumidRail[ii].szPlatFormInfo[jj].wAreaId);
					}
				}
			}
			else
			{
				/*不处理*/
			}
		}

		/****** 更新信号机的湿轨标志 ******/
		wCurSignalNum = GetSignalCurSum();
		for (ii = 0U; ii < wCurSignalNum; ii++)
		{
			wSignalId = GetSignalId(ii);
			SetSignalInHumidRailFlag(wSignalId, SIGNAL_IN_HUMID_RAIL_NO);  /*先周期清除标志，再根据湿轨范围确定信号机湿轨标志*/

			wInFstPhySecId = GetSignalInFirstPhySecId(wSignalId, 0U);  /*获取信号机内外方第一物理区段湿轨标志*/
			cInFstPSInHumidRailFlag = GetPhySecInHumidRailFlag(wInFstPhySecId);
			wOutFstPhySecId = GetSignalOutFirstPhySecId(wSignalId);
			cOutFstPSInHumidRailFlag = GetPhySecInHumidRailFlag(wOutFstPhySecId);

			if ((PHYSEC_IN_HUMID_RAIL_YES == cInFstPSInHumidRailFlag) || (PHYSEC_IN_HUMID_RAIL_YES == cOutFstPSInHumidRailFlag))
			{
				SetSignalInHumidRailFlag(wSignalId, SIGNAL_IN_HUMID_RAIL_YES);  /*信号机内方第一物理区段或外方第一物理区段湿轨标志有效，置信号机湿轨标志有效*/
			}
			else
			{
				/*不处理*/
			}
		}
	}
	else
	{
		/*开关关闭，不处理物理区段和信号机的湿轨状态*/
	}
}

/*
* 功能描述： 进路区段锁闭命令处理
* 参数说明： const UINT16 wCurRLockRouteId  当前锁闭所属进路ID
	         const UINT16 wPreRLockRouteId  之前锁闭所属进路ID
* 返回值  ： 无
* by cgh 20241204
*/
void RouteSecLockApplyCmdProc(const UINT16 wCurRLockRouteId, const UINT16 wPreRLockRouteId)
{
	UINT8 phySecSum = 0U;  /*物理区段总数*/
	UINT8 curLockState = 0U;  /*区段当前锁闭状态*/
	UINT16 validRouteId = 0U;  /*需要处理有效进路ID*/
	UINT8 ii = 0U;  /*遍历变量*/
	RoutePhysicalSectionStruct* pPhySecDataStru = NULL;  /*物理区段结构指针*/
	UINT8 chRouteDir = 0U;/*进路方向*/
	UINT16 logSectionSum = 0u; /*逻辑区段数*/
	UINT16* pLogIdBuff = NULL;
	UINT8 chTrainSum = 0U;
	LogicTrainResStruct* pstLgcResInfo = NULL;
	LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U };

	if ((0U == wCurRLockRouteId) && (0U != wPreRLockRouteId))
	{
		/*逻辑进路冲跨控区进路处理*/
		LogRouteCleanOldLogSecLockProc(wPreRLockRouteId);
		LogRouteCleanOldPhySecLockProc(wPreRLockRouteId);
	}
	else if ((0U == wPreRLockRouteId) && (0U != wCurRLockRouteId))
	{
		/*跨控区进路冲逻辑进路处理*/
		OtherPartRouteCleanLogRouteProc(wCurRLockRouteId);
	}
	else
	{
		phySecSum = GetRoutePhysicalSectionSum(wCurRLockRouteId);  /*获取进路物理区段总数*/
		pPhySecDataStru = GetRouteSectionData(wCurRLockRouteId);  /*获取进路物理区段数据*/
		if ((0U != phySecSum) && (NULL != pPhySecDataStru))
		{
			chRouteDir = GetRouteDirection(wCurRLockRouteId);
			for (ii = 0U; ii < phySecSum; ii++)
			{
				curLockState = 0U;
				curLockState = GetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId);  /*获取区段当前锁闭状态*/

				if ((PHYSICAL_SECTION_LOCK_NORMAL == curLockState)
					|| (PHYSICAL_SECTION_LOCK_DELAY == curLockState)
					|| (PHYSICAL_SECTION_LOCK_EXCEPT == curLockState))
				{ /*正常锁闭||延时解锁||故障锁闭*/

					validRouteId = GetPhySecRLockBelongRouteId(pPhySecDataStru[ii].PhysicalSectionId);  /*获取物理区段锁闭所属进路ID*/

					if (wPreRLockRouteId == validRouteId)
					{
						SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, validRouteId, 0U);  /*设置区段未锁闭*/
						SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NORMAL, wCurRLockRouteId, chRouteDir);  /*设置区段锁闭状态*/
					}
					else
					{
						;
					}
				}
				else
				{
					;
				}
			}

			if ((0U < validRouteId) && (validRouteId != wCurRLockRouteId))
			{
				/*锁闭所属进路属于本控区*/
				/*处理本次进路办理冲掉的进路（13AB场景）*/
				DealValidRouteState(validRouteId);
			}
			else if(validRouteId == wCurRLockRouteId)
			{
				DealValidRouteState(wPreRLockRouteId);  /*解决部分进路冲进路为空闲场景*/
			}
			else
			{
				/*不处理*/
			}

			/*获取进路包含逻辑区段信息*/
			logSectionSum = GetRouteLogSectionSum(wCurRLockRouteId);
			pLogIdBuff = GetRouteLogSectionIdBuf(wCurRLockRouteId);

			/*检查数据合法*/
			if (NULL != pLogIdBuff)
			{
				for (ii = 0u; ii < logSectionSum; ii++)
				{

					curLockState = 0U;
					/*获取当前锁闭状态*/
					curLockState = GetLogSecLockState(pLogIdBuff[ii]);
					/*区段正常锁闭或延时解锁*/
					if ((LOG_SECTION_LOCK_NORMAL == curLockState)
						|| (LOG_SECTION_LOCK_DELAY == curLockState)
						|| (LOG_SECTION_LOCK_EXCEPT == curLockState))
					{
						validRouteId = GetLogSecLockBelongRoute(pLogIdBuff[ii]);
						if (wPreRLockRouteId == validRouteId)
						{
							chTrainSum = GetLogSecTrainInfoSum(pLogIdBuff[ii]);
							pstLgcResInfo = GetLogSecTrainInfo(pLogIdBuff[ii]);
							if (NULL != pstLgcResInfo)
							{
								(void)ComMemCopy(pstLgcResInfo, stTmpResInfo, (UINT16)(sizeof(LogicTrainResStruct) * LOGIC_SECTION_RES_SUM_MAX));
								SetLogSecLockState(pLogIdBuff[ii], LOG_SECTION_LOCK_NO, validRouteId, 0U);/*设置区段锁闭所属之前进路未锁闭*/
								/*设置区段属于当前进路锁闭*/
								SetLogSecLockState(pLogIdBuff[ii], LOG_SECTION_LOCK_NORMAL, wCurRLockRouteId, chRouteDir);

								CpyLgcSecResTrain(pLogIdBuff[ii], chTrainSum, stTmpResInfo);/*拷贝逻辑区段列车资源信息*/
							}
							else
							{
								;
							}
						}
						else
						{
							; /*不属于自己的不处理*/
						}
					}
					else
					{
						;
					}
				}
			}
			else
			{
				;
			}
		}
		else
		{
			/*不处理*/
		}
	}
}

/*
* 功能描述：逻辑进路清除跨控区进路逻辑区段锁闭处理
* 参数说明：const UINT16 wPreRouteId  原进路ID
* 返 回 值： 无
* Created By LQ 2025.03.10
*/
void LogRouteCleanOldLogSecLockProc(const UINT16 wPreRouteId)
{
	UINT16 wRouteIndex = 0U;
	UINT16 wLogSecSum = 0U;  /*进路包含的逻辑区段数量*/
	UINT16* pLogSecIdBuff = NULL;  /*进路包含的逻辑区段ID*/
	UINT8 ii = 0U;
	UINT8 cCurRouteLockState = 0U;  /*逻辑区段当前进路锁闭状态*/
	UINT8 cCurRouteLockDir = 0U;  /*逻辑区段当前进路锁闭方向*/
	UINT16 wValidRouteId = 0U;  /*需要处理的进路ID*/
	UINT8 cCurLogLockState = 0U;  /*逻辑区段当前逻辑进路锁闭状态*/
	UINT8 cCurLogLockDir = 0U;  /*逻辑区段当前逻辑进路锁闭方向*/
	UINT8 cResTrainSum = 0U;  /*逻辑区段资源列车数量*/
	LogicTrainResStruct* pstLgcResInfo = NULL;  /*逻辑区段资源信息*/
	LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U };

	wRouteIndex = GetRouteConfigBufIndex(wPreRouteId);  /*获取进路数组下标*/

	if (ROUTE_SUM_MAX > wRouteIndex)
	{
		wLogSecSum = GetRouteLogSectionSum(wPreRouteId);  /*获取进路包含的逻辑区段信息*/
		pLogSecIdBuff = GetRouteLogSectionIdBuf(wPreRouteId);
		if ((0U < wLogSecSum) && (NULL != pLogSecIdBuff))
		{
			for (ii = 0U; ii < wLogSecSum; ii++)
			{
				cCurRouteLockState = GetLogSecLockState(pLogSecIdBuff[ii]);  /*获取当前进路锁闭状态*/
				cCurRouteLockDir = GetLogSecLockDir(pLogSecIdBuff[ii]);
				wValidRouteId = GetLogSecLockBelongRoute(pLogSecIdBuff[ii]);
				cCurLogLockState = GetLogSecLogLockState(pLogSecIdBuff[ii]);
				cCurLogLockDir = GetLogSecLogLockDir(pLogSecIdBuff[ii]);

				if (((LOG_SECTION_LOCK_NORMAL == cCurRouteLockState) || (LOG_SECTION_LOCK_DELAY == cCurRouteLockState) || (LOG_SECTION_LOCK_EXCEPT == cCurRouteLockState))
					&& (wPreRouteId == wValidRouteId) && (LOG_SECTION_LOGLOCK_NORMAL == cCurLogLockState) && (cCurRouteLockDir != cCurLogLockDir))
				{
					/*当前逻辑区段被原进路锁闭且被其它逻辑进路锁闭且锁闭方向相反，考虑为逻辑进路冲跨控区进路场景，清除原进路的锁闭状态*/
					cResTrainSum = GetLogSecTrainInfoSum(pLogSecIdBuff[ii]);
					pstLgcResInfo = GetLogSecTrainInfo(pLogSecIdBuff[ii]);
					if (NULL != pstLgcResInfo)
					{
						(void)ComMemCopy(pstLgcResInfo, stTmpResInfo, (UINT16)(sizeof(LogicTrainResStruct) * LOGIC_SECTION_RES_SUM_MAX));
						SetLogSecLockState(pLogSecIdBuff[ii], LOG_SECTION_LOCK_NO, wValidRouteId, 0U);  /*设置区段锁闭所属之前进路未锁闭*/

						CpyLgcSecResTrain(pLogSecIdBuff[ii], cResTrainSum, stTmpResInfo);  /*拷贝逻辑区段列车资源信息*/
					}
					else
					{
						/*获取数据失败，不处理*/
					}
				}
				else
				{
					/*不处理*/
				}
			}
		}
		else
		{
			/*获取进路包含的逻辑区段信息失败，不处理*/
		}
	}
	else
	{
		/*入参非法，不处理*/
	}
}

/*
* 功能描述：逻辑进路清除跨控区进路物理区段锁闭处理
* 参数说明：const UINT16 wPreRouteId  原进路ID
* 返 回 值： 无
* Created By LQ 2025.03.10
*/
void LogRouteCleanOldPhySecLockProc(const UINT16 wPreRouteId)
{
	UINT16 wRouteIndex = 0U;
	UINT8 cPhySecSum = 0U;  /*进路包含的物理区段总数*/
	RoutePhysicalSectionStruct* pPhySecDataStru = NULL;  /*进路包含的物理区段结构体指针*/
	UINT8 ii = 0U;
	UINT8 cCurPhySecRLockState = 0U;  /*物理区段当前进路锁闭状态*/
	UINT16 wPhySecRLockRouteId = 0U;  /*物理区段进路锁闭所属进路ID*/
	UINT16 wValidRouteId = 0U;  /*需要处理有效进路ID*/
	UINT8 cPhyIncLgcSecSum = 0U;  /*物理区段包含的逻辑区段数量*/
	UINT16* pPhyIncLgcSecBuf = NULL;  /*物理区段包含的逻辑区段ID*/
	UINT8 jj = 0U;
	UINT8 cCurLogSecRLockState = 0U;  /*逻辑区段当前进路锁闭状态*/
	UINT16 wLgcRLockRouteId = 0U;  /*逻辑区段进路锁闭所属进路ID*/

	wRouteIndex = GetRouteConfigBufIndex(wPreRouteId);  /*获取进路数组下标*/

	if (ROUTE_SUM_MAX > wRouteIndex)
	{
		cPhySecSum = GetRoutePhysicalSectionSum(wPreRouteId);  /*获取进路物理区段总数*/
		pPhySecDataStru = GetRouteSectionData(wPreRouteId);  /*获取进路物理区段数据*/

		if ((0U < cPhySecSum) && (NULL != pPhySecDataStru))
		{
			for (ii = 0U; ii < cPhySecSum; ii++)
			{
				cCurPhySecRLockState = GetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId);  /*获取区段当前锁闭状态*/
				wPhySecRLockRouteId = GetPhySecRLockBelongRouteId(pPhySecDataStru[ii].PhysicalSectionId);  /*获取物理区段锁闭所属进路ID*/

				if (((PHYSICAL_SECTION_LOCK_NORMAL == cCurPhySecRLockState) || (PHYSICAL_SECTION_LOCK_DELAY == cCurPhySecRLockState) || (PHYSICAL_SECTION_LOCK_EXCEPT == cCurPhySecRLockState))
					&& (wPreRouteId == wPhySecRLockRouteId))
				{
					/*物理区段被原进路正常锁闭||延时解锁||故障锁闭，检查物理区段包含的逻辑区段是否未锁闭*/
					cPhyIncLgcSecSum = GetPhySecIncLogSecSum(pPhySecDataStru[ii].PhysicalSectionId);
					pPhyIncLgcSecBuf = GetPhySecIncLogSecIdBuf(pPhySecDataStru[ii].PhysicalSectionId);
					if ((0U < cPhyIncLgcSecSum) && (NULL != pPhyIncLgcSecBuf))
					{
						for (jj = 0U; jj < cPhyIncLgcSecSum; jj++)
						{
							cCurLogSecRLockState = GetLogSecLockState(pPhyIncLgcSecBuf[jj]);
							wLgcRLockRouteId = GetLogSecLockBelongRoute(pPhyIncLgcSecBuf[jj]);
							if ((LOG_SECTION_LOCK_NO == cCurLogSecRLockState) && (0U == wLgcRLockRouteId))
							{
								/*区段未锁闭，继续遍历检查*/
							}
							else
							{
								break;
							}
						}

						if (jj == cPhyIncLgcSecSum)
						{
							SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, wPreRouteId, 0U);  /*设置区段未锁闭*/
						}
						else
						{
							/*不处理*/
						}

						wValidRouteId = wPhySecRLockRouteId;
					}
					else
					{
						/*不处理*/
					}
				}
				else
				{
					;
				}
			}

			if ((0U < wValidRouteId) && (wValidRouteId == wPreRouteId))
			{
				/*处理本次进路办理冲掉的进路*/
				for (ii = 0U; ii < cPhySecSum; ii++)
				{
					wPhySecRLockRouteId = GetPhySecRLockBelongRouteId(pPhySecDataStru[ii].PhysicalSectionId);
					if (wPreRouteId == wPhySecRLockRouteId)
					{
						break;
					}
					else
					{
						;
					}
				}

				if (ii == cPhySecSum)
				{
					(void)SetRouteState(wPreRouteId, ROUTE_STATE_IDLE);
					/*取消进路关联防护道岔的防护锁闭*/
					SetRouteRelProSwitchLockSta(wPreRouteId, SWITCH_LOCK_PROTECT_CANCEL);
				}
				else
				{
					(void)SetRouteState(wPreRouteId, ROUTE_STATE_HALF_UNLOCK);  /*当前进路存在物理区段锁闭，设置进路状态为部分进路等待解锁*/
				}
			}
			else
			{
				; /*不处理*/
			}
		}
		else
		{
			/*获取数据失败，不处理*/
		}
	}
	else
	{
		/*入参非法，不处理*/
	}
}

/*
* 功能描述：跨控区部分进路清除逻辑进路处理
* 参数说明：const UINT16 wCurRouteId 当前进路ID
* 返 回 值： 无
* Created By LQ 2025.03.10
*/
void OtherPartRouteCleanLogRouteProc(const UINT16 wCurRouteId)
{
	UINT16 wRouteIndex = 0U;
	UINT16 wLogSecSum = 0U;  /*进路包含的逻辑区段数量*/
	UINT16* pLogSecIdBuff = NULL;  /*进路包含的逻辑区段ID*/
	UINT8 ii = 0U;
	UINT8 cCurRouteLockState = 0U;  /*逻辑区段当前进路锁闭状态*/
	UINT8 cCurRouteLockDir = 0U;  /*逻辑区段当前进路锁闭方向*/
	UINT16 wCurRLockRouteId = 0U;  /*当前锁闭的进路ID*/
	UINT8 cCurLogLockState = 0U;  /*逻辑区段当前逻辑进路锁闭状态*/
	UINT8 cCurLogLockDir = 0U;  /*逻辑区段当前逻辑进路锁闭方向*/
	UINT8 LogSecLockBelLogRouteSum = 0U;
	LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*逻辑区段锁闭所属逻辑进路数据*/
	UINT16 wValidRouteId = 0U;  /*需要处理的进路ID*/
	UINT8 cFuncRet = CI_ERROR;
	UINT16 LogicalRouteInLogSecSum = 0U;
	UINT16* wLogicalRouteInLogSecIdBuf = NULL;
	UINT16 jj = 0U;
	UINT8 LogLockBelLogRouteSum = 0U;
	LogSecLockBelLogRouteStruct* pstLogLockBelLogRouteData = NULL;
	UINT8 kk = 0U;

	wRouteIndex = GetRouteConfigBufIndex(wCurRouteId);  /*获取进路数组下标*/

	if (ROUTE_SUM_MAX > wRouteIndex)
	{
		wLogSecSum = GetRouteLogSectionSum(wCurRouteId);  /*获取进路包含的逻辑区段信息*/
		pLogSecIdBuff = GetRouteLogSectionIdBuf(wCurRouteId);
		if ((0U < wLogSecSum) && (NULL != pLogSecIdBuff))
		{
			for (ii = 0U; ii < wLogSecSum; ii++)
			{
				cCurRouteLockState = GetLogSecLockState(pLogSecIdBuff[ii]);  /*获取当前进路锁闭状态*/
				cCurRouteLockDir = GetLogSecLockDir(pLogSecIdBuff[ii]);
				wCurRLockRouteId = GetLogSecLockBelongRoute(pLogSecIdBuff[ii]);
				cCurLogLockState = GetLogSecLogLockState(pLogSecIdBuff[ii]);
				cCurLogLockDir = GetLogSecLogLockDir(pLogSecIdBuff[ii]);
				LogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(pLogSecIdBuff[ii]);
				szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(pLogSecIdBuff[ii]);

				if ((LOG_SECTION_LOCK_NORMAL == cCurRouteLockState)	&& (wCurRouteId == wCurRLockRouteId) && (LOG_SECTION_LOGLOCK_NORMAL == cCurLogLockState)
					&& (cCurRouteLockDir != cCurLogLockDir) && (1U == LogSecLockBelLogRouteSum) && (NULL != szLogSecLockBelLogRouteData))
				{
					/*逻辑区段被当前进路锁闭且被逻辑进路反方向锁闭且锁闭的逻辑进路数量为1，则可清除逻辑区段的逻辑锁闭状态*/
					wValidRouteId = szLogSecLockBelLogRouteData[0U].wLogSecLockBelLogRouteId;
					SetLogSecLogLockState(pLogSecIdBuff[ii], LOG_SECTION_LOGLOCK_NO, szLogSecLockBelLogRouteData[0U].wLogSecLockBelLogRouteDir);  /*清除逻辑区段的逻辑锁闭状态*/
					
					cFuncRet = DelLogSecBelongLogRouteId(pLogSecIdBuff[ii], wValidRouteId);  /*清除逻辑区段锁闭的所属进路*/

					if (CI_SUCCESS == cFuncRet)
					{
						LogicalRouteInLogSecSum = GetLogicalRouteInLogSecSum(wValidRouteId);
						wLogicalRouteInLogSecIdBuf = GetLogicalRouteInLogSecId(wValidRouteId);
						if ((0U < LogicalRouteInLogSecSum) && (NULL != wLogicalRouteInLogSecIdBuf))
						{
							for (jj = 0U; jj < LogicalRouteInLogSecSum; jj++)
							{
								LogLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogicalRouteInLogSecIdBuf[jj]);
								pstLogLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogicalRouteInLogSecIdBuf[jj]);

								if (NULL != pstLogLockBelLogRouteData)
								{
									/*确定当前逻辑进路是否还存在锁闭*/
									for (kk = 0U; kk < LogLockBelLogRouteSum; kk++)
									{
										if (wValidRouteId == pstLogLockBelLogRouteData[kk].wLogSecLockBelLogRouteId)
										{
											break;  /*逻辑区段被本逻辑进路逻辑锁闭，停止遍历*/
										}
									}
								}

								if (kk != LogLockBelLogRouteSum)
								{
									break;	/*进路中还存在本逻辑进路逻辑锁闭，不可以将此进路置为空闲，需要最后车释放*/
								}
								else
								{
									/*继续检查*/
								}
							}

							if (jj == LogicalRouteInLogSecSum)
							{
								/*逻辑进路中所有逻辑区段都已未锁闭，已经是逻辑进路的最后一个逻辑区段，设置该逻辑进路空闲，其余的等车释放*/
								SetLogRouteStateManage(wValidRouteId, ROUTE_LOGICAL_STATE_IDLE);
							}
							else
							{
								/*存在逻辑区段锁闭，不解锁逻辑进路*/
							}
						}
						else
						{
							/*不处理*/
						}
					}
					else
					{
						/*不处理*/
					}
				}
				else
				{
					/*不处理*/
				}
			}
		}
		else
		{
			/*获取进路包含的逻辑区段信息失败，不处理*/
		}
	}
	else
	{
		/*入参非法，不处理*/
	}
}

/*
* 功能描述：处理OC->CI的PSD数据
* 参数说明： void
* 返回值  ： void
*/
void ProcessOCToCiPsdData(void)
{
	UINT8 deviceOcSum = 0u;/*通信oc总数*/
	UINT8* deviceIdBuf = NULL;/*通信设备ID数组*/
	UINT8 ocId = 0u;
	UINT8 deviceSum = 0u;/*oc发送psd设备总数*/
	UINT16 ocToCiPsdId = 0u;/*psd id*/
	UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT16 kk = 0u;
	UINT8 findOcFlag = 0u;

	deviceOcSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_OC);     /*获取通信OC设备总数*/
	deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC); /*获取通信OC设备ID数组*/
	
	for (ii = 0u; ii < deviceOcSum; ii++)
	{/*找到OC id*/
		findOcFlag = 0u;
		ocId = deviceIdBuf[ii];
		if ((0u < ocId) && (OC_SUM_MAX > ocId))
		{
			for (kk = 0u; kk < m_OcToCiOrginDataNum; kk++)
			{
				/*找到OC id对应的数组下标kk*/
				if (m_OcToCiOrginDataArr[kk].OcId == ocId)
				{
					findOcFlag = 1u;
					break;
				}
			}
			if (1u == findOcFlag)
			{
				deviceSum = m_OcToCiOrginDataArr[kk].OCPsdNum;     /*获取OC发的PSD设备总数*/
				for (jj = 0u; jj < deviceSum; jj++)
				{
					ocToCiPsdId = m_OcToCiOrginDataArr[kk].PsdInfo[jj].wPsdId;	/*psd id*/
					if (0u < ocToCiPsdId)
					{
						/*屏蔽门开关状态更新*/
						if (PSD_STATE_CLOSE_VIETNAM == m_OcToCiOrginDataArr[kk].PsdInfo[jj].OpenOrCloseState)
						{
							/*关门*/
							(void)SetPsdState(ocToCiPsdId, PSD_STATE_CLOSE);
						}
						else if (PSD_STATE_OPEN_VIETNAM == m_OcToCiOrginDataArr[kk].PsdInfo[jj].OpenOrCloseState)
						{
							/*开门*/
							(void)SetPsdState(ocToCiPsdId, PSD_STATE_OPEN);
						}
						else
						{/*屏蔽门开关状态默认开门*/
							(void)SetPsdState(ocToCiPsdId, PSD_STATE_OPEN);
						}

						/*互锁解除状态*/
						if (PSD_MUTUALLOCK_REMOVE_YES == m_OcToCiOrginDataArr[kk].PsdInfo[jj].InterlockRelState)
						{
							/*互锁解除*/
							(void)SetPsdMutualLockRemoveState(ocToCiPsdId, PSD_MUTUALLOCK_REMOVE_YES);
						}
						else if (PSD_MUTUALLOCK_REMOVE_NO == m_OcToCiOrginDataArr[kk].PsdInfo[jj].InterlockRelState)
						{
							/*未互锁解除*/
							(void)SetPsdMutualLockRemoveState(ocToCiPsdId, PSD_MUTUALLOCK_REMOVE_NO);
						}
						else
						{
							(void)SetPsdMutualLockRemoveState(ocToCiPsdId, PSD_MUTUALLOCK_REMOVE_NO);
						}

						/*开门故障状态*/
						SetOpenErrState(ocToCiPsdId, m_OcToCiOrginDataArr[kk].PsdInfo[jj].OpenErrState);

						/*关门故障状态*/
						SetCloseErrState(ocToCiPsdId, m_OcToCiOrginDataArr[kk].PsdInfo[jj].CloseErrState);

						/*单扇门故障隔离信息*/
						SetPsdFaultQState(ocToCiPsdId, m_OcToCiOrginDataArr[kk].PsdInfo[jj].psdFaultQStataOne, m_OcToCiOrginDataArr[kk].PsdInfo[jj].psdFaultQStataTwo);

						/*单扇门开关状态*/
						SetPsdDoorState(ocToCiPsdId, m_OcToCiOrginDataArr[kk].PsdInfo[jj].psdDoorsStateOne, m_OcToCiOrginDataArr[kk].PsdInfo[jj].psdDoorsStateTwo);

						/*单扇门被隔离信息*/
						SetPsdDoorIState(ocToCiPsdId, m_OcToCiOrginDataArr[kk].PsdInfo[jj].psdDoorIStateOne, m_OcToCiOrginDataArr[kk].PsdInfo[jj].psdDoorIStateTwo);

						/*障碍物报警状态（预留）*/
					}
					else
					{
						/*psd id无效，不处理*/
					}
				}
			}
		}
		else
		{
			/*oc id无效，不处理*/
		}
	}
	
}


/*
* 功能描述： 处理OC到CI的不一致继电器数据
* 参数说明： void
* 返回值  ： 0:处理失败
*			 1:处理成功
*/
void ProcessOcToCiRelayDiffData(void)
{
	UINT8 i = 0u;
	UINT8 j = 0u;
	UINT8 k = 0u;
	UINT16 ocId = 0u;
	CollBoardData* pTempCollBoardData_ForProcess = NULL;
	UINT8 BoardAddress_ForProcess = 0u;								/*板卡地址*/
	UINT8 BoardAddress_ForProcessOther = 0u;						/*对系板卡地址*/
	UINT8 cBoardState = RELAY_BOARD_FAULT_YES;						/*板卡状态初始化为故障*/
	UINT8 cBoardStateOther = RELAY_BOARD_FAULT_YES;					/*对系板卡状态初始化为故障*/
	UINT8 PosValue_ForProcess = 0u;									/*采集继电器当前地址的采集点数值:吸起、落下*/
	UINT8 PosValue_ForProcessOther = 0u;							/*采集继电器对系地址的采集点数值:吸起、落下*/
	UINT32 pointTolerateCyc = 0u;									/*点位不一致容忍周期*/
	UINT8 timeState = 0U;
	UINT32 curCycNum = 0u;

	IODiffDataStruct* pTempIODiffData = NULL;				 /*记录点位采集不一致*/
	curCycNum = Get2oo2CurCycleNum();

	(void)CommonMemSet(&IODiffDataStru, (UINT32)((OC_SUM_MAX) * sizeof(IODiffDataStruct)), 0U, (UINT32)((OC_SUM_MAX) * sizeof(IODiffDataStruct)));		/*先清空结构体*/
	gDiffDataOcNum = 0u;

	pTempIODiffData = GetIODiffData();
	if (NULL != pTempIODiffData)
	{
		for (i = 0u; i < OC_SUM_MAX; i++)                        /*指定ID继电器所属联锁ID*/
		{
			if (LocalOcIds[i] > 0u)/*oc id 有效*/
			{
				ocId = LocalOcIds[i];
				if (OC_SUM_MAX > ocId)
				{
					pTempCollBoardData_ForProcess = m_OcConvertedPtDataArr[ocId].BoardDatas;
					for (j = 0u; j < m_OcConvertedPtDataArr[ocId].OcBoardNum; j += 2u)/*遍历所有的OC板卡*/
					{
						BoardAddress_ForProcess = pTempCollBoardData_ForProcess[j].BoardAddress;/*板卡地址*/
						BoardAddress_ForProcessOther = pTempCollBoardData_ForProcess[j + 1u].BoardAddress;/*对系板卡地址*/

						cBoardState = pTempCollBoardData_ForProcess[j].BoardState;  /*板卡状态*/
						cBoardStateOther = pTempCollBoardData_ForProcess[j + 1u].BoardState;  /*对系板卡状态*/

						if ((RELAY_BOARD_FAULT_NO == cBoardState)&&(RELAY_BOARD_FAULT_NO == cBoardStateOther))
						{	
							/*板卡非故障*/
							for (k = 0u; k < (UINT8)OC_COLL_BOARD_POS_NUM; k++)
							{
								PosValue_ForProcess = pTempCollBoardData_ForProcess[j].PosValueBuf[k];/*点值：吸起、落下*/
								PosValue_ForProcessOther = pTempCollBoardData_ForProcess[j + 1u].PosValueBuf[k];/*对系板卡的点值*/

								if (PosValue_ForProcess != PosValue_ForProcessOther)
								{
									/*不一致进行容忍*/
									pointTolerateCyc = GetPointTolerateCycNum(ocId, j, k);/*该点位容忍周期*/
									timeState = SystemOverTimeCheck(pointTolerateCyc, POINTTOLERATE_CYCNUM);
									if (CI_TIME_NO == timeState) /*未计时，无容忍*/
									{/*设置当前周期*/
										SetPointTolerateCycNum(ocId, j, k, curCycNum);
										debug_infor_printf((const)"IO Compare Diff Tolerate CycleNum = %d\n", curCycNum);
									}
									else if (CI_TIME_IN == timeState)/*容忍中*/
									{/*不处理*/
									}
									else
									{
										/*点位采集不一致容忍超时，记录*/
										pTempIODiffData[i].OcId = (UINT8)ocId;	/*OC ID*/
										pTempIODiffData[i].LocalBoardAdd[pTempIODiffData[i].DiffPointNum] = BoardAddress_ForProcess;/*点位对应的板卡地址*/
										pTempIODiffData[i].OtherBoardAdd[pTempIODiffData[i].DiffPointNum] = BoardAddress_ForProcessOther;/*对系板卡地址*/
										pTempIODiffData[i].TheDiffPoint[pTempIODiffData[i].DiffPointNum] = k + 1u;/*不一致的点位*/
										pTempIODiffData[i].DiffPointNum++;		/*点位数量*/
									}
								}
								else
								{/*该点位采集一致，清除容忍周期*/
									SetPointTolerateCycNum(ocId, j, k, 0u);
								}
							}
						}
						else
						{
							/*板卡是故障，不记录，清除每个点位容忍周期*/
							for (k = 0u; k < (UINT8)OC_COLL_BOARD_POS_NUM; k++)
							{
								SetPointTolerateCycNum(ocId, j, k, 0u);
							}
						}
					}


					if (0u != pTempIODiffData[i].DiffPointNum)
					{/*该OC有点位不一致，不一致的OC数量加一*/
						gDiffDataOcNum++;
					}
				}
			}
		}
	}
	else
	{/*不处理*/
	}
	
}