/********************************************************
*                                                                                                            
* 文 件 名： PhysicalSectionDataManage.c   
* 版权说明： 北京交控科技有限公司 
* 创建时间： 2012-03-19
* 作    者： 联锁组
* 功能描述： 物理区段数据管理  
* 修改记录：   
*
********************************************************/ 


#include "PhysicalSectionDataManage.h"
#include "AxisAssertManageAPI.h"



PhysicalSectionDataStruct PhysicalSectionDataStru[PHYSICAL_SECTION_SUM_MAX];   /*定义物理区段数据结构体*/


/*
* 功能描述： 获取指定ID数据
* 参数说明：     
* 返回值  ： 
            PhysicalSectionDataStruct*    
*/
PhysicalSectionDataStruct* GetPhySecData(void)
{
    return PhysicalSectionDataStru;
}

/*
* 功能描述： 获取指定ID物理区段征用状态
* 参数说明： const UINT16 phySectionId, 物理区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 征用状态      
*/
UINT8 GetPhySecUseState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].SecUseState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 清除区段防护锁闭状态
* 参数说明： const UINT16 phySectionId, 物理区段ID      
* 返回值:	1:成功
			0:失败            
*/
UINT16 ClearPhySecPLock(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 retVal = CI_SUCCESS;
	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/


	if (bufIndex >= PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = CI_ERROR;
	}

	else
	{
		PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0;
	}

	
	return retVal;
}
/*
* 功能描述： 设置指定ID物理区段征用状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 useState, 征用状态
*            const UINT16 routeId, 进路ID
* 返回值  ： void 
*/
void SetPhySecUseState(const UINT16 phySectionId, const UINT8 useState, const UINT16 routeId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_SUCCESS;
	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
	
	
	if (bufIndex >= PHYSICAL_SECTION_SUM_MAX)
	{
	    retVal = CI_ERROR;
	}
	
	if(CI_SUCCESS == retVal)
	{
		if ((useState != PHYSICAL_SECTION_USING_NO) &&
			(useState != PHYSICAL_SECTION_USING_YES) &&
			(useState != PHYSICAL_SECTION_USING_APPLY) &&
			(useState != PHYSICAL_SECTION_USING_CANCEL))
		{ /*征用状态无效*/

			retVal = CI_ERROR;
		}
	}

    if(CI_SUCCESS == retVal)
	{
		if (PHYSICAL_SECTION_USING_NO == useState)
		{ /*未征用*/
			if (0u == routeId)
			{
				/*清除本进路征用*/
				PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = 0u;  /*清除区段征用锁闭进路ID*/
			    PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = 0u; /*清除防护征用锁闭进路ID*/
				
			}
			else if(routeId == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId)
			{
				/*清除本进路征用*/
				PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = 0u;  /*清除区段征用锁闭进路ID*/
			}
			else if(routeId == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId)
			{
				 PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = 0u; /*清除防护征用锁闭进路ID*/
			}
			else
			{
				retVal = CI_ERROR;
			}

			if((CI_SUCCESS == retVal)&&(0u == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId)&&(0u == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId) && (0u == PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId))
			{
				PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_NO;  /*物理区段未征用状态*/
			}
		}
		else if (PHYSICAL_SECTION_USING_YES == useState)
		{ /*征用*/
			if ((0u == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId) ||
				(routeId == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId))
			{
				PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = routeId;  /*设置区段征用锁闭进路ID*/

				PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_YES;  /*物理区段征用状态*/
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
		else if (PHYSICAL_SECTION_USING_APPLY == useState)
		{ /*等待征用*/
			if (0u == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId)
			{
				PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = routeId;  /*设置区段征用锁闭进路ID*/

				PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_APPLY;  /*物理区段征用状态*/
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
		else
		{ /*等待取消征用*/
			if (routeId == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId)
			{
				PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = routeId;  /*设置区段征用锁闭进路ID*/
				PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_CANCEL;  /*物理区段征用状态*/
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
	}
	if (CI_ERROR == retVal)
	{
		debug_infor_printf((const)"SetPhySecUseState ERROR, pyhSecId:%d , Stata:%d , RouteId: %d\n", phySectionId, useState, routeId);
	}
}


/*
* @brief 设置指定ID物理区段的逻辑征用状态
* @param const UINT16 phySectionId, 物理区段ID
*         const UINT8 useState, 征用状态
*         const UINT16 routeId, 逻辑进路ID
* @return 无
* @note：by cgh 20231010
*/
UINT8 SetPhySecUseStateByLogRoute(const UINT16 phySectionId, const UINT8 useState, const UINT16 logrouteId)
{
	UINT16 bufIndex = 0U;  /*数组下标*/
	UINT8 retVal = CI_SUCCESS;
	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/


	if (bufIndex >= PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = CI_ERROR;
	}

	if (CI_SUCCESS == retVal)
	{
		if ((useState != PHYSICAL_SECTION_USING_NO) &&
			(useState != PHYSICAL_SECTION_USING_YES))
		{ /*征用状态无效*/

			retVal = CI_ERROR;
		}
	}
	

	if (CI_SUCCESS == retVal)
	{
		if (PHYSICAL_SECTION_USING_NO == useState)
		{ /*未征用*/
			if (0U == logrouteId)
			{
				/*清除本进路征用*/
				PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId = 0u;  /*清除区段征用锁闭逻辑进路ID*/
				PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = 0u; /*清除防护征用锁闭进路ID*/
				PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = 0u;    /*清除征用锁闭进路ID*/
			}
			else if (logrouteId == PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId)
			{
				/*清除本进路征用*/
				PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId = 0u;  /*清除区段征用锁闭逻辑进路ID*/
			}
			else
			{
				retVal = CI_ERROR;
			}

			if ((CI_SUCCESS == retVal) 
				&& (0U == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId) 
				&& (0U == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId) 
				&& (0U == PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId))
			{
				PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_NO;  /*物理区段未征用状态*/
			}
		}
		else if (PHYSICAL_SECTION_USING_YES == useState)
		{ /*征用*/
			if ((0U == PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId) ||
				(logrouteId == PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId))
			{
				PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId = logrouteId;  /*设置区段征用锁闭进路ID*/
				PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_YES;  /*物理区段征用状态*/
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
		else
		{
			; /*不处理*/
		}
		
	}

	return retVal;
}
/*
* 功能描述： 设置指定ID物理区段防护征用状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 useState, 征用状态
*            const UINT16 routeId, 进路ID
* 返回值  ： void      
*/
void SetPhySecProtectUseState(const UINT16 phySectionId, const UINT8 useState, const UINT16 routeId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_SUCCESS;
	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/


	if (bufIndex >= PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = CI_ERROR;
	}

	if(CI_SUCCESS == retVal)
	{
		if ((useState != PHYSICAL_SECTION_USING_NO) &&
			(useState != PHYSICAL_SECTION_USING_YES) &&
			(useState != PHYSICAL_SECTION_USING_APPLY) &&
			(useState != PHYSICAL_SECTION_USING_CANCEL))
		{ /*征用状态无效*/

			retVal = CI_ERROR;
		}
	}

	if(CI_SUCCESS == retVal)
	{
		if (PHYSICAL_SECTION_USING_NO == useState)
		{ /*未征用*/
			if (0u == routeId)
			{
				/*清除本进路征用*/
				PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = 0u;  /*清除区段征用锁闭进路ID*/
				PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = 0u; /*清除防护征用锁闭进路ID*/

			}
			else if(routeId == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId)
			{
				/*清除本进路征用*/
				PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = 0u;  /*清除区段征用锁闭进路ID*/
			}
			else if(routeId == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId)
			{
				PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = 0u; /*清除防护征用锁闭进路ID*/
			}
			else
			{
				retVal = CI_ERROR;
			}

			if((CI_SUCCESS == retVal)&&(0u == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId)&&(0u == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId))
			{
				PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_NO;  /*物理区段未征用状态*/
			}
		}
		else if (PHYSICAL_SECTION_USING_YES == useState)
		{ /*征用*/
			if ((0u == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId) ||
				(routeId == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId))
			{
				PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = routeId;  /*设置区段征用锁闭进路ID*/

				PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_YES;  /*物理区段征用状态*/
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
		else if (PHYSICAL_SECTION_USING_APPLY == useState)
		{ /*等待征用*/
			if (0u == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId)
			{
				PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = routeId;  /*设置区段征用锁闭进路ID*/

				PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_APPLY;  /*物理区段征用状态*/
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
		else
		{ /*等待取消征用*/
			if (routeId == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId)
			{
				PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = routeId;  /*设置区段征用锁闭进路ID*/
				PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_CANCEL;  /*物理区段征用状态*/
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
	}
	if (CI_ERROR == retVal)
	{
		debug_infor_printf((const)"SetPhySecProtectUseState ERROR, pyhSecId:%d , Stata:%d , RouteId: %d\n", phySectionId, useState, routeId);
	}
}

/*
* 功能描述： 获取指定ID物理区段征用所属进路ID
* 参数说明： const UINT16 phySectionId, 物理区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 征用所属进路ID      
*/
UINT16 GetPhySecUseRouteId(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 获取指定ID物理区段征用所属逻辑进路ID
* 参数说明： const UINT16 phySectionId, 物理区段ID
* 返回值  ： 0: 获取数据失败
*			>0: 征用所属进路ID
*/
UINT16 GetPhySecUseLogRouteId(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 获取指定ID物理区段锁闭状态
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 锁闭状态      
*/
UINT8 GetPhySecLockState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].LockState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 设置指定ID物理区段锁闭状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 lockState, 锁闭状态
*            const UINT16 routeId, 进路ID
*            const UINT8 lockDirection, 锁闭方向
* 返回值  ： 无
*			      
*/
void SetPhySecLockState(const UINT16 phySectionId, const UINT8 lockState, const UINT16 routeId, const UINT8 lockDirection)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
	
	
	if (bufIndex >= PHYSICAL_SECTION_SUM_MAX)
	{
	    /*超最大值不做处理*/
	}
	else
	{
		if (PHYSICAL_SECTION_LOCK_START == lockState)
		{ /*上电锁闭*/

			PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置上电锁闭*/
		}
		else if (PHYSICAL_SECTION_LOCK_NO == lockState)
		{ /*未锁闭*/

			if ((PHYSICAL_SECTION_LOCK_NORMAL == PhysicalSectionDataStru[bufIndex].LockState)
				|| (PHYSICAL_SECTION_LOCK_EXCEPT == PhysicalSectionDataStru[bufIndex].LockState)
				|| (PHYSICAL_SECTION_LOCK_DELAY == PhysicalSectionDataStru[bufIndex].LockState))
			{ /*正常锁闭->空闲*/
				if (PhysicalSectionDataStru[bufIndex].RLockBelongRouteId == routeId)
				{            
					/*属于本进路的区段设置空闲*/
					if (PhysicalSectionDataStru[bufIndex].PLockBelongRouteId == 0u)
					{
						/*无保护锁闭*/
						PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO;

						PhysicalSectionDataStru[bufIndex].LockDirection = 0u;  /*清除区段锁闭方向*/
					}
					else
					{
						/*有保护锁闭*/
						PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_PROTECT;  /*###设置防护锁闭*/
					}

					PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u;     /*设置区段进路锁闭所属进路ID*/

					PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0u;  /*清除区段延时解锁起始周期*/

					PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u;  /*清除区段延时锁闭区故解时间*/

				}
				else if (PhysicalSectionDataStru[bufIndex].PLockBelongRouteId == routeId)
				{
					/*有其他锁闭同时存在的防护锁闭*/
					PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0u;     /*清除区段防护锁闭所属进路ID*/
				}
				else
				{
					
					/*不属于本进路*/
				}
			}
			else
			{
				if ((PHYSICAL_SECTION_LOCK_PROTECT == PhysicalSectionDataStru[bufIndex].LockState) &&
					(PhysicalSectionDataStru[bufIndex].PLockBelongRouteId != routeId))
				{

					/*防护锁闭->空闲且不属于本进路锁闭的防护区段*/
				}
				else
				{
					PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO;  /*###设置未锁闭*/

					PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u;     /*设置区段进路锁闭所属进路ID*/
					PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0u;     /*设置区段防护锁闭所属进路ID*/
					PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0u;  /*清除区段延时解锁起始周期*/
					PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u;  /*清除区段延时锁闭区故解时间*/
					PhysicalSectionDataStru[bufIndex].LockDirection = 0u;  /*清除区段锁闭方向*/
				}
			}
		}
		else if (PHYSICAL_SECTION_LOCK_NORMAL == lockState)
		{ /*正常锁闭*/

			PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置正常锁闭*/

			PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = routeId;
			PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection;  /*设置区段锁闭方向*/
		}
		else if (PHYSICAL_SECTION_LOCK_EXCEPT == lockState)
		{ /*异常锁闭*/

			PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置异常锁闭*/
			/*PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u;  清除区段延时锁闭区故解时间*/
		}
		else if (PHYSICAL_SECTION_LOCK_PROTECT == lockState)
		{ /*防护锁闭*/

			if (PHYSICAL_SECTION_LOCK_NO == PhysicalSectionDataStru[bufIndex].LockState)
			{ /*当前未锁闭*/

				PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置防护锁闭*/
			}

			PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = routeId;
			PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection;  /*设置区段锁闭方向*/
		}
		else if (PHYSICAL_SECTION_LOCK_DELAY == lockState)
		{ /*延时解锁*/

			PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置延时解锁*/
		}
		else if (PHYSICAL_SECTION_LOCK_FAULTDELAY == lockState)
		{ /*区故解延时解锁*/

			PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置区故解延时解锁*/
		}
		else
		{ 
			/*区段状态无效*/
		}
	}
}

/*
* 功能描述： 设置非本联锁指定ID物理区段锁闭状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 lockState, 锁闭状态
*            const UINT16 routeId, 进路ID
*            const UINT8 lockDirection, 锁闭方向
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetPhySecLockStateOtherCI(const UINT16 phySectionId, const UINT8 lockState, const UINT16 routeId, const UINT8 lockDirection)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 returnValue = CI_SUCCESS;
	UINT8 cLocalCiId = 0U;
	UINT16 wCurRouteId = 0U;
	UINT8 cCurRouteBelongCiId = 0U;   /*当前锁闭进路所属CI*/
	UINT8 cInputRouteBelongCiId = 0U;  /*入参进路所属CI*/
	UINT8 cRouteState = 0U;
	UINT8 chNewRouteCurState = 0U;/*新的进路当前状态*/
	UINT8 chNewRoutePreState = 0U;/*新的进路之前状态*/
	UINT8 chOldRoutePreState = 0U;/*旧的进路之前状态*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/	
	
	if (bufIndex >= PHYSICAL_SECTION_SUM_MAX)
	{
	    returnValue = CI_ERROR;
	}
	else
	{
		cLocalCiId = GetSystemParaLocalCiId();
		cInputRouteBelongCiId = GetRouteBelongCiId(routeId);
		if((PHYSICAL_SECTION_LOCK_PROTECT==PhysicalSectionDataStru[bufIndex].LockState) &&  (GetPhySecBelongCiId(phySectionId)== GetSystemParaLocalCiId())
			&& ((PHYSICAL_SECTION_LOCK_NORMAL != lockState) || (cLocalCiId == cInputRouteBelongCiId)))
		{/*保护区段的锁闭状态是由保护区段所属的联锁来更新处理的，若待设置锁闭状态为正常锁闭且锁闭所属进路非本控区，考虑为ZHG由防护锁闭转为正常锁闭，需刷新锁闭状态*/
			returnValue = CI_SUCCESS;	
		}
	    else if (PHYSICAL_SECTION_LOCK_START == lockState)
		{ /*上电锁闭*/
	    
			PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置上电锁闭*/
		}
		else if (PHYSICAL_SECTION_LOCK_NO == lockState)
		{ /*未锁闭*/
	    
			if ((PHYSICAL_SECTION_LOCK_NORMAL == PhysicalSectionDataStru[bufIndex].LockState)
	           || (PHYSICAL_SECTION_LOCK_EXCEPT == PhysicalSectionDataStru[bufIndex].LockState)
	           || (PHYSICAL_SECTION_LOCK_DELAY == PhysicalSectionDataStru[bufIndex].LockState))
			{ /*正常锁闭->空闲*/
			
				if (GetRouteBelongCiId(PhysicalSectionDataStru[bufIndex].RLockBelongRouteId) == GetSystemParaLocalCiId())
				{
				}
				else
				{
					/*属于本进路的区段设置空闲*/
					if (PhysicalSectionDataStru[bufIndex].PLockBelongRouteId == 0u)
					{
						/*无保护锁闭*/
						PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO;
					
						PhysicalSectionDataStru[bufIndex].LockDirection = 0u;  /*清除区段锁闭方向*/
					}
					else
					{
						/*有保护锁闭*/
						PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_PROTECT;  /*###设置防护锁闭*/
					}
				
					PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u;     /*设置区段进路锁闭所属进路ID*/
				
					PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0u;  /*清除区段延时解锁起始周期*/
				
					PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u;  /*清除区段延时锁闭区故解时间*/
				}
	        }
	        else
			{
	            if (PHYSICAL_SECTION_LOCK_PROTECT == PhysicalSectionDataStru[bufIndex].LockState)
	            {/*本物理区段不属于本联锁且当前锁闭状态是保护锁闭，本物理区段的锁闭状态采用此物理区段所属联锁发来的锁闭状态*/
	                PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO;  /*###设置未锁闭*/
            
	                PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0;     /*设置区段进路锁闭所属进路ID*/
	                PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0;     /*设置区段防护锁闭所属进路ID*/
	                PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0;  /*清除区段延时解锁起始周期*/
	                PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0;  /*清除区段延时锁闭区故解时间*/
	                PhysicalSectionDataStru[bufIndex].LockDirection = 0;  /*清除区段锁闭方向*/
	            }

				if (0U == PhysicalSectionDataStru[bufIndex].LockState)
				{/*此物理区段不属于本联锁，且还未收到过本物理区段的锁闭状态信息时本物理区段的锁闭状态采用此物理区段所属联锁发来的锁闭状态*/
					PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO;  /*###设置未锁闭*/
				
	                PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u;     /*设置区段进路锁闭所属进路ID*/
	                PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0u;     /*设置区段防护锁闭所属进路ID*/
	                PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0u;  /*清除区段延时解锁起始周期*/
	                PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u;  /*清除区段延时锁闭区故解时间*/
	                PhysicalSectionDataStru[bufIndex].LockDirection = 0u;  /*清除区段锁闭方向*/
				}

				if((GetSystemParaLocalCiId()!= GetPhySecBelongCiId(phySectionId)) && (PhysicalSectionDataStru[bufIndex].LockState == PHYSICAL_SECTION_LOCK_START))
				{/*相邻联锁在未上电解锁前发送了PHYSICAL_SECTION_LOCK_START状态，在上电解锁后发送PHYSICAL_SECTION_LOCK_NO
				   本联锁要将其更新为PHYSICAL_SECTION_LOCK_NO*/
					PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO;  /*###设置未锁闭*/
	                PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u;     /*设置区段进路锁闭所属进路ID*/	
					PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0u;     /*设置区段防护锁闭所属进路ID*/
	                PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0u;  /*清除区段延时解锁起始周期*/
	                PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u;  /*清除区段延时锁闭区故解时间*/
	                PhysicalSectionDataStru[bufIndex].LockDirection = 0u;  /*清除区段锁闭方向*/
				}				
	        }
			SetProtectSecLockDelayTimeFlag(phySectionId, PROTECTSECLOCKDELAY_NO);
			SetPhySecLockDelayStartCycNum(phySectionId, 0u);  /*清物理区段延时锁闭周期号*/

		}
		else if (PHYSICAL_SECTION_LOCK_NORMAL == lockState)
		{ /*正常锁闭*/
			if (cInputRouteBelongCiId == cLocalCiId)
			{
				/*不处理*/
			}
			else
			{
				wCurRouteId = GetPhySecRLockBelongRouteId(phySectionId);
				cCurRouteBelongCiId = GetRouteBelongCiId(wCurRouteId);
				cRouteState = GetRouteState(wCurRouteId);
				chOldRoutePreState = GetRoutePreState(wCurRouteId);
				chNewRouteCurState = GetRouteState(routeId);
				chNewRoutePreState = GetRoutePreState(routeId);

				if ((routeId != wCurRouteId) && (cLocalCiId == cCurRouteBelongCiId)
					&& ((ROUTE_STATE_HALF_UNLOCK == cRouteState)
						|| (ROUTE_STATE_FIRST_LOCK == chNewRouteCurState) || (ROUTE_STATE_FIRST_LOCK == chNewRoutePreState)
						|| (ROUTE_STATE_FIRST_LOCK == cRouteState) || (ROUTE_STATE_FIRST_LOCK == chOldRoutePreState)))
				{
					/*冲锁闭时，新的不属于本控区的进路当前为初锁或之前为初锁，保持原状态（之前初锁主要考虑通信不好）*/
				}
				else
				{
					PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置正常锁闭*/
					PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = routeId;
					PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection;  /*设置区段锁闭方向*/
				}
			}
		}
		else if (PHYSICAL_SECTION_LOCK_EXCEPT == lockState)
		{ /*异常锁闭*/
			if (GetRouteBelongCiId(PhysicalSectionDataStru[bufIndex].RLockBelongRouteId) == GetSystemParaLocalCiId())
			{				
			}
			else
			{
				if ((GetRouteBelongCiId(routeId) != GetSystemParaLocalCiId()) || (PhysicalSectionDataStru[bufIndex].LockState == 0u)|| (PhysicalSectionDataStru[bufIndex].LockState == PHYSICAL_SECTION_LOCK_START))
				{
				    /*
					 * 若发送的区段状态是异常锁闭
					 *   锁闭进路，如果不属于本联锁，则直接更新，锁闭进路属于本联锁，则需要判断下当前进路状态是否是0，如果是0，则认为是初始化时
					 *  重启结果
					 *   
					 * 
					 */
					PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置异常锁闭*/
					PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = routeId;  /*###设置异常锁闭*/
					PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection;  /*YF0083-2431：当进路属于其他控区，区段属于本控区，列车在此区段飞车后，区段出现故障锁闭，重启后会设置该逻辑区段方向为0*/
				}				
							
				/*PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u;  清除区段延时锁闭区故解时间*/
			}
			SetProtectSecLockDelayTimeFlag(phySectionId, PROTECTSECLOCKDELAY_NO);
			SetPhySecLockDelayStartCycNum(phySectionId, 0u);  /*清物理区段延时锁闭周期号*/

		}
		else if (PHYSICAL_SECTION_LOCK_PROTECT == lockState)
		{
		    /*防护锁闭*/
			cCurRouteBelongCiId = GetRouteBelongCiId(PhysicalSectionDataStru[bufIndex].RLockBelongRouteId);
			if (GetPhySecBelongCiId(phySectionId) == GetSystemParaLocalCiId())
			{
				if ((cLocalCiId != cCurRouteBelongCiId) && (cCurRouteBelongCiId == cInputRouteBelongCiId))
				{
					/*考虑为ZHG进路锁闭所属进路解锁但防护锁闭所属进路未解锁场景，需更新锁闭状态*/
					PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*设置防护锁闭*/
					PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = routeId;
					PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection;  /*设置区段锁闭方向*/
					if (0U != PhysicalSectionDataStru[bufIndex].RLockBelongRouteId)
					{
						PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0U;
					}
				}
				else
				{
					/*如果物理区段为本联锁，此区段防护锁闭由自己处理，无需更新*/
				}
			}
			else
			{
				if ((cLocalCiId == cCurRouteBelongCiId) && (cLocalCiId == cInputRouteBelongCiId))
				{
					/*解决ZHG锁闭问题，当前进路锁闭所属进路和防护锁闭所属进路均为本控区，不刷新锁闭状态*/
				}
				else
				{
					PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置防护锁闭*/

					PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = routeId;
					PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection;  /*设置区段锁闭方向*/
					if ((PhysicalSectionDataStru[bufIndex].RLockBelongRouteId != 0u) && (GetRouteBelongCiId(PhysicalSectionDataStru[bufIndex].RLockBelongRouteId) != GetSystemParaLocalCiId()))
					{
						PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u;
					}
				}
			}
		}
		else if (PHYSICAL_SECTION_LOCK_DELAY == lockState)
		{ /*延时解锁*/
			/* 不存在从未锁闭到延迟锁闭状态 */
			if (GetRouteBelongCiId(routeId) == GetSystemParaLocalCiId())
			{/*若进路属于本联锁则不更新*/
			}
			else
			{
				if(PHYSICAL_SECTION_LOCK_NO != PhysicalSectionDataStru[bufIndex].LockState)
				{
					PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置延时解锁*/
					PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = routeId;/*设置延时解锁进路ID*/
					PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection;  /*设置区段锁闭方向*/
				}
			}
		}
		else if (PHYSICAL_SECTION_LOCK_FAULTDELAY == lockState)
		{ /*区故解延时解锁*/
	    /* 不存在从未锁闭到延迟锁闭状态 */
			if(PHYSICAL_SECTION_LOCK_NO != PhysicalSectionDataStru[bufIndex].LockState)
			{			
				PhysicalSectionDataStru[bufIndex].LockState = lockState;  /*###设置区故解延时解锁*/
			}
		}
	    else
	    { /*区段状态无效*/

	        returnValue = CI_ERROR;
		}
	}

	
	return returnValue;
}

/*
* 功能描述： 获取指定ID物理区段封锁状态
* 参数说明： const UINT16 phySectionId, 物理区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 封锁      
*/
UINT8 GetPhySecFLockState(const UINT16 phySectionId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
    UINT8 retVal = CI_ERROR;
    
    bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
    
    if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
    {
        retVal = PhysicalSectionDataStru[bufIndex].FLockState;
    }
    else
    {
        retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段封锁状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 fLockState, 封锁状态
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetPhySecFLockState(const UINT16 phySectionId, const UINT8 fLockState)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
    UINT8 retVal = CI_SUCCESS;
    
    bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
    
    if (bufIndex >= PHYSICAL_SECTION_SUM_MAX)
    {
        retVal = CI_ERROR;
    }
	else
	{
		if ((fLockState == PHYSICAL_SECTION_FLOCK_NO) || (fLockState == PHYSICAL_SECTION_FLOCK_YES))
		{/*封锁状态为封锁或未封锁*/

			PhysicalSectionDataStru[bufIndex].FLockState = fLockState;
			retVal = CI_SUCCESS;
		}
		else
		{/*封锁状态不正确*/
			retVal = CI_ERROR;
		}
	}
	return retVal;


}

/*
* 功能描述： 获取指定ID物理区段进路锁闭所属进路ID
* 参数说明： const UINT16 phySectionId, 物理区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 进路锁闭所属进路ID      
*/
UINT16 GetPhySecRLockBelongRouteId(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].RLockBelongRouteId;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述：设置指定物理区段防护锁闭所属进路ID
* 参数说明：const UINT16 wPhySectionId 物理区段ID
*           const UINT16 wPLockRouteId 防护锁闭所属进路ID
* 返 回 值：无
* Created By LQ 2024.06.11
*/
void SetPhySecPLockRouteId(const UINT16 wPhySectionId, const UINT16 wPLockRouteId)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/

	wBufIndex = GetPhySecConfigBufIndex(wPhySectionId);  /*获取区段数组下标*/

	if ((PHYSICAL_SECTION_SUM_MAX > wBufIndex) && (ROUTE_SUM_MAX > wPLockRouteId))
	{
		PhysicalSectionDataStru[wBufIndex].PLockBelongRouteId = wPLockRouteId;  /*设置防护锁闭所属进路ID*/
	}
	else
	{
		/*入参非法，不处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段防护锁闭所属进路ID
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 防护锁闭所属进路ID    
*/
UINT16 GetPhySecPLockBelongRouteId(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].PLockBelongRouteId;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 获取指定ID物理区段锁闭方向
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 锁闭方向      
*/
UINT8 GetPhySecLockDirection(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].LockDirection;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 获取指定ID物理区段之前采集状态
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 之前采集状态      
*/
UINT8 GetPhySecPreOccupyState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].PreOccupyState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 设置指定ID物理区段之前采集状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 preCollState, 之前采集状态
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetPhySecPreOccupyState(const UINT16 phySectionId, const UINT8 preCollState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_SUCCESS;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((SECTION_OCCUPY_NO == preCollState) || (SECTION_OCCUPY_YES == preCollState))
		{
			PhysicalSectionDataStru[bufIndex].PreOccupyState = preCollState;  /*物理区段当前采集状态*/

			retVal = CI_SUCCESS;
		}
		else
		{
			retVal = CI_ERROR;
		}
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 获取指定ID物理区段当前采集状态
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 当前采集状态      
*/
UINT8 GetPhySecCurOccupyState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].CurOccupyState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 获取指定ID物理区段当前Oc的轨道采集状态
* 参数说明： const UINT16 phySectionId, 区段ID
* 返回值  ： 0: 获取数据失败
*			>0: 当前采集状态
*/
UINT8 GetPhySecCurOcGdOccupyState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].CurOcGdOccupyState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段当前Oc轨道采集状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 curCollState, 当前采集状态
* 返回值  ： 无
*			  
*/
void SetPhySecCurOcGdOccupyState(const UINT16 phySectionId, const UINT8 curCollState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((SECTION_OCCUPY_NO == curCollState) || (SECTION_OCCUPY_YES == curCollState) ||
			(SECTION_OCCUPY_FAULT == curCollState))
		{
			PhysicalSectionDataStru[bufIndex].PreOcGdOccupyState = PhysicalSectionDataStru[bufIndex].CurOcGdOccupyState;  /*设置物理区段之前采集状态*/
			PhysicalSectionDataStru[bufIndex].CurOcGdOccupyState = curCollState;  /*物理区段当前采集状态*/
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段当前计轴区段轨道采集状态
* 参数说明： const UINT16 phySectionId, 区段ID
* 返回值  ： 0: 获取数据失败
*			>0: 当前采集状态
*/
UINT8 GetPhySecCurAxisGdOccupyState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].CurAxleGdOccupyState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段当前计轴占用采集状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 curCollState, 当前采集状态
* 返回值  ： 0: 设置失败
*			 1: 设置成功
*/
UINT8 SetPhySecCurAxisGdOccupyState(const UINT16 phySectionId, const UINT8 curCollState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > bufIndex)
	{
		if ((SECTION_OCCUPY_NO == curCollState) || (SECTION_OCCUPY_YES == curCollState) || (SECTION_OCCUPY_FAULT == curCollState))
		{
			PhysicalSectionDataStru[bufIndex].PreAxleGdOccupyState = PhysicalSectionDataStru[bufIndex].CurAxleGdOccupyState;  /*设置物理区段之前采集状态*/
			PhysicalSectionDataStru[bufIndex].CurAxleGdOccupyState = curCollState;  /*物理区段当前采集状态*/

			retVal = CI_SUCCESS;
		}
		else
		{
			retVal = CI_ERROR;
		}
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段当前采集状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 curCollState, 当前采集状态
* 返回值  ： 无
*			        
*/
void SetPhySecCurOccupyState(const UINT16 phySectionId, const UINT8 curCollState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 dwCurCycNum = 0U;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((SECTION_OCCUPY_NO == curCollState) || (SECTION_OCCUPY_YES == curCollState))
		{
			dwCurCycNum = Get2oo2CurCycleNum();

			if (SECTION_OCCUPY_NO == curCollState)
			{
				PhysicalSectionDataStru[bufIndex].SecColOccupyStartCycNum = 0U;  /*设置物理区段采集占用起始周期为0*/
			}
			else if (0U == PhysicalSectionDataStru[bufIndex].SecColOccupyStartCycNum)
			{
				PhysicalSectionDataStru[bufIndex].SecColOccupyStartCycNum = dwCurCycNum;  /*更新物理区段采集占用起始周期*/
			}
			else
			{
				/*不更新*/
			}

			PhysicalSectionDataStru[bufIndex].PreOccupyState = PhysicalSectionDataStru[bufIndex].CurOccupyState;  /*设置物理区段之前采集状态*/
			PhysicalSectionDataStru[bufIndex].CurOccupyState = curCollState;  /*物理区段当前采集状态*/
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段之前融合状态
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 当前融合状态      
*/
UINT8 GetPhySecPreMergeState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;
	
	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
	
	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].PreMergeOccupyState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 获取指定ID物理区段当前融合状态
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 当前融合状态      
*/
UINT8 GetPhySecCurMergeState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].CurMergeOccupyState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 获取指定ID物理区段当前与占用原则融合状态
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 当前融合状态      
*/
UINT8 GetPhySecCurAndMergeState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].CurAndMergeOccupyState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段当前融合状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 curProcState, 当前融合状态
* 返回值  ： 无
*			       
*/
void SetPhySecCurMergeState(const UINT16 phySectionId, const UINT8 curProcState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((SECTION_OCCUPY_NO == curProcState) || (SECTION_OCCUPY_YES == curProcState))
		{

            /*占用状态变化*/            
            if (PhysicalSectionDataStru[bufIndex].CurMergeOccupyState != curProcState)
            {
                /*物理区段之前融合状态*/
                PhysicalSectionDataStru[bufIndex].PreMergeOccupyState = PhysicalSectionDataStru[bufIndex].CurMergeOccupyState;
            }

			PhysicalSectionDataStru[bufIndex].CurMergeOccupyState = curProcState;  /*物理区段当前融合状态*/

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

/*
* 功能描述： 设置指定ID物理区段当前与占用原则融合状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 curProcState, 当前融合状态
* 返回值  ： 无
*			        
*/
void SetPhySecCurAndMergeState(const UINT16 phySectionId, const UINT8 curProcState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((SECTION_OCCUPY_NO == curProcState) || (SECTION_OCCUPY_YES == curProcState))
		{

			/*占用状态变化*/            
			if (PhysicalSectionDataStru[bufIndex].CurAndMergeOccupyState != curProcState)
			{
				/*物理区段之前融合状态*/
				PhysicalSectionDataStru[bufIndex].PreAndMergeOccupyState = PhysicalSectionDataStru[bufIndex].CurAndMergeOccupyState;
			}

			PhysicalSectionDataStru[bufIndex].CurAndMergeOccupyState = curProcState;  /*物理区段当前融合状态*/
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 设置指定ID物理区段之前融合状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 curProcState, 之前融合状态
* 返回值  ： 无
*			        
*/
void SetPhySecPreMergeState(const UINT16 phySectionId, const UINT8 preProcState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((SECTION_OCCUPY_NO == preProcState) || (SECTION_OCCUPY_YES == preProcState))
		{

				/*物理区段之前融合状态*/
			PhysicalSectionDataStru[bufIndex].PreMergeOccupyState = preProcState;

		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}
/*
* 功能描述： 清除指定ID物理区段之前融合状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 curProcState, 当前融合状态
* 返回值  ： 无 
*			       
*/
void CleanPhySecPreMergeState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
        /*物理区段之前融合状态*/
        PhysicalSectionDataStru[bufIndex].PreMergeOccupyState = SECTION_OCCUPY_NO;

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


/*
* 功能描述： 获取指定ID物理区段停稳状态
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 停稳状态      
*/
UINT8 GetPhySecStopSteadyFlag(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].StopSteadyFlag;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 设置指定ID物理区段停稳状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 stopSteadyState, 停稳状态
* 返回值  ：无
*			       
*/
void SetPhySecStopSteadyFlag(const UINT16 phySectionId, const UINT8 stopSteadyState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHYSICAL_SECTION_STOPSTEADY_NO == stopSteadyState) || (PHYSICAL_SECTION_STOPSTEADY_YES == stopSteadyState))
		{

			PhysicalSectionDataStru[bufIndex].StopSteadyFlag = stopSteadyState;  /*物理区段停稳状态*/

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


/*
* 功能描述： 获取指定ID物理区段占用持续周期计数
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 占用持续周期计数      
*/
UINT32 GetSecCurOccupyStartCycNum(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].SecCurOccupyStartCycNum;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 获取指定ID物理区段占用变空闲持续周期计数
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 占用持续周期计数      
*/
UINT32 GetSecOccuToClearStartCycNum(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].SecOccuToClearStartCycNum;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段占用持续周期计数
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 cycCount, 占用持续周期计数
* 返回值  ：无
*			        
*/
void SetSecCurOccupyStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		PhysicalSectionDataStru[bufIndex].SecCurOccupyStartCycNum = startCycNum;
	}
	else
	{
		/*不做处理*/
	}
}


/*
* 功能描述： 设置指定ID物理区段UT或CT占用起始周期号
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const  UINT32 startCycNum, 区段占用起始周期号
* 返回值  ： 无
*			  
*/
void SetSecUtOrCtOccuStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		PhysicalSectionDataStru[bufIndex].UtOrCtOccuStartCycNum = startCycNum;
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段UT或CT占用起始周期号
* 参数说明： const UINT16 phySectionId, 物理区段ID
* 返回值  ：  0: 获取数据失败
*			>0: 占用持续周期计数     
*/
UINT32 GetSecUtOrCtOccuStartCycNum(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].UtOrCtOccuStartCycNum;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段占用变空闲持续周期计数
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 cycCount, 占用持续周期计数
* 返回值  ： 无
*			   
*/
void SetSecOccuToClearStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		PhysicalSectionDataStru[bufIndex].SecOccuToClearStartCycNum = startCycNum;
	}
	else
	{
		/*不做处理*/
	}
}


/*
* 功能描述： 获取指定ID物理区段自动解锁起始周期号
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 自动解锁起始周期号      
*/
UINT32 GetPhySecAutoUnlockStartCycNum(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 设置指定ID物理区段自动解锁起始周期号
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT32 startCycNum, 自动解锁起始周期号
* 返回值  ： 无
*			       
*/
void SetPhySecAutoUnlockStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = startCycNum;  /*物理区段自动解锁起始周期号*/
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段区故解解锁起始周期号
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 自动解锁起始周期号      
*/
UINT32 GetPhySecFaultUnlockStartCycNum(const UINT16 phySectionId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
    UINT32 retVal =  CI_ERROR;
    
    bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
    
    if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
    {
        retVal = PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum;
    }
    else
    {
        retVal = CI_ERROR;
    }
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段区故解解锁起始周期号
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT32 startCycNum, 自动解锁起始周期号
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetPhySecFaultUnlockStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
    UINT8 retVal = CI_SUCCESS;
    
    bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
    
    if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
    {
        PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = startCycNum;  /*物理区段自动解锁起始周期号*/
        
        retVal = CI_SUCCESS;
    }
    else
    {
        retVal = CI_ERROR;
    }
	return retVal;
}


/*
* 功能描述： 物理区段锁闭状态有效性检查
* 参数说明： const UINT8 lockState, 锁闭状态
* 返回值  ： 0: 数据无效
*			 1: 数据有效
*/
UINT8 PhySecLockStateValidCheck(const UINT8 lockState)
{
	UINT8 retVal = CI_SUCCESS;
    if ((PHYSICAL_SECTION_LOCK_START == lockState) || 
	    (PHYSICAL_SECTION_LOCK_NO == lockState) || 
	    (PHYSICAL_SECTION_LOCK_NORMAL ==lockState) || 
		(PHYSICAL_SECTION_LOCK_EXCEPT == lockState) || 
		(PHYSICAL_SECTION_LOCK_PROTECT == lockState) || 
		(PHYSICAL_SECTION_LOCK_DELAY == lockState) ||
		(PHYSICAL_SECTION_LOCK_FAULTDELAY == lockState))
	{
	    retVal = CI_SUCCESS;
	}
	else
	{
	    retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 获取指定ID物理区段计轴复位起始周期号
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 计轴复位起始周期号      
*/
UINT32 GetPhySecResetStartCycNum(const UINT16 phySectionId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
    UINT32 retVal = CI_ERROR;
    
    bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
    
    if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
    {
        retVal = PhysicalSectionDataStru[bufIndex].SectionResetStartCycNum;
    }
    else
    {
        retVal = CI_ERROR;
    }
	return retVal;
}

void SetPhySecSectionResetType(const UINT16 phySectionId, const UINT8 resetType)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		PhysicalSectionDataStru[bufIndex].SectionResetType = resetType;  /*物理区段计轴复位类型*/
	}
	else
	{
		/*不做处理*/
	}
}

UINT8 GetPhySecSectionResetType(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].SectionResetType;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段计轴复位起始周期号
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT32 startCycNum, 计轴复位起始周期号
* 返回值  ： 无
*			        
*/
void SetPhySecResetStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
    
    bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
    
    if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
    {
        PhysicalSectionDataStru[bufIndex].SectionResetStartCycNum = startCycNum;  /*物理区段计轴复位起始周期号*/
    }
    else
    {
       /*不做处理*/
    }
}



/*
* 功能描述： 获取指定ID保护区段延时锁闭标志
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 保护区段锁闭延时标志      
*/
UINT8 GetProtectSecLockDelayTimeFlag(const UINT16 phySectionId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
    UINT8 retVal = CI_ERROR;
    
    bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
    
    if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
    {
        retVal = PhysicalSectionDataStru[bufIndex].ProtectSecLockDelayTimeFlag;
    }
    else
    {
        retVal = CI_ERROR;
    }	
	return retVal;
}

/*
* 功能描述： 设置指定ID保护区段延时锁闭标志
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT32 startCycNum, 计轴复位起始周期号
* 返回值  ： 无
*			    
*/
void SetProtectSecLockDelayTimeFlag(const UINT16 phySectionId, const UINT8 delayTimeFlag)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
    
    bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/
    
    if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
    {
        PhysicalSectionDataStru[bufIndex].ProtectSecLockDelayTimeFlag = delayTimeFlag;  /*物理区段计轴复位起始周期号*/
        
    }
    else
    {
        /*不设置*/
    }
}


/*
* 功能描述： 比较两个物理区段占用时间
* 参数说明： const UINT16 phySectionId, 本物理区段ID
*			 const UINT16 otherSectionId,  另外一个物理区段ID
* 返回值  ： 0: 失败
*			 1: 成功      
*/
UINT8 CompareOccuTime(const UINT16 sectionId, const UINT16 otherSectionId)
{
	UINT8 retVal = CI_ERROR;
	UINT32 secCurOccupyStartCyc = 0u;
	UINT32 otherSecCurOccupyStartCyc = 0u;
	INT32 cmpResult = 0;

    secCurOccupyStartCyc = GetSecCurOccupyStartCycNum(sectionId);   /*本物理区段开始占用周期号*/
	otherSecCurOccupyStartCyc = GetSecCurOccupyStartCycNum(otherSectionId);   /*另外一个物理区段开始占用周期号*/
	cmpResult =(INT32)(secCurOccupyStartCyc - otherSecCurOccupyStartCyc); 
	if ( (cmpResult > 0) && (otherSecCurOccupyStartCyc != 0u) )		/* 若占用时间为0，则认为其他区段没有车占用，则本区段车可以发车 */
	{

		retVal = CI_ERROR;             /*本物理区段的占用时间大于另一个物理区段的占用时间*/
	} 
	else
	{
		retVal = CI_SUCCESS;				/*本物理区段的占用时间小于另一个物理区段的占用时间*/
	}

	return retVal;
}


/*
* 功能描述： 获取指定ID物理区段Arb状态
* 参数说明： const UINT16 phySectionId, 物理区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: Arb状态      
*/
UINT8 GetPhySecArbState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;                               /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].ArbState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段Arb状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 arbState, Arb状态
* 返回值  ： 无
*			    
*/
void SetPhySecArbState(const UINT16 phySectionId, const UINT8 arbState)
{
	UINT16 bufIndex = 0u;                                                                    /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);                                       /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((AXIS_SECTION_ARB_NO == arbState) || (AXIS_SECTION_ARB_YES == arbState))
		{
			PhysicalSectionDataStru[bufIndex].ArbState = arbState;                         /*物理区段ARB状态*/
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段停止检查状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
* 返回值  ： 0: 获取数据失败
*           >0: 停止检查状态
*/
UINT8 GetPhySectionStopCheckFlag(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].StopCheckFlag;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 设置指定ID物理区段停止检查状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*            const UINT8 stopCheckState, 停止检查状态
* 返回值  ： 无
*             
*/
void SetPhySectionStopCheckFlag(const UINT16 phySectionId, const UINT8 stopCheckState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHYSICAL_STOPCHECK_SET_NO == stopCheckState) || (PHYSICAL_STOPCHECK_SET_YES == stopCheckState))
		{
			PhysicalSectionDataStru[bufIndex].StopCheckFlag = stopCheckState; /*物理区段停止检查状态*/
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段跳跃锁闭状态
* 参数说明： const UINT16 phySectionId, 物理区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 跳跃锁闭状态      
*/
UINT8 GetPhySecJumpLockState(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;                               /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].JumpLockState;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段跳跃锁闭状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 jumpLockState, 跳跃锁闭状态
* 返回值  ： 无
*			        
*/
void SetPhySecJumpLockState(const UINT16 phySectionId, const UINT8 jumpLockState)
{
	UINT16 bufIndex = 0u;                                                                    /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);                                       /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHYSICAL_SECTION_JUMP_LOCK_YES == jumpLockState) || (PHYSICAL_SECTION_JUMP_LOCK_NO == jumpLockState))
		{
			PhysicalSectionDataStru[bufIndex].JumpLockState = jumpLockState;                     /*物理区段跳跃锁闭状态*/
		}
		else
		{
			/*不做处理*/
		}
		/*若是取消跳跃锁闭，则同时取消关联逻辑区段的跳跃锁闭状态*/
		if (PHYSICAL_SECTION_JUMP_LOCK_NO == jumpLockState)
		{
			SetPhyIncludeLogJumpLockState(phySectionId, jumpLockState);
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段跳跃锁闭延时解锁起始周期号
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 跳跃锁闭延时解锁起始周期号      
*/
UINT32 GetPhySecJumpDelayUnlocStartCyc(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].SecJumpDelayUnlockStartCycNum;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段跳跃锁闭延时解锁起始周期号
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT32 startCycNum, 跳跃锁闭延时解锁起始周期号
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetPhySecJumpDelayUnlocStartCyc(const UINT16 phySectionId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_SUCCESS;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		PhysicalSectionDataStru[bufIndex].SecJumpDelayUnlockStartCycNum = startCycNum;  /*物理区段跳跃锁闭延时解锁起始周期号*/

		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 获取指定ID物理区段跳跃锁闭延时解锁设置标志
* 参数说明： const UINT16 phySectionId, 物理区段ID
* 返回值  ： 0: 获取数据失败
*           >0: 跳跃锁闭延时解锁设置标志
*/
UINT8 GetPhySecJumpDelayUnlockFlag(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].JumpLockDelayUnlockFlag;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 设置指定ID物理区段跳跃锁闭延时解锁设置标志
* 参数说明： const UINT16 phySectionId, 物理区段ID
*            const UINT8 jumpDelayUnlockFlag, 跳跃锁闭延时解锁设置标志
* 返回值  ： 0: 设置数据失败
*            1: 设置数据成功
*/
UINT8 SetPhySecJumpDelayUnlockFlag(const UINT16 phySectionId, const UINT8 jumpDelayUnlockFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_SUCCESS;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHYSICAL_JUMPUNLOCK_DELAY_SET_NO == jumpDelayUnlockFlag) || (PHYSICAL_JUMPUNLOCK_DELAY_SET_YES == jumpDelayUnlockFlag))
		{
			PhysicalSectionDataStru[bufIndex].JumpLockDelayUnlockFlag = jumpDelayUnlockFlag; /*跳跃锁闭延时解锁设置标志*/

			retVal = CI_SUCCESS;
		}
		else
		{
			retVal = CI_ERROR;
		}
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述： 获取物理区段封锁状态标志
* 参数说明：UINT16 phySecId   物理区段Id
* 返回值  ： 未封锁: SPKS_STATUS_NO
*			 封锁: SPKS_STATUS_YES      
*/
UINT8 GetPhySecFlockFlag(UINT16 phySecId)
{
	UINT8 spksNum = 0u;			/* spks总数 */
	UINT16 spksId = 0u;			/* spksID */
	UINT16 jj = 0u;        /* 循环索引 */
	UINT8 spksStatus = SPKS_STATUS_NO;       /*SPKS按钮状态*/

	spksNum = GetPhySecSpksSum(phySecId);
	for (jj = 0u;jj < spksNum;jj++)
	{
		spksId = GetPhySecSpksIdBySpksIdx(phySecId,jj);
		if ((spksId > 0u ) && (SPKS_STATUS_YES == GetSpksState(spksId)) && (SPKS_CUT_NO == GetSpksCutState(spksId)))
		{
			spksStatus = SPKS_STATUS_YES;
			break;
		}
	}

	if  ((GetSystemParaLocalCiId() != GetPhySecBelongCiId(phySecId))&&
		(PHYSICAL_SECTION_FLOCK_YES == GetPhySecFLockState(phySecId)))
	{
		spksStatus = SPKS_STATUS_YES;
	} 

	return spksStatus;
}

/*
* 功能描述： 获取指定ID物理区段延时锁闭起始周期号
* 参数说明： const UINT16 phySectionId, 区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 延时解锁起始周期号      
*/
UINT32 GetPhySecLockDelayStartCycNum(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 retVal =  CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].LockDelayStartCycNum;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段延时锁闭起始周期号
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT32 startCycNum, 延时锁闭起始周期号
* 返回值  ： 无
*			       
*/
void SetPhySecLockDelayStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		PhysicalSectionDataStru[bufIndex].LockDelayStartCycNum = startCycNum;  /*物理区段延时锁闭起始周期号*/
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 置所有物理区段的停稳信息为未停稳
* 参数说明： void
* 返回值  ： void      
*/
void ResetPhySecStopSteadyInfo(void)
{
	UINT16 phySectionDataSum = 0u;					/*物理区段总数*/
	UINT16 phySectionId = 0u;						/*物理区段ID*/
	UINT16 ii = 0u;									/*游标*/
	phySectionDataSum = GetPhySecCurSum();			/*本联锁物理区段总数目,只有本联锁物理区段才重置未停稳状态*/

	if (phySectionDataSum >= PHYSICAL_SECTION_SUM_MAX)
	{/*配置数据总数错误*/
	}
	else
	{
		for (ii = 0u; ii < phySectionDataSum; ii++)
		{
			phySectionId = GetPhySecId(ii);/*获取配置文件中该索引下的物理区段ID*/
			PhysicalSectionDataStru[phySectionId].StopSteadyFlag = PHYSICAL_SECTION_STOPSTEADY_NO;
		}
	}
}

/*
* 功能描述： 设置互联互通其它联锁物理区段锁闭状态
* 参数说明：
UINT16 phySectionId, 物理区段ID
const UINT8 lockState,锁闭状态
* 返回值  ：
无
*/
void SetPhySecLockStateHlht(UINT16 phySectionId, const UINT8 lockState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 preLockState = 0u;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		preLockState = PhysicalSectionDataStru[bufIndex].LockState;

		if(PHYSICAL_SECTION_LOCK_START != preLockState)
		{
			PhysicalSectionDataStru[bufIndex].LockState = lockState;
		}
		else
		{
			;
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 设置互联互通联锁到联锁通信接口物理区段上电锁闭状态
* 参数说明： UINT16 phySectionId，物理区段ID
*			const UINT8 lockState， 上电锁闭状态
* 返回值  ： 无
*          CI_ERROR，失败
*/
void SetPhySecStartLockStateHlht(UINT16 phySectionId, const UINT8 lockState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 preLockState = 0u;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		preLockState = PhysicalSectionDataStru[bufIndex].LockState;

		if(PHYSICAL_SECTION_LOCK_START != preLockState)
		{
			if(PHYSICAL_SECTION_LOCK_START == lockState)
			{				
				PhysicalSectionDataStru[bufIndex].LockState = lockState;
			}
		}
		else
		{
			PhysicalSectionDataStru[bufIndex].LockState = lockState;
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 设置互联互通其它联锁物理区段进路锁闭所属的进路ID
* 参数说明：
UINT16 phySectionId, 物理区段ID
const UINT16 routeId,物理区段进路锁闭所属进路ID
* 返回值  ：
无
*/
void SetPhySecRLockRouteIdHlht(UINT16 phySectionId, const UINT16 routeId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if(PHYSICAL_SECTION_LOCK_START != PhysicalSectionDataStru[bufIndex].LockState)
		{
			PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = routeId;
		}
		else
		{
			if(0u == routeId)
			{
				PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u;			
			}
			else
			{
				;
			}
		}
	}
	else
	{
		/*不做处理*/
	}
}
/*
* 功能描述： 设置互联互通其它联锁物理区段保护锁闭所属的进路ID
* 参数说明：
UINT16 phySectionId, 物理区段ID
const UINT16 routeId,物理区段保护锁闭所属的进路ID
* 返回值  ：
无
*/
void SetPhySecPLockRouteIdHlht(UINT16 phySectionId, const UINT16 routeId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if(PHYSICAL_SECTION_LOCK_START != PhysicalSectionDataStru[bufIndex].LockState)
		{
			PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = routeId;
		}
		else
		{
			if(0U == routeId)
			{
				PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0u;
			}
			else
			{
				;
			}
		}

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

/*
* 功能描述： 设置互联互通其它联锁物理区段的锁闭方向
* 参数说明：
UINT16 phySectionId, 物理区段ID
const UINT8 lockDir,物理区段锁闭方向
* 返回值  ：
无
*/
void SetPhySecLockDirHlht(UINT16 phySectionId, const UINT8 lockDir)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if(PHYSICAL_SECTION_LOCK_START != PhysicalSectionDataStru[bufIndex].LockState)
		{
			PhysicalSectionDataStru[bufIndex].LockDirection = lockDir;
		}
		else
		{
			if(CI_SYSTEM_DIRECTION_NONE == lockDir)
			{
				PhysicalSectionDataStru[bufIndex].LockDirection = CI_SYSTEM_DIRECTION_NONE;
			}
			else
			{
				;
			}
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 设置物理区段封锁类型
* 参数说明：
UINT16 phySectionId, 物理区段ID
const UINT8 fLockType,物理区段封锁类型
* 返回值  ：
无
*/
void SetPhySecFLockType(const UINT16 phySectionId, const UINT8 fLockType)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHY_SEC_FLOCK_TYPE_NONE == fLockType) || (PHY_SEC_FLOCK_TYPE_SPKS == fLockType) || (PHY_SEC_FLOCK_TYPE_CMD == fLockType)|| (PHY_SEC_FLOCK_TYPE_SPKSCMD == fLockType))
		{
			PhysicalSectionDataStru[bufIndex].FLockType = fLockType;
		}
	}
	
}

/*
* 功能描述： 获取物理区段封锁类型
* 参数说明： const UINT16 phySectionId, 区段ID
* 返回值  ： 0: 获取数据失败
*			>0: 物理区段封锁类型
*/
UINT8 GetPhySecFLockType(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].FLockType;
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述： 获取计轴总复位继电器状态有效性
* 参数说明： const UINT16 phySecId, 物理区段ID
* 返回值  ： CI_ERROR 无效
*            CI_SUCCESS 有效
*/
UINT8 GetZFWValidByPhySecId(const UINT16 phySecId)
{
	UINT16 relayId = 0u;
	UINT16 relayCollState = 0u;
	UINT8 retVal = CI_ERROR;

	relayId = GetPhySecZFWRelayId(phySecId);	/*获取该物理区段总复位继电器ID*/

	if ((0u == relayId) || (UINT16_MAX == relayId))
	{
		retVal = CI_SUCCESS;	/*未配置总复位继电器（计轴复位时不进行检查），默认有效*/
	}
	else
	{
		/*联锁配置总复位继电器，判断状态有效性*/
		relayCollState = GetRelayCollState(relayId);	/*获取指定ID总复位继电器状态*/

		if (RELAY_STATE_UP == relayCollState)
		{
			retVal = CI_SUCCESS;	/*总复位继电器为吸起状态时为有效，执行计轴复位功能*/
		}
		else
		{
			retVal = CI_ERROR;		/*总复位继电器为落下状态时为无效，不能进行计轴复位功能*/
		}
	}

	return retVal;
}

/*
* 功能描述： 获取计轴总复位继电器状态有效性
* 参数说明： const UINT16 ciId, ciId
* 返回值  ： UINT16 relayId, 总复位继电器ID
*/
UINT16 GetZFWRelayId(const UINT16 ciId)
{
	UINT16 ii = 0u;               /*循环索引*/
	UINT16 phySecId = 0u;
	UINT16 relayId = 0u;
	UINT16 phySecSum = 0u;
	UINT8 belongCiId = 0u;        /*物理区段所属联锁ID*/

	phySecSum = GetPhySecCurSum();

	for (ii = 0u; ii < phySecSum; ii++)
	{
		phySecId = 0u;	      /*物理区段ID*/
		belongCiId = 0u;       /*物理区段所属联锁ID*/
		
		phySecId = GetPhySecId(ii);/*获取物理区段ID*/
		if ((phySecId > 0u) && (phySecId < PHYSICAL_SECTION_SUM_MAX))
		{
			relayId = GetPhySecZFWRelayId(phySecId);	/*获取该物理区段总复位继电器ID*/
			belongCiId = GetPhySecBelongCiId(phySecId);      /*获取物理区段所属联锁ID*/

			if ((0u == relayId) || (UINT16_MAX == relayId) || (belongCiId != ciId) || (0u == ciId))
			{
				relayId = 0u;/*未配置总复位继电器（计轴复位时不进行检查），默认有效*/
			}
			else
			{
				break;
			}
		} 
	}
	return relayId;
}

/*
* 功能描述： 获取计轴总复位继电器状态有效性
* 参数说明： const UINT16 ciId, ciId
* 返回值  ： UINT16 relayId, 总复位继电器ID
*/
UINT16 GetZFWRelayId_UseVirCI(const UINT16 ciId,UINT8 virCIid)
{
	UINT16 ii = 0u;               /*循环索引*/
	UINT16 phySecId = 0u;
	UINT16 relayId = 0u;
	UINT16 phySecSum = 0u;
	UINT8 belongCiId = 0u;        /*物理区段所属联锁ID*/
    UINT8 belongVirCIid = 0u;

	phySecSum = GetPhySecCurSum();

	for (ii = 0u; ii < phySecSum; ii++)
	{
		phySecId = 0u;	      /*物理区段ID*/
		belongCiId = 0u;       /*物理区段所属联锁ID*/
		
		phySecId = GetPhySecId(ii);/*获取物理区段ID*/
		if ((0u < phySecId) && (PHYSICAL_SECTION_SUM_MAX > phySecId))
		{
			relayId = GetPhySecZFWRelayId(phySecId);	/*获取该物理区段总复位继电器ID*/
			belongCiId = GetPhySecBelongCiId(phySecId);      /*获取物理区段所属联锁ID*/
			belongVirCIid = GetPhySecBelongVirCiId(phySecId);

			if ((0u == relayId) || (UINT16_MAX == relayId) || (belongCiId != ciId) 
				|| (0u == ciId)||(belongVirCIid != virCIid))
			{
				relayId = 0u;/*未配置总复位继电器（计轴复位时不进行检查），默认有效*/
			}
			else
			{
				break;
			}
		} 
	}
	return relayId;
}
/*
* 功能描述：获取指定ID物理区段当前CT或UT占用状态
* 参数说明： const UINT16 phySecId, 物理区段ID
* 返回值  ：0: 获取数据失败
*			0x55 无车占用 0xaa存在UT 0xbb存在CT
*/
UINT8 GetPhySecCurCtOrUtOccupyState(const UINT16 phySecId)
{		
    UINT16 axisSecId = 0u;							/*计轴区段ID*/
    UINT16 axisSecSum = 0u;							/*计轴区段数目*/
	UINT16* axisSecIdBuf = NULL;					/*计轴区段数组*/
    UINT16 logicSecSum = 0u;							/*逻辑区段数目*/
    UINT16* logicSecIdBuf = NULL;					/*逻辑区段Id数组*/
	UINT8 occupyState = LOGICSECTION_OCCUPY_UT;		/*逻辑区段占用状态：初始化为UT占用*/
	UINT16 ii = 0u;					/*游标*/
	UINT16 kk = 0u;					/*游标*/
	UINT8 retVal = CI_ERROR;
	UINT8 chFindOccupy = CI_ERROR;

	axisSecSum = GetPAxisSectionSum(phySecId);					/*获取物理区段包含的计轴区段数目*/
	axisSecIdBuf = GetPAxisSectionIdBuf(phySecId);				/*获取物理区段包含的计轴区段数组*/
	for (ii = 0u;ii < axisSecSum; ii++)
	{
		axisSecId = axisSecIdBuf[ii];							/*计轴区段ID*/
		logicSecSum = GetAxisSecLogSectionSum(axisSecId);		/*获取计轴区段包含的逻辑区段数目*/
		logicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId);	/*获取计轴区段包含的逻辑区段数组*/

		for (kk = 0u; kk< logicSecSum; kk++)
		{
			occupyState = GetLogSecOccupyState(logicSecIdBuf[kk]);
			/*非通信车占用则发送倒计时反馈*/
			/*物理区段当前CT或UT占用状态；只要一个逻辑区段是CT占用，则认为是CT车，退出判断*/
			if (LOGICSECTION_OCCUPY_CT == occupyState)
			{
				retVal = LOGICSECTION_OCCUPY_CT;
				chFindOccupy = CI_SUCCESS;
				break;
			}
			else if(LOGICSECTION_OCCUPY_UT == occupyState)
			{
				retVal = LOGICSECTION_OCCUPY_UT;
				chFindOccupy = CI_SUCCESS;
			}
			else
			{
				/*无车占用，跳过*/
			}
		}
		/* 只要一个逻辑区段是CT占用，则认为是CT车，退出判断 */
		if (LOGICSECTION_OCCUPY_CT == retVal)
		{
			break;
		}
	}
	if (CI_ERROR == chFindOccupy)
	{
		/*所有计轴区段上逻辑区段均无占用*/
		retVal = LOGICSECTION_OCCUPY_NO;
	}
	else
	{
		;/*返回ct或ut占用*/
	}
	return retVal;
}

/*
* 功能描述：获取指定ID物理区段当前通信车占用状态
* 参数说明： const UINT16 phySecId, 物理区段ID
* 返回值  ：0: 获取数据失败
*			>0: 当前占用状态
*/
UINT8 GetPhySecCurTxOccupyState(const UINT16 phySecId)
{
	UINT16 axisSecId = 0u;							/*计轴区段ID*/
	UINT16 axisSecSum = 0u;							/*计轴区段数目*/
	UINT16* axisSecIdBuf = NULL;					/*计轴区段数组*/
	UINT16 logicSecSum = 0u;							/*逻辑区段数目*/
	UINT16* logicSecIdBuf = NULL;					/*逻辑区段Id数组*/
	UINT8 occupyState = LOGICSECTION_OCCUPY_TX;		/*逻辑区段占用状态：初始化为TX（有位置得RM车）占用*/
	UINT16 ii = 0u;					/*游标*/
	UINT8 kk = 0u;					/*游标*/
	UINT8 retVal = CI_ERROR;

	axisSecSum = GetPAxisSectionSum(phySecId);					/*获取物理区段包含的计轴区段数目*/
	axisSecIdBuf = GetPAxisSectionIdBuf(phySecId);				/*获取物理区段包含的计轴区段数组*/

	if ((0u < axisSecSum) && (NULL != axisSecIdBuf))
	{
		for (ii = 0u; ii < axisSecSum; ii++)
		{
			axisSecId = axisSecIdBuf[ii];								/*计轴区段ID*/
			logicSecSum = GetAxisSecLogSectionSum(axisSecId);	/*获取计轴区段包含的逻辑区段数目*/
			logicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId);		/*获取计轴区段包含的逻辑区段数组*/

			if ((0u < logicSecSum) && (NULL != logicSecIdBuf))
			{
				for (kk = 0u; kk < logicSecSum; kk++)
				{
					occupyState = GetLogSecTXOccupyState(logicSecIdBuf[kk]);
					/*非通信车占用则发送倒计时反馈*/
					/*物理区段当前有通信车占用状态；只要一个逻辑区段通信车占用，则认为是通信车占用，退出判断*/
					if (LOGICSECTION_OCCUPY_TX == occupyState)
					{
						retVal = LOGICSECTION_OCCUPY_TX;
						break;
					}
					else if (LOGICSECTION_OCCUPY_NO_TX == occupyState)
					{
						retVal = LOGICSECTION_OCCUPY_NO_TX;
					}
					else
					{
						/*无车占用，跳过*/
					}
				}
				/* 只要一个逻辑区段是TX占用，则认为是TX车，退出判断 */
				if (LOGICSECTION_OCCUPY_TX == retVal)
				{
					break;
				}
				else
				{
					; /*继续执行*/
				}
			}

		}
	}



	return retVal;
}


/*
* 功能描述： 获取指定ID物理区段CT或UT占用状态
* 参数说明： const UINT16 phySecId, 物理区段ID
* 返回值  ：0: 获取数据失败
*			>0: 当前占用状态
*/
UINT8 GetPhySecPreOccState(const UINT16 phySecId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySecId);  /*获取物理区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].UtOrCtOccFlag;	/*获取物理区段占用状态*/
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段CT或UT占用状态
* 参数说明： const UINT16 phySecId, 物理区段ID
			 const UINT8 flag 物理区段之前CT或UT占用状态
* 返回值  ： 无
*			   
*/
void SetPhySecPreOccState(const UINT16 phySecId, const UINT8 flag)
{
	UINT16 bufIndex = 0u;		/*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySecId);  /*获取物理区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((LOGICSECTION_OCCUPY_UT == flag) || (LOGICSECTION_OCCUPY_CT == flag)
			|| (LOGICSECTION_OCCUPY_NO == flag))
		{/*如果当前状态标志为通信车或非通信车占用状态，则进行设置*/
			PhysicalSectionDataStru[bufIndex].UtOrCtOccFlag = flag;
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 设置指定ID物理区段当前计轴预复位状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 preResetState, 计轴预复位状态
* 返回值  ： 无
*			        
*/
void SetPhySecPreResetState(const UINT16 phySectionId, const UINT8 preResetState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHYSICAL_SECTION_PRE_RESET_YES == preResetState) || (PHYSICAL_SECTION_PRE_RESET_NO == preResetState))
		{
			PhysicalSectionDataStru[bufIndex].PhySecPreResetState = preResetState;  /*设置物理区段预复位状态*/
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段计轴预复位状态
* 参数说明： const UINT16 phySecId, 物理区段ID
* 返回值  ：0: 获取数据失败
*			>0: 当前计轴预复位状态
*/
UINT8 GetPhySecPreResetState(const UINT16 phySecId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySecId);  /*获取物理区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].PhySecPreResetState;	/*获取物理区段计轴预复位状态*/
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段当前计轴直接复位状态
* 参数说明： const UINT16 wPhySectionId, 物理区段ID
*			 const UINT8 chResetState, 计轴直接复位状态
* 返回值  ： 无
* by cgh 20250326
*/
void SetPhySecDirectResetState(const UINT16 wPhySectionId, const UINT8 chResetState)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/

	wBufIndex = GetPhySecConfigBufIndex(wPhySectionId);  /*获取区段数组下标*/

	if (wBufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHYSICAL_DIRECT_RESET_YES == chResetState) || (PHYSICAL_DIRECT_RESET_NO == chResetState))
		{
			/*设置物理区段直接复位状态*/
			PhysicalSectionDataStru[wBufIndex].chDirectResetRst = chResetState;
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段计轴直接复位状态
* 参数说明： const UINT16 wPhySecId, 物理区段ID
* 返回值  ：0: 获取数据失败
*			>0: 当前计轴直接复位状态
* by cgh 20250326
*/
UINT8 GetPhySecDirectResetState(const UINT16 wPhySecId)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/
	UINT8 chRetVal = CI_ERROR;

	wBufIndex = GetPhySecConfigBufIndex(wPhySecId);  /*获取物理区段数组下标*/

	if (wBufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		chRetVal = PhysicalSectionDataStru[wBufIndex].chDirectResetRst;	/*获取物理区段计轴直接复位状态*/
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 设置指定ID物理区段当前计轴预复位反馈状态
* 参数说明： const UINT16 wPhySectionId, 物理区段ID
*			 const UINT8 chPreResetBack, 计轴预复位反馈状态
* 返回值  ： 无
* by cgh 20250326
*/
void SetPhySecPreResetBack(const UINT16 wPhySectionId, const UINT8 chPreResetBack)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/

	wBufIndex = GetPhySecConfigBufIndex(wPhySectionId);  /*获取区段数组下标*/

	if (wBufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHY_RESET_BACK_RECIVE_YES == chPreResetBack) || (PHY_RESET_BACK_RECIVE_NO == chPreResetBack))
		{
			PhysicalSectionDataStru[wBufIndex].chPreResetBack = chPreResetBack;  /*设置物理区段预复位反馈状态*/
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段计轴预复位反馈状态
* 参数说明： const UINT16 wPhySecId, 物理区段ID
* 返回值  ：0: 获取数据失败
*			>0: 当前计轴预复位反馈状态
* by cgh 20250326
*/
UINT8 GetPhySecPreResetBack(const UINT16 wPhySecId)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/
	UINT8 chRetVal = CI_ERROR;

	wBufIndex = GetPhySecConfigBufIndex(wPhySecId);  /*获取物理区段数组下标*/

	if (wBufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		chRetVal = PhysicalSectionDataStru[wBufIndex].chPreResetBack;	/*获取物理区段计轴预复位反馈状态*/
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 设置指定ID物理区段当前计轴直接复位反馈状态
* 参数说明： const UINT16 wPhySectionId, 物理区段ID
*			 const UINT8 chResetBack, 计轴直接复位反馈状态
* 返回值  ： 无
* by cgh 20250326
*/
void SetPhySecDirectResetBack(const UINT16 wPhySectionId, const UINT8 chResetBack)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/

	wBufIndex = GetPhySecConfigBufIndex(wPhySectionId);  /*获取区段数组下标*/

	if (wBufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHY_RESET_BACK_RECIVE_YES == chResetBack) || (PHY_RESET_BACK_RECIVE_NO == chResetBack))
		{
			/*设置物理区段直接复位反馈状态*/
			PhysicalSectionDataStru[wBufIndex].chDirectResetBack = chResetBack;
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段计轴直接复位反馈状态
* 参数说明： const UINT16 wPhySecId, 物理区段ID
* 返回值  ：0: 获取数据失败
*			>0: 当前计轴直接复位反馈状态
* by cgh 20250326
*/
UINT8 GetPhySecDirectResetBack(const UINT16 wPhySecId)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/
	UINT8 chRetVal = CI_ERROR;

	wBufIndex = GetPhySecConfigBufIndex(wPhySecId);  /*获取物理区段数组下标*/

	if (wBufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		chRetVal = PhysicalSectionDataStru[wBufIndex].chDirectResetBack;	/*获取物理区段计轴直接复位反馈状态*/
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/**********间隔符JumpLockStateToZC******/

/*
* 功能描述： 获取指定ID物理区段给ZC的跳跃锁闭状态
* 参数说明： const UINT16 phySectionId, 物理区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 跳跃锁闭状态      
*/
UINT8 GetPhySecJumpLockStateToZC(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;                               /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].JumpLockStateToZC;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段给ZC的跳跃锁闭状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 jumpLockState, 跳跃锁闭状态
* 返回值  ： 无
*			    
*/
void SetPhySecJumpLockStateToZC(const UINT16 phySectionId, const UINT8 jumpLockState)
{
	UINT16 bufIndex = 0u;                                                                    /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);                                       /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHYSICAL_SECTION_JUMP_LOCK_YES == jumpLockState) || (PHYSICAL_SECTION_JUMP_LOCK_NO == jumpLockState))
		{
			PhysicalSectionDataStru[bufIndex].JumpLockStateToZC = jumpLockState;            /*给ZC的物理区段跳跃锁闭状态*/
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}
/*
* 功能描述： 设置指定ID物理区段关联计轴区段ARB状态
* 参数说明：  UINT16 phySecId, 物理区段ID
*			  UINT8 arbState, arb状态
* 返回值  ： CI_ERROR: 设置失败
*			 1: 设置成功      
*/
void SetPhyContainAxisSecArbState(UINT16 phySecId,UINT8 arbState)
{
	UINT8 phySecContainAxisSecSum = 0u;
	UINT16* phySecContainAxisSecIdBuf = NULL;
	UINT8 reVal = CI_ERROR;
	UINT8 jj =0u;
	phySecContainAxisSecSum = GetPAxisSectionSum(phySecId);
	phySecContainAxisSecIdBuf = GetPAxisSectionIdBuf(phySecId);
	if ((0u == phySecContainAxisSecSum))
	{
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
	}
	if (CI_SUCCESS == reVal)
	{
		if((AXIS_SECTION_ARB_YES == arbState)||(AXIS_SECTION_ARB_NO ==arbState))
		{
			for (jj = 0u; jj < phySecContainAxisSecSum; jj++)
			{
				SetAxisSecArbState(phySecContainAxisSecIdBuf[jj], arbState);/*设置计轴区段ARB*/
			}	
		}
		else
		{
		}

	}
	else
	{
	}
}

/*
* 功能描述： 获取指定ID物理区段防护征用所属进路ID
* 参数说明： const UINT16 phySectionId, 物理区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 征用所属进路ID      
*/
UINT16 GetPhySecProtectUseRouteId(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/**
* @brief ARB设置处理函数
* @note 包络管理计算之后，调用此函数，设置所有物理区段的ARB状态
*/
void SetPhySecArbStateProc(void)
{
	UINT16 i = 0u;
	UINT16 wPhyNum = 0u;
	UINT8 chLocalCiId = 0u;
	UINT8 chPhyCiId = 0u;
	UINT16 wPhyId = 0u;
	UINT8 chPhyArbState = 0u;
	UINT8 chSetArbState = 0u;

	chLocalCiId = GetSystemParaLocalCiId();
	if (0u != chLocalCiId)
	{
		wPhyNum = GetPhySecCurSum();
		for (i = 0u; i < wPhyNum; i++)
		{/* 遍历物理区段 */
			wPhyId = GetPhySecId(i);
			chPhyCiId = GetPhySecBelongCiId(wPhyId);
			/* 仅处理本TIOC控区物理区段 */
			if (chLocalCiId == chPhyCiId)
			{
				chPhyArbState = aam_GetPhyIsARB(wPhyId);
				if (AAM_API_AC_ARB == chPhyArbState)
				{/* 物理区段ARB */
					chSetArbState = AXIS_SECTION_ARB_YES;
				}
				else
				{/* 物理区段非ARB */
					chSetArbState = AXIS_SECTION_ARB_NO;
				}
				/* 设置物理区段ARB状态 */
				SetPhySecArbState(wPhyId, chSetArbState);
				/*根据物理区段Arb状态设置关联计轴区段arb*/
				SetPhyContainAxisSecArbState(wPhyId, chSetArbState);
			}
			else
			{
				;
			}
		}
	}
	else
	{
		;
	}
}

/*
* 功能描述： 获取指定的物理区段的计轴区段
* 参数说明： const UINT16 wPhySecId, 物理区段ID
* 返回值  ： UINT16_MAX 失败;其他 成功
*/
UINT16 GetAxisSecIdByPhySecIdAndSwSta(const UINT16 wPhySecId)
{
	UINT16 wRetVal = UINT16_MAX;
	UINT8 cAxisSectionSum = 0u;
	UINT16* pAxisSectionIdBuf = NULL;
	UINT16 wAxisSectionId = 0u;
	UINT8 cAxisSwitchSum = 0u;
	AxisSwitchStruct* pAxisSwitchInfo = NULL;
	UINT8 cSwitchState = SWITCH_POSITION_INVALID;
	UINT8 ii = 0u;
	UINT8 jj = 0u;

	cAxisSectionSum = GetPAxisSectionSum(wPhySecId);
	pAxisSectionIdBuf = GetPAxisSectionIdBuf(wPhySecId);

	if (0u != cAxisSectionSum) 
	{
		for (ii = 0u;ii < cAxisSectionSum;ii++)
		{
			/* 获取计轴区段ID */
			wAxisSectionId = pAxisSectionIdBuf[ii];

			/* 获取计轴区段关联的道岔 */
			cAxisSwitchSum = GetAxisSwitchSum(wAxisSectionId);
			pAxisSwitchInfo = GetAxisSwitchIdStru(wAxisSectionId);

			if (NULL != pAxisSwitchInfo)
			{
				for (jj = 0u; jj < cAxisSwitchSum; jj++)
				{
					/* 获取道岔状态 */
					cSwitchState = GetSwitchCurPosition(pAxisSwitchInfo[jj].SwitchId);

					if (cSwitchState != pAxisSwitchInfo[jj].SwitchPosition)
					{
						break;
					}
					else
					{
					}
				}

				if (jj != cAxisSwitchSum)
				{
					wAxisSectionId = 0u;
				}
				else
				{
				}
			}
			else
			{
				wAxisSectionId = 0u;
			}

			if (0u != wAxisSectionId)
			{
				wRetVal = wAxisSectionId;
				break;
			}
			else
			{
			}
		}
	}
	else
	{
		; /* 失败 */
	}

	return wRetVal;
}

/**********间隔符JumpLockStateToZC****END**/

/*
* 功能描述： 根据逻辑区段跳跃锁闭状态设置物理区段跳跃锁闭状态
* 参数说明： const UINT16 logSectionId, 逻辑区段ID
* 返回值  ： 无
*/
void SetLogRelaPhySecJumpLockSta(const UINT16 logSectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 phySecId = 0u;
	UINT8 phyRelativeAxisSecNum = 0u;
	UINT16* phyRelativeAxisSecIdBuf = NULL;
	UINT8 ii = 0u;
	UINT8 jj = 0u;
	UINT8 axisRelativeLogSecNum = 0u;
	UINT16* axisRelativeLogSecIdBuf = NULL;
	UINT8 logJumpLockState = LOGIC_SECTION_JUMP_LOCK_NO;

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

	/** 区段下标合法*/
	if (LOGIC_SECTION_SUM_MAX > bufIndex)
	{

		/** 获取逻辑区段关联的物理区段ID*/
		phySecId = GetLgcSecRelativePhySecId(logSectionId);

		/** 获取物理区段关联的计轴区段数量和ID*/
		phyRelativeAxisSecNum = GetPAxisSectionSum(phySecId);
		phyRelativeAxisSecIdBuf = GetPAxisSectionIdBuf(phySecId);
		if ((0u < phyRelativeAxisSecNum) && (NULL != phyRelativeAxisSecIdBuf ))
		{
			for (ii = 0u; ii < phyRelativeAxisSecNum; ii++)
			{
				/** 获取计轴区段关联的逻辑区段数量和ID*/
				axisRelativeLogSecNum = GetAxisSecLogSectionSum(phyRelativeAxisSecIdBuf[ii]);
				axisRelativeLogSecIdBuf = GetAxisSecLogSectionIdBuf(phyRelativeAxisSecIdBuf[ii]);
				if ((0u < axisRelativeLogSecNum) && (NULL != axisRelativeLogSecIdBuf))
				{
					for (jj = 0u; jj < axisRelativeLogSecNum; jj++)
					{
						logJumpLockState = GetLogSecJumpLockState(axisRelativeLogSecIdBuf[jj]);
						/** 有任一逻辑区段跳跃锁闭则跳出循环*/
						if (LOGIC_SECTION_JUMP_LOCK_YES == logJumpLockState)
						{
							break;
						}
					}

					if (jj == axisRelativeLogSecNum)
					{
						/** 该计轴区段关联的逻辑区段跳跃锁闭均未锁闭*/
					}
					else
					{
						/** 该计轴区段关联的逻辑区段至少有一个跳跃锁闭已锁闭*/
						break;
					}
				}
				else
				{
					/** 不做处理 */
				}
			}

			/** 该物理区段关联的逻辑区段跳跃锁闭均未锁闭*/
			if (ii == phyRelativeAxisSecNum)
			{
				SetPhySecJumpLockState(phySecId, PHYSICAL_SECTION_JUMP_LOCK_NO);
			}
			else
			{
				/** 该物理区段关联的逻辑区段至少有一个跳跃锁闭已锁闭*/
				SetPhySecJumpLockState(phySecId, PHYSICAL_SECTION_JUMP_LOCK_YES);
			}
		}
		else
		{
			/** 不做处理 */
		}
	}
	else
	{
		/** 不做处理 */
	}
}
/*
* 功能描述： 检查物理区段是否被指定的SPKS封锁
* 参数说明： const UINT16 phySecId, 物理区段ID
			 const UINT16 spksId，指定的SPKS ID
* 返回值  ： 0: 检查失败
*			 1: 检查成功
* cgh-合并CID-2539-1
*/
UINT8 CheckPhySecFlockBlongSpks(const UINT16 phySecId, const UINT16 spksId)
{
	UINT8 SpksOfPhyFlockSum = 0u;
	UINT16 SpksOfPhyFlockId = 0u;
	UINT8 ii = 0u;
	UINT8 SpksState = 0u;
	UINT8 ret = CI_ERROR;
	SpksOfPhyFlockSum = GetPhySecSpksSum(phySecId);
	for (ii = 0u; ii < SpksOfPhyFlockSum; ii++)
	{
		SpksOfPhyFlockId = GetPhySecSpksIdBySpksIdx(phySecId, ii);
		SpksState = GetSpksState(SpksOfPhyFlockId);
		if ((SPKS_STATUS_YES == SpksState) && (SpksOfPhyFlockId != spksId))
		{
			ret = CI_ERROR;
			break;
		}
		else
		{
			ret = CI_SUCCESS;
		}
	}

	return ret;
}

/*
* 功能描述： 设置指定ID物理区段包含逻辑区段跳跃锁闭状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
*			 const UINT8 jumpLockState, 跳跃锁闭状态
* 返回值  ：无
* by-cgh-20230628-清除物理区段跳跃锁闭状态时同时清除逻辑区段跳跃锁闭状态
*/
void SetPhyIncludeLogJumpLockState(const UINT16 phySectionId, const UINT8 jumpLockState)
{
	UINT16 bufIndex = 0U;                                                                    /*数组下标*/
	UINT16* pLogSecBuf = NULL;
	UINT8 chLogSecSum = 0U;
	UINT8 ii = 0U;

	pLogSecBuf = GetPhySecIncLogSecIdBuf(phySectionId);
	chLogSecSum = GetPhySecIncLogSecSum(phySectionId);

	if (NULL != pLogSecBuf)
	{
		for (ii = 0U; ii < chLogSecSum; ii++)
		{
			if (PHYSICAL_SECTION_JUMP_LOCK_NO == jumpLockState)
			{
				SetLogSecJumpLockState(pLogSecBuf[ii], LOGIC_SECTION_JUMP_LOCK_NO);
			}
			else
			{
				/*不在此函数设置逻辑区段跳跃锁闭*/
			}
		}
	}
}

/*
* 功能描述： 设置物理区段延时区故解时间
* 参数说明： const UINT16 wPhySectionId, 物理区段ID
*			const UINT16 wPhyErrUnlockTime 物理区段延时区故解时间
* by cgh 20230630 相邻联锁传递倒计时
*/
void SetPhyErrUnlockTime(const UINT16 wPhySectionId, const UINT16 wPhyErrUnlockTime)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/

	wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); ;  /*获取区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > wBufIndex)
	{
		PhysicalSectionDataStru[wBufIndex].wPhyErrUnlockTime = wPhyErrUnlockTime;  /*设置时间*/
	}
}

/*
* 功能描述： 获物理区段延时区故解时间
* 参数说明： const UINT16 wLogSectionId, 物理区段ID
* 返回值：倒计时时间
* * by cgh 20230630 相邻联锁传递倒计时
*/
UINT16 GetPhyErrUnlockTime(const UINT16 wPhySectionId)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/
	UINT16 reVal = 0U;
	wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); ;  /*获取区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > wBufIndex)
	{
		reVal = PhysicalSectionDataStru[wBufIndex].wPhyErrUnlockTime;  /*设置时间*/
	}
	return reVal;
}

/*
* 功能描述：设置指定ID物理区段区域紧急制动状态
* 参数说明：const UINT16 wPhySecId 物理区段ID
*			const UINT8 cAreaUrgentState 区域紧急制动状态
* 返回值  ：无
* Created By LQ 2023.11.09
*/
void SetPhySecAreaUrgentState(const UINT16 wPhySecId, const UINT8 cAreaUrgentState)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(wPhySecId);  /*获取物理区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > bufIndex)
	{
		if ((cAreaUrgentState == PHYSEC_AREA_URGENT_NO) || (cAreaUrgentState == PHYSEC_AREA_URGENT_YES))
		{
			PhysicalSectionDataStru[bufIndex].cAreaUrgentBrakeState = cAreaUrgentState;
		}
		else
		{
			/*状态非法，不处理*/
		}
	}
	else
	{
		/*ID非法，不处理*/
	}
}

/*
* 功能描述：获取指定ID物理区段区域紧急制动状态
* 参数说明：const UINT16 wPhySecId 物理区段ID
* 返回值  ：0 获取失败
*          >0 区域紧急制动状态
* Created By LQ 2023.11.09
*/
UINT8 GetPhySecAreaUrgentState(const UINT16 wPhySecId)
{
	UINT16 bufIndex = 0U;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(wPhySecId);  /*获取物理区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > bufIndex)
	{
		retVal = PhysicalSectionDataStru[bufIndex].cAreaUrgentBrakeState;
	}
	else
	{
		/*ID非法，返回失败*/
	}

	return retVal;
}

/*
* 功能描述： 设置物理区段停稳列车ID
* 参数说明： const UINT16 wPhySectionId, 物理区段ID
*			const UINT16 wPhyStopSteadyTrainId 物理区段停稳列车ID
*/
void SetPhyStopSteadyTrainId(const UINT16 wPhySectionId, const UINT16 wPhyStopSteadyTrainId)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/

	wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); ;  /*获取区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > wBufIndex)
	{
		PhysicalSectionDataStru[wBufIndex].StopSteadyTrainId = wPhyStopSteadyTrainId;  /*设置停稳列车ID*/
	}
}

