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

#include "OverlapDataManage.h"
#include "../Section/LogicSectionDataManage.h"



OverlapDataStruct OverlapDataStru[OVERLAP_SUM_MAX];   /*定义OVERLAP数据结构体*/



/*
* 功能描述： 获取指定ID保护区段数据
* 参数说明： 
* 返回值  ： 
            OverlapDataStruct *    
*/
OverlapDataStruct *GetOverlapData(void)
{
    return OverlapDataStru;
}

/*
* 功能描述： 获取指定ID保护区段所属进路ID
* 参数说明： const UINT16 overlapId, 保护区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 所属进路ID      
*/
UINT16 GetOverlapBelongRouteId(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 reVal = CI_ERROR;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].BelongRouteId;
	}
	return reVal;
}


/*
* 功能描述： 设置指定ID保护区段所属进路
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			 const UINT16 belongRouteId, 所属进路号
* 返回值  ： 无
*			        
*/
void SetOverlapBelongRouteId(const UINT16 overlapId, const UINT16 belongRouteId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/
	
	if (bufIndex < OVERLAP_SUM_MAX)
	{
		OverlapDataStru[bufIndex].BelongRouteId = belongRouteId;  /*设置所属进路号*/
	}
}

/*
* 功能描述： 设置保护区段关联防护道岔防护锁闭状态
* 参数说明： const UINT16 overlapId, 保护区段ID
*            const UINT8 lockCommand, 锁闭状态
* 返回值  ： void
*/
void SetOverlapRelateProtSwLockSta(const UINT16 overlapId, const UINT8 lockCommand)
{
	UINT8 ii = 0u;                                             /*遍历变量*/
	UINT8 retVal = CI_SUCCESS;                                /*返回值*/
	UINT16 protectSwitchId = 0u;                               /*防护道岔ID*/
	UINT8 overlapProtectSwitchSum = 0u; 	                      /*防护道岔数目*/
	OverlapProtectSwitchStruct* overlapProtectSwitchStru = NULL;  /*防护道岔数据*/
	
	overlapProtectSwitchSum = GetOverlapRelatedProtSwitSum(overlapId);      /*获取防护道岔数目*/
	overlapProtectSwitchStru = GetOverlapRelatedProtSwitStru(overlapId);    /*获取防护道岔数据*/

	if (0u == overlapProtectSwitchSum) 
	{
		retVal = CI_ERROR;
	}
	else
	{
	}

	if((SWITCH_LOCK_PROTECT_SET != lockCommand) && (SWITCH_LOCK_PROTECT_CANCEL != lockCommand))
	{
		retVal = CI_ERROR;
	}
	else
	{
	}

	if (CI_SUCCESS == retVal)
	{
		for (ii= 0u; ii < overlapProtectSwitchSum; ii++)
		{
			protectSwitchId = overlapProtectSwitchStru[ii].ProtectSwitchId;
			SetSwitchLockStatus(SWITCH_PLOCKTYPE_OVERLAP,overlapId,protectSwitchId, lockCommand);                        /*设置道岔防护锁闭状态*/
			/*RC 13.0.0 修：不检查防护道岔中双动道岔另一端*/
#if 0
			if (SWITCH_TYPE_DOUBLE == GetSwitchType(protectSwitchId))
			{ /*双动道岔*/
				SetSwitchLockStatus(SWITCH_PLOCKTYPE_OVERLAP,overlapId,GetDSwitchOtherId(protectSwitchId), lockCommand); /*设置道岔防护锁 闭状态*/
			}
			else
			{
			}
#endif
		}
	} 
	else
	{
		retVal = CI_ERROR;
	}
}

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

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].UnlockStartCycNum;
	}
	return reVal;
}


