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

#include "SignalDataManage.h"
#include "LinkConfigDataManage.h"
#include "CommonMemory.h"
#include "TrainDataManage.h"
#include "AxisSort_api.h"
#include "CutoffPointDataManage.h"
#include "CutoffPointConfigDataManage.h"
#include "TrainOnAcManage.h"
#include "EnvelopeManage.h"

SignalDataStruct SignalDataStru[SIGNAL_SUM_MAX];   /*定义信号机数据结构体*/


/*
* 功能描述： 获取指定ID信号数据
* 参数说明：    
* 返回值  ： 
            SignalDataStruct*
*/
SignalDataStruct *GetSignalData(void)
{
    return SignalDataStru;
}

/*
* 功能描述： 获取指定ID信号机封锁状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 封锁状态        
*/
UINT8 GetSignalFLockState(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 fLockState = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		fLockState = SignalDataStru[bufIndex].FLockState;
	}
	return fLockState;
}


/*
* 功能描述： 设置指定ID信号机封锁状态
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 fLockState, 封锁状态
* 返回值  ： 无
*			       
*/
void SetSignalFLockState(const UINT16 signalId, const UINT8 fLockState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_FENGSUO_NO == fLockState) || (SIGNAL_FENGSUO_YES == fLockState))
		{
			SignalDataStru[bufIndex].FLockState= fLockState;  /*信号机封锁状态*/
		}
	}
}


/*
* 功能描述： 获取指定ID信号机亮灭状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 亮灭状态        
*/
UINT8 GetSignalLightExtinctState(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 lightExtinctState = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		lightExtinctState = SignalDataStru[bufIndex].LightExtinctState;
	}
	return lightExtinctState;
}


/*
* 功能描述： 设置指定ID信号机亮灭状态
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 ligheCloseState, 亮灭状态
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetSignalLightExtinctState(const UINT16 signalId, const UINT8 lightExtinctState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;
	UINT8 cSleepTrainLightUpFlag = SIGNAL_SLEEP_TRAIN_LIGHTUP_NO;  /*休眠车点亮信号机标志*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_ALL_YES == lightExtinctState))
		{
			/*SignalDataStru[bufIndex].LightExtinctState = lightExtinctState;  信号机亮灭状态*/

			reVal = CI_SUCCESS;

			if (SIGNAL_LIGHT_EXTICT_STATE_ALL_YES == lightExtinctState)
			{/*如果是与ZC通信中断导致全站亮灯 则全部有效*/
				SignalDataStru[bufIndex].LightExtinctState = SIGNAL_LIGHT_EXTICT_STATE_YES;
			}
			else if (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState)
			{/*本次解析状态为亮灯*/
				if (SignalDataStru[bufIndex].SignalLightOnStateCycCount >= SIGNAL_LIGHTON_MID_COUNT)
				{/*之前为亮灯*/
					/*增加等于判断，防止计数乱跳，103 104 103 104...*/
					if (SignalDataStru[bufIndex].SignalLightOnStateCycCount >= (SIGNAL_LIGHTON_MID_COUNT + SIGNAL_LIGHTON_CHECK_VALUE))
					{/*超过了有效计数 重新设计为有效计数 防止越界*/
						SignalDataStru[bufIndex].SignalLightOnStateCycCount = (SIGNAL_LIGHTON_MID_COUNT + SIGNAL_LIGHTON_CHECK_VALUE);

						SignalDataStru[bufIndex].LightExtinctState = SIGNAL_LIGHT_EXTICT_STATE_YES;
					} 
					else
					{
						SignalDataStru[bufIndex].SignalLightOnStateCycCount++;
					}
				} 
				else
				{/*之前为灭灯 则从1计数*/
					SignalDataStru[bufIndex].SignalLightOnStateCycCount = (SIGNAL_LIGHTON_MID_COUNT + 1U);
				}
			} 
			else
			{/*本次解析状态为灭灯*/
				cSleepTrainLightUpFlag = GetSleepTrainLightUpSignalFlag(signalId);
				if (SIGNAL_SLEEP_TRAIN_LIGHTUP_YES != cSleepTrainLightUpFlag)
				{
					/*无休眠车点灯，设置灭灯*/
					if (SignalDataStru[bufIndex].SignalLightOnStateCycCount < SIGNAL_LIGHTON_MID_COUNT)
					{/*之前为灭灯*/
						/*增加等于判断，防止计数乱跳，97 96 97 96...*/
						if (SignalDataStru[bufIndex].SignalLightOnStateCycCount <= (SIGNAL_LIGHTON_MID_COUNT - SIGNAL_LIGHTON_CHECK_VALUE))
						{/*超过了有效计数 重新设计为有效计数 防止越界*/
							SignalDataStru[bufIndex].SignalLightOnStateCycCount = (SIGNAL_LIGHTON_MID_COUNT - SIGNAL_LIGHTON_CHECK_VALUE);

							SignalDataStru[bufIndex].LightExtinctState = SIGNAL_LIGHT_EXTICT_STATE_NO;
						}
						else
						{
							SignalDataStru[bufIndex].SignalLightOnStateCycCount--;
						}
					}
					else
					{/*之前为亮灯 则从1计数*/
						SignalDataStru[bufIndex].SignalLightOnStateCycCount = (SIGNAL_LIGHTON_MID_COUNT - 1U);
					}
				}
				else
				{
					/*当前存在休眠车点灯，不设置灭灯*/
				}
			}
		}
	}
	return reVal;
}
/*
* 功能描述： 设置相邻联锁指定ID信号机亮灭状态
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 ligheCloseState, 亮灭状态
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetNearCISigLightExtinctState(const UINT16 signalId, const UINT8 lightExtinctState)
{
	UINT16 bufIndex = 0u;/*数组下标*/
	UINT8 reVal = CI_ERROR;
	UINT8 localCi = 0u;/*本地联锁ID*/
	UINT8 belongCiId = 0u;/*进路所属联锁ID*/

	bufIndex = GetSignalConfigBufIndex(signalId);/*获取信号机数组下标*/
    localCi = GetSystemParaLocalCiId();/*本地联锁ID*/
	belongCiId = GetSignalBelongCiId(signalId);/*获取信号机所属联锁*/
	if(localCi != belongCiId)
	{
		if (SIGNAL_SUM_MAX > bufIndex)
		{
			if ((SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_ALL_YES == lightExtinctState))
			{
				SignalDataStru[bufIndex].LightExtinctState = lightExtinctState;  
				reVal = CI_SUCCESS;		
			}
			else
			{
			    reVal = CI_ERROR;
			}
		}
		else
		{
		    reVal = CI_ERROR;
		}
	}
	else 
	{
	    reVal = SetSignalLightExtinctState(signalId,lightExtinctState);/*设置本联锁指定ID信号机亮灭状态*/
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机之前显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 之前显示颜色        
*/
UINT8 GetSignalPreColor(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].PreColor;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机当前显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 之前显示颜色        
*/
UINT8 GetSignalCurColor(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].CurColor;
	}
	return reVal;
}


