|
@@ -68,6 +68,9 @@ JT808_DATA_OBJ jt808_obj = {
|
|
|
|
|
|
};
|
|
|
|
|
|
+Struct_Cang cang_data_tbak[8];
|
|
|
+Struct_Tank tank_data_tbak;
|
|
|
+
|
|
|
extern uint8_t Cang_IO_tbak[4][64];
|
|
|
extern uint32_t overflow_cnt_bak;
|
|
|
extern unsigned char overflow_flag_bak;
|
|
@@ -128,6 +131,7 @@ int jt808_Build_Ax_Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergencyflag)
|
|
|
unsigned char Lrc_temp;
|
|
|
unsigned char overflow_flag=0;
|
|
|
unsigned char temp_i = 0x00;
|
|
|
+ uint8_t cang_id = 0;
|
|
|
|
|
|
UNUSED(Lrc_temp);
|
|
|
UNUSED(temp_i);
|
|
@@ -179,6 +183,21 @@ int jt808_Build_Ax_Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergencyflag)
|
|
|
{
|
|
|
StoreNumber = 5;
|
|
|
}
|
|
|
+
|
|
|
+ //add for showtable
|
|
|
+ for(cang_id = 0; cang_id < StoreNumber; cang_id++){
|
|
|
+ if(memcmp(&cang_data_tbak[cang_id], &cang_data[cang_id], sizeof(Struct_Cang)))
|
|
|
+ {
|
|
|
+ emergencyflag=0x80;
|
|
|
+ }
|
|
|
+
|
|
|
+ memcpy(&cang_data_tbak[cang_id],&cang_data[cang_id],sizeof(Struct_Cang));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(memcmp(&tank_data_tbak, &tank_data, sizeof(Struct_Tank))){
|
|
|
+ emergencyflag=0x80;
|
|
|
+ }
|
|
|
+ memcpy(&tank_data_tbak, &tank_data, sizeof(Struct_Tank));
|
|
|
|
|
|
if((overflow_cnt==0) && (overflow_cnt==overflow_cnt_bak))
|
|
|
{
|
|
@@ -199,8 +218,16 @@ int jt808_Build_Ax_Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergencyflag)
|
|
|
pBuf[send_pos++] = emergencyflag; //紧急上报位
|
|
|
pBuf[send_pos++] = 0x00; //数据状态:00正常;01未收到数据;02乱码
|
|
|
pBuf[send_pos++] = StoreNumber;
|
|
|
- pBuf[send_pos++] = 0x22;
|
|
|
+ //防溢流插座
|
|
|
+ pBuf[send_pos++] = 0x22;
|
|
|
pBuf[send_pos++] = overflow_flag;
|
|
|
+ //门磁
|
|
|
+ pBuf[send_pos++] = 0x21;
|
|
|
+ pBuf[send_pos++] = 0x01;
|
|
|
+ pBuf[send_pos++] = tank_data_tbak.Door_State;
|
|
|
+ //人脸授权
|
|
|
+ pBuf[send_pos++] = 0x23;
|
|
|
+ pBuf[send_pos++] = tank_data_tbak.Facial_Auth;
|
|
|
|
|
|
//61 人孔大盖 开关
|
|
|
send_pos += jt808_Build_0x61_ManHole_Big_SW((uint8_t *)pBuf+send_pos);
|
|
@@ -214,6 +241,15 @@ int jt808_Build_Ax_Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergencyflag)
|
|
|
//64 底阀 开关
|
|
|
send_pos += jt808_Build_0x64_HaiDiFa((uint8_t *)pBuf+send_pos);
|
|
|
|
|
|
+ //65 温度
|
|
|
+ send_pos += jt808_Build_0x65_Temperature((uint8_t *)pBuf+send_pos);
|
|
|
+
|
|
|
+ //6B 压力
|
|
|
+ send_pos += jt808_Build_0x6B_Pressure((uint8_t *)pBuf+send_pos);
|
|
|
+
|
|
|
+ //6C 液位
|
|
|
+ send_pos += jt808_Build_0x6C_Level((uint8_t *)pBuf+send_pos);
|
|
|
+
|
|
|
//6D 仓状态
|
|
|
send_pos += jt808_Build_0x6d_Cang_info((uint8_t *)pBuf+send_pos);
|
|
|
|
|
@@ -470,6 +506,101 @@ int jt808_Build_0x64_HaiDiFa(uint8_t *pBuf)
|
|
|
|
|
|
return idx;
|
|
|
}
|
|
|
+/**
|
|
|
+ ***************************************
|
|
|
+ * 构建65 温度1
|
|
|
+ * 输入:pBuf-构建数据的存放首地址
|
|
|
+ * 返回: 构建数据的字节总数
|
|
|
+ ***************************************
|
|
|
+ */
|
|
|
+int jt808_Build_0x65_Temperature(uint8_t *pBuf)
|
|
|
+{
|
|
|
+ int idx=0;
|
|
|
+ int i;
|
|
|
+ uni_float uni;
|
|
|
+
|
|
|
+ pBuf[idx++] = 0x65;
|
|
|
+ for (i = 0; i < StoreNumber; i++)
|
|
|
+ {
|
|
|
+ uni.flo_Data = cang_data_tbak[i].temperature;
|
|
|
+ if((uni.array_u8[0]== 0xAB) && (uni.array_u8[1] == 0xAB) && (uni.array_u8[2] == 0xAB) && (uni.array_u8[3] == 0xAB)){
|
|
|
+ pBuf[idx++] = 0x01;
|
|
|
+ }else{
|
|
|
+ pBuf[idx++] = 0x00;
|
|
|
+ }
|
|
|
+ pBuf[idx++] = uni.array_u8[3];
|
|
|
+ pBuf[idx++] = uni.array_u8[2];
|
|
|
+ pBuf[idx++] = uni.array_u8[1];
|
|
|
+ pBuf[idx++] = uni.array_u8[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ return idx;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ ***************************************
|
|
|
+ * 构建6B 压力
|
|
|
+ * 输入:pBuf-构建数据的存放首地址
|
|
|
+ * 返回: 构建数据的字节总数
|
|
|
+ ***************************************
|
|
|
+ */
|
|
|
+int jt808_Build_0x6B_Pressure(uint8_t *pBuf)
|
|
|
+{
|
|
|
+ int idx=0;
|
|
|
+ int i;
|
|
|
+ uni_float uni;
|
|
|
+
|
|
|
+ pBuf[idx++] = 0x6B;
|
|
|
+ for (i = 0; i < StoreNumber; i++)
|
|
|
+ {
|
|
|
+ uni.flo_Data = cang_data_tbak[i].pressure;
|
|
|
+
|
|
|
+ if((uni.array_u8[0]== 0xAC) && (uni.array_u8[1] == 0xAC) && (uni.array_u8[2] == 0xAC) && (uni.array_u8[3] == 0xAC)){
|
|
|
+ pBuf[idx++] = 0x01;
|
|
|
+ }else{
|
|
|
+ pBuf[idx++] = 0x00;
|
|
|
+ }
|
|
|
+
|
|
|
+ pBuf[idx++] = uni.array_u8[3];
|
|
|
+ pBuf[idx++] = uni.array_u8[2];
|
|
|
+ pBuf[idx++] = uni.array_u8[1];
|
|
|
+ pBuf[idx++] = uni.array_u8[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ return idx;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ ***************************************
|
|
|
+ * 构建6C 液位
|
|
|
+ * 输入:pBuf-构建数据的存放首地址
|
|
|
+ * 返回: 构建数据的字节总数
|
|
|
+ ***************************************
|
|
|
+ */
|
|
|
+int jt808_Build_0x6C_Level(uint8_t *pBuf)
|
|
|
+{
|
|
|
+ int idx=0;
|
|
|
+ int i;
|
|
|
+ uni_float uni;
|
|
|
+
|
|
|
+ pBuf[idx++] = 0x6C;
|
|
|
+ for (i = 0; i < StoreNumber; i++)
|
|
|
+ {
|
|
|
+ uni.flo_Data = cang_data_tbak[i].level;
|
|
|
+ if((uni.array_u8[0]== 0xAA) && (uni.array_u8[1] == 0xAA) && (uni.array_u8[2] == 0xAA) && (uni.array_u8[3] == 0xAA)){
|
|
|
+ pBuf[idx++] = 0x01;
|
|
|
+ }else{
|
|
|
+ pBuf[idx++] = 0x00;
|
|
|
+ }
|
|
|
+ pBuf[idx++] = uni.array_u8[3];
|
|
|
+ pBuf[idx++] = uni.array_u8[2];
|
|
|
+ pBuf[idx++] = uni.array_u8[1];
|
|
|
+ pBuf[idx++] = uni.array_u8[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ return idx;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
***************************************
|
|
|
* 构建70 铅封状态
|