/*
* 功能描述： 设置指定ID保护区段组解锁起始周期号
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			 const UINT32 unlockStartCycNum, 解锁起始周期号
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetOverlapUnlockStartCycNum(const UINT16 overlapId, const UINT32 unlockStartCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		OverlapDataStru[bufIndex].UnlockStartCycNum = unlockStartCycNum;  /*设置解锁起始周期号*/
		
		reVal = CI_SUCCESS;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID保护区段选排开始周期号
* 参数说明： const UINT16 overlapId, 保护区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 选排起始周期号      
*/
UINT32 GetOverlapXuanPaiStartCycNum(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].XuanPaiStartCycNum;
	}
	return reVal;
}


/*
* 功能描述： 设置指定ID保护区段选排开始周期号
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			 const UINT32 unlockStartCycNum, 选排起始周期号
* 返回值  ： 无
*			        
*/
void SetOverlapXuanPaiStartCycNum(const UINT16 overlapId, const UINT32 xuanpaiStartCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		if ((0U == xuanpaiStartCycNum) || (0U == OverlapDataStru[bufIndex].XuanPaiStartCycNum))
		{
			OverlapDataStru[bufIndex].XuanPaiStartCycNum = xuanpaiStartCycNum;  /*设置选排起始周期号*/
		}
		else
		{
			/*已设置选排起始周期，不更新*/
		}
	}
	else
	{
		/*保护区段ID非法，不处理*/
	}
}

/*
* 功能描述： 获取指定ID保护区段向ZC申请解锁保护区段标志
* 参数说明： const UINT16 overlapId, 保护区段ID    
* 返回值  ： 0: 获取数据失败
*			>0: 选排起始周期号      
*/
UINT8 GetOverlapUnlockApplyFlag(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].OverlapUnlockApplyFlag;
	}
	return reVal;
}


/*
* 功能描述： 设置指定ID保护区段向ZC申请解锁保护区段标志
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			 const UINT8 overlapUnlockApplyFlag
* 返回值  ： 无
*			       
*/
void SetOverlapUnlockApplyFlag(const UINT16 overlapId, const UINT8 overlapUnlockApplyFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		OverlapDataStru[bufIndex].OverlapUnlockApplyFlag = overlapUnlockApplyFlag;  /*设置向ZC申请解锁保护区段标志*/
	}
}

/*
* 功能描述：获取指定ID保护区段申请解锁的列车ID
* 参数说明：const UINT16 overlapId, 保护区段ID
* 返回值  ：0 获取失败 
*           其它 列车ID（不带0x14）
*/
UINT16 GetOverlapUnlockApplyTrainId(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 reVal = 0u;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].wOverlapUnlockApplyTrainId;
	}
	return reVal;
}


/*
* 功能描述： 设置指定ID保护区段申请解锁的列车ID
* 参数说明： const UINT16 overlapId, 保护区段ID
*			 const UINT16 wTrainId，列车ID（不带0x14）
* 返回值  ： 无
*
*/
void SetOverlapUnlockApplyTrainId(const UINT16 overlapId, const UINT16 wTrainId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		OverlapDataStru[bufIndex].wOverlapUnlockApplyTrainId = wTrainId; 
	}
}

/*
* 功能描述： 设置保护区段的逻辑区段列车资源申请
* 参数说明： const UINT16 wOverlapId, 保护区段ID const UINT16 wTrnId 列车ID
*
* 返回值  ： VOID
*/
void SetOverlapTrainLockApply(const UINT16 wOverlapId, const UINT16 wTrnId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16* pLogicSectionId = NULL;
	UINT8 cLogicSectionSum = 0u;
	UINT8 i = 0u;

	bufIndex = GetOverlapConfigBufIndex(wOverlapId);  /*获取数组下标*/

	if (OVERLAP_SUM_MAX > bufIndex)
	{
		cLogicSectionSum = GetOverlapLogicSectionSum(wOverlapId);
		pLogicSectionId = GetOverlapLogicSectionBuf(wOverlapId);

		if ((0u != cLogicSectionSum) && (0u != wTrnId))
		{
			for (i = 0u; i < cLogicSectionSum; i++)
			{
				AddLogSecTrainRes(pLogicSectionId[i],wTrnId);
			}
		}
		else
		{
		}
	}
	else
	{
	}
}
/*
* 功能描述： 设置保护区段可以人工解锁标志
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			 const UINT8 CanLaborUnlockFlag 能否人工解锁标志  
*/
void SetOverlapCanLaborUnlockFlag(const UINT16 overlapId,const UINT8 CanLaborUnlockFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		if((CAN_LABOR_UNLOCK_OVERLAP == CanLaborUnlockFlag)||(CANNOT_LABOR_UNLOCK_OVERLAP == CanLaborUnlockFlag))
		{
			OverlapDataStru[bufIndex].OverlapCanLaborUnlockFlag = CanLaborUnlockFlag;  /*能否人工解锁标志*/
		}
	}
}

