Implemented logging
This commit is contained in:
parent
3e930c04a9
commit
5a6663c369
7 changed files with 123 additions and 7 deletions
10
receiver.py
10
receiver.py
|
|
@ -2,10 +2,14 @@ import send_test_data
|
|||
import json
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from logger import logwriter
|
||||
import time
|
||||
|
||||
data_store = []
|
||||
data_buffer = []
|
||||
times = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
|
||||
logpath = "log{}.txt".format(time.time())
|
||||
logs = True
|
||||
|
||||
try:
|
||||
for data in send_test_data.data_test_forever():
|
||||
|
|
@ -15,11 +19,13 @@ try:
|
|||
|
||||
# draw graph
|
||||
fig, ax = plt.subplots()
|
||||
if currentdata["V"] > 150:
|
||||
if currentdata["V"] > 160:
|
||||
ax.set_facecolor('red')
|
||||
ax.plot(times[:len(data_buffer)], data_buffer, 'k')
|
||||
warn = True
|
||||
else:
|
||||
ax.plot(times[:len(data_buffer)], data_buffer)
|
||||
warn = False
|
||||
ax.set_xlabel('Time [100 ms]')
|
||||
ax.set_ylabel('Value randomness')
|
||||
ax.set_title('Value randomness over time')
|
||||
|
|
@ -27,5 +33,7 @@ try:
|
|||
plt.yticks(np.arange(0, 257, 32))
|
||||
plt.show()
|
||||
plt.close()
|
||||
if logs:
|
||||
logwriter(currentdata["V"], logpath, warn)
|
||||
except KeyboardInterrupt:
|
||||
exit(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue