D10:
authordxy15521469561 <1731678236@qq.com>
Mon, 11 Dec 2023 09:04:57 +0000 (17:04 +0800)
committerdxy15521469561 <1731678236@qq.com>
Mon, 11 Dec 2023 09:04:57 +0000 (17:04 +0800)
优化

2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/led.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py

index 6d1df0a..c95dd7b 100644 (file)
@@ -119,6 +119,10 @@ class intervManager(Abstract):
         self.time_count = 0
         self.alarm_count = 0
         self.audio_int = 0
+
+        self.hr_auto = 0
+
+        self.temp_auto = 0
         
         check_txt = ql_fs.path_exists("/usr/static/storage_file/wechat_record.json")
         if check_txt == True :
@@ -1050,33 +1054,45 @@ class intervManager(Abstract):
         get_spo2_state = EventMesh.publish("get_spo2_state")
         get_bp_state  = EventMesh.publish("get_bp_state")
         get_bg_state  = EventMesh.publish("get_bg_state")
+        get_temp_state  = EventMesh.publish("get_temp_state")
         if msg == 1:
-            if get_hr_state != None and get_spo2_state != None and get_bp_state != None and get_bg_state != None:
-                if get_hr_state == 2 or get_hr_state == 3:
+            if get_hr_state != None and get_spo2_state != None and get_bp_state != None and get_bg_state != None and get_temp_state != None:
+                if get_hr_state != 0:
                     
                     EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 
-                    if get_hr_state == 3:
+                    if get_hr_state == 3 or get_hr_state == 1:
                         EventMesh.publish("stop_led_timer")#设置参数
+                    if get_hr_state == 1:
+                        EventMesh.publish("set_start_measure_time",0)#设置开始测量的时间戳时间
                     EventMesh.debug_log("stop debug8")
                     EventMesh.publish(constants.EVENT.STOP_HEART) 
-                elif get_spo2_state == 2 or get_spo2_state == 3:
+                elif get_spo2_state != 0:
                     EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
-                    if get_spo2_state == 3:
+                    if get_spo2_state == 3 or get_spo2_state == 1:
                         EventMesh.publish("stop_led_timer")#设置参数
                     EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
                     EventMesh.debug_log("stop debug13")
-                elif get_bp_state == 2 or get_bp_state == 3:
+                elif get_bp_state != 0:
                     EventMesh.publish("set_bp_state",0)#2代表后台进入测试
-                    if get_bp_state == 3:
+                    if get_bp_state == 3 or get_bp_state == 1:
                         EventMesh.publish("stop_led_timer")#设置参数
                     EventMesh.publish(constants.EVENT.STOP_HEART)
                     EventMesh.debug_log("stop bp debug1")
-                elif get_bg_state == 2 or get_bg_state == 3:
+                elif get_bg_state != 0:
                     EventMesh.publish("set_bg_state",0)#2代表后台进入测试
-                    if get_bg_state == 3:
+                    if get_bg_state == 3 or get_bg_state == 1:#手动开灯关闭灯
                         EventMesh.publish("stop_led_timer")#设置参数
                     EventMesh.publish(constants.EVENT.STOP_HEART)
                     EventMesh.debug_log("stop BG  debug14")
+                if get_temp_state != 0:
+                    
+                    EventMesh.publish("set_temp_state",0)#2代表后台进入测试
+                    if get_temp_state == 1 or get_temp_state == 3:
+                        EventMesh.publish("stop_led_timer")#设置参数
+                    if get_temp_state == 1:
+                        EventMesh.publish("get_start_temp_measure_time",0)#
+                    EventMesh.publish(constants.EVENT.STOP_TEMP)
+                    EventMesh.debug_log("stop temp  debug14")
         if msg == 1:
             self.usbState = msg
             str_buf = [1,1,10,led_mode.LONG_LIGHT_RED,4,2,led_mode.CHARGE_IN_MODE]