/*
* 功能描述： 获取保护区段可以人工解锁标志
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			 const UINT8 CanLaborUnlockFlag 能否人工解锁标志
* 返回值  ： 0: 获取失败
*			 0<: 获取成功      
*/
UINT8 GetOverlapCanLaborUnlockFlag(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = 0u;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].OverlapCanLaborUnlockFlag;  /*能否人工解锁标志*/
	}
	return reVal;
}

/*
* 功能描述： 设置保护区段人工解锁命令设置状态
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			 const UINT8 LaborUnlockSetState   人工解锁命令设置状态
*/
void SetOverlapLaborUnlockSetState(const UINT16 overlapId,const UINT8 LaborUnlockSetState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		if((LABOR_UNLOCK_OVERLAP_YES == LaborUnlockSetState)||(LABOR_UNLOCK_OVERLAP_NO == LaborUnlockSetState))
		{
			OverlapDataStru[bufIndex].OverlapLaborUnlockSetState = LaborUnlockSetState;  /*人工解锁命令设置状态*/
		}
	}
}

/*
* 功能描述： 获取保护区段人工解锁命令设置状态
* 参数说明： const UINT16 overlapId, 保护区段ID   
* 返回值  ： 0: 获取失败
*			 0<: 获取成功            
*/
UINT8 GetOverlapLaborUnlockSetState(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = 0u;
	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].OverlapLaborUnlockSetState;  /*人工解锁命令设置状态*/	
	}
	return reVal;
}

/*
* 功能描述： 设置保护区段人工解锁起始周期号
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			 const UINT32 laborUnlockStartCycNum  人工解锁起始周期号
*/
void SetlaborUnlockStartCycNum(const UINT16 overlapId,const UINT32 laborUnlockStartCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		OverlapDataStru[bufIndex].laborUnlockStartCycNum = laborUnlockStartCycNum;  /*人工解锁起始周期号*/
	}
}

/*
* 功能描述： 获取保护区段人工解锁起始周期号
* 参数说明： const UINT16 overlapId, 保护区段ID   
* 返回值  ： 0: 获取失败
*			 0<: 获取成功   
*/
UINT32 GetlaborUnlockStartCycNum(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = 0u;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].laborUnlockStartCycNum;  /*人工解锁起始周期号*/
	}
	return reVal;
}


/*
* 功能描述： 设置保护区段ATS或人工锁命令标识
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			 const UINT8 atsOrlaborLockCmdFlag  保护区段ATS或人工锁命令标识
*/
void SetOverlapAtsOrlaborLockCmdFlag(const UINT16 overlapId,const UINT8 atsOrlaborLockCmdFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		if((LOCK_OVERLAP_CMD_YES == atsOrlaborLockCmdFlag)||(LOCK_OVERLAP_CMD_NO == atsOrlaborLockCmdFlag))
		{
			OverlapDataStru[bufIndex].atsOrlaborLockFlag = atsOrlaborLockCmdFlag;  /*设置命令标识*/
		}

	}
}