/*
* 功能描述： 获物物理区段停稳列车ID
* 参数说明： const UINT16 wLogSectionId, 物理区段ID
* 返回值：物理区段停稳列车ID
*/
UINT16 GetPhyStopSteadyTrainId(const UINT16 wPhySectionId)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/
	UINT16 reVal = 0U;
	wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); ;  /*获取区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > wBufIndex)
	{
		reVal = PhysicalSectionDataStru[wBufIndex].StopSteadyTrainId;  /*设置时间*/
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID物理区段的最小限速取值
* 参数说明： const UINT16 wPhySectionId, 物理区段ID
* 返回值  ： UINT8_MAX: 获取数据失败
*			>0: 临时限速取值
* BY CGH 20240429
*/
UINT8 GetPhySecMinXiansuSpeed(const UINT16 wPhySectionId)
{
	UINT8 retVal = UINT8_MAX;
	UINT8 chPhyIncLogSecSum = 0U;/*物理区段包含逻辑区段数目*/
	UINT16* szPhySecIncLogId = NULL;/*物理区段包含逻辑区段ID数组*/
	UINT8 ii = 0U;
	UINT8 chTsrDataSpeed = 0U;/*限速值*/


	/** 区段下标合法 */
	if (PHYSICAL_SECTION_SUM_MAX > wPhySectionId)
	{
		chPhyIncLogSecSum = GetPhySecIncLogSecSum(wPhySectionId);
		szPhySecIncLogId = GetPhySecIncLogSecIdBuf(wPhySectionId);
		
		if (NULL != szPhySecIncLogId)
		{
			for (ii = 0U; ii < chPhyIncLogSecSum; ii++)
			{
				chTsrDataSpeed = GetLogSecXiansuSpeed(szPhySecIncLogId[ii]);

				if ((0U != chTsrDataSpeed) && (UINT8_MAX != chTsrDataSpeed))
				{
					if (chTsrDataSpeed < retVal)
					{
						/*有更小的限速取小限速*/
						retVal = chTsrDataSpeed;
					}
					else
					{
						;  /*无更小限速*/
					}
				}
				else
				{
					; /*无限速或非法继续找*/
				}
			}
		}
		else
		{
			;
		}
	}
	else
	{
		; /*返回MAX*/
	}
	return retVal;
}