/*
* 功能描述： 设置指定ID信号机当前显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 curColor, 当前显示颜色
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetSignalCurColor(const UINT16 signalId, const UINT8 curColor)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

    UINT8 preDrvColor = 0u;/*之前驱动颜色*/
	UINT8 reVal = CI_ERROR;
	UINT32 curCycle = 0u;/*当前周期*/
	UINT16 relayId = 0u;
	UINT8 relayState = 0u; /*继电器状态*/
	UINT8 signalColorValid = 0u;

    preDrvColor = GetSignalPreDriveColor(signalId);/*获取之前驱动颜色*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	curCycle = Get2oo2CurCycleNum();/*获取当前周期*/


	if (SIGNAL_SUM_MAX > bufIndex)
	{
        SignalDataStru[bufIndex].PreColor = SignalDataStru[bufIndex].CurColor;/*信号机之前显示颜色*/

		signalColorValid = CheckSignalShowColorValid(curColor);
		if (CI_SUCCESS == signalColorValid)
		{
			SignalDataStru[bufIndex].CurColor = curColor;  /*信号机当前显示颜色*/

		    /*这是为了解决红亮转为红灭或红灭转为红亮之后,继电器动作开始周期不清零的问题*/
		    SignalDataStru[bufIndex].RelayActaionStartCycNum = 0u;/*信号机继电器动作开始周期清零*/
		    SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/

			/*当前亮绿灯*/
			if (SIGNAL_SHOWCOLOUR_GREEN == SignalDataStru[bufIndex].CurColor)
			{
				/*设置绿灯未断丝*/
				SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}
		    /*亮黄灯*/
			else if(SIGNAL_SHOWCOLOUR_YELLOW == SignalDataStru[bufIndex].CurColor)
			{
				/*设置黄灯未断丝*/
				SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}
			/*白灯*/
			else if(SIGNAL_SHOWCOLOUR_WHITE == SignalDataStru[bufIndex].CurColor)
			{
				/*设置白灯未断丝*/
				SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}
			/*红黄*/
			else if(SIGNAL_SHOWCOLOUR_REDYELLOW == SignalDataStru[bufIndex].CurColor)
			{
				/*设置红黄灯未断丝*/
				SignalDataStru[bufIndex].RedYellowDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}
			/*红白*/
			else if(SIGNAL_SHOWCOLOUR_RED_WHITE == SignalDataStru[bufIndex].CurColor)
			{
				/*设置红白灯未断丝*/
				SignalDataStru[bufIndex].RedWhiteDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}
			/*绿黄*/
			else if(SIGNAL_SHOWCOLOUR_GREENYELLOW == SignalDataStru[bufIndex].CurColor)
			{
				/*设置绿黄灯未断丝*/
				SignalDataStru[bufIndex].GreenYellowDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}
			/*双绿*/
			else if(SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == SignalDataStru[bufIndex].CurColor)
			{
				/*设置双绿灯未断丝*/
				SignalDataStru[bufIndex].DoubleGreenDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}
			/*双黄*/
			else if(SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == SignalDataStru[bufIndex].CurColor)
			{
				/*设置双黄灯未断丝*/
				SignalDataStru[bufIndex].DoubleYellowDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}
			else
			{
				/*不做处理*/
			}
		}
		else
		{/*显示颜色无效*/

			switch (SignalDataStru[bufIndex].PreColor)
			{
            case SIGNAL_SHOWCOLOUR_RED:/*之前红亮*/
				if(SIGNAL_DRIVECOLOUR_REDYELLOW == SignalDataStru[bufIndex].PreDriveColor)
				{/*该状况为:驱动红黄灯,但是红灯发生断丝*/
					relayId = GetSignalFirstDsRelayId(signalId);
					relayState = GetRelayCollState(relayId);
					if(RELAY_STATE_UP == relayState)
					{
	                    SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
						SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
					}
				}
				else if(SIGNAL_DRIVECOLOUR_RED == SignalDataStru[bufIndex].PreDriveColor)
				{
					relayId = GetSignalFirstDsRelayId(signalId);
					relayState = GetRelayCollState(relayId);
					if(RELAY_STATE_UP ==relayState)
					{/*该状况为:由驱动红黄灯(或红白灯)转为驱动红灯,但是2DJ未及时落下*/
						if(RELAY_STATE_UP == GetRelayCollState(GetSignalSecondDsRelayId(signalId)))
						{
							if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
							{
								/*继电器动作开始周期为0*/
								SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
							}
							else
							{
								if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
								{
									SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
								}
								else
								{
									/*继电器动作延时等待结束*/
									SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
									SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
								}
							}
						}
						else
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红灯*/
						}
					}
					else
					{						
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
						SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
					}
				}
				else if(SIGNAL_DRIVECOLOUR_REDCLOSE == SignalDataStru[bufIndex].PreDriveColor)
				{
            		if(SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						if(SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if(SIGNAL_DRIVECOLOUR_GREENCLOSE == SignalDataStru[bufIndex].PreDriveColor)
				{
            		if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if(SIGNAL_DRIVECOLOUR_YELLOWCLOSE == SignalDataStru[bufIndex].PreDriveColor)
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_RED_WHITE == SignalDataStru[bufIndex].PreDriveColor)
				{/*该状况为:驱动红白灯,但是红灯发生断丝*/
					if(GetRelayCollState(GetSignalFirstDsRelayId(signalId)) == RELAY_STATE_UP)
					{/*由于2DJ缓吸，采集到无效颜色时保持红灯，等待2DJ吸起*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
						SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
					}
				}
				else if (SIGNAL_DRIVECOLOUR_GREENYELLOW == SignalDataStru[bufIndex].PreDriveColor)/*红--->绿黄*/
				{/*该状况为:驱动绿黄灯*/
					if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_YELLOW == SignalDataStru[bufIndex].PreDriveColor)/*之前驱黄灯,红-->黄*/
				{
					if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE == SignalDataStru[bufIndex].PreDriveColor)/*之前驱绿黄灭,红-->绿黄灭*/
				{
					if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_DOUBLE_GREEN == SignalDataStru[bufIndex].PreDriveColor)/*之前驱双绿,红-->双绿*/
				{
					if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW == SignalDataStru[bufIndex].PreDriveColor)/*之前驱双黄,红-->双黄*/
				{
					if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_GREEN == SignalDataStru[bufIndex].PreDriveColor)/*之前驱绿灯,红-->绿*/
				{
					if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else
				{ 
					SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/										
				}
				break;
            case SIGNAL_SHOWCOLOUR_GREEN:/*之前绿亮*/
				if(SIGNAL_DRIVECOLOUR_GREENCLOSE == SignalDataStru[bufIndex].PreDriveColor)
				{
            		if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*设置信号机绿亮*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*设置信号机绿亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_REDCLOSE == SignalDataStru[bufIndex].PreDriveColor)
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
					}
					else
					{
						if (SIGNAL_OPEN_TO_CLOSE_TIME_DELAY >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE == SignalDataStru[bufIndex].PreDriveColor)/*绿--》绿黄灭*/
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*设置信号机绿灯*/
					}
					else
					{
						if (SIGNAL_OPEN_TO_CLOSE_TIME_DELAY >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*设置信号机绿灯*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_GREENYELLOW == SignalDataStru[bufIndex].PreDriveColor)/*绿--》绿黄*/
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*设置信号机绿灯*/
					}
					else
					{
						if (SIGNAL_OPEN_TO_CLOSE_TIME_DELAY >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*设置信号机绿灯*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_RED == SignalDataStru[bufIndex].PreDriveColor)/*绿-->驱红*/
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红灯*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红灯*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_YELLOW == SignalDataStru[bufIndex].PreDriveColor)/*绿-->驱黄*/
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_GREEN;/*设置信号机绿灯*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_GREEN;/*设置信号机绿灯*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				/*驱绿灯*/
				else if(SIGNAL_DRIVECOLOUR_GREEN == SignalDataStru[bufIndex].PreDriveColor)
				{
					SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
					SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置绿灯断丝标志*/		
				}
				else
				{
					SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
					SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/					
				}
                break;
            case SIGNAL_SHOWCOLOUR_YELLOW:/*之前黄亮*/
				if(SIGNAL_DRIVECOLOUR_YELLOWCLOSE == SignalDataStru[bufIndex].PreDriveColor)
				{
            		if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOW;/*设置信号机黄亮*/
					}
					else
					{
						if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOW;/*设置信号机黄亮*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_REDCLOSE == SignalDataStru[bufIndex].PreDriveColor)
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
					}
					else
					{
						if (SIGNAL_OPEN_TO_CLOSE_TIME_DELAY >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum))
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_RED == SignalDataStru[bufIndex].PreDriveColor)/*黄-->驱红*/
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红灯*/
					}
					else
					{
						if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_OPEN_TO_CLOSE_TIME_DELAY)
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红灯*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_GREEN == SignalDataStru[bufIndex].PreDriveColor)/*黄-->驱绿*/
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_YELLOW;/*设置信号机黄灯*/
					}
					else
					{
						if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX)
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_YELLOW;/*设置信号机黄灯*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				/*驱黄灯*/
				else if(SIGNAL_DRIVECOLOUR_YELLOW == SignalDataStru[bufIndex].PreDriveColor)
				{
					SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
					SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置黄灯断丝标志*/
				}
				else
				{
					SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
					SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
				}
                break;
            case SIGNAL_SHOWCOLOUR_WHITE:/*之前白亮*/
				/*驱动白灯*/
				if(SIGNAL_DRIVECOLOUR_WHITE == SignalDataStru[bufIndex].PreDriveColor)
				{
					SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_WHITEBREAK;/*设置信号机白断*/
					SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置白灯断丝标志*/
				}
				else
				{
					SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_WHITEBREAK;/*设置信号机白断*/
					SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
				}

                break;
            case SIGNAL_SHOWCOLOUR_REDYELLOW:/*之前红黄亮*/
                if (GetRelayCollState(GetSignalFirstDsRelayId(signalId)) == RELAY_STATE_DOWN)
                {/*1灯丝继电器落下*/

                    SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
                    SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
                }
                else
                {
                	if(GetRelayCollState(GetSignalSecondDsRelayId(signalId)) == RELAY_STATE_DOWN)
                	{
						if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
						{
							/*继电器动作开始周期为0*/
							SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDYELLOW;/*设置信号机红黄亮*/
						}
						else
						{
							if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
							{
								/*继电器动作延时等待结束*/
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
								SignalDataStru[bufIndex].RedYellowDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置红黄断丝标志*/
							}
							else
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDYELLOW;/*设置信号机红黄亮*/
							}
						}    	
                	}
                	else
                	{
                    	SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
                    }
                }

                break;
            case SIGNAL_SHOWCOLOUR_GREENCLOSE:/*之前绿灭*/
                if (preDrvColor == SIGNAL_DRIVECOLOUR_GREEN)
                {
                	/*之前驱动绿亮*/
                    if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
                    {
                    	/*继电器动作开始周期为0*/
                        SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
                        SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENCLOSE;/*设置信号机绿灭*/
                    }
                    else
                    {
                        if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
                        {
                        	/*继电器动作延时等待结束*/
                            SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
                        }
                        else
                        {
                            SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENCLOSE;/*设置信号机绿灭*/
                        }
                    }
                }
				else if (SIGNAL_DRIVECOLOUR_RED == SignalDataStru[bufIndex].PreDriveColor)
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红灯*/
					}
					else
					{
						if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_OPEN_TO_CLOSE_TIME_DELAY)
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红灯*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_REDCLOSE == SignalDataStru[bufIndex].PreDriveColor)/*绿灭到红灭*/
				{
					if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
					}
					else
					{
						if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX)
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_GREENYELLOW == SignalDataStru[bufIndex].PreDriveColor)/*绿灭-->绿黄*/
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENCLOSE;/*设置信号机绿灭*/
					}
					else
					{
						if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_OPEN_TO_CLOSE_TIME_DELAY)
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENCLOSE;/*设置信号机绿灭*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
                else
                {
                    SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
					SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
                }
				break;
            case SIGNAL_SHOWCOLOUR_YELLOWCLOSE:/*之前黄灭*/
                if (preDrvColor == SIGNAL_DRIVECOLOUR_YELLOW)
                {/*之前驱动为黄亮*/
                    if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
                    {/*继电器动作开始周期为0*/
                        
                        SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
                        SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/*设置信号机黄灭*/
                    }
                    else
                    {
                        if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
                        {/*继电器动作延时等待结束*/
                            
                            SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
                        }
                        else
                        {
                            SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/*设置信号机黄灭*/
                        }
                    }
                }
				else if (SIGNAL_DRIVECOLOUR_RED == SignalDataStru[bufIndex].PreDriveColor)
				{
					if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红灯*/
					}
					else
					{
						if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_OPEN_TO_CLOSE_TIME_DELAY)
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红灯*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
				else if (SIGNAL_DRIVECOLOUR_REDCLOSE == SignalDataStru[bufIndex].PreDriveColor)
				{
					if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
					{
						/*继电器动作开始周期为0*/
						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
					}
					else
					{
						if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX)
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
						}
						else
						{
							/*继电器动作延时等待结束*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
					}
				}
                else
                {
                    SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
					SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
                }
				break;
			case SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE:/*之前绿黄灭*/
				{
					if (SIGNAL_DRIVECOLOUR_GREENYELLOW == preDrvColor)/*绿黄灭-->绿黄*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{/*继电器动作开始周期为0*/

							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*设置信号机绿黄灭*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
							{/*继电器动作延时等待结束*/

								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
							else
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*设置信号机绿黄灭*/
							}
						}
					}
					else if (SIGNAL_DRIVECOLOUR_GREEN == preDrvColor)/*绿黄灭-->绿*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{/*继电器动作开始周期为0*/

							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*设置信号机绿黄灭*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
							{/*继电器动作延时等待结束*/

								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
							else
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*设置信号机绿黄灭*/
							}
						}
					}
					else if (SIGNAL_DRIVECOLOUR_GREENCLOSE == preDrvColor)/*绿黄灭-->绿灭*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{/*继电器动作开始周期为0*/

							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*设置信号机绿黄灭*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
							{/*继电器动作延时等待结束*/

								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
							else
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*设置信号机绿黄灭*/
							}
						}
					}
					else if (SIGNAL_DRIVECOLOUR_RED == preDrvColor)/*绿黄灭-->红*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{/*继电器动作开始周期为0*/

							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
							{/*继电器动作延时等待结束*/

								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
							else
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红*/
							}
						}
					}
					else if (SIGNAL_DRIVECOLOUR_REDCLOSE == preDrvColor)/*绿黄灭-->红灭*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{/*继电器动作开始周期为0*/

							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_REDCLOSE;/*设置信号机黄灭*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
							{/*继电器动作延时等待结束*/

								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
							else
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_REDCLOSE;/*设置信号机红灭*/
							}
						}
					}
					else
					{
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
						SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
					}
				}
				break;
            case SIGNAL_SHOWCOLOUR_REDCLOSE:/*之前红灭*/
                if (preDrvColor == SIGNAL_DRIVECOLOUR_RED)
                {/*之前驱动为红亮*/
                    if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
                    {/*继电器动作开始周期为0*/
                        
                        SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
                        SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
                    }
                    else
                    {
                        if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
                        {/*继电器动作延时等待结束*/
                            
                            SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
                        }
                        else
                        {
                            SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
                        }
                    }
                }
				else if(SIGNAL_DRIVECOLOUR_REDCLOSE == preDrvColor)
				{
					if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
					{/*继电器动作开始周期为0*/

						SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
					}
					else
					{
						if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
						{/*继电器动作延时等待结束*/

							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
						else
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
						}
					}
				}
				else if ((SIGNAL_DRIVECOLOUR_YELLOW==preDrvColor  ) || (SIGNAL_DRIVECOLOUR_YELLOWCLOSE==preDrvColor  )
					|| (SIGNAL_DRIVECOLOUR_GREEN==preDrvColor  ) || (SIGNAL_DRIVECOLOUR_GREENCLOSE==preDrvColor  )
					|| (SIGNAL_DRIVECOLOUR_GREENYELLOW==preDrvColor))
				{
					if (0u ==SignalDataStru[bufIndex].RelayActaionStartCycNum  )
					{/*继电器动作开始周期为0*/

						SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
					}
					else
					{
						if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
						{/*继电器动作延时等待结束*/

							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
						else
						{
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*设置信号机红灭*/
						}
					}

				}
                else
                {
                    SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
					SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
                }
                break;
			case SIGNAL_SHOWCOLOUR_RED_WHITE:/*之前红白亮*/
				if (GetRelayCollState(GetSignalFirstDsRelayId(signalId)) == RELAY_STATE_DOWN)
				{/*1灯丝继电器落下*/

					SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
					SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
				}
				else
				{
					if(GetRelayCollState(GetSignalSecondDsRelayId(signalId)) == RELAY_STATE_DOWN)
					{/*引导信号保持期间2DJ故障落下*/
						if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u)
						{
							/*继电器动作开始周期为0*/
							SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED_WHITE;/*设置信号机红白亮*/
						}
						else
						{
							if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
							{
								/*继电器动作延时等待结束*/
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
								SignalDataStru[bufIndex].RedWhiteDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置红白断丝标志*/
							}
							else
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED_WHITE;/*设置信号机红白亮*/
							}
						}    	
					}
					else
					{
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*设置信号机红亮*/
					}
				}
				break;
			case SIGNAL_SHOWCOLOUR_GREENYELLOW:/*之前显示绿黄灯*/
				{
					if (SIGNAL_DRIVECOLOUR_GREEN == preDrvColor)/*且之前驱绿灯，绿黄--》绿，需容忍10个周期*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{
							/*继电器动作开始周期为0*/
							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*设置信号机绿黄亮*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX)
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*设置信号机绿黄亮*/
							}
							else
							{
								/*继电器动作延时等待结束*/
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
						}
					}
					else if (SIGNAL_DRIVECOLOUR_REDCLOSE == preDrvColor)/*且之前驱绿灯，绿黄--》红灭，需容忍10个周期*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{
							/*继电器动作开始周期为0*/
							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*设置信号机绿黄亮*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX)
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*设置信号机绿黄亮*/
							}
							else
							{
								/*继电器动作延时等待结束*/
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
						}
					}
					else if (SIGNAL_DRIVECOLOUR_RED == preDrvColor)/*且之前驱绿灯，绿黄--》红，需容忍10个周期*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{
							/*继电器动作开始周期为0*/
							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX)
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红*/
							}
							else
							{
								/*继电器动作延时等待结束*/
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
						}
					}
					else if ((SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE == preDrvColor) ||
						(SIGNAL_DRIVECOLOUR_GREENCLOSE == preDrvColor))/*且之前驱绿灯，绿黄--》绿黄灭/绿灭，需容忍10个周期*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{
							/*继电器动作开始周期为0*/
							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*设置信号机绿黄亮*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX)
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*设置信号机绿黄亮*/
							}
							else
							{
								/*继电器动作延时等待结束*/
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
						}
					}
					/*驱绿黄灯*/
					else if(SIGNAL_DRIVECOLOUR_GREENYELLOW == preDrvColor)
					{
						/*继电器动作延时等待结束*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
						SignalDataStru[bufIndex].GreenYellowDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置绿黄断丝标志*/
					}
					else
					{
						/*继电器动作延时等待结束*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
						SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
					}
				}
				break;
			case SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW:/*之前显示双黄灯*/
				{
					if (SIGNAL_DRIVECOLOUR_RED == preDrvColor)/*双黄到红*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{
							/*继电器动作开始周期为0*/
							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX)
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红*/
							}
							else
							{
								/*继电器动作延时等待结束*/
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
						}
					}
					/*驱双黄*/
					else if(SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW == preDrvColor)
					{
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
						SignalDataStru[bufIndex].DoubleYellowDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置双黄断丝标志*/
					}
					else
					{
						/*继电器动作延时等待结束*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*设置信号机黄断*/
						SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
					}
				}
				break;
			case SIGNAL_SHOWCOLOUR_DOUBLE_GREEN:/*之前显示双绿灯*/
				{
					if (SIGNAL_DRIVECOLOUR_RED == preDrvColor)/*双绿到红*/
					{
						if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum)
						{
							/*继电器动作开始周期为0*/
							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX)
							{
								SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*设置信号机红*/
							}
							else
							{
								/*继电器动作延时等待结束*/
								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
						}
					}
					/*双绿*/
					else if(SIGNAL_DRIVECOLOUR_DOUBLE_GREEN == preDrvColor)
					{
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
						SignalDataStru[bufIndex].DoubleGreenDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置双绿断丝标志*/
					}
					else
					{
						/*继电器动作延时等待结束*/
						SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*设置信号机绿断*/
						SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
					}
				}
				break;
			case SIGNAL_SHOWCOLOUR_GREENBREAK:/*绿断*/
			case SIGNAL_SHOWCOLOUR_YELLOWBREAK:/*黄断*/
			case SIGNAL_SHOWCOLOUR_WHITEBREAK:/*白断*/ 
				{/*之前颜色为非红灯断丝（绿断或者黄断或者白断），且驱红灯或红灭时，做容忍*/
					if ((SIGNAL_DRIVECOLOUR_RED == preDrvColor) || (SIGNAL_SHOWCOLOUR_REDCLOSE == preDrvColor))
					{
						if (0u ==SignalDataStru[bufIndex].RelayActaionStartCycNum  )
						{/*继电器动作开始周期为0*/

							SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*设置当前周期*/
							SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
						}
						else
						{
							if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX)
							{/*继电器动作延时等待结束*/

								SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
							else
							{
								/*信号机当前颜色不设置，维持非红灯断丝不变*/
								SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
							}
						}
					}
				}
				break;
            default:
                SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*设置信号机红断*/
				SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
                break;
			}
		}

        /*信号机已驱动开放*/
        if (GetSignalOpenCloseState(curColor) == SIGNAL_OPEN)
        {   
            /*设置信号驱动开放周期*/
            SignalDataStru[bufIndex].DriveSigOpenStartCycNum = 0u;
        }
        else
        {/*信号已驱动关闭*/

            /*信号驱动关闭周期清零*/
            SignalDataStru[bufIndex].DriveSigCloseStartCycNum = 0u;
        }

        reVal = CI_SUCCESS;
	}
	return reVal;
}
/*
* 功能描述： 设置相邻联锁指定ID信号机当前显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 curColor, 当前显示颜色
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetNearCISignalCurColor(const UINT16 signalId, const UINT8 curColor)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 localCi = 0u;/*本地联锁ID*/
	UINT8 belongCiId = 0u;/*信号机所属联锁ID*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/
	localCi = GetSystemParaLocalCiId();/*本地联锁ID*/
	belongCiId = GetSignalBelongCiId(signalId);/*获取信号机所属联锁*/
	
	if(localCi !=belongCiId)
	{
		if (bufIndex < SIGNAL_SUM_MAX)
		{
			SignalDataStru[bufIndex].PreColor = SignalDataStru[bufIndex].CurColor;/*信号机之前显示颜色*/
			SignalDataStru[bufIndex].CurColor = curColor;  /*信号机当前显示颜色*/
			reVal = CI_SUCCESS;
		}
		else
		{
			reVal = CI_ERROR;
		}
	}
	else
	{
		reVal = SetSignalCurColor(signalId,curColor);
	}
	 return reVal;
}

/*
* 功能描述： 获取指定ID信号机之前驱动显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 驱动显示颜色        
*/
UINT8 GetSignalPreDriveColor(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].PreDriveColor;
	}
	return reVal;
}

/*
* 功能描述： 设置指定ID信号机之前驱动显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 driveColor, 驱动显示颜色
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetSignalPreDriveColor(const UINT16 signalId, const UINT8 driveColor)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;
	
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/
	
	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if (SignalDataStru[bufIndex].PreDriveColor != driveColor)
		{
			/*上一驱动任务已经或改变 重置过渡周期*/
			(void)SetSignalDiffColorOpenStartCyc(signalId, 0U); /*清空信号机驱动开放颜色不等于当前开放颜色起始周期*/
		}
		SignalDataStru[bufIndex].PreDriveColor = driveColor;
			
		reVal = CI_SUCCESS;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机当前驱动显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 驱动显示颜色        
*/
UINT8 GetSignalCurDriveColor(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].CurDriveColor;
	}
	return reVal;
}


