#include "CollectMaster485.h"
#include "KeySlave485.h"
#include "TerminalSlave485.h"
#include "usart.h"	
#include "Data_deal.h"
#include "spi.h"
#include "Dwin.h"
#include "ScreenMaster485.h"
#include<math.h>
#include<stdlib.h>

extern uint16_t  bufTextCang01_IO[];
extern uint16_t  bufTextCang02_IO[];
extern uint8_t  Cang01_IO[64];
extern uint8_t  Cang02_IO[64];
extern uint8_t  Cang03_IO[64];
extern uint8_t  Cang04_IO[64];	
extern uint8_t  Cang05_IO[64];
extern uint8_t  Cang06_IO[64];
extern uint8_t  Cang07_IO[64];
extern uint8_t  Cang08_IO[64];		



#include "cmsis_os.h"
uint16_t Usart2_ErrorTimes=0,chkRetCaiJiBan;
static int cnt000=0,CangNum000;//计数器，每间隔3秒读取一次模拟量类传感器数据；每间隔1秒读取一次阀门数据;//
uint16_t CRC_data,CRC_dataCaiJiBan;//;
uint8_t StoreNumber00=1;//实际读取的仓号的阀门信息	

uint8_t  Array_IO_OnOff_AllStore[32];
uint8_t  Array_IO_Exception_AllStore[32];


#define MaxGuanGao		 (1831)


//2021jan20根据实际罐容，下调26mm=131+26


//#define LeiDaOffset		 (-157)     //0(-157)   -131
#define LeiDaOffset		 0  //(-131)     //0(-157)   -131


////////////////////////////////////////////////////////////////////////////////// 
#define dataLengthIn    USART2_RX_BUF[3]


//02功能码的子功能，传奇种类
#define Read_Press           0x01
#define Read_YeWei           0x02
#define Read_Temper          0x03
#define Read_QingJiao        0x04

#define Filter_NUM 8    //滤波器的点数，建议为8，可以为8~32之间的任何数字

//用于滤波的雷达液位计的原始数据，单位为米m,正常范围应该在0.08--1.831之间
//空仓液位大约在1831mm，雷达盲区大约80mm
float LeiDaArr[33];
float ArrOfTempeSensor_Flo[3];//三点式温度传感器的数据
float Zero_Of_LiquidMeter[8];//8个仓的雷达液位计零点参数
float Zero_Of_TankCapacity[8];//8个仓的罐容表零点参数

uint8_t USART2_RX_BUF_Collector[Uart2_BUF_SIZE];
uint8_t ValStateArr_0x13[64],ValStateArr_PoFeng_0x13[64];//破封时的阀门状态
uint8_t ValStateArr_0x20[64],ValStateArr_PoFeng_0x20[64];//破封时的阀门状态

uint8_t ValStateArr_0x20_Cang01[64],ValStateArr_PoFeng_0x20_Cang01[64];//破封时的阀门状态
uint8_t ValStateArr_0x20_Cang02[64],ValStateArr_PoFeng_0x20_Cang02[64];//破封时的阀门状态
uint8_t ValStateArr_0x20_Cang03[64],ValStateArr_PoFeng_0x20_Cang03[64];//破封时的阀门状态
uint8_t ValStateArr_0x20_Cang04[64],ValStateArr_PoFeng_0x20_Cang04[64];//破封时的阀门状态


//20210129李伟修改---增加一个全局数组用于保存8个仓的阀门状态（按照平台的位定义协议进行组包）
uint8_t Array_Of_Valve[32];//
//20210129李伟修改  -----从采集器读取的8个阀门的状态,对应于原来的采集器的8仓；
//对应于平台解析的1--4号阀门状态（每仓4个阀门，最多32个阀门）
uint8_t ValState01[8]; //ValState02,ValState03,ValState04,ValState05,ValState06,ValState07,ValState08;
uint8_t Val_4Bit_H,Val_4Bit_L;//高四位与低四位

uint32_t IO_OnOff_State01=0,IO_OnOff_State02=0,IO_OnOff_State03=0,IO_OnOff_State04=0;
uint32_t IO_Exception_State01=0,IO_Exception_State02=0,IO_Exception_State03=0,IO_Exception_State04=0;


uint32_t IO_OnOff_StateArr[4];//
uint32_t IO_Exception_StateArr[4];//,IO_Exception_State02=0,IO_Exception_State03=0,IO_Exception_State04=0;



//20210201李伟修改---增加一个全局数组用于上传按下打印键之后的车辆状态
//具体详见<控制器平台通信协议增加20210126李伟修改回传数据格式.xlsx>
uint8_t Array_Of_Tank_0x64[68];//

//李伟修改   20210729  
uint8_t Array_Of_IO_0xA1[64];//
int LenRx_0xA1=16;  

STOR_TypeDef Stor[8];
STatetemp_TypeDef Statetemp,Fg;
Collect485_TypeDef Collect485;
Calibrat_TypeDef  PlatformCalibrat;
uint8_t Pneumatic_PR1=0 ;
uint8_t Pneumatic_PR2=0 ;  
uint8_t Pneumatic_PR3=0 ;
uint8_t Pneumatic_PR4=0 ;
uint8_t StoreNumber=3,all_Store=3;

uint8_t CabinetNumForWenYou=0;//默认选择第一个仓的液位计用作稳油判断

//uint8_t HaiDiFa001=0x00;//8个海底阀的状态
//uint8_t XieYouFa001=0x00;//8个泄油阀的状态
//uint8_t ManHole_CoverBig001=0x00;//8个人孔大盖的状态
//uint8_t ManHole_CoverSmall001=0x00;//8个人孔小盖的状态
 
uni_IncliAngle uni_IncliAngle001;
uni_TankVol_Tempe20 uni_TankVol_Tempe20_001,uni_TankVol_Tempe20_002,uni_TempRealtime001;
uni_TankVol_Realtime uni_TankVol_Realtime001,uni_TankVol_Realtime002,uni_TankVol_Realtime003,uni_TankVol_Realtime004;
uni_temper uni_temper001,uni_temper002,uni_temper003,uni_temper004;
uni_QingJiao uni_QingJiao001,uni_QingJiao002;
uni_LiqLev uni_LiqLev001,uni_LiqLev002,uni_LiqLev003,uni_LiqLev004;//4个仓位的液位高度数据
uni_GasPressure uni_GasPressure001;
uni_OilWeight uni_OilWeight001;

uni_OilDensity uni_OilDensity001;
uni_LeiDaYewei uni_LeiDaYewei001;
int16_t yewei003;

uni_Float ArrayUni_MoniLiang[64];

//发往平台的数据  
uni_YeweiToPlatForm uni_YeweiToPlatForm001,uni_YeweiToPlatForm002,uni_YeweiToPlatForm003,uni_YeweiToPlatForm004;
uni_TempToPlatForm uni_TempToPlatForm001,uni_TempToPlatForm002;

//李伟修改    队尾的3个数据依次为最大值,最小值,峰峰值
float ArrYeweiForWenyou[NumOf_WenYouPanduan+3];//存储300s的液位数据    打印的时候作为是否稳油判断依据
float Yewei_max000,Yewei_min000,Yewei_peak000;

void TestUsart2_Receive(void)
{
	if(usart2_rx_flag)
	{
		usart2_rx_flag=0;
		CollectMaster485_Send_Data(USART2_RX_BUF,rx2_len);
	}
}
//RS485发送len个字节.
//buf:发送区首地址
//len:发送的字节数
uint8_t uart2_buf[1024];
void CollectMaster485_Send_Data(uint8_t *buf,uint16_t len)
{
	int retry;
	//while(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_1)==GPIO_PIN_RESET)
	for(retry=0;retry<50;++retry)
	{
		if(huart2.gState == HAL_UART_STATE_READY)
			break;
		osDelay(10);
	}
	if(retry>=50)
		return;
	CollectMaster485_TX_Set(1);			//设置为发送模式
	HAL_Delay(2);
	if(len>1024)
		len=1024;
	memcpy(uart2_buf,buf,len);
    //HAL_UART_Transmit(&huart2,buf,len,1000);//串口2发送数据 
	if(HAL_UART_Transmit_IT(&huart2,uart2_buf,len)!=HAL_OK)
	{
		CollectMaster485_TX_Set(0);			//设置为接收模式	
	}
		
}

//RS485模式控制.
//en:0,接收;1,发送.
void CollectMaster485_TX_Set(uint8_t en)
{
	if(en==1)HAL_GPIO_WritePin(GPIOA,GPIO_PIN_1,GPIO_PIN_RESET);
	else HAL_GPIO_WritePin(GPIOA,GPIO_PIN_1,GPIO_PIN_SET);

}

#if 1
void PreProcess_GetValveStatus(uint8_t* big_cover, uint8_t* small_cover, uint8_t* seavalve, uint8_t* unloadvalve)
{
	int i=0;
	ValState01[0]=Collect485.ValveState_Num1;//采集器的1仓
	ValState01[1]=Collect485.ValveState_Num2;//采集器的2仓
	ValState01[2]=Collect485.ValveState_Num3;//采集器的3仓
	ValState01[3]=Collect485.ValveState_Num4;//采集器的4仓
	ValState01[4]=Collect485.ValveState_Num5;//采集器的5仓
	ValState01[5]=Collect485.ValveState_Num6;//采集器的6仓
	ValState01[6]=Collect485.ValveState_Num7;//采集器的7仓
	ValState01[7]=Collect485.ValveState_Num8;//采集器的8仓

	for(i=0; i<Config_info_all.All_number; i++){
		if(ValState01[i]&GPIO_PIN_0){
			*big_cover |= (0X01 << i);
		}

		if(ValState01[i]&GPIO_PIN_1){
			*small_cover |= (0X01 << i);
		}

		if(ValState01[i]&GPIO_PIN_2){
			*seavalve |= (0X01 << i);
		}

		if(ValState01[i]&GPIO_PIN_3){
			*unloadvalve |= (0X01 << i);
		}
	}


}
#else 
//RS485模式控制.
//将阀门状态按照0x91的规格进行打包。有效数据32字节
//
/*
	大盖、小盖、底阀、卸油阀主界面的状态显示
	zhuzl added 2021-12-15
*/
void ValStateConvertTo91(void)
{
	uint8_t HaiDiFa002 = 0x00;			  // 8个海底阀的状态
	uint8_t XieYouFa002 = 0x00;			  // 8个泄油阀的状态
	uint8_t ManHole_CoverBig002 = 0x00;	  // 8个人孔大盖的状态
	uint8_t ManHole_CoverSmall002 = 0x00; // 8个人孔小盖的状态
	// 20210129李伟修改，将阀门状态按照1月9日的会议决议进行组包。
	// USART2_RX_BUF[5];-----	1仓大盖、小盖、底阀、卸油阀状态:

	//	Array_Of_Valve[0]=0;
	//	Array_Of_Valve[4]=0;
	//	memset(Array_Of_Valve,0x00,32);//清除残留数据
  
	//获取采集板传来的原始阀门状态，具体顺序为：bit0--bit3对应于大小底卸的开关状态；bit4--bit7对应于大小底卸的异常状态；
#if  0	
	ValState01=USART2_RX_BUF[5];//采集器的1仓
	ValState02=USART2_RX_BUF[7];//采集器的2仓
	ValState03=USART2_RX_BUF[9];//采集器的3仓
	ValState04=USART2_RX_BUF[11];//采集器的4仓
	ValState05=USART2_RX_BUF[13];//采集器的5仓
	ValState06=USART2_RX_BUF[15];//采集器的6仓
	ValState07=USART2_RX_BUF[17];//采集器的7仓
	ValState08=USART2_RX_BUF[19];//采集器的8仓
#else
	ValState01=Collect485.ValveState_Num1;//采集器的1仓
	ValState02=Collect485.ValveState_Num2;//采集器的2仓
	ValState03=Collect485.ValveState_Num3;//采集器的3仓
	ValState04=Collect485.ValveState_Num4;//采集器的4仓
	ValState05=Collect485.ValveState_Num5;//采集器的5仓
	ValState06=Collect485.ValveState_Num6;//采集器的6仓
	ValState07=Collect485.ValveState_Num7;//采集器的7仓
	ValState08=Collect485.ValveState_Num8;//采集器的8仓
#endif	
	
	//人孔大盖数据合成为一个字节
	ManHole_CoverBig002=0x00;
	if(ValState01 & GPIO_PIN_0)
	{
		ManHole_CoverBig002=ManHole_CoverBig002| GPIO_PIN_0;
	}
	
	if(ValState02 & GPIO_PIN_0)
	{
		ManHole_CoverBig002=ManHole_CoverBig002| GPIO_PIN_1;
	}
	
	if(ValState03 & GPIO_PIN_0)
	{
		ManHole_CoverBig002=ManHole_CoverBig002| GPIO_PIN_2;
	}
	
	if(ValState04 & GPIO_PIN_0)
	{
		ManHole_CoverBig002=ManHole_CoverBig002| GPIO_PIN_3;
	}
	
	if(ValState05 & GPIO_PIN_0)
	{
		ManHole_CoverBig002=ManHole_CoverBig002| GPIO_PIN_4;
	}
	
	if(ValState06 & GPIO_PIN_0)
	{
		ManHole_CoverBig002=ManHole_CoverBig002| GPIO_PIN_5;
	}
	
	if(ValState07 & GPIO_PIN_0)
	{
		ManHole_CoverBig002=ManHole_CoverBig002| GPIO_PIN_6;
	}
	
	if(ValState08 & GPIO_PIN_0)
	{
		ManHole_CoverBig002=ManHole_CoverBig002| GPIO_PIN_7;
	}
	if(ManHole_CoverBig002!=ManHole_CoverBig001)
	{
		ManHole_CoverBig001=ManHole_CoverBig002;
		WrDwinCmd16(0x1003,ManHole_CoverBig001);//人孔大盖状态刷新
	}
	
	
	//人孔小盖数据合成为一个字节
	ManHole_CoverSmall002=0x00;
	if(ValState01 & GPIO_PIN_1)
	{
		ManHole_CoverSmall002=ManHole_CoverSmall002| GPIO_PIN_0;
	}
	
	if(ValState02 & GPIO_PIN_1)
	{
		ManHole_CoverSmall002=ManHole_CoverSmall002| GPIO_PIN_1;
	}
	
	if(ValState03 & GPIO_PIN_1)
	{
		ManHole_CoverSmall002=ManHole_CoverSmall002| GPIO_PIN_2;
	}
	
	if(ValState04 & GPIO_PIN_1)
	{
		ManHole_CoverSmall002=ManHole_CoverSmall002| GPIO_PIN_3;
	}
	
	if(ValState05 & GPIO_PIN_1)
	{
		ManHole_CoverSmall002=ManHole_CoverSmall002| GPIO_PIN_4;
	}
	
	if(ValState06 & GPIO_PIN_1)
	{
		ManHole_CoverSmall002=ManHole_CoverSmall002| GPIO_PIN_5;
	}
	
	if(ValState07 & GPIO_PIN_1)
	{
		ManHole_CoverSmall002=ManHole_CoverSmall002| GPIO_PIN_6;
	}
	
	if(ValState08 & GPIO_PIN_1)
	{
		ManHole_CoverSmall002=ManHole_CoverSmall002| GPIO_PIN_7;
	}
	if(ManHole_CoverSmall002!=ManHole_CoverSmall001)
	{
		ManHole_CoverSmall001=ManHole_CoverSmall002;
		WrDwinCmd16(0x1000,ManHole_CoverSmall001);//人孔小盖状态刷新
	}
	
	
	
	
	
	
	//海底阀数据合成为一个字节
	HaiDiFa002=0x00;
	if(ValState01 & GPIO_PIN_2)
	{
		HaiDiFa002=HaiDiFa002| GPIO_PIN_0;
	}
	
	if(ValState02 & GPIO_PIN_2)
	{
		HaiDiFa002=HaiDiFa002| GPIO_PIN_1;
	}
	
	if(ValState03 & GPIO_PIN_2)
	{
		HaiDiFa002=HaiDiFa002| GPIO_PIN_2;
	}
	
	if(ValState04 & GPIO_PIN_2)
	{
		HaiDiFa002=HaiDiFa002| GPIO_PIN_3;
	}
	
	if(ValState05 & GPIO_PIN_2)
	{
		HaiDiFa002=HaiDiFa002| GPIO_PIN_4;
	}
	
	if(ValState06 & GPIO_PIN_2)
	{
		HaiDiFa002=HaiDiFa002| GPIO_PIN_5;
	}
	
	if(ValState07 & GPIO_PIN_2)
	{
		HaiDiFa002=HaiDiFa002| GPIO_PIN_6;
	}
	
	if(ValState08 & GPIO_PIN_2)
	{
		HaiDiFa002=HaiDiFa002| GPIO_PIN_7;
	}
	if(HaiDiFa002!=HaiDiFa001)
	{
		HaiDiFa001=HaiDiFa002;
		WrDwinCmd16(ADDR_DWIN_HaiDiFa,HaiDiFa001);//海底阀状态刷新
	}
	
	
	
	//卸油阀数据合成为一个字节
	XieYouFa002=0x00;
	if(ValState01 & GPIO_PIN_3)
	{
		XieYouFa002=XieYouFa002| GPIO_PIN_0;
	}
	
	if(ValState02 & GPIO_PIN_3)
	{
		XieYouFa002=XieYouFa002| GPIO_PIN_1;
	}
	
	if(ValState03 & GPIO_PIN_3)
	{
		XieYouFa002=XieYouFa002| GPIO_PIN_2;
	}
	
	if(ValState04 & GPIO_PIN_3)
	{
		XieYouFa002=XieYouFa002| GPIO_PIN_3;
	}
	
	if(ValState05 & GPIO_PIN_3)
	{
		XieYouFa002=XieYouFa002| GPIO_PIN_4;
	}
	
	if(ValState06 & GPIO_PIN_3)
	{
		XieYouFa002=XieYouFa002| GPIO_PIN_5;
	}
	
	if(ValState07 & GPIO_PIN_3)
	{
		XieYouFa002=XieYouFa002| GPIO_PIN_6;
	}
	
	if(ValState08 & GPIO_PIN_3)
	{
		XieYouFa002=XieYouFa002| GPIO_PIN_7;
	}
	if(XieYouFa002!=XieYouFa001)
	{
		XieYouFa001=XieYouFa002;
		WrDwinCmd16(ADDR_DWIN_XieYouFa,XieYouFa001);//泄油阀状态刷新  WrDwinCmd16(0x1009,c);//卸油阀关
	}
	
			//-----------------------------------------------------1号传感器结束，只实现了第1仓，剩下7仓未实现
     //李伟修改 20210206     根据上午会议讨论，1仓位置与7仓位置交换------结束
}

