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

#include "ParsePackCommon.h"
#include "../LogicProcess/InterlockLogicCheck.h"
#include "TrainOnAcManage.h"
#include "SignalDataManage.h"
#include "SignalConfigDataManage.h"
#include "SwitchDataManage.h"
#include "SwitchConfigDataManage.h"
#include "PhysicalSectionConfigDataManage.h"
#include "ESBConfigDataManage.h"
#include "PSDConfigDataManage.h"
#include "../Deployment/DeploymentExtern.h"
#include "MSCP_APP_API.h"
#include "ParsePackAtsData.h"
#include "ParsePackOcData.h"
#include "../DataManage/PlatDataManage.h"
#include "dquCIInterFace.h"
#include "NonAutoReturnDataManage.h"

#include "2oo2InterfaceDataManage.h"

PlatHeartDataStruct RecvHeartDataStru = { 0U };  /*平台心跳帧数据结构*/
PlatGPIODataStruct RecvPlatDataStruGPIO = { 0U };/*平台0x2D帧数据结构 GPIO采集状态*/
PlatGPIOToleranceDataStruct gPlatDataGPIOTolercance = { 0U };/*平台硬件采集故障容忍记录数据*/

/*
* 功能描述： 信号机相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*1、zt 2022.02.28 新增信号机异常关闭码位
*/
UINT8 SignalMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT8 returnValue = CI_SUCCESS;/*默认码位处理成功*/
	UINT16 ii = 0u;
	UINT16 statrSigRtSum = 0u;
	UINT16* startSigRouteBuf = NULL;
	UINT16 tmpRtId = 0u;
	UINT8 tmpRtState = 0u;
	UINT8 sigDetainFlag = 0u;/*信号机扣车标志*/
	UINT8 curColor = 0u;/*信号机当前显示颜色*/
	UINT8 getState = 0u;
	UINT8 chZqxFlag = 0U;
	UINT8 chZrjFlag = 0U;
	UINT8  sigEnginVehicCrossCloseSte = 0u;
	UINT8 signalBoardState = 0u;
	UINT8 cancelDetainBtnErrFlag = SIGNAL_ZFS_BTN_ERR_FLAG_NO; /*取消扣车按钮故障标志*/
	UINT8 detainBtnErrFlag = SIGNAL_ZFS_BTN_ERR_FLAG_NO; /*扣车按钮故障标志*/
	UINT8 SignalCrossState = 0U;
	UINT8 SigVobcCrossInPhyOccSta = 0U;
	UINT8 chDsFlag = SIGNAL_DS_BREAK_YES;
	UINT8 CiPattern = 0u;
	UINT8 chDsnLinSwitch = 0U;
	UINT8 cDevState = 0U;

	chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH);
	CiPattern = GetLocalCiPattern();
	switch (MaskType)
	{
	case MASK_TYPE_SIGNAL_RED:/*红灯码位*/
		if ((SIGNAL_SHOWCOLOUR_RED == GetSignalCurColor(DeviceId))

			|| (SIGNAL_SHOWCOLOUR_REDCLOSE == GetSignalCurColor(DeviceId)))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_SIGNAL_YELLOW:/*黄灯码位*/
	{
		if ((SIGNAL_SHOWCOLOUR_YELLOW == GetSignalCurColor(DeviceId))
			|| (SIGNAL_SHOWCOLOUR_YELLOWCLOSE == GetSignalCurColor(DeviceId)))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}

	}
	break;
	case MASK_TYPE_SIGNAL_GREEN:/*绿灯码位*/

		if ((SIGNAL_SHOWCOLOUR_GREEN == GetSignalCurColor(DeviceId))
			|| (SIGNAL_SHOWCOLOUR_GREENCLOSE == GetSignalCurColor(DeviceId)))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}

		break;
	case MASK_TYPE_SIGNAL_REDYELLOW:/*红黄灯码位*/
		if ((SIGNAL_SHOWCOLOUR_REDYELLOW == GetSignalCurColor(DeviceId)) || (SIGNAL_SHOWCOLOUR_RED_WHITE == GetSignalCurColor(DeviceId)))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_SIGNAL_DOUBLE_GREEN:/*双绿码位*/
	{
		if ((SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == GetSignalCurColor(DeviceId)))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
	}
	break;
	case MASK_TYPE_SIGNAL_DOUBLE_YELLOW:/*双黄码位*/
	{
		if ((SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == GetSignalCurColor(DeviceId)))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
	}
	break;
	case MASK_TYPE_SIGNAL_GREEN_YELLOW:/*绿黄码位，显示绿黄或者绿*/
	{
		curColor = GetSignalCurColor(DeviceId);
		if ((SIGNAL_SHOWCOLOUR_GREENYELLOW == curColor) ||
			(SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE == curColor))
		{/*绿黄或绿黄灭，绿黄码位都发1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
	}
	break;
#if 0
	case MASK_TYPE_SIGNAL_BLUE:
		{
			if (1 == sigColorWuhanBlue)
			{
				SetMaskValue(MaskId,dataBuf);
			}
			else
			{

			}
		}
		break;
#endif
	case MASK_TYPE_SIGNAL_WHITE:/*白灯亮灯码位*/
		if (SIGNAL_SHOWCOLOUR_WHITE == GetSignalCurColor(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_SIGNAL_FENGSUO:/*封锁码位*/
		if (SIGNAL_FENGSUO_NO == GetSignalFLockState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_SIGNAL_CLOSE_ABNORMAL:/*异常关闭码位*/
		/*遍历以该信号机为始端信号机的进路，有一条进路状态为接近锁闭异常、预先锁闭、初锁异常则发送1*/
		statrSigRtSum = GetStartSignalRouteSum(DeviceId);/*获取以该信号机为始端信号机的进路数目*/
		startSigRouteBuf = GetStartSignalRouteBuf(DeviceId);/*获取以该信号机为始端信号机的进路数组*/
		if (0u != statrSigRtSum)
		{
			for (ii = 0u; ii < statrSigRtSum; ii++)
			{
				tmpRtId = startSigRouteBuf[ii];
				tmpRtState = GetRouteState(tmpRtId);/*获取进路状态*/
				if ((ROUTE_STATE_NEAR_LOCKERR == tmpRtState)
					|| (ROUTE_STATE_YUXIAN_LOCK == tmpRtState)
					|| (ROUTE_STATE_FIRST_LOCKERR == tmpRtState)
					|| (ROUTE_STATE_LEAD_LOCKERR == tmpRtState)
					|| (ROUTE_STATE_AUTO_UNLOCKERR == tmpRtState)
					|| (ROUTE_STATE_DELAY_UNLOCK == tmpRtState))
				{/*进路状态为接近锁闭异常、预先锁闭、初锁异常*/
					curColor = GetSignalCurColor(DeviceId);
					getState = GetSignalOpenCloseState(curColor);
					chZqxFlag = GetRouteZongQuXiaoFlag(tmpRtId);
					chZrjFlag = GetRouteZongRenJieFlag(tmpRtId);
					if ((SIGNAL_OPEN != getState)
						&& (ROUTE_ZONGQUXIAO_SET_NO == chZqxFlag)
						&& (ROUTE_ZONGRENJIE_SET_NO == chZrjFlag))
					{
						SetMaskValue(MaskId, dataBuf);
					}
					else
					{
						;
					}
					break;
				}
			}
		}
		break;
	case MASK_TYPE_SIGNAL_OPENSTATE:/*CI-ZC码位，开放状态码位，根据接口说明书，引导进路发送0 */
#if 0
		if ((SIGNAL_OPEN == GetSignalOpenCloseState(GetSignalCurColor(DeviceId)))
			&& (SIGNAL_SHOWCOLOUR_REDYELLOW != GetSignalCurColor(DeviceId)))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
#endif
		/*遍历以该信号机为始端信号机的进路，有一条进路状态为预先开放或接近开放则发送1*/
		statrSigRtSum = GetStartSignalRouteSum(DeviceId);/*获取以该信号机为始端信号机的进路数目*/
		startSigRouteBuf = GetStartSignalRouteBuf(DeviceId);/*获取以该信号机为始端信号机的进路数组*/
		if (0u != statrSigRtSum)
		{
			for (ii = 0u; ii < statrSigRtSum; ii++)
			{/*查找以信号机为始端信号机的开放的进路ID*/
				tmpRtId = startSigRouteBuf[ii];
				tmpRtState = GetRouteState(tmpRtId);/*获取进路状态*/
				if ((ROUTE_STATE_YUXIAN_OPEN == tmpRtState) || (ROUTE_STATE_NEAR_OPEN == tmpRtState))
				{/*找到开放的进路则发送开放码位*/
					SetMaskValue(MaskId, dataBuf);
					break;
				}
			}
		}
		break;
	case MASK_ZC_CI_TYPE_SIGNAL_OCCUPYED:/*通信车跨压通过信号机状态码位*/
		if (SIGNAL_CROSS_STATE_YES == GetSignalCrossState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_CI_ZC_SIGNAL_OCCUPYED_REC:/*CI-ZC跨压信号机状态接收确认码位*/
		SignalCrossState = GetSignalCrossState(DeviceId);
		SigVobcCrossInPhyOccSta = GetSigVobcCrossInPhyOccSta(DeviceId);
		if ((SIGNAL_CROSS_STATE_YES == SignalCrossState) && (SECTION_OCCUPY_YES == SigVobcCrossInPhyOccSta))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_SIGNAL_LIGHTSTATE:/*信号机亮灭状态码位*/
		if ((SIGNAL_SHOWCOLOUR_REDCLOSE == GetSignalCurColor(DeviceId))
			|| (SIGNAL_SHOWCOLOUR_GREENCLOSE == GetSignalCurColor(DeviceId))
			|| (SIGNAL_SHOWCOLOUR_YELLOWCLOSE == GetSignalCurColor(DeviceId))
			|| (SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE == GetSignalCurColor(DeviceId))
			)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_SIGNAL_BREAK:/*信号机断丝码位*/
		if ((CI_PATTERN_FULL_ELECTRONIC == CiPattern) && (FUNC_SWITCH_OFF == chDsnLinSwitch))/*全电子联锁*/
		{
			getState = GetSignalCurColor(DeviceId); /*OC通信中断未设置断丝标志但信号机颜色为红断*/
			chDsFlag = GetSignalDsBreakFlag(DeviceId);
			if ((SIGNAL_DS_BREAK_YES == chDsFlag)||(SIGNAL_SHOWCOLOUR_REDBREAK == getState))
			{
				; /*0为断丝*/
			}
			else
			{
				SetMaskValue(MaskId, dataBuf);
			}
		}
		else
		{
			getState = GetSignalCurColor(DeviceId);
			if (SIGNAL_SHOWCOLOUR_REDBREAK == getState)
			{
				; /*0断丝*/
			}
			else
			{
				SetMaskValue(MaskId, dataBuf);
			}
		}
		break;
	case MASK_TYPE_SIGNAL_GREENBREAK:/*信号机断丝码位*/
		chDsFlag = GetSignalGreenDsBreakFlag(DeviceId);
		if (SIGNAL_DS_BREAK_YES== chDsFlag)
		{
			; /*0为断丝*/
		}
		else
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_SIGNAL_YELLOWBREAK:/*信号机断丝码位*/
		chDsFlag = GetSignalYellowDsBreakFlag(DeviceId);
		if (SIGNAL_DS_BREAK_YES == chDsFlag)
		{
			; /*0为断丝*/
		}
		else
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_SIGNAL_WHITEBREAK:/*信号机断丝码位*/
		chDsFlag = GetSignalWhiteDsBreakFlag(DeviceId);
		if (SIGNAL_DS_BREAK_YES == chDsFlag)
		{
			; /*0为断丝*/
		}
		else
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_SIGNAL_BLUEBREAK:/*信号机断丝码位*/
		chDsFlag = GetSignalBlueDsBreakFlag(DeviceId);
		if (SIGNAL_DS_BREAK_YES == chDsFlag)
		{
			; /*0为断丝*/
		}
		else
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_SIGNAL_CENTER_DETAIN:/*中心人工扣车码位*/
		sigDetainFlag = GetSignalATSDetainFlag(DeviceId);/*获取信号机扣车标志*/
		if ((SIGNAL_ATS_DETAIN_NO == sigDetainFlag)|| (SIGNAL_ATS_DETAIN_AUTO_YES == sigDetainFlag))
		{
			/*未中心扣车,发1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*中心扣车,发0*/
		}
		break;
	case MASK_TYPE_SIGNAL_AUTO_DERAIN:/*中心自动扣车码位*/
		sigDetainFlag = GetSignalATSDetainFlag(DeviceId);/*获取信号机扣车标志*/
		if ((SIGNAL_ATS_DETAIN_NO == sigDetainFlag)|| (SIGNAL_ATS_DETAIN_YES == sigDetainFlag))
		{
			/*未自动扣车,发1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*自动扣车,发0*/
		}
		break;
	case MASK_TYPE_SIGNAL_LOCAL_DETAIN:/*车站扣车码位*/
		sigDetainFlag = GetSignalLocalDetainFlag(DeviceId);/*获取信号机扣车标志*/
		if (SIGNAL_XIANDI_DETAIN_NO == sigDetainFlag)
		{
			/*未车站扣车,发1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*车站扣车,发0*/
		}
		break;
	case MASK_TYPE_SIGNAL_RELAY_DETAIN:/*硬线扣车码位*/
		sigDetainFlag = GetSignalRelayDetainFlag(DeviceId);/*获取信号机硬线扣车标志*/
		if (SIGNAL_RELAY_DETAIN_NO == sigDetainFlag)
		{
			/*未硬线扣车,发1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*硬线扣车,发0*/
		}
		break;
	case MASK_TYPE_SIGNAL_LINSHIXIANSU_SET:/*信号机临时限速设置码位*/
		if (SIGNAL_LINSHIXIANSUSET_STATE_YES == GetSignalLinShiXianSuSetFlag(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_SIGNAL_MAINTAINSTATE:/*CI-ATS信号机维修点灯状态码位*/
		getState = GetSignalMaintainState(DeviceId);
		if (MAINTAIN_STATE_YES == getState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_CI_ZC_SIG_ENGINCROSS_STE:/*CI-ZC 工程车跨压关灯码位*/
		sigEnginVehicCrossCloseSte = GetSigEnginVehicCrossCloseSte(DeviceId);
		if (ENGIN_VEHIC_CROSSCLOSE_STE_YES == sigEnginVehicCrossCloseSte)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*发0*/
		}
		break;
	case MASK_ZC_CI_SIG_ENGINEERV_NEAR:/*ZC-CI 工程车接近码位*/
		break;
	case MASK_TYPE_SIGNAL_OC_BOARD_FAULT: /*CI-ATS OC信号机板卡故障报警码位-WGY*/
		signalBoardState = GetSignalBoardState(DeviceId);
		if (OC_SIGNAL_BOARD_FAULT_YES == signalBoardState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*发0*/
		}
		break;
	case MASK_TYPE_SIGNAL_CANCEL_DET_ERR:
		cancelDetainBtnErrFlag = GetSignalCancelDetainBtnErrFlag(DeviceId);
		if (SIGNAL_ZFS_BTN_ERR_FLAG_YES == cancelDetainBtnErrFlag)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*码位值发0*/
		}
		break;
	case MASK_TYPE_SIGNAL_DET_ERR:
		detainBtnErrFlag = GetSignalDetainBtnErrFlag(DeviceId);
		if (SIGNAL_ZFS_BTN_ERR_FLAG_YES == detainBtnErrFlag)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*码位值发0*/
		}
		break;
	case MASK_TYPE_SIGNAL_DET_CUT_VALID:
		cDevState = GetDetCutBtnState(DeviceId);
		if (SIGNAL_DETAIN_CUT_VALID_YES == cDevState)
		{
			SetMaskValue(MaskId, dataBuf);  /*扣车旁路按钮有效，码位值发1*/
		}
		else
		{
			/*扣车旁路按钮无效，码位值发0*/
		}
		break;
	case MASK_TYPE_SIGNAL_DET_CUT_ERR:
		cDevState = GetSignalDetCutBtnErrFlag(DeviceId);
		if (SIGNAL_ZFS_BTN_ERR_FLAG_YES == cDevState)
		{
			SetMaskValue(MaskId, dataBuf);  /*扣车旁路按钮故障，码位值发1*/
		}
		else
		{
			/*扣车旁路按钮未故障，码位值发0*/
		}
		break;
	default:
		returnValue = CI_ERROR;
		break;
	}

	return returnValue;
}

/*
* 功能描述： 道岔相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*/
UINT8 SwitchMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT8 returnValue = CI_SUCCESS;/*返回值默认成功*/
	UINT8 switchLockStatus = 0U;
	UINT8 switchCurPosition = 0U;
	UINT8 switchLockState = 0U;
	UINT8 switchConnectDsState = 0U;
	UINT8 switchByPassState = 0U;
	UINT16 i = 0U;
	UINT8 k = 0U;
	UINT8 flagFind = 0U;
	UINT16 indexFind = 0U;
	UINT8 devBelongThisLine = 0U;
	UINT8 switchBoardNum = 0U;
	UINT8 switchStateCheck = CI_ERROR;

	switchLockStatus = GetSwitchLockStatus(DeviceId);

	switch (MaskType)
	{
	case MASK_TYPE_SWITCH_DINGWEI:
		/*定位码位*/
		switchCurPosition = GetSingleSwitchCurPosition(DeviceId);
		if (SWITCH_POSITION_DINGWEI == switchCurPosition)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_SWITCH_FANWEI:
		/*反位码位*/
		switchCurPosition = GetSingleSwitchCurPosition(DeviceId);
		if (SWITCH_POSITION_FANWEI == switchCurPosition)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_SWITCH_DINGWEI_LOGIC:
		/*定位逻辑码位*/
		switchCurPosition = GetSwitchCurPosition(DeviceId);
		if (SWITCH_POSITION_DINGWEI == switchCurPosition)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_SWITCH_FANWEI_LOGIC:
		/*反位逻辑码位*/
		switchCurPosition = GetSwitchCurPosition(DeviceId);
		if (SWITCH_POSITION_FANWEI == switchCurPosition)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_SWITCH_MOVING:
		/*移动码位*/
		switchCurPosition = GetSingleSwitchCurPosition(DeviceId);
		if (SWITCH_POSITION_MOVE == switchCurPosition)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_SWITCH_SIKAI:
		/*四开码位*/
		switchCurPosition = GetSingleSwitchCurPosition(DeviceId);
		if (SWITCH_POSITION_SIKAI == switchCurPosition)
		{

		}
		else
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_SWITCH_DYNAMIC_JICHA:
		/*动态红闪码位*/
		switchCurPosition = GetSwitchJichaState(DeviceId);

		if (SWITCH_POSITION_DYNAMIC_JICHA == switchCurPosition)
		{
			; /*有效值为0*/
		}
		else
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_SWITCH_DANSUO:
		/*单锁码位*/
		devBelongThisLine = GetSwitchIsThisLineState(DeviceId);
		if (DEV_IS_THIS_LINE_YES == devBelongThisLine)
		{
			switchConnectDsState = GetConnetSwitchDsState(DeviceId);
			if ((SWITCH_LOCK_STATUS_NO == switchLockStatus) || (SWITCH_LOCK_STATUS_PROTECT == switchLockStatus))
			{
				SetMaskValue(MaskId, dataBuf);
			}
			else
			{
			}
		}
		else
		{
			switchConnectDsState = GetConnetSwitchDsState(DeviceId);
			if (((SWITCH_LOCK_STATUS_NO == switchLockStatus) || (SWITCH_LOCK_STATUS_PROTECT == switchLockStatus))
				&& (CONNECT_SWITCH_DANSUO_NO == switchConnectDsState))
			{
				SetMaskValue(MaskId, dataBuf);
			}
			else
			{
			}
		}

		break;
	case MASK_TYPE_SWITCH_FENGSUO:
		/*封锁码位*/
		switchLockState = GetSwitchFLockState(DeviceId);
		if (SWITCH_LOCK_FENGSUO_NO == switchLockState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_SWITCH_YINDAOSUO:
		/*引导总锁码位*/
		switchLockState = GetSwitchYLockState(DeviceId);
		if (SWITCH_LOCK_YINZONG_NO == switchLockState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_SWITCH_PROTECTLOCK:
		/*防护锁闭码位*/
		if ((SWITCH_LOCK_STATUS_NO == switchLockStatus) || (SWITCH_LOCK_STATUS_DANSUO == switchLockStatus))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_SWITCH_LOCKSTATE:
		/*锁闭状态码位*/
		switchLockState = GetSwitchRouteLockState(DeviceId);
		if (CI_SUCCESS == switchLockState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_SWITCH_BYPASS:
		switchByPassState = GetConnetSwitchByPassState(DeviceId);
		if (SWITCH_BYPASS_YES == switchByPassState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_SWITCH_OPEN_CAP:
		for (i = 0u; i < m_SwitchNum; i++)
		{
			if (m_Switches[i].DeviceId == DeviceId)
			{
				flagFind = 1u;
				indexFind = i;
				break;
			}
		}
		if (1u == flagFind)
		{
			/*板卡状态有一系是开盖状态*/
			switchBoardNum = m_Switches[indexFind].BoardNum;
			for (k = 0u; k < switchBoardNum; k++)
			{
				if (OC_SWITCH_OPEN_CAP_STATE == (m_Switches[indexFind].BoardState[k] & OC_SWITCH_OPEN_CAP_STATE))
				{
					SetMaskValue(MaskId, dataBuf);
					break;
				}
				else
				{
					; /*继续检查*/					
				}
			}
		}
		break;
	case MASK_TYPE_SWITCH_SUDDEN_JICHA:
		/*道岔静态红闪码位*/
		switchCurPosition = GetSwitchJichaState(DeviceId);

		if (SWITCH_POSITION_SUDDEN_JICHA == switchCurPosition)
		{
			; /*有效值为0*/
		}
		else
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_SWITCH_JICHA:
		/*道岔静态红闪或动态红闪码位: 兼容28.0.0.14数据结构使用*/
		switchCurPosition = GetSwitchJichaState(DeviceId);
		if ((SWITCH_POSITION_SUDDEN_JICHA == switchCurPosition)|| (SWITCH_POSITION_DYNAMIC_JICHA == switchCurPosition))
		{
			; /*有效值为0*/
		}
		else
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	default:
		returnValue = CI_ERROR;
		break;
	}

	return returnValue;
}

/*
* 功能描述： 物理区段相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*/
UINT8 PhySectionMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT8 returnValue = CI_SUCCESS;/*返回值默认成功*/
	UINT8 localCiType = GetLocalCiType();  /*联锁类型*/
	UINT8 lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);  /*线路类型*/
	UINT16 phyId = 0u;
	UINT8 swSum = 0u;
	UINT8 switchCurPosition = 0u;
	AxisSwitchStruct* axisSwitchStru = NULL;
	UINT8 swPosRight = 1u;/*0错误 1正确*/
	UINT8 iIndex = 0u;
	UINT8 physecPreResetSta = PHYSICAL_SECTION_PRE_RESET_NO; /*计轴预复位状态临时变量*/
	UINT8 jumpState = 0u;/*跳跃锁闭状态*/
	UINT8 funcSwitchJumpLockDriveSwitch = 0u;/*功能开关：跳跃锁闭是否驱道岔*/
	UINT8 lockDir = 0u;/*锁闭方向*/
	UINT8 lockState = 0u;/*锁闭状态*/
	UINT16 routeLockBelongRouteID = 0u;/*进路锁闭所属进路ID*/
	UINT16 protectLockBelongRouteID = 0u;/*防护锁闭所属进路ID*/
	UINT16 phySecId = 0u;/*物理区段ID*/
	UINT8 haveDirChangeInRoute = 0u;
	UINT8 shouldOppose = 0u;/*是否应该取反*/
	UINT8 phySecState = 0u;
	UINT8 phySecLockType = 0u;
	UINT8 phySecLockState = 0u;
	UINT8 phyIntruSecVainCheck = 0u;
	UINT8 routeAutoSigProperty = 0u;
	UINT16 phySecPLockBelongRouteId = 0u;
	UINT8 phySecStopSteadyFlag = 0u;
	UINT8 chPhyFree = CI_ERROR;
	UINT8 gdDLline = 0u;  /*线路是否采用轨道电路*/
	funcSwitchJumpLockDriveSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_JUMPLOCK_DRIVE_SWITCH);
	/*判断是否采用轨道电路*/
	gdDLline = GetCiFunctionSwitchConfig(FUNC_CLD_GD_DIANLU_LINE);

	switch (MaskType)
	{
	case MASK_TYPE_PHYSECTION_OCCUPY:
		/*占用码位*/
		phySecState = GetPhySecCurOccupyState(DeviceId);
		if (SECTION_OCCUPY_NO == phySecState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_PHYSECTION_STARTLOCK:
		/*物理区段上电锁闭状态*/
		phySecState = GetPhySecLockState(DeviceId);
		if (PHYSICAL_SECTION_LOCK_START == phySecState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_PHYSECTION_ROUTELOCK:
		/*物理区段进路锁闭状态*/
		phySecLockState = GetPhySecLockState(DeviceId);
		localCiType = GetLocalCiType();
		phyIntruSecVainCheck = PhysicalIntruSecVainCheck(DeviceId);
		if (((PHYSICAL_SECTION_LOCK_NORMAL == phySecLockState) ||
			(PHYSICAL_SECTION_LOCK_DELAY == phySecLockState) ||
			(PHYSICAL_SECTION_LOCK_FAULTDELAY == phySecLockState) ||
			((PHYSICAL_SECTION_LOCK_EXCEPT == phySecLockState) && (CI_TYPE_CLD == localCiType)))
			&& (CI_SUCCESS == phyIntruSecVainCheck))
		{/*正常锁闭或延时解锁或区故解延时,车辆段且异常锁闭也发送锁闭状态,当该区段对应的侵限条件成立，则向ZC发送未锁闭，20190308*/

			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_PHYSECTION_ROUTELOCK_SHOW:
		/*物理区段进路锁闭显示状态(ATS/现地使用)*/
		phySecLockState = GetPhySecLockState(DeviceId);
		if ((PHYSICAL_SECTION_LOCK_NORMAL == phySecLockState) ||
			(PHYSICAL_SECTION_LOCK_DELAY == phySecLockState) ||
			(PHYSICAL_SECTION_LOCK_FAULTDELAY == phySecLockState))
		{/*正常锁闭或延时解锁或区故解延时*/
			routeAutoSigProperty = GetRouteAutoSigProperty(GetPhySecRLockBelongRouteId(DeviceId));
			if (ROUTE_AUTOSIG_PROPERTY_YES == routeAutoSigProperty)
			{

			}
			else
			{
				SetMaskValue(MaskId, dataBuf);
			}

		}
		else
		{

		}
		break;
	case MASK_TYPE_PHYSECTION_PROTECTLOCK:
		/*物理区段防护进路锁闭状态*/
		/*若跳跃锁闭，则CI->ATS/现地不发送保护区段锁闭*/
		phySecLockState = GetPhySecJumpLockState(DeviceId);
		if (PHYSICAL_SECTION_JUMP_LOCK_YES != phySecLockState)
		{
			phySecPLockBelongRouteId = GetPhySecPLockBelongRouteId(DeviceId);
			if (0u != phySecPLockBelongRouteId)
			{
				routeAutoSigProperty = GetRouteAutoSigProperty(GetPhySecPLockBelongRouteId(DeviceId));
				if (ROUTE_AUTOSIG_PROPERTY_YES == routeAutoSigProperty)
				{/*自动信号的保护区段不发送码位*/
				}
				else
				{
					SetMaskValue(MaskId, dataBuf);/*20190904修改逻辑不判断是否进路锁闭，只要有防护锁闭就发码位*/
				}
			}
		}
		else
		{

		}
		break;
	case MASK_TYPE_PHYSECTION_FAULTLOCK:
		/*物理区段故障锁闭状态*/
		phySecState = GetPhySecLockState(DeviceId);
		if (PHYSICAL_SECTION_LOCK_EXCEPT == phySecState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_PHYSECTION_HEAD_XTD:
		/*物理区段下行状态*/
		phySecId = DeviceId;
		lockDir = GetPhySecLockDirection(phySecId);
		lockState = GetPhySecLockState(phySecId);
		routeLockBelongRouteID = GetPhySecRLockBelongRouteId(phySecId);/*获取进路锁闭所属进路ID*/
		protectLockBelongRouteID = GetPhySecPLockBelongRouteId(phySecId);/*获取防护锁闭所属进路ID*/

		if (CI_SYSTEM_DIRECTION_NONE != lockDir)
		{/*锁闭方向有效*/
			if (0U < routeLockBelongRouteID)
			{
				/*有进路锁闭*//*是否应该取反*/
				haveDirChangeInRoute = GetRouteHaveDirChangePointIn(routeLockBelongRouteID);
				shouldOppose = GetRoutePhySecShouldLockOppose(routeLockBelongRouteID, phySecId);

				if (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInRoute)
				{
					/*进路内有方向变化点*/
					if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == shouldOppose)
					{
						/*应该取反*/
						if (CI_SYSTEM_DIRECTION_UP == lockDir)
						{
							lockDir = CI_SYSTEM_DIRECTION_DOWN;/*之前按上行锁闭的，取反*/
						}
						else if (CI_SYSTEM_DIRECTION_DOWN == lockDir)
						{
							lockDir = CI_SYSTEM_DIRECTION_UP;/*锁闭方向取反*/
						}
						else
						{
							; /*不会执行到这*/
						}
					}
					else
					{
						; /*不应取反,之前锁闭是啥，就是啥*/
					}
				}
			}
			else if ((0U == routeLockBelongRouteID) && (0U < protectLockBelongRouteID))
			{
				; /*没有进路锁闭，有防护锁闭,防护锁闭状态已在设置保护区段锁闭方向时考虑过为实际锁闭方向，这里不再转换*/
			}
			else
			{
				; /*既没有进路锁闭，也没有防护锁闭，不转换*/
			}
		}
		if ((CI_SYSTEM_DIRECTION_DOWN == lockDir) ||
			((PHYSICAL_SECTION_LOCK_EXCEPT == lockState) &&
				(((LINE_FAO == lineIdentity) || (LINE_HLHT == lineIdentity) || (LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity)|| (LINE_FAOHLHT_ONESELFSECOND == lineIdentity))
					&& ((CI_TYPE_CLD == localCiType) && (FUNC_SWITCH_ON == gdDLline)))))
		{
			/*区段锁闭方向为下行或FAO线路的车辆段使用轨道电路时物理区段异常锁闭发送上下行状态均有效*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_PHYSECTION_HEAD_STD:
		/*物理区段上行状态*/
		phySecId = DeviceId;
		lockDir = GetPhySecLockDirection(phySecId);
		lockState = GetPhySecLockState(phySecId);

		routeLockBelongRouteID = GetPhySecRLockBelongRouteId(phySecId);/*获取进路锁闭所属进路ID*/
		protectLockBelongRouteID = GetPhySecPLockBelongRouteId(phySecId);/*获取防护锁闭所属进路ID*/

		if (CI_SYSTEM_DIRECTION_NONE != lockDir)
		{/*锁闭方向有效*/
			if (0U < routeLockBelongRouteID)/*有进路锁闭*/
			{
				haveDirChangeInRoute = GetRouteHaveDirChangePointIn(routeLockBelongRouteID);
				shouldOppose = GetRoutePhySecShouldLockOppose(routeLockBelongRouteID, phySecId);/*是否应该取反*/
				if (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInRoute)
				{
					/*进路内有方向变化点*/
					if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == shouldOppose)
					{
						/*应该取反*/
						if (CI_SYSTEM_DIRECTION_UP == lockDir)
						{
							lockDir = CI_SYSTEM_DIRECTION_DOWN;/*之前按上行锁闭的，取反*/
						}
						else if (CI_SYSTEM_DIRECTION_DOWN == lockDir)
						{
							lockDir = CI_SYSTEM_DIRECTION_UP;/*锁闭方向取反*/
						}
						else
						{
							; /*不会执行到这*/
						}
					}
					else
					{
						; /*不应取反,之前锁闭是啥，就是啥*/
					}
				}
			}
			else if ((0U == routeLockBelongRouteID) && (0u < protectLockBelongRouteID))
			{
				; /*没有进路锁闭，有防护锁闭,防护锁闭状态已在设置保护区段锁闭方向时考虑过为实际锁闭方向，这里不再转换*/
			}
			else
			{
				; /*既没有进路锁闭，也没用防护锁闭，不*/
			}
		}
		localCiType = GetLocalCiType();
		if ((CI_SYSTEM_DIRECTION_UP == lockDir) ||
			((PHYSICAL_SECTION_LOCK_EXCEPT == lockState) &&
				(((LINE_FAO == lineIdentity) || (LINE_HLHT == lineIdentity) || (LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity))
					&& ((CI_TYPE_CLD == localCiType) && (FUNC_SWITCH_ON == gdDLline)))))
		{
			/*区段锁闭方向为上行或FAO线路的车辆段使用轨道电路时物理区段异常锁闭发送上下行状态均有效*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_AXISSECTION_ARB:
		/*计轴区段ARB状态码位*/
		phySecState = GetPhySecArbState(DeviceId);
		if (AXIS_SECTION_ARB_YES == phySecState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_LIECHE_STOPSTATE:
		/*列车停稳信息状态码位*/
		phySecStopSteadyFlag = GetPhySecStopSteadyFlag(DeviceId);
		if (PHYSICAL_SECTION_STOPSTEADY_YES == phySecStopSteadyFlag)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_PHYSECTION_FLOCK:
		/*封锁状态码位(ATS设置) 封锁发0 未封锁以及SPKS命令封锁发1*/
		phySecState = GetPhySecFLockState(DeviceId);
		if (PHYSICAL_SECTION_FLOCK_NO != phySecState)
		{
			phySecLockType = GetPhySecFLockType(DeviceId);
			if (PHY_SEC_FLOCK_TYPE_SPKS != phySecLockType)
			{
				/*除了SPKS封锁  都发0*/
			}
			else
			{
				/*SPKS命令的封锁 发1*/
				SetMaskValue(MaskId, dataBuf);
			}
		}
		else
		{
			/*未封锁 发1*/
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_PHYSEC_FLOCK_SPKS:
		/*封锁状态码位(SPKS开关设置  封锁发0 未封锁以及ATS封锁发1*/
		phySecState = GetPhySecFLockState(DeviceId);
		if (PHYSICAL_SECTION_FLOCK_NO != phySecState)
		{
			phySecLockType = GetPhySecFLockType(DeviceId);
			if (PHY_SEC_FLOCK_TYPE_CMD != phySecLockType)
			{
				/*除了ATS封锁  都发0*/
			}
			else
			{
				/*只有ATS命令的封锁 发1*/
				SetMaskValue(MaskId, dataBuf);
			}
		}
		else
		{
			/*未封锁 发1*/
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_PHYSECTION_JUMPLOCK:
		/*物理区段跳跃锁闭状态码位*/
		jumpState = GetPhySecJumpLockState(DeviceId);
		if (PHYSICAL_SECTION_JUMP_LOCK_YES == jumpState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}

		break;
	case MASK_TYPE_PHYSECTION_JUMPLOCK_ZC:
		/*物理区段跳跃锁闭状态码位--ZC;只发ZC道岔位置正确的计轴区段跳跃锁闭*/
		swSum = GetAxisSwitchSum(DeviceId);
		axisSwitchStru = GetAxisSwitchIdStru(DeviceId);
		if ((0U != swSum) && (NULL != axisSwitchStru))
		{
			for (iIndex = 0U; iIndex < swSum; iIndex++)
			{
				switchCurPosition = GetSwitchCurPosition(axisSwitchStru[iIndex].SwitchId);
				if (axisSwitchStru[iIndex].SwitchPosition == switchCurPosition)
				{
					; /*位置正确，继续检查*/
				}
				else
				{
					swPosRight = 0U;/*道岔位置错误*/
				}
			}
		}
		if (1U == swPosRight)
		{
			phyId = GetAxisSecRelativePhySecId(DeviceId);/*计轴区段id转换成物理区段id*/
			jumpState = GetPhySecJumpLockStateToZC(phyId);

			if (PHYSICAL_SECTION_JUMP_LOCK_YES == jumpState)
			{
				SetMaskValue(MaskId, dataBuf);
			}
			else
			{
				/*不处理，发0*/
			}
		}
		break;

	case MASK_TYPE_PHYSECTION_PRERESET:
		/*物理区段预复位状态码位*/
		physecPreResetSta = GetPhySecPreResetState(DeviceId);
		if (PHYSICAL_SECTION_PRE_RESET_YES == physecPreResetSta)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;

	case MASK_TYPE_PHYSECTION_UT_OCC:
		/* 物理区段故障占用码位 */
		chPhyFree = IsPhyFree(DeviceId);
		if (CI_SUCCESS == chPhyFree)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			;
		}
		break;

	default:
		returnValue = CI_ERROR;
		break;
	}

	return returnValue;
}

/*
* 功能描述： 逻辑区段相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*/
UINT8 LogicSectionMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT8 returnValue = CI_SUCCESS;/*返回值默认成功*/
	UINT8 logLockState = 0U;
	UINT8 routeAutoSigProperty = 0U;
	UINT16 logLockBelongRoute = 0U;/*逻辑区段锁闭所属进路*/
	UINT16 logProtectLockRoute = 0U;/*逻辑区段防护锁闭所属进路*/
	UINT8 chJumpLockState = 0U;/*逻辑区段锁闭状态*/
	UINT8 cLogArbState = 0U;	/* 逻辑区段ARB状态 */
	UINT8 chLogSecLockDirOpposedFlag = CI_ERROR;/*逻辑区段锁闭方向是否取反标志*/
	UINT8 cLogSpksFlockState = 0U;	/* 逻辑区段SPKS封锁状态 */
	UINT8 cLogSecLogicLockState = LOG_SECTION_LOCK_NO;  /*逻辑区段逻辑锁闭状态*/
	UINT8 cLogSecLockDir = CI_SYSTEM_DIRECTION_NONE;  /*逻辑区段锁闭方向*/
	UINT8 chLogSecBelLogRouteSum = 0U;/*逻辑区段所属逻辑进路数目*/

	switch (MaskType)
	{
	case MASK_TYPE_LOGICSECTION_UTOCCUPY:
		/*逻辑区段非通信车占用码位*/
		if ((LOGICSECTION_OCCUPY_CT == GetLogSecCurCtOrUtOccupyState(DeviceId))
			|| (LOGICSECTION_OCCUPY_NO == GetLogSecCurCtOrUtOccupyState(DeviceId)))
		{
			/*通信车占用或无车占用 该码位填1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_LOGICSECTION_CTOCCUPY:
		/*逻辑区段通信车占用码位*/
		if ((LOGICSECTION_OCCUPY_UT == GetLogSecCurCtOrUtOccupyState(DeviceId))
			|| (LOGICSECTION_OCCUPY_NO == GetLogSecCurCtOrUtOccupyState(DeviceId)))
		{
			/*非通信车占用或无车占用 该码位填1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_LOGICSECTION_LINSHIXIANSU_SET:
		/*逻辑区段临时限速设置码位*/
		if (LOGSEC_LSXS_SET_STATE_YES == GetLogSecLinShiXianSuSetState(DeviceId))
		{
			/*逻辑区段设置了临时限速，该码位填1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
		/*逻辑区段进路锁闭码位*/
	case MASK_TYPE_LOGICSECTION_ROUTELOCK:
		logLockState = GetLogSecLockState(DeviceId);
		cLogSecLogicLockState = GetLogSecLogLockState(DeviceId);
		/*逻辑区段正常锁闭或延时锁闭或逻辑正常锁闭*/
		if ((LOG_SECTION_LOCK_NORMAL == logLockState) || (LOG_SECTION_LOCK_DELAY == logLockState) || (LOG_SECTION_LOGLOCK_NORMAL == cLogSecLogicLockState))
		{
			logLockBelongRoute = GetLogSecLockBelongRoute(DeviceId);
			routeAutoSigProperty = GetRouteAutoSigProperty(logLockBelongRoute);
			/*自动信号*/
			if (ROUTE_AUTOSIG_PROPERTY_YES == routeAutoSigProperty)
			{
				/*不填*/
			}
			else
			{
				/*设置码位为1*/
				SetMaskValue(MaskId, dataBuf);
			}
		}
		break;
	case MASK_TYPE_LOGICSECTION_FAULTLOCK:
		logLockState = GetLogSecLockState(DeviceId);
		cLogSecLogicLockState = GetLogSecLogLockState(DeviceId);
		/*逻辑区段故障锁闭或逻辑故障锁闭*/
		if ((LOG_SECTION_LOCK_EXCEPT == logLockState) || (LOG_SECTION_LOGLOCK_EXCEPT == cLogSecLogicLockState))
		{
			/*设置码位为1*/
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_LOGICSECTION_PROTECTLOCK:
		/*保护锁闭*/

		/*逻辑区段无【跳跃锁闭】*/
		chJumpLockState = GetLogSecJumpLockState(DeviceId);
		if (LOGIC_SECTION_JUMP_LOCK_YES != chJumpLockState)
		{
			/*防护锁闭所属进路不是自动信号进路就发*/
			logProtectLockRoute = GetLogSecPLockRouteId(DeviceId);
			if (0u != logProtectLockRoute)
			{
				routeAutoSigProperty = GetRouteAutoSigProperty(logProtectLockRoute);
				if (ROUTE_AUTOSIG_PROPERTY_YES == routeAutoSigProperty)
				{
					/*自动信号的保护区段不发送码位*/
				}
				else
				{
					/*设置码位为1*/
					SetMaskValue(MaskId, dataBuf);
				}
			}
			else
			{
				/*无防护锁闭，不发*/
			}
		}
		else
		{
			/*有跳跃锁闭，不发*/
		}
		break;
	case MASK_TYPE_LOGICSECTION_JUMPLOCK:
		/*跳跃锁闭*/
		chJumpLockState = GetLogSecJumpLockState(DeviceId);/*逻辑区段跳跃锁闭状态*/
		if (LOGIC_SECTION_JUMP_LOCK_YES == chJumpLockState)
		{
			/*设置码位为1*/
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_UPWARD_DIRECTION:
		chLogSecLockDirOpposedFlag = GetLogSecLockDirOpposedFlag(DeviceId);
		chLogSecBelLogRouteSum = GetLogSecLockBelLogRouteSum(DeviceId);

		if (0U == chLogSecBelLogRouteSum)
		{
			cLogSecLockDir = GetLogSecLockDir(DeviceId);
		}
		else
		{
			/*逻辑区段锁闭所属逻辑进路数目大于0，逻辑区段锁闭方向取逻辑进路*/
			cLogSecLockDir = GetLogSecLogLockDir(DeviceId);
		}
		/*上行锁闭方向*/
		if (((CI_SYSTEM_DIRECTION_UP == cLogSecLockDir) && (CI_ERROR == chLogSecLockDirOpposedFlag))
			|| ((CI_SYSTEM_DIRECTION_DOWN == cLogSecLockDir) && (CI_SUCCESS == chLogSecLockDirOpposedFlag)))
		{
			/*逻辑区段锁闭方向为上行且锁闭方向不需要取反 或者 逻辑区段锁闭方向为下行且锁闭方向需要取反*/
			/*设置码位为1*/
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_DOWNWARD_DIRECTION:
		chLogSecLockDirOpposedFlag = GetLogSecLockDirOpposedFlag(DeviceId);
		chLogSecBelLogRouteSum = GetLogSecLockBelLogRouteSum(DeviceId);

		if (0U == chLogSecBelLogRouteSum)
		{
			cLogSecLockDir = GetLogSecLockDir(DeviceId);
		}
		else
		{
			/*逻辑区段锁闭所属逻辑进路数目大于0，逻辑区段锁闭方向取逻辑进路*/
			cLogSecLockDir = GetLogSecLogLockDir(DeviceId);
		}
		/*下行锁闭方向*/
		if (((CI_SYSTEM_DIRECTION_DOWN == cLogSecLockDir) && (CI_ERROR == chLogSecLockDirOpposedFlag))
			|| ((CI_SYSTEM_DIRECTION_UP == cLogSecLockDir) && (CI_SUCCESS == chLogSecLockDirOpposedFlag)))
		{
			/*逻辑区段锁闭方向为下行且锁闭方向不需要取反 或者 逻辑区段锁闭方向为上行且锁闭方向需要取反*/
			/*设置码位为1*/
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_LOGICSECTION_ARB:
		/* 逻辑区段ARB状态 */
		cLogArbState = GetLgcArbState(DeviceId);
		/*区段ARB*/
		if (LGC_SECTION_ARB_YES == cLogArbState)
		{
			/*设置码位为1*/
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_LOGICSECTION_SPKS_FLOCK:
		/* 逻辑区段SPKS封锁状态 */
		cLogSpksFlockState = GetLogSecSpksFLockState(DeviceId);
		/*区段SPKS封锁*/
		if (LOGIC_SECTION_SPKS_FLOCK_YES == cLogSpksFlockState)
		{
			; /*封锁发0*/
		}
		else
		{
			/*设置码位为1*/
			SetMaskValue(MaskId, dataBuf);
		}
		
		break;
	default:
		returnValue = CI_ERROR;
		break;
	}

	return returnValue;
}


/*
* 功能描述： 保护区段相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*/
UINT8 OverlapMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT8 returnValue = CI_ERROR; /*返回值*/
	UINT8 overlapPhySecSum = 0u;/*保护区段包含物理区段数目*/
	UINT16* overlapContainPhySecIdBuf = NULL;/*保护区段包含物理区段数组*/
	UINT8 ii = 0u;
	UINT16 overlapbelongRtId = 0u;/*保护区段保护锁闭所属进路*/
	UINT16 rtOverlapLockedId = 0u;/*进路实际锁闭的保护区段*/

	UINT8 checkResult = CI_ERROR;/*检查结果变量*/
	UINT16 tempDevId = 0u;/*设备ID临时变量，调用Check函数需要的出口参数，本函数不关心*/
	UINT8 tempDevSta = 0u;/*设备状态临时变量，调用Check函数需要的出口参数，本函数不关心*/

	UINT8 lineIdentity = CI_TRADITION_RAILWAY;
	UINT8 overlapSum = 0u;
	UINT16* overlapIdBuf = NULL;
	UINT8 jj = 0u;
	UINT8 flag = 0u;
	overlapPhySecSum = GetOverlapPhySecSum(DeviceId);
	overlapContainPhySecIdBuf = GetOverlapPhySecIdBuf(DeviceId);
	for (ii = 0u; ii < overlapPhySecSum; ii++)
	{/*遍历保护区段包含的物理区段，查找防护锁闭所属进路ID*/
		overlapbelongRtId = GetPhySecPLockBelongRouteId(overlapContainPhySecIdBuf[ii]);
		if (0u != overlapbelongRtId)
		{/*查找成功*/
			returnValue = CI_SUCCESS;
			break;
		}
	}
	if (CI_SUCCESS == returnValue)
	{
		overlapSum = GetRouteOverlapSum(overlapbelongRtId);  /*获取Overlap总数*/
		overlapIdBuf = GetRouteOverlapIdBuf(overlapbelongRtId);  /*获取Overlap ID BUF*/

		for (jj = 0u; jj < overlapSum; jj++)
		{  /*当进路包含的保护区段与锁闭的保护区段一致，则发送保护区段锁闭码位，否则不发，
		   防止多条进路包含同一个物理区段保护信息，导致实际没有锁闭的进路的保护区段也发送保护区段锁闭码位，20190109*/
			rtOverlapLockedId = GetRouteOverlapLockedId(overlapbelongRtId);/*获取进路实际锁闭的保护区段ID*/
			if (overlapIdBuf[jj] == rtOverlapLockedId)
			{
				flag = 1u;  /*锁闭的保护区段为进路内方区段*/
			}
			if ((1u == flag) && (DeviceId == overlapIdBuf[jj]))
			{
				/*由于码位表中保护区段中道岔定位反位的码位一致，故联锁只发送序号大的码位，
				此处判断防止真正锁闭的码位和实际传输的码位不一致的情况*/
				if (MASK_TYPE_OVERLAP_LOCKSTATE == MaskType) /*保护区段锁闭状态*/
				{
					/*保护区段建立码位有效性检查*/
					checkResult = OverlapValidMaskCheck(rtOverlapLockedId);

					if (CI_SUCCESS == checkResult)
					{
						returnValue = CI_SUCCESS;
					}
					else
					{
						returnValue = CI_ERROR;
					}

					/*检查信号机保护区段有效性*/
					if (CI_SUCCESS == returnValue)
					{
						checkResult = SignalOverlapValidCheck(overlapbelongRtId, &tempDevId, &tempDevSta);

						if (CI_SUCCESS == checkResult)
						{
							returnValue = CI_SUCCESS;
						}
						else
						{
							returnValue = CI_ERROR;
						}
					}

					if (CI_SUCCESS == returnValue)
					{
						/*获取线路标识*/
						lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);

						if (CI_TRADITION_RAILWAY == lineIdentity)
						{
							/*传统双轨铁路无需检查*/
							returnValue = CI_SUCCESS;
						}
						else
						{
							/* 失败返回 *//* zt 删除单轨相关代码 2022-02-15 */
							returnValue = CI_ERROR;
						}
					}
					else
					{
						returnValue = CI_ERROR;
					}

					if (CI_SUCCESS == returnValue)
					{
						SetMaskValue(MaskId, dataBuf);

						returnValue = CI_SUCCESS;
					}
					else
					{
						returnValue = CI_ERROR;
					}

				}
				else if (MASK_TYPE_OVERLAP_UNLOCK_APPLY == MaskType)
				{    /*标志有效则向ZC发送申请解锁保护区段码位,获取正真锁闭的保护区段的申请状态*/
					if (UNLOCK_OVERLAP_APPLY_YES == GetOverlapUnlockApplyFlag(rtOverlapLockedId))
					{
						SetMaskValue(MaskId, dataBuf);
						returnValue = CI_SUCCESS;
					}
					else
					{
						returnValue = CI_ERROR;
					}

				}
				else
				{
					returnValue = CI_ERROR;
				}
			}
			else
			{
				returnValue = CI_ERROR;
			}
		}
	}
	else
	{
		returnValue = CI_ERROR;
	}


	return returnValue;
}


/*
* 功能描述： 进路相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*/
UINT8 RouteMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT8 returnValue = CI_SUCCESS;              /*返回值默认成功*/
	UINT8 routeState = GetRouteState(DeviceId);  /*获取进路状态*/
	UINT8 routeLevel = GetRouteLevel(DeviceId);
	UINT16 lastPhyLockId = GetRouteLastPhySectionId(DeviceId);   /*获取指定ID进路最后一个物理区段ID*/
	UINT8 lastPhyLockState = GetPhySecLockState(lastPhyLockId);  /*获取最后一个物理区段锁闭状态*/
	UINT8 firstLogicOccuState = GetLogSecCurOccupyState(GetRouteInFirstLogSecId(DeviceId));
	UINT8 dcQState = GetRouteDCQState(DeviceId);/*进路调车请求状态*/
	UINT8 dcTState = GetRouteDCTYState(DeviceId);/*进路调车同意状态*/
	UINT8 chDCAgreeBtnErrState = GetRouteDcAgreeButtonErrState(DeviceId);/*进路调车同意按钮故障状态*/
	UINT8 RouteCiId = 0u;	/*进路所属联锁*/
	UINT8 CiTypeOfRoute = 0u;		/*当前进路所属联锁类型*/
	UINT8 ciTrainTestState = 0u;	/*试车线联锁状态*/
	UINT8 routeAutoTriggerFlag = GetRouteAutoTriggerFlag(DeviceId);     /*获取进路自动触发标志*/

	UINT32 xuanpaiStartCycNum = GetRouteXuanPaiStartCycNum(DeviceId);/*进路选排开始周期数*/
	switch (MaskType)
	{
	case MASK_TYPE_ROUTE_IDLE:/*进路空闲码位*/
		if (ROUTE_STATE_IDLE == routeState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_ROUTE_XUANPAI:/*进路选排码位*/
		/* 处于选排周期号有效即可发送码位*/
		if (xuanpaiStartCycNum > 0u)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_ROUTE_ALLLOCK:/*CI-ATS码位，进路完整锁闭码位*/
		if (ROUTE_AUTOSIG_PROPERTY_YES == GetRouteAutoSigProperty(DeviceId))
		{
			if ((ROUTE_STATE_FIRST_LOCK == routeState) ||
				(ROUTE_STATE_FIRST_LOCKERR == routeState) ||
				(ROUTE_STATE_YUXIAN_LOCK == routeState) ||
				(ROUTE_STATE_YUXIAN_OPEN == routeState) ||
				(ROUTE_STATE_NEAR_OPEN == routeState) ||
				(ROUTE_STATE_NEAR_LOCKERR == routeState) ||
				(ROUTE_STATE_LEAD_LOCK == routeState) ||
				(ROUTE_STATE_LEAD_LOCKERR == routeState) ||
				(ROUTE_STATE_LEAD_OPEN == routeState) ||
				(ROUTE_STATE_DELAY_UNLOCK == routeState) ||
				(ROUTE_STATE_NEAR_LOCK == routeState))
			{/*自动进路判断条件：进路初锁、进路初锁异常、预先锁闭、预先开放、接近开放、接近锁闭异常、接近锁闭正常
		 、引导锁闭、引导锁闭异常、引导开放、延时解锁*/
				SetMaskValue(MaskId, dataBuf);
			}
			else
			{

			}
		}
		else
		{
			if ((ROUTE_STATE_FIRST_LOCK == routeState) ||
				(ROUTE_STATE_FIRST_LOCKERR == routeState) ||
				(ROUTE_STATE_YUXIAN_LOCK == routeState) ||
				(ROUTE_STATE_YUXIAN_OPEN == routeState) ||
				(ROUTE_STATE_NEAR_OPEN == routeState) ||
				(ROUTE_STATE_NEAR_LOCKERR == routeState) ||
				(ROUTE_STATE_LEAD_LOCK == routeState) ||
				(ROUTE_STATE_LEAD_LOCKERR == routeState) ||
				(ROUTE_STATE_LEAD_OPEN == routeState) ||
				(ROUTE_STATE_DELAY_UNLOCK == routeState) ||
				((ROUTE_STATE_NEAR_LOCK == routeState) && (SECTION_OCCUPY_YES == firstLogicOccuState)))
			{/*普通进路判断条件：进路初锁、进路初锁异常、预先锁闭、预先开放、接近开放、接近锁闭异常、接近锁闭正常且第一区段占用
		 （新机场进路内方第一区段为大长计轴，列车追踪紧密时，后车需停在进路外方，现改为当第一逻辑区段空闲后向ATS发送非完整锁闭）
		 、引导锁闭、引导锁闭异常、引导开放、延时解锁*/
				SetMaskValue(MaskId, dataBuf);
			}
			else
			{

			}
		}
		break;
	case MASK_TYPE_ROUTE_PARTLOCK:/*进路部分锁闭码位*/
		break;
	case MASK_TYPE_ROUTE_DELAYUNLOCK:/*延时解锁码位*/
		if ((ROUTE_STATE_DELAY_UNLOCK == routeState) ||
			(ROUTE_STATE_AUTO_UNLOCK == routeState) ||
			(ROUTE_STATE_AUTO_UNLOCKERR == routeState))
		{/*延时解锁、自动解锁正常、自动解锁异常*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_ROUTE_LOCKSTATE:/*CI-ZC码位，基本进路锁闭状态码位:根据接口说明，进路属于办理状态，引导进路均发送0,当进路状态为预选或选排且最后一个区段为锁闭状态则仍发1，解决CBTC模式进路追踪办理动道岔期间不给ZC发进路建立状态*/
		/*获取进路所属CI*/
		RouteCiId = GetRouteBelongCiId(DeviceId);
		/*获取联锁类型*/
		CiTypeOfRoute = GetCiType(RouteCiId);
		if ((0u != RouteCiId) && (0u != CiTypeOfRoute))
		{
			if ((ROUTE_STATE_IDLE != routeState)
				&& (ROUTE_STATE_FIRST_XUANPAI != routeState)
				&& (ROUTE_STATE_XUANPAI != routeState)
				&& (ROUTE_STATE_LEAD_FIRST_XUANPAI != routeState)
				&& (ROUTE_STATE_LEAD_XUANPAI != routeState)
				&& (ROUTE_STATE_LEAD_LOCK != routeState)
				&& (ROUTE_STATE_LEAD_LOCKERR != routeState)
				&& (ROUTE_STATE_LEAD_OPEN != routeState)
				|| (((ROUTE_STATE_FIRST_XUANPAI == routeState) || (ROUTE_STATE_XUANPAI == routeState))
					&& ((PHYSICAL_SECTION_LOCK_NORMAL == lastPhyLockState) ||
						(PHYSICAL_SECTION_LOCK_DELAY == lastPhyLockState) ||
						(PHYSICAL_SECTION_LOCK_FAULTDELAY == lastPhyLockState)))
				)
			{
				ciTrainTestState = GetCiTrainTestStatus();
				if ((CI_TYPE_SCX == CiTypeOfRoute) && (CI_TRAIN_TEST_ON != ciTrainTestState))
				{
					;
				}
				else
				{
					SetMaskValue(MaskId, dataBuf);
				}
			}
			else
			{
				;
			}
		}
		else
		{
			;
		}
		break;
	case MASK_TYPE_ROUTE_OPENSTATE:/*进路开放状态码位*/
		if ((ROUTE_STATE_YUXIAN_OPEN == routeState) ||
			(ROUTE_STATE_NEAR_OPEN == routeState) ||
			(ROUTE_STATE_LEAD_OPEN == routeState))
		{/*进路预先开放、接近开放*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_ROUTE_EXISTENCE:/*进路存在状态码位*/
		if (ROUTE_STATE_IDLE == routeState)
		{/*进路空闲，不存在*/
		}
		else
		{/*其他状态，存在*/
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_ROUTE_NEARLOCK:/*进路接近锁闭状态码位*/
		if ((ROUTE_STATE_NEAR_LOCK == routeState) ||
			(ROUTE_STATE_NEAR_LOCKERR == routeState) ||
			(ROUTE_STATE_NEAR_OPEN == routeState))
		{/*进路接近锁闭、接近锁闭异常、接近开放*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_ROUTE_YINDAOLOCK:
		if ((ROUTE_STATE_LEAD_LOCK == routeState) ||
			(ROUTE_STATE_LEAD_LOCKERR == routeState) ||
			(ROUTE_STATE_LEAD_OPEN == routeState))
		{/*进路引导锁闭、引导锁闭异常、引导开放时，引导锁闭码位发1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;

	case MASK_TYPE_ROUTE_DC_QINGQIU:/*调车请求码位*/
	{
		if (ROUTE_DCQ_REQUEST == dcQState)
		{/*有调车请求，置1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*无调车请求，置0*/
		}
	}
	break;

	case MASK_TYPE_ROUTE_DC_AGREE:/*调车同意码位*/
	{
		if (ROUTE_DCT_AGREE == dcTState)
		{/*有调车同意，置1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*无调车同意，置0*/
		}
	}
	break;

	case MASK_TYPE_ROUTE_DC_AGREE_ERR:/*调车同意按钮故障码位*/
	{
		if (ROUTE_DC_AGREE_BUTTON_OK == chDCAgreeBtnErrState)
		{
			/*调车同意按钮未故障，置1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*调车同意按钮故障，置0*/
		}
	}
	break;

	case MASK_TYPE_AUTOROUTE_STATE:/*自动通过进路状态码位*/
		if (AUTO_ROUTE_SET_YES == GetAutoRouteSetFlag(DeviceId))
		{/*自动通过进路办理标志*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_AUTORETURN_STATE:/*自动折返进路状态码位*/
		if (AUTO_RETURN_SET_YES == GetAutoReturnSetFlag(DeviceId))
		{/*自动折返进路办理标志*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_ALLAUTORETURN_STATE:/*全自动折返进路状态码位*/
		if (ALL_AUTO_RETURN_SET_YES == GetAllAutoReturnSetFlag(DeviceId))
		{/*全自动折返进路办理标志*/
			SetMaskValue(MaskId, dataBuf);
		}

		break;
	case MASK_TYPE_ROUTE_STOPE_APPLY:	/*总人解并且ZC未反馈停车保证并且车未压入始端信号机内方的情况下才需要停车保证*/
		if (ROUTE_STATE_DELAY_UNLOCK == routeState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_ROUTE_SIGNAL_STATE: /* 进路信息: 信号亮红灯或灭灯，或在引导状态 发送 0 ，其他 发送1 */
		if ((ROUTE_LEVEL_BLOC == routeLevel) &&
			((ROUTE_STATE_YUXIAN_OPEN == routeState) ||
				(ROUTE_STATE_NEAR_OPEN == routeState)))
		{/* 点式下处于信号开放状态 */
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	case MASK_TYPE_ROUTE_AUTO_TRIGGER: /* CI-ATS码位，进路自动触发标志 */
		if (AUTO_TRIGGER_SET_YES == routeAutoTriggerFlag)
		{/* 自动触发进路有设置了自动触发标志 */
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;
	default:
		returnValue = CI_ERROR;
		break;
	}

	return returnValue;
}



/*
* 功能描述： 站台相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*/
UINT8 PlatMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT16 ii = 0u;
	UINT8 relaySum = 0u;
	UINT16* relayIdBuf;
	UINT8 returnValue = CI_SUCCESS;/*返回值默认成功*/
	UINT8 mutualLockState = 0u;
	UINT8 psdState = 0u;

	UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG);
	UINT8 RelayCollState = 0u;
	UINT8 localCi = GetSystemParaLocalCiId();
	UINT8 virtualZDZFBelongCiId = 0U;
	UINT8 virtualZDZFDevType = 0U;
	UINT8 virtualZDZFButtonState = 0U;
	UINT8 psdSendAtsStateFlag = 0u;
	UINT8 EssSteadyState = 0u;
	UINT8 EssFlashState = 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 cancelEsbErrFlag = ESB_ERROR_FLAG_NO;  /*取消紧急关闭按钮故障标志*/
	UINT8 esbErrFlag = ESB_ERROR_FLAG_NO;  /*紧急关闭按钮故障标志*/
	UINT8 chCleFarePDBFlaLigFlag = 0U;/*清客确认箱PDB按钮闪灯状态*/
	UINT8 chPsdVideoQkDriveState = 0U;/*清客确认箱视频清客驱动状态*/
	UINT8 chRtnIndicatorDevId = 0U;/*无人折返报警灯设备ID*/
	UINT8 chNonRrnAdhesionState = 0U;/*无人折返按钮粘连状态*/
	UINT8 cEsbCutErrFlag = ESB_ERROR_FLAG_NO;  /*紧急关闭旁路按钮故障标志*/
	UINT16 wEsbCollRelayId = 0U;  /*ESB采集继电器ID*/
	UINT8 cPsdExceptOpenState = 0U;  /*屏蔽门异常打开状态*/

	chRtnIndicatorDevId = GetIndicatorRelNonReturnId(DeviceId);
	virtualZDZFBelongCiId = GetVirtualZDZFBelongCiId();
	virtualZDZFDevType = GetVirtualZDZFDevType();
	virtualZDZFButtonState = GetVirtualZDZFButtonState();

	switch (MaskType)
	{
	case MASK_TYPE_PLAT_AUTORETURNSIG_BUTTONSTAT:/*站台无人折返按钮激活状态码位*/
		if (FUNC_SWITCH_ON == includeVirFlag)
		{
			DealAutoReturnButtonMask_Vir(DeviceId, MaskId, dataBuf);/*若配置虚拟联锁，则DeviceId为指示灯表的行ID*/
		}
		else
		{/*若未配置虚拟联锁，则DeviceId为指示灯ID*/
			for (ii = 0u; ii < GetIndicatorCurSum(); ii++)
			{
				if ((DeviceId == GetIndicatorId(ii))
					&& (INDICATOR_TYPE_EXPRESS_RETURN == GetIndicatorType(DeviceId)))
				{/*设备ID对应且指示灯类型为无人折返灯*/

					if ((virtualZDZFBelongCiId == localCi) && (CI_DEVICE_TYPE_AUTORETURN == virtualZDZFDevType))
					{/*无人折返按钮为虚拟设备*/
						if (VIRTUAL_ZDZFAJ_BUTTON_YES == virtualZDZFButtonState)
						{/*虚拟设备无人折返按钮按下*/
							SetMaskValue(MaskId, dataBuf);
						}
					}
					else
					{/*无人折返按钮是真实的*/
						relaySum = GetIndicatorRelaySum(DeviceId);
						relayIdBuf = GetIndicatorRelayIdBuf(DeviceId);
						if ((3u != relaySum) || (NULL == relayIdBuf))
						{/*继电器数据错误或无人折返按钮为虚拟设备*/
							returnValue = CI_ERROR;
							break;
						}
						else
						{
							RelayCollState = GetRelayCollState(relayIdBuf[2]);
							chNonRrnAdhesionState = GetNonRtnAdhesionState(chRtnIndicatorDevId);

							if ((RELAY_STATE_UP == RelayCollState) && (RTN_RELAY_ADHESION_NO == chNonRrnAdhesionState))
							{/*无人折返按钮继电器吸起*/
								SetMaskValue(MaskId, dataBuf);
							}
							else
							{
							}
						}
					}

				}
			}
		}

		break;

	case MASK_TYPE_ESP_STATE:/*站台紧急关闭按钮码位*/
		if ((ESB_STATE_VALID_NO == GetEsbState(DeviceId)) || (ESB_CUT_YES == GetEsbCutState(DeviceId)))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_ESS_STEADY_STATE:/*ESS稳灯状态码位*/
		EssSteadyState = GetEsbRelateEssSteadyState(DeviceId);
		if (ESB_STATE_LIGHT_STATE_Y == EssSteadyState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			; /*稳灯状态为未设置状态或者错误状态，无需设置相关码位*/
		}
		break;
	case MASK_TYPE_ESP_FLASH_STATE:/*ESS闪灯灯状态码位*/
		EssFlashState = GetEsbRelateEssFlashState(DeviceId);
		if (ESB_STATE_LIGHT_STATE_Y == EssFlashState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			; /*闪灯状态为未设置状态或者错误状态，无需设置相关码位*/
		}
		break;
	case MASK_TYPE_CANCEL_ESP_FAULT:
		cancelEsbErrFlag = GetCancelEsbErrFlag(DeviceId);
		if (ESB_ERROR_FLAG_YES == cancelEsbErrFlag)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*码位值发0*/
		}
		break;
	case MASK_TYPE_ESP_FAULT:
		esbErrFlag = GetEsbErrFlag(DeviceId);
		if (ESB_ERROR_FLAG_YES == esbErrFlag)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*码位值发0*/
		}
		break;
	case MASK_TYPE_CUT_ESP_FAULT:
		cEsbCutErrFlag = GetEsbCutErrFlag(DeviceId);
		if (ESB_ERROR_FLAG_YES == cEsbCutErrFlag)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*码位值发0*/
		}
		break;
	case MASK_TYPE_ESP_PRESS_STATE:
		wEsbCollRelayId = GetEsbRelayId(DeviceId);  /*获取ESB采集继电器*/
		RelayCollState = GetRelayCollState(wEsbCollRelayId);  /*获取ESB采集继电器状态*/
		if (RELAY_STATE_UP == RelayCollState)
		{
			SetMaskValue(MaskId, dataBuf);  /*ESB未按下，发1*/
		}
		else
		{
			/*ESB按下，发0*/
		}
		break;
	case MASK_TYPE_PSD_STATE_ATS:/*站台屏蔽门状态码位;给ATS*/
		/*获取屏蔽门互锁解除状态、门状态*/
		mutualLockState = GetPsdMutualLockRemoveState(DeviceId);
		psdState = GetPsdState(DeviceId);
		psdSendAtsStateFlag = GetCiFunctionSwitchConfig(FUNC_PSD_SEND_ATS_STATE_FLAG);
		if (FUNC_SWITCH_ON == psdSendAtsStateFlag)
		{
			if (PSD_STATE_CLOSE == psdState)
			{
				SetMaskValue(MaskId, dataBuf);
			}
			else
			{
			}
		}
		else
		{
			if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState)
				|| (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_STATE_CLOSE == psdState))
			{
				SetMaskValue(MaskId, dataBuf);
			}
			else
			{
			}
		}
		break;

	case MASK_TYPE_PSD_STATE:/*站台屏蔽门状态码位-给ZC,LEU用*/
		/*获取屏蔽门互锁解除状态、门状态*/
		mutualLockState = GetPsdMutualLockRemoveState(DeviceId);
		psdState = GetPsdState(DeviceId);
		if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState)
			|| (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_STATE_CLOSE == psdState))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_MUTUALLOCK_STATE:/*站台屏蔽门互锁解除状态码位*/
		mutualLockState = GetPsdMutualLockRemoveState(DeviceId);
		if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState)
			|| (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{

		}
		break;

	case MASK_TYPE_REMORA_STATE:/*障碍物信息码位，CI收到VOBC开始探测命令后开始驱动启动探测继电器，计时Time后CI才给现地和ATS反馈间隙探测状态。*/
		if (JXTC_MUTUALLOCK_REMOVE_YES == GetJXTCMutualLockState(DeviceId))
		{/*间隙探测互锁解除*/
			/*发送间隙探测无障碍物*/
		}
		else
		{/*间隙探测未互锁解除*/
			if (CI_TIME_OUT == SystemOverTimeCheck(GetStartDetectionCycNum(DeviceId), GetGapDetectCount()))
			{
				if (PSD_REMORA_YES == GetPsdRemoraState(DeviceId))
				{/*1表示间隙探测有障碍物*/
					SetMaskValue(MaskId, dataBuf);
				}
				else
				{/*0表示间隙探测无障碍物*/
				}
			}
			else
			{/*未开始计时或计时未到，给现地和ATS发送无障碍物*/
			}
		}
		break;
	case MASK_TYPE_PSD_JXTC_PANGLU:
	{
		if (JXTC_MUTUALLOCK_REMOVE_YES == GetJXTCMutualLockState(DeviceId))
		{/*间隙探测互锁解除*/
			/*发送间隙探测旁路状态为旁路*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{/*间隙探测未互锁解除*/

		}
		break;
	}
	case MASK_TYPE_PSD_PCBPSBDPB_PANGLU_STATE:/*屏蔽门PCB/POB/DPB旁路状态码位*/
	{
		if (PSD_BUTTON_PANGLU_STATE_VALID == GetPsdButtonPangluState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}

		break;
	}
	case MASK_TYPE_PSD_PCB:/*站台屏蔽门PCB按钮状态码位*/
		chPslPcbState = GetPsdButtonState(DeviceId);
		chCleFarePcbState = GetCleFarePCBButtonState(DeviceId);
		if ((PSD_BUTTON_STATE_DOWN == chPslPcbState) || (QK_PSD_BUTTON_STATE_DOWN == chCleFarePcbState))
		{/*cgh修改成都四线清客需求：PSL门控箱PCB或清客确认箱PCB有一个按下*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_PSD_POB:/*站台屏蔽门POB按钮状态码位*/
		if (PSD_OPEN_BUTTON_STATE_VALID == GetPsdOpenButtonState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_PSD_PSB:/*站台屏蔽门PSB按钮状态码位*/
		if (PLATFORM_DEPAR_BUTTON_STATE_VALID == GetPsdDepartButtonState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_PSD_PCB_INVALID:/*站台屏蔽门PCB按钮失效状态码位-cgh修改成都四线清客需求：包含PSL门控箱PCB按钮失效及清客确认箱PCB按钮失效*/
		dwPsdButPreTimeCount =GetPsdButtonPressCount();
		dwPslPcbPreCyc = GetPCBPressCycNum(DeviceId);
		dwCleFarePcbPreCyc = GetCleFarePCBPressCycNum(DeviceId);
		chPslPcbTimeCheck = SystemOverTimeCheck(dwPslPcbPreCyc, dwPsdButPreTimeCount);
		chCleFarePcbTimeCheck = SystemOverTimeCheck(dwCleFarePcbPreCyc, dwPsdButPreTimeCount);
		if ((CI_TIME_OUT == chPslPcbTimeCheck) || (CI_TIME_OUT == chCleFarePcbTimeCheck))
		{/*PSL门控箱PCB及清客确认箱中PCB只要有一个超时，就需要考虑发送按钮无效码位*/
			if ((0u == dwPslPcbPreCyc) && (0u == dwCleFarePcbPreCyc))
			{
				/*未计时*/
			}
			else
			{/*2种情况满足一种PCB按钮吸起超时设置无效*/
				SetMaskValue(MaskId, dataBuf);
			}
		}
		else
		{
			; /*其他情况此码位无效*/
		}
		break;
	case MASK_TYPE_PSD_POB_INVALID:/*站台屏蔽门POB按钮失效状态码位*/
		if (CI_TIME_OUT == SystemOverTimeCheck(GetPOBPressCycNum(DeviceId), GetPsdButtonPressCount()))
		{
			if (0u == GetPOBPressCycNum(DeviceId))
			{
				/*未计时*/
			}
			else
			{
				SetMaskValue(MaskId, dataBuf);
			}
		}
		else
		{
		}
		break;
	case MASK_TYPE_PSD_PSB_INVALID:/*站台屏蔽门PSB按钮失效状态码位*/
		if (CI_TIME_OUT == SystemOverTimeCheck(GetPSBPressCycNum(DeviceId), GetPsdButtonPressCount()))
		{
			if (0u == GetPSBPressCycNum(DeviceId))
			{
				/*未计时*/

			}
			else
			{
				SetMaskValue(MaskId, dataBuf);
			}
		}
		else
		{
		}
		break;
	case MASK_TYPE_PSD_PDB_FLASH_STATE:/*屏蔽门清客确认箱PDB按钮指示灯闪灯状态码位*/
		chCleFarePDBFlaLigFlag = GetCleFarePDBFlaLigFlag(DeviceId);
		if (QK_BUTTON_FLASH_LIGHT_YES == chCleFarePDBFlaLigFlag)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			; /*指定ID屏蔽门清客确认箱PDB按钮指示灯闪灯标志无效，码位无效*/
		}
		break;
	case MASK_TYPE_PSD_VIDEO_QK_LU:/*清客按钮箱视频清客表示灯（绿)状态码位*/
		chPsdVideoQkDriveState = GePsdVideoQkDriveState(DeviceId);
		if ((VIDEO_QK_DRIVE_STATE_NO == chPsdVideoQkDriveState) || (VIDEO_QK_DRIVE_STATE_TESTING == chPsdVideoQkDriveState))
		{
			/*视频清客驱动状态为无人或者检测中，绿灯码位有效*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*视频清客驱动状态为有人或者无效，绿灯码位无效*/
		}
		break;
	case MASK_TYPE_PSD_VIDEO_QK_HONG:/*清客按钮箱视频清客表示灯（红)状态码位*/
		chPsdVideoQkDriveState = GePsdVideoQkDriveState(DeviceId);
		if ((VIDEO_QK_DRIVE_STATE_HAVE == chPsdVideoQkDriveState) || (VIDEO_QK_DRIVE_STATE_TESTING == chPsdVideoQkDriveState))
		{
			/*视频清客驱动状态为有人或者检测中，红灯码位有效*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*视频清客驱动状态为无人或者无效，红灯码位无效*/
		}
		break;
	case MASK_TYPE_PSD_EXCEPT_OPEN:  /*站台屏蔽门异常打开状态码位-给ZC/ATS用*/
		cPsdExceptOpenState = GePsdExceptOpenState(DeviceId);
		if (PSD_EXCEPT_OPEN_NO == cPsdExceptOpenState)
		{
			SetMaskValue(MaskId, dataBuf);  /*PSD未异常打开，码位组1*/
		}
		else
		{
			/*PSD异常打开，码位组0*/
		}
		break;
	default:
		returnValue = CI_ERROR;
		break;
	}

	return returnValue;
}

/*
* 功能描述： SPKS相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*/
UINT8 SPKSMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT8 returnValue = CI_SUCCESS;/*返回值默认成功*/

	switch (MaskType)
	{
	case MASK_TYPE_SPKS_OPENSTATE:/*SPKS开关状态码位*/
		if (SPKS_STATUS_YES == GetSpksState(DeviceId))
		{
			/*SPKS打开，发0*/
		}
		else
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_SPKS_ISOLATE_BUTTON_STATE:/*SPKS旁路状态码位*/
		if (SPKS_CUT_YES == GetSpksCutState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_SPKS_OPENSTATE_ZC: /*SPKS开关状态码位:spks+旁路后的融合状态，CI-ZC*/
		if ((SPKS_STATUS_YES == GetSpksState(DeviceId)) && (SPKS_CUT_NO == GetSpksCutState(DeviceId)))
		{
			; /* Mask Set zero*/
		}
		else
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	default:
		returnValue = CI_ERROR;
		break;
	}

	return returnValue;
}


/*
* 功能描述： 洗车机相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*/
UINT8 WashManchineMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT8 returnValue = CI_SUCCESS;/*返回值默认成功*/
	UINT8 chWashMachineReadyState = 0U;/*洗车机就绪状态*/
	UINT8 chWashModeState = 0U;/*洗车机工作模式*/

	switch (MaskType)
	{
	case MASK_TYPE_WASHMACHINE_READYSTATE:/*洗车机就绪状态码位*/
		chWashMachineReadyState = GetWashMachineReadyState(DeviceId);
		if (WASHMACHINE_COL_READY_YES == chWashMachineReadyState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_WASHMACHINE_WORKMODE:
		/*洗车机工作模式码位*/
		chWashModeState = GetWashModeState(DeviceId);
		if (XTA_MODE_STATE_UP == chWashModeState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	default:
		returnValue = CI_ERROR;
		break;
	}

	return returnValue;
}


/*
* 功能描述： 车库门相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*/
UINT8 GaragedoorMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT8 returnValue = CI_SUCCESS;/*返回值默认成功*/

	switch (MaskType)
	{
	case MASK_TYPE_GARAGEDOOR_STATE:/*定义车库门状态码位(CI->ZC)*/
		if (GARAGE_DOOR_STATE_OPEN == GetGaragedoorState(DeviceId))
		{/*开门状态，发1*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;

	case MASK_TYPE_GARAGEDOOR_APPLYCLOSE_STATE:/*定义车库门申请关闭码位(CI->ZC)*/
		if ((GARAGE_DOOR_CMD_CLOSE == GetGrgdoorCmdProcessState(DeviceId)) &&
			(GetWaiteZCResponseStartCycNum(DeviceId) > 0U))
		{/*向ZC申请关闭车库门，发1*/
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_GARAGEDOOR_OPEN_STATE:/*定义车库门开门状态码位(CI->ATS)*/
		if (GARAGE_DOOR_STATE_OPEN == GetGaragedoorState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_GARAGEDOOR_CLOSE_STATE:/*定义车库门关门状态码位(CI->ATS)*/
		if (GARAGE_DOOR_STATE_CLOSE == GetGaragedoorState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		break;
	case MASK_TYPE_GARAGEDOOR_MODE_STATE:/*定义车库门模式状态码位(CI->ATS)*/
		if (GARAGE_DOOR_STATE_MODE_REMOTE == GetGaragedoorModeState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*即为本地模式，发0*/
		}
		break;
	case MASK_TYPE_GARAGEDOOR_FAULT_STATE:/*定义车库门故障状态码位(CI->ATS)*/
		if (GARAGE_DOOR_FAULT_TRUE == GetGaragedoorFaultState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	case MASK_TYPE_GARAGEDOOR_PANGLU_STATE:/*定义车库门旁路状态码位(CI->ATS)*/
		if (GARAGE_DOOR_PANGLU_TRUE == GetGaragedoorPangLuState(DeviceId))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
		}
		break;
	default:
		returnValue = CI_ERROR;
		break;
	}

	return returnValue;
}

/*
* 功能描述： 防淹门相关码位处理
* 参数说明： UINT8 MaskType, 码位类型
*			 UINT16 DeviceId, 设备ID
*			 UINT16 MaskId, 码位ID
*			 UINT8* dataBuf, 数据缓冲区
* 返回值  ： 0: 码位处理失败
*			 1: 码位处理成功
*/
UINT8 FloodGateMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf)
{
	UINT8 returnValue = CI_ERROR;/*返回值默认失败*/
	UINT8 floodState = 0u; /*临时变量：防淹门状态*/
	UINT16 floodId = DeviceId;
	UINT16 phySecId = 0u;
	UINT8  physecState = 0u;
	UINT8 checkRes = 0u;/*检查结果*/
	UINT32 wFloodGateDelayCloseStartCyc = 0U;		/*防淹门接近区段占压延迟关门起始时间*/
	switch (MaskType)
	{
	case MASK_TYPE_FLOODGATE_CLOSEAPLAY_STATE:/*定义防淹门关门请求码位 ATS/ZC共用*/
	{
		floodState = GetFloodGateCurCloseRequestSta(floodId);
		if (FLOOD_GATE_CLOSEREQ == floodState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*无关门请求*/
		}
		returnValue = CI_SUCCESS;
	}
	break;
	case MASK_TYPE_FD_OPENLOCK_TO_ATS:/*定义防淹门开门且锁闭码位 ATS*/
	{
		floodState = GetFloodGateCurOpenLockState(floodId);
		if (FLOOD_GATE_OPENLOCK == floodState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*未开启锁定*/
		}
		returnValue = CI_SUCCESS;
	}
	break;
	case MASK_TYPE_FD_OPENLOCK_TO_ZC:/*定义防淹门开门且锁闭码位 ZC*/
	{
		floodState = GetFloodGateCurOpenLockState(floodId);
		if (FLOOD_GATE_OPENLOCK == floodState)
		{/*无关门请求，有开门锁定时，发送开启锁定*/
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*无开启锁定*/
		}

		returnValue = CI_SUCCESS;
	}
	break;
	case MASK_TYPE_FLOODGATE_AGREECLOSE_TOATS:/*防淹门同意关闭状态 to ATS*/
	{
		floodState = GetFloodGateCurAgreeCloseSta(floodId);
		if (FLOOD_GATE_AGREE_CLOSE == floodState)
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*不同意关闭*/
		}
		returnValue = CI_SUCCESS;
	}
	break;
	case MASK_TYPE_FLOODGATE_SQGM_TOZC:/*防淹门申请关闭码位 to ZC*/
	{
		/*1. 联锁采集到关闭申请*/
		floodState = GetFloodGateCurCloseRequestSta(floodId);

		/*2. 防淹门防护区段空闲*/
		checkRes = FloodGateProtPhysecOccuCheck(floodId, &phySecId, &physecState);
		wFloodGateDelayCloseStartCyc = GetFloodGateDelayCloseStartCnt(floodId);		/*开始延时后，向ZC发码位申请*/

		if ((FLOOD_GATE_CLOSEREQ == floodState) && (CI_SUCCESS == checkRes) && (0U < wFloodGateDelayCloseStartCyc))
		{
			SetMaskValue(MaskId, dataBuf);
		}
		else
		{
			/*不发申请关闭*/
		}
		returnValue = CI_SUCCESS;
	}
	break;
	default:
		returnValue = CI_ERROR;
		break;
	}

	return returnValue;
}
/*
* 功能描述： 生成码位
* 参数说明： const UINT8 localCiId, 本机联锁站ID
*			 const UINT8 destSystemType, 目标系统类型
*            const UINT8* dataBuf, 码位buf
* 返回值  ： 0: 生成失败
*			 1: 生成成功
*/
UINT8 MaskPack(const UINT8 destSystemType, UINT8* dataBuf)
{
	UINT16 MaskSum;		/*码位总数*/
	UINT16 ii = 0u;		/*游标*/
	UINT16 DeviceId;	/*设备ID*/
	UINT8 DeviceType;	/*设备类型*/
	UINT8 MaskType;		/*码位类型*/
	UINT16 MaskId = 0u;	/*码位ID*/
	UINT8 returnValue = CI_SUCCESS;/*初始返回值为1*/

	MaskSum = GetSendMaskSum(destSystemType);
	if (0u == MaskSum)
	{
		return CI_ERROR;
	}

	for (ii = 1u; ii <= MaskSum; ii++)
	{
		MaskId = GetMaskId(Get2oo2SheBeiType(), destSystemType, ii);
		if (MaskId != 0u)
		{
			MaskType = GetSendMaskType(destSystemType, ii);
			DeviceId = GetSendMaskDeviceId(destSystemType, ii);
			DeviceType = GetSendMaskDeviceType(destSystemType, ii);
		}
		else
		{
			continue;
		}

		switch (DeviceType)
		{
		case CI_DEVICE_TYPE_SWITCH:/*道岔相关码位处理*/
			if (CI_ERROR == SwitchMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;
		case CI_DEVICE_TYPE_SIGNAL:/*信号机相关码位处理*/
			if (CI_ERROR == SignalMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;
		case CI_DEVICE_TYPE_PHYSEC:/*物理区段相关码位处理*/
			if (CI_ERROR == PhySectionMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;
		case CI_DEVICE_TYPE_LOGICSEC:/*逻辑区段相关码位处理*/
			if (CI_ERROR == LogicSectionMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;
		case CI_DEVICE_TYPE_OVERLAP:/*保护区段相关码位*/
			if (CI_ERROR == OverlapMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;
		case CI_DEVICE_TYPE_ROUTE:/*进路相关码位*/
		case CI_DEVICE_TYPE_AUTOROUTE:/*自动通过进路相关码位*/
		case CI_DEVICE_TYPE_AUTORETURN:/*自动折返进路相关码位*/
		case CI_DEVICE_TYPE_ALLAUTORETURN:/*全自动折返进路相关码位*/
			if (CI_ERROR == RouteMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;
			/*站台相关码位*/
		case CI_DEVICE_TYPE_PSD:
		case CI_DEVICE_TYPE_ESB:
		case CI_DEVICE_TYPE_PLATFORM:
			if (CI_ERROR == PlatMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;
		case CI_DEVICE_TYPE_SPKS:/*SPKS相关码位*/
			if (CI_ERROR == SPKSMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;
		case CI_DEVICE_TYPE_WASHMACHINE:/*洗车机相关码位*/
			if (CI_ERROR == WashManchineMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;
		case CI_DEVICE_TYPE_GARAGEDOOR:/*车库门相关码位*/
			if (CI_ERROR == GaragedoorMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;
		case CI_DEVICE_TYPE_FLOODGATE:/*防淹门相关码位*/
			if (CI_ERROR == FloodGateMaskManage(MaskType, DeviceId, MaskId, dataBuf))
			{
				returnValue = CI_ERROR;
			}
			break;

		default:
			returnValue = CI_ERROR;
			break;
		}
	}
	return returnValue;
}



/*
* 功能描述： 设置码位
* 参数说明： const UINT16 maskId, 码位ID
*            UINT8* dataBuf, 码位buf
* 返回值  ： 无
*
*/
void SetMaskValue(const UINT16 maskId, UINT8* dataBuf)
{
	UINT16 divNum = 0u;		  /*除数*/
	UINT16 remNum = 0u;		  /*余数*/

	if ((maskId > 0u) && (dataBuf != NULL))
	{
		divNum = (UINT16)(maskId / 8u);
		remNum = (UINT16)(maskId % 8u);

		if (0u == remNum)
		{
			dataBuf[divNum - 1U] = (UINT8)(dataBuf[divNum - 1U] | 0x01u);
		}
		else
		{
			dataBuf[divNum] = (UINT8)(dataBuf[divNum] | (0x80u >> (remNum - 1u)));/*remNum在0-7中取值*/
		}
	}
	else
	{
		/*不做处理*/
	}
}


/*
* 功能描述： 解析码位
* 参数说明： const UINT8* SourceDataBuf, 源数据缓冲区
*			 const UINT16 SourceDataLength, 源数据总长度
*			 UINT16 MaskSum, 码位数量 （实际的码位数量，可能小于SourceDataLength*8）
*			 UINT8* TargetDataBuf, 目标数据缓冲区
* 返回值  ： 0: 解析失败
*			 >0: 解析成功
*/
UINT8 GetMaskValue(UINT8* TargetDataBuf, const UINT16 MaskSum, const UINT8* SourceDataBuf, const UINT16 SourceDataLength)
{
	UINT16 curSor = 0u;			/*目标数据缓冲区下标*/
	UINT8 res = 0u;              /*余数*/
	UINT16 ii = 0u;				/*源数据缓冲区下标*/
	UINT16 jj;					/*码位解析下标*/
	UINT8 returnValue = 0u;      /*默认解析失败*/

	for (ii = 0u; ii < SourceDataLength; ii++)
	{
		for (jj = 0u; jj < 8u; jj++)
		{

			{/*码位未解析完毕*/

				res = (UINT8)((SourceDataBuf[ii] >> (7u - jj)) % 2u);/*与2的余数*/
				if (res == 0u)
				{
					TargetDataBuf[curSor++] = 0u;
				}
				else
				{
					TargetDataBuf[curSor++] = 1u;
				}
			}

			if (MaskSum == curSor)
			{/*码位解析完毕*/

				returnValue = 1u;
				break;
			}


		}
		if (1u == returnValue)
		{
			break;
		}
	}


	return returnValue;
}

/*
* 功能描述： 计算保护区段有效码位
* 参数说明： const UINT16 ovlpId, 保护区段ID
* 返回值  ：
CI_SUCCESS: 保护区段有效
*		CI_ERROR: 保护区段无效
*/
UINT8 OverlapValidMaskCheck(const UINT16 rtOverlapLockedId)
{
	UINT8 returnValue = CI_ERROR; /*返回值*/
	UINT8 overlapPhySecSum = 0u;/*保护区段包含物理区段数目*/
	UINT16* overlapContainPhySecIdBuf = NULL;/*保护区段包含物理区段数组*/
	UINT8 ovpLockState = 0u;/*保护区段锁闭状态*/
	UINT8 ii = 0u;

	/* overlap道岔 */
	UINT8 checkSum = 0u;
	OverlapConditionSwitchStruct* condSwiDataIdBuf = NULL;
	/* overlap防护道岔 */
	UINT8 protectSwitchSum = 0u;
	UINT8 lockStatus = 0u;
	UINT8 ylockStatus = 0u;/*临时变量：引导总锁状态*/
	UINT8 fengsuoStateus = 0u;/*临时变量：封锁状态*/
	UINT8 switchPos = 0u;/*临时变量：道岔位置*/
	OverlapProtectSwitchStruct* protSwiDataIdBuf = NULL;

	/*防淹门*/
	UINT16 devId = 0u;
	UINT8	devStateType = 0u;		/*设备状态类型*/
	UINT8  devState = 0u;
	UINT32 laborUnlockStartCycNum = 0u;
	UINT8 functionId = EFUNC_OVERLAP_VALIDMASK_CHECK;

	if (0u != rtOverlapLockedId)
	{
		overlapPhySecSum = GetOverlapPhySecSum(rtOverlapLockedId);
		overlapContainPhySecIdBuf = GetOverlapPhySecIdBuf(rtOverlapLockedId);
		for (ii = 0u; ii < overlapPhySecSum; ii++)
		{/*遍历保护区段包含物理区段数组是否跳跃锁闭*/
		 /*跳跃锁闭或区段封锁状态时，CI->ZC,CI->ATS不发送保护区段锁闭*/

			if ((PHYSICAL_SECTION_FLOCK_NO != GetPhySecFLockState(overlapContainPhySecIdBuf[ii])))
#if 0
				|| (PHYSICAL_SECTION_JUMP_LOCK_YES == GetPhySecJumpLockState(overlapContainPhySecIdBuf[ii]))

				/*保护区段与逻辑区段一致，不检查占压*/
				|| (SECTION_OCCUPY_YES == GetPhySecCurMergeState(overlapContainPhySecIdBuf[ii])))
#endif		
			{
				returnValue = CI_ERROR;
				break;
			}
		}

		if (ii == overlapPhySecSum)
		{
			returnValue = CI_SUCCESS;
		}
		else
		{
			returnValue = CI_ERROR;
		}

		if (CI_SUCCESS == returnValue)
		{				/* overlap道岔 */
			checkSum = GetOverlapSwitchSum(rtOverlapLockedId);
			condSwiDataIdBuf = GetOverlapCondSwitchStruct(rtOverlapLockedId);
			for (ii = 0u; ii < checkSum; ii++)
			{
				if ((SWITCH_LOCK_YINZONG_NO == GetSwitchYLockState(condSwiDataIdBuf[ii].SwitchId)) &&
					(SWITCH_LOCK_FENGSUO_NO == GetSwitchFLockState(condSwiDataIdBuf[ii].SwitchId)) &&
					(condSwiDataIdBuf[ii].SwitchPosition == GetSwitchCurPosition(condSwiDataIdBuf[ii].SwitchId)))
				{
					/* 保护区段所包含的道岔为：非引导总锁且未封锁且道岔位置正确，才发送码位*/

				}
				else
				{

					returnValue = CI_ERROR;
					break;
				}
			}
		}

		if (CI_SUCCESS == returnValue)
		{	/*保护区段关联防护道岔*/
			protectSwitchSum = GetOverlapRelatedProtSwitSum(rtOverlapLockedId);
			protSwiDataIdBuf = GetOverlapRelatedProtSwitStru(rtOverlapLockedId);
			for (ii = 0u; ii < protectSwitchSum; ii++)
			{
				lockStatus = GetSwitchLockStatus(protSwiDataIdBuf[ii].ProtectSwitchId);
				ylockStatus = GetSwitchYLockState(protSwiDataIdBuf[ii].ProtectSwitchId);
				switchPos = GetSwitchCurPosition(protSwiDataIdBuf[ii].ProtectSwitchId);
				fengsuoStateus = GetSwitchFLockState(protSwiDataIdBuf[ii].ProtectSwitchId);

				if ((SWITCH_LOCK_YINZONG_NO == ylockStatus)
					&& ((SWITCH_LOCK_STATUS_PROTECT == lockStatus) || (SWITCH_LOCK_STATUS_DAP == lockStatus))
					&& (protSwiDataIdBuf[ii].ProtectPosition == switchPos)
					&& (SWITCH_LOCK_FENGSUO_NO == fengsuoStateus))
				{
					/* 保护区段关联防护道岔：非引导总锁且防护锁闭且道岔位置正确且未封锁，才发送码位*/
				}
				else
				{
					returnValue = CI_ERROR;
					break;
				}
			}
		}

		if (CI_SUCCESS == returnValue)
		{
			ovpLockState = GetOverlapLockState(rtOverlapLockedId);
			if (CI_SUCCESS == ovpLockState)
			{
				returnValue = CI_SUCCESS;
			}
			else
			{
				returnValue = CI_ERROR;
			}
		}

		if (CI_SUCCESS == returnValue)
		{
			if (CI_SUCCESS == OverlapInvSecAndConSwiCheckup(rtOverlapLockedId, NULL, NULL))
			{
				returnValue = CI_SUCCESS;
			}
			else
			{
				returnValue = CI_ERROR;
			}
		}

		/*检查保护区段关联防淹门状态*/
		if (CI_SUCCESS == returnValue)
		{
			returnValue = OverlapFloodGateStateCheck(rtOverlapLockedId, &devId, &devStateType, &devState);
			if (CI_ERROR == returnValue)
			{
				SetErrorData(functionId, CI_DEVICE_TYPE_FLOODGATE, devId, devStateType, devState, ESEND_LEVEL_ZERO);
			}
		}
		/*检查人工解锁保护区段是否处于倒计时过程中，倒计时过程中发ZC,LEU未建立*/
		if (CI_SUCCESS == returnValue)
		{
			laborUnlockStartCycNum = GetlaborUnlockStartCycNum(rtOverlapLockedId);
			if (0u < laborUnlockStartCycNum)
			{
				returnValue = CI_ERROR;
			}
		}

		/*检查照查继电器状态*/
		if (CI_SUCCESS == returnValue)
		{
			returnValue = OverlapZhaoChaRelayCheck(rtOverlapLockedId, ESEND_LEVEL_ZERO);

			if (CI_SUCCESS == returnValue)
			{
				returnValue = CI_SUCCESS;
			}
			else
			{
				/*等待本端照查继电器落下或对端检查不过，反馈失败*/
				returnValue = CI_ERROR; 
			}
		}
	}
	else
	{
		returnValue = CI_ERROR;
	}

	return returnValue;
}


/*
* 功能描述： 组包发送CIM通信状态信息
* 参数说明： void
* 返回值  ： 无
*
*/
void PackCiToCimCommData(void)
{
	/*变量初始化*/
	UINT16 i = 0U;
	UINT8 j = 0U;
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0U };
	UINT8 deviceSum = 0u; /*通信设备数*/
	UINT8* pDeviceIdBuf = NULL;  /*设备ID数组*/
	UINT8 transmitState = 0u;  /*通信状态*/
	UINT8 transmitDevSum = 0U;
	UINT16 transmitDevIndex = 0U;
	UINT8 cLocalWorkMode = 0U;  /*工作模式*/
	UINT8 cLocalCiId = 0U;  /*本控区ID*/
	UINT32 dwCurCycNum = 0U;  /*当前周期号*/
	UINT32 dwRecvCycNum = 0U;  /*接收到对方数据时的周期号*/
	UINT16 wTempCommVobcNumIndex = 0U;  /*通信车数量索引位置*/
	UINT8 cCommVobcNum = 0U;  /*通信车数量*/
	UINT8 cVobcToCiDataSum = 0U;
	VobcToCiDataStruct* pstrVobcToCiData = NULL;
	UINT32 dwCommBadCycCount = 0U;

	cLocalWorkMode = GetLocalRcWorkMode();
	cLocalCiId = GetSystemParaLocalCiId();
	dwCurCycNum = Get2oo2CurCycleNum();
	ciToCimDataBuffer[i++] = cLocalWorkMode;
	ciToCimDataBuffer[i++] = cLocalCiId;

	transmitDevIndex = i;
	i++;
	/*ZC通信状态*/
	pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC);
	if (NULL != pDeviceIdBuf)
	{
		/*联锁只对应一个ZC*/
		transmitDevSum++;
		transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_ZC, 0U);
		ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_ZC;
		ciToCimDataBuffer[i++] = pDeviceIdBuf[0];

		/*组ZC通信冗余周期*/
		dwRecvCycNum = GetCiTransmitRecvDataCycNum(cLocalCiId, CI_SYSTEM_TYPE_ZC, pDeviceIdBuf[0]);
		if ((0U != dwRecvCycNum) && (UINT8_MAX > (dwCurCycNum - dwRecvCycNum)))
		{
			ciToCimDataBuffer[i] = (UINT8)(dwCurCycNum - dwRecvCycNum);  /*组通信设备冗余周期*/
		}
		else
		{
			ciToCimDataBuffer[i] = (UINT8)UINT8_MAX;  /*组通信设备冗余周期*/
		}
		i++;

		if (TRANSMIT_2OO2_STATE_GOOD == transmitState)
		{
			ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD;
		}
		else if (TRANSMIT_2OO2_STATE_LINK == transmitState)
		{
			ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK;
		}
		else
		{
			ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD;
		}
	}

	/*TMC通信状态*/
	pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_TMC);
	if (NULL != pDeviceIdBuf)
	{
		/*联锁只对应一个TMC*/
		transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_TMC, 0U);

		transmitDevSum++;
		ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_TMC;
		ciToCimDataBuffer[i++] = pDeviceIdBuf[0];

		/*组TMC通信冗余周期*/
		dwRecvCycNum = GetCiTransmitRecvDataCycNum(cLocalCiId, CI_SYSTEM_TYPE_TMC, pDeviceIdBuf[0]);
		if ((0U != dwRecvCycNum) && (UINT8_MAX > (dwCurCycNum - dwRecvCycNum)))
		{
			ciToCimDataBuffer[i] = (UINT8)(dwCurCycNum - dwRecvCycNum);  /*组通信设备冗余周期*/
		}
		else
		{
			ciToCimDataBuffer[i] = (UINT8)UINT8_MAX;  /*组通信设备冗余周期*/
		}
		i++;

		if (TRANSMIT_2OO2_STATE_GOOD == transmitState)
		{
			ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD;
		}
		else if (TRANSMIT_2OO2_STATE_LINK == transmitState)
		{
			ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK;
		}
		else
		{
			ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD;
		}
	}
	/*OC通信状态*/
	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_OC);
	pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC);

	if ((NULL != pDeviceIdBuf) && (0u != deviceSum))
	{
		for (j = 0u; j < deviceSum; j++)
		{
			transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_OC, j);

			transmitDevSum++;
			ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_OC;
			ciToCimDataBuffer[i++] = pDeviceIdBuf[j];
			
			/*组OC通信冗余周期*/
			dwRecvCycNum = GetCiTransmitRecvDataCycNum(cLocalCiId, CI_SYSTEM_TYPE_OC, pDeviceIdBuf[j]);
			if ((0U != dwRecvCycNum) && (UINT8_MAX > (dwCurCycNum - dwRecvCycNum)))
			{
				ciToCimDataBuffer[i] = (UINT8)(dwCurCycNum - dwRecvCycNum);  /*组通信设备冗余周期*/
			}
			else
			{
				ciToCimDataBuffer[i] = (UINT8)UINT8_MAX;  /*组通信设备冗余周期*/
			}
			i++;

			if (TRANSMIT_2OO2_STATE_GOOD == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD;
			}
			else if (TRANSMIT_2OO2_STATE_LINK == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK;
			}
			else
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD;
			}

		}

	}

	/*PSC通信状态*/
	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PSC);
	pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PSC);

	if ((NULL != pDeviceIdBuf) && (0u != deviceSum))
	{
		for (j = 0u; j < deviceSum; j++)
		{
			transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_PSC, j);

			transmitDevSum++;
			ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_PSC;
			/*填ID*/
			ciToCimDataBuffer[i++] = pDeviceIdBuf[j];

			/*组PSC通信冗余周期*/
			dwRecvCycNum = GetCiTransmitRecvDataCycNum(cLocalCiId, CI_SYSTEM_TYPE_PSC, pDeviceIdBuf[j]);
			if ((0U != dwRecvCycNum) && (UINT8_MAX > (dwCurCycNum - dwRecvCycNum)))
			{
				ciToCimDataBuffer[i] = (UINT8)(dwCurCycNum - dwRecvCycNum);  /*组通信设备冗余周期*/
			}
			else
			{
				ciToCimDataBuffer[i] = (UINT8)UINT8_MAX;  /*组通信设备冗余周期*/
			}
			i++;

			if (TRANSMIT_2OO2_STATE_GOOD == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD;
			}
			else if (TRANSMIT_2OO2_STATE_LINK == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK;
			}
			else
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD;
			}
		}

	}

	/*计轴系统通信状态*/
	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS);
	pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS);

	if ((NULL != pDeviceIdBuf) && (0u != deviceSum))
	{
		for (j = 0u; j < deviceSum; j++)
		{
			transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_AXIS, j);
			/*填ID*/

			transmitDevSum++;
			ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_AXIS;
			ciToCimDataBuffer[i++] = pDeviceIdBuf[j];
			
			/*组计轴通信冗余周期*/
			dwRecvCycNum = GetCiTransmitRecvDataCycNum(cLocalCiId, CI_SYSTEM_TYPE_AXIS, pDeviceIdBuf[j]);
			if ((0U != dwRecvCycNum) && (UINT8_MAX > (dwCurCycNum - dwRecvCycNum)))
			{
				ciToCimDataBuffer[i] = (UINT8)(dwCurCycNum - dwRecvCycNum);  /*组通信设备冗余周期*/
			}
			else
			{
				ciToCimDataBuffer[i] = (UINT8)UINT8_MAX;  /*组通信设备冗余周期*/
			}
			i++;

			if (TRANSMIT_2OO2_STATE_GOOD == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD;
			}
			else if (TRANSMIT_2OO2_STATE_LINK == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK;
			}
			else
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD;
			}
		}

	}


	/*相邻CI系统通信状态*/
	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_CI);
	pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_CI);

	if ((NULL != pDeviceIdBuf) && (0u != deviceSum))
	{
		for (j = 0u; j < deviceSum; j++)
		{
			transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_CI, j);
			/*填ID*/

			transmitDevSum++;
			ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_CI;
			ciToCimDataBuffer[i++] = pDeviceIdBuf[j];

			/*组相邻RC/CI通信冗余周期*/
			dwRecvCycNum = GetCiTransmitRecvDataCycNum(cLocalCiId, CI_SYSTEM_TYPE_CI, pDeviceIdBuf[j]);
			if ((0U != dwRecvCycNum) && (UINT8_MAX > (dwCurCycNum - dwRecvCycNum)))
			{
				ciToCimDataBuffer[i] = (UINT8)(dwCurCycNum - dwRecvCycNum);  /*组通信设备冗余周期*/
			}
			else
			{
				ciToCimDataBuffer[i] = (UINT8)UINT8_MAX;  /*组通信设备冗余周期*/
			}
			i++;

			if (TRANSMIT_2OO2_STATE_GOOD == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD;
			}
			else if (TRANSMIT_2OO2_STATE_LINK == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK;
			}
			else
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD;
			}
		}

	}
	/*现地系统通信状态*/
	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_XIANDI);
	pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_XIANDI);

	if ((NULL != pDeviceIdBuf) && (0u != deviceSum))
	{
		for (j = 0u; j < deviceSum; j++)
		{
			transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_XIANDI, j);
			/*填ID*/

			transmitDevSum++;
			ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_XIANDI;
			ciToCimDataBuffer[i++] = pDeviceIdBuf[j];

			ciToCimDataBuffer[i++] = (UINT8)UINT8_MAX;
			/*通信良好*/
			if (TRANSMIT_2OO2_STATE_GOOD == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD;
			}
			else if (TRANSMIT_2OO2_STATE_LINK == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK;
			}
			else
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD;
			}
		}

	}

	/*ATS系统通信状态*/
	deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_ATS);
	pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ATS);

	if ((NULL != pDeviceIdBuf) && (0u != deviceSum))
	{
		for (j = 0u; j < deviceSum; j++)
		{
			transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_ATS, j);
			/*填ID*/

			transmitDevSum++;
			ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_ATS;
			ciToCimDataBuffer[i++] = pDeviceIdBuf[j];

			ciToCimDataBuffer[i++] = (UINT8)UINT8_MAX;
			/*通信良好*/
			if (TRANSMIT_2OO2_STATE_GOOD == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD;
			}
			else if (TRANSMIT_2OO2_STATE_LINK == transmitState)
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK;
			}
			else
			{
				ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD;
			}
		}

	}

	ciToCimDataBuffer[transmitDevIndex] =transmitDevSum;

	/*组通信车通信冗余周期*/
	wTempCommVobcNumIndex = i;  /*通信车数量索引位置*/
	i++;

	cVobcToCiDataSum = GetVobcToCiSum();
	pstrVobcToCiData = GetVobcToCiDataStru();

	if ((0U < cVobcToCiDataSum) && (VOBC_TO_CI_SUM_MAX > cVobcToCiDataSum) && (NULL != pstrVobcToCiData))
	{
		dwCommBadCycCount = GetCiAndVobcTransBadEnsureCnt();
		for (j = 0U; j < cVobcToCiDataSum; j++)
		{
			if (dwCommBadCycCount >= (dwCurCycNum - pstrVobcToCiData[j].ComStartCycle))
			{
				ciToCimDataBuffer[i] = (UINT8)pstrVobcToCiData[j].VobcId; /*组通信车ID*/
				i++;
				ciToCimDataBuffer[i] = (UINT8)(dwCurCycNum - pstrVobcToCiData[j].ComStartCycle);  /*组通信车冗余周期*/
				i++;
				cCommVobcNum++;
			}
			else
			{
				/*通信超时，继续检查下一个列车的通信周期*/
			}
		}
	}
	else
	{
		cCommVobcNum = 0U;
	}

	ciToCimDataBuffer[wTempCommVobcNumIndex] = cCommVobcNum;  /*组通信车数量*/

	debug_infor_printf((const)"\nCIM_SEND_COMM:%d", i);
	debug_out_array(0xAA, ciToCimDataBuffer, i);
	/*发送CIM*/
	(void)DarkInfoPack(CIM_INFO_COMM_STATE, ciToCimDataBuffer, i);

}