/*
* 功能描述： 设置指定ID信号机当前驱动显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 driveColor, 驱动显示颜色
* 返回值  ： 无
*			       
*/
void SetSignalCurDriveColor(const UINT16 signalId, const UINT8 driveColor)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 curDrvColor = 0u;/*当前驱动颜色*/
    UINT8 sigDrvEnable = 0u;/*信号机是否可驱动标志*/
	UINT8 sigVirtAttr = 0u;/*信号机虚拟属性*/
	UINT8 localCiPattern = CI_PATTERN_TRADITIONAL;
	UINT8 chDriveColor = SIGNAL_DRIVECOLOUR_RED;
	UINT8 funSwitchGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*显示绿黄功能开关是否打开*/
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/
	curDrvColor = GetSignalCurDriveColor(signalId);/*获取当前驱动颜色*/
	sigDrvEnable = GetSignalDrvEnable(signalId);/*获取信号机是否可驱动标志*/
	sigVirtAttr = GetSignalVirtualAttr(signalId);/*获取信号机虚拟属性*/
	localCiPattern = GetLocalCiPattern();
	if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern)
	{
		sigDrvEnable = SIGNAL_DRV_ENABLE;
	}

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((CI_SUCCESS == CheckSignalDriveColorValid(driveColor)) &&
			((SIGNAL_DRV_ENABLE == sigDrvEnable)|| (SIGNAL_VIRTUAL_YES == sigVirtAttr)))
		{/*驱动颜色有效且（信号机为虚拟信号机或者可驱动非虚拟信号机）*/
			if (SIGNAL_DRIVECOLOUR_NULL == driveColor)
			{
                /*设置信号驱动颜色无效*/
				SignalDataStru[bufIndex].CurDriveColor = SIGNAL_DRIVECOLOUR_NULL;
			}
            else if ((SIGNAL_DRIVECOLOUR_RED == driveColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == driveColor))
			{/*信号机驱动颜色为红亮或红灭*/
				
				if ((FUNC_SWITCH_ON == funSwitchGreenYellow) && (SIGNAL_DRIVECOLOUR_REDCLOSE == driveColor))
				{
					chDriveColor = SIGNAL_DRIVECOLOUR_RED;
				}
				else
				{
					chDriveColor = driveColor;
				}
				SignalDataStru[bufIndex].CurDriveColor = chDriveColor;  /*信号机当前驱动显示颜色*/
                
                if (SignalDataStru[bufIndex].DriveSigCloseStartCycNum == 0u)
                {
                    if (GetSignalType(signalId) == SIGNAL_TYPE_TWO_JINKU_RGY)
                    {
                        /*清空驱动周期*/
                        SignalDataStru[bufIndex].DriveSigCloseStartCycNum = 0u;
                    }
                    else
                    {
                        /*设置信号驱动关闭周期*/
                        SignalDataStru[bufIndex].DriveSigCloseStartCycNum = Get2oo2CurCycleNum();
                    }
                    
                    
                }     
                else
                {
                    /*已设置*/
                }
                
                /*信号驱动开放周期清零*/
                SignalDataStru[bufIndex].DriveSigOpenStartCycNum = 0u;
			}
			else if(SIGNAL_DRIVECOLOUR_NULL == curDrvColor)/*之前为无效*/
			{/*开放信号*/
				
				SignalDataStru[bufIndex].CurDriveColor = driveColor;  /*信号机当前驱动显示颜色*/

                /*信号驱动关闭周期清零*/
                SignalDataStru[bufIndex].DriveSigCloseStartCycNum = 0u;

				if (SignalDataStru[bufIndex].DriveSigOpenStartCycNum == 0u)
                {

                    if (GetSignalType(signalId) == SIGNAL_TYPE_TWO_JINKU_RGY)
                    {
                        /*清空驱动周期*/
                        SignalDataStru[bufIndex].DriveSigOpenStartCycNum = 0u;
                    }
                    else
                    {
                        /*设置信号驱动开放周期*/
                        SignalDataStru[bufIndex].DriveSigOpenStartCycNum = Get2oo2CurCycleNum();
                    }
                     	
				}
                else
                {
                    /*已设置*/
                }                		
			}
			else
			{/*其他情况*/
				
				/*不做处理*/
			}					
		}
		else
		{
            /*设置信号驱动颜色无效*/
            SignalDataStru[bufIndex].CurDriveColor = SIGNAL_DRIVECOLOUR_NULL;
		}

		if(	(SignalDataStru[bufIndex].PreDriveColor != SignalDataStru[bufIndex].CurDriveColor)
			&&
			(SignalDataStru[bufIndex].CurDriveColor != SIGNAL_DRIVECOLOUR_NULL))
		{/*当信号驱动颜色变更的并且该驱动颜色有效时,更新驱动新颜色起始周期号,更新变更之前的驱动颜色.本段代码是为了解决红驱绿或绿驱红时,期间闪现黄灯的问题*/
			SignalDataStru[bufIndex].DriveNewSigStartCycNum = Get2oo2CurCycleNum();
			SignalDataStru[bufIndex].OldDriveColor = SignalDataStru[bufIndex].PreDriveColor;
			/*若存在OC采集全灭 则清零采集全灭起始周期号*/
			SetOcSignalStartCycNum(signalId, 0U);
		}
		else
		{
			/*不做任何处理*/
			;
		}
	}
	else
	{
		/*不做处理*/
	}
}


/*
* 功能描述： 获取指定ID信号机灯丝断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 断丝标志        
*/
UINT8 GetSignalDsBreakFlag(const UINT16 signalId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].DsBreakFlag;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机绿灯丝断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 断丝标志        
*/
UINT8 GetSignalGreenDsBreakFlag(const UINT16 signalId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].GreenDsBreakFlag;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机黄灯丝断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 断丝标志        
*/
UINT8 GetSignalYellowDsBreakFlag(const UINT16 signalId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].YellowDsBreakFlag;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机白灯丝断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 断丝标志        
*/
UINT8 GetSignalWhiteDsBreakFlag(const UINT16 signalId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].WhiteDsBreakFlag;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机蓝灯丝断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 断丝标志
*/
UINT8 GetSignalBlueDsBreakFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].BlueDsBreakFlag;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机红黄灯丝断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 断丝标志        
*/
UINT8 GetSignalRedYellowDsBreakFlag(const UINT16 signalId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].RedYellowDsBreakFlag;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机红白灯丝断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 断丝标志        
*/
UINT8 GetSignalRedWhiteDsBreakFlag(const UINT16 signalId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].RedWhiteDsBreakFlag;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机绿黄灯丝断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 断丝标志        
*/
UINT8 GetSignalGreenYellowDsBreakFlag(const UINT16 signalId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].GreenYellowDsBreakFlag;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机双绿灯丝断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 断丝标志        
*/
UINT8 GetSignalDoubleGreenDsBreakFlag(const UINT16 signalId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].DoubleGreenDsBreakFlag;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机双黄灯丝断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 断丝标志        
*/
UINT8 GetSigDoubleYellowDsBreakFlag(const UINT16 signalId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].DoubleYellowDsBreakFlag;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机驱动开放起始周期号
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 驱动开放起始周期号        
*/
UINT32 GetSignalDriveOpenStartCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].DriveSigOpenStartCycNum;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机驱动关闭起始周期号
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 驱动关闭起始周期号        
*/
UINT32 GetSignalDriveCloseStartCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].DriveSigCloseStartCycNum;
	}
	return reVal;
}

/*
* 功能描述： 获取指定ID信号机驱动新信号起始周期号
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 驱动新信号起始周期号        
*/
UINT32 GetSignalDriveNewSigStartCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].DriveNewSigStartCycNum;
	}

	return reVal;
}

/*
* 功能描述： 获取指定ID信号机驱动信号机颜色变化之前,驱动信号机显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 驱动显示颜色        
*/
UINT8 GetSignalOldDriveColor(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].OldDriveColor;
	}

	return reVal;
}

/*
* 功能描述： 检查信号机显示颜色有效
* 参数说明： const UINT8 showColor, 信号机显示颜色
* 返回值  ： 0: 显示无效
*			 1: 显示有效      
*/
UINT8 CheckSignalShowColorValid(const UINT8 showColor)
{
	UINT8 reVal = CI_ERROR;

    if ((SIGNAL_SHOWCOLOUR_RED == showColor) || (SIGNAL_SHOWCOLOUR_GREEN == showColor) || (SIGNAL_SHOWCOLOUR_YELLOW == showColor)
        || (SIGNAL_SHOWCOLOUR_REDYELLOW == showColor) || (SIGNAL_SHOWCOLOUR_WHITE == showColor) || (SIGNAL_SHOWCOLOUR_REDCLOSE == showColor) 
        || (SIGNAL_SHOWCOLOUR_GREENCLOSE == showColor) || (SIGNAL_SHOWCOLOUR_YELLOWCLOSE == showColor) || (SIGNAL_SHOWCOLOUR_RED_WHITE == showColor)
		|| (SIGNAL_SHOWCOLOUR_GREENYELLOW == showColor) || (SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE == showColor)
		|| (SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == showColor) || (SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == showColor)
		)
    {
        reVal = CI_SUCCESS;  /*信号机显示有效*/
    }
	return reVal;
}


/*
* 功能描述： 检查信号机驱动颜色有效
* 参数说明： const UINT8 drvColor, 信号机驱动颜色
* 返回值  ： 0: 驱动无效
*			 1: 驱动有效      
*/
UINT8 CheckSignalDriveColorValid(const UINT8 drvColor)
{
	UINT8 reVal = CI_ERROR;


    if ((SIGNAL_DRIVECOLOUR_RED == drvColor) || (SIGNAL_DRIVECOLOUR_YELLOW == drvColor) || (SIGNAL_DRIVECOLOUR_REDYELLOW == drvColor)
        || (SIGNAL_DRIVECOLOUR_GREEN == drvColor) || (SIGNAL_DRIVECOLOUR_YELLOWCLOSE == drvColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == drvColor) 
        || (SIGNAL_DRIVECOLOUR_GREENCLOSE == drvColor) || (SIGNAL_DRIVECOLOUR_WHITE == drvColor)|| (SIGNAL_DRIVECOLOUR_RED_WHITE == drvColor)
		|| (SIGNAL_DRIVECOLOUR_GREENYELLOW == drvColor) || (SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE == drvColor)
		|| (SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == drvColor) || (SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == drvColor)
		||(SIGNAL_DRIVECOLOUR_NULL == drvColor))
    {
        reVal = CI_SUCCESS; /*信号机驱动有效*/
    }

	return reVal;
}


/*
* 功能描述： 获取通信车跨压通过信号机状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0: 获取成功      
*/
UINT8 GetSignalCrossState(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;
	
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/
	
	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_CROSS_STATE_NO == SignalDataStru[bufIndex].SignalCrossState) || (SIGNAL_CROSS_STATE_YES == SignalDataStru[bufIndex].SignalCrossState))
		{
			reVal = SignalDataStru[bufIndex].SignalCrossState;
		}		
	}
	return reVal;
}


/*
* 功能描述： 设置通信车跨压通过信号机状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 设置失败
*			>0: 设置成功      
*/
UINT8 SetSignalCrossState(const UINT16 signalId, const UINT8 signalCrossState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;
	
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/
	
	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_CROSS_STATE_NO == signalCrossState) || (SIGNAL_CROSS_STATE_YES == signalCrossState))
		{
			SignalDataStru[bufIndex].SignalCrossState = signalCrossState;  /*设置通信车跨压通过信号机状态*/
			reVal = CI_SUCCESS;
		}
	}
	return reVal;
}

/*
* 功能描述： 获取信号机颜色开放关闭状态
* 参数说明： UINT8 signalColor
* 返回值  ： 0: 获取失败
*			>0: 获取成功      
*/
UINT8 GetSignalOpenCloseState(UINT8 signalColor)
{
    UINT8 reVal = SIGNAL_CLOSE;

    if ((SIGNAL_SHOWCOLOUR_GREEN == signalColor) || 
        (SIGNAL_SHOWCOLOUR_YELLOW == signalColor) || 
        (SIGNAL_SHOWCOLOUR_REDYELLOW == signalColor) || 
        (SIGNAL_SHOWCOLOUR_WHITE == signalColor) || 
        (SIGNAL_SHOWCOLOUR_GREENCLOSE == signalColor) || 
        (SIGNAL_SHOWCOLOUR_YELLOWCLOSE == signalColor) ||
		(SIGNAL_SHOWCOLOUR_RED_WHITE == signalColor) ||
		(SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == signalColor) ||
		(SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == signalColor) ||
		(SIGNAL_SHOWCOLOUR_GREENYELLOW == signalColor) || 
		(SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE == signalColor) 
		)
    { /*绿灯||黄灯||红黄灯||白灯||绿灭||黄灭||红白灯||双绿||双黄||绿黄||绿黄灭*/

        reVal = SIGNAL_OPEN;  /*信号开放*/
    }
    return reVal;
}

/*
* 功能描述： 获取引导总锁信号机开放状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0: 获取成功      
*/
UINT8 GetSignalYLockOpenState(const UINT16 signalId)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;
    
    bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/
    
    if (bufIndex < SIGNAL_SUM_MAX)
    {
        if ((SIGNAL_OPEN == SignalDataStru[bufIndex].SignalYLockOpenState) || (SIGNAL_CLOSE == SignalDataStru[bufIndex].SignalYLockOpenState))
        {
            reVal = SignalDataStru[bufIndex].SignalYLockOpenState;
        }
    }
	return reVal;
}

/*
* 功能描述： 获取信号机包含的所有的进路是否既有CBTC场段区域的进路，也有非CBTC场段区域进路的标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0: 获取成功
*/
UINT8 GetSignalLeadRouteCbtcFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_LEADROUTE_ALLCBTC == SignalDataStru[bufIndex].SignalLeadRouteCbtcFlag)
			|| (SIGNAL_LEADROUTE_ALL_NO_CBTC == SignalDataStru[bufIndex].SignalLeadRouteCbtcFlag)
			|| (SIGNAL_LEADROUTE_CBTC_ANDNO == SignalDataStru[bufIndex].SignalLeadRouteCbtcFlag))
		{
			reVal = SignalDataStru[bufIndex].SignalLeadRouteCbtcFlag;
		}
	}
	return reVal;
}

/*
* 功能描述： 设置引导总锁信号机开放状态
* 参数说明： const UINT16 signalId, 信号机ID
*            const UINT8 setState, 状态
* 返回值  ： 无
*			       
*/
void SetSignalYLockOpenState(const UINT16 signalId, const UINT8 setState)
{
    UINT16 bufIndex = 0u;  /*数组下标*/
    
    bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/
    
    if (bufIndex < SIGNAL_SUM_MAX)
    {
        if ((SIGNAL_OPEN == setState) && 
            (SignalDataStru[bufIndex].SignalLeadProperty == SIGNAL_LEAD_PROPERTY_YES) &&
            (GetSignalOpenCloseState(GetSignalCurColor(signalId)) == SIGNAL_CLOSE)
            )
        {
            /*信号可引导 且 信号机当前关闭*/
            SignalDataStru[bufIndex].SignalYLockOpenState = setState;  /*设置状态*/
        }
        else if (SIGNAL_CLOSE == setState)
        {
            SignalDataStru[bufIndex].SignalYLockOpenState = setState;  /*设置状态*/
        }
        else
        {
            /*不做处理*/
        }		
    }
}

/*
* 功能描述： 获取指定ID信号机扣车标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 扣车标志      
*/
UINT8 GetSignalDetainFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;
	UINT8 sigRelayDetainFlag = SIGNAL_RELAY_DETAIN_NO;	/*信号机硬线扣车标志*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		sigRelayDetainFlag = GetSignalRelayDetainFlag(signalId);/*获取信号机硬线扣车标志*/

		if (SIGNAL_RELAY_DETAIN_NO == sigRelayDetainFlag)
		{/*硬线未扣车*，获取ATS和现地扣车状态*/

			if ((SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag)&& (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto))
			{/*ATS未扣车 需满足未自动扣车且未人工扣车*/

				if (SIGNAL_DETAIN_NO ==SignalDataStru[bufIndex].XiandiDetainFlag )
				{/*现地未扣车*/

					reVal = SIGNAL_DETAIN_NO;/*返回现地、ATS均未扣车*/
				}
				else
				{
					/*现地扣车*/
					reVal = SIGNAL_DETAIN_XIANDI;/*返回现地扣车、ATS未扣车*/
				}
			}
			else
			{/*ATS扣车*/

				if (SIGNAL_DETAIN_NO ==SignalDataStru[bufIndex].XiandiDetainFlag )
				{/*现地未扣车*/
					if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag)
					{/*ATS未人工扣车*/
						reVal = SIGNAL_DETAIN_ATS_AUTO;
					}
					else if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto)
					{ 
						reVal = SIGNAL_DETAIN_ATS;
					}
					else
					{
						;  /*不处理*/
					}
					
				}
				else
				{
					/*现地扣车*/
					if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag)
					{/*ATS未人工扣车*/

						reVal = SIGNAL_DETAIN_XIANDI_ATSAUTO;/*ATS自动扣车+现地扣车*/
					}
					else if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto)
					{/*ATS未自动扣车*/
						reVal = SIGNAL_DETAIN_YES;/*ATS人工扣车+现地扣车*/
					}
					else
					{
						;  /*不处理*/
					}
				}
			}
		} 
		else if (SIGNAL_RELAY_DETAIN_YES == sigRelayDetainFlag)
		{/*硬线扣车有效*/
			reVal = SIGNAL_RELAY_DETAIN_YES; /*返回硬线扣车*/
		}
		else
		{
			/*do noting*/
		}
#if 0
        if (SignalDataStru[bufIndex].AtsDetainFlag == SIGNAL_DETAIN_NO)
        {/*ATS未扣车*/

            if (SignalDataStru[bufIndex].XiandiDetainFlag == SIGNAL_DETAIN_NO)
            {/*现地未扣车*/

				reVal = SIGNAL_DETAIN_NO;/*返回现地、ATS均未扣车*/
            }
            else
            {
                /*现地扣车*/
                reVal = SIGNAL_DETAIN_XIANDI;/*返回现地扣车、ATS未扣车*/
            }
        }
        else
        {/*ATS扣车*/

            if (SignalDataStru[bufIndex].XiandiDetainFlag == SIGNAL_DETAIN_NO)
            {/*现地未扣车*/
                
                reVal = SIGNAL_DETAIN_ATS;/*返回现地未扣车、ATS均扣车*/
            }
            else
            {
                /*现地扣车*/
                reVal = SIGNAL_DETAIN_YES;/*返回现地扣车、ATS均扣车*/
            }
        }
#endif
	}
	return reVal;
}



