From fe2bb40eba12c83e8eaa3956beff3e1b1ccc335c Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Thu, 26 Dec 2024 21:29:09 +0800 Subject: [PATCH] =?utf8?q?=E6=9B=B4=E6=96=B0=E8=84=9A=E6=9C=AC=E8=A7=A3?= =?utf8?q?=E6=9E=90=E5=B7=A5=E5=85=B7=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=A8=AA?= =?utf8?q?=E5=90=91=E5=88=86=E6=9E=90=E8=A1=A8=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- tools/log_parser/runtimeanalysis_2.0.py | 222 ++++++++++++++++++++---- 1 file changed, 193 insertions(+), 29 deletions(-) diff --git a/tools/log_parser/runtimeanalysis_2.0.py b/tools/log_parser/runtimeanalysis_2.0.py index 3028e54bd..a9a3a88f5 100644 --- a/tools/log_parser/runtimeanalysis_2.0.py +++ b/tools/log_parser/runtimeanalysis_2.0.py @@ -44,6 +44,9 @@ str_bin_list =[ ['0001', "开机 "], ['0506',"运动测量心率暂停或结束"], ['0507',"底层检测心率"], ['0508',"底层检测心率结束"], + ['0509',"心率结果未佩戴"], + ['050a',"心率结果无效值"], + ['050b',"检测成功"], ['0601',"开启佩戴检测"], ['0602',"关闭佩戴检测"], ['0701',"主动检测血氧"], @@ -172,6 +175,9 @@ workbook = xlsxwriter.Workbook("runtime.xlsx") worksheet = workbook.add_worksheet("runtime_log") worksleepdata = workbook.add_worksheet("sleepdata") workvoltage = workbook.add_worksheet("voltage") +workvoltage_time = workbook.add_worksheet("voltage_time") +headings = ['time', 'ble连接','ble未连接','APP_ble_write_count','watch_reply_count','震动次数','屏幕亮','屏幕灭','心率测量时间','电压变化'] +workvoltage_time.write_row('A1', headings) with open(txtname,"rb+")as file: data_1 = file.read(2) @@ -179,6 +185,7 @@ with open(txtname,"rb+")as file: i=0 j=0 z=0 + k=1 sys_sleep_last=-1 sys_sleep_last_tick=0 sys_sleep_tick=0 @@ -196,6 +203,27 @@ with open(txtname,"rb+")as file: fist_voltage=0.0 last_voltage=0.0 lats_time=0 + + last_ble_connect=0 + ble_connect_state_updata_time=0 + ble_no_connect_time=0 + ble_connect_time=0 + + APP_send_coutn=0 + watch_reply_count=0 + + motor_coutn=0 + + last_lcd_state=0 + lcd_state_updata_time=0 + lcd_no_screen_time=0 + lcd_screen_time=0 + + heart_state=0 + heart_state_updata_time=0 + heart_no_screen_time=0 + heart_screen_time=0 + while data_1: @@ -210,8 +238,16 @@ with open(txtname,"rb+")as file: f_out.write(l[1]) worksheet.write(i, 0, l[1]) break - + data_2_int=int(data_2_bin,16) + + if data_1_bin=='0107': + APP_send_coutn+=1 + if data_1_bin=='0109': + watch_reply_count+=1 + if data_1_bin=='0c01': + motor_coutn+=1 + if data_1_bin[:2]=='13': id=int(data_1_bin[2:],16) if id1 ble连接") + + if (data_1_bin =='0104') : #断连 + if last_ble_connect ==1: + ble_connect_time+=(data_2_int-ble_connect_state_updata_time) + ble_connect_state_updata_time=data_2_int + last_ble_connect=0 + # print("0->1 ble断连") + + if (data_1_bin =='0801') : #亮屏 + if last_lcd_state ==0: + lcd_no_screen_time+=(data_2_int-lcd_state_updata_time) + lcd_state_updata_time=data_2_int + last_lcd_state=1 + # print("0->1 亮屏") + + if (data_1_bin =='0802') : #灭屏 + if last_lcd_state ==1: + lcd_screen_time+=(data_2_int-lcd_state_updata_time) + lcd_state_updata_time=data_2_int + last_lcd_state=0 + # print("0->1 灭屏") + + # ['0507',"底层检测心率"], + # ['0508',"底层检测心率结束"], + # heart_state=0 + # heart_state_updata_time=0 + # heart_no_screen_time=0 + # heart_screen_time=0 + if (data_1_bin =='0507') : #开始检测 + if heart_state ==0: + heart_no_screen_time+=(data_2_int-heart_state_updata_time) + heart_state_updata_time=data_2_int + heart_state=1 + + if (data_1_bin =='0508') : #结束检测 + if heart_state ==1: + heart_screen_time+=(data_2_int-heart_state_updata_time) + print("检测时间",data_2_int-heart_state_updata_time) + heart_state_updata_time=data_2_int + heart_state=0 + + + if (data_1_bin[:1]=='f') | (data_1_bin[:1]=='e'): worksheet.write(i, 0, "电压变化") + f_out.write(data_1_bin) f_out.write(' ') f_out.write(data_2_bin) f_out.write('\n') - data_2_int=int(data_2_bin,16) + worksheet.write(i, 1, data_1_bin) worksheet.write(i, 2, data_2_int) i+=1 now_s_sleep_flag=0 now_m_sleep_flag=0 - if data_1_bin[:1]=='f': - temp_str="4."+ data_1_bin[1:] + + if (data_1_bin[:1]=='f' )|(data_1_bin[:1]=='e'): + if data_1_bin[:1]=='f': + temp_str="4."+ data_1_bin[1:] + else: + temp_str="3."+ data_1_bin[1:] voltage=float(temp_str) workvoltage.write(z, 0, voltage) workvoltage.write(z, 1, data_2_int) workvoltage.write(z, 2, data_2_int-lats_time) workvoltage.write(z, 3, last_voltage-voltage) - lats_time=data_2_int - z+=1 + - last_voltage=voltage - if fist_voltage==0.0: - fist_voltage= voltage + workvoltage_time.write(k, 0,data_2_int) + + if last_ble_connect==0: + ble_no_connect_time+=(data_2_int-ble_connect_state_updata_time) + if last_ble_connect==1: + ble_connect_time+=(data_2_int-ble_connect_state_updata_time) + + + if (ble_no_connect_time+ble_connect_time): + ble_connect= ble_connect_time/(ble_no_connect_time+ble_connect_time) + else: + ble_connect=0 + + if (ble_no_connect_time+ble_connect_time): + ble_no= ble_no_connect_time/(ble_no_connect_time+ble_connect_time) + else: + ble_no=0 + + # last_lcd_state=0 + # lcd_state_updata_time=0 + # lcd_no_screen_time=0 + # lcd_screen_time=0 + + if last_lcd_state==0: + lcd_no_screen_time+=(data_2_int-lcd_state_updata_time) + if last_lcd_state==1: + lcd_screen_time+=(data_2_int-lcd_state_updata_time) + + + if (lcd_no_screen_time+lcd_screen_time): + lcd_screen= lcd_screen_time/(lcd_no_screen_time+lcd_screen_time) + else: + lcd_screen=0 + + if (lcd_no_screen_time+lcd_screen_time): + lcd_no_screen= lcd_no_screen_time/(lcd_no_screen_time+lcd_screen_time) + else: + lcd_no_screen=0 + # heart_state=0 + # heart_state_updata_time=0 + # heart_no_screen_time=0 + # heart_screen_time=0 + + if heart_state==0: + heart_no_screen_time+=(data_2_int-heart_state_updata_time) + if heart_state==1: + heart_screen_time+=(data_2_int-heart_state_updata_time) + + + + + + + # headings = ['time', 'ble连接','ble未连接','APP_ble_write_count','watch_reply_count','震动次数','屏幕亮','屏幕灭','电压变化'] + + workvoltage_time.write(k, 1,ble_connect) + workvoltage_time.write(k, 2,ble_no) + workvoltage_time.write(k, 3,APP_send_coutn) + workvoltage_time.write(k, 4,watch_reply_count) + workvoltage_time.write(k, 5,motor_coutn) + workvoltage_time.write(k, 6,lcd_screen) + workvoltage_time.write(k, 7,lcd_no_screen) + workvoltage_time.write(k, 8,heart_screen_time) + workvoltage_time.write(k, 9,last_voltage-voltage) - if data_1_bin[:1]=='e': - temp_str="3."+ data_1_bin[1:] - voltage=float(temp_str) - workvoltage.write(z, 0, voltage) - workvoltage.write(z, 1, data_2_int) - workvoltage.write(z, 2, data_2_int-lats_time) - workvoltage.write(z, 3, last_voltage-voltage) - lats_time=data_2_int - z+=1 + + + ble_no_connect_time=0 + ble_connect_time=0 + ble_connect_state_updata_time=data_2_int + + lcd_no_screen_time=0 + lcd_screen_time=0 + lcd_state_updata_time=data_2_int + + heart_no_screen_time=0 + heart_screen_time=0 + heart_state_updata_time=data_2_int + + + APP_send_coutn=0 last_voltage=voltage + motor_coutn=0 + watch_reply_count=0 + lats_time=data_2_int + + k+=1 + if fist_voltage==0.0: fist_voltage= voltage - + if coutn==0: fist_tick=data_2_int @@ -286,7 +450,7 @@ with open(txtname,"rb+")as file: j+=1 no_sys_sleep_tick+=data_2_int-sys_sleep_last_tick - print("0->1 睡") + # print("0->1 睡") sys_sleep_last=1 sys_sleep_last_tick=data_2_int else: @@ -301,7 +465,7 @@ with open(txtname,"rb+")as file: worksleepdata.write(j, 3, data_2_int-sys_sleep_last_tick) j+=1 sys_sleep_tick+=data_2_int-sys_sleep_last_tick - print("1->0 醒") + # print("1->0 醒") sys_sleep_last=0 sys_sleep_last_tick=data_2_int else: @@ -324,7 +488,7 @@ with open(txtname,"rb+")as file: worksleepdata.write(j, 3, data_2_int-M_sleep_last_tick) j+=1 M_sleep_tick+=data_2_int-M_sleep_last_tick - print("0->1 睡") + # print("0->1 睡") M_sleep_last=1 M_sleep_last_tick=data_2_int else: @@ -339,13 +503,13 @@ with open(txtname,"rb+")as file: worksleepdata.write(j, 3, data_2_int-M_sleep_last_tick) j+=1 no_M_sleep_tick+=data_2_int-M_sleep_last_tick - print("1->0 醒") + # print("1->0 醒") M_sleep_last=0 M_sleep_last_tick=data_2_int else: print("erro") if (data_1_bin== '0002') | (data_1_bin== '0003')| (data_1_bin== '0004'): - toal_tick=data_2_int + if M_sleep_last==1: worksleepdata.write(j, 0, "M 睡了") worksleepdata.write(j, 1, M_sleep_last_tick) @@ -353,7 +517,7 @@ with open(txtname,"rb+")as file: worksleepdata.write(j, 3, data_2_int-M_sleep_last_tick) j+=1 no_M_sleep_tick+=data_2_int-M_sleep_last_tick - print("1->关机 睡死") + # print("1->关机 睡死") M_sleep_last=0 M_sleep_last_tick=data_2_int elif M_sleep_last==0: @@ -363,7 +527,7 @@ with open(txtname,"rb+")as file: worksleepdata.write(j, 3, data_2_int-M_sleep_last_tick) j+=1 M_sleep_tick+=data_2_int-M_sleep_last_tick - print("0->关机 醒死") + # print("0->关机 醒死") M_sleep_last=0 M_sleep_last_tick=data_2_int @@ -374,7 +538,7 @@ with open(txtname,"rb+")as file: worksleepdata.write(j, 3, data_2_int-sys_sleep_last_tick) j+=1 sys_sleep_tick+=data_2_int-sys_sleep_last_tick - print("1->关机 睡死") + # print("1->关机 睡死") M_sleep_last=0 M_sleep_last_tick=data_2_int elif sys_sleep_last==0: @@ -384,14 +548,14 @@ with open(txtname,"rb+")as file: worksleepdata.write(j, 3, data_2_int-sys_sleep_last_tick) j+=1 no_sys_sleep_tick+=data_2_int-sys_sleep_last_tick - print("0->关机 醒死") + # print("0->关机 醒死") M_sleep_last=0 M_sleep_last_tick=data_2_int coutn+=1 - + toal_tick=data_2_int data_1 = file.read(2) data_2 = file.read(4) # data_1_int=int(data_1) -- 2.17.1