/*
* 功能描述： 组包发送CIM信号机断丝状态信息
* 参数说明： void
* 返回值  ： 无
*
*/
void PackCiToCimSignalDsData(void)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u };
	UINT8 redDsFlag = 0u;  /*红灯断丝*/
	UINT8 greenDsFlag = 0u;  /*绿灯断丝*/
	UINT8 yellowDsFlag = 0u;  /*黄灯断丝*/
	UINT8 whiteDsFlag = 0u;  /*白灯断丝*/
	UINT8 redYellowDsFlag = 0u;      /*红黄灯断丝*/
	UINT8 redWhiteDsFlag = 0u;       /*红白灯断丝*/
	UINT8 greenYellowDsFlag = 0u;    /*绿黄灯断丝*/
	UINT8 doubleGreenDsFlag = 0u;    /*双绿灯断丝*/
	UINT8 doubleYellowDsFlag = 0u;  /*双黄灯断丝*/
	UINT8 signalDsSum = 0u; /*断丝信号机数*/
	UINT16 signalSum = 0u; /*信号机总数*/
	UINT16 deviceId = 0u;
	UINT8 signalNoLine = 0u;
	UINT8 signalDsStateSum = 0u; /*信号机断丝状态数*/
	UINT16 dsIndex = 0u;
	UINT16 sumIndex = 0u;
	UINT32 curCycleNum = 0u;/*当前周期数*/

	/*获取信号机数*/
	signalSum = GetSignalCurSum();
	curCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/


	/*填CI周期*/
	LongToChar(curCycleNum, &ciToCimDataBuffer[i]);
	i += 4u;

	sumIndex = i; /*记录当前位置*/
	/*数量先填0*/
	ciToCimDataBuffer[i++] = 0u;
	for (j = 0u; j < signalSum; j++)
	{
		deviceId = GetSignalId(j);
		/*不同信号机先清零*/
		signalDsStateSum = 0u;
		/*信号机属于本联锁*/
		signalNoLine = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, deviceId);
		if (CI_TRUE == signalNoLine)
		{
			/*获取灯丝断丝状态*/
			redDsFlag = GetSignalDsBreakFlag(deviceId);
			greenDsFlag = GetSignalGreenDsBreakFlag(deviceId);
			yellowDsFlag = GetSignalYellowDsBreakFlag(deviceId);
			whiteDsFlag = GetSignalWhiteDsBreakFlag(deviceId);
			redYellowDsFlag = GetSignalRedYellowDsBreakFlag(deviceId);
			redWhiteDsFlag = GetSignalRedWhiteDsBreakFlag(deviceId);
			greenYellowDsFlag = GetSignalGreenYellowDsBreakFlag(deviceId);
			doubleGreenDsFlag = GetSignalDoubleGreenDsBreakFlag(deviceId);
			doubleYellowDsFlag = GetSigDoubleYellowDsBreakFlag(deviceId);

			/*存在信号机断丝状态*/
			if ((SIGNAL_DS_BREAK_YES == redDsFlag) || (SIGNAL_DS_BREAK_YES == greenDsFlag)
				|| (SIGNAL_DS_BREAK_YES == yellowDsFlag) || (SIGNAL_DS_BREAK_YES == whiteDsFlag)
				|| (SIGNAL_DS_BREAK_YES == redYellowDsFlag) || (SIGNAL_DS_BREAK_YES == redWhiteDsFlag)
				|| (SIGNAL_DS_BREAK_YES == greenYellowDsFlag) || (SIGNAL_DS_BREAK_YES == doubleGreenDsFlag)
				|| (SIGNAL_DS_BREAK_YES == doubleYellowDsFlag))
			{
				signalDsSum++; /*信号机断丝数自加1*/
				ShortToChar(deviceId, &ciToCimDataBuffer[i]); /*填信号机ID*/
				i += 2u;
				dsIndex = i;/*记录数量位置*/
				/*断丝状态数量先填0*/
				ciToCimDataBuffer[i++] = 0u;

				/*红断*/
				if (SIGNAL_DS_BREAK_YES == redDsFlag)
				{
					ciToCimDataBuffer[i++] = SIGNAL_RED_DS_STATE;
					signalDsStateSum++; /*断丝状态数加1*/
				}
				/*绿断*/
				if (SIGNAL_DS_BREAK_YES == greenDsFlag)
				{
					ciToCimDataBuffer[i++] = SIGNAL_GREEN_DS_STATE;
					signalDsStateSum++; /*断丝状态数加1*/
				}
				/*黄断*/
				if (SIGNAL_DS_BREAK_YES == yellowDsFlag)
				{
					ciToCimDataBuffer[i++] = SIGNAL_YELLOW_DS_STATE;
					signalDsStateSum++; /*断丝状态数加1*/
				}
				/*白断*/
				if (SIGNAL_DS_BREAK_YES == whiteDsFlag)
				{
					ciToCimDataBuffer[i++] = SIGNAL_WHITE_DS_STATE;
					signalDsStateSum++; /*断丝状态数加1*/
				}
				/*红黄断*/
				if (SIGNAL_DS_BREAK_YES == redYellowDsFlag)
				{
					ciToCimDataBuffer[i++] = SIGNAL_RED_YELLOW_DS_STATE;
					signalDsStateSum++; /*断丝状态数加1*/
				}
				/*红白断*/
				if (SIGNAL_DS_BREAK_YES == redWhiteDsFlag)
				{
					ciToCimDataBuffer[i++] = SIGNAL_RED_WHITE_DS_STATE;
					signalDsStateSum++; /*断丝状态数加1*/
				}
				/*绿黄断*/
				if (SIGNAL_DS_BREAK_YES == greenYellowDsFlag)
				{
					ciToCimDataBuffer[i++] = SIGNAL_GREEN_YELLOW_DS_STATE;
					signalDsStateSum++; /*断丝状态数加1*/
				}
				/*双绿断*/
				if (SIGNAL_DS_BREAK_YES == doubleGreenDsFlag)
				{
					ciToCimDataBuffer[i++] = SIGNAL_DOUBLE_GREEN_DS_STATE;
					signalDsStateSum++; /*断丝状态数加1*/
				}
				/*双黄断*/
				if (SIGNAL_DS_BREAK_YES == doubleYellowDsFlag)
				{
					ciToCimDataBuffer[i++] = SIGNAL_DOUBLE_YELLOW_DS_STATE;
					signalDsStateSum++; /*断丝状态数加1*/
				}
				/*重新填信号机断丝状态数*/
				ciToCimDataBuffer[dsIndex] = signalDsStateSum;
			}


		}
	}
	/*填断丝信号机数*/
	ciToCimDataBuffer[sumIndex] = signalDsSum;
	/*发送维护机*/
	(void)DarkInfoPack(CIM_INFO_SIGNAL_DS_STATE, ciToCimDataBuffer, i);

}
/*
* 功能描述： 处理配置虚拟联锁下的无人折返按钮码位
* 参数说明： void
* 返回值  ： 无
*
*/
void DealAutoReturnButtonMask_Vir(UINT16 DeviceId, UINT16 MaskId, UINT8* pdataBuf)
{
	UINT16 ii = 0u;
	UINT16 localCIBaojingdengNum = GetLocalCIBaojingdengNum();
	UINT16 localCIBaojingdengWId = 0u;/*表示灯继电器表行ID*/
	UINT8 indicatorID = 0u;/*表示灯继电器表ID*/
	UINT8 localCIBaojingdengType = 0u;
	UINT8 belongVirCI = 0u;
	UINT8 relaySum = 0u;
	UINT16* pRelayIdBuf = NULL;
	UINT8 RelayCollState = 0u;
	UINT8 localCi = GetSystemParaLocalCiId();
	UINT8 virtualZDZFBelongCiId = 0U;
	UINT8 virtualZDZFDevType = 0U;
	UINT8 virtualZDZFButtonState = 0U;
	UINT8 chRtnIndicatorDevId = 0U;/*无人折返报警灯设备ID*/
	UINT8 chNonRrnAdhesionState = 0U;/*无人折返按钮粘连状态*/

	chRtnIndicatorDevId = GetIndicatorRelNonReturnId(DeviceId);
	virtualZDZFBelongCiId = GetVirtualZDZFBelongCiId();
	virtualZDZFDevType = GetVirtualZDZFDevType();
	virtualZDZFButtonState = GetVirtualZDZFButtonState();

	for (ii = 0u; ii < localCIBaojingdengNum; ii++)
	{
		localCIBaojingdengWId = GetLocalCIBaojingdengWId(ii);
		localCIBaojingdengType = GetLocalCIIndicatorIDOrType(ii);

		if ((DeviceId == localCIBaojingdengWId) && (INDICATOR_TYPE_EXPRESS_RETURN == localCIBaojingdengType))
		{/*设备ID对应且指示灯类型为无人折返灯*/
			indicatorID = GetLocalCIIndicatorIDOrType(ii);
			belongVirCI = (UINT8)GetLocalCIBaojingdengBelongVir(ii);

			if ((virtualZDZFBelongCiId == localCi) && (CI_DEVICE_TYPE_AUTORETURN == virtualZDZFDevType))
			{/*目前一个真实联锁只支持配置一个虚拟无人折返按钮为虚拟设备*/
				if (VIRTUAL_ZDZFAJ_BUTTON_YES == virtualZDZFButtonState)
				{/*虚拟设备无人折返按钮按下*/
					SetMaskValue(MaskId, pdataBuf);
				}
			}
			else
			{/*无人折返按钮是真实的*/
				relaySum = GetVirCIIndicConfDataRelaySum(belongVirCI, indicatorID);
				pRelayIdBuf = GetVirCIIndicConfDataRelayBuf(belongVirCI, indicatorID);
				if ((3u != relaySum) || (NULL == pRelayIdBuf))
				{/*继电器数据错误或无人折返按钮为虚拟设备*/
					break;
				}
				else
				{
					RelayCollState = GetRelayCollState(pRelayIdBuf[2]);
					chNonRrnAdhesionState = GetNonRtnAdhesionState(chRtnIndicatorDevId);
					if ((RELAY_STATE_UP == RelayCollState) && (RTN_RELAY_ADHESION_NO == chNonRrnAdhesionState))
					{/*无人折返按钮继电器吸起*/
						SetMaskValue(MaskId, pdataBuf);
					}
					else
					{
					}
				}
			}

		}
	}
}

