Implemented logging, improved graph presentation
This commit is contained in:
parent
4967a82c13
commit
cf2711a936
1 changed files with 21 additions and 11 deletions
10
receiver.py
10
receiver.py
|
|
@ -7,6 +7,7 @@ data_store = []
|
||||||
data_buffer = []
|
data_buffer = []
|
||||||
times = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
|
times = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
|
||||||
|
|
||||||
|
try:
|
||||||
for data in send_test_data.data_test_forever():
|
for data in send_test_data.data_test_forever():
|
||||||
currentdata = json.loads(data)
|
currentdata = json.loads(data)
|
||||||
data_store.append(currentdata["V"])
|
data_store.append(currentdata["V"])
|
||||||
|
|
@ -14,8 +15,17 @@ for data in send_test_data.data_test_forever():
|
||||||
|
|
||||||
# draw graph
|
# draw graph
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
|
if currentdata["V"] > 150:
|
||||||
|
ax.set_facecolor('red')
|
||||||
|
ax.plot(times[:len(data_buffer)], data_buffer, 'k')
|
||||||
|
else:
|
||||||
ax.plot(times[:len(data_buffer)], data_buffer)
|
ax.plot(times[:len(data_buffer)], data_buffer)
|
||||||
|
ax.set_xlabel('Time [100 ms]')
|
||||||
|
ax.set_ylabel('Value randomness')
|
||||||
|
ax.set_title('Value randomness over time')
|
||||||
plt.xticks(np.arange(1, 21, 1))
|
plt.xticks(np.arange(1, 21, 1))
|
||||||
plt.yticks(np.arange(0, 257, 32))
|
plt.yticks(np.arange(0, 257, 32))
|
||||||
plt.show()
|
plt.show()
|
||||||
plt.close()
|
plt.close()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
exit(0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue