/************************************************************************
*
* 文件名   ：  quCIInit.c
* 版权说明 ：  北京交控科技有限公司 
* 版本号   ：  1.0
* 创建时间 ：  2011.12.27
* 作者     ：  研发中心软件部
* 功能描述 ：  系统配置数据初始化过程 
* 使用注意 ： 
* 修改记录 ：  
*
************************************************************************/

#include "dquCIInit.h"
#include "CommonMemory.h"
#include "commonQueryStruDef.h"
#include "../System/SystemParameterManage.h"

#define DJ 0
#define DJ2 1
#define LXJ 2
#define ZXJ 3
#define YXJ 4
#define DDJ 5
#define DXJ 6

dquCIConfigDataStr dquCICfgDtStr = {0U};
UINT8 SpksConfigDataStructInit(CHAR * FSName);
UINT8 MJConfigDataStructInit(CHAR* FSName);
UINT8 ReadSpksConfigDataFromDquData(SpksDataConfigStruct* pSpksDataConfig);
UINT8 ReadMJConfigDataFromDquData(MJDataConfigStruct * pMJDataConfig);
UINT8 CheckInputOtherCiDevInfoValid(const LS_OtherCiDevInfoStruct *pOtherCiDevInfo); 
UINT8 GetBelongCiByRelayId(UINT16 relayId );
UINT8 CiTransmitInfoStructInit(CHAR* FSName);
UINT8 ReadDquCiTransmitInfoToConfig(DquCiTransmitStruct *pDquCiTransmitStr);


/*
功能描述: 将单个其他线路设备数据填充至DquCfg中其他线路设备数据内容中
输入参数:	DquDiffLineDevStruct *pDquDiffLineDevData  单个其他线路设备数据
输出参数:	DiffLineDevStruct *pDiffLineDevData DquCfg中其他线路设备数据内容指针
返回值:	0 失败
		1 成功
*/
UINT8 ReadDquDiffLineDevDataToConfig(DquDiffLineDevStruct *pDquDiffLineDevData, DiffLineDevStruct *pDiffLineDevData);

/*
功能描述: 将分界点数据填充至DquCfg中分界点数据内容中
输入参数:	DquCutoffPointStruct *pCutoffPointDevData  分界点设备数据
输出参数:	CfpConfigStru *pstCutoffPointData DquCfg 分界点设备数据内容指针
返回值:	0 失败
1 成功
*/
static UINT8 ReadDquCutoffPointDataToConfig(DquCutoffPointStruct *pCutoffPointDevData, CfpConfigStru *pstCutoffPointData);
/*
* 功能描述: 将系统配置联络线数据填充至DquCfg中联络线数据内容中
* 输入参数:	CBTC_BOUNDARY_AXLE_CONFIG_STRU* pCbtcBoundaryAxleInfo  系统配置联络线设备数据
* 输出参数:	LinkLineStru *pDstLinkLineData DquCfg 联络线设备数据内容指针
* 返回值  :	0 失败
*           1 成功
* Modified By LQ 2023.11.14
*/
UINT8 ReadDquLinkLineDataToConfig(CBTC_BOUNDARY_AXLE_CONFIG_STRU* pCbtcBoundaryAxleInfo, LinkLineStru* pDstLinkLineData);

void SetSignalDrvEnable(SignalConfigDataStruct* pSgnlCfgDtStr);
UINT8 InvSecNdConSwiConfDataStruInit(CHAR* FSName);
UINT8 GetRelayDrvEnableByRelayId(UINT16 relayId );
void SetGardoorphySecData(GaragedoorConfigDataStruct* pGaragedoorCfgDtStr, UINT16 physicalId);
UINT8 SetSignalVirtualAttr(DSU_SIGNAL_STRU* pSgnl,SignalConfigDataStruct* pSgnlCfgDtStr);
UINT8 SetSignalCrossCloseAttr(DSU_SIGNAL_STRU* pSgnl,SignalConfigDataStruct* pSgnlCfgDtStr);

/*********************************************
*函数功能：从点式临时限速配置数据（计轴区段）表到点式临时限速配置结构(逻辑区段)的转换
*参数说明：pDquOutStationSigStrRef 点式临时限速配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
static UINT8 sigRelatedAxisSecToLogSecTrans(DquOutStationSigStruct * pDquOutStationSigStrRef);

/*
* 功能描述：初始化分界点数据中本控区所处分界点方向
* 参数说明：CfpConfigStru *pstCutoffPointData DquCfg 分界点设备数据内容指针（出参）
* 返 回 值：0 失败
*           1 成功
* Created By LQ 2024.10.16
*/
static UINT8 EnsureCfpLocDir(CfpConfigStru* pstCutoffPointData);

/*********************************************
*函数功能：初始化无人折返配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
* by cgh 20241031
*********************************************/
static UINT8 NonAutoReturnStructInit(CHAR* FSName);

/*********************************************
*函数功能：无人折返配置数据结构体计算
*参数说明：pNonReturn 无人折返结构体指针
		   pNonReturnCfgDtStr 无人折返置数据结构体指针
*返回值：0，失败；1，成功
* by cgh 20241031
*********************************************/
static UINT8 NonReturnStruFromDquStr(DSU_AR_STRU* pNonReturn, NonAutoReturnConfigDataStruct* pNonReturnCfgDtStr);

/*
*功能描述: 初始化LINK特殊区域属性
*输入参数:	CHAR * FSName 数据文件名指针
*输出参数:	无
*返回值: 0 失败
*        1 成功
* by cgh 20250818
*/
static UINT8 LinkSpecialEaDataInit(CHAR* FSName);

/*********************************************
*函数功能：初始化继电器所有的结构体，初始化系统配置数据、相邻联锁通信数据，
*		   初始化出站信号机关联逻辑区段/计轴区段配置数据、初始化各设备继电器配置数据、初始化计轴区段/逻辑区段配置数据、
*		   初始化ESB配置、保护区段配置、侵限区段、报警灯、SPKS、防淹门配置数据；
*		   初始化联锁表（自动通过进路、自动折返进路、全自动折返进路、反向进路、屏蔽门、组合进路、进路、非进路、通信关系、车库门、其它线路、
*		   虚拟设备等）配置数据。
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 RelayInit(CHAR* FSName)
{
	UINT8 funcRtn = 0u;
	UINT8 tmpSpeedLimitType = 0u;	/*点式临时限速配置数据读取类型*/
	UINT8 localCiPattern = 0u; /*本CI模式*/
	UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 cLocalWorkType = 0U;  /*本地工作模式*/
	UINT8 chLocalOc = GetLocalOcPattern();

	(void)memset(&RelayData,0,sizeof(RelayDataStruct_Config));
	(void)memset(&LSData,0,sizeof(LSDataStruct));

	localCiPattern = GetLocalCiPattern(); /*获取本CI模式*/
	cLocalWorkType = GetLocalRcWorkMode();
	(void)dquSetInitCbtcConfigInfoRef(&cbtcConfigDataStru);/*注册全局CBTC配置结构体*/

	tmpSpeedLimitType = GetCiFunctionSwitchConfig(BLK_TEMP_SPEED_LIM_CONF);	/*获取临时限速数据类型*/

	/*初始化通信关系数据结构体*/
	funcRtn = TransmitRelationDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"TransmitRelationDataStructInit fail.\r\n");
	}
	if(FUNC_SWITCH_ON == includeVirFlag)
	{
		/* 读取虚拟联锁与OC设备关系配置数据*/
		funcRtn *= ReadVirCIWithOCRelationData(FSName);

		if (0u == funcRtn)
		{
			debug_infor_printf((const)"ReadVirCIWithOCRelationData fail.\r\n");
		}
	}
	/*初始化继电器数据结构体*/
	funcRtn *= RelayConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"RelayConfigDataStructInit fail.\r\n");
	}

	if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern)
	{
		/*初始化OC 道岔配置表数据*/
		if (DATA_TYPE_OLD == chLocalOc)
		{
			funcRtn *= OCSwitchConfigDataStructInit_OLD(FSName);
		}
		else
		{
			funcRtn *= OCSwitchConfigDataStructInit(FSName);
		}

		/*初始化OC 信号机配置表数据*/
		funcRtn *= OCSignalCfgStrConfDataStruInit(FSName);

		/*初始化OC 物理区段配置表数据*/
		funcRtn *= OCPhySecConfigDataStructInit(FSName);

	

		if (0u == funcRtn)
		{
			debug_infor_printf((const)"OCPhySecConfigDataStructInit fail.\r\n");
		}
	}

	/*初始化物理区段故障锁闭照查继电器表*/
	funcRtn *= RelayPhySecFaultLockZCStruInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"RelayPhySecFaultLockZCStruInit fail.\r\n");
	}
	

	/*初始化系统配置数据结构体*/
	funcRtn *= SystemParameterStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"SystemParameterStructInit fail.\r\n");
	}

	/* 初始化相连联锁数据通信配置数据 */
	funcRtn *= CiTransmitInfoStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"CiTransmitInfoStructInit fail.\r\n");
	}

	if (0xaau == tmpSpeedLimitType)
	{
		/* 初始化出站信号机关联的逻辑区段配置数据 */
		funcRtn *= OutStationSigRelLogSecStruInit(FSName);
		if (0u == funcRtn)
		{
			debug_infor_printf((const)"OutStationSigRelLogSecStruInit fail.\r\n");
		}
	} 
	else if(0x55u == tmpSpeedLimitType)
	{
		/* 初始化出站信号机关联的计轴区段配置数据 */
		funcRtn *= OutStationSigRelAxisSecStruInit(FSName);
		if (0u == funcRtn)
		{
			debug_infor_printf((const)"OutStationSigRelAxisSecStruInit fail.\r\n");
		}
	}
	else
	{
		/*do nothing*/
	}

	/*初始化信号机继电器配置数据结构体----对外结构体*/
	funcRtn *= SignalConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"SignalConfigDataStructInit fail.\r\n");
	}

	/*初始化洗车机继电器配置数据结构体----对外结构体*/
	funcRtn *= WashMachineConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"WashMachineConfigDataStructInit fail.\r\n");
	}

	/*初始化道岔继电器及[联锁表对应主体道岔配置数据结构体]----对外结构体*/
	funcRtn *= SwitchConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"SwitchConfigDataStructInit fail.\r\n");
	}

	/*初始化逻辑区段配置数据结构体----对外结构体*/
	funcRtn *= LogicSecConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"LogicSecConfigDataStructInit fail.\r\n");
	}

	/*初始化物理区段继电器配置数据结构体----对外结构体*/
	funcRtn *= PsclSgmtConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"PsclSgmtConfigDataStructInit fail.\r\n");
	}

	/*初始化计轴区段配置数据结构体----对外结构体*/
	funcRtn *=AxisSectionConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"AxisSectionConfigDataStructInit fail.\r\n");
	}

	/*初始化LINK配置数据结构体----对外结构体*/
	funcRtn *= LinkConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"LinkConfigDataStructInit fail.\r\n");
	}

	/*初始化防护区域配置数据结构体----对外结构体*/
	funcRtn *= EaConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"EaConfigDataStructInit fail.\r\n");
	}

	/*初始化计轴器配置数据结构体----对外结构体*/
	funcRtn *= AxisConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"AxisConfigDataStructInit fail.\r\n");
	}

	

	/*初始化紧急停车按钮接口配置数据结构体----对外结构体*/
	funcRtn *=EsbConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"EsbConfigDataStructInit fail.\r\n");
	}

	/*初始化保护区段接口配置数据结构体----对外结构体*/
	funcRtn *=OverlapConfigDataStructInit( FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"OverlapConfigDataStructInit fail.\r\n");
	}

	/*初始化侵限区段数据结构体*/
	funcRtn *= InvSecNdConSwiConfDataStruInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"InvSecNdConSwiConfDataStruInit fail.\r\n");
	}

	/*报警灯*/
	funcRtn *=IndicatorConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"IndicatorConfigDataStructInit fail.\r\n");
	}

	/* 无人折返 */
	funcRtn *= NonAutoReturnStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"NonAutoRrturnStructInit fail.\r\n");
	}

	/* SPKS */
	funcRtn *= SpksConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"SpksConfigDataStructInit fail.\r\n");
	}

	/* 门禁 */
	funcRtn *= MJConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"MenJinConfigDataStructInit fail.\r\n");
	}

	/*防淹门*/
	funcRtn *= FloodGateConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"FloodGateConfigDataStructInit fail.\r\n");
	}
	
	if (RC_WORK_MODE_TIOC == cLocalWorkType)
	{
		/*分界点	*/
		funcRtn *= CutoffPointConfigDataStructInit(FSName);
		if (0u == funcRtn)
		{
			debug_infor_printf((const)"CutoffPointConfigDataStructInit fail.\r\n");
		}
	}

	/* 联络线 */
	funcRtn *= LinkLineConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"LinkLineConfigDataStructInit fail.\r\n");
	}

	funcRtn *=ReverseCutConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"ReverseCutConfigDataStructInit fail.\r\n");
	}

	if (RC_WORK_MODE_TIOC == cLocalWorkType)
	{
		funcRtn *= GatewayConfigDataStructInit(FSName);
		if (0u == funcRtn)
		{
			debug_infor_printf((const)"GatewayConfigDataStructInit fail.\r\n");
		}
	}

	/********************************************************************************
										联锁表数据内容计算
	*********************************************************************************/
	/*初始化自动进路配置数据接口配置数据结构体----对外结构体*/
	funcRtn *=AutoRouteConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"AutoRouteConfigDataStructInit fail.\r\n");
	}

	/*初始化自动折返进路配置数据接口配置数据结构体----对外结构体*/
	funcRtn *=AutoReturnConfigDataStructInit( FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"AutoReturnConfigDataStructInit fail.\r\n");
	}

	/*初始化全自动折返进路配置数据接口配置数据结构体----对外结构体*/
	funcRtn *=AllAutoReturnCfgDtStructInit( FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"AllAutoReturnCfgDtStructInit fail.\r\n");
	}

	/*初始化反向进路配置数据接口-配置数据结构体-----对外结构体*/
	funcRtn *=ReverseRouteCfgDtStructInit( FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"ReverseRouteCfgDtStructInit fail.\r\n");
	}

	/*初始化屏蔽门配置数据接口配置数据结构体----对外结构体*/
	funcRtn *=PsdConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"PsdConfigDataStructInit fail.\r\n");
	}

	/*初始化组合进路配置数据接口配置数据结构体----对外结构体*/
	funcRtn *=LongRouteConfigDataStructInit( FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"LongRouteConfigDataStructInit fail.\r\n");
	}

	/*初始化进路配置数据*/
	funcRtn *=RouteConfigDataStructInit( FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"RouteConfigDataStructInit fail.\r\n");
	}

	/*初始化声光报警器配置数据结构体*/
	funcRtn *= SGBJConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"SGBJConfigDataStructInit fail.\r\n");
	}

	/*初始化非进路调车数据结构体----对外结构体*/
	funcRtn *=NonRouteConfigDataStructInit( FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"NonRouteConfigDataStructInit fail.\r\n");
	}

	/*车库门:注：移动到进路初始化后面，在车库门初始化中用到进路中的配置数据*/
	funcRtn *=GaragedoorConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"GaragedoorConfigDataStructInit fail.\r\n");
	}

	/*其他线路设备数据结构体初始化*/
	funcRtn *= DiffLineDevConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"DiffLineDevConfigDataStructInit fail.\r\n");
	}

	/* 初始化虚拟设备配置数据 */
	funcRtn *= VirtualDeviceInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"VirtualDeviceInit fail.\r\n");
	}

	/*PSC*/
	funcRtn *= PscConfigDataStructInit(FSName);
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"PscConfigDataStructInit fail.\r\n");
	}
	/*初始化组合自动进路配置数据接口配置数据结构体----对外结构体*/
    funcRtn *= GroupAutoRouteCfgDtStructInit(FSName);
	
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"GroupAutoRouteCfgDtStructInit fail.\r\n");
	}

	/*初始化LINK特殊防护区域属性----对外结构体*/
	funcRtn *= LinkSpecialEaDataInit(FSName);

	if (0u == funcRtn)
	{
		debug_infor_printf((const)"LinkSpecialEaDataInit fail.\r\n");
	}


	/*计轴区段防护道岔初始化*/
	funcRtn *= AxisSecProtectSwitchInit();
	if (0u == funcRtn)
	{
		debug_infor_printf((const)"AxisSecProtectSwitchInit fail.\r\n");
	}

	return funcRtn;
}

/*********************************************
*函数功能：初始化继电器数据结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 RelayConfigDataStructInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	RelayConfigDataStruct* pRlyDfgDtStr;
	UINT8* pDataAddr;         /*数据地址*/
	UINT32 DataSize;          /*数据大小（字节数）*/
	UINT16 j;
	UINT32 excelId = 0u; /*excel id*/
	UINT32 sheetId = 0u; /*sheet id*/
	UINT32 rowLen = 0u; /*行长度*/
	UINT8 localCiPattern = 0u; /*本CI模式*/

	/*已经初始化了，不用老是调用执行过程*/
	if(RelayData.pRelayCfgDtStr != NULL)
	{
		rtnValue = 1u;
	}
	else
	{
		localCiPattern = GetLocalCiPattern();
		if (CI_PATTERN_TRADITIONAL == localCiPattern)
		{
			excelId = CI_DATA_TYPE;
			sheetId = RELAY_RELAY_CONFIG_ID;
			rowLen = LEN_RELAY_RELAY_CONFIG;
		}
		else
		{
			excelId = OC_DATA_TYPE;
			sheetId = OC_RELAY_RELAY_CONFIG_ID;
			rowLen = OC_LEN_RELAY_RELAY_CONFIG;
		}

		/*读取 继电器  数据*/
		funcRtn = dquGetConfigData(FSName, excelId, sheetId,&pDataAddr,&DataSize);
		if(funcRtn == 0u)
		{
			/*函数调用失败*/
			rtnValue = 0u;
		} 	
		else
		{/*函数调用成功*/
			rtnValue = 1u;
		}

		if (1u == rtnValue)
		{
			/*求得个数*/
			if(DataSize% rowLen != 0u)
			{   
				rtnValue = 0u;
				debug_infor_printf((const)"\nCI_RELAY_DATA,RELAY_RELAY,len %d not equal to fs", rowLen);
				DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,(excelId <<8)+ sheetId,PRINT_ONCE);
			}		
		}
			
		if (1u == rtnValue)
		{
			RelayDataLen.RelayCfgDtStrLen = (UINT16)(DataSize/ rowLen);

			dquCICfgDtStr.RelayCfgDtStrLen = RelayDataLen.RelayCfgDtStrLen;

			RelayData.pRelayCfgDtStr = &dquCICfgDtStr.RelayCfgDtStr[0];

			/*内存先设为无效*/
			(void)memset(dquCICfgDtStr.RelayCfgDtStr, 0x00,sizeof(RelayConfigDataStruct) * RELAY_SUM_MAX);


			/*解析数据到 继电器数据 结构体数组 */  
			for(j=0u;j<RelayDataLen.RelayCfgDtStrLen;j++)
			{
				if (j >= RELAY_SUM_MAX)
				{
					rtnValue = 0u;
					break;
				}

				pRlyDfgDtStr = &dquCICfgDtStr.RelayCfgDtStr[j];

				/*填充数据结构体*/
				(void)RelayConfigDataStruFromChar(pDataAddr,pRlyDfgDtStr,&(dquCICfgDtStr.RelayName[j][0]));
				pDataAddr += rowLen;

				pRlyDfgDtStr->VirtualAttribute = RELAY_VIRTUAL_ATTR_NO;

			}
		}
		
	}

	return rtnValue;
}

/*********************************************
*函数功能：初始化系统配置数据结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 SystemParameterStructInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	UINT8* pDataAddr;                                  /*数据地址*/
	UINT32 DataSize;                                   /*数据大小（字节数）*/
	CBTC_CONFIG_DATA_STRU pCbtcConfigDataStru;
	UINT16 ii = 0u;/*索引*/

	funcRtn = dquCbtcConfigDataInit (FSName);
	if(0u == funcRtn)
	{
		/*函数调用失败*/
		rtnValue = 0u;
	}
	else
	{
		pCbtcConfigDataStru = cbtcConfigDataStru.cbtcConfigData;
#if 0
		dquGetCbtcConfigData (&pCbtcConfigDataStru);
#endif
		/*读取 系统配置  数据*/
		funcRtn = dquGetConfigData(FSName,CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_PARAMETER_DATA_ID,&pDataAddr,&DataSize);
		if((0u == funcRtn) || (0u == DataSize))
		{
			/*函数调用失败*/
			rtnValue = 0u;
		} 
		else
		{
			/*求得个数*/
			if(0u != (DataSize % CI_SYSTEM_PARAMETER_DATA_LEN))
			{   
				rtnValue = 0u;
				debug_infor_printf((const)"\nCI_CONFIG_DATA,SYSTEM_PARAMETER,len %d not equal to fs",CI_SYSTEM_PARAMETER_DATA_LEN);
				DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_PARAMETER_DATA_ID,PRINT_ONCE);
			}
			else
			{
				dquCICfgDtStr.SystemParamStrLen = (UINT16)(DataSize / CI_SYSTEM_PARAMETER_DATA_LEN);


				for(ii=0u;ii<dquCICfgDtStr.SystemParamStrLen;ii++)
				{
					if (CI_SYSTEM_PARA_SUM_MAX > ii )
					{
						rtnValue = PZ_SystemParaStruFromCharNew(pDataAddr,dquCICfgDtStr.SystemParaStrNew.ParaStru + ii);

						pDataAddr += CI_SYSTEM_PARAMETER_DATA_LEN;/*地址后移1行4个字节*/

						if (0u == rtnValue)
						{/*执行结果错误，中断循环*/
							break;
						}
						else
						{
						}
					}
					else
					{
						rtnValue = 0u;
					}
				}

				if (1u == rtnValue)
				{
					/*紧急制动最高触发速度（单位已在dfsInitSubSystemCommonConfigData_CC函数中转换）*/
					dquCICfgDtStr.SystemParaStrNew.MaxLineLimitSpeed = pCbtcConfigDataStru.MaxLineLimitSpeed;

					/*临时限速最高限速(km/h)（未进行单位转换）*/
					dquCICfgDtStr.SystemParaStrNew.MaxTsrSpeed = pCbtcConfigDataStru.MaxTsrSpeed;

					/*NTP校时时区差（小时）*/
					dquCICfgDtStr.SystemParaStrNew.TimeZoneDifference = pCbtcConfigDataStru.TimeZoneDifference;

					/*区间同向行驶双车间隔最小安全距离(cm))*/
					dquCICfgDtStr.SystemParaStrNew.MABackDistance = pCbtcConfigDataStru.MABackDistance;

					/*一次设置的临时限速最大个数*/
					dquCICfgDtStr.SystemParaStrNew.MaxTsrNum = pCbtcConfigDataStru.MaxTsrNum;

					/*一个临时限速报文中包含的最大限速区段数量*/
					dquCICfgDtStr.SystemParaStrNew.MaxSectionOfTsr = pCbtcConfigDataStru.MaxSectionOfTsr;

					/*IVOC-IVOC信故障判断时间（ms）*/
					dquCICfgDtStr.SystemParaStrNew.IvocIvocCommunicationErrorTime = pCbtcConfigDataStru.IvocIvocCommunicationErrorTime;

					/*IVOC-OC通信故障判断时间(ms)*/
					dquCICfgDtStr.SystemParaStrNew.IvocOcCommunicationErrorTime = pCbtcConfigDataStru.IvocOcCommunicationErrorTime;

					/*VOBC-ITS通信故障判断时间(ms)*/
					dquCICfgDtStr.SystemParaStrNew.VobcAtsCommunicationErrorTime = pCbtcConfigDataStru.VobcAtsCommunicationErrorTime;

					/*TMC-ITS通信故障判断时间（ms）*/
					dquCICfgDtStr.SystemParaStrNew.TmcItsCommunicationErrorTime = pCbtcConfigDataStru.TmcItsCommunicationErrorTime;

					/*ITS-OC通信故障判断时间（ms）*/
					dquCICfgDtStr.SystemParaStrNew.ItsOcCommunicationErrorTime = pCbtcConfigDataStru.ItsOcCommunicationErrorTime;

					/*OC-TMC通信故障判断时间（ms）*/
					dquCICfgDtStr.SystemParaStrNew.TmcOcCommunicationErrorTime = pCbtcConfigDataStru.TmcOcCommunicationErrorTime;

					/*OC-PSD通信故障判断时间（ms）*/
					dquCICfgDtStr.SystemParaStrNew.OcPsdCommunicationErrorTime = pCbtcConfigDataStru.OcPsdCommunicationErrorTime;

					/*IVOC-TSL通信故障判断时间（ms）*/
					dquCICfgDtStr.SystemParaStrNew.IvocTslCommunicationErrorTime = pCbtcConfigDataStru.IvocTslCommunicationErrorTime;

					/*OC-TSL通信故障判断时间（ms）*/
					dquCICfgDtStr.SystemParaStrNew.OcTslCommunicationErrorTime = pCbtcConfigDataStru.OcTslCommunicationErrorTime;

					/*满足精确停车条件的MA延伸长度（cm）*/
					dquCICfgDtStr.SystemParaStrNew.MALengthForATOParking = pCbtcConfigDataStru.MALengthForATOParking;

					/*本线系统定义逻辑方向与上下行方向的关系*/
					dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown = pCbtcConfigDataStru.LinkLogicDirUpAndDown;

					/*对向行驶双车间隔最小安全距离(cm)*/
					dquCICfgDtStr.SystemParaStrNew.OppositeTrackDistance = pCbtcConfigDataStru.OppositeTrackDistance;

					/*线路最差情况下紧急制动距离（单位m）*/
					dquCICfgDtStr.SystemParaStrNew.MaxMALength = pCbtcConfigDataStru.MaxMALength;

					dquCICfgDtStr.SystemParaStrNew.CiAndCiTransmitBadEnsureTime = pCbtcConfigDataStru.CICICommunicationErrorTime;

					dquCICfgDtStr.SystemParaStrNew.dwLineMinTrainLength = pCbtcConfigDataStru.dwLineMinTrainLength;

					dquCICfgDtStr.SystemParaStrNew.chZXDynamicTestSwitch = pCbtcConfigDataStru.chZXDynamicTestSwitch;

					dquCICfgDtStr.SystemParaStrNew.chDynamicTestSwitch = pCbtcConfigDataStru.chDynamicTestSwitch;

					dquCICfgDtStr.SystemParaStrNew.chWLSFunSwitch = pCbtcConfigDataStru.chWLSFunSwitch;

					dquCICfgDtStr.SystemParaStrNew.dwEaFrontDis = pCbtcConfigDataStru.dwEaFrontDis;

					dquCICfgDtStr.SystemParaStrNew.dwEaBehindDis = pCbtcConfigDataStru.dwEaBehindDis;

					dquCICfgDtStr.SystemParaStrNew.CiAndVobcTransmitBadEnsureTime = pCbtcConfigDataStru.CiVobcCommunicationErrorTime;
					dquCICfgDtStr.SystemParaStrNew.CiAndZcTransmitBadEnsureTime = pCbtcConfigDataStru.CiZcCommunicationErrorTime;

					dquCICfgDtStr.SystemParaStrNew.CiAndPsdTransmitBadEnsureTime = pCbtcConfigDataStru.CiPsdCommunicationErrorTime;

					dquCICfgDtStr.SystemParaStrNew.dwVersionOfZCToCI = pCbtcConfigDataStru.VersionOfZCToCI;
					dquCICfgDtStr.SystemParaStrNew.dwVersionOfVOBCToCI = pCbtcConfigDataStru.VersionOfVOBCToCI;
					dquCICfgDtStr.SystemParaStrNew.CiAndPscTransmitBadEnsureTime = pCbtcConfigDataStru.CommFaultTimeOfPSC_CI;

					dquCICfgDtStr.SystemParaStrNew.cAwakeCheckSpksSwitch = pCbtcConfigDataStru.cAwakeCheckSpksSwitch;
					dquCICfgDtStr.SystemParaStrNew.dwVobcCiBackUpCommErrorTime = pCbtcConfigDataStru.dwVobcCiackUpCommErrorTime;
					dquCICfgDtStr.SystemParaStrNew.VerSionBtwAxisAndCi = pCbtcConfigDataStru.ProtocolVersionOfAxisToCI;
					dquCICfgDtStr.SystemParaStrNew.dwHitSoftWallSwitch = pCbtcConfigDataStru.cHitSoftWallSwitch;
					dquCICfgDtStr.SystemParaStrNew.dwOverlapLockType = pCbtcConfigDataStru.chOverlapLockType;
					dquCICfgDtStr.SystemParaStrNew.dwCDOccuCheckFlag = pCbtcConfigDataStru.chOccuCheckinCD;
					dquCICfgDtStr.SystemParaStrNew.chNoCGFollowUtSwitch = pCbtcConfigDataStru.chNoCGFollowUtSwitch;
				}
				else
				{
				}
				
			}

		}

	}

	return rtnValue;
}


/*********************************************
*函数功能：初始化信号机继电器配置数据结构体----对外结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 SignalConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitRelay_SignalStru(FSName);
	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{/*电子地图初始化成功，继续执行*/
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		/*个数为电子地图信号机的个数*/
		dquCICfgDtStr.SgnlCfgDtStrLen = dsuDataLenStru.wSignalLen;
		for(i=0u;i<dsuDataLenStru.wSignalLen;i++)
		{
			if (i >= SIGNAL_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			rtnvalue = SglCfgDtStruFromDquSignalStr(dsuStaticHeadStru.pSignalStru+i,&dquCICfgDtStr.SgnlCfgDtStr[i]);
			if (0u == rtnvalue)
			{
				break;
			}
		}
	}
	
	return rtnvalue;
}

/*********************************************
*函数功能：初始化洗车机继电器配置数据结构体----对外结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 WashMachineConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;

	callFun = InitRelay_WashMachineStru(FSName);/*填充洗车机继电器结构体数组*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
		/*个数为洗车机继电器表里的个数*/
		dquCICfgDtStr.WashMachineCfgDtStrLen = RelayDataLen.RelayWashMachineStrLen;
		for(i=0u;i< dquCICfgDtStr.WashMachineCfgDtStrLen;i++)
		{
			if (i >= WASHMACHINE_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			(void)WashMachineCfgDtStruFromDquStr(RelayData.pRelayWashMachineStr + i,&dquCICfgDtStr.WashMachineCfgStr[i]);
		}
	}

	return rtnvalue;
}

/*********************************************
*函数功能：初始化道岔继电器配置数据结构体----对外结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 SwitchConfigDataStructInit(CHAR * FSName)
{
	UINT8 rtnvalue = 1u;
	UINT8 callFun = 0u;
	UINT16 i=0u;
	UINT8 lineIdentity = CI_TRADITION_RAILWAY;

	lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*获取线路标识:0x55:城轨交通；0xAA:单轨交通*/

	callFun = dfsEmapInit (FSName);

	if (CI_TRADITION_RAILWAY == lineIdentity)
	{
		callFun *= InitRelay_PointStru(FSName);
		callFun *= InitLS_ProSwitchHostMapStru(FSName);/*初始化联锁表-防护道岔与主体道岔对应关系表*/
		dquCICfgDtStr.SwchCfgDtStrLen = dsuDataLenStru.wPointLen;
	}/* zt 删除单轨相关代码 2022-02-15 */
	else
	{
		rtnvalue = 0u;
	}

	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	/*电子地图初始化成功，继续执行*/
	else
	{
		if (CI_TRADITION_RAILWAY == lineIdentity)
		{
			for(i=0u;i<dquCICfgDtStr.SwchCfgDtStrLen;i++)
			{
				if (i >= SWITCH_SUM_MAX)
				{
					rtnvalue = 0u;
					break;
				}
				rtnvalue = SwitchCfgDtStruFromDquPointStr(dsuStaticHeadStru.pPointStru+i,&dquCICfgDtStr.SwchCfgDtStr[i]);

				if (1u == rtnvalue)
				{
					rtnvalue = SwitchCfgDtStruFromLSProHostStr(&dquCICfgDtStr.SwchCfgDtStr[i]);
					if (0u == rtnvalue)
					{
						debug_infor_printf((const)"SwitchCfgDtStruFromLSProHostStr switch %d fail.\r\n", dquCICfgDtStr.SwchCfgDtStr[i].SwitchId);
						break;
					}
					else
					{

					}
					if (1u == rtnvalue)
					{
						rtnvalue = SwitchCfgLogTrackInitDquStr(dsuStaticHeadStru.pPointStru+i,&dquCICfgDtStr.SwchCfgDtStr[i]);
						if(0u == rtnvalue)
						{
							debug_infor_printf((const)"SwitchCfgLogTrackInitDquStr switch %d fail.\r\n",dquCICfgDtStr.SwchCfgDtStr[i].SwitchId);
							break;
						}
					}
					else
					{
						debug_infor_printf((const)"SwitchCfgDtStruFromLSProHostStr switch %d fail.\r\n",dquCICfgDtStr.SwchCfgDtStr[i].SwitchId);
						break;
					}
				}
				else
				{
					debug_infor_printf((const)"SwitchCfgDtStruFromDquPointStr switch %d fail.\r\n",dquCICfgDtStr.SwchCfgDtStr[i].SwitchId);
					break;
				}
			}
		}/* zt 删除单轨相关代码 2022-02-15 */
		else
		{
			rtnvalue = 0u;
		}
	}

	return rtnvalue;
}
/*********************************************
*函数功能：初始化物理区段继电器配置数据结构体----对外结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 PsclSgmtConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitRelay_PhysicalSgmtStru(FSName);
	callFun *= InitLS_PhySectionIntrudeStru(FSName);
	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
		return rtnvalue;
	}	
	else
	{/*电子地图初始化成功，继续执行*/
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.PsclSgmtCfgDtStrLen = dsuDataLenStru.wPhysicalSgmtLen;/*物理区段数量*/
		for(i=0u;i<dsuDataLenStru.wPhysicalSgmtLen;i++)
		{
			if (i >= PHYSICAL_SECTION_SUM_MAX)
			{
				rtnvalue = 0u;
			}
			else
			{
				rtnvalue = PhySgmtCfgDtStruFromDquSgmtStr(dsuStaticHeadStru.pPhysicalSgmtStru+i,&dquCICfgDtStr.PsclSgmtCfgDtStr[i],dquCICfgDtStr.SgnlCfgDtStr);
			}
			if(0u == rtnvalue)
			{
				break;
			}
		}
	}
	
	return rtnvalue;
}

/*********************************************
*函数功能：初始化计轴区段配置数据结构体----对外结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 AxisSectionConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;

	callFun = dfsEmapInit (FSName);

	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{	
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.AxisSctCfgDtStrLen = dsuDataLenStru.wAxleSgmtLen;
		for(i=0u;i<dsuDataLenStru.wAxleSgmtLen;i++)
		{
			if (AXIS_SECTION_SUM_MAX > i)
			{
				rtnvalue = AxisSecCfgDtStruFromDquSgmtStr(dsuStaticHeadStru.pAxleSgmtStru + i, &dquCICfgDtStr.AxisSctCfgDtStr[i]);
			}
			else
			{
				rtnvalue = 0U;
			}

			if (0U == rtnvalue)
			{
				break;
			}
			else
			{
				; /*继续执行*/
			}
		}
	}
	else
	{
		;
	}

	return rtnvalue;
}

/*********************************************
*函数功能：初始化逻辑区段配置数据结构体----对外结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8  LogicSecConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;
	UINT8 isEachInvFlag = 0U;

	/*判断是否采用《侵限关系表》*/
	isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION);

	callFun = dfsEmapInit (FSName);


	/*填充逻辑区段侵限关系表*/
	callFun *= InitLS_LogicSecIntruStru(FSName);
	/*填充逻辑区段互相侵限关系表*/
	callFun *= InitLS_LogSecIntruStru_Each(FSName);

	if (FUNC_SWITCH_OFF == isEachInvFlag)
	{
		/*填充侵限区段及条件道岔表数据结构体*/
		callFun *= InitLS_IntrudePhySectionStruct(FSName);
	}
	else
	{
		/*从逻辑区段互相侵限转化侵限区段及条件道岔表数据结构体*/
		callFun *= InitLS_InvEachPhySectionStruct(dsuDataLenStru.wLogicSgmtLen, dsuStaticHeadStru.pLogicSgmtStru);
	}

	callFun *= InitLS_LogicLtrlDfncStru(FSName);
	callFun *= InitLS_ContactConfigDataStruct(FSName);
	
	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{	
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.lgcSctCfgDtStrLen = dsuDataLenStru.wLogicSgmtLen;
		for (i = 0u; i < dsuDataLenStru.wLogicSgmtLen; i++)
		{
			if (i >= LOGIC_SECTION_SUM_MAX)
			{
				rtnvalue = 0u;

			}

			rtnvalue &= LogicSecCfgDtStruFromDquSgmtStr(dsuStaticHeadStru.pLogicSgmtStru + i, &dquCICfgDtStr.lgcSctCfgDtStr[i]);

			if (0U == rtnvalue)
			{
				/*跳出循环，返回初始化失败*/
				break;
			}
		}
	}
	
	return rtnvalue;
}

/*********************************************
*函数功能：从信号机结构体计算信号机继电器结构体
*参数说明：pSgnl是DSU信号机数据结构指针
pSgnlCfgDtStr是信号机配置数据结构指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 SglCfgDtStruFromDquSignalStr(DSU_SIGNAL_STRU* pSgnl,SignalConfigDataStruct* pSgnlCfgDtStr)
{
	UINT16 i = 0u;
	UINT8 rtnvalue = 0u;

	UINT16 index = 0u;
	UINT16 axleSgmtId = 0u;
	UINT8 relayFind = 0u;                     /*找到置1*/
	DSU_ROUTE_STRU *    pCurrentRouteStru = NULL;   /*进路结构体临时指针变量*/
	DSU_AXLE_SGMT_STRU * pCurrentAxleStru = NULL;
	UINT16 signalOutFirstAxleId = 0u;
	UINT16 ocIdBuff = 0u;
	UINT16 indexAc = 0U;
	UINT8 railwayType = CI_TRADITION_RAILWAY;

	/*入口参数防护*/
	if((NULL == pSgnl) || (NULL == pSgnlCfgDtStr))
	{
		/*返回失败*/
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = CI_SUCCESS;
		railwayType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*获取线路类型*/

		pSgnlCfgDtStr->SignalId = pSgnl->wId;
		pSgnlCfgDtStr->BelongCiId = (UINT8)pSgnl->wManagePhysicalCI;
		pSgnlCfgDtStr->BelongVirCI = (UINT8)pSgnl->wBelongVirCI;
		if (pSgnlCfgDtStr->SignalId < SIGNAL_SUM_MAX)
		{
			ocIdBuff = dquCICfgDtStr.OCSignalCfgStr[pSgnlCfgDtStr->SignalId].BelongOcId;
#if 0
			if (0u == ocIdBuff)
			{
				/*信号机ID与OC配置表ID不一致，返回失败*/
				rtnvalue = 0u;
				return rtnvalue;
			}
			else
			{
				pSgnlCfgDtStr->BelongOcId = ocIdBuff;
			}
#else
			pSgnlCfgDtStr->BelongOcId = ocIdBuff;
#endif
		}
		pSgnlCfgDtStr->Direction = (UINT8)pSgnl->wProtectDir;
		if (pSgnlCfgDtStr->Direction==dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown)
		{
			pSgnlCfgDtStr->OperDirection = CI_SYSTEM_DIRECTION_DOWN;
		}
		else
		{
			pSgnlCfgDtStr->OperDirection = CI_SYSTEM_DIRECTION_UP;
		}
		pSgnlCfgDtStr->startSigCiRouteSum = 0u;

		/*遍历开始前，全置为0*/
		pSgnlCfgDtStr->FirDsRelayId = 0u;
		pSgnlCfgDtStr->SecDsRelayId = 0u;
		pSgnlCfgDtStr->LxRelayId = 0u;
		pSgnlCfgDtStr->ZxRelayId = 0u;
		pSgnlCfgDtStr->YxRelayId = 0u;
		pSgnlCfgDtStr->DdRelayId = 0u;
		pSgnlCfgDtStr->DxRelayId = 0u;
		pSgnlCfgDtStr->YellowRelayId_wh = 0u;
		pSgnlCfgDtStr->GreenRelayId_wh = 0u;
		pSgnlCfgDtStr->BlueDsRelayId_wh = 0u;
		pSgnlCfgDtStr->RepLxRelayId = 0u;
		pSgnlCfgDtStr->DetainDriveRelayId = 0u;
		pSgnlCfgDtStr->detainRelayId = 0u;
		pSgnlCfgDtStr->detainDisplayRelayId = 0u;
		pSgnlCfgDtStr->detainCutDisplayRelayId = 0u;
		/*信号机内方第一区段ID (配置字段)*/
		pSgnlCfgDtStr->InFirstPhySecId = 0u;

		/*信号机外方第一区段ID (配置字段)*/
		pSgnlCfgDtStr->OutFirstPhySecId = 0u;

		if (pSgnl->wId < SIGNAL_SUM_MAX)
		{
			pSgnlCfgDtStr->detainRelayId = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainBtnCollRelayId;
			pSgnlCfgDtStr->detainCutRelayId = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainCutBtnRelayId;
			pSgnlCfgDtStr->detainDisplayRelayId = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainBtnIndicatorRelayId;
			pSgnlCfgDtStr->detainCutDisplayRelayId = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainCutBtnIndicatorRelayId;
			/*TSCI合并添加 -lc 20221208*/
			pSgnlCfgDtStr->detainRelayId_2 = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainBtnCollRelayId_2;
			pSgnlCfgDtStr->detainCutRelayId_2 = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainCutBtnRelayId_2;
			pSgnlCfgDtStr->detainDisplayRelayId_2 = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainBtnIndicatorRelayId_2;
			pSgnlCfgDtStr->detainCutDisplayRelayId_2 = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainCutBtnIndicatorRelayId_2;
			pSgnlCfgDtStr->cancelDetainBtnCollRelayId = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].CancelDetainBtnCollRelayId;
			pSgnlCfgDtStr->cancelDetainBtnCollRelayId_2 = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].CancelDetainBtnCollRelayId_2;
		}
		if ((pSgnl->sDengWeiFengBi | 0xfbu) == 0xfbu)
		{
			/*封黄灯*/
			pSgnlCfgDtStr->SignalFengDengType = SIGNAL_TYPE_FENG_YELLOW;
		}
		else if ((pSgnl->sDengWeiFengBi | 0xfdu) == 0xfdu)
		{
			/*封绿灯*/
			pSgnlCfgDtStr->SignalFengDengType = SIGNAL_TYPE_FENG_GREEN;
		}
		else
		{
			pSgnlCfgDtStr->SignalFengDengType = SIGNAL_TYPE_FENG_NO;
		}
		for(i=0u;i<RelayDataLen.RelaySignalStrLen;i++)
		{
			/*找到对应信号机，直接拷贝数据*/
			if((RelayData.pRelaySignalStr+i)->wSignalId == pSgnl->wId)
			{
#if 0
				pSgnlCfgDtStr->SignalType = getSignalType((RelayData.pRelaySignalStr+i),pSgnl);
#endif
				pSgnlCfgDtStr->FirDsRelayId = (RelayData.pRelaySignalStr+i)->wRelayDengSiId_1;
				pSgnlCfgDtStr->SecDsRelayId = (RelayData.pRelaySignalStr+i)->wRelayDengSiId_2;
				pSgnlCfgDtStr->LxRelayId = (RelayData.pRelaySignalStr+i)->wRelayTrainSignalId;
				pSgnlCfgDtStr->ZxRelayId = (RelayData.pRelaySignalStr+i)->wRelayZhengXianId;
				pSgnlCfgDtStr->YxRelayId = (RelayData.pRelaySignalStr+i)->wRelayYinDaoId;
				pSgnlCfgDtStr->DdRelayId = (RelayData.pRelaySignalStr+i)->wRelayDianDengId;
				pSgnlCfgDtStr->DxRelayId = (RelayData.pRelaySignalStr+i)->wRelayDiaoCheSignalId;
				pSgnlCfgDtStr->YellowRelayId_wh = (RelayData.pRelaySignalStr+i)->wRelayYellowId_wh;
				pSgnlCfgDtStr->GreenRelayId_wh = (RelayData.pRelaySignalStr+i)->wRelayGreenId_wh;
				pSgnlCfgDtStr->BlueDsRelayId_wh = (RelayData.pRelaySignalStr+i)->wRelayBlueDsId_wh;
				pSgnlCfgDtStr->RepLxRelayId = (RelayData.pRelaySignalStr+i)->wRepRelayTrainSignalId;
				pSgnlCfgDtStr->DetainDriveRelayId = (RelayData.pRelaySignalStr+i)->wRelayDriveDetainId;
				pSgnlCfgDtStr->detainRelayId = (RelayData.pRelaySignalStr+i)->wRelayCollDetainId;
				pSgnlCfgDtStr->SignalType = (UINT8)((RelayData.pRelaySignalStr+i)->wSignalDrvColType);
				pSgnlCfgDtStr->detainRelayId = (RelayData.pRelaySignalStr + i)->DetainBtnCollRelayId;
				pSgnlCfgDtStr->detainCutRelayId = (RelayData.pRelaySignalStr + i)->DetainCutBtnRelayId;
				pSgnlCfgDtStr->detainDisplayRelayId = (RelayData.pRelaySignalStr + i)->DetainBtnIndicatorRelayId;
				pSgnlCfgDtStr->detainCutDisplayRelayId = (RelayData.pRelaySignalStr + i)->DetainCutBtnIndicatorRelayId;
				if((pSgnl->sDengWeiFengBi | 0xfbu) == 0xfbu)
				{
					/*封黄灯*/
					pSgnlCfgDtStr->SignalFengDengType =  SIGNAL_TYPE_FENG_YELLOW;
				}
				else if((pSgnl->sDengWeiFengBi | 0xfdu) == 0xfdu)
				{
					/*封绿灯*/
					pSgnlCfgDtStr->SignalFengDengType =  SIGNAL_TYPE_FENG_GREEN;
				}
				else
				{
					pSgnlCfgDtStr->SignalFengDengType = SIGNAL_TYPE_FENG_NO;
				}
				/*找到对应的信号机信息*/
				relayFind = 1u;

				break;
			}
			else
			{
				/*继续循环*/
			}
		}
		SetSignalDrvEnable(pSgnlCfgDtStr);/*设置信号机是否可驱动标志*/
		rtnvalue &= SetSignalVirtualAttr(pSgnl,pSgnlCfgDtStr);/*根据电子地图中信号机属性设置信号机虚拟属性*/
		rtnvalue &= SetSignalCrossCloseAttr(pSgnl,pSgnlCfgDtStr);/*根据电子地图中信号机属性设置信号机调车跨压关灯属性*/
		rtnvalue &= SetSignalFenDuanAttr(pSgnl, pSgnlCfgDtStr);/*根据电子地图中信号机属性设置信号机分段属性*/

		if (1U == rtnvalue)
		{
			pSgnlCfgDtStr->wProtectLinkId = pSgnl->wProtectLinkId;
			pSgnlCfgDtStr->dwProtectOff = pSgnl->dwProtectLinkOfst;
			pSgnlCfgDtStr->chShineSignal = (UINT8)pSgnl->wShineSignal;
			if (EMAP_SAME_DIR == pSgnl->wProtectDir)
			{
				if (0u != pSgnl->dwProtectLinkOfst)
				{
					pSgnlCfgDtStr->wOutFirstLinkId = pSgnl->wProtectLinkId;
					pSgnlCfgDtStr->wInFirstLinkId = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[pSgnl->wProtectLinkId]].wTmnlJointMainLkId;
				}
				else
				{
					pSgnlCfgDtStr->wOutFirstLinkId = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[pSgnl->wProtectLinkId]].wOrgnJointMainLkId;
					pSgnlCfgDtStr->wInFirstLinkId = pSgnl->wProtectLinkId;
				}
			}
			else
			{
				if (0u != pSgnl->dwProtectLinkOfst)
				{
					pSgnlCfgDtStr->wOutFirstLinkId = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[pSgnl->wProtectLinkId]].wTmnlJointMainLkId;
					pSgnlCfgDtStr->wInFirstLinkId = pSgnl->wProtectLinkId;
				}
				else
				{
					pSgnlCfgDtStr->wOutFirstLinkId = pSgnl->wProtectLinkId;
					pSgnlCfgDtStr->wInFirstLinkId = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[pSgnl->wProtectLinkId]].wOrgnJointMainLkId;
				}
			}

			if (0U!=pSgnlCfgDtStr->wOutFirstLinkId)
			{
				for (indexAc = 0u; indexAc < dsuDataLenStru.wAxleSgmtLen; indexAc++)
				{
					pCurrentAxleStru = dsuStaticHeadStru.pAxleSgmtStru + indexAc;
					if (NULL!=pCurrentAxleStru)
					{
						
						if( (pCurrentAxleStru->wOrgnLkId == pSgnlCfgDtStr->wOutFirstLinkId)
							||(pCurrentAxleStru->wTmnlLkId == pSgnlCfgDtStr->wOutFirstLinkId))
						{
							pSgnlCfgDtStr->OutFirstPhySecId = pCurrentAxleStru->wRelatePhysicalSgmtId;
							signalOutFirstAxleId = pCurrentAxleStru->wId;
							break;
						}
					}
				}
			}

			if (0U != pSgnlCfgDtStr->wInFirstLinkId)
			{
				for (indexAc = 0u; indexAc < dsuDataLenStru.wAxleSgmtLen; indexAc++)
				{
					pCurrentAxleStru = dsuStaticHeadStru.pAxleSgmtStru + indexAc;
					if (NULL != pCurrentAxleStru)
					{

						if ((pCurrentAxleStru->wOrgnLkId == pSgnlCfgDtStr->wInFirstLinkId)
							|| (pCurrentAxleStru->wTmnlLkId == pSgnlCfgDtStr->wInFirstLinkId))
						{
							pSgnlCfgDtStr->InFirstPhySecId = pCurrentAxleStru->wRelatePhysicalSgmtId;
							break;
						}
					}
				}
			}
		}

		if (1U == rtnvalue)
		{
			for (i = 0U; i < dsuDataLenStru.wRouteLen; i++)
			{
				pCurrentRouteStru = dsuStaticHeadStru.pRouteStru + i;
				/*以信号机为终端的进路*/
				if (pSgnl->wId == pCurrentRouteStru->wEndSignalId)
				{
					index = pCurrentRouteStru->wIncludeAxleSgmtNum;
					/*进路的最后一个计轴区段*/
					axleSgmtId = pCurrentRouteStru->wIncludeAxleSgmtId[index - 1U];
					/*信号机外方第一区段ID*/
					if ((axleSgmtId <= AXLESGMTINDEXNUM))
					{
						if (0xffffU == dsuAxleSgmtIndex[axleSgmtId])
						{
							pSgnlCfgDtStr->OutFirstPhySecId = 0U;
							signalOutFirstAxleId = 0U;
						}
						else
						{
							/*对应物理区段*/
							pSgnlCfgDtStr->OutFirstPhySecId = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[axleSgmtId]].wRelatePhysicalSgmtId;
							signalOutFirstAxleId = axleSgmtId;
						}
					}
				}
				/*以信号机为始端的进路*/
				if (pSgnl->wId == pCurrentRouteStru->wStartSignalId)
				{
					/*信号机内方第一区段ID */
					axleSgmtId = pCurrentRouteStru->wIncludeAxleSgmtId[0];

					if ((axleSgmtId <= AXLESGMTINDEXNUM))
					{
						if (0xffffU == dsuAxleSgmtIndex[axleSgmtId])
						{
							pSgnlCfgDtStr->InFirstPhySecId = 0U;
						}
						else
						{
							/*对应物理区段*/
							pSgnlCfgDtStr->InFirstPhySecId = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[axleSgmtId]].wRelatePhysicalSgmtId;
						}
					}
				}
			}
		}

		if (1u == rtnvalue)
		{
			pSgnlCfgDtStr->signalPsdSum = 0u;
			if ((0u != signalOutFirstAxleId) && (signalOutFirstAxleId <= AXLESGMTINDEXNUM))
			{
				/*找到信号机外方的第一个计轴*/
				if (dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[signalOutFirstAxleId]].wOrgnLkId== dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[signalOutFirstAxleId]].wTmnlLkId)
				{
					/*说明计轴不包含道岔，有可能是站台轨：确定信号机关联的PSD*/
					for (i=0u;i<dsuDataLenStru.wScreenLen;i++)
					{
						if (dsuStaticHeadStru.pScreenStru[i].wRelatLkId == dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[signalOutFirstAxleId]].wOrgnLkId)
						{
							if (pSgnlCfgDtStr->signalPsdSum<SIGNAL_RELATED_PSD_MAX_SUM)
							{
								pSgnlCfgDtStr->signalPsdIdBuf[pSgnlCfgDtStr->signalPsdSum++]= dsuStaticHeadStru.pScreenStru[i].wId;
							}
							else
							{
								rtnvalue = 0u;
								break;
							}
						}
					}

					/*说明计轴不包含道岔，有可能是站台轨：确定信号机关联的ESB*/
					for (i = 0u; i < dsuDataLenStru.wEmergStopLen; i++)
					{
						if (dsuStaticHeadStru.pEmergStopStru[i].wRelatLkId == dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[signalOutFirstAxleId]].wOrgnLkId)
						{
							if (pSgnlCfgDtStr->signalEsbSum < SIGNAL_RELATED_ESB_MAX_SUM)
							{
								pSgnlCfgDtStr->signalEsbIdBuf[pSgnlCfgDtStr->signalEsbSum] = dsuStaticHeadStru.pEmergStopStru[i].wId;
								pSgnlCfgDtStr->signalEsbSum++;
							}
							else
							{
								rtnvalue = 0u;
								break;
							}
						}
					}
				}
			}
		}

#if 0
		/*电子地图信号机表中信号机的数据比CI-继电器表中信号机继电器表中信号机多，此处不应返回失败*/
		if (1u == rtnvalue)
		{
			if(0u == relayFind)
			{
				rtnvalue = 0u;
			}
			else
			{/*do nothing*/
			}
		}
#endif


		if (1u == rtnvalue)
		{
			/*信号机关联的逻辑区段计算（用于计算信号机点式临时速）*/
			pSgnlCfgDtStr->relatedLogSecSum = 0u;

			for(i = 0u; i < dquOutStationSigStrLen;i++)
			{
				if((pDquOutStationSigStr + i)->wSignalId == pSgnlCfgDtStr->SignalId)
				{
					pSgnlCfgDtStr->relatedLogSecSum = (pDquOutStationSigStr + i)->wRalatedLogSecSum;
					(void)CommonMemCpy(pSgnlCfgDtStr->ralatedLogSecIdBuf,SIGNAL_RELATED_LOGSEC_MAX_SUM * 2u,(pDquOutStationSigStr + i)->wRalatedLogSecIdBuf,pSgnlCfgDtStr->relatedLogSecSum * 2u);

				}
			}


			/*获取始端信号机相同的进路*/
			pSgnlCfgDtStr->startSigRouSum = 0u;
			for(i=0u; i<dsuDataLenStru.wRouteLen; i++)
			{
				pCurrentRouteStru = dsuStaticHeadStru.pRouteStru + i;

				if(pSgnl->wId == pCurrentRouteStru->wStartSignalId)
				{
					if (pSgnlCfgDtStr->startSigRouSum < SIGNAL_EQUAL_ROUTE_MAX_SUM)
					{
						pSgnlCfgDtStr->startSigRouBuf[pSgnlCfgDtStr->startSigRouSum] = pCurrentRouteStru->wId;
						pSgnlCfgDtStr->startSigRouSum ++;

						if (0u==(pCurrentRouteStru->wRouteType & 0x0200u))
						{/*非ZC自动办理的进路*/
							pSgnlCfgDtStr->startSigCiRouteSum++;
						}
					}
					else
					{
						rtnvalue = 0u;/*索引超出*/
						debug_infor_printf((const)"Error:signal %d startSameSigRouteNum exceed maxNum %d! ",pSgnlCfgDtStr->SignalId,SIGNAL_EQUAL_ROUTE_MAX_SUM);
					}
				}
			}
			pSgnlCfgDtStr->ConfigZcCiSignalCrossMask = SIGNAL_CONFIG_CROSS_MASK_NO;
			pSgnlCfgDtStr->SignalIsThisLine = DEV_IS_THIS_LINE_YES; /*本线路*/
		}	
	}

	return rtnvalue;
}

/*********************************************
*函数功能：计算洗车机配置数据
*参数说明：relayWashMachineStruct:洗车机继电器结构体指针
pWashMachineCfgDtStr:洗车机配置结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 WashMachineCfgDtStruFromDquStr(Relay_WashMachineStruct * relayWashMachineStruct,WashMachineConfigDataStruct* pWashMachineCfgDtStr)
{
	UINT8 retVal = 0u;
	if((NULL == relayWashMachineStruct) || (NULL == pWashMachineCfgDtStr))
	{
		retVal = 0u;
	}
	else
	{
		pWashMachineCfgDtStr->WashMachineId = relayWashMachineStruct->wId;
		pWashMachineCfgDtStr->WashMachineReadyRelayId = relayWashMachineStruct->WashMachineReadyRelayId;
		pWashMachineCfgDtStr->BelongCiId = GetBelongCiByRelayId(pWashMachineCfgDtStr->WashMachineReadyRelayId);
		pWashMachineCfgDtStr->BelongVirCiId = GetBelongVirCiByRelayId(pWashMachineCfgDtStr->WashMachineReadyRelayId);
		pWashMachineCfgDtStr->WashMachineRequestVerifyRelayId = relayWashMachineStruct->WashMachineRequestVerifyRelayId;
		pWashMachineCfgDtStr->TrainEmergencyStopRelayId = relayWashMachineStruct->TrainEmergencyStopRelayId;
		pWashMachineCfgDtStr->HeadWashAllowRelayId = relayWashMachineStruct->HeadWashAllowRelayId;
		pWashMachineCfgDtStr->TailWashAllowRelayId = relayWashMachineStruct->TailWashAllowRelayId;
		pWashMachineCfgDtStr->WashTrainRequestRelayId = relayWashMachineStruct->WashTrainRequestRelayId;
		pWashMachineCfgDtStr->TrainHeadStopSteadyRelayId = relayWashMachineStruct->TrainHeadStopSteadyRelayId;
		pWashMachineCfgDtStr->TrainTailStopSteadyRelayId = relayWashMachineStruct->TrainTailStopSteadyRelayId;
		pWashMachineCfgDtStr->TrainPassRequestRelayId = relayWashMachineStruct->TrainPassRequestRelayId;
		pWashMachineCfgDtStr->TrainOutWashPortAllowRelayId = relayWashMachineStruct->TrainOutWashPortAllowRelayId;
		pWashMachineCfgDtStr->PauseTrainWashRequestRelayId = relayWashMachineStruct->PauseTrainWashRequestRelayId;
		pWashMachineCfgDtStr->WashModeBackRelayId = relayWashMachineStruct->WashModeBackRelayId;

		pWashMachineCfgDtStr->WashModeRelayId = relayWashMachineStruct->WashModeRelayId;
		pWashMachineCfgDtStr->wDownWashAllowRelayId = relayWashMachineStruct->wDownWashAllowRelayId;
		pWashMachineCfgDtStr->wDownWashAllowLightRelayId = relayWashMachineStruct->wDownWashAllowLightRelayId;
		pWashMachineCfgDtStr->wDownWashAllowPassRelayId = relayWashMachineStruct->wDownWashAllowPassRelayId;
		pWashMachineCfgDtStr->wDownWashRelateRoute1Id = relayWashMachineStruct->wDownWashRelateRoute1Id;
		pWashMachineCfgDtStr->wDownWashRelateRoute1CheckType = relayWashMachineStruct->wDownWashRelateRoute1CheckType;
		pWashMachineCfgDtStr->wDownWashRelRoute1LightRelayId = relayWashMachineStruct->wDownWashRelRoute1LightRelayId;
		pWashMachineCfgDtStr->wDownWashRelateRoute2Id = relayWashMachineStruct->wDownWashRelateRoute2Id;
		pWashMachineCfgDtStr->wDownWashRelateRoute2CheckType = relayWashMachineStruct->wDownWashRelateRoute2CheckType;
		pWashMachineCfgDtStr->wDownWashRelRoute2LightRelayId = relayWashMachineStruct->wDownWashRelRoute2LightRelayId;


		retVal = 1u;
	}
	return  retVal;
}

/*********************************************
*函数功能：获取信号机类型
*参数说明：pRelaySgnl继电器信号机结构体指针
pSgnlDSU信号机结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 getSignalType(Relay_SignalStruct* pRelaySgnl,DSU_SIGNAL_STRU* pSgnl)
{
	UINT8 MyType = 0u;
	UINT16 i;
	UINT8 BaseType[] = {0x01u,0x02u,0x04u,0x08u,0x10u,0x20u,0x40u};
	UINT8 RtnType[14] = {0u};
	UINT8 MyRtnType[14] = {SIGNAL_TYPE_THREE_ALL_YINDAO,SIGNAL_TYPE_THREE_ALL_NOYINDAO,
		SIGNAL_TYPE_THREE_NOGREEN_YINDAO,SIGNAL_TYPE_THREE_NOGREEN_NOYINDAO,
		SIGNAL_TYPE_THREE_NOYELLOW_NOYINDAO,SIGNAL_TYPE_TWO_ALL_NOYINDAO,
		SIGNAL_TYPE_TWO_NOGREEN_NOYINDAO,SIGNAL_TYPE_DIAOCHE,SIGNAL_TYPE_THREE_NOYELLOW_YINDAO,
		SIGNAL_TYPE_JINKUCHUKU,SIGNAL_TYPE_THREE_ALL_YINDAO_NOY,SIGNAL_TYPE_THREE_JINKU_YINDAO,SIGNAL_TYPE_TWO_JINKU_RGY,
		SIGNAL_TYPE_3_NOGREEN_YINDAO_NOL};

	/*入口参数防护*/
	if((NULL == pRelaySgnl) || (NULL == pSgnl))
	{
		/*返回失败*/
		return 0u;
	}

	/*道岔防护信号机(三显示，不封灯位，带引导)DJ、2DJ、DDJ、LXJ、ZXJ、YXJ*/
	RtnType[0] = BaseType[DJ]|BaseType[DJ2]|BaseType[DDJ]|BaseType[LXJ]|BaseType[ZXJ]|BaseType[YXJ];
	/*道岔防护信号机(三显示，不封灯位，不带引导)DJ、DDJ、LXJ、ZXJ*/
	RtnType[1] = BaseType[DJ]|BaseType[DDJ]|BaseType[LXJ]|BaseType[ZXJ];
	/*道岔防护信号机(三显示，封绿灯，带引导)DJ、2DJ、DDJ、LXJ、YXJ*/
	RtnType[2] = BaseType[DJ]|BaseType[DJ2]|BaseType[DDJ]|BaseType[LXJ]|BaseType[YXJ];

	/*道岔防护信号机(三显示，封绿灯，不带引导)DJ、DDJ、LXJ*/
	RtnType[3] = BaseType[DJ]|BaseType[DDJ]|BaseType[LXJ];

	/*出站兼道岔防护信号机(三显示，封黄灯)DJ、DDJ、LXJ*/
	RtnType[4] = BaseType[DJ]|BaseType[DDJ]|BaseType[LXJ];

	/*出站、区间分割、阻挡信号机(两显示，不封灯位)DJ、DDJ、LXJ*/
	RtnType[5] = BaseType[DJ]|BaseType[DDJ]|BaseType[LXJ];

	/*反向阻挡信号机(两显示，封绿灯)DJ*/
	RtnType[6] = BaseType[DJ];

	/*调车信号机DXJ、DJ*/
	RtnType[7] = BaseType[DXJ]|BaseType[DJ];

	/*进段信号机(三显示)LXJ、YXJ、DJ、2DJ*/
	RtnType[8] = BaseType[DJ]|BaseType[DJ2]|BaseType[LXJ]|BaseType[YXJ];

	/*进库/出库信号机(三显示) DJ、LXJ、DXJ*/
	RtnType[9] = BaseType[DJ]|BaseType[DXJ]|BaseType[LXJ];

	/*道岔防护信号机(三显示，不封灯，带引导，不可单独点亮黄灯，可灭灯)*/
	RtnType[10] = BaseType[DJ]|BaseType[DJ2]|BaseType[DDJ]|BaseType[LXJ]|BaseType[YXJ];

	/*进库信号机（三显示带引导）新机场新增类型2019.1.15*/
	RtnType[11] = BaseType[DJ]|BaseType[DJ2]|BaseType[DXJ]|BaseType[LXJ]|BaseType[YXJ];

	/*进段/进库信号机(三显示)*/
	RtnType[12] = BaseType[LXJ]|BaseType[YXJ];

	/*道岔防护信号机(三显示，封绿灯，带引导，不能灭灯)*/
	RtnType[13] = BaseType[DJ]|BaseType[DJ2]|BaseType[LXJ]|BaseType[YXJ];

	if(pRelaySgnl->wRelayDengSiId_1 != 0u)
	{
		MyType |= 0x01u;
	}
	if(pRelaySgnl->wRelayDengSiId_2 != 0u)
	{
		MyType |= 0x02u;
	}
	if(pRelaySgnl->wRelayTrainSignalId != 0u)
	{
		MyType |= 0x04u;
	}
	if(pRelaySgnl->wRelayZhengXianId != 0u)
	{
		MyType |= 0x08u;
	}
	if(pRelaySgnl->wRelayYinDaoId != 0u)
	{
		MyType |= 0x10u;
	}
	if(pRelaySgnl->wRelayDianDengId != 0u)
	{
		MyType |= 0x20u;
	}
	if(pRelaySgnl->wRelayDiaoCheSignalId != 0u)
	{
		MyType |= 0x40u;
	}

	for(i=0u;i<14u;i++)
	{
		if((MyType==RtnType[i])&&(MyType!=RtnType[5])&&(MyType!=RtnType[2])&&(MyType!=RtnType[8]))
		{
			return MyRtnType[i];
		}
		if(MyType==RtnType[5])
		{
			/*两显示*/
			if (pSgnl->dwSignalDengLie >> 7u == 0x00u)
			{
				return SIGNAL_TYPE_TWO_ALL_NOYINDAO;
			}
			else/*三显示*/
			{
				/*封黄灯*/
				if((pSgnl->sDengWeiFengBi | 0xfbu) == 0xfbu)
				{
					return SIGNAL_TYPE_THREE_NOYELLOW_NOYINDAO;
				}
				else
				{
					return SIGNAL_TYPE_THREE_NOGREEN_NOYINDAO;
				}
			}

		}
		if (MyType==RtnType[2])
		{
			/*封绿灯*/
			if((pSgnl->sDengWeiFengBi | 0xfdu) == 0xfdu)
			{
				return SIGNAL_TYPE_THREE_NOGREEN_YINDAO;
			}
			else
			{
				return SIGNAL_TYPE_THREE_ALL_YINDAO_NOY;
			}
		}
		if (MyType == RtnType[8])
		{
			/*封绿灯*/
			if ((pSgnl->sDengWeiFengBi | 0xfdu) == 0xfdu)
			{
				return SIGNAL_TYPE_3_NOGREEN_YINDAO_NOL;
			}
			else
			{
				return SIGNAL_TYPE_THREE_NOYELLOW_YINDAO;
			}
		}
	}
	return 0u;
}

/*********************************************
*函数功能：从道岔结构体计算道岔继电器结构体
*参数说明：pPoint道岔继电器结构体指针
pSwitchCfgDtStr道岔配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 SwitchCfgDtStruFromDquPointStr(DSU_POINT_STRU* pPoint,SwitchConfigDataStruct* pSwitchCfgDtStr)
{
	UINT16 i=0u;
	UINT16 j=0u;
	UINT8 rtnvalue = 0u;

	/*入口参数防护*/
	if((NULL == pPoint) || (NULL == pSwitchCfgDtStr))
	{
		/*返回失败*/
		return 0u;
	}

	pSwitchCfgDtStr->SwitchId = pPoint->wId;
	pSwitchCfgDtStr->BelongCiId = (UINT8)pPoint->wManagePhysicalCI;
	pSwitchCfgDtStr->BelongVirCI =  (UINT8)pPoint->wBelongVirCI;/*所属虚拟联锁编号*/
	pSwitchCfgDtStr->dwSwitchKilo = pPoint->dwPointKilo; /* 公里标 */
	pSwitchCfgDtStr->chKiloType = pPoint->dwPointKiloPlueMinusSign;
	if (pSwitchCfgDtStr->SwitchId < SWITCH_SUM_MAX)
	{
		pSwitchCfgDtStr->BelongOcId = dquCICfgDtStr.OCSwitchCfgStr[pSwitchCfgDtStr->SwitchId].BelongOcId;
	}
	pSwitchCfgDtStr->DSwitchOtherId = (pPoint->DPointOtherId != 0xffffu)?pPoint->DPointOtherId:0U;
	pSwitchCfgDtStr->SwitchPhySecId = 0xffu;
	pSwitchCfgDtStr->SwitchIsThisLine = DEV_IS_THIS_LINE_YES;
	/*cgh-合并CID-2341-10：*/
	pSwitchCfgDtStr->DsRelayId = 0u;
	pSwitchCfgDtStr->DsQRelayId = 0u;
	pSwitchCfgDtStr->DsHRelayId = 0u;
	pSwitchCfgDtStr->ByPassRelayId = 0u;
	for(j=0u;j<RelayDataLen.RelayPointStrLen;j++)
	{
		if(pPoint->wId==(RelayData.pRelayPointStr+j)->wPointId)
		{
			pSwitchCfgDtStr->DbRelayId = (RelayData.pRelayPointStr+j)->wRelayDingBiaoId;
			pSwitchCfgDtStr->FbRelayId = (RelayData.pRelayPointStr+j)->wRelayFanBiaoId;
			pSwitchCfgDtStr->YcRelayId = (RelayData.pRelayPointStr+j)->wRelayYunCaoId;
			pSwitchCfgDtStr->DcRelayId = (RelayData.pRelayPointStr+j)->wRelayDingCaoId;
			pSwitchCfgDtStr->FcRelayId = (RelayData.pRelayPointStr+j)->wRelayFanCaoId;
			pSwitchCfgDtStr->ZDbRelayId = (RelayData.pRelayPointStr+j)->wRelayZongDingBiaoId;
			pSwitchCfgDtStr->ZFbRelayId = (RelayData.pRelayPointStr+j)->wRelayZongFanBiaoId;
			pSwitchCfgDtStr->DFHRelayId = (RelayData.pRelayPointStr+j)->wDFHId;
			pSwitchCfgDtStr->wShadowDbRelayId = (RelayData.pRelayPointStr + j)->wRelayShadowDingBiaoId;
			pSwitchCfgDtStr->wShadowFbRelayId = (RelayData.pRelayPointStr + j)->wRelayShadowFanBiaoId;
			if (pSwitchCfgDtStr->SwitchId>0u)
			{
				if (0u == pSwitchCfgDtStr->DbRelayId)
				{
					debug_infor_printf((const)"Switch %d DBJ %d not config.",pSwitchCfgDtStr->SwitchId,pSwitchCfgDtStr->DbRelayId);
					DebugPrintAppError(ERROR_SWITCH_DBJ_NOT_CONFIG,CI_DEVICE_TYPE_SWITCH,pSwitchCfgDtStr->SwitchId,PRINT_ONCE);
				}
				if (0u == pSwitchCfgDtStr->FbRelayId)
				{
					debug_infor_printf((const)"Switch %d FBJ %d not config.",pSwitchCfgDtStr->SwitchId,pSwitchCfgDtStr->FbRelayId);
					DebugPrintAppError(ERROR_SWITCH_FBJ_NOT_CONFIG,CI_DEVICE_TYPE_SWITCH,(UINT32)(pSwitchCfgDtStr->SwitchId),PRINT_ONCE);
				}
				if (0u == pSwitchCfgDtStr->YcRelayId)
				{
					debug_infor_printf((const)"Switch %d YCJ %d not config.",pSwitchCfgDtStr->SwitchId,pSwitchCfgDtStr->YcRelayId);
					DebugPrintAppError(ERROR_SWITCH_YCJ_NOT_CONFIG,CI_DEVICE_TYPE_SWITCH,(UINT32)(pSwitchCfgDtStr->SwitchId),PRINT_ONCE);
				}
				if (0u == pSwitchCfgDtStr->DcRelayId)
				{
					debug_infor_printf((const)"Switch %d DCJ %d not config.",pSwitchCfgDtStr->SwitchId,pSwitchCfgDtStr->DcRelayId);
					DebugPrintAppError(ERROR_SWITCH_DCJ_NOT_CONFIG,CI_DEVICE_TYPE_SWITCH,(UINT32)(pSwitchCfgDtStr->SwitchId),PRINT_ONCE);
				}
				if (0u == pSwitchCfgDtStr->FcRelayId)
				{
					debug_infor_printf((const)"Switch %d FCJ %d not config.",pSwitchCfgDtStr->SwitchId,pSwitchCfgDtStr->FcRelayId);
					DebugPrintAppError(ERROR_SWITCH_FCJ_NOT_CONFIG,CI_DEVICE_TYPE_SWITCH,(UINT32)(pSwitchCfgDtStr->SwitchId),PRINT_ONCE);
				}
			}
			break;
		}
	}

	for(i=0u;i<dsuDataLenStru.wAxleSgmtLen;i++)
	{
		for(j=0u;j<(dsuStaticHeadStru.pAxleSgmtStru+i)->wRelatPointNum;j++)
		{
			if(pSwitchCfgDtStr->SwitchId == (dsuStaticHeadStru.pAxleSgmtStru+i)->wRelatPointId[j])
			{
				pSwitchCfgDtStr->SwitchPhySecId = (dsuStaticHeadStru.pAxleSgmtStru+i)->wRelatePhysicalSgmtId;

				/*找到道岔继电器后，直接返回*/
				rtnvalue = 1u;
				return rtnvalue;
			}
		}
	}
	rtnvalue = 0u;
	return rtnvalue;
}

/*********************************************
*函数功能：从联锁表防护道岔与主体道岔关系表计算道岔主体道岔数据
*参数说明：
	pSwitchCfgDtStr道岔配置数据结构体指针
*返回值：0，失败；1，成功
*mod by qw.liu 2022-02-28 增加道岔对应防护道岔映射关系
*********************************************/
UINT8 SwitchCfgDtStruFromLSProHostStr(SwitchConfigDataStruct* pSwitchCfgDtStr)
{
	UINT16 i=0u;
	UINT16 j=0u;
	UINT8 rtnvalue = 0u;

	if (NULL == pSwitchCfgDtStr)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}
	if (1u == rtnvalue)
	{
		pSwitchCfgDtStr->HostSwitchNum = 0u;
		for (i=0u;i<SWITCH_HOST_SWITCH_MAX_NUM;i++)
		{
			pSwitchCfgDtStr->HostSwitchIdBuf[i] = 0u;
		}

		pSwitchCfgDtStr->wProtectSwitchNum = 0u;
		for (i = 0u; i<SWITCH_PROTECT_SWITCH_MAX_NUM; i++)
		{
			pSwitchCfgDtStr->wszProtectSwitchIdBuf[i] = 0u;
		}
		for (i=0u;i<LSDataLen.LS_ProSwitchHostSwitchMapStruLen;i++)
		{/*找到防护道岔ID为此道岔ID的数据，赋值*/
			if (pSwitchCfgDtStr->SwitchId == LSData.pLSProSwitchHostSwitchMapStru[i].wProSwitchID)
			{
				for (j=0u;j<SWITCH_HOST_SWITCH_MAX_NUM;j++)
				{
					if ((LSData.pLSProSwitchHostSwitchMapStru[i].wHostSwitchIDBuf[j] != 0u)&&
						(LSData.pLSProSwitchHostSwitchMapStru[i].wHostSwitchIDBuf[j] != 0xffffu))
					{
						pSwitchCfgDtStr->HostSwitchIdBuf[pSwitchCfgDtStr->HostSwitchNum] = LSData.pLSProSwitchHostSwitchMapStru[i].wHostSwitchIDBuf[j];
						pSwitchCfgDtStr->HostSwitchNum++;
					}
				}
				break;
			}
			
		}


		for (i = 0u; i < LSDataLen.LS_ProSwitchHostSwitchMapStruLen; i++)
		{	
			/*找到防护道岔的主体道岔为此道岔ID的数据，赋值*/
			for (j = 0u; j < SWITCH_HOST_SWITCH_MAX_NUM; j++)
			{
				if ((LSData.pLSProSwitchHostSwitchMapStru[i].wHostSwitchIDBuf[j] == pSwitchCfgDtStr->SwitchId))
				{
					if ((0U != LSData.pLSProSwitchHostSwitchMapStru[i].wProSwitchID) &&
						(0xffffU != LSData.pLSProSwitchHostSwitchMapStru[i].wProSwitchID))
					{
						pSwitchCfgDtStr->wszProtectSwitchIdBuf[pSwitchCfgDtStr->wProtectSwitchNum] = LSData.pLSProSwitchHostSwitchMapStru[i].wProSwitchID;
						pSwitchCfgDtStr->wProtectSwitchNum++;
					}

					break;
				}
				else
				{
					/*主机道岔中无该道岔，继续执行*/
				}
			}
		}
	}
	
	return rtnvalue;
}
/*
*函数功能：道岔关联的逻辑区段
*参数说明：pSwitchStr 电子地图道岔结构体指针
*          pSwitchCfgDtStr 道岔对外配置结构体指针
*返回值：0，失败；1，成功
*/
UINT8 SwitchCfgLogTrackInitDquStr(DSU_POINT_STRU* pSwitchStr,SwitchConfigDataStruct* pSwitchCfgDtStr)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 rtnvalue = CI_ERROR;
	DSU_LOGIC_SGMT_STRU* pDsuLogStr = NULL;
	UINT8 k = 0u;
	UINT8 keepWork = CI_ERROR;


	/*非空*/
	if(NULL != pSwitchCfgDtStr)
	{
		rtnvalue = CI_SUCCESS;
		keepWork = CI_SUCCESS;
		/*初始化为0*/
		pSwitchCfgDtStr->SwitchLogSecSum = 0u;
		for(i = 0u; i < SWITCH_LOG_TRACK_MAX_NUM; i++)
		{
			pSwitchCfgDtStr->SwitchLogSecIdBuf[i] = 0u;
		}

		/*遍历逻辑区段，查找逻辑区段关联的道岔，形成道岔到逻辑区段的映射。*/
		for (j = 0u; j < dsuDataLenStru.wLogicSgmtLen; j++)
		{
			pDsuLogStr = dsuStaticHeadStru.pLogicSgmtStru + j;
			for (k = 0u; k < pDsuLogStr->chSwitchNum; k++)
			{
				if (SWITCH_LOG_TRACK_MAX_NUM > pSwitchCfgDtStr->SwitchLogSecSum)
				{
					if (pDsuLogStr->wSwitchId[k] == pSwitchCfgDtStr->SwitchId)
					{
						pSwitchCfgDtStr->SwitchLogSecIdBuf[pSwitchCfgDtStr->SwitchLogSecSum++] = pDsuLogStr->wId;
					}
					else
					{
						/*不做处理*/
					}
				}
				else
				{
					keepWork = CI_ERROR;
				}
			}

			if (CI_SUCCESS != keepWork)
			{
				rtnvalue = CI_ERROR;
				break;
			}
			else
			{

			}

		}
	}
	else
	{
		rtnvalue = CI_ERROR;
	}
	return(rtnvalue);
}

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


/*********************************************
*函数功能：从物理区段结构体计算物理区段继电器结构体
*参数说明：pPhysicalSgmt物理区段结构体指针
pPsclSgmtCfgDtStr物理区段配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 PhySgmtCfgDtStruFromDquSgmtStr(DSU_PHYSICAL_SGMT_STRU* pPhysicalSgmt, PhysicalSectionConfigDataStruct* pPsclSgmtCfgDtStr, SignalConfigDataStruct* pSgnlCfgDtStr)
{
	UINT16 ii = 0u;
	UINT16 j = 0u;
	UINT16 axleSgmtManageZC = 0u;/*局部变量*/
	UINT8 rtnvalue = 0u;
	UINT16 k = 0u;
	UINT8 acFty = GetCiFunctionSwitchConfig(FUNC_SWITCH_AC_FACTORY);
	UINT16 wLogIndex = 0U;
	UINT8 logsecSum = 0U;
	UINT8 isEachInvFlag = 0U;
	/*入口参数防护*/
	if ((NULL != pPhysicalSgmt) && (NULL != pPsclSgmtCfgDtStr) && (NULL != pSgnlCfgDtStr))
	{
		pPsclSgmtCfgDtStr->PhysicalSectionId = pPhysicalSgmt->wId;
		if (PHYSICAL_SECTION_SUM_MAX > pPsclSgmtCfgDtStr->PhysicalSectionId)
		{
			pPsclSgmtCfgDtStr->BelongOcId = dquCICfgDtStr.OCPhySecCfgStr[pPsclSgmtCfgDtStr->PhysicalSectionId].BelongOcId;
		}
		else
		{
		}
		pPsclSgmtCfgDtStr->PhySecType = pPhysicalSgmt->Type;
		pPsclSgmtCfgDtStr->LjkSecFlag = pPhysicalSgmt->LjkFlag;
		pPsclSgmtCfgDtStr->QcxSecFlag = pPhysicalSgmt->QcxFlag;
		pPsclSgmtCfgDtStr->BelongAxleSysID = pPhysicalSgmt->BelongAxleSysID;
		pPsclSgmtCfgDtStr->AxisSectionSum = 0u;
		pPsclSgmtCfgDtStr->LocatedFloodGateSum = 0U;		/*所在防淹门数量初始化为0*/
		for (j = 0U; j < FLOOD_GATE_SUM_MAX; j++)
		{
			pPsclSgmtCfgDtStr->LocatedFloodGateId[j] = 0U;	/*所在防淹门id初始化为0*/
		}
		pPsclSgmtCfgDtStr->PhyIsThisLine = DEV_IS_THIS_LINE_YES; /*初始化本线路*/
		/*所属联锁ID和是否属于ZC管辖从对应计轴区段中获得*/
		for (j = 0u; j < dsuDataLenStru.wAxleSgmtLen; j++)
		{
			if (pPhysicalSgmt->wId == (dsuStaticHeadStru.pAxleSgmtStru + j)->wRelatePhysicalSgmtId)
			{
				pPsclSgmtCfgDtStr->BelongCiId = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru + j)->wManagePhysicalCI;
				pPsclSgmtCfgDtStr->BelongVirCI = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru + j)->BelongVirCI;
				axleSgmtManageZC = (dsuStaticHeadStru.pAxleSgmtStru + j)->wManageZC;/*计轴区段所属ZC区域*/
				if ((0u != axleSgmtManageZC) && (UINT16_MAX != axleSgmtManageZC))
				{/*若计轴区段所属ZC区域有效，则物理区段属于ZC管辖区域*/
					pPsclSgmtCfgDtStr->managedByZcFlag = PHY_SEC_MANAGED_BY_ZC_YES;
				}
				else
				{/*若计轴区段所属ZC区域无效，则物理区段不属于ZC管辖区域*/
					pPsclSgmtCfgDtStr->managedByZcFlag = PHY_SEC_MANAGED_BY_ZC_NO;
				}
				break;
			}
			else
			{
			}
		}
		for (j = 0u; j < dsuDataLenStru.wAxleSgmtLen; j++)
		{
			if (pPhysicalSgmt->wId == (dsuStaticHeadStru.pAxleSgmtStru + j)->wRelatePhysicalSgmtId)
			{
				pPsclSgmtCfgDtStr->AxisSectionIdBuf[pPsclSgmtCfgDtStr->AxisSectionSum++] = (dsuStaticHeadStru.pAxleSgmtStru + j)->wId;

			}
			else
			{
			}
		}
		if ((0u < dquCICfgDtStr.OCPhySecCfgStrLen) || (AXIS_TYPE_YONGLIE == acFty) || (AXIS_TYPE_KEANDA == acFty) || (AXIS_TYPE_FUHAOSHENG == acFty))
		{
			rtnvalue = 1u;
			/*全电子联锁增加计轴总复位*/
			for (j = 0u; j < RelayDataLen.RelayPhysicalSgmtStrLen; j++)
			{
				if (pPhysicalSgmt->wId == (RelayData.pRelayPhysicalSgmtStr + j)->wPhysicalId)
				{
					pPsclSgmtCfgDtStr->ZFWRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayAxleZongRetrunId;
					pPsclSgmtCfgDtStr->ZFWShowRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRepRelayZongResetShowId;
					break;
				}
				else
				{
				}
			}
		}
		else
		{
			for (j = 0u; j < RelayDataLen.RelayPhysicalSgmtStrLen; j++)
			{
				if (pPhysicalSgmt->wId == (RelayData.pRelayPhysicalSgmtStr + j)->wPhysicalId)
				{
					pPsclSgmtCfgDtStr->FWRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayAxleRetrunId;
					pPsclSgmtCfgDtStr->GdRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayRailwayId;
					pPsclSgmtCfgDtStr->wGdRelayId2 = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayRailwayId2;
					pPsclSgmtCfgDtStr->ZFWRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayAxleZongRetrunId;
					pPsclSgmtCfgDtStr->PreResetRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayAxlePreResetId;
					pPsclSgmtCfgDtStr->RepGdRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRepRelayTrainId;/*复视轨道继电器*/
					pPsclSgmtCfgDtStr->ZFWShowRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRepRelayZongResetShowId;
					if (0u == pPsclSgmtCfgDtStr->GdRelayId)
					{
						debug_infor_printf((const)"Phy %d GJ %d not config.", pPsclSgmtCfgDtStr->PhysicalSectionId, pPsclSgmtCfgDtStr->GdRelayId);
						DebugPrintAppError(ERROR_PHYSEC_GJ_NOT_CONFIG, CI_DEVICE_TYPE_PHYSEC, (UINT32)(pPsclSgmtCfgDtStr->PhysicalSectionId), PRINT_ONCE);
					}
					else
					{
						for (k = 0u; k < RelayDataLen.RelayCfgDtStrLen; k++)/* RelayData.pRelayCfgDtStr)*/
						{
							if (RelayData.pRelayCfgDtStr[k].RelayId == pPsclSgmtCfgDtStr->GdRelayId)
							{
								if (RelayData.pRelayCfgDtStr[k].CollMode != RELAY_COLL_MODE_DOUBLE)
								{
									debug_infor_printf((const)"Phy %d GJ %d not double coll-mode.", pPsclSgmtCfgDtStr->PhysicalSectionId, pPsclSgmtCfgDtStr->GdRelayId);
									DebugPrintAppError(ERROR_PHYSEC_GJ_NOT_DOUBLE_COLL, CI_DEVICE_TYPE_PHYSEC, (((UINT32)pPsclSgmtCfgDtStr->PhysicalSectionId << 16u) + pPsclSgmtCfgDtStr->GdRelayId), PRINT_ONCE);
								}
								else
								{
								}
								break;
							}
							else
							{
							}

						}

					}

					/*找到相应的物理区段后，直接返回*/
					rtnvalue = 1u;
					break;
				}
				else
				{
				}
			}
		}
	}
	else
	{
	}

	if (1u == rtnvalue)
	{
		/* 物理区段关联出站信号机 */
		pPsclSgmtCfgDtStr->relateOutStationSignalNum = 0u;
		/* 从信号机表格中查找对应的信号机外方第一物理区段ID */
		for (j = 0u; j < dsuDataLenStru.wSignalLen; j++)
		{

			if (pPsclSgmtCfgDtStr->PhysicalSectionId == pSgnlCfgDtStr[j].OutFirstPhySecId)
			{/* 判断当前信号机的外方第一物理区段是否等于本物理区段 */
				pPsclSgmtCfgDtStr->relateOutStationSignalIdBuff[pPsclSgmtCfgDtStr->relateOutStationSignalNum] = pSgnlCfgDtStr[j].SignalId;
				pPsclSgmtCfgDtStr->relateOutStationSignalNum++;
			}
			else
			{
			}
		}
	}
	else
	{
	}
	if (1u == rtnvalue)
	{
		pPsclSgmtCfgDtStr->trackSecNum = 0u;/*初始化编号对照表时，根据编号对照表中轨道区段表进行初始化*/
		for (j = 0u; j < PHY_SEC_TRACK_SEC_MAX_SUM; j++)
		{
			pPsclSgmtCfgDtStr->trackSecBuf[j] = 0u;
		}
	}
	else
	{
	}

	if (1U == rtnvalue)
	{
		/**根据逻辑区段初始化数据，建立物理区段到逻辑区段的映射*/
		pPsclSgmtCfgDtStr->LogSectionSum = 0U;
		for (wLogIndex = 0u; wLogIndex < dsuDataLenStru.wLogicSgmtLen; wLogIndex++)
		{
			if (pPsclSgmtCfgDtStr->PhysicalSectionId == dsuStaticHeadStru.pLogicSgmtStru[wLogIndex].wRelatPhySecId)
			{
				logsecSum = pPsclSgmtCfgDtStr->LogSectionSum;
				pPsclSgmtCfgDtStr->LogSectionIdBuf[logsecSum] = dsuStaticHeadStru.pLogicSgmtStru[wLogIndex].wId;
				pPsclSgmtCfgDtStr->LogSectionSum++;
			}
			else
			{

			}
		}
	}
	else
	{

	}

	if (1u == rtnvalue)
	{  /*物理区段的侵限区段及条件道岔*/
		isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION);
		/*采用旧版侵限数据表读取*/
		if (FUNC_SWITCH_OFF == isEachInvFlag)
		{
			/*物理区段的侵限区段及条件道岔*/
			pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum = 0u;
			for (ii = 0u; ii < LSDataLen.LS_PhySectionIntrudeStruLen; ii++)
			{   /*遍历物理区段的侵限区段及条件道岔表*/
				if (LSData.pLSPhyIntruPhySecStru[ii].physicalId == pPsclSgmtCfgDtStr->PhysicalSectionId)
				{
					for (j = 0u; j < SEC_INVASECT_N_CONDSWIT_SUM_MAX; j++)
					{
						if (0u != LSData.pLSPhyIntruPhySecStru[ii].phyInvSecAndConSwiId[j])
						{
							pPsclSgmtCfgDtStr->SecInvSecAndConSwiId[pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum] = LSData.pLSPhyIntruPhySecStru[ii].phyInvSecAndConSwiId[j];
							pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum++;
						}
						else
						{
							;
						}

					}
				}
				else
				{
					;
				}
			}
		}
		/*采用逻辑区段互相侵限条件转化*/
		else
		{
			pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum = 0u;

			/*遍历侵限区段及条件道岔表*/
			for (j = 0u; j < LSDataLen.LSIntruPhySecStrLen; j++)
			{
				if ((LSData.pLSIntruPhySecStr[j].belongPhySecId == pPsclSgmtCfgDtStr->PhysicalSectionId) && (0U != LSData.pLSIntruPhySecStr[j].belongPhySecId))
				{
					if (SEC_INVASECT_N_CONDSWIT_SUM_MAX > pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum)
					{
						pPsclSgmtCfgDtStr->SecInvSecAndConSwiId[pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum] = LSData.pLSIntruPhySecStr[j].wId;
						pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum++;
					}
					else
					{
						/*逻辑区段侵限数量超出范围，初始化失败*/
						rtnvalue = 0U;
						debug_infor_printf((const)"[PhySecInv]PhySecID:%d ERROR: SecInvSecAndConSwiSum Is Exceed MAX\n", pPsclSgmtCfgDtStr->PhysicalSectionId);
						break;
					}
				}
				else
				{
					;
				}
			}

		}

		/*在日志中打印物理区段侵限关系*/
		if ((0U < pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum) && (1U == rtnvalue))
		{
			for (ii = 0U; ii < pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum; ii++)
			{
				debug_infor_printf((const)"[PhySecInv] PhySecID:%d, InvDataID:%d\n", pPsclSgmtCfgDtStr->PhysicalSectionId, pPsclSgmtCfgDtStr->SecInvSecAndConSwiId[ii]);
			}
		}
		else
		{
			;
		}
	}
	else
	{
		;
	}

	return rtnvalue;
}


/*********************************************
*函数功能：计轴区段配置数据结构体计算
*参数说明：pAxleSgmt计轴区段结构体指针
pAxScCfgDtStr计轴区段配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 AxisSecCfgDtStruFromDquSgmtStr(DSU_AXLE_SGMT_STRU* pAxleSgmt, AxisSectionConfigDataStruct* pAxScCfgDtStr)
{
	UINT16 j = 0u;
	UINT8 rtnvalue = 0u;
	UINT8 cDir = EMAP_SAME_DIR;
	LOD_STRU LODAPointStru = { 0u };
	LOD_STRU LODBPointStru = { 0u };
	UINT16 wlinkNum = 0u;
	UINT16 szLinkIdBuf[100u] = { 0u };
	UINT32 dwLen = UINT32_MAX;
	DSU_LINK_STRU* pAcIncLinkStru = NULL;  /*计轴区段包含的link结构体*/
	UINT8 kk = 0U;

	/*入口参数防护*/
	if ((NULL == pAxleSgmt) || (NULL == pAxScCfgDtStr))
	{
		/*返回失败*/
		return 0u;
	}

	/*直接从计轴区段表中获取*/
	pAxScCfgDtStr->AxisSectionId = pAxleSgmt->wId;
	pAxScCfgDtStr->RelativePhySecId = pAxleSgmt->wRelatePhysicalSgmtId;
	pAxScCfgDtStr->LogSectionSum = (UINT8)pAxleSgmt->wIncludeLogicSgmtNum;
	pAxScCfgDtStr->AxisSwitchSum = (UINT8)pAxleSgmt->wRelatPointNum;
	pAxScCfgDtStr->wOrgnAxisId = pAxleSgmt->wOrgnAxleId;
	pAxScCfgDtStr->wTmnlAxisId = pAxleSgmt->wTmnlAxleId;
	pAxScCfgDtStr->dwAxisTotalLen = 0U;

	for (j = 0u; j < AXIS_INCLUDE_LOG_SUM_MAX; j++)
	{
		pAxScCfgDtStr->LogSectionIdBuf[j] = (pAxleSgmt->wLogicSgmtId[j] != 0xffffu ? pAxleSgmt->wLogicSgmtId[j] : 0U);
	}
	for (j = 0u; j < pAxScCfgDtStr->AxisSwitchSum; j++)
	{  /*获取计轴区段关联的道岔信息*/
		pAxScCfgDtStr->AxisSwitchIdStru[j].SwitchId = pAxleSgmt->wRelatPointId[j];
		pAxScCfgDtStr->AxisSwitchIdStru[j].SwitchPosition = (UINT8)pAxleSgmt->wRelatPointStatus[j];
	}

	if (pAxleSgmt->wOrgnLkId == pAxleSgmt->wTmnlLkId)
	{
		pAxScCfgDtStr->chLinkNum = 1u;
		pAxScCfgDtStr->szLinkIdBuff[0u] = pAxleSgmt->wOrgnLkId;
		pAxScCfgDtStr->dwAxisTotalLen += pAxleSgmt->dwTmnlLinkOfst;
	}
	else
	{
		LODAPointStru.Lnk = pAxleSgmt->wOrgnLkId;
		LODAPointStru.Off = 0U;
		LODAPointStru.Dir = EMAP_SAME_DIR;
		LODBPointStru.Lnk = pAxleSgmt->wTmnlLkId;
		LODBPointStru.Off = pAxleSgmt->dwTmnlLinkOfst;
		LODBPointStru.Dir = EMAP_SAME_DIR;
		dwLen = dsuLenByPoint(&LODAPointStru, &LODBPointStru, &wlinkNum, szLinkIdBuf, &cDir);

		if ((UINT32_MAX != dwLen) && (AXIS_INCLUDE_LINK_SUM_MAX >= wlinkNum))
		{
			pAxScCfgDtStr->chLinkNum = (UINT8)wlinkNum;
			for (j = 0U; j < wlinkNum; j++)
			{
				pAxScCfgDtStr->szLinkIdBuff[j] = szLinkIdBuf[j];
			}
		}
		pAxScCfgDtStr->dwAxisTotalLen = dwLen;
	}

	pAxScCfgDtStr->cAcCbtcAttr = AXIS_SEC_CBTC_PROPERTY_NO;  /*初始化计轴区段不具有CBTC区域属性*/
	
	/*遍历计轴区段包含的link，确定计轴区段的CBTC区域属性*/
	for (kk = 0U; kk < pAxScCfgDtStr->chLinkNum; kk++)
	{
		pAcIncLinkStru = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pAxScCfgDtStr->szLinkIdBuff[kk]];
		if (0x55U != pAcIncLinkStru->cCbtcProperty)
		{
			break;  /*link不具有CBTC区域属性，停止遍历*/
		}
		else
		{
			/*link具有CBTC区域属性，继续遍历*/
		}
	}

	if ((kk == pAxScCfgDtStr->chLinkNum) && (0U != kk))
	{
		pAxScCfgDtStr->cAcCbtcAttr = AXIS_SEC_CBTC_PROPERTY_YES;  /*所有link均具有CBTC区域属性，则计轴区段具有CBTC区域属性*/
	}
	else
	{
		/*存在link不具有CBTC区域属性，则计轴区段不具有CBTC区域属性*/
	}

	/*数据配置原则，若计轴为临线的计轴，则计轴包含的所有link必将是临线的，所以只需要取其中一个link校验临线属性即可*/

	if (LINK_LINXIAN_YES == dsuStaticHeadStru.pLinkStru[dsuLinkIndex[pAxScCfgDtStr->szLinkIdBuff[0u]]].wLinxian)
	{
		pAxScCfgDtStr->chAxisLinXian = AXIS_SEC_LINXIAN_YES;
	}
	else
	{
		pAxScCfgDtStr->chAxisLinXian = AXIS_SEC_LINXIAN_NO;
	}

	rtnvalue = 1u;
	return rtnvalue;
}

/*********************************************
*函数功能：逻辑区段配置数据结构体计算
*参数说明：pLogicSgmt逻辑区段结构体指针
pLgScCfgDtStr逻辑区段配置数据结构体指针
*返回值：0，失败；1，成功
*modify 20220921 TIOC5.0
*********************************************/
UINT8 LogicSecCfgDtStruFromDquSgmtStr(DSU_LOGIC_SGMT_STRU* pLogicSgmt,LogicSectionConfigDataStruct* pLgScCfgDtStr)
{
	UINT8 rtnvalue = 0u;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT8 cDir = EMAP_SAME_DIR;
	LOD_STRU LODAPointStru = { 0u };
	LOD_STRU LODBPointStru = { 0u };
	UINT16 wlinkNum = 0u;
	UINT16 szLinkIdBuf[100u] = { 0u };
	UINT32 dwLen = UINT32_MAX;
	UINT8 kk = 0u;
	UINT8 hh = 0u;
	UINT8 chLogSecLastLogSecSum = 0U;/*起点关联逻辑区段数量计数*/
	UINT8 chLogSecNextLogSecSum = 0U;/*终点关联逻辑区段数量计数*/
	UINT8 chForeachEndFlag = 0U;/*起终点关联逻辑区段查找完成标志*/
	DSU_LINK_STRU* pLogSecIncLinkStru = NULL;  /*逻辑区段包含的link结构体*/
	UINT8 isEachInvFlag = 0U;
	UINT16 wSignalAttribute = 0U;


	/*入口参数防护*/
	if ((NULL != pLogicSgmt) && (NULL != pLgScCfgDtStr))
	{
		rtnvalue = 1u;
		pLgScCfgDtStr->LogicSectionId = pLogicSgmt->wId;
		pLgScCfgDtStr->belongCiId = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pLogicSgmt->wAxleSgmtId[0]]].wManagePhysicalCI);
		pLgScCfgDtStr->belongVirCI = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pLogicSgmt->wAxleSgmtId[0]]].BelongVirCI);
		pLgScCfgDtStr->chRelativeAxleSum = pLogicSgmt->chAxleSgmtSum;
		for (kk = 0u; kk < pLogicSgmt->chAxleSgmtSum; kk++)
		{
			pLgScCfgDtStr->wRelativeAxleSecId[kk] = pLogicSgmt->wAxleSgmtId[kk];
		}

		pLgScCfgDtStr->wRelativePhySecId = pLogicSgmt->wRelatPhySecId;
		pLgScCfgDtStr->wOrgnLink = pLogicSgmt->wOrgnLkId;
		pLgScCfgDtStr->dwOrgnOffset = pLogicSgmt->dwOrgnLkOfst;
		pLgScCfgDtStr->wTmnlLink = pLogicSgmt->wTmnlLkId;
		pLgScCfgDtStr->dwTmnlOffset = pLogicSgmt->dwTmnlLkOfst;
		pLgScCfgDtStr->chLogsecSwitchSum = pLogicSgmt->chSwitchNum;
		for (hh = 0u; hh < pLogicSgmt->chSwitchNum; hh++)
		{
			pLgScCfgDtStr->LogsecSwitchIdStru[hh].SwitchId = pLogicSgmt->wSwitchId[hh];
			pLgScCfgDtStr->LogsecSwitchIdStru[hh].SwitchPosition = pLogicSgmt->chSwitchPosition[hh];
		}

		

		/* 计算逻辑区段保护的link */
		if (pLogicSgmt->wOrgnLkId == pLogicSgmt->wTmnlLkId)
		{
			pLgScCfgDtStr->chLinkNum = 1u;
			pLgScCfgDtStr->szLinkIdBuff[0u] = pLogicSgmt->wOrgnLkId;
		}
		else
		{
			LODAPointStru.Lnk = pLogicSgmt->wOrgnLkId;
			LODAPointStru.Off = 0u;
			LODAPointStru.Dir = EMAP_SAME_DIR;
			LODBPointStru.Lnk = pLogicSgmt->wTmnlLkId;
			LODBPointStru.Off = 0u;
			LODBPointStru.Dir = EMAP_SAME_DIR;
			dwLen = dsuLenByPoint(&LODAPointStru, &LODBPointStru, &wlinkNum, szLinkIdBuf, &cDir);

			if ((UINT32_MAX != dwLen) && (AXIS_INCLUDE_LINK_SUM_MAX >= wlinkNum))
			{
				pLgScCfgDtStr->chLinkNum = (UINT8)wlinkNum;

				for (ii = 0u; ii < wlinkNum; ii++)
				{
					pLgScCfgDtStr->szLinkIdBuff[ii] = szLinkIdBuf[ii];
				}
			}
		}

		pLgScCfgDtStr->cCbtcProperty = LOGSEC_CBTC_PROPERTY_NO;  /*初始化逻辑区段不具有CBTC区域属性*/
		/*遍历逻辑区段包含的link，确定逻辑区段的CBTC区域属性*/
		for (kk = 0U; kk < pLgScCfgDtStr->chLinkNum; kk++)
		{
			pLogSecIncLinkStru = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pLgScCfgDtStr->szLinkIdBuff[kk]];
			if (0x55U != pLogSecIncLinkStru->cCbtcProperty)
			{
				break;  /*link不具有CBTC区域属性，停止遍历*/
			}
			else
			{
				/*link具有CBTC区域属性，继续遍历*/
			}
		}

		if ((kk == pLgScCfgDtStr->chLinkNum) && (0U != kk))
		{
			pLgScCfgDtStr->cCbtcProperty = LOGSEC_CBTC_PROPERTY_YES;  /*所有link均具有CBTC区域属性，则逻辑区段具有CBTC区域属性*/
		}
		else
		{
			/*存在link不具有CBTC区域属性，则逻辑区段不具有CBTC区域属性*/
		}

		pLgScCfgDtStr->chLogLtrlDfncSwitchSum = 0u;
		for (ii = 0u; ii < LSDataLen.LSLgcSecLtrlDfncStruLen; ii++)
		{   /*遍历逻辑区段的侧防道岔表*/
			if (LSData.pLSLgcLrtlDfncStru[ii].wLogSecId == pLgScCfgDtStr->LogicSectionId)
			{
				for (jj = 0u; jj < LOGSEC_LTRL_DFNC_SUM_MAX; jj++)
				{
					if (0u != LSData.pLSLgcLrtlDfncStru[ii].stLrtlDfncSwitch[jj].wPointId)
					{
						pLgScCfgDtStr->LogLtrlDfncSwitchStru[pLgScCfgDtStr->chLogLtrlDfncSwitchSum].SwitchId = LSData.pLSLgcLrtlDfncStru[ii].stLrtlDfncSwitch[jj].wPointId;
						pLgScCfgDtStr->LogLtrlDfncSwitchStru[pLgScCfgDtStr->chLogLtrlDfncSwitchSum].SwitchPosition = (UINT8)LSData.pLSLgcLrtlDfncStru[ii].stLrtlDfncSwitch[jj].wPointSta;

						if (LSData.pLSLgcLrtlDfncStru[ii].szProtectLockDir[jj] == dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown)
						{
							pLgScCfgDtStr->szLgcDfncLockDir[pLgScCfgDtStr->chLogLtrlDfncSwitchSum] = CI_SYSTEM_DIRECTION_DOWN;
						}
						else
						{
							pLgScCfgDtStr->szLgcDfncLockDir[pLgScCfgDtStr->chLogLtrlDfncSwitchSum] = CI_SYSTEM_DIRECTION_UP;
						}
						pLgScCfgDtStr->chLogLtrlDfncSwitchSum++;
					}

				}

				break;
			}
		}

		/*将联锁表中的联络线条件检查数据读入pLgScCfgDtStr 结构体中*/
		pLgScCfgDtStr->chContactLineCheckSum = 0u;
		for (ii = 0u; ii < LSDataLen.LSContactStruLen; ii++)
		{
			/*遍历逻辑区段关联联络线设备检查条件表*/
			if (LSData.pLSContactLineStr[ii].wId == pLgScCfgDtStr->LogicSectionId)
			{
				for (jj = 0u; jj < PHY_SEC_CONTACT_CHECK_MAX_NUM; jj++)
				{
					if ((0U != LSData.pLSContactLineStr[ii].wPointId[jj])||(0U != LSData.pLSContactLineStr[ii].wAxisSecId[jj]))
					{
						if (0U != LSData.pLSContactLineStr[ii].wPointId[jj])
						{
							pLgScCfgDtStr->LogContactSwitchCheckStru[pLgScCfgDtStr->chContactLineCheckSum].ContactSwitchId = LSData.pLSContactLineStr[ii].wPointId[jj];
							pLgScCfgDtStr->LogContactSwitchCheckStru[pLgScCfgDtStr->chContactLineCheckSum].ContactSwitchCheckState = LSData.pLSContactLineStr[ii].wPointSta[jj];
						}

						if (0U != LSData.pLSContactLineStr[ii].wAxisSecId[jj])
						{
							pLgScCfgDtStr->chContactAxisCheckID[pLgScCfgDtStr->chContactLineCheckSum] = LSData.pLSContactLineStr[ii].wAxisSecId[jj];
						}
						pLgScCfgDtStr->chContactLineCheckSum++;
					}
				}

				break;
			}
		}

#if 0
		if ((0 != pLgScCfgDtStr->chLogLtrlDfncSwitchSum) && (0 != pLgScCfgDtStr->chSecInvSecAndConSwiSum))
		{
			/*TODO 找到侵限条件道岔在侧防里的道岔，将侵限方向赋值为相反的方向*/
			for (ii = 0U; ii < pLgScCfgDtStr->chSecInvSecAndConSwiSum; ii++)
			{
				for (jj = 0U; jj < LSDataLen.LSIntruPhySecStrLen; jj++)
				{
					if (pLgScCfgDtStr->wszSecInvSecAndConSwiId[ii] == LSData.pLSIntruPhySecStr[jj].wId)
					{
						for (kk = 0U; kk < QXQD_MAX_INCLUDE_POINT_NUM; kk++)
						{
							if ((0U != LSData.pLSIntruPhySecStr[jj].wPointId[kk])
								&& (0xFFFFU != LSData.pLSIntruPhySecStr[jj].wPointId[kk]))
							{
								for (hh = 0U; hh < pLgScCfgDtStr->chLogLtrlDfncSwitchSum; hh++)
								{
									if (pLgScCfgDtStr->LogLtrlDfncSwitchStru[hh].SwitchId == LSData.pLSIntruPhySecStr[jj].wPointId[kk])
									{
										pLgScCfgDtStr->chSecInvSecLockDir[ii] = ~pLgScCfgDtStr->szLgcDfncLockDir[hh];
									}
									else
									{
										;
									}
								}
							}
							else
							{
								break;
							}
						}

						break;
					}
					else
					{
						; /*不处理*/
					}
				}
			}
		}
		else
		{
			; /*如果不是同时存在，就不处理该场景*/
		}
#endif
		isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION);

		/*采用旧版本逻辑区段侵限条件*/
		if (FUNC_SWITCH_OFF == isEachInvFlag)
		{
			/*计算逻辑区段侵限数据*/
			pLgScCfgDtStr->chSecInvSecAndConSwiSum = 0u;
			for (ii = 0u; ii < LSDataLen.LSLgcSecIntruStruLen; ii++)
			{   /*遍历物理区段的侵限区段及条件道岔表*/
				if (LSData.pLSLgcIntruSecStru[ii].wLogSecId == pLgScCfgDtStr->LogicSectionId)
				{
					for (jj = 0u; jj < LOGSEC_INV_N_CONDSWIT_SUM_MAX; jj++)
					{
						if (0u != LSData.pLSLgcIntruSecStru[ii].wszLogicInvSecAndConSwiId[jj])
						{
							pLgScCfgDtStr->wszSecInvSecAndConSwiId[pLgScCfgDtStr->chSecInvSecAndConSwiSum] = LSData.pLSLgcIntruSecStru[ii].wszLogicInvSecAndConSwiId[jj];
							pLgScCfgDtStr->chSecInvSecAndConSwiSum++;

						}
						else
						{
						}

					}
					break;
				}
				else
				{
					;
				}
			}
			/*逻辑区段侵限区段的方向从侵限区段及条件道岔表的条件方向中获取*/
			for (ii = 0U; ii < pLgScCfgDtStr->chSecInvSecAndConSwiSum; ii++)
			{
				for (jj = 0U; jj < LSDataLen.LSIntruPhySecStrLen; jj++)
				{
					if (pLgScCfgDtStr->wszSecInvSecAndConSwiId[ii] == LSData.pLSIntruPhySecStr[jj].wId)
					{
						if (0XFFU == LSData.pLSIntruPhySecStr[jj].wCondSwitLockDir)
						{
							pLgScCfgDtStr->chSecInvSecLockDir[ii] = CI_SYSTEM_DIRECTION_NONE;
						}
						else
						{
							if (dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown == LSData.pLSIntruPhySecStr[jj].wCondSwitLockDir)
							{
								pLgScCfgDtStr->chSecInvSecLockDir[ii] = CI_SYSTEM_DIRECTION_DOWN;
							}
							else
							{
								pLgScCfgDtStr->chSecInvSecLockDir[ii] = CI_SYSTEM_DIRECTION_UP;
							}
						}
					}
				}
			}

		}
		/*采用新版本逻辑区段互相侵限条件*/
		else
		{
			/*计算逻辑区段侵限数据*/
			pLgScCfgDtStr->chSecInvSecAndConSwiSum = 0u;
			for (ii = 0u; ii < LSDataLen.LSIntruPhySecStrLen; ii++)
			{   /*遍历侵限区段及条件道岔表数据表*/

				/*查找符合所属逻辑区段ID的逻辑区段*/
				if ((LSData.pLSIntruPhySecStr[ii].belongLogSecId == pLgScCfgDtStr->LogicSectionId) && (0U != LSData.pLSIntruPhySecStr[ii].belongLogSecId))
				{
					if (LOGSEC_INV_N_CONDSWIT_SUM_MAX > pLgScCfgDtStr->chSecInvSecAndConSwiSum)
					{
						pLgScCfgDtStr->wszSecInvSecAndConSwiId[pLgScCfgDtStr->chSecInvSecAndConSwiSum] = LSData.pLSIntruPhySecStr[ii].wId;

						if (0XFFU == LSData.pLSIntruPhySecStr[ii].wCondSwitLockDir)
						{
							pLgScCfgDtStr->chSecInvSecLockDir[pLgScCfgDtStr->chSecInvSecAndConSwiSum] = CI_SYSTEM_DIRECTION_NONE;
						}
						else
						{
							if (dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown == LSData.pLSIntruPhySecStr[ii].wCondSwitLockDir)
							{
								pLgScCfgDtStr->chSecInvSecLockDir[pLgScCfgDtStr->chSecInvSecAndConSwiSum] = CI_SYSTEM_DIRECTION_DOWN;
							}
							else
							{
								pLgScCfgDtStr->chSecInvSecLockDir[pLgScCfgDtStr->chSecInvSecAndConSwiSum] = CI_SYSTEM_DIRECTION_UP;
							}
						}
						pLgScCfgDtStr->chSecInvSecAndConSwiSum++;
					}
					else
					{
						/*侵限超出最大值，返回失败*/
						rtnvalue = 0u;
						debug_infor_printf((const)"[LogSecInv] LogSecID:%d ERROR: SecInvSecAndConSwiSum Is Exceed MAX\n", pLgScCfgDtStr->LogicSectionId);
						break;
					}
				}
				else
				{
					/*继续遍历*/
				}
			}
		}

		/*在日志中打印逻辑区段侵限关系*/
		if ((0U < pLgScCfgDtStr->chSecInvSecAndConSwiSum) && (1U == rtnvalue))
		{
			for (ii = 0U; ii < pLgScCfgDtStr->chSecInvSecAndConSwiSum; ii++)
			{
				debug_infor_printf((const)"[LogSecInv] LogSecID:%d, InvData:%d, Dir:%d\n", pLgScCfgDtStr->LogicSectionId, pLgScCfgDtStr->wszSecInvSecAndConSwiId[ii], pLgScCfgDtStr->chSecInvSecLockDir[ii]);

			}
		}
		else
		{
			;
		}

#if 1
		/*计算本逻辑区段起点相邻的逻辑区段数量及对应逻辑区段ID*/
		pLgScCfgDtStr->chBeginLogSecSum = 0u;
		/*计算本逻辑区段终点相邻的逻辑区段数量及对应逻辑区段ID*/
		pLgScCfgDtStr->chEndLogSecSum = 0u;
		for (ii = 0U; ii < dsuDataLenStru.wLinkLen; ii++)
		{/*在LINK表中找到本逻辑区段终点LINK对应的那一行数据*/
			if (pLgScCfgDtStr->wTmnlLink == dsuStaticHeadStru.pLinkStru[ii].wId)
			{/*本逻辑区段起终点一致（即一个LINK上有多个逻辑区段）且本逻辑区段为此LINK上的非最后一个区段*/
			 /*本逻辑区段起终点不一致，且本逻辑区段终点LINK不是一个完整的LINK（即道岔区段被分成2个逻辑区段）*/
				if (pLgScCfgDtStr->dwTmnlOffset != dsuStaticHeadStru.pLinkStru[ii].dwLength)
				{
					/*逻辑区段终点LINK不是一个完整的LINK，因为同一个LINK不存在方向变化点*/
					for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++)
					{/*遍历逻辑区段表，找到起点LINK编号与本逻辑区段终点LINK一致，且其起点偏移量比本逻辑区段终点偏移量大1的那个逻辑区段即为相邻逻辑区段*/
						if (pLgScCfgDtStr->wTmnlLink == dsuStaticHeadStru.pLogicSgmtStru[jj].wOrgnLkId)
						{
							if (pLgScCfgDtStr->dwTmnlOffset == (dsuStaticHeadStru.pLogicSgmtStru[jj].dwOrgnLkOfst - 1U))
							{
								pLgScCfgDtStr->wEndLogSecId[chLogSecNextLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId;
								chLogSecNextLogSecSum++;
							}
						}
					}
				}
				else
				{/*本逻辑区段起终点一致（即一个LINK上有多个逻辑区段）且本逻辑区段为此LINK上的最后一个区段*/
				 /*本逻辑区段起终点不一致，且本逻辑区段包含的LINK是完成得LINK*/
					if (65535U == dsuStaticHeadStru.pLinkStru[ii].wTmnlJointMainLkId)
					{/*无终点相连接的相邻正线link编号，说明此逻辑区段后方再无区段*/
						pLgScCfgDtStr->chEndLogSecSum = 0U;
					}
					else
					{

						if ((LINK_DIRCHANGE_NONE == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged)
							|| (LINK_DIRCHANGE_BEGIN == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged))
						{
							for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++)
							{/*遍历逻辑区段，起点LINK偏移量为0*/
							/*当前逻辑区段终端LINK无方向变化点或该LINK的起点为方向变化点*/
								if (0U == dsuStaticHeadStru.pLogicSgmtStru[jj].dwOrgnLkOfst)
								{
									if ((dsuStaticHeadStru.pLinkStru[ii].wTmnlJointMainLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wOrgnLkId)
										|| (dsuStaticHeadStru.pLinkStru[ii].wTmnlJointSideLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wOrgnLkId))
									{/*本逻辑区段对应LINK的终点正线连接LINK编号与查找的逻辑区段起点LINK编号一致
									 或本逻辑区段对应LINK的终点侧线连接LINK编号与查找的逻辑区段起点LINK编号一致*/
										pLgScCfgDtStr->wEndLogSecId[chLogSecNextLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId;
										chLogSecNextLogSecSum++;
									}
								}
							}
						}
						else if (LINK_DIRCHANGE_END == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged)
						{
							for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++)
							{/*遍历逻辑区段，起点LINK偏移量为0*/
							/*当前逻辑区段终端LINK的终点为方向变化点*/
								if (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId]].dwLength == dsuStaticHeadStru.pLogicSgmtStru[jj].dwTmnlLkOfst)
								{
									/*遍历的逻辑区段终点LINK的偏移量应该为对应LINK的长度*/
									if ((dsuStaticHeadStru.pLinkStru[ii].wTmnlJointMainLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId)
										|| (dsuStaticHeadStru.pLinkStru[ii].wTmnlJointSideLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId))
									{/*本逻辑区段对应LINK的终点正线连接LINK编号与查找的逻辑区段终点LINK编号一致
									 或本逻辑区段对应LINK的终点侧线连接LINK编号与查找的逻辑区段终点LINK编号一致*/
										pLgScCfgDtStr->wEndLogSecId[chLogSecNextLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId;
										chLogSecNextLogSecSum++;
									}
								}
							}
						}
						else
						{
							rtnvalue = 0U; /*数据配置值非法*/
						}

					}
				}
				if (LOGSEC_NEXT_LOGSEC_SUM_MAX < chLogSecNextLogSecSum)
				{
					rtnvalue = 0U;
					debug_infor_printf((const)"LogicSecCfgDtStruFromDquSgmtStr Error: LogSec Rel End LogSec Num Is Exceed Max\n");
				}
				else
				{
					pLgScCfgDtStr->chEndLogSecSum = chLogSecNextLogSecSum;
					chForeachEndFlag++;
				}
			}
			/*在LINK表中找到本逻辑区段起点LINK对应的那一行数据*/
			if (pLgScCfgDtStr->wOrgnLink == dsuStaticHeadStru.pLinkStru[ii].wId)
			{/*本逻辑区段起点偏移量不为0*/
				if (0U != pLgScCfgDtStr->dwOrgnOffset)
				{
					/*逻辑区段起点LINK不是一个完整的LINK，因为同一个LINK不存在方向变化点*/
					for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++)
					{/*遍历逻辑区段表，找到终点LINK编号与本逻辑区段起LINK一致，且其终点偏移量比本逻辑区段起点偏移量小1的那个逻辑区段即为起点逻辑区段*/
						if (pLgScCfgDtStr->wOrgnLink == dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId)
						{
							if (pLgScCfgDtStr->dwOrgnOffset == (dsuStaticHeadStru.pLogicSgmtStru[jj].dwTmnlLkOfst + 1U))
							{
								pLgScCfgDtStr->wBeginLogSecId[chLogSecLastLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId;
								chLogSecLastLogSecSum++;
							}
						}
					}
				}
				else
				{/*本逻辑区段起终点一致（即一个LINK上有多个逻辑区段）且本逻辑区段为此LINK上的第一个区段*/
				 /*本逻辑区段起终点不一致，且本逻辑区段包含的LINK是完成得LINK*/
					if (65535U == dsuStaticHeadStru.pLinkStru[ii].wOrgnJointMainLkId)
					{/*无终点相连接的相邻正线link编号，说明此逻辑区段后方再无区段*/
						pLgScCfgDtStr->chBeginLogSecSum = 0U;
					}
					else
					{
						if ((LINK_DIRCHANGE_NONE == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged)
							|| (LINK_DIRCHANGE_END == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged))
						{
							for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++)
							{/*遍历逻辑区段，起点LINK偏移量为0*/
								if (dsuStaticHeadStru.pLinkStru[ii].wOrgnJointMainLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId)
								{/*本逻辑区段对应LINK的起点正线连接LINK编号与查找的逻辑区段终点LINK编号一致*/
									if (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[dsuStaticHeadStru.pLinkStru[ii].wOrgnJointMainLkId]].dwLength == dsuStaticHeadStru.pLogicSgmtStru[jj].dwTmnlLkOfst)
									{/*查找到的逻辑区段终点LINK偏移量必须为对应LINK的长度*/
										pLgScCfgDtStr->wBeginLogSecId[chLogSecLastLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId;
										chLogSecLastLogSecSum++;
									}
								}
								if (dsuStaticHeadStru.pLinkStru[ii].wOrgnJointSideLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId)
								{/*本逻辑区段对应LINK的起点侧线连接LINK编号与查找的逻辑区段终点LINK编号一致*/
									if (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[dsuStaticHeadStru.pLinkStru[ii].wOrgnJointSideLkId]].dwLength == dsuStaticHeadStru.pLogicSgmtStru[jj].dwTmnlLkOfst)
									{/*查找到的逻辑区段终点LINK偏移量必须为对应LINK的长度*/
										pLgScCfgDtStr->wBeginLogSecId[chLogSecLastLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId;
										chLogSecLastLogSecSum++;
									}
								}
							}
						}
						else if (LINK_DIRCHANGE_BEGIN == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged)
						{
							for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++)
							{/*遍历逻辑区段，起点LINK偏移量为0*/
								if (dsuStaticHeadStru.pLinkStru[ii].wOrgnJointMainLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wOrgnLkId)
								{/*本逻辑区段对应LINK的起点正线连接LINK编号与查找的逻辑区段起点LINK编号一致*/
									if (0U == dsuStaticHeadStru.pLogicSgmtStru[jj].dwOrgnLkOfst)
									{/*查找到的逻辑区段起点LINK偏移量必须为0*/
										pLgScCfgDtStr->wBeginLogSecId[chLogSecLastLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId;
										chLogSecLastLogSecSum++;
									}
								}
								if (dsuStaticHeadStru.pLinkStru[ii].wOrgnJointSideLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wOrgnLkId)
								{/*本逻辑区段对应LINK的起点侧线连接LINK编号与查找的逻辑区段起点LINK编号一致*/
									if (0U == dsuStaticHeadStru.pLogicSgmtStru[jj].dwOrgnLkOfst)
									{/*查找到的逻辑区段起点LINK偏移量必须为0*/
										pLgScCfgDtStr->wBeginLogSecId[chLogSecLastLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId;
										chLogSecLastLogSecSum++;
									}
								}
							}
						}
						else
						{
							rtnvalue = 0U; /*数据配置值非法*/
						}
					}
				}
				if (LOGSEC_NEXT_LOGSEC_SUM_MAX < chLogSecLastLogSecSum)
				{
					rtnvalue = 0U;
					debug_infor_printf((const)"LogicSecCfgDtStruFromDquSgmtStr Error: LogSec Rel Begin LogSec Num Is Exceed Max\n");
				}
				else
				{
					pLgScCfgDtStr->chBeginLogSecSum = chLogSecLastLogSecSum;
					chForeachEndFlag++;
				}
			}
			if ((2U == chForeachEndFlag) || (0U == rtnvalue))
			{
				break;
			}
		}
#endif
		/*逻辑区段关联信号机计算*/
		if ((0U == pLgScCfgDtStr->dwOrgnOffset) || (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].dwLength == pLgScCfgDtStr->dwTmnlOffset))
		{/*起点偏移量为0或者终点偏移量为对应LINK长度才具备关联信号机*/
			for (ii = 0; ii < dquCICfgDtStr.SgnlCfgDtStrLen; ii++)
			{
				wSignalAttribute = dsuStaticHeadStru.pSignalStru[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId]].wAttribute;
				if (0x4000U != (wSignalAttribute & 0x4000U))
				{
					if (dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId == dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId)
					{
						/*信号机所处LINK与防护LINK是同一个LINK且此信号机不为尽头线的防护信号机*/
						if (dquCICfgDtStr.SgnlCfgDtStr[ii].InFirstPhySecId == pLgScCfgDtStr->wRelativePhySecId)
						{
							/*当前逻辑区段所属物理区段为待查询信号机的内方第一区段
							且当前逻辑区段为此物理区段中第一个或者最后一个区段(第一层IF已经通过偏移量查询过)*/
							pLgScCfgDtStr->wRelateBeginSigId[pLgScCfgDtStr->chRelateBeginSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId;
							pLgScCfgDtStr->chRelateBeginSigSum++;
						}

						if ((0U == pLgScCfgDtStr->dwOrgnOffset) && (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].dwLength != pLgScCfgDtStr->dwTmnlOffset))
						{/*本逻辑区段起点偏移量为0，但是终点不是一个完整的LINK*/
							if (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wOrgnLink)
							{/*信号机防护LINK与本逻辑区段起点相同*/
								pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId;
								pLgScCfgDtStr->chRelateEndSigSum++;
							}
						}
						else if ((0U != pLgScCfgDtStr->dwOrgnOffset) && (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].dwLength == pLgScCfgDtStr->dwTmnlOffset))
						{/*本逻辑区段起点不为一个完整的LINK，但是终点是一个完整的LINK*/
							if (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wTmnlLink)
							{/*信号机防护LINK与本逻辑区段终点相同*/
								pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId;
								pLgScCfgDtStr->chRelateEndSigSum++;
							}
						}
						else
						{
							if ((dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wOrgnLink) || (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wTmnlLink))
							{/*信号机防护LINK与逻辑区段起点或者终点LINK相同，即为逻辑区段关联终端信号机*/
								pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId;
								pLgScCfgDtStr->chRelateEndSigSum++;
							}
						}
					}
					else
					{
						/*信号机所在LINK与防护LINK为同一个或者是尽头线的防护信号机*/
						if (((dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wOrgnLink) || (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wTmnlLink))
							&& ((pLgScCfgDtStr->dwOrgnOffset <= dquCICfgDtStr.SgnlCfgDtStr[ii].dwProtectOff) && (dquCICfgDtStr.SgnlCfgDtStr[ii].dwProtectOff <= pLgScCfgDtStr->dwTmnlOffset)))
						{/*信号机防护LINK与逻辑区段起点或者终点LINK相同，并且信号机防护LINK的偏移量在本逻辑区段偏移量范围之内即为逻辑区段关联始端信号机*/
							pLgScCfgDtStr->wRelateBeginSigId[pLgScCfgDtStr->chRelateBeginSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId;
							pLgScCfgDtStr->chRelateBeginSigSum++;
						}
						if ((0U == pLgScCfgDtStr->dwOrgnOffset) && (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].dwLength != pLgScCfgDtStr->dwTmnlOffset))
						{/*本逻辑区段起点偏移量为0，但是终点不是一个完整的LINK*/
							if ((dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId == pLgScCfgDtStr->wOrgnLink) && (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wOrgnLink]].wOrgnJointMainLkId))
							{/*信号机外方第一LINK与本逻辑区段起点相同，且其防护LINK为本逻辑区段起点相连LINK*/
								pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId;
								pLgScCfgDtStr->chRelateEndSigSum++;
							}
						}
						else if ((0U != pLgScCfgDtStr->dwOrgnOffset) && (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].dwLength == pLgScCfgDtStr->dwTmnlOffset))
						{/*本逻辑区段起点不为一个完整的LINK，但是终点是一个完整的LINK*/
							if ((dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId == pLgScCfgDtStr->wTmnlLink) && (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].wTmnlJointMainLkId))
							{/*信号机外方第一LINK与本逻辑区段终点相同，且其防护LINK为本逻辑区段终点相连LINK*/
								pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId;
								pLgScCfgDtStr->chRelateEndSigSum++;
							}
						}
						else
						{
							if ((dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId == pLgScCfgDtStr->wOrgnLink) || (dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId == pLgScCfgDtStr->wTmnlLink))
							{/*信号机外方第一LINK与逻辑区段起点或者终点LINK相同，即为逻辑区段关联终端信号机*/
								pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId;
								pLgScCfgDtStr->chRelateEndSigSum++;
							}
						}
					}
				}
				else
				{
					/*按钮信号机，不计入逻辑区段关联的信号机中*/
				}

				if ((LOGSEC_RELATE_SIG_SUM_MAX < pLgScCfgDtStr->chRelateEndSigSum) || (LOGSEC_RELATE_SIG_SUM_MAX < pLgScCfgDtStr->chRelateBeginSigSum))
				{
					rtnvalue = 0U;
					debug_infor_printf((const)"LogicSecCfgDtStruFromDquSgmtStr Error: LogSec Rel Begin or End Signal Num Is Exceed Max\n");
					break;
				}
				else
				{
					/*继续初始化*/
				}
			}
		}
		else
		{/*逻辑区段为同一物理区段中非头非尾区段*/
			pLgScCfgDtStr->chRelateBeginSigSum = 0U;
			pLgScCfgDtStr->chRelateEndSigSum = 0U;
		}
#if 0  
		/* 联络线相关 预留*/
		/*逻辑区段关联联络线道岔计算*/
		pLgScCfgDtStr->chRelateContactSwSum = 0U;
		for (ii = 0U; ii < LSDataLen.LSRouteStrLen; ii++)
		{/*遍历进路关联的其它联锁ID，避免其他联锁表里多做但进路表未引用*/
			for (jj = 0U; jj < OTHER_CI_MAX_DEV_NUM; jj++)
			{
				if (CI_DEVICE_TYPE_CONNECT_SWITCH == LSData.pLSOterCiStr[LSData.pLSRouteStr[ii].wCBTCOtherCIID].otherCiDevInfoBuf[jj].wDevType)
				{/*获取所有设备类型为联锁线道岔的设备ID*/
					for (kk = 0U; kk < wContactSwIdIndex; kk++)
					{/*设备ID去重*/
						if (wContactSwIdBuf[kk] == LSData.pLSOterCiStr[LSData.pLSRouteStr[ii].wCBTCOtherCIID].otherCiDevInfoBuf[jj].wId)
						{
							chForeachContactFlag = 1U;
						}
					}
					if (1U != chForeachContactFlag)
					{/*所有联锁线道岔ID存储到一个数组中*/
						wContactSwIdBuf[wContactSwIdIndex] = LSData.pLSOterCiStr[LSData.pLSRouteStr[ii].wCBTCOtherCIID].otherCiDevInfoBuf[jj].wId;
						wContactSwIdIndex++;
						chForeachContactFlag = 0U;
					}
				}
			}
		}
		for (ii = 0; ii < wContactSwIdIndex; ii++)
		{
			wTempLinkId = dsuStaticHeadStru.pPointStru[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[wContactSwIdBuf[ii]]].wSideLkId;
			if (0U == dsuStaticHeadStru.pPointStru[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[wContactSwIdBuf[ii]]].dwSideLkOfst)
			{/*联络线道岔所在侧线偏移量为0，说明联络线道岔侧线LINK是从左往右偏移*/
				while (3U != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wTmnlPointType)
				{/*在LINK依次查找，直到找到一个LINK的终点端点类型为道岔，此时的道岔编号便是进路方向离联络线最近的道岔*/
					wTempLinkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wTmnlJointMainLkId;
				}
				wContactSwRelateSwId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wTmnlPointId;
			}
			else
			{/*联络线道岔所在侧线偏移量不为0，说明联络线道岔侧线LINK是从右往左偏移*/
				while (3U != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wOrgnPointType)
				{/*在LINK依次查找，直到找到一个LINK的起点端点类型为道岔，此时的道岔编号便是进路方向离联络线最近的道岔*/
					wTempLinkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wOrgnJointMainLkId;
				}
				wContactSwRelateSwId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wOrgnPointId;
			}
			for (jj = 0U; jj < dquCICfgDtStr.SwchCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[wContactSwRelateSwId]].SwitchLogSecSum; jj++)
			{/*遍历对应找到道岔关联的逻辑区段*/
				if (pLgScCfgDtStr->LogicSectionId == dquCICfgDtStr.SwchCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[wContactSwRelateSwId]].SwitchLogSecIdBuf[jj])
				{/*如果此联络线道岔找到的道岔关联的逻辑区段是当前区段，这个联络线道岔便为当前区段的关联联络线道岔*/
					pLgScCfgDtStr->wRelateContactSwId[pLgScCfgDtStr->chRelateContactSwSum] = wContactSwRelateSwId;
					(pLgScCfgDtStr->chRelateContactSwSum)++;
				}
			}
		}
#endif

		/*by cgh 20230919 逻辑区段SPKS表中查找对应逻辑区段对应SPKS*/
		pLgScCfgDtStr->chSpksNum = 0u;
		/* 从逻辑区段SPKS表格中查找对应的逻辑区段ID */
		for (ii = 0u; ii < dsuDataLenStru.wLogSecSpksLen; ii++)
		{
			for (jj = 0u; jj < dsuStaticHeadStru.pLogSecSpksButtonStru[ii].wLogSecNum; jj++)
			{
				/* 判断当前SPKS按钮是否包含本物理区段 */
				if (dsuStaticHeadStru.pLogSecSpksButtonStru[ii].wRelateLogSecId[jj] == pLgScCfgDtStr->LogicSectionId)
				{
					if (pLgScCfgDtStr->chSpksNum < LOGIC_SECTION_SPKS_MAX_NUM)
					{
						pLgScCfgDtStr->wSpksIdBuff[pLgScCfgDtStr->chSpksNum] = dsuStaticHeadStru.pLogSecSpksButtonStru[ii].wId;
						pLgScCfgDtStr->chSpksNum++;
					}
				}
				else
				{
				}
			}
		}

		/* 查找逻辑区段关联的PSD*/
		pLgScCfgDtStr->logSecRltPsdSum = 0u;
		for (ii = 0u; ii < dsuDataLenStru.wScreenLen; ii++)/*安全屏蔽门数量*/
		{
			/*遍历逻辑区段关联link*/
			for (jj = 0u; jj < pLgScCfgDtStr->chLinkNum; jj++)
			{
				/* 判断屏蔽门所属的link是否在本逻辑区段所属link中 */
				if (dsuStaticHeadStru.pScreenStru[ii].wRelatLkId == pLgScCfgDtStr->szLinkIdBuff[jj])
				{
					if (pLgScCfgDtStr->logSecRltPsdSum < LOGSEC_RELATE_PSD_MAX)
					{
						pLgScCfgDtStr->logSecRltPsdBuf[pLgScCfgDtStr->logSecRltPsdSum] = dsuStaticHeadStru.pScreenStru[ii].wId;
						pLgScCfgDtStr->logSecRltPsdSum++;
					}
				}
				else
				{
				}
			}
		}

		/* 查找逻辑区段关联的ESB*/
		pLgScCfgDtStr->logSecRltEsbSum = 0u;
		for (ii = 0u; ii < dsuDataLenStru.wEmergStopLen; ii++)/*紧急按钮数量*/
		{
			/*遍历逻辑区段关联link*/
			for (jj = 0u; jj < pLgScCfgDtStr->chLinkNum; jj++)
			{
				/* 判断屏蔽门所属的link是否在本逻辑区段所属link中 */
				if (dsuStaticHeadStru.pEmergStopStru[ii].wRelatLkId == pLgScCfgDtStr->szLinkIdBuff[jj])
				{
					if (pLgScCfgDtStr->logSecRltEsbSum < LOGSEC_RELATE_ESB_MAX)
					{
						pLgScCfgDtStr->logSecRltEsbBuf[pLgScCfgDtStr->logSecRltEsbSum] = dsuStaticHeadStru.pEmergStopStru[ii].wId;
						pLgScCfgDtStr->logSecRltEsbSum++;
					}
				}
				else
				{
				}
			}
		}

		
	}
	else
	{
		/*返回失败*/
		rtnvalue = 0u;
	}
	return rtnvalue;
}


/*********************************************
*函数功能：初始化保护区段条件道岔结构体
*参数说明：pProtectLink保护区段结构体指针
pOvlpCfgDtStr保护区段配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 OverlapCfgDtStruFromDquStr(DSU_PROTECT_LINK_STRU * pProtectLink, OverlapConfigDataStruct* pOvlpCfgDtStr)
{
	UINT16 j = 0u;
	UINT16 i = 0u;
	UINT16 k = 0u;
	UINT16 l = 0u;
	UINT16 wPhySecId = 0u;    /*临时物理区段编号*/
	DSU_AXLE_SGMT_STRU* pAxleSgmt;
	DSU_ROUTE_STRU* pRoute;
	UINT8 rtnvalue = 0u;
	UINT8 handleFlag = 0u;/*标志*/
	UINT8 cTmpLogicSectionSum = 0u;/* 包含逻辑区段数量 */
	UINT8 isEachInvFlag = 0U;

	/*入口参数防护*/
	if((NULL == pProtectLink) || (NULL == pOvlpCfgDtStr))
	{
		/*返回失败*/
		return 0u;
	}

	pOvlpCfgDtStr->OverlapId = pProtectLink->wId;
	pOvlpCfgDtStr->BelongCiId =(UINT8)dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[0]]].wManagePhysicalCI; 
	pOvlpCfgDtStr->BelongVirCiId = (UINT8)dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[0]]].BelongVirCI;
	/*包含物理区段数目 及ID(配置字段)*/
	pOvlpCfgDtStr->PhySecSum = 0u;
	for(j=0u;j<pProtectLink->wIncludeAxleSgmtNum;j++)
	{
		/*获取保护区段包含的计轴区段*/
		wPhySecId = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[j]]].wRelatePhysicalSgmtId;
		if(0xFFFFu != wPhySecId)
		{
			if(pOvlpCfgDtStr->PhySecSum == 0u)
			{
				pOvlpCfgDtStr->PhySecIdBuf[pOvlpCfgDtStr->PhySecSum] = wPhySecId;
				pOvlpCfgDtStr->PhySecSum++;
			}
			else
			{
				/*对应的物理区段ID可能有重复，所以下面的for循环用来去重*/
				for(i=0u;i<pOvlpCfgDtStr->PhySecSum;i++)
				{
					if(pOvlpCfgDtStr->PhySecIdBuf[i] == wPhySecId)
					{
						handleFlag = 1u;/*表示找到相同的ID*/
						break;
					}
					else
					{

					}
				}

				if (handleFlag != 1u)
				{/*未找到相同ID*/

					pOvlpCfgDtStr->PhySecIdBuf[pOvlpCfgDtStr->PhySecSum] = wPhySecId;
					pOvlpCfgDtStr->PhySecSum++;
				}
			}

		}
	}
	/*包含道岔及数目 (配置字段)*/
	pOvlpCfgDtStr->SwitchSum = 0u;
	for(i=0u;i<pProtectLink->wIncludeAxleSgmtNum;i++)
	{
		/*获取保护区段包含的计轴区段*/
		pAxleSgmt = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[i]];
		for(j=0u;j<pAxleSgmt->wRelatPointNum;j++)
		{
			/*从计轴区段中获取道岔信息*/
			pOvlpCfgDtStr->ConditionSwitchStru[pOvlpCfgDtStr->SwitchSum].SwitchId = pAxleSgmt->wRelatPointId[j];
			pOvlpCfgDtStr->ConditionSwitchStru[pOvlpCfgDtStr->SwitchSum].SwitchPosition = (UINT8)pAxleSgmt->wRelatPointStatus[j];
			pOvlpCfgDtStr->SwitchSum++;
		}
	}
	/*自动信号overlap道岔触发物理区段ID及数目 (配置字段)*/ 
	pOvlpCfgDtStr->TriPhySecSum = 0u;
	/*1、遍历电子地图进路表，找到保护区段对应进路（可能不只一个）;*/
	for(i=0u;i<dsuDataLenStru.wRouteLen;i++)
	{
		pRoute = dsuStaticHeadStru.pRouteStru + i;
		for(j=0u;j<pRoute->wProtectLinkNum;j++)
		{
			if(pProtectLink->wId == pRoute->wProtectLinkId[j])
			{
				/*2、找到了对应的进路，再到联锁表中的进路表寻找到对应的进路，在对应的进路上获取“防护区段对应停稳物理区段ID”*/
				for(k=0u;k<LSDataLen.LSRouteStrLen;k++)
				{
					if(LSData.pLSRouteStr[k].wRouteId == pRoute->wId)
					{
						pOvlpCfgDtStr->TriPhySecIdBuf[pOvlpCfgDtStr->TriPhySecSum] = LSData.pLSRouteStr[k].wFHQD_TW_WLQDId;
						pOvlpCfgDtStr->TriPhySecSum++;
					}
				}
			}
		}
	}

	/*遍历保护区段锁闭条件表,找到保护区段对应折返进路折返轨物理区段，侵限敌对保护区段，关联防护道岔*/
	pOvlpCfgDtStr->RetRoutAndTrkPhySecSum = 0u;
	pOvlpCfgDtStr->InvOppOverlapSum = 0u;
	pOvlpCfgDtStr->FloodGateIdSum = 0u;
	pOvlpCfgDtStr->AxisSecFarId = 0u;
	pOvlpCfgDtStr->wOverlapThisZhaoChaRelayId = 0U;
	pOvlpCfgDtStr->wOverlapThatZhaoChaRelayId = 0U;

	for(k = 0u; k < LSDataLen.LSOverlapLockCondStruLen; k++)
	{
		if(LSData.pLSOverlapLockCondStru[k].wOverlapId == pProtectLink->wId)
		{/*已找到保护区段所对应的保护区段条件表项目*/

			for(l = 0u; l < OVLP_LOCK_COND_MAX_INCL_RET_ROUTE_N_PHY_SEC_NUM; l++)
			{
				if(
					(UINT16_MAX != LSData.pLSOverlapLockCondStru[k].szIncludeRetTrkPhySecId[l]) 
					&&
					(0u != LSData.pLSOverlapLockCondStru[k].szIncludeRetTrkPhySecId[l])
					&&
					(UINT16_MAX != LSData.pLSOverlapLockCondStru[k].szIncludeReturnRouteId[l])
					&&
					(0u != LSData.pLSOverlapLockCondStru[k].szIncludeReturnRouteId[l]))
				{
					pOvlpCfgDtStr->ReturnRouteIdBuf[pOvlpCfgDtStr->RetRoutAndTrkPhySecSum] = LSData.pLSOverlapLockCondStru[k].szIncludeReturnRouteId[l];
					pOvlpCfgDtStr->RetTrkPhySecIdBuf[pOvlpCfgDtStr->RetRoutAndTrkPhySecSum] = LSData.pLSOverlapLockCondStru[k].szIncludeRetTrkPhySecId[l];
					pOvlpCfgDtStr->RetRoutAndTrkPhySecSum++;
				}

			}

			/*侵限敌对保护区段*/
			for (l = 0u; l < OVLP_LOCK_COND_MAX_INCL_INV_OPP_OVLP_NUM; l++)
			{
				if (
					(UINT16_MAX != LSData.pLSOverlapLockCondStru[k].szIncludeInvOppOverlapId[l])
					&&
					(0u != LSData.pLSOverlapLockCondStru[k].szIncludeInvOppOverlapId[l]))
				{
					pOvlpCfgDtStr->InvOppOverlapIdBuff[pOvlpCfgDtStr->InvOppOverlapSum] = LSData.pLSOverlapLockCondStru[k].szIncludeInvOppOverlapId[l];
					pOvlpCfgDtStr->InvOppOverlapSum++;
				}

			}


			/*保护区段锁闭条件防护道岔组（配置字段）*/
			if ((UINT16_MAX != LSData.pLSOverlapLockCondStru[k].overlapLocProSwitchGroupID) && (0U != LSData.pLSOverlapLockCondStru[k].overlapLocProSwitchGroupID))
			{/*防护道岔组ID有效*/
				for (l = 0u;l < LSDataLen.LSFHDaoChaStrLen;l++)
				{/*遍历防护道岔组表*/
					if((LSData.pLSFHDaoChaStr+l)->wId == LSData.pLSOverlapLockCondStru[k].overlapLocProSwitchGroupID)
					{
						for(j = 0u;j < FHDC_MAX_INCLUDE_POINT_NUM;j++)
						{
							if((0u != (LSData.pLSFHDaoChaStr+l)->wPointId[j]) && (UINT16_MAX != (LSData.pLSFHDaoChaStr+l)->wPointId[j]))
							{
								pOvlpCfgDtStr->ProtectSwitchStru[pOvlpCfgDtStr->ProtectSwitchSum].ProtectSwitchId = (LSData.pLSFHDaoChaStr+l)->wPointId[j];
								pOvlpCfgDtStr->ProtectSwitchStru[pOvlpCfgDtStr->ProtectSwitchSum].ProtectPosition = (UINT8)(LSData.pLSFHDaoChaStr+l)->wPointSta[j];
								pOvlpCfgDtStr->ProtectSwitchSum++;
							}
						}
					}
				}
			}

			/*保护区段锁闭条件防淹门组（配置字段）*/
			for(l = 0u; l < ROUTE_MAX_FLOOD_GATE_NUM; l++)
			{
				if((UINT16_MAX != LSData.pLSOverlapLockCondStru[k].szIncludeFloodGateId[l]) 
					&&
					(0u != LSData.pLSOverlapLockCondStru[k].szIncludeFloodGateId[l])
					&& (ROUTE_MAX_FLOOD_GATE_NUM > pOvlpCfgDtStr->FloodGateIdSum))
				{
					pOvlpCfgDtStr->FloodGateIdBuff[pOvlpCfgDtStr->FloodGateIdSum] = LSData.pLSOverlapLockCondStru[k].szIncludeFloodGateId[l];
					pOvlpCfgDtStr->FloodGateIdSum++;
				}
			}

			pOvlpCfgDtStr->wOverlapThisZhaoChaRelayId = LSData.pLSOverlapLockCondStru[k].wOverlapThisZhaoChaRelayId;
			pOvlpCfgDtStr->wOverlapThatZhaoChaRelayId = LSData.pLSOverlapLockCondStru[k].wOverlapThatZhaoChaRelayId;

			break;
		}

	}

	/* 逻辑区段数目与ID */
	for (i = 0u; i < pProtectLink->wIncludeAxleSgmtNum; i++)
	{
		for (j = 0u; j < dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[i]]].wIncludeLogicSgmtNum;j++)
		{
			pOvlpCfgDtStr->szLogicSectionIdBuf[cTmpLogicSectionSum] = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[i]]].wLogicSgmtId[j];
			cTmpLogicSectionSum++;
		}
	}
	if (0u == cTmpLogicSectionSum)
	{
		rtnvalue = 0u;
	}
	else
	{
		pOvlpCfgDtStr->AxisSecFarId = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[pProtectLink->wIncludeAxleSgmtNum - 1]]].wId;
		pOvlpCfgDtStr->cLogicSectionSum = cTmpLogicSectionSum;
		rtnvalue = 1u;
	}

	/*侵限区段与条件道岔 初始化*/
	isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION);
	pOvlpCfgDtStr->InvSecAndConSwiSum = 0u;

	/*采用旧版本进路侵限条件*/
	if (FUNC_SWITCH_OFF == isEachInvFlag)
	{
		for (k = 0u; k < LSDataLen.LSOverlapLockCondStruLen; k++)
		{
			if (LSData.pLSOverlapLockCondStru[k].wOverlapId == pProtectLink->wId)
			{/*已找到保护区段所对应的保护区段条件表项目*/

				/*侵限区段与条件道岔*/
				for (l = 0U; l < OVLP_LOCK_COND_MAX_INCL_INV_SEC_N_CON_SWI_NUM; l++)
				{
					if ((UINT16_MAX != LSData.pLSOverlapLockCondStru[k].szIncludeInvSecAndConSwiId[l])
						&& (0U != LSData.pLSOverlapLockCondStru[k].szIncludeInvSecAndConSwiId[l]))
					{
						pOvlpCfgDtStr->InvSecAndConSwiIdBuf[pOvlpCfgDtStr->InvSecAndConSwiSum] = LSData.pLSOverlapLockCondStru[k].szIncludeInvSecAndConSwiId[l];
						pOvlpCfgDtStr->InvSecAndConSwiSum++;
					}
				}
			}
		}
	}
	/*采用新版逻辑区段互相侵限表转化*/
	else
	{
		/*遍历保护区段包含的所有逻辑区段*/
		for (k = 0U; k < pOvlpCfgDtStr->cLogicSectionSum; k++)
		{
			/*遍历所有侵限区段及条件道岔表*/
			for (l = 0U; l < LSDataLen.LSIntruPhySecStrLen; l++)
			{
				/*若侵限区段表中所属逻辑区段ID与保护区段包含的逻辑区段ID一致，将该条侵限存入保护区段侵限条件表中*/
				if ((pOvlpCfgDtStr->szLogicSectionIdBuf[k] == LSData.pLSIntruPhySecStr[l].belongLogSecId)&&(0U!= LSData.pLSIntruPhySecStr[l].belongLogSecId))
				{
					if (OVLP_INVASECT_N_CONDSWIT_SUM_MAX > pOvlpCfgDtStr->InvSecAndConSwiSum)
					{
						pOvlpCfgDtStr->InvSecAndConSwiIdBuf[pOvlpCfgDtStr->InvSecAndConSwiSum] = LSData.pLSIntruPhySecStr[l].wId;
						pOvlpCfgDtStr->InvSecAndConSwiSum++;
					}
					else
					{
						/*保护区段侵限数量超出范围，初始化失败*/
						rtnvalue = 0U;
						break;
					}
				}
				else
				{
					/*继续遍历*/
				}
			}

			if (0U == rtnvalue)
			{
				debug_infor_printf((const)"[OverLapInv] OverLapID:%d ERROR: InvSecAndConSwiSum Is Exceed MAX\n", pOvlpCfgDtStr->OverlapId);
				break;
			}
			else
			{
				/*继续遍历*/
			}

		}
	}

	/*在日志中打印保护区段侵限条件*/
	if ((0U < pOvlpCfgDtStr->InvSecAndConSwiSum) && (1U == rtnvalue))
	{
		for ( i = 0U; i < pOvlpCfgDtStr->InvSecAndConSwiSum; i++)
		{
			debug_infor_printf((const)"[OverLapInv] OverlapID:%d, InvData:%d\n", pOvlpCfgDtStr->OverlapId, pOvlpCfgDtStr->InvSecAndConSwiIdBuf[i]);
		}
	}
	else
	{
		;
	}
	return rtnvalue;
}


/*********************************************
*函数功能：初始化保护区段接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 OverlapConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitLS_RouteStruct (FSName);	
	callFun *= InitLS_OverlapLockCondStru(FSName);
	callFun *= InitLS_FHDaoChaStru(FSName);

	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}
	
	if (1u == rtnvalue)
	{
		dquCICfgDtStr.OvlapCfgDtStrLen = dsuDataLenStru.wProtectLinkLen;
		for(i = 0u; i < dsuDataLenStru.wProtectLinkLen; i++)
		{
			if (i >= OVERLAP_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			rtnvalue = OverlapCfgDtStruFromDquStr(dsuStaticHeadStru.pProtectLinkStru+i, &dquCICfgDtStr.OvlapCfgDtStr[i]);
			if (0u == rtnvalue)
			{
				break;
			}
		}
	}
	

	return rtnvalue;
}

/*********************************************
*函数功能：紧急停车按钮接口数据结构体
*参数说明：pEmergStopESB结构体指针
pEsbCfgDtStrESB配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 EsbCfgDtStruFromDquEmergStr(DSU_EMERG_STOP_STRU * pEmergStop,EsbConfigDataStruct* pEsbCfgDtStr)
{
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 rtnvalue = 0u;
	UINT16 Linkindex = 0u;

	/*入口参数防护*/
	if((NULL == pEmergStop) || (NULL == pEsbCfgDtStr))
	{
		/*返回失败*/
		return 0u;
	}

	pEsbCfgDtStr->EsbId = pEmergStop->wId;
	rtnvalue = GetDsuLinkIndexNum(pEmergStop->wRelatLkId,&Linkindex);
	if(CI_SUCCESS == rtnvalue)
	{
		pEsbCfgDtStr->BelongCiId = (UINT8)dsuStaticHeadStru.pLinkStru[Linkindex].wManagePhysicalCI;
		pEsbCfgDtStr->BelongVirCiId = (UINT8)dsuStaticHeadStru.pLinkStru[Linkindex].wBelongVirtualCI;
		for (i = 0u; i < dsuDataLenStru.wStationLen; i++)
		{
			for (j = 0u; j < 2u; j++)
			{
				if (pEsbCfgDtStr->EsbId == (dsuStaticHeadStru.pStationStru + i)->wEmergStopId[j])
				{
					pEsbCfgDtStr->BelongPlatFormId = (dsuStaticHeadStru.pStationStru + i)->wATSStationId;
					break;
				}
			}
		}

		for(i=0u;i<RelayDataLen.RelayEmgcyStpStrLen;i++)
		{
			if(pEmergStop->wId == (RelayData.pRelayEmgcyStpStr+i)->wEmgcyStopBtnId)
			{
				pEsbCfgDtStr->EsbRelayId = (RelayData.pRelayEmgcyStpStr+i)->wEmgcyStopBtnRelayId;
				pEsbCfgDtStr->wEsbRelayId2 = (RelayData.pRelayEmgcyStpStr + i)->wEmgcyStopBtnRelayId2;
				pEsbCfgDtStr->EsbDisRelayId = (RelayData.pRelayEmgcyStpStr+i)->wEmgcyStopBtnIndicateRelayId;
				pEsbCfgDtStr->EsbCutRelayId = (RelayData.pRelayEmgcyStpStr + i)->wEmgcyStopCutRelayId;
				pEsbCfgDtStr->EsbCutDisRelayId = (RelayData.pRelayEmgcyStpStr + i)->wEmgcyStopCutIndicateRelayId;
				pEsbCfgDtStr->EsbRepRelayId = (RelayData.pRelayEmgcyStpStr+i)->wRepEmgcyStopBtnRelayId;
				pEsbCfgDtStr->EsbBuzzRelayId = (RelayData.pRelayEmgcyStpStr+i)->wEmgcyStopBuzzRelayId;
				pEsbCfgDtStr->ESSRelayId = (RelayData.pRelayEmgcyStpStr + i)->wESSRelayId;
				pEsbCfgDtStr->ESSSteadyIndicatRelayId = (RelayData.pRelayEmgcyStpStr + i)->wESSSteadyIndicatRelayId;
				pEsbCfgDtStr->ESSFlashIndicatRelayId = (RelayData.pRelayEmgcyStpStr + i)->wESSFlashIndicatRelayId;
				pEsbCfgDtStr->CancelEsbRelayId = (RelayData.pRelayEmgcyStpStr + i)->wCancelEsbRelayId;
				pEsbCfgDtStr->EsbPlatformDisRelayId = (RelayData.pRelayEmgcyStpStr + i)->wEsbPlatformDisRelayId;
				pEsbCfgDtStr->EsbCutoffBuzzRelayId = (RelayData.pRelayEmgcyStpStr + i)->wCutoffEsbBuzzRelayId;
				pEsbCfgDtStr->VirtualAttribute = ESB_VIRTUAL_ATTR_NO;/*非虚拟的*/
				pEsbCfgDtStr->ConfigAtsCiEssSteadyMask = ESS_MASK_NO;/*初始化成未配置稳灯状态码位*/
				pEsbCfgDtStr->ConfigAtsCiEssFlashMask = ESS_MASK_NO;/*初始化成未配置闪灯状态码位*/
				rtnvalue = 1u;
				return rtnvalue;
			}
		}
	}

	pEsbCfgDtStr->EsbRelayId = 0u;
	pEsbCfgDtStr->EsbRepRelayId = 0u;
	pEsbCfgDtStr->VirtualAttribute = ESB_VIRTUAL_ATTR_NO;/*非虚拟的*/
	rtnvalue = 0u;
	return rtnvalue;
}


/*********************************************
*函数功能：初始化紧急停车按钮接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 EsbConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitRelay_EmgcyStpStru (FSName);

	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.EsbCfgDtStrLen = dsuDataLenStru.wEmergStopLen;
		for(i=0u;i<dsuDataLenStru.wEmergStopLen;i++)
		{
			if (i >= ESB_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}

			(void)EsbCfgDtStruFromDquEmergStr(dsuStaticHeadStru.pEmergStopStru+i,&dquCICfgDtStr.EsbCfgDtStr[i]);
		}
	}
	
	return rtnvalue;
}



/*********************************************
*函数功能：屏蔽门配置数据结构体
*参数说明：pScreen屏蔽门结构体指针
pPsdCfgDtStr屏蔽门配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 PsdCfgDtStruFromDquEmergStr(DSU_SCREEN_STRU * pScreen,PsdConfigDataStruct* pPsdCfgDtStr)
{
	UINT16 i = 0u;
	UINT8 j = 0U;
	UINT8 rtnvalue = 0u;
	UINT16 stationId = 0u;
	UINT16 linkindex = 0u;

	/*入口参数防护*/
	if((NULL == pScreen) || (NULL == pPsdCfgDtStr))
	{
		/*返回失败*/
		rtnvalue = 0U;
	}
	else
	{
		pPsdCfgDtStr->PsdId = pScreen->wId;
		rtnvalue = GetDsuLinkIndexNum(pScreen->wRelatLkId, &linkindex);
		if (CI_SUCCESS == rtnvalue)
		{
			pPsdCfgDtStr->BelongCiId = (UINT8)dsuStaticHeadStru.pLinkStru[linkindex].wManagePhysicalCI;
			pPsdCfgDtStr->BelongVirCIid = (UINT8)dsuStaticHeadStru.pLinkStru[linkindex].wBelongVirtualCI;
			pPsdCfgDtStr->wPsdFstProLinkId = pScreen->wFstProLinkId;
			pPsdCfgDtStr->wPsdSndProLinkId = pScreen->wSndProLinkId;
			pPsdCfgDtStr->wPsdTrdProLinkId = pScreen->wTrdProLinkId;

			/*先将继电器初始化为0，设置为虚拟设备*/
			pPsdCfgDtStr->CloseDriveRelayId = 0u;
			pPsdCfgDtStr->DoorStateRelayId = 0u;
			pPsdCfgDtStr->MutualLockRelayId = 0u;
			pPsdCfgDtStr->OpenFourEditGroupDriveRelayId = 0u;
			pPsdCfgDtStr->OpenSixEditGroupDriveRelayId = 0u;
			pPsdCfgDtStr->OpenEightEditGroupDriveRelayId = 0u;
			pPsdCfgDtStr->wRelayDoorButtonId = 0u;
			pPsdCfgDtStr->doorReopenRelayId = 0u;
			pPsdCfgDtStr->departureConfirmRelayId = 0u;
			pPsdCfgDtStr->detectStartRelayId = 0u;
			pPsdCfgDtStr->detectStopRelayId = 0u;
			pPsdCfgDtStr->obstacleRelayId = 0u;
			pPsdCfgDtStr->gapDetMuLockRelayId = 0u;
			pPsdCfgDtStr->closeStateRelayId = 0u;
			pPsdCfgDtStr->ClearPasseSteadyLightRelayId = 0u;
			pPsdCfgDtStr->ClearPasseFlashLightRelayId = 0u;
			pPsdCfgDtStr->ClearPassengerButtonRelayId = 0u;
			pPsdCfgDtStr->wCleFarePCBButtonRelayId = 0U;
			pPsdCfgDtStr->wCleFarePDBFlaLigRelayId = 0U;
			pPsdCfgDtStr->wPobIndicatorRelayId = 0U;
			pPsdCfgDtStr->wPcbIndicatorRelayId = 0U;
			pPsdCfgDtStr->VirtualAttribute = PSD_VIRTUAL_ATTR_YES;  /*初始化为虚拟属性*/
			pPsdCfgDtStr->chPsdControlType = PSD_CONTROL_TYPE_RCI;	/*初始化为RCI控制*/

			if ((UINT16_MAX != pScreen->wLocalPlatformId) && (0U != pScreen->wLocalPlatformId))
			{
				stationId = dsuStaticHeadStru.pStationStru[dsuStationIndex[pScreen->wLocalPlatformId]].wStationID;
				pPsdCfgDtStr->BelongStationId = (UINT8)(stationId & 0x00FFu);/*考虑到车站编号不会超过255，且为了和PSD系统ID统一在这里只取低字节*/
			}
			else
			{
				pPsdCfgDtStr->BelongStationId = 0U;
			}

			pPsdCfgDtStr->RelatedOutStationRouteSum = 0u;
			(void)memset(pPsdCfgDtStr->RelatedOutStationRouteIdBuf, 0, sizeof(UINT16) * RALATED_OUT_STATION_ROUTE_SUM_MAX);
			for (i = 0u; i < dsuDataLenStru.wStationLen; i++)
			{
				for (j = 0u; j < 2u; j++)
				{
					if (pPsdCfgDtStr->PsdId == (dsuStaticHeadStru.pStationStru + i)->wScreenId[j])
					{
						pPsdCfgDtStr->BelongPlatformId = (dsuStaticHeadStru.pStationStru + i)->wATSStationId;
						break;
					}
				}
			}

			for (i = 0u; i < RelayDataLen.RelayScreenStrLen; i++)
			{
				if (pScreen->wId == (RelayData.pRelayScreenStr + i)->wScreenId)
				{
					pPsdCfgDtStr->CloseDriveRelayId = (RelayData.pRelayScreenStr + i)->wRelayCloseDoorId;
					pPsdCfgDtStr->DoorStateRelayId = (RelayData.pRelayScreenStr + i)->wRelayDoorClosedId;
					pPsdCfgDtStr->wDoorStateRelayId2 = (RelayData.pRelayScreenStr + i)->wRelayDoorClosedId2;
					pPsdCfgDtStr->MutualLockRelayId = (RelayData.pRelayScreenStr + i)->wRelayRelatedId;
					pPsdCfgDtStr->wMutualLockRelayId2 = (RelayData.pRelayScreenStr + i)->wRelayRelatedId2;
					pPsdCfgDtStr->OpenFourEditGroupDriveRelayId = (RelayData.pRelayScreenStr + i)->wRelayFourEditGroupOpenDoorId;
					pPsdCfgDtStr->OpenSixEditGroupDriveRelayId = (RelayData.pRelayScreenStr + i)->wRelaySixEditGroupOpenDoorId;
					pPsdCfgDtStr->OpenEightEditGroupDriveRelayId = (RelayData.pRelayScreenStr + i)->wRelayEightEditGroupOpenDoorId;
					pPsdCfgDtStr->wRelayDoorButtonId = (RelayData.pRelayScreenStr + i)->wRelayDoorButtonId;
					pPsdCfgDtStr->doorReopenRelayId = (RelayData.pRelayScreenStr + i)->doorReopenRelayId;
					pPsdCfgDtStr->departureConfirmRelayId = (RelayData.pRelayScreenStr + i)->departureConfirmRelayId;
					pPsdCfgDtStr->detectStartRelayId = (RelayData.pRelayScreenStr + i)->detectStartRelayId;
					pPsdCfgDtStr->detectStopRelayId = (RelayData.pRelayScreenStr + i)->detectStopRelayId;
					pPsdCfgDtStr->obstacleRelayId = (RelayData.pRelayScreenStr + i)->obstacleRelayId;
					pPsdCfgDtStr->gapDetMuLockRelayId = (RelayData.pRelayScreenStr + i)->gapDetMuLockRelayId;
					pPsdCfgDtStr->closeStateRelayId = (RelayData.pRelayScreenStr + i)->closeStateRelayId;
					pPsdCfgDtStr->ClearPasseSteadyLightRelayId = (RelayData.pRelayScreenStr + i)->wClearPasseSteadyLightRelayId;
					pPsdCfgDtStr->ClearPasseFlashLightRelayId = (RelayData.pRelayScreenStr + i)->wClearPasseFlashLightRelayId;
					pPsdCfgDtStr->ClearPassengerButtonRelayId = (RelayData.pRelayScreenStr + i)->wClearPassengerButtonRelayId;
					pPsdCfgDtStr->wCleFarePCBButtonRelayId = (RelayData.pRelayScreenStr + i)->wCleFarePCBButtonRelayId;
					pPsdCfgDtStr->wCleFarePDBFlaLigRelayId = (RelayData.pRelayScreenStr + i)->wCleFarePDBFlaLigRelayId;
					pPsdCfgDtStr->wPobIndicatorRelayId = (RelayData.pRelayScreenStr + i)->wPobBsdRelayId;
					pPsdCfgDtStr->wPcbIndicatorRelayId = (RelayData.pRelayScreenStr + i)->wPcbBsdRelayId;
					pPsdCfgDtStr->wVideoQkLight1RelayId = (RelayData.pRelayScreenStr + i)->wVideoQkLight1RelayId;
					pPsdCfgDtStr->wVideoQkLight2RelayId = (RelayData.pRelayScreenStr + i)->wVideoQkLight2RelayId;
					pPsdCfgDtStr->VirtualAttribute = PSD_VIRTUAL_ATTR_NO;/*初始化为非虚拟属性*/
					pPsdCfgDtStr->chPsdControlType = (RelayData.pRelayScreenStr + i)->chControlType;
					break;  /*屏蔽门继电器表中找到此屏蔽门，停止遍历*/
				}
				else
				{
					/*继续初始化*/
				}
			}
		}
		else
		{			
			rtnvalue = 0U;  /*PSD关联link无效，返回0失败*/
		}
	}

	return rtnvalue;
}


/*********************************************
*函数功能：初始化屏蔽门配置数据接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 PsdConfigDataStructInit(CHAR * FSName)
{
	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i = 0u;
	UINT16 j = 0u;	
	UINT8 sumTemp = 0u;
	UINT16 startSignalId = 0u;
	UINT16 startAxisSectionWId = 0u;   /*始端计轴区段link编号*/
	UINT16 endAxisSectionWId = 0u;     /*终端计轴区段link编号*/
	UINT16 linkId = 0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitRelay_ScreenStru (FSName);

	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	
		dquCICfgDtStr.PsdCfgDtStrLen =dsuDataLenStru.wScreenLen;

		for(i=0u;i<dsuDataLenStru.wScreenLen;i++)
		{
			if (i >= PSD_SUM_MAX)
			{
				rtnvalue = 0u;
			}
			else
			{
				rtnvalue = PsdCfgDtStruFromDquEmergStr(dsuStaticHeadStru.pScreenStru + i, &dquCICfgDtStr.PsdCfgDtStr[i]);
				if (1U == rtnvalue)
				{
					for (j = 0u; j < dsuDataLenStru.wRouteLen; j++)
					{/*遍历所有进路*/
						startSignalId = dsuStaticHeadStru.pRouteStru[j].wStartSignalId;/*获取进路始端信号机ID*/
						linkId = (dsuStaticHeadStru.pSignalStru + dsuSignalIndex[startSignalId])->wLkId;/*获取始端信号机所处Link的ID*/

						if (linkId == dsuStaticHeadStru.pScreenStru[i].wRelatLkId)
						{/*始端信号机所处Link的ID == 屏蔽门所处Link的ID*/
							sumTemp = dquCICfgDtStr.PsdCfgDtStr[i].RelatedOutStationRouteSum;
							dquCICfgDtStr.PsdCfgDtStr[i].RelatedOutStationRouteIdBuf[sumTemp] = dsuStaticHeadStru.pRouteStru[j].wId;
							dquCICfgDtStr.PsdCfgDtStr[i].RelatedOutStationRouteSum++;

							if (dquCICfgDtStr.PsdCfgDtStr[i].RelatedOutStationRouteSum >= RALATED_OUT_STATION_ROUTE_SUM_MAX)
							{
								rtnvalue = 0u;
								break;
							}
						}
					}

					if (1u == rtnvalue)
					{
						for (j = 0u; j < dsuDataLenStru.wAxleSgmtLen; j++)
						{/*遍历所有计轴区段数目*/
							startAxisSectionWId = dsuStaticHeadStru.pAxleSgmtStru[j].wOrgnLkId;  /*获取计轴区段始端link编号*/
							endAxisSectionWId = dsuStaticHeadStru.pAxleSgmtStru[j].wTmnlLkId;  /*获取计轴区段终端link编号*/
							/*始端计轴区段所处Link的ID == 终端计轴区段所处Link的ID*/
							if ((startAxisSectionWId == dsuStaticHeadStru.pScreenStru[i].wRelatLkId) && (endAxisSectionWId == dsuStaticHeadStru.pScreenStru[i].wRelatLkId))
							{
								/*找到屏蔽门所关联的物理区段的ID*/
								dquCICfgDtStr.PsdCfgDtStr[i].PsdRelationPhySecId = dsuStaticHeadStru.pAxleSgmtStru[j].wRelatePhysicalSgmtId;
								break;
							}

						}
					}
				}
			}
			if ((0u == rtnvalue) || (j == dsuDataLenStru.wAxleSgmtLen))
			{
				break;
			}
		}
		if(1u==rtnvalue)
		{
			for(i=0u;i<dsuDataLenStru.wScreenLen;i++)
			{
				for(j=0u;j<dsuDataLenStru.wScreenLen;j++)
				{
					if(i!=j)
					{
						if (dquCICfgDtStr.PsdCfgDtStr[i].PsdRelationPhySecId==dquCICfgDtStr.PsdCfgDtStr[j].PsdRelationPhySecId)
						{
							dquCICfgDtStr.PsdCfgDtStr[i].GroupPsdId=dquCICfgDtStr.PsdCfgDtStr[j].PsdId;
							break;
						}
					}
				}
				
			}
		}
	}

	return rtnvalue;
}

/*****
联锁表数据内容计算
*******************/


/*********************************************
*函数功能：初始化自动进路配置数据接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 AutoRouteConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u,j=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitLS_AutoRouteStru(FSName);
	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	/*电子地图初始化成功，继续执行*/
	else
	{	 
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.AutoRouteCfgDtStrLen = LSDataLen.LSAutoRouteStrLen;
		for(i=0u;i<LSDataLen.LSAutoRouteStrLen;i++)
		{
			if (i >= AUTO_ROUTE_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			dquCICfgDtStr.AutoRouteCfgDtStr[i].AutoRouteId = LSData.pLSAutoRouteStr[i].wId;
			dquCICfgDtStr.AutoRouteCfgDtStr[i].BelongCiId = (UINT8)dsuStaticHeadStru.pRouteStru[ dsuRouteIndex[LSData.pLSAutoRouteStr[i].szIncludeRouteId[0]]].wManageCI ;
			dquCICfgDtStr.AutoRouteCfgDtStr[i].RouteSum = 0u;
			for(j=0u;j<AR_MAX_INCLUDE_ROUTE_NUM;j++)
			{
				if(LSData.pLSAutoRouteStr[i].szIncludeRouteId[j] != 0u)
				{
					dquCICfgDtStr.AutoRouteCfgDtStr[i].RouteIdBuf[j] = LSData.pLSAutoRouteStr[i].szIncludeRouteId[j];
					dquCICfgDtStr.AutoRouteCfgDtStr[i].RouteSum += 1u;
				}
			}

		}
	}
	
	
	return rtnvalue;
}

/*********************************************
*函数功能：初始化自动折返进路配置数据接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 AutoReturnConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u,j=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitLS_AutoRtnRouteStru(FSName);
	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.AutoRtnRouteCfgDtStrLen = LSDataLen.LSAutoRtnRouteStrLen;
		for(i=0u;i<LSDataLen.LSAutoRtnRouteStrLen;i++)
		{
			if (i >= AUTO_RETURN_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			dquCICfgDtStr.AutoRtnRouteCfgDtStr[i].AutoReturnId = LSData.pLSAutoRtnRouteStr[i].wId;
			dquCICfgDtStr.AutoRtnRouteCfgDtStr[i].BelongCiId = (UINT8)dsuStaticHeadStru.pRouteStru[ dsuRouteIndex[LSData.pLSAutoRtnRouteStr[i].szIncludeRouteId[0]]].wManageCI ;
			dquCICfgDtStr.AutoRtnRouteCfgDtStr[i].RouteSum = 0u;
			for(j=0u;j<ARR_MAX_INCLUDE_ROUTE_NUM;j++)
			{
				if(LSData.pLSAutoRtnRouteStr[i].szIncludeRouteId[j] != 0u)
				{
					dquCICfgDtStr.AutoRtnRouteCfgDtStr[i].RouteIdBuf[j] = LSData.pLSAutoRtnRouteStr[i].szIncludeRouteId[j];
					dquCICfgDtStr.AutoRtnRouteCfgDtStr[i].RouteSum += 1u;
				}
			}
		}
	}
	return rtnvalue;
}

/*********************************************
*函数功能：初始化反向进路接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 ReverseRouteCfgDtStructInit(CHAR * FSName)
{

	UINT8 retValue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u,j=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitLS_ReverseRouteStru(FSName);
	if(0u == callFun)
	{/*电子地图||反向进路初始化失败，函数失败退出*/
		retValue = 0u;
	}
	else
	{
		retValue = 1u;
	}

	if (1u == retValue)
	{/*电子地图||反向进路初始化成功，继续执行*/	 
		dquCICfgDtStr.ReverseRouteCfgDtStrLen = LSDataLen.LSReverseRouteStrLen;
		for(i=0u;i<LSDataLen.LSReverseRouteStrLen;i++)
		{
			if (i >= REVERSE_ROUTE_SUM_MAX)
			{
				retValue = 0u;
				break;
			}
			dquCICfgDtStr.ReverseRouteCfgDtStr[i].ReverseRouteId = LSData.pLSReverseRouteStr[i].wId;
			dquCICfgDtStr.ReverseRouteCfgDtStr[i].BelongCiId = (UINT8)dsuStaticHeadStru.pRouteStru[ dsuRouteIndex[LSData.pLSReverseRouteStr[i].wId]].wManageCI ;
			dquCICfgDtStr.ReverseRouteCfgDtStr[i].AutoSigRouteIncludeSum= 0u;
			for(j=0u;j<RR_MAX_INCLUDE_ROUTE_NUM;j++)
			{
				if(LSData.pLSReverseRouteStr[i].szIncludeRouteId[j] != 0u)
				{
					dquCICfgDtStr.ReverseRouteCfgDtStr[i].AutoSigRouteIdBuf[j] = LSData.pLSReverseRouteStr[i].szIncludeRouteId[j];
					dquCICfgDtStr.ReverseRouteCfgDtStr[i].AutoSigRouteIncludeSum += 1u;
				}
			}

		}	 
	}

	return retValue;
}



/*********************************************
*函数功能：初始化组合进路配置数据接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 LongRouteConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u,j=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitLS_LongRouteStru(FSName);
	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.LongRouteCfgDtStrLen =LSDataLen.LSLongRouteStrLen;
		for(i=0u;i<LSDataLen.LSLongRouteStrLen;i++)
		{
			if (i >= ROUTE_LONG_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			dquCICfgDtStr.LongRouteCfgDtStr[i].LongRouteId = LSData.pLSLongRouteStr[i].wId;
			dquCICfgDtStr.LongRouteCfgDtStr[i].SubRouteSum = 0u;
			for(j=0u;j<LR_MAX_INCLUDE_ROUTE_NUM;j++)
			{
				if(LSData.pLSLongRouteStr[i].szIncludeRouteId[j] != 0u)
				{
					dquCICfgDtStr.LongRouteCfgDtStr[i].SubRouteIdBuf[j] = LSData.pLSLongRouteStr[i].szIncludeRouteId[j];
					dquCICfgDtStr.LongRouteCfgDtStr[i].SubRouteSum += 1u;
				}
			}

		}
	}
	
	return rtnvalue;
}

/*********************************************
*函数功能：初始化非进路调车数据结构体----对外结构体
*参数说明：FSName逻文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 NonRouteConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitLS_NoRouteDcStru(FSName);
	callFun *= InitLS_DDXHStru(FSName);
	callFun *= InitLS_SignalStruct(FSName);
	callFun *= InitRelay_NoRouteDcStru(FSName);
	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{/*电子地图初始化成功，继续执行*/
		rtnvalue = 1u;	 
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.NonRouteCfgDtStrLen = LSDataLen.LSNoRouteDcStrLen;
		for(i=0u;i<LSDataLen.LSNoRouteDcStrLen;i++)
		{
			if (i >= NONROUTE_ID_NUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			rtnvalue = NonRouteCfgDtStruFrmLSStr(LSData.pLSNoRouteDcStr+i,&dquCICfgDtStr.NonRouteCfgDtStr[i]);
			if (0u == rtnvalue)
			{
				break;
			}
		}
	}
	
	return rtnvalue;
}

/*********************************************
*函数功能：非进路配置数据结构体计算
*参数说明：pLSNoRouteDcStr非进路结构体指针
pNonRouteCfgDtStr非进路配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 NonRouteCfgDtStruFrmLSStr( LS_NoRouteDcStru * pLSNoRouteDcStr,NonRouteConfigDataStruct * pNonRouteCfgDtStr)
{
	UINT16 i=0u,j=0u,k=0u;
	UINT8 rtnvalue = 0u;
	UINT8 flagBreak = 0u;/*临时变量，中断标志*/
	UINT8 isEachInvFlag = 0U;

	/*入口参数防护*/
	if((NULL == pLSNoRouteDcStr) || (NULL == pNonRouteCfgDtStr))
	{
		/*返回失败*/
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}
	if (1u == rtnvalue)
	{
	pNonRouteCfgDtStr->NonRouteId = (UINT8)pLSNoRouteDcStr->wId;
	/*计算信号机组*/
	pNonRouteCfgDtStr->SignalSum = 0u;

		for(i=0u;i<LSDataLen.LSSignalStrLen;i++)
		{
			if(pLSNoRouteDcStr->wIncludeSignal == LSData.pLSSignalStr[i].wId)
			{
				for(j=0u;j<MAX_INCLUDE_SIGNAL_NUM;j++)
				{
					if(0u!= LSData.pLSSignalStr[i].wSignalId[j])
					{
						pNonRouteCfgDtStr->SignalIdBuf[j] = LSData.pLSSignalStr[i].wSignalId[j];
						pNonRouteCfgDtStr->SignalSum++;
					}
				}

			}
		}


		/*计算物理区段数据*/
		pNonRouteCfgDtStr->PhySectionSum = 0u;
		for(i=0u;i<LSDataLen.LSPhyAndChkStaStrLen;i++)
		{
			if(pLSNoRouteDcStr->wWuliJianchaType == LSData.pLSPhyAndChkStaStr[i].wId)
			{
				for(j=0u;j<MAX_INCLUDE_PHYSC_SGMT_NUM;j++)
				{
					if(0u !=LSData.pLSPhyAndChkStaStr[i].wPhysicalSgmtId[j])
					{
						pNonRouteCfgDtStr->NonRoutePhySecStru[j].PhySectionId = LSData.pLSPhyAndChkStaStr[i].wPhysicalSgmtId[j];
						if (0xAAu == LSData.pLSPhyAndChkStaStr[i].wCheckState[j])
						{/*数据意思为需检查是否空闲或占用*/

							/*代码翻译为需检查区段为空闲*/
							pNonRouteCfgDtStr->NonRoutePhySecStru[j].CheckState = NONROUTE_SECTION_OCCUPY_CHECK_NO;

						}
						else if (0x55u == LSData.pLSPhyAndChkStaStr[i].wCheckState[j])
						{/*数据意思为无需检查占用情况*/

							/*代码翻译为需检查区段为占用*/
							pNonRouteCfgDtStr->NonRoutePhySecStru[j].CheckState = NONROUTE_SECTION_OCCUPY_CHECK_YES;
						}
						else
						{
							/*无操作*/
						}
						pNonRouteCfgDtStr->PhySectionSum++;
					}
				}
			}
		}
	}

	if (1u == rtnvalue)
	{
		flagBreak = 0u;
		/*计算道岔数据*/
		pNonRouteCfgDtStr->SwitchSum = 0u;
		for(i=0u;i<NR_MAX_INCLUDE_POINT_NUM;i++)
		{
			if(0u != pLSNoRouteDcStr->wIncludePoint[i])
			{
				pNonRouteCfgDtStr->NonRouteSwitStru[i].SwitchId = pLSNoRouteDcStr->wIncludePoint[i];
				pNonRouteCfgDtStr->NonRouteSwitStru[i].SwitchPos = (UINT8)pLSNoRouteDcStr->wIncludePointSta[i];
				pNonRouteCfgDtStr->SwitchSum++;
			}
		}
		/*非进路防护道岔数据初始化*/
		if((pLSNoRouteDcStr->wFHPointId != 0u) && (UINT16_MAX != pLSNoRouteDcStr->wFHPointId))
		{
			pNonRouteCfgDtStr->ProtectSwitchSum = 0u;/*防护道岔数量初始化为0*/
			for(i=0u;i<LSDataLen.LSFHDaoChaStrLen;i++)
			{
				if((LSData.pLSFHDaoChaStr+i)->wId == pLSNoRouteDcStr->wFHPointId)
				{
					for(j=0u;j<FHDC_MAX_INCLUDE_POINT_NUM;j++)
					{
						if (pNonRouteCfgDtStr->ProtectSwitchSum <NONROUTE_PROTECTSWI_SUM_MAX)
						{
							if((0u != (LSData.pLSFHDaoChaStr+i)->wPointId[j]) && (UINT16_MAX != (LSData.pLSFHDaoChaStr+i)->wPointId[j]))
							{
								pNonRouteCfgDtStr->NonRouteProtectSwitchStru[pNonRouteCfgDtStr->ProtectSwitchSum].ProtectSwitchId = (LSData.pLSFHDaoChaStr+i)->wPointId[j];
								pNonRouteCfgDtStr->NonRouteProtectSwitchStru[pNonRouteCfgDtStr->ProtectSwitchSum].ProtectPosition =(UINT8)(LSData.pLSFHDaoChaStr+i)->wPointSta[j];
								pNonRouteCfgDtStr->ProtectSwitchSum++;
							}
						}
						else
						{
							flagBreak = 1u;
						}

						if (1u == flagBreak)
						{/*退出最里层循环*/
							break;
						}
					}
				}
				if (1u == flagBreak)
				{/*退出中间层循环*/
					break;
				}
			}
		}
			
		
		if (1u == flagBreak)
		{
			rtnvalue = 0u;
		}

	}

	if (1u == rtnvalue)
	{
		/*计算敌对信号数据*/
		pNonRouteCfgDtStr->EnemySignalSum = 0u;
		for (i = 0; i < NR_MAX_INCLUDE_DDXH_NUM; i++)
		{
			if (pLSNoRouteDcStr->wDiDuiXinhao[i] != 0u)
			{
				pNonRouteCfgDtStr->EnemySignalSum++;
			}
		}
	}

	if (1u == rtnvalue)
	{
		flagBreak = 0u;
		for(i=0u;i<pNonRouteCfgDtStr->EnemySignalSum;i++)
		{
			for(j=0u;j<LSDataLen.LSDDXHStrLen;j++)
			{
				if (i < NR_MAX_INCLUDE_DDXH_NUM)
				{
					if(pLSNoRouteDcStr->wDiDuiXinhao[i] == LSData.pLSDDXHStr[j].wId)
					{
						pNonRouteCfgDtStr->EnemySignalStru[i].EnemySigId = LSData.pLSDDXHStr[j].wDiDuiXinHaoId;
						pNonRouteCfgDtStr->EnemySignalStru[i].SwitchSum = 0u;
						for(k=0u;k<NONROUTE_CONDITION_SWITCH_SUM_MAX;k++)
						{
							if(0u != LSData.pLSDDXHStr[j].wPointId[k])
							{
								pNonRouteCfgDtStr->EnemySignalStru[i].EnemySwitchStru[k].SwitchId = LSData.pLSDDXHStr[j].wPointId[k];
								pNonRouteCfgDtStr->EnemySignalStru[i].EnemySwitchStru[k].SwitchPos = (UINT8)LSData.pLSDDXHStr[j].wPointSta[k];
								pNonRouteCfgDtStr->EnemySignalStru[i].SwitchSum++;
							}
							
						}
					}
				}
				else
				{
					flagBreak = 1u;
				}
				if (1u == flagBreak)
				{/*退出中间层循环*/
					break;
				}
				
			}
			if (1u == flagBreak)
			{/*退出最外层循环*/
				break;
			}
		}
		if (1u == flagBreak)
		{
			rtnvalue = 0u;
		}
	}
	
	if (1u == rtnvalue)
	{
		/*计算申请/同意试车继电器*/
		for (i = 0u; i < RelayDataLen.RelayNoRouteDcStrLen; i++)
		{
			if (pLSNoRouteDcStr->wId == RelayData.pRelayNoRouteDcStr[i].wId)
			{
				pNonRouteCfgDtStr->ApplyTryTrainRelayId = RelayData.pRelayNoRouteDcStr[i].wRelayShenQingScId;
				pNonRouteCfgDtStr->AgreeTryTrainRelayId = RelayData.pRelayNoRouteDcStr[i].wRelayTongYiScId;
				pNonRouteCfgDtStr->DrvApplyTryTrainRelayId = RelayData.pRelayNoRouteDcStr[i].wRelayDrvShiCheShengQingId;
				pNonRouteCfgDtStr->ColAgreeTryTrainRelayId = RelayData.pRelayNoRouteDcStr[i].wRelayColTongYiScId;
			}
		}

		/*非进路侵限区段结构体*/

		if (1u == rtnvalue)
		{
			pNonRouteCfgDtStr->IntruPhySecSum = 0u;

			isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION);

			/*采用旧版本进路侵限条件*/
			if (FUNC_SWITCH_OFF == isEachInvFlag)
			{
				for (i = 0u; i < ROUTE_MAX_QXQD_NUM; i++)
				{
					if (0u != pLSNoRouteDcStr->wIntrudePhySecId[i])
					{
						pNonRouteCfgDtStr->IntruPhySecSum++;
						pNonRouteCfgDtStr->IntruPhySecStru[i].SwitchSum = 0u;
						for (j = 0u; j < LSDataLen.LSIntruPhySecStrLen; j++)
						{
							if (LSData.pLSIntruPhySecStr[j].wId == pLSNoRouteDcStr->wIntrudePhySecId[i])
							{
								/*仅当进路表中的侵限区段及条件道岔的ID标号与侵限区段及条件道岔表中的ID相同时,
								将侵限区段及条件道岔表中的侵限区段ID赋值给 结构体的SectionId*/
								pNonRouteCfgDtStr->IntruPhySecStru[i].SectionId = LSData.pLSIntruPhySecStr[j].wIntrudePhySecId;
								for (k = 0u; k < QINXIAN_SWITCH_MAX_NUM; k++)
								{
									if (0u != LSData.pLSIntruPhySecStr[j].wPointId[k])
									{
										pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[k].SwitchId = LSData.pLSIntruPhySecStr[j].wPointId[k];
										pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[k].SwitchPos = (UINT8)LSData.pLSIntruPhySecStr[j].wPointSta[k];
										pNonRouteCfgDtStr->IntruPhySecStru[i].SwitchSum++;
									}
								}

							}
						}
					}
				}
			}
			else
			{
				/*遍历非进路包含的所有物理区段*/
				for (i = 0U; i < pNonRouteCfgDtStr->PhySectionSum; i++)
				{
					/*遍历侵限区段及道岔表*/
					for (j = 0; j < LSDataLen.LSIntruPhySecStrLen; j++)
					{
						if ((LSData.pLSIntruPhySecStr[j].belongPhySecId == pNonRouteCfgDtStr->NonRoutePhySecStru[i].PhySectionId) && (0U != LSData.pLSIntruPhySecStr[j].belongPhySecId))
						{
							/*数据防溢出*/
							if (NONROUTE_ENEMY_SIGNAL_SUM_MAX > pNonRouteCfgDtStr->IntruPhySecSum)
							{
								pNonRouteCfgDtStr->IntruPhySecStru[pNonRouteCfgDtStr->IntruPhySecSum].SectionId = LSData.pLSIntruPhySecStr[j].wIntrudePhySecId;
								for (k = 0u; k < QINXIAN_SWITCH_MAX_NUM; k++)
								{
									if (0u != LSData.pLSIntruPhySecStr[j].wPointId[k])
									{
										pNonRouteCfgDtStr->IntruPhySecStru[pNonRouteCfgDtStr->IntruPhySecSum].ConditionSwitchStru[k].SwitchId = LSData.pLSIntruPhySecStr[j].wPointId[k];
										pNonRouteCfgDtStr->IntruPhySecStru[pNonRouteCfgDtStr->IntruPhySecSum].ConditionSwitchStru[k].SwitchPos = (UINT8)LSData.pLSIntruPhySecStr[j].wPointSta[k];
										pNonRouteCfgDtStr->IntruPhySecStru[pNonRouteCfgDtStr->IntruPhySecSum].SwitchSum++;
									}
								}

							}
							else
							{
								/*非进路侵限数量超出范围，初始化失败*/
								rtnvalue = 0U;
								break;
							}
							pNonRouteCfgDtStr->IntruPhySecSum++;

							
						}
					}
					if (0U == rtnvalue)
					{
						debug_infor_printf((const)"[NonRouteInv] NonRouteID:%d ERROR:IntruPhySecSum Is Exceed MAX\n", pNonRouteCfgDtStr->NonRouteId);
						break;
					}
					else
					{
						/*继续遍历*/
					}
				}
			}

			/*在日志中打印非进路侵限关系*/
			if ((0U < pNonRouteCfgDtStr->IntruPhySecSum) && (1U == rtnvalue))
			{
				for (i = 0U; i < pNonRouteCfgDtStr->IntruPhySecSum; i++)
				{
					debug_infor_printf((const)"[NonRouteInv] NonRouteID:%d, InvSecID:%d, SwitchID:%d-%d-%d-%d-%d-%d, SwitchState:%d-%d-%d-%d-%d-%d\n", pNonRouteCfgDtStr->NonRouteId, pNonRouteCfgDtStr->IntruPhySecStru[i].SectionId,
						pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[0].SwitchId, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[1].SwitchId, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[2].SwitchId, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[3].SwitchId, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[4].SwitchId, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[5].SwitchId,
						pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[0].SwitchPos, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[1].SwitchPos, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[2].SwitchPos, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[3].SwitchPos, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[4].SwitchPos, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[5].SwitchPos);
				}
			}
			else
			{
				;
			}
		}
	}

	return rtnvalue;
}



/*********************************************
*函数功能：初始化表示报警灯配置数据
*参数说明：FSName逻文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 IndicatorConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u,j=0u;
	UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);

	callFun = InitRelay_BaoJingDengStru(FSName);
	callFun *= InitRelay_NoReturnStru(FSName);
	/*初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{	 
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.IndctCfgDtStrLen = RelayDataLen.RelayBjdStrLen;
		dquCICfgDtStr.NonReturnCfgSum = RelayDataLen.RelayNoRtnStruLen;
		for(i=0u;i<RelayDataLen.RelayBjdStrLen;i++)
		{
			if (i >= INDICATOR_MAX_SIZE)
			{
				rtnvalue = 0u;
				break;
			}

			dquCICfgDtStr.IndctCfgDtStr[i].IndicatorId = RelayData.pRelayBjdStr[i].wId;				/*修改ID作为索引，不用原来的报警灯ID，会和类型重复*/
			dquCICfgDtStr.IndctCfgDtStr[i].IdSum = 0u;
			dquCICfgDtStr.IndctCfgDtStr[i].AvalibleFlag = RelayData.pRelayBjdStr[i].wBjdYouXiao;

			for(j=0;j<BJD_MAX_NUM;j++)
			{
				if(RelayData.pRelayBjdStr[i].wBjdJdqId[j] != 0u)
				{
					dquCICfgDtStr.IndctCfgDtStr[i].IdBuf[dquCICfgDtStr.IndctCfgDtStr[i].IdSum] = RelayData.pRelayBjdStr[i].wBjdJdqId[j];
					dquCICfgDtStr.IndctCfgDtStr[i].IdSum++;
				}

			}


			dquCICfgDtStr.IndctCfgDtStr[i].IndicatorType = (UINT8)RelayData.pRelayBjdStr[i].wBjdID;		/*报警灯ID作为类型*/
			dquCICfgDtStr.IndctCfgDtStr[i].BjdDeviceId = RelayData.pRelayBjdStr[i].cBjdDevId;
		}

		for (i = 0U; i < RelayDataLen.RelayNoRtnStruLen; i++)
		{
			if (i >= NON_AUTO_RETURN_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			dquCICfgDtStr.NonAutoReturnCfgDataSt[i].NonAutoReturnId = RelayData.pRelayNoRtnStru[i].wId;

			/*遍历表示灯*/
			for (j = 0U; j < RelayDataLen.RelayBjdStrLen; j++)
			{
				if (RelayData.pRelayNoRtnStru[i].wWuRenReturnRelayId == RelayData.pRelayBjdStr[j].wId)
				{

					dquCICfgDtStr.NonAutoReturnCfgDataSt[i].BelongCiId = (UINT8)RelayData.pRelayBjdStr[j].wBelongCiId;
					dquCICfgDtStr.NonAutoReturnCfgDataSt[i].BelongVirCiId = RelayData.pRelayBjdStr[j].wBelongVirCIid;
				}
			}
			dquCICfgDtStr.NonAutoReturnCfgDataSt[i].NonAutoRtnLghtRlyId = RelayData.pRelayNoRtnStru[i].wWuRenReturnDisRelayId;
			dquCICfgDtStr.NonAutoReturnCfgDataSt[i].NonAutoRtnRlyId = RelayData.pRelayNoRtnStru[i].wWuRenReturnRelayId;
		}
	}
	
	if(1u == rtnvalue)
	{
		if(FUNC_SWITCH_ON == includeVirFlag)
		{
			rtnvalue = InitBaojingdeng_UseVirCI();
		}	
	}
	return rtnvalue;
}


/*********************************************
*函数功能：计算联锁防淹门数据
*参数说明：pEmapFloodGateStr 联锁防淹门结构体指针(电子地图)
*		   pRouteCfgDtStr防淹门配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 FloodGateCfgDtStruFrmLSStr(DSU_FLOOD_GATE_STRU * pEmapFloodGateStr,FloodGateConfigDataStruct * pFloodGateCfgDtStr)
{
	UINT16 i = 0u;/*临时索引*/
	UINT16 jj = 0u;/*临时索引*/
	UINT16 ii = 0U;
	UINT16 kk = 0U;
	UINT16 floodLinkId = 0u;/*防淹门所在Link ID*/
	UINT8 rtVal = CI_ERROR;
	UINT16 linkIndex = 0u;

	if((NULL != pEmapFloodGateStr) &&(NULL != pFloodGateCfgDtStr))
	{
		rtVal = CI_SUCCESS;
	}
	else
	{
		rtVal = CI_ERROR;
	}
	if (CI_SUCCESS == rtVal)
	{
		/*从电子地图中获取防淹门信息*/


		/*获取防淹门ID*/
		pFloodGateCfgDtStr->FloodGateId = pEmapFloodGateStr->wId;

		/*计算所属联锁*/
		floodLinkId = pEmapFloodGateStr->wFloodGateLinkID;/*防淹门所在Link ID*/
		rtVal = GetDsuLinkIndexNum(floodLinkId, &linkIndex);
		if (CI_SUCCESS == rtVal)
		{
			pFloodGateCfgDtStr->BelongCiId = (UINT8)dsuStaticHeadStru.pLinkStru[linkIndex].wManagePhysicalCI;/*联锁id赋值*/
			pFloodGateCfgDtStr->BelongVirId = (UINT8)dsuStaticHeadStru.pLinkStru[linkIndex].wBelongVirtualCI;/*联锁id赋值*/

			/*防淹门关联接近区域计轴区段信息*/
			pFloodGateCfgDtStr->AccessAxisNum = pEmapFloodGateStr->wAccessAxisNum;
			if (pFloodGateCfgDtStr->AccessAxisNum < FLOOD_GATE_ACCESS_AXIS_NUM_MAX)
			{
				for (jj = 0U; jj < pFloodGateCfgDtStr->AccessAxisNum; jj++)
				{
					pFloodGateCfgDtStr->AccessAxisId[jj] = pEmapFloodGateStr->wAccessAxisId[jj];
				}
			}
			else
			{
				rtVal = CI_ERROR;		/*数据配置接近区域计轴区段超限，返回初始化失败*/
			}
		}

		if (CI_SUCCESS == rtVal)
		{
			/*防淹门关联防护区域计轴区段信息*/
			pFloodGateCfgDtStr->ProtectAxisNum = pEmapFloodGateStr->wProtectAxisNum;
			if (pFloodGateCfgDtStr->ProtectAxisNum < FLOOD_GATE_PROTECT_AXIS_NUM_MAX)
			{
				for (jj = 0U; jj < pFloodGateCfgDtStr->ProtectAxisNum; jj++)
				{
					pFloodGateCfgDtStr->ProtectAxisId[jj] = pEmapFloodGateStr->wProtectAxisId[jj];
				}
			}
			else
			{
				rtVal = CI_ERROR;		/*数据配置防护区域计轴区段超限，返回初始化失败*/
			}
		}

		if (CI_SUCCESS == rtVal)
		{
			/*防淹门关联防护区域物理区段信息*/
			pFloodGateCfgDtStr->ProtectPhySecNum = 0U;
			for (jj = 0U; jj < pEmapFloodGateStr->wProtectAxisNum; jj++)
			{
				for (ii = 0U; ii < pFloodGateCfgDtStr->ProtectPhySecNum; ii++)
				{
					if (pFloodGateCfgDtStr->ProtectPhySecIdBuf[ii] == dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pEmapFloodGateStr->wProtectAxisId[jj]]].wRelatePhysicalSgmtId)
					{
						break;		/*已经添加过的物理区段*/
					}
					else
					{

					}
				}

				if ((ii == pFloodGateCfgDtStr->ProtectPhySecNum) && (pFloodGateCfgDtStr->ProtectPhySecNum < FLOOD_GATE_PROTECT_PHYSECTION_NUM_MAX))
				{
					pFloodGateCfgDtStr->ProtectPhySecIdBuf[pFloodGateCfgDtStr->ProtectPhySecNum] = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pEmapFloodGateStr->wProtectAxisId[jj]]].wRelatePhysicalSgmtId;
					pFloodGateCfgDtStr->ProtectPhySecNum++;
				}
			}

			/*物理区段所在防淹门ID*/
			for (ii = 0U; ii < dquCICfgDtStr.PsclSgmtCfgDtStrLen; ii++)
			{
				/*查找所有防淹门的防护区段与物理区段相同对应的所有防淹门ID*/
				for (jj = 0U; jj < pFloodGateCfgDtStr->ProtectPhySecNum; jj++)
				{
					if (dquCICfgDtStr.PsclSgmtCfgDtStr[ii].PhysicalSectionId == pFloodGateCfgDtStr->ProtectPhySecIdBuf[jj])
					{/*防淹门所在防护物理区段id赋值给物理区段结构体*/
						for (kk = 0U; kk < dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateSum; kk++)
						{
							if (dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateId[kk] == pFloodGateCfgDtStr->FloodGateId)
							{
								break;		/*已经添加过的防淹门ID不再添加*/
							}
							else
							{
								;		/*继续添加*/
							}
						}
						if ((kk == dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateSum) && (FLOOD_GATE_SUM_MAX > dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateSum))
						{
							dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateId[dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateSum] = pFloodGateCfgDtStr->FloodGateId;
							dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateSum++;
						}
					}
				}
			}

			/*防淹门关联接近区域物理区段信息*/
			pFloodGateCfgDtStr->AccessPhySecNum = 0U;
			for (jj = 0U; jj < pEmapFloodGateStr->wAccessAxisNum; jj++)
			{
				for (ii = 0U; ii < pFloodGateCfgDtStr->AccessPhySecNum; ii++)
				{
					if (pFloodGateCfgDtStr->AccessPhySecStru[ii].AccessPhySecId == dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pEmapFloodGateStr->wAccessAxisId[jj]]].wRelatePhysicalSgmtId)
					{
						break;		/*已经添加过的物理区段*/
					}
					else
					{

					}
				}

				if ((ii == pFloodGateCfgDtStr->AccessPhySecNum) && (pFloodGateCfgDtStr->AccessPhySecNum < FLOOD_GATE_ACCESS_PHYSECTION_NUM_MAX))
				{
					pFloodGateCfgDtStr->AccessPhySecStru[pFloodGateCfgDtStr->AccessPhySecNum].AccessPhySecId = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pEmapFloodGateStr->wAccessAxisId[jj]]].wRelatePhysicalSgmtId;
					pFloodGateCfgDtStr->AccessPhySecStru[pFloodGateCfgDtStr->AccessPhySecNum].AccessPhySecDir = pEmapFloodGateStr->wAccessAxisDir[jj];
					pFloodGateCfgDtStr->AccessPhySecNum++;
				}
			}

			for (i = 0u; i < RelayDataLen.RelayFloodGateStrLen; i++)
			{
				if (i >= FLOOD_GATE_SUM_MAX)
				{
					rtVal = CI_ERROR;
					break;
				}
				if (pFloodGateCfgDtStr->FloodGateId == RelayData.pRelayFloodGateStr[i].wFloodGateId)
				{
					pFloodGateCfgDtStr->CloseApplyRelayId = RelayData.pRelayFloodGateStr[i].wCloseApplyRelayId;
					pFloodGateCfgDtStr->OpenLockRelayId = RelayData.pRelayFloodGateStr[i].wOpenCloseRelayId;
					pFloodGateCfgDtStr->AllowCloseRelayId = RelayData.pRelayFloodGateStr[i].wAllowRequestRelayId;
#if 0
					/*放弃这种方式计算防淹门所属联锁，因为非防淹门所在集中区计算防淹门所属联锁会失败*/
					if (RelayData.pRelayFloodGateStr[i].wOpenCloseRelayId != 0u &&
						RelayData.pRelayFloodGateStr[i].wOpenCloseRelayId != 0xffffu)
					{/*防淹门开启锁定继电器不为0时，取开启锁定继电器的所属联锁ID，赋值给防淹门的所属联锁ID*/
						for (jj = 0u; jj < RelayDataLen.RelayCfgDtStrLen; jj++)
						{
							if (RelayData.pRelayFloodGateStr[i].wOpenCloseRelayId == RelayData.pRelayCfgDtStr[jj].RelayId)
							{
								pFloodGateCfgDtStr->BelongCiId = RelayData.pRelayCfgDtStr[jj].BelongCiId;
								break;
							}
						}
					}
#endif
					break;
				}
			}
		}
	}
	return rtVal;
}


/*********************************************
*函数功能：计算联锁进路数据
*参数说明：pLSRouteStr联锁进路结构体指针
pRouteCfgDtStr进路配置数据结构体指针
*返回值：0，失败；1，成功
*mod by qw.liu 2022-02-22 增加点式接近区段，点式触发区段由CBTC接近区段、触发区段计算得来
*********************************************/
UINT8 RouteCfgDtStruFrmLSRouteStr( LS_RouteStruct * pLSRouteStr,RouteConfigDataStruct * pRouteCfgDtStr, OverlapConfigDataStruct* overlapStr)
{
	UINT16 i=0u,j=0u,k=0u,m=0u,n=0u;
	UINT16 devId = 0u;
	UINT16 lastDevId = 0u;/*最后一个计轴区段*/
	UINT8 index=0u;
	UINT8 findFlag = 0U;
	UINT8 rtnvalue = CI_ERROR;
	UINT8 flagBreak = 0u;
	UINT8 findRouteProtectDirChangeFlag = 0u;/*找到进路保护区段方向变化点*/
	/*统计有效照查物理区段ID*/
	UINT8 zhaoChaPhySecNum = 0u;
	UINT8 iIndex=0u;
	/*计算离去物理区段ID*/
	UINT16 routeId = 0u;           /*进路ID */
	UINT8 routeDir = 0u;           /*进路方向 */
	UINT16 axleSgmtNum = 0u;       /*进路包含的计轴区段数目*/
	UINT16 axleSgmtId = 0u;        /*进路的最后一个计轴区段的ID*/
	/*进路相关信号机ID*/
	UINT16 routeStartSignal = 0u;  /*进路始端信号机*/
	UINT16 routeEndSignal = 0u;    /*进路终端信号机*/
	DSU_ROUTE_STRU* pDsuRouteStr = NULL;
	DSU_LOGIC_SGMT_STRU* pLogicSgmeStr = NULL;
	DSU_AXLE_SGMT_STRU* pAxleSgmtStr = NULL;
	DSU_BLOC_ACCESS_LINK_STRU* pBlocAccessStr = NULL;
	DSU_CBTC_ACCESS_LINK_STRU* pCbtcAccessStr = NULL;
	DSU_CBTC_TRG_AREA_STRU*  pCbtcTriggerStr = NULL;   /*CBTC触发区段结构体*/
	DSU_PROTECT_LINK_STRU* pProtectStru = NULL;/*保护区段*/
	UINT8 lineIdentity;
	UINT8 ciType = 0u;/*联锁类型*/
	UINT16 firstAxleSecId = 0u;/*第一个计轴区段ID*/
	UINT16 lastAxleSecId = 0u;/*最后一个计轴区段ID*/
	UINT16 axleNum = 0u;/*计轴区段数量*/
	DSU_AXLE_SGMT_STRU *pDsuAxleSgmt = NULL;/*计轴区段*/
	DSU_AXLE_SGMT_STRU *pDsuRouteLastAxleSgmt = NULL;/*计轴区段*/
	DSU_LINK_STRU *pDsuLink = NULL;/*LINK*/
	DSU_LINK_STRU *pDsuLinkNext = NULL;/*下一LINK*/
	UINT16 firstProtectId = 0u;/*第一个保护区段ID*/
	DSU_AXLE_SGMT_STRU * pProtectFirstAxleSec = NULL;/*保护区段第一个计轴区段结构体*/
	DSU_LINK_STRU *pDsuProtectFstAxleSecStartLink = NULL;/*保护区段第一计轴区段起点LINK*/
	DSU_LINK_STRU *pDsuProtectFstAxleSecEndLink = NULL;/*保护区段第一计轴区段终点LINK*/
	DSU_LINK_STRU *pRouteLastLink = NULL;/*进路最后一个LINK*/
	UINT8 baseDir = 0u;/*基准方向*/
	UINT16 lkIndex = 0u;/*link索引*/
	UINT16 axleSecIndex = 0u;/*计轴区段索引*/
	UINT16 dirChangeLinkId = 0u;/*方向变化点LINK*/
	UINT8 flagFind = 0u;
	UINT16 dirChangeAxleSecId = 0u;/*方向变化点计轴区段ID*/
	UINT16 dirChangePhySecId = 0u;/*方向变化点物理区段ID*/
	UINT16 dirChangePhySecIndex = 0u;/*方向变化点物理区段索引*/
	UINT16 axleSecId = 0u;/*计轴区段ID*/
	DSU_LINK_STRU* pRouteIncLinkStru = NULL;  /*进路包含的link结构体*/
	DSU_LINK_STRU * pRouteFirstLinkStru = NULL;
	DSU_LINK_STRU * pRouteSecondLinkStru = NULL;
	UINT16 zCPhySecId= 0u;
	UINT8 checkResult = 0u;
	UINT16 signalIndex = 0u;
	UINT8 overlapIndex = 0u;
	RouteTriggerPhySectionStruct* pRouteTriggerPhySecStr = NULL;
	UINT8 chCheckLogIdSameFlag = 0U;
	UINT8 isEachInvFlag = 0U;
	UINT16 wLgcSecIndex = 0U; /*逻辑区段索引*/
	UINT8 chLocalCiPattern = 0u; /*本CI模式*/

	lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*??????:0x55:????;0xAA:????*/

	/*入口参数防护*/
	if((NULL != pLSRouteStr) && (NULL != pRouteCfgDtStr))
	{
		rtnvalue = CI_SUCCESS;

		pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[pLSRouteStr->wRouteId];

		pRouteCfgDtStr->RouteId = pLSRouteStr->wRouteId;
		pRouteCfgDtStr->BelongCiId = (UINT8)pDsuRouteStr->wManageCI;

		if (pLSRouteStr->wDir == dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown)
		{
			pRouteCfgDtStr->RouteDirection = CI_SYSTEM_DIRECTION_DOWN;
		} 
		else
		{
			pRouteCfgDtStr->RouteDirection = CI_SYSTEM_DIRECTION_UP;
		}

		pRouteCfgDtStr->LeadProperty = pLSRouteStr->wYinDao;

		pRouteCfgDtStr->RouteSignalOpenColor = (UINT8)pLSRouteStr->wStarSignalClr;
		pRouteCfgDtStr->LeadOpenColor = (UINT8)pLSRouteStr->wStarSigYinDaoClr;

		/*去电子地图里去始端和终端信号机*/
		pRouteCfgDtStr->StartSignalId = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[pLSRouteStr->wRouteId]].wStartSignalId;
		pRouteCfgDtStr->EndSignalId = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[pLSRouteStr->wRouteId]].wEndSignalId;
		pRouteCfgDtStr->AirShaftRouteType = 0u;  /*默认不是风井进路*/
		pRouteCfgDtStr->AutoTriggerType = 0u;  /*默认不是自动触发进路*/
		/*进路所属虚拟联锁*/
		if(SIGNALINDEXNUM >= (pRouteCfgDtStr->StartSignalId))
		{
			signalIndex = dsuSignalIndex[pRouteCfgDtStr->StartSignalId];
			if(signalIndex < dsuDataLenStru.wSignalLen)
			{
				pRouteCfgDtStr->BelongVirCIid = (UINT8)(dsuStaticHeadStru.pSignalStru[signalIndex].wBelongVirCI);
			}
			else
			{
				rtnvalue = CI_ERROR;
			}
		}
		else
		{
			rtnvalue = CI_ERROR;
		}

		ciType = (UINT8)(dsuStaticHeadStru.pCIStruStru[dsuCIIndex[pRouteCfgDtStr->BelongCiId]].wType);/*进路所属联锁类型*/

		/*进路属性*/
		if(0x01u == (pDsuRouteStr->wRouteType & 0x01u))
		{
			/*进路类型为列车进路*/
			pRouteCfgDtStr->RouteType = ROUTE_TYPE_LIECHE;
		}
		else if(0x02u == (pDsuRouteStr->wRouteType & 0x02u))
		{
			/*进路类型为折返进路*/
			pRouteCfgDtStr->RouteType = ROUTE_TYPE_RETURN;

			/*车辆段没有折返进路，车辆段折返进路按列车进路*/
			if ((CI_TYPE_TCC == ciType) || (CI_TYPE_CLD == ciType))
			{
				pRouteCfgDtStr->RouteType = ROUTE_TYPE_LIECHE;
			}
			else
			{
			}
		}
		else if(0x0100u == (pDsuRouteStr->wRouteType & 0x0100u))
		{
			/*进路类型为调车进路*/
			pRouteCfgDtStr->RouteType = ROUTE_TYPE_DIAOCHE;
		}
		else if(0u == pDsuRouteStr->wRouteType)
		{
			pRouteCfgDtStr->RouteType = 0u;
		}
		else if(0u != (0xffu&pDsuRouteStr->wRouteType))
		{
			/*类型不为0,且低字节不为0,进路类型为列车进路*/
			pRouteCfgDtStr->RouteType = ROUTE_TYPE_LIECHE;
		}
		else
		{
			pRouteCfgDtStr->RouteType = 0u;
		}

		/*设置配置进路类型*/
		pRouteCfgDtStr->ConfigRouteType = pRouteCfgDtStr->RouteType;
		/*车辆段折返进路,调整配置进路类型*/
		if (0x02u == (pDsuRouteStr->wRouteType & 0x02u))
		{
			pRouteCfgDtStr->ConfigRouteType = ROUTE_TYPE_RETURN;
		}
		else
		{
		}

		if (0x0800u == (pDsuRouteStr->wRouteType & 0x0800u))
		{  /*风井进路*/
			pRouteCfgDtStr->AirShaftRouteType = ROUTE_TYPE_AIRSHAFT;
		}
		else
		{
		}		

		/*自动触发进路属性*/
		if (0x1000u == (pDsuRouteStr->wRouteType & 0x1000u))
		{/*自动触发进路*/
			pRouteCfgDtStr->AutoTriggerType = ROUTE_TYPE_AUTO_TRIGGER;
		}
		else
		{
		}

		/*自动信号属性*/
		pRouteCfgDtStr->AutoSigProperty = ROUTE_AUTOSIG_PROPERTY_NO;
		if(0xaau == pDsuRouteStr->wAttribute)
		{
			pRouteCfgDtStr->AutoSigProperty = ROUTE_AUTOSIG_PROPERTY_YES;
		}
		else
		{
		}

		/*自动进路属性*/
		pRouteCfgDtStr->AutoRouteProperty =  ROUTE_AUTOROUTE_PROPERTY_NO;
		for(i=0u;i<LSDataLen.LSAutoRouteStrLen;i++)/*自动通过*/
		{
			for(j=0u;j<AR_MAX_INCLUDE_ROUTE_NUM;j++)
			{
				/*如果进路ID在自动进路表中出现过，则进路自动属性为yes*/
				if(LSData.pLSAutoRouteStr[i].szIncludeRouteId[j] == pLSRouteStr->wRouteId)
				{
					pRouteCfgDtStr->AutoRouteProperty =  ROUTE_AUTOROUTE_PROPERTY_YES;
					break;
				}
				else
				{
				}

			}
		}

		/*自动折返进路*/
		for(i=0u;i<LSDataLen.LSAutoRtnRouteStrLen;i++)
		{
			for(j=0u;j<ARR_MAX_INCLUDE_ROUTE_NUM;j++)
			{
				/*如果进路ID在自动折返进路表中出现过，则进路自动属性为yes （自动折返进路及自动进路包含进路数都为8，所以就在一个循环里解决了）*/
				if(LSData.pLSAutoRtnRouteStr[i].szIncludeRouteId[j] == pLSRouteStr->wRouteId)
				{
					pRouteCfgDtStr->AutoRouteProperty =  ROUTE_AUTOROUTE_PROPERTY_YES;
					break;
				}
				else
				{
				}
			}
		}

		for(i=0u;i<LSDataLen.LSAllAutoRtnRouteStrLen;i++) /*全自动折返*/
		{
			for(j=0u;j<AARR_MAX_INCLUDE_ROUTE_NUM;j++)
			{
				/*如果进路ID在全自动折返进路表中出现过，则进路自动属性为yes */
				if(LSData.pLSAllAutoRtnRouteStr[i].szIncludeRouteId[j] == pLSRouteStr->wRouteId)
				{
					pRouteCfgDtStr->AutoRouteProperty =  ROUTE_AUTOROUTE_PROPERTY_YES;
					break;
				}
				else
				{
				}
			}
		}


		pRouteCfgDtStr->ReverseRouteProperty = ROUTE_REVERSE_PROPERTY_NO;
		/*进路反向属性*/
		for(i = 0u;i < LSDataLen.LSReverseRouteStrLen;i++)
		{/*遍历反向进路表中的所有进路*/
			if(LSData.pLSReverseRouteStr[i].wId == pLSRouteStr->wRouteId)
			{/*若果进路ID在反向进路表中出现过，则进路具有反向属性*/
				pRouteCfgDtStr->ReverseRouteProperty = ROUTE_REVERSE_PROPERTY_YES;
				break;
			}
			else
			{
			}
		}

		pRouteCfgDtStr->cCbtcProperty = ROUTE_CBTC_PROPERTY_NO;  /*初始化进路为不具有CBTC区域属性*/
		/*遍历进路内所有link，确定进路的CBTC区域属性*/
		for (i = 0U; i < pDsuRouteStr->wIncludeLinkNum; i++)
		{			
			pRouteIncLinkStru = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[i]];
			if (0x55U != pRouteIncLinkStru->cCbtcProperty)
			{
				break;  /*link不具有CBTC区域属性，停止遍历*/
			}
			else
			{
				/*link具有CBTC区域属性，继续遍历*/
			}
		}

		if ((i == pDsuRouteStr->wIncludeLinkNum) && (0U != i))
		{
			pRouteCfgDtStr->cCbtcProperty = ROUTE_CBTC_PROPERTY_YES;  /*所有link均具有CBTC区域属性，则进路具有CBTC区域属性*/
		}
		else
		{
			/*存在link不具有CBTC区域属性，则进路不具有CBTC区域属性*/
		}

		pRouteCfgDtStr->HaveDirChangePointInRoute = ROUTE_NOT_HAVE_DIR_CHANGE_POINT;/*进路内默认没有方向变化点*/

		pRouteCfgDtStr->HaveDirChangePointAfterRoute = ROUTE_NOT_HAVE_DIR_CHANGE_POINT;/*进路后方默认没有方向变化点*/
		/*进路包含物理区段数目 (配置字段)*/
		pRouteCfgDtStr->RoutePhySecSum = 0u;
	
		for(i=0u;i<LSDataLen.LSPhyAndChkStaStrLen;i++)
		{
			if(pLSRouteStr->wPhySecCheckStaId == LSData.pLSPhyAndChkStaStr[i].wId)
			{
				for(j=0u;j<MAX_INCLUDE_PHYSC_SGMT_NUM;j++)
				{
					if((0u != LSData.pLSPhyAndChkStaStr[i].wPhysicalSgmtId[j]) && (UINT16_MAX != LSData.pLSPhyAndChkStaStr[i].wPhysicalSgmtId[j]))
					{
						if(ROUTE_PHYSICALSECTION_SUM_MAX <= (pRouteCfgDtStr->RoutePhySecSum))
						{
							rtnvalue = CI_ERROR;
							break;
						}
						pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].PhysicalSectionId =LSData.pLSPhyAndChkStaStr[i].wPhysicalSgmtId[j];
						pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].CheckProperty =(UINT8)LSData.pLSPhyAndChkStaStr[i].wCheckState[j];
						
						/*在这计算物理区段锁闭方向是否应该取反*/
						if (0u == pRouteCfgDtStr->RoutePhySecSum)
						{/*以第一个区段Link方向为基准*/
							/*获取进路第一个计轴区段*/
							firstAxleSecId = pDsuRouteStr->wIncludeAxleSgmtId[0];/*第一个计轴区段*/
							lastAxleSecId = pDsuRouteStr->wIncludeAxleSgmtId[pDsuRouteStr->wIncludeAxleSgmtNum-1u];/*最后一个计轴区段*/
							axleNum = pDsuRouteStr->wIncludeAxleSgmtNum;/*计轴区段数量*/
							
							
							/*进路第一个物理区段不应取反*/
							pRouteCfgDtStr->RoutePhySectionStru[0].LockDirShouldOpposedToRoute 
								= ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK;

							/*大于一个计轴区段，进路才有可能有方向变化点*/
							/*计算基准方向*/
							if ((1u < axleNum) && (1u < pDsuRouteStr->wIncludeLinkNum))
							{
								/*计算是起点到终点，还是终点到起点*/
								/*如果进路第一个计轴区段关联LINK数量大于1个，计算前两个LINK之间是起点连接关系(起点连接LINK是下一个，终点到起点)，
									还是终点连接关系(终点连接LINK是下一个，起点到终点)*/
								pDsuAxleSgmt = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[firstAxleSecId];
								
								/*进路第一个LINK结构体*/
								pRouteFirstLinkStru = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[0]];
								/*进路第二个LINK结构体*/
								pRouteSecondLinkStru = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[1]];

								if (pDsuAxleSgmt->wRelatePhysicalSgmtId == pRouteCfgDtStr->RoutePhySectionStru[0].PhysicalSectionId)
								{/*物理区段能对上*/
									

									if ((pRouteFirstLinkStru->wOrgnJointMainLkId == pRouteSecondLinkStru->wId) ||
										(pRouteFirstLinkStru->wOrgnJointSideLkId == pRouteSecondLinkStru->wId))
									{/*第一个LINK的起点连接正向LINKId或起点连接侧向LINKid与第二个LINKid相同，为从终点到起点*/
										baseDir = TERMINAL_TO_ORIGIN;/*终点到起点*/	
									}
									else if ((pRouteFirstLinkStru->wTmnlJointMainLkId == pRouteSecondLinkStru->wId) ||
										(pRouteFirstLinkStru->wTmnlJointSideLkId == pRouteSecondLinkStru->wId))
									{
										baseDir = ORIGIN_TO_TERMINAL;/*起点到终点*/		
									}
									else
									{
										/*都不是，数据错误*/
									}

									/*直接查找LINK方向变化点*/
									flagFind = 0u;
									for (lkIndex=0u;(lkIndex < (pDsuRouteStr->wIncludeLinkNum - 1u))&&((DSU_ROUTE_STRU_wLinkId-1u)>lkIndex);lkIndex++)
									{
										
										pDsuLink = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[lkIndex]];


										if (ORIGIN_TO_TERMINAL == baseDir)
										{/*起点到终点*/
											if ((pDsuLink->wTmnlJointMainLkId == pDsuRouteStr->wLinkId[lkIndex+1u]) || 
												(pDsuLink->wTmnlJointSideLkId == pDsuRouteStr->wLinkId[lkIndex+1u])
												)
											{/*如果该LINK的终点连接正线LINK 或终点连接侧线LINK，为下一LINK*/
												pDsuLinkNext = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[lkIndex+1u]];/*下一LINK*/

												if ((pDsuLinkNext->wTmnlJointMainLkId == pDsuRouteStr->wLinkId[lkIndex]) || 
													(pDsuLinkNext->wTmnlJointSideLkId == pDsuRouteStr->wLinkId[lkIndex])
													)
												{/*如果下一LINK的终点连接正线LINK 或终点连接侧线LINK，为本LINK*/
													/*说明找到方向变化点了*/
													dirChangeLinkId = pDsuRouteStr->wLinkId[lkIndex+1u];/*方向变化点LINK为下一LINK*/
													findFlag = 1u;
												}
												else
												{
												}
											}
											else
											{
											}										
											
										}
										
										else if (TERMINAL_TO_ORIGIN == baseDir)
										{/*终点到起点*/
											if ((pDsuLink->wOrgnJointMainLkId == pDsuRouteStr->wLinkId[lkIndex+1u]) || 
												(pDsuLink->wOrgnJointSideLkId == pDsuRouteStr->wLinkId[lkIndex+1u])
												)
											{/*如果该LINK的起点连接正线LINK 或起点连接侧线LINK，为下一LINK*/
												pDsuLinkNext = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[lkIndex+1u]];/*下一LINK*/

												if ((pDsuLinkNext->wOrgnJointMainLkId == pDsuRouteStr->wLinkId[lkIndex]) || 
													(pDsuLinkNext->wOrgnJointSideLkId == pDsuRouteStr->wLinkId[lkIndex])
													)
												{/*如果下一LINK的起点连接正线LINK 或起点连接侧线LINK，为本LINK*/
													/*说明找到方向变化点了*/

													dirChangeLinkId = pDsuRouteStr->wLinkId[lkIndex+1u];/*方向变化点LINK为下一LINK*/
													findFlag = 1u;
												}
												else
												{
												}
											}
											else
											{
											}
											
										}
										else
										{
											/*无操作*/
										}

										if (1u == findFlag)
										{/*找到后，退出循环*/
											break;
										}
										else
										{
										}
									}
									
									/*遍历进路计轴区段，找到方向变化点计轴区段*/
									for (axleSecIndex =0u;(axleSecIndex<pDsuRouteStr->wIncludeAxleSgmtNum)&&(DSU_ROUTE_STRU_AxleSgmtId >axleSecIndex);axleSecIndex++)
									{
										axleSecId = pDsuRouteStr->wIncludeAxleSgmtId[axleSecIndex];
										pDsuAxleSgmt = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[axleSecId];
										if ((pDsuAxleSgmt->wOrgnLkId == dirChangeLinkId) || 
											(pDsuAxleSgmt->wTmnlLkId == dirChangeLinkId))
										{/*如果计轴区段的起点LINK或者终点LINK为方向变化点LINK，则此计轴区段为方向变化区段*/
											dirChangeAxleSecId = pDsuAxleSgmt->wId;/*找到方向变化点计轴区段ID*/
											dirChangePhySecId = pDsuAxleSgmt->wRelatePhysicalSgmtId;/*记录方向变化点物理区段ID*/
											break;
										}
										else
										{
										}
									}
								
								}
								else
								{
								}								
								
							}
							else
							{
							}
							
							findRouteProtectDirChangeFlag = 0u;
							/*默认进路与保护区段之间没有方向变化点*/
							pRouteCfgDtStr->HaveDirChangePointAfterRoute = ROUTE_NOT_HAVE_DIR_CHANGE_POINT;
							if (0u == dirChangeAxleSecId)/*进路内没有方向变化点*/
							{ 
								/*计算进路最后一个区段和保护区段之间是否有方向变化点*/
								if (pDsuRouteStr->wProtectLinkNum > 0u)
								{/*必须有保护区段*/
									firstProtectId = pDsuRouteStr->wProtectLinkId[0];/*取第一个保护区段ID*/

									if (firstProtectId <= PROTECT_INDEX_NUM)
									{
										/*取得保护区段结构体*/
										pProtectStru = dsuStaticHeadStru.pProtectLinkStru + dsuProtectLinkIndex[firstProtectId];
										
										if (pProtectStru->wIncludeAxleSgmtNum > 0u)
										{/*保护区段保护计轴区段数量大于0*/
											
											pProtectFirstAxleSec = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[pProtectStru->wIncludeAxleSgmtId[0]];
											
											/*保护区段第一计轴区段起点LINK*/
											pDsuProtectFstAxleSecStartLink = 
												dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pProtectFirstAxleSec->wOrgnLkId];
											/*保护区段第一计轴区段终点LINK*/
											pDsuProtectFstAxleSecEndLink = 
												dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pProtectFirstAxleSec->wTmnlLkId];

											/*进路最后一计轴区段*/
											pDsuRouteLastAxleSgmt = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[lastAxleSecId];
											
											/*进路最后一个LINK*/
											pRouteLastLink = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteLastAxleSgmt->wTmnlLkId];
											if ((pRouteLastLink->wTmnlJointMainLkId == pDsuProtectFstAxleSecEndLink->wId) ||
												(pRouteLastLink->wTmnlJointSideLkId == pDsuProtectFstAxleSecEndLink->wId))
											{/*如果进路最后一个LINK的终点连接正向LINK等于保护区段第一计轴区段终点LINK 或
													进路最后一个LINK的终点连接侧向LINK等于保护区段第一计轴区段终点LINK*/
												if ((pDsuProtectFstAxleSecEndLink->wTmnlJointMainLkId == pRouteLastLink->wId) ||
													(pDsuProtectFstAxleSecEndLink->wTmnlJointSideLkId == pRouteLastLink->wId))
												{/*如果保护区段第一计轴区段终点LINK终点连接正向LINK等于进路最后一个LINK 或
														保护区段第一计轴区段终点LINK的终点连接侧向LINK等于进路最后一个LINK*/
													/*对顶，找到方向变化点*/
													findRouteProtectDirChangeFlag = 1u;
												}
											}
											
											/*进路最后一个LINK*/
											pRouteLastLink = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteLastAxleSgmt->wOrgnLkId];
											if ((pRouteLastLink->wOrgnJointMainLkId == pDsuProtectFstAxleSecStartLink->wId) ||
												(pRouteLastLink->wOrgnJointSideLkId == pDsuProtectFstAxleSecStartLink->wId))
											{/*如果进路最后一个LINK的起点连接正向LINK等于保护区段第一计轴区段起点LINK 或
													进路最后一个LINK的起点连接侧向LINK等于保护区段第一计轴区段起点LINK*/
												if ((pDsuProtectFstAxleSecStartLink->wOrgnJointMainLkId == pRouteLastLink->wId) ||
													(pDsuProtectFstAxleSecStartLink->wOrgnJointSideLkId == pRouteLastLink->wId))
												{/*如果保护区段第一计轴区段起点LINK起点连接正向LINK等于进路最后一个LINK 或
														保护区段第一计轴区段起点LINK的起点连接侧向LINK等于进路最后一个LINK*/
													/*对顶，找到方向变化点*/
													findRouteProtectDirChangeFlag = 1u;
												}
											}
											
											if (1u == findRouteProtectDirChangeFlag)
											{
												/*进路后有方向变化点*/
												pRouteCfgDtStr->HaveDirChangePointAfterRoute = ROUTE_HAVE_DIR_CHANGE_POINT;
											}
											else
											{/*进路后没有方向变化点*/
												pRouteCfgDtStr->HaveDirChangePointAfterRoute = ROUTE_NOT_HAVE_DIR_CHANGE_POINT;
											}
										}
										else
										{
										}
									}
									else
									{
									}
									
									
								}
								else
								{
								}
							}
							else
							{
							}
							
						}
						else if (0u < pRouteCfgDtStr->RoutePhySecSum)
						{/*其它区段，因为方向变化点LINK索引已经计算出来，在此，
						 只需要计算物理区段对应的LINK对应的索引是否大于dirChangeLinkIndex，即可*/
							pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].LockDirShouldOpposedToRoute =
								ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK;/*默认不应取反*/
							if (0u < dirChangePhySecId)
							{/*如果有方向变化点物理区段*/
								if (pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].PhysicalSectionId
									== dirChangePhySecId)
								{
									dirChangePhySecIndex = pRouteCfgDtStr->RoutePhySecSum;/*记下索引*/

									pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].LockDirShouldOpposedToRoute =
										ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK;/*应该取反，这一大段最终为了计算这个*/
								}
								else
								{/*不等于方向变化点物理区段ID*/
									if (0u == dirChangePhySecIndex)
									{/*还没到物理区段ID*/
										pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].LockDirShouldOpposedToRoute =
											ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK;/*不应取反*/
									}
									else
									{
										if (pRouteCfgDtStr->RoutePhySecSum > dirChangePhySecIndex)
										{/*pRouteCfgDtStr->RoutePhySecSum在没有++之前，都是索引*/
											pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].LockDirShouldOpposedToRoute =
												ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK;/*应该取反，这一大段最终为了计算这个*/
										}
										else
										{
										}
										
									}
								}

								
							}else
							{
							}

						}
						else
						{
							/*不存在，不处理*/
						}
						if (dirChangePhySecId >0u)
						{
							pRouteCfgDtStr->HaveDirChangePointInRoute = ROUTE_HAVE_DIR_CHANGE_POINT;/*设置有方向变化点*/
						}
						else
						{
						}
						pRouteCfgDtStr->RoutePhySecSum++;
					}
				}

				if (ROUTE_HAVE_DIR_CHANGE_POINT == pRouteCfgDtStr->HaveDirChangePointInRoute)
				{
					debug_infor_printf((const)"RouteId:%d HaveDirChangePointInRoute dirChangedPhyId:%d\n",pRouteCfgDtStr->RouteId,dirChangePhySecId);
				}
				else
				{
				}

				if (ROUTE_HAVE_DIR_CHANGE_POINT == pRouteCfgDtStr->HaveDirChangePointAfterRoute)
				{
					debug_infor_printf((const)"RouteId:%d HaveDirChangePointAfterRoute \n",pRouteCfgDtStr->RouteId);
				}
				else
				{
				}
			}
		}

		

		if(CI_SUCCESS == rtnvalue)
		{
			if (CI_TRADITION_RAILWAY == lineIdentity)
			{					
				/*进路包含道岔数目 (配置字段)*/
				pRouteCfgDtStr->RouteSwitchSum = (UINT8)pDsuRouteStr->wIncludePointNum;
				for(i=0u;i<pRouteCfgDtStr->RouteSwitchSum;i++)
				{
					if((ROUTE_SWITCH_SUM_MAX > i)&&(DSU_ROUTE_STRU_SWITCH > i))
					{
						pRouteCfgDtStr->RouteSwitchStru[i].SwitchId = pDsuRouteStr->wPointId[i];
						pRouteCfgDtStr->RouteSwitchStru[i].SwitchPosition = (UINT8)pDsuRouteStr->wPointStatus[i];
						pRouteCfgDtStr->RouteSwitchStru[i].SwitchProperty = 0xffu;
					}
					else
					{
						rtnvalue = CI_ERROR;
						break;
					}
				}
				
			
				pRouteCfgDtStr->RouteLastSwichPhySecId = 0u;/*进路最远端道岔物理区段id*/
		
				flagBreak = 0u;
		
				/*计算进路最远端道岔物理区段id*/
			if (pRouteCfgDtStr->RouteSwitchSum > 0U)
			{/*确保有岔*/
				/*遍历进路物理区段，看哪个物理区段包含这个道岔*/
				if(ROUTE_PHYSICALSECTION_SUM_MAX >= pRouteCfgDtStr->RoutePhySecSum)
				{			
					for (i = pRouteCfgDtStr->RoutePhySecSum;i >0u;i--)
					{
						if(PHYSICAL_SECTION_SUM_MAX >= dquCICfgDtStr.PsclSgmtCfgDtStrLen)
						{					
							for (j=0u;j<dquCICfgDtStr.PsclSgmtCfgDtStrLen;j++)
							{
								if (dquCICfgDtStr.PsclSgmtCfgDtStr[j].PhysicalSectionId == pRouteCfgDtStr->RoutePhySectionStru[i-1u].PhysicalSectionId)
								{
									if ((UINT8)0xaa==dquCICfgDtStr.PsclSgmtCfgDtStr[j].PhySecType  )
									{/*有岔区段*/
										pRouteCfgDtStr->RouteLastSwichPhySecId = dquCICfgDtStr.PsclSgmtCfgDtStr[j].PhysicalSectionId;
										flagBreak = 1u;
										break;
									}
									else
									{
									}
								}
								else
								{
								}
							}
							if (1u == flagBreak)
							{
								break;
							}
							else
							{
							}
						}
						else
						{
							rtnvalue = CI_ERROR;
						}
					}
					if (0u == pRouteCfgDtStr->RouteLastSwichPhySecId)
					{
						debug_infor_printf((const)"Route %d RouteLastSwichPhySecId is 0.\r\n",pRouteCfgDtStr->RouteId);
					}
					else
					{
					}
				}
				else
				{
					rtnvalue = CI_ERROR;	
				}
			}
							
				if((0u !=pLSRouteStr->wFHDCId) && (UINT16_MAX != pLSRouteStr->wFHDCId))
				{
					pRouteCfgDtStr->RouteProtectSwitchSum = 0u;/*防护道岔数量初始化为0*/
					for(i=0u;i<LSDataLen.LSFHDaoChaStrLen;i++)
					{
						if((LSData.pLSFHDaoChaStr+i)->wId == pLSRouteStr->wFHDCId)
						{
							for(j=0u;j<FHDC_MAX_INCLUDE_POINT_NUM;j++)
							{
								if((0u !=(LSData.pLSFHDaoChaStr+i)->wPointId[j]) && (UINT16_MAX != (LSData.pLSFHDaoChaStr+i)->wPointId[j]))
								{
									if(ROUTE_PROTECTSWI_SUM_MAX > pRouteCfgDtStr->RouteProtectSwitchSum)
									{
										pRouteCfgDtStr->RouteProtectSwitchStru[pRouteCfgDtStr->RouteProtectSwitchSum].ProtectSwitchId = (LSData.pLSFHDaoChaStr+i)->wPointId[j];
										pRouteCfgDtStr->RouteProtectSwitchStru[pRouteCfgDtStr->RouteProtectSwitchSum].ProtectPosition =(UINT8)(LSData.pLSFHDaoChaStr+i)->wPointSta[j];
										pRouteCfgDtStr->RouteProtectSwitchSum++;
									}
									else
									{
										rtnvalue = CI_ERROR;	
										break;
									}
								}
								else
								{
								}
							}
						}
						else
						{
						}
					}
				}
				else
				{
				}	
			}/* zt 删除单轨相关代码 2022-02-15 */
			else
			{

			}
		}
		else
		{
		}
		if(CI_SUCCESS == rtnvalue)
		{	
			pRouteCfgDtStr->RouteInitEnemyStatus = ROUTE_INIT_NOT_ENEMY;/*初始化成不敌对*/
			/*进路相关敌对信号数目 (配置字段)*/
			pRouteCfgDtStr->RouteEnemySignalSum = 0u;
			if(pLSRouteStr->wDDXHId != 0u)
			{
				findFlag = 0u;
				for(j=0u;j<LSDataLen.LSDDXHZStrLen;j++)
				{
					if(pLSRouteStr->wDDXHId == LSData.pLSDDXHZStru[j].wId)
					{
						for(k=0u;k<DDXHZ_MAX_DDXH_NUM;k++)
						{
							if((LSData.pLSDDXHZStru[j].wDiDuiXinHaoId[k]!=0u))
							{
								for(m=0u;m<LSDataLen.LSDDXHStrLen;m++)
								{
									if(LSData.pLSDDXHStr[m].wId == LSData.pLSDDXHZStru[j].wDiDuiXinHaoId[k])
									{
										pRouteCfgDtStr->RouteEnemySigStru[pRouteCfgDtStr->RouteEnemySignalSum].SignalId = LSData.pLSDDXHStr[m].wDiDuiXinHaoId;
										pRouteCfgDtStr->RouteEnemySigStru[pRouteCfgDtStr->RouteEnemySignalSum].SwitchSum = 0u;
										for(n=0u;n<DDXH_MAX_INCLUDE_POINT_NUM;n++)
										{
											if(LSData.pLSDDXHStr[m].wPointId[n] != 0u)
											{
												if(ROUTE_ENEMYSIGNAL_SUM_MAX > pRouteCfgDtStr->RouteEnemySignalSum)
												{
													pRouteCfgDtStr->RouteEnemySigStru[pRouteCfgDtStr->RouteEnemySignalSum].ConditionSwitchStru[n].SwitchId = LSData.pLSDDXHStr[m].wPointId[n];
													pRouteCfgDtStr->RouteEnemySigStru[pRouteCfgDtStr->RouteEnemySignalSum].ConditionSwitchStru[n].SwitchPosition = (UINT8)LSData.pLSDDXHStr[m].wPointSta[n];
													pRouteCfgDtStr->RouteEnemySigStru[pRouteCfgDtStr->RouteEnemySignalSum].SwitchSum++;
												}
												else
												{
													rtnvalue = CI_ERROR;
												}
											}
											else
											{
											}
										}
										pRouteCfgDtStr->RouteEnemySignalSum++;
									}
									else
									{
									}
								}
							}
							else
							{
							}
						}
						findFlag = 1u;
					}
					else
					{
					}

				}
				if (0u == findFlag)
				{
					pRouteCfgDtStr->RouteInitEnemyStatus = ROUTE_INIT_ENEMY;
				}
				else
				{
					pRouteCfgDtStr->RouteInitEnemyStatus = ROUTE_INIT_NOT_ENEMY;
				}
			}
			else
			{
			}
			
		}
		
		if(CI_SUCCESS == rtnvalue)
		{	
			/*CBTC进路接近区段条件数目 (配置字段)*/
			pRouteCfgDtStr->CbtcNearConditionSum = (UINT8)pDsuRouteStr->wCBTCAccessLinkNum;
			if(ROUTE_NEARSEC_CONDITION_SUM_MAX >= pDsuRouteStr->wCBTCAccessLinkNum)
			{		
				for(i=0u;i< pDsuRouteStr->wCBTCAccessLinkNum;i++)
				{
					pRouteCfgDtStr->CbtcNearLogSecStru[i].NearLogicSecSum = 0u;
					pRouteCfgDtStr->CbtcNearLogSecStru[i].SwitchSum = 0u;
					pCbtcAccessStr = dsuStaticHeadStru.pCBTCAccessLinkStru + dsuCBTCAccessLinkIndex[pDsuRouteStr->wCBTCAccessLinkId[i]];
					if((ROUTE_CBTCNEAR_LOGSEC_SUM_MAX >= pCbtcAccessStr->wIncludeLogicSgmtNum) &&
						(ROUTE_CBTCNEAR_LOGSEC_SUM_MAX >pRouteCfgDtStr->CbtcNearLogSecStru[i].NearLogicSecSum))
					{				
						for(j=0u;j<pCbtcAccessStr->wIncludeLogicSgmtNum;j++)
						{
							pRouteCfgDtStr->CbtcNearLogSecStru[i].NearLogicSecIdBuf[pRouteCfgDtStr->CbtcNearLogSecStru[i].NearLogicSecSum] = pCbtcAccessStr->wIncludeLogicSgmtId[j];
							pRouteCfgDtStr->CbtcNearLogSecStru[i].NearLogicSecSum++;

						}
					}
					else
					{
						rtnvalue = CI_ERROR;
					}
					if(CI_SUCCESS==rtnvalue)
					{			
						for(k=0u;k<pDsuRouteStr->wCBTCAccessLinkRelatePointNum[i];k++)
						{
							if(ROUTE_CONDITION_SWITCH_SUM_MAX > pRouteCfgDtStr->CbtcNearLogSecStru[i].SwitchSum)
							{
								pRouteCfgDtStr->CbtcNearLogSecStru[i].ConditionSwitchStru[pRouteCfgDtStr->CbtcNearLogSecStru[i].SwitchSum].SwitchId = pDsuRouteStr->wCBTCAccessLinkRelatePointId[i][k];
								pRouteCfgDtStr->CbtcNearLogSecStru[i].ConditionSwitchStru[pRouteCfgDtStr->CbtcNearLogSecStru[i].SwitchSum].SwitchPosition = (UINT8)pDsuRouteStr->wCBTCAccessLinkRelatePointSta[i][k];
								pRouteCfgDtStr->CbtcNearLogSecStru[i].SwitchSum++;
							}	
							else
							{
								rtnvalue = CI_ERROR;
							}
						}
					}
					else
					{
						; /*无操作*/
					}
				}
			}
			else
			{
			     rtnvalue = CI_ERROR;
			}
		}
		else
		{
		}

		if(CI_SUCCESS == rtnvalue)
		{
			/*点式进路接近区段条件数目 (配置字段)*/
			if (ROUTE_NEARSEC_CONDITION_SUM_MAX >= pDsuRouteStr->wBlogAccessLinkNum)
			{
				pRouteCfgDtStr->BlocNearConditionSum = (UINT8)pDsuRouteStr->wBlogAccessLinkNum;
				for (i = 0; i< pDsuRouteStr->wBlogAccessLinkNum; i++)
				{
					pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum = 0;
					pRouteCfgDtStr->BlocNearPhySecStru[i].SwitchSum = 0;

					pBlocAccessStr = dsuStaticHeadStru.pBLOCAccessLinkStru + dsuBLOCAccessLinkIndex[pDsuRouteStr->wBlogAccessLinkId[i]];
					if ((ROUTE_BLOCNEAR_PHYSEC_SUM_MAX >= pBlocAccessStr->wIncludeAxleSgmtNum) &&
						(ROUTE_BLOCNEAR_PHYSEC_SUM_MAX >pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum))
					{
						for (j = 0; j< pBlocAccessStr->wIncludeAxleSgmtNum; j++)
						{
							pAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[pBlocAccessStr->wIncludeAxleSgmtId[j]];
							for (k=0;k<pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum;k++)   /*去重，避免重复添加同一物理区段*/
							{
								if (pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecIdBuf[k] == pAxleSgmtStr->wRelatePhysicalSgmtId)
								{
									break;
								}
								else
								{
									;
								}
							}
							if (k == pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum)
							{
								pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecIdBuf[pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum] = pAxleSgmtStr->wRelatePhysicalSgmtId;
								pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum++;
								for (k = 0; k< pAxleSgmtStr->wRelatPointNum; k++)
								{
									if (ROUTE_CONDITION_SWITCH_SUM_MAX > pRouteCfgDtStr->BlocNearPhySecStru[i].SwitchSum)
									{
										pRouteCfgDtStr->BlocNearPhySecStru[i].ConditionSwitchStru[pRouteCfgDtStr->BlocNearPhySecStru[i].SwitchSum].SwitchId = pAxleSgmtStr->wRelatPointId[k];
										pRouteCfgDtStr->BlocNearPhySecStru[i].ConditionSwitchStru[pRouteCfgDtStr->BlocNearPhySecStru[i].SwitchSum].SwitchPosition = (UINT8)pAxleSgmtStr->wRelatPointStatus[k];
										pRouteCfgDtStr->BlocNearPhySecStru[i].SwitchSum++;
									}
									else
									{
										rtnvalue = CI_ERROR;
									}
								}
							}
							else
							{
								;
							}

						}

					}
					else
					{
						rtnvalue = CI_ERROR;
					}

				}
			}
			else
			{
				rtnvalue = CI_ERROR;
			}
		}
		else
		{
		}
		if(CI_SUCCESS == rtnvalue)
		{		
		    /*点式进路触发区段条件数目 (配置字段)*/  
		    /*由于目前基础查询函数不支持CBTC触发区段包含的道岔信息，故此版本CBTC进路也按点式触发进行处理，后期会优化*/
			for (i = 0U; (i < pDsuRouteStr->wCbtcTrgAreaNum) && (ROUTE_BLOC_TRIGGERPHY_NUM > i); i++)
			{  /*遍历进路表中CBTC触发区段*/
				pRouteTriggerPhySecStr = &(pRouteCfgDtStr->BlocTriggerPhySecStru[i]);
				pRouteTriggerPhySecStr->TriggerPhySecSum = 0U;
				pRouteTriggerPhySecStr->SwitchSum = 0U;

				pCbtcTriggerStr = dsuStaticHeadStru.pCbtcTrgAreaStru + dsuCbtcTrgAreaIndex[pDsuRouteStr->wCbtcTrgAreaId[i]];
				if ((NULL != pCbtcTriggerStr) && (NULL != pCbtcTriggerStr->wLogicSgmtId))
				{
					for (j = 0U; (j < pCbtcTriggerStr->wLogicSgmtNum) && (ROUTE_CBTCTRIGGER_LOGSEC_SUM_MAX > j); j++)
					{
						pLogicSgmeStr = dsuStaticHeadStru.pLogicSgmtStru + dsuLogicSgmtIndex[pCbtcTriggerStr->wLogicSgmtId[j]];
						for (m = 0U; m < ROUTE_BLOCTRIGGER_CONDITION_SUM_MAX; m++)
						{/*逻辑区段所属物理区段去重*/
							if (pLogicSgmeStr->wRelatPhySecId == pRouteTriggerPhySecStr->TriggerPhySecIdBuf[m])
							{
								chCheckLogIdSameFlag = 1U;
								break;
							}
						}
						if (1U != chCheckLogIdSameFlag)
						{/*当前列表中无对应物理区段*/
							pRouteTriggerPhySecStr->TriggerPhySecIdBuf[pRouteTriggerPhySecStr->TriggerPhySecSum] = pLogicSgmeStr->wRelatPhySecId;
							pRouteTriggerPhySecStr->TriggerPhySecSum++;
							for (k = 0U; k < pLogicSgmeStr->chSwitchNum; k++)
							{
								if (ROUTE_CONDITION_SWITCH_SUM_MAX > pRouteTriggerPhySecStr->SwitchSum)
								{
									pRouteTriggerPhySecStr->ConditionSwitchStru[pRouteTriggerPhySecStr->SwitchSum].SwitchId = pLogicSgmeStr->wSwitchId[k];
									pRouteTriggerPhySecStr->ConditionSwitchStru[pRouteTriggerPhySecStr->SwitchSum].SwitchPosition = pLogicSgmeStr->chSwitchPosition[k];
									pRouteTriggerPhySecStr->SwitchSum++;
								}
								else
								{
									rtnvalue = CI_ERROR;
								}
							}
						}
						/*cgh-20230530---清除去重标志*/
						chCheckLogIdSameFlag = 0U;
					}
				}
			}
		
    		/*进路包含带动道岔数目 (配置字段)*/
			pRouteCfgDtStr->RouteAssocSwitchSum = 0u;

			if((0u != pLSRouteStr->wDrvSwiGrpId) && (UINT16_MAX != pLSRouteStr->wDrvSwiGrpId))
			{
				for(i = 0u; i < LSDataLen.LSAssocSwitchGroupStruLen; i++)
				{
					if((LSData.pLSAssocSwitchGroupStru + i)->wId == pLSRouteStr->wDrvSwiGrpId)
					{
						for(j = 0u; j < DRV_SWI_GRP_MAX_INCLUDE_POINT_NUM; j++)
						{
							if((0u !=(LSData.pLSAssocSwitchGroupStru + i)->wPointId[j]) && (UINT16_MAX != (LSData.pLSAssocSwitchGroupStru + i)->wPointId[j]))
							{
								if(ROUTE_DRIVED_SWITCH_SUM_MAX > pRouteCfgDtStr->RouteAssocSwitchSum)
								{
									pRouteCfgDtStr->RouteAssocSwitchStru[pRouteCfgDtStr->RouteAssocSwitchSum].SwitchId = (LSData.pLSAssocSwitchGroupStru + i)->wPointId[j];
									pRouteCfgDtStr->RouteAssocSwitchStru[pRouteCfgDtStr->RouteAssocSwitchSum].SwitchPosition = (UINT8)(LSData.pLSAssocSwitchGroupStru + i)->wPointSta[j];

									pRouteCfgDtStr->RouteAssocSwitchSum++;
								}
								else
								{
									 rtnvalue = CI_ERROR;
								}
							}
							else
							{
							}
						}
						break;
					}
					else
					{
					}
				}
			}
			else
			{
			}

		    /*进路折返信号机数目 (配置字段)*/
		    pRouteCfgDtStr->RouteReturnSigSum = 0u;
		    index=0u;
			for(i=0u;i<LSDataLen.LSSignalStrLen;i++)
			{
				if(pLSRouteStr->wReturnSignalId == LSData.pLSSignalStr[i].wId)
				{
					for(j=0u;j<MAX_INCLUDE_SIGNAL_NUM;j++)
					{
						if((0u != LSData.pLSSignalStr[i].wSignalId[j]) && (UINT16_MAX != LSData.pLSSignalStr[i].wSignalId[j]))
						{
							if(ROUTE_RETURNSIGNAL_SUM_MAX > index)
							{
								pRouteCfgDtStr->RouteReturnSigIdBuf[index]=LSData.pLSSignalStr[i].wSignalId[j];
								index++;
							}
							else
							{
								 rtnvalue = CI_ERROR;
							}
						}
						else
						{
						}
					}
				}
				else
				{
				}
			}
			pRouteCfgDtStr->RouteReturnSigSum = index;
			if (ROUTE_TYPE_RETURN == pRouteCfgDtStr->RouteType )/*如果是折返进路*/
			{
				if (0u == pLSRouteStr->wReturnSignalId)/*折返信号机没有配置*/
				{
					debug_infor_printf((const)"\nRoute %d return signal not config.",pRouteCfgDtStr->RouteId);
					DebugPrintAppError(ERROR_RTNROUTE_RTNSIG_NOCONFIG,CI_DEVICE_TYPE_ROUTE,pRouteCfgDtStr->RouteId,PRINT_ONCE);
				}
				else if (0u == pRouteCfgDtStr->RouteReturnSigSum)/*配置了，但是在信号机组里找不到对应的ID*/
				{
					debug_infor_printf((const)"\nRoute %d return signalGroup %d  invalid .",pRouteCfgDtStr->RouteId,pLSRouteStr->wReturnSignalId);
					DebugPrintAppError(ERROR_RTNROUTE_RTNSIG_INVALID,CI_DEVICE_TYPE_ROUTE,((UINT32)pRouteCfgDtStr->RouteId<<16u)+pLSRouteStr->wReturnSignalId,PRINT_ONCE);
				}
				else
				{
					/*无操作*/
				}
			}
			else
			{
			}

			/*进路相关防护区段组数目 (配置字段)*/
			pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[pLSRouteStr->wRouteId];

			pRouteCfgDtStr->OverlapSum = (UINT8)pDsuRouteStr->wProtectLinkNum;
			for (i = 0; (i < pDsuRouteStr->wProtectLinkNum) && (i < ROUTE_PROTECTSECGROUP_SUM_MAX); i++)
			{

				pRouteCfgDtStr->OverlapIdBuf[i] = pDsuRouteStr->wProtectLinkId[i];
				for (j = 0; j < OVERLAP_SUM_MAX; j++)
				{
					if (overlapStr[j].OverlapId == pRouteCfgDtStr->OverlapIdBuf[i])
					{
						overlapIndex = (UINT8)overlapStr[j].OverlapRouteSum;
						if (overlapIndex < OVERLAP_ROUTE_SUM_MAX)
						{
							overlapStr[j].OverlapRouteIdBuf[overlapIndex] = pRouteCfgDtStr->RouteId;
							overlapStr[j].OverlapRouteSum++;
						}
						break;
					}
					else
					{
						/*不做处理*/
					}
				}
			}
			/*进路离去物理区段ID (初始化字段)   要求设置为0*/
			pRouteCfgDtStr->RouteLeavePhySecId = 0u;

			routeId = pLSRouteStr->wRouteId;
			routeDir = pLSRouteStr->wDir;   /*使用配置的逻辑方向*/

			/*获取进路的计轴区段数目*/
			axleSgmtNum = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[routeId]].wIncludeAxleSgmtNum;

			/*获取进路的最后一个计轴区段编号*/
			axleSgmtId = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[routeId]].wIncludeAxleSgmtId[axleSgmtNum-1u];
		}
		if(CI_SUCCESS == rtnvalue)
		{
			if (CI_TRADITION_RAILWAY == lineIdentity)
			{/*传统城轨线路*/
				/*进路离去区段为进路终端信号机内方第一区段，可能不存在（终端阻挡信号机）*/
				routeEndSignal = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[routeId]].wEndSignalId;/*进路终端信号机*/
				if(SIGNAL_SUM_MAX >= dquCICfgDtStr.SgnlCfgDtStrLen)
				{			
					for (i = 0u;i < dquCICfgDtStr.SgnlCfgDtStrLen;i++)
					{/*遍历所有信号机*/ 
						if (routeEndSignal == dquCICfgDtStr.SgnlCfgDtStr[i].SignalId)
						{/*找到进路的终端信号机*/
							pRouteCfgDtStr->RouteLeavePhySecId = dquCICfgDtStr.SgnlCfgDtStr[i].InFirstPhySecId;
							break;
						}
						else
						{
						}
					}
				}
				else
				{
					rtnvalue = CI_ERROR;
				}
			} 
			else
			{
				/* zt 删除单轨相关代码 2022-02-15 */
			}	
		}
		else
		{
		}
		if(CI_SUCCESS==rtnvalue)
		{	
			/*防护区段解锁对应停稳物理区段ID (配置字段)*/
			pRouteCfgDtStr->StopSteadyPhySecId = pLSRouteStr->wFHQD_TW_WLQDId;

			/*对/本端照查继电器ID (配置字段)*/
			for(i=0u;i<RelayDataLen.RelayZhaoChaStrLen;i++)
			{
				pRouteCfgDtStr->ThatZhaoChaRelayId = 0u;
				pRouteCfgDtStr->ThisZhaoChaRelayId = 0u;
				pRouteCfgDtStr->cancelZhaochaRelayId = 0u;
				pRouteCfgDtStr->CancelZhaoChaRelayOnRelayIntrf = 0u;
				pRouteCfgDtStr->ThatZhaoChaPhySecSum = 0u;
				pRouteCfgDtStr->RelayBenDuanZcIdOnRelayIntrf = 0u;
				pRouteCfgDtStr->RelayDuiDuanZcIdOnRelayIntrf = 0u;

				if(RelayData.pRelayZhaoChaStr[i].wRouteId == pLSRouteStr->wRouteId)
				{			
					pRouteCfgDtStr->ThatZhaoChaRelayId = RelayData.pRelayZhaoChaStr[i].wRelayDuiDuanZcId;
					pRouteCfgDtStr->ThisZhaoChaRelayId = RelayData.pRelayZhaoChaStr[i].wRelayBenDuanZcId;
					pRouteCfgDtStr->cancelZhaochaRelayId = RelayData.pRelayZhaoChaStr[i].wCancelRelayId;
					pRouteCfgDtStr->CancelZhaoChaRelayOnRelayIntrf = RelayData.pRelayZhaoChaStr[i].wCancelRelayIdOnRelayInterface;
					pRouteCfgDtStr->RelayBenDuanZcIdOnRelayIntrf = RelayData.pRelayZhaoChaStr[i].wRelayBenDuanZcIdOnRelayInterface;
					pRouteCfgDtStr->RelayDuiDuanZcIdOnRelayIntrf = RelayData.pRelayZhaoChaStr[i].wRelayDuiDuanZcIdOnRelayInterface;
					
					/*统计有效照查物理区段ID*/
					zhaoChaPhySecNum = 0u;

					for(iIndex = 0u; iIndex < ROUTE_THATZC_PHYSEC_SUM_MAX; iIndex++)
					{
						zCPhySecId = RelayData.pRelayZhaoChaStr[i].wRelayZhaoChaPhySecId[iIndex];


						/*统计有效照查物理区段ID*/
						if((0xffffu != zCPhySecId)&&(0u != zCPhySecId))
						{
							pRouteCfgDtStr->ThatZhaoChaPhySecIdBuf[zhaoChaPhySecNum] = zCPhySecId;
							zhaoChaPhySecNum++;
						}
						else
						{
						}
					}
					pRouteCfgDtStr->ThatZhaoChaPhySecSum = zhaoChaPhySecNum;

					break;		/* 一条进路应该只有一个照查信息 */
				}
				else
				{
				}
			}

			/*以本进路始端信号机为终端信号机的折返进路*/
			pRouteCfgDtStr->SignalOpposedRouteSum = 0u;
			index=0u;
			routeStartSignal = pRouteCfgDtStr->StartSignalId;
			for(i = 0u; i <LSDataLen.LSRouteStrLen; i++)
			{
				if(i < dsuDataLenStru.wRouteLen)
				{
					routeEndSignal =dsuStaticHeadStru.pRouteStru[dsuRouteIndex[LSData.pLSRouteStr[i].wRouteId]].wEndSignalId;
					if((routeStartSignal == routeEndSignal) && 
						(0x02u == (dsuStaticHeadStru.pRouteStru[dsuRouteIndex[LSData.pLSRouteStr[i].wRouteId]].wRouteType & 0x02u)))
					{/*此条折返进路的终端信号机为当前进路的始端信号机*/  /*风井折返进路和普通折返进路*/
						if(ROUTE_SIGNAL_OPPOSED_ROUTE_SUM_MAX > index)
						{
							pRouteCfgDtStr->SignalOpposedRouteIdBuf[index] = LSData.pLSRouteStr[i].wRouteId;
						    index++;
						}
						else
						{
							rtnvalue = CI_ERROR;
							index = 0u;
							debug_infor_printf((const)"error: SignalOpposedRouteIdBuf not enough space");
							break;
						}
						
					}
					else
					{
					}
				}
				else
				{
				}
				
			}
			pRouteCfgDtStr->SignalOpposedRouteSum = index;

			if(CI_SUCCESS == rtnvalue)
			{/*以本进路始端信号机为终端信号机的进路*/
				pRouteCfgDtStr->SigisEndSigRouteSum = 0u;
				index=0u;
				routeStartSignal = pRouteCfgDtStr->StartSignalId;
				for(i = 0; i <LSDataLen.LSRouteStrLen; i++)
				{
					if(i < dsuDataLenStru.wRouteLen)
					{
						routeEndSignal =dsuStaticHeadStru.pRouteStru[dsuRouteIndex[LSData.pLSRouteStr[i].wRouteId]].wEndSignalId;
						if(routeStartSignal == routeEndSignal)
						{/*此条进路的终端信号机为当前进路的始端信号机*/  
							if(ROUTE_SIGNAL_OPPOSED_ROUTE_SUM_MAX > index)
							{
								pRouteCfgDtStr->SigisEndSigRouteIdBuf[index] = LSData.pLSRouteStr[i].wRouteId;
								index++;
							}
							else
							{
								rtnvalue = CI_ERROR;
								index = 0u;
								debug_infor_printf((const)"error: SigisEndSigRouteIdBuf not enough space");
								break;
							}

						}
					}

				}
				pRouteCfgDtStr->SigisEndSigRouteSum = index;
			}

			if(CI_SUCCESS == rtnvalue)
			{
				/*进路相关封锁信号机数目 (配置字段)*/
				pRouteCfgDtStr->RouteInitFSStatus = ROUTE_INIT_NOT_FS;
				pRouteCfgDtStr->RouteFSSignalSum = 0u;
				index=0u;
				findFlag = 0u;
				for(i=0u;i<LSDataLen.LSSignalStrLen;i++)
				{
					if ((0u!=pLSRouteStr->wFS_SignalId) && (65535u!=pLSRouteStr->wFS_SignalId))
					{
						if(pLSRouteStr->wFS_SignalId == LSData.pLSSignalStr[i].wId)
						{
							for(j=0u;j<MAX_INCLUDE_SIGNAL_NUM;j++)
							{
								if((0u != LSData.pLSSignalStr[i].wSignalId[j]) && ((UINT16)UINT16_MAX != LSData.pLSSignalStr[i].wSignalId[j]))
								{/*修改前：判断信号机所属联锁等于进路所属联锁，导致进路终端信号机在其他联锁时，封锁终端信号机不关闭信号*/
									if(ROUTE_FENGSUO_SIGNAL_SUM_MAX > index)
									{
										pRouteCfgDtStr->RouteFSSignalIdBuf[index]=LSData.pLSSignalStr[i].wSignalId[j];
									    index++;
									}
									else
									{
										rtnvalue = CI_ERROR;
										index = 0u;
										debug_infor_printf((const)"error: RouteFSSignalIdBuf not enough space");
										break;
									}
									
								}
								else
								{
								}
							}
							findFlag = 1u;
						}
						else
						{
						}
						if (0u == findFlag)
						{
							pRouteCfgDtStr->RouteInitFSStatus = ROUTE_INIT_FS;
						}
						else
						{
							pRouteCfgDtStr->RouteInitFSStatus = ROUTE_INIT_NOT_FS;
						}
					}
					else
					{
					}
				}

			}
			else
			{
			}
			pRouteCfgDtStr->RouteFSSignalSum = index;

			/*进路开放需关闭信号机数目 (配置字段)*/
			if(CI_SUCCESS == rtnvalue)
			{
				pRouteCfgDtStr->OpenNeedCloseSigSum = 0u;
				index=0u;
				for(i=0u;i<LSDataLen.LSSignalStrLen;i++)
				{
					if(pLSRouteStr->wSignalClsId == LSData.pLSSignalStr[i].wId)
					{
						for(j=0u;j<MAX_INCLUDE_SIGNAL_NUM;j++)
						{
							if((0u != LSData.pLSSignalStr[i].wSignalId[j]) && (UINT16_MAX != LSData.pLSSignalStr[i].wSignalId[j]))
							{
								if(ROUTE_OPENNEEDCLOSESIG_SUM_MAX > index)
								{
									pRouteCfgDtStr->OpenNeedCloseSigIdBuf[index]=LSData.pLSSignalStr[i].wSignalId[j];
									index++;
								}
								else
								{
									rtnvalue = CI_ERROR;
									index = 0u;
									debug_infor_printf((const)"error: OpenNeedCloseSigIdBuf not enough space");
									break;
								}								
							}
							else
							{
							}
						}
					}
					else
					{
					}
				}
			}
			else
			{
			}
			pRouteCfgDtStr->OpenNeedCloseSigSum = index;
			/*进路开放需开放信号机数目 (配置字段)*/
			if(CI_SUCCESS == rtnvalue)
			{
				pRouteCfgDtStr->OpenNeedOpenSigSum = 0u;
				index=0u;
				for(i=0u;i<LSDataLen.LSSignalStrLen;i++)
				{
					if(pLSRouteStr->wSignalOpenId == LSData.pLSSignalStr[i].wId)
					{
						for(j=0u;j<MAX_INCLUDE_SIGNAL_NUM;j++)
						{
							if(0u != LSData.pLSSignalStr[i].wSignalId[j])
							{
								if(ROUTE_OPENNEEDOPENSIG_SUM_MAX > index)
								{
									pRouteCfgDtStr->OpenNeedOpenSigIdBuf[index]=LSData.pLSSignalStr[i].wSignalId[j];
								   index++;
								}
								else
								{
									rtnvalue = CI_ERROR;
									index = 0u;
									debug_infor_printf((const)"error: OpenNeedOpenSigIdBuf not enough space");
									break;
								}
							}
							else
							{
							}
						}
					}
					else
					{
					}
				}
			}
			else
			{
			}
			pRouteCfgDtStr->OpenNeedOpenSigSum = index;

			/*TODO:读取CBTC开放需开放信号机到pRouteCfgDtStr结构体相应变量中:@liuchang*/

			/*不同时开放信号机组数目 (配置字段)*/
			if(CI_SUCCESS == rtnvalue)
			{
				pRouteCfgDtStr->CBTCOpenNeedOpenSigSum = 0u;
				index = 0u;
				for (i = 0u; i < LSDataLen.LSSignalStrLen; i++)
				{
					/*遍历LSData中的信号机组结构体，找到ID与设置的wCBTCSignalOpenId一致的ID*/
					
					if (pLSRouteStr->wCBTCSignalOpenId == LSData.pLSSignalStr[i].wId)
					{
						/*找到LSData中的CBTC进路开放需开放信号机组*/
						for (j = 0u; j < MAX_INCLUDE_SIGNAL_NUM; j++)
						{
							if (0u != LSData.pLSSignalStr[i].wSignalId[j])
							{
								/*只遍历CBTC进路开放需开放信号机的可容纳信号机数量*/
								if (ROUTE_OPENNEEDOPENSIG_SUM_MAX > index)
								{
									/*将LSData中CBTC进路开放需开放信号机列中的信号机ID赋值给pRouteCfgDtStr中的CBTCOpenNeedOpenSigIdBuf*/
									pRouteCfgDtStr->CBTCOpenNeedOpenSigIdBuf[index] = LSData.pLSSignalStr[i].wSignalId[j];
									index++;
								}
								else
								{
									rtnvalue = CI_ERROR;
									index = 0u;
									debug_infor_printf((const)"error: CBTCOpenNeedOpenSigIdBuf not enough space");
									break;
								}
							}
							else
							{
							}
						}
						break;
					}
					else
					{
					}
				}
			}
			else
			{
			}
			pRouteCfgDtStr->CBTCOpenNeedOpenSigSum = index;

			/*不同时开放信号机组数目 (配置字段)*/
			if(CI_SUCCESS == rtnvalue)
			{
				pRouteCfgDtStr->OnlyOneOpenSigSum = 0u;
				index=0u;
				for(i=0u;i<LSDataLen.LSSignalStrLen;i++)
				{
					if(pLSRouteStr->wBTSOpenId == LSData.pLSSignalStr[i].wId)
					{
						for(j=0u;j<MAX_INCLUDE_SIGNAL_NUM;j++)
						{
							if(0u !=LSData.pLSSignalStr[i].wSignalId[j])
							{
								if(ROUTE_ONLYONEOPENSIG_SUM_MAX > index)
								{
									pRouteCfgDtStr->OnlyOneOpenSigIdBuf[index]=LSData.pLSSignalStr[i].wSignalId[j];
								    index++;
								}
								else
								{
									rtnvalue = CI_ERROR;
									index = 0u;
									debug_infor_printf((const)"error: OnlyOneOpenSigIdBuf not enough space");
									break;
								}
							}
							else
							{
							}
						}
					}
					else
					{
					}
				}
			}
			else
			{
			}
			pRouteCfgDtStr->OnlyOneOpenSigSum = index;
		#if 0 /* 其他联锁检查条件直接放到其他联锁检查条件表中 */
			/*CBTC进路Psd数 (配置字段)*/
			/*CBTC进路Esb数 (配置字段)*/
			pRouteCfgDtStr->CbtcEsbSum = 0u;
			pRouteCfgDtStr->CbtcPsdSum = 0u;
			for(i=0u;i<LSDataLen.LSOterCiStrLen;i++)
			{
				if(LSData.pLSOterCiStr[i].wId == pLSRouteStr->wCBTCOtherCIID)
				{
					for(j=0u;j<OTHER_MAX_EMERG_CLSBTN_NUM;j++)
					{
						if(LSData.pLSOterCiStr[i].wEmgClsBtn[j] != 0u)
						{
							pRouteCfgDtStr->CbtcEsbIdBuf[pRouteCfgDtStr->CbtcEsbSum] = LSData.pLSOterCiStr[i].wEmgClsBtn[j];
							pRouteCfgDtStr->CbtcEsbSum++;
						}
						else
						{
						}
					}
					for(k=0u;k<OTHER_MAX_PSD_NUM;k++)
					{
						if(LSData.pLSOterCiStr[i].wPsdId[k] != 0u)
						{
							pRouteCfgDtStr->CbtcPsdIdBuf[pRouteCfgDtStr->CbtcPsdSum] = LSData.pLSOterCiStr[i].wPsdId[k];
							pRouteCfgDtStr->CbtcPsdSum++;
						}
						else
						{
						}
					}
				}
				else
				{
				}
			}

			/*BLOC进路Psd数 (配置字段)*/
			/*BLOC进路Esb数 (配置字段)*/
			pRouteCfgDtStr->BlocEsbSum = 0u;
			pRouteCfgDtStr->BlocPsdSum = 0u;
			for(i=0u;i<LSDataLen.LSOterCiStrLen;i++)
			{
				if(LSData.pLSOterCiStr[i].wId == pLSRouteStr->wBLCKOtherCIID)
				{
					for(j=0u;j<OTHER_MAX_EMERG_CLSBTN_NUM;j++)
					{
						if(LSData.pLSOterCiStr[i].wEmgClsBtn[j] != 0u)
						{
							pRouteCfgDtStr->BlocEsbIdBuf[pRouteCfgDtStr->BlocEsbSum] = LSData.pLSOterCiStr[i].wEmgClsBtn[j];
							pRouteCfgDtStr->BlocEsbSum++;
						}
						else
						{
						}
					}
					for(k=0u;k<OTHER_MAX_PSD_NUM;k++)
					{
						if(LSData.pLSOterCiStr[i].wPsdId[k] != 0u)
						{
							pRouteCfgDtStr->BlocPsdIdBuf[pRouteCfgDtStr->BlocPsdSum] = LSData.pLSOterCiStr[i].wPsdId[k];
							pRouteCfgDtStr->BlocPsdSum++;
						}
						else
						{
						}
					}
				}
				else
				{
				}
			}
		#else
			/* 其他联锁条件数量设置，Bloc，CBTC */
			pRouteCfgDtStr->BlockOtherCiSum = 0u;
			pRouteCfgDtStr->CbtcOtherCiSum = 0u;
			for(i=0u;i<LSDataLen.LSOterCiStrLen;i++)
			{
				if(LSData.pLSOterCiStr[i].wId == pLSRouteStr->wBLCKOtherCIID)
				{
					for(j=0u;j< OTHER_CI_MAX_DEV_NUM;j++)
					{
						checkResult = CheckInputOtherCiDevInfoValid(&LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j]);
						if(CI_SUCCESS == checkResult)
						{
							if(ROUTE_OHTER_CHECK_SUM_MAX > (pRouteCfgDtStr->BlockOtherCiSum))
							{
								pRouteCfgDtStr->BlockOtherCiBuff[pRouteCfgDtStr->BlockOtherCiSum].DevId = LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wId;
								pRouteCfgDtStr->BlockOtherCiBuff[pRouteCfgDtStr->BlockOtherCiSum].DevStatus = LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wDevStatus;
								pRouteCfgDtStr->BlockOtherCiBuff[pRouteCfgDtStr->BlockOtherCiSum].DevType = (UINT8)(LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wDevType);
								pRouteCfgDtStr->BlockOtherCiSum++;
							}
							else
							{
								rtnvalue = CI_ERROR;
								debug_infor_printf((const)"error: BlockOtherCiBuff not enough space");
								break;
							}
						}
						else
						{
						}
					}
				}
				else
				{
				}

				if(LSData.pLSOterCiStr[i].wId == pLSRouteStr->wCBTCOtherCIID)
				{
					for(j=0u;j< OTHER_CI_MAX_DEV_NUM;j++)
					{
						checkResult = CheckInputOtherCiDevInfoValid(&LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j]);
						if(CI_SUCCESS == checkResult)
						{
							if(ROUTE_OHTER_CHECK_SUM_MAX > (pRouteCfgDtStr->CbtcOtherCiSum))
							{					
								pRouteCfgDtStr->CbtcOtherCiBuff[pRouteCfgDtStr->CbtcOtherCiSum].DevId = LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wId;
								pRouteCfgDtStr->CbtcOtherCiBuff[pRouteCfgDtStr->CbtcOtherCiSum].DevStatus = LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wDevStatus;
								pRouteCfgDtStr->CbtcOtherCiBuff[pRouteCfgDtStr->CbtcOtherCiSum].DevType = (UINT8)(LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wDevType);
								pRouteCfgDtStr->CbtcOtherCiSum++;
							}
							else
							{
								rtnvalue = CI_ERROR;
								debug_infor_printf((const)"error: CbtcOtherCiBuff not enough space");
								break;
							}
						}
						else
						{
						}
					}
				}
				else
				{
				}
			}
			
		#endif

			/*获取进路内方第一逻辑区段ID (配置字段)*/
			devId = pDsuRouteStr->wIncludeAxleSgmtId[0];
		
			for (i=0u;i<dsuDataLenStru.wAxleSgmtLen;i++)
			{
				if (devId == dsuStaticHeadStru.pAxleSgmtStru[i].wId)
				{
					if (CI_SYSTEM_DIRECTION_UP == pLSRouteStr->wDir)
					{
						/*与LINK方向相同*/
						index = 0u;
						pRouteCfgDtStr->InFirstLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index];			
					} 
					else
					{
						/*与LINK方向相反*/
						index = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru[i].wIncludeLogicSgmtNum - 1u);
						if(MAX_ALEX_HAVE_LG_NUM > index)
						{
							pRouteCfgDtStr->InFirstLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index];
						}
						else
						{
							rtnvalue = CI_ERROR;
							debug_infor_printf((const)"error: InFirstLogSec,wLogicSgmtId not enough space");
						}
					}

					break;
				}
				else
				{
				} 
			}

			/*计算进路最后一个逻辑区段ID*/
			lastDevId =  pDsuRouteStr->wIncludeAxleSgmtId[pDsuRouteStr->wIncludeAxleSgmtNum-1u];
			for (i=0u;i<dsuDataLenStru.wAxleSgmtLen;i++)
			{
				if (lastDevId == dsuStaticHeadStru.pAxleSgmtStru[i].wId)
				{
					if (CI_SYSTEM_DIRECTION_UP == pLSRouteStr->wDir)
					{
						/*获取最后一个逻辑区段*/
						if (ROUTE_HAVE_DIR_CHANGE_POINT == pRouteCfgDtStr->HaveDirChangePointInRoute)
						{
							/*进路与LINK方向相同，且有方向变化点，则方向变化点一定是LINK终端对顶*/
							index = 0U;
							pRouteCfgDtStr->InLastLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index];
						}
						else
						{
							index = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru[i].wIncludeLogicSgmtNum - 1u);
							if (MAX_ALEX_HAVE_LG_NUM > index)
							{
								pRouteCfgDtStr->InLastLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index];
							}
							else
							{
								rtnvalue = CI_ERROR;
								debug_infor_printf((const)"error: InLastLogSec,wLogicSgmtId not enough space");
							}
						}
					} 
					else
					{
						/*进路与LINK方向相反，且有方向变化点，则方向变化点一定是LINK始端对顶*/
						if (ROUTE_HAVE_DIR_CHANGE_POINT == pRouteCfgDtStr->HaveDirChangePointInRoute)
						{
							/*进路与LINK方向相同，且有方向变化点，则方向变化点一定是LINK终端对顶*/
							index = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru[i].wIncludeLogicSgmtNum - 1U);
							if (MAX_ALEX_HAVE_LG_NUM > index)
							{
								pRouteCfgDtStr->InLastLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index];
							}
							else
							{
								rtnvalue = CI_ERROR;
								debug_infor_printf((const)"error: InLastLogSec,wLogicSgmtId not enough space");
							}
						}
						else
						{
							index = 0u;
							pRouteCfgDtStr->InLastLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index];
						}
					}

					break;
				} 
				else
				{
					; /*继续查找*/
				}
			}

			/* 防淹门 数据读取 */
			pRouteCfgDtStr->floodGateSum = 0u;
			(void)CommonMemSet(pRouteCfgDtStr->floodGateIdBuf, (UINT32)(sizeof(pRouteCfgDtStr->floodGateIdBuf)/sizeof(UINT8)),0, (UINT32)(sizeof(pRouteCfgDtStr->floodGateIdBuf)/sizeof(UINT8)));
			for (i =0u;i < ROUTE_FLOOD_GATE_SUM_MAX;i++)
			{
				/* 0xFFFF 无效值 */
				if ((UINT16_MAX != pLSRouteStr->wFloodGateIdBuf[i]) && (0u != pLSRouteStr->wFloodGateIdBuf[i]))
				{			
					pRouteCfgDtStr->floodGateIdBuf[pRouteCfgDtStr->floodGateSum] = pLSRouteStr->wFloodGateIdBuf[i];
					pRouteCfgDtStr->floodGateSum++;
				}
				else
				{
				}
			}

			/*不为接近时，是否延时解锁赋值*/
			pRouteCfgDtStr->RouteNeedDelayUnlock = pLSRouteStr->wNeedDelayUnlock;

			/*调车同意继电器ID (配置字段)*/
			pRouteCfgDtStr->DCRouteDCQJId = 0U;
			pRouteCfgDtStr->DCRouteDCQJTwoId = 0U;
			pRouteCfgDtStr->DCRouteTAJId = 0U;

			for(i=0u;i<RelayDataLen.RelayDCAgreeStrLen;i++)
			{
				if(RelayData.pRelayDCAgreeStr[i].wRouteId == pLSRouteStr->wRouteId)
				{			
					pRouteCfgDtStr->DCRouteDCQJId = RelayData.pRelayDCAgreeStr[i].DCRouteDCQJId;
					pRouteCfgDtStr->DCRouteTAJId = RelayData.pRelayDCAgreeStr[i].DCRouteTAJId;
					pRouteCfgDtStr->DCRouteDCQJTwoId = RelayData.pRelayDCAgreeStr[i].DCRouteDCQJTwoId;
					break;
				}
				else
				{
				}
			}

			chLocalCiPattern = GetLocalCiPattern();

			if (CI_PATTERN_FULL_ELECTRONIC == chLocalCiPattern)
			{
				if (0U != pRouteCfgDtStr->DCRouteDCQJId)
				{
					if ((0U == pRouteCfgDtStr->DCRouteTAJId) || (0U == pRouteCfgDtStr->DCRouteDCQJTwoId))
					{
						/*配置了调车请求继电器1有效，未配置调车同意及调查请求继电器2，数据初始化失败*/
						rtnvalue = CI_ERROR;
						debug_infor_printf((const)"error: pRouteCfgDtStr->DCRouteTAJId is 0 or pRouteCfgDtStr->DCRouteDCQJTwoId is 0");
					}
					else
					{

					}
				}
				else
				{
					if ((0U != pRouteCfgDtStr->DCRouteTAJId) || (0U != pRouteCfgDtStr->DCRouteDCQJTwoId))
					{
						/*配置了调车请求继电器无效，配置调车同意有效，数据初始化失败*/
						rtnvalue = CI_ERROR;
						debug_infor_printf((const)"error: pRouteCfgDtStr->DCRouteDCQJId is 0");
					}
					else
					{

					}
				}
			}
			else if (CI_PATTERN_TRADITIONAL == chLocalCiPattern)
			{
				/*继电联锁没有调车请求继电器2*/
				if (0U != pRouteCfgDtStr->DCRouteDCQJId)
				{
					if (0U == pRouteCfgDtStr->DCRouteTAJId)
					{
						/*配置了调车请求继电器有效，未配置调车同意有效，数据初始化失败*/
						rtnvalue = CI_ERROR;
						debug_infor_printf((const)"error: pRouteCfgDtStr->DCRouteTAJId is 0");
					}
					else
					{

					}
				}
				else
				{
					if (0U != pRouteCfgDtStr->DCRouteTAJId)
					{
						/*配置了调车请求继电器无效，配置调车同意有效，数据初始化失败*/
						rtnvalue = CI_ERROR;
						debug_infor_printf((const)"error: pRouteCfgDtStr->DCRouteDCQJId is 0");
					}
					else
					{

					}
				}
			}
			else
			{
				rtnvalue = CI_ERROR;
			}

		}
		else
		{

		}
		if(CI_SUCCESS == rtnvalue)
		{
			/*初始化进路包含的逻辑区段数据*/
			rtnvalue = RouteConfigDataStruLogDataInit(pRouteCfgDtStr,pLSRouteStr);
		}
		else
		{
		}

		/*进路侵限区段结构体*/
		if (CI_SUCCESS == rtnvalue)
		{
			pRouteCfgDtStr->RouteInitInstruStatus = ROUTE_INIT_NOT_INSTRU;
			isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION);

			/*采用旧版本进路侵限条件*/
			if (FUNC_SWITCH_OFF == isEachInvFlag)
			{
				
				pRouteCfgDtStr->RouteIntruPhySecSum = 0u;
				for (i = 0u; i < ROUTE_MAX_QXQD_NUM; i++)
				{
					if ((0u != pLSRouteStr->wIntrudePhySecId[i]) && (UINT16_MAX != pLSRouteStr->wIntrudePhySecId[i]))
					{
						findFlag = 0u;
						pRouteCfgDtStr->RouteIntruPhySecSum++;
						pRouteCfgDtStr->RouteIntruPhySecStru[i].SwitchSum = 0u;
						for (j = 0u; j < LSDataLen.LSIntruPhySecStrLen; j++)
						{
							if (LSData.pLSIntruPhySecStr[j].wId == pLSRouteStr->wIntrudePhySecId[i])
							{
								/*仅当进路表中的侵限区段及条件道岔的ID标号与侵限区段及条件道岔表中的ID相同时,
								将侵限区段及条件道岔表中的侵限区段ID赋值给 pRouteCfgDtStr->RouteIntruPhySecStru[i].SectionId*/
								pRouteCfgDtStr->RouteIntruPhySecStru[i].SectionId = LSData.pLSIntruPhySecStr[j].wIntrudePhySecId;

								for (k = 0u; k < QINXIAN_SWITCH_MAX_NUM; k++)
								{
									if ((0u != LSData.pLSIntruPhySecStr[j].wPointId[k]) && (UINT16_MAX != LSData.pLSIntruPhySecStr[j].wPointId[k]))
									{
										pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[k].SwitchId = LSData.pLSIntruPhySecStr[j].wPointId[k];
										pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[k].SwitchPosition = (UINT8)LSData.pLSIntruPhySecStr[j].wPointSta[k];
										pRouteCfgDtStr->RouteIntruPhySecStru[i].SwitchSum++;
									}
									else
									{
									}

								}
								findFlag = 1u;
								break;
							}
							else
							{
							}
						}
						if (0u == findFlag)
						{
							pRouteCfgDtStr->RouteInitInstruStatus = ROUTE_INIT_INSTRU;
						}
						else
						{
							pRouteCfgDtStr->RouteInitInstruStatus = ROUTE_INIT_NOT_INSTRU;
						}
					}
					else
					{
					}
				}

				/*进路侵限方向初始化*/
				for (i = 0U; i < pRouteCfgDtStr->RouteIntruPhySecSum; i++)
				{
					for (j = 0U; j < pRouteCfgDtStr->RouteInLogTrackSum; j++)
					{
						wLgcSecIndex = dsuLogicSgmtIndex[pRouteCfgDtStr->RouteInLogTrackIdBuf[j]];
						for (k = 0U; k < dquCICfgDtStr.lgcSctCfgDtStr[wLgcSecIndex].chSecInvSecAndConSwiSum; k++)
						{
							if (pLSRouteStr->wIntrudePhySecId[i] == dquCICfgDtStr.lgcSctCfgDtStr[wLgcSecIndex].wszSecInvSecAndConSwiId[k])
							{
								pRouteCfgDtStr->RouteIntruPhySecStru[i].chCondSwitLockDir = dquCICfgDtStr.lgcSctCfgDtStr[wLgcSecIndex].chSecInvSecLockDir[k];

								break;
							}
							else
							{
								;/*继续查询*/
							}
						}
					}
				}
			}
			/*采用逻辑区段互相侵限条件*/
			else
			{
				pRouteCfgDtStr->RouteIntruPhySecSum = 0u;
				
				pRouteCfgDtStr->RouteInitInstruStatus = ROUTE_INIT_NOT_INSTRU;
				/*遍历进路内所有逻辑区段*/
				for (i = 0U; i < pRouteCfgDtStr->RouteInLogTrackSum; i++)
				{
					/*遍历所有转化后的侵限区段及条件道岔数据*/
					for (j = 0U; j < LSDataLen.LSIntruPhySecStrLen; j++)
					{
						/*当进路内逻辑区段ID与侵限条件所属ID一致时，将侵限区段及条件道岔表中的侵限区段ID与侵限方向赋值给 pRouteCfgDtStr->RouteIntruPhySecStru[i].SectionId*/
						if ((LSData.pLSIntruPhySecStr[j].belongLogSecId == pRouteCfgDtStr->RouteInLogTrackIdBuf[i]) && (0U != LSData.pLSIntruPhySecStr[j].belongLogSecId))
						{
							if (ROUTE_INTRUDEPHYSEC_SUM_MAX > pRouteCfgDtStr->RouteIntruPhySecSum)
							{
								pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].SectionId = LSData.pLSIntruPhySecStr[j].wIntrudePhySecId;
								pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].chCondSwitLockDir = LSData.pLSIntruPhySecStr[j].wCondSwitLockDir;

								/*侵限区段及条件道岔表中的侵限道岔信息遍历赋值给pRouteCfgDtStr->RouteIntruPhySecStru*/
								pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].SwitchSum = 0u;
								for (k = 0U; k < QINXIAN_SWITCH_MAX_NUM; k++)
								{
									if ((0u != LSData.pLSIntruPhySecStr[j].wPointId[k]) && (UINT16_MAX != LSData.pLSIntruPhySecStr[j].wPointId[k]))
									{
										pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].ConditionSwitchStru[k].SwitchId = LSData.pLSIntruPhySecStr[j].wPointId[k];
										pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].ConditionSwitchStru[k].SwitchPosition = (UINT8)LSData.pLSIntruPhySecStr[j].wPointSta[k];
										pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].SwitchSum++;
									}
									else
									{
										;
									}
								}
								pRouteCfgDtStr->RouteIntruPhySecSum++;
							}
							else
							{
								/*进路侵限数量超出范围，初始化失败*/
								rtnvalue = CI_ERROR;
								break;
							}
						}
						else
						{
							/*继续查找*/
						}
					}
					
					if (CI_ERROR == rtnvalue)
					{
						debug_infor_printf((const)"[RouteInv] RouteID:%d ERROR: RouteIntruPhySecSum Is Exceed MAX\n", pRouteCfgDtStr->RouteId);
						break;
					}
					else
					{
						/*继续遍历*/
					}
				}
			}

			/*在日志中打印进路侵限条件表*/
			if ((0U < pRouteCfgDtStr->RouteIntruPhySecSum) && (CI_SUCCESS == rtnvalue))
			{
				for ( i = 0U; i < pRouteCfgDtStr->RouteIntruPhySecSum; i++)
				{
					debug_infor_printf((const)"[RouteInv] RouteID:%d, InvSecID:%d, Dir:%d, SwitchID:%d-%d-%d-%d-%d-%d, SwitchState:%d-%d-%d-%d-%d-%d\n", pRouteCfgDtStr->RouteId, pRouteCfgDtStr->RouteIntruPhySecStru[i].SectionId, pRouteCfgDtStr->RouteIntruPhySecStru[i].chCondSwitLockDir,
						pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[0].SwitchId, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[1].SwitchId, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[2].SwitchId, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[3].SwitchId, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[4].SwitchId, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[5].SwitchId,
						pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[0].SwitchPosition, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[1].SwitchPosition, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[2].SwitchPosition, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[3].SwitchPosition, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[4].SwitchPosition, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[5].SwitchPosition);


				}
			}
			else
			{
				;
			}
		}


#if 0
		/*初始化主进路属性*/
		if (CI_SUCCESS == rtnvalue)
		{

			if (SIGNAL_VIRTUAL_NO == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[pRouteCfgDtStr->StartSignalId]].signalVirtualAttr
				&& SIGNAL_VIRTUAL_NO == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[pRouteCfgDtStr->EndSignalId]].signalVirtualAttr)
			{
				pRouteCfgDtStr->MainRouteProperty = ROUTE_MAIN_PROPERTY;
			}
			else
			{
				pRouteCfgDtStr->MainRouteProperty = ROUTE_SUB_PROPERTY;
				pRouteCfgDtStr->RouteSubSum = 0U;
			}
		}
		else
		{
		}
#endif
	}
	else
	{
	rtnvalue = CI_ERROR;
	}
	return rtnvalue;
}

/*
*函数功能：进路包含的逻辑区段数据初始化
*参数说明：pRouteCfgDtStr进路配置数据结构体指针
*返回值：0，失败；1，成功
*/
UINT8 RouteConfigDataStruLogDataInit(RouteConfigDataStruct * pRouteCfgDtStr, LS_RouteStruct * pLSRouteStr)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT16 k = 0u;
	UINT8 phyShouldFlag = 0u;
	UINT8 rtnvalue = CI_ERROR;
	UINT8 cRouteDir = 0u;
	UINT16 routeAxleNum = 0u;
	UINT16 routeAxleId = 0u;
	UINT16 axleLTrackId = 0u;
	UINT16 axleBelongPhy = 0u;                   /*计轴区段所属的物理区段*/

	DSU_ROUTE_STRU* pDsuRouteStr = NULL;
	DSU_AXLE_SGMT_STRU* pDsuAxleSgmtStr = NULL;  /*计轴区段信息结构体*/
	
	if((NULL != pRouteCfgDtStr) && (NULL != pLSRouteStr))
	{
		rtnvalue = CI_SUCCESS;
		/*初始化为0*/
		pRouteCfgDtStr->RouteInLogTrackSum = 0u;
		for(i = 0U; i < MAX_ROUTE_IN_LT_NUM; i++)
		{
			pRouteCfgDtStr->RouteInLogTrackIdBuf[i] = 0u;
		}
		/*获取进路包含的计轴区段数据*/
		pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[pRouteCfgDtStr->RouteId];
		routeAxleNum = pDsuRouteStr->wIncludeAxleSgmtNum;

		/*获取进路始端信号机信息*/
		cRouteDir = pLSRouteStr->wDir;
		/*不存在方向变化点*/
		if(ROUTE_NOT_HAVE_DIR_CHANGE_POINT == pRouteCfgDtStr->HaveDirChangePointInRoute)
		{
			/*防护方向为0x55(与link方向相同)*/
			if(CI_SYSTEM_DIRECTION_UP == cRouteDir)
			{
				for(i = 0U; i < routeAxleNum; i++)
				{
					/*获取计轴区段信息*/
					routeAxleId = pDsuRouteStr->wIncludeAxleSgmtId[i];
					pDsuAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[routeAxleId];
					for(j = 0U; j < pDsuAxleSgmtStr->wIncludeLogicSgmtNum; j++)
					{
						axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[j];
						/*填充进路包含逻辑区段ID*/
						pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId;
					}
				}
			}
			/*防护方向为0xaa(与link方向相反,逻辑区段取反方向)*/
			else if(CI_SYSTEM_DIRECTION_DOWN == cRouteDir)
			{
				for(i = 0U; i < routeAxleNum; i++)
				{
					/*获取计轴区段信息*/
					routeAxleId = pDsuRouteStr->wIncludeAxleSgmtId[i];
					pDsuAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[routeAxleId];

					for(j = pDsuAxleSgmtStr->wIncludeLogicSgmtNum; j > 0U; j--)
					{
						axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[j-1U];
						/*填充进路包含逻辑区段ID*/
						pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId;
					}
				}
			}
			/*其他情况*/
			else
			{
				/*返回失败*/
				rtnvalue = CI_ERROR;
				debug_infor_printf((const)"\nROUTE_startSignalDir err %d\n",pRouteCfgDtStr->RouteId);
			}
		}
		/*存在方向变化点*/
		else
		{
			/*防护方向为0x55(与link方向相同)*/
			if(CI_SYSTEM_DIRECTION_UP == cRouteDir)
			{
				for(i = 0u; i < routeAxleNum; i++)
				{
					phyShouldFlag = 0u;
					/*获取计轴区段信息*/
					routeAxleId = pDsuRouteStr->wIncludeAxleSgmtId[i];
					pDsuAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[routeAxleId];
					axleBelongPhy = pDsuAxleSgmtStr->wRelatePhysicalSgmtId;
					for(j = 0u; j < pRouteCfgDtStr->RoutePhySecSum; j++)
					{
						/*匹配物理区段*/
						if(axleBelongPhy == pRouteCfgDtStr->RoutePhySectionStru[j].PhysicalSectionId)
						{
							/*进路的物理区段应该取反*/
							if(ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == pRouteCfgDtStr->RoutePhySectionStru[j].LockDirShouldOpposedToRoute)
							{
								phyShouldFlag = 1u;

							}
						}
					}
					/*计轴区段关联的物理区段取反*/
					if(1u == phyShouldFlag)
					{
						for(k = pDsuAxleSgmtStr->wIncludeLogicSgmtNum; k > 0u; k--)
						{
							axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[k-1u];
							/*填充进路包含逻辑区段ID*/
							pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId;
						}
					}
					/*不取反*/
					else
					{
						for(k = 0u; k < pDsuAxleSgmtStr->wIncludeLogicSgmtNum; k++)
						{
							axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[k];
							/*填充进路包含逻辑区段ID*/
							pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId;
						}
					}
				}
			}
			/*防护方向为0xaa(与link方向相反,逻辑区段取反方向)*/
			else if(CI_SYSTEM_DIRECTION_DOWN == cRouteDir)
			{
				for(i = 0u; i < routeAxleNum; i++)
				{
					phyShouldFlag = 0u;
					/*获取计轴区段信息*/
					routeAxleId = pDsuRouteStr->wIncludeAxleSgmtId[i];
					pDsuAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[routeAxleId];
					axleBelongPhy = pDsuAxleSgmtStr->wRelatePhysicalSgmtId;
					for(j = 0u; j < pRouteCfgDtStr->RoutePhySecSum; j++)
					{
						/*匹配物理区段*/
						if(axleBelongPhy == pRouteCfgDtStr->RoutePhySectionStru[j].PhysicalSectionId)
						{
							/*进路的物理区段应该取反*/
							if(ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == pRouteCfgDtStr->RoutePhySectionStru[j].LockDirShouldOpposedToRoute)
							{
								phyShouldFlag = 1u;

							}
						}
					}
					/*计轴区段关联的物理区段取反*/
					if(1u == phyShouldFlag)
					{
						for(k = 0u; k < pDsuAxleSgmtStr->wIncludeLogicSgmtNum; k++)
						{
							axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[k];
							/*填充进路包含逻辑区段ID*/
							pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId;
						}
					}
					/*不取反,逻辑区段按反方向填*/
					else
					{
						for(k = pDsuAxleSgmtStr->wIncludeLogicSgmtNum; k > 0u; --k)
						{
							axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[k-1U];
							/*填充进路包含逻辑区段ID*/
							pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId;
						}
					}
				}
			}
			else
			{
				/*返回失败*/
				rtnvalue = CI_ERROR;
				debug_infor_printf((const)"\nROUTE_startSignalDir err %d\n",pRouteCfgDtStr->RouteId);
			}
		}
	}
	else
	{
		/*返回失败*/
		rtnvalue = CI_ERROR;
	}

	
	return(rtnvalue);
}

/*********************************************
*函数功能：初始化进路配置数据
*参数说明：FSName逻文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 RouteConfigDataStructInit(CHAR * FSName)
{
	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;
	UINT8 execRet = 0u;
	UINT8 chDataType = DATA_TYPE_NEW;
	chDataType = GetLocalPublicDataType();/*用于28.0.0.14不进行逻辑区段关联进路初始化*/
	callFun  = dfsEmapInit(FSName);
	callFun *= InitLS_RouteStruct(FSName);
	callFun *= InitLS_AutoRtnRouteStru(FSName);
	callFun *= InitLS_ReverseRouteStru(FSName);
	callFun *= InitLS_RoutePhyAndCheckStaStru( FSName);
	callFun *= InitLS_FHDaoChaStru(FSName);
	callFun *= InitLS_DrivedSwitchGroupStru(FSName);
	callFun *= InitLS_DDXHStru(FSName);
	callFun *= InitLS_DDXHZStru(FSName);
	callFun *= InitLS_SignalStruct(FSName);
	callFun *= InitLS_OtherCIStruct(FSName);
	/*add in 2013.05.03，需在函数RouteCfgDtStruFrmLSRouteStr()前被调用*/
	callFun *= InitRelay_ZhaoChaStru(FSName);

	callFun *= InitRelay_DCAgreeStru(FSName);/*初始化调车同意继电器表*/
	callFun *= InitLS_SGBJStru(FSName);  /*初始化声光报警表*/
	callFun *= InitLS_TransRouteRtnDataStruct(FSName);  /*初始化转换轨折返信号机表*/
	callFun *= InitLS_AirShaftRouteStru(FSName);	/*初始化风井进路检查表*/

	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{	 
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		/*电子地图初始化成功，继续执行*/
		dquCICfgDtStr.RouteCfgDtStrLen = LSDataLen.LSRouteStrLen;

		for(i=0u;i<LSDataLen.LSRouteStrLen;i++)
		{
			if (i >= ROUTE_SUM_MAX)
			{
				rtnvalue = 0u;
			}
			/*正常执行，继续循环*/
			execRet = RouteCfgDtStruFrmLSRouteStr(LSData.pLSRouteStr + i,&(dquCICfgDtStr.RouteCfgDtStr[i]), dquCICfgDtStr.OvlapCfgDtStr);
			if(execRet > 0u)
			{
			}
			else
			{/*调用函数失败，返回0*/
				rtnvalue = 0u;
			}

			if (1U == rtnvalue)
			{
				/*初始化进路点式接近区段逻辑区段数据*/
				execRet = RouteBlocNearLogSecInit(LSData.pLSRouteStr + i, &(dquCICfgDtStr.RouteCfgDtStr[i]));
				if (0U < execRet)
				{
					; /*继续执行*/
				}
				else
				{/*调用函数失败，返回0*/
					rtnvalue = 0u;
				}
			}

			if (1U != rtnvalue)
			{
				break;
			}
		}
	}

	if (1u == rtnvalue)
	{
		for(i=0u;i<LSDataLen.LSRouteStrLen;i++)
		{
			if (i >= ROUTE_SUM_MAX)
			{
				rtnvalue = 0u;
			}
			execRet = RouteOpposedConfigDataInite(dquCICfgDtStr.RouteCfgDtStr,&(dquCICfgDtStr.RouteCfgDtStr[i]));
			/*抵触进路初始化*/
			if(execRet > 0u)
			{
			}
			else
			{/*调用函数失败，返回0*/
				rtnvalue = 0u;
			}
		

			if (1U == rtnvalue)
			{
				/*初始化进路第一离去逻辑区段数据*/
				execRet = RouteFirstLeaveLogSecInit(LSData.pLSRouteStr + i, &(dquCICfgDtStr.RouteCfgDtStr[i]));
				if (0U < execRet)
				{
					; /*继续执行*/
				}
				else
				{/*调用函数失败，返回0*/
					rtnvalue = 0u;
				}
			}


			if (1U != rtnvalue)
			{
				break;
			}
		}
	}
	if (1u == rtnvalue)
	{
		for (i = 0u; i<LSDataLen.LSRouteStrLen; i++)
		{
			if (i >= ROUTE_SUM_MAX)
			{
				rtnvalue = 0u;
			}
			execRet = RouteOutLgcSecConfigDataInit(&(dquCICfgDtStr.RouteCfgDtStr[i]));
			/*抵触进路初始化*/
			if (execRet > 0u)
			{
			}
			else
			{/*调用函数失败，返回0*/
				rtnvalue = 0u;
			}

			if (1U != rtnvalue)
			{
				break;
			}
		}
	}

	/*主进路与子进路相关数据初始化*/
	if (1u == rtnvalue)
	{
		for (i = 0u; i < LSDataLen.LSRouteStrLen; i++)
		{
			if (i >= ROUTE_SUM_MAX)
			{
				rtnvalue = 0u;
			}
			if ((CI_TYPE_ZX == (UINT8)dsuStaticHeadStru.pCIStruStru[dsuCIIndex[dquCICfgDtStr.RouteCfgDtStr[i].BelongCiId]].wType)
				|| (CI_TYPE_SCX == (UINT8)dsuStaticHeadStru.pCIStruStru[dsuCIIndex[dquCICfgDtStr.RouteCfgDtStr[i].BelongCiId]].wType))
			{
				execRet = RouteMainProConfigDataInit(dquCICfgDtStr.RouteCfgDtStr, &(dquCICfgDtStr.RouteCfgDtStr[i]));
				if (execRet > 0u)
				{
				}
				else
				{/*调用函数失败，返回0*/
					rtnvalue = 0u;
				}
				if (1U != rtnvalue)
				{
					break;
				}
			}
			else
			{
				dquCICfgDtStr.RouteCfgDtStr[i].MainOrSubData.RouteBelMainSum = 0U;
				dquCICfgDtStr.RouteCfgDtStr[i].MainOrSubData.RouteSubSum = 0U;
				dquCICfgDtStr.RouteCfgDtStr[i].MainOrSubData.MainRouteProperty = ROUTE_INIT_PROPERTY;  /*车辆段默认为普通进路*/
			}
		}
	}

	/*逻辑区段关联进路及防护道岔计算*/
	if (1u == rtnvalue)
	{
		if (DATA_TYPE_NEW == chDataType)
		{
			for (i = 0u; i < dquCICfgDtStr.lgcSctCfgDtStrLen; i++)
			{
				execRet = LogRelateRouteDataInit(dquCICfgDtStr.RouteCfgDtStr, &(dquCICfgDtStr.lgcSctCfgDtStr[i]));/*逻辑区段关联进路计算*/
				execRet *= LogRelateOverlapDataInit(dquCICfgDtStr.OvlapCfgDtStr, &(dquCICfgDtStr.lgcSctCfgDtStr[i]));/*逻辑区段关联保护区段计算*/
				execRet *= LogRelateProSwDataInit(dquCICfgDtStr.RouteCfgDtStr, &(dquCICfgDtStr.lgcSctCfgDtStr[i]));/*逻辑区段关联防护道岔计算*/

				if (execRet > 0u)
				{

				}
				else
				{/*调用函数失败，返回0*/
					rtnvalue = 0u;
				}
				if (1U != rtnvalue)
				{
					break;
				}
			}
		}
		else
		{
			/*28.0.0.14数据结构暂不支持逻辑区段关联进路及防护道岔*/
			/*影响功能：逻辑进路 部分进路 部分锁闭 逻辑区段资源计算*/
			rtnvalue = 1U;
		}
	}

	/*进路关联声光报警器计算*/
	if (1U == rtnvalue)
	{
		for (i = 0U; i < LSDataLen.LSRouteStrLen; i++)
		{
			if (i >= ROUTE_SUM_MAX)
			{
				rtnvalue = 0U;
			}
			else
			{
				/*继续执行*/
			}

			execRet = RouteRelatedSGBJCfgDataInit(&(dquCICfgDtStr.RouteCfgDtStr[i]), LSData.pLSSGBJStru);  /*进路关联声光报警器计算*/

			if (execRet > 0U)
			{
				/*继续执行*/
			}
			else
			{
				rtnvalue = 0U;  /*计算失败，返回0*/
			}

			if (1U != rtnvalue)
			{
				break;
			}
		}
	}
	/*进路关联 转换轨折返信号机计算*/
	if (1U == rtnvalue)
	{
		for (i = 0U; i < LSDataLen.LSRouteStrLen; i++)
		{
			if (i >= ROUTE_SUM_MAX)
			{
				rtnvalue = 0U;
			}
			else
			{
				/*继续执行*/
			}

			execRet = RouteRelatedTransZFSigInit(&(dquCICfgDtStr.RouteCfgDtStr[i]), LSData.pLSTransRouteZFSigStru);  /*进路关联转换轨折返信号机计算*/

			if (execRet > 0U)
			{
				/*继续执行*/
			}
			else
			{
				rtnvalue = 0U;  /*计算失败，返回0*/
			}

			if (1U != rtnvalue)
			{
				break;
			}
		}
	}
	if (1U == rtnvalue)
	{
		for (i = 0U; i < LSDataLen.LSRouteStrLen; i++)
		{
			if (i >= ROUTE_SUM_MAX)
			{
				rtnvalue = 0U;
			}
			else
			{
			}
			execRet = AirShaftSectionDataInit(&(dquCICfgDtStr.RouteCfgDtStr[i]), LSData.pLSAirShaftRouteStru);  /*进路风井进路物理区段计算*/
			if (execRet > 0U)
			{
			}
			else
			{
				rtnvalue = 0U;  /*计算失败，返回0*/
			}
			if (1U != rtnvalue)
			{
				break;
			}
		}
	}
	return rtnvalue;
}

/*********************************************
*函数功能：按行解析通信关系（从设备IP表里去到的数据，每行17个数据）
*参数说明：Data通信数组
*返回值：0，失败；1，成功
*********************************************/
UINT8 TransmitRelationDataStruFrmSZ(UINT16 Data[])
{
	UINT8 rtnvalue = 0u;
	UINT16 i=0u;
	UINT16 j =0u;
	UINT16 Type = 0u;
	UINT16 findIndex = 0u;/*在既有的zcdus通信关系表中找到的索引，0：未找到，其它值：找到的索引*/
	UINT8 tmpCiId=0u;	/*临时变量：ci id*/
	UINT8 tmpOtherSysType =0u;/*临时变量：其它系统类型*/
	UINT8 findFlag = 0u;	/*找到标志*/

	/*入口参数防护*/
	if(NULL == Data)
	{
		/*返回失败*/
		return 0u;
	}
	else
	{
	}

	if((0x3c00u != (Data[0]&0xFF00u)))
	{
		rtnvalue = 1u;
		return rtnvalue;
	}
	else
	{  }
#if 0
	/*第二个数据项是有效数据长度*/
	for(i=0u;i<Data[1];i++)
	{
		/*从第三个开始是通信设备type+ID*/
		if(Type != (Data[2+i]&0xFF00))
		{
			/*不同类型的设备，才需要增加通信关系数据*/
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].CiId = (UINT8)(Data[0]&0x00FF);
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].SystemType = (UINT8)((Data[2+i]&0xFF00)>>8);
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum = 0;
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceIdBuf[dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum] = (UINT8)(Data[2+i]&0x00FF);
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum++;
			dquCICfgDtStr.TrsmtRlsDtStrLen++;
			Type = (Data[2+i]&0xFF00);
		}
		/*相同的通信设备，只记录一下ID就好(代码默认相同的设备类型写在了一起)*/
		else
		{
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen-1].DeviceIdBuf[dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen-1].DeviceSum] = (UINT8)(Data[2+i]&0x00FF);
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen-1].DeviceSum++;
		}
	}
#endif
	/*第二个数据项是有效数据长度*/
	for(i=0u;i<Data[1];i++)
	{
		tmpCiId = (UINT8)(Data[0]&0x00FFu);
		tmpOtherSysType = (UINT8)((Data[2u+i]&0xFF00u)>>8u);
		
		findFlag = 0u;
		
		for (j=0u;j<dquCICfgDtStr.TrsmtRlsDtStrLen;j++)
		{
			if ((tmpCiId == dquCICfgDtStr.TrsmtRlsDtStr[j].CiId )
				&& (tmpOtherSysType == dquCICfgDtStr.TrsmtRlsDtStr[j].SystemType)
				)
			{
				findIndex = j;
				findFlag = 1u;
				break;
			}
			else
			{
			}
		}
		if (1u == findFlag)
		{
			/*找到了*/
		}
		else
		{/*没找着*/
			findIndex = 0u;
		}
		

		if (0u == findFlag)
		{/*没找到，新建，追加*/
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].CiId = (UINT8)(Data[0]&0x00FFu);
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].SystemType = (UINT8)((Data[2u+i]&0xFF00u)>>8u);
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum = 0u;
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceIdBuf[dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum] = (UINT8)(Data[2u+i]&0x00FFu);
			dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum++;
			dquCICfgDtStr.TrsmtRlsDtStrLen++;
			Type = (Data[2u+i]&0xFF00u);

			
		}
		else if (1u == findFlag)
		{/*找到，则在找到的结构体中增加设备*/
			dquCICfgDtStr.TrsmtRlsDtStr[findIndex].DeviceIdBuf[dquCICfgDtStr.TrsmtRlsDtStr[findIndex].DeviceSum] = (UINT8)(Data[2U+i]&0x00FFu);
			dquCICfgDtStr.TrsmtRlsDtStr[findIndex].DeviceSum++;
		}
		else
		{
			/*非法值，不处理*/
		}
	}



	rtnvalue = 1u;
	return rtnvalue;
}

/*********************************************
*函数功能：初始化通信关系数据结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 TransmitRelationDataStructInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8* pDataAddr;         /*数据地址*/
	UINT32 DataSize;          /*数据大小（字节数）*/
	UINT16 i,j;
	UINT8 funcRtn = 0u;
	UINT16 Data[ZC_DSU_TRANSMIT_DATA_LEN/2U];
	/*读取 通信关系  数据*/
	funcRtn = dquGetConfigData(FSName,DEVICE_IP_TYPE, ZC_DSU_TRANSMIT_DATA_ID,&pDataAddr,&DataSize);

	if(funcRtn == 0u)
	{
		/*函数调用失败*/
		rtnValue = 0u;
		return rtnValue;
	} 	
	/*求得个数*/
	if(DataSize%ZC_DSU_TRANSMIT_DATA_LEN != 0u)
	{   
		rtnValue = 0u;
		debug_infor_printf((const)"\nCI_DEVICE_IP_DATA,ZC_DSU_COMM,len %d not equal to fs",CI_SYSTEM_CI_FUNC_SWITCH_LEN);
		DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,(DEVICE_IP_TYPE<<8)+ZC_DSU_TRANSMIT_DATA_ID,PRINT_ONCE);
		return rtnValue;
	}
	for(i=0u;i<DataSize/ZC_DSU_TRANSMIT_DATA_LEN;i++)
	{
		/*每行读取，按行解析*/
		for(j=0u;j<ZC_DSU_TRANSMIT_DATA_LEN;j+=2u)
		{
			Data[j/2U] = ShortFromChar(pDataAddr+(i*ZC_DSU_TRANSMIT_DATA_LEN)+j);
		}
		(void)TransmitRelationDataStruFrmSZ(Data);
	}
	rtnValue = 1u;
	return rtnValue;
}

/*********************************************
*函数功能：抵触进路初始化
*参数说明：pRouteCfgDtStr进路配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 RouteOpposedConfigDataInite(RouteConfigDataStruct * RouteCfgDtStr,RouteConfigDataStruct * pRouteCfgDtStr)
{
	UINT16 i=0u,j=0u,k=0u,n=0u;
	UINT8 index=0u;/*计算中抵触进路数量*/
	UINT8 rtnvalue = 1u;
	UINT8 Flag = 0u;
	UINT8 chRouteCitype = 0U;
	chRouteCitype = (UINT8)(dsuStaticHeadStru.pCIStruStru[dsuCIIndex[pRouteCfgDtStr->BelongCiId]].wType); /*进路所属联锁类型*/

	/*抵触进路ID数组 (配置字段)*/
	pRouteCfgDtStr->OpposedRouteSum = 0u;
	if ((CI_TYPE_CLD != chRouteCitype)&&(CI_TYPE_TCC != chRouteCitype))
	{
		for (i = 0u; i < pRouteCfgDtStr->RoutePhySecSum; i++)
		{/*遍历本进路区段*/

			for (j = 0u; j < LSDataLen.LSRouteStrLen; j++)
			{/*遍历所有进路数据*/
				if (pRouteCfgDtStr->RouteId == RouteCfgDtStr[j].RouteId)
				{
					/*除去本进路*/
				}
				else
				{
					for (k = 0u; k < RouteCfgDtStr[j].RoutePhySecSum; k++)
					{/*遍历该进路区段*/

						if (pRouteCfgDtStr->RoutePhySectionStru[i].PhysicalSectionId == RouteCfgDtStr[j].RoutePhySectionStru[k].PhysicalSectionId)
						{/*含有相同区段*/

							Flag = 0u;
							for (n = 0u; n < index; n++)
							{/*遍历抵触进路数组，查找是否已经添加该抵触进路*/

								if (pRouteCfgDtStr->OpposedRouteIdBuf[n] == RouteCfgDtStr[j].RouteId)
								{
									Flag = 1u;
									break;
									/*已经存在*/
								}
							}
							if (Flag == 1u)
							{
								/*已经存在，不再添加*/
							}
							else
							{
								if (ROUTE_OPPOSED_ROUTE_SUM_MAX > index)
								{
									/*添加抵触进路*/
									pRouteCfgDtStr->OpposedRouteIdBuf[index] = RouteCfgDtStr[j].RouteId;/*抵触*/
									index++;
								}
								else
								{
									rtnvalue = 0U;
									break;
								}
							}

						}
					}
					if (0U == rtnvalue)
					{
						break;
					}
				}
			}
		}

		pRouteCfgDtStr->OpposedRouteSum = index;
	}
	else
	{
		/*车辆段无自动属性进路*/
		rtnvalue = 1u;
	}
	return rtnvalue;
}


/*********************************************
*函数功能：属于同一进路物理区段，不属于本进路，且不属于道岔防护区域逻辑区段+
*		   属于同一道岔防护区段逻辑区段，不属于本进路逻辑区段初始化
*参数说明：pRouteCfgDtStr进路配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 RouteOutLgcSecConfigDataInit(RouteConfigDataStruct * pRouteCfgDtStr)
{
	UINT16 i = 0u, j = 0u;
	UINT8 rtnvalue = 0u;
	UINT8 szHitSwProLgcSec[LOGIC_SECTION_SUM_MAX] = { 0U };
	UINT8 szHitRouteLgcSec[LOGIC_SECTION_SUM_MAX] = { 0U };
	PhysicalSectionConfigDataStruct *pPhySecCfgDtSt = NULL;
	SwitchConfigDataStruct *pSwitchCfgDtSt = NULL;
	UINT16 wPhyIndex = 0U;
	UINT16 wSwitchIndex = 0U;
	if (NULL != pRouteCfgDtStr)
	{
		rtnvalue = 1U;
		for (i = 0u; i < pRouteCfgDtStr->RouteInLogTrackSum; i++)
		{
		
			if (LOGIC_SECTION_SUM_MAX > pRouteCfgDtStr->RouteInLogTrackIdBuf[i])
			{
				szHitRouteLgcSec[pRouteCfgDtStr->RouteInLogTrackIdBuf[i]] = 1U;
			}
			else
			{
				rtnvalue = 0U;
				break;
			}
		}

		if (1U == rtnvalue)
		{
			pRouteCfgDtStr->RouteInSwitOtherPosLogSecSum = 0U;
			for (i = 0u; i < pRouteCfgDtStr->RouteSwitchSum; i++)
			{
				wSwitchIndex = dsuPointIndex[pRouteCfgDtStr->RouteSwitchStru[i].SwitchId];
				pSwitchCfgDtSt = &dquCICfgDtStr.SwchCfgDtStr[wSwitchIndex];
				for (j = 0U; j < pSwitchCfgDtSt->SwitchLogSecSum; j++)
				{
					if (LOGIC_SECTION_SUM_MAX > pSwitchCfgDtSt->SwitchLogSecIdBuf[j])
					{
						if (1U != szHitRouteLgcSec[pSwitchCfgDtSt->SwitchLogSecIdBuf[j]])
						{
							pRouteCfgDtStr->RouteInSwitOtherPosLogSecIdBuf[pRouteCfgDtStr->RouteInSwitOtherPosLogSecSum++] = pSwitchCfgDtSt->SwitchLogSecIdBuf[j];
						}
						szHitSwProLgcSec[pSwitchCfgDtSt->SwitchLogSecIdBuf[j]] = 1U;
					}
					else
					{
						rtnvalue = 0U;
						break;
					}
				}
			}
		}

		if (1U == rtnvalue)
		{
			pRouteCfgDtStr->RouteOutLogSecSum = 0U;
			for (i = 0u; i < pRouteCfgDtStr->RoutePhySecSum; i++)
			{
				wPhyIndex = dsuPhysicalSgmtIndex[pRouteCfgDtStr->RoutePhySectionStru[i].PhysicalSectionId];
				pPhySecCfgDtSt = &dquCICfgDtStr.PsclSgmtCfgDtStr[wPhyIndex];
				for (j = 0U; j < pPhySecCfgDtSt->LogSectionSum; j++)
				{
					if (LOGIC_SECTION_SUM_MAX > pPhySecCfgDtSt->LogSectionIdBuf[j])
					{
						if ((1U != szHitRouteLgcSec[pPhySecCfgDtSt->LogSectionIdBuf[j]])
							&&(1U!= szHitSwProLgcSec[pPhySecCfgDtSt->LogSectionIdBuf[j]]))
						{
							pRouteCfgDtStr->RouteOutLogSecSumIdBuf[pRouteCfgDtStr->RouteOutLogSecSum++] = pPhySecCfgDtSt->LogSectionIdBuf[j];
						}
					}
					else
					{
						rtnvalue = 0U;
						break;
					}
				}
			}
		}
	}
	
	return rtnvalue;
}
/*********************************************
*函数功能：初始化Spks配置数据结构体----对外结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 SpksConfigDataStructInit(CHAR * FSName)
{
	UINT8 rtnvalue = 0U;
	UINT8 tmpRet = 0U;
	UINT16 i=0U;

	tmpRet = dfsEmapInit (FSName);
	tmpRet *= InitRelaySpksStru(FSName);

	if (1U == tmpRet)
	{
		rtnvalue = 1U;
	}
	else
	{
		rtnvalue = 0U;
	}

	/*电子地图初始化成功，继续执行*/
	if(1U == rtnvalue)
	{	
		if (0U == dsuDataLenStru.wSpksButtonLen)
		{
			/*个数为电子地图逻辑区段SPKS表中的个数*/
			dquCICfgDtStr.spksDataConfigStrLen = dsuDataLenStru.wLogSecSpksLen;
		}
		else
		{
			/*个数为电子地图SPKS表中的个数*/
			dquCICfgDtStr.spksDataConfigStrLen = dsuDataLenStru.wSpksButtonLen;
		}
		for (i = 0U; i < dquCICfgDtStr.spksDataConfigStrLen; i++)
		{
			if (i >= SPKS_SUM_MAX)
			{
				rtnvalue = 0U;
			}
			if (1U == rtnvalue)
			{
				if (0U == dsuDataLenStru.wSpksButtonLen)
				{
					/*从电子地图逻辑区段SPKS表中初始化*/
					rtnvalue = ReadDataFromDquLogSpksData(dsuStaticHeadStru.pLogSecSpksButtonStru + i, &dquCICfgDtStr.spksDataConfigStr[i]);
				}
				else
				{
					/*从电子地图物理SPKS表中初始化*/
					rtnvalue = ReadDataFromDquPhySpksData(dsuStaticHeadStru.pSpksButtonStru + i, &dquCICfgDtStr.spksDataConfigStr[i]);
				}
			}
			if (1U == rtnvalue)
			{
				rtnvalue = ReadSpksConfigDataFromDquData(&dquCICfgDtStr.spksDataConfigStr[i]);
			}
			if (0U == rtnvalue)
			{
				break;
			}
		}
	}
	if (1u == rtnvalue)
	{
		/*初始化物理区段对应的SPKS信息*/
		for (i = 0u; i < dsuDataLenStru.wPhysicalSgmtLen; i++)
		{
			if (i >= PHYSICAL_SECTION_SUM_MAX)
			{
				rtnvalue = 0u;
			}
			else
			{
				rtnvalue = PhysicRelateSpksStr(&dquCICfgDtStr.PsclSgmtCfgDtStr[i]);
			}
			if (0u == rtnvalue)
			{
				break;
			}
		}
	}
	
	return rtnvalue;
}

/*********************************************
*函数功能：初始化门禁配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 MJConfigDataStructInit(CHAR* FSName)
{
	UINT8 rtnvalue = 0u;
	UINT8 tmpRet = 0u;

	tmpRet = dfsEmapInit(FSName);
	tmpRet *= InitRelay_MJStru(FSName);

	if (1u == tmpRet)
	{
		rtnvalue = 1u;
	}
	else
	{
		rtnvalue = 0u;
	}

	/*电子地图初始化成功，继续执行*/
	if (1u == rtnvalue)
	{
		/*个数为门禁表列数*/
		dquCICfgDtStr.mjDataConfigStrLen = RelayDataLen.RelayMJStrLen;
		/*读取门禁数据到dquCICfgDtStr*/
		rtnvalue = ReadMJConfigDataFromDquData(dquCICfgDtStr.mjDataConfigStr);
		
	}

	return rtnvalue;
}

/*********************************************
*函数功能：初始化全自动折返进路配置数据接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 AllAutoReturnCfgDtStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u,j=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitLS_AllAutoRtnRouteStru(FSName);
	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		/*电子地图初始化成功，继续执行*/

		dquCICfgDtStr.AllAutoRtnRouteCfgDtStrLen = LSDataLen.LSAllAutoRtnRouteStrLen;
		for(i=0u;i<LSDataLen.LSAllAutoRtnRouteStrLen;i++)
		{
			if (i >= ALL_AUTO_RETURN_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].AllAutoReturnId = LSData.pLSAllAutoRtnRouteStr[i].wId;
			dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].BelongCiId = (UINT8)dsuStaticHeadStru.pRouteStru[ dsuRouteIndex[LSData.pLSAllAutoRtnRouteStr[i].szIncludeRouteId[0]]].wManageCI ;
			dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RouteSum = 0u;
			dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RebackRouteSum = 0u;

			for(j=0u;j<AARR_MAX_INCLUDE_ROUTE_NUM;j++)
			{
				if(LSData.pLSAllAutoRtnRouteStr[i].szIncludeRouteId[j] != 0u)
				{
					dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RouteIdBuf[dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RouteSum] = LSData.pLSAllAutoRtnRouteStr[i].szIncludeRouteId[j];
					dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RouteSum += 1u;
					if (j>=(AARR_MAX_INCLUDE_ROUTE_NUM-2u))
					{
						dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RebackRouteIdBuf[dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RebackRouteSum] = LSData.pLSAllAutoRtnRouteStr[i].szIncludeRouteId[j];
						dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RebackRouteSum += 1u;

					}
				}


			}		  
		}
	}
	return rtnvalue;
}

/*********************************************
*函数功能：初始化车库门接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 GaragedoorConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT8 i=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitRelay_GaragedoorStru (FSName);
	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}
	if (1u == rtnvalue)
	{
		/*电子地图初始化成功，继续执行*/
		dquCICfgDtStr.GaragedoorCfgDtStrLen = dsuDataLenStru.wDepotGateLen;
		for(i=0u;i<dsuDataLenStru.wDepotGateLen;i++)
		{
			if (i>=GARAGE_DOOR_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			(void)GaragedoorCfgDtStruFromDquStr(dsuStaticHeadStru.pDepotGateStru + i,&dquCICfgDtStr.GaragedoorCfgDtStr[i]);
		}
		
	}

	return rtnvalue;
}

/*
功能描述: 初始化其他线路设备配置数据结构体(对外结构体)
输入参数:	CHAR * FSName 数据文件名指针
输出参数:	无
返回值:	0 失败
		1 成功
*/
UINT8 DiffLineDevConfigDataStructInit(CHAR * FSName)
{
	UINT8* pDataAddr = NULL;         		/*数据地址*/
	UINT32 DataSize = 0u;          		/*数据大小（字节数）*/
	UINT16 i = 0u;						/*循环变量*/
	UINT8 retVal = 0u;				/*返回值*/
	UINT8 dquGetConfDataRetVal = 0u;	/*获取配置数据函数返回值*/

	/*读取非本线路设备数据*/
	dquGetConfDataRetVal = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_DIFF_LINE_DEV_ID, &pDataAddr, &DataSize);

	if(1u == dquGetConfDataRetVal)
	{
		if(0u != DataSize)
		{
			if(0u == (DataSize % CI_SYSTEM_CI_DIFF_LINE_DEV_LEN))
			{
				/* 清除dqu中数据 */
				(void)CommonMemSet(dquCICfgDtStr.dquCIfg_DiffLineDevData, (UINT32)sizeof(dquCICfgDtStr.dquCIfg_DiffLineDevData), 0, (UINT32)sizeof(dquCICfgDtStr.dquCIfg_DiffLineDevData));

				/*求得个数*/
				tempDquDiffLineDevDataLen= (UINT16) (DataSize / CI_SYSTEM_CI_DIFF_LINE_DEV_LEN);
				pTempDquDiffLineDevData = (DquDiffLineDevStruct *)MyNew((UINT32)(tempDquDiffLineDevDataLen * sizeof(DquDiffLineDevStruct)));

				if(NULL == pTempDquDiffLineDevData)
				{
					tempDquDiffLineDevDataLen = 0u;
					dquCICfgDtStr.dquCIfg_DiffLineDevData->diffLineDevSum = 0u;
					dquCICfgDtStr.dquCIfg_DiffLineDevData->signalNum = 0u;
					dquCICfgDtStr.dquCIfg_DiffLineDevData->switchNum = 0u;
					dquCICfgDtStr.dquCIfg_DiffLineDevData->psdNum = 0u;
					dquCICfgDtStr.dquCIfg_DiffLineDevData->esbNum = 0u;
					dquCICfgDtStr.dquCIfg_DiffLineDevData->spksNum = 0u;
					dquCICfgDtStr.dquCIfg_DiffLineDevData->axisSectNum = 0u;
					dquCICfgDtStr.dquCIfg_DiffLineDevData->physSectNum = 0u;
					
					retVal = 0u;
				}
				else
				{
					for (i = 0u; i < tempDquDiffLineDevDataLen; i++)
					{
						(void)PZDquDiffLineDevDataFromChar(pDataAddr, pTempDquDiffLineDevData + i);

						pDataAddr += CI_SYSTEM_CI_DIFF_LINE_DEV_LEN;

						(void)ReadDquDiffLineDevDataToConfig(pTempDquDiffLineDevData + i, dquCICfgDtStr.dquCIfg_DiffLineDevData);
					}

					retVal = 1u;
				}
			}			
			else
			{
				dquCICfgDtStr.dquCIfg_DiffLineDevData->diffLineDevSum = 0u;
				dquCICfgDtStr.dquCIfg_DiffLineDevData->signalNum = 0u;
				dquCICfgDtStr.dquCIfg_DiffLineDevData->switchNum = 0u;
				dquCICfgDtStr.dquCIfg_DiffLineDevData->psdNum = 0u;
				dquCICfgDtStr.dquCIfg_DiffLineDevData->esbNum = 0u;
				dquCICfgDtStr.dquCIfg_DiffLineDevData->spksNum = 0u;
				dquCICfgDtStr.dquCIfg_DiffLineDevData->axisSectNum = 0u;
				dquCICfgDtStr.dquCIfg_DiffLineDevData->physSectNum = 0u;

				debug_infor_printf((const)"\nCI_CONFIG_DATA,NEIGHBOUR_LINE_DATA,len %d not equal to fs",CI_SYSTEM_CI_DIFF_LINE_DEV_LEN);
				DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_CI_DIFF_LINE_DEV_ID,PRINT_ONCE);

				retVal = 0u;
			}
		}
		else
		{
			dquCICfgDtStr.dquCIfg_DiffLineDevData->diffLineDevSum = 0u;
			dquCICfgDtStr.dquCIfg_DiffLineDevData->signalNum = 0u;
			dquCICfgDtStr.dquCIfg_DiffLineDevData->switchNum = 0u;
			dquCICfgDtStr.dquCIfg_DiffLineDevData->psdNum = 0u;
			dquCICfgDtStr.dquCIfg_DiffLineDevData->esbNum = 0u;
			dquCICfgDtStr.dquCIfg_DiffLineDevData->spksNum = 0u;
			dquCICfgDtStr.dquCIfg_DiffLineDevData->axisSectNum = 0u;
			dquCICfgDtStr.dquCIfg_DiffLineDevData->physSectNum = 0u;
			
			retVal = 1u;
		}
	}
	else
	{
		dquCICfgDtStr.dquCIfg_DiffLineDevData->diffLineDevSum = 0u;
		dquCICfgDtStr.dquCIfg_DiffLineDevData->signalNum = 0u;
		dquCICfgDtStr.dquCIfg_DiffLineDevData->switchNum = 0u;
		dquCICfgDtStr.dquCIfg_DiffLineDevData->psdNum = 0u;
		dquCICfgDtStr.dquCIfg_DiffLineDevData->esbNum = 0u;
		dquCICfgDtStr.dquCIfg_DiffLineDevData->spksNum = 0u;
		dquCICfgDtStr.dquCIfg_DiffLineDevData->axisSectNum = 0u;
		dquCICfgDtStr.dquCIfg_DiffLineDevData->physSectNum = 0u;

		retVal = 0u;
	}

	return retVal;
}

/*********************************************
*函数功能：设置车库门所关联物理区段数据
*参数说明：physicalId 物理区段ID
pGaragedoorCfgDtStr 配置数据结构体指针
*返回值：void
*********************************************/
void SetGardoorphySecData(GaragedoorConfigDataStruct* pGaragedoorCfgDtStr, UINT16 physicalId)
{
	UINT16 k = 0u;    /*循环参数*/

	for (k = 0u; k < pGaragedoorCfgDtStr->GardoorphySecSum; k++)
	{
		if (pGaragedoorCfgDtStr->GardoorphySecBuf[k] == physicalId)
		{
			/*已包含*/

			break;
		} 

	}
	if ((k == pGaragedoorCfgDtStr->GardoorphySecSum)&&(physicalId != 0u))
	{
		pGaragedoorCfgDtStr->GardoorphySecBuf[pGaragedoorCfgDtStr->GardoorphySecSum] = physicalId;
		pGaragedoorCfgDtStr->GardoorphySecSum ++;
	}
}

/*********************************************
*函数功能：车库门接口数据结构体
*参数说明：pGaragedoor 结构体指针
pGaragedoorCfgDtStr 配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 GaragedoorCfgDtStruFromDquStr(DSU_DEPOT_GATE_STRU * pGaragedoor,GaragedoorConfigDataStruct* pGaragedoorCfgDtStr)
{
	UINT16 i = 0u;
	UINT16 index = 0u;
	UINT8 rtnvalue = CI_ERROR;
	UINT16 j = 0u;
	UINT16 physicalId = 0u;
	UINT16 k = 0u;
	UINT16 l=0u;
	UINT16 linkindex = 0u;
	/*入口参数防护*/
	if((NULL == pGaragedoor) || (NULL == pGaragedoorCfgDtStr))
	{
		/*返回失败*/
		rtnvalue = CI_ERROR;
	}
	else
	{
		rtnvalue = CI_SUCCESS;
		pGaragedoorCfgDtStr->GaragedoorId = pGaragedoor->wId;
		rtnvalue = GetDsuLinkIndexNum(pGaragedoor->wDepotGateLinkID,&linkindex);
		if(CI_SUCCESS == rtnvalue)
		{
			pGaragedoorCfgDtStr->BelongCiId = (UINT8)dsuStaticHeadStru.pLinkStru[linkindex].wManagePhysicalCI;
			pGaragedoorCfgDtStr->BelongVirCiId = (UINT8)dsuStaticHeadStru.pLinkStru[linkindex].wBelongVirtualCI;
		}
		if(CI_SUCCESS == rtnvalue)
		{
			for(i=0u;i<RelayDataLen.RelayGaragedoorStrLen;i++)
			{
				if(pGaragedoor->wId == (RelayData.pRelayGaragedoorStr+i)->wGaragedoorId)
				{
					pGaragedoorCfgDtStr->GardoorOpenRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorOpenRelayId;
					pGaragedoorCfgDtStr->GardoorCloseRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorCloseRelayId;
					pGaragedoorCfgDtStr->GardoorOpenOrderRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorOpenOrderRelayId;
					pGaragedoorCfgDtStr->GardoorCloseOrderRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorCloseOrderRelayId;
					pGaragedoorCfgDtStr->GardoorModeStateRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorModeStateRelayId;
					pGaragedoorCfgDtStr->GardoorFaultStateRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorFaultStateRelayId;
					pGaragedoorCfgDtStr->GardoorPangLuRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorPangLuRelayId;
					pGaragedoorCfgDtStr->GardoorKGHRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorKGHRelayId;
					/*
					* 读取车库门的数据:信号机，spks，进路、A库线、位置信息
					*/
					if (pGaragedoor->wProectSignalNum <= GARAGE_DOOR_SIG_MAX)
					{
						pGaragedoorCfgDtStr->phySecAKUId = pGaragedoor->wAPhysicalSgmtId;
						pGaragedoorCfgDtStr->depotAttribute = (UINT8)pGaragedoor->sDepotAttribute;
						pGaragedoorCfgDtStr->signalSum = pGaragedoor->wProectSignalNum;
						pGaragedoorCfgDtStr->GardoorLinkId = pGaragedoor->wDepotGateLinkID;
						pGaragedoorCfgDtStr->GardoorOffset = pGaragedoor->dwDepotGateLinkoffset;
						for (index = 0u;index < pGaragedoorCfgDtStr->signalSum;index++)
						{

							pGaragedoorCfgDtStr->signalIdBuff[index] = pGaragedoor->wProtectSignalId[index];
						}
					}				
					else
					{
						rtnvalue = CI_ERROR;
					}		
					if (pGaragedoor->wRouteInsideNum <= GARAGE_DOOR_ENTER_ROUTE_MAX)
					{
						pGaragedoorCfgDtStr->GardoorRouteSum = (UINT8)(pGaragedoor->wRouteInsideNum);
						for (index = 0u;index < pGaragedoor->wRouteInsideNum;index++)
						{
							if (0u != pGaragedoor->wRouteInsideId[index])
							{
								for (j = 0u; j< LSDataLen.LSRouteStrLen;j++)
								{   /*找出对应的进路ID对应的下标*/
									if (pGaragedoor->wRouteInsideId[index] == dquCICfgDtStr.RouteCfgDtStr[j].RouteId)
									{
										for (l=0u;l<LSDataLen.LSPhyAndChkStaStrLen;l++)
										{/*找出对应的物理区段ID对应的下标*/
											if (LSData.pLSRouteStr[j].wPhySecCheckStaId == LSData.pLSPhyAndChkStaStr[l].wId)
											{
												for (k = 0u; k < dquCICfgDtStr.RouteCfgDtStr[j].RoutePhySecSum; k++)
												{			
													physicalId = LSData.pLSPhyAndChkStaStr[l].wPhysicalSgmtId[k];
													SetGardoorphySecData(pGaragedoorCfgDtStr, physicalId);
													pGaragedoorCfgDtStr->GardoorRouteBuf[index] = pGaragedoor->wRouteInsideId[index];
												}
												break;
											}

										}
										/*找到对应的进路ID*/
										break;
									}
								}
							}
						}
					}
					else
					{
						rtnvalue = CI_ERROR;
					}
    
					if (pGaragedoor->wRouteOutsideNum <= GARAGE_DOOR_EXIT_ROUTE_MAX)
					{
						for (index = 0u;index < pGaragedoor->wRouteOutsideNum;index++)
						{
							if (0u != pGaragedoor->wRouteOutsideId[index])
							{
								for (j = 0u; j< LSDataLen.LSRouteStrLen;j++)
								{
									if (pGaragedoor->wRouteOutsideId[index] == dquCICfgDtStr.RouteCfgDtStr[j].RouteId)
									{
										for (l=0u;l<LSDataLen.LSPhyAndChkStaStrLen;l++)
										{
											if (LSData.pLSRouteStr[j].wPhySecCheckStaId == LSData.pLSPhyAndChkStaStr[l].wId)
											{   /*找到进路对应的物理区段检查属性表对应的下标*/
												for (k = 0u; k < dquCICfgDtStr.RouteCfgDtStr[j].RoutePhySecSum; k++)
												{			
													physicalId = LSData.pLSPhyAndChkStaStr[l].wPhysicalSgmtId[k];
													SetGardoorphySecData(pGaragedoorCfgDtStr, physicalId);
													pGaragedoorCfgDtStr->GardoorRouteBuf[pGaragedoorCfgDtStr->GardoorRouteSum + index] = pGaragedoor->wRouteOutsideId[index];
													
												}
												break;
											}

										}
										/*找到对应的进路ID*/
										break;
									}
								}
							}
						}
						pGaragedoorCfgDtStr->GardoorRouteSum += (UINT8)(pGaragedoor->wRouteOutsideNum);
					}
					else
					{
						rtnvalue = CI_ERROR;
					}

					if (pGaragedoor->wSpksNum <= GARAGE_DOOR_SPKS_MAX)
					{
						pGaragedoorCfgDtStr->GardoorSpksSum = pGaragedoor->wSpksNum;
						for (index = 0u; index < pGaragedoorCfgDtStr->GardoorSpksSum;index++)
						{
							pGaragedoorCfgDtStr->spksIdBuff[index] = pGaragedoor->wSpksId[index];
						}
					}
					else
					{
						rtnvalue = CI_ERROR;
					}

					break;

				}
			}
			if (CI_SUCCESS != rtnvalue)
			{
				pGaragedoorCfgDtStr->GardoorOpenRelayId = 0u;
				pGaragedoorCfgDtStr->GardoorCloseRelayId = 0u;
				pGaragedoorCfgDtStr->GardoorOpenOrderRelayId = 0u;
				pGaragedoorCfgDtStr->GardoorCloseOrderRelayId = 0u;
				pGaragedoorCfgDtStr->GardoorModeStateRelayId = 0u;
				pGaragedoorCfgDtStr->GardoorSpksSum = 0u;
				pGaragedoorCfgDtStr->depotAttribute = 0U;
				pGaragedoorCfgDtStr->phySecAKUId = 0U;
				pGaragedoorCfgDtStr->GardoorLinkId = 0U;
				pGaragedoorCfgDtStr->GardoorOffset = 0U;
				pGaragedoorCfgDtStr->signalSum = 0u;
				pGaragedoorCfgDtStr->GardoorphySecSum = 0u;
				rtnvalue = CI_ERROR;
			}
		}
	}
	return rtnvalue;
}

/*********************************************
*函数功能：从SPKS结构体计算SPKS继电器ID
*参数说明：pSpksDataConfig是信号机配置数据结构指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 ReadSpksConfigDataFromDquData(SpksDataConfigStruct* pSpksDataConfig)
{
	UINT16 i = 0u;
	UINT8 rtnvalue = 0u;
	UINT16 k = 0u;
	/*入口参数防护*/
	if (pSpksDataConfig!= NULL)
	{
		/*遍历开始前，全置为0*/
		pSpksDataConfig->colRelayId = 0u;
		pSpksDataConfig->displayRelayId = 0u;
		pSpksDataConfig->cutRelayId = 0u;
		pSpksDataConfig->repRelayId = 0u;
		pSpksDataConfig->cutDisplayRelayId = 0u;
		pSpksDataConfig->menjinJSRelayId = 0u;  /*新增SPKS关联的门禁解锁继电器ID */
		pSpksDataConfig->VirtualAttribute = SPKS_VIRTUAL_ATTR_NO;/*初始化为非虚拟的*/
		if (NULL != RelayData.pRelaySpksStr)
		{
			for (i=0u;i < RelayDataLen.RelaySpksStrLen; i++)
			{
				if (RelayData.pRelaySpksStr[i].id == pSpksDataConfig->spksId )
				{
					if ((0x0u != RelayData.pRelaySpksStr[i].colRelayId) && (0xffffu != RelayData.pRelaySpksStr[i].colRelayId))
					{
						pSpksDataConfig->colRelayId = RelayData.pRelaySpksStr[i].colRelayId;
#if 0
						pSpksDataConfig->belongCiId = GetBelongCiByRelayId(pSpksDataConfig->colRelayId);
#endif
					}
					else
					{
					    /*无操作*/
					}
					if ((0x0u != RelayData.pRelaySpksStr[i].disRelayId) && (0xffffu != RelayData.pRelaySpksStr[i].disRelayId))
					{
						pSpksDataConfig->displayRelayId = RelayData.pRelaySpksStr[i].disRelayId;
					}
					else
					{
					    /*无操作*/
					}
					if ((0x0u != RelayData.pRelaySpksStr[i].cutRelayId) && (0xffffu != RelayData.pRelaySpksStr[i].cutRelayId))
					{
						pSpksDataConfig->cutRelayId = RelayData.pRelaySpksStr[i].cutRelayId;
					}
					else
					{
					    /*无操作*/
					}
					if ((0x0u != RelayData.pRelaySpksStr[i].repRelayId) && (0xffffu != RelayData.pRelaySpksStr[i].repRelayId))
					{
						pSpksDataConfig->repRelayId = RelayData.pRelaySpksStr[i].repRelayId;/*复视继电器赋值*/
					}
					else
					{
					    /*无操作*/
					}
					if ((0x0u != RelayData.pRelaySpksStr[i].cutDisRelayId) && (0xffffu != RelayData.pRelaySpksStr[i].cutDisRelayId))
					{
						pSpksDataConfig->cutDisplayRelayId = RelayData.pRelaySpksStr[i].cutDisRelayId;/*spks旁路指示灯继电器赋值*/
					}
					else
					{
					    /*无操作*/
					}
					if ((0x0U != RelayData.pRelaySpksStr[i].outsideRelayId) && (0xffffU != RelayData.pRelaySpksStr[i].outsideRelayId))
					{
						pSpksDataConfig->outsideRelayId = RelayData.pRelaySpksStr[i].outsideRelayId;/*spks室外指示灯*/
					}
					else
					{
						/*无操作*/
					}
					
					pSpksDataConfig->VirtualAttribute = SPKS_VIRTUAL_ATTR_NO;/*继电器表中查找到，则认为SPKS为非虚拟的*/
					if (0u == pSpksDataConfig->colRelayId)
					{
						debug_infor_printf((const)"Spks %d COLLJ %d not config.",pSpksDataConfig->spksId,pSpksDataConfig->colRelayId);
						DebugPrintAppError(ERROR_SPKS_COLLJ_NOT_CONFIG,CI_DEVICE_TYPE_SPKS,pSpksDataConfig->spksId,PRINT_ONCE);
					}
					else
					{

						for (k=0u;k<RelayDataLen.RelayCfgDtStrLen;k++)
						{
							if (RelayData.pRelayCfgDtStr[k].RelayId == pSpksDataConfig->colRelayId)
							{
								if (RelayData.pRelayCfgDtStr[k].CollMode != RELAY_COLL_MODE_DOUBLE)
								{
									debug_infor_printf((const)"Spks %d COLLJ %d not double coll-mode.",pSpksDataConfig->spksId,pSpksDataConfig->colRelayId);
									DebugPrintAppError(ERROR_SPKS_COLLJ_NOT_DOUBLE_COLL,CI_DEVICE_TYPE_SPKS,((UINT32)pSpksDataConfig->spksId<<16u)+pSpksDataConfig->colRelayId,PRINT_ONCE);
								}
								else
								{
								}
								break;
							}
							else
							{
							}

						}

						
					}
					pSpksDataConfig->VirtualAttribute = SPKS_VIRTUAL_ATTR_NO;/*继电器表中查找到，则认为SPKS为非虚拟的*/
					break;
				}
				else
				{
				}
			}

			rtnvalue = 1u;
		}
		else
		{
			rtnvalue = 0u;
		}
	}
	else
	{
		rtnvalue = 0u;
	}
	return rtnvalue;
}

/*********************************************
*函数功能：从门禁结构体计算门禁继电器ID
*参数说明：pSpks是DSU信号机数据结构指针
pSpksDataConfig是信号机配置数据结构指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 ReadMJConfigDataFromDquData( MJDataConfigStruct* pMJDataConfig)
{
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 wSpksCount = 0u;/*门禁关联SPKS数量*/
	UINT8 rtnvalue = 0u;
	/*入口参数防护*/
	if (pMJDataConfig != NULL)
	{
		rtnvalue = 1u;

		/*遍历所有门禁*/
		for (i = 0u; i < RelayDataLen.RelayMJStrLen; i++)
		{
			if (i >= MJ_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			else
			{
				/*赋值开始前，全置为0*/
				pMJDataConfig[i].mjId = 0u;
				pMJDataConfig[i].mjjsRelayId = 0u;
				pMJDataConfig[i].relSpkscount = 0u;
				wSpksCount = 0u;   /*SPKS数量清空，重新累计*/
				(void)CommonMemSet(pMJDataConfig[i].relSpksIdBuff, (UINT32)(sizeof(pMJDataConfig[i].relSpksIdBuff) / sizeof(UINT8)), 0, (UINT32)(sizeof(pMJDataConfig[i].relSpksIdBuff) / sizeof(UINT8)));

				if (0u != RelayData.pMjStr[i].mjid)
				{
					pMJDataConfig[i].mjId = RelayData.pMjStr[i].mjid;

					if ((0x0u != RelayData.pMjStr[i].mjjsRelayId) && (0xffffu != RelayData.pMjStr[i].mjjsRelayId))
					{
						pMJDataConfig[i].mjjsRelayId = RelayData.pMjStr[i].mjjsRelayId;
						pMJDataConfig[i].belongCiId = (UINT8)GetCiIdByOcId(RelayData.pMjStr[i].ocId);
					}
					else
					{
						/*门禁继电器读取为0*/
						debug_infor_printf((const)"MJ %d COLLJ %d not config.", pMJDataConfig[i].mjId, pMJDataConfig[i].mjjsRelayId);
					}

					for (j = 0; j < MJ_MAX_SPKSNUM; j++)
					{

						/*循环读取门禁关联的SPKSID*/
						if (0u != RelayData.pMjStr[i].spksId[j])
						{
							pMJDataConfig[i].relSpksIdBuff[j] = RelayData.pMjStr[i].spksId[j];
							wSpksCount++;
						}
						else
						{
							/*SPKSID为0，读取完毕*/
							break;
						}
					}
					pMJDataConfig[i].relSpkscount = wSpksCount;

				}
				else
				{
					/*门禁继电器读取为0*/
					rtnvalue = 0u;
					break;
				}
			}
		}
	}
	else
	{
		rtnvalue = 0u;
	}
	return rtnvalue;
}

/*********************************************
*函数功能：初始化防淹门接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 FloodGateConfigDataStructInit(CHAR * FSName)
{
	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i = 0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitRelay_FloodGateStru (FSName); /*初始化继电器表-防淹门表*/

	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{	
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.FloodGateCfgDtStrLen =dsuDataLenStru.wFloodGateLen;

		

		for(i=0u;i<dquCICfgDtStr.FloodGateCfgDtStrLen;i++)
		{
			if (i >= FLOOD_GATE_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}

			rtnvalue = FloodGateCfgDtStruFrmLSStr(dsuStaticHeadStru.pFloodGateStru + i, &dquCICfgDtStr.FloodGateCfgDtStr[i]);
			if (0u == rtnvalue)
			{
				break;
			}
			
		}
	}
	
	return rtnvalue;
}



/*
*函数功能：从其他联锁表信息合法性检查
*参数说明：pSpks是DSU其他联锁设备信息数据结构指针
*返回值：CI_ERROR，失败；CI_SUCESS，成功
*/
UINT8 CheckInputOtherCiDevInfoValid(const LS_OtherCiDevInfoStruct *pOtherCiDevInfo)
{
	UINT8 ret = CI_ERROR;

	if (pOtherCiDevInfo != NULL)
	{
		if ((UINT8_MAX == pOtherCiDevInfo->wDevStatus)
			|| (0u == pOtherCiDevInfo->wDevStatus)
			|| (UINT16_MAX == pOtherCiDevInfo->wId)
			|| (0u == pOtherCiDevInfo->wId)
			|| (UINT16_MAX == pOtherCiDevInfo->wDevType)
			|| (0u == pOtherCiDevInfo->wDevType))
		{
			ret = CI_ERROR;
		}
		else
		{
			ret = CI_SUCCESS;
		}
	}

	return ret;
}

/*
*函数功能：根据继电器Id 查找所属联锁
*参数说明：根据继电器ID查找指定所属联锁
*返回值：0 失败，>0 成功
* 限制条件：必须继电器数据读取完毕
*/
UINT8 GetBelongCiByRelayId(UINT16 relayId )
{
	UINT8 ciId = 0u;
	UINT16 ii = 0u;

	if ((RelayDataLen.RelayCfgDtStrLen > 0u) && (RelayData.pRelayCfgDtStr != NULL))
	{
		for (ii =0u;ii<RelayDataLen.RelayCfgDtStrLen;ii++)
		{
			if (relayId == RelayData.pRelayCfgDtStr[ii].RelayId)
			{
				ciId = RelayData.pRelayCfgDtStr[ii].BelongCiId;
				break;
			}
		}
	}

	return ciId;
}

/*********************************************
*函数功能：初始化系统配置数据中相连联锁通信信息
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 CiTransmitInfoStructInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	UINT8* pDataAddr;         /*数据地址*/
	UINT32 DataSize;          /*数据大小（字节数）*/
	UINT16 ii = 0u;
	DquCiTransmitStruct *pDquCiTranStr = NULL;

	/* 数据初始化 */
	funcRtn = dquCbtcConfigDataInit (FSName);
	funcRtn *= dquGetConfigData(FSName,CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_TRANSMIT_ID,&pDataAddr,&DataSize);
	if(funcRtn != 0u)
	{	
		if(0u == DataSize%CI_SYSTEM_CI_TRANSMIT_LEN)
		{
			/* 清除dqu中数据 */
			(void)CommonMemSet(dquCICfgDtStr.CiTransmitStru, (UINT32)sizeof(dquCICfgDtStr.CiTransmitStru), 0 , (UINT32)sizeof(dquCICfgDtStr.CiTransmitStru));
			(void)CommonMemSet(dquCICfgDtStr.CiTransmitStrLen, (UINT32)sizeof(dquCICfgDtStr.CiTransmitStrLen), 0 , (UINT32)sizeof(dquCICfgDtStr.CiTransmitStrLen));

			/*求得个数*/
			dquCiTranmitInfoLen = (UINT16) (DataSize / CI_SYSTEM_CI_TRANSMIT_LEN);
			pDquCiTranmitInfoStr = (DquCiTransmitStruct *)MyNew((UINT32)(dquCiTranmitInfoLen * sizeof(DquCiTransmitStruct)));
			if(NULL == pDquCiTranmitInfoStr)
			{
				dquCiTranmitInfoLen = 0u;
				rtnValue = 0u;
			}
			else
			{
				rtnValue = 1u;
				for (ii=0u;ii<dquCiTranmitInfoLen;ii++)
				{
					pDquCiTranStr = pDquCiTranmitInfoStr+ii;
					rtnValue &= PZDquCiTransmitInfoFromChar(pDataAddr,pDquCiTranStr);
					pDataAddr += CI_SYSTEM_CI_TRANSMIT_LEN;
					rtnValue &= ReadDquCiTransmitInfoToConfig(pDquCiTranStr);
				}
			}
		}			
		else
		{
			rtnValue = 0u;
			debug_infor_printf((const)"\nCI_CONFIG_DATA,NEIGHBOUR_CI_DATA,len %d not equal to fs",CI_SYSTEM_CI_TRANSMIT_LEN);
			DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_CI_TRANSMIT_ID,PRINT_ONCE);
		}
	}
	else
	{
		rtnValue = 0u;
	}
	return rtnValue;
}

/*********************************************
*函数功能：初始化系统相连联锁整理DquCfg里面
*参数说明：pDquCiTranStr DSU数据          
*返回值：0，失败；1，成功
*********************************************/
UINT8 ReadDquCiTransmitInfoToConfig(DquCiTransmitStruct *pDquCiTransmitStr)
{
	UINT16 tmpLocalCiId = 0u;
	UINT8 rtnValue = 0u;
	UINT8 ii = 0u;
	UINT8 cLocalWorkType = 0U;  /*本地工作模式*/

	CiTransmitStruct *pTmpCiTransConfig = NULL;

	if (pDquCiTransmitStr != NULL)
	{
		tmpLocalCiId = pDquCiTransmitStr->srcCiId;
		cLocalWorkType = GetLocalRcWorkMode();
		/* 设置数据 */
		if ((tmpLocalCiId < CI_SUM_MAX) && (tmpLocalCiId > 0u)
			&& ((RC_WORK_MODE_TIOC == cLocalWorkType) || ((RC_WORK_MODE_CI == cLocalWorkType) && (CI_DEVICE_TYPE_CUTOFF_POINT != pDquCiTransmitStr->devType))))
		{			
			/* 查找目标ID是否已经添加过 */
			for(ii = 0u; ii<dquCICfgDtStr.CiTransmitStrLen[tmpLocalCiId];ii++)
			{
				if (dquCICfgDtStr.CiTransmitStru[tmpLocalCiId][ii].destCiId == pDquCiTransmitStr->dstCiId)
				{
					/* 找到退出 */
					break;
				}
			}
			/* 没有添加，则添加一个 */
			if (ii>= dquCICfgDtStr.CiTransmitStrLen[tmpLocalCiId])
			{
				dquCICfgDtStr.CiTransmitStrLen[tmpLocalCiId]++;
			}
			pTmpCiTransConfig = &dquCICfgDtStr.CiTransmitStru[tmpLocalCiId][ii];
			pTmpCiTransConfig->destCiId = pDquCiTransmitStr->dstCiId;
			pTmpCiTransConfig->srcCiId = pDquCiTransmitStr->srcCiId;

			switch (pDquCiTransmitStr->devType)
			{
			case CI_DEVICE_TYPE_SWITCH:	/* 道岔 */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < SWITCH_SUM_MAX) && (pTmpCiTransConfig->switchNum < SWITCH_SUM_MAX))
				{
					pTmpCiTransConfig->switchIdBuf[pTmpCiTransConfig->switchNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->switchNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read Switch Error\n");
				}
				break;
			case CI_DEVICE_TYPE_SIGNAL:	/* 信号机 */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < SIGNAL_SUM_MAX) && (pTmpCiTransConfig->signalNum < SIGNAL_SUM_MAX))
				{
					pTmpCiTransConfig->signalIdBuf[pTmpCiTransConfig->signalNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->signalNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read Signal Error\n");
				}
				break;
			case CI_DEVICE_TYPE_PHYSEC:	/* 物理区段 */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < PHYSICAL_SECTION_SUM_MAX) && (pTmpCiTransConfig->phySecNum < PHYSICAL_SECTION_SUM_MAX))
				{
					pTmpCiTransConfig->phySecIdBuf[pTmpCiTransConfig->phySecNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->phySecIdLockDirFlag[pTmpCiTransConfig->phySecNum] = pDquCiTransmitStr->phyLockDirOppOrNot;/*物理区段锁闭方向是否取反标志*/
					pTmpCiTransConfig->phySecNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read PhySec Error\n");
				}
				break;
			case CI_DEVICE_TYPE_LOGICSEC:	/* 逻辑区段 */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < LOGIC_SECTION_SUM_MAX) && (pTmpCiTransConfig->logicSecNum < LOGIC_SECTION_SUM_MAX))
				{
					pTmpCiTransConfig->logicSecIdBuf[pTmpCiTransConfig->logicSecNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->logicSecNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read LogSec Error\n");
				}
				break;
			case CI_DEVICE_TYPE_ESB:		/* ESB */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < ESB_SUM_MAX) && (pTmpCiTransConfig->esbNum < ESB_SUM_MAX))
				{
					pTmpCiTransConfig->esbIdBuf[pTmpCiTransConfig->esbNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->esbNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read ESB Error\n");
				}
				break;
			case CI_DEVICE_TYPE_PSD:		/* PSD */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < PSD_SUM_MAX) && (pTmpCiTransConfig->psdNum < PSD_SUM_MAX))
				{
					pTmpCiTransConfig->psdIdBuf[pTmpCiTransConfig->psdNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->psdNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read PSD Error\n");
				}
				break;
			case CI_DEVICE_TYPE_ROUTE:		/* 进路 */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < ROUTE_SUM_MAX) && (pTmpCiTransConfig->routeNum < ROUTE_SUM_MAX))
				{
					pTmpCiTransConfig->routeIdBuf[pTmpCiTransConfig->routeNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->routeNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read Route Error\n");
				}
				break;
			case CI_DEVICE_TYPE_OVERLAP:	/* 保护区段 */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < OVERLAP_SUM_MAX) && (pTmpCiTransConfig->overlapNum < OVERLAP_SUM_MAX))
				{
					pTmpCiTransConfig->overlapIdBuf[pTmpCiTransConfig->overlapNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->overlapNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read Overlap Error\n");
				}
				break;
			case CI_DEVICE_TYPE_SPKS:	/* SPKS */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < SPKS_SUM_MAX) && (pTmpCiTransConfig->spksNum < SPKS_SUM_MAX))
				{
					pTmpCiTransConfig->spksIdBuff[pTmpCiTransConfig->spksNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->spksNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read SPKS Error\n");
				}
				break;
			case CI_DEVICE_TYPE_FLOODGATE:/*防淹门*/
				{
					if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < FLOOD_GATE_SUM_MAX) && (pTmpCiTransConfig->floodGateNum < FLOOD_GATE_SUM_MAX))
					{
						pTmpCiTransConfig->floodGateIdBuf[pTmpCiTransConfig->floodGateNum] = pDquCiTransmitStr->devId;
						pTmpCiTransConfig->floodGateNum++;
						rtnValue = 1u;
					}
					else
					{
						debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read FloodGate Error\n");
					}
				}
				break;
			case CI_DEVICE_TYPE_RELAY:	/* 照查继电器 */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < RELAY_SUM_MAX) && (pTmpCiTransConfig->zcjNum < ZCJ_SUM_MAX))
				{
					pTmpCiTransConfig->zcjIdBuf[pTmpCiTransConfig->zcjNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->zcjNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read Zcj Error\n");
				}
				break;
			case CI_DEVICE_TYPE_CUTOFF_POINT:	/* 分界点 */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < CUTOFF_POINT_SUM_MAX) && (pTmpCiTransConfig->wCutoffPointNum < CUTOFF_POINT_SUM_MAX))
				{
					pTmpCiTransConfig->wCutoffPointBuf[pTmpCiTransConfig->wCutoffPointNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->wCutoffPointNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read Cfp Error\n");
				}
				break;
			case CI_DEVICE_TYPE_AUTOROUTE:/* cgh-合并CID-2539-7：自动通过 */
				if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < AUTO_ROUTE_SUM_MAX) &&
					(pTmpCiTransConfig->autoRouteNum < AUTO_ROUTE_SUM_MAX))
				{
					pTmpCiTransConfig->autoRouteIdBuf[pTmpCiTransConfig->autoRouteNum] = pDquCiTransmitStr->devId;
					pTmpCiTransConfig->autoRouteNum++;
					rtnValue = 1u;
				}
				else
				{
					debug_infor_printf((const)"ReadDquCiTransmitInfoToConfig: Read AutoRoute Error\n");
				}
				break;
			default:
				rtnValue = 0u;
				break;
			}
		}
		else if ((RC_WORK_MODE_CI == cLocalWorkType) && (CI_DEVICE_TYPE_CUTOFF_POINT == pDquCiTransmitStr->devType))
		{
		    rtnValue = 1u;  /*CI模式不读分界点，返回1*/
		}
		else
		{
			rtnValue = 0u;
		}
	}
	else 
	{
		rtnValue = 0u;
	}
	return rtnValue;
}

/*
功能描述: 将单个其他线路设备数据填充至DquCfg中其他线路设备数据内容中
输入参数:	DquDiffLineDevStruct *pDquDiffLineDevData  单个其他线路设备数据
输出参数:	DiffLineDevStruct *pDiffLineDevData DquCfg中其他线路设备数据内容指针
返回值:	0 失败
		1 成功
*/
UINT8 ReadDquDiffLineDevDataToConfig(DquDiffLineDevStruct *pDquDiffLineDevData, DiffLineDevStruct *pDiffLineDevData)
{
	UINT8 retVal = 0u;

	if ((NULL != pDquDiffLineDevData) && (NULL != pDiffLineDevData))
	{
		switch (pDquDiffLineDevData->devType)
		{
		case CI_DEVICE_TYPE_SWITCH:	/* 道岔 */
			if ((0u < pDquDiffLineDevData->devId) && (SWITCH_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_SWITCH_SUM_MAX > pDiffLineDevData->switchNum))
			{
				pDiffLineDevData->switchIdBuf[pDiffLineDevData->switchNum] = pDquDiffLineDevData->devId;
				pDiffLineDevData->switchNum++;
				pDiffLineDevData->diffLineDevSum++;
				retVal = 1u;
			}
			break;
		case CI_DEVICE_TYPE_SIGNAL:	/* 信号机 */
			if ((0u < pDquDiffLineDevData->devId) && (SIGNAL_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_SIGNAL_MAX > pDiffLineDevData->signalNum))
			{
				pDiffLineDevData->signalIdBuf[pDiffLineDevData->signalNum] = pDquDiffLineDevData->devId;
				pDiffLineDevData->signalNum++;
				pDiffLineDevData->diffLineDevSum++;
				retVal = 1u;
			}
			break;
		case CI_DEVICE_TYPE_ESB:		/* ESB */
			if ((0u < pDquDiffLineDevData->devId) && (ESB_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_ESB_SUM_MAX > pDiffLineDevData->esbNum))
			{
				pDiffLineDevData->esbIdBuf[pDiffLineDevData->esbNum] = pDquDiffLineDevData->devId;
				pDiffLineDevData->esbNum++;
				pDiffLineDevData->diffLineDevSum++;
				retVal = 1u;
			}
			break;
		case CI_DEVICE_TYPE_PSD:		/* PSD */
			if ((0u < pDquDiffLineDevData->devId) && (PSD_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_PSD_SUM_MAX > pDiffLineDevData->psdNum))
			{
				pDiffLineDevData->psdIdBuf[pDiffLineDevData->psdNum] = pDquDiffLineDevData->devId;
				pDiffLineDevData->psdNum++;
				pDiffLineDevData->diffLineDevSum++;
				retVal = 1u;
			}
			break;
		case CI_DEVICE_TYPE_SPKS:	/* SPKS */
			if ((0u < pDquDiffLineDevData->devId) && (SPKS_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_SPKS_SUM_MAX > pDiffLineDevData->spksNum))
			{
				pDiffLineDevData->spksIdBuff[pDiffLineDevData->spksNum] = pDquDiffLineDevData->devId;
				pDiffLineDevData->spksNum++;
				pDiffLineDevData->diffLineDevSum++;
				retVal = 1u;
			}
			break;
		case CI_DEVICE_TYPE_AXISSEC:	/*计轴区段*/
			if ((0u < pDquDiffLineDevData->devId) && (AXIS_SECTION_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_AXIS_SECT_SUM_MAX > pDiffLineDevData->axisSectNum))
			{
				pDiffLineDevData->axisSectIdBuff[pDiffLineDevData->axisSectNum] = pDquDiffLineDevData->devId;
				pDiffLineDevData->axisSectNum++;
				pDiffLineDevData->diffLineDevSum++;
				retVal = 1u;
			}
			break;
		case CI_DEVICE_TYPE_PHYSEC:	/*物理区段*/
			if ((0u < pDquDiffLineDevData->devId) && (PHYSICAL_SECTION_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_PHYS_SECT_SUM_MAX > pDiffLineDevData->physSectNum))
			{
				pDiffLineDevData->physSectIdBuff[pDiffLineDevData->physSectNum] = pDquDiffLineDevData->devId;
				pDiffLineDevData->physSectNum++;
				pDiffLineDevData->diffLineDevSum++;
				retVal = 1u;
			}
			break;
		default:
			retVal = 0u;
			break;
		}

	}
	else 
	{
		retVal = 0u;
	}

	return retVal;
}

/*********************************************
*函数功能：初始化出站信号机关联的逻辑区段数据结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 OutStationSigRelLogSecStruInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	UINT8* pDataAddr;                                              /*数据地址*/
	UINT32 DataSize;                                               /*数据大小（字节数）*/
	UINT16 ii = 0u;
	DquOutStationSigStruct * pDquOutStationSigInfoStr = NULL;

	/*读取出站信号机关联逻辑区段的系统配置数据*/
	funcRtn = dquGetConfigData(FSName,CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_OUTSIG_RALATE_LOG_ID,&pDataAddr,&DataSize);
	if(0u == funcRtn)
	{
		/*函数调用失败*/
		rtnValue = 0u;
	} 
	else
	{
		/*求得个数*/
		if(DataSize % CI_SYSTEM_OUTSIG_RALATE_LOG_LEN != 0u)
		{   
			rtnValue = 0u;
			debug_infor_printf((const)"\nCI_CONFIG_DATA,BLOC_TSR_LOGIC,len %d not equal to fs",CI_SYSTEM_OUTSIG_RALATE_LOG_LEN);
			DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_OUTSIG_RALATE_LOG_ID,PRINT_ONCE);
		}
		else
		{
			dquOutStationSigStrLen = (UINT16)(DataSize / CI_SYSTEM_OUTSIG_RALATE_LOG_LEN);
			pDquOutStationSigStr = (DquOutStationSigStruct *)MyNew((UINT32)(dquOutStationSigStrLen * sizeof(DquOutStationSigStruct)));
			if(NULL == pDquOutStationSigStr)
			{
				dquOutStationSigStrLen = 0u;
				rtnValue = 0u;
			}
			else
			{
				for (ii = 0u;ii < dquOutStationSigStrLen;ii++)
				{
					pDquOutStationSigInfoStr = pDquOutStationSigStr + ii;
					(void)PZDquOutStationSigReltLogSec(pDataAddr,pDquOutStationSigInfoStr);
					pDataAddr += CI_SYSTEM_OUTSIG_RALATE_LOG_LEN;
				}
				rtnValue = 1u;
			}
		}
	}

	return rtnValue;
}

/*********************************************
*函数功能：初始化联锁功能开关配置数据结构体
*参数说明：FSName文件指针          
*返回值：无
*********************************************/
void CiFunctionSwitchStructInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	UINT8* pDataAddr = NULL;                                              /*数据地址*/
	UINT32 DataSize = 0u;                                               /*数据大小（字节数）*/
	UINT16 ii = 0u;
	DquCiFuncSwitchStructNew * pTempDquCiFuncSwitchStru = NULL;

	/*读取联锁功能开关配置表的配置数据*/
	funcRtn = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_FUNC_SWITCH_ID, &pDataAddr, &DataSize);
	if((0u == funcRtn) || (0u == DataSize))
	{
		/*函数调用失败*/
		rtnValue = 0u;
	} 
	else
	{
		/*求得个数*/
		if(0u != (DataSize % CI_SYSTEM_CI_FUNC_SWITCH_LEN))
		{   
			rtnValue = 0u;
			debug_infor_printf((const)"\nCI_CONFIG_DATA,CI_FUNC_SWITCH,len %d not equal to fs",CI_SYSTEM_CI_FUNC_SWITCH_LEN);
			DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_CI_FUNC_SWITCH_ID,PRINT_ONCE);
		}
		else
		{
			dquCiFuncSwitchStruLen = (UINT16)(DataSize / CI_SYSTEM_CI_FUNC_SWITCH_LEN);
			pDquCiFuncSwitchStru = (DquCiFuncSwitchStructNew *)MyNew((UINT32)(dquCiFuncSwitchStruLen * sizeof(DquCiFuncSwitchStructNew)));

			if(NULL == pDquCiFuncSwitchStru)
			{
				dquCiFuncSwitchStruLen = 0u;
				rtnValue = 0u;
			}
			else
			{
				rtnValue = 1u;

				for (ii = 0u; ii < dquCiFuncSwitchStruLen; ii++)
				{
					pTempDquCiFuncSwitchStru = pDquCiFuncSwitchStru + ii;
					
					rtnValue = PZDquCiFunctionSwitchInfo(pDataAddr, pTempDquCiFuncSwitchStru);
					pDataAddr += CI_SYSTEM_CI_FUNC_SWITCH_LEN;
					
					if (0u == rtnValue)
					{
						break;
					}
				}
			}
		}
	}

}

/*********************************************
*函数功能：初始化当前联锁类型配置数据
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 CiPatternInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	UINT8* pDataAddr = NULL;    /*数据地址*/
	UINT32 DataSize = 0u;        /*数据大小（字节数）*/
	UINT16 ii = 0u;
	UINT16 len = 0u;
	UINT16 val = 0u;
	UINT8 findFlag = 0u;
	UINT8  chLocalCiId = GetSystemParaLocalCiId();

	/*读取联锁类型配置表的配置数据*/
	funcRtn = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_PATTERN_ID, &pDataAddr, &DataSize);
	if (funcRtn == 0u)
	{
		/*函数调用失败*/
		rtnValue = 0u;
	}
	else
	{
		/*求得个数*/
		if ((DataSize % CI_SYSTEM_CI_PATTERN_LEN) != 0u)
		{
			rtnValue = 0u;
		}
		else
		{
			len = (UINT16)(DataSize / CI_SYSTEM_CI_PATTERN_LEN);
			rtnValue = 1u;
			for (ii = 0u; ii < len; ii++)
			{
				if (*pDataAddr == chLocalCiId)
				{
					rtnValue = SetLocalCiPattern(*(pDataAddr + 1));
					
					if (1u == rtnValue)
					{
						rtnValue = SetLocalCiDistributedIO(pDataAddr[2]);
					}

					if (1u == rtnValue)
					{
						val = dquCiShortFromChar(&pDataAddr[3]);
						SetLocalCiUTProtSecUnlockTime(val);

						val = dquCiShortFromChar(&pDataAddr[5]);
						SetLocalCiCTProtSecUnlockTime(val);

						val = dquCiShortFromChar(&pDataAddr[7]);
						SetLocalCiUTNearUnLockTime(val);

						val = dquCiShortFromChar(&pDataAddr[9]);
						SetLocalCiCTNearUnLockTime(val);

						SetLocalWaysidePattern(pDataAddr[11]);
						rtnValue = SetLocalRcWorkMode(pDataAddr[12]);

					}
					findFlag = 1u;
				}
				else
				{
					if (1U == rtnValue)
					{
						/*初始化相邻联锁数据*/
						rtnValue = SetOtherCiPara(pDataAddr);
					}
					else
					{
						/*不初始化*/
					}
					
				}
				if (0U == rtnValue)
				{
					break;
				}
				else
				{
					pDataAddr += CI_SYSTEM_CI_PATTERN_LEN;
				}
			}

			if (0u == findFlag)
			{
				rtnValue = 0u;/*未找到本联锁，初始化失败*/
			}
		}
	}

	return rtnValue;
}

/*********************************************
*函数功能：初始化侵限区段数据结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 InvSecNdConSwiConfDataStruInit(CHAR* FSName)
{
	UINT8 funcRetVal = 0u;
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT16 condSwitDataSum = 0u;

	funcRetVal = dfsEmapInit(FSName);

	if(0u != funcRetVal)
	{/*电子地图初始化成功，继续执行*/
		dquCICfgDtStr.InvSecCfgDtStrLen = LSDataLen.LSIntruPhySecStrLen;

		/*解析数据到 侵入区段结构体数组 */  
		for(i = 0u; i < LSDataLen.LSIntruPhySecStrLen; i++)
		{
			if (i >= INVA_SECT_N_COND_SWIT_SUM_MAX)/*下标索引防护，如果大于等于数组最大值，让联锁初始化失败*/
			{
				funcRetVal = 0u;
				break;
			}
			dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].InvSecAndConSwiId = LSData.pLSIntruPhySecStr[i].wId;
			dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].InvaSectId = LSData.pLSIntruPhySecStr[i].wIntrudePhySecId;
			dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].CondSwitDataSum = 0u;

			condSwitDataSum = 0u;

			for (j = 0u; j < QINXIAN_SWITCH_MAX_NUM; j++)
			{
				if ((0x0000U != LSData.pLSIntruPhySecStr[i].wPointId[j]) && (UINT16_MAX != LSData.pLSIntruPhySecStr[i].wPointId[j])
					&& (0x0000U != LSData.pLSIntruPhySecStr[i].wPointSta[j]) && (UINT16_MAX != LSData.pLSIntruPhySecStr[i].wPointSta[j]))
				{
					dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].CondSwitDataBuff[condSwitDataSum].CondSwitId = LSData.pLSIntruPhySecStr[i].wPointId[j];

					if ((1u == LSData.pLSIntruPhySecStr[i].wPointSta[j]) || (2u == LSData.pLSIntruPhySecStr[i].wPointSta[j]))
					{/*防护道岔位置*/
						dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].CondSwitDataBuff[condSwitDataSum].CondSwitStat = LSData.pLSIntruPhySecStr[i].wPointSta[j];
					}
					else
					{
						funcRetVal = 0u;
						break;
					}
					condSwitDataSum++;

				}
			}
			if (0u == funcRetVal)
			{
				break;
			}
			dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].CondSwitDataSum = condSwitDataSum;
			dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].CondSwitLockDir = LSData.pLSIntruPhySecStr[i].wCondSwitLockDir;
		}

	}
	else
	{/*电子地图初始化失败，函数失败退出*/
		dquCICfgDtStr.InvSecCfgDtStrLen = 0u;
	}

	return funcRetVal;
}


/*********************************************
*函数功能：设置信号机是否可驱动状态
*参数说明：pSgnlCfgDtStr，信号机配置数据结构体指针          
*返回值:无
*********************************************/
void SetSignalDrvEnable(SignalConfigDataStruct* pSgnlCfgDtStr)
{
	UINT8 LxDrvEnableFlg = 0u;
	UINT8 ZxDrvEnableFlg = 0u;
	UINT8 YxDrvEnableFlg = 0u;
	UINT8 DdDrvEnableFlg = 0u;
	UINT8 DxDrvEnableFlg = 0u;

	if(pSgnlCfgDtStr != NULL)
	{
		LxDrvEnableFlg = GetRelayDrvEnableByRelayId(pSgnlCfgDtStr->LxRelayId);
		ZxDrvEnableFlg = GetRelayDrvEnableByRelayId(pSgnlCfgDtStr->ZxRelayId);
		YxDrvEnableFlg = GetRelayDrvEnableByRelayId(pSgnlCfgDtStr->YxRelayId);
		DdDrvEnableFlg = GetRelayDrvEnableByRelayId(pSgnlCfgDtStr->DdRelayId);
		DxDrvEnableFlg = GetRelayDrvEnableByRelayId(pSgnlCfgDtStr->DxRelayId);
		if ((SIGNAL_DRV_ENABLE == LxDrvEnableFlg)||(SIGNAL_DRV_ENABLE == ZxDrvEnableFlg)||
			(SIGNAL_DRV_ENABLE == YxDrvEnableFlg)||(SIGNAL_DRV_ENABLE == DdDrvEnableFlg)||
			(SIGNAL_DRV_ENABLE == DxDrvEnableFlg))
		{
			pSgnlCfgDtStr->driveEnable = SIGNAL_DRV_ENABLE;
		}
		else
		{
			pSgnlCfgDtStr->driveEnable = SIGNAL_DRV_DISABLE;
		}
	}
}

/*
*函数功能：根据继电器Id 判断是否可以驱动
*参数说明：继电器ID
*返回值：SIGNAL_DRV_ENABLE 可以驱动，SIGNAL_DRV_DISABLE 不可以驱动
* 限制条件：必须继电器数据读取完毕
* 特殊：未配置该继电器认为不能驱动	
*/
UINT8 GetRelayDrvEnableByRelayId(UINT16 relayId )
{
	UINT8 enableFlg = SIGNAL_DRV_DISABLE; 
	UINT16 ii = 0u;
	/* 若继电器未配置，即为0，则认为该继电器可以驱动 */
	if ((RelayDataLen.RelayCfgDtStrLen > 0u) && (RelayData.pRelayCfgDtStr != NULL))
	{
		for (ii =0u;ii<RelayDataLen.RelayCfgDtStrLen;ii++)
		{
			if (relayId == RelayData.pRelayCfgDtStr[ii].RelayId)
			{
				if ((0u !=RelayData.pRelayCfgDtStr[ii].DrvAddrA) && (0u != RelayData.pRelayCfgDtStr[ii].DrvPosA)
					&& (0u !=RelayData.pRelayCfgDtStr[ii].DrvAddrB) && (0u != RelayData.pRelayCfgDtStr[ii].DrvPosB))
				{
					enableFlg = SIGNAL_DRV_ENABLE;
				}
				break;
			}
		}
	}


	return enableFlg;
}

/*********************************************
*函数功能：根据电子地图中信号机属性设置信号机虚拟属性
*参数说明：pSgnl是DSU信号机数据结构指针
*          pSgnlCfgDtStr，信号机配置数据结构体指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 SetSignalVirtualAttr(DSU_SIGNAL_STRU* pSgnl,SignalConfigDataStruct* pSgnlCfgDtStr)
{
	UINT8 ret = CI_SUCCESS;
	UINT16 sigAttrEmap = 0u;/*电子地图中信号机属性*/

	/*入口参数防护*/
	if((NULL == pSgnl) || (NULL == pSgnlCfgDtStr))
	{
		/*返回失败*/
		ret = CI_ERROR;
	}
	if (CI_SUCCESS == ret)
	{
		sigAttrEmap = pSgnl->wAttribute;
		if ((0x8000u & sigAttrEmap) == 0x8000u)
		{
			pSgnlCfgDtStr->signalVirtualAttr = SIGNAL_VIRTUAL_YES;
		}
		else
		{
			pSgnlCfgDtStr->signalVirtualAttr = SIGNAL_VIRTUAL_NO;
		}

	}
	return ret;
}

/*********************************************
*函数功能：初始化虚拟设备数据结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 VirtualDeviceInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	UINT8* pDataAddr;                                              /*数据地址*/
	UINT32 DataSize;                                               /*数据大小（字节数）*/
	UINT16 ii = 0u;
	DquVirtualDeviceStruct * pDquVirtualDeviceInfoStr = NULL;

	/*读取出虚拟设备的系统配置数据*/
	funcRtn = dquGetConfigData(FSName,CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_VIRTUAL_DEV_ID,&pDataAddr,&DataSize);
	if(0u == funcRtn)
	{
		/*函数调用失败*/
		rtnValue = 0u;
	} 
	else
	{
		/*求得个数*/
		if(0u != (DataSize % CI_SYSTEM_CI_VIRTUAL_DEV_LEN))
		{   
			debug_infor_printf((const)"\nCI_CONFIG_DATA,VIRTUAL_DEVICE,len %d not equal to fs",CI_SYSTEM_CI_VIRTUAL_DEV_LEN);
			DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_CI_VIRTUAL_DEV_ID,PRINT_ONCE);
			rtnValue = 0u;
		}
		else
		{
			dquVirtualDeviceStrLen = (UINT16)(DataSize / CI_SYSTEM_CI_VIRTUAL_DEV_LEN);
			pDquVirtualDeviceStr = (DquVirtualDeviceStruct *)MyNew((UINT32)(dquVirtualDeviceStrLen * sizeof(DquVirtualDeviceStruct)));
			if(NULL == pDquVirtualDeviceStr)
			{
				dquVirtualDeviceStrLen = 0u;
				rtnValue = 0u;
			}
			else
			{
				rtnValue = 1u;
				for (ii = 0u;ii < dquVirtualDeviceStrLen;ii++)
				{
					pDquVirtualDeviceInfoStr = pDquVirtualDeviceStr + ii;
					rtnValue &=PZDquVirtualDeviceInfoFromChar(pDataAddr,pDquVirtualDeviceInfoStr);
					pDataAddr += CI_SYSTEM_CI_VIRTUAL_DEV_LEN;
				}
			}
		}
	}

	return rtnValue;
}

/*********************************************
*函数功能：初始化出站信号机关联的计轴区段数据结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 OutStationSigRelAxisSecStruInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	UINT8* pDataAddr;                                              /*数据地址*/
	UINT32 DataSize;                                               /*数据大小（字节数）*/
	UINT16 ii = 0u;
	DquOutStationSigStruct * pDquOutStationSigInfoStr = NULL;

	/*读取出站信号机关联计轴区段的系统配置数据*/
	funcRtn = dquGetConfigData(FSName,CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_OUTSIG_RALATE_AXIS_ID,&pDataAddr,&DataSize);
	if(funcRtn == 0u)
	{
		/*函数调用失败*/
		rtnValue = 0u;
	} 
	else
	{
		/*求得个数*/
		if(DataSize % CI_SYSTEM_OUTSIG_RALATE_AXIS_LEN != 0u)
		{   
			rtnValue = 0u;
		}
		else
		{
			dquOutStationSigStrLen = (UINT16)(DataSize / CI_SYSTEM_OUTSIG_RALATE_AXIS_LEN);
			pDquOutStationSigStr = (DquOutStationSigStruct *)MyNew((UINT32)(dquOutStationSigStrLen * sizeof(DquOutStationSigStruct)));
			if(NULL == pDquOutStationSigStr)
			{
				dquOutStationSigStrLen = 0u;
				rtnValue = 0u;
			}
			else
			{
				rtnValue = 1u;
				for (ii = 0u;ii < dquOutStationSigStrLen;ii++)
				{
					pDquOutStationSigInfoStr = pDquOutStationSigStr + ii;
					rtnValue &= PZDquOutStationSigAxisSecInfo(pDataAddr,pDquOutStationSigInfoStr);
					pDataAddr += CI_SYSTEM_OUTSIG_RALATE_AXIS_LEN;

					/*将信号机点式临时限速计轴区段转换为逻辑区段*/
					rtnValue &= sigRelatedAxisSecToLogSecTrans(pDquOutStationSigInfoStr);
				}
			}
		}
	}

	return rtnValue;
}

/*********************************************
*函数功能：从点式临时限速配置数据（计轴区段）表到点式临时限速配置结构(逻辑区段)的转换
*参数说明：pDquOutStationSigStrRef 点式临时限速配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
static UINT8 sigRelatedAxisSecToLogSecTrans(DquOutStationSigStruct * pDquOutStationSigStrRef)
{
	UINT16 i = 0u;	/*循环变量*/
	UINT16 j = 0u;	/*循环变量*/
	UINT16 k = 0u;	/*循环变量*/
	UINT16 logSecCnt = 0u;	/*逻辑区段计数值*/
	UINT16 axisSecLogSecNum = 0u;	/*计轴区段包含的逻辑区段数目*/
	UINT16 axisSecLogsecIdBuf[200] = {0u};	/*计轴区段包含逻辑区段IDBuf*/
	UINT16 axisSecId = 0u;	/*计轴区段ID*/
	UINT16 relatedAxisSecSum = 0u;	/*信号机关联的计轴区段数目*/
	UINT16 logSecIdBufIdx = 0u;	/*逻辑区段下标索引*/
	UINT8 retVal = 1u;	/*函数返回值*/

	DSU_AXLE_SGMT_STRU * pQueryAxleSgmtStru = NULL;/*计轴区段信息结构体指针*/

	if(NULL == pDquOutStationSigStrRef)
	{/*参数有效性判断*/
		retVal = 0u;
	}
	else
	{
		relatedAxisSecSum = pDquOutStationSigStrRef->wRelatedAxisSecSum;	/*信号机点式临时限速计轴区段数目*/

		if(relatedAxisSecSum > 0u)
		{
			for(i = 0u; i < relatedAxisSecSum;i++)
			{/*把信号机点式临时限速计轴区段转换为逻辑区段*/
				axisSecId = pDquOutStationSigStrRef->wRelatedAxisSecIdBuf[i];

				if ((0u != axisSecId) && (UINT16_MAX != axisSecId))
				{
					for(j = 0u; j < dsuDataLenStru.wAxleSgmtLen; j++)
					{/*遍历电子地图计轴区段表，查找目标计轴区段*/
						pQueryAxleSgmtStru = dsuStaticHeadStru.pAxleSgmtStru + j;
						if(pQueryAxleSgmtStru->wId == axisSecId)
						{
							axisSecLogSecNum = pQueryAxleSgmtStru->wIncludeLogicSgmtNum;
							for(k = 0u; k < axisSecLogSecNum; k ++)
							{
								axisSecLogsecIdBuf[logSecIdBufIdx] = pQueryAxleSgmtStru->wLogicSgmtId[k];
								logSecIdBufIdx++;
							}

							logSecCnt = logSecCnt + axisSecLogSecNum;	/*逻辑区段数目累加*/
						}
					}
				}		
			}

			pDquOutStationSigStrRef->wRalatedLogSecSum = logSecCnt;	/*赋值逻辑区段数目*/

			(void)memcpy(pDquOutStationSigStrRef->wRalatedLogSecIdBuf,axisSecLogsecIdBuf,(logSecIdBufIdx+1U)*2U);	/*赋值逻辑区段IDBuf, (logSecIdBufIdx+1)*2：数组元素为16进制*/

		}
	}

	return retVal;
}

/*********************************************
*函数功能：根据电子地图中信号机属性设置信号机调车跨压关灯属性
*参数说明：pSgnl是DSU信号机数据结构指针
*          pSgnlCfgDtStr，信号机配置数据结构体指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 SetSignalCrossCloseAttr(DSU_SIGNAL_STRU* pSgnl,SignalConfigDataStruct* pSgnlCfgDtStr)
{
	UINT8 ret = CI_SUCCESS;
	UINT16 sigAttrEmap = 0u;/*电子地图中信号机属性*/

	/*入口参数防护*/
	if((NULL == pSgnl) || (NULL == pSgnlCfgDtStr))
	{
		/*返回失败*/
		ret = CI_ERROR;
	}
	if (CI_SUCCESS == ret)
	{
		sigAttrEmap = pSgnl->wAttribute;
		if ((0x0040u & sigAttrEmap) == 0x0040u)
		{
			pSgnlCfgDtStr->signalCrossCloseAttr = SIGNAL_CROSS_ClOSE_YES;
		}
		else
		{
			pSgnlCfgDtStr->signalCrossCloseAttr = SIGNAL_CROSS_ClOSE_NO;
		}

	}
	return ret;
}


/*********************************************
*函数功能：初始化物理区段故障锁闭照查继电器表
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 RelayPhySecFaultLockZCStruInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	RelayConfigDataStruct* pRlyDfgDtStr = NULL;
	UINT8* pDataAddr = NULL;         /*数据地址*/
	UINT32 DataSize = 0u;          /*数据大小（字节数）*/
	UINT16 j = 0u;
	UINT16 ii =0u;/*游标*/
	UINT16 kk = 0u;

	UINT16 zhaoChaJDQNum = 0u;/*照查继电器数量*/
	UINT16 relayId =0u;
	UINT16 pPhyBuf[1][MAX_LOCK_EXCEPT_SECTION_NUM] = {{0u}};
	UINT32 excelId = 0u; /*excel id*/
	UINT32 sheetId = 0u; /*sheet id*/
	UINT32 rowLen = 0u; /*行长度*/
	UINT8 localCiPattern = 0u; /*本CI模式*/

	/*已经初始化了，不用老是调用执行过程*/
	if(NULL != dquCICfgDtStr.RelayCfgDtStr)
	{
		localCiPattern = GetLocalCiPattern();
		if (CI_PATTERN_TRADITIONAL == localCiPattern)
		{
			excelId = CI_DATA_TYPE;
			sheetId = RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID;
			rowLen = LEN_RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID;
		}
		else
		{
			excelId = OC_DATA_TYPE;
			sheetId = OC_RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID;
			rowLen = OC_LEN_RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID;
		}

		/*读取 物理区段故障锁闭照查继电器表  数据*/
		funcRtn = dquGetConfigData(FSName, excelId, sheetId,&pDataAddr,&DataSize);
		if(funcRtn == 0u)
		{
			/*函数调用失败*/
			rtnValue = 0u;
		} 	
		else
		{/*函数调用成功*/
			rtnValue = 1u;
		}

		if (1u == rtnValue)
		{
			/*行数是整数*/
			if(DataSize% rowLen != 0u)
			{   
				rtnValue = 0u;
				debug_infor_printf((const)"\nCI_RELAY_DATA,RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID,len %d not equal to fs", rowLen);
				DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,(excelId <<8)+ rowLen,PRINT_ONCE);
			}		
		}

		if (1u == rtnValue)
		{
			zhaoChaJDQNum = (UINT16)(DataSize/ rowLen);

			dquCICfgDtStr.RelayCfgDtStrLen = RelayDataLen.RelayCfgDtStrLen;
			
			LockExceptZhaoChaRelayNum = 0u;/*故障锁闭照查继电器数量*/

			for (ii =0u;ii<zhaoChaJDQNum;ii++)
			{
				(void)RelayCfgFaultLockPhySecFromChar(pDataAddr,pRlyDfgDtStr, &relayId,pPhyBuf);
				pDataAddr += rowLen;
				/*解析数据到 继电器数据 结构体数组 */  
				for(j=0u;j<RelayDataLen.RelayCfgDtStrLen;j++)
				{
					if (j >= RELAY_SUM_MAX)
					{
						rtnValue = 0u;
						break;
					}

					pRlyDfgDtStr = &dquCICfgDtStr.RelayCfgDtStr[j];
												
					/*填充数据结构体*/
					if (pRlyDfgDtStr->RelayId == relayId)
					{
						/*记录故障锁闭照查继电器数量和故障锁闭照查继电器ID数组*/
						LockExceptZhaoChaRelayId[LockExceptZhaoChaRelayNum] = relayId;
						LockExceptZhaoChaRelayNum++;

						pRlyDfgDtStr->LockExceptPhySecNum = 0u;
						for (kk=0u;kk<MAX_LOCK_EXCEPT_SECTION_NUM;kk++)
						{
							if (0u != pPhyBuf[0][kk])
							{
								pRlyDfgDtStr->LockExceptPhySecIdBuf[pRlyDfgDtStr->LockExceptPhySecNum] = pPhyBuf[0][kk];
								pRlyDfgDtStr->LockExceptPhySecNum++;
							}
							
						}
							
						break;
					}
						
				}
			}
				
			
		}

	}

	return rtnValue;
}

/*********************************************
*函数功能：将FS对应的数据填充到结构体
*参数说明：pSrc FS数据结构体指针，pDes要赋值的结构体数组指针，ArrBuff结构体成员长度指针，realRowCount真实行数
*返回值：0，失败；1，成功
*********************************************/
UINT8 OcStruFromChar(const UINT8 *pSrc, UINT8 *pDes, const UINT8 *ArrBuff, const UINT16 realRowCount)
{
	UINT8 rtnValue = 0u;
	UINT8 *pTempSrc = NULL;
	UINT8 *pTempDes = NULL;
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 len = 0u;
	UINT8 num = 0u;
	UINT16 totalByteLen = 0u;

	/*入参防护*/
	if ((NULL == pSrc) || (NULL == pDes) || (NULL == ArrBuff))
	{
		rtnValue = 0u;
	}
	else
	{
		pTempSrc = pSrc;
		pTempDes = pDes;

		/*获取结构体成员个数*/
		num = ArrBuff[0];

		if (num < MEMBERA_SUM_MAX)
		{
			rtnValue = 1u;

			for (i = 1u; i <= num; i++)
			{
				/*按顺序获取结构体某一个成员的长度*/
				len = ArrBuff[i];
				/*统计字节数*/
				totalByteLen = totalByteLen + len;
				/*不大于一行字节数*/
				if(totalByteLen <= realRowCount)
				{
					switch (len)
					{
						/*一个字节*/
					case CHAR_LEN:
						/*给结构体成员赋值*/
						*pTempDes = *pTempSrc;
						pTempDes += CHAR_LEN;
						pTempSrc += CHAR_LEN;
						break;
						/*二个字节*/
					case SHORT_LEN:
						for (j = 0u; j < SHORT_LEN; j++)
						{
							/*给结构体成员赋值两个字节内容*/
							*(pTempDes + SHORT_LEN - 1u - j) = *(pTempSrc + j);
						}
						pTempDes += SHORT_LEN;
						pTempSrc += SHORT_LEN;
						break;
						/*四个字节*/
					case LONG_LEN:
						for (j = 0u; j < LONG_LEN; j++)
						{
							/*给结构体成员赋值四个字节内容*/
							*(pTempDes + LONG_LEN - 1u - j) = *(pTempSrc + j);
						}
						pTempDes += LONG_LEN;
						pTempSrc += LONG_LEN;
						break;
					default:
						/*结构体成员长度错误*/
						rtnValue *= 0u;
						break;
					}
				}
				else
				{
					rtnValue = 0u;
					break;
				}

			}
		}
	}

	return rtnValue;
}

/*********************************************
*函数功能：获取FS配置表数据，计算有效长度
*参数说明：UINT16* len数据行数,FSName文件指针，DataTypeID数据类型，ConfigId，表单编号
			StrArrLen结构体数组长度，StrLen结构体长度，
			pStr要存入数据的结构体数组指针，ArrBuff结构体成员长度数组
*返回值：0，失败；其他，长度
*********************************************/
UINT8 OCConfigDataStructInit(UINT16* len, CHAR* FSName, UINT32 DataTypeID, UINT32 ConfigId, UINT16 StrArrLen, void* pStr, UINT8* ArrBuff)
{
	UINT8 rtnValue = 0u;
	UINT8* pDataAddr = NULL;      /*数据地址*/
	UINT32 DataSize = 0u;          /*数据大小（字节数）*/
	UINT16 j = 0u;
	UINT8* pTemp = NULL;
	UINT16 realRowCount = 0u; /*实际表数据的行数*/
	UINT16 realRowLen = 0u; /*实际表数据的一行的长度*/

	if ((NULL != len) && (NULL != FSName) && (NULL != pStr) && (NULL != ArrBuff))
	{
		/*读取数据*/
		rtnValue = dquGetConfigDataNew(FSName, DataTypeID, ConfigId,&pDataAddr,&DataSize,&realRowCount);
		if (1u == rtnValue)
		{
			/*数据读取正确*/
			if((0u != DataSize) && (0u != realRowCount))
			{
				if(0u != (DataSize% realRowCount))
				{   
					debug_infor_printf((const)"\nOC_CI_CONFIG len %x %d %d not equal to fs", ConfigId,DataSize,realRowCount);
					rtnValue = 0u;
				}
				else
				{
					/*获取行数长度，一行字节数*/
					*len = realRowCount;
					realRowLen = (UINT16)(DataSize / realRowCount);

					if (*len < StrArrLen)
					{
						/*解析数据到结构体数组*/
						for (j = 0u; j < *len; j++)
						{
							pTemp = (UINT8*)pStr + j * realRowLen;

							/*填充数据结构体*/
							rtnValue *= OcStruFromChar(pDataAddr, pTemp, ArrBuff, realRowLen);

							pDataAddr += realRowLen;
						}
					}
					else
					{
					}

				}
			}
			else
			{
			}
		}
		else
		{
		}
	}
	else
	{
	}

	return rtnValue;
}

/*********************************************
*函数功能：初始化OC 道岔配置表数据
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 OCSwitchConfigDataStructInit(CHAR *FSName)
{
	UINT8 rtnValue = 0u;
	UINT16 len = 0u;
	UINT16 i = 0u;
	UINT8 ArrBuff[MEMBERA_SUM_MAX] = { 0u };
	OCSwitchConfigDataStruct OCSwitchCfgStrBuff[SWITCH_SUM_MAX] = { 0u };

	/*index0：结构体成员个数，其他按顺序填充结构体成员长度*/
	ArrBuff[0] = OC_SWITCH_CFG_STR_MEMBER_NUM;
	ArrBuff[1] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchId);
	ArrBuff[2] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].BelongOcId);
	(void)memset(dquCICfgDtStr.OCSwitchCfgStr, 0x00, sizeof(OCSwitchConfigDataStruct) * SWITCH_SUM_MAX);

	rtnValue = OCConfigDataStructInit(&len, FSName, OC_DATA_TYPE, OC_SWITCH_ID, SWITCH_SUM_MAX, \
               (void*)OCSwitchCfgStrBuff, ArrBuff);

	if (1u == rtnValue)
	{
		/*填充OCSwitchCfgStr数组长度*/
		dquCICfgDtStr.OCSwitchCfgStrLen = len;
		for (i = 0u; i < len; i++)
		{
			if (OCSwitchCfgStrBuff[i].SwitchId < SWITCH_SUM_MAX)
			{
				dquCICfgDtStr.OCSwitchCfgStr[OCSwitchCfgStrBuff[i].SwitchId] = OCSwitchCfgStrBuff[i];
			}
		}
	}

	return rtnValue;
}

/*********************************************
*函数功能：初始化OC 道岔配置表数据——OC2.1.6
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 OCSwitchConfigDataStructInit_OLD(CHAR *FSName)
{
	UINT8 rtnValue = 0u;
	UINT16 len = 0u;
	UINT16 i = 0u;
	UINT8 ArrBuff[MEMBERA_SUM_MAX] = { 0u };
	OCSwitchConfigDataStruct_2 OCSwitchCfgStrBuff[SWITCH_SUM_MAX] = { 0u };

	/*index0：结构体成员个数，其他按顺序填充结构体成员长度*/
	ArrBuff[0] = OC_SWITCH_CFG_STR_MEMBER_NUM_OLD;
	ArrBuff[1] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchId);
	ArrBuff[2] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].BelongOcId);
	ArrBuff[3] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchModuleIdAddrA);
	ArrBuff[4] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchMachinePosAddrA);
	ArrBuff[5] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchModuleIdAddrB);
	ArrBuff[6] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchMachinePosAddrB);
	(void)memset(dquCICfgDtStr.OCSwitchCfgStr, 0x00, sizeof(OCSwitchConfigDataStruct) * SWITCH_SUM_MAX);

	rtnValue = OCConfigDataStructInit(&len, FSName, OC_DATA_TYPE, OC_SWITCH_ID, SWITCH_SUM_MAX, \
		(void*)OCSwitchCfgStrBuff, ArrBuff);

	if (1u == rtnValue)
	{
		/*填充OCSwitchCfgStr数组长度*/
		dquCICfgDtStr.OCSwitchCfgStrLen = len;
		for (i = 0u; i < len; i++)
		{
			if (OCSwitchCfgStrBuff[i].SwitchId < SWITCH_SUM_MAX)
			{
				dquCICfgDtStr.OCSwitchCfgStr[OCSwitchCfgStrBuff[i].SwitchId].SwitchId = OCSwitchCfgStrBuff[i].SwitchId;
				dquCICfgDtStr.OCSwitchCfgStr[OCSwitchCfgStrBuff[i].SwitchId].BelongOcId = OCSwitchCfgStrBuff[i].BelongOcId;
			}
		}
	}

	return rtnValue;
}

/*********************************************
*函数功能：解析OC 信号机表数据
*参数说明：pDataAddr 数据地址；pOCSignalCfgStr oc配置数据结构体；SwitchId信号机ID
* dataLen  每行字节长度
*返回值：0，失败；1，成功
*备注：无
*********************************************/
void R_OCSignalConfigDataFromChar(UINT8* pDataAddr,UINT16 dataLen)
{
	UINT8* pData = NULL;
	UINT16 wSignalIdTemp = 0u;

	if (NULL == pDataAddr)
	{
		; /*入口参数为空，不进行解析操作*/
	}
	else
	{
		pData = pDataAddr;
		wSignalIdTemp = ShortFromChar(pData);

		if (wSignalIdTemp < SIGNAL_SUM_MAX)
		{
			/*信号机ID--2字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].SignalId = wSignalIdTemp;
			pData += 2u;

			/*所属OC--2字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].BelongOcId = ShortFromChar(pData);
			pData += 2u;

			/* RCI不读下列数据 */
#if 1
			/*信号机模块A系ID--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].SignalModuleIdAddrA = *pData;
			pData++;

			/*A系红灯灯位地址--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].RedPosAddrA = *pData;
			pData++;

			/*A系黄灯灯位地址--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].YellowPosAddrA = *pData;
			pData++;

			/*A系绿灯灯位地址--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].GreenPosAddrA = *pData;
			pData++;

			/*A系白灯灯位地址--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].WhitePosAddrA = *pData;
			pData++;

			/*A系蓝灯灯位地址--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].BluePosAddrA = *pData;
			pData++;

			/*信号机模块B系ID--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].SignalModuleIdAddrB = *pData;
			pData++;

			/*B系红灯灯位地址--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].RedPosAddrB = *pData;
			pData++;

			/*B系黄灯灯位地址--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].YellowPosAddrB = *pData;
			pData++;

			/*B系绿灯灯位地址--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].GreenPosAddrB = *pData;
			pData++;

			/*B系白灯灯位地址--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].WhitePosAddrB = *pData;
			pData++;

			/*B系蓝灯灯位地址--1字节*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].BluePosAddrB = *pData;
			pData++;
			
#endif
			

			/*扣车按钮采集继电器ID*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainBtnCollRelayId = ShortFromChar(pData);
			pData += 2u;

			/*扣车按钮采集继电器2 ID*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainBtnCollRelayId_2 = ShortFromChar(pData);
			pData += 2u;

			/*扣车按钮指示灯继电器ID*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainBtnIndicatorRelayId = ShortFromChar(pData);
			pData += 2u;

			/*扣车按钮指示灯继电器2 ID*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainBtnIndicatorRelayId_2 = ShortFromChar(pData);
			pData += 2u;

			/*扣车旁路按钮继电器ID*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainCutBtnRelayId = ShortFromChar(pData);
			pData += 2u;

			/*扣车旁路按钮继电器2 ID*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainCutBtnRelayId_2 = ShortFromChar(pData);
			pData += 2u;

			/*扣车旁路按钮指示灯继电器ID*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainCutBtnIndicatorRelayId = ShortFromChar(pData);
			pData += 2u;

			/*扣车旁路按钮指示灯继电器2 ID*/
			dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainCutBtnIndicatorRelayId_2 = ShortFromChar(pData);
			pData += 2u;
			if (32U < dataLen)
			{
				/*取消扣车按钮采集继电器1 ID*/
				dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].CancelDetainBtnCollRelayId = ShortFromChar(pData);
				pData += 2u;
				/*取消扣车按钮采集继电器2 ID*/
				dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].CancelDetainBtnCollRelayId_2 = ShortFromChar(pData);
				pData += 2u;
			}
			else
			{
				/*取消扣车按钮采集继电器1 ID*/
				dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].CancelDetainBtnCollRelayId = 0U;
				/*取消扣车按钮采集继电器2 ID*/
				dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].CancelDetainBtnCollRelayId_2 = 0U;
			}
		}

	}

}

/*********************************************
*函数功能：初始化OC 信号机配置表数据
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*备注：m by yt 修改AR回复：修改初始化《OC_配置数据表》中“物理区段模块配置表”、“信号机模块配置表”、“道岔模块配置表”的初始化方式，和其他表格的初始化方式一致
*********************************************/
#if 0 
UINT8 OCSignalCfgStrConfDataStruInit(CHAR *FSName)
{
	UINT8 rtnValue = 0u;
	UINT16 len = 0u;
	UINT16 i = 0u;
	UINT8 ArrBuff[24] = { 0u };
	OCSignalConfigDataStruct OCSignalCfgStrBuff[SIGNAL_SUM_MAX] = { 0u };

	/*index0：结构体成员个数，其他按顺序填充结构体成员长度*/
	ArrBuff[0] = OC_SIGNAL_CFG_STR_MEMBER_NUM;
	ArrBuff[1] = sizeof(OCSignalCfgStrBuff[0].SignalId);
	ArrBuff[2] = sizeof(OCSignalCfgStrBuff[0].BelongOcId);
	ArrBuff[3] = sizeof(OCSignalCfgStrBuff[0].SignalModuleIdAddrA);
	ArrBuff[4] = sizeof(OCSignalCfgStrBuff[0].RedPosAddrA);
	ArrBuff[5] = sizeof(OCSignalCfgStrBuff[0].YellowPosAddrA);
	ArrBuff[6] = sizeof(OCSignalCfgStrBuff[0].GreenPosAddrA);
	ArrBuff[7] = sizeof(OCSignalCfgStrBuff[0].WhitePosAddrA);
	ArrBuff[8] = sizeof(OCSignalCfgStrBuff[0].BluePosAddrA);
	ArrBuff[9] = sizeof(OCSignalCfgStrBuff[0].SignalModuleIdAddrB);
	ArrBuff[10] = sizeof(OCSignalCfgStrBuff[0].RedPosAddrB);
	ArrBuff[11] = sizeof(OCSignalCfgStrBuff[0].YellowPosAddrB);
	ArrBuff[12] = sizeof(OCSignalCfgStrBuff[0].GreenPosAddrB);
	ArrBuff[13] = sizeof(OCSignalCfgStrBuff[0].WhitePosAddrB);
	ArrBuff[14] = sizeof(OCSignalCfgStrBuff[0].BluePosAddrB);
	ArrBuff[15] = sizeof(OCSignalCfgStrBuff[0].DetainBtnCollRelayId);
	ArrBuff[16] = sizeof(OCSignalCfgStrBuff[0].DetainBtnIndicatorRelayId);
	ArrBuff[17] = sizeof(OCSignalCfgStrBuff[0].DetainCutBtnRelayId);
	ArrBuff[18] = sizeof(OCSignalCfgStrBuff[0].DetainCutBtnIndicatorRelayId);

	(void)memset(dquCICfgDtStr.OCSignalCfgStr, 0x00, sizeof(OCSignalConfigDataStruct) * SIGNAL_SUM_MAX);

	rtnValue = OCConfigDataStructInit(&len, FSName, OC_DATA_TYPE, OC_SIGNAL_ID, SIGNAL_SUM_MAX, \
		(void*)OCSignalCfgStrBuff, ArrBuff);

	if (1u == rtnValue)
	{
		/*填充OCSignalCfgStr数组长度*/
		dquCICfgDtStr.OCSignalCfgStrLen = len;
		for (i = 0u; i < len; i++)
		{
			if (OCSignalCfgStrBuff[i].SignalId < SIGNAL_SUM_MAX)
			{
				dquCICfgDtStr.OCSignalCfgStr[OCSignalCfgStrBuff[i].SignalId] = OCSignalCfgStrBuff[i];
			}
		}
	}

	return rtnValue;
}
#endif
UINT8 OCSignalCfgStrConfDataStruInit(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8* pDataAddr = NULL;			/*数据地址*/
	UINT32 DataSize = 0u;				/*数据大小（字节数）*/
	UINT8 funcRtn = 0u;
	UINT16 realRowCount = 0u;			/*实际表数据的行数*/
	UINT16 i = 0u;
	UINT16 wDataLen = 0u;				/*数据宽度*/

	/*入口参数检查*/
	if (NULL == FSName)
	{
		; /*入口参数不合法*/
	}
	else
	{
		/*读取OC配置数据表数据*/
		funcRtn = dquGetConfigDataNew(FSName, OC_DATA_TYPE, OC_SIGNAL_ID, &pDataAddr, &DataSize, &realRowCount);
		if (0u == funcRtn)
		{
			rtnValue = 0u;
		}
		else
		{
			rtnValue = 1u;
			funcRtn = CommonMemSet(dquCICfgDtStr.OCSignalCfgStr, (UINT32)(SIGNAL_SUM_MAX * sizeof(OCSignalConfigDataStruct)), 0u, (UINT32)(SIGNAL_SUM_MAX * sizeof(OCSignalConfigDataStruct)));

			if (1u == funcRtn)
			{
				/*不做处理*/
			}
			if ((0u != DataSize) && (0u != realRowCount))
			{
				if (0u == (DataSize % realRowCount))
				{
					/*计算每行字节长度*/
					wDataLen = (UINT16)(DataSize / realRowCount);
					/*信号机个数*/
					dquCICfgDtStr.OCSignalCfgStrLen = realRowCount;

					for (i = 0u; i < realRowCount; i++)
					{
						/*解析信号机配置表*/
						R_OCSignalConfigDataFromChar(pDataAddr, wDataLen);
						pDataAddr += wDataLen;
					}
				}
				else
				{
					/*数据错误*/
					rtnValue = 0u;
				}


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

	}

	return rtnValue;
}

/*********************************************
*函数功能：OC信号机是否有蓝灯位
*参数说明：信号机ID
*返回值：0，否；1，是
*********************************************/
UINT8 OcSignalHasBlue(const UINT16 signalId)
{
	UINT8 rtn = 0u;

	if ((signalId < SIGNAL_SUM_MAX)&&(0U < signalId))
	{
		if ((dquCICfgDtStr.OCSignalCfgStr[signalId].BluePosAddrA > 0u) && (dquCICfgDtStr.OCSignalCfgStr[signalId].BluePosAddrA < 255U))
		{
			rtn = 1u;
		}
	}

	return rtn;
}


/*********************************************
*函数功能：初始化OC 物理区段配置表数据
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 OCPhySecConfigDataStructInit(CHAR *FSName)
{
	UINT8 rtnValue = 1u;
	UINT16 len = 0u;
	UINT16 i = 0u;
	UINT8 ArrBuff[MEMBERA_SUM_MAX] = { 0u };
	OCPhysicalSectionConfigDataStruct OCPhySecCfgStrBuff[PHYSICAL_SECTION_SUM_MAX] = { 0u };

	/*index0：结构体成员个数，其他按顺序填充结构体成员长度*/
	ArrBuff[0] = OC_PHYSEC_CFG_STR_MEMBER_NUM;
	ArrBuff[1] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].PhysicalSectionId);
	ArrBuff[2] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].BelongOcId);
	ArrBuff[3] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].PhysicalSectionModuleIdAddrA);
	ArrBuff[4] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].PhysicalSectionPosAddrA);
	ArrBuff[5] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].PhysicalSectionModuleIdAddrB);
	ArrBuff[6] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].PhysicalSectionPosAddrB);

	(void)memset(dquCICfgDtStr.OCPhySecCfgStr, 0x00, sizeof(OCPhysicalSectionConfigDataStruct) * PHYSICAL_SECTION_SUM_MAX);

	rtnValue = OCConfigDataStructInit(&len, FSName, OC_DATA_TYPE, OC_PHYSEC_ID, PHYSICAL_SECTION_SUM_MAX, \
		       (void*)OCPhySecCfgStrBuff, ArrBuff);

	if (1u == rtnValue)
	{
		/*填充OCPhySecCfgStr数组长度*/
		dquCICfgDtStr.OCPhySecCfgStrLen = len;
		for (i = 0u; i < len; i++)
		{
			if (OCPhySecCfgStrBuff[i].PhysicalSectionId < PHYSICAL_SECTION_SUM_MAX)
			{
				dquCICfgDtStr.OCPhySecCfgStr[OCPhySecCfgStrBuff[i].PhysicalSectionId] = OCPhySecCfgStrBuff[i];
			}
		}
	}

	return rtnValue;
}

/* 功能描述：获取Oc Id所属的联锁Id
*  参数说明：
*		UINT16 ocId：oc编号
*  返回值：
*		UINT16：联锁id
*/
UINT16 GetCiIdByOcId(UINT16 ocId)
{
	UINT16 i = 0u; /*用于循环*/
	UINT16 j = 0u; /*用于循环*/
	UINT16 ciId = 0u; /*CI ID*/
	UINT8 isBreak = 0u; /*是否退出遍历*/

	for (i = 0u; i < dquCICfgDtStr.TrsmtRlsDtStrLen; i++)
	{
		if (CI_SYSTEM_TYPE_OC == dquCICfgDtStr.TrsmtRlsDtStr[i].SystemType)
		{
			for (j = 0u; j < dquCICfgDtStr.TrsmtRlsDtStr[i].DeviceSum; j++)
			{
				if(TRANSMIT_OBJECT_DEVICE_SUM_MAX > j)
				{
					if (ocId == dquCICfgDtStr.TrsmtRlsDtStr[i].DeviceIdBuf[j])
					{
						ciId = dquCICfgDtStr.TrsmtRlsDtStr[i].CiId;

						isBreak = 1u; /*退出遍历*/
						break;
					}
				}
			}
		}
		if (1u == isBreak) /*是退出遍历*/
		{
			break;
		}
	}

	return ciId;
}

/*********************************************
*函数功能：初始化站台门控制器配置数据结构体----对外结构体
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 PscConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;

	callFun = dfsEmapInit (FSName);

	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}	
	else
	{/*电子地图初始化成功，继续执行*/
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.PscCfgDtStrLen = dsuDataLenStru.wPSCLen;/*psc数量*/
		for(i=0u;i<dsuDataLenStru.wPSCLen;i++)
		{
			if (i >= PSC_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			rtnvalue &= PscCfgDtStruFromDquPointStr(dsuStaticHeadStru.pPSCStru+i,&dquCICfgDtStr.PscCfgDtStr[i]);
		}
	}

	return rtnvalue;
}

/*********************************************
*函数功能：从PSC结构体计算PSC结构体
*参数说明：pPoint站台门控制器结构体指针
pPscCfgDtStr站台门控制器配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 PscCfgDtStruFromDquPointStr(DSU_PSC_STRU* pPoint,PscConfigDataStruct* pPscCfgDtStr)
{
	UINT16 j=0u;
	UINT8 rtnvalue = 0u;

	/*入口参数防护*/
	if((NULL == pPoint) || (NULL == pPscCfgDtStr))
	{
		/*返回失败*/
		rtnvalue = 0u;
	}
	else
	{
		pPscCfgDtStr->PscId = pPoint->wId;
		pPscCfgDtStr->psdSum = 0u;
		for(j=0;j<4u;j++)
		{
			pPscCfgDtStr->psdIdBuff[j] = ((0xffffu!=pPoint->wContainPSDID[j]  ) ? pPoint->wContainPSDID[j] : 0U);
			if (0U!=pPscCfgDtStr->psdIdBuff[j])
			{
				pPscCfgDtStr->psdSum++;
			}
		}
		rtnvalue = 1u;
	}

	return rtnvalue;
}


/*********************************************
*函数功能：初始化组合自动进路配置数据接口配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 GroupAutoRouteCfgDtStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i=0u;
	UINT16 j=0u;

	callFun = dfsEmapInit (FSName);
	callFun *= InitLS_GroupAutoRouteStru(FSName);
	/*电子地图初始化失败，函数失败退出*/
	if(0u == callFun)
	{
		rtnvalue = 0u;
	}
	/*电子地图初始化成功，继续执行*/
	else
	{	 
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.GroupAutoRouteStrLen = LSDataLen.LSGroupAutoRouteStruLen;
		for(i=0u;i<LSDataLen.LSGroupAutoRouteStruLen;i++)
		{
			if (GROUP_AUTO_ROUTE_SUM_MAX <= i)
			{
				rtnvalue = 0u;
				break;
			}
			dquCICfgDtStr.GroupAutoRouteCfgStr[i].GroupAutoRouteId = LSData.pLSGroupAutoRouteStru[i].wId;
			dquCICfgDtStr.GroupAutoRouteCfgStr[i].InAutoRouteSum = 0u;
			for(j=0u;j<AR_MAX_INCLUDE_ROUTE_NUM;j++)
			{
				if(0u != LSData.pLSGroupAutoRouteStru[i].szIncludeAutoRouteId[j])
				{
					dquCICfgDtStr.GroupAutoRouteCfgStr[i].InAutoRouteIdBuff[j] = LSData.pLSGroupAutoRouteStru[i].szIncludeAutoRouteId[j];
					dquCICfgDtStr.GroupAutoRouteCfgStr[i].InAutoRouteSum += 1u;
				}
			}

		}
	}

	return rtnvalue;
}

/*********************************************
*函数功能：读取虚拟联锁与OC关系表
*参数说明：FSName文件指针          
*返回值：0，失败；1，成功
*********************************************/
UINT8 ReadVirCIWithOCRelationData(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	UINT8* pDataAddr;                                              /*数据地址*/
	UINT32 DataSize;                                               /*数据大小（字节数）*/
	UINT16 ii = 0u;
	UINT8 RowDatalen =0u;/*行数*/
	UINT8 virCIid = 0u;
	UINT8 jj =0u;
	UINT16 ocid =0u; 
	UINT8 ocNum=0u;


	/*读取出虚拟设备的系统配置数据*/
	funcRtn = dquGetConfigData(FSName,CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_VIRCI_INCLUDEOC_ID,&pDataAddr,&DataSize);
	if(0u == funcRtn)
	{
		/*函数调用失败*/
		rtnValue = 0u;
	} 
	else
	{
		/*求得个数*/
		if(0u != (DataSize % CI_SYSTEM_VIRCI_INCLUDEOC_LEN))
		{
			if(0u < DataSize)
			{/*为0说明未配置虚拟联锁*/
				debug_infor_printf((const)"\nCI_CONFIG_DATA,VirCIWithOCRelation,len %d not equal to fs",CI_SYSTEM_VIRCI_INCLUDEOC_LEN);
				DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_VIRCI_INCLUDEOC_ID,PRINT_ONCE);
				rtnValue = 0u;
			}
			else
			{
			}
			
		}
		else
		{
			RowDatalen = (UINT8)(DataSize / CI_SYSTEM_VIRCI_INCLUDEOC_LEN);
			
		
			for (ii = 0u;ii < RowDatalen;ii++)
			{
				virCIid = (UINT8)ShortFromChar(pDataAddr);
				pDataAddr+=2u;
				for(jj=0u;jj<g_VirtualCIStructData.virtualCiNum;jj++)
				{
					if(VIRTUAL_CI_MAX > jj)
					{
						if(virCIid == g_VirtualCIStructData.virtualCi[jj].virtualCiId)
						{
							ocNum = PZDquVirCIWithOCRelatFromChar(pDataAddr,g_VirtualCIStructData.virtualCi[jj].IncludeOCid);
							g_VirtualCIStructData.virtualCi[jj].IncludeOCNum = ocNum;
							break;
						}
						else
						{
						}
					}
					else
					{
					}
				}
				pDataAddr += CI_SYSTEM_VIRCI_INCLUDEOC_LEN-2U;
			}
			rtnValue = 1u;			
		}
	}

	return rtnValue;
}

/*********************************************
*函数功能：初始化虚拟联锁使用的报警灯配置数据
*参数说明：void
*返回值：0，失败；1，成功
*********************************************/
UINT8 InitBaojingdeng_UseVirCI(void)
{
	UINT16 ii = 0u;
	UINT8 localCi = GetSystemParaLocalCiId();                    /*本地联锁ID*/
	UINT16 bjdNum= 0u;
	UINT8 reVal = CI_ERROR;
	for(ii=0u;ii<RelayDataLen.RelayBjdStrLen;ii++)
	{
		if(localCi == RelayData.pRelayBjdStr[ii].wBelongCiId)
		{
			if(LOCAL_CI_INDICATOR_SUM_MAX > bjdNum)
			{
				reVal = CI_SUCCESS;
				g_VirtualCIStructData.LocalCIBaojingdeng[bjdNum].wId = RelayData.pRelayBjdStr[ii].wId;
				g_VirtualCIStructData.LocalCIBaojingdeng[bjdNum].wBjdID = RelayData.pRelayBjdStr[ii].wBjdID;
				g_VirtualCIStructData.LocalCIBaojingdeng[bjdNum].wBelongCiId = localCi;
				g_VirtualCIStructData.LocalCIBaojingdeng[bjdNum].wBelongVirCIid = RelayData.pRelayBjdStr[ii].wBelongVirCIid; 
				g_VirtualCIStructData.LocalCIBaojingdeng[bjdNum].wBjdDevID = RelayData.pRelayBjdStr[ii].cBjdDevId;
				bjdNum += 1U;
			}
			else
			{
				reVal = CI_ERROR;
				bjdNum = 0u;
				break;
			}
		}
	}
	g_VirtualCIStructData.LocalCIBaojingdengNum = bjdNum;
	return reVal;
}
/*
*函数功能：根据继电器Id 查找所属虚拟联锁
*参数说明：根据继电器ID查找指定所属虚拟联锁
*返回值：0 失败，>0 成功
* 限制条件：必须继电器数据读取完毕
*/
UINT8 GetBelongVirCiByRelayId(UINT16 relayId )
{
	UINT8 VirCIid = 0u;
	UINT16 ii = 0u;

	if ((0u < RelayDataLen.RelayCfgDtStrLen) && (NULL != RelayData.pRelayCfgDtStr))
	{
		for (ii =0u;ii<RelayDataLen.RelayCfgDtStrLen;ii++)
		{
			if (relayId == RelayData.pRelayCfgDtStr[ii].RelayId)
			{
				VirCIid = RelayData.pRelayCfgDtStr[ii].BelongVirCIid;
				break;
			}
		}
	}

	return VirCIid;
}
/*
*函数功能：获取dsu信息索引数组内容
*参数说明：const UINT16 linkId LINKID
           UINT16 *pLinkIndex  输出Link索引
*返回值：CI_SUCCESS成功
*        CI_ERROR 失败
*/
UINT8 GetDsuLinkIndexNum(const UINT16 linkId,UINT16 *pLinkIndex)
{
	UINT8 reVal = CI_ERROR;
	if((linkId <= LINKINDEXNUM)&&(NULL !=dsuLinkIndex)&&(NULL != pLinkIndex))
	{
		if(dsuLinkIndex[linkId] < (dsuDataLenStru.wLinkLen))
		{
			*pLinkIndex = dsuLinkIndex[linkId];
			reVal = CI_SUCCESS;
		}
	}
	else
	{
		reVal = CI_ERROR;
	}
	return reVal;
}

/*********************************************
*函数功能：读取主体信号机与复示信号机关系表
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 ReadSigWithFushiSigRelatData(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	UINT8* pDataAddr;                                              /*数据地址*/
	UINT32 DataSize;                                               /*数据大小（字节数）*/
	UINT16 ii = 0u;
	UINT16 RowDatalen = 0u;/*行数*/
	UINT16 ztSignalId = 0u;/*主体信号机ID*/
	UINT8 fushiSigNum = 0u;
	UINT16 signalId = 0u;
	UINT16 jj = 0u;
	UINT16* pFushiSignalIdBuf = NULL;
	UINT16 signalSum = 0u;
	UINT8 isfushiFlag = 0u;
	/*读取出虚拟设备的系统配置数据*/
	funcRtn = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_SIGWITHFUSHISIG_ID, &pDataAddr, &DataSize);
	if (0u == funcRtn)
	{
		/*函数调用失败*/
		rtnValue = 0u;
	}
	else
	{
		/*求得个数*/
		if (0U != (DataSize % CI_SYSTEM_SIGWITHFUSHISIG_LEN))
		{
			if (0u < DataSize)
			{
				debug_infor_printf((const)"\CI_SYSTEM_PARAMETER_DATA_TYPE,CI_SYSTEM_SIGWITHFUSHISIG_ID,len %d not equal to fs", CI_SYSTEM_SIGWITHFUSHISIG_LEN);
				DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software, CI_DEVICE_TYPE_FS_TABLE, (CI_SYSTEM_PARAMETER_DATA_TYPE << 8) + CI_SYSTEM_SIGWITHFUSHISIG_ID, PRINT_ONCE);
				rtnValue = 0U;
			}

		}
		else
		{
			RowDatalen = (UINT16)(DataSize / CI_SYSTEM_SIGWITHFUSHISIG_LEN);
			for (ii = 0U; ii < RowDatalen; ii++)
			{
				ztSignalId = ShortFromChar(pDataAddr);/*主体信号机*/
				pDataAddr += 2U;
				signalSum = GetTotalSignalCurNum();/*本联锁和相邻联锁*/
				isfushiFlag = GetSignalIsfushiFlag(ztSignalId);
				if (SIGNALTYPE_FUSHI_YES != isfushiFlag)/*该信号机不是其他信号机的复示信号机*/
				{
					for (jj = 0u; jj < signalSum; jj++)
					{
						signalId = GetSignalId(jj);
						if (signalId == ztSignalId)
						{
							pFushiSignalIdBuf = GetSignalFushiSignalIdBuf(signalId);
							if (NULL != pFushiSignalIdBuf)
							{
								fushiSigNum = PZDquSigWithFushiSigFromChar(pDataAddr, pFushiSignalIdBuf);/*读取指定主体信号机的复示信号机ID*/
								SetSignalFushiSignalNum(signalId, fushiSigNum);/*设置信号机拥有的复示信号机数*/
							}
							break;
						}
					}
				}
				pDataAddr += CI_SYSTEM_SIGWITHFUSHISIG_LEN - 2U;
			}
			rtnValue = 1U;
		}
	}

	return rtnValue;
}

/*********************************************
*函数功能：读取总SPKS管辖各SPKS关系表
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 ReadTotalSpksWithSpksRelatData(CHAR* FSName)
{
	UINT8 rtnValue = 0u;
	UINT8 funcRtn = 0u;
	UINT8* pDataAddr;                                              /*数据地址*/
	UINT32 DataSize;                                               /*数据大小（字节数）*/
	UINT16 ii = 0u;
	UINT16 RowDatalen = 0u;/*行数*/
	UINT16 totalSpksId = 0u;
	UINT16 jj = 0u;
	UINT16 wSpksSum = 0u;
	UINT16 spksId = 0u;
	UINT16* pSpksIncludeSpksIdBuf = NULL;
	UINT8 includeSpksNum = 0u;
	/*读取出虚拟设备的系统配置数据*/
	funcRtn = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_ZSPKS_INCLUDE_ID, &pDataAddr, &DataSize);
	if (0u == funcRtn)
	{
		/*函数调用失败*/
		rtnValue = 0u;
	}
	else
	{
		/*求得个数*/
		if (0U != (DataSize % CI_SYSTEM_ZSPKS_INCLUDE_LEN))
		{
			if (0u < DataSize)
			{
				debug_infor_printf((const)"\CI_SYSTEM_PARAMETER_DATA_TYPE,CI_SYSTEM_ZSPKS_INCLUDE_LEN,len %d not equal to fs", CI_SYSTEM_ZSPKS_INCLUDE_LEN);
				DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software, CI_DEVICE_TYPE_FS_TABLE, (CI_SYSTEM_PARAMETER_DATA_TYPE << 8u) + CI_SYSTEM_ZSPKS_INCLUDE_LEN, PRINT_ONCE);
				rtnValue = 0U;
			}

		}
		else
		{
			RowDatalen = (UINT16)(DataSize / CI_SYSTEM_ZSPKS_INCLUDE_LEN);
			for (ii = 0u; ii < RowDatalen; ii++)
			{
				totalSpksId = ShortFromChar(pDataAddr);/*总SPKS id*/
				pDataAddr += 2u;
				wSpksSum = GetSpksSum();
				for (jj = 0u; jj < wSpksSum; jj++)
				{
					spksId = GetSpksIdByIndex(jj);
					if (spksId == totalSpksId)
					{
						pSpksIncludeSpksIdBuf = GetSpksIncludeSpksIdBuf(spksId);
						if (NULL != pSpksIncludeSpksIdBuf)
						{
							includeSpksNum = PZDquTotalSpksWithSpksFromChar(pDataAddr, pSpksIncludeSpksIdBuf);
							SetSpksIncludeSpksNum(spksId, includeSpksNum);
						}
						break;
					}


				}

				pDataAddr += CI_SYSTEM_ZSPKS_INCLUDE_LEN - 2u;
			}
			rtnValue = 1u;
		}
	}

	return rtnValue;
}

/*********************************************
*函数功能：LINK配置数据结构体计算
*参数说明：pLink LINK结构体指针
pLinkScCfgDtStr LINK置数据结构体指针
*返回值：0，失败；1，成功
*创建 2022.3.8
*********************************************/
UINT8 LinkCfgDtStruFromDquLinkStr(DSU_LINK_STRU* pLink, LinkDataConfigStru* pLinkScCfgDtStr)
{
	UINT8 rtnvalue = 0U;
	UINT16 i = 0U;

	/*入口参数防护*/
	if ((NULL == pLink) || (NULL == pLinkScCfgDtStr))
	{
		/*返回失败*/
		rtnvalue = 0U;
	}
	else
	{
		rtnvalue = 1U;

		/*直接从LINK表中获取*/
		pLinkScCfgDtStr->wId = pLink->wId;
		pLinkScCfgDtStr->dwLength = pLink->dwLength;
		pLinkScCfgDtStr->wLinkLine = pLink->wLinkLine;
		pLinkScCfgDtStr->wOrgnPointType = pLink->wOrgnPointType;
		pLinkScCfgDtStr->wOrgnPointId = pLink->wOrgnPointId;
		pLinkScCfgDtStr->wOrgnJointMainLkId = pLink->wOrgnJointMainLkId;
		pLinkScCfgDtStr->wOrgnJointSideLkId = pLink->wOrgnJointSideLkId;
		pLinkScCfgDtStr->wTmnlPointType = pLink->wTmnlPointType;
		pLinkScCfgDtStr->wTmnlPointId = pLink->wTmnlPointId;
		pLinkScCfgDtStr->wTmnlJointMainLkId = pLink->wTmnlJointMainLkId;
		pLinkScCfgDtStr->wTmnlJointSideLkId = pLink->wTmnlJointSideLkId;
		pLinkScCfgDtStr->wManageTioc = pLink->wManagePhysicalCI;
		pLinkScCfgDtStr->chLogicLineRelation = pLink->wLinkLogicDirUpAndDown;
		pLinkScCfgDtStr->chLogicDirChanged = pLink->wLogicDirChanged;
		pLinkScCfgDtStr->chRelPhySecIsAGorBG = LINK_REL_PHYSEC_IS_DEFAULT;  /*先初始化为非AG非BG*/
		pLinkScCfgDtStr->wLinkSpecialEa = 0U;  /*LINK特殊防护区域属性*/

		for (i = 0u; i < dsuDataLenStru.wStationLen; i++)
		{
			if (pLinkScCfgDtStr->wId == (dsuStaticHeadStru.pStationStru + i)->wLinkId)
			{
				pLinkScCfgDtStr->wBelongPlatformId = (dsuStaticHeadStru.pStationStru + i)->wATSStationId;

				/*link关联有停车区域，通过停车区域属性确定link关联的物理区段AG/BG属性*/
				if ((8U == ((dsuStaticHeadStru.pStationStru + i)->dwAttribute & 8U)) && (16U == ((dsuStaticHeadStru.pStationStru + i)->dwAttribute & 16U)))
				{
					/*停车区域属性第4位为1、第5位为1，表示库内休眠唤醒轨*/
					if (0U == ((dsuStaticHeadStru.pStationStru + i)->dwAttribute & 32U))
					{
						pLinkScCfgDtStr->chRelPhySecIsAGorBG = LINK_REL_PHYSEC_IS_AG;  /*停车区域属性第6位为0，表示AG*/
					}
					else
					{
						pLinkScCfgDtStr->chRelPhySecIsAGorBG = LINK_REL_PHYSEC_IS_BG;  /*停车区域属性第6位为1，表示BG*/
					}
				}
				else
				{
					/*非库线休眠唤醒轨，不处理*/
				}
			}

		}

		if ((LINK_TGEVACUATEDIR_UP == pLink->wLinkTG_EvacuateDir) || (LINK_TGEVACUATEDIR_DOWN == pLink->wLinkTG_EvacuateDir) || (LINK_TGEVACUATEDIR_ALL == pLink->wLinkTG_EvacuateDir))
		{
			pLinkScCfgDtStr->chLinkTgEvacuateDir = pLink->wLinkTG_EvacuateDir;
		}
		else
		{
			rtnvalue = 0U;
		}

		if (1U == rtnvalue)
		{
			if ((LINK_LINXIAN_YES == pLink->wLinxian) || (LINK_LINXIAN_NO == pLink->wLinxian))
			{
				pLinkScCfgDtStr->chLinkLinXian = pLink->wLinxian;
			}
			else
			{
				rtnvalue = 0U;
			}
		}
	}
	return rtnvalue;
}

/*********************************************
*函数功能：初始化LINK配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*创建 2022.3.8
*********************************************/
UINT8 LinkConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0U;
	UINT8 callFun = 0U;
	UINT16 i = 0U;

	callFun = dfsEmapInit(FSName);

	/*电子地图初始化失败，函数失败退出*/
	if (0U == callFun)
	{
		rtnvalue = 0U;
	}
	else
	{
		rtnvalue = 1U;
	}

	if (1U == rtnvalue)
	{
		dquCICfgDtStr.LinkCfgDtStrLen = dsuDataLenStru.wLinkLen;
		for (i = 0U; i < dsuDataLenStru.wLinkLen; i++)
		{
			if (LINK_SUM_MAX > i)
			{
				rtnvalue = LinkCfgDtStruFromDquLinkStr(dsuStaticHeadStru.pLinkStru + i, &dquCICfgDtStr.LinkCfgDtStr[i]);
			}
			else
			{
				rtnvalue = 0U;
			}

			if (0U == rtnvalue)
			{
				break;
			}
			else
			{
				; /*继续执行*/
			}
		}
	}
	else
	{
		; 
	}

	if (1U == rtnvalue)
	{
		for (i = 0U; i < dsuDataLenStru.wLinkLen; i++)
		{
			if (LINK_SUM_MAX > i)
			{
				rtnvalue = AgLinkExistRelCGFlagCalc(&dquCICfgDtStr.LinkCfgDtStr[i]);
				rtnvalue &= BGLinkRelAGLinkCal(&dquCICfgDtStr.LinkCfgDtStr[i]);
			}
			else
			{
				rtnvalue = 0U;
			}

			if (0U == rtnvalue)
			{
				break;
			}
			else
			{
				; /*继续执行*/
			}
		}
	}
	else
	{
		;
	}

	return rtnvalue;
}

/*********************************************
*函数功能：计轴器配置数据结构体计算
*参数说明：pAxis 计轴器结构体指针
pAxisCfgDtStr 计轴器配置数据结构体指针
*返回值：0，失败；1，成功
*创建 2022.3.11
*********************************************/
UINT8 AxisCfgDtStruFromDquAxisStr(DSU_AXLE_STRU* pAxis, AxisConfigStru* pAxisCfgDtStr)
{
	UINT8 rtnvalue = 0u;

	/*入口参数防护*/
	if ((NULL == pAxis) || (NULL == pAxisCfgDtStr))
	{
		/*返回失败*/
		return 0u;
	}

	/*直接从计轴器表中获取*/
	pAxisCfgDtStr->wId = pAxis->wId;
	pAxisCfgDtStr->dwAxleKilo = pAxis->dwAxleKilo;
	pAxisCfgDtStr->wType = pAxis->wType;
	pAxisCfgDtStr->chKiloType = pAxis->dwAxleKiloPlueMinusSign;
	pAxisCfgDtStr->wLkId = pAxis->wLkId;
	pAxisCfgDtStr->dwLkOfst = pAxis->dwLkOfst;

	rtnvalue = 1u;
	return rtnvalue;
}

/*********************************************
*函数功能：初始化计轴器配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*创建 2022.3.11
*********************************************/
UINT8 AxisConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i = 0u;

	callFun = dfsEmapInit(FSName);

	/*电子地图初始化失败，函数失败退出*/
	if (0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.AxisCfgDtStrLen = dsuDataLenStru.wAxlecounterLen;
		for (i = 0u; i < dsuDataLenStru.wAxlecounterLen; i++)
		{
			if (i >= AXIS_NUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			rtnvalue &= AxisCfgDtStruFromDquAxisStr(dsuStaticHeadStru.pAxleStru + i, &dquCICfgDtStr.AxisCfgDtStr[i]);
		}
	}

	return rtnvalue;
}

/*
功能描述: 初始化分界点表设备配置数据结构体(对外结构体)
输入参数:	CHAR * FSName 数据文件名指针
输出参数:	无
返回值:	0 失败
1 成功
*/
UINT8 CutoffPointConfigDataStructInit(CHAR * FSName)
{
	UINT8* pDataAddr = NULL;         		/*数据地址*/
	UINT32 DataSize = 0u;          		/*数据大小（字节数）*/
	UINT16 i = 0u;						/*循环变量*/
	UINT8 retVal = 0u;				/*返回值*/
	UINT8 dquGetConfDataRetVal = 0u;	/*获取配置数据函数返回值*/

	/*读取非本线路设备数据*/
	dquGetConfDataRetVal = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_CUTOFF_POINT_ID, &pDataAddr, &DataSize);

	if (1u == dquGetConfDataRetVal)
	{
		if (0u != DataSize)
		{
			if (0u == (DataSize % CI_SYSTEM_CI_CUTOFF_POINT_LEN))
			{
				/* 清除dqu中数据 */
				(void)CommonMemSet(dquCICfgDtStr.stCutoffPointCfgDt, (UINT32)sizeof(dquCICfgDtStr.stCutoffPointCfgDt), 0, (UINT32)sizeof(dquCICfgDtStr.stCutoffPointCfgDt));

				/*求得个数*/
				dquCutoffPointDataLen = (UINT16)(DataSize / CI_SYSTEM_CI_CUTOFF_POINT_LEN);
				pstDquCutoffPointData = (DquCutoffPointStruct *)MyNew((UINT32)(dquCutoffPointDataLen * sizeof(DquCutoffPointStruct)));

				if (NULL == pstDquCutoffPointData)
				{
					

					retVal = 0u;
				}
				else
				{
					dquCICfgDtStr.wCfgCfgDtLen = dquCutoffPointDataLen;
					retVal = 1u;
					for (i = 0u; i < dquCutoffPointDataLen; i++)
					{
						retVal &= PZDquCutoffPointDataFromChar(pDataAddr, pstDquCutoffPointData + i);

						pDataAddr += CI_SYSTEM_CI_CUTOFF_POINT_LEN;

						retVal &= ReadDquCutoffPointDataToConfig(pstDquCutoffPointData + i, &dquCICfgDtStr.stCutoffPointCfgDt[i]);
					}

				}
			}
			else
			{
				debug_infor_printf((const)"\nCI_CONFIG_DATA,CUT_OFF_DATA,len %d not equal to fs", CI_SYSTEM_CI_CUTOFF_POINT_LEN);
				DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software, CI_DEVICE_TYPE_FS_TABLE, ((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE << 8u) + CI_SYSTEM_CI_CUTOFF_POINT_ID, PRINT_ONCE);

				retVal = 0u;
			}
		}
		else
		{
			
			retVal = 1u;
		}
	}
	else
	{
		retVal = 0u;
	}

	return retVal;
}

/*
功能描述: 将分界点数据填充至DquCfg中分界点数据内容中
输入参数:	DquCutoffPointStruct *pCutoffPointDevData  分界点设备数据
输出参数:	CfpConfigStru *pstCutoffPointData DquCfg 分界点设备数据内容指针
返回值:	0 失败
1 成功
*/
static UINT8 ReadDquCutoffPointDataToConfig(DquCutoffPointStruct* pCutoffPointDevData, CfpConfigStru* pstCutoffPointData)
{
	UINT8 retVal = 0u;
	UINT8 chLocalCiId = 0U;
	UINT32 dwLinkOff = 0U;
	UINT16 wLinkId = 0U;
	UINT16 wLinkIdBelongCiId = 0U;/*分界点LINK所属控区ID*/
	UINT16 ii = 0U;

	if ((NULL != pCutoffPointDevData) && (NULL != pstCutoffPointData))
	{
		retVal = 1U;
		pstCutoffPointData->wPointId = pCutoffPointDevData->wCutoffPointId;
		pstCutoffPointData->wLinkId = pCutoffPointDevData->wCutoffPointLinkId;
		pstCutoffPointData->dwOffset = pCutoffPointDevData->dwCutoffPointLinkOff;

		chLocalCiId = GetSystemParaLocalCiId();

		wLinkId = pCutoffPointDevData->wCutoffPointLinkId;
		dwLinkOff = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wLinkId]].dwLength;
		wLinkIdBelongCiId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wLinkId]].wManagePhysicalCI;

		if (chLocalCiId == wLinkIdBelongCiId)
		{
			/*分界点link所属控区若为本控区，本控区分界点内方第一link即为该link*/
			pstCutoffPointData->wInFirstLink = wLinkId;
		}
		else
		{
			/*若link不为本控区link参考offset,若offset为0，link逻辑反方向相邻link为分界点内方第一link
			  若link不为本控区link参考offset,若offset不为0，link逻辑正方向相邻link为分界点内方第一link*/
			if (0U == pstCutoffPointData->dwOffset)
			{
				pstCutoffPointData->wInFirstLink = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wLinkId]].wOrgnJointMainLkId;
			}
			else if (dwLinkOff == pstCutoffPointData->dwOffset)
			{
				pstCutoffPointData->wInFirstLink = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wLinkId]].wTmnlJointMainLkId;
			}
			else
			{
				pstCutoffPointData->wInFirstLink = 0U;
				/*配置数据有误*/
				retVal = 0U;
			}
		}

		if (chLocalCiId == (UINT8)pCutoffPointDevData->wRelativeTioc1)
		{
			pstCutoffPointData->wLocalTiocId = chLocalCiId;
			pstCutoffPointData->wOtherTiocId = pCutoffPointDevData->wRelativeTioc2;
			retVal = EnsureCfpLocDir(pstCutoffPointData);  /* 确定本控区所处分界点的方向 */
		}
		else if (chLocalCiId == (UINT8)pCutoffPointDevData->wRelativeTioc2)
		{
			pstCutoffPointData->wLocalTiocId = chLocalCiId;
			pstCutoffPointData->wOtherTiocId = pCutoffPointDevData->wRelativeTioc1;
			retVal = EnsureCfpLocDir(pstCutoffPointData);  /* 确定本控区所处分界点的方向 */
		}
		else
		{
			pstCutoffPointData->wLocalTiocId = pCutoffPointDevData->wRelativeTioc2;
			pstCutoffPointData->wOtherTiocId = pCutoffPointDevData->wRelativeTioc1;/*无关分界点*/
			pstCutoffPointData->chLocDir = CI_SYSTEM_DIRECTION_NONE;
		}

		/*初始化分界点关联的相邻RC信号机*/
		pstCutoffPointData->wRelAdjacentRcSignalId = 0U;
		
		for (ii = 0U; ii < dquCICfgDtStr.SgnlCfgDtStrLen; ii++)
		{
			if ((chLocalCiId == pstCutoffPointData->wLocalTiocId) && (chLocalCiId != dquCICfgDtStr.SgnlCfgDtStr[ii].BelongCiId) && (pstCutoffPointData->wInFirstLink  == dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId))
			{
				pstCutoffPointData->wRelAdjacentRcSignalId = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId;  /*信号机非本控区，且信号机外方第一link为分界点内方第一link*/
				break;
			}
			else
			{
				/*不处理*/
			}
		}
	}
	else
	{
		retVal = 0u;
	}

	return retVal;
}

/*
功能描述: 初始化联络线表设备配置数据结构体(对外结构体)
输入参数:	CHAR * FSName 数据文件名指针
输出参数:	无
返回值:	0 失败
1 成功
*/
UINT8 LinkLineConfigDataStructInit(CHAR * FSName)
{
	UINT16 i = 0U;
	UINT8 retVal = 0U;  /*返回值*/

	retVal = dquCbtcConfigDataInit(FSName);  /*初始化系统配置数据*/

	if (0U != retVal)
	{
		dquCICfgDtStr.wLinkLineCfgDtLen = cbtcConfigDataStru.BoundaryAxleInfoLen;

		if (LINK_LINE_SUM_MAX >= dquCICfgDtStr.wLinkLineCfgDtLen)
		{
			/* 清除dqu中数据 */
			(void)CommonMemSet(dquCICfgDtStr.LinkLineCfgDtStr, (UINT32)sizeof(dquCICfgDtStr.LinkLineCfgDtStr), 0u, (UINT32)sizeof(dquCICfgDtStr.LinkLineCfgDtStr));

			for (i = 0U; i < dquCICfgDtStr.wLinkLineCfgDtLen; i++)
			{
				retVal = ReadDquLinkLineDataToConfig(cbtcConfigDataStru.cbtcBoundaryAxleInfo + i, &dquCICfgDtStr.LinkLineCfgDtStr[i]);

				if (1U == retVal)
				{
					/*继续读取*/
				}
				else
				{
					break;  /*停止遍历，返回0*/
				}
			}			
		}
		else
		{
			debug_infor_printf((const)"\nInit Error! LINK_LINE_DATA Len %d Exceed Max!\n", dquCICfgDtStr.wLinkLineCfgDtLen);

			retVal = 0U;
		}
	}
	else
	{
		/*系统配置数据初始化失败，返回0*/
	}

	return retVal;
}

/*
* 功能描述: 将系统配置联络线数据填充至DquCfg中联络线数据内容中
* 输入参数:	CBTC_BOUNDARY_AXLE_CONFIG_STRU* pCbtcBoundaryAxleInfo  系统配置联络线设备数据
* 输出参数:	LinkLineStru *pDstLinkLineData DquCfg 联络线设备数据内容指针
* 返回值  :	0 失败
*           1 成功
* Modified By LQ 2023.11.14
*/
UINT8 ReadDquLinkLineDataToConfig(CBTC_BOUNDARY_AXLE_CONFIG_STRU* pCbtcBoundaryAxleInfo, LinkLineStru *pDstLinkLineData)
{
	UINT8 retVal = 0U;

	if ((NULL != pCbtcBoundaryAxleInfo) && (NULL != pDstLinkLineData))
	{
		retVal = 1U;
		pDstLinkLineData->wId = pCbtcBoundaryAxleInfo->wIndex;
		pDstLinkLineData->wAxisSecId = pCbtcBoundaryAxleInfo->wAxleSecId;
		pDstLinkLineData->cLinkLineType = pCbtcBoundaryAxleInfo->cLinkLineType;
		pDstLinkLineData->cInType = pCbtcBoundaryAxleInfo->cEntranceType;
		pDstLinkLineData->cStorageLineType = pCbtcBoundaryAxleInfo->cStorageLineType;
	}
	else
	{
		retVal = 0U;
	}

	return retVal;
}

/*********************************************
*函数功能：初始化倒切设备配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8  ReverseCutConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i = 0u;

	if (NULL != FSName)
	{

		callFun = InitRelay_ReverseCutStru(FSName);
	}
	else
	{
		rtnvalue = 0u;
	}
	/*电子地图初始化失败，函数失败退出*/
	if (0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.wReverseCutCfgLen = RelayDataLen.RelayReverseCutStrLen;
		for (i = 0u; i<RelayDataLen.RelayReverseCutStrLen; i++)
		{
			if (i >= REVERSE_CUT_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			else
			{
				;
			}

			rtnvalue &= ReverseCutCfgDtStruFromDquStr(RelayData.pRelayReverseCutStr + i, &dquCICfgDtStr.stReverseCutCfgDtStr[i]);
		}
	}
	else
	{
		;
	}

	return rtnvalue;
}

/*********************************************
*函数功能：倒切设备配置数据结构体计算
*参数说明：pLogicSgmt逻辑区段结构体指针
pLgScCfgDtStr逻辑区段配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 ReverseCutCfgDtStruFromDquStr(Relay_ReverseCutStruct* pReverseCutRelay, ReverseCutCfgDataStru* pReverseCutCfgDtStr)
{
	UINT8 rtnvalue = 0u;
	UINT16 jj = 0U;

	/*入口参数防护*/
	if ((NULL != pReverseCutRelay) && (NULL != pReverseCutCfgDtStr))
	{

		pReverseCutCfgDtStr->wId = pReverseCutRelay->wReverseCutRelayId;
		for (jj = 0u; jj<RelayDataLen.RelayCfgDtStrLen; jj++)
		{
			if (pReverseCutRelay->wReverseCutRelayId == RelayData.pRelayCfgDtStr[jj].RelayId)
			{
				pReverseCutCfgDtStr->chBelongCiId = RelayData.pRelayCfgDtStr[jj].BelongCiId;
				break;
			}
			else
			{
				;
			}
		}
		pReverseCutCfgDtStr->wReverseRelayId = pReverseCutRelay->wReverseCutRelayId;
		rtnvalue = 1u;
	}
	else
	{
		/*返回失败*/
		return 0u;
	}
	return rtnvalue;
}

/*********************************************
*函数功能：初始化TIOCATS设备网关配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8  GatewayConfigDataStructInit(CHAR * FSName)
{

	UINT8* pDataAddr = NULL;         		/*数据地址*/
	UINT32 DataSize = 0u;          		/*数据大小（字节数）*/
	UINT16 i = 0u;						/*循环变量*/
	UINT16 j = 0U;
	UINT8 retVal = 0u;				/*返回值*/
	UINT8 dquGetConfDataRetVal = 0u;	/*获取配置数据函数返回值*/
	TransmitRelationDataStruct* pTrsmtRlsDtStr = NULL;
										/*读取非本线路设备数据*/
	if (NULL != FSName)
	{
		dquGetConfDataRetVal = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_GATEWAY_DEVICE_ID, &pDataAddr, &DataSize);

		if (1u == dquGetConfDataRetVal)
		{
			if (0u != DataSize)
			{
				if (0u == (DataSize % CI_SYSTEM_CI_GATEWAY_DEVICE_LEN))
				{
					/* 清除dqu中数据 */

					/*求得个数*/
					dquGatewayDeviceDataLen = (UINT16)(DataSize / CI_SYSTEM_CI_GATEWAY_DEVICE_LEN);
					pstDquGatewayDeviceData = (DquGatewayDeviceStruct *)MyNew((UINT32)(dquGatewayDeviceDataLen * sizeof(DquGatewayDeviceStruct)));
					(void)CommonMemSet(pstDquGatewayDeviceData, (UINT32)(dquGatewayDeviceDataLen * sizeof(DquGatewayDeviceStruct)), 0, (UINT32)(sizeof(dquCICfgDtStr.stCutoffPointCfgDt)));

					if (NULL == pstDquGatewayDeviceData)
					{
						retVal = 0u;
					}
					else
					{
						for (i = 0u; i < dquGatewayDeviceDataLen; i++)
						{
							(void)PZDquGatewayDeviceDataFromChar(pDataAddr, pstDquGatewayDeviceData + i);

							pDataAddr += CI_SYSTEM_CI_GATEWAY_DEVICE_LEN;
							for (j = 0U; j < dquCICfgDtStr.TrsmtRlsDtStrLen; j++)
							{
								if ((pstDquGatewayDeviceData[i].wTiocId == dquCICfgDtStr.TrsmtRlsDtStr[j].CiId)
									&& (CI_SYSTEM_TYPE_ATS == dquCICfgDtStr.TrsmtRlsDtStr[j].SystemType))
								{
									pTrsmtRlsDtStr = &dquCICfgDtStr.TrsmtRlsDtStr[j];

									(void)ReadGatewayDeviceCfgDtStru(pstDquGatewayDeviceData + i, pTrsmtRlsDtStr);
									break;
								}
							}
						}

						retVal = 1u;
					}
				}
				else
				{
					debug_infor_printf((const)"\nCI_CONFIG_DATA,CUT_OFF_DATA,len %d not equal to fs", CI_SYSTEM_CI_CUTOFF_POINT_LEN);
					DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software, CI_DEVICE_TYPE_FS_TABLE, (CI_SYSTEM_PARAMETER_DATA_TYPE << 8) + CI_SYSTEM_CI_GATEWAY_DEVICE_ID, PRINT_ONCE);

					retVal = 0u;
				}
			}
			else
			{

				retVal = 1u;
			}
		}
		else
		{
			retVal = 0u;
		}
	}
	else
	{
		retVal = 0u;
	}

	return retVal;
}

/*********************************************
*函数功能：倒切设备配置数据结构体计算
*参数说明：pLogicSgmt逻辑区段结构体指针
pLgScCfgDtStr逻辑区段配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 ReadGatewayDeviceCfgDtStru(DquGatewayDeviceStruct* pGatewayDeviceRelay, TransmitRelationDataStruct* pTrsmtRlsDtStr)
{
	UINT8 rtnvalue = 0u;

	/*入口参数防护*/
	if ((NULL != pGatewayDeviceRelay) && (NULL != pTrsmtRlsDtStr))
	{
		pTrsmtRlsDtStr->wGatewayComputerId = pGatewayDeviceRelay->wGatewayDeviceId;
		
		rtnvalue = 1u;
	}
	else
	{
		/*返回失败*/
		return 0u;
	}
	return rtnvalue;
}

/*********************************************
*函数功能：初始化防护区域配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 EaConfigDataStructInit(CHAR * FSName)
{

	UINT8 rtnvalue = 0u;
	UINT8 callFun = 0u;
	UINT16 i = 0u;

	callFun = dfsEmapInit(FSName);

	/*电子地图初始化失败，函数失败退出*/
	if (0u == callFun)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}

	if (1u == rtnvalue)
	{
		dquCICfgDtStr.wEaCfgLen = dsuDataLenStru.wEaLen;
		for (i = 0u; i < dsuDataLenStru.wEaLen; i++)
		{
			if (i >= EA_CFG_SUM_MAX)
			{
				rtnvalue = 0u;
				break;
			}
			rtnvalue &= EaConfigDataStruFromDquEaStr(dsuStaticHeadStru.pEaStru + i, &dquCICfgDtStr.szEaCfgDtStr[i]);
		}
	}

	return rtnvalue;
}

/*********************************************
*函数功能：防护区域配置数据结构体计算
*参数说明：pEa 防护区域结构体指针
pEaCfgDtStr 防护区域置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 EaConfigDataStruFromDquEaStr(DSU_EMAP_EA_STRU* pEa, EaConfigStru* pEaCfgDtStr)
{
	UINT8 rtnvalue = 0u;

	/*入口参数防护*/
	if ((NULL == pEa) || (NULL == pEaCfgDtStr))
	{
		/*返回失败*/
		return 0u;
	}

	/*直接从LINK表中获取*/
	pEaCfgDtStr->wId = pEa->wId;
	pEaCfgDtStr->chStartLinkNum = pEa->chStartLinkNum;
	(void)CommonMemCpy(pEaCfgDtStr->szStartLinkId, (UINT32)(sizeof(UINT16) * EA_BD_LINK_SUM_MAX), pEa->szStartLinkId, (UINT32)(sizeof(UINT16) * EA_BD_LINK_SUM_MAX));
	(void)CommonMemCpy(pEaCfgDtStr->szStartLinkDir, (UINT32)(sizeof(UINT8) * EA_BD_LINK_SUM_MAX), pEa->szStartLinkDir, (UINT32)(sizeof(UINT8) * EA_BD_LINK_SUM_MAX));
	pEaCfgDtStr->chEndLinkNum = pEa->chEndLinkNum;
	(void)CommonMemCpy(pEaCfgDtStr->szEndLinkId, (UINT32)(sizeof(UINT16) * EA_BD_LINK_SUM_MAX), pEa->szEndLinkId, (UINT32)(sizeof(UINT16) * EA_BD_LINK_SUM_MAX));
	(void)CommonMemCpy(pEaCfgDtStr->szEndLinkDir, (UINT32)(sizeof(UINT8) * EA_BD_LINK_SUM_MAX), pEa->szEndLinkDir, (UINT32)(sizeof(UINT8) * EA_BD_LINK_SUM_MAX));

	rtnvalue = 1u;
	return rtnvalue;
}
/*********************************************
*函数功能：解析OC 道岔配置表数据
*参数说明：pDataAddr 数据地址；
*返回值：0，失败；1，成功
*备注：cgh-合并CID-2539-5：：修改初始化《OC_配置数据表》中“物理区段模块配置表”、“信号机模块配置表”、“道岔模块配置表”的初始化方式，和其他表格的初始化方式一致
*********************************************/
void R_OCSwitchConfigDataFromChar(UINT8* pDataAddr)
{
	UINT8* pData = NULL;
	UINT16 SwitchIdTemp = 0u;
	if (NULL == pDataAddr)
	{
		; /*入口参数为空，不进行解析操作*/
	}
	else
	{
		pData = pDataAddr;
		SwitchIdTemp = ShortFromChar(pData);

		if (SwitchIdTemp < SWITCH_SUM_MAX)
		{
			/*道岔ID--2字节*/
			dquCICfgDtStr.OCSwitchCfgStr[SwitchIdTemp].SwitchId = SwitchIdTemp;
			pData += 2u;

			/*所属OC--2字节*/
			dquCICfgDtStr.OCSwitchCfgStr[SwitchIdTemp].BelongOcId = ShortFromChar(pData);
			pData += 2u;
		}
	}
}

/*********************************************
*函数功能：主进路及子进路相关数据初始化
*参数说明：pRouteCfgDtStr进路配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 RouteMainProConfigDataInit(RouteConfigDataStruct* RouteCfgDtStr, RouteConfigDataStruct* pRouteCfgDtStr)
{
	UINT16 i = 0U, j = 0U, k = 0U;
	UINT8 rtnvalue = 0U;
	UINT8 chMainIncSubLogSum = 0U;/*子进路属性进路的逻辑区段包含在主进路逻辑区段范围内的数目*/
	UINT16 wMaybeSubIdBuf[ROUTE_SUB_INCLUDE_SUM_MAX] = { 0U };/*可能是主进路的子进路ID*/
	UINT8 chMaybeSubIdIndex = 0U;/*可能是主进路的子进路ID索引*/
	UINT8 chMainIncSubIndex = 0U;/*主进路包含子进路的ID索引*/
	UINT16 wMaybeMainIdBuf[ROUTE_MAYBE_BELONG_SUM_MAX] = { 0U };/*可能是子进路的主进路ID*/
	UINT8 chMaybeMainIdIndex = 0U;/*可能是子进路的主进路ID索引*/
	UINT8 chSubBelMainIndex = 0U;/*子进路所属主进路的ID索引*/
	LOD_STRU strCurRouteSigPoint = { 0U };/*当前进路内方第一LINK*/
	LOD_STRU strFindRouteSigPoint = { 0U };/*遍历进路内方第一LINK*/
	UINT8 chDirChangeNum = 0U;/*遍历进路内方第一LINK和当前进路内方第一LINK之间方向变化点数目*/
	DSU_ROUTE_STRU* pDsuRouteStr = NULL;
	UINT8 chMaxCheckFail = CI_SUCCESS;

	/*主进路包含子进路数目及子进路所属主进路数目初始化为0*/
	pRouteCfgDtStr->MainOrSubData.RouteBelMainSum = 0U;
	pRouteCfgDtStr->MainOrSubData.RouteSubSum = 0U;

	/*进路属性初始化赋值为普通进路*/
	pRouteCfgDtStr->MainOrSubData.MainRouteProperty = ROUTE_INIT_PROPERTY;

	for (i = 0U; i < dquCICfgDtStr.RouteCfgDtStrLen; i++)
	{/*遍历所有进路，若遍历的进路包含的所有的逻辑区段都在当前进路中包含，则当前进路属性为主进路属性，对应遍历的进路为子进路*/
		for (j = 0U; j < RouteCfgDtStr[i].RouteInLogTrackSum; j++)
		{/*遍历进路包含的所有的逻辑区段*/
			for (k = 0U; k < pRouteCfgDtStr->RouteInLogTrackSum; k++)
			{/*遍历当前进路的逻辑区段*/
				if (pRouteCfgDtStr->RouteInLogTrackIdBuf[k] == RouteCfgDtStr[i].RouteInLogTrackIdBuf[j])
				{
					chMainIncSubLogSum++;
				}
				else
				{
					/*继续检查*/
				}
			}
		}

		if ((RouteCfgDtStr[i].RouteInLogTrackSum == chMainIncSubLogSum) || (pRouteCfgDtStr->RouteInLogTrackSum == chMainIncSubLogSum))
		{
			pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[pRouteCfgDtStr->RouteId];
			strCurRouteSigPoint.Lnk = pDsuRouteStr->wOrgnLkId;
			strCurRouteSigPoint.Off = 0U;

			pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[RouteCfgDtStr[i].RouteId];
			strFindRouteSigPoint.Lnk = pDsuRouteStr->wOrgnLkId;
			strFindRouteSigPoint.Off = 0U;

			chDirChangeNum = GetDirChangeNumBtwPoints(&strCurRouteSigPoint, &strFindRouteSigPoint);  /*查询当前link到信号机防护link间的方向变化点*/

			if (((RouteCfgDtStr[i].RouteDirection == pRouteCfgDtStr->RouteDirection) && (0U == chDirChangeNum))
				|| ((RouteCfgDtStr[i].RouteDirection != pRouteCfgDtStr->RouteDirection)
					&& (1U == chDirChangeNum)))
			{
				/*进路锁闭方向一致（没有方向变化点或两个进路均有方向变化点(如果都有方向变化点，2条进路内方第一LINK之间方向变化点数目必须为0，排除方向变化点导致的进路方向一致，但不是分段进路关系的情况)）
				或者 锁闭方向不一致但进路内方存在方向变化点（2条进路内方第一LINK之间方向变化点数目必须为1，排除不是分段进路关系的情况）*/
				if ((pRouteCfgDtStr->RouteInLogTrackSum) > (RouteCfgDtStr[i].RouteInLogTrackSum))
				{/*当前进路包含遍历进路的所有逻辑区段，则当前进路为主进路属性（下一步需要进一步区分直通还是折返）*/
					if (ROUTE_SUB_INCLUDE_SUM_MAX > chMaybeSubIdIndex)
					{
						wMaybeSubIdBuf[chMaybeSubIdIndex] = RouteCfgDtStr[i].RouteId;
						chMaybeSubIdIndex++;
					}
					else
					{
						chMaxCheckFail = CI_ERROR;/*停止 防止溢出*/
					}
				}
				else if ((pRouteCfgDtStr->RouteInLogTrackSum) < (RouteCfgDtStr[i].RouteInLogTrackSum))
				{/*当前进路逻辑区段被遍历的进路包含，则当前进路为子进路属性（下一步需要进一步区分直通还是折返）*/					
					if (ROUTE_MAYBE_BELONG_SUM_MAX > chMaybeMainIdIndex)
					{
						wMaybeMainIdBuf[chMaybeMainIdIndex] = RouteCfgDtStr[i].RouteId;
						chMaybeMainIdIndex++;
					}
					else
					{
						chMaxCheckFail = CI_ERROR;/*停止 防止溢出*/
					}
				}
				else
				{
					/*无操作，不对进路属性进行赋值*/
				}
			}
			else
			{
				/*其它不同即跳过*/
			}	
		}
		chMainIncSubLogSum = 0U;
	}
	if (CI_SUCCESS == chMaxCheckFail)
	{
		/*无论当前进路是主进路还是子进路，始端信号机一定是分段属性*/
		for (i = 0U; i < chMaybeSubIdIndex; i++)
		{
			/*从可能是主进路的子进路数据中筛选出最终满足条件的子进路*/
			if (pRouteCfgDtStr->StartSignalId == RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].StartSignalId)
			{
				/*主进路对应的第一个子进路，始端信号机相同*/
				if (SIGNAL_FENDUAN_YES == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].EndSignalId]].signalFenDuanAttr)
				{
					if (ROUTE_SUB_INCLUDE_SUM_MAX > chMainIncSubIndex)
					{
						/*第一个子进路终端信号机必须为分段属性*/
						pRouteCfgDtStr->MainOrSubData.RouteSubIdBuf[chMainIncSubIndex] = wMaybeSubIdBuf[i];
						chMainIncSubIndex++;
					}
					else
					{
						chMaxCheckFail = CI_ERROR;
					}
				}
				else
				{
					; /*不处理*/
				}
			}
			else if (pRouteCfgDtStr->EndSignalId != RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].EndSignalId)
			{
				/*主进路对应的非最后一个子进路:子进路终端信号机与主进路终端信号机不一致*/
				if (SIGNAL_FENDUAN_YES == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].StartSignalId]].signalFenDuanAttr)
				{
					if (ROUTE_SUB_INCLUDE_SUM_MAX > chMainIncSubIndex)
					{
						/*待确定子进路始端信号机必须为分段属性，即为主进路最终确定的其中一条子进路*/
						pRouteCfgDtStr->MainOrSubData.RouteSubIdBuf[chMainIncSubIndex] = wMaybeSubIdBuf[i];
						chMainIncSubIndex++;
					}
					else
					{
						chMaxCheckFail = CI_ERROR;
					}
				}
				else
				{
					; /*不处理*/
				}
			}
			else
			{
				/*主进路对应的最后一个子进路:子进路终端信号机与主进路终端信号机一致*/
				/*待确定子进路性质和主进路进路性质一致 并且待确定子进路始端信号必须为分段属性即为最终的子进路*/
				if ((pRouteCfgDtStr->ConfigRouteType == RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].ConfigRouteType)
					&& (SIGNAL_FENDUAN_YES == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].StartSignalId]].signalFenDuanAttr))
				{
					if (ROUTE_SUB_INCLUDE_SUM_MAX > chMainIncSubIndex)
					{
						pRouteCfgDtStr->MainOrSubData.RouteSubIdBuf[chMainIncSubIndex] = wMaybeSubIdBuf[i];
						chMainIncSubIndex++;
					}
					else
					{
						chMaxCheckFail = CI_ERROR;
					}
				}
				else
				{
					; /*主进路性质找不到相同性质的子进路*/
				}
			}
			if (0U < chMainIncSubIndex)
			{
				pRouteCfgDtStr->MainOrSubData.MainRouteProperty = ROUTE_MAIN_PROPERTY;
			}
			if (CI_ERROR == chMaxCheckFail)
			{
				break;
			}
		}

		for (i = 0U; i < chMaybeMainIdIndex; i++)
		{
			if ((SIGNAL_FENDUAN_NO == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeMainIdBuf[i]]].StartSignalId]].signalFenDuanAttr)
				&& (SIGNAL_FENDUAN_NO == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeMainIdBuf[i]]].EndSignalId]].signalFenDuanAttr)
				&& ((SIGNAL_FENDUAN_YES == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[pRouteCfgDtStr->StartSignalId]].signalFenDuanAttr)
					|| (SIGNAL_FENDUAN_YES == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[pRouteCfgDtStr->EndSignalId]].signalFenDuanAttr)))
			{
				/*如果是主进路，始终端信号机不具备分段属性；从可能是子进路的主进路数据中筛选出最终满足条件的主进路*/
				if (pRouteCfgDtStr->EndSignalId != RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeMainIdBuf[i]]].EndSignalId)
				{/*待确定主进路终端信号机与子进路终端信号机不一致，即为子进路最终确定的其中一条主进路*/
					if (ROUTE_MAIN_BELONG_SUM_MAX > chSubBelMainIndex)
					{
						pRouteCfgDtStr->MainOrSubData.RouteBelMainIdBuf[chSubBelMainIndex] = wMaybeMainIdBuf[i];
						chSubBelMainIndex++;
					}
					else
					{
						chMaxCheckFail = CI_ERROR;
					}
				}
				else
				{/*待确定主进路终端信号机与子进路终端信号机一致，则根据子进路进路性质选出进路性质一致的待确定主进路即为最终的主进路*/
					if (RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeMainIdBuf[i]]].ConfigRouteType == pRouteCfgDtStr->ConfigRouteType)
					{
						if (ROUTE_MAIN_BELONG_SUM_MAX > chSubBelMainIndex)
						{
							pRouteCfgDtStr->MainOrSubData.RouteBelMainIdBuf[chSubBelMainIndex] = wMaybeMainIdBuf[i];
							chSubBelMainIndex++;
						}
						else
						{
							chMaxCheckFail = CI_ERROR;
						}
					}
				}
			}
			if (0U < chSubBelMainIndex)
			{
				pRouteCfgDtStr->MainOrSubData.MainRouteProperty = ROUTE_SUB_PROPERTY;
			}
			if (CI_ERROR == chMaxCheckFail)
			{
				break;
			}
		}

		if (CI_ERROR == chMaxCheckFail)
		{
			rtnvalue = 0U;
			debug_infor_printf((const)"\n RouteMainProConfigDataInit Error:  Routeid:%d Sub or Main Route Over Max \n", pRouteCfgDtStr->RouteId);
		}
		else
		{
			pRouteCfgDtStr->MainOrSubData.RouteSubSum = chMainIncSubIndex;
			pRouteCfgDtStr->MainOrSubData.RouteBelMainSum = chSubBelMainIndex;
			rtnvalue = 1U;
		}
	}
	else
	{
		rtnvalue = 0U;
		debug_infor_printf((const)"\n RouteMainProConfigDataInit Error:  Routeid:%d _Maybe Sub or Main Route Over Max \n", pRouteCfgDtStr->RouteId);
	}
	return rtnvalue;
}

/*********************************************
*函数功能：逻辑区段关联进路相关数据初始化
*参数说明：pRouteCfgDtStr进路配置数据结构体指针   pLogCfgDtStr配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 LogRelateRouteDataInit(RouteConfigDataStruct* RouteCfgDtStr, LogicSectionConfigDataStruct* pLogCfgDtStr)
{
	UINT16 i = 0U;
	UINT16 j = 0U;
	UINT8 rtnvalue = 0U;
	UINT8 chMaxCheck = CI_SUCCESS;

	/*逻辑区段包含进路数目初始化为0*/
	pLogCfgDtStr->chRelateRouteSum = 0U;
	for (i = 0U; i < dquCICfgDtStr.RouteCfgDtStrLen; i++)
	{/*遍历所有进路,若包含此逻辑区段，即此进路为本逻辑区段关联进路*/
		for (j = 0; j < RouteCfgDtStr[i].RouteInLogTrackSum; j++)
		{
			if (RouteCfgDtStr[i].RouteInLogTrackIdBuf[j] == pLogCfgDtStr->LogicSectionId)
			{
				if (LOGSEC_RELATE_ROUTE_SUM_MAX > pLogCfgDtStr->chRelateRouteSum)
				{
					pLogCfgDtStr->wRelateRouteId[pLogCfgDtStr->chRelateRouteSum] = RouteCfgDtStr[i].RouteId;
					(pLogCfgDtStr->chRelateRouteSum)++;
				}
				else
				{
					chMaxCheck = CI_ERROR;
				}
				break;
			}
			if (CI_ERROR == chMaxCheck)
			{
				break;
			}
		}
		if (CI_ERROR == chMaxCheck)
		{
			break;
		}
	}
	if (CI_ERROR == chMaxCheck)
	{
		rtnvalue = 0U;
	}
	else
	{
		rtnvalue = 1U;
	}
	return rtnvalue;
}

/*********************************************
*函数功能：逻辑区段关联防护道岔相关数据初始化
*参数说明：pRouteCfgDtStr进路配置数据结构体指针   pLogCfgDtStr配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 LogRelateProSwDataInit(RouteConfigDataStruct* RouteCfgDtStr, LogicSectionConfigDataStruct* pLgScCfgDtStr)
{
	UINT8 rtnvalue = 1U;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT8 kk = 0U;
	UINT8 hh = 0U;
	UINT8 mm = 0U;
	UINT16 wProtectSwSum = 0U;/*逻辑区段关联防护道岔数量计数*/
	UINT16 wProtectSwId = 0U;/*逻辑区段关联防护道岔ID过渡变量*/
	UINT8 chProtectSwFlag = 0U;/*逻辑区段关联防护道岔去重标志*/
	UINT8 chMaxCheck = CI_SUCCESS;
	/*逻辑区段关联防护道岔计算*/
	pLgScCfgDtStr->chRelateProSwSum = 0U;
	for (ii = 0; ii < pLgScCfgDtStr->chLogsecSwitchSum; ii++)
	{/*遍历逻辑区段包含的所有道岔*/
		wProtectSwSum = dquCICfgDtStr.SwchCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[pLgScCfgDtStr->LogsecSwitchIdStru[ii].SwitchId]].wProtectSwitchNum;
		for (jj = 0; jj < wProtectSwSum; jj++)
		{/*遍历道岔对应的防护道岔*/
			wProtectSwId = dquCICfgDtStr.SwchCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[pLgScCfgDtStr->LogsecSwitchIdStru[ii].SwitchId]].wszProtectSwitchIdBuf[jj];
			chProtectSwFlag = 0U;
			for (kk = 0U; kk < pLgScCfgDtStr->chRelateRouteSum; kk++)
			{/*遍历逻辑区段关联的进路*/
				for (hh = 0U; hh < dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchSum; hh++)
				{/*查询逻辑区段关联进路，若进路包含该防护道岔，则逻辑区段关联防护道岔的位置与进路一致*/
					if (dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchStru[hh].ProtectSwitchId == wProtectSwId)
					{
						for (mm = 0U; mm < pLgScCfgDtStr->chRelateProSwSum; mm++)
						{/*关联防护道岔ID去重*/
							if ((pLgScCfgDtStr->wRelateProSwId[mm].SwitchId == dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchStru[hh].ProtectSwitchId)
								&& (pLgScCfgDtStr->wRelateProSwId[mm].SwitchPosition == dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchStru[hh].ProtectPosition))
							{
								chProtectSwFlag = 1U;
								break;
							}
						}
						if (1U != chProtectSwFlag)
						{/*当前防护道岔数组中不包含此ID才进行添加*/
							if (LOGSEC_RELATE_PRO_SW_SUM_MAX > pLgScCfgDtStr->chRelateProSwSum)
							{
								pLgScCfgDtStr->wRelateProSwId[pLgScCfgDtStr->chRelateProSwSum].SwitchId = dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchStru[hh].ProtectSwitchId;
								pLgScCfgDtStr->wRelateProSwId[pLgScCfgDtStr->chRelateProSwSum].SwitchPosition = dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchStru[hh].ProtectPosition;
								(pLgScCfgDtStr->chRelateProSwSum)++;
							}
							else
							{
								chMaxCheck = CI_ERROR;
							}
							break;
						}
					}
				}
				if (CI_ERROR == chMaxCheck)
				{
					break;
				}
			}
			if (CI_ERROR == chMaxCheck)
			{
				break;
			}
		}
		if (CI_ERROR == chMaxCheck)
		{
			break;
		}
	}
	if (CI_ERROR == chMaxCheck)
	{
		rtnvalue = 0U;
	}
	else
	{
		rtnvalue = 1U;
	}

	if (1U == rtnvalue)
	{/*将逻辑区段所属保护区段的防护道岔存储入逻辑区段结构体*/
		rtnvalue = LogRelateProSwDataByOverlapInit(pLgScCfgDtStr);
	}
	return rtnvalue;
}

/*********************************************
*函数功能：根据电子地图中信号机属性设置信号机分段属性
*参数说明：pSgnl是DSU信号机数据结构指针
*          pSgnlCfgDtStr，信号机配置数据结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 SetSignalFenDuanAttr(DSU_SIGNAL_STRU* pSgnl, SignalConfigDataStruct* pSgnlCfgDtStr)
{
	UINT8 ret = CI_SUCCESS;
	UINT16 sigAttrEmap = 0u;/*电子地图中信号机属性*/

	/*入口参数防护*/
	if ((NULL == pSgnl) || (NULL == pSgnlCfgDtStr))
	{
		/*返回失败*/
		ret = CI_ERROR;
	}
	if (CI_SUCCESS == ret)
	{
		sigAttrEmap = pSgnl->wAttribute;
		if (0x0080U == (0x0080U & sigAttrEmap))
		{
			pSgnlCfgDtStr->signalFenDuanAttr = SIGNAL_FENDUAN_YES;
		}
		else
		{
			pSgnlCfgDtStr->signalFenDuanAttr = SIGNAL_FENDUAN_NO;
		}

	}
	return ret;
}

/*********************************************
*函数功能：从电子地图逻辑区段SPKS结构体计算SPKS继电器ID
*参数说明：pSpks是DSU逻辑区段SPKS数据结构指针
pSpksDataConfig是SPKS配置数据结构指针
*返回值：0，失败；1，成功
* by cgh 20230919
*********************************************/
UINT8 ReadDataFromDquLogSpksData(const DSU_LOGSEC_SPKS_BUTTON_STRU* pSpks, SpksDataConfigStruct* pSpksDataConfig)
{
	UINT16 i = 0U;
	UINT8 rtnvalue = 0U;
	UINT16 j = 0U;
	UINT16 wLogRelatePhySum = 0U;/*逻辑区段关联物理区段数目*/
	/*入口参数防护*/
	if ((pSpks != NULL) && (pSpksDataConfig != NULL))
	{

		/* 电子地图中数据基本属性设置 */
		pSpksDataConfig->spksId = pSpks->wId;
		pSpksDataConfig->belongCiId = (UINT8)(pSpks->wManageCI);
		pSpksDataConfig->belongVirCIid = (UINT8)pSpks->wManageVirCI;
		pSpksDataConfig->wSpksRelPlatFormId = pSpks->wPlatFormId;
		pSpksDataConfig->wSpksLogSecNum = pSpks->wLogSecNum;

		(void)CommonMemSet(pSpksDataConfig->wSpksLogSecIdBuff, (UINT32)(sizeof(pSpksDataConfig->wSpksLogSecIdBuff) / sizeof(UINT8)), 0, (UINT32)(sizeof(pSpksDataConfig->wSpksLogSecIdBuff) / sizeof(UINT8)));
		for (i = 0u; (i < pSpksDataConfig->wSpksLogSecNum) && (i < SPKS_MAX_LOG_SEC_NUM) && (i < DSU_SPKS_STRU_LOGSECID); i++)
		{
			pSpksDataConfig->wSpksLogSecIdBuff[i] = pSpks->wRelateLogSecId[i];
		}

		(void)CommonMemSet(pSpksDataConfig->spksPhySecIdBuff, (UINT32)(sizeof(pSpksDataConfig->spksPhySecIdBuff) / sizeof(UINT8)), 0, (UINT32)(sizeof(pSpksDataConfig->spksPhySecIdBuff) / sizeof(UINT8)));
		for (i = 0U; i < pSpksDataConfig->wSpksLogSecNum; i++)
		{
			for (j = 0U; j < wLogRelatePhySum; j++)
			{
				if (dquCICfgDtStr.lgcSctCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLogicSgmtIndex[pSpksDataConfig->wSpksLogSecIdBuff[i]]].wRelativePhySecId == pSpksDataConfig->spksPhySecIdBuff[j])
				{
					break;
				}
			}
			if (wLogRelatePhySum == j)
			{
				pSpksDataConfig->spksPhySecIdBuff[wLogRelatePhySum] = dquCICfgDtStr.lgcSctCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLogicSgmtIndex[pSpksDataConfig->wSpksLogSecIdBuff[i]]].wRelativePhySecId;
				wLogRelatePhySum++;
			}
		}
		pSpksDataConfig->phySecNum = wLogRelatePhySum;

		if ((0U == pSpksDataConfig->wSpksLogSecNum) || (0U == pSpksDataConfig->phySecNum))
		{
			/*无SPKS关联的区段，返回失败*/
			rtnvalue = 0U;
		}
		else
		{ 
			rtnvalue = 1U;
		}
		
	}
	else
	{
		rtnvalue = 0U;
	}
	return rtnvalue;
}

/*********************************************
*函数功能：从电子地图物理区段SPKS结构体计算SPKS数据
*参数说明：pSpks是DSU物理区段SPKS数据结构指针
pSpksDataConfig是SPKS配置数据结构指针
*返回值：0，失败；1，成功
* by cgh 20230919
*********************************************/
UINT8 ReadDataFromDquPhySpksData(const DSU_SPKS_BUTTON_STRU* pSpks, SpksDataConfigStruct* pSpksDataConfig)
{
	UINT16 i = 0U;
	UINT8 rtnvalue = 0U;
	/*入口参数防护*/
	if ((pSpks != NULL) && (pSpksDataConfig != NULL))
	{

		/* 电子地图中数据基本属性设置 */
		pSpksDataConfig->spksId = pSpks->wId;
		pSpksDataConfig->belongCiId = (UINT8)(pSpks->wManageCI);
		pSpksDataConfig->belongVirCIid = (UINT8)pSpks->wManageVirCI;
		pSpksDataConfig->wSpksRelPlatFormId = (UINT8)pSpks->wPlatFormId;
		pSpksDataConfig->phySecNum = pSpks->wPhysicalSgmtNum;
		(void)CommonMemSet(pSpksDataConfig->spksPhySecIdBuff, (UINT32)(sizeof(pSpksDataConfig->spksPhySecIdBuff) / sizeof(UINT8)), 0, (UINT32)(sizeof(pSpksDataConfig->spksPhySecIdBuff) / sizeof(UINT8)));
		for (i = 0u; (i < pSpksDataConfig->phySecNum) && (i < SPKS_MAX_SEC_NUM) && (i < DSU_SPKS_STRU_PHYID); i++)
		{
			pSpksDataConfig->spksPhySecIdBuff[i] = pSpks->wRelatePhysicalSgmtId[i];
		}

		if (0U == pSpksDataConfig->phySecNum)
		{
			/*无SPKS关联的区段，返回失败*/
			rtnvalue = 0U;
		}
		else
		{
			rtnvalue = 1U;
		}
		
	}
	else
	{
		rtnvalue = 0U;
	}
	return rtnvalue;
}

/*********************************************
*函数功能：计算物理区段对应的SPKS信息
*参数说明：pPsclSgmtCfgDtStr物理区段配置数据结构体指针
*返回值：0，失败；1，成功
* by cgh 20230919
*********************************************/
UINT8 PhysicRelateSpksStr(PhysicalSectionConfigDataStruct* pPsclSgmtCfgDtStr)
{
	UINT8 rtnvalue = 0U;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	
	/*入口参数防护*/
	if (NULL != pPsclSgmtCfgDtStr)
	{
		/* SPKS */
		pPsclSgmtCfgDtStr->spksNum = 0u;

		for (jj = 0u; jj < dquCICfgDtStr.spksDataConfigStrLen; jj++)
		{
			for (ii = 0u; ii < dquCICfgDtStr.spksDataConfigStr[jj].phySecNum; ii++)
			{
				/* 判断当前SPKS按钮是否包含本物理区段 */
				if (dquCICfgDtStr.spksDataConfigStr[jj].spksPhySecIdBuff[ii] == pPsclSgmtCfgDtStr->PhysicalSectionId)
				{
					if (pPsclSgmtCfgDtStr->spksNum < PHYSICAL_SECTION_SPKS_MAX_NUM)
					{
						pPsclSgmtCfgDtStr->spksIdBuff[pPsclSgmtCfgDtStr->spksNum] = dquCICfgDtStr.spksDataConfigStr[jj].spksId;
						pPsclSgmtCfgDtStr->spksNum++;
					}
				}
				else
				{
					; /*继续查找*/
				}
			}
		}
		rtnvalue = 1U;

	}
	return rtnvalue;
}

/*********************************************
*函数功能：初始化声光报警器配置数据结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 SGBJConfigDataStructInit(CHAR* FSName)
{
	UINT8 rtnvalue = 0U;
	UINT8 callFun = 0U;
	UINT16 i = 0U;
	UINT16 j = 0U;
	UINT16 k = 0U;
	UINT8 cRouteRelFlag = FLAG_UNSET;
	UINT8 cRelayBelongCi_1 = 0U;  /*继电器1所属CI*/
	UINT8 cRelayBelongCi_2 = 0U;  /*继电器2所属CI*/

	callFun = dfsEmapInit(FSName);
	callFun *= InitLS_SGBJStru(FSName);

	/*电子地图初始化失败，函数失败退出*/
	if (1U == callFun)
	{
		rtnvalue = 1U;
		dquCICfgDtStr.wSGBJCfgLen = LSDataLen.LSSGBJStruLen;

		if (SGBJ_SUM_MAX > LSDataLen.LSSGBJStruLen)
		{
			for (i = 0U; i < LSDataLen.LSSGBJStruLen; i++)
			{
				cRelayBelongCi_1 = 0U;  /*每遍历一个声光报警器，清零一次所属CI*/
				cRelayBelongCi_2 = 0U;

				dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJId = LSData.pLSSGBJStru[i].wSGBJId;
				dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelayId = LSData.pLSSGBJStru[i].wSGBJRelayId;
				dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelayId_2 = LSData.pLSSGBJStru[i].wSGBJRelayId_2;
				dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelPhySecNum = LSData.pLSSGBJStru[i].wSGBJRelPhySecNum;

				for (j = 0U; j < SGBJ_REL_PHYSEC_SUM_MAX; j++)
				{
					dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelPhySecId[j] = LSData.pLSSGBJStru[i].szSGBJRelPhySecId[j];
				}

				/*初始化声光报警器关联进路*/
				for (j = 0U; j < dquCICfgDtStr.RouteCfgDtStrLen; j++)
				{
					cRouteRelFlag = FLAG_UNSET;  /*每遍历一次，清一次标志*/
					for (k = 0U; k < dquCICfgDtStr.RouteCfgDtStr[j].wRelatedSGBJNum; k++)
					{
						if (dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJId == dquCICfgDtStr.RouteCfgDtStr[j].szRelatedSGBJId[k])
						{
							if (SGBJ_INCLUDE_ROUTE_SUM_MAX > dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelatedRouteNum)
							{
								dquCICfgDtStr.SGBJCfgDataStru[i].szSGBJRelatedRouteId[dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelatedRouteNum] = dquCICfgDtStr.RouteCfgDtStr[j].RouteId;
								dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelatedRouteNum++;
								cRouteRelFlag = FLAG_SET;
							}
							else
							{
								rtnvalue = 0U;  /*数量超限，返回0*/
							}
						}
						else
						{
							/*继续遍历*/
						}

						if ((1U == rtnvalue) && (FLAG_UNSET == cRouteRelFlag))
						{
							/*继续遍历*/
						}
						else
						{
							break;  /*数量超限或已关联此进路，停止遍历*/
						}
					}

					if (1U == rtnvalue)
					{
						/*继续遍历*/
					}
					else
					{
						break;  /*数量超限，停止遍历，返回0*/
					}
				}

				for (j = 0U; j < RelayDataLen.RelayCfgDtStrLen; j++)
				{
					if (dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelayId == RelayData.pRelayCfgDtStr[j].RelayId)
					{
						cRelayBelongCi_1 = RelayData.pRelayCfgDtStr[j].BelongCiId;
					}

					if (dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelayId_2 == RelayData.pRelayCfgDtStr[j].RelayId)
					{
						cRelayBelongCi_2 = RelayData.pRelayCfgDtStr[j].BelongCiId;
					}

					if ((0U != cRelayBelongCi_1) && (0U != cRelayBelongCi_2))
					{
						break;
					}
				}

				if ((0U != rtnvalue) && (0U != cRelayBelongCi_1) && (cRelayBelongCi_1 == cRelayBelongCi_2))
				{
					dquCICfgDtStr.SGBJCfgDataStru[i].cBelongCiId = cRelayBelongCi_1;					
				}
				else
				{
					rtnvalue = 0U;  /*初始化失败，停止遍历，返回0*/
					break;
				}
			}
		}
		else
		{
			rtnvalue = 0U;  /*声光报警器超限，初始化失败*/
		}
	}
	else
	{
		rtnvalue = 0U;
	}

	return rtnvalue;
}

/*********************************************
*函数功能：进路关联声光报警器配置数据初始化
*参数说明：RouteConfigDataStruct* pRouteCfgDtStr 进路配置数据结构体指针
*          LS_SGBJStruct* pLSSGBJStr 联锁声光报警器结构体指针
*返回值：0，失败；1，成功
*********************************************/
UINT8 RouteRelatedSGBJCfgDataInit(RouteConfigDataStruct* pRouteCfgDtStr, LS_SGBJStruct* pLSSGBJStr)
{
	UINT16 i = 0U;
	UINT16 j = 0U;
	UINT8 k = 0U;
	UINT16 wTempRelatedSGBJNum = 0U;
	UINT8 rtnvalue = 0U;
	UINT8 cSGBJRelFlag = FLAG_UNSET;
	UINT16 wInFstPhySecIndex = 0U;  /*进路内方第一物理区段索引编号*/
	UINT16 wStartSignalIndex = 0U;  /*进路始端信号机索引编号*/
	UINT16 wOutFstPhySecIndex = 0U;  /*进路始端信号机外方第一物理区段索引编号*/
	UINT8 cInFstPhySecLjkFlag = 0U;  /*进路内方第一物理区段列检库属性*/
	UINT8 cOutFstPhySecLjkFlag = 0U;  /*进路始端信号机外方第一物理区段列检库属性*/

	if ((NULL != pRouteCfgDtStr) && (NULL != pLSSGBJStr))
	{
		rtnvalue = 1U;
		pRouteCfgDtStr->cSGBJDelayOpenFlag = ROUTE_SGBJ_DELAY_OPEN_INVALID;  /*先初始化延时开放标志无效*/

		/*获取进路内方第一物理区段及始端信号机外方第一物理区段列检库属性*/
		wInFstPhySecIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuPhysicalSgmtIndex[pRouteCfgDtStr->RoutePhySectionStru[0].PhysicalSectionId];
		cInFstPhySecLjkFlag = dquCICfgDtStr.PsclSgmtCfgDtStr[wInFstPhySecIndex].LjkSecFlag;
		wStartSignalIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[pRouteCfgDtStr->StartSignalId];
		wOutFstPhySecIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuPhysicalSgmtIndex[dquCICfgDtStr.SgnlCfgDtStr[wStartSignalIndex].OutFirstPhySecId];
		cOutFstPhySecLjkFlag = dquCICfgDtStr.PsclSgmtCfgDtStr[wOutFstPhySecIndex].LjkSecFlag;

		/*遍历所有声光报警器，初始化进路关联声光报警器*/
		for (i = 0U; i < LSDataLen.LSSGBJStruLen; i++)
		{
			cSGBJRelFlag = FLAG_UNSET;  /*每遍历一次，清一次标志*/

			/*遍历声光报警器关联的物理区段*/
			for (j = 0U; j < pLSSGBJStr[i].wSGBJRelPhySecNum; j++)
			{
				/*遍历进路内方区段，判断进路内方区段是否为声光报警器关联的物理区段*/
				for (k = 0U; k < pRouteCfgDtStr->RoutePhySecSum; k++)
				{
					if (pRouteCfgDtStr->RoutePhySectionStru[k].PhysicalSectionId == pLSSGBJStr[i].szSGBJRelPhySecId[j])
					{
						if (ROUTE_RELATED_SGBJ_NUM_MAX > wTempRelatedSGBJNum)
						{
							pRouteCfgDtStr->szRelatedSGBJId[wTempRelatedSGBJNum] = pLSSGBJStr[i].wSGBJId;  /*进路内方区段为声光报警器关联物理区段，为进路关联此声光报警器*/
							wTempRelatedSGBJNum++;
							cSGBJRelFlag = FLAG_SET;

							/*进路关联声光报警器，若进路内方或外方第一区段具有列检库属性，则置延时报警标志有效*/
							if ((0xaaU == cInFstPhySecLjkFlag) || (0xaaU == cOutFstPhySecLjkFlag))
							{
								pRouteCfgDtStr->cSGBJDelayOpenFlag = ROUTE_SGBJ_DELAY_OPEN_VALID;  /*置延时报警标志有效*/
							}
							else
							{
								/*保持延时报警标志无效*/
							}
						}
						else
						{
							rtnvalue = 0U;  /*数量超限，返回0*/
						}

						break;  /*数量超限或进路已关联此声光报警器，停止遍历*/
					}
					else
					{
						/*继续遍历*/
					}
				}

				if (FLAG_UNSET == cSGBJRelFlag)
				{
					/*进路未包含此区段，继续判断进路始端信号机外方第一区段是否为此区段*/
					if (pLSSGBJStr[i].szSGBJRelPhySecId[j] == dquCICfgDtStr.SgnlCfgDtStr[wStartSignalIndex].OutFirstPhySecId)
					{
						if (ROUTE_RELATED_SGBJ_NUM_MAX > wTempRelatedSGBJNum)
						{
							pRouteCfgDtStr->szRelatedSGBJId[wTempRelatedSGBJNum] = pLSSGBJStr[i].wSGBJId;  /*进路始端信号机外方第一区段为声光报警器关联区段，为进路关联此声光报警器*/
							wTempRelatedSGBJNum++;
							cSGBJRelFlag = FLAG_SET;

							/*进路关联声光报警器，若进路内方或外方第一区段具有列检库属性，则置延时报警标志有效*/
							if ((0xaaU == cInFstPhySecLjkFlag) || (0xaaU == cOutFstPhySecLjkFlag))
							{
								pRouteCfgDtStr->cSGBJDelayOpenFlag = ROUTE_SGBJ_DELAY_OPEN_VALID;  /*置延时报警标志有效*/
							}
							else
							{
								/*保持延时报警标志无效*/
							}
						}
						else
						{
							rtnvalue = 0U;  /*数量超限，返回0*/
						}
					}
					else
					{
						/*进路始端信号机外方第一区段非声光报警器关联区段，不处理*/
					}
				}
				else
				{
					/*进路包含此区段，不再判断进路始端信号机外方第一区段是否为本区段*/
				}

				if ((1U == rtnvalue) && (FLAG_UNSET == cSGBJRelFlag))
				{
					/*继续遍历*/
				}
				else
				{
					break;  /*数量超限或进路已关联此声光报警器，停止遍历*/
				}
			}

			if (1U == rtnvalue)
			{
				/*继续遍历*/
			}
			else
			{
				break;  /*数量超限，停止遍历*/
			}
		}
	}
	else if (NULL != pRouteCfgDtStr) /* (NULL == pLSSGBJStr)*/
	{
		wTempRelatedSGBJNum = 0U;
		pRouteCfgDtStr->cSGBJDelayOpenFlag = ROUTE_SGBJ_DELAY_OPEN_INVALID;
		rtnvalue = 1U;  /*声光报警器表为0，返回1*/
	}
	else
	{
		/*入参非法，返回0*/
	}

	if (1U == rtnvalue)
	{
		pRouteCfgDtStr->wRelatedSGBJNum = wTempRelatedSGBJNum;
	}
	else
	{
		/*返回0*/
	}

	return rtnvalue;
}

/*********************************************
*函数功能：计算联锁进路点式接近区段逻辑区段数据
*参数说明：pLSRouteStr联锁进路结构体指针
			pRouteCfgDtStr进路配置数据结构体指针
*返回值：0，失败；1，成功
*by cgh 20231014
*********************************************/
UINT8 RouteBlocNearLogSecInit(LS_RouteStruct* pLSRouteStr, RouteConfigDataStruct* pRouteCfgDtStr)
{
	UINT8 ii = 0U;
	UINT16 jj = 0U;
	UINT16 kk = 0U;
	UINT8 rtnvalue = CI_ERROR;
	DSU_ROUTE_STRU* pDsuRouteStr = NULL;/*电子地图进路表结构体*/
	DSU_BLOC_ACCESS_LINK_STRU* pBlocAccessStr = NULL;/*电子地图点式接近区段表*/
	DSU_AXLE_SGMT_STRU* pAxleSgmtStr = NULL;/*电子地图计轴区段表*/
	LOD_STRU strFirstPoint = { 0U };/*查询位置的第一个点*/
	LOD_STRU strNextPoint = { 0U }; /*查询位置的下一个点*/
	UINT8 chDirChangeNum = 0U;/*方向变化点数目*/

	/*入口参数防护*/
	if ((NULL != pLSRouteStr) && (NULL != pRouteCfgDtStr))
	{
		rtnvalue = CI_SUCCESS;

		pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[pLSRouteStr->wRouteId];

		strFirstPoint.Lnk = pDsuRouteStr->wOrgnLkId;
		strFirstPoint.Off = 1U;

		/*点式进路接近区段条件数目 (配置字段)*/
		if (ROUTE_NEARSEC_CONDITION_SUM_MAX >= pDsuRouteStr->wBlogAccessLinkNum)
		{
			for (ii = 0U; ii < pDsuRouteStr->wBlogAccessLinkNum; ii++)
			{
				pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum = 0U;
				pBlocAccessStr = dsuStaticHeadStru.pBLOCAccessLinkStru + dsuBLOCAccessLinkIndex[pDsuRouteStr->wBlogAccessLinkId[ii]];

				if ((ROUTE_BLOCNEAR_PHYSEC_SUM_MAX >= pBlocAccessStr->wIncludeAxleSgmtNum) &&
					(ROUTE_CBTCNEAR_LOGSEC_SUM_MAX > pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum))
				{
					for (jj = 0U; jj < pBlocAccessStr->wIncludeAxleSgmtNum; jj++)
					{
						pAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[pBlocAccessStr->wIncludeAxleSgmtId[jj]];

						strNextPoint.Lnk = pAxleSgmtStr->wOrgnLkId;
						strNextPoint.Off = 1U;
						/*查询进路到当前计轴区段之间有无方向变化点*/
						chDirChangeNum = GetDirChangeNumBtwPoints(&strFirstPoint, &strNextPoint); 

						if (((0U == (chDirChangeNum % 2U)) && (DIR_SAME == pLSRouteStr->wDir)) || ((0U != (chDirChangeNum % 2U)) && (DIR_CONVERT == pLSRouteStr->wDir)))
						{
							/*偶数个方向变化点且进路方向与逻辑方向一致 || 奇数个方向变化点且进路方向与逻辑方向相反，计轴区段对应的逻辑区段从后往前存储*/
							for (kk = (pAxleSgmtStr->wIncludeLogicSgmtNum - 1U); kk >= 0U; kk--)
							{
								pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecIdBuf[pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum] = pAxleSgmtStr->wLogicSgmtId[kk];
								pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum++;

								if (0U == kk)
								{
									break;
								}
								else
								{
									; /*继续遍历*/
								}
							}
						}
						else if (((0U == (chDirChangeNum % 2U)) && (DIR_CONVERT == pLSRouteStr->wDir)) || ((0U != (chDirChangeNum % 2U)) && (DIR_SAME == pLSRouteStr->wDir)))
						{
							/*偶数个方向变化点且进路方向与逻辑方向相反 || 奇数个方向变化点且进路方向与逻辑方向一致，计轴区段对应的逻辑区段从后往前存储*/
							for (kk = 0U; kk < pAxleSgmtStr->wIncludeLogicSgmtNum; kk++)
							{
								pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecIdBuf[pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum] = pAxleSgmtStr->wLogicSgmtId[kk];
								pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum++;
							}
						}
						else
						{
							rtnvalue = CI_ERROR;
						}
					}
				}
				else
				{
					rtnvalue = CI_ERROR;
				}
			}
		}
		else
		{
			rtnvalue = CI_ERROR;
		}
	}
	else
	{
		rtnvalue = CI_ERROR;
	}
	return rtnvalue;
}


/*********************************************
*函数功能：计算联锁进路第一离去逻辑区段数据
*参数说明：pLSRouteStr联锁进路结构体指针
			pRouteCfgDtStr进路配置数据结构体指针
*返回值：0，失败；1，成功
*by cgh 20231014
*********************************************/
UINT8 RouteFirstLeaveLogSecInit(LS_RouteStruct* pLSRouteStr, RouteConfigDataStruct* pRouteCfgDtStr)
{
	UINT8 lineIdentity = 0U;
	UINT16 routeId = 0U;
	UINT16 routeEndSignal = 0U;/*进路终端信号机*/
	UINT8 rtnvalue = CI_ERROR;
	UINT16 j = 0U;

	/*入口参数防护*/
	if ((NULL != pLSRouteStr) && (NULL != pRouteCfgDtStr))
	{
		rtnvalue = CI_SUCCESS;
		routeId = pLSRouteStr->wRouteId;
		lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);
		pRouteCfgDtStr->RouteLeaveLogicSecId = 0u;

		if (CI_TRADITION_RAILWAY == lineIdentity)
		{/*传统城轨线路*/
			/*进路离去区段为进路终端信号机内方第一区段，可能不存在（终端阻挡信号机）*/
			routeEndSignal = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[routeId]].wEndSignalId;/*进路终端信号机*/

			/*找到以该信号机为始端信号机的进路*/
			for (j = 0U; j < ROUTE_SUM_MAX; j++)
			{
				if (routeEndSignal == dquCICfgDtStr.RouteCfgDtStr[j].StartSignalId)
				{
					pRouteCfgDtStr->RouteLeaveLogicSecId = dquCICfgDtStr.RouteCfgDtStr[j].InFirstLogSecId;
					break;
				}
				else
				{
					/*继续遍历*/
				}
			}

		}
		else
		{
			;
		}
	}
	else
	{
		rtnvalue = CI_ERROR;
	}
	return rtnvalue;
}

/*********************************************
*函数功能：转换轨进路关联折返信号机id数据初始化
*参数说明：RouteConfigDataStruct* pRouteCfgDtStr 进路配置数据结构体指针
*           LS_TransRouteZFSigStruct* pTransRouteZFSigStruc 转换轨进路关联折返信号机id结构体指针
*返回值：0，失败；1，成功
*Create： fan 20240725
*********************************************/
UINT8 RouteRelatedTransZFSigInit(RouteConfigDataStruct* pRouteCfgDtStr, LS_TransRouteZFSigStruct* pTransRouteZFSigStruct)
{
	UINT8 rtnvalue = CI_ERROR;
	UINT8 i = 0U;
	if ((NULL != pRouteCfgDtStr) && (NULL != pTransRouteZFSigStruct))
	{
		rtnvalue = CI_SUCCESS;
		/*初始化关联信号机为0*/
		pRouteCfgDtStr->wRelatedTransZFSigId = 0U;
		/*遍历转换轨关联折返信号机id表，初始化进路配置数据*/
		for (i = 0U; i < LSDataLen.LSTransRouteZFSigStruLen; i++)
		{
			/*查找对应进路*/
			if (pRouteCfgDtStr->RouteId == pTransRouteZFSigStruct[i].wRouteId)
			{
				pRouteCfgDtStr->wRelatedTransZFSigId = pTransRouteZFSigStruct[i].wTransRouteZFSigId;
				break;
			}
		}
	}
	else if (NULL== pTransRouteZFSigStruct) 
	{
		pRouteCfgDtStr->wRelatedTransZFSigId = 0U;
		rtnvalue = 1U;  /*转换轨折返信号机表为空，返回1*/
	}
	else
	{
		/*入参非法，返回0*/
	}
	return rtnvalue;
}

/*********************************************
*函数功能：AG LINK是否存在关联CG属性计算
*参数说明：pLinkScCfgDtStr LINK置数据结构体指针
*返回值：0，失败；1，成功
*创建 by cgh 20240821
*********************************************/
UINT8 AgLinkExistRelCGFlagCalc(LinkDataConfigStru* pLinkScCfgDtStr)
{
	UINT8 rtnvalue = 0U;
	UINT16 wOrgnLinkAbgFlag = 0U; /*起点相邻LINK ABG标志*/
	UINT16 wTmnlLinkAbgFlag = 0U; /*终点相邻LINK ABG标志*/

	/*入口参数防护*/
	if (NULL == pLinkScCfgDtStr)
	{
		/*返回失败*/
		rtnvalue = 0U;
	}
	else
	{
		rtnvalue = 1U;

		pLinkScCfgDtStr->chExistRelCGFlag = LINK_EXIST_REL_CG_DEFAULT;

		if (LINK_REL_PHYSEC_IS_AG == pLinkScCfgDtStr->chRelPhySecIsAGorBG)
		{
			if ((65535U == pLinkScCfgDtStr->wOrgnJointMainLkId) || (65535U == pLinkScCfgDtStr->wTmnlJointMainLkId))
			{
				pLinkScCfgDtStr->chExistRelCGFlag = LINK_EXIST_REL_CG_NO;
			}
			else
			{
				wOrgnLinkAbgFlag = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wOrgnJointMainLkId]].chRelPhySecIsAGorBG;
				wTmnlLinkAbgFlag = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wTmnlJointMainLkId]].chRelPhySecIsAGorBG;

				/*相邻LINK有一个是BG则不存在CG*/
				if ((LINK_REL_PHYSEC_IS_BG != wOrgnLinkAbgFlag) && (LINK_REL_PHYSEC_IS_BG != wTmnlLinkAbgFlag))
				{
					pLinkScCfgDtStr->chExistRelCGFlag = LINK_EXIST_REL_CG_YES;
				}
				else
				{
					pLinkScCfgDtStr->chExistRelCGFlag = LINK_EXIST_REL_CG_NO;
				}
			}
		}
		else
		{
			; /*赋值为默认*/
		}
		
	}
	return rtnvalue;
}

/*********************************************
*函数功能：BGlink关联的AGlink计算
*参数说明：LinkDataConfigStru* pLinkScCfgDtStr LINK置数据结构体指针
*返 回 值：0 失败
*          1 成功
*Creatd By LQ 2024.08.22
*********************************************/
UINT8 BGLinkRelAGLinkCal(LinkDataConfigStru* pLinkScCfgDtStr)
{
	UINT8 cRetVal = CI_ERROR;
	UINT16 wOrgLinkId = 0U;  /*起点相邻link*/
	UINT16 wTmlLinkId = 0U;  /*终点相邻link*/
	UINT8 cOrgLinkAttr = LINK_REL_PHYSEC_IS_DEFAULT;  /*起点相邻linkAG/BG属性*/
	UINT8 cTmlLinkAttr = LINK_REL_PHYSEC_IS_DEFAULT;  /*终点相邻linkAG/BG属性*/
	UINT16 wBGRelAGLinkId = 0U;  /*BG关联的AGlink*/
	UINT16 wBGRelCGLinkId = 0U;  /*BG关联的CGlink*/

	if (NULL != pLinkScCfgDtStr)
	{
		if (LINK_REL_PHYSEC_IS_BG == pLinkScCfgDtStr->chRelPhySecIsAGorBG)
		{
			if ((UINT16_MAX != pLinkScCfgDtStr->wOrgnJointMainLkId) && (0U != pLinkScCfgDtStr->wOrgnJointMainLkId))
			{
				cOrgLinkAttr = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wOrgnJointMainLkId]].chRelPhySecIsAGorBG;
				wOrgLinkId = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wOrgnJointMainLkId]].wId;

				if (LINK_REL_PHYSEC_IS_AG == cOrgLinkAttr)
				{
					wBGRelAGLinkId = wOrgLinkId;  /*BG起点相邻link为AG*/
				}
				else if (LINK_REL_PHYSEC_IS_DEFAULT == cOrgLinkAttr)
				{
					wBGRelCGLinkId = wOrgLinkId;  /*BG起点相邻link为CG*/
				}
				else
				{
					/*BG起点相邻link为B2G，不处理*/
				}
			}
			else
			{
				/*尽头线，不处理*/
			}

			if ((UINT16_MAX != pLinkScCfgDtStr->wTmnlJointMainLkId) && (0U != pLinkScCfgDtStr->wTmnlJointMainLkId))
			{
				cTmlLinkAttr = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wTmnlJointMainLkId]].chRelPhySecIsAGorBG;
				wTmlLinkId = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wTmnlJointMainLkId]].wId;

				if (LINK_REL_PHYSEC_IS_AG == cTmlLinkAttr)
				{
					wBGRelAGLinkId = wTmlLinkId;  /*BG终点相邻link为AG*/
				}
				else if (LINK_REL_PHYSEC_IS_DEFAULT == cTmlLinkAttr)
				{
					wBGRelCGLinkId = wTmlLinkId;  /*BG终点相邻link为CG*/
				}
				else
				{
					/*BG终点相邻link为B2G，不处理*/
				}
			}
			else
			{
				/*尽头线，不处理*/
			}
			
			if ((0U == wBGRelAGLinkId) && (0U != wBGRelCGLinkId))
			{
				/*存在CG，通过CG寻找BG关联的AG*/
				wOrgLinkId = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wBGRelCGLinkId]].wOrgnJointMainLkId;  /*CG起点相邻link*/
				wTmlLinkId = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wBGRelCGLinkId]].wTmnlJointMainLkId;  /*CG终点相邻link*/

				if (wOrgLinkId == pLinkScCfgDtStr->wId)
				{
					wBGRelAGLinkId = wTmlLinkId;  /*CG终点相邻link为AG*/
				}
				else if (wTmlLinkId == pLinkScCfgDtStr->wId)
				{
					wBGRelAGLinkId = wOrgLinkId;  /*CG起点相邻link为AG*/
				}
				else
				{
					/*不处理*/
				}
			}
			else
			{
				/*不处理*/
			}
		}
		else
		{
			/*非BG，不处理*/
		}

		pLinkScCfgDtStr->wBGLinkRelAGLink = wBGRelAGLinkId;
		cRetVal = CI_SUCCESS;
	}
	else
	{
		/*入参检查失败，返回失败*/
	}

	return cRetVal;
}

/*
* 功能描述：初始化分界点数据中本控区所处分界点方向
* 参数说明：CfpConfigStru *pstCutoffPointData DquCfg 分界点设备数据内容指针（出参）
* 返 回 值：0 失败
*           1 成功
* Created By LQ 2024.10.16
*/
static UINT8 EnsureCfpLocDir(CfpConfigStru* pstCutoffPointData)
{
	UINT8 cRetVal = CI_ERROR;
	UINT16 wCfpLocLinkId = 0U;  /*分界点所处linkID*/
	UINT32 dwCfpLocLinkLen = 0U;  /*分界点所处link长度*/

	if (NULL != pstCutoffPointData)
	{
		cRetVal = CI_SUCCESS;
		wCfpLocLinkId = pstCutoffPointData->wLinkId;
		dwCfpLocLinkLen = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wCfpLocLinkId]].dwLength;

		if (LINK_DIRCHANGE_NONE == dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wCfpLocLinkId]].wLogicDirChanged)
		{
			/*没有方向变化点，根据分界点link偏移量确定本控区所处分界点的方向*/
			if (((wCfpLocLinkId == pstCutoffPointData->wInFirstLink) && (0U == pstCutoffPointData->dwOffset))
				|| ((wCfpLocLinkId != pstCutoffPointData->wInFirstLink) && (dwCfpLocLinkLen == pstCutoffPointData->dwOffset)))
			{
				/*（分界点link属于本控区且偏移量为0）或（分界点link不属于本控区且偏移量为link长度），本控区在分界点逻辑正方向*/
				pstCutoffPointData->chLocDir = EMAP_SAME_DIR;
			}
			else if (((wCfpLocLinkId == pstCutoffPointData->wInFirstLink) && (dwCfpLocLinkLen == pstCutoffPointData->dwOffset))
				|| ((wCfpLocLinkId != pstCutoffPointData->wInFirstLink) && (0U == pstCutoffPointData->dwOffset)))
			{
				/*（分界点link属于本控区且偏移量为link长度）或（分界点link不属于本控区且偏移量为0），本控区在分界点逻辑反方向*/
				pstCutoffPointData->chLocDir = EMAP_CONVER_DIR;
			}
			else
			{
				pstCutoffPointData->chLocDir = CI_SYSTEM_DIRECTION_NONE;
				cRetVal = CI_ERROR;  /*配置数据有误，返回0失败，初始化失败*/
				debug_infor_printf((const)"\nEnsureCfpLocDir Error: Cfp ID Is [%d]", pstCutoffPointData->wPointId);
			}
		}
		else
		{
			if ((0U == pstCutoffPointData->dwOffset) && (LINK_DIRCHANGE_BEGIN == dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wCfpLocLinkId]].wLogicDirChanged))
			{
				/*若分界点存在方向变化点，分界点offset为0（即起点对顶），两控区均在分界点逻辑正方向*/
				pstCutoffPointData->chLocDir = EMAP_SAME_DIR;
			}
			else if ((dwCfpLocLinkLen == pstCutoffPointData->dwOffset) && (LINK_DIRCHANGE_END == dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wCfpLocLinkId]].wLogicDirChanged))
			{
				/*若分界点存在方向变化点，分界点offset不为0（即终点对顶），两控区均在分界点逻辑反方向*/
				pstCutoffPointData->chLocDir = EMAP_CONVER_DIR;
			}
			else
			{
				pstCutoffPointData->chLocDir = CI_SYSTEM_DIRECTION_NONE;
				cRetVal = CI_ERROR;  /*配置数据有误，返回0失败，初始化失败*/
				debug_infor_printf((const)"\nEnsureCfpLocDir Error: Cfp ID Is [%d]", pstCutoffPointData->wPointId);
			}
		}
	}
	else
	{
		/*入参检查失败，返回失败*/
	}

	return cRetVal;
}

/*********************************************
*函数功能：初始化无人折返配置数据结构体----对外结构体
*参数说明：FSName文件指针
*返回值：0，失败；1，成功
* by cgh 20241031
*********************************************/
static UINT8 NonAutoReturnStructInit(CHAR* FSName)
{
	UINT8 rtnvalue = 0U;
	UINT8 callFun = 0U;
	UINT16 i = 0U;

	callFun = dfsEmapInit(FSName);

	/*电子地图初始化失败，函数失败退出*/
	if (0U == callFun)
	{
		rtnvalue = 0U;
	}
	else
	{
		rtnvalue = 1U;
	}

	if (1U == rtnvalue)
	{
		for (i = 0U; i < dquCICfgDtStr.NonReturnCfgSum; i++)
		{
			if (i >= NON_AUTO_RETURN_SUM_MAX)
			{
				rtnvalue = 0U;
			}
			else
			{
				rtnvalue = NonReturnStruFromDquStr(dsuStaticHeadStru.pARStru + i, &dquCICfgDtStr.NonAutoReturnCfgDataSt[i]);
			}

			if (0U == rtnvalue)
			{
				break;
			}
			else
			{
				; /*继续初始化*/
			}

		}
	}
	else
	{
		; 
	}

	return rtnvalue;
}

/*********************************************
*函数功能：无人折返配置数据结构体计算
*参数说明：pNonReturn 无人折返结构体指针
	       pNonReturnCfgDtStr 无人折返置数据结构体指针
*返回值：0，失败；1，成功
* by cgh 20241031
*********************************************/
static UINT8 NonReturnStruFromDquStr(DSU_AR_STRU* pNonReturn, NonAutoReturnConfigDataStruct* pNonReturnCfgDtStr)
{
	UINT8 rtnvalue = 0u;

	/*入口参数防护*/
	if ((NULL != pNonReturn) && (NULL != pNonReturnCfgDtStr))
	{
		/*直接从无人折返表中获取*/
		pNonReturnCfgDtStr->NonAutoReturnRelLightId = pNonReturn->wARLampID;
		pNonReturnCfgDtStr->NonAutoReturnRelButtonId = pNonReturn->wARButtonId;

		rtnvalue = 1u;
	}
	else
	{
		; 
	}

	
	return rtnvalue;
}

/*
*功能描述: 初始化LINK特殊区域属性
*输入参数:	CHAR * FSName 数据文件名指针
*输出参数:	无
*返回值: 0 失败
*        1 成功
* by cgh 20250818
*/
static UINT8 LinkSpecialEaDataInit(CHAR* FSName)
{
	UINT16 ii = 0U;
	UINT8 retVal = 0U;  /*返回值*/
	UINT16 jj = 0U;

	retVal = dquCbtcConfigDataInit(FSName);  /*初始化系统配置数据*/

	if (0U != retVal)
	{
		for (ii = 0U; ii < cbtcConfigDataStru.BoundarySpecialEaInfoLen; ii++)
		{
			for (jj = 0U; jj < cbtcConfigDataStru.cbtcSpecialEaInfo[ii].wLinkSum; jj++)
			{
				dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[cbtcConfigDataStru.cbtcSpecialEaInfo[ii].szLinkId[jj]]].wLinkSpecialEa = cbtcConfigDataStru.cbtcSpecialEaInfo[ii].wIndex;
				dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[cbtcConfigDataStru.cbtcSpecialEaInfo[ii].szLinkId[jj]]].dwFrontDis = cbtcConfigDataStru.cbtcSpecialEaInfo[ii].dwFrontDis;
				dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[cbtcConfigDataStru.cbtcSpecialEaInfo[ii].szLinkId[jj]]].dwBehindDis = cbtcConfigDataStru.cbtcSpecialEaInfo[ii].dwBehindDis;
			}
		}
	}
	else
	{
		/*系统配置数据初始化失败，返回0*/
	}

	return retVal;
}

/*********************************************
*函数功能：进路配置风井区段数据初始化
*参数说明：RouteConfigDataStruct* pRouteCfgDtStr 进路配置数据结构体指针
*           LS_AirShaftStruct* pAirShaftSecStruct 风井进路结构体指针
*返回值：0，失败；1，成功
*Create： yx 2026.03.04
*********************************************/
UINT8 AirShaftSectionDataInit(RouteConfigDataStruct* pRouteCfgDtStr, LS_AirShaftStruct* pAirShaftSecStruct)
{
	UINT8 rtnvalue = CI_ERROR;
	UINT16 i = 0U;
	UINT8 j = 0U;
	if ((NULL != pRouteCfgDtStr) && (NULL != pAirShaftSecStruct))
	{
		rtnvalue = CI_SUCCESS;
		/*先初始化为默认值*/
		pRouteCfgDtStr->airShaftRouteSecSum = 0U;
		(void)CommonMemSet((void*)pRouteCfgDtStr->wAirShaftRouteSecIdBuf, (UINT32)sizeof(pRouteCfgDtStr->wAirShaftRouteSecIdBuf), 0U, (UINT32)sizeof(pRouteCfgDtStr->wAirShaftRouteSecIdBuf));
		/*遍历风井区段表，初始化进路配置数据*/

		for (i = 0U; i < LSDataLen.LSAirShaftRouteStruLen; i++)
		{
			/*查找对应进路*/
			if (pRouteCfgDtStr->RouteId == pAirShaftSecStruct[i].wRouteId)
			{
				pRouteCfgDtStr->airShaftRouteSecSum = pAirShaftSecStruct[i].airShaftSecSum;
				/*初始化数据*/
				for (j = 0U; j < AIR_SHAFT_ROUTE_SECTION_NUM_MAX; j++)
				{
					pRouteCfgDtStr->wAirShaftRouteSecIdBuf[j] = pAirShaftSecStruct[i].wAirShaftSecId[j];
				}
				break;
			}
			else
			{

			}
		}
	}
	else if ((NULL != pRouteCfgDtStr) && (NULL == pAirShaftSecStruct))
	{/*风井进路检查表未配置数据*/
		pRouteCfgDtStr->airShaftRouteSecSum = 0U;
		(void)CommonMemSet((void*)pRouteCfgDtStr->wAirShaftRouteSecIdBuf, (UINT32)sizeof(pRouteCfgDtStr->wAirShaftRouteSecIdBuf), 0U, (UINT32)sizeof(pRouteCfgDtStr->wAirShaftRouteSecIdBuf));
		rtnvalue = CI_SUCCESS;
	}
	else
	{
		/*入参非法，返回0*/
	}

	return rtnvalue;
}

/*********************************************
*函数功能：逻辑区段关联防护道岔（遍历保护区段）
*参数说明：pLogCfgDtStr配置数据结构体指针
*返回值：0，失败；1，成功
* add mpt 20260331
*********************************************/
UINT8 LogRelateProSwDataByOverlapInit(LogicSectionConfigDataStruct* pLgScCfgDtStr)
{
	UINT8 rtnvalue = 0U;
	UINT8 ii = 0U;
	UINT16 jj = 0U;
	UINT8 kk = 0U;
	UINT8 hh = 0U;
	UINT8 mm = 0U;
	UINT16 wProtectSwSum = 0U;/*逻辑区段关联防护道岔数量计数*/
	UINT16 wProtectSwId = 0U;/*逻辑区段关联防护道岔ID过渡变量*/
	UINT8 chProtectSwFlag = 0U;/*逻辑区段关联防护道岔去重标志*/
	UINT8 chMaxCheck = CI_SUCCESS;

	if (NULL != pLgScCfgDtStr)
	{
		if (0u == pLgScCfgDtStr->chRelateRouteSum)
		{
			/*逻辑区段关联防护道岔计算*/
			for (ii = 0; ii < pLgScCfgDtStr->chLogsecSwitchSum; ii++)
			{/*遍历逻辑区段包含的所有道岔*/
				wProtectSwSum = dquCICfgDtStr.SwchCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[pLgScCfgDtStr->LogsecSwitchIdStru[ii].SwitchId]].wProtectSwitchNum;
				for (jj = 0; jj < wProtectSwSum; jj++)
				{/*遍历道岔对应的防护道岔*/
					wProtectSwId = dquCICfgDtStr.SwchCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[pLgScCfgDtStr->LogsecSwitchIdStru[ii].SwitchId]].wszProtectSwitchIdBuf[jj];
					chProtectSwFlag = 0U;
					for (kk = 0U; kk < pLgScCfgDtStr->chRelateOverLapSum; kk++)
					{/*遍历逻辑区段关联的保护区段*/
						for (hh = 0U; hh < dquCICfgDtStr.OvlapCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuProtectLinkIndex[pLgScCfgDtStr->wRelateOverLapIdBuf[kk]]].ProtectSwitchSum; hh++)
						{/*查询逻辑区段关联保护区段，若保护区段包含该防护道岔，则逻辑区段关联防护道岔的位置与保护区段一致*/
							if (dquCICfgDtStr.OvlapCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuProtectLinkIndex[pLgScCfgDtStr->wRelateOverLapIdBuf[kk]]].ProtectSwitchStru[hh].ProtectSwitchId == wProtectSwId)
							{
								for (mm = 0U; mm < pLgScCfgDtStr->chRelateProSwSum; mm++)
								{/*关联防护道岔ID去重*/
									if ((pLgScCfgDtStr->wRelateProSwId[mm].SwitchId == dquCICfgDtStr.OvlapCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuProtectLinkIndex[pLgScCfgDtStr->wRelateOverLapIdBuf[kk]]].ProtectSwitchStru[hh].ProtectSwitchId)
										&& (pLgScCfgDtStr->wRelateProSwId[mm].SwitchPosition == dquCICfgDtStr.OvlapCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuProtectLinkIndex[pLgScCfgDtStr->wRelateOverLapIdBuf[kk]]].ProtectSwitchStru[hh].ProtectPosition))
									{
										chProtectSwFlag = 1U;
										break;
									}
								}
								if (1U != chProtectSwFlag)
								{/*当前防护道岔数组中不包含此ID才进行添加*/
									if (LOGSEC_RELATE_PRO_SW_SUM_MAX > pLgScCfgDtStr->chRelateProSwSum)
									{
										pLgScCfgDtStr->wRelateProSwId[pLgScCfgDtStr->chRelateProSwSum].SwitchId = dquCICfgDtStr.OvlapCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuProtectLinkIndex[pLgScCfgDtStr->wRelateOverLapIdBuf[kk]]].ProtectSwitchStru[hh].ProtectSwitchId;
										pLgScCfgDtStr->wRelateProSwId[pLgScCfgDtStr->chRelateProSwSum].SwitchPosition = dquCICfgDtStr.OvlapCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuProtectLinkIndex[pLgScCfgDtStr->wRelateOverLapIdBuf[kk]]].ProtectSwitchStru[hh].ProtectPosition;
										(pLgScCfgDtStr->chRelateProSwSum)++;
									}
									else
									{
										chMaxCheck = CI_ERROR;
									}
									break;
								}
							}
						}
						if (CI_ERROR == chMaxCheck)
						{
							break;
						}
					}
					if (CI_ERROR == chMaxCheck)
					{
						break;
					}
				}
				if (CI_ERROR == chMaxCheck)
				{
					break;
				}
			}
			if (CI_ERROR == chMaxCheck)
			{
				rtnvalue = 0U;
			}
			else
			{
				rtnvalue = 1U;
			}
		}
		else
		{
			rtnvalue = 1U;
		}
		
	}

	return rtnvalue;
}

/*********************************************
*函数功能：逻辑区段关联保护区段相关数据初始化
*参数说明：pOverlapCfgDtStr保护区段配置数据结构体指针   pLogCfgDtStr配置数据结构体指针
*返回值：0，失败；1，成功
* add by mpt 20260331
*********************************************/
UINT8 LogRelateOverlapDataInit(OverlapConfigDataStruct* pOverlapCfgDtStr, LogicSectionConfigDataStruct* pLogCfgDtStr)
{
	UINT16 i = 0U;
	UINT16 j = 0U;
	UINT8 rtnvalue = 0U;
	UINT8 chMaxCheck = CI_SUCCESS;

	if ((NULL != pOverlapCfgDtStr) && (NULL != pLogCfgDtStr))
	{
		/*逻辑区段包含保护区段数目初始化为0*/
		pLogCfgDtStr->chRelateOverLapSum = 0U;
		for (i = 0U; i < dquCICfgDtStr.OvlapCfgDtStrLen; i++)
		{/*遍历所有保护区段,若包含此逻辑区段，即此保护区段为本逻辑区段关联保护区段*/
			for (j = 0; j < pOverlapCfgDtStr[i].cLogicSectionSum; j++)
			{
				if (pOverlapCfgDtStr[i].szLogicSectionIdBuf[j] == pLogCfgDtStr->LogicSectionId)
				{
					if (LOGSEC_RELATE_OVERLAP_SUM_MAX > pLogCfgDtStr->chRelateOverLapSum)
					{
						pLogCfgDtStr->wRelateOverLapIdBuf[pLogCfgDtStr->chRelateOverLapSum] = pOverlapCfgDtStr[i].OverlapId;
						pLogCfgDtStr->chRelateOverLapSum++;
					}
					else
					{
						chMaxCheck = CI_ERROR;
					}
					break;
				}
			}
			if (CI_ERROR == chMaxCheck)
			{
				break;
			}
		}
		if (CI_ERROR == chMaxCheck)
		{
			rtnvalue = 0U;
		}
		else
		{
			rtnvalue = 1U;
		}
	}

	return rtnvalue;
}

/*********************************************
*函数功能：逻辑区段配置数据结构体计算
*参数说明：LogsecSwitchStruct* pSrcSwitchStructBuf 源数据
		   UINT8 chSrclen 源数据长度
		   AxisSwitchStruct* pDstSwitchStructBuf 目标数据
		   UINT8 dstLen 目标数据长度
*返回值：-1，失败；其他为长度
*add by  mpt 20260331
*********************************************/
INT16 AxisSecCfgDtStruFromLogicSecStr(LogsecSwitchStruct* pSrcSwitchStructBuf, UINT8 chSrclen, AxisSwitchStruct* pDstSwitchStructBuf, UINT8 dstLen)
{
	UINT8 i = 0u;
	UINT8 j = 0u;
	INT16 rtnvalue = -1;
	UINT8 tempLen = 0u;

	if ((NULL != pSrcSwitchStructBuf) && (NULL != pDstSwitchStructBuf))
	{
		rtnvalue = 0;
		tempLen = dstLen;
		for (i = 0u; i < chSrclen; i++)
		{
			for (j = 0u; j < dstLen; j++)
			{
				if ((pSrcSwitchStructBuf[i].SwitchId == pDstSwitchStructBuf[j].SwitchId) && (pSrcSwitchStructBuf[i].SwitchPosition == pDstSwitchStructBuf[j].SwitchPosition))
				{/*输入的源数据在目标数据中已经找到了，则跳出*/
					break;
				}
				else
				{
					/*继续*/
				}
			}
			if (j == dstLen)
			{/*在目标数据中未找到本条防护道岔配置*/
				if (AXIS_RELATE_PRO_SW_SUM_MAX > tempLen)
				{
					pDstSwitchStructBuf[tempLen].SwitchId = pSrcSwitchStructBuf[i].SwitchId;
					pDstSwitchStructBuf[tempLen].SwitchPosition = pSrcSwitchStructBuf[i].SwitchPosition;
					tempLen++;
				}
				else
				{
					rtnvalue = -1;
					break;
				}
			}
			else
			{
				/*充分数据无需添加*/
			}
		}
	}
	else
	{
		/*返回失败*/
		rtnvalue = -1;
	}

	if (0 == rtnvalue)
	{
		rtnvalue = (INT16)tempLen;
	}

	return rtnvalue;
}

/*********************************************
*函数功能：计轴区段防护道岔初始化
*参数说明：void
*返回值：0，失败；1，成功
* add mpt 20260331
*********************************************/
UINT8 AxisSecProtectSwitchInit(void)
{
	UINT16 j = 0u;
	UINT16 i = 0u;
	INT16 ret = 0;
	UINT16 k = 0u;
	UINT8 rtnvalue = 0u;
	AxisSectionConfigDataStruct* pAxScCfgDtStr = NULL;

	for (k = 0u; k < dquCICfgDtStr.AxisCfgDtStrLen; k++)
	{
		pAxScCfgDtStr = &dquCICfgDtStr.AxisSctCfgDtStr[k];


		for (i = 0u; i < pAxScCfgDtStr->LogSectionSum; i++)
		{
			for (j = 0u; j < dquCICfgDtStr.lgcSctCfgDtStrLen; j++)
			{
				if (dquCICfgDtStr.lgcSctCfgDtStr[j].LogicSectionId == pAxScCfgDtStr->LogSectionIdBuf[i])
				{
					/*拷贝拷贝*/
					ret = AxisSecCfgDtStruFromLogicSecStr(dquCICfgDtStr.lgcSctCfgDtStr[j].wRelateProSwId, dquCICfgDtStr.lgcSctCfgDtStr[j].chRelateProSwSum, pAxScCfgDtStr->wRelateProSwId, pAxScCfgDtStr->chRelateProSwSum);
					if (-1 != ret)
					{
						pAxScCfgDtStr->chRelateProSwSum = (UINT8)ret;/*更新数量*/
					}
					break;
				}
			}
			if (-1 == ret)
			{
				break;
			}
		}


		if (-1 == ret)
		{
			break;
		}
	}

	if (-1 == ret)
	{
		rtnvalue = 0u;
	}
	else
	{
		rtnvalue = 1u;
	}

	return rtnvalue;
}