#endif 
uint32_t a1_cnt  = 0;
#include "Elec_Seal.h"
uint16_t CheckInFrame_Collect485(uint16_t LenRx,uint16_t MsgID)
{
	uint16_t DataReturn;
	uint16_t CRC_data,CRC_data02;//;
	int i007;
	int retry;

//	float sum001;
	uint8_t TempData;//,TmpValState00,TmpValState01;
	for(retry=0;retry<25;++retry)
	{
		if(usart2_rx_flag==True)
			break;
		osDelay(15);
	}
	if(usart2_rx_flag==True)
	{
		usart2_rx_flag=False;
		TempData=USART2_RX_BUF[2];
		//DataReturn=USART2_RX_BUF[2];
		DataReturn=(USART2_RX_BUF[8]<<8)+USART2_RX_BUF[9]; //zzl 发送缓冲区返回数据标识?疑问

		if((Collector_Get_Valve_OldFormat==MsgID) ||(Collector_Get_Valve_State==MsgID))
		{
			DataReturn=USART2_RX_BUF[2];
		}
		
		CRC_data=CRC16_MODBUS(USART2_RX_BUF, LenRx-2);//总长度为64字节   前边的62字节计算crc
		//CRC_data02=(USART2_RX_BUF[62]<<8) +USART2_RX_BUF[63];//来自控制板的CRC
		CRC_data02=(USART2_RX_BUF[LenRx-2]<<8) +USART2_RX_BUF[LenRx-1];//来自控制板的CRC
		
		if(CRC_data==CRC_data02)
		{
			memcpy(USART2_RX_BUF_Collector,USART2_RX_BUF,sizeof(USART2_RX_BUF));		
		}

#if 0		
		if((CRC_data==CRC_data02) && (DataReturn==0x1121))
		{
				memcpy(USART2_RX_BUF_Collector,USART2_RX_BUF,sizeof(USART2_RX_BUF));
				__NOP();
		}
#endif				
		
		
		if((USART2_RX_BUF[0]==FrameHeader_Collect&&USART2_RX_BUF[1]==EquipmentNum_Collect) &&(CRC_data==CRC_data02))
		{//最初版本的协议AA 00为帧头
#if 0		
			//CRC_data=CRC16_MODBUS(USART2_RX_BUF, dataLengthIn + 4);
			CRC_data=CRC16_MODBUS(USART2_RX_BUF, LenRx-2);//总长度为64字节   前边的62字节计算crc
 			//CRC_data02=(USART2_RX_BUF[62]<<8) +USART2_RX_BUF[63];//来自控制板的CRC
			CRC_data02=(USART2_RX_BUF[LenRx-2]<<8) +USART2_RX_BUF[LenRx-1];//来自控制板的CRC
			
			//if((CRC_data==CRC_data02) && (DataReturn==0x1121))
			{
					memcpy(USART2_RX_BUF_Collector,USART2_RX_BUF,sizeof(USART2_RX_BUF));
			}		
			
			__nop();//
#endif			
			switch(TempData)
			{////////switch(TempData)--开始
				case 0xA1://Read All Valve State 阀门状态   底阀监测器   卸油阀
				{	
					//CRC_data=CRC16_MODBUS(USART2_RX_BUF, 17+ 4);//dataLengthIn
					//__nop();
				
				 // LenRx_0xA1=LenRx;
				  a1_cnt++;
				  memcpy(Array_Of_IO_0xA1,USART2_RX_BUF,64);
				
					//__nop();
				  
				 //如果保留校验则大约30秒才能成功一次，所以去掉了校验
					//if(CRC_data==((USART2_RX_BUF[dataLengthIn+4]<<8)+USART2_RX_BUF[dataLengthIn+5]))
				  //if(1) //20210207   李伟修改    校验失误率很高所以去掉校验  后期需要重新查明原因
					//if(CRC_data==((USART2_RX_BUF[dataLengthIn+5]<<8)+USART2_RX_BUF[dataLengthIn+4]))
					//if(CRC_data==(((uint16_t)USART2_RX_BUF[22]<<8)+(uint16_t)USART2_RX_BUF[21]))  //固定位置
					//if(CRC_data==CRC_data02)
					{
						Collect485.ErrorCode_Collect= USART2_RX_BUF[4];
						//__nop();
					
						Collect485.ValveState_Num1  = USART2_RX_BUF[5]; //开关状态 大小人孔盖，底泄阀状态
						Collect485.UnloadState_Num1 = USART2_RX_BUF[6]; //油仓油尽状态
						
						Collect485.ValveState_Num2  = USART2_RX_BUF[7];
						Collect485.UnloadState_Num2 = USART2_RX_BUF[8];
						
						Collect485.ValveState_Num3  = USART2_RX_BUF[9];
						Collect485.UnloadState_Num3 =USART2_RX_BUF[10];
						
						Collect485.ValveState_Num4  =USART2_RX_BUF[11];
						Collect485.UnloadState_Num4 =USART2_RX_BUF[12];
						
						Collect485.ValveState_Num5  =USART2_RX_BUF[13];
						Collect485.UnloadState_Num5 =USART2_RX_BUF[14];
						
						Collect485.ValveState_Num6  =USART2_RX_BUF[15];
						Collect485.UnloadState_Num6 =USART2_RX_BUF[16];
						
						Collect485.ValveState_Num7  =USART2_RX_BUF[17];
						Collect485.UnloadState_Num7 =USART2_RX_BUF[18];
						
						Collect485.ValveState_Num8  =USART2_RX_BUF[19];
						Collect485.UnloadState_Num8 =USART2_RX_BUF[20];
						//HAL_GPIO_TogglePin(GPIOE,LED1_Pin);
						
						//ValStateConvertTo91(); 
						
						
					//	__nop();
						
					}

				}break;
				case 0xA2://Read Needed Sensor Value
				{	switch(USART2_RX_BUF[4])
					{
						case 1://Press expressed volume   体积  容积    
							//if(CRC_data==((USART2_RX_BUF[dataLengthIn+4]<<8)+USART2_RX_BUF[dataLengthIn+5]))
						//if(CRC_data==CRC_data02)
							{
								Stor[0].Volume=((USART2_RX_BUF[5]<<8)|USART2_RX_BUF[6]);
								Stor[1].Volume=((USART2_RX_BUF[7]<<8)|USART2_RX_BUF[8]);
								Stor[2].Volume=((USART2_RX_BUF[9]<<8)|USART2_RX_BUF[10]);
								Stor[3].Volume=((USART2_RX_BUF[11]<<8)|USART2_RX_BUF[12]);
								Stor[4].Volume=((USART2_RX_BUF[13]<<8)|USART2_RX_BUF[14]);
								Stor[5].Volume=((USART2_RX_BUF[15]<<8)|USART2_RX_BUF[16]);
								Stor[6].Volume=((USART2_RX_BUF[17]<<8)|USART2_RX_BUF[18]);
								Stor[7].Volume=((USART2_RX_BUF[19]<<8)|USART2_RX_BUF[20]);
								//uni_TankVol_Tempe20_001.flo_Data=Stor[0].Volume;  //调试用
								
								
								uni_TankVol_Realtime001.flo_Data=Stor[0].Volume;
								uni_TankVol_Realtime002.flo_Data=Stor[1].Volume;
								uni_TankVol_Realtime003.flo_Data=Stor[2].Volume;
								uni_TankVol_Realtime004.flo_Data=Stor[3].Volume;
								
								
//								if((pT2C_SetupData->Reserved_parameters_4>1.5f) || (pT2C_SetupData->Reserved_parameters_4<0.2f))
//								{//Reserved_parameters_4==2.0 使用采集器传来的Vt   体积
//								    
//									
//								}else

//								{
//									  uni_TankVol_Realtime001.flo_Data=pT2C_SetupData->Capacity_Vt;	//采用平台下发数据
//								}
//								
								
							}
							break;
						case 2://yewei  液位
							
						  // if(CRC_data==((USART2_RX_BUF[dataLengthIn+4]<<8)+USART2_RX_BUF[dataLengthIn+5]))
							{
								
								if(TypeOf_YeWeiJi==0x01)//磁致伸缩液位计
								{
									Stor[0].yewei[0]=(USART2_RX_BUF[5]<<8)|USART2_RX_BUF[6];
									Stor[1].yewei[0]=(USART2_RX_BUF[7]<<8)|USART2_RX_BUF[8];
									Stor[2].yewei[0]=(USART2_RX_BUF[9]<<8)|USART2_RX_BUF[10];
									Stor[3].yewei[0]=(USART2_RX_BUF[11]<<8)|USART2_RX_BUF[12];
									Stor[4].yewei[0]=(USART2_RX_BUF[13]<<8)|USART2_RX_BUF[14];
									Stor[5].yewei[0]=(USART2_RX_BUF[15]<<8)|USART2_RX_BUF[16];
									Stor[6].yewei[0]=(USART2_RX_BUF[17]<<8)|USART2_RX_BUF[18];
									Stor[7].yewei[0]=(USART2_RX_BUF[19]<<8)|USART2_RX_BUF[20];	
								}
								else if(TypeOf_YeWeiJi==0x02)//02————雷达液位计
								{
									
									Stor[0].yewei[0]=(USART2_RX_BUF[5]<<8)|USART2_RX_BUF[6];
									Stor[1].yewei[0]=(USART2_RX_BUF[7]<<8)|USART2_RX_BUF[8];
 
									Stor[2].yewei[0]=(USART2_RX_BUF[9]<<8)|USART2_RX_BUF[10];
									Stor[3].yewei[0]=(USART2_RX_BUF[11]<<8)|USART2_RX_BUF[12];
									Stor[4].yewei[0]=(USART2_RX_BUF[13]<<8)|USART2_RX_BUF[14];
									Stor[5].yewei[0]=(USART2_RX_BUF[15]<<8)|USART2_RX_BUF[16];
									Stor[6].yewei[0]=(USART2_RX_BUF[17]<<8)|USART2_RX_BUF[18];
									Stor[7].yewei[0]=(USART2_RX_BUF[19]<<8)|USART2_RX_BUF[20];	
								}
								else
								{
									Stor[0].yewei[0]=(USART2_RX_BUF[5]<<8)|USART2_RX_BUF[6];
									Stor[1].yewei[0]=(USART2_RX_BUF[7]<<8)|USART2_RX_BUF[8];
									Stor[2].yewei[0]=(USART2_RX_BUF[9]<<8)|USART2_RX_BUF[10];
									Stor[3].yewei[0]=(USART2_RX_BUF[11]<<8)|USART2_RX_BUF[12];
									Stor[4].yewei[0]=(USART2_RX_BUF[13]<<8)|USART2_RX_BUF[14];
									Stor[5].yewei[0]=(USART2_RX_BUF[15]<<8)|USART2_RX_BUF[16];
									Stor[6].yewei[0]=(USART2_RX_BUF[17]<<8)|USART2_RX_BUF[18];
									Stor[7].yewei[0]=(USART2_RX_BUF[19]<<8)|USART2_RX_BUF[20];	
								}
								
								
								
								//20210305液位精度数据保留一位小数，精度为0.1mm    李伟修改
 
								for(i007=0;i007<8;i007++)
								{
									Stor[i007].yewei_flo[0]=Stor[i007].yewei[0]*SCL_Yewei_Collect2Contr;//
								}
								 
						
                uni_YeweiToPlatForm001.flo_Data=Stor[0].yewei_flo[0];//yewei[0]*SCL_Yewei_Collect2Contr;
 
								
								uni_LiqLev001.flo_Data=Stor[0].yewei_flo[0];//yewei[0]*SCL_Yewei_Collect2Contr;
								uni_LiqLev002.flo_Data=Stor[1].yewei_flo[0];
								uni_LiqLev003.flo_Data=Stor[2].yewei_flo[0];
								uni_LiqLev004.flo_Data=Stor[3].yewei_flo[0];
															
								//UpdateWenYouFifo();//稳油判断数据更新							
								
							}
							 
							
							break;
						case 3://Temppreture  温度   温度传感器

							//CRC_data=CRC16_MODBUS(USART2_RX_BUF, 16+5);//dataLengthIn
							//if(CRC_data==((USART2_RX_BUF[21]<<8)+USART2_RX_BUF[22]))
							//if(1)
							{	//温度参数校验开始	
						
						  //三个温度传感器的数据依次为罐车中的高中低——也就是先发送最短的探杆，接着中间的探杆，最后是最长的探杆
						  //20201216；16位有符号整型数据
						  Stor[0].Temperature=(signed short)((USART2_RX_BUF[5]<<8)|USART2_RX_BUF[6]);
							Stor[1].Temperature=(signed short)((USART2_RX_BUF[7]<<8)|USART2_RX_BUF[8]);
							Stor[2].Temperature=(signed short)((USART2_RX_BUF[9]<<8)|USART2_RX_BUF[10]);
							Stor[3].Temperature=(signed short)((USART2_RX_BUF[11]<<8)|USART2_RX_BUF[12]);
							Stor[4].Temperature=(signed short)((USART2_RX_BUF[13]<<8)|USART2_RX_BUF[14]);
							Stor[5].Temperature=(signed short)((USART2_RX_BUF[15]<<8)|USART2_RX_BUF[16]);
							Stor[6].Temperature=(signed short)((USART2_RX_BUF[17]<<8)|USART2_RX_BUF[18]);
							Stor[7].Temperature=(signed short)((USART2_RX_BUF[19]<<8)|USART2_RX_BUF[20]);
						
						
						//20210226同康达林商量之后，决定：温度传感器的解析在采集器完成但是不用除以10，直接以int16格式发给控制器
						//因为考虑到温度精度最好达到0.1度，所以采集器不用除以10，除以10的操作放在控制器上实现
						//李伟修改20210226
						for(i007=0;i007<8;i007++)
						{
							Stor[i007].Temperature=Stor[i007].Temperature*SCL_Temp_Collect2Contr;//
						}	 				
						 
						uni_temper001.flo_Data=Stor[0].Temperature;//默认取第一个温度传感器的数据
													//李伟修改  20210428  根据平台下发的命令的p3参数决定取哪一个温度作为体积修正的 参考
							if(fabs(pT2C_SetupData->Reserved_parameters_3-1.0f)<0.2f)
							{
							
								uni_temper001.flo_Data=Stor[0].Temperature;//默认取第一个温度传感器的数据
							}
							
							if(fabs(pT2C_SetupData->Reserved_parameters_3-2.0f)<0.2f)
							{
							
								uni_temper001.flo_Data=Stor[1].Temperature;//取第2个温度传感器的数据
							}
							
							if(fabs(pT2C_SetupData->Reserved_parameters_3-3.0f)<0.2f)
							{
							
								uni_temper001.flo_Data=Stor[2].Temperature;//取第3个温度传感器的数据
							}
							 
 	
						if(fabs(pT2C_SetupData->Reserved_parameters_4-1.0f)<0.2f)  
						{//Reserved_parameters_4==1.0 使用平台上手工输入的温度
							 uni_temper001.flo_Data=pT2C_SetupData->temperature;//uni_TempRealtime001.flo_Data;
								
						}
							
						//按键输入温度的xx分钟之内，强制取值为键盘输入的温度
						if(tmrForTemp_ManualInput>5)
						{
							 uni_temper001.flo_Data=uni_TempRealtime001.flo_Data;
												
						}
							
							 
   
							uni_temper001.flo_Data=uni_temper001.flo_Data*SCL_Air_To_Oil;
							 
							 
							if(TypeOf_YeWeiJi==0x02)//雷达液位计的0808车，将其补偿为65度左右
							{
								
								//如果柴油车的温度大于10度则判定为装油，而且装的是0#柴油，需要加热。
								///*
								if(uni_temper001.flo_Data>9.99f)
								{
									 ;//uni_temper001.flo_Data=uni_temper001.flo_Data+Offset_diesel;
								}
								
								//*/
											 
							}							
								
							if(uni_temper001.flo_Data>Max_Oil_Tempe)
							{
								 uni_temper001.flo_Data=Max_Oil_Tempe;//限幅滤波
							
							}
							if(uni_temper001.flo_Data<Min_Oil_Tempe)
							{
								uni_temper001.flo_Data=Min_Oil_Tempe;
							
							}
							
							//第4个参数为1或者3，强制上传平台下发的温度数据
							if((fabs(pT2C_SetupData->Reserved_parameters_4-3.0f)<0.2f  ) ||  \
								(fabs(pT2C_SetupData->Reserved_parameters_4-1.0f)<0.2f)  )
							{
								uni_temper001.flo_Data=pT2C_SetupData->temperature;//temperature;
								Stor[0].Temperature=(signed short)uni_temper001.flo_Data;
								Stor[1].Temperature=(signed short)uni_temper001.flo_Data;
								Stor[2].Temperature=(signed short)uni_temper001.flo_Data;
							
							}
							
							 
							
							//按键输入温度的XX分钟之内，强制取值为键盘输入的温度							
							
							//如果有手工输入则强制采用手工输入温度
							if(tmrForTemp_ManualInput>5)
							{
								uni_temper001.flo_Data=uni_TempRealtime001.flo_Data;
								Stor[0].Temperature=(signed short)uni_temper001.flo_Data;
								
								
								//srand(xTaskGetTickCount());    //gSystickMsecCount这个值是在Systick中断中计数的变量
				
				 
								Stor[1].Temperature=(signed short)uni_temper001.flo_Data+(rand() % 100)*0.001f;;
								Stor[2].Temperature=(signed short)uni_temper001.flo_Data+(rand() % 100)*0.001f;;
								
							}
							
							//三点式温度传感器赋值
							for(i007=0;i007<3;i007++)
							{
								ArrOfTempeSensor_Flo[i007]=Stor[i007].Temperature;//Stor[i007].Temperature*SCL_Temp_Collect2Contr;//
							}
							
						}//温度参数校验结束	
 							
 				
							
							
						  
							break;
						case 4://倾角 角度 
 
						
						
							Stor[0].QingJiao=(int16_t)(((USART2_RX_BUF[5]<<8)|USART2_RX_BUF[6]));
							Stor[1].QingJiao=(int16_t)(((USART2_RX_BUF[7]<<8)|USART2_RX_BUF[8]));
							Stor[2].QingJiao=(int16_t)((USART2_RX_BUF[9]<<8)|USART2_RX_BUF[10]);
							Stor[3].QingJiao=(int16_t)((USART2_RX_BUF[11]<<8)|USART2_RX_BUF[12]);
							Stor[4].QingJiao=(int16_t)((USART2_RX_BUF[13]<<8)|USART2_RX_BUF[14]);
							Stor[5].QingJiao=(int16_t)((USART2_RX_BUF[15]<<8)|USART2_RX_BUF[16]);
							Stor[6].QingJiao=(int16_t)((USART2_RX_BUF[17]<<8)|USART2_RX_BUF[18]);
							Stor[7].QingJiao=(int16_t)((USART2_RX_BUF[19]<<8)|USART2_RX_BUF[20]);
						
						  Stor[0].QingJiaoFlo=(float)(Stor[0].QingJiao*SCL_Angle*1);
							Stor[1].QingJiaoFlo=(float)(Stor[1].QingJiao*SCL_Angle*1);//180/32768;						
						
						
						  uni_QingJiao001.flo_Data=Stor[0].QingJiaoFlo;
							uni_QingJiao002.flo_Data=Stor[1].QingJiaoFlo;
	 				
						
						
			if((uni_QingJiao001.flo_Data>300)  || (uni_QingJiao001.flo_Data<-10))
			{
			
			   ;//uni_QingJiao001.flo_Data=0.34;
			}
							
							break;
						case 5://压力
							Stor[0].Temperature=Switch_Byte4_To_Float(USART2_RX_BUF+4);
							Stor[1].Temperature=Switch_Byte4_To_Float(USART2_RX_BUF+8);
							Stor[2].Temperature=Switch_Byte4_To_Float(USART2_RX_BUF+12);
							Stor[3].Temperature=Switch_Byte4_To_Float(USART2_RX_BUF+16);
						  uni_GasPressure001.flo_Data=Stor[0].Temperature;
						
						
							break;
						default:
							break;
					}
				}	break;
				case 0xA3://Write StoreNum
					Collect485.Write_StorNum=USART2_RX_BUF[4];
					break;
				case 0xA4:
					break;
				case 0xA5:
					break;
				default:
					break;
			}////////switch(TempData)--结束
			
			//memset(USART2_RX_BUF, 0x00, 50);     //清除接收缓存前50个数据
			
		}
		return DataReturn;		
	}
	else
	{
		Usart2_ErrorTimes++;
		return 0;
	}

}