/*
* 功能描述：设置其它CI发送的物理区段防护锁闭所属进路ID
* 参数说明：const UINT16 wPhySectionId 物理区段ID
*           const UINT16 wPLockRouteId 防护锁闭所属进路ID
* 返 回 值：无
* Created By LQ 2024.06.11
*/
void SetPhySecOtherCiPLockRouteId(const UINT16 wPhySectionId, const UINT16 wPLockRouteId)
{
	UINT16 wBufIndex = 0U;  /*数组下标*/

	wBufIndex = GetPhySecConfigBufIndex(wPhySectionId);  /*获取区段数组下标*/

	if ((PHYSICAL_SECTION_SUM_MAX > wBufIndex) && (ROUTE_SUM_MAX > wPLockRouteId))
	{
		PhysicalSectionDataStru[wBufIndex].OtherCiPLockBelongRouteId = wPLockRouteId;  /*设置其它CI防护锁闭所属进路ID*/
	}
	else
	{
		/*入参非法，不处理*/
	}
}

/*
* 功能描述：获物其它CI发送的物理区段防护锁闭所属进路ID
* 参数说明：const UINT16 wPhySectionId 物理区段ID
* 返 回 值：其它CI发送的物理区段防护锁闭所属进路ID
* Created By LQ 2024.06.11
*/
UINT16 GetPhySecOtherCiPLockRouteId(const UINT16 wPhySectionId)
{
	UINT16 wRetVal = 0U;
	UINT16 wBufIndex = 0U;  /*数组下标*/

	wBufIndex = GetPhySecConfigBufIndex(wPhySectionId);  /*获取区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > wBufIndex)
	{
		wRetVal = PhysicalSectionDataStru[wBufIndex].OtherCiPLockBelongRouteId;  /*返回其它CI防护锁闭所属进路ID*/
	}
	else
	{
		/*入参非法，不处理*/
	}

	return wRetVal;
}