@@ -1269,7 +1285,7 @@ class intervManager(Abstract):
             if get_hr_state != 1:#不是手动测试直接打断
                 EventMesh.debug_log("set_manual_measure_mode",msg)
                 EventMesh.publish("set_hr_state",1)
-                EventMesh.publish("set_start_measure_time")#设置开始测量的时间戳时间
+                EventMesh.publish("set_start_measure_time",1)#设置开始测量的时间戳时间
                 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) #停止测试血氧
                 EventMesh.publish("set_hr_blood_led",1)
                 EventMesh.publish(constants.EVENT.START_HEART) #手动心率测试
@@ -1278,37 +1294,33 @@ class intervManager(Abstract):
                 if get_spo2_state != 1:
                     EventMesh.debug_log("set_manual_measure_mode",msg)
                     EventMesh.publish("set_spo2_state",1)
-                    EventMesh.publish("set_start_measure_time")#设置开始测量的时间戳时间
+                    EventMesh.publish("set_start_measure_time",1)#设置开始测量的时间戳时间
                     EventMesh.publish("set_hr_blood_led",1)
                     EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN) #手动血氧测试
         elif msg == 3:
             if get_temp_state != 1:
                 EventMesh.debug_log("set_manual_measure_mode",msg)
                 EventMesh.publish("set_temp_state",1)
-                EventMesh.publish("set_start_temp_measure_time")#设置开始测量的时间戳时间
+                EventMesh.publish("set_start_temp_measure_time",1)#设置开始测量的时间戳时间
                 EventMesh.publish("set_hr_blood_led",1)
                 EventMesh.publish(constants.EVENT.START_TEMP)#手动体温测试
         pass
 
 
     def set_start_measure_time(self, event, msg): #手动测试 1心
-        date_tmp = utime.localtime()
-        time_tmp = utime.mktime(date_tmp)
-        self.timeSec = time_tmp
+        self.hr_auto = msg
         pass
 
     def get_start_measure_time(self, event, msg): #手动测试 
 
-        return self.timeSec
+        return  self.hr_auto
     
     def set_start_temp_measure_time(self, event, msg): #
-        date_tmp = utime.localtime()
-        time_tmp = utime.mktime(date_tmp)
-        self.timeTempSec = time_tmp
+        self.temp_auto = msg
         pass
 
     def get_start_temp_measure_time(self, event, msg): #
-        return self.timeTempSec
+        return self.temp_auto
 
     def mearsure_cb(self, event, msg):
         if msg == 1:
index 1ccaf0f..f861048 100644 (file)
@@ -324,8 +324,8 @@ class ledEventManager(Abstract):#灯事件
                     get_spo2_state = EventMesh.publish("get_spo2_state")
                     get_temp_state = EventMesh.publish("get_temp_state")
                     if get_hr_state != None or get_spo2_state != None or get_temp_state != None:
-                        if get_hr_state != 0 or get_spo2_state != 0 or get_temp_state != 0:#手动触发
-                            if get_hr_state != 2 or get_spo2_state != 2 or get_temp_state != 2:
+                        if get_hr_state == 1 or get_spo2_state == 1 or get_temp_state == 1:#手动触发
+                            if get_hr_state == 3 or get_spo2_state == 3 or get_temp_state == 3:
                                 EventMesh.publish("close_hr_sop2")
                                 EventMesh.publish("close_led_pin")
                                 return
index 8a6ac9c..ec4ff77 100644 (file)
@@ -880,6 +880,11 @@ class DeviceInfoManager(Abstract):
 
         self.time_count = 0
         
+        self.auto_spo2_count = 0
+
+        self.auto_hr_count = 0
+
+        self.auto_temp_count = 0
 
        
 
@@ -1134,7 +1139,7 @@ class DeviceInfoManager(Abstract):
             hour = data[4]
             min = data[5]
             next_alarm_time = utime.localtime(int(old_Timesec))