void ReadCollect_ValveState_TX(void)
{////读取阀门状态
	uint16_t CRC_dataTX;
	memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	USART2_TX_BUF[2]=ValveState_Fuction;
	USART2_TX_BUF[3]=0;
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,4);
	USART2_TX_BUF[5]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[4]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,6);
}


/*
采集器按照新的协议发送64字节给控制板
AA 00 10 01 01 FD 8D
最后两个字节为CRC校验

5个参数分别为：
功能码，读取寄存器或者写入寄存器---取自国标只能为0003、0006或者0010
寄存器起始地址----实际代表操作某一个外设，比如卸油阀或者海底阀、人孔盖等
寄存器个数,后边3个参数的总字节数，不包括校验位
附加码1，仓号或者传感器的485地址；读取阀门数据时的附加参数，表示仓位编号、卸油阀的485地址、外购传感器的485地址等数据
附加码2，设置卸油阀门限参数时的ADC等

*/
void ReadCollect_ValveState_64Byte(uint16_t para001_RegOP_Code,uint16_t para002_RegAddrStart,
	            uint16_t para003_RegNum,uint16_t para004_LegacyAddr,uint16_t para005_Fujia001)
{
	uint16_t CRC_dataTX;
	memset(USART2_TX_BUF,0,64);   //清除发送缓存前64个数据
//	USART2_TX_BUF[0]=FrameHeader_Collect;
//	USART2_TX_BUF[1]=EquipmentNum_Collect;
//	USART2_TX_BUF[2]=Get_IO_State_New64Byte;//ValveState_Fuction;
//	USART2_TX_BUF[3]=01;//此后的数据长度，不包括校验位
//	USART2_TX_BUF[4]=CangNum;//仓号，取值范围为1--8
//	
//	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,5);
//	USART2_TX_BUF[6]=CRC_dataTX&0xFF;//低位在后;
//	USART2_TX_BUF[5]=(CRC_dataTX>>8)&0xFF;//高位在前;
//	CollectMaster485_Send_Data(USART2_TX_BUF,7);
	
	
	USART2_TX_BUF[0]=FrameHeader_Collect02;
	USART2_TX_BUF[1]=EquipmentNum_Collect02;
	USART2_TX_BUF[2]=0x95; 
	USART2_TX_BUF[3]=0x50; 
	
	USART2_TX_BUF[4]=0x00;
	USART2_TX_BUF[5]=0x01;
	
	//功能码，读取寄存器或者写入寄存器---取自国标只能为0003、0006或者0010
	USART2_TX_BUF[6]=para001_RegOP_Code>>8;//0x00; 
	USART2_TX_BUF[7]=(para001_RegOP_Code & 0xff);//0x03; //////读取 
	
	//////para002------------  
	USART2_TX_BUF[8]=para002_RegAddrStart>>8;//0x00;
	USART2_TX_BUF[9]=para002_RegAddrStart & 0x00ff;  //Get_Valve_State;//0x20;//读取阀门状态
	
	//////para003
	USART2_TX_BUF[10]=para003_RegNum>>8;//0x00; 
	USART2_TX_BUF[11]=para003_RegNum & 0x00ff;  //有效字节数
	
	USART2_TX_BUF[12]=0x95;
	USART2_TX_BUF[13]=0x01;// 
	USART2_TX_BUF[14]=0xaa; 
	USART2_TX_BUF[15]=0xaa; // 
	
	
	//////para004仓号或者传感器的485地址
	USART2_TX_BUF[16]=para004_LegacyAddr>>8;//0;//仓号，取值范围为1--8
	USART2_TX_BUF[17]=para004_LegacyAddr & 0x00ff;//仓号，取值范围为1--8
	
	//////para005设置卸油阀门限时的ADC值
	USART2_TX_BUF[18]=para005_Fujia001>>8;//0;// 
	USART2_TX_BUF[19]=para005_Fujia001 & 0x00ff;// 
	
	
	
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,62);
	USART2_TX_BUF[62]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[63]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,64);
	
	
}



//从采集器读取液位数据
void ReadCollect_YeWei_TX(void)
{
	uint16_t CRC_dataTX;
	//memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	USART2_TX_BUF[2]=SensorValue_Function;
	USART2_TX_BUF[3]=1;
	USART2_TX_BUF[4]=Read_YeWei;
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,5);
	USART2_TX_BUF[6]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[5]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,7);
	
}



void ReadCollect_QingJiao_TX(void)
{//从采集器读取倾角数据
	uint16_t CRC_dataTX;
	//memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	USART2_TX_BUF[2]=SensorValue_Function;
	USART2_TX_BUF[3]=1;
	USART2_TX_BUF[4]=Read_QingJiao;
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,5);
	USART2_TX_BUF[6]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[5]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,7);
	
}


//设定液位传感器零点偏移数据,将数据下发给采集器，同步进行计算
void Send_Yewei_offset_To_Collect(void)
{
	uint16_t CRC_dataTX;
	//memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
//	USART2_TX_BUF[0]=FrameHeader_Collect;
//	USART2_TX_BUF[1]=EquipmentNum_Collect;
//	USART2_TX_BUF[3]=2;//去除帧头，功能码等；有效数据长度
//	
//	USART2_TX_BUF[2]=SetPara_Yewei_Offset;
//	USART2_TX_BUF[4]=FM25L16B_ReadByte(44);
//	USART2_TX_BUF[5]=FM25L16B_ReadByte(45);
//	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,6);
//	USART2_TX_BUF[6]=CRC_dataTX&0xFF;//低位在后;
//	USART2_TX_BUF[7]=(CRC_dataTX>>8)&0xFF;//高位在前;
//	CollectMaster485_Send_Data(USART2_TX_BUF,7+1);
	
	
	//20210128经同龚经理商议后，按照磁致伸缩液位仪同样的方式进行零偏修正。
	//控制板发送两个参数给采集器，每个参数均为有符号16位；共计4字节
	//本帧命令总长度由之前的8字节变更为10字节
	//
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	
	
	USART2_TX_BUF[2]=SetPara_Yewei_Offset;
	USART2_TX_BUF[3]=4;//去除帧头，功能码等；有效数据长度
	
//	USART2_TX_BUF[4]=FM25L16B_ReadByte(44);
//	USART2_TX_BUF[5]=FM25L16B_ReadByte(45);
//	USART2_TX_BUF[6]=FM25L16B_ReadByte(46);
//	USART2_TX_BUF[7]=FM25L16B_ReadByte(47);
	
	
	
//	USART2_TX_BUF[4]=FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+0);
//	USART2_TX_BUF[5]=FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+1);
//	USART2_TX_BUF[6]=FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+2);
//	USART2_TX_BUF[7]=FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+3);
	
	//李伟修改    将以下4行替换为上述4行   上述4行实际发送两个参数，一个是液位计零点，一个是罐容零点;之前FRAM中存储2字节int16，目前4字节浮点数  
	USART2_TX_BUF[4]=OffsetYewei[0]>>8;
	USART2_TX_BUF[5]=OffsetYewei[0] & 0x00ff;
	USART2_TX_BUF[6]=OffsetTankCapacity[0]>>8;
	USART2_TX_BUF[7]=OffsetTankCapacity[0] & 0x00ff;
	
	
			
	
	
	
	//标罐之前将相关修正数据全部清零 20210129
//	USART2_TX_BUF[4]=0;//FM25L16B_ReadByte(44);
//	USART2_TX_BUF[5]=0;//FM25L16B_ReadByte(45);
//	USART2_TX_BUF[6]=0;//FM25L16B_ReadByte(46);
//	USART2_TX_BUF[7]=0;//FM25L16B_ReadByte(47);
	
	
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,8);
	USART2_TX_BUF[8]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[9]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,7+1+2);
	
	
}


void ReadCollect_Press_TX(void)
{//读取压力传感器
	uint16_t CRC_dataTX;
	//memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	USART2_TX_BUF[2]=SensorValue_Function;
	USART2_TX_BUF[3]=1;
	USART2_TX_BUF[4]=Read_Press;
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,5);
	USART2_TX_BUF[6]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[5]=(CRC_dataTX>>8)&0xFF;//高位在前;
		
	CollectMaster485_Send_Data(USART2_TX_BUF,7);
	
	
	
	
}






void ReadCollect_Temperature_TX(void)
{///*读取温度传感器数据*/
	uint16_t CRC_dataTX;
//	memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	USART2_TX_BUF[2]=SensorValue_Function;
	USART2_TX_BUF[3]=1;
	USART2_TX_BUF[4]=Read_Temper;
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,5);
	USART2_TX_BUF[6]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[5]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,7);
}
void WriteCollcet_Parameter(void)
{
	uint16_t CRC_dataTX;
	//memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	USART2_TX_BUF[2]=WriteStore_Function;
	USART2_TX_BUF[3]=6;
	USART2_TX_BUF[4]=StoreNumber;
	USART2_TX_BUF[5]=Config_info_all.ManHole_Big_info;
	USART2_TX_BUF[6]=Config_info_all.Dump_info;
	USART2_TX_BUF[7]=Config_info_all.HaiDiFa_info;
	USART2_TX_BUF[8]=0;
	USART2_TX_BUF[9]=0;
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,10);
	USART2_TX_BUF[11]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[10]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,12);
}

void PlatformCalibrat_Collect(void)
{
	uint16_t CRC_dataTX;
//	memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	USART2_TX_BUF[2]=PlatformCal_Function;
	USART2_TX_BUF[3]=6;
	USART2_TX_BUF[4]=(PlatformCalibrat.Threshold_Angle>>8)&0xFF;//角度门限高八位
	USART2_TX_BUF[5]=PlatformCalibrat.Threshold_Angle&0xFF;//低八位
	USART2_TX_BUF[6]=(PlatformCalibrat.Times>>8)&0xFF;//Times
	USART2_TX_BUF[7]=PlatformCalibrat.Times&0xFF;
	USART2_TX_BUF[8]=(PlatformCalibrat.Reserve_Register>>8)&0xFF;//预留高
	USART2_TX_BUF[9]=PlatformCalibrat.Reserve_Register&0xFF;//预留低
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,10);
	USART2_TX_BUF[11]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[10]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,12);
}
void PlatformRestart_Collect(void)
{
	uint16_t CRC_dataTX;
	//memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	USART2_TX_BUF[2]=PlatformRestartCllect;
	USART2_TX_BUF[3]=0;
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,4);
	USART2_TX_BUF[5]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[4]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,6);
}
void Platform_SetOilStyle (void)//新增
{
	uint16_t CRC_dataTX;
	//memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	USART2_TX_BUF[2]=PlatformSetOilStyle;
	USART2_TX_BUF[3]=2;
	USART2_TX_BUF[4]=PlatformCalibrat.OilStyleStore;//仓号
	USART2_TX_BUF[5]=PlatformCalibrat.OilStyle;//油品
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,6);
	USART2_TX_BUF[7]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[6]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,8);
}
void Platform_ExceptionHandling (void)//新增
{//当采集器接收到异常数据标志，不再判断人孔盖状态，只上传全关数据
	uint16_t CRC_dataTX;
//	memset(USART2_TX_BUF,0,20);   //清除发送缓存前20个数据
	USART2_TX_BUF[0]=FrameHeader_Collect;
	USART2_TX_BUF[1]=EquipmentNum_Collect;
	USART2_TX_BUF[2]=PlatformExceptionHandling;
	USART2_TX_BUF[3]=1;
	USART2_TX_BUF[4]=PlatformCalibrat.ErrorStore;
	USART2_TX_BUF[5]=PlatformCalibrat.ErrorStyle;
	CRC_dataTX=CRC16_MODBUS(USART2_TX_BUF,6);
	USART2_TX_BUF[7]=CRC_dataTX&0xFF;//低位在后;
	USART2_TX_BUF[6]=(CRC_dataTX>>8)&0xFF;//高位在前;
	CollectMaster485_Send_Data(USART2_TX_BUF,8);
}
void Immediate_Processing_Function(void)//新增
{
	
	/*
	if(Set_CollectPara_Flag==True)////通过串口4设定采集板的参数
	{
		WriteCollcet_Parameter();
		HAL_Delay(80);
		if(CheckInFrame_Collect485(64,0)==0xA3)
		{
			Set_CollectPara_Flag=False;
		}
		else 
		{
			WriteCollcet_Parameter();
			HAL_Delay(80);
			if(CheckInFrame_Collect485(64,0)==0xA3)
			{
				Set_CollectPara_Flag=False;
			}
		}
	}
	
	*/
	if(PlatformCalibrat.StartCalibrat_Flag==True)
	{///通过终端---设定采集板的参数
		PlatformCalibrat_Collect();
		//HAL_Delay(80);
		if(CheckInFrame_Collect485(64,0)==0xA4)
		{
			PlatformCalibrat.StartCalibrat_Flag=False;
		}
		else 
		{
			PlatformCalibrat_Collect();
			//HAL_Delay(80);
			if(CheckInFrame_Collect485(64,0)==0xA4)
			{
				PlatformCalibrat.StartCalibrat_Flag=False;
			}
		}
	}///通过终端---设定采集板的参数
	
	/*
	if(PlatformCalibrat.Restart_Collect==True)
	{///通过终端---重启采集板
		PlatformRestart_Collect();
		HAL_Delay(100);
		PlatformCalibrat.Restart_Collect=False;
		if(CheckInFrame_Collect485(64,0)==0xA5)
		{
			PlatformCalibrat.Restart_Collect=False;
		}
		else 
		{
			PlatformRestart_Collect();
			HAL_Delay(100);
			if(CheckInFrame_Collect485(64,0)==0xA5)
			{
				PlatformCalibrat.Restart_Collect=False;
			}
		}
	}///通过终端---重启采集板
	
	
	*/
	if(PlatformCalibrat.SetOilStyleFlag==True)//新增
	{///通过按键---设定油品参数
		Platform_SetOilStyle();
		//HAL_Delay(100);
		if(CheckInFrame_Collect485(64,0)==0xA6)
		{
			PlatformCalibrat.SetOilStyleFlag=False;
		}
		else 
		{
			Platform_SetOilStyle();
			//HAL_Delay(100);
			if(CheckInFrame_Collect485(64,0)==0xA6)
			{
				PlatformCalibrat.SetOilStyleFlag=False;
			}
		}
	}///通过按键---设定油品参数
	
	
	
	if(PlatformCalibrat.ErrorFlag==True)//新增
	{////当采集器接收到异常数据标志，不再判断人孔盖状态，只上传全关数据
		Platform_ExceptionHandling();
		//HAL_Delay(100);
		if(CheckInFrame_Collect485(64,0)==0xA7)
		{
			PlatformCalibrat.ErrorFlag=False;
		}
		else 
		{
			Platform_ExceptionHandling();
			//HAL_Delay(100);
			if(CheckInFrame_Collect485(64,0)==0xA7)
			{
				PlatformCalibrat.ErrorFlag=False;
			}
		}
	}//当采集器接收到异常数据标志，不再判断人孔盖状态，只上传全关数据
}