/*
* 功能描述： 组包发送CIM继电器混线信息
* 参数说明： void
* 返回值  ： 无
*
*/
void PackCiToCimRelayHunXianData(void)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u };
	UINT32 curCycleNum = 0u;/*当前周期数*/
	UINT16 relaySum = 0u;
	UINT16 relayId = 0u;
	UINT8 belongCi = 0u;
	UINT8 localCiId = 0u;
	UINT8 hunXianState = 0u;
	UINT16 hunXianRelaySum = 0u;
	UINT16 sumIndex = 0u;

	relaySum = GetRelayCurSum();
	curCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/
	localCiId = GetSystemParaLocalCiId(); /*获取本地联锁ID*/

	sumIndex = i; /*记录当前位置*/
	/*数量跳两字节*/
	i += 2u;

	for (j = 0u; j < relaySum; j++)
	{
		relayId = GetRelayId(j);
		/*获取继电器信息*/
		belongCi = GetRelayBelongCiId(relayId);
		if (localCiId == belongCi)
		{
			hunXianState = GetRelayHunXianState(relayId);
			if (RELAY_HUNXIAN_STATE_YES == hunXianState)
			{
				hunXianRelaySum++;
				ShortToChar(relayId, &ciToCimDataBuffer[i]); /*填继电器ID*/
				i += 2u;
			}
			else
			{
				/*不做处理*/
			}
		}
	}
	/*填写数量*/

	ShortToChar(hunXianRelaySum, &ciToCimDataBuffer[sumIndex]);
	i += 2u;

	/*发送维护机*/
	(void)DarkInfoPack(CIM_INFOR_RELAY_HUNXIAN_STATE, ciToCimDataBuffer, i);
}
/*
* 功能描述： 组包发送CIM屏蔽门报警帧类型
* 参数说明： void
* 返回值  ： 无
* cgh-合并CID-2349-4：
*/
void PackCiToCimPsdAlarmData(void)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT16 psdNum = 0u;
	UINT16 psdId = 0u;
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u };
	UINT16 sumIndex = 0u;
	UINT8 psdDriveOutTimeState = 0u;
	UINT8 psdDriAndCollDiff = 0u;
	UINT16 diffNum = 0u;
	UINT8 psdBelongCiId = 0u;
	UINT8 localCIid = GetSystemParaLocalCiId();

	/*获取屏蔽门数目*/
	psdNum = GetTotalPsdCurNum();

	sumIndex = i; /*记录当前位置*/
	/*数量先填0*/
	i += 2U;/*预留长度*/
	for (j = 0u; j < psdNum; j++)
	{
		psdId = GetPsdId(j);
		psdBelongCiId = GetPsdBelongCiId(psdId);

		if (localCIid == psdBelongCiId)
		{
			/*驱动未响应报警信息*/
			psdDriveOutTimeState = CheckPsdDriveOutTimeState(psdId);
			/*屏蔽门驱动采集不一致信息*/
			psdDriAndCollDiff = CheckPsdDriAndCollDiff(psdId);

			if ((UINT8_MAX != psdDriveOutTimeState) || (UINT8_MAX != psdDriAndCollDiff))
			{/*产生报警*/
				diffNum++;

				ShortToChar(psdId, &ciToCimDataBuffer[i]); /*psd id*/
				i += 2U;
				ciToCimDataBuffer[i++] = psdDriveOutTimeState;/*组包驱动超时信息*/
				ciToCimDataBuffer[i++] = psdDriAndCollDiff;

				ciToCimDataBuffer[i++] = 0xffU;/*开关指令冲突预留*/
			}

		}
	}
	/*填PSD数目数*/
	ShortToChar(diffNum, &ciToCimDataBuffer[sumIndex]);
	/*发送维护机*/
	(void)DarkInfoPack(CIM_INFO_PSD_ALARM, ciToCimDataBuffer, i);

}

