手机功耗分析:比对安捷伦电源数据

import struct
binf=file("A new-3g-qq.bin","rb")
binf.seek(0x7c)
binf2=file("A OLD-3g-QQ.bin","rb")
fileheader=binf2.read(0x7c)
binf2.seek(0x7c)

checkpos=5
threhold=0.01

avergelen=5


def tocomb():
    binfc=file("comb.bin","wb+")
    binfc.write(fileheader)
    cnt=0
    rec=0
    v=0
    while 1:
            buf=binf.read(20)
            if len(buf)==20:
                dat=struct.unpack("fffii", buf)
                cnt+=1
                v+=dat[0]
                if cnt>=checkpos:
                    v = v/cnt
                    if rec<checkpos:
                        if v> threhold:
                            rec+=1
                        else:
                            rec=0
                        
                    if rec>=checkpos:
                        break
                    v=0
                    cnt=0
            else:
                break
            
    cnt=0
    rec=0
    v=0
    while 1:
            buf=binf2.read(20)
            if len(buf)==20:
                dat=struct.unpack("fffii", buf)
                cnt+=1
                v+=dat[0]
                if cnt>=checkpos:
                    v = v/cnt
                    if rec<checkpos:
                        if v> threhold:
                            rec+=1
                        else:
                            rec=0
                        
                    if rec>=checkpos:
                        break
                    v=0
                    cnt=0
            else:
                break
    val0=0
    val1=0
    delv=0
    totalcnt=0
    while 1:
            buf=binf.read(20)
            buf2=binf2.read(20)
            cnt+=1
            totalcnt=totalcnt+1.0
            if len(buf)==20 and len(buf2)==20:
                val0+=struct.unpack("f", buf[:4])[0]
                val1+=struct.unpack("f", buf2[:4])[0]
                if(cnt>=avergelen):
                    delv+=val0-val1                    
                    val0=val0/cnt
                    val1=val1/cnt
                    dat=struct.pack("fff", val0,val1,delv/totalcnt)
                    dat+='\0'*8
                    binfc.write(dat)
                    val0 = 0
                    val1 = 0
                    cnt = 0
            else:
                break            
    binfc.close()
    
def toaverage():
    cnt=0
    rec=0
    v=0
    while 1:
        buf=binf.read(20)
        if len(buf)==20:
            dat=struct.unpack("fffii", buf)
            cnt+=1
            v+=dat[0]
            if cnt>=10:
                v = v/cnt
                if rec<checkpos:
                    if v > threhold:
                        rec+=1
                    else:
                        rec=0
                    
                if rec>=checkpos:
                    print v
                v=0
                cnt=0
        else:
            break
tocomb()       

阅读更多
文章标签: 手机 file import c
个人分类: android
想对作者说点什么? 我来说一句

安捷伦_Agilent电源使用手册.pdf

2011年04月14日 304KB 下载

安捷伦驱动程序

2013年04月22日 280KB 下载

安捷伦仪器的C#校准仪器

2015年03月02日 116KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