//0x0190修改液位计零点

void ReadAllStoreValue(void)//控制板读取采集板的数据
{
	
//	int j001ReadAll;
	uint16_t msgID;
	
	
	if(Usart2_ErrorTimes>=Max_Usart2_ErrorTime)//485总线没有数据传输，默认从机有问题，6S
	{
		Collect485.Collect_CommError=True;
	}
	
	
		
	cnt000++;
	
	if(cnt000>=3600)
	{
			cnt000=0;
	}
	 
		StoreNumber00=(cnt000 % StoreNumber)+1;	
	
#if(New236Byte_En_0x1121)	
	 if((cnt000%10==5) ||(cnt000%2==0))//一次性读取4仓所有传感器信息  每间隔5秒读取一次
	 {
			Get_All_Moniliang_Data_4Cang(0);
		 __NOP();
	 }
#endif
	

	 
#if(New150Byte_En_0x1193)		 
 //新增的150字节传输每仓所有传感器的协议，一帧数据中传输每仓铅封、IO、模拟量数据	 
		switch (StoreNumber00)
		{
			case 1:
				;//
				ReadCollect_ValveState_64Byte(0x000003,Collector_Get_All_Sensor_Data_Cang01,0x0000,0x0000,0x0000);
				msgID=Collector_Get_All_Sensor_Data_Cang01;
			  pT2C_ALL_Sensor_Data=&T2C_ALL_Sensor_Data01;			
			
				uni_YeweiToPlatForm001.flo_Data=T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[0]*SCL_ControllToPlatForm;

			  
			//	__NOP();
					
			  
				break;
			
			
			case 2:
				ReadCollect_ValveState_64Byte(0x000003,Collector_Get_All_Sensor_Data_Cang02,0x0000,0x0000,0x0000);
				msgID=Collector_Get_All_Sensor_Data_Cang02;
			  pT2C_ALL_Sensor_Data=&T2C_ALL_Sensor_Data02;	

				uni_YeweiToPlatForm002.flo_Data=T2C_ALL_Sensor_Data02.MoniLiang_Data_Every_Cang[0]*SCL_ControllToPlatForm;
				//__NOP();				
				break;
			case 3:
				ReadCollect_ValveState_64Byte(0x000003,Collector_Get_All_Sensor_Data_Cang03,0x0000,0x0000,0x0000);
				msgID=Collector_Get_All_Sensor_Data_Cang03;
			    pT2C_ALL_Sensor_Data=&T2C_ALL_Sensor_Data03;
				uni_YeweiToPlatForm003.flo_Data=T2C_ALL_Sensor_Data03.MoniLiang_Data_Every_Cang[0]*SCL_ControllToPlatForm;			  
				//__NOP();				
				break;	

			case 4:
				ReadCollect_ValveState_64Byte(0x000003,Collector_Get_All_Sensor_Data_Cang04,0x0000,0x0000,0x0000);
				msgID=Collector_Get_All_Sensor_Data_Cang04;
			  	pT2C_ALL_Sensor_Data=&T2C_ALL_Sensor_Data04;
				  uni_YeweiToPlatForm004.flo_Data=T2C_ALL_Sensor_Data04.MoniLiang_Data_Every_Cang[0]*SCL_ControllToPlatForm;			  
				//__NOP();				
				break;	
			case 5:
				ReadCollect_ValveState_64Byte(0x000003,Collector_Get_All_Sensor_Data_Cang05,0x0000,0x0000,0x0000);
				msgID=Collector_Get_All_Sensor_Data_Cang05;
			  	pT2C_ALL_Sensor_Data=&T2C_ALL_Sensor_Data05;			  
				//__NOP();				
				break;		
			case 6:
				ReadCollect_ValveState_64Byte(0x000003,Collector_Get_All_Sensor_Data_Cang06,0x0000,0x0000,0x0000);
				msgID=Collector_Get_All_Sensor_Data_Cang06;
			  	pT2C_ALL_Sensor_Data=&T2C_ALL_Sensor_Data06;			  
				//__NOP();				
				break;
			case 7:
				ReadCollect_ValveState_64Byte(0x000003,Collector_Get_All_Sensor_Data_Cang07,0x0000,0x0000,0x0000);
				msgID=Collector_Get_All_Sensor_Data_Cang07;
			  	pT2C_ALL_Sensor_Data=&T2C_ALL_Sensor_Data07;			  
				//__NOP();				
				break;
			case 8:
				ReadCollect_ValveState_64Byte(0x000003,Collector_Get_All_Sensor_Data_Cang08,0x0000,0x0000,0x0000);
				msgID=Collector_Get_All_Sensor_Data_Cang08;
			  	pT2C_ALL_Sensor_Data=&T2C_ALL_Sensor_Data08;			  
				//__NOP();				
				break;
			default :
				//__NOP();
				break;
		}	


//			HAL_GPIO_TogglePin(GPIOC, DWI_Pin);//复位看门狗sp706
			//HAL_Delay(SPAN_ControllerAndCollector_INTERVAL);
			//osDelay(SPAN_ControllerAndCollector_INTERVAL_180);

			
			//if((chkRetCaiJiBan==msgID) || (1==1))
			{
				//__NOP();	
				Parse_AllSensor_Data_For_SingleStore(pT2C_ALL_Sensor_Data,msgID);	
				//__NOP();
		
			}
#endif				
			
			
				
	 
	 
#if(New64Byte_En_0x0020)	

	 	//依次读取每个仓的数据	
 	ReadCollect_ValveState_64Byte(0x000003,Collector_Get_Valve_State,0x0002,StoreNumber00,0x0000);
 
//	HAL_GPIO_TogglePin(GPIOC, DWI_Pin);//复位看门狗sp706
	//HAL_Delay(SPAN_ControllerAndCollector_INTERVAL);//100ms会导致命令来不及回复！！！！必须要200ms！！！！！！---20210728
	//osDelay(SPAN_ControllerAndCollector_INTERVAL_120);
	
	Parse_0x0020_Data_64Byte();
	
#endif	


#if(New64Byte_En_0x0013)
	
	//读取阀门状态
//	ReadCollect_ValveState_TX();
	
	//按照老的格式读取之前的阀门状态----多个阀门状态或运算之后进行铅封业务运算
	ReadCollect_ValveState_64Byte(0x000003,Collector_Get_Valve_OldFormat,0x0002,0x0000,0x0000);
//	HAL_GPIO_TogglePin(GPIOC, DWI_Pin);//复位看门狗sp706
	//HAL_Delay(SPAN_ControllerAndCollector_INTERVAL);
	//osDelay(SPAN_ControllerAndCollector_INTERVAL_120);
	
	Parse_0x0013_Data();
	
#endif


#if(New80Byte_En_0x119B)	//读取整车传感器数据
	 if((cnt000%10==0))//读取整车传感器数据(cnt000%10==5) ||
	 {
			ReadCollect_ValveState_64Byte(0x000003,Collector_Get_All_Sensor_Data_WholeCar,0x0002,0x0000,0x0000);
//			HAL_GPIO_TogglePin(GPIOC, DWI_Pin);//复位看门狗sp706
			//HAL_Delay(SPAN_ControllerAndCollector_INTERVAL);
			//osDelay(SPAN_ControllerAndCollector_INTERVAL_120);
			msgID=Collector_Get_All_Sensor_Data_WholeCar;
			Parse_AllSensor_Data_For_WholeCar(pT2C_ALL_Sensor_WholeCar,msgID,ALL_Sensor_Data_Num_WholeCar);
			__NOP();
	 }
#endif
	 
	
//*/	
 
	
	/*
 
	
	
	if(Usart2_ErrorTimes>=Max_Usart2_ErrorTime)//485总线没有数据传输，默认从机有问题，6S
	{
		Collect485.Collect_CommError=True;
	}
	*/
	  
 
}
uint8_t Collect458_bus[8]={0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55};
uint8_t HDF_cnt[8]={0},XYF_cnt[8]={0};
/*
	13读取的数据作为铅封流程的判断
	1s钟转换一次
*/
void CollectData_Transform_UsefullData(void)//实时数据转换
{
	uint8_t i;
	/*                      人孔盖                            */
	Stor[0].stat[0]    = ((Collect485.ValveState_Num1&0x02)>>1);//1仓人孔小盖
	Stor[0].stat[1]    = ((Collect485.ValveState_Num1&0x01)>>0);//1仓人孔大盖
	Stor[1].stat[0]    = ((Collect485.ValveState_Num2&0x02)>>1);//2仓人孔小盖
	Stor[1].stat[1]    = ((Collect485.ValveState_Num2&0x01)>>0);//2仓人孔大盖
	Stor[2].stat[0]    = ((Collect485.ValveState_Num3&0x02)>>1);//3仓人孔小盖
	Stor[2].stat[1]    = ((Collect485.ValveState_Num3&0x01)>>0);//3仓人孔大盖
	Stor[3].stat[0]    = ((Collect485.ValveState_Num4&0x02)>>1);//4仓人孔小盖
	Stor[3].stat[1]    = ((Collect485.ValveState_Num4&0x01)>>0);//4仓人孔大盖
	Stor[4].stat[0]    = ((Collect485.ValveState_Num5&0x02)>>1);//5仓人孔小盖
	Stor[4].stat[1]    = ((Collect485.ValveState_Num5&0x01)>>0);//5仓人孔大盖
	Stor[5].stat[0]    = ((Collect485.ValveState_Num6&0x02)>>1);//6仓人孔小盖
	Stor[5].stat[1]    = ((Collect485.ValveState_Num6&0x01)>>0);//6仓人孔大盖
	Stor[6].stat[0]    = ((Collect485.ValveState_Num7&0x02)>>1);//7仓人孔小盖
	Stor[6].stat[1]    = ((Collect485.ValveState_Num7&0x01)>>0);//7仓人孔大盖
	Stor[7].stat[0]    = ((Collect485.ValveState_Num8&0x02)>>1);//8仓人孔小盖
	Stor[7].stat[1]    = ((Collect485.ValveState_Num8&0x01)>>0);//8仓人孔大盖
	/*                      底  阀                            */
	Stor[0].hdf_state  = ((Collect485.ValveState_Num1&0x04)>>2);//1仓底阀状态
	Stor[1].hdf_state  = ((Collect485.ValveState_Num2&0x04)>>2);//2仓底阀状态
	Stor[2].hdf_state  = ((Collect485.ValveState_Num3&0x04)>>2);//3仓底阀状态
	Stor[3].hdf_state  = ((Collect485.ValveState_Num4&0x04)>>2);//4仓底阀状态
	Stor[4].hdf_state  = ((Collect485.ValveState_Num5&0x04)>>2);//5仓底阀状态
	Stor[5].hdf_state  = ((Collect485.ValveState_Num6&0x04)>>2);//6仓底阀状态
	Stor[6].hdf_state  = ((Collect485.ValveState_Num7&0x04)>>2);//7仓底阀状态
	Stor[7].hdf_state  = ((Collect485.ValveState_Num8&0x04)>>2);//8仓底阀状态
	/*                      卸油阀                            */
	Stor[0].xyf_state  = ((Collect485.ValveState_Num1&0x08)>>3);//1仓卸油阀状态
	Stor[1].xyf_state   = ((Collect485.ValveState_Num2&0x08)>>3);//2仓卸油阀状态
	Stor[2].xyf_state   = ((Collect485.ValveState_Num3&0x08)>>3);//3仓卸油阀状态
	Stor[3].xyf_state   = ((Collect485.ValveState_Num4&0x08)>>3);//4仓卸油阀状态
	Stor[4].xyf_state   = ((Collect485.ValveState_Num5&0x08)>>3);//5仓卸油阀状态
	Stor[5].xyf_state   = ((Collect485.ValveState_Num6&0x08)>>3);//6仓卸油阀状态
	Stor[6].xyf_state   = ((Collect485.ValveState_Num7&0x08)>>3);//7仓卸油阀状态
	Stor[7].xyf_state   = ((Collect485.ValveState_Num8&0x08)>>3);//8仓卸油阀状态
	/*                      卸尽                            */
	if((Collect485.UnloadState_Num1==1)&&(Collect485.Collect_CommError==False))
	{
		HAL_GPIO_WritePin(GPIOE, LED2_Pin, GPIO_PIN_RESET);
	}
	else if((Collect485.UnloadState_Num1==0)&&(Collect485.Collect_CommError==False)) 
	{	
		HAL_GPIO_WritePin(GPIOE, LED2_Pin, GPIO_PIN_SET);
	}
	else if((Collect485.UnloadState_Num1==0x55)||(Collect485.Collect_CommError==True)) 
	{
		HAL_GPIO_TogglePin(GPIOE,LED2_Pin);
	}
	
	
	if((Collect485.UnloadState_Num2==1)&&(Collect485.Collect_CommError==False)) 
		HAL_GPIO_WritePin(GPIOE, LED3_Pin, GPIO_PIN_RESET);
	else if((Collect485.UnloadState_Num2==0)&&(Collect485.Collect_CommError==False)) 
		HAL_GPIO_WritePin(GPIOE, LED3_Pin, GPIO_PIN_SET);
	else if((Collect485.UnloadState_Num2==0x55)||(Collect485.Collect_CommError==True)) 
		HAL_GPIO_TogglePin(GPIOE,LED3_Pin);
	
	if((Collect485.UnloadState_Num3==1)&&(Collect485.Collect_CommError==False)) 
		HAL_GPIO_WritePin(GPIOE, LED4_Pin, GPIO_PIN_RESET);
	else if((Collect485.UnloadState_Num3==0)&&(Collect485.Collect_CommError==False)) 
		HAL_GPIO_WritePin(GPIOE, LED4_Pin, GPIO_PIN_SET);
	else if((Collect485.UnloadState_Num3==0x55)||(Collect485.Collect_CommError==True)) 
		HAL_GPIO_TogglePin(GPIOE,LED4_Pin);
	
	if((Collect485.UnloadState_Num4==1)&&(Collect485.Collect_CommError==False)) 
		HAL_GPIO_WritePin(GPIOE, LED5_Pin, GPIO_PIN_RESET);
	else if((Collect485.UnloadState_Num4==0)&&(Collect485.Collect_CommError==False)) 
		HAL_GPIO_WritePin(GPIOE, LED5_Pin, GPIO_PIN_SET);
	else if((Collect485.UnloadState_Num4==0x55)||(Collect485.Collect_CommError==True)) 
		HAL_GPIO_TogglePin(GPIOE,LED5_Pin);
	
	if(Collect485.Collect_CommError==True)
	{
		Collect458_bus[0]=0x55;//Buf=0x55;
		Collect458_bus[1]=0x55;//Buf=0x55;
		Collect458_bus[2]=0x55;//Buf=0x55;
		Collect458_bus[3]=0x55;//Buf=0x55;
		Collect458_bus[4]=0x55;//Buf=0x55;
		Collect458_bus[5]=0x55;//Buf=0x55;
		Collect458_bus[6]=0x55;//Buf=0x55;
		Collect458_bus[7]=0x55;//Buf=0x55;
		Collect485.ValveState_Num1=Collect485.ValveState_Num1|0xF0;
		Collect485.ValveState_Num2=Collect485.ValveState_Num2|0xF0;
		Collect485.ValveState_Num3=Collect485.ValveState_Num3|0xF0;
		Collect485.ValveState_Num4=Collect485.ValveState_Num4|0xF0;
		Collect485.ValveState_Num5=Collect485.ValveState_Num5|0xF0;
		Collect485.ValveState_Num6=Collect485.ValveState_Num6|0xF0;
		Collect485.ValveState_Num7=Collect485.ValveState_Num7|0xF0;
		Collect485.ValveState_Num8=Collect485.ValveState_Num8|0xF0;
	}
	else
	{
		Collect458_bus[0]=0xaa;//Buf=0xaa;
		Collect458_bus[1]=0xaa;//Buf=0xaa;
		Collect458_bus[2]=0xaa;//Buf=0xaa;
		Collect458_bus[3]=0xaa;//Buf=0xaa;
		Collect458_bus[4]=0xaa;//Buf=0xaa;
		Collect458_bus[5]=0xaa;//Buf=0xaa;
		Collect458_bus[6]=0xaa;//Buf=0xaa;
		Collect458_bus[7]=0xaa;//Buf=0xaa;
		Collect485.ValveState_Num1=Collect485.ValveState_Num1&0xFF;
		Collect485.ValveState_Num2=Collect485.ValveState_Num2&0xFF;
		Collect485.ValveState_Num3=Collect485.ValveState_Num3&0xFF;
		Collect485.ValveState_Num4=Collect485.ValveState_Num4&0xFF;
		Collect485.ValveState_Num5=Collect485.ValveState_Num5&0xFF;
		Collect485.ValveState_Num6=Collect485.ValveState_Num6&0xFF;
		Collect485.ValveState_Num7=Collect485.ValveState_Num7&0xFF;
		Collect485.ValveState_Num8=Collect485.ValveState_Num8&0xFF;
	}
	if((Collect485.ValveState_Num1&0xF0)>0)//1仓
	{
		if(((Collect485.ValveState_Num1&0x10)>>4)==1)
		{
			Stor[0].stat[1]=0x55;//大盖
//			SendChar4(0XAA);
		}
		if(((Collect485.ValveState_Num1&0x20)>>5)==1)
		{
			Stor[0].stat[0]=0x55;//小盖
//			SendChar4(0XBB);
		}
		if(((Collect485.ValveState_Num1&0x40)>>6)==1)
		{
			Stor[0].hdf_state=0x55;
		}
		if(((Collect485.ValveState_Num1&0x80)>>7)==1)
		{
			Stor[0].xyf_state=0x55;
		}
	}
	if((Collect485.ValveState_Num2&0xF0)>0)//2仓
	{
		if(((Collect485.ValveState_Num2&0x10)>>4)==1)
		{
			Stor[1].stat[1]=0x55;
		}
		if(((Collect485.ValveState_Num2&0x20)>>5)==1)
		{
			Stor[1].stat[0]=0x55;
		}
		if(((Collect485.ValveState_Num2&0x40)>>6)==1)
		{
			Stor[1].hdf_state=0x55;
		}
		if(((Collect485.ValveState_Num2&0x80)>>7)==1)
		{
			Stor[1].xyf_state=0x55;
		}
	}
	if((Collect485.ValveState_Num3&0xF0)>0)//3仓
	{
		if(((Collect485.ValveState_Num3&0x10)>>4)==1)
		{
			Stor[2].stat[1]=0x55;
		}
		if(((Collect485.ValveState_Num3&0x20)>>5)==1)
		{
			Stor[2].stat[0]=0x55;
		}
		if(((Collect485.ValveState_Num3&0x40)>>6)==1)
		{
			Stor[2].hdf_state=0x55;
		}
		if(((Collect485.ValveState_Num3&0x80)>>7)==1)
		{
			Stor[2].xyf_state=0x55;
		}
	}
	if((Collect485.ValveState_Num4&0xF0)>0)//4仓
	{
		if(((Collect485.ValveState_Num4&0x10)>>4)==1)
		{
			Stor[3].stat[1]=0x55;
		}
		if(((Collect485.ValveState_Num4&0x20)>>5)==1)
		{
			Stor[3].stat[0]=0x55;
		}
		if(((Collect485.ValveState_Num4&0x40)>>6)==1)
		{
			Stor[3].hdf_state=0x55;
		}
		if(((Collect485.ValveState_Num4&0x80)>>7)==1)
		{
			Stor[3].xyf_state=0x55;
		}
	}
	if((Collect485.ValveState_Num5&0xF0)>0)//5仓
	{
		if(((Collect485.ValveState_Num5&0x10)>>4)==1)
		{
			Stor[4].stat[1]=0x55;
		}
		if(((Collect485.ValveState_Num5&0x20)>>5)==1)
		{
			Stor[4].stat[0]=0x55;
		}
		if(((Collect485.ValveState_Num5&0x40)>>6)==1)
		{
			Stor[4].hdf_state=0x55;
		}
		if(((Collect485.ValveState_Num5&0x80)>>7)==1)
		{
			Stor[4].xyf_state=0x55;
		}
	}
	if((Collect485.ValveState_Num6&0xF0)>0)//6仓
	{
		if(((Collect485.ValveState_Num6&0x10)>>4)==1)
		{
			Stor[5].stat[1]=0x55;
		}
		if(((Collect485.ValveState_Num6&0x20)>>5)==1)
		{
			Stor[5].stat[0]=0x55;
		}
		if(((Collect485.ValveState_Num6&0x40)>>6)==1)
		{
			Stor[5].hdf_state=0x55;
		}
		if(((Collect485.ValveState_Num6&0x80)>>7)==1)
		{
			Stor[5].xyf_state=0x55;
		}
	}
	if((Collect485.ValveState_Num7&0xF0)>0)//7仓
	{
		if(((Collect485.ValveState_Num7&0x10)>>4)==1)
		{
			Stor[6].stat[1]=0x55;
		}
		if(((Collect485.ValveState_Num7&0x20)>>5)==1)
		{
			Stor[6].stat[0]=0x55;
		}
		if(((Collect485.ValveState_Num7&0x40)>>6)==1)
		{
			Stor[6].hdf_state=0x55;
		}
		if(((Collect485.ValveState_Num7&0x80)>>7)==1)
		{
			Stor[6].xyf_state=0x55;
		}
	}
	if((Collect485.ValveState_Num8&0xF0)>0)//8仓
	{
		if(((Collect485.ValveState_Num8&0x10)>>4)==1)
		{
			Stor[7].stat[1]=0x55;
		}
		if(((Collect485.ValveState_Num8&0x20)>>5)==1)
		{
			Stor[7].stat[0]=0x55;
		}
		if(((Collect485.ValveState_Num8&0x40)>>6)==1)
		{
			Stor[7].hdf_state=0x55;
		}
		if(((Collect485.ValveState_Num8&0x80)>>7)==1)
		{
			Stor[7].xyf_state=0x55;
		}
	}
	/*以下判断各仓人孔盖和阀门状态是否更新*/
	//1、读人孔盖状态更新
	for(i=0;i<StoreNumber;i++)//此处i<8应改为i<StorNum
	{
		Statetemp.rkg[i]=Stor[i].stat[1] ;
		Statetemp.rkgx[i] = Stor[i].stat[0] ;
//		SendChar4(Stor[0].stat[1]);
		/*此处添加特殊仓，如人孔盖是否存在等*/
	/* USER CODE BEGIN  */
		
		if(((Config_info_all.ManHole_Big_info&0x80)==0x80)&&((Config_info_all.ManHole_small_info&0x80)!=0x80))//人孔大盖传感器不存在
		{
			Statetemp.rkg[i] = Stor[i].stat[0] ;
			Statetemp.rkgx[i] = Stor[i].stat[0] ;
		}
		if(((Config_info_all.ManHole_small_info&0x80)==0x80)&&((Config_info_all.ManHole_Big_info&0x80)!=0x80))//人孔小盖不存在
		{
			Statetemp.rkg[i] = Stor[i].stat[1] ;
			Statetemp.rkgx[i] = Stor[i].stat[1] ;
		}
		if(((Config_info_all.ManHole_small_info&0x80)==0x80)&&((Config_info_all.ManHole_Big_info&0x80)==0x80))//人孔大小盖不存在
		{
			Statetemp.rkg[i] = 0 ;
			Statetemp.rkgx[i] = 0 ;
		}
  /* USER CODE END  */
	}
//	SendChar4(Statetemp.rkg[0]);
	//2、读卸油阀状态更新
//	uint8_t temp_advule_xyf[8]={0};
	for(i=0;i<StoreNumber;i++)//此处i<8应改为i<StorNum
	{
		if(((Config_info_all.Dump_info&0x80)==0)&&((Config_info_all.HaiDiFa_info&0x80)==0))//传感器存在
		{
#if 1
			Statetemp.xyf[i]=Stor[i].xyf_state;
			Statetemp.bottm[i]=Stor[i].hdf_state;
#else			
			/*此处添加特殊仓，如人孔盖是否存在等*/
			if((Config_info_all.Dump_info&0x0f)==StoreNumber)//传感器个数=StoreNumber
			{
				Statetemp.xyf[i]=Stor[i].xyf_state;
			}
			else if((Config_info_all.Dump_info&0x0f)==2*StoreNumber)
			{
				Statetemp.xyf[i]=Stor[2*i].xyf_state|Stor[(2*i)+1].xyf_state;
			}
			else if((Config_info_all.Dump_info&0x0f)==3*StoreNumber)
			{
				Statetemp.xyf[i]=Stor[3*i].xyf_state|Stor[(3*i)+1].xyf_state|Stor[(3*i)+2].xyf_state;
			}
			if((Config_info_all.HaiDiFa_info&0x0f)==StoreNumber)//传感器个数=StoreNumber
			{
				Statetemp.bottm[i]=Stor[i].hdf_state;
			}
			else if((Config_info_all.HaiDiFa_info&0x0f)==2*StoreNumber)
			{
				Statetemp.bottm[i]=Stor[2*i].hdf_state|Stor[(2*i)+1].hdf_state;
			}
			else if((Config_info_all.HaiDiFa_info&0x0f)==3*StoreNumber)
			{
				Statetemp.bottm[i]=Stor[3*i].hdf_state|Stor[(3*i)+1].hdf_state|Stor[(3*i)+2].hdf_state;
			}			
#endif			
		}
		else if(((Config_info_all.Dump_info&0x80)==0)&&((Config_info_all.HaiDiFa_info&0x80)==0x80))//底阀不存在
		{
#if 1
			Statetemp.xyf[i]=Stor[i].xyf_state;
#else			
			if((Config_info_all.Dump_info&0x0f)==StoreNumber)//传感器个数=StoreNumber
			{
				Statetemp.xyf[i]=Stor[i].xyf_state;
			}
			else if((Config_info_all.Dump_info&0x0f)==2*StoreNumber)
			{
				Statetemp.xyf[i]=Stor[2*i].xyf_state|Stor[(2*i)+1].xyf_state;
			}
			else if((Config_info_all.Dump_info&0x0f)==3*StoreNumber)
			{
				Statetemp.xyf[i]=Stor[3*i].xyf_state|Stor[(3*i)+1].xyf_state|Stor[(3*i)+2].xyf_state;
			}
#endif			
			Statetemp.bottm[i]=Statetemp.xyf[i];
		}
		else if(((Config_info_all.Dump_info&0x80)==0x80)&&((Config_info_all.HaiDiFa_info&0x80)==0))//卸油阀不存在
		{
#if 1
			Statetemp.bottm[i]=Stor[i].hdf_state;
#else			
			if((Config_info_all.HaiDiFa_info&0x0f)==StoreNumber)//传感器个数=StoreNumber
			{
				Statetemp.bottm[i]=Stor[i].hdf_state;
			}
			else if((Config_info_all.HaiDiFa_info&0x0f)==2*StoreNumber)
			{
				Statetemp.bottm[i]=Stor[2*i].hdf_state|Stor[(2*i)+1].hdf_state;
			}
			else if((Config_info_all.HaiDiFa_info&0x0f)==3*StoreNumber)
			{
				Statetemp.bottm[i]=Stor[3*i].hdf_state|Stor[(3*i)+1].hdf_state|Stor[(3*i)+2].hdf_state;
			}
#endif			
			Statetemp.xyf[i]=Statetemp.bottm[i];
		}
		else if(((Config_info_all.Dump_info&0x80)==0x80)&&((Config_info_all.HaiDiFa_info&0x80)==0x80))
		{
			Statetemp.bottm[i]=0;
			Statetemp.xyf[i]=0;
		}
	}
/*	
	else if((Config_info_all.Dump_info&0xf0)==0)//StoreNumber
	{
		for(i=0;i<StoreNumber;i++)//此处i<8应改为i<StorNum
		{
			if(temp_advule_xyf[i] !=Statetemp.xyf[i])
			{
				 XYF_cnt[i]++;
				if(XYF_cnt[i]>10)
				{
					temp_advule_xyf[i] =Statetemp.xyf[i];// 读取卸油阀状态值，相等，更新，存储一仓状态  Statetemp.xyf[i] 
					XYF_cnt[i] =0;
				}
				//此处日后填写状态变更时是否保存或者其他操作
			}
			else
			{
				XYF_cnt[i] =0;
			}
		}
	}
*/
	//2、读底阀状态更新
/*
	for(i=0;i<StoreNumber;i++)//此处i<8应改为i<StorNum
	{
		if((Config_info_all.HaiDiFa_info&0x80)==0)//传感器存在
		{
			if((Config_info_all.HaiDiFa_info&0x0f)==StoreNumber)//传感器个数=StoreNumber
			{
				Statetemp.bottm[i]=Stor[i].hdf_state;
			}
			else if((Config_info_all.HaiDiFa_info&0x0f)==2*StoreNumber)
			{
				Statetemp.bottm[i]=Stor[2*i].hdf_state|Stor[(2*i)+1].hdf_state;
			}
			else if((Config_info_all.HaiDiFa_info&0x0f)==3*StoreNumber)
			{
				Statetemp.bottm[i]=Stor[3*i].hdf_state|Stor[(3*i)+1].hdf_state|Stor[(3*i)+2].hdf_state;
			}
		}
		else 
		{
			Statetemp.bottm[i] = 0;
		}
	}
*/
/*
	uint8_t temp_advule_hdf[8]={0};
	if((Config_info_all.HaiDiFa_info&0xf0)==1)//2*StoreNumber
	{	
		for(i=0;i<StoreNumber;i++)//此处i<8应改为i<StorNum
		{
			if(temp_advule_hdf[i] !=Statetemp.bottm[i])
			{
				 HDF_cnt[i]++;
				if(HDF_cnt[i]>10)
				{
					temp_advule_hdf[i] =Statetemp.bottm[i];// 读取卸油阀状态值，相等，更新，存储一仓状态  Statetemp.xyf[i] 
					HDF_cnt[i] =0;
				}
				//此处日后填写状态变更时是否保存或者其他操作
			}
			else
			{
				XYF_cnt[i] =0;
			}
			//此处添加特殊仓，如人孔盖是否存在等/
//			Statetemp.bottm[0]=temp_advule_hdf[0]|temp_advule_hdf[1];
//			Statetemp.bottm[1]=temp_advule_hdf[2]|temp_advule_hdf[3];
//			Statetemp.bottm[2]=temp_advule_hdf[4]|temp_advule_hdf[5];
//			Statetemp.bottm[3]=temp_advule_hdf[6]|temp_advule_hdf[7];
		}
	}

	else if((Config_info_all.HaiDiFa_info&0xf0)==0)//StoreNumber
	{
		for(i=0;i<StoreNumber;i++)
		{
			if(temp_advule_hdf[i] !=Statetemp.bottm[i])
			{
				 HDF_cnt[i]++;
				if(HDF_cnt[i]>10)
				{
					temp_advule_hdf[i] =Statetemp.bottm[i];// 读取卸油阀状态值，相等，更新，存储一仓状态  Statetemp.xyf[i] 
					HDF_cnt[i] =0;
				}
				//此处日后填写状态变更时是否保存或者其他操作//
			}
			else
			{
				XYF_cnt[i] =0;
			}
		}
	}
*/
//	Stor[0].yewei[0]=1111;
//	Stor[1].yewei[0]=1222;
//	Stor[2].yewei[0]=1333;
//	Stor[3].yewei[0]=1444;
//	Stor[0].Press=2111;
//	Stor[1].Press=2222;
//	Stor[2].Press=2333;
//	Stor[3].Press=2444;
}