/*
* 功能描述： 设置保护区段ATS或人工锁命令标识
* 参数说明： const UINT16 overlapId, 保护区段ID   
* 返回值:0:失败
*        0<:保护区段ATS或人工锁命令标识
*/
UINT8 GetOverlapAtsOrlaborLockCmdFlag(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = 0u;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].atsOrlaborLockFlag;  /*设置命令标识*/
	}

	return reVal;
}

/*
* 功能描述： 设置保护区段锁闭成功开始周期
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			const UINT32 lockSucessStartCycNum  保护区段锁闭成功开始周期
*/
void SetOverlaplockSucessStartCycNum(const UINT16 overlapId,const UINT32 lockSucessStartCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{	
		OverlapDataStru[bufIndex].lockStartCycNum = lockSucessStartCycNum;  /*设置周期*/
	}
}

/*
* 功能描述： 获取保护区段锁闭成功开始周期
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			const UINT32 lockSucessStartCycNum  保护区段锁闭成功开始周期
*/
UINT32 GetOverlaplockSucessStartCycNum(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = 0u;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{	
		reVal = OverlapDataStru[bufIndex].lockStartCycNum;  /*设置周期*/
	}
	return reVal;
}

/*
* 功能描述： 设置保护区段倒计时解锁时间
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			const UINT16 overlapUnlockTime 保护区段倒计时解锁时间
*/
void SetOverlapUnlockTime(const UINT16 overlapId,const UINT16 overlapUnlockTime)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{	
		OverlapDataStru[bufIndex].overlapUnlockTime = overlapUnlockTime;  /*设置时间*/
	}
}

/*
* 功能描述： 设置保护区段倒计时解锁时间
* 参数说明： const UINT16 overlapId, 保护区段ID   
* 返回值：倒计时时间
*/
UINT16 GetOverlapUnlockTime(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 reVal = 0u;
	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{	
		reVal = OverlapDataStru[bufIndex].overlapUnlockTime;  /*设置时间*/
	}
	return reVal;
}
/*
* 功能描述： 设置保护区段人工锁命令标识
* 参数说明： const UINT16 overlapId, 保护区段ID   
*			 const UINT8 laborLockCmdFlag  保护区段人工锁命令标识
*/
void SetOverlaplaborLockCmdFlag(const UINT16 overlapId,const UINT8 laborLockCmdFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		if((LOCK_OVERLAP_CMD_YES == laborLockCmdFlag)||(LOCK_OVERLAP_CMD_NO == laborLockCmdFlag))
		{
			OverlapDataStru[bufIndex].laborLockOverlapCmd = laborLockCmdFlag;  /*设置命令标识*/
		}

	}
}

/*
* 功能描述： 设置保护区段人工锁命令标识
* 参数说明： const UINT16 overlapId, 保护区段ID   
* 返回值:0:失败
*        0<:保护区段人工锁命令标识
*/
UINT8 GetOverlaplaborLockCmdFlag(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = 0u;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].laborLockOverlapCmd;  /*设置命令标识*/
	}

	return reVal;
}

/*
* 功能描述：设置向车申请解锁保护区段起始周期号
* 参数说明：const UINT16 overlapId 保护区段ID
*			const UINT32 reqIvocUnlockStartCycNum 向车申请解锁保护区段起始周期号
* 返回值：无
*/
void SetReqIvocUnlockStartCycNum(const UINT16 overlapId, const UINT32 reqIvocUnlockStartCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		OverlapDataStru[bufIndex].dwReqIvocUnLockStartCycNum = reqIvocUnlockStartCycNum;  /*人工解锁起始周期号*/
	}
}

/*
* 功能描述： 获取向车申请解锁保护区段起始周期号
* 参数说明： const UINT16 overlapId 保护区段ID
* 返回值  ： 0: 获取失败
*			 0<: 获取成功
*/
UINT32 GetReqIvocUnlockStartCycNum(const UINT16 overlapId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = 0u;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].dwReqIvocUnLockStartCycNum;  /*人工解锁起始周期号*/
	}
	return reVal;
}