/*
* 功能描述： 设置指定ID信号机扣车状态
* 参数说明： const UINT16 signalId, 信号机ID
*            const UINT8 setState, 设置状态
* 返回值  ： 无
*			         
*/
void SetSignalDetainState(const UINT16 signalId, const UINT8 setState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		if (SIGNAL_DETAIN_YES == setState)
		{/*ATS人工扣车+现地扣车*/

			SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_YES;
			SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO;
			SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_YES;
		}
		else if (SIGNAL_DETAIN_NO == setState)
		{/*ATS、现地均未扣车*/

			SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_NO;
			SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO;
			SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_NO;
		}
		else if (SIGNAL_DETAIN_XIANDI == setState)
		{/*现地办理扣车*/

			SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_NO;
			SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO;
			SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_YES;
		}
		else if (SIGNAL_DETAIN_ATS == setState)
		{/*ATS办理人工扣车*/

			SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_YES;
			SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO;
			SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_NO;
		}
		else if (SIGNAL_DETAIN_ATS_AUTO == setState)
		{/*ATS办理自动扣车*/

			SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_NO;
			SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_YES;
			SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_NO;
		}
		else if (SIGNAL_DETAIN_XIANDI_ATSAUTO == setState)
		{/*ATS办理自动扣车+现地扣车*/

			SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_NO;
			SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_YES;
			SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_YES;
		}
		else
		{
			/*不做处理*/
		}
	}
}

/*
* 功能描述： 设置指定ID信号机扣车标志
* 参数说明： const UINT16 signalId, 信号机ID
*            const UINT8 setState, 设置状态
* 返回值  ： CI_ERROR
*			 CI_SUCCESS       
*/
UINT8 SetSignalDetainFlag(const UINT16 signalId, const UINT8 setState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		if (SIGNAL_DETAIN_ATS == setState)
		{/*ats办理人工扣车*/

			/*若已办理ATS自动扣车 需转换为ATS人工扣车*/
			if (SIGNAL_DETAIN_YES == SignalDataStru[bufIndex].AtsDetainFlagAuto)
			{
				SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO;
			}
			SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_YES;
			reVal = CI_SUCCESS;
		}
		else if (SIGNAL_DETAIN_ATS_AUTO == setState)
		{/*ats办理自动扣车*/

			/*若已办理ATS人工扣车 不能再办理自动扣车*/
			if (SIGNAL_DETAIN_YES == SignalDataStru[bufIndex].AtsDetainFlag)
			{
				reVal = CI_ERROR;
			}
			else
			{
				SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_YES;
				reVal = CI_SUCCESS;
			}
		}
		else if (SIGNAL_DETAIN_ATS_NO == setState)
		{/*ats取消扣车 取消人工和自动扣车*/

			SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_NO;
			SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO;
			reVal = CI_SUCCESS;
		}
		else if (SIGNAL_DETAIN_XIANDI == setState)
		{/*现地办理扣车*/

			SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_YES;
			reVal = CI_SUCCESS;
		}
		else if (SIGNAL_DETAIN_XIANDI_NO == setState)
		{/*现地取消扣车*/

			SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_NO;
			reVal = CI_SUCCESS;
		}
		else if (SIGNAL_DETAIN_CI_RELAY_YES == setState)
		{/*相邻联锁办理硬线扣车*/

			SignalDataStru[bufIndex].RealyDetainFlag = SIGNAL_RELAY_DETAIN_YES;
			reVal = CI_SUCCESS;
		}
		else if (SIGNAL_DETAIN_CI_RELAY_NO == setState)
		{/*相邻联锁取消硬线扣车*/

			SignalDataStru[bufIndex].RealyDetainFlag = SIGNAL_RELAY_DETAIN_NO;
			reVal = CI_SUCCESS;
		}
		else
		{
			reVal = CI_ERROR;
		}
	}
	return reVal;
}

/*
* 功能描述： 获取自动信号对应的进路ID
* 参数说明： const UINT16 signalId, 信号机ID    
* 返回值  ： 0: 获取数据失败
*			>0: 信号机ID      
*/
UINT16 GetSignalAutoRouteId(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 returnValue = CI_ERROR;
	
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取指定信号机的索引号*/
	
	if (bufIndex < SIGNAL_SUM_MAX)
	{
		returnValue = SignalDataStru[bufIndex].AutoRouteId;
	}

	return returnValue;
}

/*
* 功能描述： 设置自动信号对应的自动信号机ID
* 参数说明： const UINT16 signalId, 信号机ID    
* 返回值  ： 0: 设置失败
*			 1: 设置成功      
*/
UINT8 SetSignalAutoRouteId(const UINT16 signalId,const UINT16 routeId)
{
	UINT8 ret = CI_SUCCESS;
	UINT16 bufIndex = 0u;  /*数组下标*/
	
	
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取指定信号机的索引号*/
	
	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].AutoRouteId = routeId;
	}
	else
	{
		ret = CI_ERROR;
	}

	return ret;
}


/*
* 功能描述： 获取指定ID信号机临时限速设置标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 临时限速设置状态      
*/
UINT8 GetSignalLinShiXianSuSetFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8  funRetVal = 0u;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
        funRetVal = SignalDataStru[bufIndex].LinShiXianSuSetFlag;
    }
    else
    {
        funRetVal = CI_ERROR;
    }	
	return funRetVal;
}


/*
* 功能描述： 设置指定ID信号机临时限速标志
* 参数说明： const UINT16 signalId, 信号机ID
*            const UINT8 setState, 设置状态
* 返回值  ： 无
*			         
*/
void SetSignalLinShiXianSuSetFlag(const UINT16 signalId, const UINT8 linShiXianSuSetState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/
	
	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_LINSHIXIANSUSET_STATE_NO == linShiXianSuSetState) ||
            (SIGNAL_LINSHIXIANSUSET_STATE_YES == linShiXianSuSetState) ||
            (SIGNAL_LINSHIXIANSUSET_STATE_INVALID == linShiXianSuSetState))
		{
			SignalDataStru[bufIndex].LinShiXianSuSetFlag = linShiXianSuSetState;  /*信号机临时限速标志*/
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}	
}

UINT8 GetSignalPLockCommand(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 funRetVal = 0u;
	
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/
	
	if (bufIndex < SIGNAL_SUM_MAX)
	{
		funRetVal = SignalDataStru[bufIndex].PLockCommand;
	}
	else
	{
		funRetVal = CI_ERROR;
	}
	return funRetVal;	
}


/*
* 功能描述： 设置指定ID信号机异常关闭标志
* 参数说明： const UINT16 signalId, 信号机ID
			 const UINT8 curColor, 当前显示颜色
			 const UINT8 setState，当前设置状态
* 返回值  ： 无
*			      
*/
void SetSignalPLockCommand(const UINT16 signalId, const UINT8 pLockCommand)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/
	
	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].PLockCommand = pLockCommand;  /*逻辑区段之前占用状态*/

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

/*
* 功能描述： 获取信号机互联互通保护区段有效性
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 保护区段有效性属性
*/
UINT8 GetSignalProSecValid(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 funRetVal = 0u;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		funRetVal = SignalDataStru[bufIndex].ProSecValid;
	}
	else
	{
		funRetVal = CI_ERROR;
	}
	return funRetVal;
}


/*
* 功能描述： 设置信号机互联互通保护区段有效性
* 参数说明：
const UINT16 signalId, 信号机ID
const UINT8 proSecValid:保护区段有效性
* 返回值:
*		无
*		 
*/
void SetSignalProSecValid(const UINT16 signalId, const UINT8 proSecValid)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_PRO_SEC_VALID == proSecValid) || (SIGNAL_PRO_SEC_INVALID == proSecValid))
		{
			SignalDataStru[bufIndex].ProSecValid = proSecValid;
		}
		else
		{
			/*不做处理*/
		}
	}
	else
	{
		/*不做处理*/
	}
}
/*
* 功能描述： 设置信号机颜色已经开放，但不是目标的驱动开放颜色，记录该过渡态的起始周期
* 参数说明：
	const UINT16 signalId, 信号机ID
	const UINT32 cycNum:起始周期号
* 返回值:
*		0: 设置失败
*		1: 设置成功
*/
UINT8 SetSignalDiffColorOpenStartCyc(const UINT16 signalId,const UINT32 cycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 funRetVal = 0u;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].DiffColorOpenStartCycNum = cycNum;

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

/*
* 功能描述： 获取信号机颜色已经开放，但不是目标的驱动开放颜色，记录该过渡态的起始周期
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 起始周期号        
*/
UINT32 GetSignalDiffColorOpenStartCyc(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].DiffColorOpenStartCycNum;
	}

	return reVal;
}

/*
* 功能描述： 设置指定ID信号机采集开放起始周期号
* 参数说明：
	const UINT16 signalId, 信号机ID
	const UINT32 cycNum:起始周期号
* 返回值:
*		0: 设置失败
*		1: 设置成功
*/
UINT8 SetSignalCollOpenStartCycNum(const UINT16 signalId,const UINT32 cycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 funRetVal = 0u;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].CollSigOpenStartCycNum = cycNum;

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

/*
* 功能描述： 获取指定ID信号机采集开放起始周期号
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 驱动开放起始周期号        
*/
UINT32 GetSignalCollOpenStartCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].CollSigOpenStartCycNum;
	}
	return reVal;
}

/*
* 功能描述： 获取信号机硬线扣车状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0: 获取成功      
*/
UINT8 GetSignalRelayDetainFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;
	
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/
	
	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_RELAY_DETAIN_NO == SignalDataStru[bufIndex].RealyDetainFlag ) || (SIGNAL_RELAY_DETAIN_YES == SignalDataStru[bufIndex].RealyDetainFlag))
		{
			reVal = SignalDataStru[bufIndex].RealyDetainFlag;
		}		
	}
	return reVal;
}


/*
* 功能描述： 设置信号机硬线扣车状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 无
*			      
*/
void SetSignalRelayDetainFlag(const UINT16 signalId, const UINT8 signalRelayDetainState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	
	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/
	
	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_RELAY_DETAIN_NO == signalRelayDetainState) || (SIGNAL_RELAY_DETAIN_YES == signalRelayDetainState))
		{
			SignalDataStru[bufIndex].RealyDetainFlag = signalRelayDetainState;  /*设置信号机硬线扣车状态*/
		}
	}
}

#if 0


/*
* 功能描述： 获取信号机硬线扣车命令
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0: 获取成功      
*/
UINT8 GetSignalRelayDetainCmd(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_DETAIN_CI_RELAY_NO == SignalDataStru[bufIndex].RealyDetainFlag ) || 
			(SIGNAL_DETAIN_CI_RELAY_YES == SignalDataStru[bufIndex].RealyDetainFlag) )
		{
			reVal = SignalDataStru[bufIndex].RelayDetainCmd;
		}		
	}
	return reVal;
}
#endif

/*
* 功能描述： 设置信号机硬线扣车命令
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 设置失败
*			>0: 设置成功      
*/
UINT8 SetSignalRelayDetainCmd(const UINT16 signalId, const UINT8 signalRelayDetainCmd)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_DETAIN_CI_RELAY_NO == signalRelayDetainCmd)  || 
			(SIGNAL_DETAIN_CI_RELAY_YES == signalRelayDetainCmd) )
		{
			SignalDataStru[bufIndex].RelayDetainCmd = signalRelayDetainCmd;  /*设置信号机硬线扣车状态*/
			reVal = CI_SUCCESS;
		}
	}
	return reVal;
}


/*******************NeighbourSignalDetainDrive 邻站信号机扣车驱动***************************************/

/*
* 功能描述： 获取邻站信号机扣车驱动
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0: 获取成功      
*/
UINT8 GetSignalNeighbourDetainDrive(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO == SignalDataStru[bufIndex].NeighbourSignalDetainDrive ) || 
			(NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES == SignalDataStru[bufIndex].NeighbourSignalDetainDrive) )
		{
			reVal = SignalDataStru[bufIndex].NeighbourSignalDetainDrive;
		}		
	}
	return reVal;
}


/*
* 功能描述： 设置邻站信号机扣车驱动
* 参数说明： const UINT16 signalId, 信号机ID
*			const UINT8 drive，扣车驱动
* 返回值  ：无
*			       
*/
void SetSignalNeighbourDetainDrive(const UINT16 signalId, const UINT8 drive)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES == drive)  || 
			(NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO == drive) )
		{
			SignalDataStru[bufIndex].NeighbourSignalDetainDrive = drive;  /*设置邻站信号机扣车驱动*/
		}
	}
}


/*******************NeighbourSignalDetainDrive 邻站信号机扣车驱动******END*********************************/

/*
* 功能描述： 获取指定ID信号机之前变化的显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 之前变化的显示颜色
*/
UINT8 GetSignalPreChangedDriveColor(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].PreChangedDriveColor;
	}
	return reVal;
}

/*
* 功能描述： 设置指定ID信号机之前变化驱动显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 driveColor, 驱动显示颜色
* 返回值  ： 0: 设置失败
*			 1: 设置成功
*/
UINT8 SetSignalPreChangedDriveColor(const UINT16 signalId, const UINT8 driveColor)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].PreChangedDriveColor = driveColor;

		reVal = CI_SUCCESS;
	}
	return reVal;
}

/*
* 功能描述： 设置维修点灯状态
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 maintainState, 维修点灯状态
* 返回值  ： void
*/
void SetSignalMaintainState(const UINT16 signalId, const UINT8 maintainState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		if((MAINTAIN_STATE_YES ==maintainState)||(MAINTAIN_STATE_NO == maintainState))
		{
			SignalDataStru[bufIndex].MaintainLightState = maintainState;
		}
		
	}
}

/*
* 功能描述： 获取维修点灯状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 设置失败
*			 >0: 维修点灯状态
*/
UINT8 GetSignalMaintainState(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{	
		reVal = SignalDataStru[bufIndex].MaintainLightState;	
	}
	return reVal;
}

/*
* 功能描述： 设置信号机点灯区段接近列车ID
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 maintainState, 维修点灯状态
* 返回值  ： void
*/
void SetSignalLightUpTrainId(const UINT16 signalId, const UINT16 wTrainId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		SignalDataStru[bufIndex].wSignalLightUpTrainId = wTrainId;
	}
}

/*
* 功能描述： 获取信号机点灯区段接近列车ID
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 其他点灯区段接近列车ID
*            0:失败
*/
UINT16 GetSignalLightUpTrainId(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].wSignalLightUpTrainId;
	}
	else
	{
		reVal = CI_ERROR;
	}
	return reVal;
}

/*
* 功能描述： 获取信号机点灯区段link数目
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 点灯区段link数目
* create ：2022.3.4
*/
UINT16 GetSignalLightUpLinkIdSum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 reVal = 0u;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].wSignalLightUpLinkIdSum;
	}
	return reVal;
}

/*
* 功能描述： 获取信号机点灯区段LINK
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 点灯区段link
* create ：2022.3.4
*/
UINT16 * GetSignalLightUpLinkIdBuf(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 * reVal = NULL;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		reVal = SignalDataStru[bufIndex].szSignalLightUpLinkIdBuf;
	}
	return reVal;
}