//GroupNum=0，读取1-4仓
//GroupNum=1，读取5-8仓；
void Get_All_Moniliang_Data_4Cang(uint16_t GroupNum)
{//按照时间片读取1--4仓；5--8仓液位计等模拟量参数
	int j001ReadAll;
	uint16_t id000;
	{////读取1-4,5-8仓模拟量传感器信息--开始

		
		if(GroupNum==0)
		{//读取1-4
				ReadCollect_ValveState_64Byte(0x000003,Collector_Get_WenduYewei_Data_1to4,0x0000,0x0000,0x0000);
				id000=Collector_Get_WenduYewei_Data_1to4;
		    pT2C_MoniLiang_Data=&T2C_MoniLiang_Data_Cang1to4;		
		}//读取1-4
		else
		{//读取5-8
				ReadCollect_ValveState_64Byte(0x000003,Collector_Get_WenduYewei_Data_5to8,0x0000,0x0000,0x0000);
			  id000=Collector_Get_WenduYewei_Data_5to8;
		    pT2C_MoniLiang_Data=&T2C_MoniLiang_Data_Cang5to8;		
		
		}//读取5-8	

		
 
//				HAL_GPIO_TogglePin(GPIOC, DWI_Pin);//复位看门狗sp706
				//HAL_Delay(SPAN_ControllerAndCollector_INTERVAL);
				osDelay(SPAN_ControllerAndCollector_INTERVAL_180);

				chkRetCaiJiBan=CheckInFrame_Collect485(LengthOfData_From_Caijiban_Cang_1to4,id000);
				__NOP();
				if((chkRetCaiJiBan==Collector_Get_WenduYewei_Data_1to4) || (chkRetCaiJiBan==Collector_Get_WenduYewei_Data_5to8))	

				{//如果回复的校验正确---实际为功能码或者消息ID能够匹配
					Usart2_ErrorTimes=0;
					chkRetCaiJiBan=0;
					Collect485.Collect_CommError=False;
					__nop();	
					
					
					
					
					for(j001ReadAll=0;j001ReadAll<16;j001ReadAll++)
					{
						pT2C_MoniLiang_Data->FrameHead[j001ReadAll]=USART2_RX_BUF_Collector[j001ReadAll];
					}
					
					for(j001ReadAll=0;j001ReadAll<8;j001ReadAll++)
					{
						pT2C_MoniLiang_Data->ResData[j001ReadAll]=USART2_RX_BUF_Collector[j001ReadAll+16];
					}					
					
					
					for(j001ReadAll=0;j001ReadAll<FloatData_Num_Caijiban;j001ReadAll++)
					{//52个浮点数数据解析--开始
						ArrayUni_MoniLiang[j001ReadAll].farray[0]=USART2_RX_BUF_Collector[MoiLiangFrom_CaijibanOffset+j001ReadAll*4+0];
						ArrayUni_MoniLiang[j001ReadAll].farray[1]=USART2_RX_BUF_Collector[MoiLiangFrom_CaijibanOffset+j001ReadAll*4+1];
						ArrayUni_MoniLiang[j001ReadAll].farray[2]=USART2_RX_BUF_Collector[MoiLiangFrom_CaijibanOffset+j001ReadAll*4+2];
						ArrayUni_MoniLiang[j001ReadAll].farray[3]=USART2_RX_BUF_Collector[MoiLiangFrom_CaijibanOffset+j001ReadAll*4+3];
					}//52个浮点数数据解析--开始
					
					//整车模拟量数据--8个浮点数
					for(j001ReadAll=0;j001ReadAll<8;j001ReadAll++)
					{
						pT2C_MoniLiang_Data->MoniLiang_DataOf_Car[j001ReadAll]=ArrayUni_MoniLiang[j001ReadAll+0].flo_Data;
					}

					//1--4仓模拟量数据--4*11个浮点数
					for(j001ReadAll=0;j001ReadAll<44;j001ReadAll++)
					{
						pT2C_MoniLiang_Data->MoniLiang_DataOfCang_1to4[j001ReadAll]=ArrayUni_MoniLiang[j001ReadAll+8].flo_Data;
					}					

					pT2C_MoniLiang_Data->chkLRC_Data[0]=USART2_RX_BUF_Collector[LengthOfData_From_Caijiban_Cang_1to4-4];
					pT2C_MoniLiang_Data->chkLRC_Data[1]=USART2_RX_BUF_Collector[LengthOfData_From_Caijiban_Cang_1to4-3];
					
					pT2C_MoniLiang_Data->chkCRCModbus_Data[0]=USART2_RX_BUF_Collector[LengthOfData_From_Caijiban_Cang_1to4-2];
					pT2C_MoniLiang_Data->chkCRCModbus_Data[1]=USART2_RX_BUF_Collector[LengthOfData_From_Caijiban_Cang_1to4-1];	

					__NOP();
					
					memset(USART2_RX_BUF, 0x00, sizeof(USART2_RX_BUF));     //清除接收缓存
					
					
					 

				}//如果回复的校验正确---实际为功能码或者消息ID能够匹配
				else
				{//接收错误异常处理：未接收到数据，或者校验错误等
					Usart2_ErrorTimes++;
						
				}
		
	}//读取1-4,5-8仓模拟量传感器信息--结束
}




