From: Jannik ZANDER Date: Thu, 9 Jun 2016 15:16:37 +0000 (+0200) Subject: Improved speed plot X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=87ec0e439aba6a962c5a2dfe38549d0e5470acf1;p=dotfiles.git Improved speed plot --- diff --git a/.local/bin/genilog.py b/.local/bin/genilog.py index cb32c1a..e5b8278 100755 --- a/.local/bin/genilog.py +++ b/.local/bin/genilog.py @@ -18,7 +18,7 @@ def process_head(line): le,line=readbyte(line) da,line=readbyte(line) sa,line=readbyte(line) - typ="Error" + typ="**********Error**********" if ds==0x27: typ="Data Request" if ds==0x27 and da==0xFE: typ="Connection Request" if ds==0x27 and da==0xFF: typ="Broadcast Request" @@ -46,20 +46,21 @@ def process_isok(line): return line def process_timestamp(line): - timestamp=int(line) + timestamp=int(line)/1000 return timestamp def process(line): global timezero global t - global ref + global speed + global master line=line[2:] packet=line.split(" - ") n=len(packet) if n>0: print("Header:",packet[0]) ds,le,da,sa,typ=process_head(packet[0]) - print("Type:",typ,"Length",le,"Destination",da,"Source",sa) + print("Type:",typ,"Length:",le,"Destination:",da,"Source:",sa) if da==0xF7: if n>1: print("Payload:",packet[1]) @@ -91,29 +92,37 @@ def process(line): timestamp=process_timestamp(info[1].strip()) if timezero==0: timezero=timestamp - t=t + [timestamp-timezero] -# ref[0].append([ref1[0]]) -# ref[1].append([ref1[1]]) -# ref[2].append([ref1[2]]) -# ref[3].append([ref1[3]]) + t=t+[timestamp-timezero] + master=master+[1+(sa-31)/10] + speed[0]=speed[0]+[ref[0]/254] + speed[1]=speed[1]+[ref[1]/254] + speed[2]=speed[2]+[ref[2]/254] + speed[3]=speed[3]+[ref[3]/254] return timezero=0 t=[] -ref=[] -ref.append([]) -ref.append([]) -ref.append([]) -ref.append([]) +master=[] +speed=[] +speed.append([]) +speed.append([]) +speed.append([]) +speed.append([]) + for line in fileinput.input(): process(line) print("------------------------------------------------") fig=plt.figure() -plt.plot(t,ref[0]) -plt.plot(t,ref[1]) -plt.plot(t,ref[2]) -plt.plot(t,ref[3]) +plt.xlabel('time/s') +plt.ylabel('speed/upper') +plt.plot(t,speed[0],'green') +plt.plot(t,speed[1],'red') +plt.plot(t,speed[2],'blue') +plt.plot(t,speed[3],'magenta') +plt.legend('1234') +plt.plot(t,master,'black') +plt.title('multipump') plt.show() plt.close(fig)