K5:
authordxy15521469561 <1731678236@qq.com>
Mon, 9 Oct 2023 08:21:42 +0000 (16:21 +0800)
committerdxy15521469561 <1731678236@qq.com>
Mon, 9 Oct 2023 08:21:42 +0000 (16:21 +0800)
处理温度值

2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py
2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/protocol.py
2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py

index 0174a46..418c894 100644 (file)
@@ -1071,15 +1071,22 @@ class DeviceInfoManager(Abstract):
                                 temp += 0.5
                                 if temp < 25 or temp > 42:
                                     temp = 0
-                                tmp_f = str(temp).split('.')[0] 
-                                tmp_f_tmp = int(tmp_f)
-                               
+                                tmp_f_tmp = 0
+                                tmp_d_tmp = 0
+                                if str(temp).find(".") != -1:
+                                    tmp_f = str(temp).split('.')[0] 
+                                    tmp_f_tmp = int(tmp_f)
+                                    
+                                    tmp_d = str(temp).split('.')[1][:1]
+                                    tmp_d_tmp = int(tmp_d)
+                                else:
+                                    tmp_f_tmp = temp
 
-                                tmp_d = str(temp).split('.')[1][:1]
-                                tmp_d_tmp = int(tmp_d)
                                 if temp != 0:
                                     EventMesh.publish("set_history_temp_value",temp)
                                     EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+                                    num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
+                                    EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
                                 EventMesh.publish(constants.EVENT.STOP_TEMP)
                                 print("AUTO temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) 
                                 EventMesh.publish("set_temp_state",0)
@@ -1098,17 +1105,22 @@ class DeviceInfoManager(Abstract):
                                         temp += 0.5
                                         if temp < 25 or temp > 42:
                                             temp = 0
-                                        tmp_f = str(temp).split('.')[0] 
-                                        tmp_f_tmp = int(tmp_f)
-                                        
-
-                                        tmp_d = str(temp).split('.')[1][:1]
-                                        tmp_d_tmp = int(tmp_d)
+                                        tmp_f_tmp = 0
+                                        tmp_d_tmp = 0
+                                        if str(temp).find(".") != -1:
+                                            tmp_f = str(temp).split('.')[0] 
+                                            tmp_f_tmp = int(tmp_f)
+                                            
+                                            tmp_d = str(temp).split('.')[1][:1]
+                                            tmp_d_tmp = int(tmp_d)
+                                        else:
+                                            tmp_f_tmp = temp
                                         if temp != None:
                                             if temp != 0:
                                                 EventMesh.publish("set_history_temp_value",temp)
                                                 EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
-                                                EventMesh.publish("set_history_temp_value",temp)
+                                                num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
+                                                EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
                                         EventMesh.publish(constants.EVENT.STOP_TEMP)
                                         print("once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) 
                                         EventMesh.publish("set_temp_state",0)
@@ -1139,15 +1151,22 @@ class DeviceInfoManager(Abstract):
                             temp += 0.5
                             if temp < 25 or temp > 42:
                                 temp = 0
-                            tmp_f = str(temp).split('.')[0] 
-                            tmp_f_tmp = int(tmp_f)
-
-                            tmp_d = str(temp).split('.')[1][:1]
-                            tmp_d_tmp = int(tmp_d)
+                            tmp_f_tmp = 0
+                            tmp_d_tmp = 0
+                            if str(temp).find(".") != -1:
+                                tmp_f = str(temp).split('.')[0] 
+                                tmp_f_tmp = int(tmp_f)
+                                
+                                tmp_d = str(temp).split('.')[1][:1]
+                                tmp_d_tmp = int(tmp_d)
+                            else:
+                                tmp_f_tmp = temp
                             if temp != None:
                                 if temp != 0:
                                     EventMesh.publish("set_history_temp_value",temp)
                                     EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+                                    num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
+                                    EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
                             EventMesh.publish(constants.EVENT.STOP_TEMP)
                             print("AUTO once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) 
                             EventMesh.publish("set_temp_state",0)
@@ -1472,17 +1491,24 @@ class DeviceInfoManager(Abstract):
                         temp += 0.5      
                         if temp < 25 or temp > 42:
                             temp = 0
-
-                        tmp_f = str(temp).split('.')[0] 
-                        tmp_f_tmp = int(tmp_f)
+                        tmp_f_tmp = 0
+                        tmp_d_tmp = 0
+                        if str(temp).find(".") != -1:
+                            tmp_f = str(temp).split('.')[0] 
+                            tmp_f_tmp = int(tmp_f)
+                            
+                            tmp_d = str(temp).split('.')[1][:1]
+                            tmp_d_tmp = int(tmp_d)
+                        else:
+                            tmp_f_tmp = temp
                         
-                        tmp_d = str(temp).split('.')[1][:1]
-                        tmp_d_tmp = int(tmp_d)
                         EventMesh.publish("set_temp_state",0)
                         if temp != None:
                             if temp != 0:
                                 EventMesh.publish("set_history_temp_value",temp)
                                 EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+                                num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
+                                EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
                         EventMesh.publish(constants.EVENT.STOP_TEMP)
             self.SENSOR_time = time_tmp
             self.HR_Onestate = 0
index cf37e50..7588d8f 100644 (file)
@@ -746,6 +746,8 @@ class WT_ProtoCol(ProtoCol):
         #     msg_weather_content,msg_type,msg_temp,msg_min_temp,msg_max_temp,msg_city))
         print("WT_ProtoCol RECV msg:%s"%(msg))
 
+        
+
         EventMesh.publish("set_weather_data",[msg_date,msg_time,msg_weather_content,msg_type,msg_temp,msg_min_temp,msg_max_temp,msg_city,1])
         EventMesh.publish("updata_weather_show")
 
@@ -999,11 +1001,7 @@ class TEMP_ProtoCol(ProtoCol):
         # print("temp:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
-
-        str_data = str(msg[0])+'.'+str(msg[1])
-        num = eval(str_data)#将字符串数据转换成十进制数据
-        EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
-
+        
     def recv(self, event, msg):
         """
         @param event: 
index 1b30e58..6b0fd20 100644 (file)
@@ -4309,11 +4309,17 @@ class TemperatureScreen(Screen):
             temperature_start_label.set_text("正在测量中.")
             temperature_done_img.set_src("E:/static/temp_gif03.png")
 
-        tmp_f = str(temp).split('.')[0] 
-        tmp_f_tmp = int(tmp_f)
+        tmp_f_tmp = 0
+        tmp_d_tmp = 0
+        if str(temp).find(".") != -1:
+            tmp_f = str(temp).split('.')[0] 
+            tmp_f_tmp = int(tmp_f)
+            
+            tmp_d = str(temp).split('.')[1][:1]
+            tmp_d_tmp = int(tmp_d)
+        else:
+            tmp_f_tmp = temp
 
-        tmp_d = str(temp).split('.')[1][:1]
-        tmp_d_tmp = int(tmp_d)
         if self.point >= 2:
             
             if temp >= 37.3:
@@ -4338,6 +4344,8 @@ class TemperatureScreen(Screen):
                 temperature_start_label.set_text("测量结束,点击重测")
                 EventMesh.publish("set_history_temp_value",temp)
                 EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+                num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
+                EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
             if temp >= 37.3:
                 temperature_done_img.set_src("E:/static/temp_high.png")
             else: