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


#include "OutputDataProcess.h"
#include "../LogicProcess/InterlockLogicCheck.h"
#include "../ParsePack/ParsePackPSCData.h"
#include "InterlockLogicManage.h"
#include "../DataManage/PlatDataManage.h"
#include "../ParsePack/ParsePackVobcData.h"
#include "HLHTHeadContexManage.h"
#include "../EnvelopeManage/EnvelopeManageAPI.h"
#include "../RemoteRM/RRMDataPrepare.h"
#include "NonAutoReturnDataManage.h"
#include "InputDataProcess.h"



/*
* 功能描述： 照查状态指示灯关联物理区段检查
* 参数说明： UINT16 phySecId    物理区段ID 
*   
* 返回值  ：    CI_SUCCESS  成功
CI_ERROR    失败
*/
UINT8 ZhaoChaIndictorRelPhySecCheck(UINT16 phySecId);

/*
* 功能描述： 照查状态指示灯状态处理
* 参数说明： UINT16 indicatorId    指示灯ID 
*   
* 返回值  ：    
*/
void SetZhaoChaIndictorComSta_Vir(UINT8 virCIid,UINT8 indicatorId);

/*
* 功能描述： 联锁站控模式指示灯设置
* 参数说明： void
* 返回值  ： void   
*/
void SetCiModeIndicatorState_Vir(UINT8 virCIid,UINT8 indicatorId);

/*
* 功能描述： 根据试车线联锁试车状态驱动继电器
* 参数说明： void
* 返回值  ： 0: 更新失败
*			 1: 更新成功
*/
UINT8 TrainTestStatusToDevStateProc(void);

/*
* 功能描述： 根据无人折返指示灯的闪灯和稳灯状态驱动继电器或设置状态
* 参数说明： 无
* 返回值  ： 无
*/
static void AutoRtnIndictStaToDevStateProc(void);

/*
* 功能描述： 处理输出数据
* 参数说明： void
* 返回值  ： void      
*/
void OutputDataProcess(void)
{
	UINT8 retVal = CI_ERROR;
    UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 CiPattern = 0u;
	UINT8 chDsnLinSwitch = 0U;
	UINT8 chTiocSysMode = 0U;

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

	if (REVERSE_MODE_MAIN != chTiocSysMode)
	{
		/*将信号机、道岔、屏蔽门驱动清空，其他设备迪斯尼不涉及*/
		TiocSysShadowDeviceOutputProc();
	}
	if (CI_PATTERN_TRADITIONAL == CiPattern)
	{/*传统联锁*/
		/*更新道岔继电器状态*/
		SwitchDeviceToRelayStateProc();

		/*更新信号机继电器状态*/
		SignalDeviceToRelayStateProc();
	}
	else if (CI_PATTERN_FULL_ELECTRONIC == CiPattern)
	{
		if (FUNC_SWITCH_ON == chDsnLinSwitch)
		{
			/*迪斯尼线路使用继电器控制信号机与道岔*/
			/*更新道岔继电器状态*/
			SwitchDeviceToRelayStateProc();

			/*更新信号机继电器状态*/
			SignalDeviceToRelayStateProc();
		}
		else
		{
			/*驱动复示信号机显示*/
			DriveFushiSignal();

			/*道岔输出处理*/
			OcSwitchDeviceOutput();

			/*信号机输出处理*/
			OcSignalDeviceOutput();
		}
		/*spks指示灯输出处理*/
		SpksDisplayDrivOutput();

		/*esb指示灯输出处理*/
		EsbDisplayDrivOutput();

		/*esb稳灯、闪灯和蜂鸣器驱动输出处理*/
		EsbRelateDelayDriveOutputProc();

		/*门禁解锁继电器驱动输出处理*/
		SpksMenjinJSDrivOutput();

		/*扣车指示灯输出处理*/
		DetainDisplayDrivOutput();
	
		/*计轴总复位表示灯驱动*/
		PhyZFWBsRelayDriveOutput();
		/*更新联络线设备逻辑状态至继电器驱动状态*/
		UpdateConnectDriveRelayOutput();

		/*声光报警器输出处理*/
		SGBJDriveOutputProc();
	}
	else
	{
		/*无操作*/
	}
	/*更新屏蔽门继电器状态*/
	(void)PsdDeviceToRelayStateProc();

	/*更新洗车机继电器状态*/
	(void)WashMachineDevToRelayStaProc();

	/*更新计轴复位继电器状态*/
	if(FUNC_SWITCH_ON == includeVirFlag)
	{	/*虚拟联锁兼容*/
		UpDataAllPhySecResetRelay_VirCI();
	}
	else
	{
		PhySecResetToRelayStateProc();
	}

	/*非进路继电器状态处理*/
	NonRouteRelayStateProc();

	/* 车库门继电器状态 */
	GaragedoorDevToRelayStaProc();

	/*处理防淹门继电器状态*/
	FloodGateDeviceToRelayStateProc();

	/*处理进路调车同意继电器状态*/
	RouteDCTYToRelayStateProc();

	/* 试车线 试车请求继电器输出 */
	retVal = TrainTestStatusToDevStateProc();
	if (CI_ERROR == retVal)
	{
		/*错误处理，暂时不做处理*/
	}
	else
	{
		;
	}
	/*指示器状态处理*/
	if(FUNC_SWITCH_ON == includeVirFlag)
	{/*配置虚拟联锁，使用本函数*/
		AutoRtnIndictStatusProc_VirCI();
	}
	else
	{
		/*无人折返灯的闪灯稳灯状态处理*/
		AutoRtnIndictStaToDevStateProc();
	}

	/*无人折返继电器粘连状态处理*/
	RtnRealyAdhesionStatePro();

	/*虚拟设备输出处理*/
	VirtualDeviceOutputProc();
	

	/*指示器状态处理*/
	if(FUNC_SWITCH_ON == includeVirFlag)
	{/*虚拟联锁兼容*/
		OutPutIndicatorState_UseVirCI();
	}
	else
	{
		IndicatorStateProc();
		OcStationIndicStateProc();
	}

	CiToCiOutputCmdProc();

	CutoffPointOutput();

	/*CI到ATS反馈信息处理*/
	CiToAtsBackInfoProcess();

	/*更新故障锁闭照查驱动*/
	UpdateFaultLockZhaoChaDrive();
	/*更新照查联锁条件检查照查驱动*/
	UpdateZhaoChaCheckZhaoChaDrive();

	/*设置驱动继电器混线状态*/
	SetDriveRelayHunXianState();

	/*列车包络数据处理*/
	UpdateTrainEnvelope();

	/*后备列车发送数据处理*/
	VobcBackUpOutputProcess();
}

/*
* 功能描述： CI到ATS反馈信息处理
* 参数说明： void
* 返回值  ：    
*/
void CiToAtsBackInfoProcess(void)
{
	/*错误码数据处理*/
	ErrorCodeDataProcess();  

	/*倒计时信息处理*/
	TimeDataFeedBackProcess();

	/*PSD超时报警处理*/
	PsdDriveOutTimeToAts();

	/*给反馈信息统一添加虚拟联锁ID或者本地联锁ID*/
	AddCiSendBackDataCIid();
}


/*
* 功能描述： 错误码数据处理
* 参数说明： void
* 返回值  ：    
*/
void ErrorCodeDataProcess(void)
{
	UINT16 errorCodeCurSum = 0u;  /*错误码总数目*/
	UINT8 backInfoParam = 0u;  /*反馈信息参数*/
	ErrorDataStruct* errorCodeStu = NULL; /*错误码数据*/
	UINT16 ii = 0u;  /*循环索引*/
	UINT8 errorCodeData[RECORD_BUF_MAX] = {0};/*打印错误码数据缓冲7为错误码结构大小*/
	UINT16 errorCodeDataLen = 0u;

	errorCodeCurSum = GetErrorDataCurSum();  /*获取错误码总数*/

	/*处理错误码*/
	for (ii = 0u; ii < errorCodeCurSum; ii++)
	{

		errorCodeStu = GetErrorData(ii);  /*获取错误码数据*/

		if (errorCodeStu != NULL)
		{
			if (CI_SUCCESS == CiToAtsBackInfoFunctionJudge(errorCodeStu->FunctionId,errorCodeStu->DeviceType))
			{ /*需反馈至ATS*/

				/*获取ATS反馈信息参数*/
				backInfoParam = GetAtsBackInfoParam(errorCodeStu->FunctionId,errorCodeStu->DeviceStateType, errorCodeStu->DeviceState);

				if ((backInfoParam > 0u) && (errorCodeStu->SendLevel == ESEND_LEVEL_ATS))
				{
					errorCodeDataTransCmdBack(backInfoParam, errorCodeStu->DeviceType, errorCodeStu->DeviceId, errorCodeStu->VirCIid);
				}
#ifdef LOGPRINT/*日志打印宏*/


				if (RECORD_BUF_MAX > errorCodeDataLen + 8U)
				{
					errorCodeData[errorCodeDataLen++] = errorCodeStu->FunctionId;
					errorCodeData[errorCodeDataLen++] = errorCodeStu->DeviceType;
					ShortToChar(errorCodeStu->DeviceId, &errorCodeData[errorCodeDataLen]);
					errorCodeDataLen += 2U;
					errorCodeData[errorCodeDataLen++] = errorCodeStu->DeviceStateType;
					errorCodeData[errorCodeDataLen++] = errorCodeStu->DeviceState;
					errorCodeData[errorCodeDataLen++] = errorCodeStu->SendLevel;
					errorCodeData[errorCodeDataLen++] = errorCodeStu->VirCIid;
				}

#endif
			}
		}
		else
		{
		}
	}
#ifdef LOGPRINT/*日志打印宏*/
#ifdef PLATFORM_2OO2/*2oo2平台打印*/

	if (errorCodeDataLen > 0U)
	{
		debug_infor_printf((const)"\nErrorCode:%d\nFunctionId-DeviceType-DeviceId(2)-DeviceStateType-DeviceState-SendLevel-virCIid\n",errorCodeDataLen);
		debug_out_array(0xAA,errorCodeData,errorCodeDataLen);
	}

#endif/*平台打印结束*/

#endif
}



/*
* 功能描述： 获取ATS反馈信息参数
* 参数说明： 
*			 const UINT8 functionId，	  函数id
*            const UINT8 deviceStateType, 设备状态类型
*            const UINT8 deviceState, 设备状态
* 返回值  ： 0: 获取失败
*			>0: 获取成功   
*/
UINT8 GetAtsBackInfoParam(const UINT8 functionId,const UINT8 deviceStateType, const UINT8 deviceState)
{
	UINT8 returnValue = 0u;/*返回值*/
	switch (deviceStateType)
	{
		/*进路故障反馈*/
	case ETYPE_ROUTE_LEVEL:
		if (ROUTE_LEVEL_CBTC==deviceState  )
		{
			returnValue = CI_BACK_ROUTE_LEVEL_CBTC;   /*进路监督级别不为点式*/
		}
		else
		{
			returnValue = CI_BACK_ROUTE_LEVEL_BLOC;   /*进路监督级别不为CBTC*/
		}
		break;

	case ETYPE_ROUTE_TYPE:
		returnValue = CI_BACK_ROUTE_TYPE_ERROR;   /*进路类型异常*/
		break;

	case ETYPE_ROUTE_STATE:
		if (EFUNC_ROUTE_ZRJ_DEAL == functionId)
		{
			returnValue = CI_BACK_ROUTE_UNLOCK_FAIL;/*进路解锁条件不满足*/
		}
		else
		{
			returnValue = CI_BACK_ROUTE_STATE_ERROR;  /*进路建立条件不满足*/
		}
		break;

	case ETYPE_ROUTE_LEAD_PROPERTY:
		returnValue = CI_BACK_ROUTE_LEAD_ERROR;   /*进路不为引导*/
		break;

	case ETYPE_ROUTE_CANCEL:
		returnValue = CI_BACK_ROUTE_CANCEL;   /*进路已取消*/
		break;

	case ETYPE_ROUTE_OVERLAP_UNLOCK:
		returnValue = CI_BACK_ROUTE_OVERLAP_LOCK_NO;   /*进路保护区段未锁闭*/
		break;

	case ETYPE_ROUTE_OVERLAP_OCCUPY:
		returnValue = CI_BACK_ROUTE_OVERLAP_OCCUPY;   /*进路保护区段占用*/
		break;
	case ETYPE_RETURN_ROUTE_STATE:
		returnValue = CI_BACK_RETURN_ROUTE_STATE_ERROR;/*折返进路不允许追踪办理*/
		break;
	case ETYPE_ROUTE_XUANPAI_OVERTIME:
		returnValue = CI_BACK_ROUTE_XUANPAI_OVERTIME;/*进路选排超时*/
		break;

	case ETYPE_ROUTE_APPLY_SWITCH_MOVE:
		returnValue = CI_BACK_SWT_MOVE;		/*道岔单操中办理进路*/
		break;

		/*信号机故障反馈*/
	case ETYPE_SIG_START_OPEN_STATE:
		if (SIGNAL_OPEN==deviceState  )
		{
			returnValue = CI_BACK_SIG_START_OPEN;   /*进路始端信号机开放*/
		}
		else
		{
			returnValue = CI_BACK_SIG_START_CLOSE;  /*进路始端信号机关闭*/
		}
		break;

	case ETYPE_SIG_FLOCK_STATE:
		if (SIGNAL_FENGSUO_YES==deviceState  )
		{
			returnValue = CI_BACK_SIG_FLOCK_YES;   /*信号机封锁*/
		}
		else if(SIGNAL_FENGSUO_NO == deviceState)
		{
			returnValue = CI_BACK_SIG_FLOCK_NO;  /*信号机未封锁*/
		}
		else
		{
			/*其他情况，返回已封锁*/
			returnValue = CI_BACK_SIG_FLOCK_YES;   /*信号机封锁*/
		}
		break;

	case ETYPE_SIG_ENEMY_STATE:
		returnValue = CI_BACK_SIG_ENEMY_OPEN;   /*进路敌对信号机开放*/
		break;

	case ETYPE_SIG_NEED_CLOSE_STATE:
		returnValue = CI_BACK_SIG_NEED_CLOSE;   /*进路需关闭信号未关闭*/
		break;

	case ETYPE_SIG_NEED_OPEN_STATE:
		returnValue = CI_BACK_SIG_NEED_OPEN;   /*进路需开放信号未开放*/
		break;

	case ETYPE_SIG_ONE_OPEN_STATE:
		returnValue = CI_BACK_SIG_ONE_OPEN;   /*进路不同时开放信号开放*/
		break;

	case ETYPE_SIG_OPEN_OVERTIME:
		returnValue = CI_BACK_SIG_OPEN_OT;   /*信号机开放超时*/
		break;

	case ETYPE_SIG_CLOSE_OVER_TIME:
		returnValue = CI_BACK_SIG_CLOSE_OT;   /*信号机关闭超时*/
		break;

	case ETYPE_SIG_RETURN_OPENED_STATE:
		returnValue = CI_BACK_AS_RETR_ENDSIG_RT_SET;/*以该信号机为终端信号机的折返进路已经办理*/
		break;

	case ETYPE_SIG_LEAD_ALL_LOCK:
		returnValue = CI_BACK_SIG_LEAD_OPEN_FAIL;		/*引导信号开放条件不满足，全站已下发引导总锁*/
		break;

		/*区段故障反馈*/
	case ETYPE_PS_MERGY_OCU_STATE:
		if (SECTION_OCCUPY_YES==deviceState  )
		{
			returnValue = CI_BACK_PSEC_OCU_YES;   /*区段占用*/
		}
		else
		{
			returnValue = CI_BACK_PSEC_OCU_NO;  /*区段空闲*/
		}
		break;

	case ETYPE_PS_LOCK_STATE:
		if (PHYSICAL_SECTION_LOCK_NO==deviceState  )
		{
			returnValue = CI_BACK_PSEC_LOCK_NO;   /*区段未锁闭*/
		}
		else
		{
			returnValue = CI_BACK_PSEC_LOCK_YES;  /*区段锁闭*/
		}
		break;
	case ETYPE_PS_JUMP_LOCK:
		if (PHYSICAL_SECTION_JUMP_LOCK_YES == deviceState)
		{
			returnValue = CI_BACK_PSEC_JUMP_LOCK_YES; /*区段跳跃锁闭*/
		} 
		break;

	case ETYPE_PS_INTRU_OCU_STATE:
		returnValue = CI_BACK_PSEC_INTRU;   /*侵限区段占用*/
		break;

	case ETYPE_PS_RUNLOCK_ERROR:
		returnValue = CI_BACK_PSEC_RUNLOCK_ERROR;   /*折返异常*/
		break;

	case ETYPE_PS_AUNLOCK_ERROR:
		returnValue = CI_BACK_PSEC_AUNLOCK_ERROR;   /*自动解锁异常*/
		break;

	case ETYPE_PS_USE_STATE:
		returnValue = CI_BACK_PSEC_USE;   /*区段已征用*/
		break;

	case ETYPE_PS_FLOCK_STATE:
		if (OTHER_CI_PHYSICAL_FENGSUO_NO == deviceState)
		{
			returnValue = CI_BACK_PSEC_UNFLOCK;   /*区段未封锁*/
		}
		else
		{
			returnValue = CI_BACK_PSEC_FLOCK;   /*区段已封锁*/
		}
		break;

	case ETYPE_PS_UNFLOCK_STATE:
		returnValue = CI_BACK_PSEC_UNFLOCK;   /*区段未封锁*/
		break;

		/*道岔故障反馈*/
	case ETYPE_SWT_YLOCK_STATE:
		if (SWITCH_LOCK_YINZONG_YES==deviceState  )
		{
			returnValue = CI_BACK_SWT_YLOCK_YES;   /*道岔引导总锁*/
		}
		else
		{
			returnValue = CI_BACK_SWT_YLOCK_NO;  /*道岔未引导总锁*/
		}
		break;

	case ETYPE_SWT_FLOCK_STATE:
		if (SWITCH_LOCK_FENGSUO_YES==deviceState  )
		{
			returnValue = CI_BACK_SWT_FLOCK_YES;   /*道岔封锁*/
		}
		else
		{
			returnValue = CI_BACK_SWT_FLOCK_NO;  /*道岔未封锁*/
		}
		break;

	case ETYPE_SWT_LOCK_STATUS:
		if (SWITCH_LOCK_STATUS_DANSUO==deviceState  )
		{
			returnValue = CI_BACK_SWT_DLOCK_YES;   /*道岔单锁*/
		}
		else if (SWITCH_LOCK_STATUS_PROTECT==deviceState  )
		{
			returnValue = CI_BACK_SWT_PLOCK_YES;   /*道岔防护锁闭*/
		}
		else if (SWITCH_LOCK_STATUS_DANSUO_NO==deviceState  )
		{
			returnValue = CI_BACK_SWT_DLOCK_NO;   /*道岔未单锁*/
		}
		else if (SWITCH_LOCK_STATUS_PROTECT_NO==deviceState  )
		{
			returnValue = CI_BACK_SWT_PLOCK_NO;   /*道岔未防护锁闭*/
		}
		else
		{
			returnValue = CI_BACK_SWT_DLOCK_YES;  /*道岔单锁*/
		}
		break;

	case ETYPE_SWT_POSTION_STATE:
		returnValue = CI_BACK_SWT_POS_ERROR;   /*道岔位置错误*/
		break;

	case ETYPE_SWT_MOVE_INVALID:
		returnValue = CI_BACK_SWT_MOVE_VALID;   /*道岔不可动作*/
		break;

	case ETYPE_SWT_MOVE_OVERTIME:
		returnValue = CI_BACK_SWT_MOVE_OT;   /*道岔动作超时*/
		break;

	case ETYPE_SWT_USE_STATE:	/*道岔征用中*/
		{
			if (SWITCH_USING_YES == deviceState)
			{
				returnValue = CI_BACK_SWT_USING;
			}
			
			break;
		}
	case ETYPE_SWT_MOVE_STATE:	/*道岔搬动状态*/
	{
		if (SWITCH_MOVE_FAIL == deviceState)
		{
			returnValue = CI_BACK_SWT_MOVE_ERR;
		}

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

		/*继电器故障反馈*/
	case ETYPE_THAT_ZHAOCHA:
		returnValue = CI_BACK_REL_ZHAOCHA_UP;   /*对端照查继电器吸起*/
		break;
	case ETYPE_THIS_ZHAOCHA:
		returnValue = CI_BACK_REL_ZHAOCHA_UP;   /*本端照查继电器吸起*/
		break;
	case ETYPE_CANCLE_ZHAOCHA:
		returnValue = CI_BACK_CANCEL_ZHAOCHA;   /*取消照查继电器*/
		break;
	case ETYPE_PS_ZHAOCHA_CHECK:		
		returnValue = CI_BACK_PHYSEC_ZHAOCHA;   /*区段照查不满足*/
		break;
	case ETYPE_JKJ_WORK:
		returnValue = CI_BACK_JKJ_VALID;
		break;
		/*站台故障反馈*/
	case ETYPE_ESB_VALID:
		returnValue = CI_BACK_PLA_ESB_ESBVALID;   /*紧急按钮有效*/
		break;

	case ETYPE_PSD_CLOSE_NO:
		returnValue = CI_BACK_PLA_PSD_OPEN;   /*屏蔽门未关闭*/
		break;

	case ETYPE_PSD_MUTUALLOCK:
		returnValue = CI_BACK_PLA_PSD_MUTULLOCK;   /*屏蔽门互锁*/
		break;

	case ETYPE_PLAT_DETAIN:
		returnValue = CI_BACK_PLA_DETAIN;   /*站台扣车*/
		break;

	case ETYPE_WASH_MACHINE_UNVALID:		/* 洗车机未就绪 */
		returnValue = CI_BACK_WASH_MACHINE_UNVALID;
		break;
	case ETYPE_OTHER_GARAGEDOOR_OPEN_NO:	/* 车库门未打开 */
		returnValue = CI_BACK_OTHER_GARAGEDOOR_OPEN_NO;
		break;
	case ETYPE_OTHER_SIGNAL_OPEN_CHECK:	/* 关联信号开放失败 */	
		returnValue = CI_BACK_OTHER_SIGNAL_OPEN_CHECK;
		break;
	case ETYPE_OTHER_SIGNAL_CHECK:	/* 信号机其他联锁条件失败 */
		returnValue = CI_BACK_OTHER_SIGNAL_CHECK;
		break;
	case ETYPE_OTHER_SWITCH_POSITION_ERROR:	/* 道岔不在指定位置 */
		returnValue = CI_BACK_OTHER_SWITCH_POSITION_ERROR;
		break;
	case ETYPE_SPKS_STATE_UP:	/* SPKS按钮按下 */
		returnValue = CI_BACK_SPKS_STATE_UP;
		break;
	case ETYPE_GARAGEDOOR_STATE_MODE_LOCAL:	/* 车库门控制模式为本地 */
		returnValue = CI_BACK_GARAGEDOOR_STATE_MODE_LOCAL;
		break;
	case ETYPE_GARAGEDOOR_FAULT: /* 车库门故障状态 */
		returnValue = CI_BACK_GARAGEDOOR_BAD;
		break;
	case ETYPE_GARDOOR_NOT_RECV_ZC_GMXK: /* 车库门关闭未收到ZC回复的允许关闭许可 */
		returnValue = CI_BACK_GARDOOR_NOT_RECV_ZC_GMXK;
		break;
		/*系统故障*/
	case ETYPE_SYSTEM_SIGNAL_OPEN:
		returnValue = CI_BACK_SYSTEM_SIGNAL_OPEN;   /*未驱动信号机开放*/
		break;

	case ETYPE_SYSTEM_EXCEPT:
		returnValue = CI_BACK_SYSTEM_EXCEPT;   /*联锁系统状态异常*/
		break;

	case ETYPE_SYSTEM_STARTLOCKE_ERROR:
		returnValue = CI_BACK_STARTLOCKE_ERROR;   /*上电解锁失败*/
		break;

	case ETYPE_SYSTEM_REL_UPDATA_ERROR:
		returnValue = CI_BACK_REL_UPDATA_ERROR;   /*继电器更新失败*/
		break;

	case ETYPE_SYSTEM_SIG_UPDATA_ERROR:
		returnValue = CI_BACK_SIG_UPDATA_ERROR;   /*信号机更新失败*/
		break;

	case ETYPE_SYSTEM_SEC_UPDATA_ERROR:
		returnValue = CI_BACK_SEC_UPDATA_ERROR;   /*区段更新失败*/
		break;

	case ETYPE_SYSTEM_SWT_UPDATA_ERROR:
		returnValue = CI_BACK_SWT_UPDATA_ERROR;   /*道岔更新失败*/
		break;

	case ETYPE_LEU_CI_COMM_ALL_STATE_FAULT:
		returnValue = CI_BACK_LEU_ALL_STATE__FAULT;	  /*LEU与CI通信整机状态故障报警*/
		break;

	case ETYPE_LEU_CI_COMM_CHANNEL_SWITCH_FAULT:
		returnValue = CI_BACK_LEU_CHANNEL_SWITCH_FAULT;	  /*LEU与CI通道切换报警*/
		break;

	case ETYPE_COMM_WITH_VOBC:
	case ETYPE_COMM_WITH_ZC:
	case ETYPE_COMM_WITH_CI:
	case ETYPE_COMM_WITH_TMC:
		returnValue = deviceState;                        /*VOBC、ZC、CI、TMC与CI通信失败报警*/
		break;
	case ETYPE_COMM_WITH_NEIGHBOUR_CI:
		returnValue = CI_BACK_COMM_CI_GOOD;/*与相邻联锁通信都正常*/
		break;

	case ETYPE_OTHER_WASH_LINE_NOT_ALLOW:
		returnValue = CI_BACK_WASH_LINE_ALLOW_NOT;			/*联锁条件不满足：洗车线未同意洗车*/
		break;

	case ETYPE_FLOODGATE_OPENLOCKSTATE:/*设备状态类型：开启锁闭*/
		returnValue = CI_BACK_FLOOD_GATE_CLOSE;
		break;
	case ETYPE_FLOODGATE_CLOSEREQSTATE:/*设备状态类型：关门请求*/
		returnValue = CI_BACK_FLOOD_GATE_REQ_CLOSE;
		break;
	case ETYPE_FLOODGATE_AGREECLOSESTATE:/*设备状态类型：同意关闭*/
		returnValue = CI_BACK_FLOOD_ALLOW_CLOSE;
		break;
	case ETYPE_FLOODGATE_CLOSESTATE:/*防淹门关门状态错误-其他联锁条件使用*/
		if (FLOOD_GATE_REQ_CLOSE == deviceState)
		{
			returnValue = CI_BACK_FLOOD_GATE_REQ_CLOSE;
		}
		else if (FLOOD_GATE_ALLOW_CLOSE == deviceState)
		{
			returnValue = CI_BACK_FLOOD_ALLOW_CLOSE;
		}
		else
		{
			returnValue = CI_BACK_FLOOD_GATE_CLOSE;
		}
		break;
		
	case ETYPE_SIG_ENDSIGNAL_DS:/*信号机断丝错误*/
		{
			if (SIGNAL_SHOWCOLOUR_REDBREAK == deviceState)
			{
				returnValue = CI_BACK_ROUTE_END_SIGNAL_REDBREAK;
			} 
			else
			{
			}
		}
		break;

	case ETYPE_DCTY_NOT_SATIFY:/*调车同意不满足*/
		{
			returnValue = CI_BACK_DCTY_NOT_SATISFY;
		}
		break;
	case ETYPE_DCTY_REOPEN_TIMING_BREAK:/*因其它开放条件不满足，调车同意重开计时中断*/
		{
			returnValue = CI_BACK_DCTY_REOPEN_TIMING_BREAK;
		}
		break;
	case ETYPE_TRAIN_TEST_OFF:/*未进入试车模式，命令无效*/
		{
			returnValue = CI_BACK_TRAIN_TEST_OFF;
		}
		break;
	case ETYPE_DCTY_REOPEN_TIMEOUT:/*进路XX等待调车同意超时*/
		{
			returnValue = CI_BACK_DCTY_REOPEN_TIMEOUT;
		}
		break;
	case ETYPE_FLOOD_GATE_YGJ_CROSS_LINE:/*防淹门YGJ混线报警*/
		{
			returnValue = CI_BACK_FLOOD_GATE_YGJ_CROSS_LINE;
		}
		break;
	case ETYPE_COMM_WITH_PSC: /*CI与PSC通信正常*/
		{
			returnValue = CI_BACK_CIPSC_GOOD;
		}
		break;
	case ETYPE_PSC_CONFIRM_PL_STATE: /*PSC对应站台门没有设置旁路标志*/
		{
			returnValue = CI_BACK_PSC_NO_CONFIRM;
		}
		break;
	case ETYPE_PS_NO_UT_CT_OCU_STATE: /*物理区段车占用状态(无车/UT/CT)*/
		switch (functionId)
		{
		case EFUNC_SET_SEC_RESET_LOGIC_MANAGE: /*计轴复位命令逻辑管理*/
			returnValue = CI_BACK_PSEC_RESET_OP_INVALID_CT_ERROR; /*CT占用计轴复位操作无效*/
			break;
		case EFUNC_PHYSEC_RESET_TO_RELAY_STATE_PROC: /*更新区段计轴复位继电器状态*/
			returnValue = CI_BACK_PSEC_RESET_IN_CT; /*计轴复位中CT占用*/
			break;
		default:
			if ((LOGICSECTION_OCCUPY_UT == deviceState) || (LOGICSECTION_OCCUPY_CT == deviceState))
			{
				returnValue = CI_BACK_PSEC_OCU_YES;  /*侧防报警区段占用*/
			}
			else
			{
				returnValue = 0u;
			}
			break;
		}
		break;
	case ETYPE_GROUP_AUTO_ROUTE_STATE: /*组合自动进路设置失败*/
		returnValue = CI_BACK_GROUP_AUTO_ROUTE_SET_ERR; /*设置失败*/
		break;
	case ETYPE_SIG_YDROUTE_SEARCH_ERR: /*引导进路查找失败*/
		returnValue = CI_BACK_SIG_YDROUTE_SEARCH_ERR; /*查找失败*/
		break;
	case ETYPE_OVERLAP_LABORUNLOCK_FAIL: /*人工锁闭失败*/
		returnValue = LOCK_OVELAP_OUT_CANNOT; /*人工锁闭失败*/
		break;
	case ETYPE_LOGSEC_LOCK_STATE: /*逻辑区段锁闭状态（道岔搬动使用）*/
		returnValue = CI_BACK_PSEC_LOCK_YES;
		break;
	case ETYPE_LOGSEC_OCC_STATE: /*逻辑区段占用状态（道岔搬动使用）*/
		if (SECTION_OCCUPY_NO == deviceState)
		{
			returnValue = CI_BACK_PSEC_OCU_NO;
		}
		else
		{
			returnValue = CI_BACK_PSEC_OCU_YES;
		}
		break;
	case ETYPE_LOGSEC_XIANSU_STATE:
		returnValue = CI_BACK_LGC_SEC_XIANSU_SET;
		break;
	case ETYPE_AUTO_ROUTE_FLAG: /* 设置自动通过进路属性 */
		if (AUTO_ROUTE_DICHU_AUTOROUTE == deviceState)
		{
			returnValue = CI_BACK_AUTO_ROUTE_DICHU_ROUTE_SET;   
		}
		else if (AUTO_ROUTE_DICHU_AUTOREROUTE == deviceState)
		{
			returnValue = CI_BACK_AUTO_RETURN_DICHU_ROUTE_SET;
		}
		else if (AUTO_ROUTE_DICHU_ALLAUTOREROUTE == deviceState)
		{
			returnValue = CI_BACK_ALLAUTO_RETURN_DICHU_ROUTE_SET;
		}
		else if (AUTO_ROUTE_DICHU_COMMROUTE == deviceState)
		{
			returnValue = CI_BACK_COMMON_ROUTE_SET;
		}
		else if (AUTO_ROUTE_HAVE_BLOCK == deviceState)
		{
			returnValue = CI_BACK_AUTO_ROUTE_HAVE_BLOCK;
		}
		else
		{
			returnValue = CI_BACK_AUTO_ROUTE_FLOOD_STATE_ERR;
		}
		break;
	case ETYPE_AUTO_RETURN_FLAG:   /* 设置自动折返属性 */
		if (AUTO_RETURN_DICHU_AUTOROUTE == deviceState)
		{
			returnValue = CI_BACK_AUTO_ROUTE_DICHU_ROUTE_SET;
		}
		else if (AUTO_RETURN_DICHU_AUTOREROUTE == deviceState)
		{
			returnValue = CI_BACK_AUTO_RETURN_DICHU_ROUTE_SET;
		}
		else if (AUTO_RETURN_DICHU_ALLAUTOROUTE == deviceState)
		{
			returnValue = CI_BACK_ALLAUTO_RETURN_DICHU_ROUTE_SET;
		}
		else if (AUTO_RETURN_DICHU_COMMROUTE == deviceState)
		{
			returnValue = CI_BACK_COMMON_ROUTE_SET;
		}
		else if (AUTO_RETURN_HAVE_BLOCK == deviceState)
		{
			returnValue = CI_BACK_AUTO_RETURN_HAVE_BLOCK;
		}
		else
		{
			returnValue = CI_BACK_AUTO_RETURN_FLOOD_STATE_ERR;
		}
		break;
	case ETYPE_ALL_AUTO_RETURN_FLAG:  /* 设置全自动折返属性 */
		if (ALL_AUTO_RETURN_DICHU_AUTOR == deviceState)
		{
			returnValue = CI_BACK_AUTO_ROUTE_DICHU_ROUTE_SET;
		}
		else if (ALL_AUTO_RETURN_DICHU_AUTORETR == deviceState)
		{
			returnValue = CI_BACK_AUTO_RETURN_DICHU_ROUTE_SET;
		}
		else if (ALL_AUTO_RETURN_DICHU_ALLAUTOR == deviceState)
		{
			returnValue = CI_BACK_ALLAUTO_RETURN_DICHU_ROUTE_SET;
		}
		else if (ALL_AUTO_RETURN_DICHU_COMMR == deviceState)
		{
			returnValue = CI_BACK_COMMON_ROUTE_SET;
		}
		else if (ALL_AUTO_RETURN_HAVE_BLOCK == deviceState)
		{
			returnValue = CI_BACK_ALLAUTO_RETURN_HAVE_BLOCK;
		}
		else
		{
			returnValue = CI_BACK_ALLAUTO_RETURN_FLOOD_STATE_ERR;
		}
		break;

	case ETYPE_OTHER_ROUTE_CHECK:
		returnValue = CI_BACK_OTHER_ROUTE_NOT_OPEN;			/*进路其他联锁需开放进路未开放*/
		break;
	case ETYPE_OTHER_DOWNWASH_NOT_ALLOW_PASS:
		returnValue = CI_BACK_WASH_PASS_ALLOW_NOT;			/*洗车库/线未同意通过*/
		break;
	default:/*数据错误*/
		returnValue = 0U;
		break;
	}

	return returnValue;
}


/*
* 功能描述： 获取ATS反馈信息函数判断
* 参数说明： const UINT8 functionId, 函数ID
* 返回值  ： 
CI_ERROR     获取失败
CI_SUCCESS   获取成功   
*/
UINT8 CiToAtsBackInfoFunctionJudge(const UINT8 functionId,const UINT8 deviceType)
{
	UINT8 cRetVal = CI_ERROR;

	if ((functionId > 0U) && (deviceType>0U))
	{
		cRetVal = CI_SUCCESS;
	}
	else
	{
		cRetVal = CI_ERROR;
	}

	return cRetVal;
}


/*
* 功能描述： 指示器状态处理
* 参数说明： void
* 返回值  ： void 
*/
void IndicatorStateProc(void)
{
	UINT16 devCurSum = 0u;  /*设备总数*/
	UINT16 devId = 0u; /*设备ID*/
	UINT8 devType = 0u; /*设备类型*/
	UINT8 devRelaySum = 0u; /*设备继电器总数*/
	UINT16* devRelayIdBuf = NULL; /*继电器IDbuf*/
	UINT16 apply_1_Id = 0u; /*申请试车灯ID*/
	UINT16 allow_1_Id = 0u; /*允许试车灯ID*/
	UINT16 over_1_Id = 0u; /*结束试车灯ID*/

	UINT16 apply_2_Id = 0u; /*申请试车灯ID*/
	UINT16 allow_2_Id = 0u; /*允许试车灯ID*/
	UINT16 over_2_Id = 0u; /*结束试车灯ID*/
	UINT16 jkj_valid_Id = 0u; /*应急盘继电器有效灯ID*/

	UINT16 sysFirstId = 0u; /*平台一系ID*/
	UINT16 sysSecondId = 0u; /*平台二系ID*/
	UINT8 computerId = 0u; /*平台计算机ID*/
	UINT8 runMode = 0u; /*运行模式*/
	UINT8 selfState = 0u; /*本机状态*/
	UINT8 otherState = 0u; /*其他机器状态*/
	UINT16 applyRelay_1_Id = 0u; /*申请试车继电器1 ID*/
	UINT16 allowRelay_1_Id = 0u; /*允许试车继电器1 ID*/

	UINT16 applyRelay_2_Id = 0u; /*申请试车继电器2 ID*/
	UINT16 allowRelay_2_Id = 0u; /*允许试车继电器2 ID*/

	UINT8 faultFlag = 0u;/*故障标志 0为未故障*/
	UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT16 kk = 0u;/*索引*/
	UINT16 deviceCurSum = 0u;	 /*道岔总数目*/
	UINT16 deviceId = 0u;	     /*道岔ID*/
	UINT8 interfaceType = 0u;	/*试车线与车辆段接口方式*/

	UINT8 leuNum = 0u;/*与本CI通信的LEU数量*/
	UINT8 leuState = 0u;/*LEU状态*/

	UINT8 nonRouteId = 0u;/*非进路id*/
	UINT8 jkjRelayValidFlag = 0u;

	UINT8 relayConfirmFlag = 0u;/*继电接口确认标志*/

	UINT8 dianshiLinshixiansuFlag = 0u;/*点式临时限速*/
	UINT8 redDsFlag = 0u;  /*红灯断丝*/
	UINT8 greenDsFlag = 0u;  /*绿灯断丝*/
	UINT8 yellowDsFlag = 0u;  /*黄灯断丝*/
	UINT8 whiteDsFlag = 0u;  /*白灯断丝*/
	UINT8 redYellowDsFlag= 0u;      /*红黄灯断丝*/
	UINT8 redWhiteDsFlag= 0u;       /*红白灯断丝*/
	UINT8 greenYellowDsFlag= 0u;    /*绿黄灯断丝*/
	UINT8 doubleGreenDsFlag= 0u;    /*双绿灯断丝*/
    UINT8 doubleYellowDsFlag = 0u;  /*双黄灯断丝*/
	UINT8 switchBlockLinkState = 0u; /*封连报警状态*/
	UINT8 nonRouteRunModeById = 0u;
	UINT8 relayHunXianState = 0u;
	UINT16 RelayId = 0u;
	UINT8 relayBelongCi = 0u;
	UINT16 relaySum = 0u;
	UINT8 localCiId = 0u;
	UINT8 relayCollState = 0U;       /*继电器采集状态*/
	UINT8 commStatus = 0U;   /*通控通信状态*/
	UINT8 chVirtualZDZFButtonState = 0U;/*虚拟无人折返按钮状态*/
	UINT8 chStartFlockFlag = 0U;
	UINT8 chAllSwitchYlockFlag = 0U;
	UINT8 chStartLockFlag = 0U;
	UINT8 chStopCheckFlag = 0U;
	UINT8 chLocalCiType = 0U;
	UINT8 chCommuState = 0U;
	UINT8 chDevStateRtn = 0U;
	UINT8 chDevStateRtn2 = 0U;
	UINT8 chNonRouteState = 0U;
	UINT8 chNonRouteMode = 0U;	
	UINT8 chBjdDeviceId = 0U;/*报警灯设备ID*/
	UINT8 chNonReturnAdhesionState = 0U;/*无人折返粘连状态*/
	UINT8 cCommAxisNum = 0U;  /*与本控区具有通信关系的计轴子系统数量*/
	UINT8* pAxisSysIdBuf = NULL;
	UINT8 mm = 0U;
	
	dianshiLinshixiansuFlag = GetCiFunctionSwitchConfig(FUNC_DIANSHI_LINSHIXIANSU_FLAG);
	devCurSum = GetIndicatorCurSum(); /*获取指示器当前总数*/
	interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*获取试车线与车辆段接口方式*/ 
	localCiId = GetSystemParaLocalCiId();
	chLocalCiType = GetLocalCiType();
	for (ii = 0u; ii < devCurSum; ii++)
	{
		devRelaySum = 0u;
		devRelayIdBuf = NULL;

		devId = GetIndicatorId(ii); /*获取指示器ID*/
		devType = GetIndicatorType(devId); /*获取设备类型*/
		chBjdDeviceId = GetIndicatorDevId(devId);

		/*###【报警灯】###*/
		if ((INDICATOR_TYPE_ALARM_RONGSI == devType) ||
			(INDICATOR_TYPE_ALARM_GDGZ == devType)   ||
			(INDICATOR_TYPE_ALARM_RONGSI_qujian2 == devType)
			)
		{ /*熔丝报警 || 轨道故障报警*/

			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/

			if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置报警*/
				continue;
			}
			else
			{
			    ;
			}

			if (RELAY_STATE_UP == GetRelayCollState(devRelayIdBuf[0]))
			{ /*报警继电器吸起*/

				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置报警*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置无报警*/
			}
		}
		else if ((INDICATOR_TYPE_POWER_SCREEN == devType)||
			 (INDICATOR_TYPE_ALARM_XICHEJI == devType)||
			(INDICATOR_TYPE_READY_XICHEJI == devType)   ||
			(INDICATOR_TYPE_ALARM_DUANSI_qujian2 == devType) ||
			(INDICATOR_TYPE_POWER_SCREEN_qujian2 == devType)
			)
		{/* 电源屏报警 || 洗车机报警 继电器落下 报警 || 洗车机就绪状态*/

			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/

			if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置报警*/
				continue;
			}
			else
			{
			    ;
			}

			if (RELAY_STATE_UP == GetRelayCollState(devRelayIdBuf[0]))
			{ /*报警继电器吸起*/

				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置无报警*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置报警*/
			}
		}
		else if (INDICATOR_TYPE_ALARM_DUANSI == devType)
		{/*断丝报警 */
			
			SignaDsBreakAlarmIndicator(devId);
		}
		else if (INDICATOR_TYPE_ALARM_GDTD == devType)
		{ /*轨道停电报警*/

			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/
			SetIndicatorState(devId, INDICATOR_SHOW_NO); /*初始化无报警*/

			if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置报警*/
				continue;
			}
			else
			{
			    ;
			}


			for (jj = 0u; jj < devRelaySum; jj++)
			{
				if (RELAY_STATE_DOWN == GetRelayCollState(devRelayIdBuf[jj]))
				{ /*继电器落下*/

					SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置报警*/
					break;
				}
				else
			    {
			        ;
			    }

			}

			if (INDICATOR_SHOW_YES == GetIndicatorState(devId))
			{ /*有报警*/
			}
			else
			{ /*无报警*/
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置无报警*/
			}
		}
		else if ((INDICATOR_TYPE_UPS_FAULT == devType) || 
			(INDICATOR_TYPE_UPS2_FAULT == devType)
			)
		{ /*UPS指示灯 或 UPS2指示灯*/

			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/

			if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置UPS指示灯有效，数据错误*/
				continue;
			}
			else
			{
			    ;
			}


			if (RELAY_STATE_UP == GetRelayCollState(devRelayIdBuf[0]))
			{ /*继电器吸起*/

				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置UPS指示灯无效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置UPS指示灯有效*/
			}
		}

		/*###【指示灯】###*/
		else if ((INDICATOR_TYPE_EXPRESS_MAINP == devType) ||(INDICATOR_TYPE_EXPRESS_BACKP == devType)
		     || (INDICATOR_TYPE_EXPRESS_MAINP_2 == devType) || (INDICATOR_TYPE_EXPRESS_BACKP_2 == devType))
		{ /*主电源指示灯 || 副电源指示灯*/

			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/

			if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置电源报警*/
				continue;
			}
			else
			{
			    ;
			}


			if (RELAY_STATE_UP == GetRelayCollState(devRelayIdBuf[0]))
			{ /*继电器吸起*/

				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置电源有效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置电源报警*/
			}
		}
		else if ((INDICATOR_TYPE_EXPRESS_ZHAOCHA1 == devType) || 
			(INDICATOR_TYPE_EXPRESS_ZHAOCHA2 == devType) || 
			(INDICATOR_TYPE_EXPRESS_ZHAOCHA3 == devType) || 
			(INDICATOR_TYPE_EXPRESS_ZHAOCHA4 == devType) || 
			(INDICATOR_TYPE_EXPRESS_ZHAOCHA5 == devType)) 
		{ /*照查指示灯*/

			SetZhaoChaIndictorCommonState(devId);
#if 0
			if (GetIndicatorAvalibleFlag(devId) == INDICATOR_DATA_VALID)
			{/*照查无效*/

				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			else if (GetIndicatorAvalibleFlag(devId) == INDICATOR_DATA_PHYSEC)
			{/*照查指示灯有效且物理区段相关*/

				/*初始设置*/
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/

				devRelaySum = GetIndicatorRelaySum(devId);     /*获取相关照查物理区段总数*/
				devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关照查物理区段ID数组*/

				if ((0 == devRelaySum) || (NULL == devRelayIdBuf))
				{
					SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
					continue;
				}
				else
				{
			    	;
				}


				for (jj = 0; jj < devRelaySum; jj++)
				{
					/*继电器照查检查*/
					if (GetRouteThatZhaoChaRelayId(devRelayIdBuf[jj]) == 0)
					{
					}
					else
					{
						if (GetRelayCollState(GetRouteThatZhaoChaRelayId(devRelayIdBuf[jj])) == RELAY_STATE_DOWN)
						{/*对端照查落下*/

							SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
							break;
						}
						else
						{
			    			;
						}
					}

					/*进路照查检查*/
					relativeDeviceIdSum = GetRouteThatZhaoChaPhySecSum(devRelayIdBuf[jj]);
					if (relativeDeviceIdSum > 0)
					{/*进路照查检查*/

						relativeDeviceIdBuf = GetRouteThatZhaoChaPhySecIdBuf(devRelayIdBuf[jj]);
						for (kk = 0; kk < relativeDeviceIdSum; kk++)
						{
							if (GetRouteState(relativeDeviceIdBuf[kk]) == ROUTE_STATE_IDLE)
							{
							}
							else
							{
								/*进路照查不满足*/
								SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
								break;
							}
						}
					}
					else
					{
					}
				}
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
			}
#endif			
		}
		else if (INDICATOR_TYPE_EXPRESS_2OO2_I == devType)
		{ /*一系工作状态指示灯*/

			sysFirstId = devId;
		}
		else if (INDICATOR_TYPE_EXPRESS_2OO2_II == devType)
		{ /*二系工作状态指示灯*/

			sysSecondId = devId;
		}
#if 0
		else if (INDICATOR_TYPE_EXPRESS_START_UNLOCK == devType)
		{ /*上电解锁状态指示灯*/
			if (CI_START_LOCK_YES == GetStartLockFlag())
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
		}
#endif
		else if ((INDICATOR_TYPE_EXPRESS_NONROUTE == devType) || (INDICATOR_TYPE_EXPRESS_NONROUTE_2 == devType))
		{ /*非进路调车1 或 非进路调车2*/

			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/

			if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置非进路指示灯有效，数据错误*/
				continue;
			}
			else
			{
			    ;
			}
		

			if (NONROUTE_STATE_IDLE == GetNonRouteStateById((UINT8)(devRelayIdBuf[0])))
			{
				/*未办理非进路调车*/
				SetIndicatorState(devId, INDICATOR_SHOW_NONROUTE_NOSET); /*设置指示灯有效*/
			}
			else if ((NONROUTE_STATE_LOCK == GetNonRouteStateById((UINT8)(devRelayIdBuf[0]))) ||
				(NONROUTE_STATE_LOCKERR == GetNonRouteStateById((UINT8)(devRelayIdBuf[0]))) ||
				(NONROUTE_STATE_OPEN == GetNonRouteStateById((UINT8)(devRelayIdBuf[0]))))/*非进路锁闭/故障锁闭/非进路开放*/
			{
				/*非进路锁闭*/
				SetIndicatorState(devId, INDICATOR_SHOW_NONROUTE_LOCK); /*设置指示灯无效*/
			}
			else
			{
				/* 非进路正在锁闭或延时解锁期间*/
				SetIndicatorState(devId, INDICATOR_SHOW_NONROUTE_SETING); /*设置指示灯无效*/
			}
		}
		else if (INDICATOR_TYPE_EXPRESS_STOP_CHECK == devType)
		{ /*停止检查状态指示灯*/
			chStopCheckFlag = GetStopCheckFlag();
			if (ROUTE_STOPCHECK_SET_YES == chStopCheckFlag)
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
		}
		else if (INDICATOR_TYPE_SWITCH_JICHA == devType)
		{ /*道岔挤岔状态指示灯*/
			deviceCurSum = GetSwitchCurSum();
			for (jj = 0u; jj < deviceCurSum; jj++)
			{
				deviceId = GetSwitchId(jj);
				if ((SWITCH_POSITION_JICHA == GetSingleSwitchCurPosition(deviceId)) && 
					(CI_TRUE == CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, deviceId)))
				{  /*对房山线的道岔不报警*/
					break;
				}
				else
				{
			    	;
				}
			}

			if (deviceCurSum == jj)
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
			}
		}		
		else if (INDICATOR_TYPE_GD_DAD == devType)
		{ /*车库门故障指示灯*/
			deviceCurSum = GetGaragedoorSum();
			for (jj = 0u; jj < deviceCurSum; jj++)
			{
				deviceId = GetGaragedoorId(jj);
				if (GARAGE_DOOR_FAULT_TRUE == GetGaragedoorFaultState(deviceId))
				{
					break;
				}
				else
				{
			    	;
				}
			}

			if (deviceCurSum == jj)
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
			}
		}
		else if (INDICATOR_TYPE_EXPRESS_SC_APP == devType)
		{ /*申请试车指示灯1*/
			nonRouteId = GetNonRouteIdByIndicatorId(devId);
			if (nonRouteId >0u)
			{
				if(CI_TYPE_SCX == chLocalCiType)
				{
					/* 试车线 */
					apply_1_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						applyRelay_1_Id = GetSCXDrvApplyTryRelayIdById(nonRouteId); /*申请试车继电器ID*/
					}	
					else
				    {
			    	    ;
				    }
				}
				else
				{
					/* 车辆段 */
					apply_1_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						applyRelay_1_Id = GetNonRouteAppTryRelayIdById(nonRouteId); /*申请试车继电器ID*/
					}	
					else
				    {
			    	    ;
				    }
				}
			}
			else
			{
			    ;
			}

		}
		else if (INDICATOR_TYPE_EXPRESS_SC_APP_2 == devType)
		{ /*申请试车指示灯2*/
			nonRouteId = GetNonRouteIdByIndicatorId(devId);
			if (nonRouteId >0u)
			{
				if(CI_TYPE_SCX == chLocalCiType)
				{
					/* 试车线 */
					apply_2_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						applyRelay_2_Id = GetSCXDrvApplyTryRelayIdById(nonRouteId); /*申请试车继电器ID*/
					}	
					else
				    {
			    	    ;
				    }
				}
				else
				{
					/* 车辆段 */
					apply_2_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						applyRelay_2_Id = GetNonRouteAppTryRelayIdById(nonRouteId); /*申请试车继电器ID*/
					}	
					else
				    {
			    	    ;
				    }
				}
			}

		}
		else if (INDICATOR_TYPE_EXPRESS_SC_ALW == devType)
		{ /*允许试车指示灯1*/

			nonRouteId = GetNonRouteIdByIndicatorId(devId);
			if (nonRouteId>0u)
			{
			
				if(CI_TYPE_SCX == chLocalCiType)
				{
					allow_1_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						allowRelay_1_Id = GetSCXColAgreeTryRelayIdById(nonRouteId); /*允许试车继电器1ID*/
					}	
					else
				    {
			    	    ;
				    }
				}
				else
				{	/* 车辆端 */
					allow_1_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						allowRelay_1_Id = GetNonRouteAgreeTryRelayIdById(nonRouteId); /*允许试车继电器1ID*/
					}	
					else
				    {
			    	    ;
				    }	
				}
			}
		}
		else if (INDICATOR_TYPE_EXPRESS_SC_ALW_2 == devType)
		{ /*允许试车指示灯2*/

			nonRouteId = GetNonRouteIdByIndicatorId(devId);
			if (nonRouteId>0u)
			{

				if(CI_TYPE_SCX == chLocalCiType)
				{
					allow_2_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						allowRelay_2_Id = GetSCXColAgreeTryRelayIdById(nonRouteId); /*允许试车继电器2ID*/
					}
					else
				    {
			    	    ;
				    }	
				}
				else
				{	/* 车辆端 */
					allow_2_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						allowRelay_2_Id = GetNonRouteAgreeTryRelayIdById(nonRouteId); /*允许试车继电器2ID*/
					}
					else
				    {
			    	    ;
				    }		
				}
			}
		}
		else if (INDICATOR_TYPE_EXPRESS_SC_END == devType)
		{ /*结束试车指示灯1*/

			over_1_Id = devId;
		}
		else if (INDICATOR_TYPE_EXPRESS_SC_END_2 == devType)/*结束试车指示灯2*/
		{ 
			over_2_Id = devId;
		}
		else if (INDICATOR_TYPE_JKJ_VALID == devType)/*应急盘继电器有效指示灯*/
		{
			jkj_valid_Id = devId;
		}
		else if (INDICATOR_TYPE_SIGNAL_FAULT_CLOSE == devType)
		{/*信号机故障关闭报警*/

			for (jj = 0u; jj < GetSignalCurSum(); jj++)
			{
				deviceId = GetSignalId(jj);
				/*获取灯丝断丝状态*/
			    redDsFlag = GetSignalDsBreakFlag(deviceId);
			    greenDsFlag = GetSignalGreenDsBreakFlag(deviceId);
			    yellowDsFlag = GetSignalYellowDsBreakFlag(deviceId);
			    whiteDsFlag = GetSignalWhiteDsBreakFlag(deviceId);
				redYellowDsFlag = GetSignalRedYellowDsBreakFlag(deviceId);
				redWhiteDsFlag = GetSignalRedWhiteDsBreakFlag(deviceId);
				greenYellowDsFlag = GetSignalGreenYellowDsBreakFlag(deviceId);
				doubleGreenDsFlag = GetSignalDoubleGreenDsBreakFlag(deviceId);
				doubleYellowDsFlag = GetSigDoubleYellowDsBreakFlag(deviceId);

				if (((SIGNAL_DS_BREAK_YES == redDsFlag) || (SIGNAL_DS_BREAK_YES == greenDsFlag)
					|| (SIGNAL_DS_BREAK_YES == yellowDsFlag) || (SIGNAL_DS_BREAK_YES == whiteDsFlag)
					|| (SIGNAL_DS_BREAK_YES == redYellowDsFlag) || (SIGNAL_DS_BREAK_YES == redWhiteDsFlag)
					|| (SIGNAL_DS_BREAK_YES == greenYellowDsFlag) || (SIGNAL_DS_BREAK_YES == doubleGreenDsFlag)
					|| (SIGNAL_DS_BREAK_YES == doubleYellowDsFlag))
					&& (CI_TRUE == CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, deviceId)))
				{/*信号机存在故障关闭*/

					faultFlag = 1u;/*信号机故障标志*/
					break;
				}
				else
				{
			        ;
				}
			}

			if (faultFlag == 0u)
			{/*信号机未故障*/

				SetIndicatorState(devId, INDICATOR_SHOW_NO);/*设置指示灯无效*/
			}
			else
			{/*信号机故障*/

				SetIndicatorState(devId, INDICATOR_SHOW_YES);/*设置指示灯有效*/
			}

		}
		else if (INDICATOR_TYPE_CIDEVICE_FAULT == devType)
		{/*联锁设备故障报警*/
			chCommuState = Get2oo2CiAndIoCommState();
			if (TRANSMIT_2OO2_STATE_GOOD == chCommuState)
			{/*IO 通信良好*/

				SetIndicatorState(devId, INDICATOR_SHOW_IOCOMM_OK);/*设置指示灯通信良好*/
			}
			else
			{/*IO 通信故障*/

				SetIndicatorState(devId, INDICATOR_SHOW_IOCOMM_BAD);/*设置指示灯通信故障*/
			}
		}
		else if (INDICATOR_TYPE_EXPRESS_RETURN == devType)
		{/*无人折返灯指示灯*/

			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/

			if ((3u !=devRelaySum)||(NULL ==devRelayIdBuf))
			{/*数据不对*/

				SetIndicatorState(devId, INDICATOR_SHOW_RETURN_NORMAL);/*设置表示灯常态*/
			}
			else if (GetRelayDriveState(devRelayIdBuf[0]) == RELAY_STATE_UP)
			{/*闪灯驱动吸起*/

				if (GetRelayDriveState(devRelayIdBuf[1]) == RELAY_STATE_DOWN)
				{

					SetIndicatorState(devId, INDICATOR_SHOW_RETURN_FLASH);/*设置表示灯闪灯*/
				}
				else
				{
					/*稳灯驱动吸起 错误情况*/
					SetIndicatorState(devId, INDICATOR_SHOW_RETURN_NORMAL);/*设置表示灯常态*/
				}
			}
			else if (GetRelayDriveState(devRelayIdBuf[0]) == RELAY_STATE_DOWN)
			{/*闪灯驱动落下*/

				if (GetRelayDriveState(devRelayIdBuf[1]) == RELAY_STATE_UP)
				{/*稳灯驱动吸起*/

					SetIndicatorState(devId, INDICATOR_SHOW_RETURN_LIGHT);/*设置表示灯稳灯*/
				}
				else
				{
					SetIndicatorState(devId, INDICATOR_SHOW_RETURN_NORMAL);/*设置表示灯常态*/
				}
			}
			else
			{
				/*其他情况*/
				SetIndicatorState(devId, INDICATOR_SHOW_RETURN_NORMAL);/*设置表示灯常态*/
			}
					
		}
		else if (INDICATOR_TYPE_AUTORTN_ADHESION == devType)
		{
			/*无人折返按钮粘连状态指示灯*/
			chNonReturnAdhesionState = CheckNonReturnExistAdhesion(chBjdDeviceId);
			if (RTN_RELAY_ADHESION_YES == chNonReturnAdhesionState)
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES);/*设置表示灯有效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO);/*设置表示灯有效*/
			}	
		}
		else if (INDICATOR_TYPE_COMM_LEU == devType)
		{/*与LEU通信状态*/

#if 0
			if (TRANSMIT_2OO2_STATE_GOOD == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_LEU,0))
			{/*LEU 通信良好*/

				SetIndicatorState(devId, INDICATOR_SHOW_COMM_GREEN);/*设置指示灯通信良好*/
			}
			else if (TRANSMIT_2OO2_STATE_LINK == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_LEU,0))
			{/*LEU 通信一般*/

				SetIndicatorState(devId, INDICATOR_SHOW_COMM_YELLOW);/*设置指示灯通信一般*/
			}
#endif
			leuNum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_LEU);
			for (kk =0u;kk<leuNum;kk++)
			{
				leuState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_LEU,(UINT8)kk);

				if ((INDICATOR_TYPE_LEU_FAULT_NO == leuFaultFlag) && ((TRANSMIT_2OO2_STATE_LINK == leuState) 
					|| (TRANSMIT_2OO2_STATE_GOOD == leuState)))
				{
					SetIndicatorState(devId, INDICATOR_SHOW_COMM_GREEN);/*设置指示灯通信良好*/
				}
				else
				{/*LEU 通信故障*/

					SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED);/*设置指示灯通信故障*/
					break;/*有一个故障，就认为与LEU通信故障，在此打断循环*/
				}
			}
			
		}
		else if (INDICATOR_TYPE_COMM_ZC == devType)
		{/*与ZC通信状态*/

			if (TRANSMIT_2OO2_STATE_GOOD == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_ZC,0u))
			{/*ZC 通信良好*/

				SetIndicatorState(devId, INDICATOR_SHOW_COMM_GREEN);/*设置指示灯通信良好*/
			}
			else if (TRANSMIT_2OO2_STATE_LINK == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_ZC,0u))
			{/*ZC 通信一般*/

				SetIndicatorState(devId, INDICATOR_SHOW_COMM_YELLOW);/*设置指示灯通信一般*/
			}
			else
			{/*ZC 通信故障*/

				SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED);/*设置指示灯通信故障*/
			}
		}
		else if ((INDICATOR_TYPE_COMM_CI_FIRST <= devType)
			&& (INDICATOR_TYPE_COMM_CI_LAST >= devType))
		{/*第devType-INDICATOR_TYPE_COMM_CI_FIRST+1个相邻联锁通信状态*/

			devRelaySum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_CI);
			jj = devType - INDICATOR_TYPE_COMM_CI_FIRST;
			if (devRelaySum > jj)
			{
				if (TRANSMIT_2OO2_STATE_GOOD == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_CI,(UINT8)jj))
				{/*上第jj+1个相邻联锁 通信良好*/

					SetIndicatorState(devId, INDICATOR_SHOW_COMM_GREEN);/*设置指示灯通信良好*/
				}
				else if (TRANSMIT_2OO2_STATE_LINK == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_CI,(UINT8)jj))
				{/*第jj+1个相邻联锁 通信一般*/

					SetIndicatorState(devId, INDICATOR_SHOW_COMM_YELLOW);/*设置指示灯通信一般*/
				}
				else
				{/*第jj+1个相邻联锁 通信故障*/

					SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED);/*设置指示灯通信中断*/
				}
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED);/*设置指示灯通信中断*/
			}
		}
		else if (INDICATOR_TYPE_STATUS_START_FLOCK == devType)
		{/* 全站封锁 */
			chStartFlockFlag = GetStartFLockFlag();
			if (CI_START_FLOCK_YES == chStartFlockFlag)
			{
				/* 显示全站封锁状态 */
				SetIndicatorState(devId, INDICATOR_SHOW_CI_FLOCAK_YES);/*设置全站封锁显示有效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_CI_FLOCAK_NO);/*设置全站封锁显示无效*/
			}

		}
		else if (INDICATOR_TYPE_YINDAOZONGSUO == devType)
		{/* 引导总锁状态*/
			chAllSwitchYlockFlag = GetAllSwitchYLockFlag();
			if (SWITCH_LOCK_YINZONG_YES == chAllSwitchYlockFlag)
			{
				/* 显示引导总锁状态*/
				SetIndicatorState(devId, INDICATOR_SHOW_YES);/*设置引导总锁有效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO);/*设置引导总锁无效*/
			}

		}
		else if (INDICATOR_TYPE_STATUS_START_LOCK == devType)
		{
			/* 上电锁闭状态 */
			chStartLockFlag = GetStartLockFlag();
			if (CI_START_LOCK_NO == chStartLockFlag)
			{
				/* 显示全站上电锁闭状态 */
				SetIndicatorState(devId, INDICATOR_SHOW_CI_STARTLOCK_YES);/*上电解锁显示有效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_CI_STARTLOCK_NO);
			}
		}	
		else if ((INDICATOR_TYPE_COMM_PSD_START <= devType) && (devType <= INDICATOR_TYPE_COMM_PSD_FIFTH))
		{
			/* PSD 通信状态处理 */
			if (GetIndicatorAvalibleFlag(devType) != INDICATOR_DATA_VALID)
			{
				/* 有效下状态设置 */
				SetPSDCommonState(devId,devType);
			}
		}
		else if (INDICATOR_TYPE_STATUS_DISPLAY_LINSHIXIANSU == devType)
		{
			if(HAVE_DIANSHILINSHIXIANSU == dianshiLinshixiansuFlag)
			{
				/* 设置人工取消临时限速按钮显示与否 */
				chDevStateRtn = GetLabourCancelLinShiXianState();
				if (LINSHIXIANSU_COMM_BAD_STATE == chDevStateRtn)
				{
					/* 显示人工取消临时限速按钮 */
					SetIndicatorState(devId, INDICATOR_SHOW_CI_LIMIT_YES);
				}
				else
				{   /* 不显示人工取消临时限速按钮 */
					SetIndicatorState(devId, INDICATOR_SHOW_CI_LIMIT_NO);
				}
			}
			else
			{
				/* 不显示人工取消临时限速按钮 */
				SetIndicatorState(devId, INDICATOR_SHOW_CI_LIMIT_NO);
			}

		}
		else if (INDICATOR_TYPE_STATUS_CI_MODE == devType)
		{ /*工作模式指示灯*/
			SetCiModeIndicatorState(devId);

		}
		else if ((INDICATOR_TYPE_PCB1 == devType) ||(INDICATOR_TYPE_PCB2 == devType) || 
			(INDICATOR_TYPE_PCB3 == devType) ||(INDICATOR_TYPE_PCB4 == devType) ||
			(INDICATOR_TYPE_PCB5 == devType) ||(INDICATOR_TYPE_PCB6 == devType))
		{/*PCB按钮状态指示灯*/
			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关设备总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关设备ID buf，PSD ID*/

			if ((0u != devRelaySum) && (NULL != devRelayIdBuf))
			{/*相关设备有效*/
				chDevStateRtn = GetPsdButtonState(devRelayIdBuf[0]);
				chDevStateRtn2 = GetPsdVirtualAttribute(devRelayIdBuf[0]);
				if ((PSD_BUTTON_STATE_DOWN == chDevStateRtn) &&
					(PSD_VIRTUAL_ATTR_YES == chDevStateRtn2))
				{ /*虚拟PSD的PCB按下*/

					SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置按钮状态表示灯有效*/
				}
				else
				{
					SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
				}
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
			}	
		}
		else if ((INDICATOR_TYPE_PSD1_ISOLATE == devType) ||(INDICATOR_TYPE_PSD2_ISOLATE == devType) || 
			(INDICATOR_TYPE_PSD3_ISOLATE == devType) ||(INDICATOR_TYPE_PSD4_ISOLATE == devType) ||
			(INDICATOR_TYPE_PSD5_ISOLATE == devType) ||(INDICATOR_TYPE_PSD6_ISOLATE == devType))
		{/*PSD故障隔离状态指示灯*/
			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关设备总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关设备ID buf，PSD ID*/

			if ((0u != devRelaySum) && (NULL != devRelayIdBuf))
			{/*相关设备有效*/
				chDevStateRtn = GetPsdIsolateState(devRelayIdBuf[0]);
				chDevStateRtn2 = GetPsdVirtualAttribute(devRelayIdBuf[0]);
				if ((PSD_FAULT_ISOLATION_SCX == chDevStateRtn) && (PSD_VIRTUAL_ATTR_YES == chDevStateRtn2))
				{ /*虚拟PSD的故障隔离信息有效*/
					SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置按钮状态表示灯有效*/
				}
				else
				{
					SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
				}
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
			}	
		}
		else if (INDICATOR_TYPE_AUTORTN_BTN == devId)
		{/*试车线无人折返按钮状态指示灯*/
			chVirtualZDZFButtonState = GetVirtualZDZFButtonState();
			if (VIRTUAL_ZDZFAJ_BUTTON_YES == chVirtualZDZFButtonState)
			{/*按钮按下*/
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置按钮状态表示灯有效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
			}
		}
		else if (INDICATOR_TYPE_ALL_SIG_BRIGHT == devType)
		{/*全站点灯状态指示灯*/
			chDevStateRtn = GetAllSignalBrightFlag();
			if (CI_ALL_SIGNAL_BRIGHT_YES == chDevStateRtn)
			{/*全站亮灯状态有效*/
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置全站亮灯表示灯有效*/
			} 
			else
			{/*全站亮灯状态无效*/
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置全站亮灯表示灯无效*/
			}
		}
		else if (INDICATOR_TYPE_AUTO_TRIGGE == devType)
		{   /*自动触发标志*/
			chDevStateRtn = CheckAutoTriggerIndicatFlag(0U);
			if (CI_SUCCESS == chDevStateRtn)
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置自动触发表示灯有效*/
			} 
			else
			{/*全站亮灯状态无效*/
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置自动触发表示灯无效*/
			}
		}
		else if ((INDICATOR_TYPE_XICHEJI_ALLOW_STATE == devType)
		|| (INDICATOR_TYPE_DOWNWASH_ALLOW_PASS_STATE == devType))
		{/* 非FAO线路同意洗车状态指示灯||降级模式洗车同意指示灯||降级模式洗车同意通过指示灯 */
			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf，对应反向通过同意继电器XTJ*/

			if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			else
			{
				chDevStateRtn = GetRelayCollState(devRelayIdBuf[0]);
				if (RELAY_STATE_UP == chDevStateRtn)
				{ /*继电器吸起*/

					SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
				}
				else
				{
					SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
				}
			}	
		}
		else if (INDICATOR_TYPE_GENERAL_RESET_VALID == devType)
		{
			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf，对应总复位继电器ZFWJ*/

			if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			else
			{
				chDevStateRtn = GetRelayCollState(devRelayIdBuf[0]);
				if (RELAY_STATE_UP == chDevStateRtn)
				{ /*继电器吸起*/
					SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
				}
				else
				{
					SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
				}
			}
		}
		else if (INDICATOR_TYPE_ATS_CONFIRM_RELAY_INTERFACE == devType)
		{/*相邻联锁继电接口确认状态指示灯*/
			relayConfirmFlag = GetCiCiRelayInterfConfirmFlag();
			if (CICI_RELAY_INTERFACE_CONFIRM_YES == relayConfirmFlag)
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
		}
		else if(INDICATOR_TYPE_RELAY_HUNXIAN == devType)
		{
			relaySum = GetRelayCurSum();
			for(jj = 0u; jj < relaySum;jj++)
			{
				RelayId = GetRelayId(jj);
				relayBelongCi = GetRelayBelongCiId(RelayId);
				if(relayBelongCi == localCiId)
				{
					relayHunXianState = GetRelayHunXianState(RelayId);
					if(RELAY_HUNXIAN_STATE_YES == relayHunXianState)
					{
						break;
					}
				}
			}
			if(RELAY_HUNXIAN_STATE_YES == relayHunXianState)
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			/*每周期用完标志后，清状态*/
			SetZfwjHunXianFLag(ZFWJ_HUN_XIAN_NO);
		}
		/*取消转辙机封连报警指示灯*/
		else if(INDICATOR_TYPE_SWITCH_BLOCK_LINK == devType)
		{
			/*获取取消封连状态*/
			switchBlockLinkState = GetCancelOrRcvrBlockLinkSta();
			if(CANCEL_SWITCH_BLOCK_LINK == switchBlockLinkState)
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
			}
		}
		else if ((INDICATOR_TYPE_UPS_DCGD == devType) ||
		(INDICATOR_TYPE_UPS_DCDY == devType))
		{ /*cgh-合并CID-3037-3：UPS电池供电 || UPS电池电压*/

			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/

			if ((0U == devRelaySum) || (NULL == devRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置红灯报警*/
			}
			else
			{
				relayCollState = GetRelayCollState(devRelayIdBuf[0]);
				if (RELAY_STATE_UP == relayCollState)
				{ /*继电器吸起*/

					SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置绿灯*/
				}
				else
				{
					SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置红灯*/
				}

			}

		}
		else if (INDICATOR_TYPE_PORT_RONGSI == devType)
		{
			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/
			if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效，报警*/
			}
			else
			{
				relayCollState = GetRelayCollState(devRelayIdBuf[0]);
				if (RELAY_STATE_UP == relayCollState)
				{ /*继电器吸起*/
					SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效，报警*/
				}
				else
				{
					SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效，无报警*/
				}
			}
		}
		else if ((INDICATOR_TYPE_UPS1_PL == devType)|| (INDICATOR_TYPE_UPS2_PL == devType))
		{/*UPS旁路指示灯*/
		devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
		devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/
		if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
		{
			SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效，表示UPS未旁路*/
		}
		else
		{
			relayCollState = GetRelayCollState(devRelayIdBuf[0]);
			if (RELAY_STATE_UP == relayCollState)
			{ /*旁路继电器吸起*/
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效，报警*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效，无报警*/
			}
		}
		}
		else if (INDICATOR_TYPE_COMM_DEVICE == devType)
		{
		    /*联锁通信设备状态报警指示灯（通控通信状态）*/
			commStatus = CheckRCICommCCUDeviceStatue();
			if (CI_SUCCESS == commStatus)
			{
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置指示灯无效，不报警*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置指示灯有效，报警*/
			}
		}
		else if (INDICATOR_TYPE_COMM_AXIS == devType)
		{
		    /*与计轴子系统通信状态*/
			cCommAxisNum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS);
			pAxisSysIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS);

			if ((0U < cCommAxisNum) && (NULL != pAxisSysIdBuf))
			{
				for (mm = 0U; mm < cCommAxisNum; mm++)
				{
					commStatus = GetCiTransmitState(CI_SYSTEM_TYPE_AXIS, pAxisSysIdBuf[mm]);

					if (TRANSMIT_STATE_GOOD == commStatus)
					{
						SetIndicatorState(devId, INDICATOR_SHOW_COMM_GREEN);  /*设置指示灯通信良好*/
					}
					else
					{
						SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED);  /*与计轴通信故障，设置指示灯通信故障*/
						break;  /*有一个故障，就认为与计轴通信故障，在此打断循环*/
					}
				}
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED);
			}
		}
		else
		{
		/*不做处理*/
		}
	}

	/*****处理平台1、2系指示灯*****/

#ifdef PLATFORM_2OO2

	if ((sysFirstId > 0U) && (sysSecondId > 0U))
	{
		computerId = Get2oo2ComputerId(); /*获取平台计算机ID*/
		runMode = Get2oo2ProcessMode(); /*获取平台运行模式*/
		runMode|= Get2oo2OhterProcessMode();
		if ((computerId > 0U) && (runMode > 0U))
		{
			selfState = ((runMode) & ((UINT8)0xF0)) >> 4;
			otherState = (runMode) & ((UINT8)0x0F);

			debug_infor_printf((const)"computerId %d selfState %d otherState %d\n", computerId, selfState, otherState);
			if (1U == computerId)/*属于1系*/
			{
				if(0x0aU == selfState)
				{
					SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_MAIN); /*设置指示灯1系为主*/
				}
				else if (0x05U == selfState)
				{
					SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_BACKUP); /*设置指示灯1系为备*/
				}
				else
				{
					SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯1系故障*/
				}

				if(0x0aU == otherState)
				{
					SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_MAIN); /*设置指示灯2系为主*/
				}
				else if (0x05U == otherState)
				{
					SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_BACKUP); /*设置指示灯2系为备*/
				}
				else
				{
					SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯2系故障*/
				}
			}
			else if (2U == computerId)
			{
				if(0x0aU == selfState)
				{
					SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_MAIN); /*设置指示灯2系为主*/
				}
				else if (0x05U == selfState)
				{
					SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_BACKUP); /*设置指示灯2系为备*/
				}
				else
				{
					SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯2系故障*/
				}

				if(0x0aU == otherState)
				{
					SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_MAIN); /*设置指示灯1系为主*/
				}
				else if (0x05U == otherState)
				{
					SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_BACKUP); /*设置指示灯1系为备*/
				}
				else
				{
					SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯1系故障*/
				}
			}
			else
			{/*不处理*/
			}
		}
		else
		{
			SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯1系故障*/
			SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯2系故障*/
		}
	}

#endif



	SetIndicatorState(apply_1_Id, INDICATOR_SHOW_NO); /*初始化申请试车指示灯无效*/
	SetIndicatorState(allow_1_Id, INDICATOR_SHOW_NO); /*初始化同意试车指示灯无效*/
	SetIndicatorState(over_1_Id, INDICATOR_SHOW_NO); /*初始化结束试车指示灯无效*/

	SetIndicatorState(apply_2_Id, INDICATOR_SHOW_NO); /*初始化申请试车指示灯无效*/
	SetIndicatorState(allow_2_Id, INDICATOR_SHOW_NO); /*初始化同意试车指示灯无效*/
	SetIndicatorState(over_2_Id, INDICATOR_SHOW_NO); /*初始化结束试车指示灯无效*/

	SetIndicatorState(jkj_valid_Id, INDICATOR_SHOW_NO); /*初始化应急盘指示灯无效*/
	/* 车辆段下 设置默认状态为指示灯无效*/
	if(CI_TYPE_CLD == chLocalCiType)
	{	
		if (jkj_valid_Id > 0u)
		{
			jkjRelayValidFlag = GetCiJkjFlag();                      /*JKJ应急盘继电器有效标志*/
			/*应急盘继电器有效状态*/
			if (JKJ_REYLAY_VALID == jkjRelayValidFlag)
			{
				SetIndicatorState(jkj_valid_Id, INDICATOR_SHOW_YES); /*设置结束应急盘指示灯有效*/
			}
			else
			{
				SetIndicatorState(jkj_valid_Id, INDICATOR_SHOW_NO); /*设置结束应急盘指示灯无效*/
			}
		}
		
		/*处理非进路调车相关指示灯*/
		if (SCX_CLD_INTERFACE_RELAY == interfaceType)
		{/*车辆段与试车线采用继电器接口*/
			if ((apply_1_Id > 0u) && (allow_1_Id > 0u) && (over_1_Id > 0u) && (applyRelay_1_Id > 0u) && (allowRelay_1_Id > 0u))
			{

				if ((RELAY_STATE_DOWN == GetRelayCollState(applyRelay_1_Id)) &&
					(RELAY_STATE_DOWN == GetRelayCollState(allowRelay_1_Id)))
				{ /*申请试车继电器落下&&允许试车继电器落下*/
					
					nonRouteId = GetNonRouteIdByIndicatorId(apply_1_Id);
					if (nonRouteId > 0u)
					{
						chNonRouteState = GetNonRouteStateById(nonRouteId);
						if (NONROUTE_STATE_IDLE == chNonRouteState)
						{ /*非进路空闲*/

							SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
						}
						else if (NONROUTE_STATE_XUANPAI == chNonRouteState)
						{ /*非进路选排*/
							nonRouteRunModeById = GetNonRouteRunModeById(nonRouteId);
							if (NONROUTE_RUN_MODE_APPLY == nonRouteRunModeById)
							{ /*试信号模式*/

								SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
							}
							else
							{
								SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
							}
						}
						else
						{
							/*无操作*/
						}
					}
					else
					{
						SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
					}
				}

				if (RELAY_STATE_UP == GetRelayCollState(allowRelay_1_Id))
				{ /*允许试车继电器吸起*/
					nonRouteId = GetNonRouteIdByIndicatorId(allow_1_Id);
					if (nonRouteId > 0u)
					{
						chNonRouteState = GetNonRouteStateById(nonRouteId);
						if ((NONROUTE_STATE_LOCK == chNonRouteState) ||(NONROUTE_STATE_OPEN == chNonRouteState))
						{ /*非进路锁闭||非进路开放*/

							if ((NONROUTE_CANCEL_FLAG_YES == GetNonRouteCancelFlagById(nonRouteId)) ||
								(NONROUTE_CANCEL_FLAG_YES == GetNonRouteHaveCancelFlagById(nonRouteId)))
							{
								SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
							}
							else
							{
								SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_YES); /*设置同意试车指示灯有效*/
							}
						}
					}
					else
					{
						SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
					}
				}

				if (RELAY_STATE_UP == GetRelayCollState(applyRelay_1_Id))
				{ /*申请试车继电器吸起*/
					nonRouteId = GetNonRouteIdByIndicatorId(apply_1_Id);
					if (nonRouteId > 0u)
					{
						chNonRouteState = GetNonRouteStateById(nonRouteId);
						chNonRouteMode = GetNonRouteRunModeById(nonRouteId);
						if ((NONROUTE_STATE_OPEN == chNonRouteState) ||
							(NONROUTE_STATE_LOCKERR == chNonRouteState) ||
							(NONROUTE_STATE_FAULTDELAY_UNLOCK == chNonRouteState) ||
							(NONROUTE_STATE_DELAY_UNLOCK == chNonRouteState))
						{ /*非进路延时解锁||非进路开放||非进路故障锁闭||非进路故障延时解锁*/

							if (NONROUTE_RUN_MODE_APPLY == chNonRouteMode)
							{/*试信号模式*/

								SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_YES); /*设置结束试车指示灯有效*/
							}
							else
							{/*试车辆模式*/

								SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
							}

						}
						else
				        {
			    	        ;
				        }
					}
					else
					{
						SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
					}
				}
			}


			if ((apply_2_Id > 0u) && (allow_2_Id > 0u) && (over_2_Id > 0u) && (applyRelay_2_Id > 0u) && (allowRelay_2_Id > 0u))
			{

				if ((RELAY_STATE_DOWN == GetRelayCollState(applyRelay_2_Id)) &&
					(RELAY_STATE_DOWN == GetRelayCollState(allowRelay_2_Id)))
				{ /*申请试车继电器落下&&允许试车继电器落下*/

					nonRouteId = GetNonRouteIdByIndicatorId(apply_2_Id);
					if (nonRouteId > 0u)
					{
						chNonRouteState = GetNonRouteStateById(nonRouteId);
						if (NONROUTE_STATE_IDLE == chNonRouteState)
						{ /*非进路空闲*/

							SetIndicatorState(apply_2_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
						}
						else if (NONROUTE_STATE_XUANPAI == chNonRouteState)
						{ /*非进路选排*/
							nonRouteRunModeById = GetNonRouteRunModeById(nonRouteId);
							if (NONROUTE_RUN_MODE_APPLY == nonRouteRunModeById)
							{ /*试信号模式*/

								SetIndicatorState(apply_2_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
							}
							else
							{
								SetIndicatorState(apply_2_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
							}
						}
						else
						{
							/*无操作*/
						}
					}
					else
					{
						SetIndicatorState(apply_2_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
					}
				}

				if (RELAY_STATE_UP == GetRelayCollState(allowRelay_2_Id))
				{ /*允许试车继电器吸起*/
					nonRouteId = GetNonRouteIdByIndicatorId(allow_2_Id);
					if (nonRouteId > 0u)
					{
						chNonRouteState = GetNonRouteStateById(nonRouteId);
						if ((NONROUTE_STATE_LOCK == chNonRouteState) ||
							(NONROUTE_STATE_OPEN == chNonRouteState))
						{ /*非进路锁闭||非进路开放*/

							if ((NONROUTE_CANCEL_FLAG_YES == GetNonRouteCancelFlagById(nonRouteId)) ||
								(NONROUTE_CANCEL_FLAG_YES == GetNonRouteHaveCancelFlagById(nonRouteId)))
							{
								SetIndicatorState(allow_2_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
							}
							else
							{
								SetIndicatorState(allow_2_Id, INDICATOR_SHOW_SC_YES); /*设置同意试车指示灯有效*/
							}
						}
						else
				        {
			    	        ;
				        }
					}
					else
					{
						SetIndicatorState(allow_2_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
					}
				}

				if (RELAY_STATE_UP == GetRelayCollState(applyRelay_2_Id))
				{ /*申请试车继电器吸起*/
					nonRouteId = GetNonRouteIdByIndicatorId(apply_2_Id);
					if (nonRouteId > 0u)
					{
						chNonRouteState = GetNonRouteStateById(nonRouteId);
						chNonRouteMode = GetNonRouteRunModeById(nonRouteId);
						if ((NONROUTE_STATE_OPEN == chNonRouteState) ||
							(NONROUTE_STATE_LOCKERR == chNonRouteState) ||
							(NONROUTE_STATE_FAULTDELAY_UNLOCK == chNonRouteState) ||
							(NONROUTE_STATE_DELAY_UNLOCK == chNonRouteState))
						{ /*非进路延时解锁||非进路开放||非进路故障锁闭||非进路故障延时解锁*/

							if (NONROUTE_RUN_MODE_APPLY == chNonRouteMode)
							{/*试信号模式*/

								SetIndicatorState(over_2_Id, INDICATOR_SHOW_SC_YES); /*设置结束试车指示灯有效*/
							}
							else
							{/*试车辆模式*/

								SetIndicatorState(over_2_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
							}

						}
						else
				        {
			    	        ;
				        }
					}
					else
					{
						SetIndicatorState(over_2_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
					}
				}
			}
		}
		else
		{/*车辆段与试车线采用通信接口*/
			chDevStateRtn = GetCommTrainTestCLDSQJStatus();
			chDevStateRtn2 = GetCommTrainTestCLDTYSJStatus();
			if ((COMM_TRAIN_TEST_DEV_STATE_VALID == chDevStateRtn) &&
				(COMM_TRAIN_TEST_DEV_STATE_INVALID == chDevStateRtn2))
			{ /*申请试车状态有效&&允许试车状态无效*/
				nonRouteId = GetNonRouteIdByIndicatorId(apply_1_Id);
				if (nonRouteId > 0u)
				{
					chNonRouteState = GetNonRouteStateById(nonRouteId);
					chNonRouteMode = GetNonRouteRunModeById(nonRouteId);
					if (NONROUTE_STATE_IDLE == chNonRouteState)
					{ /*非进路空闲*/

						SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
					}
					else if (NONROUTE_STATE_XUANPAI == chNonRouteState)
					{ /*非进路选排*/

						if (NONROUTE_RUN_MODE_APPLY == chNonRouteMode)
						{ /*试信号模式*/

							SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
						}
						else
						{
							SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
						}
					}
					else
					{
						/*无操作 */
					}
				}
				else
				{
					SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
				}
			}

			if (COMM_TRAIN_TEST_DEV_STATE_VALID == chDevStateRtn2)
			{ /*允许试车状态有效*/
				nonRouteId = GetNonRouteIdByIndicatorId(allow_1_Id);
				if (nonRouteId > 0u)
				{
					chNonRouteState = GetNonRouteStateById(nonRouteId);
					if ((NONROUTE_STATE_LOCK == chNonRouteState) ||
						(NONROUTE_STATE_OPEN == chNonRouteState))
					{ /*非进路锁闭||非进路开放*/

						if ((NONROUTE_CANCEL_FLAG_YES == GetNonRouteCancelFlagById(nonRouteId)) ||
							(NONROUTE_CANCEL_FLAG_YES == GetNonRouteHaveCancelFlagById(nonRouteId)))
						{
							SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
						}
						else
						{
							SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_YES); /*设置同意试车指示灯有效*/
						}
					}
					else
				    {
			    	     ;
				    }
				}
				else
				{
					SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
				}
			}
			else
			{
			    ;
			}

			if (COMM_TRAIN_TEST_DEV_STATE_INVALID == chDevStateRtn)
			{ /*申请试车状态无效*/
				nonRouteId = GetNonRouteIdByIndicatorId(over_1_Id);
				if (nonRouteId > 0u)
				{
					chNonRouteState = GetNonRouteStateById(nonRouteId);
					chNonRouteMode = GetNonRouteRunModeById(nonRouteId);
					if ((NONROUTE_STATE_OPEN == chNonRouteState) ||
						(NONROUTE_STATE_LOCKERR == chNonRouteState) ||
						(NONROUTE_STATE_FAULTDELAY_UNLOCK == chNonRouteState) ||
						(NONROUTE_STATE_DELAY_UNLOCK == chNonRouteState))
					{ /*非进路延时解锁||非进路开放||非进路故障锁闭||非进路故障延时解锁*/

						if (NONROUTE_RUN_MODE_APPLY == chNonRouteMode)
						{/*试信号模式*/

							SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_YES); /*设置结束试车指示灯有效*/
						}
						else
						{/*试车辆模式*/

							SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
						}

					}
					else
					{
			    		;
					}
				}
				else
				{
					SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
				}
			}
			else
			{
			    ;
			}
		}
		
	}
	else/*本联锁类型不是车辆段*/
	{	
		if (SCX_CLD_INTERFACE_RELAY == interfaceType)
		{/*试车线与车辆段采用继电器接口*/
			/* 试车线 同意试车 指示灯 由于正线不配置该指示灯，allowid = 0,因此这里进行试车线类型判断 */
			if ((allow_1_Id > 0u) && (allowRelay_1_Id > 0u))
			{
				if (RELAY_STATE_UP == GetRelayCollState(allowRelay_1_Id))
				{ /*同意试车试车继电器吸起*/
					SetIndicatorState(allow_1_Id,INDICATOR_SHOW_SC_YES);
				}
				else
				{
					SetIndicatorState(allow_1_Id,INDICATOR_SHOW_SC_NO);   /*当收不到同意试车继电器时，关闭所有信号机*/

				}        
			}
			else
			{
			    ;
			}


			/* 试车线 申请试车指示灯 */
			if ((apply_1_Id>0u) && (applyRelay_1_Id > 0u))
			{
				if (RELAY_STATE_UP == GetRelayCollState(applyRelay_1_Id))
				{ /* 申请试车 试车继电器吸起*/
					SetIndicatorState(apply_1_Id,INDICATOR_SHOW_SC_YES);
				}
				else
				{
					SetIndicatorState(apply_1_Id,INDICATOR_SHOW_SC_NO);
				}        
			}
			else
			{
			    ;
			}
		}
		else
		{/*试车线与车辆段采用通信接口*/
			if (CI_TYPE_SCX == GetLocalCiType())
			{/*联锁类型为试车线*/
				/*同意试车指示灯*/
				if (allow_1_Id > 0u)/*由于正线不配置该指示灯，allowid = 0,因此这里进行试车线类型判断*/
				{
					if (COMM_TRAIN_TEST_DEV_STATE_VALID == GetCommTrainTestSCXYSKJStatus())
					{ /*同意试车设备状态有效*/
						SetIndicatorState(allow_1_Id,INDICATOR_SHOW_SC_YES);
					}
					else
					{
						SetIndicatorState(allow_1_Id,INDICATOR_SHOW_SC_NO);   /*当收不到同意试车继电器时，关闭所有信号机*/

					}        
				}
				else
			    {
			        ;
			    }

				/* 试车线 申请试车指示灯 */
				if (apply_1_Id>0u)
				{
					if (COMM_TRAIN_TEST_DEV_STATE_VALID == GetCommTrainTestSCXSQAJStatus())
					{ /* 申请试车 设备状态有效*/
						SetIndicatorState(apply_1_Id,INDICATOR_SHOW_SC_YES);
					}
					else
					{
						SetIndicatorState(apply_1_Id,INDICATOR_SHOW_SC_NO);
					}        
				}
				else
			    {
			        ;
			    }

			}
			else
			{
			      ;
			}
		}
	}
}


/*
* 功能描述： 指示器状态处理
* 参数说明： void
* 返回值  ： void 
*/
void IndicatorStateProc_UseVirCI(UINT8 virCIid)
{
	UINT8 devCurSum = 0u;  /*设备总数*/
	UINT8 devId = 0u; /*设备ID*/
	UINT8 devType = 0u; /*设备类型*/
	UINT8 devRelaySum = 0u; /*设备继电器总数*/
	UINT16* pDevRelayIdBuf = NULL; /*继电器IDbuf*/
	UINT8 belongVirCIid = 0u;
	UINT8 avalibleFlag = 0u;

	UINT16 apply_1_Id = 0u; /*申请试车灯ID*/
	UINT16 allow_1_Id = 0u; /*允许试车灯ID*/
	UINT16 over_1_Id = 0u; /*结束试车灯ID*/

	UINT16 apply_2_Id = 0u; /*申请试车灯ID*/
	UINT16 allow_2_Id = 0u; /*允许试车灯ID*/
	UINT16 over_2_Id = 0u; /*结束试车灯ID*/
	UINT16 jkj_valid_Id = 0u; /*应急盘继电器有效灯ID*/

	UINT16 sysFirstId = 0u; /*平台一系ID*/
	UINT16 sysSecondId = 0u; /*平台二系ID*/
	UINT8 computerId = 0u; /*平台计算机ID*/
	UINT8 runMode = 0u; /*运行模式*/
	UINT8 selfState = 0u; /*本机状态*/
	UINT8 otherState = 0u; /*其他机器状态*/
	UINT16 applyRelay_1_Id = 0u; /*申请试车继电器1 ID*/
	UINT16 allowRelay_1_Id = 0u; /*允许试车继电器1 ID*/

	UINT16 applyRelay_2_Id = 0u; /*申请试车继电器2 ID*/
	UINT16 allowRelay_2_Id = 0u; /*允许试车继电器2 ID*/

	UINT8 faultFlag = 0u;/*故障标志 0为未故障*/
	UINT8 ii = 0u;
	UINT16 jj = 0u;
	UINT16 kk = 0u;/*索引*/
	UINT16 deviceCurSum = 0u;	 /*道岔总数目*/
	UINT16 deviceId = 0u;	     /*道岔ID*/
	UINT8 interfaceType = 0u;	/*试车线与车辆段接口方式*/

	UINT8 leuNum = 0u;/*与本CI通信的LEU数量*/
	UINT8 leuState = 0u;/*LEU状态*/

	UINT16 nonRouteId = 0u;/*非进路id*/
	UINT8 jkjRelayValidFlag = 0u;

	UINT8 relayConfirmFlag = 0u;/*继电接口确认标志*/

	UINT8 redDsFlag = 0u;  /*红灯断丝*/
	UINT8 greenDsFlag = 0u;  /*绿灯断丝*/
	UINT8 yellowDsFlag = 0u;  /*黄灯断丝*/
	UINT8 whiteDsFlag = 0u;  /*白灯断丝*/
	UINT8 redYellowDsFlag= 0u;      /*红黄灯断丝*/
	UINT8 redWhiteDsFlag= 0u;       /*红白灯断丝*/
	UINT8 greenYellowDsFlag= 0u;    /*绿黄灯断丝*/
	UINT8 doubleGreenDsFlag= 0u;    /*双绿灯断丝*/
    UINT8 doubleYellowDsFlag = 0u;  /*双黄灯断丝*/

	UINT8  nonRouteState = 0u; /*非进路状态*/
	UINT8 relayCollState = 0u;/*继电器采集*/
	UINT8 relayDrivState = 0u;/*继电器驱动*/
	UINT8 stopCheckFlag = 0u;
	UINT8 dianshiLinshixiansuFlag =  GetCiFunctionSwitchConfig(FUNC_DIANSHI_LINSHIXIANSU_FLAG);/*点式临时限速*/
	UINT8 singleSwitchCurPosition = 0u;
	UINT8 checkReVal = 0u;
	UINT8 garagedoorFaultState = 0u;/*车库门状态*/
	UINT8 localCiType = 0u;
	UINT16 signalNum = 0u;
	UINT8 commState = 0u;
	UINT8 startFLockFlag = 0u;
	UINT8 virCIAllSwitchYLockState = 0u;
	UINT8 startLockFlag = 0u;
	UINT8 VirCILabourCancelLinShiXianSta = 0u;
	UINT8 psdButtonState = 0u;
	UINT8 psdVirtualAttribute = 0u;
	UINT32 psdIsolateState = 0u;
	UINT8 virtualZDZFButtonState = 0u;
	UINT8 allSignalBrightState = 0u;
	UINT8 autoTriggerFlag = 0u;
	UINT8 applyRelayCollState = 0u;
	UINT8 allowRelayCollState = 0u;
	UINT8 NonRouteState = 0u; 
	UINT8 NonRouteRunMode = 0u;
	UINT8 NonRouteCancelFlag = 0u;
	UINT8 NonRouteHaveCancelFlag = 0u;

	UINT8 CommTrainTestCLDSQJStatus= 0u;
	UINT8 CommTrainTestCLDTYSJStatus = 0u;

	UINT8 CommTrainTestSCXYSKJStatus = 0u;
	UINT8 CommTrainTestSCXSQAJStatus = 0u;
	UINT8 switchBlockLinkState = 0u;
	UINT8 relayHunXianState = 0u;
	UINT16 RelayId = 0u;
	UINT8 relayBelongCi = 0u;
	UINT16 relaySum = 0u;
	UINT8 localCiId = 0u;
	UINT8 chBjdDeviceId = 0U;/*报警灯设备ID*/
	UINT8 chNonReturnAdhesionState = 0U;/*无人折返粘连状态*/
	UINT8 cCommAxisNum = 0U;
	UINT8 mm = 0U;
	UINT8 commStatus = 0U;

	devCurSum = GetVirCIIndicatorConfigDataNum(virCIid); /*获取指示器当前总数*/
	interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*获取试车线与车辆段接口方式*/ 
	localCiId = GetSystemParaLocalCiId();

	for (ii = 0u; ii < devCurSum; ii++)
	{
		devRelaySum = 0u;
		pDevRelayIdBuf = NULL;

		devId = GetVirCIlocalCiIndicatorId(virCIid,ii);/*获取指示器ID*/
		devType = GetVirCIIndicatorType(virCIid,devId); /*获取设备类型*/
		chBjdDeviceId = GetVirCIIndicatorDevId(virCIid,devId);

		avalibleFlag = GetVirCIIndicConfDataAvalFlag(virCIid,devId);/*指示灯配置开关*/

		/*###【报警灯】###*/
		if ((INDICATOR_TYPE_ALARM_RONGSI == devType) ||
			(INDICATOR_TYPE_ALARM_GDGZ == devType)   ||
			(INDICATOR_TYPE_ALARM_RONGSI_qujian2 == devType)
			)
		{ /*熔丝报警 || 轨道故障报警*/

			devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf*/

			if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
			{
				SetVirCIIndicatorState(virCIid,devId,INDICATOR_SHOW_YES); /*设置报警*/
				
			}
			else
			{
				relayCollState =  GetRelayCollState(pDevRelayIdBuf[0]);
				if (RELAY_STATE_UP == relayCollState)
				{ /*报警继电器吸起*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置报警*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置无报警*/
				}
			}
		}
		else if ((INDICATOR_TYPE_POWER_SCREEN == devType)||
			 (INDICATOR_TYPE_ALARM_XICHEJI == devType)||
			(INDICATOR_TYPE_READY_XICHEJI == devType)   ||
			(INDICATOR_TYPE_ALARM_DUANSI_qujian2 == devType) ||
			(INDICATOR_TYPE_POWER_SCREEN_qujian2 == devType)
			)
		{/* 电源屏报警 || 洗车机报警 继电器落下 报警 || 洗车机就绪状态*/

			devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf*/

			if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置报警*/
			}
			else
			{
				relayCollState = GetRelayCollState(pDevRelayIdBuf[0]);
				if (RELAY_STATE_UP == relayCollState)
				{ /*报警继电器吸起*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置无报警*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置报警*/
				}
			}
		}
		else if (INDICATOR_TYPE_ALARM_DUANSI == devType)
		{/*断丝报警 */
			
			SignaDsBreakAlarmIndicator_Vir(virCIid,devId);
		}
		else if (INDICATOR_TYPE_ALARM_GDTD == devType)
		{ /*轨道停电报警*/

			devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf*/
			SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*初始化无报警*/

			if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置报警*/
			}
			else
			{
				for (jj = 0u; jj < devRelaySum; jj++)
				{
					relayCollState = GetRelayCollState(pDevRelayIdBuf[jj]);
					if (RELAY_STATE_DOWN == relayCollState)
					{ /*继电器落下*/

						SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置报警*/
						break;
					}
				}
			}
		}
		else if ((INDICATOR_TYPE_UPS_FAULT == devType) || 
			(INDICATOR_TYPE_UPS2_FAULT == devType)
			)
		{ /*UPS指示灯 或 UPS2指示灯*/

			devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf*/

			if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置UPS指示灯有效，数据错误*/
			}
			else
			{
				relayCollState =  GetRelayCollState(pDevRelayIdBuf[0]);
				if (RELAY_STATE_UP == relayCollState)
				{ /*继电器吸起*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置UPS指示灯无效*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置UPS指示灯有效*/
				}
			}
		}

		/*###【指示灯】###*/
		else if ((INDICATOR_TYPE_EXPRESS_MAINP == devType) ||(INDICATOR_TYPE_EXPRESS_BACKP == devType)
		      || (INDICATOR_TYPE_EXPRESS_MAINP_2 == devType) || (INDICATOR_TYPE_EXPRESS_BACKP_2 == devType))
		{ /*主电源指示灯 || 副电源指示灯*/

			devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf*/

			if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置电源报警*/
			}
			else
			{
				relayCollState =  GetRelayCollState(pDevRelayIdBuf[0]);
				if (RELAY_STATE_UP == relayCollState)
				{ /*继电器吸起*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置电源有效*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置电源报警*/
				}
			}
		}
		else if ((INDICATOR_TYPE_EXPRESS_ZHAOCHA1 == devType) || 
			(INDICATOR_TYPE_EXPRESS_ZHAOCHA2 == devType) || 
			(INDICATOR_TYPE_EXPRESS_ZHAOCHA3 == devType) || 
			(INDICATOR_TYPE_EXPRESS_ZHAOCHA4 == devType) || 
			(INDICATOR_TYPE_EXPRESS_ZHAOCHA5 == devType)) 
		{ /*照查指示灯*/

			SetZhaoChaIndictorComSta_Vir(virCIid,devId);		
		}
		else if (INDICATOR_TYPE_EXPRESS_2OO2_I == devType)
		{ /*一系工作状态指示灯*/

			sysFirstId = devId;/*后面处理*/
		}
		else if (INDICATOR_TYPE_EXPRESS_2OO2_II == devType)
		{ /*二系工作状态指示灯*/

			sysSecondId = devId;/*后面处理*/
		}
		else if ((INDICATOR_TYPE_EXPRESS_NONROUTE == devType) || (INDICATOR_TYPE_EXPRESS_NONROUTE_2 == devType))
		{ /*非进路调车1 或 非进路调车2*/

			devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf*/

			if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置非进路指示灯有效，数据错误*/
			}
			else
			{
				nonRouteState = GetNonRouteStateById((UINT8)(pDevRelayIdBuf[0]));
				if (NONROUTE_STATE_IDLE == nonRouteState)
				{
					/*未办理非进路调车*/
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NONROUTE_NOSET); /*设置指示灯有效*/
				}
				else if ((NONROUTE_STATE_LOCK == nonRouteState) ||
					(NONROUTE_STATE_LOCKERR == nonRouteState) ||
					(NONROUTE_STATE_OPEN == nonRouteState))/*非进路锁闭/故障锁闭/非进路开放*/
				{
					/*非进路锁闭*/
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NONROUTE_LOCK); /*设置指示灯无效*/
				}
				else
				{
					/* 非进路正在锁闭或延时解锁期间*/
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NONROUTE_SETING); /*设置指示灯无效*/
				}
			}
		}
		else if (INDICATOR_TYPE_EXPRESS_STOP_CHECK == devType)
		{ /*停止检查状态指示灯*/
			stopCheckFlag = GetStopCheckFlag();
			if (ROUTE_STOPCHECK_SET_YES == stopCheckFlag)
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
		}
		else if (INDICATOR_TYPE_SWITCH_JICHA == devType)
		{ /*道岔挤岔状态指示灯*/
			deviceCurSum = GetSwitchCurSum();
			for (jj = 0u; jj < deviceCurSum; jj++)
			{
				deviceId = GetSwitchId(jj);
				belongVirCIid = GetSwitchBelongVirCiId(deviceId);
				singleSwitchCurPosition =  GetSingleSwitchCurPosition(deviceId);
				checkReVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, deviceId);
				if ((SWITCH_POSITION_JICHA == singleSwitchCurPosition) && (CI_TRUE == checkReVal)&&(belongVirCIid == virCIid))
				{  /*对房山线的道岔不报警*/
					break;
				}
			}

			if (deviceCurSum == jj)
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
			}
		}		
		else if (INDICATOR_TYPE_GD_DAD == devType)
		{ /*车库门故障指示灯*/
			deviceCurSum = GetGaragedoorSum();
			if(INDICATOR_DATA_RELAY == avalibleFlag)
			{
				for (jj = 0u; jj < deviceCurSum; jj++)
				{
					deviceId = GetGaragedoorId(jj);
					garagedoorFaultState = GetGaragedoorFaultState(deviceId);
					if (GARAGE_DOOR_FAULT_TRUE == garagedoorFaultState)
					{
						break;
					}
				}

				if (deviceCurSum == jj)
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
				}
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			
		}
		else if (INDICATOR_TYPE_EXPRESS_SC_APP == devType)
		{ /*申请试车指示灯1*/
			nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid,devId);
			if (0u < nonRouteId)
			{
				localCiType = GetLocalCiType();
				if(CI_TYPE_SCX == localCiType)
				{
					/* 试车线 */
					apply_1_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						applyRelay_1_Id = GetSCXDrvApplyTryRelayIdById((UINT8)nonRouteId); /*申请试车继电器ID*/
					}	
				}
				else
				{
					/* 车辆段 */
					apply_1_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						applyRelay_1_Id = GetNonRouteAppTryRelayIdById((UINT8)nonRouteId); /*申请试车继电器ID*/
					}	
				}
			}

		}
		else if (INDICATOR_TYPE_EXPRESS_SC_APP_2 == devType)
		{ /*申请试车指示灯2*/
			nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid,devId);
			if (0u < nonRouteId)
			{

				if(CI_TYPE_SCX == GetLocalCiType())
				{
					/* 试车线 */
					apply_2_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						applyRelay_2_Id = GetSCXDrvApplyTryRelayIdById((UINT8)nonRouteId); /*申请试车继电器ID*/
					}	
				}
				else
				{
					/* 车辆段 */
					apply_2_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						applyRelay_2_Id = GetNonRouteAppTryRelayIdById((UINT8)nonRouteId); /*申请试车继电器ID*/
					}	
				}
			}

		}
		else if (INDICATOR_TYPE_EXPRESS_SC_ALW == devType)
		{ /*允许试车指示灯1*/

			nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid,devId);
			if (0u < nonRouteId)
			{
				localCiType = GetLocalCiType();
				if(CI_TYPE_SCX == localCiType)
				{
					allow_1_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						allowRelay_1_Id = GetSCXColAgreeTryRelayIdById((UINT8)nonRouteId); /*允许试车继电器1ID*/
					}	
				}
				else
				{	/* 车辆端 */
					allow_1_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						allowRelay_1_Id = GetNonRouteAgreeTryRelayIdById((UINT8)nonRouteId); /*允许试车继电器1ID*/
					}		
				}
			}
		}
		else if (INDICATOR_TYPE_EXPRESS_SC_ALW_2 == devType)
		{ /*允许试车指示灯2*/

			nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid,devId);
			if (0u < nonRouteId)
			{
				localCiType = GetLocalCiType();
				if(CI_TYPE_SCX == localCiType)
				{
					allow_2_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						allowRelay_2_Id = GetSCXColAgreeTryRelayIdById((UINT8)nonRouteId); /*允许试车继电器2ID*/
					}	
				}
				else
				{	/* 车辆端 */
					allow_2_Id = devId;
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口*/
						allowRelay_2_Id = GetNonRouteAgreeTryRelayIdById((UINT8)nonRouteId); /*允许试车继电器2ID*/
					}		
				}
			}
		}
		else if (INDICATOR_TYPE_EXPRESS_SC_END == devType)
		{ /*结束试车指示灯1*/

			over_1_Id = devId;
		}
		else if (INDICATOR_TYPE_EXPRESS_SC_END_2 == devType)/*结束试车指示灯2*/
		{ 
			over_2_Id = devId;
		}
		else if (INDICATOR_TYPE_JKJ_VALID == devType)/*应急盘继电器有效指示灯*/
		{
			jkj_valid_Id = devId;
		}
		else if (INDICATOR_TYPE_SIGNAL_FAULT_CLOSE == devType)
		{/*信号机故障关闭报警*/
			signalNum = GetSignalCurSum();
			for (jj = 0u; jj < signalNum; jj++)
			{
				deviceId = GetSignalId(jj);
				belongVirCIid = GetSignalBelongVirCiId(deviceId);
				/*获取灯丝断丝状态*/
			    redDsFlag = GetSignalDsBreakFlag(deviceId);
			    greenDsFlag = GetSignalGreenDsBreakFlag(deviceId);
			    yellowDsFlag = GetSignalYellowDsBreakFlag(deviceId);
			    whiteDsFlag = GetSignalWhiteDsBreakFlag(deviceId);
				redYellowDsFlag = GetSignalRedYellowDsBreakFlag(deviceId);
				redWhiteDsFlag = GetSignalRedWhiteDsBreakFlag(deviceId);
				greenYellowDsFlag = GetSignalGreenYellowDsBreakFlag(deviceId);
				doubleGreenDsFlag = GetSignalDoubleGreenDsBreakFlag(deviceId);
				doubleYellowDsFlag = GetSigDoubleYellowDsBreakFlag(deviceId);

				checkReVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, deviceId);
				if (((SIGNAL_DS_BREAK_YES == redDsFlag) || (SIGNAL_DS_BREAK_YES == greenDsFlag)
					|| (SIGNAL_DS_BREAK_YES == yellowDsFlag) || (SIGNAL_DS_BREAK_YES == whiteDsFlag)
					|| (SIGNAL_DS_BREAK_YES == redYellowDsFlag) || (SIGNAL_DS_BREAK_YES == redWhiteDsFlag)
					|| (SIGNAL_DS_BREAK_YES == greenYellowDsFlag) || (SIGNAL_DS_BREAK_YES == doubleGreenDsFlag)
					|| (SIGNAL_DS_BREAK_YES == doubleYellowDsFlag))
					&& (CI_TRUE == checkReVal)&&(virCIid == belongVirCIid))
				{/*信号机存在故障关闭*/

					faultFlag = 1u;/*信号机故障标志*/
					break;
				}
			}

			if (0u == faultFlag)
			{/*信号机未故障*/

				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO);/*设置指示灯无效*/
			}
			else
			{/*信号机故障*/

				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES);/*设置指示灯有效*/
			}

		}
		else if (INDICATOR_TYPE_CIDEVICE_FAULT == devType)
		{/*联锁设备故障报警*/
			commState = Get2oo2CiAndIoCommState();
			if (TRANSMIT_2OO2_STATE_GOOD == commState)
			{/*IO 通信良好*/

				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_IOCOMM_OK);/*设置指示灯通信良好*/
			}
			else
			{/*IO 通信故障*/

				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_IOCOMM_BAD);/*设置指示灯通信故障*/
			}
			
			
		}
		else if (INDICATOR_TYPE_EXPRESS_RETURN == devType)
		{/*无人折返灯指示灯*/
			if(INDICATOR_DATA_RELAY ==avalibleFlag)
			{
				devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
				pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId);/*获取相关继电器ID buf*/

				if ((3u !=devRelaySum)||(NULL ==pDevRelayIdBuf))
				{/*数据不对*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_NORMAL);/*设置表示灯常态*/
				}
				else
				{
					relayDrivState = GetRelayDriveState(pDevRelayIdBuf[0]);
					if (RELAY_STATE_UP == relayDrivState)
					{/*闪灯驱动吸起*/
						relayDrivState = GetRelayDriveState(pDevRelayIdBuf[1]); 
						if (RELAY_STATE_DOWN == relayDrivState)
						{

							SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_FLASH);/*设置表示灯闪灯*/
						}
						else
						{
							/*稳灯驱动吸起 错误情况*/
							SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_NORMAL);/*设置表示灯常态*/
						}
					}
					else if (RELAY_STATE_DOWN == relayDrivState)
					{/*闪灯驱动落下*/
						relayDrivState = GetRelayDriveState(pDevRelayIdBuf[1]);
						if (RELAY_STATE_UP == relayDrivState)
						{/*稳灯驱动吸起*/

							SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_LIGHT);/*设置表示灯稳灯*/
						}
						else
						{
							SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_NORMAL);/*设置表示灯常态*/
						}
					}
					else
					{
						/*其他情况*/
						SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_NORMAL);/*设置表示灯常态*/
					}
				}	
			}
			else
			{
				/*其他情况*/
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_NORMAL);/*设置表示灯常态*/
			}
			
					
		}
		else if (INDICATOR_TYPE_AUTORTN_ADHESION == devType)
		{
			/*无人折返按钮粘连状态指示灯*/
			chNonReturnAdhesionState = CheckNonReturnExistAdhesion(chBjdDeviceId);
			if (RTN_RELAY_ADHESION_YES == chNonReturnAdhesionState)
			{
				SetVirCIIndicatorState(virCIid, devId, INDICATOR_SHOW_YES);/*设置表示灯有效*/
			}
			else
			{
				SetVirCIIndicatorState(virCIid, devId, INDICATOR_SHOW_NO);/*设置表示灯有效*/
			}


		}
		else if (INDICATOR_TYPE_COMM_LEU == devType)
		{/*与LEU通信状态*/



			leuNum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_LEU);
			for (kk =0u;kk<leuNum;kk++)
			{
				leuState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_LEU, (UINT8)kk);

				if ((INDICATOR_TYPE_LEU_FAULT_NO == leuFaultFlag) && ((TRANSMIT_2OO2_STATE_LINK == leuState) 
					|| (TRANSMIT_2OO2_STATE_GOOD == leuState)))
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_GREEN);/*设置指示灯通信良好*/
				}
				else
				{/*LEU 通信故障*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_RED);/*设置指示灯通信故障*/
					break;/*有一个故障，就认为与LEU通信故障，在此打断循环*/
				}
			}
			
		}
		else if (INDICATOR_TYPE_COMM_ZC == devType)
		{/*与ZC通信状态*/
			commState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_ZC,0u);
			if (TRANSMIT_2OO2_STATE_GOOD == commState)
			{/*ZC 通信良好*/

				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_GREEN);/*设置指示灯通信良好*/
			}
			else if (TRANSMIT_2OO2_STATE_LINK == commState)
			{/*ZC 通信一般*/

				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_YELLOW);/*设置指示灯通信一般*/
			}
			else
			{/*ZC 通信故障*/

				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_RED);/*设置指示灯通信故障*/
			}
		}
		else if ((INDICATOR_TYPE_COMM_CI_FIRST <= devType)
			&& (INDICATOR_TYPE_COMM_CI_LAST >= devType))
		{/*第devType-INDICATOR_TYPE_COMM_CI_FIRST+1个相邻联锁通信状态*/

			devRelaySum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_CI);
			jj = devType - INDICATOR_TYPE_COMM_CI_FIRST;
			if (devRelaySum > jj)
			{
				commState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_CI,(UINT8)jj);
				if (TRANSMIT_2OO2_STATE_GOOD == commState)
				{/*上第jj+1个相邻联锁 通信良好*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_GREEN);/*设置指示灯通信良好*/
				}
				else if (TRANSMIT_2OO2_STATE_LINK == commState)
				{/*第jj+1个相邻联锁 通信一般*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_YELLOW);/*设置指示灯通信一般*/
				}
				else
				{/*第jj+1个相邻联锁 通信故障*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_RED);/*设置指示灯通信中断*/
				}
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_RED);/*设置指示灯通信中断*/
			}
		}
		else if (INDICATOR_TYPE_STATUS_START_FLOCK == devType)
		{/* 全站封锁 */
			startFLockFlag = GetStartFLockFlag();
			if (CI_START_FLOCK_YES == startFLockFlag)
			{
				/* 显示全站封锁状态 */
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_FLOCAK_YES);/*设置全站封锁显示有效*/
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_FLOCAK_NO);/*设置全站封锁显示无效*/
			}
		}
		else if (INDICATOR_TYPE_YINDAOZONGSUO == devType)
		{/* 引导总锁状态*/
            virCIAllSwitchYLockState = GetVirCIAllSwitchYLockState(virCIid);
			if (SWITCH_LOCK_YINZONG_YES == virCIAllSwitchYLockState)
			{
				/* 显示引导总锁状态*/
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES);/*设置引导总锁有效*/
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO);/*设置引导总锁无效*/
			}

		}
		else if (INDICATOR_TYPE_STATUS_START_LOCK == devType)
		{
			/* 上电解锁状态 */
            startLockFlag =  GetStartLockFlag();
			if (CI_START_LOCK_NO == startLockFlag)
			{
				/* 显示全站封锁状态 */
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_STARTLOCK_YES);/*上电解锁显示无效*/
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_STARTLOCK_NO);
			}
		}	
		else if ((INDICATOR_TYPE_COMM_PSD_START <= devType) && (devType <= INDICATOR_TYPE_COMM_PSD_FIFTH))
		{
			/* PSD 通信状态处理 */
			avalibleFlag = GetVirCIIndicConfDataAvalFlag(virCIid,devId);
			if (INDICATOR_DATA_VALID != avalibleFlag)
			{
				/* 有效下状态设置 */
				SetPSDCommonState_UseVirCI(virCIid,devId,devType);
			}
		}
		else if (INDICATOR_TYPE_STATUS_DISPLAY_LINSHIXIANSU == devType)
		{
			if(HAVE_DIANSHILINSHIXIANSU == dianshiLinshixiansuFlag)
			{
				/* 设置人工取消临时限速按钮显示与否 */
				VirCILabourCancelLinShiXianSta = GetVirCILabourCancelLSXianSta(virCIid);
				if (LINSHIXIANSU_COMM_BAD_STATE == VirCILabourCancelLinShiXianSta)
				{
					/* 显示人工取消临时限速按钮 */
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_LIMIT_YES);
				}
				else
				{   /* 不显示人工取消临时限速按钮 */
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_LIMIT_NO);
				}
			}
			else
			{
				/* 不显示人工取消临时限速按钮 */
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_LIMIT_NO);
			}

		}
		else if (INDICATOR_TYPE_STATUS_CI_MODE == devType)
		{ /*工作模式指示灯*/
			SetCiModeIndicatorState_Vir(virCIid,devId);

		}
		else if ((INDICATOR_TYPE_PCB1 == devType) ||(INDICATOR_TYPE_PCB2 == devType) || 
			(INDICATOR_TYPE_PCB3 == devType) ||(INDICATOR_TYPE_PCB4 == devType) ||
			(INDICATOR_TYPE_PCB5 == devType) ||(INDICATOR_TYPE_PCB6 == devType))
		{/*PCB按钮状态指示灯*/
			devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf*/

			if ((0u != devRelaySum) && (NULL != pDevRelayIdBuf))
			{/*相关设备有效*/
				psdButtonState = GetPsdButtonState(pDevRelayIdBuf[0]);
				psdVirtualAttribute = GetPsdVirtualAttribute(pDevRelayIdBuf[0]);
				if ((PSD_BUTTON_STATE_DOWN == psdButtonState) && 
					(PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute))
				{ /*虚拟PSD的PCB按下*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置按钮状态表示灯有效*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
				}
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
			}	
		}
		else if ((INDICATOR_TYPE_PSD1_ISOLATE == devType) ||(INDICATOR_TYPE_PSD2_ISOLATE == devType) || 
			(INDICATOR_TYPE_PSD3_ISOLATE == devType) ||(INDICATOR_TYPE_PSD4_ISOLATE == devType) ||
			(INDICATOR_TYPE_PSD5_ISOLATE == devType) ||(INDICATOR_TYPE_PSD6_ISOLATE == devType))
		{/*PSD故障隔离状态指示灯*/
			devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf*/

			if ((0u != devRelaySum) && (NULL != pDevRelayIdBuf))
			{/*相关设备有效*/
				psdIsolateState = GetPsdIsolateState(pDevRelayIdBuf[0]);
				psdVirtualAttribute = GetPsdVirtualAttribute(pDevRelayIdBuf[0]);
				if ((PSD_FAULT_ISOLATION_SCX == psdIsolateState) && (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute))
				{ /*虚拟PSD的故障隔离信息有效*/
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置按钮状态表示灯有效*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
				}
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
			}	
		}
		else if (INDICATOR_TYPE_AUTORTN_BTN == devType)
		{/*试车线无人折返按钮状态指示灯*/
			if(INDICATOR_DATA_RELAY ==avalibleFlag)
			{
				virtualZDZFButtonState =  GetVirtualZDZFButtonState();
				if (VIRTUAL_ZDZFAJ_BUTTON_YES == virtualZDZFButtonState)
				{/*按钮按下*/
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置按钮状态表示灯有效*/
				} 
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
				}
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置按钮状态表示灯无效*/
			}
			
		}
		else if (INDICATOR_TYPE_ALL_SIG_BRIGHT == devType)
		{/*全站点灯状态指示灯*/
			allSignalBrightState = GetVirCIAllSignalBrightState(virCIid);
			if (CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightState)
			{/*全站亮灯状态有效*/
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置全站亮灯表示灯有效*/
			} 
			else
			{/*全站亮灯状态无效*/
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置全站亮灯表示灯无效*/
			}
		}
		else if (INDICATOR_TYPE_AUTO_TRIGGE == devType)
		{   /*自动触发标志*/
			autoTriggerFlag = CheckAutoTriggerIndicatFlag(virCIid);
			if (CI_SUCCESS == autoTriggerFlag)
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置自动触发表示灯有效*/
			} 
			else
			{/*全站亮灯状态无效*/
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置自动触发表示灯无效*/
			}
		}
		else if ((INDICATOR_TYPE_XICHEJI_ALLOW_STATE == devType)
		|| (INDICATOR_TYPE_DOWNWASH_ALLOW_PASS_STATE == devType))
		{/* 非FAO线路同意洗车状态指示灯||降级模式洗车同意指示灯||降级模式洗车同意通过指示灯 */

			devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf，对应反向通过同意继电器XTJ*/
			if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			else
			{
				relayCollState = GetRelayCollState(pDevRelayIdBuf[0]);
				if (RELAY_STATE_UP == relayCollState)
				{ /*继电器吸起*/

					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
				}
			}	
		}
		else if (INDICATOR_TYPE_GENERAL_RESET_VALID == devType)
		{
			devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf，对应总复位继电器ZFWJ*/

			if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			else
			{
				relayCollState = GetRelayCollState(pDevRelayIdBuf[0]);
				if (RELAY_STATE_UP == relayCollState)
				{ /*继电器吸起*/
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
				}
			}
		}
		else if (INDICATOR_TYPE_ATS_CONFIRM_RELAY_INTERFACE == devType)
		{/*相邻联锁继电接口确认状态指示灯*/
			if(INDICATOR_DATA_RELAY ==avalibleFlag)
			{
				relayConfirmFlag = GetCiCiRelayInterfConfirmFlag();
				if (CICI_RELAY_INTERFACE_CONFIRM_YES == relayConfirmFlag)
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
				}
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
			
		}
		else if(INDICATOR_TYPE_RELAY_HUNXIAN == devType)
		{
			/*获取混线标志*/
			if(INDICATOR_DATA_RELAY ==avalibleFlag)
			{
				relaySum = GetRelayCurSum();
				for(jj = 0u; jj < relaySum;jj++)
				{                            
					RelayId = GetRelayId(jj);
					relayBelongCi = GetRelayBelongCiId(RelayId);
					if(relayBelongCi == localCiId)
					{
						relayHunXianState = GetRelayHunXianState(RelayId);
						if(RELAY_HUNXIAN_STATE_YES == relayHunXianState)
						{
							break;
						}
					}
				}
				if(RELAY_HUNXIAN_STATE_YES == relayHunXianState)
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
				}
				/*每周期用完标志后，清状态*/
				SetVirCIZfwHunxianFlag(virCIid,ZFWJ_HUN_XIAN_NO);
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效*/
			}
		}
		/*取消转辙机封连报警指示灯*/
		else if(INDICATOR_TYPE_SWITCH_BLOCK_LINK == devType)
		{
			/*获取取消封连状态*/
			switchBlockLinkState = GetCancelOrRcvrBlockLinkSta();
			if(CANCEL_SWITCH_BLOCK_LINK == switchBlockLinkState)
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置指示灯无效，此时显红色，对应取消报警*/
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置指示灯有效，此时不显颜色（或绿色）*/
			}
		}
		else if ((INDICATOR_TYPE_UPS_DCGD == devType) ||
		(INDICATOR_TYPE_UPS_DCDY == devType))
		{ /*UPS电池供电 || UPS电池电压*/

			devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
			pDevRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/

			if ((0U == devRelaySum) || (NULL == pDevRelayIdBuf))
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置红灯报警*/
			}
			else
			{
				relayCollState = GetRelayCollState(pDevRelayIdBuf[0]);
				if (RELAY_STATE_UP == relayCollState)
				{ /*继电器吸起*/

					SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置绿灯*/
				}
				else
				{
					SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置红灯*/
				}

			}

		}
		else if (INDICATOR_TYPE_COMM_AXIS == devType)
		{
		    /*与计轴子系统通信状态*/
		    cCommAxisNum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_AXIS);
			for (mm = 0U; mm < cCommAxisNum; mm++)
			{
				commStatus = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_AXIS, mm);

				if ((TRANSMIT_2OO2_STATE_LINK == commStatus) || (TRANSMIT_2OO2_STATE_GOOD == commStatus))
				{
					SetIndicatorState(devId, INDICATOR_SHOW_COMM_GREEN);  /*设置指示灯通信良好*/
				}
				else
				{
					SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED);  /*与计轴通信故障，设置指示灯通信故障*/
					break;  /*有一个故障，就认为与计轴通信故障，在此打断循环*/
				}
			}
		}
		else
		{
			/*不做处理*/
		}
	}

	/*****处理平台1、2系指示灯*****/

#ifdef PLATFORM_2OO2

	if ((sysFirstId > 0U) && (sysSecondId > 0U))
	{
		computerId = Get2oo2ComputerId(); /*获取平台计算机ID*/
		runMode = Get2oo2ProcessMode(); /*获取平台运行模式*/
		runMode |= Get2oo2OhterProcessMode();
		if ((computerId > 0U) && (runMode > 0U))
		{
			selfState = ((runMode) & ((UINT8)0xF0)) >> 4;
			otherState = (runMode) & ((UINT8)0x0F);

			if(1U == computerId)/*属于1系*/
			{
				if(0x0aU == selfState)
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_MAIN); /*设置指示灯1系为主*/
				}
				else if (0x05U == selfState)
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_BACKUP); /*设置指示灯1系为备*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯1系故障*/
				}

				if(0x0aU == otherState)
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_MAIN); /*设置指示灯2系为主*/
				}
				else if (0x05U == otherState)
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_BACKUP); /*设置指示灯2系为备*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid,(UINT8)sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯2系故障*/
				}
			}
			else if(2U == computerId)
			{
				if(0x0aU == selfState)
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_MAIN); /*设置指示灯2系为主*/
				}
				else if (0x05U == selfState)
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_BACKUP); /*设置指示灯2系为备*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯2系故障*/
				}

				if(0x0aU == otherState)
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_MAIN); /*设置指示灯1系为主*/
				}
				else if (0x05U == otherState)
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_BACKUP); /*设置指示灯1系为备*/
				}
				else
				{
					SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯1系故障*/
				}
			}
			else
			{/*不处理*/
			}
		}
		else
		{
			SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯1系故障*/
			SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*设置指示灯2系故障*/
		}
	}

#endif



	SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_NO); /*初始化申请试车指示灯无效*/
	SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id, INDICATOR_SHOW_NO); /*初始化同意试车指示灯无效*/
	SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_NO); /*初始化结束试车指示灯无效*/

	SetVirCIIndicatorState(virCIid, (UINT8)apply_2_Id, INDICATOR_SHOW_NO); /*初始化申请试车指示灯无效*/
	SetVirCIIndicatorState(virCIid, (UINT8)allow_2_Id, INDICATOR_SHOW_NO); /*初始化同意试车指示灯无效*/
	SetVirCIIndicatorState(virCIid, (UINT8)over_2_Id, INDICATOR_SHOW_NO); /*初始化结束试车指示灯无效*/

	SetVirCIIndicatorState(virCIid, (UINT8)jkj_valid_Id, INDICATOR_SHOW_NO); /*初始化应急盘指示灯无效*/
	/* 车辆段下 设置默认状态为指示灯无效*/
	localCiType = GetLocalCiType();
	if(CI_TYPE_CLD == localCiType)
	{	
		if (0u < jkj_valid_Id)
		{
			jkjRelayValidFlag = GetCiJkjFlag();                      /*JKJ应急盘继电器有效标志*/
			/*应急盘继电器有效状态*/
			if (JKJ_REYLAY_VALID == jkjRelayValidFlag)
			{
				SetVirCIIndicatorState(virCIid, (UINT8)jkj_valid_Id, INDICATOR_SHOW_YES); /*设置结束应急盘指示灯有效*/
			}
			else
			{
				SetVirCIIndicatorState(virCIid, (UINT8)jkj_valid_Id, INDICATOR_SHOW_NO); /*设置结束应急盘指示灯无效*/
			}
		}
		
		
		/*处理非进路调车相关指示灯*/
		if (SCX_CLD_INTERFACE_RELAY == interfaceType)
		{/*车辆段与试车线采用继电器接口*/
			if ((apply_1_Id > 0u) && (allow_1_Id > 0u) && (over_1_Id > 0u) && (applyRelay_1_Id > 0u) && (allowRelay_1_Id > 0u))
			{
				applyRelayCollState = GetRelayCollState(applyRelay_1_Id);
				allowRelayCollState = GetRelayCollState(allowRelay_1_Id);
				if ((RELAY_STATE_DOWN == applyRelayCollState) &&
					(RELAY_STATE_DOWN == allowRelayCollState))
				{ /*申请试车继电器落下&&允许试车继电器落下*/
					
					nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)apply_1_Id);
					if (0u <nonRouteId)
					{
						NonRouteState = GetNonRouteStateById((UINT8)nonRouteId);
						if (NONROUTE_STATE_IDLE == NonRouteState)
						{ /*非进路空闲*/

							SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
						}
						else if (NONROUTE_STATE_XUANPAI == NonRouteState)
						{ /*非进路选排*/
							NonRouteRunMode = GetNonRouteRunModeById((UINT8)nonRouteId);
							if (NONROUTE_RUN_MODE_APPLY == NonRouteRunMode)
							{ /*试信号模式*/

								SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
							}
							else
							{
								SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
							}
						}
						else
						{
							SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
						}
					}
					else
					{
						SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
					}
				}

				relayCollState = GetRelayCollState(allowRelay_1_Id);
				if (RELAY_STATE_UP == relayCollState)
				{ /*允许试车继电器吸起*/
					nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)allow_1_Id);
					if (0u < nonRouteId)
					{
						NonRouteState = GetNonRouteStateById((UINT8)nonRouteId);
						if ((NONROUTE_STATE_LOCK == NonRouteState) ||
							(NONROUTE_STATE_OPEN == NonRouteState))
						{ /*非进路锁闭||非进路开放*/
							NonRouteCancelFlag =  GetNonRouteCancelFlagById((UINT8)nonRouteId);
							NonRouteHaveCancelFlag = GetNonRouteHaveCancelFlagById((UINT8)nonRouteId);
							if ((NONROUTE_CANCEL_FLAG_YES == NonRouteCancelFlag) ||
								(NONROUTE_CANCEL_FLAG_YES == NonRouteHaveCancelFlag))
							{
								SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
							}
							else
							{
								SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id, INDICATOR_SHOW_SC_YES); /*设置同意试车指示灯有效*/
							}
						}
						else
						{
							SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
						}
					}
					else
					{
						SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
					}
				}

				relayCollState =  GetRelayCollState(applyRelay_1_Id);
				if (RELAY_STATE_UP == relayCollState)
				{ /*申请试车继电器吸起*/
					nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)apply_1_Id);
					if (nonRouteId > 0u)
					{
						NonRouteState = GetNonRouteStateById((UINT8)nonRouteId);
						if ((NONROUTE_STATE_OPEN == NonRouteState) ||
							(NONROUTE_STATE_LOCKERR == NonRouteState) ||
							(NONROUTE_STATE_FAULTDELAY_UNLOCK == NonRouteState) ||
							(NONROUTE_STATE_DELAY_UNLOCK == NonRouteState))
						{ /*非进路延时解锁||非进路开放||非进路故障锁闭||非进路故障延时解锁*/
							NonRouteRunMode = GetNonRouteRunModeById((UINT8)nonRouteId);
							if (NONROUTE_RUN_MODE_APPLY == NonRouteRunMode)
							{/*试信号模式*/

								SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_SC_YES); /*设置结束试车指示灯有效*/
							}
							else
							{/*试车辆模式*/

								SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
							}

						}
					}
					else
					{
						SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
					}
				}
			}


			if ((apply_2_Id > 0u) && (allow_2_Id > 0u) && (over_2_Id > 0u) && (applyRelay_2_Id > 0u) && (allowRelay_2_Id > 0u))
			{
				applyRelayCollState = GetRelayCollState(applyRelay_2_Id);
				allowRelayCollState = GetRelayCollState(allowRelay_2_Id);
				if ((RELAY_STATE_DOWN == applyRelayCollState) &&
					(RELAY_STATE_DOWN == allowRelayCollState))
				{ /*申请试车继电器落下&&允许试车继电器落下*/

					nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)apply_2_Id);
					if (0u < nonRouteId)
					{
						NonRouteState = GetNonRouteStateById((UINT8)nonRouteId);
						if (NONROUTE_STATE_IDLE == NonRouteState)
						{ /*非进路空闲*/

							SetVirCIIndicatorState(virCIid, (UINT8)apply_2_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
						}
						else if (NONROUTE_STATE_XUANPAI == NonRouteState)
						{ /*非进路选排*/
							NonRouteRunMode = GetNonRouteRunModeById((UINT8)nonRouteId);
							if (NONROUTE_RUN_MODE_APPLY == NonRouteRunMode )
							{ /*试信号模式*/

								SetVirCIIndicatorState(virCIid, (UINT8)apply_2_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
							}
							else
							{
								SetVirCIIndicatorState(virCIid, (UINT8)apply_2_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
							}
						}
						else
						{
							/*无操作*/
						}
					}
					else
					{
						SetVirCIIndicatorState(virCIid, (UINT8)apply_2_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
					}
				}
				relayCollState = GetRelayCollState(allowRelay_2_Id);
				if (RELAY_STATE_UP == relayCollState)
				{ /*允许试车继电器吸起*/
					nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)allow_2_Id);
					if (0u < nonRouteId)
					{
						NonRouteState = GetNonRouteStateById((UINT8)nonRouteId);
						if ((NONROUTE_STATE_LOCK == NonRouteState) ||
							(NONROUTE_STATE_OPEN == NonRouteState))
						{ /*非进路锁闭||非进路开放*/
							NonRouteCancelFlag =  GetNonRouteCancelFlagById((UINT8)nonRouteId);
							NonRouteHaveCancelFlag = GetNonRouteHaveCancelFlagById((UINT8)nonRouteId);
							if ((NONROUTE_CANCEL_FLAG_YES == NonRouteCancelFlag) ||
								(NONROUTE_CANCEL_FLAG_YES == NonRouteHaveCancelFlag))
							{
								SetVirCIIndicatorState(virCIid, (UINT8)allow_2_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
							}
							else
							{
								SetVirCIIndicatorState(virCIid, (UINT8)allow_2_Id, INDICATOR_SHOW_SC_YES); /*设置同意试车指示灯有效*/
							}
						}
					}
					else
					{
						SetVirCIIndicatorState(virCIid, (UINT8)allow_2_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
					}
				}

				relayCollState = GetRelayCollState(applyRelay_2_Id);
				if (RELAY_STATE_UP == relayCollState)
				{ /*申请试车继电器吸起*/
					nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)apply_2_Id);
					if (0u < nonRouteId)
					{
						NonRouteState = GetNonRouteStateById((UINT8)nonRouteId);
						if ((NONROUTE_STATE_OPEN == NonRouteState) ||
							(NONROUTE_STATE_LOCKERR == NonRouteState) ||
							(NONROUTE_STATE_FAULTDELAY_UNLOCK == NonRouteState) ||
							(NONROUTE_STATE_DELAY_UNLOCK == NonRouteState))
						{ /*非进路延时解锁||非进路开放||非进路故障锁闭||非进路故障延时解锁*/
							NonRouteRunMode = GetNonRouteRunModeById((UINT8)nonRouteId);
							if (NONROUTE_RUN_MODE_APPLY == NonRouteRunMode)
							{/*试信号模式*/

								SetVirCIIndicatorState(virCIid, (UINT8)over_2_Id, INDICATOR_SHOW_SC_YES); /*设置结束试车指示灯有效*/
							}
							else
							{/*试车辆模式*/

								SetVirCIIndicatorState(virCIid, (UINT8)over_2_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
							}

						}
					}
					else
					{
						SetVirCIIndicatorState(virCIid, (UINT8)over_2_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
					}
				}
			}
		}
		else
		{/*车辆段与试车线采用通信接口*/
			CommTrainTestCLDSQJStatus =  GetCommTrainTestCLDSQJStatus();
			CommTrainTestCLDTYSJStatus = GetCommTrainTestCLDTYSJStatus();
			if ((COMM_TRAIN_TEST_DEV_STATE_VALID == CommTrainTestCLDSQJStatus) &&
				(COMM_TRAIN_TEST_DEV_STATE_INVALID == CommTrainTestCLDTYSJStatus))
			{ /*申请试车状态有效&&允许试车状态无效*/
				nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)apply_1_Id);
				if (0u <nonRouteId)
				{
					NonRouteState = GetNonRouteStateById((UINT8)nonRouteId);
					if (NONROUTE_STATE_IDLE == NonRouteState)
					{ /*非进路空闲*/

						SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
					}
					else if (NONROUTE_STATE_XUANPAI == NonRouteState)
					{ /*非进路选排*/
						NonRouteRunMode = GetNonRouteRunModeById((UINT8)nonRouteId);
						if (NONROUTE_RUN_MODE_APPLY == NonRouteRunMode)
						{ /*试信号模式*/

							SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_SC_YES); /*设置申请试车指示灯有效*/
						}
						else
						{
							SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
						}
					}
					else
					{
						SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
					}
				}
				else
				{
					SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_SC_NO); /*设置申请试车指示灯无效*/
				}
			}

			CommTrainTestCLDTYSJStatus = GetCommTrainTestCLDTYSJStatus();
			if (COMM_TRAIN_TEST_DEV_STATE_VALID == CommTrainTestCLDTYSJStatus)
			{ /*允许试车状态有效*/
				nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)allow_1_Id);
				if (0u < nonRouteId)
				{
					NonRouteState =  GetNonRouteStateById((UINT8)nonRouteId);
					if ((NONROUTE_STATE_LOCK == NonRouteState) ||
						(NONROUTE_STATE_OPEN == NonRouteState))
					{ /*非进路锁闭||非进路开放*/
						NonRouteCancelFlag = GetNonRouteCancelFlagById((UINT8)nonRouteId);
						NonRouteHaveCancelFlag = GetNonRouteHaveCancelFlagById((UINT8)nonRouteId);
						if ((NONROUTE_CANCEL_FLAG_YES == NonRouteCancelFlag) ||
							(NONROUTE_CANCEL_FLAG_YES == NonRouteHaveCancelFlag))
						{
							SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
						}
						else
						{
							SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id, INDICATOR_SHOW_SC_YES); /*设置同意试车指示灯有效*/
						}
					}
				}
				else
				{
					SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id, INDICATOR_SHOW_SC_NO); /*设置同意试车指示灯无效*/
				}
			}
			CommTrainTestCLDTYSJStatus = GetCommTrainTestCLDSQJStatus();
			if (COMM_TRAIN_TEST_DEV_STATE_INVALID == GetCommTrainTestCLDSQJStatus())
			{ /*申请试车状态无效*/
				nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)over_1_Id);
				if (0u < nonRouteId)
				{
					NonRouteState = GetNonRouteStateById((UINT8)nonRouteId);
					if ((NONROUTE_STATE_OPEN == NonRouteState) ||
						(NONROUTE_STATE_LOCKERR == NonRouteState) ||
						(NONROUTE_STATE_FAULTDELAY_UNLOCK == NonRouteState) ||
						(NONROUTE_STATE_DELAY_UNLOCK == NonRouteState))
					{ /*非进路延时解锁||非进路开放||非进路故障锁闭||非进路故障延时解锁*/
						NonRouteRunMode = GetNonRouteRunModeById((UINT8)nonRouteId);
						if (NONROUTE_RUN_MODE_APPLY == NonRouteRunMode)
						{/*试信号模式*/

							SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_SC_YES); /*设置结束试车指示灯有效*/
						}
						else
						{/*试车辆模式*/

							SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
						}

					}
				}
				else
				{
					SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_SC_NO); /*设置申结束试车指示灯无效*/
				}
			}
		}
		
	}
	else/*本联锁类型不是车辆段*/
	{	
		if (SCX_CLD_INTERFACE_RELAY == interfaceType)
		{/*试车线与车辆段采用继电器接口*/
			/* 试车线 同意试车 指示灯 由于正线不配置该指示灯，allowid = 0,因此这里进行试车线类型判断 */
			if ((0u < allow_1_Id) && (0u < allowRelay_1_Id))
			{
				relayCollState = GetRelayCollState(allowRelay_1_Id);
				if (RELAY_STATE_UP == relayCollState)
				{ /*同意试车试车继电器吸起*/
					SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id,INDICATOR_SHOW_SC_YES);
				}
				else
				{
					SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id,INDICATOR_SHOW_SC_NO);   /*当收不到同意试车继电器时，关闭所有信号机*/

				}        
			}


			/* 试车线 申请试车指示灯 */
			if ((0u < apply_1_Id) && (0u < applyRelay_1_Id))
			{
				relayCollState = GetRelayCollState(applyRelay_1_Id);
				if (RELAY_STATE_UP == relayCollState)
				{ /* 申请试车 试车继电器吸起*/
					SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id,INDICATOR_SHOW_SC_YES);
				}
				else
				{
					SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id,INDICATOR_SHOW_SC_NO);
				}        
			}
		}
		else
		{/*试车线与车辆段采用通信接口*/
			localCiType = GetLocalCiType();
			if (CI_TYPE_SCX == localCiType)
			{/*联锁类型为试车线*/
				/*同意试车指示灯*/
				if (0u < allow_1_Id)/*由于正线不配置该指示灯，allowid = 0,因此这里进行试车线类型判断*/
				{
					CommTrainTestSCXYSKJStatus = GetCommTrainTestSCXYSKJStatus();
					if (COMM_TRAIN_TEST_DEV_STATE_VALID == CommTrainTestSCXYSKJStatus)
					{ /*同意试车设备状态有效*/
						SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id,INDICATOR_SHOW_SC_YES);
					}
					else
					{
						SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id,INDICATOR_SHOW_SC_NO);   /*当收不到同意试车继电器时，关闭所有信号机*/

					}        
				}

				/* 试车线 申请试车指示灯 */
				if (0u < apply_1_Id)
				{
					CommTrainTestSCXSQAJStatus = GetCommTrainTestSCXSQAJStatus();
					if (COMM_TRAIN_TEST_DEV_STATE_VALID == CommTrainTestSCXSQAJStatus)
					{ /* 申请试车 设备状态有效*/
						SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id,INDICATOR_SHOW_SC_YES);
					}
					else
					{
						SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id,INDICATOR_SHOW_SC_NO);
					}        
				}

			}
		}
	}
}
/*
* 功能描述： 非进路继电器状态处理
* 参数说明： void
* 返回值  ： void 
*修改：m by yt 2022年3月10日 修改车辆段非进路不是开放状态时，发送试车线不同意试车（继电接口：驱同意试车继电器落下；串口和网口：发送同意试车无效状态）
*/
void NonRouteRelayStateProc(void)
{
	UINT8 interfaceType = FUNC_SWITCH_UNDEF;/*试车线与车辆段接口类型*/
	UINT8 i = 0u;
	UINT16 agreeTryTrainRelayId = 0u;/*同意试车继电器ID*/
	NonRouteDataStruct* pNonRoute = NULL;
	UINT8 localCiId = 0U; /*本联锁ID*/
	UINT8 nonRouteBelongCiId = 0U; /*非进路所属联锁ID*/

	/*获取试车线与车辆段接口类型*/
	interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);
	localCiId = GetSystemParaLocalCiId();

	for (i=0;i<NONROUTE_ID_NUM_MAX;i++)
	{
		pNonRoute = GetNonRouteDataPtr()+i;
		if (NULL != pNonRoute)
		{
			if (0u != pNonRoute->NonRouteId)
			{
				nonRouteBelongCiId = GetnonRouteIdbelongCIid(pNonRoute->NonRouteId);
				/*找到本联锁非进路调车*/
				if (nonRouteBelongCiId == localCiId)
				{
					if (NONROUTE_STATE_OPEN == pNonRoute->NonRouteState)
					{ /*非进路开放*/

						if ((NONROUTE_RUN_MODE_APPLY == pNonRoute->RunMode) && (SCX_CLD_INTERFACE_RELAY == interfaceType))
						{ /*试信号模式且试车线与车辆段采用继电器接口*/
							agreeTryTrainRelayId = GetNonRouteAgreeTryRelayIdById(pNonRoute->NonRouteId);
							(void)SetRelayDriveState(agreeTryTrainRelayId, RELAY_DRIVE_STATE_UP); /*设置同意试车继电器吸起*/
						}
						else if ((NONROUTE_RUN_MODE_APPLY == pNonRoute->RunMode) && (SCX_CLD_INTERFACE_COMM == interfaceType))
						{/*试信号模式且试车线与车辆段采用通信接口*/
							SetCommTrainTestCLDTYSJStatus(COMM_TRAIN_TEST_DEV_STATE_VALID);/*设置TYSJ状态有效*/
						}
						else if ((NONROUTE_RUN_MODE_APPLY == pNonRoute->RunMode) && (SCX_CLD_SERIAL_PORT_COMM == interfaceType))
						{/*试信号模式且试车线与车辆段采用串口接口*/
							SetCommTrainTestCLDTYSJStatus(COMM_TRAIN_TEST_DEV_STATE_VALID);/*设置TYSJ状态有效*/
						}
						else
						{
							/*不处理*/
						}
					}
					else
					{/*车辆段非进路不是开放状态时，发送试车线不同意试车（继电接口：驱同意试车继电器落下；串口和网口：发送同意试车无效状态）*/

						if (SCX_CLD_INTERFACE_RELAY == interfaceType)
						{/*继电器接口*/
							/*驱动非进路同意试车继电器落下  非进路同意试车继电器常态落下，相当于恢复默认态*/
							agreeTryTrainRelayId = GetNonRouteAgreeTryRelayIdById(pNonRoute->NonRouteId);
							(void)SetRelayDriveState(agreeTryTrainRelayId, RELAY_DRIVE_STATE_DOWN);
						}
						else if ((SCX_CLD_INTERFACE_COMM == interfaceType) || (SCX_CLD_SERIAL_PORT_COMM == interfaceType))
						{
							SetCommTrainTestCLDTYSJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID);/*设置TYSJ状态无效*/
						}
						else
						{
							; /*不处理*/
						}
					}

					break;
				}
			}

		}
	}

	#if 0
	if ((NONROUTE_STATE_LOCK == GetNonRouteState()) ||
		(NONROUTE_STATE_OPEN == GetNonRouteState()))
	{ /*非进路锁闭||非进路开放*/

		if ((NONROUTE_RUN_MODE_APPLY == GetNonRouteRunMode()) && (SCX_CLD_INTERFACE_RELAY == interfaceType))
		{ /*试信号模式且试车线与车辆段采用继电器接口*/

			(void)SetRelayDriveState(GetNonRouteAgreeTryTrainRelayId(), RELAY_STATE_UP); /*设置同意试车继电器吸起*/
		}
		else if ((NONROUTE_RUN_MODE_APPLY == GetNonRouteRunMode()) && (SCX_CLD_INTERFACE_COMM == interfaceType))
		{/*试信号模式且试车线与车辆段采用通信接口*/
			SetCommTrainTestCLDTYSJStatus(COMM_TRAIN_TEST_DEV_STATE_VALID);/*设置TYSJ状态有效*/
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		/*不处理*/
	}
	#endif
}

/*
* 功能描述： 计时反馈数据处理
* 参数说明： void
* 返回值  ：    
*/
void TimeDataFeedBackProcess(void)
{
	UINT16 deviceId = 0u;    /*设备ID*/
	UINT16 deviceSum = 0u;   /*设备总数*/
	UINT16 ii = 0u;          /*游标*/
	UINT8 localCiId = 0u;
	UINT8 chComCycNumForCiToXianDi = 0U;/*联锁到其他通信周期记录*/
	UINT8 wFloodGateBelongCiId = 0U;	/*防淹门所属联锁ID*/

	localCiId = GetSystemParaLocalCiId();
	chComCycNumForCiToXianDi = GetComCycNumForCiToOtherSys(LastCmdSourceSysType);
	if (0U == chComCycNumForCiToXianDi)
	{
		/*总人解和引导信号内方第一区段故障倒计时反馈*/
		deviceSum = GetRouteCurSum();/*进路总数*/
		for (ii = 0u; ii < deviceSum; ii++)
		{
			deviceId = GetRouteId(ii);/*进路ID*/
			if (localCiId == GetRouteBelongCiId(deviceId))
			{/*执行进路相关计时反馈数据计算*/
				RouteTimeDataBackProcess(deviceId);
			}
		}
		/*处理物理区段倒计时*/
		deviceSum = GetTotalPhySecCurNum();/*物理区段总数*/
		for (ii = 0u; ii < deviceSum; ii++)
		{
			deviceId = GetPhySecId(ii);/*物理区段ID*/
			/*区故解延时解锁*/
			PhySecTimeDataBackProcess(deviceId);
		}
		/*保护区段延时解锁*/
		deviceSum = GetOverlapCurSum();
		for (ii = 0u; ii < deviceSum; ii++)
		{
			deviceId = GetOverlapId(ii);
			OverlapTimeDataBackProcess(deviceId);
		}

		/*总复位继电器反馈倒计时处理*/
		ZFWJTimeDataBackProcess();

		for (ii = 0u; ii < NONROUTE_ID_NUM_MAX; ii++)
		{
			NonRouteDataStruct* pNonRoute = GetNonRouteDataPtr() + ii;
			/*非进路取消倒计时反馈*/
			NonRouteTimeDataBackProcess(pNonRoute);
		}

		/*防淹门延时关闭倒计时处理*/
		deviceSum = GetFloodGateCurSum();
		for (ii = 0u; ii < deviceSum; ii++)
		{
			deviceId = GetFloodGateId(ii);
			wFloodGateBelongCiId = GetFloodGateBelongCiId(deviceId);
			if (localCiId == wFloodGateBelongCiId)
			{
				FloodGateTimeDataBackProcess(deviceId);
			}
		}
	}
	else
	{/*ATS命令或现地命令均执行此检查*/
	 /*此种情况不执行，每隔一定周期后才反馈计时数据*/
		;
	}
}

/*
* 功能描述： PSD通信状态指示灯状态处理
* 参数说明： UINT16 indicatorId    指示灯ID 
*            UINT8 devType         指示灯类型
* 返回值  ：    
*/
void SetPSDCommonState(UINT16 indicatorId ,UINT8 devType)
{
	UINT8 devRelaySum = 0u; 
	UINT8 index = 0u;

	devRelaySum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_PLATFORM);  /*获取和CI通信的站台PSD系统的数量*/
	index = devType - INDICATOR_TYPE_COMM_PSD_START;                     /*获取此指示灯在同类指示灯中的位置偏移量*/
	if (devRelaySum > index)
	{
		if (TRANSMIT_2OO2_STATE_GOOD == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_PLATFORM,(UINT8)index))
		{/*上第jj+1个站台PSD系统 通信良好*/

			SetIndicatorState(indicatorId, INDICATOR_SHOW_COMM_GREEN);   /*设置指示灯通信良好*/
		}
		else if (TRANSMIT_2OO2_STATE_LINK == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_PLATFORM,(UINT8)index))
		{/*第jj+1个站台PSD系统  通信一般*/

			SetIndicatorState(indicatorId, INDICATOR_SHOW_COMM_YELLOW);  /*设置指示灯通信一般*/
		}
		else
		{/*第jj+1个站台PSD系统  通信故障*/

			SetIndicatorState(indicatorId, INDICATOR_SHOW_COMM_RED);     /*设置指示灯通信中断*/
		}
	}
	else
	{
		SetIndicatorState(indicatorId, INDICATOR_SHOW_COMM_RED);         /*设置指示灯通信中断*/
	}
}
/*
* 功能描述： PSD通信状态指示灯状态处理
* 参数说明： UINT16 indicatorId    指示灯ID 
*            UINT8 devType         指示灯类型
* 返回值  ：    
*/
void SetPSDCommonState_UseVirCI(UINT8 virCIid,UINT8 indicatorId ,UINT8 devType)
{
	UINT8 devRelaySum = 0u; 
	UINT8 index = 0u;

	devRelaySum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_PLATFORM);  /*获取和CI通信的站台PSD系统的数量*/
	index = devType - INDICATOR_TYPE_COMM_PSD_START;                     /*获取此指示灯在同类指示灯中的位置偏移量*/
	if (devRelaySum > index)
	{
		if (TRANSMIT_2OO2_STATE_GOOD == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_PLATFORM,(UINT8)index))
		{/*上第jj+1个站台PSD系统 通信良好*/

			SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_COMM_GREEN);   /*设置指示灯通信良好*/
		}
		else if (TRANSMIT_2OO2_STATE_LINK == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_PLATFORM,(UINT8)index))
		{/*第jj+1个站台PSD系统  通信一般*/

			SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_COMM_YELLOW);  /*设置指示灯通信一般*/
		}
		else
		{/*第jj+1个站台PSD系统  通信故障*/

			SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_COMM_RED);     /*设置指示灯通信中断*/
		}
	}
	else
	{
		SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_COMM_RED);         /*设置指示灯通信中断*/
	}
}

/*
* 功能描述： 照查状态指示灯关联物理区段检查
* 参数说明： UINT16 phySecId    物理区段ID 
*   
* 返回值  ：    CI_SUCCESS  成功
CI_ERROR    失败
*/
UINT8 ZhaoChaIndictorRelPhySecCheck(UINT16 phySecId)
{

	UINT16 ii = 0u;
	UINT8 jj = 0u;
	UINT8 thatZhaoChaPhySecSum = 0u; 
	UINT16 routeId = 0u;
	UINT16  * phySecIdBuf = NULL;
	UINT16 devId = 0u;
	UINT8 devState = 0u;
	UINT8 funRetVal = 0u;
	UINT8 retVal = CI_SUCCESS;



	for(ii = 0u ;ii < GetRouteCurSum();ii++)
	{/*遍历所有进路*/
		routeId = GetRouteId(ii);
		if(GetRouteBelongCiId(routeId) == GetSystemParaLocalCiId())
		{/*此进路属于本联锁*/
			thatZhaoChaPhySecSum = GetRouteThatZhaoChaPhySecSum(routeId);  /*获取进路照查物理区段数目*/
			phySecIdBuf = GetRouteThatZhaoChaPhySecIdBuf(routeId);         /*获取进路照查物理区段ID数组*/

			if(0u != thatZhaoChaPhySecSum)
			{/*此进路配有照查区段*/
				for(jj = 0u ;jj < thatZhaoChaPhySecSum;jj++)
				{/*遍历所有的照查物理区段*/

					if(phySecIdBuf[jj] == phySecId)
					{/*找到一条此照查物理区段的宿主进路:即此物理区段被照查的进路*/
						break;
					}
				}
				if(jj < thatZhaoChaPhySecSum)
				{
					funRetVal = RoutePhySecZhaoChaCheck(routeId,phySecId,&devId,&devState);/*进行照查区段逻辑检查*/
					if(CI_ERROR == funRetVal)
					{/*此照查物理区段的一条宿主进路(本联锁)被办理,无需继续查询其他宿主进路*/
						retVal = CI_ERROR;

						break;
					}
				}
			}


		}


	}

	return retVal;

}


/*
* 功能描述： 照查状态指示灯状态处理
* 参数说明： UINT16 indicatorId    指示灯ID 
*   
* 返回值  ：    
*/
void SetZhaoChaIndictorCommonState(UINT16 indicatorId)
{
	UINT8 devRelaySum = 0u;
	UINT16 * devRelayIdBuf = NULL;
	UINT8 jj = 0u;
	if (GetIndicatorAvalibleFlag(indicatorId) == INDICATOR_DATA_VALID)
	{/*照查无效*/

		SetIndicatorState(indicatorId, INDICATOR_SHOW_NO);                   /*设置指示灯无效*/
	}
	else if (GetIndicatorAvalibleFlag(indicatorId) == INDICATOR_DATA_PHYSEC)
	{/*照查指示灯有效且物理区段相关*/

		/*初始设置*/
		SetIndicatorState(indicatorId, INDICATOR_SHOW_NO);                        /*设置指示灯无效*/

		devRelaySum = GetIndicatorRelaySum(indicatorId);                          /*获取相关照查物理区段总数*/
		devRelayIdBuf = GetIndicatorRelayIdBuf(indicatorId);                      /*获取相关照查物理区段ID数组*/

		if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
		{
			SetIndicatorState(indicatorId, INDICATOR_SHOW_YES);                   /*设置指示灯有效*/
		}
		else
		{
			for (jj = 0u; jj < devRelaySum; jj++)
			{
				if(CI_ERROR == ZhaoChaIndictorRelPhySecCheck(devRelayIdBuf[jj]))
				{
					SetIndicatorState(indicatorId, INDICATOR_SHOW_YES);                   /*设置指示灯有效*/
					break;
				}
			}

		}

	}
	else if(GetIndicatorAvalibleFlag(indicatorId) == INDICATOR_DATA_RELAY)
	{
		SetIndicatorState(indicatorId, INDICATOR_SHOW_NO);                        /*设置指示灯无效*/
		devRelaySum = GetIndicatorRelaySum(indicatorId);                          /*获取相关照查继电器总数*/
		devRelayIdBuf = GetIndicatorRelayIdBuf(indicatorId);                      /*获取相关照查继电器ID数组*/
		if ((0u == devRelaySum) || (NULL == devRelayIdBuf))
		{
			SetIndicatorState(indicatorId, INDICATOR_SHOW_YES);                   /*设置指示灯有效*/
		}
		else
		{
			for (jj = 0u; jj < devRelaySum; jj++)
			{
				if(RELAY_STATE_DOWN == GetRelayCollState(devRelayIdBuf[jj]))
				{
					SetIndicatorState(indicatorId, INDICATOR_SHOW_YES);                   /*设置指示灯有效*/
					break;
				}
			}
		}
	}
	else
	{
		SetIndicatorState(indicatorId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
	}
}

/*
* 功能描述： 照查状态指示灯状态处理
* 参数说明： UINT16 indicatorId    指示灯ID 
*   
* 返回值  ：    
*/
void SetZhaoChaIndictorComSta_Vir(UINT8 virCIid,UINT8 indicatorId)
{
	UINT8 devRelaySum = 0u;
	UINT16 * pDevRelayIdBuf = NULL;
	UINT8 jj = 0u;
	UINT8 avalibleFlag = 0u;
	UINT8 zhaoChaCheck = CI_ERROR;
	avalibleFlag = GetVirCIIndicConfDataAvalFlag(virCIid,indicatorId);
	if (INDICATOR_DATA_VALID == avalibleFlag)
	{/*照查无效*/

		SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_NO);                   /*设置指示灯无效*/
	}
	else if (INDICATOR_DATA_PHYSEC  == avalibleFlag)
	{/*照查指示灯有效且物理区段相关*/

		/*初始设置*/
		SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_NO);                        /*设置指示灯无效*/

		devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,indicatorId);                          /*获取相关照查物理区段总数*/
		pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,indicatorId);                      /*获取相关照查物理区段ID数组*/

		if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
		{
			SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_YES);                   /*设置指示灯有效*/
		}
		else
		{
			for (jj = 0u; jj < devRelaySum; jj++)
			{
				zhaoChaCheck = ZhaoChaIndictorRelPhySecCheck(pDevRelayIdBuf[jj]);
				if(CI_ERROR == zhaoChaCheck)
				{
					SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_YES);                   /*设置指示灯有效*/
					break;
				}
			}

		}

	}
	else if(INDICATOR_DATA_RELAY == avalibleFlag)
	{
		SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_NO);                        /*设置指示灯无效*/
		devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,indicatorId);                          /*获取相关照查继电器总数*/
		pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,indicatorId);                      /*获取相关照查继电器ID数组*/
		if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
		{
			SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_YES);                   /*设置指示灯有效*/
		}
		else
		{
			for (jj = 0u; jj < devRelaySum; jj++)
			{
				if(RELAY_STATE_DOWN == GetRelayCollState(pDevRelayIdBuf[jj]))
				{
					SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_YES);                   /*设置指示灯有效*/
					break;
				}
			}
		}
	}
	else
	{
		SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_YES); /*设置指示灯有效*/
	}
}



/*
* 功能描述： 联锁站控模式指示灯设置
* 参数说明： void
* 返回值  ： void   
*/
void SetCiModeIndicatorState(UINT16 indicatorId)
{
	UINT8 ciModeFlag = GetCiModeFlag();

	switch (ciModeFlag)
	{
	case CI_MODE_CONSTRA_LOCAL:	/* 强制站控 */
		SetIndicatorState(indicatorId,INDICATOR_SHOW_CI_MODE_CONSTRA_LOCAL);
		break;
	case CI_MODE_CI_LOCAL: /* 联锁控模式 */
		SetIndicatorState(indicatorId,INDICATOR_SHOW_CI_MODE_CI_LOCAL);
		break;
	case CI_MODE_ATS:	/* 遥控 */
		SetIndicatorState(indicatorId,INDICATOR_SHOW_CI_MODE_ATS);
		break;
	case CI_MODE_CONSOLE:	/* 单元控制台 */
		SetIndicatorState(indicatorId,INDICATOR_SHOW_CI_MODE_CONSOLE);
		break;
	case CI_MODE_APPLAY_LOCAL: /* 申请站控 */
		SetIndicatorState(indicatorId,INDICATOR_SHOW_CI_MODE_APPLAY_LOCAL);
		break;
	default:
		/*不可达分支*/
		break;
	}
}
/*
* 功能描述： 联锁站控模式指示灯设置
* 参数说明： void
* 返回值  ： void   
*/
void SetCiModeIndicatorState_Vir(UINT8 virCIid,UINT8 indicatorId)
{
	UINT8 ciModeFlag = GetVirCImode(virCIid);

	switch (ciModeFlag)
	{
	case CI_MODE_CONSTRA_LOCAL:	/* 强制站控 */
		SetVirCIIndicatorState(virCIid, indicatorId,INDICATOR_SHOW_CI_MODE_CONSTRA_LOCAL);
		break;
	case CI_MODE_CI_LOCAL: /* 联锁控模式 */
		SetVirCIIndicatorState(virCIid, indicatorId,INDICATOR_SHOW_CI_MODE_CI_LOCAL);
		break;
	case CI_MODE_ATS:	/* 遥控 */
		SetVirCIIndicatorState(virCIid,indicatorId,INDICATOR_SHOW_CI_MODE_ATS);
		break;
	case CI_MODE_CONSOLE:	/* 单元控制台 */
		SetVirCIIndicatorState(virCIid,indicatorId,INDICATOR_SHOW_CI_MODE_CONSOLE);
		break;
	case CI_MODE_APPLAY_LOCAL: /* 申请站控 */
		SetVirCIIndicatorState(virCIid,indicatorId,INDICATOR_SHOW_CI_MODE_APPLAY_LOCAL);
		break;
	default:
		/*不可达分支*/
		break;
	}
}


/*
* 功能描述： 根据试车线联锁试车状态驱动继电器
* 参数说明： void
* 返回值  ： 0: 更新失败
*			 1: 更新成功
*/
UINT8 TrainTestStatusToDevStateProc(void)
{
	UINT8 ret = CI_SUCCESS;
	UINT8 ciType = GetLocalCiType();
	UINT8 trainTestStatus = GetCiTrainTestStatus();
	UINT8 interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*获取试车线与车辆段接口方式*/
	UINT16 wDrvApplyTryTrainRelayId = 0U;/*试车线驱动的申请试车继电器ID*/
	UINT8 ii=0U;

	for (;ii<NONROUTE_ID_NUM_MAX;ii++)
	{
		NonRouteDataStruct *pNonRoute = GetNonRouteDataPtr() + ii;
		if (pNonRoute != NULL)
		{
		
			/* 只有试车线才需要进行状态转换 */
			if (CI_TYPE_SCX == ciType)
			{
				wDrvApplyTryTrainRelayId = GetSCXDrvApplyTryRelayIdById(pNonRoute->NonRouteId);
				if ((CI_TRAIN_TEST_START == trainTestStatus) || (CI_TRAIN_TEST_ON == trainTestStatus))
				{
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口时才驱动继电器*/
						/* 驱动试车请求继电器吸起 */
						(void)SetRelayDriveState(wDrvApplyTryTrainRelayId,RELAY_STATE_UP);
					}
					else if ((SCX_CLD_INTERFACE_COMM == interfaceType)||(SCX_CLD_SERIAL_PORT_COMM == interfaceType))
					{/*试车线与车辆段采用通信接口*/
						SetCommTrainTestSCXSQAJStatus(COMM_TRAIN_TEST_DEV_STATE_VALID);/*设置SQAJ有效，对应于继电器接口的SQAJ吸起*/
					}
					else
					{
						/*不存在的接口方式*/
					}
				}
				else 
				{
					if (SCX_CLD_INTERFACE_RELAY == interfaceType)
					{/*试车线与车辆段采用继电器接口时才驱动继电器*/
						/* 其他情况，不处于试车状态，驱动试车请求继电器落下 */
						(void)SetRelayDriveState(wDrvApplyTryTrainRelayId,RELAY_STATE_DOWN);
					}
					else if ((SCX_CLD_INTERFACE_COMM == interfaceType)||(SCX_CLD_SERIAL_PORT_COMM == interfaceType))
					{/*试车线与车辆段采用通信接口*/
						SetCommTrainTestSCXSQAJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID);/*设置SQAJ无效，对应于继电器接口的SQAJ落下*/
					}
					else
					{
						/*不存在的接口方式*/
					}
				}
			}
			else
			{
				ret = CI_SUCCESS;
			}
		}
	}

	return ret;
}


/*
* 功能描述： 虚拟照查继电器状态处理
* 参数说明： void
* 返回值  ： void      
*/
void VirtualRelayStateProc(void)
{
	UINT16 relaySum = 0u;
	UINT16 relayIndx = 0u;
	UINT16 bufIndx = 0u;
	UINT16 relayId = 0u;
	UINT8 relayVirtAttr = 0u;
	UINT8 relayDrivStat = 0u;
	UINT8 chLocalCi = GetSystemParaLocalCiId();
	UINT8 chRelayBelongCi = 0U;
	relaySum = GetTotalRelayCurNum();

	for (relayIndx = 0u; relayIndx < relaySum; relayIndx++)
	{
		relayId = GetRelayId(relayIndx);
		chRelayBelongCi = GetRelayBelongCiId(relayId);
		if (chLocalCi == chRelayBelongCi)
		{
			relayVirtAttr = GetRelayVirtAttr(relayId);

			if(RELAY_VIRTUAL_ATTR_YES == relayVirtAttr)
			{
				relayDrivStat = GetRelayDriveState(relayId);
				bufIndx = GetRelayConfigBufIndex(relayId);  /*获取继电器数组下标*/

				if(RELAY_DRIVE_STATE_UP == relayDrivStat)
				{
					RelayDataStru[bufIndx].RelayCollState = RELAY_STATE_UP;
				}
				else if(RELAY_DRIVE_STATE_DOWN == relayDrivStat)
				{					
					RelayDataStru[bufIndx].RelayCollState = RELAY_STATE_DOWN;
				}
				else
				{			
					RelayDataStru[bufIndx].RelayCollState = RELAY_STATE_DOWN;
				}
			}
		}
	}

	return;
}

/*
* 功能描述： 根据无人折返指示灯的闪灯和稳灯状态驱动继电器或设置状态
* 参数说明： 无
* 返回值  ： 无
*/
static void AutoRtnIndictStaToDevStateProc(void)
{
	UINT16 DeviceId = 0u;		/*设备ID*/
	UINT16 jj = 0u;				/*游标*/
	UINT8 indicatorContainRelaySum = 0u;/*表示灯包含继电器数目*/
	UINT16* indicatorContainRelayIdBuf = NULL;/*表示灯包含继电器ID数组*/
	UINT8 relayVirtAttr = 0u;
	UINT8 belongCiId = 0u;
	UINT8 localCiId = 0u;
	UINT8 zDZFDevType =0u;
	UINT8 indicatorType =0u;
	UINT8 flashState =0u;
	UINT8 steadyState =0u;
	UINT16 indictorCurNum = GetIndicatorCurSum();
	UINT8 indictorDevId = 0U;

	for (jj = 0u; jj < indictorCurNum; jj++ )
	{
		DeviceId =  GetIndicatorId(jj);/*获取指示灯ID*/
		indicatorType = GetIndicatorType(DeviceId);
		if (INDICATOR_TYPE_EXPRESS_RETURN == indicatorType)
		{/*设备ID对应且指示灯类型为无人折返灯*/
			indicatorContainRelaySum = GetIndicatorRelaySum(DeviceId);
			indicatorContainRelayIdBuf = GetIndicatorRelayIdBuf(DeviceId);
			indictorDevId = GetIndicatorRelNonReturnId(DeviceId);/*获取指示灯设备ID*/
			if ((3u != indicatorContainRelaySum)||(NULL == indicatorContainRelayIdBuf))
			{/*继电器数据错误*/
				break;
			}

            localCiId = GetSystemParaLocalCiId();
			belongCiId = GetVirtualZDZFBelongCiId();
			zDZFDevType = GetVirtualZDZFDevType();
			flashState = GetAutoRtnIndictFlashState((UINT16)indictorDevId);/*获取指示灯闪灯状态*/
			steadyState = GetAutoRtnIndictSteadyState((UINT16)indictorDevId);/*获取指示灯稳灯状态*/
			if ((belongCiId == localCiId) && (CI_DEVICE_TYPE_AUTORETURN == zDZFDevType))
			{/*无人折返按钮为虚拟设备*/
				/*无人折返按钮为虚拟设备，直接设置相关虚拟继电器状态*/
				relayVirtAttr = GetRelayVirtAttr(indicatorContainRelayIdBuf[0]);
				/*再次确认是虚拟继电器*/
				if(RELAY_VIRTUAL_ATTR_YES == relayVirtAttr)
				{
					if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == flashState)
					{/*闪灯状态有效*/
						(void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_UP);/*闪灯继电器驱动吸起*/
						SetRelayCollState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_UP);/*闪灯继电器采集吸起*/
					}
					else
					{
						(void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*闪灯继电器驱动落下*/
						SetRelayCollState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*闪灯继电器采集落下*/
					}
				}
				else
				{
					(void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*闪灯继电器驱动落下*/
				}

				relayVirtAttr = GetRelayVirtAttr(indicatorContainRelayIdBuf[1]);
				/*再次确认是虚拟继电器*/
				if(RELAY_VIRTUAL_ATTR_YES == relayVirtAttr)
				{
					if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == steadyState)
					{/*稳灯状态有效*/
						(void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_UP);/*稳灯继电器驱动吸起*/
						SetRelayCollState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_UP);/*稳灯继电器采集吸起*/
					}
					else
					{
						(void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*稳灯继电器驱动落下*/
						SetRelayCollState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*稳灯继电器采集落下*/
					}
				}
				else
				{
					(void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*稳灯继电器驱动落下*/
				}
			}
			else
			{/*无人折返是真实设备*/	
				if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == flashState)
				{/*闪灯状态有效*/
					(void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_UP);/*闪灯继电器驱动吸起*/
				}
				else
				{
					(void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*闪灯继电器驱动落下*/
				}

				if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == steadyState)
				{/*稳灯状态有效*/
					(void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_UP);/*稳灯继电器驱动吸起*/
				}
				else
				{
					(void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*稳灯继电器驱动落下*/
				}			
			}
		}
	}
}
/*
* 功能描述： 根据无人折返指示灯的闪灯和稳灯状态驱动继电器或设置状态
* 参数说明： 无
* 返回值  ： 无
*/
static void AutoRtnIndictStatusProc_VirCI(void)
{
	UINT8 DeviceId = 0u;		/*设备ID*/
	UINT8 jj = 0u;				/*游标*/
	UINT8 indicatorContainRelaySum = 0u;/*表示灯包含继电器数目*/
	UINT16* indicatorContainRelayIdBuf = NULL;/*表示灯包含继电器ID数组*/
	UINT8 relayVirtAttr = 0u;
	UINT8 belongCiId = 0u;
	UINT8 localCiId = 0u;
	UINT8 zDZFDevType =0u;
	UINT8 indicatorType =0u;
	UINT8 flashState =0u;
	UINT8 steadyState =0u;
	UINT8 chIndicatorCurSum = 0u;
	UINT8 virNum = 0u;
	UINT8 virCIid=0u;
	UINT8 i= 0u;
	UINT8 indictorDevId = 0U;

	virNum = GetVirtualCINum();
	for(i=0u;i<virNum;i++)
	{
		chIndicatorCurSum = GetVirCIIndicatorConfigDataNum(virCIid);
		virCIid = GetVirtualCIid(i);

		for (jj = 0u; jj < chIndicatorCurSum; jj++ )
		{
			DeviceId =  GetVirCIlocalCiIndicatorId(virCIid,jj);/*获取指示灯ID*/
			indicatorType = GetVirCIIndicatorType(virCIid,DeviceId);
			if (INDICATOR_TYPE_EXPRESS_RETURN == indicatorType)
			{/*设备ID对应且指示灯类型为无人折返灯*/
				indicatorContainRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,DeviceId);
				indicatorContainRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,DeviceId);
				indictorDevId = GetIndicatorRelNonReturnId(DeviceId);/*获取指示灯设备ID*/
				if ((3u != indicatorContainRelaySum)||(NULL == indicatorContainRelayIdBuf))
				{/*继电器数据错误*/
					break;
				}

				localCiId = GetSystemParaLocalCiId();
				belongCiId = GetVirtualZDZFBelongCiId();
				zDZFDevType = GetVirtualZDZFDevType();
				flashState = GetVirCIautoRtnIndictFlashState(indictorDevId,virCIid);/*获取指示灯闪灯状态*/
				steadyState = GetVirCIautoRtnIndictSteadyState(indictorDevId,virCIid);/*获取指示灯稳灯状态*/
				if ((belongCiId == localCiId) && (CI_DEVICE_TYPE_AUTORETURN == zDZFDevType))
				{/*无人折返按钮为虚拟设备*/
					/*无人折返按钮为虚拟设备，直接设置相关虚拟继电器状态*/
					relayVirtAttr = GetRelayVirtAttr(indicatorContainRelayIdBuf[0]);
					/*再次确认是虚拟继电器*/
					if(RELAY_VIRTUAL_ATTR_YES == relayVirtAttr)
					{
						if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == flashState)
						{/*闪灯状态有效*/
							(void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_UP);/*闪灯继电器驱动吸起*/
							SetRelayCollState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_UP);/*闪灯继电器采集吸起*/
						}
						else
						{
							(void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*闪灯继电器驱动落下*/
							SetRelayCollState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*闪灯继电器采集落下*/
						}
					}
					else
					{
						(void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*闪灯继电器驱动落下*/
					}

					relayVirtAttr = GetRelayVirtAttr(indicatorContainRelayIdBuf[1]);
					/*再次确认是虚拟继电器*/
					if(RELAY_VIRTUAL_ATTR_YES == relayVirtAttr)
					{
						if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == steadyState)
						{/*稳灯状态有效*/
							(void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_UP);/*稳灯继电器驱动吸起*/
							SetRelayCollState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_UP);/*稳灯继电器采集吸起*/
						}
						else
						{
							(void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*稳灯继电器驱动落下*/
							SetRelayCollState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*稳灯继电器采集落下*/
						}
					}
					else
					{
						(void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*稳灯继电器驱动落下*/
					}
				}
				else
				{/*无人折返是真实设备*/	
					if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == flashState)
					{/*闪灯状态有效*/
						(void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_UP);/*闪灯继电器驱动吸起*/
					}
					else
					{
						(void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*闪灯继电器驱动落下*/
					}

					if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == steadyState)
					{/*稳灯状态有效*/
						(void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_UP);/*稳灯继电器驱动吸起*/
					}
					else
					{
						(void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*稳灯继电器驱动落下*/
					}			
				}
			}
		}

	}

	
}
/*
* 功能描述： 更新故障锁闭照查驱动
* 参数说明： void
* 返回值  ： void
*/
void UpdateFaultLockZhaoChaDrive(void)
{
	UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT16 relayId = 0u;
	UINT8 relayDriveState = 0;/*继电器驱动状态*/
	UINT8 relayCollState = 0;/*继电器采集状态*/
	UINT8 relayBelongCi = 0u;/*继电器所属联锁*/
	UINT16 phyIDNum = 0u;/*物理区段数目*/
	UINT16 *pPhyIdBuf = NULL;/*物理区段ID数组*/

	UINT16 phyId = 0u;
	UINT8 phyBelongCi = 0u;
	UINT16 routeId = 0u;
	UINT8 routeBelongCi = 0u;
	UINT8 lockState = 0u;/*锁闭状态*/
	UINT8 execRes = CI_ERROR;/*执行结果*/

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

	if(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)
	{/*支持继电接口功能开关已打开*/
		for (ii=0u;ii<LockExceptZhaoChaRelayNum;ii++)
		{
			if (NULL != LockExceptZhaoChaRelayId)
			{
				relayId = LockExceptZhaoChaRelayId[ii];
				relayBelongCi = GetRelayBelongCiId(relayId);

				if (localCi == relayBelongCi)
				{
					phyIDNum = GetRelayLockExceptPhySecNum(relayId);
					pPhyIdBuf = GetRelayLockExceptPhySecIdBuf(relayId);
					if (NULL != pPhyIdBuf)
					{
						for (jj = 0u;jj<phyIDNum;jj++)
						{
							phyId = pPhyIdBuf[jj];
							lockState = GetPhySecLockState(phyId);
							
							phyBelongCi = GetPhySecBelongCiId(phyId);
							routeId = GetPhySecRLockBelongRouteId(phyId);
							if (routeId > 0u)
							{
								relayDriveState = GetRelayDriveState(relayId);/*获取继电器驱动状态*/
								routeBelongCi = GetRouteBelongCiId(routeId);
								commState = GetLocalCiAndOtherCiTransSta(routeBelongCi);/*本联锁与其它联锁通信通信状态*/
								/*物理区段属于本联锁，但物理区段锁闭所属进路属于相邻联锁，且本联锁与相邻联锁处于继电接口，
								且运营人员已下发确认继电接口命令。*/
								if ((localCi == phyBelongCi) && (routeBelongCi != localCi) &&
									(TRANSMIT_STATE_BAD == commState) && 
									(CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag))
								{
									if (PHYSICAL_SECTION_LOCK_EXCEPT != lockState)
									{/*未故障锁闭*/
										if(RELAY_DRIVE_STATE_NULL== relayDriveState)
										{/*未驱动，驱吸起*/
											execRes = SetRelayDriveState(relayId, RELAY_STATE_UP);
											if (CI_ERROR == execRes)
											{
												/*错误记录*/
											}
										}
									}
									else
									{/*故障锁闭，驱落下*/
										(void)SetRelayDriveState(relayId, RELAY_STATE_DOWN);
										relayCollState = GetRelayCollState(relayId);
										if (RELAY_STATE_DOWN != relayCollState)
										{ /*照查继电器未落下*/
												
										}
									}
								}
								
							}
						}
					}
				}

			
			}
		}
	}
}
/*
* 功能描述： 根据配置功能开关判断信号机灯丝断丝报警
* 参数说明： UINT16 devId  指示灯ID
* 返回值  ： void
*/
void SignaDsBreakAlarmIndicator(UINT16 devId)
{
	UINT8 devRelaySum = 0u; /*设备继电器总数*/
	UINT16* pDevRelayIdBuf = NULL; /*继电器IDbuf*/
	UINT8 dSValidFlag = 0u;
	UINT8 relayCollState = 0u;

	devRelaySum = GetIndicatorRelaySum(devId); /*获取相关继电器总数*/
	pDevRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*获取相关继电器ID buf*/

	if (NULL == pDevRelayIdBuf)
	{
		SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置报警*/
	}
	else
	{
		relayCollState = GetRelayCollState(pDevRelayIdBuf[0]);
		dSValidFlag = GetCiFunctionSwitchConfig(FUNC_SIGNAL_ALARM_DUANSI_FLAG);
		/*功能开关为0xAA-灯丝报警继电器吸起报警*/
		if(FUNC_SWITCH_ON == dSValidFlag)
		{
			if (RELAY_STATE_DOWN == relayCollState)
			{ /*继电器落下不报警*/
				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置无报警*/
				
			}
			else
			{/*报警继电器吸起*/
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置报警*/
			}
		}
		else
		{
			if (RELAY_STATE_UP == relayCollState)
			{ /*报警继电器吸起*/

				SetIndicatorState(devId, INDICATOR_SHOW_NO); /*设置无报警*/
			}
			else
			{
				SetIndicatorState(devId, INDICATOR_SHOW_YES); /*设置报警*/
			}
		}
	}	
}
/*
* 功能描述： 根据配置功能开关判断信号机灯丝断丝报警
* 参数说明： UINT16 devId  指示灯ID
* 返回值  ： void
*/
void SignaDsBreakAlarmIndicator_Vir(UINT8 virCIid ,UINT8 devId)
{
	UINT8 devRelaySum = 0u; /*设备继电器总数*/
	UINT16* pDevRelayIdBuf = NULL; /*继电器IDbuf*/
	UINT8 dSValidFlag = 0u;
	UINT8 relayCollState = 0u;

	devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*获取相关继电器总数*/
	pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*获取相关继电器ID buf*/

	if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf))
	{
		SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置报警*/
	}
	else
	{
		relayCollState = GetRelayCollState(pDevRelayIdBuf[0]);
		dSValidFlag = GetCiFunctionSwitchConfig(FUNC_SIGNAL_ALARM_DUANSI_FLAG);
		/*功能开关为0xAA-灯丝报警继电器吸起报警*/
		if(FUNC_SWITCH_ON == dSValidFlag)
		{
			if (RELAY_STATE_DOWN == relayCollState)
			{ /*继电器落下不报警*/
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置无报警*/
				
			}
			else
			{/*报警继电器吸起*/
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置报警*/
			}
		}
		else
		{
			if (RELAY_STATE_UP == relayCollState)
			{ /*报警继电器吸起*/

				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*设置无报警*/
			}
			else
			{
				SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*设置报警*/
			}
		}
	}	
}

/*
* 功能描述： 相邻联锁间命令输出处理
* 参数说明： void
* 返回值  ： void
*/
void CiToCiOutputCmdProc(void)
{
	UINT16 routeId = 0u;
	UINT8  routeLevel = 0u;  /*进路等级*/
	UINT16 routeCurSum = 0u;	     /*进路总数目*/
	UINT8 localCiId = 0u;         /*本地联锁ID*/
	UINT8 routeBelongCiId = 0u;        /*进路所属联锁ID*/
	UINT8 checkSum = 0u;
	RouteOtherCheckStruct *pDataOtherCiDevBuf = NULL;
	RouteOtherCheckStruct *pTmpOtherCiDevInfo = NULL;
	UINT16 psdId = 0u;
	UINT8 psdBelongCiId = 0u;
	UINT16 ii = 0u;               /*循环索引*/
	UINT16 iOtherCiIndex = 0u;               /*循环索引*/
	UINT8 tmpPsdVobcCmd = 0U;
	UINT16 wCurPhySecNum = 0U;  /*本控区物理区段数量*/
	UINT16 wCurLogSecNum = 0U;  /*本控区逻辑区段数量*/
	UINT16 wSecId = 0U;
	UINT16 wSecRLockBelongRoute = 0U;  /*区段进路锁闭所属进路*/
	UINT16 wSecPLockBelongRoute = 0U;  /*区段防护锁闭所属进路*/
	UINT8 cCmdSendFlag = CI_ERROR;
	UINT16 wOtherCiPLockRouteId = 0U;  /*其它CI发送的物理区段防护锁闭所属进路ID*/
	UINT16 wRouteLockedOverlapId = 0U;  /*进路锁闭过的保护区段ID*/

	routeCurSum = GetRouteCurSum();		        /*获取进路总数*/
	localCiId = GetSystemParaLocalCiId();

	/*处理进路*/
	for (ii = 0u; ii < routeCurSum; ii++)
	{
		routeId = GetRouteId(ii);
		routeBelongCiId = GetRouteBelongCiId(routeId);
		/*进路等级*/
		routeLevel = GetRouteLevel(routeId);
		
		if (ROUTE_LEVEL_BLOC == routeLevel)
		{
			checkSum = GetRouteBlocOtherCiSum(routeId);
			pDataOtherCiDevBuf = GetRouteBlocOtherCiBuf(routeId);
		}
		else if (ROUTE_LEVEL_CBTC == routeLevel)
		{
			checkSum = GetRouteCbtcOtherCiSum(routeId);
			pDataOtherCiDevBuf = GetRouteCbtcOtherCiBuf(routeId);
		}
		else
		{
			checkSum = 0u;
			pDataOtherCiDevBuf = NULL;
		}
		if ((0u != checkSum) && (NULL != pDataOtherCiDevBuf))
		{
			/*遍历其它联锁条件*/
			for (iOtherCiIndex = 0u;iOtherCiIndex < checkSum;iOtherCiIndex++)
			{
				if(ROUTE_OHTER_CHECK_SUM_MAX <= iOtherCiIndex)
				{
					break;
				}
				pTmpOtherCiDevInfo = &pDataOtherCiDevBuf[iOtherCiIndex];
				/*如果进路所属联锁ID不为本联锁 且 其它联锁条件设备类型为屏蔽门*/
				if ((CI_DEVICE_TYPE_PSD == pTmpOtherCiDevInfo->DevType) &&
					(routeBelongCiId != localCiId))
				{
					psdId = pTmpOtherCiDevInfo->DevId;/*屏蔽门ID*/
					psdBelongCiId = GetPsdBelongCiId(psdId);
					if (psdBelongCiId == localCiId)
					{
						tmpPsdVobcCmd = GetPsdVobcCmd(psdId);/*PSD的VOBC控制命令*/

						AddCiSendToCiCmdInfo(CI_CMD_PSD_VOBC_CMD_TO_CI,psdId,tmpPsdVobcCmd,routeBelongCiId);
					}
					
				}
			}
		}
	}

	/*处理物理区段需要发送的防护锁闭所属进路*/
	wCurPhySecNum = GetPhySecCurSum();
	for (ii = 0U; ii < wCurPhySecNum; ii++)
	{
		wSecId = GetPhySecId(ii);
		cCmdSendFlag = GetPhySecPLockRouteCmdSendFlag(wSecId);  /*判断是否需要添加设置物理区段防护锁闭所属进路命令*/

		if (CI_SUCCESS == cCmdSendFlag)
		{
			wSecPLockBelongRoute = GetPhySecPLockBelongRouteId(wSecId);  /*获取物理区段防护锁闭所属进路ID*/
			wSecRLockBelongRoute = GetPhySecRLockBelongRouteId(wSecId);
			routeBelongCiId = GetRouteBelongCiId(wSecRLockBelongRoute);  /*获取物理区段进路锁闭所属进路的所属CI*/
			AddCiSendToCiCmdInfo(CI_CMD_PHYSEC_PLOCK_ROUTE_CMD, wSecId, wSecPLockBelongRoute, routeBelongCiId);  /*添加防护锁闭所属进路ID*/
			
			wOtherCiPLockRouteId = GetPhySecOtherCiPLockRouteId(wSecId);  /*获取其它CI发送的物理区段防护锁闭所属进路ID*/
			if (0U != wSecPLockBelongRoute)
			{
				wRouteLockedOverlapId = GetRouteOverlapLockedId(wSecPLockBelongRoute);  /*获取进路锁闭过的保护区段*/
				AddCiSendToCiCmdInfo(CI_CMD_ROUTE_LOCKED_OVERLAP, wSecPLockBelongRoute, wRouteLockedOverlapId, routeBelongCiId);  /*添加进路锁闭过的保护区段*/
				
				if (0U != wOtherCiPLockRouteId)
				{					
					/*目标控区区段防护锁闭所属进路存在且与本控区区段防护锁闭所属进路不一致，清除目标控区防护锁闭所属进路锁闭过的保护区段*/
					AddCiSendToCiCmdInfo(CI_CMD_ROUTE_LOCKED_OVERLAP, wOtherCiPLockRouteId, 0U, routeBelongCiId);
				}
				else
				{
					/*不处理*/
				}
			}
			else
			{
				/*本控区区段无防护锁闭所属进路，清除目标控区防护锁闭所属进路锁闭过的保护区段*/
				AddCiSendToCiCmdInfo(CI_CMD_ROUTE_LOCKED_OVERLAP, wOtherCiPLockRouteId, 0U, routeBelongCiId);
			}
		}
		else
		{
			/*条件不满足，不发送*/
		}
	}

	/*处理逻辑区段需要发送的防护锁闭所属进路*/
	wCurLogSecNum = GetLogicSecCurSum();
	for (ii = 0U; ii < wCurLogSecNum; ii++)
	{
		wSecId = GetLogicSecId(ii);
		cCmdSendFlag = GetLogSecPLockRouteCmdSendFlag(wSecId);  /*判断是否需要添加设置逻辑区段防护锁闭所属进路命令*/

		if (CI_SUCCESS == cCmdSendFlag)
		{
			wSecPLockBelongRoute = GetLogSecPLockRouteId(wSecId);  /*获取逻辑区段防护锁闭所属进路ID*/
			wSecRLockBelongRoute = GetLogSecLockBelongRoute(wSecId);
			routeBelongCiId = GetRouteBelongCiId(wSecRLockBelongRoute);  /*获取逻辑区段进路锁闭所属进路的所属CI*/
			AddCiSendToCiCmdInfo(CI_CMD_LOGSEC_PLOCK_ROUTE_CMD, wSecId, wSecPLockBelongRoute, routeBelongCiId);
		}
		else
		{
			/*条件不满足，不发送*/
		}
	}
}


/*
* 功能描述： 虚拟联锁使用的输出指示灯处理
* 参数说明： void
* 返回值  ： void
*/
void OutPutIndicatorState_UseVirCI(void)
{
	UINT8 i = 0u;
	UINT8 virNum = 0u;
	UINT8 virCIid=0u;

	virNum = GetVirtualCINum();
	for(i=0u;i<virNum;i++)
	{
		virCIid = GetVirtualCIid(i);
		IndicatorStateProc_UseVirCI(virCIid);
	}
}
/*
* 功能描述： 获取组合自动进路所属虚拟联锁ID
* 参数说明： groupAutoRouteId 组合自动进路的ID    
* 返回值  ：所属虚拟联锁ID 
*  说明：组合自动进路所属联锁为包含自动进路的第一条进路
*/
UINT8 GetGroupAutoRouteBelongVirCIid(UINT16 groupAutoRouteId)
{
	/*变量初始化*/
	UINT16 autoRouteSum = 0u;              /*组合自动进路包含自动进路数目 (配置字段)*/
	UINT16 *pAutoRouteIdBuf = NULL;              /*组合自动进路包含自动进路进路ID数组 (配置字段)*/
	UINT8 routeSum = 0u;
	UINT16 *pRouteIdBuf= NULL;
	UINT8 reVal = 0u;

	if((0u != groupAutoRouteId) && (GROUP_AUTO_ROUTE_SUM_MAX > groupAutoRouteId))
	{
		/*获取组合自动进路信息*/
		autoRouteSum = GetGroupAutoRouteHasRouteSum(groupAutoRouteId);
		pAutoRouteIdBuf = GetGroupAutoRouteHasRouteIdBuff(groupAutoRouteId);

		/*组合自动进路有数据*/
		if(0u != autoRouteSum) 
		{
			routeSum = GetAutoRouteIncludeRouteSum(pAutoRouteIdBuf[0]);/*该进路所包含进路数目*/
			pRouteIdBuf = GetAutoRouteIncludeRouteBuf(pAutoRouteIdBuf[0]);/*获取该自动进路对应的基本进路*/
			if((0u != routeSum) && (NULL != pRouteIdBuf))
			{
				reVal = GetRouteBelongVirCiId(pRouteIdBuf[0]);/*由该进路定义本组合自动进路所属虚拟联锁*/
			}
			else
			{
			    ;
			}
		}
	}
	return reVal;
}

/*********************************************
*函数功能：更新照查联锁条件检查照查驱动
*参数说明：无          
*返回值：无
*********************************************/
void UpdateZhaoChaCheckZhaoChaDrive(void)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 localCiId = 0u;
	UINT16 zhaochaRelayId = 0u;
	UINT8 zhaoChaIdBelongCi = 0u;
	UINT8 spksState = 0u;
	UINT8 relayDriveState = 0u;
	UINT8 fLockState = 0u;
	UINT8 funcSwitchSupportRelayInterface = 0u;/*相邻联锁是否支持继电接口*/
	UINT16 zhaochaCheckNum = 0u;
	ZhaochaCheckConfigDataStruct* pZhaochaCheckConfigDataStru = NULL;

	/*获取信息*/
	localCiId = GetSystemParaLocalCiId();
	pZhaochaCheckConfigDataStru = GetZhaochaCheckConfigDataStru();
	zhaochaCheckNum = GetZhaochaCheckConfigDataNum();
	/*相邻联锁是否支持继电接口*/
	funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI);

	/*支持继电接口*/
	if(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)
	{/*非空*/
		if (NULL != pZhaochaCheckConfigDataStru)
		{
			for(i = 0u; i < zhaochaCheckNum;i++)
			{
				if(ZHAOCHA_CHECK_SUM_MAX > i)
				{
					zhaochaRelayId = pZhaochaCheckConfigDataStru[i].ZhaochaRelayId;
					if((0u < zhaochaRelayId) && (RELAY_SUM_MAX > zhaochaRelayId))
					{
						zhaoChaIdBelongCi = GetRelayBelongCiId(zhaochaRelayId);
						/*照查继电器属于本联锁*/
						if(zhaoChaIdBelongCi == localCiId)
						{

							for(j = 0u; j < pZhaochaCheckConfigDataStru[i].ZhaochaCheckSum; j++)
							{
								if(ZHAOCHA_CHECK_TYPE_SUN_MAX > j)
								{

									relayDriveState = GetRelayDriveState(zhaochaRelayId);/*获取继电器驱动状态*/
									/*检查类型是SPKS*/
									if((ZHAOCHA_CHECK_SPKS_YES == pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].CheckType) &&
										(CI_DEVICE_TYPE_SPKS == pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].DevType))
									{
										/*获取SPKS状态*/
										spksState = GetSpksState(pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].DevId);
										if(SPKS_STATUS_YES == spksState)
										{
											/*SPKS按下，驱动照查继电器落下*/
											(void)SetRelayDriveState(zhaochaRelayId, RELAY_DRIVE_STATE_DOWN);
											break;
										}
										else
										{
											/*驱动无效。驱吸起*/
											if(RELAY_DRIVE_STATE_NULL == relayDriveState)
											{
												(void)SetRelayDriveState(zhaochaRelayId, RELAY_DRIVE_STATE_UP);
											}
										}
									}
									else if((ZHAOCHA_CHECK_PHY_FLOCK_YES == pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].CheckType) &&
										(CI_DEVICE_TYPE_PHYSEC == pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].DevType))
									{
										fLockState = GetPhySecFLockState(pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].DevId);
										/*封锁*/
										if(PHYSICAL_SECTION_FLOCK_YES == fLockState)
										{
											(void)SetRelayDriveState(zhaochaRelayId, RELAY_DRIVE_STATE_DOWN);
											break;
										}
										else
										{
											/*驱动无效。驱吸起*/
											if(RELAY_DRIVE_STATE_NULL == relayDriveState)
											{
												(void)SetRelayDriveState(zhaochaRelayId, RELAY_DRIVE_STATE_UP);
											}
										}
									}
									else
									{
										/*数据配置异常，导向安全*/
										(void)SetRelayDriveState(zhaochaRelayId, RELAY_DRIVE_STATE_DOWN);
										SetErrorData(EFUNC_UPDATE_ZHAOCHA_CHECK,CI_DEVICE_TYPE_RELAY,zhaochaRelayId,ETYPE_DATA_CFG_ERR,0,ESEND_LEVEL_ZERO);
										break;
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

/*********************************************
*函数功能：虚拟设备状态处理
*参数说明：无          
*返回值：无
*********************************************/
void VirtualDeviceOutputProc(void)
{
	/*虚拟继电器状态处理*/
	VirtualRelayStateProc();

	/*虚拟信号机状态处理*/
	VirtualSignalStateProc();
}

/*********************************************
*函数功能：虚拟设备状态处理
*参数说明：无          
*返回值：无
*********************************************/
void VirtualSignalStateProc(void)
{
	UINT16 signalSum = 0u;
	UINT16 signalIndx = 0u;
	UINT16 signalId = 0u;
	UINT16 bufIndex = 0u;
	UINT8 signalVirtAttr = 0u;
	UINT8 signalDrivColor = 0u;
	UINT8 localId = 0u;
	UINT8 signalBelongCi = 0u;
	
	SignalDataStruct * pTempSignalDataStruct = NULL;

	signalSum = GetSignalCurSum();   /*获取信号机当前总数*/
	localId = GetSystemParaLocalCiId();
	for (signalIndx = 0u; signalIndx < signalSum; signalIndx++)
	{
		signalId = GetSignalId(signalIndx);
		signalBelongCi = GetSignalBelongCiId(signalId);
		if (localId == signalBelongCi)
		{
			signalVirtAttr = GetSignalVirtualAttr(signalId);

			if(SIGNAL_VIRTUAL_YES == signalVirtAttr) /*信号机为虚拟信号机*/
			{
				signalDrivColor = GetSignalCurDriveColor(signalId);
				bufIndex = GetSignalConfigBufIndex(signalId);
				pTempSignalDataStruct = GetSignalData();
				if(NULL != pTempSignalDataStruct)
				{
					pTempSignalDataStruct[bufIndex].CurColor = signalDrivColor;
				}
			}
		}
	}
}

/*
* 功能描述： 设置驱动继电器混线状态
* 参数说明： 无       
* 返回值  ： 无
*			      
*/
void SetDriveRelayHunXianState(void)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 relayId = 0u;
	UINT8 localCiId = 0u;
	UINT8 relayBelongCi = 0u;
	UINT16 relaySum = 0u;
	UINT8 relayDrvAddrA = 0u; /*驱动板卡地址*/
	UINT8 relayDrvPosA = 0u;  /*驱动位置*/
	UINT8 relayDrvAddrB = 0u;
	UINT8 relayDrvPosB = 0u;
	UINT8 collectMode = 0u;
	UINT8 retValue = CI_ERROR;

	/*获取信息*/
	relaySum = GetRelayCurSum();
	localCiId = GetSystemParaLocalCiId(); /*获取本地联锁ID*/
	for(i = 0u; i < relaySum;i++)
	{
		relayId = GetRelayId(i);
		relayBelongCi = GetRelayBelongCiId(relayId);
		if(relayBelongCi == localCiId)
		{
			/*获取继电器的驱动地址信息*/
			relayDrvAddrA = GetRelayDrvAddrA(relayId);                
			relayDrvPosA = GetRelayDrvPosA(relayId);                 
			relayDrvAddrB = GetRelayDrvAddrB(relayId);                 
			relayDrvPosB = GetRelayDrvPosB(relayId); 

			/*获取采集方式*/
			collectMode = GetRelayCollectMode(relayId);

			/*是驱动继电器*/
			if((relayDrvAddrA > 0u) && (relayDrvPosA > 0u) && (relayDrvAddrB > 0u) && (relayDrvPosB > 0u)
				&& (collectMode > 0u))
			{
				/*混线检查*/
				retValue = CheckRelayHunXiandState(relayId);
				if(CI_ERROR == retValue)
				{
					/*设置继电器混线状态*/
					SetRelayHunXianState(relayId,RELAY_HUNXIAN_STATE_YES);
				}
				else
				{
					/*设置继电器未混线状态*/
					SetRelayHunXianState(relayId,RELAY_HUNXIAN_STATE_NO);
				}
			}
		}
		else
		{
			/*不做处理*/
		}
	}
}

/*
* 功能描述： 获取人工解锁反馈倒计时
* 参数说明： 
*            const UINT16 overlapId  保护区段id
*            const UINT16 OverlapUnLockCount 解锁倒计时周期数
*            const UINT32 startCycNum        解锁起始周期
* 返回值  ： 倒计时
*			      
*/
UINT16 GetOverlapUnlockBackTime(const UINT16 overlapId, UINT16 OverlapUnLockCount, const UINT32 startCycNum)
{ 
	UINT16 autotimeData = 0u;
	UINT16 labortimeData = 0u;
	INT32 deltCount = 0;
	UINT32 curCycleNum = Get2oo2CurCycleNum();
	UINT32 appCycTime = GetSystemParaAppCycleTime();/*获取联锁周期*/
	UINT32 laborUnlockStartCycNum = 0u;
	UINT32 laborUnlockOverlapTimeCount =0u;
	UINT16 returnTime = 0u;


	/*自动解锁倒计时*/
	deltCount = (INT32)(curCycleNum - startCycNum);
	if((deltCount >= 0) && (deltCount <= (INT32)OverlapUnLockCount))/*倒计时数值在合理范围内*/
	{
		autotimeData = (UINT16)(((OverlapUnLockCount + startCycNum - curCycleNum)* appCycTime)/1000U) ;
	}	



	/*人工解锁倒计时*/
	laborUnlockStartCycNum = GetlaborUnlockStartCycNum(overlapId);

	if(0u < laborUnlockStartCycNum)/*已经设置人工解锁*/
	{
		deltCount = (INT32)(curCycleNum - laborUnlockStartCycNum);
		laborUnlockOverlapTimeCount =GetlabarUnlockOverlapTimeCount();
		if((deltCount >= 0) && (deltCount <= (INT32)laborUnlockOverlapTimeCount))/*倒计时数值在合理范围内*/
		{
			labortimeData = (UINT16)(((laborUnlockOverlapTimeCount + laborUnlockStartCycNum- curCycleNum)* appCycTime)/1000U) ;

		}
	}



	if(0u < laborUnlockStartCycNum)/*已经设置人工解锁*/
	{
		/*比较两个时间，返回最小的。因为在解锁；逻辑是以最小倒计时解锁的*/
		if(autotimeData > labortimeData)
		{
			returnTime = labortimeData;
		}
		else
		{
			returnTime = autotimeData;
		}	
	}
	else
	{
		returnTime = autotimeData;
	}

	return returnTime;
}

/*
* 功能描述： 根据主体信号机当前颜色驱动复示信号机
* 参数说明： 无
* 返回值  ： 无
*	注意：
*/
void DriveFushiSignal(void)
{
	UINT16 ii = 0u;
	UINT16 signalCurSum = 0u;
	UINT16 signalId = 0u;
	UINT8 fushiSignalNum = 0u;
	UINT16* pFushiSignalIdBuf = NULL;
	UINT8 lightExtinctState = 0u;
	UINT8 signalMaintainState = 0u;
	UINT8 checkflag = 0u;
	UINT8 signalColor = 0u;
	UINT8 ciPattern = 0u;/*联锁模式*/
	UINT32 SignalStartCycNum = 0u;
	UINT8 jj = 0u;
	UINT8 fushiSignalCurColor = 0u;
	UINT8 openCloseStat = 0u;
	UINT8 fushiDrivColor = 0u;

	signalCurSum = GetSignalCurSum();/*仅驱动属于本联锁的信号机*/
	for (ii = 0u; ii < signalCurSum; ii++)
	{
		checkflag = 0u;
		signalId = 0u;
		fushiSignalNum = 0u;
		pFushiSignalIdBuf = NULL;
		signalMaintainState = 0u;
		lightExtinctState = 0u;
		signalMaintainState = 0u;
		signalColor = 0u;
		ciPattern = 0u;
		SignalStartCycNum = 1u;

		signalId = GetSignalId(ii);

		fushiSignalNum = GetSignalFushiSignalNum(signalId);
		pFushiSignalIdBuf = GetSignalFushiSignalIdBuf(signalId);/*获取复示信号机ID数组*/
		if ((0u < fushiSignalNum) && (NULL != pFushiSignalIdBuf))/*代表该信号机具有复示信号机*/
		{
			lightExtinctState = GetSignalLightExtinctState(signalId);/*获取信号机亮灭状态*/
			signalMaintainState = GetSignalMaintainState(signalId);/*获取信号机维修点灯状态*/
			if ((SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState) || (MAINTAIN_STATE_YES == signalMaintainState))
			{/*亮灯或维修点灯*/
				checkflag = 1u;
			}
		}

		/*检查信号机是否处于开放状态*/
		if (1u == checkflag)
		{
			signalColor = GetSignalCurColor(signalId);
			if ((SIGNAL_SHOWCOLOUR_GREEN == signalColor) ||
				(SIGNAL_SHOWCOLOUR_YELLOW == signalColor))
			{ /*绿灯||黄灯*/
				/*信号开放*/
			}
			else
			{
				checkflag = 0u;/*检查不通过*/
			}
		}

		/*检查室外信号机实际是否处于开放状态*/
		if (1u == checkflag)
		{
			ciPattern = GetLocalCiPattern();/*获取联锁模式，不同联锁模式有不同的容忍方式*/

			if (CI_PATTERN_FULL_ELECTRONIC == ciPattern)  /*全电子联锁*/
			{
				SignalStartCycNum = GetOcSignalStartCycNum(signalId);/*获取OC全灭容忍周期*/
			}
			else if (CI_PATTERN_TRADITIONAL == ciPattern)
			{
				SignalStartCycNum = GetSigRelayActStartCycNum(signalId);
			}
			else
			{
				checkflag = 0u;/*检查不通过*/
			}

			if (1u == checkflag)
			{
				if (0u == SignalStartCycNum)
				{/*为0代表当前没有容忍，室内外信号一致。检查通过*/
				}
				else
				{
					checkflag = 0u;/*检查不通过*/
				}
			}
		}

		/*以上检查通过，开始驱动复示信号机*/
		if (1u == checkflag)
		{
			/*根据主体信号机颜色获取复示信号机驱动颜色*/
			fushiDrivColor = GetFushiSignalDriveColor(signalColor);
			if ((0u < fushiSignalNum) && (NULL != pFushiSignalIdBuf))/*代表该信号机具有复示信号机*/
			{
				for (jj = 0u; jj < fushiSignalNum; jj++)
				{
					fushiSignalCurColor = GetSignalCurColor(pFushiSignalIdBuf[jj]);/*获取复示信号机当前颜色*/
					openCloseStat = GetSignalOpenCloseState(fushiSignalCurColor);
					if (SIGNAL_CLOSE == openCloseStat)
					{
						SetSignalCurDriveColor(pFushiSignalIdBuf[jj], fushiDrivColor);/*根据主体信号机显示颜色驱动复示信号机颜色*/
					}
					else
					{/*当前复示信号机是开放的*/
						if (fushiSignalCurColor != signalColor)/*当前复示信号机显示颜色和主体信号机不同*/
						{
							SetSignalCurDriveColor(pFushiSignalIdBuf[jj], SIGNAL_DRIVECOLOUR_REDCLOSE);
						}
						else
						{
							SetSignalCurDriveColor(pFushiSignalIdBuf[jj], fushiDrivColor);/*持续根据主体信号机显示颜色驱动复示信号机颜色*/
						}
					}
				}
			}
		}
		else
		{
			if ((0u < fushiSignalNum) && (NULL != pFushiSignalIdBuf))/*代表该信号机具有复示信号机*/
			{
				for (jj = 0u; jj < fushiSignalNum; jj++)
				{
					SetSignalCurDriveColor(pFushiSignalIdBuf[jj], SIGNAL_DRIVECOLOUR_REDCLOSE);/*其他情况都驱动红灭*/
				}

			}
		}
	}
}

/*
* 功能描述： 检查自动触发表示报警灯是否亮灯标志
* 参数说明： UINT8 virCiId 虚拟联锁ID
* 返回值  ： CI_SUCCESS 亮灯
*            CI_ERROR   灭灯
*/
UINT8 CheckAutoTriggerIndicatFlag(UINT8 virCiId)
{
	UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT16 ii = 0U;
	UINT16 routeCurSum = 0U;	     /*进路总数目*/
	UINT16 routeId = 0U;	         /*进路ID*/
	UINT8 routeAutoTriggerFlag = 0U; /*进路自动触发标志*/
	UINT8 localCiId = 0U;
	UINT8 routeBelongCiId = 0U;
	UINT8 routeBelongVirCiId = 0U;
	UINT8 flag = 0U; /*本集中区是否有自动触发标志*/
	UINT8 retIndicatFlag = CI_ERROR;     /*指示灯是否亮灯标志*/


	routeCurSum = GetRouteCurSum();		        /*获取进路总数*/
	localCiId = GetSystemParaLocalCiId();

	/*遍历进路*/
	for (ii = 0U; ii < routeCurSum; ii++)
	{
		routeId = GetRouteId(ii);                           /*获取进路ID*/
		routeAutoTriggerFlag = GetRouteAutoTriggerFlag(routeId); /*获取进路自动触发标志*/

		if (FUNC_SWITCH_ON == includeVirFlag)
		{
			if (0U < virCiId)
			{
				routeBelongVirCiId = GetRouteBelongVirCiId(routeId); /*获取进路所属虚拟联锁ID*/
				if (virCiId == routeBelongVirCiId)
				{
					/*本集中区只要有一个自动触发进路有自动触发标志则自动触发表示报警灯亮灯，否则灭灯*/
					if (AUTO_TRIGGER_SET_YES == routeAutoTriggerFlag)
					{
						flag = 1u;
						retIndicatFlag = CI_SUCCESS;
					}
				}
			}
		}
		else
		{
			routeBelongCiId = GetRouteBelongCiId(routeId);
			if (localCiId == routeBelongCiId)
			{
				/*本集中区只要有一个自动触发进路有自动触发标志则自动触发表示报警灯亮灯，否则灭灯*/
				if (AUTO_TRIGGER_SET_YES == routeAutoTriggerFlag)
				{
					flag = 1u;
					retIndicatFlag = CI_SUCCESS;
				}
			}
		}
		if (1u == flag)
		{
			break;
		}
	}
	return retIndicatFlag;
}
/*
* 功能描述： 指示器状态处理
* 参数说明： void
* 返回值  ： void
* cgh-合并CID-3037-3：
*/
void OcStationIndicStateProc(void)
{
	UINT16 devCurSum = GetOCStationIndicCurSum(); /*获取OC站表示灯当前总数*/
	UINT8 indicId = 0U;
	UINT8 ocid = 0U;
	UINT16 relayId = 0U;
	UINT8 relayState = 0U;
	UINT16 ii = 0U;

	for (ii = 0; ii < devCurSum; ii++)
	{

		indicId = GetOCStationIndicIdByIndex(ii);
		ocid = GetOCStationIndicOcIdByIndex(ii);
		relayId = GetOCStationIndicRelayId(ocid, indicId); /*获取指示器ID*/

		if ((0U != relayId) && (UINT16_MAX != relayId))/*指示灯有效*/
		{
			relayState = GetRelayCollState(relayId);
			if (RELAY_STATE_UP == relayState)
			{
				SetOCStationIndicState(ocid, indicId, INDICATOR_SHOW_YES);
			}
			else
			{
				SetOCStationIndicState(ocid, indicId, INDICATOR_SHOW_NO);
			}
		}
		else
		{
			SetOCStationIndicState(ocid, indicId, INDICATOR_SHOW_NO);
		}
	}
}

/*
* 功能描述： 进路相关命令反馈倒计时处理
* 参数说明： const UINT16 wRouteId  进路ID
* 返回值  ： void
* cgh-优化倒计时圈复杂度
*/
void RouteTimeDataBackProcess(const UINT16 wRouteId)
{
	UINT32 dwAppCycTime = 0U;/*联锁周期数*/
	UINT32 dwCurCycleNum = 0U;/*当前周期数*/
	UINT16 wTimeData = 0U;/*反馈的倒计时时间*/
	UINT32 dwDelayUnlockStartCycNum = 0U;/*进路延时解锁起始周期号*/
	UINT32 dwLeadRouteFaultOpenCount = 0U;/*引导进路内方区段故障信号开放持续周期数*/
	UINT32 dwRouteDelayCount = 0U;/*进路延时解锁周期数*/
	UINT32 dwLeadFaultOpenStartCycNum = 0U;/*进路引导进路内方故障信号开放起始周期号*/

	dwAppCycTime = GetSystemParaAppCycleTime();/*获取联锁周期号*/
	dwCurCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/
	dwLeadRouteFaultOpenCount = GetSystemParaLeadFaultOpenCyc();

	if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId))
	{
		dwDelayUnlockStartCycNum = GetRouteDelayUnlockStartCycNum(wRouteId);
		dwLeadFaultOpenStartCycNum = GetRouteLeadFaultOpenStartCyc(wRouteId);

		dwRouteDelayCount = GetRouteDelayCycleCount(wRouteId);

		if (0U < dwDelayUnlockStartCycNum)
		{/*延时解锁倒计时*/
			if ((dwCurCycleNum - dwDelayUnlockStartCycNum) <= dwRouteDelayCount)
			{
				wTimeData = (UINT16)(((dwRouteDelayCount + dwDelayUnlockStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U);
				if (wTimeData > UINT8_MAX)
				{   /*当倒计时时间超出最大值时，则同一周期发两包数，一包为高字节，一包为低字节*/
					/*添加总人解计时反馈*/
					SetCiSendCmdBackInfoData(CI_BACK_COUNT_ZONGRENJIE_HIGH, CI_DEVICE_TYPE_ROUTE, wRouteId, (UINT8)(wTimeData >> 8), 0U);
				}
				SetCiSendCmdBackInfoData(CI_BACK_COUNT_ZONGRENJIE, CI_DEVICE_TYPE_ROUTE, wRouteId, (UINT8)wTimeData, 0U);
			}
			else
			{
				; /*不处理*/
			}
		}
		else
		{
			; /*不处理*/
		}

		/*引导信号内方第一区段故障倒计时*/
		if (0U < dwLeadFaultOpenStartCycNum)
		{/*引导信号开放延时解锁倒计时*/
			wTimeData = (UINT16)(((dwLeadRouteFaultOpenCount + dwLeadFaultOpenStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U);
			/*添加总人解计时反馈*/
			SetCiSendCmdBackInfoData(CI_BACK_COUNT_LEAD, CI_DEVICE_TYPE_ROUTE, wRouteId, (UINT8)wTimeData, 0U);
		}
		else
		{
			; /*不处理*/
		}
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述： 物理区段相关命令反馈倒计时处理
* 参数说明： const UINT16 wPhySecId  物理区段ID
* 返回值  ： void
* cgh-优化倒计时圈复杂度
*/
void PhySecTimeDataBackProcess(const UINT16 wPhySecId)
{
#if 0
	/*当前逻辑中物理区段故障周期都会清0，预留*/
	UINT16 wPhyBelRouteId = 0U;/*物理区段所属进路ID*/
	UINT8 chPhyBelRouteType = 0U;/*物理区段所属进路类型*/
	UINT32 dwAppCycTime = 0U;/*联锁周期数*/
	UINT32 dwCurCycleNum = 0U;/*当前周期数*/
	UINT16 wTimeData = 0U;/*反馈的倒计时时间*/
	UINT32 dwDelayUnlockStartCycNum = 0U;/*物理区段区故解解锁起始周期号*/
	UINT32 dwBlocRouteDelayCount = 0U;/*点式进路延时解锁周期数*/
	UINT32 dwFaultUnlockCount = 0U;/*白光带区故解计时周期数*/

	dwAppCycTime = GetSystemParaAppCycleTime();/*获取联锁周期号*/
	dwCurCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/
	dwBlocRouteDelayCount = GetSystemParaBlocRouteDelayCyc();
	dwFaultUnlockCount = GetSystemParaFaultUnlockCyc();

	if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId))
	{
		wPhyBelRouteId = GetPhySecRLockBelongRouteId(wPhySecId);
		chPhyBelRouteType = GetRouteType(wPhyBelRouteId);
		dwDelayUnlockStartCycNum = GetPhySecFaultUnlockStartCycNum(wPhySecId);

		if (0U < dwDelayUnlockStartCycNum)
		{/*区故解延时解锁倒计时*/

			if ((ROUTE_TYPE_LIECHE == chPhyBelRouteType) || (ROUTE_TYPE_RETURN == chPhyBelRouteType))
			{/*列车进路或折返进路区故解延时45s*/

				if ((dwCurCycleNum - dwDelayUnlockStartCycNum) <= dwBlocRouteDelayCount)
				{
					wTimeData = (UINT16)(((dwBlocRouteDelayCount + dwDelayUnlockStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000);

					/*添加区故解计时反馈*/
					SetCiSendCmdBackInfoData(CI_BACK_COUNT_SECFAULT, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)wTimeData, 0U);
				}
			}
			else if (ROUTE_TYPE_DIAOCHE == chPhyBelRouteType)
			{/*调车进路区故解延时30s*/

				if (dwCurCycleNum - dwDelayUnlockStartCycNum <= dwFaultUnlockCount)
				{
					wTimeData = (UINT16)(((dwFaultUnlockCount + dwDelayUnlockStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000);
					/*添加区故解计时反馈*/
					SetCiSendCmdBackInfoData(CI_BACK_COUNT_SECFAULT, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)wTimeData, 0U);
				}
			}
			else
			{
				/*其他进路类型不处理*/
			}
		}
	}
#endif
	UINT8 chLogSectionSum = 0U;/*物理区段包含逻辑区段数目*/
	UINT16* pPhyIncLogId = NULL;   /*物理区段包含逻辑区段ID数组*/
	UINT8 ii = 0U;
	UINT32 dwDelayUnlockStartCycNum = 0U;/*逻辑区段区故解延时解锁起始周期号*/
	UINT32 dwAppCycTime = 0U;/*联锁周期数*/
	UINT32 dwCurCycleNum = 0U;/*当前周期数*/
	UINT16 wTimeData = 0U;/*反馈的倒计时时间*/
	UINT32 dwBlocRouteDelayCount = 0U;/*点式进路延时解锁周期数*/
	UINT16 wPhyBackFlag = 0U;/*物理区段反馈倒计时标志*/
	UINT8 chLocalCiId = 0U;/*本地联锁ID*/
	UINT8 chPhyBelongCiId = 0U;/*物理区段所属联锁ID*/

	dwAppCycTime = GetSystemParaAppCycleTime();/*获取联锁周期号*/
	dwCurCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/
	dwBlocRouteDelayCount = GetSystemParaBlocRouteDelayCyc();
	chLocalCiId = GetSystemParaLocalCiId();

	if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId))
	{

		chPhyBelongCiId = GetPhySecBelongCiId(wPhySecId);
		if (chLocalCiId == chPhyBelongCiId)
		{
			chLogSectionSum = GetPhySecIncLogSecSum(wPhySecId);
			pPhyIncLogId = GetPhySecIncLogSecIdBuf(wPhySecId);
			if (NULL != pPhyIncLogId)
			{
				for (ii = 0U; ii < chLogSectionSum; ii++)
				{
					dwDelayUnlockStartCycNum = GetLogDelayErrlockStartCycNum(pPhyIncLogId[ii]);
					if (0U < dwDelayUnlockStartCycNum)
					{/*整个物理区段被一条进路锁闭，则找到对应的逻辑区段延时故障锁闭周期号有效，则直接设置物理区段倒计时标志*/
					/*物理区段的逻辑区段被不同进路锁闭，但下发区故解命令后同一个物理区段的逻辑区段延时周期同时设置，所以找到其中一个便设置标志*/
						wPhyBackFlag = 1U;
						break;
					}
				}
				if (1U == wPhyBackFlag)
				{/*区故解延时解锁倒计时*/
					if (dwCurCycleNum - dwDelayUnlockStartCycNum <= dwBlocRouteDelayCount)
					{
						wTimeData = (UINT16)(((dwBlocRouteDelayCount + dwDelayUnlockStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U);
						if (wTimeData > UINT8_MAX)
						{   /*当倒计时时间超出最大值时，则同一周期发两包数，一包为高字节，一包为低字节*/
							/*添加区故解计时反馈*/
							SetCiSendCmdBackInfoData(CI_BACK_COUNT_HALF_SECUNLO_HIGH, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)(wTimeData >> 8), 0U);
						}
						SetCiSendCmdBackInfoData(CI_BACK_COUNT_HALF_SECUNLO, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)wTimeData, 0U);
						SetPhyErrUnlockTime(wPhySecId, wTimeData);
					}
				}
				else
				{
					/*不存在延时解锁逻辑区段 清零区故解倒计时*/
					SetPhyErrUnlockTime(wPhySecId, 0U);
				}
			}
		}
		else
		{
			/*此处获取倒计时时间*/
			wTimeData = GetPhyErrUnlockTime(wPhySecId);
			if (0U < wTimeData)
			{
				if (wTimeData > UINT8_MAX)
				{/*当倒计时时间超出最大值时，则同一周期发两包数，一包为高字节，一包为低字节*/
					SetCiSendCmdBackInfoData(CI_BACK_COUNT_HALF_SECUNLO_HIGH, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)(wTimeData >> 8), 0U);
				}
				SetCiSendCmdBackInfoData(CI_BACK_COUNT_HALF_SECUNLO, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)wTimeData, 0U);
			}
		}
	}
}

/*
* 功能描述： 保护区段相关命令反馈倒计时处理
* 参数说明： const UINT16 wPhySecId  保护区段ID
* 返回值  ： void
* cgh-优化倒计时圈复杂度
*/
void OverlapTimeDataBackProcess(const UINT16 wOverlapId)
{
	UINT8 chOverlapBelongCiId = 0U;/*保护区段所属联锁*/
	UINT16* pOverlapPhySecBuf = NULL;/*保护区段包含物理区段ID数组*/
	UINT16 wTimeData = 0U;/*反馈的倒计时时间*/
	UINT16 wOverlapBelongRouteId = 0U;/*保护区段所属进路ID*/
	UINT8 wOverlapBelongRouteCiId = 0U;/*保护区段所属进路所属联锁*/
	UINT8 chLocalCiId = 0U;/*本地联锁ID*/
	UINT16 wRouteLastPhySectionId = 0U;/*保护区段所属进路最后一个物理区段ID*/
	UINT32 dwUtCtStartOccuCount = 0U; /*指定ID物理区段UT或CT占用起始周期号*/
	UINT16 wRLockBelongRouteId = 0U;/*指定ID物理区段进路锁闭所属进路ID*/
	UINT8 chTmpRouteBelongCiId = 0U;/*进路所属联锁过渡变量*/
	UINT8 chUtOrCtOccFlag = 0U;/*物理区段CT或者UT占用状态*/
	UINT32 dwRelyonStartCycNum = 0U;/*解锁起始倒计时*/
	UINT32 dwUtOverlapUnLockCount = 0U;/*防护区段ut解锁停稳周期数*/
	UINT32 dwCtOverlapUnLockCount = 0U; /*CT车占用进路内最后一个区段情况下的解锁停稳周期数*/
	UINT16 wRouteStopSteadyPhySecId = 0U;/*进路停稳物理区段ID*/
	UINT16 wOverlapAllClearRes = CI_ERROR;/*保护区段空闲检查标志*/
	UINT16 wTmpOvlpOccuSecId = 0U;/*临时变量，用作调用函数的出口参数，本函数中不关心其值*/
	UINT8 chTmpOvlpOccuSecSta = 0U;/*临时变量，用作调用函数的出口参数，本函数中不关心其值*/
	UINT8 chFuncSwitchSendTime = 0u;/*CBTC是否发送保护区段解锁倒计时*/
	UINT8 chABLFlag = 0U; /*进路最后物理区段ABL占用标志*/

	chLocalCiId = GetSystemParaLocalCiId();
	chFuncSwitchSendTime = GetCiFunctionSwitchConfig(FUNC_SWITCH_SEND_UNLOCK_OVERLEP_TIMER_COUNTDOWN);

	if ((0U < wOverlapId) && (OVERLAP_SUM_MAX > wOverlapId))
	{
		chOverlapBelongCiId = GetOverlapBelongCiId(wOverlapId);
		pOverlapPhySecBuf = GetOverlapPhySecIdBuf(wOverlapId);
		wOverlapBelongRouteId = GetOverlapBelongRouteId(wOverlapId);

		/*获取参数有效*/
		if ((0U < wOverlapBelongRouteId) && (NULL != pOverlapPhySecBuf))
		{
			wOverlapBelongRouteCiId = GetRouteBelongCiId(wOverlapBelongRouteId);
			/*保护区段属于本联锁*/
			if (chLocalCiId == chOverlapBelongCiId)
			{
				wRouteLastPhySectionId = GetRouteLastPhySectionId(wOverlapBelongRouteId);
				dwUtCtStartOccuCount = GetSecUtOrCtOccuStartCycNum(wRouteLastPhySectionId);
				/*进路顺序占压到最后一个区段的起始周期*/
				if (0U <dwUtCtStartOccuCount)
				{
					wRLockBelongRouteId = GetPhySecRLockBelongRouteId(wRouteLastPhySectionId);/*获取物理区段进路锁闭所属进路ID*/
					chTmpRouteBelongCiId = GetRouteBelongCiId(wRLockBelongRouteId);
					chUtOrCtOccFlag = GetPhySecPreOccState(wRouteLastPhySectionId);	/*获取物理区段CT或UT占用状态*/
					dwRelyonStartCycNum = CalculaOverlapUnlockStartCycNum(wOverlapId, wRouteLastPhySectionId);/*计算解锁起始倒计时*/
					if (LOGICSECTION_OCCUPY_UT == chUtOrCtOccFlag)/*UT占用*/
					{
						chABLFlag = GetPhySecABLTrainFlag(wRouteLastPhySectionId);
						if ((chLocalCiId == chTmpRouteBelongCiId))/*进路属于本联锁*/
						{/*此时保护区段解锁周期数为系统参数*/
							if (PHYSICAL_SECTION_ABLOCCUPY_YES != chABLFlag)
							{
								dwUtOverlapUnLockCount = (UINT16)GetSystemParaProtSecUnlockCyc();
							}
							else
							{
								/*ABL车采用CT车时间解锁*/
								dwUtOverlapUnLockCount = (UINT16)GetSystemParaCtProtSecUnlockCyc();
							}
						}
						else/*进路不属于本联锁*/
						{
							if (PHYSICAL_SECTION_ABLOCCUPY_YES != chABLFlag)
							{
								dwUtOverlapUnLockCount = GetOtherCIRouteOvlpUTUnlockCnt(wRLockBelongRouteId);
							}
							else
							{
								/*ABL车采用CT车时间解锁*/
								dwUtOverlapUnLockCount = GetOtherCIRouteOverlapCTUnlockCount(wRLockBelongRouteId);
							}
						}
						wRouteStopSteadyPhySecId = GetRouteStopSteadyPhySecId(wRLockBelongRouteId);/*获取进路停稳物理区段ID*/
						wOverlapAllClearRes = OverlapAllSecOccuClearCheck(wOverlapId, &wTmpOvlpOccuSecId, &chTmpOvlpOccuSecSta);
						if ((wRouteLastPhySectionId == wRouteStopSteadyPhySecId) && (CI_SUCCESS == wOverlapAllClearRes))
						{/*倒计时未超时*/

							wTimeData = GetOverlapUnlockBackTime(wOverlapId, (UINT16)dwUtOverlapUnLockCount, dwRelyonStartCycNum);

						}
					}
					else if (LOGICSECTION_OCCUPY_CT == chUtOrCtOccFlag)/*CT占用*/
					{
						if ((chLocalCiId == chTmpRouteBelongCiId))/*进路属于本联锁*/
						{/*此时保护区段解锁周期数为系统参数*/
							dwCtOverlapUnLockCount = GetSystemParaCtProtSecUnlockCyc();
						}
						else/*进路不属于本联锁*/
						{
							dwCtOverlapUnLockCount = GetOtherCIRouteOverlapCTUnlockCount(wRLockBelongRouteId);
						}
						if (FUNC_SWITCH_ON == chFuncSwitchSendTime)
						{/*功能打开*/
							wRouteStopSteadyPhySecId = GetRouteStopSteadyPhySecId(wRLockBelongRouteId);/*获取进路停稳物理区段ID*/
							wOverlapAllClearRes = OverlapAllSecOccuClearCheck(wOverlapId, &wTmpOvlpOccuSecId, &chTmpOvlpOccuSecSta);
							if ((wRouteLastPhySectionId == wRouteStopSteadyPhySecId) && (CI_SUCCESS == wOverlapAllClearRes))
							{
								wTimeData = GetOverlapUnlockBackTime(wOverlapId, (UINT16)dwCtOverlapUnLockCount, dwRelyonStartCycNum);
							}
						}

					}
					else
					{
						/*占用类型故障*/
					}

					if (0u < wTimeData)/*存在倒计时*/
					{
						if (wTimeData > UINT8_MAX)
						{/*当倒计时时间超出最大值时，则同一周期发两包数，一包为高字节，一包为低字节*/
							SetCiSendCmdBackInfoData(CI_BACK_COUNT_OVERLAP_UNLOCK_HIGH, CI_DEVICE_TYPE_PHYSEC, pOverlapPhySecBuf[0], (UINT8)(wTimeData >> 8), 0U);

						}
						SetCiSendCmdBackInfoData(CI_BACK_COUNT_OVERLAP_UNLOCK, CI_DEVICE_TYPE_PHYSEC, pOverlapPhySecBuf[0], (UINT8)wTimeData, 0U);
					}
					SetOverlapUnlockTime(wOverlapId, wTimeData);
				}
				else
				{
					SetOverlapUnlockTime(wOverlapId, 0U);/*清除倒计时，因为区段再次占用时，要重新以区段占用开始时间作为倒计时参考，重新记时*/
				}
			}
			else
			{
				if (chLocalCiId == wOverlapBelongRouteCiId)/*保护区段锁闭所属进路属于本联锁*/
				{
					/*此处获取倒计时时间*/
					wTimeData = GetOverlapUnlockTime(wOverlapId);
					if (0U < wTimeData)
					{
						if (wTimeData > UINT8_MAX)
						{/*当倒计时时间超出最大值时，则同一周期发两包数，一包为高字节，一包为低字节*/
							SetCiSendCmdBackInfoData(CI_BACK_COUNT_OVERLAP_UNLOCK_HIGH, CI_DEVICE_TYPE_PHYSEC, pOverlapPhySecBuf[0], (UINT8)(wTimeData >> 8), 0U);
						}
						SetCiSendCmdBackInfoData(CI_BACK_COUNT_OVERLAP_UNLOCK, CI_DEVICE_TYPE_PHYSEC, pOverlapPhySecBuf[0], (UINT8)wTimeData, 0U);
					}
				}
				else
				{
					/*无操作*/
				}
			}
		}
		else
		{
			SetOverlapUnlockTime(wOverlapId, 0U);/*没有锁闭，清0*/
		}
	}
	else
	{
		SetOverlapUnlockTime(wOverlapId, 0U);/*没有锁闭，清0*/
	}
}
/*
* 功能描述： 总复位继电器反馈倒计时处理
* 参数说明： void
* 返回值  ： void
* cgh-优化倒计时圈复杂度
*/
void ZFWJTimeDataBackProcess(void)
{
	UINT8 jj = 0U;
	UINT8 chIncludeVirFlag = 0U;/*支持虚拟联锁划分开关*/
	UINT8 chVirCiNum = 0U;/*获取本联锁包含的虚拟联锁数目*/
	UINT8 chVirCiId = 0U;/*虚拟联锁ID*/
	UINT32 dwAppCycTime = 0U;/*联锁周期数*/
	UINT32 dwCurCycleNum = 0U;/*当前周期数*/
	UINT8 chLocalCiId = 0U;/*当前联锁ID*/
	UINT16 wRelayZFWId = 0U;/*总复位继电器ID*/
	UINT32 dwZFWJDriveTimeCount = 0U;/*计轴总复位驱动失效超限周期数*/
	UINT32 dwZFWValidCycNum = 0U;/*总复位继电器有效周期*/
	UINT32 dwCycleCost = 0U;/*倒计时计算结果*/
	UINT16 wTimeData = 0U;/*反馈的倒计时时间*/

	dwAppCycTime = GetSystemParaAppCycleTime();/*获取联锁周期号*/
	dwCurCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/
	chLocalCiId = GetSystemParaLocalCiId();
	chIncludeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	dwZFWJDriveTimeCount = GetZFWJRelayDriveTimeCount();

	if (FUNC_SWITCH_ON == chIncludeVirFlag)
	{
		chVirCiNum = GetVirtualCINum();
		for (jj = 0u; jj < chVirCiNum; jj++)
		{
			chVirCiId = GetVirtualCIid(jj);
			wRelayZFWId = GetZFWRelayId_UseVirCI(chLocalCiId, chVirCiId);         /*总复位继电器ID*/
			if (wRelayZFWId > 0u)
			{
				dwZFWValidCycNum = GetVirCIZfwValidCycNum(chVirCiId);
				/*ZFWJ状态有效周期*/
				dwCycleCost = dwCurCycleNum - dwZFWValidCycNum;
				if ((0U < dwCycleCost) && (dwCycleCost <= dwZFWJDriveTimeCount) && (dwZFWValidCycNum > 0U))
				{
					wTimeData = (UINT16)(((dwZFWJDriveTimeCount + dwZFWValidCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U);
					/*添加计轴总复位按钮有效倒计时反馈*/
					SetCiSendCmdBackInfoData(CI_BACK_COUNT_ZFWJ_VALID, CI_DEVICE_TYPE_RELAY, wRelayZFWId, (UINT8)wTimeData, 0U);
				}
			}
		}
	}
	else
	{
		wRelayZFWId = GetZFWRelayId(chLocalCiId);         /*总复位继电器ID*/
		if (wRelayZFWId > 0u)
		{
			dwZFWValidCycNum = GetZFWValidCycNum();
			/*ZFWJ状态有效周期*/
			dwCycleCost = dwCurCycleNum - dwZFWValidCycNum;
			if ((0U < dwCycleCost) && (dwCycleCost <= dwZFWJDriveTimeCount) && (dwZFWValidCycNum > 0U))
			{
				wTimeData = (UINT16)(((dwZFWJDriveTimeCount + dwZFWValidCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U);
				/*添加计轴总复位按钮有效倒计时反馈*/
				SetCiSendCmdBackInfoData(CI_BACK_COUNT_ZFWJ_VALID, CI_DEVICE_TYPE_RELAY, wRelayZFWId, (UINT8)wTimeData, 0U);
			}
		}
	}
}

/*
* 功能描述： 非进路反馈倒计时处理
* 参数说明： NonRouteDataStruct* pNonRoute 非进路数据结构体
* 返回值  ： void
* cgh-优化倒计时圈复杂度
*/
void NonRouteTimeDataBackProcess(NonRouteDataStruct* pNonRoute)
{
	UINT32 dwAppCycTime = 0U;/*联锁周期数*/
	UINT32 dwCurCycleNum = 0U;/*当前周期数*/
	UINT32 dwNonRouDelayUnlockCount = 0U;/*非进路延时解锁总周期数*/
	UINT16 wTimeData = 0U;/*反馈的倒计时时间*/

	dwAppCycTime = GetSystemParaAppCycleTime();/*获取联锁周期号*/
	dwCurCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/
	dwNonRouDelayUnlockCount = GetSystemParaNonRDelayUnlockCnt();

	if (NULL != pNonRoute)
	{
		/*非进路取消倒计时反馈*/
		if (pNonRoute->DelayUnlockStartCycleNum > 0u)
		{/*非进路取消倒计时*/

			if ((dwCurCycleNum - pNonRoute->DelayUnlockStartCycleNum) <= dwNonRouDelayUnlockCount)
			{
				wTimeData = (UINT16)(((dwNonRouDelayUnlockCount + pNonRoute->DelayUnlockStartCycleNum - dwCurCycleNum) * dwAppCycTime) / 1000U);
				/*添加总人解计时反馈*/
				SetCiSendCmdBackInfoData(CI_BACK_COUNT_CANCEL_NONROUTE, CI_DEVICE_TYPE_NONROUTE, pNonRoute->NonRouteId, (UINT8)wTimeData, 0U);
			}
		}
	}
}

/*
* 功能描述： 防淹门延时关门相关命令反馈倒计时处理
* 参数说明： const UINT16 wFloodGateId  防淹门ID
* 返回值  ： void
*/
void FloodGateTimeDataBackProcess(const UINT16 wFloodGateId)
{
	UINT32 dwAppCycTime = 0U;/*联锁周期数*/
	UINT32 dwCurCycleNum = 0U;/*当前周期数*/
	UINT32 FloodGateDelayCloseCount = 0U;/*防淹门延时关闭总周期数*/
	UINT32 dwFloodGateCloseStartCycNum = 0u;		/*防淹门延时关闭起始周期号*/
	UINT16 wTimeData = 0U;/*反馈的倒计时时间*/

	dwAppCycTime = GetSystemParaAppCycleTime();/*获取联锁周期号*/
	dwCurCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/
	FloodGateDelayCloseCount = GetFloodGateDelayCloseCount();

	if ((0U < wFloodGateId) && (FLOOD_GATE_SUM_MAX > wFloodGateId))
	{
		dwFloodGateCloseStartCycNum = GetFloodGateDelayCloseStartCnt(wFloodGateId);
		if (0U < dwFloodGateCloseStartCycNum)
		{
			if ((dwCurCycleNum - dwFloodGateCloseStartCycNum) <= FloodGateDelayCloseCount)
			{
				wTimeData = (UINT16)(((FloodGateDelayCloseCount + dwFloodGateCloseStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U);
				if (wTimeData > UINT8_MAX)
				{   /*当倒计时时间超出最大值时，则同一周期发两包数，一包为高字节，一包为低字节*/
					/*添加防淹门延时关门计时反馈*/
					SetCiSendCmdBackInfoData(CI_BACK_COUNT_FLOODGATE_CLOSE_HIGH, CI_DEVICE_TYPE_FLOODGATE, wFloodGateId, (UINT8)(wTimeData >> 8), 0U);
				}
				SetCiSendCmdBackInfoData(CI_BACK_COUNT_FLOODGATE_CLOSE, CI_DEVICE_TYPE_FLOODGATE, wFloodGateId, (UINT8)wTimeData, 0U);
			}
		}
	}
}


/*
* 功能描述： 处理后备列车发送数据信息
* 参数说明： void
* 返回值  ： 无
*/
void VobcBackUpOutputProcess(void)
{
	UINT8 ii = 0U;
	UINT16 wTrainId = 0U;/*列车ID*/
	UINT8 chMainValid = 0U;/*主用列车通信状态*/
	UINT16 wVobcId = 0U;/*VOBC ID*/
	UINT8 chBackUpValid = 0U;/*备用通信有效标志*/

	for (ii = 0U; ii < TRAIN_SUM_MAX; ii++)
	{
		wTrainId = GetTrainId(ii);

		chBackUpValid = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(wTrainId & 0x00ffU));
		chMainValid = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC, (UINT8)(wTrainId & 0x00ffU));
		wVobcId = 0U;

		
		if ((CI_SUCCESS == chMainValid) || (CI_SUCCESS == chBackUpValid))
		{
			/*先计算一下车身所在进路是否有反向*/
			wVobcId = wTrainId & 0x00ffU;

			VobcLocReverseRouteCheck(wVobcId);

			/*列车当前周期主用或者备用通信有效 更新列车前车位置*/
			VobcHeadTrainDataProc(wVobcId); 

			/*后备有数据发送过来，或者510主用通信良好，均需要计算后备数据*/
			/*先清除所有要发送的后备列车信息，然后重新计算*/
			ClearBackUpTrainInfo(wVobcId);

			/*脚下逻辑区段计算*/
			VobcBackUpLogSecManage(wVobcId);

			/*脚下以及前方所有进路计算及折返逻辑区段计算*/
			VobcBackUpRouteManage(wVobcId);

			/*Psd Esb 信息计算*/
			VobcBackUpPsdEsbManage(wVobcId);

#if 0
			/*道岔信息计算*/
			VoBcBackUpSwitchManage(&VobcBackUpToCiDataStru[ii]);
#endif

			/*保护区段计算*/
			VobcBackUpProSecManage(wVobcId);

			/*限速信息计算*/
			VobcBackUpXiansuSecManage(wVobcId);


			/*脚下进路逻辑区段空闲信息计算*/
			VobcBackUpRouteNoOccuManage(wVobcId);
		}
		else
		{
			; /*不通信的车不计算*/
		}
	}
}

/*
* 功能描述： 处理后备列车发送逻辑区段数据信息
* 参数说明： const UINT16 wTrainId 列车ID
* 返回值  ： 无
* by cgh 20240710
*/
void VobcBackUpLogSecManage(const UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 TrainMinSafeTailLink = 0U;
	UINT16 LinkRelatedPhySecId = 0U;
	UINT16 TrainMaxSafeHeadLink = 0U;
	UINT16 wTrainHeadLogSecRLockId = 0U;
	struct_PathPoint start = { 0U };  /*列车逻辑起点*/
	struct_PathPoint end = { 0U };    /*列车逻辑终点*/
	UINT16 wTrainOccLogSum = 0U;      /*列车脚下逻辑区段数量*/
	UINT16 wTrainOccLogID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U };   /*列车占压的逻辑区段ID*/
	UINT8 chVobcBackUpLogSum = 0U;								/*后备发送的逻辑区段数量*/
	UINT16 wVobcBackUpLogID[TRAIN_ABL_LOGSEC_SUM] = { 0U };		/*后备发送的逻辑区段数组*/
	ABLTrainRelLogStru ablVobcBackUpLogSecStr[TRAIN_ABL_LOGSEC_SUM] = { 0U };
	UINT16 RouteLogSectionSum = 0u;			/*车头所在进路包含的逻辑区段*/
	UINT16* RouteLogSectionIdBuf = NULL;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT8 chVobcBackUpRouteSum = 0U;		/*需要发送后备列车进路总数量(记录车脚下)*/
	UINT16 wVobcBackUpRouteID = 0U;		/*锁闭逻辑区段所属进路ID*/
	ABLTrainRelAllRouteStru ablVobcBackUpRouteStr[TRAIN_ABL_ALLROUTE_SUM] = { 0U };
	UINT8 wFlag = 0U;		/*开始记录进路的标志*/
	UINT16 wTrainHeadBelongLogSec = 0U;  /*车头所在逻辑区段ID*/
	UINT8 chLogSecBelSendRange = CI_ERROR;/*初始为属于传输范围*/
	UINT8 chTrainAblRelLogSecNum = 0U;/*最终要发送的逻辑区段数目*/

	if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId))
	{
		/*车尾所在进路*/
		TrainMinSafeTailLink = GetAblTrainMinTailLink(wTrainId);
		LinkRelatedPhySecId = GetLinkRelatedPhySec(TrainMinSafeTailLink);
		start.wLinkId = TrainMinSafeTailLink;
		start.dwOffset = GetAblTrainMinTailOffset(wTrainId);

		/*车头所在进路*/
		TrainMaxSafeHeadLink = GetAblTrainMaxHeadLink(wTrainId);
		end.wLinkId = TrainMaxSafeHeadLink;
		end.dwOffset = GetAblTrainMaxHeadOffset(wTrainId);
		/*查出车头所在的逻辑区段*/
		wTrainHeadBelongLogSec = GetPointBelongLogSec(end);
		wTrainHeadLogSecRLockId = GetLogSecLockBelongRoute(wTrainHeadBelongLogSec);
		chRetVal = GetLogSecBtwTwoPoints(start, end, &wTrainOccLogSum, wTrainOccLogID);

		if (CI_SUCCESS == chRetVal)
		{
			/*记录ABL列车脚下逻辑区段数据*/
			SetTrainAblOcculogData(wTrainId, (UINT8)wTrainOccLogSum, wTrainOccLogID);
			/*记录ABL列车车头逻辑区段*/
			SetTrainAblMaxHeadLogId(wTrainId, wTrainHeadBelongLogSec);
			
			/*记录脚下的逻辑区段数量和区段ID*/
			chVobcBackUpLogSum = (UINT8)wTrainOccLogSum;
			(void)CommonMemCpy(wVobcBackUpLogID, (UINT32)(sizeof(UINT16)*TRAIN_ABL_LOGSEC_SUM), wTrainOccLogID, (UINT32)(sizeof(UINT16)*wTrainOccLogSum));
			/*查车头所在进路的所有逻辑区段*/
			RouteLogSectionSum = GetRouteLogSectionSum(wTrainHeadLogSecRLockId);
			RouteLogSectionIdBuf = GetRouteLogSectionIdBuf(wTrainHeadLogSecRLockId);


			/*计算车头所在进路(往终端信号机)剩下的全部逻辑区段*/
			for (ii = 0U; ii < RouteLogSectionSum; ii++)
			{
				if ((wTrainHeadBelongLogSec == RouteLogSectionIdBuf[ii]) && (0U == wFlag))
				{
					wFlag = 1U;		/*查进路的所有逻辑区段，查到了车头所在逻辑区段位置，往后所有开始记录入要发送的逻辑区段*/
					for (jj = 0U; jj < chVobcBackUpLogSum; jj++)
					{
						if (RouteLogSectionIdBuf[ii] == wVobcBackUpLogID[jj])
						{
							break;		/*车头已存入，不再存*/
						}
					}
					/*车头未存入，需要存一次*/
					if ((jj == chVobcBackUpLogSum) && (TRAIN_ABL_LOGSEC_SUM > chVobcBackUpLogSum))
					{
						wVobcBackUpLogID[chVobcBackUpLogSum] = RouteLogSectionIdBuf[ii];
						chVobcBackUpLogSum++;
					}
				}
				else
				{

				}
				/*找到了车头，开始存，车头所在逻辑区段已存入，不再存入*/
				if ((1U == wFlag) && (TRAIN_ABL_LOGSEC_SUM > chVobcBackUpLogSum) && (wTrainHeadBelongLogSec != RouteLogSectionIdBuf[ii]))
				{
					wVobcBackUpLogID[chVobcBackUpLogSum] = RouteLogSectionIdBuf[ii];
					chVobcBackUpLogSum++;
				}
			}

			/*设置要发送的逻辑区段信息*/
			for (ii = 0U; ii < chVobcBackUpLogSum; ii++)
			{
				chLogSecBelSendRange = CheckLogSecBelSendRange(wVobcBackUpLogID[ii]);
				if (CI_ERROR == chLogSecBelSendRange)
				{
					ablVobcBackUpLogSecStr[chTrainAblRelLogSecNum].chAblRelLogSecDir = GetLogSecLockDir(wVobcBackUpLogID[ii]);
					ablVobcBackUpLogSecStr[chTrainAblRelLogSecNum].wAblRelLogSecId = wVobcBackUpLogID[ii];
					chTrainAblRelLogSecNum++;
				}
				else
				{
					;/*不添加*/
				}	
			}

			SetTrainAblRelLogSecNum(wTrainId, chTrainAblRelLogSecNum);		/*设置要发送的逻辑区段数量*/
			SetTrainAblRelLogSecData(wTrainId, ablVobcBackUpLogSecStr);

			if (0U != wTrainHeadLogSecRLockId)
			{
				/*设置脚下进路信息*/
				for (ii = 0U; ii < wTrainOccLogSum; ii++)
				{
					wVobcBackUpRouteID = GetLogSecLockBelongRoute(wTrainOccLogID[ii]);
					for (jj = 0U; jj < chVobcBackUpRouteSum; jj++)
					{
						if (wVobcBackUpRouteID == ablVobcBackUpRouteStr[jj].wAblRelRouteId)
						{
							break;		/*去重，防止存入多余进路*/
						}
					}

					if ((jj == chVobcBackUpRouteSum) && (TRAIN_ABL_ALLROUTE_SUM > chVobcBackUpRouteSum) && (0U != wVobcBackUpRouteID))
					{
						ablVobcBackUpRouteStr[chVobcBackUpRouteSum].wAblRelRouteId = wVobcBackUpRouteID;
						ablVobcBackUpRouteStr[chVobcBackUpRouteSum].chAblRelTrainInFlag = TRAIN_ABL_ROUTE_FLAG_YES;
						chVobcBackUpRouteSum++;
					}
				}
				SetTrainAblAllRouteNum(wTrainId, chVobcBackUpRouteSum);
				SetTrainAblRelAllRouteData(wTrainId, ablVobcBackUpRouteStr);
			}
			else
			{
				; /*车头所在道岔四开；不添加脚下进路*/
			}
		}
		else
		{
			;	/*不处理*/
		}
	}
	else
	{
		;	/*不处理*/
	}
}

/*
* 功能描述： 处理后备列车发送进路数据信息(折返进路需要记录折返逻辑区段信息)
* 参数说明： const UINT16 wTrainId 列车ID
* 返回值  ： 无
* by cgh 20240710
*/
void VobcBackUpRouteManage(const UINT16 wTrainId)
{
	UINT16 TrainMaxSafeHeadLink = 0U;
	UINT16 wTrainHeadLogSecRLockId = 0U;
	UINT8 wFlag = 1U;
	UINT16 RouteLeavePhySecId = 0U;		/*进路离去区段*/
	UINT16 chVobcBackUpRouteId = 0U;
	UINT8 ablVobcBackUpRouteNum = 0U;
	ABLTrainRelAllRouteStru ablVobcBackUpRouteStr[TRAIN_ABL_ALLROUTE_SUM] = { 0U };
	ABLTrainRelAllRouteStru* ablVobcBackUpTrainRouteStr = NULL;
	UINT8 RouteState = 0U;
	UINT8 ii = 0U;
	UINT8 jj = 0U;
	UINT8 mm = 0U;
	UINT16 chVobcBackReturnRouteId = 0U;
	UINT8 RouteType = 0U;
	UINT8 ablVobcBackUpReturnLogSum = 0U;
	UINT16 ablVobcBackUpReturnLogBuf[TRAIN_ABL_RETURNLOGSEC_SUM] = { 0U };
	UINT16 RouteLastPhySectionId = 0u;
	UINT16 nlockSectionId = 0U;
	UINT16 validReturnSigId = 0U;
	UINT16* PhySecIncLogSecIdBuf = NULL;
	UINT8 PhySecIncLogSecSum = 0U;
	UINT16 chPreRouteEndSignalId = 0U;
	UINT16 chNextRouteStartSignalId = 0U;
	UINT8 chLocalCiId = 0U;
	UINT16 wOutFirstPhySec = 0U;
	UINT16 wTrainHeadBelongLogSec = 0U;
	UINT8 chRouteCiId = 0U;
	UINT8 chPhyCiId = 0U;
	UINT8 chTrainLocReverseRouteFlag = 0U;
	UINT8 chRouteReverseFlag = 0U;
	UINT8 chRouteLevel = 0U;
	struct_PathPoint end = { 0U };    /*列车逻辑终点*/

	if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId))
	{
		chLocalCiId = GetSystemParaLocalCiId();
		/*车头所在进路*/
		TrainMaxSafeHeadLink = GetAblTrainMaxHeadLink(wTrainId);
		end.wLinkId = TrainMaxSafeHeadLink;
		end.dwOffset = GetAblTrainMaxHeadOffset(wTrainId);
		/*查出车头所在的逻辑区段*/
		wTrainHeadBelongLogSec = GetPointBelongLogSec(end);
		wTrainHeadLogSecRLockId = GetLogSecLockBelongRoute(wTrainHeadBelongLogSec);

		ablVobcBackUpRouteNum = GetTrainAblAllRouteNum(wTrainId);
		ablVobcBackUpTrainRouteStr = GetTrainAblRelAllRouteData(wTrainId);

		/*将脚下进路拷贝到局部内*/
		(void)CommonMemCpy(ablVobcBackUpRouteStr, (UINT32)(sizeof(ABLTrainRelAllRouteStru)*TRAIN_ABL_ALLROUTE_SUM),
			ablVobcBackUpTrainRouteStr, (UINT32)(sizeof(ABLTrainRelAllRouteStru)*ablVobcBackUpRouteNum));

		/*检查车头所在进路的类型，若为折返进路，需要考虑离去区段为折返回来的进路*/
		RouteType = GetRouteType(wTrainHeadLogSecRLockId);

		if (ROUTE_TYPE_RETURN == RouteType)
		{
			nlockSectionId = GetRouteFirstNormalLockSection(wTrainHeadLogSecRLockId);		/*第一个属于当前进路的【正常锁闭】区段*/
			validReturnSigId = GetValidReturnSinalId(wTrainHeadLogSecRLockId, nlockSectionId);		/*有效折返信号机*/
			RouteLeavePhySecId = GetSignalInFirstLockedPhySecId(validReturnSigId);			/*折出区段，折返进路离去区段*/
			chPreRouteEndSignalId = validReturnSigId;		/*折返进路的终端信号机为折出信号机*/
		}
		else
		{
			/*查车头所在进路的离去区段，继续向下查询进路*/
			RouteLeavePhySecId = GetRouteLeavePhySecId(wTrainHeadLogSecRLockId);
			chPreRouteEndSignalId = GetRouteEndSignalId(wTrainHeadLogSecRLockId);
		}
		chTrainLocReverseRouteFlag = GetTrainLocReverseRouteFlag(wTrainId);
		/*查询车头前方的进路 脚下为反向进路时，不继续查询*/
		while ((1U == wFlag)&&(TRAIN_LOC_REV_ROUTE_FLAG_NO ==chTrainLocReverseRouteFlag))
		{
			chVobcBackUpRouteId = GetPhySecRLockBelongRouteId(RouteLeavePhySecId);
			chRouteCiId = GetRouteBelongCiId(chVobcBackUpRouteId);
			RouteState = GetRouteState(chVobcBackUpRouteId);
			chNextRouteStartSignalId = GetRouteStartSignalId(chVobcBackUpRouteId);		
			wOutFirstPhySec = GetSignalOutFirstPhySecId(chNextRouteStartSignalId);
			chPhyCiId = GetPhySecBelongCiId(wOutFirstPhySec);
			chRouteReverseFlag = GetRouteReverseProperty(chVobcBackUpRouteId);
			chRouteLevel = GetRouteLevel(chVobcBackUpRouteId);

			if ((ROUTE_STATE_NEAR_OPEN == RouteState) && (TRAIN_ABL_ALLROUTE_SUM > ablVobcBackUpRouteNum)
				&& (chVobcBackUpRouteId != wTrainHeadLogSecRLockId)	/*检查离去区段锁闭的进路不能为脚下进路，防止折返的情况计入脚下进路*/
				&& (chNextRouteStartSignalId == chPreRouteEndSignalId)
				&& (ROUTE_LEVEL_BLOC == chRouteLevel)
				&& (ROUTE_REVERSE_PROPERTY_NO ==chRouteReverseFlag) /*前方进路不为反向进路*/
				&& ((chPhyCiId == chLocalCiId) || (chRouteCiId == chLocalCiId)))
			{/*比较下一条锁闭进路的起始信号机为前一条进路的终止信号机(或者折出信号机)，保证离去区段锁闭的进路方向和车头脚下一致，下一进路或进路外方第一物理区段至少有一个属于本控区*/
				/*进路接近开放，计入进路ID*/
				ablVobcBackUpRouteStr[ablVobcBackUpRouteNum].wAblRelRouteId = chVobcBackUpRouteId;
				ablVobcBackUpRouteStr[ablVobcBackUpRouteNum].chAblRelTrainInFlag = TRAIN_ABL_ROUTE_FLAG_NO;
				ablVobcBackUpRouteNum++;

				/*更新进路的离去区段,更新进路的终端信号机*/
				RouteLeavePhySecId = GetRouteLeavePhySecId(chVobcBackUpRouteId);
				chPreRouteEndSignalId = GetRouteEndSignalId(chVobcBackUpRouteId);

				wFlag = 1U;
			}
			else
			{
				wFlag = 0U;			/*进路不为接近开放，进路超限，车脚下进路折返，且折返回来的进路还没办，跳出循环*/
			}
		}
		SetTrainAblAllRouteNum(wTrainId, ablVobcBackUpRouteNum);
		SetTrainAblRelAllRouteData(wTrainId, ablVobcBackUpRouteStr);

		/*检查要发送的所有进路是否有折返进路，有折返进路则设置要发送的折返区段所有逻辑区段*/
		for (ii = 0U; ii < ablVobcBackUpRouteNum; ii++)
		{
			chVobcBackReturnRouteId = ablVobcBackUpTrainRouteStr[ii].wAblRelRouteId;
			RouteType = GetRouteType(chVobcBackReturnRouteId);
			/*查所有折返进路折返区段逻辑区段，来回折返*/
			if (ROUTE_TYPE_RETURN == RouteType)
			{
				RouteLastPhySectionId = GetRouteLastPhySectionId(chVobcBackReturnRouteId);
				PhySecIncLogSecSum = GetPhySecIncLogSecSum(RouteLastPhySectionId);
				PhySecIncLogSecIdBuf = GetPhySecIncLogSecIdBuf(RouteLastPhySectionId);
				/*将所有折返进路的折返区段存入*/
				if (TRAIN_ABL_RETURNLOGSEC_SUM > ablVobcBackUpReturnLogSum)
				{
					for (jj = 0U; jj < PhySecIncLogSecSum; jj++)
					{
						for (mm = 0U; mm < ablVobcBackUpReturnLogSum; mm++)
						{
							if (PhySecIncLogSecIdBuf[jj] == ablVobcBackUpReturnLogBuf[mm])
							{
								break;/*已经存在跳出*/
							}
							else
							{
								; /*继续*/
							}
						}
						if (ablVobcBackUpReturnLogSum == mm)
						{
							/*说明未重复*/
							ablVobcBackUpReturnLogBuf[ablVobcBackUpReturnLogSum] = PhySecIncLogSecIdBuf[jj];
							ablVobcBackUpReturnLogSum++;
						}
						else
						{
							; /*已经存在不添加*/
						}
					}
				}
				else
				{
					;		/*要发送的折返逻辑区段数量超限*/
				}
			}
			else
			{
				;	/*无折返进路，不设置折返区段信息*/
			}
		}

		SetTrainAblRelReturnLogNum(wTrainId, ablVobcBackUpReturnLogSum);
		SetTrainAblRelReturnLogId(wTrainId, ablVobcBackUpReturnLogBuf);
	}
	else
	{
		;	/*不处理*/
	}
}

/*
* 功能描述： 后备列车发送保护区段数据信息处理
* 参数说明： const UINT16 wTrainId 列车ID
* 返回值  ： 无
* by cgh 20240710
*/
void VobcBackUpProSecManage(const UINT16 wTrainId)
{
	UINT8 chReval = CI_ERROR;
	UINT8 chAblRouteNum = 0U;/*ABL列车对应进路数目*/
	ABLTrainRelAllRouteStru* pAblRouteData = NULL;/*ABL列车对应进路数据*/
	UINT8 ii = 0U;
	UINT16 wRouteOverlapLockId = 0U;/*进路锁闭保护区段ID*/
	ABLTrainRelProSecStru szTempProSecData[TRAIN_ABL_PROSEC_SUM] = {0U};/*临时保护区段数据数组*/
	UINT8 chAblProSecNum = 0U;/*保护区段数目*/
	UINT8 chOverlapLogSecSum = 0U;/*保护区段对应逻辑区段数目*/
	UINT16* wOverlapLogSecIdBuf = NULL;/*保护区段对应逻辑区段ID*/
	UINT8 chAblProSecLockDir = 0U;/*保护区段锁闭方向*/
	UINT8 chLogSecProResUseState = 0U;/*逻辑区段保护区段资源可用状态*/
	UINT8 jj = 0U;
	
	if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId))
	{
		/*每周期均先清除数据，下面设置*/
		ClearTrainAblRelXiansuData(wTrainId);

		chAblRouteNum = GetTrainAblAllRouteNum(wTrainId);
		pAblRouteData = GetTrainAblRelAllRouteData(wTrainId);

		if ((TRAIN_ABL_ALLROUTE_SUM >= chAblRouteNum) && (NULL != pAblRouteData))
		{
			for (ii = 0U; ii < chAblRouteNum; ii++)
			{
				wRouteOverlapLockId = GetRouteOverlapLockedId(pAblRouteData[ii].wAblRelRouteId);
				if (0U != wRouteOverlapLockId)
				{
					chOverlapLogSecSum = GetOverlapLogicSectionSum(wRouteOverlapLockId);
					wOverlapLogSecIdBuf = GetOverlapLogicSectionBuf(wRouteOverlapLockId);

					if((0U < chOverlapLogSecSum) && (NULL != wOverlapLogSecIdBuf))
					{
						/*在设置逻辑区段保护区段资源可用状态时已经检查过对应保护区段资源可用条件；此处直接获取保护区段任意一个逻辑区段可用即可*/
						chLogSecProResUseState = GetLogSecProResUseState(wOverlapLogSecIdBuf[0]);
						/*保护区段中间不允许方向变化点且如果进路和保护区段之间有方向变化点；保护区段锁闭方向为实际锁闭方向*/
						chAblProSecLockDir = GetLogSecLockDir(wOverlapLogSecIdBuf[0U]);

						if ((TRAIN_ABL_PROSEC_SUM > chAblProSecNum) && (LOGIC_SECTION_PRO_RES_USABLE == chLogSecProResUseState))
						{
							szTempProSecData[chAblProSecNum].wAblRelProSecId = wRouteOverlapLockId;
							szTempProSecData[chAblProSecNum].chAblRelProSecDir = chAblProSecLockDir;
							chAblProSecNum++;
						}
						else
						{
							; /*数组溢出或状态不可用不添加*/
						}

						/*后备通道区段临时限速需要添加保护区段*/
						for (jj = 0U; jj < chOverlapLogSecSum; jj++)
						{
							AddXiansuPhySecData(wOverlapLogSecIdBuf[jj], wTrainId);
						}
					}
				}
				else
				{
					; /*此进路不添加保护区段*/
				}	
			}

			/*存储保护区段数目及数据*/
			SetTrainAblRelProSecNum(wTrainId, chAblProSecNum);
			SetTrainAblRelProSecData(wTrainId, szTempProSecData);
		}
		else
		{
			; /*不处理*/
		}
	}
	else
	{
		;	/*不处理*/
	}
}

/*
* 功能描述： 后备列车发送限速区段数据信息处理
* 参数说明： const UINT16 wTrainId 列车ID
* 返回值  ： 无
* by cgh 20240710
*/
void VobcBackUpXiansuSecManage(const UINT16 wTrainId)
{
	UINT8 chAblLogSecNum = 0U;/*ABL列车对应逻辑区段数目*/
	ABLTrainRelLogStru* pAblLogSecData = NULL;/*ABL列车对应逻辑区段数据*/
	UINT8 chAblRouteNum = 0U;/*ABL列车对应进路数目*/
	ABLTrainRelAllRouteStru* pAblRouteData = NULL;/*ABL列车对应进路数据*/
	UINT8 ii = 0U;
	UINT16 jj = 0U;
	UINT16 wRouteLogSecNum = 0U;/*进路逻辑区段数目*/
	UINT16* szRouteLogSecIdBuf = NULL;/*进路逻辑区段ID数组*/
	UINT8 chOverlopSum = 0U;/*保护区段数目*/
	UINT16 wRouteLeavePhySecId = 0U;/*进路离去物理区段ID*/
	UINT16 wRouteInLastLogSecId = 0U;/*进路最后一个逻辑区段ID*/
	UINT8 chPhySecType = 0U;/*物理区段类型*/
	UINT16 wLgcSecOrgnLink = 0U;/*逻辑区段始端LINK编号*/
	UINT16 wLgcSecTmnLink = 0U; /*逻辑区段终端LINK编号*/
	UINT16 wStopAreaId = 0U;/*停车区域编号*/
	UINT8 chRouteLeaveLogSecSum = 0U;/*进路离去物理区段对应逻辑区段数目*/
	UINT16* wRouteLeaveLogSecId = NULL;/*进路离去物理区段对应逻辑区段Id*/

	if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId))
	{
		/*先添加逻辑区段对应物理区段*/
		chAblLogSecNum = GetTrainAblRelLogSecNum(wTrainId);
		pAblLogSecData = GetTrainAblRelLogData(wTrainId);

		debug_infor_printf((const)"TrainAblRelLogSecNum:num = %d\n", chAblLogSecNum);

		if ((TRAIN_ABL_LOGSEC_SUM >= chAblLogSecNum) && (NULL != pAblLogSecData))
		{
			for (ii = 0U; ii < chAblLogSecNum; ii++)
			{
				debug_infor_printf((const)"GetTrainAblRelLogData:ID = %d\n", pAblLogSecData[ii].wAblRelLogSecId);
				AddXiansuPhySecData(pAblLogSecData[ii].wAblRelLogSecId, wTrainId);
			}
		}
		else
		{
			;	/*不处理*/
		}
		
		/*添加非车脚下进路相关的限速物理区段*/
		chAblRouteNum = GetTrainAblAllRouteNum(wTrainId);
		pAblRouteData = GetTrainAblRelAllRouteData(wTrainId);

		debug_infor_printf((const)"chAblRouteAfterNum:num = %d\n", chAblRouteNum);

		if ((0U < chAblRouteNum) && (TRAIN_ABL_ALLROUTE_SUM >= chAblRouteNum) && (NULL != pAblRouteData))
		{
			for (ii = 0U; ii < chAblRouteNum; ii++)
			{
				debug_infor_printf((const)"GetTrainAblRelAllRouteAfterData:ID = %d\n", pAblRouteData[ii].wAblRelRouteId);
				wRouteLogSecNum = GetRouteLogSectionSum(pAblRouteData[ii].wAblRelRouteId);
				szRouteLogSecIdBuf = GetRouteLogSectionIdBuf(pAblRouteData[ii].wAblRelRouteId);

				if ((MAX_ROUTE_IN_LT_NUM > wRouteLogSecNum) && (NULL != szRouteLogSecIdBuf))
				{
					if (TRAIN_ABL_ROUTE_FLAG_NO == pAblRouteData[ii].chAblRelTrainInFlag)
					{
						for (jj = 0U; jj < wRouteLogSecNum; jj++)
						{
							AddXiansuPhySecData(szRouteLogSecIdBuf[jj], wTrainId);
						}
					}
					else
					{
						; /*不添加*/
					}
					
				}
				else
				{
					; /*不添加*/
				}


				/*若进路最后一个区段为停车区域且进路无保护区段，则站外无岔区段的信息也需要发送*/
				chOverlopSum = GetRouteOverlapSum(pAblRouteData[ii].wAblRelRouteId);
				wRouteLeavePhySecId = GetRouteLeavePhySecId(pAblRouteData[ii].wAblRelRouteId);
				chPhySecType = GetPhySecType(wRouteLeavePhySecId);
				wRouteInLastLogSecId = GetRouteInLastLogSecId(pAblRouteData[ii].wAblRelRouteId);

				wLgcSecOrgnLink = GetLgcSecOrgnLink(wRouteInLastLogSecId);
				wLgcSecTmnLink = GetLgcSecTmnlLink(wRouteInLastLogSecId);

				if ((0U != wLgcSecOrgnLink) && (wLgcSecOrgnLink == wLgcSecTmnLink))
				{
					wStopAreaId = GetLinkStopAreaId(wLgcSecOrgnLink);  /*获取link停车区域ID*/
				}
				else
				{
					; /*进路最后一个区段不是停车区域*/
				}

				if ((0U == chOverlopSum) && (PHYSICAL_SEC_TYPE_NOSWITCH == chPhySecType) && (0U != wStopAreaId))
				{
					chRouteLeaveLogSecSum = GetPhySecIncLogSecSum(wRouteLeavePhySecId);
					wRouteLeaveLogSecId = GetPhySecIncLogSecIdBuf(wRouteLeavePhySecId);

					if ((PHYSICAL_INCLUDE_LOG_SUM_MAX > chRouteLeaveLogSecSum) && (NULL != wRouteLeaveLogSecId))
					{
						for (jj = 0U; jj < chRouteLeaveLogSecSum; jj++)
						{
							/*无保护区段且保护区段外方为无岔区段,且进路最后一个区段为停车区域*/
							AddXiansuPhySecData(wRouteLeaveLogSecId[jj], wTrainId);
						}
					}
					else
					{
						;
					}
				}
				else
				{
					; /*不处理*/
				}
			}
		}
		else
		{
			;	/*不处理*/
		}
	}
	else
	{
		;	/*不处理*/
	}
}

/*
* 功能描述： 添加临时限速物理区段数据
* 参数说明： const UINT16 wPhySecId 逻辑区段ID
*			 const UINT16 wTrainId 列车ID
* 返回值  ： 无
*/
void AddXiansuPhySecData(const UINT16 wLogSecId,const UINT16 wTrainId)
{
	UINT16 wSpeed = 0U;
	UINT16 wLogSecRelPhySecId = 0U;/*逻辑区段关联物理区段ID*/
	UINT8 chPhySecFlockState = 0U;/*物理区段封锁状态*/
	UINT8 chPhySecFlockType = 0U;/*物理区段封锁类型*/
	UINT8 chPhySecAreaUrgentState = 0U;/*物理区段区域紧急制动状态*/
	UINT8 chAddFlag = CI_ERROR;/*添加标志*/
	UINT8 chTsrDataSpeed = 0U;/*临时限速速度取值*/
	UINT8 chAblXiansuPhyNum = 0U;/*临时限速物理区段数目*/
	ABLTrainRelXianSuStru* pTempXiansuPhySecData = NULL;/*临时限速物理区段数目*/
	UINT8 ii = 0U;
	ABLTrainRelXianSuStru strAddXiansuPhySecData = {0U};/*需添加限速物理区段数据*/
	
	if ((0U < wLogSecId) && (LOGIC_SECTION_SUM_MAX > wLogSecId))
	{
		wLogSecRelPhySecId = GetLgcSecRelativePhySecId(wLogSecId);

		if ((0U < wLogSecRelPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wLogSecRelPhySecId))
		{
			chPhySecFlockState = GetPhySecFLockState(wLogSecRelPhySecId);
			chPhySecFlockType = GetPhySecFLockType(wLogSecRelPhySecId);
			chPhySecAreaUrgentState = GetPhySecAreaUrgentState(wLogSecRelPhySecId);

			if (((PHYSICAL_SECTION_FLOCK_YES == chPhySecFlockState) && ((PHY_SEC_FLOCK_TYPE_CMD == chPhySecFlockType) || (PHY_SEC_FLOCK_TYPE_SPKSCMD == chPhySecFlockType)))
				|| (PHYSEC_AREA_URGENT_YES == chPhySecAreaUrgentState))
			{
				chAddFlag = CI_SUCCESS;
				wSpeed = 0U;
			}
			else
			{
				/*其他情况发区段实际限速值*/
				chTsrDataSpeed = GetPhySecMinXiansuSpeed(wLogSecRelPhySecId);

				if ((0U != chTsrDataSpeed) && (UINT8_MAX != chTsrDataSpeed))
				{
					chAddFlag = CI_SUCCESS;
					wSpeed = (UINT16)chTsrDataSpeed;
				}
				else
				{
					; /*无限速或非法不添加*/
				}
			}

			chAblXiansuPhyNum = GetTrainAblRelXianSuNum(wTrainId);
			pTempXiansuPhySecData = GetTrainAblRelXiansuData(wTrainId);

			if ((TRAIN_ABL_XIANSUSEC_SUM > chAblXiansuPhyNum) && (NULL != pTempXiansuPhySecData) && (CI_SUCCESS == chAddFlag))
			{
				for (ii = 0U; ii < chAblXiansuPhyNum; ii++)
				{
					if (wLogSecRelPhySecId == pTempXiansuPhySecData[ii].wAblRelXianSuPhySecId)
					{
						if (0U == wSpeed)
						{
							/*传进来的限速如果是0，说明有人工封锁或区域紧急制动；如果同时存在有效临时限速，要取值为0*/
							strAddXiansuPhySecData.wAblRelXianSuPhySecId = wLogSecRelPhySecId;
							strAddXiansuPhySecData.chAblRelXianSuValue = 0U;
							SetTrainAblRelIndexXiansuData(wTrainId, ii, strAddXiansuPhySecData);
						}
						else if (wSpeed < pTempXiansuPhySecData[ii].chAblRelXianSuValue)
						{
							/*传进来的限速比原有限速要小，修改为最小的限速*/
							strAddXiansuPhySecData.wAblRelXianSuPhySecId = wLogSecRelPhySecId;
							strAddXiansuPhySecData.chAblRelXianSuValue = wSpeed;
							SetTrainAblRelIndexXiansuData(wTrainId, ii, strAddXiansuPhySecData);
						}
						else
						{
							/*其他情况只要原来存储了就不再保存修改*/
							;
						}
						break;
					}
					else
					{
						; /*继续查找*/
					}
				}

				if (chAblXiansuPhyNum == ii)
				{
					/*说明当前无此物理区段的临时限速信息*/
					strAddXiansuPhySecData.wAblRelXianSuPhySecId = wLogSecRelPhySecId;
					strAddXiansuPhySecData.chAblRelXianSuValue = wSpeed;

					/*此时需要添加*/
					SetTrainAblRelXiansuData(wTrainId, strAddXiansuPhySecData);
				}
				else
				{
					; /*已存在；不添加*/
				}
			}
			else
			{
				; /*不添加*/
			}

		}
		else
		{
			; /*不合法不添加*/
		}
	}
	else
	{
		; /*不处理*/
	}
}


/*
* 功能描述： 处理后备列车发送屏蔽门或者ESB数据信息
* 参数说明： UINT16 wTrainId 列车id
* 返回值  ： 无
*/
void VobcBackUpPsdEsbManage(UINT16 wTrainId)
{
	UINT8 ii = 0U;
	UINT16 jj = 0U;
	UINT8 funRetPsd = CI_ERROR;
	UINT8 funRetEsb = CI_ERROR;
	UINT8 chAblPsdNum = 0U;/*ABL列车对应屏蔽门数目*/
	UINT8 chAblEsbNum = 0U;/*ABL列车对应紧急按钮数目*/

	UINT8 chAblLogNum = 0U; /*列车关联逻辑区段数目*/
	UINT16 chRouteLogNum = 0u; /*进路关联逻辑区段数目*/
	ABLTrainRelPsdStru tmpABLTrainPsdData[TRAIN_ABL_PSD_SUM] = { 0U };/*ABL列车PSD临时数组*/
	ABLTrainRelEsbStru tmpABLTrainEsbData[TRAIN_ABL_ESB_SUM] = { 0U };/*ABL列车Esb临时数组*/
	UINT16 tmplogSecData[2*MAX_ROUTE_IN_LT_NUM] = { 0 };/*列车相关逻辑区段临时数组*/
	ABLTrainRelLogStru* pAblLogData = NULL; /*ABL列车关联逻辑区段数据*/
	ABLTrainRelAllRouteStru* pAblRouteData = NULL;/*ABL列车对应进路数据*/
	UINT8 chAblRouteNum = 0U;/*ABL列车对应进路数目*/

	UINT16 logSecId = 0U;/*逻辑区段ID*/
	UINT8 logSecSum = 0U; /*逻辑区段数量*/
	UINT16* pLogSecBuff = NULL;

	pAblLogData = GetTrainAblRelLogData(wTrainId);
	chAblLogNum = GetTrainAblRelLogSecNum(wTrainId);
	/*清零*/

	SetTrainAblRelPsdNum(wTrainId, 0);
	SetTrainAblRelPsdData(wTrainId, tmpABLTrainPsdData);
	SetTrainAblRelEsbNum(wTrainId, 0);
	SetTrainAblRelEsbId(wTrainId, tmpABLTrainEsbData);

	debug_infor_printf((const)"ABLESB_PSDInfo:  Train :%d\n", wTrainId);
	/*添加脚下逻辑区段*/
	if ((NULL != pAblLogData) && (TRAIN_ABL_LOGSEC_SUM >= chAblLogNum))
	{
		for (ii = 0U; ii < chAblLogNum; ii++)
		{
			tmplogSecData[logSecSum] = pAblLogData[ii].wAblRelLogSecId;
			logSecSum++;
		}
	}
	else
	{
		; /*无资源逻辑区段*/
	}
		
	/*添加非车脚下进路相关逻辑区段*/
	chAblRouteNum = GetTrainAblAllRouteNum(wTrainId);
	pAblRouteData = GetTrainAblRelAllRouteData(wTrainId);

	if ((TRAIN_ABL_ALLROUTE_SUM >= chAblRouteNum) && (NULL != pAblRouteData))
	{
		for (ii = 0U; ii < chAblRouteNum; ii++)
		{
			if (TRAIN_ABL_ROUTE_FLAG_NO == pAblRouteData[ii].chAblRelTrainInFlag)
			{
				/*获取进路关联逻辑区段*/
				chRouteLogNum = GetRouteLogSectionSum(pAblRouteData[ii].wAblRelRouteId);
				pLogSecBuff = GetRouteLogSectionIdBuf(pAblRouteData[ii].wAblRelRouteId);
				if ((0U < chRouteLogNum) && (NULL != pLogSecBuff))
				{	/*遍历逻辑区段*/
					for (jj = 0U; jj < chRouteLogNum; jj++)
					{
						logSecId = pLogSecBuff[jj];
						tmplogSecData[logSecSum] = logSecId;
						logSecSum++;
					}
				}
				else
				{
					; /*非法值*/
				}
			}
			else
			{
				; /*脚下区段 已处理*/
			}
		}
	}
	else
	{
		; /*无可用进路*/
	}

	/*遍历逻辑区段 存储对应PSD或SEB数据并去重*/
	if (0U < logSecSum)
	{
		for (ii = 0U; ii < logSecSum; ii++)
		{
			logSecId = tmplogSecData[ii];
			/*存储PSD数目及数据*/
			funRetPsd = AddABLPsdInfo(logSecId, tmpABLTrainPsdData, chAblPsdNum);
			if (0U != funRetPsd)
			{
				chAblPsdNum+= funRetPsd; /*添加成功*/
				debug_infor_printf((const)"\n--(logSec:%d  -PsdNum :%d)\n", logSecId, funRetPsd);
			}
			else
			{
				; /*PSD状态非法或已添加或数组已满*/
			}
			/*ESB添加并去重*/
			funRetEsb = AddABLEsbInfo(logSecId, tmpABLTrainEsbData, chAblEsbNum);
			if (0U != funRetEsb)
			{
				chAblEsbNum+= funRetEsb; /*添加成功*/
				debug_infor_printf((const)"\n--(logSec:%d  -EsbNum :%d)\n", logSecId, funRetEsb);
			}
			else
			{
				; /*ESD状态非法或已添加或数组已满*/
			}
		}
	}
	else
	{
		; /*无资源逻辑区段*/
	}

	/*存储PSD数目及数据*/
	SetTrainAblRelPsdNum(wTrainId, chAblPsdNum);
	SetTrainAblRelPsdData(wTrainId, tmpABLTrainPsdData);

	/*存储ESB数目及数据*/
	SetTrainAblRelEsbNum(wTrainId, chAblEsbNum);
	SetTrainAblRelEsbId(wTrainId, tmpABLTrainEsbData);
}

/*
* 功能描述: 添加逻辑区段PSD数据信息
* 参数说明： const UINT16 , logSecID 逻辑区段ID
*			ABLTrainRelPsdStru* tmpAblPsdData Psd信息数组
*			UINT8 ablPsdNum 已有Psd数量
* 返回值  ：>0添加的个数  0:数据溢出或者错误或者已添加
*/
UINT8 AddABLPsdInfo(const UINT16 logSecID, ABLTrainRelPsdStru* tmpAblPsdData, const UINT8 ablPsdNum)
{
	UINT8 tmpPsdNumSum = 0U;
	UINT8 index = 0U;
	UINT8 keepwork = CI_ERROR;
	UINT8 ii = 0U;
	UINT8 jj = 0U;
	UINT8 chFlag = CI_SUCCESS;
	UINT8 chLogPsdNum = 0U; /*单个逻辑区段Psd数目*/
	UINT8 chPsdMutualLockStat = 0U; /*互锁解除*/
	/*PSD数据*/
	UINT16 PsdId = 0U;
	UINT8 PsdState = 0U;
	UINT8 chCheckResult = 0U;/*检查结果*/

	if ((0U == logSecID) ||(LOGIC_SECTION_SUM_MAX < logSecID)|| (NULL == tmpAblPsdData))
	{
		keepwork = CI_ERROR;
	}
	else
	{
		keepwork = CI_SUCCESS;
	}

	if (CI_SUCCESS == keepwork)
	{
		chLogPsdNum = GetLogSecPsdSum(logSecID);
		/*遍历逻辑区段资源关联PSD*/
		if (LOGSEC_RELATE_PSD_MAX >= chLogPsdNum)
		{
			for (ii = 0U; ii < chLogPsdNum; ii++)
			{
				PsdId = GetLogSecPsdByIdx(logSecID, ii);
				if (0U < PsdId)
				{
					chCheckResult = CheckPsdBelSendRange(PsdId);
					if (CI_ERROR == chCheckResult)
					{
						PsdState = GetPsdState(PsdId);
						/*去重*/
						chFlag = CI_SUCCESS;
						index = ablPsdNum + tmpPsdNumSum;
						for (jj = 0U; jj < index; jj++)
						{
							if (tmpAblPsdData[jj].wAblRelPsdId == PsdId)
							{
								chFlag = CI_ERROR;
								break;
							}
						}

						/*需要添加*/
						if (CI_SUCCESS == chFlag)
						{
							if (TRAIN_ABL_PSD_SUM > index)
							{
								chPsdMutualLockStat = GetPsdMutualLockRemoveState(PsdId);
								if ((PSD_STATE_CLOSE == PsdState) || (PSD_MUTUALLOCK_REMOVE_YES == chPsdMutualLockStat))
								{
									PsdState = CI_IVOC_PSD_STATE_CLOSE;
								}
								else
								{
									PsdState = CI_IVOC_PSD_STATE_OPEN;/*状态非法组包屏蔽门打开*/
								}
								tmpAblPsdData[index].wAblRelPsdId = PsdId;
								tmpAblPsdData[index].chAblRelPsdSta = PsdState;
								debug_infor_printf((const)"--(Psd : -%d )", PsdId);
								tmpPsdNumSum++;
							}
							else
							{
								; /*数组溢出*/
							}
						}
						else
						{
							; /*已添加*/
						}
					}
					else
					{
						; /*超出传输范围不添加*/
					}
					
				}
			}
		}
		else
		{
			; /*数据溢出或不可用*/
		}
	}
	return tmpPsdNumSum;
}

/*
* 功能描述: 添加某个逻辑区段ESB数据信息
* 参数说明： const UINT16 , logSecID 逻辑区段ID
*			ABLTrainRelEsbStru* tmpAblEsbData Esb信息数组
*			UINT8 ablEsbNum 已有Esb数量
* 返回值  ：>0添加的个数  0:数据溢出或者错误
*/
UINT8 AddABLEsbInfo(const UINT16 logSecID, ABLTrainRelEsbStru* tmpAblEsbData, const UINT8 ablEsbNum)
{
	UINT8 tmpEsbNumSum = 0U;
	UINT8 index = 0U;
	UINT8 keepWork = CI_ERROR;
	UINT8 ii = 0U;
	UINT8 jj = 0U;
	UINT8 chFlag = CI_SUCCESS;
	UINT8 chLogEsbNum = 0U; /*单个逻辑区段Esb数目*/
	UINT8 chCheckResult = 0U;/*检查结果*/
	UINT8 chEsbCutState = 0U;

	/*ESB数据*/
	UINT16 EsbId = 0U;
	UINT8 EsbState = 0U;

	if ((0U == logSecID) || (LOGIC_SECTION_SUM_MAX < logSecID) || (NULL ==tmpAblEsbData))
	{
		keepWork = CI_ERROR;
	}
	else
	{
		keepWork = CI_SUCCESS;
	}

	if (CI_SUCCESS == keepWork)
	{
		chLogEsbNum = GetLogSecEsbSum(logSecID);
		/*遍历逻辑区段资源关联ESB*/
		if (LOGSEC_RELATE_ESB_MAX >= chLogEsbNum)
		{
			for (ii = 0U; ii < chLogEsbNum; ii++)
			{
				EsbId = GetLogSecEsbByIdx(logSecID, ii);
				if ((0U < EsbId) && (ESB_SUM_MAX > EsbId))
				{
					chCheckResult = CheckEsbBelSendRange(EsbId);
					if (CI_ERROR == chCheckResult)
					{
						EsbState = GetEsbState(EsbId);
						chEsbCutState = GetEsbCutState(EsbId);
						/*去重*/
						chFlag = CI_SUCCESS;
						index = tmpEsbNumSum + ablEsbNum;
						for (jj = 0U; jj < index; jj++)
						{
							if (tmpAblEsbData[jj].wAblRelEsbId == EsbId)
							{
								chFlag = CI_ERROR;
								break;
							}
						}

						/*需要添加*/
						if (CI_SUCCESS == chFlag)
						{
							if ((TRAIN_ABL_ESB_SUM > index) &&
								((ESB_STATE_VALID_YES == EsbState) || (ESB_STATE_VALID_NO == EsbState))
								&& ((ESB_CUT_YES == chEsbCutState) || (ESB_CUT_NO == chEsbCutState)))
							{
								tmpAblEsbData[index].wAblRelEsbId = EsbId;

								if (ESB_CUT_YES == chEsbCutState)
								{
									EsbState = CI_IVOC_ESB_STATE_INVALID;
								}
								else
								{
									if (ESB_STATE_VALID_NO == EsbState)
									{
										EsbState = CI_IVOC_ESB_STATE_INVALID;
									}
									else
									{
										EsbState = CI_IVOC_ESB_STATE_VALID;
									}
								}
							
								tmpAblEsbData[index].chAblRelEsbSta = EsbState;
								debug_infor_printf((const)"--(Esb : -%d )", EsbId);
								tmpEsbNumSum++;
							}
							else
							{
								; /*数组溢出或状态不可用不添加*/
							}
						}
						else
						{
							; /*已添加*/
						}
					}
					else
					{
						; /*不在传输范围不添加*/
					}
				}
				else
				{
					; /*数据非法*/
				}
			}
		}
		else
		{
			; /*数据溢出或不可用*/
		}
	}
	return tmpEsbNumSum;
}

#if 0
/*
* 功能描述： 处理后备列车发送道岔数据信息
* 参数说明： VobcBackUpToCiDataStruct* VobcBackUpToCiDataStr 列车后备信息结构
* 返回值  ： 无
* Create:  fan  2024.4.12
*/
void VoBcBackUpSwitchManage(VobcBackUpToCiDataStruct* VobcBackUpToCiDataStr)
{
	UINT8 ii = 0U;
	UINT8 jj = 0U;
	UINT16 wlogSecId = 0U; /*逻辑区段Id*/
	UINT16 wLogSecRelPhySecId = 0U; /*逻辑区段关联物理区段*/
	UINT16 wRouteId = 0u;
	UINT16 wTrainId = VobcBackUpToCiDataStr->VobcId;
	UINT16 switchId = 0U;
	UINT8 funRet = 0U; /*添加道岔函数返回值*/
	UINT8 chAddSwitchRet = 0U;/*添加l逻辑区段所在物理区段道岔返回值*/
	UINT8 keepWork = CI_ERROR;
	UINT8 chPhySwitchNum = 0U; /*单个物理区段道岔数目*/
	UINT16* wPhySwitchBuf = NULL; /*物理区段道岔数组*/
	UINT16 wlogNum = 0U; /*关联逻辑区段数目*/
	UINT16* wLogSecBuf = NULL; /*逻辑区段数组*/

	UINT16 wOverlapId = 0U; /*进路锁闭保护区段*/

	UINT8 chAblSwitchNum = 0U;/*ABL列车道岔总数目*/
	UINT8 chAblLogNum = 0U; /*列车关联逻辑区段数目*/
	UINT8 chAblRouteNum = 0U;/*ABL列车对应进路数目*/
	UINT16 wSwitchSum = 0U; /*本连锁和相邻联锁道岔数目*/
	ABLTrainRelAllRouteStru* pAblRouteData = NULL;/*ABL列车对应进路数据*/
	ABLTrainRelSwitchStru tmpABLTrainSwitchData[TRAIN_ABL_SWITCH_SUM] = { 0U };/*ABL列车道岔临时数组*/
	ABLTrainRelLogStru* pAblLogData = NULL; /*ABL列车关联逻辑区段数据*/


	pAblLogData = GetTrainAblRelLogData(wTrainId);
	chAblLogNum = GetTrainAblRelLogSecNum(wTrainId);
	debug_infor_printf((const)"ABLSwitchInfo:  Train :%d", wTrainId);
	if ((TRAIN_ABL_LOGSEC_SUM >= chAblLogNum) && (NULL != pAblLogData))
	{
		keepWork = CI_SUCCESS;
		for (ii = 0U; ii < chAblLogNum; ii++)
		{
			wlogSecId = pAblLogData[ii].wAblRelLogSecId;
			wLogSecRelPhySecId = GetLgcSecRelativePhySecId(wlogSecId);
			/*获取逻辑区段关联物理区段*/
			if ((0U < wLogSecRelPhySecId) && ( PHYSICAL_SECTION_SUM_MAX>wLogSecRelPhySecId))
			{
				/*添加物理区段关联道岔*/
				chPhySwitchNum = GetPhyIncludeSwitchSum(wLogSecRelPhySecId);
				wPhySwitchBuf = GetPhySecIncludeSwitch(wLogSecRelPhySecId);
				if ((NULL != wPhySwitchBuf) &&(0U < chPhySwitchNum))
				{
					for (jj = 0U; jj < chPhySwitchNum; jj++)
					{
						switchId = wPhySwitchBuf[jj];
						funRet = AddABLSwitchInfo(switchId, tmpABLTrainSwitchData, chAblSwitchNum);
						if (CI_SUCCESS == funRet)
						{
							chAblSwitchNum++; /*添加成功*/
							debug_infor_printf((const)"-( %d, PhySec: %d)", switchId, wLogSecRelPhySecId);
						}
						else
						{
							; /*数据非法或已添加*/
						}
					}
				}
			}
			else
			{
				/*数据非法*/
				keepWork = CI_ERROR;
			}
		}
	}
	else
	{
		/*资源逻辑区段数据非法*/
		keepWork = CI_ERROR;
	}

	/*添加保护区段道岔&非车脚下进路相关的道岔*/
	chAblRouteNum = GetTrainAblAllRouteNum(wTrainId);
	pAblRouteData = GetTrainAblRelAllRouteData(wTrainId);

	if ((TRAIN_ABL_ALLROUTE_SUM >= chAblRouteNum) && (NULL != pAblRouteData))
	{
		for (ii = 0U; ii < chAblRouteNum; ii++)
		{
			if (TRAIN_ABL_ROUTE_FLAG_NO == pAblRouteData[ii].chAblRelTrainInFlag)
			{
				/*获取非车脚下进路关联的逻辑区段数据*/
				wlogNum = GetRouteLogSectionSum(pAblRouteData[ii].wAblRelRouteId);
				wLogSecBuf = GetRouteLogSectionIdBuf(pAblRouteData[ii].wAblRelRouteId);

				if ((NULL != wLogSecBuf) && (0U < wlogNum)&&(MAX_ROUTE_IN_LT_NUM>=wlogNum))
				{
					chAddSwitchRet = AddLogBelongPhySecABLSwitchInfo(wlogNum, wLogSecBuf, tmpABLTrainSwitchData, chAblSwitchNum);
					chAblSwitchNum += chAddSwitchRet; /*添加总量*/
				}
			}
			else
			{
				; /*脚下逻辑区段道岔已处理*/
			}

			/*获取保护区段的的道岔数据*/
			wOverlapId = GetRouteOverlapLockedId(pAblRouteData[ii].wAblRelRouteId);
			if (0U < wOverlapId)
			{
				wlogNum = (UINT16)GetOverlapLogicSectionSum(wOverlapId);
				wLogSecBuf = GetOverlapLogicSectionBuf(wOverlapId);
				if ((NULL != wLogSecBuf) && (0U < wlogNum) && (OVLP_LOGICSECTION_SUM_MAX >= wlogNum))
				{
					chAddSwitchRet = AddLogBelongPhySecABLSwitchInfo(wlogNum, wLogSecBuf, tmpABLTrainSwitchData, chAblSwitchNum);
					chAblSwitchNum += chAddSwitchRet; /*添加总量*/
				}
			}
			else
			{
				; /*无保护区段不处理*/
			}
		}
	}
	else
	{
		/*列车关联进路数据非法*/
		keepWork = CI_ERROR;
	}
	/*判断车头所在物理区段有无锁闭*/
	wLogSecRelPhySecId = GetLinkRelatedPhySec(VobcBackUpToCiDataStr->wTrainMaxSafeHeadLink);
	wRouteId = GetPhySecRLockBelongRouteId(wLogSecRelPhySecId);
	if ((PHYSICAL_SECTION_SUM_MAX < wLogSecRelPhySecId) || (0U == wLogSecRelPhySecId))
	{
		keepWork = CI_ERROR;
	}
	else if (0u == wRouteId)
	{
		/*车头无锁闭进路，添加本控区和相邻控区所有道岔*/
		debug_infor_printf((const)"-( Train Head PhySec Not Lock)");
		wSwitchSum = GetTotalSwitchCurNum();
		if (SWITCH_SUM_MAX >= wSwitchSum)
		{
			for (ii = 0U; ii < wSwitchSum; ii++)
			{
				switchId = GetSwitchId(ii);

				funRet = AddABLSwitchInfo(switchId, tmpABLTrainSwitchData, chAblSwitchNum);
				if (CI_SUCCESS == funRet)
				{
					chAblSwitchNum++; /*添加成功*/
				}
			}
		}
	}
	else
	{
		; /*不处理*/
	}
	debug_infor_printf((const)"\n");
	if (CI_SUCCESS == keepWork)
	{
		/*存储数据*/
		SetTrainAblRelSwitchNum(wTrainId, chAblSwitchNum);
		SetTrainAblRelSwitchData(wTrainId, tmpABLTrainSwitchData);
	}
}


/*
* 功能描述：添加ABL道岔
* 参数说明： const UINT16 switchID, 道岔ID
*			ABLTrainRelSwitchStru* tmpAblSwitchData 道岔信息数组
*			UINT8 tmpSwitchNum 已添加道岔数量
* 返回值  ：CI_SUCCESS 新添加 CI_ERROR未改变
* Create:  fan  2024.4.12
*/
UINT8 AddABLSwitchInfo(const UINT16 switchID, ABLTrainRelSwitchStru* tmpAblSwitchData, UINT16 tmpSwitchNum)
{
	UINT8 retVal = CI_ERROR;
	UINT8 ii = 0U;
	UINT8 switchState = 0U;
	UINT8 chAblSwitchState = 0U;
	UINT16 wTotalSwitchSum = 0U; /*本连锁和相邻联锁道岔数目*/
	UINT16 switchCheckId = 0U;


	if ((NULL == tmpAblSwitchData)||(0U == switchID))
	{
		retVal = CI_ERROR; /*入参检查失败*/
	}
	else
	{
		retVal = CI_SUCCESS;
		/*检查道岔是否已经被添加*/
		for (ii = 0U; ii < tmpSwitchNum; ii++)
		{
			if (switchID == tmpAblSwitchData[ii].wAblRelSwitchId)
			{
				retVal = CI_ERROR;
				break;
			}
		}
	}
	if (CI_SUCCESS == retVal)
	{
		retVal = CI_ERROR;
		/*道岔在本控区和相邻控区复视内*/
		wTotalSwitchSum = GetTotalSwitchCurNum();
		if (SWITCH_SUM_MAX >= wTotalSwitchSum)
		{
			for (ii = 0U; ii < wTotalSwitchSum; ii++)
			{
				switchCheckId = GetSwitchId(ii);
				if (switchCheckId == switchID)
				{
					retVal = CI_SUCCESS;/*找到*/
					break;
				}
				else
				{
					; /*继续*/
				}
			}
		}
	}

	/*未添加，检查道岔状态*/
	if (CI_SUCCESS == retVal)
	{
		switchState = GetSwitchCurPosition(switchID);
		switch (switchState)
		{
		case SWITCH_POSITION_DINGWEI:
			chAblSwitchState = CI_IVOC_SWITCH_POSTION_DING;
			break;
		case SWITCH_POSITION_FANWEI:
			chAblSwitchState = CI_IVOC_SWITCH_POSTION_FAN;
			break;
		case SWITCH_POSITION_JICHA:
		case SWITCH_POSITION_MOVE:
		case SWITCH_POSITION_SIKAI:
		case SWITCH_POSITION_INVALID:
			chAblSwitchState = CI_IVOC_SWITCH_POSTION_SHIBIAO;
			break;
		default:
			/*道岔状态错误*/
			retVal = CI_ERROR;
			break;
		}
	}

	if (CI_SUCCESS == retVal)
	{
		if (TRAIN_ABL_SWITCH_SUM > tmpSwitchNum)
		{
			tmpAblSwitchData[tmpSwitchNum].wAblRelSwitchId = switchID;
			tmpAblSwitchData[tmpSwitchNum].chAblRelSwitchSta = chAblSwitchState;
		}
		else
		{
			/*数据溢出*/
			retVal = CI_ERROR;
		}
	}
	return retVal;
}

/*
* 功能描述：添加逻辑区段所在物理区段全部道岔道岔
* 参数说明：
* 输入参数: UINT8 logSecNum 逻辑区段数量 UINT16* logSecBuf  
* 输出参数: ABLTrainRelSwitchStru* tmpAblSwitchData 道岔信息数组 UINT8* chAblSwitchNum 道岔数量
* 返回值  ：>0添加道岔的个数  0:数据溢出或者已添加
* Create:  fan  2024.5.21
*/
UINT8 AddLogBelongPhySecABLSwitchInfo(UINT16 logSecNum, UINT16* logSecBuf, ABLTrainRelSwitchStru* tmpAblSwitchData, UINT8 chAblSwitchNum)
{
	UINT8 chAddNum= 0U;
	UINT16  ii= 0U;
	UINT8 jj = 0U;
	UINT16 wLogSecRelPhySecId = 0U;
	UINT8 chPhySwitchNum = 0U; /*物理区段道岔数目*/
	UINT16* wPhySwitchBuf = NULL; /*区段道岔数据*/
	UINT16 switchId = 0U;
	UINT8 funRet = CI_ERROR;
	if ((NULL != logSecBuf) && (NULL != tmpAblSwitchData))
	{
		for (ii = 0U; ii < logSecNum; ii++)
		{
			wLogSecRelPhySecId = GetLgcSecRelativePhySecId(logSecBuf[ii]);
			/*获取逻辑区段关联物理区段*/
			if ((0U < wLogSecRelPhySecId) && (PHYSICAL_SECTION_SUM_MAX>wLogSecRelPhySecId))
			{
				/*添加物理区段关联道岔*/
				chPhySwitchNum = GetPhyIncludeSwitchSum(wLogSecRelPhySecId);
				wPhySwitchBuf = GetPhySecIncludeSwitch(wLogSecRelPhySecId);
				if ((NULL != wPhySwitchBuf) && (0U < chPhySwitchNum))
				{
					for (jj = 0U; jj < chPhySwitchNum; jj++)
					{
						switchId = wPhySwitchBuf[jj];
						funRet = AddABLSwitchInfo(switchId, tmpAblSwitchData, chAblSwitchNum+ chAddNum);
						if (CI_SUCCESS == funRet)
						{
							chAddNum++; /*添加成功*/
							debug_infor_printf((const)"-( %d, PhySec: %d)", switchId, wLogSecRelPhySecId);
						}
						else
						{
							; /*数据非法或已添加*/
						}
					}
				}
			}
			else
			{
				; /*不处理*/
			}
		}
	}

	return chAddNum;
}
#endif

/*
* 功能描述： 列车车身所处位置反向进路检查
* 参数说明： const UINT16 wTrainId 列车ID
* 返回值  ： 无
* by cgh 20240711
*/
void VobcLocReverseRouteCheck(const UINT16 wTrainId)
{
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	struct_PathPoint start = { 0U };  /*列车逻辑起点*/
	struct_PathPoint end = { 0U };    /*列车逻辑终点*/
	UINT16 wTrainOccLogSum = 0U;      /*列车脚下逻辑区段数量*/
	UINT16 wTrainOccLogID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U };   /*列车占压的逻辑区段ID*/
	UINT16 wVobcBackUpRouteID = 0U;/*锁闭所属进路*/
	UINT8 chRouteReverseFlag = 0U;/*反向进路标志*/

	if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId))
	{
		/*首先每周期先设置为默认*/
		SetTrainLocReverseRouteFlag(wTrainId, TRAIN_LOC_REV_ROUTE_FLAG_NONE);
		/*车尾所在位置*/
		start.wLinkId = GetAblTrainMinTailLink(wTrainId);
		start.dwOffset = GetAblTrainMinTailOffset(wTrainId);

		/*车头所在位置*/
		end.wLinkId = GetAblTrainMaxHeadLink(wTrainId);
		end.dwOffset = GetAblTrainMaxHeadOffset(wTrainId);
		chRetVal = GetLogSecBtwTwoPoints(start, end, &wTrainOccLogSum, wTrainOccLogID);

		if (CI_SUCCESS == chRetVal)
		{
			for (ii = 0U; ii < wTrainOccLogSum; ii++)
			{
				wVobcBackUpRouteID = GetLogSecLockBelongRoute(wTrainOccLogID[ii]);

				if ((0U < wVobcBackUpRouteID) && (ROUTE_SUM_MAX > wVobcBackUpRouteID))
				{
					/*有进路存在，这里设置无反向，下面查找到设置标识为反向*/
					SetTrainLocReverseRouteFlag(wTrainId, TRAIN_LOC_REV_ROUTE_FLAG_NO);
					chRouteReverseFlag = GetRouteReverseProperty(wVobcBackUpRouteID);

					if (ROUTE_REVERSE_PROPERTY_YES == chRouteReverseFlag)
					{
						SetTrainLocReverseRouteFlag(wTrainId, TRAIN_LOC_REV_ROUTE_FLAG_YES);
						break;
					}
					else
					{
						; /*继续查找*/
					}
				}
				else
				{
					; /*继续查找*/
				}
			}
		}
		else
		{
			;
		}
	}
	else
	{
		;
	}
}


/*
* 功能描述： 后备列车发送脚下进路逻辑区段空闲信息计算
* 参数说明： const UINT16 wTrainId 列车ID
* 返回值  ： 无
* by LC 
*/
void VobcBackUpRouteNoOccuManage(const UINT16 wTrainId)
{
	UINT16 ablMaxheadLogSecId = 0U;
	UINT16 logBelongRouteId = 0U;
	UINT8 checkFlag = CI_ERROR;
	UINT16 wOverlapId = 0U;
	UINT16 farLogSecId = 0U;
	UINT16 lastOverlapLogId = 0U;
	UINT16 leaveLogicSecId = 0U;
	UINT8 overlapSum = 0U;
	UINT8 cEnvelopeNum = 0U;  /*列车关联的包络数量*/
	UINT16 szEnvelopeId[TRAIN_REL_ENVELOPE_SUM_MAX] = { 0U };  /*列车关联的包络ID*/
	struct_PathPoint strEnd = { 0U };
	UINT16 wEndLgcId = 0U;
	UINT16 wFrontEid = 0U;
	UINT16 wBackEid = 0U;
	UINT8 chFlag = 0U;
	const EnvelopeStruct* pstrEnvelop = NULL;  /*列车关联的包络结构体*/
	const EnvelopeStruct* pFrontEnvelop = NULL;  /*列车关联的包络结构体*/

	if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId))
	{
		/*检查车头占压的区段前方是否存在其他车*/
		cEnvelopeNum = elm_GetTrainRelELM(wTrainId, szEnvelopeId);
		if (1U == cEnvelopeNum)
		{
			pstrEnvelop = elm_GetEnvelopeInfoByID(szEnvelopeId[0U]);
			if (NULL != pstrEnvelop)
			{
				if (0U == pstrEnvelop[0U].headTrainID)
				{
					checkFlag = rrm_PrepareForwardTrain(pstrEnvelop);
				}
				else
				{
					/*前端可疑，检查失败*/
					debug_infor_printf((const)"VobcBackUpRouteNoOccuManage: HeadTrain Keyi");
				}
			}
		}
		else if (0U == cEnvelopeNum)
		{
			/*未查询到包络，返回默认值FFFF*/
			farLogSecId = UINT16_MAX;
		}
		else
		{
			/*返回0U*/
		}
		
		/*检查车头所在进路到信号机终端是否存在其他占压*/
		if (CI_SUCCESS == checkFlag)
		{
			checkFlag = VobcBackUpRouteNoOccuCheck(wTrainId);
		}
		else
		{
			/*返回失败*/
			debug_infor_printf((const)"VobcBackUpRouteNoOccuManage:  Have Another HeadTrain ");
		}

		/*进路内无占用*/
		if (CI_SUCCESS == checkFlag)
		{
			/*获取车头所在进路*/
			ablMaxheadLogSecId = GetTrainAblMaxHeadLogId(wTrainId);
			logBelongRouteId = GetLogSecLockBelongRoute(ablMaxheadLogSecId);
			if ((0U < logBelongRouteId) && (ROUTE_SUM_MAX > logBelongRouteId))
			{
				wOverlapId = GetRouteOverlapLockedId(logBelongRouteId);
				overlapSum = GetRouteOverlapSum(logBelongRouteId);

				/*进路存在保护区段锁闭，检查保护区段占用*/
				if (0U < wOverlapId)
				{
					checkFlag = VobcBackUpOverlapNoOccuCheck(wOverlapId, &lastOverlapLogId);
					if (CI_SUCCESS == checkFlag)
					{
						farLogSecId = lastOverlapLogId;
					}
					else
					{
						debug_infor_printf((const)"VobcBackUpRouteNoOccuManage:  Overlop Have Occu ");
					}
				}
				/*进路未配置保护区段*/
				else if(0U== overlapSum)
				{
					/*进路是否配置站外直轨计轴检查*/
					checkFlag = FindRouteLeaveAxis(logBelongRouteId);
					/*已配置*/
					if (CI_SUCCESS == checkFlag)
					{
						leaveLogicSecId = GetRouteLeaveLogicSecId(logBelongRouteId);
						checkFlag = TrainLeaveLogSecABLTrainCheck(leaveLogicSecId);
						if (CI_SUCCESS == checkFlag)
						{
							/*第一离去逻辑区段占用检查通过，检查通过*/
							farLogSecId = leaveLogicSecId;
						}
						else
						{
							/*离去区段存在占用，返回失败*/
							debug_infor_printf((const)"VobcBackUpRouteNoOccuManage:  Leave LogSec Have Occu ");
						}
					}
					/*未配置*/
					else
					{
						/*返回进路最后一个逻辑区段*/
						farLogSecId = GetRouteInLastLogSecId(logBelongRouteId);
					}
				
				}
				else
				{
					/*保护区段未锁闭，返回0U*/
					debug_infor_printf((const)"VobcBackUpRouteNoOccuManage:  OverLop Not Lock ");
				}
				
			}
			else
			{
				/*查询失败*/
			}
		}
		else
		{
			/*进路内有占用，返回失败*/
			debug_infor_printf((const)"VobcBackUpRouteNoOccuManage:  Route Logsec Occu ");
		}
	}

	/* 补丁：针对ABL且为UCT包络场景添加防护跨控区防护 */
	if ((0U != farLogSecId) && (UINT16_MAX != farLogSecId))
	{
		strEnd.wLinkId = pstrEnvelop->endPos.Lnk;
		strEnd.dwOffset = pstrEnvelop->endPos.Off;
		wEndLgcId = GetPointBelongLogSec(strEnd);
		if (wEndLgcId != farLogSecId)
		{/* 包络终端逻辑区段并不是查询最后逻辑区段 */
			checkFlag = elm_GetNearestEnvelopeApi(pstrEnvelop->id, &wFrontEid, &wBackEid);
			if (CI_SUCCESS != checkFlag)
			{/* 查询前方包络失败，认为前方占用 */
				farLogSecId = 0U;
			}
			else
			{
				pFrontEnvelop = elm_GetEnvelopeInfoByID(wFrontEid);
				chFlag = elm_PrepareEnvelopeIsSelfApi(pFrontEnvelop);
				if ((NULL == pFrontEnvelop) 
					|| (pFrontEnvelop->trainID[0] == pstrEnvelop->trainID[0])
					|| (ELM_BELONG_OWNER == chFlag))
				{
					; /* 不处理 */
				}
				else
				{/* 前方包络不是本车包络，认为前方占用 */
					farLogSecId = 0U;
				}
			}
		}
		else
		{
			; /* 不处理 */
		}
	}

	/*设置最远端逻辑区段*/
	SetTrainAblNoOccuFarLogId(wTrainId, farLogSecId);

}


/*
* 功能描述： 检查后备列车所在进路内是否空闲
* 参数说明： const UINT16 wTrainId 列车ID
* 返回值  ： CI_SUCCESS 无占用
*           CI_ERROR 存在占用
* by LC
*/
UINT8 VobcBackUpRouteNoOccuCheck(const UINT16 wTrainId)
{
	UINT16* trainOccuLogSecId = NULL;
	UINT8 trainOccuLogSecSum = 0U;
	UINT8 chAblLogSecNum = 0U;/*ABL列车对应逻辑区段数目*/
	ABLTrainRelLogStru* pAblLogSecData = NULL;/*ABL列车对应逻辑区段数据*/
	UINT8 i = 0U;
	UINT8 j = 0U;
	UINT8 k = 0U;
	UINT8 retVal = CI_ERROR;
	UINT8 tmpOccuState = 0U;
	UINT16 maxHeadLogSecId = 0U;
	UINT16 maxHeadPhySecId = 0U;
	UINT8 cPhySecIncLogSecSum = 0U;  /*物理区段包含的逻辑区段数量*/
	UINT16* pPhySecIncLogSecId = NULL;  /*物理区段包含的逻辑区段ID*/

	if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId))
	{
		/*获取进路脚下逻辑区段*/
		trainOccuLogSecId = GetTrainAblOcculogIdBuff(wTrainId);
		trainOccuLogSecSum = GetTrainAblOcculogIdSum(wTrainId);

		/*获取进路脚下直到进路终端逻辑区段*/
		chAblLogSecNum = GetTrainAblRelLogSecNum(wTrainId);
		pAblLogSecData = GetTrainAblRelLogData(wTrainId);
		retVal = CI_SUCCESS;

		maxHeadLogSecId= GetTrainAblMaxHeadLogId(wTrainId);
		maxHeadPhySecId = GetLgcSecRelativePhySecId(maxHeadLogSecId);

		/*获取车头物理区段关联逻辑区段信息*/
		cPhySecIncLogSecSum = GetPhySecIncLogSecSum(maxHeadPhySecId);
		pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(maxHeadPhySecId);

		if ((NULL != trainOccuLogSecId) && (NULL != pAblLogSecData) && (0U != trainOccuLogSecSum) && (0U != chAblLogSecNum) && (0U != cPhySecIncLogSecSum) && (NULL != pPhySecIncLogSecId))
		{
			/*遍历车脚下到进路终端所有逻辑区段*/
			for (i = 0U; i < chAblLogSecNum; i++)
			{
				for (j = 0U; j < trainOccuLogSecSum; j++)
				{
					if (pAblLogSecData[i].wAblRelLogSecId == trainOccuLogSecId[j])
					{
						/*属于列车脚下区段，不检查占用*/
						break;
					}
					else
					{
						;
					}
				}
				for ( k = 0U; k < cPhySecIncLogSecSum; k++)
				{
					if (pAblLogSecData[i].wAblRelLogSecId == pPhySecIncLogSecId[k])
					{
						/*属于列车车头所在物理区段，不检查占用*/
						break;
					}
					else
					{
						;
					}
				}



				/*该逻辑区段不是列车脚下区段，并且不属于车头所在的物理区段*/
				if ((j == trainOccuLogSecSum) && (k == cPhySecIncLogSecSum))
				{
					tmpOccuState = GetLogSecCurCtOrUtOccupyState(pAblLogSecData[i].wAblRelLogSecId);

					if (LOGICSECTION_OCCUPY_NO != tmpOccuState)
					{
						/*逻辑区段存在占用，返回失败*/
						retVal = CI_ERROR;
					}
					else
					{
						/*继续检查*/
					}

				}
				if (CI_ERROR == retVal)
				{
					/*跳出检查*/
					break;
				}
				else
				{
					/*继续检查*/
				}
			}
		}
		else
		{
			/*返回失败*/
		}
	}
	else
	{
		/*返回失败*/
	}
	return retVal;
}


/*
* 功能描述： 检查后备列车所在进路保护区段是否空闲
* 参数说明： const UINT16 wTrainId 列车ID
*          const UINT16 overLogSecId  保护区段内最后一个逻辑区段ID（出参）
* 返回值  ： CI_SUCCESS 空闲
*           CI_ERROR 存在占用
* by LC
*/
UINT8 VobcBackUpOverlapNoOccuCheck(const UINT16 wOverlapId, UINT16* overLogSecId)
{
	UINT8 overlapLogNum = 0U;  /*保护区段包含的逻辑区段数量*/
	UINT16* OverlapLogIdBuff = NULL;  /*保护区段包含的逻辑区段ID*/
	UINT8 occuState = 0U;
	UINT8 i = 0U;
	UINT8 retVal = CI_ERROR;
	UINT16 farAxisSecId = 0U;  /*保护区段最远端计轴*/
	UINT16 axisLogicSecSum = 0u;							/*逻辑区段数目*/
	UINT16* axisLogicSecIdBuf = NULL;					/*逻辑区段Id数组*/
	UINT8 overlapLockDir = 0U;
	UINT8 overlogicLockDir = 0U;

	if ((NULL != overLogSecId) && (0U != wOverlapId))
	{
		overlapLogNum = GetOverlapLogicSectionSum(wOverlapId);
		OverlapLogIdBuff = GetOverlapLogicSectionBuf(wOverlapId);
		

		if (NULL != OverlapLogIdBuff)
		{
			retVal = CI_SUCCESS;
			for (i = 0U; i < overlapLogNum; i++)
			{
				occuState = GetLogSecCurCtOrUtOccupyState(OverlapLogIdBuff[i]);
				if (LOGICSECTION_OCCUPY_NO != occuState)
				{
					/*逻辑区段存在占用，返回失败*/
					retVal = CI_ERROR;
					break;
				}
				else
				{
					/*继续遍历*/
				}
			}

			if (CI_SUCCESS == retVal)
			{
				/*保护区段无占用，返回最后一个逻辑区段ID*/
				farAxisSecId = GetOverlapFarLogicSecID(wOverlapId);  /*保护区段最远端计轴*/
				if (0U != farAxisSecId)
				{
					axisLogicSecSum = GetAxisSecLogSectionSum(farAxisSecId);	/*获取计轴区段包含的逻辑区段数目*/
					axisLogicSecIdBuf = GetAxisSecLogSectionIdBuf(farAxisSecId);		/*获取计轴区段包含的逻辑区段数组*/
					if (NULL != axisLogicSecIdBuf)
					{
						overlapLockDir = GetLogSecLockDir(axisLogicSecIdBuf[0]);
						overlogicLockDir = ConvertDirectionToLogic(overlapLockDir);
						/*锁闭方向与逻辑方向相同*/
						if (DIR_SAME == overlogicLockDir)
						{
							*overLogSecId = axisLogicSecIdBuf[axisLogicSecSum - 1];
						}
						else if (DIR_CONVERT == overlogicLockDir)
						{
							*overLogSecId = axisLogicSecIdBuf[0];
						}
						else
						{
							/*查询失败*/
							*overLogSecId = 0U;
							retVal = CI_ERROR;
						}

					}
					else
					{
						retVal = CI_ERROR;
					}
				}
				else
				{
					retVal = CI_ERROR;
				}
			}
			else
			{
				/*查询失败*/
			}
		}
		else
		{
			/*查询失败*/
		}
	}
	else
	{
		/*查询失败*/
	}

	return retVal;
}


/*
* 功能描述： 检查其他联锁条件中是否配置站外直轨计轴条件
* 参数说明： const UINT16 routeId 进路ID
* 返回值  ： CI_SUCCESS 已配置
*           CI_ERROR 未配置
* by LC
*/
UINT8 FindRouteLeaveAxis(const UINT16 routeId)
{
	UINT16 leaveLogicSecId = 0U;
	UINT8 logBelogAxisNum = 0u;
	UINT16* logBelogAxisBuff = NULL;
	UINT16 phySecId = 0U;
	UINT8 phySwitchSum = 0U;
	UINT8 checkOtherSum = 0U;
	RouteOtherCheckStruct* dataOtherCiDevBuf = NULL;
	UINT8 i = 0U;
	UINT8 retVal = CI_ERROR;

	if ((0U < routeId) && (ROUTE_SUM_MAX > routeId) )
	{
		
		/*获取进路外方第一离去逻辑区段*/
		leaveLogicSecId = GetRouteLeaveLogicSecId(routeId);

		/*逻辑区段关联的计轴区段*/
		logBelogAxisNum = GetLgcSecRelativeAxleSecSum(leaveLogicSecId);
		logBelogAxisBuff = GetLgcSecRltvAxleSecIdBuf(leaveLogicSecId);

		/*离去逻辑区段关联的物理区段*/
		phySecId = GetLgcSecRelativePhySecId(leaveLogicSecId);
		phySwitchSum = GetPhyIncludeSwitchSum(phySecId);	/*物理区段包含的道岔数量*/

		/*且站外离去区段为无岔区段*/
		if ((0U == phySwitchSum) && (1U == logBelogAxisNum))
		{

			/*获取点式其他联锁检查条件*/
			checkOtherSum = GetRouteBlocOtherCiSum(routeId);
			dataOtherCiDevBuf = GetRouteBlocOtherCiBuf(routeId);


			if (NULL != dataOtherCiDevBuf)
			{
				for (i = 0U; i < checkOtherSum; i++)
				{
					/*点式其他联锁条件中已配置站外直轨计轴*/
					if ((CI_DEVICE_TYPE_AXISSEC == dataOtherCiDevBuf[i].DevType) && (dataOtherCiDevBuf[i].DevId == logBelogAxisBuff[0]))
					{
						retVal = CI_SUCCESS;
						break;
					}

				}
			}
			else
			{
				/*查询失败*/
			}

		}
		else
		{
			/*离去区段存在道岔，查询失败*/
		}
	}
	else
	{
		/*查询失败*/
	}
	return retVal;
}

/*
* 功能描述： 无人折返继电器粘连状态处理
* 参数说明： void
* 返回值  ：无
* by cgh 20240904
*/
void RtnRealyAdhesionStatePro(void)
{
	UINT16 wNonAutoReturnCurSum = 0U;/*当前集中区无人折返数量*/
	UINT16 wNonAutoReturnId = 0U;/*无人折返ID*/
	UINT16 ii = 0U;
	UINT16 wNonRtnAdhesionRealyId = 0U;/*无人折返按钮继电器*/
	UINT8 chRelayCollState = 0U;/*继电器采集状态*/
	UINT32 dwCycNum = 0U;
	UINT32 dwNonRtnRelayUpCycNum = 0U;/*无人折返按钮吸起起始周期号*/
	UINT32 dwRelayAdhesionCount = 0U;/*继电器判断粘连周期*/
	UINT8 chRelayVirtAttr = 0U;/*继电器虚拟属性*/
	UINT8 chTimeCheckFlag = 0U;/*超时检查标志*/

	wNonAutoReturnCurSum = GetNonAutoReturnCurSum();

	for (ii = 0U; ii < wNonAutoReturnCurSum; ii++)
	{
		wNonAutoReturnId = GetNonReturnId(ii);
		wNonRtnAdhesionRealyId = GetNonRtnAdhesionRealyId(wNonAutoReturnId);
		chRelayVirtAttr = GetRelayVirtAttr(wNonRtnAdhesionRealyId);

		if ((0U != wNonRtnAdhesionRealyId) && (RELAY_VIRTUAL_ATTR_NO == chRelayVirtAttr))
		{
			/*不等于0说明是有效的实体无人折返*/
			chRelayCollState = GetRelayCollState(wNonRtnAdhesionRealyId);

			if (RELAY_STATE_UP == chRelayCollState)
			{
				dwCycNum = Get2oo2CurCycleNum();
				dwNonRtnRelayUpCycNum = GetNonRtnRelayUpCycNum(wNonAutoReturnId);
				dwRelayAdhesionCount = GetdwNonReturnBtnErrEnsureCount();

				if (0U == dwNonRtnRelayUpCycNum)
				{
					SetNonRtnRelayUpCycNum(wNonAutoReturnId, dwCycNum);
				}
				else
				{

					chTimeCheckFlag = SystemOverTimeCheck(dwNonRtnRelayUpCycNum, dwRelayAdhesionCount);

					if (CI_TIME_OUT == chTimeCheckFlag)
					{
						SetNonRtnAdhesionState(wNonAutoReturnId, RTN_RELAY_ADHESION_YES);
					}
					else
					{
						; /*不报警*/
					}
				}
			}
			else
			{
				/*继电器落下清除周期和粘连标志*/
				SetNonRtnRelayUpCycNum(wNonAutoReturnId,0U);
				SetNonRtnAdhesionState(wNonAutoReturnId, RTN_RELAY_ADHESION_NO);
			}
		}
		else
		{
			;
		}
	}
}