/*
* 功能描述：获取指定ID物理区段防护锁闭所属进路命令发送标志
* 参数说明：const UINT16 wPhySecId 物理区段ID
* 返回值  ：CI_ERROR 0 不发送
*			CI_SUCCESS 1 发送
* Created By LQ 2024.06.11
*/
UINT8 GetPhySecPLockRouteCmdSendFlag(const UINT16 wPhySecId)
{
	UINT8 cRetVal = CI_ERROR;
	UINT16 bufIndex = 0U;
	UINT8 cLocalCiId = 0U;
	UINT8 cSecBelongCiId = 0U;  /*区段所属CI*/
	UINT8 cSecLockState = PHYSICAL_SECTION_LOCK_NO;  /*区段锁闭状态*/
	UINT16 wSecRLockBelongRouteId = 0U;  /*区段进路锁闭所属进路*/
	UINT16 wSecPLockBelongRouteId = 0U;  /*区段防护锁闭所属进路*/
	UINT8 cRRouteBelongCiId = 0u;  /*进路锁闭所属进路的所属CI*/
	UINT8 cPRouteBelongCiId = 0u;  /*防护锁闭所属进路的所属CI*/
	UINT16 wOtherCiPLockRouteId = 0U;  /*其它CI发送的物理区段防护锁闭所属进路ID*/

	bufIndex = GetPhySecConfigBufIndex(wPhySecId);  /*获取区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > bufIndex)
	{
		/******** 1.判断是否为本控区区段 ********/
		cLocalCiId = GetSystemParaLocalCiId();
		cSecBelongCiId = GetPhySecBelongCiId(wPhySecId);

		if ((0U != cLocalCiId) && (cLocalCiId == cSecBelongCiId))
		{
			/******** 2.判断是否区段为正常锁闭或延时解锁 ********/
			cSecLockState = GetPhySecLockState(wPhySecId);

			if ((PHYSICAL_SECTION_LOCK_NORMAL == cSecLockState) || (PHYSICAL_SECTION_LOCK_DELAY == cSecLockState))
			{
				/********* 3.判断是否进路锁闭所属进路非本控区且（防护锁闭所属进路也非本控区或无防护锁闭所属进路） ********/
				wSecRLockBelongRouteId = GetPhySecRLockBelongRouteId(wPhySecId);  /*获取进路锁闭所属进路*/
				cRRouteBelongCiId = GetRouteBelongCiId(wSecRLockBelongRouteId);
				wSecPLockBelongRouteId = GetPhySecPLockBelongRouteId(wPhySecId);  /*获取防护锁闭所属进路*/
				cPRouteBelongCiId = GetRouteBelongCiId(wSecPLockBelongRouteId);

				if ((cLocalCiId != cRRouteBelongCiId) && (0U != cRRouteBelongCiId) && ((cRRouteBelongCiId == cPRouteBelongCiId) || (0U == cPRouteBelongCiId)))
				{
					/********* 4.判断是否本控区的区段防护锁闭所属进路与进路锁闭所属进路控区的区段防护锁闭所属进路不同 ********/
					wOtherCiPLockRouteId = GetPhySecOtherCiPLockRouteId(wPhySecId);
					if (wOtherCiPLockRouteId != wSecPLockBelongRouteId)
					{
						cRetVal = CI_SUCCESS;  /*本控区的区段防护锁闭所属进路与进路锁闭所属进路控区的区段防护锁闭所属进路不同，返回1*/
					}
					else
					{
						/*防护锁闭所属进路相同，不处理*/
					}
				}
				else
				{
					/*进路锁闭所属进路不满足，不处理*/
				}
			}
			else
			{
				/*区段锁闭状态不满足，不处理*/
			}
		}
		else
		{
			/*非本控区区段，不处理*/
		}
	}
	else
	{
		cRetVal = CI_ERROR;  /*物理区段ID非法，返回0*/
	}

	return cRetVal;
}