/*
* 功能描述： 组包发送CIM继电器驱动采集不一致报警信息
* 参数说明： void
* 返回值  ： 无
* cgh-合并CID-2349-4：
*/
void PackCiToCimRelayDriAndCollDiff(void)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u };
	UINT16 relaySum = 0u; /*继电器数*/
	UINT16 relayId = 0u;
	UINT32 curCycleNum = 0u;/*当前周期数*/
	UINT8 foreNodeAColl = 0u;
	UINT8 backNodeAColl = 0u;
	UINT8 foreNodeBColl = 0u;
	UINT8 backNodeBColl = 0u;
	UINT8 reValA = 0u;
	UINT8 reValB = 0u;
	UINT16 diffNum = 0u;
	UINT8 relayDrvAddrA = 0u;
	UINT8 relayDrvAddrB = 0u;
	UINT8 relayDrvPosA = 0u;
	UINT8 relayDrvPosB = 0u;
	UINT8 relayBelongCiId = 0u;
	UINT8 localCiId = GetSystemParaLocalCiId();
	UINT16 sumIndex = 0u;
	UINT8 collectMode = 0u;
	UINT8 drvAddrA = 0u;
	UINT8 drvPosA = 0u;
	UINT8 drvAddrB = 0u;
	UINT8 drvPosB = 0u;

	/*获取继电器数*/
	relaySum = GetRelayCurSum();
	curCycleNum = Get2oo2CurCycleNum();/*获取当前周期号*/

	sumIndex = i; /*记录当前位置*/

	i = i + 2U;/*预留长度*/
	for (j = 0u; j < relaySum; j++)
	{
		relayId = GetRelayId(j);
		relayBelongCiId = GetRelayBelongCiId(relayId);
		if (localCiId == relayBelongCiId)
		{
			/*获取继电器的驱动地址信息*/
			drvAddrA = GetRelayDrvAddrA(relayId);
			drvPosA = GetRelayDrvPosA(relayId);
			drvAddrB = GetRelayDrvAddrB(relayId);
			drvPosB = GetRelayDrvPosB(relayId);
			/*获取采集方式*/
			collectMode = GetRelayCollectMode(relayId);

			if ((drvAddrA > 0u) && (drvPosA > 0u) && (drvAddrB > 0u) && (drvPosB > 0u)
				&& (collectMode > 0u))
			{
				/*检查A系是否存在驱动采集不一致*/
				foreNodeAColl = GetForeNodeACollState(relayId);
				backNodeAColl = GetBackNodeACollState(relayId);
				reValA = CheckRelayDriAndCollDiffSeat(relayId, foreNodeAColl, backNodeAColl);
				/*检查B系是否存在驱动采集不一致*/
				foreNodeBColl = GetForeNodeBCollState(relayId);
				backNodeBColl = GetBackNodeBCollState(relayId);
				reValB = CheckRelayDriAndCollDiffSeat(relayId, foreNodeBColl, backNodeBColl);

				if ((CI_ERROR == reValA) || (CI_ERROR == reValB))/**A，B系存在驱动采集不一致*/
				{
					diffNum++;/*记录驱动采集继电器不一致数目*/
					relayDrvAddrA = UINT8_MAX;/*先置默认值*/
					relayDrvPosA = UINT8_MAX;

					relayDrvAddrB = UINT8_MAX;
					relayDrvPosB = UINT8_MAX;

					if (CI_ERROR == reValA)
					{
						relayDrvAddrA = GetRelayDrvAddrA(relayId);
						relayDrvPosA = GetRelayDrvPosA(relayId);
					}
					if (CI_ERROR == reValB)
					{
						relayDrvAddrB = GetRelayDrvAddrB(relayId);
						relayDrvPosB = GetRelayDrvPosB(relayId);
					}

					ShortToChar(relayId, &ciToCimDataBuffer[i]);/*继电器ID*/
					i = i + 2U;
					ciToCimDataBuffer[i++] = relayDrvAddrA;/*A系驱动板卡地址*/
					ciToCimDataBuffer[i++] = relayDrvPosA;/*A系驱动节点位置*/
					ciToCimDataBuffer[i++] = relayDrvAddrB;/*B系驱动板卡地址*/
					ciToCimDataBuffer[i++] = relayDrvPosB;/*B系驱动节点位置*/

				}
			}


		}

	}
	/*填驱动采集不一致继电器数*/
	ShortToChar(diffNum, &ciToCimDataBuffer[sumIndex]);
	/*发送维护机*/
	(void)DarkInfoPack(CIM_INFO_RELAY_DRVANDCOLLDEF, ciToCimDataBuffer, i);

}

