/********************************************************
*                                                                                                            
* 文 件 名： ParsePackCiData.c   
* 版权说明： 北京交控科技有限公司 
* 创建时间： 2012-03-28
* 作    者： 联锁组
* 功能描述： CI数据解析组包
* 修改记录：   
*
********************************************************/ 

#include "ParsePackCiData.h"
#include "../DataManage/DeviceConfigDataManage.h"
#include "../HLHTMsgHead/HLHTCommonDataPacketHead.h"
#include "../HLHTMsgHead/HLHTHeadContexManage.h"
#include "../QueryFiles/dquCIInterFace.h"
#include "../CutoffPoint/CutoffPointDataManage.h"
#include "ELMDataPrepare.h"

#define CI_CI_DEFAULT_DEV_SUM_BUF_LEN 40U /*当相邻CI间不需要发送设备状态时，只发送命令时，相应的设备数量占的缓冲区位置需要填写0，每个设备数量2字节（区间雨雪数量和区间ITE切除数量各1个字节），所以40个字节*/

/*解包使用*/
ToCiCommandDataStruct RecvCiCmdDataStru[RECVCI_CMD_DATA_STRU_SUM_MAX] = {0u}; /*CI接受其他联锁命令结构体数组*/
UINT16 RecvCiCmdDataStruCurSum = 0u;	    /*CI接受其他联锁命令结构体数组长度*/

/*组包使用*/
ToCiCommandDataStruct SendCiCmdDataStru[SENDCI_CMD_DATA_STRU_SUM_MAX] = {0u}; /*CI发送到其他联锁命令结构体数组*/
UINT16 SendCiCmdDataStruCurSum = 0u;	    /*CI发送到其他联锁命令结构体数组长度*/

UINT16 PhySecIdBufOfOtherCi[PHYSICAL_SECTION_SUM_MAX] = {0u};		/*本联锁具有锁闭状态管理权的物理区段ID数组*/
UINT8 PhySecIdBufSumhOfOtherCi = 0u;									/*本联锁具有锁闭状态管理权的物理区段ID数组数目*/

#define CI_INTER_SUM_MAX ((CI_SUM_MAX)+ (CI_SUM_MAX))
CiTransmitStruct ciTransmitStruct[CI_INTER_SUM_MAX] = { 0u };
UINT16 ciTransNum;

TiocTransmitCtStruct g_szTiocCt[TRANSMIT_OBJECT_DEVICE_SUM_MAX] = { 0u };
UINT8 g_transmitTiocNum = 0u;

ToCiDrCmdDataStruct RecvCiDrCmdDataStru[RECVCI_CMD_DATA_STRU_SUM_MAX] = { 0U };  /*CI接收其他联锁动态进路命令结构体数组*/
UINT8 RecvCiDrCmdSum = 0U;  /*CI接收其他联锁动态进路命令总数*/

ToCiDrCmdDataStruct SendCiDrCmdDataStru[RECVCI_CMD_DATA_STRU_SUM_MAX] = { 0U };  /*CI发送到其他联锁动态进路命令结构体数组*/
UINT8 SendCiDrCmdSum = 0U;  /*CI发送到其他联锁动态进路命令总数*/

ToCiAreaSnowStruct szRecvCiAreaSnow[CI_COM_CI_MAX_NUM] = { 0U };  /*接收来自相邻联锁的区间雨雪站台信息*/

ToCiAreaSnowStruct szSendCiAreaSnow[CI_COM_CI_MAX_NUM] = { 0U };  /*发送给相邻联锁的区间雨雪站台信息*/

ToCiAreaIteCutStruct szRecvCiAreaIteCut[CI_COM_CI_MAX_NUM] = { 0U };  /*接收来自相邻联锁的区间ITE切除信息*/

ToCiAreaIteCutStruct szSendCiAreaIteCut[CI_COM_CI_MAX_NUM] = { 0U };  /*发送给相邻联锁的区间ITE切除信息*/

#define CI_TO_CI_INTERFACE		(0x0606)

#define INTERFACE_INFO_TYPE_LEN (2U)			/*接口类型字节长度*/

#define SOURCE_ID_LEN (4U)					/*源ID字节长度*/

#define DESTIN_ID_LEN (4U)					/*目的ID字节长度*/

#define EMAP_VISION_CHECK_SUM_LEN (4U)		/*电子地图校验信息字节长度*/

#define SOURCE_MESSAGE_SN_LEN (4U)			/*本方消息序号字节长度*/

#define COMM_PERIOD_LEN (2U)					/*通信周期字节长度*/

#define DESTIN_MESSAGE_SN_LEN (4U)			/*对方消息序号字节长度*/

#define PREV_SOURCE_MESSAGE_SN_LEN (4U)		/*收到上一条信息时对方消息序号字节长度*/

#define PROTOCOL_VERSION_LEN (1U)			/*协议版本号字节长度*/

#define APP_LAYER_PACKET_LEN_LEN (2U)		/*应用层报文总长度字节长度*/

void PackCiToCiDataFrameUseCfg(UINT8 dstCiId,UINT8* dataFrame, UINT16* dataLength);

/**
* @brief 组区间疏散消息
* @param UINT8 dstCiId 目标TIOC编号
* @param UINT8* dataFrame 数据缓冲区
* @return 长度
*/
static UINT16 PackCiToCiDataFrameEa(UINT8 dstCiId, UINT8* dataFrame);

/*互联互通相关*/

static UINT8 SetIntconPhySecRLockState(UINT16 phySecId, UINT8 routeLockState);

/*
功能描述:
获取单一报文类型
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pPacketType 报文类型
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParsePacketType(const UINT8* pInputData, UINT16* pPacketType, UINT16* pItemLen);

/*
功能描述:
组应用报文类型数据包
输入参数:
UINT8 *pInputData 输入数据指针，UINT16 packetType 应用报文类型
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackPacketType(UINT8* pInputData, UINT16 packetType, UINT16* pItemLen);

/*
功能描述:
获取单一报文长度
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pPacketLen 报文长度
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParsePacketLength(const UINT8* pInputData, UINT16* pPacketLen, UINT16* pItemLen);

/*
功能描述:
在*pInputData中，获取存放报文内容长度地址的地址
输入参数:
UINT8 *pInputData 组包数据指针
输出参数:
UINT8 **ppLenItemAddr 存放报文内容长度地址的地址
UINT16 *pItemLen 相应类型的报文内容长度：由“报文类型～报文结束”的帧长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackPacketLenPha1(UINT8* pInputData, UINT8** ppLenItemAddr, UINT16* pItemLen);

/*
功能描述:
在*pInputData中保存报文长度的地址上，填入相应类型的报文内容的长度
输入参数:
UINT8 *pInputData 组包数据指针
输出参数:
UINT16 *pItemLen 相应类型的报文内容长度：由“报文类型～报文结束”的帧长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackPacketLenPha2(UINT8* pInputData, UINT16 itemLen);

/*
功能描述:
解析道岔数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParseSwitchPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId);

/*
功能描述:
组道岔数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
const UINT8 dstCiId:目标联锁ID
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackSwitchPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId);

/*
功能描述:
解析物理区段状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParsePhySecPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId);

/*
功能描述:
组物理区段数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackPhySecPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId);

/*
功能描述:
解析逻辑区段状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParseLogSecPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId);

/*
功能描述:
组逻辑区段数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackLogSecPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId);

/*
功能描述:
解析信号机状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParseSignalPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId);

/*
功能描述:
组信号机数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackSignalPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId);

/*
功能描述:
解析站台门状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParsePsdPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId);

/*
功能描述:
组站台门数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackPsdPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId);

/*
功能描述:
解析紧急关闭按钮状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParseEmbtnPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId);

/*
功能描述:
组紧急关闭按钮数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 PackEmbtnPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId);

/*
功能描述:
解析照查状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParseZhaoChaPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId);

/*
功能描述:
组照查继电器数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 PackZhaoChaPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId);
/*
功能描述:
解析防淹门状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParseFloodGatePacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId);

/*
功能描述:
组防淹门状态数据包
输入参数:
UINT8 *pInputData 输入数据指针
const UINT8 dstCiId 目标控区ID
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 PackFloodGatePacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId);


/*
功能描述:
解析上电锁闭状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParseStartLockPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId);


/*
功能描述:
组上电锁闭状态数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackStartLockPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId);

/*
* 功能描述：解析互联互通CI接口临时限速数据包
* 参数说明：UINT8 *pInputBuf 输入数据指针
*           UINT16 *pItemLen 该项数据在输入数据中的长度
*           const UINT8 srcCiId 源联锁ID
* 返 回 值：1 成功
*           0 失败
* edit cgh 20250116
*/
static UINT8 ParseTSRPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId);

/*
* 功能描述：互联互通CI接口组临时限速数据包
* 参数说明：UINT8 *pInputBuf 输入数据指针
*           UINT16 *pItemLen 该项数据在输入数据中的长度
*           const UINT8 dstCiId 目标联锁ID
* 返 回 值：1 成功
*           0 失败
* edit cgh 20250116
*/
static UINT8 PackTSRPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId);
/*
功能描述:
解析城市自定义数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParseCityDefPacket(const UINT8* pInputData, UINT16* pItemLen);

/*
功能描述:
组包城市自定义数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackCityDefPacket(UINT8* pInputData, UINT16* pItemLen);

/*
功能描述:
构造互联互通联锁应用数据内容
输入参数:
const UINT8 dstCiId 目标联锁ID
输出参数:
UINT8 *pInputData 数据缓存指针
UINT16 *pOverallLen 应用数据总长度指针
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 PackCiPacketCont(UINT8* pInputData, UINT16* pOverallLen, const UINT8 dstCiId);

/*
功能描述:
解析联锁报文内容
输入参数:
const UINT8 *pInputData 输入数据指针
const UINT16 overallLen 应用报文总长度
输出参数:
无
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParseCiPacketCont(const UINT8* pInputData, const UINT16 overallLen, const UINT8 srcId);

/*
功能描述:
构建互联互通联锁至联锁应用报文数据帧
输入参数:
UINT8 dstCiId 目标联锁ID
输出参数:
UINT8* dataFrame 数据帧缓存指针
UINT16* dataLength 数据帧长度变量指针
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 PackHLHTCiToCiDataFrameUseCfg(UINT8 dstCiId, UINT8* dataFrame, UINT16* dataLength);

/*互联互通相关*/
UINT16 packetOderQueue[16] =
{	SWITCH_STATUS_PACKET,
	PHYSIC_SEC_STATUS_PACKET,
	LOGIC_SEC_STATUS_PACKET,
	SIGNAL_STATUS_PACKET,
	PSD_STATUS_PACKET,
	EMERGEBTN_STATUS_PACKET,
	ZHAOCHA_STATUS_PACKET,
	FLOOD_GATE_STATUS_PACKET,
	START_LOCK_STATUS_PACKET,
	LINSHI_XIANSU_STATUS_PACKET,
	CITY_DEF_STATUS_PACKET,
	MANUFAC_DEF_STATUS_PACKET,
	0xFFFFu,
	0xFFFFu,
	0xFFFFu,
	0xFFFFu};

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

/*
* 功能描述： 解析CI数据
* 参数说明： void    
* 返回值  ： 0: 解析失败
*			 1: 解析成功        
*/
UINT8 ParseCiToCiData(void)
{	
	QueueStruct* ci0ToCiDataQueue = Get2oo2CiRecvCiDataQueue();
    UINT32 dataQueueTotalLen = 0u;	/*队列数据总长度*/
    UINT8 dataLenBuf[2];			/*数据长度数组*/
    UINT8 tempBuf[7];				/*临时数据数组*/
    UINT8 tempDataBuf[5000];		/*数据临时数组*/
    UINT16 appDataLen = 0u;			/*一帧数据长度*/

	if (ci0ToCiDataQueue != NULL)
	{
		/*获取队列数据总长度*/
		dataQueueTotalLen = QueueStatus(ci0ToCiDataQueue);
		
		while (dataQueueTotalLen > 0u)
		{
			(void)QueueScan(2, dataLenBuf, ci0ToCiDataQueue);
			
			appDataLen = (UINT16) (ShortFromChar(dataLenBuf) + 2u);	/*获取本帧数据长度*/
			
			if ((dataQueueTotalLen >= appDataLen) && (appDataLen >= 6u))
			{
                /*读出前6个字节数据*/
               (void)QueueRead(6, tempBuf, ci0ToCiDataQueue);
                
                /*从队列中读出一帧数据*/
               (void) QueueRead(appDataLen-6U, tempDataBuf, ci0ToCiDataQueue);
                
                /*解析CI到CI数据帧*/
				(void)ParseCiToCiDataFrame(tempDataBuf, (UINT16)(appDataLen-6U));
				
			}
			else
			{
				break;
			}
			
			/*获取队列数据总长度*/
			dataQueueTotalLen = QueueStatus(ci0ToCiDataQueue);
		}
		
		if (dataQueueTotalLen > 0u)
		{
			(void)QueueClear(ci0ToCiDataQueue);	/*清队列*/
			
			return 0u;
		}
		else
		{
			return 1u;
		}
	}
	else
	{
		return 0u;
	}
}

/*
* 功能描述： 校验CI到CI的帧数据长度合法性
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 totalLength, 数据总长度
*			 UINT8 * errNo,错误码地址
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功      
*/
UINT8 CheckCi2CiDataLenValid(const UINT8* dataBuf, const UINT16 totalLength,UINT8 * errNo)
{
	/*长度校验：总长度=2B(源ID) + 4B(源周期号)+ 2B(目标ID) + 2B(版本号) +4B(CI与CI间版本校验信息) + 2B(站场长度staLen)  +
		*					2B（道岔数量m）+		m * (12B)  +
		*					2B（物理区段数量n）+ n * (14B) + 
		*					2B (逻辑区段数量p) + p *	(4B)	 + 
		*					2B (信号机数量a)	+	a *	(11B)	 +
		*					2B (屏蔽门数量b) +	b *	(5B)	 +
		*					2B (ESB数量c) +		c *	(3B)	 +
		*					2B (进路数量d) +		d *	(8B)	 +
		*					2B (物理区段锁闭状态数量e) + e *	(10B)	 +
		*					2B (spks数量f) +		f *	(4B)	 +
		*					2B (虚拟继电器数量g) + g * (3B)	+
		*					2B（命令数量h）+ h * (6B)
		*					2B (自动通过进路数量i) + i*(3B)
		*	站场长度 = m*(7B) + n*(14B) + p*(4B) + a*(8B) + b*(2B) + c*(3B) + d*(8B) + e*(10B) + f*(4B) + g*(3B)
		*   总长度 = 2B + 4B +2B + 1B + 2B站场长度 + 站场数据 + 2B（命令数量h）+ h * (6B)
		*
		* 需求出并校验：
		* 站场长度索引 = 8
		* 道岔数量索引 = 10
		* 物理区段数量索引 = 10 + 2 + m*(7)
		* 逻辑区段数量索引 = 10 + 2 + m*(7) + 2 + n*(14) 
		* 信号机数量索引   = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4)
		* 屏蔽门数量索引   = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(10)
		* ESB数量索引	   = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(10) + 2 + b*(5)
		* 进路数量索引	   = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(10) + 2 + b*(5) + 2 + c*(3)
		* 物理区段锁闭状态数量索引 = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(10) + 2 + b*(5) + 2 + c*(3) + 2 + d*(8)
		* spks数量索引			   = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(10) + 2 + b*(5) + 2 + c*(3) + 2 + d*(8) + 2 + e*(10)
		* 虚拟继电器数量索引 = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(10) + 2 + b*(5) + 2 + c*(3) + 2 + d*(8) + 2 + e*(10) + 2 + f*(4)
		* 命令数量索引 = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(10) + 2 + b*(5) + 2 + c*(3) + 2 + d*(8) + 2 + e*(10) + 2 + f*(4) + 2 + g*(3)
		* 自动通过进路数量索引 = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(10) + 2 + b*(5) + 2 + c*(3) + 2 + d*(8) + 2 + e*(10) + 2 + f*(4) + 2 + g*(3)+2+h*(6)

		* 校验站场长度
		* 校验总长度
		*
	*/
	UINT8 reVal = CI_ERROR;
	UINT16 switchNum = 0u, switchNumIndex = 0u;
	UINT16 phySecNum = 0u, phySecNumIndex = 0u;
	UINT16 logSecNum = 0u, logSecNumIndex = 0u;
	UINT16 signalNum = 0u, signalNumIndex = 0u;
	UINT16 psdNum = 0u,	psdNumIndex = 0u;
	UINT16 esbNum = 0u,	esbNumIndex = 0u;
	UINT16 routeNum = 0u,routeNumIndex = 0u;
	UINT16 physecLockStateNum = 0u,	physecLockStateNumIndex = 0u;
	UINT16 spksNum = 0u,	spksNumIndex = 0u;
	UINT16 virtualRelayNum = 0u,	virtualRelayNumIndex = 0u;
	UINT16 floodGateNum = 0u,	floodGateNumIndex = 0u;
	UINT16 overlapNum = 0u,overlapNumIndex = 0u;
	UINT16 cmdNum = 0u,		cmdNumIndex = 0u;
	UINT16 stationLen = 0u,	stationLenIndex = 0u;
	UINT16 tmpStationLen = 0u;
	UINT16 logsecLockStateNumIndex = 0u;
	UINT16 logsecLockStateNum = 0u;
	UINT16 wCfpInfoNum = 0u;
	UINT16 wCfpInfoIndex = 0u;
	UINT8 chTrainNum = 0U;
	UINT16  trainNumIndex = 0U;
	UINT16  trainNum = 0U;
	UINT16  ii = 0U;
	UINT16 wCfpInfoLen = 0u;
	UINT16 wCfpIndex = 0u;
	UINT8 chEnvelopeNum = 0u;
	UINT8 chEnvelopeIndex = 0u;
	UINT8 chLgcStateTrainNum = 0u;
	UINT8 chTrainIndex = 0u;
	UINT16 wEaLen = 0u;
	UINT8 chEaNum = 0u;
	UINT8 chEaIndex = 0u;
	UINT16 wEaInfoIndex = 0u;
	UINT8 chEaLgcNum = 0u;
	UINT16 autoRouteNum = 0u;
	UINT16 autoRouteNumIndex = 0u;
	UINT16 wDrCmdNum = 0U;   /*动态进路命令数量*/
	UINT8 cDrLogSecNum = 0U;
	UINT8 cDrTrainLocLogSecNum = 0U;
	UINT16 wDrCmdIndex = 0U;
	UINT16 wDrCmdLenIndex = 0u;
	UINT16 wAreaSnowIndex = 0U;
	UINT8 cAreaSnowNum = 0U;
	UINT16 wLeaveLogIndex = 0U;
	UINT16 cLeaveLogNum = 0U;
	UINT16 wNeedCheckSwStaRouteIndex = 0U;
	UINT16 wNeedCheckSwStaRouteSum = 0U;
	UINT16 wNeedCheckProSwStaOlpIndex = 0U;
	UINT16 wNeedCheckProSwStaOlpNum = 0U;  /*需要本控区检查防护道岔状态的保护区段数量*/
	UINT16 wProSwitchNum = 0U;
	UINT16 wProSwitchIndex = 0U;
	UINT8 cPLockRouteNum = 0U;
	UINT8 cPLockOverlapNum = 0U;
	UINT16 wProSwInfoLen = 0U;
	UINT16 wAreaIteCutIndex = 0U;
	UINT8 cAreaIteCutNum = 0U;

	/*空指针防护*/
	if (NULL == errNo)
	{
		reVal = CI_ERROR;
	}
	else
	{
		reVal = CI_SUCCESS;
	}

	if (CI_SUCCESS == reVal)
	{
		/*校验站场长度索引*/
		if (totalLength < CICI_BEGIN_TO_STATION_LEN)
		{
			reVal = CI_ERROR;
			*errNo = 1U;
		}
		else
		{
			stationLenIndex = CICI_BEGIN_TO_STATION_LEN - 2U;
			stationLen = ShortFromChar(&dataBuf[stationLenIndex]);
			reVal = CI_SUCCESS;
		}
	}
	
	if (CI_SUCCESS == reVal)
	{
		/*校验道岔长度索引*/
		if (totalLength < CICI_BEGIN_TO_STATION_LEN + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 2U;
		}
		else
		{
			switchNumIndex = CICI_BEGIN_TO_STATION_LEN;
			switchNum = ShortFromChar(&dataBuf[switchNumIndex]);
			reVal = CI_SUCCESS;
		}
	}
	

	/*校验物理区段长度索引*/
	if (CI_SUCCESS == reVal)
	{
		phySecNumIndex = CICI_BEGIN_TO_STATION_LEN + 2U + switchNum * CICI_ONE_SWITCH_LEN;
		if (totalLength < phySecNumIndex + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 3U;
		} 
		else
		{
			phySecNum = ShortFromChar(&dataBuf[phySecNumIndex]);
			reVal = CI_SUCCESS;
		}
		
	}

	/*校验逻辑区段*/
	if (CI_SUCCESS == reVal)
	{
		logSecNumIndex = phySecNumIndex + 2U + phySecNum * CICI_ONE_PHYSEC_LEN;
		if (totalLength < logSecNumIndex +2U)
		{
			reVal = CI_ERROR;
			*errNo = 4U;
		} 
		else
		{
			logSecNum = ShortFromChar(&dataBuf[logSecNumIndex]);
			reVal = CI_SUCCESS;
		}
	}
	if (CI_SUCCESS == reVal)
	{
		if (0u == logSecNum)
		{
			trainNumIndex = logSecNumIndex + 1u;
		}
		else
		{
			for (ii = 0U; ii < logSecNum; ii++)
			{
				/*当前列车数量下标 = 逻辑区段起始下标+2（起始下标长度）+之前逻辑区段其余数据长度+之前列车数据长度+之前列车长度占位长度*/
				trainNumIndex = logSecNumIndex + 2U + (ii + 1U)*CICI_ONE_LOGSEC_LEN + chLgcStateTrainNum * 3U + ii * 1U;
				chLgcStateTrainNum += dataBuf[trainNumIndex];
			}
		}
	}
	/*校验信号机索引*/
	if (CI_SUCCESS == reVal)
	{
		signalNumIndex = trainNumIndex + 1u + dataBuf[trainNumIndex] * 3u; ;

		if (totalLength < signalNumIndex +2U)
		{
			reVal = CI_ERROR;
			*errNo = 5U;
		}
		else
		{
			signalNum = ShortFromChar(&dataBuf[signalNumIndex]);
			reVal = CI_SUCCESS;
		}
	} 
	

	/*校验屏蔽门数量索引*/
	if (CI_SUCCESS == reVal)
	{
		psdNumIndex = signalNumIndex +	2U + signalNum * CICI_ONE_SIGNAL_LEN ;

		if (totalLength < psdNumIndex + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 6U;
		} 
		else
		{
			psdNum = ShortFromChar(&dataBuf[psdNumIndex]);
			reVal = CI_SUCCESS;
		}
	} 
	

	/*校验ESB数量索引*/
	if (CI_SUCCESS == reVal)
	{
		esbNumIndex = psdNumIndex +	2U + psdNum * CICI_ONE_PSD_LEN;
		if (totalLength < esbNumIndex +2U)
		{
			reVal = CI_ERROR;
			*errNo = 7U;
		}
		else
		{
			esbNum = ShortFromChar(&dataBuf[esbNumIndex]);
			reVal = CI_SUCCESS;
		}
	} 

	/*校验进路数量索引*/
	if (CI_SUCCESS == reVal)
	{
		routeNumIndex = esbNumIndex + 2U + esbNum * CICI_ONE_ESB_LEN;
		if (totalLength < routeNumIndex +2U)
		{
			reVal = CI_ERROR;
			*errNo = 8U;
		}
		else
		{
			routeNum = ShortFromChar(&dataBuf[routeNumIndex]);
			reVal = CI_SUCCESS;
		}
	}

	/*校验物理区段锁闭状态索引*/
	if (CI_SUCCESS == reVal)
	{
		physecLockStateNumIndex = routeNumIndex + 2U + routeNum * CICI_ONE_ROUTE_LEN;
		if (totalLength < physecLockStateNumIndex + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 9U;
		}
		else
		{
			physecLockStateNum = ShortFromChar(&dataBuf[physecLockStateNumIndex]);
			reVal = CI_SUCCESS;
		}
	}

	/*校验spks数量索引*/
	if (CI_SUCCESS == reVal)
	{
		spksNumIndex = physecLockStateNumIndex + 2U + physecLockStateNum * CICI_ONE_PHYSEC_LOCKSTATE_LEN;
		if (totalLength < spksNumIndex + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 10U;
		} 
		else
		{
			spksNum = ShortFromChar(&dataBuf[spksNumIndex]);
			reVal = CI_SUCCESS;
		}
	}

	/*校验虚拟继电器数量索引*/
	if (CI_SUCCESS == reVal)
	{
		virtualRelayNumIndex = spksNumIndex + 2U + spksNum * CICI_ONE_SPKS_LEN;
		if (totalLength < virtualRelayNumIndex + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 11U;
		} 
		else
		{
			virtualRelayNum = ShortFromChar(&dataBuf[virtualRelayNumIndex]);
			reVal = CI_SUCCESS;
		}
	}

	/*校验防淹门数量索引*/
	if (CI_SUCCESS == reVal)
	{
		floodGateNumIndex = virtualRelayNumIndex + 2u + (virtualRelayNum * CICI_ONE_VIRTUAL_RELAY_LEN);
		if (totalLength < (floodGateNumIndex + 2u))
		{
			reVal = CI_ERROR;
			*errNo = 12U;
		} 
		else
		{
			floodGateNum = ShortFromChar(&dataBuf[floodGateNumIndex]);
			reVal = CI_SUCCESS;
		}
	}

	/*校验保护区段数量索引*/
	if (CI_SUCCESS == reVal)
	{
		overlapNumIndex = floodGateNumIndex + 2u + floodGateNum * CICI_ONE_FLOODGATE_LEN;
		if (totalLength < overlapNumIndex +2u)
		{
			reVal = CI_ERROR;
			*errNo = 13U;
		}
		else
		{
			overlapNum = ShortFromChar(&dataBuf[overlapNumIndex]);
			reVal = CI_SUCCESS;
		}
	}
	/*cgh-合并CID-2539-7：校验自动通过进路数量索引*/
	if (CI_SUCCESS == reVal)
	{
		autoRouteNumIndex = overlapNumIndex + 2u + overlapNum * CICI_ONE_OVERLAP_LEN;
		if (totalLength < autoRouteNumIndex + 2u)
		{
			reVal = CI_ERROR;
			*errNo = 14U;
		}
		else
		{
			autoRouteNum = ShortFromChar(&dataBuf[autoRouteNumIndex]);
			reVal = CI_SUCCESS;
		}
	}
	/*校验逻辑区段锁闭数量索引*/
	if(CI_SUCCESS == reVal)
	{
		logsecLockStateNumIndex = autoRouteNumIndex + 2u + autoRouteNum*CICI_ONE_AUTOROUTE_LEN;
		if(totalLength < logsecLockStateNumIndex + 2u)
		{
			reVal = CI_ERROR;
			*errNo = 15U;
		}
		else
		{
			logsecLockStateNum = ShortFromChar(&dataBuf[logsecLockStateNumIndex]);
			reVal = CI_SUCCESS;
		}
	}

	if (CI_SUCCESS == reVal)
	{
		trainNum = 0U;
		trainNumIndex = 0u;
		for (ii = 0U; ii < logsecLockStateNum; ii++)
		{
			trainNumIndex = logsecLockStateNumIndex + 2U + (ii + 1U)*CICI_ONE_LOGSEC_LOCKSTATE_LEN + trainNum * 2U + ii * 1U;
			trainNum += dataBuf[trainNumIndex];
		}
		if (totalLength < trainNumIndex + 2u)
		{
			reVal = CI_ERROR;
			*errNo = 16U;
		}
		else
		{
			reVal = CI_SUCCESS;
		}
	}

	/*校验分界点索引*/
	if (CI_SUCCESS == reVal)
	{
		if (0u == trainNumIndex)
		{
			wCfpInfoIndex = logsecLockStateNumIndex + 2U;
		}
		else
		{
			wCfpInfoIndex = trainNumIndex + 1u + dataBuf[trainNumIndex] * 2u;
		}
		
		if (totalLength < wCfpInfoIndex + 2u)
		{
			reVal = CI_ERROR;
			*errNo = 17U;
		}
		else
		{
			wCfpInfoNum = ShortFromChar(&dataBuf[wCfpInfoIndex]);
			wCfpInfoIndex += 2u;
			for (wCfpIndex = 0u; wCfpIndex < wCfpInfoNum; wCfpIndex++)
			{
				wCfpInfoIndex += CICI_ONE_CUT_OFFPOINT_LEN;
				wCfpInfoLen += CICI_ONE_CUT_OFFPOINT_LEN;

				chEnvelopeNum = dataBuf[wCfpInfoIndex++];
				wCfpInfoLen++;
				for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++)
				{
					wCfpInfoIndex += 19u;
					wCfpInfoLen += 19u;

					chTrainNum = dataBuf[wCfpInfoIndex++];
					wCfpInfoLen++;
					for (chTrainIndex = 0u; chTrainIndex < chTrainNum; chTrainIndex++)
					{
						wCfpInfoIndex += 3u;  /*增加列车激活端*/
						wCfpInfoLen += 3u;
					}
				}

				chEnvelopeNum = dataBuf[wCfpInfoIndex++];
				wCfpInfoLen++;
				for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++)
				{
					wCfpInfoIndex += 35u;
					wCfpInfoLen += 35u;
				}

				/*分界点远程RM跨控区申请信息*/
				wCfpInfoIndex += 7U;
				wCfpInfoLen += 7U;

				/*分界点关联的相邻RC的信号机ID*/
				wCfpInfoIndex += 2U;
				wCfpInfoLen += 2U;

				/*分界点信号机亮灯标志*/
				wCfpInfoIndex++;
				wCfpInfoLen++;
			}
			reVal = CI_SUCCESS;
		}
	}

	/*校验区间雨雪长度*/
	if (CI_SUCCESS == reVal)
	{
		wAreaSnowIndex = wCfpInfoIndex;
		if (totalLength < wAreaSnowIndex + 1U)
		{
			reVal = CI_ERROR;
			*errNo = 18U;
		}
		else
		{
			cAreaSnowNum = dataBuf[wAreaSnowIndex];
			wAreaSnowIndex++;  /*区间雨雪数量*/
			wAreaSnowIndex += cAreaSnowNum * 3U;  /*区间ID+区间湿轨等级*/
		}		
	}

	/*校验区间ITE切除长度*/
	if (CI_SUCCESS == reVal)
	{
		wAreaIteCutIndex = wAreaSnowIndex;
		if (totalLength < wAreaIteCutIndex + 1U)
		{
			reVal = CI_ERROR;
			*errNo = 27U;
		}
		else
		{
			cAreaIteCutNum = dataBuf[wAreaIteCutIndex];
			wAreaIteCutIndex++;  /*区间ITE切除数量*/
			wAreaIteCutIndex += cAreaIteCutNum * 2U;  /*区间ID*/
		}
	}

	/*校验离去逻辑区段长度*/
	if (CI_SUCCESS == reVal)
	{
		wLeaveLogIndex = wAreaIteCutIndex;
		if (totalLength < wLeaveLogIndex + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 23U;
		}
		else
		{
			cLeaveLogNum = ShortFromChar(&dataBuf[wLeaveLogIndex]);/*离去区段数量*/
			wLeaveLogIndex += 2U;/*离去区段数量*/

			wLeaveLogIndex += cLeaveLogNum * 3U;  /*离去区段数据ID*/
		}
	}

	/*校验需要检查道岔状态进路数据长度*/
	if (CI_SUCCESS == reVal)
	{
		wNeedCheckSwStaRouteIndex = wLeaveLogIndex;
		if (totalLength < wNeedCheckSwStaRouteIndex + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 24U;
		}
		else
		{
			wNeedCheckSwStaRouteSum = ShortFromChar(&dataBuf[wNeedCheckSwStaRouteIndex]);/*离去区段数量*/
			wNeedCheckSwStaRouteIndex += 2U;/*检查道岔进路数量*/

			wNeedCheckSwStaRouteIndex += wNeedCheckSwStaRouteSum * 8U;  /*检查道岔进路数量数据*/
		}
	}

	/*校验需要检查防护道岔状态的保护区段数据长度*/
	if (CI_SUCCESS == reVal)
	{
		wNeedCheckProSwStaOlpIndex = wNeedCheckSwStaRouteIndex;
		if (totalLength < wNeedCheckProSwStaOlpIndex + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 25U;
		}
		else
		{
			wNeedCheckProSwStaOlpNum = ShortFromChar(&dataBuf[wNeedCheckProSwStaOlpIndex]);  /*保护区段数量数量*/
			wNeedCheckProSwStaOlpIndex += 2U;

			wNeedCheckProSwStaOlpIndex += wNeedCheckProSwStaOlpNum * 3U;
		}
	}

	/*校验被其它控区进路/保护区段防护锁闭的防护道岔数据长度*/
	if (CI_SUCCESS == reVal)
	{
		wProSwitchIndex = wNeedCheckProSwStaOlpIndex;
		if (totalLength < wProSwitchIndex + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 26U;
		}
		else
		{
			wProSwitchNum = ShortFromChar(&dataBuf[wProSwitchIndex]);  /*防护道岔数量*/
			wProSwitchIndex += 2U;
			for (ii = 0U; ii < wProSwitchNum; ii++)
			{
				wProSwitchIndex += 2U;  /*防护道岔ID*/
				wProSwInfoLen += 2U;

				cPLockRouteNum = dataBuf[wProSwitchIndex];
				wProSwitchIndex++;  /*防护锁闭进路数量*/
				wProSwInfoLen++;
				wProSwitchIndex += cPLockRouteNum * 2U;  /*防护锁闭进路ID*/
				wProSwInfoLen += cPLockRouteNum * 2U;

				cPLockOverlapNum = dataBuf[wProSwitchIndex];
				wProSwitchIndex++;  /*防护锁闭保护区段数量*/
				wProSwInfoLen++;
				wProSwitchIndex += cPLockOverlapNum * 2U;  /*防护锁闭保护区段ID*/
				wProSwInfoLen += cPLockOverlapNum * 2U;
			}
		}
	}	

	/*校验站场长度*/
	if (CI_SUCCESS == reVal)
	{
		tmpStationLen = 2u + (switchNum*CICI_ONE_SWITCH_LEN) + 2u + (phySecNum* CICI_ONE_PHYSEC_LEN) + 2u +(logSecNum*CICI_ONE_LOGSEC_LEN) +
			logSecNum + (chLgcStateTrainNum * 3U)+
			2u + (signalNum * CICI_ONE_SIGNAL_LEN) + 2u + (psdNum * CICI_ONE_PSD_LEN) + 2u + (esbNum*CICI_ONE_ESB_LEN) +
			2u + (routeNum * CICI_ONE_ROUTE_LEN)  + 2u + (physecLockStateNum * CICI_ONE_PHYSEC_LOCKSTATE_LEN) +
			2u + (spksNum * CICI_ONE_SPKS_LEN) + 2u + (virtualRelayNum * CICI_ONE_VIRTUAL_RELAY_LEN) +
			2u + (floodGateNum * CICI_ONE_FLOODGATE_LEN)+ 2u + (overlapNum * CICI_ONE_OVERLAP_LEN) + 2u + (autoRouteNum * CICI_ONE_AUTOROUTE_LEN)+ 
			2u + (logsecLockStateNum * CICI_ONE_LOGSEC_LOCKSTATE_LEN) + logsecLockStateNum + (trainNum * 2U) + 2u + (wCfpInfoLen)+1U + cAreaSnowNum * 3U + 
			1U + cAreaIteCutNum * 2U + 2U + cLeaveLogNum * 3U + 2U + wNeedCheckSwStaRouteSum * 8U + 2U + wNeedCheckProSwStaOlpNum * 3U + 2U + wProSwInfoLen;
		if (stationLen == tmpStationLen)
		{
			reVal = CI_SUCCESS;
		}
		else
		{
			reVal = CI_ERROR;
			*errNo = 19U;
		}
	}

	/* 读取区间疏散相关数据长度 */
	if (CI_SUCCESS == reVal)
	{
		wEaInfoIndex = wProSwitchIndex;
		chEaNum = dataBuf[wEaInfoIndex]; /* 读取相邻控区发来的区段疏散数量 */
		wEaLen++;
		wEaInfoIndex++;
		for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++)
		{
			wEaInfoIndex += 2u;	/* 区间疏散列车ID */
			wEaLen += 2u;
			chEaLgcNum = dataBuf[wEaInfoIndex];	/* 区间疏散逻辑区段数量 */
			wEaInfoIndex++;
			wEaLen++;
			wEaInfoIndex += (UINT16)(chEaLgcNum * sizeof(UINT16));	/* 区间疏散逻辑区段ID */
			wEaLen += (UINT16)(chEaLgcNum * sizeof(UINT16));
			wEaInfoIndex += 6u;	/* 建立状态、中轴线、防护区域类型 */
			wEaLen += 6u;
			wEaInfoIndex += 4u;	/* 周期号*/
			wEaLen += 4u;
		}

		chEaNum = dataBuf[wEaInfoIndex];	/* 读取相邻控区反馈的区间疏散信息数量 */
		wEaLen++;
		wEaInfoIndex++;
		for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++)
		{
			wEaInfoIndex += 3u;	/* 疏散列车ID、允许状态 */
			wEaLen += 3u;
			wEaInfoIndex += 4u;	/* 周期号*/
			wEaLen += 4u;
		}
	}

	/*校验命令长度*/
	if (CI_SUCCESS == reVal)
	{
		cmdNumIndex = CICI_BEGIN_TO_STATION_LEN + stationLen + wEaLen;
		if (totalLength < cmdNumIndex + 2U)
		{
			reVal = CI_ERROR;
			*errNo = 20U;
		}
		else
		{
			cmdNum = ShortFromChar(&dataBuf[cmdNumIndex]);
			reVal = CI_SUCCESS;
		}
	}

	/*校验动态进路命令长度*/
	if (CI_SUCCESS == reVal)
	{
		wDrCmdLenIndex = cmdNumIndex + 2U + cmdNum * CICI_ONE_CMD_LEN;
		if (totalLength < (wDrCmdLenIndex + 2U))
		{
			reVal = CI_ERROR;
			*errNo = 21U;
		}
		else
		{
			wDrCmdNum = ShortFromChar(&dataBuf[wDrCmdLenIndex]);
			wDrCmdLenIndex += 2U;  /*命令数量*/
			for (wDrCmdIndex = 0U; wDrCmdIndex < wDrCmdNum; wDrCmdIndex++)
			{
				wDrCmdLenIndex++;  /*命令类型*/
				wDrCmdLenIndex++;  /*方向*/
				cDrLogSecNum = dataBuf[wDrCmdLenIndex];  /*逻辑区段数量*/
				wDrCmdLenIndex++;
				wDrCmdLenIndex += (UINT16)(cDrLogSecNum * sizeof(UINT16));  /*逻辑区段ID*/
				wDrCmdLenIndex += 2U;  /*列车ID*/
				cDrTrainLocLogSecNum = dataBuf[wDrCmdLenIndex];  /*列车脚下逻辑区段数量*/
				wDrCmdLenIndex++;
				wDrCmdLenIndex += (UINT16)(cDrTrainLocLogSecNum * sizeof(UINT16));  /*列车脚下逻辑区段ID*/
				wDrCmdLenIndex++;  /*道岔可动标志*/
				wDrCmdLenIndex += 2U;  /*始端信号机ID*/
			}
			reVal = CI_SUCCESS;
		}
	}

	/*校验总长度*/
	if (CI_SUCCESS == reVal)
	{
		if (totalLength == wDrCmdLenIndex + 40U)
		{
			reVal = CI_SUCCESS;
		}
		else
		{
			reVal = CI_ERROR;
			*errNo = 22U;
		}
	}

	return reVal;
}


/*
* 功能描述： 解析CI单帧数据
* 参数说明： void    
* 返回值  ： 0:解析失败
*			 1:解析成功
* @note 内部优化 20220419 wqm
1、编码规范：函数dsuCheckSameLoc返回值需要变量承接
2、增加返回值判断
*/
UINT8 ParseCiToCiDataFrame(UINT8* dataBuf, UINT16 dataLength)
{
	UINT16 sourceId = 0u;		/*源ID*/
	UINT16 targetId = 0u;		/*目标ID*/
	UINT16 MaskTotalLen = 0u;	/*码位总长度*/
	UINT16 deviceSum = 0u;		/*设备数量*/
	UINT16 deviceId = 0u;		/*设备ID*/
	UINT16 pLockBlongRouteId = 0u;	/*防护锁闭所属进路ID*/
	UINT16 rLockBlongRouteId = 0u;	/*进路锁闭所属进路ID*/
	UINT8 deviceInfo = 0u;		/*设备相关信息*/
	UINT16 commandTotalLen = 0u; /*命令总长度*/
	UINT16 commandID = 0u;		/*单帧命令编号*/
	UINT16 commandParam1 = 0u;	/*单帧命令参数1*/
	UINT16 commandParam2 = 0u;	/*单帧命令参数2*/
	UINT16 ii = 0u;/*游标*/
	UINT16 jj = 0u;/*游标*/
	UINT8 localCiId = 0u;		/*本联锁ID*/
	UINT8 floodBelongCiId = 0u;/*防淹门所属联锁ID*/
	UINT8 devSum = 0u; /*设备总数*/
	UINT8* deviceIdBuf = NULL; /*设备ID数组*/
	UINT8 deviceFlag = 0u;
	UINT8 yy = 0u;
	UINT8 kk = 0u;
	UINT8 execRet = CI_ERROR;
	UINT8 reVal = CI_ERROR;
	UINT8 chErrorType = 0U;
	UINT16 routePhySecSum = 0u;
	RoutePhysicalSectionStruct* routePSSecStru = NULL;
	UINT16 preSecId = 0u;
	RouteNearPhySectionStruct* routeNearPSSecStru = NULL;
	UINT16 routeId = 0u;
	/*物理区段CT或UT占用状态，设置为(UT)占用状态*/
	UINT8 curUtOrCtOccFlag = LOGICSECTION_OCCUPY_UT;	 /*当前CT或UT占用标志*/
	UINT8 chPreUtOrCtOccFlag = LOGICSECTION_OCCUPY_UT;

	UINT16 bufIndex = 0u;  /*数组下标*/
	UINT32 sourceCurCycleNo = 0u;/*当前消息的源周期号*/

	UINT16 utOverlapUnlockCount = 0u;/*UT保护区段解锁倒计时周期数*/
	UINT16 ctOverlapUnlockCount = 0u;/*CT保护区段解锁倒计时周期数*/

	UINT16 overlapBelongRouteId = 0u;/*保护区段所属进路ID (动态字段)*/ 
	UINT8 overlapUnlockApplyFlag = 0u; /*向ZC申请解锁保护区段解锁标志*/ 
	UINT32 unlockStartCycNum = 0u;/*保护区段解锁起始周期号 (动态字段)*/ 
	UINT32 xuanPaiStartCycNum = 0u;/*保护区段选排开始周期号(动态字段)*/
	UINT8 autoRouteSetFlag = 0u;	   /*自动进路设置标志未(设置/设置)*/

	UINT16 ciciVer = 0u;/*ci-ci接口版本号*/

	UINT8 ciTransmitRecvDataCycResult = 0u;
	UINT8 belongCiId =0u;
	UINT16 belongRouteId = 0u;
	UINT8 cRouteCiId = 0u;
	UINT8 phySecPreOccupyState = 0u;
	UINT8 phySecCurOccupyState = 0u;
	UINT8 phySecCurMergeState = 0u;
	UINT8 phySecPreMergeState = 0u;
	UINT8 phySecLockState = 0u;
	UINT8 chCurPhySecUseState = 0u;
	UINT8 phySecArbState = 0u;
	UINT8 logLockState = 0u;
	UINT8 localLogLockState = 0u;
	UINT16 lockBelongRoute = 0u;
	UINT16 pLockBelongRoute = 0u;
	UINT8 lockDir = 0u;
	UINT8 chLogSecTrainInfoSum = 0u;
	UINT8 chLogicTrainIndex = 0u;
	PhysicalSectionDataStruct* tmpPhysicalSectionDataStru = GetPhySecData();
	SignalDataStruct * tmpSignalDataStru = GetSignalData();
	SwitchDataStruct * tmpSwitchDataStru = GetSwitchData();
	LogicSectionDataStruct * tmpLogicSectionDataStru = GetLogicSecData();
	PsdDataStruct * tmpPsdDataStru = GetPsdData();
	SpksDataStruct * tmpSpksDataStru = GetSpksData();
	EsbDataStruct * tmpEsbDataStru = GetEsbData();
	RelayDataStruct * tmpRelayDataStru = GetRelayData();  
	UINT16 szTrainId[LOGIC_SECTION_RES_SUM_MAX] = {0u};
	UINT8 cFlashTrainInfoFlag = 0u;/* 是否刷新列车信息 */
	UINT16 dwTmpIndex = 0u;
	CfpTrainInfoStru tmpTrainInfo = { 0u };
	CfpEnvelopeStruct tmpOtherEnvelope[OTHER_RC_SEND_ENVELOPE_SUM_MAX] = {0u};	/* 接收到的其他联锁的包络信息 */
	UINT8 chEnvelopeNum = 0u;
	UINT8 chEnvelopeIndex = 0u;
	UINT8 chTrainIndex = 0u;
	UINT8 chAcIndex = 0u;
	UINT16 wTiocId = 0u; 
	UINT16 wLinkTioc = 0u;
	UINT8 chLgcResShrFlag = 0U;
	UINT8 chCtNum = 0u;
	UINT8 chCtIndex = 0u;
	UINT16 wLinkId = 0u;
	UINT32 dwOffset = 0u;
	UINT16 wTrainId = 0u;
	UINT8 chLevel = 0u;
	UINT32 dwTrainDelay = 0u;
	UINT16 wSpeed = 0u;
	UINT8 chSpeedDir = 0u;
	UINT8 chTiocIndex = 0u;
	UINT8 chTrainDir = 0u;
	UINT8 chEaNum = 0u;
	UINT8 chEaIndex = 0u;
	UINT8 chLgcIndex = 0u;
	EaDataStru strEaTmp = { 0u };
	UINT16 overlapUnlockTime = 0u;
	UINT32 dwDataVerFromOtherCi = 0U;
	UINT32 dwDataVerFromEmap = 0U;
	UINT16 wCiDevName = 0U;/*用于接受带联锁设备类型的联锁ID*/
	UINT8 chLgcSecResTrainSum = 0U;
	UINT16 wPhyErrlockTime = 0U;/*物理区段区故解倒计时*/
	UINT8 cTempTrainNum = 0U;
	UINT8 cLogSecLogicLockState = LOG_SECTION_LOCK_NO;  /*逻辑区段逻辑锁闭状态*/
	UINT8 cLogSecLogicLockDir = CI_SYSTEM_DIRECTION_NONE;  /*逻辑区段逻辑锁闭方向*/
	UINT8 cCiRecvAreaSnowNum = 0U;  /*相邻联锁发送的区间雨雪数量*/
	UINT16 wAreaId = 0U;  /*相邻联锁发送的区间ID*/
	UINT8 cAreaSnowLevel = 0U;  /*区间湿轨级别*/
	UINT8 cCmdRecvFlag = 0U;
	ToCiCommandDataStruct strTempCiRecvCmd = { 0U };
	ToCiDrCmdDataStruct strTempCiRecvDrCmd = { 0U };
	UINT32 dwCurCycNum = 0U;
	UINT8 cRrmSrcRcId = 0U;/* RRM源RC ID */
	UINT16 wRrmTrainId = 0U;/* RRM列车ID */
	UINT16 wRrmTrainNextStaId = 0U;/* RRM列车申请的下一站台ID */
	UINT8 chRrmSrcApplyState = 0U;/* 跨控区远程RM时，源TIOC申请状态 */
	UINT8 chRrmDstAllowState = 0U;/* 跨控区远程RM时，目标TIOC允许状态 */
	UINT8 switchIsThisLineFlag = 0U;		/*道岔是否为本线路*/
	UINT32 dwEaBuildCyc = 0U;  /*相邻联锁发送的列车疏散请求建立周期号*/
	UINT16 cCiRecvLeavelogNum = 0U;  /*相邻联锁发送的离去逻辑区段数量*/
	UINT16 leaveLogSecId = 0U; /*相邻联锁发送的离去逻辑区段ID*/
	UINT8 leaveCheckFlag = LOGSEC_LEAVE_LOGSEC_REPLY_NO; /*相邻联锁发送的离去逻辑区段检查标志*/
	UINT16 wCfpRelAdjaRcSignalId = 0U;  /*分界点关联相邻RC的信号机*/
	UINT8 cCfpSignalLightUpFlag = SIGNAL_SLEEP_TRAIN_LIGHTUP_YES;  /*分界点信号机亮灯标志*/
	UINT32 dwSecUtOrCtOccuCyc = 0U;
	UINT8 chCurAblFlag = 0U; /*当前ABL标志*/
	UINT8 chPreAblFlag = 0U; /*之前ABL标志*/
	UINT8 cPhySecInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO;
	UINT16 wUsingBelongOverlapId = 0U;  /*道岔征用所属保护区段ID*/
	UINT8 cSwitchCurUsingState = 0U;  /*道岔当前征用状态*/
	UINT8 cSwitchTempUsingState = 0U;  /*道岔待设置征用状态*/
	UINT8 cOverlapBelongCiId = 0U;
	UINT8 cProSwtCheckStartFlag = 0U;  /*保护区段防护道岔检查开始标志*/
	UINT8 cProSwtCheckResultFlag = 0U;  /*保护区段防护道岔检查结果标志*/
	UINT8 cPLockRouteNum = 0U;  /*防护道岔防护锁闭所属进路数量*/
	UINT16 szPLockRouteId[SWITCH_MAX_PROTECT_LOCKED_NUM] = { 0U };
	UINT8 cPLockOverlapNum = 0U;  /*防护道岔防护锁闭所属保护区段数量*/
	UINT16 szPLockOverlapId[SWITCH_MAX_PROTECT_LOCKED_NUM] = { 0U };
	UINT8 chRouteState = 0U;/*进路状态*/
	UINT8 chRouteStateFlag = 0U;/*进路追踪办理标志*/
	UINT8 chPhySecBelCiId = 0U;/*物理区段所属联锁ID*/
	UINT8 chRecvPhySecUseState = 0U; /*接收的物理区段征用状态*/
	UINT16 wPhySecUseRouteId = 0U;/*物理区段征用所属进路ID*/
	UINT16 wProSwSecUseRouteId = 0U;/*防护道岔物理区段征用所属进路ID*/
	UINT8 cPhySecOccState = 0U;
	UINT8 cLogLockBelLogRouteSum = 0U;
	UINT8 cCiRecvAreaIteCutNum = 0U;  /*相邻联锁发送的区间ITE切除数量*/

	localCiId = GetSystemParaLocalCiId();
	dwCurCycNum = Get2oo2CurCycleNum();

	if ((dataBuf != NULL) && (dataLength > 0u))
	{
		reVal = CI_SUCCESS;
	}
	else
	{
		reVal = CI_ERROR;
	}
	

	if (CI_SUCCESS == reVal)
	{
		sourceId = ShortFromChar(&dataBuf[ii]);			/*获取数据包来源设备ID*/
		ii += 2u;
		sourceCurCycleNo = LongFromChar(&dataBuf[ii]);	/*获取数据包来源的周期号*/
		ii +=4u;
		targetId = ShortFromChar(&dataBuf[ii]);			/*获取数据包目标设备ID*/
		ii += 2u;

		ciciVer = ShortFromChar(&dataBuf[ii]);/*版本号，2个字节*/
		ii += 2u;

		if ((UINT16)CICI_VERSION == ciciVer)
		{
			reVal = CI_SUCCESS;
		}
		else
		{
			debug_infor_printf((const)"CICI_VERSION ERROR,local:%d other:%d\n",CICI_VERSION,ciciVer);
			reVal = CI_ERROR;
		}
		if (CI_SUCCESS == reVal)
		{
			dwDataVerFromOtherCi = LongFromChar(&dataBuf[ii]);	/*相邻联锁公用数据校验信息*/
			ii += 4U;
			wCiDevName = (CI_SYSTEM_TYPE_CI) * 256U + sourceId;
			dwDataVerFromEmap = GetCiTranCiDataCheckVer(localCiId, wCiDevName); /*获取联锁系统数据版本号*/
			if (dwDataVerFromOtherCi != dwDataVerFromEmap)
			{
				reVal = CI_ERROR;
				SetCiSendCmdBackInfoData(CI_BACK_DATA_VER_CHECK_FAIL, CI_SYSTEM_TYPE_CI, sourceId, 0U, 0U);
			}
		}


		if (CI_SUCCESS == reVal)
		{
			MaskTotalLen = ShortFromChar(&dataBuf[ii]);		/*获取站场信息总长度*/
			ii += 2u;

			if (localCiId != targetId)
			{
				/*目标联锁非本联锁返回*/
				reVal = CI_ERROR;
			}
			else
			{
				reVal = CI_SUCCESS;
			}
		}
		
	}

	if (CI_SUCCESS == reVal)
	{
		/*判断来源设备是否是指定CI*/
		devSum = GetCiTransmitSpecifySysDevSum(Get2oo2SheBeiType()); /*获取通信联锁设备总数*/
		deviceIdBuf = GetCiTransmitSpecifySysDevBuf(Get2oo2SheBeiType()); /*获取通信联锁设备ID数组*/
		
		if ((0u < devSum) && (NULL != deviceIdBuf))
		{
			for (yy = 0u; yy < devSum; yy++)
			{
				if (deviceIdBuf[yy] == sourceId)
				{
					deviceFlag = 1u;
					break;
				}
			}
			reVal = CI_SUCCESS;
		}
		else
		{
			reVal = CI_ERROR;
		}
		
		if (CI_SUCCESS == reVal)
		{
			if (0u == deviceFlag)
			{
				reVal = CI_ERROR;
			}
			else
			{
				reVal = CI_SUCCESS;
			}
		}
		
	}
	if (CI_SUCCESS == reVal)
	{
		/*解析处理道岔数据*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*获取道岔数量*/
		ii += 2u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*获取道岔ID*/
			ii += 2u;
			belongCiId = GetSwitchBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				ii += CICI_ONE_SWITCH_LEN - 2u;/*跳过属于本联锁的道岔状态信息，继续解析*/
			}
			else
			{
				bufIndex = GetSwitchConfigBufIndex(deviceId);
				tmpSwitchDataStru[bufIndex].SwitchId = deviceId;

				/*道岔引导总锁状态*/
				SetSwitchYLockState(deviceId, dataBuf[ii++]);
				/*道岔锁闭状态*/
				SetOtherCiSwitchLockStatus(deviceId, dataBuf[ii++]);
				/*道岔封锁状态*/
				SetSwitchFLockState(deviceId, dataBuf[ii++]);
				/*道岔当前位置*/
				SetSwitchCurPosition(deviceId, dataBuf[ii++]);
				/*单独道岔当前位置*/
				SetSingleSwitchCurPosition(deviceId, dataBuf[ii++]);

				switchIsThisLineFlag = GetSwitchIsThisLineState(deviceId);
				if (DEV_IS_THIS_LINE_NO == switchIsThisLineFlag)
				{
					SetConnetSwitchDsState(deviceId, dataBuf[ii++]);				/*设置联络线道岔单锁状态*/
					SetConnetSwitchByPassState(deviceId, dataBuf[ii++]);			/*设置联络线道岔旁路状态,考虑进路其他联锁条件检查道岔时，未判道岔所属联锁，不传道岔旁路状态会影响信号开放*/		
				}
				else
				{
					ii += 2U;					/*不是联络线道岔，跳过此两字节*/
				}

				/*设置道岔挤岔状态*/
				SetSwitchJichaState(deviceId, dataBuf[ii++]);

				/*设置征用的保护区段ID*/
				wUsingBelongOverlapId = ShortFromChar(&dataBuf[ii]);  /*道岔征用所属保护区段*/
				ii += 2U;
				cSwitchTempUsingState = dataBuf[ii];  /*道岔征用状态*/
				ii++;

				/*根据当前征用状态更新道岔的征用状态*/
				cSwitchCurUsingState = GetSwitchUsingState(deviceId);
				cOverlapBelongCiId = GetOverlapBelongCiId(wUsingBelongOverlapId);
				if (cOverlapBelongCiId == localCiId)
				{
					/*征用保护区段为本控区*/
					if ((SWITCH_USING_YES == cSwitchTempUsingState) && (SWITCH_USING_APPLY == cSwitchCurUsingState))
					{
						/*对方发来征用，且本方当前为申请征用，更新征用状态*/
						SetSwitchUsingState(deviceId, SWITCH_USING_YES, wUsingBelongOverlapId);  /*设置道岔被该保护区段征用*/
					}
					else if ((SWITCH_USING_YES == cSwitchTempUsingState) && (SWITCH_USING_NO == cSwitchCurUsingState))
					{
						AddCiSendToCiCmdInfo(CI_CMD_OLP_PROSWT_USE_CANCEL, deviceId, wUsingBelongOverlapId, belongCiId);  /*向道岔控区发取消征用命令*/
						/*解决场景：保护区段控区重启后，初始化防护道岔未征用，但防护道岔控区还会发来征用，此时通过命令清除征用*/
					}
					else
					{
						/*不更新*/
					}
				}
				else
				{
					/*征用保护区段非本控区或ID为0*/
					if (SWITCH_USING_NO == cSwitchTempUsingState)
					{
						if (SWITCH_USING_APPLY == cSwitchCurUsingState)
						{
							/*维持当前申请征用状态，解决场景：保护区段控区刚开始申请征用，由于通信异步，防护道岔控区还会发来未征用，此时保护区段控区需要维持申请征用状态*/
						}
						else
						{
							SetSwitchUsingState(deviceId, SWITCH_USING_NO, wUsingBelongOverlapId);  /*清除征用所属保护区段*/
						}
					}
					else
					{
						if (0U < wUsingBelongOverlapId)
						{
							SetSwitchUsingState(deviceId, cSwitchTempUsingState, wUsingBelongOverlapId);  /*更新征用状态*/
						}
						else
						{
							/*不更新*/
						}
					}
				}
			}
		}
	}

	if (CI_SUCCESS == reVal)
	{
		/*解析处理物理区段数据*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*获取物理区段数量*/
		ii += 2u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*获取物理区段ID*/
			ii += 2U;
			chPhySecBelCiId = GetPhySecBelongCiId(deviceId);
			if (chPhySecBelCiId == localCiId)
			{
				ii += CICI_ONE_PHYSEC_LEN - 2U;/*跳过属于本联锁的物理区段状态信息，继续解析*/
			}
			else
			{
				bufIndex = GetPhySecConfigBufIndex(deviceId);  /*获取区段数组下标*/

				tmpPhysicalSectionDataStru[bufIndex].PhysicalSectionId = deviceId;  /*物理区段当前融合状态*/

				cPhySecOccState = dataBuf[ii];
				ii++;
				SetPhySecCurOccupyState(deviceId, cPhySecOccState);  /*物理区段采集占用状态*/

				/*物理区段融合后状态*/
				SetPhySecCurMergeState(deviceId, dataBuf[ii++]);

				/*获取物理区段当前CT或UT占用状态*/
				curUtOrCtOccFlag = dataBuf[ii++];

				/*物理区段停稳信息*/
				SetPhySecStopSteadyFlag(deviceId, dataBuf[ii++]);

				chRecvPhySecUseState = dataBuf[ii++];
				wPhySecUseRouteId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				wProSwSecUseRouteId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;

				/*物理区段征用状态设置*/
				belongCiId = GetRouteBelongCiId(wPhySecUseRouteId);
				chCurPhySecUseState = GetPhySecUseState(deviceId);
				if (belongCiId == localCiId)
				{ 
					/*区段征用进路属于本联锁控制*/		
					if ((PHYSICAL_SECTION_USING_YES == chRecvPhySecUseState) && (PHYSICAL_SECTION_USING_APPLY == chCurPhySecUseState))
					{ /*仅当对方发送征用且当前是申请征用才更新*/

						SetPhySecUseState(deviceId, chRecvPhySecUseState, wPhySecUseRouteId);
					}
					else if ((PHYSICAL_SECTION_USING_YES == chRecvPhySecUseState) && (PHYSICAL_SECTION_USING_NO == chCurPhySecUseState))
					{ /*对方发送征用且本机未征用*/
						/*发送征用取消*/
						AddCiSendToCiCmdInfo((UINT8)CI_CMD_PHYSEC_USING_CANCEL, deviceId, wPhySecUseRouteId, chPhySecBelCiId);
						/*2024.12.06内部优化，解决场景：进路控区重启后，初始化物理区段未征用，但物理区段控区还会发来征用，此时通过命令清除征用*/
					}
					else
					{
						/*不更新*/
					}
				}
				else
				{
					/*区段征用进路不属于本联锁控制或者进路ID为0*/
					if (PHYSICAL_SECTION_USING_NO == chRecvPhySecUseState)
					{
						/*未征用*/
						if (PHYSICAL_SECTION_USING_APPLY == chCurPhySecUseState)
						{
							;
						}
						else
						{
							SetPhySecUseState(deviceId, chRecvPhySecUseState, wPhySecUseRouteId);
						}
					}
					else
					{
						/*征用*/
						if (0U < wPhySecUseRouteId)
						{
							SetPhySecUseState(deviceId, chRecvPhySecUseState, wPhySecUseRouteId);
						}
						else
						{
							;
						}
					}
				}

				/*防护道岔物理区段征用状态设置*/
				belongCiId = GetRouteBelongCiId(wProSwSecUseRouteId);
				chCurPhySecUseState = GetPhySecUseState(deviceId);
				if (belongCiId == localCiId)
				{
					/*区段征用进路属于本联锁控制*/
					if ((PHYSICAL_SECTION_USING_YES == chRecvPhySecUseState) && (PHYSICAL_SECTION_USING_APPLY == chCurPhySecUseState))
					{ /*仅当对方发送征用且当前是申请征用才更新*/

						SetPhySecProtectUseState(deviceId, chRecvPhySecUseState, wProSwSecUseRouteId);
					}
					else if ((PHYSICAL_SECTION_USING_YES == chRecvPhySecUseState) && (PHYSICAL_SECTION_USING_NO == chCurPhySecUseState))
					{ /*对方发送征用且本机未征用*/
						/*发送征用取消*/
						AddCiSendToCiCmdInfo((UINT8)CI_CMD_PROSW_SEC_USING_CANCEL, deviceId, wProSwSecUseRouteId, chPhySecBelCiId);
					}
					else
					{
						;  /*不更新*/
					}
				}
				else
				{
					/*区段征用进路不属于本联锁控制或者进路ID为0*/
					if (PHYSICAL_SECTION_USING_NO == chRecvPhySecUseState)
					{
						/*未征用*/
						if (PHYSICAL_SECTION_USING_APPLY == chCurPhySecUseState)
						{
							;
						}
						else
						{
							SetPhySecProtectUseState(deviceId, chRecvPhySecUseState, wProSwSecUseRouteId);
						}
					}
					else
					{
						/*征用*/
						if (0U < wProSwSecUseRouteId)
						{
							SetPhySecProtectUseState(deviceId, chRecvPhySecUseState, wProSwSecUseRouteId);
						}
						else
						{
							;
						}
					}
				}
					

				/*物理区段封锁状态*/
				(void)SetPhySecFLockState(deviceId, dataBuf[ii++]);
				/*物理区段Arb状态*/
				phySecArbState = dataBuf[ii++];
				SetPhySecArbState(deviceId,phySecArbState);
				/*根据物理区段Arb状态设置关联计轴区段arb*/
				SetPhyContainAxisSecArbState(deviceId,phySecArbState);
				/*物理区段与占用状态*/
				SetPhySecCurAndMergeState(deviceId,dataBuf[ii++]);
				/*物理区段跳跃锁闭状态*/
				SetPhySecJumpLockState(deviceId,dataBuf[ii++]);
				/*物理区段封锁类型*/
				SetPhySecFLockType(deviceId, dataBuf[ii++]);
				/*物理区段预复位状态*/
				SetPhySecPreResetState(deviceId, dataBuf[ii++]);			
				/*by cgh 20230706 相邻联锁显示区故解倒计时*/
				wPhyErrlockTime = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				SetPhyErrUnlockTime(deviceId, wPhyErrlockTime);
				/*物理区段区域紧急制动状态*/
				SetPhySecAreaUrgentState(deviceId, dataBuf[ii++]);

				/*16.0更新：物理区段ABL占用标志设置*/
				chCurAblFlag = dataBuf[ii++];
				SetPhySecABLTrainFlag(deviceId, chCurAblFlag);
				/*处理物理区段占用状态和倒计时变化*/
				phySecCurMergeState = GetPhySecCurMergeState(deviceId);
				if (SECTION_OCCUPY_YES == phySecCurMergeState)
				{
					chPreUtOrCtOccFlag = GetPhySecPreOccState(deviceId);				/*获取物理区段之前CT或UT占用状态*/
					dwSecUtOrCtOccuCyc = GetSecUtOrCtOccuStartCycNum(deviceId);
					/*倒计时过程中，物理区段车占用状态发生变化，并且解锁已开始倒计时或之前空闲时*/
					if ((chPreUtOrCtOccFlag != curUtOrCtOccFlag) && (0u != dwSecUtOrCtOccuCyc))
					{						
						if (LOGICSECTION_OCCUPY_NO != curUtOrCtOccFlag)
						{
							/*重新设置物理区段UT或CT占用开始时间*/
							SetSecUtOrCtOccuStartCycNum(deviceId, dwCurCycNum);
						}
						else
						{
							/*逻辑区段均空闲，物理区段尚未融合空闲，暂不更新*/
						}
					}
					else if  (LOGICSECTION_OCCUPY_UT == curUtOrCtOccFlag)
					{
						/*UT占压 ABL级别跳变 重新设置物理区段UT或CT占用开始时间*/
						chPreAblFlag = GetPhySecPreABLTrainFlag(deviceId);
						if (chCurAblFlag != chPreAblFlag)
						{
							SetSecUtOrCtOccuStartCycNum(deviceId, dwCurCycNum);
						}
					}
					else
					{
						/*解锁保护区段过程中，进路最后一个物理区段车占用未发生变化，正常倒计时*/
					}

					/*将物理区段上周期占用状态设置为之前占用状态*/
					SetPhySecPreOccState(deviceId, curUtOrCtOccFlag);
				}
				if (SECTION_OCCUPY_NO == phySecCurMergeState)
				{
					/*取消物理区段UT或CT占用开始时间*/
					SetSecUtOrCtOccuStartCycNum(deviceId, 0u);
					SetPhySecPreOccState(deviceId, LOGICSECTION_OCCUPY_NO);
				}

				/*物理区段坏车占用标志设置*/
				SetPhySecUTTrainFlag(deviceId, dataBuf[ii++]);

				cPhySecInHumidRailFlag = dataBuf[ii++];
				SetPhySecInHumidRailFlag(deviceId, cPhySecInHumidRailFlag);  /*设置相邻控区物理区段的湿轨标志*/
			}
		}
	}
	if (CI_SUCCESS == reVal)
	{
		/*解析处理逻辑区段数据*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*获取逻辑区段数量*/
		ii += 2u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*获取逻辑区段ID*/
			ii += 2u;

			belongCiId = GetLogSecBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				ii += 5U;  /*跳过属于本联锁的逻辑区段状态信息*/
				chLgcSecResTrainSum = dataBuf[ii++];  /*获取逻辑区段资源列车数量*/
				ii += chLgcSecResTrainSum * 3U;  /*跳过本联锁逻辑区段的资源列车信息*/
			}
			else
			{

				bufIndex = GetlogSectionBufIndex(deviceId);
				tmpLogicSectionDataStru[bufIndex].LogicSectionId = deviceId;
				/*逻辑区段占用状态*/
				SetLogSecPreOccupyState(deviceId, GetLogSecCurCtOrUtOccupyState(deviceId));/*保存逻辑区段之前占用状态*/
				SetLogSecCurOccupyState(deviceId, dataBuf[ii++]);
				SetLogSecXSSttOtherTioc(deviceId, dataBuf[ii++]);
				/** 逻辑区段跳跃锁闭状态 */
				SetLogSecJumpLockState(deviceId, dataBuf[ii++]);
				/* 逻辑区段ARB状态 */
				SetLgcArbState(deviceId, dataBuf[ii++]);
				/* 逻辑区段SPKS封锁状态 */
				SetLogSecSpksFLockState(deviceId, dataBuf[ii++]);
				/*逻辑区段防护锁闭资源可用状态*/
				SetLogSecProResUseState(deviceId, dataBuf[ii++]);
				/*逻辑区段ABL资源可用标志*/
				SetLogSecAblUseFlag(deviceId, dataBuf[ii++]);
				/*设置相邻联锁临时限速速度值*/
				SetLogSecXiansuSpeed(deviceId, dataBuf[ii++]);

				chLgcSecResTrainSum = dataBuf[ii++];
				for (kk = 0U; kk < chLgcSecResTrainSum; kk++)
				{
					wTrainId = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					SetLogSecTrainUseState(deviceId,wTrainId,dataBuf[ii++]);
				}
			}
			
		}
	}
		
	if (CI_SUCCESS == reVal)
	{
		/*解析处理信号机数据*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*获取信号机数量*/
		ii += 2u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*获取信号机ID*/
			ii += 2u;
			belongCiId = GetSignalBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				ii += CICI_ONE_SIGNAL_LEN -2u;/*跳过属于本联锁的信号机状态信息，继续解析*/
			}
			else
			{
				bufIndex = GetSignalConfigBufIndex(deviceId);
				tmpSignalDataStru[bufIndex].SignalId = deviceId;

				/*设置信号机封锁状态*/
				SetSignalFLockState(deviceId, dataBuf[ii++]);
				/*设置信号机亮灭状态*/
				(void)SetNearCISigLightExtinctState(deviceId, dataBuf[ii++]);
				/*设置信号机当前显示颜色*/
				(void)SetNearCISignalCurColor(deviceId, dataBuf[ii++]);
				/*设置信号机临时限速*/
				SetSignalLinShiXianSuSetFlag(deviceId, dataBuf[ii++]);
				/*设置信号机扣车*/
				SetSignalDetainState(deviceId, dataBuf[ii++]);
				/*设置信号机硬线扣车状态*/
				SetSignalRelayDetainFlag(deviceId, dataBuf[ii++]);
				/*设置信号机维修点灯状态*/
				SetSignalMaintainState(deviceId, dataBuf[ii++]);
				/*设置信号机对应断丝标志*/
				SetNearCISignalCurDsFlag(deviceId, dataBuf[ii++]);
				/*设置信号机扣车旁路按钮状态*/
				SetDetCutBtnState(deviceId, dataBuf[ii]);
				ii++;
			}
		}
	}
		
	if (CI_SUCCESS == reVal)
	{
		/*解析处理屏蔽门数据*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*获取屏蔽门数量*/
		ii += 2u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*获取屏蔽门ID*/
			ii += 2u;
			belongCiId = GetPsdBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				ii += CICI_ONE_PSD_LEN -2u;/*跳过属于本联锁的PSD状态信息，继续解析*/
			}
			else
			{
				bufIndex = GetPsdConfigBufIndex(deviceId);
				tmpPsdDataStru[bufIndex].PsdId = deviceId;

				(void)SetPsdState(deviceId, dataBuf[ii++]);             /*屏蔽门开关状态状态*/
				(void)SetPsdMutualLockRemoveState(deviceId,dataBuf[ii++]);    /*屏蔽门互锁解除状态状态*/

				deviceInfo = dataBuf[ii];  /*解析PSD异常打开状态*/
				ii++;
				SetPsdExceptOpenState(deviceId, deviceInfo);
			}
		}
	}
		
	if (CI_SUCCESS == reVal)
	{
		/*解析处理紧急停车按钮数据*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*获取紧急停车数量*/
		ii += 2u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*获取紧急停车ID*/
			ii += 2u;
			belongCiId = GetEsbBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				ii += CICI_ONE_ESB_LEN -2u;/*跳过属于本联锁的ESB状态信息，继续解析*/
			}
			else
			{
				bufIndex = GetEsbConfigBufIndex(deviceId);
				tmpEsbDataStru[bufIndex].EsbId = deviceId;

				/*紧急停车按钮状态*/
				(void)SetEsbState(deviceId, dataBuf[ii++]);

				/*紧急停车旁路按钮状态*/
				SetEsbCutState(deviceId, dataBuf[ii++]);
			}
		}
	}
		
	if (CI_SUCCESS == reVal)
	{
		/*解析处理进路数据*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*获取进路数量*/
		ii += 2u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*获取进路ID*/
			ii += 2u;
			belongCiId = GetRouteBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				ii += CICI_ONE_ROUTE_LEN -2u;/*跳过属于本联锁的进路状态信息，继续解析*/
			}
			else
			{
				/*进路状态*/
				(void)SetRouteState(deviceId, dataBuf[ii++]);

				/*进路监督级别*/
				SetRouteLevel(deviceId, dataBuf[ii++]);

				/* 2B:UT保护区段解锁倒计时周期数*/
				utOverlapUnlockCount = ShortFromChar(&dataBuf[ii]);
				ii+=2u;

				if (0u < utOverlapUnlockCount)
				{
					SetOtherCIRouteOvlpUTUnlockCnt(deviceId,utOverlapUnlockCount);
				}

				/* 2B:CT保护区段解锁倒计时周期数*/
				ctOverlapUnlockCount = ShortFromChar(&dataBuf[ii]);
				ii+=2u;

				if (0u < ctOverlapUnlockCount)
				{
					SetOtherCIRouteOverlapCTUnlockCount(deviceId,ctOverlapUnlockCount);
				}

				/*自动信号取消状态*/
				SetAutoSigCancleState(deviceId,dataBuf[ii++]);
				SetRouteOverlapNeedCIlockFlag(deviceId, dataBuf[ii++]);

				SetRouteStateFlag(deviceId, dataBuf[ii++]);/*进路追踪办理标志*/

				SetRouteAutoTriggerFlag(deviceId, dataBuf[ii++]);/*进路自动触发标志*/
			}
		}
	}

	if (CI_SUCCESS == reVal)
	{
		/*解析处理本联锁中由其他联锁管理的物理区段锁闭状态*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*获取特殊物理区段数量*/
		ii += 2u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*获取物理区段ID*/
			ii += 2u;
			/*物理区段锁闭状态*/
			deviceInfo = dataBuf[ii++];

			/*物理区段防护锁闭所属进路ID*/
			pLockBlongRouteId = ShortFromChar(&dataBuf[ii]);
			ii += 2u;

			/*物理区段锁闭所属进路ID*/
			rLockBlongRouteId = ShortFromChar(&dataBuf[ii]);
			ii += 2u;

			/*处理区段锁闭状态*/
			belongCiId = GetPhySecBelongCiId(deviceId);
			if (belongCiId != localCiId)
			{/*非本联锁物理区段*/

				if (PHYSICAL_SECTION_LOCK_PROTECT == deviceInfo)
				{/*物理区段只有防护锁闭*/

					/*清除进路锁闭，设置为PHYSICAL_SECTION_LOCK_NO，清除PhysicalSectionDataStru[bufIndex].RLockBelongRouteId*/
					(void)SetPhySecLockStateOtherCI(deviceId, PHYSICAL_SECTION_LOCK_NO, 0u, 0u);

					/*进路为本联锁*/
					belongCiId = GetRouteBelongCiId(pLockBlongRouteId);
					if (belongCiId == localCiId)
					{
						/*设置进路被防护锁闭*/
						SetRouteOverlapLockedId(pLockBlongRouteId,ShortFromChar(&dataBuf[ii]));
					}
				}
				else if (PHYSICAL_SECTION_LOCK_NO == deviceInfo)
				{ /*未锁闭*/

					belongRouteId = GetPhySecPLockBelongRouteId(deviceId);
					belongCiId = GetRouteBelongCiId(belongRouteId);
					if ((0u < belongRouteId) &&(belongCiId == localCiId))
					{
						/*清除进路锁闭保护区段Id*/
						SetRouteOverlapLockedId(GetPhySecPLockBelongRouteId(deviceId), 0);
						/*清除申请解锁保护区段标志*/
						SetOverlapUnlockApplyFlag(ShortFromChar(&dataBuf[ii]),UNLOCK_OVERLAP_APPLY_NO);
					}
				}
				else
				{

					if(pLockBlongRouteId > 0u)
					{/*物理区段同时存在防护锁闭和普通锁闭*/
						belongCiId = GetRouteBelongCiId(pLockBlongRouteId);
						if(belongCiId == localCiId)
						{/*物理区段防护锁闭所属进路属于本联锁*/
							SetRouteOverlapLockedId(pLockBlongRouteId,ShortFromChar(&dataBuf[ii]));
						}

						/*设置区段防护锁闭*/
						(void)SetPhySecLockStateOtherCI(deviceId,PHYSICAL_SECTION_LOCK_PROTECT,pLockBlongRouteId,dataBuf[ii+3U]);
					}
					else
					{
						belongRouteId = GetPhySecPLockBelongRouteId(deviceId);
						if (0u < belongRouteId)
						{
							belongCiId = GetRouteBelongCiId(belongRouteId);
							if(belongCiId == localCiId)
							{
								/*清除进路锁闭保护区段Id*/
								SetRouteOverlapLockedId(GetPhySecPLockBelongRouteId(deviceId), 0);
								/*清除申请解锁保护区段标志*/
								SetOverlapUnlockApplyFlag(ShortFromChar(&dataBuf[ii]),UNLOCK_OVERLAP_APPLY_NO);
							}

							(void) ClearPhySecPLock(deviceId);
						}					

					}
				}

				ii += 2u;/*区段所属防护区段ID跳过*/
				if(PHYSICAL_SECTION_LOCK_PROTECT == deviceInfo)
				{
					(void)SetPhySecLockStateOtherCI(deviceId, deviceInfo, pLockBlongRouteId, dataBuf[ii++]);/*设置物理区段锁闭状态，dataBuf[ii++]为锁闭方向*/
				}
				else
				{
					(void)SetPhySecLockStateOtherCI(deviceId, deviceInfo, rLockBlongRouteId, dataBuf[ii++]);/*设置物理区段锁闭状态，dataBuf[ii++]为锁闭方向*/
				}
				
				/* 区段变占用计时 */
				phySecPreOccupyState = GetPhySecPreOccupyState(deviceId);
				phySecCurOccupyState = GetPhySecCurOccupyState(deviceId);
				phySecPreMergeState = GetPhySecPreMergeState(deviceId);
				phySecCurMergeState = GetPhySecCurMergeState(deviceId);
				if ((SECTION_OCCUPY_NO == phySecPreOccupyState) && (SECTION_OCCUPY_YES == phySecCurOccupyState))
				{
					/*空闲变占用*/

					/*该区段的上一区段与该区段同时占用时设置占用开始时间*/
					routeId = GetPhySecRLockBelongRouteId(deviceId);
					if (routeId > 0u)
					{/*物理区段进路锁闭*/

						routePhySecSum = GetRoutePhysicalSectionSum(routeId);
						routePSSecStru = GetRouteSectionData(routeId);
						preSecId = 0u;
						for (kk = 0u; kk < routePhySecSum; kk++)
						{
							if (routePSSecStru[kk].PhysicalSectionId == deviceId)
							{/*找到进路中的该物理区段*/

								if (kk > 0u)
								{/*非第一个物理区段*/

									preSecId = routePSSecStru[kk - 1U].PhysicalSectionId;                            
								}
								else
								{
									routeNearPSSecStru = GetRouteBlocNearPhySectionStru(routeId);
									if (routeNearPSSecStru != NULL)
									{
										preSecId = routeNearPSSecStru[0].NearPhySecIdBuf[0];
									}
									else
									{
										preSecId = 0u;
									}

								}
								phySecCurMergeState = GetPhySecCurMergeState(preSecId);
								if ((0u != preSecId) &&(SECTION_OCCUPY_YES == phySecCurMergeState))
								{/*上一物理区段同时占用*/

									/*设置占用开始时间*/
									SetSecCurOccupyStartCycNum(deviceId, Get2oo2CurCycleNum());

									/*设置物理区段UT或CT占用开始时间*/
									SetSecUtOrCtOccuStartCycNum(deviceId, Get2oo2CurCycleNum());
								}

								break;
							}
						}

					}            
					else
					{
						/* 如果没有锁闭进路，则不认为列车顺序占用,所以清空 */
						SetSecCurOccupyStartCycNum(deviceId, 0u);
						/*取消物理区段UT或CT占用开始时间*/
						SetSecUtOrCtOccuStartCycNum(deviceId, 0u);
					}
				}
				else if ((SECTION_OCCUPY_YES == phySecPreMergeState) && (SECTION_OCCUPY_NO == phySecCurMergeState))
				{
					/*占用变空闲*/

					/*取消占用开始时间*/
					SetSecCurOccupyStartCycNum(deviceId, 0u);
					/*取消物理区段UT或CT占用开始时间*/
					SetSecUtOrCtOccuStartCycNum(deviceId, 0u);
				}
				else
				{
					/*继续计时*/
				}

				continue;
			}
			else
			{
				ii += 2u;/*区段所属防护区段ID跳过*/
				SetPhySecOtherCiPLockRouteId(deviceId, pLockBlongRouteId);  /*设置本控区逻辑区段由其它CI发送的防护锁闭所属进路ID*/
			}

			/*根据物理区段现在所处状态处理发来的物理区段状态信息*/
			switch (deviceInfo)
			{
			case PHYSICAL_SECTION_LOCK_START:
				/*当前上电锁闭*/

				/*不动作*/

				break;
			case PHYSICAL_SECTION_LOCK_NO:
				/*当前未锁闭*/
				phySecLockState = GetPhySecLockState(deviceId);
				if (PHYSICAL_SECTION_LOCK_NO != phySecLockState)
				{
					(void)SetPhySecLockStateOtherCI(deviceId, deviceInfo, rLockBlongRouteId, dataBuf[ii]);/*设置物理区段锁闭状态dataBuf[ii++]为锁闭方向*/
				}

				break;

			default:
				/*其他锁闭状态*/
				if(PHYSICAL_SECTION_LOCK_PROTECT == deviceInfo)
				{
					(void)SetPhySecLockStateOtherCI(deviceId, deviceInfo, pLockBlongRouteId, dataBuf[ii]);/*设置物理区段锁闭状态dataBuf[ii++]为锁闭方向*/
				}
				else
				{
					(void)SetPhySecLockStateOtherCI(deviceId, deviceInfo, rLockBlongRouteId, dataBuf[ii]);/*设置物理区段锁闭状态dataBuf[ii++]为锁闭方向*/
				}
				break;

			}
			ii++;

		}
	}
		

	if (CI_SUCCESS == reVal)
	{
		/* 解析SPKS */
		deviceSum = ShortFromChar(&dataBuf[ii]);/*发送SPKS总数*/
		ii += 2u;
		for (jj = 0u;jj < deviceSum;jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);
			ii += 2u;
			belongCiId = GetSpksBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				ii += CICI_ONE_SPKS_LEN -2u;/*跳过属于本联锁的SPKS状态信息，继续解析*/
			}
			else
			{
				bufIndex = GetSpksConfigBufIndex(deviceId);
				tmpSpksDataStru[bufIndex].spksId = deviceId;

				deviceInfo = dataBuf[ii++];
				(void)SetSpksState(deviceId, deviceInfo);

				deviceInfo = dataBuf[ii++];
				SetSpksCutState(deviceId, deviceInfo);
			}
		}
	}
		
	if (CI_SUCCESS == reVal)
	{
		/* 解析虚拟继电器 */
		deviceSum = ShortFromChar(&dataBuf[ii]);/*虚拟继电器总数*/
		ii += 2u;
		for (jj = 0u;jj < deviceSum;jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);
			ii += 2u;
			belongCiId = GetRelayBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				ii += CICI_ONE_VIRTUAL_RELAY_LEN - 2u;/*跳过属于本联锁的虚拟继电器的状态信息，继续解析*/
			}
			else
			{
				bufIndex = GetRelayConfigBufIndex(deviceId);
				tmpRelayDataStru[bufIndex].RelayId = deviceId;

				deviceInfo = dataBuf[ii++];
				SetRelayCollState(deviceId, deviceInfo);/*设置虚拟继电器采集状态*/
			}
		}
	}
	
	if (CI_SUCCESS == reVal)
	{
		/* 解析防淹门 */
		deviceSum = ShortFromChar(&dataBuf[ii]);/*防淹门总数*/
		ii += 2u;
		for (jj = 0u;jj < deviceSum;jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);
			ii += 2u;
			floodBelongCiId = GetFloodGateBelongCiId(deviceId);
			if (floodBelongCiId == localCiId)
			{
				ii += CICI_ONE_FLOODGATE_LEN - 2u;/*跳过属于本联锁的防淹门的状态信息，继续解析*/
			}
			else
			{
				bufIndex = GetFloodGateBufIndex(deviceId);
				execRet = SetFloodGateCurOpenLockState(bufIndex,dataBuf[ii++]);/*开启锁闭*/
				if (CI_ERROR == execRet)
				{
					debug_infor_printf((const)"SetFloodGateCurOpenLockState %d error.",bufIndex);
				}
				execRet = SetFloodGateCurCloseRequestSta(bufIndex,dataBuf[ii++]);/*关门请求*/
				if (CI_ERROR == execRet)
				{
					debug_infor_printf((const)"SetFloodGateCurCloseRequestState %d error.",bufIndex);
				}
				execRet = SetFloodGateCurZCAgrCloseAck(bufIndex,dataBuf[ii++]);/*收zc同意关闭*/
				if (CI_ERROR == execRet)
				{
					debug_infor_printf((const)"SetFloodGateCurAgreeCloseAckFromZC %d error.",bufIndex);
				}
				execRet = SetFloodGateCurAgreeCloseSta(bufIndex,dataBuf[ii++]);/*当前采集同意关闭*/
				if (CI_ERROR == execRet)
				{
					debug_infor_printf((const)"SetFloodGateCurAgreeCloseCollState %d error.",bufIndex);
				}
				execRet = SetFloodGateCurAgreeCloseOutSta(bufIndex,dataBuf[ii++]);/*输出同意关闭*/
				if (CI_ERROR == execRet)
				{
					debug_infor_printf((const)"SetFloodGateCurAgreeCloseOutState %d error.",bufIndex);
				}
			}
		}
	}

	if (CI_SUCCESS == reVal)
	{
		/*解析处理保护区段数据*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*获取保护区段数量*/
		ii += 2u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*获取保护区段ID*/
			ii += 2u;
			belongCiId = GetOverlapBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				ii += CICI_ONE_OVERLAP_LEN -2u;/*跳过属于本联锁的保护区段状态信息，继续解析*/
			}
			else
			{
				/*保护区段所属进路ID*/
				overlapBelongRouteId = ShortFromChar(&dataBuf[ii]);
				ii += 2u;
				
				SetOverlapBelongRouteId(deviceId,overlapBelongRouteId);

				/* 4B:指定ID保护区段组解锁起始周期号*/
				unlockStartCycNum = LongFromChar(&dataBuf[ii]);
				ii += 4u;

				if (unlockStartCycNum > 0u)
				{
					(void)SetOverlapUnlockStartCycNum(deviceId,unlockStartCycNum);
				}

				/* 4B:指定ID保护区段选排开始周期号*/
				xuanPaiStartCycNum = LongFromChar(&dataBuf[ii]);
				ii += 4u;

				if (xuanPaiStartCycNum > 0u)
				{
					SetOverlapXuanPaiStartCycNum(deviceId,xuanPaiStartCycNum);
				}

				/*设置指定ID保护区段向ZC申请解锁保护区段标志*/
				overlapUnlockApplyFlag = dataBuf[ii++];
				if (overlapUnlockApplyFlag > 0u)
				{
					SetOverlapUnlockApplyFlag(deviceId,overlapUnlockApplyFlag);
				}
				/*保护区段解锁倒计时*/
				overlapUnlockTime = ShortFromChar(&dataBuf[ii]);
				ii += 2U;

				SetOverlapUnlockTime(deviceId,overlapUnlockTime);

				/*保护区段防护道岔检查开始标志*/
				cProSwtCheckStartFlag = dataBuf[ii];
				ii++;
				SetOverlapProSwtCheckStartFlag(deviceId, cProSwtCheckStartFlag);

				if (PROSWITCH_CHECK_START_VALID != cProSwtCheckStartFlag)
				{
					SetOverlapProSwtCheckResultFlag(deviceId, PROSWITCH_CHECK_RESULT_DEFAULT);  /*保护区段锁闭结束，清除防护道岔检查结果标志为默认值*/
				}
				else
				{
					/*不在接口中更新防护道岔检查结果标志*/
				}
			}
		}
	}

	if (CI_SUCCESS == reVal)
	{
		/*cgh-合并CID-2539-7：处理自动通过进路*/
		deviceSum = ShortFromChar(&dataBuf[ii]);   /*获取自动通过进路数量*/
		ii += 2u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);	/*获取自动通过进路ID*/
			ii += 2u;
			belongCiId = GetAutoRouteBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				ii += CICI_ONE_AUTOROUTE_LEN - 2u;/*跳过属于本联锁的自动通过进路信息，继续解析*/
			}
			else
			{
				autoRouteSetFlag = dataBuf[ii++];
				/*设置自动通过进路建立状态*/
				SetAutoRouteSetFlag(deviceId, autoRouteSetFlag);
			}
		}
	}

	if (CI_SUCCESS == reVal)
	{
		/*解析处理本联锁中由其他联锁管理的逻辑区段锁闭状态*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*获取特殊逻辑区段数量*/
		ii += 2U;
		for (jj = 0; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*获取逻辑区段ID*/
			ii += 2U;
			/*锁闭状态*/
			logLockState = dataBuf[ii++];
			/*锁闭所属进路*/
			lockBelongRoute = ShortFromChar(&dataBuf[ii]);
			ii += 2U;
			/*保护锁闭所属进路*/
			pLockBelongRoute = ShortFromChar(&dataBuf[ii]);
			ii += 2U;
			/*锁闭方向*/
			lockDir = dataBuf[ii++];
			/*逻辑区段逻辑锁闭状态*/
			cLogSecLogicLockState = dataBuf[ii++];
			/*逻辑区段逻辑锁闭方向*/
			cLogSecLogicLockDir = dataBuf[ii++];
			/*逻辑区段逻辑锁闭所属逻辑进路数量*/
			cLogLockBelLogRouteSum = dataBuf[ii++];
			chLgcResShrFlag = dataBuf[ii++];
			/* 获取逻辑区段所属TIOC */
			belongCiId = GetLogSecBelongCiId(deviceId);
			belongRouteId = GetLogSecLockBelongRoute(deviceId);
			cRouteCiId = GetRouteBelongCiId(belongRouteId);
			cFlashTrainInfoFlag = 0u;

			if ((belongCiId != localCiId) || ((cRouteCiId != localCiId)&&(0U != cRouteCiId)))
			{/*非本逻辑区段或锁闭进路非本TIOC*/

				/* 根据锁闭状态判断是否同步列车 */
				if ((LOG_SECTION_LOCK_NORMAL == logLockState) || (LOG_SECTION_LOCK_DELAY == logLockState) || (LOG_SECTION_LOCK_PROTECT == logLockState)
					|| (LOG_SECTION_LOGLOCK_NORMAL == cLogSecLogicLockState))
				{
					/* 仅对方发来正常锁闭或延时解锁或防护锁闭或逻辑正常锁闭更新 */
					cFlashTrainInfoFlag = 1u;
				}
			}

			/*设置状态*/

			if (belongCiId != localCiId)
			{/*非本逻辑区段*/

				switch (logLockState)
				{
				case LOG_SECTION_LOCK_PROTECT:
					/*保护区段只有防护锁闭*/
					SetLogSecLockStateOtherCI(deviceId, logLockState, pLockBelongRoute, lockDir);/*设置逻辑区段锁闭状态*/
					break;
				case LOG_SECTION_LOCK_NO:
					/*未锁闭*/
					SetLogSecLockStateOtherCI(deviceId, logLockState, lockBelongRoute, lockDir);/*设置逻辑区段锁闭状态*/
					/*YF0083-1235,修复缺陷，当对方传输的锁闭状态为未锁闭时，接收到清除保护区段的状态，清除锁闭所属的进路ID*/
					ClearLogicSecPLock(deviceId);
					break;
				default:

					if (pLockBelongRoute > 0u)
					{
						/*设置区段防护锁闭*/
						SetLogSecLockStateOtherCI(deviceId, LOG_SECTION_LOCK_PROTECT, pLockBelongRoute, lockDir);
					}
					else
					{
						/*修复缺陷，当对方传输过来锁闭所属防护进路ID等于0时，需要清楚防护锁闭进路ID,此时对方可能是延时锁闭或故障锁闭*/
						ClearLogicSecPLock(deviceId);
					}
					SetLogSecLockStateOtherCI(deviceId, logLockState, lockBelongRoute, lockDir);/*设置逻辑区段锁闭状态*/
					break;
				}

				SetLogSecLogLockStateOtherCi(deviceId, cLogSecLogicLockState, cLogSecLogicLockDir, cLogLockBelLogRouteSum);  /*更新非本控区逻辑区段的逻辑锁闭状态，用于复视区域显示*/
			}
			else
			{
				/*根据逻辑区段现在所处状态处理发来的逻辑区段态信息，本联锁逻辑区段的逻辑锁闭状态由本联锁独立管理，不再接收相邻联锁的逻辑锁闭状态*/
				switch (logLockState)
				{
				case LOG_SECTION_LOCK_START:
					/*当前上电锁闭*/
					/*不动作*/
					break;
				case LOG_SECTION_LOCK_NO:
					/*当前未锁闭*/
					localLogLockState = GetLogSecLockState(deviceId);
					if (LOG_SECTION_LOCK_NO != localLogLockState)
					{
						SetLogSecLockStateOtherCI(deviceId, logLockState, lockBelongRoute, lockDir);/*设置逻辑区段锁闭状态*/
					}

					break;
				case LOG_SECTION_LOCK_PROTECT:
					/* 防护锁闭 */
					SetLogSecLockStateOtherCI(deviceId, logLockState, pLockBelongRoute, lockDir);
					break;
				default:
					/*其他锁闭状态*/
					SetLogSecLockStateOtherCI(deviceId, logLockState, lockBelongRoute, lockDir);/*设置逻辑区段锁闭状态*/
					break;

				}

				SetLogSecOtherCiPLockRouteId(deviceId, pLockBelongRoute);  /*设置本控区逻辑区段由其它CI发送的防护锁闭所属进路ID*/
			}

			/* 设置资源信息 */
			chLogSecTrainInfoSum = dataBuf[ii++];/*逻辑区段列车数量*/

			/*逻辑区段列车信息*/
			for (chLogicTrainIndex = 0u; chLogicTrainIndex < chLogSecTrainInfoSum; chLogicTrainIndex++)
			{

				szTrainId[chLogicTrainIndex] = ShortFromChar(&dataBuf[ii]);/*列车ID*/
				ii += 2u;
			}


			if (1u == cFlashTrainInfoFlag)
			{
				/* 同步列车信息s */
				SetLogSecResShareFlag(deviceId, chLgcResShrFlag);
				AddLogSecOtherTIOCTrainRes(deviceId, chLogSecTrainInfoSum, szTrainId);
			}
		}
	}

	if (CI_SUCCESS == reVal)
	{
		/*解析分界点信息*/
		deviceSum = ShortFromChar(&dataBuf[ii]);		/*分界点数量*/
		ii += 2u;
		chTiocIndex = GetTiocTransmitIndex((UINT8)sourceId);
		g_szTiocCt[chTiocIndex].chCtNum = 0u;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);		/*分界点ID*/
			ii += 2u;
			dwTmpIndex = GetCfpBufIndex(deviceId);


			if (CUTOFF_POINT_SUM_MAX <= dwTmpIndex)
			{
				ii += 7U;  /*跳过属于本联锁分界点列车信息*/
				chEnvelopeNum = dataBuf[ii++];  /*分界点包络数量*/
				for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++)
				{
					/*跳过本联锁分界点包络信息*/
					ii += 19U;
					cTempTrainNum = dataBuf[ii++];  /*包络包含的列车数量*/
					ii += cTempTrainNum * 2U;  /*跳过包络包含的列车ID*/
				}

				chCtNum = dataBuf[ii++];  /*分界点列车数量*/
				ii += cTempTrainNum * 35U;  /*跳过分界点列车信息*/
				ii += 7U;  /*跳过远程RRM信息*/
				ii += 2;  /*跳过待点亮的信号机ID*/
			}
			else
			{
				/*列车ID*/
				tmpTrainInfo.wTrainId = ShortFromChar(&dataBuf[ii]);
				ii += 2u;

				/*运行等级*/
				tmpTrainInfo.chTrainLevel =dataBuf[ii];
				ii++;
				if ((0u == tmpTrainInfo.chTrainLevel) || (TRAIN_LEVEL_BACKUP_UNKNOWN == tmpTrainInfo.chTrainLevel) || (TRAIN_LEVEL_UR == tmpTrainInfo.chTrainLevel)
					|| (TRAIN_LEVEL_ABL == tmpTrainInfo.chTrainLevel) || (TRAIN_LEVEL_VBTC == tmpTrainInfo.chTrainLevel) || (TRAIN_LEVEL_ITC == tmpTrainInfo.chTrainLevel))
				{
					;/*0：无车、UR、ABL、VBTC，ITC 0xff级别合法*/
				}
				else
				{
					reVal = CI_ERROR;
				}

				/*到分界点距离*/
				tmpTrainInfo.dwDis = LongFromChar(&dataBuf[ii]);
				ii += 4u;

				/* 写入分界点列车中 */
				SetCfpOtherOcTrainInfo(deviceId,tmpTrainInfo);

				/* 分界点收到相邻OC发来的包络数量 */
				chEnvelopeNum = dataBuf[ii++];
				if (OTHER_RC_SEND_ENVELOPE_SUM_MAX >= chEnvelopeNum)
				{
					for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++)
					{
						tmpOtherEnvelope[chEnvelopeIndex].envelopeType = dataBuf[ii++];	/* 包络类型 */
						if ((TYPE_UKT_ENVELOPE == tmpOtherEnvelope[chEnvelopeIndex].envelopeType)
							|| (TYPE_UCT_ENVELOPE == tmpOtherEnvelope[chEnvelopeIndex].envelopeType)
							|| (TYPE_CT_ENVELOPE == tmpOtherEnvelope[chEnvelopeIndex].envelopeType))
						{
							;/*1:通信车 2：丢失通信车 3：隐藏车*/
						}
						else
						{
							reVal = CI_ERROR;
						}

						tmpOtherEnvelope[chEnvelopeIndex].headTrainID = ShortFromChar(&dataBuf[ii]);/* 前车ID */
						ii += 2u;

						tmpOtherEnvelope[chEnvelopeIndex].tailTrainID = ShortFromChar(&dataBuf[ii]);/* 后车ID */
						ii += 2u;

						tmpOtherEnvelope[chEnvelopeIndex].startPos.Dir = dataBuf[ii++];/* 起点方向 */

						tmpOtherEnvelope[chEnvelopeIndex].startPos.Lnk = ShortFromChar(&dataBuf[ii]);/* 起点link */
						ii += 2u;

						tmpOtherEnvelope[chEnvelopeIndex].startPos.Off = LongFromChar(&dataBuf[ii]);/* 起点offset */
						ii += 4u;

						tmpOtherEnvelope[chEnvelopeIndex].endPos.Dir = dataBuf[ii++];/* 终点方向 */

						tmpOtherEnvelope[chEnvelopeIndex].endPos.Lnk = ShortFromChar(&dataBuf[ii]);/* 终点link */
						ii += 2u;

						tmpOtherEnvelope[chEnvelopeIndex].endPos.Off = LongFromChar(&dataBuf[ii]);/* 终点offset */
						ii += 4u;

						wLinkTioc = GetLinkManageTiocById(tmpOtherEnvelope[chEnvelopeIndex].startPos.Lnk);
						if (wLinkTioc == localCiId)
						{
							(void)dsuCheckSameLoc(tmpOtherEnvelope[chEnvelopeIndex].startPos.Lnk, tmpOtherEnvelope[chEnvelopeIndex].startPos.Off, &tmpOtherEnvelope[chEnvelopeIndex].startPos.Lnk, &tmpOtherEnvelope[chEnvelopeIndex].startPos.Off);
						}

						wLinkTioc = GetLinkManageTiocById(tmpOtherEnvelope[chEnvelopeIndex].endPos.Lnk);
						if (wLinkTioc == localCiId)
						{
							(void)dsuCheckSameLoc(tmpOtherEnvelope[chEnvelopeIndex].endPos.Lnk, tmpOtherEnvelope[chEnvelopeIndex].endPos.Off, &tmpOtherEnvelope[chEnvelopeIndex].endPos.Lnk, &tmpOtherEnvelope[chEnvelopeIndex].endPos.Off);
						}

						/*分界点相邻OC发来的包络截取转移至发送联锁处理*/

						tmpOtherEnvelope[chEnvelopeIndex].ACCnt = elm_PrepareACBtwPoints(tmpOtherEnvelope[chEnvelopeIndex].startPos, tmpOtherEnvelope[chEnvelopeIndex].endPos, tmpOtherEnvelope[chEnvelopeIndex].ACID);
						/* 内部优化 20220419 wqm elm_PrepareACBtwPoints返回0或者返回列车包络中包含的区段最大个数时，此处都应设置返回为CI_ERROR*/
						if ((SECTION_IN_ENVELOPE_SUM_MAX == tmpOtherEnvelope[chEnvelopeIndex].ACCnt) || (0u == tmpOtherEnvelope[chEnvelopeIndex].ACCnt))
						{
							reVal = CI_ERROR;
						}
						else
						{
							for (chAcIndex = 0u; chAcIndex < tmpOtherEnvelope[chEnvelopeIndex].ACCnt; chAcIndex++)
							{
								wTiocId = GetAxisBelongTioc(tmpOtherEnvelope[chEnvelopeIndex].ACID[chAcIndex]);
								if ((localCiId == wTiocId) || (0u == wTiocId))
								{
									reVal = CI_ERROR;
									break;
								}
								else
								{
									;
								}
							}
						}


						tmpOtherEnvelope[chEnvelopeIndex].trianCnt = dataBuf[ii++];/* 包含列车数量 */

						for (chTrainIndex = 0u; chTrainIndex < tmpOtherEnvelope[chEnvelopeIndex].trianCnt; chTrainIndex++)
						{
							tmpOtherEnvelope[chEnvelopeIndex].trainID[chTrainIndex] = ShortFromChar(&dataBuf[ii]);/* 列车ID */
							ii += 2u;

							tmpOtherEnvelope[chEnvelopeIndex].ACTPort[chTrainIndex] = dataBuf[ii++];  /* 列车激活端——UCT跨分界点RRM用 */
						}

						if (CI_SUCCESS != reVal)
						{
							break;
						}
					}
					if (CI_SUCCESS == reVal)
					{
						/*全部解析通过 写入分界点接收到的包络数据 */
						SetCfpOtherOcENum(deviceId, chEnvelopeNum);
						for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++)
						{
							SetCfpOtherOcEData(deviceId, chEnvelopeIndex, tmpOtherEnvelope[chEnvelopeIndex]);
						}
						
					}
				}
				else
				{
					reVal = CI_ERROR;
				}

				
				if (CI_SUCCESS == reVal)
				{
					chCtNum = dataBuf[ii++];
					for (chCtIndex = 0u; chCtIndex < chCtNum; chCtIndex++)
					{
						wTrainId = ShortFromChar(&dataBuf[ii]);		/* 列车ID */
						ii += 2u;

						g_szTiocCt[chTiocIndex].szCtId[g_szTiocCt[chTiocIndex].chCtNum++] = wTrainId;

						SetTrainMsgFromTiocId(wTrainId, (UINT8)sourceId);

						(void)SetTrainTransmitStat(wTrainId, TRAIN_COMM_STATE_GOOD);

						chLevel = dataBuf[ii++];
						(void)SetTrainLevel(wTrainId, chLevel);			/* 列车运行级别 */

						dwTrainDelay = LongFromChar(&dataBuf[ii]);	/* TIOC与列车通信延时 */
						ii += 4u;
						(void)SetTrainMsgDelayTime(wTrainId, dwTrainDelay);

						wSpeed = ShortFromChar(&dataBuf[ii]);
						ii += 2u;
						(void)SetTrainSpeed(wTrainId, wSpeed);			/* 列车速度 */

						chSpeedDir = dataBuf[ii++];
						(void)SetTrainSpeedDir(wTrainId, chSpeedDir);		/* 速度方向 */

						chTrainDir = dataBuf[ii++];
						(void)SetTrainDir(wTrainId, chTrainDir);			/* 列车运行方向 */

						wLinkId = ShortFromChar(&dataBuf[ii]);		/* 列车最大安全前link */
						ii += 2u;
						(void)SetTrainMaxHeadLink(wTrainId, wLinkId);

						dwOffset = LongFromChar(&dataBuf[ii]);		/* 列车最大安全前Offset */
						ii += 4u;
						(void)SetTrainMaxHeadOffset(wTrainId, dwOffset);

						wLinkId = ShortFromChar(&dataBuf[ii]);		/* 列车最小安全前link */
						ii += 2u;
						(void)SetTrainMinHeadLink(wTrainId, wLinkId);

						dwOffset = LongFromChar(&dataBuf[ii]);		/* 列车最小安全前Offset */
						ii += 4u;
						(void)SetTrainMinHeadOffset(wTrainId, dwOffset);

						wLinkId = ShortFromChar(&dataBuf[ii]);		/* 列车最大安全后link */
						ii += 2u;
						(void)SetTrainMaxTailLink(wTrainId, wLinkId);

						dwOffset = LongFromChar(&dataBuf[ii]);		/* 列车最大安全后Offset */
						ii += 4u;
						(void)SetTrainMaxTailOffset(wTrainId, dwOffset);

						wLinkId = ShortFromChar(&dataBuf[ii]);		/* 列车最小安全后link */
						ii += 2u;
						(void)SetTrainMinTailLink(wTrainId, wLinkId);

						dwOffset = LongFromChar(&dataBuf[ii]);		/* 列车最小安全后Offset */
						ii += 4u;
						(void)SetTrainMinTailOffset(wTrainId, dwOffset);

						/*设置列车最大安全后端、最小安全前端、最大安全前端的运行方向*/
						reVal = SetTrainOtherPointDir(wTrainId, chTrainDir);

					}

					/*分界点远程RM跨控区申请信息*/
					cRrmSrcRcId = dataBuf[ii++];  /*源RC ID*/
					wRrmTrainId = ShortFromChar(&dataBuf[ii]);						/* RRM列车ID */
					ii += 2U;
					wRrmTrainNextStaId = ShortFromChar(&dataBuf[ii]);				/* RRM列车申请的下一站台ID */
					ii += 2U;
					chRrmSrcApplyState = dataBuf[ii++];				/* 跨控区远程RM时，源TIOC申请状态 */
					chRrmDstAllowState = dataBuf[ii++];				/* 跨控区远程RM时，目标TIOC允许状态 */

					SetCfpRrmSrcRcId(deviceId, cRrmSrcRcId);
					SetCfpRrmTrainId(deviceId, wRrmTrainId);
					SetCfpRrmTrainNextStaId(deviceId, wRrmTrainNextStaId);
					if (cRrmSrcRcId != localCiId)
					{
						SetCfpRrmSrcApplyState(deviceId, chRrmSrcApplyState);
					}
					else
					{
						/*本控区为源RC，不设置*/
					}

					SetCfpRrmDstAllowState(deviceId, chRrmDstAllowState);

					wCfpRelAdjaRcSignalId = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					cCfpSignalLightUpFlag = dataBuf[ii];  /*分界点信号机亮灯标志*/
					ii++;

					belongCiId = GetSignalBelongCiId(wCfpRelAdjaRcSignalId);

					if ((0U != belongCiId) && (belongCiId == localCiId))
					{
						SetSleepTrainLightUpSignalFlag(wCfpRelAdjaRcSignalId, cCfpSignalLightUpFlag);  /*设置来自分界点的休眠车点亮信号机标志有效*/
					}
					else
					{
						/*非本控区信号机，不处理*/
					}
				}
				else
				{
					break;
				}
			}
		}
	}

	/*解析区间雨雪数据*/
	if (CI_SUCCESS == reVal)
	{
		cCiRecvAreaSnowNum = dataBuf[ii];
		ii++;
		if (CI_TO_CI_AREA_SNOW_SUM_MAX >= cCiRecvAreaSnowNum)
		{			
			ClearCiRecvAreaSnowInfo((UINT8)sourceId);  /*清除相邻联锁发送给本联锁的区间雨雪信息*/
			for (kk = 0U; kk < cCiRecvAreaSnowNum; kk++)
			{
				wAreaId = ShortFromChar(&dataBuf[ii]);  /*解析区间ID*/
				ii += 2U;
				cAreaSnowLevel = dataBuf[ii];  /*解析区间湿轨级别*/
				ii++;

				AddCiRecvAreaSnowInfo((UINT8)sourceId, localCiId, wAreaId, cAreaSnowLevel);  /*存储非本控区的区间雨雪信息*/
			}
		}
		else
		{
			reVal = CI_ERROR;
		}
	}
	else
	{
		/*不处理*/
	}

	/*解析区间ITE切除数据*/
	if (CI_SUCCESS == reVal)
	{
		cCiRecvAreaIteCutNum = dataBuf[ii];
		ii++;
		if (CI_TO_CI_AREA_SNOW_SUM_MAX >= cCiRecvAreaIteCutNum)
		{
			ClearCiRecvAreaIteCutInfo((UINT8)sourceId);  /*清除相邻联锁发送给本联锁的区间ITE切除信息*/
			for (kk = 0U; kk < cCiRecvAreaIteCutNum; kk++)
			{				
				wAreaId = ShortFromChar(&dataBuf[ii]);  /*解析区间ID*/
				ii += 2U;

				AddCiRecvAreaIteCutInfo((UINT8)sourceId, localCiId, wAreaId);  /*存储非本控区的区间ID*/
			}
		}
		else
		{
			reVal = CI_ERROR;
		}
	}
	else
	{
		/*不处理*/
	}

	/*解析离去区段数据*/
	if (CI_SUCCESS == reVal)
	{
		cCiRecvLeavelogNum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		if (CI_TO_CI_LEAVE_LOGSEC_ROUTE_NUM >= cCiRecvLeavelogNum)
		{
			for (kk = 0U; kk < cCiRecvLeavelogNum; kk++)
			{
				leaveLogSecId = ShortFromChar(&dataBuf[ii]);  /*解析离去逻辑区段ID*/
				ii += 2U;
				leaveCheckFlag = dataBuf[ii++];
				SetRouteLeaveLogSecFlag(leaveLogSecId, leaveCheckFlag);
			}
		}
		else
		{
			reVal = CI_ERROR;
		}
	}
	else
	{
		/*不处理*/
	}

	if (CI_SUCCESS == reVal)
	{
		/* 解析需要检查道岔状态的进路数据 */
		deviceSum = ShortFromChar(&dataBuf[ii]);/*需要检查道岔状态的进路总数*/
		ii += 2U;
		for (jj = 0u; jj < deviceSum; jj++)
		{
			routeId = ShortFromChar(&dataBuf[ii]);
			belongCiId = GetRouteBelongCiId(routeId);
			if (belongCiId == localCiId)
			{
				ii += 2U;
				chRouteState = GetRouteState(routeId);
				chRouteStateFlag = GetRouteStateFlag(routeId);

				if ((ROUTE_STATE_XUANPAI == chRouteState)
					|| (((ROUTE_STATE_AUTO_UNLOCK == chRouteState) || (ROUTE_STATE_AUTO_UNLOCKERR == chRouteState)) && (ROUTE_STATE_FLAG_YES == chRouteStateFlag))
					|| (ROUTE_STATE_LEAD_XUANPAI == chRouteState))
				{
					/*通信异步，只有进路所在联锁进路状态满足才根据相邻控区状态设置，防止本联锁已设置默认，相邻联锁异步传输了成功或者失败将默认误修改*/
					SetRouteApplySwitchCheckFlag(routeId, dataBuf[ii++]);
					deviceId = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					deviceFlag = dataBuf[ii++];/*类型*/
					deviceInfo = dataBuf[ii++];/*状态*/
					chErrorType = dataBuf[ii++];/*错误码*/
					SetRouteApplySwitchCheckErrorData(routeId, deviceId, deviceFlag, deviceInfo, chErrorType);
				}
				else
				{
					ii+=6U;
				}
				
			}
			else
			{
				ii += 8U;/*跳过不属于本联锁的进路，继续解析*/
			}
		}
	}

	if (CI_SUCCESS == reVal)
	{
		/*解析需要检查防护道岔状态的保护区段数据*/
		deviceSum = ShortFromChar(&dataBuf[ii]);  /*需要检查防护道岔状态的保护区段总数*/
		ii += 2U;
		for (jj = 0U; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);
			ii += 2U;
			
			belongCiId = GetOverlapBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				cProSwtCheckResultFlag = dataBuf[ii];
				ii++;
				cProSwtCheckStartFlag = GetOverlapProSwtCheckStartFlag(deviceId);  /*获取防护道岔检查开始标志*/
				if (PROSWITCH_CHECK_START_VALID == cProSwtCheckStartFlag)
				{
					SetOverlapProSwtCheckResultFlag(deviceId, cProSwtCheckResultFlag);
				}
				else
				{
					/*保护区段不在锁闭中，不更新防护道岔检查结果标志。
					（解决场景：保护区段已经锁闭成功/失败，防护道岔检查结果标志已置为0xFF，但由于通信异步，防护道岔控区还会发来0xAA/0x55，此时保护区段控区需要维持标志为0xFF）*/
				}
			}
			else
			{
				ii++;  /*跳过不属于本联锁的保护区段，继续解析*/
			}
		}
	}
	else
	{
		/*不处理*/
	}

	if (CI_SUCCESS == reVal)
	{
		/*解析被其它控区进路/保护区段防护锁闭的本控区道岔的防护锁闭信息*/
		deviceSum = ShortFromChar(&dataBuf[ii]);  /*防护道岔总数*/
		ii += 2U;
		for (jj = 0U; jj < deviceSum; jj++)
		{
			deviceId = ShortFromChar(&dataBuf[ii]);  /*道岔ID*/
			ii += 2U;

			cPLockRouteNum = dataBuf[ii];  /*防护锁闭的进路数量*/
			ii++;

			for (kk = 0U; kk < cPLockRouteNum; kk++)
			{
				szPLockRouteId[kk] = ShortFromChar(&dataBuf[ii]);  /*防护锁闭的进路ID*/
				ii += 2U;
			}

			cPLockOverlapNum = dataBuf[ii];  /*防护锁闭的进路数量*/
			ii++;

			for (kk = 0U; kk < cPLockOverlapNum; kk++)
			{
				szPLockOverlapId[kk] = ShortFromChar(&dataBuf[ii]);  /*防护锁闭的进路ID*/
				ii += 2U;
			}

			belongCiId = GetSwitchBelongCiId(deviceId);
			if (belongCiId == localCiId)
			{
				for (kk = 0U; kk < cPLockRouteNum; kk++)
				{
					SetSwitchLockStatus(SWITCH_PLOCKTYPE_ROUTE, szPLockRouteId[kk], deviceId, SWITCH_LOCK_PROTECT_SET);  /*设置进路防护锁闭*/
				}
				
				for (kk = 0U; kk < cPLockOverlapNum; kk++)
				{
					SetSwitchLockStatus(SWITCH_PLOCKTYPE_OVERLAP, szPLockOverlapId[kk], deviceId, SWITCH_LOCK_PROTECT_SET);  /*设置保护区段防护锁闭*/
				}
			}
			else
			{
				/*道岔不属于本控区，不处理*/
			}
		}
	}
	else
	{
		/*不处理*/
	}

	/*解析疏散数据*/
	if (CI_SUCCESS == reVal)
	{
		chTiocIndex = GetTiocTransmitIndex((UINT8)sourceId);
		g_szTiocCt[chTiocIndex].chEaTrainNum = 0u;
		chEaNum = dataBuf[ii];
		ii++;
		for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++)
		{/* 读取疏散列车ID */
			strEaTmp.wTrainId = ShortFromChar(&dataBuf[ii]);
			ii += 2u;

			/* 防护区域逻辑区段数量 */
			strEaTmp.strLgcInfo.chObjNum = dataBuf[ii];
			ii++;
			for (chLgcIndex = 0u; chLgcIndex < strEaTmp.strLgcInfo.chObjNum; chLgcIndex++)
			{/* 防护区域逻辑区段ID */
				strEaTmp.strLgcInfo.szObjId[chLgcIndex] = ShortFromChar(&dataBuf[ii]);
				ii += 2u;
			}

			/* 建立标识 */
			strEaTmp.chBuildedFlag = dataBuf[ii];
			ii++;

			/* 疏散列车中轴线 */
			strEaTmp.dwMidLine = LongFromChar(&dataBuf[ii]);
			ii += 4u;

			/* 类型 */
			strEaTmp.chPaType = dataBuf[ii];
			ii++;

			/* 疏散建立周期号 */
			strEaTmp.dwEaBuildCycNum = LongFromChar(&dataBuf[ii]);
			ii += 4u;

			/* 记录相邻控区发来的防护区域 */
			g_szTiocCt[chTiocIndex].szEaTrainId[g_szTiocCt[chTiocIndex].chEaTrainNum] = strEaTmp.wTrainId;
			g_szTiocCt[chTiocIndex].szPaType[g_szTiocCt[chTiocIndex].chEaTrainNum] = strEaTmp.chPaType;
			g_szTiocCt[chTiocIndex].dwEaBuildCyc[g_szTiocCt[chTiocIndex].chEaTrainNum++] = strEaTmp.dwEaBuildCycNum;

			strEaTmp.chSrcTiocId = (UINT8)(sourceId & 0x00ffu);
			strEaTmp.chDstTiocId = localCiId;

			EaNeighborUpdata(&strEaTmp);
		}

		chEaNum = dataBuf[ii];
		ii++;
		for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++)
		{/* 反馈的疏散列车ID */
			strEaTmp.wTrainId = ShortFromChar(&dataBuf[ii]);
			ii += 2u;
			/* 相邻控区允许状态 */
			strEaTmp.chDstAllowed = dataBuf[ii];
			ii++;

			/* 周期号 */
			dwEaBuildCyc = LongFromChar(&dataBuf[ii]);
			ii += 4u;
			strEaTmp.chSrcTiocId = localCiId;
			strEaTmp.chDstTiocId = (UINT8)(sourceId & 0x00ffu);

			EaSetNeighborAllowFlag(strEaTmp.wTrainId, strEaTmp.chSrcTiocId, strEaTmp.chDstTiocId, strEaTmp.chDstAllowed,dwEaBuildCyc);
		}
	}
	else
	{
		;
	}

	if (CI_SUCCESS == reVal)
	{
		/*解析命令信息*/
		commandTotalLen = ShortFromChar(&dataBuf[ii]);        /*获取数据包命令个数*/
		ii += 2u;

		if (commandTotalLen <= RECVCI_CMD_DATA_STRU_SUM_MAX)
		{
			for (jj = 0u; jj < commandTotalLen; jj++)
			{
				commandID = ShortFromChar(&dataBuf[ii]);        /*获取命令编号*/
				ii += 2u;
				commandParam1 = ShortFromChar(&dataBuf[ii]);/*获取命令参数1*/
				ii += 2u;
				commandParam2 = ShortFromChar(&dataBuf[ii]);/*获取命令参数2*/
				ii += 2u;

				strTempCiRecvCmd.SourceCiId = (UINT8)sourceId;
				strTempCiRecvCmd.TargetCiId = (UINT8)targetId;
				strTempCiRecvCmd.CommandID = commandID;
				strTempCiRecvCmd.Param1 = commandParam1;
				strTempCiRecvCmd.Param2 = commandParam2;
				strTempCiRecvCmd.CycleNo = dwCurCycNum;

				cCmdRecvFlag = CheckCiRecvCmdIsRepeat(&strTempCiRecvCmd);
				if (CI_SUCCESS == cCmdRecvFlag)
				{
					RecvCiCmdDataStru[RecvCiCmdDataStruCurSum] = strTempCiRecvCmd;
					RecvCiCmdDataStruCurSum++;
				}
				else
				{
					/*命令重复，不存储*/
				}
			}
		}
		else
		{
			/*命令越界*/
			reVal = CI_ERROR;
		}

	}

	if (CI_SUCCESS == reVal)
	{
		/*解析其它CI动态进路命令信息*/
		commandTotalLen = ShortFromChar(&dataBuf[ii]);	/*获取数据包命令个数*/
		ii += 2u;

		if (commandTotalLen <= RECVCI_CMD_DATA_STRU_SUM_MAX)
		{
			for (jj = 0u; jj < commandTotalLen; jj++)
			{
				strTempCiRecvDrCmd.cSourceCiId = (UINT8)sourceId;
				strTempCiRecvDrCmd.cTargetCiId = (UINT8)targetId;
				strTempCiRecvDrCmd.cCmdType = dataBuf[ii];  /*解析动态进路命令类型*/
				ii++;

				strTempCiRecvDrCmd.cLogSecSeqDir = dataBuf[ii];  /*解析动态进路逻辑区段序列方向*/
				ii++;

				strTempCiRecvDrCmd.cLogSecSum = dataBuf[ii];  /*解析动态进路逻辑区段数量*/
				ii++;

				for (kk = 0U; kk < strTempCiRecvDrCmd.cLogSecSum; kk++)
				{
					strTempCiRecvDrCmd.wLogSecIdBuff[kk] = ShortFromChar(&dataBuf[ii]);  /*解析动态进路逻辑区段ID*/
					ii += 2U;
				}

				strTempCiRecvDrCmd.wTrainId = ShortFromChar(&dataBuf[ii]);  /*解析动态进路列车ID*/
				ii += 2U;

				strTempCiRecvDrCmd.cTrainLocLogSecSum = dataBuf[ii];  /*解析动态进路列车脚下逻辑区段数量*/
				ii++;

				for (kk = 0U; kk < strTempCiRecvDrCmd.cTrainLocLogSecSum; kk++)
				{
					strTempCiRecvDrCmd.wTrainLocLogSecIdBuff[kk] = ShortFromChar(&dataBuf[ii]);  /*解析动态进路列车脚下逻辑区段ID*/
					ii += 2U;
				}

				strTempCiRecvDrCmd.cSwitchMoveFlag = dataBuf[ii];  /*解析半截进路道岔可动标志*/
				ii++;

				strTempCiRecvDrCmd.wRelStartSignalId = ShortFromChar(&dataBuf[ii]);  /*解析首个逻辑区段关联的始端信号机ID*/
				ii += 2U;
				strTempCiRecvDrCmd.CycleNo = dwCurCycNum;

				cCmdRecvFlag = CheckCiRecvDrCmdIsRepeat(&strTempCiRecvDrCmd);
				if (CI_SUCCESS == cCmdRecvFlag)
				{
					RecvCiDrCmdDataStru[RecvCiDrCmdSum] = strTempCiRecvDrCmd;
					RecvCiDrCmdSum++;
				}
				else
				{
					/*命令重复，不存储*/
				}
			}
		}
		else
		{
			/*命令数量越界*/
			reVal = CI_ERROR;
		}
	}
	else
	{
		/*不处理*/
	}

	if (CI_SUCCESS == reVal)
	{	/*设置相邻CI与本CI通信周期*/
		/*更新通信周期*/
		ciTransmitRecvDataCycResult = SetCiTransmitRecvDataCycNum(localCiId, Get2oo2SheBeiType(), (UINT8)sourceId, Get2oo2CurCycleNum());
		if (CI_ERROR == ciTransmitRecvDataCycResult)
		{
			/*更新周期失败*/
			reVal = CI_ERROR;
		}
		else
		{
			
		}
	}

	return reVal;
}

/*
* 功能描述： 组CI数据
* 参数说明： UINT8 targetDeviceId, 目标设备ID  
* 返回值  ： 0: 组包失败
*			 1: 组包成功           
*/
UINT8 PackCiToCiData(UINT8 targetDeviceId)
{
	UINT8 localCi = GetSystemParaLocalCiId(); /*获取本机联锁ID*/
    UINT16 cmdSum = 0u;/*命令个数*/
	UINT16 dstDevId = 0u;
	UINT8 outnetSafeSendRtn = 0u;
	UINT8 localCiType = 0u;
	UINT16 scState;
	UINT32 curCycleNo = Get2oo2CurCycleNum();/*获取当前周期号*/
	UINT8 ciFunctionSwitchConfig = 0u;
	UINT8 ciToCiDataBuffer[CI_TO_CI_DATA_LEN_MAX] = {0u};/*CI到CI组帧数组*/
	UINT16 infoSumIndex = 0u;	/*数据信息总长度游标位置*/
	UINT16 infoSum = 0u;		/*数据信息总长度*/
    UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT8 kk = 0U;
    UINT16 curIndex = 0u;
	UINT16 deviceId = 0u;	/*设备ID*/
	const CiTransmitStruct* pCiTramsStru = GetDstCiTransInfo(targetDeviceId);
	UINT16 otherCiPhySecIdSum = 0u;
	UINT16 wOtherCiSwitchIdSum = 0U;
	UINT8 chRtn = CI_ERROR;
	UINT16 OcDevName = 0U;
	UINT32 emapCheckVer = 0U;
	UINT16 wDevType = 0U;
	UINT8 cDevBelongCiId = 0U;
	UINT16 wUsingBelongOverlapId = 0U;  /*道岔征用所属保护区段ID*/
	UINT8 cSwitchUsingState = 0U;  /*道岔征用状态*/
	UINT8 chPhySecUseState = 0U; /*物理区段征用状态*/
	UINT16 wPhySecUseRouteId = 0U;/*物理区段征用所属进路ID*/
	UINT16 wProSwSecUseRouteId = 0U;/*防护道岔物理区段征用所属进路ID*/
	UINT8 chPhyUseRouteBelCiId = 0U;/*物理区段征用进路所属联锁ID*/
	UINT8 chProPhyUseRouteBelCiId = 0U;/*防护道岔区段征用进路所属联锁ID*/
	
	OcDevName = (CI_SYSTEM_TYPE_CI) * 256U + targetDeviceId;
	emapCheckVer = GetCiTranCiDataCheckVer(localCi, OcDevName);

	/*应用数据帧起始*/
	ShortToChar((UINT16)localCi, &ciToCiDataBuffer[ii]);	 /*CI ID*/
	ii += 2u;
	LongToChar(curCycleNo, &ciToCiDataBuffer[ii]);	 /*组当前本方周期号*/
	ii +=4u;
	ShortToChar((UINT16)targetDeviceId, &ciToCiDataBuffer[ii]);	 /*目的CI ID*/
	ii += 2u;	

	ShortToChar((UINT16)CICI_VERSION, &ciToCiDataBuffer[ii]);/*增加ci-ci接口版本号，每次修改接口需要升级版本号*/
	ii+=2u;

	LongToChar(emapCheckVer, &ciToCiDataBuffer[ii]);	 /*CI-CI公共数据校验*/
	ii += 4U;
		
	/***组数据帧信息***/
	infoSumIndex = ii;
	ii += 2u;/*跳过数据信息总长度*/

	PackCiToCiDataFrameUseCfg(targetDeviceId,&ciToCiDataBuffer[ii],&infoSum);

	ShortToChar(infoSum, &ciToCiDataBuffer[infoSumIndex]);/*填数据总长度*/
	ii = ii + infoSum;

	/* 相邻控区之间互传跨控区疏散防护区域 */
	infoSum = PackCiToCiDataFrameEa(targetDeviceId, &ciToCiDataBuffer[ii]);
	if (0u == infoSum)
	{
		;
	}
	else
	{
		chRtn = CI_SUCCESS;
	}
	ii += infoSum;
		
	/*非本联锁物理区段命令处理*/
	if(NULL != pCiTramsStru )
	{
		otherCiPhySecIdSum = pCiTramsStru->phySecIdBufSumhOfOtherCi;
		wOtherCiSwitchIdSum = pCiTramsStru->wSwitchSumOfOtherCi;
	}
	else
	{
		otherCiPhySecIdSum = 0u;
	}
	for (jj = 0u; jj < otherCiPhySecIdSum; jj++)
	{
		deviceId = pCiTramsStru->wPhySecIdBufOfOtherCi[jj];/*获取物理区段ID*/
		cDevBelongCiId = GetPhySecBelongCiId(deviceId);

		if (targetDeviceId == cDevBelongCiId)
		{/*非本联锁物理区段*/
			chPhySecUseState = GetPhySecUseState(deviceId);
			wPhySecUseRouteId = GetPhySecUseRouteId(deviceId);
			wProSwSecUseRouteId = GetPhySecProtectUseRouteId(deviceId);
			chPhyUseRouteBelCiId = GetRouteBelongCiId(wPhySecUseRouteId);
			chProPhyUseRouteBelCiId = GetRouteBelongCiId(wProSwSecUseRouteId);

			if (PHYSICAL_SECTION_USING_APPLY == chPhySecUseState)
			{
				/*处理进路内区段申请征用*/
				if ((0U < wPhySecUseRouteId) && (localCi == chPhyUseRouteBelCiId))
				{
					/*发送征用申请*/
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_PHYSEC_USING_APPLY, deviceId, wPhySecUseRouteId, cDevBelongCiId);
				}
				else
				{
					;
				}

				/*处理进路防护道岔区段申请征用*/
				if ((0U < wProSwSecUseRouteId) && (localCi == chProPhyUseRouteBelCiId))
				{
					/*发送征用申请*/
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_PROSW_SEC_USING_APPLY, deviceId, wProSwSecUseRouteId, cDevBelongCiId);
				}
				else
				{
					;
				}
			}
			else if (PHYSICAL_SECTION_USING_CANCEL == GetPhySecUseState(deviceId))
			{
				/*处理进路内区段申请取消征用*/
				if ((0U < wPhySecUseRouteId) && (localCi == chPhyUseRouteBelCiId))
				{
					/*发送征用申请*/
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_PHYSEC_USING_CANCEL, deviceId, wPhySecUseRouteId, cDevBelongCiId);
				}
				else
				{
					;
				}

				/*处理进路防护道岔区段申请征用*/
				if ((0U < wProSwSecUseRouteId) && (localCi == chProPhyUseRouteBelCiId))
				{
					/*发送征用申请*/
					AddCiSendToCiCmdInfo((UINT8)CI_CMD_PROSW_SEC_USING_CANCEL, deviceId, wProSwSecUseRouteId, cDevBelongCiId);
				}
				else
				{
					;
				}
			}
			else
			{
				; /*不发送*/
			}
		}
		else
		{
			; /*本联锁物理区段不处理*/
		}

	}

	/*组道岔申请征用/申请取消征用命令*/
	for (jj = 0U; jj < wOtherCiSwitchIdSum; jj++)
	{
		deviceId = pCiTramsStru->szSwitchIdBufOfOtherCi[jj];
		cDevBelongCiId = GetSwitchBelongCiId(deviceId);
		if (targetDeviceId == cDevBelongCiId)
		{
			wUsingBelongOverlapId = GetSwitchBelongOverlapId(deviceId);  /*获取道岔征用所属保护区段ID*/
			cSwitchUsingState = GetSwitchUsingState(deviceId);  /*获取道岔征用状态*/
			if (SWITCH_USING_APPLY == cSwitchUsingState)
			{
				AddCiSendToCiCmdInfo(CI_CMD_OLP_PROSWT_USE_APPLY, deviceId, wUsingBelongOverlapId, cDevBelongCiId);  /*向道岔控区发申请征用*/
			}
			else if (SWITCH_USING_CANCEL == cSwitchUsingState)
			{
				AddCiSendToCiCmdInfo(CI_CMD_OLP_PROSWT_USE_CANCEL, deviceId, wUsingBelongOverlapId, cDevBelongCiId);  /*向道岔控区发申请取消征用*/
			}
			else
			{
				/*不发送*/
			}
		}
		else
		{
			/*本控区道岔，不处理*/
		}
	}

	/*如果本联锁为车辆段或试车线，根据车辆段和试车线的接口方式，组相互间试车相关设备状态*/
	ciFunctionSwitchConfig = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);
	if ((SCX_CLD_INTERFACE_COMM == ciFunctionSwitchConfig)||(SCX_CLD_SERIAL_PORT_COMM == ciFunctionSwitchConfig))
	{/*试车线与车辆段接口类型为通信接口*/
		localCiType = GetLocalCiType();/*获取本联锁设备类型*/

		if(CI_TYPE_CLD==localCiType)
		{/*本联锁类型为车辆段*/
			if(CI_TYPE_SCX==GetCiType(targetDeviceId))/*目标联锁类型为试车线*/
			{
				scState = GetCommTrainTestCLDTYSJStatus();/*获取车辆段TYSJ状态*/
				AddCiSendToCiCmdInfo((UINT8)CI_CMD_TRAIN_TEST_ALLOW_STATUS, (UINT16)COMM_TRAIN_TEST_TYSJ_CLD, scState, targetDeviceId);/*给试车线发送试车允许设备的状态*/
			}
			else
			{
			}
		}
		
		else if (CI_TYPE_SCX==localCiType)
		{/*本联锁类型为试车线*/
			if (CI_TYPE_CLD==GetCiType(targetDeviceId))/*目标联锁类型为车辆段*/
			{
				scState = GetCommTrainTestSCXSQAJStatus();/*获取试车线SQAJ状态*/
				AddCiSendToCiCmdInfo((UINT8)CI_CMD_TRAIN_TEST_APPLY, (UINT16)COMM_TRAIN_TEST_SQAJ_SCX, (UINT16)(scState*256U+CI_TYPE_SCX), targetDeviceId);/*给车辆段发送试车请求设备的状态*/
			}
			else
			{
			}
		}
		else
		{
			/*什么都不做*/
		}
	}
	else
	{
	}

	if (1u> SendCiCmdDataStruCurSum)
	{ /*命令个数错误*/
			
		ShortToChar(cmdSum, &ciToCiDataBuffer[ii]);  /*命令帧个数*/
		ii += 2u;
	}
	else
	{
        curIndex = ii;/*命令个数跳过*/
		ii += 2u;
			
		for (jj = 0u; jj < SendCiCmdDataStruCurSum; jj++)
		{
            if ((SendCiCmdDataStru[jj].SourceCiId == localCi) && (SendCiCmdDataStru[jj].TargetCiId == targetDeviceId))
            {
                ShortToChar(SendCiCmdDataStru[jj].CommandID, &ciToCiDataBuffer[ii]);			/*命令编号*/
                ii += 2u;
                ShortToChar(SendCiCmdDataStru[jj].Param1, &ciToCiDataBuffer[ii]);			/*命令参数1*/
                ii += 2u;
                ShortToChar(SendCiCmdDataStru[jj].Param2, &ciToCiDataBuffer[ii]);			/*命令参数2*/
				ii += 2u;
                cmdSum++;
            }
            else
            {
            }
				
		}
        ShortToChar(cmdSum, &ciToCiDataBuffer[curIndex]);	/*命令个数*/
	}

	/*组相邻联锁间动态进路命令*/
	cmdSum = 0U;
	if (1u > SendCiDrCmdSum)
	{ /*命令个数错误*/

		ShortToChar(cmdSum, &ciToCiDataBuffer[ii]);  /*组命令个数*/
		ii += 2u;
	}
	else
	{
		curIndex = ii;/*命令个数跳过*/
		ii += 2u;

		for (jj = 0u; jj < SendCiDrCmdSum; jj++)
		{
			if ((SendCiDrCmdDataStru[jj].cSourceCiId == localCi) && (SendCiDrCmdDataStru[jj].cTargetCiId == targetDeviceId))
			{
				ciToCiDataBuffer[ii] = SendCiDrCmdDataStru[jj].cCmdType;  /*组动态进路命令类型*/
				ii += 1u;

				ciToCiDataBuffer[ii] = SendCiDrCmdDataStru[jj].cLogSecSeqDir;  /*组逻辑区段序列方向*/
				ii += 1u;

				ciToCiDataBuffer[ii] = SendCiDrCmdDataStru[jj].cLogSecSum;  /*组逻辑区段数量*/
				ii += 1u;

				for (kk = 0U; kk < SendCiDrCmdDataStru[jj].cLogSecSum; kk++)
				{
					ShortToChar(SendCiDrCmdDataStru[jj].wLogSecIdBuff[kk], &ciToCiDataBuffer[ii]);  /*组逻辑区段ID*/
					ii += 2u;
				}

				ShortToChar(SendCiDrCmdDataStru[jj].wTrainId, &ciToCiDataBuffer[ii]);  /*组列车ID*/
				ii += 2u;

				ciToCiDataBuffer[ii] = SendCiDrCmdDataStru[jj].cTrainLocLogSecSum;  /*组列车脚下逻辑区段数量*/
				ii += 1u;

				for (kk = 0U; kk < SendCiDrCmdDataStru[jj].cTrainLocLogSecSum; kk++)
				{
					ShortToChar(SendCiDrCmdDataStru[jj].wTrainLocLogSecIdBuff[kk], &ciToCiDataBuffer[ii]);  /*组列车脚下逻辑区段ID*/
					ii += 2u;
				}

				ciToCiDataBuffer[ii] = SendCiDrCmdDataStru[jj].cSwitchMoveFlag;  /*组半截进路道岔可动标志*/
				ii += 1u;				

				ShortToChar(SendCiDrCmdDataStru[jj].wRelStartSignalId, &ciToCiDataBuffer[ii]);  /*组首个逻辑区段关联的始端信号机ID*/
				ii += 2u;

				cmdSum++;
			}
			else
			{
			}
		}
		ShortToChar(cmdSum, &ciToCiDataBuffer[curIndex]);	/*组动态进路命令个数*/
	}

	/*预留40字节*/
	ii += 40u;
			
	/*清组CI命令数据和发送给相邻RC的区间雨雪数据*/
    ClearPackCICmdData(targetDeviceId);
	ClearPackCiDrCmdData(targetDeviceId);
	
	if (CI_SUCCESS == chRtn)
	{
		wDevType = (UINT16)Get2oo2SheBeiType();
		dstDevId = ((UINT16)(wDevType << 8u) | ((UINT16)targetDeviceId));
		outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &ciToCiDataBuffer[0], ii);
		if (1u == outnetSafeSendRtn)
		{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/		
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
			debug_infor_printf((const)"\nCI_SEND:%d", ii);
			debug_out_array(0xAA, ciToCiDataBuffer, ii);
#endif/*平台打印结束*/

#endif
			chRtn = CI_SUCCESS;
		}
		else
		{
			/*写队列失败*/
			chRtn = CI_ERROR;
		}
	}
	else
	{
		;
	}
	return chRtn;
}



/*
* 功能描述： 获取本联锁具有锁闭状态管理权的物理区段ID数组总数
* 参数说明： void    
* 返回值  ： 0: 获取失败
*			 >0: 发送锁闭状态的物理区段ID数组总数
*/
UINT8 GetPhySecIdBufSumhOfOtherCi(void)
{
	return PhySecIdBufSumhOfOtherCi;
}

/*
* 功能描述： 获取本联锁具有锁闭状态管理权的物理区段ID
* 参数说明： const UINT16 bufIndex, 物理区段ID数组下标  
* 返回值  ： 0: 获取失败
*			 >0: 发送锁闭状态的物理区段ID
*/
UINT16 GetPhySecIdBufOfOtherCi(const UINT16 bufIndex)
{
	if (bufIndex >= PhySecIdBufSumhOfOtherCi)
	{
		return 0u;
	}

	return PhySecIdBufOfOtherCi[bufIndex];
}


/*
* 功能描述： 清组CI命令数据
* 参数说明： targetDeviceId 目标联锁ID    
* 返回值  ： void     
* WGY -2022.3.10-修改相邻联锁发送命令清除缺陷
*/
void ClearPackCICmdData(UINT8 targetDeviceId)
{
	UINT16 ii = 0u;
	UINT32 cycleNum = 0u;
	
	UINT16 chNeedKeepSum = 0U;
	UINT16 chStruCurSum = 0U;

	cycleNum = Get2oo2CurCycleNum();/*获取平台周期号*/
	chStruCurSum = SendCiCmdDataStruCurSum;

	for (ii = 0U; ii < chStruCurSum; ii++)
	{
		
		if(SENDCI_CMD_DATA_STRU_SUM_MAX > ii)
		{
			if ((cycleNum >= (SendCiCmdDataStru[ii].CycleNo+1U)) && (SendCiCmdDataStru[ii].TargetCiId == targetDeviceId))
			{
				/*删除该命令数据,不保留*/
			}
			else
			{/*保留，不删除*/
				SendCiCmdDataStru[chNeedKeepSum++] = SendCiCmdDataStru[ii];
			}
		}
	}
	/*不保留数据全部清零*/
	for (ii = chNeedKeepSum; ii < chStruCurSum; ii++)
	{
		SendCiCmdDataStru[ii].SourceCiId = 0U;
		SendCiCmdDataStru[ii].TargetCiId = 0U;
		SendCiCmdDataStru[ii].CommandID = 0U;
		SendCiCmdDataStru[ii].Param1 = 0U;
		SendCiCmdDataStru[ii].Param2 = 0U;
		SendCiCmdDataStru[ii].CycleNo = 0U;
	}
	SendCiCmdDataStruCurSum = chNeedKeepSum;
}

/*
* 功能描述： 获取CI接受其他CI命令结构体数组长度
* 参数说明： void    
* 返回值  ： 0: 获取失败
*           >0: 命令结构体数组长度      
*/
UINT16 GetCiRecvCiCmdStruCurSum(void)
{
    return RecvCiCmdDataStruCurSum;
}

/*
* 功能描述： 获取CI接受其他CI命令结构体数组
* 参数说明： void    
* 返回值  ： NULL: 获取失败
*           !NULL: 命令结构体数组指针      
*/
ToCiCommandDataStruct *GetCiRecvCiCmdDataStruct(void)
{
	return RecvCiCmdDataStru;	
}

/*
* 功能描述： 添加CI发送到其他联锁命令信息
* 参数说明： UINT8 cmdID, 命令ID
*			 UINT16 cmdParam1, 命令参数1
*			 UINT16 cmdParam2, 命令参数2
*			 UINT8 toCiId, 发送到的联锁ID
* 返回值  ： 0: 添加失败
*			 1: 添加成功        
*/
void AddCiSendToCiCmdInfo(UINT8 cmdID, UINT16 cmdParam1, UINT16 cmdParam2, UINT8 toCiId)
{
	UINT32 cycleNo = 0u;
	UINT8 localCi = GetSystemParaLocalCiId();/*本地联锁ID*/
	cycleNo = Get2oo2CurCycleNum();
	if(SENDCI_CMD_DATA_STRU_SUM_MAX > SendCiCmdDataStruCurSum)
	{
		/*添加命令数据信息*/
		SendCiCmdDataStru[SendCiCmdDataStruCurSum].SourceCiId = localCi;
		SendCiCmdDataStru[SendCiCmdDataStruCurSum].TargetCiId = toCiId;
		SendCiCmdDataStru[SendCiCmdDataStruCurSum].CommandID = cmdID;
		SendCiCmdDataStru[SendCiCmdDataStruCurSum].Param1 = cmdParam1;
		SendCiCmdDataStru[SendCiCmdDataStruCurSum].Param2 = cmdParam2;
		SendCiCmdDataStru[SendCiCmdDataStruCurSum].CycleNo = cycleNo;
		SendCiCmdDataStruCurSum++;
	}
	else
	{
		debug_infor_printf((const)"Error:AddCiSendToCiCmdInfo,%d exceed max %d\n",SendCiCmdDataStruCurSum,SENDCI_CMD_DATA_STRU_SUM_MAX);
	}

}

/*
* 功能描述： 获取目的联锁对应的结构数据
* 参数说明： UINT8 dstId 联锁ID    
* 返回值  ： NULL，失败  非NULL 相连联锁设备数据结构指针
*/
CiTransmitStruct* GetDstCiTransInfo(UINT8 dstId)
{
	UINT8 ii = 0u;
	CiTransmitStruct *pTmpCiTransInfo = NULL;

	for (ii = 0u; ii < ciTransNum; ii++)
	{
		if (dstId == ciTransmitStruct[ii].destCiId)
		{
			/* 找到对应的联锁 */
			pTmpCiTransInfo = &ciTransmitStruct[ii];
			break;
		}
	}
	
	return pTmpCiTransInfo;
}

/*
* 功能描述： 获取指定CI->本CI的接口数据
* 参数说明： srcId 向本CI发送数据的联锁ID
* 返回值  ： NULL，失败  非NULL 相连联锁设备
*/
CiTransmitStruct* GetSrcCiTransInfo(UINT8 srcId)
{
	UINT8 ii = 0u;
	CiTransmitStruct *pTmpCiTransInfo = NULL;

	for (ii = 0u; ii < ciTransNum; ii++)
	{
		if (srcId == ciTransmitStruct[ii].srcCiId)
		{
			/* 找到对应的联锁 */
			pTmpCiTransInfo = &ciTransmitStruct[ii];
			break;
		}
	}

	return pTmpCiTransInfo;
}

/*
* 功能描述： 组CI数据帧,根据配置数据向对应的相连联锁发送数据与PackCiToCiDataFrame功能一致
* 参数说明： 
*			 UINT8* dataFrame, 存数据Buf
*			 UINT16* dataLength, 数据总长度的地址  
* 返回值  ： 无          
*/
void PackCiToCiDataFrameUseCfg(UINT8 dstCiId,UINT8* dataFrame, UINT16* dataLength)
{
	UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT8 m = 0U;
	UINT16 n = 0u;
	UINT8 chLogSecIndex = 0u;
	UINT16 deviceSum = 0u;	/*设备总数*/
	UINT16 deviceId = 0u;	/*设备ID*/
	UINT8 localCi = 0u;		/*本地联锁ID*/
	UINT16 deviceSumIndex = 0u;	/*设备总数游标位置*/
	CiTransmitStruct *pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);
	UINT8 deviceState = 0u;/*设备状态*/
	UINT16 phySecRLockBelongRouteId = 0u;/*物理区段锁闭所属进路ID*/
	UINT8 dataIsNeedPack = CI_FALSE;/*是否组包标志*/
	UINT8 phySecLockDir = 0u;/*物理区段锁闭方向*/
	UINT16 phySecLockDirFlg = 0u;/*物理区段锁闭方向是否取反标志*/
	UINT16 utOverlapUnlockCount = 0u;/*UT保护区段解锁周期数*/
	UINT16 ctOverlapUnlockCount = 0u;/*CT保护区段解锁周期数*/
	UINT16 overlapBelongRouteId = 0u;/*保护区段所属进路ID (动态字段)*/ 
	UINT8 overlapUnlockApplyFlag = 0u; /*向ZC申请解锁保护区段解锁标志*/ 
	UINT32 unlockStartCycNum = 0u;/*保护区段解锁起始周期号 (动态字段)*/ 
	UINT32 xuanPaiStartCycNum = 0u;/*保护区段选排开始周期号(动态字段)*/
	UINT8 floodOpenL = 0u;/*防淹门开启锁定状态*/
	UINT8 floodCloseR = 0u;/*防淹门关闭请求状态*/
	UINT8 floodAgreeCloseFromZC = 0u;/*防淹门收zc同意关闭状态*/
	UINT8 floodAgreeCloseOut = 0u;/*防淹门同意关闭状态输出*/
	UINT8 floodAgreeCloseIn = 0u;/*防淹门回采同意关闭状态*/
	UINT8 routeBelongCi = 0u;
	UINT8 belongCiId = 0u;
	UINT8 startLockFlag = 0u;
	UINT16 logSectionSum = 0u;
	UINT16* logIdBuf = NULL;
	UINT16 logLockBelongRouteId = 0u;
	UINT16 logPLockBelongRouteId = 0u;
	UINT8 logLockState = 0u;
	UINT8 logLockDir = 0u;
	UINT8 chLogSecTrainInfoSum = 0U;
	UINT16 wTrainId = 0U;
	CfpTrainInfoStru tmpTrainInfo = { 0u };
	UINT8 chEnvelopeNum = 0u;
	CfpEnvelopeStruct * pEnvelopeInfo = NULL;
	UINT8 chEnvelopeIndex = 0u;
	UINT8 chTrainIndex = 0u;
	UINT8 chLgcResShrFlag = 0U;
	UINT8 chCtNum = 0u;
	UINT8 chCtIndex = 0u;
	CfpCtTrainStruct * pCtInfo = NULL;
	UINT16 overlapUnlockTime = 0u;
	UINT8 autoRouteSetFlag = 0u;
	UINT8 chLogicTrainSum = 0U;	/*征用逻辑区段的列车数量*/
	UINT16 dwPhyErrlockTime = 0U;/*物理区段区故解倒计时*/
	LogicTrainResStruct * pstLogicResTrainInfo = NULL;	/*征用逻辑区段的列车信息指针*/
	UINT8 cLogSecLogicLockState = LOG_SECTION_LOCK_NO;  /*逻辑区段逻辑锁闭状态*/
	UINT8 cLogSecLogicLockDir = CI_SYSTEM_DIRECTION_NONE;  /*逻辑区段逻辑锁闭方向*/
	UINT8 cCiSendAreaSnowNum = 0U;  /*本RC发送给相邻RC的区间雨雪数量*/
	UINT16 cCiSendAreaSnowIndex = 0U;
	ToCiAreaSnowStruct* pCiSendAreaSnow = NULL;
	UINT8 cRrmSrcRcId = 0U;/* RRM源RC ID */
	UINT16 wRrmTrainId = 0U;/* RRM列车ID */
	UINT16 wRrmTrainNextStaId = 0U;/* RRM列车申请的下一站台ID */
	UINT8 chRrmSrcApplyState = 0U;/* 跨控区远程RM时，源TIOC申请状态 */
	UINT8 chRrmDstAllowState = 0U;/* 跨控区远程RM时，目标TIOC允许状态 */
	UINT8 switchIsThisLineFlag = 0U;		/*道岔是否为本线路*/
	UINT8 chSwitchJichaState = 0U;
	UINT8 leaveCheckFlag = LOGSEC_LEAVE_LOGSEC_REPLY_NO;
	UINT16 wCfpRelAdjaRcSignalId = 0U;  /*分界点关联的相邻RC的信号机ID*/
	UINT8 cCfpSignalLightUpFlag = SIGNAL_SLEEP_TRAIN_LIGHTUP_YES;  /*分界点信号机亮灯标志*/
	UINT8 cPhySecInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO;
	UINT8 chRouteApplySwitchCheckFlag = 0U;/*进路办理道岔状态检查标志*/
	UINT16 wUsingBelongOverlapId = 0U;  /*道岔征用所属保护区段ID*/
	UINT8 cSwitchUsingState = 0U;  /*道岔征用状态*/
	UINT8 cProSwtCheckStartFlag = 0U;  /*保护区段跨控区防护道岔检查开始标志*/
	UINT8 cProSwtCheckResultFlag = 0U;  /*保护区段跨控区防护道岔检查结果标志*/
	SwitchDataStruct* pSwitchDataStru = NULL;  /*道岔结构体*/
	UINT16 wPhySecUseRouteId = 0U;/*物理区段征用所属进路ID*/
	UINT16 wProSwSecUseRouteId = 0U;/*防护道岔物理区段征用所属进路ID*/
	UINT16 wSwPLockRouteIndex = 0U;
	UINT8 cSwPLockRouteNum = 0U;
	UINT16 wSwPLockOverlapIndex = 0U;
	UINT8 cSwPLockOverlapNum = 0U;
	UINT8 cLogLockBelLogRouteSum = 0U;
	UINT16 wCiSendAreaIteCutIndex = 0U;
	ToCiAreaIteCutStruct* pCiSendAreaIteCut = NULL;
	UINT8 cCiSendAreaIteCutNum = 0U;  /*本联锁发送给相邻联锁的区间ITE切除数量*/
	UINT8 devType = 0U; /*设备类型*/
	UINT8 devState = 0U; /*设备状态*/
	UINT8 chErrorType = 0U;/*失败类型*/

	localCi = GetSystemParaLocalCiId();
	startLockFlag = GetStartLockFlag();
	if((NULL != pTmpCiTransInfo) && (CI_START_LOCK_NO==startLockFlag))
	{/*配置数据存在且已经上电解锁才给相邻联锁组包相关设备信息*/
		/*组道岔信息*/		
		deviceSum = 0u;/*道岔总数*/
		deviceSumIndex = ii;/*道岔总数的游标位置*/
		ii += 2u;	
		for (jj = 0u; jj < pTmpCiTransInfo->switchNum; jj++)
		{
			deviceId = pTmpCiTransInfo->switchIdBuf[jj];/*获取道岔ID*/
			belongCiId = GetSwitchBelongCiId(deviceId);
			if ((localCi == belongCiId) || (dstCiId != belongCiId))
			{/*道岔处于本联锁或不属于对方控区（解决13AB线第三控区复视问题）*/

				ShortToChar(deviceId, &dataFrame[ii]);/*道岔ID*/
				ii += 2u;
				dataFrame[ii++] = GetSwitchYLockState(deviceId);/*道岔引导总锁状态*/
				dataFrame[ii++] = GetSwitchLockStatus(deviceId);/*道岔锁闭状态*/
				dataFrame[ii++] = GetSwitchFLockState(deviceId);/*道岔封锁状态*/
				dataFrame[ii++] = GetSwitchCurPosition(deviceId);/*道岔当前位置*/
				dataFrame[ii++] = GetSingleSwitchCurPosition(deviceId);/*单独道岔当前位置*/
				switchIsThisLineFlag = GetSwitchIsThisLineState(deviceId);
				if (DEV_IS_THIS_LINE_NO == switchIsThisLineFlag)
				{
					dataFrame[ii++] = GetConnetSwitchDsState(deviceId);			/*联络线道岔单锁状态*/
					dataFrame[ii++] = GetConnetSwitchByPassState(deviceId);			/*联络线道岔旁路状态,考虑进路其他联锁条件检查道岔时，未判道岔所属联锁，不传道岔旁路状态会影响信号开放*/
				}
				else
				{
					dataFrame[ii++] = 0U;				/*不是联络线道岔，不需要组此两字节，组包0*/
					dataFrame[ii++] = 0U;
				}
				/*组包道岔静态动态红闪状态*/
				chSwitchJichaState = GetSwitchPrompylyAlarmInfo(deviceId);
				if ((SWITCH_POSITION_DYNAMIC_JICHA == chSwitchJichaState) || (SWITCH_POSITION_SUDDEN_JICHA == chSwitchJichaState))
				{
					dataFrame[ii++] = chSwitchJichaState;
				}
				else
				{
					dataFrame[ii++] = 0U;				/*不是挤岔对应状态发送0*/
				}

				wUsingBelongOverlapId = GetSwitchBelongOverlapId(deviceId);
				ShortToChar(wUsingBelongOverlapId, &dataFrame[ii]);  /*组征用的保护区段ID*/
				ii += 2U;
				cSwitchUsingState = GetSwitchUsingState(deviceId);
				dataFrame[ii] = cSwitchUsingState;  /*组道岔征用状态*/
				ii++;

				/* zt 删除单轨相关代码 2022-02-15 */
				deviceSum++;
			}
			else
			{
				/*对方联锁信息不发送*/

			}
		}
		/*填写道岔总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组物理区段信息*/		
		deviceSum = 0u;/*物理区段总数*/
		deviceSumIndex = ii;/*物理区段总数的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->phySecNum; jj++)
		{
			deviceId = pTmpCiTransInfo->phySecIdBuf[jj];/*获取物理区段ID*/
			belongCiId = GetPhySecBelongCiId(deviceId);
			if (localCi == belongCiId)
			{/*物理区段处于本联锁*/

				ShortToChar(deviceId, &dataFrame[ii]);                         /*物理区段ID*/
				ii += 2u;
				dataFrame[ii] = GetPhySecCurOccupyState(deviceId);            /*物理区段采集占用状态（用于对方控区更新计轴区段占用起始周期，进而判断ARB相邻区段占用时间——2025.01.08）*/
				ii++;
				dataFrame[ii++] = GetPhySecCurMergeState(deviceId);            /*物理区段融合后的占用状态*/
				dataFrame[ii++] = GetPhySecPreOccState(deviceId);				/*物理区段当前CT或UT占用状态*/
				dataFrame[ii++] = GetPhySecStopSteadyFlag(deviceId);           /*物理区段停稳信息*/
				dataFrame[ii++] = GetPhySecUseState(deviceId);                 /*物理区段征用状态*/
				wPhySecUseRouteId = GetPhySecUseRouteId(deviceId);
				ShortToChar(wPhySecUseRouteId, &dataFrame[ii]);    /*物理区段征用所属进路ID*/
				ii += 2U;
				wProSwSecUseRouteId = GetPhySecProtectUseRouteId(deviceId);
				ShortToChar(wProSwSecUseRouteId, &dataFrame[ii]);    /*防护道岔物理区段征用所属进路ID*/
				ii += 2u;

				dataFrame[ii++] = GetPhySecFLockState(deviceId);               /*物理区段封锁状态*/
				dataFrame[ii++] = GetPhySecArbState(deviceId);                 /*物理区段Arb状态*/
				dataFrame[ii++] = GetPhySecCurAndMergeState(deviceId);         /*物理区段与占用状态*/
				dataFrame[ii++] = GetPhySecJumpLockState(deviceId);            /*物理区段跳跃锁闭状态*/
				dataFrame[ii++] = GetPhySecFLockType(deviceId);                /*物理区段封锁类型*/
				dataFrame[ii++] = GetPhySecPreResetState(deviceId);				/*物理区段预复位状态*/
				dwPhyErrlockTime = GetPhyErrUnlockTime(deviceId);
				ShortToChar(dwPhyErrlockTime, &dataFrame[ii]);    /*by cgh 20230706 相邻联锁显示区故解倒计时*/
				ii += 2u;	
				dataFrame[ii++] = GetPhySecAreaUrgentState(deviceId);				/*物理区段区域紧急制动状态*/
				/*RC16.0.0更新*/
				dataFrame[ii++] = GetPhySecABLTrainFlag(deviceId);				/*物理区段区域ABL占用状态*/
				dataFrame[ii++] = GetPhySecUTTrainFlag(deviceId);				/*物理区段区域坏车占用标志*/
				cPhySecInHumidRailFlag = GetPhySecInHumidRailFlag(deviceId);
				dataFrame[ii++] = cPhySecInHumidRailFlag;  /*物理区段湿轨标志*/
				deviceSum++;
			}
			else
			{
				/*非本联锁信息不发送*/
			}
		}
		/*填写物理区段总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组逻辑区段信息*/		
		deviceSum = 0u;/*逻辑区段总数*/
		deviceSumIndex = ii;/*逻辑区段总数的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->logicSecNum; jj++)
		{
			deviceId = pTmpCiTransInfo->logicSecIdBuf[jj];/*获取逻辑区段ID*/
			belongCiId = GetLogSecBelongCiId(deviceId);
			if (localCi == belongCiId)
			{/*处于本联锁*/

				ShortToChar(deviceId, &dataFrame[ii]);/*逻辑区段ID*/
				ii += 2u;
				dataFrame[ii++] = GetLogSecCurCtOrUtOccupyState(deviceId);/*逻辑区段占用状态*/
				dataFrame[ii++] = GetLogSecLinShiXianSuSetState(deviceId);	/* 临时限速 */
				dataFrame[ii++] = GetLogSecJumpLockState(deviceId);            /*逻辑区段跳跃锁闭状态*/
				dataFrame[ii++] = GetLgcArbState(deviceId);            /*逻辑区段ARB状态*/
				dataFrame[ii++] = GetLogSecSpksFLockState(deviceId);            /*逻辑区段SPKS封锁状态*/
				dataFrame[ii++] = GetLogSecProResUseState(deviceId);            /*逻辑区段保护锁闭资源可用状态*/
				dataFrame[ii++] = GetLogSecAblUseFlag(deviceId);			    /*逻辑区段ABL接近资源可用标志*/
				dataFrame[ii++] = GetLogSecXiansuSpeed(deviceId);            /*逻辑区段临时限速取值*/

				chLogicTrainSum = GetLogSecTrainInfoSum(deviceId);
				dataFrame[ii++] = chLogicTrainSum;
				if ((0U < chLogicTrainSum))
				{
					pstLogicResTrainInfo = GetLogSecTrainInfo(deviceId);
					if ((LOGIC_SECTION_RES_SUM_MAX >chLogicTrainSum)
						&& (NULL != pstLogicResTrainInfo))
					{

						for (chTrainIndex = 0u; chTrainIndex < chLogicTrainSum; chTrainIndex++)
						{
							/*锁闭征用，锁闭未征用信息 1字节*/
							/*组车组号-2字节*/
							ShortToChar(pstLogicResTrainInfo[chTrainIndex].wTrainId, &dataFrame[ii]);
							ii += 2u;
							dataFrame[ii++] = pstLogicResTrainInfo[chTrainIndex].chLogicResUsable;
						}
					}
					else
					{
						; /*不处理，继续执行*/
					}

				}
				else
				{
					; /*没车征用 继续执行*/
				}
				deviceSum++;
			}
			else
			{
				/*非本联锁信息不发送*/
			}
		}
		/*填写逻辑区段总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组信号机信息*/		
		deviceSum = 0u;/*信号机总数*/
		deviceSumIndex = ii;/*信号机总数的游标位置*/
		ii += 2u;
		for (jj = 0u; (jj < pTmpCiTransInfo->signalNum)&&(jj<SIGNAL_SUM_MAX); jj++)
		{
			deviceId = pTmpCiTransInfo->signalIdBuf[jj];/*获取道岔ID*/
			belongCiId = GetSignalBelongCiId(deviceId);
			if (localCi == belongCiId)
			{/*处于本联锁*/
				ShortToChar(deviceId, &dataFrame[ii]);/*信号机ID*/
				ii += 2u;
				dataFrame[ii++] = GetSignalFLockState(deviceId);/*信号机封锁状态*/
				dataFrame[ii++] = GetSignalLightExtinctState(deviceId);/*信号机亮灭状态状态*/
				dataFrame[ii++] = GetSignalCurColor(deviceId);/*信号机当前显示颜色状态*/
				dataFrame[ii++] = GetSignalLinShiXianSuSetFlag(deviceId);/*信号机临时限速状态*/
				dataFrame[ii++] = GetSignalSoftDetainFlag(deviceId);/*信号机软件扣车状态*/
				dataFrame[ii++] = GetSignalRelayDetainFlag(deviceId);/*信号机硬线扣车状态*/
				dataFrame[ii++] = GetSignalMaintainState(deviceId);/*信号机维修点灯状态*/
				dataFrame[ii++] = GetSignalCurBreakFlag(deviceId); /*信号机断丝状态整合*/
				deviceState = GetDetCutBtnState(deviceId); /*信号机扣车旁路按钮状态*/
				dataFrame[ii] = deviceState;
				ii++;
				deviceSum++;
			}
			else
			{
				/*非本联锁信息不发送*/
			}
		}
		/*填写信号机总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组屏蔽门信息*/		
		deviceSum = 0u;/*屏蔽门总数*/
		deviceSumIndex = ii;/*屏蔽门总数的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->psdNum; jj++)
		{
			deviceId = pTmpCiTransInfo->psdIdBuf[jj];/*获取屏蔽门ID*/
			belongCiId = GetPsdBelongCiId(deviceId);
			if (localCi == belongCiId)
			{
				/*处于本联锁*/
				ShortToChar(deviceId, &dataFrame[ii]);/*屏蔽门ID*/
				ii += 2u;
				dataFrame[ii++] = GetPsdState(deviceId);/*屏蔽门状态*/
				dataFrame[ii++] = GetPsdMutualLockRemoveState(deviceId);/*屏蔽门互锁解除状态*/

				deviceState = GePsdExceptOpenState(deviceId);  /*PSD异常打开状态*/
				dataFrame[ii] = deviceState;
				ii++;
				deviceSum++;
			}
			else
			{
				/*非本联锁信息不发送*/
			}
		}
		/*填写屏蔽门总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组紧急停车按钮信息*/		
		deviceSum = 0u;/*紧急停车按钮总数*/
		deviceSumIndex = ii;/*紧急停车按钮总数的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->esbNum; jj++)
		{
			deviceId = pTmpCiTransInfo->esbIdBuf[jj];/*获取紧急停车按钮ID*/
			belongCiId = GetEsbBelongCiId(deviceId);
			if (localCi == belongCiId)
			{/*处于本联锁*/

				ShortToChar(deviceId, &dataFrame[ii]);/*紧急停车按钮ID*/
				ii += 2u;
				dataFrame[ii++] = GetEsbState(deviceId);/*紧急停车按钮状态*/

				dataFrame[ii++] = GetEsbCutState(deviceId);/*紧急停车旁路按钮状态*/
				deviceSum++;
			}
			else
			{
				/*非本联锁信息不发送*/
			}
		}
		/*填写紧急停车按钮总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组进路信息*/		
		deviceSum = 0u;/*进路总数*/
		deviceSumIndex = ii;/*进路总数的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->routeNum; jj++)
		{
			deviceId = pTmpCiTransInfo->routeIdBuf[jj];/*获取进路ID*/
			belongCiId = GetRouteBelongCiId(deviceId);
			if (localCi == belongCiId)
			{/*处于本联锁*/

				ShortToChar(deviceId, &dataFrame[ii]);/*进路ID 2B*/
				ii += 2u;
				dataFrame[ii++] = GetRouteState(deviceId);/*进路状态 1B*/
				dataFrame[ii++] = GetRouteLevel(deviceId);/*进路监督级别 1B*/
				
				/* 2B:UT保护区段解锁倒计时周期数*/
				utOverlapUnlockCount = (UINT16)GetSystemParaProtSecUnlockCyc();
				ShortToChar(utOverlapUnlockCount,&dataFrame[ii]);
				ii+=2u;

				/* 2B:CT保护区段解锁倒计时周期数*/
				ctOverlapUnlockCount = (UINT16)GetSystemParaCtProtSecUnlockCyc();
				ShortToChar(ctOverlapUnlockCount,&dataFrame[ii]);
				ii+=2u;

				/*自动信号进路取消状态*/
				dataFrame[ii++] = GetAutoSigCancleState(deviceId);

				/*进路保护区段需要联锁锁闭标志*/
				dataFrame[ii++] = GetRouteOverlapNeedCIlockFlag(deviceId);

				/*进路追踪办理标志*/
				dataFrame[ii++] = GetRouteStateFlag(deviceId);

				/*进路自动触发标志*/
				dataFrame[ii++] = GetRouteAutoTriggerFlag(deviceId);


				deviceSum++;
				
			}
			else
			{
				/*非本联锁信息不发送*/
			}
		}
		/*填写进路总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

#if 0
		if (GetStartLockFlag() == CI_START_LOCK_YES)
		{/*处于上电锁闭状态*/
			deviceSum = 0u;/*发锁闭状态的物理区段总数*/
			deviceSumIndex = ii;/*发锁闭状态的物理区段总数的游标位置*/
			ii += 2u;
			/*填写物理区段总数*/
			ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);
		}
		else
		{/*上电解锁状态*/
		}
#endif
		/*组物理区段锁闭状态信息*/
		deviceSum = 0u;/*发锁闭状态的物理区段总数*/
		deviceSumIndex = ii;/*发锁闭状态的物理区段总数的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->phySecIdBufSumhOfOtherCi; jj++)
		{
			dataIsNeedPack = CI_FALSE;

			deviceId = pTmpCiTransInfo->wPhySecIdBufOfOtherCi[jj];/*获取物理区段ID,包含CI配置数据中的物理区段以及进路所包含的不属于本联锁的物理区段*/

			phySecLockDirFlg = pTmpCiTransInfo->phySecIdLockDirFlag[jj];/*获取物理区段锁闭方向是否取反标志，前面phySecNum个物理区段是联锁间接口数据配置*/

			deviceState = GetPhySecLockState(deviceId);/*获取物理区段锁闭状态*/

			if((PHYSICAL_SECTION_LOCK_NORMAL == deviceState) || (PHYSICAL_SECTION_LOCK_DELAY == deviceState))
			{/*正常锁闭或延时解锁*/
				phySecRLockBelongRouteId = GetPhySecRLockBelongRouteId(deviceId);
				routeBelongCi = GetRouteBelongCiId(phySecRLockBelongRouteId);
				if(localCi != routeBelongCi)
				{/*物理区段锁闭进路不属于本联锁*/
					dataIsNeedPack = CI_FALSE;
					/*增加逻辑，如果进路所属联锁不属于本联锁，且不属于目标联锁，可以组包；解决武汉反向进路跨2个集中区，在第3个集中区现地上
					看不到复视的第2个集中区的区段的进路锁闭状态*/
					if (dstCiId != routeBelongCi)
					{
						/*也不属于目的联锁，可以组包*/
						dataIsNeedPack = CI_TRUE;
					}
					else
					{/*属于目的联锁，不能发，防止互更*/
						dataIsNeedPack = CI_FALSE;
					}
				}
				else
				{
					dataIsNeedPack = CI_TRUE;
				}
			}
			else
			{/*其他锁闭状态正常组包*/
				dataIsNeedPack = CI_TRUE;
			}

			if(CI_TRUE == dataIsNeedPack)
			{
				ShortToChar(deviceId, &dataFrame[ii]);/*物理区段ID*/
				ii += 2u;
				dataFrame[ii++] = GetPhySecLockState(deviceId);/*物理区段锁闭状态*/

				ShortToChar(GetPhySecPLockBelongRouteId(deviceId), &dataFrame[ii]);/*设置物理区段防护锁闭所属进路ID*/
				ii += 2u;
				ShortToChar(GetPhySecRLockBelongRouteId(deviceId), &dataFrame[ii]);/*设置物理区段进路锁闭所属进路ID*/
				ii += 2u;					
				ShortToChar(GetRouteOverlapLockedId(GetPhySecPLockBelongRouteId(deviceId)), &dataFrame[ii]);/*物理区段防护锁闭所属OverLap的ID*/
				ii += 2u;

				phySecLockDir = GetPhySecLockDirection(deviceId);/*获取物理区段锁闭方向*/
				if (PHYSEC_LOCKDIRECTION_OPPST_YES == phySecLockDirFlg)
				{/*锁闭方向需要取反*/
					if (CI_SYSTEM_DIRECTION_DOWN == phySecLockDir)
					{/*锁闭方向下行则发送上行*/
						phySecLockDir = CI_SYSTEM_DIRECTION_UP;
					} 
					else if (CI_SYSTEM_DIRECTION_UP == phySecLockDir)
					{/*锁闭方向上行则发送下行*/
						phySecLockDir = CI_SYSTEM_DIRECTION_DOWN;
					} 
					else
					{/*不处理*/
					}
				} 

				dataFrame[ii++] = phySecLockDir;/*物理区段锁闭方向*/
				deviceSum++;	
			}
		}
		/*填写物理区段总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		deviceSum = 0u;/*发送SPKS总数*/
		deviceSumIndex = ii;/*发SPKS总数的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->spksNum; jj++)
		{
			deviceId = pTmpCiTransInfo->spksIdBuff[jj];
			belongCiId = GetSpksBelongCiId(deviceId);
			if (localCi == belongCiId)
			{/*处于本联锁*/
				ShortToChar(deviceId, &dataFrame[ii]);
				ii += 2u;
				dataFrame[ii++] = GetSpksState(deviceId);
				dataFrame[ii++] = GetSpksCutState(deviceId);
				deviceSum++;
			}
		}
		ShortToChar(deviceSum,&dataFrame[deviceSumIndex]);

		deviceSum = 0u;/*发送虚拟继电器总数*/
		deviceSumIndex = ii;/*发送虚拟继电器总数的游标位置*/
		ii += 2u;
		for (jj = 0u;jj < pTmpCiTransInfo->zcjNum;jj++)
		{
			deviceId = pTmpCiTransInfo->zcjIdBuf[jj];
			belongCiId = GetRelayBelongCiId(deviceId);
			if (localCi == belongCiId)
			{/*处于本联锁*/
				ShortToChar(deviceId,&dataFrame[ii]);
				ii += 2u;
				dataFrame[ii++] = GetRelayCollState(deviceId);
				deviceSum++;
			}
		}
		ShortToChar(deviceSum,&dataFrame[deviceSumIndex]);


		/*防淹门信息*/
		deviceSum = 0u;/*发送防淹门总数*/
		deviceSumIndex = ii;/*发送防淹门总数的游标位置*/
		ii += 2u;
		for (jj = 0u;jj < pTmpCiTransInfo->floodGateNum;jj++)
		{
			deviceId = pTmpCiTransInfo->floodGateIdBuf[jj];
			belongCiId = GetFloodGateBelongCiId(deviceId);
			if (localCi == belongCiId)
			{/*处于本联锁*/
				ShortToChar(deviceId,&dataFrame[ii]);
				ii += 2u;
				floodOpenL = GetFloodGateCurOpenLockState(deviceId);/*防淹门开门锁闭*/
				floodCloseR = GetFloodGateCurCloseRequestSta(deviceId);/*防淹门关门请求*/
				
				floodAgreeCloseFromZC = GetFloodGateCurZCAgrCloseAck(deviceId);/*收到zc防淹门同意关闭*/
				floodAgreeCloseIn = GetFloodGateCurAgreeCloseSta(deviceId);/*防淹门采集同意关闭*/
				floodAgreeCloseOut = GetFloodGateCurAgreeCloseOutSta(deviceId);/*防淹门输出同意关闭*/

				dataFrame[ii++] = floodOpenL;/*防淹门开门锁闭*/
				dataFrame[ii++] = floodCloseR;/*防淹门关门请求*/				
				dataFrame[ii++] = floodAgreeCloseFromZC;/*收到zc防淹门同意关闭*/
				dataFrame[ii++] = floodAgreeCloseIn;/*防淹门采集同意关闭*/
				dataFrame[ii++] = floodAgreeCloseOut;/*防淹门输出同意关闭*/
				deviceSum++;
			}
			else
			{
				/*非本联锁防淹门信息不发送*/
			}
		}
		ShortToChar(deviceSum,&dataFrame[deviceSumIndex]);

		/*组保护区段信息*/		
		deviceSum = 0u;/*保护区段总数*/
		deviceSumIndex = ii;/*保护区段总数的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->overlapNum; jj++)
		{
			deviceId = pTmpCiTransInfo->overlapIdBuf[jj];/*获取保护区段ID*/
			belongCiId = GetOverlapBelongCiId(deviceId);
			if (localCi == belongCiId)
			{/*处于本联锁*/

				ShortToChar(deviceId, &dataFrame[ii]);/*保护区段ID 2B*/
				ii += 2u;

				/*2B:保护区段所属进路ID (动态字段)*/ 
				overlapBelongRouteId = GetOverlapBelongRouteId(deviceId);
				ShortToChar(overlapBelongRouteId,&dataFrame[ii]);
				ii += 2u;

				/* 4B:指定ID保护区段组解锁起始周期号*/
				unlockStartCycNum = GetOverlapUnlockStartCycNum(deviceId);
				LongToChar(unlockStartCycNum,&dataFrame[ii]);
				ii += 4u;

				/* 4B:指定ID保护区段选排开始周期号*/
				xuanPaiStartCycNum = GetOverlapXuanPaiStartCycNum(deviceId);
				LongToChar(xuanPaiStartCycNum,&dataFrame[ii]);
				ii += 4u;

				/* 1B 获取指定ID保护区段向ZC申请解锁保护区段标志*/
				overlapUnlockApplyFlag = GetOverlapUnlockApplyFlag(deviceId);
				dataFrame[ii++] = overlapUnlockApplyFlag;

				/* 2B 获取指定ID保护区段解锁倒计时*/
				overlapUnlockTime = GetOverlapUnlockTime(deviceId);
				ShortToChar(overlapUnlockTime, &dataFrame[ii]);/*保护区段解锁倒计时 2B*/
				ii += 2U;

				cProSwtCheckStartFlag = GetOverlapProSwtCheckStartFlag(deviceId);
				dataFrame[ii] = cProSwtCheckStartFlag;  /*组保护区段防护道岔检查开始标志*/
				ii++;

				deviceSum++;
			}
			else
			{
				/*非本联锁信息不发送*/
			}
		}
		/*填写保护区段总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*cgh-合并CID-2539-7：组自动通过进路信息*/
		deviceSum = 0u;
		deviceSumIndex = ii;
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->autoRouteNum; jj++)
		{
			deviceId = pTmpCiTransInfo->autoRouteIdBuf[jj];
			belongCiId = GetAutoRouteBelongCiId(deviceId);
			if (localCi == belongCiId)
			{
				ShortToChar(deviceId, &dataFrame[ii]);
				ii += 2u;
				/*获取自动通过进路建立标志*/
				autoRouteSetFlag = GetAutoRouteSetFlag(deviceId);
				dataFrame[ii++] = autoRouteSetFlag;
				deviceSum++;
			}
			else
			{
				/*非本联锁信息不发送*/
			}
		}
		/*填写自动通过进路总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组逻辑区段锁闭状态信息*/
		deviceSum = 0u;/*发锁闭状态的逻辑区段总数*/
		deviceSumIndex = ii;/*发锁闭状态的逻辑区段总数的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->phySecIdBufSumhOfOtherCi; jj++)
		{
			deviceId = pTmpCiTransInfo->wPhySecIdBufOfOtherCi[jj];

			/*获取逻辑区段信息*/
			logSectionSum = GetPhySecIncLogSecSum(deviceId);
			logIdBuf = GetPhySecIncLogSecIdBuf(deviceId);
			/*逻辑区段信息正确*/
			if ((0u < logSectionSum) && (NULL != logIdBuf))
			{
				for (n = 0u; n < logSectionSum; n++)
				{
					dataIsNeedPack = CI_FALSE;
					/*获取锁闭状态、锁闭方向*/
					logLockState = GetLogSecLockState(logIdBuf[n]);
					logLockDir = GetLogSecLockDir(logIdBuf[n]);
					chLgcResShrFlag = GetLogSecResShareFlag(logIdBuf[n]);
					/*锁闭所属进路信息*/
					logLockBelongRouteId = GetLogSecLockBelongRoute(logIdBuf[n]);
					/* 保护锁闭的进路信息 */
					logPLockBelongRouteId = GetLogSecPLockRouteId(logIdBuf[n]);
					cLogSecLogicLockState = GetLogSecLogLockState(logIdBuf[n]);  /*逻辑区段逻辑锁闭状态*/
					cLogSecLogicLockDir = GetLogSecLogLockDir(logIdBuf[n]);  /*逻辑区段逻辑锁闭方向*/

					/*正常锁闭，延时解锁状态*/
					if ((LOG_SECTION_LOCK_NORMAL == logLockState) || (LOG_SECTION_LOCK_DELAY == logLockState))
					{
						dataIsNeedPack = CI_FALSE;
						routeBelongCi = GetRouteBelongCiId(logLockBelongRouteId);
						/*进路属于本联锁，且不属于目标联锁*/
						if ((localCi == routeBelongCi) || ((localCi != routeBelongCi) && (dstCiId != routeBelongCi)))
						{
							dataIsNeedPack = CI_TRUE;
						}
						else
						{
							dataIsNeedPack = CI_FALSE;
							/*不做处理*/
						}
					}
					else
					{
						dataIsNeedPack = CI_TRUE;
					}

					if (CI_TRUE == dataIsNeedPack)
					{
						ShortToChar(logIdBuf[n], &dataFrame[ii]);/*逻辑区段ID*/
						ii += 2U;
						dataFrame[ii++] = logLockState; /*逻辑区段锁闭状态*/
						ShortToChar(logLockBelongRouteId, &dataFrame[ii]); /*逻辑区段锁闭所属进路ID*/
						ii += 2U;/*锁闭方向*/

						ShortToChar(logPLockBelongRouteId, &dataFrame[ii]); /*逻辑区段保护锁闭ID*/
						ii += 2U;/*锁闭方向*/
						dataFrame[ii++] = logLockDir;

						dataFrame[ii++] = cLogSecLogicLockState;  /*逻辑区段逻辑锁闭状态*/
						dataFrame[ii++] = cLogSecLogicLockDir;  /*逻辑区段逻辑锁闭方向*/
						cLogLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(logIdBuf[n]);
						dataFrame[ii++] = cLogLockBelLogRouteSum;  /*逻辑区段逻辑锁闭所属逻辑进路数量*/

						dataFrame[ii++] = chLgcResShrFlag;
						/* 逻辑区段资源列车数量 */
						chLogSecTrainInfoSum = GetLogSecTrainInfoSum(logIdBuf[n]); /*已征用逻辑区段列车数量*/
						dataFrame[ii++] = chLogSecTrainInfoSum;

						for (chLogSecIndex = 0u; chLogSecIndex < chLogSecTrainInfoSum; chLogSecIndex++)
						{
							wTrainId = GetLogSecTrainIdByIndex(logIdBuf[n], chLogSecIndex);
							ShortToChar(wTrainId, &dataFrame[ii]);/*列车ID*/
							ii += 2u;
						}

						deviceSum++;
					}
				}
			}
		}
		/*填写逻辑区段总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);
		/*填写数据信息总长度*/
		*dataLength = ii;

		/* 组边界点列车信息 */
		deviceSum = 0u;/*发送边界点数量*/
		deviceSumIndex = ii;/*发送边界点数量的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->wCutoffPointNum; jj++)
		{
			/* 边界点ID */
			deviceId = pTmpCiTransInfo->wCutoffPointBuf[jj];
			tmpTrainInfo = GetCfpLocalOcTrainInfo(deviceId);
			chEnvelopeNum = GetCfpLocalOcENum(deviceId);
			pEnvelopeInfo = GetCfpLocalOcEData(deviceId);
			chCtNum = GetCfpLocalOcCtNum(deviceId);
			pCtInfo = GetCfpLocalOcCtData(deviceId);
			
			dataIsNeedPack = CI_FALSE;

			if ((UINT16_MAX != tmpTrainInfo.wTrainId) && (UINT8_MAX != chEnvelopeNum) && (NULL != pEnvelopeInfo)
				&& (UINT8_MAX != chCtNum) && (NULL != pCtInfo))
			{
				dataIsNeedPack = CI_TRUE;
			}

			if (CI_TRUE == dataIsNeedPack)
			{
				ShortToChar(deviceId, &dataFrame[ii]);/*分界点ID*/
				ii += 2u;

				ShortToChar(tmpTrainInfo.wTrainId, &dataFrame[ii]);/*列车ID*/
				ii += 2u;

				dataFrame[ii] = tmpTrainInfo.chTrainLevel;	/* 列车等级 */
				ii++;

				LongToChar(tmpTrainInfo.dwDis, &dataFrame[ii]);/*列车距离ID*/
				ii += 4u;

				dataFrame[ii++] = chEnvelopeNum;/* 分界点发送给相邻OC的包络数量 */

				for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++)
				{
					dataFrame[ii++] = pEnvelopeInfo[chEnvelopeIndex].envelopeType; /* 包络类型 */

					ShortToChar(pEnvelopeInfo[chEnvelopeIndex].headTrainID, &dataFrame[ii]); /* 前车ID */
					ii += 2u;

					ShortToChar(pEnvelopeInfo[chEnvelopeIndex].tailTrainID, &dataFrame[ii]); /* 后车ID */
					ii += 2u;

					dataFrame[ii++] = pEnvelopeInfo[chEnvelopeIndex].startPos.Dir;	/* 起点方向 */

					ShortToChar(pEnvelopeInfo[chEnvelopeIndex].startPos.Lnk, &dataFrame[ii]);/* 起点link */
					ii += 2u;

					LongToChar(pEnvelopeInfo[chEnvelopeIndex].startPos.Off, &dataFrame[ii]);/* 起点offset */
					ii += 4u;

					dataFrame[ii++] = pEnvelopeInfo[chEnvelopeIndex].endPos.Dir;/* 终点方向 */

					ShortToChar(pEnvelopeInfo[chEnvelopeIndex].endPos.Lnk, &dataFrame[ii]);/* 终点link */
					ii += 2u;

					LongToChar(pEnvelopeInfo[chEnvelopeIndex].endPos.Off, &dataFrame[ii]);/* 终点offset */
					ii += 4u;

					dataFrame[ii++] = (pEnvelopeInfo[chEnvelopeIndex].trianCnt); /* 包络内列车数量 */

					for (chTrainIndex = 0u; chTrainIndex < pEnvelopeInfo[chEnvelopeIndex].trianCnt; chTrainIndex++)
					{
						ShortToChar(pEnvelopeInfo[chEnvelopeIndex].trainID[chTrainIndex], &dataFrame[ii]);	/* 包络内列车ID */
						ii += 2u;

						dataFrame[ii++] = pEnvelopeInfo[chEnvelopeIndex].ACTPort[chTrainIndex];  /* 分界点列车激活端——用于UCT跨控区RMM判断激活端 */
					}
				}

				dataFrame[ii++] = chCtNum;/* 分界点发送给相邻TIOC的通信车数量 */
				for (chCtIndex = 0u; chCtIndex < chCtNum; chCtIndex++)
				{
					ShortToChar(pCtInfo[chCtIndex].wTrainId, &dataFrame[ii]);/* 通信列车ID */
					ii += 2u;

					dataFrame[ii++] = pCtInfo[chCtIndex].chLevel;/* 列车运行级别 */

					LongToChar(pCtInfo[chCtIndex].dwDelay, &dataFrame[ii]);/* TIOC和列车通信延时 */
					ii += 4u;

					ShortToChar(pCtInfo[chCtIndex].wSpeed, &dataFrame[ii]);/* 列车速度 */
					ii += 2u;

					dataFrame[ii++] = pCtInfo[chCtIndex].chSpeedDir;/* 列车速度方向 */

					dataFrame[ii++] = pCtInfo[chCtIndex].chTrainDir;/* 列车运行方向 */

					ShortToChar(pCtInfo[chCtIndex].wMaxHeadLink, &dataFrame[ii]);/* 通信列车最大安全前link */
					ii += 2u;

					LongToChar(pCtInfo[chCtIndex].dwMaxHeadOff, &dataFrame[ii]);/* 通信列车最大安全前偏移量 */
					ii += 4u;

					ShortToChar(pCtInfo[chCtIndex].wMinHeadLink, &dataFrame[ii]);/* 通信列车最小安全前link */
					ii += 2u;

					LongToChar(pCtInfo[chCtIndex].dwMinHeadOff, &dataFrame[ii]);/* 通信列车最小安全前偏移量 */
					ii += 4u;

					ShortToChar(pCtInfo[chCtIndex].wMaxTailLink, &dataFrame[ii]);/* 通信列车最大安全后link */
					ii += 2u;

					LongToChar(pCtInfo[chCtIndex].dwMaxTailOff, &dataFrame[ii]);/* 通信列车最大安全后偏移量 */
					ii += 4u;

					ShortToChar(pCtInfo[chCtIndex].wMinTailLink, &dataFrame[ii]);/* 通信列车最小安全后link */
					ii += 2u;

					LongToChar(pCtInfo[chCtIndex].dwMinTailOff, &dataFrame[ii]);/* 通信列车最小安全后偏移量 */
					ii += 4u;
				}

				/*分界点远程RM跨控区申请信息*/
				cRrmSrcRcId = GetCfpRrmSrcRcId(deviceId);   /*RRM源RC ID*/
				wRrmTrainId = GetCfpRrmTrainId(deviceId);							/* RRM列车ID */
				wRrmTrainNextStaId = GetCfpRrmTrainNextStaId(deviceId);				/* RRM列车申请的下一站台ID */
				chRrmSrcApplyState = GetCfpRrmSrcApplyState(deviceId);				/* 跨控区远程RM时，源TIOC申请状态 */
				chRrmDstAllowState = GetCfpRrmDstAllowState(deviceId);				/* 跨控区远程RM时，目标TIOC允许状态 */

				dataFrame[ii] = cRrmSrcRcId;
				ii++;
				ShortToChar(wRrmTrainId, &dataFrame[ii]);
				ii += 2U;
				ShortToChar(wRrmTrainNextStaId, &dataFrame[ii]);
				ii += 2U;
				if (cRrmSrcRcId == localCi)
				{
					dataFrame[ii] = chRrmSrcApplyState;
				}
				else
				{
					dataFrame[ii] = TRAIN_RRM_LOCALCI_NOT_APPLY;  /*非源RC默认向外组未申请*/
				}
				ii++;
				dataFrame[ii] = chRrmDstAllowState;
				ii++;

				wCfpRelAdjaRcSignalId = GetCfpRelAdjacentRcSignalId(deviceId);
				ShortToChar(wCfpRelAdjaRcSignalId, &dataFrame[ii]);  /*组分界点关联的相邻RC的信号机*/
				ii += 2U;

				cCfpSignalLightUpFlag = GetCfpSignalLightUpFlag(deviceId);
				dataFrame[ii] = cCfpSignalLightUpFlag;
				ii++;

				deviceSum++;
			}

			SetCfpSignalLightUpFlag(deviceId, SIGNAL_SLEEP_TRAIN_LIGHTUP_NO);  /*组包完成后清除对应亮灯标志*/
		}

		/*分界点总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组区间雨雪信息*/
		cCiSendAreaSnowIndex = ii;  /*跳过区间雨雪数量*/
		ii++;
		pCiSendAreaSnow = GetCiSendAreaSnowInfo(dstCiId);
		if (NULL != pCiSendAreaSnow)
		{
			for (m = 0U; m < pCiSendAreaSnow->cPlatFormNum; m++)
			{
				ShortToChar(pCiSendAreaSnow->szPlatFormInfo[m].wAreaId, &dataFrame[ii]);  /*组区间ID*/
				ii +=2U;
				dataFrame[ii] = pCiSendAreaSnow->szPlatFormInfo[m].cAreaSnowLevel;  /*组区间湿轨级别*/
				ii++;

				cCiSendAreaSnowNum++;
			}
		}
		else
		{
			cCiSendAreaSnowNum = 0U;  /*未查到给目标联锁的区间雨雪信息，置区间雨雪数量为0*/
		}
		dataFrame[cCiSendAreaSnowIndex] = cCiSendAreaSnowNum;  /*组区间雨雪数量*/

		/*组区间ITE切除信息*/
		wCiSendAreaIteCutIndex = ii;  /*跳过区间ITE切除数量*/
		ii++;
		pCiSendAreaIteCut = GetCiSendAreaIteCutInfo(dstCiId);
		if (NULL != pCiSendAreaIteCut)
		{
			for (m = 0U; m < pCiSendAreaIteCut->cAreaIteCutNum; m++)
			{
				ShortToChar(pCiSendAreaIteCut->wAreaIteCutId[m], &dataFrame[ii]);  /*组区间ID*/
				ii += 2U;
				cCiSendAreaIteCutNum++;
			}
		}
		else
		{
			cCiSendAreaIteCutNum = 0U;  /*未查到给目标联锁的区间ITE切除信息，置区间ITE切除为0*/
		}
		dataFrame[wCiSendAreaIteCutIndex] = cCiSendAreaIteCutNum;  /*组区间ITE切除数量*/

		/*组进路第一离去逻辑区段ABL列车检查信息*/
		deviceSum = 0u;/*离去逻辑区段总数*/
		deviceSumIndex = ii;/*离去区段总数的游标位置*/
		ii += 2u;
		for (jj = 0u; jj < pTmpCiTransInfo->routeleaveLogSumOfOtherCi; jj++)
		{
			deviceId = pTmpCiTransInfo->wrouteleaveLogIdBufOfOtherCi[jj];/*获取逻辑区段ID*/
			belongCiId = GetLogSecBelongCiId(deviceId);
			if (localCi == belongCiId)
			{/*处于本联锁*/

				ShortToChar(deviceId, &dataFrame[ii]);/*逻辑区段ID 2B*/
				ii += 2u;
				leaveCheckFlag= RouteLeaveLogSecCheck(deviceId);  /*是否通过离去区段检查标志 1B*/
				if (CI_SUCCESS == leaveCheckFlag)
				{
					dataFrame[ii++] = LOGSEC_LEAVE_LOGSEC_REPLY_YES;
				}
				else
				{
					dataFrame[ii++] = LOGSEC_LEAVE_LOGSEC_REPLY_NO;
				}
				deviceSum++;
			}
			else
			{
				/*非本联锁信息不发送*/
			}
		}
		/*填写离去逻辑区段总数*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组进路需要检查道岔状态的进路信息*/
		deviceSum = 0U;/*进路需要检查道岔状态的进路数目*/
		deviceSumIndex = ii;/*进路需要检查道岔状态的进路数目的游标位置*/
		ii += 2U;
		for (jj = 0u; jj < pTmpCiTransInfo->wNeedCheckSwitchStateRouteSum; jj++)
		{
			chRouteApplySwitchCheckFlag = GetRouteApplySwitchCheckFlag(pTmpCiTransInfo->szNeedCheckSwStateRouteBuf[jj]);
			deviceId = GetRouteApplySwitchCheckErrorData(pTmpCiTransInfo->szNeedCheckSwStateRouteBuf[jj], &devType, &devState, &chErrorType);
			if ((ROUTE_APPLY_SWITCH_CHECK_NO == chRouteApplySwitchCheckFlag) || (ROUTE_APPLY_SWITCH_CHECK_YES == chRouteApplySwitchCheckFlag))
			{
				;/*进路办理道岔检查标志是成功或者失败需要反馈给进路所在联锁*/
				ShortToChar(pTmpCiTransInfo->szNeedCheckSwStateRouteBuf[jj], &dataFrame[ii]);/*进路ID 2B*/
				ii += 2U;
				dataFrame[ii++] = chRouteApplySwitchCheckFlag;
				/*增加检查失败设备ID(2) 设备类型(1) 设备状态(1) 错误类型(1)*/
				ShortToChar(deviceId, &dataFrame[ii]);/*设备ID 2B*/
				ii += 2U;
				dataFrame[ii++] = devType;
				dataFrame[ii++] = devState;
				dataFrame[ii++] = chErrorType;
				deviceSum++;
			}
			else
			{
				; /*状态为默认不给相邻控区组包*/
			}
		}
		/*填写离去进路需要检查道岔状态的进路数目*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组其它控区保护区段的防护道岔检查结果*/
		deviceSum = 0U;
		deviceSumIndex = ii;
		ii += 2U;
		for (jj = 0U; jj < pTmpCiTransInfo->wNeedCheckProSwtStateOlpNum; jj++)
		{
			deviceId = pTmpCiTransInfo->szNeedCheckProSwtStateOlpIdBuf[jj];
			cProSwtCheckResultFlag = GetOverlapProSwtCheckResultFlag(deviceId);
			if ((PROSWITCH_CHECK_RESULT_VALID == cProSwtCheckResultFlag) || (PROSWITCH_CHECK_RESULT_INVALID == cProSwtCheckResultFlag))
			{
				ShortToChar(deviceId, &dataFrame[ii]);  /*保护区段ID*/
				ii += 2U;

				dataFrame[ii++] = cProSwtCheckResultFlag;  /*防护道岔检查结果*/
				deviceSum++;
			}
			else
			{
				/*状态为默认不给相邻控区组包*/
			}
		}
		/*填写需要本控区检查防护道岔的保护区段数量*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*组被本控区进路/保护区段防护锁闭的其他控区防护道岔的防护锁闭信息*/
		deviceSum = 0U;
		deviceSumIndex = ii;
		ii += 2U;
		pSwitchDataStru = GetSwitchData();
		if (NULL != pSwitchDataStru)
		{
			for (jj = 0U; jj < pTmpCiTransInfo->wSwitchSumOfOtherCi; jj++)
			{
				cSwPLockRouteNum = 0U;  /*清0处理*/
				cSwPLockOverlapNum = 0U;
				deviceId = pTmpCiTransInfo->szSwitchIdBufOfOtherCi[jj];/*获取道岔ID*/
				belongCiId = GetSwitchBelongCiId(deviceId);
				if (dstCiId == belongCiId)
				{			
					if ((0U < pSwitchDataStru[deviceId].PLockedRouteNum) || (0U < pSwitchDataStru[deviceId].PLockedOverlapNum))
					{
						ShortToChar(deviceId, &dataFrame[ii]);  /*组防护道岔ID*/
						ii += 2U;

						wSwPLockRouteIndex = ii;  /*防护锁闭所属进路数量*/
						ii++;
						for (m = 0U; m < SWITCH_MAX_PROTECT_LOCKED_NUM; m++)
						{
							if (0U != pSwitchDataStru[deviceId].PLockedRouteIdArr[m])
							{
								ShortToChar(pSwitchDataStru[deviceId].PLockedRouteIdArr[m], &dataFrame[ii]);  /*组防护锁闭的进路ID*/
								ii += 2U;
								cSwPLockRouteNum++;
							}
							else
							{
								/*防护锁闭所属进路ID为0，不组包*/
							}
						}
						dataFrame[wSwPLockRouteIndex] = cSwPLockRouteNum;  /*组防护锁闭的进路数量*/

						wSwPLockOverlapIndex = ii;  /*防护锁闭的保护区段数量*/
						ii++;
						for (m = 0U; m < SWITCH_MAX_PROTECT_LOCKED_NUM; m++)
						{
							if (0U != pSwitchDataStru[deviceId].PLockedOverlapIdArr[m])
							{
								ShortToChar(pSwitchDataStru[deviceId].PLockedOverlapIdArr[m], &dataFrame[ii]);  /*组防护锁闭的保护区段ID*/
								ii += 2U;
								cSwPLockOverlapNum++;
							}
							else
							{
								/*防护锁闭所属保护区段ID为0，不组包*/
							}
						}
						dataFrame[wSwPLockOverlapIndex] = cSwPLockOverlapNum;  /*组防护锁闭的保护区段数量*/

						deviceSum++;  /*待组的防护道岔数量+1*/
					}
					else
					{
						/*不存在防护锁闭，不组包*/
					}
				}
				else
				{
					/*本控区道岔，不组包*/
				}
			}
		}
		else
		{
			/*不组包*/
		}
		/*填写被本控区保护区段/进路防护锁闭的其它控区防护道岔数量*/
		ShortToChar(deviceSum, &dataFrame[deviceSumIndex]);

		/*填写数据信息总长度*/
		*dataLength = ii;
	}	
	else
	{
		/*相关设备数目都填0*/
		for (ii=0u;ii<CI_CI_DEFAULT_DEV_SUM_BUF_LEN;ii++)
		{
			dataFrame[ii]=0u;
		}

		*dataLength = CI_CI_DEFAULT_DEV_SUM_BUF_LEN;
	}
}


/*
* 功能描述： 初始化本联锁具有锁闭状态管理权的物理区段ID数组,通过配置数据
* 参数说明： void  
* 返回值  ： 返回成功
* edit cgh 20240102
*/
UINT8 InitPhySecIdBufOfOtherCiByConf(void)
{
	UINT16 ii = 0U;								/* 游标 */
	UINT16 jj = 0U;
	UINT8 kk = 0U;
	UINT8 belongCiId = 0u;						/*所属联锁ID*/
	RoutePhysicalSectionStruct* routePhySecData = NULL;	/*进路包含物理区段数据*/
	UINT8 routePhySecSum = 0U;							/*进路包含物理区段数目*/
	CiTransmitStruct* pTmpCiTransmitStru = NULL;
	UINT8 reVal = CI_ERROR;
	UINT8 phyBelongCIid = 0U;
	UINT8 chRouteProSwitchSum = 0U; 							/*防护道岔数目*/
	RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL;    /*防护道岔数据*/
	UINT16 wProSwRelPhySecId = 0U;/*防护道岔关联物理区段ID*/
	UINT16 wPhySecIdCheck = 0U;/*物理区段ID检查*/

	belongCiId = GetSystemParaLocalCiId();

	reVal = CI_SUCCESS;
	/* 具有锁闭状态所有区段 */
	for (ii = 0u; ii < ciTransNum; ii++)
	{
		pTmpCiTransmitStru = &ciTransmitStruct[ii];

		if (pTmpCiTransmitStru->srcCiId == belongCiId)
		{
			pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi = 0u;
			/* 将配置的物理区段，也许要发送保护区段 */
			for (jj = 0u; jj < pTmpCiTransmitStru->phySecNum; jj++)
			{
				/* 本联锁进路内的物理区段，不属于本联锁，需要将锁闭后状态告诉其他联锁 */
				phyBelongCIid = GetPhySecBelongCiId(pTmpCiTransmitStru->phySecIdBuf[jj]);
				wPhySecIdCheck = CheckPhyBufOfOtherCiExist(pTmpCiTransmitStru->destCiId, pTmpCiTransmitStru->phySecIdBuf[jj]);

				if ((phyBelongCIid == belongCiId) && (CI_SUCCESS == wPhySecIdCheck))
				{
					if (PHYSICAL_SECTION_SUM_MAX > pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi)
					{
						pTmpCiTransmitStru->wPhySecIdBufOfOtherCi[pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi] = pTmpCiTransmitStru->phySecIdBuf[jj];
						pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi++;
					}
					else
					{
						reVal = CI_ERROR;
					}
				}
				else
				{
					; /*其他不处理*/
				}
			}
			/* 需要发送的物理区段全部加入发送区段联锁关系 */
			for (jj = 0u; jj < pTmpCiTransmitStru->routeNum; jj++)
			{
				routePhySecSum = GetRoutePhysicalSectionSum(pTmpCiTransmitStru->routeIdBuf[jj]);/*进路包含物理区段数目*/
				routePhySecData = GetRouteSectionData(pTmpCiTransmitStru->routeIdBuf[jj]);		/*进路包含物理区段数据*/

				for (kk = 0u; kk < routePhySecSum; kk++)
				{
					/* 本联锁进路内的物理区段，不属于本联锁，需要将锁闭后状态告诉其他联锁 */
					phyBelongCIid = GetPhySecBelongCiId(routePhySecData[kk].PhysicalSectionId);
					wPhySecIdCheck = CheckPhyBufOfOtherCiExist(pTmpCiTransmitStru->destCiId, routePhySecData[kk].PhysicalSectionId);

					if ((phyBelongCIid != belongCiId) && (phyBelongCIid == pTmpCiTransmitStru->destCiId) && (CI_SUCCESS == wPhySecIdCheck))
					{
						/*物理区段不属于本联锁且属于目标联锁*/
						if (PHYSICAL_SECTION_SUM_MAX > pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi)
						{
							pTmpCiTransmitStru->wPhySecIdBufOfOtherCi[pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi] = routePhySecData[kk].PhysicalSectionId;
							pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi++;
						}
						else
						{
							reVal = CI_ERROR;
						}
					}
					else
					{
						; /*其他不处理*/
					}
				}

				chRouteProSwitchSum = GetRouteRelatedProtectSwitchSum(pTmpCiTransmitStru->routeIdBuf[jj]);
				pRouteProtectSwitchStru = GetRouteRelatedProtSwitchData(pTmpCiTransmitStru->routeIdBuf[jj]);

				for (kk = 0u; kk < chRouteProSwitchSum; kk++)
				{
					wProSwRelPhySecId = GetSwitchPhySectionId(pRouteProtectSwitchStru[kk].ProtectSwitchId);
					phyBelongCIid = GetPhySecBelongCiId(wProSwRelPhySecId);
					wPhySecIdCheck = CheckPhyBufOfOtherCiExist(pTmpCiTransmitStru->destCiId, wProSwRelPhySecId);

					if ((phyBelongCIid != belongCiId) && (phyBelongCIid == pTmpCiTransmitStru->destCiId) && (CI_SUCCESS == wPhySecIdCheck))
					{
						/*物理区段不属于本联锁且属于目标联锁*/
						if (PHYSICAL_SECTION_SUM_MAX > pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi)
						{
							pTmpCiTransmitStru->wPhySecIdBufOfOtherCi[pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi] = wProSwRelPhySecId;
							pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi++;
						}
						else
						{
							reVal = CI_ERROR;
						}
					}
					else
					{
						; /*不处理*/
					}
				}

			}
		}
		else
		{
			; /*其它不初始化*/
		}
	}

	return reVal;
}

/*
* 功能描述： 检查本联锁具有锁闭状态管理权的物理区段ID是否已添加
* 参数说明： const UINT8 chDetCiId 目标联锁ID
*		     const UINT16 wPhySecId 物理区段ID
* 返回值  ： CI_SUCCESS 未添加
*	         CI_ERROR   已添加
* edit cgh 20240107
*/
UINT8 CheckPhyBufOfOtherCiExist(const UINT8 chDetCiId,const UINT16 wPhySecId)
{
	UINT16 ii = 0U;								/* 游标 */
	UINT16 jj = 0U;
	UINT8 belongCiId = 0U;						/*所属联锁ID*/
	CiTransmitStruct* pTmpCiTransmitStru = NULL;
	UINT8 reVal = CI_ERROR;

	for (ii = 0U; ii < ciTransNum; ii++)
	{
		reVal = CI_SUCCESS;
		pTmpCiTransmitStru = &ciTransmitStruct[ii];
		belongCiId = GetSystemParaLocalCiId();

		if ((pTmpCiTransmitStru->srcCiId == belongCiId) && (pTmpCiTransmitStru->destCiId == chDetCiId))
		{
			/*只能找到一个数组*/
			for (jj = 0U; jj < pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi; jj++)
			{
				if (wPhySecId == pTmpCiTransmitStru->wPhySecIdBufOfOtherCi[jj])
				{
					break;
				}
				else
				{
					; 
				}
			}

			if (jj == pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi)
			{
				; 
			}
			else
			{
				/*有重复；跳出*/
				reVal = CI_ERROR;
			}
		}
		else
		{
			;
		}

		if (CI_ERROR == reVal)
		{
			break;
		}
		else
		{
			;
		}
	}

	return reVal;
}


/*
* 功能描述： 清CI接收到的其他联锁命令数据
* 参数说明： void    
* 返回值  ： 0: 解析失败
*			 1: 解析成功      
*/
void ClearCiRevCiCmdData(void)
{
	UINT16 ii = 0U;
	UINT32 dwCycleNum = 0U;
	UINT16 cStruCurSum = 0U;
	UINT16 cNeedKeepSum = 0U;	

	dwCycleNum = Get2oo2CurCycleNum();
	cStruCurSum = RecvCiCmdDataStruCurSum;

	for (ii = 0U; ii < cStruCurSum; ii++)
	{
		if (((dwCycleNum >= (RecvCiCmdDataStru[ii].CycleNo + 1U)) && (CI_CMD_AUTO_SIG_ROUTE_CANCLE != RecvCiCmdDataStru[ii].CommandID)) 
			|| ((dwCycleNum >= (RecvCiCmdDataStru[ii].CycleNo + 2U)) && (CI_CMD_AUTO_SIG_ROUTE_CANCLE == RecvCiCmdDataStru[ii].CommandID)))
		{
			/*命令存储达到2周期，删除该命令数据,不保留*/
		}
		else
		{
			RecvCiCmdDataStru[cNeedKeepSum] = RecvCiCmdDataStru[ii];  /*保留当周期命令，不删除*/
			cNeedKeepSum++;
		}
	}

	/*不保留数据全部清零*/
	for (ii = cNeedKeepSum; ii < cStruCurSum; ii++)
	{
		RecvCiCmdDataStru[ii].SourceCiId = 0U;
		RecvCiCmdDataStru[ii].TargetCiId = 0U;
		RecvCiCmdDataStru[ii].CommandID = 0U;
		RecvCiCmdDataStru[ii].Param1 = 0U;
		RecvCiCmdDataStru[ii].Param2 = 0U;
		RecvCiCmdDataStru[ii].CycleNo = 0U;
	}

	RecvCiCmdDataStruCurSum = cNeedKeepSum;
}

/*
* 功能描述： 解析互联互通接口的CI到CI数据
* 参数说明：
UINT8* dataBuf,数据帧字节数组
const UINT16 dataLength,数组帧字节数组中有效数据的长度
const UINT8 systemId,发送方联锁编号
* 返回值  ： 0:解析失败
*			 1:解析成功
*/
UINT8 ParseCiToCiDataFrameHLHT(UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId)
{
	UINT8 retVal = CI_SUCCESS;
	UINT8 localCiId = GetSystemParaLocalCiId();/*联锁ID*/
	UINT32 errCode = 0u;
	HLHTGALInfoStruct hlhtGalHead = { 0u };
	INT32 vobcInfoRemainValidiy = 0;
	UINT8 headRet = HLHT_HEAD_ERROR;/*互联互通检查结果*/
	UINT16 srcCiName, localCiName;/*原CI和目标两字节ID*/
	UINT32 curntCycleNo = 0u;/*当前周期号*/
	UINT32 ii = 0u;
	UINT8 startLockState = 0u;
	UINT8 chTransmitRecvDataCycResult = 0U;/*通信状态更新结果*/
	UINT32 dwBadEnsureTime = 0U;  /*通信中断判断周期数*/
	UINT32 dwAppCycleTime = 0U;  /*CI应用周期*/

	srcCiName = (CI_SYSTEM_TYPE_CI) * 256U + systemId;
	localCiName = (CI_SYSTEM_TYPE_CI) * 256U + localCiId;

	/*解析通用消息包头*/
	hlhtGalHead.devInterInfoType = ShortFromChar(&dataBuf[ii]);
	ii += 2u;
	hlhtGalHead.sourceId = LongFromChar(&dataBuf[ii]);
	ii += 4u;
	hlhtGalHead.destId = LongFromChar(&dataBuf[ii]);
	ii += 4u;
	hlhtGalHead.emapVerCrc = LongFromChar(&dataBuf[ii]);
	ii += 4u;
	hlhtGalHead.crntOwnMsgSN = LongFromChar(&dataBuf[ii]);
	ii += 4u;
	hlhtGalHead.comPeriod = ShortFromChar(&dataBuf[ii]);
	ii += 2u;
	hlhtGalHead.recvOppMsgSN = LongFromChar(&dataBuf[ii]);
	ii += 4u;
	hlhtGalHead.preOwnMsgSN = LongFromChar(&dataBuf[ii]);
	ii += 4u;
	hlhtGalHead.prtclVer = dataBuf[ii++];
	hlhtGalHead.totalDataLen = ShortFromChar(&dataBuf[ii]);
	ii += 2u;

	curntCycleNo = Get2oo2CurCycleNum();

	/*通用报文头检查*/
	headRet = HLHTCiCommonPacketHeadCheck(srcCiName, localCiName, HLHT_CI_INTER_TYPE, HLHT_CI_INTER_VER, &hlhtGalHead, &errCode, 0, CI_SYSTEM_TYPE_CI);
	debug_infor_printf((const)"\nCI %d GAL Check Result:%d errCode:%d", systemId, headRet, errCode);	/*0x55正确，0xaa错误，0x33初始通信帧*/

	if (HLHT_HEAD_SUCCESS == headRet)
	{
		/*计算消息的时效性*/
		dwBadEnsureTime = GetCiAndCiTransmitBadEnsureTime();
		dwAppCycleTime = GetSystemParaAppCycleTime();
		vobcInfoRemainValidiy = HLHTCommonMsgRemainingValidity(dwBadEnsureTime, curntCycleNo, dwAppCycleTime, hlhtGalHead.recvOppMsgSN, hlhtGalHead.crntOwnMsgSN, hlhtGalHead.preOwnMsgSN, hlhtGalHead.comPeriod);

		if (vobcInfoRemainValidiy > 0)
		{
			startLockState = GetStartLockFlag();

			if(startLockState == CI_START_LOCK_NO)
			{
				/*执行具体解析*/
				retVal = ParseCiPacketCont(dataBuf + ii, hlhtGalHead.totalDataLen, systemId);
			}
			else
			{
				retVal = CI_SUCCESS;
			}

			if (CI_SUCCESS == retVal)
			{
				SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.comPeriod);
				SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.crntOwnMsgSN);
				SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.recvOppMsgSN);
				SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.preOwnMsgSN);
				SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_CI, systemId, curntCycleNo);

				if (CI_SUCCESS == retVal)
				{	/*设置相邻CI与本CI通信周期*/
					/*更新通信周期*/
					chTransmitRecvDataCycResult = SetCiTransmitRecvDataCycNum(localCiId, Get2oo2SheBeiType(), systemId, curntCycleNo);
					if (CI_ERROR == chTransmitRecvDataCycResult)
					{
						/*更新周期失败*/
						retVal = CI_ERROR;
					}
					else
					{
						; 
					}
				}
				else
				{
					; 
				}
			}
		}
		else
		{
			debug_infor_printf((const)"\nParseCiToCiDataFrameHLHT: Msg Validity Error");
			retVal = CI_ERROR;
		}
	}
	else if (HLHT_HEAD_INIT == headRet)
	{
		if (curntCycleNo > 0u)/*判断序号大于0，因为把0当做无效序号*/
		{
			SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.comPeriod);
			SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.crntOwnMsgSN);
			SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.recvOppMsgSN);
			SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.preOwnMsgSN);
			SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_CI, systemId, curntCycleNo);
		}

		retVal = CI_ERROR;
	}
	else
	{
		/*给ATS或现地反馈CI-CI数据接口信息类型错误*/
		if (GAL_COMPARE_INFO_TYPE_ERR == (errCode & GAL_COMPARE_INFO_TYPE_ERR))
		{/*记录通信故障码*/
			SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_INFO_TYPE_ERR,ESEND_LEVEL_ATS);
		}
		/*给ATS或现地反馈CI-CI数据发送方标识信息错误*/
		else if (GAL_COMPARE_SEND_FLAG_ERR == (errCode & GAL_COMPARE_SEND_FLAG_ERR))
		{/*记录通信故障码*/
			SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_SEND_FLAG_ERR,ESEND_LEVEL_ATS);
		}
		/*给ATS或现地反馈CI-CI数据接收方标志信息错误*/
		else if (GAL_COMPARE_RECV_FLAG_ERR == (errCode & GAL_COMPARE_RECV_FLAG_ERR))
		{/*记录通信故障码*/
			SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_RECV_FLAG_ERR,ESEND_LEVEL_ATS);
		}
		/*给ATS或现地反馈CI-CI数据版本校验失败信息*/
		else if (GAL_COMPARE_EMAP_VER_COMP_ERR == (errCode & GAL_COMPARE_EMAP_VER_COMP_ERR))
		{/*记录通信故障码*/
			SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_VER_CHECK_FAIL,ESEND_LEVEL_ATS);
		}
		/*给ATS或现地反馈CI-CI数据本方、对方及收到上一条消息时本方序列号错误*/
		else if (GAL_COMPARE_MSG_BDS_SN_ERR == (errCode & GAL_COMPARE_MSG_BDS_SN_ERR))
		{/*记录通信故障码*/
			SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_MSG_BDS_SN_ERR,ESEND_LEVEL_ATS);
		}
		/*给ATS或现地反馈CI-CI数据对方消息序列号及收到上一条消息时本方序列号错误*/
		else if (GAL_COMPARE_MSG_SN_ERR == (errCode & GAL_COMPARE_MSG_SN_ERR))
		{/*记录通信故障码*/
			SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_MSG_SN_ERR,ESEND_LEVEL_ATS);
		}
		/*给ATS或现地反馈CI-CI数据协议版本号错误*/
		else if (GAL_COMPARE_PROTOCOL_VER_ERR == (errCode & GAL_COMPARE_PROTOCOL_VER_ERR))
		{/*记录通信故障码*/
			SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_PROTOCOL_VER_ERR,ESEND_LEVEL_ATS);
		}
		/*给ATS或现地反馈CI-CI数据应用层数据长度无效*/
		else if (GAL_COMPARE_APP_LEN_ERR == (errCode & GAL_COMPARE_APP_LEN_ERR))
		{/*记录通信故障码*/
			SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_APP_LEN_ERR,ESEND_LEVEL_ATS);
		}
		/*给ATS或现地反馈CI-CI数据通信周期错误 */
		else if (GAL_COMPARE_COM_PERIOD == (errCode & GAL_COMPARE_COM_PERIOD))
		{/*记录通信故障码*/
			SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_COM_PERIOD,ESEND_LEVEL_ATS);
		}
		else
		{/*记录通信故障码*/
			SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_ERROR,ESEND_LEVEL_ATS);
		}
		retVal = CI_ERROR;
	}

	return retVal;
}
/*互联互通相关*/

static UINT8 SetIntconPhySecRLockState(UINT16 phySecId, UINT8 routeLockState)
{
	UINT16 bufIndex = 0u;
	UINT8 retVal = CI_ERROR;

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

	if (bufIndex < PHYSICAL_SECTION_SUM_MAX)
	{
		IntconPhySecData[bufIndex].RLockState = routeLockState;
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
功能描述:
获取单一报文类型
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pPacketType 报文类型
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParsePacketType(const UINT8* pInputData, UINT16* pPacketType, UINT16* pItemLen)
{
	UINT8 cRetVal = CI_ERROR;

	if ((NULL != pInputData) && (NULL != pPacketType) && (NULL != pItemLen))
	{
		*pPacketType = ShortFromChar(pInputData);
		*pItemLen = PACKET_TYPE_LEN;

		cRetVal = CI_SUCCESS;
	}
	else
	{
		/*返回失败*/
	}

	return cRetVal;
}

/*
功能描述:
组应用报文类型数据包
输入参数:
UINT8 *pInputData 输入数据指针，UINT16 packetType 应用报文类型
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackPacketType(UINT8 *pInputData, UINT16 packetType, UINT16 *pItemLen)
{
	UINT8 cRetVal = CI_ERROR;

	if ((NULL != pInputData) && (NULL != pItemLen))
	{
		ShortToChar(packetType, pInputData);
		*pItemLen = PACKET_TYPE_LEN;

		cRetVal = CI_SUCCESS;
	}
	else
	{
		/*返回失败*/
	}

	return cRetVal;
}

/*
功能描述:
获取单一报文长度
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pPacketLen 报文长度
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParsePacketLength(const UINT8 *pInputData, UINT16 *pPacketLen, UINT16 *pItemLen)
{
	UINT8 cRetVal = CI_ERROR;

	if ((NULL != pInputData) && (NULL != pPacketLen) && (NULL != pItemLen))
	{
		*pPacketLen = ShortFromChar(pInputData);
		*pItemLen = PACKET_LENGTH_LEN;

		cRetVal = CI_SUCCESS;
	}
	else
	{
		/*返回失败*/
	}

	return cRetVal;
}

/*
功能描述:
在*pInputData中，获取存放报文内容长度地址的地址
输入参数:
UINT8 *pInputData 组包数据指针
输出参数:
UINT8 **ppLenItemAddr 存放报文内容长度地址的地址
UINT16 *pItemLen 相应类型的报文内容长度：由“报文类型～报文结束”的帧长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackPacketLenPha1(UINT8 *pInputData, UINT8 **ppLenItemAddr, UINT16 *pItemLen)
{
	UINT8 cRetVal = CI_ERROR;

	if ((NULL != pInputData) && (NULL != ppLenItemAddr) && (NULL != pItemLen))
	{
		*pItemLen = PACKET_LENGTH_LEN;
		*ppLenItemAddr = pInputData;

		cRetVal = CI_SUCCESS;
	}
	else
	{
		/*返回失败*/
	}

	return cRetVal;
}

/*
功能描述:
在*pInputData中保存报文长度的地址上，填入相应类型的报文内容的长度
输入参数:
UINT8 *pInputData 组包数据指针
输出参数:
UINT16 *pItemLen 相应类型的报文内容长度：由“报文类型～报文结束”的帧长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackPacketLenPha2(UINT8 *pInputData, UINT16 itemLen)
{
	UINT8 cRetVal = CI_ERROR;

	if (NULL != pInputData)
	{
		ShortToChar(itemLen, pInputData);
		cRetVal = CI_SUCCESS;
	}
	else
	{
		/*返回失败*/
	}

	return cRetVal;
}

/*
功能描述:
解析道岔数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParseSwitchPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId)
{
	const CiTransmitStruct* pCiRecptStru = NULL;
	UINT8 deviceSum = 0u;		/*道岔数量*/
	UINT8 dataBuf = 0u;			/*道岔状态*/
	UINT8 curPosition = 0u;		/*道岔位置*/
	UINT8 yLockState = 0u;		/*道岔引导总锁闭状态*/
	UINT8 dLockState = 0u;		/*道岔单锁状态*/
	UINT8 fLockState = 0u;		/*道岔封锁状态*/

	UINT8 localCiId = 0u;
	UINT8 belongCiId = 0u;

	UINT16 switchId = 0xFFFFu;		/*道岔id*/
	UINT8 swiInd = 0u;
	UINT16 parsedLen = 0u;		/*指针偏移量*/
	UINT8 retValue = CI_ERROR;
	UINT16 bufInd = 0u;
	SwitchDataStruct * pSwitchDataStru = NULL;

	localCiId = GetSystemParaLocalCiId();
	pCiRecptStru = GetSrcCiTransInfo(srcCiId);					/*获取源联锁对应的结构数据*/

	deviceSum = *(pInputData + parsedLen);
	parsedLen += 1u;
	if (NULL == pCiRecptStru)
	{
		retValue = CI_ERROR; /*获取失败*/
	}
	else if (deviceSum == pCiRecptStru->switchNum)
	{
		pSwitchDataStru = GetSwitchData();

		for (swiInd = 0u; swiInd < pCiRecptStru->switchNum; swiInd++)
		{
			dataBuf = *(pInputData + parsedLen);	/*道岔状态信息包获取*/
			parsedLen += 1u;

			switchId = pCiRecptStru->switchIdBuf[swiInd];			/*获取道岔ID*/

			bufInd = GetSwitchConfigBufIndex(switchId);

			(pSwitchDataStru + bufInd)->SwitchId = switchId;

			belongCiId = GetSwitchBelongCiId(switchId);

			if (localCiId != belongCiId)
			{
				curPosition = (dataBuf & BIT_MASK_00000011B);
				yLockState = ((dataBuf >> 2u) & BIT_MASK_00000011B);
				dLockState = ((dataBuf >> 4u) & BIT_MASK_00000011B);
				fLockState = ((dataBuf >> 6u) & BIT_MASK_00000011B);

				switch (curPosition)
				{
				case BIT_VAL_00000001B:
					SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_DINGWEI);
					SetSwitchCurPosition(switchId, SWITCH_POSITION_DINGWEI);/*如果道岔是对方的，只能认为与Single位置一致*/
					break;
				case BIT_VAL_00000010B:
					SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_FANWEI);
					SetSwitchCurPosition(switchId, SWITCH_POSITION_FANWEI);
					break;
				case BIT_VAL_00000000B:
					SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);
					SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);
					break;
				default:
					/*不可达分支*/
					break;
				}
				switch (yLockState)
				{
				case BIT_VAL_00000001B:
					SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_NO);		/*未引导锁闭*/
					break;
				case BIT_VAL_00000010B:
					SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_YES);		/*道岔引导总锁闭状态*/
					break;
				default:
					/*不可达分支*/
					break;
				}
				switch (dLockState)
				{
				case BIT_VAL_00000001B:
					SetOtherCiSwitchLockStatus(switchId, SWITCH_LOCK_STATUS_NO);		/*道岔未单锁状态*/
					break;
				case BIT_VAL_00000010B:
					SetOtherCiSwitchLockStatus(switchId, SWITCH_LOCK_STATUS_DANSUO);  /*道岔单锁状态*/
					break;
				default:
					/*不可达分支*/
					break;
				}
				switch (fLockState)
				{
				case BIT_VAL_00000001B:
					SetSwitchFLockState(switchId, SWITCH_LOCK_FENGSUO_NO);		/*道岔未封锁状态*/
					break;
				case BIT_VAL_00000010B:
					SetSwitchFLockState(switchId, SWITCH_LOCK_FENGSUO_YES);		/*道岔封锁状态*/
					break;
				default:
					/*不可达分支*/
					break;
				}
			}
			else
			{
				;
			}
		}
		retValue = CI_SUCCESS;
	}
	else
	{
		retValue = CI_ERROR;
	}

	*pItemLen = parsedLen;
	return retValue;
}

/*
功能描述:
组道岔数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
const UINT8 dstCiId:目标联锁ID
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackSwitchPacket(UINT8 *pInputBuf, UINT16 *pItemLen,const UINT8 dstCiId)
{
	UINT8 deviceSum = 0u;			/*设备总数*/

	UINT8 localCi = 0u;				/*本机联锁ID*/
	UINT16 switchId = 0u;			/*道岔id*/
	UINT8 curPosition = 0u;			/*道岔位置*/
	UINT8 yLockState = 0u;			/*道岔引导总锁闭状态*/
	UINT8 dLockState = 0u;			/*道岔单锁状态*/
	UINT8 fLockState = 0u;			/*道岔封锁状态*/

	UINT16 deviceSumIndex = 0u;		/*设备总数游标位置*/
	UINT16 packedLen = 0u;
	UINT16 i = 0u;
	UINT8 retValue = CI_ERROR;
	CiTransmitStruct *pTmpCiTransInfo = NULL;

	localCi = GetSystemParaLocalCiId();								/*获取本机联锁ID*/
	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);

	if (NULL != pTmpCiTransInfo)
	{
		*(pInputBuf + packedLen) = (UINT8)pTmpCiTransInfo->switchNum;

		packedLen += 1u;

		for (i = 0u; i < pTmpCiTransInfo->switchNum; i++)
		{
			switchId = pTmpCiTransInfo->switchIdBuf[i];					/*获取道岔ID*/

			if (localCi == GetSwitchBelongCiId(switchId))
			{/*道岔处于本联锁*/
				curPosition = GetSingleSwitchCurPosition(switchId);			/*道岔当前位置*/

				yLockState = GetSwitchYLockState(switchId);				/*道岔引导总锁状态*/

				dLockState = GetSwitchLockStatus(switchId);				/*道岔锁闭状态*/

				fLockState = GetSwitchFLockState(switchId);				/*道岔封锁状态*/

				switch (curPosition)
				{
				case SWITCH_POSITION_DINGWEI:
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | BIT_VAL_00000001B;		/*道岔定位*/
					break;
				case  SWITCH_POSITION_FANWEI:
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | BIT_VAL_00000010B;		/*道岔反位*/
					break;
				case SWITCH_POSITION_SIKAI:
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | BIT_VAL_00000000B;		/*道岔四开*/
					break;
				default:
					/*不可达分支*/
					break;
				}

				switch (yLockState)
				{
				case SWITCH_LOCK_YINZONG_NO:
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 2u));/*道岔未引导总锁状态*/
					break;
				case SWITCH_LOCK_YINZONG_YES:
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 2u));/*道岔引导总锁状态*/
					break;
				default:
					/*不可达分支*/
					break;
				}

				switch (dLockState)
				{
				case SWITCH_LOCK_STATUS_NO:
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 4u));/*道岔未单锁状态*/
					break;
				case SWITCH_LOCK_STATUS_DANSUO:
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 4u));/*道岔单锁状态*/
					break;
				default:
					/*不可达分支*/
					break;
				}

				switch (fLockState)
				{
				case SWITCH_LOCK_FENGSUO_NO:
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 6u));/*道岔封锁状态*/
					break;
				case SWITCH_LOCK_FENGSUO_YES:
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 6u));/*道岔封锁状态*/
					break;
				default:
					/*不可达分支*/
					break;
				}
			}
			else
			{
				/*非本联锁信息不发送*/
			}

			packedLen += 1u;
			deviceSum += 1u;

		}

		pInputBuf[deviceSumIndex] = deviceSum;			/*填入道岔数量*/
		*pItemLen = packedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
解析物理区段状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParsePhySecPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId)
{
	UINT8 deviceSum = 0u;		/*物理区段数量*/
	UINT16 phySectionId = 0u;		/*物理区段ID*/
	UINT8 dataBuf1 = 0u;
	UINT8 dataBuf2 = 0u;
	UINT8 curCollState = 0u;			/*占用*/
	UINT8 routeLockState = 0u;		/*进路锁闭状态*/
	UINT8 protectLockState = 0u;		/*保护锁闭状态*/
	UINT8 exceptLockState = 0u;		/*故障锁闭状态*/
	UINT8 arbState = 0u;				/*区段ARB状态*/
	UINT8 fLockState = 0u;		/*区段 封锁状态*/
	UINT8 lockDirection = 0u;	/*区段锁闭方向*/
	UINT8 directionState = 0u;

	UINT8 localCiId = 0u;
	UINT8 belongCiId = 0u;

	UINT8 phySecInd = 0u;
	UINT16 parsedLen = 0u;
	UINT8 retValue = CI_ERROR;
	UINT16 bufInd = 0u;

	UINT16 *proRouteIdS = NULL;
	UINT8 proRouteIdSum = 0u;
	UINT8 i = 0u;/*进路ID遍历索引*/
	UINT16 tempRouteId = 0u;
	UINT8 routeState = 0u;

	PhysicalSectionDataStruct * pPhySecDataStru = NULL;

	const CiTransmitStruct* pCiRecptStru = NULL;

	localCiId = GetSystemParaLocalCiId();
	pCiRecptStru = GetSrcCiTransInfo(srcCiId);

	deviceSum = *(pInputData + parsedLen);
	parsedLen += 1u;

	if(NULL == pCiRecptStru)
	{
		*pItemLen = 0u;
		retValue = CI_ERROR; /*数据获取失败*/
	}
	else if (deviceSum == pCiRecptStru->phySecNum)
	{
		pPhySecDataStru = GetPhySecData();

		for (phySecInd = 0u; phySecInd < pCiRecptStru->phySecNum; phySecInd++)
		{
			dataBuf1 = *(pInputData + parsedLen); 			/*物理区段byte1信息包获取*/
			dataBuf2 = *(pInputData + parsedLen + 1u); 			/*物理区段byte2信息包获取*/

			parsedLen += 2u;

			phySectionId = pCiRecptStru->phySecIdBuf[phySecInd];								/*获取物理ID*/

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

			(pPhySecDataStru + bufInd)->PhysicalSectionId = phySectionId;	/*物理区段当前融合状态*/

			belongCiId = GetPhySecBelongCiId(phySectionId);

			if (localCiId != belongCiId)
			{
				curCollState = (dataBuf1 & BIT_MASK_00000011B);										/*区段占用状态*/
				routeLockState = ((dataBuf1 >> 2u) & BIT_MASK_00000011B);								/*区段 进路锁闭状态*/
				protectLockState = ((dataBuf1 >> 4u) & BIT_MASK_00000011B);							/*区段 保护锁闭状态*/
				exceptLockState = ((dataBuf1 >> 6u) & BIT_MASK_00000011B);								/*区段 故障锁闭状态*/
				arbState = (dataBuf2 & BIT_MASK_00000011B);											/*区段ARB状态*/
				fLockState = ((dataBuf2 >> 2u) & BIT_MASK_00000011B);									/*区段 封锁状态*/
				lockDirection = ((dataBuf2 >> 4u) & BIT_MASK_00000011B);								/*区段 锁闭方向*/

				switch (curCollState)
				{
					case BIT_VAL_00000000B:
						SetPhySecCurOccupyState(phySectionId, SECTION_OCCUPY_YES);
						SetPhySecCurMergeState(phySectionId, SECTION_OCCUPY_YES);
						break;
					case BIT_VAL_00000010B:
						SetPhySecCurOccupyState(phySectionId, SECTION_OCCUPY_NO);
						SetPhySecCurMergeState(phySectionId, SECTION_OCCUPY_NO);
						break;
					default:
						/*不可达分支*/
						break;
				}

				/*区段保护锁闭状态*/
				switch (protectLockState)
				{
					case BIT_VAL_00000001B:
						protectLockState = PHYSICAL_SECTION_LOCK_NO;
						break;
					case BIT_VAL_00000010B:
						protectLockState = PHYSICAL_SECTION_LOCK_PROTECT;
						break;
					default:
						break;
				}

				/*区段进路锁闭状态*/
				switch (routeLockState)
				{
					case BIT_VAL_00000001B:
						routeLockState = PHYSICAL_SECTION_LOCK_NO;
						break;
					case BIT_VAL_00000010B:
						routeLockState = PHYSICAL_SECTION_LOCK_NORMAL;
						break;
					default:
						break;
				}

				/*区段 ARB状态*/
				switch (arbState)
				{
				case BIT_VAL_00000001B:
					SetPhySecArbState(phySectionId, AXIS_SECTION_ARB_YES);
					SetPhyContainAxisSecArbState(phySectionId, AXIS_SECTION_ARB_YES);
					break;
				case BIT_VAL_00000010B:
					SetPhySecArbState(phySectionId, AXIS_SECTION_ARB_NO);
					SetPhyContainAxisSecArbState(phySectionId, AXIS_SECTION_ARB_NO);
					break;
				default:
					/*不可达分支*/
					break;
				}

				/*区段 封锁状态*/
				switch (fLockState)
				{
					case BIT_VAL_00000001B:
						(void)SetPhySecFLockState(phySectionId, PHYSICAL_SECTION_FLOCK_YES);
						break;
					case BIT_VAL_00000010B:
						(void)SetPhySecFLockState(phySectionId, PHYSICAL_SECTION_FLOCK_NO);
						break;
					default:
						/*不可达分支*/
						break;
				}

				/*区段锁闭方向*/
				switch (lockDirection)
				{
					case BIT_VAL_00000001B:
						directionState = CI_SYSTEM_DIRECTION_UP;
						break;
					case BIT_VAL_00000010B:
						directionState = CI_SYSTEM_DIRECTION_DOWN;
						break;
					case BIT_VAL_00000000B:
						directionState = CI_SYSTEM_DIRECTION_NONE;
						break;
					default:
						/*不可达分支*/
						break;
				}

				/*区段故障锁闭*/
				switch (exceptLockState)
				{
					case BIT_VAL_00000001B:
						exceptLockState = PHYSICAL_SECTION_LOCK_NO;
						break;
					case BIT_VAL_00000010B:
						exceptLockState = PHYSICAL_SECTION_LOCK_EXCEPT;
						break;
					default:
						break;
				}

				/*结合物理区段的三种锁闭状态，更新物理区段的锁闭状态*/
				/*首先设置为未锁闭*/
				SetPhySecLockStateHlht(phySectionId, PHYSICAL_SECTION_LOCK_NO);
				SetPhySecLockDirHlht(phySectionId, directionState);

				if (PHYSICAL_SECTION_LOCK_PROTECT == protectLockState)
				{
					SetPhySecLockStateHlht(phySectionId, PHYSICAL_SECTION_LOCK_PROTECT);

					/*需判断是否是为本CI的进路锁闭的*/
					proRouteIdS = GetPhySecProLockRouteIdBuf(phySectionId);
					proRouteIdSum = GetPhySecProLockRouteSum(phySectionId);

					for (i = 0u;i < proRouteIdSum;i++)
					{
						tempRouteId = proRouteIdS[i];

						if (GetRouteBelongCiId(tempRouteId) == localCiId)
						{
							routeState = GetRouteState(tempRouteId);
							if ((ROUTE_STATE_IDLE != routeState) && (GetRouteDirection(tempRouteId) == directionState))
							{
								SetPhySecPLockRouteIdHlht(phySectionId, tempRouteId);
								break;
							}
						}
					}

					if (proRouteIdSum == i)
					{/*说明物理区段保护锁闭所属的进路不是本联锁*/
						SetPhySecPLockRouteIdHlht(phySectionId, UINT16_MAX);
					}
				}
				else
				{
					SetPhySecPLockRouteIdHlht(phySectionId, 0u);
				}

				/*正常锁闭优先级高于防护锁闭*/
				if ((PHYSICAL_SECTION_LOCK_NORMAL == routeLockState))
				{
					SetPhySecLockStateHlht(phySectionId, PHYSICAL_SECTION_LOCK_NORMAL);
					SetPhySecRLockRouteIdHlht(phySectionId, UINT16_MAX);
				}
				else
				{
					SetPhySecRLockRouteIdHlht(phySectionId, 0u);
				}

				/*异常锁闭的优先级最高*/
				if (PHYSICAL_SECTION_LOCK_EXCEPT==exceptLockState)
				{
					SetPhySecLockStateHlht(phySectionId, PHYSICAL_SECTION_LOCK_EXCEPT);
				}
			}
			else
			{
				;
			}
		}

		*pItemLen = parsedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
组物理区段数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackPhySecPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId)
{
	UINT8 deviceSum = 0u;			/*设备总数*/

	UINT8 localCi = 0u;					/*本机联锁ID*/
	UINT16 phySectionId = 0xFFFFu;		/*物理区段id*/
	UINT8 curCollState = 0u;				/*占用*/
	UINT8 PhySecLockState = 0u;            /*锁闭状态*/
	UINT8 arbState = 0u;					/*区段ARB状态*/
	UINT8 fLockState = 0u;				/*区段 封锁状态*/
	UINT8 lockDirection = 0u;			/*区段锁闭方向*/
	UINT16 i = 0u;
	UINT16 packedLen = 0u;
	UINT16 deviceSumIndex = 0u;		/*设备总数游标位置*/
	UINT8 retValue = CI_ERROR;
	CiTransmitStruct *pTmpCiTransInfo = NULL;

	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);

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

	packedLen++;

	if (NULL != pTmpCiTransInfo)
	{
		for (i = 0u; i < pTmpCiTransInfo->phySecNum; i++)
		{
			phySectionId = pTmpCiTransInfo->phySecIdBuf[i];  				/*获取物理区段ID*/

			if (localCi == GetPhySecBelongCiId(phySectionId))
			{/*物理区段处于本联锁*/
				curCollState = GetPhySecCurMergeState(phySectionId);		/*区段占用状态*/
				PhySecLockState = GetPhySecLockState(phySectionId);			/*区段锁闭状态*/
				arbState = GetPhySecArbState(phySectionId);					/*区段ARB状态*/
				fLockState = GetPhySecFLockState(phySectionId);				/*区段封锁状态*/
				lockDirection = GetPhySecLockDirection(phySectionId);		/*区段锁闭方向*/

																			/*区段占用状态*/
				switch (curCollState)
				{
					case SECTION_OCCUPY_YES:
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | (BIT_VAL_00000000B);
						break;
					case SECTION_OCCUPY_NO:
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | (BIT_VAL_00000010B);
						break;
					default:
						/*不可达分支*/
						break;
				}

				/*区段锁闭状态*/
				if (PhySecLockState == PHYSICAL_SECTION_LOCK_EXCEPT)
				{/*物理区段故障锁闭*/
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 6u));
				}
				else
				{
					*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 6u));				 /*未故障锁闭*/
					switch (PhySecLockState)
					{
						case PHYSICAL_SECTION_LOCK_PROTECT:									 /*物理区段只有保护锁闭*/
							*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 4u));
							*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 2u));
							break;
						case PHYSICAL_SECTION_LOCK_NO:										/*物理区段未锁闭*/
							*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 4u));
							*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 2u));
							break;
						case PHYSICAL_SECTION_LOCK_NORMAL:
							if (0U != GetPhySecPLockBelongRouteId(phySectionId))
							{/*物理区段同时存在进路锁闭和保护锁闭*/
								*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 4u));
								*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 2u));
							}
							else
							{/*物理区段正常锁闭*/
								*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 4u));
								*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 2u));
							}
							break;
						default:
							/*不可达分支*/
							break;
					}
				}


				/*区段ARB状态*/
				switch (arbState)
				{
					case AXIS_SECTION_ARB_YES:
						*(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | (BIT_VAL_00000001B);
						break;
					case AXIS_SECTION_ARB_NO:
						*(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | (BIT_VAL_00000010B);
						break;
					default:
						/*不可达分支*/
						break;
				}

				/*区段封锁状态*/
				switch (fLockState)
				{
					case PHYSICAL_SECTION_FLOCK_YES:
						*(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000001B << 2u));
						break;
					case PHYSICAL_SECTION_FLOCK_NO:
						*(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000010B << 2u));
						break;
					default:
						/*不可达分支*/
						break;
				}

				/*区段锁闭方向*/
				switch (lockDirection)
				{
					case CI_SYSTEM_DIRECTION_UP:
						*(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000001B << 4u));
						break;
					case CI_SYSTEM_DIRECTION_DOWN:
						*(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000010B << 4u));
						break;
					case CI_SYSTEM_DIRECTION_NONE:
						*(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000000B << 4u));
						break;
					default:
						break;
				}
			}
			else
			{
				/*非本联锁信息不发送*/
			}

			packedLen += 2u;

			deviceSum += 1u;
		}

		pInputBuf[deviceSumIndex] = deviceSum;
		*pItemLen = packedLen;

		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
解析逻辑区段状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParseLogSecPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId)
{

	UINT8 deviceSum = 0u;		/*逻辑区段数量*/
	UINT16 logSecId = 0u; 	    /*逻辑区段ID*/

	UINT8 retValue = CI_ERROR;
	UINT8 logSecInd = 0u;               /*游标*/
	UINT8 dataBuf1 = 0u;
	UINT8 dataBuf2 = 0u;
	UINT8 localCiId = 0u;
	UINT8 belongCiId = 0u;

	UINT8 lockDirection = 0u;			/*锁闭方向*/
	UINT8 protectionLockState = 0u;		/*保护锁闭状态*/
	UINT8 sectionRouteLockState = 0u;	/*区段进路锁闭状态*/
	UINT8 sectionOccupyState = 0u;		/*区段占用状态*/
	UINT8 sectionFlockState = 0u;		/*区段封锁状态*/
	UINT8 faultLockState = 0u;			/*故障锁闭状态*/
	UINT16 bufInd = 0u;
	LogicSectionDataStruct * pLogSecDataStru = NULL;
	const CiTransmitStruct* pCiRecptStru = NULL;
	UINT16 parsedLen = 0u;
	UINT16 wLogSecBelPhySecId = 0U;/*逻辑区段关联物理区段ID*/
	UINT16* proRouteIdS = NULL;
	UINT8 proRouteIdSum = 0u;
	UINT8 ii = 0u;/*进路ID遍历索引*/
	UINT16 tempRouteId = 0u;
	UINT8 chRouteState = 0U;/*进路状态*/
	UINT8 chRouteBelCiId = 0U;/*进路所属联锁ID*/
	UINT8 chRouteDir = 0U;/*进路方向*/

	localCiId = GetSystemParaLocalCiId();
	pCiRecptStru = GetSrcCiTransInfo(srcCiId);

	deviceSum = *(pInputData + parsedLen);
	parsedLen += 1u;

	if(NULL == pCiRecptStru)
	{
		*pItemLen = 0u;
		retValue = CI_ERROR; /*数据获取失败*/
	}
	else if (deviceSum == pCiRecptStru->logicSecNum)
	{
		pLogSecDataStru = GetLogicSecData();

		for (logSecInd = 0u; logSecInd < pCiRecptStru->logicSecNum; logSecInd++)
		{
			dataBuf1 = *(pInputData + parsedLen); 						/*逻辑区段状态信息包获取*/

			dataBuf2 = *(pInputData + parsedLen + 1u);

			parsedLen += 2u;

			logSecId = pCiRecptStru->logicSecIdBuf[logSecInd]; 				/*获取逻辑区段ID*/

			bufInd = GetlogSectionBufIndex(logSecId);

			(pLogSecDataStru + bufInd)->LogicSectionId = logSecId;

			belongCiId = GetLogSecBelongCiId(logSecId);

			if (localCiId != belongCiId)
			{
				sectionOccupyState = (dataBuf1 & BIT_MASK_00000011B);				/*区段占用状态*/
				sectionRouteLockState = ((dataBuf1 >> 2u) & BIT_MASK_00000011B);		/*区段进路锁闭状态*/
				protectionLockState = ((dataBuf1 >> 4u)& BIT_MASK_00000011B);			/*区段保护锁闭状态*/
				lockDirection = ((dataBuf1 >> 6u) & BIT_MASK_00000011B);				/*区段锁闭方向*/

				sectionFlockState = (dataBuf2 & BIT_MASK_00000011B);					/*区段封锁状态（预留状态）*/
				faultLockState = ((dataBuf2 >> 2u) & BIT_MASK_00000011B);				/*区段故障锁闭状态 */

				switch (sectionOccupyState)
				{
					case BIT_VAL_00000000B:
						SetLogSecPreOccupyState(logSecId, GetLogSecCurCtOrUtOccupyState(logSecId));/*保存逻辑区段之前占用状态*/
						SetLogSecCurOccupyState(logSecId, LOGICSECTION_OCCUPY_UT);/*非CBTC车占用*/
						break;
					case BIT_VAL_00000001B:
						SetLogSecPreOccupyState(logSecId, GetLogSecCurCtOrUtOccupyState(logSecId));/*保存逻辑区段之前占用状态*/
						SetLogSecCurOccupyState(logSecId, LOGICSECTION_OCCUPY_CT);/*CBTC车占用*/
						break;
					case BIT_VAL_00000010B:
						SetLogSecPreOccupyState(logSecId, GetLogSecCurCtOrUtOccupyState(logSecId));/*保存逻辑区段之前占用状态*/
						SetLogSecCurOccupyState(logSecId, LOGICSECTION_OCCUPY_NO);/*空闲*/
						break;
					default:
						/*不可达分支*/
						break;
				}

				SetLogSecLinShiXianSuState(logSecId, LOGSEC_LSXS_SET_STATE_NO);

				/*区段进路锁闭状态*/
				switch (sectionRouteLockState)
				{
				case BIT_VAL_00000001B:
					sectionRouteLockState = LOG_SECTION_LOCK_NO;
					break;
				case BIT_VAL_00000010B:
					sectionRouteLockState = LOG_SECTION_LOCK_NORMAL;
					break;
				default:
					break;
				}

				/*区段保护区段锁闭状态*/
				switch (protectionLockState)
				{
				case BIT_VAL_00000001B:
					protectionLockState = LOG_SECTION_LOCK_NO;
					break;
				case BIT_VAL_00000010B:
					protectionLockState = LOG_SECTION_LOCK_PROTECT;
					break;
				default:
					break;
				}


				/*区段锁闭方向*/
				switch (lockDirection)
				{
				case BIT_VAL_00000001B:
					lockDirection = CI_SYSTEM_DIRECTION_UP;
					break;
				case BIT_VAL_00000010B:
					lockDirection = CI_SYSTEM_DIRECTION_DOWN;
					break;
				case BIT_VAL_00000000B:
					lockDirection = CI_SYSTEM_DIRECTION_NONE;
					break;
				default:
					break;
				}

				
				/*区段故障锁闭状态*/
				switch (faultLockState)
				{
				case BIT_VAL_00000001B:
					faultLockState = LOG_SECTION_LOCK_NO;
					break;
				case BIT_VAL_00000010B:
					faultLockState = LOG_SECTION_LOCK_EXCEPT;
					break;
				default:
					break;
				}

				/*结合逻辑区段的三种锁闭状态，更新锁闭状态*/
				/*首先设置为未锁闭*/
				SetLogSecLockStateHlht(logSecId, LOG_SECTION_LOCK_NO);
				SetLogSecLockDirHlht(logSecId, lockDirection);

				if (LOG_SECTION_LOCK_PROTECT == protectionLockState)
				{
					SetLogSecLockStateHlht(logSecId, LOG_SECTION_LOCK_PROTECT);

					wLogSecBelPhySecId = GetLgcSecRelativePhySecId(logSecId);

					/*需判断是否是为本CI的进路锁闭的*/
					proRouteIdS = GetPhySecProLockRouteIdBuf(wLogSecBelPhySecId);
					proRouteIdSum = GetPhySecProLockRouteSum(wLogSecBelPhySecId);

					for (ii = 0u; ii < proRouteIdSum; ii++)
					{
						tempRouteId = proRouteIdS[ii];
						chRouteBelCiId = GetRouteBelongCiId(tempRouteId);

						if (localCiId == chRouteBelCiId)
						{
							chRouteState = GetRouteState(tempRouteId);
							chRouteDir = GetRouteDirection(tempRouteId);

							if ((ROUTE_STATE_IDLE != chRouteState) && (chRouteDir == lockDirection))
							{
								SetLogSecPLockRouteIdHlht(logSecId, tempRouteId);
								break;
							}
						}
					}

					if (proRouteIdSum == ii)
					{/*说明物理区段保护锁闭所属的进路不是本联锁*/
						SetLogSecPLockRouteIdHlht(logSecId, UINT16_MAX);
					}
				}
				else
				{
					SetLogSecPLockRouteIdHlht(logSecId, 0U);
				}

				/*正常锁闭优先级高于防护锁闭*/
				if ((LOG_SECTION_LOCK_NORMAL == sectionRouteLockState))
				{
					SetLogSecLockStateHlht(logSecId, LOG_SECTION_LOCK_NORMAL);
					SetLogSecRLockRouteIdHlht(logSecId, UINT16_MAX);
				}
				else
				{
					SetLogSecRLockRouteIdHlht(logSecId, 0u);
				}

				/*异常锁闭的优先级最高*/
				if (LOG_SECTION_LOCK_EXCEPT == faultLockState)
				{
					SetLogSecLockStateHlht(logSecId, LOG_SECTION_LOCK_EXCEPT);
				}

			}
			else
			{
				;
			}
		}

		*pItemLen = parsedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
组逻辑区段数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackLogSecPacket(UINT8 *pInputBuf, UINT16 *pItemLen,const UINT8 dstCiId)
{
	UINT8 deviceSum = 0u;			/*设备总数*/

	UINT8 localCi = 0u;					/*本机联锁ID*/
	UINT16 logSectionId = 0u;		/*逻辑区段id*/
	UINT16 phySecId = 0u;
	UINT8 lockDirection = 0u;			/*区段锁闭方向*/
	UINT8 protectLockState = 0u;			/*保护锁闭状态*/
	UINT8 routeLockState = 0u;			/*进路锁闭状态*/
	UINT8 occupyState = 0u;				/*占用*/
	UINT8 exceptLockState = 0u;			/*故障锁闭状态*/
	UINT8 fLockState = 0u;				/*区段 封锁状态*/
	UINT8 phySecLockState = 0u;

	UINT16 logSecIx = 0u;
	UINT16 packedLen = 0u;
	UINT16 deviceSumIndex = 0u;		/*设备总数游标位置*/
	UINT8 retValue = CI_ERROR;
	CiTransmitStruct *pTmpCiTransInfo = NULL; 
	UINT16 plockRouteId = 0u;
	UINT16 rlockRouteId = 0u;

	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);
	localCi = GetSystemParaLocalCiId();								/*获取本机联锁ID*/

	packedLen++;

	if (NULL != pTmpCiTransInfo)
	{
		for (logSecIx = 0u; logSecIx < pTmpCiTransInfo->logicSecNum; logSecIx++)
		{
			logSectionId = pTmpCiTransInfo->logicSecIdBuf[logSecIx];  				/*获取逻辑区段ID*/

			if (localCi == GetLogSecBelongCiId(logSectionId))
			{/*逻辑区段处于本联锁*/

				phySecId = GetLgcSecRelativePhySecId(logSectionId);

				phySecLockState = GetLogSecLockState(logSectionId);

				lockDirection = GetLogSecLockDir(logSectionId);

				plockRouteId = GetLogSecPLockRouteId(logSectionId);

				if(0u == plockRouteId)
				{
					protectLockState = LOG_SECTION_LOCK_NO;
				}
				else
				{
					protectLockState = LOG_SECTION_LOCK_PROTECT;
				}

				rlockRouteId = GetLogSecLockBelongRoute(logSectionId);

				if(0u == rlockRouteId)
				{
					routeLockState = LOG_SECTION_LOCK_NO;
				}
				else
				{
					routeLockState = LOG_SECTION_LOCK_NORMAL;
				}

				occupyState = GetLogSecCurCtOrUtOccupyState(logSectionId);

				if(LOG_SECTION_LOCK_EXCEPT != phySecLockState)
				{
					exceptLockState = LOG_SECTION_LOCK_NO;
				}
				else
				{
					exceptLockState = LOG_SECTION_LOCK_EXCEPT;
				}

				fLockState = GetPhySecFLockState(phySecId);

				/*区段占用状态*/
				switch (occupyState)
				{
					case LOGICSECTION_OCCUPY_UT:
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000000B << 0u));
						break;
					case LOGICSECTION_OCCUPY_CT:
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 0u));
						break;
					case LOGICSECTION_OCCUPY_NO:
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 0u));
						break;
					default:
						break;
				}

				switch (routeLockState)
				{
					case LOG_SECTION_LOCK_NO:										/*逻辑区段未锁闭*/
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 2u));
						break;
					case LOG_SECTION_LOCK_NORMAL:
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 2u));
						break;
					default:
						break;
				}

				switch (protectLockState)
				{
					case LOG_SECTION_LOCK_NO:										/*逻辑区段所在未锁闭*/
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 4u));
						break;
					case LOG_SECTION_LOCK_PROTECT: 								 /*逻辑区段保护锁闭*/
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 4u));
						break;
					default:
						break;
				}

				/*区段锁闭方向*/
				switch (lockDirection)
				{
					case CI_SYSTEM_DIRECTION_UP:
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 6u));
						break;
					case CI_SYSTEM_DIRECTION_DOWN:
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 6u));
						break;
					case CI_SYSTEM_DIRECTION_NONE:
						*(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000000B << 6u));
						break;
					default:
						break;
				}

				/*区段封锁状态*/
				switch (fLockState)
				{
					case PHYSICAL_SECTION_FLOCK_YES:
						*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000001B << 0u));
						break;
					case PHYSICAL_SECTION_FLOCK_NO:
						*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000010B << 0u));
						break;
					default:
						break;
				}

				/*区段故障锁闭状态*/
				switch (exceptLockState)
				{
					case LOG_SECTION_LOCK_NO:
						*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000001B << 2u));
						break;
					case LOG_SECTION_LOCK_EXCEPT:
						*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000010B << 2u));
						break;
					default:
						break;
				}
			}
			else
			{
				/*非本联锁信息不发送*/
			}

			packedLen += 2u;

			deviceSum += 1u;
		}
		pInputBuf[deviceSumIndex] = deviceSum;
		*pItemLen = packedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
解析信号机状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParseSignalPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId)
{
	UINT8 deviceSum = 0u;			/*信号机数量*/
	UINT16 signalId = 0u; 			/*信号机ID*/
	UINT8 dataByte1 = 0u;
	UINT8 dataByte2 = 0u;
	UINT8 dataByte3 = 0u;
	UINT8 sigPLockCmd = 0u;
	UINT8 showColor = 0u;				/*信号机显示状态*/
	UINT8 sigColor = 0u;				/*信号机显示状态*/
	UINT8 fLockState = 0u;			/*信号机封锁状态*/
	UINT8 overlapValid = 0u;			/*保护区段有效性*/
	UINT8 nearLock = 0u;
	UINT8 sigExtStat = 0u;			/*信号机亮灭状态*/
	
	UINT8 localCiId = 0u;
	UINT8 belongCiId = 0u;

	UINT8 sigInd = 0u;
	UINT16 parsedLen = 0u;
	UINT8 retValue = CI_ERROR;
	UINT16 bufInd = 0u;
	const CiTransmitStruct* pCiRecptStru = NULL;
	SignalDataStruct * pSignalDataStru = NULL;

	UINT16 sigOutSec = 0u;/*信号机外方物理区段*/
	UINT16 sigOutSecCi = 0u;/*信号机外方物理区段所属CI*/

	localCiId = GetSystemParaLocalCiId();
	pCiRecptStru = GetSrcCiTransInfo(srcCiId);

	deviceSum = *(pInputData + parsedLen);
	parsedLen += 1u;
	if(NULL == pCiRecptStru)
	{
		*pItemLen = 0u;
		retValue = CI_ERROR; /*数据获取失败*/
	}
	else if (deviceSum == pCiRecptStru->signalNum)
	{
		pSignalDataStru = GetSignalData();

		for (sigInd = 0u; sigInd < pCiRecptStru->signalNum; sigInd++)
		{
			dataByte1 = *(pInputData + parsedLen);	/*信号机显示状态*/

			dataByte2 = *(pInputData + parsedLen + 1);

			dataByte3 = *(pInputData + parsedLen + 2);

			parsedLen += 3u;

			signalId = pCiRecptStru->signalIdBuf[sigInd];

			bufInd = GetSignalConfigBufIndex(signalId);

			pSignalDataStru[bufInd].SignalId = signalId;

			sigColor = dataByte1;
			sigExtStat = ((dataByte2 >> 0u) & BIT_MASK_00000011B); 	/*信号机亮灭状态*/
			fLockState = ((dataByte2 >> 2u) & BIT_MASK_00000011B);		/*信号机封锁状态*/
			nearLock = ((dataByte2 >> 4u) & BIT_MASK_00000011B);			/*接近锁闭*/
			sigPLockCmd = ((dataByte2 >> 6u) & BIT_MASK_00000011B);		/*信号机保护区段锁闭命令*/
			overlapValid = ((dataByte3 >> 0u) & BIT_MASK_00000011B); 	/*保护区段有效性*/

			belongCiId = GetSignalBelongCiId(signalId);

			if (localCiId != belongCiId)
			{
				switch(sigColor)
				{/*颜色显示判断*/
					case BIT_VAL_00000000B:/*断丝*/
						sigColor = SIGNAL_SHOWCOLOUR_REDBREAK;
						break;
					case BIT_VAL_00010001B:/*红灯*/
						sigColor = SIGNAL_SHOWCOLOUR_RED;
						break;
					case BIT_VAL_00010010B:/*黄灯*/
						sigColor = SIGNAL_SHOWCOLOUR_YELLOW;
						break;
					case BIT_VAL_00010100B:/*绿灯*/
						sigColor = SIGNAL_SHOWCOLOUR_GREEN;
						break;
					case BIT_VAL_00011000B:/*红黄灯*/
						sigColor = SIGNAL_SHOWCOLOUR_REDYELLOW;
						break;
					default:
						sigColor = SIGNAL_SHOWCOLOUR_REDBREAK;
						break;
				}

				switch(sigExtStat)
				{
					case BIT_VAL_00000001B:
						sigExtStat = SIGNAL_LIGHT_EXTICT_STATE_NO;	/*信号机灭灯*/
						break;
					case BIT_VAL_00000010B:
						sigExtStat = SIGNAL_LIGHT_EXTICT_STATE_YES;	/*信号机亮灯*/
						break;
					default:
						/*不可达分支*/
						break;
				}

				if(SIGNAL_SHOWCOLOUR_RED == sigColor)
				{
					if(SIGNAL_LIGHT_EXTICT_STATE_NO == sigExtStat)
					{
						showColor = SIGNAL_SHOWCOLOUR_RED;
					}
					else
					{
						showColor = SIGNAL_SHOWCOLOUR_REDCLOSE;
					}					
				}
				else if(SIGNAL_SHOWCOLOUR_YELLOW == sigColor)
				{
					if(SIGNAL_LIGHT_EXTICT_STATE_NO == sigExtStat)
					{
						showColor = SIGNAL_SHOWCOLOUR_YELLOW;
					}
					else
					{
						showColor = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;
					}	
				}
				else if(SIGNAL_SHOWCOLOUR_GREEN == sigColor)
				{
					if(SIGNAL_LIGHT_EXTICT_STATE_NO == sigExtStat)
					{
						showColor = SIGNAL_SHOWCOLOUR_GREEN;
					}
					else
					{
						showColor = SIGNAL_SHOWCOLOUR_GREENCLOSE;
					}	
				}
				else if(SIGNAL_SHOWCOLOUR_REDYELLOW == sigColor)
				{
					showColor = SIGNAL_SHOWCOLOUR_REDYELLOW;
				}
				else if(SIGNAL_SHOWCOLOUR_REDBREAK == sigColor)
				{
					showColor = SIGNAL_SHOWCOLOUR_REDBREAK;
				}
				else
				{
					showColor = SIGNAL_SHOWCOLOUR_REDBREAK;					
				}
					

				(void)SetSignalCurColor(signalId, showColor);

				switch(fLockState)
				{
					case BIT_VAL_00000001B:
						SetSignalFLockState(signalId, SIGNAL_FENGSUO_YES);						/*信号机封锁*/
						break;
					case BIT_VAL_00000010B:
						SetSignalFLockState(signalId, SIGNAL_FENGSUO_NO);						/*信号机未封锁*/
						break;
					default:
						/*不可达分支*/
						break;
				}

				switch(sigPLockCmd)
				{
					case BIT_VAL_00000001B:
						break;
					case BIT_VAL_00000010B:
						break;
					default:
						/*不可达分支*/
						break;
				}

				sigOutSec = GetSignalOutFirstPhySecId(signalId);
				sigOutSecCi = GetPhySecBelongCiId(sigOutSec);

				if (sigOutSecCi == localCiId)
				{/*说明信号机是跨站信号机，才需要更新信号机保护区段有效性*/
					switch (overlapValid)
					{
					case BIT_VAL_00000001B:
						SetSignalProSecValid(signalId, SIGNAL_PRO_SEC_VALID);
						break;
					case BIT_VAL_00000010B:
						SetSignalProSecValid(signalId, SIGNAL_PRO_SEC_INVALID);
						break;
					default:
						SetSignalProSecValid(signalId, SIGNAL_PRO_SEC_INVALID);/*其它值都认为是无效，导向安全*/
						break;
					}
				}
			}
			else
			{
				switch (sigPLockCmd)
				{
					case BIT_VAL_00000001B:
						SetSignalPLockCommand(signalId, SIGNAL_PLOCK_CMD_CREATE);
						break;
					case BIT_VAL_00000010B:
						SetSignalPLockCommand(signalId, SIGNAL_PLOCK_CMD_CANCEL);
						break;
					case BIT_VAL_00000000B:
						SetSignalPLockCommand(signalId, SIGNAL_PLOCK_CMD_NONE);
						break;
					default:
						break;
				}
			}
		}
		*pItemLen = parsedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
组信号机数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackSignalPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId)
{
	UINT8 deviceSum = 0u;			/*设备总数*/

	UINT8 localCi = 0u;				/*本机联锁ID*/
	UINT16 signalId = 0u; 			/*信号机ID*/
	UINT8 curColor = 0u;				/*信号机显示状态*/
	UINT8 lightExtinctState = 0u; 	/*信号机亮灭状态*/
	UINT8 fLockState = 0u;			/*信号机封锁状态*/

	UINT16 sigInd = 0u;
	UINT16 packedLen = 0u;
	UINT8 retValue = CI_ERROR;
	UINT16 deviceSumIndex = 0u;		/*设备总数游标位置*/
	UINT8 signalPLockCmd = 0u;
	CiTransmitStruct *pTmpCiTransInfo = NULL;
	UINT16 *sigProSecIdBuf = NULL;/*信号机关联的保护区段数组*/
	UINT8 sigProSecSum = 0u;/*信号机关联的保护区段数量*/
	UINT8 tempMaskValue = BIT_VAL_00000010B;/*码位值临时变量*/
	UINT16 ii = 0u;/*用于循环的索引变量*/
	UINT16 tempProSecId = 0u;/*保护区段ID临时变量*/
	UINT8 checkResult = CI_ERROR;/*检查结果临时变量*/
	UINT16 sigOutSec = 0u;/*信号机外方物理区段*/
	UINT16 sigOutSecCi = 0u;/*信号机外方物理区段所属CI*/
	UINT8 sigDsBreakFlag = 0u; /*信号机断丝标志*/

	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);
	localCi = GetSystemParaLocalCiId();								/*获取本机联锁ID*/

	packedLen++;

	if (NULL != pTmpCiTransInfo)
	{
		for (sigInd = 0u; sigInd < pTmpCiTransInfo->signalNum; sigInd++)
		{
			signalId = pTmpCiTransInfo->signalIdBuf[sigInd];							/*获取信号机ID*/

			signalPLockCmd = GetSignalPLockCommand(signalId);

			curColor = GetSignalCurColor(signalId); 						/*信号机当前显示颜色状态*/

			lightExtinctState = GetSignalLightExtinctState(signalId);		/*信号机亮灭状态状态*/

			fLockState = GetSignalFLockState(signalId); 					/*信号机封锁状态*/

			if (localCi == GetSignalBelongCiId(signalId))
			{
				sigDsBreakFlag = GetSignalDsBreakFlag(signalId);

				if(SIGNAL_DS_BREAK_NO == sigDsBreakFlag)
				{
					switch (curColor)
					{
						case SIGNAL_SHOWCOLOUR_REDBREAK:
						case SIGNAL_SHOWCOLOUR_GREENBREAK:
						case SIGNAL_SHOWCOLOUR_YELLOWBREAK:
						case SIGNAL_SHOWCOLOUR_WHITEBREAK:
							*(pInputBuf + packedLen) = BIT_VAL_00000000B;
							break;
						case SIGNAL_SHOWCOLOUR_RED:
						case SIGNAL_SHOWCOLOUR_REDCLOSE:
							*(pInputBuf + packedLen) = BIT_VAL_00010001B;
							break;
						case SIGNAL_SHOWCOLOUR_YELLOW:
						case SIGNAL_SHOWCOLOUR_YELLOWCLOSE:
							*(pInputBuf + packedLen) = BIT_VAL_00010010B;
							break;
						case SIGNAL_SHOWCOLOUR_GREEN:
						case SIGNAL_SHOWCOLOUR_GREENCLOSE:
							*(pInputBuf + packedLen) = BIT_VAL_00010100B;
							break;
						case SIGNAL_SHOWCOLOUR_REDYELLOW:
							*(pInputBuf + packedLen) = BIT_VAL_00011000B;
							break;
						default:
							*(pInputBuf + packedLen) = BIT_VAL_11111111B;
							break;
					}
				}
				else
				{
					*(pInputBuf + packedLen) = BIT_VAL_00000000B;
				}

				switch (curColor)
				{
					case SIGNAL_SHOWCOLOUR_RED:
					case SIGNAL_SHOWCOLOUR_YELLOW:
					case SIGNAL_SHOWCOLOUR_GREEN:
					case SIGNAL_SHOWCOLOUR_REDYELLOW:
						*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000001B << 0u));
						break;
					case SIGNAL_SHOWCOLOUR_REDCLOSE:
					case SIGNAL_SHOWCOLOUR_YELLOWCLOSE:
					case SIGNAL_SHOWCOLOUR_GREENCLOSE:
						*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000010B << 0u));
						break;
					case SIGNAL_SHOWCOLOUR_INVALID:
						*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000000B << 0u));
						break;
					default:
						*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000011B << 0u));
						break;
				}

				switch (fLockState)
				{
					case SIGNAL_FENGSUO_YES:
						*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000001B << 2u));
						break;
					case SIGNAL_FENGSUO_NO:
						*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000010B << 2u));
						break;
					default:
						break;
				}

				/*信号机保护区段锁闭命令,无效*/
				*(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000000B << 6u));

				/*保护区段有效性*/
				sigOutSec = GetSignalOutFirstPhySecId(signalId);
				sigOutSecCi = GetPhySecBelongCiId(sigOutSec);

				sigProSecIdBuf = GetSignalProSecIdBuf(signalId);
				sigProSecSum = GetSignalProSecIdSum(signalId);

				if ((sigOutSecCi == dstCiId)&&(sigProSecSum > 0u) && (sigProSecIdBuf != NULL))
				{
					for (ii = 0u;ii < sigProSecSum;ii++)
					{
						tempProSecId = sigProSecIdBuf[ii];

						checkResult = OverlapValidMaskCheck(tempProSecId);
						if (CI_SUCCESS == checkResult)
						{
							break;
						}
					}

					if (CI_SUCCESS == checkResult)
					{/*说明存在锁闭并能通过检查的保护区段*/
						tempMaskValue = BIT_VAL_00000001B;
					}
					else
					{
						tempMaskValue = BIT_VAL_00000010B;
					}
				}
				else
				{
					tempMaskValue = BIT_VAL_00000010B;
				}

				*(pInputBuf + packedLen + 2u) = *(pInputBuf + packedLen + 2u) | (tempMaskValue << 0u);
			}
			else
			{
				switch (signalPLockCmd)
				{
					case SIGNAL_PLOCK_CMD_CREATE:
						*(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000001B << 6u));
						break;
					case SIGNAL_PLOCK_CMD_CANCEL:
						*(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000010B << 6u));
						break;
					case SIGNAL_PLOCK_CMD_NONE:
						*(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000000B << 6u));
						break;
					default:
						break;
				}

				/*非本联锁其他信息不发送*/
			}

			packedLen += 3u;

			deviceSum++;
		}

		pInputBuf[deviceSumIndex] = deviceSum;

		*pItemLen = packedLen;

		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
解析站台门状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParsePsdPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId)
{
	UINT8 deviceSum = 0u;				/*站台门数量*/
	UINT16 psdId = 0u; 					/*站台门ID*/
	UINT8 doorState = 0u;				/*站台门状态*/
	UINT8 mutualLockState = 0u;			/*旁路状态*/
	UINT8 psdByte = 0u;					/*站台门数据字节*/

	UINT8 localCiId = 0u;				/*本地连锁ID*/
	UINT8 belongCiId = 0u;				/*站台门所属联锁ID*/
	UINT16 inxRem = 0u;					/*索引值余数*/

	UINT16 psdInx = 0u;					/*站台门索引值*/
	UINT16 parsedLen = 0u;				/*已解析字节数*/
	UINT16 offset = 0u;					/*单字节中位偏移*/
	UINT8 retValue = CI_ERROR;			/*返回值*/
	const CiTransmitStruct* pCiRecptStru = NULL;	/*CI-CI通信关系结构体指针*/
	UINT16 bufInx = 0u;								/*站台门动态数据结构索引*/
	PsdDataStruct * pPsdDataStru = NULL;			/*站台门动态数据结构指针*/

	localCiId = GetSystemParaLocalCiId();
	pCiRecptStru = GetSrcCiTransInfo(srcCiId);

	deviceSum = *(pInputData + parsedLen);
	parsedLen += 1u;

	if (NULL == pCiRecptStru)
	{
		*pItemLen = 0u;
		retValue = CI_ERROR; /*数据获取失败*/
	}
	else if (deviceSum == pCiRecptStru->psdNum)
	{
		pPsdDataStru = GetPsdData();

		for (psdInx = 0u; psdInx < pCiRecptStru->psdNum; psdInx++)
		{
			inxRem = psdInx % PSD_NUM_PER_BYTE;

			if (0u == inxRem)
			{
				psdByte = *(pInputData + parsedLen);

				parsedLen += 1u;
			}
			else
			{
				/*不作任何处理*/
				;
			}

			psdId = pCiRecptStru->psdIdBuf[psdInx];

			bufInx = GetPsdConfigBufIndex(psdId);

			(pPsdDataStru + bufInx)->PsdId = psdId;

			belongCiId = GetPsdBelongCiId(psdId);

			if (localCiId != belongCiId)
			{
				offset = inxRem * BIT_NUM_PER_PSD;

				/*站台门开关状态*/
				doorState = ((psdByte >> offset) & BIT_MASK_00000011B);/*offset取值小于等于4恒成立*/
				switch (doorState)
				{
				case BIT_VAL_00000001B:
					(void)SetPsdState(psdId, PSD_STATE_OPEN);
					break;
				case BIT_VAL_00000010B:
					(void)SetPsdState(psdId, PSD_STATE_CLOSE);
					break;
				default:
					/*不可达分支*/
					break;
				}

				/*站台门旁路标志(互锁解除状态)*/
				mutualLockState = ((psdByte >> (offset + 2U)) & BIT_MASK_00000011B);/*offset取值小于等于4恒成立*/
			    
				switch (mutualLockState)
				{
				case BIT_VAL_00000001B:
					(void)SetPsdMutualLockRemoveState(psdId, PSD_MUTUALLOCK_REMOVE_NO);
					break;
				case BIT_VAL_00000010B:
					(void)SetPsdMutualLockRemoveState(psdId, PSD_MUTUALLOCK_REMOVE_YES);
					break;
				default:
					/*不可达分支*/
					break;
				}
			}
			else
			{
				;
			}
		}

		*pItemLen = parsedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
组站台门数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackPsdPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId)
{
	UINT8 localCi = 0u;
	UINT8 deviceSum = 0u;				/*设备总数*/

	UINT16 psdId = 0u; 					/*站台门ID*/
	UINT8 doorState = 0u;				/*站台门状态*/
	UINT8 mutualLockState = 0u;			/*旁路状态*/

	UINT16 packedLen = 0u;
	UINT16 psdInx = 0u;
	UINT16 offset = 0u;
	UINT8 retValue = CI_ERROR;
	UINT16 deviceSumIndex = 0u;		/*设备总数游标位置*/
	UINT16 inxRem = 0u;
	UINT8 * pPsdByte = NULL;
	CiTransmitStruct *pTmpCiTransInfo = NULL;

	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);
	localCi = GetSystemParaLocalCiId();								/*获取本机联锁ID*/

	packedLen += 1u;

	if (NULL != pTmpCiTransInfo)
	{
		for (psdInx = 0u; psdInx < pTmpCiTransInfo->psdNum; psdInx++)
		{
			inxRem = psdInx % PSD_NUM_PER_BYTE;

			if (0u == inxRem)
			{
				pPsdByte = pInputBuf + packedLen;

				packedLen += 1u;
			}
			else
			{
				/*不作任何处理*/
				;
			}

			psdId = pTmpCiTransInfo->psdIdBuf[psdInx];		/*获取站台门ID*/

			if (localCi == GetPsdBelongCiId(psdId))
			{/*处于本联锁*/
				offset = inxRem * BIT_NUM_PER_PSD;

				doorState = GetPsdState(psdId);
				
					switch (doorState)
					{
					case PSD_STATE_OPEN:
						*pPsdByte = *pPsdByte | ((UINT8)(BIT_VAL_00000001B << offset));/*offset取值小于等于4恒成立*/
						break;
					case PSD_STATE_CLOSE:
						*pPsdByte = *pPsdByte | ((UINT8)(BIT_VAL_00000010B << offset));
						break;
					default:
						break;
					}
				
				/*获取旁路状态并组包*/
				mutualLockState = GetPsdMutualLockRemoveState(psdId);
			
					switch (mutualLockState)
					{
					case PSD_MUTUALLOCK_REMOVE_NO:
						*pPsdByte = *pPsdByte | ((UINT8)(BIT_VAL_00000001B << (offset + 2u)));/*offset取值小于等于4恒成立*/
						break;
					case PSD_MUTUALLOCK_REMOVE_YES:
					case PSD_ATS_MUTUALLOCK_REMOVE_YES:
					case PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES:
						*pPsdByte = *pPsdByte | ((UINT8)(BIT_VAL_00000010B << (offset + 2u)));
						break;
					default:
						break;
					}
			
			}
			else
			{
				/*非本联锁信息不发送*/
			}

			deviceSum += 1u;
		}

		pInputBuf[deviceSumIndex] = deviceSum;
		*pItemLen = packedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
解析紧急关闭按钮状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParseEmbtnPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId)
{
	UINT8 deviceSum = 0u;		/*紧急关闭按钮数量*/
	UINT16 esbId = 0u; 			/*紧急关闭按钮ID*/
	UINT8 esbByte = 0u;
	UINT8 esbState = 0u;		/*紧急关闭按钮状态*/

	UINT8 localCiId = 0u;
	UINT8 belongCiId = 0u;

	UINT8 esbInx = 0u;
	UINT8 retValue = CI_ERROR;
	const CiTransmitStruct* pCiRecptStru = NULL;
	UINT16 offset = 0u;
	UINT16 parsedLen = 0u;
	UINT16 inxRem = 0u;

	UINT16 bufInx = 0u;
	EsbDataStruct * pEsbDataStru = NULL;

	localCiId = GetSystemParaLocalCiId();
	pCiRecptStru = GetSrcCiTransInfo(srcCiId);

	deviceSum = *(pInputData + parsedLen);
	parsedLen += 1u;

	if (NULL == pCiRecptStru)
	{
		*pItemLen = 0u;
		retValue = CI_ERROR; /*数据获取失败*/
	}
	else if (deviceSum == pCiRecptStru->esbNum)
	{
		pEsbDataStru = GetEsbData();

		for (esbInx = 0u; esbInx < deviceSum; esbInx++)
		{
			inxRem = esbInx % ESB_NUM_PER_BYTE;

			if (0u == inxRem)
			{
				esbByte = *(pInputData + parsedLen);

				parsedLen += 1u;
			}
			else
			{
				/*不作任何处理*/
				;
			}

			esbId = pCiRecptStru->esbIdBuf[esbInx];

			bufInx = GetEsbConfigBufIndex(esbId);

			(pEsbDataStru + bufInx)->EsbId = esbId;

			belongCiId = GetEsbBelongCiId(esbId);

			if (localCiId != belongCiId)
			{
				offset = inxRem * BIT_NUM_PER_ESB;
				/*offset取值小于等于4恒成立*/
				esbState = ((esbByte >> offset) & BIT_MASK_00000011B);		/*紧急关闭按钮状态*/
				
				switch (esbState)
				{
				case BIT_VAL_00000001B:
					(void)SetEsbState(esbId, ESB_STATE_VALID_YES);
					break;
				case BIT_VAL_00000010B:
					(void)SetEsbState(esbId, ESB_STATE_VALID_NO);
					break;
				default:
					/*不可达分支*/
					break;
				}
			}
			else
			{
				;
			}
		}

		*pItemLen = parsedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
组紧急关闭按钮数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 PackEmbtnPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId)
{
	UINT8 localCi = 0u;
	UINT8 deviceSum = 0u;			/*设备总数*/

	UINT16 esbId = 0u; 			/*紧急关闭按钮ID*/
	UINT8 esbState = 0u;		/*紧急关闭按钮状态*/

	UINT16 offset = 0u;
	UINT16 packedLen = 0u;
	UINT16 esbInx = 0u;
	UINT16 deviceSumIndex = 0u;		/*设备总数游标位置*/
	UINT8 retValue = CI_ERROR;
	CiTransmitStruct *pTmpCiTransInfo = NULL;
	UINT16 inxRem = 0u;
	UINT8 * pEsbByte = NULL;
	
	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);
	localCi = GetSystemParaLocalCiId();								/*获取本机联锁ID*/

	packedLen += 1u;

	if (NULL != pTmpCiTransInfo )
	{

		for (esbInx = 0u; esbInx < pTmpCiTransInfo->esbNum; esbInx++)
		{
			inxRem = esbInx % ESB_NUM_PER_BYTE;

			if (0u == inxRem)
			{
				pEsbByte = pInputBuf + packedLen;

				packedLen += 1u;
			}
			else
			{
				/*不作任何处理*/
				;
			}

			esbId = pTmpCiTransInfo->esbIdBuf[esbInx];				/*获取紧急停车按钮ID*/

			if (localCi == GetEsbBelongCiId(esbId))
			{
				offset = inxRem * BIT_NUM_PER_ESB;

				esbState = GetEsbState(esbId);		/*紧急关闭按钮状态*/
			
				switch (esbState)
				{
				case ESB_STATE_VALID_YES:
				    *pEsbByte = *pEsbByte | ((UINT8)(BIT_VAL_00000001B << offset));/*offset取值小于等于4恒成立*/
				    break;
				case ESB_STATE_VALID_NO:
				    *pEsbByte = *pEsbByte | ((UINT8)(BIT_VAL_00000010B << offset));
					break;
				default:
					/*不可达分支*/
				    break;
					
				}
			}
			else
			{
				/*非本联锁信息不发送*/
			}

			deviceSum++;
		}

		pInputBuf[deviceSumIndex] = deviceSum;
		*pItemLen = packedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}

/*
功能描述:
解析照查状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParseZhaoChaPacket(const UINT8 *pInputData, UINT16 *pItemLen, const UINT8 srcCiId)
{
	UINT8 devSum = 0u;		/*照查继电器数量*/
	UINT16 zcjIdt = 0u; 			/*照查继电器ID*/
	UINT8 zcjByte = 0u;
	UINT8 zcjSta = 0u;		/*照查继电器采集状态*/

	UINT8 localCiId = 0u;
	UINT8 belongCiId = 0u;

	UINT8 zcjInx = 0u;
	UINT8 retVal = CI_ERROR;
	const CiTransmitStruct* pCiRecptStru = NULL;
	UINT16 offset = 0u;
	UINT16 parsedLen = 0u;
	UINT16 inxRem = 0u;

	UINT16 bufInx = 0u;

	pCiRecptStru = GetSrcCiTransInfo(srcCiId);

	devSum = *(pInputData + parsedLen);
	parsedLen += 1u;

	if (NULL == pCiRecptStru)
	{
		*pItemLen = 0u;
		retVal = CI_ERROR; /*数据获取失败*/
	}
	else if (devSum == pCiRecptStru->zcjNum)
	{		
		localCiId = GetSystemParaLocalCiId();

		for (zcjInx = 0u; zcjInx < devSum; zcjInx++)
		{
			inxRem = zcjInx % ZCJ_NUM_PER_BYTE;

			if (0u == inxRem)
			{
				zcjByte = *(pInputData + parsedLen);

				parsedLen += 1u;
			}
			else
			{
				/*不作任何处理*/
				;
			}

			zcjIdt = pCiRecptStru->zcjIdBuf[zcjInx];

			belongCiId = GetRelayBelongCiId(zcjIdt);

			if (localCiId != belongCiId)
			{
				offset = inxRem * BIT_NUM_PER_ZCJ;
			
				/*offset取值小于等于4恒成立*/				
				zcjSta = ((zcjByte >> offset) & BIT_MASK_00000011B);/*照查继电器采集状态*/

				bufInx = GetRelayConfigBufIndex(zcjIdt);	/*获取继电器数组下标*/

				RelayDataStru[bufInx].RelayId = zcjIdt;

				switch (zcjSta)
				{
					case BIT_VAL_00000001B:
						RelayDataStru[bufInx].RelayCollState = RELAY_STATE_DOWN;
						break;
					case BIT_VAL_00000010B:
						RelayDataStru[bufInx].RelayCollState = RELAY_STATE_UP;					
						break;
					default:
						RelayDataStru[bufInx].RelayCollState = RELAY_STATE_DOWN;
						break;
				}
			}
			else
			{
				;
			}
		}

		*pItemLen = parsedLen;
		retVal = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
功能描述:
组照查继电器数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 PackZhaoChaPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId)
{
	UINT8 localCi = 0u;
	UINT8 devSum = 0u;			/*设备总数*/

	UINT16 zcjIdt = 0u; 			/*照查继电器ID*/
	UINT8 zcjSta = 0u;		/*照查继电器采集状态*/

	UINT16 offset = 0u;
	UINT16 packedLen = 0u;
	UINT16 zcjInx = 0u;
	UINT16 devSumInx = 0u;		/*设备总数游标位置*/
	UINT8 retVal = CI_ERROR;
	CiTransmitStruct *pTmpCiTransInfo = NULL;
	UINT16 inxRem = 0u;
	UINT8 * pZcjByte = NULL;
	
	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);
	localCi = GetSystemParaLocalCiId();								/*获取本机联锁ID*/

	packedLen += 1u;

	if (NULL != pTmpCiTransInfo)
	{
		for (zcjInx = 0u; zcjInx < pTmpCiTransInfo->zcjNum; zcjInx++)
		{
			inxRem = zcjInx % ZCJ_NUM_PER_BYTE;

			if(0u == inxRem)
			{
				pZcjByte = pInputBuf + packedLen;		

				packedLen += 1u;
			}
			else
			{
				/*不作任何处理*/
				;
			}

			zcjIdt = pTmpCiTransInfo->zcjIdBuf[zcjInx];				/*获取照查继电器ID*/

			if (localCi == GetRelayBelongCiId(zcjIdt))
			{
				offset = inxRem * BIT_NUM_PER_ZCJ;

				zcjSta = GetRelayCollState(zcjIdt);		/*照查继电器采集状态*/

					switch (zcjSta)
					{
					case RELAY_STATE_DOWN:
						*pZcjByte = *pZcjByte | ((UINT8)(BIT_VAL_00000001B << offset));/*offset取值小于等于4恒成立*/
						break;
					case RELAY_STATE_UP:
						*pZcjByte = *pZcjByte | ((UINT8)(BIT_VAL_00000010B << offset));
						break;
					default:
						break;
				}
			}
			else
			{
				/*非本联锁信息不发送*/
			}

			devSum++;
		}

		pInputBuf[devSumInx] = devSum;
		*pItemLen = packedLen;
		retVal = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retVal = CI_ERROR;
	}

	return retVal;
}


/*
功能描述:
解析防淹门状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
const UINT8 srcCiId 源控区ID
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParseFloodGatePacket(const UINT8 *pInputData, UINT16 *pItemLen, const UINT8 srcCiId)
{
	const CiTransmitStruct* pCiRecptStru = NULL;
	FloodGateDataStruct* pstrFloodGateData = NULL;
	UINT8 cDevSum = 0U;	 /*防淹门数量*/
	UINT16 wParsedLen = 0U;
	UINT8 cLocalCiId = 0U;
	UINT8 cFloodGateIndex = 0U;
	UINT16 wFloodGateId = 0U;  /*防淹门ID*/
	UINT8 cFloodGateBelongCiId = 0U;
	UINT16 wFloodGateIdIndex = 0U;
	UINT8 cFloodGateByte = 0U;
	UINT8 cFloodGateState = 0U;  /*防淹门开/关门状态*/
	UINT8 cFloodGateReqState = 0U;  /*防淹门关门请求状态*/
	UINT8 cFloodGateAllowState = 0U;  /*防淹门允许关门状态*/
	UINT8 cRetVal = CI_ERROR;

	pCiRecptStru = GetSrcCiTransInfo(srcCiId);
	pstrFloodGateData = GetFloodGateData();
	cDevSum = *(pInputData + wParsedLen);
	wParsedLen++;

	if ((NULL == pCiRecptStru) || (NULL == pstrFloodGateData))
	{
		*pItemLen = 0U;
		cRetVal = CI_ERROR;  /*数据获取失败*/
	}
	else if (cDevSum == ((UINT8)pCiRecptStru->floodGateNum))
	{
		cLocalCiId = GetSystemParaLocalCiId();
		
		for (cFloodGateIndex = 0U; cFloodGateIndex < cDevSum; cFloodGateIndex++)
		{
			cFloodGateByte = *(pInputData + wParsedLen);  /*解析当前防淹门状态*/
			wParsedLen++;

			wFloodGateId = pCiRecptStru->floodGateIdBuf[cFloodGateIndex];
			cFloodGateBelongCiId = GetFloodGateBelongCiId(wFloodGateId);
			if (cLocalCiId != cFloodGateBelongCiId)
			{
				wFloodGateIdIndex = GetFloodGateBufIndex(wFloodGateId);
				pstrFloodGateData[wFloodGateIdIndex].FloodGateId = wFloodGateId;

				cFloodGateState = (cFloodGateByte & BIT_MASK_00000011B);  /*防淹门开门/关门状态*/
				switch (cFloodGateState)
				{
				case BIT_VAL_00000010B:
					SetFloodGateCurOpenLockState(wFloodGateId, FLOOD_GATE_OPENLOCK);  /*设置开门*/
					break;
				case BIT_VAL_00000001B:
					SetFloodGateCurOpenLockState(wFloodGateId, FLOOD_GATE_NOT_OPENLOCK);  /*设置关门*/
					break;
				default:
					break;
				}

				cFloodGateReqState = ((cFloodGateByte >> 2U) & BIT_MASK_00000011B);  /*防淹门关门请求状态*/
				switch (cFloodGateReqState)
				{
				case BIT_VAL_00000001B:
					SetFloodGateCurCloseRequestSta(wFloodGateId, FLOOD_GATE_CLOSEREQ);  /*设置有关门请求*/
					break;
				case BIT_VAL_00000010B:
					SetFloodGateCurCloseRequestSta(wFloodGateId, FLOOD_GATE_NOT_CLOSEREQ);  /*设置无关门请求*/
					break;
				default:
					break;
				}

				cFloodGateAllowState = ((cFloodGateByte >> 4U) & BIT_MASK_00000011B);  /*防淹门允许关门状态*/
				switch (cFloodGateAllowState)
				{
				case BIT_VAL_00000001B:
					SetFloodGateCurAgreeCloseSta(wFloodGateId, FLOOD_GATE_AGREE_CLOSE);  /*设置允许关门*/
					break;
				case BIT_VAL_00000010B:
					SetFloodGateCurAgreeCloseSta(wFloodGateId, FLOOD_GATE_NOT_AGREE_CLOSE);  /*设置不允许关门*/
					break;
				default:
					break;
				}
			}
			else
			{
				;/*本联锁设备，不处理*/
			}
		}

		*pItemLen = wParsedLen;
		cRetVal = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0U;
		cRetVal = CI_ERROR;
	}

	return cRetVal;
}

/*
功能描述:
组防淹门状态数据包
输入参数:
UINT8 *pInputData 输入数据指针
const UINT8 dstCiId 目标控区ID
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 PackFloodGatePacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId)
{
	CiTransmitStruct* pTmpCiTransInfo = NULL;
	UINT8 cLocalCiId = 0U;
	UINT16 wPackedLen = 0U;
	UINT16 wFdGateIndex = 0U;
	UINT8* pFloodGateByte = NULL;
	UINT16 wFloodGateId = 0U;  /*防淹门ID*/
	UINT8 cFloodGateBelongCiId = 0U;
	UINT8 cFloodGateState = 0U;  /*防淹门开/关门状态*/
	UINT8 cFloodGateReqState = 0U;  /*防淹门关门请求状态*/
	UINT8 cFloodGateAllowState = 0U;  /*防淹门允许关门状态*/
	UINT8 cRetVal = CI_ERROR;

	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);

	if (NULL != pTmpCiTransInfo)
	{
		cLocalCiId = GetSystemParaLocalCiId();  /*获取本机联锁ID*/
		pInputBuf[wPackedLen] = (UINT8)pTmpCiTransInfo->floodGateNum;  /*组防淹门数量*/
		wPackedLen++;

		for (wFdGateIndex = 0U; wFdGateIndex < pTmpCiTransInfo->floodGateNum; wFdGateIndex++)
		{
			pFloodGateByte = pInputBuf + wPackedLen;

			wFloodGateId = pTmpCiTransInfo->floodGateIdBuf[wFdGateIndex];				/*获取照查继电器ID*/
			cFloodGateBelongCiId = GetFloodGateBelongCiId(wFloodGateId);

			if (cLocalCiId == cFloodGateBelongCiId)
			{
				cFloodGateState = GetFloodGateCurOpenLockState(wFloodGateId);
				switch (cFloodGateState)
				{
				case FLOOD_GATE_OPENLOCK:
					*pFloodGateByte = *pFloodGateByte | BIT_VAL_00000010B;  /*防淹门开启*/
					break;
				case FLOOD_GATE_NOT_OPENLOCK:
					*pFloodGateByte = *pFloodGateByte | BIT_VAL_00000001B;  /*防淹门关闭*/
					break;
				default:
					break;
				}

				cFloodGateReqState = GetFloodGateCurCloseRequestSta(wFloodGateId);
				switch (cFloodGateReqState)
				{
				case FLOOD_GATE_CLOSEREQ:
					*pFloodGateByte = *pFloodGateByte | (BIT_VAL_00000001B << 2U);  /*防淹门有关门请求*/
					break;
				case FLOOD_GATE_NOT_CLOSEREQ:
					*pFloodGateByte = *pFloodGateByte | (BIT_VAL_00000010B << 2U);  /*防淹门无关门请求*/
					break;
				default:
					break;
				}

				cFloodGateAllowState = GetFloodGateCurAgreeCloseSta(wFloodGateId);
				switch (cFloodGateAllowState)
				{
				case FLOOD_GATE_AGREE_CLOSE:
					*pFloodGateByte = *pFloodGateByte | (BIT_VAL_00000001B << 4U);  /*防淹门允许关门*/
					break;
				case FLOOD_GATE_NOT_AGREE_CLOSE:
					*pFloodGateByte = *pFloodGateByte | (BIT_VAL_00000010B << 4U);  /*防淹门不允许关门*/
					break;
				default:
					break;
				}
			}
			else
			{
				/*非本联锁信息不发送*/
			}

			wPackedLen++;
		}

		*pItemLen = wPackedLen;
		cRetVal = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0U;
		cRetVal = CI_ERROR;
	}

	return cRetVal;
}


/*
功能描述:
解析上电锁闭状态数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParseStartLockPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId)
{
	UINT8 deviceSum = 0u;			/*上电锁闭物理区段数量*/
	UINT8 retValue = CI_ERROR;
	UINT16 phySecId = 0u;				/*物理区段ID*/
	UINT16 ii = 0u;					/*游标*/
	UINT16 bufIndex = 0u;				/*数组下标*/
	UINT8 StartLockState = 0u;		/*上电锁闭状态*/
	UINT8 localCiId = 0u;
	UINT16 wLogSecId = 0u;				/*逻辑区段ID*/
	UINT8 cSecBelongCiId = 0U;
	const CiTransmitStruct* pCiRecptStru = NULL;
	UINT16 parsedLen = 0u;
	LogicSectionDataStruct* pstrLogSecData = NULL;
	PhysicalSectionDataStruct* tmpPhysicalSectionDataStru = GetPhySecData();
	localCiId = GetSystemParaLocalCiId();
	pCiRecptStru = GetSrcCiTransInfo(srcCiId);
	pstrLogSecData = GetLogicSecData();

	deviceSum = *(pInputData + parsedLen);
	parsedLen += 1u;

	if ((NULL == pCiRecptStru) || (NULL == tmpPhysicalSectionDataStru) || (NULL == pstrLogSecData))
	{
		*pItemLen = 0u;
		retValue = CI_ERROR; /*数据获取失败*/
	}
	else if (1u == deviceSum)
	{
		StartLockState = *(pInputData + parsedLen);	/*上电锁闭状态*/
		parsedLen += 1u;

		for (ii = 0u;ii < pCiRecptStru->phySecNum;ii++)
		{
			phySecId = pCiRecptStru->phySecIdBuf[ii];
			cSecBelongCiId = GetPhySecBelongCiId(phySecId);
			if (cSecBelongCiId == srcCiId)
			{
				bufIndex = GetPhySecConfigBufIndex(phySecId);
				tmpPhysicalSectionDataStru[bufIndex].PhysicalSectionId = phySecId;

				switch (StartLockState)
				{
					case HLHT_STARTLOCK_SET_NO:
						SetPhySecStartLockStateHlht(phySecId, PHYSICAL_SECTION_LOCK_NO);
						break;
					case HLHT_STARTLOCK_SET_YES:
						SetPhySecStartLockStateHlht(phySecId, PHYSICAL_SECTION_LOCK_START);
						SetPhySecLockDirHlht(phySecId, CI_SYSTEM_DIRECTION_NONE);						
						SetPhySecRLockRouteIdHlht(phySecId, 0u);						
						SetPhySecPLockRouteIdHlht(phySecId, 0u);
						break;
					default:
						/*不可达分支*/
						break;
				}
			}
			else
			{
				/*非本控区区段，不处理*/
			}
		}

		for (ii = 0u; ii < pCiRecptStru->logicSecNum; ii++)
		{
			wLogSecId = pCiRecptStru->logicSecIdBuf[ii];
			cSecBelongCiId = GetLogSecBelongCiId(wLogSecId);
			if (cSecBelongCiId == srcCiId)
			{
				bufIndex = GetlogSectionBufIndex(wLogSecId);
				pstrLogSecData[bufIndex].LogicSectionId = wLogSecId;

				switch (StartLockState)
				{
				case HLHT_STARTLOCK_SET_NO:
					SetLogSecStartLockStateHlht(wLogSecId, LOG_SECTION_LOCK_NO);
					break;
				case HLHT_STARTLOCK_SET_YES:
					SetLogSecStartLockStateHlht(wLogSecId, LOG_SECTION_LOCK_START);
					SetLogSecLockDirHlht(wLogSecId, CI_SYSTEM_DIRECTION_NONE);
					SetLogSecPLockRouteIdHlht(wLogSecId, 0U);
					SetLogSecRLockRouteIdHlht(wLogSecId, 0U);
					break;
				default:
					/*不可达分支*/
					break;
				}
			}
			else
			{
				/*非本控区区段，不处理*/
			}
		}

		*pItemLen = parsedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		*pItemLen = 0u;
		retValue = CI_ERROR;
	}

	return retValue;
}


/*
功能描述:
组上电锁闭状态数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackStartLockPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId)
{
	UINT8 StartLockState = 0u;		/*上电锁闭状态*/
	UINT16 ii = 0u;
	UINT16 deviceSumIndex = 0u;		/*设备总数游标位置*/
	UINT8 retValue = CI_ERROR;

	ii++;

	StartLockState = GetStartLockFlag();		/*物理区段锁闭状态*/

	switch (StartLockState)
	{
		case CI_START_LOCK_YES:
			pInputBuf[ii] = HLHT_STARTLOCK_SET_YES;
			break;
		case CI_START_LOCK_NO:
			pInputBuf[ii] = HLHT_STARTLOCK_SET_NO;
			break;
		default:
			/*不可达分支*/
			break;
	}

	ii++;

	pInputBuf[deviceSumIndex] = 1u;/*上电锁闭数量恒为1*/
	*pItemLen = ii;
	retValue = CI_SUCCESS;

	return retValue;
}

/*
* 功能描述：解析互联互通CI接口临时限速数据包
* 参数说明：UINT8 *pInputBuf 输入数据指针
*           UINT16 *pItemLen 该项数据在输入数据中的长度
*           const UINT8 srcCiId 源联锁ID
* 返 回 值：1 成功
*           0 失败
* edit cgh 20250116
*/
static UINT8 ParseTSRPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId)
{
	UINT8 retValue = CI_ERROR;
	UINT8 chLocalCiId = 0U;/*本地联锁ID*/
	const CiTransmitStruct* pCiRecptStru = NULL; /*源地址数据*/
	UINT8 chDeviceSum = 0U;/*设备数目*/
	UINT16 wParsedLen = 0U;/*解析数据长度*/
	UINT16 wLogSecIndex = 0U;/*逻辑区段索引*/
	UINT16 wLogSecId = 0U;/*逻辑区段ID*/
	UINT8 chLogSecBelCiId = 0U;/*逻辑区段所属联锁ID*/
	UINT8 chLinShiXianSuState = 0U;/*临时限速状态*/
	UINT8 chTsrByte = 0U;/*临时限速字节数据*/
	UINT16 wInxRem = 0U;/*临时限速逻辑区段字节偏移标志*/
	UINT16 wOffset = 0U;/*临时限速逻辑区段字节偏移量*/

	pCiRecptStru = GetSrcCiTransInfo(srcCiId);

	if ((NULL != pInputData) && (NULL != pItemLen) && (NULL != pCiRecptStru))
	{
		chLocalCiId = GetSystemParaLocalCiId();
		chDeviceSum = *pInputData;
		wParsedLen += 1U;

		if (chDeviceSum == (UINT8)pCiRecptStru->logicSecNum)
		{
			for (wLogSecIndex = 0U; wLogSecIndex < pCiRecptStru->logicSecNum; wLogSecIndex++)
			{
				wInxRem = wLogSecIndex % TSR_NUM_PER_BYTE;

				if (0U == wInxRem)
				{
					/*说明需要整个字节*/
					chTsrByte = *(pInputData + wParsedLen);

					wParsedLen += 1U;
				}
				else
				{
					/*不作任何处理，需要计算偏移*/
					;
				}

				wLogSecId = pCiRecptStru->logicSecIdBuf[wLogSecIndex];
				chLogSecBelCiId = GetLogSecBelongCiId(wLogSecId);

				if (chLocalCiId != chLogSecBelCiId)
				{
					wOffset = wInxRem * BIT_NUM_PER_TSR;

					chLinShiXianSuState = ((chTsrByte >> wOffset) & BIT_MASK_00000011B);

					switch (chLinShiXianSuState)
					{
					case BIT_VAL_00000011B:
						SetLogSecLinShiXianSuState(wLogSecId, LOGSEC_LSXS_SET_STATE_INVALID);
						break;
					case BIT_VAL_00000001B:
						SetLogSecLinShiXianSuState(wLogSecId, LOGSEC_LSXS_SET_STATE_YES);
						break;
					case BIT_VAL_00000010B:
						SetLogSecLinShiXianSuState(wLogSecId, LOGSEC_LSXS_SET_STATE_NO);
						break;
					default:
						/*不可达分支*/
						break;
					}
				}
				else
				{
					; /*本联锁区段，不处理*/
				}
			}

			*pItemLen = wParsedLen;
			retValue = CI_SUCCESS;
		}
		else
		{
			*pItemLen = 0U; /*失败*/
		}
	}
	else
	{
		;
	}

	return retValue;
}

/*
* 功能描述：互联互通CI接口组临时限速数据包
* 参数说明：UINT8 *pInputBuf 输入数据指针
*           UINT16 *pItemLen 该项数据在输入数据中的长度
*           const UINT8 dstCiId 目标联锁ID
* 返 回 值：1 成功
*           0 失败
* edit cgh 20250116
*/
static UINT8 PackTSRPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId)
{
	UINT8 retValue = CI_ERROR;
	CiTransmitStruct* pTmpCiTransInfo = NULL;
	UINT16 wLogSecIndex = 0U;/*逻辑区段索引*/
	UINT8 chLocalCi = 0U;					/*本机联锁ID*/
	UINT16 wPackedLen = 0U;/*组包长度*/
	UINT16 wLogSecId = 0U;/*逻辑区段ID*/
	UINT8 chLogSecBelCiId = 0U;/*逻辑区段所属联锁ID*/
	UINT8 chLinShiXianSuState = 0U;/*临时限速状态*/
	UINT8* pTsrByte = NULL;/*临时限速存储地址*/
	UINT16 wInxRem = 0U;/*临时限速逻辑区段字节偏移标志*/
	UINT16 wOffset = 0U;/*临时限速逻辑区段字节偏移量*/

	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);

	if ((NULL != pInputBuf) && (NULL != pItemLen) && (NULL != pTmpCiTransInfo))
	{
		chLocalCi = GetSystemParaLocalCiId();
		wPackedLen += 1U;

		for (wLogSecIndex = 0U; wLogSecIndex < pTmpCiTransInfo->logicSecNum; wLogSecIndex++)
		{
			wInxRem = wLogSecIndex % TSR_NUM_PER_BYTE;

			if (0U == wInxRem)
			{
				/*说明需要整个字节*/
				pTsrByte = pInputBuf + wPackedLen;

				wPackedLen += 1U;
			}
			else
			{
				/*不作任何处理，需要计算偏移*/
				;
			}

			wLogSecId = pTmpCiTransInfo->logicSecIdBuf[wLogSecIndex];
			chLogSecBelCiId = GetLogSecBelongCiId(wLogSecId);
			if (chLocalCi == chLogSecBelCiId)
			{
				wOffset = wInxRem * BIT_NUM_PER_TSR;

				chLinShiXianSuState = GetLogSecLinShiXianSuSetState(wLogSecId);

				switch (chLinShiXianSuState)
				{
				case LOGSEC_LSXS_SET_STATE_INVALID:
					*pTsrByte = *pTsrByte | ((UINT8)(BIT_VAL_00000011B << wOffset));
					break;
				case LOGSEC_LSXS_SET_STATE_YES:
					*pTsrByte = *pTsrByte | ((UINT8)(BIT_VAL_00000001B << wOffset));
					break;
				case LOGSEC_LSXS_SET_STATE_NO:
					*pTsrByte = *pTsrByte | ((UINT8)(BIT_VAL_00000010B << wOffset));
					break;
				default:
					/*不可达分支*/
					break;
				}
			}
			else
			{
				; /*非本联锁不发送*/
			}
		}

		pInputBuf[0] = pTmpCiTransInfo->logicSecNum;
		*pItemLen = wPackedLen;
		retValue = CI_SUCCESS;
	}
	else
	{
		;
	}
	return retValue;
}
/*
功能描述:
解析城市自定义数据包
输入参数:
const UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 ParseCityDefPacket(const UINT8 *pInputData, UINT16 *pItemLen)
{

	return CI_SUCCESS;
}

/*
功能描述:
组包城市自定义数据包
输入参数:
UINT8 *pInputData 输入数据指针
输出参数:
UINT16 *pItemLen 该项数据在输入数据中的长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/

static UINT8 PackCityDefPacket(UINT8 *pInputData, UINT16 *pItemLen)
{

	return CI_SUCCESS;
}

/*
功能描述:
构造互联互通联锁应用数据内容
输入参数:
const UINT8 dstCiId 目标联锁ID
输出参数:
UINT8 *pInputData 数据缓存指针
UINT16 *pOverallLen 应用数据总长度指针
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 PackCiPacketCont(UINT8 *pInputData, UINT16 *pOverallLen, const UINT8 dstCiId)
{
	UINT16 packetOrder = 0u;
	UINT16 packetType = 0xFFFFu;		/*应用报文类型*/

	UINT16 packedLen = 0u;			/*应用报文指针偏移量*/
	UINT16 itemLen = 0u;				/*信息长度*/
	UINT8 *pLenItemAddr = NULL;		/*指向 应用报文长度所在buffer地址*/

	UINT8 dataIsAvail = CI_FALSE;
	UINT8 retVal = CI_ERROR;

	CiTransmitStruct *pTmpCiTransInfo = NULL;

	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);

	if ((NULL == pTmpCiTransInfo) || (NULL == pInputData) || (NULL == pOverallLen))
	{
		retVal = CI_ERROR;
	}
	else
	{
		retVal = CI_SUCCESS;
		while (1)
		{
			packetType = packetOderQueue[packetOrder];							/*报文类型*/

			packetOrder++;

			if ((0xFFFFU != packetType) && (CI_SUCCESS == retVal))
			{
				/*继续构造数据包*/
			}
			else
			{
				break;
			}

			switch (packetType)
			{
			case SWITCH_STATUS_PACKET:
				if (0u != pTmpCiTransInfo->switchNum)
				{
					dataIsAvail = CI_TRUE;
				}
				else
				{
					dataIsAvail = CI_FALSE;
				}
				break;
			case PHYSIC_SEC_STATUS_PACKET:
				if (0u != pTmpCiTransInfo->phySecNum)
				{
					dataIsAvail = CI_TRUE;
				}
				else
				{
					dataIsAvail = CI_FALSE;
				}
				break;
			case LOGIC_SEC_STATUS_PACKET:
				if (0u != pTmpCiTransInfo->logicSecNum)
				{
					dataIsAvail = CI_TRUE;
				}
				else
				{
					dataIsAvail = CI_FALSE;
				}
				break;
			case SIGNAL_STATUS_PACKET:
				if (0u != pTmpCiTransInfo->signalNum)
				{
					dataIsAvail = CI_TRUE;
				}
				else
				{
					dataIsAvail = CI_FALSE;
				}
				break;
			case PSD_STATUS_PACKET:
				if (0u != pTmpCiTransInfo->psdNum)
				{
					dataIsAvail = CI_TRUE;
				}
				else
				{
					dataIsAvail = CI_FALSE;
				}
				break;
			case EMERGEBTN_STATUS_PACKET:
				if (0u != pTmpCiTransInfo->esbNum)
				{
					dataIsAvail = CI_TRUE;
				}
				else
				{
					dataIsAvail = CI_FALSE;
				}
				break;
			case ZHAOCHA_STATUS_PACKET:
				if (0u != pTmpCiTransInfo->zcjNum)
				{
					dataIsAvail = CI_TRUE;
				}
				else
				{
					dataIsAvail = CI_FALSE;
				}
				break;
			case FLOOD_GATE_STATUS_PACKET:
				if (0u != pTmpCiTransInfo->floodGateNum)
				{
					dataIsAvail = CI_TRUE;
				}
				else
				{
					dataIsAvail = CI_FALSE;
				}
				break;
			case START_LOCK_STATUS_PACKET:
				dataIsAvail = CI_TRUE;
				break;
			case LINSHI_XIANSU_STATUS_PACKET:
				if (0u != pTmpCiTransInfo->logicSecNum)
				{
					dataIsAvail = CI_TRUE;
				}
				else
				{
					dataIsAvail = CI_FALSE;
				}
				break;
			case CITY_DEF_STATUS_PACKET:
				dataIsAvail = CI_FALSE;
				break;
			case MANUFAC_DEF_STATUS_PACKET:
				dataIsAvail = CI_TRUE;
				break;
			default:
				dataIsAvail = CI_FALSE;
				break;
			}

			if (CI_TRUE == dataIsAvail)
			{
				retVal &= PackPacketLenPha1(pInputData + packedLen, &pLenItemAddr, &itemLen); 					/*获取存放报文内容长度地址的地址*/
				packedLen += itemLen;

				retVal &= PackPacketType(pInputData + packedLen, packetType, &itemLen);							/*填入应用报文类型数据*/
				packedLen += itemLen;

				packedLen += PACKET_EMPTY_LEN;															/*填入两个空字节的预留位*/

				if (CI_SUCCESS == retVal)
				{
					switch (packetType)
					{
					case SWITCH_STATUS_PACKET:
						retVal &= PackSwitchPacket(pInputData + packedLen, &itemLen, dstCiId);								/*组道岔报文内容*/
						packedLen += itemLen;
						break;
					case PHYSIC_SEC_STATUS_PACKET:
						retVal &= PackPhySecPacket(pInputData + packedLen, &itemLen, dstCiId);								/*组物理区段报文内容*/
						packedLen += itemLen;
						break;
					case LOGIC_SEC_STATUS_PACKET:
						retVal &= PackLogSecPacket(pInputData + packedLen, &itemLen, dstCiId);								/*组逻辑区段报文内容*/
						packedLen += itemLen;
						break;
					case SIGNAL_STATUS_PACKET:
						retVal &= PackSignalPacket(pInputData + packedLen, &itemLen, dstCiId);								/*组信号机报文内容*/
						packedLen += itemLen;
						break;
					case PSD_STATUS_PACKET:
						retVal &= PackPsdPacket(pInputData + packedLen, &itemLen, dstCiId);								/*组PSD报文内容*/
						packedLen += itemLen;
						break;
					case EMERGEBTN_STATUS_PACKET:
						retVal &= PackEmbtnPacket(pInputData + packedLen, &itemLen, dstCiId);								/*组紧急停车按钮报文内容*/
						packedLen += itemLen;
						break;
					case ZHAOCHA_STATUS_PACKET:
						retVal &= PackZhaoChaPacket(pInputData + packedLen, &itemLen, dstCiId);   /*组照查继电器报文内容*/
						packedLen += itemLen;
						break;
					case FLOOD_GATE_STATUS_PACKET:
						retVal &= PackFloodGatePacket(pInputData + packedLen, &itemLen, dstCiId);
						packedLen += itemLen;
						break;
					case START_LOCK_STATUS_PACKET:
						retVal &= PackStartLockPacket(pInputData + packedLen, &itemLen, dstCiId);							/*组上电锁闭报文内容*/
						packedLen += itemLen;
						break;
					case LINSHI_XIANSU_STATUS_PACKET:
						retVal &= PackTSRPacket(pInputData + packedLen, &itemLen, dstCiId);							/*组上电锁闭报文内容*/
						packedLen += itemLen;
						break;
					case CITY_DEF_STATUS_PACKET:
						break;
					case MANUFAC_DEF_STATUS_PACKET:
						retVal &= PackManufacDefPacket(pInputData + packedLen, &itemLen, dstCiId);  /*组厂商自定义帧报文内容*/
						packedLen += itemLen;
						break;
					default:
						/*不可达分支*/
						break;
					}

					retVal &= PackPacketLenPha2(pLenItemAddr, itemLen + PACKET_TYPE_LEN + PACKET_EMPTY_LEN);  /*填入报文内容的长度*/

					if (CI_SUCCESS == retVal)
					{
						/*继续组包*/
					}
					else
					{						
						retVal = CI_ERROR;  /*组包失败，返回失败*/
						debug_infor_printf((const)"\nHlht Ci Id[%d] Pack Packet[0x%04x] Error", dstCiId, packetType);
					}
				}
				else
				{					
					retVal = CI_ERROR;  /*组包失败，返回失败*/
					debug_infor_printf((const)"\nHlht Ci Id[%d] Pack Len Or Type Error", dstCiId);
				}
			}
			else
			{
				packedLen += 0u;
			}
		}
		*pOverallLen = packedLen;					/*获取报文总长度*/
	}

	return retVal;
}

/*
功能描述:
解析联锁报文内容
输入参数:
const UINT8 *pInputData 输入数据指针
const UINT16 overallLen 应用报文总长度
输出参数:
无
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 ParseCiPacketCont(const UINT8 *pInputData, const UINT16 overallLen,const UINT8 srcId)
{
	UINT16 packetType = 0xFFFFu;		/*应用报文类型*/
	UINT16 packetLen = 0u;			/*应用报文长度*/
	UINT16 parsedLen = 0u;			/*应用报文指针偏移量*/
	UINT16 packetIdle = 0u;			/*预留*/
	UINT16 itemLen = 0u;				/*信息长度*/
	UINT8 cRetVal = CI_ERROR;

	if (NULL != pInputData)
	{
		cRetVal = CI_SUCCESS;
		while (1)
		{
			if ((parsedLen < overallLen) && (CI_SUCCESS == cRetVal))
			{
				/*继续解析数据包*/
			}
			else
			{
				break;
			}

			cRetVal &= ParsePacketLength(pInputData + parsedLen, &packetLen, &itemLen);		/*获取单一报文长度*/
			parsedLen += itemLen;

			cRetVal &= ParsePacketType(pInputData + parsedLen, &packetType, &itemLen);		/*获取单一报文类型*/
			parsedLen += itemLen;

			packetIdle = ShortFromChar(pInputData + parsedLen);					/*获取预留位*/
			parsedLen += PACKET_EMPTY_LEN;

			if (CI_SUCCESS == cRetVal)
			{
				switch (packetType)
				{
				case SWITCH_STATUS_PACKET:
					cRetVal &= ParseSwitchPacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				case PHYSIC_SEC_STATUS_PACKET:
					cRetVal &= ParsePhySecPacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				case LOGIC_SEC_STATUS_PACKET:
					cRetVal &= ParseLogSecPacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				case SIGNAL_STATUS_PACKET:
					cRetVal &= ParseSignalPacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				case PSD_STATUS_PACKET:
					cRetVal &= ParsePsdPacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				case EMERGEBTN_STATUS_PACKET:
					cRetVal &= ParseEmbtnPacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				case ZHAOCHA_STATUS_PACKET:
					cRetVal &= ParseZhaoChaPacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				case FLOOD_GATE_STATUS_PACKET:
					cRetVal &= ParseFloodGatePacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				case START_LOCK_STATUS_PACKET:
					cRetVal &= ParseStartLockPacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				case LINSHI_XIANSU_STATUS_PACKET:
					cRetVal &= ParseTSRPacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				case CITY_DEF_STATUS_PACKET:
					cRetVal &= ParseCityDefPacket(pInputData + parsedLen, &itemLen);
					parsedLen += itemLen;
					break;
				case MANUFAC_DEF_STATUS_PACKET:
					cRetVal &= ParseManufacDefPacket(pInputData + parsedLen, &itemLen, srcId);
					parsedLen += itemLen;
					break;
				default:
					/*不可达分支*/
					break;
				}

				if (CI_SUCCESS == cRetVal)
				{
					/*继续解包*/
				}
				else
				{
					cRetVal = CI_ERROR;  /*返回失败*/
					debug_infor_printf((const)"\nHlht Ci Id[%d] Parse Packet[0x%04x] Error", srcId, packetType);
				}
			}
			else
			{
				cRetVal = CI_ERROR;  /*返回失败*/
				debug_infor_printf((const)"\nHlht Ci Id[%d] Parse Len Or Type Error");
			}
		}
	}
	else
	{
		/*返回失败*/
	}

	return cRetVal;
}

/*
功能描述:
构建互联互通联锁至联锁报文头第二步
输入参数:
无
输出参数:
UINT8 * pInputData 数据缓存指针
UINT16 appDataLen 应用数据长度
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
UINT8 PackHlhtPacketHeadPha2(UINT8 * pInputData, UINT16 appDataLen)
{
	UINT8 cRetVal = CI_ERROR;

	if (NULL != pInputData)
	{
		/*写入应用数据长度*/
		ShortToChar(appDataLen, pInputData);
		cRetVal = CI_SUCCESS;
	}
	else
	{
		/*返回失败*/
	}

	return cRetVal;
}


/*
功能描述:
构建互联互通联锁至联锁报文头第一步
输入参数:
UINT8 dstCiId 目标联锁ID
输出参数:
UINT8 * pInputData 数据缓存指针
UINT16 * pHeadDataLen 报文头长度变量指针
UINT8 * * ppLenItemAddr 报文头中存放应用长度的地址的指针
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
UINT8 PackHlhtPacketHeadPha1(UINT8 dstCiId, UINT8 * pInputData, UINT16 * pHeadDataLen, UINT8 * * ppLenItemAddr)
{
	UINT16 interfaceInfoType = CI_TO_CI_INTERFACE;	/*接口类型*/
	UINT32 srcCiEtcsId = 0u;				/*本机联锁ID*/
	UINT32 dstCiEtcsId = 0u;				/*目标联锁ID*/
	UINT32 emapVerChkSum = 0u;		/*电子地图校验信息*/
	UINT32 sourceMessageSn = 0u;			/*本方消息序号*/
	UINT16 commPeriod = 0u;				/*通信周期*/
	UINT32 destinMessageSn = 0u;			/*对方消息序号*/
	UINT32 prevSourceMessageSn = 0u;		/*收到上一条信息时对方消息序号*/
	UINT8 protocolVersion = HLHT_CI_INTER_VER;			/*协议版本号*/
	UINT8 locCiId = 0u;
	UINT16 ii = 0u;					/*游标*/
	UINT8 headSaved = GetHLHTHeadCtxExistance(CI_SYSTEM_TYPE_CI, dstCiId);
	UINT16 wCiDevName = 0U;
	UINT8 cRetVal = CI_ERROR;

	if ((NULL != pInputData) && (NULL != pHeadDataLen) && (NULL != ppLenItemAddr))
	{
		locCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/

		ShortToChar(interfaceInfoType, &pInputData[ii]);		/*写入接口信息类型*/
		ii += INTERFACE_INFO_TYPE_LEN;

		(void)dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_CI << 8u) + locCiId, 0u, &srcCiEtcsId);
		LongToChar(srcCiEtcsId, &pInputData[ii]);					/*写入发送方ETCS ID*/
		ii += SOURCE_ID_LEN;

		(void)dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_CI << 8u) + dstCiId, 0u, &dstCiEtcsId);
		LongToChar(dstCiEtcsId, &pInputData[ii]);					/*写入接收方ETCS ID*/
		ii += DESTIN_ID_LEN;

		wCiDevName = (CI_SYSTEM_TYPE_CI) * 256U + dstCiId;
		emapVerChkSum = GetCiTranCiDataCheckVer(locCiId, wCiDevName);

		LongToChar(emapVerChkSum, &pInputData[ii]);			/*写入电子地图校验信息*/
		ii += EMAP_VISION_CHECK_SUM_LEN;

		sourceMessageSn = Get2oo2CurCycleNum();
		LongToChar(sourceMessageSn, &pInputData[ii]);			/*写入对方消息序号*/
		ii += SOURCE_MESSAGE_SN_LEN;

		commPeriod = (UINT16)GetSystemParaAppCycleTime();
		ShortToChar(commPeriod, &pInputData[ii]);				/*写入通信周期*/
		ii += COMM_PERIOD_LEN;

		if (CI_SUCCESS == headSaved)
		{
			destinMessageSn = GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_CI, dstCiId);
			prevSourceMessageSn = GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_CI, dstCiId);
		}
		else
		{
			destinMessageSn = UINT32_MAX;
			prevSourceMessageSn = UINT32_MAX;
		}

		LongToChar(destinMessageSn, &pInputData[ii]);			/*写入对方消息序号*/
		ii += DESTIN_MESSAGE_SN_LEN;

		LongToChar(prevSourceMessageSn, &pInputData[ii]);		/*写入收到上一条信息时对方消息序号*/
		ii += PREV_SOURCE_MESSAGE_SN_LEN;

		pInputData[ii] = protocolVersion;						/*写入协议版本号*/
		ii += PROTOCOL_VERSION_LEN;

		/*传出应用报文长度位置指针*/
		*ppLenItemAddr = (pInputData + ii);

		ii += PACKET_LENGTH_LEN;

		*pHeadDataLen = ii;										 /*获取数据头的长度*/

		cRetVal = CI_SUCCESS;
	}
	else
	{
		/*返回失败*/
	}

	return cRetVal;
}



/*
功能描述:
构建互联互通联锁至联锁应用报文数据帧
输入参数:
UINT8 dstCiId 目标联锁ID
输出参数:
UINT8* dataFrame 数据帧缓存指针
UINT16* dataLength 数据帧长度变量指针
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
static UINT8 PackHLHTCiToCiDataFrameUseCfg(UINT8 dstCiId, UINT8* dataFrame, UINT16* dataLength)
{
	UINT16 appDataLen = 0u;			/*应用层数据长度*/
	UINT16 headDataLen = 0u;			/*通用报文头数据长度*/
	UINT8 reVaule = CI_ERROR;
	UINT8 * pLenItemAddr = NULL;

	if ((dataFrame != NULL) && (NULL != dataLength))
	{
		/*组互联互通报文头第一步*/
		reVaule = PackHlhtPacketHeadPha1(dstCiId, dataFrame, &headDataLen, &pLenItemAddr);	/*填入报文头内容 ，不包括应用层报文总长度*/

		reVaule &= PackCiPacketCont(dataFrame + headDataLen, &appDataLen, dstCiId);		/*填入应用报文内容*/

		/*组互联互通报文头第二步*/
		reVaule &= PackHlhtPacketHeadPha2(pLenItemAddr, appDataLen);

		*dataLength = headDataLen + appDataLen;						/*数据报文总长度*/
	}
	else
	{
		reVaule = CI_ERROR;
	}

	return reVaule;
}

/*
功能描述:
构建互联互通联锁至联锁数据
输入参数:
UINT8 targetDeviceId 目标联锁ID
输出参数:
QueueStruct* ciToCiDataQueue 联锁至联锁数据队列指针
返回值:
CI_SUCCESS,成功;CI_ERROR,失败.
*/
UINT8 PackHLHTCiToCiData(UINT8 targetDeviceId)
{
	UINT8 retVal = CI_ERROR;
	UINT8 localCiId = 0u;
	UINT32 etcsId = 0u;
	UINT32 emapCheckVer = 0u;
	UINT8 ciToCiDataBuffer[CI_TO_CI_DATA_LEN_MAX] = { 0u };/*CI到CI组帧数组*/
	UINT16 frameDataLen = 0u; 	/*数据信息总长度*/
	UINT16 ii = 0u;
	UINT8 locCiEtcsIdChkRetVal = CI_ERROR;
	UINT8 tarCiEtcsIdChkRetVal = CI_ERROR;
	UINT8 locCiEmapChkRetVal = CI_ERROR;
	UINT16 dstDevId = 0u;
	UINT8 outnetSafeSendRtn = 0u;
	UINT16 wDevType = 0u;

	localCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/
	locCiEtcsIdChkRetVal = dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_CI << 8u) + localCiId,0u,&etcsId);
	tarCiEtcsIdChkRetVal = dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_CI << 8u) + targetDeviceId,0u,&etcsId);
	locCiEmapChkRetVal = GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_CI);
	/*首先获取组包时所需的信息，获取成功才有必要继续组包*/
	if(	(CI_SUCCESS == locCiEtcsIdChkRetVal) 
		&& 
		(CI_SUCCESS == tarCiEtcsIdChkRetVal) 
		&& 
		(CI_SUCCESS == locCiEmapChkRetVal))
	{
		/*构建互联互通联锁至联锁应用报文数据帧*/
		retVal = PackHLHTCiToCiDataFrameUseCfg(targetDeviceId, &ciToCiDataBuffer[ii], &frameDataLen);
		ii = ii + frameDataLen;

		if (CI_SUCCESS == retVal)
		{
			wDevType = (UINT16)Get2oo2SheBeiType();
			dstDevId = ((UINT16)(wDevType << 8u) | ((UINT16)targetDeviceId));
			outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &ciToCiDataBuffer[0], ii);
			if (1u == outnetSafeSendRtn)
			{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/		
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
				debug_infor_printf((const)"\nCI_SEND:%d", ii);
				debug_out_array(0xAA, ciToCiDataBuffer, ii);
#endif/*平台打印结束*/


#endif
				retVal = CI_SUCCESS;
			}
			else
			{
				/*写队列失败*/
				retVal = CI_ERROR;
			}
		}
		else
		{
			retVal = CI_ERROR;  /*返回失败*/
		}
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}

/**
* @brief 初始化TIOC间接口通信车记录
* @param 无
* @return 无
* @note：
*/
void TiocTransCtInit(void)
{
	UINT8 * pTiocIdBuf = NULL;
	UINT8 chTiocNum = 0u;
	UINT8 chIndex = 0u;

	chTiocNum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_CI);
	pTiocIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_CI);

	if ((TRANSMIT_OBJECT_DEVICE_SUM_MAX > chTiocNum) && (NULL != pTiocIdBuf))
	{
		g_transmitTiocNum = chTiocNum;
		for (chIndex = 0u; chIndex < chTiocNum; chIndex++)
		{
			g_szTiocCt[chIndex].chTiocId = pTiocIdBuf[chIndex];
		}
	}
	else
	{
		;
	}
}

/**
* @brief 获取指定TIOC通信车存储索引
* @param 无
* @return 索引
* @note：
*/
UINT8 GetTiocTransmitIndex(UINT8 chTiocId)
{
	UINT8 chIndex = 0u;
	for (chIndex = 0u; chIndex < g_transmitTiocNum; chIndex++)
	{
		if (chTiocId == g_szTiocCt[chIndex].chTiocId)
		{
			break;
		}
		else
		{
			;
		}
	}
	return chIndex;
}

/**
* @brief 获取指定TIOC通信车传输数量
* @param 无
* @return 数量
* @note：
*/
UINT8 GetTiocTransmitCtNum(UINT8 chTiocId)
{
	UINT8 chIndex = 0u;
	UINT8 chRtn = 0u;
	chIndex = GetTiocTransmitIndex(chTiocId);
	if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex)
	{
		chRtn = g_szTiocCt[chIndex].chCtNum;
	}
	else
	{
		;
	}
	return chRtn;
}

/**
* @brief 获取指定TIOC通信车ID
* @param 无
* @return ID地址
* @note：
*/
UINT16 * GetTiocTransmitCtIds(UINT8 chTiocId)
{
	UINT8 chIndex = 0u;
	UINT16 * chRtn = NULL;
	chIndex = GetTiocTransmitIndex(chTiocId);
	if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex)
	{
		chRtn = g_szTiocCt[chIndex].szCtId;
	}
	else
	{
		;
	}
	return chRtn;
}

/**
* @brief 组区间疏散消息
* @param UINT8 dstCiId 目标TIOC编号
* @param UINT8* dataFrame 数据缓冲区
* @return 长度，失败0
*/
static UINT16 PackCiToCiDataFrameEa(UINT8 dstCiId, UINT8* dataFrame)
{
	UINT16 wRtn = 0u;
	UINT16 wEaNumIndex = 0u;
	UINT8 chEaSendNum = 0u;
	UINT8 chEaNum = 0u;
	UINT8 chEaIndex = 0u;
	UINT16 wEaTrainId = 0u;
	UINT8 chEaLgcNum = 0u;
	UINT16 * pEaLgcId = NULL;
	UINT32 dwMidLine = 0u;
	UINT8 chEaBuidFlag = 0u;
	UINT8 chDstTioc = 0u;
	UINT8 chSrcTioc = 0u;
	UINT8 chDstAllowed = 0u;
	UINT8 chLgcIndex = 0u;
	UINT8 chPackFlag = CI_ERROR;
	UINT8 chLocalId = GetSystemParaLocalCiId();
	UINT8 chPaType = 0u;
	UINT32 dwEaBuildCyc = 0u;
	
	/* 预留出区间疏散数量位置 */
	wRtn++;

	chEaNum = GetEaNum();
	/*增加chEaNum防护，区间疏散数量大于最大值时，都不进行组包*/
	if (EA_MAX_NUM < chEaNum) 
	{
		chPackFlag = CI_ERROR;
	}
	else
	{
		chPackFlag = CI_SUCCESS;
	}

	if (CI_SUCCESS == chPackFlag)
	{
		for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++)
		{
			/* 疏散列车ID */
			wEaTrainId = GetEvacuatingTrainIdByIndex(chEaIndex);
			if ((0u == wEaTrainId) || (UINT16_MAX == wEaTrainId))
			{
				chPackFlag = CI_ERROR;
			}
			else
			{
				;
			}

			/* 逻辑区段数量 */
			chEaLgcNum = EaGetLgcNum(chEaIndex);
			if ((0u < chEaLgcNum) && (EA_SECTION_MAX_NUM >= chEaLgcNum))
			{
				;
			}
			else
			{
				chPackFlag = CI_ERROR;
			}

			/* 逻辑区段 */
			pEaLgcId = EaGetLgcId(chEaIndex);
			if (NULL == pEaLgcId)
			{
				chPackFlag = CI_ERROR;
			}
			else
			{
				;
			}

			/* 疏散列车中轴线 */
			dwMidLine = EaGetMidLine(chEaIndex);

			/* 建立标志 */
			chEaBuidFlag = GetEaBuildedFlag(chEaIndex);
			if ((EA_IS_BUILDED != chEaBuidFlag) && (EA_IS_NOT_BUILDED != chEaBuidFlag))
			{
				chPackFlag = CI_ERROR;
			}
			else
			{
				;
			}

			/* 类型 */
			chPaType = GetPaTypeByIndex(chEaIndex);
			if ((PA_TYPE_DA != chPaType) && (PA_TYPE_EA != chPaType))
			{
				chPackFlag = CI_ERROR;
			}
			else
			{
				;
			}

			/* 建立周期号 */
			dwEaBuildCyc = EaGetBuildCycNum(chEaIndex);
			if (0U == dwEaBuildCyc)
			{
				chPackFlag = CI_ERROR;
			}
			else
			{
				;
			}

			chDstTioc = GetEaDstTiocByIndex(chEaIndex);
			chSrcTioc = GetEaSrcTiocByIndex(chEaIndex);
			if (CI_SUCCESS == chPackFlag)
			{
				if ((chSrcTioc == chLocalId) && (chDstTioc == dstCiId))
				{/* 建立控区为本控区，接收对象为目标控区 */
					chEaSendNum++;
					ShortToChar(wEaTrainId, &dataFrame[wRtn]);
					wRtn += 2u;
					dataFrame[wRtn] = chEaLgcNum;
					wRtn++;
					for (chLgcIndex = 0u; chLgcIndex < chEaLgcNum; chLgcIndex++)
					{
						/* 逻辑区段ID */
						if ((0u != pEaLgcId[chLgcIndex]) && (UINT16_MAX != pEaLgcId[chLgcIndex]))
						{
							ShortToChar(pEaLgcId[chLgcIndex], &dataFrame[wRtn]);
							wRtn += 2u;
						}
						else
						{
							chPackFlag = CI_ERROR;
							break;
						}
					}

					dataFrame[wRtn] = chEaBuidFlag;
					wRtn++;

					LongToChar(dwMidLine, &dataFrame[wRtn]);
					wRtn += 4u;

					dataFrame[wRtn] = chPaType;
					wRtn++;

					LongToChar(dwEaBuildCyc, &dataFrame[wRtn]);
					wRtn += 4u;
				}
				else
				{
					;
				}
			}
			else
			{
				;
			}

			if (CI_ERROR == chPackFlag)
			{
				break;
			}
			else
			{
				;
			}
		}
		/* 记录发送Ea数量 */
		dataFrame[wEaNumIndex] = chEaSendNum;
	}

	wEaNumIndex = wRtn;
	wRtn++;
	chEaSendNum = 0u;
	if (CI_SUCCESS == chPackFlag)
	{
		for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++)
		{
			/* 疏散列车ID */
			wEaTrainId = GetEvacuatingTrainIdByIndex(chEaIndex);
			if ((0u == wEaTrainId) || (UINT16_MAX == wEaTrainId))
			{
				chPackFlag = CI_ERROR;
			}
			else
			{
				;
			}

			/* 类型 */
			chPaType = GetPaTypeByIndex(chEaIndex);
			if ((PA_TYPE_DA != chPaType) && (PA_TYPE_EA != chPaType))
			{
				chPackFlag = CI_ERROR;
			}
			else
			{
				;
			}

			/*周期号*/
			dwEaBuildCyc = EaGetBuildCycNum(chEaIndex);
			if (dwEaBuildCyc == 0U)
			{
				chPackFlag = CI_ERROR;
			}
			else
			{
				;
			}

			chDstTioc = GetEaDstTiocByIndex(chEaIndex);
			chSrcTioc = GetEaSrcTiocByIndex(chEaIndex);
			/* 当前控区同意状态 */
			chDstAllowed = GetEaDstAllowedByIndex(chEaIndex);
			if ((EA_DST_ALLOWED_YES != chDstAllowed) && (EA_DST_ALLOWED_NO != chDstAllowed))
			{
				chPackFlag = CI_ERROR;
			}
			else
			{
				;
			}

			if (CI_SUCCESS == chPackFlag)
			{
				if ((chDstTioc == chLocalId) && (chSrcTioc == dstCiId) && (PA_TYPE_EA == chPaType))
				{/* 接收对象为建立控区，目标控区为本控区 */
					chEaSendNum++;
					ShortToChar(wEaTrainId, &dataFrame[wRtn]);
					wRtn += 2u;
					dataFrame[wRtn] = chDstAllowed;
					wRtn++;
					LongToChar(dwEaBuildCyc, &dataFrame[wRtn]);
					wRtn += 4u;
				}
				else
				{
					 ;
				}
			}
			else
			{
				;
			}
		}
	}
	else
	{
		;
	}
	/* 记录反馈Ea数量 */
	dataFrame[wEaNumIndex] = chEaSendNum;

	if (CI_ERROR == chPackFlag)
	{/* 组包失败，返回0 */
		wRtn = 0u;
	}
	else
	{
		;
	}

	return wRtn;
}

/**
* @brief 获取指定TIOC疏散防护区域传输数量
* @param 无
* @return 数量
* @note：
*/
UINT8 GetTiocTransmitEaNum(UINT8 chTiocId)
{
	UINT8 chIndex = 0u;
	UINT8 chRtn = 0u;
	chIndex = GetTiocTransmitIndex(chTiocId);
	if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex)
	{
		chRtn = g_szTiocCt[chIndex].chEaTrainNum;
	}
	else
	{
		;
	}
	return chRtn;
}

/**
* @brief 获取指定TIOC疏散车ID
* @param 无
* @return ID地址
* @note：
*/
UINT16 * GetTiocTransmitEaIds(UINT8 chTiocId)
{
	UINT8 chIndex = 0u;
	UINT16 * pRtn = NULL;
	chIndex = GetTiocTransmitIndex(chTiocId);
	if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex)
	{
		pRtn = g_szTiocCt[chIndex].szEaTrainId;
	}
	else
	{
		;
	}
	return pRtn;
}

/**
* @brief 获取指定TIOC防护区域类型
* @param 无
* @return 类型地址
* @note：
*/
UINT8 * GetTiocTransmitPaTypes(UINT8 chTiocId)
{
	UINT8 chIndex = 0u;
	UINT8 * pRtn = NULL;
	chIndex = GetTiocTransmitIndex(chTiocId);
	if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex)
	{
		pRtn = g_szTiocCt[chIndex].szPaType;
	}
	else
	{
		;
	}
	return pRtn;
}

/**
* @brief 获取指定TIOC疏散区域建立时间
* @param 无
* @return 类型地址
* @note：
*/
UINT32 * GetTiocTransmitPaBuildCyc(UINT8 chTiocId)
{
	UINT8 chIndex = 0u;
	UINT32 * pRtn = NULL;
	chIndex = GetTiocTransmitIndex(chTiocId);
	if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex)
	{
		pRtn = g_szTiocCt[chIndex].dwEaBuildCyc;
	}
	else
	{
		;
	}
	return pRtn;
}

/*
* 功能描述： 清组CI动态进路命令数据
* 参数说明： targetDeviceId 目标联锁ID
* 返回值  ： void
* 
*/
void ClearPackCiDrCmdData(UINT8 targetDeviceId)
{
	UINT8 ii = 0u;
	UINT32 cycleNum = 0u;
	UINT8 chNeedKeepSum = 0U;
	UINT8 chStruCurSum = 0U;

	cycleNum = Get2oo2CurCycleNum();/*获取平台周期号*/
	chStruCurSum = SendCiDrCmdSum;

	for (ii = 0U; ii < chStruCurSum; ii++)
	{

		if (SENDCI_CMD_DATA_STRU_SUM_MAX > ii)
		{
			if ((cycleNum >= (SendCiDrCmdDataStru[ii].CycleNo + 1U)) && (SendCiDrCmdDataStru[ii].cTargetCiId == targetDeviceId))
			{
				/*删除该命令数据,不保留*/
			}
			else
			{/*保留，不删除*/
				SendCiDrCmdDataStru[chNeedKeepSum++] = SendCiDrCmdDataStru[ii];
			}
		}
	}
	/*不保留数据全部清零*/
	for (ii = chNeedKeepSum; ii < chStruCurSum; ii++)
	{
		SendCiDrCmdDataStru[ii].cSourceCiId = 0U;
		SendCiDrCmdDataStru[ii].cTargetCiId = 0U;
		SendCiDrCmdDataStru[ii].cCmdType = 0U;
		SendCiDrCmdDataStru[ii].cLogSecSeqDir = 0U;
		SendCiDrCmdDataStru[ii].cLogSecSum = 0U;
		(void)CommonMemSet(SendCiDrCmdDataStru[ii].wLogSecIdBuff, (UINT32)(MAX_ROUTE_IN_LT_NUM * sizeof(UINT16)), 0U, (UINT32)(MAX_ROUTE_IN_LT_NUM * sizeof(UINT16)));
		SendCiDrCmdDataStru[ii].wTrainId = 0U;
		SendCiDrCmdDataStru[ii].cTrainLocLogSecSum = 0U;
		(void)CommonMemSet(SendCiDrCmdDataStru[ii].wTrainLocLogSecIdBuff, (UINT32)(SIZE_MAX_SECTION_BT_TRAIN * sizeof(UINT16)), 0U, (UINT32)(SIZE_MAX_SECTION_BT_TRAIN * sizeof(UINT16)));
		SendCiDrCmdDataStru[ii].cSwitchMoveFlag = 0U;
		SendCiDrCmdDataStru[ii].CycleNo = 0U;
		SendCiDrCmdDataStru[ii].wRelStartSignalId = 0U;
	}
	SendCiDrCmdSum = chNeedKeepSum;
}

/*
* 功能描述： 添加CI发送到其他联锁动态进路命令包含的逻辑区段信息
* 参数说明： UINT8 cmdType 命令类型
*            UINT8 logSecSqeDir 逻辑区段序列方向
*            UINT8 logSecSum 逻辑区段数量
*			 UINT16 logSecIdBuff[] 逻辑区段ID数组
*			 UINT8 toCiId 发送到的联锁ID
*/
void AddCiSendToCiDrCmdLogSecInfo(UINT8 cmdType, UINT8 logSecSqeDir, UINT8 logSecSum, UINT16 logSecIdBuff[], UINT8 toCiId)
{
	UINT32 cycleNo = 0u;
	UINT8 localCi = 0U; /*本地联锁ID*/
	UINT8 i = 0U;

	cycleNo = Get2oo2CurCycleNum();
	localCi = GetSystemParaLocalCiId();

	if (((CICI_DR_CMD_HALF == cmdType) || (CICI_DR_CMD_FULL == cmdType) || (CICI_DR_CMD_LOGIC == cmdType))
		&& (0U != logSecSum) && (MAX_ROUTE_IN_LT_NUM > logSecSum) && (NULL != logSecIdBuff) 
		&&((CI_SYSTEM_DIRECTION_DOWN == logSecSqeDir) || (CI_SYSTEM_DIRECTION_UP == logSecSqeDir))
		&& (0U != toCiId))
	{
		if (SENDCI_CMD_DATA_STRU_SUM_MAX > SendCiDrCmdSum)
		{
			/*添加命令数据信息*/
			SendCiDrCmdDataStru[SendCiDrCmdSum].cSourceCiId = localCi;
			SendCiDrCmdDataStru[SendCiDrCmdSum].cTargetCiId = toCiId;
			SendCiDrCmdDataStru[SendCiDrCmdSum].CycleNo = cycleNo;
			SendCiDrCmdDataStru[SendCiDrCmdSum].cCmdType = cmdType;
			SendCiDrCmdDataStru[SendCiDrCmdSum].cLogSecSeqDir = logSecSqeDir;
			SendCiDrCmdDataStru[SendCiDrCmdSum].cLogSecSum = logSecSum;
			for (i = 0u; i < logSecSum; i++)
			{
				SendCiDrCmdDataStru[SendCiDrCmdSum].wLogSecIdBuff[i] = logSecIdBuff[i];
			}
			SendCiDrCmdSum++;
		}
		else
		{
			debug_infor_printf((const)"Error in AddCiSendToCiDrCmdLogSecInfo: SendCiDrCmdSum exceed max %d!\n", SENDCI_CMD_DATA_STRU_SUM_MAX);
		}
	}
	else
	{
		debug_infor_printf((const)"Error in AddCiSendToCiDrCmdLogSecInfo: CmdType is %d, LogSecSum is %d, LogSecSqeDir is %d, TargetCiId is %d!\n", cmdType, logSecSum, logSecSqeDir, toCiId);
	}
}

/*
* 功能描述： 添加CI发送到其他联锁动态进路命令包含的半截进路信息
* 参数说明： UINT16 trainId 列车ID
*            UINT8 trainLocLogSecSum 列车脚下逻辑区段数量
*			 UINT16 trainLocLogSecIdBuff[] 列车脚下逻辑区段ID数组
*			 UINT8 switchMoveFlag 半截进路可动道岔标志
*            UINT16 startSignalId 首个逻辑区段关联的始端信号机ID
*/
void AddCiSendToCiDrCmdHalfInfo(UINT16 trainId, UINT8 trainLocLogSecSum, UINT16 trainLocLogSecIdBuff[], UINT8 switchMoveFlag, UINT16 startSignalId)
{
	UINT8 i = 0U;

	if ((SIZE_MAX_SECTION_BT_TRAIN > trainLocLogSecSum) && (NULL != trainLocLogSecIdBuff) 
		&& ((ROUTE_HALF_SWITCH_MOVE_VALID == switchMoveFlag) || (ROUTE_HALF_SWITCH_MOVE_INVALID == switchMoveFlag))
		&& (SIGNAL_SUM_MAX > startSignalId))
	{
		if (SENDCI_CMD_DATA_STRU_SUM_MAX > SendCiDrCmdSum)
		{
			/*添加命令数据信息*/
			SendCiDrCmdDataStru[SendCiDrCmdSum].wTrainId = trainId;
			SendCiDrCmdDataStru[SendCiDrCmdSum].cSwitchMoveFlag = switchMoveFlag;
			SendCiDrCmdDataStru[SendCiDrCmdSum].cTrainLocLogSecSum = trainLocLogSecSum;
			for (i = 0u; i < trainLocLogSecSum; i++)
			{
				SendCiDrCmdDataStru[SendCiDrCmdSum].wTrainLocLogSecIdBuff[i] = trainLocLogSecIdBuff[i];
			}
			SendCiDrCmdDataStru[SendCiDrCmdSum].wRelStartSignalId = startSignalId;
		}
		else
		{
			debug_infor_printf((const)"Error in AddCiSendToCiDrCmdHalfInfo: SendCiDrCmdSum exceed max %d!\n", SENDCI_CMD_DATA_STRU_SUM_MAX);
		}
	}
	else
	{
		debug_infor_printf((const)"Error in AddCiSendToCiDrCmdHalfInfo: TrainLocLogSecSum is %d, SwitchMoveFlag is %d!\n", trainLocLogSecSum, switchMoveFlag);
	}
}

/*
* 功能描述： 获取CI接收其他CI动态进路命令结构体数组长度
* 参数说明： void
* 返回值  ： 0: 获取失败
*           >0: 命令总数
*/
UINT8 GetCiRecvCiDrCmdStruCurSum(void)
{
	return RecvCiDrCmdSum;
}

/*
* 功能描述： 获取CI接收其他CI动态进路命令结构体数组
* 参数说明： void
* 返回值  ： NULL: 获取失败
*           !NULL: 命令结构体数组指针
*/
ToCiDrCmdDataStruct* GetCiRecvCiDrCmdDataStruct(void)
{
	return RecvCiDrCmdDataStru;
}

/*
* 功能描述： 清CI接收到的其他联锁动态进路命令数据
* 参数说明： 无
* 返回值  ： 无
*/
void ClearCiRevCiDrCmdData(void)
{
	UINT8 ii = 0U;
	UINT32 dwCycleNum = 0U;
	UINT8 cStruCurSum = 0U;
	UINT8 cNeedKeepSum = 0U;	

	dwCycleNum = Get2oo2CurCycleNum();
	cStruCurSum = RecvCiDrCmdSum;

	for (ii = 0U; ii < cStruCurSum; ii++)
	{
		if (dwCycleNum >= (RecvCiDrCmdDataStru[ii].CycleNo + 1U))
		{
			/*命令存储达到2周期，删除该命令数据,不保留*/
		}
		else
		{
			RecvCiDrCmdDataStru[cNeedKeepSum] = RecvCiDrCmdDataStru[ii];  /*保留当周期命令，不删除*/
			cNeedKeepSum++;
		}
	}

	/*不保留数据全部清零*/
	for (ii = cNeedKeepSum; ii < cStruCurSum; ii++)
	{
		RecvCiDrCmdDataStru[ii].cSourceCiId = 0U;
		RecvCiDrCmdDataStru[ii].cTargetCiId = 0U;
		RecvCiDrCmdDataStru[ii].cCmdType = 0U;
		RecvCiDrCmdDataStru[ii].cLogSecSeqDir = 0U;
		RecvCiDrCmdDataStru[ii].cLogSecSum = 0U;
		(void)CommonMemSet(RecvCiDrCmdDataStru[ii].wLogSecIdBuff, (UINT32)(MAX_ROUTE_IN_LT_NUM * sizeof(UINT16)), 0U, (UINT32)(MAX_ROUTE_IN_LT_NUM * sizeof(UINT16)));
		RecvCiDrCmdDataStru[ii].wTrainId = 0U;
		RecvCiDrCmdDataStru[ii].cTrainLocLogSecSum = 0U;
		(void)CommonMemSet(RecvCiDrCmdDataStru[ii].wTrainLocLogSecIdBuff, (UINT32)(SIZE_MAX_SECTION_BT_TRAIN * sizeof(UINT16)), 0U, (UINT32)(SIZE_MAX_SECTION_BT_TRAIN * sizeof(UINT16)));
		RecvCiDrCmdDataStru[ii].cSwitchMoveFlag = 0U;
		RecvCiDrCmdDataStru[ii].CycleNo = 0U;
		RecvCiDrCmdDataStru[ii].wRelStartSignalId = 0U;
	}

	RecvCiDrCmdSum = cNeedKeepSum;
}

/*
* 功能描述： 校验相邻CI间单帧数据
* 参数说明： UINT8* dataBuf		输入数据信息
*			 UINT16 dataLength   输入数据长度
*			 UINT8 *errNo		校验失败故障码
* 返回值  ： CI_ERROR:校验失败
*			 CI_SUCCESS:校验成功
*/
UINT8 ParseCiToCiDataCheck(UINT8* dataBuf, UINT16 dataLength,UINT8 *errNo)
{
	UINT8 reVal = CI_ERROR;
	UINT8 errorNo_length = 0U;
	UINT16 ii = 0U;			/*数据索引*/

	/*入参防护*/
	if ((dataBuf != NULL) && (dataLength > 0U))
	{
		reVal = CI_SUCCESS;
	}
	else
	{
		reVal = CI_ERROR;
	}

	/*版本号，ID校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiIDAndVer(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 1U;
		}
	}

	/*长度校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCi2CiDataLenValid(dataBuf, dataLength, &errorNo_length);
		if (CI_ERROR == reVal)
		{
			debug_infor_printf((const)"CheckCi2CiDataLenValid error:%d\n", errorNo_length);
			*errNo = 2U;
		}
	}

	/*道岔数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiSwitchData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 3U;
		}
	}

	/*物理区段数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiPhySecData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 4U;
		}
	}

	/*逻辑区段数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiLogSecData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 5U;
		}
	}

	/*信号机数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiSignalData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 6U;
		}
	}

	/*屏蔽门数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiPsdData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 7U;
		}
	}

	/*紧急停车按钮数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiEsbData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 8U;
		}
	}

	/*进路数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiRouteData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 9U;
		}
	}

	/*本联锁中由其它联锁共同管理的物理区段锁闭状态数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiCommonPhyLockData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 10U;
		}
	}

	/*SPKS数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiSpksData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 11U;
		}
	}

	/*虚拟继电器数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiVirRelayData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 12U;
		}
	}

	/*防淹门数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiFloodGateData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 13U;
		}
	}

	/*保护区段数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiOverlapData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 14U;
		}
	}

	/*自动通过进路数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiAutoRouteData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 15U;
		}
	}

	/*本联锁中其他联锁管理的逻辑区段锁闭状态校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiLogicLockData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 16U;
		}
	}

	/*分界点数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiCfpData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 17U;
		}
	}

	/*区间雨雪数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiAreaSnowData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 18U;
		}
	}

	/*区间ITE切除数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiAreaIteCutData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 27U;
		}
	}

	/*进路离去逻辑区段数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiLeaveLogSecData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 23U;
		}
	}

	/*需要检查道岔状态的进路数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiNeedCheckSwRouteData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 24U;
		}
	}

	/*需要检查防护道岔状态的保护区段数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiNeedCheckSwOlpData(dataBuf, &ii);
		if (CI_SUCCESS == reVal)
		{
			/*不处理*/
		}
		else
		{
			*errNo = 25U;
		}
	}
	else
	{
		/*不处理*/
	}

	/*被其它控区进路/保护区段防护锁闭的防护道岔数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiProSwPLockData(dataBuf, &ii);
		if (CI_SUCCESS == reVal)
		{
			/*不处理*/
		}
		else
		{
			*errNo = 26U;
		}
	}
	else
	{
		/*不处理*/
	}

	/*区间疏散数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiEaData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 19U;
		}
	}
	
	/*相邻联锁间命令数据校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiCommandData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 20U;
		}
	}
	/*动态进路命令信息校验*/
	if (CI_SUCCESS == reVal)
	{
		reVal = CheckCiToCiDrCmdData(dataBuf, &ii);
		if (CI_ERROR == reVal)
		{
			*errNo = 21U;
		}
	}

	return reVal;
}


/*
* 功能描述： 校验相邻CI间版本信息和ID
* 参数说明： const UINT8* dataBuf		输入数据信息
*			 UINT8* Index    数据索引(出参，入参)
* 返回值  ： CI_ERROR:校验失败
*			 CI_SUCCESS:校验成功
*/
UINT8 CheckCiIDAndVer(const UINT8* dataBuf, UINT8* Index)
{
	UINT8 reVal = CI_ERROR;
	UINT8 ii = 0u;
	UINT16 sourceId = 0u;		/*源ID*/
	UINT16 targetId = 0u;		/*目标ID*/
	UINT32 sourceCurCycleNo = 0u;/*当前消息的源周期号*/
	UINT16 ciciVer = 0u;/*ci-ci接口版本号*/
	UINT32 dwDataVerFromOtherCi = 0U;
	UINT16 wCiDevName = 0U;/*用于接受带联锁设备类型的联锁ID*/
	UINT32 dwDataVerFromEmap = 0U;
	UINT8 localCiId = 0u;		/*本联锁ID*/
	UINT16 MaskTotalLen = 0u;	/*码位总长度*/
	UINT8 devSum = 0u; /*设备总数*/
	UINT8* deviceIdBuf = NULL; /*设备ID数组*/
	UINT8 deviceFlag = 0u;
	UINT8 yy = 0u;
	localCiId = GetSystemParaLocalCiId();

	if ((dataBuf != NULL) && (Index != NULL))
	{
		ii = *Index;

		sourceId = ShortFromChar(&dataBuf[ii]);			/*获取数据包来源设备ID*/
		ii += 2u;
		sourceCurCycleNo = LongFromChar(&dataBuf[ii]);	/*获取数据包来源的周期号*/
		ii += 4u;
		targetId = ShortFromChar(&dataBuf[ii]);			/*获取数据包目标设备ID*/
		ii += 2u;

		ciciVer = ShortFromChar(&dataBuf[ii]);/*版本号，2个字节*/
		ii += 2u;

		if ((UINT16)CICI_VERSION == ciciVer)
		{
			reVal = CI_SUCCESS;
		}
		else
		{
			debug_infor_printf((const)"CICI_VERSION ERROR,local:%d other:%d\n", CICI_VERSION, ciciVer);
			reVal = CI_ERROR;
		}

		if (CI_SUCCESS == reVal)
		{
			dwDataVerFromOtherCi = LongFromChar(&dataBuf[ii]);	/*相邻联锁公用数据校验信息*/
			ii += 4U;
			wCiDevName = (CI_SYSTEM_TYPE_CI) * 256U + sourceId;
			dwDataVerFromEmap = GetCiTranCiDataCheckVer(localCiId, wCiDevName); /*获取联锁系统数据版本号*/
			if (dwDataVerFromOtherCi != dwDataVerFromEmap)
			{
				reVal = CI_ERROR;
				SetCiSendCmdBackInfoData(CI_BACK_DATA_VER_CHECK_FAIL, CI_SYSTEM_TYPE_CI, sourceId, 0U, 0U);
			}
		}

		if (CI_SUCCESS == reVal)
		{
			MaskTotalLen = ShortFromChar(&dataBuf[ii]);		/*获取站场信息总长度*/
			ii += 2u;

			if (localCiId != targetId)
			{
				/*目标联锁非本联锁返回*/
				reVal = CI_ERROR;
			}
			else
			{
				reVal = CI_SUCCESS;
			}
		}

		if (CI_SUCCESS == reVal)
		{
			/*判断来源设备是否是指定CI*/
			devSum = GetCiTransmitSpecifySysDevSum(Get2oo2SheBeiType()); /*获取通信联锁设备总数*/
			deviceIdBuf = GetCiTransmitSpecifySysDevBuf(Get2oo2SheBeiType()); /*获取通信联锁设备ID数组*/

			if ((0u < devSum) && (NULL != deviceIdBuf))
			{
				for (yy = 0u; yy < devSum; yy++)
				{
					if (deviceIdBuf[yy] == sourceId)
					{
						deviceFlag = 1u;
						break;
					}
				}
				reVal = CI_SUCCESS;
			}
			else
			{
				reVal = CI_ERROR;
			}

			if (CI_SUCCESS == reVal)
			{
				if (0u == deviceFlag)
				{
					reVal = CI_ERROR;
				}
				else
				{
					reVal = CI_SUCCESS;
				}
			}
		}

		*Index = ii;		/*返回对应索引*/
	}
	else
	{
		;	/*不处理*/
	}

	return reVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的道岔数据
* 参数说明：const UINT8* dataBuf 待解析的数据
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiSwitchData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 cSwitchSum = 0U;  /*道岔数量*/
	UINT16 wSwitchId = 0U;   /*道岔ID*/
	UINT8 cSwitchYDLockState = 0U;  /*道岔引导总锁状态*/
	UINT8 cSwitchLockState = 0U;  /*道岔锁闭状态*/
	UINT8 cSwitchFLockState = 0U;  /*道岔封锁状态*/
	UINT8 cSwitchCurPos = 0U;  /*道岔当前位置*/
	UINT8 cSingleSwitchCurPos = 0U;  /*单独道岔当前位置*/
	UINT8 cSwitchBelongCiId = 0U;
	UINT8 cLocalCiId = 0U;
	UINT8 switchIsThisLineFlag = 0U;		/*道岔是否为本线路*/
	UINT8 ConnetSwitchDsState = 0U;			/*联络线道岔单锁状态*/
	UINT8 ConnetSwitchByPassState = 0U;			/*联络线道岔旁路状态*/
	UINT8 chSwitchJichaState = 0U;/*道岔挤岔状态*/
	UINT16 wUsingBelongOverlapId = 0U;  /*征用所属保护区段ID*/
	UINT8 cSwitchUsingState = 0U;  /*道岔征用状态*/

	cLocalCiId = GetSystemParaLocalCiId();

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;
		cSwitchSum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		if (SWITCH_SUM_MAX > cSwitchSum)
		{
			retVal = CI_SUCCESS;
			for (jj = 0U; jj < cSwitchSum; jj++)
			{
				/*校验道岔ID*/
				wSwitchId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				if ((0U < wSwitchId) && (SWITCH_SUM_MAX > wSwitchId))
				{
					/*继续校验*/
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchId Is 0 Or Exceed Max %d\n", wSwitchId, SWITCH_SUM_MAX);
					retVal = CI_ERROR;
				}

				cSwitchBelongCiId = GetSwitchBelongCiId(wSwitchId);
				if (cSwitchBelongCiId == cLocalCiId)
				{
					ii += CICI_ONE_SWITCH_LEN - 2U;  /*跳过属于本联锁的道岔状态信息，继续校验*/
				}
				else
				{
					/*校验道岔引导总锁状态*/
					if (CI_SUCCESS == retVal)
					{
						cSwitchYDLockState = dataBuf[ii];
						ii++;
						if ((SWITCH_LOCK_YINZONG_NO == cSwitchYDLockState) || (SWITCH_LOCK_YINZONG_YES == cSwitchYDLockState))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchYDLockState Is %d\n", wSwitchId, cSwitchYDLockState);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}

					/*校验道岔锁闭状态*/
					if (CI_SUCCESS == retVal)
					{
						cSwitchLockState = dataBuf[ii];
						ii++;
						if ((SWITCH_LOCK_STATUS_NO == cSwitchLockState) || (SWITCH_LOCK_STATUS_DANSUO == cSwitchLockState)
							|| (SWITCH_LOCK_STATUS_PROTECT == cSwitchLockState) || (SWITCH_LOCK_STATUS_DAP == cSwitchLockState))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchLockState Is %d\n", wSwitchId, cSwitchLockState);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}

					/*校验道岔封锁状态*/
					if (CI_SUCCESS == retVal)
					{
						cSwitchFLockState = dataBuf[ii];
						ii++;
						if ((SWITCH_LOCK_FENGSUO_NO == cSwitchFLockState) || (SWITCH_LOCK_FENGSUO_YES == cSwitchFLockState))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchFLockState Is %d\n", wSwitchId, cSwitchFLockState);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}

					/*校验道岔当前位置*/
					if (CI_SUCCESS == retVal)
					{
						cSwitchCurPos = dataBuf[ii];
						ii++;
						if ((SWITCH_POSITION_DINGWEI == cSwitchCurPos) || (SWITCH_POSITION_FANWEI == cSwitchCurPos) || (SWITCH_POSITION_SIKAI == cSwitchCurPos)
							|| (SWITCH_POSITION_MOVE == cSwitchCurPos) || (SWITCH_POSITION_JICHA == cSwitchCurPos))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchCurPos Is %d\n", wSwitchId, cSwitchCurPos);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}

					/*校验单独道岔当前位置*/
					if (CI_SUCCESS == retVal)
					{
						cSingleSwitchCurPos = dataBuf[ii];
						ii++;
						if ((SWITCH_POSITION_DINGWEI == cSingleSwitchCurPos) || (SWITCH_POSITION_FANWEI == cSingleSwitchCurPos) || (SWITCH_POSITION_SIKAI == cSingleSwitchCurPos)
							|| (SWITCH_POSITION_MOVE == cSingleSwitchCurPos) || (SWITCH_POSITION_JICHA == cSingleSwitchCurPos))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SingleSwitchCurPos Is %d\n", wSwitchId, cSingleSwitchCurPos);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}

					/*校验联络线道岔单锁状态*/
					if (CI_SUCCESS == retVal)
					{
						switchIsThisLineFlag = GetSwitchIsThisLineState(wSwitchId);
						if (DEV_IS_THIS_LINE_NO == switchIsThisLineFlag)
						{
							ConnetSwitchDsState = dataBuf[ii];
							ii++;
							if ((CONNECT_SWITCH_DANSUO_YES == ConnetSwitchDsState) || (CONNECT_SWITCH_DANSUO_NO == ConnetSwitchDsState))
							{
								/*继续校验*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: ConnetSwitchDsState Is %d\n", wSwitchId, ConnetSwitchDsState);
								retVal = CI_ERROR;
							}

							if (CI_SUCCESS == retVal)
							{
								ConnetSwitchByPassState = dataBuf[ii];
								ii++;

								if ((SWITCH_BYPASS_NO == ConnetSwitchByPassState) || (SWITCH_BYPASS_YES == ConnetSwitchByPassState))
								{
									/*继续校验*/
								}
								else
								{
									debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: ConnetSwitchByPassState Is %d\n", wSwitchId, ConnetSwitchByPassState);
									retVal = CI_ERROR;
								}
							}
							else
							{
								/*校验失败*/
							}
						}
						else
						{
							ii += 2U;	/*非联络线的道岔跳过此二字节*/
						}
					}
					else
					{
						/*校验失败*/
					}

					/*校验单独道岔挤岔状态*/
					if (CI_SUCCESS == retVal)
					{
						chSwitchJichaState = dataBuf[ii];
						ii++;
						if ((SWITCH_POSITION_DYNAMIC_JICHA == chSwitchJichaState) || (SWITCH_POSITION_SUDDEN_JICHA == chSwitchJichaState) || (0U == chSwitchJichaState))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: chSwitchJichaState Is %d\n", wSwitchId, chSwitchJichaState);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}

					/*校验道岔征用所属保护区段*/
					if (CI_SUCCESS == retVal)
					{
						wUsingBelongOverlapId = ShortFromChar(&dataBuf[ii]);
						ii += 2U;
						if (OVERLAP_SUM_MAX > wUsingBelongOverlapId)
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: UsingBelongOverlapId Is %d\n", wSwitchId, wUsingBelongOverlapId);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}

					/*校验道岔征用状态*/
					if (CI_SUCCESS == retVal)
					{
						cSwitchUsingState = dataBuf[ii];
						ii++;
						if ((SWITCH_USING_NO == cSwitchUsingState) || (SWITCH_USING_YES == cSwitchUsingState)
							|| (SWITCH_USING_APPLY == cSwitchUsingState) || (SWITCH_USING_CANCEL == cSwitchUsingState))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchUsingState Is %d\n", wSwitchId, cSwitchUsingState);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}
				}

				if (CI_SUCCESS != retVal)
				{
					break;
				}
				else
				{
					/*继续校验*/
				}
			}
		}
		else
		{
			/*道岔数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiSwitchData Is Error: SwitchSum %d Exceed Max %d\n", cSwitchSum, SWITCH_SUM_MAX);
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的物理区段数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiPhySecData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 wPhySecSum = 0U;/*物理区段数目*/
	UINT16 wPhySecId = 0U;/*物理区段Id*/
	UINT8 chPhySecBelongCiId = 0U;/*物理区段所属联锁*/
	UINT8 chLocalCiId = 0U;/*本地联锁ID*/
	UINT8 chPhySecOccupyState = 0U;/*物理区段占用状态*/
	UINT8 chPhySecUtOrCtState = 0U;/*物理区段UT或CT占用状态*/
	UINT8 chPhySecStopSteadyFlag = 0U;/*物理区段停稳信息*/
	UINT8 chPhySecUsingState = 0U;/*物理区段征用状态*/
	UINT16 wPhySecUseBelongRouteId = 0U;/*物理区段征用所属进路ID*/
	UINT8 chPhySecFLockState = 0U;/*物理区段封锁状态*/
	UINT8 chPhySecArbState = 0U;/*物理区段Arb状态*/
	UINT8 chPhySecCurAndMergeState = 0U;/*物理区段与占用状态*/
	UINT8 chPhySecJumpLockState = 0U;/*物理区段跳跃锁闭状态*/
	UINT8 chPhySecFLockType = 0U;/*物理区段封锁类型*/
	UINT8 chPhySecPreResetState = 0U;/*物理区段预复位状态*/
	UINT16 wPhySecErrUnlockTime = 0U;/*物理区段区故解倒计时*/
	UINT8 chPhySecAreaUrgentState = 0U;/*物理区段区域紧急制动状态*/
	UINT8 chPhyAblTrainFlag = 0U; /*物理区段ABL占用标志*/
	UINT8 chPhyUtOccupyFlag = 0U; /*物理区段坏车占用标志*/
	UINT8 cPhySecInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO;
	UINT16 wProSwSecUseBelRouteId = 0U;/*防护道岔物理区段征用所属进路ID*/

	chLocalCiId = GetSystemParaLocalCiId();

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		wPhySecSum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		if (PHYSICAL_SECTION_SUM_MAX > wPhySecSum)
		{
			for (jj = 0U; jj < wPhySecSum; jj++)
			{
				/*物理区段ID*/
				wPhySecId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId))
				{
					chPhySecBelongCiId = GetPhySecBelongCiId(wPhySecId);
					if (chLocalCiId == chPhySecBelongCiId)
					{
						ii += CICI_ONE_PHYSEC_LEN - 2U;/*跳过属于本联锁的物理区段状态信息*/
					}
					else
					{
						/*物理区段采集占用状态*/
						chPhySecOccupyState = dataBuf[ii];
						ii++;
						if ((SECTION_OCCUPY_NO == chPhySecOccupyState) || (SECTION_OCCUPY_YES == chPhySecOccupyState))
						{
							/*继续解析*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecCurOccupyState Is %d\n", wPhySecId, chPhySecOccupyState);
						}

						if (CI_SUCCESS == retVal)
						{
							/*物理区段融合后的占用状态*/
							chPhySecOccupyState = dataBuf[ii++];
							if ((SECTION_OCCUPY_NO == chPhySecOccupyState) || (SECTION_OCCUPY_YES == chPhySecOccupyState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecMerOccupyState Is %d\n", wPhySecId, chPhySecOccupyState);
							}
						}
						else
						{
							/*不处理*/
						}

						if (CI_SUCCESS == retVal)
						{
							/*物理区段当前CT或UT占用状态*/
							chPhySecUtOrCtState = dataBuf[ii++];
							if ((LOGICSECTION_OCCUPY_UT == chPhySecUtOrCtState) || (LOGICSECTION_OCCUPY_CT == chPhySecUtOrCtState)
								|| (LOGICSECTION_OCCUPY_NO == chPhySecUtOrCtState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecOccupyState Is %d\n", wPhySecId, chPhySecOccupyState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*物理区段停稳信息*/
							chPhySecStopSteadyFlag = dataBuf[ii++];
							if ((PHYSICAL_SECTION_STOPSTEADY_NO == chPhySecStopSteadyFlag) || (PHYSICAL_SECTION_STOPSTEADY_YES == chPhySecStopSteadyFlag))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecStopSteadyFlag Is %d\n", wPhySecId, chPhySecStopSteadyFlag);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*物理区段征用状态*/
							chPhySecUsingState = dataBuf[ii++];
							if ((PHYSICAL_SECTION_USING_NO == chPhySecUsingState) || (PHYSICAL_SECTION_USING_YES == chPhySecUsingState)
								|| (PHYSICAL_SECTION_USING_APPLY == chPhySecUsingState) || (PHYSICAL_SECTION_USING_CANCEL == chPhySecUsingState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecUsingState Is %d\n", wPhySecId, chPhySecUsingState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*物理区段征用所属进路ID*/
							wPhySecUseBelongRouteId = ShortFromChar(&dataBuf[ii]);
							ii += 2U;
							if (ROUTE_SUM_MAX > wPhySecUseBelongRouteId)
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: wPhySecUseBelongRouteId Is %d\n", wPhySecId, wPhySecUseBelongRouteId);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*防护道岔物理区段征用所属进路ID*/
							wProSwSecUseBelRouteId = ShortFromChar(&dataBuf[ii]);
							ii += 2U;
							if (ROUTE_SUM_MAX > wProSwSecUseBelRouteId)
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: wProSwSecUseBelRouteId Is %d\n", wPhySecId, wProSwSecUseBelRouteId);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*物理区段封锁状态*/
							chPhySecFLockState = dataBuf[ii++];
							if ((PHYSICAL_SECTION_FLOCK_NO == chPhySecFLockState) || (PHYSICAL_SECTION_FLOCK_YES == chPhySecFLockState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecFLockState Is %d\n", wPhySecId, chPhySecFLockState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*物理区段Arb状态*/
							chPhySecArbState = dataBuf[ii++];
							if ((AXIS_SECTION_ARB_NO == chPhySecArbState) || (AXIS_SECTION_ARB_YES == chPhySecArbState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecArbState Is %d\n", wPhySecId, chPhySecArbState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*物理区段与占用状态*/
							chPhySecCurAndMergeState = dataBuf[ii++];
							if ((SECTION_OCCUPY_NO == chPhySecCurAndMergeState) || (SECTION_OCCUPY_YES == chPhySecCurAndMergeState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecCurAndMergeState Is %d\n", wPhySecId, chPhySecCurAndMergeState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*物理区段跳跃锁闭状态*/
							chPhySecJumpLockState = dataBuf[ii++];
							if ((PHYSICAL_SECTION_JUMP_LOCK_YES == chPhySecJumpLockState) || (PHYSICAL_SECTION_JUMP_LOCK_NO == chPhySecJumpLockState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecJumpLockState Is %d\n", wPhySecId, chPhySecJumpLockState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*物理区段封锁类型*/
							chPhySecFLockType = dataBuf[ii++];
							if ((PHY_SEC_FLOCK_TYPE_NONE == chPhySecFLockType) || (PHY_SEC_FLOCK_TYPE_SPKSCMD == chPhySecFLockType)
								|| (PHY_SEC_FLOCK_TYPE_SPKS == chPhySecFLockType) || (PHY_SEC_FLOCK_TYPE_CMD == chPhySecFLockType))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecFLockType Is %d\n", wPhySecId, chPhySecFLockType);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*物理区段预复位状态*/
							chPhySecPreResetState = dataBuf[ii++];
							if ((PHYSICAL_SECTION_PRE_RESET_YES == chPhySecPreResetState) || (PHYSICAL_SECTION_PRE_RESET_NO == chPhySecPreResetState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecPreResetState Is %d\n", wPhySecId, chPhySecPreResetState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							wPhySecErrUnlockTime = ShortFromChar(&dataBuf[ii]);
							ii += 2U;
							if (UINT16_MAX > wPhySecErrUnlockTime)
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: wPhySecErrUnlockTime Is %d\n", wPhySecId, wPhySecErrUnlockTime);
							}
						}

						if (CI_SUCCESS == retVal)
						{
							/*物理区段区域紧急制动状态*/
							chPhySecAreaUrgentState = dataBuf[ii++];
							if ((PHYSEC_AREA_URGENT_NO == chPhySecAreaUrgentState) || (PHYSEC_AREA_URGENT_YES == chPhySecAreaUrgentState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecAreaUrgentState Is %d\n", wPhySecId, chPhySecAreaUrgentState);
							}
						}

						if (CI_SUCCESS == retVal)
						{
							/*物理区段ABL占用状态*/
							chPhyAblTrainFlag = dataBuf[ii++];
							if ((PHYSICAL_SECTION_ABLOCCUPY_NO == chPhyAblTrainFlag) || (PHYSICAL_SECTION_ABLOCCUPY_YES == chPhyAblTrainFlag) || (PHYSICAL_SECTION_ABLOCCUPY_DEFAULT == chPhyAblTrainFlag))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhyAblTrainFlag Is %d\n", wPhySecId, chPhyAblTrainFlag);
							}
						}

						if (CI_SUCCESS == retVal)
						{
							/*物理区段坏车占用占用状态*/
							chPhyUtOccupyFlag = dataBuf[ii++];
							if ((PHYSICAL_AXIS_UT_YES == chPhyUtOccupyFlag) || (PHYSICAL_AXIS_UT_NO == chPhyUtOccupyFlag))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhyUtOccupyFlag Is %d\n", wPhySecId, chPhyUtOccupyFlag);
							}
						}

						if (CI_SUCCESS == retVal)
						{
							/*物理区段湿轨标志*/
							cPhySecInHumidRailFlag = dataBuf[ii++];
							if ((PHYSEC_IN_HUMID_RAIL_YES == cPhySecInHumidRailFlag) || (PHYSEC_IN_HUMID_RAIL_NO == cPhySecInHumidRailFlag))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: cPhySecInHumidRailFlag Is %d\n", wPhySecId, cPhySecInHumidRailFlag);
							}
						}
						else
						{
							/*不处理*/
						}
					}
				}
				else
				{
					retVal = CI_ERROR;
					debug_infor_printf((const)"CheckCiToCiPhySecData Is Error: wPhySecId Is %d\n", wPhySecId);
				}
				if (CI_ERROR == retVal)
				{
					break;
				}
			}

		}
		else
		{
			retVal = CI_ERROR;
			/*物理数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiPhySecData Is Error: wPhySecSum Is %d\n", wPhySecSum);
		}
		*index = ii;
	}
	else
	{
		retVal = CI_ERROR; /*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的逻辑区段数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiLogSecData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 kk = 0U;
	UINT16 wLogSecSum = 0U;/*逻辑区段数目*/
	UINT16 wLogSecId = 0U;/*逻辑区段Id*/
	UINT8 chLogSecBelongCiId = 0U;/*逻辑区段所属联锁*/
	UINT8 chLocalCiId = 0U;/*本地联锁ID*/
	UINT8 chLogSecCurOccupyState = 0U;/*逻辑区段占用状态*/
	UINT8 chLogSecLSXSState = 0U;/*逻辑区段临时限速设置状态*/
	UINT8 chLogSecJumpLockState = 0U;/** 逻辑区段跳跃锁闭状态 */
	UINT8 chLogSecArbState = 0U;/* 逻辑区段ARB状态 */
	UINT8 chLogSecResTrainSum = 0U;/*逻辑区段资源列车数量*/
	UINT16 wLogSecResTrainId = 0U;/*逻辑区段资源列车ID*/
	UINT8 chLogSecTrainUseState = 0U;/*逻辑区段资源可用状态*/
	UINT8 chLogSecSpksFLockState = 0U;/*逻辑区段SPKS封锁状态*/
	UINT8 chLogSecProResUseState = 0U;/*逻辑区段保护锁闭资源可用状态*/
	UINT8 chLogSecAblUseFlag = 0U;
	UINT8 chLogSecXinsuSpeed = 0U;

	chLocalCiId = GetSystemParaLocalCiId();

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		wLogSecSum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		if (LOGIC_SECTION_SUM_MAX > wLogSecSum)
		{
			for (jj = 0U; jj < wLogSecSum; jj++)
			{
				/*逻辑区段ID*/
				wLogSecId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				if ((0U < wLogSecId) && (LOGIC_SECTION_SUM_MAX > wLogSecId))
				{
					chLogSecBelongCiId = GetLogSecBelongCiId(wLogSecId);
					if (chLocalCiId == chLogSecBelongCiId)
					{
						ii += CICI_ONE_LOGSEC_LEN - 2U;/*跳过属于本联锁的逻辑区段状态信息*/
						ii = ii + 1U + (dataBuf[ii] * 3U);/* 跳过逻辑区段资源相关数目1B + 数目*3B */
					}
					else
					{
						/*逻辑区段占用状态*/
						chLogSecCurOccupyState = dataBuf[ii++];
						if ((LOGICSECTION_OCCUPY_UT == chLogSecCurOccupyState) || (LOGICSECTION_OCCUPY_CT == chLogSecCurOccupyState)
							|| (LOGICSECTION_OCCUPY_NO == chLogSecCurOccupyState))
						{
							retVal = CI_SUCCESS; /*继续解析*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecCurOccupyState Is %d\n", wLogSecId, chLogSecCurOccupyState);
						}
						if (CI_SUCCESS == retVal)
						{
							/*逻辑区段临时限速设置状态*/
							chLogSecLSXSState = dataBuf[ii++];
							if ((LOGSEC_LSXS_SET_STATE_NO == chLogSecLSXSState) || (LOGSEC_LSXS_SET_STATE_YES == chLogSecLSXSState)
								|| (LOGSEC_LSXS_SET_STATE_INVALID == chLogSecLSXSState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecLSXSState Is %d\n", wLogSecId, chLogSecLSXSState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/* 逻辑区段跳跃锁闭状态 */
							chLogSecJumpLockState = dataBuf[ii++];
							if ((LOGIC_SECTION_JUMP_LOCK_NO == chLogSecJumpLockState) || (LOGIC_SECTION_JUMP_LOCK_YES == chLogSecJumpLockState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecJumpLockState Is %d\n", wLogSecId, chLogSecJumpLockState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/* 逻辑区段ARB状态 */
							chLogSecArbState = dataBuf[ii++];
							if ((LGC_SECTION_ARB_NO == chLogSecArbState) || (LGC_SECTION_ARB_YES == chLogSecArbState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecArbState Is %d\n", wLogSecId, chLogSecArbState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/* 逻辑区段SPKS封锁状态 */
							chLogSecSpksFLockState = dataBuf[ii++];
							if ((LOGIC_SECTION_SPKS_FLOCK_NO == chLogSecSpksFLockState) || (LOGIC_SECTION_SPKS_FLOCK_YES == chLogSecSpksFLockState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecSpksFLockState Is %d\n", wLogSecId, chLogSecSpksFLockState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/* 逻辑区段保护锁闭资源可用状态 */
							chLogSecProResUseState = dataBuf[ii++];
							if ((LOGIC_SECTION_PRO_RES_UNUSABLE == chLogSecProResUseState) || (LOGIC_SECTION_PRO_RES_USABLE == chLogSecProResUseState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecProResUseState Is %d\n", wLogSecId, chLogSecProResUseState);
							}
						}

						if (CI_SUCCESS == retVal)
						{
							/* 逻辑区段ABL接近资源可用标志 */
							chLogSecAblUseFlag = dataBuf[ii++];
							if ((LOGIC_ABLNEAR_USE_FLAG_YES == chLogSecAblUseFlag) || (LOGIC_ABLNEAR_USE_FLAG_NO == chLogSecAblUseFlag))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecAblUseFlag Is %d\n", wLogSecId, chLogSecAblUseFlag);
							}
						}

						if (CI_SUCCESS == retVal)
						{
							/* 逻辑区段临时限速速度值 */
							chLogSecXinsuSpeed = dataBuf[ii++];
							if (UINT8_MAX > chLogSecXinsuSpeed)
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecXinsuSpeed Is %d\n", wLogSecId, chLogSecXinsuSpeed);
							}
						}

						if (CI_SUCCESS == retVal)
						{
							/* 逻辑区段资源列车数量 */
							chLogSecResTrainSum = dataBuf[ii++];
							if (LOGIC_SECTION_RES_SUM_MAX >= chLogSecResTrainSum)
							{
								for (kk = 0U; kk < chLogSecResTrainSum; kk++)
								{
									if (CI_SUCCESS == retVal)
									{
										/*逻辑区段资源列车ID*/
										wLogSecResTrainId = ShortFromChar(&dataBuf[ii]);/*逻辑区段资源列车ID*/
										ii += 2U;
										if (((0U < wLogSecResTrainId) && (254U >= wLogSecResTrainId))
											|| ((0X1401U <= wLogSecResTrainId) && (0X14FEU >= wLogSecResTrainId)))
										{
											retVal = CI_SUCCESS; /*继续解析*/
										}
										else
										{
											retVal = CI_ERROR;
											debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: wLogSecResTrainId Is %d\n", wLogSecId, wLogSecResTrainId);
										}
									}
									if (CI_SUCCESS == retVal)
									{
										/*逻辑区段资源可用状态*/
										chLogSecTrainUseState = dataBuf[ii++];/*逻辑区段资源可用状态*/
										if ((LOGIC_SECTION_RES_USABLE == chLogSecTrainUseState) || (LOGIC_SECTION_RES_UNUSABLE == chLogSecTrainUseState))
										{
											retVal = CI_SUCCESS; /*继续解析*/
										}
										else
										{
											retVal = CI_ERROR;
											debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecTrainUseState Is %d\n", wLogSecId, chLogSecTrainUseState);
										}
									}
								}
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecResTrainSum Is %d\n", wLogSecId, chLogSecResTrainSum);
							}
						}
					}
				}
				else
				{
					retVal = CI_ERROR;
					debug_infor_printf((const)"CheckCiToCiLogSecData Is Error: wLogSecId Is %d\n", wLogSecId);
				}
				if (CI_ERROR == retVal)
				{
					break;
				}
			}

		}
		else
		{
			retVal = CI_ERROR;
			/*逻辑区段数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiLogSecData Is Error: wLogSecSum Is %d\n", wLogSecSum);
		}
		*index = ii;
	}
	else
	{
		retVal = CI_ERROR; /*入参校验失败，返回失败*/
	}
	

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的信号机数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiSignalData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 wSignalSum = 0U;/*信号机数目*/
	UINT16 wSignalId = 0U;/*信号机Id*/
	UINT8 chSignalBelongCiId = 0U;/*信号机所属联锁*/
	UINT8 chLocalCiId = 0U;/*本地联锁ID*/
	UINT8 chSignalFLockState = 0U;/*信号机封锁状态*/
	UINT8 chSignalLigExtinctState = 0U;/*信号机亮灭状态状态*/
	UINT8 chSignalCurColor = 0U;/*信号机当前显示颜色状态*/
	UINT8 chSignalLSXSSetFlag = 0U;/*信号机临时限速状态*/
	UINT8 chSignalDetainFlag = 0U;/*信号机扣车状态*/
	UINT8 chSignalRelayDetainFlag = 0U;/*信号机硬线扣车状态*/
	UINT8 chSignalMaintainState = 0U;/*信号机维修点灯状态*/
	UINT8 chSignalDsState = 0U;/*信号机断丝状态*/
	UINT8 chDsState = 0U; /*信号机断丝按位校验*/
	UINT8 chCheckSigCurColorResult = CI_ERROR;/*信号机当前显示颜色合法性检查结果*/
	UINT8 cCutBtnState = 0U;  /*旁路按钮状态*/

	chLocalCiId = GetSystemParaLocalCiId();

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		wSignalSum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		if (SIGNAL_SUM_MAX > wSignalSum)
		{
			for (jj = 0U; jj < wSignalSum; jj++)
			{
				/*信号机ID*/
				wSignalId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				if ((0U < wSignalId) && (SIGNAL_SUM_MAX > wSignalId))
				{
					chSignalBelongCiId = GetSignalBelongCiId(wSignalId);
					if (chLocalCiId == chSignalBelongCiId)
					{
						ii += CICI_ONE_SIGNAL_LEN - 2U;/*跳过属于本联锁的信号机状态信息*/
					}
					else
					{
						/*信号机封锁状态*/
						chSignalFLockState = dataBuf[ii++];
						if ((SIGNAL_FENGSUO_NO == chSignalFLockState) || (SIGNAL_FENGSUO_YES == chSignalFLockState))
						{
							retVal = CI_SUCCESS; /*继续解析*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalFLockState Is %d\n", wSignalId, chSignalFLockState);
						}
						if (CI_SUCCESS == retVal)
						{
							/*信号机亮灭状态状态*/
							chSignalLigExtinctState = dataBuf[ii++];
							if ((SIGNAL_LIGHT_EXTICT_STATE_NO == chSignalLigExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_YES == chSignalLigExtinctState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalLigExtinctState Is %d\n", wSignalId, chSignalLigExtinctState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*信号机当前显示颜色状态*/
							chSignalCurColor = dataBuf[ii++];
							chCheckSigCurColorResult = CheckSignalCurColor(chSignalCurColor);
							if (CI_SUCCESS == chCheckSigCurColorResult)
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalCurColor Is %d\n", wSignalId, chSignalCurColor);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*信号机临时限速状态*/
							chSignalLSXSSetFlag = dataBuf[ii++];
							if ((SIGNAL_LINSHIXIANSUSET_STATE_NO == chSignalLSXSSetFlag) || (SIGNAL_LINSHIXIANSUSET_STATE_YES == chSignalLSXSSetFlag)
								|| (SIGNAL_LINSHIXIANSUSET_STATE_INVALID == chSignalLSXSSetFlag))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalLSXSSetFlag Is %d\n", wSignalId, chSignalLSXSSetFlag);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*信号机扣车状态*/
							chSignalDetainFlag = dataBuf[ii++];
							if ((SIGNAL_DETAIN_YES == chSignalDetainFlag) || (SIGNAL_DETAIN_XIANDI_ATSAUTO == chSignalDetainFlag) || (SIGNAL_DETAIN_NO == chSignalDetainFlag)
								|| (SIGNAL_DETAIN_XIANDI == chSignalDetainFlag) || (SIGNAL_DETAIN_ATS == chSignalDetainFlag) || (SIGNAL_DETAIN_ATS_AUTO == chSignalDetainFlag)
								|| (SIGNAL_RELAY_DETAIN_YES == chSignalDetainFlag))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalDetainFlag Is %d\n", wSignalId, chSignalDetainFlag);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*信号机硬线扣车状态*/
							chSignalRelayDetainFlag = dataBuf[ii++];
							if ((SIGNAL_RELAY_DETAIN_NO == chSignalRelayDetainFlag) || (SIGNAL_RELAY_DETAIN_YES == chSignalRelayDetainFlag))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalRelayDetainFlag Is %d\n", wSignalId, chSignalRelayDetainFlag);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*信号机维修点灯状态*/
							chSignalMaintainState = dataBuf[ii++];
							if ((MAINTAIN_STATE_YES == chSignalMaintainState) || (MAINTAIN_STATE_NO == chSignalMaintainState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalMaintainState Is %d\n", wSignalId, chSignalMaintainState);
							}
						}
						if (CI_SUCCESS == retVal)
						{
							/*信号机断丝状态*/
							chSignalDsState = dataBuf[ii++];
							/*bit7~bit6红蓝断 10红断 01蓝断 11同时断 00无断丝 均为合法值无需校验*/
							chDsState = (chSignalDsState & SIGNAL_DS_BREAK_GREEN);
							if ((SIGNAL_DS_BREAK_GREEN == chDsState) || (0U == chDsState))
							{
								chDsState = (chSignalDsState & SIGNAL_DS_BREAK_YELLOW);
								if ((SIGNAL_DS_BREAK_YELLOW == chDsState) || (0U == chDsState))
								{
									chDsState = (chSignalDsState & SIGNAL_DS_BREAK_WHITE);
									if ((SIGNAL_DS_BREAK_WHITE == chDsState) || (0U == chDsState))
									{
										retVal = CI_SUCCESS; /*继续解析*/
									}
									else
									{
										retVal = CI_ERROR;
										debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalWhiteDsState Is %d\n", wSignalId, chSignalDsState);
									}
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalYellowDsState Is %d\n", wSignalId, chSignalDsState);
								}
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalGreenDsState Is %d\n", wSignalId, chSignalDsState);
							}
						}

						if (CI_SUCCESS == retVal)
						{
							/*信号机扣车旁路按钮状态*/
							cCutBtnState = dataBuf[ii];
							ii++;
							if ((SIGNAL_DETAIN_CUT_VALID_NO == cCutBtnState) || (SIGNAL_DETAIN_CUT_VALID_YES == cCutBtnState))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: SignalDetCutBtnState Is %d\n", wSignalId, cCutBtnState);
							}
						}
						else
						{
							/*不处理*/
						}
					}
				}
				else
				{
					retVal = CI_ERROR;
					debug_infor_printf((const)"CheckCiToCiSignalData Is Error: wSignalId Is %d\n", wSignalId);
				}
				if (CI_ERROR == retVal)
				{
					break;
				}
			}

		}
		else
		{
			retVal = CI_ERROR;
			/*信号机数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiSignalData Is Error: wSignalSum Is %d\n", wSignalSum);
		}
		*index = ii;
	}
	else
	{
		retVal = CI_ERROR; /*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的命令数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiCommandData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 wCommandSum = 0U;/*相邻联锁间命令数量*/
	UINT16 wCommandId = 0U;/*相邻联锁间命令编号*/
	UINT16 wCommandParam1 = 0U;/*相邻联锁间命令参数1*/
	UINT16 wCommandParam2 = 0U;/*相邻联锁间命令参数2*/
	UINT8 chNeiborCiType = 0U;/*相邻联锁联锁类型*/
	UINT8 chDevState = 0U;/*设备状态*/

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		wCommandSum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		if (RECVCI_CMD_DATA_STRU_SUM_MAX >= wCommandSum)
		{
			for (jj = 0U; jj < wCommandSum; jj++)
			{
				if (CI_SUCCESS == retVal)
				{
					/*相邻联锁间命令编号*/
					wCommandId = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					/*相邻联锁间命令参数1*/
					wCommandParam1 = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					/*相邻联锁间命令参数2*/
					wCommandParam2 = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					switch (wCommandId)
					{
						case CI_CMD_PHYSEC_USING_APPLY:/*物理区段征用申请*/
						{
							if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((0U < wCommandParam2) && (ROUTE_SUM_MAX > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_PHYSEC_USING_REPLAY_FAILURE:/*物理区段征用失败应答*/
						{
							if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (ROUTE_SUM_MAX > wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_PHYSEC_USING_CANCEL:/*物理区段征用取消*/
						{
							if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((0U < wCommandParam2) && (ROUTE_SUM_MAX > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_PROSW_SEC_USING_APPLY:/*防护道岔物理区段征用申请*/
						{
							if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((0U < wCommandParam2) && (ROUTE_SUM_MAX > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_PROSW_SEC_USING_FAIL:/*防护道岔物理区段征用失败应答*/
						{
							if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (ROUTE_SUM_MAX > wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_PROSW_SEC_USING_CANCEL:/*防护道岔物理区段征用取消*/
						{
							if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((0U < wCommandParam2) && (ROUTE_SUM_MAX > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_SWITCH_DRIVE:/*道岔驱动命令*/
						{
							if ((0U < wCommandParam1) && (SWITCH_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if((SWITCH_POSITION_DINGWEI == wCommandParam2) || (SWITCH_POSITION_FANWEI == wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_SIGNAL_SPEC_OPEN_APPLY:/*信号特开申请命令*/
						{
							if ((0U < wCommandParam1) && (SIGNAL_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (0U == wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_KOUCHE:/*相邻联锁软扣车命令*/
						{
							if ((0U < wCommandParam1) && (SIGNAL_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((SIGNAL_DETAIN_ATS == wCommandParam2)|| (SIGNAL_DETAIN_ATS_AUTO == wCommandParam2) || (SIGNAL_DETAIN_XIANDI == wCommandParam2)
									|| (SIGNAL_DETAIN_ATS_NO == wCommandParam2) || (SIGNAL_DETAIN_XIANDI_NO == wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_KOUCHE_DETAIN:/*相邻联锁硬线扣车命令*/
						{
							if ((0U < wCommandParam1) && (SIGNAL_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((SIGNAL_DETAIN_CI_RELAY_YES == wCommandParam2) || (SIGNAL_DETAIN_CI_RELAY_NO == wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_TRAIN_TEST_APPLY:/*车辆段联锁处理试车线联锁的试车请求*/
						{
							if (COMM_TRAIN_TEST_SQAJ_SCX == wCommandParam1)
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								chNeiborCiType = (UINT8)((wCommandParam2 & ((UINT16)0x00FF)));/*相邻联锁类型*/
								chDevState = (UINT8)((wCommandParam2 >> 8));/*设备状态*/
								if ((CI_TYPE_SCX == chNeiborCiType) && ((COMM_TRAIN_TEST_DEV_STATE_VALID == chDevState) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == chDevState)))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_TRAIN_TEST_ALLOW_STATUS:/*试车线联锁处理车辆段联锁发送的试车允许状态*/
						{
							if (COMM_TRAIN_TEST_TYSJ_CLD == wCommandParam1)
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((COMM_TRAIN_TEST_DEV_STATE_VALID == wCommandParam2) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_SET_PSC_PL:/*相邻联锁PSC旁路命令*/
						{
							if ((0U < wCommandParam1) && (PSD_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((0U < wCommandParam2) && (PSC_SUM_MAX > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_QX_PSC_PL:/*相邻联锁取消PSC旁路命令*/
						{
							if ((0U < wCommandParam1) && (PSD_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((0U < wCommandParam2) && (PSC_SUM_MAX > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_SECTION_FAULT_UNLOCK:/*相邻联锁区段故障解锁命令*/
						{
							if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (0U == wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_AUTO_SIG_ROUTE_CANCLE:/*自动信号取消命令*/
						{
							if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (0U == wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_SET_AUTO_SIG_ROUTE_VALID:/*自动信号进路设置自动属性*/
						{
							if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (0U == wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_PSD_VOBC_CMD_TO_CI:/*psd的vobc命令设置*/
						{
							if ((0U < wCommandParam1) && (PSD_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((VOBCTOCI_COMMAND_TYPE_PSDCHECK == wCommandParam2) || (VOBCTOCI_COMMAND_TYPE_PSDOPEN == wCommandParam2)
									|| (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == wCommandParam2) || (VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT == wCommandParam2)
									|| (PSD_DEFAULT_CONTROL_CMD == wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_LOCK_OVERLAP_CMD:/*处理相邻联锁发送的办理保护区段命令*/
						{
							if ((0U < wCommandParam1) && (OVERLAP_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((ATS_LOCK_OVERLAP == wCommandParam2) || (LABOR_LOCK_OVERLAP == wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case LOCK_OVERLAP_HAVE_ROUTE_CMD:/*处理相邻联锁发送的办理保护区段命令带进路ID*/
						{
							if ((0U < wCommandParam1) && (OVERLAP_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((0U < wCommandParam2) && (ROUTE_SUM_MAX > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_UNLOCK_OVERLAP_CMD:/*处理相邻联锁发送的解锁保护区段命令*/
						{
							if ((0U < wCommandParam1) && (OVERLAP_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (0U == wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_LOGSEC_LOCK:/*进路内逻辑区段锁闭命令*/
						{
							if ((0U < wCommandParam1) && (LOGIC_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (((0U < wCommandParam2) && (255U > wCommandParam2))
									|| ((0X1400U < wCommandParam2) && (0X14FFU > wCommandParam2)))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_ROUTE_LOGIC_LOCK_CANCEL:/*逻辑区段解锁命令*/
						{
							if ((0U < wCommandParam1) && (LOGIC_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((0X1400U < wCommandParam2) && (0X14FFU > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_ROUTE_NOTVBTC_LOGIC_LOCK_CANCEL:/*逻辑区段非VBTC车释放命令*/
						{
							if ((0U < wCommandParam1) && (LOGIC_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((0X1400U < wCommandParam2) && (0X14FFU > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_DR_ROUTE_STATE:/*相邻联锁间动态进路命令设置进路状态*/
						{
							if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((ROUTE_STATE_IDLE == wCommandParam2) || (ROUTE_STATE_HALF_UNLOCK == wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_DR_SWITCH_PLOCK_CANCEL:/*相邻联锁间动态进路命令设置取消道岔防护锁闭状态*/
						{
							if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (SWITCH_LOCK_PROTECT_CANCEL == wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_PHYSEC_PLOCK_ROUTE_CMD:  /*相邻联锁间设置物理区段防护锁闭所属进路命令*/
						{
							if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (ROUTE_SUM_MAX > wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_LOGSEC_PLOCK_ROUTE_CMD:  /*相邻联锁间设置逻辑区段防护锁闭所属进路命令*/
						{
							if ((0U < wCommandParam1) && (LOGIC_SECTION_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (ROUTE_SUM_MAX > wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_ROUTE_LOCKED_OVERLAP:  /*相邻联锁间设置进路锁闭过的保护区段命令*/
						{
							if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (OVERLAP_SUM_MAX > wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_ROUTE_NEAR_STATE_SEARCH:  /*相邻联锁间进路接近区段状态查询*/
						{
							if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
						}
						break;
						case CI_CMD_ROUTE_NEAR_STATE_REPLAY:  /*相邻联锁间进路接近区段状态回复*/
						{
							if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1))
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if ((ROUTE_NEAR_SEC_HAVE_UT == wCommandParam2) || (ROUTE_NEAR_SEC_NOT_HAVE_UT == wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_ROUTE_SEC_LOCK_APPLY:  /*进路申请锁闭区段命令*/
						{
							if (ROUTE_SUM_MAX > wCommandParam1)
							{
								retVal = CI_SUCCESS; /*继续解析*/
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
							if (CI_SUCCESS == retVal)
							{
								if (ROUTE_SUM_MAX > wCommandParam2)
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2);
								}
							}
						}
						break;
						case CI_CMD_OLP_PROSWT_USE_APPLY:  /*保护区段防护道岔征用申请*/
						{
							if ((0U < wCommandParam1) && (SWITCH_SUM_MAX > wCommandParam1))
							{
								if ((0U < wCommandParam2) && (OVERLAP_SUM_MAX > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam2);
								}
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
						}
						break;
						case CI_CMD_OLP_PROSWT_USE_CANCEL:  /*保护区段防护道岔征用取消*/
						{
							if ((0U < wCommandParam1) && (SWITCH_SUM_MAX > wCommandParam1))
							{
								if ((0U < wCommandParam2) && (OVERLAP_SUM_MAX > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam2);
								}
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
						}
						break;
						case CI_CMD_OLP_PROSWT_USE_FAILURE:  /*保护区段防护道岔征用失败反馈*/
						{
							if ((0U < wCommandParam1) && (SWITCH_SUM_MAX > wCommandParam1))
							{
								if ((0U < wCommandParam2) && (OVERLAP_SUM_MAX > wCommandParam2))
								{
									retVal = CI_SUCCESS; /*继续解析*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam2);
								}
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1);
							}
						}
						break;
						default:
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CheckCiToCiCommandData Is Error: wCommandId Is %d\n", wCommandId);
						}
						break;
					}
				}
			}
		}
		else
		{
			retVal = CI_ERROR;
			/*相邻联锁间命令数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiCommandData Is Error: wCommandSum Is %d\n", wCommandSum);
		}
		*index = ii;
	}
	else
	{
		retVal = CI_ERROR; /*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的防淹门数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiFloodGateData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	
	UINT16 floodGateSum = 0U;  /*防淹门数量*/
	UINT16 chFloodGateId = 0U;   /*防淹门ID*/
	UINT8 chFloodBelongCiId = 0U;  /*防淹门所属联锁ID*/
	UINT8 chFGOpenLockState = 0u; /*防淹门开门锁闭状态*/
	UINT8 chFGCloseRequestState = 0u; /*防淹门关门请求状态*/
	UINT8 chFGAgreeClosefromZC = 0u;   /*ZC回复的关门许可*/
	UINT8 chFGAgreeCloseCollState = 0u;   /*当前同意关门采集状态*/
	UINT8 chFGAgreeCloseOutState = 0u;   /*当前同意关门输出状态*/

	UINT8 localCiId = GetSystemParaLocalCiId();	/*本联锁ID*/
	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		floodGateSum = ShortFromChar(&dataBuf[ii]);/*防淹门总数*/
		ii += 2u;
		if (FLOOD_GATE_SUM_MAX > floodGateSum)
		{
			/*遍历防淹门*/
			for (jj = 0U; jj < floodGateSum; jj++)
			{
				/*校验防淹门ID*/
				chFloodGateId = ShortFromChar(&dataBuf[ii]);
				ii += 2u;
				if ((0U != chFloodGateId)&& (FLOOD_GATE_SUM_MAX > chFloodGateId))
				{
					/*跳过属于本联锁的防淹门的状态信息，继续校验*/
					chFloodBelongCiId = GetFloodGateBelongCiId(chFloodGateId);
					if (chFloodBelongCiId == localCiId)
					{
						ii += CICI_ONE_FLOODGATE_LEN - 2u;
					}
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiFloodGateData Is Error: FloodGateId Is %d\n", chFloodGateId);
					retVal = CI_ERROR;
				}
				/*校验开门锁闭状态*/
				if (CI_SUCCESS == retVal)
				{
					chFGOpenLockState = dataBuf[ii];
					ii++;
					if ((FLOOD_GATE_OPENLOCK == chFGOpenLockState) || (FLOOD_GATE_NOT_OPENLOCK == chFGOpenLockState))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiFloodGateData wFloodGateId %d Is Error: FloodGateOpenLockState Is %d\n", chFloodGateId, chFGOpenLockState);
						retVal = CI_ERROR;
					}
				}
				/*校验关门请求状态*/
				if (CI_SUCCESS == retVal)
				{
					chFGCloseRequestState = dataBuf[ii];
					ii++;
					if ((FLOOD_GATE_CLOSEREQ == chFGCloseRequestState) || (FLOOD_GATE_NOT_CLOSEREQ == chFGCloseRequestState))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiFloodGateData wFloodGateId %d Is Error: FloodGateCloseRequestState Is %d\n", chFloodGateId, chFGCloseRequestState);
						retVal = CI_ERROR;
					}
				}
				/*校验ZC回复关门许可*/
				if (CI_SUCCESS == retVal)
				{
					chFGAgreeClosefromZC = dataBuf[ii];
					ii++;
					if ((FLOOD_GATE_ALLOWCLOSE_ZC == chFGAgreeClosefromZC) || (FLOOD_GATE_NOT_ALLOWCLOSE_ZC == chFGAgreeClosefromZC))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiFloodGateData wFloodGateId %d Is Error: FloodGateAgreeCloseAckFromZC Is %d\n", chFloodGateId, chFGAgreeClosefromZC);
						retVal = CI_ERROR;
					}
				}
				/*校验当前同意关门采集状态*/
				if (CI_SUCCESS == retVal)
				{
					chFGAgreeCloseCollState = dataBuf[ii];
					ii++;
					if ((FLOOD_GATE_AGREE_CLOSE == chFGAgreeCloseCollState) || (FLOOD_GATE_NOT_AGREE_CLOSE == chFGAgreeCloseCollState))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiFloodGateData wFloodGateId %d Is Error: FloodGateAgreeCloseCollState Is %d\n", chFloodGateId, chFGAgreeCloseCollState);
						retVal = CI_ERROR;
					}
				}
				/*校验输出同意关门状态*/
				if (CI_SUCCESS == retVal)
				{
					chFGAgreeCloseOutState = dataBuf[ii];
					ii++;
					if ((FLOOD_GATE_AGREE_CLOSE == chFGAgreeCloseOutState) || (FLOOD_GATE_NOT_AGREE_CLOSE == chFGAgreeCloseOutState))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiFloodGateData wFloodGateId %d Is Error: FloodGateAgreeCloseOutState Is %d\n", chFloodGateId, chFGAgreeCloseOutState);
						retVal = CI_ERROR;
					}
				}

				if (CI_ERROR == retVal)
				{
					/*校验失败*/
					break;
				}
				else
				{
					/*校验成功，继续遍历*/
				}
			}
		}
		else
		{
			/*防淹门数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiFloodGateData Is Error: floodGateSum Is %d\n", floodGateSum);
			retVal = CI_ERROR;
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的保护区段数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiOverlapData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;

	UINT16 overlapSum = 0U;  /*保护区段数量*/
	UINT16 chOverlapId = 0U;   /*保护区段ID*/
	UINT8 chOverlapBelongCiId = 0U;  /*保护区段所属联锁ID*/
	UINT16 chOverlapBelongRouteId = 0U;  /*保护区段所属进路ID*/
	UINT32 chOverlapUnlockCycNum = 0u; /*保护区段组解锁起始周期号*/
	UINT32 chOverlapXuanpaiCycNum = 0u; /*保护区段组选排开始周期号*/
	UINT8 chOverlapUnlockApplyFlag = 0u; /*向ZC申请解锁保护区段标志*/
	UINT16 chOverlapUnlockTime = 0u;   /*保护区段解锁倒计时*/
	UINT8 localCiId = GetSystemParaLocalCiId();	/*本联锁ID*/
	UINT8 cProSwtCheckStartFlag = 0U; /*保护区段防护道岔检查开始标志*/

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		overlapSum = ShortFromChar(&dataBuf[ii]);/*保护区段总数*/
		ii += 2u;
		if (OVERLAP_SUM_MAX > overlapSum)
		{
			for (jj = 0U; jj < overlapSum; jj++)
			{
				/*校验保护区段ID*/
				chOverlapId = ShortFromChar(&dataBuf[ii]);
				ii += 2u;
				if ((0U != chOverlapId) && (OVERLAP_SUM_MAX > chOverlapId))
				{
					/*跳过属于本联锁的保护区段的信息，继续校验*/
					chOverlapBelongCiId = GetOverlapBelongCiId(chOverlapId);
					if (chOverlapBelongCiId == localCiId)
					{
						ii += CICI_ONE_OVERLAP_LEN - 2u;
					}
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiOverlapData Is Error: OverlapId Is %d\n", chOverlapId);
					retVal = CI_ERROR;
				}
				/*校验保护区段所属进路ID*/
				if (CI_SUCCESS == retVal)
				{
					chOverlapBelongRouteId = ShortFromChar(&dataBuf[ii]);
					ii += 2u;
					if (ROUTE_SUM_MAX > chOverlapBelongRouteId)
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: OverlapBelongRouteId Is %d\n", chOverlapId, chOverlapBelongRouteId);
						retVal = CI_ERROR;
					}
				}
				/*校验保护区段组解锁起始周期号*/
				if (CI_SUCCESS == retVal)
				{
					chOverlapUnlockCycNum = LongFromChar(&dataBuf[ii]);
					ii += 4u;
					if (UINT32_MAX > chOverlapUnlockCycNum)
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: OverlapUnlockCycNum Is %d\n", chOverlapId, chOverlapUnlockCycNum);
						retVal = CI_ERROR;
					}
				}
				/*校验保护区段组选排开始周期号*/
				if (CI_SUCCESS == retVal)
				{
					chOverlapXuanpaiCycNum = LongFromChar(&dataBuf[ii]);
					ii += 4u;
					if (UINT32_MAX > chOverlapXuanpaiCycNum)
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: OverlapXuanpaiCycNum Is %d\n", chOverlapId, chOverlapXuanpaiCycNum);
						retVal = CI_ERROR;
					}
				}
				/*校验向ZC申请解锁保护区段标志*/
				if (CI_SUCCESS == retVal)
				{
					chOverlapUnlockApplyFlag = dataBuf[ii];
					ii++;
					if ((UNLOCK_OVERLAP_APPLY_YES == chOverlapUnlockApplyFlag) || (UNLOCK_OVERLAP_APPLY_NO == chOverlapUnlockApplyFlag))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: OverlapUnlockApplyFlag Is %d\n", chOverlapId, chOverlapUnlockApplyFlag);
						retVal = CI_ERROR;
					}
				}
				/*校验保护区段解锁倒计时*/
				if (CI_SUCCESS == retVal)
				{
					chOverlapUnlockTime = ShortFromChar(&dataBuf[ii]);
					ii += 2u;
					if (UINT16_MAX > chOverlapUnlockTime)
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: OverlapUnlockTime Is %d\n", chOverlapId, chOverlapUnlockTime);
						retVal = CI_ERROR;
					}
				}
				/*校验保护区段防护道岔开始检查标志*/
				if (CI_SUCCESS == retVal)
				{
					cProSwtCheckStartFlag = dataBuf[ii];
					ii++;
					if ((PROSWITCH_CHECK_START_VALID == cProSwtCheckStartFlag) || (PROSWITCH_CHECK_START_INVALID == cProSwtCheckStartFlag))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: ProSwtCheckStartFlag Is %d\n", chOverlapId, cProSwtCheckStartFlag);
						retVal = CI_ERROR;
					}
				}
				if (CI_ERROR == retVal)
				{
					/*校验失败*/
					break;
				}
				else
				{
					/*校验成功，继续遍历*/
				}
			}
		}
		else
		{
			/*保护区段数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiOverlapData Is Error: overlapSum Is %d\n", overlapSum);
			retVal = CI_ERROR;
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
		retVal = CI_ERROR;
	}

	return retVal;
}


/*
* 功能描述：校验相邻CI发送的待解析的自动通过进路数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiAutoRouteData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;

	UINT16 autoRouteSum = 0U;  /*自动通过进路数量*/
	UINT16 chAutoRouteId = 0U;   /*自动通过进路ID*/
	UINT8 chAutoRouteBelongCiId = 0u;  /*自动通过进路所属联锁ID*/
	UINT8 chAutoRouteSetFlag = 0U;  /*自动通过进路建立标志*/
	UINT8 localCiId = GetSystemParaLocalCiId();	/*本联锁ID*/
	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		autoRouteSum = ShortFromChar(&dataBuf[ii]);/*自动通过进路数量*/
		ii += 2u;
		if (AUTO_ROUTE_SUM_MAX > autoRouteSum)
		{
			for (jj = 0U; jj < autoRouteSum; jj++)
			{
				/*校验自动通过进路ID*/
				chAutoRouteId = ShortFromChar(&dataBuf[ii]);
				ii += 2u;
				if ((0U != chAutoRouteId) && (AUTO_ROUTE_SUM_MAX > chAutoRouteId))
				{
					/*跳过属于本联锁的自动通过进路的信息，继续校验*/
					chAutoRouteBelongCiId = GetAutoRouteBelongCiId(chAutoRouteId);
					if (chAutoRouteBelongCiId == localCiId)
					{
						ii += CICI_ONE_AUTOROUTE_LEN - 2u;
					}
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiAutoRouteData Is Error: AutoRouteId Is %d\n", chAutoRouteId);
					retVal = CI_ERROR;
				}
				/*校验自动通过进路建立标志*/
				if (CI_SUCCESS == retVal)
				{
					chAutoRouteSetFlag = dataBuf[ii];
					ii++;
					if ((AUTO_ROUTE_SET_YES == chAutoRouteSetFlag) || (AUTO_ROUTE_SET_NO == chAutoRouteSetFlag))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiAutoRouteData AutoRouteId %d Is Error: AutoRouteSetFlag Is %d\n", chAutoRouteId, chAutoRouteSetFlag);
						retVal = CI_ERROR;
					}
				}
				if (CI_ERROR == retVal)
				{
					/*校验失败*/
					break;
				}
				else
				{
					/*校验成功，继续遍历*/
				}
			}
		}
		else
		{
			/*自动通过进路数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiAutoRouteData Is Error: autoRouteSum Is %d\n", autoRouteSum);
			retVal = CI_ERROR;
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述：校验相邻CI发送的本联锁中由其他联锁管理的逻辑区段锁闭数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiLogicLockData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT8 kk = 0u;

	UINT16 lgcSum = 0U;  /*特殊逻辑区段数量*/
	UINT16 chLgcId = 0U;   /*特殊逻辑区段ID*/
	UINT8 chLgcLockState = 0u;  /*逻辑区段锁闭状态*/
	UINT16 chLgcLockBelongRoute = 0u;  /*逻辑区段锁闭所属进路ID*/
	UINT16 chLgcPLockBelongRoute = 0u;  /*逻辑区段保护锁闭所属进路ID*/
	UINT8 chLgcLockDir = 0U;            /*锁闭方向*/
	UINT8 chLgcResShrFlag = 0u;            /*共享资源标志*/
	UINT8 chLgcSecTrainSum = 0u;        /*已征用逻辑区段的列车数量*/
	UINT16 szLgcSecTrainId = 0u;        /*已征用逻辑区段的列车ID*/
	UINT8 cLogLockLogRouteSum = 0u;    /*逻辑区段逻辑锁闭所属逻辑进路数量*/

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		lgcSum = ShortFromChar(&dataBuf[ii]);/*特殊逻辑区段数量*/
		ii += 2u;
		if (LOGIC_SECTION_SUM_MAX > lgcSum)
		{
			for (jj = 0U; jj < lgcSum; jj++)
			{
				/*校验逻辑区段ID*/
				chLgcId = ShortFromChar(&dataBuf[ii]);
				ii += 2u;
				if ((0U != chLgcId) && (LOGIC_SECTION_SUM_MAX > chLgcId))
				{
					/*校验通过*/
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiLogicLockData Is Error: LgcId Is %d\n", chLgcId);
					retVal = CI_ERROR;
				}
				/*校验逻辑区段锁闭状态*/
				if (CI_SUCCESS == retVal)
				{
					chLgcLockState = dataBuf[ii];
					ii++;
					if ((LOG_SECTION_LOCK_NO == chLgcLockState) || (LOG_SECTION_LOCK_NORMAL == chLgcLockState)
						|| (LOG_SECTION_LOCK_DELAY == chLgcLockState) || (LOG_SECTION_LOCK_EXCEPT == chLgcLockState)
						|| (LOG_SECTION_LOCK_PROTECT == chLgcLockState)||(LOG_SECTION_LOCK_START == chLgcLockState))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcLockState Is %d\n", chLgcId, chLgcLockState);
						retVal = CI_ERROR;
					}
				}
				/*校验逻辑区段锁闭所属进路*/
				if (CI_SUCCESS == retVal)
				{
					chLgcLockBelongRoute = ShortFromChar(&dataBuf[ii]);
					ii += 2u;
					if (ROUTE_SUM_MAX > chLgcLockBelongRoute)
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcLockBelongRouteID Is %d\n", chLgcId, chLgcLockBelongRoute);
						retVal = CI_ERROR;
					}
				}
				/*校验逻辑区段保护锁闭所属进路*/
				if (CI_SUCCESS == retVal)
				{
					chLgcPLockBelongRoute = ShortFromChar(&dataBuf[ii]);
					ii += 2u;
					if (ROUTE_SUM_MAX > chLgcPLockBelongRoute)
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcPLockBelongRouteID Is %d\n", chLgcId, chLgcPLockBelongRoute);
						retVal = CI_ERROR;
					}
				}
				/*校验逻辑区段锁闭方向*/
				if (CI_SUCCESS == retVal)
				{
					chLgcLockDir = dataBuf[ii];
					ii++;
					if ((CI_SYSTEM_DIRECTION_DOWN == chLgcLockDir) || (CI_SYSTEM_DIRECTION_UP == chLgcLockDir) || (0u == chLgcLockDir))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcLockDir Is %d\n", chLgcId, chLgcLockDir);
						retVal = CI_ERROR;
					}
				}
				/*校验逻辑区段逻辑锁闭状态*/
				if (CI_SUCCESS == retVal)
				{
					chLgcLockState = dataBuf[ii];
					ii++;
					if ((LOG_SECTION_LOGLOCK_NO == chLgcLockState) || (LOG_SECTION_LOGLOCK_NORMAL == chLgcLockState) || (LOG_SECTION_LOGLOCK_EXCEPT == chLgcLockState))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcLogicLockState Is %d\n", chLgcId, chLgcLockState);
						retVal = CI_ERROR;
					}
				}
				/*校验逻辑区段逻辑锁闭方向*/
				if (CI_SUCCESS == retVal)
				{
					chLgcLockDir = dataBuf[ii];
					ii++;
					if ((CI_SYSTEM_DIRECTION_DOWN == chLgcLockDir) || (CI_SYSTEM_DIRECTION_UP == chLgcLockDir) || (0u == chLgcLockDir))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcLogicLockDir Is %d\n", chLgcId, chLgcLockDir);
						retVal = CI_ERROR;
					}
				}
				/*校验逻辑区段逻辑锁闭所属逻辑进路数量*/
				if (CI_SUCCESS == retVal)
				{
					cLogLockLogRouteSum = dataBuf[ii];
					ii++;
					if (LOGSEC_RELATE_ROUTE_SUM_MAX >= cLogLockLogRouteSum)
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LogLockLogRouteSum Is %d\n", chLgcId, cLogLockLogRouteSum);
						retVal = CI_ERROR;
					}
				}

				/*校验逻辑区段共享资源标志*/
				if (CI_SUCCESS == retVal)
				{
					chLgcResShrFlag = dataBuf[ii];
					ii++;
					if ((LOGIC_SECTION_RES_SHARE_NO == chLgcResShrFlag) || (LOGIC_SECTION_RES_SHARE_YES == chLgcResShrFlag))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcResShrFlag Is %d\n", chLgcId, chLgcResShrFlag);
						retVal = CI_ERROR;
					}
				}
				/*校验已征用逻辑区段的列车数据*/
				if (CI_SUCCESS == retVal)
				{
					chLgcSecTrainSum = dataBuf[ii];/*已征用逻辑区段的列车数量*/
					ii++;
					if (LOGIC_SECTION_RES_SUM_MAX > chLgcSecTrainSum)
					{
						/*校验已征用逻辑区段的列车ID*/
						for (kk = 0u; kk < chLgcSecTrainSum; kk++)
						{
							szLgcSecTrainId = ShortFromChar(&dataBuf[ii]);/*已征用逻辑区段的列车ID*/
							ii += 2u;
							if (TRAIN_SUM_MAX >= szLgcSecTrainId)
							{
								/*0到255 校验通过*/
							}
							else if ((TRAIN_ID_MIN < szLgcSecTrainId) && (TRAIN_ID_MAX >= szLgcSecTrainId))
							{
								/*0x1401到0x14ff校验通过*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcSecTrainId Is %d\n", chLgcId, szLgcSecTrainId);
								retVal = CI_ERROR;
								break;
							}
						}
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcSecTrainSum Is %d\n", chLgcId, chLgcSecTrainSum);
						retVal = CI_ERROR;
					}
				}
				if (CI_ERROR == retVal)
				{
					/*校验失败*/
					break;
				}
				else
				{
					/*校验成功，继续遍历*/
				}
			}
		}
		else
		{
			/*逻辑区段数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiLogicLockData Is Error: lgcSum Is %d\n", lgcSum);
			retVal = CI_ERROR;
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
		retVal = CI_ERROR;
	}
	return retVal;
}


/*
* 功能描述：校验动态进路命令信息
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiDrCmdData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT8 kk = 0u;
	UINT16 drCmdSum = 0U;  /*动态进路命令数量*/
	UINT8 chDrRouteType = 0u;  /*动态进路命令类型*/
	UINT8 chDrRouteDir = 0u;  /*动态进路逻辑区段序列方向*/
	UINT8 chDrRouteLgcSum = 0u;  /*动态进路逻辑区段数量*/
	UINT16 szDrRouteLgcId = 0U;   /*动态进路逻辑区段ID*/
	UINT16 chDrRouteTrainId = 0U;  /*动态进路列车ID*/
	UINT8 chDrRouteTrainLgcSum = 0U;/*动态进路列车脚下逻辑区段数量*/
	UINT16 szDrRouteTrainLgcID = 0U;/*动态进路列车脚下逻辑区段ID*/
	UINT8 chSwitchMoveFlag = 0u;   /*半截进路道岔可动标志*/
	UINT16 wRelSignalId = 0U;  /*首个逻辑区段关联的始端信号机ID*/

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		drCmdSum = ShortFromChar(&dataBuf[ii]);/*动态进路命令数量*/
		ii += 2u;
		if (RECVCI_CMD_DATA_STRU_SUM_MAX > drCmdSum)
		{
			for (jj = 0U; jj < drCmdSum; jj++)
			{
				/*校验动态进路命令类型*/
				chDrRouteType = dataBuf[ii];
				ii++;
				if ((CICI_DR_CMD_HALF == chDrRouteType) || (CICI_DR_CMD_FULL == chDrRouteType) || (CICI_DR_CMD_LOGIC == chDrRouteType))
				{
					/*校验通过*/
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteType Is %d\n", jj, chDrRouteType);
					retVal = CI_ERROR;
				}
				/*校验动态进路逻辑区段序列方向*/
				if (CI_SUCCESS == retVal)
				{
					chDrRouteDir = dataBuf[ii];
					ii++;
					if ((CI_SYSTEM_DIRECTION_UP == chDrRouteDir) || (CI_SYSTEM_DIRECTION_DOWN == chDrRouteDir))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteDir Is %d\n", jj, chDrRouteDir);
						retVal = CI_ERROR;
					}
				}
				/*校验动态进路逻辑区段数量*/
				if (CI_SUCCESS == retVal)
				{
					chDrRouteLgcSum = dataBuf[ii];
					ii++;
					if ( MAX_ROUTE_IN_LT_NUM > chDrRouteLgcSum)
					{
						/*校验动态进路逻辑区段ID*/
						for (kk = 0U; kk < chDrRouteLgcSum; kk++)
						{
							szDrRouteLgcId = ShortFromChar(&dataBuf[ii]);  /*动态进路逻辑区段ID*/
							ii += 2U;
							if ((0u != szDrRouteLgcId) && (UINT16_MAX > szDrRouteLgcId))
							{
								/*校验通过*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteLgcId Is %d\n", jj, szDrRouteLgcId);
								retVal = CI_ERROR;
								break;
							}
						}
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteLgcSum Is %d\n", jj, chDrRouteLgcSum);
						retVal = CI_ERROR;
					}
				}
				/*校验动态进路列车ID*/
				if (CI_SUCCESS == retVal)
				{
					chDrRouteTrainId = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					if (UINT16_MAX > chDrRouteTrainId)
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteTrainId Is %d\n", jj, chDrRouteTrainId);
						retVal = CI_ERROR;
					}
				}
				/*校验动态进路列车脚下逻辑区段数量,不包含多条进路*/
				if (CI_SUCCESS == retVal)
				{
					chDrRouteTrainLgcSum = dataBuf[ii];
					ii++;
					if (SIZE_MAX_SECTION_BT_TRAIN > chDrRouteTrainLgcSum)
					{
						/*校验动态进路列车脚下逻辑区段ID*/
						for (kk = 0U; kk < chDrRouteTrainLgcSum; kk++)
						{
							szDrRouteTrainLgcID = ShortFromChar(&dataBuf[ii]);
							ii += 2U;
							if ((0u != szDrRouteTrainLgcID) && (LOGIC_SECTION_SUM_MAX > szDrRouteTrainLgcID))
							{
								/*校验通过*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteTrainLgcID Is %d\n", jj, szDrRouteTrainLgcID);
								retVal = CI_ERROR;
								break;
							}
						}
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteTrainLgcSum Is %d\n", jj, chDrRouteTrainLgcSum);
						retVal = CI_ERROR;
					}
				}
				/*校验半截进路道岔可动标志*/
				if (CI_SUCCESS == retVal)
				{
					chSwitchMoveFlag = dataBuf[ii];
					ii++;
					if ((ROUTE_HALF_SWITCH_MOVE_VALID == chSwitchMoveFlag) || (ROUTE_HALF_SWITCH_MOVE_INVALID == chSwitchMoveFlag))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: SwitchMoveFlag Is %d\n", jj, chSwitchMoveFlag);
						retVal = CI_ERROR;
					}
				}

				/*校验首个逻辑区段关联的始端信号机ID*/
				if (CI_SUCCESS == retVal)
				{
					wRelSignalId = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					if (SIGNAL_SUM_MAX > wRelSignalId)
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: RelStartSignalId Is %d\n", jj, wRelSignalId);
						retVal = CI_ERROR;
					}
				}

				if (CI_ERROR == retVal)
				{
					/*校验失败*/
					break;
				}
				else
				{
					/*校验成功，继续遍历*/
				}
			}
		}
		else
		{
			/*动态进路命令数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiDrCmdData Is Error: drCmdSum Is %d\n", drCmdSum);
			retVal = CI_ERROR;
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的共管物理区段锁闭数据
* 参数说明：const UINT8* dataBuf 待解析的数据
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiCommonPhyLockData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 cPhySecSum = 0U;  /*物理区段数量*/
	UINT16 wPhySecId = 0U;   /*物理区段ID*/
	UINT8 cPhySecLockState = 0U;  /*物理区段锁闭状态*/
	UINT16 wPLockBelongRouteId = 0U;  /*物理区段防护锁闭所属进路ID*/
	UINT16 wRLockBelongRouteId = 0U;  /*物理区段进路锁闭所属进路ID*/
	UINT16 wOverlapId = 0U;  /*物理区段锁闭所属保护区段ID*/
	UINT8 cPhySecLockDir = 0U;  /*物理区段锁闭方向*/
	UINT8 cPhySecBelongCiId = 0U;
	UINT8 cLocalCiId = 0U;

	cLocalCiId = GetSystemParaLocalCiId();

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;
		cPhySecSum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		if (PHYSICAL_SECTION_SUM_MAX > cPhySecSum)
		{
			retVal = CI_SUCCESS;
			for (jj = 0U; jj < cPhySecSum; jj++)
			{
				/*校验物理区段ID*/
				wPhySecId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId))
				{
					/*继续校验*/
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiCommonPhyLockData  PhySecId[%d] Is Error: PhySecId Is 0 Or Exceed Max %d\n", wPhySecId, PHYSICAL_SECTION_SUM_MAX);
					retVal = CI_ERROR;
				}

				/*校验物理区段的锁闭状态*/
				if (CI_SUCCESS == retVal)
				{
					cPhySecLockState = dataBuf[ii];
					ii++;
					if ((PHYSICAL_SECTION_LOCK_NO == cPhySecLockState) || (PHYSICAL_SECTION_LOCK_NORMAL == cPhySecLockState)
						|| (PHYSICAL_SECTION_LOCK_EXCEPT == cPhySecLockState) || (PHYSICAL_SECTION_LOCK_PROTECT == cPhySecLockState) || (PHYSICAL_SECTION_LOCK_DELAY == cPhySecLockState)
						|| (PHYSICAL_SECTION_LOCK_FAULTDELAY == cPhySecLockState) || (PHYSICAL_SECTION_LOCK_START == cPhySecLockState))
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: PhySecLockState Is %d\n", wPhySecId, cPhySecLockState);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验物理区段防护锁闭所属进路ID*/
				if (CI_SUCCESS == retVal)
				{
					wPLockBelongRouteId = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					if (ROUTE_SUM_MAX > wPLockBelongRouteId)
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: PLockBelongRouteId Is %d\n", wPhySecId, wPLockBelongRouteId);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验物理区段进路锁闭所属进路ID*/
				if (CI_SUCCESS == retVal)
				{
					wRLockBelongRouteId = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					if (ROUTE_SUM_MAX > wRLockBelongRouteId)
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: RLockBelongRouteId Is %d\n", wPhySecId, wRLockBelongRouteId);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				cPhySecBelongCiId = GetPhySecBelongCiId(wPhySecId);
				if (cPhySecBelongCiId == cLocalCiId)
				{
					ii += 2U;  /*跳过本联锁保护区段，继续校验*/
				}
				else
				{
					/*校验物理区段防护锁闭对应的保护区段ID*/
					if (CI_SUCCESS == retVal)
					{
						wOverlapId = ShortFromChar(&dataBuf[ii]);
						ii += 2U;
						if (OVERLAP_SUM_MAX > wOverlapId)
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: OverlapId Is %d\n", wPhySecId, wOverlapId);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}
				}

				/*校验物理区段的锁闭方向*/
				if (CI_SUCCESS == retVal)
				{
					cPhySecLockDir = dataBuf[ii];
					ii++;
					if ((0U == cPhySecLockDir)||(CI_SYSTEM_DIRECTION_UP == cPhySecLockDir) || (CI_SYSTEM_DIRECTION_DOWN == cPhySecLockDir)|| (CI_SYSTEM_DIRECTION_NONE == cPhySecLockDir))
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: PhySecLockDir Is %d\n", wPhySecId, cPhySecLockDir);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				if (CI_SUCCESS != retVal)
				{
					break;
				}
				else
				{
					/*继续校验*/
				}
			}

		}
		else
		{
			/*物理区段数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiCommonPhyLockData Is Error: PhySecSum %d Exceed Max %d\n", cPhySecSum, PHYSICAL_SECTION_SUM_MAX);
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的SPKS数据
* 参数说明：const UINT8* dataBuf 待解析的数据
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiSpksData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 cSpksSum = 0U;  /*SPKS数量*/
	UINT16 wSpksId = 0U;   /*SPKS ID*/
	UINT8 cSpksState = 0U;  /*SPKS状态*/
	UINT8 cSpksCutState = 0U;  /*SPKS旁路状态*/
	UINT8 cSpksBelongCiId = 0U;
	UINT8 cLocalCiId = 0U;

	cLocalCiId = GetSystemParaLocalCiId();

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;
		cSpksSum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		if (SPKS_SUM_MAX > cSpksSum)
		{
			retVal = CI_SUCCESS;
			for (jj = 0U; jj < cSpksSum; jj++)
			{
				/*校验SPKS ID*/
				wSpksId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				if ((0U < wSpksId) && (SPKS_SUM_MAX > wSpksId))
				{
					/*继续校验*/
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiSpksData  SpksId[%d] Is Error: SpksId Is 0 Or Exceed Max %d\n", wSpksId, SPKS_SUM_MAX);
					retVal = CI_ERROR;
				}

				cSpksBelongCiId = GetSpksBelongCiId(wSpksId);
				if (cSpksBelongCiId == cLocalCiId)
				{
					ii += CICI_ONE_SPKS_LEN - 2U;  /*跳过属于本联锁的SPKS状态信息，继续校验*/
				}
				else
				{
					/*校验SPKS状态*/
					if (CI_SUCCESS == retVal)
					{
						cSpksState = dataBuf[ii];
						ii++;
						if ((SPKS_STATUS_NO == cSpksState) || (SPKS_STATUS_YES == cSpksState))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiSpksData SpksId[%d] Is Error: SpksState Is %d\n", wSpksId, cSpksState);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}

					/*校验SPKS旁路状态*/
					if (CI_SUCCESS == retVal)
					{
						cSpksCutState = dataBuf[ii];
						ii++;
						if ((SPKS_CUT_NO == cSpksCutState) || (SPKS_CUT_YES == cSpksCutState))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiSpksData SpksId[%d] Is Error: SpksCutState Is %d\n", wSpksId, cSpksCutState);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}
				}

				if (CI_SUCCESS != retVal)
				{
					break;
				}
				else
				{
					/*继续校验*/
				}
			}

		}
		else
		{
			/*SPKS数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiSpksData Is Error: SpksSum %d Exceed Max %d\n", cSpksSum, SPKS_SUM_MAX);
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的虚拟继电器数据
* 参数说明：const UINT8* dataBuf 待解析的数据
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiVirRelayData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 cVirRelaySum = 0U;  /*虚拟继电器数量*/
	UINT16 wVirRelayId = 0U;   /*虚拟继电器ID*/
	UINT8 cVirRelayCollState = 0U;  /*虚拟继电器采集状态*/
	UINT8 cVirRelayBelongCiId = 0U;
	UINT8 cLocalCiId = 0U;

	cLocalCiId = GetSystemParaLocalCiId();

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;
		cVirRelaySum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		if (RELAY_SUM_MAX > cVirRelaySum)
		{
			retVal = CI_SUCCESS;
			for (jj = 0U; jj < cVirRelaySum; jj++)
			{
				/*校验虚拟继电器ID*/
				wVirRelayId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				if ((0U < wVirRelayId) && (RELAY_SUM_MAX > wVirRelayId))
				{
					/*继续校验*/
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiVirRelayData VirRelayId[%d] Is Error: VirRelayId Is 0 Or Exceed Max %d\n", wVirRelayId, RELAY_SUM_MAX);
					retVal = CI_ERROR;
				}

				cVirRelayBelongCiId = GetRelayBelongCiId(wVirRelayId);
				if (cVirRelayBelongCiId == cLocalCiId)
				{
					ii += CICI_ONE_VIRTUAL_RELAY_LEN - 2U;  /*跳过属于本联锁的虚拟继电器状态信息，继续校验*/
				}
				else
				{
					/*校验虚拟继电器采集状态*/
					if (CI_SUCCESS == retVal)
					{
						cVirRelayCollState = dataBuf[ii];
						ii++;
						if ((RELAY_DRIVE_STATE_DOWN == cVirRelayCollState) || (RELAY_DRIVE_STATE_UP == cVirRelayCollState))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiVirRelayData VirRelayId[%d] Is Error: VirRelayCollState Is %d\n", wVirRelayId, cVirRelayCollState);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}
				}

				if (CI_SUCCESS != retVal)
				{
					break;
				}
				else
				{
					/*继续校验*/
				}
			}

		}
		else
		{
			/*虚拟继电器数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiVirRelayData Is Error: VirRelaySum %d Exceed Max %d\n", cVirRelaySum, RELAY_SUM_MAX);
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的区间疏散数据
* 参数说明：const UINT8* dataBuf 待解析的数据
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiEaData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT8 kk = 0U;
	UINT8 cEaSum = 0U;  /*区间疏散防护区域数量*/
	EaDataStru strEaTmp = { 0u };  /*区间疏散防护区域结构体*/
	UINT16 wTrainIdIndex = 0U;

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;

		/*校验相邻控区建立的区间疏散防护区域数量*/
		cEaSum = dataBuf[ii];
		ii++;
		if (EA_MAX_NUM >= cEaSum)
		{
			retVal = CI_SUCCESS;
			for (jj = 0U; jj < cEaSum; jj++)
			{
				/*校验相邻控区建立的区间疏散的列车ID*/
				strEaTmp.wTrainId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				wTrainIdIndex = GetTrainBufIndex(strEaTmp.wTrainId);
				if (TRAIN_SUM_MAX > wTrainIdIndex)
				{
					/*继续校验*/
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaTrainId Is %d\n", jj, strEaTmp.wTrainId);
					retVal = CI_ERROR;
				}

				/*校验相邻控区建立的区间疏散防护区域包含的逻辑区段信息*/
				if (CI_SUCCESS == retVal)
				{
					strEaTmp.strLgcInfo.chObjNum = dataBuf[ii];
					ii++;
					if (EA_SECTION_MAX_NUM >= strEaTmp.strLgcInfo.chObjNum)
					{
						for (kk = 0U; kk < strEaTmp.strLgcInfo.chObjNum; kk++)
						{
							/*校验相邻控区建立的区间疏散防护区域包含的逻辑区段ID*/
							strEaTmp.strLgcInfo.szObjId[kk] = ShortFromChar(&dataBuf[ii]);
							ii += 2u;
							if ((0U < strEaTmp.strLgcInfo.szObjId[kk]) && (LOGIC_SECTION_SUM_MAX > strEaTmp.strLgcInfo.szObjId[kk]))
							{
								/*继续校验*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaLogSecId %d Is 0 Or Exceed Max %d\n", jj, strEaTmp.strLgcInfo.szObjId[kk], LOGIC_SECTION_SUM_MAX);
								retVal = CI_ERROR;
							}

							if (CI_SUCCESS != retVal)
							{
								break;
							}
							else
							{
								/*继续校验*/
							}
						}
					}
					else
					{
						retVal = CI_ERROR;
						debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaLogSecSum %d Exceed Max %d\n", jj, strEaTmp.strLgcInfo.chObjNum, EA_SECTION_MAX_NUM);
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验相邻控区建立的区间疏散防护区域的建立标识*/
				if (CI_SUCCESS == retVal)
				{
					strEaTmp.chBuildedFlag = dataBuf[ii];
					ii++;
					if ((EA_IS_BUILDED == strEaTmp.chBuildedFlag) || (EA_IS_NOT_BUILDED == strEaTmp.chBuildedFlag))
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaBuildedFlag Is %d\n", jj, strEaTmp.chBuildedFlag);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验相邻控区建立的区间疏散防护区域的列车中轴线*/
				if (CI_SUCCESS == retVal)
				{
					strEaTmp.dwMidLine = LongFromChar(&dataBuf[ii]);
					ii += 4U;

				}
				else
				{
					/*校验失败*/
				}

				/*校验相邻控区建立的区间疏散防护区域的类型*/
				if (CI_SUCCESS == retVal)
				{
					strEaTmp.chPaType = dataBuf[ii];
					ii++;
					if ((PA_TYPE_EA == strEaTmp.chPaType) || (PA_TYPE_DA == strEaTmp.chPaType))
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaType Is %d\n", jj, strEaTmp.chPaType);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验相邻控区建立的区间疏散防护区域建立周期号*/
				if (CI_SUCCESS == retVal)
				{
					strEaTmp.dwEaBuildCycNum = LongFromChar(&dataBuf[ii]);
					ii += 4U;
					if ((PA_TYPE_EA == strEaTmp.chPaType) && (0U == strEaTmp.dwEaBuildCycNum))
					{
						debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: dwEaBuildCycNum Is %d\n", jj, strEaTmp.dwEaBuildCycNum);
						retVal = CI_ERROR;
					}
					else
					{
						; /*继续校验*/
					}
				}
				else
				{
					/*校验失败*/
				}

				if (CI_SUCCESS != retVal)
				{
					break;
				}
				else
				{
					/*继续校验*/
				}
			}
		}
		else
		{
			/*相邻控区建立的区间疏散防护区域数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiEaData Is Error: BuildEaSum %d Exceed Max %d\n", cEaSum, EA_MAX_NUM);
		}

		if (CI_SUCCESS == retVal)
		{
			/*校验相邻控区反馈的区间疏散防护区域数量*/
			cEaSum = dataBuf[ii];
			ii++;
			if (EA_MAX_NUM >= cEaSum)
			{
				for (jj = 0U; jj < cEaSum; jj++)
				{
					/*校验相邻控区反馈的区间疏散的列车ID*/
					strEaTmp.wTrainId = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					wTrainIdIndex = GetTrainBufIndex(strEaTmp.wTrainId);
					if (TRAIN_SUM_MAX > wTrainIdIndex)
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiEaData BackEaIndex[%d] Is Error: EaTrainId Is %d\n", jj, strEaTmp.wTrainId);
						retVal = CI_ERROR;
					}

					/*校验相邻控区建立的区间疏散防护区域的类型*/
					if (CI_SUCCESS == retVal)
					{
						strEaTmp.chDstAllowed = dataBuf[ii];
						ii++;
						if ((EA_DST_ALLOWED_NO == strEaTmp.chDstAllowed) || (EA_DST_ALLOWED_YES == strEaTmp.chDstAllowed))
						{
							/*继续校验*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiEaData BackEaIndex[%d] Is Error: EaDstAllowed Is %d\n", jj, strEaTmp.chDstAllowed);
							retVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败*/
					}

					/*校验相邻控区建立的区间疏散防护区域建立周期号*/
					if (CI_SUCCESS == retVal)
					{
						strEaTmp.dwEaBuildCycNum = LongFromChar(&dataBuf[ii]);
						ii += 4U;
						if (0U == strEaTmp.dwEaBuildCycNum)
						{
							debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: dwEaBuildCycNum Is %d\n", jj, strEaTmp.dwEaBuildCycNum);
							retVal = CI_ERROR;
						}
						else
						{
							; /*继续校验*/
						}
					}
					else
					{
						/*校验失败*/
					}

					if (CI_SUCCESS != retVal)
					{
						break;
					}
					else
					{
						/*继续校验*/
					}
				}

			}
			else
			{
				/*相邻控区反馈的区间疏散防护区域数量超限，返回失败*/
				retVal = CI_ERROR;
				debug_infor_printf((const)"CheckCiToCiEaData Is Error: BackEaSum %d Exceed Max %d\n", cEaSum, EA_MAX_NUM);
			}
		}
		else
		{
			/*校验失败*/
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的分界点通信车数据
* 参数说明：const UINT8* dataBuf 待解析的数据
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiCfpCTData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT8 cCTSum = 0U;  /*通信车数量*/
	UINT16 wTrainId = 0U;   /*列车ID*/
	UINT8 cTrainLevel = 0U;  /*列车运行级别*/
	UINT32 dwTrainDelay = 0U;  /*与列车通信延时*/
	UINT16 wTrainSpeed = 0U;  /*列车速度*/
	UINT8 cSpeedDir = 0U;  /*速度方向*/
	UINT8 cTrainDir = 0U;  /*列车方向*/
	UINT16 wTrainIdIndex = 0U;
	
	LOD_STRU wMaxhead = { 0u };
	LOD_STRU wMinhead = { 0u };
	LOD_STRU wMaxtail = { 0u };
	LOD_STRU wMintail = { 0u };

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;
		cCTSum = dataBuf[ii];
		ii++;
		if (TRAIN_SUM_MAX > cCTSum)
		{
			retVal = CI_SUCCESS;
			for (jj = 0U; jj < cCTSum; jj++)
			{
				/*校验通信车ID*/
				wTrainId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				wTrainIdIndex = GetTrainBufIndex(wTrainId);
				if (TRAIN_SUM_MAX > wTrainIdIndex)
				{
					/*继续校验*/
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainId Is 0 Or Exceed Max %d\n", wTrainId, TRAIN_SUM_MAX);
					retVal = CI_ERROR;
				}

				/*校验通信车级别*/
				if (CI_SUCCESS == retVal)
				{
					cTrainLevel = dataBuf[ii];
					ii++;
					if ((TRAIN_LEVEL_UR == cTrainLevel)|| (TRAIN_LEVEL_ABL == cTrainLevel) || (TRAIN_LEVEL_VBTC == cTrainLevel)||(TRAIN_LEVEL_ITC == cTrainLevel))
					{
						/*继续校验 此处不会出现0 0xff*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainLevel Is %d\n", wTrainId, cTrainLevel);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车通信延时*/
				if (CI_SUCCESS == retVal)
				{
					dwTrainDelay = LongFromChar(&dataBuf[ii]);
					ii += 4U;
					if (UINT32_MAX > dwTrainDelay)
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainDelay Is %d\n", wTrainId, dwTrainDelay);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车速度*/
				if (CI_SUCCESS == retVal)
				{
					wTrainSpeed = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					if (UINT16_MAX > wTrainSpeed)
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainSpeed Is %d\n", wTrainId, wTrainSpeed);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车速度方向*/
				if (CI_SUCCESS == retVal)
				{
					cSpeedDir = dataBuf[ii];
					ii++;
					if ((TRAIN_SPEED_DIR_BACKWARD == cSpeedDir) || (TRAIN_SPEED_DIR_FORWARD == cSpeedDir))
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: SpeedDir Is %d\n", wTrainId, cSpeedDir);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车方向*/
				if (CI_SUCCESS == retVal)
				{
					cTrainDir = dataBuf[ii];
					ii++;
					if ((DIR_SAME == cTrainDir) || (DIR_CONVERT == cTrainDir))
					{
						/*继续校验*/
						
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainDir Is %d\n", wTrainId, cTrainDir);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车大前Link ID*/
				if (CI_SUCCESS == retVal)
				{
					wMaxhead.Lnk = ShortFromChar(&dataBuf[ii]);
					ii += 2u;
					if ((0U < wMaxhead.Lnk) && (UINT16_MAX > wMaxhead.Lnk))
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: MaxHeadLinkId Is %d\n", wTrainId, wMaxhead.Lnk);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车大前Link偏移量*/
				if (CI_SUCCESS == retVal)
				{
					wMaxhead.Off = LongFromChar(&dataBuf[ii]);
					ii += 4u;
					if (UINT32_MAX > wMaxhead.Off)
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: MaxHeadLinkOffset Is %d\n", wTrainId, wMaxhead.Off);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车小前Link ID*/
				if (CI_SUCCESS == retVal)
				{
					wMinhead.Lnk = ShortFromChar(&dataBuf[ii]);
					ii += 2u;
					if ((0U < wMinhead.Lnk) && (UINT16_MAX > wMinhead.Lnk))
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)" TrainId[%d] Is Error: MinHeadLinkId Is %d\n", wTrainId, wMinhead.Lnk);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车小前Link偏移量*/
				if (CI_SUCCESS == retVal)
				{
					wMinhead.Off = LongFromChar(&dataBuf[ii]);
					ii += 4u;
					if (UINT32_MAX > wMinhead.Off)
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: MinHeadLinkOffset Is %d\n", wTrainId, wMinhead.Off);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车大后Link ID*/
				if (CI_SUCCESS == retVal)
				{
					wMaxtail.Lnk = ShortFromChar(&dataBuf[ii]);
					ii += 2u;
					if ((0U < wMaxtail.Lnk) && (UINT16_MAX > wMaxtail.Lnk))
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: MaxTailLinkId Is %d\n", wTrainId, wMaxtail.Lnk);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车大后Link偏移量*/
				if (CI_SUCCESS == retVal)
				{
					wMaxtail.Off = LongFromChar(&dataBuf[ii]);
					ii += 4u;
					if (UINT32_MAX > wMaxtail.Off)
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error:MaxTailLinkOffset Is %d\n", wTrainId, wMaxtail.Off);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车小后Link ID*/
				if (CI_SUCCESS == retVal)
				{
					wMintail.Lnk = ShortFromChar(&dataBuf[ii]);
					ii += 2u;
					if ((0U < wMintail.Lnk) && (UINT16_MAX > wMintail.Lnk))
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: MinTailLinkId Is %d\n", wTrainId, wMintail.Lnk);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}

				/*校验列车小后Link偏移量*/
				if (CI_SUCCESS == retVal)
				{
					wMintail.Off = LongFromChar(&dataBuf[ii]);
					ii += 4u;
					if (UINT32_MAX > wMintail.Off)
					{
						/*继续校验*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error:MinTailLinkOffset Is %d\n", wTrainId, wMintail.Off);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*校验失败*/
				}
				/*校验列车小后方向能否得出其他三点方向*/
				if (CI_SUCCESS == retVal)
				{
					retVal = CheckTrainDirToOtherPointDir(wMaxhead, wMinhead, wMaxtail, wMintail, cTrainDir);
					if (CI_SUCCESS != retVal)
					{
						debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainDir %d is Fail To Calculate\n", wTrainId, cTrainDir);
						retVal = CI_ERROR;
					}

				}
				if (CI_SUCCESS != retVal)
				{
					break;
				}
				else
				{
					/*继续校验*/
				}
			}
		}
		else
		{
			/*通信车数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiCfpCTData Is Error: CTSum %d Exceed Max %d\n", cCTSum, TRAIN_SUM_MAX);
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	
	return retVal;
}

/*
* 功能描述：校验相邻CI发送的PSD数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiPsdData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT8 belongCiId = 0u;
	UINT8 localCiId = 0u;		/*本联锁ID*/

	UINT16 psdSum = 0u;		/*Psd数量*/
	UINT16 psdId = 0u;		/*Psd设备ID*/
	UINT8 doorState = 0u;	/*屏蔽门状态*/
	UINT8 mutualLockState = 0u;		/*屏蔽门互锁解除状态*/
	UINT8 cPsdExceptOpenState = 0U;  /*屏蔽门异常打开状态*/

	localCiId = GetSystemParaLocalCiId();

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;

		/*解析处理屏蔽门数据*/
		psdSum = ShortFromChar(&dataBuf[ii]);		/*获取屏蔽门数量*/
		ii += 2u;

		if (PSD_SUM_MAX > psdSum)
		{
			retVal = CI_SUCCESS;
			for (jj = 0U; jj < psdSum; jj++)
			{
				psdId = ShortFromChar(&dataBuf[ii]);
				ii += 2u;
				if ((0u < psdId) && (PSD_SUM_MAX > psdId))
				{
					belongCiId = GetPsdBelongCiId(psdId);
					if (belongCiId == localCiId)
					{
						ii += CICI_ONE_PSD_LEN - 2u;/*跳过属于本联锁的PSD状态信息，继续解析*/
					}
					else
					{
						/*屏蔽门状态*/
						doorState = dataBuf[ii];
						ii++;
						if ((PSD_STATE_CLOSE == doorState) || (PSD_STATE_OPEN == doorState))
						{
							;		/*校验通过继续处理*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiPsdData PsdId %d Is Error: doorState Is %d\n", psdId, doorState);
							retVal = CI_ERROR;
						}

						/*互锁解除状态*/
						if (CI_SUCCESS == retVal)
						{
							mutualLockState = dataBuf[ii];
							ii++;
							if ((PSD_MUTUALLOCK_REMOVE_NO == mutualLockState) || (PSD_MUTUALLOCK_REMOVE_YES == mutualLockState)
								|| (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState))
							{
								;		/*校验通过继续处理*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiPsdData PsdId %d Is Error: mutualLockState Is %d\n", psdId, mutualLockState);
								retVal = CI_ERROR;
							}
						}

						/*屏蔽门异常打开状态*/
						cPsdExceptOpenState = dataBuf[ii];
						ii++;
						if ((PSD_EXCEPT_OPEN_YES == cPsdExceptOpenState) || (PSD_EXCEPT_OPEN_NO == cPsdExceptOpenState))
						{
							;/*校验通过，继续处理*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiPsdData PsdId %d Is Error: PsdExceptOpenState Is %d\n", psdId, cPsdExceptOpenState);
							retVal = CI_ERROR;
						}
					}
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiPsdData Is Error: PsdId Is %d\n", psdId);
					retVal = CI_ERROR;
				}

				if (CI_ERROR == retVal)
				{
					break;
				}
				else
				{
					/*继续查询下一个Psd*/
				}
			}
		}
		else
		{
			/*PSD数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiPsdData Is Error: PsdSum Is %d\n", psdSum);
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的ESB数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiEsbData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT8 belongCiId = 0u;
	UINT8 localCiId = 0u;		/*本联锁ID*/

	UINT16 esbSum = 0u;		/*esb数量*/
	UINT16 esbId = 0u;		/*esb设备ID*/
	UINT8 esdState = 0u;	/*紧急停车按钮状态*/
	UINT8 esbCutState = 0u;		/*紧急停车按钮旁路状态*/
	localCiId = GetSystemParaLocalCiId();

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;

		/*解析处理紧急停车按钮数据*/
		esbSum = ShortFromChar(&dataBuf[ii]);		/*获取紧急停车按钮数量*/
		ii += 2u;

		if (ESB_SUM_MAX > esbSum)
		{
			retVal = CI_SUCCESS;
			for (jj = 0U; jj < esbSum; jj++)
			{
				esbId = ShortFromChar(&dataBuf[ii]);
				ii += 2u;
				if ((0u < esbId) && (ESB_SUM_MAX > esbId))
				{
					belongCiId = GetEsbBelongCiId(esbId);
					if (belongCiId == localCiId)
					{
						ii += CICI_ONE_ESB_LEN - 2u;/*跳过属于本联锁的ESD状态信息，继续解析*/
					}
					else
					{
						/*紧急停车按钮状态*/
						esdState = dataBuf[ii];
						ii++;
						if ((ESB_STATE_VALID_NO == esdState) || (ESB_STATE_VALID_YES == esdState))
						{
							;		/*校验通过继续处理*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiEsbData esbId %d Is Error: esdState Is %d\n", esbId, esdState);
							retVal = CI_ERROR;
						}


						/*紧急停车按钮旁路状态*/
						if (CI_SUCCESS == retVal)
						{
							esbCutState = dataBuf[ii];
							ii++;
							if ((ESB_CUT_NO == esbCutState) || (ESB_CUT_YES == esbCutState))
							{
								;		/*校验通过继续处理*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiEsbData esbId %d Is Error: esbCutState Is %d\n", esbId, esbCutState);
								retVal = CI_ERROR;
							}
						}
					}
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiEsbData Is Error: esbId Is %d\n", esbId);
					retVal = CI_ERROR;
				}

				if (CI_ERROR == retVal)
				{
					break;
				}
				else
				{
					/*继续查询下一个Esb*/
				}
			}
		}
		else
		{
			/*ESB数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiEsbData Is Error: esbSum Is %d\n", esbSum);
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}


/*
* 功能描述：校验相邻CI发送的进路数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiRouteData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT8 belongCiId = 0u;
	UINT8 localCiId = 0u;		/*本联锁ID*/

	UINT16 routeSum = 0u;		/*进路数量*/
	UINT16 routeId = 0u;		/*进路设备ID*/
	UINT8 routeState = 0u;	/*进路状态*/
	UINT8 routeLevel = 0u;		/*进路监督级别*/
	UINT16 utOverlapUnlockCount = 0u;/*UT保护区段解锁倒计时周期数*/
	UINT16 ctOverlapUnlockCount = 0u;/*CT保护区段解锁倒计时周期数*/
	UINT8 cancleState = 0u;		/*进路取消状态*/
	UINT8 overLapflag = 0u;		/*设置保护区段需要由联锁锁闭标志*/
	UINT8 routeStateFlag = 0U;  /*进路追踪办理标志*/
	UINT8 routeZDCFFlag = 0U;    /*进路自动触发标志*/

	localCiId = GetSystemParaLocalCiId();

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;

		/*解析处理进路数据*/
		routeSum = ShortFromChar(&dataBuf[ii]);		/*获取进路数量*/
		ii += 2u;

		if (ROUTE_SUM_MAX > routeSum)
		{
			retVal = CI_SUCCESS;
			for (jj = 0U; jj < routeSum; jj++)
			{
				routeId = ShortFromChar(&dataBuf[ii]);
				ii += 2u;
				if ((0u < routeId) && (ROUTE_SUM_MAX > routeId))
				{
					belongCiId = GetRouteBelongCiId(routeId);
					if (belongCiId == localCiId)
					{
						ii += CICI_ONE_ROUTE_LEN - 2u;/*跳过属于本联锁的进路状态信息，继续解析*/
					}
					else
					{
						/*进路状态*/
						routeState = dataBuf[ii];
						ii++;
						retVal = RouteStateValidCheck(routeState);
						if (CI_SUCCESS == retVal)
						{
							;		/*校验通过继续处理*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: routeState Is %d\n", routeId, routeState);
						}

						/*进路监督级别*/
						if (CI_SUCCESS == retVal)
						{
							routeLevel = dataBuf[ii];
							ii++;
							if ((ROUTE_LEVEL_CBTC == routeLevel) || (ROUTE_LEVEL_BLOC == routeLevel))
							{
								;		/*校验通过继续处理*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: routeLevel Is %d\n", routeId, routeLevel);
								retVal = CI_ERROR;
							}
						}

						/*进路取消状态*/
						if (CI_SUCCESS == retVal)
						{
							utOverlapUnlockCount = ShortFromChar(&dataBuf[ii]);
							ii += 2u;

							ctOverlapUnlockCount = ShortFromChar(&dataBuf[ii]);
							ii += 2u;

							cancleState = dataBuf[ii];
							ii++;
							if ((AUTO_ROUTE_CANCLE_NO == cancleState) || (AUTO_ROUTE_CANCLE_WAIT == cancleState)
								|| (AUTO_ROUTE_CANCLE_FAIL == cancleState) || (AUTO_ROUTE_CANCLE_SUCCESS == cancleState))
							{
								;		/*校验通过继续处理*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: cancleState Is %d\n", routeId, cancleState);
								retVal = CI_ERROR;
							}
						}

						/*进路保护区段由联锁锁闭标志*/
						if (CI_SUCCESS == retVal)
						{
							overLapflag = dataBuf[ii];
							ii++;
							if ((OVERLAPCILOCK_YES == overLapflag) || (OVERLAPCILOCK_NO == overLapflag))
							{
								;		/*校验通过继续处理*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: overLapflag Is %d\n", routeId, overLapflag);
								retVal = CI_ERROR;
							}
						}

						/*进路追踪办理标志*/
						if (CI_SUCCESS == retVal)
						{
							routeStateFlag = dataBuf[ii];
							ii++;
							if ((ROUTE_STATE_FLAG_YES == routeStateFlag) || (ROUTE_STATE_FLAG_NO == routeStateFlag))
							{
								;		/*校验通过继续处理*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: Zhuizongbanliflag Is %d\n", routeId, routeStateFlag);
								retVal = CI_ERROR;
							}
						}

						/*进路自动触发标志*/
						if (CI_SUCCESS == retVal)
						{
							routeZDCFFlag = dataBuf[ii];
							ii++;
							if ((AUTO_TRIGGER_SET_YES == routeZDCFFlag) || (AUTO_TRIGGER_SET_NO == routeZDCFFlag))
							{
								;		/*校验通过继续处理*/
							}
							else
							{
								debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: AutoTriggerflag Is %d\n", routeId, routeZDCFFlag);
								retVal = CI_ERROR;
							}
						}

					}
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiRouteData Is Error: routeId Is %d\n", routeId);
					retVal = CI_ERROR;
				}

				if (CI_ERROR == retVal)
				{
					break;
				}
				else
				{
					/*继续查询下一进路*/
				}
			}
		}
		else
		{
			/*进路数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiRouteData Is Error: routeSum Is %d\n", routeSum);
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的分界点数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CheckCiToCiCfpData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 dwTmpIndex = 0u;
	UINT16 cfpSum = 0u;		/*分界点数量*/
	UINT16 cfpId = 0u;		/*分界点设备ID*/
	UINT16 wCfpRelAdjaRcSignalId = 0U;  /*分界点关联的相邻RC的信号机ID*/
	UINT8 cSignalBelongCiId = 0U;
	UINT8 cLocalCiId = 0U;
	UINT8 cCfpSignalLightUpFlag = 0U;

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;
		retVal = CI_SUCCESS;

		/*解析处理分界点数据*/
		cfpSum = ShortFromChar(&dataBuf[ii]);		/*获取分界点数量*/
		ii += 2u;

		if (CUTOFF_POINT_SUM_MAX >= cfpSum)
		{
			for (jj = 0U; jj < cfpSum; jj++)
			{
				cfpId = ShortFromChar(&dataBuf[ii]);
				ii += 2u;

				dwTmpIndex = GetCfpBufIndex(cfpId);
				if (CUTOFF_POINT_SUM_MAX <= dwTmpIndex)
				{
					retVal = CI_ERROR;/*分界点ID范围有误*/
				}
				else
				{
					/*包络解析数据校验*/
					retVal = CiToCiEnvelopeCheck(dataBuf, &ii);

					if (CI_SUCCESS == retVal)
					{
						;		/*校验通过继续处理*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiCfpData CiToCiEnvelopeCheck cfpId %d Is Error\n", cfpId);
					}

					/*CT列车数据校验*/
					if (CI_SUCCESS == retVal)
					{
						retVal = CheckCiToCiCfpCTData(dataBuf, &ii);
						if (CI_SUCCESS == retVal)
						{
							;		/*校验通过继续处理*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiCfpData CheckCiToCiCfpCTData cfpId %d Is Error\n", cfpId);
						}
					}

					/*分界点远程RM跨控区申请信息*/
					if (CI_SUCCESS == retVal)
					{
						retVal = CheckCiToCiCfpRrmData(dataBuf, &ii);
						if (CI_SUCCESS == retVal)
						{
							;		/*校验通过继续处理*/
						}
						else
						{
							debug_infor_printf((const)"CheckCiToCiCfpData CheckCiToCiCfpRrmData cfpId %d Is Error\n", cfpId);
						}
					}

					/*分界点关联相邻RC的信号机ID校验*/
					if (CI_SUCCESS == retVal)
					{
						wCfpRelAdjaRcSignalId = ShortFromChar(&dataBuf[ii]);
						ii += 2U;

						cLocalCiId = GetSystemParaLocalCiId();  /*获取本控区ID*/
						cSignalBelongCiId = GetSignalBelongCiId(wCfpRelAdjaRcSignalId);

						if ((0U == wCfpRelAdjaRcSignalId) || ((1U <= wCfpRelAdjaRcSignalId) && (SIGNAL_SUM_MAX > wCfpRelAdjaRcSignalId) && (cSignalBelongCiId == cLocalCiId)))
						{
							retVal = CI_SUCCESS;  /*校验通过*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CheckCiToCiCfpData CheckCiToCiCfpLightUpSignalId cfpId %d Is Error\n", cfpId);
						}
					}
					else
					{
						/*不处理*/
					}

					/*分界点信号机亮灯标志校验*/
					if (CI_SUCCESS == retVal)
					{
						cCfpSignalLightUpFlag = dataBuf[ii];
						ii++;

						if ((SIGNAL_SLEEP_TRAIN_LIGHTUP_YES == cCfpSignalLightUpFlag) || (SIGNAL_SLEEP_TRAIN_LIGHTUP_NO == cCfpSignalLightUpFlag))
						{
							retVal = CI_SUCCESS;  /*校验通过*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CheckCiToCiCfpData CheckCiToCiCfpSignalLightUpFlag cfpId %d Is Error\n", cfpId);
						}
					}
					else
					{
						/*不处理*/
					}
				}
				
				if (CI_ERROR == retVal)
				{
					break;
				}
				else
				{
					;/*继续查询下一分界点*/
				}
			}
		}
		else
		{
			/*进路数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiCfpData Is Error: cfpSum Is %d\n", cfpSum);
			retVal = CI_ERROR;
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的分界点中包络的数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
*/
UINT8 CiToCiEnvelopeCheck(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 wTrainId = 0U;			/*列车ID*/
	UINT8 chTrainLevel = 0U;		/*列车等级*/
	UINT32 dwDis = 0U;				/*到分界点距离*/
	UINT8 chEnvelopeNum = 0U;		/*分界点收到相邻OC发来的包络数量*/
	UINT8 chEnvelopeIndex = 0U;
	UINT8 envelopeType = 0U;		/* 包络类型 */
	UINT16 headTrainID = 0U;                                /*包络前端列车ID*/
	UINT16 tailTrainID = 0U;                                /*包络后端列车ID*/
	UINT8 startPosDir = 0U;									/*起点方向*/
	UINT16 startPosLnk = 0U;			/*起点LINK*/
	UINT32 startPosOff = 0U;			/*起点偏移量*/
	UINT8 endPosDir = 0U;									/*终点方向*/
	UINT16 endPosLnk = 0U;			/*终点LINK*/
	UINT32 endPosOff = 0U;			/*终点偏移量*/
	UINT8 trianCnt = 0U;			/*包含列车数量*/
	UINT8 chTrainIndex = 0u;
	UINT16 envlopetrainID = 0U;
	UINT16 ii = 0U;
	UINT8 cActivePort = 0U;  /*列车激活端*/

	if ((NULL != dataBuf) && (NULL != index))
	{
		ii = *index;
		/*列车ID*/
		wTrainId = ShortFromChar(&dataBuf[ii]);
		ii += 2u;
		if ((TRAIN_ID_MIN <= wTrainId) && (TRAIN_ID_MAX >= wTrainId))
		{
			retVal = CI_SUCCESS;
		}
		else if (TRAIN_SUM_MAX >= wTrainId)
		{
			retVal = CI_SUCCESS;
		}
		else
		{
			debug_infor_printf((const)"CiToCiEnvelopeCheck Is Error: wTrainId Is %d\n", wTrainId);
		}

		/*运行等级*/
		if (CI_SUCCESS == retVal)
		{
			chTrainLevel = dataBuf[ii];
			ii++;

			if ((0u == chTrainLevel) ||(TRAIN_LEVEL_UR == chTrainLevel)
				|| (TRAIN_LEVEL_ABL == chTrainLevel) || (TRAIN_LEVEL_VBTC == chTrainLevel) || (TRAIN_LEVEL_ITC == chTrainLevel))
			{
				;/*0：无车、UR、ABL、VBTC级别合法*/
			}
			else
			{
				retVal = CI_ERROR;
				debug_infor_printf((const)"CiToCiEnvelopeCheck Is Error: chTrainLevel Is %d\n", chTrainLevel);
			}
		}

		/*到分界点距离*/
		if (CI_SUCCESS == retVal)
		{
			dwDis = LongFromChar(&dataBuf[ii]);
			ii += 4u;

			if (UINT32_MAX > dwDis)
			{
				;	/*数据合法，继续运行*/
			}
			else
			{
				retVal = CI_ERROR;
				debug_infor_printf((const)"CiToCiEnvelopeCheck Is Error: dwDis Is %d\n", dwDis);
			}
		}

		/*相邻OC发来的包络数量校验*/
		if (CI_SUCCESS == retVal)
		{
			chEnvelopeNum = dataBuf[ii];
			ii++;

			if (OTHER_RC_SEND_ENVELOPE_SUM_MAX >= chEnvelopeNum)
			{
				for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++)
				{
					envelopeType = dataBuf[ii++];	/* 包络类型 */
					if ((TYPE_UKT_ENVELOPE == envelopeType)
						|| (TYPE_UCT_ENVELOPE == envelopeType)
						|| (TYPE_CT_ENVELOPE == envelopeType))
					{
						;/*1:通信车 2：丢失通信车 3：隐藏车*/
					}
					else
					{
						retVal = CI_ERROR;
						debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: envelopeType Is %d\n", chEnvelopeIndex, envelopeType);
					}
					

					if (CI_SUCCESS == retVal)
					{
						headTrainID = ShortFromChar(&dataBuf[ii]);/* 前车ID */
						ii += 2u;
						if (TRAIN_SUM_MAX >= headTrainID)
						{
							;/*前/后列车ID的取值范围是0-255 数据合法，继续运行*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: headTrainID Is %d\n", chEnvelopeIndex, headTrainID);
						}
					}

					if (CI_SUCCESS == retVal)
					{
						tailTrainID = ShortFromChar(&dataBuf[ii]);/* 后车ID */
						ii += 2u;
						if (TRAIN_SUM_MAX >= tailTrainID)
						{
							;/*数据合法，继续运行*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: tailTrainID Is %d\n", chEnvelopeIndex, tailTrainID);
						}
					}

					if (CI_SUCCESS == retVal)
					{
						startPosDir = dataBuf[ii++];/* 起点方向 */
						if ((EMAP_SAME_DIR == startPosDir) || (EMAP_CONVER_DIR == startPosDir))
						{
							;/*数据合法，继续运行*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: startPosDir Is %d\n", chEnvelopeIndex, startPosDir);
						}
					}

					if (CI_SUCCESS == retVal)
					{
						startPosLnk = ShortFromChar(&dataBuf[ii]);/* 起点link */
						ii += 2u;
						if ((0u < startPosLnk) && (UINT16_MAX > startPosLnk))
						{
							;/*数据合法，继续运行*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: startPosLnk Is %d\n", chEnvelopeIndex, startPosLnk);
						}
					}

					if (CI_SUCCESS == retVal)
					{
						startPosOff = LongFromChar(&dataBuf[ii]);/* 起点offset */
						ii += 4u;
						if (UINT32_MAX > startPosOff)
						{
							;/*数据合法，继续运行*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: startPosOff Is %d\n", chEnvelopeIndex, startPosOff);
						}
					}

					if (CI_SUCCESS == retVal)
					{
						endPosDir = dataBuf[ii++];/* 终点方向 */
						if ((EMAP_SAME_DIR == endPosDir) || (EMAP_CONVER_DIR == endPosDir))
						{
							;/*数据合法，继续运行*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: endPosDir Is %d\n", chEnvelopeIndex, endPosDir);
						}
					}

					if (CI_SUCCESS == retVal)
					{
						endPosLnk = ShortFromChar(&dataBuf[ii]);/* 终点link */
						ii += 2u;
						if ((0u < endPosLnk) && (UINT16_MAX > endPosLnk))
						{
							;/*数据合法，继续运行*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: endPosLnk Is %d\n", chEnvelopeIndex, endPosLnk);
						}
					}

					if (CI_SUCCESS == retVal)
					{
						endPosOff = LongFromChar(&dataBuf[ii]);/* 终点offset */
						ii += 4u;
						if (UINT32_MAX > endPosOff)
						{
							;/*数据合法，继续运行*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: endPosOff Is %d\n", chEnvelopeIndex, endPosOff);
						}
					}

					if (CI_SUCCESS == retVal)
					{
						trianCnt = dataBuf[ii++];/* 包含列车数量 */
						if ((TRAIN_IN_ENVELOPE_SUM_MAX >= trianCnt) && (0U < trianCnt))
						{
							for (chTrainIndex = 0u; chTrainIndex < trianCnt; chTrainIndex++)
							{
								envlopetrainID = ShortFromChar(&dataBuf[ii]);/* 列车ID */
								ii += 2u;

								cActivePort = dataBuf[ii++];  /*列车激活端*/
								
								if ((TRAIN_SUM_MAX >= envlopetrainID)
									&& ((TRAIN_ACTIVE_NONE == cActivePort) || (TRAIN_ACTIVE_ONE == cActivePort) 
										|| (TRAIN_ACTIVE_TWO == cActivePort) || (TRAIN_ACTIVE_ALL == cActivePort)))
								{
									;/*数据合法，继续运行*/
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: envlopetrainID Is %d, ActivePort Is %d\n", chEnvelopeIndex, envlopetrainID, cActivePort);
									break;
								}
							}
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: endPosOff Is %d\n", chEnvelopeIndex, endPosOff);
						}
					}
				}
			}
			else
			{
				retVal = CI_ERROR;
				debug_infor_printf((const)"CiToCiEnvelopeCheck Is Error: chEnvelopeNum Is %d\n", chEnvelopeNum);
			}
		}

		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述： 添加相邻联锁发送给本联锁的区间雨雪信息
* 参数说明： UINT8 cSrcCiId 发送方CI
*            UINT8 cDstCiId 接收方CI
*			 UINT16 wAreaSnowId 区间ID
*            UINT8 cAreaSnowLevel 区间湿轨级别
* 返 回 值： 无
* Modified By LQ 2025.5.28
*/
void AddCiRecvAreaSnowInfo(UINT8 cSrcCiId, UINT8 cDstCiId, UINT16 wAreaSnowId, UINT8 cAreaSnowLevel)
{
	UINT16 ii = 0U;
	UINT8 cKeepWork = CI_ERROR;

	if ((0U != cSrcCiId) && (CI_SUM_MAX > cSrcCiId) && (0U != cDstCiId) && (CI_SUM_MAX > cDstCiId) && (0U != wAreaSnowId)
		&& ((CI_SNOW_LEVEL_DEFAULT == cAreaSnowLevel) || (CI_SNOW_LEVEL_ONE == cAreaSnowLevel) || (CI_SNOW_LEVEL_TWO == cAreaSnowLevel)))
	{
		for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++)
		{
			/*寻找目标CI的索引*/
			if ((cSrcCiId == szRecvCiAreaSnow[ii].cSourceCiId) && (cDstCiId == szRecvCiAreaSnow[ii].cTargetCiId))
			{
				cKeepWork = CI_SUCCESS;
			}
			else if ((0U == szRecvCiAreaSnow[ii].cSourceCiId) && (0U == szRecvCiAreaSnow[ii].cTargetCiId))
			{
				cKeepWork = CI_SUCCESS;
			}
			else
			{
				/*继续遍历，查找目标CI*/
			}

			if (CI_SUCCESS == cKeepWork)
			{

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

		if (CI_SUCCESS == cKeepWork)
		{
			if (CI_TO_CI_AREA_SNOW_SUM_MAX > szRecvCiAreaSnow[ii].cPlatFormNum)
			{
				/*添加区间雨雪信息*/
				szRecvCiAreaSnow[ii].cSourceCiId = cSrcCiId;
				szRecvCiAreaSnow[ii].cTargetCiId = cDstCiId;
				szRecvCiAreaSnow[ii].szPlatFormInfo[szRecvCiAreaSnow[ii].cPlatFormNum].wAreaId = wAreaSnowId;
				szRecvCiAreaSnow[ii].szPlatFormInfo[szRecvCiAreaSnow[ii].cPlatFormNum].cAreaSnowLevel = cAreaSnowLevel;
				szRecvCiAreaSnow[ii].cPlatFormNum++;
			}
			else
			{
				debug_infor_printf((const)"Error in AddCiRecvAreaSnowInfo: PlatFormNum Exceed Max %d!\n", CI_TO_CI_AREA_SNOW_SUM_MAX);
			}
		}
		else
		{
			debug_infor_printf((const)"Error in AddCiRecvAreaSnowInfo: No TargetCi!\n");
		}
	}
	else
	{
		debug_infor_printf((const)"Error in AddCiRecvAreaSnowInfo: Input Data Is Illegal!\n");
	}
}

/*
* 功能描述： 添加本联锁发送给指定ID相邻联锁的区间雨雪信息
* 参数说明： UINT8 cSrcCiId 发送方CI
*            UINT8 cDstCiId 接收方CI
*			 UINT16 wAreaId 区间ID
*            UINT8 cAreaSnowLevel 区间湿轨等级
* 返 回 值： 无
* Modified By LQ 2025.05.28
*/
void AddCiSendAreaSnowInfo(UINT8 cSrcCiId, UINT8 cDstCiId, UINT16 wAreaId, UINT8 cAreaSnowLevel)
{
	UINT16 ii = 0U;
	UINT8 cKeepWork = CI_ERROR;
	UINT8 jj = 0U;

	if ((0U != cSrcCiId) && (CI_SUM_MAX > cSrcCiId) && (0U != cDstCiId) && (CI_SUM_MAX > cDstCiId) && (0U != wAreaId)
		&& ((CI_SNOW_LEVEL_DEFAULT == cAreaSnowLevel) || (CI_SNOW_LEVEL_ONE == cAreaSnowLevel) || (CI_SNOW_LEVEL_TWO == cAreaSnowLevel)))
	{
		for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++)
		{
			/*寻找目标CI的索引*/
			if ((cSrcCiId == szSendCiAreaSnow[ii].cSourceCiId) && (cDstCiId == szSendCiAreaSnow[ii].cTargetCiId))
			{
				cKeepWork = CI_SUCCESS;
			}
			else if ((0U == szSendCiAreaSnow[ii].cSourceCiId) && (0U == szSendCiAreaSnow[ii].cTargetCiId))
			{
				cKeepWork = CI_SUCCESS;
			}
			else
			{
				/*继续遍历，查找目标CI*/
			}

			if(CI_SUCCESS == cKeepWork)
			{

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

		if (CI_SUCCESS == cKeepWork)
		{
			if (CI_TO_CI_AREA_SNOW_SUM_MAX > szSendCiAreaSnow[ii].cPlatFormNum)
			{
				/*by cgh 去重*/
				for (jj = 0U; jj < szSendCiAreaSnow[ii].cPlatFormNum; jj++)
				{
					if (szSendCiAreaSnow[ii].szPlatFormInfo[jj].wAreaId == wAreaId)
					{
						break;
					}
					else
					{
						; /*继续查重*/
					}
				}

				if (szSendCiAreaSnow[ii].cPlatFormNum == jj)
				{
					/*添加区间雨雪信息*/
					szSendCiAreaSnow[ii].cSourceCiId = cSrcCiId;
					szSendCiAreaSnow[ii].cTargetCiId = cDstCiId;
					szSendCiAreaSnow[ii].szPlatFormInfo[szSendCiAreaSnow[ii].cPlatFormNum].wAreaId = wAreaId;
					szSendCiAreaSnow[ii].szPlatFormInfo[szSendCiAreaSnow[ii].cPlatFormNum].cAreaSnowLevel = cAreaSnowLevel;
					szSendCiAreaSnow[ii].cPlatFormNum++;
				}
				else
				{
					; /*重复不添加*/
				}
			}
			else
			{
				debug_infor_printf((const)"Error in AddCiSendToCiAreaSnowInfo: PlatFormNum Exceed Max %d!\n", CI_TO_CI_AREA_SNOW_SUM_MAX);
			}
		}
		else
		{
			debug_infor_printf((const)"Error in AddCiSendToCiAreaSnowInfo: No TargetCi!\n");
		}
	}
	else
	{
		debug_infor_printf((const)"Error in AddCiSendToCiAreaSnowInfo: Input Data Is Illegal!\n");
	}
}

/*
* 功能描述： 获取相邻联锁发送给本联锁的区间雨雪信息
* 参数说明： 无
* 返回值  ： 其它联锁发送的区间雨雪信息
* Created By LQ 2023.11.16
*/
ToCiAreaSnowStruct* GetCiRecvAreaSnowInfo(void)
{
	return szRecvCiAreaSnow;
}

/*
* 功能描述： 获取本联锁发送给指定ID相邻联锁的区间雨雪信息
* 参数说明： const UINT8 cTargetCiId 目标联锁
* 返回值  ： 其它联锁发送的区间雨雪信息
* Created By LQ 2023.11.16
*/
ToCiAreaSnowStruct* GetCiSendAreaSnowInfo(const UINT8 cTargetCiId)
{
	ToCiAreaSnowStruct* retVal = NULL;
	UINT16 ii = 0U;	

	if ((0U != cTargetCiId) && (CI_SUM_MAX > cTargetCiId))
	{
		for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++)
		{
			if (szSendCiAreaSnow[ii].cTargetCiId == cTargetCiId)
			{
				retVal = &szSendCiAreaSnow[ii];
			}
			else
			{
				/*不处理*/
			}
		}
	}
	else
	{
		/*入参非法，返回NULL*/
	}

	return retVal;
}

/*
* 功能描述： 清除相邻联锁发送给本联锁的区间雨雪信息
* 参数说明： const UINT8 cSrcCiId 发送方CI
* 返回值  ： 无
* Created By LQ 2023.11.16
*/
void ClearCiRecvAreaSnowInfo(const UINT8 cSrcCiId)
{
	UINT16 ii = 0U;

	if ((0U != cSrcCiId) && (CI_SUM_MAX > cSrcCiId))
	{
		for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++)
		{
			if (szRecvCiAreaSnow[ii].cSourceCiId == cSrcCiId)
			{
				(void)CommonMemSet(&szRecvCiAreaSnow[ii], (UINT32)sizeof(ToCiAreaSnowStruct), 0U, (UINT32)sizeof(ToCiAreaSnowStruct));
				break;
			}
			else
			{
				/*不处理*/
			}
		}
	}
	else
	{
		/*入参非法，不处理*/
	}
}

/*
* 功能描述： 清除本联锁发送给相邻联锁的区间雨雪信息
* 参数说明： 无
* 返回值  ： 无
* Created By LQ 2023.11.16
*/
void ClearCiSendAreaSnowInfo(void)
{
	(void)CommonMemSet(szSendCiAreaSnow, (UINT32)(CI_COM_CI_MAX_NUM * sizeof(ToCiAreaSnowStruct)), 0U, (UINT32)(CI_COM_CI_MAX_NUM * sizeof(ToCiAreaSnowStruct)));
}

/*
* 功能描述：校验相邻CI发送的待解析的区间雨雪数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
* Created By LQ 2023.11.16
*/
UINT8 CheckCiToCiAreaSnowData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT8 cAreaSnowNum = 0U;  /*保护区段数量*/
	UINT16 wPlatFormId = 0U;  /*区间雨雪站台ID*/
	UINT8 cPlatFormBelongCiId = 0U;  /*站台所属联锁*/
	UINT8 localCiId = 0U;	/*本联锁ID*/
	UINT8 cAreaSnowLevel = 0U;  /*区间湿轨等级*/

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		localCiId = GetSystemParaLocalCiId();

		cAreaSnowNum = dataBuf[ii];  /*区间雨雪站台数量*/
		ii++;
		if (CI_TO_CI_AREA_SNOW_SUM_MAX >= cAreaSnowNum)
		{
			for (jj = 0U; jj < cAreaSnowNum; jj++)
			{
				/*校验区间ID*/
				wPlatFormId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;

				if ((0U < wPlatFormId) && (UINT16_MAX > wPlatFormId))
				{
					cPlatFormBelongCiId = GetAreaSnowPlatFormBelongCiId(wPlatFormId);  /*获取区间雨雪站台所属控区*/

					if ((localCiId != cPlatFormBelongCiId) && (0U != cPlatFormBelongCiId) && (0U != localCiId))
					{
						/*校验通过*/
					}
					else
					{
						/*站台为本控区，返回失败*/
						debug_infor_printf((const)"CheckCiToCiAreaSnowData Is Error: PlatFormBelongCiId Is %d\n", cPlatFormBelongCiId);
						retVal = CI_ERROR;
					}			
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiAreaSnowData Is Error: wPlatFormId Is %d\n", wPlatFormId);
					retVal = CI_ERROR;
				}

				if (CI_SUCCESS == retVal)
				{
					cAreaSnowLevel = dataBuf[ii];  /*区间湿轨等级*/
					ii++;

					if ((CI_SNOW_LEVEL_DEFAULT == cAreaSnowLevel) || (CI_SNOW_LEVEL_ONE == cAreaSnowLevel) || (CI_SNOW_LEVEL_TWO == cAreaSnowLevel))
					{
						/*校验通过*/
					}
					else
					{
						debug_infor_printf((const)"CheckCiToCiAreaSnowData Is Error: AreaSnowLevel Is %d\n", cAreaSnowLevel);
						retVal = CI_ERROR;
					}
				}
				else
				{
					/*已解析失败，不处理*/
				}

				if (CI_SUCCESS != retVal)
				{
					break;
				}
				else
				{
					/*继续解析*/
				}
			}
		}
		else
		{
			/*区间雨雪站台数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiAreaSnowData Is Error: AreaSnowNum Is %d\n", cAreaSnowNum);
			retVal = CI_ERROR;
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的命令是否重复
* 参数说明：const ToCiCommandDataStruct* pCiRecvCmdStr 接收的相邻CI命令
* 返回值  ：0 命令重复
*           1 命令不重复
* Created By LQ 2023.11.22
*/
UINT8 CheckCiRecvCmdIsRepeat(const ToCiCommandDataStruct* pCiRecvCmdStr)
{
	UINT8 retVal = CI_ERROR;
	UINT8 ii = 0U;

	if (NULL != pCiRecvCmdStr)
	{
		retVal = CI_SUCCESS;
		if (CI_CMD_PHYSEC_USING_APPLY != pCiRecvCmdStr->CommandID)
		{
			for (ii = 0U; ii < RecvCiCmdDataStruCurSum; ii++)
			{
				/*遍历当前存储的相邻控区命令，找出与入参命令重复的命令*/
				if ((RecvCiCmdDataStru[ii].SourceCiId == pCiRecvCmdStr->SourceCiId) && (RecvCiCmdDataStru[ii].TargetCiId == pCiRecvCmdStr->TargetCiId)
					&& (RecvCiCmdDataStru[ii].CommandID == pCiRecvCmdStr->CommandID) && (RecvCiCmdDataStru[ii].Param1 == pCiRecvCmdStr->Param1) && (RecvCiCmdDataStru[ii].Param2 == pCiRecvCmdStr->Param2))
				{
					retVal = CI_ERROR;  /*找到重复的命令，停止遍历，返回0*/
					break;
				}
				else
				{
					/*命令未重复，继续遍历*/
				}
			}
		}
		else
		{
			/*物理区段征用申请命令不处理*/
		}
	}
	else
	{
		/*入参非法，返回0*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的动态进路命令是否重复
* 参数说明：const ToCiDrCmdDataStruct* pCiRecvDrCmdStr 接收的相邻CI动态进路命令
* 返回值  ：0 命令重复
*           1 命令不重复
* Created By LQ 2023.11.22
*/
UINT8 CheckCiRecvDrCmdIsRepeat(const ToCiDrCmdDataStruct* pCiRecvDrCmdStr)
{
	UINT8 retVal = CI_ERROR;
	UINT8 ii = 0U;
	UINT8 jj = 0U;

	if (NULL != pCiRecvDrCmdStr)
	{
		retVal = CI_SUCCESS;
		for (ii = 0U; ii < RecvCiDrCmdSum; ii++)
		{
			/*遍历当前存储的相邻控区动态进路命令，找出与入参命令重复的动态进路命令*/
			if ((RecvCiDrCmdDataStru[ii].cSourceCiId == pCiRecvDrCmdStr->cSourceCiId) && (RecvCiDrCmdDataStru[ii].cTargetCiId == pCiRecvDrCmdStr->cTargetCiId)
				&& (RecvCiDrCmdDataStru[ii].cCmdType == pCiRecvDrCmdStr->cCmdType) && (RecvCiDrCmdDataStru[ii].cLogSecSeqDir == pCiRecvDrCmdStr->cLogSecSeqDir)
				&& (RecvCiDrCmdDataStru[ii].cLogSecSum == pCiRecvDrCmdStr->cLogSecSum) && (RecvCiDrCmdDataStru[ii].wTrainId == pCiRecvDrCmdStr->wTrainId))
			{
				for (jj = 0U; jj < RecvCiDrCmdDataStru[ii].cLogSecSum; jj++)
				{
					if (RecvCiDrCmdDataStru[ii].wLogSecIdBuff[jj] != pCiRecvDrCmdStr->wLogSecIdBuff[jj])
					{						
						break;  /*逻辑区段ID不同，停止遍历*/
					}
					else
					{
						/*逻辑区段ID相同，继续遍历*/
					}
				}

				if (jj == RecvCiDrCmdDataStru[ii].cLogSecSum)
				{
					retVal = CI_ERROR;  /*所有逻辑区段ID均相同，命令重复，停止遍历，返回0*/
					break;
				}
				else
				{
					/*存在逻辑区段ID不同，命令未重复，继续遍历*/
				}				
			}
			else
			{
				/*命令未重复，继续遍历*/
			}

		}
	}
	else
	{
		/*入参非法，返回0*/
	}

	return retVal;
}

/*
* 功能描述：校验相邻CI发送的待解析的分界点远程RM数据
* 参数说明：const UINT8* dataBuf 待解析的数据
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
* by cgh 20240221
*/
UINT8 CheckCiToCiCfpRrmData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 cRrmSrcRcId = 0U;/* RRM源RC ID */
	UINT16 wRrmTrainId = 0U;/* RRM列车ID */
	UINT16 wRrmTrainNextStaId = 0U;/* RRM列车申请的下一站台ID */
	UINT8 chRrmSrcApplyState = 0U;/* 跨控区远程RM时，源TIOC申请状态 */
	UINT8 chRrmDstAllowState = 0U;/* 跨控区远程RM时，目标TIOC允许状态 */

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;

		/*分界点远程RM跨控区申请信息*/
		cRrmSrcRcId = dataBuf[ii++];
		if (CI_SUM_MAX > cRrmSrcRcId)
		{
			/*继续校验*/
		}
		else
		{
			debug_infor_printf((const)"CheckCiToCiCfpRrmData cRrmSrcRcId %d Is Error\n", cRrmSrcRcId);
			retVal = CI_ERROR;
		}

		if (CI_SUCCESS == retVal)
		{
			wRrmTrainId = ShortFromChar(&dataBuf[ii]);						/* RRM列车ID */
			ii += 2U;
			if (TRAIN_SUM_MAX > wRrmTrainId)
			{
				/*继续校验*/
			}
			else
			{
				debug_infor_printf((const)"CheckCiToCiCfpRrmData wRrmTrainId[%d] Is Error: TrainId Is Exceed Max %d\n", wRrmTrainId, TRAIN_SUM_MAX);
				retVal = CI_ERROR;
			}
		}
		else
		{
			/*校验失败*/
		}

		if (CI_SUCCESS == retVal)
		{
			wRrmTrainNextStaId = ShortFromChar(&dataBuf[ii]);				/* RRM列车申请的下一站台ID */
			ii += 2U;
			if (UINT16_MAX != wRrmTrainNextStaId)
			{
				/*继续校验*/
			}
			else
			{
				debug_infor_printf((const)"CheckCiToCiCfpRrmData wRrmTrainNextStaId %d Is Error: wRrmTrainNextStaId Is Exceed Max %d\n", wRrmTrainNextStaId, UINT16_MAX);
				retVal = CI_ERROR;
			}
		}
		else
		{
			/*校验失败*/
		}

		if (CI_SUCCESS == retVal)
		{

			chRrmSrcApplyState = dataBuf[ii++];				/* 跨控区远程RM时，源TIOC申请状态 */
			if ((TRAIN_RRM_LOCALCI_NOT_APPLY == chRrmSrcApplyState) || (TRAIN_RRM_LOCALCI_APPLY == chRrmSrcApplyState))
			{
				/*继续校验*/
			}
			else
			{
				debug_infor_printf((const)"CheckCiToCiCfpRrmData chRrmSrcApplyState %d Is Error\n", chRrmSrcApplyState);
				retVal = CI_ERROR;
			}
		}
		else
		{
			/*校验失败*/
		}
		
		if (CI_SUCCESS == retVal)
		{

			chRrmDstAllowState = dataBuf[ii++];				/* 跨控区远程RM时，目标TIOC允许状态 */
			if ((TRAIN_RRM_OTHERCI_ALLOW == chRrmDstAllowState) || (TRAIN_RRM_OTHERCI_NOT_ALLOW == chRrmDstAllowState))
			{
				/*继续校验*/
			}
			else
			{
				debug_infor_printf((const)"CheckCiToCiCfpRrmData chRrmDstAllowState %d Is Error\n", chRrmDstAllowState);
				retVal = CI_ERROR;
			}
		}
		else
		{
			/*校验失败*/
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
	}

	return retVal;
}

/*
* 功能描述： 初始化本联锁需发送的离去逻辑区段ID数组,通过配置数据
* 参数说明： void
* 返回值  ： 返回成功
*/
UINT8 InitLeaveLogIdBufOfOtherCiByConf(void)
{
	UINT16 ii = 0u;								/* 游标 */
	UINT16 jj = 0u;
	UINT8 kk = 0u;
	UINT8 belongCiId = 0u;						/*所属联锁ID*/

	CiTransmitStruct* pTmpCiTransmitStru = NULL;
	UINT8 reVal = CI_ERROR;
	UINT16 routeSum = 0U;

	UINT8 leaveLogBelongCI = 0U;  /*第一离去区段所属联锁ID*/
	UINT8 routeBelongCi = 0U;  /*进路所属联锁ID*/
	UINT16 leaveLogicSecId = 0U;
	UINT16 tmpRouteId = 0U;

	UINT8 checkSumCBTC = 0U;
	UINT8 checkSumBloc = 0U;
	RouteOtherCheckStruct* dataOtherCiDevBufCBTC = NULL;
	RouteOtherCheckStruct* dataOtherCiDevBufBloc = NULL;
	UINT8 checkFlag = CI_ERROR; 
	UINT8 logBelogAxisNum = 0u;
	UINT16* logBelogAxisBuff = NULL;
	UINT16 phySecId = 0U;
	UINT8 phySwitchSum = 0U;

	routeSum = GetRouteCurSum();		        /*获取进路总数*/
	belongCiId = GetSystemParaLocalCiId();
	reVal = CI_SUCCESS;
	/* 具有锁闭状态所有区段 */
	for (ii = 0u; ii < ciTransNum; ii++)
	{
		pTmpCiTransmitStru = &ciTransmitStruct[ii];

		if (pTmpCiTransmitStru->srcCiId == belongCiId)
		{
			pTmpCiTransmitStru->routeleaveLogSumOfOtherCi = 0u;
			
			/* 遍历所有进路 */
			for (jj = 0u; jj < routeSum; jj++)
			{

				checkFlag = CI_ERROR;
				tmpRouteId = GetRouteId(jj);                           /*获取进路ID*/
				routeBelongCi = GetRouteBelongCiId(tmpRouteId);/*进路所属联锁ID*/
			    /*获取进路外方第一离去逻辑区段*/
				leaveLogicSecId = GetRouteLeaveLogicSecId(tmpRouteId);
				leaveLogBelongCI = GetLogSecBelongCiId(leaveLogicSecId);

				/*逻辑区段关联的计轴区段*/
				logBelogAxisNum = GetLgcSecRelativeAxleSecSum(leaveLogicSecId);
				logBelogAxisBuff = GetLgcSecRltvAxleSecIdBuf(leaveLogicSecId);
			
				/*离去逻辑区段关联的物理区段*/
				phySecId= GetLgcSecRelativePhySecId(leaveLogicSecId);
				phySwitchSum = GetPhyIncludeSwitchSum(phySecId);	/*物理区段包含的道岔数量*/
				
				/*进路所属联锁为目标联锁，并且离去区段为无岔区段*/
				if ((pTmpCiTransmitStru->destCiId == routeBelongCi)&&(0U == phySwitchSum)&&(1U== logBelogAxisNum))
				{
					/*CBTC其他联锁检查条件*/
					checkSumBloc = GetRouteBlocOtherCiSum(tmpRouteId);
					dataOtherCiDevBufBloc = GetRouteBlocOtherCiBuf(tmpRouteId);
					/*点式其他联锁检查条件*/
					checkSumCBTC = GetRouteCbtcOtherCiSum(tmpRouteId);
					dataOtherCiDevBufCBTC = GetRouteCbtcOtherCiBuf(tmpRouteId);

					/*进路其他联锁条件中已配置离去计轴检查条件*/
					if ((NULL != dataOtherCiDevBufBloc) && (NULL != dataOtherCiDevBufCBTC))
					{
						for (kk = 0; kk < checkSumBloc; kk++)
						{
							if ((CI_DEVICE_TYPE_AXISSEC == dataOtherCiDevBufBloc[kk].DevType)&&(dataOtherCiDevBufBloc[kk].DevId== logBelogAxisBuff[0]))
							{
								checkFlag = CI_SUCCESS;
								break;
							}
						}

						for (kk = 0; kk < checkSumCBTC; kk++)
						{
							if ((CI_DEVICE_TYPE_AXISSEC == dataOtherCiDevBufCBTC[kk].DevType)&&(dataOtherCiDevBufCBTC[kk].DevId == logBelogAxisBuff[0]))
							{
								checkFlag = CI_SUCCESS;
								break;
							}
						}
					}
					else
					{
						reVal = CI_ERROR;
					}
				}
				if (CI_SUCCESS == checkFlag)
				{

					/*查找进路属于目标联锁，离去逻辑区段属于本联锁*/
					if (leaveLogBelongCI == belongCiId)
					{
						if (CI_TO_CI_LEAVE_LOGSEC_ROUTE_NUM > pTmpCiTransmitStru->routeleaveLogSumOfOtherCi)
						{
							/*去重*/
							for ( kk = 0; kk < pTmpCiTransmitStru->routeleaveLogSumOfOtherCi; kk++)
							{
								if (leaveLogicSecId == pTmpCiTransmitStru->wrouteleaveLogIdBufOfOtherCi[kk])
								{
									/*逻辑区段已存入数组*/
									break;
								}
							}
							if(kk== pTmpCiTransmitStru->routeleaveLogSumOfOtherCi)
							{
								pTmpCiTransmitStru->wrouteleaveLogIdBufOfOtherCi[pTmpCiTransmitStru->routeleaveLogSumOfOtherCi] = leaveLogicSecId;
								pTmpCiTransmitStru->routeleaveLogSumOfOtherCi++;
							}
						}
						else
						{
							/*数组溢出，返回失败*/
							reVal = CI_ERROR;
							break;
						}

					}
					else
					{
						;
					}
				}
			}
		}
		if (CI_ERROR == reVal)
		{
			break;
		}
	
	}

	return reVal;
}

/*
* 功能描述：校验相邻CI发送的离去逻辑区段数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
* Created By LQ 2023.11.16
*/
UINT8 CheckCiToCiLeaveLogSecData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT16 leaveLogNum = 0U;  /*离去区段数量*/
	UINT32 dwLogSecId = 0U;  /*逻辑区段ID*/
	UINT8 checkFlag = 0U;	/*检查标志*/

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;

		leaveLogNum =ShortFromChar(&dataBuf[ii]);  /*离去区段数量*/
		ii += 2U;
	
		if (CI_TO_CI_LEAVE_LOGSEC_ROUTE_NUM >= leaveLogNum)
		{
			for (jj = 0U; jj < leaveLogNum; jj++)
			{
				/*校验逻辑区段ID*/
				dwLogSecId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;

				checkFlag=dataBuf[ii];
				ii++;

				if ((0U != dwLogSecId) && (LOGIC_SECTION_SUM_MAX > dwLogSecId))
				{
					if ((LOGSEC_LEAVE_LOGSEC_REPLY_YES == checkFlag) || (LOGSEC_LEAVE_LOGSEC_REPLY_NO == checkFlag))
					{
						;
					}
					else
					{
						/*返回失败*/
						debug_infor_printf((const)"CheckCiToCiLeaveLogSecData Is Error: checkFlag Is %d\n", checkFlag);
						retVal = CI_ERROR;
					}
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiLeaveLogSecData Is Error: dwLogSecId Is %d\n", dwLogSecId);
					retVal = CI_ERROR;
				}

				if (CI_SUCCESS != retVal)
				{
					break;
				}
				else
				{
					/*继续解析*/
				}
			}
		}
		else
		{
			/*离去区段数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiLeaveLogSecData Is Error: leaveLogNum Is %d\n", leaveLogNum);
			retVal = CI_ERROR;
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述： 初始化本联锁需发送的需要检查道岔状态的进路
* 参数说明： void
* 返回值  ： CI_SUCCESS 初始化成功
*            CI_ERROR 初始化失败
* by cgh 20241202
*/
UINT8 InitNeedCheckSwitchStaRoute(void)
{
	UINT8 chReVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 wRouteCurSum = 0U;/*进路当前总数*/
	UINT16 jj = 0U;
	UINT8 chLocalCiId = 0U;/*本地联锁ID*/
	CiTransmitStruct* pTmpCiTransmitStru = NULL;
	UINT16 wRouteId = 0U;/*进路ID*/
	UINT8 chRouteExistLocalCiSwFlag = 0U;/*进路存在本地联锁道岔检查结果*/
	CiTransmitStruct* pDestCiTransmitStru = NULL;/*目标相邻联锁数据*/

	wRouteCurSum = GetRouteCurSum();
	chLocalCiId = GetSystemParaLocalCiId();

	if (0U == ciTransNum)
	{
		/*试车线无相邻联锁数据传输要初始化成功*/
		chReVal = CI_SUCCESS;
	}
	else
	{
		for (ii = 0u; ii < ciTransNum; ii++)
		{
			pTmpCiTransmitStru = &ciTransmitStruct[ii];
			if (NULL != pTmpCiTransmitStru)
			{
				chReVal = CI_SUCCESS;
				if (chLocalCiId == pTmpCiTransmitStru->destCiId)
				{
					/*跨控区驱动道岔的进路，必然进路所在联锁要在数据中配置给道岔所在联锁传递进路数据*/
					pDestCiTransmitStru = GetDstCiTransInfo(pTmpCiTransmitStru->srcCiId);
					if (NULL != pDestCiTransmitStru)
					{
						pDestCiTransmitStru->wNeedCheckSwitchStateRouteSum = 0U;
						for (jj = 0U; jj < wRouteCurSum; jj++)
						{
							wRouteId = GetRouteId(jj);
							chRouteExistLocalCiSwFlag = GetOthCiRouteExistLocalCiSw(wRouteId);
							if (pTmpCiTransmitStru->srcCiId == chRouteExistLocalCiSwFlag)
							{
								/*获取本联锁要发给相邻联锁的数据，填充数据*/
								if (ROUTE_SUM_MAX > pDestCiTransmitStru->wNeedCheckSwitchStateRouteSum)
								{
									pDestCiTransmitStru->szNeedCheckSwStateRouteBuf[pDestCiTransmitStru->wNeedCheckSwitchStateRouteSum] = wRouteId;
									pDestCiTransmitStru->wNeedCheckSwitchStateRouteSum++;
								}
								else
								{
									chReVal = CI_ERROR;
									break;
								}
							}
							else
							{
								; /*不添加*/
							}
						}
					}
				}
				else
				{
					; /*继续查找接收方是自己联锁的*/
				}
			}
			else
			{
				;
			}

			if (CI_ERROR == chReVal)
			{
				break;
			}
			else
			{
				; /*继续初始化*/
			}
		}
	}

	return chReVal;
}

/*
* 功能描述：校验相邻CI发送的需要检查道岔状态的进路数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返回值  ：0 校验失败
*           1 校验成功
* by cgh 20241202
*/
UINT8 CheckCiToCiNeedCheckSwRouteData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT16 wNeedCheckRouteSum = 0U;  /*需要检查进路数目*/
	UINT32 wNeedCheckRouteId = 0U;  /*需要检查进路ID*/
	UINT8 chRouteApplySwitchCheckFlag = 0U;/*进路办理道岔检查标志*/
	UINT16 wErrorDevID = 0U;
	UINT8 chErrorDevType = 0U;
	UINT8 chErrorDevState = 0U;
	UINT8 chErrorCodeType = 0U;

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;

		wNeedCheckRouteSum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;

		if (ROUTE_SUM_MAX > wNeedCheckRouteSum)
		{
			for (jj = 0U; jj < wNeedCheckRouteSum; jj++)
			{
				wNeedCheckRouteId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;

				if ((0U < wNeedCheckRouteId) && (ROUTE_SUM_MAX > wNeedCheckRouteId))
				{
					chRouteApplySwitchCheckFlag = dataBuf[ii];
					ii++;
					if ((ROUTE_APPLY_SWITCH_CHECK_NO == chRouteApplySwitchCheckFlag) || (ROUTE_APPLY_SWITCH_CHECK_YES == chRouteApplySwitchCheckFlag))
					{
						/*设备ID 2  设备类型1 设备状态1 错误类型1*/
						wErrorDevID = ShortFromChar(&dataBuf[ii]);
						ii += 2U;
						chErrorDevType = dataBuf[ii++];
						chErrorDevState = dataBuf[ii++];
						chErrorCodeType = dataBuf[ii++];
						if (0U == wErrorDevID)
						{
							;/*跳过类型、状态和错误类型检查*/
						}
						else
						{
							switch (chErrorDevType)
							{
							case CI_DEVICE_TYPE_SWITCH:
								if (SWITCH_SUM_MAX > wErrorDevID)
								{
									if ((ETYPE_SWT_POSTION_STATE == chErrorCodeType)
										|| (ETYPE_SWT_YLOCK_STATE == chErrorCodeType)
										|| (ETYPE_SWT_LOCK_STATUS == chErrorCodeType))
									{
										;/*通过*/
									}
									else
									{
										retVal = CI_ERROR;
										debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: Switchid: chErrorCodeType Is %d\n", chErrorCodeType);
									}
								}
								else
								{
									debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: Switchid: wErrorDevID Is %d\n", wErrorDevID);
									retVal = CI_ERROR;
								}
								break;
							case CI_DEVICE_TYPE_ROUTE:
								if ((wNeedCheckRouteId != wErrorDevID) || (ETYPE_ROUTE_APPLY_SWITCH_MOVE != chErrorCodeType))
								{
									retVal = CI_ERROR;/*错误类型*/
									debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: Route: wErrorDevID Is %d\n", wErrorDevID);
								}
								break;
							case CI_DEVICE_TYPE_LOGICSEC:
								if (LOGIC_SECTION_SUM_MAX > wErrorDevID)
								{
									if (ETYPE_LOGSEC_LOCK_STATE == chErrorCodeType)
									{
										;/*通过*/
									}
									else
									{
										debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: Logsec: chErrorDevState Is %d\n", chErrorCodeType);
										retVal = CI_ERROR;
									}
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: LogSec: wErrorDevID Is %d\n", wErrorDevID);
								}
								break;
							case CI_DEVICE_TYPE_PHYSEC:
								if (PHYSICAL_SECTION_SUM_MAX > wErrorDevID)
								{
									if ((ETYPE_PS_LOCK_STATE == chErrorCodeType) 
										||(ETYPE_PS_JUMP_LOCK == chErrorCodeType) 
										||(ETYPE_PS_MERGY_OCU_STATE == chErrorCodeType)
										||(ETYPE_PS_FLOCK_STATE == chErrorCodeType))
									{
										;/*通过*/
									}
									else
									{
										debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: PhySec: chErrorCodeType Is %d\n", chErrorCodeType);
										retVal = CI_ERROR;
									}
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: PhySec: wErrorDevID Is %d\n", wErrorDevID);
								}
								break;
							default:
								debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: chErrorDevType Is %d\n", chErrorDevType);
								retVal = CI_ERROR;/*错误类型*/
							}
						}
					}
					else
					{
						/*返回失败*/
						debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: chRouteApplySwitchCheckFlag Is %d\n", chRouteApplySwitchCheckFlag);
						retVal = CI_ERROR;
					}
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: wNeedCheckRouteId Is %d\n", wNeedCheckRouteId);
					retVal = CI_ERROR;
				}

				if (CI_SUCCESS != retVal)
				{
					break;
				}
				else
				{
					; /*继续解析*/
				}
			}
		}
		else
		{
			/*数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: wNeedCheckRouteSum Is %d\n", wNeedCheckRouteSum);
			retVal = CI_ERROR;
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述：初始化需要由本控区检查防护道岔状态的其它控区的保护区段
* 参数说明：void
* 返 回 值：1 成功
*           0 失败
* Created By LQ 2024.12.03
*/
UINT8 InitNeedCheckProSwtStaOverlap(void)
{
	UINT8 cRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 wOverlapCurSum = 0U;  /*保护区段当前总数*/
	UINT8 cLocalCiId = 0U;  /*本地联锁ID*/
	CiTransmitStruct* pTmpCiTransmitStru = NULL;  /*当前联锁数据*/
	CiTransmitStruct* pDestCiTransmitStru = NULL;  /*目标相邻联锁数据*/
	UINT16 wOverlapId = 0U;  /*保护区段ID*/
	UINT8 cCheckFlag = 0U;

	wOverlapCurSum = GetOverlapCurSum();
	cLocalCiId = GetSystemParaLocalCiId();
	cRetVal = CI_SUCCESS;

	for (ii = 0U; ii < ciTransNum; ii++)
	{		
		pTmpCiTransmitStru = &ciTransmitStruct[ii];
		if (NULL != pTmpCiTransmitStru)
		{			
			if (cLocalCiId == pTmpCiTransmitStru->destCiId)
			{
				/*保护区段要跨控区驱动防护道岔，该保护区段必然要在接口中进行传递*/
				pDestCiTransmitStru = GetDstCiTransInfo(pTmpCiTransmitStru->srcCiId);
				if (NULL != pDestCiTransmitStru)
				{
					pDestCiTransmitStru->wNeedCheckProSwtStateOlpNum = 0U;  /*初始化清0*/
					for (jj = 0U; jj < wOverlapCurSum; jj++)
					{
						wOverlapId = GetOverlapId(jj);
						cCheckFlag = CheckOtherCiOlpHaveLocalCiPSw(wOverlapId);  /*检查其它控区保护区段是否有防护道岔属于本控区*/
						if (pTmpCiTransmitStru->srcCiId == (UINT16)cCheckFlag)
						{
							if (OVERLAP_SUM_MAX > pDestCiTransmitStru->wNeedCheckProSwtStateOlpNum)
							{
								/*存在保护区段的防护道岔属于本控区，记录此保护区段*/
								pDestCiTransmitStru->szNeedCheckProSwtStateOlpIdBuf[pDestCiTransmitStru->wNeedCheckProSwtStateOlpNum] = wOverlapId;
								pDestCiTransmitStru->wNeedCheckProSwtStateOlpNum++;
							}
							else
							{
								cRetVal = CI_ERROR;
								break;
							}
						}
						else
						{
							/*不添加，继续遍历*/
						}
					}
				}
				else
				{
					/*本方不向对方发送数据，说明对方的数据仅复视用，不处理*/
				}
			}
			else
			{
				/*继续查找接收方是自己联锁的*/
			}
		}
		else
		{
			cRetVal = CI_ERROR;  /*数据获取错误，返回失败*/
		}

		if (CI_ERROR == cRetVal)
		{
			break;  /*初始化失败*/
		}
		else
		{
			/*继续遍历*/
		}
	}

	return cRetVal;
}

/*
* 功能描述：校验相邻CI发送的需要检查防护道岔状态的保护区段数据
* 参数说明：const UINT8* dataBuf 待解析的数据
*           UINT16* index 索引
* 返 回 值：0 校验失败
*           1 校验成功
* Created By LQ 2024.12.03
*/
UINT8 CheckCiToCiNeedCheckSwOlpData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 cRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 wNeedCheckOverlapNum = 0U;  /*保护区段数目*/
	UINT16 wNeedCheckOverlapId = 0U;  /*保护区段ID*/
	UINT8 cProSwCheckResultFlag = 0U;  /*防护道岔检查结果标志*/

	if ((NULL != dataBuf) && (NULL != index))
	{
		cRetVal = CI_SUCCESS;
		ii = *index;

		wNeedCheckOverlapNum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;

		if (OVERLAP_SUM_MAX > wNeedCheckOverlapNum)
		{
			for (jj = 0U; jj < wNeedCheckOverlapNum; jj++)
			{
				wNeedCheckOverlapId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;
				
				if ((0U < wNeedCheckOverlapId) && (OVERLAP_SUM_MAX > wNeedCheckOverlapId))
				{
					cProSwCheckResultFlag = dataBuf[ii];
					ii++;
					if ((PROSWITCH_CHECK_RESULT_INVALID == cProSwCheckResultFlag) || (PROSWITCH_CHECK_RESULT_VALID == cProSwCheckResultFlag))
					{
						/*继续检查*/
					}
					else
					{
						/*检查结果非法，返回失败*/
						debug_infor_printf((const)"CheckCiToCiNeedCheckSwOlpData Is Error: ProSwCheckResultFlag Is %d\n", cProSwCheckResultFlag);
						cRetVal = CI_ERROR;
					}
				}
				else
				{
					/*保护区段ID非法，返回失败*/
					debug_infor_printf((const)"CheckCiToCiNeedCheckSwOlpData Is Error: NeedCheckOverlapId Is %d\n", wNeedCheckOverlapId);
					cRetVal = CI_ERROR;
				}

				if (CI_SUCCESS != cRetVal)
				{
					break;
				}
				else
				{
					; /*继续解析*/
				}
			}
		}
		else
		{
			/*数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiNeedCheckSwOlpData Is Error: NeedCheckOverlapNum Is %d\n", wNeedCheckOverlapNum);
			cRetVal = CI_ERROR;
		}

		*index = ii;  /*传出索引*/
	}
	else
	{		
		cRetVal = CI_ERROR;  /*入参校验失败，返回失败*/
	}

	return cRetVal;
}

/*
* 功能描述：校验相邻CI发送的防护道岔防护锁闭数据
* 参数说明：const UINT8* dataBuf 待解析的数据
*           UINT16* index 索引
* 返 回 值：0 校验失败
*           1 校验成功
* Created By LQ 2024.12.04
*/
UINT8 CheckCiToCiProSwPLockData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 cRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT8 kk = 0U;
	UINT16 wProSwNum = 0U;  /*防护道岔数目*/
	UINT16 wProSwId = 0U;  /*防护道岔ID*/
	UINT8 cPLockRouteNum = 0U;  /*防护锁闭的进路数量*/
	UINT16 wPLockRouteId = 0U;  /*防护锁闭的进路ID*/
	UINT8 cPLockOverlapNum = 0U;  /*防护锁闭的保护区段数量*/
	UINT16 wPLockOverlapId = 0U;  /*防护锁闭的保护区段ID*/

	if ((NULL != dataBuf) && (NULL != index))
	{
		cRetVal = CI_SUCCESS;
		ii = *index;

		wProSwNum = ShortFromChar(&dataBuf[ii]);
		ii += 2U;

		if (SWITCH_SUM_MAX > wProSwNum)
		{
			for (jj = 0U; jj < wProSwNum; jj++)
			{
				wProSwId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;

				if ((0U < wProSwId) && (SWITCH_SUM_MAX > wProSwId))
				{
					cPLockRouteNum = dataBuf[ii];  /*防护锁闭进路数量*/
					ii++;
					if (SWITCH_MAX_PROTECT_LOCKED_NUM >= cPLockRouteNum)
					{
						for (kk = 0U; kk < cPLockRouteNum; kk++)
						{
							wPLockRouteId = ShortFromChar(&dataBuf[ii]);  /*防护锁闭进路ID*/
							ii += 2U;

							if ((0 < wPLockRouteId) && (ROUTE_SUM_MAX > wPLockRouteId))
							{

							}
							else
							{
								/*防护锁闭进路ID非法，返回失败*/
								debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: PLockRouteId Is %d\n", wPLockRouteId);
								cRetVal = CI_ERROR;
								break;
							}
						}
					}
					else
					{
						/*防护锁闭进路数量超限，返回失败*/
						debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: PLockRouteNum Is %d\n", cPLockRouteNum);
						cRetVal = CI_ERROR;
					}

					if (CI_SUCCESS == cRetVal)
					{
						cPLockOverlapNum = dataBuf[ii];  /*防护锁闭保护区段数量*/
						ii++;
						if (SWITCH_MAX_PROTECT_LOCKED_NUM >= cPLockOverlapNum)
						{
							for (kk = 0U; kk < cPLockOverlapNum; kk++)
							{
								wPLockOverlapId = ShortFromChar(&dataBuf[ii]);  /*防护锁闭保护区段ID*/
								ii += 2U;

								if ((0 < wPLockOverlapId) && (OVERLAP_SUM_MAX > wPLockOverlapId))
								{

								}
								else
								{
									/*防护锁闭保护区段ID非法，返回失败*/
									debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: PLockOverlapId Is %d\n", wPLockOverlapId);
									cRetVal = CI_ERROR;
									break;
								}
							}
						}
						else
						{
							/*防护锁闭保护区段数量超限，返回失败*/
							debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: PLockOverlapNum Is %d\n", cPLockOverlapNum);
							cRetVal = CI_ERROR;
						}
					}
					else
					{
						/*校验失败，不继续校验*/
					}
				}
				else
				{
					/*防护道岔ID非法，返回失败*/
					debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: ProSwitchId Is %d\n", wProSwId);
					cRetVal = CI_ERROR;
				}

				if (CI_SUCCESS != cRetVal)
				{
					break;
				}
				else
				{
					; /*继续解析*/
				}
			}
		}
		else
		{
			/*防护道岔数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: ProSwitchNum Is %d\n", wProSwNum);
			cRetVal = CI_ERROR;
		}

		*index = ii;  /*传出索引*/
	}
	else
	{
		cRetVal = CI_ERROR;  /*入参校验失败，返回失败*/
	}

	return cRetVal;
}

/*
* 功能描述：初始化需要本控区保护区段征用的其它控区的防护道岔
* 参数说明：void
* 返 回 值：1 成功
*           0 失败
* edit cgh 20241224
*/
UINT8 InitNeedOlapUsingOtherCiProSw(void)
{
	UINT8 cRetVal = CI_ERROR;
	UINT8 cLocalCiId = 0U;  /*本地联锁ID*/
	UINT16 wOverlapCurSum = 0U;  /*保护区段当前总数*/
	UINT16 ii = 0U;
	CiTransmitStruct* pTmpCiTransmitStru = NULL;  /*当前联锁数据*/
	UINT16 jj = 0U;
	UINT16 wOverlapId = 0U;  /*保护区段ID*/
	UINT8 cOverlapBelongCiId = 0U;
	UINT8 cOverlapRelProSwNum = 0U;  /*保护区段关联的防护道岔数量*/
	OverlapProtectSwitchStruct* pOverlapRelProSwStru = NULL;  /*保护区段关联的防护道岔信息*/
	UINT8 cSwitchBelongCiId = 0U;
	UINT8 kk = 0U;
	UINT16 mm = 0U;
	UINT16 wRouteCurSum = 0U;/*进路当前总数*/
	UINT16 wRouteId = 0U;/*进路ID*/
	UINT8 chRouteBelCiId = 0U;/*进路所属联锁ID*/
	UINT8 chRouteProSwitchSum = 0U;/*进路防护道岔数目*/
	RouteProtectSwitchStruct* szRouteProSwitchData = NULL;/*进路防护道岔数据*/

	cLocalCiId = GetSystemParaLocalCiId();
	wOverlapCurSum = GetOverlapCurSum();
	cRetVal = CI_SUCCESS;
	wRouteCurSum = GetRouteCurSum();

	for (ii = 0U; ii < ciTransNum; ii++)
	{
		pTmpCiTransmitStru = &ciTransmitStruct[ii];
		if (NULL != pTmpCiTransmitStru)
		{
			if ((cLocalCiId == pTmpCiTransmitStru->srcCiId) && (0U != pTmpCiTransmitStru->srcCiId))
			{
				pTmpCiTransmitStru->wSwitchSumOfOtherCi = 0U;  /*初始化清0*/
				for (jj = 0U; jj < wOverlapCurSum; jj++)
				{
					wOverlapId = GetOverlapId(jj);
					cOverlapBelongCiId = GetOverlapBelongCiId(wOverlapId);  /*获取保护区段所属控区*/
					if (cLocalCiId == cOverlapBelongCiId)
					{
						cOverlapRelProSwNum = GetOverlapRelatedProtSwitSum(wOverlapId);  /*获取保护区段关联的防护道岔信息*/
						pOverlapRelProSwStru = GetOverlapRelatedProtSwitStru(wOverlapId);

						if (NULL != pOverlapRelProSwStru)
						{
							for (kk = 0U; kk < cOverlapRelProSwNum; kk++)
							{
								cSwitchBelongCiId = GetSwitchBelongCiId(pOverlapRelProSwStru[kk].ProtectSwitchId);
								if ((0U != cSwitchBelongCiId) && (pTmpCiTransmitStru->destCiId == cSwitchBelongCiId))
								{
									/*防护道岔属于对方控区，去重检查后添加该道岔*/
									for (mm = 0U; mm < pTmpCiTransmitStru->wSwitchSumOfOtherCi; mm++)
									{
										/*去重检查*/
										if (pOverlapRelProSwStru[kk].ProtectSwitchId == pTmpCiTransmitStru->szSwitchIdBufOfOtherCi[mm])
										{
											break;
										}
										else
										{
											/*继续遍历查找是否已添加*/
										}
									}

									if (mm == pTmpCiTransmitStru->wSwitchSumOfOtherCi)
									{
										/*未添加该道岔，则添加*/
										if (SWITCH_SUM_MAX > pTmpCiTransmitStru->wSwitchSumOfOtherCi)
										{
											pTmpCiTransmitStru->szSwitchIdBufOfOtherCi[pTmpCiTransmitStru->wSwitchSumOfOtherCi] = pOverlapRelProSwStru[kk].ProtectSwitchId;  /*添加保护区段征用的非本控区道岔ID*/
											pTmpCiTransmitStru->wSwitchSumOfOtherCi++;
										}
										else
										{
											cRetVal = CI_ERROR;  /*数量超限，返回失败*/
											break;
										}
									}
									else
									{
										/*该道岔已添加或数量已达上限，不处理*/
									}
								}
								else
								{
									/*防护道岔属于本控区，不处理*/
								}
							}
						}
						else
						{
							cRetVal = CI_ERROR;  /*数据获取错误，返回失败*/
							break;
						}
					}
					else
					{
						/*非本控区保护区段，不处理*/
					}
				}

				/*添加相邻控区进路有道岔或防护道岔在本控区数据*/
				if (CI_SUCCESS == cRetVal)
				{
					for (jj = 0U; jj < wRouteCurSum; jj++)
					{
						wRouteId = GetRouteId(jj);
						chRouteBelCiId = GetRouteBelongCiId(wRouteId);  /*获取进路所属控区*/

						if (cLocalCiId == chRouteBelCiId)
						{
							chRouteProSwitchSum = GetRouteRelatedProtectSwitchSum(wRouteId);  
							szRouteProSwitchData = GetRouteRelatedProtSwitchData(wRouteId);

							if (NULL != szRouteProSwitchData)
							{
								for (kk = 0U; kk < chRouteProSwitchSum; kk++)
								{
									cSwitchBelongCiId = GetSwitchBelongCiId(szRouteProSwitchData[kk].ProtectSwitchId);
									if ((0U != cSwitchBelongCiId) && (pTmpCiTransmitStru->destCiId == cSwitchBelongCiId))
									{
										/*防护道岔属于对方控区，去重检查后添加该道岔*/
										for (mm = 0U; mm < pTmpCiTransmitStru->wSwitchSumOfOtherCi; mm++)
										{
											/*去重检查*/
											if (szRouteProSwitchData[kk].ProtectSwitchId == pTmpCiTransmitStru->szSwitchIdBufOfOtherCi[mm])
											{
												break;
											}
											else
											{
												/*继续遍历查找是否已添加*/
											}
										}

										if (mm == pTmpCiTransmitStru->wSwitchSumOfOtherCi)
										{
											/*未添加该道岔，则添加*/
											if (SWITCH_SUM_MAX > pTmpCiTransmitStru->wSwitchSumOfOtherCi)
											{
												pTmpCiTransmitStru->szSwitchIdBufOfOtherCi[pTmpCiTransmitStru->wSwitchSumOfOtherCi] = szRouteProSwitchData[kk].ProtectSwitchId;  /*添加保护区段征用的非本控区道岔ID*/
												pTmpCiTransmitStru->wSwitchSumOfOtherCi++;
											}
											else
											{
												cRetVal = CI_ERROR;  /*数量超限，返回失败*/
												break;
											}
										}
										else
										{
											/*该道岔已添加或数量已达上限，不处理*/
										}
									}
									else
									{
										/*防护道岔属于本控区，不处理*/
									}
								}
							}
							else
							{
								cRetVal = CI_ERROR;  /*数据获取错误，返回失败*/
								break;
							}
						}
						else
						{
							/*非本控区进路，不处理*/
						}
					}
				}
				else
				{
					; /*返回失败*/
				}
			}
			else
			{
				/*继续遍历初始化*/
			}
		}
		else
		{
			cRetVal = CI_ERROR;  /*数据获取错误，返回失败*/
		}

		if (CI_ERROR == cRetVal)
		{
			break;  /*初始化失败*/
		}
		else
		{
			/*继续遍历*/
		}
	}

	return cRetVal;
}

/*
* 功能描述：清除相邻联锁发送给本联锁的区间ITE切除信息
* 参数说明：const UINT8 cSrcCiId 发送方CI
* 返 回 值：无
* Created By LQ 2025.04.14
*/
void ClearCiRecvAreaIteCutInfo(const UINT8 cSrcCiId)
{
	UINT16 ii = 0U;

	if ((0U != cSrcCiId) && (CI_SUM_MAX > cSrcCiId))
	{
		for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++)
		{
			if (szRecvCiAreaIteCut[ii].cSourceCiId == cSrcCiId)
			{
				(void)CommonMemSet(&szRecvCiAreaIteCut[ii], (UINT32)sizeof(ToCiAreaIteCutStruct), 0U, (UINT32)sizeof(ToCiAreaIteCutStruct));
				break;
			}
			else
			{
				/*不处理*/
			}
		}
	}
	else
	{
		/*入参非法，不处理*/
	}
}

/*
* 功能描述：清除本联锁发送给相邻联锁的区间ITE切除信息
* 参数说明：无
* 返 回 值：无
* Created By LQ 2025.04.14
*/
void ClearCiSendAreaIteCutInfo(void)
{
	(void)CommonMemSet(szSendCiAreaIteCut, (UINT32)(CI_COM_CI_MAX_NUM * sizeof(ToCiAreaIteCutStruct)), 0U, (UINT32)(CI_COM_CI_MAX_NUM * sizeof(ToCiAreaIteCutStruct)));
}

/*
* 功能描述： 获取相邻联锁发送给本联锁的区间ITE切除信息
* 参数说明： 无
* 返 回 值： 接收其它联锁的区间ITE切除信息
* Created By LQ 2025.04.14
*/
ToCiAreaIteCutStruct* GetCiRecvAreaIteCutInfo(void)
{
	return szRecvCiAreaIteCut;
}

/*
* 功能描述：获取本联锁发送给指定ID相邻联锁的区间ITE切除信息
* 参数说明：const UINT8 cTargetCiId 目标联锁
* 返 回 值：发送给其它联锁的区间ITE切除信息
* Created By LQ 2023.11.16
*/
ToCiAreaIteCutStruct* GetCiSendAreaIteCutInfo(const UINT8 cTargetCiId)
{
	ToCiAreaIteCutStruct* retVal = NULL;
	UINT16 ii = 0U;

	if ((0U != cTargetCiId) && (CI_SUM_MAX > cTargetCiId))
	{
		for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++)
		{
			if (szSendCiAreaIteCut[ii].cTargetCiId == cTargetCiId)
			{
				retVal = &szSendCiAreaIteCut[ii];
			}
			else
			{
				/*不处理*/
			}
		}
	}
	else
	{
		/*入参非法，返回NULL*/
	}

	return retVal;
}

/*
* 功能描述：添加相邻联锁发送给本联锁的区间ITE切除信息
* 参数说明：UINT8 cSrcCiId 发送方CI
*           UINT8 cDstCiId 接收方CI
*			UINT16 wAreaId 区间ID
* 返 回 值：无
* Created By LQ 2025.04.14
*/
void AddCiRecvAreaIteCutInfo(UINT8 cSrcCiId, UINT8 cDstCiId, UINT16 wAreaId)
{
	UINT16 ii = 0U;
	UINT8 cKeepWork = CI_ERROR;
	UINT8 cLocalAreaIteCutNum = 0U;
	UINT16* pLocalAreaIteCutId = NULL;
	UINT8 jj = 0U;
	UINT8 cAddFlag = CI_SUCCESS;

	if ((0U != cSrcCiId) && (CI_SUM_MAX > cSrcCiId) && (0U != cDstCiId) && (CI_SUM_MAX > cDstCiId) && (0U != wAreaId) && (UINT16_MAX > wAreaId))
	{
		/*检查此区间ID是否已包含在本地*/
		cLocalAreaIteCutNum = GetLocalAreaIteCutNum();
		pLocalAreaIteCutId = GetLocalAreaIteCutId();

		if ((0U < cLocalAreaIteCutNum) && (NULL != pLocalAreaIteCutId))
		{
			for (jj = 0U; jj < cLocalAreaIteCutNum; jj++)
			{
				if (wAreaId == pLocalAreaIteCutId[jj])
				{
					cAddFlag = CI_ERROR;
					break;
				}
				else
				{
					/*继续遍历检查*/
				}
			}
		}
		else
		{
			/*不处理*/
		}

		if (CI_SUCCESS == cAddFlag)
		{
			for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++)
			{
				/*寻找目标CI的索引*/
				if ((cSrcCiId == szRecvCiAreaIteCut[ii].cSourceCiId) && (cDstCiId == szRecvCiAreaIteCut[ii].cTargetCiId))
				{
					cKeepWork = CI_SUCCESS;
				}
				else if ((0U == szRecvCiAreaIteCut[ii].cSourceCiId) && (0U == szRecvCiAreaIteCut[ii].cTargetCiId))
				{
					cKeepWork = CI_SUCCESS;
				}
				else
				{
					/*继续遍历，查找目标CI*/
				}

				if (CI_SUCCESS == cKeepWork)
				{

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

			if (CI_SUCCESS == cKeepWork)
			{
				if (CI_TO_CI_AREA_SNOW_SUM_MAX > szRecvCiAreaIteCut[ii].cAreaIteCutNum)
				{
					/*添加区间ITE切除信息*/
					szRecvCiAreaIteCut[ii].cSourceCiId = cSrcCiId;
					szRecvCiAreaIteCut[ii].cTargetCiId = cDstCiId;
					szRecvCiAreaIteCut[ii].wAreaIteCutId[szRecvCiAreaIteCut[ii].cAreaIteCutNum] = wAreaId;
					szRecvCiAreaIteCut[ii].cAreaIteCutNum++;
				}
				else
				{
					debug_infor_printf((const)"AddCiRecvAreaIteCutInfo Error: Area Num Exceed Max %d!\n", CI_TO_CI_AREA_SNOW_SUM_MAX);
				}
			}
			else
			{
				debug_infor_printf((const)"AddCiRecvAreaIteCutInfo Error: No TargetCi!\n");
			}
		}
		else
		{
			/*不处理*/
		}
	}
	else
	{
		debug_infor_printf((const)"AddCiRecvAreaIteCutInfo Error: Input Data Error!\n");
	}
}

/*
* 功能描述：添加本联锁发送给指定ID相邻联锁的区间ITE切除信息
* 参数说明：UINT8 cSrcCiId 发送方CI
*           UINT8 cDstCiId 接收方CI
*			UINT16 wAreaId 区间ID
* 返 回 值：无
* Created By LQ 2025.04.14
*/
void AddCiSendAreaIteCutInfo(UINT8 cSrcCiId, UINT8 cDstCiId, UINT16 wAreaId)
{
	UINT16 ii = 0U;
	UINT8 cKeepWork = CI_ERROR;
	UINT8 jj = 0U;
	UINT8 cCommCiNum = 0U;
	UINT8* pCommCiId = NULL;
	UINT8 cAddFlag = CI_ERROR;

	if ((0U != cSrcCiId) && (CI_SUM_MAX > cSrcCiId) && (0U != cDstCiId) && (CI_SUM_MAX > cDstCiId) && (0U != wAreaId) && (UINT16_MAX > wAreaId))
	{
		cCommCiNum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_CI);  /*获取通信CI设备总数*/
		pCommCiId = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_CI);  /*获取通信CI设备ID数组*/

		if ((0U < cCommCiNum) && (NULL != pCommCiId))
		{
			for (jj = 0U; jj < cCommCiNum; jj++)
			{
				if (cDstCiId == pCommCiId[jj])
				{
					cAddFlag = CI_SUCCESS;
					break;
				}
				else
				{
					/*继续遍历检查*/
				}
			}
		}
		else
		{
			/*不处理*/
		}

		if (CI_SUCCESS == cAddFlag)
		{
			for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++)
			{
				/*寻找目标CI的索引*/
				if ((cSrcCiId == szSendCiAreaIteCut[ii].cSourceCiId) && (cDstCiId == szSendCiAreaIteCut[ii].cTargetCiId))
				{
					cKeepWork = CI_SUCCESS;
				}
				else if ((0U == szSendCiAreaIteCut[ii].cSourceCiId) && (0U == szSendCiAreaIteCut[ii].cTargetCiId))
				{
					cKeepWork = CI_SUCCESS;
				}
				else
				{
					/*继续遍历，查找目标CI*/
				}

				if (CI_SUCCESS == cKeepWork)
				{

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

			if (CI_SUCCESS == cKeepWork)
			{
				if (CI_TO_CI_AREA_SNOW_SUM_MAX > szSendCiAreaIteCut[ii].cAreaIteCutNum)
				{
					for (jj = 0U; jj < szSendCiAreaIteCut[ii].cAreaIteCutNum; jj++)
					{
						/*去重处理*/
						if (szSendCiAreaIteCut[ii].wAreaIteCutId[jj] == wAreaId)
						{
							break;
						}
						else
						{
							; /*继续查重*/
						}
					}

					if (szSendCiAreaIteCut[ii].cAreaIteCutNum == jj)
					{
						/*添加区间ITE切除信息*/
						szSendCiAreaIteCut[ii].cSourceCiId = cSrcCiId;
						szSendCiAreaIteCut[ii].cTargetCiId = cDstCiId;
						szSendCiAreaIteCut[ii].wAreaIteCutId[szSendCiAreaIteCut[ii].cAreaIteCutNum] = wAreaId;
						szSendCiAreaIteCut[ii].cAreaIteCutNum++;
					}
					else
					{
						; /*重复不添加*/
					}
				}
				else
				{
					debug_infor_printf((const)"AddCiSendAreaIteCutInfo Error: Area Num Exceed Max %d!\n", CI_TO_CI_AREA_SNOW_SUM_MAX);
				}
			}
			else
			{
				debug_infor_printf((const)"AddCiSendAreaIteCutInfo Error: No TargetCi!\n");
			}
		}
		else
		{
			/*目标RC/CI不具有通信关系，不添加*/
		}
	}
	else
	{
		debug_infor_printf((const)"AddCiSendAreaIteCutInfo Error: Input Data Error!\n");
	}
}

/*
* 功能描述：校验相邻CI发送的待解析的区间ITE切除数据
* 参数说明：const UINT8* dataBuf 待解析的数据；
*           UINT16* index 索引
* 返 回 值：0 校验失败
*           1 校验成功
* Created By LQ 2024.04.15
*/
UINT8 CheckCiToCiAreaIteCutData(const UINT8* dataBuf, UINT16* index)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT8 cAreaIteCutNum = 0U;  /*区间ITE切除数量*/
	UINT16 wAreaId = 0U;  /*区间ID*/
	UINT8 cAreaBelongCiId = 0U;  /*区间所属联锁*/
	UINT8 localCiId = 0U;	/*本联锁ID*/

	if ((NULL != dataBuf) && (NULL != index))
	{
		retVal = CI_SUCCESS;
		ii = *index;
		localCiId = GetSystemParaLocalCiId();

		cAreaIteCutNum = dataBuf[ii];  /*区间ITE切除数量*/
		ii++;
		if (CI_TO_CI_AREA_SNOW_SUM_MAX >= cAreaIteCutNum)
		{
			for (jj = 0U; jj < cAreaIteCutNum; jj++)
			{
				/*校验区间ID*/
				wAreaId = ShortFromChar(&dataBuf[ii]);
				ii += 2U;

				if ((0U != wAreaId) && (UINT16_MAX > wAreaId))
				{
					cAreaBelongCiId = GetAreaSnowPlatFormBelongCiId(wAreaId);  /*获取区间所属控区*/

					if ((localCiId != cAreaBelongCiId) && (0U != cAreaBelongCiId) && (0U != localCiId))
					{
						/*校验通过*/
					}
					else
					{
						/*区间为本控区，返回失败*/
						debug_infor_printf((const)"CheckCiToCiAreaIteCutData Is Error: cAreaBelongCiId Is %d\n", cAreaBelongCiId);
						retVal = CI_ERROR;
					}
				}
				else
				{
					debug_infor_printf((const)"CheckCiToCiAreaIteCutData Is Error: wAreaId Is %d\n", wAreaId);
					retVal = CI_ERROR;
				}

				if (CI_SUCCESS != retVal)
				{
					break;
				}
				else
				{
					/*继续解析*/
				}
			}
		}
		else
		{
			/*区间数量超限，返回失败*/
			debug_infor_printf((const)"CheckCiToCiAreaIteCutData Is Error: cAreaIteCutNum Is %d\n", cAreaIteCutNum);
			retVal = CI_ERROR;
		}
		*index = ii;
	}
	else
	{
		/*入参校验失败，返回失败*/
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述：组互联互通厂商自定义帧
* 参数说明：UINT8 *pInputData 输入数据指针
*           UINT16 *pItemLen 该项数据在输入数据中的长度（出参）
*           const UINT8 dstCiId 目标联锁ID
* 返 回 值：CI_SUCCESS 1 组包成功
*           CI_ERROR 0 组包失败
* Created By LQ 2025.05.23
*/
UINT8 PackManufacDefPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId)
{
	UINT8 cRetVal = CI_ERROR;
	UINT16 wPackedInfoNum = 0U;  /*已组包的信息数量*/
	UINT16 wDeviceId = 0U;  /*设备ID*/
	UINT8 cDeviceState = 0U;  /*设备状态*/
	UINT16 ii = 0U;
	UINT8 cTempCounter = 0U;  /*循环计数器*/
	UINT8 cBitOffset = 0U;  /*位偏移量*/
	UINT16 wPackedLen = 0U;
	CiTransmitStruct* pTmpCiTransInfo = NULL;
	UINT16 wSwitchRelPhySecId = 0U;  /*道岔关联物理区段ID*/
	UINT16 wLockedRouteId = 0U;  /*锁闭所属进路ID*/

	pTmpCiTransInfo = GetDstCiTransInfo(dstCiId);

	if ((NULL != pInputBuf) && (NULL != pItemLen) && (NULL != pTmpCiTransInfo))
	{
		/*组厂商自定义信息版本（微联厂商默认0x01）*/
		*(pInputBuf + wPackedLen) = MANUFAC_DEF_INFO_VER_WL;
		wPackedLen++;
		
		/*组自动进路*/
		for (ii = 0U; ii < pTmpCiTransInfo->autoRouteNum; ii++)
		{
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			wDeviceId = pTmpCiTransInfo->autoRouteIdBuf[ii];
			cDeviceState = GetAutoRouteSetFlag(wDeviceId);  /*获取自动进路办理标志*/
			if (AUTO_ROUTE_SET_YES == cDeviceState)
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*已设置自动进路*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*未设置自动进路*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/
		}

		/*组紧急临时限速*/
		for (ii = 0U; ii < pTmpCiTransInfo->logicSecNum; ii++)
		{
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;
			
			*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*紧急临时限速功能预留，默认组不存在紧急临时限速*/

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/
		}

		/*组道岔防护锁闭状态*/
		for (ii = 0U; ii < pTmpCiTransInfo->switchNum; ii++)
		{
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			wDeviceId = pTmpCiTransInfo->switchIdBuf[ii];
			cDeviceState = GetSwitchLockStatus(wDeviceId);  /*获取道岔锁闭状态*/
			if ((SWITCH_LOCK_STATUS_PROTECT == cDeviceState) || (SWITCH_LOCK_STATUS_DAP == cDeviceState))
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*有防护锁闭*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*无防护锁闭*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/
		}

		/*组道岔区段状态*/
		for (ii = 0U; ii < pTmpCiTransInfo->switchNum; ii++)
		{
			/*组道岔区段CT占用状态*/
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			wDeviceId = pTmpCiTransInfo->switchIdBuf[ii];
			wSwitchRelPhySecId = GetSwitchPhySectionId(wDeviceId);  /*获取道岔关联的物理区段ID*/
			cDeviceState = GetPhySecPreOccState(wSwitchRelPhySecId);  /*获取道岔区段CT/UT占用状态*/
			if ((LOGICSECTION_OCCUPY_UT == cDeviceState) || (LOGICSECTION_OCCUPY_NO == cDeviceState))
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*空闲*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*CT占用*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/

			/*组道岔区段UT占用状态*/
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			cDeviceState = GetPhySecPreOccState(wSwitchRelPhySecId);  /*获取道岔区段CT/UT占用状态*/
			if ((LOGICSECTION_OCCUPY_CT == cDeviceState) || (LOGICSECTION_OCCUPY_NO == cDeviceState))
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*空闲*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*UT占用*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/

			/*组道岔区段进路锁闭状态*/
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			cDeviceState = GetPhySecLockState(wSwitchRelPhySecId);  /*获取道岔区段锁闭状态*/
			wLockedRouteId = GetPhySecRLockBelongRouteId(wSwitchRelPhySecId);  /*获取道岔区段进路锁闭所属进路ID*/
			if (((PHYSICAL_SECTION_LOCK_NORMAL == cDeviceState) || (PHYSICAL_SECTION_LOCK_DELAY == cDeviceState)) && (0U != wLockedRouteId))
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*存在进路锁闭*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*不存在进路锁闭*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/

			/*组道岔区段封锁状态*/
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			cDeviceState = GetPhySecFLockState(wSwitchRelPhySecId);  /*获取道岔区段封锁状态*/
			if (PHYSICAL_SECTION_FLOCK_NO == cDeviceState)
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*未封锁*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*封锁*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/

			/*组道岔区段异常锁闭状态*/
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			cDeviceState = GetPhySecLockState(wSwitchRelPhySecId);  /*获取道岔区段锁闭状态*/
			wLockedRouteId = GetPhySecRLockBelongRouteId(wSwitchRelPhySecId);  /*获取道岔区段进路锁闭所属进路ID*/
			if ((PHYSICAL_SECTION_LOCK_EXCEPT == cDeviceState) && (0U != wLockedRouteId))
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*存在故障锁闭*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*不存在故障锁闭*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/
		}

		/*组物理区段停准停稳状态*/
		for (ii = 0U; ii < pTmpCiTransInfo->phySecNum; ii++)
		{
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			wDeviceId = pTmpCiTransInfo->phySecIdBuf[ii];
			cDeviceState = GetPhySecStopSteadyFlag(wDeviceId);  /*获取物理区段停准停稳状态*/

			if (PHYSICAL_SECTION_STOPSTEADY_YES == cDeviceState)
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*停准停稳*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*未停准停稳*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/
		}

		/*组物理区段计轴预复位状态（以物理区段为单位）*/
		for (ii = 0U; ii < pTmpCiTransInfo->phySecNum; ii++)
		{
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			wDeviceId = pTmpCiTransInfo->phySecIdBuf[ii];
			cDeviceState = GetPhySecPreResetState(wDeviceId);  /*获取物理区段计轴预复位状态*/

			if (PHYSICAL_SECTION_PRE_RESET_YES == cDeviceState)
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*预复位状态继电器吸起*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*预复位状态继电器落下*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/
		}

		/*组信号机蓝灯断丝状态*/
		for (ii = 0U; ii < pTmpCiTransInfo->signalNum; ii++)
		{
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			wDeviceId = pTmpCiTransInfo->signalIdBuf[ii];
			cDeviceState = GetSignalBlueDsBreakFlag(wDeviceId);  /*获取信号机蓝灯断丝状态*/

			if (SIGNAL_DS_BREAK_NO == cDeviceState)
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*蓝灯未断丝*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*蓝灯断丝*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/
		}		

		/*组信号机扣车状态（中心扣车和车站扣车）*/
		for (ii = 0U; ii < pTmpCiTransInfo->signalNum; ii++)
		{
			/*组信号机中心扣车状态*/
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			wDeviceId = pTmpCiTransInfo->signalIdBuf[ii];
			cDeviceState = GetSignalATSDetainFlag(wDeviceId);  /*获取信号机中心扣车状态*/
			if (SIGNAL_ATS_DETAIN_NO == cDeviceState)
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*不存在扣车*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*存在扣车*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/

			/*组信号机车站扣车状态*/
			cTempCounter = (UINT8)(wPackedInfoNum % DEV_NUM_PER_BYTE);  /*每2位存一个信息，一个字节可存4个信息*/
			cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

			cDeviceState = GetSignalLocalDetainFlag(wDeviceId);  /*获取信号机车站扣车状态*/
			if (SIGNAL_XIANDI_DETAIN_NO == cDeviceState)
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000010B << cBitOffset);  /*不存在扣车*/
			}
			else
			{
				*(pInputBuf + wPackedLen) = *(pInputBuf + wPackedLen) | (BIT_VAL_00000001B << cBitOffset);  /*存在扣车*/
			}

			if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
			{
				wPackedLen++;  /*存满一个字节，组包长度加1*/
			}
			else
			{
				/*不处理*/
			}
			wPackedInfoNum++;  /*组完一个信息，数量加1*/
		}

		if ((DEV_NUM_PER_BYTE - 1U) != cTempCounter)
		{
			wPackedLen++;  /*最后一个字节未存满4个信息，组包长度需要额外加1*/
		}
		else
		{
			/*不处理*/
		}
		
		*pItemLen = wPackedLen;
		cRetVal = CI_SUCCESS;
	}
	else
	{
		cRetVal = CI_ERROR;  /*入参非法返回失败*/
	}

	return cRetVal;
}

/*
* 功能描述：解析互联互通厂商自定义帧
* 参数说明：const UINT8 *pInputData 输入数据指针
*           UINT16 *pItemLen 该项数据在输入数据中的长度
*           const UINT8 srcCiId 源联锁ID
* 返 回 值：CI_SUCCESS 1 解析成功
*           CI_ERROR 0 解析失败
* Created By LQ 2025.05.26
*/
UINT8 ParseManufacDefPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId)
{
	UINT8 cRetVal = CI_ERROR;
	UINT8 cLocalCiId = 0U;
	const CiTransmitStruct* pCiRecptStru = NULL;
	AutoRouteDataStruct* pstrAutoRouteData = NULL;  /*自动进路动态数据结构体指针*/
	LogicSectionDataStruct* pstrLogSecData = NULL;  /*逻辑区段动态数据结构体指针*/
	SwitchDataStruct* pstrSwitchData = NULL;  /*道岔动态数据结构体指针*/
	PhysicalSectionDataStruct* pstrPhySecData = NULL;  /*物理区段动态数据结构体指针*/
	SignalDataStruct* pstrSignalData = NULL;  /*信号机动态数据结构体指针*/
	UINT8 cInfoVer = 0U;  /*信息版本*/
	UINT16 wParsedLen = 0U;	 /*指针偏移量*/
	UINT16 ii = 0U;
	UINT16 wParsedInfoNum = 0U;  /*已解析的信息数量*/
	UINT8 cTempCounter = 0U;  /*循环计数器*/
	UINT8 cBitOffset = 0U;  /*位偏移量*/
	UINT16 wDevId = 0U;  /*设备ID*/
	UINT8 cDevBelongCiId = 0U;  /*设备所属联锁*/
	UINT16 wDevIndex = 0U;  /*设备ID索引*/
	UINT8 cDevInfo = 0U;  /*设备信息*/
	UINT8 cDevState = 0U;  /*设备状态*/
	UINT8 cPhySecCtOcc = 0U;  /*物理区段CT占用状态*/
	UINT8 cPhySecUtOcc = 0U;  /*物理区段UT占用状态*/
	UINT8 cPhySecCtOrUtOcc = 0U;  /*物理区段CT/UT占用状态*/
	UINT8 cPhySecRouteLockState = 0U;  /*物理区段进路锁闭状态*/
	UINT8 cPhySecExceptLockState = 0U;  /*物理区段故障锁闭状态*/
	UINT8 cPhySecLockState = 0U;  /*物理区段锁闭状态*/
	UINT8 cPhySecFLockState = 0U;  /*物理区段封锁状态*/
	UINT16 wPhySecId = 0U;  /*物理区段ID*/
	UINT8 cSignalAtsDetainFlag = 0U;  /*信号机中心扣车标志*/
	UINT8 cSignalXiandiDetainFlag = 0U;  /*信号机车站扣车标志*/

	cLocalCiId = GetSystemParaLocalCiId();
	pCiRecptStru = GetSrcCiTransInfo(srcCiId);	/*获取源联锁对应的结构数据*/
	pstrAutoRouteData = GetAutoRouteDataStr();  /*获取自动进路动态数据结构体*/
	pstrLogSecData = GetLogicSecData();  /*获取逻辑区段动态数据结构体*/
	pstrSwitchData = GetSwitchData();  /*获取道岔动态数据结构体*/
	pstrPhySecData = GetPhySecData();  /*获取物理区段动态数据结构体*/
	pstrSignalData = GetSignalData();  /*获取信号机动态数据结构体*/
	
	if ((NULL !=pInputData) && (NULL != pItemLen) && (NULL != pCiRecptStru) && (0U != cLocalCiId) && (NULL != pstrAutoRouteData) 
		&& (NULL != pstrLogSecData) && (NULL != pstrSwitchData) && (NULL != pstrPhySecData) && (NULL != pstrSignalData))
	{
		cInfoVer = *(pInputData + wParsedLen);
		wParsedLen++;

		if (MANUFAC_DEF_INFO_VER_WL == cInfoVer)
		{
			cRetVal = CI_SUCCESS;

			/*解析自动进路信息*/
			for (ii = 0U; ii < pCiRecptStru->autoRouteNum; ii++)
			{
				cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
				cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

				wDevId = pCiRecptStru->autoRouteIdBuf[ii];
				cDevBelongCiId = GetAutoRouteBelongCiId(wDevId);  /*获取自动进路所属联锁*/
				if ((cLocalCiId != cDevBelongCiId) && (0U != cDevBelongCiId))
				{
					/*存储非本控区设备的状态*/
					wDevIndex = GetAutoRouteBufIndex(wDevId);
					pstrAutoRouteData[wDevIndex].AutoRouteId = wDevId;

					cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的自动进路信息*/
					cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
					if (BIT_VAL_00000010B == cDevState)
					{
						SetAutoRouteSetFlag(wDevId, AUTO_ROUTE_SET_YES);  /*设置自动进路已办理*/
					}
					else if (BIT_VAL_00000001B == cDevState)
					{
						SetAutoRouteSetFlag(wDevId, AUTO_ROUTE_SET_NO);  /*设置自动进路未办理*/
					}
					else
					{
						debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: AutoRoute Id[%d] State Error", srcCiId, wDevId);
						cRetVal = CI_ERROR;  /*信息异常，返回失败*/
						break;
					}
				}
				else
				{
					/*不处理*/
				}

				if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
				{
					wParsedLen++;  /*解析完一个字节，长度加1*/
				}
				else
				{
					/*不处理*/
				}
				wParsedInfoNum++;  /*解析完一个信息，数量加1*/
			}

			/*解析紧急临时限速信息*/
			if (CI_SUCCESS == cRetVal)
			{
				for (ii = 0U; ii < pCiRecptStru->logicSecNum; ii++)
				{
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

					wDevId = pCiRecptStru->logicSecIdBuf[ii];
					cDevBelongCiId = GetLogSecBelongCiId(wDevId);  /*获取逻辑区段所属联锁*/
					if ((cLocalCiId != cDevBelongCiId) && (0U != cDevBelongCiId))
					{
						/*存储非本控区设备的状态*/
						wDevIndex = GetlogSectionBufIndex(wDevId);
						pstrLogSecData[wDevIndex].LogicSectionId = wDevId;

						cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的逻辑区段紧急临时限速信息*/
						cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
						if (BIT_VAL_00000010B == cDevState)
						{
							/*TODO: 待紧急临时限速功能具备后处理*/
						}
						else if (BIT_VAL_00000001B == cDevState)
						{
							/*TODO: 待紧急临时限速功能具备后处理*/
						}
						else
						{
							debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: LogSec Id[%d] Urgent Tsr Error", srcCiId, wDevId);
							cRetVal = CI_ERROR;  /*信息异常，返回失败*/
							break;
						}
					}
					else
					{
						/*不处理*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/
				}
			}
			else
			{
				cRetVal = CI_ERROR;
			}

			/*解析道岔防护锁闭信息*/
			if (CI_SUCCESS == cRetVal)
			{
				for (ii = 0U; ii < pCiRecptStru->switchNum; ii++)
				{
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

					wDevId = pCiRecptStru->switchIdBuf[ii];
					cDevBelongCiId = GetSwitchBelongCiId(wDevId);  /*获取道岔所属联锁*/
					if ((cLocalCiId != cDevBelongCiId) && (0U != cDevBelongCiId))
					{
						/*存储非本控区设备的状态*/
						wDevIndex = GetSwitchConfigBufIndex(wDevId);
						pstrSwitchData[wDevIndex].SwitchId = wDevId;

						cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的道岔防护锁闭信息*/
						cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
						if (BIT_VAL_00000001B == cDevState)
						{
							SetHlhtCiSwitchPlockStatus(wDevId, SWITCH_LOCK_STATUS_PROTECT);  /*设置道岔有防护锁闭*/
						}
						else if (BIT_VAL_00000010B == cDevState)
						{
							SetHlhtCiSwitchPlockStatus(wDevId, SWITCH_LOCK_STATUS_NO);  /*设置道岔无防护锁闭*/
						}
						else
						{
							debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Switch Id[%d] PLock Error", srcCiId, wDevId);
							cRetVal = CI_ERROR;  /*信息异常，返回失败*/
							break;
						}

					}
					else
					{
						/*不处理*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/
				}
			}
			else
			{
				cRetVal = CI_ERROR;
			}

			/*解析道岔区段状态信息*/
			if (CI_SUCCESS == cRetVal)
			{
				for (ii = 0U; ii < pCiRecptStru->switchNum; ii++)
				{
					/*确定道岔区段CT占用状态*/
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;
					cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的道岔区段信息*/
					cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
					if (BIT_VAL_00000010B == cDevState)
					{
						cPhySecCtOcc = LOGICSECTION_OCCUPY_NO;  /*空闲*/
					}
					else if (BIT_VAL_00000001B == cDevState)
					{
						cPhySecCtOcc = LOGICSECTION_OCCUPY_CT;  /*CT占用*/
					}
					else
					{
						debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Switch Id[%d] CT Occ Error", srcCiId, pCiRecptStru->switchIdBuf[ii]);
						cRetVal = CI_ERROR;  /*信息异常，返回失败*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/

					/*确定道岔区段UT占用状态*/
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;
					cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的道岔区段信息*/
					cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
					if (BIT_VAL_00000010B == cDevState)
					{
						cPhySecUtOcc = LOGICSECTION_OCCUPY_NO;  /*空闲*/
					}
					else if (BIT_VAL_00000001B == cDevState)
					{
						cPhySecUtOcc = LOGICSECTION_OCCUPY_UT;  /*UT占用*/
					}
					else
					{
						debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Switch Id[%d] UT Occ Error", srcCiId, pCiRecptStru->switchIdBuf[ii]);
						cRetVal = CI_ERROR;  /*信息异常，返回失败*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/

					/*确定道岔区段进路锁闭状态*/
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;
					cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的道岔区段信息*/
					cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
					if (BIT_VAL_00000010B == cDevState)
					{
						cPhySecRouteLockState = PHYSICAL_SECTION_LOCK_NORMAL;  /*进路锁闭*/
					}
					else if (BIT_VAL_00000001B == cDevState)
					{
						cPhySecRouteLockState = PHYSICAL_SECTION_LOCK_NO;  /*未进路锁闭*/
					}
					else
					{
						debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Switch Id[%d] RouteLock Error", srcCiId, pCiRecptStru->switchIdBuf[ii]);
						cRetVal = CI_ERROR;  /*信息异常，返回失败*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/

					/*确定道岔区段封锁状态*/
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;
					cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的道岔区段信息*/
					cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
					if (BIT_VAL_00000010B == cDevState)
					{
						cPhySecFLockState = PHYSICAL_SECTION_FLOCK_NO;  /*未封锁*/
					}
					else if (BIT_VAL_00000001B == cDevState)
					{
						cPhySecFLockState = PHYSICAL_SECTION_FLOCK_YES;  /*封锁*/
					}
					else
					{
						debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Switch Id[%d] Flock Error", srcCiId, pCiRecptStru->switchIdBuf[ii]);
						cRetVal = CI_ERROR;  /*信息异常，返回失败*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/

					/*确定道岔区段故障锁闭状态*/
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;
					cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的道岔区段信息*/
					cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
					if (BIT_VAL_00000010B == cDevState)
					{
						cPhySecExceptLockState = PHYSICAL_SECTION_LOCK_EXCEPT;  /*异常锁闭*/
					}
					else if (BIT_VAL_00000001B == cDevState)
					{
						cPhySecExceptLockState = PHYSICAL_SECTION_LOCK_NO;  /*未异常锁闭*/
					}
					else
					{
						debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Switch Id[%d] ExceptLock Error", srcCiId, pCiRecptStru->switchIdBuf[ii]);
						cRetVal = CI_ERROR;  /*信息异常，返回失败*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/

					/*确定道岔区段最终CT/UT占用状态*/
					if ((LOGICSECTION_OCCUPY_NO == cPhySecCtOcc) && (LOGICSECTION_OCCUPY_NO == cPhySecUtOcc))
					{
						cPhySecCtOrUtOcc = LOGICSECTION_OCCUPY_NO;  /*CT/UT均空闲，则空闲*/
					}
					else if ((LOGICSECTION_OCCUPY_CT == cPhySecCtOcc) && (LOGICSECTION_OCCUPY_NO == cPhySecUtOcc))
					{
						cPhySecCtOrUtOcc = LOGICSECTION_OCCUPY_CT;  /*CT占用，UT空闲，则CT占用*/
					}
					else if ((LOGICSECTION_OCCUPY_NO == cPhySecCtOcc) && (LOGICSECTION_OCCUPY_UT == cPhySecUtOcc))
					{
						cPhySecCtOrUtOcc = LOGICSECTION_OCCUPY_UT;  /*CT空闲，UT占用，则UT占用*/
					}
					else
					{
						debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Switch Id[%d] CT And UT Diff", srcCiId, pCiRecptStru->switchIdBuf[ii]);
						cRetVal = CI_ERROR;  /*信息异常，返回失败*/
					}

					/*确定道岔区段最终锁闭状态*/
					if ((PHYSICAL_SECTION_LOCK_NO == cPhySecRouteLockState) && (PHYSICAL_SECTION_LOCK_NO == cPhySecExceptLockState))
					{
						cPhySecLockState = PHYSICAL_SECTION_LOCK_NO;  /*进路锁闭和故障锁闭均未锁闭，则未锁闭*/
					}
					else if ((PHYSICAL_SECTION_LOCK_NORMAL == cPhySecRouteLockState) && (PHYSICAL_SECTION_LOCK_NO == cPhySecExceptLockState))
					{
						cPhySecLockState = PHYSICAL_SECTION_LOCK_NORMAL;  /*进路锁闭为正常锁闭，故障锁闭为未锁闭，则正常锁闭*/
					}
					else if ((PHYSICAL_SECTION_LOCK_NO == cPhySecRouteLockState) && (PHYSICAL_SECTION_LOCK_EXCEPT == cPhySecExceptLockState))
					{
						cPhySecLockState = PHYSICAL_SECTION_LOCK_EXCEPT;  /*进路锁闭为未锁闭，故障锁闭为异常锁闭，则异常锁闭*/
					}
					else
					{
						debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Switch Id[%d] Lock Diff Error", srcCiId, pCiRecptStru->switchIdBuf[ii]);
						cRetVal = CI_ERROR;  /*信息异常，返回失败*/
					}

					if (CI_SUCCESS == cRetVal)
					{
						wDevId = pCiRecptStru->switchIdBuf[ii];
						wPhySecId = GetSwitchPhySectionId(wDevId);
						cDevBelongCiId = GetPhySecBelongCiId(wPhySecId);  /*获取道岔区段所属联锁*/
						if ((cLocalCiId != cDevBelongCiId) && (0U != cDevBelongCiId))
						{
							/*存储非本控区设备的状态*/
							wDevIndex = GetPhySecConfigBufIndex(wDevId);
							pstrPhySecData[wDevIndex].PhysicalSectionId = wPhySecId;

							/*暂时预留*/
#if 0
							SetPhySecLockStateHlht(wPhySecId, cPhySecLockState);  /*设置物理区段锁闭状态*/
							SetPhySecFLockState(wPhySecId, cPhySecFLockState);  /*设置物理区段封锁状态*/
							SetHlhtPhySecCtOrUtOccState(wPhySecId, cPhySecCtOrUtOcc);  /*设置物理区段CT/UT占用状态*/
#endif
						}
						else
						{
							/*不处理*/
						}
					}
					else
					{
						cRetVal = CI_ERROR;
						break;
					}
				}
			}
			else
			{
				cRetVal = CI_ERROR;
			}

			/*解析物理区段停准停稳信息*/
			if (CI_SUCCESS == cRetVal)
			{
				for (ii = 0U; ii < pCiRecptStru->phySecNum; ii++)
				{
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

					wDevId = pCiRecptStru->phySecIdBuf[ii];
					cDevBelongCiId = GetPhySecBelongCiId(wDevId);  /*获取物理区段所属联锁*/
					if ((cLocalCiId != cDevBelongCiId) && (0U != cDevBelongCiId))
					{
						/*存储非本控区设备的状态*/
						wDevIndex = GetPhySecConfigBufIndex(wDevId);
						pstrPhySecData[wDevIndex].PhysicalSectionId = wDevId;

						cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的物理区段停准停稳信息*/
						cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
						if (BIT_VAL_00000010B == cDevState)
						{
							SetPhySecStopSteadyFlag(wDevId, PHYSICAL_SECTION_STOPSTEADY_YES);  /*设置物理区段停准停稳*/
						}
						else if (BIT_VAL_00000001B == cDevState)
						{
							SetPhySecStopSteadyFlag(wDevId, PHYSICAL_SECTION_STOPSTEADY_NO);  /*设置物理区段未停准停稳*/
						}
						else
						{
							debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: PhySec Id[%d] Stop Steady Error", srcCiId, wDevId);
							cRetVal = CI_ERROR;  /*信息异常，返回失败*/
							break;
						}
					}
					else
					{
						/*不处理*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/
				}
			}
			else
			{
				cRetVal = CI_ERROR;
			}

			/*解析物理区段计轴预复位状态信息*/
			if (CI_SUCCESS == cRetVal)
			{
				for (ii = 0U; ii < pCiRecptStru->phySecNum; ii++)
				{
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

					wDevId = pCiRecptStru->phySecIdBuf[ii];
					cDevBelongCiId = GetPhySecBelongCiId(wDevId);  /*获取物理区段所属联锁*/
					if ((cLocalCiId != cDevBelongCiId) && (0U != cDevBelongCiId))
					{
						/*存储非本控区设备的状态*/
						wDevIndex = GetPhySecConfigBufIndex(wDevId);
						pstrPhySecData[wDevIndex].PhysicalSectionId = wDevId;

						cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的物理区段计轴预复位状态信息*/
						cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
						if (BIT_VAL_00000010B == cDevState)
						{
							SetPhySecPreResetState(wDevId, PHYSICAL_SECTION_PRE_RESET_YES);  /*设置物理区段计轴预复位状态有效*/
						}
						else if (BIT_VAL_00000001B == cDevState)
						{
							SetPhySecPreResetState(wDevId, PHYSICAL_SECTION_PRE_RESET_NO);  /*设置物理区段计轴预复位状态无效*/
						}
						else
						{
							debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: PhySec Id[%d] PreReset Error", srcCiId, wDevId);
							cRetVal = CI_ERROR;  /*信息异常，返回失败*/
							break;
						}
					}
					else
					{
						/*不处理*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/
				}
			}
			else
			{
				cRetVal = CI_ERROR;
			}

			/*解析信号机蓝灯断丝信息*/
			if (CI_SUCCESS == cRetVal)
			{
				for (ii = 0U; ii < pCiRecptStru->signalNum; ii++)
				{
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;

					wDevId = pCiRecptStru->signalIdBuf[ii];
					cDevBelongCiId = GetSignalBelongCiId(wDevId);  /*获取信号机所属联锁*/
					if ((cLocalCiId != cDevBelongCiId) && (0U != cDevBelongCiId))
					{
						/*存储非本控区设备的状态*/
						wDevIndex = GetSignalConfigBufIndex(wDevId);
						pstrSignalData[wDevIndex].SignalId = wDevId;

						cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的信号机蓝灯断丝信息*/
						cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;
						if (BIT_VAL_00000010B == cDevState)
						{
							SetHlhtCiSignalBlueDsBreakFlag(wDevId, SIGNAL_DS_BREAK_NO);  /*设置信号机未蓝灯断丝*/
						}
						else if (BIT_VAL_00000001B == cDevState)
						{
							SetHlhtCiSignalBlueDsBreakFlag(wDevId, SIGNAL_DS_BREAK_YES);  /*设置信号机蓝灯断丝*/
						}
						else
						{
							debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Signal Id[%d] BlueDengsi Error", srcCiId, wDevId);
							cRetVal = CI_ERROR;  /*信息异常，返回失败*/
							break;
						}
					}
					else
					{
						/*不处理*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/
				}
			}
			else
			{
				cRetVal = CI_ERROR;
			}

			/*解析信号机扣车信息（中心扣车和车站扣车）*/
			if (CI_SUCCESS == cRetVal)
			{
				for (ii = 0U; ii < pCiRecptStru->signalNum; ii++)
				{
					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;
					cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的信号机扣车信息*/
					cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;

					/*确定中心扣车状态*/
					if (BIT_VAL_00000010B == cDevState)
					{
						cSignalAtsDetainFlag = SIGNAL_DETAIN_ATS_NO;  /*不存在中心扣车*/
					}
					else if (BIT_VAL_00000001B == cDevState)
					{
						cSignalAtsDetainFlag = SIGNAL_DETAIN_ATS;  /*存在中心扣车*/
					}
					else
					{
						debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Signal Id[%d] Ats Detain Error", srcCiId, pCiRecptStru->signalIdBuf[ii]);
						cRetVal = CI_ERROR;  /*信息异常，返回失败*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/

					cTempCounter = (UINT8)(wParsedInfoNum % DEV_NUM_PER_BYTE);  /*每2位一个信息，一个字节有4个信息*/
					cBitOffset = cTempCounter * BIT_NUM_PER_DEV;
					cDevInfo = *(pInputData + wParsedLen);  /*该字节存储的信号机扣车信息*/
					cDevState = (cDevInfo >> cBitOffset) & BIT_MASK_00000011B;

					/*确定车站扣车状态*/
					if (BIT_VAL_00000010B == cDevState)
					{
						cSignalXiandiDetainFlag = SIGNAL_DETAIN_XIANDI_NO;  /*不存在车站扣车*/
					}
					else if (BIT_VAL_00000001B == cDevState)
					{
						cSignalXiandiDetainFlag = SIGNAL_DETAIN_XIANDI;  /*存在车站扣车*/
					}
					else
					{
						debug_infor_printf((const)"\nHlht Ci Id[%d] Parse ManufacDef Error: Signal Id[%d] Xiandi Detain Error", srcCiId, pCiRecptStru->signalIdBuf[ii]);
						cRetVal = CI_ERROR;  /*信息异常，返回失败*/
					}

					if ((DEV_NUM_PER_BYTE - 1U) == cTempCounter)
					{
						wParsedLen++;  /*解析完一个字节，长度加1*/
					}
					else
					{
						/*不处理*/
					}
					wParsedInfoNum++;  /*解析完一个信息，数量加1*/

					if (CI_SUCCESS == cRetVal)
					{
						wDevId = pCiRecptStru->signalIdBuf[ii];
						cDevBelongCiId = GetSignalBelongCiId(wDevId);  /*获取信号机所属联锁*/
						if ((cLocalCiId != cDevBelongCiId) && (0U != cDevBelongCiId))
						{
							/*存储非本控区设备的状态*/
							wDevIndex = GetSignalConfigBufIndex(wDevId);
							pstrSignalData[wDevIndex].SignalId = wDevId;
							SetSignalDetainFlag(wDevId, cSignalAtsDetainFlag);  /*设置信号机有中心扣车*/
							SetSignalDetainFlag(wDevId, cSignalXiandiDetainFlag);  /*设置信号机有中心扣车*/
						}
						else
						{
							/*不处理*/
						}
					}
					else
					{
						cRetVal = CI_ERROR;
						break;
					}
				}
			}
			else
			{
				cRetVal = CI_ERROR;
			}
					
			if (CI_SUCCESS == cRetVal)
			{
				if ((DEV_NUM_PER_BYTE - 1U) != cTempCounter)
				{
					wParsedLen++;  /*最后一个字节未存满4个信息，解析长度需要额外加1*/
				}
				else
				{
					/*不处理*/
				}

				*pItemLen = wParsedLen;
			}
			else
			{
				cRetVal = CI_ERROR;
			}
		}
		else
		{
			/*厂商自定义信息版本不一致，解析失败*/
			cRetVal = CI_ERROR;
			debug_infor_printf((const)"\nHlht Ci Id[%d] Parse Error: ManufacDef Info Ver Is Diff.", srcCiId);
		}
	}
	else
	{
		cRetVal = CI_ERROR;  /*入参非法获取数据失败，返回失败*/
	}	

	return cRetVal;
}