/*
* 功能描述：设置指定ID保护区段列车允许解锁标志
* 参数说明：const UINT16 overlapId 保护区段ID
*			const UINT8 overlapIvocUnlockFlag 列车允许解锁标志
* 返回值  ：无
*/
void SetOverlapIvocAllowUnlockFlag(const UINT16 overlapId, const UINT8 overlapIvocUnlockFlag)
{
	UINT8 retVal = CI_ERROR;
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if ((bufIndex < OVERLAP_SUM_MAX) && ((IVOC_ALLOW_UNLOCK_OVERLAP_YES == overlapIvocUnlockFlag) || (IVOC_ALLOW_UNLOCK_OVERLAP_NO == overlapIvocUnlockFlag)))
	{
		OverlapDataStru[bufIndex].cIvocAllowUnlockFlag = overlapIvocUnlockFlag;
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：获取指定ID保护区段列车允许解锁标志
* 参数说明：const UINT16 overlapId 保护区段ID
* 返回值  ：0xAA: 同意解锁
*			0x55: 不同意解锁
*           0: 获取失败
*/
UINT8 GetOverlapIvocAllowUnlockFlag(const UINT16 overlapId)
{
	UINT8 reVal = CI_ERROR;
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].cIvocAllowUnlockFlag;
	}
	else
	{
		/*返回失败*/
	}

	return reVal;
}

/*
* 功能描述：获取指定ID保护区段关联的物理区段包含的非保护区段内的所有逻辑区段
* 参数说明：const UINT16 overlapId 保护区段ID
*          UINT16* logsecIdbuf 逻辑区段ID数组
* 返回值  ：CI_SUCCESS 查找成功
*          CI_ERROR 查找失败
* BY LC
*/
UINT8 GetOverlapPhysecOtherLogSec(const UINT16 overlapId, OUT UINT16 * logsecIdbuf,OUT UINT8 * logSecSum)
{
	UINT8 phySecSum = 0u;  /*物理区段总数*/
	UINT16* pPhySecIdBuf = NULL;  /*物理区段结构指针*/
	UINT8 cLogicSectionSum = 0u;  /*逻辑区段总数*/
	UINT16* pLogicSectionIdBuf = NULL;  /*逻辑区段ID数组*/
	UINT8 cPhySecIncLogSecSum = 0U;  /*物理区段包含的逻辑区段数量*/
	UINT16* pPhySecIncLogSecId = NULL;  /*物理区段包含的逻辑区段ID*/

	UINT8 i = 0u;  /*遍历变量*/
	UINT8 j = 0u;  /*遍历变量*/
	UINT8 k = 0u;  /*遍历变量*/
	UINT8 szHitOverlapLgcSec[LOGIC_SECTION_SUM_MAX] = { 0U };
	UINT8 retVal = CI_ERROR;
	UINT8 count = 0U;

	phySecSum = GetOverlapPhySecSum(overlapId);  /*获取overlap物理区段总数*/
	pPhySecIdBuf = GetOverlapPhySecIdBuf(overlapId);  /*获取overlap物理区段ID数组*/


	if ((0U < overlapId) && (OVERLAP_SUM_MAX > overlapId)
		&& (NULL != logsecIdbuf) && (NULL != logSecSum))
	{
		retVal = CI_SUCCESS;

		cLogicSectionSum = GetOverlapLogicSectionSum(overlapId); /*获取overlap逻辑区段总数*/
		pLogicSectionIdBuf = GetOverlapLogicSectionBuf(overlapId); /*获取overlap逻辑区段ID数组*/

		for (i = 0U; i < cLogicSectionSum; i++)
		{
			if ((LOGIC_SECTION_SUM_MAX > pLogicSectionIdBuf[i]) && (0U != pLogicSectionIdBuf[i]))
			{
				szHitOverlapLgcSec[pLogicSectionIdBuf[i]] = 1U;
			}
			else
			{
				retVal = CI_ERROR;
				break;
			}
		}

		for (j = 0U; j < phySecSum; j++)
		{
			/*获取物理区段关联逻辑区段信息*/
			cPhySecIncLogSecSum = GetPhySecIncLogSecSum(pPhySecIdBuf[j]);
			pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(pPhySecIdBuf[j]);
			if ((NULL == pPhySecIncLogSecId) || (0U == cPhySecIncLogSecSum))
			{
				retVal = CI_ERROR;
				break;
			}
			else
			{
				for (k = 0U; k < cPhySecIncLogSecSum; k++)
				{
					/*该逻辑区段不属于保护区段*/
					if (0U == szHitOverlapLgcSec[pPhySecIncLogSecId[k]])
					{
						logsecIdbuf[count] = pPhySecIncLogSecId[k];
						count++;
					}
				}
			}
		}
		*logSecSum = count;
	}
	else
	{
		retVal = CI_ERROR;
	}


	return retVal;
}