-            EventMesh.debug_log("data[5]:{} {} next_alarm_time:{} old_Timesec:{}".format(data[1],data[2],next_alarm_time,old_Timesec))
+            # EventMesh.debug_log("data[5]:{} {} next_alarm_time:{} old_Timesec:{}".format(data[1],data[2],next_alarm_time,old_Timesec))
             month = next_alarm_time[1]
             day = next_alarm_time[2]
             if month != data[1] or day != data[2]:
@@ -1311,13 +1316,13 @@ class DeviceInfoManager(Abstract):
                             EventMesh.publish("stop_led_timer")#设置参数
                         EventMesh.publish(constants.EVENT.STOP_HEART)
                         
-                    
+        if self.pull_time == 0:
+            self.pull_time = time_tmp
 
-        if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#已联网 并且不在充电 佩戴正常 不在通话就给测试心率
-        # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "0" and WEAR == 1 and call_state == 0:
-            if self.pull_time == 0:
-                self.pull_time = time_tmp
+        # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#已联网 并且不在充电 佩戴正常 不在通话就给测试心率
+        if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "1" and WEAR == 1 and call_state == 0:
             if time_tmp - self.pull_time >= 30:
+                # EventMesh.debug_log("shifens:")  
 
                 get_hr_state = EventMesh.publish("get_hr_state")
                 get_spo2_state = EventMesh.publish("get_spo2_state")
@@ -1565,12 +1570,12 @@ class DeviceInfoManager(Abstract):
                             get_spo2_state = EventMesh.publish("get_spo2_state")#血氧
                             get_bp_state  = EventMesh.publish("get_bp_state")#血压
                             get_bg_state  = EventMesh.publish("get_bg_state")#血糖
-                            # print("state hr",get_hr_state,get_spo2_state,get_bp_state,get_bg_state)
+                            print("state hr",get_hr_state,get_spo2_state,get_bp_state,get_bg_state)
                             if (get_bg_state == 0 and get_spo2_state == 0 and get_bp_state == 0) and  (get_hr_state == 2 or get_hr_state == 0):#心率血压血氧不在测试就测试血糖自动测量
                                 if (time_tmp-self.SENSOR_time) >= self.mearsure_timer:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 
                                     self.SENSOR_time = time_tmp
                                     self.HR_Onestate = 0
-                                # print("time_tmp hr",time_tmp,self.SENSOR_time,time_tmp-self.SENSOR_time,self.mearsure_timer,self.HR_Onestate)
+                                print("time_tmp hr",time_tmp,self.SENSOR_time,time_tmp-self.SENSOR_time,self.mearsure_timer,self.HR_Onestate)
                                 if (time_tmp - self.SENSOR_time) == 0 and self.HR_Onestate == 0:
                                     EventMesh.debug_log("START_hr:1")
                                     EventMesh.publish("set_hr_state",2)#2代表后台进入测试
@@ -1773,33 +1778,45 @@ class DeviceInfoManager(Abstract):
         spo2_state = EventMesh.publish("get_spo2_state")
         temp_state  = EventMesh.publish("get_temp_state")
         if hr_state != None or spo2_state != None or temp_state != None:#手动测试
+            auto_hr = EventMesh.publish("get_start_measure_time")#设置开始测量的时间戳时间
+            if auto_hr == None:
+                auto_hr = 0
             if hr_state == 1:
-                time_s = EventMesh.publish("get_start_measure_time")#设置开始测量的时间戳时间
-                if time_s != None:
-                    if time_s != 0:
-                        if (time_tmp - time_s) >= 60:#大于60s关闭测试
+                if auto_hr != 0:
+                    self.auto_hr_count+=1
+                    if  self.auto_hr_count > 6:
+                        self.auto_hr_count = 0
+                        EventMesh.publish("set_hr_state",0)#0代表g关闭测试
+                        EventMesh.debug_log("stop debug7")
+                        EventMesh.publish(constants.EVENT.STOP_HEART)
+                        heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+                        if heart_value > 50 and heart_value != None:
+                            EventMesh.publish("play_hr_value",heart_value)
+                            EventMesh.publish("set_history_hr_value",heart_value)
+                            EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+                        else:
+                            EventMesh.publish("play_hr_value",0) 
+
+                    else :
+                        if WEAR  != 1:
                             EventMesh.publish("set_hr_state",0)#0代表g关闭测试
                             EventMesh.debug_log("stop debug7")