////稳油数据更新
/*
修改全局变量
*/
void UpdateWenYouFifo(void)
{
	int i007;
//稳油判断的Fifo   滑动窗操作
								for(i007=0;i007<NumOf_WenYouPanduan-1;i007++)
								{
									ArrYeweiForWenyou[i007]=ArrYeweiForWenyou[i007+1];//Stor[CabinetNumForWenYou].yewei_flo[0];//Stor[0].yewei[0]*SCL_Yewei_Collect2Contr;//
								}
								
								//最新的采样点存入队尾
								ArrYeweiForWenyou[NumOf_WenYouPanduan-1]=Stor[CabinetNumForWenYou].yewei_flo[0];
								
								
								Yewei_max000=ArrYeweiForWenyou[0];
								Yewei_min000=ArrYeweiForWenyou[0];
								Yewei_peak000=0;//ArrYeweiForWenyou[0];
								
								for(i007=0;i007<NumOf_WenYouPanduan;i007++)
								{
									if(ArrYeweiForWenyou[i007]<Yewei_min000)
									{
										Yewei_min000=ArrYeweiForWenyou[i007];
									}
									
									if(ArrYeweiForWenyou[i007]>Yewei_max000)
									{
										Yewei_max000=ArrYeweiForWenyou[i007];
									
									}					
								 
								}
								
								Yewei_peak000=Yewei_max000-Yewei_min000;
}

//64字节帧长度  最初版本的协议--一个bit表示一个开关状态
////阀门状态或运算之后数据解析   用于电子铅封业务
void Parse_0x0013_Data(void)
{
	//数据的处理在CheckInFrame_Collect485中进行，直接进行转换	
	chkRetCaiJiBan=CheckInFrame_Collect485(64,Collector_Get_Valve_OldFormat);

	if(chkRetCaiJiBan==0xA1)
	{
		Usart2_ErrorTimes=0;
		memcpy(ValStateArr_0x13,USART2_RX_BUF,64);
		Collect485.Collect_CommError=False;		
	}
	else
	{//接收错误异常处理：未接收到数据，或者校验错误等
		Usart2_ErrorTimes++;
	}
}

//64字节帧长度  40字节IO状态
//北京部队试用64字节的协议  其他程序均沿用。底卸大小尽
//根据传入的仓号将阀门数据拷贝到相应的单独的缓冲区
void Parse_0x0020_Data_64Byte(void)
{
	int retry;
	for (retry = 0; retry < 50; ++retry)
	{
		if (usart2_rx_flag == True)
			break;
		osDelay(5);
	}
	if (usart2_rx_flag == True)
	{
		usart2_rx_flag = False;

		//指示灯1 表明系统正在运行
		//HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);

		// 39 01 95 50 00 01 00 03 00 20 00 28 95 01 AA AA 00 01 00 00 03 03 01 A5 A5 A5 A5 A5 00 00 00 00
		// 00 A5 A5 A5 A5 A5 00 00 00 00 00 A5 A5 A5 A5 A5 00 00 00 00 00 A5 A5 A5 A5 A5 00 00 00 00 F0 93
		// 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
		// 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 33 39 30 31 33 39 34 31 0D 0A
		//
		CangNum000 = USART2_RX_BUF[17]; //分析仓号
		CRC_data = CRC16_MODBUS(USART2_RX_BUF, 62);
		CRC_dataCaiJiBan = (USART2_RX_BUF[62] << 8) + USART2_RX_BUF[63];

		if (CRC_dataCaiJiBan == CRC_data)
		{ // if(CRC_dataCaiJiBan==CRC_data)

			memcpy(ValStateArr_0x20, USART2_RX_BUF, 64);
			// CangNum000=9;
			switch (CangNum000)
			{
			case 1:
				memcpy(Cang01_IO, USART2_RX_BUF, 64);
				//memcpy(ValStateArr_0x20_Cang01, USART2_RX_BUF, 64);
				HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
				break;
			case 2:
				memcpy(Cang02_IO, USART2_RX_BUF, 64);
				//memcpy(ValStateArr_0x20_Cang02, USART2_RX_BUF, 64);
				//HAL_GPIO_TogglePin(LED2_GPIO_Port, LED3_Pin);
				break;
			case 3:
				memcpy(Cang03_IO, USART2_RX_BUF, 64);
				//memcpy(ValStateArr_0x20_Cang03, USART2_RX_BUF, 64);
				//HAL_GPIO_TogglePin(LED2_GPIO_Port, LED4_Pin);
				break;
			case 4:
				memcpy(Cang04_IO, USART2_RX_BUF, 64);
				//memcpy(ValStateArr_0x20_Cang04, USART2_RX_BUF, 64);
				//HAL_GPIO_TogglePin(LED2_GPIO_Port, LED5_Pin);
				break;
			case 5:
				memcpy(Cang05_IO, USART2_RX_BUF, 64);
				break;
			case 6:
				memcpy(Cang06_IO, USART2_RX_BUF, 64);
				break;
			case 7:
				memcpy(Cang07_IO, USART2_RX_BUF, 64);
				break;
			case 8:
				memcpy(Cang08_IO, USART2_RX_BUF, 64);
				break;
			default:
				break;
			}
			Translate_IO_to_U32Bit_V2();
			//Translate_IO_to_U32Bit();
		} // if(CRC_dataCaiJiBan==CRC_data)
	} // if(usart2_rx_flag==True)
	/*else
	{
	}*/
}





