import usys
import sms
from Gsensor import SC7A20
-# motor_pin = Pin(Pin.GPIO20, Pin.OUT, Pin.PULL_PD, 0)
-motor_pin = 1
-def open_motor():
- motor_pin.write(1)
+if EventMesh.model == "D10_" :
+ # motor_pin = Pin(Pin.GPIO20, Pin.OUT, Pin.PULL_PD, 0)
+ motor_pin = 1
+ def open_motor():
+ motor_pin.write(1)
-def close_motor():
- motor_pin.write(0)
+ def close_motor():
+ motor_pin.write(0)
-audio_buf = ['audio_find_haixiu', 'R_ALARM_NEW', 'R_BLOOD_SUGAR', 'R_CALL_mp3', 'R_CHARGE_FULL', 'R_CHARGE_IN', 'R_CHARGE_OUT', 'R_DRINK_ALARM', 'R_FALL_ALARM', 'R_HOME_ALARM', 'R_HSENSOR_RESULT_FAILE', 'R_HSENSOR_RESULT_HR_TITLE', 'R_HSENSOR_RESULT_OK', 'R_HSENSOR_SPO2_TITLE', 'R_HSENSOR_TEMP_TITLE', 'R_MEDICINE_ALARM', 'R_NO_SET_SOS_DIAL', 'R_NO_SIM', 'R_POWER_OFF_1', 'R_READ_STEP_0', 'R_READ_STEP_1', 'R_READ_STEP_2', 'R_READ_STEP_3', 'R_READ_STEP_4', 'R_READ_TIME_0', 'R_READ_TIME_1', 'R_READ_TIME_2', 'R_READ_TIME_3', 'R_READ_TIME_4', 'R_READ_TIME_5', 'R_READ_TIME_6', 'R_READ_TIME_7', 'R_READ_TIME_8', 'R_READ_TIME_9', 'R_READ_TIME_MIN', 'R_READ_TIME_ZHENG', 'R_RESET_ALARM', 'R_RESET_END_ALARM', 'R_SIM_CONNECT', 'R_SIM_FAILE', 'R_SLEEP_ALARM', 'R_SOS_ALERT', 'R_TSENSOR_RESULT_VALUE_DOT', 'R_UNREAD_WECHAT', 'R_WAKEUP_ALARM', 'R_WECHAT_RECV']
+ audio_buf = ['audio_find_haixiu', 'R_ALARM_NEW', 'R_BLOOD_SUGAR', 'R_CALL_mp3', 'R_CHARGE_FULL', 'R_CHARGE_IN', 'R_CHARGE_OUT', 'R_DRINK_ALARM', 'R_FALL_ALARM', 'R_HOME_ALARM', 'R_HSENSOR_RESULT_FAILE', 'R_HSENSOR_RESULT_HR_TITLE', 'R_HSENSOR_RESULT_OK', 'R_HSENSOR_SPO2_TITLE', 'R_HSENSOR_TEMP_TITLE', 'R_MEDICINE_ALARM', 'R_NO_SET_SOS_DIAL', 'R_NO_SIM', 'R_POWER_OFF_1', 'R_READ_STEP_0', 'R_READ_STEP_1', 'R_READ_STEP_2', 'R_READ_STEP_3', 'R_READ_STEP_4', 'R_READ_TIME_0', 'R_READ_TIME_1', 'R_READ_TIME_2', 'R_READ_TIME_3', 'R_READ_TIME_4', 'R_READ_TIME_5', 'R_READ_TIME_6', 'R_READ_TIME_7', 'R_READ_TIME_8', 'R_READ_TIME_9', 'R_READ_TIME_MIN', 'R_READ_TIME_ZHENG', 'R_RESET_ALARM', 'R_RESET_END_ALARM', 'R_SIM_CONNECT', 'R_SIM_FAILE', 'R_SLEEP_ALARM', 'R_SOS_ALERT', 'R_TSENSOR_RESULT_VALUE_DOT', 'R_UNREAD_WECHAT', 'R_WAKEUP_ALARM', 'R_WECHAT_RECV']
-class call:
- CALL_OUT = 1
- CALL_IN = 2
- ON_CALL = 3
-class intervManager(Abstract):
- def __init__(self):
- self.timer = osTimer()
+ class intervManager(Abstract):
+ def __init__(self):
+ self.timer = osTimer()
- self.pwk_timer1 = osTimer()
- self.pwk_timer2 = osTimer()
- self.timer1 = osTimer()
- self.sos_timer2 = osTimer()
- self.sos_timer1 = osTimer()
+ self.pwk_timer1 = osTimer()
+ self.pwk_timer2 = osTimer()
+ self.timer1 = osTimer()
+ self.sos_timer2 = osTimer()
+ self.sos_timer1 = osTimer()
- self.sos_sendtime = osTimer()
+ self.sos_sendtime = osTimer()
- self.fall_timer1 = osTimer()
- self.fall_timer2 = osTimer()
+ self.fall_timer1 = osTimer()
+ self.fall_timer2 = osTimer()
- self.alarm_timer1 = osTimer()
+ self.alarm_timer1 = osTimer()
- self.find_timer1 = osTimer()
- self.fall_flag = 0
+ self.find_timer1 = osTimer()
+ self.fall_flag = 0
- self.factory_timer = osTimer()
-
- self.restart_timer = osTimer()
-
- self.aud = audio.Audio(0)
- self.aud.set_pa(Pin.GPIO29)
- self.aud.setVolume(11)
- self.play_count = 0
- self.count = 0
-
- self.get_hr_state = 0
- self.get_spo2_state = 0
- self.timeSec = 0
- self.timeTempSec = 0
-
- self.hr_value = 0
- self.spo2_value = 0
- self.temp_value = 0
-
- self.usbState = 0
-
- self.setp_old = 0
- self.step_tmp = ""
- self.step_num = 0
- self.power_off = 0
- self.call_state = 0
-
- self.find_state = 0
- self.FIND_timer_count = 0
-
- self.old_hour = 0
- self.alarm_state = 0
- self.alarm_timer_count = 0
- self.old_min = 0
- self.interInfo_queue = Queue()
- _thread.stack_size(10*1024+64)
- _thread.start_new_thread(self.interInfo_queue_thread, ())
- _thread.stack_size(8*1024)
- EventMesh.subscribe("publish_message_event_interInfo",self.publish_message_event_interInfo)
-
+ self.factory_timer = osTimer()
+
+ self.restart_timer = osTimer()
- self.audio_event_queue = Queue()
- _thread.stack_size(10*1024+128)
- _thread.start_new_thread(self.audio_event_queue_thread, ())
- _thread.stack_size(8*1024)
- EventMesh.subscribe("publish_message_event_audio",self.publish_message_event_audio)
-
- self.record_test = audio.Record()
- self.record_test.gain(4,12)
-
- self.timeSecond = 0
- self.wechat_show = 0
- self.sort_new = {}
- self.time_min = 0
- self.press_btn = 0
- self.countdown_old = 0
- self.set_unread_wechat = 0
- self.updateTime = 0
-
- self.power_on_flag = 0
-
- self.MXA_MSG = 1
- self.wechat_recode_list = {"num":0}
- self.wechat_num = 0
- self.read_data = {}
- self.volum_size = 8
- self.phone_num = ''
- self.sos_phone_num = ''
- self.msg_tmp = ""
- self.time_count = 0
- self.alarm_count = 0
- self.audio_int = 0
-
- self.hr_auto = 0
-
- self.temp_auto = 0
-
- check_txt = ql_fs.path_exists("/usr/static/storage_file/wechat_record.json")
- if check_txt == True :
- with open("/usr/static/storage_file/wechat_record.json","r") as fd:#音频文件编号
- self.wechat_recode_list = ujson.load(fd)
- if not self.wechat_recode_list:
- self.wechat_recode_list = {"num":0}
- self.wechat_num = 0
- else:
+ self.aud = audio.Audio(0)
+ self.aud.set_pa(Pin.GPIO29)
+ self.aud.setVolume(11)
+ self.play_count = 0
+ self.count = 0
+
+ self.get_hr_state = 0
+ self.get_spo2_state = 0
+ self.timeSec = 0
+ self.timeTempSec = 0
+
+ self.hr_value = 0
+ self.spo2_value = 0
+ self.temp_value = 0
+
+ self.usbState = 0
+
+ self.setp_old = 0
+ self.step_tmp = ""
+ self.step_num = 0
+ self.power_off = 0
+ self.call_state = 0
+
+ self.find_state = 0
+ self.FIND_timer_count = 0
+
+ self.old_hour = 0
+ self.alarm_state = 0
+ self.alarm_timer_count = 0
+ self.old_min = 0
+ self.interInfo_queue = Queue()
+ _thread.stack_size(10*1024+64)
+ _thread.start_new_thread(self.interInfo_queue_thread, ())
+ _thread.stack_size(8*1024)
+ EventMesh.subscribe("publish_message_event_interInfo",self.publish_message_event_interInfo)
+
+
+ self.audio_event_queue = Queue()
+ _thread.stack_size(10*1024+128)
+ _thread.start_new_thread(self.audio_event_queue_thread, ())
+ _thread.stack_size(8*1024)
+ EventMesh.subscribe("publish_message_event_audio",self.publish_message_event_audio)
+
+ self.record_test = audio.Record()
+ self.record_test.gain(4,12)
+
+ self.timeSecond = 0
+ self.wechat_show = 0
+ self.sort_new = {}
+ self.time_min = 0
+ self.press_btn = 0
+ self.countdown_old = 0
+ self.set_unread_wechat = 0
+ self.updateTime = 0
+
+ self.power_on_flag = 0
+
+ self.MXA_MSG = 1
self.wechat_recode_list = {"num":0}
- with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
- ujson.dump(self.wechat_recode_list,fd)
+ self.wechat_num = 0
+ self.read_data = {}
+ self.volum_size = 8
+ self.phone_num = ''
+ self.sos_phone_num = ''
+ self.msg_tmp = ""
+ self.time_count = 0
+ self.alarm_count = 0
+ self.audio_int = 0
+ self.hr_auto = 0
- def post_processor_after_instantiation(self):
- EventMesh.subscribe("open_power_on", self.open_power_on)#开机关机
+ self.temp_auto = 0
+
+ check_txt = ql_fs.path_exists("/usr/static/storage_file/wechat_record.json")
+ if check_txt == True :
+ with open("/usr/static/storage_file/wechat_record.json","r") as fd:#音频文件编号
+ self.wechat_recode_list = ujson.load(fd)
+ if not self.wechat_recode_list:
+ self.wechat_recode_list = {"num":0}
+ self.wechat_num = 0
+ else:
+ self.wechat_recode_list = {"num":0}
+ with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
- EventMesh.subscribe("play_imei_event", self.play_imei_event)#播報imei号
- EventMesh.subscribe("play_center_phone", self.play_center_phone)#拨打快捷号码
- EventMesh.subscribe("play_cur_time_event", self.play_cur_time_event)#播放当前时间
- EventMesh.subscribe("OPEN_FIND_WATCH", self.send_find_watch)#查找设备
- EventMesh.subscribe("STOP_FIND_WATCH", self.stop_find_watch)#是否需要关闭查找设备
- EventMesh.subscribe("close_timer_all", self.close_timer_all)#关闭相关定时器
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("open_power_on", self.open_power_on)#开机关机
- EventMesh.subscribe("dial_sos_phone", self.dial_sos_phone)#长按3s拨打sos求助号码
+ EventMesh.subscribe("play_imei_event", self.play_imei_event)#播報imei号
+ EventMesh.subscribe("play_center_phone", self.play_center_phone)#拨打快捷号码
+ EventMesh.subscribe("play_cur_time_event", self.play_cur_time_event)#播放当前时间
- EventMesh.subscribe("set_sim_mode", self.set_sim_mode)#sim检测
+ EventMesh.subscribe("OPEN_FIND_WATCH", self.send_find_watch)#查找设备
+ EventMesh.subscribe("STOP_FIND_WATCH", self.stop_find_watch)#是否需要关闭查找设备
+ EventMesh.subscribe("close_timer_all", self.close_timer_all)#关闭相关定时器
- EventMesh.subscribe("close_hr_sop2", self.close_hr_sop2)#关闭健康测试
- EventMesh.subscribe("set_manual_measure_mode", self.set_manual_measure_mode)#设置测试模式
- EventMesh.subscribe("set_start_measure_time", self.set_start_measure_time)#设置开始测量的时间戳时间
- EventMesh.subscribe("get_start_measure_time", self.get_start_measure_time)#获取开始测量的时间戳时间
- EventMesh.subscribe("set_start_temp_measure_time", self.set_start_temp_measure_time)#设置体温开始测量的时间戳时间
- EventMesh.subscribe("get_start_temp_measure_time", self.get_start_temp_measure_time)#获取体温开始测量的时间戳时间
- EventMesh.subscribe("play_hr_value", self.play_hr_value)#播放心率数值
- EventMesh.subscribe("play_spo2_value", self.play_spo2_value)#播放心率数值
- EventMesh.subscribe("play_temp_value", self.play_temp_value)#播放体温数值
+ EventMesh.subscribe("dial_sos_phone", self.dial_sos_phone)#长按3s拨打sos求助号码
- EventMesh.subscribe("play_sugar_value", self.play_sugar_value)#播放血糖数值
+ EventMesh.subscribe("set_sim_mode", self.set_sim_mode)#sim检测
+ EventMesh.subscribe("close_hr_sop2", self.close_hr_sop2)#关闭健康测试
+ EventMesh.subscribe("set_manual_measure_mode", self.set_manual_measure_mode)#设置测试模式
+ EventMesh.subscribe("set_start_measure_time", self.set_start_measure_time)#设置开始测量的时间戳时间
+ EventMesh.subscribe("get_start_measure_time", self.get_start_measure_time)#获取开始测量的时间戳时间
+ EventMesh.subscribe("set_start_temp_measure_time", self.set_start_temp_measure_time)#设置体温开始测量的时间戳时间
+ EventMesh.subscribe("get_start_temp_measure_time", self.get_start_temp_measure_time)#获取体温开始测量的时间戳时间
+ EventMesh.subscribe("play_hr_value", self.play_hr_value)#播放心率数值
+ EventMesh.subscribe("play_spo2_value", self.play_spo2_value)#播放心率数值
+ EventMesh.subscribe("play_temp_value", self.play_temp_value)#播放体温数值
- EventMesh.subscribe("set_usb", self.set_usb)#
- EventMesh.subscribe("get_usb", self.get_usb)#
+ EventMesh.subscribe("play_sugar_value", self.play_sugar_value)#播放血糖数值
- EventMesh.subscribe("play_cur_step_event", self.play_cur_step_event)#
- EventMesh.subscribe("set_call_state", self.set_call_state)#1是 拨出去呼叫中 2是播进来 3 是正在通话中 0是无效
- EventMesh.subscribe("get_call_state", self.get_call_state)#
- EventMesh.subscribe("interup_call_event", self.interup_call_event)#
- EventMesh.subscribe("answer_call_event", self.answer_call_event)#接听电话
- EventMesh.subscribe("dialin_call_event", self.dialin_call_event)#电话拨进响铃
- EventMesh.subscribe("dialing_out_event", self.dialing_out_event)#电话呼叫中
- EventMesh.subscribe("call_test_event", self.call_test_event)#电话拨进响铃测试
+ EventMesh.subscribe("set_usb", self.set_usb)#
+ EventMesh.subscribe("get_usb", self.get_usb)#
- EventMesh.subscribe("dial_out_call_center_cb", self.dial_out_call_center_cb)#电话拨出去
- EventMesh.subscribe("sos_out_call_center_cb", self.sos_out_call_center_cb)#sos拨打
+ EventMesh.subscribe("play_cur_step_event", self.play_cur_step_event)#
- EventMesh.subscribe("close_audio_play", self.close_audio_play)#关闭音频
+ EventMesh.subscribe("set_call_state", self.set_call_state)#1是 拨出去呼叫中 2是播进来 3 是正在通话中 0是无效
+ EventMesh.subscribe("get_call_state", self.get_call_state)#
+ EventMesh.subscribe("interup_call_event", self.interup_call_event)#
+ EventMesh.subscribe("answer_call_event", self.answer_call_event)#接听电话
+ EventMesh.subscribe("dialin_call_event", self.dialin_call_event)#电话拨进响铃
+ EventMesh.subscribe("dialing_out_event", self.dialing_out_event)#电话呼叫中
+ EventMesh.subscribe("call_test_event", self.call_test_event)#电话拨进响铃测试
+ EventMesh.subscribe("dial_out_call_center_cb", self.dial_out_call_center_cb)#电话拨出去
+ EventMesh.subscribe("sos_out_call_center_cb", self.sos_out_call_center_cb)#sos拨打
- EventMesh.subscribe("start_wechat_record", self.start_wechat_record)#手表开始录音
- EventMesh.subscribe("send_wechat_record", self.send_wechat_record)#发送微聊语音文件to app
- EventMesh.subscribe("play_wechat_last_amr", self.play_wechat_last_amr)#播放微聊语音最后一条语音文件
- EventMesh.subscribe("get_wechat_data", self.get_wechat_data)
- EventMesh.subscribe("set_wechat_data", self.set_wechat_data)
- EventMesh.subscribe("play_unread_wechat_infor", self.play_unread_wechat_infor)#按键播放最近一条微聊语音
- EventMesh.subscribe("set_unread_wechat_state", self.set_unread_wechat_state)#设置未读标识
- EventMesh.subscribe("get_unread_wechat_state", self.get_unread_wechat_state)#获取未读标志
- EventMesh.subscribe("get_wechat_time", self.get_wechat_time)#获取微聊时间戳
- EventMesh.subscribe("get_wechat_state", self.get_wechat_state)#获取微聊时间戳
+ EventMesh.subscribe("close_audio_play", self.close_audio_play)#关闭音频
- EventMesh.subscribe("get_power_on_state", self.get_power_on_state)#获取开机标识
- EventMesh.subscribe("get_power_off_state", self.get_power_off_state)#获取关机标识
+ EventMesh.subscribe("start_wechat_record", self.start_wechat_record)#手表开始录音
+ EventMesh.subscribe("send_wechat_record", self.send_wechat_record)#发送微聊语音文件to app
+ EventMesh.subscribe("play_wechat_last_amr", self.play_wechat_last_amr)#播放微聊语音最后一条语音文件
+ EventMesh.subscribe("get_wechat_data", self.get_wechat_data)
+ EventMesh.subscribe("set_wechat_data", self.set_wechat_data)
+ EventMesh.subscribe("play_unread_wechat_infor", self.play_unread_wechat_infor)#按键播放最近一条微聊语音
+ EventMesh.subscribe("set_unread_wechat_state", self.set_unread_wechat_state)#设置未读标识
+ EventMesh.subscribe("get_unread_wechat_state", self.get_unread_wechat_state)#获取未读标志
+ EventMesh.subscribe("get_wechat_time", self.get_wechat_time)#获取微聊时间戳
+ EventMesh.subscribe("get_wechat_state", self.get_wechat_state)#获取微聊时间戳
- EventMesh.subscribe("play_audio_file", self.play_audio_file)#获取播放音频文件
- EventMesh.subscribe("OPEN_ALARM_RING", self.send_alarm_ring)#闹钟到点响铃
- EventMesh.subscribe("STOP_ALARM_RING", self.stop_alarm_ring)#是否需要关闭闹钟
+ EventMesh.subscribe("get_power_on_state", self.get_power_on_state)#获取开机标识
+ EventMesh.subscribe("get_power_off_state", self.get_power_off_state)#获取关机标识
- EventMesh.subscribe("recv_wechat_audio", self.recv_wechat_audio)#
+ EventMesh.subscribe("play_audio_file", self.play_audio_file)#获取播放音频文件
+ EventMesh.subscribe("OPEN_ALARM_RING", self.send_alarm_ring)#闹钟到点响铃
+ EventMesh.subscribe("STOP_ALARM_RING", self.stop_alarm_ring)#是否需要关闭闹钟
- EventMesh.subscribe("sos_short_press", self.sos_short_press)#sos短按事件
+ EventMesh.subscribe("recv_wechat_audio", self.recv_wechat_audio)#
- EventMesh.subscribe("falldown_alarm_event", self.falldown_alarm_event)#跌倒报警
- EventMesh.subscribe("close_falldown_alarm_event", self.close_falldown_alarm_event)#关闭跌倒报警
+ EventMesh.subscribe("sos_short_press", self.sos_short_press)#sos短按事件
- EventMesh.subscribe("drink_alarm_event", self.drink_alarm_event)#该喝水了
+ EventMesh.subscribe("falldown_alarm_event", self.falldown_alarm_event)#跌倒报警
- EventMesh.subscribe("medicine_alarm_event", self.medicine_alarm_event)#该吃药了
+ EventMesh.subscribe("close_falldown_alarm_event", self.close_falldown_alarm_event)#关闭跌倒报警
- EventMesh.subscribe("wakeup_alarm_event", self.wakeup_alarm_event)#该起床了
+ EventMesh.subscribe("drink_alarm_event", self.drink_alarm_event)#该喝水了
- EventMesh.subscribe("home_alarm_event", self.home_alarm_event)#该回家了
+ EventMesh.subscribe("medicine_alarm_event", self.medicine_alarm_event)#该吃药了
- EventMesh.subscribe("sleep_alarm_event", self.sleep_alarm_event)#该睡觉了
+ EventMesh.subscribe("wakeup_alarm_event", self.wakeup_alarm_event)#该起床了
- EventMesh.subscribe("reset_alarm_event", self.reset_alarm_event)#该休息了
+ EventMesh.subscribe("home_alarm_event", self.home_alarm_event)#该回家了
- EventMesh.subscribe("reset_end_alarm_event", self.reset_end_alarm_event)#休息结束了
+ EventMesh.subscribe("sleep_alarm_event", self.sleep_alarm_event)#该睡觉了
- EventMesh.subscribe("get_fall_down_state", self.get_fall_down_state)#è·\8cå\80\92æ\8a¥è¦æ \87è¯\86
+ EventMesh.subscribe("reset_alarm_event", self.reset_alarm_event)#该ä¼\91æ\81¯äº\86
- EventMesh.subscribe("app_factory", self.app_factory)#app恢复出厂
+ EventMesh.subscribe("reset_end_alarm_event", self.reset_end_alarm_event)#休息结束了
- EventMesh.subscribe("app_restart", self.app_restart)#远程重启
+ EventMesh.subscribe("get_fall_down_state", self.get_fall_down_state)#跌倒报警标识
-
+ EventMesh.subscribe("app_factory", self.app_factory)#app恢复出厂
- def interInfo_queue_thread(self):
- while True:
- data = self.interInfo_queue.get()
- #EventMesh.debug_log("interInfo_queue_thread:data = {}".format(data))
- if data != None:
- try:
- data["func"](data["data"])
- except Exception as e:
- EventMesh.debug_log("interInfo_queue_thread:ERROR:{}".format(e))
- usys.print_exception(e)
-
- def publish_message_event_interInfo(self,event,msg):
- self.interInfo_queue.put(msg)
-
- def publish_call_event_cb(self, *args, **kwargs):#拨打电话
- EventMesh.publish("publish_message_event_interInfo",{"func":self.call_timer_cb,"data":0})
-
- def publish_resatrt_down_event_cb(self, *args, **kwargs):#重启设备
- EventMesh.publish("publish_message_event_interInfo",{"func":self.powe_resatrt_down_fun,"data":0})
-
- def publish_power_down_event_cb(self, *args, **kwargs):#关机
- EventMesh.publish("publish_message_event_interInfo",{"func":self.power_down_fun,"data":0})
+ EventMesh.subscribe("app_restart", self.app_restart)#远程重启
- def publish_find_watch_event_cb(self, *args, **kwargs):#查找设备
- EventMesh.publish("publish_message_event_interInfo",{"func":self.FIND_timer_cb,"data":0})
+
- def publish_alarm_ring_event_cb(self, *args, **kwargs):#闹钟响铃
- EventMesh.publish("publish_message_event_interInfo",{"func":self.Alarm_timer_cb,"data":0})
+ def interInfo_queue_thread(self):
+ while True:
+ data = self.interInfo_queue.get()
+ #EventMesh.debug_log("interInfo_queue_thread:data = {}".format(data))
+ if data != None:
+ try:
+ data["func"](data["data"])
+ except Exception as e:
+ EventMesh.debug_log("interInfo_queue_thread:ERROR:{}".format(e))
+ usys.print_exception(e)
+
+ def publish_message_event_interInfo(self,event,msg):
+ self.interInfo_queue.put(msg)
+
+ def publish_call_event_cb(self, *args, **kwargs):#拨打电话
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.call_timer_cb,"data":0})
+
+ def publish_resatrt_down_event_cb(self, *args, **kwargs):#重启设备
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.powe_resatrt_down_fun,"data":0})
+
+ def publish_power_down_event_cb(self, *args, **kwargs):#关机
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.power_down_fun,"data":0})
- def publish_reset_alarm_ring_event_cb(self, *args, **kwargs):#休息响铃
- EventMesh.publish("publish_message_event_interInfo",{"func":self.reset_alarm_event_cb,"data":0})
-
- def publish_reset_end_alarm_ring_event_cb(self, *args, **kwargs):#休息结束响铃
- EventMesh.publish("publish_message_event_interInfo",{"func":self.reset_end_alarm_event_cb,"data":0})
-
- def publish_sleep_alarm_ring_event_cb(self, *args, **kwargs):#睡觉响铃
- EventMesh.publish("publish_message_event_interInfo",{"func":self.sleep_alarm_event_cb,"data":0})
-
- def publish_home_ring_event_cb(self, *args, **kwargs):#回家响铃
- EventMesh.publish("publish_message_event_interInfo",{"func":self.home_alarm_event_cb,"data":0})
+ def publish_find_watch_event_cb(self, *args, **kwargs):#查找设备
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.FIND_timer_cb,"data":0})
+
+ def publish_alarm_ring_event_cb(self, *args, **kwargs):#闹钟响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.Alarm_timer_cb,"data":0})
+
+ def publish_reset_alarm_ring_event_cb(self, *args, **kwargs):#休息响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.reset_alarm_event_cb,"data":0})
+
+ def publish_reset_end_alarm_ring_event_cb(self, *args, **kwargs):#休息结束响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.reset_end_alarm_event_cb,"data":0})
+
+ def publish_sleep_alarm_ring_event_cb(self, *args, **kwargs):#睡觉响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.sleep_alarm_event_cb,"data":0})
+
+ def publish_home_ring_event_cb(self, *args, **kwargs):#回家响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.home_alarm_event_cb,"data":0})
- def publish_wakeup_ring_event_cb(self, *args, **kwargs):#起床响铃
- EventMesh.publish("publish_message_event_interInfo",{"func":self.wakeup_alarm_event_cb,"data":0})
+ def publish_wakeup_ring_event_cb(self, *args, **kwargs):#起床响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.wakeup_alarm_event_cb,"data":0})
- def publish_medicine_ring_event_cb(self, *args, **kwargs):#吃药响铃
- EventMesh.publish("publish_message_event_interInfo",{"func":self.medicine_alarm_event_cb,"data":0})
+ def publish_medicine_ring_event_cb(self, *args, **kwargs):#吃药响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.medicine_alarm_event_cb,"data":0})
- def publish_drink_ring_event_cb(self, *args, **kwargs):#喝水响铃
- EventMesh.publish("publish_message_event_interInfo",{"func":self.drink_alarm_event_cb,"data":0})
+ def publish_drink_ring_event_cb(self, *args, **kwargs):#喝水响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.drink_alarm_event_cb,"data":0})
- def publish_fall_done_ring_event_cb(self, *args, **kwargs):#跌倒提醒
- EventMesh.publish("publish_message_event_interInfo",{"func":self.falldown_alarm_cb,"data":0})
+ def publish_fall_done_ring_event_cb(self, *args, **kwargs):#跌倒提醒
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.falldown_alarm_cb,"data":0})
- def reset_alarm_event(self,args,msg):#该休息了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count = 0
- self.alarm_timer1.start(2000, 1, self.publish_reset_alarm_ring_event_cb)
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- def reset_alarm_event_cb(self,args):#该休息了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count += 1
- if self.alarm_count >= 3:
+ def reset_alarm_event(self,args,msg):#该休息了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_reset_alarm_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ def reset_alarm_event_cb(self,args):#该休息了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
self.alarm_count = 0
self.alarm_timer1.stop()
- return
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- else:
- self.alarm_count = 0
- self.alarm_timer1.stop()
- def reset_end_alarm_event(self,args,msg):#休息结束了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count = 0
- self.alarm_timer1.start(2000, 1, self.reset_end_alarm_event_cb)
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_END_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
-
- def reset_end_alarm_event_cb(self,args):#休息结束了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count += 1
- if self.alarm_count >= 3:
+ def reset_end_alarm_event(self,args,msg):#休息结束了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.reset_end_alarm_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_END_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+ def reset_end_alarm_event_cb(self,args):#休息结束了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_END_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
self.alarm_count = 0
self.alarm_timer1.stop()
- return
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_END_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- else:
- self.alarm_count = 0
- self.alarm_timer1.stop()
-
- def sleep_alarm_event(self,args,msg):#该睡觉了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count = 0
- self.alarm_timer1.start(2000, 1, self.publish_sleep_alarm_ring_event_cb)
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SLEEP_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- def sleep_alarm_event_cb(self,args):#该睡觉了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count += 1
- if self.alarm_count >= 3:
+
+ def sleep_alarm_event(self,args,msg):#该睡觉了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_sleep_alarm_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SLEEP_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ def sleep_alarm_event_cb(self,args):#该睡觉了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SLEEP_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
self.alarm_count = 0
self.alarm_timer1.stop()
- return
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SLEEP_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- else:
- self.alarm_count = 0
- self.alarm_timer1.stop()
- def home_alarm_event(self,args,msg):#该回家了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count = 0
- self.alarm_timer1.start(2000, 1, self.publish_home_ring_event_cb)
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HOME_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
-
- def home_alarm_event_cb(self,args):#该回家了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count += 1
- if self.alarm_count >= 3:
+ def home_alarm_event(self,args,msg):#该回家了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_home_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HOME_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+ def home_alarm_event_cb(self,args):#该回家了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HOME_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
self.alarm_count = 0
self.alarm_timer1.stop()
- return
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HOME_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- else:
- self.alarm_count = 0
- self.alarm_timer1.stop()
-
- def wakeup_alarm_event(self,args,msg):#该起床了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count = 0
- self.alarm_timer1.start(2000, 1, self.publish_wakeup_ring_event_cb)
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_WAKEUP_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
-
- def wakeup_alarm_event_cb(self,args):#该起床了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count += 1
- if self.alarm_count >= 3:
+
+ def wakeup_alarm_event(self,args,msg):#该起床了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_wakeup_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_WAKEUP_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+ def wakeup_alarm_event_cb(self,args):#该起床了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_WAKEUP_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
self.alarm_count = 0
self.alarm_timer1.stop()
- return
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_WAKEUP_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- else:
- self.alarm_count = 0
- self.alarm_timer1.stop()
- def medicine_alarm_event(self,args,msg):#该吃药了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count = 0
- self.alarm_timer1.start(2000, 1, self.publish_medicine_ring_event_cb)
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_MEDICINE_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ def medicine_alarm_event(self,args,msg):#该吃药了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_medicine_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_MEDICINE_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- def medicine_alarm_event_cb(self,args):#该吃药了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count += 1
- if self.alarm_count >= 3:
+ def medicine_alarm_event_cb(self,args):#该吃药了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_MEDICINE_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
self.alarm_count = 0
self.alarm_timer1.stop()
- return
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_MEDICINE_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- else:
- self.alarm_count = 0
- self.alarm_timer1.stop()
- def drink_alarm_event(self,args,msg):#该喝水了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count = 0
- self.alarm_timer1.start(2000, 1, self.publish_drink_ring_event_cb)
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_DRINK_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
-
+ def drink_alarm_event(self,args,msg):#该喝水了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_drink_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_DRINK_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
- def drink_alarm_event_cb(self,args):#该喝水了
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
- self.alarm_count += 1# 1 2
- if self.alarm_count >= 3:
+ def drink_alarm_event_cb(self,args):#该喝水了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1# 1 2
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_DRINK_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
self.alarm_count = 0
self.alarm_timer1.stop()
- return
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_DRINK_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- else:
- self.alarm_count = 0
- self.alarm_timer1.stop()
-
- def falldown_alarm_event(self,args,msg):#跌倒报警启动中提示
- flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
- wechat_state = EventMesh.publish("get_wechat_state")
- if flag == 0 and wechat_state == 0:
- EventMesh.publish("close_timer_all")#
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_FALL_ALARM"))
- self.time_count = 0
- self.fall_flag = 0
- self.fall_timer1.stop()
- self.fall_flag = 1
- self.fall_timer1.start(4000, 1, self.publish_fall_done_ring_event_cb)
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
-
- def falldown_alarm_cb(self,*args):
- wechat_state = EventMesh.publish("get_wechat_state")
- if self.call_state == 0 and wechat_state == 0:
- self.time_count+=1
- if self.time_count >= 5:
+
+ def falldown_alarm_event(self,args,msg):#跌倒报警启动中提示
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if flag == 0 and wechat_state == 0:
+ EventMesh.publish("close_timer_all")#
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_FALL_ALARM"))
self.time_count = 0
+ self.fall_flag = 0
self.fall_timer1.stop()
- EventMesh.publish_async("dial_sos_phone")#拨打sos号码
- return
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_FALL_ALARM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- else:
- self.time_count = 0
- self.fall_timer1.stop()
-
- def close_falldown_alarm_event(self,event,msg):#跌倒挂断挂断
- if self.fall_flag == 1:#跌倒标志
- self.fall_flag = 0
- self.fall_timer1.stop()
- self.sos_timer1.stop()
- self.sos_timer2.stop()
- if self.call_state != 0:
- self.call_state = 0
- voiceCall.callEnd()
- sos_flag = EventMesh.publish("get_sos_flag")
- if sos_flag == 1:
- self.call_state = 0
- EventMesh.publish("set_sos_flag",0)
- EventMesh.publish("set_sos_num",0)
- EventMesh.publish("set_hangup_mode",0)
+ self.fall_flag = 1
+ self.fall_timer1.start(4000, 1, self.publish_fall_done_ring_event_cb)
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
-
+ def falldown_alarm_cb(self,*args):
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0:
+ self.time_count+=1
+ if self.time_count >= 5:
+ self.time_count = 0
+ self.fall_timer1.stop()
+ EventMesh.publish_async("dial_sos_phone")#拨打sos号码
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_FALL_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
+ self.time_count = 0
+ self.fall_timer1.stop()
+
+ def close_falldown_alarm_event(self,event,msg):#跌倒挂断挂断
+ if self.fall_flag == 1:#跌倒标志
+ self.fall_flag = 0
+ self.fall_timer1.stop()
+ self.sos_timer1.stop()
+ self.sos_timer2.stop()
+ if self.call_state != 0:
+ self.call_state = 0
+ voiceCall.callEnd()
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ self.call_state = 0
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("set_hangup_mode",0)
- def send_find_watch(self, event, msg): #发送查找设备指令
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- power_off = EventMesh.publish("get_power_off_state")#获取开机标识
- if power_off != None:
- if power_off == 1:
- return
- flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
- wechat_state = EventMesh.publish("get_wechat_state")
- if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
- EventMesh.publish("close_timer_all")#
- self.find_state = 1
- self.FIND_timer_count = 0
- self.alarm_timer1.start(3000,1,self.publish_find_watch_event_cb)
- EventMesh.publish("set_led_time_arg",[1,1,330,led_mode.LONG_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
- # EventMesh.publish("set_led_time_arg",[1000,33000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("audio_find_haixiu"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- def stop_find_watch(self, event, msg):
- if self.find_state == 1:
- self.find_state = 0
- self.FIND_timer_count = 0
- # EventMesh.publish("stop_led_timer")#设置参数
- self.aud.stopPlayStream() #播放声音
- self.alarm_timer1.stop()
+
- def FIND_timer_cb(self, data):
- flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
- wechat_state = EventMesh.publish("get_wechat_state")
- if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
- if self.find_state == 1:
- # EventMesh.debug_log("self.FIND_timer_count:{}".format(self.FIND_timer_count))
+ def send_find_watch(self, event, msg): #发送查找设备指令
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ self.find_state = 1
+ self.FIND_timer_count = 0
+ self.alarm_timer1.start(3000,1,self.publish_find_watch_event_cb)
+ EventMesh.publish("set_led_time_arg",[1,1,330,led_mode.LONG_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,33000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
str_data = 'mp3files={}.mp3'.format(audio_buf.index("audio_find_haixiu"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- self.FIND_timer_count += 1
- if self.FIND_timer_count > 10: #120秒30s
- EventMesh.publish("STOP_FIND_WATCH")
- else:
- self.FIND_timer_count = 0
- self.alarm_timer1.stop()
-
-
- def stop_FIND(self) :
- self.alarm_timer1.stop()
+
+ def stop_find_watch(self, event, msg):
+ if self.find_state == 1:
+ self.find_state = 0
+ self.FIND_timer_count = 0
+ # EventMesh.publish("stop_led_timer")#设置参数
+ self.aud.stopPlayStream() #播放声音
+ self.alarm_timer1.stop()
- def send_alarm_ring(self, event, msg): #发送查找设备指令
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- power_off = EventMesh.publish("get_power_off_state")#获取开机标识
- if power_off != None:
- if power_off == 1:
- return
- flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
- wechat_state = EventMesh.publish("get_wechat_state")
- if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
- EventMesh.publish("close_timer_all")#
- self.alarm_state = 1
- self.alarm_timer_count = 0
- self.alarm_timer1.start(3000,1,self.publish_alarm_ring_event_cb)
- # EventMesh.publish("set_led_time_arg",[1,1,330,led_mode.LONG_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
- # EventMesh.publish("set_led_time_arg",[1000,33000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_ALARM_NEW"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- def stop_alarm_ring(self, event, msg): #停止闹钟响铃
- if self.alarm_state == 1:
- self.alarm_state = 0
- self.alarm_timer_count = 0
- # EventMesh.publish("stop_led_timer")#设置参数
- self.aud.stopPlayStream() #停止播放
+ def FIND_timer_cb(self, data):
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
+ if self.find_state == 1:
+ # EventMesh.debug_log("self.FIND_timer_count:{}".format(self.FIND_timer_count))
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("audio_find_haixiu"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ self.FIND_timer_count += 1
+ if self.FIND_timer_count > 10: #120秒30s
+ EventMesh.publish("STOP_FIND_WATCH")
+ else:
+ self.FIND_timer_count = 0
+ self.alarm_timer1.stop()
+
+
+ def stop_FIND(self) :
self.alarm_timer1.stop()
- def Alarm_timer_cb(self, data):
- flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
- wechat_state = EventMesh.publish("get_wechat_state")
- if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
- if self.alarm_state == 1:
- # EventMesh.debug_log("self.alarm_timer_count:{}".format(self.alarm_timer_count))
+ def send_alarm_ring(self, event, msg): #发送查找设备指令
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ self.alarm_state = 1
+ self.alarm_timer_count = 0
+ self.alarm_timer1.start(3000,1,self.publish_alarm_ring_event_cb)
+ # EventMesh.publish("set_led_time_arg",[1,1,330,led_mode.LONG_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,33000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_ALARM_NEW"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- self.alarm_timer_count += 1
- if self.alarm_timer_count > 15: #120秒30s
- EventMesh.publish("STOP_ALARM_RING")
- else:
- self.alarm_timer_count = 0
- self.alarm_timer1.stop()
+
+ def stop_alarm_ring(self, event, msg): #停止闹钟响铃
+ if self.alarm_state == 1:
+ self.alarm_state = 0
+ self.alarm_timer_count = 0
+ # EventMesh.publish("stop_led_timer")#设置参数
+ self.aud.stopPlayStream() #停止播放
+ self.alarm_timer1.stop()
- def get_fall_down_state(self,event,msg):
- return self.fall_flag
+ def Alarm_timer_cb(self, data):
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
+ if self.alarm_state == 1:
+ # EventMesh.debug_log("self.alarm_timer_count:{}".format(self.alarm_timer_count))
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_ALARM_NEW"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ self.alarm_timer_count += 1
+ if self.alarm_timer_count > 15: #120秒30s
+ EventMesh.publish("STOP_ALARM_RING")
+ else:
+ self.alarm_timer_count = 0
+ self.alarm_timer1.stop()
- def sos_short_press(self,args,msg):
- EventMesh.publish("interup_call_event")#如果在电话中强制挂断电话
- EventMesh.publish("close_audio_play")#强制关闭音频文件播放
- EventMesh.publish("STOP_FIND_WATCH")#停止查找设备
- EventMesh.publish("STOP_ALARM_RING")#停止闹钟响铃
- EventMesh.publish("play_cur_time_event")#播报当前时间
- #播报当前时间
+ def get_fall_down_state(self,event,msg):
+ return self.fall_flag
- def recv_wechat_audio(self,event,str_data):#接收微聊语音播放
- if self.call_state == 0 and self.fall_flag == 0:
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_WECHAT_RECV"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ def sos_short_press(self,args,msg):
+ EventMesh.publish("interup_call_event")#如果在电话中强制挂断电话
+ EventMesh.publish("close_audio_play")#强制关闭音频文件播放
+ EventMesh.publish("STOP_FIND_WATCH")#停止查找设备
+ EventMesh.publish("STOP_ALARM_RING")#停止闹钟响铃
+ EventMesh.publish("play_cur_time_event")#播报当前时间
+ #播报当前时间
+ def recv_wechat_audio(self,event,str_data):#接收微聊语音播放
+ if self.call_state == 0 and self.fall_flag == 0:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_WECHAT_RECV"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- def audio_event_queue_thread(self):
- while True:
- data = self.audio_event_queue.get()
- #EventMesh.debug_log("audio_event_queue:data = {}".format(data))
- if data != None:
- try:
- data["func"](data["data"])
- except Exception as e:
- EventMesh.debug_log("audio_event_queue:ERROR:{}".format(e))
- usys.print_exception(e)
- def publish_message_event_audio(self,event,msg):
- self.audio_event_queue.put(msg)
-
- def play_audio_file(self, *args, **kwargs):#播放音频文件
- # EventMesh.debug_log("args",args)
- EventMesh.publish("publish_message_event_audio",{"func":self.play_audio_file_do,"data":args[1]})
-
- def play_audio_file_do(self,data):#msg 拼接的路径文件
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- power_off = EventMesh.publish("get_power_off_state")#获取开机标识
- # EventMesh.debug_log("play_audio_file",data[0],data[1],open_power,power_off)#路径 str_data[1] 是否需要被打断
- if open_power != None:
- if open_power == 0:
- return
- if power_off != None:
- if power_off == 1:
- return
- self.aud.montage_play('U:/static/audio.bin',1,data[1],data[0])
- # EventMesh.debug_log("play_audio_file end",data[0],data[1])#路径 str_data[1] 是否需要被打断
-
+ def audio_event_queue_thread(self):
+ while True:
+ data = self.audio_event_queue.get()
+ #EventMesh.debug_log("audio_event_queue:data = {}".format(data))
+ if data != None:
+ try:
+ data["func"](data["data"])
+ except Exception as e:
+ EventMesh.debug_log("audio_event_queue:ERROR:{}".format(e))
+ usys.print_exception(e)
+ def publish_message_event_audio(self,event,msg):
+ self.audio_event_queue.put(msg)
+
+ def play_audio_file(self, *args, **kwargs):#播放音频文件
+ # EventMesh.debug_log("args",args)
+ EventMesh.publish("publish_message_event_audio",{"func":self.play_audio_file_do,"data":args[1]})
+
+ def play_audio_file_do(self,data):#msg 拼接的路径文件
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ # EventMesh.debug_log("play_audio_file",data[0],data[1],open_power,power_off)#路径 str_data[1] 是否需要被打断
+ if open_power != None:
+ if open_power == 0:
+ return
+ if power_off != None:
+ if power_off == 1:
+ return
+ self.aud.montage_play('U:/static/audio.bin',1,data[1],data[0])
+ # EventMesh.debug_log("play_audio_file end",data[0],data[1])#路径 str_data[1] 是否需要被打断
+
- def powe_resatrt_down_fun(self, *args):#重启设备
- EventMesh.publish("close_led_pin")
- self.aud.stopPlayStream()
- Power.powerRestart()
- def power_down_fun(self, *args):
- EventMesh.publish("close_led_pin")
- self.aud.stopPlayStream()
- Power.powerDown()
+ def powe_resatrt_down_fun(self, *args):#重启设备
+ EventMesh.publish("close_led_pin")
+ self.aud.stopPlayStream()
+ Power.powerRestart()
+ def power_down_fun(self, *args):
+ EventMesh.publish("close_led_pin")
+ self.aud.stopPlayStream()
+ Power.powerDown()
- def close_audio_play(self, event, msg): #msg
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- power_off = EventMesh.publish("get_power_off_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- if power_off != None:
- if power_off == 1:
- return
- self.aud.stopPlayStream()
+ def close_audio_play(self, event, msg): #msg
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ if power_off != None:
+ if power_off == 1:
+ return
+ self.aud.stopPlayStream()
- def close_timer_all(self, event, msg):
- # EventMesh.debug_log("close_timer_all!!!!!!!!!!!!!!!!!!!")
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- power_off = EventMesh.publish("get_power_off_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- if power_off != None:
- if power_off == 1:
- return
- self.aud.stopPlayStream()
-
+
+ def close_timer_all(self, event, msg):
+ # EventMesh.debug_log("close_timer_all!!!!!!!!!!!!!!!!!!!")
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ if power_off != None:
+ if power_off == 1:
+ return
+ self.aud.stopPlayStream()
+
+
+ self.timer.stop()
+ self.sos_timer2.stop()
+ self.sos_timer1.stop()
+ self.fall_flag = 0
+ self.fall_timer1.stop()
+ self.alarm_timer1.stop()
- self.timer.stop()
- self.sos_timer2.stop()
- self.sos_timer1.stop()
- self.fall_flag = 0
- self.fall_timer1.stop()
- self.alarm_timer1.stop()
-
-
- def answer_call_event(self, event, msg): #
- if self.call_state == 2:
- sos_flag = EventMesh.publish("get_sos_flag")
- if sos_flag == 1:
- self.call_state = 0
- EventMesh.publish("set_sos_flag",0)
- EventMesh.publish("set_sos_num",0)
- EventMesh.publish("set_hangup_mode",0)
- EventMesh.publish("close_timer_all")#
- voiceCall.callAnswer()
- def set_call_state(self, event, msg): #
- self.call_state = msg
+ def answer_call_event(self, event, msg): #
+ if self.call_state == 2:
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ self.call_state = 0
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("set_hangup_mode",0)
+ EventMesh.publish("close_timer_all")#
+ voiceCall.callAnswer()
- def dialin_call_event(self, event, msg):
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- power_off = EventMesh.publish("get_power_off_state")#获取开机标识
- if power_off != None:
- if power_off == 1:
- return
- EventMesh.publish("close_timer_all")#
- EventMesh.publish("close_wechat_btn_timer")#
- self.timer.start(6000, 1, self.publish_call_event_cb)
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CALL_mp3"))
- EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件
- # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- def call_timer_cb(self,data):
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- power_off = EventMesh.publish("get_power_off_state")#获取开机标识
- if power_off != None:
- if power_off == 1:
- return
- if self.call_state != 2:
+ def set_call_state(self, event, msg): #
+ self.call_state = msg
+
+ def dialin_call_event(self, event, msg):
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
EventMesh.publish("close_timer_all")#
- return
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CALL_mp3"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
-
- def dial_out_call_center_cb(self, event, msg):#电话拨出去
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- power_off = EventMesh.publish("get_power_off_state")#获取开机标识
- if power_off != None:
- if power_off == 1:
+ EventMesh.publish("close_wechat_btn_timer")#
+ EventMesh.publish("set_led_time_arg",[1,2,10*10,led_mode.FLASH_LIGHT_RED,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
+ self.timer.start(6000, 1, self.publish_call_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CALL_mp3"))
+ EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件
+ # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ def call_timer_cb(self,data):
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ if self.call_state != 2:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("close_timer_all")#
return
- # EventMesh.debug_log("dial_out_call_center_cb",msg)
- if self.call_state == 0:
- self.phone_num = ''
- EventMesh.publish("close_timer_all")#
- if msg == None:
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- self.phone_num = str(msg)
- self.timer1.start(2000, 0, self.time_out_phone)
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
- EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件
-
- def time_out_phone(self, msg):#电话拨出去
- voiceCall.callStart(self.phone_num)
+ EventMesh.publish("set_led_time_arg",[1,2,10*10,led_mode.FLASH_LIGHT_RED,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CALL_mp3"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+ def dial_out_call_center_cb(self, event, msg):#电话拨出去
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ # EventMesh.debug_log("dial_out_call_center_cb",msg)
+ if self.call_state == 0:
+ self.phone_num = ''
+ EventMesh.publish("close_timer_all")#
+ if msg == None:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ self.phone_num = str(msg)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
+ EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件
+ self.timer1.start(2000, 0, self.time_out_phone)
+
+
+ def time_out_phone(self, msg):#电话拨出去
+ voiceCall.callStart(self.phone_num)
- def sos_out_call_center_cb(self, event, msg):#sos电话呼叫中
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- power_off = EventMesh.publish("get_power_off_state")#获取开机标识
- if power_off != None:
- if power_off == 1:
- return
- self.sos_phone_num = ''
- # EventMesh.debug_log("sos_out_call_center_cb",msg)
- if self.call_state == 0:
-
- EventMesh.publish("close_timer_all")#
- if msg == None:
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
- # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- sos_state = EventMesh.publish("get_dev_state")
+ def sos_out_call_center_cb(self, event, msg):#sos电话呼叫中
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ self.sos_phone_num = ''
+ # EventMesh.debug_log("sos_out_call_center_cb",msg)
+ if self.call_state == 0:
+
+ EventMesh.publish("close_timer_all")#
+ if msg == None:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ sos_state = EventMesh.publish("get_dev_state")
- tmp = 1 << 16
- sos_state = sos_state|tmp #第21位=1
- EventMesh.publish("set_dev_state",sos_state)
+ tmp = 1 << 16
+ sos_state = sos_state|tmp #第21位=1
+ EventMesh.publish("set_dev_state",sos_state)
- EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,sos_state]) #开始AL定位
- EventMesh.publish("close_timer_all")#
- self.sos_phone_num = msg
- self.sos_timer1.start(2000, 0, self.sos_call_out_phone)
- self.sos_timer2.start(30000, 0, self.sos_time_out_phone)
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
- EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件
-
- def sos_time_out_phone(self, msg):#30s超时未打通或者信号不好则重新拨打
- sos_flag = EventMesh.publish("get_sos_flag")
- if sos_flag == 1:
- if self.call_state == 0:
- EventMesh.publish("set_sos_info_call")
-
- def sos_call_out_phone(self, msg):#电话拨出去
- voiceCall.callStart(self.sos_phone_num)
-
+ EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,sos_state]) #开始AL定位
+ EventMesh.publish("close_timer_all")#
+ self.sos_phone_num = msg
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
+ EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件
+ self.sos_timer1.start(2000, 0, self.sos_call_out_phone)
+ self.sos_timer2.start(30000, 0, self.sos_time_out_phone)
+
+
+ def sos_time_out_phone(self, msg):#30s超时未打通或者信号不好则重新拨打
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ if self.call_state == 0:
+ EventMesh.publish("set_sos_info_call")
+
+ def sos_call_out_phone(self, msg):#电话拨出去
+ voiceCall.callStart(self.sos_phone_num)
+
- def call_test_event(self, event, msg):
- voiceCall.callStart(str("10086"))
+ def call_test_event(self, event, msg):
+ voiceCall.callStart(str("10086"))
- def get_call_state(self, event, msg):
- return self.call_state
-
- def interup_call_event(self, event, msg):#侧边金属按钮挂断来电
- flag = EventMesh.publish("get_call_state")
- if flag == 2 or flag == 3:#电话通话中 或者呼叫中挂断中断
- self.call_state = 0
- voiceCall.callEnd()
-
- def dialing_out_event(self, event, msg):#侧边金属按键挂断电话呼叫中
- flag = EventMesh.publish("get_call_state")
- if flag == 1:#电话呼叫中
- self.call_state = 0
- voiceCall.callEnd()
-
+ def get_call_state(self, event, msg):
+ return self.call_state
+
+ def interup_call_event(self, event, msg):#侧边金属按钮挂断来电
+ flag = EventMesh.publish("get_call_state")
+ if flag == 2 or flag == 3:#电话通话中 或者呼叫中挂断中断
+ self.call_state = 0
+ voiceCall.callEnd()
+
+ def dialing_out_event(self, event, msg):#侧边金属按键挂断电话呼叫中
+ flag = EventMesh.publish("get_call_state")
+ if flag == 1:#电话呼叫中
+ self.call_state = 0
+ voiceCall.callEnd()
+
- def play_cur_step_event(self, event, msg): #msg 1 播放当前步数
- flag = EventMesh.publish("get_call_state")
- if flag == 0:#电话通话中 或者呼叫中挂断中断
- if self.fall_flag == 0:
- EventMesh.publish("close_timer_all")#
- step = EventMesh.publish("get_old_step_value")
- EventMesh.debug_log("step",step)
- self.setp_old = step
- if step <= 10:#
- if step == 10:#十步
- str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:# 9步
- str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(step)),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- elif step <= 100:#十 90
- if step == 100:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_1"),audio_buf.index("R_READ_STEP_2"),\
- audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- step_tmp = str(step)
- shi_value = int(step_tmp[0])#十
- ge_value = int(step_tmp[1])#个
- if shi_value > 1:#大于19步
- if ge_value == 0:#9十步 70十步
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ def play_cur_step_event(self, event, msg): #msg 1 播放当前步数
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0:#电话通话中 或者呼叫中挂断中断
+ if self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ step = EventMesh.publish("get_old_step_value")
+ EventMesh.debug_log("step",step)
+ self.setp_old = step
+ if step <= 10:#
+ if step == 10:#十步
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:# 9步
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(step)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ elif step <= 100:#十 90
+ if step == 100:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_1"),audio_buf.index("R_READ_STEP_2"),\
audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#9十2步
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
- audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#十9步
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
- audio_buf.index("R_READ_STEP_4"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- elif step <= 1000:
- if step == 1000:#1千步
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_1"),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- step_tmp = str(step)#500
- bai_value = int(step_tmp[0])#百
- shi_value = int(step_tmp[1])#十
- ge_value = int(step_tmp[2])#个
- #101 110 1
- if shi_value > 0:#110
- if ge_value == 0:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
- audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
else:
- if shi_value == 0 and ge_value == 0:#500 600
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- else:
-
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
- audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- elif step <= 10000:#千
- if step == 10000:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_1"),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- else:
- one_thousand = step//1000 #千
- one_hundred = step%1000 #百
- baishu = step%100 #十
- shishu = step%10 #个
- step_tmp = str(step)
- qian = int(step_tmp[0])#千
- bai_value = int(step_tmp[1])#百
- shi_value = int(step_tmp[2])#十
- ge_value = int(step_tmp[3])#个
- if bai_value <= 0:
- if shi_value <= 0:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ step_tmp = str(step)
+ shi_value = int(step_tmp[0])#十
+ ge_value = int(step_tmp[1])#个
+ if shi_value > 1:#大于19步
+ if ge_value == 0:#9十步 70十步
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#9十2步
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#十9步
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
audio_buf.index("R_READ_STEP_4"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- if ge_value == 0:#1020 1040
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ elif step <= 1000:
+ if step == 1000:#1千步
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_1"),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ step_tmp = str(step)#500
+ bai_value = int(step_tmp[0])#百
+ shi_value = int(step_tmp[1])#十
+ ge_value = int(step_tmp[2])#个
+ #101 110 1
+ if shi_value > 0:#110
+ if ge_value == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#1021
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- if shi_value <= 0:#1109
- if ge_value == 0:#1110
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
+ else:
+ if shi_value == 0 and ge_value == 0:#500 600
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_STEP_4"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
+
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
audio_buf.index("R_READ_STEP_4"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- if ge_value == 0:#1110
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#1117
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ pass
+ elif step <= 10000:#千
+ if step == 10000:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_1"),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ one_thousand = step//1000 #千
+ one_hundred = step%1000 #百
+ baishu = step%100 #十
+ shishu = step%10 #个
+ step_tmp = str(step)
+ qian = int(step_tmp[0])#千
+ bai_value = int(step_tmp[1])#百
+ shi_value = int(step_tmp[2])#十
+ ge_value = int(step_tmp[3])#个
+ if bai_value <= 0:
+ if shi_value <= 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- pass
- elif step <= 100000:#万
- if step == 100000:#10万步
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3"),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if ge_value == 0:#1020 1040
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#1021
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
else:
- step_tmp = str(step)
- wang = int(step_tmp[0])#万
- qian = int(step_tmp[1])#千
- bai_value = int(step_tmp[2])#百
- shi_value = int(step_tmp[3])#十
- ge_value = int(step_tmp[4])#个
- if wang > 0 and qian > 0 and bai_value > 0:#11109 11111
- if shi_value <= 0:#11109
- if ge_value == 0:#11100
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#11108
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
- audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
+ if shi_value <= 0:#1109
+ if ge_value == 0:#1110
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
else:
- if ge_value == 0:#11110
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#11116
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- elif wang > 0 and qian > 0:#11000 11010 11012 11008
- if shi_value > 0:
- if ge_value == 0:#11010
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#11016
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- if ge_value == 0:#11000
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#11004
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
- audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
- audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- elif wang > 0:#1
- if bai_value > 0:#百
- if shi_value > 0:#10110
- if ge_value == 0:#10150
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
- audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
- audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#10108
- if ge_value == 0:#10100
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if ge_value == 0:#1110
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#1117
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ pass
+ elif step <= 100000:#万
+ if step == 100000:#10万步
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ step_tmp = str(step)
+ wang = int(step_tmp[0])#万
+ qian = int(step_tmp[1])#千
+ bai_value = int(step_tmp[2])#百
+ shi_value = int(step_tmp[3])#十
+ ge_value = int(step_tmp[4])#个
+ if wang > 0 and qian > 0 and bai_value > 0:#11109 11111
+ if shi_value <= 0:#11109
+ if ge_value == 0:#11100
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_STEP_4"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#10108
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ else:#11108
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
audio_buf.index("R_READ_STEP_4"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
+ pass
+ else:
+ if ge_value == 0:#11110
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#11116
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ elif wang > 0 and qian > 0:#11000 11010 11012 11008
if shi_value > 0:
- if ge_value == 0:#10090
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ if ge_value == 0:#11010
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#10098
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#11016
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if ge_value == 0:#11000
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#11004
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ elif wang > 0:#1
+ if bai_value > 0:#百
+ if shi_value > 0:#10110
+ if ge_value == 0:#10150
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#10108
+ if ge_value == 0:#10100
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#10108
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
- audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
- audio_buf.index("R_READ_STEP_4"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- def set_usb(self, event, msg): #msg 1 正在充电 2充电已移出 3 充电已满 0
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- power_off = EventMesh.publish("get_power_off_state")#获取开机标识
- if power_off != None:
- if power_off == 1:
- return
- flag = EventMesh.publish("get_call_state")
- 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 msg == 1:
- if get_hr_state != None and get_spo2_state != None and get_bp_state != None and get_bg_state != None and get_temp_state != None:
- if get_hr_state != 0:
-
- EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
- if get_hr_state == 1:
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("set_start_measure_time",0)#设置开始测量的时间戳时间
+ if shi_value > 0:
+ if ge_value == 0:#10090
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#10098
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- EventMesh.debug_log("stop debug8")
- EventMesh.publish(constants.EVENT.STOP_HEART)
- elif get_spo2_state != 0:
- EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
- if get_spo2_state == 1:
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
- EventMesh.debug_log("stop debug13")
- elif get_bp_state != 0:
- EventMesh.publish("set_bp_state",0)#2代表后台进入测试
- if get_bp_state == 1:
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish(constants.EVENT.STOP_HEART)
- EventMesh.debug_log("stop bp debug1")
- elif get_bg_state != 0:
- EventMesh.publish("set_bg_state",0)#2代表后台进入测试
- if get_bg_state == 1:#手动开灯关闭灯
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish(constants.EVENT.STOP_HEART)
- EventMesh.debug_log("stop BG debug14")
- if get_temp_state != 0:
-
- EventMesh.publish("set_temp_state",0)#2代表后台进入测试
- if get_temp_state == 1:
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("get_start_temp_measure_time",0)#
- EventMesh.publish(constants.EVENT.STOP_TEMP)
- EventMesh.debug_log("stop temp debug14")
- if msg == 1:
- self.usbState = msg
- str_buf = [1,1,10,led_mode.LONG_LIGHT_RED,4,2,led_mode.CHARGE_IN_MODE]
- EventMesh.publish("set_led_time_arg",str_buf)#
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
- self.aud.stop()
- self.aud.play(1,1,'U:/static/R_CHARGE_IN.mp3')
- # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_IN"))
- # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- EventMesh.debug_log("charge R_CHARGE_IN")
-
-
- elif msg == 2:
- self.usbState = msg
- EventMesh.publish("stop_led_timer")#设置参数
- # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.CHARGE_OUT_MODE])#測量成功
- EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,4,led_mode.CHARGE_OUT_MODE])#測量成功
- EventMesh.debug_log("charge R_CHARGE_OUT")
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
- self.aud.stop()
- self.aud.play(1,1,'U:/static/R_CHARGE_OUT.mp3')
- # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_OUT"))
- # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
+ def set_usb(self, event, msg): #msg 1 正在充电 2充电已移出 3 充电已满 0
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ flag = EventMesh.publish("get_call_state")
+ 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 msg == 1:
+ if get_hr_state != None and get_spo2_state != None and get_bp_state != None and get_bg_state != None and get_temp_state != None:
+ if get_hr_state != 0:
+
+ EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ if get_hr_state == 1:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("set_start_measure_time",0)#设置开始测量的时间戳时间
+
+ EventMesh.debug_log("stop debug8")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ elif get_spo2_state != 0:
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
+ if get_spo2_state == 1:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ EventMesh.debug_log("stop debug13")
+ elif get_bp_state != 0:
+ EventMesh.publish("set_bp_state",0)#2代表后台进入测试
+ if get_bp_state == 1:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ EventMesh.debug_log("stop bp debug1")
+ elif get_bg_state != 0:
+ EventMesh.publish("set_bg_state",0)#2代表后台进入测试
+ if get_bg_state == 1:#手动开灯关闭灯
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ EventMesh.debug_log("stop BG debug14")
+ if get_temp_state != 0:
+
+ EventMesh.publish("set_temp_state",0)#2代表后台进入测试
+ if get_temp_state == 1:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("get_start_temp_measure_time",0)#
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+ EventMesh.debug_log("stop temp debug14")
+ if msg == 1:
+ self.usbState = msg
+ str_buf = [1,1,10,led_mode.LONG_LIGHT_RED,4,2,led_mode.CHARGE_IN_MODE]
+ EventMesh.publish("set_led_time_arg",str_buf)#
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ self.aud.stop()
+ self.aud.play(1,1,'U:/static/R_CHARGE_IN.mp3')
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_IN"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.debug_log("charge R_CHARGE_IN")
+
+
+ elif msg == 2:
+ self.usbState = msg
+ EventMesh.publish("stop_led_timer")#设置参数
+ # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.CHARGE_OUT_MODE])#測量成功
+ EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,4,led_mode.CHARGE_OUT_MODE])#測量成功
+ EventMesh.debug_log("charge R_CHARGE_OUT")
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ self.aud.stop()
+ self.aud.play(1,1,'U:/static/R_CHARGE_OUT.mp3')
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_OUT"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
- elif msg == 3:
- self.usbState = msg
- EventMesh.debug_log("charge full")
- str_buf = [1,1,10,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.CHARGE_FULL_MODE]
- EventMesh.publish("set_led_time_arg",str_buf)#
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_FULL"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
+ elif msg == 3:
+ self.usbState = msg
+ EventMesh.debug_log("charge full")
+ str_buf = [1,1,10,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.CHARGE_FULL_MODE]
+ EventMesh.publish("set_led_time_arg",str_buf)#
+ # if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ # EventMesh.publish("close_timer_all")#
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_FULL"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
- def get_usb(self, event, msg):
- return self.usbState
-
+ def get_usb(self, event, msg):
+ return self.usbState
+
- def app_factory(self,event,msg):
- if msg != None:
- number = str(msg)
- sms.sendPduMsg(number, 'factory# send ok', 'UCS2')
- ret = 0
- ret = ql_fs.path_exists("/usr/static/storage_file")#
- if ret == True:
- ql_fs.rmdirs("/usr/static/storage_file")
- ql_fs.mkdirs("/usr/static/storage_file")
- if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
- EventMesh.publish(constants.PROTOCOL.DLT_SEND)
-
- self.factory_timer.start(6*1000,0,self.factory_cb)
- pass
- def factory_cb(self,*argc):
- self.aud.stopPlayStream()
- Power.powerRestart()
-
- def app_restart(self,event,msg):#远程发短信重启
- if msg != None:
- number = str(msg)
- sms.sendPduMsg(number, 'reset# send ok', 'UCS2')
- self.restart_timer.start(3*1000,0,self.app_restart_cb)
- pass
- def app_restart_cb(self,*argc):
- Power.powerRestart()
-
- def open_power_on(self, event, msg): #msg 1 开机 2 关机 3 重启 4恢复出厂设置 5静音关机
- EventMesh.publish("close_timer_all")#
- if msg == 1:
-
- # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
- # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- self.pwk_timer1.start(3000,0,self.power_on_audio_cb)
-
- elif msg == 2:
- flag = EventMesh.publish("get_call_state")
- if flag != 0:#电话呼叫中
- self.call_state = 0
- voiceCall.callEnd()
- step = EventMesh.publish("get_old_step_value")
- # step1 = SC7A20().get_step()
- # step1 = EventMesh.publish(constants.EVENT.GET_STEP)
- # step2 = EventMesh.publish("get_storage_config","old_step")
- self.read_data = EventMesh.publish("get_storage_data")
- # EventMesh.publish("set_test_data5",[1,step,step1,step2])
- if step != 0:
- EventMesh.publish("set_storage_config",["old_step",step])
- date_tmp = utime.localtime()
- time_tmp = utime.mktime(date_tmp)
- # step3 = EventMesh.publish("get_old_step_value")
- # step4 = SC7A20().get_step()
- # step4 = EventMesh.publish(constants.EVENT.GET_STEP)
- # step5 = EventMesh.publish("get_storage_config","old_step")
- # EventMesh.publish("set_test_data6",[1,step3,step4,step5])
- EventMesh.publish("set_storage_config",["old_time",time_tmp])#关机保存一个是时间
- EventMesh.publish("set_storage_config",["power_state",0])
- self.pwk_timer1.start(3000,0,self.power_off_audio_cb)
- elif msg == 3:
- flag = EventMesh.publish("get_call_state")
- if flag != 0:#电话呼叫中
- self.call_state = 0
- voiceCall.callEnd()
- self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
- # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
- # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- EventMesh.publish("stop_led_timer")#设置参数
- self.power_off = 1
- self.timer.start(8000,0,self.publish_resatrt_down_event_cb)
- #EventMesh.publish("set_led_time_arg",[3000,4000,1,led_mode.LONG_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE])#
- elif msg == 4:
- flag = EventMesh.publish("get_call_state")
- if flag != 0:#电话呼叫中
- self.call_state = 0
- voiceCall.callEnd()
- EventMesh.publish("stop_led_timer")#设置参数
- self.power_off = 1
+ def app_factory(self,event,msg):
+ if msg != None:
+ number = str(msg)
+ sms.sendPduMsg(number, 'factory# send ok', 'UCS2')
ret = 0
ret = ql_fs.path_exists("/usr/static/storage_file")#
if ret == True:
ql_fs.mkdirs("/usr/static/storage_file")
if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
EventMesh.publish(constants.PROTOCOL.DLT_SEND)
+
+ self.factory_timer.start(6*1000,0,self.factory_cb)
+ pass
+ def factory_cb(self,*argc):
self.aud.stopPlayStream()
- self.timer.start(6*1000,0,self.fun)
- elif msg == 5:
- flag = EventMesh.publish("get_call_state")
- if flag != 0:#电话呼叫中
- self.call_state = 0
- voiceCall.callEnd()
- step = EventMesh.publish("get_old_step_value")
- # step1 = SC7A20().get_step()
- # step1 = EventMesh.publish(constants.EVENT.GET_STEP)
- # step2 = EventMesh.publish("get_storage_config","old_step")
- self.read_data = EventMesh.publish("get_storage_data")
- # EventMesh.publish("set_test_data7",[1,step,step1,step2])
- if step != 0:
- EventMesh.publish("set_storage_config",["old_step",step])
-
- # step3 = EventMesh.publish("get_old_step_value")
- # step4 = SC7A20().get_step()
- # step4 = EventMesh.publish(constants.EVENT.GET_STEP)
- # step5 = EventMesh.publish("get_storage_config","old_step")
- # EventMesh.publish("set_test_data8",[1,step3,step4,step5])
- date_tmp = utime.localtime()
- time_tmp = utime.mktime(date_tmp)
- EventMesh.publish("set_storage_config",["old_time",time_tmp])#关机保存一个是时间
- EventMesh.publish("set_storage_config",["power_state",1])
- self.pwk_timer1.start(3000,0,self.power_off_no_audio_cb)#不需要关机铃声
-
- def fun(self,*argc):
- self.aud.stopPlayStream()
- Power.powerRestart()
-
-
- def power_on_cb(self, msg): #msg 开机标识
- self.power_on_flag = 1
- def clear_power_on_cb(self, msg): #msg 开机标识
- self.power_on_flag = 0
-
- def power_on_audio_cb(self, msg):
- self.power_on_flag = 1
- # EventMesh.debug_log("power_on_audio_cb")
- power_state = EventMesh.publish("get_storage_config","power_state")
- if power_state == None:
- power_state = 0
- # print("power_state",power_state)
- if power_state <= 0:
- self.aud.play(1,1,'U:/static/R_POWER_OFF_1.mp3')
- # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
- # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- EventMesh.publish("set_led_time_arg",[1,2,6*8,led_mode.FLASH_LIGHT_GREEN,6,3,led_mode.OTHER_MEASURE_MODE])#測量成功
- # EventMesh.publish("set_led_time_arg",[1000,200,10,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
- self.power_on_flag = 0
- self.pwk_timer2.start(5000,0,self.power_on_cb)
-
- def get_power_on_state(self, event, msg):
- return self.power_on_flag
-
- def power_off_audio_cb(self, msg):
- # EventMesh.debug_log("power_off_audio_cb")
- self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
- # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
- # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- EventMesh.publish("set_led_time_arg",[1,2,6*8,led_mode.FLASH_LIGHT_RED,6,3,led_mode.POWER_OFF_MODE])#
- self.power_off = 1
- self.pwk_timer2.start(6000,0,self.publish_power_down_event_cb)
-
- def power_off_no_audio_cb(self, msg):
- EventMesh.debug_log("power_off_no_audio_cb")
- EventMesh.publish("set_led_time_arg",[1,2,6*8,led_mode.FLASH_LIGHT_RED,6,3,led_mode.POWER_OFF_MODE])#
- self.power_off = 1
- self.pwk_timer2.start(6000,0,self.publish_power_down_event_cb)
-
- def set_power_off_cb(self, msg):
- self.power_off = 1
-
- def get_power_off_state(self, event, msg):
- return self.power_off
-
- def close_hr_sop2(self, event, msg): #msg 关闭心率血氧体温测试
- get_hr_state = EventMesh.publish("get_hr_state")
- get_spo2_state = EventMesh.publish("get_spo2_state")
- get_temp_state = EventMesh.publish("get_temp_state")
- get_bg_state = EventMesh.publish("get_bg_state")
- get_bp_state = EventMesh.publish("get_bp_state")
- if get_hr_state != None and get_spo2_state != None and get_temp_state != None and get_bg_state != None and get_bp_state != None:
- if get_hr_state != 0:
- EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
- EventMesh.debug_log("sstop hr")
- EventMesh.publish(constants.EVENT.STOP_HEART)
- if get_spo2_state != 0 :
- EventMesh.debug_log("stop spo2")
- EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
- EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
- if get_temp_state != 0:
- EventMesh.debug_log("stop temp")
- EventMesh.publish("set_temp_state",0)
- EventMesh.publish(constants.EVENT.STOP_TEMP)#手动体温测试
- if get_bg_state != 0:
- EventMesh.publish("set_bg_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
- EventMesh.debug_log("sstop bg")
- EventMesh.publish(constants.EVENT.STOP_HEART)
-
- if get_bp_state != 0:
- EventMesh.publish("set_bp_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
- EventMesh.debug_log("sstop bp")
- EventMesh.publish(constants.EVENT.STOP_HEART)
-
- def set_manual_measure_mode(self, event, msg): #手动测试 1心率 2 血氧 3 体温
- get_hr_state = EventMesh.publish("get_hr_state")
- get_spo2_state = EventMesh.publish("get_spo2_state")
- get_temp_state = EventMesh.publish("get_temp_state")
- if msg == 1:
- if get_hr_state != 1:#不是手动测试直接打断
- EventMesh.debug_log("set_manual_measure_mode",msg)
- EventMesh.publish("set_hr_state",1)
- EventMesh.publish("set_start_measure_time",1)#设置开始测量的时间戳时间
- EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) #停止测试血氧
- EventMesh.publish("set_hr_blood_led",1)
- EventMesh.publish(constants.EVENT.START_HEART) #手动心率测试
- elif msg == 2:
- if get_hr_state == 0:
- if get_spo2_state != 1:
+ Power.powerRestart()
+
+ def app_restart(self,event,msg):#远程发短信重启
+ if msg != None:
+ number = str(msg)
+ sms.sendPduMsg(number, 'reset# send ok', 'UCS2')
+ self.restart_timer.start(3*1000,0,self.app_restart_cb)
+ pass
+ def app_restart_cb(self,*argc):
+ Power.powerRestart()
+
+ def open_power_on(self, event, msg): #msg 1 开机 2 关机 3 重启 4恢复出厂设置 5静音关机
+ EventMesh.publish("close_timer_all")#
+ if msg == 1:
+
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
+ # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ self.pwk_timer1.start(3000,0,self.power_on_audio_cb)
+
+ elif msg == 2:
+ flag = EventMesh.publish("get_call_state")
+ if flag != 0:#电话呼叫中
+ self.call_state = 0
+ voiceCall.callEnd()
+ step = EventMesh.publish("get_old_step_value")
+ # step1 = SC7A20().get_step()
+ # step1 = EventMesh.publish(constants.EVENT.GET_STEP)
+ # step2 = EventMesh.publish("get_storage_config","old_step")
+ self.read_data = EventMesh.publish("get_storage_data")
+ # EventMesh.publish("set_test_data5",[1,step,step1,step2])
+ if step != 0:
+ EventMesh.publish("set_storage_config",["old_step",step])
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ # step3 = EventMesh.publish("get_old_step_value")
+ # step4 = SC7A20().get_step()
+ # step4 = EventMesh.publish(constants.EVENT.GET_STEP)
+ # step5 = EventMesh.publish("get_storage_config","old_step")
+ # EventMesh.publish("set_test_data6",[1,step3,step4,step5])
+ EventMesh.publish("set_storage_config",["old_time",time_tmp])#关机保存一个是时间
+ EventMesh.publish("set_storage_config",["power_state",0])
+ self.pwk_timer1.start(3000,0,self.power_off_audio_cb)
+ elif msg == 3:
+ flag = EventMesh.publish("get_call_state")
+ if flag != 0:#电话呼叫中
+ self.call_state = 0
+ voiceCall.callEnd()
+ self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
+ # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("stop_led_timer")#设置参数
+ self.power_off = 1
+ self.timer.start(8000,0,self.publish_resatrt_down_event_cb)
+ #EventMesh.publish("set_led_time_arg",[3000,4000,1,led_mode.LONG_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE])#
+ elif msg == 4:
+ flag = EventMesh.publish("get_call_state")
+ if flag != 0:#电话呼叫中
+ self.call_state = 0
+ voiceCall.callEnd()
+ EventMesh.publish("stop_led_timer")#设置参数
+ self.power_off = 1
+ ret = 0
+ ret = ql_fs.path_exists("/usr/static/storage_file")#
+ if ret == True:
+ ql_fs.rmdirs("/usr/static/storage_file")
+ ql_fs.mkdirs("/usr/static/storage_file")
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
+ EventMesh.publish(constants.PROTOCOL.DLT_SEND)
+ self.aud.stopPlayStream()
+ self.timer.start(6*1000,0,self.fun)
+ elif msg == 5:
+ flag = EventMesh.publish("get_call_state")
+ if flag != 0:#电话呼叫中
+ self.call_state = 0
+ voiceCall.callEnd()
+ step = EventMesh.publish("get_old_step_value")
+ # step1 = SC7A20().get_step()
+ # step1 = EventMesh.publish(constants.EVENT.GET_STEP)
+ # step2 = EventMesh.publish("get_storage_config","old_step")
+ self.read_data = EventMesh.publish("get_storage_data")
+ # EventMesh.publish("set_test_data7",[1,step,step1,step2])
+ if step != 0:
+ EventMesh.publish("set_storage_config",["old_step",step])
+
+ # step3 = EventMesh.publish("get_old_step_value")
+ # step4 = SC7A20().get_step()
+ # step4 = EventMesh.publish(constants.EVENT.GET_STEP)
+ # step5 = EventMesh.publish("get_storage_config","old_step")
+ # EventMesh.publish("set_test_data8",[1,step3,step4,step5])
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ EventMesh.publish("set_storage_config",["old_time",time_tmp])#关机保存一个是时间
+ EventMesh.publish("set_storage_config",["power_state",1])
+ self.pwk_timer1.start(3000,0,self.power_off_no_audio_cb)#不需要关机铃声
+
+ def fun(self,*argc):
+ self.aud.stopPlayStream()
+ Power.powerRestart()
+
+
+ def power_on_cb(self, msg): #msg 开机标识
+ self.power_on_flag = 1
+ def clear_power_on_cb(self, msg): #msg 开机标识
+ self.power_on_flag = 0
+
+ def power_on_audio_cb(self, msg):
+ self.power_on_flag = 1
+ # EventMesh.debug_log("power_on_audio_cb")
+ power_state = EventMesh.publish("get_storage_config","power_state")
+ if power_state == None:
+ power_state = 0
+ # print("power_state",power_state)
+ if power_state <= 0:
+ self.aud.play(1,1,'U:/static/R_POWER_OFF_1.mp3')
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
+ # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_led_time_arg",[1,2,6*8,led_mode.FLASH_LIGHT_GREEN,6,3,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,200,10,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ self.power_on_flag = 0
+ self.pwk_timer2.start(5000,0,self.power_on_cb)
+
+ def get_power_on_state(self, event, msg):
+ return self.power_on_flag
+
+ def power_off_audio_cb(self, msg):
+ # EventMesh.debug_log("power_off_audio_cb")
+ self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
+ # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_led_time_arg",[1,2,6*8,led_mode.FLASH_LIGHT_RED,6,3,led_mode.POWER_OFF_MODE])#
+ self.power_off = 1
+ self.pwk_timer2.start(6000,0,self.publish_power_down_event_cb)
+
+ def power_off_no_audio_cb(self, msg):
+ EventMesh.debug_log("power_off_no_audio_cb")
+ EventMesh.publish("set_led_time_arg",[1,2,6*8,led_mode.FLASH_LIGHT_RED,6,3,led_mode.POWER_OFF_MODE])#
+ self.power_off = 1
+ self.pwk_timer2.start(6000,0,self.publish_power_down_event_cb)
+
+ def set_power_off_cb(self, msg):
+ self.power_off = 1
+
+ def get_power_off_state(self, event, msg):
+ return self.power_off
+
+ def close_hr_sop2(self, event, msg): #msg 关闭心率血氧体温测试
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ get_temp_state = EventMesh.publish("get_temp_state")
+ get_bg_state = EventMesh.publish("get_bg_state")
+ get_bp_state = EventMesh.publish("get_bp_state")
+ if get_hr_state != None and get_spo2_state != None and get_temp_state != None and get_bg_state != None and get_bp_state != None:
+ if get_hr_state != 0:
+ EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ EventMesh.debug_log("sstop hr")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ if get_spo2_state != 0 :
+ EventMesh.debug_log("stop spo2")
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ if get_temp_state != 0:
+ EventMesh.debug_log("stop temp")
+ EventMesh.publish("set_temp_state",0)
+ EventMesh.publish(constants.EVENT.STOP_TEMP)#手动体温测试
+ if get_bg_state != 0:
+ EventMesh.publish("set_bg_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ EventMesh.debug_log("sstop bg")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+
+ if get_bp_state != 0:
+ EventMesh.publish("set_bp_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ EventMesh.debug_log("sstop bp")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+
+ def set_manual_measure_mode(self, event, msg): #手动测试 1心率 2 血氧 3 体温
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ get_temp_state = EventMesh.publish("get_temp_state")
+ if msg == 1:
+ if get_hr_state != 1:#不是手动测试直接打断
EventMesh.debug_log("set_manual_measure_mode",msg)
- EventMesh.publish("set_spo2_state",1)
+ EventMesh.publish("set_hr_state",1)
EventMesh.publish("set_start_measure_time",1)#设置开始测量的时间戳时间
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) #停止测试血氧
+ EventMesh.publish("set_hr_blood_led",1)
+ EventMesh.publish(constants.EVENT.START_HEART) #手动心率测试
+ elif msg == 2:
+ if get_hr_state == 0:
+ if get_spo2_state != 1:
+ EventMesh.debug_log("set_manual_measure_mode",msg)
+ EventMesh.publish("set_spo2_state",1)
+ EventMesh.publish("set_start_measure_time",1)#设置开始测量的时间戳时间
+ EventMesh.publish("set_hr_blood_led",1)
+ EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN) #手动血氧测试
+ elif msg == 3:
+ if get_temp_state != 1:
+ EventMesh.debug_log("set_manual_measure_mode",msg)
+ EventMesh.publish("set_temp_state",1)
+ EventMesh.publish("set_start_temp_measure_time",1)#设置开始测量的时间戳时间
EventMesh.publish("set_hr_blood_led",1)
- EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN) #手动血氧测试
- elif msg == 3:
- if get_temp_state != 1:
- EventMesh.debug_log("set_manual_measure_mode",msg)
- EventMesh.publish("set_temp_state",1)
- EventMesh.publish("set_start_temp_measure_time",1)#设置开始测量的时间戳时间
- EventMesh.publish("set_hr_blood_led",1)
- EventMesh.publish(constants.EVENT.START_TEMP)#手动体温测试
- pass
+ EventMesh.publish(constants.EVENT.START_TEMP)#手动体温测试
+ pass
- def set_start_measure_time(self, event, msg): #手动测试 1心
- self.hr_auto = msg
- pass
+ def set_start_measure_time(self, event, msg): #手动测试 1心
+ self.hr_auto = msg
+ pass
- def get_start_measure_time(self, event, msg): #手动测试
+ def get_start_measure_time(self, event, msg): #手动测试
- return self.hr_auto
-
- def set_start_temp_measure_time(self, event, msg): #
- self.temp_auto = msg
- pass
-
- def get_start_temp_measure_time(self, event, msg): #
- return self.temp_auto
-
- def mearsure_cb(self, event, msg):
- if msg == 1:
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- elif msg == 2:
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- elif msg == 3:
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- elif msg == 4:
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ return self.hr_auto
-
-
- def play_temp_value(self, event, msg): #播放体温数值
- flag = EventMesh.publish("get_call_state")
- if msg != None:
- if flag == 0 and self.fall_flag == 0:
- EventMesh.publish("close_timer_all")#
- if msg > 0:
- # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
- # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- EventMesh.publish("set_hr_blood_led",2)#测量成功
- self.temp_value = msg
- # self.timer.start(2*1000,1,self.play_temp_fun)
- self.play_temp_fun(0)
+ def set_start_temp_measure_time(self, event, msg): #
+ self.temp_auto = msg
+ pass
+
+ def get_start_temp_measure_time(self, event, msg): #
+ return self.temp_auto
+
+ def mearsure_cb(self, event, msg):
+ if msg == 1:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ elif msg == 2:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ elif msg == 3:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ elif msg == 4:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+
+ def play_temp_value(self, event, msg): #播放体温数值
+ flag = EventMesh.publish("get_call_state")
+ if msg != None:
+ if flag == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ if msg > 0:
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",2)#测量成功
+ self.temp_value = msg
+ # self.timer.start(2*1000,1,self.play_temp_fun)
+ self.play_temp_fun(0)
+ else:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
else:
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
EventMesh.publish("set_hr_blood_led",3)#测量异常
- else:
- EventMesh.publish("set_hr_blood_led",3)#测量异常
- def play_temp_fun(self,argc): #播放体温数值
- data = self.temp_value
- if data > 42:
- data = 42
- data_tmp = str(data)
- if data_tmp.find(".") != -1:
- temp_shi = int(data_tmp.split('.')[0])//10
- temp_ge = int(data_tmp.split('.')[0])%10
- dot_ge = int(data_tmp.split('.')[1][:1])
- if temp_ge > 0:#37.0
- if dot_ge > 0:#37.5
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(temp_ge)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),\
- audio_buf.index("R_READ_TIME_{}".format(dot_ge)))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ def play_temp_fun(self,argc): #播放体温数值
+ data = self.temp_value
+ if data > 42:
+ data = 42
+ data_tmp = str(data)
+ if data_tmp.find(".") != -1:
+ temp_shi = int(data_tmp.split('.')[0])//10
+ temp_ge = int(data_tmp.split('.')[0])%10
+ dot_ge = int(data_tmp.split('.')[1][:1])
+ if temp_ge > 0:#37.0
+ if dot_ge > 0:#37.5
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(temp_ge)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),\
+ audio_buf.index("R_READ_TIME_{}".format(dot_ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:#37.0
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(temp_ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#30.0 30.6
+ if dot_ge > 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(dot_ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
+ audio_buf.index("R_READ_STEP_3"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:
+ temp_shi = int(data_tmp)//10
+ temp_ge = int(data_tmp)%10
- else:#37.0
+ if temp_ge > 0:#45
str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(temp_ge)))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#30.0 30.6
- if dot_ge > 0:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(dot_ge)))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
else:
str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
audio_buf.index("R_READ_STEP_3"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
- else:
- temp_shi = int(data_tmp)//10
- temp_ge = int(data_tmp)%10
-
- if temp_ge > 0:#45
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(temp_ge)))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
- audio_buf.index("R_READ_STEP_3"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
-
- def play_hr_value(self, event, msg): #播放心率数值
- flag = EventMesh.publish("get_call_state")
- if msg != None:
- if flag == 0 and self.fall_flag == 0:
- EventMesh.publish("close_timer_all")#
- if msg >= 50:
- # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
- # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- self.hr_value = msg
- EventMesh.publish("set_hr_blood_led",2)#测量成功
- # self.timer.start(2*1000,1,self.play_hr_fun)
- self.play_hr_fun(0)
+ def play_hr_value(self, event, msg): #播放心率数值
+ flag = EventMesh.publish("get_call_state")
+ if msg != None:
+ if flag == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ if msg >= 50:
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ self.hr_value = msg
+ EventMesh.publish("set_hr_blood_led",2)#测量成功
+ # self.timer.start(2*1000,1,self.play_hr_fun)
+ self.play_hr_fun(0)
+ else:
+ str_data ='mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
else:
- str_data ='mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
EventMesh.publish("set_hr_blood_led",3)#测量异常
- else:
- EventMesh.publish("set_hr_blood_led",3)#测量异常
- def play_hr_fun(self,argc):#播放心率测试值
- flag = EventMesh.publish("get_call_state")
-
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
- data = self.hr_value
- if data > 220:
- data = 220
- if data < 100:
- if data%10 == 0:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
- audio_buf.index("R_READ_STEP_3"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(data%10)))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- shi = (data%100)//10 #210
- ge = (data%100)%10
- #210 234
- if shi > 0:
- if ge == 0:#210 230 120
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi)),audio_buf.index("R_READ_STEP_3"))
+ def play_hr_fun(self,argc):#播放心率测试值
+ flag = EventMesh.publish("get_call_state")
+
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ data = self.hr_value
+ if data > 220:
+ data = 220
+ if data < 100:
+ if data%10 == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
+ audio_buf.index("R_READ_STEP_3"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi)),audio_buf.index("R_READ_STEP_3"),\
- audio_buf.index("R_READ_TIME_{}".format(ge)))
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(data%10)))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- if ge == 0:#200 100 209 108
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
- audio_buf.index("R_READ_STEP_2"))
- EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ shi = (data%100)//10 #210
+ ge = (data%100)%10
+ #210 234
+ if shi > 0:
+ if ge == 0:#210 230 120
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi)),audio_buf.index("R_READ_STEP_3"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_TIME_{}".format(ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
- audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge)))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ if ge == 0:#200 100 209 108
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
+ audio_buf.index("R_READ_STEP_2"))
+ EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- def play_sugar_value(self, event, msg): #播放血糖数值
- flag = EventMesh.publish("get_call_state")
- if msg != None:
- if flag == 0 and self.fall_flag == 0:
- EventMesh.publish("close_timer_all")#
- if msg != 0:
- # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
- # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- EventMesh.publish("set_hr_blood_led",2)#测量成功
- # self.timer.start(2*1000,1,self.play_spo2_fun)
- self.play_sugar_fun(msg)
+ def play_sugar_value(self, event, msg): #播放血糖数值
+ flag = EventMesh.publish("get_call_state")
+ if msg != None:
+ if flag == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ if msg != 0:
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",2)#测量成功
+ # self.timer.start(2*1000,1,self.play_spo2_fun)
+ self.play_sugar_fun(msg)
+ else:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
else:
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
EventMesh.publish("set_hr_blood_led",3)#测量异常
- else:
- EventMesh.publish("set_hr_blood_led",3)#测量异常
-
- def play_sugar_fun(self,argc):#播放血糖测试值
- flag = EventMesh.publish("get_call_state")
-
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
- data = str(argc)
- data_shi = 0
- data_ge = 0
- if data.find(".") != -1:
- data_shi = int(data.split(".")[0])
- data_ge = int(data.split(".")[1])
- else:
- data_shi = int(data)
- data_ge = 0
-
- if data_shi != 0 and data_ge != 0:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_BLOOD_SUGAR"),audio_buf.index("R_READ_TIME_{}".format(data_shi)),\
- audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(data_ge)))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- EventMesh.publish("set_hr_blood_led",3)#测量异常
-
-
- def play_spo2_value(self, event, msg): #播放血样数值
- flag = EventMesh.publish("get_call_state")
- if msg != None:
- if flag == 0 and self.fall_flag == 0:
+ def play_sugar_fun(self,argc):#播放血糖测试值
+ flag = EventMesh.publish("get_call_state")
+
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
EventMesh.publish("close_timer_all")#
- if msg >= 85:
- # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
- # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- EventMesh.publish("set_hr_blood_led",2)#测量成功
- self.spo2_value = msg
- # self.timer.start(2*1000,1,self.play_spo2_fun)
- self.play_spo2_fun(0)
+ data = str(argc)
+ data_shi = 0
+ data_ge = 0
+ if data.find(".") != -1:
+ data_shi = int(data.split(".")[0])
+ data_ge = int(data.split(".")[1])
else:
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ data_shi = int(data)
+ data_ge = 0
+
+ if data_shi != 0 and data_ge != 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_BLOOD_SUGAR"),audio_buf.index("R_READ_TIME_{}".format(data_shi)),\
+ audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(data_ge)))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- EventMesh.publish("set_hr_blood_led",3)#测量异常
else:
EventMesh.publish("set_hr_blood_led",3)#测量异常
- def play_spo2_fun(self,argc):#播放血氧测试值
- flag = EventMesh.publish("get_call_state")
-
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
- data = self.spo2_value
- if data > 100:
- data = 100
- if data == 100:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
- audio_buf.index("R_READ_STEP_2"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- if data % 10 == 0:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
- audio_buf.index("R_READ_STEP_3"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
- audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(data%10)))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- def set_sim_mode(self, event, msg): #mode 1 蓝灯闪烁 可识别卡 但未联网 2 可绑定appsim正常 3 手表不识别卡或者未插卡
- flag = EventMesh.publish("get_call_state")
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
- # EventMesh.publish("stop_led_timer")#设置参数
- mode = 0
- signal = EventMesh.publish("screen_get_sig")
- if signal != None:
- if signal >= 0 and signal <= 31:#有卡
- if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网提示关机
- mode = 2
- else:
- mode = 1
- else:#未插卡
- mode = 3
- if mode == 1:#白色灯
- EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_WHITE,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
- # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_WHITE,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_FAILE"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- elif mode == 2:#蓝灯色灯
- EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_GREEN,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
- # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_CONNECT"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- elif mode == 3:#红灯闪烁
- EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_RED,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SIM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
-
- def dial_sos_phone(self, event, msg): #拨打紧急求助电话
- flag = EventMesh.publish("get_call_state")
- if flag == 0:
-
- signal = EventMesh.publish("screen_get_sig")
- if signal != None:
- if signal >= 0 and signal <= 31:#有卡
- if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网提示关机
- sos_number = EventMesh.publish("get_dial_sos_number")
- if sos_number != None:
- if len(sos_number) != 0:
- EventMesh.publish("close_timer_all")#
- EventMesh.publish("set_sos_flag",1)
-
- else:#未设置sos紧急求助号码
- EventMesh.publish("close_timer_all")#
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- else:
- EventMesh.publish("close_timer_all")#
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_FAILE"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#未插卡
+ def play_spo2_value(self, event, msg): #播放血样数值
+ flag = EventMesh.publish("get_call_state")
+ if msg != None:
+ if flag == 0 and self.fall_flag == 0:
EventMesh.publish("close_timer_all")#
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SIM"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- def play_cur_time_event(self, event, msg): #播放当前时间
- flag = EventMesh.publish("get_call_state")
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
-
- data = RTC().datetime()
- hour = data[4]
- min = data[5]
- # EventMesh.debug_log("hour",hour,min)
- self.old_hour = hour
- self.old_min = min
- if self.old_hour == 0:
- if self.old_min <= 9:#00:09
- if self.old_min == 0:#0点整
- str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#0点09分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(self.old_min))\
- ,audio_buf.index("R_READ_TIME_MIN"))
+ if msg >= 85:
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",2)#测量成功
+ self.spo2_value = msg
+ # self.timer.start(2*1000,1,self.play_spo2_fun)
+ self.play_spo2_fun(0)
+ else:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
-
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
else:
- if self.old_min % 10 == 0:#0点2十分 0点3十分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- else:#0点2十8分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10)),audio_buf.index("R_READ_TIME_MIN"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
- elif self.old_hour <= 9:#8:09 9:20 9:45
- if self.old_min <= 9:#9点09分
- if self.old_min <= 0:
- str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ def play_spo2_fun(self,argc):#播放血氧测试值
+ flag = EventMesh.publish("get_call_state")
+
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ data = self.spo2_value
+ if data > 100:
+ data = 100
+ if data == 100:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
+ audio_buf.index("R_READ_STEP_2"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if data % 10 == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
+ audio_buf.index("R_READ_STEP_3"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
pass
else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(self.old_min))\
- ,audio_buf.index("R_READ_TIME_MIN"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- else:
- if self.old_min % 10 == 0:#9点2十分 9点4十分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min //10))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#9点2十4分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min //10))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10)),audio_buf.index("R_READ_TIME_MIN"))
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(data%10)))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#12:0
- if self.old_min == 0:#12:00 13:00 15:00 20 10 11 12 13 14 15
- self.play_count+=1
- hour_shi = self.old_hour//10
- hour_ge = self.old_hour%10
- if self.old_hour == 10:#十点整
- str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- elif self.old_hour == 20:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ def set_sim_mode(self, event, msg): #mode 1 蓝灯闪烁 可识别卡 但未联网 2 可绑定appsim正常 3 手表不识别卡或者未插卡
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ # EventMesh.publish("stop_led_timer")#设置参数
+ mode = 0
+ signal = EventMesh.publish("screen_get_sig")
+ if signal != None:
+ if signal >= 0 and signal <= 31:#有卡
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网提示关机
+ mode = 2
+ else:
+ mode = 1
+ else:#未插卡
+ mode = 3
+ if mode == 1:#白色灯
+ EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_WHITE,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_WHITE,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ elif mode == 2:#蓝灯色灯
+ EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_GREEN,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_CONNECT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ elif mode == 3:#红灯闪烁
+ EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_RED,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SIM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+
+ def dial_sos_phone(self, event, msg): #拨打紧急求助电话
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0:
+
+ signal = EventMesh.publish("screen_get_sig")
+ if signal != None:
+ if signal >= 0 and signal <= 31:#有卡
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网提示关机
+ sos_number = EventMesh.publish("get_dial_sos_number")
+ if sos_number != None:
+ if len(sos_number) != 0:
+ EventMesh.publish("close_timer_all")#
+ EventMesh.publish("set_sos_flag",1)
+
+ else:#未设置sos紧急求助号码
+ EventMesh.publish("close_timer_all")#
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ EventMesh.publish("close_timer_all")#
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#未插卡
+ EventMesh.publish("close_timer_all")#
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SIM"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ def play_cur_time_event(self, event, msg): #播放当前时间
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+
+ data = RTC().datetime()
+ hour = data[4]
+ min = data[5]
+ # EventMesh.debug_log("hour",hour,min)
+ self.old_hour = hour
+ self.old_min = min
+ if self.old_hour == 0:
+ if self.old_min <= 9:#00:09
+ if self.old_min == 0:#0点整
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#0点09分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(self.old_min))\
+ ,audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
else:
- if hour_shi <= 1:#十3点整
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
- ,audio_buf.index("R_READ_TIME_{}".format(hour_ge)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ if self.old_min % 10 == 0:#0点2十分 0点3十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:#0点2十8分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10)),audio_buf.index("R_READ_TIME_MIN"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ elif self.old_hour <= 9:#8:09 9:20 9:45
+ if self.old_min <= 9:#9点09分
+ if self.old_min <= 0:
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(self.old_min))\
+ ,audio_buf.index("R_READ_TIME_MIN"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- if self.old_hour == 10:#10:09 10:10
- if self.old_min <= 9:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0")\
- ,audio_buf.index("R_READ_TIME_{}".format(self.old_min)),audio_buf.index("R_READ_TIME_MIN"))
+ else:
+ if self.old_min % 10 == 0:#9点2十分 9点4十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min //10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#9点2十4分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min //10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+ else:#12:0
+ if self.old_min == 0:#12:00 13:00 15:00 20 10 11 12 13 14 15
+ self.play_count+=1
+ hour_shi = self.old_hour//10
+ hour_ge = self.old_hour%10
+ if self.old_hour == 10:#十点整
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ elif self.old_hour == 20:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
else:
- if self.old_min % 10 == 0:#十点2十分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min//10))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ if hour_shi <= 1:#十3点整
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(hour_ge)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#十点2十1分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min//10))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(self.old_min%10))\
- ,audio_buf.index("R_READ_TIME_MIN"))
+
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
else:
- if self.old_hour < 20:#19:00
- if self.old_min <= 9:#19:09
- if self.old_min == 0:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
- ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ if self.old_hour == 10:#10:09 10:10
+ if self.old_min <= 9:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_min)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if self.old_min % 10 == 0:#十点2十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min//10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- else:
+ else:#十点2十1分
str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
- ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT")\
- ,audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min//10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(self.old_min%10))\
,audio_buf.index("R_READ_TIME_MIN"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- else:#19:18 19:40 19:56
- if self.old_min % 10 == 0:#十9点2十分 十9点3十分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
- ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT")\
- ,audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10)),audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#十9点2十1分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
- ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT")\
- ,audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10)),audio_buf.index("R_READ_STEP_3")\
- ,audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10)),audio_buf.index("R_READ_TIME_MIN"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
else:
- hour_shi = self.old_hour//10
- hour_ge = self.old_hour%10
-
- min_shi = self.old_min//10
- min_ge = self.old_min%10
-
- #20:08 20:18 20:20
- if hour_ge == 0:
- if self.old_min <= 9:
+ if self.old_hour < 20:#19:00
+ if self.old_min <= 9:#19:09
if self.old_min == 0:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
pass
else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0")\
- ,audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT")\
+ ,audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10))\
+ ,audio_buf.index("R_READ_TIME_MIN"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- else:
- if min_ge == 0:#2十点2十分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+
+ else:#19:18 19:40 19:56
+ if self.old_min % 10 == 0:#十9点2十分 十9点3十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10)),audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#2十点2十1分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
+ else:#十9点2十1分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10)),audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10)),audio_buf.index("R_READ_TIME_MIN"))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#21:08 21:18
- if self.old_min <= 9:
- if self.old_min == 0:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
+ else:
+ hour_shi = self.old_hour//10
+ hour_ge = self.old_hour%10
+
+ min_shi = self.old_min//10
+ min_ge = self.old_min%10
+
+ #20:08 20:18 20:20
+ if hour_ge == 0:
+ if self.old_min <= 9:
+ if self.old_min == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
else:
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0")\
- ,audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- if min_ge == 0:#2十3点3十分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:#2十3点3十1分
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
- ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
- ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ if min_ge == 0:#2十点2十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#2十点2十1分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#21:08 21:18
+ if self.old_min <= 9:
+ if self.old_min == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if min_ge == 0:#2十3点3十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#2十3点3十1分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- def play_timer_cb_1(self,*agrs):
- return
- def play_center_phone(self, event, msg): #msg
- flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许设备再次拨出
- if flag == 0 and self.fall_flag == 0:
- EventMesh.publish("close_timer_all")#
-
- center_dial = EventMesh.publish("get_storage_config","center_dial")
- if center_dial != None:
- if len(center_dial) > 0:
- voiceCall.callStart(str(center_dial))
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
- EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- else:#未设置号码
- # EventMesh.debug_log("play_center_phone")
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+ def play_timer_cb_1(self,*agrs):
+ return
+
+ def play_center_phone(self, event, msg): #msg
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许设备再次拨出
+ if flag == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+
+ center_dial = EventMesh.publish("get_storage_config","center_dial")
+ if center_dial != None:
+ if len(center_dial) > 0:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
+ EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ voiceCall.callStart(str(center_dial))
+
+
+ else:#未设置号码
+ # EventMesh.debug_log("play_center_phone")
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ def center_phone_cb(self,*argc): #msg
+ pass
+
+
+
+
+ def play_imei_event(self, event, msg): #msg
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ imei = EventMesh.publish(constants.EVENT.GET_IMEI)
+ EventMesh.debug_log(imei)
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(imei[0]))\
+ ,audio_buf.index("R_READ_TIME_{}".format(imei[1])),audio_buf.index("R_READ_TIME_{}".format(imei[2])),audio_buf.index("R_READ_TIME_{}".format(imei[3])),\
+ audio_buf.index("R_READ_TIME_{}".format(imei[4])),audio_buf.index("R_READ_TIME_{}".format(imei[5])),audio_buf.index("R_READ_TIME_{}".format(imei[6])),audio_buf.index("R_READ_TIME_{}".format(imei[7])),\
+ audio_buf.index("R_READ_TIME_{}".format(imei[8])),audio_buf.index("R_READ_TIME_{}".format(imei[9])),audio_buf.index("R_READ_TIME_{}".format(imei[10])),audio_buf.index("R_READ_TIME_{}".format(imei[11])),\
+ audio_buf.index("R_READ_TIME_{}".format(imei[12])),audio_buf.index("R_READ_TIME_{}".format(imei[13])),audio_buf.index("R_READ_TIME_{}".format(imei[14])))
EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- pass
- def center_phone_cb(self,*argc): #msg
- pass
+ def get_unread_wechat_state(self,event, msg):
+ return self.set_unread_wechat
+
+ def set_unread_wechat_state(self, event, msg):
+ self.set_unread_wechat = msg
- def play_imei_event(self, event, msg): #msg
- flag = EventMesh.publish("get_call_state")
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
- imei = EventMesh.publish(constants.EVENT.GET_IMEI)
- EventMesh.debug_log(imei)
- str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(imei[0]))\
- ,audio_buf.index("R_READ_TIME_{}".format(imei[1])),audio_buf.index("R_READ_TIME_{}".format(imei[2])),audio_buf.index("R_READ_TIME_{}".format(imei[3])),\
- audio_buf.index("R_READ_TIME_{}".format(imei[4])),audio_buf.index("R_READ_TIME_{}".format(imei[5])),audio_buf.index("R_READ_TIME_{}".format(imei[6])),audio_buf.index("R_READ_TIME_{}".format(imei[7])),\
- audio_buf.index("R_READ_TIME_{}".format(imei[8])),audio_buf.index("R_READ_TIME_{}".format(imei[9])),audio_buf.index("R_READ_TIME_{}".format(imei[10])),audio_buf.index("R_READ_TIME_{}".format(imei[11])),\
- audio_buf.index("R_READ_TIME_{}".format(imei[12])),audio_buf.index("R_READ_TIME_{}".format(imei[13])),audio_buf.index("R_READ_TIME_{}".format(imei[14])))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ def get_wechat_data(self,event, msg):
+ return [self.MXA_MSG ,self.wechat_recode_list]
+
+ def set_wechat_data(self, event, msg):
+ # EventMesh.debug_log("set_wechat_data1 ",msg,self.wechat_num)
+ self.MXA_MSG = msg[0]
+ self.wechat_recode_list = msg[1]
+ self.wechat_num = self.wechat_recode_list["num"]
+ with open("/usr/static/storage_file/wechat_record.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
+ #写编号
+ # EventMesh.debug_log("set_wechat_data2:{} ".format(self.wechat_num))
+
- def get_unread_wechat_state(self,event, msg):
+ def get_wechat_time(self, event, msg):
+ return [self.press_btn,self.timeSecond]
- return self.set_unread_wechat
-
- def set_unread_wechat_state(self, event, msg):
- self.set_unread_wechat = msg
+ def start_wechat_record(self, event, msg): #开始录音相关配置
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ if self.press_btn == 0:
+ self.press_btn = 1
+ audio_state = EventMesh.publish("get_audio_state")
+ if audio_state == 1:
+ self.aud.stop()
+ EventMesh.publish("close_timer_all")#
+ EventMesh.publish("set_led_time_arg",[1,1,160,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.WECHAT_LED_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,1000,1,led_mode.LONG_LIGHT_GREEN,led_mode.OPEN_LONG_LIGHT_MODE,led_mode.WECHAT_LED_MODE])#測量成功
+
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ self.timeSecond = time_tmp#保存按下的时间长s
+ self.aud.setVolume(11)#设置音量最大
+
+ EventMesh.debug_log("talking1.0")
+ # if self.wechat_num >= self.MXA_MSG:
+ # self.wechat_num = 0
+ # self.wechat_num += 1
+ # self.wechat_show = self.wechat_num
+ # self.record_test.start("/usr/static/storage_file/{}.amr".format(self.wechat_show),16)
+ self.record_test.start("/usr/static/storage_file/wechat.amr",16)
+
+ else:
+ self.timeSecond = 0
+ self.press_btn = 0
+ def get_wechat_state(self, event, msg):
+ return self.press_btn
+
+ def send_wechat_record(self, event, msg): #发送录音文件
+ if self.press_btn == 1:
+ self.press_btn = 0
+ self.record_test.stop() #停止錄音
+ EventMesh.publish("stop_led_timer")#关闭灯
+ EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.LONG_LIGHT_GREEN,led_mode.OPEN_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#測量成功
+ self.countdown_old = 0
- def get_wechat_data(self,event, msg):
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
- return [self.MXA_MSG ,self.wechat_recode_list]
-
- def set_wechat_data(self, event, msg):
- # EventMesh.debug_log("set_wechat_data1 ",msg,self.wechat_num)
- self.MXA_MSG = msg[0]
- self.wechat_recode_list = msg[1]
- self.wechat_num = self.wechat_recode_list["num"]
- with open("/usr/static/storage_file/wechat_record.json","w",encoding="utf-8") as fd:
- ujson.dump(self.wechat_recode_list,fd)
- #写编号
- # EventMesh.debug_log("set_wechat_data2:{} ".format(self.wechat_num))
-
-
- def get_wechat_time(self, event, msg):
- return [self.press_btn,self.timeSecond]
-
- def start_wechat_record(self, event, msg): #开始录音相关配置
- if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
+ self.countdown_old = msg
+ if self.countdown_old >= 15:
+ self.countdown_old = 15
+ if self.countdown_old <= 0:
+ #录音时间太短
+ return
+ else:
+ # self.wechat_recode_list["%02d"%(self.wechat_show)] = "read:0"
+ # self.wechat_recode_list["num"] = self.wechat_show
+ EventMesh.debug_log("self.wechat_recode_list :{}".format(self.wechat_recode_list))
+
+ # with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ # ujson.dump(self.wechat_recode_list,fd)
+ EventMesh.debug_log("send wechat data!!!!!!!!!!!!!!!!!!!!!")
+
+ check_txt = ql_fs.path_exists("/usr/static/storage_file/wechat.amr")
+ if check_txt == True :
+ path = "/usr/static/storage_file/wechat.amr"
+ with open(path,"rb") as fd:
+ buf = bytearray(ql_fs.path_getsize(path))
+ fd.readinto(buf)
+ senddata = [self.countdown_old,buf]
+ EventMesh.publish(constants.PROTOCOL.TKS_SEND,senddata)
+
+ # with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ # ujson.dump(self.wechat_recode_list,fd)
+ # EventMesh.debug_log("send wechat data!!!!!!!!!!!!!!!!!!!!!")
+
+ # check_txt = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(self.wechat_show))
+ # if check_txt == True :
+ # path = "/usr/static/storage_file/{}.amr".format(self.wechat_show)
+ # with open(path,"rb") as fd:
+ # buf = bytearray(ql_fs.path_getsize(path))
+ # fd.readinto(buf)
+ # senddata = [self.countdown_old,buf]
+ # EventMesh.publish(constants.PROTOCOL.TKS_SEND,senddata)
+
+
+ def play_wechat_last_amr(self, event, msg):#播放微聊最后一条语音文件
flag = EventMesh.publish("get_call_state")
- if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- if self.press_btn == 0:
- self.press_btn = 1
- audio_state = EventMesh.publish("get_audio_state")
- if audio_state == 1:
- self.aud.stop()
- EventMesh.publish("close_timer_all")#
- EventMesh.publish("set_led_time_arg",[1,1,160,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.WECHAT_LED_MODE])#測量成功
- # EventMesh.publish("set_led_time_arg",[1000,1000,1,led_mode.LONG_LIGHT_GREEN,led_mode.OPEN_LONG_LIGHT_MODE,led_mode.WECHAT_LED_MODE])#測量成功
-
- date_tmp = utime.localtime()
- time_tmp = utime.mktime(date_tmp)
- self.timeSecond = time_tmp#保存按下的时间长s
- self.aud.setVolume(11)#设置音量最大
-
- EventMesh.debug_log("talking1.0")
- # if self.wechat_num >= self.MXA_MSG:
- # self.wechat_num = 0
- # self.wechat_num += 1
- # self.wechat_show = self.wechat_num
- # self.record_test.start("/usr/static/storage_file/{}.amr".format(self.wechat_show),16)
- self.record_test.start("/usr/static/storage_file/wechat.amr",16)
-
- else:
- self.timeSecond = 0
- self.press_btn = 0
- def get_wechat_state(self, event, msg):
- return self.press_btn
-
- def send_wechat_record(self, event, msg): #发送录音文件
- if self.press_btn == 1:
- self.press_btn = 0
- self.record_test.stop() #停止錄音
- EventMesh.publish("stop_led_timer")#关闭灯
- EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功
- # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.LONG_LIGHT_GREEN,led_mode.OPEN_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#測量成功
- self.countdown_old = 0
+ if flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ if self.wechat_recode_list != None:
+ num = 0
+ play_state = 0
+ if len(self.wechat_recode_list) > 1:
+ num = int(self.wechat_recode_list["num"])
+ #EventMesh.debug_log("self.wechat_recode_list1:{}".format(self.wechat_recode_list))
+ if num != 0:
+ last_num = str("%02d"%(num))
+ last_tmp = self.wechat_recode_list[last_num]
+ last_read = int(last_tmp.split(":")[1])
+ if last_read == 1:#如果最后一条没有读则读最新的一条
+ self.wechat_recode_list[last_num] = "read:0"
+ self.wechat_recode_list["num"] = num
+ with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
+ else:
+ sotr_new = {}
+ sotr_new = sorted(self.wechat_recode_list.keys(), reverse=True)#降序排序
+ # EventMesh.debug_log("sotr_new:{}".format(sotr_new))
+ for i in range(len(self.wechat_recode_list)-1):#1 01 02
+ key = sotr_new[i+1]
+ num_id = int(key)
+ #EventMesh.debug_log("key:{} num_id:{}".format(key,num_id))
+ if key in self.wechat_recode_list:#
+ str_tmp = self.wechat_recode_list[key]
+ read = int(str_tmp.split(":")[1])
+ if read != 0:#未读是按一下播放下一条同时删除
+ check_amr = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(num_id))#还要检测这个文件是否存在
+ if check_amr == True:
+ self.wechat_recode_list[key] = "read:0"
+ self.wechat_recode_list["num"] = num
+ EventMesh.debug_log("self.wechat_recode_list2:{} num_id:{} num:{}".format(self.wechat_recode_list,num_id,num))
+ # self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num)) #文件名前面要加上路径
+ play_state = 1
+ with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
+ break
+ else:
+ continue
+ else:
+ continue
+ else:
+ continue
+ #EventMesh.debug_log("play_state:{}".format(play_state))
+ # if play_state == 0:#
+ check_amr = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(num))#还要检测这个文件是否存在
+ if check_amr == True:
+ self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num)) #文件名前面要加上路径
- date_tmp = utime.localtime()
- time_tmp = utime.mktime(date_tmp)
- self.countdown_old = msg
- if self.countdown_old >= 15:
- self.countdown_old = 15
- if self.countdown_old <= 0:
- #录音时间太短
- return
- else:
- # self.wechat_recode_list["%02d"%(self.wechat_show)] = "read:0"
- # self.wechat_recode_list["num"] = self.wechat_show
- EventMesh.debug_log("self.wechat_recode_list :{}".format(self.wechat_recode_list))
-
- # with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
- # ujson.dump(self.wechat_recode_list,fd)
- EventMesh.debug_log("send wechat data!!!!!!!!!!!!!!!!!!!!!")
-
- check_txt = ql_fs.path_exists("/usr/static/storage_file/wechat.amr")
- if check_txt == True :
- path = "/usr/static/storage_file/wechat.amr"
- with open(path,"rb") as fd:
- buf = bytearray(ql_fs.path_getsize(path))
- fd.readinto(buf)
- senddata = [self.countdown_old,buf]
- EventMesh.publish(constants.PROTOCOL.TKS_SEND,senddata)
-
- # with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
- # ujson.dump(self.wechat_recode_list,fd)
- # EventMesh.debug_log("send wechat data!!!!!!!!!!!!!!!!!!!!!")
-
- # check_txt = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(self.wechat_show))
- # if check_txt == True :
- # path = "/usr/static/storage_file/{}.amr".format(self.wechat_show)
- # with open(path,"rb") as fd:
- # buf = bytearray(ql_fs.path_getsize(path))
- # fd.readinto(buf)
- # senddata = [self.countdown_old,buf]
- # EventMesh.publish(constants.PROTOCOL.TKS_SEND,senddata)
-
-
- def play_wechat_last_amr(self, event, msg):#播放微聊最后一条语音文件
- flag = EventMesh.publish("get_call_state")
- if flag == 0:#电话通话中 或者呼叫中挂断中断
- EventMesh.publish("close_timer_all")#
- if self.wechat_recode_list != None:
- num = 0
- play_state = 0
- if len(self.wechat_recode_list) > 1:
- num = int(self.wechat_recode_list["num"])
- #EventMesh.debug_log("self.wechat_recode_list1:{}".format(self.wechat_recode_list))
- if num != 0:
- last_num = str("%02d"%(num))
- last_tmp = self.wechat_recode_list[last_num]
- last_read = int(last_tmp.split(":")[1])
- if last_read == 1:#如果最后一条没有读则读最新的一条
- self.wechat_recode_list[last_num] = "read:0"
- self.wechat_recode_list["num"] = num
- with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
- ujson.dump(self.wechat_recode_list,fd)
- else:
- sotr_new = {}
- sotr_new = sorted(self.wechat_recode_list.keys(), reverse=True)#降序排序
- # EventMesh.debug_log("sotr_new:{}".format(sotr_new))
+ def play_unread_wechat_infor(self,event,msg):#未读微聊语音
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0 and self.press_btn == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ if self.wechat_recode_list != None:
+ num = 0
+ play_state = 0
+ if len(self.wechat_recode_list) > 1:
+ num = int(self.wechat_recode_list["num"])
+ if num != 0:
for i in range(len(self.wechat_recode_list)-1):#1 01 02
- key = sotr_new[i+1]
- num_id = int(key)
- #EventMesh.debug_log("key:{} num_id:{}".format(key,num_id))
+ key = "%02d"%(i+1)
if key in self.wechat_recode_list:#
str_tmp = self.wechat_recode_list[key]
read = int(str_tmp.split(":")[1])
- if read != 0:#未读是按一下播放下一条同时删除
- check_amr = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(num_id))#还要检测这个文件是否存在
- if check_amr == True:
- self.wechat_recode_list[key] = "read:0"
- self.wechat_recode_list["num"] = num
- EventMesh.debug_log("self.wechat_recode_list2:{} num_id:{} num:{}".format(self.wechat_recode_list,num_id,num))
- # self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num)) #文件名前面要加上路径
- play_state = 1
- with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
- ujson.dump(self.wechat_recode_list,fd)
- break
- else:
- continue
+ if read == 1:#未读是按一下播放下一条同时删除
+ play_state = 1
else:
continue
else:
continue
- #EventMesh.debug_log("play_state:{}".format(play_state))
- # if play_state == 0:#
- check_amr = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(num))#还要检测这个文件是否存在
- if check_amr == True:
- self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num)) #文件名前面要加上路径
-
-
- def play_unread_wechat_infor(self,event,msg):#未读微聊语音
- flag = EventMesh.publish("get_call_state")
- if flag == 0 and self.press_btn == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
- if self.wechat_recode_list != None:
- num = 0
- play_state = 0
- if len(self.wechat_recode_list) > 1:
- num = int(self.wechat_recode_list["num"])
- if num != 0:
- for i in range(len(self.wechat_recode_list)-1):#1 01 02
- key = "%02d"%(i+1)
- if key in self.wechat_recode_list:#
- str_tmp = self.wechat_recode_list[key]
- read = int(str_tmp.split(":")[1])
- if read == 1:#未读是按一下播放下一条同时删除
- play_state = 1
- else:
- continue
+ if play_state == 1:#设置未读语音状态
+ EventMesh.publish("set_unread_wechat_state",1)
else:
- continue
- if play_state == 1:#设置未读语音状态
- EventMesh.publish("set_unread_wechat_state",1)
- else:
- EventMesh.publish("set_unread_wechat_state",0)
- self.updateTime = 0
+ EventMesh.publish("set_unread_wechat_state",0)
+ self.updateTime = 0
- state = EventMesh.publish("get_unread_wechat_state")#
- date_tmp = utime.localtime()
- time_tmp = utime.mktime(date_tmp)
- if state != None:
- if state == 1:
- EventMesh.publish("set_led_time_arg",[1,2,8,led_mode.FLASH_LIGHT_GREEN,8,4,led_mode.OTHER_MEASURE_MODE])#測量成功
- # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
- if self.updateTime == 0:
- self.updateTime = time_tmp
- if self.updateTime != 0:
- if time_tmp - self.updateTime >= 10*60:
+ state = EventMesh.publish("get_unread_wechat_state")#
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ if state != None:
+ if state == 1:
+ EventMesh.publish("set_led_time_arg",[1,2,8,led_mode.FLASH_LIGHT_GREEN,8,4,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ if self.updateTime == 0:
self.updateTime = time_tmp
- #播放音频文件
- EventMesh.publish("close_timer_all")
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_UNREAD_WECHAT"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
- else:
- self.updateTime = 0
-
+ if self.updateTime != 0:
+ if time_tmp - self.updateTime >= 10*60:
+ self.updateTime = time_tmp
+ #播放音频文件
+ EventMesh.publish("close_timer_all")
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_UNREAD_WECHAT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ self.updateTime = 0
+
-class BtnDevice(Abstract):
+ class BtnDevice(Abstract):
- def __init__(self, tp=None):
- self.pk = PowerKey()
- self.__pwk_timer = osTimer()
- self.aud = audio.Audio(0)
- self.aud.set_pa(Pin.GPIO29)
- self.aud.setVolume(11)
- # self.keypad = machine.KeyPad(1, 2)
- self.__PowerDownTimeOut = 3000
- self.__tp = tp
- self.pwk_press = 0
- self.pwk_count = 0
- self.GPIO26_status = 1#默认是低电平
- self.powerKey_status = 0
- self.sosKey = 0
- self.wechatKey = 0
- self.sosKey_status = 1#默认是低电平
- self.WeChatKey_status = 1#默认是低电平
+ def __init__(self, tp=None):
+ self.pk = PowerKey()
+ self.__pwk_timer = osTimer()
+ self.aud = audio.Audio(0)
+ self.aud.set_pa(Pin.GPIO29)
+ self.aud.setVolume(11)
+ # self.keypad = machine.KeyPad(1, 2)
+ self.__PowerDownTimeOut = 3000
+ self.__tp = tp
+ self.pwk_press = 0
+ self.pwk_count = 0
+ self.GPIO26_status = 1#默认是低电平
+ self.powerKey_status = 0
+ self.sosKey = 0
+ self.wechatKey = 0
+ self.sosKey_status = 1#默认是低电平
+ self.WeChatKey_status = 1#默认是低电平
- self.wechatKey_timer = osTimer()
- self.wechatKey_count = 0
- self.wechatKey_press = 0
+ self.wechatKey_timer = osTimer()
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
- self.sosKey_timer = osTimer()
- self.sosKey_count = 0
- self.sosKey_press = 0
+ self.sosKey_timer = osTimer()
+ self.sosKey_count = 0
+ self.sosKey_press = 0
- self.wechatKey_press_count = 0
+ self.wechatKey_press_count = 0
- self.timeSeconOld = 0
- self.wechat_state = 1 #按下录音时的状态
+ self.timeSeconOld = 0
+ self.wechat_state = 1 #按下录音时的状态
-
- self.sosKey_press_count = 0
-
-
- self.pwkey_timer = osTimer()
- self.pwKey_press_count = 0
- self.pwkey_count = 0
- self.pwkey_press = 0
- self.led_state = 0
- self.hsensorTest_timer = osTimer()
- self.btnInfo_queue = Queue()
- _thread.stack_size(10*1024+192)
- _thread.start_new_thread(self.btnInfo_queue_thread, ())
- _thread.stack_size(8*1024)
-
- EventMesh.subscribe("publish_message_event_btnInfo",self.publish_message_event_btnInfo)
-
- EventMesh.subscribe("close_wechat_btn_timer", self.close_wechat_btn_timer)#来电强制关闭微聊语音
-
- def btnInfo_queue_thread(self):
- while True:
- data = self.btnInfo_queue.get()
- #EventMesh.debug_log("Info_queue:data = {}".format(data))
- if data != None:
- try:
- data["func"](data["data"])
- except Exception as e:
- EventMesh.debug_log("btnInfo_queue:ERROR:{}".format(e))
- usys.print_exception(e)
- def publish_message_event_btnInfo(self,event,msg):
- self.btnInfo_queue.put(msg)
- EventMesh.publish(constants.EVENT.SYSTEM_UP)#唤醒休眠
-
- def publish_wechat_btn_event_cb(self, *args, **kwargs):
- EventMesh.publish("publish_message_event_btnInfo",{"func":self.wechatKey_press_cb,"data":0})
+
+ self.sosKey_press_count = 0
+
+
+ self.pwkey_timer = osTimer()
+ self.pwKey_press_count = 0
+ self.pwkey_count = 0
+ self.pwkey_press = 0
+ self.led_state = 0
+ self.hsensorTest_timer = osTimer()
+ self.btnInfo_queue = Queue()
+ _thread.stack_size(10*1024+192)
+ _thread.start_new_thread(self.btnInfo_queue_thread, ())
+ _thread.stack_size(8*1024)
+
+ EventMesh.subscribe("publish_message_event_btnInfo",self.publish_message_event_btnInfo)
+
+ EventMesh.subscribe("close_wechat_btn_timer", self.close_wechat_btn_timer)#来电强制关闭微聊语音
+
+ def btnInfo_queue_thread(self):
+ while True:
+ data = self.btnInfo_queue.get()
+ #EventMesh.debug_log("Info_queue:data = {}".format(data))
+ if data != None:
+ try:
+ data["func"](data["data"])
+ except Exception as e:
+ EventMesh.debug_log("btnInfo_queue:ERROR:{}".format(e))
+ usys.print_exception(e)
+ def publish_message_event_btnInfo(self,event,msg):
+ self.btnInfo_queue.put(msg)
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)#唤醒休眠
+
+ def publish_wechat_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.wechatKey_press_cb,"data":0})
- def publish_soskey_btn_event_cb(self, *args, **kwargs):
- EventMesh.publish("publish_message_event_btnInfo",{"func":self.sosKey_press_cb,"data":0})
+ def publish_soskey_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.sosKey_press_cb,"data":0})
- def publish_pwkKey_btn_event_cb(self, *args, **kwargs):
- EventMesh.publish("publish_message_event_btnInfo",{"func":self.pwKey_press_cb,"data":0})
+ def publish_pwkKey_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.pwKey_press_cb,"data":0})
-
+
- def post_processor_after_instantiation(self):
- # self.keypad.init()
- # self.keypad.set_callback(self.key_callback)
-
- self.pk.powerKeyEventRegister(self.powerKey_callback)
+ def post_processor_after_instantiation(self):
+ # self.keypad.init()
+ # self.keypad.set_callback(self.key_callback)
- self.extint = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, self.pwk_extint_cb)
- self.extint.enable()
-
- self.sosKey = ExtInt(ExtInt.GPIO22, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.sosKey_extint_cb)
- self.sosKey.enable()
+ self.pk.powerKeyEventRegister(self.powerKey_callback)
+
+ self.extint = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, self.pwk_extint_cb)
+ self.extint.enable()
- self.wechatKey = ExtInt(ExtInt.GPIO20, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.wechatKey_extint_cb)
- self.wechatKey.enable()
+ self.sosKey = ExtInt(ExtInt.GPIO22, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.sosKey_extint_cb)
+ self.sosKey.enable()
- key19 = Pin(Pin.GPIO19, Pin.OUT, Pin.PULL_PU, 0)
+ self.wechatKey = ExtInt(ExtInt.GPIO20, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.wechatKey_extint_cb)
+ self.wechatKey.enable()
- def pwk_extint_cb(self,args):#侧边按键
- self.GPIO26_status = self.extint.read_level()
- # EventMesh.debug_log('### key20_extint_cb {} self.GPIO26_status :{}'.format(args,self.GPIO26_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
- power_off = EventMesh.publish("get_power_off_state")#获取关机标识
- if power_off != None:
- if power_off == 1:
- return
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
- if fall_down != None:
- if fall_down != 0:
- return
- if self.sosKey_status != 0 and self.WeChatKey_status != 0:
- if self.GPIO26_status == 0:#按下
- if self.pwkey_press == 0 :
- self.aud.stop() #播放声音
- # self.wechatKey_timeout_cb(0)
- # self.sosKey_timeout_cb(0)
- self.wechatKey_timer.stop()
- self.pwkey_timer.stop()
- self.sosKey_timer.stop()
- self.wechatKey_press_count = 0
- self.sosKey_press_count = 0
- self.sosKey_press = 0
- self.wechatKey_press = 0
+ key19 = Pin(Pin.GPIO19, Pin.OUT, Pin.PULL_PU, 0)
- self.pwkey_press = 1
- self.pwkey_count = 0
- self.led_state = 0
- self.pwkey_timer.start(100, 1, self.publish_pwkKey_btn_event_cb)
- # EventMesh.debug_log("key22_extint_cb:self.key22_timer.start!!!!\n")
-
- def pwKey_press_cb(self, data):
- '''KEY2:联动屏幕右下角或返回键长按关机'''
- if self.pwkey_press == 1 :
- self.pwkey_count += 1
- if self.pwkey_count > 5:
- if self.led_state == 0:
- self.led_state = 1
- EventMesh.publish("set_led_time_arg",[1,1,330,led_mode.LONG_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
- if self.pwkey_count >= 10*10:
- EventMesh.publish("stop_led_timer")#设置参数
- self.pwkey_timer.stop()
- self.pwkey_count = 0
- self.pwkey_press = 0
- self.pwKey_press_count = 0
- self.led_state = 0
- # if EventMesh.publish("get_sim_Status") != 1:
- # EventMesh.publish("open_power_on", 2)#
- # else:
- EventMesh.publish("open_power_on", 3)#
+ def pwk_extint_cb(self,args):#侧边按键
+ # self.GPIO26_status = self.extint.read_level()
+ self.GPIO26_status = int(args[1])
+ if self.GPIO26_status == 0:
+ self.GPIO26_status = 1
+ else:
+ self.GPIO26_status = 0
+ pass
+ # EventMesh.debug_log('### key20_extint_cb {} self.GPIO26_status :{}'.format(args,self.GPIO26_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+ power_off = EventMesh.publish("get_power_off_state")#获取关机标识
+ if power_off != None:
+ if power_off == 1:
return
-
- if self.pwkey_count >= 3*10 :
- if EventMesh.publish("get_sim_Status") != 1:
- EventMesh.debug_log("长3秒关机")
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ return
+ if self.sosKey_status != 0 and self.WeChatKey_status != 0:
+ if self.GPIO26_status == 0:#按下
+ if self.pwkey_press == 0 :
+ self.aud.stop() #播放声音
+ # self.wechatKey_timeout_cb(0)
+ # self.sosKey_timeout_cb(0)
+ self.wechatKey_timer.stop()
+ self.pwkey_timer.stop()
+ self.sosKey_timer.stop()
+ self.wechatKey_press_count = 0
+ self.sosKey_press_count = 0
+ self.sosKey_press = 0
+ self.wechatKey_press = 0
+
+ self.pwkey_press = 1
+ self.pwkey_count = 0
+ self.led_state = 0
+ self.pwkey_timer.start(100, 1, self.publish_pwkKey_btn_event_cb)
+ # EventMesh.debug_log("key22_extint_cb:self.key22_timer.start!!!!\n")
+
+ def pwKey_press_cb(self, data):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.pwkey_press == 1 :
+ self.pwkey_count += 1
+ if self.pwkey_count > 5:
+ if self.led_state == 0:
+ self.led_state = 1
+ EventMesh.publish("set_led_time_arg",[1,1,330,led_mode.LONG_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
+ if self.pwkey_count >= 10*10:
EventMesh.publish("stop_led_timer")#设置参数
self.pwkey_timer.stop()
self.pwkey_count = 0
self.pwkey_press = 0
self.pwKey_press_count = 0
self.led_state = 0
- EventMesh.publish("open_power_on", 2)#
+ # if EventMesh.publish("get_sim_Status") != 1:
+ # EventMesh.publish("open_power_on", 2)#
+ # else:
+ EventMesh.publish("open_power_on", 3)#
return
-
+
+ if self.pwkey_count >= 3*10 :
+ if EventMesh.publish("get_sim_Status") != 1:
+ EventMesh.debug_log("长3秒关机")
+ EventMesh.publish("stop_led_timer")#设置参数
+ self.pwkey_timer.stop()
+ self.pwkey_count = 0
+ self.pwkey_press = 0
+ self.pwKey_press_count = 0
+ self.led_state = 0
+ EventMesh.publish("open_power_on", 2)#
+ return
+
+
+ if self.GPIO26_status == 1:#松开
+ if self.pwkey_count >= 1: #防抖100ms
+ # EventMesh.debug_log("self.GPIO26_status == 1")
+ self.pwkey_timer.stop()
+ self.pwkey_count = 0
+ self.pwkey_press = 0
+ self.led_state = 0
+ self.pwKey_press_count+=1
+ self.pwkey_timer.start(500, 0, self.publish_pwKey_timeout_cb_do)#松手超时1s判断
+
+ def hsensorTest_timer_cb(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ w_data = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+ #EventMesh.debug_log("FactoryModeHsensorTest{}".format(data))
+
+ c_data = self.Hsensor.get_test_data()#校准数据和工厂数据
+ # text_data = " 佩戴状态\n红外:{}活体:{}佩戴:{}\n{},{} \n{},{} \n{},{}\n校准数据:{},{},{},{}\n漏光数据:{},{},{}".format(
+ # c_data[3],c_data[4],w_data,c_data[5],c_data[6],c_data[7],c_data[8],c_data[9],c_data[10],
+ # c_data[11],c_data[12],c_data[13],c_data[14],c_data[0],c_data[1],c_data[2],)
- if self.GPIO26_status == 1:#松开
- if self.pwkey_count >= 1: #防抖100ms
- # EventMesh.debug_log("self.GPIO26_status == 1")
- self.pwkey_timer.stop()
- self.pwkey_count = 0
- self.pwkey_press = 0
- self.led_state = 0
- self.pwKey_press_count+=1
- self.pwkey_timer.start(500, 0, self.publish_pwKey_timeout_cb_do)#松手超时1s判断
-
- def hsensorTest_timer_cb(self,e):
- EventMesh.publish("system_sleep_rest")#防止黑屏
- w_data = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
- #EventMesh.debug_log("FactoryModeHsensorTest{}".format(data))
-
- c_data = self.Hsensor.get_test_data()#校准数据和工厂数据
- # text_data = " 佩戴状态\n红外:{}活体:{}佩戴:{}\n{},{} \n{},{} \n{},{}\n校准数据:{},{},{},{}\n漏光数据:{},{},{}".format(
- # c_data[3],c_data[4],w_data,c_data[5],c_data[6],c_data[7],c_data[8],c_data[9],c_data[10],
- # c_data[11],c_data[12],c_data[13],c_data[14],c_data[0],c_data[1],c_data[2],)
-
- if(self.hsensorTest_timer_count != 0):
- self.hsensorTest_timer_count -= 1
- if self.hsensorTest_timer_count%5 == 0:
- EventMesh.debug_log("c_data:{} {} {} {}".format(c_data[11],c_data[12],c_data[13],c_data[14]))
- if c_data[11] != 0 and c_data[13] != 0: #校准成功
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ if(self.hsensorTest_timer_count != 0):
+ self.hsensorTest_timer_count -= 1
+ if self.hsensorTest_timer_count%5 == 0:
+ EventMesh.debug_log("c_data:{} {} {} {}".format(c_data[11],c_data[12],c_data[13],c_data[14]))
+ if c_data[11] != 0 and c_data[13] != 0: #校准成功
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ self.Hsensor.close()
+ self.Hsensor.init()
+ self.hsensorTest_timer.stop()
+ return
+ if self.hsensorTest_timer_count == 0:#50秒超时,失败
self.Hsensor.close()
- self.Hsensor.init()
+ self.Hsensor.init();
self.hsensorTest_timer.stop()
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ def publish_pwKey_timeout_cb_do(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.pwKey_timeout_cb,"data":0})
+
+ def pwKey_timeout_cb(self, data):#侧边按键
+ boot_count = EventMesh.publish("get_boot_time_count")
+ try :
+ if boot_count < 50 :#开机50秒内按键次数大于10就校准
+ #EventMesh.debug_log("boot_count:{}".format(boot_count))
+ if self.pwKey_press_count >= 6:
+ self.Hsensor = EventMesh.publish("get_Hsensor")
+ self.hsensorTest_timer.start(1000,1,self.hsensorTest_timer_cb)
+ EventMesh.debug_log("打开校准模式")
+ self.Hsensor.set_sar(1)
+ self.Hsensor.open_test(255) #打开校准模式
+ utime.sleep_ms(500)
+ self.Hsensor.open_heart()
+ self.hsensorTest_timer_count = 50
+ self.hsensorTest_timer.start(1000,1,self.hsensorTest_timer_cb)
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_HSENSOR_SPO2_TITLE"),)
+ EventMesh.publish("play_audio_file",[str_data,1])
+ self.pwKey_press_count = 0
return
- if self.hsensorTest_timer_count == 0:#50秒超时,失败
- self.Hsensor.close()
- self.Hsensor.init();
- self.hsensorTest_timer.stop()
- str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
- EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
- def publish_pwKey_timeout_cb_do(self, *args, **kwargs):
- EventMesh.publish("publish_message_event_btnInfo",{"func":self.pwKey_timeout_cb,"data":0})
-
- def pwKey_timeout_cb(self, data):#侧边按键
- boot_count = EventMesh.publish("get_boot_time_count")
- try :
- if boot_count < 50 :#开机50秒内按键次数大于10就校准
- #EventMesh.debug_log("boot_count:{}".format(boot_count))
- if self.pwKey_press_count >= 6:
- self.Hsensor = EventMesh.publish("get_Hsensor")
- self.hsensorTest_timer.start(1000,1,self.hsensorTest_timer_cb)
- EventMesh.debug_log("打开校准模式")
- self.Hsensor.set_sar(1)
- self.Hsensor.open_test(255) #打开校准模式
- utime.sleep_ms(500)
- self.Hsensor.open_heart()
- self.hsensorTest_timer_count = 50
- self.hsensorTest_timer.start(1000,1,self.hsensorTest_timer_cb)
- str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_HSENSOR_SPO2_TITLE"),)
- EventMesh.publish("play_audio_file",[str_data,1])
- self.pwKey_press_count = 0
- return
- except Exception as e:
- usys.print_exception(e)
- if self.pwKey_press_count >= 1:
- # EventMesh.debug_log("pwKey_timeout_cb:self.pwKey_press_count >= 1")
-
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("dialing_out_event")#电话呼叫中voiceCall.callEnd()
+ except Exception as e:
+ usys.print_exception(e)
+ if self.pwKey_press_count >= 1:
+ self.pwKey_press_count = 0
+ # EventMesh.debug_log("pwKey_timeout_cb:self.pwKey_press_count >= 1")
+ flag = EventMesh.publish("get_call_state")
+ if flag != 2:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("dialing_out_event")#电话呼叫中voiceCall.callEnd()
+
+ if flag == 1:#如果是sos电话拨出去
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("set_hangup_mode",0)
+ EventMesh.publish("close_hr_sop2")#
+ flag = EventMesh.publish("get_call_state")
+ if flag != 1:
+ EventMesh.publish("set_sim_mode")#
- # EventMesh.publish(constants.EVENT.START_LOCATION) #开始定位
- sos_flag = EventMesh.publish("get_sos_flag")
- if sos_flag == 1:
- EventMesh.publish("set_sos_flag",0)
- EventMesh.publish("set_sos_num",0)
- EventMesh.publish("set_hangup_mode",0)
- EventMesh.publish("close_hr_sop2")#
- flag = EventMesh.publish("get_call_state")
- if flag != 1:
- EventMesh.publish("set_sim_mode")#
-
- self.pwKey_press_count = 0
-
- def sosKey_extint_cb(self,args):
- power_off = EventMesh.publish("get_power_off_state")#获取关机标识
- if power_off != None:
- if power_off == 1:
- return
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
- self.sosKey_status = self.sosKey.read_level()
- # EventMesh.debug_log('### key22_extint_cb {} self.GPIO22_status:{}'.format(args,self.sosKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
- if self.WeChatKey_status != 0 and self.GPIO26_status != 0:
- if self.sosKey_status == 0:#按下
- EventMesh.publish("close_falldown_alarm_event")#sos短按事件
- if self.sosKey_press == 0 :
- self.led_state = 0
- self.wechatKey_timer.stop()
- self.pwkey_timer.stop()
- self.sosKey_timer.stop()
- self.wechatKey_press_count = 0
- self.pwKey_press_count = 0
- self.sosKey_press = 1
- self.pwkey_press = 0
- self.wechatKey_press = 0
- self.sosKey_long_press = 0
- self.sosKey_count = 0
- self.sosKey_timer.start(100, 1, self.publish_soskey_btn_event_cb)
- # EventMesh.debug_log("key22_extint_cb:self.key22_timer.start!!!!\n")
-
- def sosKey_press_cb(self, data):
- '''KEY2:联动屏幕右下角或返回键长按关机'''
- if self.sosKey_press == 1 :
- # if self.sosKey_count <= 2:
- # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
- # EventMesh.publish("set_led_time_arg",[1000,200,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
- # else:
- # EventMesh.publish("set_led_time_arg",[1000,200,1,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
- self.sosKey_count += 1
- if self.sosKey_count >= 10*3: #长按3s sos拨号
- self.sosKey_count = 0
- self.sosKey_long_press = 1
- self.sosKey_press = 0
- self.sosKey_timer.stop()
- EventMesh.publish_async("dial_sos_phone")#拨打sos号码
- return
+ self.pwKey_press_count = 0
- # EventMesh.debug_log("self.sosKey_count {}",self.sosKey_count)
- if self.sosKey_status == 1:#松开
- if self.sosKey_count >= 1: #防抖100ms
- self.sosKey_timer.stop()
+ def sosKey_extint_cb(self,args):
+ power_off = EventMesh.publish("get_power_off_state")#获取关机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ # self.sosKey_status = self.sosKey.read_level()
+ self.sosKey_status = int(args[1])
+ if self.sosKey_status == 0:
+ self.sosKey_status = 1
+ else:
+ self.sosKey_status = 0
+ pass
+ # EventMesh.debug_log('### key22_extint_cb {} self.GPIO22_status:{}'.format(args,self.sosKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+ if self.WeChatKey_status != 0 and self.GPIO26_status != 0:
+ if self.sosKey_status == 0:#按下
+ EventMesh.publish("close_falldown_alarm_event")#sos短按事件
+ if self.sosKey_press == 0 :
+ self.led_state = 0
+ self.wechatKey_timer.stop()
+ self.pwkey_timer.stop()
+ self.sosKey_timer.stop()
+ self.wechatKey_press_count = 0
+ self.pwKey_press_count = 0
+ self.sosKey_press = 1
+ self.pwkey_press = 0
+ self.wechatKey_press = 0
+ self.sosKey_long_press = 0
+ self.sosKey_count = 0
+ self.sosKey_timer.start(100, 1, self.publish_soskey_btn_event_cb)
+ # EventMesh.debug_log("key22_extint_cb:self.key22_timer.start!!!!\n")
+
+ def sosKey_press_cb(self, data):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.sosKey_press == 1 :
+ # if self.sosKey_count <= 2:
+ # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
+ # EventMesh.publish("set_led_time_arg",[1000,200,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ # else:
+ # EventMesh.publish("set_led_time_arg",[1000,200,1,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ self.sosKey_count += 1
+ if self.sosKey_count >= 10*3: #长按3s sos拨号
self.sosKey_count = 0
+ self.sosKey_long_press = 1
self.sosKey_press = 0
- self.sosKey_press_count+=1
- self.sosKey_timer.start(500, 0, self.publish_sosKey_timeout_cb_do)#松手超时1s判断
- def publish_sosKey_timeout_cb_do(self, *args, **kwargs):
- EventMesh.publish("publish_message_event_btnInfo",{"func":self.sosKey_timeout_cb,"data":0})
- def sosKey_timeout_cb(self, data):#
- # EventMesh.debug_log("sosKey_press_count!!!!!!!!!!!!!! ",self.sosKey_press_count)
-
- if self.sosKey_press_count == 10:#
- self.sosKey_press_count = 0
- pass
- elif self.sosKey_press_count == 6:#
- self.sosKey_press_count = 0
- pass
- elif self.sosKey_press_count == 5:#功能暂时屏蔽
- self.sosKey_press_count = 0
- call_state = EventMesh.publish("get_call_state")
- battery = EventMesh.publish("screen_get_battery")
- if call_state == None:
- call_state = 0
- if call_state == 0:
- if battery != None:
- if battery[0] != "1":#在充电得时候
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("set_manual_measure_mode",3)#测量体温
- pass
- elif self.sosKey_press_count == 4:#拨打app快捷号码
- self.sosKey_press_count = 0
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("play_center_phone")#拨打快捷号码
- # EventMesh.publish("call_phonebook_three_call")
- pass
- elif self.sosKey_press_count == 3:#测试心率
- self.sosKey_press_count = 0
-
- call_state = EventMesh.publish("get_call_state")
- battery = EventMesh.publish("screen_get_battery")
- if call_state == None:
- call_state = 0
- if call_state == 0:
- if battery != None:
- if battery[0] != "1":#在充电得时候
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("set_manual_measure_mode",1)#
- pass
- elif self.sosKey_press_count == 2:#播报当前步数
- self.sosKey_press_count = 0
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("play_cur_step_event")#
- pass
- elif self.sosKey_press_count == 1:#挂断来电 短语音播报
+ self.sosKey_timer.stop()
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ return
+ EventMesh.publish_async("dial_sos_phone")#拨打sos号码
+ return
+
+ # EventMesh.debug_log("self.sosKey_count {}",self.sosKey_count)
+ if self.sosKey_status == 1:#松开
+ if self.sosKey_count >= 1: #防抖100ms
+ self.sosKey_timer.stop()
+ self.sosKey_count = 0
+ self.sosKey_press = 0
+ self.sosKey_press_count+=1
+ self.sosKey_timer.start(500, 0, self.publish_sosKey_timeout_cb_do)#松手超时1s判断
+ def publish_sosKey_timeout_cb_do(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.sosKey_timeout_cb,"data":0})
+ def sosKey_timeout_cb(self, data):#
+ # EventMesh.debug_log("sosKey_press_count!!!!!!!!!!!!!! ",self.sosKey_press_count)
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if self.sosKey_press_count > 1:#短按十次解绑app
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ self.sosKey_press_count = 0
+ return
+ if self.sosKey_press_count == 10:#
+ self.sosKey_press_count = 0
+ pass
+ elif self.sosKey_press_count == 6:#
+ self.sosKey_press_count = 0
+ pass
+ elif self.sosKey_press_count == 5:#功能暂时屏蔽
+ self.sosKey_press_count = 0
+ call_state = EventMesh.publish("get_call_state")
+ battery = EventMesh.publish("screen_get_battery")
+ if call_state == None:
+ call_state = 0
+ if call_state == 0:
+ if battery != None:
+ if battery[0] != "1":#在充电得时候
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("set_manual_measure_mode",3)#测量体温
+ pass
+ elif self.sosKey_press_count == 4:#拨打app快捷号码
+ self.sosKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("play_center_phone")#拨打快捷号码
+ # EventMesh.publish("call_phonebook_three_call")
+ pass
+ elif self.sosKey_press_count == 3:#测试心率
+ self.sosKey_press_count = 0
+
+ call_state = EventMesh.publish("get_call_state")
+ battery = EventMesh.publish("screen_get_battery")
+ if call_state == None:
+ call_state = 0
+ if call_state == 0:
+ if battery != None:
+ if battery[0] != "1":#在充电得时候
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("set_manual_measure_mode",1)#
+ pass
+ elif self.sosKey_press_count == 2:#播报当前步数
+ self.sosKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("play_cur_step_event")#
+ pass
+ elif self.sosKey_press_count == 1:#挂断来电 短语音播报
+ self.sosKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("sos_short_press")#sos短按事件
+
+ pass
self.sosKey_press_count = 0
- EventMesh.publish("stop_led_timer")#设置参数
- # EventMesh.publish("call_test_event")
- EventMesh.publish("sos_short_press")#sos短按事件
-
- pass
- self.sosKey_press_count = 0
- def wechatKey_extint_cb(self,args):
- power_off = EventMesh.publish("get_power_off_state")#获取关机标识
- if power_off != None:
- if power_off != 0:
- return
- open_power = EventMesh.publish("get_power_on_state")#获取开机标识
- if open_power != None:
- if open_power == 0:
- return
+ def wechatKey_extint_cb(self,args):
+ power_off = EventMesh.publish("get_power_off_state")#获取关机标识
+ if power_off != None:
+ if power_off != 0:
+ return
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0:
+ return
+ # self.WeChatKey_status = self.wechatKey.read_level()
+ self.WeChatKey_status = int(args[1])
+ if self.WeChatKey_status == 0:
+ self.WeChatKey_status = 1
+ else:
+ self.WeChatKey_status = 0
+ pass
+ # EventMesh.debug_log('### wechatKey_extint_cb {} self.WeChatKey_status:{}'.format(args,self.WeChatKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+ if self.sosKey_status != 0 and self.GPIO26_status != 0:
+ if self.WeChatKey_status == 0:#按下
+ if self.wechatKey_press == 0:
+ # self.pwKey_timeout_cb(0)
+ # self.sosKey_timeout_cb(0)
+ self.wechatKey_timer.stop()
+ self.pwkey_timer.stop()
+ self.sosKey_timer.stop()
+ self.sosKey_press_count = 0
+ self.pwKey_press_count = 0
+ self.sosKey_press = 0
+ self.pwkey_press = 0
+ self.wechatKey_press = 1
+ self.led_state = 0
+ self.wechatKey_count = 0
+ self.wechat_state = 1
+ self.wechatKey_timer.start(100, 1, self.publish_wechat_btn_event_cb)
+
+ def close_wechat_btn_timer(self,event,*argc):
+ tmp = EventMesh.publish("get_wechat_time")#获取微聊时间戳
+ wechat_time = 0
+ time_tmp = 0
+ time_sec = 0
- self.WeChatKey_status = self.wechatKey.read_level()
- # EventMesh.debug_log('### wechatKey_extint_cb {} self.WeChatKey_status:{}'.format(args,self.WeChatKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
- if self.sosKey_status != 0 and self.GPIO26_status != 0:
- if self.WeChatKey_status == 0:#按下
- if self.wechatKey_press == 0:
- # self.pwKey_timeout_cb(0)
- # self.sosKey_timeout_cb(0)
+ if tmp != None:
+ if tmp[0] == 1:
self.wechatKey_timer.stop()
- self.pwkey_timer.stop()
- self.sosKey_timer.stop()
- self.sosKey_press_count = 0
- self.pwKey_press_count = 0
- self.sosKey_press = 0
- self.pwkey_press = 0
- self.wechatKey_press = 1
- self.led_state = 0
self.wechatKey_count = 0
- self.wechat_state = 1
- self.wechatKey_timer.start(100, 1, self.publish_wechat_btn_event_cb)
-
- def close_wechat_btn_timer(self,event,*argc):
- tmp = EventMesh.publish("get_wechat_time")#获取微聊时间戳
- wechat_time = 0
- time_tmp = 0
- time_sec = 0
-
- if tmp != None:
- if tmp[0] == 1:
- self.wechatKey_timer.stop()
- self.wechatKey_count = 0
- self.wechatKey_press = 0
- self.wechatKey_press_count=0
- date_tmp = utime.localtime()
- time_tmp = utime.mktime(date_tmp)
- time_sec = tmp[1]
- wechat_time = time_tmp - time_sec
- # EventMesh.debug_log("close_btn_timer",time_tmp,time_sec,wechat_time)
- if wechat_time >= 15:
- wechat_time = 15
- if wechat_time <= 0:
- wechat_time = 0
- EventMesh.publish("send_wechat_record",wechat_time)#发送录音文件内容
-
-
- def wechatKey_press_cb(self,data):
- wechat_time = 0
- tmp = None
- time_sec = 0
- time_tmp = 0
- date_tmp = utime.localtime()
- time_tmp = utime.mktime(date_tmp)
- '''KEY2:联动屏幕右下角或返回键长按关机'''
- if self.wechatKey_press == 1 :#是否按下
- tmp = EventMesh.publish("get_wechat_time")#获取微聊时间戳
- self.wechatKey_count += 1
- if self.wechatKey_count >= 10: #长按1s进入微聊录音
- flag = EventMesh.publish("get_call_state")
- fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
- if flag != None:
- if flag == 0 and fall_down == 0:
- if self.WeChatKey_status == 0:
- if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
- if self.wechat_state == 1:#按下超过s开始录音
- EventMesh.publish("start_wechat_record")#开始录音
+ self.wechatKey_press = 0
+ self.wechatKey_press_count=0
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ time_sec = tmp[1]
+ wechat_time = time_tmp - time_sec
+ # EventMesh.debug_log("close_btn_timer",time_tmp,time_sec,wechat_time)
+ if wechat_time >= 15:
+ wechat_time = 15
+ if wechat_time <= 0:
+ wechat_time = 0
+ EventMesh.publish("send_wechat_record",wechat_time)#发送录音文件内容
+
+
+ def wechatKey_press_cb(self,data):
+ wechat_time = 0
+ tmp = None
+ time_sec = 0
+ time_tmp = 0
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.wechatKey_press == 1 :#是否按下
+ tmp = EventMesh.publish("get_wechat_time")#获取微聊时间戳
+ self.wechatKey_count += 1
+ if self.wechatKey_count >= 10: #长按1s进入微聊录音
+ flag = EventMesh.publish("get_call_state")
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if flag != None:
+ if flag == 0 and fall_down == 0:
+ if self.WeChatKey_status == 0:
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
+ if self.wechat_state == 1:#按下超过s开始录音
+ EventMesh.publish("start_wechat_record")#开始录音
+ self.wechat_state = 0
+ else:
self.wechat_state = 0
- else:
- self.wechat_state = 0
- self.wechatKey_timer.stop()
- self.wechatKey_count = 0
- self.wechatKey_press = 0
- self.wechatKey_press_count=0
- EventMesh.publish("set_sim_mode")#播報imei号
- return
-
- if self.WeChatKey_status == 0:#未松手超过15s啧停止录音
- if self.wechat_state == 0:
- if tmp != None:
- if tmp[0] != 0:
- time_sec = tmp[1]
- if time_tmp - time_sec >= 15:
- wechat_time = time_tmp - time_sec
- if wechat_time >= 15:
- wechat_time = 15
- EventMesh.publish("send_wechat_record",wechat_time)#发送录音文件内容
-
- self.wechatKey_timer.stop()
- self.wechatKey_count = 0
- self.wechatKey_press = 0
- self.wechatKey_press_count=0
- return
- else:
- if self.WeChatKey_status == 1:
- if self.wechat_state == 0:#如果按下时长超过1s且小于长按的时间也认为是录微聊
- if tmp != None:
- if tmp[0] != 0:
- time_sec = tmp[1]
- wechat_time = time_tmp - time_sec
- # EventMesh.debug_log("WECHAT TIEM",time_tmp,time_sec,wechat_time)
- if wechat_time >= 15:
- wechat_time = 15
-
- EventMesh.publish("send_wechat_record",wechat_time)#发送录音文件内容
self.wechatKey_timer.stop()
-
self.wechatKey_count = 0
self.wechatKey_press = 0
self.wechatKey_press_count=0
+ EventMesh.publish("set_sim_mode")#播報imei号
return
- if self.WeChatKey_status == 1:#松开
- if self.wechatKey_count >= 1: #防抖100ms
- # EventMesh.debug_log("WeChat time!!!!!!!!!!!!!!")
- self.wechatKey_timer.stop()
- self.wechatKey_count = 0
- self.wechatKey_press = 0
- self.wechatKey_press_count+=1
- self.wechatKey_timer.start(500, 0, self.publish_wechatKey_btn_event_cb)#松手超时1s判断
-
- def publish_wechatKey_btn_event_cb(self, *args, **kwargs):
- EventMesh.publish("publish_message_event_btnInfo",{"func":self.wechatKey_timeout_cb,"data":0})
-
- def wechatKey_timeout_cb(self,data):#微聊键
-
- if self.wechatKey_press_count > 1:#短按十次解绑app
+ if self.WeChatKey_status == 0:#未松手超过15s啧停止录音
+ if self.wechat_state == 0:
+ if tmp != None:
+ if tmp[0] != 0:
+ time_sec = tmp[1]
+ if time_tmp - time_sec >= 15:
+ wechat_time = time_tmp - time_sec
+ if wechat_time >= 15:
+ wechat_time = 15
+ EventMesh.publish("send_wechat_record",wechat_time)#发送录音文件内容
+
+ self.wechatKey_timer.stop()
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+ self.wechatKey_press_count=0
+ return
+ else:
+ if self.WeChatKey_status == 1:
+ if self.wechat_state == 0:#如果按下时长超过1s且小于长按的时间也认为是录微聊
+ if tmp != None:
+ if tmp[0] != 0:
+ time_sec = tmp[1]
+ wechat_time = time_tmp - time_sec
+ # EventMesh.debug_log("WECHAT TIEM",time_tmp,time_sec,wechat_time)
+ if wechat_time >= 15:
+ wechat_time = 15
+
+ EventMesh.publish("send_wechat_record",wechat_time)#发送录音文件内容
+ self.wechatKey_timer.stop()
+
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+ self.wechatKey_press_count=0
+ return
+ else:
+ self.wechatKey_timer.stop()
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+ self.wechatKey_press_count=0
+ if self.WeChatKey_status == 1:#松开
+ if self.wechatKey_count >= 1: #防抖100ms
+ # EventMesh.debug_log("WeChat time!!!!!!!!!!!!!!")
+ self.wechatKey_timer.stop()
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+ self.wechatKey_press_count+=1
+ self.wechatKey_timer.start(500, 0, self.publish_wechatKey_btn_event_cb)#松手超时1s判断
+
+ def publish_wechatKey_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.wechatKey_timeout_cb,"data":0})
+
+ def wechatKey_timeout_cb(self,data):#微聊键
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
- if fall_down != None:
- if fall_down != 0:
- self.wechatKey_press_count = 0
- return
- # EventMesh.debug_log("wechatKey_timeout_cb!!!!!!!!!!!!!! ",self.wechatKey_press_count)
- if self.wechatKey_press_count == 10:#短按十次解绑app
- self.wechatKey_press_count = 0
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("open_power_on", 4)#恢复出厂
- pass
- elif self.wechatKey_press_count == 6:#短按六次播报imei号
- self.wechatKey_press_count = 0
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("play_imei_event")#播報imei号
- pass
- elif self.wechatKey_press_count == 4:#拨打通讯录号码三
- self.wechatKey_press_count = 0
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("call_phonebook_three_call")
- pass
- elif self.wechatKey_press_count == 3:#拨打通讯录号码二
- self.wechatKey_press_count = 0
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("call_phonebook_two_call")
- pass
- elif self.wechatKey_press_count == 2:#拨打通讯录号码一
- EventMesh.publish("stop_led_timer")#设置参数
- self.wechatKey_press_count = 0
- EventMesh.publish("call_phonebook_one_call")
- # EventMesh.publish("interup_call_event")#
- pass
- elif self.wechatKey_press_count == 1:#播放最后收到的语音
- self.wechatKey_press_count = 0
- EventMesh.publish("stop_led_timer")#设置参数
- call_state = EventMesh.publish("get_call_state")
- if call_state == 0:
- fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if self.wechatKey_press_count > 1:#
if fall_down != None:
- if fall_down != 0:
- EventMesh.publish_async("dial_sos_phone")#拨打sos号码
+ if fall_down != 0 or flag == 2:
+ self.wechatKey_press_count = 0
return
- else:
- if call_state == 2:#电话拨进需要接听
- EventMesh.publish("answer_call_event")#接听电话
- return
- EventMesh.publish("play_wechat_last_amr")
- # pass
- self.wechatKey_press_count = 0
+ # EventMesh.debug_log("wechatKey_timeout_cb!!!!!!!!!!!!!! ",self.wechatKey_press_count)
+ if self.wechatKey_press_count == 10:#短按十次解绑app
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("open_power_on", 4)#恢复出厂
+ pass
+ elif self.wechatKey_press_count == 6:#短按六次播报imei号
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("play_imei_event")#播報imei号
+ pass
+ elif self.wechatKey_press_count == 4:#拨打通讯录号码三
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("call_phonebook_three_call")
+ pass
+ elif self.wechatKey_press_count == 3:#拨打通讯录号码二
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("call_phonebook_two_call")
+ pass
+ elif self.wechatKey_press_count == 2:#拨打通讯录号码一
+ EventMesh.publish("stop_led_timer")#设置参数
+ self.wechatKey_press_count = 0
+ EventMesh.publish("call_phonebook_one_call")
+ # EventMesh.publish("interup_call_event")#
+ pass
+ elif self.wechatKey_press_count == 1:#播放最后收到的语音
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ call_state = EventMesh.publish("get_call_state")
+ if call_state == 0:
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0:
+ EventMesh.publish_async("dial_sos_phone")#拨打sos号码
+ return
+ else:
+ if call_state == 2:#电话拨进需要接听
+ EventMesh.publish("answer_call_event")#接听电话
+ return
+ EventMesh.publish("play_wechat_last_amr")
+ # pass
+ self.wechatKey_press_count = 0
- def pwk_press_cb(self, *args):
- '''KEY2:联动屏幕右下角或返回键长按关机'''
- if self.pwk_press == 1 :
-
- self.pwk_count += 1
- EventMesh.debug_log("self.pwk_count {}",self.pwk_count)
- if self.GPIO26_status == 1:#松开
- if self.pwk_count >= 1: #防抖100ms
+ def pwk_press_cb(self, *args):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.pwk_press == 1 :
+
+ self.pwk_count += 1
+ EventMesh.debug_log("self.pwk_count {}",self.pwk_count)
+ if self.GPIO26_status == 1:#松开
+ if self.pwk_count >= 1: #防抖100ms
+ self.__pwk_timer.stop()
+ self.pwk_count = 0
+ self.pwk_press = 0
+ EventMesh.debug_log("self.GPIO22_status")
+
+ if self.pwk_count > (self.__PowerDownTimeOut//100): #长按
self.__pwk_timer.stop()
self.pwk_count = 0
self.pwk_press = 0
- EventMesh.debug_log("self.GPIO22_status")
-
- if self.pwk_count > (self.__PowerDownTimeOut//100): #长按
- self.__pwk_timer.stop()
- self.pwk_count = 0
- self.pwk_press = 0
- EventMesh.debug_log("btn8_long_press")
-
- def __ui_callback(self, para):
- # EventMesh.debug_log("para = {}".format(para))
- if para == 0:
- EventMesh.publish("done_left_to_right")
- #EventMesh.debug_log("<-")
- elif para == 1:
- EventMesh.publish("done_right_to_left")
- #EventMesh.debug_log("->")
- elif para == 2:
- EventMesh.publish("done_bottom_to_top")
- #EventMesh.debug_log("^")
- elif para == 3:
- EventMesh.publish("done_top_to_bottom")
- #EventMesh.debug_log("V")
- elif para == 4:
- EventMesh.publish("done_return")
- #EventMesh.debug_log("return")
- elif para == 5:
- EventMesh.publish("done_click")
- #EventMesh.debug_log("CLICK")
- elif para == 6:
- EventMesh.publish("done_press")
- #EventMesh.debug_log("press")
- elif (para == 6):
- EventMesh.publish("done_error")
- #EventMesh.debug_log("error")
-
- def key_callback(self, l_list):
- EventMesh.debug_log("key_callback:",str(l_list))
- if l_list[0] == 1:
- # 马达震动预留
- pass
- if (l_list[1] == 3) and (l_list[2] == 0):
+ EventMesh.debug_log("btn8_long_press")
+
+ def __ui_callback(self, para):
+ # EventMesh.debug_log("para = {}".format(para))
+ if para == 0:
+ EventMesh.publish("done_left_to_right")
+ #EventMesh.debug_log("<-")
+ elif para == 1:
+ EventMesh.publish("done_right_to_left")
+ #EventMesh.debug_log("->")
+ elif para == 2:
+ EventMesh.publish("done_bottom_to_top")
+ #EventMesh.debug_log("^")
+ elif para == 3:
+ EventMesh.publish("done_top_to_bottom")
+ #EventMesh.debug_log("V")
+ elif para == 4:
+ EventMesh.publish("done_return")
+ #EventMesh.debug_log("return")
+ elif para == 5:
+ EventMesh.publish("done_click")
+ #EventMesh.debug_log("CLICK")
+ elif para == 6:
+ EventMesh.publish("done_press")
+ #EventMesh.debug_log("press")
+ elif (para == 6):
+ EventMesh.publish("done_error")
+ #EventMesh.debug_log("error")
+
+ def key_callback(self, l_list):
+ EventMesh.debug_log("key_callback:",str(l_list))
if l_list[0] == 1:
- #self.pwk_press = 0
- EventMesh.publish("btn1_press")
- else:
+ # 马达震动预留
pass
- # EventMesh.publish("btn1_press")
+ if (l_list[1] == 3) and (l_list[2] == 0):
+ if l_list[0] == 1:
+ #self.pwk_press = 0
+ EventMesh.publish("btn1_press")
+ else:
+ pass
+ # EventMesh.publish("btn1_press")
- def powerKey_callback(self, status):
- EventMesh.debug_log('==pwr:', status)# 0 1 0
- self.powerKey_status = status
- if self.pwk_press == 1: #按按钮时不处理
- return
-
-
+ def powerKey_callback(self, status):
+ EventMesh.debug_log('==pwr:', status)# 0 1 0
+ self.powerKey_status = status
+ if self.pwk_press == 1: #按按钮时不处理
+ return
+
+
- def power_key_press_cb(self, *args):
- pass
- # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 0:#未插卡的情况下强制关机
- # EventMesh.publish("open_power_on", 2)#
+ def power_key_press_cb(self, *args):
+ pass
+ # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 0:#未插卡的情况下强制关机
+ # EventMesh.publish("open_power_on", 2)#
- def start(self):
- self.post_processor_after_instantiation()
+ def start(self):
+ self.post_processor_after_instantiation()
--- /dev/null
+from common import Abstract
+import machine
+import osTimer
+from misc import PowerKey
+import EventMesh
+from machine import Pin
+from machine import ExtInt
+import constants
+import utime
+import audio
+import ql_fs
+import ujson
+import voiceCall
+from misc import Power
+from led import red_green_light,green_light_fast,led_mode,open_led_red,close_led_red,open_led_green,close_led_green,close_led_white
+from machine import RTC
+from queue import Queue
+import _thread
+import usys
+import sms
+from Gsensor import SC7A20
+if EventMesh.model == "D15_" :
+ motor_pin = Pin(Pin.GPIO20, Pin.OUT, Pin.PULL_PD, 0)
+
+ audio_buf = ['audio_find_haixiu', 'R_ALARM_NEW', 'R_BLOOD_SUGAR', 'R_CALL_mp3', 'R_CHARGE_FULL', 'R_CHARGE_IN', 'R_CHARGE_OUT', 'R_DRINK_ALARM', 'R_FALL_ALARM', 'R_HOME_ALARM', 'R_HSENSOR_RESULT_FAILE', 'R_HSENSOR_RESULT_HR_TITLE', 'R_HSENSOR_RESULT_OK', 'R_HSENSOR_SPO2_TITLE', 'R_HSENSOR_TEMP_TITLE', 'R_MEDICINE_ALARM', 'R_NO_SET_SOS_DIAL', 'R_NO_SIM', 'R_POWER_OFF_1', 'R_READ_STEP_0', 'R_READ_STEP_1', 'R_READ_STEP_2', 'R_READ_STEP_3', 'R_READ_STEP_4', 'R_READ_TIME_0', 'R_READ_TIME_1', 'R_READ_TIME_2', 'R_READ_TIME_3', 'R_READ_TIME_4', 'R_READ_TIME_5', 'R_READ_TIME_6', 'R_READ_TIME_7', 'R_READ_TIME_8', 'R_READ_TIME_9', 'R_READ_TIME_MIN', 'R_READ_TIME_ZHENG', 'R_RESET_ALARM', 'R_RESET_END_ALARM', 'R_SIM_CONNECT', 'R_SIM_FAILE', 'R_SLEEP_ALARM', 'R_SOS_ALERT', 'R_TSENSOR_RESULT_VALUE_DOT', 'R_UNREAD_WECHAT', 'R_WAKEUP_ALARM', 'R_WECHAT_RECV']
+
+ class call:
+ CALL_OUT = 1
+ CALL_IN = 2
+ ON_CALL = 3
+
+
+ class intervManager(Abstract):
+ def __init__(self):
+ self.timer = osTimer()
+
+ self.pwk_timer1 = osTimer()
+ self.pwk_timer2 = osTimer()
+ self.timer1 = osTimer()
+ self.sos_timer2 = osTimer()
+ self.sos_timer1 = osTimer()
+
+ self.sos_sendtime = osTimer()
+
+ self.fall_timer1 = osTimer()
+ self.fall_timer2 = osTimer()
+
+ self.alarm_timer1 = osTimer()
+
+ self.find_timer1 = osTimer()
+ self.fall_flag = 0
+
+ self.factory_timer = osTimer()
+
+ self.restart_timer = osTimer()
+
+ self.aud = audio.Audio(0)
+ self.aud.set_pa(Pin.GPIO29)
+ self.aud.setVolume(11)
+ self.play_count = 0
+ self.count = 0
+
+ self.get_hr_state = 0
+ self.get_spo2_state = 0
+ self.timeSec = 0
+ self.timeTempSec = 0
+
+ self.hr_value = 0
+ self.spo2_value = 0
+ self.temp_value = 0
+
+ self.usbState = 0
+
+ self.setp_old = 0
+ self.step_tmp = ""
+ self.step_num = 0
+ self.power_off = 0
+ self.call_state = 0
+
+ self.find_state = 0
+ self.FIND_timer_count = 0
+
+ self.old_hour = 0
+ self.alarm_state = 0
+ self.alarm_timer_count = 0
+ self.old_min = 0
+ self.interInfo_queue = Queue()
+ _thread.stack_size(10*1024+64)
+ _thread.start_new_thread(self.interInfo_queue_thread, ())
+ _thread.stack_size(8*1024)
+ EventMesh.subscribe("publish_message_event_interInfo",self.publish_message_event_interInfo)
+
+
+ self.audio_event_queue = Queue()
+ _thread.stack_size(10*1024+128)
+ _thread.start_new_thread(self.audio_event_queue_thread, ())
+ _thread.stack_size(8*1024)
+ EventMesh.subscribe("publish_message_event_audio",self.publish_message_event_audio)
+
+ self.record_test = audio.Record()
+ self.record_test.gain(4,12)
+
+ self.timeSecond = 0
+ self.wechat_show = 0
+ self.sort_new = {}
+ self.time_min = 0
+ self.press_btn = 0
+ self.countdown_old = 0
+ self.set_unread_wechat = 0
+ self.updateTime = 0
+
+ self.power_on_flag = 0
+
+ self.MXA_MSG = 1
+ self.wechat_recode_list = {"num":0}
+ self.wechat_num = 0
+ self.read_data = {}
+ self.volum_size = 8
+ self.phone_num = ''
+ self.sos_phone_num = ''
+ self.msg_tmp = ""
+ self.time_count = 0
+ self.alarm_count = 0
+ self.audio_int = 0
+
+ self.hr_auto = 0
+
+ self.temp_auto = 0
+
+ check_txt = ql_fs.path_exists("/usr/static/storage_file/wechat_record.json")
+ if check_txt == True :
+ with open("/usr/static/storage_file/wechat_record.json","r") as fd:#音频文件编号
+ self.wechat_recode_list = ujson.load(fd)
+ if not self.wechat_recode_list:
+ self.wechat_recode_list = {"num":0}
+ self.wechat_num = 0
+ else:
+ self.wechat_recode_list = {"num":0}
+ with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
+
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("open_power_on", self.open_power_on)#开机关机
+
+ EventMesh.subscribe("play_imei_event", self.play_imei_event)#播報imei号
+ EventMesh.subscribe("play_center_phone", self.play_center_phone)#拨打快捷号码
+ EventMesh.subscribe("play_cur_time_event", self.play_cur_time_event)#播放当前时间
+
+ EventMesh.subscribe("OPEN_FIND_WATCH", self.send_find_watch)#查找设备
+ EventMesh.subscribe("STOP_FIND_WATCH", self.stop_find_watch)#是否需要关闭查找设备
+ EventMesh.subscribe("close_timer_all", self.close_timer_all)#关闭相关定时器
+
+ EventMesh.subscribe("dial_sos_phone", self.dial_sos_phone)#长按3s拨打sos求助号码
+
+ EventMesh.subscribe("set_sim_mode", self.set_sim_mode)#sim检测
+
+ EventMesh.subscribe("close_hr_sop2", self.close_hr_sop2)#关闭健康测试
+ EventMesh.subscribe("set_manual_measure_mode", self.set_manual_measure_mode)#设置测试模式
+ EventMesh.subscribe("set_start_measure_time", self.set_start_measure_time)#设置开始测量的时间戳时间
+ EventMesh.subscribe("get_start_measure_time", self.get_start_measure_time)#获取开始测量的时间戳时间
+ EventMesh.subscribe("set_start_temp_measure_time", self.set_start_temp_measure_time)#设置体温开始测量的时间戳时间
+ EventMesh.subscribe("get_start_temp_measure_time", self.get_start_temp_measure_time)#获取体温开始测量的时间戳时间
+ EventMesh.subscribe("play_hr_value", self.play_hr_value)#播放心率数值
+ EventMesh.subscribe("play_spo2_value", self.play_spo2_value)#播放心率数值
+ EventMesh.subscribe("play_temp_value", self.play_temp_value)#播放体温数值
+
+ EventMesh.subscribe("play_sugar_value", self.play_sugar_value)#播放血糖数值
+
+
+ EventMesh.subscribe("set_usb", self.set_usb)#
+ EventMesh.subscribe("get_usb", self.get_usb)#
+
+ EventMesh.subscribe("play_cur_step_event", self.play_cur_step_event)#
+
+ EventMesh.subscribe("set_call_state", self.set_call_state)#1是 拨出去呼叫中 2是播进来 3 是正在通话中 0是无效
+ EventMesh.subscribe("get_call_state", self.get_call_state)#
+ EventMesh.subscribe("interup_call_event", self.interup_call_event)#
+ EventMesh.subscribe("answer_call_event", self.answer_call_event)#接听电话
+ EventMesh.subscribe("dialin_call_event", self.dialin_call_event)#电话拨进响铃
+ EventMesh.subscribe("dialing_out_event", self.dialing_out_event)#电话呼叫中
+ EventMesh.subscribe("call_test_event", self.call_test_event)#电话拨进响铃测试
+
+ EventMesh.subscribe("dial_out_call_center_cb", self.dial_out_call_center_cb)#电话拨出去
+ EventMesh.subscribe("sos_out_call_center_cb", self.sos_out_call_center_cb)#sos拨打
+
+ EventMesh.subscribe("close_audio_play", self.close_audio_play)#关闭音频
+
+
+ EventMesh.subscribe("start_wechat_record", self.start_wechat_record)#手表开始录音
+ EventMesh.subscribe("send_wechat_record", self.send_wechat_record)#发送微聊语音文件to app
+ EventMesh.subscribe("play_wechat_last_amr", self.play_wechat_last_amr)#播放微聊语音最后一条语音文件
+ EventMesh.subscribe("get_wechat_data", self.get_wechat_data)
+ EventMesh.subscribe("set_wechat_data", self.set_wechat_data)
+ EventMesh.subscribe("play_unread_wechat_infor", self.play_unread_wechat_infor)#按键播放最近一条微聊语音
+ EventMesh.subscribe("set_unread_wechat_state", self.set_unread_wechat_state)#设置未读标识
+ EventMesh.subscribe("get_unread_wechat_state", self.get_unread_wechat_state)#获取未读标志
+ EventMesh.subscribe("get_wechat_time", self.get_wechat_time)#获取微聊时间戳
+ EventMesh.subscribe("get_wechat_state", self.get_wechat_state)#获取微聊时间戳
+
+
+ EventMesh.subscribe("get_power_on_state", self.get_power_on_state)#获取开机标识
+ EventMesh.subscribe("get_power_off_state", self.get_power_off_state)#获取关机标识
+
+ EventMesh.subscribe("play_audio_file", self.play_audio_file)#获取播放音频文件
+
+ EventMesh.subscribe("OPEN_ALARM_RING", self.send_alarm_ring)#闹钟到点响铃
+ EventMesh.subscribe("STOP_ALARM_RING", self.stop_alarm_ring)#是否需要关闭闹钟
+
+ EventMesh.subscribe("recv_wechat_audio", self.recv_wechat_audio)#
+
+
+ EventMesh.subscribe("sos_short_press", self.sos_short_press)#sos短按事件
+
+ EventMesh.subscribe("falldown_alarm_event", self.falldown_alarm_event)#跌倒报警
+
+ EventMesh.subscribe("close_falldown_alarm_event", self.close_falldown_alarm_event)#关闭跌倒报警
+
+ EventMesh.subscribe("drink_alarm_event", self.drink_alarm_event)#该喝水了
+
+ EventMesh.subscribe("medicine_alarm_event", self.medicine_alarm_event)#该吃药了
+
+ EventMesh.subscribe("wakeup_alarm_event", self.wakeup_alarm_event)#该起床了
+
+ EventMesh.subscribe("home_alarm_event", self.home_alarm_event)#该回家了
+
+ EventMesh.subscribe("sleep_alarm_event", self.sleep_alarm_event)#该睡觉了
+
+ EventMesh.subscribe("reset_alarm_event", self.reset_alarm_event)#该休息了
+
+ EventMesh.subscribe("reset_end_alarm_event", self.reset_end_alarm_event)#休息结束了
+
+ EventMesh.subscribe("get_fall_down_state", self.get_fall_down_state)#跌倒报警标识
+
+ EventMesh.subscribe("app_factory", self.app_factory)#app恢复出厂
+
+ EventMesh.subscribe("app_restart", self.app_restart)#远程重启
+
+
+
+ def interInfo_queue_thread(self):
+ while True:
+ data = self.interInfo_queue.get()
+ #EventMesh.debug_log("interInfo_queue_thread:data = {}".format(data))
+ if data != None:
+ try:
+ data["func"](data["data"])
+ except Exception as e:
+ EventMesh.debug_log("interInfo_queue_thread:ERROR:{}".format(e))
+ usys.print_exception(e)
+
+ def publish_message_event_interInfo(self,event,msg):
+ self.interInfo_queue.put(msg)
+
+ def publish_call_event_cb(self, *args, **kwargs):#拨打电话
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.call_timer_cb,"data":0})
+
+ def publish_resatrt_down_event_cb(self, *args, **kwargs):#重启设备
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.powe_resatrt_down_fun,"data":0})
+
+ def publish_power_down_event_cb(self, *args, **kwargs):#关机
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.power_down_fun,"data":0})
+
+ def publish_find_watch_event_cb(self, *args, **kwargs):#查找设备
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.FIND_timer_cb,"data":0})
+
+ def publish_alarm_ring_event_cb(self, *args, **kwargs):#闹钟响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.Alarm_timer_cb,"data":0})
+
+ def publish_reset_alarm_ring_event_cb(self, *args, **kwargs):#休息响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.reset_alarm_event_cb,"data":0})
+
+ def publish_reset_end_alarm_ring_event_cb(self, *args, **kwargs):#休息结束响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.reset_end_alarm_event_cb,"data":0})
+
+ def publish_sleep_alarm_ring_event_cb(self, *args, **kwargs):#睡觉响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.sleep_alarm_event_cb,"data":0})
+
+ def publish_home_ring_event_cb(self, *args, **kwargs):#回家响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.home_alarm_event_cb,"data":0})
+
+ def publish_wakeup_ring_event_cb(self, *args, **kwargs):#起床响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.wakeup_alarm_event_cb,"data":0})
+
+ def publish_medicine_ring_event_cb(self, *args, **kwargs):#吃药响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.medicine_alarm_event_cb,"data":0})
+
+ def publish_drink_ring_event_cb(self, *args, **kwargs):#喝水响铃
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.drink_alarm_event_cb,"data":0})
+
+ def publish_fall_done_ring_event_cb(self, *args, **kwargs):#跌倒提醒
+ EventMesh.publish("publish_message_event_interInfo",{"func":self.falldown_alarm_cb,"data":0})
+
+
+ def reset_alarm_event(self,args,msg):#该休息了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_reset_alarm_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ def reset_alarm_event_cb(self,args):#该休息了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+
+ def reset_end_alarm_event(self,args,msg):#休息结束了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.reset_end_alarm_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_END_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+ def reset_end_alarm_event_cb(self,args):#休息结束了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_RESET_END_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+
+ def sleep_alarm_event(self,args,msg):#该睡觉了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_sleep_alarm_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SLEEP_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ def sleep_alarm_event_cb(self,args):#该睡觉了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SLEEP_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+
+
+ def home_alarm_event(self,args,msg):#该回家了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_home_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HOME_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+ def home_alarm_event_cb(self,args):#该回家了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HOME_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+
+ def wakeup_alarm_event(self,args,msg):#该起床了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_wakeup_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_WAKEUP_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+ def wakeup_alarm_event_cb(self,args):#该起床了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_WAKEUP_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+
+
+ def medicine_alarm_event(self,args,msg):#该吃药了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_medicine_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_MEDICINE_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+ def medicine_alarm_event_cb(self,args):#该吃药了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_MEDICINE_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+
+ def drink_alarm_event(self,args,msg):#该喝水了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count = 0
+ self.alarm_timer1.start(2000, 1, self.publish_drink_ring_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_DRINK_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+
+
+ def drink_alarm_event_cb(self,args):#该喝水了
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0 and self.fall_flag == 0:
+ self.alarm_count += 1# 1 2
+ if self.alarm_count >= 3:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_DRINK_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
+ self.alarm_count = 0
+ self.alarm_timer1.stop()
+
+ def falldown_alarm_event(self,args,msg):#跌倒报警启动中提示
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if flag == 0 and wechat_state == 0:
+ EventMesh.publish("close_timer_all")#
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_FALL_ALARM"))
+ self.time_count = 0
+ self.fall_flag = 0
+ self.fall_timer1.stop()
+ self.fall_flag = 1
+ self.fall_timer1.start(4000, 1, self.publish_fall_done_ring_event_cb)
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+ def falldown_alarm_cb(self,*args):
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if self.call_state == 0 and wechat_state == 0:
+ self.time_count+=1
+ if self.time_count >= 5:
+ self.time_count = 0
+ self.fall_timer1.stop()
+ EventMesh.publish_async("dial_sos_phone")#拨打sos号码
+ return
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_FALL_ALARM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ else:
+ self.time_count = 0
+ self.fall_timer1.stop()
+
+ def close_falldown_alarm_event(self,event,msg):#跌倒挂断挂断
+ if self.fall_flag == 1:#跌倒标志
+ self.fall_flag = 0
+ self.fall_timer1.stop()
+ self.sos_timer1.stop()
+ self.sos_timer2.stop()
+ if self.call_state != 0:
+ self.call_state = 0
+ voiceCall.callEnd()
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ self.call_state = 0
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("set_hangup_mode",0)
+
+
+
+ def send_find_watch(self, event, msg): #发送查找设备指令
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ self.find_state = 1
+ self.FIND_timer_count = 0
+ self.alarm_timer1.start(3000,1,self.publish_find_watch_event_cb)
+ EventMesh.publish("set_led_time_arg",[1,1,330,led_mode.LONG_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,33000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("audio_find_haixiu"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ def stop_find_watch(self, event, msg):
+ if self.find_state == 1:
+ self.find_state = 0
+ self.FIND_timer_count = 0
+ # EventMesh.publish("stop_led_timer")#设置参数
+ self.aud.stopPlayStream() #播放声音
+ self.alarm_timer1.stop()
+
+ def FIND_timer_cb(self, data):
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
+ if self.find_state == 1:
+ # EventMesh.debug_log("self.FIND_timer_count:{}".format(self.FIND_timer_count))
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("audio_find_haixiu"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ self.FIND_timer_count += 1
+ if self.FIND_timer_count > 10: #120秒30s
+ EventMesh.publish("STOP_FIND_WATCH")
+ else:
+ self.FIND_timer_count = 0
+ self.alarm_timer1.stop()
+
+
+ def stop_FIND(self) :
+ self.alarm_timer1.stop()
+
+ def send_alarm_ring(self, event, msg): #发送查找设备指令
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ self.alarm_state = 1
+ self.alarm_timer_count = 0
+ self.alarm_timer1.start(3000,1,self.publish_alarm_ring_event_cb)
+ # EventMesh.publish("set_led_time_arg",[1,1,330,led_mode.LONG_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,33000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_ALARM_NEW"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ def stop_alarm_ring(self, event, msg): #停止闹钟响铃
+ if self.alarm_state == 1:
+ self.alarm_state = 0
+ self.alarm_timer_count = 0
+ # EventMesh.publish("stop_led_timer")#设置参数
+ self.aud.stopPlayStream() #停止播放
+ self.alarm_timer1.stop()
+
+ def Alarm_timer_cb(self, data):
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ wechat_state = EventMesh.publish("get_wechat_state")
+ if flag == 0 and wechat_state == 0 and self.fall_flag == 0:
+ if self.alarm_state == 1:
+ # EventMesh.debug_log("self.alarm_timer_count:{}".format(self.alarm_timer_count))
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_ALARM_NEW"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ self.alarm_timer_count += 1
+ if self.alarm_timer_count > 15: #120秒30s
+ EventMesh.publish("STOP_ALARM_RING")
+ else:
+ self.alarm_timer_count = 0
+ self.alarm_timer1.stop()
+
+ def get_fall_down_state(self,event,msg):
+ return self.fall_flag
+
+ def sos_short_press(self,args,msg):
+ EventMesh.publish("interup_call_event")#如果在电话中强制挂断电话
+ EventMesh.publish("close_audio_play")#强制关闭音频文件播放
+ EventMesh.publish("STOP_FIND_WATCH")#停止查找设备
+ EventMesh.publish("STOP_ALARM_RING")#停止闹钟响铃
+ EventMesh.publish("play_cur_time_event")#播报当前时间
+ #播报当前时间
+
+ def recv_wechat_audio(self,event,str_data):#接收微聊语音播放
+ if self.call_state == 0 and self.fall_flag == 0:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_WECHAT_RECV"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+
+
+ def audio_event_queue_thread(self):
+ while True:
+ data = self.audio_event_queue.get()
+ #EventMesh.debug_log("audio_event_queue:data = {}".format(data))
+ if data != None:
+ try:
+ data["func"](data["data"])
+ except Exception as e:
+ EventMesh.debug_log("audio_event_queue:ERROR:{}".format(e))
+ usys.print_exception(e)
+ def publish_message_event_audio(self,event,msg):
+ self.audio_event_queue.put(msg)
+
+ def play_audio_file(self, *args, **kwargs):#播放音频文件
+ # EventMesh.debug_log("args",args)
+ EventMesh.publish("publish_message_event_audio",{"func":self.play_audio_file_do,"data":args[1]})
+
+ def play_audio_file_do(self,data):#msg 拼接的路径文件
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ # EventMesh.debug_log("play_audio_file",data[0],data[1],open_power,power_off)#路径 str_data[1] 是否需要被打断
+ if open_power != None:
+ if open_power == 0:
+ return
+ if power_off != None:
+ if power_off == 1:
+ return
+ self.aud.montage_play('U:/static/audio.bin',1,data[1],data[0])
+ # EventMesh.debug_log("play_audio_file end",data[0],data[1])#路径 str_data[1] 是否需要被打断
+
+
+
+
+
+ def powe_resatrt_down_fun(self, *args):#重启设备
+ EventMesh.publish("close_led_pin")
+ self.aud.stopPlayStream()
+ Power.powerRestart()
+
+ def power_down_fun(self, *args):
+ EventMesh.publish("close_led_pin")
+ self.aud.stopPlayStream()
+ Power.powerDown()
+
+
+
+ def close_audio_play(self, event, msg): #msg
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ if power_off != None:
+ if power_off == 1:
+ return
+ self.aud.stopPlayStream()
+
+
+
+ def close_timer_all(self, event, msg):
+ # EventMesh.debug_log("close_timer_all!!!!!!!!!!!!!!!!!!!")
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ if power_off != None:
+ if power_off == 1:
+ return
+ self.aud.stopPlayStream()
+
+
+ self.timer.stop()
+ self.sos_timer2.stop()
+ self.sos_timer1.stop()
+ self.fall_flag = 0
+ self.fall_timer1.stop()
+ self.alarm_timer1.stop()
+
+
+ def answer_call_event(self, event, msg): #
+ if self.call_state == 2:
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ self.call_state = 0
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("set_hangup_mode",0)
+ EventMesh.publish("close_timer_all")#
+ voiceCall.callAnswer()
+
+ def set_call_state(self, event, msg): #
+ self.call_state = msg
+
+ def dialin_call_event(self, event, msg):
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ EventMesh.publish("close_timer_all")#
+ EventMesh.publish("close_wechat_btn_timer")#
+ EventMesh.publish("set_led_time_arg",[1,2,10*10,led_mode.FLASH_LIGHT_RED,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
+ self.timer.start(6000, 1, self.publish_call_event_cb)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CALL_mp3"))
+ EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件
+ # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ def call_timer_cb(self,data):
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ if self.call_state != 2:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("close_timer_all")#
+ return
+ EventMesh.publish("set_led_time_arg",[1,2,10*10,led_mode.FLASH_LIGHT_RED,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CALL_mp3"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+
+ def dial_out_call_center_cb(self, event, msg):#电话拨出去
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ # EventMesh.debug_log("dial_out_call_center_cb",msg)
+ if self.call_state == 0:
+ self.phone_num = ''
+ EventMesh.publish("close_timer_all")#
+ if msg == None:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ self.phone_num = str(msg)
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
+ EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件
+ self.timer1.start(2000, 0, self.time_out_phone)
+
+
+ def time_out_phone(self, msg):#电话拨出去
+ voiceCall.callStart(self.phone_num)
+
+ def sos_out_call_center_cb(self, event, msg):#sos电话呼叫中
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ self.sos_phone_num = ''
+ # EventMesh.debug_log("sos_out_call_center_cb",msg)
+ if self.call_state == 0:
+
+ EventMesh.publish("close_timer_all")#
+ if msg == None:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+ # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ sos_state = EventMesh.publish("get_dev_state")
+
+ tmp = 1 << 16
+ sos_state = sos_state|tmp #第21位=1
+ EventMesh.publish("set_dev_state",sos_state)
+
+ EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,sos_state]) #开始AL定位
+ EventMesh.publish("close_timer_all")#
+ self.sos_phone_num = msg
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
+ EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件
+ self.sos_timer1.start(2000, 0, self.sos_call_out_phone)
+ self.sos_timer2.start(30000, 0, self.sos_time_out_phone)
+
+
+ def sos_time_out_phone(self, msg):#30s超时未打通或者信号不好则重新拨打
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ if self.call_state == 0:
+ EventMesh.publish("set_sos_info_call")
+
+ def sos_call_out_phone(self, msg):#电话拨出去
+ voiceCall.callStart(self.sos_phone_num)
+
+
+ def call_test_event(self, event, msg):
+ voiceCall.callStart(str("10086"))
+
+ def get_call_state(self, event, msg):
+ return self.call_state
+
+ def interup_call_event(self, event, msg):#侧边金属按钮挂断来电
+ flag = EventMesh.publish("get_call_state")
+ if flag == 2 or flag == 3:#电话通话中 或者呼叫中挂断中断
+ self.call_state = 0
+ voiceCall.callEnd()
+
+ def dialing_out_event(self, event, msg):#侧边金属按键挂断电话呼叫中
+ flag = EventMesh.publish("get_call_state")
+ if flag == 1:#电话呼叫中
+ self.call_state = 0
+ voiceCall.callEnd()
+
+
+
+ def play_cur_step_event(self, event, msg): #msg 1 播放当前步数
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0:#电话通话中 或者呼叫中挂断中断
+ if self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ step = EventMesh.publish("get_old_step_value")
+ EventMesh.debug_log("step",step)
+ self.setp_old = step
+ if step <= 10:#
+ if step == 10:#十步
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:# 9步
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(step)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ elif step <= 100:#十 90
+ if step == 100:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_1"),audio_buf.index("R_READ_STEP_2"),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ step_tmp = str(step)
+ shi_value = int(step_tmp[0])#十
+ ge_value = int(step_tmp[1])#个
+ if shi_value > 1:#大于19步
+ if ge_value == 0:#9十步 70十步
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#9十2步
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#十9步
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ elif step <= 1000:
+ if step == 1000:#1千步
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_1"),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ step_tmp = str(step)#500
+ bai_value = int(step_tmp[0])#百
+ shi_value = int(step_tmp[1])#十
+ ge_value = int(step_tmp[2])#个
+ #101 110 1
+ if shi_value > 0:#110
+ if ge_value == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if shi_value == 0 and ge_value == 0:#500 600
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ elif step <= 10000:#千
+ if step == 10000:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_1"),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ one_thousand = step//1000 #千
+ one_hundred = step%1000 #百
+ baishu = step%100 #十
+ shishu = step%10 #个
+ step_tmp = str(step)
+ qian = int(step_tmp[0])#千
+ bai_value = int(step_tmp[1])#百
+ shi_value = int(step_tmp[2])#十
+ ge_value = int(step_tmp[3])#个
+ if bai_value <= 0:
+ if shi_value <= 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if ge_value == 0:#1020 1040
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#1021
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if shi_value <= 0:#1109
+ if ge_value == 0:#1110
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if ge_value == 0:#1110
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#1117
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ pass
+ elif step <= 100000:#万
+ if step == 100000:#10万步
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ step_tmp = str(step)
+ wang = int(step_tmp[0])#万
+ qian = int(step_tmp[1])#千
+ bai_value = int(step_tmp[2])#百
+ shi_value = int(step_tmp[3])#十
+ ge_value = int(step_tmp[4])#个
+ if wang > 0 and qian > 0 and bai_value > 0:#11109 11111
+ if shi_value <= 0:#11109
+ if ge_value == 0:#11100
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#11108
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ if ge_value == 0:#11110
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#11116
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ elif wang > 0 and qian > 0:#11000 11010 11012 11008
+ if shi_value > 0:
+ if ge_value == 0:#11010
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#11016
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if ge_value == 0:#11000
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#11004
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_{}".format(qian)),\
+ audio_buf.index("R_READ_STEP_1"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ elif wang > 0:#1
+ if bai_value > 0:#百
+ if shi_value > 0:#10110
+ if ge_value == 0:#10150
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#10108
+ if ge_value == 0:#10100
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#10108
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(bai_value)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if shi_value > 0:
+ if ge_value == 0:#10090
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#10098
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(shi_value)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(wang)),\
+ audio_buf.index("R_READ_STEP_0"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge_value)),\
+ audio_buf.index("R_READ_STEP_4"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ def set_usb(self, event, msg): #msg 1 正在充电 2充电已移出 3 充电已满 0
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ flag = EventMesh.publish("get_call_state")
+ 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 msg == 1:
+ if get_hr_state != None and get_spo2_state != None and get_bp_state != None and get_bg_state != None and get_temp_state != None:
+ if get_hr_state != 0:
+
+ EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ if get_hr_state == 1:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("set_start_measure_time",0)#设置开始测量的时间戳时间
+
+ EventMesh.debug_log("stop debug8")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ elif get_spo2_state != 0:
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
+ if get_spo2_state == 1:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ EventMesh.debug_log("stop debug13")
+ elif get_bp_state != 0:
+ EventMesh.publish("set_bp_state",0)#2代表后台进入测试
+ if get_bp_state == 1:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ EventMesh.debug_log("stop bp debug1")
+ elif get_bg_state != 0:
+ EventMesh.publish("set_bg_state",0)#2代表后台进入测试
+ if get_bg_state == 1:#手动开灯关闭灯
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ EventMesh.debug_log("stop BG debug14")
+ if get_temp_state != 0:
+
+ EventMesh.publish("set_temp_state",0)#2代表后台进入测试
+ if get_temp_state == 1:
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("get_start_temp_measure_time",0)#
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+ EventMesh.debug_log("stop temp debug14")
+ if msg == 1:
+ self.usbState = msg
+ str_buf = [1,1,10,led_mode.LONG_LIGHT_RED,4,2,led_mode.CHARGE_IN_MODE]
+ EventMesh.publish("set_led_time_arg",str_buf)#
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ self.aud.stop()
+ self.aud.play(1,1,'U:/static/R_CHARGE_IN.mp3')
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_IN"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.debug_log("charge R_CHARGE_IN")
+
+
+ elif msg == 2:
+ self.usbState = msg
+ EventMesh.publish("stop_led_timer")#设置参数
+ # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.CHARGE_OUT_MODE])#測量成功
+ EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,4,led_mode.CHARGE_OUT_MODE])#測量成功
+ EventMesh.debug_log("charge R_CHARGE_OUT")
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ self.aud.stop()
+ self.aud.play(1,1,'U:/static/R_CHARGE_OUT.mp3')
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_OUT"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+
+ elif msg == 3:
+ self.usbState = msg
+ EventMesh.debug_log("charge full")
+ str_buf = [1,1,10,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.CHARGE_FULL_MODE]
+ EventMesh.publish("set_led_time_arg",str_buf)#
+ # if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ # EventMesh.publish("close_timer_all")#
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_FULL"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+
+ def get_usb(self, event, msg):
+ return self.usbState
+
+
+
+ def app_factory(self,event,msg):
+ if msg != None:
+ number = str(msg)
+ sms.sendPduMsg(number, 'factory# send ok', 'UCS2')
+ ret = 0
+ ret = ql_fs.path_exists("/usr/static/storage_file")#
+ if ret == True:
+ ql_fs.rmdirs("/usr/static/storage_file")
+ ql_fs.mkdirs("/usr/static/storage_file")
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
+ EventMesh.publish(constants.PROTOCOL.DLT_SEND)
+
+ self.factory_timer.start(6*1000,0,self.factory_cb)
+ pass
+ def factory_cb(self,*argc):
+ self.aud.stopPlayStream()
+ Power.powerRestart()
+
+ def app_restart(self,event,msg):#远程发短信重启
+ if msg != None:
+ number = str(msg)
+ sms.sendPduMsg(number, 'reset# send ok', 'UCS2')
+ self.restart_timer.start(3*1000,0,self.app_restart_cb)
+ pass
+ def app_restart_cb(self,*argc):
+ Power.powerRestart()
+
+ def open_power_on(self, event, msg): #msg 1 开机 2 关机 3 重启 4恢复出厂设置 5静音关机
+ EventMesh.publish("close_timer_all")#
+ if msg == 1:
+
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
+ # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ self.pwk_timer1.start(3000,0,self.power_on_audio_cb)
+
+ elif msg == 2:
+ flag = EventMesh.publish("get_call_state")
+ if flag != 0:#电话呼叫中
+ self.call_state = 0
+ voiceCall.callEnd()
+ step = EventMesh.publish("get_old_step_value")
+ # step1 = SC7A20().get_step()
+ # step1 = EventMesh.publish(constants.EVENT.GET_STEP)
+ # step2 = EventMesh.publish("get_storage_config","old_step")
+ self.read_data = EventMesh.publish("get_storage_data")
+ # EventMesh.publish("set_test_data5",[1,step,step1,step2])
+ if step != 0:
+ EventMesh.publish("set_storage_config",["old_step",step])
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ # step3 = EventMesh.publish("get_old_step_value")
+ # step4 = SC7A20().get_step()
+ # step4 = EventMesh.publish(constants.EVENT.GET_STEP)
+ # step5 = EventMesh.publish("get_storage_config","old_step")
+ # EventMesh.publish("set_test_data6",[1,step3,step4,step5])
+ EventMesh.publish("set_storage_config",["old_time",time_tmp])#关机保存一个是时间
+ EventMesh.publish("set_storage_config",["power_state",0])
+ self.pwk_timer1.start(3000,0,self.power_off_audio_cb)
+ elif msg == 3:
+ flag = EventMesh.publish("get_call_state")
+ if flag != 0:#电话呼叫中
+ self.call_state = 0
+ voiceCall.callEnd()
+ self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
+ # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("stop_led_timer")#设置参数
+ self.power_off = 1
+ self.timer.start(8000,0,self.publish_resatrt_down_event_cb)
+ #EventMesh.publish("set_led_time_arg",[3000,4000,1,led_mode.LONG_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE])#
+ elif msg == 4:
+ flag = EventMesh.publish("get_call_state")
+ if flag != 0:#电话呼叫中
+ self.call_state = 0
+ voiceCall.callEnd()
+ EventMesh.publish("stop_led_timer")#设置参数
+ self.power_off = 1
+ ret = 0
+ ret = ql_fs.path_exists("/usr/static/storage_file")#
+ if ret == True:
+ ql_fs.rmdirs("/usr/static/storage_file")
+ ql_fs.mkdirs("/usr/static/storage_file")
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
+ EventMesh.publish(constants.PROTOCOL.DLT_SEND)
+ self.aud.stopPlayStream()
+ self.timer.start(6*1000,0,self.fun)
+ elif msg == 5:
+ flag = EventMesh.publish("get_call_state")
+ if flag != 0:#电话呼叫中
+ self.call_state = 0
+ voiceCall.callEnd()
+ step = EventMesh.publish("get_old_step_value")
+ # step1 = SC7A20().get_step()
+ # step1 = EventMesh.publish(constants.EVENT.GET_STEP)
+ # step2 = EventMesh.publish("get_storage_config","old_step")
+ self.read_data = EventMesh.publish("get_storage_data")
+ # EventMesh.publish("set_test_data7",[1,step,step1,step2])
+ if step != 0:
+ EventMesh.publish("set_storage_config",["old_step",step])
+
+ # step3 = EventMesh.publish("get_old_step_value")
+ # step4 = SC7A20().get_step()
+ # step4 = EventMesh.publish(constants.EVENT.GET_STEP)
+ # step5 = EventMesh.publish("get_storage_config","old_step")
+ # EventMesh.publish("set_test_data8",[1,step3,step4,step5])
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ EventMesh.publish("set_storage_config",["old_time",time_tmp])#关机保存一个是时间
+ EventMesh.publish("set_storage_config",["power_state",1])
+ self.pwk_timer1.start(3000,0,self.power_off_no_audio_cb)#不需要关机铃声
+
+ def fun(self,*argc):
+ self.aud.stopPlayStream()
+ Power.powerRestart()
+
+
+ def power_on_cb(self, msg): #msg 开机标识
+ self.power_on_flag = 1
+ def clear_power_on_cb(self, msg): #msg 开机标识
+ self.power_on_flag = 0
+
+ def power_on_audio_cb(self, msg):
+ self.power_on_flag = 1
+ # EventMesh.debug_log("power_on_audio_cb")
+ power_state = EventMesh.publish("get_storage_config","power_state")
+ if power_state == None:
+ power_state = 0
+ # print("power_state",power_state)
+ if power_state <= 0:
+ self.aud.play(1,1,'U:/static/R_POWER_OFF_1.mp3')
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
+ # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_led_time_arg",[1,2,6*8,led_mode.FLASH_LIGHT_GREEN,6,3,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,200,10,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ self.power_on_flag = 0
+ self.pwk_timer2.start(5000,0,self.power_on_cb)
+
+ def get_power_on_state(self, event, msg):
+ return self.power_on_flag
+
+ def power_off_audio_cb(self, msg):
+ # EventMesh.debug_log("power_off_audio_cb")
+ self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
+ # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_led_time_arg",[1,2,6*8,led_mode.FLASH_LIGHT_RED,6,3,led_mode.POWER_OFF_MODE])#
+ self.power_off = 1
+ self.pwk_timer2.start(6000,0,self.publish_power_down_event_cb)
+
+ def power_off_no_audio_cb(self, msg):
+ EventMesh.debug_log("power_off_no_audio_cb")
+ EventMesh.publish("set_led_time_arg",[1,2,6*8,led_mode.FLASH_LIGHT_RED,6,3,led_mode.POWER_OFF_MODE])#
+ self.power_off = 1
+ self.pwk_timer2.start(6000,0,self.publish_power_down_event_cb)
+
+ def set_power_off_cb(self, msg):
+ self.power_off = 1
+
+ def get_power_off_state(self, event, msg):
+ return self.power_off
+
+ def close_hr_sop2(self, event, msg): #msg 关闭心率血氧体温测试
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ get_temp_state = EventMesh.publish("get_temp_state")
+ get_bg_state = EventMesh.publish("get_bg_state")
+ get_bp_state = EventMesh.publish("get_bp_state")
+ if get_hr_state != None and get_spo2_state != None and get_temp_state != None and get_bg_state != None and get_bp_state != None:
+ if get_hr_state != 0:
+ EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ EventMesh.debug_log("sstop hr")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ if get_spo2_state != 0 :
+ EventMesh.debug_log("stop spo2")
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ if get_temp_state != 0:
+ EventMesh.debug_log("stop temp")
+ EventMesh.publish("set_temp_state",0)
+ EventMesh.publish(constants.EVENT.STOP_TEMP)#手动体温测试
+ if get_bg_state != 0:
+ EventMesh.publish("set_bg_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ EventMesh.debug_log("sstop bg")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+
+ if get_bp_state != 0:
+ EventMesh.publish("set_bp_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ EventMesh.debug_log("sstop bp")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+
+ def set_manual_measure_mode(self, event, msg): #手动测试 1心率 2 血氧 3 体温
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ get_temp_state = EventMesh.publish("get_temp_state")
+ if msg == 1:
+ if get_hr_state != 1:#不是手动测试直接打断
+ EventMesh.debug_log("set_manual_measure_mode",msg)
+ EventMesh.publish("set_hr_state",1)
+ EventMesh.publish("set_start_measure_time",1)#设置开始测量的时间戳时间
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) #停止测试血氧
+ EventMesh.publish("set_hr_blood_led",1)
+ EventMesh.publish(constants.EVENT.START_HEART) #手动心率测试
+ elif msg == 2:
+ if get_hr_state == 0:
+ if get_spo2_state != 1:
+ EventMesh.debug_log("set_manual_measure_mode",msg)
+ EventMesh.publish("set_spo2_state",1)
+ EventMesh.publish("set_start_measure_time",1)#设置开始测量的时间戳时间
+ EventMesh.publish("set_hr_blood_led",1)
+ EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN) #手动血氧测试
+ elif msg == 3:
+ if get_temp_state != 1:
+ EventMesh.debug_log("set_manual_measure_mode",msg)
+ EventMesh.publish("set_temp_state",1)
+ EventMesh.publish("set_start_temp_measure_time",1)#设置开始测量的时间戳时间
+ EventMesh.publish("set_hr_blood_led",1)
+ EventMesh.publish(constants.EVENT.START_TEMP)#手动体温测试
+ pass
+
+
+ def set_start_measure_time(self, event, msg): #手动测试 1心
+ self.hr_auto = msg
+ pass
+
+ def get_start_measure_time(self, event, msg): #手动测试
+
+ return self.hr_auto
+
+ def set_start_temp_measure_time(self, event, msg): #
+ self.temp_auto = msg
+ pass
+
+ def get_start_temp_measure_time(self, event, msg): #
+ return self.temp_auto
+
+ def mearsure_cb(self, event, msg):
+ if msg == 1:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ elif msg == 2:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ elif msg == 3:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ elif msg == 4:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+
+ def play_temp_value(self, event, msg): #播放体温数值
+ flag = EventMesh.publish("get_call_state")
+ if msg != None:
+ if flag == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ if msg > 0:
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",2)#测量成功
+ self.temp_value = msg
+ # self.timer.start(2*1000,1,self.play_temp_fun)
+ self.play_temp_fun(0)
+ else:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
+ else:
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
+
+ def play_temp_fun(self,argc): #播放体温数值
+ data = self.temp_value
+ if data > 42:
+ data = 42
+ data_tmp = str(data)
+ if data_tmp.find(".") != -1:
+ temp_shi = int(data_tmp.split('.')[0])//10
+ temp_ge = int(data_tmp.split('.')[0])%10
+ dot_ge = int(data_tmp.split('.')[1][:1])
+ if temp_ge > 0:#37.0
+ if dot_ge > 0:#37.5
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(temp_ge)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),\
+ audio_buf.index("R_READ_TIME_{}".format(dot_ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:#37.0
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(temp_ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#30.0 30.6
+ if dot_ge > 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(dot_ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
+ audio_buf.index("R_READ_STEP_3"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:
+ temp_shi = int(data_tmp)//10
+ temp_ge = int(data_tmp)%10
+
+ if temp_ge > 0:#45
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(temp_ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_TEMP_TITLE"),audio_buf.index("R_READ_TIME_{}".format(temp_shi)),\
+ audio_buf.index("R_READ_STEP_3"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+ def play_hr_value(self, event, msg): #播放心率数值
+ flag = EventMesh.publish("get_call_state")
+ if msg != None:
+ if flag == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ if msg >= 50:
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ self.hr_value = msg
+ EventMesh.publish("set_hr_blood_led",2)#测量成功
+ # self.timer.start(2*1000,1,self.play_hr_fun)
+ self.play_hr_fun(0)
+ else:
+ str_data ='mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
+ else:
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
+
+ def play_hr_fun(self,argc):#播放心率测试值
+ flag = EventMesh.publish("get_call_state")
+
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ data = self.hr_value
+ if data > 220:
+ data = 220
+ if data < 100:
+ if data%10 == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
+ audio_buf.index("R_READ_STEP_3"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(data%10)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ shi = (data%100)//10 #210
+ ge = (data%100)%10
+ #210 234
+ if shi > 0:
+ if ge == 0:#210 230 120
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi)),audio_buf.index("R_READ_STEP_3"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_{}".format(shi)),audio_buf.index("R_READ_STEP_3"),\
+ audio_buf.index("R_READ_TIME_{}".format(ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if ge == 0:#200 100 209 108
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
+ audio_buf.index("R_READ_STEP_2"))
+ EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//100)),\
+ audio_buf.index("R_READ_STEP_2"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+ def play_sugar_value(self, event, msg): #播放血糖数值
+ flag = EventMesh.publish("get_call_state")
+ if msg != None:
+ if flag == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ if msg != 0:
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",2)#测量成功
+ # self.timer.start(2*1000,1,self.play_spo2_fun)
+ self.play_sugar_fun(msg)
+ else:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
+ else:
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
+
+ def play_sugar_fun(self,argc):#播放血糖测试值
+ flag = EventMesh.publish("get_call_state")
+
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ data = str(argc)
+ data_shi = 0
+ data_ge = 0
+ if data.find(".") != -1:
+ data_shi = int(data.split(".")[0])
+ data_ge = int(data.split(".")[1])
+ else:
+ data_shi = int(data)
+ data_ge = 0
+
+ if data_shi != 0 and data_ge != 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_BLOOD_SUGAR"),audio_buf.index("R_READ_TIME_{}".format(data_shi)),\
+ audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(data_ge)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
+
+
+
+ def play_spo2_value(self, event, msg): #播放血样数值
+ flag = EventMesh.publish("get_call_state")
+ if msg != None:
+ if flag == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+ if msg >= 85:
+ # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",2)#测量成功
+ self.spo2_value = msg
+ # self.timer.start(2*1000,1,self.play_spo2_fun)
+ self.play_spo2_fun(0)
+ else:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
+ else:
+ EventMesh.publish("set_hr_blood_led",3)#测量异常
+
+ def play_spo2_fun(self,argc):#播放血氧测试值
+ flag = EventMesh.publish("get_call_state")
+
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ data = self.spo2_value
+ if data > 100:
+ data = 100
+ if data == 100:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
+ audio_buf.index("R_READ_STEP_2"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if data % 10 == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
+ audio_buf.index("R_READ_STEP_3"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_SPO2_TITLE"),audio_buf.index("R_READ_TIME_{}".format(data//10)),\
+ audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(data%10)))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+ def set_sim_mode(self, event, msg): #mode 1 蓝灯闪烁 可识别卡 但未联网 2 可绑定appsim正常 3 手表不识别卡或者未插卡
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ # EventMesh.publish("stop_led_timer")#设置参数
+ mode = 0
+ signal = EventMesh.publish("screen_get_sig")
+ if signal != None:
+ if signal >= 0 and signal <= 31:#有卡
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网提示关机
+ mode = 2
+ else:
+ mode = 1
+ else:#未插卡
+ mode = 3
+ if mode == 1:#白色灯
+ EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_WHITE,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_WHITE,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ elif mode == 2:#蓝灯色灯
+ EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_GREEN,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_CONNECT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ elif mode == 3:#红灯闪烁
+ EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_RED,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SIM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+
+ def dial_sos_phone(self, event, msg): #拨打紧急求助电话
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0:
+
+ signal = EventMesh.publish("screen_get_sig")
+ if signal != None:
+ if signal >= 0 and signal <= 31:#有卡
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网提示关机
+ sos_number = EventMesh.publish("get_dial_sos_number")
+ if sos_number != None:
+ if len(sos_number) != 0:
+ EventMesh.publish("close_timer_all")#
+ EventMesh.publish("set_sos_flag",1)
+
+ else:#未设置sos紧急求助号码
+ EventMesh.publish("close_timer_all")#
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ EventMesh.publish("close_timer_all")#
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#未插卡
+ EventMesh.publish("close_timer_all")#
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SIM"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ def play_cur_time_event(self, event, msg): #播放当前时间
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+
+ data = RTC().datetime()
+ hour = data[4]
+ min = data[5]
+ # EventMesh.debug_log("hour",hour,min)
+ self.old_hour = hour
+ self.old_min = min
+ if self.old_hour == 0:
+ if self.old_min <= 9:#00:09
+ if self.old_min == 0:#0点整
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#0点09分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(self.old_min))\
+ ,audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+
+ else:
+ if self.old_min % 10 == 0:#0点2十分 0点3十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:#0点2十8分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+
+ elif self.old_hour <= 9:#8:09 9:20 9:45
+ if self.old_min <= 9:#9点09分
+ if self.old_min <= 0:
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(self.old_min))\
+ ,audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:
+ if self.old_min % 10 == 0:#9点2十分 9点4十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min //10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#9点2十4分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(self.old_hour))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min //10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+ else:#12:0
+ if self.old_min == 0:#12:00 13:00 15:00 20 10 11 12 13 14 15
+ self.play_count+=1
+ hour_shi = self.old_hour//10
+ hour_ge = self.old_hour%10
+ if self.old_hour == 10:#十点整
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ elif self.old_hour == 20:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:
+ if hour_shi <= 1:#十3点整
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(hour_ge)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:
+ if self.old_hour == 10:#10:09 10:10
+ if self.old_min <= 9:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_min)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if self.old_min % 10 == 0:#十点2十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min//10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#十点2十1分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(self.old_min//10))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(self.old_min%10))\
+ ,audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:
+ if self.old_hour < 20:#19:00
+ if self.old_min <= 9:#19:09
+ if self.old_min == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT")\
+ ,audio_buf.index("R_READ_TIME_0"),audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10))\
+ ,audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:#19:18 19:40 19:56
+ if self.old_min % 10 == 0:#十9点2十分 十9点3十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10)),audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#十9点2十1分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_hour % 10)),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_min // 10)),audio_buf.index("R_READ_STEP_3")\
+ ,audio_buf.index("R_READ_TIME_{}".format(self.old_min % 10)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:
+ hour_shi = self.old_hour//10
+ hour_ge = self.old_hour%10
+
+ min_shi = self.old_min//10
+ min_ge = self.old_min%10
+
+ #20:08 20:18 20:20
+ if hour_ge == 0:
+ if self.old_min <= 9:
+ if self.old_min == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:
+ if min_ge == 0:#2十点2十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#2十点2十1分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ else:#21:08 21:18
+ if self.old_min <= 9:
+ if self.old_min == 0:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ else:
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_0")\
+ ,audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ if min_ge == 0:#2十3点3十分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:#2十3点3十1分
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(hour_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(hour_ge))\
+ ,audio_buf.index("R_TSENSOR_RESULT_VALUE_DOT"),audio_buf.index("R_READ_TIME_{}".format(min_shi))\
+ ,audio_buf.index("R_READ_STEP_3"),audio_buf.index("R_READ_TIME_{}".format(min_ge)),audio_buf.index("R_READ_TIME_MIN"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+ def play_timer_cb_1(self,*agrs):
+ return
+
+ def play_center_phone(self, event, msg): #msg
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许设备再次拨出
+ if flag == 0 and self.fall_flag == 0:
+ EventMesh.publish("close_timer_all")#
+
+ center_dial = EventMesh.publish("get_storage_config","center_dial")
+ if center_dial != None:
+ if len(center_dial) > 0:
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
+ EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ voiceCall.callStart(str(center_dial))
+
+
+ else:#未设置号码
+ # EventMesh.debug_log("play_center_phone")
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ pass
+ def center_phone_cb(self,*argc): #msg
+ pass
+
+
+
+
+ def play_imei_event(self, event, msg): #msg
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ imei = EventMesh.publish(constants.EVENT.GET_IMEI)
+ EventMesh.debug_log(imei)
+ str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(imei[0]))\
+ ,audio_buf.index("R_READ_TIME_{}".format(imei[1])),audio_buf.index("R_READ_TIME_{}".format(imei[2])),audio_buf.index("R_READ_TIME_{}".format(imei[3])),\
+ audio_buf.index("R_READ_TIME_{}".format(imei[4])),audio_buf.index("R_READ_TIME_{}".format(imei[5])),audio_buf.index("R_READ_TIME_{}".format(imei[6])),audio_buf.index("R_READ_TIME_{}".format(imei[7])),\
+ audio_buf.index("R_READ_TIME_{}".format(imei[8])),audio_buf.index("R_READ_TIME_{}".format(imei[9])),audio_buf.index("R_READ_TIME_{}".format(imei[10])),audio_buf.index("R_READ_TIME_{}".format(imei[11])),\
+ audio_buf.index("R_READ_TIME_{}".format(imei[12])),audio_buf.index("R_READ_TIME_{}".format(imei[13])),audio_buf.index("R_READ_TIME_{}".format(imei[14])))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+
+ def get_unread_wechat_state(self,event, msg):
+
+ return self.set_unread_wechat
+
+ def set_unread_wechat_state(self, event, msg):
+ self.set_unread_wechat = msg
+
+ def get_wechat_data(self,event, msg):
+
+ return [self.MXA_MSG ,self.wechat_recode_list]
+
+ def set_wechat_data(self, event, msg):
+ # EventMesh.debug_log("set_wechat_data1 ",msg,self.wechat_num)
+ self.MXA_MSG = msg[0]
+ self.wechat_recode_list = msg[1]
+ self.wechat_num = self.wechat_recode_list["num"]
+ with open("/usr/static/storage_file/wechat_record.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
+ #写编号
+ # EventMesh.debug_log("set_wechat_data2:{} ".format(self.wechat_num))
+
+
+ def get_wechat_time(self, event, msg):
+ return [self.press_btn,self.timeSecond]
+
+ def start_wechat_record(self, event, msg): #开始录音相关配置
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ if self.press_btn == 0:
+ self.press_btn = 1
+ audio_state = EventMesh.publish("get_audio_state")
+ if audio_state == 1:
+ self.aud.stop()
+ EventMesh.publish("close_timer_all")#
+ EventMesh.publish("set_led_time_arg",[1,1,160,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.WECHAT_LED_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,1000,1,led_mode.LONG_LIGHT_GREEN,led_mode.OPEN_LONG_LIGHT_MODE,led_mode.WECHAT_LED_MODE])#測量成功
+
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ self.timeSecond = time_tmp#保存按下的时间长s
+ self.aud.setVolume(11)#设置音量最大
+
+ EventMesh.debug_log("talking1.0")
+ # if self.wechat_num >= self.MXA_MSG:
+ # self.wechat_num = 0
+ # self.wechat_num += 1
+ # self.wechat_show = self.wechat_num
+ # self.record_test.start("/usr/static/storage_file/{}.amr".format(self.wechat_show),16)
+ self.record_test.start("/usr/static/storage_file/wechat.amr",16)
+
+ else:
+ self.timeSecond = 0
+ self.press_btn = 0
+ def get_wechat_state(self, event, msg):
+ return self.press_btn
+
+ def send_wechat_record(self, event, msg): #发送录音文件
+ if self.press_btn == 1:
+ self.press_btn = 0
+ self.record_test.stop() #停止錄音
+ EventMesh.publish("stop_led_timer")#关闭灯
+ EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.LONG_LIGHT_GREEN,led_mode.OPEN_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#測量成功
+ self.countdown_old = 0
+
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+
+ self.countdown_old = msg
+ if self.countdown_old >= 15:
+ self.countdown_old = 15
+ if self.countdown_old <= 0:
+ #录音时间太短
+ return
+ else:
+ # self.wechat_recode_list["%02d"%(self.wechat_show)] = "read:0"
+ # self.wechat_recode_list["num"] = self.wechat_show
+ EventMesh.debug_log("self.wechat_recode_list :{}".format(self.wechat_recode_list))
+
+ # with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ # ujson.dump(self.wechat_recode_list,fd)
+ EventMesh.debug_log("send wechat data!!!!!!!!!!!!!!!!!!!!!")
+
+ check_txt = ql_fs.path_exists("/usr/static/storage_file/wechat.amr")
+ if check_txt == True :
+ path = "/usr/static/storage_file/wechat.amr"
+ with open(path,"rb") as fd:
+ buf = bytearray(ql_fs.path_getsize(path))
+ fd.readinto(buf)
+ senddata = [self.countdown_old,buf]
+ EventMesh.publish(constants.PROTOCOL.TKS_SEND,senddata)
+
+ # with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ # ujson.dump(self.wechat_recode_list,fd)
+ # EventMesh.debug_log("send wechat data!!!!!!!!!!!!!!!!!!!!!")
+
+ # check_txt = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(self.wechat_show))
+ # if check_txt == True :
+ # path = "/usr/static/storage_file/{}.amr".format(self.wechat_show)
+ # with open(path,"rb") as fd:
+ # buf = bytearray(ql_fs.path_getsize(path))
+ # fd.readinto(buf)
+ # senddata = [self.countdown_old,buf]
+ # EventMesh.publish(constants.PROTOCOL.TKS_SEND,senddata)
+
+
+ def play_wechat_last_amr(self, event, msg):#播放微聊最后一条语音文件
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0:#电话通话中 或者呼叫中挂断中断
+ EventMesh.publish("close_timer_all")#
+ if self.wechat_recode_list != None:
+ num = 0
+ play_state = 0
+ if len(self.wechat_recode_list) > 1:
+ num = int(self.wechat_recode_list["num"])
+ #EventMesh.debug_log("self.wechat_recode_list1:{}".format(self.wechat_recode_list))
+ if num != 0:
+ last_num = str("%02d"%(num))
+ last_tmp = self.wechat_recode_list[last_num]
+ last_read = int(last_tmp.split(":")[1])
+ if last_read == 1:#如果最后一条没有读则读最新的一条
+ self.wechat_recode_list[last_num] = "read:0"
+ self.wechat_recode_list["num"] = num
+ with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
+ else:
+ sotr_new = {}
+ sotr_new = sorted(self.wechat_recode_list.keys(), reverse=True)#降序排序
+ # EventMesh.debug_log("sotr_new:{}".format(sotr_new))
+ for i in range(len(self.wechat_recode_list)-1):#1 01 02
+ key = sotr_new[i+1]
+ num_id = int(key)
+ #EventMesh.debug_log("key:{} num_id:{}".format(key,num_id))
+ if key in self.wechat_recode_list:#
+ str_tmp = self.wechat_recode_list[key]
+ read = int(str_tmp.split(":")[1])
+ if read != 0:#未读是按一下播放下一条同时删除
+ check_amr = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(num_id))#还要检测这个文件是否存在
+ if check_amr == True:
+ self.wechat_recode_list[key] = "read:0"
+ self.wechat_recode_list["num"] = num
+ EventMesh.debug_log("self.wechat_recode_list2:{} num_id:{} num:{}".format(self.wechat_recode_list,num_id,num))
+ # self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num)) #文件名前面要加上路径
+ play_state = 1
+ with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
+ break
+ else:
+ continue
+ else:
+ continue
+ else:
+ continue
+ #EventMesh.debug_log("play_state:{}".format(play_state))
+ # if play_state == 0:#
+ check_amr = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(num))#还要检测这个文件是否存在
+ if check_amr == True:
+ self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num)) #文件名前面要加上路径
+
+
+ def play_unread_wechat_infor(self,event,msg):#未读微聊语音
+ flag = EventMesh.publish("get_call_state")
+ if flag == 0 and self.press_btn == 0 and self.fall_flag == 0:#电话通话中 或者呼叫中挂断中断
+ if self.wechat_recode_list != None:
+ num = 0
+ play_state = 0
+ if len(self.wechat_recode_list) > 1:
+ num = int(self.wechat_recode_list["num"])
+ if num != 0:
+ for i in range(len(self.wechat_recode_list)-1):#1 01 02
+ key = "%02d"%(i+1)
+ if key in self.wechat_recode_list:#
+ str_tmp = self.wechat_recode_list[key]
+ read = int(str_tmp.split(":")[1])
+ if read == 1:#未读是按一下播放下一条同时删除
+ play_state = 1
+ else:
+ continue
+ else:
+ continue
+ if play_state == 1:#设置未读语音状态
+ EventMesh.publish("set_unread_wechat_state",1)
+ else:
+ EventMesh.publish("set_unread_wechat_state",0)
+ self.updateTime = 0
+
+ state = EventMesh.publish("get_unread_wechat_state")#
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ if state != None:
+ if state == 1:
+ EventMesh.publish("set_led_time_arg",[1,2,8,led_mode.FLASH_LIGHT_GREEN,8,4,led_mode.OTHER_MEASURE_MODE])#測量成功
+ # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ if self.updateTime == 0:
+ self.updateTime = time_tmp
+ if self.updateTime != 0:
+ if time_tmp - self.updateTime >= 10*60:
+ self.updateTime = time_tmp
+ #播放音频文件
+ EventMesh.publish("close_timer_all")
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_UNREAD_WECHAT"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ else:
+ self.updateTime = 0
+
+
+
+
+ class BtnDevice(Abstract):
+
+ def __init__(self, tp=None):
+ self.pk = PowerKey()
+ self.__pwk_timer = osTimer()
+ self.aud = audio.Audio(0)
+ self.aud.set_pa(Pin.GPIO29)
+ self.aud.setVolume(11)
+ # self.keypad = machine.KeyPad(4, 4)
+ self.__PowerDownTimeOut = 3000
+ self.__tp = tp
+ self.pwk_press = 0
+ self.pwk_count = 0
+ self.GPIO26_status = 1#默认是低电平
+ self.powerKey_status = 0
+ self.sosKey = 0
+ self.wechatKey = 0
+ self.sosKey_status = 1#默认是低电平
+ self.WeChatKey_status = 1#默认是低电平
+
+ self.wechatKey_timer = osTimer()
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+
+ self.sosKey_timer = osTimer()
+ self.sosKey_count = 0
+ self.sosKey_press = 0
+
+ self.wechatKey_press_count = 0
+
+ self.timeSeconOld = 0
+ self.wechat_state = 1 #按下录音时的状态
+
+
+ self.sosKey_press_count = 0
+
+
+ self.pwk_key = 0
+ self.GPIO26_status = 1
+
+ self.extint_22 = 0
+ self.GPIO22_status = 1
+
+ self.extint_17= 0
+ self.KeyCall2_status = 1
+
+ self.extint_19= 0
+ self.KeyCall1_status = 1
+
+ self.Keycall1_timer = osTimer()
+ self.Keycall1_count = 0
+ self.Keycall1_press = 0
+ self.Keycall1_press_count = 0
+
+ self.Keycall2_timer = osTimer()
+ self.Keycall2_count = 0
+ self.Keycall2_press = 0
+ self.Keycall2_press_count = 0
+
+
+
+ self.pwkey_timer = osTimer()
+ self.pwKey_press_count = 0
+ self.pwkey_count = 0
+ self.pwkey_press = 0
+ self.led_state = 0
+ self.hsensorTest_timer = osTimer()
+ self.btnInfo_queue = Queue()
+ _thread.stack_size(10*1024+192)
+ _thread.start_new_thread(self.btnInfo_queue_thread, ())
+ _thread.stack_size(8*1024)
+
+ EventMesh.subscribe("publish_message_event_btnInfo",self.publish_message_event_btnInfo)
+
+ EventMesh.subscribe("close_wechat_btn_timer", self.close_wechat_btn_timer)#来电强制关闭微聊语音
+
+ def btnInfo_queue_thread(self):
+ while True:
+ data = self.btnInfo_queue.get()
+ #EventMesh.debug_log("Info_queue:data = {}".format(data))
+ if data != None:
+ try:
+ data["func"](data["data"])
+ except Exception as e:
+ EventMesh.debug_log("btnInfo_queue:ERROR:{}".format(e))
+ usys.print_exception(e)
+ def publish_message_event_btnInfo(self,event,msg):
+ self.btnInfo_queue.put(msg)
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)#唤醒休眠
+
+ def publish_wechat_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.wechatKey_press_cb,"data":0})
+
+ def publish_soskey_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.sosKey_press_cb,"data":0})
+
+ def publish_call1key_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.call1Key_press_cb,"data":0})
+
+ def publish_call2key_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.call2Key_press_cb,"data":0})
+
+ def publish_pwkKey_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.pwKey_press_cb,"data":0})
+
+
+
+ def post_processor_after_instantiation(self):
+ # self.keypad.init()
+ # self.keypad.set_callback(self.key_callback)
+
+ self.pk.powerKeyEventRegister(self.powerKey_callback)
+
+ 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.GPIO22,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.sosKey = ExtInt(ExtInt.GPIO22, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.sosKey_extint_cb)
+ # self.sosKey.enable()
+
+ self.wechatKey = ExtInt(ExtInt.GPIO6, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.wechatKey_extint_cb)
+ self.wechatKey.enable()
+
+ # key19 = Pin(Pin.GPIO19, Pin.OUT, Pin.PULL_PU, 0)
+ # def key22_extint_cb(self,args):#SOS键
+ # self.GPIO22_status = self.extint_22.read_level()
+ # EventMesh.debug_log('### key22_extint_cb {} self.GPIO22_status :{}'.format(args,self.GPIO22_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+
+ def key17_extint_cb(self,args):#call 2
+
+ power_off = EventMesh.publish("get_power_off_state")#获取关机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ return
+ self.KeyCall2_status = int(args[1])
+ if self.KeyCall2_status == 0:
+ self.KeyCall2_status = 1
+ else:
+ self.KeyCall2_status = 0
+ pass
+ EventMesh.debug_log('### key17_extint_cb {} self.KeyCall2_status :{}'.format(args,self.KeyCall2_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+ if self.WeChatKey_status != 0 and self.GPIO26_status != 0 and self.KeyCall1_status != 0 and self.sosKey_status != 0:
+ if self.KeyCall2_status == 0:#按下
+ if self.Keycall2_press == 0 :
+ self.wechatKey_timer.stop()
+ self.pwkey_timer.stop()
+ self.sosKey_timer.stop()
+ self.Keycall2_timer.stop()
+ self.Keycall1_timer.stop()
+
+ self.wechatKey_press_count = 0
+ self.wechatKey_press = 0
+
+ self.pwKey_press_count = 0
+ self.pwkey_press = 0
+
+ self.sosKey_long_press = 0
+ self.sosKey_count = 0
+
+ self.Keycall1_count = 0
+ self.Keycall1_press = 0
+ self.Keycall1_press_count = 0
+
+ self.Keycall2_count = 0
+ self.Keycall2_press = 1
+ self.Keycall2_timer.start(100, 1, self.publish_call2key_btn_event_cb)
+
+ def call2Key_press_cb(self, data):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.Keycall2_press == 1 :
+ if self.KeyCall2_status == 1:#松开
+ self.Keycall2_count += 1
+ if self.Keycall2_count >= 1: #防抖100ms
+ self.Keycall2_timer.stop()
+ self.Keycall2_count = 0
+ self.Keycall2_press = 0
+ self.Keycall2_press_count+=1
+ self.Keycall2_timer.start(500, 0, self.publish_call2Key_timeout_cb_do)#松手超时1s判断
+
+ def publish_call2Key_timeout_cb_do(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.call2Key_timeout_cb,"data":0})
+
+ def call2Key_timeout_cb(self, data):#
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if self.Keycall2_press_count >= 1:#短按十次解绑app
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0 or flag != 0:#在打电话或者跌倒报警提醒中不允许按键触发
+ self.Keycall2_press_count = 0
+ return
+ if self.Keycall2_press_count == 1:#拨打通讯录号码二
+ self.Keycall2_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("call_phonebook_two_call")
+ self.Keycall2_press_count = 0
+
+
+ def key19_extint_cb(self,args):#call 1
+
+ power_off = EventMesh.publish("get_power_off_state")#获取关机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ return
+ # self.KeyCall1_status = self.extint_19.read_level()
+ # self.KeyCall1_status = ~args[1]
+ self.KeyCall1_status = int(args[1])
+ if self.KeyCall1_status == 0:
+ self.KeyCall1_status = 1
+ else:
+ self.KeyCall1_status = 0
+ pass
+ EventMesh.debug_log('### key19_extint_cb {} self.KeyCall1_status :{}'.format(args,self.KeyCall1_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+ if self.WeChatKey_status != 0 and self.GPIO26_status != 0 and self.KeyCall2_status != 0 and self.sosKey_status != 0:
+ if self.KeyCall1_status == 0:#按下
+ if self.Keycall1_press == 0 :
+ self.wechatKey_timer.stop()
+ self.pwkey_timer.stop()
+ self.sosKey_timer.stop()
+ self.Keycall2_timer.stop()
+ self.Keycall1_timer.stop()
+
+ self.wechatKey_press_count = 0
+ self.wechatKey_press = 0
+
+ self.pwKey_press_count = 0
+ self.pwkey_press = 0
+
+ self.sosKey_long_press = 0
+ self.sosKey_count = 0
+
+ self.Keycall2_count = 0
+ self.Keycall2_press = 0
+ self.Keycall2_press_count = 0
+
+ self.Keycall1_count = 0
+ self.Keycall1_press = 1
+ self.Keycall1_timer.start(100, 1, self.publish_call1key_btn_event_cb)
+
+ def call1Key_press_cb(self, data):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.Keycall1_press == 1 :
+ if self.KeyCall1_status == 1:#松开
+ self.Keycall1_count += 1
+ if self.Keycall1_count >= 1: #防抖100ms
+ self.Keycall1_timer.stop()
+ self.Keycall1_count = 0
+ self.Keycall1_press = 0
+ self.Keycall1_press_count+=1
+ self.Keycall1_timer.start(500, 0, self.publish_call1Key_timeout_cb_do)#松手超时1s判断
+
+ def publish_call1Key_timeout_cb_do(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.call1Key_timeout_cb,"data":0})
+
+ def call1Key_timeout_cb(self, data):#
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if self.Keycall1_press_count >= 1:#短按十次解绑app
+ if fall_down != None:
+ if fall_down != 0 or flag != 0:#在打电话或者跌倒报警提醒中不允许按键触发
+ self.Keycall1_press_count = 0
+ return
+ if self.Keycall1_press_count == 1:#拨打通讯录号码一
+ self.Keycall1_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("call_phonebook_one_call")
+ self.Keycall1_press_count = 0
+
+
+
+ def pwk_extint_cb(self,args):#侧边按键
+ # self.GPIO26_status = self.pwk_key26.read_level()
+
+ power_off = EventMesh.publish("get_power_off_state")#获取关机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ return
+ self.GPIO26_status = int(args[1])
+ if self.GPIO26_status == 0:
+ self.GPIO26_status = 1
+ else:
+ self.GPIO26_status = 0
+ pass
+ # self.GPIO26_status = ~args[1]
+ EventMesh.debug_log('### GPIO26_status {} self.GPIO26_status :{}'.format(args,self.GPIO26_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+ if self.WeChatKey_status != 0 and self.KeyCall1_status != 0 and self.sosKey_status != 0 and self.KeyCall2_status != 0:
+ # if self.sosKey_status != 0 and self.WeChatKey_status != 0:
+ if self.GPIO26_status == 0:#按下
+ if self.pwkey_press == 0 :
+ self.aud.stop() #播放声音
+ self.wechatKey_timer.stop()
+ self.pwkey_timer.stop()
+ self.sosKey_timer.stop()
+ self.Keycall2_timer.stop()
+ self.Keycall1_timer.stop()
+
+ self.wechatKey_press_count = 0
+ self.sosKey_press_count = 0
+ self.sosKey_press = 0
+ self.wechatKey_press = 0
+
+ self.pwkey_press = 1
+ self.pwkey_count = 0
+
+ self.Keycall1_count = 0
+ self.Keycall1_press = 0
+ self.Keycall1_press_count = 0
+
+ self.Keycall2_count = 0
+ self.Keycall2_press = 0
+ self.Keycall2_press_count = 0
+
+ self.pwkey_timer.start(100, 1, self.publish_pwkKey_btn_event_cb)
+ # EventMesh.debug_log("key22_extint_cb:self.key22_timer.start!!!!\n")
+
+
+
+
+ def pwKey_press_cb(self, data):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.pwkey_press == 1 :
+ self.pwkey_count += 1
+ if self.pwkey_count > 5:
+ if self.led_state == 0:
+ self.led_state = 1
+ EventMesh.publish("set_led_time_arg",[1,1,330,led_mode.LONG_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
+ if self.pwkey_count >= 10*10:
+ EventMesh.publish("stop_led_timer")#设置参数
+ self.pwkey_timer.stop()
+ self.pwkey_count = 0
+ self.pwkey_press = 0
+ self.pwKey_press_count = 0
+ self.led_state = 0
+ # if EventMesh.publish("get_sim_Status") != 1:
+ # EventMesh.publish("open_power_on", 2)#
+ # else:
+ EventMesh.publish("open_power_on", 3)#
+ return
+
+ if self.pwkey_count >= 3*10 :
+ if EventMesh.publish("get_sim_Status") != 1:
+ EventMesh.debug_log("长3秒关机")
+ EventMesh.publish("stop_led_timer")#设置参数
+ self.pwkey_timer.stop()
+ self.pwkey_count = 0
+ self.pwkey_press = 0
+ self.pwKey_press_count = 0
+ self.led_state = 0
+ EventMesh.publish("open_power_on", 2)#
+ return
+
+
+ if self.GPIO26_status == 1:#松开
+ if self.pwkey_count >= 1: #防抖100ms
+ # EventMesh.debug_log("self.GPIO26_status == 1")
+ self.pwkey_timer.stop()
+ self.pwkey_count = 0
+ self.pwkey_press = 0
+ self.led_state = 0
+ self.pwKey_press_count+=1
+ self.pwkey_timer.start(500, 0, self.publish_pwKey_timeout_cb_do)#松手超时1s判断
+
+ def hsensorTest_timer_cb(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ w_data = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+ #EventMesh.debug_log("FactoryModeHsensorTest{}".format(data))
+
+ c_data = self.Hsensor.get_test_data()#校准数据和工厂数据
+ # text_data = " 佩戴状态\n红外:{}活体:{}佩戴:{}\n{},{} \n{},{} \n{},{}\n校准数据:{},{},{},{}\n漏光数据:{},{},{}".format(
+ # c_data[3],c_data[4],w_data,c_data[5],c_data[6],c_data[7],c_data[8],c_data[9],c_data[10],
+ # c_data[11],c_data[12],c_data[13],c_data[14],c_data[0],c_data[1],c_data[2],)
+
+ if(self.hsensorTest_timer_count != 0):
+ self.hsensorTest_timer_count -= 1
+ if self.hsensorTest_timer_count%5 == 0:
+ EventMesh.debug_log("c_data:{} {} {} {}".format(c_data[11],c_data[12],c_data[13],c_data[14]))
+ if c_data[11] != 0 and c_data[13] != 0: #校准成功
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+ self.Hsensor.close()
+ self.Hsensor.init()
+ self.hsensorTest_timer.stop()
+ return
+ if self.hsensorTest_timer_count == 0:#50秒超时,失败
+ self.Hsensor.close()
+ self.Hsensor.init();
+ self.hsensorTest_timer.stop()
+ str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
+ EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
+ def publish_pwKey_timeout_cb_do(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.pwKey_timeout_cb,"data":0})
+
+ def pwKey_timeout_cb(self, data):#侧边按键
+ boot_count = EventMesh.publish("get_boot_time_count")
+ try :
+ if boot_count < 50 :#开机50秒内按键次数大于10就校准
+ #EventMesh.debug_log("boot_count:{}".format(boot_count))
+ if self.pwKey_press_count >= 6:
+ self.Hsensor = EventMesh.publish("get_Hsensor")
+ self.hsensorTest_timer.start(1000,1,self.hsensorTest_timer_cb)
+ EventMesh.debug_log("打开校准模式")
+ self.Hsensor.set_sar(1)
+ self.Hsensor.open_test(255) #打开校准模式
+ utime.sleep_ms(500)
+ self.Hsensor.open_heart()
+ self.hsensorTest_timer_count = 50
+ self.hsensorTest_timer.start(1000,1,self.hsensorTest_timer_cb)
+ str_data = 'mp3files={}.mp3+{}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_HR_TITLE"),audio_buf.index("R_HSENSOR_SPO2_TITLE"),)
+ EventMesh.publish("play_audio_file",[str_data,1])
+ self.pwKey_press_count = 0
+ return
+
+ except Exception as e:
+ usys.print_exception(e)
+ if self.pwKey_press_count >= 1:
+ self.pwKey_press_count = 0
+ # EventMesh.debug_log("pwKey_timeout_cb:self.pwKey_press_count >= 1")
+ flag = EventMesh.publish("get_call_state")
+ if flag != 2:#如果是电话拨出去或者不在打电话中都可以执行
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("dialing_out_event")#电话呼叫中voiceCall.callEnd()
+
+ if flag == 1:#如果是sos电话拨出去
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("set_hangup_mode",0)
+ EventMesh.publish("close_hr_sop2")#
+ flag = EventMesh.publish("get_call_state")
+ if flag != 1:
+ EventMesh.publish("set_sim_mode")#
+
+ self.pwKey_press_count = 0
+
+ def sosKey_extint_cb(self,args):
+ power_off = EventMesh.publish("get_power_off_state")#获取关机标识
+ if power_off != None:
+ if power_off == 1:
+ return
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ self.sosKey_status = int(args[1])
+ if self.sosKey_status == 0:
+ self.sosKey_status = 1
+ else:
+ self.sosKey_status = 0
+ pass
+ # self.sosKey_status = self.sosKey.read_level()
+ EventMesh.debug_log('### sosKey_extint_cb {} self.sosKey_status:{}'.format(args,self.sosKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+ # if self.WeChatKey_status != 0 and self.GPIO26_status != 0:
+ if self.WeChatKey_status != 0 and self.GPIO26_status != 0 and self.KeyCall1_status != 0 and self.KeyCall2_status != 0:
+ if self.sosKey_status == 0:#按下
+ EventMesh.publish("close_falldown_alarm_event")#sos短按事件
+ if self.sosKey_press == 0 :
+ self.led_state = 0
+ self.wechatKey_timer.stop()
+ self.pwkey_timer.stop()
+ self.sosKey_timer.stop()
+ self.Keycall2_timer.stop()
+ self.Keycall1_timer.stop()
+ self.wechatKey_press_count = 0
+ self.pwKey_press_count = 0
+ self.sosKey_press = 1
+ self.pwkey_press = 0
+ self.wechatKey_press = 0
+ self.sosKey_long_press = 0
+ self.sosKey_count = 0
+
+ self.Keycall1_count = 0
+ self.Keycall1_press = 0
+ self.Keycall1_press_count = 0
+
+ self.Keycall2_count = 0
+ self.Keycall2_press = 0
+ self.Keycall2_press_count = 0
+
+ self.sosKey_timer.start(100, 1, self.publish_soskey_btn_event_cb)
+ # self.sosKey_timer.start(100, 1, self.sosKey_press_cb)
+ # EventMesh.debug_log("key22_extint_cb:self.key22_timer.start!!!!\n")
+
+ def sosKey_press_cb(self, data):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.sosKey_press == 1 :
+ # if self.sosKey_count <= 2:
+ # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
+ # EventMesh.publish("set_led_time_arg",[1000,200,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ # else:
+ # EventMesh.publish("set_led_time_arg",[1000,200,1,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+ self.sosKey_count += 1
+ if self.sosKey_count >= 10*3: #长按3s sos拨号
+ self.sosKey_count = 0
+ self.sosKey_long_press = 1
+ self.sosKey_press = 0
+ self.sosKey_timer.stop()
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ return
+ EventMesh.publish_async("dial_sos_phone")#拨打sos号码
+ return
+
+ # EventMesh.debug_log("self.sosKey_count {}",self.sosKey_count)
+ if self.sosKey_status == 1:#松开
+ if self.sosKey_count >= 1: #防抖100ms
+ self.sosKey_timer.stop()
+ self.sosKey_count = 0
+ self.sosKey_press = 0
+ self.sosKey_press_count+=1
+ self.sosKey_timer.start(500, 0, self.publish_sosKey_timeout_cb_do)#松手超时1s判断
+ def publish_sosKey_timeout_cb_do(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.sosKey_timeout_cb,"data":0})
+ def sosKey_timeout_cb(self, data):#
+ # EventMesh.debug_log("sosKey_press_count!!!!!!!!!!!!!! ",self.sosKey_press_count)
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if self.sosKey_press_count > 1:#短按十次解绑app
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ self.sosKey_press_count = 0
+ return
+ if self.sosKey_press_count == 10:#
+ self.sosKey_press_count = 0
+ pass
+ elif self.sosKey_press_count == 6:#
+ self.sosKey_press_count = 0
+ pass
+ elif self.sosKey_press_count == 5:#功能暂时屏蔽
+ self.sosKey_press_count = 0
+ call_state = EventMesh.publish("get_call_state")
+ battery = EventMesh.publish("screen_get_battery")
+ if call_state == None:
+ call_state = 0
+ if call_state == 0:
+ if battery != None:
+ if battery[0] != "1":#在充电得时候
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("set_manual_measure_mode",3)#测量体温
+ pass
+ elif self.sosKey_press_count == 4:#拨打app快捷号码
+ self.sosKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("play_center_phone")#拨打快捷号码
+ # EventMesh.publish("call_phonebook_three_call")
+ pass
+ elif self.sosKey_press_count == 3:#测试心率
+ self.sosKey_press_count = 0
+
+ call_state = EventMesh.publish("get_call_state")
+ battery = EventMesh.publish("screen_get_battery")
+ if call_state == None:
+ call_state = 0
+ if call_state == 0:
+ if battery != None:
+ if battery[0] != "1":#在充电得时候
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("set_manual_measure_mode",1)#
+ pass
+ elif self.sosKey_press_count == 2:#播报当前步数
+ self.sosKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("play_cur_step_event")#
+ pass
+ elif self.sosKey_press_count == 1:#挂断来电 短语音播报
+ self.sosKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ # EventMesh.publish("call_test_event")
+ EventMesh.publish("sos_short_press")#sos短按事件
+
+ pass
+ self.sosKey_press_count = 0
+
+
+ def wechatKey_extint_cb(self,args):
+ power_off = EventMesh.publish("get_power_off_state")#获取关机标识
+ if power_off != None:
+ if power_off != 0:
+ return
+ open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+ if open_power != None:
+ if open_power == 0:
+ return
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0:
+ return
+ self.WeChatKey_status = int(args[1])
+ if self.WeChatKey_status == 0:
+ self.WeChatKey_status = 1
+ else:
+ self.WeChatKey_status = 0
+ pass
+ EventMesh.debug_log('### wechatKey_extint_cb {} self.WeChatKey_status:{}'.format(args,self.WeChatKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+ # if self.sosKey_status != 0 and self.GPIO26_status != 0:
+ if self.sosKey_status != 0 and self.GPIO26_status != 0 and self.KeyCall1_status != 0 and self.KeyCall2_status != 0:
+ if self.WeChatKey_status == 0:#按下
+ if self.wechatKey_press == 0:
+ self.wechatKey_timer.stop()
+ self.pwkey_timer.stop()
+ self.sosKey_timer.stop()
+ self.Keycall2_timer.stop()
+ self.Keycall1_timer.stop()
+
+ self.sosKey_press_count = 0
+ self.pwKey_press_count = 0
+ self.sosKey_press = 0
+ self.pwkey_press = 0
+ self.wechatKey_press = 1
+ self.led_state = 0
+ self.wechatKey_count = 0
+ self.wechat_state = 1
+
+ self.Keycall1_count = 0
+ self.Keycall1_press = 0
+ self.Keycall1_press_count = 0
+
+ self.Keycall2_count = 0
+ self.Keycall2_press = 0
+ self.Keycall2_press_count = 0
+
+ self.wechatKey_timer.start(100, 1, self.publish_wechat_btn_event_cb)
+
+ def close_wechat_btn_timer(self,event,*argc):
+ tmp = EventMesh.publish("get_wechat_time")#获取微聊时间戳
+ wechat_time = 0
+ time_tmp = 0
+ time_sec = 0
+
+ if tmp != None:
+ if tmp[0] == 1:
+ self.wechatKey_timer.stop()
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+ self.wechatKey_press_count=0
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ time_sec = tmp[1]
+ wechat_time = time_tmp - time_sec
+ # EventMesh.debug_log("close_btn_timer",time_tmp,time_sec,wechat_time)
+ if wechat_time >= 15:
+ wechat_time = 15
+ if wechat_time <= 0:
+ wechat_time = 0
+ EventMesh.publish("send_wechat_record",wechat_time)#发送录音文件内容
+
+
+ def wechatKey_press_cb(self,data):
+ wechat_time = 0
+ tmp = None
+ time_sec = 0
+ time_tmp = 0
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.wechatKey_press == 1 :#是否按下
+ tmp = EventMesh.publish("get_wechat_time")#获取微聊时间戳
+ self.wechatKey_count += 1
+ if self.wechatKey_count >= 10: #长按1s进入微聊录音
+ flag = EventMesh.publish("get_call_state")
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if flag != None:
+ if flag == 0 and fall_down == 0:
+ if self.WeChatKey_status == 0:
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
+ if self.wechat_state == 1:#按下超过s开始录音
+ EventMesh.publish("start_wechat_record")#开始录音
+ self.wechat_state = 0
+ else:
+ self.wechat_state = 0
+ self.wechatKey_timer.stop()
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+ self.wechatKey_press_count=0
+ EventMesh.publish("set_sim_mode")#播報imei号
+ return
+
+ if self.WeChatKey_status == 0:#未松手超过15s啧停止录音
+ if self.wechat_state == 0:
+ if tmp != None:
+ if tmp[0] != 0:
+ time_sec = tmp[1]
+ if time_tmp - time_sec >= 15:
+ wechat_time = time_tmp - time_sec
+ if wechat_time >= 15:
+ wechat_time = 15
+ EventMesh.publish("send_wechat_record",wechat_time)#发送录音文件内容
+
+ self.wechatKey_timer.stop()
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+ self.wechatKey_press_count=0
+ return
+ else:
+ if self.WeChatKey_status == 1:
+ if self.wechat_state == 0:#如果按下时长超过1s且小于长按的时间也认为是录微聊
+ if tmp != None:
+ if tmp[0] != 0:
+ time_sec = tmp[1]
+ wechat_time = time_tmp - time_sec
+ # EventMesh.debug_log("WECHAT TIEM",time_tmp,time_sec,wechat_time)
+ if wechat_time >= 15:
+ wechat_time = 15
+
+ EventMesh.publish("send_wechat_record",wechat_time)#发送录音文件内容
+ self.wechatKey_timer.stop()
+
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+ self.wechatKey_press_count=0
+ return
+ else:
+ self.wechatKey_timer.stop()
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+ self.wechatKey_press_count = 0
+
+ if self.WeChatKey_status == 1:#松开
+ if self.wechatKey_count >= 1: #防抖100ms
+ # EventMesh.debug_log("WeChat time!!!!!!!!!!!!!!")
+ self.wechatKey_timer.stop()
+ self.wechatKey_count = 0
+ self.wechatKey_press = 0
+ self.wechatKey_press_count+=1
+ self.wechatKey_timer.start(500, 0, self.publish_wechatKey_btn_event_cb)#松手超时1s判断
+
+ def publish_wechatKey_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.wechatKey_timeout_cb,"data":0})
+
+ def wechatKey_timeout_cb(self,data):#微聊键
+ flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if self.wechatKey_press_count > 1:#
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ self.wechatKey_press_count = 0
+ return
+ # EventMesh.debug_log("wechatKey_timeout_cb!!!!!!!!!!!!!! ",self.wechatKey_press_count)
+ if self.wechatKey_press_count == 10:#短按十次解绑app
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("open_power_on", 4)#恢复出厂
+ pass
+ elif self.wechatKey_press_count == 6:#短按六次播报imei号
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("play_imei_event")#播報imei号
+ pass
+ elif self.wechatKey_press_count == 4:#拨打通讯录号码三
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("call_phonebook_three_call")
+ pass
+ elif self.wechatKey_press_count == 3:#拨打通讯录号码二
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("call_phonebook_two_call")
+ pass
+ elif self.wechatKey_press_count == 2:#拨打通讯录号码一
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("call_phonebook_one_call")
+ # EventMesh.publish("interup_call_event")#
+ pass
+ elif self.wechatKey_press_count == 1:#播放最后收到的语音
+ self.wechatKey_press_count = 0
+ EventMesh.publish("stop_led_timer")#设置参数
+ call_state = EventMesh.publish("get_call_state")
+ if call_state == 0:
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0:
+ EventMesh.publish_async("dial_sos_phone")#拨打sos号码
+ return
+ else:
+ if call_state == 2:#电话拨进需要接听
+ EventMesh.publish("answer_call_event")#接听电话
+ return
+ EventMesh.publish("play_wechat_last_amr")
+ # pass
+ self.wechatKey_press_count = 0
+
+
+ def pwk_press_cb(self, *args):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.pwk_press == 1 :
+
+ self.pwk_count += 1
+ EventMesh.debug_log("self.pwk_count {}",self.pwk_count)
+ if self.GPIO26_status == 1:#松开
+ if self.pwk_count >= 1: #防抖100ms
+ self.__pwk_timer.stop()
+ self.pwk_count = 0
+ self.pwk_press = 0
+ EventMesh.debug_log("self.pwk_press_cb")
+
+ if self.pwk_count > (self.__PowerDownTimeOut//100): #长按
+ self.__pwk_timer.stop()
+ self.pwk_count = 0
+ self.pwk_press = 0
+ EventMesh.debug_log("btn8_long_press")
+
+ def __ui_callback(self, para):
+ # EventMesh.debug_log("para = {}".format(para))
+ if para == 0:
+ EventMesh.publish("done_left_to_right")
+ #EventMesh.debug_log("<-")
+ elif para == 1:
+ EventMesh.publish("done_right_to_left")
+ #EventMesh.debug_log("->")
+ elif para == 2:
+ EventMesh.publish("done_bottom_to_top")
+ #EventMesh.debug_log("^")
+ elif para == 3:
+ EventMesh.publish("done_top_to_bottom")
+ #EventMesh.debug_log("V")
+ elif para == 4:
+ EventMesh.publish("done_return")
+ #EventMesh.debug_log("return")
+ elif para == 5:
+ EventMesh.publish("done_click")
+ #EventMesh.debug_log("CLICK")
+ elif para == 6:
+ EventMesh.publish("done_press")
+ #EventMesh.debug_log("press")
+ elif (para == 6):
+ EventMesh.publish("done_error")
+ #EventMesh.debug_log("error")
+
+ def key_callback(self, l_list):
+ EventMesh.debug_log("key_callback:",str(l_list))
+ if l_list[0] == 1:
+ # 马达震动预留
+ pass
+ if (l_list[1] == 3) and (l_list[2] == 0):
+ if l_list[0] == 1:
+ #self.pwk_press = 0
+ EventMesh.publish("btn1_press")
+ else:
+ pass
+ # EventMesh.publish("btn1_press")
+
+
+
+
+ def powerKey_callback(self, status):
+ EventMesh.debug_log('==pwr:', status)# 0 1 0
+ self.powerKey_status = status
+ if self.pwk_press == 1: #按按钮时不处理
+ return
+
+
+
+
+ def power_key_press_cb(self, *args):
+ pass
+ # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 0:#未插卡的情况下强制关机
+ # EventMesh.publish("open_power_on", 2)#
+
+
+ def start(self):
+ self.post_processor_after_instantiation()