From: dxy15521469561 <1731678236@qq.com> Date: Sat, 20 Jan 2024 03:10:00 +0000 (+0800) Subject: K5_DDY: X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=9552d4067b1c6e5f01009e0b7deadcb8e4748bd4;p=mirrors%2FASR1603_G5.git K5_DDY: 需求更改 --- diff --git a/2.sdk/Helios_SDK/components/juphoon/lib/libjrtc.a b/2.sdk/Helios_SDK/components/juphoon/lib/libjrtc.a index 6885f14d..a9efd93f 100644 Binary files a/2.sdk/Helios_SDK/components/juphoon/lib/libjrtc.a and b/2.sdk/Helios_SDK/components/juphoon/lib/libjrtc.a differ diff --git a/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/initTP.py b/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/initTP.py index 36058aa8..534ca065 100644 --- a/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/initTP.py +++ b/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/initTP.py @@ -81,7 +81,7 @@ def cst816d_update(startAddr, length, data): cmd[0] = 0xEE ret = i2c_obj.write(TP_HYN_I2C_UPDATE_WRITE_ADDR>>1, bytearray([0xa0,0x04]), 2, bytearray(cmd), 1) - utime.sleep_ms(250) + utime.sleep_ms(100) retrycnt = 51 for i in range (retrycnt): @@ -92,19 +92,7 @@ def cst816d_update(startAddr, length, data): if r_data[0] == 0x55: print("r_data[0] = 0x55,break") break - i2c_obj = I2C(I2C.I2C2, I2C.STANDARD_MODE) - print("cst816d_update try:count:{}!!!".format(i)) - # ret = i2c_obj.write(TP_HYN_I2C_UPDATE_WRITE_ADDR>>1, bytearray([0xa0,0x14]), 2, bytearray(cmd), 2) - # utime.sleep_ms(5) - - # ret = i2c_obj.write(TP_HYN_I2C_UPDATE_WRITE_ADDR>>1, bytearray([0xa0,0x18]), 2, bytearray(data), PER_LEN) - - # utime.sleep_ms(5) - - # cmd[0] = 0xEE - # ret = i2c_obj.write(TP_HYN_I2C_UPDATE_WRITE_ADDR>>1, bytearray([0xa0,0x04]), 2, bytearray(cmd), 1) - - utime.sleep_ms(5) + startAddr = startAddr + PER_LEN del data[0:PER_LEN] sum_len = sum_len + PER_LEN diff --git a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/constants.py b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/constants.py index a67e2e0f..f56d62ab 100644 --- a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/constants.py +++ b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/constants.py @@ -126,6 +126,12 @@ class PROTOCOL: SLEEPTIME_SEND = "SLEEPTIME_SEND" SLEEPTIME_RECV = "SLEEPTIME_RECV" + MESSAGE_SOS_SEND = "MESSAGE_SOS_SEND" + MESSAGE_SOS_RECV = "MESSAGE_SOS_RECV" + + MSGQ_SEND = "MSGQ_SEND" + MSGQ_RECV = "MSGQ_RECV" + class EVENT: diff --git a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/main_init.py b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/main_init.py index ce3b261f..6a354822 100644 --- a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/main_init.py +++ b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/main_init.py @@ -212,6 +212,7 @@ def main_init(): ui.add_screen(NewWechatPopupScreen()) ui.add_screen(HealthScreen()) ui.add_screen(_ui.classMgrPopupScreen()) + ui.add_screen(_ui.sosrecvScreen()) # ui.add_screen(_ui.Setting3Screen()) except Exception as e: usys.print_exception(e) @@ -332,6 +333,8 @@ def main_init(): pcr.add_support(protocol.REMOVE_ProtoCol()) pcr.add_support(protocol.SLEEPTIME_ProtoCol()) pcr.add_support(protocol.FACTORY_ProtoCol()) + pcr.add_support(protocol.MESSAGE_SOS_ProtoCol()) + pcr.add_support(protocol.MSGQ_ProtoCol()) except Exception as e: usys.print_exception(e) try: diff --git a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/mgr.py b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/mgr.py index 84a0d90e..89fd629b 100644 --- a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/mgr.py +++ b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/mgr.py @@ -944,10 +944,7 @@ class DeviceInfoManager(Abstract): # print("date_tmp......01....{} time_tmp:{}\r\n".format(date_tmp,time_tmp)) """电量小于20% 5分钟提醒一次""" - if self.alarm_count <= 120: - self.alarm_count+=10 - if self.alarm_count == 20: - EventMesh.publish("set_rtc_alarm") + EventMesh.publish(constants.PROTOCOL.MSGQ_SEND) get_low_btn = EventMesh.publish("get_low_bat_btn")# battery = EventMesh.publish("screen_get_battery") diff --git a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/protocol.py b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/protocol.py index 2ea56eac..0c137018 100644 --- a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/protocol.py +++ b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/protocol.py @@ -2356,7 +2356,75 @@ class MESSAGE_ProtoCol(ProtoCol): else: EventMesh.publish("wechat_updata_list_show") +# 平台发送: +# [XT*YYYYYYYYYYYYYYY*LEN*MESSAGE_SOS,短语内容] +# 实例:[XT*334588000000156*0018*MESSAGE_SOS,597D003100320033] +# 终端确认操作回复: +# [XT*YYYYYYYYYYYYYYY*LEN*MESSAGE_SOS] +# 实例:[XT*334588000000156*0007*MESSAGE_SOS] +class MESSAGE_SOS_ProtoCol(ProtoCol): + """微聊""" + TYPE = "MESSAGE_SOS" + + + def send(self, event, msg): + + #[XT*334588000000156*0007*MESSAGE] + send_data = self.PID+"*%s*000b*MESSAGE_SOS"%(self.imei) + MD5_SIGN = self.pack_MD5_head(send_data) + data = "[%s%s]"%(str(MD5_SIGN),send_data) + #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data)) + # 通过socket发送到服务器端 + EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data) + + def recv(self, event, msg): + """ + + @param event: 微聊文字 + @param msg: 接收到的下行数据 + """ + msg = msg[1:-1] + + msg_s = msg.decode('ascii') + msg_s = msg_s.split('MESSAGE_SOS,')[1] + + for phonebook_tmp in msg_s: + if len(phonebook_tmp) != 0: + phonebook_name = UnicodeHexStr_To_Utf8Str(phonebook_tmp) + EventMesh.publish("load_screen", {"screen": "sos_rev","meta":phonebook_name}) + + + +# 请求[XT*334588000000156*0004*MSGQ] +class MSGQ_ProtoCol(ProtoCol): + """微聊""" + TYPE = "MSGQ" + + + def send(self, event, msg): + + #[XT*334588000000156*0007*MESSAGE] + send_data = self.PID+"*%s*0005*MSGQ"%(self.imei) + MD5_SIGN = self.pack_MD5_head(send_data) + data = "[%s%s]"%(str(MD5_SIGN),send_data) + #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data)) + # 通过socket发送到服务器端 + EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data) + + def recv(self, event, msg): + """ + + @param event: 微聊文字 + @param msg: 接收到的下行数据 + """ + msg = msg[1:-1] + + msg_s = msg.decode('ascii') + + + + diff --git a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui.py b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui.py index db63e80e..f04d7a26 100644 --- a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui.py +++ b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui.py @@ -6049,6 +6049,92 @@ class classMgrPopupScreen(Screen):#上课禁用时间界面 else: EventMesh.publish(constants.EVENT.SYSTEM_UP) + +sos_recv_screen = None +sos_recv_screen_label = None +sos_recv_screen_comfirm=None +sos_recv_screen_label2 = None +class sosrecvScreen(Screen):#设备接收平台发送的 + NAME = "sos_rev" + def __init__(self): + super().__init__() + self.meta = None + self.meta_type = "popup" + self.timer = osTimer() + self.count = 0 + + def initialization(self): + self.count = 0 + global sos_recv_screen,sos_recv_screen_label,sos_recv_screen_label2,sos_recv_screen_comfirm + if sos_recv_screen == None : + sos_recv_screen = lv.obj() + print("sos_recv_screen") + sos_recv_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) + # add style for watchface + sos_recv_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT) + # + sos_recv_screen_label = lv.label(sos_recv_screen) + sos_recv_screen_label.set_size(240, 220-20) + sos_recv_screen_label.set_pos(0, 20) + sos_recv_screen_label.set_text(" ") + sos_recv_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN|lv.STATE.DEFAULT) + + sos_recv_screen_comfirm = lv.img(sos_recv_screen) + sos_recv_screen_comfirm.set_size(176, 46) + sos_recv_screen_comfirm.set_pos(32, 220) + sos_recv_screen_comfirm.set_src("E:/static/off_icon.png") + sos_recv_screen_comfirm.add_flag(lv.obj.FLAG.CLICKABLE) + sos_recv_screen_comfirm.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + sos_recv_screen_label2 = lv.label(sos_recv_screen_comfirm) + sos_recv_screen_label2.set_text("确定") + sos_recv_screen_label2.align(lv.ALIGN.CENTER, 0, 5) + sos_recv_screen_label2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + + + self.meta = sos_recv_screen + sos_recv_screen_comfirm.add_event_cb(lambda e: EventMesh.callback_wrapper(self.confirm(e)), + lv.EVENT.SHORT_CLICKED, None) + self.meta_info = "需要你的帮助,是好滴还是我hi海带丝电池给谁hi都会死hi换货地址好ID号i海底火山hi大海hi属地化似乎机顶盒试试几点合适试试是是是" + sos_recv_screen_label.set_text("{}".format(self.meta_info)) + EventMesh.publish("set_motor_time",[1,2,10*10,10,5])#设置马达参数 + self.timer.start(1*1000,1,self.motor_cb) + + def confirm(self,e): + EventMesh.publish(constants.PROTOCOL.MESSAGE_SOS_SEND) + EventMesh.publish("close_motor_infor")#关闭马达和定时器 + EventMesh.publish("return_prev_screen") + + def motor_cb(self,*argc): + EventMesh.publish("system_sleep_rest")#防止黑屏 + self.count+=1 + if self.count >= 7: + self.count = 0 + EventMesh.publish("set_motor_time",[1,2,10*10,10,5])#设置马达参数 + + # + + def Close(self): + EventMesh.publish("close_motor_infor")#关闭马达和定时器 + + def done_return(self): + EventMesh.publish("return_prev_screen") + + def btn1_release(self): + EventMesh.publish("return_prev_screen") + + def done_left_to_right(self): + EventMesh.publish("return_prev_screen") + def done_right_to_left(self): + EventMesh.publish("return_prev_screen") + def done_bottom_to_top(self): + EventMesh.publish("return_prev_screen") + def done_top_to_bottom(self): + EventMesh.publish("return_prev_screen") + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "main_menu"}) #from usr.ui_WatchFaceScreen import WatchFaceScreen class UI(object): def __init__(self): diff --git a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui_health.py b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui_health.py index 9f31eec2..f3da73a3 100644 --- a/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui_health.py +++ b/2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui_health.py @@ -401,7 +401,9 @@ class TemperatureScreen(Screen): self.timer.start(1*500, 1, self.start_measure) def show_history_temp_data(self,event,msg): - global temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,temp_line6,temp_line7 + global temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,temp_line6,temp_line7,temperature_screen + if temperature_screen == None: + return read_data = {} read_data = EventMesh.publish("get_history_temp_value") print("hr get_history_temp_value",read_data) @@ -866,7 +868,9 @@ class Spo2Screen(Screen): EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN) def show_history_spo2_data(self,event,msg): - global spo2_line1,spo2_line2,spo2_line3,spo2_line4,spo2_line5,spo2_line6,spo2_line7 + global spo2_line1,spo2_line2,spo2_line3,spo2_line4,spo2_line5,spo2_line6,spo2_line7,spo2_screen + if spo2_screen == None: + return read_data = {} read_data = EventMesh.publish("get_history_spo2_value") # print("hr get_history_spo2_value",read_data) @@ -1239,6 +1243,8 @@ class HeartrateScreen(Screen): def show_history_hr_data(self,event,msg): global hr_line1,hr_line2,hr_line3,hr_line4,hr_line5,hr_line6,hr_line7 + if heartrate_screen == None: + return read_data = {} read_data = EventMesh.publish("get_history_hr_value") if read_data != None: @@ -2175,6 +2181,9 @@ class bloodpressureScreen(Screen): blood_pressure_line2_h,blood_pressure_line2_l,blood_pressure_line3_h,blood_pressure_line3_l,blood_pressure_line4_h,blood_pressure_line4_l,\ blood_pressure_line5_h,blood_pressure_line5_l,blood_pressure_line6_h,blood_pressure_line6_l,blood_pressure_line7_h,blood_pressure_line7_l,\ blood_pressure_line_bg_img,blood_pressure_done_img ,blood_pressure_start_label,blood_pressure_bpm_label ,blood_pressure_done_label + if blood_pressure_screen == None: + return + read_data = {} read_data = EventMesh.publish("get_old_blood_data") print("get_old_blood_data",read_data) diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py index 2663a0b4..e0b704ca 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py @@ -1655,9 +1655,9 @@ if EventMesh.model == "D10" : EventMesh.publish("close_timer_all")# # EventMesh.publish("stop_led_timer")#设置参数 mode = 0 - signal = EventMesh.publish("screen_get_sig") + signal = EventMesh.publish("get_sim_Status") if signal != None: - if signal >= 0 and signal <= 31:#有卡 + if signal == 1:#有卡 if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网提示关机 mode = 2 else: diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m_d15.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m_d15.py index 4c58f7a3..019820a2 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m_d15.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m_d15.py @@ -708,6 +708,7 @@ if EventMesh.model == "D15" : self.aud.stopPlayStream() Power.powerRestart() + def power_down_fun(self, *args): EventMesh.publish("close_led_pin") self.aud.stopPlayStream() @@ -1965,9 +1966,9 @@ if EventMesh.model == "D15" : EventMesh.publish("close_timer_all")# # EventMesh.publish("stop_led_timer")#设置参数 mode = 0 - signal = EventMesh.publish("screen_get_sig") + signal = EventMesh.publish("get_sim_Status") if signal != None: - if signal >= 0 and signal <= 31:#有卡 + if signal == 1:#有卡 if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网提示关机 mode = 2 else: @@ -2600,14 +2601,14 @@ if EventMesh.model == "D15" : self.pwk_key26 = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, self.pwk_extint_cb) self.pwk_key26.enable() - # self.sosKey = ExtInt(ExtInt.GPIO6,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.sosKey_extint_cb)#S0S键 - # self.sosKey.enable() + self.sosKey = ExtInt(ExtInt.GPIO6,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.sosKey_extint_cb)#S0S键 + self.sosKey.enable() self.extint_19 = ExtInt(ExtInt.GPIO19,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.key19_extint_cb) self.extint_19.enable() - # self.extint_17 = ExtInt(ExtInt.GPIO17,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.key17_extint_cb) - # self.extint_17.enable() + self.extint_17 = ExtInt(ExtInt.GPIO17,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.key17_extint_cb) + self.extint_17.enable() self.wechatKey = ExtInt(ExtInt.GPIO22, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.wechatKey_extint_cb) self.wechatKey.enable() @@ -2616,10 +2617,11 @@ if EventMesh.model == "D15" : def key17_extint_cb(self,args):#call 1 open_power = EventMesh.publish("get_power_on_state")#获取开机标识 open_power_off = EventMesh.publish("get_power_off_state")#获取开机标识 + video_state = EventMesh.publish("get_video_state")#获取视频通话状态 5在通话状态不允许按键输入 + get_video_state = EventMesh.publish("get_video_in_out_state") dev_app_mode = EventMesh.publish("get_dev_app_mode") - - if open_power != None and open_power_off != None and dev_app_mode != None: - if open_power == 0 or open_power_off == 1 or dev_app_mode == 1: + if open_power != None and open_power_off != None and dev_app_mode != None: + if open_power == 0 or open_power_off == 1 or (dev_app_mode == 1 and get_video_state != 0): return fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识 flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备 @@ -2816,8 +2818,9 @@ if EventMesh.model == "D15" : open_power = EventMesh.publish("get_power_on_state")#获取开机标识 dev_app_mode = EventMesh.publish("get_dev_app_mode") video_state = EventMesh.publish("get_video_state")#获取视频通话状态 5在通话状态不允许按键输入 + get_video_state = EventMesh.publish("get_video_in_out_state") if open_power != None and power_off != None and dev_app_mode != None: - if open_power == 0 or power_off == 1 or dev_app_mode == 1: + if open_power == 0 or power_off == 1 or (dev_app_mode == 1 and get_video_state != 0): return fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识 flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备 @@ -2839,6 +2842,7 @@ if EventMesh.model == "D15" : print("key17_extint_cb") EventMesh.publish("video_answer_cb") else: + EventMesh.publish("video_reject_cb",2)#挂断视频通话 return self.WeChatKey_status = self.wechatKey.read_level() @@ -3008,9 +3012,10 @@ if EventMesh.model == "D15" : open_power = EventMesh.publish("get_power_on_state")#获取开机标识 open_power_off = EventMesh.publish("get_power_off_state")#获取开机标识 video_state = EventMesh.publish("get_video_state") + get_video_state = EventMesh.publish("get_video_in_out_state") dev_app_mode = EventMesh.publish("get_dev_app_mode") if open_power != None and open_power_off != None and dev_app_mode != None: - if open_power == 0 or open_power_off == 1 or dev_app_mode == 1: + if open_power == 0 or open_power_off == 1 or (dev_app_mode == 1 and get_video_state != 0): return flag = EventMesh.publish("get_call_state")#获取通话状态 @@ -3270,16 +3275,7 @@ if EventMesh.model == "D15" : else: self.sosKey_status = 0 pass - if NEW_ENABLE == 0:#新的按键功能定义 - if self.sosKey_status == 0: - video_state = EventMesh.publish("get_video_state") - if video_state != 0:#视频通话打入或者接听后允许挂断视频通话 - if video_state == 6:#6是app打手表需要接通 - print("pwk_extint_cb") - # EventMesh.publish("video_answer_cb") - else: - EventMesh.publish("video_reject_cb",2)#挂断视频通话 - return + get_video = EventMesh.publish("get_video_in_out_state") self.WeChatKey_status = self.wechatKey.read_level() self.GPIO26_status = self.pwk_key26.read_level() @@ -3292,14 +3288,15 @@ if EventMesh.model == "D15" : if NEW_ENABLE == 0:#新的按键功能定义 video_state = EventMesh.publish("get_video_state") if video_state != 0:#视频通话打入或者接听后允许挂断视频通话 - EventMesh.publish("video_reject_cb",2)#挂断视频通话 - self.sosKey_press_count=0 - self.wechatKey_timer.stop() - self.pwkey_timer.stop() - self.sosKey_timer.stop() - self.Keycall2_timer.stop() - self.Keycall1_timer.stop() - return + if video_state == 6 or get_video == 0: + EventMesh.publish("video_reject_cb",2)#挂断视频通话 + self.sosKey_press_count=0 + self.wechatKey_timer.stop() + self.pwkey_timer.stop() + self.sosKey_timer.stop() + self.Keycall2_timer.stop() + self.Keycall1_timer.stop() + return EventMesh.publish("close_falldown_alarm_event")#关闭跌倒报警提醒事件 EventMesh.publish("close_wechat_btn_timer") @@ -3542,8 +3539,10 @@ if EventMesh.model == "D15" : open_power = EventMesh.publish("get_power_on_state")#获取开机标识 dev_app_mode = EventMesh.publish("get_dev_app_mode") video_state = EventMesh.publish("get_video_state")#获取视频通话状态 5在通话状态不允许按键输入 + get_video_state = EventMesh.publish("get_video_in_out_state") + if open_power != None and power_off != None and dev_app_mode != None: - if open_power == 0 or power_off == 1 or dev_app_mode == 1 : + if open_power == 0 or power_off == 1 or (dev_app_mode == 1 and get_video_state != 0): return fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识 if fall_down != None: @@ -3580,8 +3579,8 @@ if EventMesh.model == "D15" : if video_state == 6:#6是app打手表需要接通 print("wechatKey_extint_cb") EventMesh.publish("video_answer_cb") - # else: - # EventMesh.publish("video_reject_cb",2)#挂断视频通话 + else: + EventMesh.publish("video_reject_cb",2)#挂断视频通话 self.wechatKey_press_count = 0 self.wechatKey_timer.stop() diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py index 46840727..551ad0ee 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py @@ -1912,9 +1912,8 @@ if EventMesh.model == "D10": if bgdata != 0: EventMesh.publish(constants.PROTOCOL.BLOODGLUSOCE_SEND,bgdata)#上传心率数据 EventMesh.debug_log("stop debug15") - - if get_temp_time != None: - get_temp_state = EventMesh.publish("get_temp_state") + get_temp_state = EventMesh.publish("get_temp_state") + if get_temp_state != None: if get_temp_state > 1: self.temp_one_state = 0 self.temp_state = 0 diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr_d15.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr_d15.py index 0fa5d4c0..b401c50a 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr_d15.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr_d15.py @@ -1428,534 +1428,99 @@ if EventMesh.model == "D15": if self.pull_time == 0: self.pull_time = time_tmp - if EventMesh.model == "D15": - # 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 and video_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_bp_state = EventMesh.publish("get_bp_state") - get_bg_state = EventMesh.publish("get_bg_state") - get_temp_state = EventMesh.publish("get_temp_state") - if get_hr_state == None: - get_hr_state = 0 - self.old_hr_time = 0 + # 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 and video_state == 0: + if time_tmp - self.pull_time >= 30: + # EventMesh.debug_log("shifens:") - if get_spo2_state == None: - get_spo2_state = 0 - self.old_spo2_time = 0 + get_hr_state = EventMesh.publish("get_hr_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") + get_temp_state = EventMesh.publish("get_temp_state") + if get_hr_state == None: + get_hr_state = 0 + self.old_hr_time = 0 - if get_temp_state == None: - get_temp_state = 0 - self.temp_one_state = 0 + if get_spo2_state == None: + get_spo2_state = 0 + self.old_spo2_time = 0 - if get_bp_state == None: - get_bp_state = 0 - self.old_bp_time = 0 - - if get_bg_state == None: - get_bg_state = 0 - self.old_bg_time = 0 - - # print("bp get_bp_state ",get_bp_state,self.old_bp_time) + if get_temp_state == None: + get_temp_state = 0 + self.temp_one_state = 0 - - if get_hr_state != None: - if get_hr_state == 3: - self.old_hr_time+=1 - if self.old_hr_time == 1: - EventMesh.publish("set_hr_state",3)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_HEART) - EventMesh.txt_log("auto start_hr:333") - elif self.old_hr_time > 6: - self.old_hr_time = 0 - EventMesh.publish("set_hr_state",0)#2代表后台进入测试 - EventMesh.txt_log("auto stop_hr:333") - EventMesh.publish(constants.EVENT.STOP_HEART) - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - EventMesh.debug_log("heart_value:{}".format(heart_value)) - if heart_value > 50 and heart_value != None: - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 - EventMesh.debug_log("STOP_HEART:3") - else: + if get_bp_state == None: + get_bp_state = 0 + self.old_bp_time = 0 + + if get_bg_state == None: + get_bg_state = 0 + self.old_bg_time = 0 + + # print("bp get_bp_state ",get_bp_state,self.old_bp_time) + + + if get_hr_state != None: + if get_hr_state == 3: + self.old_hr_time+=1 + if self.old_hr_time == 1: + EventMesh.publish("set_hr_state",3)#2代表后台进入测试 + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_HEART) + EventMesh.txt_log("auto start_hr:333") + elif self.old_hr_time > 6: self.old_hr_time = 0 + EventMesh.publish("set_hr_state",0)#2代表后台进入测试 + EventMesh.txt_log("auto stop_hr:333") + EventMesh.publish(constants.EVENT.STOP_HEART) + heart_value = EventMesh.publish(constants.EVENT.GET_HEART) + EventMesh.debug_log("heart_value:{}".format(heart_value)) + if heart_value > 50 and heart_value != None: + EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 + EventMesh.debug_log("STOP_HEART:3") else: self.old_hr_time = 0 + else: + self.old_hr_time = 0 - if get_spo2_state != None: - if get_spo2_state == 3: - self.old_spo2_time+=1 - if self.old_spo2_time == 1: - EventMesh.publish("set_spo2_state",3)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 - EventMesh.txt_log("auto start_spo2:333") - elif self.old_spo2_time > 6: - self.old_spo2_time = 0 - EventMesh.txt_log("auto stop_spo2:333") - EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - if spo2_value > 85 and spo2_value != None: - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - - else: + if get_spo2_state != None: + if get_spo2_state == 3: + self.old_spo2_time+=1 + if self.old_spo2_time == 1: + EventMesh.publish("set_spo2_state",3)#2代表后台进入测试 + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 + EventMesh.txt_log("auto start_spo2:333") + elif self.old_spo2_time > 6: self.old_spo2_time = 0 - else: - self.old_spo2_time = 0 - - - if get_bp_state != None: - if get_bp_state == 3: - self.old_bp_time+=1 - if self.old_bp_time == 1: - EventMesh.publish("set_bp_state",3)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_HEART) - EventMesh.txt_log("auto start_bp:333") - elif self.old_bp_time > 6: - self.old_bp_time = 0 + EventMesh.txt_log("auto stop_spo2:333") + EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 + EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) + spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) + if spo2_value > 85 and spo2_value != None: + EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - EventMesh.publish("set_bp_state",0)#2代表后台进入测试 - # EventMesh.publish("stop_led_timer")#设置参数 - blood_data = get_autoblood_value() - if blood_data == None: - blood_data[0] = 0 - blood_data[1] = 0 - - max_value = blood_data[0] - min_value = blood_data[1] - if max_value != 0 and min_value != 0: - EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value]) - EventMesh.publish(constants.EVENT.STOP_HEART) - EventMesh.txt_log("auto stop_bp:333") - else: - self.old_bp_time = 0 - else: - self.old_bp_time = 0 - - if get_bg_state != None: - if get_bg_state == 3: - self.old_bg_time+=1 - if self.old_bg_time == 1: - EventMesh.publish("set_bg_state",3)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_HEART) - EventMesh.txt_log("auto start_bg:333") - elif self.old_bg_time > 6: - self.old_bg_time = 0 - EventMesh.publish("set_bg_state",0)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.STOP_HEART) - # EventMesh.publish("stop_led_timer")#设置参数 - bg_data = get_blood_sugar_value() - if bg_data == None: - bg_data = 0 - if bg_data != 0: - EventMesh.publish(constants.PROTOCOL.BLOODGLUSOCE_SEND,bg_data) - - EventMesh.txt_log("auto stop_bp:333") - else: - self.old_bg_time = 0 else: - self.old_bg_time = 0 - - - if get_temp_state != None: - if get_temp_state == 3:#单次测量 - self.temp_one_state+=1 - if self.temp_one_state == 1: - EventMesh.txt_log("auto start_temp:333") - EventMesh.debug_log("AUTO one temp:2") - EventMesh.publish("set_temp_state",3) - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_TEMP) - elif self.temp_one_state > 3: - self.temp_one_state = 0 - temp = EventMesh.publish(constants.EVENT.GET_TEMP) - temp = self.optimize_temp(temp) - - EventMesh.publish("set_temp_state",0) - 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(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp]) - EventMesh.publish(constants.EVENT.STOP_TEMP) - EventMesh.txt_log("auto start_temp:333") - - - - - # EventMesh.debug_log("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state)) - if get_temp_time != None:#定时测量体温 - if get_temp_time > 0: - if get_temp_state != None: - get_temp_state = EventMesh.publish("get_temp_state") - if get_temp_state == 0 or get_temp_state == 2: - if (time_tmp-self.temp_time) >= get_temp_time:#大于一个周期的时间,重新赋值 - self.temp_state = 0 - self.temp_time = time_tmp - - if self.old_temp_time != get_temp_time:#重复修改测量间隔时间 - self.temp_time = time_tmp#防止改变时间的时候正在开启测量突然10s就停止测量 - self.temp_state = 0 - self.old_temp_time = get_temp_time - - 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.debug_log("AUTO temp:") - EventMesh.txt_log("auto START_temp:1") - EventMesh.publish(constants.EVENT.START_TEMP) - - elif (time_tmp-self.temp_time) >= 30 and self.temp_state == 1: - self.temp_state = 0 - EventMesh.txt_log("auto stop_temp:1") - EventMesh.publish("set_temp_state",0) - temp = EventMesh.publish(constants.EVENT.GET_TEMP) - temp = self.optimize_temp(temp) - - 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(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp]) - EventMesh.publish(constants.EVENT.STOP_TEMP) - - else: - self.temp_state = 0 - self.old_temp_time = 0 - else: - temp_state = EventMesh.publish("get_temp_state") - if temp_state == 2: - EventMesh.publish("set_temp_state",0)#2代表后台进入测试 - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.txt_log("auto wear stop_temp:2 ") - EventMesh.publish(constants.EVENT.STOP_TEMP) - self.temp_state = 0 - self.temp_time = 0 - self.old_temp_time = 0 - - - - hr_time = {} - hr_time = EventMesh.publish("get_time_hr")#获取时间是否大于0 - - if hr_time[0] != None: - self.mearsure_btn = int(hr_time[0]) - self.mearsure_timer = int(hr_time[1]) - - if self.mearsure_btn != None and self.mearsure_timer != None: - - if self.mearsure_btn >= 1 and self.mearsure_timer > 0:#开关打开并且时间大于0就可以测试血糖 - get_hr_state = EventMesh.publish("get_hr_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) - 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) - if (time_tmp - self.SENSOR_time) == 0 and self.HR_Onestate == 0: - self.HR_Onestate = 1 - EventMesh.txt_log("auto START_hr:1") - EventMesh.publish("set_hr_state",2)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_HEART) - - elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_Onestate == 1: - self.HR_Onestate = 0 - EventMesh.publish("set_hr_state",0)#2代表后台进入测试 - EventMesh.debug_log("stop debug3") - EventMesh.txt_log("auto stop_hr:1") - EventMesh.publish(constants.EVENT.STOP_HEART) - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - EventMesh.debug_log("heart_value:{}".format(heart_value)) - # heart_value = 60+urandom.randint(0,10) - if heart_value > 50 and heart_value != None: - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 - #获取心率数据上传数据app - EventMesh.debug_log("STOP_HEART:") - - else: - self.HR_Onestate = 0 - else: - self.SENSOR_time = 0 - self.HR_Onestate = 0 - hr_state = EventMesh.publish("get_hr_state")#心率 - if hr_state == 2: - EventMesh.publish("set_hr_state",0)#2代表后台进入测试 - EventMesh.debug_log("33stop debug3") - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.publish(constants.EVENT.STOP_HEART) - EventMesh.txt_log("auto wear stop_hr:2 ") - - get_spo2time = EventMesh.publish("get_spo2_time")#血压自动测试 - # print("get_spo2time",get_spo2time) - if get_spo2time != None:#血压时间不为0 - spo2_on = int(get_spo2time[0]) - spo2_time = int(get_spo2time[1]) - if spo2_on != 0 and spo2_time != 0: - get_hr_state = EventMesh.publish("get_hr_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 bg2",get_hr_state,get_spo2_state,get_bp_state,get_bg_state) - if (get_hr_state == 0 and get_bp_state == 0 and get_bg_state == 0) and (get_spo2_state == 2 or get_spo2_state == 0):#心率血压血氧不在测试就测试血糖自动测量 - if (time_tmp-self.spo2_timeSecond) >= spo2_time:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 - self.spo2_timeSecond = time_tmp - self.spo2auto_state = 0 - # print("time_tmp spo2",time_tmp,self.spo2_timeSecond,time_tmp-self.spo2_timeSecond,self.bg_timer,self.bpauto_state) - if (time_tmp - self.spo2_timeSecond) == 0 and self.spo2auto_state == 0: - self.spo2auto_state = 1 - EventMesh.debug_log("START_spo2:auto") - EventMesh.txt_log("auto START_spo2:1") - EventMesh.publish("set_spo2_state",2)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 - - elif (time_tmp - self.spo2_timeSecond) >= 60 and self.spo2auto_state == 1: - EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 - self.spo2auto_state = 0 - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - if spo2_value > 85 and spo2_value != None: - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - EventMesh.txt_log("auto stop_spo2:1") - - else: - self.spo2auto_state = 0 - else: - self.spo2_timeSecond = 0 - self.spo2auto_state = 0 - spo2_state = EventMesh.publish("get_spo2_state")#心率 - if spo2_state == 2: - EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 - EventMesh.debug_log("spo2 stop debug3") - EventMesh.txt_log("auto wear stop_spo2:2 ") - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - - - get_bptime = EventMesh.publish("get_bp_time")#血压自动测试 - # print("get_bptime",get_bptime) - if get_bptime != None:#血压时间不为0 - bp_on = int(get_bptime[0]) - bp_time = int(get_bptime[1]) - if bp_on != 0 and bp_time != 0: - get_hr_state = EventMesh.publish("get_hr_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 bg2",get_hr_state,get_spo2_state,get_bp_state,get_bg_state) - - if (get_hr_state == 0 and get_spo2_state == 0 and get_bg_state == 0) and (get_bp_state == 2 or get_bp_state == 0):#心率血压血氧不在测试就测试血糖自动测量 - if (time_tmp-self.bp_timeSecond) >= bp_time:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 - self.bp_timeSecond = time_tmp - self.bpauto_state = 0 - # print("time_tmp bp",time_tmp,self.bp_timeSecond,time_tmp-self.bp_timeSecond,self.bg_timer,self.bpauto_state) - if (time_tmp - self.bp_timeSecond) == 0 and self.bpauto_state == 0: - self.bpauto_state = 1 - EventMesh.debug_log("START_bp:auto") - EventMesh.txt_log("auto START_bp:1") - EventMesh.publish("set_bp_state",2)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_HEART) - - elif (time_tmp - self.bp_timeSecond) >= 60 and self.bpauto_state == 1: - self.bpauto_state = 0 - EventMesh.publish("set_bp_state",0)#2代表后台进入测试 - blood_data = get_autoblood_value() - if blood_data == None: - blood_data[0] = 0 - blood_data[1] = 0 - - max_value = blood_data[0] - min_value = blood_data[1] - if max_value != 0 and min_value != 0: - EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value]) - EventMesh.publish(constants.EVENT.STOP_HEART) - EventMesh.txt_log("auto stop_bp:1") - - else: - self.bpauto_state = 0 - else: - self.bp_timeSecond = 0 - self.bpauto_state = 0 - bp_state = EventMesh.publish("get_bp_state")#心率 - if bp_state == 2: - EventMesh.publish("set_bp_state",0)#2代表后台进入测试 - EventMesh.debug_log("bp stop debug3") - EventMesh.txt_log("auto wear stop_bp:2 ") - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.publish(constants.EVENT.STOP_HEART) - - - - bg_time = {} - bg_time = EventMesh.publish("get_bgauto_time") - if bg_time[0] != None: - - bg_btn = int(bg_time[0]) - bg_timer = int(bg_time[1]) - # print("state bg2",self.bg_btn,self.bg_timer) - if bg_btn >= 1 and bg_timer > 0:#开关打开并且时间大于0就可以测试血糖 - get_hr_state = EventMesh.publish("get_hr_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 bg2",get_hr_state,get_spo2_state,get_bp_state,get_bg_state) - - if (get_hr_state == 0 and get_spo2_state == 0 and get_bp_state == 0) and (get_bg_state == 2 or get_bg_state == 0):#心率血压血氧不在测试就测试血糖自动测量 - if (time_tmp-self.bg_times) >= bg_timer:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 - self.bg_times = time_tmp #1780 - self.BG_state = 0 - # print("time_tmp bg",time_tmp,self.bg_times,time_tmp-self.bg_times,bg_timer,self.BG_state) - if (time_tmp - self.bg_times) == 0 and self.BG_state == 0: - EventMesh.debug_log("START_bg:1") - EventMesh.txt_log("auto START_bg:1") - EventMesh.publish("set_bg_state",2)#2代表后台进入测试 - # 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: - self.BG_state = 0 - EventMesh.publish("set_bg_state",0)#2代表后台进入测试 - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.txt_log("auto stop_bg:1") - EventMesh.debug_log("stop bgdebug3") - EventMesh.publish(constants.EVENT.STOP_HEART) - bgdata = get_blood_sugar_value() - if bgdata == None: - bgdata = 0 - if bgdata != 0: - EventMesh.debug_log("bgdata",bgdata) - EventMesh.publish(constants.PROTOCOL.BLOODGLUSOCE_SEND,bgdata)#上传心率数据 - - else: - - self.BG_state = 0 - else: - bg_state = EventMesh.publish("get_bg_state") - if bg_state == 2: - EventMesh.publish("set_bg_state",0)#2代表后台进入测试 - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.debug_log("bg stop bgdebug3") - EventMesh.txt_log("auto wear stop_bg:2 ") - EventMesh.publish(constants.EVENT.STOP_HEART) - self.bg_times = 0 - self.BG_state = 0 - + self.old_spo2_time = 0 else: - self.old_temp_time = 0 - self.old_time = 0 - # self.SENSOR_time = time_tmp - self.HR_Onestate = 0 - self.HR_OneTime = 0 - self.HR_state = 0 - self.old_time = 0 - self.old_bp_time = 0 - self.old_hr_time = 0 self.old_spo2_time = 0 - self.set_hsenor_crt = 0 - self.old_bg_time = 0 - # self.bg_times = time_tmp - self.BG_state = 0 - # self.temp_time = time_tmp - - # self.bp_timeSecond = time_tmp - self.bpauto_state = 0 - # self.spo2_timeSecond = time_tmp - self.spo2auto_state = 0 - - self.temp_state = 0 - self.temp_one_state = 0 - - else: - self.old_temp_time = 0 - self.old_time = 0 - # self.SENSOR_time = time_tmp - self.HR_Onestate = 0 - self.HR_OneTime = 0 - self.HR_state = 0 - self.old_time = 0 - self.old_bp_time = 0 - self.old_hr_time = 0 - self.old_spo2_time = 0 - self.set_hsenor_crt = 0 - self.old_bg_time = 0 - # self.bg_times = time_tmp - - self.BG_state = 0 - # self.temp_time = time_tmp - - # self.bp_timeSecond = time_tmp - self.bpauto_state = 0 - - # self.spo2_timeSecond = time_tmp - self.spo2auto_state = 0 - - self.temp_state = 0 - self.temp_one_state = 0 - - get_hr_state = EventMesh.publish("get_hr_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") - if get_hr_state != None and get_spo2_state != None and get_bp_state != None and get_bg_state != None: - if get_hr_state > 1: - EventMesh.txt_log("auto stop_hr:44") - EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 - # if get_hr_state == 3: - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.debug_log("stop debug8") - if WEAR == 1: - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - if heart_value > 50 and heart_value != None: - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 - EventMesh.publish(constants.EVENT.STOP_HEART) - elif get_spo2_state > 1: - EventMesh.txt_log("auto stop_spo2:44") - EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 - # if get_spo2_state == 3: - # EventMesh.publish("stop_led_timer")#设置参数 - if WEAR == 1: - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - if spo2_value > 85 and spo2_value != None: - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - EventMesh.debug_log("stop debug13") - elif get_bp_state > 1: - EventMesh.txt_log("auto stop_bp:44") - EventMesh.publish("set_bp_state",0)#2代表后台进入测试 - # if get_bp_state == 3: - # EventMesh.publish("stop_led_timer")#设置参数 - if WEAR == 1: + if get_bp_state != None: + if get_bp_state == 3: + self.old_bp_time+=1 + if self.old_bp_time == 1: + EventMesh.publish("set_bp_state",3)#2代表后台进入测试 + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_HEART) + EventMesh.txt_log("auto start_bp:333") + elif self.old_bp_time > 6: + self.old_bp_time = 0 + + EventMesh.publish("set_bp_state",0)#2代表后台进入测试 + # EventMesh.publish("stop_led_timer")#设置参数 blood_data = get_autoblood_value() if blood_data == None: blood_data[0] = 0 @@ -1965,32 +1530,54 @@ if EventMesh.model == "D15": min_value = blood_data[1] if max_value != 0 and min_value != 0: EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value]) - EventMesh.publish(constants.EVENT.STOP_HEART) - EventMesh.debug_log("stop debug14") - elif get_bg_state > 1: - EventMesh.txt_log("auto stop_bg:44") - EventMesh.publish("set_bg_state",0)#2代表后台进入测试 - # if get_bg_state == 3: - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.publish(constants.EVENT.STOP_HEART) - if WEAR == 1: - bgdata = get_blood_sugar_value() - if bgdata == None: - bgdata = 0 - if bgdata != 0: - EventMesh.publish(constants.PROTOCOL.BLOODGLUSOCE_SEND,bgdata)#上传心率数据 - EventMesh.debug_log("stop debug15") - - if get_temp_time != None: - get_temp_state = EventMesh.publish("get_temp_state") - if get_temp_state > 1: - self.temp_one_state = 0 - self.temp_state = 0 - temp = EventMesh.publish(constants.EVENT.GET_TEMP) - temp = self.optimize_temp(temp) - EventMesh.txt_log("auto stop_temp:44") - EventMesh.publish("set_temp_state",0) - if WEAR == 1: + EventMesh.publish(constants.EVENT.STOP_HEART) + EventMesh.txt_log("auto stop_bp:333") + else: + self.old_bp_time = 0 + else: + self.old_bp_time = 0 + + if get_bg_state != None: + if get_bg_state == 3: + self.old_bg_time+=1 + if self.old_bg_time == 1: + EventMesh.publish("set_bg_state",3)#2代表后台进入测试 + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_HEART) + EventMesh.txt_log("auto start_bg:333") + elif self.old_bg_time > 6: + self.old_bg_time = 0 + EventMesh.publish("set_bg_state",0)#2代表后台进入测试 + EventMesh.publish(constants.EVENT.STOP_HEART) + # EventMesh.publish("stop_led_timer")#设置参数 + bg_data = get_blood_sugar_value() + if bg_data == None: + bg_data = 0 + if bg_data != 0: + EventMesh.publish(constants.PROTOCOL.BLOODGLUSOCE_SEND,bg_data) + + EventMesh.txt_log("auto stop_bp:333") + else: + self.old_bg_time = 0 + else: + self.old_bg_time = 0 + + + if get_temp_state != None: + if get_temp_state == 3:#单次测量 + self.temp_one_state+=1 + if self.temp_one_state == 1: + EventMesh.txt_log("auto start_temp:333") + EventMesh.debug_log("AUTO one temp:2") + EventMesh.publish("set_temp_state",3) + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_TEMP) + elif self.temp_one_state > 3: + self.temp_one_state = 0 + temp = EventMesh.publish(constants.EVENT.GET_TEMP) + temp = self.optimize_temp(temp) + + EventMesh.publish("set_temp_state",0) tmp_f_tmp = 0 tmp_d_tmp = 0 if str(temp).find(".") != -1: @@ -2005,103 +1592,199 @@ if EventMesh.model == "D15": if temp != None: if temp != 0: EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp]) - EventMesh.publish(constants.EVENT.STOP_TEMP) - - - else: - # 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_bp_state = EventMesh.publish("get_bp_state") - get_bg_state = EventMesh.publish("get_bg_state") - get_temp_state = EventMesh.publish("get_temp_state") - if get_hr_state == None: - get_hr_state = 0 - self.old_hr_time = 0 + EventMesh.publish(constants.EVENT.STOP_TEMP) + EventMesh.txt_log("auto start_temp:333") - if get_spo2_state == None: - get_spo2_state = 0 - self.old_spo2_time = 0 - if get_temp_state == None: - get_temp_state = 0 - self.temp_one_state = 0 + + + # EventMesh.debug_log("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state)) + if get_temp_time != None:#定时测量体温 + if get_temp_time > 0: + if get_temp_state != None: + get_temp_state = EventMesh.publish("get_temp_state") + if get_temp_state == 0 or get_temp_state == 2: + if (time_tmp-self.temp_time) >= get_temp_time:#大于一个周期的时间,重新赋值 + self.temp_state = 0 + self.temp_time = time_tmp - if get_bp_state == None: - get_bp_state = 0 - self.old_bp_time = 0 - - if get_bg_state == None: - get_bg_state = 0 - self.old_bg_time = 0 - - # print("bp get_bp_state ",get_bp_state,self.old_bp_time) + if self.old_temp_time != get_temp_time:#重复修改测量间隔时间 + self.temp_time = time_tmp#防止改变时间的时候正在开启测量突然10s就停止测量 + self.temp_state = 0 + self.old_temp_time = get_temp_time - - if get_hr_state != None: - if get_hr_state == 3: - self.old_hr_time+=1 - if self.old_hr_time == 1: - EventMesh.publish("set_hr_state",3)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_HEART) - EventMesh.txt_log("auto start_hr:333") - elif self.old_hr_time > 6: - self.old_hr_time = 0 - EventMesh.publish("set_hr_state",0)#2代表后台进入测试 - EventMesh.txt_log("auto stop_hr:333") - EventMesh.publish(constants.EVENT.STOP_HEART) - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - EventMesh.debug_log("heart_value:{}".format(heart_value)) - if heart_value > 50 and heart_value != None: - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 - EventMesh.debug_log("STOP_HEART:3") - else: - self.old_hr_time = 0 + 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.debug_log("AUTO temp:") + EventMesh.txt_log("auto START_temp:1") + EventMesh.publish(constants.EVENT.START_TEMP) + + elif (time_tmp-self.temp_time) >= 30 and self.temp_state == 1: + self.temp_state = 0 + EventMesh.txt_log("auto stop_temp:1") + EventMesh.publish("set_temp_state",0) + temp = EventMesh.publish(constants.EVENT.GET_TEMP) + temp = self.optimize_temp(temp) + + 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(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp]) + EventMesh.publish(constants.EVENT.STOP_TEMP) + + else: + self.temp_state = 0 + self.old_temp_time = 0 else: - self.old_hr_time = 0 + temp_state = EventMesh.publish("get_temp_state") + if temp_state == 2: + EventMesh.publish("set_temp_state",0)#2代表后台进入测试 + # EventMesh.publish("stop_led_timer")#设置参数 + EventMesh.txt_log("auto wear stop_temp:2 ") + EventMesh.publish(constants.EVENT.STOP_TEMP) + self.temp_state = 0 + self.temp_time = 0 + self.old_temp_time = 0 - if get_spo2_state != None: - if get_spo2_state == 3: - self.old_spo2_time+=1 - if self.old_spo2_time == 1: - EventMesh.publish("set_spo2_state",3)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) + + hr_time = EventMesh.publish("get_time_hr")#获取时间是否大于0 + if hr_time != None: + self.mearsure_btn = int(hr_time[0]) + self.mearsure_timer = int(hr_time[1]) + + if self.mearsure_btn != None and self.mearsure_timer != None: + + if self.mearsure_btn >= 1 and self.mearsure_timer > 0:#开关打开并且时间大于0就可以测试血糖 + get_hr_state = EventMesh.publish("get_hr_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) + 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) + if (time_tmp - self.SENSOR_time) == 0 and self.HR_Onestate == 0: + self.HR_Onestate = 1 + EventMesh.txt_log("auto START_hr:1") + EventMesh.publish("set_hr_state",2)#2代表后台进入测试 + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_HEART) + + elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_Onestate == 1: + self.HR_Onestate = 0 + EventMesh.publish("set_hr_state",0)#2代表后台进入测试 + EventMesh.debug_log("stop debug3") + EventMesh.txt_log("auto stop_hr:1") + EventMesh.publish(constants.EVENT.STOP_HEART) + heart_value = EventMesh.publish(constants.EVENT.GET_HEART) + EventMesh.debug_log("heart_value:{}".format(heart_value)) + # heart_value = 60+urandom.randint(0,10) + if heart_value > 50 and heart_value != None: + EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 + #获取心率数据上传数据app + EventMesh.debug_log("STOP_HEART:") + + else: + self.HR_Onestate = 0 + else: + self.SENSOR_time = 0 + self.HR_Onestate = 0 + hr_state = EventMesh.publish("get_hr_state")#心率 + if hr_state == 2: + EventMesh.publish("set_hr_state",0)#2代表后台进入测试 + EventMesh.debug_log("33stop debug3") + # EventMesh.publish("stop_led_timer")#设置参数 + EventMesh.publish(constants.EVENT.STOP_HEART) + EventMesh.txt_log("auto wear stop_hr:2 ") + + get_spo2time = EventMesh.publish("get_spo2_time")#血压自动测试 + # print("get_spo2time",get_spo2time) + if get_spo2time != None:#血压时间不为0 + spo2_on = int(get_spo2time[0]) + spo2_time = int(get_spo2time[1]) + if spo2_on != 0 and spo2_time != 0: + get_hr_state = EventMesh.publish("get_hr_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 bg2",get_hr_state,get_spo2_state,get_bp_state,get_bg_state) + if (get_hr_state == 0 and get_bp_state == 0 and get_bg_state == 0) and (get_spo2_state == 2 or get_spo2_state == 0):#心率血压血氧不在测试就测试血糖自动测量 + if (time_tmp-self.spo2_timeSecond) >= spo2_time:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 + self.spo2_timeSecond = time_tmp + self.spo2auto_state = 0 + # print("time_tmp spo2",time_tmp,self.spo2_timeSecond,time_tmp-self.spo2_timeSecond,self.bg_timer,self.bpauto_state) + if (time_tmp - self.spo2_timeSecond) == 0 and self.spo2auto_state == 0: + self.spo2auto_state = 1 + EventMesh.debug_log("START_spo2:auto") + EventMesh.txt_log("auto START_spo2:1") + EventMesh.publish("set_spo2_state",2)#2代表后台进入测试 EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 - EventMesh.txt_log("auto start_spo2:333") - elif self.old_spo2_time > 6: - self.old_spo2_time = 0 - EventMesh.txt_log("auto stop_spo2:333") + + elif (time_tmp - self.spo2_timeSecond) >= 60 and self.spo2auto_state == 1: EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 + self.spo2auto_state = 0 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) if spo2_value > 85 and spo2_value != None: EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - + EventMesh.txt_log("auto stop_spo2:1") + else: - self.old_spo2_time = 0 + self.spo2auto_state = 0 else: - self.old_spo2_time = 0 + self.spo2_timeSecond = 0 + self.spo2auto_state = 0 + spo2_state = EventMesh.publish("get_spo2_state")#心率 + if spo2_state == 2: + EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 + EventMesh.debug_log("spo2 stop debug3") + EventMesh.txt_log("auto wear stop_spo2:2 ") + EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - if get_bp_state != None: - if get_bp_state == 3: - self.old_bp_time+=1 - if self.old_bp_time == 1: - EventMesh.publish("set_bp_state",3)#2代表后台进入测试 + get_bptime = EventMesh.publish("get_bp_time")#血压自动测试 + # print("get_bptime",get_bptime) + if get_bptime != None:#血压时间不为0 + bp_on = int(get_bptime[0]) + bp_time = int(get_bptime[1]) + if bp_on != 0 and bp_time != 0: + get_hr_state = EventMesh.publish("get_hr_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 bg2",get_hr_state,get_spo2_state,get_bp_state,get_bg_state) + + if (get_hr_state == 0 and get_spo2_state == 0 and get_bg_state == 0) and (get_bp_state == 2 or get_bp_state == 0):#心率血压血氧不在测试就测试血糖自动测量 + if (time_tmp-self.bp_timeSecond) >= bp_time:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 + self.bp_timeSecond = time_tmp + self.bpauto_state = 0 + # print("time_tmp bp",time_tmp,self.bp_timeSecond,time_tmp-self.bp_timeSecond,self.bg_timer,self.bpauto_state) + if (time_tmp - self.bp_timeSecond) == 0 and self.bpauto_state == 0: + self.bpauto_state = 1 + EventMesh.debug_log("START_bp:auto") + EventMesh.txt_log("auto START_bp:1") + EventMesh.publish("set_bp_state",2)#2代表后台进入测试 # EventMesh.publish("set_hr_blood_led",1) EventMesh.publish(constants.EVENT.START_HEART) - EventMesh.txt_log("auto start_bp:333") - elif self.old_bp_time > 6: - self.old_bp_time = 0 + elif (time_tmp - self.bp_timeSecond) >= 60 and self.bpauto_state == 1: + self.bpauto_state = 0 EventMesh.publish("set_bp_state",0)#2代表后台进入测试 - # EventMesh.publish("stop_led_timer")#设置参数 blood_data = get_autoblood_value() if blood_data == None: blood_data[0] = 0 @@ -2112,368 +1795,79 @@ if EventMesh.model == "D15": if max_value != 0 and min_value != 0: EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value]) EventMesh.publish(constants.EVENT.STOP_HEART) - EventMesh.txt_log("auto stop_bp:333") - else: - self.old_bp_time = 0 - else: - self.old_bp_time = 0 - - if get_bg_state != None: - if get_bg_state == 3: - self.old_bg_time+=1 - if self.old_bg_time == 1: - EventMesh.publish("set_bg_state",3)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_HEART) - EventMesh.txt_log("auto start_bg:333") - elif self.old_bg_time > 6: - self.old_bg_time = 0 - EventMesh.publish("set_bg_state",0)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.STOP_HEART) - # EventMesh.publish("stop_led_timer")#设置参数 - bg_data = get_blood_sugar_value() - if bg_data == None: - bg_data = 0 - if bg_data != 0: - EventMesh.publish(constants.PROTOCOL.BLOODGLUSOCE_SEND,bg_data) - - EventMesh.txt_log("auto stop_bp:333") - else: - self.old_bg_time = 0 - else: - self.old_bg_time = 0 - - - if get_temp_state != None: - if get_temp_state == 3:#单次测量 - self.temp_one_state+=1 - if self.temp_one_state == 1: - EventMesh.txt_log("auto start_temp:333") - EventMesh.debug_log("AUTO one temp:2") - EventMesh.publish("set_temp_state",3) - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_TEMP) - elif self.temp_one_state > 3: - self.temp_one_state = 0 - temp = EventMesh.publish(constants.EVENT.GET_TEMP) - temp = self.optimize_temp(temp) - - EventMesh.publish("set_temp_state",0) - 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(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp]) - EventMesh.publish(constants.EVENT.STOP_TEMP) - EventMesh.txt_log("auto start_temp:333") - - - - - # EventMesh.debug_log("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state)) - if get_temp_time != None:#定时测量体温 - if get_temp_time > 0: - if get_temp_state != None: - get_temp_state = EventMesh.publish("get_temp_state") - if get_temp_state == 0 or get_temp_state == 2: - if (time_tmp-self.temp_time) >= get_temp_time:#大于一个周期的时间,重新赋值 - self.temp_state = 0 - self.temp_time = time_tmp - - if self.old_temp_time != get_temp_time:#重复修改测量间隔时间 - self.temp_time = time_tmp#防止改变时间的时候正在开启测量突然10s就停止测量 - self.temp_state = 0 - self.old_temp_time = get_temp_time - - 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.debug_log("AUTO temp:") - EventMesh.txt_log("auto START_temp:1") - EventMesh.publish(constants.EVENT.START_TEMP) - - elif (time_tmp-self.temp_time) >= 30 and self.temp_state == 1: - self.temp_state = 0 - EventMesh.txt_log("auto stop_temp:1") - EventMesh.publish("set_temp_state",0) - temp = EventMesh.publish(constants.EVENT.GET_TEMP) - temp = self.optimize_temp(temp) - - 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(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp]) - EventMesh.publish(constants.EVENT.STOP_TEMP) - - else: - self.temp_state = 0 - self.old_temp_time = 0 - else: - temp_state = EventMesh.publish("get_temp_state") - if temp_state == 2: - EventMesh.publish("set_temp_state",0)#2代表后台进入测试 - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.txt_log("auto wear stop_temp:2 ") - EventMesh.publish(constants.EVENT.STOP_TEMP) - self.temp_state = 0 - self.temp_time = 0 - self.old_temp_time = 0 - - - - hr_time = {} - hr_time = EventMesh.publish("get_time_hr")#获取时间是否大于0 - - if hr_time[0] != None: - self.mearsure_btn = int(hr_time[0]) - self.mearsure_timer = int(hr_time[1]) - - if self.mearsure_btn != None and self.mearsure_timer != None: - - if self.mearsure_btn >= 1 and self.mearsure_timer > 0:#开关打开并且时间大于0就可以测试血糖 - get_hr_state = EventMesh.publish("get_hr_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) - 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) - if (time_tmp - self.SENSOR_time) == 0 and self.HR_Onestate == 0: - self.HR_Onestate = 1 - EventMesh.txt_log("auto START_hr:1") - EventMesh.publish("set_hr_state",2)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_HEART) - - elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_Onestate == 1: - self.HR_Onestate = 0 - EventMesh.publish("set_hr_state",0)#2代表后台进入测试 - EventMesh.debug_log("stop debug3") - EventMesh.txt_log("auto stop_hr:1") - EventMesh.publish(constants.EVENT.STOP_HEART) - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - EventMesh.debug_log("heart_value:{}".format(heart_value)) - # heart_value = 60+urandom.randint(0,10) - if heart_value > 50 and heart_value != None: - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 - #获取心率数据上传数据app - EventMesh.debug_log("STOP_HEART:") - - else: - self.HR_Onestate = 0 - else: - self.SENSOR_time = 0 - self.HR_Onestate = 0 - hr_state = EventMesh.publish("get_hr_state")#心率 - if hr_state == 2: - EventMesh.publish("set_hr_state",0)#2代表后台进入测试 - EventMesh.debug_log("33stop debug3") - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.publish(constants.EVENT.STOP_HEART) - EventMesh.txt_log("auto wear stop_hr:2 ") - - get_spo2time = EventMesh.publish("get_spo2_time")#血压自动测试 - # print("get_spo2time",get_spo2time) - if get_spo2time != None:#血压时间不为0 - spo2_on = int(get_spo2time[0]) - spo2_time = int(get_spo2time[1]) - if spo2_on != 0 and spo2_time != 0: - get_hr_state = EventMesh.publish("get_hr_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 bg2",get_hr_state,get_spo2_state,get_bp_state,get_bg_state) - if (get_hr_state == 0 and get_bp_state == 0 and get_bg_state == 0) and (get_spo2_state == 2 or get_spo2_state == 0):#心率血压血氧不在测试就测试血糖自动测量 - if (time_tmp-self.spo2_timeSecond) >= spo2_time:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 - self.spo2_timeSecond = time_tmp - self.spo2auto_state = 0 - # print("time_tmp spo2",time_tmp,self.spo2_timeSecond,time_tmp-self.spo2_timeSecond,self.bg_timer,self.bpauto_state) - if (time_tmp - self.spo2_timeSecond) == 0 and self.spo2auto_state == 0: - self.spo2auto_state = 1 - EventMesh.debug_log("START_spo2:auto") - EventMesh.txt_log("auto START_spo2:1") - EventMesh.publish("set_spo2_state",2)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 - - elif (time_tmp - self.spo2_timeSecond) >= 60 and self.spo2auto_state == 1: - EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 - self.spo2auto_state = 0 - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - if spo2_value > 85 and spo2_value != None: - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - EventMesh.txt_log("auto stop_spo2:1") + EventMesh.txt_log("auto stop_bp:1") - else: - self.spo2auto_state = 0 - else: - self.spo2_timeSecond = 0 - self.spo2auto_state = 0 - spo2_state = EventMesh.publish("get_spo2_state")#心率 - if spo2_state == 2: - EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 - EventMesh.debug_log("spo2 stop debug3") - EventMesh.txt_log("auto wear stop_spo2:2 ") - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - - - get_bptime = EventMesh.publish("get_bp_time")#血压自动测试 - # print("get_bptime",get_bptime) - if get_bptime != None:#血压时间不为0 - bp_on = int(get_bptime[0]) - bp_time = int(get_bptime[1]) - if bp_on != 0 and bp_time != 0: - get_hr_state = EventMesh.publish("get_hr_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 bg2",get_hr_state,get_spo2_state,get_bp_state,get_bg_state) - - if (get_hr_state == 0 and get_spo2_state == 0 and get_bg_state == 0) and (get_bp_state == 2 or get_bp_state == 0):#心率血压血氧不在测试就测试血糖自动测量 - if (time_tmp-self.bp_timeSecond) >= bp_time:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 - self.bp_timeSecond = time_tmp - self.bpauto_state = 0 - # print("time_tmp bp",time_tmp,self.bp_timeSecond,time_tmp-self.bp_timeSecond,self.bg_timer,self.bpauto_state) - if (time_tmp - self.bp_timeSecond) == 0 and self.bpauto_state == 0: - self.bpauto_state = 1 - EventMesh.debug_log("START_bp:auto") - EventMesh.txt_log("auto START_bp:1") - EventMesh.publish("set_bp_state",2)#2代表后台进入测试 - # EventMesh.publish("set_hr_blood_led",1) - EventMesh.publish(constants.EVENT.START_HEART) - - elif (time_tmp - self.bp_timeSecond) >= 60 and self.bpauto_state == 1: - self.bpauto_state = 0 - EventMesh.publish("set_bp_state",0)#2代表后台进入测试 - blood_data = get_autoblood_value() - if blood_data == None: - blood_data[0] = 0 - blood_data[1] = 0 - - max_value = blood_data[0] - min_value = blood_data[1] - if max_value != 0 and min_value != 0: - EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value]) - EventMesh.publish(constants.EVENT.STOP_HEART) - EventMesh.txt_log("auto stop_bp:1") - - else: - self.bpauto_state = 0 else: - self.bp_timeSecond = 0 self.bpauto_state = 0 - bp_state = EventMesh.publish("get_bp_state")#心率 - if bp_state == 2: - EventMesh.publish("set_bp_state",0)#2代表后台进入测试 - EventMesh.debug_log("bp stop debug3") - EventMesh.txt_log("auto wear stop_bp:2 ") - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.publish(constants.EVENT.STOP_HEART) + else: + self.bp_timeSecond = 0 + self.bpauto_state = 0 + bp_state = EventMesh.publish("get_bp_state")#心率 + if bp_state == 2: + EventMesh.publish("set_bp_state",0)#2代表后台进入测试 + EventMesh.debug_log("bp stop debug3") + EventMesh.txt_log("auto wear stop_bp:2 ") + # EventMesh.publish("stop_led_timer")#设置参数 + EventMesh.publish(constants.EVENT.STOP_HEART) - bg_time = {} - bg_time = EventMesh.publish("get_bgauto_time") - if bg_time[0] != None: - - bg_btn = int(bg_time[0]) - bg_timer = int(bg_time[1]) - # print("state bg2",self.bg_btn,self.bg_timer) - if bg_btn >= 1 and bg_timer > 0:#开关打开并且时间大于0就可以测试血糖 - get_hr_state = EventMesh.publish("get_hr_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 bg2",get_hr_state,get_spo2_state,get_bp_state,get_bg_state) - - if (get_hr_state == 0 and get_spo2_state == 0 and get_bp_state == 0) and (get_bg_state == 2 or get_bg_state == 0):#心率血压血氧不在测试就测试血糖自动测量 - if (time_tmp-self.bg_times) >= bg_timer:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 - self.bg_times = time_tmp #1780 - self.BG_state = 0 - # print("time_tmp bg",time_tmp,self.bg_times,time_tmp-self.bg_times,bg_timer,self.BG_state) - if (time_tmp - self.bg_times) == 0 and self.BG_state == 0: - EventMesh.debug_log("START_bg:1") - EventMesh.txt_log("auto START_bg:1") - EventMesh.publish("set_bg_state",2)#2代表后台进入测试 - # 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: - self.BG_state = 0 - EventMesh.publish("set_bg_state",0)#2代表后台进入测试 - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.txt_log("auto stop_bg:1") - EventMesh.debug_log("stop bgdebug3") - EventMesh.publish(constants.EVENT.STOP_HEART) - bgdata = get_blood_sugar_value() - if bgdata == None: - bgdata = 0 - if bgdata != 0: - EventMesh.debug_log("bgdata",bgdata) - EventMesh.publish(constants.PROTOCOL.BLOODGLUSOCE_SEND,bgdata)#上传心率数据 - - else: - + bg_time = EventMesh.publish("get_bgauto_time") + if bg_time != None: + + bg_btn = int(bg_time[0]) + bg_timer = int(bg_time[1]) + # print("state bg2",self.bg_btn,self.bg_timer) + if bg_btn >= 1 and bg_timer > 0:#开关打开并且时间大于0就可以测试血糖 + get_hr_state = EventMesh.publish("get_hr_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 bg2",get_hr_state,get_spo2_state,get_bp_state,get_bg_state) + + if (get_hr_state == 0 and get_spo2_state == 0 and get_bp_state == 0) and (get_bg_state == 2 or get_bg_state == 0):#心率血压血氧不在测试就测试血糖自动测量 + if (time_tmp-self.bg_times) >= bg_timer:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 + self.bg_times = time_tmp #1780 + self.BG_state = 0 + # print("time_tmp bg",time_tmp,self.bg_times,time_tmp-self.bg_times,bg_timer,self.BG_state) + if (time_tmp - self.bg_times) == 0 and self.BG_state == 0: + EventMesh.debug_log("START_bg:1") + EventMesh.txt_log("auto START_bg:1") + EventMesh.publish("set_bg_state",2)#2代表后台进入测试 + # 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: self.BG_state = 0 - else: - bg_state = EventMesh.publish("get_bg_state") - if bg_state == 2: EventMesh.publish("set_bg_state",0)#2代表后台进入测试 # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.debug_log("bg stop bgdebug3") - EventMesh.txt_log("auto wear stop_bg:2 ") + EventMesh.txt_log("auto stop_bg:1") + EventMesh.debug_log("stop bgdebug3") EventMesh.publish(constants.EVENT.STOP_HEART) - self.bg_times = 0 + bgdata = get_blood_sugar_value() + if bgdata == None: + bgdata = 0 + if bgdata != 0: + EventMesh.debug_log("bgdata",bgdata) + EventMesh.publish(constants.PROTOCOL.BLOODGLUSOCE_SEND,bgdata)#上传心率数据 + + else: + self.BG_state = 0 - - else: - self.old_temp_time = 0 - self.old_time = 0 - # self.SENSOR_time = time_tmp - self.HR_Onestate = 0 - self.HR_OneTime = 0 - self.HR_state = 0 - self.old_time = 0 - self.old_bp_time = 0 - self.old_hr_time = 0 - self.old_spo2_time = 0 - self.set_hsenor_crt = 0 - self.old_bg_time = 0 - # self.bg_times = time_tmp - self.BG_state = 0 - # self.temp_time = time_tmp + else: + bg_state = EventMesh.publish("get_bg_state") + if bg_state == 2: + EventMesh.publish("set_bg_state",0)#2代表后台进入测试 + # EventMesh.publish("stop_led_timer")#设置参数 + EventMesh.debug_log("bg stop bgdebug3") + EventMesh.txt_log("auto wear stop_bg:2 ") + EventMesh.publish(constants.EVENT.STOP_HEART) + self.bg_times = 0 + self.BG_state = 0 + - # self.bp_timeSecond = time_tmp - self.bpauto_state = 0 - # self.spo2_timeSecond = time_tmp - self.spo2auto_state = 0 - self.temp_state = 0 - self.temp_one_state = 0 else: self.old_temp_time = 0 @@ -2489,7 +1883,6 @@ if EventMesh.model == "D15": self.set_hsenor_crt = 0 self.old_bg_time = 0 # self.bg_times = time_tmp - self.BG_state = 0 # self.temp_time = time_tmp @@ -2502,91 +1895,116 @@ if EventMesh.model == "D15": self.temp_state = 0 self.temp_one_state = 0 - get_hr_state = EventMesh.publish("get_hr_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") - if get_hr_state != None and get_spo2_state != None and get_bp_state != None and get_bg_state != None: - if get_hr_state > 1: - EventMesh.txt_log("auto stop_hr:44") - EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 - # if get_hr_state == 3: - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.debug_log("stop debug8") - if WEAR == 1: - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - if heart_value > 50 and heart_value != None: - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 - EventMesh.publish(constants.EVENT.STOP_HEART) - elif get_spo2_state > 1: - EventMesh.txt_log("auto stop_spo2:44") - EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 - # if get_spo2_state == 3: - # EventMesh.publish("stop_led_timer")#设置参数 - if WEAR == 1: - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - if spo2_value > 85 and spo2_value != None: - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - EventMesh.debug_log("stop debug13") - elif get_bp_state > 1: - EventMesh.txt_log("auto stop_bp:44") - EventMesh.publish("set_bp_state",0)#2代表后台进入测试 - # if get_bp_state == 3: - # EventMesh.publish("stop_led_timer")#设置参数 - if WEAR == 1: - blood_data = get_autoblood_value() - if blood_data == None: - blood_data[0] = 0 - blood_data[1] = 0 - max_value = blood_data[0] - min_value = blood_data[1] - if max_value != 0 and min_value != 0: - EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value]) - EventMesh.publish(constants.EVENT.STOP_HEART) - EventMesh.debug_log("stop debug14") - elif get_bg_state > 1: - EventMesh.txt_log("auto stop_bg:44") - EventMesh.publish("set_bg_state",0)#2代表后台进入测试 - # if get_bg_state == 3: - # EventMesh.publish("stop_led_timer")#设置参数 - EventMesh.publish(constants.EVENT.STOP_HEART) - if WEAR == 1: - bgdata = get_blood_sugar_value() - if bgdata == None: - bgdata = 0 - if bgdata != 0: - EventMesh.publish(constants.PROTOCOL.BLOODGLUSOCE_SEND,bgdata)#上传心率数据 - EventMesh.debug_log("stop debug15") - - if get_temp_time != None: - get_temp_state = EventMesh.publish("get_temp_state") - if get_temp_state > 1: - self.temp_one_state = 0 - self.temp_state = 0 - temp = EventMesh.publish(constants.EVENT.GET_TEMP) - temp = self.optimize_temp(temp) - EventMesh.txt_log("auto stop_temp:44") - EventMesh.publish("set_temp_state",0) - if WEAR == 1: - 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(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp]) - EventMesh.publish(constants.EVENT.STOP_TEMP) - - + else: + self.old_temp_time = 0 + self.old_time = 0 + # self.SENSOR_time = time_tmp + self.HR_Onestate = 0 + self.HR_OneTime = 0 + self.HR_state = 0 + self.old_time = 0 + self.old_bp_time = 0 + self.old_hr_time = 0 + self.old_spo2_time = 0 + self.set_hsenor_crt = 0 + self.old_bg_time = 0 + # self.bg_times = time_tmp + + self.BG_state = 0 + # self.temp_time = time_tmp + + # self.bp_timeSecond = time_tmp + self.bpauto_state = 0 + + # self.spo2_timeSecond = time_tmp + self.spo2auto_state = 0 + + self.temp_state = 0 + self.temp_one_state = 0 + + get_hr_state = EventMesh.publish("get_hr_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") + if get_hr_state != None and get_spo2_state != None and get_bp_state != None and get_bg_state != None: + if get_hr_state > 1: + EventMesh.txt_log("auto stop_hr:44") + EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 + # if get_hr_state == 3: + # EventMesh.publish("stop_led_timer")#设置参数 + EventMesh.debug_log("stop debug8") + if WEAR == 1: + heart_value = EventMesh.publish(constants.EVENT.GET_HEART) + if heart_value > 50 and heart_value != None: + EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 + EventMesh.publish(constants.EVENT.STOP_HEART) + elif get_spo2_state > 1: + EventMesh.txt_log("auto stop_spo2:44") + EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 + # if get_spo2_state == 3: + # EventMesh.publish("stop_led_timer")#设置参数 + if WEAR == 1: + spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) + if spo2_value > 85 and spo2_value != None: + EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) + EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) + EventMesh.debug_log("stop debug13") + elif get_bp_state > 1: + EventMesh.txt_log("auto stop_bp:44") + EventMesh.publish("set_bp_state",0)#2代表后台进入测试 + # if get_bp_state == 3: + # EventMesh.publish("stop_led_timer")#设置参数 + if WEAR == 1: + blood_data = get_autoblood_value() + if blood_data == None: + blood_data[0] = 0 + blood_data[1] = 0 + + max_value = blood_data[0] + min_value = blood_data[1] + if max_value != 0 and min_value != 0: + EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value]) + EventMesh.publish(constants.EVENT.STOP_HEART) + EventMesh.debug_log("stop debug14") + elif get_bg_state > 1: + EventMesh.txt_log("auto stop_bg:44") + EventMesh.publish("set_bg_state",0)#2代表后台进入测试 + # if get_bg_state == 3: + # EventMesh.publish("stop_led_timer")#设置参数 + EventMesh.publish(constants.EVENT.STOP_HEART) + if WEAR == 1: + bgdata = get_blood_sugar_value() + if bgdata == None: + bgdata = 0 + if bgdata != 0: + EventMesh.publish(constants.PROTOCOL.BLOODGLUSOCE_SEND,bgdata)#上传心率数据 + EventMesh.debug_log("stop debug15") + get_temp_state = EventMesh.publish("get_temp_state") + if get_temp_state != None: + if get_temp_state > 1: + self.temp_one_state = 0 + self.temp_state = 0 + temp = EventMesh.publish(constants.EVENT.GET_TEMP) + temp = self.optimize_temp(temp) + EventMesh.txt_log("auto stop_temp:44") + EventMesh.publish("set_temp_state",0) + if WEAR == 1: + 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(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp]) + EventMesh.publish(constants.EVENT.STOP_TEMP) hr_state = EventMesh.publish("get_hr_state") @@ -5853,7 +5271,7 @@ if EventMesh.model == "D15": jrtc.open(uid,ticket,[],[15,120,240,320]) EventMesh.publish(constants.EVENT.SYSTEM_UP)#唤醒休眠 - jrtc.set_rotate(jrtc.CAM_ROTATE_90) + jrtc.set_rotate(jrtc.CAM_ROTATE_0) self.video_count = 0 self.video_state_time = 0 diff --git a/2.sdk/project/K01/sdk/services/microPython/ports/quectel/core/versions.py b/2.sdk/project/K01/sdk/services/microPython/ports/quectel/core/versions.py index 65fab6f5..e3e83797 100644 --- a/2.sdk/project/K01/sdk/services/microPython/ports/quectel/core/versions.py +++ b/2.sdk/project/K01/sdk/services/microPython/ports/quectel/core/versions.py @@ -1,2 +1,2 @@ Version="V1.0" -Build_Time="2023-12-25 14:29:09" +Build_Time="2024-01-17 19:25:24" diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py index 1f61ed09..60b8602d 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py @@ -1136,8 +1136,10 @@ class DeviceInfoManager(Abstract): get_temp_state = EventMesh.publish("get_temp_state") if get_temp_state == None : get_temp_state = 0 - hr_time = {} + hr_time = [] hr_time = EventMesh.publish("get_time_hr_spo2")#获取时间是否大于0 + if hr_time == None: + hr_time = [0,0] if get_temp_state != None : #突然脱腕 if get_temp_state > 1 and WEAR != 1: EventMesh.publish(constants.EVENT.STOP_TEMP) diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/sleep_test.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/sleep_test.py index 609a9e36..2651a731 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/sleep_test.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/sleep_test.py @@ -87,7 +87,7 @@ params = { import audio from machine import Pin record_test = audio.Record() -record_test.gain(4,12) +record_test.gain_set(4,12) aud = audio.Audio(0) aud.set_pa(Pin.GPIO29) aud.setVolume(11) diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py index b4eeb35a..3e8418fe 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py @@ -2590,8 +2590,11 @@ class HeartrateScreen(Screen): EventMesh.publish(constants.EVENT.START_HEART) - def show_history_hr_data(self): + def show_history_hr_data(self,event,msg): global hr_line1,hr_line2,hr_line3,hr_line4,hr_line5,hr_line6,hr_line7 + if heartrate_screen == None: + return + read_data = {} read_data = EventMesh.publish("get_history_hr_value") if len(read_data) != 0: @@ -4306,8 +4309,10 @@ class TemperatureScreen(Screen): self.temp_data_old = 0 self.timer.start(1*500, 1, self.start_measure) - def show_history_temp_data(self): - global temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,temp_line6,temp_line7 + def show_history_temp_data(self,event,msg): + global temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,temp_line6,temp_line7,temperature_screen + if temperature_screen == None: + return read_data = {} read_data = EventMesh.publish("get_history_temp_value") # print("hr get_history_temp_value",read_data) @@ -4666,8 +4671,10 @@ class Spo2Screen(Screen): EventMesh.publish("set_spo2_state",1)#2代表后台进入血氧测试 EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN) - def show_history_spo2_data(self): + def show_history_spo2_data(self,event,msg): global spo2_line1,spo2_line2,spo2_line3,spo2_line4,spo2_line5,spo2_line6,spo2_line7 + if spo2_screen == None: + return read_data = {} read_data = EventMesh.publish("get_history_spo2_value") # print("hr get_history_spo2_value",read_data) diff --git a/2.sdk/project/K5_DDY/ext/static/NO_NETWORK.png b/2.sdk/project/K5_DDY/ext/static/NO_NETWORK.png new file mode 100644 index 00000000..72dbf680 Binary files /dev/null and b/2.sdk/project/K5_DDY/ext/static/NO_NETWORK.png differ diff --git a/2.sdk/project/K5_DDY/ext/static/NO_SIM.png b/2.sdk/project/K5_DDY/ext/static/NO_SIM.png new file mode 100644 index 00000000..82489ccf Binary files /dev/null and b/2.sdk/project/K5_DDY/ext/static/NO_SIM.png differ diff --git a/2.sdk/project/K5_DDY/images/ext_fs.bin b/2.sdk/project/K5_DDY/images/ext_fs.bin index 074c7235..51fbd0b7 100644 Binary files a/2.sdk/project/K5_DDY/images/ext_fs.bin and b/2.sdk/project/K5_DDY/images/ext_fs.bin differ diff --git a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/EventMesh.py b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/EventMesh.py index e7745149..26deaea1 100644 --- a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/EventMesh.py +++ b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/EventMesh.py @@ -87,6 +87,10 @@ def add_filter(flt): event_store.add_filter(flt) import utime import uos +debug_Log = 1 +def debug_log(*data): + if debug_Log != 0 : + print(data) Txt_Log = 1 def txt_log(data): if Txt_Log != 0 : diff --git a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/alarm.py b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/alarm.py index 92f1679f..bbe5a77f 100644 --- a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/alarm.py +++ b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/alarm.py @@ -654,10 +654,10 @@ class ClockManager(Abstract): - get_hr_state = EventMesh.publish("get_hr_state") - get_spo2_state = EventMesh.publish("get_spo2_state") - if get_hr_state != None or get_spo2_state != None: - if get_hr_state != 1 and get_spo2_state != 1: + hr_state = EventMesh.publish("get_hr_state") + spo2_state = EventMesh.publish("get_spo2_state") + if hr_state != None or spo2_state != None: + if hr_state != 1 and spo2_state != 1: EventMesh.publish("load_screen", {"screen": "popup_alarm"}) # def _reset_rtc_alarm_time(self, args): # print("---alarm_ring---") diff --git a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py index d560f238..098ae427 100644 --- a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py +++ b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py @@ -93,10 +93,9 @@ class BtnDevice(Abstract): if self.key22_press == 1 : self.key22_count += 1 - if self.key22_count >= 2500//100: + if self.key22_count >= 3000//100: if self.GPIO22_flag == 0: self.GPIO22_flag = 1 - EventMesh.publish("btn8_long_press") return if self.GPIO22_status == 1:#松开 diff --git a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/constants.py b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/constants.py index 78430dd9..13d85933 100644 --- a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/constants.py +++ b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/constants.py @@ -117,6 +117,13 @@ class PROTOCOL: AL_SOS_SEND ="AL_SOS_SEND" AL_SOS_RECV ="AL_SOS_RECV" + + BLOOD_SEND = "blood_SEND" + BLOOD_RECV = "blood_RECV" + + BLDSTART_SEND ="bldstart_SEND" + BLDSTART_RECV = "bldstart_RECV" + class EVENT: CHANNEL_SOCKET_SEND = "CHANNEL_SOCKET_SEND" START_LOCATION = "START_LOCATION" diff --git a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/main_init.py b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/main_init.py index 87e27be7..cdfe74b7 100644 --- a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/main_init.py +++ b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/main_init.py @@ -253,6 +253,7 @@ def main_init(): app.append_manager(gethistoryDataManager()) app.append_manager(getHrTimeManager()) app.append_manager(getBrightnessManager()) + app.append_manager(mgr.firwDownloadManager()) except Exception as e: usys.print_exception(e) try: @@ -319,6 +320,8 @@ def main_init(): pcr.add_support(protocol.REMOVE_ProtoCol()) pcr.add_support(protocol.GSMANT_ProtoCol()) pcr.add_support(protocol.AL_SOS_ProtoCol()) + pcr.add_support(protocol.blood_ProtoCol()) + pcr.add_support(protocol.bldstart_ProtoCol()) except Exception as e: usys.print_exception(e) try: diff --git a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/mgr.py b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/mgr.py index 1eddec25..c067f5bc 100644 --- a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/mgr.py +++ b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/mgr.py @@ -41,6 +41,52 @@ import math import voiceCall from misc import PWM from queue import Queue +def get_autoblood_value():#血压值 + data = RTC().datetime() + hour = int(data[4]) + blood_Maxvalue = 0 + blood_Minvalue = 0 + if hour >= 6 and hour <= 10: + random_numMax = urandom.randint(0, 30) + random_numMin = urandom.randint(0, 20) + blood_Maxvalue = 120+random_numMax + blood_Minvalue = 75+random_numMin + + print("get_autoblood_value 6 -10",blood_Maxvalue,blood_Minvalue) + # return [self.blood_Maxvalue,self.blood_Minvalue] + elif hour > 10 and hour <= 14:#10-14(10,14] + random_numMax = urandom.randint(0, 20) + random_numMin = urandom.randint(0, 25) + blood_Maxvalue = 115+random_numMax + blood_Minvalue = 60+random_numMin + print("get_autoblood_value 10 -14",blood_Maxvalue,blood_Minvalue) + # return [self.blood_Maxvalue,self.blood_Minvalue] + elif hour > 14 and hour <= 18:#14-18 + random_numMax = urandom.randint(0, 25) + random_numMin = urandom.randint(0, 15) + blood_Maxvalue = 115+random_numMax + blood_Minvalue = 70+random_numMin + + print("get_autoblood_value 14 -18",blood_Maxvalue,blood_Minvalue) + # return [self.blood_Maxvalue,self.blood_Minvalue] + elif hour > 2 and hour < 6:#2-6 + random_numMax = urandom.randint(0, 30) + random_numMin = urandom.randint(0, 20) + blood_Maxvalu = 105+random_numMax + blood_Minvalue = 65+random_numMin + + + print("get_autoblood_value 2 -6",blood_Maxvalue,blood_Minvalue) + # return [self.blood_Maxvalue,self.blood_Minvalue] + else:#18-2 19 20 21 22 23 1 2 + random_numMax = urandom.randint(0, 30) + random_numMin = urandom.randint(0, 20) + blood_Maxvalue = 100+random_numMax + blood_Minvalue = 60+random_numMin + print("get_autoblood_value 18 -2",blood_Maxvalue,blood_Minvalue) + return [blood_Maxvalue,blood_Minvalue] + + class PhoneVolumeLevelManager(Abstract): def __init__(self): self.level = 0 @@ -784,6 +830,27 @@ class DeviceInfoManager(Abstract): print("DeviceInfoManager:3") self.i2c0 = I2C(I2C.I2C0, I2C.FAST_MODE) self.stop_temp( None, None) + self.pull_time = 0 + + self.time_count = 0 + + self.auto_spo2_count = 0 + + self.auto_hr_count = 0 + + self.auto_temp_count = 0 + + self.old_temp_time = 0 + + self.old_hr_time = 0 + self.old_spo2_time = 0 + + self.spo2_timeSecond = 0 + self.spo2auto_state = 0 + + self.bpauto_state = 0 + self.bp_timeSecond = 0 + self.old_bp_time = 0 def post_processor_after_instantiation(self): print("post_processor_after_instantiation:1") @@ -836,6 +903,8 @@ class DeviceInfoManager(Abstract): EventMesh.subscribe("optimize_temp",self.optimize_temp) + EventMesh.subscribe("clear_health_state", self.clear_health_state) + print("post_processor_after_instantiation:2") self.timer_push_schedule.start(10000, 1, self.publish_event_cb) # self.timer_pusht_test.start(2000, 1, self.publish_test) @@ -911,6 +980,29 @@ class DeviceInfoManager(Abstract): temp = 40 return temp + def clear_health_state(self,event,msg): + print("clear_health_state") + #关闭心率 血压 血氧 体温清除标志 + self.old_time = 0 + self.HR_Onestate = 0 + self.HR_OneTime = 0 + self.HR_state = 0 + self.set_hsenor_crt = 0 + self.old_hr_time = 0 + self.old_spo2_time = 0 + self.spo2auto_state = 0 + self.bpauto_state = 0 + self.old_bp_time = 0 + pass + + def clear_temp_state(self,event,msg): + print("clear_temp_state") + self.temp_state = 0 + self.temp_one_state = 0 + self.old_temp_time = 0 + pass + + def publish_event(self,data): """ 定时事件处理 @@ -1128,151 +1220,163 @@ class DeviceInfoManager(Abstract): #EventMesh.publish(constants.PROTOCOL.HELP_SEND,65) self.wear = WEAR - self.get_hr_state = EventMesh.publish("get_hr_state") - if self.get_hr_state == None : - self.get_hr_state = 0 - self.get_spo2_state = EventMesh.publish("get_spo2_state") - if self.get_spo2_state == None : - self.get_spo2_state = 0 + hr_state = EventMesh.publish("get_hr_state") + if hr_state == None : + hr_state = 0 + spo2_state = EventMesh.publish("get_spo2_state") + if spo2_state == None : + spo2_state = 0 + bp_state = EventMesh.publish("get_bp_state") + if bp_state == None: + bp_state = 0 + get_temp_time = EventMesh.publish("get_temp_time") - get_temp_state = EventMesh.publish("get_temp_state") - if get_temp_state == None : - get_temp_state = 0 - hr_time = {} - hr_time = EventMesh.publish("get_time_hr_spo2")#获取时间是否大于0 - if get_temp_state != None : #突然脱腕 - if get_temp_state > 1 and WEAR != 1: + temp_state = EventMesh.publish("get_temp_state") + if temp_state == None : + temp_state = 0 + + if temp_state != None : #突然脱腕 + if temp_state > 1 and WEAR != 1: + print("TMEP WEAR !!!!") EventMesh.publish(constants.EVENT.STOP_TEMP) EventMesh.publish("set_temp_state",0) - if (self.get_hr_state > 1 or self.get_spo2_state > 1) and WEAR != 1: - if self.get_hr_state > 1 : + if (hr_state > 1 or spo2_state > 1 or bp_state > 1) and WEAR != 1: + print("SENSOR WEAR !!!!") + if hr_state > 1 : EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 EventMesh.publish(constants.EVENT.STOP_HEART) - elif self.get_spo2_state > 1: + if spo2_state > 1: EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - # print("hr......01....{} {}\r\n".format(hr_time,get_temp_time)) + if bp_state > 1: + EventMesh.txt_log("auto stop_bp:22") + EventMesh.publish("set_bp_state",0)#2代表后台进入测试 + EventMesh.publish(constants.EVENT.STOP_HEART) + if self.pull_time == 0: + self.pull_time = time_tmp + # EventMesh.txt_log("time_tmp - self.pull_time!!!!{}".format(time_tmp - self.pull_time)) if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "1" and WEAR == 1: + if time_tmp - self.pull_time >= 60: - # print("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state)) - if get_temp_time != None:#定时测量体温 - if get_temp_time > 0: - if get_temp_state != None: - if get_temp_state == 0 or get_temp_state == 2 or get_temp_state == 3 : - if (time_tmp-self.temp_time) >= get_temp_time:#大于一个周期的时间,重新赋值 - self.temp_one_state = 0 - self.temp_state = 0 - self.temp_time = time_tmp + hr_state = EventMesh.publish("get_hr_state") + spo2_state = EventMesh.publish("get_spo2_state") + temp_state = EventMesh.publish("get_temp_state") + bp_state = EventMesh.publish("get_bp_state") - if self.old_temp_time != get_temp_time:#重复修改测量间隔时间 - self.temp_one_state = 0 - self.temp_time = time_tmp#防止改变时间的时候正在开启测量突然10s就停止测量 - self.temp_state = 0 - self.old_temp_time = get_temp_time + if hr_state == None: + hr_state = 0 + self.old_hr_time = 0 - if (time_tmp-self.temp_time) == 0 and self.temp_state == 0:#一开始就测量 测量一分钟停止测量体温 - self.temp_state = 1 - self.temp_one_state = 0 - EventMesh.publish("set_temp_state",2) - print("AUTO temp:") - EventMesh.publish(constants.EVENT.START_TEMP) + if spo2_state == None: + spo2_state = 0 + self.old_spo2_time = 0 - elif (time_tmp-self.temp_time) >= 60 and self.temp_state == 1: - self.temp_state = 0 - self.temp_one_state = 0 - # temp = EventMesh.publish(constants.EVENT.GET_TEMP) - # temp += 0.5 - # if temp < 25 or temp > 42: - # temp = 0 - temp = EventMesh.publish("optimize_temp") - if temp == None: - temp = 0 - 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 bp_state == None: + bp_state = 0 + self.old_bp_time = 0 - 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) + if temp_state == None: + temp_state = 0 + self.temp_one_state = 0 + + + if hr_state != None: + if hr_state == 3: + self.old_hr_time+=1 + if self.old_hr_time == 1: + EventMesh.publish("set_hr_state",3)#2代表后台进入测试 + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_HEART) + EventMesh.txt_log("auto start_hr:333") + elif self.old_hr_time > 6: + self.old_hr_time = 0 + EventMesh.publish("set_hr_state",0)#2代表后台进入测试 + EventMesh.txt_log("auto stop_hr:333") + EventMesh.publish(constants.EVENT.STOP_HEART) + heart_value = EventMesh.publish(constants.EVENT.GET_HEART) + EventMesh.debug_log("heart_value:{}".format(heart_value)) + if heart_value > 50 and heart_value != None: + EventMesh.publish("set_old_hr_data",heart_value) + EventMesh.publish("set_history_hr_value",heart_value) + EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 + EventMesh.debug_log("STOP_HEART:3") + else: + self.old_hr_time = 0 + else: + self.old_hr_time = 0 + + + if spo2_state != None: + if spo2_state == 3: + self.old_spo2_time+=1 + if self.old_spo2_time == 1: + EventMesh.publish("set_spo2_state",3)#2代表后台进入测试 + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 + EventMesh.txt_log("auto start_spo2:333") + elif self.old_spo2_time > 6: + self.old_spo2_time = 0 + EventMesh.txt_log("auto stop_spo2:333") + EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 + EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) + spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) + if spo2_value > 85 and spo2_value != None: + EventMesh.publish("set_old_spo2_data",spo2_value) + EventMesh.publish("set_history_spo2_value",spo2_value) + EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) + else: + self.old_spo2_time = 0 + else: + self.old_spo2_time = 0 + + if bp_state != None: + if bp_state == 3: + self.old_bp_time+=1 + if self.old_bp_time == 1: + EventMesh.publish("set_bp_state",3)#2代表后台进入测试 + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_HEART) + EventMesh.txt_log("auto start_bp:333") + elif self.old_bp_time > 6: + self.old_bp_time = 0 + + EventMesh.publish("set_bp_state",0)#2代表后台进入测试 + # EventMesh.publish("stop_led_timer")#设置参数 + blood_data = get_autoblood_value() + if blood_data == None: + blood_data[0] = 0 + blood_data[1] = 0 + + max_value = blood_data[0] + min_value = blood_data[1] + if max_value != 0 and min_value != 0: + EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value]) + EventMesh.publish(constants.EVENT.STOP_HEART) + EventMesh.txt_log("auto stop_bp:333") + else: + self.old_bp_time = 0 + else: + self.old_bp_time = 0 - if self.temp_state == 0 or get_temp_state == 3:#只有不在测量的时候才测单次的 - if get_temp_state == 3:#单次测量 - self.temp_one_state+=1 - if self.temp_one_state == 1: - EventMesh.publish("set_temp_state",3) - print("AUTO one temp:1") - EventMesh.publish(constants.EVENT.START_TEMP) - elif self.temp_one_state > 6: - self.temp_one_state = 0 - # temp = EventMesh.publish(constants.EVENT.GET_TEMP) - # temp += 0.5 - # if temp < 25 or temp > 42: - # temp = 0 - temp = EventMesh.publish("optimize_temp") - if temp == None: - temp = 0 - 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("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) - else: - self.temp_one_state = 0 - self.temp_state = 0 - self.old_temp_time = 0 - else: - self.old_temp_time = 0 - get_temp_end_state = EventMesh.publish("get_temp_state") - if self.temp_state != 0: - if self.temp_state == 2: - self.temp_state = 0 - EventMesh.publish(constants.EVENT.STOP_TEMP) - if get_temp_end_state == 1: - self.temp_one_state = 0 - if get_temp_end_state == 3:#单次测量 + if temp_state != None: + if temp_state == 3:#单次测量 self.temp_one_state+=1 if self.temp_one_state == 1: - print("AUTO one temp:2") + EventMesh.txt_log("auto start_temp:333") + EventMesh.debug_log("AUTO one temp:2") EventMesh.publish("set_temp_state",3) + # EventMesh.publish("set_hr_blood_led",1) EventMesh.publish(constants.EVENT.START_TEMP) - elif self.temp_one_state > 6: + elif self.temp_one_state > 3: self.temp_one_state = 0 - # temp = EventMesh.publish(constants.EVENT.GET_TEMP) - # temp += 0.5 - # if temp < 25 or temp > 42: - # temp = 0 temp = EventMesh.publish("optimize_temp") if temp == None: temp = 0 + + EventMesh.publish("set_temp_state",0) tmp_f_tmp = 0 tmp_d_tmp = 0 if str(temp).find(".") != -1: @@ -1283,339 +1387,313 @@ class DeviceInfoManager(Abstract): 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) - - self.mearsure_btn = int(hr_time[0]) - self.mearsure_timer = int(hr_time[1]) - if self.mearsure_btn != None and self.mearsure_timer != None: - print("hr......01....{} {}\r\n".format(hr_time[0],hr_time[1])) - if self.mearsure_btn > 0: - if self.mearsure_timer > 0: - #print("get_hr_state:{} get_spo2_state:{} self.old_time:{} mearsure_timer:{}".format(self.get_hr_state,self.get_spo2_state,self.old_time,mearsure_timer)) - if self.get_hr_state != 1 and self.get_spo2_state != 1: - if self.get_hr_state == 0 and self.get_spo2_state == 0: - if self.HR_state == 0 or self.HR_state == 3: - self.HR_Onestate = 0 - self.HR_OneTime = 0 - - if self.old_time != self.mearsure_timer:#重复修改测量间隔时间 - self.SENSOR_time = time_tmp#防止改变时间的时候正在开启测量突然10s就停止测量 - if self.get_hr_state == 2 and self.HR_state == 1:#自动检测的心率还在测量立马关了测试 - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - if heart_value > 50 and heart_value != None: - EventMesh.publish("set_old_hr_data",heart_value) - EventMesh.publish("set_history_hr_value",heart_value) - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value) - print("stop debug1") - EventMesh.publish(constants.EVENT.STOP_HEART) - self.HR_state = 0 - elif self.get_spo2_state == 2 and self.HR_state == 2: - self.HR_state = 0 - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - if spo2_value > 85 and spo2_value != None: - EventMesh.publish("set_old_spo2_data",spo2_value) - EventMesh.publish("set_history_spo2_value",spo2_value) - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - self.old_time = self.mearsure_timer - - if self.HR_state == 3 or self.HR_state == 0:# - if (time_tmp - self.SENSOR_time) >= self.mearsure_timer: - if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量没有完毕优先测量间隔时间测量的 - if self.get_hr_state == 3: - print("stop debug2") - EventMesh.publish(constants.EVENT.STOP_HEART) - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - if heart_value > 50 and heart_value != None: - EventMesh.publish("set_old_hr_data",heart_value) - EventMesh.publish("set_history_hr_value",heart_value) - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value) - - elif self.get_spo2_state == 3: - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - if spo2_value > 85 and spo2_value != None: - EventMesh.publish("set_history_spo2_value",spo2_value) - EventMesh.publish("set_old_spo2_data",spo2_value) - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - - self.HR_state = 0 - self.SENSOR_time = time_tmp - self.SENSOR_time = time_tmp - self.HR_state = 0 - - #print("time_tmp :{} self.SENSOR_time :{} time_tmp - self.SENSOR_time:{} self.HR_state:{}".format(time_tmp,self.SENSOR_time,time_tmp - self.SENSOR_time,self.HR_state)) - if (time_tmp - self.SENSOR_time) == 0 and self.HR_state == 0: - print("START_HEART:1") - EventMesh.publish("set_hr_state",2)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.START_HEART) - self.HR_state = 1 - self.HR_Onestate = 0 - self.HR_OneTime = 0 - elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_state == 1: - EventMesh.publish("set_hr_state",0)#2代表后台进入测试 - print("stop debug3") - EventMesh.publish(constants.EVENT.STOP_HEART) - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - print("heart_value:{}".format(heart_value)) - if heart_value > 50 and heart_value != None: - EventMesh.publish("set_old_hr_data",heart_value) - EventMesh.publish("set_history_hr_value",heart_value) - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 - #获取心率数据上传数据app - print("STOP_HEART:") - - self.HR_state = 3 - # EventMesh.publish("set_spo2_state",2)#2代表后台进入血氧测试 - # EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 - # print("START_BLOOD_OXYGEN:") - # elif (time_tmp - self.SENSOR_time) >= 120 and self.HR_state == 2:#有需要再打开 - # print("STOP_BLOOD_OXYGEN:") - # EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 - # EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试 - # spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - # print("spo2_value:{}".format(spo2_value)) - # if spo2_value > 85 and spo2_value != None: - # EventMesh.publish("set_old_spo2_data",spo2_value) - # EventMesh.publish("set_history_spo2_value",spo2_value) - # EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - # self.HR_state = 3 - else: - self.HR_state = 0 - self.old_time = self.mearsure_timer - - if self.HR_state == 3 or self.HR_state == 0:#只有不在测量的时候才测单次的 - if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量 - self.HR_state = 0 - self.HR_OneTime+=1 - if self.HR_OneTime == 1 and self.HR_Onestate == 0: - print("hr..........\r\n") - if self.get_hr_state == 3: - self.Hr_Need_Open = 1 - EventMesh.publish("set_hr_state",3)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.START_HEART) - else: - self.Hr_Need_Open = 0 + EventMesh.txt_log("auto start_temp:333") - if self.get_spo2_state == 3 and self.Hr_Need_Open == 0: - self.Spo2_Need_Open = 1 - EventMesh.publish("set_spo2_state",3)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 - else: - self.Spo2_Need_Open = 0 - self.HR_Onestate = 1 - # print("self.HR_Onestate....3..:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open)) - elif self.HR_OneTime > 6 and self.HR_Onestate == 1: - # print("self.HR_Onestate...4....:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open)) - if self.Hr_Need_Open == 1:#需要关闭心率测量 - print("stop debug4") - EventMesh.publish(constants.EVENT.STOP_HEART) - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - if heart_value > 50 and heart_value != None: - EventMesh.publish("set_history_hr_value",heart_value) - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 - EventMesh.publish("set_old_hr_data",heart_value) - - if self.Spo2_Need_Open == 0 and self.get_spo2_state == 3: - EventMesh.publish("set_spo2_state",3)#2代表后台进入血氧测试 - EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 - - self.HR_Onestate = 2 - self.set_hsenor_crt = 2#血氧关闭 - else: - self.HR_Onestate = 0 - self.HR_OneTime = 0 - self.set_hsenor_crt = 0# + + + + EventMesh.debug_log("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state)) + if get_temp_time != None:#定时测量体温 + if get_temp_time > 0: + if temp_state != None: + temp_state = EventMesh.publish("get_temp_state") + if temp_state == 0 or temp_state == 2: + if (time_tmp-self.temp_time) >= get_temp_time:#大于一个周期的时间,重新赋值 + self.temp_state = 0 + self.temp_time = time_tmp + + if self.old_temp_time != get_temp_time:#重复修改测量间隔时间 + self.temp_time = time_tmp#防止改变时间的时候正在开启测量突然10s就停止测量 + self.temp_state = 0 + self.old_temp_time = get_temp_time + + 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.debug_log("AUTO temp:") + EventMesh.txt_log("auto START_temp:1") + EventMesh.publish(constants.EVENT.START_TEMP) + + elif (time_tmp-self.temp_time) >= 30 and self.temp_state == 1: + self.temp_state = 0 + EventMesh.txt_log("auto stop_temp:1") + EventMesh.publish("set_temp_state",0) + temp = EventMesh.publish("optimize_temp") + if temp == None: + temp = 0 + + 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) - EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试 - EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 + tmp_d = str(temp).split('.')[1][:1] + tmp_d_tmp = int(tmp_d) else: - if self.Spo2_Need_Open == 1:#停止测试血氧 - EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#K开血氧 - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) + tmp_f_tmp = temp - if spo2_value > 85 and spo2_value != None: - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - EventMesh.publish("set_old_spo2_data",spo2_value) - EventMesh.publish("set_history_spo2_value",spo2_value) - if self.Hr_Need_Open == 0 and self.get_hr_state == 3: - EventMesh.publish("set_hr_state",3)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.START_HEART) - self.HR_Onestate = 2 - self.set_hsenor_crt = 1#心率 - else: - self.HR_Onestate = 0 - self.HR_OneTime = 0 - self.set_hsenor_crt = 2#血氧关闭 - - - elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2: - print("HR_OneTime:....05") - if self.set_hsenor_crt == 2: - EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试 - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - if spo2_value > 85 and spo2_value != None: - EventMesh.publish("set_history_spo2_value",spo2_value) - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - EventMesh.publish("set_old_spo2_data",spo2_value) - elif self.set_hsenor_crt == 1: - EventMesh.publish("set_hr_state",0)#0代表g关闭测试 - print("stop debug5") - EventMesh.publish(constants.EVENT.STOP_HEART) - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - if heart_value > 50 and heart_value != None: - EventMesh.publish("set_history_hr_value",heart_value) - EventMesh.publish("set_old_hr_data",heart_value) - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 - self.HR_Onestate = 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]) + EventMesh.publish(constants.EVENT.STOP_TEMP) + else: - if self.get_spo2_state == 2 or self.get_hr_state == 2:#单次测量 - if self.get_hr_state == 2: - EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试 - EventMesh.publish(constants.EVENT.STOP_HEART) - elif self.get_spo2_state == 2: - EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) - self.HR_state = 0 - self.HR_Onestate = 0 - self.HR_OneTime = 0 - self.set_hsenor_crt = 0 - else: - #print("hr......01....{} {} self.HR_Onestate {} {}".format(self.get_hr_state,self.get_spo2_state,self.HR_OneTime,self.HR_Onestate)) - self.SENSOR_time = time_tmp#进入最后一次的时间戳 - self.old_time = 0 - - self.set_hsenor_crt = 0 - if self.get_hr_state != 1 and self.get_spo2_state != 1:#没有设置间隔时间单次测量 - if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量 - self.HR_state = 0 - self.HR_OneTime+=1 - if self.HR_OneTime == 1 and self.HR_Onestate == 0: - if self.get_hr_state == 3: - self.Hr_Need_Open = 1 - EventMesh.publish("set_hr_state",3)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.START_HEART) - else: - self.Hr_Need_Open = 0 - - if self.get_spo2_state == 3 and self.Hr_Need_Open == 0: - self.Spo2_Need_Open = 1 - EventMesh.publish("set_spo2_state",3)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 - else: - self.Spo2_Need_Open = 0 - self.HR_Onestate = 1 + self.temp_state = 0 + self.old_temp_time = 0 + else: + temp_state = EventMesh.publish("get_temp_state") + if temp_state == 2: + EventMesh.publish("set_temp_state",0)#2代表后台进入测试 + # EventMesh.publish("stop_led_timer")#设置参数 + EventMesh.txt_log("auto wear stop_temp:2 ") + EventMesh.publish(constants.EVENT.STOP_TEMP) + self.temp_state = 0 + self.temp_time = 0 + self.old_temp_time = 0 + + + hr_time = [] + hr_time = EventMesh.publish("get_time_hr")#获取时间是否大于0 + if hr_time == None: + hr_time = [0,0] + print("hr_time hr",hr_time) + if hr_time != None: + self.mearsure_btn = int(hr_time[0]) + self.mearsure_timer = int(hr_time[1]) + + if self.mearsure_btn != None and self.mearsure_timer != None: - elif self.HR_OneTime > 6 and self.HR_Onestate == 1: - print("stop_heart Onec ") - if self.Hr_Need_Open == 1:#需要关闭心率测量 - print("stop debug6") - EventMesh.publish(constants.EVENT.STOP_HEART) - heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - print("stop_heart heart_value:{}".format(heart_value)) - if heart_value > 50 and heart_value != None: - EventMesh.publish("set_old_hr_data",heart_value) - EventMesh.publish("set_history_hr_value",heart_value) - EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 - if self.Spo2_Need_Open == 0 and self.get_spo2_state == 3: - EventMesh.publish("set_spo2_state",3)#2代表后台进入血氧测试 - EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 - self.HR_Onestate = 2 - self.set_hsenor_crt = 2#血氧关闭 - else: - self.HR_Onestate = 0 - self.HR_OneTime = 0 - self.set_hsenor_crt = 0# - EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试 - EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 - else: - if self.Spo2_Need_Open == 1:#停止测试血氧 - EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#K开血氧 - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - print("spo2_value:{}.......01..".format(spo2_value)) - if spo2_value > 85 and spo2_value != None: - EventMesh.publish("set_old_spo2_data",spo2_value) - EventMesh.publish("set_history_spo2_value",spo2_value) - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - if self.Hr_Need_Open == 0 and self.get_hr_state == 3: - EventMesh.publish("set_hr_state",3)#2代表后台进入测试 - EventMesh.publish(constants.EVENT.START_HEART) - self.HR_Onestate = 2 - self.set_hsenor_crt = 1#心率 - else: - self.HR_Onestate = 0 - self.HR_OneTime = 0 - self.set_hsenor_crt = 2#血氧关闭 - print("STOP_BLOOD_OXYGEN:....06.....") - - elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2: - if self.set_hsenor_crt == 2: - EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试 - spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - if spo2_value > 85 and spo2_value != None: - EventMesh.publish("set_old_spo2_data",spo2_value) - EventMesh.publish("set_history_spo2_value",spo2_value) - EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) - elif self.set_hsenor_crt == 1: - EventMesh.publish("set_hr_state",0)#0代表g关闭测试 - print("stop debug7") + if self.mearsure_btn >= 1 and self.mearsure_timer > 0:#开关打开并且时间大于0就可以测试血糖 + hr_state = EventMesh.publish("get_hr_state")#心率 + spo2_state = EventMesh.publish("get_spo2_state")#血氧 + bp_state = EventMesh.publish("get_bp_state") + # print("state hr",get_hr_state,spo2_state,get_bp_state,get_bg_state) + if spo2_state == 0 and bp_state == 0 and (hr_state == 2 or 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) + if (time_tmp - self.SENSOR_time) == 0 and self.HR_Onestate == 0: + self.HR_Onestate = 1 + EventMesh.txt_log("auto START_hr:1") + EventMesh.publish("set_hr_state",2)#2代表后台进入测试 + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_HEART) + + elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_Onestate == 1: + self.HR_Onestate = 0 + EventMesh.publish("set_hr_state",0)#2代表后台进入测试 + EventMesh.debug_log("stop debug3") + EventMesh.txt_log("auto stop_hr:1") EventMesh.publish(constants.EVENT.STOP_HEART) heart_value = EventMesh.publish(constants.EVENT.GET_HEART) + EventMesh.debug_log("heart_value:{}".format(heart_value)) + # heart_value = 60+urandom.randint(0,10) if heart_value > 50 and heart_value != None: EventMesh.publish("set_old_hr_data",heart_value) EventMesh.publish("set_history_hr_value",heart_value) EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 + #获取心率数据上传数据app + EventMesh.debug_log("STOP_HEART:") + + else: self.HR_Onestate = 0 else: - if self.get_spo2_state == 2 or self.get_hr_state == 2:#单次测量 - if self.get_hr_state == 2: - EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试 - EventMesh.publish(constants.EVENT.STOP_HEART) - elif self.get_spo2_state == 2: - EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 - EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) + self.SENSOR_time = 0 self.HR_Onestate = 0 - self.HR_OneTime = 0 - self.old_time = 0 - else: - self.old_temp_time = 0 - self.old_time = 0 - if battery[0] == "1": - get_hr_state = EventMesh.publish("get_hr_state") - get_spo2_state = EventMesh.publish("get_spo2_state") - if get_hr_state != None and get_spo2_state != None: - if get_hr_state == 2 or get_hr_state == 3: - EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 - print("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(constants.EVENT.STOP_BLOOD_OXYGEN) + hr_state = EventMesh.publish("get_hr_state")#心率 + if hr_state == 2: + EventMesh.publish("set_hr_state",0)#2代表后台进入测试 + EventMesh.debug_log("33stop debug3") + # EventMesh.publish("stop_led_timer")#设置参数 + EventMesh.publish(constants.EVENT.STOP_HEART) + EventMesh.txt_log("auto wear stop_hr:2 ") + + get_spo2time = EventMesh.publish("get_spo2_time")#血压自动测试 + print("get_spo2time",get_spo2time) + if get_spo2time != None:#血压时间不为0 + spo2_on = int(get_spo2time[0]) + spo2_time = int(get_spo2time[1]) + if spo2_on != 0 and spo2_time != 0: + hr_state = EventMesh.publish("get_hr_state") + spo2_state = EventMesh.publish("get_spo2_state") + bp_state = EventMesh.publish("get_bp_state") + # print("state bg2",get_hr_state,get_spo2_state,bp_state,get_bg_state) + if hr_state == 0 and bp_state == 0 and (spo2_state == 2 or spo2_state == 0):#心率血压血氧不在测试就测试血糖自动测量 + if (time_tmp-self.spo2_timeSecond) >= spo2_time:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 + self.spo2_timeSecond = time_tmp + self.spo2auto_state = 0 + # print("time_tmp spo2",time_tmp,self.spo2_timeSecond,time_tmp-self.spo2_timeSecond,self.bg_timer,self.bpauto_state) + if (time_tmp - self.spo2_timeSecond) == 0 and self.spo2auto_state == 0: + self.spo2auto_state = 1 + EventMesh.debug_log("START_spo2:auto") + EventMesh.txt_log("auto START_spo2:1") + EventMesh.publish("set_spo2_state",2)#2代表后台进入测试 + EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 + + elif (time_tmp - self.spo2_timeSecond) >= 60 and self.spo2auto_state == 1: + EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 + self.spo2auto_state = 0 + EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) + spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) + if spo2_value > 85 and spo2_value != None: + EventMesh.publish("set_old_spo2_data",spo2_value) + EventMesh.publish("set_history_spo2_value",spo2_value) + EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) + EventMesh.txt_log("auto stop_spo2:1") + + else: + self.spo2auto_state = 0 + else: + self.spo2_timeSecond = 0 + self.spo2auto_state = 0 + spo2_state = EventMesh.publish("get_spo2_state")#心率 + if spo2_state == 2: + EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 + EventMesh.debug_log("spo2 stop debug3") + EventMesh.txt_log("auto wear stop_spo2:2 ") + EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) + + get_bptime = EventMesh.publish("get_bp_time")#血压自动测试 + # print("get_bptime",get_bptime) + if get_bptime != None:#血压时间不为0 + bp_on = int(get_bptime[0]) + bp_time = int(get_bptime[1]) + if bp_on != 0 and bp_time != 0: + hr_state = EventMesh.publish("get_hr_state") + spo2_state = EventMesh.publish("get_spo2_state") + bp_state = EventMesh.publish("get_bp_state") + # print("state bg2",get_hr_state,get_spo2_state,bp_state,get_bg_state) + + if (hr_state == 0 and spo2_state == 0) and (bp_state == 2 or bp_state == 0):#心率血压血氧不在测试就测试血糖自动测量 + if (time_tmp-self.bp_timeSecond) >= bp_time:#大于一个周期的时间,保存的时间戳时间 1678 0 1678 30 1678 + self.bp_timeSecond = time_tmp + self.bpauto_state = 0 + # print("time_tmp bp",time_tmp,self.bp_timeSecond,time_tmp-self.bp_timeSecond,self.bg_timer,self.bpauto_state) + if (time_tmp - self.bp_timeSecond) == 0 and self.bpauto_state == 0: + self.bpauto_state = 1 + EventMesh.debug_log("START_bp:auto") + EventMesh.txt_log("auto START_bp:1") + EventMesh.publish("set_bp_state",2)#2代表后台进入测试 + # EventMesh.publish("set_hr_blood_led",1) + EventMesh.publish(constants.EVENT.START_HEART) + + elif (time_tmp - self.bp_timeSecond) >= 60 and self.bpauto_state == 1: + self.bpauto_state = 0 + EventMesh.publish("set_bp_state",0)#2代表后台进入测试 + blood_data = get_autoblood_value() + if blood_data == None: + blood_data[0] = 0 + blood_data[1] = 0 + + max_value = blood_data[0] + min_value = blood_data[1] + if max_value != 0 and min_value != 0: + EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value]) + EventMesh.publish(constants.EVENT.STOP_HEART) + EventMesh.txt_log("auto stop_bp:1") + + else: + self.bpauto_state = 0 + else: + self.bp_timeSecond = 0 + self.bpauto_state = 0 + bp_state = EventMesh.publish("get_bp_state")#心率 + if bp_state == 2: + EventMesh.publish("set_bp_state",0)#2代表后台进入测试 + EventMesh.debug_log("bp stop debug3") + EventMesh.txt_log("auto wear stop_bp:2 ") + # EventMesh.publish("stop_led_timer")#设置参数 + EventMesh.publish(constants.EVENT.STOP_HEART) + + - if get_temp_time != None: - get_temp_state = EventMesh.publish("get_temp_state") - if get_temp_state == 2 or get_temp_state == 3: - self.temp_one_state = 0 - self.temp_state = 0 - # temp = EventMesh.publish(constants.EVENT.GET_TEMP) - # temp += 0.5 - # if temp < 25 or temp > 42: - # temp = 0 - temp = EventMesh.publish("optimize_temp") - if temp == None: - temp = 0 + else: + self.old_temp_time = 0 + self.old_time = 0 + self.HR_Onestate = 0 + self.HR_OneTime = 0 + self.HR_state = 0 + self.old_time = 0 + self.old_hr_time = 0 + self.old_spo2_time = 0 + self.set_hsenor_crt = 0 + self.spo2auto_state = 0 + self.temp_state = 0 + self.temp_one_state = 0 + self.old_bp_time = 0 + self.bpauto_state = 0 + + + + + else: + hr_state = EventMesh.publish("get_hr_state") + spo2_state = EventMesh.publish("get_spo2_state") + bp_state = EventMesh.publish("get_bp_state")# + if hr_state != None and spo2_state != None and bp_state != None: + if hr_state > 1: + EventMesh.txt_log("auto stop_hr:44") + EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 + # if hr_state == 3: + # EventMesh.publish("stop_led_timer")#设置参数 + EventMesh.debug_log("stop debug8") + if WEAR == 1: + heart_value = EventMesh.publish(constants.EVENT.GET_HEART) + if heart_value > 50 and heart_value != None: + EventMesh.publish("set_old_hr_data",heart_value) + EventMesh.publish("set_history_hr_value",heart_value) + EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据 + EventMesh.publish(constants.EVENT.STOP_HEART) + if spo2_state > 1: + EventMesh.txt_log("auto stop_spo2:44") + EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 + # if spo2_state == 3: + # EventMesh.publish("stop_led_timer")#设置参数 + if WEAR == 1: + spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) + if spo2_value > 85 and spo2_value != None: + EventMesh.publish("set_old_spo2_data",spo2_value) + EventMesh.publish("set_history_spo2_value",spo2_value) + EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value) + EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) + EventMesh.debug_log("stop debug13") + if bp_state > 1: + EventMesh.txt_log("auto stop_bp:44") + EventMesh.publish("set_bp_state",0)#2代表后台进入测试 + if WEAR == 1: + blood_data = get_autoblood_value() + if blood_data == None: + blood_data[0] = 0 + blood_data[1] = 0 + + max_value = blood_data[0] + min_value = blood_data[1] + if max_value != 0 and min_value != 0: + EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value]) + EventMesh.publish(constants.EVENT.STOP_HEART) + EventMesh.debug_log("stop debug14") + + temp_state = EventMesh.publish("get_temp_state") + if temp_state != None: + if temp_state > 1: + self.temp_one_state = 0 + self.temp_state = 0 + temp = EventMesh.publish("optimize_temp") + if temp == None: + temp = 0 + EventMesh.txt_log("auto stop_temp:44") + EventMesh.publish("set_temp_state",0) + if WEAR == 1: tmp_f_tmp = 0 tmp_d_tmp = 0 if str(temp).find(".") != -1: @@ -1626,21 +1704,27 @@ class DeviceInfoManager(Abstract): tmp_d_tmp = int(tmp_d) else: tmp_f_tmp = temp - - 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 + EventMesh.publish(constants.EVENT.STOP_TEMP) + + self.old_temp_time = 0 + self.temp_one_state = 0 + self.old_time = 0 self.HR_Onestate = 0 self.HR_OneTime = 0 self.HR_state = 0 self.old_time = 0 + self.old_hr_time = 0 + self.old_spo2_time = 0 self.set_hsenor_crt = 0 + self.spo2auto_state = 0 + self.temp_state = 0 + self.bpauto_state = 0 + self.old_bp_time = 0 #quecgnss.gnssEnable(0) @@ -1901,6 +1985,7 @@ class DeviceInfoManager(Abstract): if not self.imei: self.imei = modem.getDevImei() # self.imei = "860132060345899" + # self.imei = "876226002021444"#视频通话测试账号 return self.imei def get_cid(self, topic, msg): @@ -2895,40 +2980,79 @@ class getWeatherDataManager(Abstract): class getHrTimeManager(Abstract): def __init__(self): - self.set_time = 15*60 - self.set_hr = 0 #0关闭 1手动 2 自动测量按照时间间隔测试心率 - self.set_spo2 = 0 + self.set_time = 30*60 self.open_btn = 1 + + self.spo2time_on = 1 + self.spo2time_time = 30*60 + + self.set_hr = 0 + + self.set_spo2 = 0 + + self.get_bpstate = 0 + + read_data = EventMesh.publish("get_storage_config","measure_time") if read_data != None: self.set_time = read_data read_data = EventMesh.publish("get_storage_config","open_hr_btn") if read_data != None: - self.open_btn = read_data + self.open_btn = read_data + + read_data = EventMesh.publish("get_storage_config","spo2auto_btn") + if read_data != None: + self.spo2time_on = read_data + + read_data = EventMesh.publish("get_storage_config","spo2auto_time") + if read_data != None: + self.spo2time_time = read_data + + self.bptime_on = 0 + self.bptime_time = 0 + read_data=EventMesh.publish("get_storage_config","bpauto_btn") + if read_data != None: + self.bptime_on = read_data + + EventMesh.publish("get_storage_config","bpauto_time") + if read_data != None: + self.bptime_time = read_data def post_processor_after_instantiation(self): - EventMesh.subscribe("set_time_hr_spo2", self.set_time_hr_spo2) - EventMesh.subscribe("get_time_hr_spo2", self.get_time_hr_spo2) + EventMesh.subscribe("set_time_hr", self.set_time_hr) + EventMesh.subscribe("get_time_hr", self.get_time_hr) EventMesh.subscribe("set_hr_state", self.set_hr_state) EventMesh.subscribe("get_hr_state", self.get_hr_state) EventMesh.subscribe("set_spo2_state", self.set_spo2_state) EventMesh.subscribe("get_spo2_state", self.get_spo2_state) + EventMesh.subscribe("set_spo2_time", self.set_spo2_time) + EventMesh.subscribe("get_spo2_time", self.get_spo2_time) + + EventMesh.subscribe("set_bp_time", self.set_bp_time) + EventMesh.subscribe("get_bp_time", self.get_bp_time) + + EventMesh.subscribe("set_bp_state", self.set_bp_state) + EventMesh.subscribe("get_bp_state", self.get_bp_state) + + - def set_time_hr_spo2(self, event, msg): + def set_time_hr(self, event, msg): self.open_btn = msg[0] self.set_time = msg[1] EventMesh.publish("set_storage_config",["measure_time",self.set_time]) EventMesh.publish("set_storage_config",["open_hr_btn",self.open_btn]) - def get_time_hr_spo2(self, event, msg): + def get_time_hr(self, event, msg): return [self.open_btn,self.set_time] def set_hr_state(self, event, msg): self.set_hr = msg + if self.set_hr == 0:#关闭 + EventMesh.publish("clear_health_state") def get_hr_state(self, event, msg): if self.set_hr: @@ -2938,6 +3062,8 @@ class getHrTimeManager(Abstract): def set_spo2_state(self, event, msg): self.set_spo2 = msg + if self.set_spo2 == 0:#关闭 + EventMesh.publish("clear_health_state") def get_spo2_state(self, event, msg): if self.set_spo2: @@ -2945,13 +3071,51 @@ class getHrTimeManager(Abstract): else: return 0 + def set_spo2_time(self, event, msg): + self.spo2time_on = msg[0] + self.spo2time_time = msg[1] + EventMesh.publish("set_storage_config",["spo2auto_btn",self.spo2time_on]) + EventMesh.publish("set_storage_config",["spo2auto_time",self.spo2time_time]) + + + def get_spo2_time(self, event, msg): + + return [self.spo2time_on,self.spo2time_time] + + + def set_bp_time(self, event, msg): + self.bptime_on = msg[0] + self.bptime_time = msg[1] + EventMesh.publish("set_storage_config",["bpauto_btn",self.bptime_on]) + EventMesh.publish("set_storage_config",["bpauto_time",self.bptime_time]) + + def get_bp_time(self, event, msg): + if self.bptime_on == None: + self.bptime_on = 0 + if self.bptime_time == None: + self.bptime_time = 0 + return [self.bptime_on,self.bptime_time] + + def set_bp_state(self, event, msg): + self.get_bpstate = msg + if self.get_bpstate == 0: + EventMesh.publish("clear_health_state") + # if msg != 0: + # EventMesh.publish("set_hr_blood_led",1)#红绿灯交替闪烁 + + def get_bp_state(self, event, msg): + if self.get_bpstate: + return self.get_bpstate + else : + return 0 + #体温 class getTempTimeManager(Abstract): def __init__(self): self.set_time = 0 self.get_temp = 0 read_data = EventMesh.publish("get_storage_config","temp_time") - self.set_time = 15*60 + self.set_time = 30*60 if read_data != None: self.set_time = read_data @@ -2976,6 +3140,8 @@ class getTempTimeManager(Abstract): def set_temp_state(self, event, msg): self.get_temp = msg + if self.get_temp == 0: + EventMesh.publish("clear_temp_state") def get_temp_state(self, event, msg): if self.get_temp: @@ -3554,4 +3720,21 @@ class setclassTimeManager(Abstract):#设置上课禁用时间 EventMesh.publish("load_screen", {"screen": "main_menu"}) pass - \ No newline at end of file + +import fota +class firwDownloadManager(Abstract):# + def __init__(self): + self.timer = osTimer() + + + def post_processor_after_instantiation(self): + EventMesh.subscribe("firware_download", self.firware_download)# + + def firware_download(self, event, msg): + number = str(msg) + sms.sendPduMsg(number, 'set ok', 'UCS2') + self.timer.start(10*1000,0,self.fun) + + def fun(self,*argc): + fota_obj = fota() + fota_obj.httpDownload(url1="http://u-oss.thisiot.com/test/dfota_1.bin",url2="http://u-oss.thisiot.com/test/dfota_2.bin") \ No newline at end of file diff --git a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/protocol.py b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/protocol.py index 1caf9566..4a2de8e7 100644 --- a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/protocol.py +++ b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/protocol.py @@ -25,7 +25,7 @@ import usys def server_init(server_type = None): #服务器选择1,防走丢,2大锤,3三基同创,4童信,5云米,6荣为 if server_type == None: - server_type = 2 + server_type = 1 #print("server_init:server_type:{}".format(server_type)) d_server_addr = "api.xcloudtech.com" d_server_port = 9000 @@ -883,15 +883,18 @@ class HRSTART_ProtoCol(ProtoCol): hrTotal = int(msg_tmp) if hrTotal == 0:#关闭自动测量 print("HRSTART_ 1") - EventMesh.publish("set_time_hr_spo2",[0,0]) + EventMesh.publish("set_time_hr",[0,0]) else: if hrTotal == 1:#单次测量 print("HRSTART_ 2".format(hrTotal)) - get_hr_state = EventMesh.publish("get_hr_state") - get_spo2_state = EventMesh.publish("get_spo2_state") - # if (get_hr_state == 3 ) or (get_spo2_state == 0 and get_hr_state == 0):#只要两个不在测量 单次优先级最低 - if (get_spo2_state == 0 and get_hr_state == 0): - EventMesh.publish("set_hr_state",3)#3代表单次测量 + hr_state = EventMesh.publish("get_hr_state") + spo2_state = EventMesh.publish("get_spo2_state") + bp_state = EventMesh.publish("get_bp_state") + if (spo2_state == 0 and hr_state == 0 and bp_state == 0): + battery = EventMesh.publish("screen_get_battery") + if battery != None: + if battery[0] != "1": + EventMesh.publish("set_hr_state",3)#3代表单次测量 pass else: if hrTotal > 0 and hrTotal <= 300: @@ -899,7 +902,7 @@ class HRSTART_ProtoCol(ProtoCol): elif hrTotal >= 65536: hrTotal = 65536 print("HRSTART_ 3".format(hrTotal)) - EventMesh.publish("set_time_hr_spo2",[1,hrTotal]) + EventMesh.publish("set_time_hr",[1,hrTotal]) EventMesh.publish(constants.PROTOCOL.HRTSTART_SEND) @@ -980,15 +983,129 @@ class OXYGEN_One_ProtoCol(ProtoCol):#单次测量 msg_tmp = msg.decode('ascii') msg_tmp = msg_tmp.split(',') msg_tmp = msg_tmp[1] - state = int(msg_tmp) - get_hr_state = EventMesh.publish("get_hr_state") - get_spo2_state = EventMesh.publish("get_spo2_state") - if state == 1: - # if (get_hr_state == 3 ) or (get_spo2_state == 0 and get_hr_state == 0):#只要两个不在测量 单次优先级最低 - if (get_spo2_state == 0 and get_hr_state == 0): - EventMesh.publish("set_spo2_state",3)#3代表单次测量 + oxstartTotal = int(msg_tmp) + hr_state = EventMesh.publish("get_hr_state") + spo2_state = EventMesh.publish("get_spo2_state") + bp_state = EventMesh.publish("get_bp_state") + if oxstartTotal == 1: + # if (hr_state == 3 ) or (spo2_state == 0 and hr_state == 0):#只要两个不在测量 单次优先级最低 + if (spo2_state == 0 and hr_state == 0 and bp_state == 0) : + battery = EventMesh.publish("screen_get_battery") + if battery != None: + if battery[0] != "1": + EventMesh.publish("set_spo2_state",3)#3代表单次测量 + else: + if oxstartTotal > 0 and oxstartTotal <= 300: + oxstartTotal = 300 + elif oxstartTotal >= 65536: + oxstartTotal = 65536 + + # if oxstartTotal == 0:#关闭自动测量 + # EventMesh.debug_log("bpSTART_ 1") + # EventMesh.publish("set_spo2_time",[0,0]) + # else: + on = 0 + if oxstartTotal != 0: + on = 1 + EventMesh.publish("set_spo2_time",[on,oxstartTotal]) EventMesh.publish(constants.PROTOCOL.OXSTART_SEND) +# 设置血压上传频率 +# 平台发送[XT*YYYYYYYYYYYYYYY*LEN*bldstart,x] +# x为上传间隔时间,单位秒,连续上传时最小时间不小于300秒,最大不超过65535. +# 示例[XT*334588000000156*0008*bldstart,300] +# 终端回复: +# [XT*334588000000156*0005*bldstart] +# x为1则代表终端单次上传。 +# x为0则代表终端上传关闭。 +class bldstart_ProtoCol(ProtoCol): + """app下发血压测试频率""" + TYPE = "bldstart" + def send(self, event, msg): + #[XT*334588000000156*len*wdstart,300] + send_data = self.PID+"*%s*0008*bldstart"%(self.imei) + MD5_SIGN = self.pack_MD5_head(send_data) + data = "[%s%s]"%(str(MD5_SIGN),send_data) + # print("temp:data:%s"%(data)) + # 通过socket发送到服务器端 + EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data) + + def recv(self, event, msg): + """ + @param event: 体温下发频率数据 + @param msg: 接收到的下行数据 + """ + # print("WDSTART_ProtoCol RECV msg:") + print("bldstart:{}".format(msg)) + msg = msg[1:-1] + msg_tmp = msg.decode('ascii') + msg_tmp = msg_tmp.split(',') + msg_tmp = msg_tmp[1] + + bldstartTotal = int(msg_tmp) + # bldstartTotal = 300 + print("bldstartTotal:{}".format(bldstartTotal)) + if bldstartTotal == 1:#单次测量 + bp_state = EventMesh.publish("get_bp_state") + hr_state = EventMesh.publish("get_hr_state") + spo2_state = EventMesh.publish("get_spo2_state") + print("bp_state:{}".format(bp_state)) + if bp_state == 0 and hr_state == 0 and spo2_state == 0:#只要两个不在测量 单次优先级最低 + battery = EventMesh.publish("screen_get_battery") + if battery != None: + if battery[0] != "1": + EventMesh.publish("set_bp_state",3)#3代表单次测量 + else: + if bldstartTotal > 0 and bldstartTotal <= 300: + bldstartTotal = 300 + elif bldstartTotal >= 65536: + bldstartTotal = 65536 + + on = 0 + if bldstartTotal != 0:#关闭自动测量 + on = 1 + print("on:{} bldstartTotal:{} ".format(on,bldstartTotal)) + EventMesh.publish("set_bp_time",[on,bldstartTotal]) + + EventMesh.publish(constants.PROTOCOL.BLDSTART_SEND) + + +# 注:回复完后开始测量血压并上传(一般测一次90秒,app端会提醒用户两分钟后刷新页面查看) +# 上传血压数据 +# 终端发送[XT*YYYYYYYYYYYYYYY*LEN*blood,x,y] +# x 是收缩压(高压) +# y 是舒张压(低压) +# 示例[XT*334588000000156*000C*blood,150,70] +# 平台回复: +# [XT*334588000000156*0005*blood] +class blood_ProtoCol(ProtoCol): + """上传血压测试数据""" + TYPE = "blood" + def send(self, event, msg): + len_size = len(str(msg[0]))+len("blood,")+1+len(str(msg[1])) + print("blood:send:{} len:{}".format(msg,len_size)) + # 实例:[XT*334588000000156*0009*blood,36,2] + # 代表终端的 + # 平台回复: + # [XT*334588000000156*0004*blood] + send_data = self.PID+"*%s*%04X*blood"%(self.imei,len_size) + MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"blood") + MD5_SIGN = self.pack_MD5_head(MD5_head_data) + data = "[%s%s,%d,%d]"%(str(MD5_SIGN),send_data,msg[0],msg[1]) + print("blood:data:%s"%(data)) + # 通过socket发送到服务器端 + EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data) + + def recv(self, event, msg): + """ + @param event: + @param msg: 接收到的下行数据 + """ + # print("HRSTART_ProtoCol RECV msg:") + #EventMesh.publish(constants.PROTOCOL.TEMP_SEND) + + + class TEMP_ProtoCol(ProtoCol): """上传体温测试数据""" TYPE = "temp" @@ -1076,9 +1193,9 @@ class bodytemp2_ProtoCol(ProtoCol): """ # print("bodytemp2_ProtoCol RECV msg:") print("bodytemp2:{}".format(msg)) - get_temp_state = EventMesh.publish("get_temp_state") - print("get_temp_state:{}".format(get_temp_state)) - if get_temp_state == 0:#只要两个不在测量 单次优先级最低 + temp_state = EventMesh.publish("get_temp_state") + print("temp_state:{}".format(temp_state)) + if temp_state == 0:#只要两个不在测量 单次优先级最低 EventMesh.publish("set_temp_state",3)#3代表单次测量 EventMesh.publish(constants.PROTOCOL.BODYTEMP2_SEND) class btemp2_ProtoCol(ProtoCol):#上传体温数据 @@ -1135,9 +1252,9 @@ class WDSTART_ProtoCol(ProtoCol): tempTotal = int(msg_tmp) print("tempTotal:{}".format(tempTotal)) if tempTotal == 1:#单次测量 - get_temp_state = EventMesh.publish("get_temp_state") - print("get_temp_state:{}".format(get_temp_state)) - if get_temp_state == 0:#只要两个不在测量 单次优先级最低 + temp_state = EventMesh.publish("get_temp_state") + print("temp_state:{}".format(temp_state)) + if temp_state == 0:#只要两个不在测量 单次优先级最低 EventMesh.publish("set_temp_state",3)#3代表单次测量 else: if tempTotal > 0 and tempTotal <= 300: diff --git a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/ui.py b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/ui.py index 77602d71..67c97277 100644 --- a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/ui.py +++ b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/ui.py @@ -1964,6 +1964,8 @@ def msg_cb(args): if len(new_ip) > 0 and len(new_com) > 0: EventMesh.publish("set_new_ip", [new_ip,new_com,tmp[0]])#设置关机时间 # EventMesh.publish("set_new_ip", [new_ip,new_com,new_md5])#设置关机时间 + if detail.find("fota:http://u-oss.thisiot.com/test/") != -1:# + EventMesh.publish("firware_download",tmp[0])# if index >= sms_max-1: EventMesh.publish("load_screen", {"screen": "message_full"}) @@ -2591,8 +2593,10 @@ class HeartrateScreen(Screen): EventMesh.publish(constants.EVENT.START_HEART) - def show_history_hr_data(self): + def show_history_hr_data(self,event,msg): global hr_line1,hr_line2,hr_line3,hr_line4,hr_line5,hr_line6,hr_line7 + if heartrate_screen == None: + return read_data = {} read_data = EventMesh.publish("get_history_hr_value") if len(read_data) != 0: @@ -2712,9 +2716,9 @@ class HeartrateScreen(Screen): def Close(self): self.timer.stop() - get_hr_state = EventMesh.publish("get_hr_state") - get_spo2_state = EventMesh.publish("get_spo2_state") - if get_hr_state == 1 or get_spo2_state == 1: + hr_state = EventMesh.publish("get_hr_state") + spo2_state = EventMesh.publish("get_spo2_state") + if hr_state == 1 or spo2_state == 1: EventMesh.publish("set_hr_state",0)#0代表关闭测试 print("stop debug10") EventMesh.publish(constants.EVENT.STOP_HEART) @@ -4307,8 +4311,10 @@ class TemperatureScreen(Screen): self.temp_data_old = 0 self.timer.start(1*500, 1, self.start_measure) - def show_history_temp_data(self): - global temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,temp_line6,temp_line7 + def show_history_temp_data(self,event,msg): + global temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,temp_line6,temp_line7,temperature_screen + if temperature_screen == None: + return read_data = {} read_data = EventMesh.publish("get_history_temp_value") # print("hr get_history_temp_value",read_data) @@ -4667,8 +4673,10 @@ class Spo2Screen(Screen): EventMesh.publish("set_spo2_state",1)#2代表后台进入血氧测试 EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN) - def show_history_spo2_data(self): + def show_history_spo2_data(self,event,msg): global spo2_line1,spo2_line2,spo2_line3,spo2_line4,spo2_line5,spo2_line6,spo2_line7 + if spo2_screen == None: + return read_data = {} read_data = EventMesh.publish("get_history_spo2_value") # print("hr get_history_spo2_value",read_data) @@ -4810,9 +4818,9 @@ class Spo2Screen(Screen): def Close(self): self.timer.stop() - get_hr_state = EventMesh.publish("get_hr_state") - get_spo2_state = EventMesh.publish("get_spo2_state") - if get_hr_state == 1 or get_spo2_state == 1: + hr_state = EventMesh.publish("get_hr_state") + spo2_state = EventMesh.publish("get_spo2_state") + if hr_state == 1 or spo2_state == 1: EventMesh.publish("set_spo2_state",0)#0代表关闭测试 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) @@ -6749,6 +6757,7 @@ class classMgrPopupScreen(Screen):#上课禁用时间界面 no_sim_screen = None no_sim_screenn_label = None +no_sim_screenn_img = None class no_sim_screenScreen(Screen): NAME = "no_sim_screen" def __init__(self): @@ -6758,7 +6767,7 @@ class no_sim_screenScreen(Screen): def initialization(self): EventMesh.publish("set_UI_high_priority",1) - global no_sim_screen,no_sim_screenn_label + global no_sim_screen,no_sim_screenn_label,no_sim_screenn_img if no_sim_screen == None : no_sim_screen = lv.obj() print("no_sim_screen") @@ -6766,9 +6775,15 @@ class no_sim_screenScreen(Screen): # add style for watchface no_sim_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT) #进入图片 + no_sim_screenn_img = lv.img(no_sim_screen) + no_sim_screenn_img.set_size(160, 160) + no_sim_screenn_img.set_pos(40, 20) + no_sim_screenn_img.set_src("E:/static/NO_SIM.png") + no_sim_screenn_img.add_flag(lv.obj.FLAG.CLICKABLE) + no_sim_screenn_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) no_sim_screenn_label = lv.label(no_sim_screen) - no_sim_screenn_label.set_pos(0, 100) + no_sim_screenn_label.set_pos(0, 220) no_sim_screenn_label.set_size(240, 80) no_sim_screenn_label.set_text("请插入SIM卡,插卡后长按【POWER】键3S重启") no_sim_screenn_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) @@ -6876,12 +6891,16 @@ class ImeiNewScreen(Screen): iccid = str(sim.getIccid()) - data_str = "https://iot.duduyun.com:19083/openApi/deviceScan?devicename=k5#{}#{}".format(imei,iccid) + data_str = "https://iot.duduyun.com:19083/openApi/deviceScan?pid=k5&devicename={}&iccid={}".format(imei,iccid) print("data_str",data_str) imei_qr_data = str(data_str) imei_qr.update(imei_qr_data,len(imei_qr_data)) imei_label.set_text("{}".format(imei)) - imei_iccid_label.set_text("{}".format(iccid[5:])) + if iccid != -1: + imei_iccid_label.set_text("{}".format(iccid[5:])) + else: + imei_iccid_label.set_text(" ") + self.count = 0 self.count_status = 1 self.timer.start(1*1000,1,self.check_sim) @@ -6915,6 +6934,7 @@ class ImeiNewScreen(Screen): pass def Close(self): self.count_status = 0 + self.count = 0 self.timer.stop() EventMesh.publish("set_UI_high_priority",0) pass @@ -6945,6 +6965,7 @@ class ImeiNewScreen(Screen): no_network_screen = None no_network_screen_label = None +no_network_screen_img =None class no_network_Screen(Screen):#开机未联网 NAME = "no_network_screen" def __init__(self): @@ -6958,7 +6979,7 @@ class no_network_Screen(Screen):#开机未联网 def initialization(self): EventMesh.publish("set_UI_high_priority",1) - global no_network_screen ,no_network_screen_label + global no_network_screen ,no_network_screen_label,no_network_screen_img if no_network_screen == None : no_network_screen = lv.obj() print("no_network_screen") @@ -6966,11 +6987,17 @@ class no_network_Screen(Screen):#开机未联网 # add style for watchface no_network_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT) #进入图片 + no_network_screen_img = lv.img(no_network_screen) + no_network_screen_img.set_size(160, 160) + no_network_screen_img.set_pos(40, 20) + no_network_screen_img.set_src("E:/static/NO_NETWORK.png") + no_network_screen_img.add_flag(lv.obj.FLAG.CLICKABLE) + no_network_screen_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) no_network_screen_label = lv.label(no_network_screen) - no_network_screen_label.set_pos(0, 100) + no_network_screen_label.set_pos(0, 220) no_network_screen_label.set_size(240, 60) - no_network_screen_label.set_text("请插入SIM卡,网络是否已正常") + no_network_screen_label.set_text("网络异常或未联网") no_network_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) no_network_screen_label.set_long_mode(lv.label.LONG.WRAP) no_network_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) @@ -7269,7 +7296,7 @@ class UI(object): #息屏状态按按钮都亮屏 screen_NAME = EventMesh.publish("get_screen_NAME") - if (self.main_flag != 1 and self.sleep_flag == 0) or screen_NAME == "SOS_MAIN" : + if (self.main_flag != 1 and self.sleep_flag == 0): if event == "btn8_long_press": if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机 sos_number = EventMesh.publish("get_dial_sos_number") @@ -7454,7 +7481,7 @@ class UI(object): if scr.NAME == msg["screen"]: # 每次屏幕切换开始息屏倒计时 - if scr.NAME == 'main_menu': + if scr.NAME == 'main_menu' or scr.NAME == "SOS_MAIN" : self.main_flag = 1 else : self.main_flag = 0 diff --git a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/ui_setting.py b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/ui_setting.py index ffdf7a50..dacdbd2e 100644 --- a/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/ui_setting.py +++ b/2.sdk/project/K5_DDY/sdk/services/microPython/ports/quectel/core/ui_setting.py @@ -865,9 +865,12 @@ class PoweroffScreen(Screen): #请插入SIM卡 #sim.getIccid() def check_sim_exit(): - signal = EventMesh.publish("screen_get_sig") + signal = EventMesh.publish("get_sim_Status") if signal != None: - if signal >= 0 and signal <= 31:#有卡 + if signal != 1:#无卡 + print("check sim is no exit") + EventMesh.publish("load_screen", {"screen": "no_sim_screen"}) + else:# ping_state = "0" ping_state = EventMesh.publish(constants.EVENT.GET_PING) print("check sim is exit",ping_state) @@ -878,12 +881,6 @@ def check_sim_exit(): EventMesh.publish("load_screen", {"screen": "no_network_screen"}) else: EventMesh.publish("load_screen", {"screen": "main_menu"}) - else:#未插卡 - print("check sim is no exit") - # EventMesh.publish("load_screen", {"screen": "imei_new"}) - # EventMesh.publish("load_screen", {"screen": "no_network_screen"}) - EventMesh.publish("load_screen", {"screen": "no_sim_screen"}) - pass poweron_screen = lv.obj() print("poweron_screen") @@ -931,7 +928,7 @@ class PowerOnScreen(Screen): self.timer.stop() EventMesh.publish("set_UI_high_priority",0) check_sim_exit() - # EventMesh.publish("load_screen", {"screen": "main_menu"}) + #EventMesh.publish("load_screen", {"screen": "main_menu"}) return self.count+=1 @@ -1280,22 +1277,48 @@ class ImeiScreen(Screen): def __init__(self): super().__init__() self.meta = imei_screen + self.timer = osTimer() + self.count = 0 def initialization(self): imei = EventMesh.publish(constants.EVENT.GET_IMEI) iccid = str(sim.getIccid()) +# 遗留问题: +# 域名修改为: +# https://iot.duduyun.com:19083/openApi/deviceScan?pid=*&devicename=*&iccid=* -# 现有IMEI、二维码显示调整为: -# 二维码格式:https://iot.duduyun.com:19083/openApi/deviceScan?devicename=pid#imei#iccid -# 如:https://iot.duduyun.com:19083/openApi/deviceScan?devicename=k5#860132060126901#8986080111923C0225152 - - data_str = "https://iot.duduyun.com:19083/openApi/deviceScan?devicename=k5#{}#{}".format(imei,iccid) +# 示例: +# https://iot.duduyun.com:19083/openApi/deviceScan?pid=k5&devicename=860132060126901&iccid=8986080111923C0225152 + # https://iot.duduyun.com:19083/openApi/deviceScan?pid=*&devicename=*&iccid=* + + data_str = "https://iot.duduyun.com:19083/openApi/deviceScan?pid=k5&devicename={}&iccid={}".format(imei,iccid) print("data_str",data_str) imei_qr_data = str(data_str) imei_qr.update(imei_qr_data,len(imei_qr_data)) imei_label.set_text("{}".format(imei)) - imei_iccid_label.set_text("{}".format(iccid[5:])) + if iccid != -1: + imei_iccid_label.set_text("{}".format(iccid[5:])) + else: + imei_iccid_label.set_text(" ") + self.count = 0 + self.timer.start(1*1000,1,self.timer_cb) + + def timer_cb(self,*argc): + self.count+=1 + if self.count <= 30: + EventMesh.publish("system_sleep_rest")#防止黑屏 + + pass + def lcd_off(self): + self.timer.stop() + + def lcd_on(self): + self.count = 0 + self.timer.start(1*1000,1,self.timer_cb) + def Close(self): + self.count = 0 + self.timer.stop() def done_return(self): EventMesh.publish("return_prev_screen")