Bladeren bron

add new protocol 0x1130

guoqiang 2 jaren geleden
bovenliggende
commit
bde751fcd0
3 gewijzigde bestanden met toevoegingen van 445 en 166 verwijderingen
  1. 27 0
      Core/Inc/kzq.h
  2. 285 2
      Core/Src/kzq.c
  3. 133 164
      Core/Src/main.c

+ 27 - 0
Core/Inc/kzq.h

@@ -2,6 +2,32 @@
 #define  __KZQ_H
 #include "stdint.h"
 
+
+#define SENSOR_TYPE_BIGCOVER        (0x61)
+#define SENSOR_TYPE_SMALLCOVER      (0x62)
+#define SENSOR_TYPE_UNLOADVALVE     (0x63)
+#define SENSOR_TYPE_SEAVALVE        (0x64)
+#define SENSOR_TYPE_TEMPERATURE1    (0x65)
+#define SENSOR_TYPE_TEMPERATURE2    (0x66)
+#define SENSOR_TYPE_TEMPERATURE3    (0x67)
+#define SENSOR_TYPE_TILTANGLE_X     (0x68)
+#define SENSOR_TYPE_TILTANGLE_Y     (0x69)
+#define SENSOR_TYPE_DENSITY         (0x6A)
+#define SENSOR_TYPE_PRESSURE        (0X6B)
+#define SENSOR_TYPE_LIQUID_LEVEL    (0X6C)
+
+#define SENSOR_TYPE_UNLOADSTATUS    (0x80)
+
+#define SENSOR_TYPE_EXTEND_IO            (0X90)
+#define SENSOR_TYPE_EXTENDPROTOCOL_IO    (0X91)
+#define SENSOR_TYPE_EXTEND_ANALOG1       (0x92)
+#define SENSOR_TYPE_EXTEND_ANALOG2       (0X93)
+#define SENSOR_TYPE_EXTEND_ANALOG3       (0X94)
+
+#define IO_VALUE_SIZE  (4)
+#define ANALOG_VALUE_SIZE  (8)
+
+
 typedef struct{
 uint16_t USE_RKG;								//控制器占用人孔盖总线
 uint16_t USE_XYF;								//控制器占用卸油阀总线
@@ -24,6 +50,7 @@ extern void Flash_WriteBytes(uint16_t* sorBuf,uint32_t FlashAddr,uint16_t len);
 extern void Cang_Init(void);
 
 extern uint16_t Read_CangSensorData(uint8_t* pTx);
+extern void Read_SensorData_New(uint8_t* pTx, uint16_t* tx_len); // add by guoqiang	
 
 extern uint16_t Read_CangSensorData_V2(uint8_t* pTx, uint8_t Cang_Num); // add by guoqiang	
 #if 0

+ 285 - 2
Core/Src/kzq.c

@@ -3313,8 +3313,291 @@ uint16_t Read_CangSensorData_1to4(uint8_t* pTx)//
 }
 
 