/*
* 功能描述： 组包发送CIM信号机驱动超时信息
* 参数说明： void
* 返回值  ： 无
* cgh-合并CID-2349-4：
*
*/
void PackCiToCimSigDriOutTimeData(void)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT16 j = 0u;
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0 };
	UINT16 signalSum = 0u; /*信号机总数*/
	UINT16 deviceId = 0u;
	UINT8 signalNoLine = 0u;
	UINT16 sumIndex = 0u;
	UINT8 curDrvColor = 0u;
	UINT32 sigDriCloseStarNum = 0u;
	UINT32 SigDriOpenStartNum = 0u;
	UINT32 SysParaSigCloseCount = 0u;
	UINT32 SysParaSigOpenCount = 0u;
	UINT8 checkOut = 0u;
	UINT8 signalDriOutTimeSum = 0u;
	UINT8 signalCurColor = 0u;
	UINT8 signalOpenCloseState = 0u;
	UINT32 SigDifColorOpenStartNum = 0u;
	UINT32 actionMaxCount = 0u;
	UINT8 CiPattern = 0u;
	UINT8 chDsnLinSwitch = 0U;
	UINT8 signalPreDrvColor = 0U;
	chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH);
	CiPattern = GetLocalCiPattern();
	/*获取信号机数*/
	signalSum = GetSignalCurSum();

	sumIndex = i; /*记录当前位置*/
	/*数量先填0*/
	ciToCimDataBuffer[i++] = 0u;
	for (j = 0U; j < signalSum; j++)
	{
		deviceId = GetSignalId(j);
		/*信号机属于本联锁*/
		signalNoLine = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, deviceId);
		if (CI_TRUE == signalNoLine)
		{
			/*获取信号机驱动颜色*/
			curDrvColor = GetSignalCurDriveColor(deviceId);  /*获取信号机当前驱动颜色*/

			if ((SIGNAL_DRIVECOLOUR_NULL == curDrvColor) || (0u == curDrvColor))
			{/*信号机驱动无效*/
			}
			else
			{
				if ((SIGNAL_DRIVECOLOUR_RED == curDrvColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == curDrvColor))
				{/*信号机关闭*/
					sigDriCloseStarNum = GetSignalDriveCloseStartCycNum(deviceId);
					SysParaSigCloseCount = GetSystemParaSignalCloseCyc();
					checkOut = SystemOverTimeCheck(sigDriCloseStarNum, SysParaSigCloseCount);
					if (CI_TIME_OUT == checkOut)
					{
						signalDriOutTimeSum++; /*信号机驱动超时数*/
						ShortToChar(deviceId, &ciToCimDataBuffer[i]); /*填信号机ID*/
						i += 2U;
						/*填写驱动超时颜色*/
						ciToCimDataBuffer[i++] = curDrvColor;
					}
				}
				else
				{/*驱动开放*/
					signalCurColor = GetSignalCurColor(deviceId);
					signalOpenCloseState = GetSignalOpenCloseState(signalCurColor);
					if (SIGNAL_CLOSE == signalOpenCloseState)
					{/*信号机当前状态关闭，由关闭驱动开放超时处理*/
						SigDriOpenStartNum = GetSignalDriveOpenStartCycNum(deviceId);
						SysParaSigOpenCount = GetSystemParaSignalOpenCyc();
						if (0u < SysParaSigOpenCount)
						{/*检查到驱动开放超时后，会立即驱动关闭。因此需提前一周期将驱动超时报警发出*/
							SysParaSigOpenCount = SysParaSigOpenCount - 1U;
						}
						checkOut = SystemOverTimeCheck(SigDriOpenStartNum, SysParaSigOpenCount);
						if (CI_TIME_OUT == checkOut)
						{
							signalDriOutTimeSum++; /*信号机驱动超时数*/
							ShortToChar(deviceId, &ciToCimDataBuffer[i]); /*填信号机ID*/
							i += 2U;
							/*填写驱动超时颜色*/
							ciToCimDataBuffer[i++] = curDrvColor;
						}
					}
					else
					{/*信号机当前状态开放，由当前的开放颜色驱动另一种开放颜色超时处理*/
						SigDifColorOpenStartNum = GetSignalDiffColorOpenStartCyc(deviceId);
						signalPreDrvColor = GetSignalPreDriveColor(deviceId);/*获取信号机之前驱动颜色*/
						if ((CI_PATTERN_FULL_ELECTRONIC == CiPattern) && (FUNC_SWITCH_OFF == chDsnLinSwitch)&& (SIGNAL_DRIVECOLOUR_GREENYELLOW == signalPreDrvColor))
						{
							/*全电子联锁非迪士尼 驱动绿黄  若以后继电器联锁存在使用绿黄灯需求再修改*/
							actionMaxCount = GetSystemParaSignalOpenCyc() - 2u;/*减2是因为在驱动显示不同的对应周期已经驱动关闭了，因此需要提前报警*/
						}
						else if (2u <= SIGNAL_RELAY_ACTION_TIMEMAX)
						{
							actionMaxCount = SIGNAL_RELAY_ACTION_TIMEMAX - 2u;/*减2是因为在驱动显示不同的第10周期已经驱动关闭了，因此需要在第9周期提前报警*/
						}
						else
						{
							actionMaxCount = SIGNAL_RELAY_ACTION_TIMEMAX;
						}
						checkOut = SystemOverTimeCheck(SigDifColorOpenStartNum, actionMaxCount);
						if (CI_TIME_OUT == checkOut)
						{
							signalDriOutTimeSum++; /*信号机驱动超时数*/
							ShortToChar(deviceId, &ciToCimDataBuffer[i]); /*填信号机ID*/
							i += 2U;
							/*填写驱动超时颜色*/
							ciToCimDataBuffer[i++] = curDrvColor;
						}
					}


				}

			}
		}
	}
	/*填信号机数*/
	ciToCimDataBuffer[sumIndex] = signalDriOutTimeSum;
	debug_infor_printf((const)"\nCIM_Signal_DriveOutTime \n");
	/*发送维护机*/
	(void)DarkInfoPack(CIM_INFO_SIGNAL_DRIVOUT, ciToCimDataBuffer, i);

}


