From: p15692025051 <846603105@qq.com> Date: Mon, 27 Nov 2023 08:32:08 +0000 (+0800) Subject: 冲突修复提交 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=8ca45b396ec7d1c08acd4bb58ede2d2a808f5fba;p=mirrors%2FASR1603_G5.git 冲突修复提交 --- diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/alarm.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/alarm.py index d2123bbb..ee398af8 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/alarm.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/alarm.py @@ -67,7 +67,7 @@ style_alarm_screen_default.set_pad_bottom(0) # -------------------------------------------clk_list screen---------------------------------------------------------- clk_list_screen = lv.obj() -print("clk_list_screen") +EventMesh.debug_log("clk_list_screen") clk_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) clk_list_title_bg= lv.btn(clk_list_screen) @@ -121,7 +121,7 @@ no_add_alarm.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) # -------------------------------------------clk_edit screen---------------------------------------------------------- clk_edit_screen = lv.obj() -print("clk_edit_screen") +EventMesh.debug_log("clk_edit_screen") clk_edit_screen.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT) clk_edit_title = lv.label(clk_edit_screen) @@ -170,7 +170,7 @@ clk_delete_alarm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE. # -------------------------------------------clk_repeat screen---------------------------------------------------------- clk_repeat_screen = lv.obj() -print("clk_repeat_screen") +EventMesh.debug_log("clk_repeat_screen") clk_repeat_screen.set_scrollbar_mode(0) clk_repeat_screen.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT) @@ -339,7 +339,7 @@ clk_repeat_switch6.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.IN # -------------------------------------------clk_repeat screen---------------------------------------------------------- clk_time_screen = lv.obj() -print("clk_time_screen") +EventMesh.debug_log("clk_time_screen") clk_time_screen.set_scrollbar_mode(0) clk_time_screen.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT) @@ -403,7 +403,7 @@ alarm_list = [{'hour': 16, 'repeart': 10, 'idx': 0, 'enabled': 0, 'days': [], 'm #闹钟弹窗 popup_alarm_screen = lv.obj() -print("popup_alarm_screen") +EventMesh.debug_log("popup_alarm_screen") popup_alarm_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) @@ -507,7 +507,7 @@ class ClkListScreen(Screen): def initialization(self): EventMesh.publish("read_alarminjson") EventMesh.publish("set_rtc_alarm") - print("n闹钟列表初始化!!") + EventMesh.debug_log("n闹钟列表初始化!!") self.alarm_draw_btn() def update_show_info(self,event,msg): @@ -524,7 +524,7 @@ class ClkListScreen(Screen): IFEXIST = ql_fs.path_exists("/usr/static/storage_file/alarm_msg.json") if IFEXIST == True: if self.clock_list: - # print("nalarm_list:{}".format(alarm_list)) + # EventMesh.debug_log("nalarm_list:{}".format(alarm_list)) no_add_alarm_img.add_flag(lv.obj.FLAG.HIDDEN) no_add_alarm.add_flag(lv.obj.FLAG.HIDDEN) self.alarm_show_list.delete()#先删除一次控件 @@ -533,7 +533,7 @@ class ClkListScreen(Screen): self.alarm_show_list.set_size(240, 255) self.alarm_show_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.alarm_show_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - #print("菜单的孩子个数:",clk_list_screen1.get_child_cnt()) + #EventMesh.debug_log("菜单的孩子个数:",clk_list_screen1.get_child_cnt()) num = 0 count = 0 for i ,each in enumerate(self.clock_list): @@ -551,7 +551,7 @@ class ClkListScreen(Screen): lv.EVENT.CLICKED, None) - # print("------刷新闹钟列表噢:{} num:{}",each,num) + # EventMesh.debug_log("------刷新闹钟列表噢:{} num:{}",each,num) _btn_label1 = lv.label(_btn) _btn_label1.set_pos(50, 0) _btn_label1.set_size(0, 0) @@ -573,7 +573,7 @@ class ClkListScreen(Screen): _btn_label3 = lv.label(_btn) _btn_label3.set_pos(5, 44) _btn_label3.set_size(200, 40) - print("_new_list:{} repeart:{}".format(_new_list,repeart)) + EventMesh.debug_log("_new_list:{} repeart:{}".format(_new_list,repeart)) if repeart == 1: _btn_label3.set_text("一次") elif repeart == 2: @@ -619,7 +619,7 @@ class ClkListScreen(Screen): def edit_alarm(self, e):#暂时屏蔽 return idx = int(e.get_target().get_child(0).get_text()) - print("edit!!!!!!!!!!!!:",idx) + EventMesh.debug_log("edit!!!!!!!!!!!!:",idx) clock_info = self.clock_list[idx] clock_info["idx"] = idx @@ -629,7 +629,7 @@ class ClkListScreen(Screen): if len(self.clock_list) >= 3: return - print("!!!!!!!!!!!!!!!!!------") + EventMesh.debug_log("!!!!!!!!!!!!!!!!!------") EventMesh.publish("add_alarm") self.alarm_draw_btn() @@ -637,18 +637,18 @@ class ClkListScreen(Screen): # obj = e.get_target() # idx = int(e.get_target().get_parent().get_child(0).get_text()) # clock_info = self.clock_list[idx] - # print("修改闹钟开关:",self.clock_list[idx]) + # EventMesh.debug_log("修改闹钟开关:",self.clock_list[idx]) # clock_info["idx"] = idx # if obj.has_state(lv.STATE.CHECKED): - # print("ON ~~~") + # EventMesh.debug_log("ON ~~~") # clock_info["enabled"] = True # else: - # print("OFF ~~~") + # EventMesh.debug_log("OFF ~~~") # clock_info["enabled"] = False # EventMesh.publish("push_clock_info", clock_info) # EventMesh.publish("set_rtc_alarm") - # print("sw_event_cb ~~~") + # EventMesh.debug_log("sw_event_cb ~~~") def done_return(self): EventMesh.publish("load_screen", {"screen": "toolbox"}) @@ -671,7 +671,7 @@ class NewEditClk(Screen): clk_delete_alarm.add_event_cb(lambda e: EventMesh.callback_wrapper(self.delete_alarm(e)), lv.EVENT.CLICKED, None) def initialization(self): - print("hahahahh",self.meta_info["idx"]) + EventMesh.debug_log("hahahahh",self.meta_info["idx"]) def delete_alarm(self, e): EventMesh.publish("remove_alarm",self.meta_info) @@ -718,7 +718,7 @@ class CLKTimeScreen(Screen): clk_time_roller_1.get_selected_str(option_1, len(option_1)) option_1_strip = option_1.strip()[:2] option_2_strip = option_2.strip()[:2] - print("option_1_strip = {} option_2_strip = {}".format(option_1_strip, option_2_strip)) + EventMesh.debug_log("option_1_strip = {} option_2_strip = {}".format(option_1_strip, option_2_strip)) self.meta_info["hour"] = int(option_1_strip) self.meta_info["minute"] = int(option_2_strip) EventMesh.publish("push_clock_info", self.meta_info) @@ -764,7 +764,7 @@ class ClkPeriod(Screen): def initialization(self): self.choice_list = self.meta_info["days"] self.alarm_info = self.meta_info - print("初始化:{},{}".format(self.alarm_info,self.choice_list)) + EventMesh.debug_log("初始化:{},{}".format(self.alarm_info,self.choice_list)) for i in range(0,6): @@ -779,17 +779,17 @@ class ClkPeriod(Screen): if i in self.choice_list: self.clk_switch_list[i].clear_state(lv.STATE.CHECKED) self.choice_list.remove(i) - print("here1-----",self.choice_list,i) + EventMesh.debug_log("here1-----",self.choice_list,i) else: self.clk_switch_list[i].add_state(lv.STATE.CHECKED) self.choice_list.append(i) - print("here2-----",self.choice_list,i) + EventMesh.debug_log("here2-----",self.choice_list,i) - print("here-----",self.choice_list) + EventMesh.debug_log("here-----",self.choice_list) self.alarm_info["days"] = self.choice_list - print("编辑星期:{}".format(self.alarm_info)) + EventMesh.debug_log("编辑星期:{}".format(self.alarm_info)) if self.alarm_info["days"] == []: self.alarm_info["repeart"] = 1 else: diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py index c637e8c5..caf01df8 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py @@ -28,12 +28,12 @@ import urandom try : from Hsensor import GH3018 except Exception as e: - print("Hsensor none GH3018:{}".format(e)) + EventMesh.debug_log("Hsensor none GH3018:{}".format(e)) # try : from Hsensor import HX3918 except Exception as e: - print("Hsensor none HX3918:{}".format(e)) + EventMesh.debug_log("Hsensor none HX3918:{}".format(e)) from machine import RTC import quecgnss import wifiScan @@ -187,7 +187,7 @@ class CountdownManager(Abstract): def set_countdown_all_time(self, event, msg): self.total = msg[0] self.total_sec = msg[1] - # print("self.total:{} self.total_sec:{}".format(self.total,self.total_sec)) + # EventMesh.debug_log("self.total:{} self.total_sec:{}".format(self.total,self.total_sec)) def get_countdown_all_time(self, event, msg): @@ -197,7 +197,7 @@ class CountdownManager(Abstract): self.time_cb = msg[0] self.time_play = msg[1] - # print("self.time_cb:{} self.total_sec:{}".format(self.time_cb,self.time_play)) + # EventMesh.debug_log("self.time_cb:{} self.total_sec:{}".format(self.time_cb,self.time_play)) def get_countdown_off_state(self, event, msg): @@ -209,7 +209,7 @@ class CountdownManager(Abstract): date_tmp = utime.localtime() time_tmp = utime.mktime(date_tmp) reduce = time_tmp- self.total_sec - print("self.time_cb:{} self.time_play:{} self.total:{} self.total_sec:{}".format(self.time_cb,self.time_play, self.total,self.total_sec)) + EventMesh.debug_log("self.time_cb:{} self.time_play:{} self.total:{} self.total_sec:{}".format(self.time_cb,self.time_play, self.total,self.total_sec)) self.total = self.total - reduce if self.total <= 0: self.total = 0 @@ -370,7 +370,7 @@ class Battery(object): break else: pre_volt = volt - # print("__get_soc_from_dict:{}".format(soc2 - (soc2 - soc1) * (pre_volt - volt_arg) // (pre_volt - volt))) + # EventMesh.debug_log("__get_soc_from_dict:{}".format(soc2 - (soc2 - soc1) * (pre_volt - volt_arg) // (pre_volt - volt))) if pre_volt == 0: # Input Voltarg > Highest Voltarg return soc1 elif volt_not_under == 0: @@ -424,7 +424,7 @@ class Battery(object): if( volt_arg == None) : volt_arg = self.get_voltage() self.__energy = self.__get_soc(self.__temp, volt_arg) - # print("get_energy:volt_arg {} __energy{}".format(volt_arg,self.__energy)) + # EventMesh.debug_log("get_energy:volt_arg {} __energy{}".format(volt_arg,self.__energy)) return self.__energy def set_charge_callback(self, charge_callback): @@ -498,9 +498,9 @@ class sosInfoCallManager(Abstract): EventMesh.publish("set_sos_flag",0) EventMesh.publish("set_sos_num",0) EventMesh.publish("set_hangup_mode",0) - print('hangup_mode disconnect',hangup_mode) + EventMesh.debug_log('hangup_mode disconnect',hangup_mode) sos_flag = EventMesh.publish("get_sos_flag") - print('voicecall sos_flag',sos_flag) + EventMesh.debug_log('voicecall sos_flag',sos_flag) if sos_flag == 0 : EventMesh.publish("set_sos_num",0) else: @@ -519,7 +519,7 @@ class sosInfoCallManager(Abstract): num_len = len(number)+1 elif len(number) == 3: num_len = len(number)+2 - # print("number:{} number_len :{} num:{} num_len:{}".format(number,len(number),num,num_len)) + # EventMesh.debug_log("number:{} number_len :{} num:{} num_len:{}".format(number,len(number),num,num_len)) if num > num_len : if len(number) == 1: number1 = str(number[0]) @@ -540,37 +540,37 @@ class sosInfoCallManager(Abstract): EventMesh.publish("set_sos_flag",0) EventMesh.publish("set_sos_num",0) else: - # print("number:{} number_len :{}".format(number,len(number))) + # EventMesh.debug_log("number:{} number_len :{}".format(number,len(number))) EventMesh.publish("set_sos_num",num) if len(number) == 1: EventMesh.publish("set_callnumer_cb",number[0]) - print("phone 1") + EventMesh.debug_log("phone 1") elif len(number) == 2: if num == 1 or num == 3: - print("phone 2") + EventMesh.debug_log("phone 2") EventMesh.publish("set_callnumer_cb",number[1]) elif num == 2: - print("phone 3") + EventMesh.debug_log("phone 3") EventMesh.publish("set_callnumer_cb",number[0]) elif len(number) == 3: if num == 1 or num == 4: EventMesh.publish("set_callnumer_cb",number[1]) - print("phone 4") + EventMesh.debug_log("phone 4") elif num == 2 or num == 5: - print("phone 5") + EventMesh.debug_log("phone 5") EventMesh.publish("set_callnumer_cb",number[2]) elif num == 3: - print("phone 6") + EventMesh.debug_log("phone 6") EventMesh.publish("set_callnumer_cb",number[0]) def voice_callback(args): - print('voicecall iinfo:{}'.format(args)) + EventMesh.debug_log('voicecall iinfo:{}'.format(args)) if args[0] == 10: get_UI_high_priority = EventMesh.publish("get_UI_high_priority")#如果在拨出去或者通话中屏蔽来电 if get_UI_high_priority == 1: EventMesh.publish("set_interrup_incall",1) return - print('voicecall incoming call, PhoneNO.: ', args[6]) + EventMesh.debug_log('voicecall incoming call, PhoneNO.: ', args[6]) size_len = len(str(args[6])) tmp = [] tmp = args[6] @@ -590,7 +590,7 @@ def voice_callback(args): sos_flag = 0 EventMesh.publish("set_sos_flag",0) - print('voicecall connected, PhoneNO.: ', args[6]) + EventMesh.debug_log('voicecall connected, PhoneNO.: ', args[6]) size_len = len(str(args[6])) tmp = [] tmp = args[6] @@ -618,25 +618,25 @@ def voice_callback(args): if flag == 2: EventMesh.publish("close_timer_all")# EventMesh.publish("set_call_state",0) - print('voicecall disconnect end') + EventMesh.debug_log('voicecall disconnect end') elif args[0] == 13: - print('voicecall is waiting, PhoneNO.: ', args[6]) + EventMesh.debug_log('voicecall is waiting, PhoneNO.: ', args[6]) elif args[0] == 14: - print('voicecall dialing, PhoneNO.: ', args[6]) + EventMesh.debug_log('voicecall dialing, PhoneNO.: ', args[6]) EventMesh.publish("set_UI_high_priority",0) EventMesh.publish("set_call_state",1) # EventMesh.publish("load_screen", {"screen": "dialing"}) elif args[0] == 15: - print('voicecall alerting, PhoneNO.: ', args[6]) + EventMesh.debug_log('voicecall alerting, PhoneNO.: ', args[6]) EventMesh.publish("set_call_state",1) elif args[0] == 16: - print('voicecall holding, PhoneNO.: ', args[6]) + EventMesh.debug_log('voicecall holding, PhoneNO.: ', args[6]) class DeviceInfoManager(Abstract): @@ -715,23 +715,23 @@ class DeviceInfoManager(Abstract): self.log = LogAdapter(self.__class__.__name__) self.rtc = RTC() self.aud = audio.Audio(0) - print("DeviceInfoManager:1") + EventMesh.debug_log("DeviceInfoManager:1") self.gsensor = SC7A20() - print("DeviceInfoManager:1.0") + EventMesh.debug_log("DeviceInfoManager:1.0") self.gsensor.activate() - print("DeviceInfoManager:1.1") + EventMesh.debug_log("DeviceInfoManager:1.1") self.gsensor.init() - print("DeviceInfoManager:2") + EventMesh.debug_log("DeviceInfoManager:2") self.gsensor.set_callback(self.gsensor_cb) try : self.hsensor = HX3918() except Exception as e: - print("Hsensor none HX3918:{}".format(e)) + EventMesh.debug_log("Hsensor none HX3918:{}".format(e)) try : self.hsensor = GH3018() except Exception as e: - print("Hsensor none GH3018:{}".format(e)) + EventMesh.debug_log("Hsensor none GH3018:{}".format(e)) # self.hsensor.activate() self.hsensor.init() @@ -739,15 +739,15 @@ class DeviceInfoManager(Abstract): try : self.hsensor.set_sar(1) except Exception as e: - print("Hsensor none set_sar:{}".format(e)) + EventMesh.debug_log("Hsensor none set_sar:{}".format(e)) self.old_temp_time = 0 - # #print("hsensor.open_heart:%d\r\n"%(self.hsensor.open_heart())) - print("DeviceInfoManager:3") + # #EventMesh.debug_log("hsensor.open_heart:%d\r\n"%(self.hsensor.open_heart())) + EventMesh.debug_log("DeviceInfoManager:3") self.i2c0 = I2C(I2C.I2C0, I2C.FAST_MODE) self.stop_temp( None, None) def post_processor_after_instantiation(self): - print("post_processor_after_instantiation:1") + EventMesh.debug_log("post_processor_after_instantiation:1") """订阅此类所有的事件到 EventMesh中""" voiceCall.setCallback(voice_callback) EventMesh.subscribe("screen_get_ope", self.get_device_ope) @@ -793,7 +793,7 @@ class DeviceInfoManager(Abstract): EventMesh.subscribe(constants.EVENT.STOP_TEMP, self.stop_temp) EventMesh.subscribe(constants.EVENT.GET_TEMP, self.get_temp) EventMesh.subscribe("get_boot_time_count", self.get_boot_time_count) - print("post_processor_after_instantiation:2") + EventMesh.debug_log("post_processor_after_instantiation:2") self.timer_push_schedule.start(10000, 1, self.publish_event_cb) # self.timer_pusht_test.start(2000, 1, self.publish_test) # self.battery_push_schedule.start(3000, 1, self.__check_battery) @@ -802,7 +802,7 @@ class DeviceInfoManager(Abstract): # 设备开机立刻更新一次参数 self.publish_event_cb() - print("post_processor_after_instantiation:3") + EventMesh.debug_log("post_processor_after_instantiation:3") def publish_message_event_DeviceInfo(self,event,msg): self.DeviceInfo_queue.put(msg) @@ -811,17 +811,17 @@ class DeviceInfoManager(Abstract): def DeviceInfo_queue_thread(self): while True: data = self.DeviceInfo_queue.get() - #print("DeviceInfo_queue_thread:data = {}".format(data)) + #EventMesh.debug_log("DeviceInfo_queue_thread:data = {}".format(data)) if data != None: try: data["func"](data["data"]) except Exception as e: - print("DeviceInfo_queue_thread:ERROR:{}".format(e)) + EventMesh.debug_log("DeviceInfo_queue_thread:ERROR:{}".format(e)) usys.print_exception(e) def gsensor_cb(self, para): - print("gsensor_cb:{}".format(para)) + EventMesh.debug_log("gsensor_cb:{}".format(para)) flip_sw = EventMesh.publish("get_storage_config","flip_sw") if para == 0: #跌倒报警 @@ -841,18 +841,18 @@ class DeviceInfoManager(Abstract): def publish_event_cb(self, *args, **kwargs): if self.boot_time_count < 50000000: self.boot_time_count += 10 - #print("boot_time_count:{}".format(self.boot_time_count)) + #EventMesh.debug_log("boot_time_count:{}".format(self.boot_time_count)) EventMesh.publish("publish_message_event_DeviceInfo",{"func":self.publish_event,"data":0}) def optimize_temp(self,temp): temp += 0.5 get_temp_time = EventMesh.publish("get_temp_time") - print("temp:{}".format(temp)) + EventMesh.debug_log("temp:{}".format(temp)) if temp < 36 :#or temp > 37.5: temp = 36+urandom.random() if temp > 37.5: self.temp_warning += 1 - print("temp_warning:{} get_temp_time{}".format(self.temp_warning,get_temp_time)) + EventMesh.debug_log("temp_warning:{} get_temp_time{}".format(self.temp_warning,get_temp_time)) if self.temp_warning*get_temp_time < 3:#高温没连续超过3次,和谐成37.5度以下 temp = 37+(urandom.randint(1, 4)/10) @@ -880,7 +880,7 @@ class DeviceInfoManager(Abstract): self.timer_push = 0 date_tmp = utime.localtime() time_tmp = utime.mktime(date_tmp) - # print("date_tmp......01....{} time_tmp:{}\r\n".format(date_tmp,time_tmp)) + # EventMesh.debug_log("date_tmp......01....{} time_tmp:{}\r\n".format(date_tmp,time_tmp)) EventMesh.publish("countdown_end_cb") @@ -901,7 +901,7 @@ class DeviceInfoManager(Abstract): """定时定位""" #EventMesh.publish("set_upload_data",3*60) self.upload_time = EventMesh.publish("get_upload_data") - #print("self.upload_time:{} math.fabs(time_tmp - self.UD_time):{}".format(self.upload_time,math.fabs(time_tmp - self.UD_time))) + #EventMesh.debug_log("self.upload_time:{} math.fabs(time_tmp - self.UD_time):{}".format(self.upload_time,math.fabs(time_tmp - self.UD_time))) if self.upload_time != None : if math.fabs(time_tmp - self.UD_time) > self.upload_time: #30分钟一次定位 self.UD_time = time_tmp @@ -913,7 +913,7 @@ class DeviceInfoManager(Abstract): self.gsensor.clean_status()#清除运动次数 else : #关闭定位 #EventMesh.txt_log("NO status") - print("NO status") + EventMesh.debug_log("NO status") EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 EventMesh.publish(constants.EVENT.PUSH_STEP, self.get_step_count()) @@ -932,7 +932,7 @@ class DeviceInfoManager(Abstract): bat_total_value += self.vbat_buf[i] bat_total_value = bat_total_value//curr_count#一分钟更新一次电量 10个平均值 EventMesh.publish("set_curr_battery_level",bat_total_value) - # print("self.vbat_buf:{} curr_count :{} bat_total_value:{} temp:{}".format(self.vbat_buf,curr_count,bat_total_value,temp)) + # EventMesh.debug_log("self.vbat_buf:{} curr_count :{} bat_total_value:{} temp:{}".format(self.vbat_buf,curr_count,bat_total_value,temp)) bat_tmp = EventMesh.publish("screen_get_battery") self.vbat_count+=10 if self.vbat_count >= 60: @@ -950,13 +950,13 @@ class DeviceInfoManager(Abstract): hour = date_tmp[3] min = date_tmp[4] old_Timesec = EventMesh.publish("get_old_time_data") - # print("old_Timesec",old_Timesec) + # EventMesh.debug_log("old_Timesec",old_Timesec) if old_Timesec != None: data = RTC().datetime() hour = data[4] min = data[5] next_alarm_time = utime.localtime(int(old_Timesec)) - # print("data[5]:{} {} next_alarm_time:{} old_Timesec:{}".format(data[1],data[2],next_alarm_time,old_Timesec)) + # EventMesh.debug_log("data[5]:{} {} next_alarm_time:{} old_Timesec:{}".format(data[1],data[2],next_alarm_time,old_Timesec)) month = next_alarm_time[1] day = next_alarm_time[2] if month != data[1] or day != data[2]: @@ -999,11 +999,11 @@ class DeviceInfoManager(Abstract): """电量小于20% 5分钟提醒一次""" get_low_btn = EventMesh.publish("get_low_bat_btn")# battery = EventMesh.publish("screen_get_battery") - # print("get_low_btn:{} self.bat_time:{}".format(get_low_btn,self.bat_time)) + # EventMesh.debug_log("get_low_btn:{} self.bat_time:{}".format(get_low_btn,self.bat_time)) if get_low_btn != None:#低电使能开关 if get_low_btn == 1: self.bat_time+=10 - # print("date_tmp:{} self.bat_time:{}".format(date_tmp,self.bat_time)) + # EventMesh.debug_log("date_tmp:{} self.bat_time:{}".format(date_tmp,self.bat_time)) if self.bat_time > 5*60: self.bat_time = 0 if battery[1] <= 20 and battery[1] > 0: @@ -1014,11 +1014,11 @@ class DeviceInfoManager(Abstract): """未联网提示关机""" ble=EventMesh.publish(constants.EVENT.GET_CONNECT) - # print("ble",ble) + # EventMesh.debug_log("ble",ble) if ble == 0:#未联网提示关机 if battery[0] != '1': self.no_smi_count+=10 - # print("self.no_smi_count",self.no_smi_count) + # EventMesh.debug_log("self.no_smi_count",self.no_smi_count) if self.no_smi_count >= (15*60): self.no_smi_count = 0 EventMesh.publish("open_power_on", 2)# #未检测到sim卡15分钟后关机 @@ -1032,7 +1032,7 @@ class DeviceInfoManager(Abstract): self.no_smi_count = 0 msg_nums = sms.getMsgNums() #获取短信条数 - # print("msg_nums",msg_nums) + # EventMesh.debug_log("msg_nums",msg_nums) if(msg_nums != -1): sms_data = sms.getSaveLoc() sms_max = sms_data[0][2] @@ -1067,7 +1067,7 @@ class DeviceInfoManager(Abstract): if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1: # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "1" and WEAR == 1 and call_state == 0: - # print("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state)) + # EventMesh.debug_log("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state)) if get_temp_time != None:#定时测量体温 if get_temp_time > 0: if get_temp_state != None: @@ -1087,7 +1087,7 @@ class DeviceInfoManager(Abstract): self.temp_state = 1 self.temp_one_state = 0 EventMesh.publish("set_temp_state",2) - print("AUTO temp:") + EventMesh.debug_log("AUTO temp:") EventMesh.publish(constants.EVENT.START_TEMP) elif (time_tmp-self.temp_time) >= 30 and self.temp_state == 1: @@ -1116,7 +1116,7 @@ class DeviceInfoManager(Abstract): EventMesh.publish("set_history_temp_value",0) # EventMesh.publish("play_temp_value",0)#播放体温数值 EventMesh.publish(constants.EVENT.STOP_TEMP) - print("AUTO temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) + EventMesh.debug_log("AUTO temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) @@ -1125,7 +1125,7 @@ class DeviceInfoManager(Abstract): self.temp_one_state+=1 if self.temp_one_state == 1: EventMesh.publish("set_temp_state",3) - print("AUTO one temp:1") + EventMesh.debug_log("AUTO one temp:1") EventMesh.publish(constants.EVENT.START_TEMP) elif self.temp_one_state > 3: self.temp_one_state = 0 @@ -1153,7 +1153,7 @@ class DeviceInfoManager(Abstract): EventMesh.publish("set_history_temp_value",0) # EventMesh.publish("play_temp_value",0)#播放体温数值 EventMesh.publish(constants.EVENT.STOP_TEMP) - print("once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) + EventMesh.debug_log("once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) else: self.temp_one_state = 0 @@ -1173,7 +1173,7 @@ class DeviceInfoManager(Abstract): if get_temp_end_state == 3:#单次测量 self.temp_one_state+=1 if self.temp_one_state == 1: - print("AUTO one temp:2") + EventMesh.debug_log("AUTO one temp:2") EventMesh.publish("set_temp_state",3) EventMesh.publish(constants.EVENT.START_TEMP) elif self.temp_one_state > 3: @@ -1202,16 +1202,16 @@ class DeviceInfoManager(Abstract): EventMesh.publish("set_history_temp_value",0) # EventMesh.publish("play_temp_value",0)#播放体温数值 EventMesh.publish(constants.EVENT.STOP_TEMP) - print("AUTO once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) + EventMesh.debug_log("AUTO once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) if hr_time[0] != None: self.mearsure_btn = int(hr_time[0]) self.mearsure_timer = int(hr_time[1]) if self.mearsure_btn != None and self.mearsure_timer != None: - # print("hr......01....{} {}\r\n".format(hr_time[0],hr_time[1])) + # EventMesh.debug_log("hr......01....{} {}\r\n".format(hr_time[0],hr_time[1])) if self.mearsure_btn > 0: if self.mearsure_timer > 0: - #print("get_hr_state:{} get_spo2_state:{} self.old_time:{} mearsure_timer:{}".format(self.get_hr_state,self.get_spo2_state,self.old_time,mearsure_timer)) + #EventMesh.debug_log("get_hr_state:{} get_spo2_state:{} self.old_time:{} mearsure_timer:{}".format(self.get_hr_state,self.get_spo2_state,self.old_time,mearsure_timer)) if self.get_hr_state != 1 and self.get_spo2_state != 1: if self.get_hr_state == 0 and self.get_spo2_state == 0: if self.HR_state == 0 or self.HR_state == 3: @@ -1229,7 +1229,7 @@ class DeviceInfoManager(Abstract): else: pass # EventMesh.publish("play_hr_value",0)#测量失败 - print("stop debug1") + EventMesh.debug_log("stop debug1") EventMesh.publish(constants.EVENT.STOP_HEART) self.HR_state = 0 elif self.get_spo2_state == 2 and self.HR_state == 2: @@ -1249,7 +1249,7 @@ class DeviceInfoManager(Abstract): if (time_tmp - self.SENSOR_time) >= self.mearsure_timer: if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量没有完毕优先测量间隔时间测量的 if self.get_hr_state == 3: - print("stop debug2") + EventMesh.debug_log("stop debug2") EventMesh.publish(constants.EVENT.STOP_HEART) heart_value = EventMesh.publish(constants.EVENT.GET_HEART) if heart_value > 50 and heart_value != None: @@ -1278,9 +1278,9 @@ class DeviceInfoManager(Abstract): self.SENSOR_time = time_tmp self.HR_state = 0 - #print("time_tmp :{} self.SENSOR_time :{} time_tmp - self.SENSOR_time:{} self.HR_state:{}".format(time_tmp,self.SENSOR_time,time_tmp - self.SENSOR_time,self.HR_state)) + #EventMesh.debug_log("time_tmp :{} self.SENSOR_time :{} time_tmp - self.SENSOR_time:{} self.HR_state:{}".format(time_tmp,self.SENSOR_time,time_tmp - self.SENSOR_time,self.HR_state)) if (time_tmp - self.SENSOR_time) == 0 and self.HR_state == 0: - print("START_HEART:1") + EventMesh.debug_log("START_HEART:1") EventMesh.publish("set_hr_state",2)#2代表后台进入测试 EventMesh.publish(constants.EVENT.START_HEART) self.HR_state = 1 @@ -1288,10 +1288,10 @@ class DeviceInfoManager(Abstract): self.HR_OneTime = 0 elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_state == 1: EventMesh.publish("set_hr_state",0)#2代表后台进入测试 - print("stop debug3") + EventMesh.debug_log("stop debug3") EventMesh.publish(constants.EVENT.STOP_HEART) heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - print("heart_value:{}".format(heart_value)) + EventMesh.debug_log("heart_value:{}".format(heart_value)) if heart_value > 50 and heart_value != None: # EventMesh.publish("play_hr_value",heart_value) EventMesh.publish("set_history_hr_value",heart_value) @@ -1300,18 +1300,18 @@ class DeviceInfoManager(Abstract): pass # EventMesh.publish("play_hr_value",0) #获取心率数据上传数据app - print("STOP_HEART:") + EventMesh.debug_log("STOP_HEART:") self.HR_state = 3 # EventMesh.publish("set_spo2_state",2)#2代表后台进入血氧测试 # EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧 - # print("START_BLOOD_OXYGEN:") + # EventMesh.debug_log("START_BLOOD_OXYGEN:") # elif (time_tmp - self.SENSOR_time) >= 120 and self.HR_state == 2:#有需要再打开 - # print("STOP_BLOOD_OXYGEN:") + # EventMesh.debug_log("STOP_BLOOD_OXYGEN:") # EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 # EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试 # spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - # print("spo2_value:{}".format(spo2_value)) + # EventMesh.debug_log("spo2_value:{}".format(spo2_value)) # if spo2_value > 85 and spo2_value != None: # EventMesh.publish("set_old_spo2_data",spo2_value) # EventMesh.publish("set_history_spo2_value",spo2_value) @@ -1326,7 +1326,7 @@ class DeviceInfoManager(Abstract): self.HR_state = 0 self.HR_OneTime+=1 if self.HR_OneTime == 1 and self.HR_Onestate == 0: - print("hr..........\r\n") + EventMesh.debug_log("hr..........\r\n") if self.get_hr_state == 3: self.Hr_Need_Open = 1 EventMesh.publish("set_hr_state",3)#2代表后台进入测试 @@ -1341,11 +1341,11 @@ class DeviceInfoManager(Abstract): else: self.Spo2_Need_Open = 0 self.HR_Onestate = 1 - # print("self.HR_Onestate....3..:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open)) + # EventMesh.debug_log("self.HR_Onestate....3..:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open)) elif self.HR_OneTime > 6 and self.HR_Onestate == 1: - # print("self.HR_Onestate...4....:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open)) + # EventMesh.debug_log("self.HR_Onestate...4....:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open)) if self.Hr_Need_Open == 1:#需要关闭心率测量 - print("stop debug4") + EventMesh.debug_log("stop debug4") EventMesh.publish(constants.EVENT.STOP_HEART) heart_value = EventMesh.publish(constants.EVENT.GET_HEART) if heart_value > 50 and heart_value != None: @@ -1395,7 +1395,7 @@ class DeviceInfoManager(Abstract): elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2: - print("HR_OneTime:....05") + EventMesh.debug_log("HR_OneTime:....05") if self.set_hsenor_crt == 2: EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试 @@ -1411,7 +1411,7 @@ class DeviceInfoManager(Abstract): elif self.set_hsenor_crt == 1: EventMesh.publish("set_hr_state",0)#0代表g关闭测试 - print("stop debug5") + EventMesh.debug_log("stop debug5") EventMesh.publish(constants.EVENT.STOP_HEART) heart_value = EventMesh.publish(constants.EVENT.GET_HEART) if heart_value > 50 and heart_value != None: @@ -1435,7 +1435,7 @@ class DeviceInfoManager(Abstract): self.HR_OneTime = 0 self.set_hsenor_crt = 0 else: - #print("hr......01....{} {} self.HR_Onestate {} {}".format(self.get_hr_state,self.get_spo2_state,self.HR_OneTime,self.HR_Onestate)) + #EventMesh.debug_log("hr......01....{} {} self.HR_Onestate {} {}".format(self.get_hr_state,self.get_spo2_state,self.HR_OneTime,self.HR_Onestate)) self.SENSOR_time = time_tmp#进入最后一次的时间戳 self.old_time = 0 @@ -1461,12 +1461,12 @@ class DeviceInfoManager(Abstract): self.HR_Onestate = 1 elif self.HR_OneTime > 6 and self.HR_Onestate == 1: - print("stop_heart Onec ") + EventMesh.debug_log("stop_heart Onec ") if self.Hr_Need_Open == 1:#需要关闭心率测量 - print("stop debug6") + EventMesh.debug_log("stop debug6") EventMesh.publish(constants.EVENT.STOP_HEART) heart_value = EventMesh.publish(constants.EVENT.GET_HEART) - print("stop_heart heart_value:{}".format(heart_value)) + EventMesh.debug_log("stop_heart heart_value:{}".format(heart_value)) if heart_value > 50 and heart_value != None: # EventMesh.publish("play_hr_value",heart_value) EventMesh.publish("set_history_hr_value",heart_value) @@ -1490,7 +1490,7 @@ class DeviceInfoManager(Abstract): EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#K开血氧 spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) - print("spo2_value:{}.......01..".format(spo2_value)) + EventMesh.debug_log("spo2_value:{}.......01..".format(spo2_value)) if spo2_value > 85 and spo2_value != None: # EventMesh.publish("play_spo2_value",spo2_value) EventMesh.publish("set_history_spo2_value",spo2_value) @@ -1508,7 +1508,7 @@ class DeviceInfoManager(Abstract): self.HR_Onestate = 0 self.HR_OneTime = 0 self.set_hsenor_crt = 2#血氧关闭 - print("STOP_BLOOD_OXYGEN:....06.....") + EventMesh.debug_log("STOP_BLOOD_OXYGEN:....06.....") elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2: if self.set_hsenor_crt == 2: @@ -1524,7 +1524,7 @@ class DeviceInfoManager(Abstract): # EventMesh.publish("play_spo2_value",0) elif self.set_hsenor_crt == 1: EventMesh.publish("set_hr_state",0)#0代表g关闭测试 - print("stop debug7") + EventMesh.debug_log("stop debug7") EventMesh.publish(constants.EVENT.STOP_HEART) heart_value = EventMesh.publish(constants.EVENT.GET_HEART) if heart_value > 50 and heart_value != None: @@ -1556,7 +1556,7 @@ class DeviceInfoManager(Abstract): if get_hr_state != None and get_spo2_state != None: if get_hr_state == 2 or get_hr_state == 3: EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 - print("stop debug8") + EventMesh.debug_log("stop debug8") EventMesh.publish(constants.EVENT.STOP_HEART) elif get_spo2_state == 2 or get_spo2_state == 3: EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 @@ -1609,7 +1609,7 @@ class DeviceInfoManager(Abstract): if time_s != 0: if (time_tmp - time_s) >= 60:#大于60s关闭测试 EventMesh.publish("set_hr_state",0)#0代表g关闭测试 - print("stop debug7") + EventMesh.debug_log("stop debug7") EventMesh.publish(constants.EVENT.STOP_HEART) heart_value = EventMesh.publish(constants.EVENT.GET_HEART) if heart_value > 50 and heart_value != None: @@ -1621,7 +1621,7 @@ class DeviceInfoManager(Abstract): else : if WEAR != 1: EventMesh.publish("set_hr_state",0)#0代表g关闭测试 - print("stop debug7") + EventMesh.debug_log("stop debug7") EventMesh.publish(constants.EVENT.STOP_HEART) EventMesh.publish("play_hr_value",0) pass @@ -1631,7 +1631,7 @@ class DeviceInfoManager(Abstract): if time_s != 0: if (time_tmp - time_s) >= 60:#大于60s关闭测试 EventMesh.publish("set_spo2_state",0)#0代表g关闭测试 - print("stop spo2 debug7") + EventMesh.debug_log("stop spo2 debug7") EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN) if spo2_value > 85 and spo2_value != None: @@ -1643,7 +1643,7 @@ class DeviceInfoManager(Abstract): else : if WEAR != 1: EventMesh.publish("set_spo2_state",0)#0代表g关闭测试 - print("stop debug8") + EventMesh.debug_log("stop debug8") EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) EventMesh.publish("play_spo2_value",0) pass @@ -1653,10 +1653,10 @@ class DeviceInfoManager(Abstract): if time_s != None: if time_s != 0: if (time_tmp - time_s) >= 30:#大于60s关闭测试 - print("体温测量结束") + EventMesh.debug_log("体温测量结束") temp = EventMesh.publish(constants.EVENT.GET_TEMP) temp = self.optimize_temp(temp) - print("temp",temp) + EventMesh.debug_log("temp",temp) EventMesh.publish("set_temp_state",0) tmp_f_tmp = 0 tmp_d_tmp = 0 @@ -1682,7 +1682,7 @@ class DeviceInfoManager(Abstract): else : if WEAR != 1: EventMesh.publish("set_temp_state",0)#0代表g关闭测试 - print("stop debug9") + EventMesh.debug_log("stop debug9") EventMesh.publish(constants.EVENT.STOP_TEMP) EventMesh.publish("play_temp_value",0) @@ -1692,7 +1692,7 @@ class DeviceInfoManager(Abstract): if battery[0] == '1': - # print("battery[1]",battery[1]) + # EventMesh.debug_log("battery[1]",battery[1]) if self.vbat_full_flag <= 120: self.vbat_full_flag+=10 if self.vbat_full_flag == 60:#开机检测一次如果是充电标识为1就不再提示 @@ -1702,7 +1702,7 @@ class DeviceInfoManager(Abstract): if battery[1] >= 100: if self.charge_full_count == 0:#充电已满 EventMesh.publish("set_usb",3)# - print("charge R_CHARGE_full") + EventMesh.debug_log("charge R_CHARGE_full") self.charge_full_count = 1 else: @@ -1793,7 +1793,7 @@ class DeviceInfoManager(Abstract): tmp = 0 tmp = self.gsensor.get_step() - # print("x:%d,y:%d,z:%d tmp %d",XYZ[0],XYZ[1],XYZ[2],tmp) + # EventMesh.debug_log("x:%d,y:%d,z:%d tmp %d",XYZ[0],XYZ[1],XYZ[2],tmp) self.step[0]= tmp self.step[1] = XYZ[0] self.step[2] = XYZ[1] @@ -1838,7 +1838,7 @@ class DeviceInfoManager(Abstract): vbat = EventMesh.publish("get_battery",temp) if vbat == None: vbat = 100 - # print("vbat",vbat) + # EventMesh.debug_log("vbat",vbat) # if temp != None : # if temp <= 3505: # vbat = 0 @@ -1926,25 +1926,25 @@ class DeviceInfoManager(Abstract): return self.PING def set_connect(self, topic, msg): - #print("set_connect:{}".format(msg)) + #EventMesh.debug_log("set_connect:{}".format(msg)) self.connect = msg def get_connect(self, topic, msg): return self.connect def start_blood_oxygen(self, topic, msg): - print("start_blood_oxygen!!!") + EventMesh.debug_log("start_blood_oxygen!!!") self.hsensor.open_blood_oxygen() def start_heart(self, topic, msg): - print("start_heart!!!") + EventMesh.debug_log("start_heart!!!") self.hsensor.open_heart() def stop_blood_oxygen(self, topic, msg): - print("stop_blood_oxygen!!!") + EventMesh.debug_log("stop_blood_oxygen!!!") self.hsensor.close() def stop_heart(self, topic, msg): - print("stop_heart!!!") + EventMesh.debug_log("stop_heart!!!") self.hsensor.close() def get_blood_oxygen(self, topic, msg): @@ -1965,7 +1965,7 @@ class DeviceInfoManager(Abstract): self.hsensor.set_sleep() def start_temp(self, topic, msg): - print("start_temp!!!!!!!") + EventMesh.debug_log("start_temp!!!!!!!") WHO_AM_I = bytearray([0x01, 0]) I2C_SLAVE_ADDR = 0x49 #I2C_SLAVE_ADDR = 0x48 @@ -1973,7 +1973,7 @@ class DeviceInfoManager(Abstract): data = bytearray([0x61A0, 0]) # 唤醒 return self.i2c0.write(I2C_SLAVE_ADDR, WHO_AM_I, 1, data, 2) def stop_temp(self, topic, msg): - print("stop_temp!!!!!!!") + EventMesh.debug_log("stop_temp!!!!!!!") WHO_AM_I = bytearray([0x01, 0]) I2C_SLAVE_ADDR = 0x49 #I2C_SLAVE_ADDR = 0x48 @@ -1987,11 +1987,11 @@ class DeviceInfoManager(Abstract): #I2C_SLAVE_ADDR = 0x48 r_data = bytearray(2) self.i2c0.read(I2C_SLAVE_ADDR, WHO_AM_I, 1, r_data, 2, 0) - #print("temp_data:{}".format(r_data)) + #EventMesh.debug_log("temp_data:{}".format(r_data)) temp_s = ((r_data[0]<<8) | (r_data[1]))>>4 - #print("temp_s:{}".format(temp_s)) + #EventMesh.debug_log("temp_s:{}".format(temp_s)) temp_data = temp_s * 0.0625 - print("temp_data:{}".format(temp_data)) + EventMesh.debug_log("temp_data:{}".format(temp_data)) return temp_data @@ -2015,12 +2015,12 @@ class DeviceInfoManager(Abstract): status = state if status == 1:#插入USB - print("charge R_CHARGE_in") + EventMesh.debug_log("charge R_CHARGE_in") EventMesh.publish("set_usb", 1)# pass elif status == 0:#拨出usbs EventMesh.publish("set_usb", 2)# - print("charge R_CHARGE_out") + EventMesh.debug_log("charge R_CHARGE_out") @@ -2057,8 +2057,15 @@ class LocationManager(Abstract): self.location_queue = Queue(100) self.lpm_fd = None self.start_agps = 0 - quecgnss.init() - quecgnss.gnssEnable(0) + read_data = EventMesh.publish("get_storage_config","isOpenGNSS")#获取是否打开GNSS + if read_data != None: + self.isOpenGNSS = read_data + else:#默认关闭GNSS + self.isOpenGNSS = "0" + EventMesh.publish("set_storage_config",["isOpenGNSS",self.isOpenGNSS]) + if self.isOpenGNSS == "1": + quecgnss.init() + quecgnss.gnssEnable(0) @staticmethod def get_date(): return "{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3]) @@ -2101,7 +2108,7 @@ class LocationManager(Abstract): self.cell_data = [] self.location_timer_count = 0 self.GSV_sig_ok_count = 0 - print("start_location:{}".format(msg)) + EventMesh.debug_log("start_location:{}".format(msg)) if( self.location_flag == 1): return _thread.stack_size((9+5)*1024) @@ -2114,7 +2121,7 @@ class LocationManager(Abstract): def start_location_test(self, event, msg): - print("start_location_test") + EventMesh.debug_log("start_location_test") self.location_type = 1 if( self.location_flag == 1): @@ -2139,11 +2146,11 @@ class LocationManager(Abstract): def WIFI_INFO(self, event, msg): self.wifi_data = msg - # print("WIFI_INFO:") - # print([msg[0],msg]) + # EventMesh.debug_log("WIFI_INFO:") + # EventMesh.debug_log([msg[0],msg]) def WIFI_scan_open(self, event, msg): - #print("WIFI_scan_open") + #EventMesh.debug_log("WIFI_scan_open") if wifiScan.getState() == False : @@ -2152,23 +2159,25 @@ class LocationManager(Abstract): wifiScan.setCfgParam(6, 2, 5, 0) #设置WiFi参数,10秒上层,两轮,最多6个,6秒底层,PS优先 wifiScan.setCallback(wifiScan_cb) #注册回调函数 wifiScan.asyncStart() - #print("wifiScan.asyncStart") + #EventMesh.debug_log("wifiScan.asyncStart") else : - print("WIFI_scan_open:error1") + EventMesh.debug_log("WIFI_scan_open:error1") def gps_open(self, event, msg): - #print("publish:gps_open") - #quecgnss.init() - quecgnss.gnssEnable(2) - #self.gps.__gps_nmea_data_clean() + if self.isOpenGNSS == "1": + #EventMesh.debug_log("publish:gps_open") + #quecgnss.init() + quecgnss.gnssEnable(2) + #self.gps.__gps_nmea_data_clean() def gps_close(self, event, msg): - quecgnss.gnssEnable(0) + if self.isOpenGNSS == "1": + quecgnss.gnssEnable(0) def location_timer(self, *args, **kwargs): self.location_timer_count = self.location_timer_count +1 self.location_check_data_timer_count = self.location_check_data_timer_count+1 def Location_send(self, msg) : - #print("Location_send1") + #EventMesh.debug_log("Location_send1") if self.location_queue.empty() == True: return date = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6]) @@ -2264,11 +2273,11 @@ class LocationManager(Abstract): send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data) send_data += ",%d,%s"%(WIFI_num,WIFI_data) send_data+=",%s"%(precision) - #print("Location_send2:{} q_size:{}".format(send_data,self.location_queue.size())) + #EventMesh.debug_log("Location_send2:{} q_size:{}".format(send_data,self.location_queue.size())) while True: if self.location_queue.empty() == False: TYPE = self.location_queue.get() - #print("Location_send3:{}".format(TYPE)) + #EventMesh.debug_log("Location_send3:{}".format(TYPE)) EventMesh.publish(TYPE,send_data) else : break @@ -2313,11 +2322,11 @@ class LocationManager(Abstract): if self.lpm_fd == None: self.lpm_fd = pm.create_wakelock("test_lock", len("test_lock")) pm.wakelock_lock(self.lpm_fd) - print("location_thread:1") + EventMesh.debug_log("location_thread:1") EventMesh.publish(constants.EVENT.GPSOPEN) - print("location_thread:2") + EventMesh.debug_log("location_thread:2") #self.timer_read_GPS_info.start(1000, 1, self.location_timer) - print("location_thread:3") + EventMesh.debug_log("location_thread:3") #utime.sleep_ms(1000) self.location_timer_count = 0 #quecgnss.read(4096)#去掉第一次错误数据 @@ -2336,92 +2345,92 @@ class LocationManager(Abstract): # pm.sclkEx_set(0, 1, 5) if self.location_check_data_timer_count >= 1 :#3秒查一次基站数据和wifi数据 self.location_check_data_timer_count = 0 - #print(self.location_timer_count) + #EventMesh.debug_log(self.location_timer_count) GSV_dict= {} - - #检查GNSS数据 - if ( self.gps_data == {} or self.location_type == 1) and quecgnss.get_state() == 2: + if self.isOpenGNSS == "1": + #检查GNSS数据 + if ( self.gps_data == {} or self.location_type == 1) and quecgnss.get_state() == 2: - pass - tmp_ok_count = 0 - tmp_very_ok_count = 0 - gsv_data = quecgnss.get_gsv() - rmc_data = quecgnss.get_rmc() - gga_data = quecgnss.get_gga() - vtg_data = quecgnss.get_vtg() - # print("gsv:{}".format(quecgnss.get_gsv())) - # print("gga:{}".format(quecgnss.get_gga())) - # print("rmc:{}".format(quecgnss.get_rmc())) - # print("vtg:{}".format(quecgnss.get_vtg())) - for i in range(len(gsv_data)) : - - if i % 2 == 0: - if i+1 >= len(gsv_data) : - # print("gsv_data num error!!") - break - GSV_dict[gsv_data[i]] = gsv_data[i+1] - #print("type:gsv_data{}".format(type(gsv_data[i+1]))) - try: - #print("gsv_tmp[i+3]:{}".format(gsv_tmp[i+3])) - if gsv_data[i+1] : - if (gsv_data[i+1])>=20: - tmp_ok_count +=1 - if (gsv_data[i+1])>=30: - tmp_very_ok_count +=1 - - except Exception as e: - usys.print_exception(e) + pass + tmp_ok_count = 0 + tmp_very_ok_count = 0 + gsv_data = quecgnss.get_gsv() + rmc_data = quecgnss.get_rmc() + gga_data = quecgnss.get_gga() + vtg_data = quecgnss.get_vtg() + # EventMesh.debug_log("gsv:{}".format(quecgnss.get_gsv())) + # EventMesh.debug_log("gga:{}".format(quecgnss.get_gga())) + # EventMesh.debug_log("rmc:{}".format(quecgnss.get_rmc())) + # EventMesh.debug_log("vtg:{}".format(quecgnss.get_vtg())) + for i in range(len(gsv_data)) : - if(tmp_ok_count > self.GSV_sig_ok_count ): - self.GSV_sig_ok_count = tmp_ok_count - if(tmp_very_ok_count > self.GSV_sig_very_ok_count ): - self.GSV_sig_very_ok_count = tmp_very_ok_count - match_rmc_data = rmc_data.split(",") - if len (match_rmc_data)>3: #有rmc数据 - if match_rmc_data[2] == 'A': - match_gga_data = gga_data.split(",") - if len(match_gga_data) >4: #数据全 - match_vtg_data = vtg_data.split(",") - gps_date = "%s,%s"%(match_rmc_data[9],match_rmc_data[1][:6])#日期 - #gps_data_tmp = self.gps.read_coordinates(gnss_r_data[1]) - latitude = "0,N" #纬度 - latitude_tmp = str(self.GxGGA_latitude(gga_data)).split(".") - if len(latitude_tmp) >= 2 and len(latitude_tmp[1])>=5: - latitude = "%s.%s"%(latitude_tmp[0],latitude_tmp[1][:6]) - latitude = "%s,%s"%(latitude,match_rmc_data[4] ) - - longitude = "0,E"#经度 - longitude_tmp = str(self.GxGGA_longitude(gga_data)).split(".") - if len(longitude_tmp) >= 2 and len(longitude_tmp[1])>=5: - longitude = "%s.%s"%(longitude_tmp[0],longitude_tmp[1][:6]) - longitude = "%s,%s"%(longitude,match_rmc_data[6] ) #match_rmc_data[6] + str(gnss_r_data[1]) - - high = "0"#高度 - high = str(self.GxGGA_altitude(gga_data)) - number = "0"#可用卫星 - precision = "5.8"#精度 - if len(match_gga_data)>5 : - if match_gga_data[7]: - number = match_gga_data[7] - if match_gga_data[8]: - precision = match_gga_data[8] - direction = "249.5" #方向 - speed = '0.00' #速度 - if(len(match_vtg_data)>5 ): - if match_vtg_data[1]: - direction = match_vtg_data[1] - if match_vtg_data[7]: - speed = match_vtg_data[7] - self.gps_data = { - "latitude": latitude, - "longitude": longitude, - "high": high, - "direction": direction, - "speed": speed, - "number": number, - "date": gps_date, - "precision": precision - } + if i % 2 == 0: + if i+1 >= len(gsv_data) : + # EventMesh.debug_log("gsv_data num error!!") + break + GSV_dict[gsv_data[i]] = gsv_data[i+1] + #EventMesh.debug_log("type:gsv_data{}".format(type(gsv_data[i+1]))) + try: + #EventMesh.debug_log("gsv_tmp[i+3]:{}".format(gsv_tmp[i+3])) + if gsv_data[i+1] : + if (gsv_data[i+1])>=20: + tmp_ok_count +=1 + if (gsv_data[i+1])>=30: + tmp_very_ok_count +=1 + + except Exception as e: + usys.print_exception(e) + + if(tmp_ok_count > self.GSV_sig_ok_count ): + self.GSV_sig_ok_count = tmp_ok_count + if(tmp_very_ok_count > self.GSV_sig_very_ok_count ): + self.GSV_sig_very_ok_count = tmp_very_ok_count + match_rmc_data = rmc_data.split(",") + if len (match_rmc_data)>3: #有rmc数据 + if match_rmc_data[2] == 'A': + match_gga_data = gga_data.split(",") + if len(match_gga_data) >4: #数据全 + match_vtg_data = vtg_data.split(",") + gps_date = "%s,%s"%(match_rmc_data[9],match_rmc_data[1][:6])#日期 + #gps_data_tmp = self.gps.read_coordinates(gnss_r_data[1]) + latitude = "0,N" #纬度 + latitude_tmp = str(self.GxGGA_latitude(gga_data)).split(".") + if len(latitude_tmp) >= 2 and len(latitude_tmp[1])>=5: + latitude = "%s.%s"%(latitude_tmp[0],latitude_tmp[1][:6]) + latitude = "%s,%s"%(latitude,match_rmc_data[4] ) + + longitude = "0,E"#经度 + longitude_tmp = str(self.GxGGA_longitude(gga_data)).split(".") + if len(longitude_tmp) >= 2 and len(longitude_tmp[1])>=5: + longitude = "%s.%s"%(longitude_tmp[0],longitude_tmp[1][:6]) + longitude = "%s,%s"%(longitude,match_rmc_data[6] ) #match_rmc_data[6] + str(gnss_r_data[1]) + + high = "0"#高度 + high = str(self.GxGGA_altitude(gga_data)) + number = "0"#可用卫星 + precision = "5.8"#精度 + if len(match_gga_data)>5 : + if match_gga_data[7]: + number = match_gga_data[7] + if match_gga_data[8]: + precision = match_gga_data[8] + direction = "249.5" #方向 + speed = '0.00' #速度 + if(len(match_vtg_data)>5 ): + if match_vtg_data[1]: + direction = match_vtg_data[1] + if match_vtg_data[7]: + speed = match_vtg_data[7] + self.gps_data = { + "latitude": latitude, + "longitude": longitude, + "high": high, + "direction": direction, + "speed": speed, + "number": number, + "date": gps_date, + "precision": precision + } # *********************************************************************************** @@ -2472,7 +2481,7 @@ class LocationManager(Abstract): # EventMesh.txt_log("GGA_count<3:timer:{} ok_count:{} count:{}".format(self.location_timer_count,self.GSV_sig_ok_count,self.GGA_count)) # self.Location_send([self.gps_data,self.wifi_data,self.cell_data]) - if self.GSV_sig_ok_count <= 1 and self.wifi_data != [] and self.cell_data != [] and self.location_timer_count > 20: #超过40秒且信号大于30的不足3个 + if (self.isOpenGNSS == "1" or self.GSV_sig_ok_count <= 1) and self.wifi_data != [] and self.cell_data != [] and self.location_timer_count > 20: #超过40秒且信号大于30的不足3个 EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 #EventMesh.txt_log("GSV_sig_ok_count<3:timer:{} ok_count:{} ".format(self.location_timer_count,self.GSV_sig_ok_count)) self.Location_send([self.gps_data,self.wifi_data,self.cell_data]) @@ -2483,13 +2492,13 @@ class LocationManager(Abstract): #EventMesh.txt_log("self.GSV_sig_ok_count :{}".format(self.GSV_sig_ok_count)) #EventMesh.publish("set_old_step_value",self.location_timer_count) - #print("location_timer_count:{}".format(self.location_timer_count)) + #EventMesh.debug_log("location_timer_count:{}".format(self.location_timer_count)) except Exception as e: usys.print_exception(e) EventMesh.txt_log("location_thread:ERROR:".format(e)) - #print("location_thread:ERROR:{}".format(usys.print_exception(e))) - print("self.gps_data{},self.wifi_data{},self.cell_data{}".format(self.gps_data,self.wifi_data,self.cell_data)) + #EventMesh.debug_log("location_thread:ERROR:{}".format(usys.print_exception(e))) + EventMesh.debug_log("self.gps_data{},self.wifi_data{},self.cell_data{}".format(self.gps_data,self.wifi_data,self.cell_data)) #self.Location_send([self.gps_data,self.wifi_data,self.cell_data]) EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 utime.sleep_ms(500) @@ -2504,7 +2513,7 @@ class LocationManager(Abstract): if self.lpm_fd != None: pm.wakelock_unlock(self.lpm_fd) #pm.delete_wakelock(lpm_fd) - print("CLOSE_LOCATION") + EventMesh.debug_log("CLOSE_LOCATION") #EventMesh.txt_log("CLOSE_LOCATION") @@ -2519,7 +2528,7 @@ class AddrBookManager(Abstract): if self.check_json == True: with open("/usr/static/storage_file/phonebook.json","r",encoding="utf-8") as fd: self.read_phonebook = ujson.load(fd) - print("读取电话本") + EventMesh.debug_log("读取电话本") def post_processor_after_instantiation(self): EventMesh.subscribe("get_phonebook_list", self.get) @@ -2550,7 +2559,7 @@ class AddrBookManager(Abstract): EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去 else: EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去 - print("call_phonebook_one_call name:{} key_tmp:{} len:{}".format(name,key_tmp,len(self.read_phonebook))) + EventMesh.debug_log("call_phonebook_one_call name:{} key_tmp:{} len:{}".format(name,key_tmp,len(self.read_phonebook))) def call_phonebook_two_call(self, event, msg): name = '' @@ -2572,7 +2581,7 @@ class AddrBookManager(Abstract): EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去 else: EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去 - print("call_phonebook_two_call name:{} key_tmp:{}".format(name,key_tmp)) + EventMesh.debug_log("call_phonebook_two_call name:{} key_tmp:{}".format(name,key_tmp)) def call_phonebook_three_call(self, event, msg): name = '' @@ -2594,7 +2603,7 @@ class AddrBookManager(Abstract): EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去 else: EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去 - print("call_phonebook_three_call name:{} key_tmp:{}".format(name,key_tmp)) + EventMesh.debug_log("call_phonebook_three_call name:{} key_tmp:{}".format(name,key_tmp)) def set(self, event, msg): self.check_json = msg[0] @@ -2615,13 +2624,13 @@ class MsgManager(Abstract): def get_msg_nums(self, event, msg): self.msg_nums = sms.getMsgNums() - print("self.msg_nums {}:".format(self.msg_nums)) + EventMesh.debug_log("self.msg_nums {}:".format(self.msg_nums)) return self.msg_nums def get_msg_detail(self, event, msg): # self.msg_detail = sms.searchTextMsg(self.msg_nums) - # print("self.msg_detai {}:".format(self.msg_detai)) + # EventMesh.debug_log("self.msg_detai {}:".format(self.msg_detai)) return{ "小明":"有内鬼,停止交易", "小红":"今晚十点一起吃饭" @@ -2641,11 +2650,11 @@ class MsgdetailManager(Abstract): def save_msg_name(self, event, msg): self.msg_name = str(msg) - print("save_msg_name:msg".format(msg)) + EventMesh.debug_log("save_msg_name:msg".format(msg)) def save_msg_content(self, event, msg): self.msg_content = str(msg) - print("save_msg_content:msg".format(msg)) + EventMesh.debug_log("save_msg_content:msg".format(msg)) def get_msg_content(self, event, msg): return self.msg_content @@ -2662,7 +2671,7 @@ class CallLogManager(Abstract): if self.check_json == True: with open("/usr/static/storage_file/Call_log.json","r",encoding="utf-8") as fd: self.read_call_log = ujson.load(fd) - print("读取通话记录") + EventMesh.debug_log("读取通话记录") def post_processor_after_instantiation(self): EventMesh.subscribe("get_call_log_list", self.get) @@ -2789,7 +2798,7 @@ class gethistoryDataManager(Abstract): # if len(self.read_histroy_temp_data) >= 7: # sort_new = {} # sort_new = sorted(self.read_histroy_temp_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条 - # print(sort_new) + # EventMesh.debug_log(sort_new) # for i in range(len(self.read_histroy_temp_data)-1): # sort_new[i] = sort_new[i+1]#0==1 1== 2 2== 3 3==4 4==5 5==6 6==7 # self.read_histroy_temp_data[i] = sort_new[i] @@ -2800,7 +2809,7 @@ class gethistoryDataManager(Abstract): # with open("/usr/static/storage_file/history_temp.json","w",encoding="utf-8") as fd: # ujson.dump(self.read_histroy_temp_data,fd) - #print(self.read_histroy_temp_data) + #EventMesh.debug_log(self.read_histroy_temp_data) pass else: pass @@ -2824,7 +2833,7 @@ class gethistoryDataManager(Abstract): if len(self.read_histroy_hr_data) >= 7: sort_new = {} sort_new = sorted(self.read_histroy_hr_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条 - print(sort_new) + EventMesh.debug_log(sort_new) for i in range(len(self.read_histroy_hr_data)-1): sort_new[i] = sort_new[i+1]#0==1 1== 2 2== 3 3==4 4==5 5==6 6==7 self.read_histroy_hr_data[i] = sort_new[i] @@ -2855,7 +2864,7 @@ class gethistoryDataManager(Abstract): # if len(self.read_histroy_spo2_data) >= 7: # sort_new = {} # sort_new = sorted(self.read_histroy_spo2_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条 - # print(sort_new) + # EventMesh.debug_log(sort_new) # for i in range(len(self.read_histroy_spo2_data)-1): # sort_new[i] = sort_new[i+1]#0==1 1== 2 2== 3 3==4 4==5 5==6 6==7 # self.read_histroy_spo2_data[i] = sort_new[i] @@ -2866,7 +2875,7 @@ class gethistoryDataManager(Abstract): # with open("/usr/static/storage_file/history_spo2.json","w",encoding="utf-8") as fd: # ujson.dump(self.read_histroy_spo2_data,fd) - # #print(self.read_histroy_spo2_data) + # #EventMesh.debug_log(self.read_histroy_spo2_data) #播放语音 # EventMesh.publish("set_hr_blood_led",2)#测量成功 pass @@ -3106,7 +3115,7 @@ class getStorageDataManager(Abstract):#获取内存数据 EventMesh.subscribe("get_storage_config", self.get_storage_config) def set_storage_data(self, event, msg): - # print("set_storage_data:{}".format(msg)) + # EventMesh.debug_log("set_storage_data:{}".format(msg)) if msg != None: self.config_data = msg with open("/usr/static/storage_file/config.json",'w+',encoding="utf-8") as fd: @@ -3114,29 +3123,29 @@ class getStorageDataManager(Abstract):#获取内存数据 def set_storage_config(self,event,msg): - # print("set_storage_key_data1:{}".format(msg)) + # EventMesh.debug_log("set_storage_key_data1:{}".format(msg)) if len(msg) >= 2: self.config_data[msg[0]]=msg[1] - # print("set_storage_key_data2:{}".format(self.config_data[msg[0]])) + # EventMesh.debug_log("set_storage_key_data2:{}".format(self.config_data[msg[0]])) EventMesh.publish("publish_message_event_ui",{"func":self.set_storage_save,"data":0}) def set_storage_save(self, data): with open("/usr/static/storage_file/config.json",'w+',encoding="utf-8") as fd: ujson.dump(self.config_data,fd) def get_storage_data(self, event, msg): - # print("get_storage_data:{}".format(self.config_data)) + # EventMesh.debug_log("get_storage_data:{}".format(self.config_data)) return self.config_data def get_storage_config(self,event,msg): - # print("get_storage_key_data1:{}".format(msg)) + # EventMesh.debug_log("get_storage_key_data1:{}".format(msg)) b = msg in self.config_data.keys() if b == True: - # print("get_storage_key_data2:{}".format(self.config_data[msg])) + # EventMesh.debug_log("get_storage_key_data2:{}".format(self.config_data[msg])) return self.config_data[msg] else : return None # try: # return self.config_data[msg] # except: - # print("get_storage_key_data:none key:{}",msg) + # EventMesh.debug_log("get_storage_key_data:none key:{}",msg) # return None #定位频率 class getUpLoadDataManager(Abstract):# @@ -3335,7 +3344,7 @@ class getBootOffManager(Abstract):#开关机时间 EventMesh.subscribe("get_boot_off_time", self.get_boot_off_time) def set_boot_off_time(self, event, msg): - print("set_boot_off_time",msg) + EventMesh.debug_log("set_boot_off_time",msg) EventMesh.publish("set_storage_config",["off_on",msg[0]]) EventMesh.publish("set_storage_config",["off_start",msg[1]]) EventMesh.publish("set_storage_config",["off_end",msg[2]]) @@ -3483,9 +3492,9 @@ class ClockManager(Abstract): def set(self, event, msg): global alarm_list - print("msg = {}".format(msg)) + EventMesh.debug_log("msg = {}".format(msg)) idx = msg.get("idx") - print("修改第{}个闹钟信息{}".format(idx,alarm_list[idx])) + EventMesh.debug_log("修改第{}个闹钟信息{}".format(idx,alarm_list[idx])) alarm_list[idx]["hour"] = msg["hour"] alarm_list[idx]["minute"] = msg["minute"] alarm_list[idx]["days"] = msg["days"] @@ -3497,7 +3506,7 @@ class ClockManager(Abstract): def read_alarminjson(self, event, msg): IFEXIST = ql_fs.path_exists("/usr/static/storage_file/alarm_msg.json") global alarm_list - print("IFEXIST:{}".format(IFEXIST)) + EventMesh.debug_log("IFEXIST:{}".format(IFEXIST)) if IFEXIST == True: with open("/usr/static/storage_file/alarm_msg.json","r",encoding='utf-8') as fd: alarm_list = ujson.load(fd) @@ -3512,7 +3521,7 @@ class ClockManager(Abstract): # min2 = str(alarm_list[1]["minute"]) EventMesh.publish("set_boot_off_time",[1,hour1,hour2]) - print("hour1:{}-{}".format(hour1,hour2)) + EventMesh.debug_log("hour1:{}-{}".format(hour1,hour2)) return alarm_list @@ -3521,14 +3530,14 @@ class ClockManager(Abstract): global alarm_list EventMesh.publish("read_alarminjson") - print("msg:{}".format(msg)) + EventMesh.debug_log("msg:{}".format(msg)) for i in range(0,2):#开关机固定是 idx 0 1 off_msg1 = msg[i+1] msg_tmp1 = off_msg1.split(':') start_hour = int(msg_tmp1[0]) start_min = int(msg_tmp1[1]) enable = int(msg[0]) - print("start_hour:{} start_min:{} enable:{}",start_hour,start_min,enable) + EventMesh.debug_log("start_hour:{} start_min:{} enable:{}",start_hour,start_min,enable) EventMesh.publish("set_boot_off_time",[msg[0],msg[1],msg[2]]) alarm_list[i]["idx"]=i @@ -3542,7 +3551,7 @@ class ClockManager(Abstract): # alarm_list.append({"idx": i, "hour": start_hour, "minute": start_min, "days":[0,1,2,3,4,5,6], "enabled": enable,"repeart":10}) - # print("alarm_list----len- :{} alarm_list:{}".format(len(alarm_list),alarm_list)) + # EventMesh.debug_log("alarm_list----len- :{} alarm_list:{}".format(len(alarm_list),alarm_list)) with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd: ujson.dump(alarm_list,fd) EventMesh.publish("push_update_alarm_show") @@ -3554,22 +3563,22 @@ class ClockManager(Abstract): def remove_alarm(self, event, msg): global alarm_list - print("ddddddddddddddddddd:",msg) + EventMesh.debug_log("ddddddddddddddddddd:",msg) idx = msg.get("idx") - print("delete_here1-----{},{}:".format(idx,msg)) + EventMesh.debug_log("delete_here1-----{},{}:".format(idx,msg)) for i, alarm in enumerate(alarm_list): - print("delete_here2-----{},{}:".format(i,alarm)) + EventMesh.debug_log("delete_here2-----{},{}:".format(i,alarm)) if alarm["idx"] == idx: del alarm_list[i] - print("delete_here3-----",alarm_list) + EventMesh.debug_log("delete_here3-----",alarm_list) #删除闹钟后,对idx重新排序 if alarm_list: for j in range(i,len(alarm_list)): alarm_list[j]["idx"] -= 1 - print("delete_here4-----",alarm_list) + EventMesh.debug_log("delete_here4-----",alarm_list) with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd: ujson.dump(alarm_list,fd) @@ -3579,25 +3588,25 @@ class ClockManager(Abstract): return self.idx def _rtc_callback(self,args): - print("---!!!!!!pfff neew alarm_ring!!!!!!!---,idx:",args) + EventMesh.debug_log("---!!!!!!pfff neew alarm_ring!!!!!!!---,idx:",args) global alarm_list EventMesh.publish("read_alarminjson") idx = self.idx - print("单次闹钟关闭:{} alarm_list:{}".format(idx,alarm_list)) + EventMesh.debug_log("单次闹钟关闭:{} alarm_list:{}".format(idx,alarm_list)) #判断是否是单次闹钟,如果是,则将开关状态设置为关闭 # for i in range(len(alarm_list)): # if alarm_list[i]["idx"] == self.idx: # idx = i if not alarm_list[idx]["days"] : - print("关闭1:",alarm_list[idx]["days"]) - print("关闭2:",alarm_list [idx]["days"]) + EventMesh.debug_log("关闭1:",alarm_list[idx]["days"]) + EventMesh.debug_log("关闭2:",alarm_list [idx]["days"]) alarm_list[idx]["enabled"] = False with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd: ujson.dump(alarm_list,fd) #设置下一个闹钟,定时开关机功能 msg_data = EventMesh.publish("get_boot_off_time") - print("msg_tmp:{}".format(msg_data)) + EventMesh.debug_log("msg_tmp:{}".format(msg_data)) off_on = 1 off_start = "6:0" off_end = "23:0" @@ -3618,7 +3627,7 @@ class ClockManager(Abstract): rtc_now_time = self.rtc.datetime() current = rtc_now_time[4]*60+rtc_now_time[5] cur_day = rtc_now_time[3] - print("off_on:{} current:{} start_min:{} end_min:{}".format(off_on,current,start_min,end_min)) + EventMesh.debug_log("off_on:{} current:{} start_min:{} end_min:{}".format(off_on,current,start_min,end_min)) if off_on != None: if off_on == 1: if end_min == current:#结束的时间分钟等于关机时间分钟数则关机 @@ -3631,25 +3640,25 @@ class ClockManager(Abstract): if next_minute >= current_minute:#开机时间大于当前时间 9:00 > = 8:00 interval_minute = next_minute - current_minute - print("关机距离下一次响铃的的分钟数:", interval_minute,next_minute) + EventMesh.debug_log("关机距离下一次响铃的的分钟数:", interval_minute,next_minute) else:#8:00 9:00 #7*60*24 7天一个周期 7*60*24 - interval_minute = next_minute + 24*60 - print("关机08888距离下一次响铃的的分钟数:", interval_minute,next_minute) + EventMesh.debug_log("关机08888距离下一次响铃的的分钟数:", interval_minute,next_minute) #反向获取时间戳 time = utime.localtime() - print("关机09获取utime的时间戳:", time) + EventMesh.debug_log("关机09获取utime的时间戳:", time) rtc_mktime = utime.mktime(time) - print("关机10反向获取utime的mktime:", rtc_mktime) + EventMesh.debug_log("关机10反向获取utime的mktime:", rtc_mktime) #加上下一次响铃需要的时间 next_alarm_mktime = rtc_mktime + interval_minute*60 #转换成s单位 时间戳 - print("关机11下一次响铃的mktime:", next_alarm_mktime) + EventMesh.debug_log("关机11下一次响铃的mktime:", next_alarm_mktime) #格式化时间戳,得到下一次闹钟的时间 next_alarm_time = utime.localtime(next_alarm_mktime) - print("关机12下一次响铃的准确时间:", next_alarm_time) + EventMesh.debug_log("关机12下一次响铃的准确时间:", next_alarm_time) #将时间转换为rtc的格式 data_l = [2021, 7, 9, 5, 12, 30, 0, 0] #给rtc时间赋值 @@ -3659,22 +3668,22 @@ class ClockManager(Abstract): data_l[4] = next_alarm_time[3] #hour data_l[5] = next_alarm_time[4] #minute data_e=tuple(data_l) - print("关机13将该时间转换为RTC元组:", data_e) + EventMesh.debug_log("关机13将该时间转换为RTC元组:", data_e) self.rtc.register_callback(self._rtc_callback) FLAG = self.rtc.set_alarm(data_e) if FLAG == 0: - print("开机11成功设置rtc的到期时间:", data_e) + EventMesh.debug_log("开机11成功设置rtc的到期时间:", data_e) else: - print("开机时设置rtc的到期时间失败:", data_e) + EventMesh.debug_log("开机时设置rtc的到期时间失败:", data_e) self.rtc.enable_alarm(1) if ubs_state == 2 or ubs_state == 0: - print("结束时设置rtc的到期时间失败:", data_e) + EventMesh.debug_log("结束时设置rtc的到期时间失败:", data_e) EventMesh.publish("open_power_on", 5)#静音关机 return else: - print("结束111开机时设置rtc的到期时间失败:", data_e) + EventMesh.debug_log("结束111开机时设置rtc的到期时间失败:", data_e) return EventMesh.publish("set_rtc_alarm") @@ -3684,7 +3693,7 @@ class ClockManager(Abstract): total_min = 0 if off_on != None: if off_on == 1: - # print("alarm_list:{}".format(alarm_list)) + # EventMesh.debug_log("alarm_list:{}".format(alarm_list)) for idx in range(0,len(alarm_list)): hour = int(alarm_list[idx]["hour"]) min = int(alarm_list[idx]["minute"]) @@ -3692,7 +3701,7 @@ class ClockManager(Abstract): enable = int(alarm_list[idx]["enabled"]) repeart = int(alarm_list[idx]["repeart"]) total_min = hour*60+min - # print("hour",hour,min,day,enable,repeart,total_min,start_min) + # EventMesh.debug_log("hour",hour,min,day,enable,repeart,total_min,start_min) if enable == 1: if repeart != 10: if len(day) == 0 and enable == 1:#单次闹钟 @@ -3705,7 +3714,7 @@ class ClockManager(Abstract): else: if (cur_day in day) and enable == 1: if total_min == start_min and enable == 1:#如果闹钟时间和开机时间一致啧响铃否则不响铃 - # print("alarm_ring22222") + # EventMesh.debug_log("alarm_ring22222") EventMesh.publish("OPEN_ALARM_RING")#闹钟到点响铃 alarm_flag = 1 break @@ -3715,7 +3724,7 @@ class ClockManager(Abstract): continue else: alarm_flag = 0 - # print("start_min",start_min,current,alarm_flag) + # EventMesh.debug_log("start_min",start_min,current,alarm_flag) if (start_min != current and alarm_flag == 0) or off_on == 0: EventMesh.publish("OPEN_ALARM_RING")#闹钟到点响铃 @@ -3725,17 +3734,17 @@ class ClockManager(Abstract): EventMesh.publish("read_alarminjson") rtc_now_time = self.rtc.datetime() - # print("00获取所有闹钟信息:{}".format(alarm_list)) + # EventMesh.debug_log("00获取所有闹钟信息:{}".format(alarm_list)) new_alarm_list = [(alarm['hour'], alarm['minute'], alarm['days'],alarm["idx"]) for alarm in alarm_list if alarm['enabled']] - print("01获取开启的闹钟:{}".format(new_alarm_list)) + EventMesh.debug_log("01获取开启的闹钟:{}".format(new_alarm_list)) start_day = 0 # 周日 start_minute = 0 # 0点 end_minute = 60*24*7 minute_list = [] if not new_alarm_list: - print("02当前并没有开启的闹钟,退出闹钟设置程序:{}".format(new_alarm_list)) + EventMesh.debug_log("02当前并没有开启的闹钟,退出闹钟设置程序:{}".format(new_alarm_list)) self.rtc.enable_alarm(0) return @@ -3750,25 +3759,25 @@ class ClockManager(Abstract): #如果当前时间没超过闹钟设置时间,则设置为今天,否则设置为明天 if (hour*60 + minute) > (rtc_now_time[4]*60 + rtc_now_time[5]): minute_list.append(hour*60 + minute + (rtc_now_time[3]-start_day)*24*60) - print("设置单次闹钟:{}".format(new_alarm_list)) + EventMesh.debug_log("设置单次闹钟:{}".format(new_alarm_list)) else: minute_list.append(hour*60 + minute + (rtc_now_time[3]-start_day+1)*24*60) total_minutes = sorted(minute_list) - print("02以周日00:00为起点,计算所有开启闹钟的total_min并排序:{}".format(total_minutes)) + EventMesh.debug_log("02以周日00:00为起点,计算所有开启闹钟的total_min并排序:{}".format(total_minutes)) #获取当前时间 (2020, 9, 11, 5, 15, 43, 23, 0) # rtc_now_time = (2020, 9, 11, 6, 11, 43, 23, 0) # rtc_now_time = self.rtc.datetime() - print("03当前的rtc时间:{}".format(rtc_now_time)) + EventMesh.debug_log("03当前的rtc时间:{}".format(rtc_now_time)) current_minute = rtc_now_time[4]*60 + rtc_now_time[5] + (rtc_now_time[3]-start_day)*24*60 - print("04当前的rtc_total_minutes:{}".format(current_minute)) + EventMesh.debug_log("04当前的rtc_total_minutes:{}".format(current_minute)) if current_minute in minute_list: - print("当前时间和闹钟列表时间重复,删除重复的时间") + EventMesh.debug_log("当前时间和闹钟列表时间重复,删除重复的时间") minute_list.remove(current_minute) minute_list.append(current_minute) @@ -3777,38 +3786,38 @@ class ClockManager(Abstract): minute_list = sorted(minute_list) current_index = minute_list.index(current_minute) - print("05将当前时间插入min_list后的min_list:{}".format(minute_list)) - print("06当前时间所在位置:{}".format(current_index)) + EventMesh.debug_log("05将当前时间插入min_list后的min_list:{}".format(minute_list)) + EventMesh.debug_log("06当前时间所在位置:{}".format(current_index)) next_index = current_index + 1 if next_index >= len(minute_list): next_minute = minute_list[0] - print("0744下一个闹钟的分钟数:", next_minute) + EventMesh.debug_log("0744下一个闹钟的分钟数:", next_minute) else: next_minute = minute_list[next_index] - print("0744下一个闹钟的分钟数:", next_minute) + EventMesh.debug_log("0744下一个闹钟的分钟数:", next_minute) if next_minute >= current_minute: interval_minute = next_minute - current_minute - print("08666距离下一次响铃的的分钟数:", interval_minute) + EventMesh.debug_log("08666距离下一次响铃的的分钟数:", interval_minute) else: #7*60*24 7天一个周期 7*60*24 - interval_minute = end_minute - current_minute + next_minute - print("08888距离下一次响铃的的分钟数:", interval_minute) + EventMesh.debug_log("08888距离下一次响铃的的分钟数:", interval_minute) #反向获取时间戳 time = utime.localtime() - print("09获取utime的时间戳:", time) + EventMesh.debug_log("09获取utime的时间戳:", time) rtc_mktime = utime.mktime(time) - print("10反向获取utime的mktime:", rtc_mktime) + EventMesh.debug_log("10反向获取utime的mktime:", rtc_mktime) #加上下一次响铃需要的时间 next_alarm_mktime = rtc_mktime + interval_minute*60 - print("11下一次响铃的mktime:", next_alarm_mktime) + EventMesh.debug_log("11下一次响铃的mktime:", next_alarm_mktime) #格式化时间戳,得到下一次闹钟的时间 next_alarm_time = utime.localtime(next_alarm_mktime) - print("12下一次响铃的准确时间:", next_alarm_time) + EventMesh.debug_log("12下一次响铃的准确时间:", next_alarm_time) #将时间转换为rtc的格式 data_l = [2021, 7, 9, 5, 12, 30, 0, 0] #给rtc时间赋值 @@ -3819,11 +3828,11 @@ class ClockManager(Abstract): data_l[5] = next_alarm_time[4] #minute #转换为元组 data_e=tuple(data_l) - print("13将该时间转换为RTC元组:", data_e) + EventMesh.debug_log("13将该时间转换为RTC元组:", data_e) for alarm in alarm_list: if not alarm["days"] and alarm["enabled"]: - print("关闭666:",alarm["idx"]) + EventMesh.debug_log("关闭666:",alarm["idx"]) if alarm["hour"] == data_l[4] and alarm["minute"]==data_l[5]: self.idx = alarm["idx"] #设置rtc闹钟时间 @@ -3831,9 +3840,9 @@ class ClockManager(Abstract): FLAG = self.rtc.set_alarm(data_e) if FLAG == 0: - print("14成功设置rtc的到期时间:", data_e) + EventMesh.debug_log("14成功设置rtc的到期时间:", data_e) else: - print("14设置rtc的到期时间失败:", data_e) + EventMesh.debug_log("14设置rtc的到期时间失败:", data_e) self.rtc.enable_alarm(1)