+//单仓数据
+uint16_t Get_CangData(uint8_t* buffer, uint16_t buffer_size, uint8_t CangNo) // add by guoqiang	
+{
+	Cang_Inf* pcang = &cang_inf;
+	HDF_Inf*  phdf = hdf_inf;
+	XYF_Inf*  pxyf  = xyf_inf;
+	Level_Inf* plevel = level_inf;
+	TEM_Inf* ptem = tem_inf;
+	RKG_Inf*  prkg  = rkg_inf;
+
+	typedef union{
+   		float float_temp;   //青鸟贵和磁致伸缩液位温度一体传感器
+   		uint8_t arr[4];
+  	}Hex_to_float;
+	Hex_to_float hex_to_float;
+
+	uint8_t i = 0,HDF_Start = 0,XYF_Start = 0,RKG_Start = 0,BGY_Start = 0;
+	uint16_t offset = 0;
+	if(CangNo < 1 ||CangNo > 8)
+		return offset;
+	if(CangNo > pcang->Cang_Num){
+		return offset;
+	}
+	
+	for(i = 0;i < CangNo - 1;i++)
+	{
+		HDF_Start += pcang->HDF_Num[i];
+		XYF_Start += pcang->XYF_Num[i];
+		RKG_Start += pcang->RKG_Num[i];
+		BGY_Start += pcang->BGY_Num[i];
+	}
+	
+	// hdf 
+	if(pcang->HDF_Num[CangNo - 1] > 0){
+		for(i = 0; i<pcang->HDF_Num[CangNo - 1]; i++){ 
+
+			if((offset + IO_VALUE_SIZE) <= buffer_size){
+				buffer[offset] = SENSOR_TYPE_SEAVALVE;
+				buffer[offset+1] = ((CangNo << 4)|i);   //cang & id
+				buffer[offset+2] = 0x00;  //IO type
+				buffer[offset+3] = phdf[HDF_Start+i+1].HDF_Error? State_Error:Get_DFState(HDF_Start+i+1);
+				offset += IO_VALUE_SIZE;
+			}else{
+				return offset;
+			}
+
+		}
+	}
+	
+	// xyf 
+	if(pcang->XYF_Num[CangNo - 1] > 0){
+		for(i = 0; i<pcang->XYF_Num[CangNo - 1]; i++){ 
+
+			if((offset + IO_VALUE_SIZE) <= buffer_size){
+				buffer[offset] = SENSOR_TYPE_UNLOADVALVE;
+				buffer[offset+1] = ((CangNo << 4)|i);   //cang & id
+				buffer[offset+2] = 0x00;  //IO type
+				buffer[offset+3] = pxyf[XYF_Start+i+1].XYF_Error? State_Error:pxyf[XYF_Start+i+1].XYF_State1;
+				offset += IO_VALUE_SIZE;
+			}else{
+				return offset;
+			}
+		}
 
 
+	}
+	
+	//rkdg & rkxg
+	if(pcang->RKG_Num[CangNo - 1] > 0){
+		
+		for(i = 0;i < pcang->RKG_Num[CangNo - 1];i++){  
+
+			if((offset + IO_VALUE_SIZE) <= buffer_size){
+				buffer[offset] = SENSOR_TYPE_BIGCOVER;
+				buffer[offset+1] = ((CangNo << 4)|i);   //cang & id
+				buffer[offset+2] = 0x00;  //IO type
+				buffer[offset+3] = prkg[RKG_Start+i+1].RKDG_Error? State_Error:prkg[RKG_Start+i+1].RKDG_State;
+				offset += IO_VALUE_SIZE;
+			}else{
+				return offset;
+			}
+		}
+
+		if(pcang->RKG_XG > 0){ //rkxg
+			for(i = 0;i < pcang->RKG_Num[CangNo - 1];i++){  
+				if((offset + IO_VALUE_SIZE) <= buffer_size){
+					buffer[offset] = SENSOR_TYPE_SMALLCOVER;
+					buffer[offset+1] = ((CangNo << 4)|i);   //cang & id
+					buffer[offset+2] = 0x00;  //IO type
+					buffer[offset+3] = prkg[RKG_Start+i+1].RKDG_Error? State_Error:prkg[RKG_Start+i+1].RKXG_State;
+					offset += IO_VALUE_SIZE;
+				}else{
+					return offset;
+				}
+			}
+		}
+			
+	}
+	
+	
+	// xj status
+	if((2 != pcang->XYF_Type )&& (pcang->XYF_Num[CangNo - 1] > 0)){
+		for(i = 0; i < pcang->XYF_Num[CangNo - 1]; i++){
+
+			if((offset + IO_VALUE_SIZE) <= buffer_size){
+				buffer[offset] = SENSOR_TYPE_UNLOADSTATUS;
+				buffer[offset+1] = ((CangNo << 4)|i);   //cang & id
+				buffer[offset+2] = 0x00;  //IO type
+				buffer[offset+3] = pxyf[XYF_Start+i+1].XYF_Error? State_Error:pxyf[XYF_Start+i+1].XYF_State2;
+				offset += IO_VALUE_SIZE;
+			}else{
+				return offset;
+			}
+		}
+	}
+	
+
+	//level
+	if(0 != pcang->Level){
+		if((1 == pcang->Level) || (2 == pcang->Level)){
+
+			if((offset + ANALOG_VALUE_SIZE) <= buffer_size){
+				buffer[offset] = SENSOR_TYPE_LIQUID_LEVEL;
+				buffer[offset+1] = ((CangNo << 4)|0x00);   //cang & id
+				buffer[offset+2] = 0x01;  //analog type
+				buffer[offset+3] = plevel[CangNo].Level_Error? State_Error:0x00;
+
+				hex_to_float.float_temp = plevel[CangNo].Level_Data1;		
+				buffer[offset+4] = hex_to_float.arr[0];               
+				buffer[offset+5] = hex_to_float.arr[1];
+				buffer[offset+6] = hex_to_float.arr[2];
+				buffer[offset+7] = hex_to_float.arr[3];
+
+				offset += ANALOG_VALUE_SIZE;
+			}else{
+				return offset;
+			}
+
+		}
+	}
+
+	//temperture
+	if(0 != pcang->Temperture){
+		if(1 == pcang->Temperture || 3 == pcang->Temperture){
+
+			if((offset + ANALOG_VALUE_SIZE) <= buffer_size){
+				buffer[offset] = SENSOR_TYPE_TEMPERATURE1;
+				buffer[offset+1] = 0;
+				buffer[offset+2] = 0x01;  //analog type
+				buffer[offset+3] = ptem[CangNo].TEM_Error? State_Error:0x00;
+
+				hex_to_float.float_temp = ((float)ptem[CangNo].TEM_HData[1]*(0.1f));	
+				buffer[offset+4] = hex_to_float.arr[0];              
+				buffer[offset+5] = hex_to_float.arr[1];
+				buffer[offset+6] = hex_to_float.arr[2];
+				buffer[offset+7] = hex_to_float.arr[3];
+
+				offset += ANALOG_VALUE_SIZE;
+			}else{
+				return offset;
+			}
+		}
+
+		if(3 == pcang->Temperture){
+
+			if((offset + ANALOG_VALUE_SIZE) <= buffer_size){
+				buffer[offset] = SENSOR_TYPE_TEMPERATURE2;
+				buffer[offset+1] = ((CangNo << 4)|0x00);   //cang & id
+				buffer[offset+2] = 0x01;  //analog type
+				buffer[offset+3] = ptem[CangNo].TEM_Error? State_Error:0x00;
+
+				hex_to_float.float_temp = ((float)ptem[CangNo].TEM_MData[1]*(0.1f));	
+				buffer[offset+4] = hex_to_float.arr[0];              
+				buffer[offset+5] = hex_to_float.arr[1];
+				buffer[offset+6] = hex_to_float.arr[2];
+				buffer[offset+7] = hex_to_float.arr[3];
+
+				offset += ANALOG_VALUE_SIZE;
+			}else{
+				return offset;
+			}
+
+			if((offset + ANALOG_VALUE_SIZE) <= buffer_size){
+				buffer[offset] = SENSOR_TYPE_TEMPERATURE3;
+				buffer[offset+1] = ((CangNo << 4)|0x00);   //cang & id
+				buffer[offset+2] = 0x01;  //analog type
+				buffer[offset+3] = ptem[CangNo].TEM_Error? State_Error:0x00;
+
+				hex_to_float.float_temp = ((float)ptem[CangNo].TEM_LData[1]*(0.1f));	
+				buffer[offset+4] = hex_to_float.arr[0];              
+				buffer[offset+5] = hex_to_float.arr[1];
+				buffer[offset+6] = hex_to_float.arr[2];
+				buffer[offset+7] = hex_to_float.arr[3];
+
+				offset += ANALOG_VALUE_SIZE;
+			}else{
+				return offset;
+			}
+		}
+
+	}
+
+	
+
+	return offset;
+
+}
+
+//车身数据
+uint16_t Get_BodyData(uint8_t* buffer, uint16_t buffer_size) // add by guoqiang	
+{
+	uint16_t offset=0;
+	
+	return offset;
+}
+
+uint16_t Get_AllData(uint8_t* buffer, uint16_t buffer_size) // add by guoqiang	
+{
+	Cang_Inf* pcang = &cang_inf;
+	uint16_t offset = 0;
+	uint8_t i=0;
+
+	offset += Get_BodyData(buffer+offset, buffer_size-offset);
+
+	for(i=0; i< pcang->Cang_Num; i++){
+
+		offset += Get_CangData(buffer+offset, buffer_size-offset, i+1);
+		if((offset+ANALOG_VALUE_SIZE) > buffer_size) {
+			return offset;
+		}
+
+	}
+
+	return offset;
+
+}
+
+/*
+新的采控传感协议
+功能增加:	郭强  
+*/
+void Read_SensorData_New(uint8_t* pTx, uint16_t* tx_len) // add by guoqiang	
+{
+	KZQ_Inf* pkzq = &kzq_inf;
+	uint8_t Cang_Num = 0xFF;
+	
+
+	uint8_t* pPayload_len = pTx+11;
+
+	pTx[16] = pkzq->data_buf[16];
+	pTx[17] = pkzq->data_buf[17];
+	uint16_t data_len = 2;
+
+	uint8_t* buffer = pTx+18;
+	uint16_t buffer_size = 256-16-2-2; //the pTx Size is 256. 
+
+	Cang_Num = pkzq->data_buf[17]; 
+
+	switch(Cang_Num){
+		case 0x00:      //车身
+			data_len += Get_BodyData(buffer, buffer_size);
+			break;
+		case 0x01:      //第1仓
+		case 0x02:		//第2仓
+		case 0x03:		//第3仓
+		case 0x04:		//第4仓
+		case 0x05:		//第5仓
+		case 0x06:		//第6仓
+		case 0x07:		//第7仓
+		case 0x08:		//第8仓
+			data_len += Get_CangData(buffer, buffer_size, Cang_Num);
+			break;
+		case 0x0A:		//全部数据
+			data_len += Get_AllData(buffer, buffer_size);
+			break;
+		default:		//不支持
+			break;
+	}
+
+	pTx[10] = data_len>>8;
+	pTx[11] = data_len&0xFF;
+
+	*tx_len = data_len+16;
+
+}
 
 uint16_t Read_CangSensorData(uint8_t* pTx)
 {
@@ -3326,7 +3609,7 @@ uint16_t Read_CangSensorData(uint8_t* pTx)
 
 	uint8_t Cang_Num = 0;
 	
-	Cang_Num = pkzq->data_buf[17];                   //读取第几仓传感器数据
+	Cang_Num = pkzq->data_buf[17];        //读取第几仓传感器数据
 	if(Cang_Num < 1 ||Cang_Num > 8)
 		return 0;	
 	pTx[11] = 32;                         //数据长度
@@ -4298,7 +4581,7 @@ uint16_t Tem_SetType(uint8_t* pTx)
 		return 0;
 }
 