/*
* 功能描述： 获取指定ID物理区段ABL列车占用
* 参数说明： const UINT16 phySectionId, 物理区段ID
* 返回值  ： 0: 获取数据失败
*			0xaa ABL车占用 0x55 非ABL
*	Created By fan 2024.08.15
*/
UINT8 GetPhySecABLTrainFlag(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].chABLTrainFlag;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 获取指定ID物理区段之前ABL列车占用标志
* 参数说明： const UINT16 phySectionId, 物理区段ID
* 返回值  ： 0: 获取数据失败
*			0xaa ABL车占用 0x55 非ABL
*	Created By fan 2024.08.15
*/
UINT8 GetPhySecPreABLTrainFlag(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].chPreABLTrainFlag;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段ABL列车占用标志并更新设置周期
* 参数说明： const UINT16 phySectionId, 物理区段ID  ablTrainFlag 是否列车 0xaa是  0x55否 0默认
* 返回值  ：无
*	Created By fan 2024.08.15
*/
void SetPhySecABLTrainFlag(const UINT16 phySectionId,UINT8 ablTrainFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 checkFlag = CI_SUCCESS;
	UINT32 dwCurCyc = Get2oo2CurCycleNum();
	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		if ((PHYSICAL_SECTION_ABLOCCUPY_YES == ablTrainFlag) || (PHYSICAL_SECTION_ABLOCCUPY_NO == ablTrainFlag)
			|| (PHYSICAL_SECTION_ABLOCCUPY_DEFAULT == ablTrainFlag))
		{
			if ((dwCurCyc == PhysicalSectionDataStru[bufIndex].dwAblTagSetCyc) &&
				(PHYSICAL_SECTION_ABLOCCUPY_YES == PhysicalSectionDataStru[bufIndex].chABLTrainFlag))
			{
				; /*本周期当前区段已经设置过ABL  再有非ABL车不更新*/
			}
			else if ((dwCurCyc == PhysicalSectionDataStru[bufIndex].dwAblTagSetCyc) &&
				((PHYSICAL_SECTION_ABLOCCUPY_YES == ablTrainFlag) || (PHYSICAL_SECTION_ABLOCCUPY_NO == ablTrainFlag)))
			{
				/*本周期当前区段已经设置过标志 仅更新级别*/
				PhysicalSectionDataStru[bufIndex].chABLTrainFlag = ablTrainFlag;
			}
			else  if ((dwCurCyc == PhysicalSectionDataStru[bufIndex].dwAblTagSetCyc)&& (PHYSICAL_SECTION_ABLOCCUPY_DEFAULT == ablTrainFlag))
			{
				; /*本周期已更新过不再设置为默认级别*/
			}
			else if (dwCurCyc != PhysicalSectionDataStru[bufIndex].dwAblTagSetCyc)
			{
				/*本周期第一次更新 设置之前标志 更新设置周期*/
				PhysicalSectionDataStru[bufIndex].chPreABLTrainFlag = PhysicalSectionDataStru[bufIndex].chABLTrainFlag;
				PhysicalSectionDataStru[bufIndex].dwAblTagSetCyc = dwCurCyc;
				PhysicalSectionDataStru[bufIndex].chABLTrainFlag = ablTrainFlag;
			}
			else
			{
				; /*错误*/
			}
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}
/*
* 功能描述： 获取指定ID物理区段坏车占用标志
* 参数说明： const UINT16 phySectionId, 物理区段ID
* 返回值  ： 0x55 未设置坏车占用 0xaa 坏车占用
*	Created By fan 2024.08.19
*/
UINT8 GetPhySecUTTrainFlag(const UINT16 phySectionId)
{

	UINT8 retVal = PHYSICAL_AXIS_UT_YES;
	UINT8 jj = 0U;
	UINT8 phySecContainAxisSecSum; /*物理区段关联计轴区段数量*/
	UINT16* phySecContainAxisSecIdBuf = NULL; /*物理区段关联计轴数组*/
	UINT32 dwAxisUtOccupyCyc = 0U; /*计轴区段坏车占用周期*/
	UINT32 dwCurCyc = Get2oo2CurCycleNum(); /*当前周期号*/
	/*物理区段上任意计轴区段坏车占用则返回坏车*/
	phySecContainAxisSecSum = GetPAxisSectionSum(phySectionId);
	phySecContainAxisSecIdBuf = GetPAxisSectionIdBuf(phySectionId);
	if ((0u == phySecContainAxisSecSum)|| (NULL == phySecContainAxisSecIdBuf))
	{
		retVal = PHYSICAL_AXIS_UT_YES;
	}
	else
	{
		retVal = PHYSICAL_AXIS_UT_NO;
		for (jj = 0u; jj < phySecContainAxisSecSum; jj++)
		{
			dwAxisUtOccupyCyc = GetAxisRecentUtOccupyCyc(phySecContainAxisSecIdBuf[jj]);
			if ((dwAxisUtOccupyCyc == dwCurCyc)||(UINT32_MAX ==dwAxisUtOccupyCyc))
			{
				/*当前周期有计轴有坏车 或获取失败 中止遍历*/
				retVal = PHYSICAL_AXIS_UT_YES;
				break;
			}
		}
	}
	return retVal;
}

/*
* 功能描述： 设置指定ID物理区段内计轴区段坏车占用
* 参数说明： const UINT16 phySectionId, 物理区段ID, 坏车占用标志
* 返回值  ： 无
*	Created By fan 2024.08.19
*/
void SetPhySecUTTrainFlag(const UINT16 phySectionId, UINT8 ablTrainFlag)
{
	UINT8 phySecContainAxisSecSum; /*物理区段关联计轴区段数量*/
	UINT16* phySecContainAxisSecIdBuf = NULL; /*物理区段关联计轴数组*/
	UINT8 jj = 0U;
	UINT32 dwCurCyc = Get2oo2CurCycleNum(); /*当前周期号*/
	if (PHYSICAL_AXIS_UT_YES == ablTrainFlag)
	{
		phySecContainAxisSecSum = GetPAxisSectionSum(phySectionId);
		phySecContainAxisSecIdBuf = GetPAxisSectionIdBuf(phySectionId);
		if ((0u != phySecContainAxisSecSum) && (NULL != phySecContainAxisSecIdBuf))
		{
			for (jj = 0u; jj < phySecContainAxisSecSum; jj++)
			{
				SetAxisRecentUtOccupyCyc(phySecContainAxisSecIdBuf[jj], dwCurCyc);
			}
		}
		else
		{
			; /*获取失败*/
		}
	}
	else
	{
		; /*不更新该物理区段最近坏车占用*/
	}
}

/*
* 功能描述：获取指定ID物理区段湿轨标志
* 参数说明：const UINT16 phySectionId, 区段ID
* 返 回 值：0x55 无效
*			0xAA 有效
* Created By LQ 2024.09.20
*/
UINT8 GetPhySecInHumidRailFlag(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 retVal = PHYSEC_IN_HUMID_RAIL_YES;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].cPhySecInHumidRailFlag;
	}
	else
	{
		/*不处理*/
	}

	return retVal;
}

