]> git.zndr.dk Git - dotfiles.git/commitdiff
Improved speed plot
authorJannik ZANDER <jzander@grundfos.com>
Thu, 9 Jun 2016 15:16:37 +0000 (17:16 +0200)
committerJannik ZANDER <jzander@grundfos.com>
Thu, 9 Jun 2016 15:16:37 +0000 (17:16 +0200)
.local/bin/genilog.py

index cb32c1a6b565efc7c0b047e3e4716521a963ed9d..e5b8278edea9527154e1f42d2fd4031359fc80ae 100755 (executable)
@@ -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)