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 :
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]
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) #手动心率测试
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:
self.time_count = 0
+ self.auto_spo2_count = 0
+
+ self.auto_hr_count = 0
+
+ self.auto_temp_count = 0
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]:
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")
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代表后台进入测试
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)
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)
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检测是否有未读语音数据