def printStepInfo(): "输出计步数据" for i in range(len(stepData)): print str(i + 1) + "d计步信息:" print "当地时间:\t" + hex(stepData[i][StepInfo.TIMESTAMP]) + "\t\t" + util.converUnixTimestamp(stepData[i][StepInfo.TIMESTAMP]) print "时区:\t\t" + hex(stepData[i][StepInfo.TIMEZONE]) + "\t\t\t" + str(stepData[i][StepInfo.TIMEZONE]) print "久坐:\t\t" + hex(stepData[i][StepInfo.SEDENTARYCOUNT]) + "\t\t\t" + str(stepData[i][StepInfo.SEDENTARYCOUNT]) print "静息卡路里:\t" + hex(stepData[i][StepInfo.CALORIEBMR]) + "\t\t\t" + str(stepData[i][StepInfo.CALORIEBMR]) print "运动卡路里:\t" + hex(stepData[i][StepInfo.CALORIESPORT]) + "\t\t\t" + str(stepData[i][StepInfo.CALORIESPORT]) for j in range(24): h = str(j) if j < 10: h = "0" + str(j) print h + ":00 步数:\t" + hex(stepData[i][StepInfo.STEPHOUR + j * 2]) + "\t\t\t" + str(stepData[i][StepInfo.STEPHOUR + j * 2]) print h + ":00 距离:\t" + hex(stepData[i][StepInfo.DISTANCEHOUR + j * 2]) + "\t\t\t" + str(stepData[i][StepInfo.DISTANCEHOUR + j * 2]) util.printDividingLine()
def printInfo(): "输出实时数据" samplingInterval = 5 samplingCount = 168 # 打开一个文件 timestamp = info.uuid + info.dataindex * samplingInterval * samplingCount file = open("output.txt", "a") for i in range(len(realtimeData)): timestamp = timestamp + 5 timestring = util.converUnixTimestamp(timestamp) longitude = float(realtimeData[i][RealtimeData.LONGITUDE]) / 1000000 latitude = float(realtimeData[i][RealtimeData.LATITUDE]) / 1000000 longitude_ew = chr(realtimeData[i][RealtimeData.LONGITUDE_EW]) latitude_ns = chr(realtimeData[i][RealtimeData.LATITUDE_NS]) if 0xffffffff == realtimeData[i][RealtimeData.LONGITUDE]: longitude = 0 if 0xffffffff == realtimeData[i][RealtimeData.LATITUDE]: latitude = 0 if realtimeData[i][RealtimeData.LONGITUDE_EW] in (0, 0xff): longitude_ew = "" if realtimeData[i][RealtimeData.LATITUDE_NS] in (0, 0xff): latitude_ns = "" distance = util.computeDistanceByGnss(longitude, latitude, longitude_ew, latitude_ns) file.write(timestring + "\t\t") file.write("longitude:\t" + str(longitude) + longitude_ew) if 0.0 == longitude: file.write("\t\t\t\t") else: file.write("\t\t") file.write("latitude:\t" + str(latitude) + latitude_ns) if 0.0 == latitude: file.write("\t\t\t\t") else: file.write("\t\t") file.write("pace:\t" + str(realtimeData[i][RealtimeData.PACE]) + "\t\t") file.write("altitude:\t" + str(realtimeData[i][RealtimeData.DELTAALTITUDE]) + "\t\t") file.write("distance:\t" + str(realtimeData[i][RealtimeData.DELTADISTANCE]) + " cm" + "\t\t") file.write("offset:\t" + str(distance)) file.write("\n") file.flush() file.close()
def printRealtimeInfo(): "输出实时数据" # 打开一个文件 timestamp = statisticsData[Statistics.TIMESTAMP] + (dataInfo[DataHead.MODEL2] - 1) * 5 * 168 file = open("output.txt", "a") for i in range(len(realtimeData)): timestamp = timestamp + 5 timestring = util.converUnixTimestamp(timestamp) longitude = float(realtimeData[i][RealtimeData.LONGITUDE]) / 1000000 latitude = float(realtimeData[i][RealtimeData.LATITUDE]) / 1000000 longitude_ew = chr(realtimeData[i][RealtimeData.LONGITUDE_EW]) latitude_ns = chr(realtimeData[i][RealtimeData.LATITUDE_NS]) if 0xffffffff == realtimeData[i][RealtimeData.LONGITUDE]: longitude = 0 if 0xffffffff == realtimeData[i][RealtimeData.LATITUDE]: latitude = 0 if realtimeData[i][RealtimeData.LONGITUDE_EW] in (0, 0xff): longitude_ew = "" if realtimeData[i][RealtimeData.LATITUDE_NS] in (0, 0xff): latitude_ns = "" distance = computeDistanceByGnss(longitude, latitude, longitude_ew, latitude_ns) # print timestring + "\t\tcadence:\t" + hex(realtimeInfo[RealtimeData.CADENCE]) + "\t\t" + str(realtimeInfo[RealtimeData.CADENCE]) # print timestring + "\t\tlongitude:\t" + hex(realtimeData[i][RealtimeData.LONGITUDE]) + "\t" + str(longitude) + longitude_ew\ # + "\t" + "latitude:\t" + hex(realtimeData[i][RealtimeData.LATITUDE]) + "\t" + str(latitude) + latitude_ns\ # + "\t" + str(distance) file.write(timestring + "\t\t") file.write("longitude:\t" + str(longitude) + longitude_ew) if 0.0 == longitude: file.write("\t\t\t\t") else: file.write("\t\t") file.write("latitude:\t" + str(latitude) + latitude_ns) if 0.0 == latitude: file.write("\t\t\t\t") else: file.write("\t\t") file.write("distance:\t" + str(distance)) file.write("\n") file.flush() file.close()
def printStatisticsInfo(): "打印统计数据信息" modeName = ["健走", "户外跑", "室内跑", "骑行"] hrCount = 0 for i in range(5): hrCount += statisticsData[Statistics.DISTRIBUTED1 + i] if (statisticsData[Statistics.MODE] < 4): print "运动类型:\t" + hex(statisticsData[Statistics.MODE]) + "\t\t" + modeName[statisticsData[Statistics.MODE]] else: print "运动类型:\t " + hex(statisticsData[Statistics.MODE]) + "\t\t无法识别" print "平均心率:\t" + str(statisticsData[Statistics.AVERAGEHR]) print "最大心率:\t" + str(statisticsData[Statistics.MAXHR]) print "时区:\t\t" + str(statisticsData[Statistics.TIMEZONE]) for i in range(5): print "心率区间%d:\t%d\t\t%d%s"%(i + 1, statisticsData[Statistics.DISTRIBUTED1 + i], statisticsData[Statistics.DISTRIBUTED1 + i] * 100 / hrCount, "%") print "最大步频:\t" + str(statisticsData[Statistics.MAXCADENCE]) + "spm" print "上升大气压:\t" + str(statisticsData[Statistics.RISEATMOSPRESS]) + "帕" print "下降大气压:\t" + str(statisticsData[Statistics.DROPATMOSPRESS]) + "帕" print "最大大气压:\t" + str(statisticsData[Statistics.MAXATMOSPRESS]) + "帕" print "最小大气压:\t" + str(statisticsData[Statistics.MINATMOSPRESS]) + "帕" print "起始大气压:\t" + str(statisticsData[Statistics.ATMOSPRESS]) + "帕" print "卡路里消耗:\t" + str(statisticsData[Statistics.CALORIE]) + "卡" if SportMode.SPORT_RIDE != statisticsData[Statistics.MODE]: print "最佳配速:\t%d\t\t%d'%d\""%(statisticsData[Statistics.BESTPACE], statisticsData[Statistics.BESTPACE] / 60, statisticsData[Statistics.BESTPACE] % 60) else: print "最佳速度:\t%d\t\t%d.%dkm/h"%(statisticsData[Statistics.BESTPACE], statisticsData[Statistics.BESTPACE] / 1000, (statisticsData[Statistics.BESTPACE] % 1000) / 100) print "起始时间戳:\t" + str(statisticsData[Statistics.TIMESTAMP]) + "\t" + util.converUnixTimestamp(statisticsData[Statistics.TIMESTAMP]) print "完成时间:\t" + str(statisticsData[Statistics.ACCOMPLISHTIME]) + "秒\t\t" + util.converUnixTimestamp(statisticsData[Statistics.TIMESTAMP] + statisticsData[Statistics.ACCOMPLISHTIME]) print "暂停时间:\t" + str(statisticsData[Statistics.PAUSETIME]) + "秒" print "距离:\t\t" + str(statisticsData[Statistics.DISTANCE]) + "米" print "校准距离:\t" + str(statisticsData[Statistics.CALIDISTANCE]) + "米" print "步数:\t\t" + str(statisticsData[Statistics.STEP]) + "次" file = open("output.txt", "a") if (statisticsData[Statistics.MODE] < 4): file.write("运动类型:\t" + hex(statisticsData[Statistics.MODE]) + "\t\t\t" + modeName[statisticsData[Statistics.MODE]] + "\n") else: file.write("运动类型:\t " + hex(statisticsData[Statistics.MODE]) + "\t\t\t无法识别\n") file.write("平均心率:\t" + str(statisticsData[Statistics.AVERAGEHR]) + "\n") file.write("最大心率:\t" + str(statisticsData[Statistics.MAXHR]) + "\n") file.write("时区:\t\t" + str(statisticsData[Statistics.TIMEZONE]) + "\n") for i in range(5): file.write("心率区间%d:\t%d\t\t\t%d%s"%(i + 1, statisticsData[Statistics.DISTRIBUTED1 + i], statisticsData[Statistics.DISTRIBUTED1 + i] * 100 / hrCount, "%") + "\n") file.write("最大步频:\t" + str(statisticsData[Statistics.MAXCADENCE]) + " spm" + "\n") file.write("上升大气压:\t" + str(statisticsData[Statistics.RISEATMOSPRESS]) + " pa" + "\n") file.write("下降大气压:\t" + str(statisticsData[Statistics.DROPATMOSPRESS]) + " pa" + "\n") file.write("最大大气压:\t" + str(statisticsData[Statistics.MAXATMOSPRESS]) + " pa" + "\n") file.write("最小大气压:\t" + str(statisticsData[Statistics.MINATMOSPRESS]) + " pa" + "\n") file.write("起始大气压:\t" + str(statisticsData[Statistics.ATMOSPRESS]) + " pa" + "\n") file.write("卡路里消耗:\t" + str(statisticsData[Statistics.CALORIE]) + " cal" + "\n") if SportMode.SPORT_RIDE != statisticsData[Statistics.MODE]: file.write("最佳配速:\t%d\t\t%d'%d\""%(statisticsData[Statistics.BESTPACE], statisticsData[Statistics.BESTPACE] / 60, statisticsData[Statistics.BESTPACE] % 60) + "\n") else: file.write("最佳速度:\t%d\t\t%d.%dkm/h"%(statisticsData[Statistics.BESTPACE], statisticsData[Statistics.BESTPACE] / 1000, (statisticsData[Statistics.BESTPACE] % 1000) / 100) + "\n") file.write("起始时间戳:\t" + str(statisticsData[Statistics.TIMESTAMP]) + "\t" + util.converUnixTimestamp(statisticsData[Statistics.TIMESTAMP]) + "\n") file.write("完成时间:\t" + str(statisticsData[Statistics.ACCOMPLISHTIME]) + "秒\t\t" + util.converUnixTimestamp(statisticsData[Statistics.TIMESTAMP] + statisticsData[Statistics.ACCOMPLISHTIME]) + "\n") file.write("暂停时间:\t" + str(statisticsData[Statistics.PAUSETIME]) + "秒" + "\n") file.write("距离:\t\t" + str(statisticsData[Statistics.DISTANCE]) + " m" + "\n") file.write("校准距离:\t" + str(statisticsData[Statistics.CALIDISTANCE]) + " m" + "\n") file.write("步数:\t\t" + str(statisticsData[Statistics.STEP]) + "次" + "\n") file.write("*" * 40 + "\n") file.flush() file.close()
def printInfo(): "打印统计数据信息" modeName = ["健走", "户外跑", "室内跑", "骑行"] hrCount = 0 for i in range(5): hrCount += statisticsData[Statistics.DISTRIBUTED1 + i] olongitude = float(statisticsData[Statistics.OLONGITUDE]) / 1000000 olatitude = float(statisticsData[Statistics.OLATITUDE]) / 1000000 olongitude_ew = chr(statisticsData[Statistics.OLONGITUDE_EW]) olatitude_ns = chr(statisticsData[Statistics.OLATITUDE_NS]) if 0xffffffff == statisticsData[Statistics.OLONGITUDE]: olongitude = 0 if 0xffffffff == statisticsData[Statistics.OLATITUDE]: olatitude = 0 if statisticsData[Statistics.OLONGITUDE_EW] in (0, 0xff): olongitude_ew = "" if statisticsData[Statistics.OLATITUDE_NS] in (0, 0xff): olatitude_ns = "" tlongitude = float(statisticsData[Statistics.TLONGITUDE]) / 1000000 tlatitude = float(statisticsData[Statistics.TLATITUDE]) / 1000000 tlongitude_ew = chr(statisticsData[Statistics.TLONGITUDE_EW]) tlatitude_ns = chr(statisticsData[Statistics.TLATITUDE_NS]) if 0xffffffff == statisticsData[Statistics.TLONGITUDE]: tlongitude = 0 if 0xffffffff == statisticsData[Statistics.TLATITUDE]: tlatitude = 0 if statisticsData[Statistics.TLONGITUDE_EW] in (0, 0xff): tlongitude_ew = "" if statisticsData[Statistics.TLATITUDE_NS] in (0, 0xff): tlatitude_ns = "" h = statisticsData[Statistics.ACCOMPLISHTIME] / 3600 m = (statisticsData[Statistics.ACCOMPLISHTIME] - h * 3600) / 60 s = statisticsData[Statistics.ACCOMPLISHTIME] % 60 if (h > 0): accomplishtime = str(h) + "小时" + str(m) + "分" + str(s) + "秒" else: accomplishtime = str(m) + "分" + str(s) + "秒" if (statisticsData[Statistics.MODE] < info.SportMode.SPORT_MAX): print "运动类型:\t" + hex(statisticsData[Statistics.MODE]) + "\t\t" + modeName[statisticsData[Statistics.MODE]] else: print "运动类型:\t " + hex(statisticsData[Statistics.MODE]) + "\t\t无法识别" print "平均心率:\t" + str(statisticsData[Statistics.AVERAGEHR]) print "最大心率:\t" + str(statisticsData[Statistics.MAXHR]) print "时区:\t\t" + str(statisticsData[Statistics.TIMEZONE]) for i in range(5): if 0 == hrCount: print "心率区间%d:\t%d\t\t%d%s"%(i + 1, statisticsData[Statistics.DISTRIBUTED1 + i], 0, "%") else: print "心率区间%d:\t%d\t\t%d%s"%(i + 1, statisticsData[Statistics.DISTRIBUTED1 + i], statisticsData[Statistics.DISTRIBUTED1 + i] * 100 / hrCount, "%") print "最大步频:\t" + str(statisticsData[Statistics.MAXCADENCE]) + "spm" print "累计上升:\t" + str(statisticsData[Statistics.RISEALTITUDE]) + "米" print "累计下降:\t" + str(statisticsData[Statistics.DROPALTITUDE]) + "米" print "最大高度:\t" + str(statisticsData[Statistics.MAXALTITUDE]) + "米" print "最低高度:\t" + str(statisticsData[Statistics.MINALTITUDE]) + "米" print "起始高度:\t" + str(statisticsData[Statistics.ALTITUDE]) + "米" print "卡路里消耗:\t" + str(statisticsData[Statistics.CALORIE]) + "卡" if info.SportMode.SPORT_RIDE != info.mode: print "最佳配速:\t%d\t\t%d'%d\""%(statisticsData[Statistics.BESTPACE], statisticsData[Statistics.BESTPACE] / 60, statisticsData[Statistics.BESTPACE] % 60) else: print "最佳速度:\t%d\t\t%d.%dkm/h"%(statisticsData[Statistics.BESTPACE], statisticsData[Statistics.BESTPACE] / 1000, (statisticsData[Statistics.BESTPACE] % 1000) / 100) print "起始时间戳:\t" + str(statisticsData[Statistics.TIMESTAMP]) + "\t" + util.converUnixTimestamp(statisticsData[Statistics.TIMESTAMP]) print "完成时间:\t" + str(accomplishtime) + "\t\t" + util.converUnixTimestamp(statisticsData[Statistics.TIMESTAMP] + statisticsData[Statistics.ACCOMPLISHTIME]) print "暂停时间:\t" + str(statisticsData[Statistics.PAUSETIME]) + "秒" print "距离:\t\t" + str(statisticsData[Statistics.DISTANCE]) + "米" print "校准距离:\t" + str(statisticsData[Statistics.CALIDISTANCE]) + "米" print "步数:\t\t" + str(statisticsData[Statistics.STEP]) + "次" print "起始经度:\t" + hex(statisticsData[Statistics.OLONGITUDE]) + "\t" + str(olongitude) + olongitude_ew print "起始纬度:\t" + hex(statisticsData[Statistics.OLATITUDE]) + "\t" + str(olatitude) + olatitude_ns print "结束经度:\t" + hex(statisticsData[Statistics.TLONGITUDE]) + "\t" + str(tlongitude) + tlongitude_ew print "结束纬度:\t" + hex(statisticsData[Statistics.TLATITUDE]) + "\t" + str(tlatitude) + tlatitude_ns file = open(info.outfile, "a") if (statisticsData[Statistics.MODE] < info.SportMode.SPORT_MAX): file.write("运动类型:\t" + hex(statisticsData[Statistics.MODE]) + "\t\t\t" + modeName[statisticsData[Statistics.MODE]] + "\n") else: file.write("运动类型:\t " + hex(statisticsData[Statistics.MODE]) + "\t\t\t无法识别\n") file.write("平均心率:\t" + str(statisticsData[Statistics.AVERAGEHR]) + "\n") file.write("最大心率:\t" + str(statisticsData[Statistics.MAXHR]) + "\n") file.write("时区:\t\t" + str(statisticsData[Statistics.TIMEZONE]) + "\n") for i in range(5): if 0 == hrCount: file.write("心率区间%d:\t%d\t\t\t%d%s"%(i + 1, statisticsData[Statistics.DISTRIBUTED1 + i], 0, "%") + "\n") else: file.write("心率区间%d:\t%d\t\t\t%d%s"%(i + 1, statisticsData[Statistics.DISTRIBUTED1 + i], statisticsData[Statistics.DISTRIBUTED1 + i] * 100 / hrCount, "%") + "\n") file.write("最大步频:\t" + str(statisticsData[Statistics.MAXCADENCE]) + " spm" + "\n") file.write("累计上升:\t" + str(statisticsData[Statistics.RISEALTITUDE]) + " 米" + "\n") file.write("累计下降:\t" + str(statisticsData[Statistics.DROPALTITUDE]) + " 米" + "\n") file.write("最大高度:\t" + str(statisticsData[Statistics.MAXALTITUDE]) + " 米" + "\n") file.write("最低高度:\t" + str(statisticsData[Statistics.MINALTITUDE]) + " 米" + "\n") file.write("起始高度:\t" + str(statisticsData[Statistics.ALTITUDE]) + " 米" + "\n") file.write("卡路里消耗:\t" + str(statisticsData[Statistics.CALORIE]) + " cal" + "\n") if info.SportMode.SPORT_RIDE != info.mode: file.write("最佳配速:\t%d\t\t%d'%d\""%(statisticsData[Statistics.BESTPACE], statisticsData[Statistics.BESTPACE] / 60, statisticsData[Statistics.BESTPACE] % 60) + "\n") else: file.write("最佳速度:\t%d\t\t%d.%dkm/h"%(statisticsData[Statistics.BESTPACE], statisticsData[Statistics.BESTPACE] / 1000, (statisticsData[Statistics.BESTPACE] % 1000) / 100) + "\n") file.write("起始时间戳:\t" + str(statisticsData[Statistics.TIMESTAMP]) + "\t" + util.converUnixTimestamp(statisticsData[Statistics.TIMESTAMP]) + "\n") file.write("完成时间:\t" + str(accomplishtime) + "\t\t" + util.converUnixTimestamp(statisticsData[Statistics.TIMESTAMP] + statisticsData[Statistics.ACCOMPLISHTIME]) + "\n") file.write("暂停时间:\t" + str(statisticsData[Statistics.PAUSETIME]) + "秒" + "\n") file.write("距离:\t\t" + str(statisticsData[Statistics.DISTANCE]) + " m" + "\n") file.write("校准距离:\t" + str(statisticsData[Statistics.CALIDISTANCE]) + " m" + "\n") file.write("步数:\t\t" + str(statisticsData[Statistics.STEP]) + "次" + "\n") file.write("起始经度:\t" + str(olongitude) + olongitude_ew + "\n") file.write("起始纬度:\t" + str(olatitude) + olatitude_ns + "\n") file.write("结束经度:\t" + str(tlongitude) + tlongitude_ew + "\n") file.write("结束纬度:\t" + str(tlatitude) + tlatitude_ns + "\n") file.write("*" * 40 + "\n") file.flush() file.close()