void Translate_IO_to_U32Bit_V2(void)
{
		uint32_t IO_Exception_State011,IO_OnOff_State011;
		int i;
//第1组阀门--------------------------------------------------------开始	
		for(i=0;i<4;++i)
		{	
		//////////////////////////////--1仓
		IO_Exception_State011 = 0;
		IO_OnOff_State011 = 0;
		if(Cang01_IO[indexHaiDiFa01+10*i]==0x03)//海底阀
		{//海底阀
			IO_Exception_State011|=U32_BIT_03;
		}//海底阀
		else
		{//海底阀
			//IO_Exception_State01&=(!U32_BIT_03);//异常状态标志清零
			
			if(Cang01_IO[indexHaiDiFa01+10*i]==0x01)//海底阀
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_03;
			}
			/*else if(Cang01_IO[indexHaiDiFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_03);
			}*/			
		}//海底阀
		
		if(Cang01_IO[indexXieYouFa01+10*i]==0x03)//卸油阀
		{//卸油阀
			IO_Exception_State011|=U32_BIT_02;
		}//卸油阀
		else
		{//卸油阀
			//IO_Exception_State01&=(!U32_BIT_02);//异常状态标志清零
			
			if(Cang01_IO[indexXieYouFa01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_02;
			}
			/*else if(Cang01_IO[indexXieYouFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State011&=(!U32_BIT_02);
			}	*/		
		}//卸油阀

		if(Cang01_IO[indexDaGai01+10*i]==0x03)//人孔大盖
		{///人孔大盖
			IO_Exception_State011|=U32_BIT_01;
		}////人孔大盖
		else
		{////人孔大盖
		//	IO_Exception_State01&=(!U32_BIT_01);//异常状态标志清零
			
			if(Cang01_IO[indexDaGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_01;
			}
			/*else if(Cang01_IO[indexDaGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_01);
			}	*/		
		}////人孔大盖
		
		if(Cang01_IO[indexXiaoGai01+10*i]==0x03)//人孔小盖
		{///人孔小盖
			IO_Exception_State011|=U32_BIT_00;
		}////人孔小盖
		else
		{////人孔小盖
			//IO_Exception_State01&=(!U32_BIT_00);//异常状态标志清零
			
			if(Cang01_IO[indexXiaoGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_00;
			}
			/*else if(Cang01_IO[indexXiaoGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_00);
			}	*/		
		}////人孔小盖
		
		////////////////////////////--2仓开始
		if(Cang02_IO[indexHaiDiFa01+10*i]==0x03)//海底阀
		{//海底阀
			IO_Exception_State011|=U32_BIT_07;
		}//海底阀
		else
		{//海底阀
			//IO_Exception_State01&=(!U32_BIT_07);//异常状态标志清零
			
			if(Cang02_IO[indexHaiDiFa01+10*i]==0x01)//海底阀
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_07;
			}
			/*else if(Cang02_IO[indexHaiDiFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_07);
			}*/			
		}//海底阀
		
		if(Cang02_IO[indexXieYouFa01+10*i]==0x03)//卸油阀
		{//卸油阀
			IO_Exception_State011|=U32_BIT_06;
		}//卸油阀
		else
		{//卸油阀
			//IO_Exception_State011&=(!U32_BIT_06);//异常状态标志清零
			
			if(Cang02_IO[indexXieYouFa01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_06;
			}
		/*	else if(Cang02_IO[indexXieYouFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_06);
			}	*/		
		}//卸油阀

		if(Cang02_IO[indexDaGai01+10*i]==0x03)//人孔大盖
		{///人孔大盖
			IO_Exception_State011|=U32_BIT_05;
		}////人孔大盖
		else
		{////人孔大盖
		//	IO_Exception_State01&=(!U32_BIT_05);//异常状态标志清零
			
			if(Cang02_IO[indexDaGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_05;
			}
			/*else if(Cang02_IO[indexDaGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_05);
			}*/			
		}////人孔大盖
		
		if(Cang02_IO[indexXiaoGai01+10*i]==0x03)//人孔小盖
		{///人孔小盖
			IO_Exception_State011|=U32_BIT_04;
		}////人孔小盖
		else
		{////人孔小盖
			//IO_Exception_State01&=(!U32_BIT_04);//异常状态标志清零
			
			if(Cang02_IO[indexXiaoGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_04;
			}
			/*else if(Cang02_IO[indexXiaoGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_04);
			}*/			
		}////人孔小盖
		////////////////////////////--2仓结束
		
////////////////////////////--3仓开始
		if(Cang03_IO[indexHaiDiFa01+10*i]==0x03)//海底阀
		{//海底阀
			IO_Exception_State011|=U32_BIT_11;
		}//海底阀
		else
		{//海底阀
			//IO_Exception_State01&=(!U32_BIT_11);//异常状态标志清零
			
			if(Cang03_IO[indexHaiDiFa01+10*i]==0x01)//海底阀
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_11;
			}
			/*else if(Cang03_IO[indexHaiDiFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_11);
			}	*/		
		}//海底阀
		
		if(Cang03_IO[indexXieYouFa01+10*i]==0x03)//卸油阀
		{//卸油阀
			IO_Exception_State011|=U32_BIT_10;
		}//卸油阀
		else
		{//卸油阀
			//IO_Exception_State01&=(!U32_BIT_10);//异常状态标志清零
			
			if(Cang03_IO[indexXieYouFa01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_10;
			}
			/*else if(Cang03_IO[indexXieYouFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_10);
			}*/			
		}//卸油阀

		if(Cang03_IO[indexDaGai01+10*i]==0x03)//人孔大盖
		{///人孔大盖
			IO_Exception_State011|=U32_BIT_09;
		}////人孔大盖
		else
		{////人孔大盖
		//	IO_Exception_State01&=(!U32_BIT_09);//异常状态标志清零
			
			if(Cang03_IO[indexDaGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_09;
			}
			/*else if(Cang03_IO[indexDaGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_09);
			}*/			
		}////人孔大盖
		
		if(Cang03_IO[indexXiaoGai01+10*i]==0x03)//人孔小盖
		{///人孔小盖
			IO_Exception_State011|=U32_BIT_08;
		}////人孔小盖
		else
		{////人孔小盖
			//IO_Exception_State01&=(!U32_BIT_08);//异常状态标志清零
			
			if(Cang03_IO[indexXiaoGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_08;
			}
			/*else if(Cang03_IO[indexXiaoGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_08);
			}	*/		
		}////人孔小盖
		////////////////////////////--3仓结束		
		


////////////////////////////--4仓开始
		if(Cang04_IO[indexHaiDiFa01+10*i]==0x03)//海底阀
		{//海底阀
			IO_Exception_State011|=U32_BIT_15;
		}//海底阀
		else
		{//海底阀
			//IO_Exception_State01&=(!U32_BIT_15);//异常状态标志清零
			
			if(Cang04_IO[indexHaiDiFa01+10*i]==0x01)//海底阀
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_15;
			}
			/*else if(Cang04_IO[indexHaiDiFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_15);
			}*/			
		}//海底阀
		
		if(Cang04_IO[indexXieYouFa01+10*i]==0x03)//卸油阀
		{//卸油阀
			IO_Exception_State011|=U32_BIT_14;
		}//卸油阀
		else
		{//卸油阀
			//IO_Exception_State01&=(!U32_BIT_14);//异常状态标志清零
			
			if(Cang04_IO[indexXieYouFa01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_14;
			}
		/*	else if(Cang04_IO[indexXieYouFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_14);
			}*/			
		}//卸油阀

		if(Cang04_IO[indexDaGai01+10*i]==0x03)//人孔大盖
		{///人孔大盖
			IO_Exception_State011|=U32_BIT_13;
		}////人孔大盖
		else
		{////人孔大盖
		//	IO_Exception_State01&=(!U32_BIT_13);//异常状态标志清零
			
			if(Cang04_IO[indexDaGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_13;
			}
			/*else if(Cang04_IO[indexDaGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_13);
			}	*/		
		}////人孔大盖
		
		if(Cang04_IO[indexXiaoGai01+10*i]==0x03)//人孔小盖
		{///人孔小盖
			IO_Exception_State011|=U32_BIT_12;
		}////人孔小盖
		else
		{////人孔小盖
			//IO_Exception_State01&=(!U32_BIT_12);//异常状态标志清零
			
			if(Cang04_IO[indexXiaoGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_12;
			}
			/*else if(Cang04_IO[indexXiaoGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_12);
			}*/			
		}////人孔小盖
		////////////////////////////--4仓结束	

		
		////////////////////////////--5仓开始
		if(Cang05_IO[indexHaiDiFa01+10*i]==0x03)//海底阀
		{//海底阀
			IO_Exception_State011|=U32_BIT_19;
		}//海底阀
		else
		{//海底阀
			//IO_Exception_State01&=(!U32_BIT_19);//异常状态标志清零
			
			if(Cang05_IO[indexHaiDiFa01+10*i]==0x01)//海底阀
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_19;
			}
			/*else if(Cang05_IO[indexHaiDiFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_19);
			}*/			
		}//海底阀
		
		if(Cang05_IO[indexXieYouFa01+10*i]==0x03)//卸油阀
		{//卸油阀
			IO_Exception_State011|=U32_BIT_18;
		}//卸油阀
		else
		{//卸油阀
			//IO_Exception_State01&=(!U32_BIT_18);//异常状态标志清零
			
			if(Cang05_IO[indexXieYouFa01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_18;
			}
			/*else if(Cang05_IO[indexXieYouFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_18);
			}	*/		
		}//卸油阀

		if(Cang05_IO[indexDaGai01+10*i]==0x03)//人孔大盖
		{///人孔大盖
			IO_Exception_State011|=U32_BIT_17;
		}////人孔大盖
		else
		{////人孔大盖
			//IO_Exception_State01&=(!U32_BIT_17);//异常状态标志清零
			
			if(Cang05_IO[indexDaGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_17;
			}
			/*else if(Cang05_IO[indexDaGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_17);
			}*/			
		}////人孔大盖
		
		if(Cang05_IO[indexXiaoGai01+10*i]==0x03)//人孔小盖
		{///人孔小盖
			IO_Exception_State011|=U32_BIT_16;
		}////人孔小盖
		else
		{////人孔小盖
			//IO_Exception_State01&=(!U32_BIT_16);//异常状态标志清零
			
			if(Cang05_IO[indexXiaoGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_16;
			}
			/*else if(Cang05_IO[indexXiaoGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_16);
			}*/			
		}////人孔小盖
		////////////////////////////--5仓结束
		
		
		
				////////////////////////////--6仓开始
		if(Cang06_IO[indexHaiDiFa01+10*i]==0x03)//海底阀
		{//海底阀
			IO_Exception_State011|=U32_BIT_23;
		}//海底阀
		else
		{//海底阀
		//	IO_Exception_State01&=(!U32_BIT_23);//异常状态标志清零
			
			if(Cang06_IO[indexHaiDiFa01+10*i]==0x01)//海底阀
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_23;
			}
			/*else if(Cang06_IO[indexHaiDiFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_23);
			}*/			
		}//海底阀
		
		if(Cang06_IO[indexXieYouFa01+10*i]==0x03)//卸油阀
		{//卸油阀
			IO_Exception_State011|=U32_BIT_22;
		}//卸油阀
		else
		{//卸油阀
			//IO_Exception_State01&=(!U32_BIT_22);//异常状态标志清零
			
			if(Cang06_IO[indexXieYouFa01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_22;
			}
			/*else if(Cang06_IO[indexXieYouFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_22);
			}	*/		
		}//卸油阀

		if(Cang06_IO[indexDaGai01+10*i]==0x03)//人孔大盖
		{///人孔大盖
			IO_Exception_State011|=U32_BIT_21;
		}////人孔大盖
		else
		{////人孔大盖
			//IO_Exception_State01&=(!U32_BIT_21);//异常状态标志清零
			
			if(Cang06_IO[indexDaGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_21;
			}
			/*else if(Cang06_IO[indexDaGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_21);
			}*/			
		}////人孔大盖
		
		if(Cang06_IO[indexXiaoGai01+10*i]==0x03)//人孔小盖
		{///人孔小盖
			IO_Exception_State011|=U32_BIT_20;
		}////人孔小盖
		else
		{////人孔小盖
			//IO_Exception_State01&=(!U32_BIT_20);//异常状态标志清零
			
			if(Cang06_IO[indexXiaoGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_20;
			}
			/*else if(Cang06_IO[indexXiaoGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_20);
			}*/			
		}////人孔小盖
		////////////////////////////--6仓结束
		
		
		
			
				////////////////////////////--7仓开始
		if(Cang07_IO[indexHaiDiFa01+10*i]==0x03)//海底阀
		{//海底阀
			IO_Exception_State011|=U32_BIT_27;
		}//海底阀
		else
		{//海底阀
			//IO_Exception_State01&=(!U32_BIT_27);//异常状态标志清零
			
			if(Cang07_IO[indexHaiDiFa01+10*i]==0x01)//海底阀
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_27;
			}
			/*else if(Cang07_IO[indexHaiDiFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_27);
			}*/			
		}//海底阀
		
		if(Cang07_IO[indexXieYouFa01+10*i]==0x03)//卸油阀
		{//卸油阀
			IO_Exception_State011|=U32_BIT_26;
		}//卸油阀
		else
		{//卸油阀
		//	IO_Exception_State01&=(!U32_BIT_26);//异常状态标志清零
			
			if(Cang07_IO[indexXieYouFa01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_26;
			}
			/*else if(Cang07_IO[indexXieYouFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_26);
			}*/			
		}//卸油阀

		if(Cang07_IO[indexDaGai01+10*i]==0x03)//人孔大盖
		{///人孔大盖
			IO_Exception_State011|=U32_BIT_25;
		}////人孔大盖
		else
		{////人孔大盖
			//IO_Exception_State01&=(!U32_BIT_25);//异常状态标志清零
			
			if(Cang07_IO[indexDaGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_25;
			}
			/*else if(Cang07_IO[indexDaGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_25);
			}*/			
		}////人孔大盖
		
		if(Cang07_IO[indexXiaoGai01+10*i]==0x03)//人孔小盖
		{///人孔小盖
			IO_Exception_State011|=U32_BIT_24;
		}////人孔小盖
		else
		{////人孔小盖
			//IO_Exception_State01&=(!U32_BIT_24);//异常状态标志清零
			
			if(Cang07_IO[indexXiaoGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_24;
			}
			/*else if(Cang07_IO[indexXiaoGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_24);
			}*/			
		}////人孔小盖
		////////////////////////////--7仓结束
		
		
		
				////////////////////////////--8仓开始
		if(Cang08_IO[indexHaiDiFa01+10*i]==0x03)//海底阀
		{//海底阀
			IO_Exception_State011|=U32_BIT_31;
		}//海底阀
		else
		{//海底阀
		//	IO_Exception_State01&=(!U32_BIT_31);//异常状态标志清零
			
			if(Cang08_IO[indexHaiDiFa01+10*i]==0x01)//海底阀
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_31;
			}
			/*else if(Cang08_IO[indexHaiDiFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_31);
			}*/			
		}//海底阀
		
		if(Cang08_IO[indexXieYouFa01+10*i]==0x03)//卸油阀
		{//卸油阀
			IO_Exception_State011|=U32_BIT_30;
		}//卸油阀
		else
		{//卸油阀
			//IO_Exception_State01&=(!U32_BIT_30);//异常状态标志清零
			
			if(Cang08_IO[indexXieYouFa01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_30;
			}
			/*else if(Cang08_IO[indexXieYouFa01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_30);
			}*/			
		}//卸油阀

		if(Cang08_IO[indexDaGai01+10*i]==0x03)//人孔大盖
		{///人孔大盖
			IO_Exception_State011|=U32_BIT_29;
		}////人孔大盖
		else
		{////人孔大盖
			//IO_Exception_State01&=(!U32_BIT_29);//异常状态标志清零
			
			if(Cang08_IO[indexDaGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_29;
			}
			/*else if(Cang08_IO[indexDaGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_29);
			}*/			
		}////人孔大盖
		
		if(Cang08_IO[indexXiaoGai01+10*i]==0x03)//人孔小盖
		{///人孔小盖
			IO_Exception_State011|=U32_BIT_28;
		}////人孔小盖
		else
		{////人孔小盖
			//IO_Exception_State01&=(!U32_BIT_28);//异常状态标志清零
			
			if(Cang08_IO[indexXiaoGai01+10*i]==0x01) 
			{//开关状态置位
					IO_OnOff_State011|=U32_BIT_28;
			}
			/*else if(Cang08_IO[indexXiaoGai01]==0x00)
			{//开关状态清零
					IO_OnOff_State01&=(!U32_BIT_28);
			}*/			
		}////人孔小盖
		switch (i)
		{
		case 0:
			IO_OnOff_State01 = IO_OnOff_State011;
			IO_Exception_State01 = IO_Exception_State011;
			break;
		case 1:
			IO_OnOff_State02 = IO_OnOff_State011;
			IO_Exception_State02 = IO_Exception_State011;
			break;
		case 2:
			IO_OnOff_State03 = IO_OnOff_State011;
			IO_Exception_State03 = IO_Exception_State011;
			break;
		case 3:
			IO_OnOff_State04 = IO_OnOff_State011;
			IO_Exception_State04 = IO_Exception_State011;
			break;
		default:
			break;
		}
		
		////////////////////////////--8仓结束
		}
		
		
		
		
//第1组阀门--------------------------------------------------------结束		
}




/*
	20采集上来的分仓数据合成转换到
*/
uni_float  tmp_uni_trans;

void Translate_IO_to_U32Bit(void)
{
	int i;
#if 0
uint8_t tmpArr[40]=
{ 
	
	0x00,0x00,0x00,0x00,0x01,0xa5,0x01,0x01,0x01,0xa5,
	0x00,0x00,0x00,0x00,0x00,0xa5,0x01,0x01,0x01,0xa5,
	0x00,0x00,0x00,0x00,0x00,0xa5,0x01,0x01,0x01,0xa5,
	0x01,0x01,0x03,0x01,0x01,0xa5,0x01,0x01,0x01,0xa5,
};	

   //仅供测试 
		if(1==0)
		{
			memcpy(&Cang01_IO[indexHaiDiFa01],tmpArr,40);
			memcpy(&Cang02_IO[indexHaiDiFa01],tmpArr,40);
			memcpy(&Cang03_IO[indexHaiDiFa01],tmpArr,40);
			memcpy(&Cang04_IO[indexHaiDiFa01],tmpArr,40);
			memcpy(&Cang05_IO[indexHaiDiFa01],tmpArr,40);
			memcpy(&Cang06_IO[indexHaiDiFa01],tmpArr,40);
			memcpy(&Cang07_IO[indexHaiDiFa01],tmpArr,40);
			memcpy(&Cang08_IO[indexHaiDiFa01],tmpArr,40);
		}
#endif


	//taskENTER_CRITICAL();	
	//第1组阀门状态--开始；索引为16开始，依次为海底阀，卸油阀，大盖，小盖，卸尽传感器
//	memcpy(&Array_IO_OnOff_AllStore[0+0],&Cang01_IO[indexHaiDiFa01],4);
//	memcpy(&Array_IO_OnOff_AllStore[0+4],&Cang02_IO[indexHaiDiFa01],4);
//

	for (i = 0; i < 4; ++i)
	{
		Array_IO_OnOff_AllStore[0+i] = Cang01_IO[indexHaiDiFa01+i];
		Array_IO_OnOff_AllStore[4+i] = Cang02_IO[indexHaiDiFa01+i];
		Array_IO_OnOff_AllStore[8+i] = Cang03_IO[indexHaiDiFa01+i];
		Array_IO_OnOff_AllStore[12+i] = Cang04_IO[indexHaiDiFa01+i];
		Array_IO_OnOff_AllStore[16+i] = Cang05_IO[indexHaiDiFa01+i];
	}
#if 0	
  Array_IO_OnOff_AllStore[0]=Cang01_IO[indexHaiDiFa01];
	Array_IO_OnOff_AllStore[1]=Cang01_IO[indexHaiDiFa01+1];
  Array_IO_OnOff_AllStore[2]=Cang01_IO[indexHaiDiFa01+2];
	Array_IO_OnOff_AllStore[3]=Cang01_IO[indexHaiDiFa01+3];
		
	Array_IO_OnOff_AllStore[4]=Cang02_IO[indexHaiDiFa01];
	Array_IO_OnOff_AllStore[5]=Cang02_IO[indexHaiDiFa01+1];
  Array_IO_OnOff_AllStore[6]=Cang02_IO[indexHaiDiFa01+2];
	Array_IO_OnOff_AllStore[7]=Cang02_IO[indexHaiDiFa01+3];
	

  //memcpy(&Cang03_IO[indexHaiDiFa01],tmpArr,40);//仅供测试   发行时必须删除

	Array_IO_OnOff_AllStore[8]=Cang03_IO[indexHaiDiFa01];
	Array_IO_OnOff_AllStore[9]=Cang03_IO[indexHaiDiFa01+1];
  Array_IO_OnOff_AllStore[10]=Cang03_IO[indexHaiDiFa01+2];
	Array_IO_OnOff_AllStore[11]=Cang03_IO[indexHaiDiFa01+3];		
	
	Array_IO_OnOff_AllStore[12]=Cang04_IO[indexHaiDiFa01];
	Array_IO_OnOff_AllStore[13]=Cang04_IO[indexHaiDiFa01+1];
  Array_IO_OnOff_AllStore[14]=Cang04_IO[indexHaiDiFa01+2];
	Array_IO_OnOff_AllStore[15]=Cang04_IO[indexHaiDiFa01+3];		
			
		
//	memcpy(&Array_IO_OnOff_AllStore[0+8],&Cang03_IO[indexHaiDiFa01],4);
//	memcpy(&Array_IO_OnOff_AllStore[0+12],&Cang04_IO[indexHaiDiFa01],4);
	memcpy(&Array_IO_OnOff_AllStore[0+16],&Cang05_IO[indexHaiDiFa01],4);
	memcpy(&Array_IO_OnOff_AllStore[0+20],&Cang06_IO[indexHaiDiFa01],4);
	memcpy(&Array_IO_OnOff_AllStore[0+24],&Cang07_IO[indexHaiDiFa01],4);
	memcpy(&Array_IO_OnOff_AllStore[0+28],&Cang08_IO[indexHaiDiFa01],4);
#endif	
//	taskEXIT_CRITICAL();
 	
	
	
	IO_Exception_State01=0;
	
	

	
//	for(i_trans=0;i_trans<32;i_trans++)
//  {//8个仓位的第一组阀门异常状态
//		
//		if(Array_IO_OnOff_AllStore[i_trans]==0x03)
//		{
//				IO_Exception_State01|=(1<<(i_trans));		
//		}
//		
//  }//8个仓位的第一组阀门异常状态	

    //1仓四个阀门，字节顺序为底卸大小--第一组U32
		if(Array_IO_OnOff_AllStore[0]==0x03)
		{//海底阀异常状态
				IO_Exception_State01|=U32_BIT_03;		
		}
		
		if(Array_IO_OnOff_AllStore[1]==0x03)
			{//卸油阀异常状态
				IO_Exception_State01|=U32_BIT_02;		
		}
		
		if(Array_IO_OnOff_AllStore[2]==0x03)
		{//大盖异常状态
				IO_Exception_State01|=U32_BIT_01;		
		}
		
		if(Array_IO_OnOff_AllStore[3]==0x03)
		{//小盖异常状态
				IO_Exception_State01|=U32_BIT_00;		
		}
		
		
		
		
		
		
		//2仓四个阀门，字节顺序为底卸大小--第一组U32
		if(Array_IO_OnOff_AllStore[0+4]==0x03)
		{//海底阀异常状态
				IO_Exception_State01|=U32_BIT_07;		
		}
		
		if(Array_IO_OnOff_AllStore[4+1]==0x03)
			{//卸油阀异常状态
				IO_Exception_State01|=U32_BIT_06;		
		}
		
		if(Array_IO_OnOff_AllStore[4+2]==0x03)
		{//大盖异常状态
				IO_Exception_State01|=U32_BIT_05;		
		}
		
		if(Array_IO_OnOff_AllStore[4+3]==0x03)
		{//小盖异常状态
				IO_Exception_State01|=U32_BIT_04;		
		}
		
		
		//3仓四个阀门，字节顺序为底卸大小--第一组U32
		if(Array_IO_OnOff_AllStore[8+0]==0x03)
		{//海底阀异常状态
				IO_Exception_State01|=U32_BIT_11;		
		}
		
		if(Array_IO_OnOff_AllStore[8+1]==0x03)
			{//卸油阀异常状态
				IO_Exception_State01|=U32_BIT_10;		
		}
		
		if(Array_IO_OnOff_AllStore[8+2]==0x03)
		{//大盖异常状态
				IO_Exception_State01|=U32_BIT_09;		
		}
		
		if(Array_IO_OnOff_AllStore[8+3]==0x03)
		{//小盖异常状态
				IO_Exception_State01|=U32_BIT_08;		
		}		
		
		

		
		

    IO_OnOff_State01=0x00;
		
    //第一组四个阀门的开关状态，字节顺序为底卸大小----第1仓数据
		if(Array_IO_OnOff_AllStore[0]==0x01)
		{//海底阀开关状态--1仓
				IO_OnOff_State01|=U32_BIT_03;		
		}
		
		if(Array_IO_OnOff_AllStore[1]==0x01)
			{//卸油阀开关状态
				IO_OnOff_State01|=U32_BIT_02;		
		}
		
		if(Array_IO_OnOff_AllStore[2]==0x01)
		{//大盖开关状态
				IO_OnOff_State01|=U32_BIT_01;		
		}
		
		if(Array_IO_OnOff_AllStore[3]==0x01)
		{//小盖开关状态
				IO_OnOff_State01|=U32_BIT_00;		
		}
		
    //第一组四个阀门的开关状态，字节顺序为底卸大小----第2仓数据
		if(Array_IO_OnOff_AllStore[0+4]==0x01)
		{//海底阀开关状态--1仓
				IO_OnOff_State01|=U32_BIT_07;		
		}
		
		if(Array_IO_OnOff_AllStore[1+4]==0x01)
			{//卸油阀开关状态
				IO_OnOff_State01|=U32_BIT_06;		
		}
		
		if(Array_IO_OnOff_AllStore[2+4]==0x01)
		{//大盖开关状态
				IO_OnOff_State01|=U32_BIT_05;		
		}
		
		if(Array_IO_OnOff_AllStore[3+4]==0x01)
		{//小盖开关状态
				IO_OnOff_State01|=U32_BIT_04;		
		}
		
    //第一组四个阀门的开关状态，字节顺序为底卸大小----第3仓数据
		if(Array_IO_OnOff_AllStore[0+4*2]==0x01)
		{//海底阀开关状态--1仓
				IO_OnOff_State01|=U32_BIT_11;		
		}
		
		if(Array_IO_OnOff_AllStore[1+4*2]==0x01)
			{//卸油阀开关状态
				IO_OnOff_State01|=U32_BIT_10;		
		}
		
		if(Array_IO_OnOff_AllStore[2+4*2]==0x01)
		{//大盖开关状态
				IO_OnOff_State01|=U32_BIT_09;		
		}
		
		if(Array_IO_OnOff_AllStore[3+4*2]==0x01)
		{//小盖开关状态
				IO_OnOff_State01|=U32_BIT_08;		
		}		
		
		
    //第一组四个阀门的开关状态，字节顺序为底卸大小----第4仓数据
		if(Array_IO_OnOff_AllStore[0+4*3]==0x01)
		{//海底阀开关状态--1仓
				IO_OnOff_State01|=U32_BIT_15;		
		}
		
		if(Array_IO_OnOff_AllStore[1+4*3]==0x01)
			{//卸油阀开关状态
				IO_OnOff_State01|=U32_BIT_14;		
		}
		
		if(Array_IO_OnOff_AllStore[2+4*3]==0x01)
		{//大盖开关状态
				IO_OnOff_State01|=U32_BIT_13;		
		}
		
		if(Array_IO_OnOff_AllStore[3+4*3]==0x01)
		{//小盖开关状态
				IO_OnOff_State01|=U32_BIT_12;		
		}		
		
//		//第一组异常状态----1-8仓
//		IO_Exception_State01=0xaabbccdd;//仅供测试
//		tmp_uni_trans.u32Dat=IO_Exception_State01;
//		Array_Of_Valve[7+8*0]=tmp_uni_trans.array_u8[3];
//		Array_Of_Valve[6+8*0]=tmp_uni_trans.array_u8[2];
//		Array_Of_Valve[5+8*0]=tmp_uni_trans.array_u8[1];
//		Array_Of_Valve[4+8*0]=tmp_uni_trans.array_u8[0];
//		
//		
//		////第一组开关状态----1-8仓
//		IO_OnOff_State01=0x55667788;//仅供测试
//		tmp_uni_trans.u32Dat=IO_OnOff_State01;
//		Array_Of_Valve[3+8*0]=tmp_uni_trans.array_u8[3];
//		Array_Of_Valve[2+8*0]=tmp_uni_trans.array_u8[2];
//		Array_Of_Valve[1+8*0]=tmp_uni_trans.array_u8[1];
//		Array_Of_Valve[0+8*0]=tmp_uni_trans.array_u8[0];		
		
		//__NOP();
		
		
//		//第2组异常状态----1-8仓
//		tmp_uni_trans.u32Dat=IO_Exception_State02;
//		Array_Of_Valve[7+8*1]=tmp_uni_trans.array_u8[3];
//		Array_Of_Valve[6+8*1]=tmp_uni_trans.array_u8[2];
//		Array_Of_Valve[5+8*1]=tmp_uni_trans.array_u8[1];
//		Array_Of_Valve[4+8*1]=tmp_uni_trans.array_u8[0];
//		
//		
//		////第2组开关状态----1-8仓
//		tmp_uni_trans.u32Dat=IO_OnOff_State02;
//		Array_Of_Valve[3+8*1]=tmp_uni_trans.array_u8[3];
//		Array_Of_Valve[2+8*1]=tmp_uni_trans.array_u8[2];
//		Array_Of_Valve[1+8*1]=tmp_uni_trans.array_u8[1];
//		Array_Of_Valve[0+8*1]=tmp_uni_trans.array_u8[0];	
//		


		
		
		
/*		
  
	
//	IO_OnOff_State01=0;
//	for(i_trans=0;i_trans<32;i_trans++)
//  {//8个仓位的阀门开关状态	
//		
//		if(Array_IO_OnOff_AllStore[i_trans]==0x01)
//		{
//				IO_OnOff_State01|=(1<<(i_trans));		
//		}

//  }	//8个仓位的第2组阀门开关状态
	//第1组阀门状态--结束；索引为16开始，依次为海底阀，卸油阀，大盖，小盖，卸尽传感器
	
	
	
//	//第2组阀门状态--开始；索引为26开始，依次为海底阀，卸油阀，大盖，小盖，卸尽传感器
//	memcpy(&Array_IO_OnOff_AllStore[0+0],&Cang01_IO[indexHaiDiFa02],4);
//	memcpy(&Array_IO_OnOff_AllStore[0+4],&Cang02_IO[indexHaiDiFa02],4);
//	memcpy(&Array_IO_OnOff_AllStore[0+8],&Cang03_IO[indexHaiDiFa02],4);
//	memcpy(&Array_IO_OnOff_AllStore[0+12],&Cang04_IO[indexHaiDiFa02],4);
//	memcpy(&Array_IO_OnOff_AllStore[0+16],&Cang05_IO[indexHaiDiFa02],4);
//	memcpy(&Array_IO_OnOff_AllStore[0+20],&Cang06_IO[indexHaiDiFa02],4);
//	memcpy(&Array_IO_OnOff_AllStore[0+24],&Cang07_IO[indexHaiDiFa02],4);
//	memcpy(&Array_IO_OnOff_AllStore[0+28],&Cang08_IO[indexHaiDiFa02],4);
	
//	for(i_trans=0;i_trans<8;i_trans++)
//  {//8个仓位的阀门异常状态
//		
//	}
 
	
 	IO_Exception_State02=0;
	
	for(i_trans=0;i_trans<32;i_trans++)
  {//8个仓位的阀门异常状态
		
		if(Array_IO_OnOff_AllStore[i_trans]==0x03)
		{
				IO_Exception_State02|=(1<<(i_trans));		
		}
		
  }//8个仓位的阀门异常状态	
	
	IO_OnOff_State02=0;
	for(i_trans=0;i_trans<32;i_trans++)
  {//8个仓位的阀门开关状态	
		
		if(Array_IO_OnOff_AllStore[i_trans]==0x01)
		{
				IO_OnOff_State02|=(1<<(i_trans));		
		}

  }	//8个仓位的第2组阀门开关状态
	//第2组阀门状态--结束；索引为26开始，依次为海底阀，卸油阀，大盖，小盖，卸尽传感器
	
	
	
//第3组阀门状态--开始；索引为36开始，依次为海底阀，卸油阀，大盖，小盖，卸尽传感器
	memcpy(&Array_IO_OnOff_AllStore[0+0],&Cang01_IO[indexHaiDiFa03],4);
	memcpy(&Array_IO_OnOff_AllStore[0+4],&Cang02_IO[indexHaiDiFa03],4);
	memcpy(&Array_IO_OnOff_AllStore[0+8],&Cang03_IO[indexHaiDiFa03],4);
	memcpy(&Array_IO_OnOff_AllStore[0+12],&Cang04_IO[indexHaiDiFa03],4);
	memcpy(&Array_IO_OnOff_AllStore[0+16],&Cang05_IO[indexHaiDiFa03],4);
	memcpy(&Array_IO_OnOff_AllStore[0+20],&Cang06_IO[indexHaiDiFa03],4);
	memcpy(&Array_IO_OnOff_AllStore[0+24],&Cang07_IO[indexHaiDiFa03],4);
	memcpy(&Array_IO_OnOff_AllStore[0+28],&Cang08_IO[indexHaiDiFa03],4);
	
//	for(i_trans=0;i_trans<8;i_trans++)
//  {//8个仓位的阀门异常状态
//		
//	}
	 
	
 	IO_Exception_State03=0;
	
	for(i_trans=0;i_trans<32;i_trans++)
  {//8个仓位的阀门异常状态
		
		if(Array_IO_OnOff_AllStore[i_trans]==0x03)
		{
				IO_Exception_State03|=(1<<(i_trans));		
		}
		
  }//8个仓位的阀门异常状态	
	
	IO_OnOff_State03=0;
	for(i_trans=0;i_trans<32;i_trans++)
  {//8个仓位的阀门开关状态	
		
		if(Array_IO_OnOff_AllStore[i_trans]==0x01)
		{
				IO_OnOff_State03|=(1<<(i_trans));		
		}

  }	//8个仓位的第3组阀门开关状态
	//第3组阀门状态--结束；索引为36开始，依次为海底阀，卸油阀，大盖，小盖，卸尽传感器	

//第4组阀门状态--开始；索引为46开始，依次为海底阀，卸油阀，大盖，小盖，卸尽传感器
	memcpy(&Array_IO_OnOff_AllStore[0+0],&Cang01_IO[indexHaiDiFa04],4);
	memcpy(&Array_IO_OnOff_AllStore[0+4],&Cang02_IO[indexHaiDiFa04],4);
	memcpy(&Array_IO_OnOff_AllStore[0+8],&Cang03_IO[indexHaiDiFa04],4);
	memcpy(&Array_IO_OnOff_AllStore[0+12],&Cang04_IO[indexHaiDiFa04],4);
	memcpy(&Array_IO_OnOff_AllStore[0+16],&Cang05_IO[indexHaiDiFa04],4);
	memcpy(&Array_IO_OnOff_AllStore[0+20],&Cang06_IO[indexHaiDiFa04],4);
	memcpy(&Array_IO_OnOff_AllStore[0+24],&Cang07_IO[indexHaiDiFa04],4);
	memcpy(&Array_IO_OnOff_AllStore[0+28],&Cang08_IO[indexHaiDiFa04],4);
	
//	for(i_trans=0;i_trans<8;i_trans++)
//  {//8个仓位的阀门异常状态
//		
//	}
	 
	
 	IO_Exception_State04=0;
	
	for(i_trans=0;i_trans<32;i_trans++)
  {//8个仓位的阀门异常状态
		
		if(Array_IO_OnOff_AllStore[i_trans]==0x03)
		{
				IO_Exception_State04|=(1<<(i_trans));		
		}
		
  }//8个仓位的阀门异常状态	
	
	IO_OnOff_State04=0;
	for(i_trans=0;i_trans<32;i_trans++)
  {//8个仓位的阀门开关状态	
		
		if(Array_IO_OnOff_AllStore[i_trans]==0x01)
		{
				IO_OnOff_State04|=(1<<(i_trans));		
		}

  }	//8个仓位的第3组阀门开关状态
	//第4组阀门状态--结束；索引为46开始，依次为海底阀，卸油阀，大盖，小盖，卸尽传感器	

 */			
		
}


void Parse_AllSensor_Data_For_SingleStore(sT2C_ALL_Sensor_Data_Each_Cang* pT2C_ALL_Sensor_Data,uint16_t msgID)
{
	int j001ReadAll;

	chkRetCaiJiBan = CheckInFrame_Collect485(LengthOfData_From_Caijiban_Cang_01, msgID);

	// if((chkRetCaiJiBan==msgID) || (1==1))
	if ((chkRetCaiJiBan == msgID))
	{ //如果回复的校验正确---实际为功能码或者消息ID能够匹配
		Usart2_ErrorTimes = 0;
		chkRetCaiJiBan = 0;
		Collect485.Collect_CommError = False;

		for (j001ReadAll = 0; j001ReadAll < 16; j001ReadAll++)
		{ //帧头数据16字节
			pT2C_ALL_Sensor_Data->FrameHead[j001ReadAll] = USART2_RX_BUF_Collector[j001ReadAll];
		} //帧头数据16字节

		// for(j001ReadAll=0;j001ReadAll<8;j001ReadAll++)
		{
			pT2C_ALL_Sensor_Data->ElecSealState =
				(USART2_RX_BUF_Collector[0 + 16] << 24) + (USART2_RX_BUF_Collector[1 + 16] << 16) +
				(USART2_RX_BUF_Collector[2 + 16] << 8) + (USART2_RX_BUF_Collector[3 + 16]);
		}

		for (j001ReadAll = 0; j001ReadAll < ALL_Sensor_Data_Num_Caijiban; j001ReadAll++)
		{ // 33个浮点数数据解析--开始
			ArrayUni_MoniLiang[j001ReadAll].farray[0] = USART2_RX_BUF_Collector[ALL_SensorData_From_CaijibanOffset + 0 + j001ReadAll * 4 + 0];
			ArrayUni_MoniLiang[j001ReadAll].farray[1] = USART2_RX_BUF_Collector[ALL_SensorData_From_CaijibanOffset + 0 + j001ReadAll * 4 + 1];
			ArrayUni_MoniLiang[j001ReadAll].farray[2] = USART2_RX_BUF_Collector[ALL_SensorData_From_CaijibanOffset + 0 + j001ReadAll * 4 + 2];
			ArrayUni_MoniLiang[j001ReadAll].farray[3] = USART2_RX_BUF_Collector[ALL_SensorData_From_CaijibanOffset + 0 + j001ReadAll * 4 + 3];
		} // 33个浮点数数据解析--开始
#if 0
		if (msgID == Collector_Get_All_Sensor_Data_Cang01)
		{
			__NOP();
		}

		if (msgID == Collector_Get_All_Sensor_Data_Cang02)
		{
			__NOP();
		}
		__NOP();
#endif
		// 21个IO开关类数据--21个U32
		for (j001ReadAll = 0; j001ReadAll < 22; j001ReadAll++)
		{
			pT2C_ALL_Sensor_Data->IO_Valve_Data_Every_Cang[j001ReadAll] = ArrayUni_MoniLiang[j001ReadAll + 1].u32_Data;
		}

		// 11个模拟量数据--11个浮点数
		for (j001ReadAll = 0; j001ReadAll < 11; j001ReadAll++)
		{
			pT2C_ALL_Sensor_Data->MoniLiang_Data_Every_Cang[j001ReadAll] = ArrayUni_MoniLiang[j001ReadAll + 22].flo_Data;
		}

		//					//增加合法性检查
		//					if(pT2C_ALL_Sensor_Data->MoniLiang_Data_Every_Cang[0]>Max_Oil_Height)
		//					{//液位高度上限
		//						pT2C_ALL_Sensor_Data->MoniLiang_Data_Every_Cang[0]=Max_Oil_Height;
		//					}

		pT2C_ALL_Sensor_Data->chkCRCModbus_Data[0] = USART2_RX_BUF_Collector[LengthOfData_From_Caijiban_Cang_01 - 2];
		pT2C_ALL_Sensor_Data->chkCRCModbus_Data[1] = USART2_RX_BUF_Collector[LengthOfData_From_Caijiban_Cang_01 - 1];
#if  0
		__NOP();

		if (msgID == Collector_Get_All_Sensor_Data_Cang01)
		{
			__NOP();
		}

		if (msgID == Collector_Get_All_Sensor_Data_Cang02)
		{
			__NOP();
		}
		__NOP();

		memset(USART2_RX_BUF, 0x00, sizeof(USART2_RX_BUF)); //清除接收缓存
#endif
	} //如果回复的校验正确---实际为功能码或者消息ID能够匹配
	else
	{ //接收错误异常处理：未接收到数据，或者校验错误等
		Usart2_ErrorTimes++;
	}
}

void Parse_AllSensor_Data_For_WholeCar(sT2C_ALL_Sensor_Data_WholeCar* pT2C_ALL_Sensor_Data,uint16_t msgID,uint16_t LenOfPara)
{
	 int j001ReadAll;
	
				chkRetCaiJiBan=CheckInFrame_Collect485(LengthOfData_From_Caijiban_WholeCar,msgID);
	
				if(chkRetCaiJiBan==msgID)//	 || (1==1)

				{//如果回复的校验正确---实际为功能码或者消息ID能够匹配
					Usart2_ErrorTimes=0;
					chkRetCaiJiBan=0;
					Collect485.Collect_CommError=False;
					__nop();
					
								
					for(j001ReadAll=0;j001ReadAll<16;j001ReadAll++)
					{//帧头数据16字节
						pT2C_ALL_Sensor_Data->FrameHead[j001ReadAll]=USART2_RX_BUF_Collector[j001ReadAll];
					}//帧头数据16字节
					
 

					__NOP();
					
					
					for(j001ReadAll=0;j001ReadAll<LenOfPara;j001ReadAll++)//ALL_Sensor_Data_Num_WholeCar
					{//数据解析--开始
						ArrayUni_MoniLiang[j001ReadAll].farray[0]=USART2_RX_BUF_Collector[ALL_SensorData_From_CaijibanOffset+0+j001ReadAll*4+0];
						ArrayUni_MoniLiang[j001ReadAll].farray[1]=USART2_RX_BUF_Collector[ALL_SensorData_From_CaijibanOffset+0+j001ReadAll*4+1];
						ArrayUni_MoniLiang[j001ReadAll].farray[2]=USART2_RX_BUF_Collector[ALL_SensorData_From_CaijibanOffset+0+j001ReadAll*4+2];
						ArrayUni_MoniLiang[j001ReadAll].farray[3]=USART2_RX_BUF_Collector[ALL_SensorData_From_CaijibanOffset+0+j001ReadAll*4+3];
					}//数据解析--结束
					
					
					pT2C_ALL_Sensor_Data->tiltXYZ[0]=ArrayUni_MoniLiang[0].flo_Data;
					pT2C_ALL_Sensor_Data->tiltXYZ[1]=ArrayUni_MoniLiang[1].flo_Data;
					pT2C_ALL_Sensor_Data->tiltXYZ[2]=ArrayUni_MoniLiang[2].flo_Data;
					
					
					Stor[0].QingJiaoFlo=pT2C_ALL_Sensor_Data->tiltXYZ[0];//(float)(Stor[0].QingJiao*SCL_Angle*1);
					Stor[1].QingJiaoFlo=pT2C_ALL_Sensor_Data->tiltXYZ[1];//(float)(Stor[1].QingJiao*SCL_Angle*1);//180/32768;						


					uni_QingJiao001.flo_Data=pT2C_ALL_Sensor_Data->tiltXYZ[0];
					uni_QingJiao002.flo_Data=pT2C_ALL_Sensor_Data->tiltXYZ[1];
					
					
					
					pT2C_ALL_Sensor_Data->BeiDian_State_OnOff=ArrayUni_MoniLiang[3].u32_Data;
					pT2C_ALL_Sensor_Data->BeiDianDianLiang=ArrayUni_MoniLiang[4].flo_Data;
					pT2C_ALL_Sensor_Data->YouQiHuiShou_State_OnOff=ArrayUni_MoniLiang[5].u32_Data;
					pT2C_ALL_Sensor_Data->YouQiHuiShou_State_Photo=ArrayUni_MoniLiang[6].u32_Data;
					
					
					
					pT2C_ALL_Sensor_Data->ResPara[0]=ArrayUni_MoniLiang[7].u32_Data;
					
					
					for(j001ReadAll=0;j001ReadAll<13;j001ReadAll++)
					{//帧头数据16字节
						pT2C_ALL_Sensor_Data->ResPara[j001ReadAll]=ArrayUni_MoniLiang[j001ReadAll+7].u32_Data;
					}//帧头数据16字节
				
					
					__NOP();
					  
					
					pT2C_ALL_Sensor_Data->chkCRCModbus_Data[0]=USART2_RX_BUF_Collector[LengthOfData_From_Caijiban_WholeCar-2];
					pT2C_ALL_Sensor_Data->chkCRCModbus_Data[1]=USART2_RX_BUF_Collector[LengthOfData_From_Caijiban_WholeCar-1];	

					__NOP();
					
					memset(USART2_RX_BUF, 0x00, sizeof(USART2_RX_BUF));     //清除接收缓存
					
					
					 

				}//如果回复的校验正确---实际为功能码或者消息ID能够匹配
				else
				{//接收错误异常处理：未接收到数据，或者校验错误等
					Usart2_ErrorTimes++;
						
				}
}