/**
* @brief 计算信号机点灯link序列
* @param wSignalId 信号机编号
* @param pLinkNum 输出的link数量
* @param szLinkIdBuf 输出的link序列
* @return CI_SUCCESS成功；CI_ERROR失败
* @create 2022.3.4
* 修复bug YF0083-119
*/
UINT8 CalSignalLightUpLinkSeq(IN const UINT16 wSignalId, OUT UINT16 * pLinkNum, OUT UINT16 szLinkIdBuf[])
{
	UINT8 cRetVal = CI_ERROR;
	UINT8 cKeepWork = CI_ERROR;
	UINT16 wLightUpLinkSum = 0u;
	UINT16 wszLightUpLinkIdBuf[MAX_SIGNAL_LIGHTUPLINK_NUM] = { 0u };
	UINT16 wSignalOutFirstLinkId = 0u;
	UINT16 wSignalProtectLinkId = 0U;			/*信号机防护linkID*/
	UINT32 dwSignalOutFirstLinkOff = 0u;
	UINT32 dwSignalLightUpLinkLength = 0u; /*信号机点灯距离*/
	UINT8 cSignalProtectDir = UINT8_MAX;
	UINT32 dwSearchLen = UINT32_MAX;
	UINT16 wCurrentLink = UINT16_MAX;
	UINT16 wNextLink = UINT16_MAX;
	UINT16 wPointId = UINT16_MAX;
	UINT8 cSearchDir = UINT8_MAX;
	UINT8 cRetMem = 0u;
	UINT8 cDirectionPointFlag = 0U;			/*是否具有方向变化点标志*/
	UINT8 cDirectionPointCnt = 0U;			/*方向变化点数量*/

	dwSignalLightUpLinkLength = GetSystemParaValue(SIGNAL_LIGHTUP_SEC_LEN_ID);
	dwSignalLightUpLinkLength *= 100u;

	/*入参检查*/
	if ((0u < wSignalId) && (SIGNAL_SUM_MAX > wSignalId))
	{
		cKeepWork = CI_SUCCESS;
	}
	else
	{
		cKeepWork = CI_ERROR;
	}

	if (CI_SUCCESS == cKeepWork)
	{
		/*入参检查*/
		if ((NULL != pLinkNum) && (NULL != szLinkIdBuf))
		{
			cKeepWork = CI_SUCCESS;
		}
		else
		{
			cKeepWork = CI_ERROR;
		}
	}
	else
	{

	}

	if (CI_SUCCESS == cKeepWork)
	{
		/* 配置数据检查 */
		if ((0u != dwSignalLightUpLinkLength) && (UINT32_MAX != dwSignalLightUpLinkLength))
		{
			cKeepWork = CI_SUCCESS;
		}
		else
		{
			cKeepWork = CI_ERROR;
		}
	}
	else
	{

	}

	if (CI_SUCCESS == cKeepWork)
	{
		wSignalProtectLinkId = GetSignalProtectLink(wSignalId);					/*获取信号机防护LINK，按防护Link往防护方向查，防止信号机在方向变化点上*/
		wSignalOutFirstLinkId = GetSignalOutFirstLink(wSignalId);
		dwSignalOutFirstLinkOff = GetLinkLengthById(wSignalOutFirstLinkId);
		wCurrentLink = wSignalProtectLinkId;
		/*返回值检查*/
		if ((UINT16_MAX != wSignalOutFirstLinkId) && (UINT32_MAX != dwSignalOutFirstLinkOff))
		{
			cSignalProtectDir = GetSignalDirection(wSignalId);

			if (wSignalProtectLinkId == wSignalOutFirstLinkId)
			{
				dwSearchLen = dwSignalOutFirstLinkOff;		/*防护Link为外方第一Link，需要加长度*/
			}
			else
			{
				dwSearchLen = 0U;			/*不为外方第一link，不加长度*/
			}
			
			/*信号机防护方向反向搜索*/
			if (DIR_SAME == cSignalProtectDir)
			{
				cSearchDir = DIR_CONVERT;
			}
			else if (DIR_CONVERT == cSignalProtectDir)
			{
				cSearchDir = DIR_SAME;
			}
			else
			{
				cSearchDir = DIR_INVALID;
				cKeepWork = CI_ERROR;
			}
			if (CI_SUCCESS == cKeepWork)
			{
				do
				{
					/*获取下一linkID*/
					wNextLink = FindAdjacentLinkIDSafe(wCurrentLink, cSearchDir, &wPointId, &cDirectionPointFlag);

					if (MAX_SIGNAL_LIGHTUPLINK_NUM > wLightUpLinkSum)
					{
						if ((wCurrentLink == wSignalProtectLinkId) && (wSignalProtectLinkId != wSignalOutFirstLinkId))
						{
							;	/*当前link为防护link，取的第一个link，且，防护link和外方第一link不相等时，第一个防护link不算入点灯序列（信号机在方向点上）*/
						}
						else
						{
							wszLightUpLinkIdBuf[wLightUpLinkSum] = wCurrentLink;
							wLightUpLinkSum++;
						}
					}
					else
					{
						;
					}

					if ((UINT16_MAX != wNextLink) && (0u != wNextLink) && (dwSearchLen < dwSignalLightUpLinkLength))
					{
						cKeepWork = dsuCheckLinkFitPointSafe(wCurrentLink, cSearchDir, &wPointId);
						if (CI_SUCCESS == cKeepWork)
						{
							/*获取成功*/
							wCurrentLink = wNextLink;
							/*具有方向变化点，转换查询下一link方向*/
							cSearchDir = TransDirectionPointDir(cDirectionPointFlag, cSearchDir, &cDirectionPointCnt);
							
							dwSearchLen += GetLinkLengthById(wCurrentLink);
							if ((dwSearchLen >= dwSignalLightUpLinkLength) && (MAX_SIGNAL_LIGHTUPLINK_NUM > wLightUpLinkSum))
							{
								wszLightUpLinkIdBuf[wLightUpLinkSum] = wCurrentLink;
								wLightUpLinkSum++;
							}
							else
							{

							}
						}
						else
						{
							/*道岔不在期望位置，停止搜索*/
							dwSearchLen = UINT32_MAX;
							cKeepWork = CI_SUCCESS;
						}
					}
					else
					{
						dwSearchLen = UINT32_MAX;
					}
				} while (dwSearchLen < dwSignalLightUpLinkLength);

			}
			else
			{

			}
		}
		else
		{
			/*外放第一区段无效*/
			cKeepWork = CI_SUCCESS;
		}
	}
	else
	{

	}



	if (CI_SUCCESS == cKeepWork)
	{
		/*检查通过，将结果拷贝到输出数组*/
		cRetMem = CommonMemCpy(szLinkIdBuf, (UINT32)(MAX_SIGNAL_LIGHTUPLINK_NUM * sizeof(UINT16)), wszLightUpLinkIdBuf, (UINT32)(wLightUpLinkSum * sizeof(UINT16)));
		if (CI_SUCCESS == cRetMem)
		{
			/*将数量输出*/
			*pLinkNum = wLightUpLinkSum;
			cRetVal = CI_SUCCESS;
		}
		else
		{

		}

	}
	else
	{
		cRetVal = CI_ERROR;
	}

	return cRetVal;
}

/**
* @brief 设置信号机点灯LinkID数组
* @param UINT16 wSignalId
* @param UINT16 wLinkSum
* @param UINT16 szLinkBuf[]
* @return CI_SUCCESS成功；CI_ERROR失败
* @create 2022.3.4
*/
UINT8  SetSignalLightUpLinkIdBuf(const UINT16 wSignalId, UINT16 wLinkSum, const UINT16 szLinkBuf[])
{
	UINT8 cRetVal = CI_ERROR;
	UINT16 ii = 0u;
	UINT16 jj = 0u;

	UINT16 wSignalIndex = GetSignalConfigBufIndex(wSignalId);


	if (SIGNAL_SUM_MAX != wSignalIndex)
	{
		/*清空信号机点灯区段*/
		for (jj = 0u; jj < MAX_SIGNAL_LIGHTUPLINK_NUM; jj++)
		{
			SignalDataStru[wSignalIndex].szSignalLightUpLinkIdBuf[jj] = 0u;
		}

		if (wLinkSum < MAX_SIGNAL_LIGHTUPLINK_NUM)
		{
			if (NULL != szLinkBuf)
			{
				for (ii = 0u; ii < wLinkSum; ii++)
				{
					SignalDataStru[wSignalIndex].szSignalLightUpLinkIdBuf[ii] = szLinkBuf[ii];
				}
				SignalDataStru[wSignalIndex].wSignalLightUpLinkIdSum = wLinkSum;
				cRetVal = CI_SUCCESS;
			}
		}

	}
	return cRetVal;
}

/**
* @brief 刷新信号机点灯link
* @return CI_SUCCESS成功；CI_ERROR失败
* @create 2022.3.4
* 修复bug YF0083-119
*/
UINT8 RefreshSignalLightUpLink(void)
{
	UINT16 ii = 0u;
	UINT8 cRetVal = CI_ERROR;
	UINT16 wSignalId = 0u;
	UINT8 cKeepWork = CI_ERROR;
	UINT8 cRetMem = 0u;
	UINT16 wLightUpLinkSum = 0u;
	UINT16 szLightUpLinkIdBuf[MAX_SIGNAL_LIGHTUPLINK_NUM] = { 0u };
	UINT16 chOcId = 0u;
	UINT16 wSignalOcId = 0u;

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

	if ((UINT8_MAX != chOcId) && (0u != chOcId))
	{
		cKeepWork = CI_SUCCESS;
	}
	else
	{
		/*错误信息 联锁ID错误*/
		cKeepWork = CI_ERROR;
	}

	if (CI_SUCCESS == cKeepWork)
	{
		for (ii = 0u; ii < SIGNAL_SUM_MAX; ii++)
		{
			wSignalId = GetSignalId(ii);
			wSignalOcId = GetSignalBelongCiId(wSignalId);

			if (chOcId == wSignalOcId)
			{
				/*获取信号机点灯区段成功*/
				cKeepWork = CalSignalLightUpLinkSeq(wSignalId, &wLightUpLinkSum, szLightUpLinkIdBuf);
				if (CI_SUCCESS == cKeepWork)
				{
					/*设置该信号机点灯区段*/
					cKeepWork = SetSignalLightUpLinkIdBuf(wSignalId, wLightUpLinkSum, szLightUpLinkIdBuf);
				}
				else
				{
					cKeepWork = CI_ERROR;
				}

				if (CI_SUCCESS == cKeepWork)
				{
					/*清空点灯区段数组*/
					cRetMem = CommonMemSet(szLightUpLinkIdBuf, (UINT32)sizeof(szLightUpLinkIdBuf), 0u, (UINT32)sizeof(szLightUpLinkIdBuf));
					if (CI_SUCCESS == cRetMem)
					{
						wLightUpLinkSum = 0u;
					}
					else
					{
						cKeepWork = CI_ERROR;
					}
				}
				else
				{

				}
				if (CI_SUCCESS != cKeepWork)
				{
					/*错误信息 信号机点灯区段查询失败*/
					break;
				}
				else
				{

				}
			}
			else
			{
				;/* 其他OC跳过 */
			}
		}
	}
	else
	{

	}

	/*执行成功*/
	if (CI_SUCCESS == cKeepWork)
	{
		/*返回成功*/
		cRetVal = CI_SUCCESS;
	}
	else
	{
		cRetVal = CI_ERROR;
	}

	return cRetVal;
}