/*
* 功能描述：设置指定ID物理区段湿轨标志
* 参数说明：const UINT16 phySectionId, 物理区段ID
*			const UINT8 cInHumidRailFlag 物理区段湿轨标志
* 返 回 值：无
* Created By LQ 2024.09.20
*/
void SetPhySecInHumidRailFlag(const UINT16 phySectionId, const UINT8 cInHumidRailFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > bufIndex)
	{
		if ((PHYSEC_IN_HUMID_RAIL_YES == cInHumidRailFlag) || (PHYSEC_IN_HUMID_RAIL_NO == cInHumidRailFlag))
		{
			PhysicalSectionDataStru[bufIndex].cPhySecInHumidRailFlag = cInHumidRailFlag;
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：设置区间湿轨关联的物理区段湿轨标志
* 参数说明：const UINT16 wAreaHumidRailId 区间湿轨ID
* 返 回 值：无
* Created By LQ 2024.09.20
*/
void SetPlatFormRelPSHumidRailFlag(const UINT16 wAreaHumidRailId)
{
	UINT8 ii = 0U;
	UINT16 jj = 0U;
	UINT8 cPlatFormRelSpksNum = 0U;  /*站台关联的SPKS数量*/
	UINT16 szPlatFormRelSpksId[PLATFORM_REL_SPKS_NUM_MAX] = { 0U };  /*站台关联的SPKS ID数组*/
	UINT16 wCurPhySecNum = 0U;
	UINT16 wPhySecId = 0U;
	UINT16 wSpksIndex = 0U;
	UINT16 wSpksRelPhySecNum = 0U;  /*SPKS关联物理区段数量*/
	UINT16 wSpksRelPhySecId = 0U;  /*SPKS关联物理区段ID*/
	UINT8 cPhySecBelongCiId = 0U;  /*SPKS关联物理区段的所属控区*/
	UINT8 cLocalCiId = 0U;  /*本地CI ID*/

	if (0U != wAreaHumidRailId)
	{
		cLocalCiId = GetSystemParaLocalCiId();
		cPlatFormRelSpksNum = GetPlatFormRelSpksNum(wAreaHumidRailId, szPlatFormRelSpksId);  /*获取站台关联的SPKS*/

		if (CI_ERROR != cPlatFormRelSpksNum)
		{
			/*遍历所有站台关联的SPKS，设置SPKS关联的本控区的物理区段所处湿轨标志有效*/
			for (ii = 0U; ii < cPlatFormRelSpksNum; ii++)
			{
				wSpksIndex = GetSpksConfigBufIndex(szPlatFormRelSpksId[ii]);
				wSpksRelPhySecNum = GetSpksPhySecSumByIndex(wSpksIndex);

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

					if ((cLocalCiId == cPhySecBelongCiId) && (0U != cLocalCiId))
					{
						SetPhySecInHumidRailFlag(wSpksRelPhySecId, PHYSEC_IN_HUMID_RAIL_YES);  /*物理区段处于区间湿轨*/
					}
					else
					{
						/*继续遍历*/
					}
				}
			}
		}
		else
		{
			/*获取站台关联SPKS失败，设置整个控区的物理区段湿轨有效*/
			wCurPhySecNum = GetPhySecCurSum();
			for (jj = 0U; jj < wCurPhySecNum; jj++)
			{
				wPhySecId = GetPhySecId(jj);
				SetPhySecInHumidRailFlag(wPhySecId, PHYSEC_IN_HUMID_RAIL_YES);
			}
		}
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述： 获取指定ID物理区段关联区段是否具备ARB状态
* 参数说明： const UINT16 phySectionId, 物理区段ID
* 返回值  ： PHY_SECTION_ARB_NO: 未ARB
*			 PHY_SECTION_ARB_YES: ARB
* by cgh 20241030
*/
UINT8 GetPhySecRelLogSecExistArb(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0U;                               /*数组下标*/
	UINT8 retVal = PHY_SECTION_ARB_NO;
	UINT8 ii = 0U;
	UINT8 chPhySecInLogSecSum = 0U;/*物理区段包含逻辑区段数目*/
	UINT16* szPhySecInLogSecBuf = NULL;/*物理区段包含逻辑区段数组*/
	UINT8 chLogSecArbState = 0U;/*逻辑区段ARB状态*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (PHYSICAL_SECTION_SUM_MAX > bufIndex)
	{
		chPhySecInLogSecSum = GetPhySecIncLogSecSum(phySectionId);
		szPhySecInLogSecBuf = GetPhySecIncLogSecIdBuf(phySectionId);

		if (NULL != szPhySecInLogSecBuf)
		{
			for (ii = 0U; ii < chPhySecInLogSecSum; ii++)
			{
				chLogSecArbState = GetLgcArbState(szPhySecInLogSecBuf[ii]);
				if (LGC_SECTION_ARB_YES == chLogSecArbState)
				{
					retVal = PHY_SECTION_ARB_YES;
					break;
				}
				else
				{
					; /*继续查找*/
				}
			}
		}
		else
		{
			; /*非法，返回非ARB*/
		}
	}
	else
	{
		; /*非法，返回非ARB*/
	}
	return retVal;
}

