|
|
|
|
@ -109,21 +109,27 @@ import numpy as np |
|
|
|
|
def f(conn,q): |
|
|
|
|
ongoing = True |
|
|
|
|
reading = False |
|
|
|
|
serialPort = serial.Serial(port='COM7',baudrate=115200,timeout=1) |
|
|
|
|
while ongoing: |
|
|
|
|
if conn.poll(): |
|
|
|
|
rec = conn.recv() |
|
|
|
|
if rec == 'start': |
|
|
|
|
reading = True |
|
|
|
|
serialPort = serial.Serial(port='COM7',baudrate=115200,timeout=1) |
|
|
|
|
#if not serialPort.isOpen(): |
|
|
|
|
# print('open serial port') |
|
|
|
|
#serialPort.close() |
|
|
|
|
# serialPort = serial.Serial(port='COM7',baudrate=115200,timeout=1) |
|
|
|
|
#else: |
|
|
|
|
# print('already open') |
|
|
|
|
if rec == 'stop': |
|
|
|
|
reading = False |
|
|
|
|
serialPort.close() |
|
|
|
|
# serialPort.close() |
|
|
|
|
if rec == 'kill': |
|
|
|
|
serialPort.close() |
|
|
|
|
#print(data) |
|
|
|
|
ongoing=False |
|
|
|
|
if reading: |
|
|
|
|
if serialPort.inWaiting() > 0: |
|
|
|
|
if reading: |
|
|
|
|
msg = serialPort.readline() |
|
|
|
|
try: |
|
|
|
|
msg = msg.decode("Ascii") |
|
|
|
|
@ -131,7 +137,9 @@ def f(conn,q): |
|
|
|
|
print("failed") |
|
|
|
|
if msg.startswith("X"): |
|
|
|
|
q.put(msg) |
|
|
|
|
time.sleep(0.05) |
|
|
|
|
else: |
|
|
|
|
serialPort.read_all() |
|
|
|
|
#time.sleep(0.001) |
|
|
|
|
conn.close() |
|
|
|
|
|
|
|
|
|
def buttonPressed(button, conn,q): |
|
|
|
|
@ -143,6 +151,7 @@ def buttonPressed(button, conn,q): |
|
|
|
|
dString = dString.rstrip("\r\n") |
|
|
|
|
tmp = dString.split('\t') |
|
|
|
|
d = {} |
|
|
|
|
print(tmp) |
|
|
|
|
for elem in tmp: |
|
|
|
|
tmp1 = elem.split(':') |
|
|
|
|
d[tmp1[0]] = int(tmp1[1]) |
|
|
|
|
@ -157,7 +166,19 @@ def buttonPressed(button, conn,q): |
|
|
|
|
ax2 = figure.add_subplot(111) |
|
|
|
|
line = FigureCanvasTkAgg(figure,window) |
|
|
|
|
line.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH) |
|
|
|
|
df.plot(kind='line',legend=True,ax=ax2) |
|
|
|
|
#ax2.hline(173,df.shape[0]) |
|
|
|
|
#df.plot(kind='line',legend=True,ax=ax2, grid=True) |
|
|
|
|
#df.plot.line(y=173) |
|
|
|
|
ax2.plot(df['X'],'-b',label='X',) |
|
|
|
|
ax2.plot(df['Y'],'-y',label='Y') |
|
|
|
|
ax2.plot(df['Z'],'-g',label='Z') |
|
|
|
|
ax2.plot(df['sqr'],color='black',label='sqr') |
|
|
|
|
axl = ax2.twinx() |
|
|
|
|
axl.plot(df['F'],'-*',label='Freefallcounter') |
|
|
|
|
axl.legend() |
|
|
|
|
ax2.grid() |
|
|
|
|
ax2.axhline(y=173,color='red') |
|
|
|
|
ax2.legend() |
|
|
|
|
|
|
|
|
|
def onClosing(): |
|
|
|
|
if tk.messagebox.askokcancel("Quit","Wanna quit?"): |
|
|
|
|
|