-uint32_t Version_Soft[8] = {2, 2, 3, 13, 1, 1, 0, 20220829};
+uint32_t Version_Soft[8] = {2, 2, 3, 13, 1, 1, 0, 20221013};
 uint16_t Read_SoftVersion(uint8_t *pTx)
 {
 	int i;

+ 133 - 164
Core/Src/main.c

@@ -42,7 +42,7 @@
 #include "yqhs.h"
 #include "iap.h"
 /* USER CODE END Includes */
-#if 1
+#if 0
 #define IR_ROM1   0x08000000
 #else
 #define IR_ROM1   0x08020000
@@ -762,7 +762,7 @@ void Cang_Init(void)
 	
 	Flash_ReadBytes(Flash_buff,ADDR_LEVEL_TYPE,1);
 	if(Flash_buff[0] == 0xffff)
-		pcang->Level = 2;           //默认磁致伸缩液位传感器   slm
+		pcang->Level = 0;           //默认无液位传感器   slm
 	else
 		pcang->Level = Flash_buff[0];
 
@@ -1495,7 +1495,7 @@ static void MX_USART2_UART_Init(void)
 
   /* USER CODE END USART2_Init 1 */
   huart2.Instance = USART2;
-  huart2.Init.BaudRate = 19200;//19200
+  huart2.Init.BaudRate = 38400;//19200
   huart2.Init.WordLength = UART_WORDLENGTH_8B;
   huart2.Init.StopBits = UART_STOPBITS_1;
   huart2.Init.Parity = UART_PARITY_NONE;
@@ -2962,173 +2962,152 @@ void StartTask04(void *argument)                                    //
 			
 			if(KZQ_RTerror == 0)
 			{
+				send_len=0;
+
 				pkzq->sensor_reg = USART2_RX_BUF002[8];
 				pkzq->sensor_reg = pkzq->sensor_reg<<8;
 				pkzq->sensor_reg |= USART2_RX_BUF002[9];
+
 				switch(pkzq->sensor_reg)
 				{
-					case 0x10:  RstCPU();                                   //复位
-						break;
-					case 0x11:
-						break;
-					case 0x12:
-						break;
-					case 0x13: Sen_CangState_old(F_STATE);                //老协议  传输阀门状态               
-						break;
-	
-					
-					
-					case 0x20: SetSuccess = Read_CangState(ptx);           //读取仓状态
-						break;
-					case 0x21:
-						break;
-					case 0x22:
-						break;
-					case 0x23:
-						break;
-					case 0x24:
-						break;
-					case 0x25:
-						break;
-					case 0x26:
-						break;
-					case 0x27: SetSuccess = Read_CangSensorData(ptx);			//读取仓传感器
+					case 0x10:  
+						RstCPU();                                   //复位
 						break;
-					case 0x28:
-						break;
-					case 0x29:
-						break;
-					
-					
-					case 0x40: SetSuccess = Angle_SetZero(ptx);						//姿态传感器置零
-									for(i = 0;i < 64;i++)
-										ptx[i] = USART2_RX_BUF002[i];
+
+					case 0x13: 
+						Sen_CangState_old(F_STATE);                //老协议  传输阀门状态               
+						send_ptr =  F_STATE;
+						send_len = 62;
 						break;
-					case 0x41:
+
+					case 0x20: 
+						SetSuccess = Read_CangState(ptx);           //读取仓状态
 						break;
-					case 0x42:
+
+					case 0x27:
+						SetSuccess = Read_CangSensorData(ptx);			//读取仓传感器
 						break;
-					case 0x43:
+
+					case 0x40: 
+						SetSuccess = Angle_SetZero(ptx);						//姿态传感器置零
+						for(i = 0;i < 64;i++)
+							ptx[i] = USART2_RX_BUF002[i];
 						break;
 					
-					
-					case 0x50: SetSuccess = XYF_SetOFF(ptx);                        //远程卸油阀标定关    slm
-									for(i = 0;i < 64;i++)
-										ptx[i] = USART2_RX_BUF002[i];
-						break;
-					case 0x51: SetSuccess = XYF_SetThreshold(ptx);                  //设置卸油阀传感器开关门限
-						break;
-					case 0x52: SetSuccess = RKG_SetZero(ptx);											  //人孔盖传感器置零
-									for(i = 0;i < 64;i++)
-										ptx[i] = USART2_RX_BUF002[i];
+					case 0x50: 
+						SetSuccess = XYF_SetOFF(ptx);                        //远程卸油阀标定关    slm
+						for(i = 0;i < 64;i++)
+							ptx[i] = USART2_RX_BUF002[i];
+
 						break;
-					case 0x53: 
+					case 0x51: 
+						SetSuccess = XYF_SetThreshold(ptx);                  //设置卸油阀传感器开关门限
 						break;
-					case 0x54:
+					case 0x52: 
+						SetSuccess = RKG_SetZero(ptx);											  //人孔盖传感器置零
+						for(i = 0;i < 64;i++)
+							ptx[i] = USART2_RX_BUF002[i];
 						break;
-					case 0x55: SetSuccess = Read_Sensor(ptx);											    // 远程读取传感器数据  slm
+
+					case 0x55: 
+						SetSuccess = Read_Sensor(ptx);											    // 远程读取传感器数据  slm
 						break;
-					
-					
+
 					case 0x70:
 						break;
-					case 0x71: SetSuccess = BGY_SetThreshold(ptx);													//设置壁挂油门限
+					case 0x71: 
+						SetSuccess = BGY_SetThreshold(ptx);													//设置壁挂油门限
 						break;
-					case 0x72: SetSuccess = RKG_SetThreshold(ptx);													//设置人孔盖开关门限
+					case 0x72: 
+						SetSuccess = RKG_SetThreshold(ptx);													//设置人孔盖开关门限
 						break;
-					case 0x73: SetSuccess = Sensor_SetJudgefNum(ptx);											//设置开关判断次数
+					case 0x73: 
+						SetSuccess = Sensor_SetJudgefNum(ptx);											//设置开关判断次数
 						break;
-					case 0x74: SetSuccess = CJQ_SetConfig(ptx);														//设置采集器参数
-										 Flash_Change = 1;
+					case 0x74:
+						SetSuccess = CJQ_SetConfig(ptx);														//设置采集器参数
+						Flash_Change = 1;
 						break;
-					case 0x75: SetSuccess = RKG_SetTypeNum(ptx);														//设置人孔盖种类、数量
-										 Flash_Change = 1;
+					case 0x75: 
+						SetSuccess = RKG_SetTypeNum(ptx);														//设置人孔盖种类、数量
+						Flash_Change = 1;
 						break;
-					case 0x76: SetSuccess = XYF_SetTypeNum(ptx);														//设置卸油阀种类、数量
-										 Flash_Change = 1;
+					case 0x76: 
+						SetSuccess = XYF_SetTypeNum(ptx);														//设置卸油阀种类、数量
+						Flash_Change = 1;
 						break;
-					case 0x77: SetSuccess = HDF_SetTypeNum(ptx);														//设置海底阀种类、数量
-										 Flash_Change = 1;
+					case 0x77: 
+						SetSuccess = HDF_SetTypeNum(ptx);														//设置海底阀种类、数量
+						Flash_Change = 1;
 						break;
-					case 0x78: SetSuccess = Level_SetType(ptx);														//设置液位计种类
-										 Flash_Change = 1;
+					case 0x78: 
+						SetSuccess = Level_SetType(ptx);														//设置液位计种类
+						Flash_Change = 1;
 						break;
-					case 0x79: SetSuccess = Angle_SetType(ptx);														//设置姿态传感器种类
-										 Flash_Change = 1;
+					case 0x79: 
+						SetSuccess = Angle_SetType(ptx);														//设置姿态传感器种类
+						Flash_Change = 1;
 						break;
-					case 0x7a: SetSuccess = Tem_SetType(ptx);															//设置温度传感器种类
-										// Flash_Change = 1;
+					case 0x7a: 
+						SetSuccess = Tem_SetType(ptx);															//设置温度传感器种类
+						// Flash_Change = 1;
 						break;
-			    case 0x7b: HDF_Set_CloseVal(ptx);										                      //设置智能海底阀放大倍数
-										 Flash_Change = 1;
+					case 0x7b: 
+						HDF_Set_CloseVal(ptx);										                      //设置智能海底阀放大倍数
+						Flash_Change = 1;
 						break;				 
-			    case 0x7c: HDF_Set_Threshold(ptx);										                      //设置智能海底阀放大倍数
-										 Flash_Change = 1;	
+					case 0x7c: 
+						HDF_Set_Threshold(ptx);										                      //设置智能海底阀放大倍数
+						Flash_Change = 1;	
 						break;				 
-			    case 0x7d: HDF_Set_Gain(ptx);										                      //设置智能海底阀放大倍数
-										 Flash_Change = 1;		 
+					case 0x7d: 
+						HDF_Set_Gain(ptx);										                      //设置智能海底阀放大倍数
+						Flash_Change = 1;		 
 						break;
-			    case 0x7e: HDF_Reset(ptx);										                        //设置智能海底阀放大倍数
-										 Flash_Change = 1;		 
+					case 0x7e: HDF_Reset(ptx);										                        //设置智能海底阀放大倍数
+						Flash_Change = 1;		 
 						break;	
-				case 0x80: SetSuccess = RW_SensorBusMaxRetry(ptx);										//传感器总线重试最大值来获取异常
+					case 0x80: 
+						SetSuccess = RW_SensorBusMaxRetry(ptx);										//传感器总线重试最大值来获取异常
 						break;
-				case 0x81: SetSuccess = RW_PinIoHitSameParam(ptx);										//
+					case 0x81: 
+						SetSuccess = RW_PinIoHitSameParam(ptx);										//
 						break;
-				case 0x017e: TOUCHUAN_UART_NUM(ptx);										              //设置智能海底阀放大倍数
-										 Flash_Change = 1;		 
+					case 0x017e: 
+						TOUCHUAN_UART_NUM(ptx);										              //设置智能海底阀放大倍数
+						Flash_Change = 1;		 
 						break;				
-					case 0x0180: SetSuccess = GRB_SET_Table(ptx);										      //罐容表配置  邵磊明增加
-										 Flash_Change = 1;		 
+					case 0x0180: 
+						SetSuccess = GRB_SET_Table(ptx);										      //罐容表配置  邵磊明增加
+						Flash_Change = 1;		 
 						break;
-					case 0x0190: SetSuccess = Level_SetCalvalue(ptx);														//设置液位计零点 邵磊明增加
-										 Flash_Change = 1;	
-					case 0x0121: //SetSuccess = Level_SetCalvalue(ptx);														//设置液位计种类
-										   // Flash_Change = 1;										 
+					case 0x0190: 
+						SetSuccess = Level_SetCalvalue(ptx);														//设置液位计零点 邵磊明增加
+						Flash_Change = 1;	
+					case 0x0121: 
+						//SetSuccess = Level_SetCalvalue(ptx);														//设置液位计种类
+						// Flash_Change = 1;										 
 						break;		
-					case 0x0122://SetSuccess = Level_SetCalvalue(ptx);														//设置液位计种类
-										  // Flash_Change = 1;										 
+					case 0x0122:
+						//SetSuccess = Level_SetCalvalue(ptx);														//设置液位计种类
+						// Flash_Change = 1;										 
 						break;	
 					case 0x0220:
 						SetSuccess=Read_SoftVersion(ptx);
 						break;
 					case 0x1121: 
 						SetSuccess1 = Read_CangSensorData_1to4(ptx);														//读仓1-4传感器
-							 
+						if(SetSuccess1)
+						{
+							SetSuccess1=0;
+							ptx[232] = 0x00;
+							ptx[233] = 0x00;
+							send_ptr = ptx;
+							send_len = 234;
+						} 
 						break;
 				#if 0
-					case 0x1193: 
-						SetSuccess2 = Read_CangSensorData_1(ptx);														//?á2?1′??D?÷
-							 
-						break;		
-					case 0x1194: 
-						SetSuccess2 = Read_CangSensorData_2(ptx);														//?á2?2′??D?÷
-							 
-						break;
-					case 0x1195: 
-						SetSuccess2 = Read_CangSensorData_3(ptx);														//?á2?3′??D?÷
-							 
-						break;
-					case 0x1196: 
-						SetSuccess2 = Read_CangSensorData_4(ptx);														//?á2?4′??D?÷
-							 
-						break;		
-					case 0x1197: 
-						SetSuccess2 = Read_CangSensorData_5(ptx);														//?á2?5′??D?÷
-							 
-						break;
-					case 0x1198: 
-						SetSuccess2 = Read_CangSensorData_6(ptx);														//?á2?6′??D?÷
-							 
-						break;	
-					case 0x1199: 
-						SetSuccess2 = Read_CangSensorData_7(ptx);														//?á2?7′??D?÷
-							 
-						break;
-					case 0x119a: 
-						SetSuccess2 = Read_CangSensorData_8(ptx);														//?á2?8′??D?÷
-							 
-						break;
+
 				#else
 					case 0x1193:
 					case 0x1194:
@@ -3139,56 +3118,46 @@ void StartTask04(void *argument)                                    //
 					case 0x1199:
 					case 0x119a:
 						SetSuccess2 = Read_CangSensorData_V2(ptx, (uint8_t)(pkzq->sensor_reg-0x1193+1));
+						if(SetSuccess2){
+							send_ptr = ptx;
+							send_len = 148;
+							SetSuccess2 = 0;
+						}
+						
 						break;	
 				#endif 
 					case 0x119b: 
 						SetSuccess3 = Read_ZhencheSensorData1(ptx);														//读仓1-4传感器
-							 
+						if(SetSuccess3)
+						{
+							SetSuccess3=0;
+							send_ptr = ptx;
+							send_len = 96;
+						}
+						break;
+					case 0x1130:
+						Read_SensorData_New(ptx, &send_len);
+						send_ptr = ptx;
 						break;					
 					default:
 						break;
 				}
-				send_len=0;
-				if(pkzq->sensor_reg == 0x13)
-				{
-					send_ptr =  F_STATE;
-					send_len = 62;
-				}
-				else if(SetSuccess2)
-				{
-					SetSuccess2=0;
-					send_ptr = ptx;
-					send_len = 148;
-				}	
-				else if(SetSuccess3)
-				{
-					SetSuccess3=0;
-					send_ptr = ptx;
-					send_len = 96;
-				}								
-				else if(SetSuccess1)
-				{
-					SetSuccess1=0;
-					ptx[232] = 0x00;
-					ptx[233] = 0x00;
-					send_ptr = ptx;
-					send_len = 234;
-				}
-				 else if(SetSuccess)
-				{
-					ptx[60] = 0x00;
-					ptx[61] = 0x00;
-					send_ptr = ptx;
-					send_len = 62;
-				}
-				else
-				{
-					ptx[60] = 0xFF;
-					ptx[61] = 0xFF;
+				
+				//send_len=0;
+				if(0 == send_len){
+					if(SetSuccess){
+						ptx[60] = 0x00;
+						ptx[61] = 0x00;
+					}else{
+						ptx[60] = 0xFF;
+						ptx[61] = 0xFF;
+					}
 					send_ptr = ptx;
 					send_len = 62;
 				}
+
 				SetSuccess = 0;
+
 				if(send_len)
 				{
 					ModbusCRC = LIB_CRC_MODBUS(send_ptr,send_len);