/*
* 功能描述： 组包发送版本号信息
* 参数说明： void
* 返回值  ： 无
*
*/
void PackCiToCimVerData(void)
{
	/*变量初始化*/
	UINT16 i = 0u;
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u };
	UINT16* pTiocFsVersion = NULL;  /*FS版本号buff*/

	/*组FS版本号*/
	pTiocFsVersion = GetTiocFsVersion();
	ciToCimDataBuffer[i++] = (UINT8)pTiocFsVersion[0];
	ciToCimDataBuffer[i++] = (UINT8)pTiocFsVersion[1];
	ciToCimDataBuffer[i++] = (UINT8)(pTiocFsVersion[2] >> 4U);
	ciToCimDataBuffer[i++] = (UINT8)((pTiocFsVersion[2] << 4U) + pTiocFsVersion[3]);
	/*组软件版本号*/
	ciToCimDataBuffer[i++] = VER_SOFT_PRODUCT;
	ciToCimDataBuffer[i++] = VER_SOFT_MODUAL_APP;
	ciToCimDataBuffer[i++] = VER_SOFT_MIANVERSION;
	ciToCimDataBuffer[i++] = VER_SOFT_SUBVERSION;
	/*组集成版本号*/
	ciToCimDataBuffer[i++] = VER_INTE_PROJECT;
	ciToCimDataBuffer[i++] = VER_INTE_PRODUCT;
	ciToCimDataBuffer[i++] = VER_INTE_EXE;
	ciToCimDataBuffer[i++] = VER_INTE_TIME;
	/*发送CIM*/
	(void)DarkInfoPack(CIM_INFO_VER_INFO, ciToCimDataBuffer, i);

}