/*
* 功能描述： 设置保护区段锁闭命令由进路办理命令连带标志
* 参数说明： const UINT16 overlapId, 保护区段ID
*			 const UINT8 setFlag  标识
*/
void SetOverlapFromSetRouteCmdFlag(const UINT16 overlapId, const UINT8 setFlag)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		if ((OVERLAP_ROUTE_FLAG_YES == setFlag) || (OVERLAP_ROUTE_FLAG_NO == setFlag))
		{
			OverlapDataStru[bufIndex].OverlapFromSetRouteCmdFlag = setFlag;  /*设置命令标识*/
		}

	}
}

/*
* 功能描述： 获取保护区段锁闭命令由进路办理命令连带标志
* 参数说明： const UINT16 overlapId, 保护区段ID
* 返回值:0:失败
*        0<:连带标志
*/
UINT8 GetOverlapFromSetRouteCmdFlag(const UINT16 overlapId)
{
	UINT16 bufIndex = 0U;  /*数组下标*/
	UINT8 reVal = 0U;

	bufIndex = GetOverlapConfigBufIndex(overlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		reVal = OverlapDataStru[bufIndex].OverlapFromSetRouteCmdFlag;
	}

	return reVal;
}

/*
* 功能描述： 清保护区段人工或ATS锁闭命令标志
* 参数说明： const UINT16 routeId, 进路ID
*            const UINT16 overlapId, 保护区段ID
* 返回值:无
* by cgh 20240920
*/
void CleanOverlapAtsOrlaborLockFlag(const UINT16 routeId, const UINT16 overlapId)
{
	UINT16 overlapRouteSum = 0U;     /*保护区段进路数量*/
	UINT16* pOverlapRouteBuf = NULL; /*保护区段进路数据*/
	UINT16 atsExpLockOverlapId = 0U;  /*ATS期望锁闭的保护区段ID*/
	UINT16 routeLastPhyId = 0U;      /*进路最后一个物理区段ID*/
	UINT8 routeLastPhyState = 0U;   /*进路最后一个物理区段融合占用状态*/
	UINT16 ii = 0U;                  /*游标*/

	overlapRouteSum = GetOverlapRouteIdSum(overlapId);  /*获取保护区段进路数量*/
	pOverlapRouteBuf = GetOverlapRouteIdBuf(overlapId); /*获取保护区段进路数据*/

	for (ii = 0U; ii < overlapRouteSum; ii++)
	{
		atsExpLockOverlapId = GetRouteAtsExpLkOverlapId(pOverlapRouteBuf[ii]);
		routeLastPhyId = GetRouteLastPhySectionId(pOverlapRouteBuf[ii]);
		routeLastPhyState = GetPhySecCurMergeState(routeLastPhyId);
		if ((pOverlapRouteBuf[ii] != routeId) && (overlapId == atsExpLockOverlapId) && (SECTION_OCCUPY_YES == routeLastPhyState))
		{
			/*当前一条进路最后一个区段占用保护区段解锁倒计时快到时，办理另一条进路，此时清除保护区段ATS或人工锁闭命令标志，
			会导致后面的进路建立的保护区段根据占用时间去解锁*/
			break;
		}
	}
	if (ii == overlapRouteSum)
	{
		SetOverlapAtsOrlaborLockCmdFlag(overlapId, LOCK_OVERLAP_CMD_NO);
	}
}