-                            EventMesh.publish(constants.EVENT.STOP_HEART)
-                            heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
-                            if heart_value > 50 and heart_value != None:
-                                EventMesh.publish("play_hr_value",heart_value)
-                                EventMesh.publish("set_history_hr_value",heart_value)
-                                EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
-                            else:
-                                EventMesh.publish("play_hr_value",0) 
-                        else :
-                            if WEAR  != 1:
-                                EventMesh.publish("set_hr_state",0)#0代表g关闭测试
-                                EventMesh.debug_log("stop debug7")
-                                EventMesh.publish(constants.EVENT.STOP_HEART)                               
-                                EventMesh.publish("play_hr_value",0) 
-                pass
+                            EventMesh.publish(constants.EVENT.STOP_HEART)                               
+                            EventMesh.publish("play_hr_value",0) 
+                            
+            else:
+                self.auto_hr_count = 0
+                
+
+            auto_spo2 = EventMesh.publish("get_start_measure_time")#设置开始测量的时间戳时间
+            if auto_spo2 == None:
+                auto_spo2 = 0
             if spo2_state == 1:#手动测试血氧
-                time_s = EventMesh.publish("get_start_measure_time")#设置开始测量的时间戳时间
-                if time_s != None:
-                    if time_s != 0:
-                        if (time_tmp - time_s) >= 60:#大于60s关闭测试
+                if auto_spo2 != None:
+                    if auto_spo2 != 0:
+                        self.auto_spo2_count+=1
+                        if self.auto_spo2_count > 6:
+                            self.auto_spo2_count = 0
                             EventMesh.publish("set_spo2_state",0)#0代表g关闭测试
                             EventMesh.debug_log("stop spo2 debug7")
                             EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
@@ -1810,19 +1827,26 @@ class DeviceInfoManager(Abstract):
                                 EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
                             else:
                                 EventMesh.publish("play_spo2_value",0)
-                        else :
+                           
+                        else:
                             if WEAR  != 1:
                                 EventMesh.publish("set_spo2_state",0)#0代表g关闭测试
                                 EventMesh.debug_log("stop debug8")
                                 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)                               
                                 EventMesh.publish("play_spo2_value",0) 
-                pass
+                                
+            else:
+                self.auto_spo2_count = 0
 
             if temp_state == 1:#手动测试体温
-                time_s = EventMesh.publish("get_start_temp_measure_time")#设置开始测量的时间戳时间
-                if time_s != None:
-                    if time_s != 0:
-                        if (time_tmp - time_s) >= 30:#大于60s关闭测试
+                auto_temp = EventMesh.publish("get_start_temp_measure_time")#设置开始测量的时间戳时间
+                if auto_temp == None:
+                    auto_temp = 0
+                if auto_temp != None:
+                    if auto_temp != 0:
+                        self.auto_temp_count += 1
+                        if self.auto_temp_count > 6:
+                            self.auto_temp_count = 0
                             EventMesh.debug_log("体温测量结束")
                             temp = EventMesh.publish(constants.EVENT.GET_TEMP)       
                             temp = self.optimize_temp(temp)
@@ -1849,12 +1873,16 @@ class DeviceInfoManager(Abstract):
                                     EventMesh.publish("play_temp_value",0)#播放体温数值
                             
                             EventMesh.publish(constants.EVENT.STOP_TEMP)
+
                         else :
                             if WEAR  != 1:
                                 EventMesh.publish("set_temp_state",0)#0代表g关闭测试
                                 EventMesh.debug_log("stop debug9")
                                 EventMesh.publish(constants.EVENT.STOP_TEMP)                               
                                 EventMesh.publish("play_temp_value",0) 
+                                
+            else:
+                self.auto_temp_count = 0
 
         EventMesh.publish("play_unread_wechat_infor")#每10s检测是否有未读语音数据