/*
* 功能描述： 组包发送设备状态信息
* 参数说明： void
* 返回值  ： 无
*
*/
void PackCiToCimDeviceData(void)
{
	/*变量初始化*/
	UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u };
	UINT16 deviceNum = 0U;
	UINT16 deviceId = 0U;
	SwitchDataStruct* pSwitchData = NULL;
	SignalDataStruct* pSignalData = NULL;
	PsdDataStruct* pPsdData = NULL;
	EsbDataStruct* pEsbData = NULL;
	SpksDataStruct* pSpksData = NULL;
	PhysicalSectionDataStruct* pPhysicalData = NULL;
	WashMachineDataStruct* pWashMachineData = NULL;
	GaragedoorDataStruct* pGrageDoorData = NULL;
	FloodGateDataStruct* pFloodGateData = NULL;
	UINT8 cRcWorkMode = GetLocalRcWorkMode();
	UINT8 chSwitchJichaState = 0U;
	UINT8 chSwitchCurPos = 0U;
	UINT32 switchCollTolerateCycNum = 0U;
	UINT8 chSwitchBDState = SEND_CIM_COLLTOLERATE_NO;
	UINT8 chSignalDsState = 0xFFU;

	/*发送道岔数据*/
	pSwitchData = GetSwitchData();
	deviceNum = GetSwitchCurSum();
	ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*道岔数量*/
	ii += 2u;
	for (jj = 0u; jj < deviceNum; jj++)/*本联锁和相邻联锁发送给本联锁的道岔总数目*/
	{


		/*比较数据*/
		deviceId = GetSwitchId(jj);

		/**************打印数据信息****************/

		ShortToChar(pSwitchData[deviceId].SwitchId, &ciToCimDataBuffer[ii]);/*道岔ID*/
		ii += 2u;

		chSwitchJichaState = GetSwitchJichaState(deviceId);
		chSwitchCurPos = GetSingleSwitchCurPosition(pSwitchData[deviceId].SwitchId);/*道岔状态*/
		if (SWITCH_POSITION_DYNAMIC_JICHA == chSwitchJichaState)
		{
			ciToCimDataBuffer[ii++] = 0x20U;/*道岔动态红闪*/
		}
		else if (SWITCH_POSITION_SUDDEN_JICHA == chSwitchJichaState)
		{
			/*开关打开*/
			ciToCimDataBuffer[ii++] = 0x40U;/*道岔静态红闪*/
		}
		else
		{
			ciToCimDataBuffer[ii++] = chSwitchCurPos;/*单独道岔当前位置*/
		}


		ciToCimDataBuffer[ii++] = pSwitchData[deviceId].SwitchDrivePos;/*道岔驱动位置*/
		ciToCimDataBuffer[ii++] = pSwitchData[deviceId].SwitchDanCaoPostition;/*道岔单操位置*/

		ciToCimDataBuffer[ii++] = pSwitchData[deviceId].SwitchByPassState;   /*道岔旁路状态*/
		ciToCimDataBuffer[ii++] = pSwitchData[deviceId].ConnetSwitchDsState; /*联络线道岔单锁状态*/

		switchCollTolerateCycNum = GetSwitchCollTolerateCycNum(pSwitchData[deviceId].SwitchId);
		if (0u < switchCollTolerateCycNum)
		{
			if (SWITCH_POSITION_DINGWEI == chSwitchCurPos)
			{
				chSwitchBDState = SEND_CIM_COLLTOLERATE_DW;/*是容忍后定位*/
			}
			else  if (SWITCH_POSITION_FANWEI == chSwitchCurPos)
			{
				chSwitchBDState = SEND_CIM_COLLTOLERATE_FW;/*是容忍后反位*/
			}
			else
			{
				chSwitchBDState = SEND_CIM_COLLTOLERATE_NO;
			}
		}
		else
		{
			chSwitchBDState = SEND_CIM_COLLTOLERATE_NO;/*无波动*/
		}
		ciToCimDataBuffer[ii++] = chSwitchBDState; /*道岔波动状态*/
	}

	/*发送信号机数据*/

	deviceNum = GetSignalCurSum();
	pSignalData = GetSignalData();
	ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*信号机数量*/
	ii += 2u;
	for (jj = 0u; jj < deviceNum; jj++)/*本联锁和相邻联锁发送给本联锁的信号机总数目*/
	{
		deviceId = GetSignalId(jj);
		/**************打印数据信息****************/

		ShortToChar(pSignalData[deviceId].SignalId, &ciToCimDataBuffer[ii]);/*信号机ID*/
		ii += 2u;
		ciToCimDataBuffer[ii++] = pSignalData[deviceId].CurColor;/*当前显示颜色*/
		ciToCimDataBuffer[ii++] = pSignalData[deviceId].CurDriveColor;/*当前驱动颜色*/
		ciToCimDataBuffer[ii++] = pSignalData[deviceId].CancelDetainBtnErrFlag;/*取消扣车按钮故障标志*/
		ciToCimDataBuffer[ii++] = pSignalData[deviceId].DetainBtnErrFlag;/*扣车按钮故障标志*/
		ciToCimDataBuffer[ii++] = pSignalData[deviceId].RealyDetainFlag;/*硬线扣车标志*/
		chSignalDsState = GetSignalCurBreakFlag(pSignalData[deviceId].SignalId);/*灯丝断丝标志状态*/
		ciToCimDataBuffer[ii++] = chSignalDsState;
	}

	/*************************************发送PSD状态数据********************************************/
	/*发送状态数据*/
	deviceNum = GetPsdSum();
	pPsdData = GetPsdData();
	ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*PSD数量*/
	ii += 2u;
	for (jj = 0u; jj < deviceNum; jj++)/*本联锁和相邻联锁发送给本联锁的Psd总数目*/
	{


		/*比较数据*/
		deviceId = GetPsdId(jj);

		/**************打印数据信息****************/

		ShortToChar(pPsdData[deviceId].PsdId, &ciToCimDataBuffer[ii]);/*PSD ID*/
		ii += 2u;
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].PsdState;/*屏蔽门屏蔽门状态*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].MutualLockRemoveState;/*屏蔽门互锁解除状态*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].DoorButtonState;/*屏蔽门按钮状态*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].doorOpenButtonState;/*站台开门按钮状态*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].doorDepartButtonState;/*站台发车按钮状态*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].PsdRemoraState;/*屏蔽门障碍物状态*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].JXTCMutualLockState;/*间隙探测互锁解除状态*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].StartDetectionState;/*启动探测状态*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].StopDetectionState; /*停止探测状态*/
		ShortToChar(pPsdData[deviceId].SrcVobcId, &ciToCimDataBuffer[ii]);/*操作该屏蔽门的当前VOBC ID*/
		ii += 2u;
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].PsdCmd;/*操作屏蔽门的命令*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].PsdDriveState;/*屏蔽门驱动状态*/

		ciToCimDataBuffer[ii++] = pPsdData[deviceId].clearPassengerFlag;/*ATS是否发送清客标志*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].steadyLightFlag;      /*稳灯标志*/


		ciToCimDataBuffer[ii++] = pPsdData[deviceId].chCleFarePCBButtonState;/*清客确认箱关门按钮状态*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].chCleFarePCBButKeepState;/*清客确认箱关门按钮记忆状态*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].chCleFarePDBFlaLigFlag;/*清客确认箱PDB按钮指示灯闪灯标志*/
		ciToCimDataBuffer[ii++] = pPsdData[deviceId].chVideoQkDriveState; /*视频清客驱动状态*/
		ShortToChar(pPsdData[deviceId].wVideoQkRelateVobcId, &ciToCimDataBuffer[ii]);/*视频清客对应列车ID*/
		ii += 2u;
		ciToCimDataBuffer[ii] = pPsdData[deviceId].cPsdExceptOpenState; /*屏蔽门异常打开状态：0x55-异常打开，0xAA-未异常打开*/
		ii++;

	}

	/*发送状态数据*/
	deviceNum = GetEsbSum();
	pEsbData = GetEsbData();
	ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*ESB数量*/
	ii += 2u;
	for (jj = 0u; jj < deviceNum; jj++)/*本联锁和相邻联锁发送给本联锁的Psd总数目*/
	{


		/*比较数据*/
		deviceId = GetEsbId(jj);

		/**************打印数据信息****************/

		ShortToChar(pEsbData[deviceId].EsbId, &ciToCimDataBuffer[ii]);/*PSD ID*/
		ii += 2u;
		ciToCimDataBuffer[ii++] = pEsbData[deviceId].EsbState;			/*Esb状态*/
		ciToCimDataBuffer[ii++] = pEsbData[deviceId].CutStatus;			/*esb旁路状态*/
		ciToCimDataBuffer[ii++] = pEsbData[deviceId].EssSteadyState;	/*Esb稳灯状态*/
		ciToCimDataBuffer[ii++] = pEsbData[deviceId].EssFlashState;		/*Esb闪灯状态*/


	}

	/*发送状态数据*/
	deviceNum = GetSpksSum();
	pSpksData = GetSpksData();
	ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*SPKS数量*/
	ii += 2u;
	for (jj = 0u; jj < deviceNum; jj++)/*本联锁和相邻联锁发送给本联锁的Psd总数目*/
	{


		/*比较数据*/
		deviceId = GetSpksIdByIndex(jj);

		/**************打印数据信息****************/

		ShortToChar(pSpksData[deviceId].spksId, &ciToCimDataBuffer[ii]);/*SPks ID*/
		ii += 2u;
		ciToCimDataBuffer[ii++] = pSpksData[deviceId].status;			/*Esb状态*/
		ciToCimDataBuffer[ii++] = pSpksData[deviceId].cutStatus;			/*esb旁路状态*/


	}

	/*发送状态数据*/
	deviceNum = GetPhySecCurSum();
	pPhysicalData = GetPhySecData();
	ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*物理区段 数量*/
	ii += 2u;
	for (jj = 0u; jj < deviceNum; jj++)/*本联锁和相邻联锁发送给本联锁的Psd总数目*/
	{
		/*比较数据*/
		deviceId = GetPhySecId(jj);

		/**************打印数据信息****************/

		ShortToChar(pPhysicalData[deviceId].PhysicalSectionId, &ciToCimDataBuffer[ii]);/*物理区段 ID*/
		ii += 2u;
		ciToCimDataBuffer[ii++] = pPhysicalData[deviceId].CurOccupyState;			/*采集占压状态*/
		ciToCimDataBuffer[ii++] = pPhysicalData[deviceId].cAreaUrgentBrakeState;	/*紧急制动状态*/

		ciToCimDataBuffer[ii++] = GetPhySecRelLogSecExistArb(pPhysicalData[deviceId].PhysicalSectionId);/*物理区段ARB状态*/

	}

	/*************************************打印洗车机数据********************************************/
	/*打印洗车机数据*/
	pWashMachineData = GetWashMachineData();
	deviceNum = GetWashMachineSum();
	ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*洗车机数量*/
	ii += 2u;
	for (jj = 0u; jj < deviceNum; jj++)
	{


		/*比较数据*/
		deviceId = GetWashMachineId(jj);

		/**************打印数据信息****************/

		ShortToChar(pWashMachineData[deviceId].WashMachineId, &ciToCimDataBuffer[ii]);/*洗车机ID*/
		ii += 2u;
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].WashMachineReadyState;/*洗车机就绪状态*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].WashMachineRequestVerifyState;/*洗车机请求确认状态*/

		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].TrainEmergencyStopState;/*列车紧急停车状态*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].HeadWashAllowState;/*允许车头清洗状态*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].TailWashAllowState;/*允许车尾清洗状态*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].TrainOutWashTrainPortAllowState;/*允许出洗车库状态*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].WashTrainRequestDrvState;/*洗车请求驱动状态*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].TrainHeadStopSteadyDrvState;/*车头停稳驱动状态*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].TrainTailStopSteadyDrvState;/*车尾停稳驱动状态*/
		ii += 2u;

		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].PauseTrainWashRequestDrvState;/*暂停洗车请求驱动状态(动态字段:驱动)*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].PaseWashMachineRequesDrvtState;/*通过洗车机请求驱动状态(动态字段:驱动)*/

		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].WashMachineWorkModeDrvtState;/*洗车机工作模式设置驱动状态(动态字段:驱动)*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].WashModeState;/*洗车模式(动态字段:采集)*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].chSetWashWorkModeBack;/*设置洗车机工作模式反馈*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].chDownWashAllowState;/*降级模式洗车同意状态(动态字段:采集)*/
		ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].chDownWashAllowPassState;/*降级模式洗车同意通过状态(动态字段:采集)*/

	}


	/*************************************打印车库门数据********************************************/
	/*打印车库门数据*/
	deviceNum = GetGaragedoorSum();
	pGrageDoorData = GetGaragedoorData();
	ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*车库门数量*/
	ii += 2u;
	for (jj = 0u; jj < deviceNum; jj++)
	{

		deviceId = GetGaragedoorId(jj);

		/**************打印数据信息****************/

		ShortToChar(pGrageDoorData[deviceId].GaragedoorId, &ciToCimDataBuffer[ii]);/*车库门ID (初始化字段)*/
		ii += 2u;
		ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GaragedoorState;      /*车库门状态 (动态字段)*/
		ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GaragedoorAllowCloseFlag; /*车库门允许关门标志 ZC*/
		ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GDAllowCloseFlagIVOC; /*车库门允许关门标志 IVOC*/
		ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GaragedoorModeState;       /*车库门模式状态*/
		ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GaragedoorFaultState;	/*车库门故障状态*/
		ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GaragedoorPangLuState;    /*车库门旁路状态*/;
		ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].drvDoorState;				/* 驱动车库门状态*/
		ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].cmdProcessState;			/* 命令处理状态 */
		LongToChar(pGrageDoorData[deviceId].waiteZCResponseStartCycNum, &ciToCimDataBuffer[ii]);/* 等待ZC反馈开始时间 */
		ii += 4u;
		LongToChar(pGrageDoorData[deviceId].waiteIVOCResponseStartCycNum, &ciToCimDataBuffer[ii]);/* 等待IVOC反馈开始时间 */
		ii += 4u;
		LongToChar(pGrageDoorData[deviceId].GaragedoorOpenStartCycNum, &ciToCimDataBuffer[ii]);/* 车库门打开开始周期 */
		ii += 4u;
		LongToChar(pGrageDoorData[deviceId].GaragedoorCloseStartCycNum, &ciToCimDataBuffer[ii]);/* 车库门关闭开始周期 */
		ii += 4u;
	}


	/*打印防淹门数据*/
	deviceNum = GetFloodGateCurSum();
	pFloodGateData = GetFloodGateData();
	ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*防淹门数量*/
	ii += 2u;
	for (jj = 0u; jj < deviceNum; jj++)
	{

		/*比较数据*/
		deviceId = GetFloodGateId(jj);

		/**************打印数据信息****************/

		ShortToChar(pFloodGateData[deviceId].FloodGateId, &ciToCimDataBuffer[ii]);/*防淹门ID (初始化字段)*/
		ii += 2u;
		ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].CurOpenLockStateFromFYM;      /*当前开门且锁闭状态 (动态字段)*/
		ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].CurCloseRequestStateFromFYM; /*当前关门请求状态*/
		if ((FLOOD_GATE_CLOSEREQ == pFloodGateData[deviceId].CurCloseRequestStateFromFYM) && (0U < pFloodGateData[deviceId].CurFloodGateDelayCloseStartCyc) && (RC_WORK_MODE_CI == cRcWorkMode))
		{
			ciToCimDataBuffer[ii++] = 0x55;				/*CI向ZC发送防淹门关门申请*/
		}
		else
		{
			ciToCimDataBuffer[ii++] = 0xaa;				/*未申请*/
		}
		ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].CurAgreeCloseAckFromZC;	/*当前zc回复关门许可状态*/
		ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].CurAgreeCloseStateIn;		/*当前同意关门采集状态*/;
		ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].CurAgreeCloseStateOut;	/* 当前同意关门输出状态（动态字段）*/
		LongToChar(pFloodGateData[deviceId].CurFloodGateDelayCloseStartCyc, &ciToCimDataBuffer[ii]);/* 防淹门接近区段占压延时关门开始时间 */
		ii += 4u;
		ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].FloodGateCloseApplyIvocSum;  /*防淹门关门申请列车数量*/
		ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].FloodGateCloseAnsIvocSum;   /*防淹门关门允许，列车回复数量*/
		ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].FloodGateAccessUTFlag;   /*防淹门接近区段是否有非通信车标志*/


	}
	/*发送CIM*/
	debug_infor_printf((const)"\nCIM_SEND_DEVSTATE:%d", ii);
	debug_out_array(0xAA, ciToCimDataBuffer, ii);
	(void)DarkInfoPack(CIM_INFO_DEVICE_STATE, ciToCimDataBuffer, ii);

}



/*
* 功能描述： 输出AIM数据
* 参数说明：AIM输出信息组帧函数
* 返回值  ： 无
*/
void AIMOutput(void)
{
	UINT16  wQueueIndex = 0U;                 /*输出数组下标*/
	UINT16  wQueueCountTemp = 0U;             /*组帧长度*/
	UINT8  g_szAIMOut[CI_TO_AIM_DATA_LEN_MAX] = {0u};                                             /*AIM输出数据组帧数组*/
	
	/*初始化AIM输出数组*/
	(void)memset(&g_szAIMOut[0], 0xff, CI_TO_AIM_DATA_LEN_MAX);

	wQueueCountTemp = Deploy_PackToAIMInfo(&g_szAIMOut[0], CI_TO_AIM_DATA_LEN_MAX);

	if (0U != wQueueCountTemp)
	{
		wQueueIndex += wQueueCountTemp;
		/******************下面是填写安全通信协议（SFP）相关信息***************************/
		/*调用ProtocolInfoSend函数，根据协议配置类型，写入对应的输出队列*/
		ProtocolInfoSend((UINT8)((DEVICE_TYPE_AIM >> 8U) & 0x00ffU), (UINT8)(DEVICE_TYPE_AIM & 0x00ffU), g_szAIMOut, wQueueIndex);

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

/*
* 功能描述： 输出AIM数据
* 参数说明：  
 * @param[in]	UINT8 chDevType			目标设备类型
 * @param[in]	UINT8 chDevID			目标设备ID
 * @param[in]	UINT8 g_szOutBuffer[]	实际数据输出首地址
 * @param[in]	UINT16 wLength			实际数据长度
* 返回值  ： 无
*
*/
void ProtocolInfoSend(UINT8 chDevType, UINT8 chDevID, UINT8 g_szOutBuffer[], UINT16 wLength)
{
	/*- 初始化 */
	UINT16 logicId = 0u;
	UINT16 DataTypeAndId = (UINT16)((UINT16)chDevType << 8U) + (UINT16)chDevID;
	UINT8* pLocalPointer = NULL;                                    /*控制类型转换的的局部指针*/
	UINT8  g_TempOutBuffer[CI_TO_AIM_DATA_LEN_MAX] = { 0U };             /*临时缓冲区*/


	/** 非VOBC数据 逻辑ID为默认值 */
	logicId = 0U;

	/*- 初始化局部buff*/
	(void)memset(&g_TempOutBuffer[0u], 0, sizeof(UINT8) * CI_TO_AIM_DATA_LEN_MAX);

	/*- 调用SFP协议组包，发送*/
	pLocalPointer = &g_TempOutBuffer[0u];
	ShortToChar((UINT16)(wLength + 4u), pLocalPointer);

	/*将安全通信协议（SFP）预留的字节填写为保留值*/
	/*- 填写目标设备类型及ID */
	g_TempOutBuffer[2] = chDevType;
	g_TempOutBuffer[3] = chDevID;

	/*填写设备逻辑类型恒比码 数据代码分离 用宏值表示*/
	/** 填写设备逻辑ID */
	ShortToChar(logicId, &g_TempOutBuffer[4]);

	/** 拷贝实际数据*/
	(void)memcpy(&g_TempOutBuffer[6], &g_szOutBuffer[0u], (UINT32)wLength);

	/** QNX */
#if (kPLATFORM==kVXWORKS)
	if ((UINT8)((DEVICE_TYPE_AIM >> 8U) & 0x00ff) == chDevType)
	{
		(void)InnetSafeSend(DataTypeAndId, logicId, g_szOutBuffer, wLength);
		debug_infor_printf((const)"\nAIM_SEND:%d", wLength);
		debug_out_array(0xAA, g_szOutBuffer, wLength);
	}
	else
	{
		(void)OutnetSafeSend(DataTypeAndId, logicId, g_szOutBuffer, wLength);
	}
#if 0
	/*- 打印输出*/
	ZC_QNX_Printf(chFlag, chDevType, chDevID, wLength + 6u, g_TempOutBuffer);
#endif

#endif
}

/*
* 功能描述： 组包发送执行单元报警信息
* 参数说明： void
* 返回值  ： 无
*
*/
void PackCiToCimUnitAlarmData(void)
{
	/*变量初始化*/
	UINT16 ii = 0u;
	UINT16 jj = 0u;
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u };
	UINT8 wPbNum = 0u;			/*执行电插箱数量*/
	UINT8 kk = 0u;                                                                              /*游标*/
	UINT8 mm = 0U;
	UINT16 nn = 0U;
	UINT16 ocId = 0u;
	UINT16 ocDeviceSum = 0u;/*OC设备总数*/
	UINT8* pOcDeviceIdBuf = NULL;         /*OC设备ID数组*/
	OcToATSPlusBox szSendAIMPlusBox[MAX_OC_PLUS_BOX_NUM] = { 0U };	/*输出给ATS的执行电插箱结构体相关信息,组给维护机的执行单元信息和给ATS的一样，调用ATS的结构体*/
	OcToATSSwitchZzjData szSendAIMSwitchZzjData[SWITCH_SUM_MAX] = { 0U };  /*发送给AIM的多机牵引道岔数据*/
	UINT16 wSwitchNum = 0U;  /*多机牵引道岔数量*/

	ocDeviceSum = (UINT16)GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_OC);     /*获取通信OC设备总数*/
	pOcDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC); /*获取通信OC设备ID数组*/

	ShortToChar(ocDeviceSum, &ciToCimDataBuffer[ii]);  /*OC数量总长度*/
	ii += 2u;

	if (NULL != pOcDeviceIdBuf)
	{
		for (jj = 0u; jj < ocDeviceSum; jj++)/*遍历所有通信的oc*/
		{
			ocId = pOcDeviceIdBuf[jj];					/*获取OC ID*/

			wPbNum = 0U;								/*在组OC前先清除电插箱数量，防止将同一集中区另一个OC数据组入*/

			if (0U != ocId)
			{
				ShortToChar(ocId, &ciToCimDataBuffer[ii]);  /*OC的ID*/
				ii += 2u;

				for (kk = 0u; kk < m_OcToCiOrginDataNum; kk++)
				{
					if (NULL != m_OcToCiOrginDataArr)
					{
						if (m_OcToCiOrginDataArr[kk].OcId == ocId)/*有通信，能找到，就赋值*/
						{
							wPbNum = TransCiToAtsOCPlusBoxInfo(szSendAIMPlusBox, &kk);  /*OCbyte执行电插箱接口转换,组给AIM的信息和组给ATS数据信息一样，调用此转换函数*/
							wSwitchNum = TransCiToAtsSwitchZzjInfo(szSendAIMSwitchZzjData, &kk);  /*获取发送给AIM的多机牵引道岔数据*/
						}
						else
						{

						}
					}
					else
					{
					}
				}

				ciToCimDataBuffer[ii++] = wPbNum;		/*组执行电插箱数量,若数据无效只组数量，若数量为0，也只组数量*/
				if (MAX_OC_PLUS_BOX_NUM >= wPbNum)
				{
					for (mm = 0u; mm < wPbNum; mm++)
					{
						ciToCimDataBuffer[ii++] = szSendAIMPlusBox[mm].chPbId;		/*组执行电插箱编号*/
						ciToCimDataBuffer[ii++] = szSendAIMPlusBox[mm].SendAtsAsState;		/*组报警类型*/
					}
				}
				
				if (SWITCH_SUM_MAX > wSwitchNum)
				{
					ShortToChar(wSwitchNum, &ciToCimDataBuffer[ii]);  /*组多机牵引道岔数量*/
					ii += 2U;

					for (nn = 0U; nn < wSwitchNum; nn++)
					{
						ShortToChar(szSendAIMSwitchZzjData[nn].wSwitchId, &ciToCimDataBuffer[ii]);  /*组双机牵引道岔的ID*/
						ii += 2U;

						if (MAX_OC_SWITCH_INCLUDE_ZZJ_NUM >= szSendAIMSwitchZzjData[nn].chSwIncludeZzjSum)
						{
							ciToCimDataBuffer[ii++] = szSendAIMSwitchZzjData[nn].chSwIncludeZzjSum;  /*组多机牵引道岔的转辙机数量*/
							for (mm = 0U; mm < szSendAIMSwitchZzjData[nn].chSwIncludeZzjSum; mm++)
							{
								ciToCimDataBuffer[ii++] = szSendAIMSwitchZzjData[nn].szSwitchIncldeZzjState[mm];  /*组多机牵引道岔的转辙机状态*/
							}
						}
						else
						{
							ciToCimDataBuffer[ii++] = 0U;  /*若数量超限，则组多机牵引道岔的转辙机数量为0*/
						}
					}
				}
				else 
				{
					ShortToChar(0U, &ciToCimDataBuffer[ii]);  /*若数量超限，则组多机牵引道岔数量为0*/
					ii += 2U;
				}
			}
			else
			{
			}
		}
	}
	else
	{
	}
	/*发送CIM*/
	(void)DarkInfoPack(CIM_INFO_UNIT_ALARM, ciToCimDataBuffer, ii);

}



