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



#include "ParsePackVobcData.h"
#include "../HLHTMsgHead/HLHTHeadContexManage.h"
#include "../DataManage/DeviceConfigDataManage.h"
#include "../HLHTMsgHead/HLHTCommonDataPacketHead.h"
#include "CommonMemory.h"
#include "../QueryFiles/dquCIInterFace.h"
#include "../Train/TrainDefine.h"
#include "../Train/TrainDataManage.h"
#include "EnvelopeManageAPI.h"
#include "LogicSectionDataManage.h"
#include "NonAutoReturnConfigDataManage.h"
#include "LogicSectionConfigDataManage.h"
#include "WLBrakeDataManage.h"
#include "../AxisSort/AxisSort_api.h"

/*
* 功能描述： 拷贝VOBC发送给CI的信息结构体
* 参数说明： const VobcToCiDataStruct* srcMsg:被复制的VOBC发送给CI的信息结构体指针
			 VobcToCiDataStruct* dstMsg:目标VOBC发送给CI的信息结构体的指针
* 返回值  ： 无     
*/
static void CopyVobcToCiMsg(const VobcToCiDataStruct* srcMsg,VobcToCiDataStruct* dstMsg);

/*
* 功能描述： 解析处理HLHT VOBC单帧数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            const UINT8 systemId, 源设备ID
*            VobcToCiDataStru vobcToci数据结构体指针
*			 UINT8* saveGalHead,通用报文头是否保留,1:保留，0:不保留
*            const UINT16 logId，互联互通4IP VOBC的1端或2端标识  
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功
*/
static UINT8 ParseVobcToCiDataFrameHLHT(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* vobcToCiDataStru, UINT8* saveGalHead,const UINT16 logId);

/*
* 功能描述： 解析处理FAO VOBC单帧数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            const UINT8 systemId, 源设备ID
*            VobcToCiDataStru vobcToci数据结构体指针
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功      
*/
static UINT8 ParseVobcToCiDataFrameFAO(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId,VobcToCiDataStruct* vobcToCiDataStru);

/*
* 功能描述： 组互联互通VOBC数据
* 参数说明： 
*            VobcToCiDataStruct *vobcToCiDataStru VOBC数据结构体指针
* 返回值  ： 0:组数据失败
*			 1:组数据成功      
*/
static UINT8 PackCiToVobcDataHLHT(VobcToCiDataStruct *vobcToCiDataStru);

/*
* 功能描述： 组FAOVOBC数据
* 参数说明： 
*            VobcToCiDataStruct *vobcToCiDataStru VOBC数据结构体指针
* 返回值  ： 0:组数据失败
*			 1:组数据成功      
*/
static UINT8 PackCiToVobcDataFAO(VobcToCiDataStruct *vobcToCiDataStru);

/*
* 功能描述： 组互联互通CI->VOBC心跳帧
* 参数说明： 
*            const UINT8 vobcId 目标VOBC ID
*            const UINT8 logId 目标VOBC 的逻辑ID（1端或2端）
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
static UINT8 PackCiToVobcDataHLHTHeart(const UINT8 vobcId, const UINT16 logId);

/*
* 功能描述： 解析处理FAO+HLHT VOBC单帧数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            const UINT8 systemId, 源设备ID
*            VobcToCiDataStru vobcToci数据结构体指针
*			 UINT8* saveGalHead,通用报文头是否保留,1:保留，0:不保留
*            const UINT16 logId，互联互通4IP VOBC的1端或2端标识  
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功
*/
static UINT8 ParseVobcToCiDataFrameFAOHLHT(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* vobcToCiDataStru, UINT8* saveGalHead,const UINT16 logId);

/*
* 功能描述： 解析处理车车单帧数据
* 参数说明： const UINT8* pDataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            const UINT8 systemId, 源设备ID
*            pstVobcToCiDataStru vobcToci数据结构体指针
*			 UINT8* pSaveGalHead,通用报文头是否保留,1:保留，0:不保留
*            const UINT16 logId，互联互通4IP VOBC的1端或2端标识
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功
*/
static UINT8 ParseIvocToCiDataFrameCC(const UINT8* pDataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* pstVobcToCiDataStru, UINT8* pSaveGalHead, const UINT16 logId);
/*
* 功能描述： 解析处理CC IVOC命令信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            VobcToCiDataStru vobcToci数据结构体指针
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功
*/
static UINT8 ParseIvocToCiCmdCC(const UINT8* pDataBuf,UINT16 * wDataLength, VobcToCiDataStruct* pstVobcToCiDataStru);
/*
* 功能描述： 组(FAO+HLHT)VOBC数据
* 参数说明： VobcToCiDataStruct *vobcToCiDataStru,VOBC给ci数据结构体
* 返回值  ： 0:组数据失败
*			 1:组数据成功      
*/
static UINT8 PackCiToVobcDataFAOHLHT(VobcToCiDataStruct *vobcToCiDataStru);

/*
* 功能描述： 组车车Ivoc数据
* 参数说明： QueueStruct* CiToVobcDataQueue, 组包发送队列地址
*			 VobcToCiDataStruct *vobcToCiDataStru Vobc信息结构体
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
static UINT8 PackCiToIvocDataCC(VobcToCiDataStruct *pstVobcToCiDataStru);

/*
* 功能描述： 组车车备用通道Ivoc数据
* 参数说明： QueueStruct* CiToVobcDataQueue, 组包发送队列地址
*			 VobcBackUpToCiDataStruct *pstVobcBackUpToCiDataStru Vobc备用通道信息结构体
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
static UINT8 PackCiToIvocBackUpDataCC(VobcBackUpToCiDataStruct *pstVobcBackUpToCiDataStru);

/*
* 功能描述： 组包Ci到Ivoc道岔状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocSwitchInfo(UINT8* pDataBuf, UINT16  *wDataLength);

/*
* 功能描述： 组包Ci到Ivoc屏蔽门状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocPsdInfo(UINT8* pDataBuf, UINT16  *wDataLength);

/*
* 功能描述： 组包Ci到Ivoc紧急按钮状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocEsbInfo(UINT8* pDataBuf, UINT16  *wDataLength);

/*
* 功能描述： 组包Ci到Ivoc无人折返按钮状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocARInfo(UINT8* pDataBuf, UINT16  *wDataLength);
/*
* 功能描述： 组包Ci到IvocSpks状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocSpksInfo(UINT8* pDataBuf, UINT16  *wDataLength);

/*
* 功能描述： 组包Ci到Ivoc车库门状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocGaragedoorInfo(UINT8* pDataBuf, UINT16  *wDataLength);

/*
* 功能描述： 组包Ci到Ivoc防淹门状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId,	列车ID
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocFloodGateInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId);

/*
* 功能描述： 组包Ci到Ivoc封锁状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocFLockInfo(UINT8* pDataBuf, UINT16  *wDataLength);

/*
* 功能描述： 组包Ci到Ivoc通信车状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocCommTrainInfo(UINT8* pDataBuf, UINT16  *wDataLength);

/*
* 功能描述： 组包Ci到Ivoc故障车状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocFaultTrainInfo(UINT8* pDataBuf, UINT16  *wDataLength);

/*
* 功能描述： 组包Ci到Ivoc休眠车状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocSleepTrainInfo(UINT8* pDataBuf, UINT16  *wDataLength);

/*
* 功能描述： 组包Ci到Ivoc临时限速状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocTsrInfo(UINT8* pDataBuf, UINT16  *wDataLength);

/*
* 功能描述： 组包Ci到Ivoc逻辑区段状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocLgcSgmtInfo(UINT8* pDataBuf, UINT16  *wDataLength, UINT16 wVobcId);
/*
* 功能描述： 组包Ci到Ivoc 请求与回复状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocReqAndReplyInfo(UINT8* pDataBuf, UINT16  *wDataLength, UINT16 wTrnId);

/*
* 功能描述： 洗车请求信息接口校验
* 参数说明： 入参：UINT8 Data 洗车请求信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
*/
static UINT8 WashTrainRequestCheck(UINT8 Data);
/*
* 功能描述： 洗车停稳1信息接口校验
* 参数说明： 入参：UINT8 Data 洗车停稳1信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
*/
static UINT8 HeadWashStopSteadyInfoCheck(UINT8 Data);
/*
* 功能描述： 暂停洗车请求信息接口校验
* 参数说明： 入参：UINT8 Data 暂停洗车请求信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
*/
static UINT8 WashPauseRequestCheck(UINT8 Data);
/*
* 功能描述： 洗车停稳2信息接口校验
* 参数说明： 入参：UINT8 Data 洗车停稳2信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
*/
static UINT8 TailWashStopSteadyInfoCheck(UINT8 Data);
/*
* 功能描述： 通过洗车机请求信息接口校验
* 参数说明： 入参：UINT8 Data 通过洗车机请求信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
*/
static UINT8 PassWashMachineRequestCheck(UINT8 Data);

/*
* 功能描述： 组包Ci到Ivoc 资源对顶信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
* by cgh 20230802
*/
static UINT8 PackCiToIvocReqAlignmentInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrnId);

/*
* 功能描述： 组包Ci到Ivoc申请解锁保护区段信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocUnlockOverlapInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrnId);

/*
* 功能描述： 洗车机工作模式设置信息接口校验
* 参数说明： 入参：UINT8 Data 洗车机工作模式设置信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
* by cgh 20231107
*/
static UINT8 WashMachineWorkModeCheck(UINT8 Data);

/*
* 功能描述： 组包Ci到Ivoc洗车机信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
*			 const UINT16 wTrnId VOBC ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
* by cgh 20231110
*/
static UINT8 PackCiToIvocWashMachineInfo(UINT8* pDataBuf, UINT16* wDataLength, const UINT16 wTrnId);

/*
* 功能描述： 组包Ci到Ivoc区间雨雪与紧急制动信息
* 参数说明： UINT8* pDataBuf 数据缓冲区
*            UINT16 *pDataLength 数据长度(输出参数)
*            UINT16 wTrainId 列车ID（不带0x14）
* 返回值  ： CI_ERROR 0 失败
*			 CI_SUCCESS 1 成功
* Created By LQ 2023.11.10
*/
static UINT8 PackCiToIvocSnowAndUrgentInfo(UINT8* pDataBuf, UINT16* pDataLength, UINT16 wTrainId);

/*
* 功能描述： 组包Ci到VOBC后备通道信号机状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
* by cgh 20240607
*/
static UINT8 PackCiToVobcSigInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId);

/*
* 功能描述： 组CI到VOBC后备状态数据
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 VobcToCiDataStruct *pstVobcToCiDataStru VOBC到CI数据
* 返回值  ： 0:组数据失败
*			 1:组数据成功
* by cgh 20240704
*/
static UINT8 PackCiToVobcBackUpStateData(UINT8* pDataBuf, UINT16* wDataLength, VobcToCiDataStruct* pstVobcToCiDataStru);

/*
* 功能描述：组包Ci到Ivoc的ITE切除状态
* 参数说明：const UINT8* dataBuf 数据缓冲区（出参）
*           const UINT16 *dataLength 数据长度（出参）
* 返 回 值：CI_ERROR 0 失败
*			CI_SUCCESS 1 成功
* Created By LQ 2024.07.12
*/
static UINT8 PackCiToIvocIteCutInfo(UINT8* pDataBuf, UINT16* wDataLength);


/*
* 功能描述：组包Ci到Ivoc的最远未占用逻辑区段
	* 参数说明： UINT8* dataBuf, 数据缓冲区
	*            UINT16 *dataLength, 数据长度 输出参数
	*			 UINT16 wTrainId 列车ID
* 返 回 值：CI_ERROR 0 失败
*			CI_SUCCESS 1 成功
* Created By LC
*/
static UINT8 PackCiToIvocFarNoOccuLogInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId);

/*
* 功能描述：组包Ci到Ivoc的NVRAM位置监督状态
* 参数说明：const UINT8* dataBuf 数据缓冲区（出参）
*           const UINT16 *dataLength 数据长度（出参）
*           const UINT16 wTrainId 列车ID
* 返 回 值：CI_ERROR 0 失败
*			CI_SUCCESS 1 成功
* Created By LQ 2024.08.19
*/
static UINT8 PackCiToIvocPosMonitorInfo(UINT8* pDataBuf, UINT16* wDataLength, const UINT16 wTrainId);


/*解析组包使用*/
VobcToCiDataStruct VobcToCiDataStru[VOBC_TO_CI_SUM_MAX] = {0u};/*与联锁通信的Vobc信息*/

VobcBackUpToCiDataStruct VobcBackUpToCiDataStru[VOBC_BACKUP_TO_CI_SUM_MAX] = { 0u };/*使用后备模式与联锁通信的Vobc信息*/

UINT8 VobcToCiSum = 0u;/*与联锁通信的Vobc数目*/

 
/*按车站编号映射
  即stationId == 1,则映射到platformToCiDataStru[1]中
*/
extern PlatformToCiDataStruct platformToCiDataStru[PLATFORM_TO_CI_SUM_MAX];

/*屏蔽门在PlatformToCiDataStruct结构中的位置:Psd映射为行，Psd所处车站映射为第一列，所处PsdToCiDataStruct位置映射为第2列
  即屏蔽门1在platformToCiDataStru中的位置为:所属车站为PsdPlatformIndex[1][0] ,在屏蔽门的结构中位置为PsdPlatformIndex[1][1]
*/
extern UINT8 PsdPlatformIndex[PSD_SUM_MAX][2]; 


/*
* 功能描述： 解析处理VOBC单帧数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            const UINT8 systemId, 源设备ID
*            const UINT16 logId，互联互通4IP VOBC的1端或2端标识  
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功      
*/
UINT8 ParseVobcToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId,const UINT16 logId)
{					
	UINT8 ii = 0u;                                /*索引管理*/
	UINT8 retVal = CI_SUCCESS;
	UINT8 lineIdentity = 0u;						 /*线路标识*/
	UINT8 galHeadSaved = 0u;
	VobcToCiDataStruct parseCheckVobcStruc = { 0 };
	UINT8 chFind = CI_ERROR;
	lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*获取线路标识*/
	/*能处理的VOBC数量判断*/
	if (VobcToCiSum >= VOBC_TO_CI_SUM_MAX)
	{
		retVal = CI_ERROR;
	}

	if (CI_SUCCESS==retVal)
	{
		if (LINE_HLHT == lineIdentity)/*互联互通线路*/
		{
			retVal = ParseVobcToCiDataFrameHLHT(dataBuf, dataLength, systemId, &parseCheckVobcStruc, &galHeadSaved,logId);
		}
		else if (LINE_FAO == lineIdentity)/*FAO线路*/
		{
			retVal = ParseVobcToCiDataFrameFAO(dataBuf,dataLength,systemId,&parseCheckVobcStruc);
		}
		else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity)||(LINE_FAOHLHT_ONESELFSECOND == lineIdentity))/*FAO+HLHT线路*/
		{
			retVal = ParseVobcToCiDataFrameFAOHLHT(dataBuf, dataLength, systemId, &parseCheckVobcStruc, &galHeadSaved,logId);
		}
		else if (LINE_CC == lineIdentity)/*车车线路*/
		{
			retVal = ParseIvocToCiDataFrameCC(dataBuf, dataLength, systemId, &parseCheckVobcStruc, &galHeadSaved, logId);
		}
		else
		{
			retVal = CI_ERROR;
		}

		if(CI_SUCCESS == retVal)
		{
			/*命令去重*/
			for (ii = 0u; ii < VobcToCiSum; ii++)
			{
				if (VobcToCiDataStru[ii].VobcId == parseCheckVobcStruc.VobcId)
				{/*列车号与刚添加的列车号一致*/
					CopyVobcToCiMsg(&parseCheckVobcStruc,&(VobcToCiDataStru[ii]));					
					chFind = CI_SUCCESS;
					break;
				}
			}
			if (CI_ERROR == chFind)
			{
				(void)CommonMemSet(&(VobcToCiDataStru[VobcToCiSum]), (UINT32)sizeof(VobcToCiDataStruct), 0U, (UINT32)sizeof(VobcToCiDataStruct));/*清内存，防止脏数据*/
				CopyVobcToCiMsg(&parseCheckVobcStruc, &(VobcToCiDataStru[VobcToCiSum]));
				VobcToCiSum++;
			}
			else
			{
				; /*已存在并更新*/
			}
		}
		else
		{
			if ((LINE_HLHT == lineIdentity) || (LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) 
				|| (LINE_FAOHLHT_ONESELFSECOND == lineIdentity) || (LINE_CC == lineIdentity))
			{

				/*如果通用头已经保存了，则不执行清除通用头操作，否则，出错后也将清除通用头*/
				if (0u == galHeadSaved)
				{
					ClearHlhtHeadCtx(CI_SYSTEM_TYPE_VOBC, systemId);
				}
				else
				{
					;
				}
			}
			else
			{
				; /*无操作*/
			}
		}
	}

	return retVal;
}

/*
* 功能描述： 解析处理VOBC备用通道单帧数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            const UINT8 systemId, 源设备ID
*            const UINT16 logId，互联互通4IP VOBC的1端或2端标识
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功
*/
UINT8 ParseVobcBackUpToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, const UINT16 logId)
{
	UINT8 retVal = CI_SUCCESS;
	UINT8 VobcID = systemId;	/*使用车ID对应到结构体ID，不会超过255*/
	UINT32 errCode = 0U;
	UINT32 curntCycleNo = 0U;					/*当前周期号*/
	UINT8 ii = 0U;                                /*索引管理*/
	UINT8 jj = 0U;
	UINT8 headRet = HLHT_HEAD_ERROR;/*互联互通检查结果*/
	UINT16 vobcName = 0U;						/*VOBC设备名称：类型+ID*/
	UINT16 ciName = 0U;							/*联锁设备名称：类型+ID*/
	UINT8 localCiId = GetSystemParaLocalCiId();/*联锁ID*/
	UINT16 appInfoType = 0U;						 /*应用信息类型*/
	UINT8 trainDirection = 0U;					/*列车方向*/
	UINT8 trainLevel = 0U;				/*列车运行级别*/
	HLHTGALInfoStruct vobvBackupGalHead = { 0U };   /*与互联互通同格式的通用报文头*/
	VobcBackUpToCiDataStruct VobcBackUpTemp;
	VobcBackUpToCiDataStruct* vobcBackupToCiCur = &VobcBackUpTemp;
	VobcBackUpToCiDataStruct* vobcBackup = &VobcBackUpToCiDataStru[VobcID];
	UINT8 ci_vobcPrtclVersion = 0U;
	INT32 vobcInfoRemainValidiy = 0; /*校验时效性*/
	UINT16 maxHeadLink = 0U;		/*最大前端link*/
	UINT32 maxHeadOff = 0U;		/*最大前端lInk偏移*/
	UINT16 minTailLink = 0U;		/*最小后端link*/
	UINT32 minTailOff = 0U;      /*最小后端link偏移*/
	UINT8 psdSum = 0U;
	UINT16 psdId = 0U;				     /*PSD的ID*/
	UINT32 psdIdIntConnt = 0U;                    /*互联互通PSD的ID*/
	UINT8 psdCmdCode = 0U;       /*站台门开门码*/                
	UINT8 cmdType = 0U; /*屏蔽门控制信息，0x55开，0xAA关*/
	UINT8 funRet = 0U;
	UINT8 galSaveTag = 0U;  /*互联互通头保存标志*/
	UINT32 hlhtStationId = 0U;   /*获取互联互通站台ID*/
	UINT32 transmitBadEnsureTime = 0U;   /*通信失效时间*/
	UINT16 TrainSignalId = 0U;
	UINT8 errorNum = 0U;
	UINT32 dwHlhtNs = 0U;
	UINT16 wHeadTrainId = 0U;/*列车前车ID*/
	UINT16 wTrainRelLgcId = 0U;/*列车使用端*/
	UINT8 chNvramPosFlag = 0U;/*NVRAM位置标识*/
	UINT8 chStopSteayFlag = 0U; /*停准停稳状态*/
	UINT32 dwTrackSecId = 0U; /*停准轨道区段Id*/

	(void)memset(vobcBackupToCiCur, 0, sizeof(VobcBackUpToCiDataStruct));/*清内存，防止脏数据*/

	/*参数校验*/
	if ((NULL == dataBuf)
		|| (NULL == vobcBackupToCiCur)
		|| (NULL == vobcBackup)
		|| (CI_IVOC_PACKET_LENGTH_MAX< dataLength))
	{
		retVal = CI_ERROR;
	}
	else
	{
		; /*不处理*/
	}

	if (CI_SUCCESS == retVal)
	{
		ci_vobcPrtclVersion = GetVersionOfVOBCToCI();
		vobcName = (CI_SYSTEM_TYPE_VOBC)* 256U + systemId;
		ciName = (CI_SYSTEM_TYPE_CI)* 256U + localCiId;
		/*解析通用消息包头*/
		vobvBackupGalHead.devInterInfoType = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		vobvBackupGalHead.sourceId = LongFromChar(&dataBuf[ii]);
		ii += 4U;
		vobvBackupGalHead.destId = LongFromChar(&dataBuf[ii]);
		ii += 4U;
		vobvBackupGalHead.emapVerCrc = LongFromChar(&dataBuf[ii]);
		ii += 4U;
		vobvBackupGalHead.crntOwnMsgSN = LongFromChar(&dataBuf[ii]);
		ii += 4U;
		vobvBackupGalHead.comPeriod = ShortFromChar(&dataBuf[ii]);
		ii += 2U;
		vobvBackupGalHead.recvOppMsgSN = LongFromChar(&dataBuf[ii]);
		ii += 4U;
		vobvBackupGalHead.preOwnMsgSN = LongFromChar(&dataBuf[ii]);
		ii += 4U;
		vobvBackupGalHead.prtclVer = dataBuf[ii++];
		vobvBackupGalHead.totalDataLen = ShortFromChar(&dataBuf[ii]);
		ii += 2U;

		curntCycleNo = Get2oo2CurCycleNum();


		/*通用消息包头校验通过 && 报文生存时间有效  才继续解析其他信息*/
		headRet = HLHTRecvCommonPacketHeadCheck(vobcName, ciName, CI_VOBC_BACKUP_INTERFACE_INFOTYPE, CI_IVOC_BACKUP_PRTCL_VER, &vobvBackupGalHead, &errCode, logId, CI_SYSTEM_TYPE_VOBC);
		transmitBadEnsureTime = 2U*GetCiAndVobcTransBadEnsureTime();
		debug_infor_printf((const)"\nVOBC_BACK_UP %d GAL Check Result:%d errCode:%d", systemId, headRet, errCode);	/*0x55正确，0xaa错误，0x33初始通信帧*/
		if (HLHT_HEAD_SUCCESS == headRet)
		{
			/*计算消息的时效性*/
			vobcInfoRemainValidiy = HLHTCommonMsgRemainingValidity(transmitBadEnsureTime, curntCycleNo, GetSystemParaAppCycleTime(), vobvBackupGalHead.recvOppMsgSN, vobvBackupGalHead.crntOwnMsgSN, vobvBackupGalHead.preOwnMsgSN, vobvBackupGalHead.comPeriod);
			/*有效*/
			if (0 < vobcInfoRemainValidiy)
			{
				/*解析应用数据*/
				/*更新接收到上一条消息时的本方周期号*/
				ii += 2U;/*跳过应用报文长度2字节*/

				appInfoType = ShortFromChar(&dataBuf[ii]);/*应用信息类型，0x0308代表VOBC备用通道给RC/CI*/
				ii += 2U;
				vobcBackupToCiCur->appInfoType = appInfoType;
				vobcBackupToCiCur->VobcId = systemId;
				vobcBackupToCiCur->vobcLogId = logId;/*存储VOBC的逻辑ID，1端或2端*/
#if 0
				vobcToCiDataStru->vobcInfoStartCycNum = Get2oo2CurCycleNum();/*CI接收到VOBC发送的信息起始周期*/
#endif
				ii += 2U;/*跳过两个预留字节*/

				if (VOBC_CI_INFO_TYPE_BACKUP == appInfoType)
				{/*只有当VOBC发送CI的信息类型是屏蔽门控制报文时才继续解析报文信息*/

					/*与VOBC后备模式通信周期号*/
					vobcBackupToCiCur->ComStartCycle= curntCycleNo;

				   /*列车运行控制级别有效性校验*/
					trainLevel =  dataBuf[ii++];
					if ((TRAIN_LEVEL_BACKUP_LIANXU == trainLevel) || (TRAIN_LEVEL_BACKUP_BLOCK == trainLevel) || (TRAIN_LEVEL_BACKUP_CI == trainLevel)
						|| (TRAIN_LEVEL_BACKUP_ABL == trainLevel) || (TRAIN_LEVEL_BACKUP_UNKNOWN == trainLevel) )
					{
						/*01:连续510=CBTC/VBTC；02:点式510=ITC；03:联锁510=IL/车车项目UR  */
						vobcBackupToCiCur->chTrainLevel = trainLevel;
					}
					else
					{
						retVal = CI_ERROR;
						debug_infor_printf((const)"\nVOBC_BACK_UP %d  trainLevel ERROR：%d", systemId, trainLevel);
					}

					/*列车运行方向判断*/
					trainDirection = dataBuf[ii++];
					if ((TRAIN_DIR_UP == trainDirection) || (TRAIN_DIR_DOWN == trainDirection) || (TRAIN_DIR_DEF == trainDirection))
					{
						vobcBackupToCiCur->trainDirection = trainDirection;
					}
					else
					{
						retVal = CI_ERROR;
						debug_infor_printf((const)"\nVOBC_BACK_UP %d  trainDirection ERROR：%d", systemId, trainDirection);	
					}

					/*读取包络相关数值并校验*/
					if (CI_SUCCESS == retVal)
					{
#if 0
						hlhtStationId = LongFromChar(&dataBuf[ii]);
						ii += 4U;
						vobcBackupToCiCur->wNextStation = 0u;
						(void)dquQueryInDevIndex(QFUN_IDMAP_STATION_ID, hlhtStationId, &vobcBackupToCiCur->wNextStation);
#endif
						maxHeadLink = ShortFromChar(&dataBuf[ii]); /*列车最大安全前端所处Link*/
						ii += 2U;
						maxHeadOff = LongFromChar(&dataBuf[ii]); /*列车最大安全前端偏移量*/
						ii += 4U;
						minTailLink = ShortFromChar(&dataBuf[ii]); /*列车最小安全后端所处Link*/
						ii += 2U;
						minTailOff = LongFromChar(&dataBuf[ii]); /*列车最小安全后端偏移量*/
						ii += 4U;

						if ((0u != maxHeadLink) && (UINT16_MAX != maxHeadLink)
							&& (0u != minTailLink) && (UINT16_MAX != minTailLink)
							&& (UINT32_MAX != maxHeadOff) && (UINT32_MAX != minTailOff))
						{
							vobcBackupToCiCur->wTrainMaxSafeHeadLink = maxHeadLink;
							vobcBackupToCiCur->dwTrainMaxSafeHeadOffset = maxHeadOff;
							vobcBackupToCiCur->wTrainMinSafeTailLink = minTailLink;
							vobcBackupToCiCur->dwTrainMinSafeTailOffset = minTailOff;
						}
						else
						{
							retVal = CI_ERROR;  /*包络数值非法*/
							debug_infor_printf((const)"\nVOBC_BACK_UP %d  Link & Offset ERROR", systemId);
						}
					}
					else
					{
						; /*不处理*/
					}
					/*获取并检验屏蔽门数量*/
					if (CI_SUCCESS == retVal)
					{
						psdCmdCode = dataBuf[ii++];  /*站台开门码，每个开门码对应CI需要开的一组站台门*/;
						vobcBackupToCiCur->psdCmdCode = psdCmdCode & 0x1fU;
						if ((4U == vobcBackupToCiCur->psdCmdCode) 
							|| (6U == vobcBackupToCiCur->psdCmdCode) 
							|| (8U == vobcBackupToCiCur->psdCmdCode)
							|| (0U == vobcBackupToCiCur->psdCmdCode))
						{/*列车编组信息取值为0或4或6或8*/
							; /*取值合法*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"\nVOBC_BACK_UP %d  psdCmdCode ERROR：%d", systemId, vobcBackupToCiCur->psdCmdCode);
						}
						psdSum = dataBuf[ii];
						ii += 1U;

						if ((2U == psdSum) || (1U == psdSum) || (0U == psdSum))
						{/*接口定义：屏蔽门数量取值为0或1或2*/
							vobcBackupToCiCur->PsdSum = psdSum;		          /*屏蔽门数量*/
						}
						else
						{
							retVal = CI_ERROR;
							debug_infor_printf((const)"\nVOBC_BACK_UP %d  psdNum ERROR：%d", systemId, psdSum);
						}
					}
					else
					{
						; /*不处理*/
					}
					/*获取并校验屏蔽门信息*/
					if (CI_SUCCESS == retVal)
					{
						for (jj = 0U; jj < psdSum; jj++)
						{
							psdIdIntConnt = LongFromChar(&dataBuf[ii]);/*获取互联互通4字节屏蔽门ID*/
							ii += 4U;
							vobcBackupToCiCur->PsdData[jj].PsdIdInterConn = psdIdIntConnt;

							/*根据互联互通4字节ID获取屏蔽门ID*/
							funRet = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdIdIntConnt, &psdId);

							if (CI_SUCCESS == funRet)
							{
								vobcBackupToCiCur->PsdData[jj].PsdId = psdId;

								cmdType = dataBuf[ii];/*获取屏蔽门命令*/
								ii += 1U;
								if (((VOBCTOCI_COMMAND_TYPE_PSDOPEN == cmdType)&& (0U != vobcBackupToCiCur->psdCmdCode))
									|| (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == cmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT == cmdType))
								{
									/*开门命令时开门码信息需要为有效值*/
									vobcBackupToCiCur->PsdData[jj].CmdType = cmdType;

									vobcBackupToCiCur->PsdData[jj].CmdStartCycNum = Get2oo2CurCycleNum();
								}
								else
								{
									retVal = CI_ERROR;
									debug_infor_printf((const)"\nVOBC_BACK_UP %d  PSD cmdType : %d, cmdCode : \n", systemId, cmdType, vobcBackupToCiCur->psdCmdCode);
								}
							}
							else
							{
								ii += 1U;
							}
						}
					}
					else
					{
						; /*不处理*/
					}

					/*解析前方信号机ID*/
					if (CI_SUCCESS == retVal)
					{
						dwHlhtNs = LongFromChar(&dataBuf[ii]);/*回复收到的信号机ID*/
						ii += 4U;
						if (0x00000000U == dwHlhtNs)
						{
							/*默认值设置前车ID为0*/
							vobcBackupToCiCur->wTrainHeadCurSignalId = 0U;
						}
						else
						{
							/*根据互联互通4字节ID获取信号机ID*/
							funRet = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, dwHlhtNs, &TrainSignalId);
							if ((CI_SUCCESS == funRet) && (SIGNAL_SUM_MAX > TrainSignalId))
							{
								vobcBackupToCiCur->wTrainHeadCurSignalId = TrainSignalId;
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"\nVOBC_BACK_UP %d  wTrainHeadCurSignalId : %d\n", systemId, dwHlhtNs);

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

					/*前车ID*/
					if (CI_SUCCESS == retVal)
					{
						dwHlhtNs = LongFromChar(&dataBuf[ii]);
						ii += 4U;
						if (0xFFFFFFFFU == dwHlhtNs)
						{
							/*默认值设置前车ID为0*/
							vobcBackupToCiCur->wTrainHeadTrainId = 0x14FFU;
						}
						else
						{
							retVal = dquHlhtId2VobcName(dwHlhtNs, &wHeadTrainId, &wTrainRelLgcId);
							if (CI_SUCCESS == retVal)
							{
								vobcBackupToCiCur->wTrainHeadTrainId = wHeadTrainId;
							}
							else
							{
								retVal = CI_ERROR;
								debug_infor_printf((const)"\nVOBC_BACK_UP %d  wTrainHeadTrainId : %d\n", systemId, dwHlhtNs);
							}
						}
					}
					else
					{
						/*解析错误不继续解析*/
					}

					/*NVRAM位置标识*/
					if (CI_SUCCESS == retVal)
					{
						chNvramPosFlag = dataBuf[ii++];
						if ((TRAIN_NVRAM_POS_FLAG_YES == chNvramPosFlag) || (TRAIN_NVRAM_POS_FLAG_NO == chNvramPosFlag))
						{
							vobcBackupToCiCur->chNvramPosFlag = chNvramPosFlag;
						}
						else
						{
							debug_infor_printf((const)"\nVOBC_BACK_UP %d  chNvramPosFlag : %d\n", systemId, chNvramPosFlag);
							retVal = CI_ERROR;
						}
					}
					else
					{
						; /*不处理*/
					}

					/*列车停稳状态*/
					if (CI_SUCCESS == retVal)
					{

						chStopSteayFlag = dataBuf[ii];
						ii += 1U;
						dwTrackSecId = LongFromChar(&dataBuf[ii]);
						ii += 4U;
						if ((VOBC_CI_STOP_TW == chStopSteayFlag) || (VOBC_CI_STOP_WTW == chStopSteayFlag))
						{
							vobcBackupToCiCur->chStopSteadyState = chStopSteayFlag;
							vobcBackupToCiCur->stopSteadyStartCycNum = Get2oo2CurCycleNum();
							vobcBackupToCiCur->trackSecID = dwTrackSecId;
						}
						else
						{
							debug_infor_printf((const)"\nVOBC_BACK_UP %d  chStopSteayFlag : %d\n", systemId, chStopSteayFlag);
							retVal = CI_ERROR;
						}
					}

					/*预留5字节*/
					ii += 5U;
				}
				else
				{
					retVal = CI_ERROR;
				}

				if (CI_SUCCESS == retVal)
				{
					/*校验数据长度*/
					if (vobvBackupGalHead.totalDataLen != ii - 31U)
					{
						/* 31为应用数据帧头长度 */
						debug_infor_printf((const)"\nVOBC_BACK_UP %d len Error vobvBackupGalHead.totalDataLen:%d  Infactlen：%d", systemId, vobvBackupGalHead.totalDataLen,ii);
						retVal = CI_ERROR;
					}
					else
					{
						;  /*不处理*/
					}
				}
				else
				{
					;  /*不处理*/
				}

				/*数据经过校验，需要存储通用报文上下文*/
				if (CI_SUCCESS == retVal)
				{
					SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.comPeriod);
					SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.crntOwnMsgSN);
					SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.recvOppMsgSN);
					SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.preOwnMsgSN);
					SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, curntCycleNo);
					SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, logId);

					galSaveTag = 1U;
				}
				else
				{
					;  /*不处理*/
				}
			}
			else
			{
				retVal = CI_ERROR;
			}
		}
		/*第一次收到VOBC消息时校验不通过，只记录curntOwnMsg以及当前本方软件周期号*/
		else if (HLHT_HEAD_INIT == headRet)
		{
			if (0U < curntCycleNo)/*判断序号大于0*/
			{
				SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.comPeriod);
				SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.crntOwnMsgSN);
				SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.recvOppMsgSN);
				SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.preOwnMsgSN);
				SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, curntCycleNo);
				SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, logId);

				galSaveTag = 1u;
			}
			else
			{
				;  /*不处理*/
			}

			retVal = CI_ERROR;
		}
		else
		{
			/*给ATS或现地反馈VOBC-CI数据接口信息类型错误*/
			if (GAL_COMPARE_INFO_TYPE_ERR == (errCode & GAL_COMPARE_INFO_TYPE_ERR))
			{/*记录通信故障码*/
				SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_INFO_TYPE_ERR, ESEND_LEVEL_ATS);
				errorNum++;
			}
			else
			{
				; /*无操作*/
			}
			/*给ATS或现地反馈VOBC-CI数据发送方标识信息错误*/
			if (GAL_COMPARE_SEND_FLAG_ERR == (errCode & GAL_COMPARE_SEND_FLAG_ERR))
			{/*记录通信故障码*/
				SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_SEND_FLAG_ERR, ESEND_LEVEL_ATS);
				errorNum++;
			}
			else
			{
				; /*无操作*/
			}

			/*给ATS或现地反馈VOBC-CI数据接收方标志信息错误*/
			if (GAL_COMPARE_RECV_FLAG_ERR == (errCode & GAL_COMPARE_RECV_FLAG_ERR))
			{/*记录通信故障码*/
				SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_RECV_FLAG_ERR, ESEND_LEVEL_ATS);
				errorNum++;
			}
			else
			{
				; /*无操作*/
			}
			/*给ATS或现地反馈VOBC-CI数据版本校验失败信息*/
			if (GAL_COMPARE_EMAP_VER_COMP_ERR == (errCode & GAL_COMPARE_EMAP_VER_COMP_ERR))
			{/*记录通信故障码*/
				SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_VER_CHECK_FAIL, ESEND_LEVEL_ATS);
				errorNum++;
			}
			else
			{
				; /*无操作*/
			}
			/*给ATS或现地反馈VOBC-CI数据本方、对方及收到上一条消息时本方序列号错误*/
			if (GAL_COMPARE_MSG_BDS_SN_ERR == (errCode & GAL_COMPARE_MSG_BDS_SN_ERR))
			{/*记录通信故障码*/
				SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_MSG_BDS_SN_ERR, ESEND_LEVEL_ATS);
				errorNum++;
			}
			else
			{
				; /*无操作*/
			}

			/*给ATS或现地反馈VOBC-CI数据对方消息序列号及收到上一条消息时本方序列号错误*/
			if (GAL_COMPARE_MSG_SN_ERR == (errCode & GAL_COMPARE_MSG_SN_ERR))
			{/*记录通信故障码*/
				SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_MSG_SN_ERR, ESEND_LEVEL_ATS);
				errorNum++;
			}
			else
			{
				; /*无操作*/
			}
			/*给ATS或现地反馈VOBC-CI数据协议版本号错误*/
			if (GAL_COMPARE_PROTOCOL_VER_ERR == (errCode & GAL_COMPARE_PROTOCOL_VER_ERR))
			{/*记录通信故障码*/
				SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_PROTOCOL_VER_ERR, ESEND_LEVEL_ATS);
				errorNum++;
			}
			else
			{
				; /*无操作*/
			}

			/*给ATS或现地反馈VOBC-CI数据应用层数据长度无效*/
			if (GAL_COMPARE_APP_LEN_ERR == (errCode & GAL_COMPARE_APP_LEN_ERR))
			{/*记录通信故障码*/
				SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_APP_LEN_ERR, ESEND_LEVEL_ATS);
				errorNum++;
			}
			else
			{
				; /*无操作*/
			}

			/*给ATS或现地反馈VOBC-CI数据通信周期错误 */
			if (GAL_COMPARE_COM_PERIOD == (errCode & GAL_COMPARE_COM_PERIOD))
			{/*记录通信故障码*/
				SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_COM_PERIOD, ESEND_LEVEL_ATS);
				errorNum++;
			}
			else
			{
				; /*无操作*/
			}

			/*异常报错防护*/
			if((0U != errCode)&&(0U == errorNum))
			{/*记录通信故障码*/
				SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_ERROR, ESEND_LEVEL_ATS);
			}
			else
			{
				; /*无操作*/
			}
			retVal = CI_ERROR;
		}
	}
	else
	{
		; /*不处理*/
	}

	if (CI_SUCCESS == retVal)
	{
		if ((NULL != vobcBackupToCiCur) && (NULL != vobcBackup))
		{
			(void)CommonMemCpy((void *)(vobcBackup), (UINT32)sizeof(VobcBackUpToCiDataStruct), (void *)(vobcBackupToCiCur), (UINT32)sizeof(VobcBackUpToCiDataStruct));
		}
		else
		{
			retVal = CI_ERROR;
		}
	}
	else if(HLHT_HEAD_INIT == headRet)
	{
		/*对初始帧 保存id*/
		vobcBackup->VobcId = systemId;
	}
	else
	{
		; /*do nothing*/
	}
	return retVal;
}


/*
* 功能描述： 组VOBC数据
* 参数说明： void
* 返回值  ： 0:组数据失败
*			 1:组数据成功      
*/
UINT8 PackCiToVobcData(void)
{
	UINT32 ii = 0u;
	UINT8 retVal = CI_SUCCESS;
	UINT8 lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);
	UINT8 initVobcIds[UINT8_MAX] = { 0u };
	UINT16 initVobcIdLogIds[UINT8_MAX] = { 0u };
	UINT8 initVobcSum = 0u;
	debug_infor_printf((const)"\nPackCiToVobcData VobcToCiSum = %d\n", VobcToCiSum);	/*打印与CI通信的VOBC数目*/
	for (ii = 0u; (ii < (UINT32)VobcToCiSum) && (ii < VOBC_TO_CI_SUM_MAX); ii++)
	{
		if (LINE_HLHT == lineIdentity)/*互联互通线路*/
		{
			retVal = PackCiToVobcDataHLHT(&(VobcToCiDataStru[ii]));
		}
		else if (LINE_FAO == lineIdentity)
		{/*FAO*/
			retVal = PackCiToVobcDataFAO(&(VobcToCiDataStru[ii]));
		}
		else if (LINE_FAOHLHT == lineIdentity)
		{/*FAO+互联互通线路*/
			retVal = PackCiToVobcDataFAOHLHT(&(VobcToCiDataStru[ii]));
		}
		else if (LINE_CC == lineIdentity)
		{
			/*车车线路*/
			retVal = PackCiToIvocDataCC(&(VobcToCiDataStru[ii]));
		}
		else if (LINE_FAOHLHT_ONESELF == lineIdentity)
		{
			retVal = PackCiToVobcDataFAOHLHToneSelf(&(VobcToCiDataStru[ii]));
		}
		else if (LINE_FAOHLHT_ONESELFSECOND == lineIdentity)
		{
			retVal = PackCiToVobcDataFAOHLHToneSelfSecond(&(VobcToCiDataStru[ii]));
		}
		else
		{
			retVal = CI_ERROR;
		}
#if 0
		if (CI_ERROR==chRetVal)
		{
			break;  /*注释掉：防止某个车组包失败，后面的车不组包，导致VOBC收不到屏蔽门信息，判与CI中断*/
		}
#endif
	}

	if ((LINE_HLHT == lineIdentity)
		|| (LINE_FAOHLHT == lineIdentity)
		|| (LINE_CC == lineIdentity)
		|| (LINE_FAOHLHT_ONESELF == lineIdentity)
		|| (LINE_FAOHLHT_ONESELFSECOND == lineIdentity))/*互联互通线路或（FAO+互联互通）线路*/
	{
		/*处理VOBC的通用报文头数据，协议规定，当VOBC首次给CI发送数据时，虽然校验无法通过，无法产生真正可用的数据，但CI需要给VOBC反馈心跳*/
		if (CI_SUCCESS == GetHlhtInitHeadDevsByDevType(CI_SYSTEM_TYPE_VOBC, initVobcIds, (UINT8)sizeof(initVobcIds), &initVobcSum, initVobcIdLogIds))
		{
			for (ii = 0u; ii < initVobcSum; ii++)
			{
				retVal &=PackCiToVobcDataHLHTHeart(initVobcIds[ii], initVobcIdLogIds[ii]);
				debug_infor_printf((const)"\nPACK HEARTFARME TO VOBC %d", initVobcIds[ii]);	/*打印信息*/
			}
		}
		else
		{
		}
	}
	else
	{
	}


	return retVal;
}

/*
* 功能描述： 组VOBC后备通道数据
* 参数说明： void
* 返回值  ： CI_ERROR失败  CI_SUCCESS成功
*/
UINT8 PackCiToVobcBackUpData(void)
{
	UINT32 ii = 0u;
	UINT8 retVal = CI_ERROR;
	UINT8 VobcBackUpToCiSum = 0U;/*与联锁通信的后备通道Vobc数目*/
	UINT32 dwCycNum = 0U;
	UINT8 chHeadCheck = 0U;

	dwCycNum = Get2oo2CurCycleNum();
	for (ii = 0u; ii < VOBC_BACKUP_TO_CI_SUM_MAX; ii++)
	{
		if (0U != VobcBackUpToCiDataStru[ii].VobcId)
		{
			chHeadCheck = BackupHeadCheckValid(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(VobcBackUpToCiDataStru[ii].VobcId));

			if ((CI_SUCCESS == chHeadCheck) || ((CI_SUCCESS != chHeadCheck) && (dwCycNum == VobcBackUpToCiDataStru[ii].ComStartCycle)))
			{
				/*初始状态帧或者不是初始状态要求当周期收到数据*/
				/*组车车备用通道信息*/
				debug_infor_printf((const)"\nPackCiToVobcData BackUpVobcID: %d\n", VobcBackUpToCiDataStru[ii].VobcId);
				retVal = PackCiToIvocBackUpDataCC(&VobcBackUpToCiDataStru[ii]);
				VobcBackUpToCiSum++;
			}
			else
			{
				; /*不组包*/
			}
		}
		else
		{
			; /*无效列车ID 不解析*/
		}
	}
	debug_infor_printf((const)"\nPackCiToVobcData VobcBackUpToCiSum = %d\n", VobcBackUpToCiSum);	/*打印与CI通信的VOBC数目*/
	return retVal;
}
/*
* 功能描述： 获取VOBC到CI命令结构体数组
* 参数说明： void    
* 返回值  ： NULL: 获取失败
*           !NULL: VOBC到CI命令结构体数组指针      
*/
VobcToCiDataStruct* GetVobcToCiDataStru(void)
{
	VobcToCiDataStruct * retVal = NULL;
	if (VobcToCiSum == 0u)
	{
		retVal = NULL;
	}
	else
	{
		retVal = VobcToCiDataStru;
	}
	return retVal;
}

/*
* 功能描述： 根据索引获取Vobc id
* 参数说明： UINT16 idx:VOBC发送给CI的信息结构体数组的位置索引
* 返回值  ： 0:失败
*			 其它值:VobcId
*/
UINT16 GetVobcIdByIndex(UINT16 index)
{
	UINT16 retVal = 0u;
	if (index < VOBC_TO_CI_SUM_MAX)
	{
		retVal = VobcToCiDataStru[index].VobcId;
	}
	return retVal;
}

/*
* 功能描述： 根据索引获取Vobc 编组信息
* 参数说明： UINT16 idx:VOBC发送给CI的信息结构体数组的位置索引
* 返回值  ： 0:失败
*			 其它值:VobcId
*/
UINT8 GetVobcEditGroupInfoByIndex(UINT16 index)
{
	UINT8 retVal = 0u;
	if (index < VOBC_TO_CI_SUM_MAX)
	{
		retVal = (UINT8)(VobcToCiDataStru[index].trainEditGroupInfo);
	}
	return retVal;
}

/*
* 功能描述： 获取VOBC到CI命令结构体数组总数
* 参数说明： void    
* 返回值  ： 数组总数    
*/
UINT8 GetVobcToCiSum(void)
{
	return VobcToCiSum;
}

/*
* 功能描述： 获取屏蔽门编组信息
* 参数说明： const UINT16 psdId :屏蔽门ID    
* 返回值  ： 01:四编组
*            02:六编组
*			 08:八编组
*            CI_ERROR: 不合法
*/
UINT8 GetPsdEditGroupInfo(const UINT16 psdId)
{
	UINT8 ii = 0u, jj = 0u;
	VobcToCiDataStruct * vobcToCiDataStru = NULL;
	UINT8 retVal = 0u;
	vobcToCiDataStru = GetVobcToCiDataStru();

	if(NULL != vobcToCiDataStru)
	{
		for(ii = 0u;ii < GetVobcToCiSum();ii++)
		{	
			for(jj = 0u;jj < vobcToCiDataStru[ii].PsdSum; jj++)
			{
				if(psdId == vobcToCiDataStru[ii].PsdData[jj].PsdId)
				{
					break;
				}
			}
			if(jj < vobcToCiDataStru[ii].PsdSum)
			{
				break;
			}
		}
		if(ii < GetVobcToCiSum())
		{
			retVal = (UINT8)(vobcToCiDataStru[ii].trainEditGroupInfo);
		}
		else
		{
			retVal = CI_ERROR;
		}
	}
	else
	{
		retVal =  CI_ERROR;
	}
	return  retVal;
}

/*
* 功能描述： 从VOBC发送给CI的信息结构体数组中，删除指定位置的数据
* 参数说明： const UINT8 idx:VOBC发送给CI的信息结构体数组的位置索引
* 返回值  ： 0:失败
*			 1:成功     
*/
UINT8 RemoveVobcToCiMsgAt(UINT8 idx)
{
	UINT8 retVal = CI_ERROR;
	UINT8 afIdx;
	if(idx>=VobcToCiSum)
	{
		retVal = CI_ERROR;
	}
	else
	{
		for(afIdx=idx+1U;afIdx<VobcToCiSum;afIdx++)
		{
			CopyVobcToCiMsg(&(VobcToCiDataStru[afIdx]),&(VobcToCiDataStru[afIdx-1U]));
		}
		VobcToCiDataStru[VobcToCiSum-1U].VobcId=0u;
		(void)memset(&(VobcToCiDataStru[VobcToCiSum-1U]),0,sizeof(VobcToCiDataStruct));/*清内存，防止脏数据*/
		/*总数减少一个*/
		VobcToCiSum--;
		retVal = CI_SUCCESS;
	}

	return retVal;
}
/*
* 功能描述： 拷贝VOBC发送给CI的信息结构体
* 参数说明： const VobcToCiDataStruct* srcMsg:被复制的VOBC发送给CI的信息结构体指针
			 VobcToCiDataStruct* dstMsg:目标VOBC发送给CI的信息结构体的指针
* 返回值  ： 无     
*/
static void CopyVobcToCiMsg(const VobcToCiDataStruct* srcMsg,VobcToCiDataStruct* dstMsg)
{
	if ((srcMsg !=NULL) && (dstMsg != NULL))
	{
		(void)CommonMemCpy(dstMsg, (UINT32)sizeof(VobcToCiDataStruct), srcMsg, (UINT32)sizeof(VobcToCiDataStruct));
	}

}
/*
* 功能描述： 解析处理HLHT VOBC单帧数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            const UINT8 systemId, 源设备ID
*            VobcToCiDataStru vobcToci数据结构体指针
*			 UINT8* saveGalHead,通用报文头是否保留,1:保留，0:不保留
*            const UINT16 logId，互联互通4IP VOBC的1端或2端标识  
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功
*/
static UINT8 ParseVobcToCiDataFrameHLHT(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* vobcToCiDataStru, UINT8* saveGalHead,const UINT16 logId)
{
	UINT8 cmdType = 0u;							 /*屏蔽门命令类型*/
	UINT8 trainStopSteadyState = 0u;				/*列车停稳状态*/
	UINT8 psdSum = 0u;
	UINT8 trainDirection = 0u;					/*列车方向*/
	UINT8 ii = 0u;                                /*索引管理*/
	UINT8 jj = 0u;
	UINT8 retVal = CI_SUCCESS;
	UINT8 retValue = 0u;
	UINT16 psdId = 0u;                            /*PSD的ID*/
	UINT16 appInfoType = 0u;						 /*应用信息类型*/
	UINT32 psdIdIntConnt = 0u;                    /*互联互通PSD的ID*/
	UINT32 trackSectionId = 0u;					 /*轨道区段ID*/
	UINT32 curntCycleNo = 0u;					/*当前周期号*/
	UINT16 vobcName = 0u;						/*VOBC设备名称：类型+ID*/
	UINT16 ciName = 0u;							/*联锁设备名称：类型+ID*/
	UINT8 localCiId = GetSystemParaLocalCiId();/*联锁ID*/
	UINT32 errCode = 0u;
	HLHTGALInfoStruct hlhtGalHead = { 0u };
	INT32 vobcInfoRemainValidiy = 0;
	UINT8 headRet = HLHT_HEAD_ERROR;/*互联互通检查结果*/
	UINT8 cTempPsdCmdCode = 0U;
	UINT32 signalId = 0u;		/*VOBC->CI信号机ID*/
    UINT8 ci_vobcPrtclVersion = 0u;

	ci_vobcPrtclVersion = GetVersionOfVOBCToCI();
	vobcName = (CI_SYSTEM_TYPE_VOBC)*256U + systemId;
	ciName = (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();

	vobcToCiDataStru->vobcLogId = logId;/*存储VOBC的逻辑ID，1端或2端*/
	/*（通用消息包头校验通过 && 报文生存时间有效）才继续解析其他信息*/
	/*第一次收到VOBC消息时校验不通过，只记录curntOwnMsg以及当前本方软件周期号*/
	headRet = HLHTRecvCommonPacketHeadCheck(vobcName, ciName, CI_VOBC_INTERFACE_INFOTYPE, ci_vobcPrtclVersion, &hlhtGalHead, &errCode, logId,CI_SYSTEM_TYPE_VOBC);

	debug_infor_printf((const)"\nVOBC %d GAL Check Result:%d errCode:%d", systemId,headRet,errCode);	/*0x55正确，0xaa错误，0x33初始通信帧*/

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

		if (0 < vobcInfoRemainValidiy)
		{
			/*解析应用数据*/
			/*更新接收到上一条消息时的本方周期号*/
			ii += 2u;/*跳过应用报文长度2字节*/

			appInfoType = ShortFromChar(&dataBuf[ii]);/*应用信息类型，屏蔽门控制信息或者心跳帧信息*/
			ii += 2u;
			vobcToCiDataStru->appInfoType = appInfoType;
			vobcToCiDataStru->VobcId = systemId;
#if 0
			vobcToCiDataStru->vobcInfoStartCycNum = Get2oo2CurCycleNum();/*CI接收到VOBC发送的信息起始周期*/
#endif

			ii += 2u;/*跳过两个预留字节*/

			if (VOBC_CI_INFO_TYPE_PSD_CONTROL == appInfoType)
			{/*只有当VOBC发送CI的信息类型是屏蔽门控制报文时才继续解析报文信息*/
				vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum();
				/*列车运行方向判断*/
				trainDirection = dataBuf[ii];
				ii += 1u;

				if ((TRAIN_DIR_UP == trainDirection) || (TRAIN_DIR_DOWN == trainDirection) || (TRAIN_DIR_DEF == trainDirection))
				{
					vobcToCiDataStru->trainDirection = trainDirection;
				}
				else
				{
					retVal = CI_ERROR;
				}

				/*列车停稳停准信息判断*/
				if (CI_SUCCESS == retVal)
				{
					trainStopSteadyState = dataBuf[ii];
					ii += 1u;

					if ((VOBC_CI_STOP_TW == trainStopSteadyState) || (VOBC_CI_STOP_WTW == trainStopSteadyState))
					{
						vobcToCiDataStru->trainStopSteadyState = trainStopSteadyState;
						vobcToCiDataStru->stopSteadyStartCycNum = Get2oo2CurCycleNum();/*记录收到停稳或未停稳信息的周期*/
					}
					else
					{
						retVal = CI_ERROR;
					}
				}
				else
				{
				}

				trackSectionId = LongFromChar(&dataBuf[ii]);/*获取轨道区段ID*/
				ii += 4u;
				vobcToCiDataStru->trackSecID = trackSectionId;

				if (CI_SUCCESS == retVal)
				{
					vobcToCiDataStru->VobcId = systemId;                         /*VOBC的ID*/
					vobcToCiDataStru->psdCmdCode = dataBuf[ii++];        /*站台开门码，每个开门码对应CI需要开的一组站台门*/
																		 /*根据站台开门码获取编组信息，开门码的低5位表示列车实际编组数*/

					/*因为在关门时VOBC发送车辆编组默认值,所以需要在开门时保存车辆编组数值*/		
					cTempPsdCmdCode = 0x1Fu & vobcToCiDataStru->psdCmdCode;
					if (0U != cTempPsdCmdCode)  /*修缺陷YF0083-682，2023-07-03*/
					{						 
						vobcToCiDataStru->trainEditGroupInfo = cTempPsdCmdCode;
					}
					else
					{
						vobcToCiDataStru->trainEditGroupInfo = vobcToCiDataStru->trainEditGroupInfo;
					}

					psdSum = dataBuf[ii];
					ii += 1u;

					if ((2u == psdSum) || (1u == psdSum) || (0u == psdSum))
					{/*接口定义：屏蔽门数量取值为0或1或2*/
						vobcToCiDataStru->PsdSum = psdSum;		          /*屏蔽门数量*/
					}
					else
					{
						retVal = CI_ERROR;
					}
				}
				else
				{
				}

				if (CI_SUCCESS == retVal)
				{
					for (jj = 0u; jj < 2u; jj++)
					{
						psdIdIntConnt = LongFromChar(&dataBuf[ii]);/*获取互联互通4字节屏蔽门ID*/
						ii += 4u;
						vobcToCiDataStru->PsdData[jj].PsdIdInterConn = psdIdIntConnt;

						/*根据互联互通4字节ID获取屏蔽门ID*/
						retValue = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdIdIntConnt, &psdId);

						if (CI_SUCCESS == retValue)
						{
							vobcToCiDataStru->PsdData[jj].PsdId = psdId;

							cmdType = dataBuf[ii];/*获取屏蔽门命令*/
							ii += 1u;
							if ((VOBCTOCI_COMMAND_TYPE_PSDOPEN == cmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == cmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT == cmdType))  /*修缺陷YF0083-682，2023-07-03*/
							{
								vobcToCiDataStru->PsdData[jj].CmdType = cmdType;

								vobcToCiDataStru->PsdData[jj].CmdStartCycNum = Get2oo2CurCycleNum();
							}
							else
							{
								retVal = CI_ERROR;
							}
						}
						else
						{
							ii++;
						}
					}

					/*增加新的接口：信号机的ID1~0xFFFFFFFF,0为默认值，VOBC最大安全前端前方沿列车运行方向可搜索到的最近的同向信号机。*/
					signalId = LongFromChar(&dataBuf[ii]);	/*获取信号机ID*/
					ii += 4u;

					vobcToCiDataStru->signalID = signalId;	/*将信号机ID保存到结构体*/

				}
				else
				{
				}
			}
			else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == appInfoType) || (VOBC_CI_INFO_TYPE_LOGOUT_ASK == appInfoType))
			{/*心跳帧或注销请求帧*/
				vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum();
			}
			else
			{
				retVal = CI_ERROR;
			}

			if (CI_SUCCESS == retVal)
			{
				/*校验数据长度*/
				if (ii > dataLength)
				{
					retVal = CI_ERROR;
				}
				else
				{
				}
			}
			else
			{
			}

			if (CI_SUCCESS == retVal)
			{
				/*数据经过校验，需要存储通用报文上下文*/
				SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod);
				SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN);
				SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN);
				SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN);
				SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo);
				SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId);

				*saveGalHead = 1u;
			}
			else
			{
			}
		}
		else
		{
			retVal = CI_ERROR;
		}
	}
	else if (HLHT_HEAD_INIT ==headRet)
	{
		if (curntCycleNo > 0u)/*判断序号大于0，因为把0当做无效序号*/
		{
			SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod);
			SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN);
			SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN);
			SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN);
			SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo);
			SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId);

			*saveGalHead = 1u;
		}
		else
		{
		}

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

	return retVal;
}

/*
* 功能描述： 解析处理FAO VOBC单帧数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            const UINT8 systemId, 源设备ID
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功      
*/
static UINT8 ParseVobcToCiDataFrameFAO(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId,VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT8 localCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/
	UINT8 rowIndex  = 0u;                         /*行索引*/
	UINT8 colIndex  = 0u;                         /*列索引*/	
	UINT8 trainEditGroup = 0u;                    /*列车编组信息*/
	UINT8 ii = 0u;                                /*索引管理*/
	UINT8 jj = 0u;
	UINT8 retVal = CI_SUCCESS;
	UINT16 psdId = 0u;                            /*PSD的ID*/
	UINT8 psdCmdType = 0u;                         /*PSD的控制命令*/
	UINT32 faultInfo = 0u;                        /*故障隔离信息*/

	if (dataBuf[ii++] != CI_SYSTEM_TYPE_VOBC)
	{/*不是VOBC发送的数据*/

		retVal = CI_ERROR;
	}
	if(CI_SUCCESS == retVal)
	{
		/*跳过VOBC的ID*/
		ii++;

		if (dataBuf[ii++] != Get2oo2SheBeiType())
		{/*不是发送到本设备的数据*/

			retVal = CI_ERROR;
		}
	}

	if(CI_SUCCESS == retVal)
	{
		if (dataBuf[ii++] != localCiId)
		{/*不是发送到本联锁的数据*/

			retVal = CI_ERROR;
		}
	}

	if(CI_SUCCESS == retVal)
	{
		if (VobcToCiSum >= VOBC_TO_CI_SUM_MAX)
		{
			retVal = CI_ERROR;
		}
	}

	if(CI_SUCCESS == retVal)
	{
		vobcToCiDataStru->VobcId = systemId;                 /*VOBC的ID*/
		vobcToCiDataStru->PsdSum = dataBuf[ii++];            /*屏蔽门数量*/

		if (2U != vobcToCiDataStru->PsdSum)
		{/*接口定义：屏蔽门数量取值为2*/
			vobcToCiDataStru->PsdSum = 0u;
			retVal = CI_ERROR;
		}
	}

	if(CI_SUCCESS == retVal)
	{
		vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum();
		for (jj = 0u; jj < vobcToCiDataStru->PsdSum; jj++)
		{/*屏蔽门控制信息*/

			psdId = ShortFromChar(&dataBuf[ii]);/*获取屏蔽门ID*/
			ii += 2u;
			psdCmdType = dataBuf[ii];                /*命令类型*/
			ii += 1u;
			if ((0U == psdId) || (PSD_INVALID_ID == psdId) || (GetPsdBelongCiId(psdId) != GetSystemParaLocalCiId()) || (PSD_INVALID_CMD == psdCmdType) || (PSD_DEFAULT_CONTROL_CMD == psdCmdType))
			{/*屏蔽门ID无效或屏蔽门不属于本联锁，则认为控制命令无效*/
				vobcToCiDataStru->PsdData[jj].PsdId = PSD_INVALID_ID;
				vobcToCiDataStru->PsdData[jj].CmdType = PSD_DEFAULT_CONTROL_CMD;
				ii += 1u;/*跨过命令类型字段*/
#if 0
				vobcToCiDataStru->PsdData[jj].CmdStartCycNum = Get2oo2CurCycleNum(); /*设置命令起始周期:新需求规定，只要VOBC->CI发数据，CI就应该->VOBC回复*/
#endif
			}
			else
			{
				vobcToCiDataStru->PsdData[jj].PsdId =   psdId;
				vobcToCiDataStru->PsdData[jj].CmdType = psdCmdType;                /*命令类型*/
				vobcToCiDataStru->PsdData[jj].CmdStartCycNum = Get2oo2CurCycleNum();/*设置命令起始周期*/
			}
		}

		retVal = ChecktrainEditGroupInfo(dataBuf[ii], OUT (UINT8)vobcToCiDataStru->trainEditGroupInfo);                         /*列车编组信息*/
		ii++;

		for (jj = 0u; jj < vobcToCiDataStru->PsdSum; jj++)
		{/*故障隔离信息请求*/

			psdId = vobcToCiDataStru->PsdData[jj].PsdId;
			trainEditGroup = (UINT8)(vobcToCiDataStru->trainEditGroupInfo); 

			faultInfo = LongFromChar(&dataBuf[ii]);                                         /*获取故障隔离信息*/
			ii += 4u;




			if((0u != psdId) && (PSD_INVALID_ID != psdId) &&(GetPsdBelongCiId(psdId) == GetSystemParaLocalCiId()))
			{/*屏蔽门ID有效则:将相关信息填入CI--->PSD的数据结构中*/

				rowIndex = PsdPlatformIndex[psdId][0];/*获取映射点*/
				colIndex = PsdPlatformIndex[psdId][1];
				if(0u != rowIndex )
				{/*已经配置*/
					platformToCiDataStru[rowIndex].psdDataStr[colIndex].PsdId = psdId;                           /*屏蔽门ID*/
					platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationRequestInfo = faultInfo;   /*故障隔离信息*/
					platformToCiDataStru[rowIndex].psdDataStr[colIndex].doorEditGroupInfo = trainEditGroup;      /*车门编组信息*/
					platformToCiDataStru[rowIndex].psdDataStr[colIndex].doorHaveOrNot = PSD_HAVE_TRAIN_DOOR_YES;/*置为有车门信息*/
				}
				vobcToCiDataStru->PsdData[jj].faultIsolationRequest = faultInfo;                     /*故障隔离信息请求*/
			}
		}


		retVal = CheckwashTrainRequest(dataBuf[ii], OUT vobcToCiDataStru->washTrainRequest);  /*洗车请求信息*/
		ii++;
		retVal = CheckheadWashStopSteady(dataBuf[ii++], OUT vobcToCiDataStru->headWashStopSteadyInfo);   /*头端洗位停稳信息*/
		ii++;
		retVal = ChecktailWashStopSteady(dataBuf[ii++], OUT vobcToCiDataStru->tailWashStopSteadyInfo);   /*尾端洗位停稳信息*/
		ii++;
		retVal = CheckpassWashMachine(dataBuf[ii++], OUT vobcToCiDataStru->passWashMachineRequest);   /*通过洗车机请求信息*/
		ii++;

		ii += 10u;/*新增预留10个字节，用于未来扩展，20151211新增*/

		if (ii > dataLength)
		{
			retVal = CI_ERROR;
		}
	}
	return retVal;
}

/*
* 功能描述： 组VOBC数据
* 参数说明： VobcToCiDataStruct *vobcToCiDataStru, vobc到CI数据结构体     
* 返回值  ： 0:组数据失败
*			 1:组数据成功      
*/
static UINT8 PackCiToVobcDataHLHT(VobcToCiDataStruct *vobcToCiDataStru)
{
	UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = {0u};/*CI到VOBC组帧数组*/
	UINT16 psdId = 0u;                                       /*屏蔽门ID*/
	UINT32 psdIdInterConn = 0u;                              /*互联互通4字节屏蔽门ID*/
	UINT8 startSigColour = 0u;								/*屏蔽门关联的出站进路始端信号机*/
	UINT8 psdState = 0u;                                     /*屏蔽门状态*/
	UINT16 ii = 0u;
	UINT8 kk = 0u;
	UINT16 sigId = 0u;				/*信号机ID*/
	UINT8 rowIndex  = 0u;
	UINT8 colIndex  = 0u;
	UINT32 curCycleNum = Get2oo2CurCycleNum();
	UINT32 appCycleTime = GetSystemParaAppCycleTime();
	UINT8 retVal = CI_SUCCESS;
	UINT8 localCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/
	UINT32 ciEtcsId = 0u;
	UINT32 vobcEtcsId = 0u;
	UINT32 emapCheckVer = 0u;
#if 0
	UINT8 sigIdx = 0u;/*信号机索引*/
	UINT8 sigDir = 0u;/*信号机运营方向*/
	UINT16 trackIdRelatePhySecId = 0u;/*轨道区段关联的物理区段ID*/
	UINT8 outStationSignalAllowOrNotUp = CI_VOBC_SIGNAL_DEFAULT;			/*上行信号机的允许或禁止状态*/
	UINT8 outStationSignalAllowOrNotDown = CI_VOBC_SIGNAL_DEFAULT;			/*下行信号机的允许或禁止状态*/
	UINT8 outStationSignalSum = 0u;/*出站信号机数目*/
#endif
	UINT8 ci_vobcPrtclVersion = 0u;
	UINT8 mutualLockState = 0u;
	UINT16 dstDevId = 0u;
	UINT8 outnetSafeSendRtn = 0u;
	UINT8 chPsdBelongCiId = 0U;
	UINT8 outStationSignalAllowOrNot = CI_VOBC_SIGNAL_DEFAULT;			/*信号机的允许或禁止状态*/
	UINT32 signalIdInterConn = 0u;	/*互联互通4字节信号机ID*/
	ci_vobcPrtclVersion = GetVersionOfVOBCToCI();


	/*首先获取组包时所需的信息，获取成功才有必要继续组包*/
	if ((CI_SUCCESS == dquDevName2HlhtId((CI_SYSTEM_TYPE_CI*256U) + localCiId,0U,&ciEtcsId)) && (CI_SUCCESS == dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC*256U) + (UINT8)(vobcToCiDataStru->VobcId),vobcToCiDataStru->vobcLogId,&vobcEtcsId)) && (CI_SUCCESS == GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC)))
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	if (CI_SUCCESS == retVal)
	{
		ii = 0u;

		/*开始组应用数据帧*/

		ShortToChar(CI_VOBC_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*接口信息类型*/
		ii += 2u;
		LongToChar(ciEtcsId, &CiToVobcDataBuffer[ii]);/*发送方标识信息*/
		ii += 4u;
		LongToChar(vobcEtcsId, &CiToVobcDataBuffer[ii]);/*接收方标识信息*/
		ii += 4u;
		LongToChar(emapCheckVer, &CiToVobcDataBuffer[ii]);/*电子地图版本校验信息*/
		ii += 4u;
		LongToChar(curCycleNum, &CiToVobcDataBuffer[ii]);/*本方消息序列号*/
		ii += 4u;
		ShortToChar((UINT16)appCycleTime, &CiToVobcDataBuffer[ii]);/*设备通讯周期*/
		ii += 2u;
		LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*对方消息序列号：recvOppMsgSN记录收到对方上一条消息中的对方消息序列号*/
		ii += 4u;
		LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*收到上一条消息时本方序列号*/
		ii += 4u;
		CiToVobcDataBuffer[ii++] = ci_vobcPrtclVersion;/*CI_VOBC接口协议版本号*/
		ii += 2u;/*通用报文头中的应用层报文总长度*/

		/*以下为应用层数据*/
		ii += 2u;/*报文长度*/

		ii += 2u;/*应用报文类型*/

		ii += 2u;/*预留两个字节*/

		if ((VOBC_CI_INFO_TYPE_PSD_CONTROL == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{/*只有当VOBC发送的信息类型是屏蔽门控制信息时，才组包如下内容；若信息类型为心跳帧，则只发送报文帧头（31+6）*/
			LongToChar(vobcToCiDataStru->trackSecID,&CiToVobcDataBuffer[ii]);/*回复收到的轨道区段ID,依据CI-VOBCV2.9接口文档修改*/
			ii += 4u;
			CiToVobcDataBuffer[ii++] = vobcToCiDataStru->psdCmdCode;   /*回复收到的状态开门码*/

			CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum;           /*屏蔽门数量*/

			for (kk = 0u; kk < 2u; kk++)
			{
				psdId = vobcToCiDataStru->PsdData[kk].PsdId; 
				psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn;
				chPsdBelongCiId = GetPsdBelongCiId(psdId);
				if (localCiId != chPsdBelongCiId)
				{/*未查到此屏蔽门的相关信息：即此屏蔽门不属于本联锁*/
					

					LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]);                     /*屏蔽门ID*/
					ii += 4U;

					CiToVobcDataBuffer[ii++] = PSD_STATE_INVALID_HLHT;                             /*屏蔽门状态*/

					CiToVobcDataBuffer[ii++] = PSD_INVALID_CMD;              /*屏蔽门命令类型*/
				}
				else
				{/*此屏蔽门属于本联锁*/
					LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]);                                                   /*屏蔽门ID*/
					ii += 4u;          
					mutualLockState = GetPsdMutualLockRemoveState(psdId);
					if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState)
						|| (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState))
					{/*屏蔽门互锁解除*/

						psdState = PSD_STATE_CLOSE_VIETNAM;/*关闭且锁闭*/
					}
					else
					{/*屏蔽门未互锁解除*/

						if (GetPsdState(psdId) == PSD_STATE_CLOSE)
						{/*屏蔽门关门*/

							psdState = PSD_STATE_CLOSE_VIETNAM;/*关闭且锁闭*/
						}
						else
						{
							psdState = PSD_STATE_OPEN_VIETNAM;/*非关闭且锁闭*/
						}
					}

					CiToVobcDataBuffer[ii++] = psdState;                                                            /*屏蔽门状态*/
					CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdData[kk].CmdType;                            /*屏蔽门命令类型*/
				}	

			}/*for (kk = 0; kk < vobcToCiDataStru->PsdSum; kk++)*/

			/*修改于20180111，修改原因：互联互通VOBC-CI接口回退（VOBC给CI不发送4字节信号机ID，CI也不回复信号机ID），适应越南线需求*/

			signalIdInterConn = vobcToCiDataStru->signalID;	/*互联互通4字节信号机ID*/
			/*回复收到的信号机ID,依据CI-VOBCV3.0接口文档修改*/
			LongToChar(signalIdInterConn,&CiToVobcDataBuffer[ii]);	
			ii += 4u;
			/*根据互联互通4字节ID获取信号机ID*/
			retVal = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, signalIdInterConn, &sigId);

			if (CI_SUCCESS == retVal)
			{
				startSigColour = GetSignalCurColor(sigId);/*获取信号机当前显示颜色*/
				
				if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*获取始端信号机开放状态*/
				{/*信号开放*/
					outStationSignalAllowOrNot = CI_VOBC_SIGNAL_YES;
				}
				else
				{
					outStationSignalAllowOrNot = CI_VOBC_SIGNAL_NO;
				}
			}

			/*CI接收到的VOBC发送的信号机ID的状态*/
			CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNot;              /*CI->VOBC信号机状态*/

#if 0
			/*先查找轨道区段对应的物理区段，获取以此物理区段为外方第一区段的信号机的数目，遍历之*/
			trackIdRelatePhySecId = GetTrackToPhySectionId(vobcToCiDataStru->trackSecID);
			outStationSignalSum = GetPhySecAsOutFirstPhySecSigSum(trackIdRelatePhySecId);/*获取以本物理区段为外方第一区段的信号机数目*/
			for (sigIdx = 0u;sigIdx < outStationSignalSum;sigIdx++)
			{
				sigId = GetPhySecAsOutFstPhySecSigId(trackIdRelatePhySecId,sigIdx);/*获取关联信号机Id*/
				sigDir = GetSignalOperDirection(sigId);/*获取信号机运营方向*/
				startSigColour = GetSignalCurColor(sigId);/*获取信号机当前显示颜色*/

				if (CI_SYSTEM_DIRECTION_UP == sigDir)
				{/*上行方向*/
					if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*获取始端信号机开放状态*/
					{/*信号开放*/
						outStationSignalAllowOrNotUp = CI_VOBC_SIGNAL_YES;
					}
					else
					{
						outStationSignalAllowOrNotUp = CI_VOBC_SIGNAL_NO;
					}
				} 
				else if (CI_SYSTEM_DIRECTION_DOWN == sigDir)
				{/*下行方向*/
					if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*获取始端信号机开放状态*/
					{/*信号开放*/
						outStationSignalAllowOrNotDown = CI_VOBC_SIGNAL_YES;
					}
					else
					{
						outStationSignalAllowOrNotDown = CI_VOBC_SIGNAL_NO;
					}
				}
				else
				{
					/*无操作*/
				}
			}	

			/*CI->VOBC上行和下行出站信号机状态*/
			CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNotUp;              /*CI_VOBC上行出站信号机状态*/
			CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNotDown;             /*CI_VOBC下行出站信号机状态*/
#endif
			ShortToChar(CI_VOBC_INFO_TYPE_PSD_STATE,&CiToVobcDataBuffer[33]);/*屏蔽门控制报文类型，两字节*/
		}
		else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{/*组心跳帧*/
			ShortToChar(CI_VOBC_INFO_TYPE_HEART_FRAME,&CiToVobcDataBuffer[33]);/*心跳帧报文类型，两字节*/
		}
		else if ((VOBC_CI_INFO_TYPE_LOGOUT_ASK == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{/*组注销请求回复帧*/
			ShortToChar(CI_VOBC_INFO_TYPE_LOGOUT_ACK,&CiToVobcDataBuffer[33]);/*注销请求回复帧报文类型，两字节*/
		}
		else
		{
			/*信息类型错误，什么都不做*/
		}

		/*通用报文头中应用层报文总长度*/
		CiToVobcDataBuffer[29U] = (UINT8) ((UINT8)((ii - 31U) >> 8u) & 0xffu);
		CiToVobcDataBuffer[30U] = (UINT8) ((ii - 31U) & 0xffu);

		/*应用层数据的报文长度 */
		CiToVobcDataBuffer[31U] = (UINT8) (((ii - 33U) >> 8u) & 0xffu);
		CiToVobcDataBuffer[32U] = (UINT8) ((ii - 33U) & 0xffu);

		dstDevId = ((UINT16)CI_SYSTEM_TYPE_VOBC << 8u) | vobcToCiDataStru->VobcId;
		outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &CiToVobcDataBuffer[0U], ii);
		if (1u == outnetSafeSendRtn)
		{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/                 
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
			debug_infor_printf((const)"\nVOBC_SEND:%d", ii);
			debug_out_array(0xAA, CiToVobcDataBuffer, ii);
#endif/*平台打印结束*/
#endif
		}
		else
		{
			/*写队列失败*/
			retVal = CI_ERROR;
		}
	}
	else
	{
	}

	return retVal;
}

/*
* 功能描述： 组FAOVOBC数据
* 参数说明： QueueStruct* CiToVobcDataQueue, 组包发送队列地址     
* 返回值  ： 0:组数据失败
*			 1:组数据成功      
*/
static UINT8 PackCiToVobcDataFAO(VobcToCiDataStruct *vobcToCiDataStru)
{
	UINT8 localCi = GetSystemParaLocalCiId();               /*本地联锁ID*/
	UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = {0u};/*CI到VOBC组帧数组*/
	UINT16 psdId = 0u;                                       /*屏蔽门ID*/
	UINT8 psdState = 0u;                                     /*屏蔽门状态*/
	UINT8 isPack = 0u;                                       /*是否组包发送标志*/
	UINT16 ii = 0u;
	UINT8 jj = 0u;
	UINT8 kk = 0u;
	UINT8 rowIndex  = 0u;
	UINT8 colIndex  = 0u;
	UINT32 faultIslutionInfo = 0u;
	UINT16 washMachineCurSum = GetWashMachineSum();        /*获取当前联锁包含洗车机数量*/
	UINT16 washMachineId = 0u;
	UINT32 psdOpenState = 0u;								/*每一扇屏蔽门的打开状态*/
	UINT8 CI_PSD_COMM_STATE[VOBC_TO_CI_TRAIN_PSD_MAX] = {0u};/*CI与PSD通信状态，默认故障。20151211增加*/
	UINT8 psdBelongStationId = 0u;                                     /*PSD所属站台ID*/
	UINT8 psdVirtAttr = 0u;									/*psd虚拟属性*/
	UINT8 retVal = CI_SUCCESS;
	UINT8 mutualLockState = 0u;
	UINT16 dstDevId = 0u;
	UINT8 outnetSafeSendRtn = 0u;

	for (jj = 0u;jj < VOBC_TO_CI_TRAIN_PSD_MAX;jj++)
	{/*初始化CI发送给VOBC的CI-PSD通信状态，默认故障0xAA。*/
		CI_PSD_COMM_STATE[jj] = CI_PSD_COMM_STATE_BAD;
	}

	/*当前认为一个联锁集中区最多有一个全自动洗车机*/
	if(1u == washMachineCurSum)
	{/*本联锁集中区有一台全自动洗车机*/
		washMachineId = GetWashMachineId(0u);            /*获取全自动洗车机ID*/
	}
	else
	{
	}

	
	isPack = 0u;
	if (Get2oo2CurCycleNum() == vobcToCiDataStru->ComStartCycle)
	{
		isPack=1u;
	}
	else
	{
		/*无操作*/
	}

	if (1u == isPack)
	{/*需发送此信息*/
		ii = 0u;


		/*开始组应用数据帧*/
		CiToVobcDataBuffer[ii++] = Get2oo2SheBeiType();
		CiToVobcDataBuffer[ii++] = localCi;
		CiToVobcDataBuffer[ii++] = CI_SYSTEM_TYPE_VOBC;
		CiToVobcDataBuffer[ii++] = (UINT8)vobcToCiDataStru->VobcId;

		CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum;                  /*屏蔽门数量*/

		for (kk = 0u; kk < vobcToCiDataStru->PsdSum; kk++)
		{
			psdId = vobcToCiDataStru->PsdData[kk].PsdId; 
			if (PSD_INVALID_ID == psdId)	/* 无效直接返回默认隔离信息 */
			{
				rowIndex = 0u;
				colIndex = 0u;
			} 
			else
			{
				rowIndex = PsdPlatformIndex[psdId][0U];                               /*获取映射点*/
				colIndex = PsdPlatformIndex[psdId][1U];	
			}
			if(0u == rowIndex)
			{/*未查到此屏蔽门的相关信息：即此屏蔽门不属于本联锁*/
				ShortToChar(psdId, &CiToVobcDataBuffer[ii]);                     /*屏蔽门ID*/
				ii += 2u;

				psdState = PSD_STATE_OPEN;
				CiToVobcDataBuffer[ii++] = psdState;                             /*屏蔽门状态*/                         

				CiToVobcDataBuffer[ii++] = PSD_DEFAULT_CONTROL_CMD;              /*屏蔽门命令类型*/

				LongToChar(PSD_DEFAULT_FAULT_ISOLATION,&CiToVobcDataBuffer[ii]); /*故障隔离信息*/
				ii += 4u;

				LongToChar(PSD_DEFAULT_ALL_OPEN_STATE,&CiToVobcDataBuffer[ii]);	/*单扇门的状态*/
				ii += 4u;

				CiToVobcDataBuffer[ii++] = PSD_BUTTON_STATE_UP;                  /*站台按钮状态*/

				CI_PSD_COMM_STATE[kk] = CI_PSD_COMM_STATE_BAD;					/*CI_PSD通信状态*/
			}
			else
			{/*此屏蔽门属于本联锁*/
				ShortToChar(psdId, &CiToVobcDataBuffer[ii]);                                                   /*屏蔽门ID*/
				ii += 2u;            

				psdVirtAttr = GetPsdVirtualAttribute(psdId);/*获取PSD虚拟属性*/

				if (PSD_VIRTUAL_ATTR_YES == psdVirtAttr)
				{/*若为虚拟屏蔽门则认为CI与PSD通信正常*/
					CI_PSD_COMM_STATE[kk] = CI_PSD_COMM_STATE_GOOD;/*CI-PSD通信良好*/
				} 
				else
				{/*非虚拟屏蔽门，判断CI与PSD通信状态*/
					psdBelongStationId = GetPsdBelongStationId(psdId);/*获取psd所属站台ID*/
					(void)UpdateCiTransmitState(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_PLATFORM, psdBelongStationId);/*更新联锁与站台通信状态*/

					if (TRANSMIT_STATE_GOOD == GetCiTransmitState(CI_SYSTEM_TYPE_PLATFORM,psdBelongStationId))/*获取与当前PSD的通信状态*/
					{
						CI_PSD_COMM_STATE[kk] = CI_PSD_COMM_STATE_GOOD;/*CI-PSD通信良好*/
					}
					else
					{
						CI_PSD_COMM_STATE[kk] = CI_PSD_COMM_STATE_BAD;/*CI-PSD通信故障*/
					}
				}
				
				/*获取互锁解除状态*/
				mutualLockState = GetPsdMutualLockRemoveState(psdId);
				if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState)
					|| (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState))
				{/*屏蔽门互锁解除*/

					psdState = PSD_STATE_CLOSE;/*关闭且锁闭*/

					if (PSD_VIRTUAL_ATTR_YES != psdVirtAttr)
					{/*非虚拟屏蔽门*/
						/*20161027新增需求：互锁解除且CI-PSD通信中断时，CI->VOBC发送每扇门状态为全部关闭，所有PSD门未隔离*/
						if (CI_PSD_COMM_STATE_BAD == CI_PSD_COMM_STATE[kk])
						{
							if (PSD_FOUR_EDIT_GROUP_FAO_YF == vobcToCiDataStru->trainEditGroupInfo)
							{/*4编组发送bit0-bit15*/
								platformToCiDataStru[rowIndex].psdDataStr[colIndex].psdState = 0xFFFF0000u;/*1打开，0关闭*/
								platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationReplyInfo = 0xFFFF0000u;/*0无故障隔离，未定义比特填1*/
							}
							else if (PSD_SIX_EDIT_GROUP_FAO_YF == vobcToCiDataStru->trainEditGroupInfo)
							{/*6编组发送bit0-bit23*/
								platformToCiDataStru[rowIndex].psdDataStr[colIndex].psdState = 0xFF000000u;
								platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationReplyInfo = 0xFF000000u;
							}
							else
							{/*编组信息错误，发送全部门打开和隔离*/
								platformToCiDataStru[rowIndex].psdDataStr[colIndex].psdState = PSD_DEFAULT_ALL_OPEN_STATE;
								platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationReplyInfo = PSD_DEFAULT_FAULT_ISOLATION;
							}

						}
						else
						{
						}
					}
					else
					{
					}
						
				}
				else
				{/*屏蔽门未互锁解除*/

					if (PSD_STATE_CLOSE == GetPsdState(psdId)  )
					{/*屏蔽门关门*/

						psdState = PSD_STATE_CLOSE;/*关闭且锁闭*/
					}
					else
					{
						psdState = PSD_STATE_OPEN;/*非关闭且锁闭*/
					}
				}

				CiToVobcDataBuffer[ii++] = psdState;                                                            /*屏蔽门状态*/
				CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdData[kk].CmdType;                            /*屏蔽门命令类型*/
				faultIslutionInfo = platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationReplyInfo;/*故障隔离信息*/
				LongToChar(faultIslutionInfo,&CiToVobcDataBuffer[ii]);
				ii += 4u;

				if (PSD_VIRTUAL_ATTR_YES == psdVirtAttr)
				{/*虚拟屏蔽门，单扇门的状态需CI判断*/
					if (PSD_STATE_OPEN == psdState)
					{/*门开状态*/
						if (PSD_FAULT_ISOLATION_SCX == faultIslutionInfo)
						{/*故障隔离*/
							psdOpenState = PSD_OPEN_STATE_SCX;/*除1和8外，其余均为开*/
						} 
						else
						{/*未故障隔离*/
							psdOpenState = PSD_DEFAULT_ALL_OPEN_STATE;/*门全开状态*/
						}
							
					} 
					else
					{/*门关状态*/
						/*故障和非故障全部发送关闭*/
						psdOpenState = 0;/*全部单扇门状态为关闭*/
					}
				} 
				else
				{/*真实屏蔽门，单扇门状态从PSD->CI通信接口获取*/
					psdOpenState = platformToCiDataStru[rowIndex].psdDataStr[colIndex].psdState;
				}
				LongToChar(psdOpenState,&CiToVobcDataBuffer[ii]);
				ii += 4u;

				CiToVobcDataBuffer[ii++] = GetPsdButtonState(psdId);                                            /*站台按钮状态*/

			}					

		}/*for (kk = 0; kk < vobcToCiDataStru->PsdSum; kk++)*/

		if (1U == washMachineCurSum)
		{/*本联锁集中区有洗车机*/
			CiToVobcDataBuffer[ii++] = GetWashMachineRequestVerifySta(washMachineId);   /*洗车请求反馈*/
			CiToVobcDataBuffer[ii++] = GetHeadWashAllowState(washMachineId);              /*头端洗位洗完移动指令*/
			CiToVobcDataBuffer[ii++] = GetTailWashAllowState(washMachineId);              /*尾端洗位洗完移动指令*/
			CiToVobcDataBuffer[ii++] = GetTrainEmergencyStopState(washMachineId);         /*洗车机故障状态*/
			CiToVobcDataBuffer[ii++] = GetTrainOutWashPortAllowSta(washMachineId); /*洗车完成允许列车通过*/

		}
		else
		{/*本联锁集中区没有洗车机，发送默认值*/
			CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_REQUEST_INVALID;
			CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_HEADWASH_NO;
			CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_TAILWASH_NO ;
			CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_FALUT_NO ;
			CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_OUT_NO;
		}

		for (kk = 0u; kk < vobcToCiDataStru->PsdSum; kk++)
		{
			CiToVobcDataBuffer[ii++] = CI_PSD_COMM_STATE[kk];/*组CI->VOBC CI-PSD通信状态*/
		}

		ii += 8u;/*预留8字节，默认值0x00,用于未来扩展*/


		dstDevId = (UINT16)(CI_SYSTEM_TYPE_VOBC << 8u) | vobcToCiDataStru->VobcId;
		outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &CiToVobcDataBuffer[0], ii);
		if (1u == outnetSafeSendRtn)
		{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/                 
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
			debug_infor_printf((const)"\nVOBC_SEND:%d", ii);
			debug_out_array(0xAA, CiToVobcDataBuffer, ii);
#endif/*平台打印结束*/

#endif
		}
		else
		{
			retVal = CI_ERROR;
		}
	}
	else
	{
	}

	return retVal;
}

/*
* 功能描述： 组互联互通CI->VOBC心跳帧
* 参数说明： 
*            const UINT8 vobcId 目标VOBC ID
*            const UINT16 logId 目标VOBC 的逻辑ID（1端或2端）
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
static UINT8 PackCiToVobcDataHLHTHeart(const UINT8 vobcId, const UINT16 logId)
{
	UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = { 0u };/*CI到VOBC组帧数组*/
	UINT32 curCycleNum = Get2oo2CurCycleNum();
	UINT32 appCycleTime = GetSystemParaAppCycleTime();
	UINT16 ii = 0u;

	UINT8 retVal = CI_ERROR;
	UINT8 localCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/
	UINT32 ciEtcsId = 0u;
	UINT32 vobcEtcsId = 0u;
	UINT32 emapCheckVer = 0u;
	UINT8 lineIdentity = 0u;
	UINT8 ci_vobcPrtclVersion = 0u;
	UINT16 dstDevId = 0u;
	UINT8 outnetSafeSendRtn = 0u;
	UINT8 functionreturn= 0u;

	ci_vobcPrtclVersion = GetVersionOfVOBCToCI();
	functionreturn = dquDevName2HlhtId(((UINT16)CI_SYSTEM_TYPE_CI * 256U + localCiId),0U,&ciEtcsId)  ;
    functionreturn &= dquDevName2HlhtId(((UINT16)CI_SYSTEM_TYPE_VOBC *256U) + vobcId,logId,&vobcEtcsId);
	functionreturn &= GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC);
	/*首先获取组包时所需的信息，获取成功才有必要继续组包*/
	if (CI_SUCCESS ==  functionreturn)
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	if (CI_SUCCESS == retVal)
	{
		lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*获取VOBC-CI接口标识*/

		ii = 0u;

		/*开始组应用数据帧*/
		if (LINE_CC == lineIdentity)
		{
			ShortToChar(IVOC_CI_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*接口信息类型*/
			ii += 2u;
		}
		else
		{
			ShortToChar(CI_VOBC_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*接口信息类型*/
			ii += 2u;
		}

		
		LongToChar(ciEtcsId, &CiToVobcDataBuffer[ii]);/*发送方标识信息*/
		ii += 4u;
		LongToChar(vobcEtcsId, &CiToVobcDataBuffer[ii]);/*接收方标识信息*/
		ii += 4u;
		LongToChar(emapCheckVer, &CiToVobcDataBuffer[ii]);/*电子地图版本校验信息*/
		ii += 4u;
		LongToChar(curCycleNum, &CiToVobcDataBuffer[ii]);/*本方消息序列号*/
		ii += 4u;
		ShortToChar((UINT16)appCycleTime, &CiToVobcDataBuffer[ii]);/*设备通讯周期*/
		ii += 2u;
		LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, vobcId), &CiToVobcDataBuffer[ii]);/*对方消息序列号：收到对方上一条消息中的对方消息序列号*/
		ii += 4u;
		LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, vobcId), &CiToVobcDataBuffer[ii]);/*收到上一条消息时本方序列号*/
		ii += 4u;
		if (LINE_HLHT == lineIdentity)
		{/*互联互通线路*/
			CiToVobcDataBuffer[ii++] = ci_vobcPrtclVersion;/*CI_VOBC接口协议版本号*/
		} 
		else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity)|| (LINE_FAOHLHT_ONESELFSECOND == lineIdentity))
		{/*互联互通+FAO线路*/
			CiToVobcDataBuffer[ii++] = CI_VOBC_PRTCL_VER_FAOHLHT;/*CI_VOBC接口协议版本号*/
		}
		else if (LINE_CC == lineIdentity)
		{/*互联互通+FAO线路*/
			CiToVobcDataBuffer[ii++] = CI_IVOC_PRTCL_VER;/*CI_VOBC接口协议版本号*/
		}
		else
		{/*其他线路类型，组初始值0*/
			ii++;
		}

		ii += 2u;/*通用报文头中的应用层报文总长度*/

		/*以下为应用层数据*/
		ii += 2u;/*报文长度*/

		ii += 2u;/*应用报文类型*/

		ii += 2u;/*预留两个字节*/
		if(LINE_CC == lineIdentity)
		{/*互联互通+FAO线路*/
			ShortToChar(CI_IVOC_INFO_TYPE_HEART_FRAME, &CiToVobcDataBuffer[33]);/*心跳帧报文类型，两字节*/
		}
		else {
			/*组心跳帧*/
			ShortToChar(CI_VOBC_INFO_TYPE_HEART_FRAME, &CiToVobcDataBuffer[33]);/*心跳帧报文类型，两字节*/
		}
		/*通用报文头中应用层报文总长度*/
		CiToVobcDataBuffer[29U] = (UINT8)((UINT8)((ii - 31U) >> 8u) & 0xffu);
		CiToVobcDataBuffer[30U] = (UINT8)((ii - 31U) & 0xffu);

		/*应用层数据的报文长度 */
		CiToVobcDataBuffer[31U] = (UINT8)((UINT8)((ii - 33U) >> 8u) & 0xffu);
		CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffu);

		dstDevId = (UINT16)(CI_SYSTEM_TYPE_VOBC << 8U) | ((UINT16)vobcId);
		outnetSafeSendRtn = OutnetSafeSend(dstDevId, logId, &CiToVobcDataBuffer[0U], ii);
		if(1u == outnetSafeSendRtn)
		{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/                 
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
			debug_infor_printf((const)"\nVOBC_SEND:%d", ii);
			debug_out_array(0xAA, CiToVobcDataBuffer, ii);
#endif/*平台打印结束*/
#endif
			retVal = CI_SUCCESS;
		}
		else
		{
			/*写队列失败*/
			retVal = CI_ERROR;
		}
	}
	else
	{
	}

	return retVal;
}

/*
* 功能描述： 解析处理FAO+HLHT VOBC单帧数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            const UINT8 systemId, 源设备ID
*            VobcToCiDataStru vobcToci数据结构体指针
*			 UINT8* saveGalHead,通用报文头是否保留,1:保留，0:不保留
*            const UINT16 logId，互联互通4IP VOBC的1端或2端标识  
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功
*/
static UINT8 ParseVobcToCiDataFrameFAOHLHT(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* vobcToCiDataStru, UINT8* saveGalHead,const UINT16 logId)
{
	UINT8 cmdType = 0u;							 /*屏蔽门命令类型*/
	UINT8 trainStopSteadyState = 0u;				/*列车停稳状态*/
	UINT8 psdSum = 0u;
	UINT8 trainDirection = 0u;					/*列车方向*/
	UINT16 ii = 0u;                                /*索引管理*/
	UINT8 jj = 0u;
	UINT8 retVal = CI_SUCCESS;
	UINT8 retValue = 0u;
	UINT16 psdId = 0u;                            /*PSD的ID*/
	UINT16 appInfoType = 0u;						 /*应用信息类型*/
	UINT32 psdIdIntConnt = 0u;                    /*互联互通PSD的ID*/
	UINT32 trackSectionId = 0u;					 /*轨道区段ID*/
	UINT32 curntCycleNo = 0u;					/*当前周期号*/
	UINT16 vobcName = 0u;						/*VOBC设备名称：类型+ID*/
	UINT16 ciName = 0u;							/*联锁设备名称：类型+ID*/
	UINT8 localCiId = GetSystemParaLocalCiId();/*联锁ID*/
	UINT32 errCode = 0u;
	HLHTGALInfoStruct hlhtGalHead = { 0u };
	INT32 vobcInfoRemainValidiy = 0;
	UINT8 headRet = HLHT_HEAD_ERROR;/*互联互通检查结果*/
	UINT32 signalId = 0u;		/*VOBC->CI信号机ID*/
	UINT8 gapDetCmdType = 0u;	/*间隙探测命令类型*/
	UINT8 doorState = 0u;        /*VOBC-CI关联车门状态*/
	UINT8 cTempPsdCmdCode = 0U;
	UINT8 chVideoQkState = 0U;/*视频清客状态*/
	UINT8 chVideoQkResult = 0U;/*视频清客结果*/
	UINT16 wMsgLen = 0U;/*一条应用数据长度*/
	UINT16 wTmpDataLen = 0U;/*临时长度记录*/
	UINT16 wMsgCheckLen = 0u;			/* 用于解析校验的数据长度 */
	UINT16 wTempDataLenIndex = 0U;/*临时数据长度索引*/

	vobcName = (CI_SYSTEM_TYPE_VOBC)*256U + systemId;
	ciName = (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();

	vobcToCiDataStru->vobcLogId = logId;/*存储VOBC的逻辑ID，1端或2端*/
	/*（通用消息包头校验通过 && 报文生存时间有效）才继续解析其他信息*/
	/*第一次收到VOBC消息时校验不通过，只记录curntOwnMsg以及当前本方软件周期号*/
	headRet = HLHTRecvCommonPacketHeadCheck(vobcName, ciName, CI_VOBC_INTERFACE_INFOTYPE, CI_VOBC_PRTCL_VER_FAOHLHT, &hlhtGalHead, &errCode, logId, CI_SYSTEM_TYPE_VOBC);

	debug_infor_printf((const)"\nVOBC %d GAL Check Result:%d errCode:%d", systemId,headRet,errCode);	/*0x55正确，0xaa错误，0x33初始通信帧*/

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

		if (vobcInfoRemainValidiy > 0)
		{
			if (6U > hlhtGalHead.totalDataLen)
			{
				retVal = CI_ERROR;
			}
			else 
			{
				while (wTmpDataLen < hlhtGalHead.totalDataLen)
				{
					/*后备运行控制信息每周期均发送，需要时刻循环*/
					/* 一条应用数据长度 */
					wMsgLen = ShortFromChar(&dataBuf[ii]);
					ii += 2U;
					wTempDataLenIndex = ii + wMsgLen;
					
					if (4U > wMsgLen)
					{
						retVal = CI_ERROR;
					}
					else
					{
						appInfoType = ShortFromChar(&dataBuf[ii]);/*应用信息类型，屏蔽门控制信息或者心跳帧信息*/
						ii += 2U;
						if (VOBC_CI_INFO_TYPE_BACKUU_CONTROL != appInfoType)
						{
							vobcToCiDataStru->appInfoType = appInfoType;
						}
						else
						{
							; /*不更新*/
						}
						vobcToCiDataStru->VobcId = systemId;

						ii += 2u;/*跳过两个预留字节*/

						if (VOBC_CI_INFO_TYPE_PSD_CONTROL == appInfoType)
						{
							wMsgCheckLen = wMsgLen - 4U + 2U + ShortFromChar(&dataBuf[wTempDataLenIndex]);
						}
						else
						{
							wMsgCheckLen = wMsgLen - 4U;
						}

						wTmpDataLen += 2U;/*本数据长度*/
						wTmpDataLen = wTmpDataLen + wMsgCheckLen + 4U;/*除了类型和预留的4个字节*/
						
						switch (appInfoType)
						{
						case VOBC_CI_INFO_TYPE_PSD_CONTROL:
						case VOBC_CI_INFO_TYPE_FAO_INFO:
						case VOBC_CI_INFO_TYPE_HEART_FRAME:
						case VOBC_CI_INFO_TYPE_LOGOUT_ASK:
							retVal = ParseFAOHLHTOtherTypeData(appInfoType,&dataBuf[ii], wMsgCheckLen,systemId,vobcToCiDataStru);
							break;
						case VOBC_CI_INFO_TYPE_BACKUU_CONTROL:
							retVal = ParseFAOHLHTBackUpControlData(&dataBuf[ii],wMsgCheckLen, vobcToCiDataStru);
							break;
						default:
							retVal = CI_ERROR;
							break;
						}

						if (CI_SUCCESS == retVal)
						{
							/* 解析成功，跳过该数据包 */
							ii += wMsgCheckLen;
						}
						else
						{
							debug_infor_printf((const)"\nVOBC %d appInfoType CHECK ERR,appInfoType:%d", vobcToCiDataStru->VobcId, appInfoType);
							break;
						}
					}
				}
			}

			if (CI_SUCCESS == retVal)
			{
				/*校验数据长度*/
				if (ii > dataLength)
				{
					debug_infor_printf((const)"\nVOBC %d DATALEN CHECK ERR,dataLen:%d,ii:%d", vobcToCiDataStru->VobcId, dataLength, ii);

					retVal = CI_ERROR;
				}
			}

			if (CI_SUCCESS == retVal)
			{
				/*数据经过校验，需要存储通用报文上下文*/
				SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod);
				SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN);
				SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN);
				SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN);
				SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo);
				SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId);

				*saveGalHead = 1u;
			}
		}
		else
		{
			retVal = CI_ERROR;
		}
	}
	else if (HLHT_HEAD_INIT ==headRet)
	{
		if (curntCycleNo > 0u)/*判断序号大于0，因为把0当做无效序号*/
		{
			SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod);
			SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN);
			SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN);
			SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN);
			SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo);
			SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId);

			*saveGalHead = 1u;
		}

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

	return retVal;
}

/*
* 功能描述： 组(FAO+HLHT)VOBC数据
* 参数说明： VobcToCiDataStruct *vobcToCiDataStru,vobc给CI数据结构体     
* 返回值  ： 0:组数据失败
*			 1:组数据成功      
*/
static UINT8 PackCiToVobcDataFAOHLHT(VobcToCiDataStruct *vobcToCiDataStru)
{
	UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = {0u};/*CI到VOBC组帧数组*/
	UINT16 psdId = 0u;                                       /*屏蔽门ID*/
	UINT32 psdIdInterConn = 0u;                              /*互联互通4字节屏蔽门ID*/
	UINT8 startSigColour = 0u;								/*屏蔽门关联的出站进路始端信号机*/
	UINT8 psdState = 0u;                                     /*屏蔽门状态*/
	UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT8 kk = 0u;
	UINT16 sigId = 0u;				/*信号机ID*/
	UINT32 curCycleNum = Get2oo2CurCycleNum();
	UINT32 appCycleTime = GetSystemParaAppCycleTime();
	UINT8 retVal = CI_SUCCESS;
	UINT8 chTempCheckFlag = CI_ERROR;
	UINT8 localCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/
	UINT32 ciEtcsId = 0u;
	UINT32 vobcEtcsId = 0u;
	UINT32 emapCheckVer = 0u;
	UINT8 outStationSignalAllowOrNot = CI_VOBC_SIGNAL_DEFAULT;			/*信号机的允许或禁止状态*/
	UINT32 signalIdInterConn = 0u;	/*互联互通4字节信号机ID*/
	UINT16 washMachineCurSum = GetWashMachineSum();        /*获取当前联锁包含洗车机数量*/
	UINT16 washMachineId = 0u;
	UINT8 psdValidFlag[2] = {0u,0u};							/*0无效，1有效*/
	UINT8 psdReopenButtState = 0u;                           /*站台再次开门按钮状态*/
	UINT8 platDepartButtState = 0u;                          /*站台发车按钮状态*/
	UINT8 psdCloseButtState = 0u;                            /*屏蔽门状态*/
	UINT8 gapDetStatus = 0u;									/*间隙探测状态*/
	UINT8 gapDetMutualLockRemvSta = 0u;						/*间隙探测互锁解除状态*/
	UINT32 psdStartDetCycNum = 0u;							/*PSD间隙探测开始周期*/
	UINT8 psdButtonPangluState = 0u;                         /*站台按钮旁路状态*/ 
	UINT8 washMachineState = 0u;                             /*洗车机故障状态*/ 
	UINT8 mutualLockState = 0u;                             /*互锁解除状态*/
	UINT16 psdDepartureButtonRelayId = 0u;                  /*站台发车按钮继电器*/
	UINT8 localhlhtId = 0u;
	UINT8 vobcHlhtId = 0u;
	UINT8 ciEmapCheckVer = 0u;
	UINT16 dstDevId = 0;
	UINT8 chPsdBelongCiId = 0U;
	UINT8 outnetSafeSendRtn = 0u;
	UINT16 wTempSendIndex = 0U;

	/*首先获取组包时所需的信息，获取成功才有必要继续组包*/
	localhlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI*256U) + localCiId,0U,&ciEtcsId);
	vobcHlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC*256U) + (UINT8)(vobcToCiDataStru->VobcId),vobcToCiDataStru->vobcLogId,&vobcEtcsId);
	ciEmapCheckVer = GetCiEmapCheckVer(localCiId, &emapCheckVer,CI_SYSTEM_TYPE_VOBC);
	if ((CI_SUCCESS == localhlhtId) && (CI_SUCCESS == vobcHlhtId) &&	(CI_SUCCESS == ciEmapCheckVer))
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	debug_infor_printf((const)"\nPack vobc %d data,retVal = %d\n", vobcToCiDataStru->VobcId,retVal);	/*打印错误信息*/

	if (CI_SUCCESS == retVal)
	{
		ii = 0u;

		/*开始组应用数据帧*/

		ShortToChar(CI_VOBC_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*接口信息类型*/
		ii += 2u;
		LongToChar(ciEtcsId, &CiToVobcDataBuffer[ii]);/*发送方标识信息*/
		ii += 4u;
		LongToChar(vobcEtcsId, &CiToVobcDataBuffer[ii]);/*接收方标识信息*/
		ii += 4u;
		LongToChar(emapCheckVer, &CiToVobcDataBuffer[ii]);/*电子地图版本校验信息*/
		ii += 4u;
		LongToChar(curCycleNum, &CiToVobcDataBuffer[ii]);/*本方消息序列号*/
		ii += 4u;
		ShortToChar((UINT16)appCycleTime, &CiToVobcDataBuffer[ii]);/*设备通讯周期*/
		ii += 2u;
		LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*对方消息序列号：recvOppMsgSN记录收到对方上一条消息中的对方消息序列号*/
		ii += 4u;
		LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*收到上一条消息时本方序列号*/
		ii += 4u;
		CiToVobcDataBuffer[ii++] = CI_VOBC_PRTCL_VER_FAOHLHT;/*HLHT+FAO_CI_VOBC接口协议版本号*/
		ii += 2u;/*通用报文头中的应用层报文总长度*/

		if ((VOBC_CI_INFO_TYPE_PSD_CONTROL == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{/*只有当VOBC发送的信息类型是屏蔽门控制信息时，才组包如下内容；若信息类型为心跳帧，则只发送报文帧头（31+6）*/

			ii += 2u;/*报文长度*/
			ii += 2u;/*应用报文类型*/
			ii += 2u;/*预留两个字节*/

			LongToChar(vobcToCiDataStru->trackSecID, &CiToVobcDataBuffer[ii]);/*回复收到的轨道区段ID*/
			ii += 4u;
			CiToVobcDataBuffer[ii++] = vobcToCiDataStru->psdCmdCode;   /*回复收到的状态开门码*/

			CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum;           /*屏蔽门数量*/

			for (kk = 0u; kk < 2u; kk++)
			{
				psdId = vobcToCiDataStru->PsdData[kk].PsdId;
				psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn;
				chPsdBelongCiId = GetPsdBelongCiId(psdId);
				if (localCiId != chPsdBelongCiId)
				{/*未查到此屏蔽门的相关信息：即此屏蔽门不属于本联锁*/
					psdValidFlag[kk] = 0u;

					LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]);                     /*屏蔽门ID*/
					ii += 4u;

					CiToVobcDataBuffer[ii++] = PSD_STATE_INVALID_HLHT;                             /*屏蔽门状态*/

					CiToVobcDataBuffer[ii++] = PSD_INVALID_CMD;              /*屏蔽门命令类型*/
				}
				else
				{/*此屏蔽门属于本联锁*/
					psdValidFlag[kk] = 1u;
					/*互锁解除状态*/
					mutualLockState = GetPsdMutualLockRemoveState(psdId);
					LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]);                                                   /*屏蔽门ID*/
					ii += 4u;

					if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState)
						|| (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState))
					{/*屏蔽门互锁解除*/

						psdState = PSD_STATE_CLOSE_VIETNAM;/*关闭且锁闭*/
					}
					else
					{/*屏蔽门未互锁解除*/

						if (GetPsdState(psdId) == PSD_STATE_CLOSE)
						{/*屏蔽门关门*/

							psdState = PSD_STATE_CLOSE_VIETNAM;/*关闭且锁闭*/
						}
						else
						{
							psdState = PSD_STATE_OPEN_VIETNAM;/*非关闭且锁闭*/
						}
					}

					CiToVobcDataBuffer[ii++] = psdState;                                                            /*屏蔽门状态*/
					CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdData[kk].CmdType;                            /*屏蔽门命令类型*/
				}

			}/*for (kk = 0; kk < vobcToCiDataStru->PsdSum; kk++)*/

			signalIdInterConn = vobcToCiDataStru->signalID;	/*互联互通4字节信号机ID*/

			LongToChar(signalIdInterConn, &CiToVobcDataBuffer[ii]);/*回复收到的信号机ID*/
			ii += 4u;
			/*根据互联互通4字节ID获取信号机ID*/
			chTempCheckFlag = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, signalIdInterConn, &sigId);

			if (CI_SUCCESS == chTempCheckFlag)
			{
				startSigColour = GetSignalCurColor(sigId);/*获取信号机当前显示颜色*/

				if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*获取始端信号机开放状态*/
				{/*信号开放*/
					outStationSignalAllowOrNot = CI_VOBC_SIGNAL_YES;
				}
				else
				{
					outStationSignalAllowOrNot = CI_VOBC_SIGNAL_NO;
				}
			}
			else
			{
			}

			/*CI接收到的VOBC发送的信号机ID的状态*/
			CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNot;              /*CI->VOBC信号机状态*/

			ShortToChar(CI_VOBC_INFO_TYPE_PSD_STATE, &CiToVobcDataBuffer[33U]);/*屏蔽门控制报文类型，两字节（6+31+2）*/
			/*填充CI2VOBC状态信息长度*/
			CiToVobcDataBuffer[31U] = (UINT8)(((ii - 33U) >> 8u) & 0xffu);
			CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffu);

			/*根据文档《区域轨道交通全自动运行信号系统互联互通VOBC-CI接口规格书-v1.6-20190109》修改，2019.02.20*/
			/*CI->VOBC全自动运行站台状态信息应用报文头*/
			ii += 2u;	/*报文长度*/
			ShortToChar(CI_VOBC_PLAT_CLEAR_PASSENGER_INFO, &CiToVobcDataBuffer[ii]);
			ii += 2u;	/*报文类型：全自动运行站台状态信息*/
			ii += 2u;	/*预留2字节*/

			/*CI2VOBC全自动运行站台状态信息，始终与CI2VOBC状态信息一同发送，如站台无相关按钮则发送默认值*/
			CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum;           /*屏蔽门数量*/
			for (kk = 0u; kk < 2u; kk++)
			{
				psdId = vobcToCiDataStru->PsdData[kk].PsdId;
				psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn;

				chPsdBelongCiId = GetPsdBelongCiId(psdId);
				LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]);                                                   /*屏蔽门ID*/
				ii += 4u;

				if (localCiId != chPsdBelongCiId)
				{

					CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;	/*站台关门按钮默认值*/
					CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;	/*站台开门按钮默认值*/
					CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;	/*站台发车按钮默认值*/
					CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_DEFAULT;	/*间隙探测状态默认值：未检测/无此功能*/
				}
				else
				{/*屏蔽门ID有效*/
					/*获取全自动运行站台状态信息并组包发送给VOBC*/
					psdButtonPangluState = GetPsdButtonPangluState(psdId);
					if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState)
					{
						CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;    /*站台关门按钮默认值*/
					}
					else
					{
						psdCloseButtState = GetPsdButtonState(psdId);/*站台关门按钮状态*/
						if (CI_TIME_OUT == SystemOverTimeCheck(GetPCBPressCycNum(psdId), GetPsdButtonPressCount()))
						{
							CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;
						}
						else
						{
							CiToVobcDataBuffer[ii++] = psdCloseButtState;
						}
					}
					if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState)
					{
						CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;    /*站台开门按钮默认值*/
					}
					else
					{

						psdReopenButtState = GetPsdOpenButtonState(psdId);/*站台开门按钮状态*/
						if (CI_TIME_OUT == SystemOverTimeCheck(GetPOBPressCycNum(psdId), GetPsdButtonPressCount()))
						{
							CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;
						}
						else
						{
							CiToVobcDataBuffer[ii++] = psdReopenButtState;
						}
					}
					psdDepartureButtonRelayId = GetPsdDeparConfmRelayId(psdId);
					/*屏蔽门发车按钮状态更新*/
					if ((0u != psdDepartureButtonRelayId) && (UINT16_MAX != psdDepartureButtonRelayId))
					{/*站台发车按钮继电器ID有效*/
						if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState)
						{
							CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;    /*站台关门按钮默认值*/
						}
						else
						{
							platDepartButtState = GetPsdDepartButtonState(psdId);/*站台发车按钮状态*/
							if (CI_TIME_OUT == SystemOverTimeCheck(GetPSBPressCycNum(psdId), GetPsdButtonPressCount()))
							{
								CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;
							}
							else
							{
								CiToVobcDataBuffer[ii++] = platDepartButtState;
							}
						}
					}
					else
					{/*无站台发车按钮给VOBC发送站台无发车按钮状态*/
						CiToVobcDataBuffer[ii++] = PLATFORM_DEPAR_BUTTON_NO;
					}
					gapDetStatus = GetPsdRemoraState(psdId);	/*获取间隙探测状态*/
					gapDetMutualLockRemvSta = GetJXTCMutualLockState(psdId);	/*获取间隙探测互锁解除状态*/
					psdStartDetCycNum = GetStartDetectionCycNum(psdId);			/*获取间隙探测启动开始周期*/

					if (((PSD_REMORA_NO == gapDetStatus) && (0u != psdStartDetCycNum))
						|| (JXTC_MUTUALLOCK_REMOVE_YES == gapDetMutualLockRemvSta))
					{/*无障碍物或间隙探测互锁解锁*/
						CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_CLEAR;	/*无障碍物*/
					}
					else if ((PSD_REMORA_YES == gapDetStatus) && (0u != psdStartDetCycNum))
					{/*检测结果为有障碍物*/
						CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_UNCLEAR;	/*有障碍物*/
					}
					else
					{/*其他情况发送默认值*/
						CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_DEFAULT;	/*间隙探测状态默认值：未检测/无此功能*/
					}
				}
			}

			/*填充站台状态信息应用报文长度*/
			CiToVobcDataBuffer[60U] = (UINT8)(((ii - 62U) >> 8u) & 0xffu);
			CiToVobcDataBuffer[61U] = (UINT8)((ii - 62U) & 0xffu);
		}
		else if ((VOBC_CI_INFO_TYPE_FAO_INFO == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{/*组全自动运行洗车信息帧*/

			ii += 2u;/*报文长度*/
			ii += 2u;/*应用报文类型*/
			ii += 2u;/*预留两个字节*/
				/*当前认为一个联锁集中区最多有一个全自动洗车机*/
			if (1U == washMachineCurSum)
			{/*本联锁集中区有一台全自动洗车机*/
				washMachineId = GetWashMachineId(0u);                            /*获取全自动洗车机ID*/
				washMachineState = GetTrainEmergencyStopState(washMachineId);   /*获取全自动洗车机状态*/
			}

			/*全自动洗车相关信息*/
			if (1U == washMachineCurSum)
			{/*本联锁集中区有洗车机*/
				CiToVobcDataBuffer[ii++] = GetWashMachineRequestVerifySta(washMachineId);   /*1洗车请求确认：0x55允许洗车，0xaa不允许洗车*/
				CiToVobcDataBuffer[ii++] = GetHeadWashAllowState(washMachineId);              /*2允许通过1：0x55允许通过，0xaa禁止通过*/
				CiToVobcDataBuffer[ii++] = GetTailWashAllowState(washMachineId);              /*3允许通过2：0x55允许通过，0xaa禁止通过*/
				CiToVobcDataBuffer[ii++] = GetTrainOutWashPortAllowSta(washMachineId); /*4允许通过洗车区：0x55允许通过，0xaa禁止通过*/
				CiToVobcDataBuffer[ii++] = washMachineState;                                  /*5洗车机故障：0x55无故障，0xaa故障*/
			}
			else
			{/*本联锁集中区没有洗车机,发送默认值,洗车机故障状态发送采集信息*/
				CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_REQUEST_INVALID;
				CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_HEADWASH_NO;
				CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_TAILWASH_NO;
				CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_OUT_NO_2;
				CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_FALUT_NO;
			}

			ShortToChar(CI_VOBC_INFO_TYPE_FAO_INFO, &CiToVobcDataBuffer[33]);/*全自动运行洗车帧报文类型，两字节*/

			/*填充全自动运行洗车应用报文信息长度*/
			CiToVobcDataBuffer[31] = (UINT8)(((ii - 33u) >> 8u) & 0xffu);
			CiToVobcDataBuffer[32] = (UINT8)((ii - 33u) & 0xffu);
		}
		else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{/*组心跳帧*/

			ii += 2u;/*报文长度*/
			ii += 2u;/*应用报文类型*/
			ii += 2u;/*预留两个字节*/
			ShortToChar(CI_VOBC_INFO_TYPE_HEART_FRAME, &CiToVobcDataBuffer[33]);/*心跳帧报文类型，两字节*/

			/*填充应用层信息长度*/
			CiToVobcDataBuffer[31] = (UINT8)((UINT8)((ii - 33u) >> 8u) & 0xffu);
			CiToVobcDataBuffer[32] = (UINT8)((ii - 33u) & 0xffu);
		}
		else if ((VOBC_CI_INFO_TYPE_LOGOUT_ASK == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{/*组注销请求回复帧*/

			ii += 2u;/*报文长度*/
			ii += 2u;/*应用报文类型*/
			ii += 2u;/*预留两个字节*/

			ShortToChar(CI_VOBC_INFO_TYPE_LOGOUT_ACK, &CiToVobcDataBuffer[33]);/*注销请求回复帧报文类型，两字节*/

			/*填充应用层信息长度*/
			CiToVobcDataBuffer[31] = (UINT8)((UINT8)((ii - 33u) >> 8u) & 0xffu);
			CiToVobcDataBuffer[32] = (UINT8)((ii - 33u) & 0xffu);
		}
		else
		{
			/*信息类型错误，什么都不做*/
		}

		if ((CI_SUCCESS == retVal) && (curCycleNum == vobcToCiDataStru->ComStartCycle) && (0u != vobcToCiDataStru->wTrainMaxSafeHeadLink) && (UINT16_MAX != vobcToCiDataStru->wTrainMaxSafeHeadLink))
		{
			/*当周期收到数据且510主用通道后备信息帧位置有效（当前VOBC发送了后备信息帧才回复）*/
			wTempSendIndex = ii;

			ii += 2U;	/*报文长度*/
			ShortToChar(CI_VOBC_BACKUP_STATE_INFO, &CiToVobcDataBuffer[ii]);
			ii += 2U;	/*报文类型*/
			ii += 2U;	/*预留2字节*/
			
			retVal = PackCiToVobcBackUpStateData(CiToVobcDataBuffer, &ii, vobcToCiDataStru);

			if (CI_SUCCESS == retVal)
			{

				/*填充应用层信息长度*/
				CiToVobcDataBuffer[wTempSendIndex] = (UINT8)((UINT8)((ii - wTempSendIndex - 2U) >> 8U) & 0xffU);
				CiToVobcDataBuffer[wTempSendIndex + 1U] = (UINT8)((ii - wTempSendIndex - 2U) & 0xffU);
			}
			else
			{
				; /*组包错误*/
			}
		}
		else
		{
			;
		}

		if (CI_SUCCESS == retVal)
		{
			/*通用报文头中应用层报文总长度*/
			CiToVobcDataBuffer[29U] = (UINT8)((UINT8)((ii - 31U) >> 8u) & 0xffu);
			CiToVobcDataBuffer[30U] = (UINT8)((ii - 31U) & 0xffu);

			dstDevId = (UINT16)(CI_SYSTEM_TYPE_VOBC << 8u) | vobcToCiDataStru->VobcId;
			outnetSafeSendRtn = OutnetSafeSend(dstDevId, (vobcToCiDataStru->vobcLogId), &CiToVobcDataBuffer[0], ii);
			if (1u == outnetSafeSendRtn)
			{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/                 
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
				debug_infor_printf((const)"\nVOBC_SEND:%d", ii);
				debug_out_array(0xAA, CiToVobcDataBuffer, ii);
#endif/*平台打印结束*/
#endif
				retVal = CI_SUCCESS;
			}
			else
			{
				/*写队列失败*/
				retVal = CI_ERROR;
				debug_infor_printf((const)"\nWrite VOBC %d dataQueue Error Len = %d\n", vobcToCiDataStru->VobcId, ii);
			}
		}
		else
		{
			;
		}
	}
	else
	{
		;
	}
	
	if (CI_ERROR == retVal)
	{
		SetErrorData(EFUNC_PACK_CI2VOBC_DATA,CI_DEVICE_TYPE_COMM_VOBC,vobcToCiDataStru->VobcId,ETYPE_COMM_WITH_VOBC,0,ESEND_LEVEL_ZERO);
	}
	else
	{
	}

	return retVal;
}


/*
* 功能描述： 解析处理CC VOBC单帧数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            const UINT8 systemId, 源设备ID
*            VobcToCiDataStru vobcToci数据结构体指针
*			 UINT8* saveGalHead,通用报文头是否保留,1:保留，0:不保留
*            const UINT16 logId，互联互通4IP VOBC的1端或2端标识
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功
* 修复bug YF0083-100
*/
static UINT8 ParseIvocToCiDataFrameCC(const UINT8* pDataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* pstVobcToCiDataStru, UINT8* pSaveGalHead, const UINT16 logId)
{
	UINT8 chTrainDir = 0U;					/*列车方向*/
	UINT8 chTrainZeroStt = 0U;					/*列车零速标志*/
	UINT16 ii = 0U;                                /*索引管理*/
	UINT8 jj = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT16 appInfoType = 0U;						 /*应用信息类型*/
	UINT32 dwTrackSecId = 0U;					 /*轨道区段ID*/
	UINT32 curntCycleNo = 0U;					/*当前周期号*/
	UINT16 vobcName = 0U;						/*VOBC设备名称：类型+ID*/
	UINT16 ciName = 0U;							/*联锁设备名称：类型+ID*/
	UINT8 localCiId = GetSystemParaLocalCiId();/*联锁ID*/
	UINT32 errCode = 0U;
	HLHTGALInfoStruct hlhtGalHead = { 0 };
	INT32 vobcInfoRemainValidiy = 0;
	UINT8 headRet = HLHT_HEAD_ERROR;/*互联互通检查结果*/
	UINT8 chTrainLevel = 0U;
	UINT16 wLinkId = 0U;
	UINT32 dwOffset = 0U;
	UINT16 wTrainSpeed = 0U;
	UINT8 chTrainSpeedDir = 0U;
	UINT8 chTrainStopNum = 0U;
	UINT16 wTrainStopRtId = 0U;
	UINT8 chStopSteayState = 0U;
	UINT8 chEaNum = 0U;
	UINT8 chLogOutState = 0U;
	UINT32 dwCyc = 0u;
	UINT8 chGroupState = 0u;
	UINT16 wGroupOtherTrainId = 0u;
	UINT8 chTrainMode = 0u;
	UINT8 chTrainHeadScreenConfirm = 0u;
	UINT8 chTrainTailScreenConfirm = 0u;
	UINT8 chTrainWakeState = 0u;
	UINT8 chTrainReportState = 0u;
	UINT8 chEaIndex = 0u;
	UINT16 wEaTrainId = 0u;
	UINT8 chEaState = 0u;
	UINT32 dwEaBuildCyc = 0U;
	UINT32 dwHlhtNs = 0u;
	UINT8 chResourceCancelNum = 0U;			/*资源取消允许进路数量*/
	UINT16 wResourceCancelRtID = 0U;		/*资源取消进路ID*/
	UINT32 dwResourceCancelCyc = 0U;		/*资源取消请求周期号*/
	UINT8 cUnlockOverlapNum = 0U;			/*列车允许解锁保护区段的数量*/
	UINT16 wUnlockOverlapID = 0U;		    /*列车允许解锁保护区段的ID*/
	UINT32 dwUnlockOverlapStartCyc = 0U;    /*列车允许解锁保护区段的起始周期号*/
	UINT8 cFloodGateCloseAllowNum = 0U;			/*列车允许关闭的防淹门数量*/
	UINT16 wFloodGateID = 0U;		    /*列车允许关闭的防淹门ID*/
	UINT32 dwFloodGateCloseCyc = 0U;    /*防淹门关闭请求周期号*/
	UINT8 cGarageDoorCloseAllowNum = 0U;			/*列车允许关闭的车库门数量*/
	UINT16 wGarageDoorID = 0U;		    /*列车允许关闭的车库门ID*/
	UINT32 dwGarageDoorCloseCyc = 0U;    /*车库门关闭请求周期号*/
	LOD_STRU wMaxhead = { 0u };
	LOD_STRU wMaxtail = { 0u };
	LOD_STRU wMinhead = { 0u };
	LOD_STRU wMintail = { 0u };
	UINT16 wApplyDataLenth = 0U;
	UINT8 chVideoQkState = 0U;/*视频清客状态*/
	UINT8 chVideoQkResult = 0U;/*视频清客结果*/
	UINT16 wVideoQkRelatePsdId1 = 0U;/*视频清客关联屏蔽门ID1*/
	UINT16 wVideoQkRelatePsdId2 = 0U;/*视频清客关联屏蔽门ID2*/
	UINT16 wHeadAxis = 0U; /*前方计轴器编号*/
	UINT16 wTailAxis = 0U; /*后方计轴器编号*/
	UINT16 wHeadTrainId = 0U;/*前车ID*/
	UINT16 wTrainRelLgcId = 0U;/*列车关联使用端*/
	UINT16 wHeadSignalId = 0U;/*前方信号机ID*/
	UINT8 chJumpBackState = 0U;/*向后跳跃申请*/
	UINT32 dwJumpBackSN = 0U;/*向后跳跃申请序列号*/

	vobcName = (CI_SYSTEM_TYPE_VOBC) * 256U + systemId;
	ciName = (CI_SYSTEM_TYPE_CI) * 256U + localCiId;

	if ((NULL == pDataBuf) 
		|| (NULL == pstVobcToCiDataStru) 
		|| (NULL == pSaveGalHead)
		|| (CI_IVOC_PACKET_LENGTH_MAX< dataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		/*入参不为空，先将返回值置为成功*/
		chRetVal = CI_SUCCESS;
	}

	if (CI_SUCCESS == chRetVal)
	{
		/*解析通用消息包头*/
		hlhtGalHead.devInterInfoType = ShortFromChar(&pDataBuf[ii]);
		ii += 2U;
		hlhtGalHead.sourceId = LongFromChar(&pDataBuf[ii]);
		ii += 4U;
		hlhtGalHead.destId = LongFromChar(&pDataBuf[ii]);
		ii += 4U;
		hlhtGalHead.emapVerCrc = LongFromChar(&pDataBuf[ii]);
		ii += 4U;
		hlhtGalHead.crntOwnMsgSN = LongFromChar(&pDataBuf[ii]);
		ii += 4U;
		hlhtGalHead.comPeriod = ShortFromChar(&pDataBuf[ii]);
		ii += 2U;
		hlhtGalHead.recvOppMsgSN = LongFromChar(&pDataBuf[ii]);

		ii += 4U;
		hlhtGalHead.preOwnMsgSN = LongFromChar(&pDataBuf[ii]);
		ii += 4U;
		hlhtGalHead.prtclVer = pDataBuf[ii++];
		hlhtGalHead.totalDataLen = ShortFromChar(&pDataBuf[ii]);
		ii += 2U;

		curntCycleNo = Get2oo2CurCycleNum();

		pstVobcToCiDataStru->vobcLogId = logId;/*存储VOBC的逻辑ID，1端或2端*/
											/*（通用消息包头校验通过 && 报文生存时间有效）才继续解析其他信息*/
											/*第一次收到VOBC消息时校验不通过，只记录curntOwnMsg以及当前本方软件周期号*/
		headRet = HLHTRecvCommonPacketHeadCheck(vobcName, ciName, IVOC_CI_INTERFACE_INFOTYPE, CI_IVOC_PRTCL_VER, &hlhtGalHead, &errCode, logId, CI_SYSTEM_TYPE_VOBC);

		debug_infor_printf((const)"\nVOBC %d GAL Check Result:%d errCode:%d", systemId, headRet, errCode);	/*0x55正确，0xaa错误，0x33初始通信帧*/

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

			if (vobcInfoRemainValidiy > 0)
			{
				/*解析应用数据*/
				wApplyDataLenth= ShortFromChar(&pDataBuf[ii]);/*应用层数据长度*/
				ii += 2U;

				appInfoType = ShortFromChar(&pDataBuf[ii]);/*应用信息类型，屏蔽门控制信息或者心跳帧信息*/
				ii += 2U;
				pstVobcToCiDataStru->appInfoType = appInfoType;
				pstVobcToCiDataStru->VobcId = systemId;

				ii += 2U;/*跳过两个预留字节*/

				if (IVOC_CI_INFO_TYPE_CONTROL == appInfoType)
				{/*只有当VOBC发送CI的信息类型是屏蔽门控制报文时才继续解析报文信息*/
					pstVobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum();
					/*列车运行等级判断*/
					chTrainLevel = pDataBuf[ii];
					ii += 1U;

					if ((TRAIN_LEVEL_UR == chTrainLevel) || (TRAIN_LEVEL_ABL == chTrainLevel) || (TRAIN_LEVEL_VBTC == chTrainLevel) || (TRAIN_LEVEL_ITC == chTrainLevel))
					{
						pstVobcToCiDataStru->chTrainLevel = chTrainLevel;
					}
					else
					{
						chRetVal = CI_ERROR;
					}

					chTrainMode = pDataBuf[ii];
					ii++;

					/* 列车模式 */
					if ((TRAIN_MODE_RM == chTrainMode)
						|| (TRAIN_MODE_CM == chTrainMode)
						|| (TRAIN_MODE_AM == chTrainMode)
						|| (TRAIN_MODE_EUM == chTrainMode)
						|| (TRAIN_MODE_RD == chTrainMode)
						|| (TRAIN_MODE_AR == chTrainMode)
						|| (TRAIN_MODE_FAM == chTrainMode)
						|| (TRAIN_MODE_CAM == chTrainMode)
						|| (TRAIN_MODE_RRM == chTrainMode)
						|| (TRAIN_MODE_VCM == chTrainMode))
					{
						pstVobcToCiDataStru->chTrainMode = chTrainMode;
					}
					else
					{
						chRetVal = CI_ERROR;
					}

					/*列车最大安全前端位置*/
					if (CI_SUCCESS == chRetVal)
					{
						wMaxhead.Lnk = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;
						wMaxhead.Off = LongFromChar(&pDataBuf[ii]);
						ii += 4U;
						if (UINT16_MAX != wLinkId)
						{
							pstVobcToCiDataStru->wTrainMaxSafeHeadLink = wMaxhead.Lnk;
							pstVobcToCiDataStru->dwTrainMaxSafeHeadOffset = wMaxhead.Off;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*列车最小安全后端位置*/
					if (CI_SUCCESS == chRetVal)
					{
						wMintail.Lnk = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;
						wMintail.Off = LongFromChar(&pDataBuf[ii]);
						ii += 4U;
						if (UINT16_MAX != wLinkId)
						{
							pstVobcToCiDataStru->wTrainMinSafeTailLink = wMintail.Lnk;
							pstVobcToCiDataStru->dwTrainMinSafeTailOffset = wMintail.Off;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}


					/*列车最小安全前端位置*/
					if (CI_SUCCESS == chRetVal)
					{
						wMinhead.Lnk = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;
						wMinhead.Off = LongFromChar(&pDataBuf[ii]);
						ii += 4U;
						if (UINT16_MAX != wLinkId)
						{
							pstVobcToCiDataStru->wTrainMinSafeHeadLink = wMinhead.Lnk;
							pstVobcToCiDataStru->dwTrainMinSafeHeadOffset = wMinhead.Off;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*列车最大安全后端位置*/
					if (CI_SUCCESS == chRetVal)
					{
						wMaxtail.Lnk = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;
						wMaxtail.Off = LongFromChar(&pDataBuf[ii]);
						ii += 4U;
						if (UINT16_MAX != wLinkId)
						{
							pstVobcToCiDataStru->wTrainMaxSafeTailLink = wMaxtail.Lnk;
							pstVobcToCiDataStru->dwTrainMaxSafeTailOffset = wMaxtail.Off;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}
					/*列车运行方向*/
					if (CI_SUCCESS == chRetVal)
					{
						chTrainDir = pDataBuf[ii];
						ii += 1U;
						if ((TRAIN_DIR_UP == chTrainDir) || (TRAIN_DIR_DOWN == chTrainDir))
						{
							pstVobcToCiDataStru->trainDirection = chTrainDir;
							/*校验是否能计算出大前大后小前三点方向*/
							chRetVal = CheckTrainDirToOtherPointDir(wMaxhead, wMinhead, wMaxtail, wMintail, chTrainDir);
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*列车速度方向*/
					if (CI_SUCCESS == chRetVal)
					{
						wTrainSpeed = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;
						chTrainSpeedDir = pDataBuf[ii];
						ii += 1U;
						if (((TRAIN_SPEED_DIR_FORWARD == chTrainSpeedDir) || (TRAIN_SPEED_DIR_BACKWARD == chTrainSpeedDir)) && (UINT16_MAX!= wTrainSpeed))
						{
							pstVobcToCiDataStru->chSpeedDir = chTrainSpeedDir;
							pstVobcToCiDataStru->wTrainSpeed = wTrainSpeed;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*零速标志*/
					if (CI_SUCCESS == chRetVal)
					{
						chTrainZeroStt = pDataBuf[ii];
						ii += 1U;
						if ((TRAIN_SPEED_ZERO_YES == chTrainZeroStt) || (TRAIN_SPEED_ZERO_NO == chTrainZeroStt))
						{
							pstVobcToCiDataStru->chTrainZeroState = chTrainZeroStt;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*人工确认前筛*/
					if (CI_SUCCESS == chRetVal)
					{
						chTrainHeadScreenConfirm = pDataBuf[ii];
						ii++;
						if ((TRAIN_HEAD_CONFIRM_YES == chTrainHeadScreenConfirm) || (TRAIN_HEAD_CONFIRM_NO == chTrainHeadScreenConfirm))
						{
							pstVobcToCiDataStru->chTrainHeadScreenConfirm = chTrainHeadScreenConfirm;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						;
					}

					/*人工确认后筛*/
					if (CI_SUCCESS == chRetVal)
					{
						chTrainTailScreenConfirm = pDataBuf[ii];
						ii++;
						if ((TRAIN_TAIL_CONFIRM_YES == chTrainTailScreenConfirm) || (TRAIN_TAIL_CONFIRM_NO == chTrainTailScreenConfirm))
						{
							pstVobcToCiDataStru->chTrainTailScreenConfirm = chTrainTailScreenConfirm;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						;
					}

					/*前后筛识别信息*/
					if (CI_SUCCESS == chRetVal)
					{
						/*前方计轴编号*/
						wHeadAxis = ShortFromChar(&pDataBuf[ii]);
						ii += 2u;
						if (0xffffU == wHeadAxis)
						{
							chRetVal = CI_ERROR; /*非法值*/
						}
						else
						{
							pstVobcToCiDataStru->wHeadAxisId = wHeadAxis;
						}

						/*前方ITE识别结果*/
						if (CI_SUCCESS == chRetVal)
						{
							pstVobcToCiDataStru->wHeadITEResult = pDataBuf[ii];
							ii++;
							if ((TRAIN_ITE_RESULT_YES == pstVobcToCiDataStru->wHeadITEResult)
								|| (TRAIN_ITE_RESULT_NO == pstVobcToCiDataStru->wHeadITEResult))
							{
								; /*解析通过*/
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
						else
						{
							/*解析错误不继续解析*/
						}

						/*后方计轴编号*/
						if (CI_SUCCESS == chRetVal)
						{
							wTailAxis = ShortFromChar(&pDataBuf[ii]);
							ii += 2u;
							if (0xffffU == wTailAxis)
							{
								chRetVal = CI_ERROR; /*非法值*/
							}
							else
							{
								pstVobcToCiDataStru->wTailAxisId = wTailAxis;
							}
						}
						else
						{
							/*解析错误不继续解析*/
						}

						/*后方ITE识别结果*/
						if (CI_SUCCESS == chRetVal)
						{
							pstVobcToCiDataStru->wTailITEResult = pDataBuf[ii];
							ii++;
							if ((TRAIN_ITE_RESULT_YES == pstVobcToCiDataStru->wTailITEResult)
								|| (TRAIN_ITE_RESULT_NO == pstVobcToCiDataStru->wTailITEResult))
							{
								; /*解析通过*/
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
						else
						{
							/*解析错误不继续解析*/
						}

						if (0U != wHeadAxis)
						{
							/*识别有效*/
							debug_infor_printf((const)"\nVOBC %d ITE Result : Head axis_%d RE :%d __Tail Axis_%d RE: %d\n",
								systemId, wHeadAxis, pstVobcToCiDataStru->wHeadITEResult, wTailAxis, pstVobcToCiDataStru->wTailITEResult);
						}
					}
					else
					{
						/*解析错误不继续解析*/
					}

					/*列车停车保证*/
					if (CI_SUCCESS == chRetVal)
					{

						chTrainStopNum = pDataBuf[ii];
						ii += 1U;
						if (IVOC_CI_STOP_ASS_SUM_MAX > chTrainStopNum)
						{
							pstVobcToCiDataStru->chTrainStopAssureNum = chTrainStopNum;
							for (jj = 0U; jj < chTrainStopNum; jj++)
							{
								wTrainStopRtId = ShortFromChar(&pDataBuf[ii]);
								ii += 2U;
								dwCyc = LongFromChar(&pDataBuf[ii]);
								ii += 4U;

								if ((UINT16_MAX != wTrainStopRtId) && (0U != wTrainStopRtId))
								{
									pstVobcToCiDataStru->szTrainStopRouteId[jj] = wTrainStopRtId;
									pstVobcToCiDataStru->szTrainStopRouteCyc[jj] = dwCyc;
								}
								else
								{
									chRetVal = CI_ERROR;
								}
								if (CI_ERROR == chRetVal)
								{
									break;
								}
							}
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*列车资源取消*/
					if (CI_SUCCESS == chRetVal)
					{

						chResourceCancelNum = pDataBuf[ii];/*资源取消允许进路数量*/
						ii += 1U;
						if (IV0C_CI_RESOURCE_CANCEL_SUM_MAX > chResourceCancelNum)
						{
							pstVobcToCiDataStru->chResourcesCancelNum = chResourceCancelNum;
							/*遍历资源取消允许的进路*/
							for (jj = 0U; jj < chResourceCancelNum; jj++)
							{
								wResourceCancelRtID = ShortFromChar(&pDataBuf[ii]);
								ii += 2U;
								dwResourceCancelCyc = LongFromChar(&pDataBuf[ii]);
								ii += 4U;
								/*资源取消进路ID有效*/
								if ((UINT16_MAX != wResourceCancelRtID) && (0U != wResourceCancelRtID))
								{
									pstVobcToCiDataStru->szResourcesCancelRouteId[jj] = wResourceCancelRtID;/*获取资源取消进路ID*/
									pstVobcToCiDataStru->szResourcesCancelRouteCyc[jj] = dwResourceCancelCyc;/*获取资源取消请求周期号*/
								}
								else
								{
									chRetVal = CI_ERROR;
								}
								if (CI_ERROR == chRetVal)
								{
									break;
								}
								else
								{
									/*继续循环*/
								}
							}
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*解析列车允许解锁的保护区段信息*/
					if (CI_SUCCESS == chRetVal)
					{
						cUnlockOverlapNum = pDataBuf[ii];  /*解析列车允许解锁保护区段的数量*/
						ii += 1U;

						if (IVOC_CI_UNLOCK_OVERLAP_SUM > cUnlockOverlapNum)
						{
							pstVobcToCiDataStru->cAllowUnlockOverlapNum = cUnlockOverlapNum;  /*列车允许解锁保护区段的数量有效，存入VOBC结构体*/

							/*遍历列车允许解锁的保护区段*/
							for (jj = 0U; jj < cUnlockOverlapNum; jj++)
							{
								wUnlockOverlapID = ShortFromChar(&pDataBuf[ii]);  /*解析列车允许解锁保护区段的ID*/
								ii += 2U;
								dwUnlockOverlapStartCyc = LongFromChar(&pDataBuf[ii]);  /*解析列车允许解锁保护区段的起始周期号*/
								ii += 4U;

								if ((OVERLAP_SUM_MAX > wUnlockOverlapID) && (0U != wUnlockOverlapID) && (0U != dwUnlockOverlapStartCyc))
								{
									/*保护区段ID和解锁起始周期号有效，存入VOBC结构体*/
									pstVobcToCiDataStru->szAllowUnlockOverlapId[jj] = wUnlockOverlapID;
									pstVobcToCiDataStru->szAllowUnlockOverlapStartCyc[jj] = dwUnlockOverlapStartCyc;
								}
								else
								{
									chRetVal = CI_ERROR;
									break;									
								}
							}
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*解析列车允许关闭的防淹门信息*/
					if (CI_SUCCESS == chRetVal)
					{
						cFloodGateCloseAllowNum = pDataBuf[ii];  /*列车允许关闭的防淹门数量*/
						ii += 1U;

						if (IVOC_CI_FLOODGATE_CLOSE_ALLOW_SUM > cFloodGateCloseAllowNum)
						{
							pstVobcToCiDataStru->cAllowCloseFloodGateNum = cFloodGateCloseAllowNum;  /*列车允许关闭的防淹门数量有效，存入VOBC结构体*/

							/*遍历列车允许关闭的防淹门*/
							for (jj = 0U; jj < cFloodGateCloseAllowNum; jj++)
							{
								wFloodGateID = ShortFromChar(&pDataBuf[ii]);  /*解析列车允许关闭的防淹门ID*/
								ii += 2U;
								dwFloodGateCloseCyc = LongFromChar(&pDataBuf[ii]);  /*解析防淹门关闭请求周期号*/
								ii += 4U;

								if ((FLOOD_GATE_SUM_MAX > wFloodGateID) && (0U != wFloodGateID) && (0U != dwFloodGateCloseCyc))
								{
									/*列车允许关闭的防淹门ID和防淹门关闭请求周期号有效，存入VOBC结构体*/
									pstVobcToCiDataStru->szAllowCloseFloodGateId[jj] = wFloodGateID;
									pstVobcToCiDataStru->szAllowCloseFloodGateCyc[jj] = dwFloodGateCloseCyc;
								}
								else
								{
									chRetVal = CI_ERROR;
									break;
								}
							}
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*解析列车允许关闭的车库门信息*/
					if (CI_SUCCESS == chRetVal)
					{
						cGarageDoorCloseAllowNum= pDataBuf[ii];/*列车允许关闭的车库门数量*/
						ii++;

						if (IVOC_CI_GARAGEDOOR_CLOSE_ALLOW_SUM > cGarageDoorCloseAllowNum)
						{
							pstVobcToCiDataStru->cAllowCloseGarageGateNum = cGarageDoorCloseAllowNum;  /*列车允许关闭的防淹门数量有效，存入VOBC结构体*/

							/*遍历列车允许关闭的防淹门*/
							for (jj = 0U; jj < cGarageDoorCloseAllowNum; jj++)
							{
								wGarageDoorID = ShortFromChar(&pDataBuf[ii]);  /*解析列车允许关闭的车库门ID*/
								ii += 2U;
								dwGarageDoorCloseCyc = LongFromChar(&pDataBuf[ii]);  /*解析车库门关闭请求周期号*/
								ii += 4U;

								if ((GARAGE_DOOR_SUM_MAX > wGarageDoorID) && (0U != wGarageDoorID) && (0U != dwGarageDoorCloseCyc))
								{
									/*列车允许关闭的车库门ID和车库门关闭请求周期号有效，存入VOBC结构体*/
									pstVobcToCiDataStru->szAllowCloseGarageGateId[jj] = wGarageDoorID;
									pstVobcToCiDataStru->szAllowCloseGarageGateCyc[jj] = dwGarageDoorCloseCyc;
								}
								else
								{
									chRetVal = CI_ERROR;
									break;
								}
							}
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{

					}
					/*列车停稳状态*/
					if (CI_SUCCESS == chRetVal)
					{

						chStopSteayState = pDataBuf[ii];
						ii += 1U; 
						dwTrackSecId = LongFromChar(&pDataBuf[ii]);
						ii += 4U;
						if ((VOBC_CI_STOP_TW == chStopSteayState)||(VOBC_CI_STOP_WTW == chStopSteayState))
						{
							pstVobcToCiDataStru->trainStopSteadyState = chStopSteayState;
							pstVobcToCiDataStru->stopSteadyStartCycNum = Get2oo2CurCycleNum();
							pstVobcToCiDataStru->trackSecID = dwTrackSecId;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*列车唤醒状态*/
					if (CI_SUCCESS == chRetVal)
					{
						chTrainWakeState = pDataBuf[ii];
						ii++;
						if ((TRAIN_WAKE_SUCCESS == chTrainWakeState)
							|| (TRAIN_WAKE_PROCESS == chTrainWakeState)
							|| (TRAIN_WAKE_FAILURE == chTrainWakeState)
							|| (TRAIN_WAKE_DEFAULT == chTrainWakeState))
						{
							pstVobcToCiDataStru->chTrainWakeState = chTrainWakeState;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						;
					}

					/*列车汇报状态*/
					if (CI_SUCCESS == chRetVal)
					{
						chTrainReportState = pDataBuf[ii];
						ii++;
						
						pstVobcToCiDataStru->chTrainReportState = chTrainReportState;
					}
					else
					{
						;
					}
					/*列车区间疏散信息*/
					if (CI_SUCCESS == chRetVal)
					{
						chEaNum = pDataBuf[ii];
						ii += 1U;

						if (IVOC_CI_EA_MAX >= chEaNum)
						{
							pstVobcToCiDataStru->chEaNum = chEaNum;
							for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++)
							{
								wEaTrainId = ShortFromChar(&pDataBuf[ii]);
								ii += 2u;
								chEaState = pDataBuf[ii];
								ii++;
								dwEaBuildCyc =LongFromChar(&pDataBuf[ii]);
								ii += 4u;
								if ((0x1401u <= wEaTrainId) && (0x14feu >= wEaTrainId) && ((EA_PROTECT_BUILD_Y == chEaState) || (EA_PROTECT_BUILD_N == chEaState)))
								{
									pstVobcToCiDataStru->stEaInfo[chEaIndex].wDeviceId = wEaTrainId;
									pstVobcToCiDataStru->stEaInfo[chEaIndex].chDeviceStatus = chEaState;
									pstVobcToCiDataStru->stEaInfo[chEaIndex].dwBuildCyc = dwEaBuildCyc;
								}
								else
								{
									chRetVal = CI_ERROR;
								}
							}
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}
#if 0
					/*编组另一车ID*/
					if (CI_SUCCESS == chRetVal)
					{
						wGroupOtherTrainId = ShortFromChar(&pDataBuf[ii]);
						ii += 2u;
						if (((TRAIN_ID_MIN < wGroupOtherTrainId) && (TRAIN_ID_MAX > wGroupOtherTrainId))
							||(TRAIN_ID_INVAL == wGroupOtherTrainId))
						{
							pstVobcToCiDataStru->wGroupOtherTrainId = wGroupOtherTrainId;
						}
						else
						{
							/*列车ID错误*/
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/* 解析错误*/
					}

					/*编组列车状态*/
					if (CI_SUCCESS == chRetVal)
					{
						chGroupState = pDataBuf[ii];
						ii++;
						if ((VOBC_CI_GROUP_NO == chGroupState)||
							(VOBC_CI_GROUP_SET == chGroupState)||
							(VOBC_CI_GROUP_RUN == chGroupState)||
							(VOBC_CI_GROUP_REVERSE == chGroupState)||
							(VOBC_CI_GROUP_EXIT == chGroupState))
						{
							pstVobcToCiDataStru->chGroupRunState = chGroupState;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/* 解析错误*/
					}

					/*编组前后车关系*/
					if (CI_SUCCESS == chRetVal)
					{
						chGroupState = pDataBuf[ii];
						ii++;
						if ((VOBC_CI_GROUP_HEAD == chGroupState)||
							(VOBC_CI_GROUP_TAIL == chGroupState)||
							(VOBC_CI_GROUP_INVAL == chGroupState))
						{
							pstVobcToCiDataStru->chGroupTrainReat = chGroupState;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/* 解析错误*/
					}
#endif
					/*当前激活端*/
					if (CI_SUCCESS == chRetVal)
					{
						pstVobcToCiDataStru->chActive = pDataBuf[ii];
						ii++;
						if ((TRAIN_ACTIVE_NONE == pstVobcToCiDataStru->chActive)
							|| (TRAIN_ACTIVE_ONE == pstVobcToCiDataStru->chActive)
							|| (TRAIN_ACTIVE_TWO == pstVobcToCiDataStru->chActive)
							|| (TRAIN_ACTIVE_ALL == pstVobcToCiDataStru->chActive))
						{
							; /*解析通过*/
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						; /*输入有误*/
					}

					/*远程RM申请状态*/
					if (CI_SUCCESS == chRetVal)
					{
						pstVobcToCiDataStru->chRrmReq = pDataBuf[ii];
						ii++;
						if ((TRAIN_RRM_RQST_YES == pstVobcToCiDataStru->chRrmReq)
							|| (TRAIN_RRM_RQST_NO == pstVobcToCiDataStru->chRrmReq))
						{
							; /*解析通过*/
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						; /*解析失败*/
					}

					/*RRM模式运行下一站ID*/
					if (CI_SUCCESS == chRetVal)
					{
						dwHlhtNs = LongFromChar(&pDataBuf[ii]);
						ii += 4u;
						pstVobcToCiDataStru->wNextStation = 0u;
						(void)dquQueryInDevIndex(QFUN_IDMAP_STATION_ID, dwHlhtNs, &pstVobcToCiDataStru->wNextStation);
					}
					else
					{
						;
					}

					/*列车脱轨状态*/
					if (CI_SUCCESS == chRetVal)
					{
						pstVobcToCiDataStru->chDerailment = pDataBuf[ii];
						ii++;
						if ((TRAIN_DERAIL_YES == pstVobcToCiDataStru->chDerailment)
							|| (TRAIN_DERAIL_NO == pstVobcToCiDataStru->chDerailment))
						{
							; /*解析通过*/
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						; /*解析失败*/
					}

					

					/*视频清客相关信息*/
					if (CI_SUCCESS == chRetVal)
					{
						/*视频清客状态*/
						chVideoQkState = pDataBuf[ii];
						ii++;
						/*视频清客结果*/
						chVideoQkResult = pDataBuf[ii];
						ii++;
						/*视频清客关联屏蔽门ID1*/
						wVideoQkRelatePsdId1 = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;
						/*视频清客关联屏蔽门ID2*/
						wVideoQkRelatePsdId2 = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;

						if (((VIDEO_QK_STATE_TESTING == chVideoQkState) || (VIDEO_QK_STATE_DEFAULT == chVideoQkState))
							&& ((VIDEO_QK_RESULT_TESTNO == chVideoQkResult) || (VIDEO_QK_RESULT_TESTHAVE == chVideoQkResult) || (VIDEO_QK_RESULT_TESTDEFAULT == chVideoQkResult))
							&& (PSD_SUM_MAX > wVideoQkRelatePsdId1)
							&& (PSD_SUM_MAX > wVideoQkRelatePsdId2))
						{
							pstVobcToCiDataStru->chVideoQkState = chVideoQkState;
							pstVobcToCiDataStru->chVideoQkResult = chVideoQkResult;
							pstVobcToCiDataStru->wVideoQkRelatePsdId1 = wVideoQkRelatePsdId1;
							pstVobcToCiDataStru->wVideoQkRelatePsdId2 = wVideoQkRelatePsdId2;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误不继续解析*/
					}

					/*列车洗车相关信息*/
					if (CI_SUCCESS == chRetVal)
					{
						/*洗车请求*/
						pstVobcToCiDataStru->washTrainRequest = pDataBuf[ii];
						ii++;
						if ((WASHMACHINE_DRVSTATE_REQ_TRUE == pstVobcToCiDataStru->washTrainRequest)
							|| (WASHMACHINE_DRVSTATE_REQ_FALSE == pstVobcToCiDataStru->washTrainRequest))
						{
							; /*解析通过*/
						}
						else
						{
							chRetVal = CI_ERROR;
						}
						if (CI_SUCCESS == chRetVal)
						{
							/*洗车停稳1*/
							pstVobcToCiDataStru->headWashStopSteadyInfo = pDataBuf[ii];
							ii++;
							if ((WASHMACHINE_HEAD_STEADY_YES == pstVobcToCiDataStru->headWashStopSteadyInfo)
								|| (WASHMACHINE_HEAD_STEADY_NO == pstVobcToCiDataStru->headWashStopSteadyInfo))
							{
								; /*解析通过*/
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
						else
						{
							/*解析错误不继续解析*/
						}
						if (CI_SUCCESS == chRetVal)
						{
							/*暂停洗车*/
							pstVobcToCiDataStru->washPauseRequest = pDataBuf[ii];
							ii++;
							if ((WASHMACHINE_PAUSE_DRVREQ_TRUE == pstVobcToCiDataStru->washPauseRequest)
								|| (WASHMACHINE_PAUSE_DRVREQ_FALSE == pstVobcToCiDataStru->washPauseRequest))
							{
								; /*解析通过*/
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
						else
						{
							/*解析错误不继续解析*/
						}
						if (CI_SUCCESS == chRetVal)
						{
							/*洗车停稳2*/
							pstVobcToCiDataStru->tailWashStopSteadyInfo = pDataBuf[ii];
							ii++;
							if ((WASHMACHINE_TAIL_STEADY_YES == pstVobcToCiDataStru->tailWashStopSteadyInfo)
								|| (WASHMACHINE_TAIL_STEADY_NO == pstVobcToCiDataStru->tailWashStopSteadyInfo))
							{
								; /*解析通过*/
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
						else
						{
							/*解析错误不继续解析*/
						}
						if (CI_SUCCESS == chRetVal)
						{
							/*洗车区通过请求*/
							pstVobcToCiDataStru->passWashMachineRequest = pDataBuf[ii];
							ii++;
							if ((PASS_WASHMACHINE_REQUEST_VALID == pstVobcToCiDataStru->passWashMachineRequest)
								|| (PASS_WASHMACHINE_REQUEST_INVALID == pstVobcToCiDataStru->passWashMachineRequest))
							{
								; /*解析通过*/
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
						else
						{
							/*解析错误不继续解析*/
						}
						if (CI_SUCCESS == chRetVal)
						{
							/*洗车机工作模式设置*/
							pstVobcToCiDataStru->chWashMachineWorkMode = pDataBuf[ii];
							ii++;
							if ((WASHMACHINE_WORKMODE_ALL_DRV == pstVobcToCiDataStru->chWashMachineWorkMode)
								|| (WASHMACHINE_WORKMODE_SIDE_DRV == pstVobcToCiDataStru->chWashMachineWorkMode)
								|| (WASHMACHINE_WORKMODE_DEFAULT_DRV == pstVobcToCiDataStru->chWashMachineWorkMode))
							{
								; /*解析通过*/
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
						else
						{
							/*解析错误不继续解析*/
						}
					}
					else
					{
						/*解析错误不继续解析*/
					}

					if (CI_SUCCESS == chRetVal)
					{
						/*NVRAM位置标识*/
						pstVobcToCiDataStru->chNvramPosFlag = pDataBuf[ii];
						ii++;
						if ((TRAIN_NVRAM_POS_FLAG_YES == pstVobcToCiDataStru->chNvramPosFlag)
							|| (TRAIN_NVRAM_POS_FLAG_NO == pstVobcToCiDataStru->chNvramPosFlag))
						{
							; /*解析通过*/
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误不继续解析*/
					}

					if (CI_SUCCESS == chRetVal)
					{
						dwHlhtNs = LongFromChar(&pDataBuf[ii]);
						ii += 4u;
						if (0x00000000U == dwHlhtNs)
						{
							/*默认值设置前方信号机ID为0*/
							pstVobcToCiDataStru->wHeadSigId = 0U;
						}
						else
						{
							/*根据互联互通4字节ID获取信号机ID*/
							chRetVal = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, dwHlhtNs, &wHeadSignalId);
							if ((CI_SUCCESS == chRetVal) && (SIGNAL_SUM_MAX > wHeadSignalId))
							{
								pstVobcToCiDataStru->wHeadSigId = wHeadSignalId;
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
					}
					else
					{
						/*解析错误不继续解析*/
					}

					/*前车ID*/
					if (CI_SUCCESS == chRetVal)
					{
						dwHlhtNs = LongFromChar(&pDataBuf[ii]);
						ii += 4u;
						if (0xFFFFFFFFU == dwHlhtNs)
						{
							/*默认值设置前车ID为0*/
							pstVobcToCiDataStru->wHeadVobcId = 0x14FFU;
						}
						else
						{
							chRetVal = dquHlhtId2VobcName(dwHlhtNs, &wHeadTrainId, &wTrainRelLgcId);
							if (CI_SUCCESS == chRetVal)
							{
								pstVobcToCiDataStru->wHeadVobcId = wHeadTrainId;
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
					}
					else
					{
						/*解析错误不继续解析*/
					}

					/*向后跳跃申请*/
					if (CI_SUCCESS == chRetVal)
					{
						chJumpBackState = pDataBuf[ii];
						ii++;
						if ((TRAIN_JUMP_BACK_STATE_VALID == chJumpBackState)
							|| (TRAIN_JUMP_BACK_STATE_INVALID == chJumpBackState))
						{
							/*解析通过*/
							pstVobcToCiDataStru->chJumpBackApply = chJumpBackState;
							dwJumpBackSN = LongFromChar(&pDataBuf[ii]);
							ii += 4u;
							if (((0U == dwJumpBackSN) && (TRAIN_JUMP_BACK_STATE_INVALID == chJumpBackState))
								|| ((0U < dwJumpBackSN) && (TRAIN_JUMP_BACK_STATE_VALID == chJumpBackState)))
							{
								/*解析通过*/
								pstVobcToCiDataStru->dwJumpBackSn = dwJumpBackSN;
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						; /*解析错误不继续解析*/
					}

					/*列车命令信息*/
					if (CI_SUCCESS == chRetVal)
					{
						chRetVal = ParseIvocToCiCmdCC(pDataBuf, &ii, pstVobcToCiDataStru);

					}
					else
					{
						/* 解析错误*/
					}
					/*控制信息帧末尾有4字节预留位，注销请求帧无预留位*/
					ii += 4U;

				}
				else if (IVOC_CI_INFO_TYPE_LOGOUT_ASK == appInfoType)
				{/*IVOC->OC注销请求帧*/

					pstVobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum();
					chLogOutState = pDataBuf[ii];
					ii += 1U;
					if ((IVOC_CI_LOGOUT_NORMAL == chLogOutState) || (IVOC_CI_LOGOUT_SLEEP == chLogOutState))
					{
						pstVobcToCiDataStru->chLogOutState = chLogOutState;
					}
					else
					{
						chRetVal = CI_ERROR;
					}

					/*列车最大安全前端位置*/
					if (CI_SUCCESS == chRetVal)
					{
						wLinkId = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;
						dwOffset = LongFromChar(&pDataBuf[ii]);
						ii += 4U;
						if ((0U != wLinkId) && (UINT16_MAX != wLinkId) && (UINT32_MAX != dwOffset))
						{
							pstVobcToCiDataStru->wTrainMaxSafeHeadLink = wLinkId;
							pstVobcToCiDataStru->dwTrainMaxSafeHeadOffset = dwOffset;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*列车最小安全后端位置*/
					if (CI_SUCCESS == chRetVal)
					{
						wLinkId = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;
						dwOffset = LongFromChar(&pDataBuf[ii]);
						ii += 4U;
						if ((0U != wLinkId) && (UINT16_MAX != wLinkId) && (UINT32_MAX != dwOffset))
						{
							pstVobcToCiDataStru->wTrainMinSafeTailLink = wLinkId;
							pstVobcToCiDataStru->dwTrainMinSafeTailOffset = dwOffset;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*列车最小安全前端位置*/
					if (CI_SUCCESS == chRetVal)
					{
						wLinkId = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;
						dwOffset = LongFromChar(&pDataBuf[ii]);
						ii += 4U;
						if ((0U != wLinkId) && (UINT16_MAX != wLinkId) && (UINT32_MAX != dwOffset))
						{
							pstVobcToCiDataStru->wTrainMinSafeHeadLink = wLinkId;
							pstVobcToCiDataStru->dwTrainMinSafeHeadOffset = dwOffset;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}

					/*列车最大安全后端位置*/
					if (CI_SUCCESS == chRetVal)
					{
						wLinkId = ShortFromChar(&pDataBuf[ii]);
						ii += 2U;
						dwOffset = LongFromChar(&pDataBuf[ii]);
						ii += 4U;
						if ((0U != wLinkId) && (UINT16_MAX != wLinkId) && (UINT32_MAX != dwOffset))
						{
							pstVobcToCiDataStru->wTrainMaxSafeTailLink = wLinkId;
							pstVobcToCiDataStru->dwTrainMaxSafeTailOffset = dwOffset;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						/*解析错误*/
					}
				}
				else if (IVOC_CI_INFO_TYPE_HEART_FRAME == appInfoType)
				{
					pstVobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum();
				}
				else
				{
					chRetVal = CI_ERROR;
				}

				if (CI_SUCCESS == chRetVal)
				{
					/*校验数据长度 发送两次长度，内层长度比外层少记录长度的两字节 */
					if ((hlhtGalHead.totalDataLen != ii - 31U) || (wApplyDataLenth != ii - 33U))
					{
						/* 31为应用数据帧头长度 */
						chRetVal = CI_ERROR;

					}
				}

				if (CI_SUCCESS == chRetVal)
				{
					/*数据经过校验，需要存储通用报文上下文*/
					SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod);
					SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN);
					SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN);
					SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN);
					SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo);
					SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId);

					*pSaveGalHead = 1U;
				}
			}
			else
			{
				chRetVal = CI_ERROR;
			}
		}
		else if (HLHT_HEAD_INIT == headRet)
		{
			if (curntCycleNo > 0U)/*判断序号大于0，因为把0当做无效序号*/
			{
				SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod);
				SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN);
				SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN);
				SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN);
				SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo);
				SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId);

				*pSaveGalHead = 1U;
			}

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

/*
* 功能描述： 解析处理CC IVOC命令信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*            VobcToCiDataStru vobcToci数据结构体指针
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 ParseIvocToCiCmdCC(const UINT8* pDataBuf,UINT16  *wDataLength, VobcToCiDataStruct* pstVobcToCiDataStru)
{
	UINT16 wCmdNum = 0U;
	UINT16 wCmdIndex = 0U;
	UINT8 chCmdDevNum = 0U;
	UINT8 chCmdDevIdx = 0U;
	UINT8 chCmdType = 0U;
	UINT16 wCmdDevId = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 cLocalCiId = 0u;
	UINT16 wTrainMaxSafeHeadBelongCiId = 0u;
	cLocalCiId = GetSystemParaLocalCiId();
	
	if ((NULL == pDataBuf)
		|| (NULL == pstVobcToCiDataStru)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		wTrainMaxSafeHeadBelongCiId = GetLinkManageTiocById(pstVobcToCiDataStru->wTrainMaxSafeHeadLink);

		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wCmdNum = ShortFromChar(&pDataBuf[ii]);
		ii += 2U;

		if (IVOC_CI_CMD_MAX > wCmdNum)
		{
			pstVobcToCiDataStru->wIvocCmdNum = wCmdNum;
			for (wCmdIndex = 0U; wCmdIndex < wCmdNum ; wCmdIndex++)
			{
				chCmdType = pDataBuf[ii];
				ii += 1U;
				chCmdDevNum = pDataBuf[ii];
				ii += 1U;
				if (IVOC_CI_CMD_DEVICE_MAX > chCmdDevNum)
				{
					switch (chCmdType)
					{
					case IVOC_CI_CMD_TYPE_RES_APPLY:
					case IVOC_CI_CMD_TYPE_RES_RELEASE:
					case IVOC_CI_CMD_TYPE_EA_BUILD:
					case IVOC_CI_CMD_TYPE_EA_CANCEL:
					case IVOC_CI_CMD_TYPE_DYTEST_REQ:
					case IVOC_CI_CMD_TYPE_DYTEST_CANCEL:
					case IVOC_CI_CMD_TYPE_JUMP_LOCK_APPLY:
					case IVOC_CI_CMD_TYPE_JUMP_LOCK_RELEASE:
					case IVOC_CI_CMD_GAP_DETECT_START:
					case IVOC_CI_CMD_GAP_DETECT_STOP:
					case IVOC_CI_CMD_NON_RETURN_STEADY:
					case IVOC_CI_CMD_NON_RETURN_FLASH:
					case IVOC_CI_CMD_TYPE_EMD_BUILD:
						/*资源数量小于100*/
						if (((IVOC_CI_CMD_TYPE_EA_BUILD == chCmdType) || (IVOC_CI_CMD_TYPE_EMD_BUILD == chCmdType))
							&& ((cLocalCiId != wTrainMaxSafeHeadBelongCiId) || (0u != chCmdDevNum)))
						{
							chRetVal = CI_ERROR;
						}
						else
						{
							;
						}
						pstVobcToCiDataStru->stCmdInfo[wCmdIndex].chCmdType = chCmdType;
						pstVobcToCiDataStru->stCmdInfo[wCmdIndex].chCmdDevNum = chCmdDevNum;
						break;
					case IVOC_CI_CMD_TYPE_PSD_OPEN_FOUR:
					case IVOC_CI_CMD_TYPE_PSD_CLOSE:
					case IVOC_CI_CMD_TYPE_PSD_OPEN_SIX:
					case IVOC_CI_CMD_TYPE_PSD_OPEN_EIGHT:
						if (2u >= chCmdDevNum)
						{
							/*屏蔽门数量小于2*/
							pstVobcToCiDataStru->stCmdInfo[wCmdIndex].chCmdType = chCmdType;
							pstVobcToCiDataStru->stCmdInfo[wCmdIndex].chCmdDevNum = chCmdDevNum;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
						break;
					default:
						chRetVal = CI_ERROR;
						break;
					}

					if (CI_SUCCESS == chRetVal)
					{
						for (chCmdDevIdx = 0U; chCmdDevIdx < chCmdDevNum; chCmdDevIdx++)
						{
							wCmdDevId = ShortFromChar(&pDataBuf[ii]);
							ii += 2U;
							if ((0U < wCmdDevId) && (UINT16_MAX > wCmdDevId))
							{
								pstVobcToCiDataStru->stCmdInfo[wCmdIndex].wCmdDevId[chCmdDevIdx] = wCmdDevId;
							}
							else
							{
								chRetVal = CI_ERROR;
								break;
							}
						}
					}

				}
				else
				{
					/*命令中控制对象数量非法*/
					chRetVal = CI_ERROR;
				}

				if (CI_ERROR == chRetVal)
				{
					break;/*控制对象数量非法||控制对象ID非法*/
				}
			}
		}
		else
		{
			chRetVal = CI_ERROR;
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}


/*
* 功能描述： 组车车Ivoc数据
* 参数说明： QueueStruct* CiToVobcDataQueue, 组包发送队列地址
*			 VobcToCiDataStruct *pstVobcToCiDataStru Vobc信息结构体
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
static UINT8 PackCiToIvocDataCC(VobcToCiDataStruct *pstVobcToCiDataStru)
{
	UINT8 cszCiToIvocDataBuf[VOBC_TO_CI_DATA_LEN_MAX] = { 0u };/*CI到VOBC组帧数组*/
	UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT8 kk = 0u;
	UINT32 curCycleNum = Get2oo2CurCycleNum();
	UINT32 appCycleTime = GetSystemParaAppCycleTime();
	UINT8 chRetVal = CI_ERROR;
	UINT8 localCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/
	UINT32 ciEtcsId = 0u;
	UINT32 vobcEtcsId = 0u;
	UINT32 emapCheckVer = 0u;
	UINT8 localhlhtId = 0u;
	UINT8 vobcHlhtId = 0u;
	UINT8 ciEmapCheckVer = 0u;
	UINT16 wAppInfoIndex = 0U;
	UINT16 dstDevId = 0u;
	UINT8 outnetSafeSendRtn = 0u;
	UINT8 chFunRtn = CI_ERROR;
	UINT8 chSwState = 0u;
	/*首先获取组包时所需的信息，获取成功才有必要继续组包*/

	if (NULL != pstVobcToCiDataStru)
	{
		localhlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + localCiId, 0U, &ciEtcsId);
		vobcHlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC * 256U) + (UINT8)(pstVobcToCiDataStru->VobcId), pstVobcToCiDataStru->vobcLogId, &vobcEtcsId);
		ciEmapCheckVer = GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC);
	}
	else
	{
		;
	}

	if ((CI_SUCCESS == localhlhtId) && (CI_SUCCESS == vobcHlhtId) && (CI_SUCCESS == ciEmapCheckVer))
	{
		chRetVal = CI_SUCCESS;
	}
	else
	{
		debug_infor_printf((const)"\nPack vobc %d HLHT_id or EmapCheckVer error， ciEmapCheckVer：%d \n", pstVobcToCiDataStru->VobcId, ciEmapCheckVer);
		chRetVal = CI_ERROR;
	}
	if (CI_SUCCESS == chRetVal)
	{
		ii = 0u;
#if 0
		/*通用协议帧头*/
		ii += 2u;
		cszCiToIvocDataBuf[ii++] = CI_SYSTEM_TYPE_VOBC;		                    /*目的逻辑类型*/
		cszCiToIvocDataBuf[ii++] = (UINT8)pstVobcToCiDataStru->VobcId;	        /*目的逻辑ID*/
		ShortToChar(pstVobcToCiDataStru->vobcLogId, &cszCiToIvocDataBuf[ii]);	/*互联互通4IP VOBC1端或2端标识*/
		ii += 2u;
#endif
		/*开始组应用数据帧*/

		ShortToChar(IVOC_CI_INTERFACE_INFOTYPE, &cszCiToIvocDataBuf[ii]);/*接口信息类型*/
		ii += 2u;
		LongToChar(ciEtcsId, &cszCiToIvocDataBuf[ii]);/*发送方标识信息*/
		ii += 4u;
		LongToChar(vobcEtcsId, &cszCiToIvocDataBuf[ii]);/*接收方标识信息*/
		ii += 4u;
		LongToChar(emapCheckVer, &cszCiToIvocDataBuf[ii]);/*电子地图版本校验信息*/
		ii += 4u;
		LongToChar(curCycleNum, &cszCiToIvocDataBuf[ii]);/*本方消息序列号*/
		ii += 4u;
		ShortToChar((UINT16)appCycleTime, &cszCiToIvocDataBuf[ii]);/*设备通讯周期*/
		ii += 2u;
		LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(pstVobcToCiDataStru->VobcId)), &cszCiToIvocDataBuf[ii]);/*对方消息序列号：recvOppMsgSN记录收到对方上一条消息中的对方消息序列号*/
		ii += 4u;
		LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(pstVobcToCiDataStru->VobcId)), &cszCiToIvocDataBuf[ii]);/*收到上一条消息时本方序列号*/
		ii += 4u;
		cszCiToIvocDataBuf[ii++] = CI_VOBC_PRTCL_VER;/*HLHT+FAO_CI_VOBC接口协议版本号*/
		ii += 2u;/*通用报文头中的应用层报文总长度*/

				 /*以下为应用层数据*/
		ii += 2u;/*报文长度*/

		wAppInfoIndex = ii;
		ii += 2u;/*应用报文类型*/

		ii += 2u;/*预留两个字节*/

		if (IVOC_CI_INFO_TYPE_CONTROL == pstVobcToCiDataStru->appInfoType)
		{
			ShortToChar(CI_IVOC_INFO_TYPE_STATE, &cszCiToIvocDataBuf[wAppInfoIndex]);

			chRetVal = PackCiToIvocSwitchInfo(cszCiToIvocDataBuf, &ii);

			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocPsdInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocSwitchInfo Error \n", pstVobcToCiDataStru->VobcId);
			}
			
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocEsbInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocPsdInfo Error \n", pstVobcToCiDataStru->VobcId);
			}
			
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocARInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocEsbInfo Error \n", pstVobcToCiDataStru->VobcId);
			}
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocSpksInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocARInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocGaragedoorInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocSpksInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			/*组防淹门信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocFloodGateInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocGaragedoorInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocFLockInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocFloodGateInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocCommTrainInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocFLockInfo Error \n", pstVobcToCiDataStru->VobcId);
			}


			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocFaultTrainInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocCommTrainInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocSleepTrainInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocFaultTrainInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocTsrInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocSleepTrainInfo Error \n", pstVobcToCiDataStru->VobcId);
			}


			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocLgcSgmtInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocTsrInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocReqAndReplyInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocLgcSgmtInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocReqAlignmentInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocReqAndReplyInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocUnlockOverlapInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocReqAlignmentInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			/*组区间雨雪状态和紧急制动信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocSnowAndUrgentInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocUnlockOverlapInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			/*洗车信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocWashMachineInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocSnowAndUrgentInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			/*前方信号机信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToVobcSigInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocWashMachineInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocHeadTrainInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToVobcSigInfo Error \n", pstVobcToCiDataStru->VobcId);
			}
			
			/*主用通道给IVOC组ITE切除状态*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocIteCutInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocHeadTrainInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			/*主用通道给IVOC组最远未占用逻辑区段信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocFarNoOccuLogInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocIteCutInfo Error \n", pstVobcToCiDataStru->VobcId);
			}
			/*主用通道给IVOC组列车位置监督状态*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocPosMonitorInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocFarNoOccuLogInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			/*主用通道给IVOC组向后跳跃申请回复信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocJumpBackReply(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocPosMonitorInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			/*给IVOC组未接近开放进路信息（预先开放）*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocOpenRouteNotNearInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocJumpBackReply Error \n", pstVobcToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				/*组包成功*/
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC: %d PackCiToIvocOpenRouteNotNearInfo Error \n", pstVobcToCiDataStru->VobcId);
			}

			/*预留4字节*/
			ii += 4U;
		}
		else if ((IVOC_CI_INFO_TYPE_LOGOUT_ASK == pstVobcToCiDataStru->appInfoType) && (curCycleNum == pstVobcToCiDataStru->ComStartCycle))
		{/*组注销请求回复帧*/
			ShortToChar(CI_IVOC_INFO_TYPE_LOGOUT_ACK, &cszCiToIvocDataBuf[wAppInfoIndex]);/*注销请求回复帧报文类型，两字节*/

			if (IVOC_CI_LOGOUT_NORMAL == pstVobcToCiDataStru->chLogOutState)
			{
				chFunRtn = IsPointManaged(pstVobcToCiDataStru->wTrainMaxSafeHeadLink, pstVobcToCiDataStru->dwTrainMaxSafeHeadOffset);
				chFunRtn &= IsPointManaged(pstVobcToCiDataStru->wTrainMinSafeTailLink, pstVobcToCiDataStru->dwTrainMinSafeTailOffset);
				chFunRtn &= IsPointManaged(pstVobcToCiDataStru->wTrainMinSafeHeadLink, pstVobcToCiDataStru->dwTrainMinSafeHeadOffset);
				chFunRtn &= IsPointManaged(pstVobcToCiDataStru->wTrainMaxSafeTailLink, pstVobcToCiDataStru->dwTrainMaxSafeTailOffset);
				if (CI_ERROR == chFunRtn)
				{
					cszCiToIvocDataBuf[ii++] = IVOC_LOG_OUT_FAILURE;
				}
				else
				{
					cszCiToIvocDataBuf[ii++] = IVOC_LOG_OUT_SUCCESS;
				}
			}
			else if(IVOC_CI_LOGOUT_SLEEP == pstVobcToCiDataStru->chLogOutState)
			{
				chSwState = GetTrainSleepState(pstVobcToCiDataStru->VobcId);
				if (TRAIN_SLEEP_YES == chSwState)
				{
					cszCiToIvocDataBuf[ii++] = IVOC_LOG_OUT_SUCCESS;
				}
				else
				{
					cszCiToIvocDataBuf[ii++] = IVOC_LOG_OUT_FAILURE;
					debug_infor_printf((const)"Train:%x Sleep error sw:%d hl:%d hl:%d tl:%d tl:%d\n", pstVobcToCiDataStru->VobcId, \
						chSwState, pstVobcToCiDataStru->wTrainMaxSafeHeadLink, pstVobcToCiDataStru->wTrainMinSafeHeadLink, \
						pstVobcToCiDataStru->wTrainMaxSafeTailLink, pstVobcToCiDataStru->wTrainMinSafeTailLink);
				}
			}
			else
			{
				cszCiToIvocDataBuf[ii++] = IVOC_LOG_OUT_FAILURE;
			}

			/*填充应用层信息长度*/
		}
		else
		{
			/*信息类型错误，什么都不做*/
		}

		if (CI_SUCCESS == chRetVal)
		{
			if (CI_IVOC_PACKET_LENGTH_MAX > ii)
			{
				; /*继续执行*/
			}
			else
			{
				chRetVal = CI_ERROR;
				debug_infor_printf((const)"\nPack vobc %d PackCiToIvoc_PACKETLEN_ Error, len: %d  \n", pstVobcToCiDataStru->VobcId, ii);
			}
		}

		if (CI_SUCCESS == chRetVal)
		{
			/*应用层数据的报文长度 */
			cszCiToIvocDataBuf[31U] = (UINT8)((UINT8)((ii - 33u) >> 8u) & 0xffu);
			cszCiToIvocDataBuf[32U] = (UINT8)((ii - 33u) & 0xffu);

			/*通用报文头中应用层报文总长度*/
			cszCiToIvocDataBuf[29U] = (UINT8)((UINT8)((ii - 31U) >> 8U) & 0xffU);
			cszCiToIvocDataBuf[30U] = (UINT8)((ii - 31U) & 0xffU);

			dstDevId = ((UINT16)(CI_SYSTEM_TYPE_VOBC << 8U) | pstVobcToCiDataStru->VobcId);
			outnetSafeSendRtn = OutnetSafeSend(dstDevId, (pstVobcToCiDataStru->vobcLogId), &cszCiToIvocDataBuf[0], ii);
			if (1u == outnetSafeSendRtn)
			{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/                 
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
				debug_infor_printf((const)"\nVOBC_SEND:%d", ii);
				debug_out_array(0xAA, cszCiToIvocDataBuf, ii);
#endif/*平台打印结束*/
#endif
				chRetVal = CI_SUCCESS;
			}
			else
			{
				/*写队列失败*/
				chRetVal = CI_ERROR;
				debug_infor_printf((const)"\nWrite VOBC %d dataQueue Error Len = %d\n", pstVobcToCiDataStru->VobcId, ii);
			}


			if (CI_ERROR == chRetVal)
			{
				SetErrorData(EFUNC_PACK_CI2VOBC_DATA, CI_DEVICE_TYPE_COMM_VOBC, pstVobcToCiDataStru->VobcId, ETYPE_COMM_WITH_VOBC, 0, ESEND_LEVEL_ZERO);
			}
			
		}
	}

	return chRetVal;
}

/*
* 功能描述： 组车车备用通道Ivoc数据
* 参数说明： QueueStruct* CiToVobcDataQueue, 组包发送队列地址
*			 VobcBackUpToCiDataStruct *pstVobcBackUpToCiDataStru Vobc备用通道信息结构体
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
static UINT8 PackCiToIvocBackUpDataCC(VobcBackUpToCiDataStruct *pstVobcBackUpToCiDataStru)
{
	UINT8 cszCiToIvocDataBuf[VOBC_TO_CI_DATA_LEN_MAX] = { 0u };/*CI到VOBC组帧数组*/
	UINT16 ii = 0u;
	UINT8 psdIndex = 0U;				/*PSD索引*/
	UINT32 curCycleNum = Get2oo2CurCycleNum();
	UINT32 appCycleTime = GetSystemParaAppCycleTime();
	UINT8 chRetVal = CI_ERROR;
	UINT8 localCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/
	UINT32 ciEtcsId = 0u;
	UINT32 vobcEtcsId = 0u;
	UINT32 emapCheckVer = 0u;
	UINT8 localhlhtId = 0u;
	UINT8 vobcHlhtId = 0u;
	UINT8 ciEmapCheckVer = 0u;
	UINT16 wAppInfoIndex = 0U;
	UINT16 dstDevId = 0u;
	UINT8 outnetSafeSendRtn = 0u;
	UINT8 chFunRtn = CI_ERROR;
	UINT8 chSwState = 0u;
	/*首先获取组包时所需的信息，获取成功才有必要继续组包*/

	if (NULL != pstVobcBackUpToCiDataStru)
	{
		localhlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + localCiId, 0U, &ciEtcsId);
		vobcHlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC * 256U) + (UINT8)(pstVobcBackUpToCiDataStru->VobcId), pstVobcBackUpToCiDataStru->vobcLogId, &vobcEtcsId);
		ciEmapCheckVer = GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC);
	}
	else
	{
		;
	}

	if ((CI_SUCCESS == localhlhtId) && (CI_SUCCESS == vobcHlhtId) && (CI_SUCCESS == ciEmapCheckVer))
	{
		chRetVal = CI_SUCCESS;
	}
	else
	{
		debug_infor_printf((const)"\nPack vobc %d data check error", pstVobcBackUpToCiDataStru->VobcId);
		chRetVal = CI_ERROR;
	}

	if (CI_SUCCESS == chRetVal)
	{
		ii = 0u;
		/*开始组应用数据帧*/

		ShortToChar(IVOC_CI_BACKUP_INTERFACE_INFOTYPE, &cszCiToIvocDataBuf[ii]);/*接口信息类型*/
		ii += 2u;
		LongToChar(ciEtcsId, &cszCiToIvocDataBuf[ii]);/*发送方标识信息*/
		ii += 4u;
		LongToChar(vobcEtcsId, &cszCiToIvocDataBuf[ii]);/*接收方标识信息*/
		ii += 4u;
		LongToChar(emapCheckVer, &cszCiToIvocDataBuf[ii]);/*电子地图版本校验信息*/
		ii += 4u;
		LongToChar(curCycleNum, &cszCiToIvocDataBuf[ii]);/*本方消息序列号*/
		ii += 4u;
		ShortToChar((UINT16)appCycleTime, &cszCiToIvocDataBuf[ii]);/*设备通讯周期*/
		ii += 2u;
		LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(pstVobcBackUpToCiDataStru->VobcId)), &cszCiToIvocDataBuf[ii]);/*对方消息序列号：recvOppMsgSN记录收到对方上一条消息中的对方消息序列号*/
		ii += 4u;
		LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(pstVobcBackUpToCiDataStru->VobcId)), &cszCiToIvocDataBuf[ii]);/*收到上一条消息时本方序列号*/
		ii += 4u;
		cszCiToIvocDataBuf[ii++] = CI_VOBC_BACKUP_PRTCL_VER;/*CI_VOBC后备通道接口协议版本号*/
		ii += 2u;/*通用报文头中的应用层报文总长度*/

				 /*以下为应用层数据*/
		ii += 2u;/*报文长度*/

		wAppInfoIndex = ii;
		ii += 2u;/*应用报文类型*/

		ii += 2u;/*预留两个字节*/

		if (IVOC_CI_BACKUPINFO_TYPE_CONTROL == pstVobcBackUpToCiDataStru->appInfoType)
		{
			ShortToChar(CI_IVOC_BACKUPINFO_TYPE_STATE, &cszCiToIvocDataBuf[wAppInfoIndex]);

			/*组备用通道发给车的逻辑区段信息*/
			chRetVal = PackCiToIvocBackUpLogSecInfo(cszCiToIvocDataBuf, &ii,pstVobcBackUpToCiDataStru->VobcId);

			if (CI_SUCCESS == chRetVal)
			{
				/*组备用通道发给车的进路信息*/
				chRetVal = PackCiToIvocBackUpRouteInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpLogSecInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				/*组备用通道发给车的折返逻辑区段信息*/
				chRetVal = PackCiToIvocBackUpReturnLogInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpRouteInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			if (CI_SUCCESS == chRetVal)
			{
				/*组备用通道发给车的PSD的信息*/
				chRetVal = PackCiToIvocBackUpPsdInfo(cszCiToIvocDataBuf, &ii,pstVobcBackUpToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpReturnLogInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*组备用通道发给车已激活的SPKS信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocBackUpSpksInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpPsdInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*组备用通道发给车的ESB的信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocBackUpEsbInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpSpksInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*组道岔信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocBackUpSwitchInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpEsbInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*组备用通道发给车的保护区段状态信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocBackUpProtectLgcInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpSwitchInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*组备用通道发给车的TSR的信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocBackUpTsrInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpProtectLgcInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}
			
			/*组备用通道发给车的状态确认信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocBackUpReqStateInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpTsrInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*组备用通道发给车的防淹门信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocBackUpFloodInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpReqStateInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*组备用通道发给车的信号机状态信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToVobcSigInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpFloodInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*组备用通道发给车的前车位置信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocHeadTrainInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToVobcSigInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*组备用通道发给车的ITE全线切除信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocIteCutInfo(cszCiToIvocDataBuf, &ii);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocHeadTrainInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*组备用通道发给车的最远未占用逻辑区段信息*/
			if (CI_SUCCESS == chRetVal)
			{
				chRetVal = PackCiToIvocFarNoOccuLogInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId);
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocIteCutInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}


			if (CI_SUCCESS == chRetVal)
			{
				/*组包成功*/
			}
			else
			{
				/*发生组包错误*/
				debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocFarNoOccuLogInfo Error \n", pstVobcBackUpToCiDataStru->VobcId);
			}

			/*预留8字节*/
			ii += 8U;
		}
		else
		{
			/*信息类型错误，什么都不做*/
		}

		if (CI_SUCCESS == chRetVal)
		{
			if (CI_IVOC_PACKET_LENGTH_MAX > ii)
			{
				; /*继续执行*/
			}
			else
			{
				chRetVal = CI_ERROR;
			}
		}

		if (CI_SUCCESS == chRetVal)
		{
			/*应用层数据的报文长度 */
			cszCiToIvocDataBuf[31U] = (UINT8)((UINT8)((ii - 33u) >> 8u) & 0xffu);
			cszCiToIvocDataBuf[32U] = (UINT8)((ii - 33u) & 0xffu);

			/*通用报文头中应用层报文总长度*/
			cszCiToIvocDataBuf[29U] = (UINT8)((UINT8)((ii - 31U) >> 8U) & 0xffU);
			cszCiToIvocDataBuf[30U] = (UINT8)((ii - 31U) & 0xffU);

			dstDevId = ((UINT16)(CI_SYSTEM_TYPE_VOBC_BACKUP << 8U) | pstVobcBackUpToCiDataStru->VobcId);
			outnetSafeSendRtn = OutnetSafeSend(dstDevId, (pstVobcBackUpToCiDataStru->vobcLogId), &cszCiToIvocDataBuf[0], ii);
			if (1u == outnetSafeSendRtn)
			{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/                 
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
				debug_infor_printf((const)"\nVOBC_BACKUP_SEND:%d", ii);
				debug_out_array(0xAA, cszCiToIvocDataBuf, ii);
#endif/*平台打印结束*/
#endif
				chRetVal = CI_SUCCESS;
			}
			else
			{
				/*写队列失败*/
				chRetVal = CI_ERROR;
				debug_infor_printf((const)"\nWrite VOBC_BACKUP %d dataQueue Error Len = %d\n", pstVobcBackUpToCiDataStru->VobcId, ii);
			}


			if (CI_ERROR == chRetVal)
			{
				SetErrorData(EFUNC_PACK_CI2VOBC_DATA, CI_DEVICE_TYPE_COMM_VOBC, pstVobcBackUpToCiDataStru->VobcId, ETYPE_COMM_WITH_VOBC, 0, ESEND_LEVEL_ZERO);
			}

		}
	}

	return chRetVal;
}
/*
* 功能描述： 组包Ci到Ivoc道岔状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocSwitchInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT8 chSwStat = 0U;
	UINT16 wSwId = 0U;
	UINT16 wSwIndex = 0U;
	UINT16 wSwitchSum = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;


	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wSwitchSum = GetSwitchCurSum();
		if (SWITCH_SUM_MAX > wSwitchSum)
		{
			ShortToChar(wSwitchSum, &pDataBuf[ii]);
			ii += 2U;
			for (wSwIndex = 0U; wSwIndex < wSwitchSum; wSwIndex++)
			{
				wSwId = GetSwitchId(wSwIndex);
				if ((0U < wSwId) && (UINT16_MAX > wSwId))
				{
					ShortToChar(wSwId, &pDataBuf[ii]);
					ii += 2U;
					chSwStat = GetSwitchCurPosition(wSwId);
					switch (chSwStat)
					{
					case SWITCH_POSITION_DINGWEI:
						pDataBuf[ii] = CI_IVOC_SWITCH_POSTION_DING;
						break;
					case SWITCH_POSITION_FANWEI:
						pDataBuf[ii] = CI_IVOC_SWITCH_POSTION_FAN;
						break;
					case SWITCH_POSITION_JICHA:
					case SWITCH_POSITION_MOVE:
					case SWITCH_POSITION_SIKAI:
					case SWITCH_POSITION_INVALID:
						pDataBuf[ii] = CI_IVOC_SWITCH_POSTION_SHIBIAO;
						break;
					default:
						/*道岔状态错误，停止组包*/
						chRetVal = CI_ERROR;
						break;

					}
					/*索引加1*/
					ii++;
				}
				else
				{
					/*道岔状态错误，停止组包*/
					chRetVal = CI_ERROR;
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
		}
		else
		{
			/*道岔数量错误 停止组包*/
			chRetVal = CI_ERROR;
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc屏蔽门状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocPsdInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{

	UINT8 chPsdTmpStat = 0U;
	UINT8 chPsdDoorStat = 0U;
	UINT8 chPsdMutualLockStat = 0U;
	UINT16 wPsdId = 0U;
	UINT16 wPsdIndex = 0U;
	UINT16 wPsdSum = 0U;
	UINT16 ii = 0U;
	UINT16 psdDepartureButtonRelayId = 0U;
	UINT8 platDepartButtState = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 psdButtonPangluState = 0U;
	UINT8 gapDetStatus=0U;
	UINT8 gapDetMutualLockRemvSta=0U;
	UINT32 psdStartDetCycNum=0U;
	UINT8 chTimeState = 0U;
	UINT8 chCleFarePcbState = 0U;/*清客确认箱PCB按钮状态*/
	UINT32 dwPsdButPreTimeCount = 0U;/*站台按钮吸起失效时间*/
	UINT32 dwPslPcbPreCyc = 0U;/*PSL门控箱PCB按钮按下周期*/
	UINT32 dwCleFarePcbPreCyc = 0U;/*清客确认箱PCB按钮按下周期*/
	UINT8 chPslPcbTimeCheck = 0U;/*PSL门控箱PCB按钮吸起超时检查结果*/
	UINT8 chCleFarePcbTimeCheck = 0U;/*清客确认箱PCB按钮吸起超时检查结果*/
	UINT32 dwPobPreCyc = 0U;  /*POB按钮按下周期*/
	UINT32 dwPobButPreTimeCount = 0U;/*站台按钮吸起失效时间*/
	UINT8 chPobTimeCheck = 0U;  /*POB按钮吸起超时检查结果*/
	UINT8 psdLockRemoveState = 0U;/*屏蔽门互锁解除按钮继电器状态*/
	UINT16 psdMutualLockRelayId = 0U; /*互锁解除按钮继电器ID*/

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wPsdSum = GetPsdSum();
		if (PSD_SUM_MAX > wPsdSum)
		{
			pDataBuf[ii] = (UINT8)wPsdSum;
			ii += 1U;
			for (wPsdIndex = 0U; wPsdIndex < wPsdSum; wPsdIndex++)
			{
				wPsdId = GetPsdId(wPsdIndex);
				if ((0U < wPsdId) && (UINT16_MAX > wPsdId))
				{
					ShortToChar(wPsdId, &pDataBuf[ii]);
					ii += 2U;
					chPsdDoorStat = GetPsdState(wPsdId);
					chPsdMutualLockStat = GetPsdMutualLockRemoveState(wPsdId);
					psdButtonPangluState = GetPsdButtonPangluState(wPsdId);
					/*门关或已互锁解除发送关门*/
					if ((PSD_STATE_CLOSE == chPsdDoorStat) || (PSD_MUTUALLOCK_REMOVE_YES== chPsdMutualLockStat))
					{
						pDataBuf[ii] = CI_IVOC_PSD_STATE_CLOSE;
					}
					else if(PSD_STATE_OPEN==chPsdDoorStat)
					{

						pDataBuf[ii] = CI_IVOC_PSD_STATE_OPEN;
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\nPackCiToIvocPsdInfo PsdDoorState_Error, state: %d \n", chPsdDoorStat);
					}
					ii++;

					if (CI_SUCCESS == chRetVal)
					{
						chPsdTmpStat = GetPsdButtonState(wPsdId);
						chCleFarePcbState = GetCleFarePCBButtonState(wPsdId);
						if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState)
						{
							pDataBuf[ii] = CI_IVOC_PSD_PCB_PL;    /*站台关门按钮旁路值*/
						}
						else
						{
							dwPsdButPreTimeCount = GetPsdButtonPressCount();
							dwPslPcbPreCyc = GetPCBPressCycNum(wPsdId);
							dwCleFarePcbPreCyc = GetCleFarePCBPressCycNum(wPsdId);
							chPslPcbTimeCheck = SystemOverTimeCheck(dwPslPcbPreCyc, dwPsdButPreTimeCount);
							chCleFarePcbTimeCheck = SystemOverTimeCheck(dwCleFarePcbPreCyc, dwPsdButPreTimeCount);
							if ((CI_TIME_OUT == chPslPcbTimeCheck) || (CI_TIME_OUT == chCleFarePcbTimeCheck))
							{/*cgh修改成都四线清客需求:PSL门控箱PCB及清客确认箱中PCB只要有一个超时,站台按钮发送默认状态*/
								pDataBuf[ii] = CI_IVOC_PSD_PCB_STATE_UP;
							}
							else
							{
								if ((PSD_BUTTON_STATE_UP == chPsdTmpStat) && (QK_PSD_BUTTON_STATE_UP == chCleFarePcbState))
								{/*cgh修改成都四线清客需求：PSL门控箱PCB及清客确认箱中PCB均未按下,站台按钮发送未按下状态*/
									pDataBuf[ii] = CI_IVOC_PSD_PCB_STATE_UP;
								}
								else if ((PSD_BUTTON_STATE_DOWN == chPsdTmpStat) || (QK_PSD_BUTTON_STATE_DOWN == chCleFarePcbState))
								{/*cgh修改成都四线清客需求：PSL门控箱PCB及清客确认箱中PCB只要有一个按下,站台按钮发送按下状态*/
									pDataBuf[ii] = CI_IVOC_PSD_PCB_STATE_DOWN;
								}
								else
								{
									chRetVal = CI_ERROR;
									debug_infor_printf((const)"\nPackCiToIvocPsdInfo PsdButtonState_Error, PSDstate: %d  PCB-ButtonState: %d \n", chPsdTmpStat, chCleFarePcbState);
								}
							}
						}
						ii++;
					}

					if (CI_SUCCESS == chRetVal)
					{
						chPsdTmpStat =GetPsdOpenButtonState (wPsdId);
						if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState)
						{
							pDataBuf[ii] = CI_IVOC_PSD_POB_PL;    /*站台关门按钮默认值*/
						}
						else
						{
							dwPobPreCyc = GetPOBPressCycNum(wPsdId);
							dwPobButPreTimeCount = GetPsdButtonPressCount();
							chPobTimeCheck = SystemOverTimeCheck(dwPobPreCyc, dwPobButPreTimeCount);
							if (CI_TIME_OUT == chPobTimeCheck)
							{
								/*POB按钮超时，发送未激活状态*/
								pDataBuf[ii] = CI_IVOC_PSD_POB_STATE_INVALID;
							}
							else
							{
								if (PSD_OPEN_BUTTON_STATE_INVALID == chPsdTmpStat)
								{
									pDataBuf[ii] = CI_IVOC_PSD_POB_STATE_INVALID;/*未激活*/
								}
								else if (PSD_OPEN_BUTTON_STATE_VALID == chPsdTmpStat)
								{
									pDataBuf[ii] = CI_IVOC_PSD_POB_STATE_VALID;/*激活*/
								}
								else
								{
									chRetVal = CI_ERROR;
									debug_infor_printf((const)"\nPackCiToIvocPsdInfo PsdOpenButtonState_Error, state: %d \n", chPsdTmpStat);
								}
							}
						}
						ii++;
					}

					if (CI_SUCCESS == chRetVal)
					{
						psdDepartureButtonRelayId = GetPsdDeparConfmRelayId(wPsdId);
						/*屏蔽门发车按钮状态更新*/
						if ((0u != psdDepartureButtonRelayId) && (UINT16_MAX != psdDepartureButtonRelayId))
						{/*站台发车按钮继电器ID有效*/
							if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState)
							{
								pDataBuf[ii] = CI_IVOC_PSD_PDB_PL;    /*站台关门按钮默认值*/
							}
							else
							{
								platDepartButtState = GetPsdDepartButtonState(wPsdId);/*站台发车按钮状态*/
								chTimeState = SystemOverTimeCheck(GetPSBPressCycNum(wPsdId), GetPsdButtonPressCount());
								if (CI_TIME_OUT == chTimeState)
								{
									pDataBuf[ii] = CI_IVOC_PSD_PDB_STATE_INVALID;
								}
								else
								{
									pDataBuf[ii] = platDepartButtState;
								}
							}
						}
						else
						{/*无站台发车按钮给VOBC发送站台无发车按钮状态*/
							pDataBuf[ii] = CI_IVOC_PSD_PDB_NO_BUTTON;
						}
						ii++;
					}

					if (CI_SUCCESS == chRetVal)
					{
						gapDetStatus = GetPsdRemoraState(wPsdId);	/*获取间隙探测状态*/
						gapDetMutualLockRemvSta = GetJXTCMutualLockState(wPsdId);	/*获取间隙探测互锁解除状态*/
						psdStartDetCycNum = GetStartDetectionCycNum(wPsdId);			/*获取间隙探测启动开始周期*/

						if (((PSD_REMORA_NO == gapDetStatus) && (0u != psdStartDetCycNum))
							|| (JXTC_MUTUALLOCK_REMOVE_YES == gapDetMutualLockRemvSta))
						{/*无障碍物或间隙探测互锁解锁*/
							pDataBuf[ii++] = CI_IVOC_GAP_DETECT_STATUS_CLEAR;	/*无障碍物*/
						}
						else if ((PSD_REMORA_YES == gapDetStatus) && (0u != psdStartDetCycNum))
						{/*检测结果为有障碍物*/
							pDataBuf[ii++] = CI_IVOC_GAP_DETECT_STATUS_UNCLEAR;	/*有障碍物*/
						}
						else
						{/*其他情况发送默认值*/
							pDataBuf[ii++] = CI_IVOC_GAP_DETECT_STATUS_DEFAULT;	/*间隙探测状态默认值：未检测/无此功能*/
						}
					}

					/*组屏蔽门互锁解除按钮状态*/
					if (CI_SUCCESS == chRetVal)
					{
						psdMutualLockRelayId = GetPsdMutualLockRelayId(wPsdId);
						psdLockRemoveState = GetRelayCollState(psdMutualLockRelayId);

						/*继电器吸起——按钮按下*/
						if (RELAY_STATE_UP == psdLockRemoveState)
						{
							pDataBuf[ii++] = PSD_MUTUALLOCK_STATE_DOWN;
						}
						/*继电器落下——按钮未按下*/
						else if (RELAY_STATE_DOWN == psdLockRemoveState)
						{
							pDataBuf[ii++] = PSD_MUTUALLOCK_STATE_UP;	
						}
						else
						{
							/*发默认值*/
							pDataBuf[ii++] = PSD_MUTUALLOCK_STATE_DEFAULT;
						}
					}
					
				}
				else
				{
					/*屏蔽门ID错误，停止组包*/
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\nPackCiToIvocPsdInfo PsdID_Error, ID : %d \n", wPsdId);
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
		}
		else
		{
			/*屏蔽门当前数量错误 停止组包*/
			chRetVal = CI_ERROR;
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}


/*
* 功能描述： 组包Ci到Ivoc紧急按钮状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocEsbInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT8 chEsbStat = 0U;	/*记录状态*/
	UINT16 wEsbId = 0U; /*用作ID*/
	UINT16 wEsbIndex = 0U;
	UINT16 wEsbSum = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 chEsbCutState = 0U;

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wEsbSum =GetEsbSum();
		if (ESB_SUM_MAX > wEsbSum)
		{
			pDataBuf[ii] = (UINT8)wEsbSum;
			ii += 1U;
			for (wEsbIndex = 0U; wEsbIndex < wEsbSum; wEsbIndex++)
			{
				wEsbId = GetEsbId(wEsbIndex);
				if ((0U < wEsbId) && (UINT16_MAX > wEsbId))
				{
					ShortToChar(wEsbId, &pDataBuf[ii]);
					ii += 2u;
					chEsbStat = GetEsbState(wEsbId);
					chEsbCutState = GetEsbCutState(wEsbId);

					if (ESB_CUT_YES == chEsbCutState)
					{
						pDataBuf[ii++] = CI_IVOC_ESB_STATE_INVALID;
					}
					else if (ESB_CUT_NO == chEsbCutState)
					{
						if (ESB_STATE_VALID_NO == chEsbStat)
						{
							pDataBuf[ii++] = CI_IVOC_ESB_STATE_INVALID;
						}
						else if (ESB_STATE_VALID_YES == chEsbStat)
						{
							pDataBuf[ii++] = CI_IVOC_ESB_STATE_VALID;
						}
						else
						{
							chRetVal = CI_ERROR;
							debug_infor_printf((const)"\n PackCiToIvocEsbInfo EsbState_Error,  state: %d \n", chEsbStat);
						}
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocEsbInfo chEsbCutState_Error,  state: %d \n", chEsbCutState);
					}
				}
				else
				{
					/*紧急停车ID错误，停止组包*/
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocEsbInfo ESDID_Error, ID : %d \n", wEsbId);
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
		}
		else
		{
			/*紧急停车当前总数错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocEsbInfo EsbSum_Error,  sum: %d ; MAX: %d \n", wEsbSum, ESB_SUM_MAX);
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc无人折返按钮状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocARInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT8 chNonRelayStat = 0U;	/*记录状态*/
	UINT16 nonRetrunId = 0U; /*用作ID*/
	UINT16 nonReturunIndex = 0U;
	UINT16 nonReturnSum = 0U;
	UINT16 nonReturnRelayId = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 relaySum = 0u;
	UINT16* relayIdBuf;
	UINT8 virtualZDZFDevType = 0U;
	UINT8 virtualZDZFButtonState = 0U;
	UINT8 chNonRtnAdhesionState = 0U;/*无人折返按钮粘连状态*/

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		nonReturnSum = GetNonAutoReturnCurSum();
		if (NON_AUTO_RETURN_SUM_MAX >nonReturnSum )
		{
			pDataBuf[ii] = (UINT8)nonReturnSum;
			ii += 1U;
			for (nonReturunIndex = 0U; nonReturunIndex < nonReturnSum; nonReturunIndex++)
			{
				/*获取无人折ID*/
				nonRetrunId =GetNonReturnId (nonReturunIndex);
				if ((0U < nonRetrunId) && (UINT16_MAX > nonRetrunId))
				{
					/*组包无人折返ID*/
					ShortToChar(nonRetrunId, &pDataBuf[ii]);
					ii += 2u;
					/*获取无人折返指示灯ID*/
					nonReturnRelayId = GetNonRtnRlyId(nonRetrunId);
					virtualZDZFDevType = GetVirtualZDZFDevType();
					virtualZDZFButtonState = GetVirtualZDZFButtonState();

					/*无人折返按钮为虚拟设备*/
					if (CI_DEVICE_TYPE_AUTORETURN == virtualZDZFDevType)
					{
						if (VIRTUAL_ZDZFAJ_BUTTON_YES == virtualZDZFButtonState)
						{/*虚拟设备无人折返按钮按下*/
							pDataBuf[ii] = CI_IVOC_NON_RETURN_STATE_VALID;
						}
						else if (VIRTUAL_ZDZFAJ_BUTTON_NO == virtualZDZFButtonState)
						{
							pDataBuf[ii] = CI_IVOC_NON_RETURN_STATE_INVALID;
						}
						else
						{
							chRetVal = CI_ERROR;
							debug_infor_printf((const)"\n PackCiToIvocARInfo NonReturn_Virtual_Error, state : %d \n", chNonRelayStat);
						}
					}
					else
					{
						/*真实无人折返无人折返*/
						relaySum = GetIndicatorRelaySum(nonReturnRelayId);
						relayIdBuf = GetIndicatorRelayIdBuf(nonReturnRelayId);

						/*无人折返按钮继电器状态*/
						chNonRelayStat = GetRelayCollState(relayIdBuf[2]);
						if (RELAY_STATE_UP == chNonRelayStat)
						{
							chNonRtnAdhesionState = GetNonRtnAdhesionState(nonRetrunId);
							if (RTN_RELAY_ADHESION_NO == chNonRtnAdhesionState)
							{
								/*继电器吸起且无粘连——按钮按下*/
								pDataBuf[ii] = CI_IVOC_NON_RETURN_STATE_VALID;
							}
							else
							{
								/*有粘连*/
								pDataBuf[ii] = CI_IVOC_NON_RETURN_STATE_INVALID;
							}
						}
						else if (RELAY_STATE_DOWN == chNonRelayStat)
						{
							pDataBuf[ii] = CI_IVOC_NON_RETURN_STATE_INVALID;
						}
						else
						{
							chRetVal = CI_ERROR;
							debug_infor_printf((const)"\n PackCiToIvocARInfo NonReturn_RelayState_Error, state : %d \n", chNonRelayStat);
						}
						
					}
					/*索引加1*/
					ii++;
				}
				else
				{
					/*状态错误，停止组包*/
					chRetVal = CI_ERROR;				
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
		}
		else
		{
			/*当前总数错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocARInfo nonReturnSum_Error, id : %d \n", nonReturnSum);
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}
/*
* 功能描述： 组包Ci到IvocSpks状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocSpksInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT8 chSpksStat = 0U;	/*记录状态*/
	UINT16 wSpksId = 0U; /*用作ID*/
	UINT16 wSpksIndex = 0U;
	UINT16 wSpksSum = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 chSpksCutState = 0U;
	UINT8 checkflag = 0U; /*检查SPKS是否包含本控区物理区段*/
	UINT16 spksSendIndext = 0U;
	UINT16 wSPKSSendSum = 0U;

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wSpksSum = GetTotalSpksCurNum();/*大于等于SPKS_SUM_MAX返回0*/
		spksSendIndext = ii;
		wSPKSSendSum = 0U;

		ii += 2U;
		for (wSpksIndex = 0U; wSpksIndex < wSpksSum; wSpksIndex++)
		{
			wSpksId = GetSpksIdByIndex(wSpksIndex);
			if ((0U < wSpksId) && (UINT16_MAX > wSpksId))
			{
				/*增加检查条件：SPKS需要包含本控区区段*/
				checkflag = CheckSpksRelSecBelongCI(wSpksId);

				/*不包含本控区物理区段*/
				if (CI_SUCCESS == checkflag)
				{
					/*不组包此SPKS信息*/
				}
				/*包含本控区物理区段*/
				else if (CI_ERROR == checkflag)
				{
					ShortToChar(wSpksId, &pDataBuf[ii]);
					ii += 2u;
					chSpksStat = GetSpksState(wSpksId);
					chSpksCutState = GetSpksCutState(wSpksId);
					if (((SPKS_STATUS_YES == chSpksStat) || (SPKS_STATUS_NO == chSpksStat))
						&& ((SPKS_CUT_NO == chSpksCutState) || (SPKS_CUT_YES == chSpksCutState)))
					{

						if ((SPKS_STATUS_YES == chSpksStat) && (SPKS_CUT_NO == chSpksCutState))
						{
							/*等于封锁并且未旁路发送SPKS有效*/
							pDataBuf[ii] = CI_IVOC_SPKS_STATE_VALID;
						}
						else
						{
							pDataBuf[ii] = CI_IVOC_SPKS_STATE_INVALID;
						}
						/*索引加1*/
						ii++;
						wSPKSSendSum++;
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocSpksInfo SpksState_Error, SpksState : %d  SpksCutState : %d  \n", chSpksStat, chSpksCutState);
					}
				}
				else
				{
					/*检查错误，返回失败*/
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocSpksInfo SpksRelSecBelongCI_Error \n");
				}
			}
			else
			{
				/*spksID错误，停止组包*/
				chRetVal = CI_ERROR;
				debug_infor_printf((const)"\n PackCiToIvocSpksInfo Spksid_Error, id : %d \n", wSpksId);
			}
			if (CI_SUCCESS != chRetVal)
			{
				break;
			}
			else
			{
				/*继续执行*/
			}
		}

		/*组包SPKS数量*/
		ShortToChar(wSPKSSendSum, &pDataBuf[spksSendIndext]);

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc车库门状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocGaragedoorInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT8 chGaragedoorStat = 0U;	/*记录状态*/
	UINT16 wGaragedoorId = 0U; /*用作ID*/
	UINT16 wGaragedoorIndex = 0U;
	UINT16 wGaragedoorSum = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;


	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wGaragedoorSum = GetGaragedoorSum();
		if (GARAGE_DOOR_SUM_MAX > wGaragedoorSum)
		{
			pDataBuf[ii] = (UINT8)wGaragedoorSum;
			ii += 1U;
			for (wGaragedoorIndex = 0U; wGaragedoorIndex < wGaragedoorSum; wGaragedoorIndex++)
			{
				wGaragedoorId = GetGaragedoorId(wGaragedoorIndex);
				if ((0U < wGaragedoorId) && (UINT16_MAX > wGaragedoorId))
				{
					ShortToChar(wGaragedoorId, &pDataBuf[ii]);
					ii += 2u;
					chGaragedoorStat = GetGaragedoorState(wGaragedoorId);
					if (GARAGE_DOOR_STATE_OPEN == chGaragedoorStat)
					{
						pDataBuf[ii] = CI_IVOC_GARAGEDR_STATE_VALID;
					}
					else
					{
						/*其他情况导向安全侧，全为关门，门在关门过程中算关门*/
						pDataBuf[ii] = CI_IVOC_GARAGEDR_STATE_INVALID;
					}
					/*索引加1*/
					ii++;
				}
				else
				{
					/*车库门ID错误，停止组包*/
					chRetVal = CI_ERROR;
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
		}
		else
		{
			/*车库门当前总数错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocGaragedoorInfo GaragedoorSum_Error, sum : %d  MAX: %d \n", wGaragedoorSum, GARAGE_DOOR_SUM_MAX);
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc防淹门状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId,	列车ID
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocFloodGateInfo(UINT8* pDataBuf, UINT16  *wDataLength, UINT16 wTrainId)
{
	UINT16 wFloodGateId = 0U; /*用作ID*/
	UINT16 wFloodGateIndex = 0U;
	UINT16 wFloodGateSum = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 chRet = CI_ERROR;
	UINT8 floodOpenState = 0U;		/*开门锁定信息*/
	UINT8 floodCloseReq = 0U;		/*关门请求信息*/
	UINT8 floodCloseReqTempSta = 0U;

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wFloodGateSum = GetTotalFloodGateCurSum();
		if (FLOOD_GATE_SUM_MAX > wFloodGateSum)
		{
			pDataBuf[ii] = (UINT8)wFloodGateSum;
			ii += 1U;
			for (wFloodGateIndex = 0U; wFloodGateIndex < wFloodGateSum; wFloodGateIndex++)
			{
				wFloodGateId = GetFloodGateId(wFloodGateIndex);
				if ((0U < wFloodGateId) && (UINT16_MAX > wFloodGateId))
				{
					ShortToChar(wFloodGateId, &pDataBuf[ii]);
					ii += 2u;
					floodOpenState = GetFloodGateCurOpenLockState(wFloodGateId);
					if (FLOOD_GATE_OPENLOCK == floodOpenState)
					{
						pDataBuf[ii] = CI_IVOC_FLOODGATE_OPEN_LOCK;
					}
					else
					{
						pDataBuf[ii] = CI_IVOC_FLOODGATE_OPEN_LOCK_NO;
					}
					/*索引加1*/
					ii++;

					chRet = CheckProtectEnvelope(wFloodGateId, wTrainId);
					if (CI_SUCCESS == chRet)
					{
						/*包络有重叠，发无关门请求*/
						pDataBuf[ii] = CI_IVOC_FLOODGATE_CLOSE_REQ_NO;
					}
					else
					{
						/*包络无重叠，发关门请求实际状态*/
						floodCloseReqTempSta = GetFloodGateCurCloseRequestSta(wFloodGateId);
						if (FLOOD_GATE_CLOSEREQ == floodCloseReqTempSta)
						{
							pDataBuf[ii] = CI_IVOC_FLOODGATE_CLOSE_REQ;
						}
						else if (FLOOD_GATE_NOT_CLOSEREQ == floodCloseReqTempSta)
						{
							pDataBuf[ii] = CI_IVOC_FLOODGATE_CLOSE_REQ_NO;
						}
						else
						{
							chRetVal = CI_ERROR;		/*防淹门关门请求状态非法，停止组包*/
							debug_infor_printf((const)"\n PackCiToIvocFloodGateInfo floodCloseReqState_Error, state : %d  \n", floodCloseReqTempSta);
						}
					}

					/*索引加1*/
					ii++;
				}
				else
				{
					/*防淹门ID错误，停止组包*/
					chRetVal = CI_ERROR;
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
		}
		else
		{
			/*防淹门当前总数错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocFloodGateInfo FloodGateSum_Error, sum : %d  MAX: %d \n", wFloodGateSum, FLOOD_GATE_SUM_MAX);
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc封锁状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocFLockInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT8 chPhyFlockStat = 0U;	/*记录状态*/
	UINT16 wPhySecId = 0U; /*用作ID*/
	UINT16 wPhyIndex = 0U;
	UINT16 wPhySum = 0U;
	UINT16 wPhySendSumIndex = 0U;
	UINT16 wPhySendSum = 0U;
	UINT8  chStartLockStat = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 cTsrSureFlag = CI_TSR_SURE_NO;/* 限速确认标志 */
	UINT8 cSnowModel = CI_ALL_SNOW_UNVALID;/* 雨雪模式标志 */
	UINT8 cAllLineTsrState = CI_ALL_LINE_TSR_UNVALID;/* 全线临时限速 */
	UINT8 cAllLineTsrSpeed = 0U;/* 雨雪模式标志 */
	UINT8 chSecFLockType = 0U;/*物理区段封锁类型*/
	UINT8 cSnowLevel = 0U;  /*湿轨等级*/

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		chStartLockStat = GetStartFLockFlag();

		/*上电封锁状态*/
		if (CI_START_LOCK_NO == chStartLockStat)
		{
			pDataBuf[ii] = CI_IVOC_ALLLINE_FLOCK_NO;
		}
		else
		{
			pDataBuf[ii] = CI_IVOC_ALLLINE_FLOCK;
		}
		ii++;

		/* 限速确认标志位 */
		cTsrSureFlag = GetTsrSureFlag();
		if (CI_TSR_SURE_YES == cTsrSureFlag)
		{
			/* 已确认 */
			pDataBuf[ii] = cTsrSureFlag;
		}
		else
		{
			/* 未确认 */
			pDataBuf[ii] = CI_TSR_SURE_NO;
		}
		ii += 1U;

		/* 雨雪模式 */
		cSnowModel = GetAllSnowModel();
		cSnowLevel = GetAllSnowLevel();

		if (CI_ALL_SNOW_VALID == cSnowModel)
		{
			/* 雨雪 */
			if (CI_SNOW_LEVEL_TWO == cSnowLevel)
			{
				pDataBuf[ii] = CI_SNOW_LEVEL_TWO;  /*雨雪模式有效且湿轨等级为二级时，发0x02*/
			}
			else if(CI_SNOW_LEVEL_ONE == cSnowLevel)
			{
				pDataBuf[ii] = CI_SNOW_LEVEL_ONE;  /*雨雪模式有效且湿轨等级为一级时，发0x01*/
			}
			else
			{
				pDataBuf[ii] = CI_ALL_SNOW_VALID;  /*雨雪模式有效且湿轨等级为默认值时，发0x55*/
			}
		}
		else
		{
			/* 非雨雪 */
			pDataBuf[ii] = CI_ALL_SNOW_UNVALID;
		}
		ii += 1U;

		/* 全线临时限速信息 */
		cAllLineTsrState = GetAllLineTsrState();
		cAllLineTsrSpeed = GetAllLineTsrSpeed();
		if (CI_ALL_LINE_TSR_VALID == cAllLineTsrState)
		{
			/* 全线临时限速 */
			pDataBuf[ii] = CI_ALL_LINE_TSR_VALID;
			ii += 1U;
			pDataBuf[ii] = cAllLineTsrSpeed;
			ii += 1U;

		}
		else
		{
			pDataBuf[ii] = CI_ALL_LINE_TSR_UNVALID;
			ii += 1U;
			pDataBuf[ii] = 0u;
			ii += 1U;
		}

		wPhySum = GetPhySecCurSum();
		if (PHYSICAL_SECTION_SUM_MAX > wPhySum)
		{
			wPhySendSumIndex = ii;
			ii += 2U;
			for (wPhyIndex = 0U; wPhyIndex < wPhySum; wPhyIndex++)
			{
				wPhySecId =GetPhySecId (wPhyIndex);
				if ((0U < wPhySecId) && (UINT16_MAX > wPhySecId))
				{
					chPhyFlockStat =GetPhySecFLockState (wPhySecId);
					chSecFLockType = GetPhySecFLockType(wPhySecId);
					if ((PHYSICAL_SECTION_FLOCK_NO != chPhyFlockStat) && (PHY_SEC_FLOCK_TYPE_SPKS != chSecFLockType))
					{
						/*物理区段存在人工封锁才发送*/
						ShortToChar(wPhySecId,&pDataBuf[ii]);
						ii += 2U;
						wPhySendSum++;
					}
					else
					{
						/*继续执行*/
					}
				}
				else
				{
					/*物理区段ID错误，停止组包*/
					chRetVal = CI_ERROR;
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
			ShortToChar(wPhySendSum, &pDataBuf[wPhySendSumIndex]);
		}
		else
		{
			/*物理区段当前总数错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocFLockInfo PhySum_Error, sum : %d  MAX: %d \n", wPhySum, PHYSICAL_SECTION_SUM_MAX);
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc通信车状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocCommTrainInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT16 wTmpLinkId = 0U;
	UINT32 dwTmpOff = 0U;
	UINT16 wOrgnLinkId = 0u;
	UINT32 dwOrgnOffset = 0u;
	UINT8 chTrainDir = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 chHeadScreStat=0u;			/*列车前筛标志*/
	UINT8 chTailScreStat=0u;			/*列车后筛标志*/
	UINT16 szEnvelopeIdBuf[ENVELOPE_SUM_MAX] = { 0u };
	UINT16 wEnvelopeSum = 0u;
	UINT16 wEnvelopeIndex = 0u;
	UINT16 wEnvelopeId = 0u;
	UINT16 wEnvelopeSendSum = 0u;
	UINT8 chFunRtn = CI_ERROR;
	InfEnvelopeStruct strEnvelope = { 0u };
	UINT16 wEnvelopeSendSumIndex = 0u;
	UINT16 wTrainId = 0u;
	UINT8 chLinkLogicDirUpAndDown = 0u;
	UINT8 chTrainVirHeadScreenFlag = 0U;/*虚拟前筛标志*/
	UINT8 chTrainVirTailScreenFlag = 0U;/*虚拟后筛标志*/
	UINT8 chTrainNvramFlag = 0U;/*列车NVRAM标志*/
	UINT8 chTrainReportState = 0U;/*列车汇报状态*/

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		
		wEnvelopeSum = elm_GetCTEnvelope(szEnvelopeIdBuf);
		if (ENVELOPE_SUM_MAX > wEnvelopeSum)
		{
			wEnvelopeSendSumIndex = ii;
			ii += 1U;
			for (wEnvelopeIndex = 0U; wEnvelopeIndex < wEnvelopeSum; wEnvelopeIndex++)
			{
				wEnvelopeId = szEnvelopeIdBuf[wEnvelopeIndex];
				chFunRtn = elm_ConvertEnvelopeInfo(wEnvelopeId, &strEnvelope);
				if (CI_SUCCESS == chFunRtn)
				{
					wTmpLinkId = strEnvelope.endPos.Lnk;
					dwTmpOff = strEnvelope.endPos.Off;

					wOrgnLinkId = strEnvelope.startPos.Lnk;
					dwOrgnOffset = strEnvelope.startPos.Off;

					wEnvelopeSendSum++;
					wTrainId = (0x1400u + (strEnvelope.trainID[0] & 0x00FFu));
					
					pDataBuf[ii] = strEnvelope.trainID[0];
					ii += 1U;

					if ((0U != wTmpLinkId) && (UINT16_MAX != wTmpLinkId) && (UINT32_MAX != dwTmpOff))
					{
						ShortToChar(wTmpLinkId, &pDataBuf[ii]);
						ii += 2U;
						LongToChar(dwTmpOff, &pDataBuf[ii]);
						ii += 4U;
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo End_link&Off_Error, linkId : %d  Off: %d \n", wTmpLinkId, dwTmpOff);
					}

					if ((0U != wOrgnLinkId) && (UINT16_MAX != wOrgnLinkId) && (UINT32_MAX != dwOrgnOffset))
					{
						ShortToChar(wOrgnLinkId, &pDataBuf[ii]);
						ii += 2U;
						LongToChar(dwOrgnOffset, &pDataBuf[ii]);
						ii += 4U;
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo Start_link&Off_Error, linkId : %d  Off: %d \n", wOrgnLinkId, dwOrgnOffset);
					}

					chTrainDir = strEnvelope.startPos.Dir;
					chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown();
					if (DIR_SAME == chTrainDir)
					{
						chTrainDir = ~chLinkLogicDirUpAndDown;
					}
					else
					{
						chTrainDir = chLinkLogicDirUpAndDown;
					}

					if (TRAIN_DIR_UP == chTrainDir)
					{
						pDataBuf[ii] |= BIT_VAL_00000001B; /* 01B 上行*/
						
					}
					else if (TRAIN_DIR_DOWN == chTrainDir)
					{
						pDataBuf[ii] |= BIT_VAL_00000010B; /* 10B 下行*/

					}
					else
					{
						chRetVal = CI_ERROR;
					}
					/*前筛*/
					chTrainVirHeadScreenFlag = GetTrainVirHeadScreenPassFlag(wTrainId);
					if (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chTrainVirHeadScreenFlag)
					{
						chHeadScreStat = CI_IVOC_HEAD_SCREEN_PASS;
					}
					else
					{
						chHeadScreStat = strEnvelope.suspicHead;
					}

					if (CI_IVOC_HEAD_SCREEN_PASS == chHeadScreStat)
					{
						pDataBuf[ii] |= BIT_VAL_00000001B<<2; /*前端筛选通过 01B*/
					}
					else if (CI_IVOC_HEAD_SCREEN_UNKNOW == chHeadScreStat)
					{
						pDataBuf[ii] |= BIT_VAL_00000010B << 2; /*前端筛选不通过 10B*/
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo HeadScreState_Error, state : %d  \n", chHeadScreStat);
					}
					/*后筛*/
					chTrainVirTailScreenFlag = GetTrainVirTailScreenPassFlag(wTrainId);
					if (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chTrainVirTailScreenFlag)
					{
						chTailScreStat = CI_IVOC_TAIL_SCREEN_PASS;
					}
					else
					{
						chTailScreStat = strEnvelope.suspicTail;
					}

					if (CI_IVOC_TAIL_SCREEN_PASS == chTailScreStat)
					{
						pDataBuf[ii] |= BIT_VAL_00000001B << 4; /*后端筛选通过 01B*/
					}
					else if (CI_IVOC_TAIL_SCREEN_UNKNOW == chTailScreStat)
					{
						pDataBuf[ii] |= BIT_VAL_00000010B << 4; /*后端筛选不通过 10B*/
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo TailScreState_Error, state : %d  \n", chTailScreStat);
					}
					ii += 1U; /*列车信息一个字节偏移*/

					chTrainNvramFlag = GetTrainNvramPosFlag(wTrainId);
					chTrainReportState = GetTrainReportState(wTrainId);  /*该状态不检查非法值，直接发送*/
					if (TRAIN_NVRAM_POS_FLAG_YES == chTrainNvramFlag)
					{
						chTrainReportState = (UINT8)(chTrainReportState | 0X40U);
					}
					else
					{
						chTrainReportState = (UINT8)(chTrainReportState | 0X00U);
					}

					pDataBuf[ii] = chTrainReportState;

					ii += 1U;
				}
				else
				{
					/*包络ID错误，停止组包*/
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo EnvelopeId_Error, id : %d  \n", wEnvelopeId);
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
			pDataBuf[wEnvelopeSendSumIndex] = (UINT8)wEnvelopeSendSum;
		}
		else
		{
			/*线路所有的包络信息错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo EnvelopeSum_Error, sum : %d  MAX: %d \n", wEnvelopeSum, ENVELOPE_SUM_MAX);
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc故障车状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocFaultTrainInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT16 wTmpLinkId = 0U;
	UINT32 dwTmpOff = 0U;
	UINT16 wOrgnLinkId = 0u;
	UINT32 dwOrgnOffset = 0u;
	UINT8 chTrainDir = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 chHeadScreStat = 0u;			/*列车前筛标志*/
	UINT8 chTailScreStat = 0u;			/*列车后筛标志*/
	UINT16 szEnvelopeIdBuf[ENVELOPE_SUM_MAX] = { 0u };
	UINT16 wEnvelopeSum = 0u;
	UINT16 wEnvelopeIndex = 0u;
	UINT16 wEnvelopeId = 0u;
	UINT16 wEnvelopeSendSum = 0u;
	UINT8 chFunRtn = CI_ERROR;
	InfEnvelopeStruct strEnvelope = { 0u };
	UINT16 wEnvelopeSendSumIndex = 0u;
	UINT8 chTrainIndex = 0u;
	UINT16 wTrainId = 0u;
	UINT8 chLocalId = 0u;

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		chLocalId = GetSystemParaLocalCiId();
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wEnvelopeSum = elm_GetFaultEnvelope(szEnvelopeIdBuf);
		if (ENVELOPE_SUM_MAX > wEnvelopeSum)
		{
			wEnvelopeSendSumIndex = ii;
			ii += 1U;
			for (wEnvelopeIndex = 0U; wEnvelopeIndex < wEnvelopeSum; wEnvelopeIndex++)
			{
				wEnvelopeId = szEnvelopeIdBuf[wEnvelopeIndex];
				chFunRtn = elm_ConvertEnvelopeInfo(wEnvelopeId, &strEnvelope);
				if (CI_SUCCESS == chFunRtn)
				{
					wTmpLinkId = strEnvelope.endPos.Lnk;
					dwTmpOff = strEnvelope.endPos.Off;

					wOrgnLinkId = strEnvelope.startPos.Lnk;
					dwOrgnOffset = strEnvelope.startPos.Off;
					
					for (chTrainIndex = 0u; chTrainIndex < strEnvelope.trianCnt; chTrainIndex++)
					{
						wEnvelopeSendSum++;
						wTrainId = 0x14ffu;

						wTmpLinkId = strEnvelope.endPos.Lnk;
						dwTmpOff = strEnvelope.endPos.Off;

						if ((0U != wTmpLinkId) && (UINT16_MAX != wTmpLinkId) && (UINT32_MAX != dwTmpOff))
						{
							ShortToChar(wTmpLinkId, &pDataBuf[ii]);
							ii += 2U;
							LongToChar(dwTmpOff, &pDataBuf[ii]);
							ii += 4U;
						}
						else
						{
							chRetVal = CI_ERROR;
							debug_infor_printf((const)"\n PackCiToIvocFaultTrainInfo End_Link&Off_Error, link : %d  Off: %d \n", wTmpLinkId, dwTmpOff);
						}

						wTmpLinkId = strEnvelope.startPos.Lnk;
						dwTmpOff = strEnvelope.startPos.Off;

						if ((0U != wTmpLinkId) && (UINT16_MAX != wTmpLinkId) && (UINT32_MAX != dwTmpOff))
						{
							ShortToChar(wTmpLinkId, &pDataBuf[ii]);
							ii += 2U;
							LongToChar(dwTmpOff, &pDataBuf[ii]);
							ii += 4U;
						}
						else
						{
							chRetVal = CI_ERROR;
							debug_infor_printf((const)"\n PackCiToIvocFaultTrainInfo Start_Link&Off_Error, link : %d  Off: %d \n", wTmpLinkId, dwTmpOff);
						}
					}
				}
				else
				{
					/*包络ID错误，停止组包*/
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocFaultTrainInfo EnvelopeId_Error, id : %d  \n", wEnvelopeId);
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
			pDataBuf[wEnvelopeSendSumIndex] = (UINT8)wEnvelopeSendSum;
		}
		else
		{
			/*线路所有的包络信息错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocFaultTrainInfo EnvelopeSum_Error, sum : %d  MAX: %d  \n", wEnvelopeSum , ENVELOPE_SUM_MAX);
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc休眠车状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocSleepTrainInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT16 wTmpLinkId = 0U;
	UINT32 dwTmpOff = 0U;
	UINT16 wOrgnLinkId = 0u;
	UINT32 dwOrgnOffset = 0u;
	UINT8 chTrainDir = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 chHeadScreStat = 0u;			/*列车前筛标志*/
	UINT8 chTailScreStat = 0u;			/*列车后筛标志*/
	UINT16 szEnvelopeIdBuf[ENVELOPE_SUM_MAX] = { 0u };
	UINT16 wEnvelopeSum = 0u;
	UINT16 wEnvelopeIndex = 0u;
	UINT16 wEnvelopeId = 0u;
	UINT16 wEnvelopeSendSum = 0u;
	UINT8 chFunRtn = CI_ERROR;
	InfEnvelopeStruct strEnvelope = { 0u };
	UINT16 wEnvelopeSendSumIndex = 0u;
	UINT16 wTrainId = 0u;
	UINT8 chLinkLogicDirUpAndDown = 0u;
	UINT8 chTrainVirHeadScreenFlag = 0U;/*虚拟前筛标志*/
	UINT8 chTrainVirTailScreenFlag = 0U;/*虚拟后筛标志*/

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wEnvelopeSum = elm_GetSleepEnvelope(szEnvelopeIdBuf);
		if (ENVELOPE_SUM_MAX > wEnvelopeSum)
		{
			wEnvelopeSendSumIndex = ii;
			ii += 1U;
			for (wEnvelopeIndex = 0U; wEnvelopeIndex < wEnvelopeSum; wEnvelopeIndex++)
			{
				wEnvelopeId = szEnvelopeIdBuf[wEnvelopeIndex];
				chFunRtn = elm_ConvertEnvelopeInfo(wEnvelopeId, &strEnvelope);
				if (CI_SUCCESS == chFunRtn)
				{
					wTmpLinkId = strEnvelope.endPos.Lnk;
					dwTmpOff = strEnvelope.endPos.Off;

					wOrgnLinkId = strEnvelope.startPos.Lnk;
					dwOrgnOffset = strEnvelope.startPos.Off;
				
					wEnvelopeSendSum++;
					wTrainId = (0x1400u + (strEnvelope.trainID[0] & 0x00FFu));

					pDataBuf[ii] = strEnvelope.trainID[0];
					ii += 1U;

					if ((0U != wTmpLinkId) && (UINT16_MAX != wTmpLinkId) && (UINT32_MAX != dwTmpOff))
					{
						ShortToChar(wTmpLinkId, &pDataBuf[ii]);
						ii += 2U;
						LongToChar(dwTmpOff, &pDataBuf[ii]);
						ii += 4U;
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo End_Link&Off_Error, link : %d  Off: %d \n", wTmpLinkId, dwTmpOff);
					}



					if ((0U != wOrgnLinkId) && (UINT16_MAX != wOrgnLinkId) && (UINT32_MAX != dwOrgnOffset))
					{
						ShortToChar(wOrgnLinkId, &pDataBuf[ii]);
						ii += 2U;
						LongToChar(dwOrgnOffset, &pDataBuf[ii]);
						ii += 4U;
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo Start_Link&Off_Error, link : %d  Off: %d \n", wTmpLinkId, dwTmpOff);
					}

					chTrainDir = GetTrainSafeTailDir(strEnvelope.trainID[0]);
					chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown();
					if (DIR_SAME == chTrainDir)
					{
						chTrainDir = ~chLinkLogicDirUpAndDown;
					}
					else
					{
						chTrainDir = chLinkLogicDirUpAndDown;
					}

					if (TRAIN_DIR_UP == chTrainDir)
					{
						pDataBuf[ii] |= BIT_VAL_00000001B; /* 01B 上行*/

					}
					else if (TRAIN_DIR_DOWN == chTrainDir)
					{
						pDataBuf[ii] |= BIT_VAL_00000010B; /* 10B 下行*/

					}
					else
					{
						chRetVal = CI_ERROR;
					}
					/*前筛*/
					chTrainVirHeadScreenFlag = GetTrainVirHeadScreenPassFlag(wTrainId);
					if (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chTrainVirHeadScreenFlag)
					{
						chHeadScreStat = CI_IVOC_HEAD_SCREEN_PASS;
					}
					else
					{
						chHeadScreStat = strEnvelope.suspicHead;
					}
					if (CI_IVOC_HEAD_SCREEN_PASS == chHeadScreStat)
					{
						pDataBuf[ii] |= BIT_VAL_00000001B << 2; /*前端筛选通过 01B*/
					}
					else if (CI_IVOC_HEAD_SCREEN_UNKNOW == chHeadScreStat)
					{
						pDataBuf[ii] |= BIT_VAL_00000010B << 2; /*前端筛选不通过 10B*/
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo HeadScreState_Error, state : %d  \n", chHeadScreStat);
					}
					/*后筛*/
					chTrainVirTailScreenFlag = GetTrainVirTailScreenPassFlag(wTrainId);
					if (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chTrainVirTailScreenFlag)
					{
						chTailScreStat = CI_IVOC_TAIL_SCREEN_PASS;
					}
					else
					{
						chTailScreStat = strEnvelope.suspicTail;
					}
					if (CI_IVOC_TAIL_SCREEN_PASS == chTailScreStat)
					{
						pDataBuf[ii] |= BIT_VAL_00000001B << 4; /*后端筛选通过 01B*/
					}
					else if (CI_IVOC_TAIL_SCREEN_UNKNOW == chTailScreStat)
					{
						pDataBuf[ii] |= BIT_VAL_00000010B << 4; /*后端筛选不通过 10B*/
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo TailScreStat_Error, state : %d  \n", chTailScreStat);
					}
					ii += 1U; /*列车信息偏移量一个字节*/
				}
				else
				{
					/*包络ID错误，停止组包*/
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo End_Link&Off_Error, link : %d  Off: %d \n", wTmpLinkId, dwTmpOff);
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
			pDataBuf[wEnvelopeSendSumIndex] = (UINT8)wEnvelopeSendSum;
		}
		else
		{
			/*列车包络个数错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo EnvelopeSum_Error, sum : %d  MAX: %d  \n", wEnvelopeSum, ENVELOPE_SUM_MAX);
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc临时限速状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocTsrInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT8 chPhyFlockStat = 0U;	/*记录状态*/
	UINT16 wTsrId = 0U; /*用作ID*/
	UINT16 wTsrIndex = 0U;
	UINT8 cTsrSum = 0U;
	UINT16 wTmpLinkId = 0U;
	UINT32 dwTmpOff = 0U;
	UINT16 wTsrSpeed = 0U;
	UINT16 wTsrSecSum = 0U;
	UINT8 chTsrCommStat = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 jj = 0u;
	UINT8 kk = 0u;
	TsrDataStruct* pTsrData = NULL;

	pTsrData = GetTsrData();/*不会返回NULL*/

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		/* 获取限速数量 */
		cTsrSum = GetTsrSum();
		if (TSR_MAX_SUM >= cTsrSum)
		{
			/* 临时限速数量 */
			pDataBuf[ii] = cTsrSum;
			ii++;

			for (jj = 0u;jj < cTsrSum;jj++)
			{
				/* 组临时限速速度 */
				pDataBuf[ii] = pTsrData[jj].cSpeed;
				ii++;

				/* 组逻辑区段数量 */
				if ((0u == pTsrData[jj].cLogSecSum) || (TSR_SEC_MAX_SUM < pTsrData[jj].cLogSecSum))
				{
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocTsrInfo LogSecSum_Error, sum : %d  MAX: %d \n", pTsrData[jj].cLogSecSum, TSR_SEC_MAX_SUM);
				}
				else
				{
					pDataBuf[ii] = pTsrData[jj].cLogSecSum;
					ii++;
				}

				if (CI_SUCCESS == chRetVal)
				{
					for (kk = 0u; kk < pTsrData[jj].cLogSecSum;kk++)
					{
						/* 逻辑区段ID */
						if ((0u == pTsrData[jj].szLogSecId[kk]) || (UINT16_MAX == pTsrData[jj].szLogSecId[kk]))
						{
							chRetVal = CI_ERROR;
						}
						else
						{
							ShortToChar(pTsrData[jj].szLogSecId[kk], &pDataBuf[ii]);
							ii += 2u;
						}

						if (CI_ERROR == chRetVal)
						{
							debug_infor_printf((const)"\n PackCiToIvocTsrInfo LogSecId_Error, ID : %d \n", pTsrData[jj].szLogSecId[kk]);
							break;
						}
					}
				}

				if (CI_ERROR == chRetVal)
				{
					break;
				}
			}
		}
		else
		{
			/*临时限速数量错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocTsrInfo TsrSum_Error, sum : %d  MAX: %d \n", cTsrSum , TSR_MAX_SUM);
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

#if 0
/*
* 功能描述： 组包Ci到Ivoc计轴状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败 
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocAxisSgmtInfo(UINT8* pDataBuf, UINT16  *wDataLength)
{
	UINT8 chAxisSecHdStat = 0U;	/*记录状态*/
	UINT8 chAxisSecTlStat = 0U;
	UINT8 chAxisSecOccStt = 0U;
	UINT16 wAxisSecId = 0U; /*用作ID*/
	UINT16 wAxisSecIndex = 0U;
	UINT16 wAxisSecSum = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;


	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wAxisSecSum = GetAxisSecCurSum();
		if (AXIS_SECTION_SUM_MAX > wAxisSecSum)
		{
			ShortToChar(wAxisSecSum, &pDataBuf[ii]);
			ii += 2U;
			for (wAxisSecIndex = 0U; wAxisSecIndex < wAxisSecSum; wAxisSecIndex++)
			{
				wAxisSecId = GetAxisSecId(wAxisSecIndex);
				if ((0U < wAxisSecId) && (UINT16_MAX > wAxisSecId))
				{
					ShortToChar(wAxisSecId, &pDataBuf[ii]);
					ii += 2U;
					chAxisSecHdStat = GetAxisSecHeadUtCtState(wAxisSecId);
					chAxisSecTlStat = GetAxisSecTailUtCtState(wAxisSecId);
					if (AXIS_SECTION_UT_STATE == chAxisSecHdStat)
					{
						chAxisSecOccStt = CI_IVOC_AXIS_HEAD_UT;
					}
					else if (AXIS_SECTION_CT_STATE == chAxisSecHdStat)
					{

						chAxisSecOccStt = CI_IVOC_AXIS_HEAD_CT;
					}
					else
					{

					}

					if (AXIS_SECTION_UT_STATE == chAxisSecTlStat)
					{
						chAxisSecOccStt |= CI_IVOC_AXIS_TAIL_UT;
					}
					else if (AXIS_SECTION_CT_STATE == chAxisSecTlStat)
					{
						chAxisSecOccStt |= CI_IVOC_AXIS_TAIL_CT;
					}
					else
					{

					}

					if( (0U == chAxisSecOccStt)&&(AXIS_SECTION_FREE_STATE == chAxisSecHdStat)&&(AXIS_SECTION_FREE_STATE == chAxisSecTlStat))
					{
						chAxisSecOccStt = CI_IVOC_AXIS_HEAD_TAIL_FREE;
					}
					else if(0U!=chAxisSecOccStt)
					{
						/*已赋值*/
					}
					else
					{
						/*错误，停止组包*/
						chRetVal = CI_ERROR;
					}

					pDataBuf[ii] = chAxisSecOccStt;
					/*索引加1*/
					ii++;
				}
				else
				{
					/*错误，停止组包*/
					chRetVal = CI_ERROR;
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
		}
		else
		{
			/*计轴区段当前总数错误 停止组包*/
			chRetVal = CI_ERROR;
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}
#endif

/*
* 功能描述： 组包Ci到Ivoc逻辑区段状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocLgcSgmtInfo(UINT8* pDataBuf, UINT16  *wDataLength,UINT16 wVobcId)
{
	UINT8 chLogicSecLockDir = 0U;	/*记录状态*/
	UINT8 chLogicSendTrnFlag = 0U;  /*逻辑区段锁闭信息是否发送IVOC标志*/
	UINT8 chLogicTrainRetrunStt = 0U;
	UINT8 trainInRoute = 0U;
	UINT16 wLogicSecId = 0U; /*用作ID*/
	UINT16 wLogicSecIndex = 0U;
	UINT16 wLogicSecSum = 0U;
	UINT16 wLogicSecSendIndex = 0U;
	UINT16 wLogicSecSendSum = 0U;
	UINT16 wRouteId = 0U;
	UINT16 wPLockRouteId = 0U;
	UINT16 wRLockRouteId = 0U;
	UINT16 wRouteLockOverlapId = 0U;
	UINT16 ii = 0U;
	UINT16 wTrainSysId = 0U;
	LogicTrainResStruct * pstLogicResTrainInfo = NULL;
	UINT8 chRetVal = CI_ERROR;
	UINT8 logSecJumpLockSta = LOGIC_SECTION_JUMP_LOCK_NO;
	UINT16 logSecJumpLockTrnId = 0u;
	UINT8 logSecJumpLockPermFlag = LOGIC_JUMPUNLOCK_PERMISSIVE_NO;
	UINT8 chLogSecProResUseState = 0U;/*逻辑区段防护锁闭资源可用性状态*/
	UINT16 wLogSecBelongPhyId = 0U;/*逻辑区段所属物理区段ID*/
	UINT8 chLockDirOpposedFlag = ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK;/*锁闭方向是否取反标志*/
	UINT8 cRouteType = 0U;  /*进路类型*/
	UINT8 chLogSecBelLogRouteSum = 0U;/*逻辑区段所属逻辑进路数目*/
	UINT16 wLogSecTrainLogRouteSum = 0U;/*逻辑区段列车所属逻辑进路数目*/
	UINT16 wLogSecRLockRouteId = 0U;/*逻辑区段锁闭所属进路*/
	UINT8 chRouteType = 0U;/*进路类型*/
	UINT16 wRouteLastPhy = 0U;/*进路最后一个物理区段*/
	UINT8 chSendFlag = 0U;
	UINT16 wMinTailPointBelongLogSecId = 0U;
	struct_PathPoint strTrainMinTail = { 0u };


	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		wTrainSysId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + (wVobcId&0x00FFU);
		wLogicSecSum = GetLogicSecCurSum();
		strTrainMinTail.wLinkId = GetTrainMinTailLink(wVobcId);
		strTrainMinTail.dwOffset = GetTrainMinTailOffset(wVobcId);
		wMinTailPointBelongLogSecId = GetPointBelongLogSec(strTrainMinTail);
		if (LOGIC_SECTION_SUM_MAX > wLogicSecSum)
		{
			wLogicSecSendIndex = ii;
			wLogicSecSendSum = 0U;
			ii += 2U;
			for (wLogicSecIndex = 0U; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++)
			{
				wLogicSecId = GetLogicSecId(wLogicSecIndex);
				pstLogicResTrainInfo = NULL;
				if ((0U < wLogicSecId) && (UINT16_MAX > wLogicSecId))
				{
					pstLogicResTrainInfo = GetLogSecTrainInfoById(wLogicSecId, wTrainSysId);
					
					trainInRoute = GetTrainInLgcPRLock(wLogicSecId, wMinTailPointBelongLogSecId);   /*列车在进路中*/
					
					chLogicSendTrnFlag = GetLogSecTrainLockSendFlag(wLogicSecId, wTrainSysId);
					wRLockRouteId = GetLogSecLockBelongRoute(wLogicSecId);
					cRouteType = GetRouteType(wRLockRouteId);
					wLogSecTrainLogRouteSum = GetLogSecBelongLogRouteId(wLogicSecId, wTrainSysId);   /*获取指定列车逻辑区段锁闭锁闭关联进路*/
					chLogSecBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogicSecId);

					if (0U == chLogSecBelLogRouteSum)
					{
						chLogicSecLockDir = GetLogSecLockDir(wLogicSecId);
					}
					else
					{
						/*逻辑区段锁闭所属逻辑进路数目大于0，逻辑区段锁闭方向取逻辑进路（普通进路和逻辑进路叠加必然方向是一致的）*/
						chLogicSecLockDir = GetLogSecLogLockDir(wLogicSecId);
					}
					
					
					if (((CI_SUCCESS == chLogicSendTrnFlag) || (CI_SUCCESS == trainInRoute) || (0U < wLogSecTrainLogRouteSum))
						&& (ROUTE_TYPE_DIAOCHE != cRouteType))
					{
						wLogicSecSendSum += 1U;
						ShortToChar(wLogicSecId, &pDataBuf[ii]);
						ii += 2U;
						if ((CI_SYSTEM_DIRECTION_UP == chLogicSecLockDir)
							|| (CI_SYSTEM_DIRECTION_DOWN == chLogicSecLockDir))
						{
							wLogSecRLockRouteId = GetLogSecLockBelongRoute(wLogicSecId);
							wLogSecBelongPhyId = GetLgcSecRelativePhySecId(wLogicSecId);
							chLockDirOpposedFlag = GetRoutePhySecShouldLockOppose(wLogSecRLockRouteId, wLogSecBelongPhyId);

							if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == chLockDirOpposedFlag)
							{
								chLogicSecLockDir = ~chLogicSecLockDir;
							}
							else
							{
								; /*物理区段锁闭方向不需要取反，则说明逻辑区段也不需要取反*/
							}
							pDataBuf[ii] = chLogicSecLockDir;
							ii += 1U;
						}
						else
						{
							chRetVal = CI_ERROR;
							debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicSecLockDir_Error, DIR : %d  \n", chLogicSecLockDir);
						}

#if 0
						if ((0U < wRLockRouteId) && (0U < wPLockRouteId))
						{
							if ((ROUTE_STATE_NEAR_OPEN == chRouteState)
								|| (ROUTE_STATE_YUXIAN_OPEN == chRouteState))
							{
								pDataBuf[ii] = CI_IVOC_LOGSEC_PRLOCK_OPEN;
							}
							else
							{
								pDataBuf[ii] = CI_IVOC_LOGSEC_PRLOCK_CLOSE;
							}
						}
						else if (0 < wRLockRouteId)
						{
							pDataBuf[ii] = CI_IVOC_LOGSEC_RLOCK;
						}
						else if (0 < wPLockRouteId)
						{
							pDataBuf[ii] = CI_IVOC_LOGSEC_PLOCK;
						}
						else
						{
							chRetVal = CI_ERROR;
						}
						ii++;
#endif
						if (NULL == pstLogicResTrainInfo)
						{

							pDataBuf[ii] = LOGIC_SECTION_RES_UNUSABLE;
							ii += 1U;

						}
						else
						{
							if ((LOGIC_SECTION_RES_UNUSABLE == pstLogicResTrainInfo->chLogicResUsable)
								|| (LOGIC_SECTION_RES_USABLE == pstLogicResTrainInfo->chLogicResUsable))
							{
								pDataBuf[ii] = pstLogicResTrainInfo->chLogicResUsable;
								ii += 1U;
							}
							else
							{
								chRetVal = CI_ERROR;
								debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicResUsable_Error, state : %d  \n", pstLogicResTrainInfo->chLogicResUsable);
							}
						}

					}
					else
					{
						/*继续执行，跳过该逻辑区段*/
					}
					
				}
				else
				{
					/*错误，停止组包*/
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicSecId_Error, ID : %d  \n", wLogicSecId);
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}

			ShortToChar(wLogicSecSendSum, &pDataBuf[wLogicSecSendIndex]);

			/*防护锁闭逻辑区段组包*/
			if (CI_SUCCESS == chRetVal)
			{
				wLogicSecSendIndex = ii;
				wLogicSecSendSum = 0U;
				ii += 2U;

				for (wLogicSecIndex = 0U; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++)
				{
					wLogicSecId = GetLogicSecId(wLogicSecIndex);
					if ((0U < wLogicSecId) && (UINT16_MAX > wLogicSecId))
					{
						chLogSecProResUseState = GetLogSecProResUseState(wLogicSecId);
						wPLockRouteId = GetLogSecPLockRouteId(wLogicSecId);
						chLogicSecLockDir = GetLogSecLockDir(wLogicSecId);
						if(0U < wPLockRouteId)
						{
							wLogicSecSendSum++;
							ShortToChar(wLogicSecId, &pDataBuf[ii]);
							ii += 2U;
							if ((CI_SYSTEM_DIRECTION_UP == chLogicSecLockDir)
								|| (CI_SYSTEM_DIRECTION_DOWN == chLogicSecLockDir))
							{
								pDataBuf[ii] = chLogicSecLockDir;
								ii += 1U;
							}
							else
							{
								chRetVal = CI_ERROR;
							}
							if ((LOGIC_SECTION_PRO_RES_USABLE == chLogSecProResUseState)
								|| (LOGIC_SECTION_PRO_RES_UNUSABLE == chLogSecProResUseState))
							{
								pDataBuf[ii] = chLogSecProResUseState;
								ii += 1U;
							}
							else
							{
								chRetVal = CI_ERROR;
								debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogSecProResUseState_Error, state : %d  \n", chLogSecProResUseState);
							}
						}
						else
						{
							/*继续执行，跳过该逻辑区段*/
						}
					}
					else
					{
						/*错误，停止组包*/
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicSecId_PRO_Error, ID : %d  \n", wLogicSecId);
					}
					if (CI_SUCCESS != chRetVal)
					{
						break;
					}
					else
					{
						/*继续执行*/
					}
				}
				ShortToChar(wLogicSecSendSum, &pDataBuf[wLogicSecSendIndex]);
			}

			/*折返属性逻辑区段*/
			if (CI_SUCCESS == chRetVal)
			{
				wLogicSecSendIndex = ii;
				wLogicSecSendSum = 0U;
				ii += 2U;
				for (wLogicSecIndex = 0U; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++)
				{
					wLogicSecId = GetLogicSecId(wLogicSecIndex);
					if ((0U < wLogicSecId) && (UINT16_MAX > wLogicSecId))
					{
						chLogicSendTrnFlag = GetLogSecTrainLockSendFlag(wLogicSecId, wTrainSysId);
						if (CI_SUCCESS == chLogicSendTrnFlag)
						{
							wLogSecRLockRouteId = GetLogSecLockBelongRoute(wLogicSecId);
							chRouteType = GetConfigRouteType(wLogSecRLockRouteId);

							/*获取逻辑区段管理物理区段、进路最后一个物理区段*/
							wLogSecBelongPhyId = GetLgcSecRelativePhySecId(wLogicSecId);
							wRouteLastPhy = GetRouteLastPhySectionId(wLogSecRLockRouteId);

							if ((ROUTE_TYPE_RETURN == chRouteType) && (wLogSecBelongPhyId == wRouteLastPhy))
							{
								chLogicTrainRetrunStt = LOGIC_SECTION_TRAIN_RETURN_YES;
							}
							else
							{
								chLogicTrainRetrunStt = LOGIC_SECTION_TRAIN_RETURN_NO;
							}
							if (LOGIC_SECTION_TRAIN_RETURN_YES == chLogicTrainRetrunStt)
							{
								/*逻辑区段为列车资源且为折返区段*/
								wLogicSecSendSum += 1U;
								ShortToChar(wLogicSecId, &pDataBuf[ii]);
								ii += 2U;
							}
							else
							{
								/*继续执行，跳过该逻辑区段*/
							}
						}
						else
						{
							/*继续执行，跳过该逻辑区段*/
						}
					}
					else
					{
						/*错误，停止组包*/
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicSecId_ZF_Error, ID : %d  \n", wLogicSecId);
					}
					if (CI_SUCCESS != chRetVal)
					{
						break;
					}
					else
					{
						/*继续执行*/
					}
				}

				/*折返属性逻辑区段数量0-100合法*/
				if (100u < wLogicSecSendSum)
				{/*数量不合法*/
					wLogicSecSendSum = 100u;
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo ZFLogicSum_Error, sum : %d  MAX: %d \n", wLogicSecSendSum, 100u);
				}
				else
				{
					;/*数量合法*/
				}
				ShortToChar(wLogicSecSendSum, &pDataBuf[wLogicSecSendIndex]);
			}

			/** 组跳跃锁闭逻辑区段 */
			if (CI_SUCCESS == chRetVal)
			{
				wLogicSecSendIndex = ii;
				wLogicSecSendSum = 0U;
				ii += 2U;
				for (wLogicSecIndex = 0U; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++)
				{
					wLogicSecId = GetLogicSecId(wLogicSecIndex);
					if ((0U < wLogicSecId) && (UINT16_MAX > wLogicSecId))
					{
						logSecJumpLockTrnId = GetLogSecJumpLockTrainId(wLogicSecId);
						if (logSecJumpLockTrnId == wTrainSysId)
						{
							/** 指定列车ID申请跳跃锁闭的逻辑区段数量和ID*/
							wLogicSecSendSum += 1U;
							ShortToChar(wLogicSecId, &pDataBuf[ii]);
							ii += 2U;

							/** 逻辑区段允许标志*/
							logSecJumpLockPermFlag = GetLogSecJumpLockPermFlag(wLogicSecId);
							if ((LOGIC_JUMPUNLOCK_PERMISSIVE_YES == logSecJumpLockPermFlag) 
								|| (LOGIC_JUMPUNLOCK_PERMISSIVE_NO == logSecJumpLockPermFlag))
							{
								pDataBuf[ii++] = logSecJumpLockPermFlag;
							}
							else
							{
								chRetVal = CI_ERROR;
								debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogSecJumpLockPermFlag_Error, flag : %d  \n", logSecJumpLockPermFlag);
							}

							/** 逻辑区段锁闭状态*/
							logSecJumpLockSta = GetLogSecJumpLockState(wLogicSecId);
							if (LOGIC_SECTION_JUMP_LOCK_YES == logSecJumpLockSta)
							{
								pDataBuf[ii++] = CI_IVOC_LOGSEC_JUMPLOCK_YES;
							}
							else if (LOGIC_SECTION_JUMP_LOCK_NO == logSecJumpLockSta)
							{
								pDataBuf[ii++] = CI_IVOC_LOGSEC_JUMPLOCK_NO;
							}
							else
							{
								chRetVal = CI_ERROR;
								debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogSecJumpLockState_Error, state : %d  \n", logSecJumpLockSta);
							}
						}
						else
						{
							/** 逻辑区段非该列车申请资源，不组包 */
						}

					}
					else
					{
						/*错误，停止组包*/
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicSecId_JUMP_Error, ID : %d  \n", wLogicSecId);
					}
					if (CI_SUCCESS != chRetVal)
					{
						break;
					}
					else
					{
						/*继续执行*/
					}
				}

				/*跳跃锁闭逻辑区段数量0-20合法*/
				if (20u < wLogicSecSendSum)
				{/*数量不合法*/
					wLogicSecSendSum = 20u;
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo JumpLogicSum_Error, sum : %d  MAX: %d \n", wLogicSecSendSum, 20u);
				}
				else
				{
					;/*数量合法*/
				}
				ShortToChar(wLogicSecSendSum, &pDataBuf[wLogicSecSendIndex]);
			}
		}
		else
		{
			/*逻辑区段数量错误 停止组包*/
			chRetVal = CI_ERROR;
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}



/*
* 功能描述： 组包Ci到Ivoc 请求与回复状态信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocReqAndReplyInfo(UINT8* pDataBuf, UINT16  *wDataLength,UINT16 wTrnId)
{
	UINT8 chPhyFlockStat = 0U;	/*记录状态*/
	UINT16 wRouteId = 0U; /*用作ID*/
	UINT16 wRouteBelongCiId = 0U; /*用作ID*/
	UINT16 wCiId = 0U; /*用作ID*/
	UINT16 wRouteIndex = 0U;
	UINT16 wRouteSum = 0U;
	UINT16 wTrainId = 0U;
	UINT16 wRouteSendSum = 0U;
	UINT16 wRouteSendIndex = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT32 dwCyc = 0u;
	UINT8 chDynRpl = 0u;
	UINT8 chScreenApply = 0u;
	UINT8 chEaNum = 0u;
	UINT8 chEaIndex = 0u;
	UINT16 wEaTrainId = 0u;
	UINT8 chEaLgcNum = 0u;
	UINT16 * pEaLgcId = NULL;
	UINT8 chLgcIndex = 0u;
	UINT32 dwMidLine = 0u;
	UINT8 chEaBuidFlag = 0u;
	UINT8 chPaType = 0u;
	UINT32 dwEaBuildCyc = 0u;
	UINT8 chRrmState = 0u;
	UINT8 chRrmReson = 0u;
	UINT16 wNextTioc = 0u;
	UINT32 dwHlhtNt = 0u;

	UINT16 wResourceCancelSendIndex = 0U;
	UINT16 wResourceCancelSendSum = 0U;
	UINT16 wResourceCancelTrainId = 0U;
	UINT32 dwResourceCancelCyc = 0u;

	UINT16 gdIndex = 0U;
	UINT16 gdCloseSendIndex = 0U;
	UINT16 gdApplyCloseTrainId = 0U;
	UINT8 gdApplyThisTrainCloseCount = 0U;
	UINT16 gdSum = 0U; /*当前防护门总数*/
	UINT16 wGaragedoorId = 0U;
	UINT32 wGDApplyIVOCStartCycle = 0U;


	UINT16 chFloodGateSum = 0U;			/*防淹门总数量*/
	UINT16 chFloodGateIndex = 0U;
	UINT16 wFloodGateSendNumIndex = 0U;
	UINT16 wFloodGateSendSum = 0U;		/*发送防淹门的数量*/
	UINT16 wFloodGateId = 0U;
	UINT8 wFloodGateBelongCiId = 0U;
	UINT8 wFloodGateCloseApplyIvocSum = 0U;		/*防淹门关门申请列车数量*/
	UINT16* wFloodGateCloseApplyIvocIdBuf = NULL;	/*防淹门关门申请列车id*/
	UINT16 wwFloodGateCloseApplyTrainID = 0U;
	UINT8 FloodGateCloseAnsIvocSum = 0U;		/*已经回复的列车数量*/
	FloodGateTrainAnsStruct *pFloodGatteAnsFromIvoc = NULL;			/*已经回复的列车信息*/
	UINT8 jj = 0U;
	UINT8 kk = 0U;
	UINT8 sendFlag = CI_ERROR;
	UINT32 wFloodGateDelayCloseStartCyc = 0U;		/*防淹门接近区段有车接近，延时开始时间即为向列车发申请的时间*/

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		sendFlag = CI_SUCCESS;

		chDynRpl = GetTrainDynRpl(wTrnId);
		/*动态测试*/
		
		pDataBuf[ii] = chDynRpl;
		ii += 1U;

		/*区间疏散*/
		chEaNum = GetEaNum();
		if (EA_MAX_NUM < chEaNum)
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo EaNum_Error, Num : %d  MAX: %d \n", chEaNum, EA_MAX_NUM);
		}
		else
		{
			pDataBuf[ii] = chEaNum;
			ii += 1U;
			for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++)
			{
				wEaTrainId = GetEvacuatingTrainIdByIndex(chEaIndex);
				chEaLgcNum = EaGetLgcNum(chEaIndex);
				pEaLgcId = EaGetLgcId(chEaIndex);
				dwMidLine = EaGetMidLine(chEaIndex);
				chEaBuidFlag = GetEaBuildedFlag(chEaIndex);
				chPaType = GetPaTypeByIndex(chEaIndex);
				dwEaBuildCyc = EaGetBuildCycNum(chEaIndex);
				if (NULL == pEaLgcId)
				{
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo GetLgcId_Error \n");
					break;
				}
				else
				{
					ShortToChar(wEaTrainId, &pDataBuf[ii]);
					ii += 2u;
					pDataBuf[ii] = chEaLgcNum;
					ii++;
					for (chLgcIndex = 0u; chLgcIndex < chEaLgcNum; chLgcIndex++)
					{
						ShortToChar(pEaLgcId[chLgcIndex], &pDataBuf[ii]);
						ii += 2u;
					}

					pDataBuf[ii] = chEaBuidFlag;
					ii++;

					LongToChar(dwMidLine, &pDataBuf[ii]);
					ii += 4u;

					pDataBuf[ii] = chPaType;
					ii++;

					LongToChar(dwEaBuildCyc, &pDataBuf[ii]);
					ii += 4u;
				}
			}
		}
		/*停车保证*/
		pDataBuf[ii] = 0U;
		wRouteSendIndex = ii;
		ii += 1U;
		wRouteSum = GetRouteCurSum();
		wCiId = GetSystemParaLocalCiId();
		for (wRouteIndex = 0U; wRouteIndex < wRouteSum; wRouteIndex++)
		{
			wRouteId = GetRouteId(wRouteIndex);
			wRouteBelongCiId = GetRouteBelongCiId(wRouteId);

			if ((0u != wRouteId) && ( ROUTE_SUM_MAX > wRouteId))
			{
				if (wRouteBelongCiId == wCiId)
				{
					wTrainId = GetRouteStopEnassureTrainId(wRouteId);
					dwCyc = GetRouteStopEnassureCyc(wRouteId);
					if (wTrnId == wTrainId)
					{
						wRouteSendSum++;
						ShortToChar(wRouteId, &pDataBuf[ii]);
						ii += 2U;

						LongToChar(dwCyc, &pDataBuf[ii]);
						ii += 4U;
					}
					else
					{
						/*继续执行*/
					}

				}
				else
				{
					/*继续执行*/
				}
			}
			else
			{
				chRetVal = CI_ERROR;
				debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo RouteId_Stop_Error , route: %d \n", wRouteId);
			}
		}

		if (CI_IVOC_STOP_ENASSURE_ROUTE_SUM > wRouteSendSum)
		{

			pDataBuf[wRouteSendIndex] = (UINT8)wRouteSendSum;
		}
		else
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo StopEnassureRouteSum_Error, sum : %d  MAX: %d \n", wRouteSendSum, CI_IVOC_STOP_ENASSURE_ROUTE_SUM);
		}

		/*资源取消申请*/
		pDataBuf[ii] = 0U;
		wResourceCancelSendIndex = ii;
		ii += 1U;
		for (wRouteIndex = 0U; wRouteIndex < wRouteSum; wRouteIndex++)
		{
			wRouteId = GetRouteId(wRouteIndex);
			wRouteBelongCiId = GetRouteBelongCiId(wRouteId);

			if ((0u != wRouteId) && (ROUTE_SUM_MAX > wRouteId))
			{
				if (wRouteBelongCiId == wCiId)
				{
					wResourceCancelTrainId = GetRouteResourceCancelTrainId(wRouteId);
					wResourceCancelTrainId &= 0x00FFu;
					dwResourceCancelCyc = GetRouteResourceCancelCyc(wRouteId);
					if (wTrnId == wResourceCancelTrainId)
					{
						wResourceCancelSendSum++;
						ShortToChar(wRouteId, &pDataBuf[ii]);
						ii += 2U;

						LongToChar(dwResourceCancelCyc, &pDataBuf[ii]);
						ii += 4U;
					}
					else
					{
						/*继续执行*/
					}

				}
				else
				{
					/*继续执行*/
				}
			}
			else
			{
				chRetVal = CI_ERROR;
				debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo RouteId_ResCancel_Error , route: %d \n", wRouteId);
			}
		}

		if (CI_IVOC_RESOURCE_CANCEL_RTSUM > wResourceCancelSendSum)
		{

			pDataBuf[wResourceCancelSendIndex] = (UINT8)wResourceCancelSendSum;
		}
		else
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo ResCancelRouteSum_Error, sum : %d  MAX: %d \n", wResourceCancelSendSum, CI_IVOC_RESOURCE_CANCEL_RTSUM);
		}

		/*组防淹门信息*/
		pDataBuf[ii] = 0U;
		wFloodGateSendNumIndex = ii;
		ii += 1U;  /*防淹门*/
		chFloodGateSum = GetFloodGateCurSum();
		for (chFloodGateIndex = 0U; chFloodGateIndex < chFloodGateSum; chFloodGateIndex++)
		{
			wFloodGateId = GetFloodGateId(chFloodGateIndex);
			wFloodGateBelongCiId = GetFloodGateBelongCiId(wFloodGateId);
			if ((0u != wFloodGateId) && (FLOOD_GATE_SUM_MAX > wFloodGateId))
			{
				if (wFloodGateBelongCiId == wCiId)
				{
					wFloodGateCloseApplyIvocSum = GetFloodGateCloseApplyIvocSum(wFloodGateId);
					wFloodGateCloseApplyIvocIdBuf = GetFloodGateCloseApplyIvocId(wFloodGateId);
					wFloodGateDelayCloseStartCyc = GetFloodGateDelayCloseStartCnt(wFloodGateId);
					if ((0U != wFloodGateCloseApplyIvocSum) && (NULL != wFloodGateCloseApplyIvocIdBuf) && (0U < wFloodGateDelayCloseStartCyc))
					{
						for (jj = 0U; jj < wFloodGateCloseApplyIvocSum; jj++)
						{
							wwFloodGateCloseApplyTrainID = wFloodGateCloseApplyIvocIdBuf[jj];
							wwFloodGateCloseApplyTrainID &= 0x00FFu;

							if (wTrnId == wwFloodGateCloseApplyTrainID)
							{
								/*检查此列车是否已经回复过同意关门，若回复过则不再申请*/
								FloodGateCloseAnsIvocSum = GetFloodGateCloseAnsIvocSum(wFloodGateId);
								pFloodGatteAnsFromIvoc = GetFloodGateCloseFromIvocStru(wFloodGateId);
								for (kk = 0U; kk < FloodGateCloseAnsIvocSum; kk++)
								{
									if ((wTrnId == pFloodGatteAnsFromIvoc[kk].wTrainId)
										&& (FLOOD_GATE_ALLOWCLOSE_IVOC == pFloodGatteAnsFromIvoc[kk].wFloodGateCloseIvocFlag))
									{
										sendFlag = CI_ERROR;
										break;		/*列车已经回复了同意关门，则无需再次申请*/
									}
								}

								if (CI_SUCCESS == sendFlag)
								{
									wFloodGateSendSum++;
									ShortToChar(wFloodGateId, &pDataBuf[ii]);
									ii += 2U;

									LongToChar(wFloodGateDelayCloseStartCyc, &pDataBuf[ii]);
									ii += 4U;
								}
								else
								{
									;		/*已经回复过允许的列车，不再申请*/
								}
								break;
							}
							else
							{
								;	/*不在防淹门接近区内的列车，不申请*/
							}
						}

					}
					else
					{
						;	/*当无申请的列车，则无需申请*/
					}
				}
				else
				{
					;	/*非本联锁的防淹门不申请*/
				}
			}
			else
			{
				chRetVal = CI_ERROR;
				debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo FloodGateId_Error , FloodGateId: %d \n", wFloodGateId);
			}
		}

		if (CI_IVOC_FLOODGATE_APPLY_SUM > wFloodGateSendSum)
		{
			pDataBuf[wFloodGateSendNumIndex] = (UINT8)wFloodGateSendSum;
		}
		else
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo FloodGateSendSum_Error, sum : %d  MAX: %d \n", wFloodGateSendSum, CI_IVOC_FLOODGATE_APPLY_SUM);
		}

		/*车库门关闭申请*/
		pDataBuf[ii] = 0U; /*预留申请数目*/
		gdCloseSendIndex = ii;
		ii += 1U;

		
		gdSum = GetGaragedoorSum();
		for (gdIndex = 0U; gdIndex < gdSum; gdIndex++)
		{
			wGaragedoorId = GetGaragedoorId(gdIndex);
			if ((0U != wGaragedoorId) && (GARAGE_DOOR_SUM_MAX != wGaragedoorId))
			{
				wGDApplyIVOCStartCycle = GetWaiteIVOCResponseStartCycNum(wGaragedoorId);
				if (0U != wGDApplyIVOCStartCycle)
				{
					/*关门申请过程中的车库门*/
					gdApplyCloseTrainId = GetGaragedoorNearestTrainId(wGaragedoorId);
					if (gdApplyCloseTrainId == wTrnId)
					{
						gdApplyThisTrainCloseCount++;

						ShortToChar(wGaragedoorId, &pDataBuf[ii]);
						ii += 2U;

						LongToChar(wGDApplyIVOCStartCycle, &pDataBuf[ii]);
						ii += 4U;
					}
					
				}
			}
			else
			{
				chRetVal = CI_ERROR;
				debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo  GaragedoorId_Error , GaragedoorId: %d \n", wGaragedoorId);
				break;
			}
		}


		if (GARAGE_DOOR_SUM_MAX > gdApplyThisTrainCloseCount)
		{

			pDataBuf[gdCloseSendIndex] = gdApplyThisTrainCloseCount;
		}
		else
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo GarageDoorSum_Error, sum : %d  MAX: %d \n", gdApplyThisTrainCloseCount, GARAGE_DOOR_SUM_MAX);
		}



		chScreenApply = GetTrainScreenApply(wTrnId);
		if ((TRAIN_HEAD_SCREEN_IVOC == chScreenApply) || (TRAIN_SCREEN_IVOC == chScreenApply))
		{/* 申请前筛 */
			pDataBuf[ii++] = CI_IVOC_SCREEN_REQ_YES;
		}
		else
		{
			pDataBuf[ii++] = CI_IVOC_SCREEN_REQ_NO;
		}

		if ((TRAIN_TAIL_SCREEN_IVOC == chScreenApply) || (TRAIN_SCREEN_IVOC == chScreenApply))
		{/* 申请后筛 */
			pDataBuf[ii++] = CI_IVOC_SCREEN_REQ_YES;
		}
		else
		{
			pDataBuf[ii++] = CI_IVOC_SCREEN_REQ_NO;
		}

		chRrmState = GetTrainRrmState(wTrnId);	
		chRrmReson = GetTrainRrmReson(wTrnId);	
		wNextTioc = GetTrainNextTioc(wTrnId);
		(void)dquDevName2HlhtId(wNextTioc, 0u, &dwHlhtNt);
		pDataBuf[ii++] = chRrmState;	/* 远程RM允许状态 */
		pDataBuf[ii++] = chRrmReson;	/* 远程RM不允许原因 */
		LongToChar(dwHlhtNt, &pDataBuf[ii]);	/* 下一TIOC互联互通编号 */
		ii += 4u;
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}
/*
* 功能描述： 组(FAO+HLHT)VOBC数据
* 参数说明： QueueStruct* CiToVobcDataQueue, 组包发送队列地址
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
UINT8 PackCiToVobcDataFAOHLHToneSelf(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = { 0 };/*CI到VOBC组帧数组*/
	UINT16 psdId = 0;                                       /*屏蔽门ID*/
	UINT32 psdIdInterConn = 0;                              /*互联互通4字节屏蔽门ID*/
	UINT8 startSigColour = 0;								/*屏蔽门关联的出站进路始端信号机*/
	UINT8 psdState = 0;                                     /*屏蔽门状态*/
	UINT16 ii = 0;
	UINT8 kk = 0;
	UINT16 sigId = 0;				/*信号机ID*/
	UINT8 rowIndex = 0;
	UINT8 colIndex = 0;
	UINT32 curCycleNum = Get2oo2CurCycleNum();
	UINT32 appCycleTime = GetSystemParaAppCycleTime();
	UINT8 retVal = CI_SUCCESS;
	UINT8 localCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/
	UINT32 ciEtcsId = 0u;
	UINT32 vobcEtcsId = 0u;
	UINT32 emapCheckVer = 0u;
	UINT8 outStationSignalAllowOrNot = CI_VOBC_SIGNAL_DEFAULT;			/*信号机的允许或禁止状态*/
	UINT32 signalIdInterConn = 0u;	/*互联互通4字节信号机ID*/
	UINT16 washMachineCurSum = GetWashMachineSum();        /*获取当前联锁包含洗车机数量*/
	UINT16 washMachineId = 0u;
	UINT8 psdValidFlag[2] = { 0,0 };							/*0无效，1有效*/
	UINT8 psdReopenButtState = 0u;                           /*站台再次开门按钮状态*/
	UINT8 platDepartButtState = 0u;                          /*站台发车按钮状态*/
	UINT8 psdCloseButtState = 0u;                            /*屏蔽门状态*/
	UINT8 gapDetStatus = 0u;									/*间隙探测状态*/
	UINT8 gapDetMutualLockRemvSta = 0u;						/*间隙探测互锁解除状态*/
	UINT32 psdStartDetCycNum = 0u;							/*PSD间隙探测开始周期*/
	UINT8 psdButtonPangluState = 0u;                         /*站台按钮旁路状态*/
	UINT8 washMachineState = 0u;                             /*洗车机故障状态*/
	UINT8 mutualLockState = 0u;                             /*互锁解除状态*/
	UINT16 psdDepartureButtonRelayId = 0u;                  /*站台发车按钮继电器*/
	UINT8 localhlhtId = 0u;
	UINT8 vobcHlhtId = 0u;
	UINT8 ciEmapCheckVer = 0u;
	UINT16 QKButtonRelayId = 0u;                            /*清客按钮继电器ID*/
	UINT8 QKButtonCollState = 0u;                          /*清客按钮继电器采集状态*/
	UINT8 flag = 0u;                                        /*清客按钮按下后PDB状态组默认值*/
	UINT8 washModeState = 0xff;
	UINT8 chPsdBelongCiId = 0U;
	UINT8 chPslPcbState = 0U;/*PSL门控箱PCB按钮状态*/
	UINT8 chCleFarePcbState = 0U; /*清客确认箱PCB按钮状态*/
	UINT32 dwPsdButPreTimeCount = 0U;/*站台按钮吸起失效时间*/
	UINT32 dwPslPcbPreCyc = 0U;/*PSL门控箱PCB按钮按下周期*/
	UINT32 dwCleFarePcbPreCyc = 0U;/*清客确认箱PCB按钮按下周期*/
	UINT8 chPslPcbTimeCheck = 0U;/*PSL门控箱PCB按钮吸起超时检查结果*/
	UINT8 chCleFarePcbTimeCheck = 0U;/*清客确认箱PCB按钮吸起超时检查结果*/
	UINT8 chWashWorkModeBack = WASH_WORKMODE_BACK_DEFAULT;/*洗车机工作模式设置反馈*/
	UINT16 wTempSendIndex = 0U;/*发送数组临时索引*/
	UINT8 chTempCheckFlag = CI_ERROR;

	/*首先获取组包时所需的信息，获取成功才有必要继续组包*/
	localhlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + localCiId, 0U, &ciEtcsId);
	vobcHlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC * 256U) + (UINT8)(vobcToCiDataStru->VobcId), vobcToCiDataStru->vobcLogId, &vobcEtcsId);
	ciEmapCheckVer = GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC);
	if ((CI_SUCCESS == localhlhtId) && (CI_SUCCESS == vobcHlhtId) && (CI_SUCCESS == ciEmapCheckVer))
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	debug_infor_printf((const)"\nPack vobc %d data,retVal = %d\n", vobcToCiDataStru->VobcId, retVal);	/*打印错误信息*/

	if (CI_SUCCESS == retVal)
	{
		ii = 0U;
#if 0
		/*通用协议帧头*/
		ii += 2U;
		CiToVobcDataBuffer[ii++] = CI_SYSTEM_TYPE_VOBC;		                    /*目的逻辑类型*/
		CiToVobcDataBuffer[ii++] = (UINT8)vobcToCiDataStru->VobcId;	        /*目的逻辑ID*/
		ShortToChar(vobcToCiDataStru->vobcLogId, &CiToVobcDataBuffer[ii]);	/*互联互通4IP VOBC1端或2端标识*/
		ii += 2U;
#endif
		/*开始组应用数据帧*/

		ShortToChar(CI_VOBC_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*接口信息类型*/
		ii += 2U;
		LongToChar(ciEtcsId, &CiToVobcDataBuffer[ii]);/*发送方标识信息*/
		ii += 4U;
		LongToChar(vobcEtcsId, &CiToVobcDataBuffer[ii]);/*接收方标识信息*/
		ii += 4U;
		LongToChar(emapCheckVer, &CiToVobcDataBuffer[ii]);/*电子地图版本校验信息*/
		ii += 4U;
		LongToChar(curCycleNum, &CiToVobcDataBuffer[ii]);/*本方消息序列号*/
		ii += 4U;
		ShortToChar((UINT16)appCycleTime, &CiToVobcDataBuffer[ii]);/*设备通讯周期*/
		ii += 2U;
		LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*对方消息序列号：recvOppMsgSN记录收到对方上一条消息中的对方消息序列号*/
		ii += 4U;
		LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*收到上一条消息时本方序列号*/
		ii += 4U;
		CiToVobcDataBuffer[ii++] = CI_VOBC_PRTCL_VER_FAOHLHT;/*HLHT+FAO_CI_VOBC接口协议版本号*/
		ii += 2U;/*通用报文头中的应用层报文总长度*/

		

		if ((VOBC_CI_INFO_TYPE_PSD_CONTROL == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{
			/*以下为应用层数据*/
			ii += 2U;/*报文长度*/

			ii += 2U;/*应用报文类型*/

			ii += 2U;/*预留两个字节*/
			/*只有当VOBC发送的信息类型是屏蔽门控制信息时，才组包如下内容；若信息类型为心跳帧，则只发送报文帧头（31+6）*/
			LongToChar(vobcToCiDataStru->trackSecID, &CiToVobcDataBuffer[ii]);/*回复收到的轨道区段ID*/
			ii += 4U;
			CiToVobcDataBuffer[ii++] = vobcToCiDataStru->psdCmdCode;   /*回复收到的状态开门码*/

			CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum;           /*屏蔽门数量*/

			for (kk = 0U; kk < 2U; kk++)
			{
				psdId = vobcToCiDataStru->PsdData[kk].PsdId;
				psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn;
				chPsdBelongCiId = GetPsdBelongCiId(psdId);
				
				if (localCiId != chPsdBelongCiId)
				{/*未查到此屏蔽门的相关信息：即此屏蔽门不属于本联锁*/
					

					LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]);                     /*屏蔽门ID*/
					ii += 4U;

					CiToVobcDataBuffer[ii++] = PSD_STATE_INVALID_HLHT;                             /*屏蔽门状态*/

					CiToVobcDataBuffer[ii++] = PSD_INVALID_CMD;              /*屏蔽门命令类型*/
				}
				else
				{/*此屏蔽门属于本联锁*/
					/*互锁解除状态*/
					mutualLockState = GetPsdMutualLockRemoveState(psdId);
					LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]);                                                   /*屏蔽门ID*/
					ii += 4U;

					if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState)
						|| (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState))
					{/*屏蔽门互锁解除*/

						psdState = PSD_STATE_CLOSE_VIETNAM;/*关闭且锁闭*/
					}
					else
					{/*屏蔽门未互锁解除*/

						if (GetPsdState(psdId) == PSD_STATE_CLOSE)
						{/*屏蔽门关门*/

							psdState = PSD_STATE_CLOSE_VIETNAM;/*关闭且锁闭*/
						}
						else
						{
							psdState = PSD_STATE_OPEN_VIETNAM;/*非关闭且锁闭*/
						}
					}

					CiToVobcDataBuffer[ii++] = psdState;                                                            /*屏蔽门状态*/
					CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdData[kk].CmdType;                            /*屏蔽门命令类型*/
				}

			}/*for (kk = 0; kk < vobcToCiDataStru->PsdSum; kk++)*/

			signalIdInterConn = vobcToCiDataStru->signalID;	/*互联互通4字节信号机ID*/

			LongToChar(signalIdInterConn, &CiToVobcDataBuffer[ii]);/*回复收到的信号机ID*/
			ii += 4U;
			/*根据互联互通4字节ID获取信号机ID*/
			chTempCheckFlag = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, signalIdInterConn, &sigId);

			if (CI_SUCCESS == chTempCheckFlag)
			{
				startSigColour = GetSignalCurColor(sigId);/*获取信号机当前显示颜色*/

				if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*获取始端信号机开放状态*/
				{/*信号开放*/
					outStationSignalAllowOrNot = CI_VOBC_SIGNAL_YES;
				}
				else
				{
					outStationSignalAllowOrNot = CI_VOBC_SIGNAL_NO;
				}
			}

			/*CI接收到的VOBC发送的信号机ID的状态*/
			CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNot;              /*CI->VOBC信号机状态*/

			ShortToChar(CI_VOBC_INFO_TYPE_PSD_STATE, &CiToVobcDataBuffer[33U]);/*屏蔽门控制报文类型，两字节（31+2）*/
			/*填充CI2VOBC状态信息长度*/
			CiToVobcDataBuffer[31U] = (UINT8)(((ii - 33U) >> 8U) & 0xffU);
			CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU);

			/*根据文档《区域轨道交通全自动运行信号系统互联互通VOBC-CI接口规格书-v1.6-20190109》修改，2019.02.20*/
			/*CI->VOBC全自动运行站台状态信息应用报文头*/
			ii += 2U;	/*报文长度*/
			ShortToChar(CI_VOBC_PLAT_CLEAR_PASSENGER_INFO, &CiToVobcDataBuffer[ii]);
			ii += 2U;	/*报文类型：全自动运行站台状态信息*/
			ii += 2U;	/*预留2字节*/

			/*CI2VOBC全自动运行站台状态信息，始终与CI2VOBC状态信息一同发送，如站台无相关按钮则发送默认值*/
			CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum;           /*屏蔽门数量*/
			for (kk = 0U; kk < 2U; kk++)
			{
				psdId = vobcToCiDataStru->PsdData[kk].PsdId;
				psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn;
				chPsdBelongCiId = GetPsdBelongCiId(psdId);
				LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]);                                                   /*屏蔽门ID*/
				ii += 4U;

				if (localCiId != chPsdBelongCiId)
				{

					CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;	/*站台关门按钮默认值*/
					CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;	/*站台开门按钮默认值*/
					CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;	/*站台发车按钮默认值*/
					CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_DEFAULT;	/*间隙探测状态默认值：未检测/无此功能*/
					CiToVobcDataBuffer[ii++] = CI_VOBC_REMOVE_OFF;   /*互锁解除默认值*/
				}
				else
				{/*屏蔽门ID有效*/
					/*获取全自动运行站台状态信息并组包发送给VOBC*/
					psdButtonPangluState = GetPsdButtonPangluState(psdId);
					if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState)
					{
						CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;    /*站台关门按钮默认值*/
					}
					else
					{
						dwPsdButPreTimeCount = GetPsdButtonPressCount();
						dwPslPcbPreCyc = GetPCBPressCycNum(psdId);
						dwCleFarePcbPreCyc = GetCleFarePCBPressCycNum(psdId);
						chPslPcbTimeCheck = SystemOverTimeCheck(dwPslPcbPreCyc, dwPsdButPreTimeCount);
						chCleFarePcbTimeCheck = SystemOverTimeCheck(dwCleFarePcbPreCyc, dwPsdButPreTimeCount);
						if ((CI_TIME_OUT == chPslPcbTimeCheck) || (CI_TIME_OUT == chCleFarePcbTimeCheck))
						{/*cgh修改成都四线清客需求:PSL门控箱PCB及清客确认箱中PCB只要有一个超时,站台按钮发送默认状态*/
							psdCloseButtState = PSD_RELATED_BUTTON_STATE_DEFAULT;
						}
						else
						{
							chPslPcbState = GetPsdButtonState(psdId);
							chCleFarePcbState = GetCleFarePCBButtonState(psdId);
							if ((PSD_BUTTON_STATE_DOWN == chPslPcbState) || (QK_PSD_BUTTON_STATE_DOWN == chCleFarePcbState))
							{/*cgh修改成都四线清客需求：PSL门控箱PCB及清客确认箱中PCB只要有一个按下,站台按钮发送按下状态*/
								psdCloseButtState = PSD_BUTTON_STATE_DOWN;
							}
							else
							{/*cgh修改成都四线清客需求：PSL门控箱PCB及清客确认箱中PCB都未按下,站台按钮发送未按下状态*/
								psdCloseButtState = PSD_BUTTON_STATE_UP;
							}
						}

						if ((PSD_RELATED_BUTTON_STATE_DEFAULT == psdCloseButtState) || (PSD_BUTTON_STATE_UP == psdCloseButtState) )
						{
							/*PCB按钮状态为落下或者无效时，如果清客按钮按下仍然可以发车*/
							QKButtonRelayId = GetQKButtonRelayId(psdId);
							if ((0u != QKButtonRelayId) && (UINT16_MAX != QKButtonRelayId))
							{
								QKButtonCollState = GetRelayCollState(QKButtonRelayId);
								if (RELAY_STATE_UP == QKButtonCollState)
								{
									psdCloseButtState = PSD_BUTTON_STATE_DOWN;
								}
							}
						}

						CiToVobcDataBuffer[ii++] = psdCloseButtState;

					}
					if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState)
					{
						CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;    /*站台开门按钮默认值*/
					}
					else
					{

						psdReopenButtState = GetPsdOpenButtonState(psdId);/*站台开门按钮状态*/
						if (CI_TIME_OUT == SystemOverTimeCheck(GetPOBPressCycNum(psdId), GetPsdButtonPressCount()))
						{
							CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;
						}
						else
						{
							CiToVobcDataBuffer[ii++] = psdReopenButtState;
						}
					}
					psdDepartureButtonRelayId = GetPsdDeparConfmRelayId(psdId);
					QKButtonRelayId = GetQKButtonRelayId(psdId);
					if ((0u != QKButtonRelayId) && (UINT16_MAX != QKButtonRelayId))
					{
						QKButtonCollState = GetRelayCollState(QKButtonRelayId);
						if (RELAY_STATE_UP == QKButtonCollState)
						{
							flag = 1u;
						}
					}
					/*屏蔽门发车按钮状态更新*/
					if ((0u != psdDepartureButtonRelayId) && (UINT16_MAX != psdDepartureButtonRelayId))
					{/*站台发车按钮继电器ID有效*/
						if ((PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState) || (1u == flag))
						{
							CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;    /*站台关门按钮默认值*/
						}
						else
						{
							platDepartButtState = GetPsdDepartButtonState(psdId);/*站台发车按钮状态*/
							if (CI_TIME_OUT == SystemOverTimeCheck(GetPSBPressCycNum(psdId), GetPsdButtonPressCount()))
							{
								CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT;
							}
							else
							{
								CiToVobcDataBuffer[ii++] = platDepartButtState;
							}
						}
					}
					else
					{/*无站台发车按钮给VOBC发送站台无发车按钮状态*/
						CiToVobcDataBuffer[ii++] = PLATFORM_DEPAR_BUTTON_NO;
					}
					gapDetStatus = GetPsdRemoraState(psdId);	/*获取间隙探测状态*/
					gapDetMutualLockRemvSta = GetJXTCMutualLockState(psdId);	/*获取间隙探测互锁解除状态*/
					psdStartDetCycNum = GetStartDetectionCycNum(psdId);			/*获取间隙探测启动开始周期*/

					if (((PSD_REMORA_NO == gapDetStatus) && (0U != psdStartDetCycNum))
						|| (JXTC_MUTUALLOCK_REMOVE_YES == gapDetMutualLockRemvSta))
					{/*无障碍物或间隙探测互锁解锁*/
						CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_CLEAR;	/*无障碍物*/
					}
					else if ((PSD_REMORA_YES == gapDetStatus) && (0U != psdStartDetCycNum))
					{/*检测结果为有障碍物*/
						CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_UNCLEAR;	/*有障碍物*/
					}
					else
					{/*其他情况发送默认值*/
						CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_DEFAULT;	/*间隙探测状态默认值：未检测/无此功能*/
					}

					/*获取互锁解除状态*/
					mutualLockState = GetPsdMutualLockRemoveState(psdId);
					if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState)
						|| (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState))
					{/*屏蔽门互锁解除*/

						CiToVobcDataBuffer[ii++] = CI_VOBC_REMOVE_YES;
					}
					else
					{
						CiToVobcDataBuffer[ii++] = CI_VOBC_REMOVE_NO;
					}
				}
			}

			/*填充站台状态信息应用报文长度*/
			CiToVobcDataBuffer[60U] = (UINT8)((UINT8)((ii - 62U) >> 8U) & 0xffU);
			CiToVobcDataBuffer[61U] = (UINT8)((ii - 62U) & 0xffU);
		}
		else if ((VOBC_CI_INFO_TYPE_FAO_INFO == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{
			/*以下为应用层数据*/
			ii += 2U;/*报文长度*/

			ii += 2U;/*应用报文类型*/

			ii += 2U;/*预留两个字节*/
			/*组全自动运行洗车信息帧*/
			/*当前认为一个联锁集中区最多有一个全自动洗车机*/
			if (1U == washMachineCurSum)
			{/*本联锁集中区有一台全自动洗车机*/
				washMachineId = GetWashMachineId(0U);                            /*获取全自动洗车机ID*/
				washMachineState = GetTrainEmergencyStopState(washMachineId);   /*获取全自动洗车机状态*/
				washModeState = GetWashModeState(washMachineId); /*获取洗车模式*/
				chWashWorkModeBack = GetWashWorkModeBackState(washMachineId);/*获取洗车机洗车模式设置反馈状态*/
			}

			/*全自动洗车相关信息*/
			if (1U == washMachineCurSum)
			{/*本联锁集中区有洗车机*/
				CiToVobcDataBuffer[ii++] = GetWashMachineRequestVerifySta(washMachineId);   /*1洗车请求确认：0x55允许洗车，0xaa不允许洗车*/
				CiToVobcDataBuffer[ii++] = GetHeadWashAllowState(washMachineId);              /*2允许通过1：0x55允许通过，0xaa禁止通过*/
				CiToVobcDataBuffer[ii++] = GetTailWashAllowState(washMachineId);              /*3允许通过2：0x55允许通过，0xaa禁止通过*/
				CiToVobcDataBuffer[ii++] = GetTrainOutWashPortAllowSta(washMachineId); /*4允许通过洗车区：0x55允许通过，0xaa禁止通过*/
				CiToVobcDataBuffer[ii++] = washMachineState;                                  /*5洗车机故障：0x55无故障，0xaa故障*/
				CiToVobcDataBuffer[ii++] = washModeState;                                     /*洗车模式：0x01:通过洗(侧洗)，0x02:端洗（全洗）*/
				CiToVobcDataBuffer[ii++] = chWashWorkModeBack;                                /*洗车模式设置反馈：5个取值*/
			}
			else
			{/*本联锁集中区没有洗车机,发送默认值,洗车机故障状态发送采集信息*/
				CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_REQUEST_INVALID;
				CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_HEADWASH_NO;
				CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_TAILWASH_NO;
				CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_OUT_NO_2;
				CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_FALUT_NO_2;
				CiToVobcDataBuffer[ii++] = XTA_MODE_STATE_NO;
				CiToVobcDataBuffer[ii++] = WASH_WORKMODE_BACK_DEFAULT;
			}

			ShortToChar(CI_VOBC_INFO_TYPE_FAO_INFO, &CiToVobcDataBuffer[33]);/*全自动运行洗车帧报文类型，两字节*/

			/*填充全自动运行洗车应用报文信息长度*/
			CiToVobcDataBuffer[31U] = (UINT8)((UINT8)((ii - 33U) >> 8U) & 0xffU);
			CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU);
		}
		else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{
			/*以下为应用层数据*/
			ii += 2U;/*报文长度*/

			ii += 2U;/*应用报文类型*/

			ii += 2U;/*预留两个字节*/
			/*组心跳帧*/
			ShortToChar(CI_VOBC_INFO_TYPE_HEART_FRAME, &CiToVobcDataBuffer[33U]);/*心跳帧报文类型，两字节*/

			/*填充应用层信息长度*/
			CiToVobcDataBuffer[31] = (UINT8)((UINT8)((ii - 33U) >> 8U) & 0xffU);
			CiToVobcDataBuffer[32] = (UINT8)((ii - 33U) & 0xffU);
		}
		else if ((VOBC_CI_INFO_TYPE_LOGOUT_ASK == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{
			/*以下为应用层数据*/
			ii += 2U;/*报文长度*/

			ii += 2U;/*应用报文类型*/

			ii += 2U;/*预留两个字节*/
			/*组注销请求回复帧*/
			ShortToChar(CI_VOBC_INFO_TYPE_LOGOUT_ACK, &CiToVobcDataBuffer[33]);/*注销请求回复帧报文类型，两字节*/

			/*填充应用层信息长度*/
			CiToVobcDataBuffer[31U] = (UINT8)((UINT8)((ii - 33U) >> 8U) & 0xffU);
			CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU);
		}
		else
		{
			/*信息类型不存在，什么都不做*/
		}

		if ((CI_SUCCESS == retVal) && (curCycleNum == vobcToCiDataStru->ComStartCycle) && (0u != vobcToCiDataStru->wTrainMaxSafeHeadLink) && (UINT16_MAX != vobcToCiDataStru->wTrainMaxSafeHeadLink))
		{
			/*当周期收到数据且510主用通道后备信息帧位置有效（当前VOBC发送了后备信息帧才回复）*/
			wTempSendIndex = ii;

			ii += 2U;	/*报文长度*/
			ShortToChar(CI_VOBC_BACKUP_STATE_INFO, &CiToVobcDataBuffer[ii]);
			ii += 2U;	/*报文类型*/
			ii += 2U;	/*预留2字节*/
			retVal = PackCiToVobcBackUpStateData(CiToVobcDataBuffer, &ii, vobcToCiDataStru);

			if (CI_SUCCESS == retVal)
			{
				/*填充应用层信息长度*/
				CiToVobcDataBuffer[wTempSendIndex] = (UINT8)((UINT8)((ii - wTempSendIndex - 2U) >> 8U) & 0xffU);
				CiToVobcDataBuffer[wTempSendIndex + 1U] = (UINT8)((ii - wTempSendIndex - 2U) & 0xffU);
			}
			else
			{
				; /*组包错误*/
			}
		}
		else
		{
			;
		}

		if (CI_SUCCESS == retVal)
		{
			/*通用报文头中应用层报文总长度*/
			CiToVobcDataBuffer[29U] = (UINT8)((UINT8)((ii - 31U) >> 8U) & 0xffU);
			CiToVobcDataBuffer[30U] = (UINT8)((ii - 31U) & 0xffU);
#if 0
			/*数据长度 */
			CiToVobcDataBuffer[0] = (UINT8)(((ii - 2) >> 8) & 0xff);
			CiToVobcDataBuffer[1] = (UINT8)((ii - 2) & 0xff);
#endif
			retVal = OutnetSafeSend(((UINT16)(CI_SYSTEM_TYPE_VOBC << 8u) | vobcToCiDataStru->VobcId), (vobcToCiDataStru->vobcLogId), &CiToVobcDataBuffer[0], ii);
			if (CI_SUCCESS == retVal)
			{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/                 
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
				debug_infor_printf((const)"\nVOBC_SEND:%d", ii);
				debug_out_array(0xAA, CiToVobcDataBuffer, ii);
#endif/*平台打印结束*/
#endif
			}
			else
			{
				/*写队列失败*/
				retVal = CI_ERROR;
				debug_infor_printf((const)"\nWrite VOBC %d dataQueue Error Len = %d\n", vobcToCiDataStru->VobcId, ii);
			}
		}
		else
		{
			;
		}
	}

	if (CI_ERROR == retVal)
	{
		SetErrorData(EFUNC_PACK_CI2VOBC_DATA, CI_DEVICE_TYPE_COMM_VOBC, vobcToCiDataStru->VobcId, ETYPE_COMM_WITH_VOBC, 0, ESEND_LEVEL_ZERO);
	}
	else
	{
		; /*组包成功*/
	}

	return retVal;
}

/*
* 功能描述： 组(FAO+HLHT)VOBC数据(去除自动洗车和站台控制信息)
* 参数说明： QueueStruct* CiToVobcDataQueue, 组包发送队列地址
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
UINT8 PackCiToVobcDataFAOHLHToneSelfSecond(VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = { 0U };/*CI到VOBC组帧数组*/
	UINT16 psdId = 0U;                                       /*屏蔽门ID*/
	UINT32 psdIdInterConn = 0U;                              /*互联互通4字节屏蔽门ID*/
	UINT8 startSigColour = 0U;								/*屏蔽门关联的出站进路始端信号机*/
	UINT8 psdState = 0U;                                     /*屏蔽门状态*/
	UINT16 ii = 0U;
	UINT8 kk = 0U;
	UINT16 sigId = 0U;				/*信号机ID*/
	UINT8 rowIndex = 0U;
	UINT8 colIndex = 0U;
	UINT32 curCycleNum = Get2oo2CurCycleNum();
	UINT32 appCycleTime = GetSystemParaAppCycleTime();
	UINT8 retVal = CI_SUCCESS;
	UINT8 localCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/
	UINT32 ciEtcsId = 0u;
	UINT32 vobcEtcsId = 0u;
	UINT32 emapCheckVer = 0u;
	UINT8 outStationSignalAllowOrNot = CI_VOBC_SIGNAL_DEFAULT;			/*信号机的允许或禁止状态*/
	UINT32 signalIdInterConn = 0u;	/*互联互通4字节信号机ID*/
	UINT8 psdValidFlag[2U] = { 0U,0U };							/*0无效，1有效*/
	UINT8 mutualLockState = 0u;                             /*互锁解除状态*/
	UINT8 localhlhtId = 0u;
	UINT8 vobcHlhtId = 0u;
	UINT8 ciEmapCheckVer = 0u;
	UINT8 flag = 0u;                                        /*清客按钮按下后PDB状态组默认值*/
	UINT8 chPsdBelongCiId = 0U;
	UINT16 wTempSendIndex = 0U;
	UINT8 chTempCheckFlag = CI_ERROR;

	/*首先获取组包时所需的信息，获取成功才有必要继续组包*/
	localhlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + localCiId, 0U, &ciEtcsId);
	vobcHlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC * 256U) + (UINT8)(vobcToCiDataStru->VobcId), vobcToCiDataStru->vobcLogId, &vobcEtcsId);
	ciEmapCheckVer = GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC);
	if ((CI_SUCCESS == localhlhtId) && (CI_SUCCESS == vobcHlhtId) && (CI_SUCCESS == ciEmapCheckVer))
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	debug_infor_printf((const)"\nPack vobc %d data,retVal = %d\n", vobcToCiDataStru->VobcId, retVal);	/*打印错误信息*/

	if (CI_SUCCESS == retVal)
	{
		ii = 0U;
#if 0
		/*通用协议帧头*/
		ii += 2U;
		CiToVobcDataBuffer[ii++] = CI_SYSTEM_TYPE_VOBC;		                    /*目的逻辑类型*/
		CiToVobcDataBuffer[ii++] = (UINT8)vobcToCiDataStru->VobcId;	        /*目的逻辑ID*/
		ShortToChar(vobcToCiDataStru->vobcLogId, &CiToVobcDataBuffer[ii]);	/*互联互通4IP VOBC1端或2端标识*/
		ii += 2U;
#endif
		/*开始组应用数据帧*/

		ShortToChar(CI_VOBC_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*接口信息类型*/
		ii += 2U;
		LongToChar(ciEtcsId, &CiToVobcDataBuffer[ii]);/*发送方标识信息*/
		ii += 4U;
		LongToChar(vobcEtcsId, &CiToVobcDataBuffer[ii]);/*接收方标识信息*/
		ii += 4U;
		LongToChar(emapCheckVer, &CiToVobcDataBuffer[ii]);/*电子地图版本校验信息*/
		ii += 4U;
		LongToChar(curCycleNum, &CiToVobcDataBuffer[ii]);/*本方消息序列号*/
		ii += 4U;
		ShortToChar((UINT16)appCycleTime, &CiToVobcDataBuffer[ii]);/*设备通讯周期*/
		ii += 2U;
		LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*对方消息序列号：recvOppMsgSN记录收到对方上一条消息中的对方消息序列号*/
		ii += 4U;
		LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*收到上一条消息时本方序列号*/
		ii += 4U;
		CiToVobcDataBuffer[ii++] = CI_VOBC_PRTCL_VER_FAOHLHT;/*HLHT+FAO_CI_VOBC接口协议版本号*/
		ii += 2U;/*通用报文头中的应用层报文总长度*/

		if ((VOBC_CI_INFO_TYPE_PSD_CONTROL == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{/*只有当VOBC发送的信息类型是屏蔽门控制信息时，才组包如下内容；若信息类型为心跳帧，则只发送报文帧头（31+6）*/

			ii += 2u;/*报文长度*/
			ii += 2u;/*应用报文类型*/
			ii += 2u;/*预留两个字节*/

			LongToChar(vobcToCiDataStru->trackSecID, &CiToVobcDataBuffer[ii]);/*回复收到的轨道区段ID*/
			ii += 4U;
			CiToVobcDataBuffer[ii++] = vobcToCiDataStru->psdCmdCode;   /*回复收到的状态开门码*/

			CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum;           /*屏蔽门数量*/

			for (kk = 0U; kk < 2U; kk++)
			{
				psdId = vobcToCiDataStru->PsdData[kk].PsdId;
				psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn;
				chPsdBelongCiId = GetPsdBelongCiId(psdId);

				if (localCiId != chPsdBelongCiId)
				{/*未查到此屏蔽门的相关信息：即此屏蔽门不属于本联锁*/


					LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]);                     /*屏蔽门ID*/
					ii += 4U;

					CiToVobcDataBuffer[ii++] = PSD_STATE_INVALID_HLHT;                             /*屏蔽门状态*/

					CiToVobcDataBuffer[ii++] = PSD_INVALID_CMD;              /*屏蔽门命令类型*/
				}
				else
				{/*此屏蔽门属于本联锁*/
					/*互锁解除状态*/
					mutualLockState = GetPsdMutualLockRemoveState(psdId);
					LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]);                                                   /*屏蔽门ID*/
					ii += 4U;

					if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState)
						|| (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState))
					{/*屏蔽门互锁解除*/

						psdState = PSD_STATE_CLOSE_VIETNAM;/*关闭且锁闭*/
					}
					else
					{/*屏蔽门未互锁解除*/

						if (GetPsdState(psdId) == PSD_STATE_CLOSE)
						{/*屏蔽门关门*/

							psdState = PSD_STATE_CLOSE_VIETNAM;/*关闭且锁闭*/
						}
						else
						{
							psdState = PSD_STATE_OPEN_VIETNAM;/*非关闭且锁闭*/
						}
					}

					CiToVobcDataBuffer[ii++] = psdState;                                                            /*屏蔽门状态*/
					CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdData[kk].CmdType;                            /*屏蔽门命令类型*/
				}

			}/*for (kk = 0; kk < vobcToCiDataStru->PsdSum; kk++)*/

			signalIdInterConn = vobcToCiDataStru->signalID;	/*互联互通4字节信号机ID*/

			LongToChar(signalIdInterConn, &CiToVobcDataBuffer[ii]);/*回复收到的信号机ID*/
			ii += 4U;
			/*根据互联互通4字节ID获取信号机ID*/
			chTempCheckFlag = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, signalIdInterConn, &sigId);

			if (CI_SUCCESS == chTempCheckFlag)
			{
				startSigColour = GetSignalCurColor(sigId);/*获取信号机当前显示颜色*/

				if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*获取始端信号机开放状态*/
				{/*信号开放*/
					outStationSignalAllowOrNot = CI_VOBC_SIGNAL_YES;
				}
				else
				{
					outStationSignalAllowOrNot = CI_VOBC_SIGNAL_NO;
				}
			}

			/*CI接收到的VOBC发送的信号机ID的状态*/
			CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNot;              /*CI->VOBC信号机状态*/

			ShortToChar(CI_VOBC_INFO_TYPE_PSD_STATE, &CiToVobcDataBuffer[33U]);/*屏蔽门控制报文类型，两字节（31+2）*/
			/*填充CI2VOBC状态信息长度*/
			CiToVobcDataBuffer[31U] = (UINT8)(((ii - 33U) >> 8U) & 0xffU);
			CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU);
		}
		else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{/*组心跳帧*/
			ii += 2u;/*报文长度*/
			ii += 2u;/*应用报文类型*/
			ii += 2u;/*预留两个字节*/

			ShortToChar(CI_VOBC_INFO_TYPE_HEART_FRAME, &CiToVobcDataBuffer[33U]);/*心跳帧报文类型，两字节*/

			/*填充应用层信息长度*/
			CiToVobcDataBuffer[31U] = (UINT8)((UINT8)((ii - 33U) >> 8U) & 0xffU);
			CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU);
		}
		else if ((VOBC_CI_INFO_TYPE_LOGOUT_ASK == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle))
		{/*组注销请求回复帧*/

			ii += 2u;/*报文长度*/
			ii += 2u;/*应用报文类型*/
			ii += 2u;/*预留两个字节*/
			ShortToChar(CI_VOBC_INFO_TYPE_LOGOUT_ACK, &CiToVobcDataBuffer[33U]);/*注销请求回复帧报文类型，两字节*/

			/*填充应用层信息长度*/
			CiToVobcDataBuffer[31U] = (UINT8)((UINT8)((ii - 33U) >> 8U) & 0xffU);
			CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU);
		}
		else
		{
			/*信息类型无效，什么都不做*/
		}

		if ((CI_SUCCESS == retVal) && (curCycleNum == vobcToCiDataStru->ComStartCycle) && (0u != vobcToCiDataStru->wTrainMaxSafeHeadLink) && (UINT16_MAX != vobcToCiDataStru->wTrainMaxSafeHeadLink))
		{
			/*当周期收到数据且510主用通道后备信息帧位置有效（当前VOBC发送了后备信息帧才回复）*/
			wTempSendIndex = ii;
			ii += 2U;	/*报文长度*/
			ShortToChar(CI_VOBC_BACKUP_STATE_INFO, &CiToVobcDataBuffer[ii]);
			ii += 2U;	/*报文类型*/
			ii += 2U;	/*预留2字节*/

			retVal = PackCiToVobcBackUpStateData(CiToVobcDataBuffer, &ii, vobcToCiDataStru);

			if (CI_SUCCESS == retVal)
			{
				/*填充应用层信息长度*/
				CiToVobcDataBuffer[wTempSendIndex] = (UINT8)((UINT8)((ii - wTempSendIndex - 2U) >> 8U) & 0xffU);
				CiToVobcDataBuffer[wTempSendIndex + 1U] = (UINT8)((ii - wTempSendIndex - 2U) & 0xffU);
			}
			else
			{
				; /*组包错误*/
			}
		}
		else
		{
			;
		}	

		if (CI_SUCCESS == retVal)
		{
			/*通用报文头中应用层报文总长度*/
			CiToVobcDataBuffer[29U] = (UINT8)((UINT8)((ii - 31U) >> 8U) & 0xffU);
			CiToVobcDataBuffer[30U] = (UINT8)((ii - 31U) & 0xffU);
#if 0
			/*数据长度 */
			CiToVobcDataBuffer[0] = (UINT8)(((ii - 2) >> 8) & 0xff);
			CiToVobcDataBuffer[1] = (UINT8)((ii - 2) & 0xff);
#endif
			retVal = OutnetSafeSend(((UINT16)(CI_SYSTEM_TYPE_VOBC << 8u) | vobcToCiDataStru->VobcId), (vobcToCiDataStru->vobcLogId), &CiToVobcDataBuffer[0], ii);
			if (CI_SUCCESS == retVal)
			{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/                 
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
				debug_infor_printf((const)"\nVOBC_SEND:%d", ii);
				debug_out_array(0xAA, CiToVobcDataBuffer, ii);
#endif/*平台打印结束*/
#endif
			}
			else
			{
				/*写队列失败*/
				retVal = CI_ERROR;
				debug_infor_printf((const)"\nWrite VOBC %d dataQueue Error Len = %d\n", vobcToCiDataStru->VobcId, ii);
			}
		}
		else
		{
			;
		}
	}

	if (CI_ERROR == retVal)
	{
		SetErrorData(EFUNC_PACK_CI2VOBC_DATA, CI_DEVICE_TYPE_COMM_VOBC, vobcToCiDataStru->VobcId, ETYPE_COMM_WITH_VOBC, 0, ESEND_LEVEL_ZERO);
	}

	return retVal;
}
/*
* 功能描述： 列车编组信息防护检查
* 参数说明：UINT8 trainEditGroupInfo, 列车编组信息
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
UINT8 ChecktrainEditGroupInfo(UINT8 trainEditGroupInfo, OUT UINT8 EditGroupinfo_out)
{
	UINT8 retval = CI_ERROR;
	if ((PSD_SIX_EDIT_GROUP_FAO_YF == trainEditGroupInfo) || (PSD_FOUR_EDIT_GROUP_FAO_YF == trainEditGroupInfo))
	{
		EditGroupinfo_out = trainEditGroupInfo;
		retval = CI_SUCCESS;
	}
	else
	{
		EditGroupinfo_out = 0u;
		retval = CI_ERROR;
	}
	return retval;
}

/*
* 功能描述： 列车洗车请求防护检查
* 参数说明：UINT8 trainEditGroupInfo,  列车洗车请求
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
UINT8 CheckwashTrainRequest(UINT8 washTrainRequest, OUT UINT8 washTrainRequest_out)
{
	UINT8 retval = CI_ERROR;
	if ((WASHMACHINE_DRVSTATE_REQ_FALSE == washTrainRequest) || (WASHMACHINE_DRVSTATE_REQ_TRUE == washTrainRequest))
	{
		washTrainRequest_out = washTrainRequest;
		retval = CI_SUCCESS;
	}
	else
	{
		washTrainRequest_out = 0u;
		retval = CI_ERROR;
	}
	return retval;
}

/*
* 功能描述： 头端洗位停稳信息防护检查
* 参数说明：UINT8 trainEditGroupInfo, 头端洗位停稳信息
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
UINT8 CheckheadWashStopSteady(UINT8 headwashStop, OUT UINT8 headwashStop_out)
{
	UINT8 retval = CI_ERROR;
	if ((WASHMACHINE_HEAD_STEADY_YES == headwashStop) || (WASHMACHINE_HEAD_STEADY_NO == headwashStop))
	{
		headwashStop_out = headwashStop;
		retval = CI_SUCCESS;
	}
	else
	{
		headwashStop_out = 0u;
		retval = CI_ERROR;
	}
	return retval;
}

/*
* 功能描述： 尾端洗位停稳信息
* 参数说明：UINT8 trainEditGroupInfo,尾端洗位停稳信息
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
UINT8 ChecktailWashStopSteady(UINT8 tailwashStop, OUT UINT8 tailwashStop_out)
{
	UINT8 retval = CI_ERROR;
	if ((WASHMACHINE_TAIL_STEADY_YES == tailwashStop) || (WASHMACHINE_TAIL_STEADY_NO == tailwashStop))
	{
		tailwashStop_out = tailwashStop;
		retval = CI_SUCCESS;
	}
	else
	{
		tailwashStop_out = 0u;
		retval = CI_ERROR;
	}
	return retval;
}

/*
* 功能描述： 通过洗车机请求防护检查
* 参数说明：UINT8 trainEditGroupInfo, 通过洗车机请求
* 返回值  ： 0:组数据失败
*			 1:组数据成功
*/
UINT8 CheckpassWashMachine(UINT8 passWashMachine, OUT UINT8 passWashMachine_out)
{
	UINT8 retval = CI_ERROR;
	if ((PASS_WASHMACHINE_DRVREQ_TRUE == passWashMachine) || (PASS_WASHMACHINE_DRVREQ_FALSE == passWashMachine))
	{
		passWashMachine_out = passWashMachine;
		retval = CI_SUCCESS;
	}
	else
	{
		passWashMachine_out = 0u;
		retval = CI_ERROR;
	}
	return retval;
}

/*
* 功能描述： 洗车请求信息接口校验
* 参数说明： 入参：UINT8 Data 洗车请求信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
*/
static UINT8 WashTrainRequestCheck(UINT8 Data)
{
	UINT8 washTrainRequest = 0U;
	UINT8 retVal = CI_ERROR;
	washTrainRequest = Data;

	if ((WASHMACHINE_DRVSTATE_REQ_TRUE == washTrainRequest) || (WASHMACHINE_DRVSTATE_REQ_FALSE == washTrainRequest))
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}
	
	return retVal;
}

/*
* 功能描述： 洗车停稳1信息接口校验
* 参数说明： 入参：UINT8 Data 洗车停稳1信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
*/
static UINT8 HeadWashStopSteadyInfoCheck(UINT8 Data)
{
	UINT8 headWashStopSteadyInfo = 0U;
	UINT8 retVal = CI_ERROR;
	headWashStopSteadyInfo = Data;

	if ((WASHMACHINE_HEAD_STEADY_YES == headWashStopSteadyInfo) || (WASHMACHINE_HEAD_STEADY_NO == headWashStopSteadyInfo))
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述： 暂停洗车请求信息接口校验
* 参数说明： 入参：UINT8 Data 暂停洗车请求信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
*/
static UINT8 WashPauseRequestCheck(UINT8 Data)
{
	UINT8 washPauseRequest = 0U;
	UINT8 retVal = CI_ERROR;
	washPauseRequest = Data;

	if ((WASHMACHINE_PAUSE_DRVREQ_TRUE == washPauseRequest) || (WASHMACHINE_PAUSE_DRVREQ_FALSE == washPauseRequest))
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述： 洗车停稳2信息接口校验
* 参数说明： 入参：UINT8 Data 洗车停稳2信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
*/
static UINT8 TailWashStopSteadyInfoCheck(UINT8 Data)
{
	UINT8 tailWashStopSteadyInfo = 0U;
	UINT8 retVal = CI_ERROR;
	tailWashStopSteadyInfo = Data;

	if ((WASHMACHINE_TAIL_STEADY_YES == tailWashStopSteadyInfo) || (WASHMACHINE_TAIL_STEADY_NO == tailWashStopSteadyInfo))
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述： 通过洗车机请求信息接口校验
* 参数说明： 入参：UINT8 Data 通过洗车机请求信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
*/
static UINT8 PassWashMachineRequestCheck(UINT8 Data)
{
	UINT8 passWashMachineRequest = 0U;
	UINT8 retVal = CI_ERROR;
	passWashMachineRequest = Data;

	if ((PASS_WASHMACHINE_REQUEST_VALID == passWashMachineRequest) || (PASS_WASHMACHINE_REQUEST_INVALID == passWashMachineRequest))
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述： 组包Ci到Ivoc 资源对顶信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
* by cgh 20230802
*/
static UINT8 PackCiToIvocReqAlignmentInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrnId)
{
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT8 mm = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT16 wLogicSecSum = 0U;/*逻辑区段数目*/
	UINT16 wLogicSecIndex = 0U;/*逻辑区段索引*/
	UINT16 wLogicSecId = 0U;/*逻辑区段ID*/
	UINT16 wLogicSecSendIndex = 0U;/*临时索引记录*/
	UINT8 wLogicSecSendSum = 0U;/*发送的资源对顶点数目*/
	UINT16 wRLockRouteId = 0U;/*逻辑区段进路锁闭所属进路*/
	UINT16 wPLockRouteId = 0U;/*逻辑区段防护锁闭所属进路*/
	UINT8 chRelateLogSecSum = 0U;/*逻辑区段关联逻辑区段数目*/
	UINT16* wRelateLogSecId = NULL;/*逻辑区段关联逻辑区段ID*/
	UINT8 chLogLockDir = 0U;/*逻辑区段锁闭方向*/
	UINT8 chLogRelateLogLockDir = 0U;/*逻辑区段关联逻辑区段锁闭方向*/
	UINT8 chLinkLogicDirUpAndDown = CI_SYSTEM_DIRECTION_NONE;/*逻辑区段与上下行的关系*/
	UINT8 chLogSecLogicLockDir = 0U;/*逻辑区段锁闭方向对应的逻辑方向*/
	UINT16 wSendLinkId = 0U;/*资源对顶点LINK编号*/
	UINT32 wSendLinkOffset = 0U;/*资源对顶点LINK偏移量*/
	UINT8 chLogSecHaveResOpp = 0U;/*逻辑区段是否具备资源对顶前提条件*/
	UINT16 wLogSecBelongPhyId = 0U;/*逻辑区段所属物理区段*/
	UINT16 wPhySecRLockRouteId = 0U;/*物理区段锁闭所属进路*/
	UINT8 chLockDirOpposedFlag = ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK;/*物理区段锁闭方向是否可以取反*/
	LOD_STRU pAPoint = { 0U }; /*A进路始端位置*/
	LOD_STRU pBPoint = { 0u }; /*B进路始端位置*/
	UINT8 chDirChangedNum = 0U;/*方向变化点数量*/
	UINT16 wRouteLogSecSum = 0U;/*进路包含逻辑区段数量*/
	UINT16* pRouteLogSecId = NULL;/*进路包含逻辑区段ID*/
	UINT8 chTempBreakFlag = 0U;/*临时跳出循环标志*/
	UINT8 chTempRemoveFlag = 0U;/*临时去重添加标志*/
	UINT8 chTempAddFlag = 0U;/*临时添加标志*/
	struct_PathPoint pSendPoint[20] = { 0U };
	UINT16 wSameLinkId = 0U;/*同位点LINK编号*/
	UINT32 wSameLinkOffset = 0U;/*同位点LINK偏移量*/
	UINT16 wOverlapLockedId = 0U;/*进路锁闭保护区段ID*/

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		wLogicSecSum = GetLogicSecCurSum();
		chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown();
		if (LOGIC_SECTION_SUM_MAX > wLogicSecSum)
		{
			wLogicSecSendIndex = ii;
			wLogicSecSendSum = 0U;
			ii += 1U;
			for (wLogicSecIndex = 0U; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++)
			{
				chTempBreakFlag = 0U;
				chTempRemoveFlag = 0U;
				chTempAddFlag = 0U;
				pRouteLogSecId = NULL;
				wLogicSecId = GetLogicSecId(wLogicSecIndex);

				if ((0U < wLogicSecId) && (UINT16_MAX > wLogicSecId))
				{
					chLogSecHaveResOpp = GetLogSecHaveResOpp(wLogicSecId);
					if (CI_SUCCESS == chLogSecHaveResOpp)
					{
						/*逻辑区段具备资源对顶前提条件才有以下逻辑*/
						wRLockRouteId = GetLogSecLockBelongRoute(wLogicSecId);
						wPLockRouteId = GetLogSecPLockRouteId(wLogicSecId);
						chLogLockDir = GetLogSecLockDir(wLogicSecId);
						pAPoint.Lnk = 0U;
						pAPoint.Off = 0U;
						
						if (0U < wRLockRouteId)
						{
							wRouteLogSecSum = GetRouteLogSectionSum(wRLockRouteId);
							pRouteLogSecId = GetRouteLogSectionIdBuf(wRLockRouteId);
						}
						else if (0U < wPLockRouteId)
						{
							wOverlapLockedId = GetRouteOverlapLockedId(wPLockRouteId);
							wRouteLogSecSum = GetOverlapLogicSectionSum(wOverlapLockedId);
							pRouteLogSecId = GetOverlapLogicSectionBuf(wOverlapLockedId);
						}
						else
						{
							; /*继续下一个*/
						}

						if (NULL != pRouteLogSecId)
						{
							pAPoint.Lnk = GetLgcSecOrgnLink(pRouteLogSecId[0]);
							pAPoint.Off = 0U;
						}
						else
						{
							;
						}
						
						if ((CI_SYSTEM_DIRECTION_UP == chLogLockDir) || (CI_SYSTEM_DIRECTION_DOWN == chLogLockDir))
						{
							/*将锁闭方向转换为和逻辑方向之间的关系*/
							if (chLinkLogicDirUpAndDown == chLogLockDir)
							{
								chLogSecLogicLockDir = EMAP_CONVER_DIR;
							}
							else
							{
								chLogSecLogicLockDir = EMAP_SAME_DIR;
							}

							wLogSecBelongPhyId = GetLgcSecRelativePhySecId(wLogicSecId);
							wPhySecRLockRouteId = GetPhySecRLockBelongRouteId(wLogSecBelongPhyId);
							chLockDirOpposedFlag = GetRoutePhySecShouldLockOppose(wPhySecRLockRouteId, wLogSecBelongPhyId);

							if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == chLockDirOpposedFlag)
							{
								/*进路最后一个物理区段锁闭方向需要取反则转换逻辑方向*/
								chLogSecLogicLockDir = ~chLogSecLogicLockDir;
							}

							if (EMAP_SAME_DIR == chLogSecLogicLockDir)
							{
								/*当前逻辑区段锁闭方向与逻辑方向一致，根据终点相邻逻辑区段锁闭方向判断是否为资源对顶点*/
								chRelateLogSecSum = GetLogEndLogSecSum(wLogicSecId);
								wRelateLogSecId = GetLogEndLogSecData(wLogicSecId);
								wSendLinkId = GetLgcSecTmnlLink(wLogicSecId);
								wSendLinkOffset = GetLgcSecTmnlOffset(wLogicSecId);
							}
							else if (EMAP_CONVER_DIR == chLogSecLogicLockDir)
							{
								/*当前逻辑区段锁闭方向与逻辑方向相反，若起点逻辑区段锁闭方向与之相反，则为资源对顶点*/
								chRelateLogSecSum = GetLogBeginLogSecSum(wLogicSecId);
								wRelateLogSecId = GetLogBeginLogSecData(wLogicSecId);
								wSendLinkId = GetLgcSecOrgnLink(wLogicSecId);
								wSendLinkOffset = 0U;
							}
							else
							{
								/*错误，停止组包*/
								chRetVal = CI_ERROR;
								debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo LogSecLogicLockDir_Error, Dir : %d  \n", chLogSecLogicLockDir);
							}

							(void)dsuCheckSameLoc(wSendLinkId, wSendLinkOffset, &wSameLinkId, &wSameLinkOffset);
							for (mm = 0U; mm < wLogicSecSendSum; mm++)
							{
								/*去重，当前已发送数组中是否已存在对应位置点及同位点*/
								if (((pSendPoint[mm].wLinkId == wSendLinkId) && (pSendPoint[mm].dwOffset == wSendLinkOffset))
									|| ((pSendPoint[mm].wLinkId == wSameLinkId) && (pSendPoint[mm].dwOffset == wSameLinkOffset)))
								{
									chTempRemoveFlag = 1U;
									break;
								}
							}
							for (jj = 0U; jj < chRelateLogSecSum; jj++)
							{
								chLogRelateLogLockDir = GetLogSecLockDir(wRelateLogSecId[jj]);
								wRLockRouteId = GetLogSecLockBelongRoute(wRelateLogSecId[jj]);
								wPLockRouteId = GetLogSecPLockRouteId(wRelateLogSecId[jj]);
								pBPoint.Lnk = 0U;
								pBPoint.Off = 0U;

								if (0U < wRLockRouteId)
								{
									wRouteLogSecSum = GetRouteLogSectionSum(wRLockRouteId);
									pRouteLogSecId = GetRouteLogSectionIdBuf(wRLockRouteId);
									if (NULL != pRouteLogSecId)
									{
										/*可能涉及到相邻联锁，如果数据没做，指针可能为空，此时需要防一下*/
										pBPoint.Lnk = GetLgcSecOrgnLink(pRouteLogSecId[0]);
										pBPoint.Off = 0U;
									}

								}
								else if (0U < wPLockRouteId)
								{
									pBPoint.Lnk = GetLgcSecOrgnLink(wRelateLogSecId[jj]);
									pBPoint.Off = 0U;
								}
								else
								{
									; /*继续查找*/
								}

								if ((NULL != pRouteLogSecId) && (0U < pAPoint.Lnk) && (0U < pBPoint.Lnk))
								{
									/*可能涉及到相邻联锁，如果数据没做，指针可能为空，此时需要防一下*/
									/*两个比较的区段均有锁闭才去检查方向变化点数目和锁闭方向*/

									if ((CI_SYSTEM_DIRECTION_UP == chLogRelateLogLockDir) || (CI_SYSTEM_DIRECTION_DOWN == chLogRelateLogLockDir))
									{
										/*当前逻辑区段锁闭方向和关联逻辑区段锁闭方向必须有效*/
										chDirChangedNum = GetDirChangeNumBtwPoints(&pAPoint, &pBPoint);
										
										if (0U == (chDirChangedNum % 2U))
										{
											/*2条进路之间方向变化点数目为偶数，则锁闭方向不一致则资源对顶*/
											if (chLogLockDir != chLogRelateLogLockDir)
											{
												if (0U == chTempRemoveFlag)
												{
													/*不存在组包发送*/
													chTempAddFlag = 1U;
													chTempBreakFlag = 1U;
												}
											}
										}
										else
										{
											/*2条进路之间方向变化点数目为奇数，则锁闭方向一致则资源对顶*/
											if (chLogLockDir == chLogRelateLogLockDir)
											{
												if (0U == chTempRemoveFlag)
												{
													/*不存在组包发送*/
													chTempAddFlag = 1U;
													chTempBreakFlag = 1U;
												}
											}
										}
										if (1U == chTempBreakFlag)
										{
											break;
										}
									}
									else
									{
										; /*继续查找下一个*/
									}
								}
							}
							if (1U == chTempAddFlag)
							{
								pSendPoint[wLogicSecSendSum].wLinkId = wSendLinkId;
								pSendPoint[wLogicSecSendSum].dwOffset = wSendLinkOffset;
								wLogicSecSendSum += 1U;
								ShortToChar(wSendLinkId, &pDataBuf[ii]);
								ii += 2U;
								LongToChar(wSendLinkOffset, &pDataBuf[ii]);
								ii += 4U;
							}
						}
						else
						{
							/*错误，停止组包*/
							chRetVal = CI_ERROR;
							debug_infor_printf((const)"\n PackCiToIvocReqAlignmentInfo LogLockDir_Error, LockDir : %d  \n", chLogLockDir);
						}
					}
					else
					{
						; /*继续查找*/
					}
				}
				else
				{
					/*错误，停止组包*/
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocReqAlignmentInfo LogicSecId_Error, ID : %d  \n", wLogicSecId);
				}
				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
			pDataBuf[wLogicSecSendIndex] = wLogicSecSendSum;
		}
		else
		{
			/*逻辑区段数量错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocReqAlignmentInfo LogicSecSum_Error, sum : %d  _MAX: %d  \n", wLogicSecSum, LOGIC_SECTION_SUM_MAX);
		}
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc申请解锁保护区段信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocUnlockOverlapInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrnId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT16 wSendNumIndex = 0U;
	UINT16 wOverlapId = 0U;  /*保护区段的ID*/
	UINT16 wOverlapSum = 0U;  /*控区内保护区段总数*/
	UINT8 cReqUnlockOverlapNum = 0U;  /*向车申请解锁保护区段的数量*/
	UINT16 wReqUnlockTrainId = 0U;  /*保护区段解锁申请的列车ID*/
	UINT32 dwReqUnlockStartCycNum = 0U;  /*向车申请解锁保护区段的起始周期号*/
	UINT8 cOverlapBelongCi = 0U;  /*保护区段所属CI*/
	UINT8 cLocalCiId = 0U;

	if ((NULL != pDataBuf) && (NULL != wDataLength) && (0U < wTrnId) && (UINT16_MAX > wTrnId))
	{
		chRetVal = CI_SUCCESS;

		cLocalCiId = GetSystemParaLocalCiId();
		wOverlapSum = GetOverlapCurSum();
		ii = *wDataLength;
		wSendNumIndex = ii;		
		ii++;

		for (jj = 0U; jj < wOverlapSum; jj++)
		{
			wOverlapId = GetOverlapId(jj);
			cOverlapBelongCi = GetOverlapBelongCiId(wOverlapId);

			if ((0u != wOverlapId) && (OVERLAP_SUM_MAX > wOverlapId))
			{
				if ((0u != cLocalCiId) && (cLocalCiId == cOverlapBelongCi))
				{
					wReqUnlockTrainId = GetOverlapUnlockApplyTrainId(wOverlapId);
					dwReqUnlockStartCycNum = GetReqIvocUnlockStartCycNum(wOverlapId);
					if (wTrnId == wReqUnlockTrainId)
					{
						cReqUnlockOverlapNum++;
						ShortToChar(wOverlapId, &pDataBuf[ii]);  /*组申请解锁保护区段的ID*/
						ii += 2U;

						LongToChar(dwReqUnlockStartCycNum, &pDataBuf[ii]);  /*组申请解锁保护区段的起始周期号*/
						ii += 4U;
					}
					else
					{
						/*非解锁申请的列车，不处理*/
					}
				}
				else
				{
					/*非本控区保护区段，不处理*/
				}
			}
			else
			{
				chRetVal = CI_ERROR;
				debug_infor_printf((const)"\n PackCiToIvocUnlockOverlapInfo OverlapId_Error, OverlapId : %d  \n", wOverlapId);
				break;				
			}
		}

		pDataBuf[wSendNumIndex] = cReqUnlockOverlapNum;  /*组申请解锁保护区段的总数*/

		if ((CI_SUCCESS == chRetVal) && (CI_IVOC_UNLOCK_OVERLAP_SUM > cReqUnlockOverlapNum))
		{
			*wDataLength = ii;  /*组包成功且申请解锁保护区段的数量未超限，返回成功*/
		}
		else
		{
			if (CI_SUCCESS == chRetVal)
			{
				debug_infor_printf((const)"\n PackCiToIvocUnlockOverlapInfo ReqUnlockOverlapSum_Error, sum : %d  _MAX: %d \n", cReqUnlockOverlapNum, CI_IVOC_UNLOCK_OVERLAP_SUM);
			}
			chRetVal = CI_ERROR;
		}
	}
	else
	{
		chRetVal = CI_ERROR;
	}
	
	return chRetVal;
}

/*
* 功能描述： 洗车机工作模式设置信息接口校验
* 参数说明： 入参：UINT8 Data 洗车机工作模式设置信息
* 返回值  ： CI_ERROR: 接口校验失败
*			 CI_SUCESS: 接口校验成功
* by cgh 20231107
*/
static UINT8 WashMachineWorkModeCheck(UINT8 Data)
{
	UINT8 chWashMachineWorkMode = 0U;
	UINT8 retVal = CI_ERROR;

	chWashMachineWorkMode = Data;

	if ((WASHMACHINE_WORKMODE_ALL_DRV == chWashMachineWorkMode)
		|| (WASHMACHINE_WORKMODE_SIDE_DRV == chWashMachineWorkMode)
		|| (WASHMACHINE_WORKMODE_DEFAULT_DRV == chWashMachineWorkMode))
	{
		retVal = CI_SUCCESS;
	}
	else
	{
		retVal = CI_ERROR;
	}

	return retVal;
}

/*
* 功能描述： 组包Ci到Ivoc洗车机信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
*			 const UINT16 wTrnId VOBC ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
* by cgh 20231110
*/
static UINT8 PackCiToIvocWashMachineInfo(UINT8* pDataBuf, UINT16* wDataLength,const UINT16 wTrnId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 washMachineCurSum = 0U;/*当前集中区洗车机数量*/
	UINT16 washMachineId = 0U;/*洗车机ID*/

	if ((NULL != pDataBuf) && (NULL != wDataLength) && (0U < wTrnId) && (UINT16_MAX > wTrnId))
	{
		chRetVal = CI_SUCCESS;
		ii = *wDataLength;	
		/*获取当前联锁包含洗车机数量*/
		washMachineCurSum = GetWashMachineSum();

		if (1U == washMachineCurSum)
		{
			/*本联锁集中区有一台全自动洗车机*/
			washMachineId = GetWashMachineId(0U);
		}
		else
		{
			if (0U == washMachineCurSum)
			{
				; /*本集中区没有洗车机*/
			}
			else
			{
				chRetVal = CI_ERROR; /*集中区洗车机超限*/
				debug_infor_printf((const)"\n PackCiToIvocWashMachineInfo washMachineCurSum_Error, sum : %d \n", washMachineCurSum);
			}
		}

		if(0U != washMachineId)
		{
			pDataBuf[ii++] = GetWashMachineRequestVerifySta(washMachineId);   /*1洗车请求确认：0x55允许洗车，0xaa不允许洗车*/
			pDataBuf[ii++] = GetHeadWashAllowState(washMachineId);              /*2允许通过1：0x55允许通过，0xaa禁止通过*/
			pDataBuf[ii++] = GetTailWashAllowState(washMachineId);              /*3允许通过2：0x55允许通过，0xaa禁止通过*/
			pDataBuf[ii++] = GetTrainOutWashPortAllowSta(washMachineId); /*4允许通过洗车区：0x55允许通过，0xaa禁止通过*/
			pDataBuf[ii++] = GetTrainEmergencyStopState(washMachineId);         /*5洗车机故障：0x55无故障，0xaa故障*/
			pDataBuf[ii++] = GetWashModeState(washMachineId);                   /*洗车模式：0x01:通过洗(侧洗)，0x02:端洗（全洗）*/
			pDataBuf[ii++] = GetWashWorkModeBackState(washMachineId);           /*洗车模式设置反馈：5个取值*/
		}
		else
		{
			/*本联锁集中区没有洗车机或不是当前列车在洗车,发送默认值*/
			pDataBuf[ii++] = WASHMACHINE_COL_REQUEST_INVALID;
			pDataBuf[ii++] = WASHMACHINE_COL_HEADWASH_NO;
			pDataBuf[ii++] = WASHMACHINE_COL_TAILWASH_NO;
			pDataBuf[ii++] = WASHMACHINE_COL_OUT_NO_2;
			pDataBuf[ii++] = WASHMACHINE_COL_FALUT_NO_2;
			pDataBuf[ii++] = XTA_MODE_STATE_NO;
			pDataBuf[ii++] = WASH_WORKMODE_BACK_DEFAULT;
		}

		

		if (CI_SUCCESS == chRetVal)
		{
			*wDataLength = ii;  
		}
		else
		{
			chRetVal = CI_ERROR;
		}
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc区间雨雪与紧急制动信息
* 参数说明： UINT8* pDataBuf 数据缓冲区
*            UINT16 *pDataLength 数据长度(输出参数)
*            UINT16 wTrainId 列车ID（不带0x14）
* 返回值  ： CI_ERROR 0 失败
*			 CI_SUCCESS 1 成功
* Created By LQ 2023.11.10
*/
static UINT8 PackCiToIvocSnowAndUrgentInfo(UINT8* pDataBuf, UINT16* pDataLength, UINT16 wTrainId)
{
	UINT8 retVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT16 kk = 0U;
	UINT8 cAreaSnowTotalNum = 0U;  /*区间雨雪站台数量*/
	UINT16 wAreaSnowNumIndex = 0U;
	AreaSnowInfoStruct* pAreaSnowData = NULL;  /*区间雨雪信息数组*/
	ToCiAreaSnowStruct* pRecvCiAreaSnow = NULL;  /*相邻联锁发送的区间雨雪信息*/
	UINT8 cWlbState = 0U;  /*全线紧急制动状态*/
	UINT8 cUrgentReason = 0U;  /*紧急原因*/
	UINT8 cAreaUrgentState = 0U;  /*区域紧急制动状态*/
	EnvelopeStruct* strTrainEnvelope = NULL;  /*列车包络信息*/
	UINT16 wAxisRelPhySecId = 0U;  /*计轴区段关联的物理区段ID*/
	UINT8 cUrgentState = 0U;  /*发送给IVOC的紧急状态*/
	UINT16 wSnowPlatId = 0U;
	UINT8 cSnowLevel = 0U;  /*湿轨级别*/

	if ((NULL != pDataBuf) && (NULL != pDataLength) && (0U != wTrainId) && (LINE_MAX_TRAIN > wTrainId))
	{
		retVal = CI_SUCCESS;
		ii = *pDataLength;

		/*组本地区间雨雪状态信息*/
		wAreaSnowNumIndex = ii;  /*跳过区间雨雪站台数量*/
		ii++;
		cAreaSnowTotalNum = GetLocalAreaSnowNum();
		pAreaSnowData = GetLocalAreaSnow();

		if (LOCAL_AREA_SNOW_SUM_MAX >= cAreaSnowTotalNum)
		{
			for (jj = 0U; jj < cAreaSnowTotalNum; jj++)
			{
				wSnowPlatId = pAreaSnowData[jj].wAreaId;
				cSnowLevel = pAreaSnowData[jj].cAreaSnowLevel;
				if ((0U < wSnowPlatId) && (UINT16_MAX > wSnowPlatId)
					&& ((CI_SNOW_LEVEL_DEFAULT == cSnowLevel) || (CI_SNOW_LEVEL_ONE == cSnowLevel) || (CI_SNOW_LEVEL_TWO == cSnowLevel)))
				{
					ShortToChar(wSnowPlatId, &pDataBuf[ii]);  /*组区间ID*/
					ii += 2U;
					pDataBuf[ii] = cSnowLevel;  /*组区间湿轨级别*/
					ii++;
				}
				else
				{
					retVal = CI_ERROR;  /*区间雨雪站台Id非法，返回失败*/
				}
			}
		}
		else
		{
			retVal = CI_ERROR;  /*区间雨雪数量超限，返回失败*/
			debug_infor_printf((const)"\n PackCiToIvocSnowAndUrgentInfo AreaSnowSum_Error, sum : %d  _MAX: %d \n", cAreaSnowTotalNum, LOCAL_AREA_SNOW_SUM_MAX);
		}

		/*组相邻联锁发送的区间雨雪状态信息*/
		pRecvCiAreaSnow = GetCiRecvAreaSnowInfo();
		for (kk = 0U; kk < CI_COM_CI_MAX_NUM; kk++)
		{
			if (0U != pRecvCiAreaSnow[kk].cPlatFormNum)
			{
				for (jj = 0U; jj < pRecvCiAreaSnow[kk].cPlatFormNum; jj++)
				{
					if (LOCAL_AREA_SNOW_SUM_MAX > cAreaSnowTotalNum)
					{
						wSnowPlatId = pRecvCiAreaSnow[kk].szPlatFormInfo[jj].wAreaId;
						cSnowLevel = pRecvCiAreaSnow[kk].szPlatFormInfo[jj].cAreaSnowLevel;
						if ((0U < wSnowPlatId) && (UINT16_MAX > wSnowPlatId)
							&& ((CI_SNOW_LEVEL_DEFAULT == cSnowLevel) || (CI_SNOW_LEVEL_ONE == cSnowLevel) || (CI_SNOW_LEVEL_TWO == cSnowLevel)))
						{
							ShortToChar(wSnowPlatId, &pDataBuf[ii]);  /*组区间ID*/
							ii += 2U;
							pDataBuf[ii] = cSnowLevel;  /*组区间湿轨级别*/
							ii++;
							cAreaSnowTotalNum++;
						}
						else
						{
							retVal = CI_ERROR;  /*区间雨雪站台Id非法，返回失败*/
						}
					}
					else
					{
						retVal = CI_ERROR;  /*区间雨雪数量超限，返回失败*/
					}
				}
			}
			else
			{
				/*继续遍历*/
			}
		}
		pDataBuf[wAreaSnowNumIndex] = cAreaSnowTotalNum;  /*组区间雨雪站台数量*/

		/*组紧急制动状态信息*/
		cWlbState = WlbGetState();  /*获取全线紧急状态*/
		if (WLB_UNSET != cWlbState)
		{
			cUrgentReason |= 0x01U;  /*紧急原因增加全线紧急制动*/
		}
		else
		{
			/*不处理*/
		}

		strTrainEnvelope = elm_GetEnvelopeInfoByTrainID(wTrainId);
		if (NULL != strTrainEnvelope)
		{
			for (jj = 0U; jj < strTrainEnvelope->ACCnt; jj++)
			{
				wAxisRelPhySecId = GetAxisSecRelativePhySecId(strTrainEnvelope->ACID[jj]);
				cAreaUrgentState = GetPhySecAreaUrgentState(wAxisRelPhySecId);

				if (PHYSEC_AREA_URGENT_NO != cAreaUrgentState)
				{
					cUrgentReason |= 0x02U;  /*紧急原因增加区域紧急制动*/
					break;
				}
				else
				{
					/*不处理*/
				}
			}
		}
		else
		{
			/*包络为空，列车还未进入本控区，不处理*/
		}

		if (0U == cUrgentReason)
		{
			cUrgentState = CI_IVOC_URGENT_NO;  /*紧急原因为0，发紧急无效*/
		}
		else
		{
			cUrgentState = CI_IVOC_URGENT_YES;  /*紧急原因非0，发紧急有效*/
		}

		if (CI_SUCCESS == retVal)
		{
			pDataBuf[ii] = cUrgentState;  /*组紧急制动状态*/
			ii++;
			pDataBuf[ii] = cUrgentReason;  /*组紧急制动原因*/
			ii++;
			*pDataLength = ii;
		}
		else
		{
			/*不处理，返回失败*/
		}
	}
	else
	{
		/*入参非法，返回失败*/
	}

	return retVal;
}

/*
* 功能描述： 校验防护区域和列车包络是否有重合
* 参数说明： UINT16 wFloodGateId, 防淹门ID
*			 UINT16 wTrainId,	列车ID
* 返回值  ： CI_ERROR 失败,包络和防护区域无重叠，发实际状态
*			 CI_SUCCESS 成功，包络和防护区域有重叠，发无关门请求
*/
UINT8 CheckProtectEnvelope(UINT16 wFloodGateId, UINT16 wTrainId)
{
	UINT8 retVal = CI_ERROR;
	UINT16 axisSum = 0u;
	UINT16 *pAxisIdBuf = NULL;
	UINT16 ii = 0u;
	UINT16 axisId = 0u;	/*计轴区段ID*/
	UINT8 cAxisLinkSum = 0U;
	UINT16 *pAxisLinkIdBuf = NULL;
	UINT8 linkIndex = 0U;
	UINT16 wAxisLinkId = 0U;
	UINT8 chTrainSum = 0U;
	TRAIN_SEQUANCE_s TrainList[SIZE_MAX_LINETRAIN] = { 0u };
	UINT8 chTrainIndex = 0U;

	axisSum = GetFloodGateProtectAxisNum(wFloodGateId);
	pAxisIdBuf = GetFloodGateProtectAxisIDBuf(wFloodGateId);

	if (NULL == pAxisIdBuf)
	{
		retVal = CI_ERROR;
	}
	else
	{
		retVal = CI_SUCCESS;
	}
	if (CI_SUCCESS == retVal)
	{
		for (ii = 0u; ii < axisSum; ii++)
		{
			axisId = pAxisIdBuf[ii];
			if (0U < axisId)
			{
				cAxisLinkSum = GetAxisLinkSum(axisId);
				pAxisLinkIdBuf = GetAxisLinkIdBuf(axisId);
				if (NULL == pAxisLinkIdBuf)
				{
					retVal = CI_ERROR;
				}
				else
				{
					for (linkIndex = 0U; linkIndex < cAxisLinkSum; linkIndex++)
					{
						wAxisLinkId = pAxisLinkIdBuf[linkIndex];
						chTrainSum = as_GetLinkTrainList(wAxisLinkId, TrainList, SIZE_MAX_LINETRAIN);
						if (0u != chTrainSum)
						{
							for (chTrainIndex = 0u; chTrainIndex < chTrainSum; chTrainIndex++)
							{
								if (wTrainId == TrainList[chTrainIndex].u16TrainID)
								{
									/*防护区域有本车包络，包络和防护区域重叠*/
									retVal = CI_SUCCESS;
									break;
								}
								else
								{
									/*防护区域有包络，不是本车包络，返回无包络重叠*/
									retVal = CI_ERROR;
								}
							}
						}
						else
						{
							/*无列车包络信息，与防护区域无重叠，返回无包络重叠*/
							retVal = CI_ERROR;
						}

						if (CI_SUCCESS == retVal)
						{
							/*防护区域有本车包络，包络和防护区域重叠*/
							break;
						}
					}
				}
				if (CI_SUCCESS == retVal)
				{
					/*防护区域有本车包络，包络和防护区域重叠*/
					break;
				}
			}
		}
	}

	return retVal;
}

/*
* 功能描述： 组包Ci到Ivoc备用通道逻辑区段信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpLogSecInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 wVobcBackUpSendLogAllNum = 0U;
	UINT8 wVobcBackUpSendLogUseNum = 0U;
	UINT8 jj = 0U;
	UINT16 chIndex = 0U;			/*需要发送可用逻辑区段的数量索引*/
	ABLTrainRelLogStru* ablVobcBackUpSendLogStr = NULL;
	UINT16 wVobcBackUpSendLogId = 0U;
	UINT8 LogSecAblUseFlag = 0U;
	UINT8 chVobcBackUpSendLogDir = 0U;
	UINT16 wLogSecBelongPhyId = 0U;
	UINT8 chLockDirOpposedFlag = 0U;
	UINT16 wRLockRouteId = 0U;

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		wVobcBackUpSendLogAllNum = GetTrainAblRelLogSecNum(wTrainId);
		ablVobcBackUpSendLogStr = GetTrainAblRelLogData(wTrainId);
		chIndex = ii;
		ii++;

		for (jj = 0U; jj < wVobcBackUpSendLogAllNum; jj++)
		{
			wVobcBackUpSendLogId = ablVobcBackUpSendLogStr[jj].wAblRelLogSecId;
			chVobcBackUpSendLogDir = ablVobcBackUpSendLogStr[jj].chAblRelLogSecDir;
			LogSecAblUseFlag = GetLogSecAblUseFlag(wVobcBackUpSendLogId);

			if (LOGIC_ABLNEAR_USE_FLAG_YES == LogSecAblUseFlag)
			{
				/*资源可用性检查通过且列车级别不为ABL且逻辑区段锁闭所属进路不为反向*/
				wVobcBackUpSendLogUseNum += 1U;
				ShortToChar(wVobcBackUpSendLogId, &pDataBuf[ii]);		/*逻辑区段ID*/
				ii += 2u;

				if ((CI_SYSTEM_DIRECTION_UP == chVobcBackUpSendLogDir)
					|| (CI_SYSTEM_DIRECTION_DOWN == chVobcBackUpSendLogDir))
				{
					/*逻辑区段查进路*/
					wRLockRouteId = GetLogSecLockBelongRoute(wVobcBackUpSendLogId);
					/*物理区段查进路*/
					wLogSecBelongPhyId = GetLgcSecRelativePhySecId(wVobcBackUpSendLogId);
					chLockDirOpposedFlag = GetRoutePhySecShouldLockOppose(wRLockRouteId, wLogSecBelongPhyId);

					if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == chLockDirOpposedFlag)
					{
						chVobcBackUpSendLogDir = ~chVobcBackUpSendLogDir;
					}
					else
					{
						; /*物理区段锁闭方向不需要取反，则说明逻辑区段也不需要取反*/
					}
					pDataBuf[ii] = chVobcBackUpSendLogDir;
					ii += 1U;
				}
				else
				{
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocBackUpLogSecInfo VobcBackUpSendLogDir_Error, DIR : %d  \n", chVobcBackUpSendLogDir);
				}
			}
			else
			{
				;	/*逻辑区段不可用，不向列车发送*/
			}

		}

		pDataBuf[chIndex] = wVobcBackUpSendLogUseNum;
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc备用通道进路信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpRouteInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 chTrainAblAllRouteNum = 0U;
	UINT8 VobcBackUpSendRouteNum = 0U;
	UINT8 jj = 0U;
	UINT16 chIndex = 0U;			/*需要发送进路的数量索引*/
	ABLTrainRelAllRouteStru* ablVobcBackUpSendRouteStr = NULL;
	UINT16 VobcBackUpSendAblRelRouteId = 0U;
	UINT8 VobcBackUpSendAblRelRouteFlag = 0U;

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		chTrainAblAllRouteNum = GetTrainAblAllRouteNum(wTrainId);
		ablVobcBackUpSendRouteStr = GetTrainAblRelAllRouteData(wTrainId);
		chIndex = ii;
		ii++;

		for (jj = 0U; jj < chTrainAblAllRouteNum; jj++)
		{
			VobcBackUpSendAblRelRouteId = ablVobcBackUpSendRouteStr[jj].wAblRelRouteId;
			VobcBackUpSendAblRelRouteFlag = ablVobcBackUpSendRouteStr[jj].chAblRelTrainInFlag;

			if (TRAIN_ABL_ROUTE_FLAG_NO == VobcBackUpSendAblRelRouteFlag)
			{
				if (CI_VOBC_BACKUP_SEND_ROUTE_SUM > VobcBackUpSendRouteNum)
				{
					VobcBackUpSendRouteNum += 1U;
					ShortToChar(VobcBackUpSendAblRelRouteId, &pDataBuf[ii]);		/*进路ID*/
					ii += 2u;
				}
				else
				{
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocBackUpRouteInfo VobcBackUpSendRouteNum Error: %d \n", VobcBackUpSendRouteNum);
					break;
				}
			}
			else
			{
				;	/*非列车脚下的进路不发送*/
			}

		}
	}

	if (CI_SUCCESS == chRetVal)
	{
		pDataBuf[chIndex] = VobcBackUpSendRouteNum;
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc备用通道折返逻辑区段信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpReturnLogInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 TrainAblRelReturnLogNum = 0U;
	UINT8 jj = 0U;
	UINT16* TrainAblRelReturnLogIdBuf = NULL;

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		TrainAblRelReturnLogNum = GetTrainAblRelReturnLogNum(wTrainId);
		pDataBuf[ii++] = TrainAblRelReturnLogNum;
		TrainAblRelReturnLogIdBuf = GetTrainAblRelReturnLogId(wTrainId);

		for (jj = 0U; jj < TrainAblRelReturnLogNum; jj++)
		{
			ShortToChar(TrainAblRelReturnLogIdBuf[jj], &pDataBuf[ii]);		/*折返逻辑区段ID*/
			ii += 2u;
		}
		
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc备用通道屏蔽门状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpPsdInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 TrainAblRelPsdNum = 0U; 
	UINT8 jj = 0U;
	ABLTrainRelPsdStru* pAblRelPsdData = NULL;

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		TrainAblRelPsdNum = GetTrainAblRelPsdNum(wTrainId);
		pDataBuf[ii++] = TrainAblRelPsdNum;
		pAblRelPsdData = GetTrainAblRelPsdData(wTrainId);
		if (((0U != TrainAblRelPsdNum) && (NULL == pAblRelPsdData))
			||(TRAIN_ABL_PSD_SUM < TrainAblRelPsdNum))
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocBackUpPsdInfo TrainAblRelPsdNum : %d \n", TrainAblRelPsdNum);
		}
		else
		{
			for (jj = 0U; jj < TrainAblRelPsdNum; jj++)
			{
				ShortToChar(pAblRelPsdData[jj].wAblRelPsdId, &pDataBuf[ii]);		/*PSD ID*/
				ii += 2U;
				if ((CI_IVOC_PSD_STATE_CLOSE == pAblRelPsdData[jj].chAblRelPsdSta) || (CI_IVOC_PSD_STATE_OPEN == pAblRelPsdData[jj].chAblRelPsdSta))
				{
					pDataBuf[ii++] = pAblRelPsdData[jj].chAblRelPsdSta;
				}
				else
				{
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocBackUpPsdInfo chAblRelPsdSta : %d \n", pAblRelPsdData[jj].chAblRelPsdSta);
				}
			}
		}
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到IvocSpks备用通道状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpSpksInfo(UINT8* pDataBuf, UINT16* wDataLength)
{
	UINT8 chSpksStat = 0U;	/*记录状态*/
	UINT16 wSpksId = 0U; /*用作ID*/
	UINT16 wSpksIndex = 0U;
	UINT16 wSpksSum = 0U;
	UINT8 chSpksCiToVobcSum = 0U;		/*CI最终发送给VOBC的spks数量*/
	UINT16 wSpksCiToVobcSumDress = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 chSpksPangLStat = 0U;		/*spks旁路状态*/
	UINT8 checkflag = 0U;

	if ((NULL == pDataBuf)
		|| (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wSpksSum = GetTotalSpksCurNum();		/*SPKS总数，大于等于SPKS_SUM_MAX返回0*/
		wSpksCiToVobcSumDress = ii;
		ii++;
		for (wSpksIndex = 0U; wSpksIndex < wSpksSum; wSpksIndex++)
		{
			wSpksId = GetSpksIdByIndex(wSpksIndex);
			if ((0U < wSpksId) && (UINT16_MAX > wSpksId))
			{
				/*增加检查条件：SPKS需要包含本控区区段*/
				checkflag = CheckSpksRelSecBelongCI(wSpksId);
				/*不包含本控区物理区段*/
				if (CI_SUCCESS == checkflag)
				{
					; /*不组包此SPKS信息*/
				}
				/*包含本控区物理区段*/
				else if (CI_ERROR == checkflag)
				{
					chSpksStat = GetSpksState(wSpksId);				/*SPKS按下，激活才需要组ID*/
					chSpksPangLStat = GetSpksCutState(wSpksId);		/*SPKS旁路状态*/
					if ((SPKS_STATUS_NO != chSpksStat) && (SPKS_CUT_YES != chSpksPangLStat))
					{
						ShortToChar(wSpksId, &pDataBuf[ii]);
						ii += 2U;
						chSpksCiToVobcSum++;			/*SPKS计数*/
					}
					else
					{
						;	/*未激活，无需组包*/
					}
				}
				else
				{
					/*检查错误，返回失败*/
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocBackUpSpksInfo SpksRelSecBelongCI_Error \n");
				}
			}
			else
			{
				debug_infor_printf((const)"\n PackCiToIvocBackUpSpksInfo wSpksId_Error : %d \n", wSpksId);
				/*spksID错误，停止组包*/
				chRetVal = CI_ERROR;
			}

			if (CI_SUCCESS != chRetVal)
			{
				break;
			}
			else
			{
				/*继续执行*/
			}
		}

		if (TRAIN_ABL_SPKS_SUM < chSpksCiToVobcSum)
		{
			/*激活的SPKS数量超限，断通信，不组包*/
			debug_infor_printf((const)"\n PackCiToIvocBackUpSpksInfo chSpksCiToVobcSum_Error : %d \n", chSpksCiToVobcSum);
			chRetVal = CI_ERROR;
		}
		else
		{
			; /*维持*/
		}
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
		pDataBuf[wSpksCiToVobcSumDress] = chSpksCiToVobcSum;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc备用通道紧急按钮状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpEsbInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 TrainAblReEsbNum = 0U;
	UINT8 jj = 0U;
	ABLTrainRelEsbStru* pAblRelEsbData = NULL;

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		TrainAblReEsbNum = GetTrainAblRelEsbNum(wTrainId);
		pDataBuf[ii++] = TrainAblReEsbNum;
		pAblRelEsbData = GetTrainAblRelEsbData(wTrainId);
		if(((0U != TrainAblReEsbNum)&&(NULL == pAblRelEsbData))
		||(TRAIN_ABL_ESB_SUM < TrainAblReEsbNum))
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"PackCiToIvocBackUpEsbInfo_ERROR TrainAblReEsbNum INVALID, %d", TrainAblReEsbNum);
		}
		else 
		{
			for (jj = 0U; jj < TrainAblReEsbNum; jj++)
			{
				ShortToChar(pAblRelEsbData[jj].wAblRelEsbId, &pDataBuf[ii]);		/*ESB ID*/
				ii += 2u;
				if ((CI_IVOC_ESB_STATE_INVALID == pAblRelEsbData[jj].chAblRelEsbSta) || (CI_IVOC_ESB_STATE_VALID == pAblRelEsbData[jj].chAblRelEsbSta))
				{
					pDataBuf[ii++] = pAblRelEsbData[jj].chAblRelEsbSta;
				}
				else
				{
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"PackCiToIvocBackUpEsbInfo ERROR AblRelEsbSta INVALID, %d", pAblRelEsbData[jj].chAblRelEsbSta);
				}
			}
		}
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc备用通道道岔状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpSwitchInfo(UINT8* pDataBuf, UINT16* wDataLength)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT16 chAblRelSwitchNum = 0U; /*ABL道岔数量*/
	UINT16 wSwitchId = 0U;/*道岔ID*/
	UINT8 chSwitchState = 0U;/*道岔状态*/

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		chAblRelSwitchNum = GetTotalSwitchCurNum();
		if (TRAIN_ABL_SWITCH_SUM < chAblRelSwitchNum)
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"PackCiToIvocBackUpSwitchInfo chAblRelSwitchNum INVALID, %d", chAblRelSwitchNum);
		}
		else
		{
			pDataBuf[ii++] = (UINT8)chAblRelSwitchNum;
			for (jj = 0U; jj < (UINT8)chAblRelSwitchNum; jj++)
			{
				wSwitchId = GetSwitchId(jj);/*获取配置文件中该索引下的道岔ID*/
				if (SWITCH_SUM_MAX > wSwitchId)
				{
					ShortToChar(wSwitchId, &pDataBuf[ii]);		/*道岔 ID*/
					ii += 2U;
					chSwitchState = GetSwitchCurPosition(wSwitchId);
					switch (chSwitchState)
					{
					case SWITCH_POSITION_DINGWEI:
						pDataBuf[ii++] = CI_IVOC_SWITCH_POSTION_DING;
						break;
					case SWITCH_POSITION_FANWEI:
						pDataBuf[ii++] = CI_IVOC_SWITCH_POSTION_FAN;
						break;
					case SWITCH_POSITION_JICHA:
					case SWITCH_POSITION_MOVE:
					case SWITCH_POSITION_SIKAI:
					case SWITCH_POSITION_INVALID:
						pDataBuf[ii++] = CI_IVOC_SWITCH_POSTION_SHIBIAO;
						break;
					default:
						/*道岔状态错误，停止组包*/
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"PackCiToIvocBackUpSwitchInfo_ERROR_switchState_INVALID, %d", chSwitchState);
						break;
					}
				}
				else
				{
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"PackCiToIvocBackUpSwitchInfo_ERROR_wSwitchId_INVALID, %d", wSwitchId);
				}
			}
		}
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc备用通道保护区段状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpProtectLgcInfo(UINT8* pDataBuf, UINT16* wDataLength,UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 chProSecSum = 0U;/*保护区段数目*/
	UINT8 jj = 0U;
	ABLTrainRelProSecStru* pAblProSecData = NULL;/*ABL保护区段数目*/
	UINT16 wProSecId = 0U;/*保护区段ID*/
	UINT8 chProSecDir = 0U;/*保护区段锁闭方向*/


	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		chProSecSum = GetTrainAblRelProSecNum(wTrainId);
		pAblProSecData = GetTrainAblRelProSecData(wTrainId);

		if (TRAIN_ABL_PROSEC_SUM >= chProSecSum)
		{
			pDataBuf[ii++] = chProSecSum;
			for (jj = 0U; jj < chProSecSum; jj++)
			{
				wProSecId = pAblProSecData[jj].wAblRelProSecId;
				if ((0U < wProSecId) && (UINT16_MAX > wProSecId))
				{
					ShortToChar(wProSecId, &pDataBuf[ii]);
					ii += 2U;
					chProSecDir = pAblProSecData[jj].chAblRelProSecDir;
					if ((CI_SYSTEM_DIRECTION_UP == chProSecDir) || (CI_SYSTEM_DIRECTION_DOWN == chProSecDir))
					{
						pDataBuf[ii++] = chProSecDir;
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocBackUpProtectLgcInfo chProSecDir_error : %d  \n", chProSecDir);
					}

				}
				else
				{
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocBackUpProtectLgcInfo wProSecId_error : %d  \n", wProSecId);
				}

				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
		}
		else
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocBackUpProtectLgcInfo chProSecSum more than MAX : %d  \n", chProSecSum);
		}
		
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc临时限速状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpTsrInfo(UINT8* pDataBuf, UINT16* wDataLength,UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 chXianSuPhySecSum = 0U;/*限速物理区段数目*/
	UINT8 jj = 0U;
	ABLTrainRelXianSuStru* pAblXiansuPhyData = NULL;/*ABL列车限速物理区段数据*/
	UINT16 wXiansuPhySecId = 0U;/*限速物理区段ID*/
	UINT16 wXiansuPhySecSpeed = 0U;/*限速物理区段限速值*/
	UINT8 chTempSendAxisSecSum = 0U;/*临时存放发送计轴区段数目*/
	UINT16 wTempSendAxisSecIndex = 0U;/*临时存放发送计轴区段数目索引*/
	UINT8 kk = 0U;
	UINT8 chPhySecRelAxisSecSum = 0U;/*物理区段对应计轴区段数目*/
	UINT16* szPhySecRelAxisId = NULL;/*物理区段关联计轴区段ID数组*/
	UINT8 wTempAxisSum = 0U; /*临时计轴区段数目*/
	UINT16 szAxisIdBuf[AC_MAXCNT_IN_SWITCH] = { 0U };/*临时计轴区段ID*/


	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		wTempSendAxisSecIndex = ii;
		ii++;

		chXianSuPhySecSum = GetTrainAblRelXianSuNum(wTrainId);
		pAblXiansuPhyData = GetTrainAblRelXiansuData(wTrainId);

		if (TRAIN_ABL_XIANSUSEC_SUM >= chXianSuPhySecSum)
		{
			for (jj = 0U; jj < chXianSuPhySecSum; jj++)
			{
				wXiansuPhySecId = pAblXiansuPhyData[jj].wAblRelXianSuPhySecId;
				if ((0U < wXiansuPhySecId) && (UINT16_MAX > wXiansuPhySecId))
				{
					chPhySecRelAxisSecSum = GetPAxisSectionSum(wXiansuPhySecId);
					szPhySecRelAxisId = GetPAxisSectionIdBuf(wXiansuPhySecId);

					if ((0U < chPhySecRelAxisSecSum) && (NULL != szPhySecRelAxisId))
					{
						wTempAxisSum = GetAllAxisFromAxisSeqSafeSw(szPhySecRelAxisId, (UINT16)chPhySecRelAxisSecSum, &szAxisIdBuf);

						if (0U == wTempAxisSum)
						{
							/*道岔四开所有计轴区段全部发送*/
							for (kk = 0U; kk < chPhySecRelAxisSecSum; kk++)
							{
								if ((0U < szPhySecRelAxisId[kk]) && (UINT16_MAX > szPhySecRelAxisId[kk]))
								{
									ShortToChar(szPhySecRelAxisId[kk], &pDataBuf[ii]);
									ii += 2U;
									wXiansuPhySecSpeed = pAblXiansuPhyData[jj].chAblRelXianSuValue;
									if (UINT16_MAX > wXiansuPhySecSpeed)
									{
										chTempSendAxisSecSum++;
										ShortToChar(wXiansuPhySecSpeed, &pDataBuf[ii]);
										ii += 2U;
									}
									else
									{
										chRetVal = CI_ERROR;
										debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo wXiansuPhySecSpeed_error : %d  \n", wXiansuPhySecSpeed);
									}
								}
								else
								{
									chRetVal = CI_ERROR;
									debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo szPhySecRelAxisId_error : %d  \n", szPhySecRelAxisId[kk]);
								}

								if (CI_SUCCESS != chRetVal)
								{
									break;
								}
								else
								{
									/*继续执行*/
								}
							}

						}
						else
						{
							for (kk = 0U; kk < wTempAxisSum; kk++)
							{
								if ((0U < szAxisIdBuf[kk]) && (UINT16_MAX > szAxisIdBuf[kk]))
								{
									ShortToChar(szAxisIdBuf[kk], &pDataBuf[ii]);
									ii += 2U;
									wXiansuPhySecSpeed = pAblXiansuPhyData[jj].chAblRelXianSuValue;
									if (UINT16_MAX > wXiansuPhySecSpeed)
									{
										chTempSendAxisSecSum++;
										ShortToChar(wXiansuPhySecSpeed, &pDataBuf[ii]);
										ii += 2U;
									}
									else
									{
										chRetVal = CI_ERROR;
										debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo wXiansuPhySecSpeed_error : %d  \n", wXiansuPhySecSpeed);
									}
								}
								else
								{
									chRetVal = CI_ERROR;
									debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo szPhySecRelAxisId_error : %d  \n", szPhySecRelAxisId[kk]);
								}

								if (CI_SUCCESS != chRetVal)
								{
									break;
								}
								else
								{
									/*继续执行*/
								}
							}
						}
					}
					else
					{
						chRetVal = CI_ERROR;
						debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo chPhySecRelAxisSecSum_error : %d  \n", chPhySecRelAxisSecSum);
					}
				}
				else
				{
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo wXiansuPhySecId_error : %d  \n", wXiansuPhySecId);
				}

				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
		}
		else
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo chXianSuPhySecSum more than MAX : %d  \n", chXianSuPhySecSum);
		}
	}

	if ((CI_SUCCESS == chRetVal) && (TRAIN_ABL_XIANSUSEC_SUM >= chTempSendAxisSecSum))
	{
		*wDataLength = ii;
		pDataBuf[wTempSendAxisSecIndex] = chTempSendAxisSecSum;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc状态确认信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpReqStateInfo(UINT8* pDataBuf, UINT16* wDataLength)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 jj = 0U;
	UINT16 kk = 0U;
	UINT8 chAreaSnowTotalNum = 0U;  /*区间雨雪站台数量*/
	UINT16 wAreaSnowNumIndex = 0U;
	AreaSnowInfoStruct* pAreaSnowData = NULL;  /*区间雨雪信息数组*/
	ToCiAreaSnowStruct* pRecvCiAreaSnow = NULL;  /*相邻联锁发送的区间雨雪信息*/
	UINT8 chTsrSureFlag = GetTsrSureFlag();/* 限速确认标志位 */
	UINT8 chAllLineTsrState = 0U;/*全线临时限速标志*/
	UINT8 chAllLineTsrSpeed = 0U;/*全线临时限速值*/
	UINT8 chWlbState = 0U;	/*全线紧急制动状态*/
	UINT8 chSnowModel = 0U;	/* 雨雪模式 */
	UINT16 wSnowPlatId = 0U;

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		/* 限速确认标志位 */
		chTsrSureFlag = GetTsrSureFlag();
		if (CI_TSR_SURE_YES == chTsrSureFlag)
		{
			/* 已确认 */
			pDataBuf[ii] = CI_TSR_SURE_YES;
		}
		else
		{
			/* 未确认 */
			pDataBuf[ii] = CI_TSR_SURE_NO;
		}
		ii += 1U;

		/* 全线临时限速信息 */
		chAllLineTsrState = GetAllLineTsrState();
		chAllLineTsrSpeed = GetAllLineTsrSpeed();
		if (CI_ALL_LINE_TSR_VALID == chAllLineTsrState)
		{
			/* 全线临时限速 */
			pDataBuf[ii] = CI_ALL_LINE_TSR_UNVALID;
			ii += 1U;
			ShortToChar((UINT16)chAllLineTsrSpeed, &pDataBuf[ii]);
			ii += 2U;

		}
		else
		{
			pDataBuf[ii] = CI_ALL_LINE_TSR_VALID;
			ii += 1U;
			ShortToChar(0U, &pDataBuf[ii]);
			ii += 2U;
		}

		/*全线紧急制动状态*/
		chWlbState = WlbGetState();
		if (WLB_UNSET == chWlbState)
		{
			/* 未设置 */
			pDataBuf[ii] = WLB_UNSET;
		}
		else
		{
			/* 已设置 */
			pDataBuf[ii] = WLB_SET;
		}
		ii += 1U;

		/* 雨雪模式 */
		chSnowModel = GetAllSnowModel();
		if (CI_ALL_SNOW_VALID == chSnowModel)
		{
			/* 雨雪 */
			pDataBuf[ii] = CI_ALL_SNOW_VALID;
		}
		else
		{
			/* 非雨雪 */
			pDataBuf[ii] = CI_ALL_SNOW_UNVALID;
		}
		ii += 1U;
		

		/*组本地区间雨雪状态信息*/
		wAreaSnowNumIndex = ii;  /*跳过区间雨雪站台数量*/
		ii++;
		chAreaSnowTotalNum = GetLocalAreaSnowNum();
		pAreaSnowData = GetLocalAreaSnow();

		if (ALL_AREA_SNOW_SUM_MAX >= chAreaSnowTotalNum)
		{
			for (jj = 0U; jj < chAreaSnowTotalNum; jj++)
			{
				wSnowPlatId = pAreaSnowData[jj].wAreaId;
				if ((0U<wSnowPlatId) && (UINT16_MAX>wSnowPlatId))
				{
					ShortToChar(wSnowPlatId, &pDataBuf[ii]);  /*组区间雨雪站台ID*/
					ii += 2U;
				}
				else
				{
					chRetVal = CI_ERROR;  /*区间雨雪站台ID非法，返回失败*/
				}
			}
		}
		else
		{
			chRetVal = CI_ERROR;  /*区间雨雪数量超限，返回失败*/
			debug_infor_printf((const)"\n PackCiToIvocSnowAndUrgentInfo AreaSnowSum_Error, sum : %d  _MAX: %d \n", chAreaSnowTotalNum, LOCAL_AREA_SNOW_SUM_MAX);
		}

		/*组相邻联锁发送的区间雨雪状态信息*/
		pRecvCiAreaSnow = GetCiRecvAreaSnowInfo();
		for (kk = 0U; kk < CI_COM_CI_MAX_NUM; kk++)
		{
			if (0U != pRecvCiAreaSnow[kk].cPlatFormNum)
			{
				for (jj = 0U; jj < pRecvCiAreaSnow[kk].cPlatFormNum; jj++)
				{
					if (ALL_AREA_SNOW_SUM_MAX > chAreaSnowTotalNum)
					{
						wSnowPlatId = pRecvCiAreaSnow[kk].szPlatFormInfo[jj].wAreaId;
						if ((0U < wSnowPlatId) && (UINT16_MAX > wSnowPlatId))
						{
							ShortToChar(wSnowPlatId, &pDataBuf[ii]);  /*组区间雨雪站台ID*/
							ii += 2U;
							chAreaSnowTotalNum++;
						}
						else
						{
							chRetVal = CI_ERROR;  /*区间雨雪站台Id非法，返回失败*/
						}						
					}
					else
					{
						debug_infor_printf((const)"\n PackCiToIvocSnowAndUrgentInfo RecvCiAreaSnowSum_Error, sum : %d  _MAX: %d \n", pRecvCiAreaSnow, LOCAL_AREA_SNOW_SUM_MAX);
						chRetVal = CI_ERROR;  /*区间雨雪数量超限，返回失败*/
					}
				}
			}
			else
			{
				/*继续遍历*/
			}
		}
		pDataBuf[wAreaSnowNumIndex] = chAreaSnowTotalNum;  /*组区间雨雪站台数量*/

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到IvoC防淹门状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
* 返回值  ： CI_ERROR 失败Spks
*			 CI_SUCCESS 成功
*/
static UINT8 PackCiToIvocBackUpFloodInfo(UINT8* pDataBuf, UINT16* wDataLength)
{
	UINT16 wFloodGateId = 0U; /*用作ID*/
	UINT16 wFloodGateIndex = 0U;
	UINT16 wFloodGateSum = 0U;
	UINT16 ii = 0U;
	UINT8 chRetVal = CI_ERROR;
	UINT8 chFloodOpenState = 0U;		/*开门锁定信息*/
	UINT8 chFloodrCloseRequestState = 0U;	/*关门请求*/

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;
		wFloodGateSum = GetTotalFloodGateCurSum();

		if (TRAIN_ABL_FLOODGATE_SUM >= wFloodGateSum)
		{
			pDataBuf[ii++] = (UINT8)wFloodGateSum;

			for (wFloodGateIndex = 0U; wFloodGateIndex < wFloodGateSum; wFloodGateIndex++)
			{
				wFloodGateId = GetFloodGateId(wFloodGateIndex);
				if ((0U < wFloodGateId) && (UINT16_MAX > wFloodGateId))
				{
					ShortToChar(wFloodGateId, &pDataBuf[ii]);
					ii += 2U;
					/*开门锁闭状态*/
					chFloodOpenState = GetFloodGateCurOpenLockState(wFloodGateId);
					chFloodrCloseRequestState = GetFloodGateCurCloseRequestSta(wFloodGateId);
					if ((FLOOD_GATE_NOT_OPENLOCK == chFloodOpenState) || (FLOOD_GATE_CLOSEREQ == chFloodrCloseRequestState))
					{
						/*防淹门关闭状态或有关门请求*/
						pDataBuf[ii++] = 0X55U;
					}
					else if ((FLOOD_GATE_OPENLOCK == chFloodOpenState) && (FLOOD_GATE_NOT_CLOSEREQ == chFloodrCloseRequestState))
					{
						pDataBuf[ii++] = 0XAAU;
					}
					else
					{
						; /*非法值*/
						debug_infor_printf((const)"\n PackCiToIvocBackUpFloodInfo FloodState_Error[chFloodOpenState:%d--chFloodrCloseRequestState:%d] : %d \n", chFloodOpenState,chFloodrCloseRequestState);
						/*防淹门状态错误，停止组包*/
						chRetVal = CI_ERROR;
					}
				}
				else
				{
					debug_infor_printf((const)"\n PackCiToIvocBackUpFloodInfo wFloodGateId_Error : %d \n", wFloodGateId);
					/*防淹门ID错误，停止组包*/
					chRetVal = CI_ERROR;
				}

				if (CI_SUCCESS != chRetVal)
				{
					break;
				}
				else
				{
					/*继续执行*/
				}
			}
		}
		else
		{
			/*防淹门当前总数错误 停止组包*/
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocBackUpFloodInfo FloodGateSum_Error, sum : %d  MAX: %d \n", wFloodGateSum, TRAIN_ABL_FLOODGATE_SUM);
		}

	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;

	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组包Ci到Ivoc前车信息
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 *dataLength, 数据长度 输出参数
*			 const UINT16 wTrnId VOBC ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
* by cgh 20240606
*/
static UINT8 PackCiToIvocHeadTrainInfo(UINT8* pDataBuf, UINT16* wDataLength, const UINT16 wTrnId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	HeadTrainLocStru strHeadTrainLocData = { 0U };
	UINT8 chTrainLocReverseRouteFlag = 0U;/*列车车身所处位置反向进路标识*/

	if ((NULL != pDataBuf) && (NULL != wDataLength) && (0U < wTrnId) && (UINT16_MAX > wTrnId))
	{
		chRetVal = CI_SUCCESS;
		ii = *wDataLength;

		strHeadTrainLocData = GetTrainHeadTrainLocData(wTrnId);
		if (0U != strHeadTrainLocData.wHeadVobcId)
		{
			LongToChar(strHeadTrainLocData.wHeadVobcId,&pDataBuf[ii]);  
			ii += 4U;
		}
		else
		{
			chRetVal = CI_ERROR;
			debug_infor_printf((const)"\n PackCiToIvocHeadTrainInfo wHeadVobcId %d ERROR \n", strHeadTrainLocData.wHeadVobcId);
		}

		if (CI_SUCCESS == chRetVal)
		{
			pDataBuf[ii++] = strHeadTrainLocData.chHeadTrainLocFlag;
			if (HEAD_TRAIN_LOC_ATP == strHeadTrainLocData.chHeadTrainLocFlag)
			{
				if ((TRAIN_DIR_DEF == strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir)
					|| (TRAIN_DIR_UP == strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir)
					|| (TRAIN_DIR_DOWN == strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir))
				{
					pDataBuf[ii++] = strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir;
					ShortToChar(strHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink, &pDataBuf[ii]);
					ii += 2U;
					LongToChar(strHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset, &pDataBuf[ii]);
					ii += 4U;
					ShortToChar(strHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink, &pDataBuf[ii]);
					ii += 2U;
					LongToChar(strHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset, &pDataBuf[ii]);
					ii += 4U;

					/*预留4个字节*/
					ii += 4U;
				}
				else
				{
					chRetVal = CI_ERROR;
					debug_infor_printf((const)"\n PackCiToIvocHeadTrainInfo chTrainDir %d ERROR \n", strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir);
				}
			}
			else if (HEAD_TRAIN_LOC_ITE == strHeadTrainLocData.chHeadTrainLocFlag)
			{
					ShortToChar(strHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink, &pDataBuf[ii]);
					ii += 2U;
					LongToChar(strHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset, &pDataBuf[ii]);
					ii += 4U;
					ShortToChar(strHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink, &pDataBuf[ii]);
					ii += 2U;
					LongToChar(strHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset, &pDataBuf[ii]);
					ii += 4U;


					pDataBuf[ii++] = strHeadTrainLocData.strHeadTrainIteLoc.chTrainDir;
					ShortToChar(strHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss, &pDataBuf[ii]);
					ii += 2U;
					ShortToChar(strHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss, &pDataBuf[ii]);
					ii += 2U;
			}
			else
			{
				/*前面成功，说明前者位置信息获取成功，这里位置信息不发送*/
				; 
			}
		}
		else
		{
			; /*错误不继续组包*/
		}

		if (CI_SUCCESS == chRetVal)
		{
			chTrainLocReverseRouteFlag = GetTrainLocReverseRouteFlag(wTrnId);
			if ((TRAIN_LOC_REV_ROUTE_FLAG_NONE == chTrainLocReverseRouteFlag)
				|| (TRAIN_LOC_REV_ROUTE_FLAG_NO == chTrainLocReverseRouteFlag)
				|| (TRAIN_LOC_REV_ROUTE_FLAG_YES == chTrainLocReverseRouteFlag))
			{
				pDataBuf[ii++] = chTrainLocReverseRouteFlag;
			}
			else
			{
				chRetVal = CI_ERROR;
				debug_infor_printf((const)"\n PackCiToIvocHeadTrainInfo chTrainLocReverseRouteFlag %d ERROR \n", chTrainLocReverseRouteFlag);
			}
		}
		else
		{
			; /*错误不继续组包*/
		}

		if (CI_SUCCESS == chRetVal)
		{
			*wDataLength = ii;
		}
		else
		{
			chRetVal = CI_ERROR;
		}
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 解析FAOHLHT其他报文类型数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*			 const UINT8 systemId, 源设备ID
*			 VobcToCiDataStruct* vobcToCiDataStru VOBC到CI结构体数据
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功
* BY CGH 20240606
*/
UINT8 ParseFAOHLHTOtherTypeData(const UINT16 appInfoType, UINT8* dataBuf, UINT16 dataLen, const UINT8 systemId, VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT8 chRetVal = CI_ERROR;
	UINT8 cmdType = 0u;							 /*屏蔽门命令类型*/
	UINT8 trainStopSteadyState = 0u;				/*列车停稳状态*/
	UINT8 psdSum = 0u;
	UINT8 trainDirection = 0u;					/*列车方向*/
	UINT8 ii = 0u;                                /*索引管理*/
	UINT8 jj = 0u;
	UINT8 retValue = 0u;
	UINT16 psdId = 0u;                            /*PSD的ID*/
	UINT32 psdIdIntConnt = 0u;                    /*互联互通PSD的ID*/
	UINT32 trackSectionId = 0u;					 /*轨道区段ID*/
	UINT32 signalId = 0u;		/*VOBC->CI信号机ID*/
	UINT8 gapDetCmdType = 0u;	/*间隙探测命令类型*/
	UINT8 doorState = 0u;        /*VOBC-CI关联车门状态*/
	UINT8 cTempPsdCmdCode = 0U;
	UINT8 chVideoQkState = 0U;/*视频清客状态*/
	UINT8 chVideoQkResult = 0U;/*视频清客结果*/
	UINT16 wTempAppInfoType = 0U;

	if (NULL == dataBuf)
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		chRetVal = CI_SUCCESS;

		if (VOBC_CI_INFO_TYPE_PSD_CONTROL == appInfoType)
		{	/*只有当VOBC发送CI的信息类型是屏蔽门控制报文时才继续解析报文信息*/
			/*列车运行方向判断*/
			vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum();
			trainDirection = dataBuf[ii];
			ii += 1u;

			if ((TRAIN_DIR_UP == trainDirection) || (TRAIN_DIR_DOWN == trainDirection) || (TRAIN_DIR_DEF == trainDirection))
			{
				vobcToCiDataStru->trainDirection = trainDirection;
			}
			else
			{
				chRetVal = CI_ERROR;
			}

			/*列车停稳停准信息（允许保护区段解锁命令）判断*/
			if (CI_SUCCESS == chRetVal)
			{
				trainStopSteadyState = dataBuf[ii];
				ii += 1u;

				if ((VOBC_CI_STOP_TW == trainStopSteadyState) || (VOBC_CI_STOP_WTW == trainStopSteadyState))
				{
					vobcToCiDataStru->trainStopSteadyState = trainStopSteadyState;
					vobcToCiDataStru->stopSteadyStartCycNum = Get2oo2CurCycleNum();/*记录收到停稳或未停稳信息的周期*/
				}
				else
				{
					chRetVal = CI_ERROR;
				}
			}

			trackSectionId = LongFromChar(&dataBuf[ii]);/*获取轨道区段ID*/
			ii += 4u;
			vobcToCiDataStru->trackSecID = trackSectionId;

			if (CI_SUCCESS == chRetVal)
			{
				vobcToCiDataStru->VobcId = systemId;                         /*VOBC的ID*/
				vobcToCiDataStru->psdCmdCode = dataBuf[ii++];        /*站台开门码，每个开门码对应CI需要开的一组站台门*/
				/*根据站台开门码获取编组信息，开门码的低5位表示列车实际编组数*/

				/*因为在关门时VOBC发送车辆编组默认值,所以需要在开门时保存车辆编组数值*/
				cTempPsdCmdCode = 0x1Fu & vobcToCiDataStru->psdCmdCode;
				if (0U != cTempPsdCmdCode)  /*修缺陷YF0083-682，2023-07-03*/
				{
					vobcToCiDataStru->trainEditGroupInfo = cTempPsdCmdCode;
				}
				else
				{
					vobcToCiDataStru->trainEditGroupInfo = vobcToCiDataStru->trainEditGroupInfo;
				}

				psdSum = dataBuf[ii];
				ii += 1u;

				if ((2u == psdSum) || (1u == psdSum) || (0u == psdSum))
				{/*接口定义：屏蔽门数量取值为0或1或2*/
					vobcToCiDataStru->PsdSum = psdSum;		          /*屏蔽门数量*/
				}
				else
				{
					chRetVal = CI_ERROR;
				}
			}

			if (CI_SUCCESS == chRetVal)
			{
				for (jj = 0u; jj < 2u; jj++)
				{
					psdIdIntConnt = LongFromChar(&dataBuf[ii]);/*获取互联互通4字节屏蔽门ID*/
					ii += 4u;
					vobcToCiDataStru->PsdData[jj].PsdIdInterConn = psdIdIntConnt;

					/*根据互联互通4字节ID获取屏蔽门ID*/
					retValue = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdIdIntConnt, &psdId);

					if (CI_SUCCESS == retValue)
					{
						vobcToCiDataStru->PsdData[jj].PsdId = psdId;

						cmdType = dataBuf[ii];/*获取屏蔽门命令*/
						ii += 1u;
						if ((VOBCTOCI_COMMAND_TYPE_PSDOPEN == cmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == cmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT == cmdType))  /*修缺陷YF0083-682，2023-07-03*/
						{
							vobcToCiDataStru->PsdData[jj].CmdType = cmdType;
							vobcToCiDataStru->PsdData[jj].CmdStartCycNum = Get2oo2CurCycleNum();
						}
						else
						{
							chRetVal = CI_ERROR;
						}
					}
					else
					{
						ii++;
					}
				}

				/*增加新的接口：信号机的ID1~0xFFFFFFFF,0为默认值，VOBC最大安全前端前方沿列车运行方向可搜索到的最近的同向信号机。*/
				signalId = LongFromChar(&dataBuf[ii]);	/*获取信号机ID*/
				ii += 4u;
				vobcToCiDataStru->signalID = signalId;	/*将信号机ID保存到结构体*/
			}

			/*继续解析VOBC2CI全自动运行站台控制信息（间隙探测启动或停止命令），与VOBC2CI站台门控制信息一并发送*/
			ii += 2u;/*跳过应用报文长度2字节*/
			wTempAppInfoType = ShortFromChar(&dataBuf[ii]);/*应用信息类型，屏蔽门控制信息或者心跳帧信息*/
			ii += 2u;
			ii += 2u;/*跳过两个预留字节*/

			if (VOBC_CI_INFO_TYPE_FAO_CONTROL == wTempAppInfoType)
			{/*报文类型为全自动运行站台控制信息*/
				psdSum = dataBuf[ii];
				ii += 1u;

				if ((2u == psdSum) || (1u == psdSum) || (0u == psdSum))
				{/*接口定义：屏蔽门数量取值为0或1或2*/
				}
				else
				{
					chRetVal = CI_ERROR;
				}

				if (CI_SUCCESS == chRetVal)
				{/*此处CI默认VOBC发送的FAO站台控制信息中PSD ID及顺序与PSD控制信息中PSD ID及顺序完全一致。*/
					for (jj = 0u; jj < 2u; jj++)
					{
						psdIdIntConnt = LongFromChar(&dataBuf[ii]);/*获取互联互通4字节屏蔽门ID*/
						ii += 4u;

						/*根据互联互通4字节ID获取屏蔽门ID*/
						retValue = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdIdIntConnt, &psdId);

						if (CI_SUCCESS == retValue)
						{
							gapDetCmdType = dataBuf[ii];/*获取屏蔽门命令*/
							ii += 1u;

							if ((VOBC_CI_GAP_DETECT_CMD_START == gapDetCmdType) || (VOBC_CI_GAP_DETECT_CMD_STOP == gapDetCmdType)
								|| (VOBC_CI_GAP_DETECT_CMD_DEFAULT == gapDetCmdType))
							{/*判断间隙探测命令有效性*/
								vobcToCiDataStru->PsdData[jj].gapDetectCmd = gapDetCmdType;
							}
							else
							{
								chRetVal = CI_ERROR;
							}

						}
						else
						{
							ii += 1u;	/*跳过间隙探测命令类型*/
						}
					}
				}
			}
			else if (VOBC_CI_INFO_TYPE_MANU_DEFINED == wTempAppInfoType)
			{/*解析厂商自定义帧数据更新车门状态信息*/

				psdSum = dataBuf[ii];
				ii += 1u;

				if ((2u == psdSum) || (1u == psdSum) || (0u == psdSum))
				{/*接口定义：屏蔽门数量取值为0或1或2*/
				}
				else
				{
					chRetVal = CI_ERROR;
				}

				if (CI_SUCCESS == chRetVal)
				{/*此处CI默认VOBC发送的VOBC车门状态信息中PSD ID及顺序与PSD控制信息中PSD ID及顺序完全一致。*/
					for (jj = 0u; jj < 2u; jj++)
					{
						psdIdIntConnt = LongFromChar(&dataBuf[ii]);/*获取互联互通4字节屏蔽门ID*/
						ii += 4u;
						vobcToCiDataStru->PsdData[jj].PsdIdInterConn = psdIdIntConnt;

						/*根据互联互通4字节ID获取屏蔽门ID*/
						retValue = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdIdIntConnt, &psdId);

						if (CI_SUCCESS == retValue)
						{
							vobcToCiDataStru->PsdData[jj].PsdId = psdId;

							doorState = dataBuf[ii];/*获取VOBC车门状态*/
							ii += 1u;

							if ((VOBC_CI_DOOR_CLOSEDANDLOCKED == doorState) || (VOBC_CI_DOOR_NOTCLOSEDANDLOCKED == doorState))
							{ /*VOBC车门状态检查有效性*/
								vobcToCiDataStru->PsdData[jj].VOBCDoorState = doorState;
							}
							else
							{
								chRetVal = CI_ERROR;
							}
						}
						else
						{
							ii += 1u;	/*跳过VOBC车门状态*/
						}
					}
				}

				/*视频清客相关信息*/
				if (CI_SUCCESS == chRetVal)
				{
					/*视频清客状态*/
					chVideoQkState = dataBuf[ii];
					ii++;
					/*视频清客结果*/
					chVideoQkResult = dataBuf[ii];
					ii++;

					if (((VIDEO_QK_STATE_TESTING == chVideoQkState) || (VIDEO_QK_STATE_DEFAULT == chVideoQkState))
						&& ((VIDEO_QK_RESULT_TESTNO == chVideoQkResult) || (VIDEO_QK_RESULT_TESTHAVE == chVideoQkResult) || (VIDEO_QK_RESULT_TESTDEFAULT == chVideoQkResult))
						&& (PSD_SUM_MAX > vobcToCiDataStru->PsdData[0].PsdId) && (PSD_SUM_MAX > vobcToCiDataStru->PsdData[1].PsdId))
					{
						vobcToCiDataStru->chVideoQkState = chVideoQkState;
						vobcToCiDataStru->chVideoQkResult = chVideoQkResult;
						vobcToCiDataStru->wVideoQkRelatePsdId1 = vobcToCiDataStru->PsdData[0].PsdId;
						vobcToCiDataStru->wVideoQkRelatePsdId2 = vobcToCiDataStru->PsdData[1].PsdId;
					}
					else
					{
						chRetVal = CI_ERROR;;
					}
				}
			}
			else
			{
				chRetVal = CI_ERROR;
			}
		}
		else if (VOBC_CI_INFO_TYPE_FAO_INFO == appInfoType)
		{/*VOBC->CI全自动运行洗车信息*/
			vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum();	/*保存CI-VOBC 通信开始周期*/
			/*解析全自动洗车相关信息*/

			/*洗车请求信息校验及存储*/
			chRetVal = WashTrainRequestCheck(dataBuf[ii]);

			if (CI_SUCCESS == chRetVal)
			{
				vobcToCiDataStru->washTrainRequest = dataBuf[ii];
				ii += 1U;
				/*洗车停稳1信息校验及存储*/
				chRetVal = HeadWashStopSteadyInfoCheck(dataBuf[ii]);
			}
			else
			{
				chRetVal = CI_ERROR;
			}

			if (CI_SUCCESS == chRetVal)
			{
				vobcToCiDataStru->headWashStopSteadyInfo = dataBuf[ii];
				ii += 1U;
				/*暂停洗车请求信息及存储*/
				chRetVal = WashPauseRequestCheck(dataBuf[ii]);
			}
			else
			{
				chRetVal = CI_ERROR;
			}

			if (CI_SUCCESS == chRetVal)
			{
				vobcToCiDataStru->washPauseRequest = dataBuf[ii];
				ii += 1U;
				/*洗车停稳2信息及存储*/
				chRetVal = TailWashStopSteadyInfoCheck(dataBuf[ii]);
			}
			else
			{
				chRetVal = CI_ERROR;
			}

			if (CI_SUCCESS == chRetVal)
			{
				vobcToCiDataStru->tailWashStopSteadyInfo = dataBuf[ii];
				ii += 1U;
				/*通过洗车机请求信息及存储*/
				chRetVal = PassWashMachineRequestCheck(dataBuf[ii]);
			}
			else
			{
				chRetVal = CI_ERROR;
			}

			if (CI_SUCCESS == chRetVal)
			{
				/*洗车机工作模式信息及存储*/
				vobcToCiDataStru->passWashMachineRequest = dataBuf[ii];
				ii += 1U;
				chRetVal = WashMachineWorkModeCheck(dataBuf[ii]);
			}
			else
			{
				chRetVal = CI_ERROR;
			}

			if (CI_SUCCESS == chRetVal)
			{
				vobcToCiDataStru->chWashMachineWorkMode = dataBuf[ii];
				ii += 1U;
			}
			else
			{
				chRetVal = CI_ERROR;
			}
		}
		else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == appInfoType) || (VOBC_CI_INFO_TYPE_LOGOUT_ASK == appInfoType))
		{/*心跳帧或注销请求帧*/
			vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum();
		}
		else
		{
			chRetVal = CI_ERROR;
		}
	}


	if (dataLen != ii)
	{
		debug_infor_printf((const)"\nVOBC %d DATALEN1 CHECK ERR,dataLen:%d,ii:%d", systemId, dataLen, ii);
		chRetVal = CI_ERROR;
	}
	else
	{
		; /* do nothing */
	}
	return chRetVal;
}

/*
* 功能描述： 解析FAOHLHT后备运行控制信息数据
* 参数说明： const UINT8* dataBuf, 数据缓冲区
*            const UINT16 dataLength, 数据长度
*			 VobcToCiDataStruct* vobcToCiDataStru VOBC到CI结构体数据
* 返回值  ： 0: 数据解析失败
*			 1: 数据解析成功
* BY CGH 20240606
*/
UINT8 ParseFAOHLHTBackUpControlData(UINT8* dataBuf, UINT16 dataLen, VobcToCiDataStruct* vobcToCiDataStru)
{
	UINT8 chRetVal = CI_ERROR;
	UINT8 ii = 0U;
	UINT8 chTrainLevel = 0U;/*列车运行控制级别*/
	UINT8 chTrainDirection = 0U;/*运行方向*/
	UINT16 wMaxHeadLink = 0U; /*列车最大安全前端所处Link*/
	UINT32 dwMaxHeadOff = 0U; /*列车最大安全前端偏移量*/
	UINT16 wMinTailLink = 0U; /*列车最小安全后端所处Link*/
	UINT32 dwMinTailOff = 0U; /*列车最小安全后端偏移量*/
	UINT32 dwHlhtNs = 0U;/*互联互通ID*/
	UINT16 wHeadTrainId = 0U;/*前车ID*/
	UINT16 wTrainRelLgcId = 0U;
	UINT16 wHeadSignalId = 0U;/*前方信号机ID*/
	UINT8 chNvramPosFlag = 0U;
	UINT8 chStopSteayFlag = 0U; /*停稳标志*/
	UINT32 dwTrackSecId = 0U;  /*轨道区段*/

	if ((NULL == dataBuf) || (NULL == vobcToCiDataStru))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		chRetVal = CI_SUCCESS;

		vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum();
		/*列车运行控制级别有效性校验*/
		chTrainLevel = dataBuf[ii++];
		if ((TRAIN_LEVEL_BACKUP_LIANXU == chTrainLevel) || (TRAIN_LEVEL_BACKUP_BLOCK == chTrainLevel) || (TRAIN_LEVEL_BACKUP_CI == chTrainLevel)
			|| (TRAIN_LEVEL_BACKUP_ABL == chTrainLevel) || (TRAIN_LEVEL_BACKUP_UNKNOWN == chTrainLevel))
		{
			vobcToCiDataStru->chTrainLevel = chTrainLevel;
		}
		else
		{
			debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,chTrainLevel:%d", vobcToCiDataStru->VobcId, chTrainLevel);
			chRetVal = CI_ERROR;
		}

		if (CI_SUCCESS == chRetVal)
		{
			/*列车运行方向判断*/
			chTrainDirection = dataBuf[ii++];
			if ((TRAIN_DIR_UP == chTrainDirection) || (TRAIN_DIR_DOWN == chTrainDirection) || (TRAIN_DIR_DEF == chTrainDirection))
			{
				vobcToCiDataStru->trainDirection = chTrainDirection;
			}
			else
			{
				debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,chTrainDirection:%d", vobcToCiDataStru->VobcId, chTrainDirection);
				chRetVal = CI_ERROR;
			}
		}
		else
		{
			; 
		}
		
		/*读取包络相关数值并校验*/
		if (CI_SUCCESS == chRetVal)
		{
			wMaxHeadLink = ShortFromChar(&dataBuf[ii]); /*列车最大安全前端所处Link*/
			ii += 2U;
			dwMaxHeadOff = LongFromChar(&dataBuf[ii]); /*列车最大安全前端偏移量*/
			ii += 4U;
			wMinTailLink = ShortFromChar(&dataBuf[ii]); /*列车最小安全后端所处Link*/
			ii += 2U;
			dwMinTailOff = LongFromChar(&dataBuf[ii]); /*列车最小安全后端偏移量*/
			ii += 4U;

			if ((0u != wMaxHeadLink) && (UINT16_MAX != wMaxHeadLink)
				&& (0u != wMinTailLink) && (UINT16_MAX != wMinTailLink)
				&& (UINT32_MAX != dwMaxHeadOff) && (UINT32_MAX != dwMinTailOff))
			{
				vobcToCiDataStru->wTrainMaxSafeHeadLink = wMaxHeadLink;
				vobcToCiDataStru->dwTrainMaxSafeHeadOffset = dwMaxHeadOff;
				vobcToCiDataStru->wTrainMinSafeTailLink = wMinTailLink;
				vobcToCiDataStru->dwTrainMinSafeTailOffset = dwMinTailOff;
			}
			else
			{
				debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,wMaxHeadLink:%d,dwMaxHeadOff:%d,wMinTailLink:%d,dwMinTailOff:%d", vobcToCiDataStru->VobcId, wMaxHeadLink, dwMaxHeadOff, wMinTailLink, dwMinTailOff);
				chRetVal = CI_ERROR;  /*包络数值非法*/
			}
		}
		else
		{
			; /*不处理*/
		}

		/*信号机ID*/
		if (CI_SUCCESS == chRetVal)
		{
			dwHlhtNs = LongFromChar(&dataBuf[ii]);
			ii += 4U;
			if (0x00000000U == dwHlhtNs)
			{
				/*默认值设置前方信号机ID为0*/
				vobcToCiDataStru->wHeadSigId = 0U;
			}
			else
			{
				/*根据互联互通4字节ID获取信号机ID*/
				chRetVal = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, dwHlhtNs, &wHeadSignalId);
				if ((CI_SUCCESS == chRetVal) && (SIGNAL_SUM_MAX > wHeadSignalId))
				{
					vobcToCiDataStru->wHeadSigId = wHeadSignalId;
				}
				else
				{
					chRetVal = CI_ERROR;

					debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,wFaoHlhtBackUpInfoSigId:%d", vobcToCiDataStru->VobcId, dwHlhtNs);

				}
			}
		}
		else
		{

		}

		/*前车ID*/
		if (CI_SUCCESS == chRetVal)
		{
			dwHlhtNs = LongFromChar(&dataBuf[ii]);
			ii += 4U;
			if (0xFFFFFFFFU == dwHlhtNs)
			{
				/*默认值设置前车ID为0*/
				vobcToCiDataStru->wHeadVobcId = 0x14FFU;
			}
			else
			{
				chRetVal = dquHlhtId2VobcName(dwHlhtNs, &wHeadTrainId, &wTrainRelLgcId);
				if (CI_SUCCESS == chRetVal)
				{
					vobcToCiDataStru->wHeadVobcId = wHeadTrainId;
				}
				else
				{
					debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,wHeadTrainId dwHlhtNs:%d", vobcToCiDataStru->VobcId, dwHlhtNs);

					chRetVal = CI_ERROR;
				}
			}
		}
		else
		{
			; /*不处理*/
		}

		/*NVRAM位置标识*/
		if (CI_SUCCESS == chRetVal)
		{
			chNvramPosFlag = dataBuf[ii++];
			if ((TRAIN_NVRAM_POS_FLAG_YES == chNvramPosFlag) || (TRAIN_NVRAM_POS_FLAG_NO == chNvramPosFlag))
			{
				vobcToCiDataStru->chNvramPosFlag = chNvramPosFlag;
			}
			else
			{
				debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,chNvramPosFlag:%d", vobcToCiDataStru->VobcId, chNvramPosFlag);
				chRetVal = CI_ERROR;
			}
		}
		else
		{
			; /*不处理*/
		}

		/*列车停稳状态*/
		if (CI_SUCCESS == chRetVal)
		{

			chStopSteayFlag = dataBuf[ii];
			ii += 1U;
			dwTrackSecId = LongFromChar(&dataBuf[ii]);
			ii += 4U;
			if ((VOBC_CI_STOP_TW == chStopSteayFlag) || (VOBC_CI_STOP_WTW == chStopSteayFlag))
			{
				vobcToCiDataStru->trainStopSteadyState = chStopSteayFlag;
				vobcToCiDataStru->stopSteadyStartCycNum = Get2oo2CurCycleNum();
				vobcToCiDataStru->trackSecID = dwTrackSecId;
			}
			else
			{
				debug_infor_printf((const)"\nVOBC_BACK_UP %d  chStopSteayFlag : %d\n", vobcToCiDataStru->VobcId, chStopSteayFlag);
				chRetVal = CI_ERROR;
			}
		}
	}


	if (dataLen != (ii + 5U))
	{
		chRetVal = CI_ERROR;

		debug_infor_printf((const)"\nVOBC %d DATALEN2 CHECK ERR,dataLen:%d,ii:%d", vobcToCiDataStru->VobcId, dataLen, ii);
	}
	else
	{
		; /* do nothing */
	}
	return chRetVal;
}

/*
* 功能描述： 组包Ci到VOBC后备通道信号机状态信息
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返回值  ： CI_ERROR 失败
*			 CI_SUCCESS 成功
* by cgh 20240607
*/
static UINT8 PackCiToVobcSigInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 jj = 0U;
	UINT32 dwSigHlhtId = 0U;/*信号机互联互通ID*/
	UINT8 chRouteState = 0U;/*进路状态*/
	UINT16	wStatrSigRtSum = 0U;/*获取以该信号机为始端信号机的进路数目*/
	UINT16* szStartSigRouteBuf = NULL;/*获取以该信号机为始端信号机的进路数组*/
	UINT8 chSigState = 0U;/*信号机状态*/
	UINT16 wSigId = 0U;/*信号机ID*/
	UINT8 chRouteLevel = 0U;/*进路监督级别*/
	UINT8 chKeepFlag = CI_ERROR;/*继续检查标志*/
	UINT8 chRouteReverseProperty = 0U;

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		
		ii = *wDataLength;
		chRetVal = CI_SUCCESS;

		wSigId = GetTrainHeadSigId(wTrainId);
		
		if (0U == wSigId)
		{
			LongToChar(0U, &pDataBuf[ii]);
			ii += 4U;
			pDataBuf[ii++] = CI_VOBC_SIGNAL_DEFAULT;
		}
		else
		{
			chRetVal = dquQueryOutDevId(QFUN_IDMAP_SIGNAL_ID, wSigId, &dwSigHlhtId);
			if (CI_SUCCESS == chRetVal)
			{
				LongToChar(dwSigHlhtId, &pDataBuf[ii]);
				ii += 4U;
				chSigState = CI_VOBC_SIGNAL_DEFAULT;
				/*遍历以该信号机为始端信号机的进路，有一条进路状态为预先开放或接近开放则发送1*/
				wStatrSigRtSum = GetStartSignalRouteSum(wSigId);/*获取以该信号机为始端信号机的进路数目*/
				szStartSigRouteBuf = GetStartSignalRouteBuf(wSigId);/*获取以该信号机为始端信号机的进路数组*/
				if (0U != wStatrSigRtSum)
				{
					for (jj = 0U; jj < wStatrSigRtSum; jj++)
					{/*查找以信号机为始端信号机的开放的进路ID*/
						chRouteLevel = GetRouteLevel(szStartSigRouteBuf[jj]);
						if (ROUTE_LEVEL_BLOC == chRouteLevel)
						{
							chRouteState = GetRouteState(szStartSigRouteBuf[jj]);/*获取进路状态*/
							if ((ROUTE_STATE_YUXIAN_OPEN == chRouteState) || (ROUTE_STATE_NEAR_OPEN == chRouteState))
							{
								chRouteReverseProperty = GetRouteReverseProperty(szStartSigRouteBuf[jj]);
								if (ROUTE_REVERSE_PROPERTY_YES == chRouteReverseProperty)
								{
									/*进路若为反向进路，状态为默认*/
									chSigState = CI_VOBC_SIGNAL_DEFAULT;
								}
								else
								{
									chSigState = CI_VOBC_SIGNAL_YES;
								}

								/*完整锁闭就不继续找了*/
								chKeepFlag = CI_SUCCESS;
							}
							else if (ROUTE_STATE_NEAR_LOCK == chRouteState)
							{
								chSigState = CI_VOBC_SIGNAL_NO;
								/*禁止信号（正常关闭）0XAA：接近锁闭正常*/
								chKeepFlag = CI_SUCCESS;
							}
							else if (ROUTE_STATE_AUTO_UNLOCK == chRouteState)
							{
								chSigState = CI_VOBC_SIGNAL_NO;
								/*禁止信号（正常关闭）0XAA：自动解锁正常*/
							}
							else if ((ROUTE_STATE_FIRST_LOCKERR == chRouteState) || (ROUTE_STATE_YUXIAN_LOCK == chRouteState)
								|| (ROUTE_STATE_NEAR_LOCKERR == chRouteState) || (ROUTE_STATE_DELAY_UNLOCK == chRouteState))
							{
								chSigState = CI_VOBC_SIGNAL_ERR;
								/*禁止信号（异常关闭）0XCC：进路状态为初锁异常、预先锁闭、接近锁闭异常、延时解锁*/
								/*完整锁闭就不继续找了*/
								chKeepFlag = CI_SUCCESS;
							}
							else if (ROUTE_STATE_AUTO_UNLOCKERR == chRouteState)
							{
								chSigState = CI_VOBC_SIGNAL_ERR;
								/*禁止信号（异常关闭）0XCC：进路状态为自动解锁异常、*/
							}
							else if (ROUTE_STATE_IDLE == chRouteState)
							{
								; /*空闲继续查找下一条*/
							}
							else if ((ROUTE_STATE_HALF_FIRST_XUAN == chRouteState) || (ROUTE_STATE_HALF_XUANPAI == chRouteState)
								|| (ROUTE_STATE_HALF_LOCK == chRouteState) || (ROUTE_STATE_HALF_UNLOCKDELAY == chRouteState)
								|| (ROUTE_STATE_HALF_UNLOCK == chRouteState))
							{
								/*默认值0XFF:部分锁闭初选、部分锁闭选排、部分锁闭、部分进路等待解锁、部分进路延时解锁*/
								chSigState = CI_VOBC_SIGNAL_DEFAULT;
							}
							else
							{
								/*默认值0XFF:初选、选排、初锁、引导选排、引导锁闭、引导锁闭异常、引导开放*/
								chSigState = CI_VOBC_SIGNAL_DEFAULT;
								chKeepFlag = CI_SUCCESS;
							}
						}
						else
						{
							/*进路监督级别是按照进路始端信号机判断，所以只要出现一个进路监督级别不是后备，就退出查找，返回默认*/
							chKeepFlag = CI_SUCCESS;
							chSigState = CI_VOBC_SIGNAL_DEFAULT;
						}

						if (CI_SUCCESS == chKeepFlag)
						{
							break;
						}
						else
						{
							; /*继续查找*/
						}
					}
				}
				else
				{
					; /*无匹配进路,状态为默认*/
				}
				pDataBuf[ii++] = chSigState;
			}
			else
			{
				debug_infor_printf((const)"\n PackCiToIvocBackUpSigInfo wSigId: %d error\n", wSigId);
			}
		}	
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组CI到VOBC后备状态数据
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 VobcToCiDataStruct *pstVobcToCiDataStru VOBC到CI数据
* 返回值  ： 0:组数据失败
*			 1:组数据成功
* by cgh 20240704
*/
static UINT8 PackCiToVobcBackUpStateData(UINT8* pDataBuf, UINT16* wDataLength,VobcToCiDataStruct* pstVobcToCiDataStru)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;

	if ((NULL == pDataBuf) || (NULL == wDataLength) || (NULL == pstVobcToCiDataStru))
	{
		chRetVal = CI_ERROR;
	}
	else
	{
		ii = *wDataLength;

		/*组备用通道发给车的逻辑区段信息*/
		chRetVal = PackCiToIvocBackUpLogSecInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId);

		if (CI_SUCCESS == chRetVal)
		{
			/*组备用通道发给车的进路信息*/
			chRetVal = PackCiToIvocBackUpRouteInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpLogSecInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		if (CI_SUCCESS == chRetVal)
		{
			/*组备用通道发给车的折返逻辑区段信息*/
			chRetVal = PackCiToIvocBackUpReturnLogInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpRouteInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		if (CI_SUCCESS == chRetVal)
		{
			/*组备用通道发给车的PSD的信息*/
			chRetVal = PackCiToIvocBackUpPsdInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpReturnLogInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		/*组备用通道发给车已激活的SPKS信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToIvocBackUpSpksInfo(pDataBuf, &ii);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpPsdInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		/*组备用通道发给车的ESB的信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToIvocBackUpEsbInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpSpksInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		/*组道岔信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToIvocBackUpSwitchInfo(pDataBuf, &ii);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpEsbInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		/*组备用通道发给车的保护区段状态信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToIvocBackUpProtectLgcInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpSwitchInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		/*组备用通道发给车的TSR的信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToIvocBackUpTsrInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpProtectLgcInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		/*组备用通道发给车的状态确认信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToIvocBackUpReqStateInfo(pDataBuf, &ii);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpTsrInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		/*组备用通道发给车的防淹门信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToIvocBackUpFloodInfo(pDataBuf, &ii);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpReqStateInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		/*组备用通道发给车的信号机状态信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToVobcSigInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpFloodInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		/*组备用通道发给车的前车位置信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToIvocHeadTrainInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToVobcSigInfo Error \n", pstVobcToCiDataStru->VobcId);
		}
		
		/*组备用通道发给车的ITE全线切除信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToIvocIteCutInfo(pDataBuf, &ii);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocHeadTrainInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		/*组备用通道发给车的最远未占用逻辑区段信息*/
		if (CI_SUCCESS == chRetVal)
		{
			chRetVal = PackCiToIvocFarNoOccuLogInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId);
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocIteCutInfo Error \n", pstVobcToCiDataStru->VobcId);
		}

		if (CI_SUCCESS == chRetVal)
		{
			/*组包成功*/
		}
		else
		{
			/*发生组包错误*/
			debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocFarNoOccuLogInfo Error \n", pstVobcToCiDataStru->VobcId);
		}
	}

	if (CI_SUCCESS == chRetVal)
	{
		ii += 8U;
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述：组包Ci到Ivoc的ITE切除状态
* 参数说明：const UINT8* dataBuf 数据缓冲区（出参）
*           const UINT16 *dataLength 数据长度（出参）
* 返 回 值：CI_ERROR 0 失败
*			CI_SUCCESS 1 成功
* Modified By LQ 2025.04.15
*/
static UINT8 PackCiToIvocIteCutInfo(UINT8* pDataBuf, UINT16* wDataLength)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 cIteLineCutState = CI_ITE_LINE_CUT_INVALID;/* ITE全线切除状态 */
	UINT16 wAreaIteCutNumIndex = 0U;
	UINT8 cAreaIteCutNum = 0U;  /*区间ITE切除数量*/	
	UINT16* pAreaIteCutId = NULL;  /*区间ITE切除ID数组*/
	UINT8 jj = 0U;	
	ToCiAreaIteCutStruct* pRecvCiAreaIteCut = NULL;  /*相邻联锁发送的区间ITE切除信息*/
	UINT16 kk = 0U;

	if ((NULL != pDataBuf) && (NULL != wDataLength))
	{
		chRetVal = CI_SUCCESS;
		ii = *wDataLength;

		/* 组ITE全线切除状态 */
		cIteLineCutState = GetIteLineCutState();
		if ((CI_ITE_LINE_CUT_VALID == cIteLineCutState) || (CI_ITE_LINE_CUT_INVALID == cIteLineCutState))
		{
			pDataBuf[ii] = cIteLineCutState;
		}
		else
		{
			pDataBuf[ii] = CI_ITE_LINE_CUT_DEFAULT;  /* 组默认值 */
		}
		ii++;

		/*组本地区间ITE切除信息*/
		wAreaIteCutNumIndex = ii;  /*跳过区间ITE切除数量*/
		ii++;
		cAreaIteCutNum = GetLocalAreaIteCutNum();
		pAreaIteCutId = GetLocalAreaIteCutId();

		if ((ALL_AREA_SNOW_SUM_MAX >= cAreaIteCutNum) && (NULL != pAreaIteCutId))
		{
			for (jj = 0U; jj < cAreaIteCutNum; jj++)
			{
				ShortToChar(pAreaIteCutId[jj], &pDataBuf[ii]);  /*组区间ID*/
				ii += 2U;
			}
		}
		else
		{
			chRetVal = CI_ERROR;  /*区间ITE切除数量超限，返回失败*/
			debug_infor_printf((const)"\n PackCiToIvocIteCutInfo: LocalAreaIteCutInfo Error\n");
		}

		/*组相邻联锁发送的区间ITE切除信息*/
		pRecvCiAreaIteCut = GetCiRecvAreaIteCutInfo();
		if (NULL != pRecvCiAreaIteCut)
		{
			for (kk = 0U; kk < CI_COM_CI_MAX_NUM; kk++)
			{
				if (0U != pRecvCiAreaIteCut[kk].cAreaIteCutNum)
				{
					for (jj = 0U; jj < pRecvCiAreaIteCut[kk].cAreaIteCutNum; jj++)
					{
						if (ALL_AREA_SNOW_SUM_MAX > cAreaIteCutNum)
						{
							ShortToChar(pRecvCiAreaIteCut[kk].wAreaIteCutId[jj], &pDataBuf[ii]);  /*组区间ID*/
							ii += 2U;
							cAreaIteCutNum++;
						}
						else
						{
							debug_infor_printf((const)"\n PackCiToIvocIteCutInfo: LocalAreaIteCutNum Error\n");
							chRetVal = CI_ERROR;  /*区间ITE切除数量超限，返回失败*/
							break;
						}
					}
				}
				else
				{
					/*继续遍历*/
				}

				if (CI_SUCCESS != chRetVal)
				{
					break;  /*组包失败，停止组包*/
				}
				else
				{
					/*继续组包*/
				}
			}
		}
		else
		{
			debug_infor_printf((const)"\n PackCiToIvocIteCutInfo: CiRecvAreaIteCutInfo Error\n");
			chRetVal = CI_ERROR;  /*获取数据失败，返回失败*/
		}

		if (CI_SUCCESS == chRetVal)
		{
			pDataBuf[wAreaIteCutNumIndex] = cAreaIteCutNum;  /*组区间ITE切除数量*/
			*wDataLength = ii;  /*传出数据长度*/
		}
		else
		{
			chRetVal = CI_ERROR;  /*组包失败，返回失败*/
		}
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}



/*
* 功能描述：组包Ci到Ivoc的最远未占用逻辑区段
	* 参数说明： UINT8* dataBuf, 数据缓冲区
	*            UINT16 *dataLength, 数据长度 输出参数
	*			 UINT16 wTrainId 列车ID
* 返 回 值：CI_ERROR 0 失败
*			CI_SUCCESS 1 成功
* Created By LC
*/
static UINT8 PackCiToIvocFarNoOccuLogInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT16 farLogSecId = 0U;

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{

		ii = *wDataLength;
		chRetVal = CI_SUCCESS;


		farLogSecId = GetTrainAblNoOccuFarLogId(wTrainId);

		if (LOGIC_SECTION_SUM_MAX > farLogSecId)
		{
			ShortToChar(farLogSecId, &pDataBuf[ii]);
			ii += 2U;
		}
		else if (UINT16_MAX == farLogSecId)
		{
			ShortToChar(UINT16_MAX, &pDataBuf[ii]);
			ii += 2U;
		}
		else
		{
			ShortToChar(0U, &pDataBuf[ii]);
			ii += 2U;
		}
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;

}

/*
* 功能描述：组包Ci到Ivoc的NVRAM位置监督状态
* 参数说明：const UINT8* dataBuf 数据缓冲区（出参）
*           const UINT16 *dataLength 数据长度（出参）
*           const UINT16 wTrainId 列车ID
* 返 回 值：CI_ERROR 0 失败
*			CI_SUCCESS 1 成功
* Created By LQ 2024.08.19
*/
static UINT8 PackCiToIvocPosMonitorInfo(UINT8* pDataBuf, UINT16* wDataLength, const UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 wTrainIndex = 0U;
	UINT16 ii = 0U;
	UINT8 cTrainPosMonitorState = TRAIN_POS_MONITOR_INVALID;  /* 列车位置监督状态 */

	wTrainIndex = GetTrainBufIndex(wTrainId);
	if ((NULL != pDataBuf) && (NULL != wDataLength) && (TRAIN_SUM_MAX > wTrainIndex))
	{
		ii = *wDataLength;

		/* 组列车位置监督状态 */
		cTrainPosMonitorState = GetTrainPosMonitorState(wTrainId);
		if (TRAIN_POS_MONITOR_VALID == cTrainPosMonitorState)
		{
			pDataBuf[ii] = TRAIN_POS_MONITOR_VALID;  /*组监督有效*/
		}
		else if (TRAIN_POS_MONITOR_DIFF == cTrainPosMonitorState)
		{
			pDataBuf[ii] = TRAIN_POS_MONITOR_DIFF;  /* 组监督位置不一致 */
		}
		else
		{
			pDataBuf[ii] = TRAIN_POS_MONITOR_INVALID;  /* 组监督无效 */
		}

		ii++;

		*wDataLength = ii;  /*传出数据长度*/
		chRetVal = CI_SUCCESS;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;
}

/*
* 功能描述： 组联锁到车载飞车宕机数据
* 参数说明： 无
* 返回值  ： 无
* by cgh 20250630
*/
void PackCiToVobcFlyProtectData(void)
{
	UINT8 jj = 0U;
	UINT8 chLineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);
	UINT8 chFlyProtectTrainNum = GetFlyProtectNum(); /*飞车宕机数目*/
	TrainFlyProtectStru* pFlyData = NULL; /*飞车宕机数据*/
	UINT8 cNvramFlyProtectNum = 0U; /*使用NVRAM且位置监督无效的飞车数量*/
	UINT16* pNvramFlyProtectId = NULL;  /*使用NVRAM且位置监督无效的飞车ID*/

	cNvramFlyProtectNum = GetNvramFlyProtectNum();  /*获取使用NVRAM且位置监督无效的飞车数量*/
	pNvramFlyProtectId = GetNvramFlyProtectId();  /*获取使用NVRAM且位置监督无效的飞车ID*/
	if ((LINE_CC == chLineIdentity)
		&& (SHUT_DOWN_TRAIN_NUMMAX > chFlyProtectTrainNum)
		&& (SHUT_DOWN_TRAIN_NUMMAX > cNvramFlyProtectNum) && (NULL != pNvramFlyProtectId))
	{
		/*组飞车宕机的飞车特控报文*/
		for (jj = 0U; jj < chFlyProtectTrainNum; jj++)
		{
			pFlyData = GetFlyProtectData(jj);
			if (NULL != pFlyData)
			{
				PackCiToVobcFlyProtectInfo(pFlyData->wTrainId);
			}
			else
			{
				; /*不组包*/
			}
		}

		/*组飞车不宕机的飞车特控报文*/
		for (jj = 0U; jj < cNvramFlyProtectNum; jj++)
		{
			PackCiToVobcFlyProtectInfo(pNvramFlyProtectId[jj]);
		}
	}
	else
	{
		; /*其它接口无此帧*/
	}
}

/*
* 功能描述：组RC到车载飞车宕机信息
* 参数说明：const UINT16 wTrainId 列车ID
* 返 回 值：无
* Created By LQ 2025.09.15
*/
void PackCiToVobcFlyProtectInfo(const UINT16 wTrainId)
{
	UINT16 wBufIndex = 0U;
	UINT8 ii = 0U;
	UINT8 cszCiToIvocDataBuf[VOBC_TO_CI_DATA_LEN_MAX] = { 0U };/*CI到VOBC组帧数组*/
	UINT16 wDataIndex = 0U; /*组包数据索引*/
	UINT8 chLocalCiId = 0U;  /*本地联锁ID*/
	UINT32 dwCiEtcsId = 0U; /*联锁互联互通编号*/
	UINT32 dwVobcEtcsId = 0U; /*车载互联互通ID*/
	UINT32 dwEmapCheckVer = 0U; /*电子地图数据版本号*/
	UINT8 chTempResult = 0U;/*临时检查结果*/
	UINT32 dwCurCycleNum = 0U; /*当前联锁周期号*/
	UINT32 dwAppCycleTime = 0U;
	UINT32 dwSrcCrntSN = 0U;
	UINT32 dwCiRcvSN = 0U;
	UINT16 wDstDevId = 0U; /*目的设备ID*/

	wBufIndex = GetTrainBufIndex(wTrainId);
	chLocalCiId = GetSystemParaLocalCiId();  /*本地联锁ID*/
	if ((TRAIN_SUM_MAX > wBufIndex) && (0U != chLocalCiId))
	{
		dwCurCycleNum = Get2oo2CurCycleNum(); /*当前联锁周期号*/
		dwAppCycleTime = GetSystemParaAppCycleTime();
		for (ii = 0U; ii < VobcToCiSum; ii++)
		{
			if (VobcToCiDataStru[ii].VobcId == wTrainId)
			{
				break;
			}
			else
			{
				/*继续遍历比较*/
			}
		}

		if (ii == VobcToCiSum)
		{
			; /*没找到当前和该车通信，不组包*/
		}
		else
		{
			/*开始组包*/
			chTempResult = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + chLocalCiId, 0U, &dwCiEtcsId);
			chTempResult &= dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC * 256U) + (UINT8)(VobcToCiDataStru[ii].VobcId), VobcToCiDataStru[ii].vobcLogId, &dwVobcEtcsId);
			chTempResult &= GetCiEmapCheckVer(chLocalCiId, &dwEmapCheckVer, CI_SYSTEM_TYPE_VOBC);

			if (CI_SUCCESS == chTempResult)
			{
				dwSrcCrntSN = GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(VobcToCiDataStru[ii].VobcId));
				dwCiRcvSN = GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(VobcToCiDataStru[ii].VobcId));
				wDataIndex = 0U;

				ShortToChar(IVOC_CI_INTERFACE_INFOTYPE, &cszCiToIvocDataBuf[wDataIndex]);/*接口信息类型*/
				wDataIndex += 2U;
				LongToChar(dwCiEtcsId, &cszCiToIvocDataBuf[wDataIndex]);/*发送方标识信息*/
				wDataIndex += 4U;
				LongToChar(dwVobcEtcsId, &cszCiToIvocDataBuf[wDataIndex]);/*接收方标识信息*/
				wDataIndex += 4U;
				LongToChar(dwEmapCheckVer, &cszCiToIvocDataBuf[wDataIndex]);/*电子地图版本校验信息*/
				wDataIndex += 4U;
				LongToChar(dwCurCycleNum, &cszCiToIvocDataBuf[wDataIndex]);/*本方消息序列号*/
				wDataIndex += 4U;
				ShortToChar((UINT16)dwAppCycleTime, &cszCiToIvocDataBuf[wDataIndex]);/*设备通讯周期*/
				wDataIndex += 2U;
				LongToChar(dwSrcCrntSN, &cszCiToIvocDataBuf[wDataIndex]);/*对方消息序列号：recvOppMsgSN记录收到对方上一条消息中的对方消息序列号*/
				wDataIndex += 4U;
				LongToChar(dwCiRcvSN, &cszCiToIvocDataBuf[wDataIndex]);/*收到上一条消息时本方序列号*/
				wDataIndex += 4U;
				cszCiToIvocDataBuf[wDataIndex] = CI_VOBC_PRTCL_VER;/*HLHT+FAO_CI_VOBC接口协议版本号*/
				wDataIndex++;

				wDataIndex += 2U;/*通用报文头中的应用层报文总长度*/
				/*以下为应用层数据*/
				wDataIndex += 2U;/*报文长度*/
				ShortToChar(CI_IVOC_INFO_TYPE_SPECIAL_CONTROL, &cszCiToIvocDataBuf[wDataIndex]);
				wDataIndex += 2U;/*应用报文类型*/
				wDataIndex += 2U;/*预留两个字节*/

				/*特控报文*/
				cszCiToIvocDataBuf[wDataIndex] = CI_IVOC_LOST_POSITION;
				wDataIndex++;

				/*应用层数据的报文长度 */
				cszCiToIvocDataBuf[31U] = (UINT8)((UINT8)((wDataIndex - 33U) >> 8U) & 0xFFU);
				cszCiToIvocDataBuf[32U] = (UINT8)((wDataIndex - 33U) & 0xFFU);

				/*通用报文头中应用层报文总长度*/
				cszCiToIvocDataBuf[29U] = (UINT8)((UINT8)((wDataIndex - 31U) >> 8U) & 0xFFU);
				cszCiToIvocDataBuf[30U] = (UINT8)((wDataIndex - 31U) & 0xFFU);

				wDstDevId = ((UINT16)(CI_SYSTEM_TYPE_VOBC << 8U) | VobcToCiDataStru[ii].VobcId);
				chTempResult = OutnetSafeSend(wDstDevId, (VobcToCiDataStru[ii].vobcLogId), &cszCiToIvocDataBuf[0], wDataIndex);

				if (1U == chTempResult)
				{ /*写队列成功*/
#ifdef LOGPRINT/*日志打印宏*/                 
#ifdef PLATFORM_2OO2/*2oo2平台打印*/
					debug_infor_printf((const)"\nVOBCFLYPROTECT_SEND:%d vobc:%d", wDataIndex, VobcToCiDataStru[ii].VobcId);
					debug_out_array(0xAA, cszCiToIvocDataBuf, wDataIndex);
#endif/*平台打印结束*/
#endif
				}
				else
				{
					debug_infor_printf((const)"\nWrite VOBC %d FLYPROTECT Error, Len = %d\n", VobcToCiDataStru[ii].VobcId, wDataIndex);
				}
			}
			else
			{
				/*不组包*/
				debug_infor_printf((const)"\nvobc %d PackCiToVobcFlyProtectInfo error，dwCiEtcsId：%d dwVobcEtcsId：%d dwEmapCheckVer：%d \n", VobcToCiDataStru[ii].VobcId, dwCiEtcsId, dwVobcEtcsId, dwEmapCheckVer);
			}
		}
	}
	else
	{
		; /*其它接口无此帧*/
	}

}

/*
* 功能描述：组包Ci到Ivoc的向后跳跃申请回复
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返 回 值：CI_ERROR 0 失败
*			CI_SUCCESS 1 成功
* Create： fan 20250725
*/
UINT8 PackCiToIvocJumpBackReply(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;
	UINT8 chJumpBackReplyState = 0U;
	UINT32 dwJumpBackSn = 0U;

	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{

		ii = *wDataLength;
		chRetVal = CI_SUCCESS;


		chJumpBackReplyState = GetTrainJumpBackReplyState(wTrainId);
		if ((TRAIN_JUMP_BACK_STATE_NONE == chJumpBackReplyState)
			|| (TRAIN_JUMP_BACK_STATE_VALID == chJumpBackReplyState) || (TRAIN_JUMP_BACK_STATE_INVALID == chJumpBackReplyState))
		{
			pDataBuf[ii] = chJumpBackReplyState;
			ii++;

			if (TRAIN_JUMP_BACK_STATE_NONE == chJumpBackReplyState)
			{
				LongToChar(0U, &pDataBuf[ii]);
				ii += 4U;
			}
			else
			{
				/*回复序列号*/
				dwJumpBackSn = GetTrainJumpBackApplySN(wTrainId);
				LongToChar(dwJumpBackSn, &pDataBuf[ii]);
				ii += 4U;
			}
		}
		else
		{
			chRetVal = CI_ERROR;
		}
	}

	if (CI_SUCCESS == chRetVal)
	{
		*wDataLength = ii;
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;

}

/*
* 功能描述：组包Ci到Ivoc未接近开放进路信息(预先开放)
* 参数说明： UINT8* dataBuf, 数据缓冲区
*            UINT16 *dataLength, 数据长度 输出参数
*			 UINT16 wTrainId 列车ID
* 返 回 值：CI_ERROR 0 失败
*			CI_SUCCESS 1 成功
* Create： fan 20251202
*/
UINT8 PackCiToIvocOpenRouteNotNearInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId)
{
	UINT8 chRetVal = CI_ERROR;
	UINT16 ii = 0U;/*存储下标*/
	UINT16 jj = 0U;/*循环下标*/
	UINT8 chYuXianRouteSum = 0U; /*预先开放进路总数*/
	UINT8 chLocalCI= 0U;/*联锁ID*/
	UINT8 chLocalCIType = 0U;/*本联锁类型*/
	UINT16 routeCurSum = 0U; 	/*获取进路总数*/
	UINT16 wRouteNumIndex = 0U;/*进路数量下标*/
	UINT16 routeId = 0U;
	UINT8 routeBelongCiId = 0u;/*进路所属联锁*/
	UINT8 routeState = 0U; /*进路状态*/
	UINT16 wFirstLogSecId = 0U; /*第一逻辑区段*/
	LogicTrainResStruct * pLogicSecTrainResInfo = NULL;/*逻辑区段对应列车资源信息*/
	UINT16 wTrnID = 0U;
	chLocalCI = GetSystemParaLocalCiId();
	chLocalCIType = GetLocalCiType();
	routeCurSum = GetRouteCurSum();
	if ((NULL == pDataBuf) || (NULL == wDataLength))
	{
		chRetVal = CI_ERROR;
	}
	else
	{

		ii = *wDataLength;
		wRouteNumIndex = ii;  /*跳过进路数量*/
		ii++;
		chRetVal = CI_SUCCESS;

		if ((CI_TYPE_ZX == chLocalCIType) || (CI_TYPE_SCX == chLocalCIType))
		{
			for (jj = 0u; jj < routeCurSum; jj++)
			{
				routeId = GetRouteId(jj);                           /*获取进路ID*/
				routeBelongCiId = GetRouteBelongCiId(routeId);           /*获取进路所属联锁ID*/
				routeState = GetRouteState(routeId);
				if ((ROUTE_STATE_YUXIAN_OPEN == routeState) && (routeBelongCiId == chLocalCI))
				{
					/*仅处理本联锁预先开放进路*/
					wFirstLogSecId = GetRouteInFirstLogSecId(routeId);
					wTrnID = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + wTrainId;
					pLogicSecTrainResInfo = GetLogSecTrainInfoById(wFirstLogSecId, wTrnID);
					if (NULL != pLogicSecTrainResInfo)
					{
						/*存在列车资源*/
						ShortToChar(routeId, &pDataBuf[ii]);  /*组进路ID*/
						ii += 2U;
						chYuXianRouteSum++;
						if (CI_IVOC_YUXIANOPEN_ROUTE_MAX < chYuXianRouteSum)
						{
							chRetVal = CI_ERROR;
							break;
						}
						else
						{
							; /*继续*/
						}
					}
					else
					{
						;/*不处理*/
					}
				}
				else
				{
					;/*不处理*/
				}
			}
		}
		else
		{
			chYuXianRouteSum = 0U;/*车辆段发送数量为0*/
		}
	}

	if (CI_SUCCESS == chRetVal)
	{
		pDataBuf[wRouteNumIndex] = chYuXianRouteSum;  /*组预先开放进路数量*/
		*wDataLength = ii;  /*传出数据长度*/
	}
	else
	{
		chRetVal = CI_ERROR;
	}

	return chRetVal;

}