/*
* 功能描述：获取指定ID物理区段采集占用起始周期
* 参数说明：const UINT16 phySectionId, 区段ID
* 返 回 值：物理区段采集占用起始周期
*/
UINT32 GetSecColOccupyStartCycNum(const UINT16 phySectionId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 retVal = CI_ERROR;

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		retVal = PhysicalSectionDataStru[bufIndex].SecColOccupyStartCycNum;
	}
	else
	{
		retVal = CI_ERROR;
	}
	return retVal;
}

/*
* 功能描述：设置指定ID物理区段采集占用起始周期
* 参数说明：const UINT16 phySectionId, 物理区段ID
*			const UINT8 startCycNum 采集占用起始周期
* 返 回 值：无
*/
void SetSecColOccupyStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetPhySecConfigBufIndex(phySectionId);  /*获取区段数组下标*/

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		PhysicalSectionDataStru[bufIndex].SecColOccupyStartCycNum = startCycNum;
	}
	else
	{
		/*不做处理*/
	}
}

/*
* 功能描述：设置互联互通CI指定ID物理区段CT/UT占用状态
* 参数说明：const UINT16 phySecId, 物理区段ID
			const UINT8 flag 物理区段之前CT或UT占用状态
* 返 回 值：无
* Created By LQ 2025.05.28
*/
void SetHlhtPhySecCtOrUtOccState(const UINT16 phySecId, const UINT8 flag)
{
	UINT16 bufIndex = 0u;		/*数组下标*/
	UINT32 dwCurCycNum = 0U;

	bufIndex = GetPhySecConfigBufIndex(phySecId);  /*获取物理区段数组下标*/

	if ((bufIndex < PHYSICAL_SECTION_SUM_MAX) && ((LOGICSECTION_OCCUPY_UT == flag) || (LOGICSECTION_OCCUPY_CT == flag) || (LOGICSECTION_OCCUPY_NO == flag)))
	{
		/*更新CT/UT占用起始周期*/
		if (LOGICSECTION_OCCUPY_NO == flag)
		{
			PhysicalSectionDataStru[bufIndex].UtOrCtOccuStartCycNum = 0U; /*空闲，清除CT/UT占用起始周期*/
		}
		else
		{
			if ((PhysicalSectionDataStru[bufIndex].UtOrCtOccFlag != flag)
				&& ((PHYSICAL_SECTION_LOCK_NORMAL == PhysicalSectionDataStru[bufIndex].LockState) || (PHYSICAL_SECTION_LOCK_EXCEPT == PhysicalSectionDataStru[bufIndex].LockState)))
			{
				dwCurCycNum = Get2oo2CurCycleNum();
				PhysicalSectionDataStru[bufIndex].UtOrCtOccuStartCycNum = dwCurCycNum;  /*更新CT/UT占用起始周期*/
			}
			else
			{
				/*不处理*/
			}
		}

		/*更新CT/UT占用状态*/
		PhysicalSectionDataStru[bufIndex].UtOrCtOccFlag = flag;

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