|
@@ -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;
|