EventMesh.subscribe("sos_short_press", self.sos_short_press)#sos短按事件
- EventMesh.subscribe("falldown_alarm_event", self.falldown_alarm_event)#休息结束了
+ EventMesh.subscribe("falldown_alarm_event", self.falldown_alarm_event)#跌倒报警
+
+ EventMesh.subscribe("close_falldown_alarm_event", self.close_falldown_alarm_event)#关闭跌倒报警
EventMesh.subscribe("drink_alarm_event", self.drink_alarm_event)#该喝水了
else:
self.time_count = 0
self.fall_timer1.stop()
+
+ def close_falldown_alarm_event(self,event,msg):#跌倒挂断挂断
+ if self.fall_flag == 1:#跌倒标志
+ self.fall_flag = 0
+ self.fall_timer1.stop()
+ self.sos_timer1.stop()
+ self.sos_timer2.stop()
+ if self.call_state != 0:
+ self.call_state = 0
+ voiceCall.callEnd()
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ self.call_state = 0
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("set_hangup_mode",0)
return self.fall_flag
def sos_short_press(self,args,msg):
- self.fall_timer1.stop()
- if self.fall_flag == 1:#跌倒标志
- self.fall_flag = 0
- self.sos_timer1.stop()
- self.sos_timer2.stop()
- if self.call_state != 0:
- self.call_state = 0
- voiceCall.callEnd()
- sos_flag = EventMesh.publish("get_sos_flag")
- if sos_flag == 1:
- self.call_state = 0
- EventMesh.publish("set_sos_flag",0)
- EventMesh.publish("set_sos_num",0)
- EventMesh.publish("set_hangup_mode",0)
-
EventMesh.publish("interup_call_event")#如果在电话中强制挂断电话
EventMesh.publish("close_audio_play")#强制关闭音频文件播放
EventMesh.publish("STOP_FIND_WATCH")#停止查找设备
self.timer.stop()
self.sos_timer2.stop()
self.sos_timer1.stop()
- self.fall_timer1.stop()
self.fall_flag = 0
+ self.fall_timer1.stop()
self.alarm_timer1.stop()
def set_call_state(self, event, msg): #
self.call_state = msg
- def dialin_call_event(self, event, msg):#电话打进来
+ def dialin_call_event(self, event, msg):
open_power = EventMesh.publish("get_power_on_state")#获取开机标识
if open_power != None:
if open_power == 0:
def play_cur_step_event(self, event, msg): #msg 1 播放当前步数
flag = EventMesh.publish("get_call_state")
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
+ if flag == 0:#电话通话中 或者呼叫中挂断中断
+ if self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
step = EventMesh.publish("get_old_step_value")
EventMesh.debug_log("step",step)
self.setp_old = step
if get_hr_state == 2 or get_hr_state == 3:
EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_hr_state == 3:
+ EventMesh.publish("stop_led_timer")#设置参数
EventMesh.debug_log("stop debug8")
EventMesh.publish(constants.EVENT.STOP_HEART)
elif get_spo2_state == 2 or get_spo2_state == 3:
EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_spo2_state == 3:
+ 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:
EventMesh.publish("set_bp_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_bp_state == 3:
+ 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:
EventMesh.publish("set_bg_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_bg_state == 3:
+ EventMesh.publish("stop_led_timer")#设置参数
EventMesh.publish(constants.EVENT.STOP_HEART)
EventMesh.debug_log("stop BG debug14")
if msg == 1:
get_bg_state = EventMesh.publish("get_bg_state")
get_bp_state = EventMesh.publish("get_bp_state")
if get_hr_state != None and get_spo2_state != None and get_temp_state != None and get_bg_state != None and get_bp_state != None:
- if get_hr_state != 0:
+ if get_hr_state == 1 or get_hr_state == 3:
EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
EventMesh.debug_log("sstop hr")
EventMesh.publish(constants.EVENT.STOP_HEART)
- elif get_spo2_state != 0:
+ if get_spo2_state == 1 or get_spo2_state == 3:
EventMesh.debug_log("stop spo2")
EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
- if get_temp_state != 0:
+ if get_temp_state == 1 or get_temp_state == 3:
EventMesh.debug_log("stop temp")
EventMesh.publish("set_temp_state",0)
EventMesh.publish(constants.EVENT.STOP_TEMP)#手动体温测试
- if get_bg_state != 0:
+ if get_bg_state == 1 or get_bg_state == 3:
EventMesh.publish("set_bg_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
EventMesh.debug_log("sstop bg")
EventMesh.publish(constants.EVENT.STOP_HEART)
- if get_bp_state != 0:
+ if get_bp_state == 1 or get_bp_state == 3:
EventMesh.publish("set_bp_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
EventMesh.debug_log("sstop bp")
EventMesh.publish(constants.EVENT.STOP_HEART)
# EventMesh.debug_log('### key22_extint_cb {} self.GPIO22_status:{}'.format(args,self.sosKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
if self.WeChatKey_status != 0 and self.GPIO26_status != 0:
if self.sosKey_status == 0:#按下
+ EventMesh.publish("close_falldown_alarm_event")#sos短按事件
if self.sosKey_press == 0 :
self.led_state = 0
# self.wechatKey_timeout_cb(0)
def sosKey_timeout_cb(self, data):#
# EventMesh.debug_log("sosKey_press_count!!!!!!!!!!!!!! ",self.sosKey_press_count)
- fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
if self.sosKey_press_count == 10:#
self.sosKey_press_count = 0
pass
pass
elif self.sosKey_press_count == 4:#拨打app快捷号码
self.sosKey_press_count = 0
- if fall_down == 0:
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("play_center_phone")#拨打快捷号码
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("play_center_phone")#拨打快捷号码
# EventMesh.publish("call_phonebook_three_call")
pass
elif self.sosKey_press_count == 3:#测试心率
pass
elif self.sosKey_press_count == 2:#播报当前步数
self.sosKey_press_count = 0
- if fall_down == 0:
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("play_cur_step_event")#
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("play_cur_step_event")#
pass
elif self.sosKey_press_count == 1:#挂断来电 短语音播报
self.sosKey_press_count = 0
EventMesh.publish("stop_led_timer")#设置参数
# EventMesh.publish("call_test_event")
EventMesh.publish("sos_short_press")#sos短按事件
+
pass
self.sosKey_press_count = 0
hour = date_tmp[3]
min = date_tmp[4]
old_Timesec = EventMesh.publish("get_old_time_data")
+ old_step_state = EventMesh.publish("get_old_step_data")
+ if old_step_state == None:
+ old_step_state = 0
# EventMesh.debug_log("old_Timesec",old_Timesec)
- if old_Timesec != None:
+ if old_Timesec != None and old_step_state != None:
data = RTC().datetime()
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]:
- step = EventMesh.publish("get_old_step_value")
- if step > 0:
- self.gsensor.reset_step()
- EventMesh.publish("set_old_step_value",0)
-
- hr = EventMesh.publish("get_old_hr_data",)
- if hr != 0:
- EventMesh.publish("set_old_hr_data", 0)
-
- spo2 = EventMesh.publish("get_old_spo2_data")
- if spo2 != 0:
- EventMesh.publish("set_old_spo2_data", 0)
- EventMesh.publish("set_old_time_data",time_tmp)
- if hour == 0:#清步数
- if min <= 1:
- if self.clear_step == 0:
+ if old_step_state == 0:
step = EventMesh.publish("get_old_step_value")
- EventMesh.publish("set_old_time_data",time_tmp)
if step > 0:
- EventMesh.publish("set_old_step_value",0)
self.gsensor.reset_step()
- hr = EventMesh.publish("get_old_hr_data")
+ EventMesh.publish("set_old_step_value",0)
+
+ hr = EventMesh.publish("get_old_hr_data",)
if hr != 0:
EventMesh.publish("set_old_hr_data", 0)
spo2 = EventMesh.publish("get_old_spo2_data")
if spo2 != 0:
EventMesh.publish("set_old_spo2_data", 0)
- self.clear_step = 1
+ EventMesh.publish("set_old_time_data",time_tmp)
+ EventMesh.publish("set_old_step_data",1)#清一次
+ if hour == 23:#清步数
+ if min <= 59 and min >= 58:#58 59
+ clear_step_state = EventMesh.publish("get_old_step_data")
+ if clear_step_state == None:
+ clear_step_state = 0
+ if self.clear_step == 0 :
+ if clear_step_state == 0:
+ step = EventMesh.publish("get_old_step_value")
+ EventMesh.publish("set_old_time_data",time_tmp)
+ EventMesh.publish("set_old_step_data",1)
+ if step > 0:
+ EventMesh.publish("set_old_step_value",0)
+ self.gsensor.reset_step()
+ hr = EventMesh.publish("get_old_hr_data")
+ if hr != 0:
+ EventMesh.publish("set_old_hr_data", 0)
+
+ spo2 = EventMesh.publish("get_old_spo2_data")
+ if spo2 != 0:
+ EventMesh.publish("set_old_spo2_data", 0)
+ self.clear_step = 1
else:
if self.clear_step == 1:
self.clear_step = 0
if get_temp_state > 1 and (WEAR != 1 or call_state != 0):
EventMesh.publish(constants.EVENT.STOP_TEMP)
EventMesh.publish("set_temp_state",0)
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_temp_state > 2:
+ EventMesh.publish("stop_led_timer")#设置参数
if (self.get_hr_state > 1 or self.get_spo2_state > 1 or get_bp_state > 1 or get_bg_state > 1) and (WEAR != 1 or call_state != 0):
print("wear faile")
if self.get_hr_state > 1 :
EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
- EventMesh.publish("stop_led_timer")#设置参数
+ if self.get_hr_state > 2:
+ EventMesh.publish("stop_led_timer")#设置参数
EventMesh.publish(constants.EVENT.STOP_HEART)
elif self.get_spo2_state > 1:
EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ if self.get_spo2_state > 2:
+ EventMesh.publish("stop_led_timer")#设置参数
EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
elif get_bp_state > 1:
EventMesh.publish("set_bp_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_bp_state > 2:
+ EventMesh.publish("stop_led_timer")#设置参数
EventMesh.publish(constants.EVENT.STOP_HEART)
elif get_bg_state > 1:
EventMesh.publish("set_bg_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_bg_state > 2:
+ EventMesh.publish("stop_led_timer")#设置参数
EventMesh.publish(constants.EVENT.STOP_HEART)
- # 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 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 time_tmp - self.pull_time >= 30:
if (time_tmp-self.temp_time) == 0 and self.temp_state == 0:#一开始就测量 测量一分钟停止测量体温
self.temp_state = 1
EventMesh.publish("set_temp_state",2)
- EventMesh.publish("set_hr_blood_led",1)
+ # EventMesh.publish("set_hr_blood_led",1)
EventMesh.debug_log("AUTO temp:")
EventMesh.publish(constants.EVENT.START_TEMP)
EventMesh.publish("set_history_temp_value",0)
# EventMesh.publish("play_temp_value",0)#播放体温数值
EventMesh.publish(constants.EVENT.STOP_TEMP)
- EventMesh.publish("stop_led_timer")#设置参数
+ # EventMesh.publish("stop_led_timer")#设置参数
EventMesh.debug_log("AUTO temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp))
else:
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代表后台进入测试
- EventMesh.publish("set_hr_blood_led",1)
+ # EventMesh.publish("set_hr_blood_led",1)
EventMesh.publish(constants.EVENT.START_HEART)
self.HR_Onestate = 1
elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_Onestate == 1:
EventMesh.publish("set_history_hr_value",heart_value)
EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
else:
- EventMesh.publish("stop_led_timer")#设置参数
+ # EventMesh.publish("stop_led_timer")#设置参数
pass
# EventMesh.publish("play_hr_value",0)
#获取心率数据上传数据app
if hr_state == 2:
EventMesh.publish("set_hr_state",0)#2代表后台进入测试
EventMesh.debug_log("33stop debug3")
- EventMesh.publish("stop_led_timer")#设置参数
+ # EventMesh.publish("stop_led_timer")#设置参数
EventMesh.publish(constants.EVENT.STOP_HEART)
if bg_time[0] != None:
if (time_tmp - self.bg_times) == 0 and self.BG_state == 0:
EventMesh.debug_log("START_bg:1")
EventMesh.publish("set_bg_state",2)#2代表后台进入测试
- EventMesh.publish("set_hr_blood_led",1)
+ # EventMesh.publish("set_hr_blood_led",1)
EventMesh.publish(constants.EVENT.START_HEART)
self.BG_state = 1
elif (time_tmp - self.bg_times) >= 60 and self.BG_state == 1:
EventMesh.publish("set_bg_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ # EventMesh.publish("stop_led_timer")#设置参数
EventMesh.debug_log("stop bgdebug3")
EventMesh.publish(constants.EVENT.STOP_HEART)
bgdata = get_blood_sugar_value()
bg_state = EventMesh.publish("get_bg_state")
if bg_state == 2:
EventMesh.publish("set_bg_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ # EventMesh.publish("stop_led_timer")#设置参数
EventMesh.debug_log("bg stop bgdebug3")
EventMesh.publish(constants.EVENT.STOP_HEART)
self.bg_times = 0
if get_hr_state == 2 or get_hr_state == 3:
EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_hr_state == 3:
+ EventMesh.publish("stop_led_timer")#设置参数
EventMesh.debug_log("stop debug8")
EventMesh.publish(constants.EVENT.STOP_HEART)
elif get_spo2_state == 2 or get_spo2_state == 3:
EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_spo2_state == 3:
+ 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:
EventMesh.publish("set_bp_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_bp_state == 3:
+ EventMesh.publish("stop_led_timer")#设置参数
EventMesh.publish(constants.EVENT.STOP_HEART)
EventMesh.debug_log("stop debug14")
elif get_bg_state == 2 or get_bg_state == 3:
EventMesh.publish("set_bg_state",0)#2代表后台进入测试
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_bg_state == 3:
+ EventMesh.publish("stop_led_timer")#设置参数
EventMesh.publish(constants.EVENT.STOP_HEART)
EventMesh.debug_log("stop debug15")
else:
EventMesh.publish("set_history_temp_value",0)
# EventMesh.publish("play_temp_value",0)#播放体温数值
- EventMesh.publish("stop_led_timer")#设置参数
+ if get_temp_state == 3:
+ EventMesh.publish("stop_led_timer")#设置参数
+
EventMesh.publish(constants.EVENT.STOP_TEMP)
# 获取天气数据
def __init__(self):
self.time_sec = 0
+ self.time_step = 0
tmp_data = EventMesh.publish("get_storage_config","old_time")
if tmp_data !=None :
self.time_sec = tmp_data
+ tmp_data = EventMesh.publish("get_storage_config","old_step")
+ if tmp_data !=None :
+ self.time_step = tmp_data
def post_processor_after_instantiation(self):
EventMesh.subscribe("get_old_time_data", self.get_old_time_data)
EventMesh.subscribe("set_old_time_data", self.set_old_time_data)
+ EventMesh.subscribe("get_old_step_data", self.get_old_step_data)
+ EventMesh.subscribe("set_old_step_data", self.set_old_step_data)
+
def get_old_time_data(self, event, msg):
return self.time_sec
+
+ def get_old_step_data(self, event, msg):
+ return self.time_step
def set_old_time_data(self, event, msg):
self.time_sec = msg
EventMesh.publish("set_storage_config",["old_time",msg])
+ def set_old_step_data(self, event, msg):
+ self.time_sec = msg
+ EventMesh.publish("set_storage_config",["old_step",msg])
+