/**
* @brief 刷新信号机亮灭状态
* @return CI_SUCCESS成功；CI_ERROR失败
* @create 2022.3.4
*/
UINT8 RefreshSignalLightUpState(void)
{
	UINT8 cKeepWork = CI_ERROR;
	UINT8 cRetVal = CI_ERROR;
	UINT16 wSignalIndex = 0u;
	UINT16 wSignalId = 0u;
	UINT16 wSignalLightUpLinkIdSum = 0u;
	UINT16 * pSignalLightUpLinkIdBuff = NULL;
	UINT16 wLinkIndex = 0u;
	UINT16 wTrainId = 0u;
	UINT8 chOcId = 0u;
	UINT16 wSignalOcId = 0u;
	UINT16 wPhySecId = 0u;
	UINT8 chOccState = 0u;
	UINT8 chTrainLevel = 0u;
	UINT8 chFlag = 0u;
	UINT8 chDir = 0u;
	TRAIN_SEQUANCE_s strTmp = { 0u };
	UINT8 chLinkOcId = 0u;
	UINT8 chOtherFlag = FLAG_UNSET;
	UINT32 dwDdLen = 0u;
	UINT32 dwUsedLen = 0u;
	UINT32 dwLinkLen = 0u;
	CfpTrainInfoStru strCfpOther = { 0u };
	UINT16 wCfpId = 0u;
	UINT16 wLink = 0u;
	UINT32 dwOffset = 0u;
	UINT8 chTransmitStat = 0u;
	UINT32 dwLeftLen = 0u;
	UINT8 chTrainNum = 0u;
	UINT8 chPhyFree = CI_ERROR;
	UINT8 cDirectionPointfirst = 0U;			/*方向变化点1*/
	UINT8 cDirectionPointsecond = 0U;			/*方向变化点2*/
	UINT8 cDirectionPointCnt = 0U;			/*方向变化点数量*/
	UINT8 cDirectionProtectLinkPoint = 0U;		/*信号机防护link方向变化点*/
	UINT8 cDirectionOutFirstLinkPoint = 0U;		/*信号机外方第一link方向变化点*/
	UINT16 wSignalOutFirstLinkId = 0u;			/*信号机外方第一link*/
	UINT16 wSignalProtectLinkId = 0U;			/*信号机防护linkID*/
	UINT16 wOutFstPhySecId = 0U;  /*信号机外方第一物理区段*/
	UINT8 cPhySecBelongCiId = 0U;  /*信号机外方第一物理区段所属CI*/
	UINT8 cSleepTrainLightUpFlag = SIGNAL_SLEEP_TRAIN_LIGHTUP_YES;  /*休眠车点亮信号机标志*/
	UINT8 cCommState = TRANSMIT_STATE_BAD;

	dwDdLen = GetSystemParaValue(SIGNAL_LIGHTUP_SEC_LEN_ID);
	dwDdLen *= 100u;
	chOcId = GetSystemParaLocalCiId();
	if ((0u != chOcId) && (UINT8_MAX != chOcId))
	{
		cKeepWork = CI_SUCCESS;
	}
	else
	{
		;
	}

	if (CI_SUCCESS == cKeepWork)
	{
		for (wSignalIndex = 0u; wSignalIndex < SIGNAL_SUM_MAX; wSignalIndex++)
		{
			dwUsedLen = 0u;
			chOtherFlag = FLAG_UNSET;
			chOccState = SECTION_OCCUPY_NO;
			wSignalId = GetSignalId(wSignalIndex);
			wSignalOcId = GetSignalBelongCiId(wSignalId);
			SetSignalLightUpTrainId(wSignalId, 0U);
			/* 只为本控区信号机计算点灯区段 */
			if (wSignalOcId == chOcId)
			{
				wSignalLightUpLinkIdSum = GetSignalLightUpLinkIdSum(wSignalId);
				pSignalLightUpLinkIdBuff = GetSignalLightUpLinkIdBuf(wSignalId);
				wSignalProtectLinkId = GetSignalProtectLink(wSignalId);					/*获取信号机防护LINK，按防护Link往防护方向查，防止信号机在方向变化点上*/
				wSignalOutFirstLinkId = GetSignalOutFirstLink(wSignalId);
				chDir = GetSignalDirection(wSignalId);		
				wTrainId = 0u;
				chFlag = GetSignalShine(wSignalId);

				if ((UINT16_MAX == wSignalId)
					|| (MAX_SIGNAL_LIGHTUPLINK_NUM < wSignalLightUpLinkIdSum)
					|| (NULL == pSignalLightUpLinkIdBuff)
					|| ((DIR_SAME != chDir) && (DIR_CONVERT != chDir)))
				{
					cKeepWork = CI_ERROR;

				}
				else
				{
					cKeepWork = CI_SUCCESS;
				}

				if(CI_SUCCESS == cKeepWork)
				{/* 遍历点灯区段，查找列车 */
					if (wSignalProtectLinkId != wSignalOutFirstLinkId)
					{
						cDirectionProtectLinkPoint = GetLinkLogicDirChangedById(wSignalProtectLinkId);
						cDirectionOutFirstLinkPoint = GetLinkLogicDirChangedById(wSignalOutFirstLinkId);	/*若防护link不是外方第一link，且两link间存在方向变化点，则需要反方向*/
						if (((LINK_DIRCHANGE_BEGIN == cDirectionProtectLinkPoint) || (LINK_DIRCHANGE_END == cDirectionOutFirstLinkPoint))
							&& (cDirectionProtectLinkPoint == cDirectionOutFirstLinkPoint))
						{
							chDir = TransDirectionPointDir(DIRECTIONPOINT_FLAG_VALID, chDir, &cDirectionPointCnt);			/*有方向变化点，转换方向*/
						}
						else
						{
							;	/*没有反向变换点，不考虑变方向*/
						}
					}
					else
					{
						;	/*防护link是外方第一link，不需要转方向*/
					}
					for (wLinkIndex = 0u; wLinkIndex < wSignalLightUpLinkIdSum; wLinkIndex++)
					{
						chLinkOcId = (UINT8)GetLinkManageTiocById(pSignalLightUpLinkIdBuff[wLinkIndex]);
						if (chLinkOcId == chOcId)
						{
							dwLinkLen = GetLinkLengthById(pSignalLightUpLinkIdBuff[wLinkIndex]);
							dwUsedLen += dwLinkLen;
							wPhySecId = GetLinkRelatedPhySec(pSignalLightUpLinkIdBuff[wLinkIndex]);
							chOccState = GetPhySecCurOccupyState(wPhySecId);
							chPhyFree = IsPhyFree(wPhySecId);
							if ((SECTION_OCCUPY_YES == chOccState) || (CI_ERROR == chPhyFree))
							{
								if (DIR_SAME == chDir)
								{
									chTrainNum = as_GetLinkTrainNum(pSignalLightUpLinkIdBuff[wLinkIndex]);
									strTmp = as_GetLinkLastTrain(pSignalLightUpLinkIdBuff[wLinkIndex]);
								}
								else
								{
									chTrainNum = as_GetLinkTrainNum(pSignalLightUpLinkIdBuff[wLinkIndex]);
									strTmp = as_GetLinkFirstTrain(pSignalLightUpLinkIdBuff[wLinkIndex]);
								}

								if (0u != chTrainNum)
								{
									wTrainId = strTmp.u16TrainID;
									SetSignalLightUpTrainId(wSignalId, wTrainId);
								}
								else
								{
									;/* 无处理 */
								}
							}
							else
							{
								;/*无处理*/
							}
						}
						else
						{
							wLink = pSignalLightUpLinkIdBuff[wLinkIndex];
							if (DIR_SAME == chDir)
							{
								dwOffset = GetLinkLengthById(wLink);
							}
							else
							{
								dwOffset = 0u;
							}
							chOtherFlag = FLAG_SET;
						}

						/*检查是否有方向变化点，此处检查，当前link已按既定方向查找完，查下一link，若此时中间有方向变化点，则跨过方向变化点，到下一link改变方向查*/
						if (wLinkIndex < (wSignalLightUpLinkIdSum - 1U))
						{
							cDirectionPointfirst = GetLinkLogicDirChangedById(pSignalLightUpLinkIdBuff[wLinkIndex]);
							cDirectionPointsecond = GetLinkLogicDirChangedById(pSignalLightUpLinkIdBuff[(wLinkIndex + 1u)]);		/*todo越界*/
							if (((LINK_DIRCHANGE_BEGIN == cDirectionPointfirst) || (LINK_DIRCHANGE_END == cDirectionPointfirst))
								&& (cDirectionPointsecond == cDirectionPointfirst))
							{
								chDir = TransDirectionPointDir(DIRECTIONPOINT_FLAG_VALID, chDir, &cDirectionPointCnt);			/*有方向变化点，转换方向*/
							}
							else
							{
								;	/*没有反向变换点，不考虑变方向*/
							}
						}
						else
						{
							;			/*最后一个link不需要考虑方向变化点的问题，防止数组越界*/
						}
						

						if ((((SECTION_OCCUPY_YES == chOccState) || (CI_ERROR == chPhyFree))  && (0u != chTrainNum)) 
							|| (FLAG_SET == chOtherFlag))
						{
							break;
						}
						else
						{
							;/* 无处理 */
						}
					}
				}
				else
				{
					;
				}

				if (CI_SUCCESS == cKeepWork)
				{
					if (SIGNAL_LIGHT_CONFIG_LIGHT == chFlag)
					{
						/* 常亮，点灯 */
						(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
						if (FLAG_SET == chOtherFlag)	/*常量信号机，处理分界点相邻联锁传来的车*/
						{
							wCfpId = GetCfpIdByPoint(wLink, dwOffset);
							strCfpOther = GetCfpOtherOcTrainInfo(wCfpId);
							chTransmitStat = GetCiTransmitState(CI_SYSTEM_TYPE_CI, chLinkOcId);
							dwLeftLen = dwDdLen - dwUsedLen;

							if ((TRANSMIT_STATE_GOOD != chTransmitStat) || ((UINT32_MAX != strCfpOther.dwDis) && (dwLeftLen <= strCfpOther.dwDis)))
							{
								;	/*通信不良好，或者相邻TIOC有车占用，距离已超出点灯距离，不设置点灯区段接近列车ID*/
							}
							else
							{
								SetSignalLightUpTrainId(wSignalId, strCfpOther.wTrainId);
							}
						}
					}
					else if ((0u != wTrainId) && (UINT16_MAX != wTrainId))
					{
						chTrainLevel = GetTrainLevel(wTrainId);
						if (TRAIN_LEVEL_VBTC == chTrainLevel)
						{/* CBTC级别亮灯 */
							if (SIGNAL_LIGHT_CONFIG_CBTC_LIGHT == chFlag)
							{
								(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
							}
							else
							{
								/* 信号机点灯区段查询到的第一列车为VBTC车，信号机保持灭灯 */
								(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_NO);
							}
						}
						else
						{/* OC为非VBTC车点灯 */
							(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
						}
					}
					else if ((SECTION_OCCUPY_YES == chOccState) && (0u != chTrainNum))
					{/* 计轴区段占用，但未查询到列车信息，点灯 */
						(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
					}
					else if (FLAG_SET == chOtherFlag)
					{
						wCfpId = GetCfpIdByPoint(wLink, dwOffset);
						strCfpOther = GetCfpOtherOcTrainInfo(wCfpId);
						chTransmitStat = GetCiTransmitState(CI_SYSTEM_TYPE_CI, chLinkOcId);
						dwLeftLen = dwDdLen - dwUsedLen;
						if ((0u == wCfpId) || (TRANSMIT_STATE_GOOD != chTransmitStat))
						{/* 相邻TIOC通信故障，亮灯 */
							(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
						}
						else
						{
							SetSignalLightUpTrainId(wSignalId, strCfpOther.wTrainId);
							if ((0u == strCfpOther.wTrainId) && (SIGNAL_LIGHT_CONFIG_CBTC_CLOSE != chFlag))			/*相邻RC无车占用，此信号机为常态亮灯时不走灭灯逻辑*/
							{/* 相邻TIOC无车占用，灭灯 */

								(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_NO);
							}
							else if ((UINT32_MAX != strCfpOther.dwDis) && (dwLeftLen <= strCfpOther.dwDis))
							{/* 相邻TIOC有车占用，级别不为VBTC，但距离已超出点灯距离，灭灯 */
								SetSignalLightUpTrainId(wSignalId, 0U);
								if (SIGNAL_LIGHT_CONFIG_CBTC_CLOSE != chFlag)			/*相邻RC有车占用，不为VBTC车，距离已超出点灯距离，此信号机为常态亮灯时不走灭灯逻辑*/
								{
									(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_NO);
								}
								else
								{
									(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
								}
							}
							else if (TRAIN_LEVEL_VBTC == strCfpOther.chTrainLevel)
							{/*相邻TIOC有VBTC车占用，需要查看配置是否为常态灭灯，CBTC接近亮灯*/
								if (SIGNAL_LIGHT_CONFIG_CBTC_LIGHT == chFlag)
								{
									(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
								}
								else
								{
									/* 信号机点灯区段查询到的第一列车为VBTC车，信号机保持灭灯 */
									(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_NO);
								}
							}
							else
							{/* 其余情况，亮灯 */
								(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
							}
						}
					}
					else
					{
						/* 没有查到列车 */
						if ((0u != wSignalLightUpLinkIdSum) && (SIGNAL_LIGHT_CONFIG_CBTC_CLOSE != chFlag))
						{
							/* 每周期设置信号机灭灯，根据点灯区段是否有非通信车占用判断点灯 */
							(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_NO);
						}
						else
						{
							/* 点灯区段为0或者常亮信号机 */
							(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
						}
					}

					wOutFstPhySecId = GetSignalOutFirstPhySecId(wSignalId);
					cPhySecBelongCiId = GetPhySecBelongCiId(wOutFstPhySecId);

					if (chOcId != cPhySecBelongCiId)
					{
						/*信号机外方第一物理区段位于相邻RC，通过相邻RC间接口中的休眠车点亮信号机标志，点亮信号机*/

						cCommState = GetCiTransmitState(CI_SYSTEM_TYPE_CI, cPhySecBelongCiId);
						if (TRANSMIT_STATE_GOOD == cCommState)
						{
							/*与信号机外方第一区段所属RC通信正常，通过休眠车点亮信号机标志刷新信号机亮灭状态*/
							cSleepTrainLightUpFlag = GetSleepTrainLightUpSignalFlag(wSignalId);
							if (SIGNAL_SLEEP_TRAIN_LIGHTUP_YES == cSleepTrainLightUpFlag)
							{
								(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
							}
							else
							{
								/*保持既有亮灭状态*/
							}
						}
						else
						{
							SetSleepTrainLightUpSignalFlag(wSignalId, SIGNAL_SLEEP_TRAIN_LIGHTUP_NO);  /*与信号机外方第一区段所属RC通信异常，清除休眠车点亮信号机标志*/
						}
					}
					else
					{
						SetSleepTrainLightUpSignalFlag(wSignalId, SIGNAL_SLEEP_TRAIN_LIGHTUP_NO);  /*信号机及其外方第一物理区段属于本控区，周期清除休眠车点亮信号机标志*/
					}
				}
				else
				{
					/* 查询失败 */
					(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
				}
			}
			else
			{
				;/* 跳过 */
			}

			/*休眠车所在休眠唤醒轨关联的终端信号机亮灯处理*/
			SleepTrainSignalLightUpProc(wSignalId);
		}
	}
	else
	{
		;/*无处理*/
	}

	cRetVal = cKeepWork;

	return cRetVal;
}

/**
* @brief 信号机点灯处理
* @return CI_SUCCESS成功；CI_ERROR失败
* @create 2022.3.4
*/
UINT8 SignalLightUpProc(void)
{
	UINT8 chRtnVal = CI_ERROR;
	chRtnVal = RefreshSignalLightUpLink();
	chRtnVal *= RefreshSignalLightUpState();
	return chRtnVal;
}

/*
* 功能描述： 设置信号机工程车接近状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 设置失败
*			>0: 设置成功
* cgh-合并CID-2341-5：
*/
void SetSigEngineerVehicleNearSte(const UINT16 signalId, const UINT8 sigEngineerVehicleNearState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIG_ENGINEERVEHICNEAR_STE_NO == sigEngineerVehicleNearState) || (SIG_ENGINEERVEHICNEAR_STE_YES == sigEngineerVehicleNearState))
		{
			SignalDataStru[bufIndex].EngineerVehicleNearState = sigEngineerVehicleNearState;  /*设置信号机工程车接近状态*/
		}
	}
}

/*
* 功能描述： 获取信号机工程车接近状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0:信号机工程车接近状态
* cgh-合并CID-2341-5：
*/
UINT8 GetSigEngineerVehicleNearSte(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].EngineerVehicleNearState;  /*设置信号机工程车接近状态*/
	}
	return reVal;
}

/*
* 功能描述： 设置信号机工程车跨压关闭状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 设置失败
*			>0: 设置成功
* cgh-合并CID-2341-5：
*/
void SetSigEnginVehicCrossCloseSte(const UINT16 signalId, const UINT8 sigEngineerVehicCrossCloseSte)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((ENGIN_VEHIC_CROSSCLOSE_STE_NO == sigEngineerVehicCrossCloseSte) || (ENGIN_VEHIC_CROSSCLOSE_STE_YES == sigEngineerVehicCrossCloseSte))
		{
			SignalDataStru[bufIndex].EngineerVehicleCrossClose = sigEngineerVehicCrossCloseSte;  /*设置信号机工程车跨压关闭状态*/
		}
	}
}

/*
* 功能描述： 获取信号机工程车跨压关闭状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 设置失败
*			>0: 设置成功
* cgh-合并CID-2341-5：
*/
UINT8 GetSigEnginVehicCrossCloseSte(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].EngineerVehicleCrossClose;
	}
	return reVal;
}

/*
* 功能描述： 设置信号机工程车跨压关闭所属进路
* 参数说明： const UINT16 signalId, 信号机ID
			 const UINT16 routeId 进路ID
*cgh-合并CID-2341-5：
*/
void SetEnginVehicCroCloBelongRoute(const UINT16 signalId, const UINT16 routeId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].EnginVehicCroCloBelongRoute = routeId;
	}
}

/*
* 功能描述： 获取信号机工程车跨压关闭所属进路
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 设置失败
*			>0:  信号机工程车跨压关闭所属进路
* cgh-合并CID-2341-5：
*/
UINT16 GetEnginVehicCroCloBelongRoute(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT16 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].EnginVehicCroCloBelongRoute;
	}
	return reVal;
}
/*
* 功能描述： OC-设置指定ID信号机当前显示颜色
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 curColor, 当前显示颜色
*返回值：无
* WGY 修改工程缺陷：信号机红灯断丝时，现地信号机颜色灰显
*/
void OcSetSignalCurColor(const UINT16 signalId, const UINT8 curColor)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 signalState = 0u;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if(SIGNAL_SUM_MAX > bufIndex)
	{
		/*设置信号机当前颜色*/
		if (SIGNAL_SHOWCOLOUR_REDFAULT == curColor)
		{
			SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;
		}
		else
		{
			SignalDataStru[bufIndex].CurColor = curColor;
		}
		/*对不同颜色设置断丝状态*/
		switch(curColor)
		{
			/*信号机红亮*/
		case SIGNAL_SHOWCOLOUR_RED:
			SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/
			break;
			/*信号机绿亮*/
		case SIGNAL_SHOWCOLOUR_GREEN:
		case SIGNAL_SHOWCOLOUR_DOUBLE_GREEN:
			SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/
			break;
			/*信号机黄亮*/
		case SIGNAL_SHOWCOLOUR_YELLOW:
		case SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW:
			SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/
			break;
			/*绿黄亮*/
		case SIGNAL_SHOWCOLOUR_GREENYELLOW:
			SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/
			SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/
			break;
			/*白亮*/
		case SIGNAL_SHOWCOLOUR_WHITE:
			SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/
			break;
			/*红黄*/
		case SIGNAL_SHOWCOLOUR_REDYELLOW:
			SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/
			SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/
			break;
			/*红白*/
		case SIGNAL_SHOWCOLOUR_RED_WHITE:
			SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/
			SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_NO;/*设置未断丝标志*/
			break;
			/*信号机绿灭*/
		case SIGNAL_SHOWCOLOUR_GREENCLOSE:
		case SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE:
		case SIGNAL_SHOWCOLOUR_YELLOWCLOSE:
			/*蓝断处理见GetOcSignalColor*/
			break;
			/*黄断*/
		case SIGNAL_SHOWCOLOUR_YELLOWBREAK:
			SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
			break;
			/*绿断*/
		case SIGNAL_SHOWCOLOUR_GREENBREAK:
			SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
			break;
			/*红断*/
		case SIGNAL_SHOWCOLOUR_REDBREAK:
			SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
			break;
		case SIGNAL_SHOWCOLOUR_REDFAULT:
			/*通信中断不设标志*/
			break;
			/*白断*/
		case SIGNAL_SHOWCOLOUR_WHITEBREAK:
			SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_YES;/*设置断丝标志*/
			break;
		default:
			/*不可达分支*/
			break;
		}
		signalState = GetSignalOpenCloseState(curColor);
		/*信号机已驱动开放*/
		if (SIGNAL_OPEN == signalState)
		{   
			/*设置信号驱动开放周期*/
			SignalDataStru[bufIndex].DriveSigOpenStartCycNum = 0u;
		}
		else
		{/*信号已驱动关闭*/

			/*信号驱动关闭周期清零*/
			SignalDataStru[bufIndex].DriveSigCloseStartCycNum = 0u;
		}
	}

}
/*
* 功能描述： 获取OC信号机板卡状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0:  OC信号机板卡状态     
*/
UINT8 GetSignalBoardState(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].SignalBoardState;  
	}
	return reVal;
}

/*
* 功能描述： 设置OC信号机板卡状态
* 参数说明： const UINT16 signalId, 信号机ID
*            const UINT8 boardState  板卡状态
             
*/
void SetSignalBoardState(const UINT16 signalId, const UINT8 boardState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].SignalBoardState = boardState; 
	}
}
	
/*
* 功能描述： 获取OC信号机全灭灯容忍起始周期
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0:  OC信号机全灭灯容忍起始周期    
*/
UINT32 GetOcSignalStartCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].OcSignalStartCycNum;  
	}
	return reVal;
}

/*
* 功能描述： 设置OC信号机全灭灯容忍起始周期
* 参数说明： const UINT16 signalId, 信号机ID   
             
*/
void SetOcSignalStartCycNum(const UINT16 signalId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].OcSignalStartCycNum = startCycNum; 
	}
}

/*
* 功能描述： 获取信号机继电器开始动作起始周期
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 继电器开始动作起始周期
*/
UINT32 GetSigRelayActStartCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].RelayActaionStartCycNum;
	}
	return reVal;
}

/*
* 功能描述： 获取信号机自复式扣车按钮1激活标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0: 获取成功
*/
UINT8 GetSignalDetainBtnActFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_ZFS_BTN_ACT_FLAG_NO == SignalDataStru[bufIndex].DetainBtnActivateFlag) || (SIGNAL_ZFS_BTN_ACT_FLAG_YES == SignalDataStru[bufIndex].DetainBtnActivateFlag))
		{
			reVal = SignalDataStru[bufIndex].DetainBtnActivateFlag;
		}
	}
	return reVal;
}

/*
* 功能描述： 设置信号机自复式扣车按钮1激活标志
* 参数说明： const UINT16 signalId, 信号机ID
*            const UINT8 signalZFSBtnActFlag 信号机自复式按钮激活标志
* 返回值  ： 无
*
*/
void SetSignalDetainBtnActFlag(const UINT16 signalId, const UINT8 signalZFSBtnActFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_ZFS_BTN_ACT_FLAG_NO == signalZFSBtnActFlag) || (SIGNAL_ZFS_BTN_ACT_FLAG_YES == signalZFSBtnActFlag))
		{
			SignalDataStru[bufIndex].DetainBtnActivateFlag = signalZFSBtnActFlag;  /*设置信号机硬线扣车状态*/
		}
	}
}

/*
* 功能描述： 设置信号机自复式取消扣车按钮1故障标志
* 参数说明： const UINT16 signalId, 信号机ID
*            const UINT8 signalZFSBtnErrFlag 信号机自复式按钮故障标志
* 返回值  ： 无
*
*/
void SetSignalCancelDetainBtnErrFlag(const UINT16 signalId, const UINT8 signalZFSBtnErrFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO == signalZFSBtnErrFlag) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == signalZFSBtnErrFlag))
		{
			SignalDataStru[bufIndex].CancelDetainBtnErrFlag = signalZFSBtnErrFlag;  /*设置信号机硬线扣车状态*/
		}
	}
}