/*
* 功能描述：解析平台通控心跳帧报文
* 参数说明：UINT8* datdaBuff：心跳数据缓存
*          UINT32 dataLength  心跳帧长度
* 返回值  ：CI_ERROR 解析失败
*          CI_SUCCESS 解析成功
* BY LC
*/
UINT8 ParasePlantCCUHeartFrame(UINT8* dataBuf)
{
	UINT8 retVal = CI_ERROR;
	UINT32 ii = 0U;
	UINT32 crcCheck = 0U;

	UINT8 boardCCId = 0U;/*通控板ID */
	UINT16 dataLengthRcv = 0U; /*帧长度*/
	UINT32 cycCount = 0U; 
	UINT16 volA = 0U;
	UINT16 volB = 0U;
	UINT16 curA = 0U;
	UINT16 curB = 0U;
	UINT16 volCoup = 0U;
	UINT16 curCoup = 0U;
	UINT32 tempera = 0U;
	UINT8 flagEEPROM = 0U;
	UINT32 crcRecv = 0U;
	
	/*接收到平台心跳帧*/
	if (dataBuf != NULL)
	{
		retVal = CI_SUCCESS;

		/*包内数据长度*/
		dataLengthRcv = ShortFromChar(&dataBuf[ii]);
		ii += 2u;

		/*板卡ID*/
		boardCCId = dataBuf[ii];
		ii += 1u;
		/*数据周期号*/
		cycCount= LongFromChar(&dataBuf[ii]);
		ii += 4u;
		/*24VA电源电压*/
		volA= ShortFromChar(&dataBuf[ii]);
		ii += 2u;
		/*24VB电源电压*/
		volB = ShortFromChar(&dataBuf[ii]);
		ii += 2u;
		/*24VA电源电流*/
		curA = ShortFromChar(&dataBuf[ii]);
		ii += 2u;
		/*24VB电源电流*/
		curB = ShortFromChar(&dataBuf[ii]);
		ii += 2u;
		/*24V电源耦合电压*/
		volCoup = ShortFromChar(&dataBuf[ii]);
		ii += 2u;
		/*24V电源耦合电流*/
		curCoup = ShortFromChar(&dataBuf[ii]);
		ii += 2u;
		/*温度*/
		tempera = LongFromChar(&dataBuf[ii]);
		ii += 4u;
		/*EEPROM存储检验*/
		flagEEPROM = dataBuf[ii];
		ii += 1u;
		/*CRC校验码*/
		crcRecv = LongFromChar(&dataBuf[ii]);		/*获取CRC*/
		ii += 4u;

		/*长度校验*/
		if (dataLengthRcv == ii - 2U)
		{

			/*计算CRC校验码,除长度2和CRC4*/
			crcCheck = Tioc_PlatCommonCrc32(&dataBuf[2], 22U);

			
			if (crcCheck == crcRecv)
			{
				/*校验通过*/
			}
			else
			{
				/*CRC校验失败*/
				retVal = CI_ERROR;
				debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:CRC Check Error, RecvCRC:%d, CalCRC:%d", boardCCId, crcRecv, crcCheck);
			}

		}
		else
		{
			/*长度校验失败*/
			retVal = CI_ERROR;
			debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:Length Check Error, RecvLength:%d, RealLength:%d", boardCCId, dataLengthRcv, ii - 2U);
		}

		
		if (CI_SUCCESS == retVal)
		{
			/*CCUA 通控红网*/
			if (0x09U == boardCCId)
			{
				RecvHeartDataStru.voltageA_CCA = volA;
				RecvHeartDataStru.voltageB_CCA = volB;
				RecvHeartDataStru.currentA_CCA = curA;
				RecvHeartDataStru.currentB_CCA = curB;
				RecvHeartDataStru.voltageCoup_CCA = volCoup;
				RecvHeartDataStru.currentCoup_CCA = curCoup;
				RecvHeartDataStru.temperature_CCA = tempera;
				RecvHeartDataStru.check_EEPROM_CCA = flagEEPROM;

				/*记录通信周期*/
				RecvHeartDataStru.commStartCycle_CCA = Get2oo2CurCycleNum();
			}
			/*CCUB 通控蓝网*/
			else if (0x0CU == boardCCId)
			{
				RecvHeartDataStru.voltageA_CCB = volA;
				RecvHeartDataStru.voltageB_CCB = volB;
				RecvHeartDataStru.currentA_CCB = curA;
				RecvHeartDataStru.currentB_CCB = curB;
				RecvHeartDataStru.voltageCoup_CCB = volCoup;
				RecvHeartDataStru.currentCoup_CCB = curCoup;
				RecvHeartDataStru.temperature_CCB = tempera;
				RecvHeartDataStru.check_EEPROM_CCB = flagEEPROM;

				/*记录通信周期*/
				RecvHeartDataStru.commStartCycle_CCB = Get2oo2CurCycleNum();
			}
			else
			{
				/*板卡ID校验错误*/
				retVal = CI_ERROR;
				debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:BoradId Check Error", boardCCId);
			}
		}
		else
		{
			/*解析失败，数据不存入*/
		}
			
	}
	else
	{
		/*解析失败*/
	}

	return retVal;
}

/*
* 功能描述：解析平台扩展板心跳帧报文
* 参数说明：UINT8* datdaBuff：心跳数据缓存
*          UINT32 dataLength  心跳帧长度
* 返回值  ：void
* BY LC
*/
UINT8 ParasePlantSEBHeartFrame(UINT8* dataBuf)
{
	UINT8 retVal = CI_ERROR;
	UINT32 ii = 0U;
	UINT32 crcCheck = 0U;

	UINT8 boardSEBId = 0U;/*扩展板ID */
	UINT16 dataLengthRcv = 0U; /*帧长度*/
	UINT32 crcRecv = 0U;  /*CRC校验码*/
	UINT32 rcvCyc = 0U;  /*周期号*/
	/*接收到平台心跳帧*/
	if (dataBuf != NULL)
	{
		retVal = CI_SUCCESS;

		/*包内数据长度*/
		dataLengthRcv = ShortFromChar(&dataBuf[ii]);
		ii += 2u;


		/*板卡ID*/
		boardSEBId = dataBuf[ii];
		ii += 1u;

		/*周期号*/
		rcvCyc = LongFromChar(&dataBuf[ii]);
		ii += 4U;

		/*数据内容 3字节*/
		ii += 5U;


		/*CRC校验码*/
		crcRecv = LongFromChar(&dataBuf[ii]);		/*获取CRC*/
		ii += 4u;

		/*长度校验*/  /*总长度16字节*/
		if (dataLengthRcv == ii - 2U)
		{

			/*计算CRC校验码,除长度2和CRC4*/
			crcCheck = Tioc_PlatCommonCrc32(&dataBuf[2], 10U);


			if (crcCheck == crcRecv)
			{
				/*校验通过*/
				
			}
			else
			{
				/*CRC校验失败*/
				retVal = CI_ERROR;
				debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:CRC Check Error, RecvCRC:%d, CalCRC:%d", boardSEBId, crcRecv, crcCheck);
			}

		}
		else
		{
			/*长度校验失败*/
			retVal = CI_ERROR;
			debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:Length Check Error, RecvLength:%d, RealLength:%d", boardSEBId, dataLengthRcv, ii - 2U);
		}

		if (CI_SUCCESS == retVal)
		{
			/*SEB1*/
			if (BOARD_TYPE_SEBA == boardSEBId)
			{
				/*记录通信周期*/
				RecvHeartDataStru.commStartCycle_SEBA = Get2oo2CurCycleNum();
			}
			/*SEB2*/
			else if (BOARD_TYPE_SEBB == boardSEBId)
			{
				
				/*记录通信周期*/
				RecvHeartDataStru.commStartCycle_SEBB = Get2oo2CurCycleNum();
			}
			else
			{
				/*板卡ID校验错误*/
				retVal = CI_ERROR;
				debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:BoradId Check Error", boardSEBId);
			}
		}
		else
		{
			/*解析失败，数据不存入*/
		}

	}
	else
	{
		/*解析失败*/
	}


	return retVal;
}

/*
* 功能描述：平台心跳帧报文处理
* 参数说明：无
* 返回值  ：无
* BY LC
*/
UINT8 PlatHeartFrameProcess(void)
{
	UINT8 retVal = CI_ERROR;
	UINT8 heartData_CC1[HEART_FRAME_MAX_LENGTH] = { 0u };  /*CC1心跳帧数据*/
	UINT8 heartData_CC2[HEART_FRAME_MAX_LENGTH] = { 0u };  /*CC2心跳帧数据*/
	UINT8 heartData_SEB1[HEART_FRAME_MAX_LENGTH] = { 0u };  /*SEB1心跳帧数据*/
	UINT8 heartData_SEB2[HEART_FRAME_MAX_LENGTH] = { 0u };  /*SEB2心跳帧数据*/
	UINT8 platFlag = CI_ERROR;  /*真机/仿真运行标志*/

	UINT8 commFlag_CC1 = CI_ERROR;/*与CC1通信正常标志*/
	UINT8 commFlag_CC2 = CI_ERROR;/*与CC2通信正常标志*/
	UINT8 commFlag_SEB1 = CI_ERROR;/*与SEB1通信正常标志*/
	UINT8 commFlag_SEB2 = CI_ERROR;/*与SEB2通信正常标志*/

	UINT32 commCyc_CC1 = 0U;
	UINT32 commCyc_CC2 = 0U;
	UINT32 commCyc_SEB1 = 0U;
	UINT32 commCyc_SEB2 = 0U;

	UINT32 curCycNum = 0U;
	
#if (kPLATFORM == kVXWORKS)
	platFlag = CI_SUCCESS;
#endif

	/*真机模式下 处理平台心跳帧*/
	if (CI_SUCCESS == platFlag)
	{
		retVal = CI_SUCCESS;
		curCycNum = Get2oo2CurCycleNum();

		/*获取本周期平台发送的心跳帧报文*/
		InnetHeartFrameRecv(&heartData_CC1, &heartData_CC2, &heartData_SEB1, &heartData_SEB2, &commFlag_CC1, &commFlag_CC2, &commFlag_SEB1, &commFlag_SEB2);

		debug_infor_printf((const)"\ncommFlag_CC1 %d", commFlag_CC1);
		debug_infor_printf((const)"\ncommFlag_CC2 %d", commFlag_CC2);
		debug_infor_printf((const)"\ncommFlag_SEB1 %d", commFlag_SEB1);
		debug_infor_printf((const)"\ncommFlag_SEB2 %d", commFlag_SEB2);

		/*解析CC1心跳帧*/
		if (CI_SUCCESS == commFlag_CC1)
		{
			commFlag_CC1 = ParasePlantCCUHeartFrame(&heartData_CC1);
			debug_infor_printf((const)"\nCC1_RECV HeartFrame:");
			debug_out_array(0xAA, heartData_CC1, HEART_FRAME_REAL_LENGTH);
		}
		else
		{
			retVal = CI_ERROR;
		}
		/*解析CC2心跳帧*/
		if (CI_SUCCESS == commFlag_CC2)
		{
			commFlag_CC2 = ParasePlantCCUHeartFrame(&heartData_CC2);
			debug_infor_printf((const)"\nCC2_RECV HeartFrame:");
			debug_out_array(0xAA, heartData_CC2, HEART_FRAME_REAL_LENGTH);
		}
		else
		{
			retVal = CI_ERROR;
		}
		/*解析SEB1心跳帧*/
		if (CI_SUCCESS == commFlag_SEB1)
		{
			commFlag_SEB1 = ParasePlantSEBHeartFrame(&heartData_SEB1);
			debug_infor_printf((const)"\nSEB1_RECV HeartFrame:");
			debug_out_array(0xAA, heartData_SEB1, HEART_FRAME_REAL_LENGTH);
		}
		else
		{
			retVal = CI_ERROR;
		}
		/*解析SEB2心跳帧*/
		if (CI_SUCCESS == commFlag_SEB2)
		{
			commFlag_SEB2 = ParasePlantSEBHeartFrame(&heartData_SEB2);
			debug_infor_printf((const)"\nSEB2_RECV HeartFrame:");
			debug_out_array(0xAA, heartData_SEB2, HEART_FRAME_REAL_LENGTH);
		}
		else
		{
			retVal = CI_ERROR;
		}




		/*判断CC1通信状态*/
		commCyc_CC1 = GetRCIandCCBoardCommCyCNum(BOARD_TYPE_CCUA);
		if ((CCU_CommBadEnsureTime_CycleCount < (curCycNum - commCyc_CC1))
			&& (CI_ERROR == commFlag_CC1))
		{
			SetRCIandCCBoardCommStatus(BOARD_TYPE_CCUA, CCU_COMMSTATUS_BAD);
			ClearnCCUHeartData(BOARD_TYPE_CCUA);
			debug_infor_printf((const)"\nCC1 And RCI CommState is Bad");
		}
		else
		{
			SetRCIandCCBoardCommStatus(BOARD_TYPE_CCUA, CCU_COMMSTATUS_GOOD);
			debug_infor_printf((const)"\nCC1 And RCI CommState is Good");
			

		}

		/*判断CC2通信状态*/
		commCyc_CC2 = GetRCIandCCBoardCommCyCNum(BOARD_TYPE_CCUB);
		if ((CCU_CommBadEnsureTime_CycleCount < (curCycNum - commCyc_CC2))
			&& (CI_ERROR == commFlag_CC2))
		{
			SetRCIandCCBoardCommStatus(BOARD_TYPE_CCUB, CCU_COMMSTATUS_BAD);
			ClearnCCUHeartData(BOARD_TYPE_CCUB);
			debug_infor_printf((const)"\nCC2 And RCI CommState is Bad ");
		}
		else
		{
			SetRCIandCCBoardCommStatus(BOARD_TYPE_CCUB, CCU_COMMSTATUS_GOOD);
			debug_infor_printf((const)"\nCC2 And RCI CommState is Good ");
			
		}

		/*判断SEB1通信状态*/
		commCyc_SEB1 = GetRCIandCCBoardCommCyCNum(BOARD_TYPE_SEBA);
		if ((CCU_CommBadEnsureTime_CycleCount < (curCycNum - commCyc_SEB1))
			&& (CI_ERROR == commFlag_SEB1))
		{
			SetRCIandCCBoardCommStatus(BOARD_TYPE_SEBA, CCU_COMMSTATUS_BAD);
			ClearnCCUHeartData(BOARD_TYPE_SEBA);
			debug_infor_printf((const)"\nSEB1 And RCI CommState is Bad");
		}
		else
		{
			SetRCIandCCBoardCommStatus(BOARD_TYPE_SEBA, CCU_COMMSTATUS_GOOD);
			debug_infor_printf((const)"\nSEB1 And RCI CommState is Good");


		}
		/*判断SEB2通信状态*/
		commCyc_SEB2 = GetRCIandCCBoardCommCyCNum(BOARD_TYPE_SEBB);
		if ((CCU_CommBadEnsureTime_CycleCount < (curCycNum - commCyc_SEB2))
			&& (CI_ERROR == commFlag_SEB2))
		{
			SetRCIandCCBoardCommStatus(BOARD_TYPE_SEBB, CCU_COMMSTATUS_BAD);
			ClearnCCUHeartData(BOARD_TYPE_SEBB);
			debug_infor_printf((const)"\nSEB2 And RCI CommState is Bad");
		}
		else
		{
			SetRCIandCCBoardCommStatus(BOARD_TYPE_SEBB, CCU_COMMSTATUS_GOOD);
			debug_infor_printf((const)"\nSEB2 And RCI CommState is Good");
		}
	}
	else
	{
		/*仿真模式，将心跳帧数值设为正常值,不报警*/
		SetCCUHeartDataNormal();
		retVal = CI_SUCCESS;
	}
	return retVal;
}

/*
* 功能描述：平台IO数据处理（当前设置预留）
* 参数说明：无
* 返回值  ：CI_ERROR 处理失败
*          CI_SUCCESS 处理成功
* BY LC
*/
void PlatChannelIODataProcess(void)
{

	UINT8 platFlag = CI_ERROR;  /*真机/仿真运行标志*/
	UINT8 retVal = CI_ERROR;
	UINT8 ioDataBuff[IO_DATA_DATA_LENGTH] = { 0U };

#if (kPLATFORM == kVXWORKS)
	platFlag = CI_SUCCESS;
#endif

	/*真机模式下 获取IO状态数据*/
	if (CI_SUCCESS == platFlag)
	{
		retVal = InnetChannelIODataRecv(&ioDataBuff);

		/*此周期未成功接收到IO数据*/
		if (CI_ERROR == retVal)
		{
			/*设置所有IO采集状态为故障*/
			(void)CommonMemSet(&ioDataBuff, IO_DATA_DATA_LENGTH, 0U, IO_DATA_LENGTH);
		}
		else
		{
			/*解析IO状态数据*/
			ParasePlantIOData(&ioDataBuff);
		}

	}
	else
	{
		/*仿真模式，将GPIO数据设为正常值,不报警*/
		SetCCUPlatGPIODataNormal();
	}

}

/*
* 功能描述：解析平台IO状态数据
* 参数说明：UINT8* datdaBuff：IO数据缓存
* 返回值  ：无
* BY LC
*/
void ParasePlantIOData(UINT8* dataBuf)
{
	UINT8 powerANode_PUA = 0U;            /*A系采集 A系电源插箱的空开辅助触点状态*/
	UINT8 powerBNode_PUA = 0U;            /*A系采集 B系电源插箱的空开辅助触点状态*/
	UINT8 ModepowerAState_PUA = 0U;           /*机柜A系电源插箱中为CPUA供电的24VDC电源模块状态*/
	UINT8 ModepowerBState_PUA = 0U;            /*机柜B系电源插箱中为CPUA供电的24VDC电源模块状态*/

	UINT8 powerANode_PUB = 0U;            /*B系采集 A系电源插箱的空开辅助触点状态*/
	UINT8 powerBNode_PUB = 0U;            /*B系采集 B系电源插箱的空开辅助触点状态*/
	UINT8 ModepowerAState_PUB = 0U;            /*机柜A系电源插箱中为CPUB供电的24VDC电源模块状态*/
	UINT8 ModepowerBState_PUB = 0U;            /*机柜B系电源插箱中为CPUB供电的24VDC电源模块状态*/

	if (NULL != dataBuf)
	{
		powerANode_PUA = dataBuf[0] & dataBuf[4];
		ModepowerAState_PUA = dataBuf[1] & dataBuf[5];
		powerBNode_PUA = dataBuf[2] & dataBuf[6];
		ModepowerBState_PUA = dataBuf[3] & dataBuf[7];

		powerANode_PUB = dataBuf[8] & dataBuf[12];
		ModepowerAState_PUB = dataBuf[9] & dataBuf[13];
		powerBNode_PUB = dataBuf[10] & dataBuf[14];
		ModepowerBState_PUB = dataBuf[11] & dataBuf[15];

		/*A系电源插箱的空开辅助触点状态  00：故障 01：正常*/
		if (0x01U == (powerANode_PUA & powerANode_PUB))
		{
			RecvPlatDataStruGPIO.powerANodeState = NODE_STATUS_CLOSE;
		}
		else
		{
			RecvPlatDataStruGPIO.powerANodeState = NODE_STATUS_BREAK;
		}
		/*B系电源插箱的空开辅助触点状态  00：故障 01：正常*/
		if (0x01U == (powerBNode_PUA & powerBNode_PUB))
		{
			RecvPlatDataStruGPIO.powerBNodeState = NODE_STATUS_CLOSE;
		}
		else
		{
			RecvPlatDataStruGPIO.powerBNodeState = NODE_STATUS_BREAK;
		}
		/*机柜A系电源插箱中为CPUA供电的24VDC电源模块状态  00：故障 01：正常*/
		if (0x01U == ModepowerAState_PUA)
		{
			RecvPlatDataStruGPIO.ModepowerAState_PUA = POWER_STATUS_NORMAL;
		}
		else
		{
			RecvPlatDataStruGPIO.ModepowerAState_PUA = POWER_STATUS_ABNORMAL;
		}
		/*机柜B系电源插箱中为CPUA供电的24VDC电源模块状态  00：故障 01：正常*/
		if (0x01U == ModepowerBState_PUA)
		{
			RecvPlatDataStruGPIO.ModepowerBState_PUA = POWER_STATUS_NORMAL;
		}
		else
		{
			RecvPlatDataStruGPIO.ModepowerBState_PUA = POWER_STATUS_ABNORMAL;
		}
		/*机柜A系电源插箱中为CPUB供电的24VDC电源模块状态  00：故障 01：正常*/
		if (0x01U == ModepowerAState_PUB)
		{
			RecvPlatDataStruGPIO.ModepowerAState_PUB = POWER_STATUS_NORMAL;
		}
		else
		{
			RecvPlatDataStruGPIO.ModepowerAState_PUB = POWER_STATUS_ABNORMAL;
		}
		/*机柜B系电源插箱中为CPUB供电的24VDC电源模块状态  00：故障 01：正常*/
		if (0x01U == ModepowerBState_PUB)
		{
			RecvPlatDataStruGPIO.ModepowerBState_PUB = POWER_STATUS_NORMAL;
		}
		else
		{
			RecvPlatDataStruGPIO.ModepowerBState_PUB = POWER_STATUS_ABNORMAL;
		}


	}
	else
	{
		/*不处理*/
	}

}

/*
* 功能描述： 组包发送CIM飞车报警状态信息
* 参数说明： void
* 返回值  ： 无
* BY fan 20241021
*/
void PackCiToCimFlyProtectData(void)
{
	/*变量初始化*/
	UINT16 ii = 0u;
	UINT8 jj = 0U;
	UINT8 chIndex = 0U;
	UINT8 chFlyTrainNum = 0U;  /*报警列车数量*/
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0U };
	UINT16 wTrainId = 0U;
	UINT32 dwTrainId = 0U;	/*互联互通列车编号*/
	TrainFlyProtectStru * pFlyData = NULL;
	UINT8 TrainFlyAxis = 0U; /*飞车计轴*/
	chFlyTrainNum = GetFlyProtectNum();
	if (SHUT_DOWN_TRAIN_NUMMAX < chFlyTrainNum)
	{
		chFlyTrainNum = SHUT_DOWN_TRAIN_NUMMAX;
	}
	ciToCimDataBuffer[ii++] = chFlyTrainNum;
	for (chIndex = 0U; chIndex < chFlyTrainNum; chIndex++)
	{
		pFlyData = GetFlyProtectData(chIndex);
		wTrainId = pFlyData->wTrainId;
		TrainFlyAxis = pFlyData->flyProtectSecCnt;
		(void)dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U) + wTrainId, 0U, &dwTrainId); /*两字节列车ID转换为4字节互联互通ID*/
		LongToChar(dwTrainId, &ciToCimDataBuffer[ii]);		/* 列车ID */
		ii += 4u;

		if (TRAIN_FLYALARM_SECNUM_MAX < TrainFlyAxis)
		{
			TrainFlyAxis = TRAIN_FLYALARM_SECNUM_MAX;
		}
		ciToCimDataBuffer[ii++] = TrainFlyAxis;			/* 计轴数量 */
		for (jj = 0U; jj < TrainFlyAxis; jj++)
		{
			ShortToChar(pFlyData->flyProtectSec[jj], &ciToCimDataBuffer[ii]);
			ii += 2u;
		}
	}

	/*发送维护机*/
	(void)DarkInfoPack(CIM_INFO_FLYPROTECT_ALARM, ciToCimDataBuffer, ii);

}

/*
* 功能描述： 组包发送CIM双系IO采集不一致信息
* 参数说明： void
* 返回值  ： 无
*/
void PackCiToCimCollDiffData(void)
{
	/*变量初始化*/
	UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0U };
	UINT16 ii = 0u;
	UINT8 jj = 0u;
	UINT8 kk = 0u;
	UINT8 diffPointSum = 0u;/*每个OC的不一致点位数*/
	IODiffDataStruct* tempDiffData = NULL;

	tempDiffData = GetIODiffData();/*获取比较不一致的数据*/

	ciToCimDataBuffer[ii++] = gDiffDataOcNum;

	if (NULL != tempDiffData)
	{
		for (jj = 0u; jj < OC_SUM_MAX; jj++)
		{/*遍历每个OC*/
			diffPointSum = tempDiffData[jj].DiffPointNum;/*不一致的点位数*/
			if (0u < diffPointSum)
			{
				ciToCimDataBuffer[ii++] = tempDiffData[jj].OcId;/*OC id*/

				ciToCimDataBuffer[ii++] = diffPointSum;

				for (kk = 0u; kk < diffPointSum; kk++)
				{/*遍历不一致的点位*/
					ciToCimDataBuffer[ii++] = tempDiffData[jj].LocalBoardAdd[kk];	/*不一致点位对应的板卡地址*/
					ciToCimDataBuffer[ii++] = tempDiffData[jj].OtherBoardAdd[kk];	/*对系的板卡地址*/
					ciToCimDataBuffer[ii++] = tempDiffData[jj].TheDiffPoint[kk];	/*点位*/
				}
			}
			else
			{/*没有不一致点位，不处理*/
			}

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

	debug_infor_printf((const)"IO Compare Diff OCnum = %d\n", gDiffDataOcNum);
	debug_out_array(0xAA, ciToCimDataBuffer, ii);

	/*发送维护机*/
	(void)DarkInfoPack(CIM_INFO_IO_COLL_DIFF_ALARM, ciToCimDataBuffer, ii);
}