/*
* 功能描述：设置保护区段防护道岔检查结果标志
* 参数说明：const UINT16 wOverlapId 保护区段ID
*			const UINT8 cCheckResultFlag 防护道岔检查结果标志
* 返 回 值：无
* Created By LQ 2024.12.03
*/
void SetOverlapProSwtCheckResultFlag(const UINT16 wOverlapId, const UINT8 cCheckResultFlag)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(wOverlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		if ((PROSWITCH_CHECK_RESULT_DEFAULT == cCheckResultFlag) || (PROSWITCH_CHECK_RESULT_VALID == cCheckResultFlag) || (PROSWITCH_CHECK_RESULT_INVALID == cCheckResultFlag))
		{
			if ((PROSWITCH_CHECK_RESULT_VALID == cCheckResultFlag) && (PROSWITCH_CHECK_RESULT_INVALID == OverlapDataStru[bufIndex].cProSwitchCheckResultFlag))
			{
				/*防护道岔检查结果标志不能直接由成功转失败*/
			}
			else
			{
				OverlapDataStru[bufIndex].cProSwitchCheckResultFlag = cCheckResultFlag;
			}
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：获取保护区段防护道岔检查结果标志
* 参数说明：const UINT16 wOverlapId 保护区段ID
* 返 回 值：0xFF 默认值
*			0x55 失败
*           0xAA 成功
* Created By LQ 2024.12.03
*/
UINT8 GetOverlapProSwtCheckResultFlag(const UINT16 wOverlapId)
{
	UINT16 bufIndex = 0U;  /*数组下标*/
	UINT8 cRetVal = PROSWITCH_CHECK_RESULT_INVALID;

	bufIndex = GetOverlapConfigBufIndex(wOverlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		cRetVal = OverlapDataStru[bufIndex].cProSwitchCheckResultFlag;
	}
	else
	{
		/*返回失败*/
	}

	return cRetVal;
}

/*
* 功能描述：设置保护区段防护道岔检查开始标志
* 参数说明：const UINT16 wOverlapId 保护区段ID
*			const UINT8 cCheckStartFlag 防护道岔检查开始标志
* 返 回 值：无
* Created By LQ 2024.12.03
*/
void SetOverlapProSwtCheckStartFlag(const UINT16 wOverlapId, const UINT8 cCheckStartFlag)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetOverlapConfigBufIndex(wOverlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		if ((PROSWITCH_CHECK_START_VALID == cCheckStartFlag) || (PROSWITCH_CHECK_START_INVALID == cCheckStartFlag))
		{
			OverlapDataStru[bufIndex].cProSwitchCheckStartFlag = cCheckStartFlag;
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：获取保护区段防护道岔检查开始标志
* 参数说明：const UINT16 wOverlapId 保护区段ID
* 返 回 值：0x55 检查开始
*           0xAA 检查停止
* Created By LQ 2024.12.03
*/
UINT8 GetOverlapProSwtCheckStartFlag(const UINT16 wOverlapId)
{
	UINT16 bufIndex = 0U;  /*数组下标*/
	UINT8 cRetVal = PROSWITCH_CHECK_START_INVALID;

	bufIndex = GetOverlapConfigBufIndex(wOverlapId);  /*获取数组下标*/

	if (bufIndex < OVERLAP_SUM_MAX)
	{
		cRetVal = OverlapDataStru[bufIndex].cProSwitchCheckStartFlag;
	}
	else
	{
		/*返回失败*/
	}

	return cRetVal;
}