/*
* 功能描述： 获取信号机自复式取消扣车按钮1故障标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0: 获取成功
*/
UINT8 GetSignalCancelDetainBtnErrFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO == SignalDataStru[bufIndex].CancelDetainBtnErrFlag) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == SignalDataStru[bufIndex].CancelDetainBtnErrFlag))
		{
			reVal = SignalDataStru[bufIndex].CancelDetainBtnErrFlag;
		}
	}
	return reVal;
}

/*
* 功能描述： 设置信号机扣车按钮1按下周期
* 输入参数： const UINT16 signalId  信号机ID
*            const UINT32 startCycNum 周期号
* 输出参数：无
* 返回值  ：无
*/
void SetDetainBtnPressCycNum(const UINT16 signalId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].DetainBtnPressCycNum = startCycNum;
	}
}

/*
* 功能描述： 获取信号机扣车按钮1按下周期
* 输入参数： const UINT16 signalId  信号机ID
* 输出参数： 无
* 返回值  ： 信号机扣车按钮1按下周期
*/
UINT32 GetDetainBtnPressCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].DetainBtnPressCycNum;
	}
	return reVal;
}

/*
* 功能描述： 设置信号机取消扣车按钮按下周期
* 输入参数： const UINT16 signalId  信号机ID
*            const UINT32 startCycNum 周期号
* 输出参数：无
* 返回值  ：无
*/
void SetCancelDetainBtnPressCycNum(const UINT16 signalId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].CancelDetainBtnPressCycNum = startCycNum;
	}
}

/*
* 功能描述： 获取信号机取消扣车按钮按下周期
* 输入参数： const UINT16 signalId  信号机ID
* 输出参数： 无
* 返回值  ： 信号机取消扣车按钮按下周期
*/
UINT32 GetCancelDetainBtnPressCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].CancelDetainBtnPressCycNum;
	}
	return reVal;
}

/*
* 功能描述： 设置信号机自复式取消扣车按钮1有效标志
* 参数说明： const UINT16 signalId, 信号机ID
*            const UINT8 signalZFSBtnValidFlag 信号机自复式按钮有效标志
* 返回值  ： 无
*/
void SetCancelDetainBtnValidFlag(const UINT16 signalId, const UINT8 signalZFSBtnValidFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_CANCEL_DETAIN_VALID_NO == signalZFSBtnValidFlag) || (SIGNAL_CANCEL_DETAIN_VALID_YES == signalZFSBtnValidFlag))
		{
			SignalDataStru[bufIndex].CancelDetainBtnValidFlag = signalZFSBtnValidFlag;  /*设置信号机硬线扣车状态*/
		}
	}
	else
	{
		/*下标错误，不处理*/
	}
}

/*
* 功能描述： 获取信号机自复式取消扣车按钮1有效标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0: 获取成功
*/
UINT8 GetCancelDetainBtnValidFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_CANCEL_DETAIN_VALID_NO == SignalDataStru[bufIndex].CancelDetainBtnValidFlag)
			|| (SIGNAL_CANCEL_DETAIN_VALID_YES == SignalDataStru[bufIndex].CancelDetainBtnValidFlag))
		{
			reVal = SignalDataStru[bufIndex].CancelDetainBtnValidFlag;
		}
	}
	else
	{
		/*下标错误，不处理*/
	}

	return reVal;
}

/*
* 功能描述： 设置信号机自复式扣车按钮1故障标志
* 参数说明： const UINT16 signalId, 信号机ID
*            const UINT8 signalZFSBtnErrFlag 信号机自复式按钮故障标志
* 返回值  ： 无
*
*/
void SetSignalDetainBtnErrFlag(const UINT16 signalId, const UINT8 signalZFSBtnErrFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO == signalZFSBtnErrFlag) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == signalZFSBtnErrFlag))
		{
			SignalDataStru[bufIndex].DetainBtnErrFlag = signalZFSBtnErrFlag;  /*设置信号机硬线扣车状态*/
		}
	}
}

/*
* 功能描述： 获取信号机自复式扣车按钮1故障标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0: 获取成功
*/
UINT8 GetSignalDetainBtnErrFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO == SignalDataStru[bufIndex].DetainBtnErrFlag) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == SignalDataStru[bufIndex].DetainBtnErrFlag))
		{
			reVal = SignalDataStru[bufIndex].DetainBtnErrFlag;
		}
	}
	return reVal;
}

/*
* 功能描述： 检查当前信号机显示颜色是否合法
* 参数说明： const UINT8 chSignalCurColor 信号机当前显示颜色
* 返回值  ： CI_SUCCESS: 合法
*			 CI_ERROR: 不合法
* by cgh 20230719 相邻联锁传递信号机当前显示颜色时进行接口校验
*/
UINT8 CheckSignalCurColor(const UINT8 chSignalCurColor)
{
	UINT8 reVal = CI_ERROR;
	if ((SIGNAL_SHOWCOLOUR_RED == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_YELLOW == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_REDYELLOW == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_GREEN == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_YELLOWCLOSE == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_GREENCLOSE == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_WHITE == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_RED_WHITE == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_REDBREAK == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_GREENBREAK == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_YELLOWBREAK == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_WHITEBREAK == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_GREENYELLOW == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_GREEN_OR_GREENYELLOW == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_GREEN_OR_YELLOW == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_INVALID == chSignalCurColor)
		|| (SIGNAL_SHOWCOLOUR_REDCLOSE == chSignalCurColor))
	{
		reVal = CI_SUCCESS;
	}
	else
	{
		; /*信号机显示颜色不合法*/
	}
	return reVal;
}

/*
* 功能描述： 判断指定ID信号机是否中心扣车
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ：	aa: 中心扣车
*           55: 未人工扣车
*           5a: 未自动扣车
*/
UINT8 GetSignalATSDetainFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = SIGNAL_ATS_DETAIN_YES;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag) && (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto))
		{/*ATS未扣车*/
			reVal = SIGNAL_ATS_DETAIN_NO;
		}
		else if ((SIGNAL_DETAIN_YES == SignalDataStru[bufIndex].AtsDetainFlag) && (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto))
		{/*ATS人工扣车*/
			reVal = SIGNAL_ATS_DETAIN_YES;
			
		}
		else if ((SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag) && (SIGNAL_DETAIN_YES == SignalDataStru[bufIndex].AtsDetainFlagAuto))
		{/*ATS自动扣车*/
			reVal = SIGNAL_ATS_DETAIN_AUTO_YES;
		}
		else
		{
			reVal = SIGNAL_ATS_DETAIN_YES;
		}

	}
	return reVal;
}

/*
* 功能描述： 判断指定ID信号机是否车站扣车
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ：	CI_ERROR: 车站扣车
*           CI_SUCCESS: 未车站扣车
*/
UINT8 GetSignalLocalDetainFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = SIGNAL_XIANDI_DETAIN_YES;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].XiandiDetainFlag)
		{/*现地未扣车*/

			reVal = SIGNAL_XIANDI_DETAIN_NO;
		}
		else
		{/*现地扣车*/
			reVal = SIGNAL_XIANDI_DETAIN_YES;
		}
	}
	return reVal;
}

/*
* 功能描述：设置逻辑进路驱动信号机异常关闭标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： LOG_ROUTE_SIGNAL_CLOSE_ERR：异常关闭
*			 LOG_ROUTE_SIGNAL_CLOSE_NOERR：未异常关闭
*/
UINT8 GetLogRouteSignalErrCloseFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((LOG_ROUTE_SIGNAL_CLOSE_ERR == SignalDataStru[bufIndex].LogRouteSignalErrCloseFlag) || (LOG_ROUTE_SIGNAL_CLOSE_NOERR == SignalDataStru[bufIndex].LogRouteSignalErrCloseFlag))
		{
			reVal = SignalDataStru[bufIndex].LogRouteSignalErrCloseFlag;
		}
	}

	return reVal;
}


/*
* 功能描述：设置逻辑进路驱动信号机异常关闭标志
* 参数说明： const UINT8 wFlag, 异常关闭标志
*			 const UINT16 signalId, 信号机ID
* 返回值  ： void
*/
void SetLogRouteSignalErrCloseFlag(const UINT16 signalId, const UINT8 wFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((LOG_ROUTE_SIGNAL_CLOSE_ERR == wFlag) || (LOG_ROUTE_SIGNAL_CLOSE_NOERR == wFlag))
		{
			SignalDataStru[bufIndex].LogRouteSignalErrCloseFlag = wFlag;  /*设置信号机异常关闭标志*/
		}
	}
}


/*
* 功能描述： 获取指定ID信号机软件扣车标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取数据失败
*			>0: 扣车标志
*/
UINT8 GetSignalSoftDetainFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag) && (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto))
		{/*ATS未扣车 需满足未自动扣车且未人工扣车*/

			if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].XiandiDetainFlag)
			{/*现地未扣车*/

				reVal = SIGNAL_DETAIN_NO;/*返回现地、ATS均未扣车*/
			}
			else
			{
				/*现地扣车*/
				reVal = SIGNAL_DETAIN_XIANDI;/*返回现地扣车、ATS未扣车*/
			}
		}
		else
		{/*ATS扣车*/

			if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].XiandiDetainFlag)
			{/*现地未扣车*/
				if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag)
				{/*ATS未人工扣车*/
					reVal = SIGNAL_DETAIN_ATS_AUTO;
				}
				else if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto)
				{
					reVal = SIGNAL_DETAIN_ATS;
				}
				else
				{
					;  /*不处理*/
				}

			}
			else
			{
				/*现地扣车*/
				if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag)
				{/*ATS未人工扣车*/

					reVal = SIGNAL_DETAIN_XIANDI_ATSAUTO;/*ATS自动扣车+现地扣车*/
				}
				else if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto)
				{/*ATS未自动扣车*/
					reVal = SIGNAL_DETAIN_YES;/*ATS人工扣车+现地扣车*/
				}
				else
				{
					;  /*不处理*/
				}
			}
		}


	}
	return reVal;
}

/*
* 功能描述： 获取信号机列车跨压内方第一区段占压状态
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ： 0: 获取失败
*			>0:信号机列车跨压内方第一区段占压状态
*/
UINT8 GetSigVobcCrossInPhyOccSta(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].VobcCroSigInPhyOccSta;  /*设置信号机列车跨压内方第一区段占压状态*/
	}
	return reVal;
}

/*
* 功能描述： 设置信号机列车跨压内方第一区段占压状态
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 SigVobcCrossInPhyOccSta  设置占压状态
* 返回值  ： 无
*/
void SetSigVobcCrossInPhyOccSta(const UINT16 signalId, const UINT8 SigVobcCrossInPhyOccSta)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SECTION_OCCUPY_NO == SigVobcCrossInPhyOccSta) || (SECTION_OCCUPY_YES == SigVobcCrossInPhyOccSta))
		{
			SignalDataStru[bufIndex].VobcCroSigInPhyOccSta = SigVobcCrossInPhyOccSta;  /*设置信号机工程车跨压关闭状态*/
		}
	}
}

/*
* 功能描述：设置信号机取消扣车按钮误触发按下周期
* 输入参数：const UINT16 signalId  信号机ID
*           const UINT32 startCycNum 周期号
* 输出参数：无
* 返回值  ：无
* Created By LQ 2024.04.11
*/
void SetCancelDetErrTrigPressCycNum(const UINT16 signalId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].CancelDetainErrTrigPressCycNum = startCycNum;
	}
	else
	{
		/*入参错误，不处理*/
	}
}

/*
* 功能描述：获取信号机取消扣车按钮误触发按下周期
* 输入参数：const UINT16 signalId  信号机ID
* 输出参数：无
* 返回值  ：信号机取消扣车按钮误触发按下周期
* Created By LQ 2024.04.11
*/
UINT32 GetCancelDetErrTrigPressCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].CancelDetainErrTrigPressCycNum;
	}
	else
	{
		/*入参错误，返回失败*/
	}

	return reVal;
}

/*
* 功能描述：设置信号机取消扣车按钮采集继电器落下状态
* 参数说明：const UINT16 signalId, 信号机ID
*           const UINT8 cRelayDownState 继电器落下状态
* 返回值  ：无
* Created By LQ 2024.04.11
*/
void SetCancelDetainRelayDownState(const UINT16 signalId, const UINT8 cRelayDownState)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_RELAY_ERROR_DOWN_NO == cRelayDownState) || (SIGNAL_RELAY_ERROR_DOWN_YES == cRelayDownState))
		{
			SignalDataStru[bufIndex].CancelDetainRelayDownState = cRelayDownState;  /*设置取消扣车按钮采集继电器落下状态*/
		}
		else
		{
			/*状态错误，不处理*/
		}
	}
	else
	{
		/*下标错误，不处理*/
	}
}

/*
* 功能描述：获取信号机取消扣车按钮采集继电器落下状态
* 参数说明：const UINT16 signalId, 信号机ID
* 返回值  ：0 获取失败
*			0x55 正常落下
*           0xaa 通信异常落下
* Created By LQ 2024.04.11
*/
UINT8 GetCancelDetainRelayDownState(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_RELAY_ERROR_DOWN_NO == SignalDataStru[bufIndex].CancelDetainRelayDownState)
			|| (SIGNAL_RELAY_ERROR_DOWN_YES == SignalDataStru[bufIndex].CancelDetainRelayDownState))
		{
			reVal = SignalDataStru[bufIndex].CancelDetainRelayDownState;
		}
		else
		{
			/*状态错误，返回0失败*/
		}
	}
	else
	{
		/*下标错误，返回0失败*/
	}

	return reVal;
}

/*
* 功能描述：休眠车终端信号机亮灭状态处理
* 参数说明：const UINT16 wSignalId 信号机ID
* 返 回 值：无
* Created By LQ 2024.08.21
*/
void SleepTrainSignalLightUpProc(const UINT16 wSignalId)
{
	UINT16 wSignalIndex = 0U;
	UINT16 wOutFstPhySecId = 0U;  /*信号机外方第一物理区段*/
	UINT8 cPhySecBelongCiId = 0U;  /*外方第一物理区段物理区段所属CI*/
	UINT8 cLocalCiId = 0U;
	UINT8 cPhySecIncAxleSecNum = 0U;  /*外方第一物理区段包含的计轴区段数量*/
	UINT16* pPhySecIncAxleSecID = NULL;  /*外方第一物理区段包含的计轴区段ID数组*/
	UINT16 wACIdIndex = 0U;  /*AG计轴ID索引*/
	UINT8 cACRelEnvNum = 0U;  /*AG关联的包络数量*/
	UINT16 szACRelEnvID[SECTION_REL_ENVELOPE_SUM_MAX] = { 0U };  /*AG关联的包络ID*/
	const EnvelopeStruct* pEnvelope = NULL;
	UINT8 cSleepState = TRAIN_SLEEP_NO;  /*列车休眠状态*/
	UINT8 cSignalBelongCiId = 0U;  /*信号机所属CI*/
	UINT16 wCutoffPointId = 0U;  /*分界点ID*/

	wSignalIndex = GetSignalConfigBufIndex(wSignalId);  /*获取信号机数组下标*/

	if (SIGNAL_SUM_MAX > wSignalIndex)
	{
		wOutFstPhySecId = GetSignalOutFirstPhySecId(wSignalId);
		cPhySecBelongCiId = GetPhySecBelongCiId(wOutFstPhySecId);
		cLocalCiId = GetSystemParaLocalCiId();  /*获取本控区ID*/

		if ((0U != cLocalCiId) && (cPhySecBelongCiId == cLocalCiId))
		{
			/*信号机外方第一物理区段属于本控区，继续判断*/
			cPhySecIncAxleSecNum = GetPAxisSectionSum(wOutFstPhySecId);
			pPhySecIncAxleSecID = GetPAxisSectionIdBuf(wOutFstPhySecId);

			if ((1U == cPhySecIncAxleSecNum) && (NULL != pPhySecIncAxleSecID))
			{
				/*非道岔区段，继续判断*/
				wACIdIndex = GetLocalCiAxisSectionIndex(pPhySecIncAxleSecID[0]);
				cACRelEnvNum = elm_GetACRelEnvelopeCnt(wACIdIndex, szACRelEnvID);

				if (1U == cACRelEnvNum)
				{
					pEnvelope = elm_GetEnvelopeInfoPtr(szACRelEnvID[0]);
					if ((NULL != pEnvelope) && (TYPE_CT_ENVELOPE == pEnvelope->envelopeType))
					{
						/*计轴区段仅关联一个CT包络，继续判断该列车是否休眠*/
						cSleepState = GetTrainSleepState(pEnvelope->trainID[0]);
						if (TRAIN_SLEEP_YES == cSleepState)
						{
							/*休眠车，设置此信号机亮灯*/
							cSignalBelongCiId = GetSignalBelongCiId(wSignalId);
							if (cSignalBelongCiId == cLocalCiId)
							{
								/*本控区的信号机，设置信号机亮灯*/
								(void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES);
								SetSleepTrainLightUpSignalFlag(wSignalId, SIGNAL_SLEEP_TRAIN_LIGHTUP_YES);  /*设置休眠车点亮信号机标志有效*/
							}
							else
							{
								/*非本控区信号机，通过分界点信息由信号机所在RC点亮信号机*/
								wCutoffPointId = GetAxisRelateCfpId(pPhySecIncAxleSecID[0]);

								if (0U != wCutoffPointId)
								{
									SetCfpSignalLightUpFlag(wCutoffPointId, SIGNAL_SLEEP_TRAIN_LIGHTUP_YES);
								}
								else
								{
									/*获取分界点失败，不处理*/
								}
							}
						}
						else
						{
							/*非休眠车，不处理*/
						}
					}
					else
					{
						/*获取包络失败或非CT包络，不处理*/
					}
				}
				else
				{
					/*无包络或多包络不符合休眠场景，不处理*/
				}
			}
			else
			{
				/*获取物理区段包含的计轴区段失败或非休眠唤醒轨（道岔区段不可休眠），不处理*/
			}
		}
		else
		{
			/*物理区段非本控区，不处理*/
		}
	}
	else
	{
		/*入参检查失败，不处理*/
	}
}

/*
* 功能描述：获取休眠车点亮信号机标志
* 参数说明：const UINT16 signalId 信号机ID
* 返 回 值：0x55 无效
*			0xAA 有效
* Created By LQ 2024.08.21
*/
UINT8 GetSleepTrainLightUpSignalFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 cRetVal = SIGNAL_SLEEP_TRAIN_LIGHTUP_NO;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		cRetVal = SignalDataStru[bufIndex].cSleepTrainLightUpFlag;
	}
	else
	{
		/*入参检查失败，不处理*/
	}

	return cRetVal;
}

/*
* 功能描述：设置休眠车点亮信号机标志
* 参数说明：const UINT16 signalId, 信号机ID
*			const UINT8 cLightUpFlag  点亮标志
* 返 回 值：无
* Created By LQ 2024.08.21
*/
void SetSleepTrainLightUpSignalFlag(const UINT16 signalId, const UINT8 cLightUpFlag)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (SIGNAL_SUM_MAX >bufIndex)
	{
		if ((SIGNAL_SLEEP_TRAIN_LIGHTUP_YES == cLightUpFlag) || (SIGNAL_SLEEP_TRAIN_LIGHTUP_NO == cLightUpFlag))
		{
			SignalDataStru[bufIndex].cSleepTrainLightUpFlag = cLightUpFlag;  /*设置休眠车点亮信号机标志*/
		}
		else
		{
			/*非法标志，不处理*/
		}
	}
	else
	{
		/*入参检查失败，不处理*/
	}
}

/*
* 功能描述：获取信号机湿轨标志
* 参数说明：const UINT16 signalId 信号机ID
* 返 回 值：0x55 无效
*			0xAA 有效
* Created By LQ 2024.09.20
*/
UINT8 GetSignalInHumidRailFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 cRetVal = SIGNAL_IN_HUMID_RAIL_YES;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		cRetVal = SignalDataStru[bufIndex].cInHumidRailFlag;
	}
	else
	{
		/*入参检查失败，不处理*/
	}

	return cRetVal;
}

/*
* 功能描述：设置信号机湿轨标志
* 参数说明：const UINT16 signalId 信号机ID
*			const UINT8 cInHumidRailFlag  信号机湿轨标志
* 返 回 值：无
* Created By LQ 2024.09.20
*/
void SetSignalInHumidRailFlag(const UINT16 signalId, const UINT8 cInHumidRailFlag)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取道岔数组下标*/

	if (SIGNAL_SUM_MAX > bufIndex)
	{
		if ((SIGNAL_IN_HUMID_RAIL_YES == cInHumidRailFlag) || (SIGNAL_IN_HUMID_RAIL_NO == cInHumidRailFlag))
		{
			SignalDataStru[bufIndex].cInHumidRailFlag = cInHumidRailFlag;
		}
		else
		{
			/*非法标志，不处理*/
		}
	}
	else
	{
		/*入参检查失败，不处理*/
	}
}

/*
* 功能描述： 整合指定ID信号机当前断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
* 返回值  ：
bit7：1表示存在红灯断丝；0未断丝
bit6：1表示存在蓝灯断丝；0未断丝
bit5~bit4：11表示存在绿灯断丝；00未断丝，其他非法
bit3~bit2：11表示存在黄灯断丝；00未断丝，其他非法
bit1~bit9：11表示存在白灯断丝；00未断丝，其他非法
* Created By fan 2025.05.06
*/
UINT8 GetSignalCurBreakFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 reVal = 0U;
	UINT8 chDsFlag = 0U;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取区段数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		/*获取红灯断丝标志*/
		chDsFlag = GetSignalDsBreakFlag(signalId);
		if (SIGNAL_DS_BREAK_YES== chDsFlag)
		{
			reVal |= SIGNAL_DS_BREAK_RED;
		}
		else
		{
			; /*不处理*/
		}
		/*获取蓝灯断丝标志*/
		chDsFlag = GetSignalBlueDsBreakFlag(signalId);
		if (SIGNAL_DS_BREAK_YES == chDsFlag)
		{
			reVal |= SIGNAL_DS_BREAK_BLUE;
		}
		else
		{
			; /*不处理*/
		}
		/*获取绿灯断丝标志*/
		chDsFlag = GetSignalGreenDsBreakFlag(signalId);
		if (SIGNAL_DS_BREAK_YES == chDsFlag)
		{
			reVal |= SIGNAL_DS_BREAK_GREEN;
		}
		else
		{
			; /*不处理*/
		}
		/*获取黄灯断丝标志*/
		chDsFlag = GetSignalYellowDsBreakFlag(signalId);
		if (SIGNAL_DS_BREAK_YES == chDsFlag)
		{
			reVal |= SIGNAL_DS_BREAK_YELLOW;
		}
		else
		{
			; /*不处理*/
		}
		/*获取白灯断丝标志*/
		chDsFlag = GetSignalWhiteDsBreakFlag(signalId);
		if (SIGNAL_DS_BREAK_YES == chDsFlag)
		{
			reVal |= SIGNAL_DS_BREAK_WHITE;
		}
		else
		{
			; /*不处理*/
		}
	}
	else
	{
		reVal = 0xFFU;
	}
	return reVal;
}

/*
* 功能描述： 设置相邻联锁指定ID信号机当前断丝标志
* 参数说明： const UINT16 signalId, 信号机ID
*			 const UINT8 curDsFlag, 相邻联锁发送断丝标志
* 返回值  ：无
* Created By fan 2025.05.06
*/
void SetNearCISignalCurDsFlag(const UINT16 signalId, const UINT8 curDsFlag)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT8 localCi = 0u;/*本地联锁ID*/
	UINT8 belongCiId = 0u;/*信号机所属联锁ID*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/
	localCi = GetSystemParaLocalCiId();/*本地联锁ID*/
	belongCiId = GetSignalBelongCiId(signalId);/*获取信号机所属联锁*/

	if (localCi != belongCiId)
	{
		if (bufIndex < SIGNAL_SUM_MAX)
		{
			if (SIGNAL_DS_BREAK_RED == (curDsFlag & SIGNAL_DS_BREAK_RED))
			{
				/*存在红断标志*/
				SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;
			}
			else
			{
				/*清除红断标志*/
				SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_NO;
			}

			if (SIGNAL_DS_BREAK_BLUE == (curDsFlag & SIGNAL_DS_BREAK_BLUE))
			{
				/*存在蓝断标志*/
				SignalDataStru[bufIndex].BlueDsBreakFlag = SIGNAL_DS_BREAK_YES;
			}
			else
			{
				/*清除蓝断标志*/
				SignalDataStru[bufIndex].BlueDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}

			if (SIGNAL_DS_BREAK_GREEN == (curDsFlag & SIGNAL_DS_BREAK_GREEN))
			{
				/*存在绿断标志*/
				SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_YES;
			}
			else
			{
				/*清除绿断标志*/
				SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}

			if (SIGNAL_DS_BREAK_YELLOW == (curDsFlag & SIGNAL_DS_BREAK_YELLOW))
			{
				/*存在黄断标志*/
				SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_YES;
			}
			else
			{
				/*清除黄断标志*/
				SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}

			if (SIGNAL_DS_BREAK_WHITE == (curDsFlag & SIGNAL_DS_BREAK_WHITE))
			{
				/*存在白断标志*/
				SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_YES;
			}
			else
			{
				/*清除白断标志*/
				SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_NO;
			}
		}
		else
		{
			; /*不处理*/
		}
	}
	else
	{
		; /*不处理*/
	}
}

/*
* 功能描述：设置互联互通CI指定ID信号机蓝灯断丝标志
* 参数说明：const UINT16 wSignalId 信号机ID
*			const UINT8 cFlag 断丝标志
* 返 回 值：无
* Created By LQ 2025.05.31
*/
void SetHlhtCiSignalBlueDsBreakFlag(const UINT16 wSignalId, const UINT8 cFlag)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(wSignalId);  /*获取道岔数组下标*/

	if ((SIGNAL_SUM_MAX > bufIndex) && ((SIGNAL_DS_BREAK_NO == cFlag) || (SIGNAL_DS_BREAK_YES == cFlag)))
	{
		SignalDataStru[bufIndex].BlueDsBreakFlag = cFlag;  /*设置蓝灯断丝标志*/
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：设置信号机扣车旁路按钮状态
* 参数说明：const UINT16 signalId, 信号机ID
*           const UINT8 cFlag 旁路按钮状态
* 返 回 值：无
* Created By LQ 2025.06.19
*/
void SetDetCutBtnState(const UINT16 signalId, const UINT8 cState)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_DETAIN_CUT_VALID_NO == cState) || (SIGNAL_DETAIN_CUT_VALID_YES == cState))
		{
			SignalDataStru[bufIndex].cDetCutBtnState = cState;  /*设置旁路按钮状态*/
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		/*下标错误，不处理*/
	}
}

/*
* 功能描述：获取信号机扣车旁路按钮状态
* 参数说明：const UINT16 signalId 信号机ID
* 返 回 值：0: 获取失败
*			>0: 获取成功
* Created By LQ 2025.06.19
*/
UINT8 GetDetCutBtnState(const UINT16 signalId)
{
	UINT16 bufIndex = 0U;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_DETAIN_CUT_VALID_NO == SignalDataStru[bufIndex].cDetCutBtnState)
			|| (SIGNAL_DETAIN_CUT_VALID_YES == SignalDataStru[bufIndex].cDetCutBtnState))
		{
			reVal = SignalDataStru[bufIndex].cDetCutBtnState;
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		/*下标错误，不处理*/
	}

	return reVal;
}

/*
* 功能描述：设置信号机扣车旁路按钮正常按下周期
* 参数说明：const UINT16 signalId  信号机ID
*           const UINT32 startCycNum 周期号
* 返 回 值：无
* Created By LQ 2025.06.19
*/
void SetDetCutBtnPressCycNum(const UINT16 signalId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].DetCutBtnPressCycNum = startCycNum;
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：获取信号机扣车旁路按钮正常按下周期
* 参数说明：const UINT16 signalId  信号机ID
* 返 回 值： 信号机扣车旁路按钮按下正常周期
* Created By LQ 2025.06.19
*/
UINT32 GetDetCutBtnPressCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0U;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].DetCutBtnPressCycNum;
	}
	else
	{
		/*不处理*/
	}

	return reVal;
}

/*
* 功能描述：设置信号机扣车旁路按钮误触发按下周期
* 参数说明：const UINT16 signalId  信号机ID
*           const UINT32 startCycNum 周期号
* 返 回 值：无
* Created By LQ 2025.06.19
*/
void SetDetCutBtnErrTrigPressCycNum(const UINT16 signalId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].DetCutBtnErrTrigPressCycNum = startCycNum;
	}
	else
	{
		/*入参错误，不处理*/
	}
}

/*
* 功能描述：获取信号机扣车旁路按钮误触发按下周期
* 输入参数：const UINT16 signalId  信号机ID
* 输出参数：无
* 返回值  ：信号机扣车旁路按钮误触发按下周期
* Created By LQ 2025.06.19
*/
UINT32 GetDetCutBtnErrTrigPressCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0U;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].DetCutBtnErrTrigPressCycNum;
	}
	else
	{
		/*入参错误，返回失败*/
	}

	return reVal;
}

/*
* 功能描述：设置信号机扣车旁路按钮故障标志
* 参数说明：const UINT16 signalId 信号机ID
*           const UINT8 cBtnErrFlag 信号机扣车旁路按钮故障标志
* 返 回 值：无
* Created By LQ 2025.06.19
*/
void SetSignalDetCutBtnErrFlag(const UINT16 signalId, const UINT8 cBtnErrFlag)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO == cBtnErrFlag) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == cBtnErrFlag))
		{
			SignalDataStru[bufIndex].cDetCutBtnErrFlag = cBtnErrFlag;  /*设置信号机扣车旁路按钮故障标志*/
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：获取信号机扣车旁路按钮故障标志
* 参数说明：const UINT16 signalId 信号机ID
* 返 回 值：0: 获取失败
*		   >0: 获取成功
* Created By LQ 2025.06.19
*/
UINT8 GetSignalDetCutBtnErrFlag(const UINT16 signalId)
{
	UINT16 bufIndex = 0U;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO == SignalDataStru[bufIndex].cDetCutBtnErrFlag) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == SignalDataStru[bufIndex].cDetCutBtnErrFlag))
		{
			reVal = SignalDataStru[bufIndex].cDetCutBtnErrFlag;
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		/*不处理*/
	}

	return reVal;
}

/*
* 功能描述：设置信号机扣车旁路按钮采集继电器落下状态
* 参数说明：const UINT16 signalId 信号机ID
*           const UINT8 cRelayDownState 继电器落下状态
* 返 回 值：无
* Created By LQ 2025.06.19
*/
void SetDetCutBtnRelayDownState(const UINT16 signalId, const UINT8 cRelayDownState)
{
	UINT16 bufIndex = 0U;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_RELAY_ERROR_DOWN_NO == cRelayDownState) || (SIGNAL_RELAY_ERROR_DOWN_YES == cRelayDownState))
		{
			SignalDataStru[bufIndex].cDetCutBtnRelayDownState = cRelayDownState;  /*设置扣车旁路按钮采集继电器落下状态*/
		}
		else
		{
			/*状态错误，不处理*/
		}
	}
	else
	{
		/*下标错误，不处理*/
	}
}

/*
* 功能描述：获取信号机扣车旁路按钮采集继电器落下状态
* 参数说明：const UINT16 signalId 信号机ID
* 返回值  ：0 获取失败
*			0x55 正常落下
*           0xaa 通信异常落下
* Created By LQ 2025.06.19
*/
UINT8 GetDetCutBtnRelayDownState(const UINT16 signalId)
{
	UINT16 bufIndex = 0U;  /*数组下标*/
	UINT8 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		if ((SIGNAL_RELAY_ERROR_DOWN_NO == SignalDataStru[bufIndex].cDetCutBtnRelayDownState)
			|| (SIGNAL_RELAY_ERROR_DOWN_YES == SignalDataStru[bufIndex].cDetCutBtnRelayDownState))
		{
			reVal = SignalDataStru[bufIndex].cDetCutBtnRelayDownState;
		}
		else
		{
			/*状态错误，返回0失败*/
		}
	}
	else
	{
		/*下标错误，返回0失败*/
	}

	return reVal;
}

/*
* 功能描述：设置信号机扣车按钮2按下周期
* 输入参数：const UINT16 signalId  信号机ID
*           const UINT32 startCycNum 周期号
* 输出参数：无
* 返 回 值：无
* Created By LQ 2025.06.26
*/
void SetDetainSndBtnPressCycNum(const UINT16 signalId, const UINT32 startCycNum)
{
	UINT16 bufIndex = 0u;  /*数组下标*/

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		SignalDataStru[bufIndex].DetainSndBtnPressCycNum = startCycNum;
	}
	else
	{
		/*不处理*/
	}
}

/*
* 功能描述：获取信号机扣车按钮2按下周期
* 输入参数：const UINT16 signalId  信号机ID
* 输出参数：无
* 返 回 值：信号机扣车按钮2按下周期
* Created By LQ 2025.06.26
*/
UINT32 GetDetainSndBtnPressCycNum(const UINT16 signalId)
{
	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 reVal = CI_ERROR;

	bufIndex = GetSignalConfigBufIndex(signalId);  /*获取信号机数组下标*/

	if (bufIndex < SIGNAL_SUM_MAX)
	{
		reVal = SignalDataStru[bufIndex].DetainSndBtnPressCycNum;
	}
	else
	{
		/*不处理*/
	}

	return reVal;
}